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);
69 // Loading MUON subsystem
70 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
71 MUONLoader->LoadHits("READ"); // Loading Tree of hits for MUON
72 AliMUONData muondata(MUONLoader,"MUON","MUON"); // Creating MUON data container
73 Int_t ievent, nevents;
74 nevents = RunLoader->GetNumberOfEvents();
76 for(ievent=0; ievent<nevents; ievent++) { // Event loop
77 printf(">>> Event %d \n",ievent);
78 // Getting event ievent
79 RunLoader->GetEvent(ievent);
80 muondata.SetTreeAddress("H");
81 Int_t itrack, ntracks;
82 ntracks = (Int_t) muondata.GetNtracks();
83 for (itrack=0; itrack<ntracks; itrack++) { // Track loop
84 printf(">>> Track %d \n",itrack);
86 //Getting List of Hits of Track itrack
87 muondata.GetTrack(itrack);
90 nhits = (Int_t) muondata.Hits()->GetEntriesFast();
91 printf(">>> Number of hits %d \n",nhits);
93 for(ihit=0; ihit<nhits; ihit++) {
94 mHit = static_cast<AliMUONHit*>(muondata.Hits()->At(ihit));
95 Int_t Nch = mHit->Chamber(); // chamber number
96 Int_t hittrack = mHit->Track();
97 Float_t x = mHit->X();
98 Float_t y = mHit->Y();
99 Float_t z = mHit->Z();
100 Float_t elos = mHit->Eloss();
101 Float_t theta = mHit->Theta();
102 Float_t phi = mHit->Phi();
103 Float_t momentum = mHit->Momentum();
104 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",
105 ihit, Nch,hittrack,x,y,z,elos,theta,phi, momentum);
107 muondata.ResetHits();
110 MUONLoader->UnloadHits();
114 void MUONdigits(char * filename="galice.root")
116 // Creating Run Loader and openning file containing Hits
117 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
118 if (RunLoader ==0x0) {
119 printf(">>> Error : Error Opening %s file \n",filename);
122 // Loading MUON subsystem
123 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
124 MUONLoader->LoadDigits("READ");
125 // Creating MUON data container
126 AliMUONData muondata(MUONLoader,"MUON","MUON");
128 Int_t ievent, nevents;
129 nevents = RunLoader->GetNumberOfEvents();
130 AliMUONDigit * mDigit;
132 for(ievent=0; ievent<nevents; ievent++) {
133 printf(">>> Event %d \n",ievent);
134 RunLoader->GetEvent(ievent);
137 Int_t ichamber, nchambers;
138 nchambers = AliMUONConstants::NCh(); ;
139 muondata.SetTreeAddress("D");
142 Int_t icathode, ncathodes;
145 for(icathode=0; icathode<ncathodes; icathode++) {
146 printf(">>> Cathode %d\n",icathode);
147 muondata.GetCathode(icathode);
149 for( ichamber=0; ichamber<nchambers; ichamber++) {
150 printf(">>> Chamber %d\n",ichamber);
152 Int_t idigit, ndigits;
153 ndigits = (Int_t) muondata.Digits(ichamber)->GetEntriesFast();
155 for(idigit=0; idigit<ndigits; idigit++) {
156 mDigit = static_cast<AliMUONDigit*>(muondata.Digits(ichamber)->At(idigit));
157 Int_t PadX = mDigit->PadX(); // Pad X number
158 Int_t PadY = mDigit->PadY(); // Pad Y number
159 Int_t Signal = mDigit->Signal(); // Physics Signal
160 Int_t Hit = mDigit->Hit(); // iHit
161 Int_t Cathode= mDigit->Cathode(); // Cathode
162 Int_t Track0 = mDigit->Track(0);
163 Int_t Track1 = mDigit->Track(1);
164 Int_t Track2 = mDigit->Track(2);
166 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);
168 } // end chamber loop
169 muondata.ResetDigits();
170 } // end cathode loop
172 MUONLoader->UnloadDigits();
175 void MUONrecpoints(char * filename="galice.root") {
177 // Creating Run Loader and openning file containing Hits
178 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
179 if (RunLoader ==0x0) {
180 printf(">>> Error : Error Opening %s file \n",filename);
183 // Getting MUONloader
184 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
185 MUONLoader->LoadRecPoints("READ");
186 // Creating MUON data container
187 AliMUONData muondata(MUONLoader,"MUON","MUON");
189 Int_t ievent, nevents;
190 nevents = RunLoader->GetNumberOfEvents();
191 AliMUONRawCluster * mRecPoint;
193 for(ievent=0; ievent<nevents; ievent++) {
194 printf(">>> Event %d \n",ievent);
195 RunLoader->GetEvent(ievent);
197 Int_t ichamber, nchambers;
198 nchambers = AliMUONConstants::NTrackingCh();
199 muondata.SetTreeAddress("RC");
201 muondata.GetRawClusters();
203 for( ichamber=0; ichamber<nchambers; ichamber++) {
204 printf(">>> Chamber %d\n",ichamber);
205 sprintf(branchname,"MUONRawClusters%d",ichamber+1);
206 //printf(">>> branchname %s\n",branchname);
208 Int_t irecpoint, nrecpoints;
209 nrecpoints = (Int_t) muondata.RawClusters(ichamber)->GetEntriesFast();
211 for(irecpoint=0; irecpoint<nrecpoints; irecpoint++) {
212 mRecPoint = static_cast<AliMUONRawCluster*>(muondata.RawClusters(ichamber)->At(irecpoint));
213 // Int_t fTracks[3]; //labels of overlapped tracks
214 // Int_t fQ[2] ; // Q of cluster (in ADC counts)
215 // Float_t fX[2] ; // X of cluster
216 // Float_t fY[2] ; // Y of cluster
217 // Float_t fZ[2] ; // Z of cluster
218 // Int_t fPeakSignal[2]; // Peak signal
219 // Int_t fIndexMap[50][2]; // indeces of digits
220 // Int_t fOffsetMap[50][2]; // Emmanuel special
221 // Float_t fContMap[50][2]; // Contribution from digit
222 // Int_t fPhysicsMap[50]; // Distinguish signal and background contr.
223 // Int_t fMultiplicity[2]; // Cluster multiplicity
224 // Int_t fNcluster[2]; // Number of clusters
225 // Int_t fClusterType; // Cluster type
226 // Float_t fChi2[2]; // Chi**2 of fit
227 // Int_t fGhost; // 0 if not a ghost or ghost problem solved
228 // // >0 if ghost problem remains because
229 // // 1 both (true and ghost) satify
230 // // charge chi2 compatibility
231 // // 2 none give satisfactory chi2
233 Int_t Track0 = mRecPoint->fTracks[0];
234 Int_t Track1 = mRecPoint->fTracks[1];
235 Int_t Track2 = mRecPoint->fTracks[2];
236 Int_t Q0 = mRecPoint->fQ[0];
237 Int_t Q1 = mRecPoint->fQ[1];
238 Float_t x0 = mRecPoint->fX[0];
239 Float_t x1 = mRecPoint->fX[1];
240 Float_t y0 = mRecPoint->fY[0];
241 Float_t y1 = mRecPoint->fY[1];
242 Float_t z0 = mRecPoint->fZ[0];
243 Float_t z1 = mRecPoint->fZ[1];
244 Float_t chi2_0 = mRecPoint->fChi2[0];
245 Float_t chi2_1 = mRecPoint->fChi2[1];
247 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",
248 irecpoint, x0, x1, y0, y1, z0, z1, Q0, Q1, Track0, Track1, Track2, chi2_0, chi2_1);
249 } // end recpoint loop
250 } // end chamber loop
251 muondata.ResetRawClusters();
253 MUONLoader->UnloadRecPoints();
256 void MUONTestTrigger (char * filename="galice.root"){
257 // reads and dumps trigger objects from MUON.RecPoints.root
258 TClonesArray * globalTrigger;
259 TClonesArray * localTrigger;
261 // Creating Run Loader and openning file containing Hits
262 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
263 if (RunLoader ==0x0) {
264 printf(">>> Error : Error Opening %s file \n",filename);
268 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
269 MUONLoader->LoadRecPoints("READ");
270 // Creating MUON data container
271 AliMUONData muondata(MUONLoader,"MUON","MUON");
274 Int_t ievent, nevents;
275 nevents = RunLoader->GetNumberOfEvents();
277 AliMUONGlobalTrigger *gloTrg;
278 AliMUONLocalTrigger *locTrg;
280 for (ievent=0; ievent<nevents; ievent++) {
281 RunLoader->GetEvent(ievent);
283 muondata.SetTreeAddress("GLT");
284 muondata.GetTrigger();
286 globalTrigger = muondata.GlobalTrigger();
287 localTrigger = muondata.LocalTrigger();
289 Int_t nglobals = (Int_t) globalTrigger->GetEntriesFast(); // should be 1
290 Int_t nlocals = (Int_t) localTrigger->GetEntriesFast(); // up to 234
291 printf("###################################################\n");
292 cout << " event " << ievent
293 << " nglobals nlocals: " << nglobals << " " << nlocals << "\n";
295 for (Int_t iglobal=0; iglobal<nglobals; iglobal++) { // Global Trigger
296 gloTrg = static_cast<AliMUONGlobalTrigger*>(globalTrigger->At(iglobal));
298 printf("===================================================\n");
299 printf(" Global Trigger output Low pt High pt All\n");
300 printf(" number of Single Plus :\t");
301 printf("%i\t%i\t%i\t",gloTrg->SinglePlusLpt(),
302 gloTrg->SinglePlusHpt(),gloTrg->SinglePlusApt());
304 printf(" number of Single Minus :\t");
305 printf("%i\t%i\t%i\t",gloTrg->SingleMinusLpt(),
306 gloTrg->SingleMinusHpt(),gloTrg->SingleMinusApt());
308 printf(" number of Single Undefined :\t");
309 printf("%i\t%i\t%i\t",gloTrg->SingleUndefLpt(),
310 gloTrg->SingleUndefHpt(),gloTrg->SingleUndefApt());
312 printf(" number of UnlikeSign pair :\t");
313 printf("%i\t%i\t%i\t",gloTrg->PairUnlikeLpt(),
314 gloTrg->PairUnlikeHpt(),gloTrg->PairUnlikeApt());
316 printf(" number of LikeSign pair :\t");
317 printf("%i\t%i\t%i\t",gloTrg->PairLikeLpt(),
318 gloTrg->PairLikeHpt(),gloTrg->PairLikeApt());
320 printf("===================================================\n");
322 } // end of loop on Global Trigger
324 for (Int_t ilocal=0; ilocal<nlocals; ilocal++) { // Local Trigger
325 cout << " >>> Output for Local Trigger " << ilocal << "\n";
327 locTrg = static_cast<AliMUONLocalTrigger*>(localTrigger->At(ilocal));
329 cout << "Circuit StripX Dev StripY: "
330 << locTrg->LoCircuit() << " "
331 << locTrg->LoStripX() << " "
332 << locTrg->LoDev() << " "
333 << locTrg->LoStripY()
335 cout << "Lpt Hpt Apt: "
336 << locTrg->LoLpt() << " "
337 << locTrg->LoHpt() << " "
338 << locTrg->LoApt() << "\n";
340 } // end of loop on Local Trigger
341 muondata.ResetTrigger();
342 } // end loop on event