HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HarpoAnalyseGainStudy.cxx
Go to the documentation of this file.
1 //
2 // File HarpoAnalyseGainStudy.cxx
3 //
12 #include "HarpoAnalyseGainStudy.h"
13 #include "HarpoConfig.h"
14 #include "HarpoDetSet.h"
15 #include "HarpoDebug.h"
16 #include "HarpoDccEvent.h"
17 #include "HarpoEvent.h"
18 #include "Pmm2Event.h"
19 #include "HarpoRecoEvent.h"
20 #include "HarpoSimEvent.h"
21 
22 #include "TFile.h"
23 #include "TStyle.h"
24 #include "TCanvas.h"
25 #include "TLatex.h"
26 #include "TGraph.h"
27 #include "TF1.h"
28 #include "TMath.h"
29 #include "TSystem.h"
30 
31 #include <cstdlib>
32 #include <cstring>
33 #include <cassert>
34 #include <fstream>
35 #include <iostream>
36 
37 ClassImp(HarpoAnalyseGainStudy);
38 
40  {
41  unsigned int nd; // number of detectors
43 
44  assert(hdr != NULL);
45  hdr->print();
46 
47  for (nd = 0; nd < gkNDetectors; nd++) {
48  // if (fEvt->isdataExist(nd)) {
49  HarpoDccMap *plane = fEvt->GetDccMap(nd);
50  if (plane != NULL )plane->print();
51  }
52  }
53 
55 {
56  // Bool_t drawEvent = kFALSE;
57  nEvents++;
58 
59  if(nEvents%100 == 0)
60  std::cout << "Event " << nEvents << std::endl;
61 
62 
63 
64 
65 
66 
67  if (gHDetSet->isExist(SIMDET)){
68 
69  // Process RAW data
70  Double_t qTotEvt = 0;
71  for(UInt_t ndet=0;ndet<2;ndet++) {
72  //std::cout << "NDET: " << ndet << " => " << gHDetSet->isExist(ndet) << std::endl;
73  if (!gHDetSet->isExist(ndet)) continue;
74  HarpoDccMap* m = fEvt->GetDccMap(ndet);
75  if ( m == NULL ) continue;
76  for(Int_t i=0;i<NADC;i++){ //Time bins
77  for(Int_t j=0;j<NCHAN;j++){ // Channels
78  Double_t q = m->GetData(j,i);// - 250.;
79  if(q <= -1000) continue;
80  qTotEvt += q;
81  }
82  }
83  }
84 
85 
86 
88  Int_t nElectronsTot = 0;
89  Int_t nIonTr = simEvt->GetNtracks();
90  for(Int_t i = 0; i<nIonTr; i++){
92  Int_t nPoints = tr->GetNpoints();
93  for(Int_t j = 0; j<nPoints; j++){
94  TpcSimIonisationPoint* point = tr->GetPoint(j);
95  nElectronsTot += point->GetNe();
96  }
97  }
98 
99  if(gHarpoDebug>1)
100  Info("process","%g / %d = %g",qTotEvt,nElectronsTot,qTotEvt/nElectronsTot);
101  hQoverNe->Fill(qTotEvt/nElectronsTot);
102 
103  }
104 
105 
106 
107 
108  // if (gHDetSet->isExist(PMM2)){
109  // Pmm2Event *anaEvt = static_cast<Pmm2Event *>(fEvt->GetDetEvent(PMM2));
110  // Int_t esize = anaEvt->GetHeader()->eventSize;
111  // Pmm2MesVect * pm = anaEvt->GetMesurements();
112  // Int_t hit[16];
113  // for(Int_t ch = 0; ch<16; ch++) hit[ch] = 0;
114  // for(Int_t imes=0;imes<esize;imes++) {
115  // int ch = pm->at(imes).getChNum(); // channel
116  // int q = pm->at(imes).getCharge(); // charge
117  // hit[ch] = 1;
118  // }
119  // if(!(hit[3] && hit[4] && hit[5] && hit[6]))
120  // return;
121  // }
122 
123  // Process Reconstructed data (clusters, tracks, matched tracks)
124  HarpoRecoEvent* reco = fEvt->GetRecoEvent();
125  TClonesArray* clArray = reco->GetClustersArray();
126  TClonesArray* trArray = reco->GetTracksArray();
127  // Int_t NtrX=reco->GetNtracksXEvt();
128  // Int_t NtrY=reco->GetNtracksYEvt();
129 
130 
131  // if(reco->GetNclXEvt()<20)
132  // return;
133  // if(reco->GetQtotXEvt()/reco->GetNclXEvt()<2000)
134  // return;
135 
136  // if(NtrX!=1) return;
137  // if(NtrY!=1) return;
138  const Int_t nTr = trArray->GetEntries();
139  if(gHarpoDebug>1)
140  Info("process","nTr = %d",nTr);
141  if(nTr != 2) return;
142  Int_t nCl = clArray->GetEntries();
143 
144  Double_t angle[2];
145  // Double_t angleCut = 100;//0.5;
146  for(Int_t itr = 0; itr<nTr; itr++){
147  HarpoRecoTracks* track = (HarpoRecoTracks*)trArray->At(itr);
148  Int_t plane = track->GetPlane();
149  angle[plane] = track->GetAngleTrack();
150  hAngleTrack[plane]->Fill(angle[plane]);
151  }
152 
153  if(gHarpoDebug>1)
154  Info("process","angles = %g %g",angle[0],angle[1]);
155  if(angle[0]==0) return;
156  if(angle[1]==0) return;
157 
158  // Double_t corr = 1./TMath::Cos(angle[0])/TMath::Cos(angle[1]);
159  // Double_t corr2 = TMath::Abs(1./TMath::Sin(angle[0])/TMath::Sin(angle[1]));
160  Double_t alpha = TMath::Abs(TMath::Cos(angle[0])*TMath::Cos(angle[1]));
161  Double_t alpha2 = TMath::Abs(TMath::Sin(angle[0])*TMath::Sin(angle[1]));
162  hAlpha->Fill(alpha);
163 
164  Double_t tmin[2], tmax[2];
165  tmin[0] = 512;
166  tmin[1] = 512;
167  tmax[0] = 0;
168  tmax[1] = 0;
169  const Int_t maxN = 20;
170  Double_t Qx[511][maxN], Qy[511][maxN];
171  // Double_t Wx[511][maxN], Wy[511][maxN];
172  Double_t X[511][maxN], Y[511][maxN];
173  Int_t Nx[511], Ny[511];
174  Double_t Qxtot[511], Qytot[511];
175  for(Int_t i = 0; i<511; i++) {
176  for(Int_t j = 0; j<maxN; j++) {
177  Qx[i][j] = 0;
178  Qy[i][j] = 0;
179  // Wx[i][j] = 0;
180  // Wy[i][j] = 0;
181  X[i][j] = 0;
182  Y[i][j] = 0;
183  }
184  Nx[i] = 0;
185  Ny[i] = 0;
186  Qxtot[i] = 0;
187  Qytot[i] = 0;
188  }
189  Double_t QtotX = 0, QtotY = 0;
190  for(Int_t icl = 0; icl<nCl; icl++){
191  HarpoRecoClusters* cluster = (HarpoRecoClusters*)clArray->At(icl);
192  // Int_t size = cluster->GetWidth();
193  // if(size<4) continue;
194  Int_t plane = cluster->GetPlane();
195  Int_t index = cluster->GetIndex();
196  // Int_t width = cluster->GetWidth();
197  Double_t mean = cluster->GetMean();
198  Double_t q = cluster->GetQ();
199 
200  if(cluster->GetType()==CCLUSTER) {
201  if(!(TMath::Abs(fmod(mean+16.5,33)-11.5)<5))
202  hQclVsAlpha2[plane]->Fill(alpha,q*alpha2);
203  if(alpha<0.05) continue;
204  if(alpha>0.4) continue;
205  if(!(TMath::Abs(fmod(index+16.5,33)-11.5)<5))
206  hQclVsT2[plane]->Fill(mean,q*alpha2);
207  hQclVsCh2[plane]->Fill(index,q*alpha2);
208  }
209 
210  if(cluster->GetType()!=TCLUSTER) continue;
211  if(index<tmin[plane]) tmin[plane] = index;
212  if(index>tmax[plane]) tmax[plane] = index;
213  hMean[plane]->Fill(mean);
214  if(plane==XPLANE){
215  QtotX += q;
216  Qxtot[index] += q;
217  if(Nx[index]<maxN){
218  Qx[index][Nx[index]] = q;
219  // Wx[index][Nx[index]] = width;
220  X[index][Nx[index]] = mean;
221  Nx[index]++;
222  }
223  }
224  if(plane==YPLANE){
225  QtotY += q;
226  Qytot[index] += q;
227  if(Ny[index]<maxN){
228  Qy[index][Ny[index]] = q;
229  // Wy[index][Ny[index]] = width;
230  Y[index][Ny[index]] = mean;
231  Ny[index]++;
232  }
233  }
234  if(!(TMath::Abs(fmod(mean+16.5,33)-11.5)<5))
235  hMeanCut[plane]->Fill(mean);
236  // hQclVsAngle[plane]->Fill(index,alpha,q*corr);
237  // hQcl2D[plane]->Fill(index,q);
238  // hQcl[plane]->Fill(index,q);
239  if(!(TMath::Abs(fmod(mean+16.5,33)-11.5)<5))
240  hQclVsAlpha[plane]->Fill(alpha,q*alpha);
241  if(alpha<0.5) continue;
242  if(alpha>0.95) continue;
243  if(!(TMath::Abs(fmod(mean+16.5,33)-11.5)<5))
244  hQclVsT[plane]->Fill(index,q*alpha);
245  hQclVsCh[plane]->Fill(mean,q*alpha);
246 
247  }
248 
249  for(Int_t i = 0; i<511; i++){
250  for(Int_t j = 0; j<Nx[i]; j++){
251  if(Qx[i][j] == 0) continue;
252  hRatioClVsX->Fill(X[i][j],Qx[i][j]/Qytot[i]);
253  // Qxtot += Qx[i][j];
254  for(Int_t k = 0; k<Ny[i]; k++){
255  if(Qy[i][k] == 0) continue;
256  //fNtuple->Fill(i,Qx[i][j],Qy[i][k],Wx[i][j],Wy[i][k],Nx[i],Ny[i],X[i][j],Y[i][k],alpha,QtotX,QtotY);
257  hRatioClVsT->Fill(i,Qx[i][k]/Qy[i][j]);
258  if(j!=0) continue;
259  hRatioClVsY->Fill(Y[i][k],Qy[i][k]/Qxtot[i]);
260  }
261  }
262  if(Qxtot[i] == 0) continue;
263  if(Qytot[i] == 0) continue;
264  hQVsT[0]->Fill(i,Qxtot[i]*alpha);
265  hQVsT[1]->Fill(i,Qytot[i]*alpha);
266  if(i>tmin[0]+10 && i<tmax[0]-10)
267  hQVsTcut[0]->Fill(i,Qxtot[i]*alpha);
268  if(i>tmin[1]+10 && i<tmax[1]-10)
269  hQVsTcut[1]->Fill(i,Qytot[i]*alpha);
270 
271  hQVsAlpha[0]->Fill(alpha,Qxtot[i]*alpha);
272  hQVsAlpha[1]->Fill(alpha,Qytot[i]*alpha);
273  // fNtuple->Fill(i,Qxtot[i],Qytot[i],Wx[i][0],Wy[i][0],Nx[i],Ny[i],X[i][0],Y[i][0],alpha,QtotX,QtotY);
274  hRatioVsAngle->Fill(i,alpha,Qxtot[i]/Qytot[i]);
275  }
276  //std::cout << "PROCESSING RAW DATA" << std::endl;
277 
278 
279 
280 
281 
282 
283 
284 
285  // Info("process","Check Sim");
286  if (gHDetSet->isExist(SIMDET)){
287  // Info("process","Sim Data exists");
289 
290  TpcSimMCEvent* mcEvent = (TpcSimMCEvent*)simEvt->GetMCEvent();
291  TpcSimMCTrack* mcTrack = mcEvent->GetTrack(0);
292  Double_t pz = mcTrack->GetPz();
293  // Info("process","%p",simEvt);
294 
295  Int_t nIonTr = simEvt->GetNtracks();
296  // Info("process","%p %d",simEvt, nIonTr);
297  TH1F* hTmp = new TH1F("hTmp","",512,0,512);
298  for(Int_t i = 0; i<nIonTr; i++){
299  // Info("process","%d", i);
300  TpcSimIonisationTrack* tr = simEvt->GetIonisationTrack(i);
301  Int_t nPoints = tr->GetNpoints();
302  for(Int_t j = 0; j<nPoints; j++){
303  TpcSimIonisationPoint* point = tr->GetPoint(j);
304  hTmp->Fill(point->GetZ(),point->GetNe()*pz);
305  hNeVsLambda->Fill(point->GetZ()/pz,point->GetNe());
306  }
307  }
308  for(Int_t i = 0; i<512; i++)
309  hNeVsZSim1->Fill(hTmp->GetXaxis()->GetBinCenter(i+1),400*hTmp->GetBinContent(i+1)/1.);
310  hTmp->Rebin(2);
311  for(Int_t i = 0; i<256; i++)
312  hNeVsZSim2->Fill(hTmp->GetXaxis()->GetBinCenter(i+1),400*hTmp->GetBinContent(i+1)/2.);
313  hTmp->Rebin(2);
314  for(Int_t i = 0; i<128; i++)
315  hNeVsZSim3->Fill(hTmp->GetXaxis()->GetBinCenter(i+1),400*hTmp->GetBinContent(i+1)/4.);
316  hTmp->Rebin(2);
317  for(Int_t i = 0; i<64; i++)
318  hNeVsZSim4->Fill(hTmp->GetXaxis()->GetBinCenter(i+1),400*hTmp->GetBinContent(i+1)/8.);
319 
320  hTmp->Delete();
321  }
322 
323  // Process RAW data
324  // Double_t sigQ[NADC][2];
325  // for(Int_t ndet=0;ndet<gkNDetectors;ndet++) {
326  // for(UInt_t ndet=0;ndet<2;ndet++) {
327  // //std::cout << "NDET: " << ndet << " => " << gHDetSet->isExist(ndet) << std::endl;
328  // if (!gHDetSet->isExist(ndet)) continue;
329  // ULong_t timestamp = fEvt->GetDetEvent(ndet)->GetTimeStamp();
330  // HarpoDccMap* m = fEvt->GetDccMap(ndet);
331  // if ( m == NULL ) continue;
332  // Double_t qTotEvt = 0;
333  // Int_t nCl = 0;
334  // for(Int_t i=0;i<NADC;i++){ //Time bins
335  // if(tmin[ndet]>100 && i<tmin[ndet]+20) continue;
336  // if(tmax[ndet]<400 && i>tmax[ndet]-20) continue;
337  // Double_t qTot = 0;
338  // Double_t sigmaQ = 0;
339  // for(Int_t j=0;j<NCHAN;j++){ // Channels
340  // Double_t q = m->GetData(j,i);// - 250.;
341  // if(q<2) continue;
342  // qTot += q;
343  // sigmaQ += q*q;
344  // hPosVsAngle[ndet]->Fill(i,j,alpha);
345  // hMap[ndet]->Fill(i,j,q);
346  // }
347  // if(qTot>0){
348  // nCl++;
349  // hQraw[ndet]->Fill(i,qTot);
350  // // hQrawVsAngle[ndet]->Fill(i,alpha,qTot*corr);
351  // qTot *= alpha;
352  // hQrawCut[ndet]->Fill(i,qTot);
353  // }
354  // qTotEvt += qTot;
355  // // if(angle[ndet]>angleCut && angle[ndet]<TMath::Pi()-angleCut) continue;
356  // // if(alpha>angleCut && alpha<TMath::Pi()-angleCut) continue;
357  // // if(qTot>0)
358  // // hQrawCut[ndet]->Fill(i,qTot);
359  // // // sigmaQ /= NCHAN;
360  // // // qTot /= NCHAN;
361  // // sigmaQ -= qTot*qTot;
362  // // sigQ[i][ndet] = sigmaQ;
363  // // if(sigmaQ)
364  // // hSigmaQ[ndet]->Fill(sigmaQ);
365  // }
366  // if(nCl)
367  // qTotEvt /= nCl;
368  // hQ[ndet]->Fill(qTotEvt);
369  // }
370 
371 
372  // for(Int_t i=0;i<NADC;i++)
373  // hSigmaQXY->Fill(sigQ[i][0],sigQ[i][1]);
374 
375 
376 
377  // return;
378 
379 
380 
381  // hTminX->Fill(tmin[0]);
382  // hTminY->Fill(tmin[1]);
383  // hTmaxX->Fill(tmax[0]);
384  // hTmaxY->Fill(tmax[1]);
385  // hTminmaxX->Fill(tmin[0],tmax[0]);
386  // hTminmaxY->Fill(tmin[1],tmax[1]);
387  // hTdriftX->Fill(tmax[0]-tmin[0]);
388  // hTdriftY->Fill(tmax[1]-tmin[1]);
389 
390 
391 
392  if(nEvents%100 == 0)
393  std::cout << "Event " << nEvents << " done" << std::endl;
394  }
395 
397  {
398 
399  hAlpha = new TH1F("hAlpha",";track angle",100,0,1);
400 
401  // Initialise histograms here
402  hAngleTrack[0] = new TH1F("hAngleTrackX",";track angle",100,0,2*TMath::Pi());
403  hAngleTrack[1] = new TH1F("hAngleTrackY",";track angle",100,0,2*TMath::Pi());
404 
405  hMean[0] = new TH1F("hMeanX",";X",300,0,300);
406  hMean[1] = new TH1F("hMeanY",";Y",300,0,300);
407  hMeanCut[0] = new TH1F("hMeanCutX",";X",300,0,300);
408  hMeanCut[1] = new TH1F("hMeanCutY",";Y",300,0,300);
409 
410  hRatioVsAngle = new TH3F("hRatioVsAngle",";t;#alpha;Q_{x}/Q_{y}",512,0,512,100,0,1,500,0,5);
411 
412  fNeventCut[0] = 0;
413  fNeventCut[1] = 0;
414 
415  hQoverNe = new TH1F("hQoverNe","",1000,0,1000);
416 
417 
418  fNtuple = new TNtuple("fNtuple","ntuple","t:Qx:Qy:Wx:Wy:Nx:Ny:X:Y:alpha:QtotX:QtotY");
419  fNtuple->SetDirectory(0);
420 
421  const Int_t nbinsQ = 500;
422  Double_t xminQ = 10;
423  Double_t xmaxQ = 1e5;
424  Double_t logxminQ = TMath::Log(xminQ);
425  Double_t logxmaxQ = TMath::Log(xmaxQ);
426  Double_t binwidthQ = (logxmaxQ-logxminQ)/nbinsQ;
427  Double_t xbinsQ[nbinsQ+1];
428  xbinsQ[0] = xminQ;
429  for (Int_t i=1;i<=nbinsQ;i++)
430  xbinsQ[i] = TMath::Exp(logxminQ+i*binwidthQ);
431  hQ[0] = new TH1F("hQX",";Q_{cl}",nbinsQ,xbinsQ);
432  hQ[1] = new TH1F("hQY",";Q_{cl}",nbinsQ,xbinsQ);
433  hQclVsT[0] = new TH2F("hQclVsTX",";t;Q_{cl}",512,0,512,nbinsQ,xbinsQ);
434  hQclVsT[1] = new TH2F("hQclVsTY",";t;Q_{cl}",512,0,512,nbinsQ,xbinsQ);
435  hQclVsCh[0] = new TH2F("hQclVsChX",";channel;Q_{cl}",304,0,304,nbinsQ,xbinsQ);
436  hQclVsCh[1] = new TH2F("hQclVsChY",";channel;Q_{cl}",304,0,304,nbinsQ,xbinsQ);
437  hQclVsAlpha[0] = new TH2F("hQclVsAlphaX",";#alpha;Q",100,0,1,nbinsQ,xbinsQ);
438  hQclVsAlpha[1] = new TH2F("hQclVsAlphaY",";#alpha;Q",100,0,1,nbinsQ,xbinsQ);
439  hQclVsT2[0] = new TH2F("hQclVsT2X",";t;Q_{cl}",512,0,512,nbinsQ,xbinsQ);
440  hQclVsT2[1] = new TH2F("hQclVsT2Y",";t;Q_{cl}",512,0,512,nbinsQ,xbinsQ);
441  hQclVsCh2[0] = new TH2F("hQclVsCh2X",";channel;Q_{cl}",304,0,304,nbinsQ,xbinsQ);
442  hQclVsCh2[1] = new TH2F("hQclVsCh2Y",";channel;Q_{cl}",304,0,304,nbinsQ,xbinsQ);
443  hQclVsAlpha2[0] = new TH2F("hQclVsAlpha2X",";#alpha;Q",100,0,1,nbinsQ,xbinsQ);
444  hQclVsAlpha2[1] = new TH2F("hQclVsAlpha2Y",";#alpha;Q",100,0,1,nbinsQ,xbinsQ);
445 
446  hNeVsZSim1 = new TH2F("hNeVsZSim1",";Z [mm];N_{electrons}",512,0,512,nbinsQ,xbinsQ);
447  hNeVsZSim2 = new TH2F("hNeVsZSim2",";Z [mm];N_{electrons}",256,0,512,nbinsQ,xbinsQ);
448  hNeVsZSim3 = new TH2F("hNeVsZSim3",";Z [mm];N_{electrons}",128,0,512,nbinsQ,xbinsQ);
449  hNeVsZSim4 = new TH2F("hNeVsZSim4",";Z [mm];N_{electrons}",64,0,512,nbinsQ,xbinsQ);
450  hNeVsLambda = new TH2F("hNeVsLambda",";Z [mm];N_{electrons}",1000,0,1000,nbinsQ,xbinsQ);
451 
452  hQVsT[0] = new TH2F("hQVsTX",";channel;Q_{cl}",512,0,512,nbinsQ,xbinsQ);
453  hQVsT[1] = new TH2F("hQVsTY",";channel;Q_{cl}",512,0,512,nbinsQ,xbinsQ);
454  hQVsTcut[0] = new TH2F("hQVsTcutX",";channel;Q_{cl}",512,0,512,nbinsQ,xbinsQ);
455  hQVsTcut[1] = new TH2F("hQVsTcutY",";channel;Q_{cl}",512,0,512,nbinsQ,xbinsQ);
456  hQVsAlpha[0] = new TH2F("hQVsAlphaX",";#alpha;Q",100,0,1,nbinsQ,xbinsQ);
457  hQVsAlpha[1] = new TH2F("hQVsAlphaY",";#alpha;Q",100,0,1,nbinsQ,xbinsQ);
458 
459  hRatioClVsX = new TH2F("hRatioClVsX",";X;Q",304,0,304,100,0,5);
460  hRatioClVsY = new TH2F("hRatioClVsY",";Y;Q",304,0,304,100,0,5);
461  hRatioClVsT = new TH2F("hRatioClVsT",";t;Q",512,0,512,100,0,5);
462 
463 
464  // const Int_t nbins2 = 500;
465  // Double_t xmin2 = 1;
466  // Double_t xmax2 = 1e6;
467  // Double_t logxmin2 = TMath::Log(xmin2);
468  // Double_t logxmax2 = TMath::Log(xmax2);
469  // Double_t binwidth2 = (logxmax2-logxmin2)/nbins2;
470  // Double_t xbins2[nbins2+1];
471  // xbins2[0] = xmin2;
472  // for (Int_t i=1;i<=nbins2;i++)
473  // xbins2[i] = TMath::Exp(logxmin2+i*binwidth2);
474  // hSigmaQ[0] = new TH1F("hSigmaQX",";#sigma_{Q}",nbins2,xbins2);
475  // hSigmaQ[1] = new TH1F("hSigmaQY",";#sigma_{Q}",nbins2,xbins2);
476  // hSigmaQXY = new TH2F("hSigmaQXY",";#sigma_{Q}",nbins2,xbins2,nbins2,xbins2);
477 
478  // const Int_t nbinsPrf = 100;
479  // Double_t xminPrf = 1e-3;
480  // Double_t xmaxPrf = 2;
481  // Double_t logxminPrf = TMath::Log(xminPrf);
482  // Double_t logxmaxPrf = TMath::Log(xmaxPrf);
483  // Double_t binwidthPrf = (logxmaxPrf-logxminPrf)/nbinsPrf;
484  // Double_t xbinsPrf[nbinsPrf+1];
485  // xbinsPrf[0] = xminPrf;
486  // for (Int_t i=1;i<=nbinsPrf;i++)
487  // xbinsPrf[i] = xminPrf + TMath::Exp(logxminPrf+i*binwidthPrf);
488  // hPrf[0] = new TH2F("hPrf_X",";",1000,-10,10,nbinsPrf,xbinsPrf);
489  // hPrf[1] = new TH2F("hPrf_Y",";",1000,-10,10,nbinsPrf,xbinsPrf);
490  // hPrf2[0] = new TH2F("hPrf2_X",";",1000,-10,10,nbinsPrf,xbinsPrf);
491  // hPrf2[1] = new TH2F("hPrf2_Y",";",1000,-10,10,nbinsPrf,xbinsPrf);
492  // hPrfT[0] = new TH2F("hPrfT_X",";",200,-20,30,nbinsPrf,xbinsPrf);
493  // hPrfT[1] = new TH2F("hPrfT_Y",";",200,-20,30,nbinsPrf,xbinsPrf);
494  // hPrfTcut[0] = new TH2F("hPrfTcut_X",";",200,-20,30,nbinsPrf,xbinsPrf);
495  // hPrfTcut[1] = new TH2F("hPrfTcut_Y",";",200,-20,30,nbinsPrf,xbinsPrf);
496 
497 
498 
499  // gTimeStampVsEvent[0] = new TGraph();
500  // gTimeStampVsEvent[1] = new TGraph();
501 
502  }
503 
504 void HarpoAnalyseGainStudy::Save(char * /* mode */)
505  {
506  OpenHistFile("gain");
507 
508  // Save histograms here
509  hAlpha->Write();
510  hAngleTrack[0]->Write();
511  hAngleTrack[1]->Write();
512  hRatioVsAngle->Write();
513  hQ[0]->Write();
514  hQ[1]->Write();
515 
516  hMean[0]->Write();
517  hMean[1]->Write();
518  hMeanCut[0]->Write();
519  hMeanCut[1]->Write();
520 
521  hQVsT[0]->Write();
522  hQVsT[1]->Write();
523  hQVsTcut[0]->Write();
524  hQVsTcut[1]->Write();
525  hQVsAlpha[0]->Write();
526  hQVsAlpha[1]->Write();
527  hQclVsT[0]->Write();
528  hQclVsT[1]->Write();
529  hQclVsCh[0]->Write();
530  hQclVsCh[1]->Write();
531  hQclVsAlpha[0]->Write();
532  hQclVsAlpha[1]->Write();
533  hQclVsT2[0]->Write();
534  hQclVsT2[1]->Write();
535  hQclVsCh2[0]->Write();
536  hQclVsCh2[1]->Write();
537  hQclVsAlpha2[0]->Write();
538  hQclVsAlpha2[1]->Write();
539  hRatioClVsX->Write();
540  hRatioClVsY->Write();
541  hRatioClVsT->Write();
542 
543  hQoverNe->Write();
544  hNeVsZSim1->Write();
545  hNeVsZSim2->Write();
546  hNeVsZSim3->Write();
547  hNeVsZSim4->Write();
548  hNeVsLambda->Write();
549 
550  }
551 
552 
553 
554 Double_t HarpoAnalyseGainStudy::TruncSigma(TArrayD* vect, Double_t &truncS, Double_t &truncM, Double_t tl, Double_t th)
555 {
556  //
557  // Calculates the truncated mean mean of the non zero value in vect
558  // The truncation is done on the 100*tl% lowest and 100*(1-th) highest value
559  //
560  // debug(2,"truncated mean");
561 
562 
563  Int_t size = vect->GetSize();
564  Double_t truncMean = 0;
565  Double_t truncSigma = 0;
566  Int_t* index = new Int_t[size];
567  TMath::Sort(size,vect->GetArray(),index,kFALSE);
568  Int_t t = 0, tLow, tHigh;
569 
570 
571  while(vect->At(index[t])<10&&t<size-1) t++;
572  tLow = TMath::FloorNint(t + (size - t)*tl);
573  tHigh = TMath::FloorNint(t + (size - t)*th);
574 
575  for(Int_t tind = tLow; tind<tHigh; tind++){
576  truncMean += vect->At(index[tind]);
577  truncSigma += vect->At(index[tind])*vect->At(index[tind]);
578  }
579 
580  // if(tHigh-tLow == 0) return 0;
581  if(tHigh-tLow < 15) return 0;
582 
583  truncMean /= (tHigh-tLow);
584  truncSigma /= (tHigh-tLow);
585  truncSigma -= truncMean*truncMean;
586 
587  truncM = truncMean;
588  truncS = TMath::Sqrt(truncSigma);
589 
590  return truncSigma;
591 }
TpcSimIonisationTrack * GetIonisationTrack(Int_t iTr)
HarpoRecoEvent * GetRecoEvent()
Definition: HarpoEvent.h:46
#define XPLANE
Definition: HarpoConfig.h:24
#define NCHAN
Definition: HarpoDccMap.h:16
Double_t GetMean()
Double_t GetPz()
Definition: TpcSimMCEvent.h:32
Int_t GetNtracks()
Definition: HarpoSimEvent.h:54
Double_t GetData(Int_t i, Int_t j)
Set/Get Data Cell.
Definition: HarpoDccMap.cxx:84
Bool_t isExist(ULong_t det)
Detecror date exist //! Number of Real Detectors.
Definition: HarpoDetSet.h:33
Double_t GetAngleTrack()
Track object, containing position, angle, charge and quality information.
Object containing the reconstruction information for one event (with array of HarpoRecoClusters Harpo...
virtual void print()
TpcSimIonisationPoint * GetPoint(Int_t i)
FullEvent Header not scecific to the detectors The class is ....
A class store HARPO row DCC event data and header. End provide access metods to the row data...
Definition: HarpoSimEvent.h:24
virtual void print()
Cluster object, containing position, charge and quality information.
TFile * OpenHistFile(const char *ananame)
unpacked dcc data The class contains the data map for DCC or Feminos The data is stored as a 2D TMatr...
Definition: HarpoDccMap.h:29
HarpoDetEvent * GetDetEvent(Long_t plane=XDCC)
Definition: HarpoEvent.cxx:93
Data from Keller temperuture and pressure sensors.
Definition: HarpoDet.h:22
void Save(char *mode=NULL)
Double_t TruncSigma(TArrayD *vect, Double_t &truncS, Double_t &truncM, Double_t tl, Double_t th)
Redefine empty default.
Analysis of charge distributions from event with single track Requires tracking information.
TpcSimMCTrack * GetTrack(Int_t i)
Definition: TpcSimMCEvent.h:91
#define NADC
Definition: HarpoDccMap.h:18
#define TCLUSTER
Long64_t gHarpoDebug
Definition: HarpoDebug.cxx:9
#define YPLANE
Definition: HarpoConfig.h:25
TpcSimMCEvent * GetMCEvent()
Definition: HarpoSimEvent.h:57
const ULong_t tmax
HarpoEventHeader * GetHeader()
Definition: HarpoEvent.cxx:80
HarpoEvent * fEvt
Definition: HarpoAnalyse.h:70
ULong_t nEvents
Definition: HarpoAnalyse.h:75
const ULong_t gkNDetectors
Definition: HarpoDet.h:14
#define CCLUSTER
void print()
Ovreloaded medod whic do all job.
TClonesArray * GetTracksArray()
HarpoDccMap * GetDccMap(Long_t plane=XDCC)
Definition: HarpoEvent.cxx:108
TClonesArray * GetClustersArray()
R__EXTERN HarpoDetSet * gHDetSet
Definition: HarpoDetSet.h:71