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 **************************************************************************/
21 #include "AliLoader.h"
22 #include "AliMUONConstants.h"
23 #include "AliMUONData.h"
24 #include "AliMUONDigit.h"
25 #include "AliMUONHit.h"
26 #include "AliMUONLocalTrigger.h"
27 #include "AliMUONGlobalTrigger.h"
28 #include "AliMUONRawCluster.h"
29 #include "AliMUONTrack.h"
33 //_____________________________________________________________________________
34 AliMUONData::AliMUONData():TNamed()
37 fHits = 0x0; // One event in treeH per primary track
38 fDigits = 0x0; // One event in treeH per detection plane
40 fRawClusters = 0x0; //One event in TreeR/RawclusterBranch per tracking detection plane
41 fGlobalTrigger = 0x0; //! List of Global Trigger 1st event in TreeR/GlobalTriggerBranch
42 fLocalTrigger = 0x0; //! List of Local Trigger, 1st event in TreeR/LocalTriggerBranch
47 //_____________________________________________________________________________
48 AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
52 fHits = 0x0; // One event in treeH per primary track
53 fDigits = 0x0; // One event in treeH per detection plane
55 fRawClusters = 0x0; //One event in TreeR/RawclusterBranch per tracking detection plane
56 fGlobalTrigger = 0x0; //! List of Global Trigger 1st event in TreeR/GlobalTriggerBranch
57 fLocalTrigger = 0x0; //! List of Local Trigger, 1st event in TreeR/LocalTriggerBranch
64 // fHits = new TClonesArray("AliMUONHit",1000);
66 // fDigits = new TObjArray(AliMUONConstants::NCh());
67 // fNdigits = new Int_t[AliMUONConstants::NCh()];
68 // for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
69 // fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
70 // fNdigits[iDetectionPlane]=0;
72 // fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
73 // fNrawclusters = new Int_t[AliMUONConstants::NTrackingCh()];
74 // for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NTrackingCh();iDetectionPlane++) {
75 // fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),iDetectionPlane);
76 // fNrawclusters[iDetectionPlane]=0;
78 // fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
79 // fNglobaltrigger =0;
80 // fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
81 // fNlocaltrigger = 0;
82 // fRecTracks = new TClonesArray("AliMUONTrack", 100);
83 // fNrectracks = 0; // really needed or GetEntriesFast sufficient ????
88 //_____________________________________________________________________________
89 AliMUONData::AliMUONData(const AliMUONData& rMUONData):TNamed(rMUONData)
91 // Dummy copy constructor
94 //_____________________________________________________________________________
95 AliMUONData::~AliMUONData()
106 fRawClusters->Delete();
110 fGlobalTrigger->Delete();
111 delete fGlobalTrigger;
114 fLocalTrigger->Delete();
115 delete fLocalTrigger;
118 fRecTracks->Delete();
123 //_____________________________________________________________________________
124 void AliMUONData::AddDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
127 // Add a MUON digit to the list of Digits of the detection plane id
129 TClonesArray &ldigits = * Digits(id) ;
130 new(ldigits[fNdigits[id]++]) AliMUONDigit(tracks,charges,digits);
132 //_____________________________________________________________________________
133 void AliMUONData::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
135 Int_t *pairUnlike, Int_t *pairLike)
137 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
138 TClonesArray &globalTrigger = *fGlobalTrigger;
139 new(globalTrigger[fNglobaltrigger++])
140 AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
142 //_____________________________________________________________________________
143 void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
144 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
145 Float_t tof, Float_t momentum, Float_t theta,
146 Float_t phi, Float_t length, Float_t destep)
148 TClonesArray &lhits = *fHits;
149 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
151 tof, momentum, theta,
152 phi, length, destep);
154 //____________________________________________________________________________
155 void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
156 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
157 Float_t tof, Float_t momentum, Float_t theta,
158 Float_t phi, Float_t length, Float_t destep,
159 Float_t Xref,Float_t Yref,Float_t Zref)
161 TClonesArray &lhits = *fHits;
162 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
164 tof, momentum, theta,
168 //____________________________________________________________________________
169 void AliMUONData::AddLocalTrigger(Int_t *localtr)
171 // add a MUON Local Trigger to the list
172 TClonesArray &localTrigger = *fLocalTrigger;
173 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(localtr);
175 //_____________________________________________________________________________
176 void AliMUONData::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
179 // Add a MUON rawcluster to the list in the detection plane id
181 TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id));
182 new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c);
184 //_____________________________________________________________________________
185 void AliMUONData::AddRecTrack(const AliMUONTrack& track)
188 // Add a MUON rectrack
190 TClonesArray &lrectracks = *fRecTracks;
191 new(lrectracks[fNrectracks++]) AliMUONTrack(track);
193 //____________________________________________________________________________
194 TClonesArray* AliMUONData::Digits(Int_t DetectionPlane)
197 return ( (TClonesArray*) fDigits->At(DetectionPlane) );
201 //____________________________________________________________________________
202 Bool_t AliMUONData::IsRawClusterBranchesInTree()
205 Error("TreeR","No treeR in memory");
210 sprintf(branchname,"%sRawClusters1",GetName());
211 TBranch * branch = 0x0;
212 branch = TreeR()->GetBranch(branchname);
213 if (branch) return kTRUE;
217 //____________________________________________________________________________
218 Bool_t AliMUONData::IsTriggerBranchesInTree()
221 Error("TreeR","No treeR in memory");
226 sprintf(branchname,"%sLocalTrigger",GetName());
227 TBranch * branch = 0x0;
228 branch = TreeR()->GetBranch(branchname);
229 if (branch) return kTRUE;
233 //____________________________________________________________________________
234 void AliMUONData::Fill(Option_t* option)
236 // Method to fill the trees
237 const char *cH = strstr(option,"H");
238 const char *cD = strstr(option,"D"); // Digits branches in TreeD
239 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
240 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
241 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
242 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
245 TBranch * branch = 0x0;
249 if ( TreeH() && cH ) {
254 if ( TreeD() && cD) {
259 // filling rawclusters
260 if ( TreeR() && cRC ) {
261 if ( IsTriggerBranchesInTree() ) {
262 // Branch per branch filling
263 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
264 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
265 branch = TreeR()->GetBranch(branchname);
269 else TreeR()->Fill();
274 if ( TreeR() && cGLT) {
275 if (IsRawClusterBranchesInTree()) {
276 // Branch per branch filling
277 sprintf(branchname,"%sLocalTrigger",GetName());
278 branch = TreeR()->GetBranch(branchname);
280 sprintf(branchname,"%sGlobalTrigger",GetName());
281 branch = TreeR()->GetBranch(branchname);
284 else TreeR()->Fill();
288 if ( TreeT() && cRT ) {
289 sprintf(branchname,"%sTrack",GetName());
293 //_____________________________________________________________________________
294 void AliMUONData::MakeBranch(Option_t* option)
297 // Create Tree branches for the MUON.
299 const Int_t kBufferSize = 4000;
302 const char *cH = strstr(option,"H");
303 const char *cD = strstr(option,"D"); // Digits branches in TreeD
304 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
305 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
306 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
307 const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
309 TBranch * branch = 0x0;
311 // Creating Branches for Hits
313 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
315 sprintf(branchname,"%sHits",GetName());
316 branch = TreeH()->GetBranch(branchname);
318 Info("MakeBranch","Branch %s is already in tree.",GetName());
321 branch = TreeH()->Branch(branchname,&fHits,kBufferSize,fSplitLevel);
322 Info("MakeBranch","Making Branch %s for hits \n",branchname);
325 //Creating Branches for Digits
326 if (TreeD() && cD ) {
327 // one branch for digits per chamber
328 if (fDigits == 0x0) {
329 fDigits = new TObjArray(AliMUONConstants::NCh());
330 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
331 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
334 if (fNdigits == 0x0) {
335 fNdigits = new Int_t[AliMUONConstants::NCh()];
336 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
337 fNdigits[iDetectionPlane]=0;
340 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
341 sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
343 branch = TreeD()->GetBranch(branchname);
345 Info("MakeBranch","Branch %s is already in tree.",GetName());
348 TClonesArray * digits = Digits(iDetectionPlane);
349 branch = TreeD()->Branch(branchname, &digits, kBufferSize,1);
350 Info("MakeBranch","Making Branch %s for digits in detection plane %d\n",branchname,iDetectionPlane+1);
354 if (TreeR() && cRC ) {
355 // one branch for raw clusters per tracking detection plane
358 if (fRawClusters == 0x0) {
359 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
360 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
361 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",1000),i);
365 if (fNrawclusters == 0x0) {
366 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
367 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
372 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
373 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
375 branch = TreeR()->GetBranch(branchname);
377 Info("MakeBranch","Branch %s is already in tree.",GetName());
380 branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize,fSplitLevel);
381 Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1);
385 if (TreeR() && cGLT ) {
387 // one branch for global trigger
389 sprintf(branchname,"%sGlobalTrigger",GetName());
392 if (fGlobalTrigger == 0x0) {
393 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",fSplitLevel);
396 branch = TreeR()->GetBranch(branchname);
398 Info("MakeBranch","Branch %s is already in tree.",GetName());
401 branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize,fSplitLevel);
402 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
405 // one branch for local trigger
407 sprintf(branchname,"%sLocalTrigger",GetName());
410 if (fLocalTrigger == 0x0) {
411 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
414 branch = TreeR()->GetBranch(branchname);
416 Info("MakeBranch","Branch %s is already in tree.",GetName());
419 branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize,fSplitLevel);
420 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
423 if (TreeT() && cRT ) {
424 if (fRecTracks == 0x0) fRecTracks = new TClonesArray("AliMUONTrack",100);
426 sprintf(branchname,"%sTrack",GetName());
427 branch = TreeT()->GetBranch(branchname);
429 Info("MakeBranch","Branch %s is already in tree.",GetName());
432 branch = TreeT()->Branch(branchname,&fRecTracks,kBufferSize);
433 Info("MakeBranch","Making Branch %s for tracks \n",branchname);
436 if (TreeP() && cRP ) {
437 Info("MakeBranch","Making Branch for TreeP is not yet ready. \n");
440 //____________________________________________________________________________
441 TClonesArray* AliMUONData::RawClusters(Int_t DetectionPlane)
444 return ( (TClonesArray*) fRawClusters->At(DetectionPlane) );
448 //____________________________________________________________________________
449 void AliMUONData::ResetDigits()
452 // Reset number of digits and the digits array for this detector
454 if (fDigits == 0x0) return;
455 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
456 if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear();
457 if (fNdigits) fNdigits[i]=0;
460 //______________________________________________________________________________
461 void AliMUONData::ResetHits()
463 // Reset number of clusters and the cluster array for this detector
465 if (fHits) fHits->Clear();
467 //_______________________________________________________________________________
468 void AliMUONData::ResetRawClusters()
470 // Reset number of raw clusters and the raw clust array for this detector
472 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
473 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
474 if (fNrawclusters) fNrawclusters[i]=0;
477 //_______________________________________________________________________________
478 void AliMUONData::ResetTrigger()
480 // Reset Local and Global Trigger
482 if (fGlobalTrigger) fGlobalTrigger->Clear();
484 if (fLocalTrigger) fLocalTrigger->Clear();
486 //____________________________________________________________________________
487 void AliMUONData::ResetRecTracks()
489 // Reset tracks information
491 if (fRecTracks) fRecTracks->Clear();
493 //_____________________________________________________________________________
494 void AliMUONData::SetTreeAddress(Option_t* option)
496 const char *cH = strstr(option,"H");
497 const char *cD = strstr(option,"D"); // Digits branches in TreeD
498 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
499 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
500 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
501 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
503 // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree.
505 TBranch * branch = 0x0;
508 // Branch address for hit tree
509 if ( TreeH() && cH ) {
510 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
513 if (TreeH() && fHits && cH) {
514 sprintf(branchname,"%sHits",GetName());
515 branch = TreeH()->GetBranch(branchname);
517 // Info("SetTreeAddress","(%s) Setting for Hits",GetName());
518 branch->SetAddress(&fHits);
520 else { //can be invoked before branch creation
521 Warning("SetTreeAddress","(%s) Failed for Hits. Can not find branch in tree.",GetName());
526 // Branch address for digit tree
527 if ( TreeD() && cD) {
528 if (fDigits == 0x0) {
529 fDigits = new TObjArray(AliMUONConstants::NCh());
530 fNdigits= new Int_t[AliMUONConstants::NCh()];
531 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
532 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i);
538 if (TreeD() && fDigits && cD) {
539 for (int i=0; i<AliMUONConstants::NCh(); i++) {
540 sprintf(branchname,"%sDigits%d",GetName(),i+1);
542 branch = TreeD()->GetBranch(branchname);
543 TClonesArray * digits = Digits(i);
544 if (branch) branch->SetAddress( &digits );
545 else Warning("SetTreeAddress","(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i);
551 // Branch address for rawclusters, globaltrigger and local trigger tree
553 if (fRawClusters == 0x0 && cRC) {
554 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
555 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
556 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
557 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
561 if (fLocalTrigger == 0x0 && cGLT) {
562 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
564 if (fGlobalTrigger== 0x0 && cGLT) {
565 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
569 if ( TreeR() && fRawClusters && cRC) {
570 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
571 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
573 branch = TreeR()->GetBranch(branchname);
574 if (branch) branch->SetAddress( &((*fRawClusters)[i]) );
575 else Warning("SetTreeAddress","(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i);
579 if ( TreeR() && fLocalTrigger && cGLT) {
580 sprintf(branchname,"%sLocalTrigger",GetName());
581 branch = TreeR()->GetBranch(branchname);
582 if (branch) branch->SetAddress(&fLocalTrigger);
583 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
585 if ( TreeR() && fGlobalTrigger && cGLT) {
586 sprintf(branchname,"%sGlobalTrigger",GetName());
587 branch = TreeR()->GetBranch(branchname);
588 if (branch) branch->SetAddress(&fGlobalTrigger);
589 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
593 if (fRecTracks == 0x0 && cRT ) {
594 fRecTracks = new TClonesArray("AliMUONTrack",100);
597 if ( TreeT() && fRecTracks && cRT ) {
598 sprintf(branchname,"%sTrack",GetName());
599 branch = TreeT()->GetBranch(branchname);
600 if (branch) branch->SetAddress(&fRecTracks);
601 else Warning("SetTreeAddress","(%s) Failed for Tracks. Can not find branch in tree.",GetName());
604 //_____________________________________________________________________________