power problem in AliMUONv1 patched. StepManagerNew commented. Waiting for better...
[u/mrichter/AliRoot.git] / MUON / AliMUONData.cxx
CommitLineData
6309cf6e 1
6309cf6e 2//Root includes
1a1cdff8 3#include "TNamed.h"
6309cf6e 4//AliRoot includes
1a1cdff8 5#include "AliLoader.h"
6#include "AliMUONConstants.h"
6309cf6e 7#include "AliMUONData.h"
8#include "AliMUONDigit.h"
9#include "AliMUONHit.h"
10#include "AliMUONLocalTrigger.h"
11#include "AliMUONGlobalTrigger.h"
12#include "AliMUONRawCluster.h"
dcd2690d 13#include "AliMUONTrack.h"
6309cf6e 14
15ClassImp(AliMUONData)
16
17//_____________________________________________________________________________
18AliMUONData::AliMUONData():TNamed()
19{
20 fLoader = 0x0;
21 fHits = 0x0; // One event in treeH per primary track
22 fDigits = 0x0; // One event in treeH per detection plane
ce3f5e87 23 fNdigits = 0x0;
6309cf6e 24 fRawClusters = 0x0; //One event in TreeR/RawclusterBranch per tracking detection plane
25 fGlobalTrigger = 0x0; //! List of Global Trigger 1st event in TreeR/GlobalTriggerBranch
dcd2690d 26 fLocalTrigger = 0x0; //! List of Local Trigger, 1st event in TreeR/LocalTriggerBranch
27 fRecTracks = 0x0;
6309cf6e 28//default constructor
29}
30//_____________________________________________________________________________
31AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
32 TNamed(name,title)
33{
34 fLoader = loader;
35 fHits = new TClonesArray("AliMUONHit",1000);
36 fNhits = 0;
37 fDigits = new TObjArray(AliMUONConstants::NCh());
38 fNdigits = new Int_t[AliMUONConstants::NCh()];
39 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
40 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
41 fNdigits[iDetectionPlane]=0;
42 }
43 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
44 fNrawclusters = new Int_t[AliMUONConstants::NTrackingCh()];
45 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NTrackingCh();iDetectionPlane++) {
46 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),iDetectionPlane);
47 fNrawclusters[iDetectionPlane]=0;
48 }
49 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
50 fNglobaltrigger =0;
51 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
52 fNlocaltrigger = 0;
dcd2690d 53 fRecTracks = new TClonesArray("AliMUONTrack", 10);
54 fNrectracks = 0; // really needed or GetEntriesFast sufficient ????
6309cf6e 55 //default constructor
56}
57//_____________________________________________________________________________
58AliMUONData::AliMUONData(const AliMUONData& rMUONData):TNamed(rMUONData)
59{
60 // Dummy copy constructor
61 ;
62}
63//_____________________________________________________________________________
64AliMUONData::~AliMUONData()
65{
66 if (fHits) {
67 fHits->Delete();
68 delete fHits;
69 }
70 if (fDigits) {
71 fDigits->Delete();
72 delete fDigits;
73 }
74 if (fRawClusters) {
75 fRawClusters->Delete();
76 delete fRawClusters;
77 }
78 if (fGlobalTrigger){
79 fGlobalTrigger->Delete();
80 delete fGlobalTrigger;
81 }
82 if (fLocalTrigger){
83 fLocalTrigger->Delete();
84 delete fLocalTrigger;
85 }
dcd2690d 86 if (fRecTracks){
87 fRecTracks->Delete();
88 delete fRecTracks;
89 }
6309cf6e 90 //detructor
91}
92//_____________________________________________________________________________
93void AliMUONData::AddDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
94{
95 //
96 // Add a MUON digit to the list of Digits of the detection plane id
97 //
1a1cdff8 98 TClonesArray &ldigits = * Digits(id) ;
6309cf6e 99 new(ldigits[fNdigits[id]++]) AliMUONDigit(tracks,charges,digits);
100}
101//_____________________________________________________________________________
102void AliMUONData::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
103 Int_t *singleUndef,
104 Int_t *pairUnlike, Int_t *pairLike)
105{
106 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
107 TClonesArray &globalTrigger = *fGlobalTrigger;
108 new(globalTrigger[fNglobaltrigger++])
109 AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
110}
111//_____________________________________________________________________________
112void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
113 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
114 Float_t tof, Float_t momentum, Float_t theta,
115 Float_t phi, Float_t length, Float_t destep)
116{
117 TClonesArray &lhits = *fHits;
118 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
119 idpart, X, Y, Z,
120 tof, momentum, theta,
121 phi, length, destep);
122}
123//____________________________________________________________________________
124void AliMUONData::AddLocalTrigger(Int_t *localtr)
125{
126 // add a MUON Local Trigger to the list
127 TClonesArray &localTrigger = *fLocalTrigger;
128 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(localtr);
129}
130//_____________________________________________________________________________
131void AliMUONData::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
132{
133 //
134 // Add a MUON rawcluster to the list in the detection plane id
135 //
136 TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id));
137 new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c);
138}
dcd2690d 139//_____________________________________________________________________________
140void AliMUONData::AddRecTrack(const AliMUONTrack& track)
141{
142 //
143 // Add a MUON rectrack
144 //
145 TClonesArray &lrectracks = *fRecTracks;
146 new(lrectracks[fNrectracks++]) AliMUONTrack(track);
147}
ce3f5e87 148//____________________________________________________________________________
1a1cdff8 149void AliMUONData::Fill(Option_t* option)
150{
151 // Method to fill the trees
152 const char *cH = strstr(option,"H");
153 const char *cD = strstr(option,"D"); // Digits branches in TreeD
154 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
155 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
156 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
157 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
158
159 char branchname[30];
160 TBranch * branch = 0x0;
161
162 //
163 // Filling TreeH
164 if ( TreeH() && cH ) {
165 TreeH()->Fill();
166 }
167 //
168 // Filling TreeD
169 if ( TreeD() && cD) {
170 TreeD()->Fill();
171 }
172 //
173 // filling rawclusters
174 if ( TreeR() && cRC) {
175 TreeR()->Fill();
176 // for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
177// sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
178// branch = TreeR()->GetBranch(branchname);
179// branch->Fill();
180// }
181 }
182 //
183 // filling trigger
184 if ( TreeR() && cGLT) {
185 sprintf(branchname,"%sLocalTrigger",GetName());
186 branch = TreeR()->GetBranch(branchname);
187 branch->Fill();
188 sprintf(branchname,"%sGlobalTrigger",GetName());
189 branch = TreeR()->GetBranch(branchname);
190 branch->Fill();
191 }
192 //
193 // filling tracks
194 if ( TreeT() && cRT ) {
195 sprintf(branchname,"%sTrack",GetName());
196 branch = TreeT()->GetBranch(branchname);
197 branch->Fill();
198 }
199}
200//_____________________________________________________________________________
6309cf6e 201void AliMUONData::MakeBranch(Option_t* option)
202{
203 //
204 // Create Tree branches for the MUON.
205 //
206 const Int_t kBufferSize = 4000;
207 char branchname[30];
208
209 const char *cH = strstr(option,"H");
210 const char *cD = strstr(option,"D"); // Digits branches in TreeD
211 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
212 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
213 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
214 const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
215
216 TBranch * branch = 0x0;
217
218 // Creating Branches for Hits
219 if (TreeH() && cH) {
220 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
221 fNhits = 0;
222 sprintf(branchname,"%sHits",GetName());
223 branch = TreeH()->GetBranch(branchname);
224 if (branch) {
225 Info("MakeBranch","Branch %s is already in tree.",GetName());
226 return ;
227 }
228 branch = TreeH()->Branch(branchname,&fHits,kBufferSize);
229 Info("MakeBranch","Making Branch %s for hits \n",branchname);
230 }
231
232 //Creating Branches for Digits
233 if (TreeD() && cD ) {
234 // one branch for digits per chamber
235 if (fDigits == 0x0) {
ce3f5e87 236 fDigits = new TObjArray(AliMUONConstants::NCh());
6309cf6e 237 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
238 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
ce3f5e87 239 }
240 }
241 if (fNdigits == 0x0) {
242 fNdigits = new Int_t[AliMUONConstants::NCh()];
243 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
6309cf6e 244 fNdigits[iDetectionPlane]=0;
245 }
246 }
247 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
248 sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
249 branch = 0x0;
250 branch = TreeD()->GetBranch(branchname);
251 if (branch) {
252 Info("MakeBranch","Branch %s is already in tree.",GetName());
253 return;
254 }
1a1cdff8 255 TClonesArray * digits = Digits(iDetectionPlane);
ce3f5e87 256 branch = TreeD()->Branch(branchname, &digits, kBufferSize);
6309cf6e 257 Info("MakeBranch","Making Branch %s for digits in detection plane %d\n",branchname,iDetectionPlane+1);
258 }
259 }
260
261 if (TreeR() && cRC ) {
262 // one branch for raw clusters per tracking detection plane
263 //
264 Int_t i;
265 if (fRawClusters == 0x0) {
266 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
6309cf6e 267 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
268 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
ce3f5e87 269 }
270 }
271
272 if (fNrawclusters == 0x0) {
273 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
274 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
6309cf6e 275 fNrawclusters[i]=0;
276 }
277 }
278
279 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
280 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
281 branch = 0x0;
282 branch = TreeR()->GetBranch(branchname);
283 if (branch) {
284 Info("MakeBranch","Branch %s is already in tree.",GetName());
285 return;
286 }
287 branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize);
288 Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1);
289 }
290 }
291
292 if (TreeR() && cGLT ) {
293 //
294 // one branch for global trigger
295 //
296 sprintf(branchname,"%sGlobalTrigger",GetName());
297 branch = 0x0;
298
299 if (fGlobalTrigger == 0x0) {
300 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
301 fNglobaltrigger = 0;
302 }
303 branch = TreeR()->GetBranch(branchname);
304 if (branch) {
305 Info("MakeBranch","Branch %s is already in tree.",GetName());
306 return ;
307 }
308 branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize);
309 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
310
311 //
312 // one branch for local trigger
313 //
314 sprintf(branchname,"%sLocalTrigger",GetName());
315 branch = 0x0;
316
317 if (fLocalTrigger == 0x0) {
318 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
319 fNlocaltrigger = 0;
320 }
321 branch = TreeR()->GetBranch(branchname);
322 if (branch) {
323 Info("MakeBranch","Branch %s is already in tree.",GetName());
324 return;
325 }
326 branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize);
327 Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
328 }
329
dcd2690d 330 if (TreeT() && cRT ) {
331 if (fRecTracks == 0x0) fRecTracks = new TClonesArray("AliMUONTrack",10);
332 fNrectracks = 0;
333 sprintf(branchname,"%sTrack",GetName());
334 branch = TreeT()->GetBranch(branchname);
335 if (branch) {
336 Info("MakeBranch","Branch %s is already in tree.",GetName());
337 return ;
338 }
339 branch = TreeT()->Branch(branchname,&fRecTracks,kBufferSize);
340 Info("MakeBranch","Making Branch %s for tracks \n",branchname);
341 }
342
343 if (TreeP() && cRP ) {
6309cf6e 344 Info("MakeBranch","Making Branch for TreeP is not yet ready. \n");
345 }
346}
347
348//____________________________________________________________________________
349void AliMUONData::ResetDigits()
350{
351 //
352 // Reset number of digits and the digits array for this detector
353 //
354 if (fDigits == 0x0) return;
355 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
356 if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear();
357 if (fNdigits) fNdigits[i]=0;
358 }
359}
360//______________________________________________________________________________
361void AliMUONData::ResetHits()
362{
363 // Reset number of clusters and the cluster array for this detector
364 fNhits = 0;
365 if (fHits) fHits->Clear();
366}
367//_______________________________________________________________________________
368void AliMUONData::ResetRawClusters()
369{
370 // Reset number of raw clusters and the raw clust array for this detector
371 //
372 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
373 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
374 if (fNrawclusters) fNrawclusters[i]=0;
375 }
376}
377//_______________________________________________________________________________
378void AliMUONData::ResetTrigger()
379{
380 // Reset Local and Global Trigger
381 fNglobaltrigger = 0;
382 if (fGlobalTrigger) fGlobalTrigger->Clear();
383 fNlocaltrigger = 0;
384 if (fLocalTrigger) fLocalTrigger->Clear();
385}
dcd2690d 386//____________________________________________________________________________
387void AliMUONData::ResetRecTracks()
388{
389 // Reset tracks information
390 fNrectracks = 0;
391 if (fRecTracks) fRecTracks->Clear();
392}
6309cf6e 393//_____________________________________________________________________________
ce3f5e87 394void AliMUONData::SetTreeAddress(Option_t* option)
6309cf6e 395{
ce3f5e87 396 const char *cH = strstr(option,"H");
397 const char *cD = strstr(option,"D"); // Digits branches in TreeD
398 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
399 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
dcd2690d 400 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
ce3f5e87 401 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
402
6309cf6e 403 // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree.
404 char branchname[30];
405 TBranch * branch = 0x0;
406
407 //
408 // Branch address for hit tree
ce3f5e87 409 if ( TreeH() && cH ) {
6309cf6e 410 if (fHits == 0x0) fHits = new TClonesArray("AliMUONHit",1000);
411 fNhits =0;
412 }
ce3f5e87 413 if (TreeH() && fHits && cH) {
6309cf6e 414 sprintf(branchname,"%sHits",GetName());
415 branch = TreeH()->GetBranch(branchname);
416 if (branch) {
417 Info("SetTreeAddress","(%s) Setting for Hits",GetName());
418 branch->SetAddress(&fHits);
419 }
420 else { //can be invoked before branch creation
421 Warning("SetTreeAddress","(%s) Failed for Hits. Can not find branch in tree.",GetName());
422 }
423 }
424
425 //
426 // Branch address for digit tree
ce3f5e87 427 if ( TreeD() && cD) {
6309cf6e 428 if (fDigits == 0x0) {
429 fDigits = new TObjArray(AliMUONConstants::NCh());
430 fNdigits= new Int_t[AliMUONConstants::NCh()];
431 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
432 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i);
433 fNdigits[i]=0;
434 }
435 }
436 }
437
ce3f5e87 438 if (TreeD() && fDigits && cD) {
6309cf6e 439 for (int i=0; i<AliMUONConstants::NCh(); i++) {
440 sprintf(branchname,"%sDigits%d",GetName(),i+1);
441 branch = TreeD()->GetBranch(branchname);
1a1cdff8 442 TClonesArray * digits = Digits(i);
ce3f5e87 443 if (branch) branch->SetAddress( &digits );
6309cf6e 444 else Warning("SetTreeAddress","(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i);
445 }
446 }
447
448 //
449 // Branch address for rawclusters, globaltrigger and local trigger tree
450 if (TreeR() ) {
ce3f5e87 451 if (fRawClusters == 0x0 && cRC) {
6309cf6e 452 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
453 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
454 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
455 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
456 fNrawclusters[i]=0;
457 }
458 }
ce3f5e87 459 if (fLocalTrigger == 0x0 && cGLT) {
6309cf6e 460 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
461 }
ce3f5e87 462 if (fGlobalTrigger== 0x0 && cGLT) {
6309cf6e 463 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
464 }
465
466 }
ce3f5e87 467 if ( TreeR() && fRawClusters && cRC) {
6309cf6e 468 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
469 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
470 if (fRawClusters) {
471 branch = TreeR()->GetBranch(branchname);
472 if (branch) branch->SetAddress(&((*fRawClusters)[i]));
473 else Warning("SetTreeAddress","(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i);
474 }
475 }
476 }
ce3f5e87 477 if ( TreeR() && fLocalTrigger && cGLT) {
6309cf6e 478 sprintf(branchname,"%sLocalTrigger",GetName());
479 branch = TreeR()->GetBranch(branchname);
480 if (branch) branch->SetAddress(&fLocalTrigger);
481 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
482 }
ce3f5e87 483 if ( TreeR() && fGlobalTrigger && cGLT) {
6309cf6e 484 sprintf(branchname,"%sGlobalTrigger",GetName());
485 branch = TreeR()->GetBranch(branchname);
486 if (branch) branch->SetAddress(&fGlobalTrigger);
487 else Warning("SetTreeAddress","(%s) Failed for LocalTrigger. Can not find branch in tree.",GetName());
488 }
dcd2690d 489
490 if ( TreeT() && fRecTracks && cRT ) {
491 sprintf(branchname,"%sTrack",GetName());
492 branch = TreeT()->GetBranch(branchname);
493 if (branch) branch->SetAddress(&fRecTracks);
494 else Warning("SetTreeAddress","(%s) Failed for Tracks. Can not find branch in tree.",GetName());
495 }
6309cf6e 496}
497//_____________________________________________________________________________