]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - MUON/AliMUONData.cxx
Suppressed warning from fkSegmentation->PadByPosition(...)
[u/mrichter/AliRoot.git] / MUON / AliMUONData.cxx
... / ...
CommitLineData
1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id$ */
17// AliMUONData classes
18// Class containing MUON data: hits, digits, rawclusters, globaltrigger, localtrigger, etc ..
19// The classe makes the lik between the MUON data lists and the event trees from loaders
20// Gines Martinez, Subatech, September 2003
21//
22
23//AliRoot include
24//#include "AliRun.h"
25//#include "AliMC.h"
26#include "AliMUONConstants.h"
27#include "AliMUONData.h"
28#include "AliMUONDigit.h"
29#include "AliMUONHit.h"
30#include "AliMUONLocalTrigger.h"
31#include "AliMUONGlobalTrigger.h"
32#include "AliMUONRawCluster.h"
33#include "AliMUONTrack.h"
34#include "AliMUONTriggerTrack.h"
35#include "AliLog.h"
36
37ClassImp(AliMUONData)
38
39//_____________________________________________________________________________
40 AliMUONData::AliMUONData():
41 TNamed(),
42 fLoader(0x0),
43 fHits(0x0),
44 fDigits(0x0),
45 fSDigits(0x0),
46 fRawClusters(0x0),
47 fGlobalTrigger(0x0),
48 fLocalTrigger(0x0),
49 fRecTracks(0x0),
50 fRecTriggerTracks(0x0),
51 fNhits(0),
52 fNdigits(0x0),
53 fNSdigits(0x0),
54 fNrawclusters(0x0),
55 fNglobaltrigger(0),
56 fNlocaltrigger(0),
57 fNrectracks(0),
58 fNrectriggertracks(0),
59 fSplitLevel(0)
60{
61 // Default constructor
62}
63//_____________________________________________________________________________
64AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
65 TNamed(name,title),
66 fLoader(loader),
67 fHits(0x0),
68 fDigits(0x0),
69 fSDigits(0x0),
70 fRawClusters(0x0),
71 fGlobalTrigger(0x0),
72 fLocalTrigger(0x0),
73 fRecTracks(0x0),
74 fRecTriggerTracks(0x0),
75 fNhits(0),
76 fNdigits(0x0),
77 fNSdigits(0x0),
78 fNrawclusters(0x0),
79 fNglobaltrigger(0),
80 fNlocaltrigger(0),
81 fNrectracks(0),
82 fNrectriggertracks(0),
83 fSplitLevel(0)
84{
85 // Constructor for AliMUONData
86
87// fHits = new TClonesArray("AliMUONHit",1000);
88// fNhits = 0;
89// fDigits = new TObjArray(AliMUONConstants::NCh());
90// fNdigits = new Int_t[AliMUONConstants::NCh()];
91// for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
92// fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane);
93// fNdigits[iDetectionPlane]=0;
94// }
95// fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
96// fNrawclusters = new Int_t[AliMUONConstants::NTrackingCh()];
97// for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NTrackingCh();iDetectionPlane++) {
98// fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),iDetectionPlane);
99// fNrawclusters[iDetectionPlane]=0;
100// }
101// fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
102// fNglobaltrigger =0;
103// fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
104// fNlocaltrigger = 0;
105// fRecTracks = new TClonesArray("AliMUONTrack", 100);
106// fNrectracks = 0; // really needed or GetEntriesFast sufficient ????
107
108
109}
110
111//_____________________________________________________________________________
112AliMUONData::AliMUONData(const AliMUONData& rMUONData):TNamed(rMUONData)
113{
114// Protected copy constructor
115
116 AliFatal("Not implemented.");
117}
118
119//_____________________________________________________________________________
120AliMUONData::~AliMUONData()
121{
122 // Destructor for AliMUONData
123 if (fHits) {
124 fHits->Delete();
125 delete fHits;
126 }
127 if (fDigits) {
128 fDigits->Delete();
129 delete fDigits;
130 }
131 if (fSDigits) {
132 fSDigits->Delete();
133 delete fSDigits;
134 }
135 if (fRawClusters) {
136 fRawClusters->Delete();
137 delete fRawClusters;
138 }
139 if (fGlobalTrigger){
140 fGlobalTrigger->Delete();
141 delete fGlobalTrigger;
142 }
143 if (fLocalTrigger){
144 fLocalTrigger->Delete();
145 delete fLocalTrigger;
146 }
147 if (fRecTracks){
148 fRecTracks->Delete();
149 delete fRecTracks;
150 }
151 if (fRecTriggerTracks){
152 fRecTriggerTracks->Delete();
153 delete fRecTriggerTracks;
154 }
155 //detructor
156}
157
158//_____________________________________________________________________________
159AliMUONData& AliMUONData::operator=(const AliMUONData& rhs)
160{
161// Protected assignement operator
162
163 if (this == &rhs) return *this;
164
165 AliFatal("Not implemented.");
166
167 return *this;
168}
169
170
171//_____________________________________________________________________________
172void AliMUONData::AddDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
173{
174 //
175 // Add a MUON digit to the list of Digits of the detection plane id
176 //
177 TClonesArray &ldigits = * Digits(id) ;
178 new(ldigits[fNdigits[id]++]) AliMUONDigit(tracks,charges,digits);
179}
180//_____________________________________________________________________________
181void AliMUONData::AddDigit(Int_t id, const AliMUONDigit& digit)
182{
183 //
184 // Add a MUON digit to the list of Digits of the detection plane id
185 //
186 TClonesArray &ldigits = * Digits(id) ;
187 new(ldigits[fNdigits[id]++]) AliMUONDigit(digit);
188}
189//_____________________________________________________________________________
190void AliMUONData::AddSDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *sdigits)
191{
192 //
193 // Add a MUON Sdigit to the list of SDigits of the detection plane id
194 //
195 TClonesArray &lSdigits = * SDigits(id) ;
196 new(lSdigits[fNSdigits[id]++]) AliMUONDigit(tracks,charges,sdigits);
197}
198//_____________________________________________________________________________
199void AliMUONData::AddSDigit(Int_t id, const AliMUONDigit& Sdigit)
200{
201 //
202 // Add a MUON Sdigit to the list of SDigits of the detection plane id
203 //
204 TClonesArray &lSdigits = * SDigits(id) ;
205 new(lSdigits[fNSdigits[id]++]) AliMUONDigit(Sdigit);
206}
207//_____________________________________________________________________________
208void AliMUONData::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
209 Int_t *singleUndef,
210 Int_t *pairUnlike, Int_t *pairLike)
211{
212 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
213
214 TClonesArray &globalTrigger = *fGlobalTrigger;
215 new(globalTrigger[fNglobaltrigger++])
216 AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
217}
218//_____________________________________________________________________________
219void AliMUONData::AddGlobalTrigger(const AliMUONGlobalTrigger& trigger )
220{
221 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !);
222 TClonesArray &globalTrigger = *fGlobalTrigger;
223 new(globalTrigger[fNglobaltrigger++]) AliMUONGlobalTrigger(trigger);
224}
225//____________________________________________________________________________
226void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
227 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
228 Float_t tof, Float_t momentum, Float_t theta,
229 Float_t phi, Float_t length, Float_t destep,
230 Float_t Xref,Float_t Yref,Float_t Zref)
231{
232 // Add new hit to the hit list
233 TClonesArray &lhits = *fHits;
234 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
235 idpart, X, Y, Z,
236 tof, momentum, theta,
237 phi, length, destep,
238 Xref,Yref,Zref);
239}
240//____________________________________________________________________________
241void AliMUONData::AddHit2(Int_t fIshunt, Int_t track, Int_t detElemId,
242 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
243 Float_t tof, Float_t momentum, Float_t theta,
244 Float_t phi, Float_t length, Float_t destep,
245 Float_t Xref,Float_t Yref,Float_t Zref)
246{
247 // Add new hit to the hit list
248 TClonesArray &lhits = *fHits;
249 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, detElemId,
250 idpart, X, Y, Z,
251 tof, momentum, theta,
252 phi, length, destep,
253 Xref,Yref,Zref, true);
254}
255//____________________________________________________________________________
256void AliMUONData::AddLocalTrigger(const Int_t *localtr, const TArrayI& digits)
257{
258 // add a MUON Local Trigger to the list
259 TClonesArray &localTrigger = *fLocalTrigger;
260 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(localtr, digits);
261}
262//____________________________________________________________________________
263void AliMUONData::AddLocalTrigger(const AliMUONLocalTrigger& trigger)
264{
265 // add a MUON Local Trigger to the list
266 TClonesArray &localTrigger = *fLocalTrigger;
267 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(trigger);
268}
269//_____________________________________________________________________________
270void AliMUONData::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
271{
272 //
273 // Add a MUON rawcluster to the list in the detection plane id
274 //
275 TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id));
276 new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c);
277}
278//_____________________________________________________________________________
279void AliMUONData::AddRecTrack(const AliMUONTrack& track)
280{
281 //
282 // Add a MUON rectrack
283 //
284 TClonesArray &lrectracks = *fRecTracks;
285 new(lrectracks[fNrectracks++]) AliMUONTrack(track);
286 // printf("TTTTTT %d ,\n",((AliMUONTrack*)fRecTracks->At(fNrectracks-1))->GetNTrackHits());
287}
288//_____________________________________________________________________________
289void AliMUONData::AddRecTriggerTrack(const AliMUONTriggerTrack& triggertrack)
290{
291 //
292 // Add a MUON triggerrectrack
293 //
294 TClonesArray &lrectriggertracks = *fRecTriggerTracks;
295 new(lrectriggertracks[fNrectriggertracks++]) AliMUONTriggerTrack(triggertrack);
296 // printf("TTTTTT %d ,\n",((AliMUONTrack*)fRecTracks->At(fNrectracks-1))->GetNTrackHits());
297}
298
299//____________________________________________________________________________
300TClonesArray* AliMUONData::Digits(Int_t DetectionPlane)
301{
302 //Getting List of Digits
303 if (fDigits)
304 return ( (TClonesArray*) fDigits->At(DetectionPlane) );
305 else
306 return NULL;
307}
308//____________________________________________________________________________
309TClonesArray* AliMUONData::SDigits(Int_t DetectionPlane)
310{
311 //Getting List of SDigits
312 if (fSDigits)
313 return ( (TClonesArray*) fSDigits->At(DetectionPlane) );
314 else
315 return NULL;
316}
317//____________________________________________________________________________
318Bool_t AliMUONData::IsRawClusterBranchesInTree()
319{
320 // Checking if there are RawCluster Branches In TreeR
321 if (TreeR()==0x0) {
322 AliError("No treeR in memory");
323 return kFALSE;
324 }
325 else {
326 char branchname[30];
327 sprintf(branchname,"%sRawClusters1",GetName());
328 TBranch * branch = 0x0;
329 branch = TreeR()->GetBranch(branchname);
330 if (branch) return kTRUE;
331 else return kFALSE;
332 }
333}
334//____________________________________________________________________________
335Bool_t AliMUONData::IsDigitsBranchesInTree()
336{
337 // Checking if there are RawCluster Branches In TreeR
338 if (TreeD()==0x0) {
339 AliError("No treeD in memory");
340 return kFALSE;
341 }
342 else {
343 char branchname[30];
344 sprintf(branchname,"%sDigits1",GetName());
345 TBranch * branch = 0x0;
346 branch = TreeD()->GetBranch(branchname);
347 if (branch) return kTRUE;
348 else return kFALSE;
349 }
350}
351//____________________________________________________________________________
352Bool_t AliMUONData::IsTriggerBranchesInTree()
353{
354 // Checking if there are Trigger Branches In TreeR
355 if (TreeR()==0x0) {
356 AliError("No treeR in memory");
357 return kFALSE;
358 }
359 else {
360 char branchname[30];
361 sprintf(branchname,"%sLocalTrigger",GetName());
362 TBranch * branch = 0x0;
363 branch = TreeR()->GetBranch(branchname);
364 if (branch) return kTRUE;
365 else return kFALSE;
366 }
367}
368//____________________________________________________________________________
369Bool_t AliMUONData::IsTriggerBranchesInTreeD()
370{
371 // Checking if there are Trigger Branches In TreeR
372 if (TreeD()==0x0) {
373 AliError("No treeD in memory");
374 return kFALSE;
375 }
376 else {
377 char branchname[30];
378 sprintf(branchname,"%sLocalTrigger",GetName());
379 TBranch * branch = 0x0;
380 branch = TreeD()->GetBranch(branchname);
381 if (branch) return kTRUE;
382 else return kFALSE;
383 }
384}
385
386//____________________________________________________________________________
387Bool_t AliMUONData::IsTrackBranchesInTree()
388{
389 // Checking if there are Track Branches In TreeT
390 if (TreeT()==0x0) {
391 AliError("No treeT in memory");
392 return kFALSE;
393 }
394 else {
395 char branchname[30];
396 sprintf(branchname,"%sTrack",GetName());
397 TBranch * branch = 0x0;
398 branch = TreeT()->GetBranch(branchname);
399 if (branch) return kTRUE;
400 else return kFALSE;
401 }
402}
403//____________________________________________________________________________
404Bool_t AliMUONData::IsTriggerTrackBranchesInTree()
405{
406 // Checking if there are TriggerTrack Branches In TreeT
407 if (TreeT()==0x0) {
408 AliError("No treeT in memory");
409 return kFALSE;
410 }
411 else {
412 char branchname[30];
413 sprintf(branchname,"%sTriggerTrack",GetName());
414 TBranch * branch = 0x0;
415 branch = TreeT()->GetBranch(branchname);
416 if (branch) return kTRUE;
417 else return kFALSE;
418 }
419}
420//____________________________________________________________________________
421void AliMUONData::Fill(Option_t* option)
422{
423 // Method to fill the trees
424 const char *cH = strstr(option,"H");
425 const char *cD = strstr(option,"D"); // Digits branches in TreeD
426 const char *cS = strstr(option,"S"); // SDigits branches in TreeS
427 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
428 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
429 const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR
430 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
431 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
432
433 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
434
435 char branchname[30];
436 TBranch * branch = 0x0;
437
438 // Filling TreeH
439 if ( TreeH() && cH ) {
440 TreeH()->Fill();
441 }
442
443 // Filling TreeD
444
445 if ( TreeD() && cD ) {
446 if ( IsTriggerBranchesInTreeD() ) {
447 for (int i=0; i<AliMUONConstants::NCh(); i++) {
448 sprintf(branchname,"%sDigits%d",GetName(),i+1);
449 branch = TreeD()->GetBranch(branchname);
450 branch->Fill();
451 }
452 } else
453 TreeD()->Fill();
454 }
455
456 // filling trigger
457 if ( TreeD() && cGLT ) {
458 if ( IsDigitsBranchesInTree() ) {
459 sprintf(branchname,"%sLocalTrigger",GetName());
460 branch = TreeD()->GetBranch(branchname);
461 branch->Fill();
462 sprintf(branchname,"%sGlobalTrigger",GetName());
463 branch = TreeD()->GetBranch(branchname);
464 branch->Fill();
465 } else
466 TreeD()->Fill();
467 }
468
469 // Filling TreeS
470 if ( TreeS() && cS) {
471 TreeS()->Fill();
472 }
473
474 //
475 // filling rawclusters
476 if ( TreeR() && cRC ) {
477 if ( IsTriggerBranchesInTree() ) {
478 // Branch per branch filling
479 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
480 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
481 branch = TreeR()->GetBranch(branchname);
482 branch->Fill();
483 }
484 }
485 else TreeR()->Fill();
486 }
487
488 //
489 // filling trigger
490 if ( TreeR() && cTC) {
491 if (IsRawClusterBranchesInTree()) {
492 // Branch per branch filling
493 sprintf(branchname,"%sLocalTrigger",GetName());
494 branch = TreeR()->GetBranch(branchname);
495 branch->Fill();
496 sprintf(branchname,"%sGlobalTrigger",GetName());
497 branch = TreeR()->GetBranch(branchname);
498 branch->Fill();
499 }
500 else TreeR()->Fill();
501 }
502 //
503 // filling tracks
504 if ( TreeT() && cRT ) {
505 if (IsTriggerTrackBranchesInTree()) {
506 sprintf(branchname,"%sTrack",GetName());
507 branch = TreeT()->GetBranch(branchname);
508 branch->Fill();
509 }
510 else TreeT()->Fill();
511 }
512 // filling trigger tracks
513 if ( TreeT() && cRL ) {
514 if (IsTrackBranchesInTree()) {
515 sprintf(branchname,"%sTriggerTrack",GetName());
516 branch = TreeT()->GetBranch(branchname);
517 branch->Fill();
518 }
519 else TreeT()->Fill();
520 }
521// if ( TreeT() && cRL ) {
522// sprintf(branchname,"%sTrackTrig",GetName());
523// TreeT()->Fill();
524// }
525}
526//_____________________________________________________________________________
527void AliMUONData::MakeBranch(Option_t* option)
528{
529 //
530 // Create Tree branches for the MUON.
531 //
532 const Int_t kBufferSize = 4000;
533 char branchname[30];
534
535
536 const char *cH = strstr(option,"H");
537 const char *cD = strstr(option,"D"); // Digits branches in TreeD
538 const char *cS = strstr(option,"S"); // Digits branches in TreeS
539 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
540 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
541 const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR
542 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
543 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
544 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
545
546 TBranch * branch = 0x0;
547
548 // Creating Branches for Hits
549 if (TreeH() && cH) {
550
551 if (fHits == 0x0) {
552 fHits = new TClonesArray("AliMUONHit",1000);
553// if (gAlice->GetMCApp())
554// gAlice->GetMCApp()->AddHitList (fHits);
555 }
556
557 fNhits = 0;
558 sprintf(branchname,"%sHits",GetName());
559 branch = TreeH()->GetBranch(branchname);
560 if (branch) {
561 AliInfo(Form("MakeBranch","Branch %s is already in tree.",GetName()));
562 return ;
563 }
564 branch = TreeH()->Branch(branchname,&fHits,kBufferSize);
565 //Info("MakeBranch","Making Branch %s for hits \n",branchname);
566 }
567
568 //Creating Branches for Digits
569 if (TreeD() && cD ) {
570 // one branch for digits per chamber
571 if (fDigits == 0x0) {
572 fDigits = new TObjArray(AliMUONConstants::NCh());
573 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
574 TClonesArray * tca = new TClonesArray("AliMUONDigit",10000);
575 tca->SetOwner();
576 fDigits->AddAt(tca,iDetectionPlane);
577 }
578 }
579 if (fNdigits == 0x0) {
580 fNdigits = new Int_t[AliMUONConstants::NCh()];
581 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
582 fNdigits[iDetectionPlane]=0;
583 }
584 }
585 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
586 sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
587 branch = 0x0;
588 branch = TreeD()->GetBranch(branchname);
589 if (branch) {
590 AliInfo(Form("Branch %s is already in tree.",GetName()));
591 return;
592 }
593 TClonesArray * digits = Digits(iDetectionPlane);
594 branch = TreeD()->Branch(branchname, &digits, kBufferSize,1);
595 //Info("MakeBranch","Making Branch %s for digits in detection plane %d\n",branchname,iDetectionPlane+1);
596 }
597 }
598
599 if (TreeD() && cGLT ) {
600 //
601 // one branch for global trigger
602 //
603 sprintf(branchname,"%sGlobalTrigger",GetName());
604 branch = 0x0;
605
606 if (fGlobalTrigger == 0x0) {
607 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger");
608 fNglobaltrigger = 0;
609 }
610 branch = TreeD()->GetBranch(branchname);
611 if (branch) {
612 AliInfo(Form("Branch GlobalTrigger is already in treeD."));
613 return ;
614 }
615 branch = TreeD()->Branch(branchname, &fGlobalTrigger, kBufferSize);
616 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
617
618 //
619 // one branch for local trigger
620 //
621 sprintf(branchname,"%sLocalTrigger",GetName());
622 branch = 0x0;
623
624 if (fLocalTrigger == 0x0) {
625 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
626 fNlocaltrigger = 0;
627 }
628 branch = TreeD()->GetBranch(branchname);
629 if (branch) {
630 AliInfo(Form("Branch LocalTrigger is already in treeD."));
631 return;
632 }
633 branch = TreeD()->Branch(branchname, &fLocalTrigger, kBufferSize);
634 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
635 }
636
637
638 //Creating Branches for SDigits
639 if (TreeS() && cS ) {
640 // one branch for Sdigits per chamber
641 if (fSDigits == 0x0) {
642 fSDigits = new TObjArray(AliMUONConstants::NCh());
643 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
644 TClonesArray * tca = new TClonesArray("AliMUONDigit",10000);
645 tca->SetOwner();
646 fSDigits->AddAt(tca,iDetectionPlane);
647 }
648 }
649 if (fNSdigits == 0x0) {
650 fNSdigits = new Int_t[AliMUONConstants::NCh()];
651 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
652 fNSdigits[iDetectionPlane]=0;
653 }
654 }
655 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
656 sprintf(branchname,"%sSDigits%d",GetName(),iDetectionPlane+1);
657 branch = 0x0;
658 branch = TreeS()->GetBranch(branchname);
659 if (branch) {
660 AliInfo(Form("Branch %s is already in tree.",GetName()));
661 return;
662 }
663 TClonesArray * sdigits = SDigits(iDetectionPlane);
664 branch = TreeS()->Branch(branchname, &sdigits, kBufferSize,1);
665 //Info("MakeBranch","Making Branch %s for sdigits in detection plane %d\n",branchname,iDetectionPlane+1);
666 }
667 }
668
669 if (TreeR() && cRC ) {
670 // one branch for raw clusters per tracking detection plane
671 //
672 Int_t i;
673 if (fRawClusters == 0x0) {
674 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
675 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
676 TClonesArray * tca = new TClonesArray("AliMUONRawCluster",1000);
677 tca->SetOwner();
678 fRawClusters->AddAt(tca,i);
679 }
680 }
681
682 if (fNrawclusters == 0x0) {
683 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
684 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
685 fNrawclusters[i]=0;
686 }
687 }
688
689 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
690 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
691 branch = 0x0;
692 branch = TreeR()->GetBranch(branchname);
693 if (branch) {
694 AliInfo(Form("Branch %s is already in tree.",GetName()));
695 return;
696 }
697 branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize);
698 //Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1);
699 }
700 }
701
702 if (TreeR() && cTC ) {
703 //
704 // one branch for global trigger
705 //
706 sprintf(branchname,"%sGlobalTrigger",GetName());
707 branch = 0x0;
708
709 if (fGlobalTrigger == 0x0) {
710 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger");
711 fNglobaltrigger = 0;
712 }
713 branch = TreeR()->GetBranch(branchname);
714 if (branch) {
715 AliInfo(Form("Branch GlobalTrigger is already in treeR."));
716 return ;
717 }
718 branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize);
719 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
720
721 //
722 // one branch for local trigger
723 //
724 sprintf(branchname,"%sLocalTrigger",GetName());
725 branch = 0x0;
726
727 if (fLocalTrigger == 0x0) {
728 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
729 fNlocaltrigger = 0;
730 }
731 branch = TreeR()->GetBranch(branchname);
732 if (branch) {
733 AliInfo(Form("Branch LocalTrigger is already in treeR."));
734 return;
735 }
736 branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize);
737 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
738 }
739
740 if (TreeT() && cRT ) {
741 if (fRecTracks == 0x0) fRecTracks = new TClonesArray("AliMUONTrack",100);
742 fNrectracks = 0;
743 sprintf(branchname,"%sTrack",GetName());
744 branch = TreeT()->GetBranch(branchname);
745 if (branch) {
746 AliInfo(Form("Branch %s is already in tree.",GetName()));
747 return ;
748 }
749 branch = TreeT()->Branch(branchname,&fRecTracks,kBufferSize);
750 //Info("MakeBranch","Making Branch %s for tracks \n",branchname);
751 }
752// trigger tracks
753 if (TreeT() && cRL ) {
754 if (fRecTriggerTracks == 0x0) fRecTriggerTracks = new TClonesArray("AliMUONTriggerTrack",100);
755 fNrectriggertracks = 0;
756 sprintf(branchname,"%sTriggerTrack",GetName());
757 branch = TreeT()->GetBranch(branchname);
758 if (branch) {
759 AliInfo(Form("Branch %s is already in tree.",GetName()));
760 return ;
761 }
762 branch = TreeT()->Branch(branchname,&fRecTriggerTracks,kBufferSize);
763 //Info("MakeBranch","Making Branch %s for trigger tracks \n",branchname);
764 }
765}
766//____________________________________________________________________________
767TClonesArray* AliMUONData::RawClusters(Int_t DetectionPlane)
768{
769 // Getting Raw Clusters
770 if (fRawClusters)
771 return ( (TClonesArray*) fRawClusters->At(DetectionPlane) );
772 else
773 return NULL;
774}
775//____________________________________________________________________________
776TClonesArray* AliMUONData::LocalTrigger()
777{
778 // Getting Local Trigger
779 if (fLocalTrigger)
780 return ( (TClonesArray*) fLocalTrigger );
781 else
782 return NULL;
783}
784//____________________________________________________________________________
785TClonesArray* AliMUONData::GlobalTrigger()
786{
787 // Getting Global Trigger
788 if (fGlobalTrigger)
789 return ( (TClonesArray*) fGlobalTrigger );
790 else
791 return NULL;
792}
793//____________________________________________________________________________
794void AliMUONData::ResetDigits()
795{
796 //
797 // Reset number of digits and the digits array for this detector
798 //
799 if (fDigits == 0x0) return;
800 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
801 if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear();
802 if (fNdigits) fNdigits[i]=0;
803 }
804}
805//____________________________________________________________________________
806void AliMUONData::ResetSDigits()
807{
808 //
809 // Reset number of Sdigits and the Sdigits array for this detector
810 //
811 if (fSDigits == 0x0) return;
812 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
813 if ((*fSDigits)[i]) ((TClonesArray*)fSDigits->At(i))->Clear();
814 if (fNSdigits) fNSdigits[i]=0;
815 }
816}
817//______________________________________________________________________________
818void AliMUONData::ResetHits()
819{
820 // Reset number of clusters and the cluster array for this detector
821 fNhits = 0;
822 if (fHits) fHits->Clear();
823}
824//_______________________________________________________________________________
825void AliMUONData::ResetRawClusters()
826{
827 // Reset number of raw clusters and the raw clust array for this detector
828 //
829 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
830 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
831 if (fNrawclusters) fNrawclusters[i]=0;
832 }
833}
834//_______________________________________________________________________________
835void AliMUONData::ResetTrigger()
836{
837 // Reset Local and Global Trigger
838 fNglobaltrigger = 0;
839 if (fGlobalTrigger) fGlobalTrigger->Clear();
840 fNlocaltrigger = 0;
841 if (fLocalTrigger) fLocalTrigger->Clear();
842}
843//____________________________________________________________________________
844void AliMUONData::ResetRecTracks()
845{
846 // Reset tracks information
847 fNrectracks = 0;
848 if (fRecTracks) fRecTracks->Delete(); // necessary to delete in case of memory allocation
849}
850//____________________________________________________________________________
851void AliMUONData::ResetRecTriggerTracks()
852{
853 // Reset tracks information
854 fNrectriggertracks = 0;
855 if (fRecTriggerTracks) fRecTriggerTracks->Delete(); // necessary to delete in case of memory allocation
856}
857//_____________________________________________________________________________
858void AliMUONData::SetTreeAddress(Option_t* option)
859{
860 //Setting Addresses to the events trees
861 const char *cH = strstr(option,"H");
862 const char *cD = strstr(option,"D"); // Digits branches in TreeD
863 const char *cS = strstr(option,"S"); // SDigits branches in TreeS
864 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
865 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
866 const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR
867 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
868 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
869 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
870
871 // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree.
872 char branchname[30];
873 TBranch * branch = 0x0;
874
875 //
876 // Branch address for hit tree
877 if ( TreeH() && cH ) {
878 if (fHits == 0x0) {
879 fHits = new TClonesArray("AliMUONHit",1000);
880 // if (gAlice->GetMCApp())
881 // gAlice->GetMCApp()->AddHitList (fHits); Moved to AliMUON
882 }
883 fNhits =0;
884 }
885 if (TreeH() && fHits && cH) {
886 sprintf(branchname,"%sHits",GetName());
887 branch = TreeH()->GetBranch(branchname);
888 if (branch) {
889 // Info("SetTreeAddress","(%s) Setting for Hits",GetName());
890 branch->SetAddress(&fHits);
891 }
892 else { //can be invoked before branch creation
893 AliWarning(Form("(%s) Failed for Hits. Can not find branch in tree.",GetName()));
894 }
895 }
896
897 //
898 // Branch address for digit tree
899 if ( TreeD() ) {
900 if (fDigits == 0x0 && cD) {
901 fDigits = new TObjArray(AliMUONConstants::NCh());
902 fNdigits= new Int_t[AliMUONConstants::NCh()];
903 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
904 fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i);
905 fNdigits[i]=0;
906 }
907 }
908 if (fLocalTrigger == 0x0 && cGLT) {
909 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
910 }
911 if (fGlobalTrigger== 0x0 && cGLT) {
912 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
913 }
914 }
915
916 if (TreeD() && fDigits && cD) {
917 for (int i=0; i<AliMUONConstants::NCh(); i++) {
918 sprintf(branchname,"%sDigits%d",GetName(),i+1);
919 if (fDigits) {
920 branch = TreeD()->GetBranch(branchname);
921 TClonesArray * digits = Digits(i);
922 if (branch) {
923 branch->SetAddress( &digits );
924 }
925 else AliWarning(Form("(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i));
926 }
927 }
928 }
929 if ( TreeD() && fLocalTrigger && cGLT) {
930 sprintf(branchname,"%sLocalTrigger",GetName());
931 branch = TreeD()->GetBranch(branchname);
932 if (branch) branch->SetAddress(&fLocalTrigger);
933 else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeD.",GetName()));
934 }
935 if ( TreeD() && fGlobalTrigger && cGLT) {
936 sprintf(branchname,"%sGlobalTrigger",GetName());
937 branch = TreeD()->GetBranch(branchname);
938 if (branch) branch->SetAddress(&fGlobalTrigger);
939 else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeD.",GetName()));
940 }
941
942 //
943 // Branch address for Sdigit tree
944 if ( TreeS() && cS) {
945 if (fSDigits == 0x0) {
946 fSDigits = new TObjArray(AliMUONConstants::NCh());
947 fNSdigits= new Int_t[AliMUONConstants::NCh()];
948 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
949 fSDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i);
950 fNSdigits[i]=0;
951 }
952 }
953 }
954
955 if (TreeS() && fSDigits && cS) {
956 for (int i=0; i<AliMUONConstants::NCh(); i++) {
957 sprintf(branchname,"%sSDigits%d",GetName(),i+1);
958 if (fSDigits) {
959 branch = TreeS()->GetBranch(branchname);
960 TClonesArray * sdigits = SDigits(i);
961 if (branch) branch->SetAddress( &sdigits );
962 else AliWarning(Form("(%s) Failed for SDigits Detection plane %d. Can not find branch in tree.",GetName(),i));
963 }
964 }
965 }
966
967 //
968 // Branch address for rawclusters, globaltrigger and local trigger tree
969 if (TreeR() ) {
970 if (fRawClusters == 0x0 && cRC) {
971 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
972 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
973 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
974 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
975 fNrawclusters[i]=0;
976 }
977 }
978 if (fLocalTrigger == 0x0 && cTC) {
979 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
980 }
981 if (fGlobalTrigger== 0x0 && cTC) {
982 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
983 }
984
985 }
986 if ( TreeR() && fRawClusters && cRC && !strstr(cRC,"RCC")) {
987 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
988 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
989 if (fRawClusters) {
990 branch = TreeR()->GetBranch(branchname);
991 if (branch) branch->SetAddress( &((*fRawClusters)[i]) );
992 else AliWarning(Form("(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i));
993 }
994 }
995 }
996 if ( TreeR() && fLocalTrigger && cTC) {
997 sprintf(branchname,"%sLocalTrigger",GetName());
998 branch = TreeR()->GetBranch(branchname);
999 if (branch) branch->SetAddress(&fLocalTrigger);
1000 else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeR.",GetName()));
1001 }
1002 if ( TreeR() && fGlobalTrigger && cTC) {
1003 sprintf(branchname,"%sGlobalTrigger",GetName());
1004 branch = TreeR()->GetBranch(branchname);
1005 if (branch) branch->SetAddress(&fGlobalTrigger);
1006 else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeR.",GetName()));
1007 }
1008
1009 if ( TreeT() ) {
1010 if (fRecTracks == 0x0 && cRT) {
1011 fRecTracks = new TClonesArray("AliMUONTrack",100);
1012 }
1013
1014 }
1015 if ( TreeT() && fRecTracks && cRT ) {
1016 sprintf(branchname,"%sTrack",GetName());
1017 branch = TreeT()->GetBranch(branchname);
1018 if (branch) branch->SetAddress(&fRecTracks);
1019 else AliWarning(Form("(%s) Failed for Tracks. Can not find branch in tree.",GetName()));
1020 }
1021// trigger tracks
1022 if ( TreeT() ) {
1023 if (fRecTriggerTracks == 0x0 && cRL) {
1024 fRecTriggerTracks = new TClonesArray("AliMUONTriggerTrack",100);
1025 }
1026
1027 }
1028 if ( TreeT() && fRecTriggerTracks && cRL ) {
1029 sprintf(branchname,"%sTriggerTrack",GetName());
1030 branch = TreeT()->GetBranch(branchname);
1031 if (branch) branch->SetAddress(&fRecTriggerTracks);
1032 else AliWarning(Form("(%s) Failed for Trigger Tracks. Can not find branch in tree.",GetName()));
1033 }
1034
1035
1036}
1037//_____________________________________________________________________________