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