]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONData.cxx
Generation of new path in St345 for svmap (Ivana, 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"
8c343c7c 35#include "AliLog.h"
30178c30 36
6309cf6e 37ClassImp(AliMUONData)
38
39//_____________________________________________________________________________
1017e5bf 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)
6309cf6e 60{
9140dcef 61 // Default constructor
6309cf6e 62}
63//_____________________________________________________________________________
64AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
1017e5bf 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)
6309cf6e 84{
9140dcef 85 // Constructor for AliMUONData
1017e5bf 86
b1c7d777 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;
374ebd7d 105// fRecTracks = new TClonesArray("AliMUONTrack", 100);
b1c7d777 106// fNrectracks = 0; // really needed or GetEntriesFast sufficient ????
107
108
6309cf6e 109}
e3ea1889 110
6309cf6e 111//_____________________________________________________________________________
112AliMUONData::AliMUONData(const AliMUONData& rMUONData):TNamed(rMUONData)
113{
e3ea1889 114// Protected copy constructor
115
8c343c7c 116 AliFatal("Not implemented.");
6309cf6e 117}
e3ea1889 118
6309cf6e 119//_____________________________________________________________________________
120AliMUONData::~AliMUONData()
121{
9140dcef 122 // Destructor for AliMUONData
6309cf6e 123 if (fHits) {
124 fHits->Delete();
125 delete fHits;
126 }
127 if (fDigits) {
128 fDigits->Delete();
129 delete fDigits;
130 }
d1775029 131 if (fSDigits) {
132 fSDigits->Delete();
133 delete fSDigits;
134 }
6309cf6e 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 }
dcd2690d 147 if (fRecTracks){
148 fRecTracks->Delete();
149 delete fRecTracks;
150 }
276c44b7 151 if (fRecTriggerTracks){
152 fRecTriggerTracks->Delete();
153 delete fRecTriggerTracks;
154 }
6309cf6e 155 //detructor
156}
e3ea1889 157
158//_____________________________________________________________________________
159AliMUONData& AliMUONData::operator=(const AliMUONData& rhs)
160{
161// Protected assignement operator
162
163 if (this == &rhs) return *this;
164
8c343c7c 165 AliFatal("Not implemented.");
e3ea1889 166
167 return *this;
168}
169
170
6309cf6e 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 //
1a1cdff8 177 TClonesArray &ldigits = * Digits(id) ;
6309cf6e 178 new(ldigits[fNdigits[id]++]) AliMUONDigit(tracks,charges,digits);
179}
180//_____________________________________________________________________________
61adb9bd 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//_____________________________________________________________________________
30178c30 190void AliMUONData::AddSDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *sdigits)
d1775029 191{
192 //
193 // Add a MUON Sdigit to the list of SDigits of the detection plane id
194 //
195 TClonesArray &lSdigits = * SDigits(id) ;
30178c30 196 new(lSdigits[fNSdigits[id]++]) AliMUONDigit(tracks,charges,sdigits);
d1775029 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//_____________________________________________________________________________
6309cf6e 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 !)
ce3e25a8 213
6309cf6e 214 TClonesArray &globalTrigger = *fGlobalTrigger;
215 new(globalTrigger[fNglobaltrigger++])
216 AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
217}
218//_____________________________________________________________________________
61adb9bd 219void AliMUONData::AddGlobalTrigger(const AliMUONGlobalTrigger& trigger )
220{
ce3e25a8 221 // add a MUON Global Trigger to the list (only one GlobalTrigger per event !);
61adb9bd 222 TClonesArray &globalTrigger = *fGlobalTrigger;
223 new(globalTrigger[fNglobaltrigger++]) AliMUONGlobalTrigger(trigger);
224}
d59b2ec3 225//____________________________________________________________________________
6309cf6e 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,
d59b2ec3 229 Float_t phi, Float_t length, Float_t destep,
230 Float_t Xref,Float_t Yref,Float_t Zref)
6309cf6e 231{
d59b2ec3 232 // Add new hit to the hit list
6309cf6e 233 TClonesArray &lhits = *fHits;
234 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber,
235 idpart, X, Y, Z,
236 tof, momentum, theta,
d59b2ec3 237 phi, length, destep,
8690a0a6 238 Xref,Yref,Zref);
6309cf6e 239}
240//____________________________________________________________________________
d59b2ec3 241void AliMUONData::AddHit2(Int_t fIshunt, Int_t track, Int_t detElemId,
1391e633 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{
9140dcef 247 // Add new hit to the hit list
1391e633 248 TClonesArray &lhits = *fHits;
d59b2ec3 249 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, detElemId,
1391e633 250 idpart, X, Y, Z,
251 tof, momentum, theta,
252 phi, length, destep,
d59b2ec3 253 Xref,Yref,Zref, true);
61adb9bd 254}
255//____________________________________________________________________________
6309cf6e 256void AliMUONData::AddLocalTrigger(Int_t *localtr)
257{
258 // add a MUON Local Trigger to the list
259 TClonesArray &localTrigger = *fLocalTrigger;
260 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(localtr);
261}
61adb9bd 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}
6309cf6e 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}
dcd2690d 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);
61adb9bd 286 // printf("TTTTTT %d ,\n",((AliMUONTrack*)fRecTracks->At(fNrectracks-1))->GetNTrackHits());
dcd2690d 287}
276c44b7 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
ce3f5e87 299//____________________________________________________________________________
1eccde20 300TClonesArray* AliMUONData::Digits(Int_t DetectionPlane)
301{
9140dcef 302 //Getting List of Digits
1eccde20 303 if (fDigits)
304 return ( (TClonesArray*) fDigits->At(DetectionPlane) );
305 else
306 return NULL;
307}
308//____________________________________________________________________________
d1775029 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//____________________________________________________________________________
c1d45bdf 318Bool_t AliMUONData::IsRawClusterBranchesInTree()
319{
9140dcef 320 // Checking if there are RawCluster Branches In TreeR
c1d45bdf 321 if (TreeR()==0x0) {
8c343c7c 322 AliError("No treeR in memory");
c1d45bdf 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//____________________________________________________________________________
ce3e25a8 335Bool_t AliMUONData::IsDigitsBranchesInTree()
336{
337 // Checking if there are RawCluster Branches In TreeR
338 if (TreeD()==0x0) {
8c343c7c 339 AliError("No treeD in memory");
ce3e25a8 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//____________________________________________________________________________
c1d45bdf 352Bool_t AliMUONData::IsTriggerBranchesInTree()
353{
9140dcef 354 // Checking if there are Trigger Branches In TreeR
c1d45bdf 355 if (TreeR()==0x0) {
8c343c7c 356 AliError("No treeR in memory");
c1d45bdf 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}
ce3e25a8 368//____________________________________________________________________________
369Bool_t AliMUONData::IsTriggerBranchesInTreeD()
370{
371 // Checking if there are Trigger Branches In TreeR
372 if (TreeD()==0x0) {
8c343c7c 373 AliError("No treeD in memory");
ce3e25a8 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
c1d45bdf 386//____________________________________________________________________________
276c44b7 387Bool_t AliMUONData::IsTrackBranchesInTree()
388{
389 // Checking if there are Track Branches In TreeT
390 if (TreeT()==0x0) {
8c343c7c 391 AliError("No treeT in memory");
276c44b7 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) {
8c343c7c 408 AliError("No treeT in memory");
276c44b7 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//____________________________________________________________________________
1a1cdff8 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
d1775029 426 const char *cS = strstr(option,"S"); // SDigits branches in TreeS
1a1cdff8 427 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
ce3e25a8 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
1a1cdff8 430 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
ce3e25a8 431 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
61adb9bd 432
1a1cdff8 433 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
434
435 char branchname[30];
436 TBranch * branch = 0x0;
437
1a1cdff8 438 // Filling TreeH
439 if ( TreeH() && cH ) {
440 TreeH()->Fill();
441 }
ce3e25a8 442
1a1cdff8 443 // Filling TreeD
ce3e25a8 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();
1a1cdff8 454 }
ce3e25a8 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
d1775029 469 // Filling TreeS
470 if ( TreeS() && cS) {
471 TreeS()->Fill();
472 }
c1d45bdf 473
1a1cdff8 474 //
475 // filling rawclusters
c1d45bdf 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();
1a1cdff8 486 }
c1d45bdf 487
1a1cdff8 488 //
489 // filling trigger
ce3e25a8 490 if ( TreeR() && cTC) {
346357f4 491 if (IsRawClusterBranchesInTree()) {
c1d45bdf 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();
1a1cdff8 501 }
502 //
503 // filling tracks
504 if ( TreeT() && cRT ) {
276c44b7 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();
1a1cdff8 520 }
276c44b7 521// if ( TreeT() && cRL ) {
61adb9bd 522// sprintf(branchname,"%sTrackTrig",GetName());
523// TreeT()->Fill();
524// }
1a1cdff8 525}
526//_____________________________________________________________________________
6309cf6e 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
276c44b7 535
6309cf6e 536 const char *cH = strstr(option,"H");
537 const char *cD = strstr(option,"D"); // Digits branches in TreeD
d1775029 538 const char *cS = strstr(option,"S"); // Digits branches in TreeS
6309cf6e 539 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
ce3e25a8 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
6309cf6e 542 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
276c44b7 543 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
61adb9bd 544 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
276c44b7 545
6309cf6e 546 TBranch * branch = 0x0;
547
548 // Creating Branches for Hits
549 if (TreeH() && cH) {
1988766a 550
551 if (fHits == 0x0) {
552 fHits = new TClonesArray("AliMUONHit",1000);
307d9d04 553// if (gAlice->GetMCApp())
554// gAlice->GetMCApp()->AddHitList (fHits);
1988766a 555 }
556
6309cf6e 557 fNhits = 0;
558 sprintf(branchname,"%sHits",GetName());
559 branch = TreeH()->GetBranch(branchname);
560 if (branch) {
8c343c7c 561 AliInfo(Form("MakeBranch","Branch %s is already in tree.",GetName()));
6309cf6e 562 return ;
563 }
c6ce342a 564 branch = TreeH()->Branch(branchname,&fHits,kBufferSize);
cba99c31 565 //Info("MakeBranch","Making Branch %s for hits \n",branchname);
6309cf6e 566 }
567
568 //Creating Branches for Digits
569 if (TreeD() && cD ) {
570 // one branch for digits per chamber
571 if (fDigits == 0x0) {
ce3f5e87 572 fDigits = new TObjArray(AliMUONConstants::NCh());
6309cf6e 573 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
1017e5bf 574 TClonesArray * tca = new TClonesArray("AliMUONDigit",10000);
575 tca->SetOwner();
576 fDigits->AddAt(tca,iDetectionPlane);
ce3f5e87 577 }
578 }
579 if (fNdigits == 0x0) {
580 fNdigits = new Int_t[AliMUONConstants::NCh()];
581 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
6309cf6e 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) {
8c343c7c 590 AliInfo(Form("Branch %s is already in tree.",GetName()));
6309cf6e 591 return;
592 }
1a1cdff8 593 TClonesArray * digits = Digits(iDetectionPlane);
d652f85c 594 branch = TreeD()->Branch(branchname, &digits, kBufferSize,1);
cba99c31 595 //Info("MakeBranch","Making Branch %s for digits in detection plane %d\n",branchname,iDetectionPlane+1);
6309cf6e 596 }
597 }
ce3e25a8 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) {
8c343c7c 612 AliInfo(Form("Branch GlobalTrigger is already in treeD."));
ce3e25a8 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) {
8c343c7c 630 AliInfo(Form("Branch LocalTrigger is already in treeD."));
ce3e25a8 631 return;
632 }
633 branch = TreeD()->Branch(branchname, &fLocalTrigger, kBufferSize);
634 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
635 }
636
637
d1775029 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++) {
1017e5bf 644 TClonesArray * tca = new TClonesArray("AliMUONDigit",10000);
645 tca->SetOwner();
646 fSDigits->AddAt(tca,iDetectionPlane);
d1775029 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) {
8c343c7c 660 AliInfo(Form("Branch %s is already in tree.",GetName()));
d1775029 661 return;
662 }
30178c30 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);
d1775029 666 }
667 }
668
6309cf6e 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());
6309cf6e 675 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
1017e5bf 676 TClonesArray * tca = new TClonesArray("AliMUONRawCluster",1000);
677 tca->SetOwner();
678 fRawClusters->AddAt(tca,i);
ce3f5e87 679 }
680 }
681
682 if (fNrawclusters == 0x0) {
683 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
684 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
6309cf6e 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) {
8c343c7c 694 AliInfo(Form("Branch %s is already in tree.",GetName()));
6309cf6e 695 return;
696 }
c6ce342a 697 branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize);
cba99c31 698 //Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1);
6309cf6e 699 }
700 }
701
ce3e25a8 702 if (TreeR() && cTC ) {
6309cf6e 703 //
704 // one branch for global trigger
705 //
706 sprintf(branchname,"%sGlobalTrigger",GetName());
707 branch = 0x0;
708
709 if (fGlobalTrigger == 0x0) {
c6ce342a 710 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger");
6309cf6e 711 fNglobaltrigger = 0;
712 }
713 branch = TreeR()->GetBranch(branchname);
714 if (branch) {
8c343c7c 715 AliInfo(Form("Branch GlobalTrigger is already in treeR."));
6309cf6e 716 return ;
717 }
c6ce342a 718 branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize);
cba99c31 719 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
6309cf6e 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) {
8c343c7c 733 AliInfo(Form("Branch LocalTrigger is already in treeR."));
6309cf6e 734 return;
735 }
c6ce342a 736 branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize);
cba99c31 737 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
6309cf6e 738 }
739
dcd2690d 740 if (TreeT() && cRT ) {
374ebd7d 741 if (fRecTracks == 0x0) fRecTracks = new TClonesArray("AliMUONTrack",100);
dcd2690d 742 fNrectracks = 0;
743 sprintf(branchname,"%sTrack",GetName());
744 branch = TreeT()->GetBranch(branchname);
745 if (branch) {
8c343c7c 746 AliInfo(Form("Branch %s is already in tree.",GetName()));
dcd2690d 747 return ;
748 }
749 branch = TreeT()->Branch(branchname,&fRecTracks,kBufferSize);
cba99c31 750 //Info("MakeBranch","Making Branch %s for tracks \n",branchname);
dcd2690d 751 }
276c44b7 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) {
8c343c7c 759 AliInfo(Form("Branch %s is already in tree.",GetName()));
276c44b7 760 return ;
761 }
762 branch = TreeT()->Branch(branchname,&fRecTriggerTracks,kBufferSize);
cba99c31 763 //Info("MakeBranch","Making Branch %s for trigger tracks \n",branchname);
276c44b7 764 }
6309cf6e 765}
1eccde20 766//____________________________________________________________________________
767TClonesArray* AliMUONData::RawClusters(Int_t DetectionPlane)
768{
9140dcef 769 // Getting Raw Clusters
1eccde20 770 if (fRawClusters)
771 return ( (TClonesArray*) fRawClusters->At(DetectionPlane) );
772 else
773 return NULL;
774}
6309cf6e 775//____________________________________________________________________________
276c44b7 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//____________________________________________________________________________
6309cf6e 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}
d1775029 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}
6309cf6e 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}
dcd2690d 843//____________________________________________________________________________
844void AliMUONData::ResetRecTracks()
845{
846 // Reset tracks information
847 fNrectracks = 0;
848 if (fRecTracks) fRecTracks->Clear();
849}
276c44b7 850//____________________________________________________________________________
851void AliMUONData::ResetRecTriggerTracks()
852{
853 // Reset tracks information
854 fNrectriggertracks = 0;
855 if (fRecTriggerTracks) fRecTriggerTracks->Clear();
856}
6309cf6e 857//_____________________________________________________________________________
ce3f5e87 858void AliMUONData::SetTreeAddress(Option_t* option)
6309cf6e 859{
9140dcef 860 //Setting Addresses to the events trees
ce3f5e87 861 const char *cH = strstr(option,"H");
862 const char *cD = strstr(option,"D"); // Digits branches in TreeD
d1775029 863 const char *cS = strstr(option,"S"); // SDigits branches in TreeS
ce3f5e87 864 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
ce3e25a8 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
dcd2690d 867 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
276c44b7 868 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
ce3f5e87 869 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
870
6309cf6e 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
ce3f5e87 877 if ( TreeH() && cH ) {
88cf591d 878 if (fHits == 0x0) {
879 fHits = new TClonesArray("AliMUONHit",1000);
d1775029 880 // if (gAlice->GetMCApp())
881 // gAlice->GetMCApp()->AddHitList (fHits); Moved to AliMUON
88cf591d 882 }
6309cf6e 883 fNhits =0;
884 }
ce3f5e87 885 if (TreeH() && fHits && cH) {
6309cf6e 886 sprintf(branchname,"%sHits",GetName());
887 branch = TreeH()->GetBranch(branchname);
888 if (branch) {
d652f85c 889 // Info("SetTreeAddress","(%s) Setting for Hits",GetName());
6309cf6e 890 branch->SetAddress(&fHits);
891 }
892 else { //can be invoked before branch creation
8c343c7c 893 AliWarning(Form("(%s) Failed for Hits. Can not find branch in tree.",GetName()));
6309cf6e 894 }
895 }
896
897 //
898 // Branch address for digit tree
95e68a13 899 if ( TreeD() ) {
900 if (fDigits == 0x0 && cD) {
6309cf6e 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 }
ce3e25a8 908 if (fLocalTrigger == 0x0 && cGLT) {
909 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
910 }
911 if (fGlobalTrigger== 0x0 && cGLT) {
912 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
913 }
6309cf6e 914 }
915
ce3f5e87 916 if (TreeD() && fDigits && cD) {
6309cf6e 917 for (int i=0; i<AliMUONConstants::NCh(); i++) {
918 sprintf(branchname,"%sDigits%d",GetName(),i+1);
d652f85c 919 if (fDigits) {
920 branch = TreeD()->GetBranch(branchname);
921 TClonesArray * digits = Digits(i);
d1775029 922 if (branch) {
923 branch->SetAddress( &digits );
924 }
8c343c7c 925 else AliWarning(Form("(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i));
d652f85c 926 }
6309cf6e 927 }
928 }
ce3e25a8 929 if ( TreeD() && fLocalTrigger && cGLT) {
930 sprintf(branchname,"%sLocalTrigger",GetName());
931 branch = TreeD()->GetBranch(branchname);
932 if (branch) branch->SetAddress(&fLocalTrigger);
8c343c7c 933 else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeD.",GetName()));
ce3e25a8 934 }
935 if ( TreeD() && fGlobalTrigger && cGLT) {
936 sprintf(branchname,"%sGlobalTrigger",GetName());
937 branch = TreeD()->GetBranch(branchname);
938 if (branch) branch->SetAddress(&fGlobalTrigger);
8c343c7c 939 else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeD.",GetName()));
ce3e25a8 940 }
941
d1775029 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);
30178c30 960 TClonesArray * sdigits = SDigits(i);
961 if (branch) branch->SetAddress( &sdigits );
8c343c7c 962 else AliWarning(Form("(%s) Failed for SDigits Detection plane %d. Can not find branch in tree.",GetName(),i));
d1775029 963 }
964 }
965 }
6309cf6e 966
967 //
968 // Branch address for rawclusters, globaltrigger and local trigger tree
969 if (TreeR() ) {
ce3f5e87 970 if (fRawClusters == 0x0 && cRC) {
6309cf6e 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 }
ce3e25a8 978 if (fLocalTrigger == 0x0 && cTC) {
6309cf6e 979 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
980 }
ce3e25a8 981 if (fGlobalTrigger== 0x0 && cTC) {
6309cf6e 982 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
983 }
984
985 }
ce3f5e87 986 if ( TreeR() && fRawClusters && cRC) {
6309cf6e 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);
d652f85c 991 if (branch) branch->SetAddress( &((*fRawClusters)[i]) );
8c343c7c 992 else AliWarning(Form("(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i));
6309cf6e 993 }
994 }
995 }
ce3e25a8 996 if ( TreeR() && fLocalTrigger && cTC) {
6309cf6e 997 sprintf(branchname,"%sLocalTrigger",GetName());
998 branch = TreeR()->GetBranch(branchname);
999 if (branch) branch->SetAddress(&fLocalTrigger);
8c343c7c 1000 else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeR.",GetName()));
6309cf6e 1001 }
ce3e25a8 1002 if ( TreeR() && fGlobalTrigger && cTC) {
6309cf6e 1003 sprintf(branchname,"%sGlobalTrigger",GetName());
1004 branch = TreeR()->GetBranch(branchname);
1005 if (branch) branch->SetAddress(&fGlobalTrigger);
8c343c7c 1006 else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeR.",GetName()));
6309cf6e 1007 }
dcd2690d 1008
8547965d 1009 if ( TreeT() ) {
61adb9bd 1010 if (fRecTracks == 0x0 && cRT) {
8547965d 1011 fRecTracks = new TClonesArray("AliMUONTrack",100);
1012 }
61adb9bd 1013
8547965d 1014 }
dcd2690d 1015 if ( TreeT() && fRecTracks && cRT ) {
1016 sprintf(branchname,"%sTrack",GetName());
1017 branch = TreeT()->GetBranch(branchname);
1018 if (branch) branch->SetAddress(&fRecTracks);
8c343c7c 1019 else AliWarning(Form("(%s) Failed for Tracks. Can not find branch in tree.",GetName()));
dcd2690d 1020 }
276c44b7 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);
8c343c7c 1032 else AliWarning(Form("(%s) Failed for Trigger Tracks. Can not find branch in tree.",GetName()));
276c44b7 1033 }
1034
61adb9bd 1035
6309cf6e 1036}
1037//_____________________________________________________________________________