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", 10);
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 Bool_t AliMUONData::IsRawClusterBranchesInTree()
197 Error("TreeR","No treeR in memory");
202 sprintf(branchname,"%sRawClusters1",GetName());
203 TBranch * branch = 0x0;
204 branch = TreeR()->GetBranch(branchname);
205 if (branch) return kTRUE;
209 //____________________________________________________________________________
210 Bool_t AliMUONData::IsTriggerBranchesInTree()
213 Error("TreeR","No treeR in memory");
218 sprintf(branchname,"%sLocalTrigger",GetName());
219 TBranch * branch = 0x0;
220 branch = TreeR()->GetBranch(branchname);
221 if (branch) return kTRUE;
225 //____________________________________________________________________________
226 void AliMUONData::Fill(Option_t* option)
228 // Method to fill the trees
229 const char *cH = strstr(option,"H");
230 const char *cD = strstr(option,"D"); // Digits branches in TreeD
231 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
232 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
233 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
234 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
237 TBranch * branch = 0x0;
241 if ( TreeH() && cH ) {
246 if ( TreeD() && cD) {
251 // filling rawclusters
252 if ( TreeR() && cRC ) {
253 if ( IsTriggerBranchesInTree() ) {
254 // Branch per branch filling
255 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
256 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
257 branch = TreeR()->GetBranch(branchname);
261 else TreeR()->Fill();
266 if ( TreeR() && cGLT) {
267 if (IsRawClusterBranchesInTree()) {
268 // Branch per branch filling
269 sprintf(branchname,"%sLocalTrigger",GetName());
270 branch = TreeR()->GetBranch(branchname);
272 sprintf(branchname,"%sGlobalTrigger",GetName());
273 branch = TreeR()->GetBranch(branchname);
276 else TreeR()->Fill();
280 if ( TreeT() && cRT ) {
281 sprintf(branchname,"%sTrack",GetName());
282 branch = TreeT()->GetBranch(branchname);
286 //_____________________________________________________________________________
287 void AliMUONData::MakeBranch(Option_t* option)
290 // Create Tree branches for the MUON.
292 const Int_t kBufferSize = 4000;
295 const char *cH = strstr(option,"H");
296 const char *cD = strstr(option,"D"); // Digits branches in TreeD
297 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
298 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
299 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
300 const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
302 TBranch * branch = 0x0;
304 // Creating Branches for Hits
306 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
308 sprintf(branchname,"%sHits",GetName());
309 branch = TreeH()->GetBranch(branchname);
311 Info("MakeBranch","Branch %s is already in tree.",GetName());
314 branch = TreeH()->Branch(branchname,&fHits,kBufferSize,fSplitLevel);
315 Info("MakeBranch","Making Branch %s for hits \n",branchname);
318 //Creating Branches for Digits
319 if (TreeD() && cD ) {
320 // one branch for digits per chamber
321 if (fDigits == 0x0) {
322 fDigits = new TObjArray(AliMUONConstants::NCh());
323 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
324 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
327 if (fNdigits == 0x0) {
328 fNdigits = new Int_t[AliMUONConstants::NCh()];
329 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
330 fNdigits[iDetectionPlane]=0;
333 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
334 sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
336 branch = TreeD()->GetBranch(branchname);
338 Info("MakeBranch","Branch %s is already in tree.",GetName());
341 TClonesArray * digits = Digits(iDetectionPlane);
342 branch = TreeD()->Branch(branchname, &digits, kBufferSize,1);
343 Info("MakeBranch","Making Branch %s for digits in detection plane %d\n",branchname,iDetectionPlane+1);
347 if (TreeR() && cRC ) {
348 // one branch for raw clusters per tracking detection plane
351 if (fRawClusters == 0x0) {
352 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
353 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
354 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",1000),i);
358 if (fNrawclusters == 0x0) {
359 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
360 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
365 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
366 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
368 branch = TreeR()->GetBranch(branchname);
370 Info("MakeBranch","Branch %s is already in tree.",GetName());
373 branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize,fSplitLevel);
374 Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1);
378 if (TreeR() && cGLT ) {
380 // one branch for global trigger
382 sprintf(branchname,"%sGlobalTrigger",GetName());
385 if (fGlobalTrigger == 0x0) {
386 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",fSplitLevel);
389 branch = TreeR()->GetBranch(branchname);
391 Info("MakeBranch","Branch %s is already in tree.",GetName());
394 branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize,fSplitLevel);
395 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
398 // one branch for local trigger
400 sprintf(branchname,"%sLocalTrigger",GetName());
403 if (fLocalTrigger == 0x0) {
404 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
407 branch = TreeR()->GetBranch(branchname);
409 Info("MakeBranch","Branch %s is already in tree.",GetName());
412 branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize,fSplitLevel);
413 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
416 if (TreeT() && cRT ) {
417 if (fRecTracks == 0x0) fRecTracks = new TClonesArray("AliMUONTrack",10);
419 sprintf(branchname,"%sTrack",GetName());
420 branch = TreeT()->GetBranch(branchname);
422 Info("MakeBranch","Branch %s is already in tree.",GetName());
425 branch = TreeT()->Branch(branchname,&fRecTracks,kBufferSize);
426 Info("MakeBranch","Making Branch %s for tracks \n",branchname);
429 if (TreeP() && cRP ) {
430 Info("MakeBranch","Making Branch for TreeP is not yet ready. \n");
434 //____________________________________________________________________________
435 void AliMUONData::ResetDigits()
438 // Reset number of digits and the digits array for this detector
440 if (fDigits == 0x0) return;
441 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
442 if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear();
443 if (fNdigits) fNdigits[i]=0;
446 //______________________________________________________________________________
447 void AliMUONData::ResetHits()
449 // Reset number of clusters and the cluster array for this detector
451 if (fHits) fHits->Clear();
453 //_______________________________________________________________________________
454 void AliMUONData::ResetRawClusters()
456 // Reset number of raw clusters and the raw clust array for this detector
458 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
459 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
460 if (fNrawclusters) fNrawclusters[i]=0;
463 //_______________________________________________________________________________
464 void AliMUONData::ResetTrigger()
466 // Reset Local and Global Trigger
468 if (fGlobalTrigger) fGlobalTrigger->Clear();
470 if (fLocalTrigger) fLocalTrigger->Clear();
472 //____________________________________________________________________________
473 void AliMUONData::ResetRecTracks()
475 // Reset tracks information
477 if (fRecTracks) fRecTracks->Clear();
479 //_____________________________________________________________________________
480 void AliMUONData::SetTreeAddress(Option_t* option)
482 const char *cH = strstr(option,"H");
483 const char *cD = strstr(option,"D"); // Digits branches in TreeD
484 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
485 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
486 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
487 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
489 // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree.
491 TBranch * branch = 0x0;
494 // Branch address for hit tree
495 if ( TreeH() && cH ) {
496 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
499 if (TreeH() && fHits && cH) {
500 sprintf(branchname,"%sHits",GetName());
501 branch = TreeH()->GetBranch(branchname);
503 // Info("SetTreeAddress","(%s) Setting for Hits",GetName());
504 branch->SetAddress(&fHits);
506 else { //can be invoked before branch creation
507 Warning("SetTreeAddress","(%s) Failed for Hits. Can not find branch in tree.",GetName());
512 // Branch address for digit tree
513 if ( TreeD() && cD) {
514 if (fDigits == 0x0) {
515 fDigits = new TObjArray(AliMUONConstants::NCh());
516 fNdigits= new Int_t[AliMUONConstants::NCh()];
517 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
518 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i);
524 if (TreeD() && fDigits && cD) {
525 for (int i=0; i<AliMUONConstants::NCh(); i++) {
526 sprintf(branchname,"%sDigits%d",GetName(),i+1);
528 branch = TreeD()->GetBranch(branchname);
529 TClonesArray * digits = Digits(i);
530 if (branch) branch->SetAddress( &digits );
531 else Warning("SetTreeAddress","(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i);
537 // Branch address for rawclusters, globaltrigger and local trigger tree
539 if (fRawClusters == 0x0 && cRC) {
540 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
541 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
542 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
543 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
547 if (fLocalTrigger == 0x0 && cGLT) {
548 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
550 if (fGlobalTrigger== 0x0 && cGLT) {
551 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
555 if ( TreeR() && fRawClusters && cRC) {
556 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
557 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
559 branch = TreeR()->GetBranch(branchname);
560 if (branch) branch->SetAddress( &((*fRawClusters)[i]) );
561 else Warning("SetTreeAddress","(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i);
565 if ( TreeR() && fLocalTrigger && cGLT) {
566 sprintf(branchname,"%sLocalTrigger",GetName());
567 branch = TreeR()->GetBranch(branchname);
568 if (branch) branch->SetAddress(&fLocalTrigger);
569 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
571 if ( TreeR() && fGlobalTrigger && cGLT) {
572 sprintf(branchname,"%sGlobalTrigger",GetName());
573 branch = TreeR()->GetBranch(branchname);
574 if (branch) branch->SetAddress(&fGlobalTrigger);
575 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
578 if ( TreeT() && fRecTracks && cRT ) {
579 sprintf(branchname,"%sTrack",GetName());
580 branch = TreeT()->GetBranch(branchname);
581 if (branch) branch->SetAddress(&fRecTracks);
582 else Warning("SetTreeAddress","(%s) Failed for Tracks. Can not find branch in tree.",GetName());
585 //_____________________________________________________________________________