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