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