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 "AliMUONData.h"
24 #include "AliMUONHit.h"
25 #include "AliMUONConstants.h"
26 #include "AliMUONDigit.h"
27 #include "AliMUONRawCluster.h"
28 #include "AliMUONGlobalTrigger.h"
29 #include "AliMUONLocalTrigger.h"
31 void MUONkine(char * filename="galice.root")
33 TClonesArray * ListOfParticles = new TClonesArray("TParticle",1000);
34 TParticle * particle = new TParticle();
35 // Creating Run Loader and openning file containing Hits
36 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
37 if (RunLoader ==0x0) {
38 printf(">>> Error : Error Opening %s file \n",filename);
41 RunLoader->LoadKinematics("READ");
42 Int_t ievent, nevents;
43 nevents = RunLoader->GetNumberOfEvents();
45 for(ievent=0; ievent<nevents; ievent++) { // Event loop
46 Int_t iparticle, nparticles;
47 // Getting event ievent
48 RunLoader->GetEvent(ievent);
49 RunLoader->TreeK()->GetBranch("Particles")->SetAddress(&particle);
50 nparticles = RunLoader->TreeK()->GetEntries();
51 printf(">>> Event %d, Number of particles is %d \n",ievent, nparticles);
52 for(iparticle=0; iparticle<nparticles; iparticle++) {
53 RunLoader->TreeK()->GetEvent(iparticle);
57 RunLoader->UnloadKinematics();
61 void MUONhits(char * filename="galice.root")
63 // Creating Run Loader and openning file containing Hits
64 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
65 if (RunLoader ==0x0) {
66 printf(">>> Error : Error Opening %s file \n",filename);
70 // Loading MUON subsystem
71 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
72 MUONLoader->LoadHits("READ");
73 // Creating MUON data container
74 AliMUONData muondata(MUONLoader,"MUON","MUON");
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 muondata.SetTreeAddress("H");
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) muondata.Hits()->GetEntriesFast();
96 printf(">>> Number of hits %d \n",nhits);
98 for(ihit=0; ihit<nhits; ihit++) {
99 mHit = static_cast<AliMUONHit*>(muondata.Hits()->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);
112 muondata.ResetHits();
115 MUONLoader->UnloadHits();
119 void MUONdigits(char * filename="galice.root")
121 // Creating Run Loader and openning file containing Hits
122 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
123 if (RunLoader ==0x0) {
124 printf(">>> Error : Error Opening %s file \n",filename);
127 // Loading MUON subsystem
128 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
129 MUONLoader->LoadDigits("READ");
131 // Creating MUON data container
132 AliMUONData muondata(MUONLoader,"MUON","MUON");
134 Int_t ievent, nevents;
135 nevents = RunLoader->GetNumberOfEvents();
137 AliMUONDigit * mDigit;
140 for(ievent=0; ievent<nevents; ievent++) {
141 printf(">>> Event %d \n",ievent);
142 RunLoader->GetEvent(ievent);
145 Int_t ichamber, nchambers;
146 nchambers = AliMUONConstants::NCh(); ;
147 muondata.SetTreeAddress("D");
150 Int_t icathode, ncathodes;
153 for(icathode=0; icathode<ncathodes; icathode++) {
154 printf(">>> Cathode %d\n",icathode);
155 MUONLoader->TreeD()->GetEvent(icathode);
157 for( ichamber=0; ichamber<nchambers; ichamber++) {
158 printf(">>> Chamber %d\n",ichamber);
159 // sprintf(branchname,"MUONDigits%d",ichamber+1);
160 //printf(">>> branchname %s\n",branchname);
162 Int_t idigit, ndigits;
164 ndigits = (Int_t) muondata.Digits(ichamber,0)->GetEntriesFast();
166 for(idigit=0; idigit<ndigits; idigit++) {
167 mDigit = static_cast<AliMUONDigit*>(muondata.Digits(ichamber,0)->At(idigit));
168 Int_t PadX = mDigit->PadX(); // Pad X number
169 Int_t PadY = mDigit->PadY(); // Pad Y number
170 Int_t Signal = mDigit->Signal(); // Physics Signal
171 Int_t Hit = mDigit->Hit(); // iHit
172 Int_t Cathode= mDigit->Cathode(); // Cathode
173 Int_t Track0 = mDigit->Track(0);
174 Int_t Track1 = mDigit->Track(1);
175 Int_t Track2 = mDigit->Track(2);
177 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);
179 } // end chamber loop
180 muondata.ResetDigits();
181 } // end cathode loop
183 MUONLoader->UnloadDigits();
186 void MUONrecpoints(char * filename="galice.root") {
188 // Creating Run Loader and openning file containing Hits
189 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
190 if (RunLoader ==0x0) {
191 printf(">>> Error : Error Opening %s file \n",filename);
194 // Getting MUONloader
195 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
196 MUONLoader->LoadRecPoints("READ");
197 // Creating MUON data container
198 AliMUONData muondata(MUONLoader,"MUON","MUON");
200 Int_t ievent, nevents;
201 nevents = RunLoader->GetNumberOfEvents();
203 AliMUONRawCluster * mRecPoint;
205 for(ievent=0; ievent<nevents; ievent++) {
206 printf(">>> Event %d \n",ievent);
207 RunLoader->GetEvent(ievent);
210 Int_t ichamber, nchambers;
211 nchambers = AliMUONConstants::NTrackingCh();
212 muondata.SetTreeAddress("RC");
214 MUONLoader->TreeR()->GetEvent(0);
216 for( ichamber=0; ichamber<nchambers; ichamber++) {
217 printf(">>> Chamber %d\n",ichamber);
218 sprintf(branchname,"MUONRawClusters%d",ichamber+1);
219 //printf(">>> branchname %s\n",branchname);
221 Int_t irecpoint, nrecpoints;
223 nrecpoints = (Int_t) muondata.RawClusters(ichamber)->GetEntriesFast();
225 for(irecpoint=0; irecpoint<nrecpoints; irecpoint++) {
226 mRecPoint = static_cast<AliMUONRawCluster*>(muondata.RawClusters(ichamber)->At(irecpoint));
227 // Int_t fTracks[3]; //labels of overlapped tracks
228 // Int_t fQ[2] ; // Q of cluster (in ADC counts)
229 // Float_t fX[2] ; // X of cluster
230 // Float_t fY[2] ; // Y of cluster
231 // Float_t fZ[2] ; // Z of cluster
232 // Int_t fPeakSignal[2]; // Peak signal
233 // Int_t fIndexMap[50][2]; // indeces of digits
234 // Int_t fOffsetMap[50][2]; // Emmanuel special
235 // Float_t fContMap[50][2]; // Contribution from digit
236 // Int_t fPhysicsMap[50]; // Distinguish signal and background contr.
237 // Int_t fMultiplicity[2]; // Cluster multiplicity
238 // Int_t fNcluster[2]; // Number of clusters
239 // Int_t fClusterType; // Cluster type
240 // Float_t fChi2[2]; // Chi**2 of fit
241 // Int_t fGhost; // 0 if not a ghost or ghost problem solved
242 // // >0 if ghost problem remains because
243 // // 1 both (true and ghost) satify
244 // // charge chi2 compatibility
245 // // 2 none give satisfactory chi2
247 Int_t Track0 = mRecPoint->fTracks[0];
248 Int_t Track1 = mRecPoint->fTracks[1];
249 Int_t Track2 = mRecPoint->fTracks[2];
250 Int_t Q0 = mRecPoint->fQ[0];
251 Int_t Q1 = mRecPoint->fQ[1];
252 Float_t x0 = mRecPoint->fX[0];
253 Float_t x1 = mRecPoint->fX[1];
254 Float_t y0 = mRecPoint->fY[0];
255 Float_t y1 = mRecPoint->fY[1];
256 Float_t z0 = mRecPoint->fZ[0];
257 Float_t z1 = mRecPoint->fZ[1];
258 Float_t chi2_0 = mRecPoint->fChi2[0];
259 Float_t chi2_1 = mRecPoint->fChi2[1];
261 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",
262 irecpoint, x0, x1, y0, y1, z0, z1, Q0, Q1, Track0, Track1, Track2, chi2_0, chi2_1);
263 } // end recpoint loop
264 } // end chamber loop
265 muondata.ResetRawClusters();
267 MUONLoader->UnloadRecPoints();
270 void MUONTestTrigger (char * filename="galice.root"){
271 // reads and dumps trigger objects from MUON.RecPoints.root
272 TClonesArray * globalTrigger;
273 TClonesArray * localTrigger;
275 // Creating Run Loader and openning file containing Hits
276 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
277 if (RunLoader ==0x0) {
278 printf(">>> Error : Error Opening %s file \n",filename);
282 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
283 MUONLoader->LoadRecPoints("READ");
284 // Creating MUON data container
285 AliMUONData muondata(MUONLoader,"MUON","MUON");
288 Int_t ievent, nevents;
289 nevents = RunLoader->GetNumberOfEvents();
291 AliMUONGlobalTrigger *gloTrg;
292 AliMUONLocalTrigger *locTrg;
294 for (ievent=0; ievent<nevents; ievent++) {
295 RunLoader->GetEvent(ievent);
297 muondata.SetTreeAddress("GLT");
298 MUONLoader->TreeR()->GetEvent(0);
300 globalTrigger = muondata.GlobalTrigger();
301 localTrigger = muondata.LocalTrigger();
303 Int_t nglobals = (Int_t) globalTrigger->GetEntriesFast(); // should be 1
304 Int_t nlocals = (Int_t) localTrigger->GetEntriesFast(); // up to 234
305 printf("###################################################\n");
306 cout << " event " << ievent
307 << " nglobals nlocals: " << nglobals << " " << nlocals << "\n";
309 for (Int_t iglobal=0; iglobal<nglobals; iglobal++) { // Global Trigger
310 gloTrg = static_cast<AliMUONGlobalTrigger*>(globalTrigger->At(iglobal));
312 printf("===================================================\n");
313 printf(" Global Trigger output Low pt High pt All\n");
314 printf(" number of Single Plus :\t");
315 printf("%i\t%i\t%i\t",gloTrg->SinglePlusLpt(),
316 gloTrg->SinglePlusHpt(),gloTrg->SinglePlusApt());
318 printf(" number of Single Minus :\t");
319 printf("%i\t%i\t%i\t",gloTrg->SingleMinusLpt(),
320 gloTrg->SingleMinusHpt(),gloTrg->SingleMinusApt());
322 printf(" number of Single Undefined :\t");
323 printf("%i\t%i\t%i\t",gloTrg->SingleUndefLpt(),
324 gloTrg->SingleUndefHpt(),gloTrg->SingleUndefApt());
326 printf(" number of UnlikeSign pair :\t");
327 printf("%i\t%i\t%i\t",gloTrg->PairUnlikeLpt(),
328 gloTrg->PairUnlikeHpt(),gloTrg->PairUnlikeApt());
330 printf(" number of LikeSign pair :\t");
331 printf("%i\t%i\t%i\t",gloTrg->PairLikeLpt(),
332 gloTrg->PairLikeHpt(),gloTrg->PairLikeApt());
334 printf("===================================================\n");
336 } // end of loop on Global Trigger
338 for (Int_t ilocal=0; ilocal<nlocals; ilocal++) { // Local Trigger
339 cout << " >>> Output for Local Trigger " << ilocal << "\n";
341 locTrg = static_cast<AliMUONLocalTrigger*>(localTrigger->At(ilocal));
343 cout << "Circuit StripX Dev StripY: "
344 << locTrg->LoCircuit() << " "
345 << locTrg->LoStripX() << " "
346 << locTrg->LoDev() << " "
347 << locTrg->LoStripY()
349 cout << "Lpt Hpt Apt: "
350 << locTrg->LoLpt() << " "
351 << locTrg->LoHpt() << " "
352 << locTrg->LoApt() << "\n";
354 } // end of loop on Local Trigger
355 muondata.ResetTrigger();
356 } // end loop on event