New MUON data container AliMUONData implementation
[u/mrichter/AliRoot.git] / MUON / MUONCheck.C
CommitLineData
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"
ce3f5e87 23#include "AliMUONData.h"
88cb7938 24#include "AliMUONHit.h"
25#include "AliMUONConstants.h"
26#include "AliMUONDigit.h"
27#include "AliMUONRawCluster.h"
28#include "AliMUONGlobalTrigger.h"
29#include "AliMUONLocalTrigger.h"
30
31void MUONkine(char * filename="galice.root")
32{
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);
39 return;
40 }
41 RunLoader->LoadKinematics("READ");
42 Int_t ievent, nevents;
43 nevents = RunLoader->GetNumberOfEvents();
44
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);
54 particle->Print("");
55 }
56 }
57 RunLoader->UnloadKinematics();
58}
59
60
61void MUONhits(char * filename="galice.root")
62{
88cb7938 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);
67 return;
68 }
69
70 // Loading MUON subsystem
71 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
72 MUONLoader->LoadHits("READ");
ce3f5e87 73 // Creating MUON data container
74 AliMUONData muondata(MUONLoader,"MUON","MUON");
88cb7938 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);
ce3f5e87 84 muondata.SetTreeAddress("H");
85
88cb7938 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;
ce3f5e87 95 nhits = (Int_t) muondata.Hits()->GetEntriesFast();
88cb7938 96 printf(">>> Number of hits %d \n",nhits);
97 AliMUONHit* mHit;
98 for(ihit=0; ihit<nhits; ihit++) {
ce3f5e87 99 mHit = static_cast<AliMUONHit*>(muondata.Hits()->At(ihit));
88cb7938 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 }
ce3f5e87 112 muondata.ResetHits();
88cb7938 113 } // end track loop
114 } // end event loop
115 MUONLoader->UnloadHits();
116}
117
118
119void MUONdigits(char * filename="galice.root")
120{
88cb7938 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);
125 return;
126 }
ce3f5e87 127 // Loading MUON subsystem
88cb7938 128 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
129 MUONLoader->LoadDigits("READ");
130
ce3f5e87 131 // Creating MUON data container
132 AliMUONData muondata(MUONLoader,"MUON","MUON");
133
88cb7938 134 Int_t ievent, nevents;
135 nevents = RunLoader->GetNumberOfEvents();
136
137 AliMUONDigit * mDigit;
138
139
140 for(ievent=0; ievent<nevents; ievent++) {
141 printf(">>> Event %d \n",ievent);
142 RunLoader->GetEvent(ievent);
143
144 // Addressing
145 Int_t ichamber, nchambers;
146 nchambers = AliMUONConstants::NCh(); ;
ce3f5e87 147 muondata.SetTreeAddress("D");
88cb7938 148 char branchname[30];
ce3f5e87 149
88cb7938 150 Int_t icathode, ncathodes;
151 ncathodes=2;
152 //Loop on cathodes
153 for(icathode=0; icathode<ncathodes; icathode++) {
154 printf(">>> Cathode %d\n",icathode);
155 MUONLoader->TreeD()->GetEvent(icathode);
156 // Loop on chambers
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);
88cb7938 161
162 Int_t idigit, ndigits;
163
ce3f5e87 164 ndigits = (Int_t) muondata.Digits(ichamber,0)->GetEntriesFast();
88cb7938 165
166 for(idigit=0; idigit<ndigits; idigit++) {
ce3f5e87 167 mDigit = static_cast<AliMUONDigit*>(muondata.Digits(ichamber,0)->At(idigit));
88cb7938 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);
176
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);
178 } // end digit loop
179 } // end chamber loop
ce3f5e87 180 muondata.ResetDigits();
88cb7938 181 } // end cathode loop
182 } // end event loop
183 MUONLoader->UnloadDigits();
184}
185
186void MUONrecpoints(char * filename="galice.root") {
187
88cb7938 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);
192 return;
193 }
ce3f5e87 194 // Getting MUONloader
88cb7938 195 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
196 MUONLoader->LoadRecPoints("READ");
ce3f5e87 197 // Creating MUON data container
198 AliMUONData muondata(MUONLoader,"MUON","MUON");
88cb7938 199
200 Int_t ievent, nevents;
201 nevents = RunLoader->GetNumberOfEvents();
202
203 AliMUONRawCluster * mRecPoint;
204
88cb7938 205 for(ievent=0; ievent<nevents; ievent++) {
206 printf(">>> Event %d \n",ievent);
207 RunLoader->GetEvent(ievent);
208
209 // Addressing
210 Int_t ichamber, nchambers;
211 nchambers = AliMUONConstants::NTrackingCh();
ce3f5e87 212 muondata.SetTreeAddress("RC");
88cb7938 213 char branchname[30];
88cb7938 214 MUONLoader->TreeR()->GetEvent(0);
215 // Loop on chambers
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);
ce3f5e87 220
88cb7938 221 Int_t irecpoint, nrecpoints;
222
ce3f5e87 223 nrecpoints = (Int_t) muondata.RawClusters(ichamber)->GetEntriesFast();
88cb7938 224
225 for(irecpoint=0; irecpoint<nrecpoints; irecpoint++) {
ce3f5e87 226 mRecPoint = static_cast<AliMUONRawCluster*>(muondata.RawClusters(ichamber)->At(irecpoint));
88cb7938 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
246
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];
260
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",
262irecpoint, x0, x1, y0, y1, z0, z1, Q0, Q1, Track0, Track1, Track2, chi2_0, chi2_1);
263 } // end recpoint loop
264 } // end chamber loop
ce3f5e87 265 muondata.ResetRawClusters();
88cb7938 266 } // end event loop
267 MUONLoader->UnloadRecPoints();
268}
269
270void MUONTestTrigger (char * filename="galice.root"){
271// reads and dumps trigger objects from MUON.RecPoints.root
272 TClonesArray * globalTrigger;
273 TClonesArray * localTrigger;
274
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);
279 return;
280 }
281
88cb7938 282 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
283 MUONLoader->LoadRecPoints("READ");
ce3f5e87 284 // Creating MUON data container
285 AliMUONData muondata(MUONLoader,"MUON","MUON");
88cb7938 286
ce3f5e87 287
88cb7938 288 Int_t ievent, nevents;
289 nevents = RunLoader->GetNumberOfEvents();
290
291 AliMUONGlobalTrigger *gloTrg;
292 AliMUONLocalTrigger *locTrg;
293
294 for (ievent=0; ievent<nevents; ievent++) {
295 RunLoader->GetEvent(ievent);
296
ce3f5e87 297 muondata.SetTreeAddress("GLT");
88cb7938 298 MUONLoader->TreeR()->GetEvent(0);
299
ce3f5e87 300 globalTrigger = muondata.GlobalTrigger();
301 localTrigger = muondata.LocalTrigger();
88cb7938 302
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";
308
309 for (Int_t iglobal=0; iglobal<nglobals; iglobal++) { // Global Trigger
310 gloTrg = static_cast<AliMUONGlobalTrigger*>(globalTrigger->At(iglobal));
311
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());
317 printf("\n");
318 printf(" number of Single Minus :\t");
319 printf("%i\t%i\t%i\t",gloTrg->SingleMinusLpt(),
320 gloTrg->SingleMinusHpt(),gloTrg->SingleMinusApt());
321 printf("\n");
322 printf(" number of Single Undefined :\t");
323 printf("%i\t%i\t%i\t",gloTrg->SingleUndefLpt(),
324 gloTrg->SingleUndefHpt(),gloTrg->SingleUndefApt());
325 printf("\n");
326 printf(" number of UnlikeSign pair :\t");
327 printf("%i\t%i\t%i\t",gloTrg->PairUnlikeLpt(),
328 gloTrg->PairUnlikeHpt(),gloTrg->PairUnlikeApt());
329 printf("\n");
330 printf(" number of LikeSign pair :\t");
331 printf("%i\t%i\t%i\t",gloTrg->PairLikeLpt(),
332 gloTrg->PairLikeHpt(),gloTrg->PairLikeApt());
333 printf("\n");
334 printf("===================================================\n");
335
336 } // end of loop on Global Trigger
337
338 for (Int_t ilocal=0; ilocal<nlocals; ilocal++) { // Local Trigger
339 cout << " >>> Output for Local Trigger " << ilocal << "\n";
340
341 locTrg = static_cast<AliMUONLocalTrigger*>(localTrigger->At(ilocal));
342
343 cout << "Circuit StripX Dev StripY: "
344 << locTrg->LoCircuit() << " "
345 << locTrg->LoStripX() << " "
346 << locTrg->LoDev() << " "
347 << locTrg->LoStripY()
348 << "\n";
349 cout << "Lpt Hpt Apt: "
350 << locTrg->LoLpt() << " "
351 << locTrg->LoHpt() << " "
352 << locTrg->LoApt() << "\n";
353
354 } // end of loop on Local Trigger
ce3f5e87 355 muondata.ResetTrigger();
88cb7938 356 } // end loop on event
357}
358
359
360
361
362