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 **************************************************************************/
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
27 #include "AliLoader.h"
28 #include "AliMUONConstants.h"
29 #include "AliMUONData.h"
30 #include "AliMUONDigit.h"
31 #include "AliMUONHit.h"
32 #include "AliMUONLocalTrigger.h"
33 #include "AliMUONGlobalTrigger.h"
34 #include "AliMUONRawCluster.h"
35 #include "AliMUONTrack.h"
39 //_____________________________________________________________________________
40 AliMUONData::AliMUONData():TNamed()
42 // Default constructor
44 fHits = 0x0; // One event in treeH per primary track
45 fDigits = 0x0; // One event in treeH per detection plane
47 fRawClusters = 0x0; //One event in TreeR/RawclusterBranch per tracking detection plane
48 fGlobalTrigger = 0x0; //! List of Global Trigger 1st event in TreeR/GlobalTriggerBranch
49 fLocalTrigger = 0x0; //! List of Local Trigger, 1st event in TreeR/LocalTriggerBranch
54 //_____________________________________________________________________________
55 AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
58 // Constructor for AliMUONData
60 fHits = 0x0; // One event in treeH per primary track
61 fDigits = 0x0; // One event in treeH per detection plane
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
72 // fHits = new TClonesArray("AliMUONHit",1000);
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;
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;
86 // fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
87 // fNglobaltrigger =0;
88 // fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
89 // fNlocaltrigger = 0;
90 // fRecTracks = new TClonesArray("AliMUONTrack", 100);
91 // fNrectracks = 0; // really needed or GetEntriesFast sufficient ????
96 //_____________________________________________________________________________
97 AliMUONData::AliMUONData(const AliMUONData& rMUONData):TNamed(rMUONData)
99 // Dummy copy constructor
102 //_____________________________________________________________________________
103 AliMUONData::~AliMUONData()
105 // Destructor for AliMUONData
115 fRawClusters->Delete();
119 fGlobalTrigger->Delete();
120 delete fGlobalTrigger;
123 fLocalTrigger->Delete();
124 delete fLocalTrigger;
127 fRecTracks->Delete();
132 //_____________________________________________________________________________
133 void AliMUONData::AddDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
136 // Add a MUON digit to the list of Digits of the detection plane id
138 TClonesArray &ldigits = * Digits(id) ;
139 new(ldigits[fNdigits[id]++]) AliMUONDigit(tracks,charges,digits);
141 //_____________________________________________________________________________
142 void AliMUONData::AddDigit(Int_t id, const AliMUONDigit& digit)
145 // Add a MUON digit to the list of Digits of the detection plane id
147 TClonesArray &ldigits = * Digits(id) ;
148 new(ldigits[fNdigits[id]++]) AliMUONDigit(digit);
150 //_____________________________________________________________________________
151 void AliMUONData::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
153 Int_t *pairUnlike, Int_t *pairLike)
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);
160 //_____________________________________________________________________________
161 void AliMUONData::AddGlobalTrigger(const AliMUONGlobalTrigger& trigger )
163 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
164 TClonesArray &globalTrigger = *fGlobalTrigger;
165 new(globalTrigger[fNglobaltrigger++]) AliMUONGlobalTrigger(trigger);
167 //_____________________________________________________________________________
168 void 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)
173 // Add new hit to the hit list
174 TClonesArray &lhits = *fHits;
175 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
177 tof, momentum, theta,
178 phi, length, destep);
180 //____________________________________________________________________________
181 void 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)
187 // Add new hit to the hit list
188 TClonesArray &lhits = *fHits;
189 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
191 tof, momentum, theta,
195 //____________________________________________________________________________
196 void AliMUONData::AddHit(const AliMUONHit& hit)
198 TClonesArray &lhits = *fHits;
199 new(lhits[fNhits++]) AliMUONHit(hit);
201 //____________________________________________________________________________
202 void AliMUONData::AddLocalTrigger(Int_t *localtr)
204 // add a MUON Local Trigger to the list
205 TClonesArray &localTrigger = *fLocalTrigger;
206 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(localtr);
208 //____________________________________________________________________________
209 void AliMUONData::AddLocalTrigger(const AliMUONLocalTrigger& trigger)
211 // add a MUON Local Trigger to the list
212 TClonesArray &localTrigger = *fLocalTrigger;
213 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(trigger);
215 //_____________________________________________________________________________
216 void AliMUONData::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
219 // Add a MUON rawcluster to the list in the detection plane id
221 TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id));
222 new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c);
224 //_____________________________________________________________________________
225 void AliMUONData::AddRecTrack(const AliMUONTrack& track)
228 // Add a MUON rectrack
230 TClonesArray &lrectracks = *fRecTracks;
231 new(lrectracks[fNrectracks++]) AliMUONTrack(track);
232 // printf("TTTTTT %d ,\n",((AliMUONTrack*)fRecTracks->At(fNrectracks-1))->GetNTrackHits());
234 //____________________________________________________________________________
235 TClonesArray* AliMUONData::Digits(Int_t DetectionPlane)
237 //Getting List of Digits
239 return ( (TClonesArray*) fDigits->At(DetectionPlane) );
243 //____________________________________________________________________________
244 Bool_t AliMUONData::IsRawClusterBranchesInTree()
246 // Checking if there are RawCluster Branches In TreeR
248 Error("TreeR","No treeR in memory");
253 sprintf(branchname,"%sRawClusters1",GetName());
254 TBranch * branch = 0x0;
255 branch = TreeR()->GetBranch(branchname);
256 if (branch) return kTRUE;
260 //____________________________________________________________________________
261 Bool_t AliMUONData::IsTriggerBranchesInTree()
263 // Checking if there are Trigger Branches In TreeR
265 Error("TreeR","No treeR in memory");
270 sprintf(branchname,"%sLocalTrigger",GetName());
271 TBranch * branch = 0x0;
272 branch = TreeR()->GetBranch(branchname);
273 if (branch) return kTRUE;
277 //____________________________________________________________________________
278 void AliMUONData::Fill(Option_t* option)
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
287 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
290 TBranch * branch = 0x0;
294 if ( TreeH() && cH ) {
299 if ( TreeD() && cD) {
304 // filling rawclusters
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);
314 else TreeR()->Fill();
319 if ( TreeR() && cGLT) {
320 if (IsRawClusterBranchesInTree()) {
321 // Branch per branch filling
322 sprintf(branchname,"%sLocalTrigger",GetName());
323 branch = TreeR()->GetBranch(branchname);
325 sprintf(branchname,"%sGlobalTrigger",GetName());
326 branch = TreeR()->GetBranch(branchname);
329 else TreeR()->Fill();
333 if ( TreeT() && cRT ) {
334 sprintf(branchname,"%sTrack",GetName());
337 // if ( TreeT() && cRTT ) {
338 // sprintf(branchname,"%sTrackTrig",GetName());
342 //_____________________________________________________________________________
343 void AliMUONData::MakeBranch(Option_t* option)
346 // Create Tree branches for the MUON.
348 const Int_t kBufferSize = 4000;
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
356 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
358 TBranch * branch = 0x0;
360 // Creating Branches for Hits
362 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
364 sprintf(branchname,"%sHits",GetName());
365 branch = TreeH()->GetBranch(branchname);
367 Info("MakeBranch","Branch %s is already in tree.",GetName());
370 branch = TreeH()->Branch(branchname,&fHits,kBufferSize);
371 Info("MakeBranch","Making Branch %s for hits \n",branchname);
374 //Creating Branches for Digits
375 if (TreeD() && cD ) {
376 // one branch for digits per chamber
377 if (fDigits == 0x0) {
378 fDigits = new TObjArray(AliMUONConstants::NCh());
379 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
380 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
383 if (fNdigits == 0x0) {
384 fNdigits = new Int_t[AliMUONConstants::NCh()];
385 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
386 fNdigits[iDetectionPlane]=0;
389 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
390 sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
392 branch = TreeD()->GetBranch(branchname);
394 Info("MakeBranch","Branch %s is already in tree.",GetName());
397 TClonesArray * digits = Digits(iDetectionPlane);
398 branch = TreeD()->Branch(branchname, &digits, kBufferSize,1);
399 Info("MakeBranch","Making Branch %s for digits in detection plane %d\n",branchname,iDetectionPlane+1);
403 if (TreeR() && cRC ) {
404 // one branch for raw clusters per tracking detection plane
407 if (fRawClusters == 0x0) {
408 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
409 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
410 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",1000),i);
414 if (fNrawclusters == 0x0) {
415 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
416 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
421 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
422 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
424 branch = TreeR()->GetBranch(branchname);
426 Info("MakeBranch","Branch %s is already in tree.",GetName());
429 branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize);
430 Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1);
434 if (TreeR() && cGLT ) {
436 // one branch for global trigger
438 sprintf(branchname,"%sGlobalTrigger",GetName());
441 if (fGlobalTrigger == 0x0) {
442 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger");
445 branch = TreeR()->GetBranch(branchname);
447 Info("MakeBranch","Branch %s is already in tree.",GetName());
450 branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize);
451 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
454 // one branch for local trigger
456 sprintf(branchname,"%sLocalTrigger",GetName());
459 if (fLocalTrigger == 0x0) {
460 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
463 branch = TreeR()->GetBranch(branchname);
465 Info("MakeBranch","Branch %s is already in tree.",GetName());
468 branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize);
469 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
472 if (TreeT() && cRT ) {
473 if (fRecTracks == 0x0) fRecTracks = new TClonesArray("AliMUONTrack",100);
475 sprintf(branchname,"%sTrack",GetName());
476 branch = TreeT()->GetBranch(branchname);
478 Info("MakeBranch","Branch %s is already in tree.",GetName());
481 branch = TreeT()->Branch(branchname,&fRecTracks,kBufferSize);
482 Info("MakeBranch","Making Branch %s for tracks \n",branchname);
485 //____________________________________________________________________________
486 TClonesArray* AliMUONData::RawClusters(Int_t DetectionPlane)
488 // Getting Raw Clusters
490 return ( (TClonesArray*) fRawClusters->At(DetectionPlane) );
494 //____________________________________________________________________________
495 void AliMUONData::ResetDigits()
498 // Reset number of digits and the digits array for this detector
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;
506 //______________________________________________________________________________
507 void AliMUONData::ResetHits()
509 // Reset number of clusters and the cluster array for this detector
511 if (fHits) fHits->Clear();
513 //_______________________________________________________________________________
514 void AliMUONData::ResetRawClusters()
516 // Reset number of raw clusters and the raw clust array for this detector
518 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
519 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
520 if (fNrawclusters) fNrawclusters[i]=0;
523 //_______________________________________________________________________________
524 void AliMUONData::ResetTrigger()
526 // Reset Local and Global Trigger
528 if (fGlobalTrigger) fGlobalTrigger->Clear();
530 if (fLocalTrigger) fLocalTrigger->Clear();
532 //____________________________________________________________________________
533 void AliMUONData::ResetRecTracks()
535 // Reset tracks information
537 if (fRecTracks) fRecTracks->Clear();
539 //_____________________________________________________________________________
540 void AliMUONData::SetTreeAddress(Option_t* option)
542 //Setting Addresses to the events trees
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
547 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
548 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
550 // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree.
552 TBranch * branch = 0x0;
555 // Branch address for hit tree
556 if ( TreeH() && cH ) {
557 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
560 if (TreeH() && fHits && cH) {
561 sprintf(branchname,"%sHits",GetName());
562 branch = TreeH()->GetBranch(branchname);
564 // Info("SetTreeAddress","(%s) Setting for Hits",GetName());
565 branch->SetAddress(&fHits);
567 else { //can be invoked before branch creation
568 Warning("SetTreeAddress","(%s) Failed for Hits. Can not find branch in tree.",GetName());
573 // Branch address for digit tree
574 if ( TreeD() && cD) {
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);
585 if (TreeD() && fDigits && cD) {
586 for (int i=0; i<AliMUONConstants::NCh(); i++) {
587 sprintf(branchname,"%sDigits%d",GetName(),i+1);
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);
598 // Branch address for rawclusters, globaltrigger and local trigger tree
600 if (fRawClusters == 0x0 && cRC) {
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);
608 if (fLocalTrigger == 0x0 && cGLT) {
609 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
611 if (fGlobalTrigger== 0x0 && cGLT) {
612 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
616 if ( TreeR() && fRawClusters && cRC) {
617 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
618 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
620 branch = TreeR()->GetBranch(branchname);
621 if (branch) branch->SetAddress( &((*fRawClusters)[i]) );
622 else Warning("SetTreeAddress","(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i);
626 if ( TreeR() && fLocalTrigger && cGLT) {
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());
632 if ( TreeR() && fGlobalTrigger && cGLT) {
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());
640 if (fRecTracks == 0x0 && cRT) {
641 fRecTracks = new TClonesArray("AliMUONTrack",100);
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());
653 //_____________________________________________________________________________