6 #include "AliMUONData.h"
7 #include "AliMUONDigit.h"
8 #include "AliMUONHit.h"
9 #include "AliMUONLocalTrigger.h"
10 #include "AliMUONGlobalTrigger.h"
11 #include "AliMUONRawCluster.h"
12 #include "AliMUONTrack.h"
16 //_____________________________________________________________________________
17 AliMUONData::AliMUONData():TNamed()
20 fHits = 0x0; // One event in treeH per primary track
21 fDigits = 0x0; // One event in treeH per detection plane
23 fRawClusters = 0x0; //One event in TreeR/RawclusterBranch per tracking detection plane
24 fGlobalTrigger = 0x0; //! List of Global Trigger 1st event in TreeR/GlobalTriggerBranch
25 fLocalTrigger = 0x0; //! List of Local Trigger, 1st event in TreeR/LocalTriggerBranch
29 //_____________________________________________________________________________
30 AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
34 fHits = new TClonesArray("AliMUONHit",1000);
36 fDigits = new TObjArray(AliMUONConstants::NCh());
37 fNdigits = new Int_t[AliMUONConstants::NCh()];
38 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
39 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
40 fNdigits[iDetectionPlane]=0;
42 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
43 fNrawclusters = new Int_t[AliMUONConstants::NTrackingCh()];
44 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NTrackingCh();iDetectionPlane++) {
45 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),iDetectionPlane);
46 fNrawclusters[iDetectionPlane]=0;
48 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
50 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
52 fRecTracks = new TClonesArray("AliMUONTrack", 10);
53 fNrectracks = 0; // really needed or GetEntriesFast sufficient ????
56 //_____________________________________________________________________________
57 AliMUONData::AliMUONData(const AliMUONData& rMUONData):TNamed(rMUONData)
59 // Dummy copy constructor
62 //_____________________________________________________________________________
63 AliMUONData::~AliMUONData()
74 fRawClusters->Delete();
78 fGlobalTrigger->Delete();
79 delete fGlobalTrigger;
82 fLocalTrigger->Delete();
91 //_____________________________________________________________________________
92 void AliMUONData::AddDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
95 // Add a MUON digit to the list of Digits of the detection plane id
97 TClonesArray &ldigits = * Digits(id,0) ;
98 new(ldigits[fNdigits[id]++]) AliMUONDigit(tracks,charges,digits);
100 //_____________________________________________________________________________
101 void AliMUONData::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
103 Int_t *pairUnlike, Int_t *pairLike)
105 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
106 TClonesArray &globalTrigger = *fGlobalTrigger;
107 new(globalTrigger[fNglobaltrigger++])
108 AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
110 //_____________________________________________________________________________
111 void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
112 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
113 Float_t tof, Float_t momentum, Float_t theta,
114 Float_t phi, Float_t length, Float_t destep)
116 TClonesArray &lhits = *fHits;
117 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
119 tof, momentum, theta,
120 phi, length, destep);
122 //____________________________________________________________________________
123 void AliMUONData::AddLocalTrigger(Int_t *localtr)
125 // add a MUON Local Trigger to the list
126 TClonesArray &localTrigger = *fLocalTrigger;
127 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(localtr);
129 //_____________________________________________________________________________
130 void AliMUONData::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
133 // Add a MUON rawcluster to the list in the detection plane id
135 TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id));
136 new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c);
138 //_____________________________________________________________________________
139 void AliMUONData::AddRecTrack(const AliMUONTrack& track)
142 // Add a MUON rectrack
144 TClonesArray &lrectracks = *fRecTracks;
145 new(lrectracks[fNrectracks++]) AliMUONTrack(track);
147 //____________________________________________________________________________
148 void AliMUONData::MakeBranch(Option_t* option)
151 // Create Tree branches for the MUON.
153 const Int_t kBufferSize = 4000;
156 const char *cH = strstr(option,"H");
157 const char *cD = strstr(option,"D"); // Digits branches in TreeD
158 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
159 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
160 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
161 const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
163 TBranch * branch = 0x0;
165 // Creating Branches for Hits
167 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
169 sprintf(branchname,"%sHits",GetName());
170 branch = TreeH()->GetBranch(branchname);
172 Info("MakeBranch","Branch %s is already in tree.",GetName());
175 branch = TreeH()->Branch(branchname,&fHits,kBufferSize);
176 Info("MakeBranch","Making Branch %s for hits \n",branchname);
179 //Creating Branches for Digits
180 if (TreeD() && cD ) {
181 // one branch for digits per chamber
182 if (fDigits == 0x0) {
183 fDigits = new TObjArray(AliMUONConstants::NCh());
184 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
185 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
188 if (fNdigits == 0x0) {
189 fNdigits = new Int_t[AliMUONConstants::NCh()];
190 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
191 fNdigits[iDetectionPlane]=0;
194 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
195 sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
197 branch = TreeD()->GetBranch(branchname);
199 Info("MakeBranch","Branch %s is already in tree.",GetName());
202 TClonesArray * digits = Digits(iDetectionPlane,0);
203 branch = TreeD()->Branch(branchname, &digits, kBufferSize);
204 Info("MakeBranch","Making Branch %s for digits in detection plane %d\n",branchname,iDetectionPlane+1);
208 if (TreeR() && cRC ) {
209 // one branch for raw clusters per tracking detection plane
212 if (fRawClusters == 0x0) {
213 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
214 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
215 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
219 if (fNrawclusters == 0x0) {
220 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
221 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
226 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
227 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
229 branch = TreeR()->GetBranch(branchname);
231 Info("MakeBranch","Branch %s is already in tree.",GetName());
234 branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize);
235 Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1);
239 if (TreeR() && cGLT ) {
241 // one branch for global trigger
243 sprintf(branchname,"%sGlobalTrigger",GetName());
246 if (fGlobalTrigger == 0x0) {
247 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
250 branch = TreeR()->GetBranch(branchname);
252 Info("MakeBranch","Branch %s is already in tree.",GetName());
255 branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize);
256 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
259 // one branch for local trigger
261 sprintf(branchname,"%sLocalTrigger",GetName());
264 if (fLocalTrigger == 0x0) {
265 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
268 branch = TreeR()->GetBranch(branchname);
270 Info("MakeBranch","Branch %s is already in tree.",GetName());
273 branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize);
274 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
277 if (TreeT() && cRT ) {
278 if (fRecTracks == 0x0) fRecTracks = new TClonesArray("AliMUONTrack",10);
280 sprintf(branchname,"%sTrack",GetName());
281 branch = TreeT()->GetBranch(branchname);
283 Info("MakeBranch","Branch %s is already in tree.",GetName());
286 branch = TreeT()->Branch(branchname,&fRecTracks,kBufferSize);
287 Info("MakeBranch","Making Branch %s for tracks \n",branchname);
290 if (TreeP() && cRP ) {
291 Info("MakeBranch","Making Branch for TreeP is not yet ready. \n");
295 //____________________________________________________________________________
296 void AliMUONData::ResetDigits()
299 // Reset number of digits and the digits array for this detector
301 if (fDigits == 0x0) return;
302 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
303 if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear();
304 if (fNdigits) fNdigits[i]=0;
307 //______________________________________________________________________________
308 void AliMUONData::ResetHits()
310 // Reset number of clusters and the cluster array for this detector
312 if (fHits) fHits->Clear();
314 //_______________________________________________________________________________
315 void AliMUONData::ResetRawClusters()
317 // Reset number of raw clusters and the raw clust array for this detector
319 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
320 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
321 if (fNrawclusters) fNrawclusters[i]=0;
324 //_______________________________________________________________________________
325 void AliMUONData::ResetTrigger()
327 // Reset Local and Global Trigger
329 if (fGlobalTrigger) fGlobalTrigger->Clear();
331 if (fLocalTrigger) fLocalTrigger->Clear();
333 //____________________________________________________________________________
334 void AliMUONData::ResetRecTracks()
336 // Reset tracks information
338 if (fRecTracks) fRecTracks->Clear();
340 //_____________________________________________________________________________
341 void AliMUONData::SetTreeAddress(Option_t* option)
343 const char *cH = strstr(option,"H");
344 const char *cD = strstr(option,"D"); // Digits branches in TreeD
345 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
346 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
347 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
348 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
350 // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree.
352 TBranch * branch = 0x0;
355 // Branch address for hit tree
356 if ( TreeH() && cH ) {
357 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
360 if (TreeH() && fHits && cH) {
361 sprintf(branchname,"%sHits",GetName());
362 branch = TreeH()->GetBranch(branchname);
364 Info("SetTreeAddress","(%s) Setting for Hits",GetName());
365 branch->SetAddress(&fHits);
367 else { //can be invoked before branch creation
368 Warning("SetTreeAddress","(%s) Failed for Hits. Can not find branch in tree.",GetName());
373 // Branch address for digit tree
374 if ( TreeD() && cD) {
375 if (fDigits == 0x0) {
376 fDigits = new TObjArray(AliMUONConstants::NCh());
377 fNdigits= new Int_t[AliMUONConstants::NCh()];
378 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
379 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i);
385 if (TreeD() && fDigits && cD) {
386 for (int i=0; i<AliMUONConstants::NCh(); i++) {
387 sprintf(branchname,"%sDigits%d",GetName(),i+1);
388 branch = TreeD()->GetBranch(branchname);
389 TClonesArray * digits = Digits(i,0);
390 if (branch) branch->SetAddress( &digits );
391 else Warning("SetTreeAddress","(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i);
396 // Branch address for rawclusters, globaltrigger and local trigger tree
398 if (fRawClusters == 0x0 && cRC) {
399 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
400 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
401 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
402 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
406 if (fLocalTrigger == 0x0 && cGLT) {
407 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
409 if (fGlobalTrigger== 0x0 && cGLT) {
410 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
414 if ( TreeR() && fRawClusters && cRC) {
415 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
416 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
418 branch = TreeR()->GetBranch(branchname);
419 if (branch) branch->SetAddress(&((*fRawClusters)[i]));
420 else Warning("SetTreeAddress","(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i);
424 if ( TreeR() && fLocalTrigger && cGLT) {
425 sprintf(branchname,"%sLocalTrigger",GetName());
426 branch = TreeR()->GetBranch(branchname);
427 if (branch) branch->SetAddress(&fLocalTrigger);
428 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
430 if ( TreeR() && fGlobalTrigger && cGLT) {
431 sprintf(branchname,"%sGlobalTrigger",GetName());
432 branch = TreeR()->GetBranch(branchname);
433 if (branch) branch->SetAddress(&fGlobalTrigger);
434 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
437 if ( TreeT() && fRecTracks && cRT ) {
438 sprintf(branchname,"%sTrack",GetName());
439 branch = TreeT()->GetBranch(branchname);
440 if (branch) branch->SetAddress(&fRecTracks);
441 else Warning("SetTreeAddress","(%s) Failed for Tracks. Can not find branch in tree.",GetName());
444 //_____________________________________________________________________________