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