2 // Macro for checking aliroot output and associated files contents
3 // Gines Martinez, Subatech June 2003
8 #include "TClonesArray.h"
11 #include "TParticle.h"
16 #include "AliRunLoader.h"
17 #include "AliHeader.h"
18 #include "AliLoader.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"
30 void MUONkine(char * filename="galice.root")
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);
40 RunLoader->LoadKinematics("READ");
41 Int_t ievent, nevents;
42 nevents = RunLoader->GetNumberOfEvents();
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);
56 RunLoader->UnloadKinematics();
60 void MUONhits(char * filename="galice.root")
62 // List of Hits per event and per track
63 TClonesArray * ListOfHits = new TClonesArray("AliMUONHit",1000);
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);
72 // Loading MUON subsystem
73 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
74 MUONLoader->LoadHits("READ");
76 Int_t ievent, nevents;
77 nevents = RunLoader->GetNumberOfEvents();
79 for(ievent=0; ievent<nevents; ievent++) { // Event loop
80 printf(">>> Event %d \n",ievent);
82 // Getting event ievent
83 RunLoader->GetEvent(ievent);
84 MUONLoader->TreeH()->GetBranch("MUON")->SetAddress(&ListOfHits);
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);
91 //Getting List of Hits of Track itrack
92 (MUONLoader->TreeH())->GetEvent(itrack);
95 nhits = (Int_t) ListOfHits->GetEntriesFast();
96 printf(">>> Number of hits %d \n",nhits);
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);
115 MUONLoader->UnloadHits();
119 void MUONdigits(char * filename="galice.root")
121 TClonesArray * ListOfDigits;
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);
130 // Loading AliRun master
131 RunLoader->LoadgAlice();
132 gAlice = RunLoader->GetAliRun();
133 // Getting Module MUON
134 AliMUON *pMUON = (AliMUON *) gAlice->GetDetector("MUON");
136 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
137 MUONLoader->LoadDigits("READ");
139 Int_t ievent, nevents;
140 nevents = RunLoader->GetNumberOfEvents();
142 AliMUONDigit * mDigit;
145 for(ievent=0; ievent<nevents; ievent++) {
146 printf(">>> Event %d \n",ievent);
147 RunLoader->GetEvent(ievent);
150 Int_t ichamber, nchambers;
151 nchambers = AliMUONConstants::NCh(); ;
152 pMUON->SetTreeAddress();
154 //for( ichamber=0; ichamber<nchambers; ichamber++) {
155 // sprintf(branchname,"MUONDigits%d",ichamber+1);
156 //(MUONLoader->TreeD()->GetBranch(branchname))->SetAddress(&((*pMUON->Dchambers())[ichamber]));
160 Int_t icathode, ncathodes;
163 for(icathode=0; icathode<ncathodes; icathode++) {
164 printf(">>> Cathode %d\n",icathode);
165 MUONLoader->TreeD()->GetEvent(icathode);
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);
173 Int_t idigit, ndigits;
175 ndigits = (Int_t) ListOfDigits->GetEntriesFast();
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);
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);
190 } // end chamber loop
191 } // end cathode loop
193 MUONLoader->UnloadDigits();
196 void MUONrecpoints(char * filename="galice.root") {
198 TClonesArray * ListOfRecPoints;
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);
207 // Loading AliRun master
208 RunLoader->LoadgAlice();
209 gAlice = RunLoader->GetAliRun();
210 // Getting Module MUON
211 AliMUON *pMUON = (AliMUON *) gAlice->GetDetector("MUON");
213 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
214 MUONLoader->LoadRecPoints("READ");
216 Int_t ievent, nevents;
217 nevents = RunLoader->GetNumberOfEvents();
219 AliMUONRawCluster * mRecPoint;
222 for(ievent=0; ievent<nevents; ievent++) {
223 printf(">>> Event %d \n",ievent);
224 RunLoader->GetEvent(ievent);
227 Int_t ichamber, nchambers;
228 nchambers = AliMUONConstants::NTrackingCh();
229 pMUON->SetTreeAddress();
232 MUONLoader->TreeR()->GetEvent(0);
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);
240 Int_t irecpoint, nrecpoints;
242 nrecpoints = (Int_t) ListOfRecPoints->GetEntriesFast();
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
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];
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
285 MUONLoader->UnloadRecPoints();
288 void MUONTestTrigger (char * filename="galice.root"){
289 // reads and dumps trigger objects from MUON.RecPoints.root
290 TClonesArray * globalTrigger;
291 TClonesArray * localTrigger;
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);
300 // Loading AliRun master
301 RunLoader->LoadgAlice();
302 gAlice = RunLoader->GetAliRun();
303 // Getting Module MUON
304 AliMUON *pMUON = (AliMUON *) gAlice->GetDetector("MUON");
306 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
307 MUONLoader->LoadRecPoints("READ");
309 Int_t ievent, nevents;
310 nevents = RunLoader->GetNumberOfEvents();
312 AliMUONGlobalTrigger *gloTrg;
313 AliMUONLocalTrigger *locTrg;
315 for (ievent=0; ievent<nevents; ievent++) {
316 RunLoader->GetEvent(ievent);
318 pMUON->SetTreeAddress();
319 MUONLoader->TreeR()->GetEvent(0);
321 globalTrigger = (TClonesArray *) pMUON->GlobalTrigger();
322 localTrigger = (TClonesArray *) pMUON->LocalTrigger();
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";
330 for (Int_t iglobal=0; iglobal<nglobals; iglobal++) { // Global Trigger
331 gloTrg = static_cast<AliMUONGlobalTrigger*>(globalTrigger->At(iglobal));
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());
339 printf(" number of Single Minus :\t");
340 printf("%i\t%i\t%i\t",gloTrg->SingleMinusLpt(),
341 gloTrg->SingleMinusHpt(),gloTrg->SingleMinusApt());
343 printf(" number of Single Undefined :\t");
344 printf("%i\t%i\t%i\t",gloTrg->SingleUndefLpt(),
345 gloTrg->SingleUndefHpt(),gloTrg->SingleUndefApt());
347 printf(" number of UnlikeSign pair :\t");
348 printf("%i\t%i\t%i\t",gloTrg->PairUnlikeLpt(),
349 gloTrg->PairUnlikeHpt(),gloTrg->PairUnlikeApt());
351 printf(" number of LikeSign pair :\t");
352 printf("%i\t%i\t%i\t",gloTrg->PairLikeLpt(),
353 gloTrg->PairLikeHpt(),gloTrg->PairLikeApt());
355 printf("===================================================\n");
357 } // end of loop on Global Trigger
359 for (Int_t ilocal=0; ilocal<nlocals; ilocal++) { // Local Trigger
360 cout << " >>> Output for Local Trigger " << ilocal << "\n";
362 locTrg = static_cast<AliMUONLocalTrigger*>(localTrigger->At(ilocal));
364 cout << "Circuit StripX Dev StripY: "
365 << locTrg->LoCircuit() << " "
366 << locTrg->LoStripX() << " "
367 << locTrg->LoDev() << " "
368 << locTrg->LoStripY()
370 cout << "Lpt Hpt Apt: "
371 << locTrg->LoLpt() << " "
372 << locTrg->LoHpt() << " "
373 << locTrg->LoApt() << "\n";
375 } // end of loop on Local Trigger
376 } // end loop on event