88cb7938 |
1 | // |
2 | // Macro for checking aliroot output and associated files contents |
3 | // Gines Martinez, Subatech June 2003 |
4 | // |
5 | |
6 | // ROOT includes |
7 | #include "TBranch.h" |
8 | #include "TClonesArray.h" |
9 | #include "TFile.h" |
10 | #include "TH1.h" |
11 | #include "TParticle.h" |
12 | #include "TTree.h" |
13 | |
14 | // STEER includes |
15 | #include "AliRun.h" |
16 | #include "AliRunLoader.h" |
17 | #include "AliHeader.h" |
18 | #include "AliLoader.h" |
19 | #include "AliStack.h" |
20 | |
21 | // MUON includes |
22 | #include "AliMUON.h" |
23 | #include "AliMUONHit.h" |
24 | #include "AliMUONConstants.h" |
25 | #include "AliMUONDigit.h" |
26 | #include "AliMUONRawCluster.h" |
27 | #include "AliMUONGlobalTrigger.h" |
28 | #include "AliMUONLocalTrigger.h" |
29 | |
30 | void MUONkine(char * filename="galice.root") |
31 | { |
32 | TClonesArray * ListOfParticles = new TClonesArray("TParticle",1000); |
33 | TParticle * particle = new TParticle(); |
34 | // Creating Run Loader and openning file containing Hits |
35 | AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ"); |
36 | if (RunLoader ==0x0) { |
37 | printf(">>> Error : Error Opening %s file \n",filename); |
38 | return; |
39 | } |
40 | RunLoader->LoadKinematics("READ"); |
41 | Int_t ievent, nevents; |
42 | nevents = RunLoader->GetNumberOfEvents(); |
43 | |
44 | for(ievent=0; ievent<nevents; ievent++) { // Event loop |
45 | Int_t iparticle, nparticles; |
46 | // Getting event ievent |
47 | RunLoader->GetEvent(ievent); |
48 | RunLoader->TreeK()->GetBranch("Particles")->SetAddress(&particle); |
49 | nparticles = RunLoader->TreeK()->GetEntries(); |
50 | printf(">>> Event %d, Number of particles is %d \n",ievent, nparticles); |
51 | for(iparticle=0; iparticle<nparticles; iparticle++) { |
52 | RunLoader->TreeK()->GetEvent(iparticle); |
53 | particle->Print(""); |
54 | } |
55 | } |
56 | RunLoader->UnloadKinematics(); |
57 | } |
58 | |
59 | |
60 | void MUONhits(char * filename="galice.root") |
61 | { |
62 | // List of Hits per event and per track |
63 | TClonesArray * ListOfHits = new TClonesArray("AliMUONHit",1000); |
64 | |
65 | // Creating Run Loader and openning file containing Hits |
66 | AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ"); |
67 | if (RunLoader ==0x0) { |
68 | printf(">>> Error : Error Opening %s file \n",filename); |
69 | return; |
70 | } |
71 | |
72 | // Loading MUON subsystem |
73 | AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader"); |
74 | MUONLoader->LoadHits("READ"); |
75 | |
76 | Int_t ievent, nevents; |
77 | nevents = RunLoader->GetNumberOfEvents(); |
78 | |
79 | for(ievent=0; ievent<nevents; ievent++) { // Event loop |
80 | printf(">>> Event %d \n",ievent); |
81 | |
82 | // Getting event ievent |
83 | RunLoader->GetEvent(ievent); |
84 | MUONLoader->TreeH()->GetBranch("MUON")->SetAddress(&ListOfHits); |
85 | |
86 | Int_t itrack, ntracks; |
87 | ntracks = (Int_t) (MUONLoader->TreeH())->GetEntries(); |
88 | for (itrack=0; itrack<ntracks; itrack++) { // Track loop |
89 | printf(">>> Track %d \n",itrack); |
90 | |
91 | //Getting List of Hits of Track itrack |
92 | (MUONLoader->TreeH())->GetEvent(itrack); |
93 | |
94 | Int_t ihit, nhits; |
95 | nhits = (Int_t) ListOfHits->GetEntriesFast(); |
96 | printf(">>> Number of hits %d \n",nhits); |
97 | AliMUONHit* mHit; |
98 | for(ihit=0; ihit<nhits; ihit++) { |
99 | mHit = static_cast<AliMUONHit*>(ListOfHits->At(ihit)); |
100 | Int_t Nch = mHit->Chamber(); // chamber number |
101 | Int_t hittrack = mHit->Track(); |
102 | Float_t x = mHit->X(); |
103 | Float_t y = mHit->Y(); |
104 | Float_t z = mHit->Z(); |
105 | Float_t elos = mHit->Eloss(); |
106 | Float_t theta = mHit->Theta(); |
107 | Float_t phi = mHit->Phi(); |
108 | Float_t momentum = mHit->Momentum(); |
109 | printf(">>> Hit %2d Chamber %2d Track %4d x %6.3f y %6.3f z %7.3f elos %g theta %6.3f phi %5.3f momentum %5.3f\n", |
110 | ihit, Nch,hittrack,x,y,z,elos,theta,phi, momentum); |
111 | } |
112 | ListOfHits->Clear(); |
113 | } // end track loop |
114 | } // end event loop |
115 | MUONLoader->UnloadHits(); |
116 | } |
117 | |
118 | |
119 | void MUONdigits(char * filename="galice.root") |
120 | { |
121 | TClonesArray * ListOfDigits; |
122 | |
123 | // Creating Run Loader and openning file containing Hits |
124 | AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ"); |
125 | if (RunLoader ==0x0) { |
126 | printf(">>> Error : Error Opening %s file \n",filename); |
127 | return; |
128 | } |
129 | |
130 | // Loading AliRun master |
131 | RunLoader->LoadgAlice(); |
132 | gAlice = RunLoader->GetAliRun(); |
133 | // Getting Module MUON |
134 | AliMUON *pMUON = (AliMUON *) gAlice->GetDetector("MUON"); |
135 | |
136 | AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader"); |
137 | MUONLoader->LoadDigits("READ"); |
138 | |
139 | Int_t ievent, nevents; |
140 | nevents = RunLoader->GetNumberOfEvents(); |
141 | |
142 | AliMUONDigit * mDigit; |
143 | |
144 | |
145 | for(ievent=0; ievent<nevents; ievent++) { |
146 | printf(">>> Event %d \n",ievent); |
147 | RunLoader->GetEvent(ievent); |
148 | |
149 | // Addressing |
150 | Int_t ichamber, nchambers; |
151 | nchambers = AliMUONConstants::NCh(); ; |
152 | pMUON->SetTreeAddress(); |
153 | char branchname[30]; |
154 | //for( ichamber=0; ichamber<nchambers; ichamber++) { |
155 | // sprintf(branchname,"MUONDigits%d",ichamber+1); |
156 | //(MUONLoader->TreeD()->GetBranch(branchname))->SetAddress(&((*pMUON->Dchambers())[ichamber])); |
157 | //} |
158 | |
159 | |
160 | Int_t icathode, ncathodes; |
161 | ncathodes=2; |
162 | //Loop on cathodes |
163 | for(icathode=0; icathode<ncathodes; icathode++) { |
164 | printf(">>> Cathode %d\n",icathode); |
165 | MUONLoader->TreeD()->GetEvent(icathode); |
166 | // Loop on chambers |
167 | for( ichamber=0; ichamber<nchambers; ichamber++) { |
168 | printf(">>> Chamber %d\n",ichamber); |
169 | // sprintf(branchname,"MUONDigits%d",ichamber+1); |
170 | //printf(">>> branchname %s\n",branchname); |
171 | ListOfDigits = (TClonesArray *) pMUON->Dchambers()->At(ichamber); |
172 | |
173 | Int_t idigit, ndigits; |
174 | |
175 | ndigits = (Int_t) ListOfDigits->GetEntriesFast(); |
176 | |
177 | for(idigit=0; idigit<ndigits; idigit++) { |
178 | mDigit = static_cast<AliMUONDigit*>(ListOfDigits->At(idigit)); |
179 | Int_t PadX = mDigit->PadX(); // Pad X number |
180 | Int_t PadY = mDigit->PadY(); // Pad Y number |
181 | Int_t Signal = mDigit->Signal(); // Physics Signal |
182 | Int_t Hit = mDigit->Hit(); // iHit |
183 | Int_t Cathode= mDigit->Cathode(); // Cathode |
184 | Int_t Track0 = mDigit->Track(0); |
185 | Int_t Track1 = mDigit->Track(1); |
186 | Int_t Track2 = mDigit->Track(2); |
187 | |
188 | printf(">>> Digit %4d cathode %1d hit %4d PadX %3d PadY %3d Signal %4d Track0 %4d Track1 %'d Track2 %4d \n",idigit, Cathode,Hit, PadX, PadY, Signal, Track0, Track1, Track2); |
189 | } // end digit loop |
190 | } // end chamber loop |
191 | } // end cathode loop |
192 | } // end event loop |
193 | MUONLoader->UnloadDigits(); |
194 | } |
195 | |
196 | void MUONrecpoints(char * filename="galice.root") { |
197 | |
198 | TClonesArray * ListOfRecPoints; |
199 | |
200 | // Creating Run Loader and openning file containing Hits |
201 | AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ"); |
202 | if (RunLoader ==0x0) { |
203 | printf(">>> Error : Error Opening %s file \n",filename); |
204 | return; |
205 | } |
206 | |
207 | // Loading AliRun master |
208 | RunLoader->LoadgAlice(); |
209 | gAlice = RunLoader->GetAliRun(); |
210 | // Getting Module MUON |
211 | AliMUON *pMUON = (AliMUON *) gAlice->GetDetector("MUON"); |
212 | |
213 | AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader"); |
214 | MUONLoader->LoadRecPoints("READ"); |
215 | |
216 | Int_t ievent, nevents; |
217 | nevents = RunLoader->GetNumberOfEvents(); |
218 | |
219 | AliMUONRawCluster * mRecPoint; |
220 | |
221 | |
222 | for(ievent=0; ievent<nevents; ievent++) { |
223 | printf(">>> Event %d \n",ievent); |
224 | RunLoader->GetEvent(ievent); |
225 | |
226 | // Addressing |
227 | Int_t ichamber, nchambers; |
228 | nchambers = AliMUONConstants::NTrackingCh(); |
229 | pMUON->SetTreeAddress(); |
230 | char branchname[30]; |
231 | |
232 | MUONLoader->TreeR()->GetEvent(0); |
233 | // Loop on chambers |
234 | for( ichamber=0; ichamber<nchambers; ichamber++) { |
235 | printf(">>> Chamber %d\n",ichamber); |
236 | sprintf(branchname,"MUONRawClusters%d",ichamber+1); |
237 | //printf(">>> branchname %s\n",branchname); |
238 | ListOfRecPoints = (TClonesArray *) pMUON->RawClusters()->At(ichamber); |
239 | |
240 | Int_t irecpoint, nrecpoints; |
241 | |
242 | nrecpoints = (Int_t) ListOfRecPoints->GetEntriesFast(); |
243 | |
244 | for(irecpoint=0; irecpoint<nrecpoints; irecpoint++) { |
245 | mRecPoint = static_cast<AliMUONRawCluster*>(ListOfRecPoints->At(irecpoint)); |
246 | // Int_t fTracks[3]; //labels of overlapped tracks |
247 | // Int_t fQ[2] ; // Q of cluster (in ADC counts) |
248 | // Float_t fX[2] ; // X of cluster |
249 | // Float_t fY[2] ; // Y of cluster |
250 | // Float_t fZ[2] ; // Z of cluster |
251 | // Int_t fPeakSignal[2]; // Peak signal |
252 | // Int_t fIndexMap[50][2]; // indeces of digits |
253 | // Int_t fOffsetMap[50][2]; // Emmanuel special |
254 | // Float_t fContMap[50][2]; // Contribution from digit |
255 | // Int_t fPhysicsMap[50]; // Distinguish signal and background contr. |
256 | // Int_t fMultiplicity[2]; // Cluster multiplicity |
257 | // Int_t fNcluster[2]; // Number of clusters |
258 | // Int_t fClusterType; // Cluster type |
259 | // Float_t fChi2[2]; // Chi**2 of fit |
260 | // Int_t fGhost; // 0 if not a ghost or ghost problem solved |
261 | // // >0 if ghost problem remains because |
262 | // // 1 both (true and ghost) satify |
263 | // // charge chi2 compatibility |
264 | // // 2 none give satisfactory chi2 |
265 | |
266 | Int_t Track0 = mRecPoint->fTracks[0]; |
267 | Int_t Track1 = mRecPoint->fTracks[1]; |
268 | Int_t Track2 = mRecPoint->fTracks[2]; |
269 | Int_t Q0 = mRecPoint->fQ[0]; |
270 | Int_t Q1 = mRecPoint->fQ[1]; |
271 | Float_t x0 = mRecPoint->fX[0]; |
272 | Float_t x1 = mRecPoint->fX[1]; |
273 | Float_t y0 = mRecPoint->fY[0]; |
274 | Float_t y1 = mRecPoint->fY[1]; |
275 | Float_t z0 = mRecPoint->fZ[0]; |
276 | Float_t z1 = mRecPoint->fZ[1]; |
277 | Float_t chi2_0 = mRecPoint->fChi2[0]; |
278 | Float_t chi2_1 = mRecPoint->fChi2[1]; |
279 | |
280 | printf(">>> RecPoint %4d x %6.3f %6.3f y %6.3f %6.3f z %6.3f %6.3f Q0 %4d Q1 %4d Hit %4d Track1 %4d Track2 %4d Chi2 %6.3f %6.3f \n", |
281 | irecpoint, x0, x1, y0, y1, z0, z1, Q0, Q1, Track0, Track1, Track2, chi2_0, chi2_1); |
282 | } // end recpoint loop |
283 | } // end chamber loop |
284 | } // end event loop |
285 | MUONLoader->UnloadRecPoints(); |
286 | } |
287 | |
288 | void MUONTestTrigger (char * filename="galice.root"){ |
289 | // reads and dumps trigger objects from MUON.RecPoints.root |
290 | TClonesArray * globalTrigger; |
291 | TClonesArray * localTrigger; |
292 | |
293 | // Creating Run Loader and openning file containing Hits |
294 | AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ"); |
295 | if (RunLoader ==0x0) { |
296 | printf(">>> Error : Error Opening %s file \n",filename); |
297 | return; |
298 | } |
299 | |
300 | // Loading AliRun master |
301 | RunLoader->LoadgAlice(); |
302 | gAlice = RunLoader->GetAliRun(); |
303 | // Getting Module MUON |
304 | AliMUON *pMUON = (AliMUON *) gAlice->GetDetector("MUON"); |
305 | |
306 | AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader"); |
307 | MUONLoader->LoadRecPoints("READ"); |
308 | |
309 | Int_t ievent, nevents; |
310 | nevents = RunLoader->GetNumberOfEvents(); |
311 | |
312 | AliMUONGlobalTrigger *gloTrg; |
313 | AliMUONLocalTrigger *locTrg; |
314 | |
315 | for (ievent=0; ievent<nevents; ievent++) { |
316 | RunLoader->GetEvent(ievent); |
317 | |
318 | pMUON->SetTreeAddress(); |
319 | MUONLoader->TreeR()->GetEvent(0); |
320 | |
321 | globalTrigger = (TClonesArray *) pMUON->GlobalTrigger(); |
322 | localTrigger = (TClonesArray *) pMUON->LocalTrigger(); |
323 | |
324 | Int_t nglobals = (Int_t) globalTrigger->GetEntriesFast(); // should be 1 |
325 | Int_t nlocals = (Int_t) localTrigger->GetEntriesFast(); // up to 234 |
326 | printf("###################################################\n"); |
327 | cout << " event " << ievent |
328 | << " nglobals nlocals: " << nglobals << " " << nlocals << "\n"; |
329 | |
330 | for (Int_t iglobal=0; iglobal<nglobals; iglobal++) { // Global Trigger |
331 | gloTrg = static_cast<AliMUONGlobalTrigger*>(globalTrigger->At(iglobal)); |
332 | |
333 | printf("===================================================\n"); |
334 | printf(" Global Trigger output Low pt High pt All\n"); |
335 | printf(" number of Single Plus :\t"); |
336 | printf("%i\t%i\t%i\t",gloTrg->SinglePlusLpt(), |
337 | gloTrg->SinglePlusHpt(),gloTrg->SinglePlusApt()); |
338 | printf("\n"); |
339 | printf(" number of Single Minus :\t"); |
340 | printf("%i\t%i\t%i\t",gloTrg->SingleMinusLpt(), |
341 | gloTrg->SingleMinusHpt(),gloTrg->SingleMinusApt()); |
342 | printf("\n"); |
343 | printf(" number of Single Undefined :\t"); |
344 | printf("%i\t%i\t%i\t",gloTrg->SingleUndefLpt(), |
345 | gloTrg->SingleUndefHpt(),gloTrg->SingleUndefApt()); |
346 | printf("\n"); |
347 | printf(" number of UnlikeSign pair :\t"); |
348 | printf("%i\t%i\t%i\t",gloTrg->PairUnlikeLpt(), |
349 | gloTrg->PairUnlikeHpt(),gloTrg->PairUnlikeApt()); |
350 | printf("\n"); |
351 | printf(" number of LikeSign pair :\t"); |
352 | printf("%i\t%i\t%i\t",gloTrg->PairLikeLpt(), |
353 | gloTrg->PairLikeHpt(),gloTrg->PairLikeApt()); |
354 | printf("\n"); |
355 | printf("===================================================\n"); |
356 | |
357 | } // end of loop on Global Trigger |
358 | |
359 | for (Int_t ilocal=0; ilocal<nlocals; ilocal++) { // Local Trigger |
360 | cout << " >>> Output for Local Trigger " << ilocal << "\n"; |
361 | |
362 | locTrg = static_cast<AliMUONLocalTrigger*>(localTrigger->At(ilocal)); |
363 | |
364 | cout << "Circuit StripX Dev StripY: " |
365 | << locTrg->LoCircuit() << " " |
366 | << locTrg->LoStripX() << " " |
367 | << locTrg->LoDev() << " " |
368 | << locTrg->LoStripY() |
369 | << "\n"; |
370 | cout << "Lpt Hpt Apt: " |
371 | << locTrg->LoLpt() << " " |
372 | << locTrg->LoHpt() << " " |
373 | << locTrg->LoApt() << "\n"; |
374 | |
375 | } // end of loop on Local Trigger |
376 | } // end loop on event |
377 | } |
378 | |
379 | |
380 | |
381 | |
382 | |