1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 29.05.2001 Yuri Kharlov:
20 Everywhere reading the treese TTree->GetEvent(i)
21 is replaced by reading the branches TBranch->GetEntry(0)
24 //_________________________________________________________________________
25 // A singleton. This class should be used in the analysis stage to get
26 // reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles,
27 // instead of directly reading them from galice.root file. This container
28 // ensures, that one reads Digits, made of these particular digits, RecPoints,
29 // made of these particular RecPoints, TrackSegments and RecParticles.
30 // This becomes non trivial if there are several identical branches, produced with
31 // different set of parameters.
33 // An example of how to use (see also class AliPHOSAnalyser):
34 // AliPHOSGetter * gime = AliPHOSGetter::GetInstance("galice.root","test") ;
35 // for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++)
36 // AliPHOSRecParticle * part = gime->RecParticle(1) ;
38 // please->GetEvent(event) ; // reads new event from galice.root
40 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
41 //*-- Completely redesigned by Dmitri Peressounko March 2001
43 //*-- YS June 2001 : renamed the original AliPHOSIndexToObject and make
44 //*-- systematic usage of TFolders without changing the interface
45 //////////////////////////////////////////////////////////////////////////////
48 // --- ROOT system ---
53 #include "TObjString.h"
56 // --- Standard library ---
59 // --- AliRoot header files ---
62 #include "AliPHOSGetter.h"
64 #include "AliPHOSDigitizer.h"
65 #include "AliPHOSSDigitizer.h"
66 #include "AliPHOSClusterizer.h"
67 #include "AliPHOSClusterizerv1.h"
68 #include "AliPHOSTrackSegmentMaker.h"
69 #include "AliPHOSTrackSegmentMakerv1.h"
70 #include "AliPHOSTrackSegment.h"
71 #include "AliPHOSPID.h"
72 #include "AliPHOSPIDv1.h"
73 #include "AliPHOSGeometry.h"
75 ClassImp(AliPHOSGetter)
77 AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
79 //____________________________________________________________________________
80 AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* branchTitle )
82 //Initialize all lists
84 fHeaderFile = headerFile ;
85 fSDigitsTitle = branchTitle ;
86 fDigitsTitle = branchTitle ;
87 fRecPointsTitle = branchTitle ;
88 fRecParticlesTitle = branchTitle ;
89 fTrackSegmentsTitle = branchTitle ;
91 fPrimaries = new TObjArray(1) ;
93 if ( fHeaderFile != "aliroot" ) { // to call the getter without a file
96 TFile * file = (TFile*) gROOT->GetFile(fHeaderFile.Data() ) ;
98 if(file == 0){ //if file was not opened yet, read gAlice
99 if(fHeaderFile.Contains("rfio")) // if we read file using HPSS
100 file = TFile::Open(fHeaderFile.Data(),"update") ;
102 file = new TFile(fHeaderFile.Data(),"update") ;
104 if (!file->IsOpen()) {
105 cerr << "ERROR : AliPHOSGetter::AliPHOSGetter -> Cannot open " << fHeaderFile.Data() << endl ;
109 gAlice = (AliRun *) file->Get("gAlice") ;
112 cerr << "ERROR : AliPHOSGetter::AliPHOSGetter -> Cannot find gAlice in " << fHeaderFile.Data() << endl ;
117 if ( PHOS()->TreeQA() )
121 //____________________________________________________________________________
122 void AliPHOSGetter::CreateWhiteBoard() const
124 // Posts a few item to the white board (folders)
127 Post(fHeaderFile, "G") ;
130 Post(fHeaderFile, "H") ;
134 //____________________________________________________________________________
135 AliPHOSGetter * AliPHOSGetter::GetInstance()
137 // Returns the pointer of the unique instance already defined
139 AliPHOSGetter * rv = 0 ;
143 cout << "AliPHOSGetter::GetInstance ERROR: not yet initialized" << endl ;
148 //____________________________________________________________________________
149 AliPHOSGetter * AliPHOSGetter::GetInstance(const char* headerFile,
150 const char* branchTitle)
152 // Creates and returns the pointer of the unique instance
153 // Must be called only when the environment has changed
156 if ( fgObjGetter ) // delete it if already exists
159 fgObjGetter = new AliPHOSGetter(headerFile,branchTitle) ;
161 // Posts a few item to the white board (folders)
162 fgObjGetter->CreateWhiteBoard() ;
164 // Get the first event into the arrays posted on the white board
165 // branchTitle = 0, means simulation run and no event yet
167 fgObjGetter->Event(0) ;
173 //____________________________________________________________________________
174 const AliPHOS * AliPHOSGetter::PHOS() const
176 // returns the PHOS object
177 return ( (AliPHOS*)gAlice->GetDetector("PHOS") );
180 //____________________________________________________________________________
181 const AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
183 // retrieves the geometr from the folder
185 TString path("YSAlice/WhiteBoard/Geometry/PHOS/") ;
186 path += PHOS()->GetTitle() ;
187 return (AliPHOSGeometry*)gROOT->FindObjectAny(path.Data()) ;
190 //____________________________________________________________________________
191 void AliPHOSGetter::Post(const char * headerFile, const char * opt, const char * name, const Int_t event) const
193 // Adds a new folder for summable digits
195 TString foldertitle ;
197 foldertitle += event ;
201 TFolder * aliceF = (TFolder*)gROOT->FindObjectAny("YSAlice") ;
203 if ( strcmp(opt, "G") == 0 ) { // Geometry
204 // the hierarchy is //YSALICE/WhiteBoard/Geometry/PHOS/
205 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance(PHOS()->GetTitle(),"") ;
206 TFolder * geomF = (TFolder*)aliceF->FindObject("WhiteBoard/Geometry/PHOS") ;
208 cerr << "ERROR: AliPHOSGetter::Post G -> Folder WhiteBoard/Geometry/PHOS/" << " not found!" << endl;
212 geomF->Add((TObject*)geom) ;
214 } else if ( strcmp(opt, "H") == 0 ) { // Hits
215 // the hierarchy is //YSALICE/WhiteBoard/SDigits/PHOS/Hits
216 TClonesArray * hits = new TClonesArray("AliPHOSHit",1000) ;
217 hits->SetName("Hits") ;
218 TFolder * hitsF = (TFolder*)aliceF->FindObject("WhiteBoard/Hits/PHOS") ;
220 cerr << "ERROR: AliPHOSGetter::Post H -> Folder WhiteBoard/Hits/PHOS/" << " not found!" << endl;
226 } else if ( strcmp(opt, "S") == 0 ) { // summable digits
227 // the hierarchy is //YSALICE/WhiteBoard/SDigits/PHOS/headerFile/sdigitsname
228 // because you can have sdigits from several hit files for mixing
229 TClonesArray * sdigits = new TClonesArray("AliPHOSDigit",1000) ;
230 TString sdigitsName ;
234 sdigitsName = "SDigits" ;
235 sdigits->SetName( sdigitsName.Data() ) ;
236 TFolder * sdigitsF = (TFolder*)aliceF->FindObject("WhiteBoard/SDigits/PHOS") ;
237 TFolder * sdigitsF2 = 0 ;
238 TString subdir(headerFile) ;
239 if ( !(sdigitsF2=(TFolder*)sdigitsF->FindObject(subdir)) )
240 sdigitsF2 = sdigitsF->AddFolder(subdir, foldertitle);
242 if ( sdigitsF2->FindObject( sdigitsName.Data() ) ) {
243 if (fDebug.Contains("S"))
244 cerr <<"INFO: AliPHOSGetter::Post S -> Folder " << subdir << ", " << foldertitle
245 << " already exists!" << endl ;
250 cerr << "ERROR: AliPHOSGetter::Post S -> Folder WhiteBoard/SDigits/PHOS/" << subdir << " not created!" << endl;
254 sdigitsF2->Add(sdigits) ;
256 } else if ( strcmp(opt, "Ser") == 0 ) { // sdigizer
257 // the hierarchy is //YSALICE/tasks/Digitizer/PHOS/sdigitsname
258 AliPHOSSDigitizer * sdigitizer = new AliPHOSSDigitizer() ;
259 TString sdigitsName ;
263 sdigitsName = "SDigitizer" ;
264 sdigitizer->SetName( sdigitsName.Data() ) ;
265 TTask * sdigitsF = (TTask*)aliceF->FindObject("tasks/SDigitizer") ;
267 cerr << "ERROR: AliPHOSGetter::Post Ser -> Task tasks/SDigitizer" << " not found!" << endl;
270 TTask * phos = (TTask*)sdigitsF->GetListOfTasks()->FindObject("PHOS") ;
272 cerr <<"ERROR: AliPHOSGetter::Post Ser -> tasks/SDigitizer/PHOS" << " not found!" << endl;
275 AliPHOSSDigitizer * phossd = (AliPHOSSDigitizer*)phos->GetListOfTasks()->FindObject(sdigitsName.Data()) ;
277 if (fDebug.Contains("Ser"))
278 cout << "INFO: AliPHOSGetter::Post Ser -> Task " << sdigitsName.Data() << " already exists" << endl ;
281 phos->Add(sdigitizer) ;
284 } else if ( strcmp(opt, "D") == 0 ) { // digits
285 // the hierarchy is //YSALICE/WhiteBoard/Digits/PHOS/digitsname
286 TClonesArray * digits = new TClonesArray("AliPHOSDigit",20000) ;
291 digitsName = "Digits" ;
292 digits->SetName( digitsName.Data() ) ;
293 TFolder * digitsF = (TFolder*)aliceF->FindObject("WhiteBoard/Digits/PHOS") ;
295 cerr << "ERROR: AliPHOSGetter::Post D -> Folder WhiteBoard/Digits/PHOS/" << " not found!" << endl;
298 digitsF->SetTitle(foldertitle) ;
299 if ( digitsF->FindObject( digitsName.Data() ) ) {
300 if (fDebug.Contains("D"))
301 cerr <<"INFO: AliPHOSGetter::Post D -> Object " << digitsName.Data()
302 << " already exists!" << endl ;
306 digitsF->Add(digits) ;
308 } else if ( strcmp(opt, "Der") == 0 ) { // sdigizer
309 // the hierarchy is //YSALICE/tasks/Digitizer/PHOS/digitsname
310 AliPHOSDigitizer * digitizer = new AliPHOSDigitizer() ;
315 digitsName = "Digitizer" ;
316 digitizer->SetName( digitsName.Data() ) ;
317 TTask * digitsF = (TTask*)aliceF->FindObject("tasks/Digitizer") ;
319 cerr << "ERROR: AliPHOSGetter::Post Der -> Task tasks/Digitizer" << " not found!" << endl;
322 TTask * phos = (TTask*)digitsF->GetListOfTasks()->FindObject("PHOS") ;
324 cerr <<"ERROR: AliPHOSGetter::Post Der -> tasks/Digitizer/PHOS" << " not found!" << endl;
327 AliPHOSDigitizer * phosd = (AliPHOSDigitizer*)phos->GetListOfTasks()->FindObject(digitsName.Data()) ;
329 if (fDebug.Contains("Der"))
330 cout << "INFO: AliPHOSGetter::Post Der -> Task " << digitsName.Data() << " already exists" << endl ;
333 phos->Add(digitizer) ;
336 } else if ( strcmp(opt, "R") == 0 ) { // RecPoints
337 // the hierarchy is //YSALICE/WhiteBoard/RecPoints/PHOS/emc/recpointsname
338 // //YSALICE/WhiteBoard/RecPoints/PHOS/cpv/recpointsname
339 TObjArray * emcrp = new TObjArray(100) ;
340 TObjArray * cpvrp = new TObjArray(100) ;
341 TString recpointsName ;
343 recpointsName = name ;
345 recpointsName = "RecPoints" ;
346 emcrp->SetName( recpointsName.Data() ) ;
347 cpvrp->SetName( recpointsName.Data() ) ;
348 TFolder * emcrpF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/emc") ;
349 TFolder * cpvrpF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/cpv") ;
350 emcrpF->SetTitle(foldertitle) ;
351 cpvrpF->SetTitle(foldertitle) ;
352 if ( !emcrpF || !cpvrpF ) {
353 cerr << "ERROR: AliPHOSGetter::Post R -> Folder WhiteBoard/RecPoints/PHOS/emc(cpv)" << " not found!" << endl;
356 // TString title("PHOS Digits") ;
357 if ( emcrpF->FindObject( recpointsName.Data() ) || cpvrpF->FindObject( recpointsName.Data() ) ) {
358 if (fDebug.Contains("R"))
359 cerr <<"INFO: AliPHOSGetter::Post R -> Object " << recpointsName.Data()
360 << " already exists!" << endl ;
368 } else if ( strcmp(opt, "Rer") == 0 ) { // clusterizer
369 // the hierarchy is //YSALICE/tasks/Reconstructionner/PHOS/recpointsname
370 AliPHOSClusterizer * clusterizer;
371 if ( strstr(name, "clu-v1") != 0 )
372 clusterizer = new AliPHOSClusterizerv1() ;
374 cerr << "ERROR: AliPHOSGetter::Post Rer -> " << name << " unknown clusterizer version" << endl ;
377 TString recpointsName ;
379 recpointsName = name ;
381 recpointsName = "Clusterizer" ;
382 clusterizer->SetName( recpointsName.Data() ) ;
383 TTask * reF = (TTask*)aliceF->FindObject("tasks/Reconstructioner") ;
385 cerr << "ERROR: AliPHOSGetter::Post Rer -> Task tasks/Reconstructioner" << " not found!" << endl;
388 TTask * phos = (TTask*)reF->GetListOfTasks()->FindObject("PHOS") ;
390 cerr <<"ERROR: AliPHOSGetter::Post Rer -> tasks/Reconstructioner/PHOS" << " not found!" << endl;
393 AliPHOSClusterizer * phoscl = (AliPHOSClusterizer*)phos->GetListOfTasks()->FindObject(recpointsName.Data()) ;
395 if (fDebug.Contains("Rer"))
396 cout << "INFO: AliPHOSGetter::Post Rer -> Task " << recpointsName.Data() << " already exists" << endl ;
399 phos->Add(clusterizer) ;
402 } else if ( strcmp(opt, "T") == 0 ) { //TrackSegments
403 // the hierarchy is //YSALICE/WhiteBoard/TrackSegments/PHOS/tracksegmentsname
405 TClonesArray * tracksegments = new TClonesArray("AliPHOSTrackSegment", 200) ;
406 TString tracksegmentsName ;
408 tracksegmentsName = name ;
410 tracksegmentsName = "TrackSegments" ;
411 tracksegments->SetName( tracksegmentsName.Data() ) ;
412 TFolder * tracksegmentsF = (TFolder*)aliceF->FindObject("WhiteBoard/TrackSegments/PHOS") ;
413 tracksegmentsF->SetTitle(foldertitle) ;
414 if ( !tracksegmentsF) {
415 cerr << "ERROR: AliPHOSGetter::Post T -> Folder WhiteBoard/TrackSegments/PHOS" << " not found!" << endl;
418 if ( tracksegmentsF->FindObject( tracksegmentsName.Data() ) ) {
419 if (fDebug.Contains("T"))
420 cerr <<"INFO: AliPHOSGetter::Post T -> Object " << tracksegmentsName.Data()
421 << " already exists!" << endl ;
425 tracksegmentsF->Add(tracksegments) ;
427 } else if ( strcmp(opt, "Ter") == 0 ) { // TrackSegmentsMaker
428 // the hierarchy is //YSALICE/tasks/Reconstructionner/PHOS/tracksegmentsname
429 AliPHOSTrackSegmentMaker * tracksegmentmaker ;
430 if ( strstr(name, "tsm-v1") != 0 )
431 tracksegmentmaker = new AliPHOSTrackSegmentMakerv1() ;
433 cerr << "ERROR: AliPHOSGetter::Post Ter -> " << name << " unknown track segment maker version" << endl ;
436 TString tracksegmentsName ;
438 tracksegmentsName = name ;
440 tracksegmentsName = "TrackSegmentMaker" ;
441 tracksegmentmaker->SetName( tracksegmentsName.Data() ) ;
442 TTask * reF = (TTask*)aliceF->FindObject("tasks/Reconstructioner") ;
444 cerr << "ERROR: AliPHOSGetter::Post Ter -> Task tasks/Reconstructioner" << " not found!" << endl;
447 TTask * phos = (TTask*)reF->GetListOfTasks()->FindObject("PHOS") ;
449 cerr <<"ERROR: AliPHOSGetter::Post Ter -> tasks/Reconstructioner/PHOS" << " not found!" << endl;
452 AliPHOSTrackSegmentMaker * phosts = (AliPHOSTrackSegmentMaker*)phos->GetListOfTasks()->FindObject(tracksegmentsName.Data()) ;
454 if (fDebug.Contains("Ter"))
455 cout << "INFO: AliPHOSGetter::Post Ter -> Task " << tracksegmentsName.Data() << " already exists" << endl ;
458 phos->Add(tracksegmentmaker) ;
461 } else if ( strcmp(opt, "P") == 0 ) { // RecParticles
462 // the hierarchy is //YSALICE/WhiteBoard/RecParticles/PHOS/recparticlesname
464 TClonesArray * recparticles = new TClonesArray("AliPHOSRecParticle", 200) ;
465 TString recparticlesName ;
467 recparticlesName = name ;
469 recparticlesName = "RecParticles" ;
470 recparticles->SetName( recparticlesName.Data() ) ;
471 TFolder * recparticlesF = (TFolder*)aliceF->FindObject("WhiteBoard/RecParticles/PHOS") ;
472 recparticlesF->SetTitle(foldertitle) ;
473 if ( !recparticlesF) {
474 cerr << "ERROR: AliPHOSGetter::Post P -> Folder WhiteBoard/RecParticles/PHOS" << " not found!" << endl;
477 if ( recparticlesF->FindObject( recparticlesName.Data() ) ) {
478 if (fDebug.Contains("P"))
479 cerr <<"INFO: AliPHOSGetter::Post P -> Object " << recparticlesName.Data()
480 << " already exists!" << endl ;
484 recparticlesF->Add(recparticles) ;
486 } else if ( strcmp(opt, "Per") == 0 ) { // PID Maker
487 // the hierarchy is //YSALICE/tasks/Reconstructionner/PHOS/recparticlesname
489 if ( strstr(name, "pid-v1") != 0 )
490 pid = new AliPHOSPIDv1() ;
492 cerr << "ERROR: AliPHOSGetter::Post Per -> " << name << " unknown PID maker version" << endl ;
495 TString recparticlesName ;
497 recparticlesName = name ;
499 recparticlesName = "PID" ;
500 pid->SetName( recparticlesName.Data() ) ;
501 TTask * reF = (TTask*)aliceF->FindObject("tasks/Reconstructioner") ;
503 cerr << "ERROR: AliPHOSGetter::Post Per -> Task tasks/Reconstructioner" << " not found!" << endl;
506 TTask * phos = (TTask*)reF->GetListOfTasks()->FindObject("PHOS") ;
508 cerr <<"ERROR: AliPHOSGetter::Post Per -> tasks/Reconstructioner/PHOS" << " not found!" << endl;
511 AliPHOSPID * phospid = (AliPHOSPID*)phos->GetListOfTasks()->FindObject(recparticlesName.Data()) ;
513 if (fDebug.Contains("Per"))
514 cout << "INFO: AliPHOSGetter::Post Per -> Task " << recparticlesName.Data() << " already exists" << endl ;
520 else if ( strcmp(opt, "QA") == 0 ) { // Alarms
521 // the hierarchy is //YSALICE/WhiteBoard/Alarms/PHOS/
523 TFolder * alarmsF = new TFolder() ;
528 alarmsName = "Alarm with no name" ;
529 alarmsF->SetName( alarmsName.Data() ) ;
530 alarmsF->SetTitle(foldertitle) ;
531 TFolder * qaaF = (TFolder*)aliceF->FindObject("WhiteBoard/QAAlarms") ;
533 cerr << "ERROR: AliPHOSGetter::Post QA -> Folder WhiteBoard/QAAlarms/" << " not found!" << endl;
536 if ( qaaF->FindObject( alarmsName.Data() ) )
537 qaaF->RecursiveRemove( qaaF->FindObject( alarmsName.Data() ) ) ;
544 //____________________________________________________________________________
545 const TParticle * AliPHOSGetter::Primary(Int_t index) const
547 // Return primary particle numbered by <index>
552 Int_t primaryIndex = index % 10000000 ;
553 Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
555 if ( primaryList > 0 ) {
556 cout << " Getter does not support currently Mixing of primary " << endl ;
557 cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
561 return gAlice->Particle(primaryIndex) ;
565 //____________________________________________________________________________
566 void AliPHOSGetter::ReadTreeD()
568 // Read the digit tree gAlice->TreeD()
569 if(gAlice->TreeD()== 0){
570 cerr << "ERROR: AliPHOSGetter::ReadTreeD: can not read TreeD " << endl ;
574 TObjArray * lob = (TObjArray*)gAlice->TreeD()->GetListOfBranches() ;
576 TBranch * branch = 0 ;
577 TBranch * digitsbranch = 0 ;
578 TBranch * digitizerbranch = 0 ;
579 Bool_t phosfound = kFALSE, digitizerfound = kFALSE ;
581 while ( (branch = (TBranch*)next()) && (!phosfound || !digitizerfound) ) {
582 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
583 digitsbranch = branch ;
586 else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
587 digitizerbranch = branch ;
588 digitizerfound = kTRUE ;
592 if ( !phosfound || !digitizerfound ) {
593 cout << "WARNING: AliPHOSGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name " << fDigitsTitle << endl ;
599 if (EventNumber() == 0)
600 Post(fHeaderFile, "D", fDigitsTitle) ;
602 // Post the Digitizer
603 if (EventNumber() == 0)
604 Post(fHeaderFile, "Der", fDigitsTitle) ;
606 TClonesArray * digits = Digits(fDigitsTitle) ;
608 digitsbranch ->SetAddress(&digits) ;
610 AliPHOSDigitizer * digitizer = Digitizer(fDigitsTitle) ;
611 digitizerbranch->SetAddress(&digitizer) ;
613 digitsbranch ->GetEntry(0) ;
614 digitizerbranch->GetEntry(0) ;
618 //____________________________________________________________________________
619 void AliPHOSGetter::ReadTreeH()
621 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
623 if(gAlice->TreeH()== 0){
624 cerr << "ERROR: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
628 TBranch * hitsbranch = (TBranch*)gAlice->TreeH()->GetListOfBranches()->FindObject("PHOS") ;
630 cout << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ;
632 TClonesArray * hits = Hits() ;
634 hitsbranch->SetAddress(&hits) ;
635 hitsbranch->GetEntry(0) ;
639 //____________________________________________________________________________
640 void AliPHOSGetter::ReadTreeQA()
642 // Read the digit tree gAlice->TreeQA()
643 // so far only PHOS knows about this Tree
645 if(PHOS()->TreeQA()== 0){
646 cerr << "ERROR: AliPHOSGetter::ReadTreeQA: can not read TreeQA " << endl ;
650 TBranch * qabranch = PHOS()->TreeQA()->GetBranch("PHOS") ;
652 cout << "WARNING: AliPHOSGetter::ReadTreeQA -> Cannot find QA Alarms for PHOS" << endl ;
656 // Post the QA Alarms
657 Post(fHeaderFile, "QA", "PHOS") ;
658 TFolder * alarmsF = Alarms() ;
660 qabranch->SetAddress(&alarmsF) ;
661 qabranch->GetEntry(0) ;
665 //____________________________________________________________________________
666 void AliPHOSGetter::ReadTreeR()
668 // Read the reconstrunction tree gAlice->TreeR()
670 if(gAlice->TreeR()== 0){
671 cout << "ERROR: AliPHOSGetter::ReadTreeR: can not read TreeR " << endl ;
675 TObjArray * lob = (TObjArray*)gAlice->TreeR()->GetListOfBranches() ;
677 TBranch * branch = 0 ;
678 TBranch * emcbranch = 0 ;
679 TBranch * cpvbranch = 0 ;
680 TBranch * clusterizerbranch = 0 ;
681 Bool_t phosemcrpfound = kFALSE, phoscpvrpfound = kFALSE, clusterizerfound = kFALSE ;
683 while ( (branch = (TBranch*)next()) && (!phosemcrpfound || !phoscpvrpfound || !clusterizerfound) ) {
684 if ( (strcmp(branch->GetName(), "PHOSEmcRP")==0) && (strcmp(branch->GetTitle(), fRecPointsTitle)==0) ) {
686 phosemcrpfound = kTRUE ;
688 else if ( (strcmp(branch->GetName(), "PHOSCpvRP")==0) && (strcmp(branch->GetTitle(), fRecPointsTitle)==0) ) {
690 phoscpvrpfound = kTRUE ;
692 else if ( (strcmp(branch->GetName(), "AliPHOSClusterizer")==0) && (strcmp(branch->GetTitle(), fRecPointsTitle)==0) ) {
693 clusterizerbranch = branch ;
694 clusterizerfound = kTRUE ;
698 if ( !phosemcrpfound || !phoscpvrpfound || !clusterizerfound ) {
699 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find RecPoints and/or Clusterizer with name " << fRecPointsTitle << endl ;
703 // Post the RecPoints
704 if (EventNumber() == 0)
705 Post(fHeaderFile, "R", fRecPointsTitle) ;
707 // Post the Clusterizer
708 // Need the version first
709 AliPHOSClusterizer * clusterizer = 0 ;
710 clusterizerbranch->SetAddress(&clusterizer) ;
711 clusterizerbranch->GetEntry(0) ;
712 TString clusterizerName(fRecPointsTitle) ;
713 clusterizerName.Append(clusterizer->Version()) ;
714 if (EventNumber() == 0)
715 Post(fHeaderFile, "Rer", clusterizerName) ;
717 TObjArray * emcRecPoints = EmcRecPoints(fRecPointsTitle) ;
718 emcRecPoints->Delete() ;
719 emcbranch->SetAddress(&emcRecPoints) ;
721 TObjArray * cpvRecPoints = CpvRecPoints(fRecPointsTitle) ;
722 cpvRecPoints->Delete() ;
723 cpvbranch->SetAddress(&cpvRecPoints) ;
726 clusterizer = Clusterizer(clusterizerName) ;
727 clusterizerbranch->SetAddress(&clusterizer) ;
729 emcbranch ->GetEntry(0) ;
730 cpvbranch ->GetEntry(0) ;
731 clusterizerbranch->GetEntry(0) ;
735 TBranch * tsbranch = 0 ;
736 TBranch * tsmakerbranch = 0 ;
737 Bool_t phostsfound = kFALSE, tsmakerfound = kFALSE ;
739 while ( (branch = (TBranch*)next()) && (!phostsfound || !tsmakerfound) ) {
740 if ( (strcmp(branch->GetName(), "PHOSTS")==0) && (strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0) ) {
742 phostsfound = kTRUE ;
744 else if ( (strcmp(branch->GetName(), "AliPHOSTrackSegmentMaker")==0) && (strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0) ) {
745 tsmakerbranch = branch ;
746 tsmakerfound = kTRUE ;
750 if ( !phostsfound || !tsmakerfound ) {
751 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name " << fTrackSegmentsTitle << endl ;
755 // Post the TrackSegments
756 if (EventNumber() == 0)
757 Post(fHeaderFile, "T", fTrackSegmentsTitle) ;
759 // Post the TrackSegment Maker
760 // Need the version first
761 AliPHOSTrackSegmentMaker * tsmaker = 0 ;
762 tsmakerbranch->SetAddress(&tsmaker) ;
763 tsmakerbranch->GetEntry(0) ;
764 TString tsmakerName(fTrackSegmentsTitle) ;
765 tsmakerName.Append(tsmaker->Version()) ;
766 if (EventNumber() == 0)
767 Post(fHeaderFile, "Ter", tsmakerName) ;
769 TClonesArray * tracksegments = TrackSegments(fTrackSegmentsTitle) ;
770 tracksegments->Clear() ;
771 tsbranch->SetAddress(&tracksegments) ;
774 tsmaker = TrackSegmentMaker(tsmakerName) ;
775 tsmakerbranch->SetAddress(&tsmaker) ;
777 tsmakerbranch ->GetEntry(0) ;
778 tsbranch ->GetEntry(0) ;
782 TBranch * rpabranch = 0 ;
783 TBranch * pidbranch = 0 ;
784 Bool_t phosrpafound = kFALSE, pidfound = kFALSE ;
786 while ( (branch = (TBranch*)next()) && (!phosrpafound || !pidfound) ) {
787 if ( (strcmp(branch->GetName(), "PHOSRP")==0) && (strcmp(branch->GetTitle(), fRecParticlesTitle)==0) ) {
789 phosrpafound = kTRUE ;
791 else if ( (strcmp(branch->GetName(), "AliPHOSPID")==0) && (strcmp(branch->GetTitle(), fRecParticlesTitle)==0) ) {
797 if ( !phosrpafound || !pidfound ) {
798 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name " << fRecParticlesTitle << endl ;
802 // Post the RecParticles
803 if (EventNumber() == 0)
804 Post(fHeaderFile, "P", fRecParticlesTitle) ;
807 // Need the version first
808 AliPHOSPID * pid = 0 ;
809 pidbranch->SetAddress(&pid) ;
810 pidbranch->GetEntry(0) ;
811 TString pidName(fRecParticlesTitle) ;
812 pidName.Append(pid->Version()) ;
813 if (EventNumber() == 0)
814 Post(fHeaderFile, "Per", pidName) ;
816 TClonesArray * recParticles = RecParticles(fRecParticlesTitle) ;
817 recParticles->Clear() ;
818 rpabranch->SetAddress(&recParticles) ;
822 pidbranch->SetAddress(&pid) ;
824 pidbranch ->GetEntry(0) ;
825 rpabranch ->GetEntry(0) ;
829 //____________________________________________________________________________
830 void AliPHOSGetter::ReadTreeS()
832 // Read the summable digits tree gAlice->TreeS()
834 if(gAlice->TreeS()== 0){
835 cerr << "ERROR: AliPHOSGetter::ReadTreeS -> Cannot find TreeS " << endl ;
839 TObjArray * lob = (TObjArray*)gAlice->TreeS()->GetListOfBranches() ;
841 TBranch * branch = 0 ;
842 TBranch * sdigitsbranch = 0 ;
843 TBranch * sdigitizerbranch = 0 ;
844 Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
846 while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) {
847 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
848 sdigitsbranch = branch ;
851 else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
852 sdigitizerbranch = branch ;
853 sdigitizerfound = kTRUE ;
857 if ( !phosfound || !sdigitizerfound ) {
858 cout << "WARNING: AliPHOSGetter::ReadTreeS -> Cannot find SDigits and/or SDigitizer with name " << fSDigitsTitle << endl ;
863 if (EventNumber() == 0)
864 Post(fHeaderFile, "S", fSDigitsTitle) ;
866 // Post the SDigitizer
867 if (EventNumber() == 0)
868 Post(fHeaderFile, "Ser", fSDigitsTitle) ;
870 TClonesArray * sdigits = SDigits(fSDigitsTitle) ;
872 sdigitsbranch->SetAddress(&sdigits) ;
874 AliPHOSSDigitizer * sdigitizer = SDigitizer(fSDigitsTitle) ;
875 sdigitizerbranch->SetAddress(&sdigitizer) ;
877 sdigitsbranch->GetEvent(0) ;
878 sdigitizerbranch->GetEvent(0) ;
882 //____________________________________________________________________________
883 void AliPHOSGetter::ReadPrimaries()
885 // Reads specific branches of primaries
887 fNPrimaries = gAlice->GetNtrack();
889 // //Check, is it necessary to open new files
890 // TArrayI* events = fDigitizer->GetCurrentEvents() ;
891 // TClonesArray * filenames = fDigitizer->GetHeadersFiles() ;
893 // for(input = 0; input < filenames->GetEntriesFast(); input++){
895 // TObjString * filename = (TObjString *) filenames->At(input) ;
897 // //Test, if this file already open
898 // TFile *file = (TFile*) gROOT->GetFile( filename->GetString() ) ;
900 // file = new TFile( filename->GetString()) ;
903 // // Get Kine Tree from file
904 // // char treeName[20];
905 // // sprintf(treeName,"TreeK%d",events->At(input));
906 // // TTree * treeK = (TTree*)gDirectory->Get(treeName);
908 // // treeK->SetBranchAddress("Particles", &fParticleBuffer);
910 // // cout << "AliPHOSGetter: cannot find Kine Tree for event:" << events->At(input) << endl;
912 // // // Create the particle stack
913 // // if(!fParticles) fParticles = new TClonesArray("TParticle",1000);
914 // // // Build the pointer list
915 // // if(fParticleMap) { <----
916 // // fParticleMap->Clear();
917 // // fParticleMap->Expand(treeK->GetEntries());
919 // // fParticleMap = new TObjArray(treeK->GetEntries());
921 // // From gAlice->Particle(i)
924 // // if(!(*fParticleMap)[i]) {
925 // // Int_t nentries = fParticles->GetEntries();
927 // // // algorithmic way of getting entry index
928 // // // (primary particles are filled after secondaries)
930 // // if (i<fHeader.GetNprimary())
931 // // entry = i+fHeader.GetNsecondary();
933 // // entry = i-fHeader.GetNprimary();
935 // // // only check the algorithmic way and give
936 // // // the fatal error if it is wrong
937 // // if (entry != fParticleFileMap[i]) {
938 // // Fatal("Particle",
939 // // "!!!! The algorithmic way is WRONG: !!!\n entry: %d map: %d",
940 // // entry, fParticleFileMap[i]);
943 // // fTreeK->GetEntry(fParticleFileMap[i]);
944 // // new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
945 // // fParticleMap->AddAt((*fParticles)[nentries],i);
947 // // return (TParticle *) (*fParticleMap)[i];
954 // //scan over opened files and read corresponding TreeK##
958 //____________________________________________________________________________
959 void AliPHOSGetter::Event(Int_t event)
961 // Reads the content of all Tree's S, D and R
963 if ( event > gAlice->TreeE()->GetEntries() ) {
964 cerr << "ERROR: AliPHOSGetter::Event -> There are only " << gAlice->TreeE()->GetEntries() << " events in this file" << endl ;
968 gAlice->GetEvent(event) ;
969 gAlice->SetEvent(event) ;
978 //____________________________________________________________________________
979 const TObject * AliPHOSGetter::ReturnO(TString what, TString name, TString file) const
981 // get the object named "what" from the folder
982 // folders are named like //YSAlice/WhiteBoard/what/PHOS/name
986 TString path("WhiteBoard/") ;
987 if ( name.IsNull() ) {
988 if ( what.CompareTo("Hits") == 0 ) {
993 else if ( what.CompareTo("SDigits") == 0 ) {
998 path += fSDigitsTitle ;
1000 else if ( what.CompareTo("Digits") == 0 ){
1003 path += fDigitsTitle ;
1005 else if ( what.CompareTo("EmcRecPoints") == 0 ) {
1006 path += "RecPoints/PHOS/";
1008 path += fRecPointsTitle ;
1010 else if ( what.CompareTo("CpvRecPoints") == 0 ) {
1011 path += "RecPoints/PHOS/";
1013 path += fRecPointsTitle ;
1015 else if ( what.CompareTo("TrackSegments") == 0 ) {
1016 path += "TrackSegments/PHOS/";
1017 path += fTrackSegmentsTitle ;
1019 else if ( what.CompareTo("RecParticles") == 0 ) {
1020 path += "RecParticles/PHOS/";
1021 path += fRecParticlesTitle ;
1023 else if ( what.CompareTo("Alarms") == 0 ) {
1024 path += "QAAlarms/PHOS";
1028 if ( what.CompareTo("SDigits") == 0 ) {
1035 else if ( what.CompareTo("Digits") == 0 ) {
1040 else if ( what.CompareTo("EmcRecPoints") == 0 ) {
1041 path += "RecPoints/PHOS/";
1045 else if ( what.CompareTo("CpvRecPoints") == 0 ) {
1046 path += "RecPoints/PHOS/";
1050 else if ( what.CompareTo("TrackSegments") == 0 ) {
1051 path += "TrackSegments/PHOS/";
1054 else if ( what.CompareTo("RecParticles") == 0 ) {
1055 path += "RecParticles/PHOS/";
1058 else if ( what.CompareTo("Alarms") == 0 ) {
1059 path += "QAAlarms/PHOS/";
1063 path.Prepend("YSAlice/") ;
1064 TObject * phosO = (TObject*)gROOT->FindObjectAny(path) ;
1066 cerr << "ERROR : AliPHOSGetter::ReturnO -> Object " << path << " not found!" << endl ;
1072 //____________________________________________________________________________
1073 const TTask * AliPHOSGetter::ReturnT(TString what, TString name) const
1075 // get the TTask named "what" from the folder
1076 // folders are named like //YSAlice/Tasks/what/PHOS/name
1078 TString path("tasks") ;
1080 if ( what.CompareTo("SDigitizer") == 0 )
1081 path += "/SDigitizer" ;
1082 else if ( what.CompareTo("Digitizer") == 0 )
1083 path += "/Digitizer" ;
1084 else if ( what.CompareTo("Clusterizer") == 0 )
1085 path += "/Reconstructioner" ;
1086 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
1087 path += "/Reconstructioner" ;
1088 else if ( what.CompareTo("PID") == 0 )
1089 path += "/Reconstructioner" ;
1090 else if ( what.CompareTo("QATasks") == 0 )
1093 TFolder * aliceF = (TFolder*)gROOT ->FindObjectAny("YSAlice") ;
1094 TTask * aliceT = (TTask*) aliceF->FindObject(path) ;
1097 cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << path << " not found!" << endl ;
1101 TTask * phosT = (TTask*) aliceT->GetListOfTasks()->FindObject("PHOS") ;
1103 cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << path << "/PHOS not found!" << endl ;
1106 TList * l = phosT->GetListOfTasks() ;
1108 if (what.CompareTo("SDigitizer") == 0) {
1109 if ( name.IsNull() )
1110 name = fSDigitsTitle ;
1111 } else if (what.CompareTo("Digitizer") == 0){
1112 if ( name.IsNull() )
1113 name = fDigitsTitle ;
1114 } else if (what.CompareTo("Clusterizer") == 0){
1115 if ( name.IsNull() )
1116 name = fRecPointsTitle ;
1118 else if (what.CompareTo("TrackSegmentMaker") == 0){
1119 if ( name.IsNull() )
1120 name = fTrackSegmentsTitle ;
1122 else if (what.CompareTo("PID") == 0){
1123 if ( name.IsNull() )
1124 name = fRecParticlesTitle ;
1126 else if (what.CompareTo("QATasks") == 0){
1127 if ( name.IsNull() )
1131 TTask * task = (TTask*)l->FindObject(name) ;
1134 cout << "WARNING: AliPHOSGetter::ReturnT -> Task " << path << "/" << name << " not found!" << endl ;