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 "AliMUONHit.h"
31 #include "AliMUONDigit.h"
32 #include "AliMUONGlobalTrigger.h"
33 #include "AliMUONLocalTrigger.h"
34 #include "AliMUONRegionalTrigger.h"
35 #include "AliMUONRawCluster.h"
36 #include "AliMUONTrack.h"
37 #include "AliMUONTriggerTrack.h"
38 #include "AliRunLoader.h"
46 //_____________________________________________________________________________
47 AliMUONData::AliMUONData():
56 fRegionalTrigger(0x0),
58 fRecTriggerTracks(0x0),
67 fNrectriggertracks(0),
71 // Default constructor
73 //_____________________________________________________________________________
74 AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
83 fRegionalTrigger(0x0),
85 fRecTriggerTracks(0x0),
94 fNrectriggertracks(0),
98 /// Standard constructor
101 //_____________________________________________________________________________
102 AliMUONData::~AliMUONData()
104 /// Destructor for AliMUONData
119 fRawClusters->Delete();
123 fGlobalTrigger->Delete();
124 delete fGlobalTrigger;
126 if (fRegionalTrigger){
127 fRegionalTrigger->Delete();
128 delete fRegionalTrigger;
131 fLocalTrigger->Delete();
132 delete fLocalTrigger;
135 fRecTracks->Delete();
138 if (fRecTriggerTracks){
139 fRecTriggerTracks->Delete();
140 delete fRecTriggerTracks;
143 //____________________________________________________________________________
144 void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t detElemId,
145 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
146 Float_t tof, Float_t momentum, Float_t theta,
147 Float_t phi, Float_t length, Float_t destep,
148 Float_t Xref,Float_t Yref,Float_t Zref)
150 // Add new hit to the hit list
152 TClonesArray &lhits = *fHits;
153 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, detElemId,
155 tof, momentum, theta,
159 //_____________________________________________________________________________
160 void AliMUONData::AddDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
162 /// Add a MUON digit to the list of Digits of the detection plane id
164 TClonesArray &ldigits = * Digits(id) ;
165 new(ldigits[fNdigits[id]++]) AliMUONDigit(tracks,charges,digits);
167 //_____________________________________________________________________________
168 void AliMUONData::AddDigit(Int_t id, const AliMUONDigit& digit)
170 /// Add a MUON digit to the list of Digits of the detection plane id
172 TClonesArray &ldigits = * Digits(id) ;
173 new(ldigits[fNdigits[id]++]) AliMUONDigit(digit);
175 //_____________________________________________________________________________
176 void AliMUONData::AddSDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *sdigits)
178 /// Add a MUON Sdigit to the list of SDigits of the detection plane id
180 TClonesArray &lSdigits = * SDigits(id) ;
181 new(lSdigits[fNSdigits[id]++]) AliMUONDigit(tracks,charges,sdigits);
183 //_____________________________________________________________________________
184 void AliMUONData::AddSDigit(Int_t id, const AliMUONDigit& Sdigit)
186 /// Add a MUON Sdigit to the list of SDigits of the detection plane id
188 TClonesArray &lSdigits = * SDigits(id) ;
189 new(lSdigits[fNSdigits[id]++]) AliMUONDigit(Sdigit);
192 //_____________________________________________________________________________
193 void AliMUONData::AddGlobalTrigger(const AliMUONGlobalTrigger& trigger )
195 /// Add a MUON Global Trigger to the list (only one GlobalTrigger per event !);
197 TClonesArray &globalTrigger = *fGlobalTrigger;
198 new(globalTrigger[fNglobaltrigger++]) AliMUONGlobalTrigger(trigger);
201 //____________________________________________________________________________
202 void AliMUONData::AddRegionalTrigger(const AliMUONRegionalTrigger& trigger)
204 /// add a MUON regional Trigger to the list
205 TClonesArray ®ionalTrigger = *fRegionalTrigger;
206 new(regionalTrigger[fNregionaltrigger++]) AliMUONRegionalTrigger(trigger);
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);
217 //_____________________________________________________________________________
218 void AliMUONData::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
220 /// Add a MUON rawcluster to the list in the detection plane id
222 TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id));
223 new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c);
225 //_____________________________________________________________________________
226 void AliMUONData::AddRecTrack(const AliMUONTrack& track)
228 /// Add a MUON rectrack
230 TClonesArray &lrectracks = *fRecTracks;
231 new(lrectracks[fNrectracks++]) AliMUONTrack(track);
233 //_____________________________________________________________________________
234 void AliMUONData::AddRecTriggerTrack(const AliMUONTriggerTrack& triggertrack)
236 /// Add a MUON triggerrectrack
238 TClonesArray &lrectriggertracks = *fRecTriggerTracks;
239 new(lrectriggertracks[fNrectriggertracks++]) AliMUONTriggerTrack(triggertrack);
241 //____________________________________________________________________________
242 TClonesArray* AliMUONData::Digits(Int_t DetectionPlane) const
244 /// Getting List of Digits
247 return ( (TClonesArray*) fDigits->At(DetectionPlane) );
251 //____________________________________________________________________________
252 TClonesArray* AliMUONData::SDigits(Int_t DetectionPlane) const
254 /// Getting List of SDigits
257 return ( (TClonesArray*) fSDigits->At(DetectionPlane) );
261 //____________________________________________________________________________
262 Bool_t AliMUONData::IsRawClusterBranchesInTree()
264 /// Checking if there are RawCluster Branches In TreeR
267 AliError("No treeR in memory");
272 sprintf(branchname,"%sRawClusters1",GetName());
273 TBranch * branch = 0x0;
274 branch = TreeR()->GetBranch(branchname);
275 if (branch) return kTRUE;
279 //____________________________________________________________________________
280 Bool_t AliMUONData::IsDigitsBranchesInTree()
282 /// Checking if there are RawCluster Branches In TreeR
285 AliError("No treeD in memory");
290 sprintf(branchname,"%sDigits1",GetName());
291 TBranch * branch = 0x0;
292 branch = TreeD()->GetBranch(branchname);
293 if (branch) return kTRUE;
297 //____________________________________________________________________________
298 Bool_t AliMUONData::IsTriggerBranchesInTree()
300 /// Checking if there are Trigger Branches In TreeR
302 AliError("No treeR in memory");
307 sprintf(branchname,"%sLocalTrigger",GetName());
308 TBranch * branch = 0x0;
309 branch = TreeR()->GetBranch(branchname);
310 if (branch) return kTRUE;
314 //____________________________________________________________________________
315 Bool_t AliMUONData::IsTriggerBranchesInTreeD()
317 /// Checking if there are Trigger Branches In TreeR
319 AliError("No treeD in memory");
324 sprintf(branchname,"%sLocalTrigger",GetName());
325 TBranch * branch = 0x0;
326 branch = TreeD()->GetBranch(branchname);
327 if (branch) return kTRUE;
332 //____________________________________________________________________________
333 Bool_t AliMUONData::IsTrackBranchesInTree()
335 /// Checking if there are Track Branches In TreeT
337 AliError("No treeT in memory");
342 sprintf(branchname,"%sTrack",GetName());
343 TBranch * branch = 0x0;
344 branch = TreeT()->GetBranch(branchname);
345 if (branch) return kTRUE;
349 //____________________________________________________________________________
350 Bool_t AliMUONData::IsTriggerTrackBranchesInTree()
352 /// Checking if there are TriggerTrack Branches In TreeT
354 AliError("No treeT in memory");
359 sprintf(branchname,"%sTriggerTrack",GetName());
360 TBranch * branch = 0x0;
361 branch = TreeT()->GetBranch(branchname);
362 if (branch) return kTRUE;
366 //____________________________________________________________________________
367 void AliMUONData::Fill(Option_t* option)
369 /// Method to fill the trees
370 const char *cH = strstr(option,"H");
371 const char *cD = strstr(option,"D"); // Digits branches in TreeD
372 const char *cS = strstr(option,"S"); // SDigits branches in TreeS
373 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
374 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
375 const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR
376 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
377 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
379 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
382 TBranch * branch = 0x0;
392 if ( TreeD() && cD && cGLT )
394 // Writing digits and (global+local) trigger at once.
401 if ( IsTriggerBranchesInTreeD() )
403 for (int i=0; i<AliMUONConstants::NCh(); i++)
405 sprintf(branchname,"%sDigits%d",GetName(),i+1);
406 branch = TreeD()->GetBranch(branchname);
416 if ( TreeD() && cGLT )
418 if ( IsDigitsBranchesInTree() )
420 sprintf(branchname,"%sLocalTrigger",GetName());
421 branch = TreeD()->GetBranch(branchname);
423 sprintf(branchname,"%sRegionalTrigger",GetName());
424 branch = TreeD()->GetBranch(branchname);
426 sprintf(branchname,"%sGlobalTrigger",GetName());
427 branch = TreeD()->GetBranch(branchname);
436 } // end of TreeD() handling.
446 if ( TreeR() && cRC && cTC )
452 if ( TreeR() && cRC )
454 if ( IsTriggerBranchesInTree() )
456 // Branch per branch filling
457 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++)
459 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
460 branch = TreeR()->GetBranch(branchname);
472 if (IsRawClusterBranchesInTree())
474 // Branch per branch filling
475 sprintf(branchname,"%sLocalTrigger",GetName());
476 branch = TreeR()->GetBranch(branchname);
478 sprintf(branchname,"%sRegionalTrigger",GetName());
479 branch = TreeR()->GetBranch(branchname);
481 sprintf(branchname,"%sGlobalTrigger",GetName());
482 branch = TreeR()->GetBranch(branchname);
494 if ( TreeT() && cRT && cRL )
500 if ( TreeT() && cRT )
502 if (IsTriggerTrackBranchesInTree())
504 sprintf(branchname,"%sTrack",GetName());
505 branch = TreeT()->GetBranch(branchname);
514 if ( TreeT() && cRL )
516 if (IsTrackBranchesInTree())
518 sprintf(branchname,"%sTriggerTrack",GetName());
519 branch = TreeT()->GetBranch(branchname);
530 //_____________________________________________________________________________
531 void AliMUONData::MakeBranch(Option_t* option)
533 /// Create Tree branches for the MUON.
535 const Int_t kBufferSize = 4000;
539 const char *cH = strstr(option,"H");
540 const char *cD = strstr(option,"D"); // Digits branches in TreeD
541 const char *cS = strstr(option,"S"); // Digits branches in TreeS
542 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
543 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
544 const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR
545 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
546 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
547 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
549 TBranch * branch = 0x0;
551 // Creating Branches for Hits
555 fHits = new TClonesArray("AliMUONHit",1000);
556 // if (gAlice->GetMCApp())
557 // gAlice->GetMCApp()->AddHitList (fHits);
561 sprintf(branchname,"%sHits",GetName());
562 branch = TreeH()->GetBranch(branchname);
564 AliInfo(Form("MakeBranch","Branch %s is already in tree.",branchname));
567 branch = TreeH()->Branch(branchname,&fHits,kBufferSize);
568 //Info("MakeBranch","Making Branch %s for hits \n",branchname);
571 //Creating Branches for Digits
580 // one branch for digits per chamber
583 fDigits = new TObjArray(AliMUONConstants::NCh());
584 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++)
586 TClonesArray * tca = new TClonesArray("AliMUONDigit",10000);
588 fDigits->AddAt(tca,iDetectionPlane);
593 fNdigits = new Int_t[AliMUONConstants::NCh()];
594 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++)
596 fNdigits[iDetectionPlane]=0;
599 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++)
601 sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
602 branch = treeD->GetBranch(branchname);
605 AliInfo(Form("Branch %s is already in tree.",branchname));
608 TClonesArray * digits = Digits(iDetectionPlane);
609 branch = treeD->Branch(branchname, &digits, kBufferSize,1);
616 // one branch for global trigger
618 sprintf(branchname,"%sGlobalTrigger",GetName());
620 if (fGlobalTrigger == 0x0)
622 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger");
625 branch = treeD->GetBranch(branchname);
628 AliInfo(Form("Branch GlobalTrigger is already in treeD."));
631 branch = treeD->Branch(branchname, &fGlobalTrigger, kBufferSize);
634 // one branch for regional trigger
636 sprintf(branchname,"%sRegionalTrigger",GetName());
639 if (fRegionalTrigger == 0x0)
641 fRegionalTrigger = new TClonesArray("AliMUONRegionalTrigger",16);
642 fNregionaltrigger = 0;
644 branch = treeD->GetBranch(branchname);
647 AliInfo(Form("Branch RegionalTrigger is already in treeD."));
650 branch = treeD->Branch(branchname, &fRegionalTrigger, kBufferSize);
654 // one branch for local trigger
656 sprintf(branchname,"%sLocalTrigger",GetName());
659 if (fLocalTrigger == 0x0)
661 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
664 branch = treeD->GetBranch(branchname);
667 AliInfo(Form("Branch LocalTrigger is already in treeD."));
670 branch = treeD->Branch(branchname, &fLocalTrigger, kBufferSize);
673 //Creating Branches for SDigits
674 if (TreeS() && cS ) {
675 // one branch for Sdigits per chamber
676 if (fSDigits == 0x0) {
677 fSDigits = new TObjArray(AliMUONConstants::NCh());
678 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
679 TClonesArray * tca = new TClonesArray("AliMUONDigit",10000);
681 fSDigits->AddAt(tca,iDetectionPlane);
684 if (fNSdigits == 0x0) {
685 fNSdigits = new Int_t[AliMUONConstants::NCh()];
686 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
687 fNSdigits[iDetectionPlane]=0;
690 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
691 sprintf(branchname,"%sSDigits%d",GetName(),iDetectionPlane+1);
693 branch = TreeS()->GetBranch(branchname);
695 AliInfo(Form("Branch %s is already in tree.",branchname));
698 TClonesArray * sdigits = SDigits(iDetectionPlane);
699 branch = TreeS()->Branch(branchname, &sdigits, kBufferSize,1);
700 //Info("MakeBranch","Making Branch %s for sdigits in detection plane %d\n",branchname,iDetectionPlane+1);
704 if (TreeR() && cRC ) {
705 // one branch for raw clusters per tracking detection plane
708 if (fRawClusters == 0x0) {
709 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
710 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
711 TClonesArray * tca = new TClonesArray("AliMUONRawCluster",1000);
713 fRawClusters->AddAt(tca,i);
717 if (fNrawclusters == 0x0) {
718 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
719 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
724 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
725 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
727 branch = TreeR()->GetBranch(branchname);
729 AliInfo(Form("Branch %s is already in tree.",branchname));
732 branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize);
733 //Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1);
737 if (TreeR() && cTC ) {
739 // one branch for global trigger
741 sprintf(branchname,"%sGlobalTrigger",GetName());
744 if (fGlobalTrigger == 0x0) {
745 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger");
748 branch = TreeR()->GetBranch(branchname);
750 AliInfo(Form("Branch GlobalTrigger is already in treeR."));
753 branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize);
754 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
757 // one branch for regional trigger
759 sprintf(branchname,"%sRegionalTrigger",GetName());
762 if (fRegionalTrigger == 0x0) {
763 fRegionalTrigger = new TClonesArray("AliMUONRegionalTrigger",16);
764 fNregionaltrigger = 0;
766 branch = TreeR()->GetBranch(branchname);
768 AliInfo(Form("Branch RegionalTrigger is already in treeR."));
771 branch = TreeR()->Branch(branchname, &fRegionalTrigger, kBufferSize);
774 // one branch for local trigger
776 sprintf(branchname,"%sLocalTrigger",GetName());
779 if (fLocalTrigger == 0x0) {
780 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
783 branch = TreeR()->GetBranch(branchname);
785 AliInfo(Form("Branch LocalTrigger is already in treeR."));
788 branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize);
789 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
792 if (TreeT() && cRT ) {
793 if (fRecTracks == 0x0) fRecTracks = new TClonesArray("AliMUONTrack",100);
795 sprintf(branchname,"%sTrack",GetName());
796 branch = TreeT()->GetBranch(branchname);
798 AliInfo(Form("Branch %s is already in tree.",GetName()));
801 branch = TreeT()->Branch(branchname,&fRecTracks,kBufferSize);
802 //Info("MakeBranch","Making Branch %s for tracks \n",branchname);
805 if (TreeT() && cRL ) {
806 if (fRecTriggerTracks == 0x0) fRecTriggerTracks = new TClonesArray("AliMUONTriggerTrack",100);
807 fNrectriggertracks = 0;
808 sprintf(branchname,"%sTriggerTrack",GetName());
809 branch = TreeT()->GetBranch(branchname);
811 AliInfo(Form("Branch %s is already in tree.",GetName()));
814 branch = TreeT()->Branch(branchname,&fRecTriggerTracks,kBufferSize);
815 //Info("MakeBranch","Making Branch %s for trigger tracks \n",branchname);
818 //____________________________________________________________________________
819 TClonesArray* AliMUONData::RawClusters(Int_t DetectionPlane)
821 /// Getting Raw Clusters
824 return ( (TClonesArray*) fRawClusters->At(DetectionPlane) );
829 //____________________________________________________________________________
831 AliMUONData::LocalTrigger() const
833 /// Getting local trigger
835 return fLocalTrigger;
838 //____________________________________________________________________________
840 AliMUONData::RegionalTrigger() const
842 /// Getting regional trigger
844 return fRegionalTrigger;
847 //____________________________________________________________________________
849 AliMUONData::GetDigits() const
851 /// Load the digits from TreeD for the current event.
853 Int_t event = fLoader->GetRunLoader()->GetEventNumber();
854 if ( fCurrentEvent != event )
856 if (fLoader->TreeD()) {
857 fLoader->TreeD()->GetEvent(0);
858 fCurrentEvent = event;
863 //____________________________________________________________________________
865 AliMUONData::GlobalTrigger() const
867 /// Return the global trigger
869 return fGlobalTrigger;
872 //____________________________________________________________________________
873 void AliMUONData::ResetDigits()
875 /// Reset number of digits and the digits array for this detector
877 if (fDigits == 0x0) return;
878 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
879 if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear("C");
880 if (fNdigits) fNdigits[i]=0;
883 //____________________________________________________________________________
884 void AliMUONData::ResetSDigits()
886 /// Reset number of Sdigits and the Sdigits array for this detector
888 if (fSDigits == 0x0) return;
889 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
890 if ((*fSDigits)[i]) ((TClonesArray*)fSDigits->At(i))->Clear();
891 if (fNSdigits) fNSdigits[i]=0;
894 //______________________________________________________________________________
895 void AliMUONData::ResetHits()
897 /// Reset number of clusters and the cluster array for this detector
900 if (fHits) fHits->Clear();
902 //_______________________________________________________________________________
903 void AliMUONData::ResetRawClusters()
905 /// Reset number of raw clusters and the raw clust array for this detector
907 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
908 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
909 if (fNrawclusters) fNrawclusters[i]=0;
912 //_______________________________________________________________________________
913 void AliMUONData::ResetTrigger()
915 /// Reset Local and Global Trigger
918 if (fGlobalTrigger) fGlobalTrigger->Clear();
919 fNregionaltrigger = 0;
920 if (fRegionalTrigger) fRegionalTrigger->Clear();
922 if (fLocalTrigger) fLocalTrigger->Clear();
925 //____________________________________________________________________________
926 void AliMUONData::ResetRecTracks()
928 /// Reset tracks information
931 if (fRecTracks) fRecTracks->Delete(); // necessary to delete in case of memory allocation
933 //____________________________________________________________________________
934 void AliMUONData::ResetRecTriggerTracks()
936 /// Reset tracks information
938 fNrectriggertracks = 0;
939 if (fRecTriggerTracks) fRecTriggerTracks->Delete(); // necessary to delete in case of memory allocation
941 //_____________________________________________________________________________
942 void AliMUONData::SetTreeAddress(Option_t* option)
944 /// Setting Addresses to the events trees
946 const char *cH = strstr(option,"H");
947 const char *cD = strstr(option,"D"); // Digits branches in TreeD
948 const char *cS = strstr(option,"S"); // SDigits branches in TreeS
949 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
950 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
951 const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR
952 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
953 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
954 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
956 // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree.
958 TBranch * branch = 0x0;
960 AliDebug(1,Form("option=%s",option));
962 // Branch address for hit tree
963 if ( TreeH() && cH ) {
965 fHits = new TClonesArray("AliMUONHit",1000);
966 // if (gAlice->GetMCApp())
967 // gAlice->GetMCApp()->AddHitList (fHits); Moved to AliMUON
971 if (TreeH() && fHits && cH) {
972 sprintf(branchname,"%sHits",GetName());
973 branch = TreeH()->GetBranch(branchname);
975 // Info("SetTreeAddress","(%s) Setting for Hits",GetName());
976 branch->SetAddress(&fHits);
978 else { //can be invoked before branch creation
979 AliWarning(Form("(%s) Failed for Hits. Can not find branch in tree.",GetName()));
984 // Branch address for digit tree
986 if (fDigits == 0x0 && cD) {
987 fDigits = new TObjArray(AliMUONConstants::NCh());
988 fNdigits= new Int_t[AliMUONConstants::NCh()];
989 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
990 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i);
994 if (fLocalTrigger == 0x0 && cGLT) {
995 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
997 if (fRegionalTrigger == 0x0 && cGLT) {
998 fRegionalTrigger = new TClonesArray("AliMUONRegionalTrigger",16);
1000 if (fGlobalTrigger== 0x0 && cGLT) {
1001 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
1005 if (TreeD() && fDigits && cD) {
1006 for (int i=0; i<AliMUONConstants::NCh(); i++) {
1007 sprintf(branchname,"%sDigits%d",GetName(),i+1);
1009 branch = TreeD()->GetBranch(branchname);
1010 TClonesArray * digits = Digits(i);
1012 branch->SetAddress( &digits );
1014 else AliWarning(Form("(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i));
1018 if ( TreeD() && fLocalTrigger && cGLT) {
1019 sprintf(branchname,"%sLocalTrigger",GetName());
1020 branch = TreeD()->GetBranch(branchname);
1021 if (branch) branch->SetAddress(&fLocalTrigger);
1022 else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeD.",GetName()));
1024 if ( TreeD() && fRegionalTrigger && cGLT) {
1025 sprintf(branchname,"%sRegionalTrigger",GetName());
1026 branch = TreeD()->GetBranch(branchname);
1027 if (branch) branch->SetAddress(&fRegionalTrigger);
1028 else AliWarning(Form("(%s) Failed for RegionalTrigger. Can not find branch in treeD.",GetName()));
1030 if ( TreeD() && fGlobalTrigger && cGLT) {
1031 sprintf(branchname,"%sGlobalTrigger",GetName());
1032 branch = TreeD()->GetBranch(branchname);
1033 if (branch) branch->SetAddress(&fGlobalTrigger);
1034 else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeD.",GetName()));
1038 // Branch address for Sdigit tree
1041 if (fSDigits == 0x0)
1043 AliDebug(1,"Creating fSDigits TObjArray");
1044 fSDigits = new TObjArray(AliMUONConstants::NCh());
1045 fNSdigits= new Int_t[AliMUONConstants::NCh()];
1046 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++)
1048 TClonesArray* a = new TClonesArray("AliMUONDigit",10000);
1049 fSDigits->AddAt(a,i);
1050 AliDebug(1,Form("fSDigits[%d]=%p",i,a));
1056 AliDebug(1,Form("fSDigits already there = %p",fSDigits));
1060 if (TreeS() && fSDigits && cS) {
1061 AliDebug(1,"Setting branch addresses");
1062 for (int i=0; i<AliMUONConstants::NCh(); i++) {
1063 sprintf(branchname,"%sSDigits%d",GetName(),i+1);
1065 AliDebug(1,Form("TreeS=%p for ich=%d branchname=%s",
1066 TreeS(),i,branchname));
1067 branch = TreeS()->GetBranch(branchname);
1068 TClonesArray * sdigits = SDigits(i);
1069 if (branch) branch->SetAddress( &sdigits );
1070 else AliWarning(Form("(%s) Failed for SDigits Detection plane %d. Can not find branch in tree.",GetName(),i));
1076 // Branch address for rawclusters, globaltrigger and local trigger tree
1078 if (fRawClusters == 0x0 && cRC) {
1079 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
1080 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
1081 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
1082 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
1086 if (fLocalTrigger == 0x0 && cTC) {
1087 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
1089 if (fRegionalTrigger == 0x0 && cTC) {
1090 fRegionalTrigger = new TClonesArray("AliMUONRegionalTrigger",16);
1092 if (fGlobalTrigger== 0x0 && cTC) {
1093 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
1097 if ( TreeR() && fRawClusters && cRC && !strstr(cRC,"RCC")) {
1098 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
1099 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
1101 branch = TreeR()->GetBranch(branchname);
1102 if (branch) branch->SetAddress( &((*fRawClusters)[i]) );
1103 else AliWarning(Form("(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i));
1107 if ( TreeR() && fLocalTrigger && cTC) {
1108 sprintf(branchname,"%sLocalTrigger",GetName());
1109 branch = TreeR()->GetBranch(branchname);
1110 if (branch) branch->SetAddress(&fLocalTrigger);
1111 else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeR.",GetName()));
1114 if ( TreeR() && fRegionalTrigger && cTC) {
1115 sprintf(branchname,"%sRegionalTrigger",GetName());
1116 branch = TreeR()->GetBranch(branchname);
1117 if (branch) branch->SetAddress(&fRegionalTrigger);
1118 else AliWarning(Form("(%s) Failed for RegionalTrigger. Can not find branch in treeR.",GetName()));
1121 if ( TreeR() && fGlobalTrigger && cTC) {
1122 sprintf(branchname,"%sGlobalTrigger",GetName());
1123 branch = TreeR()->GetBranch(branchname);
1124 if (branch) branch->SetAddress(&fGlobalTrigger);
1125 else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeR.",GetName()));
1129 if (fRecTracks == 0x0 && cRT) {
1130 fRecTracks = new TClonesArray("AliMUONTrack",100);
1134 if ( TreeT() && fRecTracks && cRT ) {
1135 sprintf(branchname,"%sTrack",GetName());
1136 branch = TreeT()->GetBranch(branchname);
1137 if (branch) branch->SetAddress(&fRecTracks);
1138 else AliWarning(Form("(%s) Failed for Tracks. Can not find branch in tree.",GetName()));
1142 if (fRecTriggerTracks == 0x0 && cRL) {
1143 fRecTriggerTracks = new TClonesArray("AliMUONTriggerTrack",100);
1147 if ( TreeT() && fRecTriggerTracks && cRL ) {
1148 sprintf(branchname,"%sTriggerTrack",GetName());
1149 branch = TreeT()->GetBranch(branchname);
1150 if (branch) branch->SetAddress(&fRecTriggerTracks);
1151 else AliWarning(Form("(%s) Failed for Trigger Tracks. Can not find branch in tree.",GetName()));
1157 //_____________________________________________________________________________
1159 AliMUONData::Print(Option_t* opt) const
1161 /// Dump object on screen
1163 TString options(opt);
1166 if ( options.Contains("D") )
1168 for ( Int_t ich = 0; ich < AliMUONConstants::NCh(); ++ich)
1170 TClonesArray* digits = Digits(ich);
1171 Int_t ndigits = digits->GetEntriesFast();
1172 for ( Int_t id = 0; id < ndigits; ++id )
1174 AliMUONDigit* digit =
1175 static_cast<AliMUONDigit*>(digits->UncheckedAt(id));
1181 if ( options.Contains("S") )
1183 for ( Int_t ich = 0; ich < AliMUONConstants::NCh(); ++ich)
1185 TClonesArray* digits = SDigits(ich);
1186 Int_t ndigits = digits->GetEntriesFast();
1187 for ( Int_t id = 0; id < ndigits; ++id )
1189 AliMUONDigit* digit =
1190 static_cast<AliMUONDigit*>(digits->UncheckedAt(id));