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"
43 //_____________________________________________________________________________
44 AliMUONData::AliMUONData():
54 fRecTriggerTracks(0x0),
62 fNrectriggertracks(0),
66 // Default constructor
68 //_____________________________________________________________________________
69 AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
79 fRecTriggerTracks(0x0),
87 fNrectriggertracks(0),
91 // Constructor for AliMUONData
94 //_____________________________________________________________________________
95 AliMUONData::AliMUONData(const AliMUONData& rMUONData):TNamed(rMUONData)
97 // Protected copy constructor
99 AliFatal("Not implemented.");
102 //_____________________________________________________________________________
103 AliMUONData::~AliMUONData()
105 // Destructor for AliMUONData
120 fRawClusters->Delete();
124 fGlobalTrigger->Delete();
125 delete fGlobalTrigger;
128 fLocalTrigger->Delete();
129 delete fLocalTrigger;
132 fRecTracks->Delete();
135 if (fRecTriggerTracks){
136 fRecTriggerTracks->Delete();
137 delete fRecTriggerTracks;
141 //_____________________________________________________________________________
142 AliMUONData& AliMUONData::operator=(const AliMUONData& rhs)
144 // Protected assignement operator
146 if (this == &rhs) return *this;
148 AliFatal("Not implemented.");
154 //_____________________________________________________________________________
155 void AliMUONData::AddDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
158 // Add a MUON digit to the list of Digits of the detection plane id
160 TClonesArray &ldigits = * Digits(id) ;
161 new(ldigits[fNdigits[id]++]) AliMUONDigit(tracks,charges,digits);
163 //_____________________________________________________________________________
164 void AliMUONData::AddDigit(Int_t id, const AliMUONDigit& digit)
167 // Add a MUON digit to the list of Digits of the detection plane id
169 TClonesArray &ldigits = * Digits(id) ;
170 new(ldigits[fNdigits[id]++]) AliMUONDigit(digit);
172 //_____________________________________________________________________________
173 void AliMUONData::AddSDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *sdigits)
176 // Add a MUON Sdigit to the list of SDigits of the detection plane id
178 TClonesArray &lSdigits = * SDigits(id) ;
179 new(lSdigits[fNSdigits[id]++]) AliMUONDigit(tracks,charges,sdigits);
181 //_____________________________________________________________________________
182 void AliMUONData::AddSDigit(Int_t id, const AliMUONDigit& Sdigit)
185 // Add a MUON Sdigit to the list of SDigits of the detection plane id
187 TClonesArray &lSdigits = * SDigits(id) ;
188 new(lSdigits[fNSdigits[id]++]) AliMUONDigit(Sdigit);
190 //_____________________________________________________________________________
191 void AliMUONData::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
193 Int_t *pairUnlike, Int_t *pairLike)
195 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
197 TClonesArray &globalTrigger = *fGlobalTrigger;
198 new(globalTrigger[fNglobaltrigger++])
199 AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
201 //_____________________________________________________________________________
202 void AliMUONData::AddGlobalTrigger(const AliMUONGlobalTrigger& trigger )
204 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !);
205 TClonesArray &globalTrigger = *fGlobalTrigger;
206 new(globalTrigger[fNglobaltrigger++]) AliMUONGlobalTrigger(trigger);
208 //____________________________________________________________________________
209 void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
210 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
211 Float_t tof, Float_t momentum, Float_t theta,
212 Float_t phi, Float_t length, Float_t destep,
213 Float_t Xref,Float_t Yref,Float_t Zref)
215 // Add new hit to the hit list
216 TClonesArray &lhits = *fHits;
217 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
219 tof, momentum, theta,
223 //____________________________________________________________________________
224 void AliMUONData::AddHit2(Int_t fIshunt, Int_t track, Int_t detElemId,
225 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
226 Float_t tof, Float_t momentum, Float_t theta,
227 Float_t phi, Float_t length, Float_t destep,
228 Float_t Xref,Float_t Yref,Float_t Zref)
230 // Add new hit to the hit list
231 TClonesArray &lhits = *fHits;
232 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, detElemId,
234 tof, momentum, theta,
236 Xref,Yref,Zref, true);
238 //____________________________________________________________________________
239 void AliMUONData::AddLocalTrigger(const Int_t *localtr, const TArrayI& digits)
241 // add a MUON Local Trigger to the list
242 TClonesArray &localTrigger = *fLocalTrigger;
243 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(localtr, digits);
245 //____________________________________________________________________________
246 void AliMUONData::AddLocalTrigger(const AliMUONLocalTrigger& trigger)
248 // add a MUON Local Trigger to the list
249 TClonesArray &localTrigger = *fLocalTrigger;
250 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(trigger);
252 //_____________________________________________________________________________
253 void AliMUONData::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
256 // Add a MUON rawcluster to the list in the detection plane id
258 TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id));
259 new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c);
261 //_____________________________________________________________________________
262 void AliMUONData::AddRecTrack(const AliMUONTrack& track)
265 // Add a MUON rectrack
267 TClonesArray &lrectracks = *fRecTracks;
268 new(lrectracks[fNrectracks++]) AliMUONTrack(track);
269 // printf("TTTTTT %d ,\n",((AliMUONTrack*)fRecTracks->At(fNrectracks-1))->GetNTrackHits());
271 //_____________________________________________________________________________
272 void AliMUONData::AddRecTriggerTrack(const AliMUONTriggerTrack& triggertrack)
275 // Add a MUON triggerrectrack
277 TClonesArray &lrectriggertracks = *fRecTriggerTracks;
278 new(lrectriggertracks[fNrectriggertracks++]) AliMUONTriggerTrack(triggertrack);
279 // printf("TTTTTT %d ,\n",((AliMUONTrack*)fRecTracks->At(fNrectracks-1))->GetNTrackHits());
282 //____________________________________________________________________________
283 TClonesArray* AliMUONData::Digits(Int_t DetectionPlane) const
285 //Getting List of Digits
287 return ( (TClonesArray*) fDigits->At(DetectionPlane) );
291 //____________________________________________________________________________
292 TClonesArray* AliMUONData::SDigits(Int_t DetectionPlane) const
294 //Getting List of SDigits
296 return ( (TClonesArray*) fSDigits->At(DetectionPlane) );
300 //____________________________________________________________________________
301 Bool_t AliMUONData::IsRawClusterBranchesInTree()
303 // Checking if there are RawCluster Branches In TreeR
305 AliError("No treeR in memory");
310 sprintf(branchname,"%sRawClusters1",GetName());
311 TBranch * branch = 0x0;
312 branch = TreeR()->GetBranch(branchname);
313 if (branch) return kTRUE;
317 //____________________________________________________________________________
318 Bool_t AliMUONData::IsDigitsBranchesInTree()
320 // Checking if there are RawCluster Branches In TreeR
322 AliError("No treeD in memory");
327 sprintf(branchname,"%sDigits1",GetName());
328 TBranch * branch = 0x0;
329 branch = TreeD()->GetBranch(branchname);
330 if (branch) return kTRUE;
334 //____________________________________________________________________________
335 Bool_t AliMUONData::IsTriggerBranchesInTree()
337 // Checking if there are Trigger Branches In TreeR
339 AliError("No treeR in memory");
344 sprintf(branchname,"%sLocalTrigger",GetName());
345 TBranch * branch = 0x0;
346 branch = TreeR()->GetBranch(branchname);
347 if (branch) return kTRUE;
351 //____________________________________________________________________________
352 Bool_t AliMUONData::IsTriggerBranchesInTreeD()
354 // Checking if there are Trigger Branches In TreeR
356 AliError("No treeD in memory");
361 sprintf(branchname,"%sLocalTrigger",GetName());
362 TBranch * branch = 0x0;
363 branch = TreeD()->GetBranch(branchname);
364 if (branch) return kTRUE;
369 //____________________________________________________________________________
370 Bool_t AliMUONData::IsTrackBranchesInTree()
372 // Checking if there are Track Branches In TreeT
374 AliError("No treeT in memory");
379 sprintf(branchname,"%sTrack",GetName());
380 TBranch * branch = 0x0;
381 branch = TreeT()->GetBranch(branchname);
382 if (branch) return kTRUE;
386 //____________________________________________________________________________
387 Bool_t AliMUONData::IsTriggerTrackBranchesInTree()
389 // Checking if there are TriggerTrack Branches In TreeT
391 AliError("No treeT in memory");
396 sprintf(branchname,"%sTriggerTrack",GetName());
397 TBranch * branch = 0x0;
398 branch = TreeT()->GetBranch(branchname);
399 if (branch) return kTRUE;
403 //____________________________________________________________________________
404 void AliMUONData::Fill(Option_t* option)
406 // Method to fill the trees
407 const char *cH = strstr(option,"H");
408 const char *cD = strstr(option,"D"); // Digits branches in TreeD
409 const char *cS = strstr(option,"S"); // SDigits branches in TreeS
410 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
411 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
412 const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR
413 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
414 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
416 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
419 TBranch * branch = 0x0;
429 if ( TreeD() && cD && cGLT )
431 // Writing digits and (global+local) trigger at once.
438 if ( IsTriggerBranchesInTreeD() )
440 for (int i=0; i<AliMUONConstants::NCh(); i++)
442 sprintf(branchname,"%sDigits%d",GetName(),i+1);
443 branch = TreeD()->GetBranch(branchname);
453 if ( TreeD() && cGLT )
455 if ( IsDigitsBranchesInTree() )
457 sprintf(branchname,"%sLocalTrigger",GetName());
458 branch = TreeD()->GetBranch(branchname);
460 sprintf(branchname,"%sGlobalTrigger",GetName());
461 branch = TreeD()->GetBranch(branchname);
469 } // end of TreeD() handling.
479 if ( TreeR() && cRC && cTC )
485 if ( TreeR() && cRC )
487 if ( IsTriggerBranchesInTree() )
489 // Branch per branch filling
490 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++)
492 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
493 branch = TreeR()->GetBranch(branchname);
505 if (IsRawClusterBranchesInTree())
507 // Branch per branch filling
508 sprintf(branchname,"%sLocalTrigger",GetName());
509 branch = TreeR()->GetBranch(branchname);
511 sprintf(branchname,"%sGlobalTrigger",GetName());
512 branch = TreeR()->GetBranch(branchname);
524 if ( TreeT() && cRT && cRL )
530 if ( TreeT() && cRT )
532 if (IsTriggerTrackBranchesInTree())
534 sprintf(branchname,"%sTrack",GetName());
535 branch = TreeT()->GetBranch(branchname);
544 if ( TreeT() && cRL )
546 if (IsTrackBranchesInTree())
548 sprintf(branchname,"%sTriggerTrack",GetName());
549 branch = TreeT()->GetBranch(branchname);
560 //_____________________________________________________________________________
561 void AliMUONData::MakeBranch(Option_t* option)
564 // Create Tree branches for the MUON.
566 const Int_t kBufferSize = 4000;
570 const char *cH = strstr(option,"H");
571 const char *cD = strstr(option,"D"); // Digits branches in TreeD
572 const char *cS = strstr(option,"S"); // Digits branches in TreeS
573 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
574 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
575 const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR
576 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
577 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
578 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
580 TBranch * branch = 0x0;
582 // Creating Branches for Hits
586 fHits = new TClonesArray("AliMUONHit",1000);
587 // if (gAlice->GetMCApp())
588 // gAlice->GetMCApp()->AddHitList (fHits);
592 sprintf(branchname,"%sHits",GetName());
593 branch = TreeH()->GetBranch(branchname);
595 AliInfo(Form("MakeBranch","Branch %s is already in tree.",branchname));
598 branch = TreeH()->Branch(branchname,&fHits,kBufferSize);
599 //Info("MakeBranch","Making Branch %s for hits \n",branchname);
602 //Creating Branches for Digits
611 // one branch for digits per chamber
614 fDigits = new TObjArray(AliMUONConstants::NCh());
615 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++)
617 TClonesArray * tca = new TClonesArray("AliMUONDigit",10000);
619 fDigits->AddAt(tca,iDetectionPlane);
624 fNdigits = new Int_t[AliMUONConstants::NCh()];
625 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++)
627 fNdigits[iDetectionPlane]=0;
630 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++)
632 sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
633 branch = treeD->GetBranch(branchname);
636 AliInfo(Form("Branch %s is already in tree.",branchname));
639 TClonesArray * digits = Digits(iDetectionPlane);
640 branch = treeD->Branch(branchname, &digits, kBufferSize,1);
647 // one branch for global trigger
649 sprintf(branchname,"%sGlobalTrigger",GetName());
651 if (fGlobalTrigger == 0x0)
653 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger");
656 branch = treeD->GetBranch(branchname);
659 AliInfo(Form("Branch GlobalTrigger is already in treeD."));
662 branch = treeD->Branch(branchname, &fGlobalTrigger, kBufferSize);
665 // one branch for local trigger
667 sprintf(branchname,"%sLocalTrigger",GetName());
670 if (fLocalTrigger == 0x0)
672 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
675 branch = treeD->GetBranch(branchname);
678 AliInfo(Form("Branch LocalTrigger is already in treeD."));
681 branch = treeD->Branch(branchname, &fLocalTrigger, kBufferSize);
684 //Creating Branches for SDigits
685 if (TreeS() && cS ) {
686 // one branch for Sdigits per chamber
687 if (fSDigits == 0x0) {
688 fSDigits = new TObjArray(AliMUONConstants::NCh());
689 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
690 TClonesArray * tca = new TClonesArray("AliMUONDigit",10000);
692 fSDigits->AddAt(tca,iDetectionPlane);
695 if (fNSdigits == 0x0) {
696 fNSdigits = new Int_t[AliMUONConstants::NCh()];
697 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
698 fNSdigits[iDetectionPlane]=0;
701 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
702 sprintf(branchname,"%sSDigits%d",GetName(),iDetectionPlane+1);
704 branch = TreeS()->GetBranch(branchname);
706 AliInfo(Form("Branch %s is already in tree.",branchname));
709 TClonesArray * sdigits = SDigits(iDetectionPlane);
710 branch = TreeS()->Branch(branchname, &sdigits, kBufferSize,1);
711 //Info("MakeBranch","Making Branch %s for sdigits in detection plane %d\n",branchname,iDetectionPlane+1);
715 if (TreeR() && cRC ) {
716 // one branch for raw clusters per tracking detection plane
719 if (fRawClusters == 0x0) {
720 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
721 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
722 TClonesArray * tca = new TClonesArray("AliMUONRawCluster",1000);
724 fRawClusters->AddAt(tca,i);
728 if (fNrawclusters == 0x0) {
729 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
730 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
735 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
736 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
738 branch = TreeR()->GetBranch(branchname);
740 AliInfo(Form("Branch %s is already in tree.",branchname));
743 branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize);
744 //Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1);
748 if (TreeR() && cTC ) {
750 // one branch for global trigger
752 sprintf(branchname,"%sGlobalTrigger",GetName());
755 if (fGlobalTrigger == 0x0) {
756 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger");
759 branch = TreeR()->GetBranch(branchname);
761 AliInfo(Form("Branch GlobalTrigger is already in treeR."));
764 branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize);
765 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
768 // one branch for local trigger
770 sprintf(branchname,"%sLocalTrigger",GetName());
773 if (fLocalTrigger == 0x0) {
774 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
777 branch = TreeR()->GetBranch(branchname);
779 AliInfo(Form("Branch LocalTrigger is already in treeR."));
782 branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize);
783 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
786 if (TreeT() && cRT ) {
787 if (fRecTracks == 0x0) fRecTracks = new TClonesArray("AliMUONTrack",100);
789 sprintf(branchname,"%sTrack",GetName());
790 branch = TreeT()->GetBranch(branchname);
792 AliInfo(Form("Branch %s is already in tree.",GetName()));
795 branch = TreeT()->Branch(branchname,&fRecTracks,kBufferSize);
796 //Info("MakeBranch","Making Branch %s for tracks \n",branchname);
799 if (TreeT() && cRL ) {
800 if (fRecTriggerTracks == 0x0) fRecTriggerTracks = new TClonesArray("AliMUONTriggerTrack",100);
801 fNrectriggertracks = 0;
802 sprintf(branchname,"%sTriggerTrack",GetName());
803 branch = TreeT()->GetBranch(branchname);
805 AliInfo(Form("Branch %s is already in tree.",GetName()));
808 branch = TreeT()->Branch(branchname,&fRecTriggerTracks,kBufferSize);
809 //Info("MakeBranch","Making Branch %s for trigger tracks \n",branchname);
812 //____________________________________________________________________________
813 TClonesArray* AliMUONData::RawClusters(Int_t DetectionPlane)
815 // Getting Raw Clusters
817 return ( (TClonesArray*) fRawClusters->At(DetectionPlane) );
822 //____________________________________________________________________________
824 AliMUONData::LocalTrigger() const
826 return fLocalTrigger;
829 //____________________________________________________________________________
831 AliMUONData::GetDigits() const
833 // Load the digits from TreeD for the current event.
834 Int_t event = fLoader->GetRunLoader()->GetEventNumber();
835 if ( fCurrentEvent != event )
837 fLoader->TreeD()->GetEvent(0);
838 fCurrentEvent = event;
842 //____________________________________________________________________________
844 AliMUONData::GlobalTrigger() const
846 // Return the global trigger
847 return fGlobalTrigger;
850 //____________________________________________________________________________
851 void AliMUONData::ResetDigits()
854 // Reset number of digits and the digits array for this detector
856 if (fDigits == 0x0) return;
857 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
858 if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear("C");
859 if (fNdigits) fNdigits[i]=0;
862 //____________________________________________________________________________
863 void AliMUONData::ResetSDigits()
866 // Reset number of Sdigits and the Sdigits array for this detector
868 if (fSDigits == 0x0) return;
869 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
870 if ((*fSDigits)[i]) ((TClonesArray*)fSDigits->At(i))->Clear();
871 if (fNSdigits) fNSdigits[i]=0;
874 //______________________________________________________________________________
875 void AliMUONData::ResetHits()
877 // Reset number of clusters and the cluster array for this detector
879 if (fHits) fHits->Clear();
881 //_______________________________________________________________________________
882 void AliMUONData::ResetRawClusters()
884 // Reset number of raw clusters and the raw clust array for this detector
886 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
887 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
888 if (fNrawclusters) fNrawclusters[i]=0;
891 //_______________________________________________________________________________
892 void AliMUONData::ResetTrigger()
894 // Reset Local and Global Trigger
896 if (fGlobalTrigger) fGlobalTrigger->Clear();
898 if (fLocalTrigger) fLocalTrigger->Clear();
900 //____________________________________________________________________________
901 void AliMUONData::ResetRecTracks()
903 // Reset tracks information
905 if (fRecTracks) fRecTracks->Delete(); // necessary to delete in case of memory allocation
907 //____________________________________________________________________________
908 void AliMUONData::ResetRecTriggerTracks()
910 // Reset tracks information
911 fNrectriggertracks = 0;
912 if (fRecTriggerTracks) fRecTriggerTracks->Delete(); // necessary to delete in case of memory allocation
914 //_____________________________________________________________________________
915 void AliMUONData::SetTreeAddress(Option_t* option)
917 //Setting Addresses to the events trees
918 const char *cH = strstr(option,"H");
919 const char *cD = strstr(option,"D"); // Digits branches in TreeD
920 const char *cS = strstr(option,"S"); // SDigits branches in TreeS
921 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
922 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
923 const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR
924 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
925 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
926 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
928 // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree.
930 TBranch * branch = 0x0;
932 AliDebug(1,Form("option=%s",option));
934 // Branch address for hit tree
935 if ( TreeH() && cH ) {
937 fHits = new TClonesArray("AliMUONHit",1000);
938 // if (gAlice->GetMCApp())
939 // gAlice->GetMCApp()->AddHitList (fHits); Moved to AliMUON
943 if (TreeH() && fHits && cH) {
944 sprintf(branchname,"%sHits",GetName());
945 branch = TreeH()->GetBranch(branchname);
947 // Info("SetTreeAddress","(%s) Setting for Hits",GetName());
948 branch->SetAddress(&fHits);
950 else { //can be invoked before branch creation
951 AliWarning(Form("(%s) Failed for Hits. Can not find branch in tree.",GetName()));
956 // Branch address for digit tree
958 if (fDigits == 0x0 && cD) {
959 fDigits = new TObjArray(AliMUONConstants::NCh());
960 fNdigits= new Int_t[AliMUONConstants::NCh()];
961 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
962 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i);
966 if (fLocalTrigger == 0x0 && cGLT) {
967 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
969 if (fGlobalTrigger== 0x0 && cGLT) {
970 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
974 if (TreeD() && fDigits && cD) {
975 for (int i=0; i<AliMUONConstants::NCh(); i++) {
976 sprintf(branchname,"%sDigits%d",GetName(),i+1);
978 branch = TreeD()->GetBranch(branchname);
979 TClonesArray * digits = Digits(i);
981 branch->SetAddress( &digits );
983 else AliWarning(Form("(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i));
987 if ( TreeD() && fLocalTrigger && cGLT) {
988 sprintf(branchname,"%sLocalTrigger",GetName());
989 branch = TreeD()->GetBranch(branchname);
990 if (branch) branch->SetAddress(&fLocalTrigger);
991 else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeD.",GetName()));
993 if ( TreeD() && fGlobalTrigger && cGLT) {
994 sprintf(branchname,"%sGlobalTrigger",GetName());
995 branch = TreeD()->GetBranch(branchname);
996 if (branch) branch->SetAddress(&fGlobalTrigger);
997 else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeD.",GetName()));
1001 // Branch address for Sdigit tree
1004 if (fSDigits == 0x0)
1006 AliDebug(1,"Creating fSDigits TObjArray");
1007 fSDigits = new TObjArray(AliMUONConstants::NCh());
1008 fNSdigits= new Int_t[AliMUONConstants::NCh()];
1009 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++)
1011 TClonesArray* a = new TClonesArray("AliMUONDigit",10000);
1012 fSDigits->AddAt(a,i);
1013 AliDebug(1,Form("fSDigits[%d]=%p",i,a));
1019 AliDebug(1,Form("fSDigits already there = %p",fSDigits));
1023 if (TreeS() && fSDigits && cS) {
1024 AliDebug(1,"Setting branch addresses");
1025 for (int i=0; i<AliMUONConstants::NCh(); i++) {
1026 sprintf(branchname,"%sSDigits%d",GetName(),i+1);
1028 AliDebug(1,Form("TreeS=%p for ich=%d branchname=%s",
1029 TreeS(),i,branchname));
1030 branch = TreeS()->GetBranch(branchname);
1031 TClonesArray * sdigits = SDigits(i);
1032 if (branch) branch->SetAddress( &sdigits );
1033 else AliWarning(Form("(%s) Failed for SDigits Detection plane %d. Can not find branch in tree.",GetName(),i));
1039 // Branch address for rawclusters, globaltrigger and local trigger tree
1041 if (fRawClusters == 0x0 && cRC) {
1042 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
1043 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
1044 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
1045 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
1049 if (fLocalTrigger == 0x0 && cTC) {
1050 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
1052 if (fGlobalTrigger== 0x0 && cTC) {
1053 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
1057 if ( TreeR() && fRawClusters && cRC && !strstr(cRC,"RCC")) {
1058 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
1059 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
1061 branch = TreeR()->GetBranch(branchname);
1062 if (branch) branch->SetAddress( &((*fRawClusters)[i]) );
1063 else AliWarning(Form("(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i));
1067 if ( TreeR() && fLocalTrigger && cTC) {
1068 sprintf(branchname,"%sLocalTrigger",GetName());
1069 branch = TreeR()->GetBranch(branchname);
1070 if (branch) branch->SetAddress(&fLocalTrigger);
1071 else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeR.",GetName()));
1073 if ( TreeR() && fGlobalTrigger && cTC) {
1074 sprintf(branchname,"%sGlobalTrigger",GetName());
1075 branch = TreeR()->GetBranch(branchname);
1076 if (branch) branch->SetAddress(&fGlobalTrigger);
1077 else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeR.",GetName()));
1081 if (fRecTracks == 0x0 && cRT) {
1082 fRecTracks = new TClonesArray("AliMUONTrack",100);
1086 if ( TreeT() && fRecTracks && cRT ) {
1087 sprintf(branchname,"%sTrack",GetName());
1088 branch = TreeT()->GetBranch(branchname);
1089 if (branch) branch->SetAddress(&fRecTracks);
1090 else AliWarning(Form("(%s) Failed for Tracks. Can not find branch in tree.",GetName()));
1094 if (fRecTriggerTracks == 0x0 && cRL) {
1095 fRecTriggerTracks = new TClonesArray("AliMUONTriggerTrack",100);
1099 if ( TreeT() && fRecTriggerTracks && cRL ) {
1100 sprintf(branchname,"%sTriggerTrack",GetName());
1101 branch = TreeT()->GetBranch(branchname);
1102 if (branch) branch->SetAddress(&fRecTriggerTracks);
1103 else AliWarning(Form("(%s) Failed for Trigger Tracks. Can not find branch in tree.",GetName()));
1109 //_____________________________________________________________________________
1111 AliMUONData::Print(Option_t* opt) const
1113 // Dump object on screen
1114 TString options(opt);
1117 if ( options.Contains("D") )
1119 for ( Int_t ich = 0; ich < AliMUONConstants::NCh(); ++ich)
1121 TClonesArray* digits = Digits(ich);
1122 Int_t ndigits = digits->GetEntriesFast();
1123 for ( Int_t id = 0; id < ndigits; ++id )
1125 AliMUONDigit* digit =
1126 static_cast<AliMUONDigit*>(digits->UncheckedAt(id));
1132 if ( options.Contains("S") )
1134 for ( Int_t ich = 0; ich < AliMUONConstants::NCh(); ++ich)
1136 TClonesArray* digits = SDigits(ich);
1137 Int_t ndigits = digits->GetEntriesFast();
1138 for ( Int_t id = 0; id < ndigits; ++id )
1140 AliMUONDigit* digit =
1141 static_cast<AliMUONDigit*>(digits->UncheckedAt(id));