1 void SSDrecpointTest (Int_t evNumber1=0,Int_t evNumber2=0)
2 //void SSDrecpointTest (Int_t evNumber1=0,Int_t evNumber2=999)
4 /////////////////////////////////////////////////////////////////////////
5 // This macro is a small example of a ROOT macro
6 // illustrating how to read the output of GALICE
7 // and fill some histograms.
9 // Root > .L anal.C //this loads the macro in memory
10 // Root > anal(); //by default process first event
11 // Root > anal(2); //process third event
14 <img src="gif/anal.gif">
17 /////////////////////////////////////////////////////////////////////////
19 // Dynamically link some shared libs
21 if (gClassTable->GetID("AliRun") < 0) {
22 gROOT->LoadMacro("loadlibs.C");
29 // Connect the Root Galice file containing Geometry, Kine and Hits
30 //TString *str = new TString("galice.root");
31 //TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(str->Data());
32 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
33 //if (!file) file = new TFile(str->Data(),"UPDATE");
34 if (!file) file = new TFile("galice.root");
37 // Get AliRun object from file or create it if not on file
39 gAlice = (AliRun*)file->Get("gAlice");
40 if (gAlice) printf("AliRun object found on file\n");
41 if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
45 // -------------- Create ntuples --------------------
91 ntuple = new TTree("ntuple","Demo ntuple");
92 ntuple->Branch("lay",&ntuple_st.lay,"lay/I");
93 ntuple->Branch("nxP",&ntuple_st.nxP,"nxP/I");
94 ntuple->Branch("nxN",&ntuple_st.nxN,"nxN/I");
95 ntuple->Branch("hitprim",&ntuple_st.hitprim,"hitprim/I");
96 ntuple->Branch("partcode",&ntuple_st.partcode,"partcode/I");
97 ntuple->Branch("ntrover",&ntuple_st.ntrover,"ntrover/I");
98 ntuple->Branch("x",&ntuple_st.x,"x/F");
99 ntuple->Branch("z",&ntuple_st.z,"z/F");
100 ntuple->Branch("dx",&ntuple_st.dx,"dx/F");
101 ntuple->Branch("dz",&ntuple_st.dz,"dz/F");
102 ntuple->Branch("pmod",&ntuple_st.pmod,"pmod/F");
105 ntuple1 = new TTree("ntuple1","Demo ntuple1");
106 ntuple1->Branch("lay",&ntuple1_st.lay,"lay/I");
107 ntuple1->Branch("lad",&ntuple1_st.lad,"lad/I");
108 ntuple1->Branch("det",&ntuple1_st.det,"det/I");
109 ntuple1->Branch("nxP",&ntuple1_st.nxP,"nxP/I");
110 ntuple1->Branch("nxN",&ntuple1_st.nxN,"nxN/I");
111 ntuple1->Branch("qclP",&ntuple1_st.qclP,"qclP/F");
112 ntuple1->Branch("qclN",&ntuple1_st.qclN,"qclN/F");
113 ntuple1->Branch("qrec",&ntuple1_st.qrec,"qrec/F");
114 ntuple1->Branch("qcut",&ntuple1_st.qcut,"qcut/F");
115 ntuple1->Branch("dx",&ntuple1_st.dx,"dx/F");
116 ntuple1->Branch("dz",&ntuple1_st.dz,"dz/F");
117 ntuple1->Branch("noverlaps",&ntuple1_st.noverlaps,"noverlaps/I");
118 ntuple1->Branch("noverprim",&ntuple1_st.noverprim,"noverprim/I");
119 ntuple1->Branch("ntrover",&ntuple1_st.ntrover,"ntrover/I");
122 ntuple2 = new TTree("ntuple2","Demo ntuple2");
123 ntuple2->Branch("nxP",&ntuple2_st.nxP,"nxP/I");
124 ntuple2->Branch("nxN",&ntuple2_st.nxN,"nxN/I");
125 ntuple2->Branch("x",&ntuple2_st.x,"x/F");
126 ntuple2->Branch("z",&ntuple2_st.z,"z/F");
129 // Create Histogramms
131 TH1F *NxP5 = new TH1F("NxP5","P cluster size for layer 5",20,0.,20.);
132 TH1F *NxN5 = new TH1F("NxN5","N cluster size for layer 5",20,0.,20.);
133 TH1F *NxP6 = new TH1F("NxP6","P cluster size for layer 6",20,0.,20.);
134 TH1F *NxN6 = new TH1F("NxN6","N cluster size for layer 6",20,0.,20.);
136 TH1F *Xres5 = new TH1F("Xres5","Xrec and Xgen difference (micr) for layers 5",100,-200.,200.);
137 TH1F *Xres6 = new TH1F("Xres6","Xrec and Xgen difference (micr) for layers 6",100,-200.,200.);
138 TH1F *Zres5 = new TH1F("Zres5","Zrec and Zgen difference (micr) for layers 5",100,-8000.,8000.);
139 TH1F *Zres6 = new TH1F("Zres6","Zrec and Zgen difference (micr) for layers 6",100,-8000.,8000.);
140 TH1F *Path5 = new TH1F("Path5","Path length in Si",100,0.,600.);
141 TH1F *Path6 = new TH1F("Path6","Path length in Si",100,0.,600.);
142 TH1F *dEdX = new TH1F("dEdX","dEdX (KeV)",100,0.,500.);
143 TH2F *adcPadcN5all = new TH2F("adcPadcN5all","adcP/N correlation for lay5",100,0.,200.,100,0.,200.);
144 TH2F *adcPadcN6all = new TH2F("adcPadcN6all","adcP/N correlation for lay6",100,0.,200.,100,0.,200.);
145 TH2F *adcPadcN5cut = new TH2F("adcPadcN5cut","adcP/N correlation for lay5 and cut of P-N signas",100,0.,200.,100,0.,200.);
146 TH2F *adcPadcN6cut = new TH2F("adcPadcN6cut","adcP/N correlation for lay6 and cut of P-N signals",100,0.,200.,100,0.,200.);
147 //-----------------------------------------------------------
152 for (int nev=0; nev<= evNumber2; nev++) {
153 Int_t nparticles = gAlice->GetEvent(nev);
154 cout << "nev " << nev <<endl;
155 //cout << "nparticles " << nparticles <<endl;
156 if (nev < evNumber1) continue;
157 if (nparticles <= 0) return;
159 TTree *TH = gAlice->TreeH();
160 Int_t ntracks = TH->GetEntries();
161 cout<<"all entries to GEANT(charged and neutral) "<<ntracks<<endl;
163 // Get pointers to Alice detectors and Digits containers
164 AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
165 TClonesArray *Particles = gAlice->Particles();
169 // fill modules with sorted by module hits
171 ITS->InitModules(-1,nmodules);
172 ITS->FillModules(nev,evNumber2,nmodules," "," ");
174 //get pointer to modules array
175 TObjArray *ITSmodules = ITS->GetModules();
178 // get the Tree for clusters
180 TTree *TC=ITS->TreeC();
181 Int_t nent=TC->GetEntries();
182 printf("Found %d entries in the TreeC (full number of the modules)\n",nent);
183 TTree *TR = gAlice->TreeR();
185 AliITSgeom *geom = ITS->GetITSgeom();
188 Int_t first0 = geom->GetStartDet(0); // SPD
189 Int_t last0 = geom->GetLastDet(0); // SPD
190 Int_t first1 = geom->GetStartDet(1); // SDD
191 Int_t last1 = geom->GetLastDet(1); // SDD
192 Int_t first2 = geom->GetStartDet(2); // SSD
193 Int_t last2 = geom->GetLastDet(2); // SSD
195 // For the SPD: first0 = 0, last0 = 239 (240 modules);
196 // for the SDD: first1 = 240, last1 = 499 (260 modules);
197 // for the SSD: first2 = 500, last2 = 2197 (1698 modules).
199 printf("det type %d first0, last0 %d %d \n",0,first0,last0);
200 printf("det type %d first1, last1 %d %d \n",1,first1,last1);
201 printf("det type %d first2, last2 %d %d \n",2,first2,last2);
204 AliITSDetType *iDetType=ITS->DetType(2);
205 AliITSsegmentationSSD *seg2=(AliITSsegmentationSSD*)iDetType->GetSegmentationModel();
206 //AliITSresponseSSD *res2 = (AliITSresponseSSD*)iDetType->GetResponseModel();
208 printf("SSD dimensions %f %f %f \n",seg2->Dx(),seg2->Dz(),seg2->Dy());
209 printf("SSD nstrips %d %d \n",seg2->Npz(),seg2->Npx());
210 Float_t ylim = seg2->Dy()/2 - 12;
214 for (Int_t idettype=0;idettype<3;idettype++) {
216 TClonesArray *ITSclu = ITS->ClustersAddress(idettype);
217 TClonesArray *ITSrec = ITS->RecPoints();
218 //printf ("ITSrec %p \n",ITSrec);
219 //printf ("ITSclu %p \n",ITSclu);
221 if (idettype != 2) continue;
225 //for (mod=first2; mod<last2+1; mod++) { // for the "ALL" option
226 for (mod=0; mod<last2-first2+1; mod++) { //for the "SSD" option
228 AliITSmodule *Mod = (AliITSmodule *)ITSmodules->At(mod+first2);
229 // for the "SSD" option
231 //AliITSmodule *Mod = (AliITSmodule *)ITSmodules->At(mod);
232 // for the "ALL" option
234 geom->GetModuleId(mod,lay,lad,det);
236 Int_t nhits = Mod->GetNhits();
237 //if(nhits) printf("module nhits %d %d\n",mod,nhits);
240 ITS->ResetClusters();
242 Int_t nclust = ITSclu->GetEntries();
243 if (!nclust) continue;
245 ITS->ResetRecPoints();
247 Int_t nrecp = ITSrec->GetEntries();
248 //if (nrecp) printf("Found %d rec points for module %d\n",nrecp,mod);
249 if (!nrecp) continue;
254 cout <<" module,nrecp,nclust,nhits ="<<mod<<","<<nrecp<<","<<nclust<<","<<nhits<< endl;
256 // ---------------- cluster/recpoint/hit analysis ---------------------
259 Float_t pathInSSD = 300.;
261 // ---- Recpoint loop
262 for (Int_t pnt=0;pnt<nrecp;pnt++) {
264 itsPnt = (AliITSRecPoint*)ITSrec->At(pnt);
265 if(!itsPnt) continue;
266 itsClu = (AliITSRawClusterSSD*)ITSclu->At(pnt);
267 if(!itsClu) continue;
269 Int_t nxP = itsClu->fMultiplicity;
270 Int_t nxN = itsClu->fMultiplicityN;
271 Int_t ntrover = itsClu->fNtracks;
272 Float_t qclP = itsClu->fSignalP; // in ADC
273 Float_t qclN = itsClu->fSignalN; // in ADC
274 Float_t dq = TMath::Abs(qclP - qclN);
275 Float_t xrec = 10000*itsPnt->GetX();
276 Float_t zrec = 10000*itsPnt->GetZ();
277 Float_t qrec = itsPnt->GetQ(); // in ADC, maximum from fSignalP/N
278 Float_t qcut = dq/qrec;
279 //Float_t dedx = itsPnt->GetdEdX(); // in KeV (ADC * 2.16)
280 Float_t dedx = itsPnt->fdEdX; // in KeV (ADC * 2.16)
282 Int_t tr1 = itsPnt->GetLabel(ii);
284 Int_t tr2 = itsPnt->GetLabel(ii);
286 Int_t tr3 = itsPnt->GetLabel(ii);
289 ntuple2_st.nxP = nxP;
290 ntuple2_st.nxN = nxN;
291 ntuple2_st.x = xrec/1000;
292 ntuple2_st.z = zrec/1000;
299 Float_t xhit0 = 1e+7;
300 Float_t yhit0 = 1e+7;
301 Float_t zhit0 = 1e+7;
302 Float_t dxprimbest = 1e+7;
303 Float_t dzprimbest = 1e+7;
306 for (Int_t hit=0;hit<nhits;hit++) {
308 itsHit = (AliITShit*)Mod->GetHit(hit);
311 Int_t hitlayer = itsHit->GetLayer();
312 Int_t hitladder= itsHit->GetLadder();
313 Int_t hitdet= itsHit->GetDetector();
315 Int_t track = itsHit->GetTrack();
317 Int_t hitstat = itsHit->GetTrackStatus();
319 Float_t zhit = 10000*itsHit->GetZL();
320 Float_t xhit = 10000*itsHit->GetXL();
321 Float_t yhit = 10000*itsHit->GetYL();
322 Float_t ehit = 1.0e+6*itsHit->GetIonization(); // hit energy, KeV
324 Int_t parent = itsHit->GetParticle()->GetFirstMother();
325 Int_t partcode = itsHit->GetParticle()->GetPdgCode();
327 // partcode (pdgCode): 11 - e-, 13 - mu-, 22 - gamma, 111 - pi0, 211 - i+
328 // 310 - K0s, 321 - K+, 2112 - n, 2212 - p, 3122 - lambda
330 Float_t pmod = itsHit->GetParticle()->P(); // the momentum at the
334 if(hitstat == 66 && yhit < -ylim) {
340 if(hitstat == 66) continue; // Take the not entering hits only
342 if(xhit0 > 9e+6 || zhit0 > 9e+6 || yhit0 > 9e+6) {
346 // Consider the hits only with the track number equaled to one
348 if((track == tr1) || (track == tr2) || (track == tr3)) flagtrack = 1;
350 if(flagtrack == 1) { // the hit corresponds to the recpoint
354 //Float_t px = itsHit->GetPXL(); // the momenta at this GEANT point
355 //Float_t py = itsHit->GetPYL();
356 //Float_t pz = itsHit->GetPZL();
360 if(partcode == 11 && pmod < 6) dray = 1; // delta ray is e-
363 if((hitstat == 68 || hitstat == 33) && dray == 0) noverlaps=noverlaps + 1;
364 // overlapps for all hits but
365 // not for delta ray which
366 // also went out from the
367 // detector and returned
371 // x,z resolution colculation
372 if((hitstat == 68 || hitsat == 33) && dray == 0) {
373 Float_t xmed = (xhit + xhit0)/2;
374 Float_t zmed = (zhit + zhit0)/2;
375 Float_t xdif = xmed - xrec;
376 Float_t zdif = zmed - zrec;
379 hitprim = 1; // hitprim=1 for the primery particles
382 pathInSSD = TMath::Sqrt((xhit0-xhit)*(xhit0-xhit)+(yhit0-yhit)*(yhit0-yhit)+(zhit0-zhit)*(zhit0-zhit));
384 // Find the best xdif and zdif from any ones for the primery
385 // particles (to remove the wronge xdif and zdif if the hit
386 // belongs to the other package containing the same P/N cluster
389 if(TMath::Abs(dxprimbest)>TMath::Abs(xdif)) dxprimbest = xdif;
390 if(TMath::Abs(dzprimbest)>TMath::Abs(zdif)) dzprimbest = zdif;
396 ntuple_st.lay = hitlayer;
399 ntuple_st.hitprim = hitprim;
400 ntuple_st.partcode = partcode;
401 ntuple_st.ntrover = ntrover;
402 ntuple_st.x = xrec/1000;
403 ntuple_st.z = zrec/1000;
406 ntuple_st.pmod = pmod;
408 //if(qcut < 0.18) ntuple->Fill();
412 //if(hitlayer == 5 && qcut < 0.18) {
417 Path5->Fill(pathInSSD);
419 //if(hitlayer == 6 && qcut < 0.18) {
423 Path6->Fill(pathInSSD);
426 } else { // non correspondent hit
429 } // end of hit-recpoint correspondence
434 if(noverlaps == 0) noverlaps = 1; // cluster contains one or more
439 ntuple1_st.lay = hitlayer;
440 ntuple1_st.lad = hitladder;
441 ntuple1_st.det = hitdet;
442 ntuple1_st.nxP = nxP;
443 ntuple1_st.nxN = nxN;
444 ntuple1_st.qclP = qclP*300/pathInSSD;
445 ntuple1_st.qclN = qclN*300/pathInSSD;
446 ntuple1_st.qrec = qrec*300/pathInSSD;
447 ntuple1_st.qcut = qcut;
448 ntuple1_st.dx = dxprimbest;
449 ntuple1_st.dz = dzprimbest;
452 ntuple1_st.noverlaps = noverlaps;
453 ntuple1_st.noverprim = noverprim;
454 ntuple1_st.ntrover = ntrover;
456 //if(qcut < 0.18) ntuple1->Fill();
460 Float_t de = dedx*300./pathInSSD;
464 adcPadcN5all->Fill(qclP,qclN);
467 adcPadcN6all->Fill(qclP,qclN);
469 if(hitlayer == 5 && qcut < 0.18) {
470 //if(hitlayer == 5 && noverlaps == 0) {
471 adcPadcN5cut->Fill(qclP,qclN);
475 if(hitlayer == 6 && qcut < 0.18) {
476 //if(hitlayer == 6 && noverlaps == 0) {
477 adcPadcN6cut->Fill(qclP,qclN);
483 } //b.b. recpoint loop
485 } // detector loop (iDetType)
489 TFile fhistos("SSD_his.root","RECREATE");
504 adcPadcN5all->Write();
505 adcPadcN6all->Write();
506 adcPadcN5cut->Write();
507 adcPadcN6cut->Write();
512 cout<<"!!! Histogramms and ntuples were written"<<endl;
514 TCanvas *c1 = new TCanvas("c1","ITS clusters",400,10,600,700);
517 gPad->SetFillColor(33);
518 Xres5->SetFillColor(42);
521 gPad->SetFillColor(33);
522 Zres5->SetFillColor(46);
525 gPad->SetFillColor(33);
526 Xres6->SetFillColor(42);
529 gPad->SetFillColor(33);
530 Zres6->SetFillColor(46);
533 cout<<"END test for clusters and hits "<<endl;