1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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
27 #include "AliLoader.h"
28 #include "AliMUONConstants.h"
29 #include "AliMUONData.h"
30 #include "AliMUONDigit.h"
31 #include "AliMUONHit.h"
32 #include "AliMUONLocalTrigger.h"
33 #include "AliMUONGlobalTrigger.h"
34 #include "AliMUONRawCluster.h"
35 #include "AliMUONTrack.h"
39 //_____________________________________________________________________________
40 AliMUONData::AliMUONData():TNamed()
42 // Default constructor
44 fHits = 0x0; // One event in treeH per primary track
45 fDigits = 0x0; // One event in treeH per detection plane
47 fRawClusters = 0x0; //One event in TreeR/RawclusterBranch per tracking detection plane
48 fGlobalTrigger = 0x0; //! List of Global Trigger 1st event in TreeR/GlobalTriggerBranch
49 fLocalTrigger = 0x0; //! List of Local Trigger, 1st event in TreeR/LocalTriggerBranch
54 //_____________________________________________________________________________
55 AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
58 // Constructor for AliMUONData
60 fHits = 0x0; // One event in treeH per primary track
61 fDigits = 0x0; // One event in treeH per detection plane
63 fRawClusters = 0x0; //One event in TreeR/RawclusterBranch per tracking detection plane
64 fGlobalTrigger = 0x0; //! List of Global Trigger 1st event in TreeR/GlobalTriggerBranch
65 fLocalTrigger = 0x0; //! List of Local Trigger, 1st event in TreeR/LocalTriggerBranch
72 // fHits = new TClonesArray("AliMUONHit",1000);
74 // fDigits = new TObjArray(AliMUONConstants::NCh());
75 // fNdigits = new Int_t[AliMUONConstants::NCh()];
76 // for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
77 // fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
78 // fNdigits[iDetectionPlane]=0;
80 // fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
81 // fNrawclusters = new Int_t[AliMUONConstants::NTrackingCh()];
82 // for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NTrackingCh();iDetectionPlane++) {
83 // fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),iDetectionPlane);
84 // fNrawclusters[iDetectionPlane]=0;
86 // fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
87 // fNglobaltrigger =0;
88 // fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
89 // fNlocaltrigger = 0;
90 // fRecTracks = new TClonesArray("AliMUONTrack", 100);
91 // fNrectracks = 0; // really needed or GetEntriesFast sufficient ????
96 //_____________________________________________________________________________
97 AliMUONData::AliMUONData(const AliMUONData& rMUONData):TNamed(rMUONData)
99 // Dummy copy constructor
102 //_____________________________________________________________________________
103 AliMUONData::~AliMUONData()
105 // Destructor for AliMUONData
115 fRawClusters->Delete();
119 fGlobalTrigger->Delete();
120 delete fGlobalTrigger;
123 fLocalTrigger->Delete();
124 delete fLocalTrigger;
127 fRecTracks->Delete();
132 //_____________________________________________________________________________
133 void AliMUONData::AddDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
136 // Add a MUON digit to the list of Digits of the detection plane id
138 TClonesArray &ldigits = * Digits(id) ;
139 new(ldigits[fNdigits[id]++]) AliMUONDigit(tracks,charges,digits);
141 //_____________________________________________________________________________
142 void AliMUONData::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
144 Int_t *pairUnlike, Int_t *pairLike)
146 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
147 TClonesArray &globalTrigger = *fGlobalTrigger;
148 new(globalTrigger[fNglobaltrigger++])
149 AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
151 //_____________________________________________________________________________
152 void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
153 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
154 Float_t tof, Float_t momentum, Float_t theta,
155 Float_t phi, Float_t length, Float_t destep)
157 // Add new hit to the hit list
158 TClonesArray &lhits = *fHits;
159 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
161 tof, momentum, theta,
162 phi, length, destep);
164 //____________________________________________________________________________
165 void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
166 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
167 Float_t tof, Float_t momentum, Float_t theta,
168 Float_t phi, Float_t length, Float_t destep,
169 Float_t Xref,Float_t Yref,Float_t Zref)
171 // Add new hit to the hit list
172 TClonesArray &lhits = *fHits;
173 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
175 tof, momentum, theta,
179 //____________________________________________________________________________
180 void AliMUONData::AddLocalTrigger(Int_t *localtr)
182 // add a MUON Local Trigger to the list
183 TClonesArray &localTrigger = *fLocalTrigger;
184 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(localtr);
186 //_____________________________________________________________________________
187 void AliMUONData::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
190 // Add a MUON rawcluster to the list in the detection plane id
192 TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id));
193 new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c);
195 //_____________________________________________________________________________
196 void AliMUONData::AddRecTrack(const AliMUONTrack& track)
199 // Add a MUON rectrack
201 TClonesArray &lrectracks = *fRecTracks;
202 new(lrectracks[fNrectracks++]) AliMUONTrack(track);
204 //____________________________________________________________________________
205 TClonesArray* AliMUONData::Digits(Int_t DetectionPlane)
207 //Getting List of Digits
209 return ( (TClonesArray*) fDigits->At(DetectionPlane) );
213 //____________________________________________________________________________
214 Bool_t AliMUONData::IsRawClusterBranchesInTree()
216 // Checking if there are RawCluster Branches In TreeR
218 Error("TreeR","No treeR in memory");
223 sprintf(branchname,"%sRawClusters1",GetName());
224 TBranch * branch = 0x0;
225 branch = TreeR()->GetBranch(branchname);
226 if (branch) return kTRUE;
230 //____________________________________________________________________________
231 Bool_t AliMUONData::IsTriggerBranchesInTree()
233 // Checking if there are Trigger Branches In TreeR
235 Error("TreeR","No treeR in memory");
240 sprintf(branchname,"%sLocalTrigger",GetName());
241 TBranch * branch = 0x0;
242 branch = TreeR()->GetBranch(branchname);
243 if (branch) return kTRUE;
247 //____________________________________________________________________________
248 void AliMUONData::Fill(Option_t* option)
250 // Method to fill the trees
251 const char *cH = strstr(option,"H");
252 const char *cD = strstr(option,"D"); // Digits branches in TreeD
253 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
254 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
255 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
256 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
259 TBranch * branch = 0x0;
263 if ( TreeH() && cH ) {
268 if ( TreeD() && cD) {
273 // filling rawclusters
274 if ( TreeR() && cRC ) {
275 if ( IsTriggerBranchesInTree() ) {
276 // Branch per branch filling
277 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
278 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
279 branch = TreeR()->GetBranch(branchname);
283 else TreeR()->Fill();
288 if ( TreeR() && cGLT) {
289 if (IsRawClusterBranchesInTree()) {
290 // Branch per branch filling
291 sprintf(branchname,"%sLocalTrigger",GetName());
292 branch = TreeR()->GetBranch(branchname);
294 sprintf(branchname,"%sGlobalTrigger",GetName());
295 branch = TreeR()->GetBranch(branchname);
298 else TreeR()->Fill();
302 if ( TreeT() && cRT ) {
303 sprintf(branchname,"%sTrack",GetName());
307 //_____________________________________________________________________________
308 void AliMUONData::MakeBranch(Option_t* option)
311 // Create Tree branches for the MUON.
313 const Int_t kBufferSize = 4000;
316 const char *cH = strstr(option,"H");
317 const char *cD = strstr(option,"D"); // Digits branches in TreeD
318 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
319 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
320 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
321 const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
323 TBranch * branch = 0x0;
325 // Creating Branches for Hits
327 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
329 sprintf(branchname,"%sHits",GetName());
330 branch = TreeH()->GetBranch(branchname);
332 Info("MakeBranch","Branch %s is already in tree.",GetName());
335 branch = TreeH()->Branch(branchname,&fHits,kBufferSize);
336 Info("MakeBranch","Making Branch %s for hits \n",branchname);
339 //Creating Branches for Digits
340 if (TreeD() && cD ) {
341 // one branch for digits per chamber
342 if (fDigits == 0x0) {
343 fDigits = new TObjArray(AliMUONConstants::NCh());
344 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
345 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
348 if (fNdigits == 0x0) {
349 fNdigits = new Int_t[AliMUONConstants::NCh()];
350 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
351 fNdigits[iDetectionPlane]=0;
354 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
355 sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
357 branch = TreeD()->GetBranch(branchname);
359 Info("MakeBranch","Branch %s is already in tree.",GetName());
362 TClonesArray * digits = Digits(iDetectionPlane);
363 branch = TreeD()->Branch(branchname, &digits, kBufferSize,1);
364 Info("MakeBranch","Making Branch %s for digits in detection plane %d\n",branchname,iDetectionPlane+1);
368 if (TreeR() && cRC ) {
369 // one branch for raw clusters per tracking detection plane
372 if (fRawClusters == 0x0) {
373 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
374 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
375 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",1000),i);
379 if (fNrawclusters == 0x0) {
380 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
381 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
386 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
387 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
389 branch = TreeR()->GetBranch(branchname);
391 Info("MakeBranch","Branch %s is already in tree.",GetName());
394 branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize);
395 Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1);
399 if (TreeR() && cGLT ) {
401 // one branch for global trigger
403 sprintf(branchname,"%sGlobalTrigger",GetName());
406 if (fGlobalTrigger == 0x0) {
407 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger");
410 branch = TreeR()->GetBranch(branchname);
412 Info("MakeBranch","Branch %s is already in tree.",GetName());
415 branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize);
416 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
419 // one branch for local trigger
421 sprintf(branchname,"%sLocalTrigger",GetName());
424 if (fLocalTrigger == 0x0) {
425 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
428 branch = TreeR()->GetBranch(branchname);
430 Info("MakeBranch","Branch %s is already in tree.",GetName());
433 branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize);
434 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
437 if (TreeT() && cRT ) {
438 if (fRecTracks == 0x0) fRecTracks = new TClonesArray("AliMUONTrack",100);
440 sprintf(branchname,"%sTrack",GetName());
441 branch = TreeT()->GetBranch(branchname);
443 Info("MakeBranch","Branch %s is already in tree.",GetName());
446 branch = TreeT()->Branch(branchname,&fRecTracks,kBufferSize);
447 Info("MakeBranch","Making Branch %s for tracks \n",branchname);
450 if (TreeP() && cRP ) {
451 Info("MakeBranch","Making Branch for TreeP is not yet ready. \n");
454 //____________________________________________________________________________
455 TClonesArray* AliMUONData::RawClusters(Int_t DetectionPlane)
457 // Getting Raw Clusters
459 return ( (TClonesArray*) fRawClusters->At(DetectionPlane) );
463 //____________________________________________________________________________
464 void AliMUONData::ResetDigits()
467 // Reset number of digits and the digits array for this detector
469 if (fDigits == 0x0) return;
470 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
471 if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear();
472 if (fNdigits) fNdigits[i]=0;
475 //______________________________________________________________________________
476 void AliMUONData::ResetHits()
478 // Reset number of clusters and the cluster array for this detector
480 if (fHits) fHits->Clear();
482 //_______________________________________________________________________________
483 void AliMUONData::ResetRawClusters()
485 // Reset number of raw clusters and the raw clust array for this detector
487 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
488 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
489 if (fNrawclusters) fNrawclusters[i]=0;
492 //_______________________________________________________________________________
493 void AliMUONData::ResetTrigger()
495 // Reset Local and Global Trigger
497 if (fGlobalTrigger) fGlobalTrigger->Clear();
499 if (fLocalTrigger) fLocalTrigger->Clear();
501 //____________________________________________________________________________
502 void AliMUONData::ResetRecTracks()
504 // Reset tracks information
506 if (fRecTracks) fRecTracks->Clear();
508 //_____________________________________________________________________________
509 void AliMUONData::SetTreeAddress(Option_t* option)
511 //Setting Addresses to the events trees
512 const char *cH = strstr(option,"H");
513 const char *cD = strstr(option,"D"); // Digits branches in TreeD
514 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
515 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
516 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
517 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
519 // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree.
521 TBranch * branch = 0x0;
524 // Branch address for hit tree
525 if ( TreeH() && cH ) {
526 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
529 if (TreeH() && fHits && cH) {
530 sprintf(branchname,"%sHits",GetName());
531 branch = TreeH()->GetBranch(branchname);
533 // Info("SetTreeAddress","(%s) Setting for Hits",GetName());
534 branch->SetAddress(&fHits);
536 else { //can be invoked before branch creation
537 Warning("SetTreeAddress","(%s) Failed for Hits. Can not find branch in tree.",GetName());
542 // Branch address for digit tree
543 if ( TreeD() && cD) {
544 if (fDigits == 0x0) {
545 fDigits = new TObjArray(AliMUONConstants::NCh());
546 fNdigits= new Int_t[AliMUONConstants::NCh()];
547 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
548 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i);
554 if (TreeD() && fDigits && cD) {
555 for (int i=0; i<AliMUONConstants::NCh(); i++) {
556 sprintf(branchname,"%sDigits%d",GetName(),i+1);
558 branch = TreeD()->GetBranch(branchname);
559 TClonesArray * digits = Digits(i);
560 if (branch) branch->SetAddress( &digits );
561 else Warning("SetTreeAddress","(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i);
567 // Branch address for rawclusters, globaltrigger and local trigger tree
569 if (fRawClusters == 0x0 && cRC) {
570 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
571 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
572 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
573 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
577 if (fLocalTrigger == 0x0 && cGLT) {
578 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
580 if (fGlobalTrigger== 0x0 && cGLT) {
581 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
585 if ( TreeR() && fRawClusters && cRC) {
586 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
587 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
589 branch = TreeR()->GetBranch(branchname);
590 if (branch) branch->SetAddress( &((*fRawClusters)[i]) );
591 else Warning("SetTreeAddress","(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i);
595 if ( TreeR() && fLocalTrigger && cGLT) {
596 sprintf(branchname,"%sLocalTrigger",GetName());
597 branch = TreeR()->GetBranch(branchname);
598 if (branch) branch->SetAddress(&fLocalTrigger);
599 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
601 if ( TreeR() && fGlobalTrigger && cGLT) {
602 sprintf(branchname,"%sGlobalTrigger",GetName());
603 branch = TreeR()->GetBranch(branchname);
604 if (branch) branch->SetAddress(&fGlobalTrigger);
605 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
609 if (fRecTracks == 0x0 && cRT ) {
610 fRecTracks = new TClonesArray("AliMUONTrack",100);
613 if ( TreeT() && fRecTracks && cRT ) {
614 sprintf(branchname,"%sTrack",GetName());
615 branch = TreeT()->GetBranch(branchname);
616 if (branch) branch->SetAddress(&fRecTracks);
617 else Warning("SetTreeAddress","(%s) Failed for Tracks. Can not find branch in tree.",GetName());
620 //_____________________________________________________________________________