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 ;
119 //____________________________________________________________________________
120 void AliPHOSGetter::CreateWhiteBoard() const
122 // Posts a few item to the white board (folders)
125 Post(fHeaderFile, "G") ;
128 Post(fHeaderFile, "H") ;
132 //____________________________________________________________________________
133 AliPHOSGetter * AliPHOSGetter::GetInstance()
135 // Returns the pointer of the unique instance already defined
137 AliPHOSGetter * rv = 0 ;
141 cout << "AliPHOSGetter::GetInstance ERROR: not yet initialized" << endl ;
146 //____________________________________________________________________________
147 AliPHOSGetter * AliPHOSGetter::GetInstance(const char* headerFile,
148 const char* branchTitle)
150 // Creates and returns the pointer of the unique instance
151 // Must be called only when the environment has changed
154 if ( fgObjGetter ) // delete it if already exists
157 fgObjGetter = new AliPHOSGetter(headerFile,branchTitle) ;
159 // Posts a few item to the white board (folders)
160 fgObjGetter->CreateWhiteBoard() ;
162 // Get the first event into the arrays posted on the white board
163 // branchTitle = 0, means simulation run and no event yet
165 fgObjGetter->Event(0) ;
171 //____________________________________________________________________________
172 const AliPHOS * AliPHOSGetter::PHOS() const
174 // returns the PHOS object
175 return ( (AliPHOS*)gAlice->GetDetector("PHOS") );
178 //____________________________________________________________________________
179 const AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
181 // retrieves the geometr from the folder
183 TString path("YSAlice/WhiteBoard/Geometry/PHOS/") ;
184 path += PHOS()->GetTitle() ;
185 return (AliPHOSGeometry*)gROOT->FindObjectAny(path.Data()) ;
188 //____________________________________________________________________________
189 void AliPHOSGetter::Post(const char * headerFile, const char * opt, const char * name, const Int_t event) const
191 // Adds a new folder for summable digits
193 TString foldertitle ;
195 foldertitle += event ;
199 TFolder * aliceF = (TFolder*)gROOT->FindObjectAny("YSAlice") ;
201 if ( strcmp(opt, "G") == 0 ) { // Geometry
202 // the hierarchy is //YSALICE/WhiteBoard/Geometry/PHOS/
203 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance(PHOS()->GetTitle(),"") ;
204 TFolder * geomF = (TFolder*)aliceF->FindObject("WhiteBoard/Geometry/PHOS") ;
206 cerr << "ERROR: AliPHOSGetter::Post G -> Folder WhiteBoard/Geometry/PHOS/" << " not found!" << endl;
210 geomF->Add((TObject*)geom) ;
212 } else if ( strcmp(opt, "H") == 0 ) { // Hits
213 // the hierarchy is //YSALICE/WhiteBoard/SDigits/PHOS/Hits
214 TClonesArray * hits = new TClonesArray("AliPHOSHit",1000) ;
215 hits->SetName("Hits") ;
216 TFolder * hitsF = (TFolder*)aliceF->FindObject("WhiteBoard/Hits/PHOS") ;
218 cerr << "ERROR: AliPHOSGetter::Post H -> Folder WhiteBoard/Hits/PHOS/" << " not found!" << endl;
224 } else if ( strcmp(opt, "S") == 0 ) { // summable digits
225 // the hierarchy is //YSALICE/WhiteBoard/SDigits/PHOS/headerFile/sdigitsname
226 // because you can have sdigits from several hit files for mixing
227 TClonesArray * sdigits = new TClonesArray("AliPHOSDigit",1000) ;
228 TString sdigitsName ;
232 sdigitsName = "SDigits" ;
233 sdigits->SetName( sdigitsName.Data() ) ;
234 TFolder * sdigitsF = (TFolder*)aliceF->FindObject("WhiteBoard/SDigits/PHOS") ;
235 TFolder * sdigitsF2 = 0 ;
236 TString subdir(headerFile) ;
237 if ( !(sdigitsF2=(TFolder*)sdigitsF->FindObject(subdir)) )
238 sdigitsF2 = sdigitsF->AddFolder(subdir, foldertitle);
240 if ( sdigitsF2->FindObject( sdigitsName.Data() ) ) {
241 if (fDebug.Contains("S"))
242 cerr <<"INFO: AliPHOSGetter::Post S -> Folder " << subdir << ", " << foldertitle
243 << " already exists!" << endl ;
248 cerr << "ERROR: AliPHOSGetter::Post S -> Folder WhiteBoard/SDigits/PHOS/" << subdir << " not created!" << endl;
252 sdigitsF2->Add(sdigits) ;
254 } else if ( strcmp(opt, "Ser") == 0 ) { // sdigizer
255 // the hierarchy is //YSALICE/tasks/Digitizer/PHOS/sdigitsname
256 AliPHOSSDigitizer * sdigitizer = new AliPHOSSDigitizer() ;
257 TString sdigitsName ;
261 sdigitsName = "SDigitizer" ;
262 sdigitizer->SetName( sdigitsName.Data() ) ;
263 TTask * sdigitsF = (TTask*)aliceF->FindObject("tasks/SDigitizer") ;
265 cerr << "ERROR: AliPHOSGetter::Post Ser -> Task tasks/SDigitizer" << " not found!" << endl;
268 TTask * phos = (TTask*)sdigitsF->GetListOfTasks()->FindObject("PHOS") ;
270 cerr <<"ERROR: AliPHOSGetter::Post Ser -> tasks/SDigitizer/PHOS" << " not found!" << endl;
273 AliPHOSSDigitizer * phossd = (AliPHOSSDigitizer*)phos->GetListOfTasks()->FindObject(sdigitsName.Data()) ;
275 if (fDebug.Contains("Ser"))
276 cout << "INFO: AliPHOSGetter::Post Ser -> Task " << sdigitsName.Data() << " already exists" << endl ;
279 phos->Add(sdigitizer) ;
282 } else if ( strcmp(opt, "D") == 0 ) { // digits
283 // the hierarchy is //YSALICE/WhiteBoard/Digits/PHOS/digitsname
284 TClonesArray * digits = new TClonesArray("AliPHOSDigit",20000) ;
289 digitsName = "Digits" ;
290 digits->SetName( digitsName.Data() ) ;
291 TFolder * digitsF = (TFolder*)aliceF->FindObject("WhiteBoard/Digits/PHOS") ;
293 cerr << "ERROR: AliPHOSGetter::Post D -> Folder WhiteBoard/Digits/PHOS/" << " not found!" << endl;
296 digitsF->SetTitle(foldertitle) ;
297 if ( digitsF->FindObject( digitsName.Data() ) ) {
298 if (fDebug.Contains("D"))
299 cerr <<"INFO: AliPHOSGetter::Post D -> Object " << digitsName.Data()
300 << " already exists!" << endl ;
304 digitsF->Add(digits) ;
306 } else if ( strcmp(opt, "Der") == 0 ) { // sdigizer
307 // the hierarchy is //YSALICE/tasks/Digitizer/PHOS/digitsname
308 AliPHOSDigitizer * digitizer = new AliPHOSDigitizer() ;
313 digitsName = "Digitizer" ;
314 digitizer->SetName( digitsName.Data() ) ;
315 TTask * digitsF = (TTask*)aliceF->FindObject("tasks/Digitizer") ;
317 cerr << "ERROR: AliPHOSGetter::Post Der -> Task tasks/Digitizer" << " not found!" << endl;
320 TTask * phos = (TTask*)digitsF->GetListOfTasks()->FindObject("PHOS") ;
322 cerr <<"ERROR: AliPHOSGetter::Post Der -> tasks/Digitizer/PHOS" << " not found!" << endl;
325 AliPHOSDigitizer * phosd = (AliPHOSDigitizer*)phos->GetListOfTasks()->FindObject(digitsName.Data()) ;
327 if (fDebug.Contains("Der"))
328 cout << "INFO: AliPHOSGetter::Post Der -> Task " << digitsName.Data() << " already exists" << endl ;
331 phos->Add(digitizer) ;
334 } else if ( strcmp(opt, "R") == 0 ) { // RecPoints
335 // the hierarchy is //YSALICE/WhiteBoard/RecPoints/PHOS/emc/recpointsname
336 // //YSALICE/WhiteBoard/RecPoints/PHOS/cpv/recpointsname
337 TObjArray * emcrp = new TObjArray(100) ;
338 TObjArray * cpvrp = new TObjArray(100) ;
339 TString recpointsName ;
341 recpointsName = name ;
343 recpointsName = "RecPoints" ;
344 emcrp->SetName( recpointsName.Data() ) ;
345 cpvrp->SetName( recpointsName.Data() ) ;
346 TFolder * emcrpF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/emc") ;
347 TFolder * cpvrpF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/cpv") ;
348 emcrpF->SetTitle(foldertitle) ;
349 cpvrpF->SetTitle(foldertitle) ;
350 if ( !emcrpF || !cpvrpF ) {
351 cerr << "ERROR: AliPHOSGetter::Post R -> Folder WhiteBoard/RecPoints/PHOS/emc(cpv)" << " not found!" << endl;
354 // TString title("PHOS Digits") ;
355 if ( emcrpF->FindObject( recpointsName.Data() ) || cpvrpF->FindObject( recpointsName.Data() ) ) {
356 if (fDebug.Contains("R"))
357 cerr <<"INFO: AliPHOSGetter::Post R -> Object " << recpointsName.Data()
358 << " already exists!" << endl ;
366 } else if ( strcmp(opt, "Rer") == 0 ) { // clusterizer
367 // the hierarchy is //YSALICE/tasks/Reconstructionner/PHOS/recpointsname
368 AliPHOSClusterizer * clusterizer;
369 if ( strstr(name, "clu-v1") != 0 )
370 clusterizer = new AliPHOSClusterizerv1() ;
372 cerr << "ERROR: AliPHOSGetter::Post Rer -> " << name << " unknown clusterizer version" << endl ;
375 TString recpointsName ;
377 recpointsName = name ;
379 recpointsName = "Clusterizer" ;
380 clusterizer->SetName( recpointsName.Data() ) ;
381 TTask * reF = (TTask*)aliceF->FindObject("tasks/Reconstructioner") ;
383 cerr << "ERROR: AliPHOSGetter::Post Rer -> Task tasks/Reconstructioner" << " not found!" << endl;
386 TTask * phos = (TTask*)reF->GetListOfTasks()->FindObject("PHOS") ;
388 cerr <<"ERROR: AliPHOSGetter::Post Rer -> tasks/Reconstructioner/PHOS" << " not found!" << endl;
391 AliPHOSClusterizer * phoscl = (AliPHOSClusterizer*)phos->GetListOfTasks()->FindObject(recpointsName.Data()) ;
393 if (fDebug.Contains("Rer"))
394 cout << "INFO: AliPHOSGetter::Post Rer -> Task " << recpointsName.Data() << " already exists" << endl ;
397 phos->Add(clusterizer) ;
400 } else if ( strcmp(opt, "T") == 0 ) { //TrackSegments
401 // the hierarchy is //YSALICE/WhiteBoard/TrackSegments/PHOS/tracksegmentsname
403 TClonesArray * tracksegments = new TClonesArray("AliPHOSTrackSegment", 200) ;
404 TString tracksegmentsName ;
406 tracksegmentsName = name ;
408 tracksegmentsName = "TrackSegments" ;
409 tracksegments->SetName( tracksegmentsName.Data() ) ;
410 TFolder * tracksegmentsF = (TFolder*)aliceF->FindObject("WhiteBoard/TrackSegments/PHOS") ;
411 tracksegmentsF->SetTitle(foldertitle) ;
412 if ( !tracksegmentsF) {
413 cerr << "ERROR: AliPHOSGetter::Post T -> Folder WhiteBoard/TrackSegments/PHOS" << " not found!" << endl;
416 if ( tracksegmentsF->FindObject( tracksegmentsName.Data() ) ) {
417 if (fDebug.Contains("T"))
418 cerr <<"INFO: AliPHOSGetter::Post T -> Object " << tracksegmentsName.Data()
419 << " already exists!" << endl ;
423 tracksegmentsF->Add(tracksegments) ;
425 } else if ( strcmp(opt, "Ter") == 0 ) { // TrackSegmentsMaker
426 // the hierarchy is //YSALICE/tasks/Reconstructionner/PHOS/tracksegmentsname
427 AliPHOSTrackSegmentMaker * tracksegmentmaker ;
428 if ( strstr(name, "tsm-v1") != 0 )
429 tracksegmentmaker = new AliPHOSTrackSegmentMakerv1() ;
431 cerr << "ERROR: AliPHOSGetter::Post Ter -> " << name << " unknown track segment maker version" << endl ;
434 TString tracksegmentsName ;
436 tracksegmentsName = name ;
438 tracksegmentsName = "TrackSegmentMaker" ;
439 tracksegmentmaker->SetName( tracksegmentsName.Data() ) ;
440 TTask * reF = (TTask*)aliceF->FindObject("tasks/Reconstructioner") ;
442 cerr << "ERROR: AliPHOSGetter::Post Ter -> Task tasks/Reconstructioner" << " not found!" << endl;
445 TTask * phos = (TTask*)reF->GetListOfTasks()->FindObject("PHOS") ;
447 cerr <<"ERROR: AliPHOSGetter::Post Ter -> tasks/Reconstructioner/PHOS" << " not found!" << endl;
450 AliPHOSTrackSegmentMaker * phosts = (AliPHOSTrackSegmentMaker*)phos->GetListOfTasks()->FindObject(tracksegmentsName.Data()) ;
452 if (fDebug.Contains("Ter"))
453 cout << "INFO: AliPHOSGetter::Post Ter -> Task " << tracksegmentsName.Data() << " already exists" << endl ;
456 phos->Add(tracksegmentmaker) ;
459 } else if ( strcmp(opt, "P") == 0 ) { // RecParticles
460 // the hierarchy is //YSALICE/WhiteBoard/RecParticles/PHOS/recparticlesname
462 TClonesArray * recparticles = new TClonesArray("AliPHOSRecParticle", 200) ;
463 TString recparticlesName ;
465 recparticlesName = name ;
467 recparticlesName = "RecParticles" ;
468 recparticles->SetName( recparticlesName.Data() ) ;
469 TFolder * recparticlesF = (TFolder*)aliceF->FindObject("WhiteBoard/RecParticles/PHOS") ;
470 recparticlesF->SetTitle(foldertitle) ;
471 if ( !recparticlesF) {
472 cerr << "ERROR: AliPHOSGetter::Post P -> Folder WhiteBoard/RecParticles/PHOS" << " not found!" << endl;
475 if ( recparticlesF->FindObject( recparticlesName.Data() ) ) {
476 if (fDebug.Contains("P"))
477 cerr <<"INFO: AliPHOSGetter::Post P -> Object " << recparticlesName.Data()
478 << " already exists!" << endl ;
482 recparticlesF->Add(recparticles) ;
484 } else if ( strcmp(opt, "Per") == 0 ) { // PID Maker
485 // the hierarchy is //YSALICE/tasks/Reconstructionner/PHOS/recparticlesname
487 if ( strstr(name, "pid-v1") != 0 )
488 pid = new AliPHOSPIDv1() ;
490 cerr << "ERROR: AliPHOSGetter::Post Per -> " << name << " unknown PID maker version" << endl ;
493 TString recparticlesName ;
495 recparticlesName = name ;
497 recparticlesName = "PID" ;
498 pid->SetName( recparticlesName.Data() ) ;
499 TTask * reF = (TTask*)aliceF->FindObject("tasks/Reconstructioner") ;
501 cerr << "ERROR: AliPHOSGetter::Post Per -> Task tasks/Reconstructioner" << " not found!" << endl;
504 TTask * phos = (TTask*)reF->GetListOfTasks()->FindObject("PHOS") ;
506 cerr <<"ERROR: AliPHOSGetter::Post Per -> tasks/Reconstructioner/PHOS" << " not found!" << endl;
509 AliPHOSPID * phospid = (AliPHOSPID*)phos->GetListOfTasks()->FindObject(recparticlesName.Data()) ;
511 if (fDebug.Contains("Per"))
512 cout << "INFO: AliPHOSGetter::Post Per -> Task " << recparticlesName.Data() << " already exists" << endl ;
518 else if ( strcmp(opt, "QA") == 0 ) { // Alarms
519 // the hierarchy is //YSALICE/WhiteBoard/Alarms/PHOS/
521 TFolder * alarmsF = new TFolder() ;
526 alarmsName = "Alarm with no name" ;
527 alarmsF->SetName( alarmsName.Data() ) ;
528 alarmsF->SetTitle(foldertitle) ;
529 TFolder * qaaF = (TFolder*)aliceF->FindObject("WhiteBoard/QAAlarms") ;
531 cerr << "ERROR: AliPHOSGetter::Post QA -> Folder WhiteBoard/QAAlarms/" << " not found!" << endl;
534 if ( qaaF->FindObject( alarmsName.Data() ) )
535 qaaF->RecursiveRemove( qaaF->FindObject( alarmsName.Data() ) ) ;
542 //____________________________________________________________________________
543 const TParticle * AliPHOSGetter::Primary(Int_t index) const
545 // Return primary particle numbered by <index>
550 Int_t primaryIndex = index % 10000000 ;
551 Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
553 if ( primaryList > 0 ) {
554 cout << " Getter does not support currently Mixing of primary " << endl ;
555 cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
559 return gAlice->Particle(primaryIndex) ;
563 //____________________________________________________________________________
564 void AliPHOSGetter::ReadTreeD()
566 // Read the digit tree gAlice->TreeD()
567 if(gAlice->TreeD()== 0){
568 cerr << "ERROR: AliPHOSGetter::ReadTreeD: can not read TreeD " << endl ;
572 TObjArray * lob = (TObjArray*)gAlice->TreeD()->GetListOfBranches() ;
574 TBranch * branch = 0 ;
575 TBranch * digitsbranch = 0 ;
576 TBranch * digitizerbranch = 0 ;
577 Bool_t phosfound = kFALSE, digitizerfound = kFALSE ;
579 while ( (branch = (TBranch*)next()) && (!phosfound || !digitizerfound) ) {
580 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
581 digitsbranch = branch ;
584 else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
585 digitizerbranch = branch ;
586 digitizerfound = kTRUE ;
590 if ( !phosfound || !digitizerfound ) {
591 cerr << "WARNING: AliPHOSGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name " << fDigitsTitle << endl ;
597 if (EventNumber() == 0)
598 Post(fHeaderFile, "D", fDigitsTitle) ;
600 // Post the Digitizer
601 if (EventNumber() == 0)
602 Post(fHeaderFile, "Der", fDigitsTitle) ;
604 TClonesArray * digits = Digits(fDigitsTitle) ;
606 digitsbranch ->SetAddress(&digits) ;
608 AliPHOSDigitizer * digitizer = Digitizer(fDigitsTitle) ;
609 digitizerbranch->SetAddress(&digitizer) ;
611 digitsbranch ->GetEntry(0) ;
612 digitizerbranch->GetEntry(0) ;
616 //____________________________________________________________________________
617 void AliPHOSGetter::ReadTreeH()
619 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
621 if(gAlice->TreeH()== 0){
622 cerr << "ERROR: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
626 TBranch * hitsbranch = (TBranch*)gAlice->TreeH()->GetListOfBranches()->FindObject("PHOS") ;
628 cerr << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ;
630 TClonesArray * hits = Hits() ;
632 hitsbranch->SetAddress(&hits) ;
633 hitsbranch->GetEntry(0) ;
637 //____________________________________________________________________________
638 void AliPHOSGetter::ReadTreeQA()
640 // Read the digit tree gAlice->TreeQA()
641 // so far only PHOS knows about this Tree
643 if(PHOS()->TreeQA()== 0){
644 cerr << "ERROR: AliPHOSGetter::ReadTreeQA: can not read TreeQA " << endl ;
648 TBranch * qabranch = PHOS()->TreeQA()->GetBranch("PHOS") ;
650 cerr << "WARNING: AliPHOSGetter::ReadTreeQA -> Cannot find QA Alarms for PHOS" << endl ;
654 // Post the QA Alarms
655 Post(fHeaderFile, "QA", "PHOS") ;
656 TFolder * alarmsF = Alarms() ;
658 qabranch->SetAddress(&alarmsF) ;
659 qabranch->GetEntry(0) ;
663 //____________________________________________________________________________
664 void AliPHOSGetter::ReadTreeR()
666 // Read the reconstrunction tree gAlice->TreeR()
668 if(gAlice->TreeR()== 0){
669 cout << "ERROR: AliPHOSGetter::ReadTreeR: can not read TreeR " << endl ;
673 TObjArray * lob = (TObjArray*)gAlice->TreeR()->GetListOfBranches() ;
675 TBranch * branch = 0 ;
676 TBranch * emcbranch = 0 ;
677 TBranch * cpvbranch = 0 ;
678 TBranch * clusterizerbranch = 0 ;
679 Bool_t phosemcrpfound = kFALSE, phoscpvrpfound = kFALSE, clusterizerfound = kFALSE ;
681 while ( (branch = (TBranch*)next()) && (!phosemcrpfound || !phoscpvrpfound || !clusterizerfound) ) {
682 if ( (strcmp(branch->GetName(), "PHOSEmcRP")==0) && (strcmp(branch->GetTitle(), fRecPointsTitle)==0) ) {
684 phosemcrpfound = kTRUE ;
686 else if ( (strcmp(branch->GetName(), "PHOSCpvRP")==0) && (strcmp(branch->GetTitle(), fRecPointsTitle)==0) ) {
688 phoscpvrpfound = kTRUE ;
690 else if ( (strcmp(branch->GetName(), "AliPHOSClusterizer")==0) && (strcmp(branch->GetTitle(), fRecPointsTitle)==0) ) {
691 clusterizerbranch = branch ;
692 clusterizerfound = kTRUE ;
696 if ( !phosemcrpfound || !phoscpvrpfound || !clusterizerfound ) {
697 cerr << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find RecPoints and/or Clusterizer with name " << fRecPointsTitle << endl ;
701 // Post the RecPoints
702 if (EventNumber() == 0)
703 Post(fHeaderFile, "R", fRecPointsTitle) ;
705 // Post the Clusterizer
706 // Need the version first
707 AliPHOSClusterizer * clusterizer = 0 ;
708 clusterizerbranch->SetAddress(&clusterizer) ;
709 clusterizerbranch->GetEntry(0) ;
710 TString clusterizerName(fRecPointsTitle) ;
711 clusterizerName.Append(clusterizer->Version()) ;
712 if (EventNumber() == 0)
713 Post(fHeaderFile, "Rer", clusterizerName) ;
715 TObjArray * emcRecPoints = EmcRecPoints(fRecPointsTitle) ;
716 emcRecPoints->Delete() ;
717 emcbranch->SetAddress(&emcRecPoints) ;
719 TObjArray * cpvRecPoints = CpvRecPoints(fRecPointsTitle) ;
720 cpvRecPoints->Delete() ;
721 cpvbranch->SetAddress(&cpvRecPoints) ;
724 clusterizer = Clusterizer(clusterizerName) ;
725 clusterizerbranch->SetAddress(&clusterizer) ;
727 emcbranch ->GetEntry(0) ;
728 cpvbranch ->GetEntry(0) ;
729 clusterizerbranch->GetEntry(0) ;
733 TBranch * tsbranch = 0 ;
734 TBranch * tsmakerbranch = 0 ;
735 Bool_t phostsfound = kFALSE, tsmakerfound = kFALSE ;
737 while ( (branch = (TBranch*)next()) && (!phostsfound || !tsmakerfound) ) {
738 if ( (strcmp(branch->GetName(), "PHOSTS")==0) && (strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0) ) {
740 phostsfound = kTRUE ;
742 else if ( (strcmp(branch->GetName(), "AliPHOSTrackSegmentMaker")==0) && (strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0) ) {
743 tsmakerbranch = branch ;
744 tsmakerfound = kTRUE ;
748 if ( !phostsfound || !tsmakerfound ) {
749 cerr << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name " << fTrackSegmentsTitle << endl ;
753 // Post the TrackSegments
754 if (EventNumber() == 0)
755 Post(fHeaderFile, "T", fTrackSegmentsTitle) ;
757 // Post the TrackSegment Maker
758 // Need the version first
759 AliPHOSTrackSegmentMaker * tsmaker = 0 ;
760 tsmakerbranch->SetAddress(&tsmaker) ;
761 tsmakerbranch->GetEntry(0) ;
762 TString tsmakerName(fTrackSegmentsTitle) ;
763 tsmakerName.Append(tsmaker->Version()) ;
764 if (EventNumber() == 0)
765 Post(fHeaderFile, "Ter", tsmakerName) ;
767 TClonesArray * tracksegments = TrackSegments(fTrackSegmentsTitle) ;
768 tracksegments->Clear() ;
769 tsbranch->SetAddress(&tracksegments) ;
772 tsmaker = TrackSegmentMaker(tsmakerName) ;
773 tsmakerbranch->SetAddress(&tsmaker) ;
775 tsmakerbranch ->GetEntry(0) ;
776 tsbranch ->GetEntry(0) ;
780 TBranch * rpabranch = 0 ;
781 TBranch * pidbranch = 0 ;
782 Bool_t phosrpafound = kFALSE, pidfound = kFALSE ;
784 while ( (branch = (TBranch*)next()) && (!phosrpafound || !pidfound) ) {
785 if ( (strcmp(branch->GetName(), "PHOSRP")==0) && (strcmp(branch->GetTitle(), fRecParticlesTitle)==0) ) {
787 phosrpafound = kTRUE ;
789 else if ( (strcmp(branch->GetName(), "AliPHOSPID")==0) && (strcmp(branch->GetTitle(), fRecParticlesTitle)==0) ) {
795 if ( !phosrpafound || !pidfound ) {
796 cerr << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name " << fRecParticlesTitle << endl ;
800 // Post the RecParticles
801 if (EventNumber() == 0)
802 Post(fHeaderFile, "P", fRecParticlesTitle) ;
805 // Need the version first
806 AliPHOSPID * pid = 0 ;
807 pidbranch->SetAddress(&pid) ;
808 pidbranch->GetEntry(0) ;
809 TString pidName(fRecParticlesTitle) ;
810 pidName.Append(pid->Version()) ;
811 if (EventNumber() == 0)
812 Post(fHeaderFile, "Per", pidName) ;
814 TClonesArray * recParticles = RecParticles(fRecParticlesTitle) ;
815 recParticles->Clear() ;
816 rpabranch->SetAddress(&recParticles) ;
820 pidbranch->SetAddress(&pid) ;
822 pidbranch ->GetEntry(0) ;
823 rpabranch ->GetEntry(0) ;
827 //____________________________________________________________________________
828 void AliPHOSGetter::ReadTreeS()
830 // Read the summable digits tree gAlice->TreeS()
832 if(gAlice->TreeS()== 0){
833 cerr << "ERROR: AliPHOSGetter::ReadTreeS -> Cannot find TreeS " << endl ;
837 TObjArray * lob = (TObjArray*)gAlice->TreeS()->GetListOfBranches() ;
839 TBranch * branch = 0 ;
840 TBranch * sdigitsbranch = 0 ;
841 TBranch * sdigitizerbranch = 0 ;
842 Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
844 while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) {
845 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
846 sdigitsbranch = branch ;
849 else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
850 sdigitizerbranch = branch ;
851 sdigitizerfound = kTRUE ;
855 if ( !phosfound || !sdigitizerfound ) {
856 cerr << "WARNING: AliPHOSGetter::ReadTreeS -> Cannot find SDigits and/or SDigitizer with name " << fSDigitsTitle << endl ;
861 if (EventNumber() == 0)
862 Post(fHeaderFile, "S", fSDigitsTitle) ;
864 // Post the SDigitizer
865 if (EventNumber() == 0)
866 Post(fHeaderFile, "Ser", fSDigitsTitle) ;
868 TClonesArray * sdigits = SDigits(fSDigitsTitle) ;
870 sdigitsbranch->SetAddress(&sdigits) ;
872 AliPHOSSDigitizer * sdigitizer = SDigitizer(fSDigitsTitle) ;
873 sdigitizerbranch->SetAddress(&sdigitizer) ;
875 sdigitsbranch->GetEvent(0) ;
876 sdigitizerbranch->GetEvent(0) ;
880 //____________________________________________________________________________
881 void AliPHOSGetter::ReadPrimaries()
883 // Reads specific branches of primaries
885 fNPrimaries = gAlice->GetNtrack();
887 // //Check, is it necessary to open new files
888 // TArrayI* events = fDigitizer->GetCurrentEvents() ;
889 // TClonesArray * filenames = fDigitizer->GetHeadersFiles() ;
891 // for(input = 0; input < filenames->GetEntriesFast(); input++){
893 // TObjString * filename = (TObjString *) filenames->At(input) ;
895 // //Test, if this file already open
896 // TFile *file = (TFile*) gROOT->GetFile( filename->GetString() ) ;
898 // file = new TFile( filename->GetString()) ;
901 // // Get Kine Tree from file
902 // // char treeName[20];
903 // // sprintf(treeName,"TreeK%d",events->At(input));
904 // // TTree * treeK = (TTree*)gDirectory->Get(treeName);
906 // // treeK->SetBranchAddress("Particles", &fParticleBuffer);
908 // // cout << "AliPHOSGetter: cannot find Kine Tree for event:" << events->At(input) << endl;
910 // // // Create the particle stack
911 // // if(!fParticles) fParticles = new TClonesArray("TParticle",1000);
912 // // // Build the pointer list
913 // // if(fParticleMap) { <----
914 // // fParticleMap->Clear();
915 // // fParticleMap->Expand(treeK->GetEntries());
917 // // fParticleMap = new TObjArray(treeK->GetEntries());
919 // // From gAlice->Particle(i)
922 // // if(!(*fParticleMap)[i]) {
923 // // Int_t nentries = fParticles->GetEntries();
925 // // // algorithmic way of getting entry index
926 // // // (primary particles are filled after secondaries)
928 // // if (i<fHeader.GetNprimary())
929 // // entry = i+fHeader.GetNsecondary();
931 // // entry = i-fHeader.GetNprimary();
933 // // // only check the algorithmic way and give
934 // // // the fatal error if it is wrong
935 // // if (entry != fParticleFileMap[i]) {
936 // // Fatal("Particle",
937 // // "!!!! The algorithmic way is WRONG: !!!\n entry: %d map: %d",
938 // // entry, fParticleFileMap[i]);
941 // // fTreeK->GetEntry(fParticleFileMap[i]);
942 // // new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
943 // // fParticleMap->AddAt((*fParticles)[nentries],i);
945 // // return (TParticle *) (*fParticleMap)[i];
952 // //scan over opened files and read corresponding TreeK##
956 //____________________________________________________________________________
957 void AliPHOSGetter::Event(Int_t event)
959 // Reads the content of all Tree's S, D and R
961 if ( event > gAlice->TreeE()->GetEntries() ) {
962 cerr << "ERROR: AliPHOSGetter::Event -> There are only " << gAlice->TreeE()->GetEntries() << " events in this file" << endl ;
966 gAlice->GetEvent(event) ;
967 gAlice->SetEvent(event) ;
977 //____________________________________________________________________________
978 const TObject * AliPHOSGetter::ReturnO(TString what, TString name, TString file) const
980 // get the object named "what" from the folder
981 // folders are named like //YSAlice/WhiteBoard/what/PHOS/name
985 TString path("WhiteBoard/") ;
986 if ( name.IsNull() ) {
987 if ( what.CompareTo("Hits") == 0 ) {
992 else if ( what.CompareTo("SDigits") == 0 ) {
997 path += fSDigitsTitle ;
999 else if ( what.CompareTo("Digits") == 0 ){
1002 path += fDigitsTitle ;
1004 else if ( what.CompareTo("EmcRecPoints") == 0 ) {
1005 path += "RecPoints/PHOS/";
1007 path += fRecPointsTitle ;
1009 else if ( what.CompareTo("CpvRecPoints") == 0 ) {
1010 path += "RecPoints/PHOS/";
1012 path += fRecPointsTitle ;
1014 else if ( what.CompareTo("TrackSegments") == 0 ) {
1015 path += "TrackSegments/PHOS/";
1016 path += fTrackSegmentsTitle ;
1018 else if ( what.CompareTo("RecParticles") == 0 ) {
1019 path += "RecParticles/PHOS/";
1020 path += fRecParticlesTitle ;
1022 else if ( what.CompareTo("Alarms") == 0 ) {
1023 path += "QAAlarms/PHOS";
1027 if ( what.CompareTo("SDigits") == 0 ) {
1034 else if ( what.CompareTo("Digits") == 0 ) {
1039 else if ( what.CompareTo("EmcRecPoints") == 0 ) {
1040 path += "RecPoints/PHOS/";
1044 else if ( what.CompareTo("CpvRecPoints") == 0 ) {
1045 path += "RecPoints/PHOS/";
1049 else if ( what.CompareTo("TrackSegments") == 0 ) {
1050 path += "TrackSegments/PHOS/";
1053 else if ( what.CompareTo("RecParticles") == 0 ) {
1054 path += "RecParticles/PHOS/";
1057 else if ( what.CompareTo("Alarms") == 0 ) {
1058 path += "QAAlarms/PHOS/";
1062 path.Prepend("YSAlice/") ;
1063 TObject * phosO = (TObject*)gROOT->FindObjectAny(path) ;
1065 cerr << "ERROR : AliPHOSGetter::ReturnO -> Object " << path << " not found!" << endl ;
1071 //____________________________________________________________________________
1072 const TTask * AliPHOSGetter::ReturnT(TString what, TString name) const
1074 // get the TTask named "what" from the folder
1075 // folders are named like //YSAlice/Tasks/what/PHOS/name
1077 TString path("tasks") ;
1079 if ( what.CompareTo("SDigitizer") == 0 )
1080 path += "/SDigitizer" ;
1081 else if ( what.CompareTo("Digitizer") == 0 )
1082 path += "/Digitizer" ;
1083 else if ( what.CompareTo("Clusterizer") == 0 )
1084 path += "/Reconstructioner" ;
1085 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
1086 path += "/Reconstructioner" ;
1087 else if ( what.CompareTo("PID") == 0 )
1088 path += "/Reconstructioner" ;
1089 else if ( what.CompareTo("QATasks") == 0 )
1092 TFolder * aliceF = (TFolder*)gROOT ->FindObjectAny("YSAlice") ;
1093 TTask * aliceT = (TTask*) aliceF->FindObject(path) ;
1096 cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << path << " not found!" << endl ;
1100 TTask * phosT = (TTask*) aliceT->GetListOfTasks()->FindObject("PHOS") ;
1102 cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << path << "/PHOS not found!" << endl ;
1105 TList * l = phosT->GetListOfTasks() ;
1107 if (what.CompareTo("SDigitizer") == 0) {
1108 if ( name.IsNull() )
1109 name = fSDigitsTitle ;
1110 } else if (what.CompareTo("Digitizer") == 0){
1111 if ( name.IsNull() )
1112 name = fDigitsTitle ;
1113 } else if (what.CompareTo("Clusterizer") == 0){
1114 if ( name.IsNull() )
1115 name = fRecPointsTitle ;
1117 else if (what.CompareTo("TrackSegmentMaker") == 0){
1118 if ( name.IsNull() )
1119 name = fTrackSegmentsTitle ;
1121 else if (what.CompareTo("PID") == 0){
1122 if ( name.IsNull() )
1123 name = fRecParticlesTitle ;
1125 else if (what.CompareTo("QATasks") == 0){
1126 if ( name.IsNull() )
1130 TTask * task = (TTask*)l->FindObject(name) ;
1133 cout << "WARNING: AliPHOSGetter::ReturnT -> Task " << path << "/" << name << " not found!" << endl ;