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