3 void SPDclusterTest (Int_t evNumber1=0,Int_t evNumber2=0)
5 /////////////////////////////////////////////////////////////////////////
6 // This macro is a small example of a ROOT macro
7 // illustrating how to read the output of GALICE
8 // and do some analysis.
10 /////////////////////////////////////////////////////////////////////////
12 // Dynamically link some shared libs
14 if (gClassTable->GetID("AliRun") < 0) {
15 gROOT->LoadMacro("loadlibs.C");
19 // Connect the Root Galice file containing Geometry, Kine and Hits
21 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
22 if (!file) file = new TFile("galice.root");
25 // Get AliRun object from file or create it if not on file
28 gAlice = (AliRun*)file->Get("gAlice");
29 if (gAlice) printf("AliRun object found on file\n");
30 if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
33 // ------------ Cluster and point analysis histogramms ------------
35 TH1F *Nxpix1 = new TH1F("Nxpix1","Cluster size in x(r*phi) direction for layer 1",20,0.,20.);
36 TH1F *Nxpix2 = new TH1F("Nxpix2","Cluster size in x(r*phi) direction for layer 2",20,0.,20.);
37 TH1F *Nzpix1 = new TH1F("Nzpix1","Cluster size in z direction for layer 1",15,0.,15.);
38 TH1F *Nzpix2 = new TH1F("Nzpix2","Cluster size in z direction for layer 2",15,0.,15.);
39 TH1F *Xpix1 = new TH1F("Xpix1","Local x coordinate (mm) for layer 1",20,-2.,18.);
40 TH1F *Xpix2 = new TH1F("Xpix2","Local x coordinate (mm) for layer 2",20,-2.,18.);
41 TH1F *Zpix1 = new TH1F("Zpix1","Local z coordinate (mm) for layer 1",90,-2.,88.);
42 TH1F *Zpix2 = new TH1F("Zpix2","Lolac z coordinate (mm) for layer 2",90,-2.,88.);
44 TH1F *Xres1 = new TH1F("Xres1","Xrec and Xgen difference (micr) for layers 1",100,-200.,200.);
45 TH1F *Xres2 = new TH1F("Xres2","Xrec and Xgen difference (micr) for layers 2",100,-200.,200.);
46 TH1F *Zres1 = new TH1F("Zres1","Zrec and Zgen difference (micr) for layers 1",100,-800.,800.);
47 TH1F *Zres2 = new TH1F("Zres2","Zrec and Zgen difference (micr) for layers 2",100,-800.,800.);
49 // -------------- Create ntuples --------------------
84 ntuple = new TTree("ntuple","Demo ntuple");
85 ntuple->Branch("lay",&ntuple_st.lay,"lay/I");
86 ntuple->Branch("nx",&ntuple_st.nx,"nx/I");
87 ntuple->Branch("nz",&ntuple_st.nz,"nz/I");
88 ntuple->Branch("hitprim",&ntuple_st.hitprim,"hitprim/I");
89 ntuple->Branch("partcode",&ntuple_st.partcode,"partcode/I");
90 ntuple->Branch("ntrover",&ntuple_st.ntrover,"ntrover/I");
91 ntuple->Branch("dx",&ntuple_st.dx,"dx/F");
92 ntuple->Branch("dz",&ntuple_st.dz,"dz/F");
93 ntuple->Branch("pmod",&ntuple_st.pmod,"pmod/F");
95 ntuple1 = new TTree("ntuple1","Demo ntuple1");
96 ntuple1->Branch("lay",&ntuple1_st.lay,"lay/I");
97 ntuple1->Branch("lad",&ntuple1_st.lad,"lad/I");
98 ntuple1->Branch("det",&ntuple1_st.det,"det/I");
99 ntuple1->Branch("nx",&ntuple1_st.nx,"nx/I");
100 ntuple1->Branch("nz",&ntuple1_st.nz,"nz/I");
101 ntuple1->Branch("qcl",&ntuple1_st.qcl,"qcl/F");
102 ntuple1->Branch("ntrover",&ntuple1_st.ntrover,"ntrover/I");
103 ntuple1->Branch("noverlaps",&ntuple1_st.noverlaps,"noverlaps/I");
104 ntuple1->Branch("noverprim",&ntuple1_st.noverprim,"noverprim/I");
105 ntuple1->Branch("dx",&ntuple1_st.dx,"dx/F");
106 ntuple1->Branch("dz",&ntuple1_st.dz,"dz/F");
109 ntuple2 = new TTree("ntuple2","Demo ntuple2");
110 // ntuple2->Branch("lay",&ntuple2_st.lay,"lay/I");
111 ntuple2->Branch("nx",&ntuple2_st.nx,"nx/I");
112 ntuple2->Branch("nz",&ntuple2_st.nz,"nz/I");
114 // ------------------------------------------------------------------------
118 for (int nev=0; nev<= evNumber2; nev++) {
119 Int_t nparticles = gAlice->GetEvent(nev);
120 cout << "nev " << nev <<endl;
121 cout << "nparticles " << nparticles <<endl;
122 if (nev < evNumber1) continue;
123 if (nparticles <= 0) return;
125 TTree *TH = gAlice->TreeH();
126 Int_t ntracks = TH->GetEntries();
127 cout<<"ntracks "<<ntracks<<endl;
129 // Get pointers to Alice detectors and Digits containers
130 AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
131 TClonesArray *Particles = gAlice->Particles();
134 // fill modules with sorted by module hits
136 ITS->InitModules(-1,nmodules);
137 // ITS->FillModules(nev,-1,evNumber2,nmodules," "," ");
138 ITS->FillModules(nev,evNumber2,nmodules," "," ");
139 //get pointer to modules array
140 TObjArray *ITSmodules = ITS->GetModules();
143 // get the Tree for clusters
145 TTree *TC=ITS->TreeC();
146 Int_t nent=TC->GetEntries();
147 printf("Found %d entries in the tree (must be one per module per event!)\n",nent);
149 for (Int_t idettype=0;idettype<3;idettype++) {
151 TClonesArray *ITSclusters = ITS->ClustersAddress(idettype);
152 //printf ("ITSclusters %p \n",ITSclusters);
154 if (idettype != 0) continue;
157 for (Int_t mod=0; mod<nent; mod++) {
158 AliITSmodule *itsModule = (AliITSmodule*)ITSmodules->At(mod);
160 Int_t nhits = itsModule->GetNhits();
161 //if(nhits) printf("module nhits %d %d\n",mod,nhits);
164 ITS->ResetClusters();
166 Int_t nclust = ITSclusters->GetEntries();
167 if (!nclust) continue;
171 for (Int_t clu=0;clu<nclust;clu++) {
172 itsclu = (AliITSRawClusterSPD*)ITSclusters->UncheckedAt(clu);
177 Int_t clustersizex = itsclu->NclX();
178 Int_t clustersizez = itsclu->NclZ();
179 // Int_t xstart = itsclu->XStart();
180 // Int_t xstop = itsclu->XStop();
181 Int_t xstart = itsclu->XStartf();
182 Int_t xstop = itsclu->XStopf();
183 Float_t fxstart = xstart*50;
184 Float_t fxstop = (xstop+1)*50;
185 Float_t zstart = itsclu->ZStart();
186 Float_t zstop = itsclu->ZStop();
187 Int_t zend = itsclu->Zend();
188 Int_t ntrover = itsclu->NTracks();
189 Float_t clusterx = itsclu->X();
190 Float_t clusterz = itsclu->Z();
191 Float_t clusterQ = itsclu->Q();
193 ntuple2_st.nx = clustersizex;
194 ntuple2_st.nz = clustersizez;
199 Float_t dxprimlast = 10.e+6;
200 Float_t dzprimlast = 10.e+6;
202 Float_t SPDlength = 83600;
203 Float_t SPDwidth = 12800;
204 Float_t xhit0 = 1e+5;
205 Float_t zhit0 = 1e+5;
208 for (Int_t hit=0;hit<nhits;hit++) {
210 // Find coordinate differences between the hit and cluster positions
211 // for the resolution determination.
213 itsHit = (AliITShit*)itsModule->GetHit(hit);
215 Int_t hitlayer = itsHit->GetLayer();
216 Int_t hitladder= itsHit->GetLadder();
217 Int_t hitdet= itsHit->GetDetector();
219 Int_t clusterlayer = hitlayer;
220 Int_t clusterladder= hitladder;
221 Int_t clusterdetector = hitdet;
223 Int_t track = itsHit->GetTrack();
225 Int_t hitstat = itsHit->GetTrackStatus();
228 Float_t zhit = 10000*itsHit->GetZL();
229 Float_t xhit = 10000*itsHit->GetXL();
231 if(abs(zhit) > SPDlength/2) {
232 if(hitstat == 66) zhit0 = 1e+5;
236 if(abs(xhit) > SPDwidth/2) {
237 if(hitstat == 66) xhit0 = 1e+5;
243 Float_t yhit = 10000*itsHit->GetYL();
245 if(hitlayer == 1 && hitstat == 66 && yhit > 71) {
249 if(hitlayer == 2 && hitstat == 66 && yhit < -71) {
254 if(hitstat != 68) continue; // Take only the hit if the last
255 // track point went out from
258 if(xhit0 > 9e+4 || zhit0 > 9e+4) continue;
261 Float_t xmed = (xhit + xhit0)/2;
262 Float_t zmed = (zhit + zhit0)/2;
264 Float_t xdif = xmed - clusterx;
265 Float_t zdif = zmed - clusterz;
268 // Consider the hits inside of cluster region only
270 if((xmed >= fxstart && xmed <= fxstop) && (zmed >= zstart && zmed <= zstop)) {
274 // part = (TParticle *)particles.UncheckedAt(track);
275 // Int_t partcode = part->GetPdgCode();
276 // Int_t primery = gAlice->GetPrimary(track);
278 Int_t parent = itsHit->GetParticle()->GetFirstMother();
279 Int_t partcode = itsHit->GetParticle()->GetPdgCode();
281 // partcode (pdgCode): 11 - e-, 13 - mu-, 22 - gamma, 111 - pi0, 211 - pi+
282 // 310 - K0s, 321 - K+, 2112 - n, 2212 - p, 3122 - lambda
284 Float_t pmod = itsHit->GetParticle()->P(); // the momentum at the
289 Float_t px = itsHit->GetPXL(); // the momenta at this GEANT point
290 Float_t py = itsHit->GetPYL();
291 Float_t pz = itsHit->GetPZL();
296 if(partcode == 11 && pmod < 6) dray = 1; // delta ray is e-
299 if(dray == 0) noverlaps = noverlaps + 1; // overlapps for all hits but
300 // not for delta ray which
301 // also went out from the
302 // detector and returned
305 if(parent < 0) hitprim = hitprim + 1; // hitprim=1 for the primery
308 if(hitprim > 0) noverprim = noverprim + 1;
317 ntuple_st.lay = hitlayer;
318 ntuple_st.nx = clustersizex;
319 ntuple_st.nz = clustersizez;
320 ntuple_st.hitprim = hitprim;
321 ntuple_st.partcode = partcode;
322 ntuple_st.ntrover = ntrover;
325 ntuple_st.pmod = pmod;
331 if(hitprim > 0) { // for primary particles
340 } // primery particles
342 } // end of cluster region
350 // ntuple1->Fill(clusterlayer,clustersizex,clustersizez,noverlaps,\
353 if(noverlaps == 0) noverlaps = 1; // cluster contains one or more
356 ntuple1_st.lay = clusterlayer;
357 ntuple1_st.lad = clusterladder;
358 ntuple1_st.det = clusterdetector;
359 ntuple1_st.nx = clustersizex;
360 ntuple1_st.nz = clustersizez;
361 ntuple1_st.qcl = clusterQ;
362 ntuple1_st.ntrover = ntrover;
363 ntuple1_st.noverlaps = noverlaps;
364 ntuple1_st.noverprim = noverprim;
365 ntuple1_st.dx = dxprimlast;
366 ntuple1_st.dz = dzprimlast;
378 // Write and Draw Histogramms and ntuples
382 TFile fhistos("SPD_his.root","RECREATE");
404 cout<<"!!! Histogramms and ntuples were written"<<endl;
406 TCanvas *c1 = new TCanvas("c1","ITS clusters",400,10,600,700);
409 gPad->SetFillColor(33);
410 Xres1->SetFillColor(42);
413 gPad->SetFillColor(33);
414 Zres1->SetFillColor(46);
417 gPad->SetFillColor(33);
418 Xres2->SetFillColor(42);
421 gPad->SetFillColor(33);
422 Zres2->SetFillColor(46);
425 cout<<"END test for clusters and hits "<<endl;