]>
Commit | Line | Data |
---|---|---|
6309cf6e | 1 | |
2 | ||
3 | //Root includes | |
4 | ||
5 | //AliRoot includes | |
6 | #include "AliMUONData.h" | |
7 | #include "AliMUONDigit.h" | |
8 | #include "AliMUONHit.h" | |
9 | #include "AliMUONLocalTrigger.h" | |
10 | #include "AliMUONGlobalTrigger.h" | |
11 | #include "AliMUONRawCluster.h" | |
dcd2690d | 12 | #include "AliMUONTrack.h" |
6309cf6e | 13 | |
14 | ClassImp(AliMUONData) | |
15 | ||
16 | //_____________________________________________________________________________ | |
17 | AliMUONData::AliMUONData():TNamed() | |
18 | { | |
19 | fLoader = 0x0; | |
20 | fHits = 0x0; // One event in treeH per primary track | |
21 | fDigits = 0x0; // One event in treeH per detection plane | |
ce3f5e87 | 22 | fNdigits = 0x0; |
6309cf6e | 23 | fRawClusters = 0x0; //One event in TreeR/RawclusterBranch per tracking detection plane |
24 | fGlobalTrigger = 0x0; //! List of Global Trigger 1st event in TreeR/GlobalTriggerBranch | |
dcd2690d | 25 | fLocalTrigger = 0x0; //! List of Local Trigger, 1st event in TreeR/LocalTriggerBranch |
26 | fRecTracks = 0x0; | |
6309cf6e | 27 | //default constructor |
28 | } | |
29 | //_____________________________________________________________________________ | |
30 | AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title): | |
31 | TNamed(name,title) | |
32 | { | |
33 | fLoader = loader; | |
34 | fHits = new TClonesArray("AliMUONHit",1000); | |
35 | fNhits = 0; | |
36 | fDigits = new TObjArray(AliMUONConstants::NCh()); | |
37 | fNdigits = new Int_t[AliMUONConstants::NCh()]; | |
38 | for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) { | |
39 | fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane); | |
40 | fNdigits[iDetectionPlane]=0; | |
41 | } | |
42 | fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh()); | |
43 | fNrawclusters = new Int_t[AliMUONConstants::NTrackingCh()]; | |
44 | for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NTrackingCh();iDetectionPlane++) { | |
45 | fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),iDetectionPlane); | |
46 | fNrawclusters[iDetectionPlane]=0; | |
47 | } | |
48 | fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1); | |
49 | fNglobaltrigger =0; | |
50 | fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234); | |
51 | fNlocaltrigger = 0; | |
dcd2690d | 52 | fRecTracks = new TClonesArray("AliMUONTrack", 10); |
53 | fNrectracks = 0; // really needed or GetEntriesFast sufficient ???? | |
6309cf6e | 54 | //default constructor |
55 | } | |
56 | //_____________________________________________________________________________ | |
57 | AliMUONData::AliMUONData(const AliMUONData& rMUONData):TNamed(rMUONData) | |
58 | { | |
59 | // Dummy copy constructor | |
60 | ; | |
61 | } | |
62 | //_____________________________________________________________________________ | |
63 | AliMUONData::~AliMUONData() | |
64 | { | |
65 | if (fHits) { | |
66 | fHits->Delete(); | |
67 | delete fHits; | |
68 | } | |
69 | if (fDigits) { | |
70 | fDigits->Delete(); | |
71 | delete fDigits; | |
72 | } | |
73 | if (fRawClusters) { | |
74 | fRawClusters->Delete(); | |
75 | delete fRawClusters; | |
76 | } | |
77 | if (fGlobalTrigger){ | |
78 | fGlobalTrigger->Delete(); | |
79 | delete fGlobalTrigger; | |
80 | } | |
81 | if (fLocalTrigger){ | |
82 | fLocalTrigger->Delete(); | |
83 | delete fLocalTrigger; | |
84 | } | |
dcd2690d | 85 | if (fRecTracks){ |
86 | fRecTracks->Delete(); | |
87 | delete fRecTracks; | |
88 | } | |
6309cf6e | 89 | //detructor |
90 | } | |
91 | //_____________________________________________________________________________ | |
92 | void AliMUONData::AddDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits) | |
93 | { | |
94 | // | |
95 | // Add a MUON digit to the list of Digits of the detection plane id | |
96 | // | |
ce3f5e87 | 97 | TClonesArray &ldigits = * Digits(id,0) ; |
6309cf6e | 98 | new(ldigits[fNdigits[id]++]) AliMUONDigit(tracks,charges,digits); |
99 | } | |
100 | //_____________________________________________________________________________ | |
101 | void AliMUONData::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus, | |
102 | Int_t *singleUndef, | |
103 | Int_t *pairUnlike, Int_t *pairLike) | |
104 | { | |
105 | // add a MUON Global Trigger to the list (only one GlobalTrigger per event !) | |
106 | TClonesArray &globalTrigger = *fGlobalTrigger; | |
107 | new(globalTrigger[fNglobaltrigger++]) | |
108 | AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike); | |
109 | } | |
110 | //_____________________________________________________________________________ | |
111 | void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber, | |
112 | Int_t idpart, Float_t X, Float_t Y, Float_t Z, | |
113 | Float_t tof, Float_t momentum, Float_t theta, | |
114 | Float_t phi, Float_t length, Float_t destep) | |
115 | { | |
116 | TClonesArray &lhits = *fHits; | |
117 | new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber, | |
118 | idpart, X, Y, Z, | |
119 | tof, momentum, theta, | |
120 | phi, length, destep); | |
121 | } | |
122 | //____________________________________________________________________________ | |
123 | void AliMUONData::AddLocalTrigger(Int_t *localtr) | |
124 | { | |
125 | // add a MUON Local Trigger to the list | |
126 | TClonesArray &localTrigger = *fLocalTrigger; | |
127 | new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(localtr); | |
128 | } | |
129 | //_____________________________________________________________________________ | |
130 | void AliMUONData::AddRawCluster(Int_t id, const AliMUONRawCluster& c) | |
131 | { | |
132 | // | |
133 | // Add a MUON rawcluster to the list in the detection plane id | |
134 | // | |
135 | TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id)); | |
136 | new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c); | |
137 | } | |
dcd2690d | 138 | //_____________________________________________________________________________ |
139 | void AliMUONData::AddRecTrack(const AliMUONTrack& track) | |
140 | { | |
141 | // | |
142 | // Add a MUON rectrack | |
143 | // | |
144 | TClonesArray &lrectracks = *fRecTracks; | |
145 | new(lrectracks[fNrectracks++]) AliMUONTrack(track); | |
146 | } | |
ce3f5e87 | 147 | //____________________________________________________________________________ |
6309cf6e | 148 | void AliMUONData::MakeBranch(Option_t* option) |
149 | { | |
150 | // | |
151 | // Create Tree branches for the MUON. | |
152 | // | |
153 | const Int_t kBufferSize = 4000; | |
154 | char branchname[30]; | |
155 | ||
156 | const char *cH = strstr(option,"H"); | |
157 | const char *cD = strstr(option,"D"); // Digits branches in TreeD | |
158 | const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR | |
159 | const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR | |
160 | const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT | |
161 | const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP | |
162 | ||
163 | TBranch * branch = 0x0; | |
164 | ||
165 | // Creating Branches for Hits | |
166 | if (TreeH() && cH) { | |
167 | if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000); | |
168 | fNhits = 0; | |
169 | sprintf(branchname,"%sHits",GetName()); | |
170 | branch = TreeH()->GetBranch(branchname); | |
171 | if (branch) { | |
172 | Info("MakeBranch","Branch %s is already in tree.",GetName()); | |
173 | return ; | |
174 | } | |
175 | branch = TreeH()->Branch(branchname,&fHits,kBufferSize); | |
176 | Info("MakeBranch","Making Branch %s for hits \n",branchname); | |
177 | } | |
178 | ||
179 | //Creating Branches for Digits | |
180 | if (TreeD() && cD ) { | |
181 | // one branch for digits per chamber | |
182 | if (fDigits == 0x0) { | |
ce3f5e87 | 183 | fDigits = new TObjArray(AliMUONConstants::NCh()); |
6309cf6e | 184 | for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) { |
185 | fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane); | |
ce3f5e87 | 186 | } |
187 | } | |
188 | if (fNdigits == 0x0) { | |
189 | fNdigits = new Int_t[AliMUONConstants::NCh()]; | |
190 | for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) { | |
6309cf6e | 191 | fNdigits[iDetectionPlane]=0; |
192 | } | |
193 | } | |
194 | for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) { | |
195 | sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1); | |
196 | branch = 0x0; | |
197 | branch = TreeD()->GetBranch(branchname); | |
198 | if (branch) { | |
199 | Info("MakeBranch","Branch %s is already in tree.",GetName()); | |
200 | return; | |
201 | } | |
ce3f5e87 | 202 | TClonesArray * digits = Digits(iDetectionPlane,0); |
203 | branch = TreeD()->Branch(branchname, &digits, kBufferSize); | |
6309cf6e | 204 | Info("MakeBranch","Making Branch %s for digits in detection plane %d\n",branchname,iDetectionPlane+1); |
205 | } | |
206 | } | |
207 | ||
208 | if (TreeR() && cRC ) { | |
209 | // one branch for raw clusters per tracking detection plane | |
210 | // | |
211 | Int_t i; | |
212 | if (fRawClusters == 0x0) { | |
213 | fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh()); | |
6309cf6e | 214 | for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) { |
215 | fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i); | |
ce3f5e87 | 216 | } |
217 | } | |
218 | ||
219 | if (fNrawclusters == 0x0) { | |
220 | fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()]; | |
221 | for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) { | |
6309cf6e | 222 | fNrawclusters[i]=0; |
223 | } | |
224 | } | |
225 | ||
226 | for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) { | |
227 | sprintf(branchname,"%sRawClusters%d",GetName(),i+1); | |
228 | branch = 0x0; | |
229 | branch = TreeR()->GetBranch(branchname); | |
230 | if (branch) { | |
231 | Info("MakeBranch","Branch %s is already in tree.",GetName()); | |
232 | return; | |
233 | } | |
234 | branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize); | |
235 | Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1); | |
236 | } | |
237 | } | |
238 | ||
239 | if (TreeR() && cGLT ) { | |
240 | // | |
241 | // one branch for global trigger | |
242 | // | |
243 | sprintf(branchname,"%sGlobalTrigger",GetName()); | |
244 | branch = 0x0; | |
245 | ||
246 | if (fGlobalTrigger == 0x0) { | |
247 | fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1); | |
248 | fNglobaltrigger = 0; | |
249 | } | |
250 | branch = TreeR()->GetBranch(branchname); | |
251 | if (branch) { | |
252 | Info("MakeBranch","Branch %s is already in tree.",GetName()); | |
253 | return ; | |
254 | } | |
255 | branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize); | |
256 | Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname); | |
257 | ||
258 | // | |
259 | // one branch for local trigger | |
260 | // | |
261 | sprintf(branchname,"%sLocalTrigger",GetName()); | |
262 | branch = 0x0; | |
263 | ||
264 | if (fLocalTrigger == 0x0) { | |
265 | fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234); | |
266 | fNlocaltrigger = 0; | |
267 | } | |
268 | branch = TreeR()->GetBranch(branchname); | |
269 | if (branch) { | |
270 | Info("MakeBranch","Branch %s is already in tree.",GetName()); | |
271 | return; | |
272 | } | |
273 | branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize); | |
274 | Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname); | |
275 | } | |
276 | ||
dcd2690d | 277 | if (TreeT() && cRT ) { |
278 | if (fRecTracks == 0x0) fRecTracks = new TClonesArray("AliMUONTrack",10); | |
279 | fNrectracks = 0; | |
280 | sprintf(branchname,"%sTrack",GetName()); | |
281 | branch = TreeT()->GetBranch(branchname); | |
282 | if (branch) { | |
283 | Info("MakeBranch","Branch %s is already in tree.",GetName()); | |
284 | return ; | |
285 | } | |
286 | branch = TreeT()->Branch(branchname,&fRecTracks,kBufferSize); | |
287 | Info("MakeBranch","Making Branch %s for tracks \n",branchname); | |
288 | } | |
289 | ||
290 | if (TreeP() && cRP ) { | |
6309cf6e | 291 | Info("MakeBranch","Making Branch for TreeP is not yet ready. \n"); |
292 | } | |
293 | } | |
294 | ||
295 | //____________________________________________________________________________ | |
296 | void AliMUONData::ResetDigits() | |
297 | { | |
298 | // | |
299 | // Reset number of digits and the digits array for this detector | |
300 | // | |
301 | if (fDigits == 0x0) return; | |
302 | for ( int i=0;i<AliMUONConstants::NCh();i++ ) { | |
303 | if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear(); | |
304 | if (fNdigits) fNdigits[i]=0; | |
305 | } | |
306 | } | |
307 | //______________________________________________________________________________ | |
308 | void AliMUONData::ResetHits() | |
309 | { | |
310 | // Reset number of clusters and the cluster array for this detector | |
311 | fNhits = 0; | |
312 | if (fHits) fHits->Clear(); | |
313 | } | |
314 | //_______________________________________________________________________________ | |
315 | void AliMUONData::ResetRawClusters() | |
316 | { | |
317 | // Reset number of raw clusters and the raw clust array for this detector | |
318 | // | |
319 | for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) { | |
320 | if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear(); | |
321 | if (fNrawclusters) fNrawclusters[i]=0; | |
322 | } | |
323 | } | |
324 | //_______________________________________________________________________________ | |
325 | void AliMUONData::ResetTrigger() | |
326 | { | |
327 | // Reset Local and Global Trigger | |
328 | fNglobaltrigger = 0; | |
329 | if (fGlobalTrigger) fGlobalTrigger->Clear(); | |
330 | fNlocaltrigger = 0; | |
331 | if (fLocalTrigger) fLocalTrigger->Clear(); | |
332 | } | |
dcd2690d | 333 | //____________________________________________________________________________ |
334 | void AliMUONData::ResetRecTracks() | |
335 | { | |
336 | // Reset tracks information | |
337 | fNrectracks = 0; | |
338 | if (fRecTracks) fRecTracks->Clear(); | |
339 | } | |
6309cf6e | 340 | //_____________________________________________________________________________ |
ce3f5e87 | 341 | void AliMUONData::SetTreeAddress(Option_t* option) |
6309cf6e | 342 | { |
ce3f5e87 | 343 | const char *cH = strstr(option,"H"); |
344 | const char *cD = strstr(option,"D"); // Digits branches in TreeD | |
345 | const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR | |
346 | const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR | |
dcd2690d | 347 | const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT |
ce3f5e87 | 348 | //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP |
349 | ||
6309cf6e | 350 | // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree. |
351 | char branchname[30]; | |
352 | TBranch * branch = 0x0; | |
353 | ||
354 | // | |
355 | // Branch address for hit tree | |
ce3f5e87 | 356 | if ( TreeH() && cH ) { |
6309cf6e | 357 | if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000); |
358 | fNhits =0; | |
359 | } | |
ce3f5e87 | 360 | if (TreeH() && fHits && cH) { |
6309cf6e | 361 | sprintf(branchname,"%sHits",GetName()); |
362 | branch = TreeH()->GetBranch(branchname); | |
363 | if (branch) { | |
364 | Info("SetTreeAddress","(%s) Setting for Hits",GetName()); | |
365 | branch->SetAddress(&fHits); | |
366 | } | |
367 | else { //can be invoked before branch creation | |
368 | Warning("SetTreeAddress","(%s) Failed for Hits. Can not find branch in tree.",GetName()); | |
369 | } | |
370 | } | |
371 | ||
372 | // | |
373 | // Branch address for digit tree | |
ce3f5e87 | 374 | if ( TreeD() && cD) { |
6309cf6e | 375 | if (fDigits == 0x0) { |
376 | fDigits = new TObjArray(AliMUONConstants::NCh()); | |
377 | fNdigits= new Int_t[AliMUONConstants::NCh()]; | |
378 | for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) { | |
379 | fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i); | |
380 | fNdigits[i]=0; | |
381 | } | |
382 | } | |
383 | } | |
384 | ||
ce3f5e87 | 385 | if (TreeD() && fDigits && cD) { |
6309cf6e | 386 | for (int i=0; i<AliMUONConstants::NCh(); i++) { |
387 | sprintf(branchname,"%sDigits%d",GetName(),i+1); | |
388 | branch = TreeD()->GetBranch(branchname); | |
ce3f5e87 | 389 | TClonesArray * digits = Digits(i,0); |
390 | if (branch) branch->SetAddress( &digits ); | |
6309cf6e | 391 | else Warning("SetTreeAddress","(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i); |
392 | } | |
393 | } | |
394 | ||
395 | // | |
396 | // Branch address for rawclusters, globaltrigger and local trigger tree | |
397 | if (TreeR() ) { | |
ce3f5e87 | 398 | if (fRawClusters == 0x0 && cRC) { |
6309cf6e | 399 | fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh()); |
400 | fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()]; | |
401 | for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) { | |
402 | fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i); | |
403 | fNrawclusters[i]=0; | |
404 | } | |
405 | } | |
ce3f5e87 | 406 | if (fLocalTrigger == 0x0 && cGLT) { |
6309cf6e | 407 | fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234); |
408 | } | |
ce3f5e87 | 409 | if (fGlobalTrigger== 0x0 && cGLT) { |
6309cf6e | 410 | fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1); |
411 | } | |
412 | ||
413 | } | |
ce3f5e87 | 414 | if ( TreeR() && fRawClusters && cRC) { |
6309cf6e | 415 | for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) { |
416 | sprintf(branchname,"%sRawClusters%d",GetName(),i+1); | |
417 | if (fRawClusters) { | |
418 | branch = TreeR()->GetBranch(branchname); | |
419 | if (branch) branch->SetAddress(&((*fRawClusters)[i])); | |
420 | else Warning("SetTreeAddress","(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i); | |
421 | } | |
422 | } | |
423 | } | |
ce3f5e87 | 424 | if ( TreeR() && fLocalTrigger && cGLT) { |
6309cf6e | 425 | sprintf(branchname,"%sLocalTrigger",GetName()); |
426 | branch = TreeR()->GetBranch(branchname); | |
427 | if (branch) branch->SetAddress(&fLocalTrigger); | |
428 | else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName()); | |
429 | } | |
ce3f5e87 | 430 | if ( TreeR() && fGlobalTrigger && cGLT) { |
6309cf6e | 431 | sprintf(branchname,"%sGlobalTrigger",GetName()); |
432 | branch = TreeR()->GetBranch(branchname); | |
433 | if (branch) branch->SetAddress(&fGlobalTrigger); | |
434 | else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName()); | |
435 | } | |
dcd2690d | 436 | |
437 | if ( TreeT() && fRecTracks && cRT ) { | |
438 | sprintf(branchname,"%sTrack",GetName()); | |
439 | branch = TreeT()->GetBranch(branchname); | |
440 | if (branch) branch->SetAddress(&fRecTracks); | |
441 | else Warning("SetTreeAddress","(%s) Failed for Tracks. Can not find branch in tree.",GetName()); | |
442 | } | |
6309cf6e | 443 | } |
444 | //_____________________________________________________________________________ |