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 **************************************************************************/
20 /// Class containing MUON data: hits, digits, rawclusters, globaltrigger, localtrigger, etc ..
21 /// The classe makes the lik between the MUON data lists and the event trees from loaders
23 /// Gines Martinez, Subatech, September 2003
26 #include "AliMUONData.h"
29 #include "AliMUONConstants.h"
30 #include "AliMUONDigit.h"
31 #include "AliMUONGlobalTrigger.h"
32 #include "AliMUONHit.h"
33 #include "AliMUONLocalTrigger.h"
34 #include "AliMUONRawCluster.h"
35 #include "AliMUONTrack.h"
36 #include "AliMUONTriggerTrack.h"
37 #include "AliRunLoader.h"
45 //_____________________________________________________________________________
46 AliMUONData::AliMUONData():
56 fRecTriggerTracks(0x0),
64 fNrectriggertracks(0),
68 // Default constructor
70 //_____________________________________________________________________________
71 AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
81 fRecTriggerTracks(0x0),
89 fNrectriggertracks(0),
93 /// Standard constructor
96 //_____________________________________________________________________________
97 AliMUONData::~AliMUONData()
99 /// Destructor for AliMUONData
114 fRawClusters->Delete();
118 fGlobalTrigger->Delete();
119 delete fGlobalTrigger;
122 fLocalTrigger->Delete();
123 delete fLocalTrigger;
126 fRecTracks->Delete();
129 if (fRecTriggerTracks){
130 fRecTriggerTracks->Delete();
131 delete fRecTriggerTracks;
135 //_____________________________________________________________________________
136 void AliMUONData::AddDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
138 /// Add a MUON digit to the list of Digits of the detection plane id
140 TClonesArray &ldigits = * Digits(id) ;
141 new(ldigits[fNdigits[id]++]) AliMUONDigit(tracks,charges,digits);
143 //_____________________________________________________________________________
144 void AliMUONData::AddDigit(Int_t id, const AliMUONDigit& digit)
146 /// Add a MUON digit to the list of Digits of the detection plane id
148 TClonesArray &ldigits = * Digits(id) ;
149 new(ldigits[fNdigits[id]++]) AliMUONDigit(digit);
151 //_____________________________________________________________________________
152 void AliMUONData::AddSDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *sdigits)
154 /// Add a MUON Sdigit to the list of SDigits of the detection plane id
156 TClonesArray &lSdigits = * SDigits(id) ;
157 new(lSdigits[fNSdigits[id]++]) AliMUONDigit(tracks,charges,sdigits);
159 //_____________________________________________________________________________
160 void AliMUONData::AddSDigit(Int_t id, const AliMUONDigit& Sdigit)
162 /// Add a MUON Sdigit to the list of SDigits of the detection plane id
164 TClonesArray &lSdigits = * SDigits(id) ;
165 new(lSdigits[fNSdigits[id]++]) AliMUONDigit(Sdigit);
168 //_____________________________________________________________________________
169 void AliMUONData::AddGlobalTrigger(const AliMUONGlobalTrigger& trigger )
171 /// Add a MUON Global Trigger to the list (only one GlobalTrigger per event !);
173 TClonesArray &globalTrigger = *fGlobalTrigger;
174 new(globalTrigger[fNglobaltrigger++]) AliMUONGlobalTrigger(trigger);
176 //____________________________________________________________________________
177 void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
178 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
179 Float_t tof, Float_t momentum, Float_t theta,
180 Float_t phi, Float_t length, Float_t destep,
181 Float_t Xref,Float_t Yref,Float_t Zref)
183 /// Add new hit to the hit list
185 TClonesArray &lhits = *fHits;
186 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
188 tof, momentum, theta,
192 //____________________________________________________________________________
193 void AliMUONData::AddHit2(Int_t fIshunt, Int_t track, Int_t detElemId,
194 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
195 Float_t tof, Float_t momentum, Float_t theta,
196 Float_t phi, Float_t length, Float_t destep,
197 Float_t Xref,Float_t Yref,Float_t Zref)
199 // Add new hit to the hit list
201 TClonesArray &lhits = *fHits;
202 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, detElemId,
204 tof, momentum, theta,
206 Xref,Yref,Zref, true);
208 //____________________________________________________________________________
209 void AliMUONData::AddLocalTrigger(const AliMUONLocalTrigger& trigger)
211 /// add a MUON Local Trigger to the list
213 TClonesArray &localTrigger = *fLocalTrigger;
214 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(trigger);
216 //_____________________________________________________________________________
217 void AliMUONData::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
219 /// Add a MUON rawcluster to the list in the detection plane id
221 TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id));
222 new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c);
224 //_____________________________________________________________________________
225 void AliMUONData::AddRecTrack(const AliMUONTrack& track)
227 /// Add a MUON rectrack
229 TClonesArray &lrectracks = *fRecTracks;
230 new(lrectracks[fNrectracks++]) AliMUONTrack(track);
232 //_____________________________________________________________________________
233 void AliMUONData::AddRecTriggerTrack(const AliMUONTriggerTrack& triggertrack)
235 /// Add a MUON triggerrectrack
237 TClonesArray &lrectriggertracks = *fRecTriggerTracks;
238 new(lrectriggertracks[fNrectriggertracks++]) AliMUONTriggerTrack(triggertrack);
240 //____________________________________________________________________________
241 TClonesArray* AliMUONData::Digits(Int_t DetectionPlane) const
243 /// Getting List of Digits
246 return ( (TClonesArray*) fDigits->At(DetectionPlane) );
250 //____________________________________________________________________________
251 TClonesArray* AliMUONData::SDigits(Int_t DetectionPlane) const
253 /// Getting List of SDigits
256 return ( (TClonesArray*) fSDigits->At(DetectionPlane) );
260 //____________________________________________________________________________
261 Bool_t AliMUONData::IsRawClusterBranchesInTree()
263 /// Checking if there are RawCluster Branches In TreeR
266 AliError("No treeR in memory");
271 sprintf(branchname,"%sRawClusters1",GetName());
272 TBranch * branch = 0x0;
273 branch = TreeR()->GetBranch(branchname);
274 if (branch) return kTRUE;
278 //____________________________________________________________________________
279 Bool_t AliMUONData::IsDigitsBranchesInTree()
281 /// Checking if there are RawCluster Branches In TreeR
284 AliError("No treeD in memory");
289 sprintf(branchname,"%sDigits1",GetName());
290 TBranch * branch = 0x0;
291 branch = TreeD()->GetBranch(branchname);
292 if (branch) return kTRUE;
296 //____________________________________________________________________________
297 Bool_t AliMUONData::IsTriggerBranchesInTree()
299 /// Checking if there are Trigger Branches In TreeR
301 AliError("No treeR in memory");
306 sprintf(branchname,"%sLocalTrigger",GetName());
307 TBranch * branch = 0x0;
308 branch = TreeR()->GetBranch(branchname);
309 if (branch) return kTRUE;
313 //____________________________________________________________________________
314 Bool_t AliMUONData::IsTriggerBranchesInTreeD()
316 /// Checking if there are Trigger Branches In TreeR
318 AliError("No treeD in memory");
323 sprintf(branchname,"%sLocalTrigger",GetName());
324 TBranch * branch = 0x0;
325 branch = TreeD()->GetBranch(branchname);
326 if (branch) return kTRUE;
331 //____________________________________________________________________________
332 Bool_t AliMUONData::IsTrackBranchesInTree()
334 /// Checking if there are Track Branches In TreeT
336 AliError("No treeT in memory");
341 sprintf(branchname,"%sTrack",GetName());
342 TBranch * branch = 0x0;
343 branch = TreeT()->GetBranch(branchname);
344 if (branch) return kTRUE;
348 //____________________________________________________________________________
349 Bool_t AliMUONData::IsTriggerTrackBranchesInTree()
351 /// Checking if there are TriggerTrack Branches In TreeT
353 AliError("No treeT in memory");
358 sprintf(branchname,"%sTriggerTrack",GetName());
359 TBranch * branch = 0x0;
360 branch = TreeT()->GetBranch(branchname);
361 if (branch) return kTRUE;
365 //____________________________________________________________________________
366 void AliMUONData::Fill(Option_t* option)
368 /// Method to fill the trees
369 const char *cH = strstr(option,"H");
370 const char *cD = strstr(option,"D"); // Digits branches in TreeD
371 const char *cS = strstr(option,"S"); // SDigits branches in TreeS
372 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
373 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
374 const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR
375 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
376 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
378 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
381 TBranch * branch = 0x0;
391 if ( TreeD() && cD && cGLT )
393 // Writing digits and (global+local) trigger at once.
400 if ( IsTriggerBranchesInTreeD() )
402 for (int i=0; i<AliMUONConstants::NCh(); i++)
404 sprintf(branchname,"%sDigits%d",GetName(),i+1);
405 branch = TreeD()->GetBranch(branchname);
415 if ( TreeD() && cGLT )
417 if ( IsDigitsBranchesInTree() )
419 sprintf(branchname,"%sLocalTrigger",GetName());
420 branch = TreeD()->GetBranch(branchname);
422 sprintf(branchname,"%sGlobalTrigger",GetName());
423 branch = TreeD()->GetBranch(branchname);
431 } // end of TreeD() handling.
441 if ( TreeR() && cRC && cTC )
447 if ( TreeR() && cRC )
449 if ( IsTriggerBranchesInTree() )
451 // Branch per branch filling
452 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++)
454 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
455 branch = TreeR()->GetBranch(branchname);
467 if (IsRawClusterBranchesInTree())
469 // Branch per branch filling
470 sprintf(branchname,"%sLocalTrigger",GetName());
471 branch = TreeR()->GetBranch(branchname);
473 sprintf(branchname,"%sGlobalTrigger",GetName());
474 branch = TreeR()->GetBranch(branchname);
486 if ( TreeT() && cRT && cRL )
492 if ( TreeT() && cRT )
494 if (IsTriggerTrackBranchesInTree())
496 sprintf(branchname,"%sTrack",GetName());
497 branch = TreeT()->GetBranch(branchname);
506 if ( TreeT() && cRL )
508 if (IsTrackBranchesInTree())
510 sprintf(branchname,"%sTriggerTrack",GetName());
511 branch = TreeT()->GetBranch(branchname);
522 //_____________________________________________________________________________
523 void AliMUONData::MakeBranch(Option_t* option)
525 /// Create Tree branches for the MUON.
527 const Int_t kBufferSize = 4000;
531 const char *cH = strstr(option,"H");
532 const char *cD = strstr(option,"D"); // Digits branches in TreeD
533 const char *cS = strstr(option,"S"); // Digits branches in TreeS
534 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
535 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
536 const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR
537 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
538 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
539 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
541 TBranch * branch = 0x0;
543 // Creating Branches for Hits
547 fHits = new TClonesArray("AliMUONHit",1000);
548 // if (gAlice->GetMCApp())
549 // gAlice->GetMCApp()->AddHitList (fHits);
553 sprintf(branchname,"%sHits",GetName());
554 branch = TreeH()->GetBranch(branchname);
556 AliInfo(Form("MakeBranch","Branch %s is already in tree.",branchname));
559 branch = TreeH()->Branch(branchname,&fHits,kBufferSize);
560 //Info("MakeBranch","Making Branch %s for hits \n",branchname);
563 //Creating Branches for Digits
572 // one branch for digits per chamber
575 fDigits = new TObjArray(AliMUONConstants::NCh());
576 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++)
578 TClonesArray * tca = new TClonesArray("AliMUONDigit",10000);
580 fDigits->AddAt(tca,iDetectionPlane);
585 fNdigits = new Int_t[AliMUONConstants::NCh()];
586 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++)
588 fNdigits[iDetectionPlane]=0;
591 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++)
593 sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
594 branch = treeD->GetBranch(branchname);
597 AliInfo(Form("Branch %s is already in tree.",branchname));
600 TClonesArray * digits = Digits(iDetectionPlane);
601 branch = treeD->Branch(branchname, &digits, kBufferSize,1);
608 // one branch for global trigger
610 sprintf(branchname,"%sGlobalTrigger",GetName());
612 if (fGlobalTrigger == 0x0)
614 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger");
617 branch = treeD->GetBranch(branchname);
620 AliInfo(Form("Branch GlobalTrigger is already in treeD."));
623 branch = treeD->Branch(branchname, &fGlobalTrigger, kBufferSize);
626 // one branch for local trigger
628 sprintf(branchname,"%sLocalTrigger",GetName());
631 if (fLocalTrigger == 0x0)
633 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
636 branch = treeD->GetBranch(branchname);
639 AliInfo(Form("Branch LocalTrigger is already in treeD."));
642 branch = treeD->Branch(branchname, &fLocalTrigger, kBufferSize);
645 //Creating Branches for SDigits
646 if (TreeS() && cS ) {
647 // one branch for Sdigits per chamber
648 if (fSDigits == 0x0) {
649 fSDigits = new TObjArray(AliMUONConstants::NCh());
650 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
651 TClonesArray * tca = new TClonesArray("AliMUONDigit",10000);
653 fSDigits->AddAt(tca,iDetectionPlane);
656 if (fNSdigits == 0x0) {
657 fNSdigits = new Int_t[AliMUONConstants::NCh()];
658 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
659 fNSdigits[iDetectionPlane]=0;
662 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
663 sprintf(branchname,"%sSDigits%d",GetName(),iDetectionPlane+1);
665 branch = TreeS()->GetBranch(branchname);
667 AliInfo(Form("Branch %s is already in tree.",branchname));
670 TClonesArray * sdigits = SDigits(iDetectionPlane);
671 branch = TreeS()->Branch(branchname, &sdigits, kBufferSize,1);
672 //Info("MakeBranch","Making Branch %s for sdigits in detection plane %d\n",branchname,iDetectionPlane+1);
676 if (TreeR() && cRC ) {
677 // one branch for raw clusters per tracking detection plane
680 if (fRawClusters == 0x0) {
681 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
682 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
683 TClonesArray * tca = new TClonesArray("AliMUONRawCluster",1000);
685 fRawClusters->AddAt(tca,i);
689 if (fNrawclusters == 0x0) {
690 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
691 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
696 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
697 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
699 branch = TreeR()->GetBranch(branchname);
701 AliInfo(Form("Branch %s is already in tree.",branchname));
704 branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize);
705 //Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1);
709 if (TreeR() && cTC ) {
711 // one branch for global trigger
713 sprintf(branchname,"%sGlobalTrigger",GetName());
716 if (fGlobalTrigger == 0x0) {
717 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger");
720 branch = TreeR()->GetBranch(branchname);
722 AliInfo(Form("Branch GlobalTrigger is already in treeR."));
725 branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize);
726 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
729 // one branch for local trigger
731 sprintf(branchname,"%sLocalTrigger",GetName());
734 if (fLocalTrigger == 0x0) {
735 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
738 branch = TreeR()->GetBranch(branchname);
740 AliInfo(Form("Branch LocalTrigger is already in treeR."));
743 branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize);
744 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
747 if (TreeT() && cRT ) {
748 if (fRecTracks == 0x0) fRecTracks = new TClonesArray("AliMUONTrack",100);
750 sprintf(branchname,"%sTrack",GetName());
751 branch = TreeT()->GetBranch(branchname);
753 AliInfo(Form("Branch %s is already in tree.",GetName()));
756 branch = TreeT()->Branch(branchname,&fRecTracks,kBufferSize);
757 //Info("MakeBranch","Making Branch %s for tracks \n",branchname);
760 if (TreeT() && cRL ) {
761 if (fRecTriggerTracks == 0x0) fRecTriggerTracks = new TClonesArray("AliMUONTriggerTrack",100);
762 fNrectriggertracks = 0;
763 sprintf(branchname,"%sTriggerTrack",GetName());
764 branch = TreeT()->GetBranch(branchname);
766 AliInfo(Form("Branch %s is already in tree.",GetName()));
769 branch = TreeT()->Branch(branchname,&fRecTriggerTracks,kBufferSize);
770 //Info("MakeBranch","Making Branch %s for trigger tracks \n",branchname);
773 //____________________________________________________________________________
774 TClonesArray* AliMUONData::RawClusters(Int_t DetectionPlane)
776 /// Getting Raw Clusters
779 return ( (TClonesArray*) fRawClusters->At(DetectionPlane) );
784 //____________________________________________________________________________
786 AliMUONData::LocalTrigger() const
788 /// Getting local trigger
790 return fLocalTrigger;
793 //____________________________________________________________________________
795 AliMUONData::GetDigits() const
797 /// Load the digits from TreeD for the current event.
799 Int_t event = fLoader->GetRunLoader()->GetEventNumber();
800 if ( fCurrentEvent != event )
802 fLoader->TreeD()->GetEvent(0);
803 fCurrentEvent = event;
807 //____________________________________________________________________________
809 AliMUONData::GlobalTrigger() const
811 /// Return the global trigger
813 return fGlobalTrigger;
816 //____________________________________________________________________________
817 void AliMUONData::ResetDigits()
819 /// Reset number of digits and the digits array for this detector
821 if (fDigits == 0x0) return;
822 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
823 if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear("C");
824 if (fNdigits) fNdigits[i]=0;
827 //____________________________________________________________________________
828 void AliMUONData::ResetSDigits()
830 /// Reset number of Sdigits and the Sdigits array for this detector
832 if (fSDigits == 0x0) return;
833 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
834 if ((*fSDigits)[i]) ((TClonesArray*)fSDigits->At(i))->Clear();
835 if (fNSdigits) fNSdigits[i]=0;
838 //______________________________________________________________________________
839 void AliMUONData::ResetHits()
841 /// Reset number of clusters and the cluster array for this detector
844 if (fHits) fHits->Clear();
846 //_______________________________________________________________________________
847 void AliMUONData::ResetRawClusters()
849 /// Reset number of raw clusters and the raw clust array for this detector
851 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
852 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
853 if (fNrawclusters) fNrawclusters[i]=0;
856 //_______________________________________________________________________________
857 void AliMUONData::ResetTrigger()
859 /// Reset Local and Global Trigger
862 if (fGlobalTrigger) fGlobalTrigger->Clear();
864 if (fLocalTrigger) fLocalTrigger->Clear();
866 //____________________________________________________________________________
867 void AliMUONData::ResetRecTracks()
869 /// Reset tracks information
872 if (fRecTracks) fRecTracks->Delete(); // necessary to delete in case of memory allocation
874 //____________________________________________________________________________
875 void AliMUONData::ResetRecTriggerTracks()
877 /// Reset tracks information
879 fNrectriggertracks = 0;
880 if (fRecTriggerTracks) fRecTriggerTracks->Delete(); // necessary to delete in case of memory allocation
882 //_____________________________________________________________________________
883 void AliMUONData::SetTreeAddress(Option_t* option)
885 /// Setting Addresses to the events trees
887 const char *cH = strstr(option,"H");
888 const char *cD = strstr(option,"D"); // Digits branches in TreeD
889 const char *cS = strstr(option,"S"); // SDigits branches in TreeS
890 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
891 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
892 const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR
893 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
894 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
895 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
897 // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree.
899 TBranch * branch = 0x0;
901 AliDebug(1,Form("option=%s",option));
903 // Branch address for hit tree
904 if ( TreeH() && cH ) {
906 fHits = new TClonesArray("AliMUONHit",1000);
907 // if (gAlice->GetMCApp())
908 // gAlice->GetMCApp()->AddHitList (fHits); Moved to AliMUON
912 if (TreeH() && fHits && cH) {
913 sprintf(branchname,"%sHits",GetName());
914 branch = TreeH()->GetBranch(branchname);
916 // Info("SetTreeAddress","(%s) Setting for Hits",GetName());
917 branch->SetAddress(&fHits);
919 else { //can be invoked before branch creation
920 AliWarning(Form("(%s) Failed for Hits. Can not find branch in tree.",GetName()));
925 // Branch address for digit tree
927 if (fDigits == 0x0 && cD) {
928 fDigits = new TObjArray(AliMUONConstants::NCh());
929 fNdigits= new Int_t[AliMUONConstants::NCh()];
930 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
931 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i);
935 if (fLocalTrigger == 0x0 && cGLT) {
936 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
938 if (fGlobalTrigger== 0x0 && cGLT) {
939 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
943 if (TreeD() && fDigits && cD) {
944 for (int i=0; i<AliMUONConstants::NCh(); i++) {
945 sprintf(branchname,"%sDigits%d",GetName(),i+1);
947 branch = TreeD()->GetBranch(branchname);
948 TClonesArray * digits = Digits(i);
950 branch->SetAddress( &digits );
952 else AliWarning(Form("(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i));
956 if ( TreeD() && fLocalTrigger && cGLT) {
957 sprintf(branchname,"%sLocalTrigger",GetName());
958 branch = TreeD()->GetBranch(branchname);
959 if (branch) branch->SetAddress(&fLocalTrigger);
960 else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeD.",GetName()));
962 if ( TreeD() && fGlobalTrigger && cGLT) {
963 sprintf(branchname,"%sGlobalTrigger",GetName());
964 branch = TreeD()->GetBranch(branchname);
965 if (branch) branch->SetAddress(&fGlobalTrigger);
966 else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeD.",GetName()));
970 // Branch address for Sdigit tree
975 AliDebug(1,"Creating fSDigits TObjArray");
976 fSDigits = new TObjArray(AliMUONConstants::NCh());
977 fNSdigits= new Int_t[AliMUONConstants::NCh()];
978 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++)
980 TClonesArray* a = new TClonesArray("AliMUONDigit",10000);
981 fSDigits->AddAt(a,i);
982 AliDebug(1,Form("fSDigits[%d]=%p",i,a));
988 AliDebug(1,Form("fSDigits already there = %p",fSDigits));
992 if (TreeS() && fSDigits && cS) {
993 AliDebug(1,"Setting branch addresses");
994 for (int i=0; i<AliMUONConstants::NCh(); i++) {
995 sprintf(branchname,"%sSDigits%d",GetName(),i+1);
997 AliDebug(1,Form("TreeS=%p for ich=%d branchname=%s",
998 TreeS(),i,branchname));
999 branch = TreeS()->GetBranch(branchname);
1000 TClonesArray * sdigits = SDigits(i);
1001 if (branch) branch->SetAddress( &sdigits );
1002 else AliWarning(Form("(%s) Failed for SDigits Detection plane %d. Can not find branch in tree.",GetName(),i));
1008 // Branch address for rawclusters, globaltrigger and local trigger tree
1010 if (fRawClusters == 0x0 && cRC) {
1011 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
1012 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
1013 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
1014 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
1018 if (fLocalTrigger == 0x0 && cTC) {
1019 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
1021 if (fGlobalTrigger== 0x0 && cTC) {
1022 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
1026 if ( TreeR() && fRawClusters && cRC && !strstr(cRC,"RCC")) {
1027 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
1028 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
1030 branch = TreeR()->GetBranch(branchname);
1031 if (branch) branch->SetAddress( &((*fRawClusters)[i]) );
1032 else AliWarning(Form("(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i));
1036 if ( TreeR() && fLocalTrigger && cTC) {
1037 sprintf(branchname,"%sLocalTrigger",GetName());
1038 branch = TreeR()->GetBranch(branchname);
1039 if (branch) branch->SetAddress(&fLocalTrigger);
1040 else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeR.",GetName()));
1042 if ( TreeR() && fGlobalTrigger && cTC) {
1043 sprintf(branchname,"%sGlobalTrigger",GetName());
1044 branch = TreeR()->GetBranch(branchname);
1045 if (branch) branch->SetAddress(&fGlobalTrigger);
1046 else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeR.",GetName()));
1050 if (fRecTracks == 0x0 && cRT) {
1051 fRecTracks = new TClonesArray("AliMUONTrack",100);
1055 if ( TreeT() && fRecTracks && cRT ) {
1056 sprintf(branchname,"%sTrack",GetName());
1057 branch = TreeT()->GetBranch(branchname);
1058 if (branch) branch->SetAddress(&fRecTracks);
1059 else AliWarning(Form("(%s) Failed for Tracks. Can not find branch in tree.",GetName()));
1063 if (fRecTriggerTracks == 0x0 && cRL) {
1064 fRecTriggerTracks = new TClonesArray("AliMUONTriggerTrack",100);
1068 if ( TreeT() && fRecTriggerTracks && cRL ) {
1069 sprintf(branchname,"%sTriggerTrack",GetName());
1070 branch = TreeT()->GetBranch(branchname);
1071 if (branch) branch->SetAddress(&fRecTriggerTracks);
1072 else AliWarning(Form("(%s) Failed for Trigger Tracks. Can not find branch in tree.",GetName()));
1078 //_____________________________________________________________________________
1080 AliMUONData::Print(Option_t* opt) const
1082 /// Dump object on screen
1084 TString options(opt);
1087 if ( options.Contains("D") )
1089 for ( Int_t ich = 0; ich < AliMUONConstants::NCh(); ++ich)
1091 TClonesArray* digits = Digits(ich);
1092 Int_t ndigits = digits->GetEntriesFast();
1093 for ( Int_t id = 0; id < ndigits; ++id )
1095 AliMUONDigit* digit =
1096 static_cast<AliMUONDigit*>(digits->UncheckedAt(id));
1102 if ( options.Contains("S") )
1104 for ( Int_t ich = 0; ich < AliMUONConstants::NCh(); ++ich)
1106 TClonesArray* digits = SDigits(ich);
1107 Int_t ndigits = digits->GetEntriesFast();
1108 for ( Int_t id = 0; id < ndigits; ++id )
1110 AliMUONDigit* digit =
1111 static_cast<AliMUONDigit*>(digits->UncheckedAt(id));