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
21 fRawClusters = 0x0; //One event in TreeR/RawclusterBranch per tracking detection plane
22 fGlobalTrigger = 0x0; //! List of Global Trigger 1st event in TreeR/GlobalTriggerBranch
23 fLocalTrigger = 0x0; //! List of Local Trigger, 1st event in TreeR/LocalTriggerBranch
26 //_____________________________________________________________________________
27 AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
31 fHits = new TClonesArray("AliMUONHit",1000);
33 fDigits = new TObjArray(AliMUONConstants::NCh());
34 fNdigits = new Int_t[AliMUONConstants::NCh()];
35 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
36 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
37 fNdigits[iDetectionPlane]=0;
39 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
40 fNrawclusters = new Int_t[AliMUONConstants::NTrackingCh()];
41 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NTrackingCh();iDetectionPlane++) {
42 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),iDetectionPlane);
43 fNrawclusters[iDetectionPlane]=0;
45 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
47 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
51 //_____________________________________________________________________________
52 AliMUONData::AliMUONData(const AliMUONData& rMUONData):TNamed(rMUONData)
54 // Dummy copy constructor
57 //_____________________________________________________________________________
58 AliMUONData::~AliMUONData()
69 fRawClusters->Delete();
73 fGlobalTrigger->Delete();
74 delete fGlobalTrigger;
77 fLocalTrigger->Delete();
82 //_____________________________________________________________________________
83 void AliMUONData::AddDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
86 // Add a MUON digit to the list of Digits of the detection plane id
88 TClonesArray &ldigits = * ( (TClonesArray*) fDigits->At(id) );
89 new(ldigits[fNdigits[id]++]) AliMUONDigit(tracks,charges,digits);
91 //_____________________________________________________________________________
92 void AliMUONData::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
94 Int_t *pairUnlike, Int_t *pairLike)
96 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
97 TClonesArray &globalTrigger = *fGlobalTrigger;
98 new(globalTrigger[fNglobaltrigger++])
99 AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
101 //_____________________________________________________________________________
102 void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
103 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
104 Float_t tof, Float_t momentum, Float_t theta,
105 Float_t phi, Float_t length, Float_t destep)
107 TClonesArray &lhits = *fHits;
108 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
110 tof, momentum, theta,
111 phi, length, destep);
113 //____________________________________________________________________________
114 void AliMUONData::AddLocalTrigger(Int_t *localtr)
116 // add a MUON Local Trigger to the list
117 TClonesArray &localTrigger = *fLocalTrigger;
118 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(localtr);
120 //_____________________________________________________________________________
121 void AliMUONData::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
124 // Add a MUON rawcluster to the list in the detection plane id
126 TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id));
127 new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c);
129 //_____________________________________________________________________________
131 //___________________________________________
132 void AliMUONData::MakeBranch(Option_t* option)
135 // Create Tree branches for the MUON.
137 const Int_t kBufferSize = 4000;
140 const char *cH = strstr(option,"H");
141 const char *cD = strstr(option,"D"); // Digits branches in TreeD
142 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
143 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
144 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
145 const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
147 TBranch * branch = 0x0;
149 // Creating Branches for Hits
151 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
153 sprintf(branchname,"%sHits",GetName());
154 branch = TreeH()->GetBranch(branchname);
156 Info("MakeBranch","Branch %s is already in tree.",GetName());
159 branch = TreeH()->Branch(branchname,&fHits,kBufferSize);
160 Info("MakeBranch","Making Branch %s for hits \n",branchname);
163 //Creating Branches for Digits
164 if (TreeD() && cD ) {
165 // one branch for digits per chamber
166 if (fDigits == 0x0) {
167 fDigits = new TObjArray(AliMUONConstants::NCh());
168 fNdigits = new Int_t[AliMUONConstants::NCh()];
169 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
170 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
171 fNdigits[iDetectionPlane]=0;
174 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
175 sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
177 branch = TreeD()->GetBranch(branchname);
179 Info("MakeBranch","Branch %s is already in tree.",GetName());
182 branch = TreeD()->Branch(branchname, &((*fDigits)[iDetectionPlane]),kBufferSize);
183 Info("MakeBranch","Making Branch %s for digits in detection plane %d\n",branchname,iDetectionPlane+1);
187 if (TreeR() && cRC ) {
188 // one branch for raw clusters per tracking detection plane
191 if (fRawClusters == 0x0) {
192 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
193 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
194 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
195 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
200 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
201 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
203 branch = TreeR()->GetBranch(branchname);
205 Info("MakeBranch","Branch %s is already in tree.",GetName());
208 branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize);
209 Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1);
213 if (TreeR() && cGLT ) {
215 // one branch for global trigger
217 sprintf(branchname,"%sGlobalTrigger",GetName());
220 if (fGlobalTrigger == 0x0) {
221 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
224 branch = TreeR()->GetBranch(branchname);
226 Info("MakeBranch","Branch %s is already in tree.",GetName());
229 branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize);
230 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
233 // one branch for local trigger
235 sprintf(branchname,"%sLocalTrigger",GetName());
238 if (fLocalTrigger == 0x0) {
239 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
242 branch = TreeR()->GetBranch(branchname);
244 Info("MakeBranch","Branch %s is already in tree.",GetName());
247 branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize);
248 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
251 if (TreeR() && cRT ) {
252 Info("MakeBranch","Making Branch for TreeT is not yet ready. \n");
254 if (TreeR() && cRP ) {
255 Info("MakeBranch","Making Branch for TreeP is not yet ready. \n");
259 //____________________________________________________________________________
260 void AliMUONData::ResetDigits()
263 // Reset number of digits and the digits array for this detector
265 if (fDigits == 0x0) return;
266 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
267 if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear();
268 if (fNdigits) fNdigits[i]=0;
271 //______________________________________________________________________________
272 void AliMUONData::ResetHits()
274 // Reset number of clusters and the cluster array for this detector
276 if (fHits) fHits->Clear();
278 //_______________________________________________________________________________
279 void AliMUONData::ResetRawClusters()
281 // Reset number of raw clusters and the raw clust array for this detector
283 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
284 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
285 if (fNrawclusters) fNrawclusters[i]=0;
288 //_______________________________________________________________________________
289 void AliMUONData::ResetTrigger()
291 // Reset Local and Global Trigger
293 if (fGlobalTrigger) fGlobalTrigger->Clear();
295 if (fLocalTrigger) fLocalTrigger->Clear();
297 //_____________________________________________________________________________
298 void AliMUONData::SetTreeAddress()
300 // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree.
302 TBranch * branch = 0x0;
305 // Branch address for hit tree
307 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
310 if (TreeH() && fHits) {
311 sprintf(branchname,"%sHits",GetName());
312 branch = TreeH()->GetBranch(branchname);
314 Info("SetTreeAddress","(%s) Setting for Hits",GetName());
315 branch->SetAddress(&fHits);
317 else { //can be invoked before branch creation
318 Warning("SetTreeAddress","(%s) Failed for Hits. Can not find branch in tree.",GetName());
323 // Branch address for digit tree
325 if (fDigits == 0x0) {
326 fDigits = new TObjArray(AliMUONConstants::NCh());
327 fNdigits= new Int_t[AliMUONConstants::NCh()];
328 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
329 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i);
335 if (TreeD() && fDigits) {
336 for (int i=0; i<AliMUONConstants::NCh(); i++) {
337 sprintf(branchname,"%sDigits%d",GetName(),i+1);
338 branch = TreeD()->GetBranch(branchname);
339 if (branch) branch->SetAddress(&((*fDigits)[i]));
340 else Warning("SetTreeAddress","(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i);
345 // Branch address for rawclusters, globaltrigger and local trigger tree
347 if (fRawClusters == 0x0) {
348 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
349 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
350 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
351 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
355 if (fLocalTrigger == 0x0) {
356 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
358 if (fGlobalTrigger== 0x0) {
359 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
363 if ( TreeR() && fRawClusters ) {
364 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
365 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
367 branch = TreeR()->GetBranch(branchname);
368 if (branch) branch->SetAddress(&((*fRawClusters)[i]));
369 else Warning("SetTreeAddress","(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i);
373 if ( TreeR() && fLocalTrigger ) {
374 sprintf(branchname,"%sLocalTrigger",GetName());
375 branch = TreeR()->GetBranch(branchname);
376 if (branch) branch->SetAddress(&fLocalTrigger);
377 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
379 if ( TreeR() && fGlobalTrigger) {
380 sprintf(branchname,"%sGlobalTrigger",GetName());
381 branch = TreeR()->GetBranch(branchname);
382 if (branch) branch->SetAddress(&fGlobalTrigger);
383 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
386 //_____________________________________________________________________________