Two new classes added.
[u/mrichter/AliRoot.git] / MUON / AliMUONData.cxx
CommitLineData
50837721 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
9140dcef 17// AliMUONData classes
18// Class containing MUON data: hits, digits, rawclusters, globaltrigger, localtrigger, etc ..
19// The classe makes the lik between the MUON data lists and the event trees from loaders
20// Gines Martinez, Subatech, September 2003
21//
22
6309cf6e 23//Root includes
1a1cdff8 24#include "TNamed.h"
374ebd7d 25//AliRoot include
1988766a 26#include "AliRun.h"
27#include "AliMC.h"
1a1cdff8 28#include "AliLoader.h"
29#include "AliMUONConstants.h"
6309cf6e 30#include "AliMUONData.h"
31#include "AliMUONDigit.h"
32#include "AliMUONHit.h"
33#include "AliMUONLocalTrigger.h"
34#include "AliMUONGlobalTrigger.h"
35#include "AliMUONRawCluster.h"
dcd2690d 36#include "AliMUONTrack.h"
276c44b7 37#include "AliMUONTriggerTrack.h"
6309cf6e 38ClassImp(AliMUONData)
39
40//_____________________________________________________________________________
41AliMUONData::AliMUONData():TNamed()
42{
9140dcef 43 // Default constructor
6309cf6e 44 fLoader = 0x0;
45 fHits = 0x0; // One event in treeH per primary track
46 fDigits = 0x0; // One event in treeH per detection plane
ce3f5e87 47 fNdigits = 0x0;
6309cf6e 48 fRawClusters = 0x0; //One event in TreeR/RawclusterBranch per tracking detection plane
49 fGlobalTrigger = 0x0; //! List of Global Trigger 1st event in TreeR/GlobalTriggerBranch
dcd2690d 50 fLocalTrigger = 0x0; //! List of Local Trigger, 1st event in TreeR/LocalTriggerBranch
51 fRecTracks = 0x0;
276c44b7 52 fRecTriggerTracks = 0x0;
d652f85c 53 fSplitLevel = 0;
6309cf6e 54//default constructor
55}
56//_____________________________________________________________________________
57AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
58 TNamed(name,title)
59{
9140dcef 60 // Constructor for AliMUONData
6309cf6e 61 fLoader = loader;
b1c7d777 62 fHits = 0x0; // One event in treeH per primary track
63 fDigits = 0x0; // One event in treeH per detection plane
64 fNdigits = 0x0;
65 fRawClusters = 0x0; //One event in TreeR/RawclusterBranch per tracking detection plane
66 fGlobalTrigger = 0x0; //! List of Global Trigger 1st event in TreeR/GlobalTriggerBranch
67 fLocalTrigger = 0x0; //! List of Local Trigger, 1st event in TreeR/LocalTriggerBranch
68 fRecTracks = 0x0;
276c44b7 69 fRecTriggerTracks = 0x0;
6309cf6e 70 fNhits = 0;
6309cf6e 71 fNglobaltrigger =0;
6309cf6e 72 fNlocaltrigger = 0;
d652f85c 73 fNrectracks = 0;
276c44b7 74 fNrectriggertracks = 0;
d652f85c 75 fSplitLevel = 0;
b1c7d777 76// fHits = new TClonesArray("AliMUONHit",1000);
77// fNhits = 0;
78// fDigits = new TObjArray(AliMUONConstants::NCh());
79// fNdigits = new Int_t[AliMUONConstants::NCh()];
80// for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
81// fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
82// fNdigits[iDetectionPlane]=0;
83// }
84// fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
85// fNrawclusters = new Int_t[AliMUONConstants::NTrackingCh()];
86// for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NTrackingCh();iDetectionPlane++) {
87// fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),iDetectionPlane);
88// fNrawclusters[iDetectionPlane]=0;
89// }
90// fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
91// fNglobaltrigger =0;
92// fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
93// fNlocaltrigger = 0;
374ebd7d 94// fRecTracks = new TClonesArray("AliMUONTrack", 100);
b1c7d777 95// fNrectracks = 0; // really needed or GetEntriesFast sufficient ????
96
97
6309cf6e 98 //default constructor
99}
100//_____________________________________________________________________________
101AliMUONData::AliMUONData(const AliMUONData& rMUONData):TNamed(rMUONData)
102{
103 // Dummy copy constructor
104 ;
105}
106//_____________________________________________________________________________
107AliMUONData::~AliMUONData()
108{
9140dcef 109 // Destructor for AliMUONData
6309cf6e 110 if (fHits) {
111 fHits->Delete();
112 delete fHits;
113 }
114 if (fDigits) {
115 fDigits->Delete();
116 delete fDigits;
117 }
118 if (fRawClusters) {
119 fRawClusters->Delete();
120 delete fRawClusters;
121 }
122 if (fGlobalTrigger){
123 fGlobalTrigger->Delete();
124 delete fGlobalTrigger;
125 }
126 if (fLocalTrigger){
127 fLocalTrigger->Delete();
128 delete fLocalTrigger;
129 }
dcd2690d 130 if (fRecTracks){
131 fRecTracks->Delete();
132 delete fRecTracks;
133 }
276c44b7 134 if (fRecTriggerTracks){
135 fRecTriggerTracks->Delete();
136 delete fRecTriggerTracks;
137 }
6309cf6e 138 //detructor
139}
140//_____________________________________________________________________________
141void AliMUONData::AddDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
142{
143 //
144 // Add a MUON digit to the list of Digits of the detection plane id
145 //
1a1cdff8 146 TClonesArray &ldigits = * Digits(id) ;
6309cf6e 147 new(ldigits[fNdigits[id]++]) AliMUONDigit(tracks,charges,digits);
148}
149//_____________________________________________________________________________
61adb9bd 150void AliMUONData::AddDigit(Int_t id, const AliMUONDigit& digit)
151{
152 //
153 // Add a MUON digit to the list of Digits of the detection plane id
154 //
155 TClonesArray &ldigits = * Digits(id) ;
156 new(ldigits[fNdigits[id]++]) AliMUONDigit(digit);
157}
158//_____________________________________________________________________________
6309cf6e 159void AliMUONData::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
160 Int_t *singleUndef,
161 Int_t *pairUnlike, Int_t *pairLike)
162{
163 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
164 TClonesArray &globalTrigger = *fGlobalTrigger;
165 new(globalTrigger[fNglobaltrigger++])
166 AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
167}
168//_____________________________________________________________________________
61adb9bd 169void AliMUONData::AddGlobalTrigger(const AliMUONGlobalTrigger& trigger )
170{
171 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
172 TClonesArray &globalTrigger = *fGlobalTrigger;
173 new(globalTrigger[fNglobaltrigger++]) AliMUONGlobalTrigger(trigger);
174}
175//_____________________________________________________________________________
6309cf6e 176void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
177 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
178 Float_t tof, Float_t momentum, Float_t theta,
179 Float_t phi, Float_t length, Float_t destep)
180{
9140dcef 181 // Add new hit to the hit list
6309cf6e 182 TClonesArray &lhits = *fHits;
183 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
184 idpart, X, Y, Z,
185 tof, momentum, theta,
186 phi, length, destep);
187}
188//____________________________________________________________________________
1391e633 189void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
190 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
191 Float_t tof, Float_t momentum, Float_t theta,
192 Float_t phi, Float_t length, Float_t destep,
193 Float_t Xref,Float_t Yref,Float_t Zref)
194{
9140dcef 195 // Add new hit to the hit list
1391e633 196 TClonesArray &lhits = *fHits;
197 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
198 idpart, X, Y, Z,
199 tof, momentum, theta,
200 phi, length, destep,
201 Xref,Yref,Zref);
202}
203//____________________________________________________________________________
61adb9bd 204void AliMUONData::AddHit(const AliMUONHit& hit)
205{
206 TClonesArray &lhits = *fHits;
207 new(lhits[fNhits++]) AliMUONHit(hit);
208}
209//____________________________________________________________________________
6309cf6e 210void AliMUONData::AddLocalTrigger(Int_t *localtr)
211{
212 // add a MUON Local Trigger to the list
213 TClonesArray &localTrigger = *fLocalTrigger;
214 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(localtr);
215}
61adb9bd 216//____________________________________________________________________________
217void AliMUONData::AddLocalTrigger(const AliMUONLocalTrigger& trigger)
218{
219 // add a MUON Local Trigger to the list
220 TClonesArray &localTrigger = *fLocalTrigger;
221 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(trigger);
222}
6309cf6e 223//_____________________________________________________________________________
224void AliMUONData::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
225{
226 //
227 // Add a MUON rawcluster to the list in the detection plane id
228 //
229 TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id));
230 new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c);
231}
dcd2690d 232//_____________________________________________________________________________
233void AliMUONData::AddRecTrack(const AliMUONTrack& track)
234{
235 //
236 // Add a MUON rectrack
237 //
238 TClonesArray &lrectracks = *fRecTracks;
239 new(lrectracks[fNrectracks++]) AliMUONTrack(track);
61adb9bd 240 // printf("TTTTTT %d ,\n",((AliMUONTrack*)fRecTracks->At(fNrectracks-1))->GetNTrackHits());
dcd2690d 241}
276c44b7 242//_____________________________________________________________________________
243void AliMUONData::AddRecTriggerTrack(const AliMUONTriggerTrack& triggertrack)
244{
245 //
246 // Add a MUON triggerrectrack
247 //
248 TClonesArray &lrectriggertracks = *fRecTriggerTracks;
249 new(lrectriggertracks[fNrectriggertracks++]) AliMUONTriggerTrack(triggertrack);
250 // printf("TTTTTT %d ,\n",((AliMUONTrack*)fRecTracks->At(fNrectracks-1))->GetNTrackHits());
251}
252
ce3f5e87 253//____________________________________________________________________________
1eccde20 254TClonesArray* AliMUONData::Digits(Int_t DetectionPlane)
255{
9140dcef 256 //Getting List of Digits
1eccde20 257 if (fDigits)
258 return ( (TClonesArray*) fDigits->At(DetectionPlane) );
259 else
260 return NULL;
261}
262//____________________________________________________________________________
c1d45bdf 263Bool_t AliMUONData::IsRawClusterBranchesInTree()
264{
9140dcef 265 // Checking if there are RawCluster Branches In TreeR
c1d45bdf 266 if (TreeR()==0x0) {
267 Error("TreeR","No treeR in memory");
268 return kFALSE;
269 }
270 else {
271 char branchname[30];
272 sprintf(branchname,"%sRawClusters1",GetName());
273 TBranch * branch = 0x0;
274 branch = TreeR()->GetBranch(branchname);
275 if (branch) return kTRUE;
276 else return kFALSE;
277 }
278}
279//____________________________________________________________________________
280Bool_t AliMUONData::IsTriggerBranchesInTree()
281{
9140dcef 282 // Checking if there are Trigger Branches In TreeR
c1d45bdf 283 if (TreeR()==0x0) {
284 Error("TreeR","No treeR in memory");
285 return kFALSE;
286 }
287 else {
288 char branchname[30];
289 sprintf(branchname,"%sLocalTrigger",GetName());
290 TBranch * branch = 0x0;
291 branch = TreeR()->GetBranch(branchname);
292 if (branch) return kTRUE;
293 else return kFALSE;
294 }
295}
296//____________________________________________________________________________
276c44b7 297Bool_t AliMUONData::IsTrackBranchesInTree()
298{
299 // Checking if there are Track Branches In TreeT
300 if (TreeT()==0x0) {
301 Error("TreeT","No treeT in memory");
302 return kFALSE;
303 }
304 else {
305 char branchname[30];
306 sprintf(branchname,"%sTrack",GetName());
307 TBranch * branch = 0x0;
308 branch = TreeT()->GetBranch(branchname);
309 if (branch) return kTRUE;
310 else return kFALSE;
311 }
312}
313//____________________________________________________________________________
314Bool_t AliMUONData::IsTriggerTrackBranchesInTree()
315{
316 // Checking if there are TriggerTrack Branches In TreeT
317 if (TreeT()==0x0) {
318 Error("TreeT","No treeT in memory");
319 return kFALSE;
320 }
321 else {
322 char branchname[30];
323 sprintf(branchname,"%sTriggerTrack",GetName());
324 TBranch * branch = 0x0;
325 branch = TreeT()->GetBranch(branchname);
326 if (branch) return kTRUE;
327 else return kFALSE;
328 }
329}
330//____________________________________________________________________________
1a1cdff8 331void AliMUONData::Fill(Option_t* option)
332{
333 // Method to fill the trees
334 const char *cH = strstr(option,"H");
335 const char *cD = strstr(option,"D"); // Digits branches in TreeD
336 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
337 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
338 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
276c44b7 339 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
61adb9bd 340
1a1cdff8 341 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
342
343 char branchname[30];
344 TBranch * branch = 0x0;
345
346 //
347 // Filling TreeH
348 if ( TreeH() && cH ) {
349 TreeH()->Fill();
350 }
351 //
352 // Filling TreeD
353 if ( TreeD() && cD) {
354 TreeD()->Fill();
355 }
c1d45bdf 356
1a1cdff8 357 //
358 // filling rawclusters
c1d45bdf 359 if ( TreeR() && cRC ) {
360 if ( IsTriggerBranchesInTree() ) {
361 // Branch per branch filling
362 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
363 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
364 branch = TreeR()->GetBranch(branchname);
365 branch->Fill();
366 }
367 }
368 else TreeR()->Fill();
1a1cdff8 369 }
c1d45bdf 370
1a1cdff8 371 //
372 // filling trigger
373 if ( TreeR() && cGLT) {
346357f4 374 if (IsRawClusterBranchesInTree()) {
c1d45bdf 375 // Branch per branch filling
376 sprintf(branchname,"%sLocalTrigger",GetName());
377 branch = TreeR()->GetBranch(branchname);
378 branch->Fill();
379 sprintf(branchname,"%sGlobalTrigger",GetName());
380 branch = TreeR()->GetBranch(branchname);
381 branch->Fill();
382 }
383 else TreeR()->Fill();
1a1cdff8 384 }
385 //
386 // filling tracks
387 if ( TreeT() && cRT ) {
276c44b7 388 if (IsTriggerTrackBranchesInTree()) {
389 sprintf(branchname,"%sTrack",GetName());
390 branch = TreeT()->GetBranch(branchname);
391 branch->Fill();
392 }
393 else TreeT()->Fill();
394 }
395 // filling trigger tracks
396 if ( TreeT() && cRL ) {
397 if (IsTrackBranchesInTree()) {
398 sprintf(branchname,"%sTriggerTrack",GetName());
399 branch = TreeT()->GetBranch(branchname);
400 branch->Fill();
401 }
402 else TreeT()->Fill();
1a1cdff8 403 }
276c44b7 404// if ( TreeT() && cRL ) {
61adb9bd 405// sprintf(branchname,"%sTrackTrig",GetName());
406// TreeT()->Fill();
407// }
1a1cdff8 408}
409//_____________________________________________________________________________
6309cf6e 410void AliMUONData::MakeBranch(Option_t* option)
411{
412 //
413 // Create Tree branches for the MUON.
414 //
415 const Int_t kBufferSize = 4000;
416 char branchname[30];
417
276c44b7 418
6309cf6e 419 const char *cH = strstr(option,"H");
420 const char *cD = strstr(option,"D"); // Digits branches in TreeD
421 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
422 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
423 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
276c44b7 424 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
61adb9bd 425 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
276c44b7 426
6309cf6e 427 TBranch * branch = 0x0;
428
429 // Creating Branches for Hits
430 if (TreeH() && cH) {
1988766a 431
432 if (fHits == 0x0) {
433 fHits = new TClonesArray("AliMUONHit",1000);
307d9d04 434// if (gAlice->GetMCApp())
435// gAlice->GetMCApp()->AddHitList (fHits);
1988766a 436 }
437
6309cf6e 438 fNhits = 0;
439 sprintf(branchname,"%sHits",GetName());
440 branch = TreeH()->GetBranch(branchname);
441 if (branch) {
442 Info("MakeBranch","Branch %s is already in tree.",GetName());
443 return ;
444 }
c6ce342a 445 branch = TreeH()->Branch(branchname,&fHits,kBufferSize);
cba99c31 446 //Info("MakeBranch","Making Branch %s for hits \n",branchname);
6309cf6e 447 }
448
449 //Creating Branches for Digits
450 if (TreeD() && cD ) {
451 // one branch for digits per chamber
452 if (fDigits == 0x0) {
ce3f5e87 453 fDigits = new TObjArray(AliMUONConstants::NCh());
6309cf6e 454 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
455 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
ce3f5e87 456 }
457 }
458 if (fNdigits == 0x0) {
459 fNdigits = new Int_t[AliMUONConstants::NCh()];
460 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
6309cf6e 461 fNdigits[iDetectionPlane]=0;
462 }
463 }
464 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
465 sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
466 branch = 0x0;
467 branch = TreeD()->GetBranch(branchname);
468 if (branch) {
469 Info("MakeBranch","Branch %s is already in tree.",GetName());
470 return;
471 }
1a1cdff8 472 TClonesArray * digits = Digits(iDetectionPlane);
d652f85c 473 branch = TreeD()->Branch(branchname, &digits, kBufferSize,1);
cba99c31 474 //Info("MakeBranch","Making Branch %s for digits in detection plane %d\n",branchname,iDetectionPlane+1);
6309cf6e 475 }
476 }
477
478 if (TreeR() && cRC ) {
479 // one branch for raw clusters per tracking detection plane
480 //
481 Int_t i;
482 if (fRawClusters == 0x0) {
483 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
6309cf6e 484 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
d652f85c 485 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",1000),i);
ce3f5e87 486 }
487 }
488
489 if (fNrawclusters == 0x0) {
490 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
491 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
6309cf6e 492 fNrawclusters[i]=0;
493 }
494 }
495
496 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
497 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
498 branch = 0x0;
499 branch = TreeR()->GetBranch(branchname);
500 if (branch) {
501 Info("MakeBranch","Branch %s is already in tree.",GetName());
502 return;
503 }
c6ce342a 504 branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize);
cba99c31 505 //Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1);
6309cf6e 506 }
507 }
508
509 if (TreeR() && cGLT ) {
510 //
511 // one branch for global trigger
512 //
513 sprintf(branchname,"%sGlobalTrigger",GetName());
514 branch = 0x0;
515
516 if (fGlobalTrigger == 0x0) {
c6ce342a 517 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger");
6309cf6e 518 fNglobaltrigger = 0;
519 }
520 branch = TreeR()->GetBranch(branchname);
521 if (branch) {
522 Info("MakeBranch","Branch %s is already in tree.",GetName());
523 return ;
524 }
c6ce342a 525 branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize);
cba99c31 526 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
6309cf6e 527
528 //
529 // one branch for local trigger
530 //
531 sprintf(branchname,"%sLocalTrigger",GetName());
532 branch = 0x0;
533
534 if (fLocalTrigger == 0x0) {
535 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
536 fNlocaltrigger = 0;
537 }
538 branch = TreeR()->GetBranch(branchname);
539 if (branch) {
540 Info("MakeBranch","Branch %s is already in tree.",GetName());
541 return;
542 }
c6ce342a 543 branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize);
cba99c31 544 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
6309cf6e 545 }
546
dcd2690d 547 if (TreeT() && cRT ) {
374ebd7d 548 if (fRecTracks == 0x0) fRecTracks = new TClonesArray("AliMUONTrack",100);
dcd2690d 549 fNrectracks = 0;
550 sprintf(branchname,"%sTrack",GetName());
551 branch = TreeT()->GetBranch(branchname);
552 if (branch) {
553 Info("MakeBranch","Branch %s is already in tree.",GetName());
554 return ;
555 }
556 branch = TreeT()->Branch(branchname,&fRecTracks,kBufferSize);
cba99c31 557 //Info("MakeBranch","Making Branch %s for tracks \n",branchname);
dcd2690d 558 }
276c44b7 559// trigger tracks
560 if (TreeT() && cRL ) {
561 if (fRecTriggerTracks == 0x0) fRecTriggerTracks = new TClonesArray("AliMUONTriggerTrack",100);
562 fNrectriggertracks = 0;
563 sprintf(branchname,"%sTriggerTrack",GetName());
564 branch = TreeT()->GetBranch(branchname);
565 if (branch) {
566 Info("MakeBranch","Branch %s is already in tree.",GetName());
567 return ;
568 }
569 branch = TreeT()->Branch(branchname,&fRecTriggerTracks,kBufferSize);
cba99c31 570 //Info("MakeBranch","Making Branch %s for trigger tracks \n",branchname);
276c44b7 571 }
6309cf6e 572}
1eccde20 573//____________________________________________________________________________
574TClonesArray* AliMUONData::RawClusters(Int_t DetectionPlane)
575{
9140dcef 576 // Getting Raw Clusters
1eccde20 577 if (fRawClusters)
578 return ( (TClonesArray*) fRawClusters->At(DetectionPlane) );
579 else
580 return NULL;
581}
6309cf6e 582//____________________________________________________________________________
276c44b7 583TClonesArray* AliMUONData::LocalTrigger()
584{
585 // Getting Local Trigger
586 if (fLocalTrigger)
587 return ( (TClonesArray*) fLocalTrigger );
588 else
589 return NULL;
590}
591//____________________________________________________________________________
592TClonesArray* AliMUONData::GlobalTrigger()
593{
594 // Getting Global Trigger
595 if (fGlobalTrigger)
596 return ( (TClonesArray*) fGlobalTrigger );
597 else
598 return NULL;
599}
600//____________________________________________________________________________
6309cf6e 601void AliMUONData::ResetDigits()
602{
603 //
604 // Reset number of digits and the digits array for this detector
605 //
606 if (fDigits == 0x0) return;
607 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
608 if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear();
609 if (fNdigits) fNdigits[i]=0;
610 }
611}
612//______________________________________________________________________________
613void AliMUONData::ResetHits()
614{
615 // Reset number of clusters and the cluster array for this detector
616 fNhits = 0;
617 if (fHits) fHits->Clear();
618}
619//_______________________________________________________________________________
620void AliMUONData::ResetRawClusters()
621{
622 // Reset number of raw clusters and the raw clust array for this detector
623 //
624 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
625 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
626 if (fNrawclusters) fNrawclusters[i]=0;
627 }
628}
629//_______________________________________________________________________________
630void AliMUONData::ResetTrigger()
631{
632 // Reset Local and Global Trigger
633 fNglobaltrigger = 0;
634 if (fGlobalTrigger) fGlobalTrigger->Clear();
635 fNlocaltrigger = 0;
636 if (fLocalTrigger) fLocalTrigger->Clear();
637}
dcd2690d 638//____________________________________________________________________________
639void AliMUONData::ResetRecTracks()
640{
641 // Reset tracks information
642 fNrectracks = 0;
643 if (fRecTracks) fRecTracks->Clear();
644}
276c44b7 645//____________________________________________________________________________
646void AliMUONData::ResetRecTriggerTracks()
647{
648 // Reset tracks information
649 fNrectriggertracks = 0;
650 if (fRecTriggerTracks) fRecTriggerTracks->Clear();
651}
6309cf6e 652//_____________________________________________________________________________
ce3f5e87 653void AliMUONData::SetTreeAddress(Option_t* option)
6309cf6e 654{
9140dcef 655 //Setting Addresses to the events trees
ce3f5e87 656 const char *cH = strstr(option,"H");
657 const char *cD = strstr(option,"D"); // Digits branches in TreeD
658 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
659 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
dcd2690d 660 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
276c44b7 661 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
ce3f5e87 662 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
663
6309cf6e 664 // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree.
665 char branchname[30];
666 TBranch * branch = 0x0;
667
668 //
669 // Branch address for hit tree
ce3f5e87 670 if ( TreeH() && cH ) {
88cf591d 671 if (fHits == 0x0) {
672 fHits = new TClonesArray("AliMUONHit",1000);
d74a82ab 673 if (gAlice->GetMCApp())
674 gAlice->GetMCApp()->AddHitList (fHits);
88cf591d 675 }
6309cf6e 676 fNhits =0;
677 }
ce3f5e87 678 if (TreeH() && fHits && cH) {
6309cf6e 679 sprintf(branchname,"%sHits",GetName());
680 branch = TreeH()->GetBranch(branchname);
681 if (branch) {
d652f85c 682 // Info("SetTreeAddress","(%s) Setting for Hits",GetName());
6309cf6e 683 branch->SetAddress(&fHits);
684 }
685 else { //can be invoked before branch creation
686 Warning("SetTreeAddress","(%s) Failed for Hits. Can not find branch in tree.",GetName());
687 }
688 }
689
690 //
691 // Branch address for digit tree
ce3f5e87 692 if ( TreeD() && cD) {
6309cf6e 693 if (fDigits == 0x0) {
694 fDigits = new TObjArray(AliMUONConstants::NCh());
695 fNdigits= new Int_t[AliMUONConstants::NCh()];
696 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
697 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i);
698 fNdigits[i]=0;
699 }
700 }
701 }
702
ce3f5e87 703 if (TreeD() && fDigits && cD) {
6309cf6e 704 for (int i=0; i<AliMUONConstants::NCh(); i++) {
705 sprintf(branchname,"%sDigits%d",GetName(),i+1);
d652f85c 706 if (fDigits) {
707 branch = TreeD()->GetBranch(branchname);
708 TClonesArray * digits = Digits(i);
709 if (branch) branch->SetAddress( &digits );
710 else Warning("SetTreeAddress","(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i);
711 }
6309cf6e 712 }
713 }
714
715 //
716 // Branch address for rawclusters, globaltrigger and local trigger tree
717 if (TreeR() ) {
ce3f5e87 718 if (fRawClusters == 0x0 && cRC) {
6309cf6e 719 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
720 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
721 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
722 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
723 fNrawclusters[i]=0;
724 }
725 }
ce3f5e87 726 if (fLocalTrigger == 0x0 && cGLT) {
6309cf6e 727 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
728 }
ce3f5e87 729 if (fGlobalTrigger== 0x0 && cGLT) {
6309cf6e 730 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
731 }
732
733 }
ce3f5e87 734 if ( TreeR() && fRawClusters && cRC) {
6309cf6e 735 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
736 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
737 if (fRawClusters) {
738 branch = TreeR()->GetBranch(branchname);
d652f85c 739 if (branch) branch->SetAddress( &((*fRawClusters)[i]) );
6309cf6e 740 else Warning("SetTreeAddress","(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i);
741 }
742 }
743 }
ce3f5e87 744 if ( TreeR() && fLocalTrigger && cGLT) {
6309cf6e 745 sprintf(branchname,"%sLocalTrigger",GetName());
746 branch = TreeR()->GetBranch(branchname);
747 if (branch) branch->SetAddress(&fLocalTrigger);
748 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
749 }
ce3f5e87 750 if ( TreeR() && fGlobalTrigger && cGLT) {
6309cf6e 751 sprintf(branchname,"%sGlobalTrigger",GetName());
752 branch = TreeR()->GetBranch(branchname);
753 if (branch) branch->SetAddress(&fGlobalTrigger);
754 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
755 }
dcd2690d 756
8547965d 757 if ( TreeT() ) {
61adb9bd 758 if (fRecTracks == 0x0 && cRT) {
8547965d 759 fRecTracks = new TClonesArray("AliMUONTrack",100);
760 }
61adb9bd 761
8547965d 762 }
dcd2690d 763 if ( TreeT() && fRecTracks && cRT ) {
764 sprintf(branchname,"%sTrack",GetName());
765 branch = TreeT()->GetBranch(branchname);
766 if (branch) branch->SetAddress(&fRecTracks);
767 else Warning("SetTreeAddress","(%s) Failed for Tracks. Can not find branch in tree.",GetName());
768 }
276c44b7 769// trigger tracks
770 if ( TreeT() ) {
771 if (fRecTriggerTracks == 0x0 && cRL) {
772 fRecTriggerTracks = new TClonesArray("AliMUONTriggerTrack",100);
773 }
774
775 }
776 if ( TreeT() && fRecTriggerTracks && cRL ) {
777 sprintf(branchname,"%sTriggerTrack",GetName());
778 branch = TreeT()->GetBranch(branchname);
779 if (branch) branch->SetAddress(&fRecTriggerTracks);
780 else Warning("SetTreeAddress","(%s) Failed for Trigger Tracks. Can not find branch in tree.",GetName());
781 }
782
61adb9bd 783
6309cf6e 784}
785//_____________________________________________________________________________