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
46 //_____________________________________________________________________________
47 AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
51 fHits = 0x0; // One event in treeH per primary track
52 fDigits = 0x0; // One event in treeH per detection plane
54 fRawClusters = 0x0; //One event in TreeR/RawclusterBranch per tracking detection plane
55 fGlobalTrigger = 0x0; //! List of Global Trigger 1st event in TreeR/GlobalTriggerBranch
56 fLocalTrigger = 0x0; //! List of Local Trigger, 1st event in TreeR/LocalTriggerBranch
62 // fHits = new TClonesArray("AliMUONHit",1000);
64 // fDigits = new TObjArray(AliMUONConstants::NCh());
65 // fNdigits = new Int_t[AliMUONConstants::NCh()];
66 // for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
67 // fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
68 // fNdigits[iDetectionPlane]=0;
70 // fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
71 // fNrawclusters = new Int_t[AliMUONConstants::NTrackingCh()];
72 // for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NTrackingCh();iDetectionPlane++) {
73 // fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),iDetectionPlane);
74 // fNrawclusters[iDetectionPlane]=0;
76 // fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
77 // fNglobaltrigger =0;
78 // fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
79 // fNlocaltrigger = 0;
80 // fRecTracks = new TClonesArray("AliMUONTrack", 10);
81 // fNrectracks = 0; // really needed or GetEntriesFast sufficient ????
86 //_____________________________________________________________________________
87 AliMUONData::AliMUONData(const AliMUONData& rMUONData):TNamed(rMUONData)
89 // Dummy copy constructor
92 //_____________________________________________________________________________
93 AliMUONData::~AliMUONData()
104 fRawClusters->Delete();
108 fGlobalTrigger->Delete();
109 delete fGlobalTrigger;
112 fLocalTrigger->Delete();
113 delete fLocalTrigger;
116 fRecTracks->Delete();
121 //_____________________________________________________________________________
122 void AliMUONData::AddDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
125 // Add a MUON digit to the list of Digits of the detection plane id
127 TClonesArray &ldigits = * Digits(id) ;
128 new(ldigits[fNdigits[id]++]) AliMUONDigit(tracks,charges,digits);
130 //_____________________________________________________________________________
131 void AliMUONData::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
133 Int_t *pairUnlike, Int_t *pairLike)
135 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
136 TClonesArray &globalTrigger = *fGlobalTrigger;
137 new(globalTrigger[fNglobaltrigger++])
138 AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
140 //_____________________________________________________________________________
141 void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
142 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
143 Float_t tof, Float_t momentum, Float_t theta,
144 Float_t phi, Float_t length, Float_t destep)
146 TClonesArray &lhits = *fHits;
147 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
149 tof, momentum, theta,
150 phi, length, destep);
152 //____________________________________________________________________________
153 void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
154 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
155 Float_t tof, Float_t momentum, Float_t theta,
156 Float_t phi, Float_t length, Float_t destep,
157 Float_t Xref,Float_t Yref,Float_t Zref)
159 TClonesArray &lhits = *fHits;
160 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
162 tof, momentum, theta,
166 //____________________________________________________________________________
167 void AliMUONData::AddLocalTrigger(Int_t *localtr)
169 // add a MUON Local Trigger to the list
170 TClonesArray &localTrigger = *fLocalTrigger;
171 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(localtr);
173 //_____________________________________________________________________________
174 void AliMUONData::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
177 // Add a MUON rawcluster to the list in the detection plane id
179 TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id));
180 new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c);
182 //_____________________________________________________________________________
183 void AliMUONData::AddRecTrack(const AliMUONTrack& track)
186 // Add a MUON rectrack
188 TClonesArray &lrectracks = *fRecTracks;
189 new(lrectracks[fNrectracks++]) AliMUONTrack(track);
191 //____________________________________________________________________________
192 Bool_t AliMUONData::IsRawClusterBranchesInTree()
195 Error("TreeR","No treeR in memory");
200 sprintf(branchname,"%sRawClusters1",GetName());
201 TBranch * branch = 0x0;
202 branch = TreeR()->GetBranch(branchname);
203 if (branch) return kTRUE;
207 //____________________________________________________________________________
208 Bool_t AliMUONData::IsTriggerBranchesInTree()
211 Error("TreeR","No treeR in memory");
216 sprintf(branchname,"%sLocalTrigger",GetName());
217 TBranch * branch = 0x0;
218 branch = TreeR()->GetBranch(branchname);
219 if (branch) return kTRUE;
223 //____________________________________________________________________________
224 void AliMUONData::Fill(Option_t* option)
226 // Method to fill the trees
227 const char *cH = strstr(option,"H");
228 const char *cD = strstr(option,"D"); // Digits branches in TreeD
229 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
230 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
231 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
232 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
235 TBranch * branch = 0x0;
239 if ( TreeH() && cH ) {
244 if ( TreeD() && cD) {
249 // filling rawclusters
250 if ( TreeR() && cRC ) {
251 if ( IsTriggerBranchesInTree() ) {
252 // Branch per branch filling
253 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
254 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
255 branch = TreeR()->GetBranch(branchname);
259 else TreeR()->Fill();
264 if ( TreeR() && cGLT) {
265 if (IsRawClusterBranchesInTree()) {
266 // Branch per branch filling
267 sprintf(branchname,"%sLocalTrigger",GetName());
268 branch = TreeR()->GetBranch(branchname);
270 sprintf(branchname,"%sGlobalTrigger",GetName());
271 branch = TreeR()->GetBranch(branchname);
274 else TreeR()->Fill();
278 if ( TreeT() && cRT ) {
279 sprintf(branchname,"%sTrack",GetName());
280 branch = TreeT()->GetBranch(branchname);
284 //_____________________________________________________________________________
285 void AliMUONData::MakeBranch(Option_t* option)
288 // Create Tree branches for the MUON.
290 const Int_t kBufferSize = 4000;
293 const char *cH = strstr(option,"H");
294 const char *cD = strstr(option,"D"); // Digits branches in TreeD
295 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
296 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
297 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
298 const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
300 TBranch * branch = 0x0;
302 // Creating Branches for Hits
304 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
306 sprintf(branchname,"%sHits",GetName());
307 branch = TreeH()->GetBranch(branchname);
309 Info("MakeBranch","Branch %s is already in tree.",GetName());
312 branch = TreeH()->Branch(branchname,&fHits,kBufferSize);
313 Info("MakeBranch","Making Branch %s for hits \n",branchname);
316 //Creating Branches for Digits
317 if (TreeD() && cD ) {
318 // one branch for digits per chamber
319 if (fDigits == 0x0) {
320 fDigits = new TObjArray(AliMUONConstants::NCh());
321 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
322 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
325 if (fNdigits == 0x0) {
326 fNdigits = new Int_t[AliMUONConstants::NCh()];
327 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
328 fNdigits[iDetectionPlane]=0;
331 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
332 sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
334 branch = TreeD()->GetBranch(branchname);
336 Info("MakeBranch","Branch %s is already in tree.",GetName());
339 TClonesArray * digits = Digits(iDetectionPlane);
340 branch = TreeD()->Branch(branchname, &digits, kBufferSize);
341 Info("MakeBranch","Making Branch %s for digits in detection plane %d\n",branchname,iDetectionPlane+1);
345 if (TreeR() && cRC ) {
346 // one branch for raw clusters per tracking detection plane
349 if (fRawClusters == 0x0) {
350 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
351 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
352 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
356 if (fNrawclusters == 0x0) {
357 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
358 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
363 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
364 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
366 branch = TreeR()->GetBranch(branchname);
368 Info("MakeBranch","Branch %s is already in tree.",GetName());
371 branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize);
372 Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1);
376 if (TreeR() && cGLT ) {
378 // one branch for global trigger
380 sprintf(branchname,"%sGlobalTrigger",GetName());
383 if (fGlobalTrigger == 0x0) {
384 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
387 branch = TreeR()->GetBranch(branchname);
389 Info("MakeBranch","Branch %s is already in tree.",GetName());
392 branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize);
393 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
396 // one branch for local trigger
398 sprintf(branchname,"%sLocalTrigger",GetName());
401 if (fLocalTrigger == 0x0) {
402 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
405 branch = TreeR()->GetBranch(branchname);
407 Info("MakeBranch","Branch %s is already in tree.",GetName());
410 branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize);
411 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
414 if (TreeT() && cRT ) {
415 if (fRecTracks == 0x0) fRecTracks = new TClonesArray("AliMUONTrack",10);
417 sprintf(branchname,"%sTrack",GetName());
418 branch = TreeT()->GetBranch(branchname);
420 Info("MakeBranch","Branch %s is already in tree.",GetName());
423 branch = TreeT()->Branch(branchname,&fRecTracks,kBufferSize);
424 Info("MakeBranch","Making Branch %s for tracks \n",branchname);
427 if (TreeP() && cRP ) {
428 Info("MakeBranch","Making Branch for TreeP is not yet ready. \n");
432 //____________________________________________________________________________
433 void AliMUONData::ResetDigits()
436 // Reset number of digits and the digits array for this detector
438 if (fDigits == 0x0) return;
439 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
440 if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear();
441 if (fNdigits) fNdigits[i]=0;
444 //______________________________________________________________________________
445 void AliMUONData::ResetHits()
447 // Reset number of clusters and the cluster array for this detector
449 if (fHits) fHits->Clear();
451 //_______________________________________________________________________________
452 void AliMUONData::ResetRawClusters()
454 // Reset number of raw clusters and the raw clust array for this detector
456 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
457 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
458 if (fNrawclusters) fNrawclusters[i]=0;
461 //_______________________________________________________________________________
462 void AliMUONData::ResetTrigger()
464 // Reset Local and Global Trigger
466 if (fGlobalTrigger) fGlobalTrigger->Clear();
468 if (fLocalTrigger) fLocalTrigger->Clear();
470 //____________________________________________________________________________
471 void AliMUONData::ResetRecTracks()
473 // Reset tracks information
475 if (fRecTracks) fRecTracks->Clear();
477 //_____________________________________________________________________________
478 void AliMUONData::SetTreeAddress(Option_t* option)
480 const char *cH = strstr(option,"H");
481 const char *cD = strstr(option,"D"); // Digits branches in TreeD
482 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
483 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
484 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
485 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
487 // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree.
489 TBranch * branch = 0x0;
492 // Branch address for hit tree
493 if ( TreeH() && cH ) {
494 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
497 if (TreeH() && fHits && cH) {
498 sprintf(branchname,"%sHits",GetName());
499 branch = TreeH()->GetBranch(branchname);
501 Info("SetTreeAddress","(%s) Setting for Hits",GetName());
502 branch->SetAddress(&fHits);
504 else { //can be invoked before branch creation
505 Warning("SetTreeAddress","(%s) Failed for Hits. Can not find branch in tree.",GetName());
510 // Branch address for digit tree
511 if ( TreeD() && cD) {
512 if (fDigits == 0x0) {
513 fDigits = new TObjArray(AliMUONConstants::NCh());
514 fNdigits= new Int_t[AliMUONConstants::NCh()];
515 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
516 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i);
522 if (TreeD() && fDigits && cD) {
523 for (int i=0; i<AliMUONConstants::NCh(); i++) {
524 sprintf(branchname,"%sDigits%d",GetName(),i+1);
525 branch = TreeD()->GetBranch(branchname);
526 TClonesArray * digits = Digits(i);
527 if (branch) branch->SetAddress( &digits );
528 else Warning("SetTreeAddress","(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i);
533 // Branch address for rawclusters, globaltrigger and local trigger tree
535 if (fRawClusters == 0x0 && cRC) {
536 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
537 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
538 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
539 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
543 if (fLocalTrigger == 0x0 && cGLT) {
544 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
546 if (fGlobalTrigger== 0x0 && cGLT) {
547 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
551 if ( TreeR() && fRawClusters && cRC) {
552 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
553 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
555 branch = TreeR()->GetBranch(branchname);
556 if (branch) branch->SetAddress(&((*fRawClusters)[i]));
557 else Warning("SetTreeAddress","(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i);
561 if ( TreeR() && fLocalTrigger && cGLT) {
562 sprintf(branchname,"%sLocalTrigger",GetName());
563 branch = TreeR()->GetBranch(branchname);
564 if (branch) branch->SetAddress(&fLocalTrigger);
565 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
567 if ( TreeR() && fGlobalTrigger && cGLT) {
568 sprintf(branchname,"%sGlobalTrigger",GetName());
569 branch = TreeR()->GetBranch(branchname);
570 if (branch) branch->SetAddress(&fGlobalTrigger);
571 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
574 if ( TreeT() && fRecTracks && cRT ) {
575 sprintf(branchname,"%sTrack",GetName());
576 branch = TreeT()->GetBranch(branchname);
577 if (branch) branch->SetAddress(&fRecTracks);
578 else Warning("SetTreeAddress","(%s) Failed for Tracks. Can not find branch in tree.",GetName());
581 //_____________________________________________________________________________