]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONData.cxx
Updated comments for Doxygen
[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
c4ee792d 18/// \class AliMUONData class
f0945e46 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///
c4ee792d 23/// \author Gines Martinez, Subatech, September 2003
f0945e46 24///
9140dcef 25
6309cf6e 26#include "AliMUONData.h"
6b74d6d9 27#include "AliMUONDataIterator.h"
c82862d3 28#include "AliMUONConstants.h"
47dc4ee7 29#include "AliMUONHit.h"
6309cf6e 30#include "AliMUONDigit.h"
c82862d3 31#include "AliMUONGlobalTrigger.h"
6309cf6e 32#include "AliMUONLocalTrigger.h"
47dc4ee7 33#include "AliMUONRegionalTrigger.h"
6b74d6d9 34#include "AliMUONTriggerCrateStore.h"
35#include "AliMUONTriggerCircuit.h"
36#include "AliMUONGeometryTransformer.h"
6309cf6e 37#include "AliMUONRawCluster.h"
6b74d6d9 38
39// This is from rec, classes in base should not depend on rec !!!
dcd2690d 40#include "AliMUONTrack.h"
276c44b7 41#include "AliMUONTriggerTrack.h"
6b74d6d9 42
f0945e46 43#include "AliRunLoader.h"
6b74d6d9 44#include "AliStack.h"
45#include "AliLog.h"
46
47#include <TString.h>
48#include <TParticle.h>
49#include <TNtuple.h>
50#include <Riostream.h>
51#include <TFile.h>
30178c30 52
5398f946 53/// \cond CLASSIMP
6309cf6e 54ClassImp(AliMUONData)
5398f946 55/// \endcond
6309cf6e 56
57//_____________________________________________________________________________
1017e5bf 58 AliMUONData::AliMUONData():
59 TNamed(),
6b74d6d9 60 fRunLoader(0x0),
1017e5bf 61 fLoader(0x0),
62 fHits(0x0),
63 fDigits(0x0),
64 fSDigits(0x0),
65 fRawClusters(0x0),
66 fGlobalTrigger(0x0),
67 fLocalTrigger(0x0),
47dc4ee7 68 fRegionalTrigger(0x0),
1017e5bf 69 fRecTracks(0x0),
70 fRecTriggerTracks(0x0),
71 fNhits(0),
72 fNdigits(0x0),
73 fNSdigits(0x0),
74 fNrawclusters(0x0),
75 fNglobaltrigger(0),
76 fNlocaltrigger(0),
47dc4ee7 77 fNregionaltrigger(0),
1017e5bf 78 fNrectracks(0),
79 fNrectriggertracks(0),
f0945e46 80 fSplitLevel(0),
81 fCurrentEvent(-1)
6309cf6e 82{
9140dcef 83 // Default constructor
6309cf6e 84}
85//_____________________________________________________________________________
86AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
1017e5bf 87 TNamed(name,title),
6b74d6d9 88 fRunLoader(0x0),
1017e5bf 89 fLoader(loader),
90 fHits(0x0),
91 fDigits(0x0),
92 fSDigits(0x0),
93 fRawClusters(0x0),
94 fGlobalTrigger(0x0),
95 fLocalTrigger(0x0),
47dc4ee7 96 fRegionalTrigger(0x0),
1017e5bf 97 fRecTracks(0x0),
98 fRecTriggerTracks(0x0),
99 fNhits(0),
100 fNdigits(0x0),
101 fNSdigits(0x0),
102 fNrawclusters(0x0),
103 fNglobaltrigger(0),
104 fNlocaltrigger(0),
47dc4ee7 105 fNregionaltrigger(0),
1017e5bf 106 fNrectracks(0),
107 fNrectriggertracks(0),
f0945e46 108 fSplitLevel(0),
109 fCurrentEvent(-1)
6309cf6e 110{
5398f946 111/// Standard constructor
6309cf6e 112}
e3ea1889 113
6b74d6d9 114//_____________________________________________________________________________
115AliMUONData::AliMUONData(const char* galiceFile):
116 TNamed("MUON", "MUON"),
117 fRunLoader(0x0),
118 fLoader(0x0),
119 fHits(0x0),
120 fDigits(0x0),
121 fSDigits(0x0),
122 fRawClusters(0x0),
123 fGlobalTrigger(0x0),
124 fLocalTrigger(0x0),
125 fRegionalTrigger(0x0),
126 fRecTracks(0x0),
127 fRecTriggerTracks(0x0),
128 fNhits(0),
129 fNdigits(0x0),
130 fNSdigits(0x0),
131 fNrawclusters(0x0),
132 fNglobaltrigger(0),
133 fNlocaltrigger(0),
134 fNregionaltrigger(0),
135 fNrectracks(0),
136 fNrectriggertracks(0),
137 fSplitLevel(0),
138 fCurrentEvent(-1)
139{
140/// Constructor for loading data from gAlice file
141
142 fRunLoader = AliRunLoader::Open(galiceFile, "MUONFolder", "READ");
143 if (!fRunLoader) {
144 AliError(Form("Error opening %s file \n", galiceFile));
145 return;
146 }
147
148 fLoader = fRunLoader->GetLoader("MUONLoader");
149 if ( ! fLoader ) {
150 AliError(Form("Could get MUONLoader"));
151 return;
152 }
153}
154
6309cf6e 155//_____________________________________________________________________________
156AliMUONData::~AliMUONData()
157{
5398f946 158/// Destructor for AliMUONData
6309cf6e 159 if (fHits) {
160 fHits->Delete();
161 delete fHits;
162 }
c82862d3 163
6309cf6e 164 if (fDigits) {
165 fDigits->Delete();
166 delete fDigits;
167 }
d1775029 168 if (fSDigits) {
169 fSDigits->Delete();
170 delete fSDigits;
171 }
6309cf6e 172 if (fRawClusters) {
173 fRawClusters->Delete();
174 delete fRawClusters;
175 }
176 if (fGlobalTrigger){
177 fGlobalTrigger->Delete();
178 delete fGlobalTrigger;
179 }
47dc4ee7 180 if (fRegionalTrigger){
181 fRegionalTrigger->Delete();
182 delete fRegionalTrigger;
183 }
6309cf6e 184 if (fLocalTrigger){
185 fLocalTrigger->Delete();
186 delete fLocalTrigger;
187 }
dcd2690d 188 if (fRecTracks){
189 fRecTracks->Delete();
190 delete fRecTracks;
191 }
276c44b7 192 if (fRecTriggerTracks){
193 fRecTriggerTracks->Delete();
194 delete fRecTriggerTracks;
195 }
6b74d6d9 196
197 if (fRunLoader) {
198 fRunLoader->UnloadAll();
199 delete fRunLoader;
200 }
6309cf6e 201}
47dc4ee7 202//____________________________________________________________________________
f1348c21 203void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t detElemId,
47dc4ee7 204 Int_t idpart, Float_t X, Float_t Y, Float_t Z,
205 Float_t tof, Float_t momentum, Float_t theta,
206 Float_t phi, Float_t length, Float_t destep,
207 Float_t Xref,Float_t Yref,Float_t Zref)
208{
209 // Add new hit to the hit list
e3ea1889 210
47dc4ee7 211 TClonesArray &lhits = *fHits;
212 new(lhits[fNhits++]) AliMUONHit(fIshunt, track, detElemId,
213 idpart, X, Y, Z,
214 tof, momentum, theta,
215 phi, length, destep,
f1348c21 216 Xref,Yref,Zref);
47dc4ee7 217}
6309cf6e 218//_____________________________________________________________________________
61adb9bd 219void AliMUONData::AddDigit(Int_t id, const AliMUONDigit& digit)
220{
5398f946 221/// Add a MUON digit to the list of Digits of the detection plane id
222
61adb9bd 223 TClonesArray &ldigits = * Digits(id) ;
224 new(ldigits[fNdigits[id]++]) AliMUONDigit(digit);
225}
226//_____________________________________________________________________________
d1775029 227void AliMUONData::AddSDigit(Int_t id, const AliMUONDigit& Sdigit)
228{
5398f946 229/// Add a MUON Sdigit to the list of SDigits of the detection plane id
230
d1775029 231 TClonesArray &lSdigits = * SDigits(id) ;
232 new(lSdigits[fNSdigits[id]++]) AliMUONDigit(Sdigit);
233}
2cf44ef3 234
6309cf6e 235//_____________________________________________________________________________
61adb9bd 236void AliMUONData::AddGlobalTrigger(const AliMUONGlobalTrigger& trigger )
237{
5398f946 238/// Add a MUON Global Trigger to the list (only one GlobalTrigger per event !);
239
61adb9bd 240 TClonesArray &globalTrigger = *fGlobalTrigger;
241 new(globalTrigger[fNglobaltrigger++]) AliMUONGlobalTrigger(trigger);
242}
5398f946 243
6309cf6e 244//____________________________________________________________________________
47dc4ee7 245void AliMUONData::AddRegionalTrigger(const AliMUONRegionalTrigger& trigger)
1391e633 246{
47dc4ee7 247/// add a MUON regional Trigger to the list
248 TClonesArray &regionalTrigger = *fRegionalTrigger;
249 new(regionalTrigger[fNregionaltrigger++]) AliMUONRegionalTrigger(trigger);
61adb9bd 250}
251//____________________________________________________________________________
61adb9bd 252void AliMUONData::AddLocalTrigger(const AliMUONLocalTrigger& trigger)
253{
5398f946 254/// add a MUON Local Trigger to the list
255
61adb9bd 256 TClonesArray &localTrigger = *fLocalTrigger;
257 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(trigger);
258}
47dc4ee7 259
6309cf6e 260//_____________________________________________________________________________
261void AliMUONData::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
262{
5398f946 263/// Add a MUON rawcluster to the list in the detection plane id
264
6309cf6e 265 TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id));
266 new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c);
267}
dcd2690d 268//_____________________________________________________________________________
269void AliMUONData::AddRecTrack(const AliMUONTrack& track)
270{
5398f946 271/// Add a MUON rectrack
272
dcd2690d 273 TClonesArray &lrectracks = *fRecTracks;
274 new(lrectracks[fNrectracks++]) AliMUONTrack(track);
275}
276c44b7 276//_____________________________________________________________________________
277void AliMUONData::AddRecTriggerTrack(const AliMUONTriggerTrack& triggertrack)
278{
5398f946 279/// Add a MUON triggerrectrack
280
276c44b7 281 TClonesArray &lrectriggertracks = *fRecTriggerTracks;
282 new(lrectriggertracks[fNrectriggertracks++]) AliMUONTriggerTrack(triggertrack);
276c44b7 283}
ce3f5e87 284//____________________________________________________________________________
c82862d3 285TClonesArray* AliMUONData::Digits(Int_t DetectionPlane) const
1eccde20 286{
5398f946 287/// Getting List of Digits
288
1eccde20 289 if (fDigits)
290 return ( (TClonesArray*) fDigits->At(DetectionPlane) );
291 else
292 return NULL;
293}
294//____________________________________________________________________________
c82862d3 295TClonesArray* AliMUONData::SDigits(Int_t DetectionPlane) const
d1775029 296{
5398f946 297/// Getting List of SDigits
298
d1775029 299 if (fSDigits)
300 return ( (TClonesArray*) fSDigits->At(DetectionPlane) );
301 else
302 return NULL;
303}
304//____________________________________________________________________________
c1d45bdf 305Bool_t AliMUONData::IsRawClusterBranchesInTree()
306{
5398f946 307/// Checking if there are RawCluster Branches In TreeR
308
c1d45bdf 309 if (TreeR()==0x0) {
8c343c7c 310 AliError("No treeR in memory");
c1d45bdf 311 return kFALSE;
312 }
313 else {
314 char branchname[30];
315 sprintf(branchname,"%sRawClusters1",GetName());
316 TBranch * branch = 0x0;
317 branch = TreeR()->GetBranch(branchname);
318 if (branch) return kTRUE;
319 else return kFALSE;
320 }
321}
322//____________________________________________________________________________
ce3e25a8 323Bool_t AliMUONData::IsDigitsBranchesInTree()
324{
5398f946 325/// Checking if there are RawCluster Branches In TreeR
326
ce3e25a8 327 if (TreeD()==0x0) {
8c343c7c 328 AliError("No treeD in memory");
ce3e25a8 329 return kFALSE;
330 }
331 else {
332 char branchname[30];
333 sprintf(branchname,"%sDigits1",GetName());
334 TBranch * branch = 0x0;
335 branch = TreeD()->GetBranch(branchname);
336 if (branch) return kTRUE;
337 else return kFALSE;
338 }
339}
340//____________________________________________________________________________
c1d45bdf 341Bool_t AliMUONData::IsTriggerBranchesInTree()
342{
5398f946 343/// Checking if there are Trigger Branches In TreeR
c1d45bdf 344 if (TreeR()==0x0) {
8c343c7c 345 AliError("No treeR in memory");
c1d45bdf 346 return kFALSE;
347 }
348 else {
349 char branchname[30];
350 sprintf(branchname,"%sLocalTrigger",GetName());
351 TBranch * branch = 0x0;
352 branch = TreeR()->GetBranch(branchname);
353 if (branch) return kTRUE;
354 else return kFALSE;
355 }
356}
ce3e25a8 357//____________________________________________________________________________
358Bool_t AliMUONData::IsTriggerBranchesInTreeD()
359{
5398f946 360/// Checking if there are Trigger Branches In TreeR
ce3e25a8 361 if (TreeD()==0x0) {
8c343c7c 362 AliError("No treeD in memory");
ce3e25a8 363 return kFALSE;
364 }
365 else {
366 char branchname[30];
367 sprintf(branchname,"%sLocalTrigger",GetName());
368 TBranch * branch = 0x0;
369 branch = TreeD()->GetBranch(branchname);
370 if (branch) return kTRUE;
371 else return kFALSE;
372 }
373}
374
c1d45bdf 375//____________________________________________________________________________
276c44b7 376Bool_t AliMUONData::IsTrackBranchesInTree()
377{
5398f946 378/// Checking if there are Track Branches In TreeT
276c44b7 379 if (TreeT()==0x0) {
8c343c7c 380 AliError("No treeT in memory");
276c44b7 381 return kFALSE;
382 }
383 else {
384 char branchname[30];
385 sprintf(branchname,"%sTrack",GetName());
386 TBranch * branch = 0x0;
387 branch = TreeT()->GetBranch(branchname);
388 if (branch) return kTRUE;
389 else return kFALSE;
390 }
391}
392//____________________________________________________________________________
393Bool_t AliMUONData::IsTriggerTrackBranchesInTree()
394{
5398f946 395/// Checking if there are TriggerTrack Branches In TreeT
276c44b7 396 if (TreeT()==0x0) {
8c343c7c 397 AliError("No treeT in memory");
276c44b7 398 return kFALSE;
399 }
400 else {
401 char branchname[30];
402 sprintf(branchname,"%sTriggerTrack",GetName());
403 TBranch * branch = 0x0;
404 branch = TreeT()->GetBranch(branchname);
405 if (branch) return kTRUE;
406 else return kFALSE;
407 }
408}
409//____________________________________________________________________________
1a1cdff8 410void AliMUONData::Fill(Option_t* option)
411{
5398f946 412/// Method to fill the trees
1a1cdff8 413 const char *cH = strstr(option,"H");
414 const char *cD = strstr(option,"D"); // Digits branches in TreeD
d1775029 415 const char *cS = strstr(option,"S"); // SDigits branches in TreeS
1a1cdff8 416 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
ce3e25a8 417 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
418 const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR
1a1cdff8 419 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
ce3e25a8 420 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
61adb9bd 421
1a1cdff8 422 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
423
424 char branchname[30];
425 TBranch * branch = 0x0;
426
1a1cdff8 427 // Filling TreeH
f0945e46 428 if ( TreeH() && cH )
429 {
1a1cdff8 430 TreeH()->Fill();
431 }
ce3e25a8 432
1a1cdff8 433 // Filling TreeD
ce3e25a8 434
c82862d3 435 if ( TreeD() && cD && cGLT )
436 {
f0945e46 437 // Writing digits and (global+local) trigger at once.
c82862d3 438 TreeD()->Fill();
439 }
f0945e46 440 else
441 {
442 if ( TreeD() && cD )
443 {
444 if ( IsTriggerBranchesInTreeD() )
445 {
446 for (int i=0; i<AliMUONConstants::NCh(); i++)
447 {
448 sprintf(branchname,"%sDigits%d",GetName(),i+1);
449 branch = TreeD()->GetBranch(branchname);
450 branch->Fill();
451 }
452 }
453 else
454 {
455 TreeD()->Fill();
ce3e25a8 456 }
f0945e46 457 }
458
459 if ( TreeD() && cGLT )
460 {
461 if ( IsDigitsBranchesInTree() )
462 {
463 sprintf(branchname,"%sLocalTrigger",GetName());
464 branch = TreeD()->GetBranch(branchname);
465 branch->Fill();
47dc4ee7 466 sprintf(branchname,"%sRegionalTrigger",GetName());
467 branch = TreeD()->GetBranch(branchname);
468 branch->Fill();
f0945e46 469 sprintf(branchname,"%sGlobalTrigger",GetName());
470 branch = TreeD()->GetBranch(branchname);
471 branch->Fill();
47dc4ee7 472
f0945e46 473 }
474 else
475 {
476 TreeD()->Fill();
477 }
478 }
479 } // end of TreeD() handling.
ce3e25a8 480
d1775029 481 // Filling TreeS
f0945e46 482 if ( TreeS() && cS)
483 {
d1775029 484 TreeS()->Fill();
485 }
c1d45bdf 486
f0945e46 487 // Filling TreeR
488
489 if ( TreeR() && cRC && cTC )
490 {
491 TreeR()->Fill();
492 }
493 else
494 {
495 if ( TreeR() && cRC )
496 {
497 if ( IsTriggerBranchesInTree() )
498 {
c1d45bdf 499 // Branch per branch filling
f0945e46 500 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++)
501 {
502 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
503 branch = TreeR()->GetBranch(branchname);
504 branch->Fill();
505 }
506 }
507 else
508 {
509 TreeR()->Fill();
510 }
511 }
512
513 if ( TreeR() && cTC)
514 {
515 if (IsRawClusterBranchesInTree())
516 {
517 // Branch per branch filling
518 sprintf(branchname,"%sLocalTrigger",GetName());
519 branch = TreeR()->GetBranch(branchname);
520 branch->Fill();
47dc4ee7 521 sprintf(branchname,"%sRegionalTrigger",GetName());
522 branch = TreeR()->GetBranch(branchname);
523 branch->Fill();
f0945e46 524 sprintf(branchname,"%sGlobalTrigger",GetName());
525 branch = TreeR()->GetBranch(branchname);
526 branch->Fill();
527 }
528 else
529 {
530 TreeR()->Fill();
c1d45bdf 531 }
532 }
1a1cdff8 533 }
f0945e46 534
535 // Filling TreeT
c1d45bdf 536
f0945e46 537 if ( TreeT() && cRT && cRL )
538 {
539 TreeT()->Fill();
1a1cdff8 540 }
f0945e46 541 else
542 {
543 if ( TreeT() && cRT )
544 {
545 if (IsTriggerTrackBranchesInTree())
546 {
547 sprintf(branchname,"%sTrack",GetName());
548 branch = TreeT()->GetBranch(branchname);
549 branch->Fill();
550 }
551 else
552 {
553 TreeT()->Fill();
554 }
555 }
556
557 if ( TreeT() && cRL )
558 {
559 if (IsTrackBranchesInTree())
560 {
561 sprintf(branchname,"%sTriggerTrack",GetName());
562 branch = TreeT()->GetBranch(branchname);
563 branch->Fill();
564 }
565 else
566 {
567 TreeT()->Fill();
568 }
276c44b7 569 }
1a1cdff8 570 }
571}
c82862d3 572
1a1cdff8 573//_____________________________________________________________________________
6309cf6e 574void AliMUONData::MakeBranch(Option_t* option)
575{
5398f946 576/// Create Tree branches for the MUON.
577
6309cf6e 578 const Int_t kBufferSize = 4000;
579 char branchname[30];
580
79fc84ff 581 //Setting Data Container
582 SetDataContainer(option);
583
6309cf6e 584 const char *cH = strstr(option,"H");
585 const char *cD = strstr(option,"D"); // Digits branches in TreeD
d1775029 586 const char *cS = strstr(option,"S"); // Digits branches in TreeS
6309cf6e 587 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
ce3e25a8 588 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
47dc4ee7 589 const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR
6309cf6e 590 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
276c44b7 591 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
c82862d3 592 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
593
6309cf6e 594 TBranch * branch = 0x0;
595
596 // Creating Branches for Hits
597 if (TreeH() && cH) {
6309cf6e 598 sprintf(branchname,"%sHits",GetName());
599 branch = TreeH()->GetBranch(branchname);
600 if (branch) {
f0945e46 601 AliInfo(Form("MakeBranch","Branch %s is already in tree.",branchname));
6309cf6e 602 return ;
603 }
c6ce342a 604 branch = TreeH()->Branch(branchname,&fHits,kBufferSize);
cba99c31 605 //Info("MakeBranch","Making Branch %s for hits \n",branchname);
6309cf6e 606 }
607
608 //Creating Branches for Digits
c82862d3 609 TTree* treeD = 0x0;
610 if ( cD || cGLT )
611 {
612 treeD = TreeD();
613 }
614
615 if ( treeD && cD )
616 {
6309cf6e 617 // one branch for digits per chamber
c82862d3 618 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++)
619 {
6309cf6e 620 sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
c82862d3 621 branch = treeD->GetBranch(branchname);
622 if (branch)
623 {
f0945e46 624 AliInfo(Form("Branch %s is already in tree.",branchname));
c82862d3 625 return;
6309cf6e 626 }
1a1cdff8 627 TClonesArray * digits = Digits(iDetectionPlane);
c82862d3 628 branch = treeD->Branch(branchname, &digits, kBufferSize,1);
629 }
6309cf6e 630 }
c82862d3 631
632 if ( treeD && cGLT )
633 {
ce3e25a8 634 //
635 // one branch for global trigger
636 //
637 sprintf(branchname,"%sGlobalTrigger",GetName());
c82862d3 638 branch = treeD->GetBranch(branchname);
639 if (branch)
640 {
8c343c7c 641 AliInfo(Form("Branch GlobalTrigger is already in treeD."));
ce3e25a8 642 return ;
643 }
c82862d3 644 branch = treeD->Branch(branchname, &fGlobalTrigger, kBufferSize);
645
47dc4ee7 646 //
647 // one branch for regional trigger
648 //
649 sprintf(branchname,"%sRegionalTrigger",GetName());
650 branch = 0x0;
47dc4ee7 651 branch = treeD->GetBranch(branchname);
652 if (branch)
653 {
654 AliInfo(Form("Branch RegionalTrigger is already in treeD."));
655 return;
656 }
657 branch = treeD->Branch(branchname, &fRegionalTrigger, kBufferSize);
658
659
ce3e25a8 660 //
661 // one branch for local trigger
662 //
663 sprintf(branchname,"%sLocalTrigger",GetName());
664 branch = 0x0;
c82862d3 665 branch = treeD->GetBranch(branchname);
666 if (branch)
667 {
8c343c7c 668 AliInfo(Form("Branch LocalTrigger is already in treeD."));
ce3e25a8 669 return;
670 }
c82862d3 671 branch = treeD->Branch(branchname, &fLocalTrigger, kBufferSize);
ce3e25a8 672 }
c82862d3 673
d1775029 674 //Creating Branches for SDigits
675 if (TreeS() && cS ) {
676 // one branch for Sdigits per chamber
d1775029 677 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
678 sprintf(branchname,"%sSDigits%d",GetName(),iDetectionPlane+1);
679 branch = 0x0;
680 branch = TreeS()->GetBranch(branchname);
681 if (branch) {
f0945e46 682 AliInfo(Form("Branch %s is already in tree.",branchname));
c82862d3 683 return;
d1775029 684 }
30178c30 685 TClonesArray * sdigits = SDigits(iDetectionPlane);
686 branch = TreeS()->Branch(branchname, &sdigits, kBufferSize,1);
687 //Info("MakeBranch","Making Branch %s for sdigits in detection plane %d\n",branchname,iDetectionPlane+1);
c82862d3 688 }
d1775029 689 }
c82862d3 690
6309cf6e 691 if (TreeR() && cRC ) {
692 // one branch for raw clusters per tracking detection plane
693 //
79fc84ff 694 Int_t i;
6309cf6e 695 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
696 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
697 branch = 0x0;
698 branch = TreeR()->GetBranch(branchname);
699 if (branch) {
f0945e46 700 AliInfo(Form("Branch %s is already in tree.",branchname));
c82862d3 701 return;
6309cf6e 702 }
c6ce342a 703 branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize);
cba99c31 704 //Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1);
6309cf6e 705 }
706 }
c82862d3 707
ce3e25a8 708 if (TreeR() && cTC ) {
6309cf6e 709 //
710 // one branch for global trigger
711 //
712 sprintf(branchname,"%sGlobalTrigger",GetName());
713 branch = 0x0;
6309cf6e 714 branch = TreeR()->GetBranch(branchname);
715 if (branch) {
8c343c7c 716 AliInfo(Form("Branch GlobalTrigger is already in treeR."));
6309cf6e 717 return ;
718 }
c6ce342a 719 branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize);
cba99c31 720 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
47dc4ee7 721
722 //
723 // one branch for regional trigger
724 //
725 sprintf(branchname,"%sRegionalTrigger",GetName());
726 branch = 0x0;
47dc4ee7 727 branch = TreeR()->GetBranch(branchname);
728 if (branch) {
729 AliInfo(Form("Branch RegionalTrigger is already in treeR."));
730 return;
731 }
732 branch = TreeR()->Branch(branchname, &fRegionalTrigger, kBufferSize);
733
6309cf6e 734 //
735 // one branch for local trigger
736 //
737 sprintf(branchname,"%sLocalTrigger",GetName());
738 branch = 0x0;
6309cf6e 739 branch = TreeR()->GetBranch(branchname);
740 if (branch) {
8c343c7c 741 AliInfo(Form("Branch LocalTrigger is already in treeR."));
6309cf6e 742 return;
743 }
c6ce342a 744 branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize);
cba99c31 745 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
6309cf6e 746 }
747
dcd2690d 748 if (TreeT() && cRT ) {
dcd2690d 749 sprintf(branchname,"%sTrack",GetName());
750 branch = TreeT()->GetBranch(branchname);
751 if (branch) {
8c343c7c 752 AliInfo(Form("Branch %s is already in tree.",GetName()));
dcd2690d 753 return ;
754 }
755 branch = TreeT()->Branch(branchname,&fRecTracks,kBufferSize);
cba99c31 756 //Info("MakeBranch","Making Branch %s for tracks \n",branchname);
dcd2690d 757 }
c82862d3 758 // trigger tracks
276c44b7 759 if (TreeT() && cRL ) {
276c44b7 760 sprintf(branchname,"%sTriggerTrack",GetName());
761 branch = TreeT()->GetBranch(branchname);
762 if (branch) {
8c343c7c 763 AliInfo(Form("Branch %s is already in tree.",GetName()));
276c44b7 764 return ;
765 }
766 branch = TreeT()->Branch(branchname,&fRecTriggerTracks,kBufferSize);
cba99c31 767 //Info("MakeBranch","Making Branch %s for trigger tracks \n",branchname);
276c44b7 768 }
6309cf6e 769}
1eccde20 770//____________________________________________________________________________
771TClonesArray* AliMUONData::RawClusters(Int_t DetectionPlane)
772{
5398f946 773/// Getting Raw Clusters
774
1eccde20 775 if (fRawClusters)
776 return ( (TClonesArray*) fRawClusters->At(DetectionPlane) );
777 else
778 return NULL;
779}
f0945e46 780
6309cf6e 781//____________________________________________________________________________
f0945e46 782TClonesArray*
783AliMUONData::LocalTrigger() const
276c44b7 784{
5398f946 785/// Getting local trigger
786
f0945e46 787 return fLocalTrigger;
276c44b7 788}
f0945e46 789
1a46cb76 790//____________________________________________________________________________
791TClonesArray*
792AliMUONData::RegionalTrigger() const
793{
794/// Getting regional trigger
795
796 return fRegionalTrigger;
797}
798
e89190bb 799//____________________________________________________________________________
800Int_t
801AliMUONData::GetNtracks() const
802{
803/// Get number of entries in hits three
804
805 Int_t ntrk = 0;
806 if (fLoader && fLoader->TreeH())
807 ntrk = (Int_t) fLoader->TreeH()->GetEntries();
808 return ntrk;
809}
810
276c44b7 811//____________________________________________________________________________
f0945e46 812void
813AliMUONData::GetDigits() const
276c44b7 814{
5398f946 815/// Load the digits from TreeD for the current event.
816
f0945e46 817 Int_t event = fLoader->GetRunLoader()->GetEventNumber();
818 if ( fCurrentEvent != event )
819 {
698b2e52 820 if (fLoader->TreeD()) {
821 fLoader->TreeD()->GetEvent(0);
822 fCurrentEvent = event;
823 }
f0945e46 824 }
276c44b7 825}
f0945e46 826
827//____________________________________________________________________________
828TClonesArray*
829AliMUONData::GlobalTrigger() const
830{
5398f946 831/// Return the global trigger
832
f0945e46 833 return fGlobalTrigger;
834}
835
276c44b7 836//____________________________________________________________________________
6309cf6e 837void AliMUONData::ResetDigits()
838{
5398f946 839/// Reset number of digits and the digits array for this detector
840
6309cf6e 841 if (fDigits == 0x0) return;
842 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
f68d0cf6 843 if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear("C");
6309cf6e 844 if (fNdigits) fNdigits[i]=0;
845 }
846}
d1775029 847//____________________________________________________________________________
848void AliMUONData::ResetSDigits()
849{
5398f946 850/// Reset number of Sdigits and the Sdigits array for this detector
851
d1775029 852 if (fSDigits == 0x0) return;
853 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
854 if ((*fSDigits)[i]) ((TClonesArray*)fSDigits->At(i))->Clear();
855 if (fNSdigits) fNSdigits[i]=0;
856 }
857}
6309cf6e 858//______________________________________________________________________________
859void AliMUONData::ResetHits()
860{
5398f946 861/// Reset number of clusters and the cluster array for this detector
862
6309cf6e 863 fNhits = 0;
864 if (fHits) fHits->Clear();
865}
866//_______________________________________________________________________________
867void AliMUONData::ResetRawClusters()
868{
5398f946 869/// Reset number of raw clusters and the raw clust array for this detector
870
6309cf6e 871 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
872 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
873 if (fNrawclusters) fNrawclusters[i]=0;
874 }
875}
876//_______________________________________________________________________________
877void AliMUONData::ResetTrigger()
878{
5398f946 879/// Reset Local and Global Trigger
880
6309cf6e 881 fNglobaltrigger = 0;
882 if (fGlobalTrigger) fGlobalTrigger->Clear();
47dc4ee7 883 fNregionaltrigger = 0;
884 if (fRegionalTrigger) fRegionalTrigger->Clear();
6309cf6e 885 fNlocaltrigger = 0;
886 if (fLocalTrigger) fLocalTrigger->Clear();
47dc4ee7 887
6309cf6e 888}
dcd2690d 889//____________________________________________________________________________
890void AliMUONData::ResetRecTracks()
891{
5398f946 892/// Reset tracks information
893
dcd2690d 894 fNrectracks = 0;
34f1bfa0 895 if (fRecTracks) fRecTracks->Delete(); // necessary to delete in case of memory allocation
dcd2690d 896}
276c44b7 897//____________________________________________________________________________
898void AliMUONData::ResetRecTriggerTracks()
899{
5398f946 900/// Reset tracks information
901
276c44b7 902 fNrectriggertracks = 0;
34f1bfa0 903 if (fRecTriggerTracks) fRecTriggerTracks->Delete(); // necessary to delete in case of memory allocation
276c44b7 904}
79fc84ff 905//____________________________________________________________________________
906void AliMUONData::SetDataContainer(Option_t* option)
907{
908/// Setting data containers of muon data
909 const char *cH = strstr(option,"H");
910 const char *cD = strstr(option,"D"); // Digits
911 const char *cS = strstr(option,"S"); // SDigits
912 const char *cRC = strstr(option,"RC"); // RawCluster
913 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger
914 const char *cTC = strstr(option,"TC"); // global and local Trigger
915 const char *cRT = strstr(option,"RT"); // Reconstructed Tracks
916 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Tracks
917 //const char *cRP = strstr(option,"RP"); // Reconstructed Particles
918 AliDebug(1,Form("option=%s",option));
919 //
920 // Clones array for hits
921 if ( cH ) {
922 if (fHits == 0x0) {
923 fHits = new TClonesArray("AliMUONHit",1000);
924 }
925 ResetHits();
926 }
927
928 //
929 // ObjArray of ClonesArrays for Digits
930 if ( cD ) {
931 if (fDigits == 0x0 ) {
932 fDigits = new TObjArray(AliMUONConstants::NCh());
933 fNdigits= new Int_t[AliMUONConstants::NCh()];
934 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
935 TClonesArray * tca = new TClonesArray("AliMUONDigit",10000);
936 tca->SetOwner();
937 fDigits->AddAt(tca,i);
938 fNdigits[i]=0;
939 }
940 }
941 else {
942 AliDebug(1,Form("fDigits already there = %p",fSDigits));
943 }
944 ResetDigits();
945 }
946
947 //
948 // ClonesArrays for Trigger
949 if ( cGLT ) {
950 if (fLocalTrigger == 0x0) {
951 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
952 }
953 if (fRegionalTrigger == 0x0) {
954 fRegionalTrigger = new TClonesArray("AliMUONRegionalTrigger",16);
955 }
956 if (fGlobalTrigger== 0x0) {
957 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
958 }
959 ResetTrigger();
960 }
961
962 //
963 // Container for Sdigits
964 if (cS) {
965 if (fSDigits == 0x0) {
966 AliDebug(1,"Creating fSDigits TObjArray");
967 fSDigits = new TObjArray(AliMUONConstants::NCh());
968 fNSdigits= new Int_t[AliMUONConstants::NCh()];
969 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
970 TClonesArray* a = new TClonesArray("AliMUONDigit",10000);
971 a->SetOwner();
972 fSDigits->AddAt(a,i);
973 AliDebug(1,Form("fSDigits[%d]=%p",i,a));
974 fNSdigits[i]=0;
975 }
976 }
977 else {
978 AliDebug(1,Form("fSDigits already there = %p",fSDigits));
979 }
980 ResetSDigits();
981 }
982
983 //
984 // Containers for rawclusters, globaltrigger and local trigger tree
985 if (cRC ) {
986 if (fRawClusters == 0x0) {
987 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
988 fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
989 for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
990 TClonesArray* tca = new TClonesArray("AliMUONRawCluster",10000);
991 tca->SetOwner();
992 fRawClusters->AddAt(tca,i);
993 fNrawclusters[i]=0;
994 }
995 }
0ff312d5 996 // ResetRawClusters();
997 // It breaks the correct functioning of the combined reconstruction (AZ)
998
79fc84ff 999 }
1000 if (cTC ) {
1001 if (fLocalTrigger == 0x0) {
1002 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
1003 }
1004 if (fRegionalTrigger == 0x0) {
1005 fRegionalTrigger = new TClonesArray("AliMUONRegionalTrigger",16);
1006 }
1007 if (fGlobalTrigger== 0x0) {
1008 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
1009 }
0ff312d5 1010 // ResetTrigger();
1011 // This is not necessary here since trigger info ins copied from digits info on flight to RecPoint output
79fc84ff 1012 }
1013
1014 //
1015 // Containers for rectracks and rectrigger tracks
1016 if ( cRT ) {
1017 if (fRecTracks == 0x0) {
1018 fRecTracks = new TClonesArray("AliMUONTrack",100);
1019 }
1020 ResetRecTracks();
1021 }
1022 if (cRL) {
1023 if (fRecTriggerTracks == 0x0 && cRL) {
1024 fRecTriggerTracks = new TClonesArray("AliMUONTriggerTrack",100);
1025 }
1026 ResetRecTriggerTracks();
1027 }
1028}
1029
1030//____________________________________________________________________________
ce3f5e87 1031void AliMUONData::SetTreeAddress(Option_t* option)
6309cf6e 1032{
79fc84ff 1033 // Setting Data containers
1034 SetDataContainer(option);
1035
5398f946 1036/// Setting Addresses to the events trees
1037
ce3f5e87 1038 const char *cH = strstr(option,"H");
1039 const char *cD = strstr(option,"D"); // Digits branches in TreeD
d1775029 1040 const char *cS = strstr(option,"S"); // SDigits branches in TreeS
ce3f5e87 1041 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
ce3e25a8 1042 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
1043 const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR
dcd2690d 1044 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
276c44b7 1045 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
c82862d3 1046 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
ce3f5e87 1047
6309cf6e 1048 // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree.
1049 char branchname[30];
1050 TBranch * branch = 0x0;
c82862d3 1051
1052 AliDebug(1,Form("option=%s",option));
6309cf6e 1053 //
1054 // Branch address for hit tree
ce3f5e87 1055 if (TreeH() && fHits && cH) {
6309cf6e 1056 sprintf(branchname,"%sHits",GetName());
1057 branch = TreeH()->GetBranch(branchname);
1058 if (branch) {
d652f85c 1059 // Info("SetTreeAddress","(%s) Setting for Hits",GetName());
6309cf6e 1060 branch->SetAddress(&fHits);
1061 }
1062 else { //can be invoked before branch creation
bbcdca4c 1063 //AliWarning(Form("(%s) Failed for Hits. Can not find branch in tree.",GetName()));
6309cf6e 1064 }
1065 }
1066
1067 //
1068 // Branch address for digit tree
ce3f5e87 1069 if (TreeD() && fDigits && cD) {
6309cf6e 1070 for (int i=0; i<AliMUONConstants::NCh(); i++) {
1071 sprintf(branchname,"%sDigits%d",GetName(),i+1);
d652f85c 1072 if (fDigits) {
c82862d3 1073 branch = TreeD()->GetBranch(branchname);
1074 TClonesArray * digits = Digits(i);
1075 if (branch) {
1076 branch->SetAddress( &digits );
1077 }
1078 else AliWarning(Form("(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i));
d652f85c 1079 }
6309cf6e 1080 }
1081 }
ce3e25a8 1082 if ( TreeD() && fLocalTrigger && cGLT) {
1083 sprintf(branchname,"%sLocalTrigger",GetName());
1084 branch = TreeD()->GetBranch(branchname);
1085 if (branch) branch->SetAddress(&fLocalTrigger);
8c343c7c 1086 else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeD.",GetName()));
ce3e25a8 1087 }
47dc4ee7 1088 if ( TreeD() && fRegionalTrigger && cGLT) {
1089 sprintf(branchname,"%sRegionalTrigger",GetName());
1090 branch = TreeD()->GetBranch(branchname);
1091 if (branch) branch->SetAddress(&fRegionalTrigger);
1092 else AliWarning(Form("(%s) Failed for RegionalTrigger. Can not find branch in treeD.",GetName()));
1093 }
ce3e25a8 1094 if ( TreeD() && fGlobalTrigger && cGLT) {
1095 sprintf(branchname,"%sGlobalTrigger",GetName());
1096 branch = TreeD()->GetBranch(branchname);
1097 if (branch) branch->SetAddress(&fGlobalTrigger);
8c343c7c 1098 else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeD.",GetName()));
ce3e25a8 1099 }
c82862d3 1100
d1775029 1101 //
1102 // Branch address for Sdigit tree
d1775029 1103 if (TreeS() && fSDigits && cS) {
c82862d3 1104 AliDebug(1,"Setting branch addresses");
d1775029 1105 for (int i=0; i<AliMUONConstants::NCh(); i++) {
1106 sprintf(branchname,"%sSDigits%d",GetName(),i+1);
1107 if (fSDigits) {
c82862d3 1108 AliDebug(1,Form("TreeS=%p for ich=%d branchname=%s",
1109 TreeS(),i,branchname));
1110 branch = TreeS()->GetBranch(branchname);
1111 TClonesArray * sdigits = SDigits(i);
1112 if (branch) branch->SetAddress( &sdigits );
1113 else AliWarning(Form("(%s) Failed for SDigits Detection plane %d. Can not find branch in tree.",GetName(),i));
d1775029 1114 }
1115 }
1116 }
6309cf6e 1117
1118 //
1119 // Branch address for rawclusters, globaltrigger and local trigger tree
cc87ebcd 1120 if ( TreeR() && fRawClusters && cRC && !strstr(cRC,"RCC")) {
6309cf6e 1121 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
1122 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
1123 if (fRawClusters) {
c82862d3 1124 branch = TreeR()->GetBranch(branchname);
1125 if (branch) branch->SetAddress( &((*fRawClusters)[i]) );
1126 else AliWarning(Form("(%s) Failed for RawClusters Detection plane %d. Can not find branch in tree.",GetName(),i));
6309cf6e 1127 }
1128 }
1129 }
ce3e25a8 1130 if ( TreeR() && fLocalTrigger && cTC) {
6309cf6e 1131 sprintf(branchname,"%sLocalTrigger",GetName());
1132 branch = TreeR()->GetBranch(branchname);
1133 if (branch) branch->SetAddress(&fLocalTrigger);
8c343c7c 1134 else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeR.",GetName()));
6309cf6e 1135 }
47dc4ee7 1136 if ( TreeR() && fRegionalTrigger && cTC) {
1137 sprintf(branchname,"%sRegionalTrigger",GetName());
1138 branch = TreeR()->GetBranch(branchname);
1139 if (branch) branch->SetAddress(&fRegionalTrigger);
1140 else AliWarning(Form("(%s) Failed for RegionalTrigger. Can not find branch in treeR.",GetName()));
1141 }
ce3e25a8 1142 if ( TreeR() && fGlobalTrigger && cTC) {
6309cf6e 1143 sprintf(branchname,"%sGlobalTrigger",GetName());
1144 branch = TreeR()->GetBranch(branchname);
1145 if (branch) branch->SetAddress(&fGlobalTrigger);
8c343c7c 1146 else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeR.",GetName()));
6309cf6e 1147 }
79fc84ff 1148
1149 // Rec Trakcs
dcd2690d 1150 if ( TreeT() && fRecTracks && cRT ) {
1151 sprintf(branchname,"%sTrack",GetName());
1152 branch = TreeT()->GetBranch(branchname);
1153 if (branch) branch->SetAddress(&fRecTracks);
8c343c7c 1154 else AliWarning(Form("(%s) Failed for Tracks. Can not find branch in tree.",GetName()));
dcd2690d 1155 }
79fc84ff 1156 // Trigger tracks
276c44b7 1157 if ( TreeT() && fRecTriggerTracks && cRL ) {
1158 sprintf(branchname,"%sTriggerTrack",GetName());
1159 branch = TreeT()->GetBranch(branchname);
1160 if (branch) branch->SetAddress(&fRecTriggerTracks);
8c343c7c 1161 else AliWarning(Form("(%s) Failed for Trigger Tracks. Can not find branch in tree.",GetName()));
276c44b7 1162 }
6309cf6e 1163}
c82862d3 1164
6309cf6e 1165//_____________________________________________________________________________
c82862d3 1166void
1167AliMUONData::Print(Option_t* opt) const
1168{
5398f946 1169/// Dump object on screen
1170
c82862d3 1171 TString options(opt);
1172 options.ToUpper();
1173
1174 if ( options.Contains("D") )
1175 {
1176 for ( Int_t ich = 0; ich < AliMUONConstants::NCh(); ++ich)
1177 {
1178 TClonesArray* digits = Digits(ich);
1179 Int_t ndigits = digits->GetEntriesFast();
1180 for ( Int_t id = 0; id < ndigits; ++id )
1181 {
1182 AliMUONDigit* digit =
1183 static_cast<AliMUONDigit*>(digits->UncheckedAt(id));
1184 digit->Print();
1185 }
1186 }
1187 }
1188
1189 if ( options.Contains("S") )
1190 {
1191 for ( Int_t ich = 0; ich < AliMUONConstants::NCh(); ++ich)
1192 {
1193 TClonesArray* digits = SDigits(ich);
1194 Int_t ndigits = digits->GetEntriesFast();
1195 for ( Int_t id = 0; id < ndigits; ++id )
1196 {
1197 AliMUONDigit* digit =
1198 static_cast<AliMUONDigit*>(digits->UncheckedAt(id));
1199 digit->Print();
1200 }
1201 }
1202 }
1203
3cdccc77 1204}
6b74d6d9 1205
1206//_____________________________________________________________________________
1207void
1208AliMUONData::DumpKine(Int_t event2Check)
1209{
1210 // Load kinematics
1211 fRunLoader->LoadKinematics("READ");
1212
1213 Int_t nevents = fRunLoader->GetNumberOfEvents();
1214 for (Int_t ievent=0; ievent<nevents; ievent++) { // Event loop
1215 if ( event2Check != 0 ) ievent=event2Check;
1216
1217 // Getting event ievent
1218 fRunLoader->GetEvent(ievent);
1219
1220 // Stack of particle for this event
1221 AliStack* stack = fRunLoader->Stack();
1222
1223 Int_t nparticles = (Int_t) fRunLoader->Stack()->GetNtrack();
1224 printf(">>> Event %d, Number of particles is %d \n", ievent, nparticles);
1225
1226 for (Int_t iparticle=0; iparticle<nparticles; iparticle++) {
1227 stack->Particle(iparticle)->Print("");
1228 }
1229 if (event2Check!=0) ievent=nevents;
1230 }
1231 fRunLoader->UnloadKinematics();
1232}
1233
1234
1235//_____________________________________________________________________________
1236void
1237AliMUONData::DumpHits(Int_t event2Check, Option_t* opt)
1238{
1239 // Loading data
1240 fLoader->LoadHits("READ");
1241
1242 // Event loop
1243 Int_t nevents = fRunLoader->GetNumberOfEvents();
1244 for (Int_t ievent=0; ievent<nevents; ievent++) {
1245 if (event2Check!=0) ievent=event2Check;
1246 printf(">>> Event %d \n",ievent);
1247
1248 // Getting event ievent
1249 fRunLoader->GetEvent(ievent);
1250 SetTreeAddress("H");
1251
1252 // Track loop
1253 Int_t ntracks = (Int_t) GetNtracks();
1254 for (Int_t itrack=0; itrack<ntracks; itrack++) {
1255 //Getting List of Hits of Track itrack
1256 GetTrack(itrack);
1257
1258 Int_t nhits = (Int_t) Hits()->GetEntriesFast();
1259 printf(">>> Track %d, Number of hits %d \n",itrack,nhits);
1260 for (Int_t ihit=0; ihit<nhits; ihit++) {
1261 AliMUONHit* mHit = static_cast<AliMUONHit*>(Hits()->At(ihit));
1262 mHit->Print(opt);
1263 }
1264 ResetHits();
1265 }
1266 if (event2Check!=0) ievent=nevents;
1267 }
1268 fLoader->UnloadHits();
1269}
1270
1271//_____________________________________________________________________________
1272void
1273AliMUONData::DumpDigits(Int_t event2Check, Option_t* opt)
1274{
1275 // Loading data
1276 fLoader->LoadDigits("READ");
1277
1278 // Event loop
1279 Int_t firstEvent = 0;
1280 Int_t lastEvent = fRunLoader->GetNumberOfEvents()-1;
1281 if ( event2Check != 0 ) {
1282 firstEvent = event2Check;
1283 lastEvent = event2Check;
1284 }
1285
1286 for ( Int_t ievent = firstEvent; ievent <= lastEvent; ++ievent ) {
1287 printf(">>> Event %d \n",ievent);
1288 fRunLoader->GetEvent(ievent);
1289
1290 AliMUONDataIterator it(this, "digit", AliMUONDataIterator::kTrackingChambers);
1291 AliMUONDigit* digit;
1292
1293 while ( ( digit = (AliMUONDigit*)it.Next() ) )
1294 {
1295 digit->Print(opt);
1296 }
1297 }
1298 fLoader->UnloadDigits();
1299}
1300
1301//_____________________________________________________________________________
1302void
1303AliMUONData::DumpSDigits(Int_t event2Check, Option_t* opt)
1304{
1305 // Loading data
1306 fLoader->LoadSDigits("READ");
1307
1308 // Event loop
1309 Int_t nevents = fRunLoader->GetNumberOfEvents();
1310 for (Int_t ievent=0; ievent<nevents; ievent++) {
1311 if (event2Check!=0) ievent=event2Check;
1312 printf(">>> Event %d \n",ievent);
1313
1314 // Getting event ievent
1315 fRunLoader->GetEvent(ievent);
1316 SetTreeAddress("S");
1317 GetSDigits();
1318
1319 // Loop on chambers
1320 Int_t nchambers = AliMUONConstants::NCh(); ;
1321 for (Int_t ichamber=0; ichamber<nchambers; ichamber++) {
1322 TClonesArray* digits = SDigits(ichamber);
1323
1324 // Loop on Sdigits
1325 Int_t ndigits = (Int_t)digits->GetEntriesFast();
1326 for (Int_t idigit=0; idigit<ndigits; idigit++) {
1327 AliMUONDigit* mDigit = static_cast<AliMUONDigit*>(digits->At(idigit));
1328 mDigit->Print(opt);
1329 }
1330 }
1331 ResetSDigits();
1332 if (event2Check!=0) ievent=nevents;
1333 }
1334 fLoader->UnloadSDigits();
1335}
1336
1337//_____________________________________________________________________________
1338void
1339AliMUONData::DumpRecPoints(Int_t event2Check, Option_t* opt)
1340{
1341 // Loading data
1342 fLoader->LoadRecPoints("READ");
1343
1344 // Event loop
1345 Int_t nevents = fRunLoader->GetNumberOfEvents();
1346 for (Int_t ievent=0; ievent<nevents; ievent++) {
1347 if (event2Check!=0) ievent=event2Check;
1348 printf(">>> Event %d \n",ievent);
1349
1350 // Getting event ievent
1351 fRunLoader->GetEvent(ievent);
1352 Int_t nchambers = AliMUONConstants::NTrackingCh();
1353 SetTreeAddress("RC,TC");
1354 GetRawClusters();
1355
1356 // Loop on chambers
1357 for (Int_t ichamber=0; ichamber<nchambers; ichamber++) {
1358 char branchname[30];
1359 sprintf(branchname,"MUONRawClusters%d",ichamber+1);
1360 //printf(">>> branchname %s\n",branchname);
1361
1362 // Loop on rec points
1363 Int_t nrecpoints = (Int_t) RawClusters(ichamber)->GetEntriesFast();
1364 // printf(">>> Chamber %2d, Number of recpoints = %6d \n",ichamber+1, nrecpoints);
1365 for (Int_t irecpoint=0; irecpoint<nrecpoints; irecpoint++) {
1366 AliMUONRawCluster* mRecPoint = static_cast<AliMUONRawCluster*>(RawClusters(ichamber)->At(irecpoint));
1367 mRecPoint->Print(opt);
1368 }
1369 }
1370 ResetRawClusters();
1371 if (event2Check!=0) ievent=nevents;
1372 }
1373 fLoader->UnloadRecPoints();
1374}
1375
1376
1377//_____________________________________________________________________________
1378void
1379AliMUONData::DumpRecTrigger(Int_t event2Check,
1380 Int_t write, Bool_t readFromRP)
1381{
1382/// Reads and dumps trigger objects from MUON.RecPoints.root
1383
1384 TClonesArray * globalTrigger;
1385 TClonesArray * localTrigger;
1386
1387 // Do NOT print out all the info if the loop runs over all events
1388 Int_t printout = (event2Check == 0 ) ? 0 : 1 ;
1389
1390 // Book a ntuple for more detailled studies
1391 TNtuple *tupleGlo = new TNtuple("TgtupleGlo","Global Trigger Ntuple","ev:global:slpt:shpt:uplpt:uphpt:lplpt:lplpt");
1392 TNtuple *tupleLoc = new TNtuple("TgtupleLoc","Local Trigger Ntuple","ev:LoCircuit:LoStripX:LoDev:StripY:LoLpt:LoHpt:y11:y21:x11");
1393
1394 // counters
1395 Int_t sLowpt=0,sHighpt=0;
1396 Int_t uSLowpt=0,uSHighpt=0;
1397 Int_t lSLowpt=0,lSHighpt=0;
1398
1399 AliMUONTriggerCrateStore* crateManager = new AliMUONTriggerCrateStore();
1400 crateManager->ReadFromFile();
1401
1402 AliMUONGeometryTransformer* transformer = new AliMUONGeometryTransformer(kFALSE);
1403 transformer->ReadGeometryData("volpath.dat", "geometry.root");
1404
1405 TClonesArray* triggerCircuit = new TClonesArray("AliMUONTriggerCircuit", 234);
1406
1407 for (Int_t i = 0; i < AliMUONConstants::NTriggerCircuit(); i++) {
1408 AliMUONTriggerCircuit* c = new AliMUONTriggerCircuit();
1409 c->SetTransformer(transformer);
1410 c->Init(i,*crateManager);
1411 TClonesArray& circuit = *triggerCircuit;
1412 new(circuit[circuit.GetEntriesFast()])AliMUONTriggerCircuit(*c);
1413 delete c;
1414 }
1415
1416 Char_t fileName[30];
1417 if (!readFromRP) {
1418 AliInfoStream() << " reading from digits \n";
1419 fLoader->LoadDigits("READ");
1420 sprintf(fileName,"TriggerCheckFromDigits.root");
1421 } else {
1422 AliInfoStream() << " reading from RecPoints \n";
1423 fLoader->LoadRecPoints("READ");
1424 sprintf(fileName,"TriggerCheckFromRP.root");
1425 }
1426
1427
1428 AliMUONGlobalTrigger *gloTrg(0x0);
1429 AliMUONLocalTrigger *locTrg(0x0);
1430
1431 Int_t nevents = fRunLoader->GetNumberOfEvents();
1432 for (Int_t ievent=0; ievent<nevents; ievent++) {
1433 if (event2Check!=0) ievent=event2Check;
1434 if (ievent%100==0 || event2Check)
1435 AliInfoStream() << "Processing event " << ievent << endl;
1436 fRunLoader->GetEvent(ievent);
1437
1438 if (!readFromRP) {
1439 SetTreeAddress("D,GLT");
1440 GetTriggerD();
1441 } else {
1442 SetTreeAddress("RC,TC");
1443 GetTrigger();
1444 }
1445
1446 globalTrigger = GlobalTrigger();
1447 localTrigger = LocalTrigger();
1448
1449 Int_t nglobals = (Int_t) globalTrigger->GetEntriesFast(); // should be 1
1450 Int_t nlocals = (Int_t) localTrigger->GetEntriesFast(); // up to 234
1451 if (printout) printf("###################################################\n");
1452 if (printout) printf("event %d nglobal %d nlocal %d \n",ievent,nglobals,nlocals);
1453
1454 for (Int_t iglobal=0; iglobal<nglobals; iglobal++) { // Global Trigger
1455 gloTrg = static_cast<AliMUONGlobalTrigger*>(globalTrigger->At(iglobal));
1456
1457 sLowpt+=gloTrg->SingleLpt() ;
1458 sHighpt+=gloTrg->SingleHpt() ;
1459 uSLowpt+=gloTrg->PairUnlikeLpt();
1460 uSHighpt+=gloTrg->PairUnlikeHpt();
1461 lSLowpt+=gloTrg->PairLikeLpt();
1462 lSHighpt+=gloTrg->PairLikeHpt();
1463
1464 if (printout) gloTrg->Print("full");
1465
1466 } // end of loop on Global Trigger
1467
1468 for (Int_t ilocal=0; ilocal<nlocals; ilocal++) { // Local Trigger
1469 locTrg = static_cast<AliMUONLocalTrigger*>(localTrigger->At(ilocal));
1470
1471 if (locTrg->LoLpt()!=0) { // board is fired
1472
1473 if (printout) locTrg->Print("full");
1474
1475 AliMUONTriggerCircuit* circuit = (AliMUONTriggerCircuit*)triggerCircuit->At(locTrg->LoCircuit()-1);
1476
1477 tupleLoc->Fill(ievent,locTrg->LoCircuit(),locTrg->LoStripX(),locTrg->LoDev(),locTrg->LoStripY(),locTrg->LoLpt(),locTrg->LoHpt(),circuit->GetY11Pos(locTrg->LoStripX()),circuit->GetY21Pos(locTrg->LoStripX()+locTrg->LoDev()+1),circuit->GetX11Pos(locTrg->LoStripY()));
1478 }
1479
1480 } // end of loop on Local Trigger
1481
1482 // fill ntuple
1483 tupleGlo->Fill(ievent,nglobals,gloTrg->SingleLpt(),gloTrg->SingleHpt(),gloTrg->PairUnlikeLpt(),gloTrg->PairUnlikeHpt(),gloTrg->PairLikeLpt(),gloTrg->PairLikeHpt());
1484
1485 ResetTrigger();
1486 if (event2Check!=0) ievent=nevents;
1487 } // end loop on event
1488
1489 // Print out summary if loop ran over all event
1490 if (!event2Check){
1491
1492 printf("\n");
1493 printf("=============================================\n");
1494 printf("================ SUMMARY ==================\n");
1495 printf("\n");
1496 printf("Total number of events processed %d \n", (event2Check==0) ? nevents : 1);
1497 printf("\n");
1498 printf(" Global Trigger output Low pt High pt\n");
1499 printf(" number of Single :\t");
1500 printf("%i\t%i\t",sLowpt,sHighpt);
1501 printf("\n");
1502 printf(" number of UnlikeSign pair :\t");
1503 printf("%i\t%i\t",uSLowpt,uSHighpt);
1504 printf("\n");
1505 printf(" number of LikeSign pair :\t");
1506 printf("%i\t%i\t",lSLowpt,lSHighpt);
1507 printf("\n");
1508 printf("=============================================\n");
1509 fflush(stdout);
1510 }
1511
1512 if (write){
1513 TFile *myFile = new TFile(fileName, "RECREATE");
1514 tupleGlo->Write();
1515 tupleLoc->Write();
1516 myFile->Close();
1517 }
1518
1519 fLoader->UnloadRecPoints();
1520
1521 delete crateManager;
1522 delete transformer;
1523 delete triggerCircuit;
1524
1525}