]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - MUON/AliMUONData.cxx
Decoupling trigX and trigY in LocalTrigger (Philippe C.)
[u/mrichter/AliRoot.git] / MUON / AliMUONData.cxx
... / ...
CommitLineData
1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18/// \class AliMUONData
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/// \author Gines Martinez, Subatech, September 2003
24///
25
26#include "AliMUONData.h"
27#include "AliMUONDataIterator.h"
28#include "AliMUONConstants.h"
29#include "AliMUONHit.h"
30#include "AliMUONDigit.h"
31#include "AliMUONGlobalTrigger.h"
32#include "AliMUONLocalTrigger.h"
33#include "AliMUONRegionalTrigger.h"
34#include "AliMUONTriggerCrateStore.h"
35#include "AliMUONTriggerCircuit.h"
36#include "AliMUONGeometryTransformer.h"
37#include "AliMUONRawCluster.h"
38
39// This is from rec, classes in base should not depend on rec !!!
40#include "AliMUONTrack.h"
41#include "AliMUONTriggerTrack.h"
42
43#include "AliRunLoader.h"
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>
52
53/// \cond CLASSIMP
54ClassImp(AliMUONData)
55/// \endcond
56
57//_____________________________________________________________________________
58 AliMUONData::AliMUONData():
59 TNamed(),
60 fRunLoader(0x0),
61 fLoader(0x0),
62 fHits(0x0),
63 fDigits(0x0),
64 fSDigits(0x0),
65 fRawClusters(0x0),
66 fGlobalTrigger(0x0),
67 fLocalTrigger(0x0),
68 fRegionalTrigger(0x0),
69 fRecTracks(0x0),
70 fRecTriggerTracks(0x0),
71 fNhits(0),
72 fNdigits(0x0),
73 fNSdigits(0x0),
74 fNrawclusters(0x0),
75 fNglobaltrigger(0),
76 fNlocaltrigger(0),
77 fNregionaltrigger(0),
78 fNrectracks(0),
79 fNrectriggertracks(0),
80 fSplitLevel(0),
81 fCurrentEvent(-1)
82{
83/// Default constructor
84}
85//_____________________________________________________________________________
86AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
87 TNamed(name,title),
88 fRunLoader(0x0),
89 fLoader(loader),
90 fHits(0x0),
91 fDigits(0x0),
92 fSDigits(0x0),
93 fRawClusters(0x0),
94 fGlobalTrigger(0x0),
95 fLocalTrigger(0x0),
96 fRegionalTrigger(0x0),
97 fRecTracks(0x0),
98 fRecTriggerTracks(0x0),
99 fNhits(0),
100 fNdigits(0x0),
101 fNSdigits(0x0),
102 fNrawclusters(0x0),
103 fNglobaltrigger(0),
104 fNlocaltrigger(0),
105 fNregionaltrigger(0),
106 fNrectracks(0),
107 fNrectriggertracks(0),
108 fSplitLevel(0),
109 fCurrentEvent(-1)
110{
111/// Standard constructor
112}
113
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
155//_____________________________________________________________________________
156AliMUONData::~AliMUONData()
157{
158/// Destructor for AliMUONData
159 if (fHits) {
160 fHits->Delete();
161 delete fHits;
162 }
163
164 if (fDigits) {
165 fDigits->Delete();
166 delete fDigits;
167 }
168 if (fSDigits) {
169 fSDigits->Delete();
170 delete fSDigits;
171 }
172 if (fRawClusters) {
173 fRawClusters->Delete();
174 delete fRawClusters;
175 }
176 if (fGlobalTrigger){
177 fGlobalTrigger->Delete();
178 delete fGlobalTrigger;
179 }
180 if (fRegionalTrigger){
181 fRegionalTrigger->Delete();
182 delete fRegionalTrigger;
183 }
184 if (fLocalTrigger){
185 fLocalTrigger->Delete();
186 delete fLocalTrigger;
187 }
188 if (fRecTracks){
189 fRecTracks->Delete();
190 delete fRecTracks;
191 }
192 if (fRecTriggerTracks){
193 fRecTriggerTracks->Delete();
194 delete fRecTriggerTracks;
195 }
196
197 if (fRunLoader) {
198 fRunLoader->UnloadAll();
199 delete fRunLoader;
200 }
201}
202//____________________________________________________________________________
203void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t detElemId,
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
210
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,
216 Xref,Yref,Zref);
217}
218//_____________________________________________________________________________
219void AliMUONData::AddDigit(Int_t id, const AliMUONDigit& digit)
220{
221/// Add a MUON digit to the list of Digits of the detection plane id
222
223 TClonesArray &ldigits = * Digits(id) ;
224 new(ldigits[fNdigits[id]++]) AliMUONDigit(digit);
225}
226//_____________________________________________________________________________
227void AliMUONData::AddSDigit(Int_t id, const AliMUONDigit& Sdigit)
228{
229/// Add a MUON Sdigit to the list of SDigits of the detection plane id
230
231 TClonesArray &lSdigits = * SDigits(id) ;
232 new(lSdigits[fNSdigits[id]++]) AliMUONDigit(Sdigit);
233}
234
235//_____________________________________________________________________________
236void AliMUONData::AddGlobalTrigger(const AliMUONGlobalTrigger& trigger )
237{
238/// Add a MUON Global Trigger to the list (only one GlobalTrigger per event !);
239
240 TClonesArray &globalTrigger = *fGlobalTrigger;
241 new(globalTrigger[fNglobaltrigger++]) AliMUONGlobalTrigger(trigger);
242}
243
244//____________________________________________________________________________
245void AliMUONData::AddRegionalTrigger(const AliMUONRegionalTrigger& trigger)
246{
247/// add a MUON regional Trigger to the list
248 TClonesArray &regionalTrigger = *fRegionalTrigger;
249 new(regionalTrigger[fNregionaltrigger++]) AliMUONRegionalTrigger(trigger);
250}
251//____________________________________________________________________________
252void AliMUONData::AddLocalTrigger(const AliMUONLocalTrigger& trigger)
253{
254/// add a MUON Local Trigger to the list
255
256 TClonesArray &localTrigger = *fLocalTrigger;
257 new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(trigger);
258}
259
260//_____________________________________________________________________________
261void AliMUONData::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
262{
263/// Add a MUON rawcluster to the list in the detection plane id
264
265 TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id));
266 new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c);
267}
268//_____________________________________________________________________________
269void AliMUONData::AddRecTrack(const AliMUONTrack& track)
270{
271/// Add a MUON rectrack
272
273 TClonesArray &lrectracks = *fRecTracks;
274 new(lrectracks[fNrectracks++]) AliMUONTrack(track);
275}
276//_____________________________________________________________________________
277void AliMUONData::AddRecTriggerTrack(const AliMUONTriggerTrack& triggertrack)
278{
279/// Add a MUON triggerrectrack
280
281 TClonesArray &lrectriggertracks = *fRecTriggerTracks;
282 new(lrectriggertracks[fNrectriggertracks++]) AliMUONTriggerTrack(triggertrack);
283}
284//____________________________________________________________________________
285TClonesArray* AliMUONData::Digits(Int_t DetectionPlane) const
286{
287/// Getting List of Digits
288
289 if (fDigits)
290 return ( (TClonesArray*) fDigits->At(DetectionPlane) );
291 else
292 return NULL;
293}
294//____________________________________________________________________________
295TClonesArray* AliMUONData::SDigits(Int_t DetectionPlane) const
296{
297/// Getting List of SDigits
298
299 if (fSDigits)
300 return ( (TClonesArray*) fSDigits->At(DetectionPlane) );
301 else
302 return NULL;
303}
304//____________________________________________________________________________
305Bool_t AliMUONData::IsRawClusterBranchesInTree()
306{
307/// Checking if there are RawCluster Branches In TreeR
308
309 if (TreeR()==0x0) {
310 AliError("No treeR in memory");
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//____________________________________________________________________________
323Bool_t AliMUONData::IsDigitsBranchesInTree()
324{
325/// Checking if there are RawCluster Branches In TreeR
326
327 if (TreeD()==0x0) {
328 AliError("No treeD in memory");
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//____________________________________________________________________________
341Bool_t AliMUONData::IsTriggerBranchesInTree()
342{
343/// Checking if there are Trigger Branches In TreeR
344 if (TreeR()==0x0) {
345 AliError("No treeR in memory");
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}
357//____________________________________________________________________________
358Bool_t AliMUONData::IsTriggerBranchesInTreeD()
359{
360/// Checking if there are Trigger Branches In TreeR
361 if (TreeD()==0x0) {
362 AliError("No treeD in memory");
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
375//____________________________________________________________________________
376Bool_t AliMUONData::IsTrackBranchesInTree()
377{
378/// Checking if there are Track Branches In TreeT
379 if (TreeT()==0x0) {
380 AliError("No treeT in memory");
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{
395/// Checking if there are TriggerTrack Branches In TreeT
396 if (TreeT()==0x0) {
397 AliError("No treeT in memory");
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//____________________________________________________________________________
410void AliMUONData::Fill(Option_t* option)
411{
412/// Method to fill the trees
413 const char *cH = strstr(option,"H");
414 const char *cD = strstr(option,"D"); // Digits branches in TreeD
415 const char *cS = strstr(option,"S"); // SDigits branches in TreeS
416 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
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
419 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
420 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
421
422 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
423
424 char branchname[30];
425 TBranch * branch = 0x0;
426
427 // Filling TreeH
428 if ( TreeH() && cH )
429 {
430 TreeH()->Fill();
431 }
432
433 // Filling TreeD
434
435 if ( TreeD() && cD && cGLT )
436 {
437 // Writing digits and (global+local) trigger at once.
438 TreeD()->Fill();
439 }
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();
456 }
457 }
458
459 if ( TreeD() && cGLT )
460 {
461 if ( IsDigitsBranchesInTree() )
462 {
463 sprintf(branchname,"%sLocalTrigger",GetName());
464 branch = TreeD()->GetBranch(branchname);
465 branch->Fill();
466 sprintf(branchname,"%sRegionalTrigger",GetName());
467 branch = TreeD()->GetBranch(branchname);
468 branch->Fill();
469 sprintf(branchname,"%sGlobalTrigger",GetName());
470 branch = TreeD()->GetBranch(branchname);
471 branch->Fill();
472
473 }
474 else
475 {
476 TreeD()->Fill();
477 }
478 }
479 } // end of TreeD() handling.
480
481 // Filling TreeS
482 if ( TreeS() && cS)
483 {
484 TreeS()->Fill();
485 }
486
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 {
499 // Branch per branch filling
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();
521 sprintf(branchname,"%sRegionalTrigger",GetName());
522 branch = TreeR()->GetBranch(branchname);
523 branch->Fill();
524 sprintf(branchname,"%sGlobalTrigger",GetName());
525 branch = TreeR()->GetBranch(branchname);
526 branch->Fill();
527 }
528 else
529 {
530 TreeR()->Fill();
531 }
532 }
533 }
534
535 // Filling TreeT
536
537 if ( TreeT() && cRT && cRL )
538 {
539 TreeT()->Fill();
540 }
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 }
569 }
570 }
571}
572
573//_____________________________________________________________________________
574void AliMUONData::MakeBranch(Option_t* option)
575{
576/// Create Tree branches for the MUON.
577
578 const Int_t kBufferSize = 4000;
579 char branchname[30];
580
581 //Setting Data Container
582 SetDataContainer(option);
583
584 const char *cH = strstr(option,"H");
585 const char *cD = strstr(option,"D"); // Digits branches in TreeD
586 const char *cS = strstr(option,"S"); // Digits branches in TreeS
587 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
588 const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
589 const char *cTC = strstr(option,"TC"); // global and local Trigger branches Copy in TreeR
590 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
591 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
592 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
593
594 TBranch * branch = 0x0;
595
596 // Creating Branches for Hits
597 if (TreeH() && cH) {
598 sprintf(branchname,"%sHits",GetName());
599 branch = TreeH()->GetBranch(branchname);
600 if (branch) {
601 AliInfo(Form("MakeBranch","Branch %s is already in tree.",branchname));
602 return ;
603 }
604 branch = TreeH()->Branch(branchname,&fHits,kBufferSize);
605 //Info("MakeBranch","Making Branch %s for hits \n",branchname);
606 }
607
608 //Creating Branches for Digits
609 TTree* treeD = 0x0;
610 if ( cD || cGLT )
611 {
612 treeD = TreeD();
613 }
614
615 if ( treeD && cD )
616 {
617 // one branch for digits per chamber
618 for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++)
619 {
620 sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
621 branch = treeD->GetBranch(branchname);
622 if (branch)
623 {
624 AliInfo(Form("Branch %s is already in tree.",branchname));
625 return;
626 }
627 TClonesArray * digits = Digits(iDetectionPlane);
628 branch = treeD->Branch(branchname, &digits, kBufferSize,1);
629 }
630 }
631
632 if ( treeD && cGLT )
633 {
634 //
635 // one branch for global trigger
636 //
637 sprintf(branchname,"%sGlobalTrigger",GetName());
638 branch = treeD->GetBranch(branchname);
639 if (branch)
640 {
641 AliInfo(Form("Branch GlobalTrigger is already in treeD."));
642 return ;
643 }
644 branch = treeD->Branch(branchname, &fGlobalTrigger, kBufferSize);
645
646 //
647 // one branch for regional trigger
648 //
649 sprintf(branchname,"%sRegionalTrigger",GetName());
650 branch = 0x0;
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
660 //
661 // one branch for local trigger
662 //
663 sprintf(branchname,"%sLocalTrigger",GetName());
664 branch = 0x0;
665 branch = treeD->GetBranch(branchname);
666 if (branch)
667 {
668 AliInfo(Form("Branch LocalTrigger is already in treeD."));
669 return;
670 }
671 branch = treeD->Branch(branchname, &fLocalTrigger, kBufferSize);
672 }
673
674 //Creating Branches for SDigits
675 if (TreeS() && cS ) {
676 // one branch for Sdigits per chamber
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) {
682 AliInfo(Form("Branch %s is already in tree.",branchname));
683 return;
684 }
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);
688 }
689 }
690
691 if (TreeR() && cRC ) {
692 // one branch for raw clusters per tracking detection plane
693 //
694 Int_t i;
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) {
700 AliInfo(Form("Branch %s is already in tree.",branchname));
701 return;
702 }
703 branch = TreeR()->Branch(branchname, &((*fRawClusters)[i]),kBufferSize);
704 //Info("MakeBranch","Making Branch %s for rawcluster in detection plane %d\n",branchname,i+1);
705 }
706 }
707
708 if (TreeR() && cTC ) {
709 //
710 // one branch for global trigger
711 //
712 sprintf(branchname,"%sGlobalTrigger",GetName());
713 branch = 0x0;
714 branch = TreeR()->GetBranch(branchname);
715 if (branch) {
716 AliInfo(Form("Branch GlobalTrigger is already in treeR."));
717 return ;
718 }
719 branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize);
720 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
721
722 //
723 // one branch for regional trigger
724 //
725 sprintf(branchname,"%sRegionalTrigger",GetName());
726 branch = 0x0;
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
734 //
735 // one branch for local trigger
736 //
737 sprintf(branchname,"%sLocalTrigger",GetName());
738 branch = 0x0;
739 branch = TreeR()->GetBranch(branchname);
740 if (branch) {
741 AliInfo(Form("Branch LocalTrigger is already in treeR."));
742 return;
743 }
744 branch = TreeR()->Branch(branchname, &fLocalTrigger, kBufferSize);
745 //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
746 }
747
748 if (TreeT() && cRT ) {
749 sprintf(branchname,"%sTrack",GetName());
750 branch = TreeT()->GetBranch(branchname);
751 if (branch) {
752 AliInfo(Form("Branch %s is already in tree.",GetName()));
753 return ;
754 }
755 branch = TreeT()->Branch(branchname,&fRecTracks,kBufferSize);
756 //Info("MakeBranch","Making Branch %s for tracks \n",branchname);
757 }
758 // trigger tracks
759 if (TreeT() && cRL ) {
760 sprintf(branchname,"%sTriggerTrack",GetName());
761 branch = TreeT()->GetBranch(branchname);
762 if (branch) {
763 AliInfo(Form("Branch %s is already in tree.",GetName()));
764 return ;
765 }
766 branch = TreeT()->Branch(branchname,&fRecTriggerTracks,kBufferSize);
767 //Info("MakeBranch","Making Branch %s for trigger tracks \n",branchname);
768 }
769}
770//____________________________________________________________________________
771TClonesArray* AliMUONData::RawClusters(Int_t DetectionPlane)
772{
773/// Getting Raw Clusters
774
775 if (fRawClusters)
776 return ( (TClonesArray*) fRawClusters->At(DetectionPlane) );
777 else
778 return NULL;
779}
780
781//____________________________________________________________________________
782TClonesArray*
783AliMUONData::LocalTrigger() const
784{
785/// Getting local trigger
786
787 return fLocalTrigger;
788}
789
790//____________________________________________________________________________
791TClonesArray*
792AliMUONData::RegionalTrigger() const
793{
794/// Getting regional trigger
795
796 return fRegionalTrigger;
797}
798
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
811//____________________________________________________________________________
812void
813AliMUONData::GetDigits() const
814{
815/// Load the digits from TreeD for the current event.
816
817 Int_t event = fLoader->GetRunLoader()->GetEventNumber();
818 if ( fCurrentEvent != event )
819 {
820 if (fLoader->TreeD()) {
821 fLoader->TreeD()->GetEvent(0);
822 fCurrentEvent = event;
823 }
824 }
825}
826
827//____________________________________________________________________________
828TClonesArray*
829AliMUONData::GlobalTrigger() const
830{
831/// Return the global trigger
832
833 return fGlobalTrigger;
834}
835
836//____________________________________________________________________________
837void AliMUONData::ResetDigits()
838{
839/// Reset number of digits and the digits array for this detector
840
841 if (fDigits == 0x0) return;
842 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
843 if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear("C");
844 if (fNdigits) fNdigits[i]=0;
845 }
846}
847//____________________________________________________________________________
848void AliMUONData::ResetSDigits()
849{
850/// Reset number of Sdigits and the Sdigits array for this detector
851
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}
858//______________________________________________________________________________
859void AliMUONData::ResetHits()
860{
861/// Reset number of clusters and the cluster array for this detector
862
863 fNhits = 0;
864 if (fHits) fHits->Clear();
865}
866//_______________________________________________________________________________
867void AliMUONData::ResetRawClusters()
868{
869/// Reset number of raw clusters and the raw clust array for this detector
870
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{
879/// Reset Local and Global Trigger
880
881 fNglobaltrigger = 0;
882 if (fGlobalTrigger) fGlobalTrigger->Clear();
883 fNregionaltrigger = 0;
884 if (fRegionalTrigger) fRegionalTrigger->Clear();
885 fNlocaltrigger = 0;
886 if (fLocalTrigger) fLocalTrigger->Clear();
887
888}
889//____________________________________________________________________________
890void AliMUONData::ResetRecTracks()
891{
892/// Reset tracks information
893
894 fNrectracks = 0;
895 if (fRecTracks) fRecTracks->Delete(); // necessary to delete in case of memory allocation
896}
897//____________________________________________________________________________
898void AliMUONData::ResetRecTriggerTracks()
899{
900/// Reset tracks information
901
902 fNrectriggertracks = 0;
903 if (fRecTriggerTracks) fRecTriggerTracks->Delete(); // necessary to delete in case of memory allocation
904}
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 }
996 // ResetRawClusters();
997 // It breaks the correct functioning of the combined reconstruction (AZ)
998
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 }
1010 // ResetTrigger();
1011 // This is not necessary here since trigger info ins copied from digits info on flight to RecPoint output
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//____________________________________________________________________________
1031void AliMUONData::SetTreeAddress(Option_t* option)
1032{
1033 // Setting Data containers
1034 SetDataContainer(option);
1035
1036/// Setting Addresses to the events trees
1037
1038 const char *cH = strstr(option,"H");
1039 const char *cD = strstr(option,"D"); // Digits branches in TreeD
1040 const char *cS = strstr(option,"S"); // SDigits branches in TreeS
1041 const char *cRC = strstr(option,"RC"); // RawCluster branches in TreeR
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
1044 const char *cRT = strstr(option,"RT"); // Reconstructed Track in TreeT
1045 const char *cRL = strstr(option,"RL"); // Reconstructed Trigger Track in TreeT
1046 //const char *cRP = strstr(option,"RP"); // Reconstructed Particle in TreeP
1047
1048 // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree.
1049 char branchname[30];
1050 TBranch * branch = 0x0;
1051
1052 AliDebug(1,Form("option=%s",option));
1053 //
1054 // Branch address for hit tree
1055 if (TreeH() && fHits && cH) {
1056 sprintf(branchname,"%sHits",GetName());
1057 branch = TreeH()->GetBranch(branchname);
1058 if (branch) {
1059 // Info("SetTreeAddress","(%s) Setting for Hits",GetName());
1060 branch->SetAddress(&fHits);
1061 }
1062 else { //can be invoked before branch creation
1063 //AliWarning(Form("(%s) Failed for Hits. Can not find branch in tree.",GetName()));
1064 }
1065 }
1066
1067 //
1068 // Branch address for digit tree
1069 if (TreeD() && fDigits && cD) {
1070 for (int i=0; i<AliMUONConstants::NCh(); i++) {
1071 sprintf(branchname,"%sDigits%d",GetName(),i+1);
1072 if (fDigits) {
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));
1079 }
1080 }
1081 }
1082 if ( TreeD() && fLocalTrigger && cGLT) {
1083 sprintf(branchname,"%sLocalTrigger",GetName());
1084 branch = TreeD()->GetBranch(branchname);
1085 if (branch) branch->SetAddress(&fLocalTrigger);
1086 else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeD.",GetName()));
1087 }
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 }
1094 if ( TreeD() && fGlobalTrigger && cGLT) {
1095 sprintf(branchname,"%sGlobalTrigger",GetName());
1096 branch = TreeD()->GetBranch(branchname);
1097 if (branch) branch->SetAddress(&fGlobalTrigger);
1098 else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeD.",GetName()));
1099 }
1100
1101 //
1102 // Branch address for Sdigit tree
1103 if (TreeS() && fSDigits && cS) {
1104 AliDebug(1,"Setting branch addresses");
1105 for (int i=0; i<AliMUONConstants::NCh(); i++) {
1106 sprintf(branchname,"%sSDigits%d",GetName(),i+1);
1107 if (fSDigits) {
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));
1114 }
1115 }
1116 }
1117
1118 //
1119 // Branch address for rawclusters, globaltrigger and local trigger tree
1120 if ( TreeR() && fRawClusters && cRC && !strstr(cRC,"RCC")) {
1121 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
1122 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
1123 if (fRawClusters) {
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));
1127 }
1128 }
1129 }
1130 if ( TreeR() && fLocalTrigger && cTC) {
1131 sprintf(branchname,"%sLocalTrigger",GetName());
1132 branch = TreeR()->GetBranch(branchname);
1133 if (branch) branch->SetAddress(&fLocalTrigger);
1134 else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeR.",GetName()));
1135 }
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 }
1142 if ( TreeR() && fGlobalTrigger && cTC) {
1143 sprintf(branchname,"%sGlobalTrigger",GetName());
1144 branch = TreeR()->GetBranch(branchname);
1145 if (branch) branch->SetAddress(&fGlobalTrigger);
1146 else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeR.",GetName()));
1147 }
1148
1149 // Rec Trakcs
1150 if ( TreeT() && fRecTracks && cRT ) {
1151 sprintf(branchname,"%sTrack",GetName());
1152 branch = TreeT()->GetBranch(branchname);
1153 if (branch) branch->SetAddress(&fRecTracks);
1154 else AliWarning(Form("(%s) Failed for Tracks. Can not find branch in tree.",GetName()));
1155 }
1156 // Trigger tracks
1157 if ( TreeT() && fRecTriggerTracks && cRL ) {
1158 sprintf(branchname,"%sTriggerTrack",GetName());
1159 branch = TreeT()->GetBranch(branchname);
1160 if (branch) branch->SetAddress(&fRecTriggerTracks);
1161 else AliWarning(Form("(%s) Failed for Trigger Tracks. Can not find branch in tree.",GetName()));
1162 }
1163}
1164
1165//_____________________________________________________________________________
1166void
1167AliMUONData::Print(Option_t* opt) const
1168{
1169/// Dump object on screen
1170
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
1204}
1205
1206//_____________________________________________________________________________
1207void
1208AliMUONData::DumpKine(Int_t event2Check)
1209{
1210/// Dump kinematics
1211
1212 fRunLoader->LoadKinematics("READ");
1213
1214 Int_t nevents = fRunLoader->GetNumberOfEvents();
1215 for (Int_t ievent=0; ievent<nevents; ievent++) { // Event loop
1216 if ( event2Check != 0 ) ievent=event2Check;
1217
1218 // Getting event ievent
1219 fRunLoader->GetEvent(ievent);
1220
1221 // Stack of particle for this event
1222 AliStack* stack = fRunLoader->Stack();
1223
1224 Int_t nparticles = (Int_t) fRunLoader->Stack()->GetNtrack();
1225 printf(">>> Event %d, Number of particles is %d \n", ievent, nparticles);
1226
1227 for (Int_t iparticle=0; iparticle<nparticles; iparticle++) {
1228 stack->Particle(iparticle)->Print("");
1229 }
1230 if (event2Check!=0) ievent=nevents;
1231 }
1232 fRunLoader->UnloadKinematics();
1233}
1234
1235
1236//_____________________________________________________________________________
1237void
1238AliMUONData::DumpHits(Int_t event2Check, Option_t* opt)
1239{
1240/// Dump hits
1241
1242 fLoader->LoadHits("READ");
1243
1244 // Event loop
1245 Int_t nevents = fRunLoader->GetNumberOfEvents();
1246 for (Int_t ievent=0; ievent<nevents; ievent++) {
1247 if (event2Check!=0) ievent=event2Check;
1248 printf(">>> Event %d \n",ievent);
1249
1250 // Getting event ievent
1251 fRunLoader->GetEvent(ievent);
1252 SetTreeAddress("H");
1253
1254 // Track loop
1255 Int_t ntracks = (Int_t) GetNtracks();
1256 for (Int_t itrack=0; itrack<ntracks; itrack++) {
1257 //Getting List of Hits of Track itrack
1258 GetTrack(itrack);
1259
1260 Int_t nhits = (Int_t) Hits()->GetEntriesFast();
1261 printf(">>> Track %d, Number of hits %d \n",itrack,nhits);
1262 for (Int_t ihit=0; ihit<nhits; ihit++) {
1263 AliMUONHit* mHit = static_cast<AliMUONHit*>(Hits()->At(ihit));
1264 mHit->Print(opt);
1265 }
1266 ResetHits();
1267 }
1268 if (event2Check!=0) ievent=nevents;
1269 }
1270 fLoader->UnloadHits();
1271}
1272
1273//_____________________________________________________________________________
1274void
1275AliMUONData::DumpDigits(Int_t event2Check, Option_t* opt)
1276{
1277/// Dump digits
1278
1279 fLoader->LoadDigits("READ");
1280
1281 // Event loop
1282 Int_t firstEvent = 0;
1283 Int_t lastEvent = fRunLoader->GetNumberOfEvents()-1;
1284 if ( event2Check != 0 ) {
1285 firstEvent = event2Check;
1286 lastEvent = event2Check;
1287 }
1288
1289 for ( Int_t ievent = firstEvent; ievent <= lastEvent; ++ievent ) {
1290 printf(">>> Event %d \n",ievent);
1291 fRunLoader->GetEvent(ievent);
1292
1293 AliMUONDataIterator it(this, "digit", AliMUONDataIterator::kTrackingChambers);
1294 AliMUONDigit* digit;
1295
1296 while ( ( digit = (AliMUONDigit*)it.Next() ) )
1297 {
1298 digit->Print(opt);
1299 }
1300 }
1301 fLoader->UnloadDigits();
1302}
1303
1304//_____________________________________________________________________________
1305void
1306AliMUONData::DumpSDigits(Int_t event2Check, Option_t* opt)
1307{
1308/// Dump SDigits
1309
1310 fLoader->LoadSDigits("READ");
1311
1312 // Event loop
1313 Int_t nevents = fRunLoader->GetNumberOfEvents();
1314 for (Int_t ievent=0; ievent<nevents; ievent++) {
1315 if (event2Check!=0) ievent=event2Check;
1316 printf(">>> Event %d \n",ievent);
1317
1318 // Getting event ievent
1319 fRunLoader->GetEvent(ievent);
1320 SetTreeAddress("S");
1321 GetSDigits();
1322
1323 // Loop on chambers
1324 Int_t nchambers = AliMUONConstants::NCh(); ;
1325 for (Int_t ichamber=0; ichamber<nchambers; ichamber++) {
1326 TClonesArray* digits = SDigits(ichamber);
1327
1328 // Loop on Sdigits
1329 Int_t ndigits = (Int_t)digits->GetEntriesFast();
1330 for (Int_t idigit=0; idigit<ndigits; idigit++) {
1331 AliMUONDigit* mDigit = static_cast<AliMUONDigit*>(digits->At(idigit));
1332 mDigit->Print(opt);
1333 }
1334 }
1335 ResetSDigits();
1336 if (event2Check!=0) ievent=nevents;
1337 }
1338 fLoader->UnloadSDigits();
1339}
1340
1341//_____________________________________________________________________________
1342void
1343AliMUONData::DumpRecPoints(Int_t event2Check, Option_t* opt)
1344{
1345/// Dump rec points
1346
1347 fLoader->LoadRecPoints("READ");
1348
1349 // Event loop
1350 Int_t nevents = fRunLoader->GetNumberOfEvents();
1351 for (Int_t ievent=0; ievent<nevents; ievent++) {
1352 if (event2Check!=0) ievent=event2Check;
1353 printf(">>> Event %d \n",ievent);
1354
1355 // Getting event ievent
1356 fRunLoader->GetEvent(ievent);
1357 Int_t nchambers = AliMUONConstants::NTrackingCh();
1358 SetTreeAddress("RC,TC");
1359 GetRawClusters();
1360
1361 // Loop on chambers
1362 for (Int_t ichamber=0; ichamber<nchambers; ichamber++) {
1363 char branchname[30];
1364 sprintf(branchname,"MUONRawClusters%d",ichamber+1);
1365 //printf(">>> branchname %s\n",branchname);
1366
1367 // Loop on rec points
1368 Int_t nrecpoints = (Int_t) RawClusters(ichamber)->GetEntriesFast();
1369 // printf(">>> Chamber %2d, Number of recpoints = %6d \n",ichamber+1, nrecpoints);
1370 for (Int_t irecpoint=0; irecpoint<nrecpoints; irecpoint++) {
1371 AliMUONRawCluster* mRecPoint = static_cast<AliMUONRawCluster*>(RawClusters(ichamber)->At(irecpoint));
1372 mRecPoint->Print(opt);
1373 }
1374 }
1375 ResetRawClusters();
1376 if (event2Check!=0) ievent=nevents;
1377 }
1378 fLoader->UnloadRecPoints();
1379}
1380
1381
1382//_____________________________________________________________________________
1383void
1384AliMUONData::DumpRecTrigger(Int_t event2Check,
1385 Int_t write, Bool_t readFromRP)
1386{
1387/// Reads and dumps trigger objects from MUON.RecPoints.root
1388
1389 TClonesArray * globalTrigger;
1390 TClonesArray * localTrigger;
1391
1392 // Do NOT print out all the info if the loop runs over all events
1393 Int_t printout = (event2Check == 0 ) ? 0 : 1 ;
1394
1395 // Book a ntuple for more detailled studies
1396 TNtuple *tupleGlo = new TNtuple("TgtupleGlo","Global Trigger Ntuple","ev:global:slpt:shpt:uplpt:uphpt:lplpt:lplpt");
1397 TNtuple *tupleLoc = new TNtuple("TgtupleLoc","Local Trigger Ntuple","ev:LoCircuit:LoStripX:LoDev:StripY:LoLpt:LoHpt:y11:y21:x11");
1398
1399 // counters
1400 Int_t sLowpt=0,sHighpt=0;
1401 Int_t uSLowpt=0,uSHighpt=0;
1402 Int_t lSLowpt=0,lSHighpt=0;
1403
1404 AliMUONTriggerCrateStore* crateManager = new AliMUONTriggerCrateStore();
1405 crateManager->ReadFromFile();
1406
1407 AliMUONGeometryTransformer* transformer = new AliMUONGeometryTransformer(kFALSE);
1408 transformer->ReadGeometryData("volpath.dat", "geometry.root");
1409
1410 TClonesArray* triggerCircuit = new TClonesArray("AliMUONTriggerCircuit", 234);
1411
1412 for (Int_t i = 0; i < AliMUONConstants::NTriggerCircuit(); i++) {
1413 AliMUONTriggerCircuit* c = new AliMUONTriggerCircuit();
1414 c->SetTransformer(transformer);
1415 c->Init(i,*crateManager);
1416 TClonesArray& circuit = *triggerCircuit;
1417 new(circuit[circuit.GetEntriesFast()])AliMUONTriggerCircuit(*c);
1418 delete c;
1419 }
1420
1421 Char_t fileName[30];
1422 if (!readFromRP) {
1423 AliInfoStream() << " reading from digits \n";
1424 fLoader->LoadDigits("READ");
1425 sprintf(fileName,"TriggerCheckFromDigits.root");
1426 } else {
1427 AliInfoStream() << " reading from RecPoints \n";
1428 fLoader->LoadRecPoints("READ");
1429 sprintf(fileName,"TriggerCheckFromRP.root");
1430 }
1431
1432
1433 AliMUONGlobalTrigger *gloTrg(0x0);
1434 AliMUONLocalTrigger *locTrg(0x0);
1435
1436 Int_t nevents = fRunLoader->GetNumberOfEvents();
1437 for (Int_t ievent=0; ievent<nevents; ievent++) {
1438 if (event2Check!=0) ievent=event2Check;
1439 if (ievent%100==0 || event2Check)
1440 AliInfoStream() << "Processing event " << ievent << endl;
1441 fRunLoader->GetEvent(ievent);
1442
1443 if (!readFromRP) {
1444 SetTreeAddress("D,GLT");
1445 GetTriggerD();
1446 } else {
1447 SetTreeAddress("RC,TC");
1448 GetTrigger();
1449 }
1450
1451 globalTrigger = GlobalTrigger();
1452 localTrigger = LocalTrigger();
1453
1454 Int_t nglobals = (Int_t) globalTrigger->GetEntriesFast(); // should be 1
1455 Int_t nlocals = (Int_t) localTrigger->GetEntriesFast(); // up to 234
1456 if (printout) printf("###################################################\n");
1457 if (printout) printf("event %d nglobal %d nlocal %d \n",ievent,nglobals,nlocals);
1458
1459 for (Int_t iglobal=0; iglobal<nglobals; iglobal++) { // Global Trigger
1460 gloTrg = static_cast<AliMUONGlobalTrigger*>(globalTrigger->At(iglobal));
1461
1462 sLowpt+=gloTrg->SingleLpt() ;
1463 sHighpt+=gloTrg->SingleHpt() ;
1464 uSLowpt+=gloTrg->PairUnlikeLpt();
1465 uSHighpt+=gloTrg->PairUnlikeHpt();
1466 lSLowpt+=gloTrg->PairLikeLpt();
1467 lSHighpt+=gloTrg->PairLikeHpt();
1468
1469 if (printout) gloTrg->Print("full");
1470
1471 } // end of loop on Global Trigger
1472
1473 for (Int_t ilocal=0; ilocal<nlocals; ilocal++) { // Local Trigger
1474 locTrg = static_cast<AliMUONLocalTrigger*>(localTrigger->At(ilocal));
1475
1476 Bool_t xTrig=kFALSE;
1477 Bool_t yTrig=kFALSE;
1478
1479 if ( locTrg->LoSdev()==1 && locTrg->LoDev()==0 &&
1480 locTrg->LoStripX()==0) xTrig=kFALSE; // no trigger in X
1481 else xTrig=kTRUE; // trigger in X
1482 if (locTrg->LoTrigY()==1 &&
1483 locTrg->LoStripY()==15 ) yTrig = kFALSE; // no trigger in Y
1484 else yTrig = kTRUE; // trigger in Y
1485
1486 if (xTrig && yTrig) { // make Trigger Track if trigger in X and Y
1487
1488 if (printout) locTrg->Print("full");
1489
1490 AliMUONTriggerCircuit* circuit = (AliMUONTriggerCircuit*)triggerCircuit->At(locTrg->LoCircuit()-1);
1491
1492 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()));
1493 }
1494
1495 } // end of loop on Local Trigger
1496
1497 // fill ntuple
1498 tupleGlo->Fill(ievent,nglobals,gloTrg->SingleLpt(),gloTrg->SingleHpt(),gloTrg->PairUnlikeLpt(),gloTrg->PairUnlikeHpt(),gloTrg->PairLikeLpt(),gloTrg->PairLikeHpt());
1499
1500 ResetTrigger();
1501 if (event2Check!=0) ievent=nevents;
1502 } // end loop on event
1503
1504 // Print out summary if loop ran over all event
1505 if (!event2Check){
1506
1507 printf("\n");
1508 printf("=============================================\n");
1509 printf("================ SUMMARY ==================\n");
1510 printf("\n");
1511 printf("Total number of events processed %d \n", (event2Check==0) ? nevents : 1);
1512 printf("\n");
1513 printf(" Global Trigger output Low pt High pt\n");
1514 printf(" number of Single :\t");
1515 printf("%i\t%i\t",sLowpt,sHighpt);
1516 printf("\n");
1517 printf(" number of UnlikeSign pair :\t");
1518 printf("%i\t%i\t",uSLowpt,uSHighpt);
1519 printf("\n");
1520 printf(" number of LikeSign pair :\t");
1521 printf("%i\t%i\t",lSLowpt,lSHighpt);
1522 printf("\n");
1523 printf("=============================================\n");
1524 fflush(stdout);
1525 }
1526
1527 if (write){
1528 TFile *myFile = new TFile(fileName, "RECREATE");
1529 tupleGlo->Write();
1530 tupleLoc->Write();
1531 myFile->Close();
1532 }
1533
1534 fLoader->UnloadRecPoints();
1535
1536 delete crateManager;
1537 delete transformer;
1538 delete triggerCircuit;
1539
1540}