6 #include "AliMUONData.h"
7 #include "AliMUONDigit.h"
8 #include "AliMUONHit.h"
9 #include "AliMUONLocalTrigger.h"
10 #include "AliMUONGlobalTrigger.h"
11 #include "AliMUONRawCluster.h"
15 //_____________________________________________________________________________
16 AliMUONData::AliMUONData():TNamed()
19 fHits = 0x0; // One event in treeH per primary track
20 fDigits = 0x0; // One event in treeH per detection plane
22 fRawClusters = 0x0; //One event in TreeR/RawclusterBranch per tracking detection plane
23 fGlobalTrigger = 0x0; //! List of Global Trigger 1st event in TreeR/GlobalTriggerBranch
24 fLocalTrigger = 0x0; //! List of Local Trigger, 1st event in TreeR/LocalTriggerBranch
27 //_____________________________________________________________________________
28 AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
32 fHits = new TClonesArray("AliMUONHit",1000);
34 fDigits = new TObjArray(AliMUONConstants::NCh());
35 fNdigits = new Int_t[AliMUONConstants::NCh()];
36 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
37 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
38 fNdigits[iDetectionPlane]=0;
40 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
41 fNrawclusters = new Int_t[AliMUONConstants::NTrackingCh()];
42 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NTrackingCh();iDetectionPlane++) {
43 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),iDetectionPlane);
44 fNrawclusters[iDetectionPlane]=0;
46 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
48 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
52 //_____________________________________________________________________________
53 AliMUONData::AliMUONData(const AliMUONData& rMUONData):TNamed(rMUONData)
55 // Dummy copy constructor
58 //_____________________________________________________________________________
59 AliMUONData::~AliMUONData()
70 fRawClusters->Delete();
74 fGlobalTrigger->Delete();
75 delete fGlobalTrigger;
78 fLocalTrigger->Delete();
83 //_____________________________________________________________________________
84 void AliMUONData::AddDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
87 // Add a MUON digit to the list of Digits of the detection plane id
89 TClonesArray &ldigits = * Digits(id,0) ;
90 new(ldigits[fNdigits[id]++]) AliMUONDigit(tracks,charges,digits);
92 //_____________________________________________________________________________
93 void AliMUONData::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
95 Int_t *pairUnlike, Int_t *pairLike)
97 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
98 TClonesArray &globalTrigger = *fGlobalTrigger;
99 new(globalTrigger[fNglobaltrigger++])
100 AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
102 //_____________________________________________________________________________
103 void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
104 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
105 Float_t tof, Float_t momentum, Float_t theta,
106 Float_t phi, Float_t length, Float_t destep)
108 TClonesArray &lhits = *fHits;
109 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
111 tof, momentum, theta,
112 phi, length, destep);
114 //____________________________________________________________________________
115 void AliMUONData::AddLocalTrigger(Int_t *localtr)
117 // add a MUON Local Trigger to the list
118 TClonesArray &localTrigger = *fLocalTrigger;
119 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(localtr);
121 //_____________________________________________________________________________
122 void AliMUONData::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
125 // Add a MUON rawcluster to the list in the detection plane id
127 TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id));
128 new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c);
130 //____________________________________________________________________________
131 void AliMUONData::MakeBranch(Option_t* option)
134 // Create Tree branches for the MUON.
136 const Int_t kBufferSize = 4000;
139 const char *cH = strstr(option,"H");
140 const char *cD = strstr(option,"D"); // Digits branches in TreeD
141 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
142 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
143 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
144 const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
146 TBranch * branch = 0x0;
148 // Creating Branches for Hits
150 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
152 sprintf(branchname,"%sHits",GetName());
153 branch = TreeH()->GetBranch(branchname);
155 Info("MakeBranch","Branch %s is already in tree.",GetName());
158 branch = TreeH()->Branch(branchname,&fHits,kBufferSize);
159 Info("MakeBranch","Making Branch %s for hits \n",branchname);
162 //Creating Branches for Digits
163 if (TreeD() && cD ) {
164 // one branch for digits per chamber
165 if (fDigits == 0x0) {
166 fDigits = new TObjArray(AliMUONConstants::NCh());
167 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
168 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
171 if (fNdigits == 0x0) {
172 fNdigits = new Int_t[AliMUONConstants::NCh()];
173 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
174 fNdigits[iDetectionPlane]=0;
177 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
178 sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
180 branch = TreeD()->GetBranch(branchname);
182 Info("MakeBranch","Branch %s is already in tree.",GetName());
185 TClonesArray * digits = Digits(iDetectionPlane,0);
186 branch = TreeD()->Branch(branchname, &digits, kBufferSize);
187 Info("MakeBranch","Making Branch %s for digits in detection plane %d\n",branchname,iDetectionPlane+1);
191 if (TreeR() && cRC ) {
192 // one branch for raw clusters per tracking detection plane
195 if (fRawClusters == 0x0) {
196 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
197 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
198 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
202 if (fNrawclusters == 0x0) {
203 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
204 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
209 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
210 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
212 branch = TreeR()->GetBranch(branchname);
214 Info("MakeBranch","Branch %s is already in tree.",GetName());
217 branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize);
218 Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1);
222 if (TreeR() && cGLT ) {
224 // one branch for global trigger
226 sprintf(branchname,"%sGlobalTrigger",GetName());
229 if (fGlobalTrigger == 0x0) {
230 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
233 branch = TreeR()->GetBranch(branchname);
235 Info("MakeBranch","Branch %s is already in tree.",GetName());
238 branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize);
239 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
242 // one branch for local trigger
244 sprintf(branchname,"%sLocalTrigger",GetName());
247 if (fLocalTrigger == 0x0) {
248 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
251 branch = TreeR()->GetBranch(branchname);
253 Info("MakeBranch","Branch %s is already in tree.",GetName());
256 branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize);
257 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
260 if (TreeR() && cRT ) {
261 Info("MakeBranch","Making Branch for TreeT is not yet ready. \n");
263 if (TreeR() && cRP ) {
264 Info("MakeBranch","Making Branch for TreeP is not yet ready. \n");
268 //____________________________________________________________________________
269 void AliMUONData::ResetDigits()
272 // Reset number of digits and the digits array for this detector
274 if (fDigits == 0x0) return;
275 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
276 if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear();
277 if (fNdigits) fNdigits[i]=0;
280 //______________________________________________________________________________
281 void AliMUONData::ResetHits()
283 // Reset number of clusters and the cluster array for this detector
285 if (fHits) fHits->Clear();
287 //_______________________________________________________________________________
288 void AliMUONData::ResetRawClusters()
290 // Reset number of raw clusters and the raw clust array for this detector
292 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
293 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
294 if (fNrawclusters) fNrawclusters[i]=0;
297 //_______________________________________________________________________________
298 void AliMUONData::ResetTrigger()
300 // Reset Local and Global Trigger
302 if (fGlobalTrigger) fGlobalTrigger->Clear();
304 if (fLocalTrigger) fLocalTrigger->Clear();
306 //_____________________________________________________________________________
307 void AliMUONData::SetTreeAddress(Option_t* option)
309 const char *cH = strstr(option,"H");
310 const char *cD = strstr(option,"D"); // Digits branches in TreeD
311 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
312 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
313 // const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
314 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
316 // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree.
318 TBranch * branch = 0x0;
321 // Branch address for hit tree
322 if ( TreeH() && cH ) {
323 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
326 if (TreeH() && fHits && cH) {
327 sprintf(branchname,"%sHits",GetName());
328 branch = TreeH()->GetBranch(branchname);
330 Info("SetTreeAddress","(%s) Setting for Hits",GetName());
331 branch->SetAddress(&fHits);
333 else { //can be invoked before branch creation
334 Warning("SetTreeAddress","(%s) Failed for Hits. Can not find branch in tree.",GetName());
339 // Branch address for digit tree
340 if ( TreeD() && cD) {
341 if (fDigits == 0x0) {
342 fDigits = new TObjArray(AliMUONConstants::NCh());
343 fNdigits= new Int_t[AliMUONConstants::NCh()];
344 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
345 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i);
351 if (TreeD() && fDigits && cD) {
352 for (int i=0; i<AliMUONConstants::NCh(); i++) {
353 sprintf(branchname,"%sDigits%d",GetName(),i+1);
354 branch = TreeD()->GetBranch(branchname);
355 TClonesArray * digits = Digits(i,0);
356 if (branch) branch->SetAddress( &digits );
357 else Warning("SetTreeAddress","(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i);
362 // Branch address for rawclusters, globaltrigger and local trigger tree
364 if (fRawClusters == 0x0 && cRC) {
365 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
366 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
367 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
368 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
372 if (fLocalTrigger == 0x0 && cGLT) {
373 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
375 if (fGlobalTrigger== 0x0 && cGLT) {
376 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
380 if ( TreeR() && fRawClusters && cRC) {
381 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
382 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
384 branch = TreeR()->GetBranch(branchname);
385 if (branch) branch->SetAddress(&((*fRawClusters)[i]));
386 else Warning("SetTreeAddress","(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i);
390 if ( TreeR() && fLocalTrigger && cGLT) {
391 sprintf(branchname,"%sLocalTrigger",GetName());
392 branch = TreeR()->GetBranch(branchname);
393 if (branch) branch->SetAddress(&fLocalTrigger);
394 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
396 if ( TreeR() && fGlobalTrigger && cGLT) {
397 sprintf(branchname,"%sGlobalTrigger",GetName());
398 branch = TreeR()->GetBranch(branchname);
399 if (branch) branch->SetAddress(&fGlobalTrigger);
400 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
403 //_____________________________________________________________________________