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 ;
120 //____________________________________________________________________________
121 void AliPHOSGetter::CreateWhiteBoard() const
123 // Posts a few item to the white board (folders)
126 Post(fHeaderFile, "G") ;
129 Post(fHeaderFile, "H") ;
133 //____________________________________________________________________________
134 AliPHOSGetter * AliPHOSGetter::GetInstance()
136 // Returns the pointer of the unique instance already defined
138 AliPHOSGetter * rv = 0 ;
142 cout << "AliPHOSGetter::GetInstance ERROR: not yet initialized" << endl ;
147 //____________________________________________________________________________
148 AliPHOSGetter * AliPHOSGetter::GetInstance(const char* headerFile,
149 const char* branchTitle)
151 // Creates and returns the pointer of the unique instance
152 // Must be called only when the environment has changed
155 if ( fgObjGetter ) // delete it if already exists
158 fgObjGetter = new AliPHOSGetter(headerFile,branchTitle) ;
160 // Posts a few item to the white board (folders)
161 fgObjGetter->CreateWhiteBoard() ;
163 // Get the first event into the arrays posted on the white board
164 // branchTitle = 0, means simulation run and no event yet
166 fgObjGetter->Event(0) ;
172 //____________________________________________________________________________
173 const AliPHOS * AliPHOSGetter::PHOS() const
175 // returns the PHOS object
176 return ( (AliPHOS*)gAlice->GetDetector("PHOS") );
179 //____________________________________________________________________________
180 const AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
182 // retrieves the geometr from the folder
184 TString path("YSAlice/WhiteBoard/Geometry/PHOS/") ;
185 path += PHOS()->GetTitle() ;
186 return (AliPHOSGeometry*)gROOT->FindObjectAny(path.Data()) ;
189 //____________________________________________________________________________
190 void AliPHOSGetter::Post(const char * headerFile, const char * opt, const char * name, const Int_t event) const
192 // Adds a new folder for summable digits
194 TString foldertitle ;
196 foldertitle += event ;
200 TFolder * aliceF = (TFolder*)gROOT->FindObjectAny("YSAlice") ;
202 if ( strcmp(opt, "G") == 0 ) { // Geometry
203 // the hierarchy is //YSALICE/WhiteBoard/Geometry/PHOS/
204 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance(PHOS()->GetTitle(),"") ;
205 TFolder * geomF = (TFolder*)aliceF->FindObject("WhiteBoard/Geometry/PHOS") ;
207 cerr << "ERROR: AliPHOSGetter::Post G -> Folder WhiteBoard/Geometry/PHOS/" << " not found!" << endl;
211 geomF->Add((TObject*)geom) ;
213 } else if ( strcmp(opt, "H") == 0 ) { // Hits
214 // the hierarchy is //YSALICE/WhiteBoard/SDigits/PHOS/Hits
215 TClonesArray * hits = new TClonesArray("AliPHOSHit",1000) ;
216 hits->SetName("Hits") ;
217 TFolder * hitsF = (TFolder*)aliceF->FindObject("WhiteBoard/Hits/PHOS") ;
219 cerr << "ERROR: AliPHOSGetter::Post H -> Folder WhiteBoard/Hits/PHOS/" << " not found!" << endl;
225 } else if ( strcmp(opt, "S") == 0 ) { // summable digits
226 // the hierarchy is //YSALICE/WhiteBoard/SDigits/PHOS/headerFile/sdigitsname
227 // because you can have sdigits from several hit files for mixing
228 TClonesArray * sdigits = new TClonesArray("AliPHOSDigit",1000) ;
229 TString sdigitsName ;
233 sdigitsName = "SDigits" ;
234 sdigits->SetName( sdigitsName.Data() ) ;
235 TFolder * sdigitsF = (TFolder*)aliceF->FindObject("WhiteBoard/SDigits/PHOS") ;
236 TFolder * sdigitsF2 = 0 ;
237 TString subdir(headerFile) ;
238 if ( !(sdigitsF2=(TFolder*)sdigitsF->FindObject(subdir)) )
239 sdigitsF2 = sdigitsF->AddFolder(subdir, foldertitle);
241 if ( sdigitsF2->FindObject( sdigitsName.Data() ) ) {
242 if (fDebug.Contains("S"))
243 cerr <<"INFO: AliPHOSGetter::Post S -> Folder " << subdir << ", " << foldertitle
244 << " already exists!" << endl ;
249 cerr << "ERROR: AliPHOSGetter::Post S -> Folder WhiteBoard/SDigits/PHOS/" << subdir << " not created!" << endl;
253 sdigitsF2->Add(sdigits) ;
255 } else if ( strcmp(opt, "Ser") == 0 ) { // sdigizer
256 // the hierarchy is //YSALICE/tasks/Digitizer/PHOS/sdigitsname
257 AliPHOSSDigitizer * sdigitizer = new AliPHOSSDigitizer() ;
258 TString sdigitsName ;
262 sdigitsName = "SDigitizer" ;
263 sdigitizer->SetName( sdigitsName.Data() ) ;
264 TTask * sdigitsF = (TTask*)aliceF->FindObject("tasks/SDigitizer") ;
266 cerr << "ERROR: AliPHOSGetter::Post Ser -> Task tasks/SDigitizer" << " not found!" << endl;
269 TTask * phos = (TTask*)sdigitsF->GetListOfTasks()->FindObject("PHOS") ;
271 cerr <<"ERROR: AliPHOSGetter::Post Ser -> tasks/SDigitizer/PHOS" << " not found!" << endl;
274 AliPHOSSDigitizer * phossd = (AliPHOSSDigitizer*)phos->GetListOfTasks()->FindObject(sdigitsName.Data()) ;
276 if (fDebug.Contains("Ser"))
277 cout << "INFO: AliPHOSGetter::Post Ser -> Task " << sdigitsName.Data() << " already exists" << endl ;
280 phos->Add(sdigitizer) ;
283 } else if ( strcmp(opt, "D") == 0 ) { // digits
284 // the hierarchy is //YSALICE/WhiteBoard/Digits/PHOS/digitsname
285 TClonesArray * digits = new TClonesArray("AliPHOSDigit",20000) ;
290 digitsName = "Digits" ;
291 digits->SetName( digitsName.Data() ) ;
292 TFolder * digitsF = (TFolder*)aliceF->FindObject("WhiteBoard/Digits/PHOS") ;
294 cerr << "ERROR: AliPHOSGetter::Post D -> Folder WhiteBoard/Digits/PHOS/" << " not found!" << endl;
297 digitsF->SetTitle(foldertitle) ;
298 if ( digitsF->FindObject( digitsName.Data() ) ) {
299 if (fDebug.Contains("D"))
300 cerr <<"INFO: AliPHOSGetter::Post D -> Object " << digitsName.Data()
301 << " already exists!" << endl ;
305 digitsF->Add(digits) ;
307 } else if ( strcmp(opt, "Der") == 0 ) { // sdigizer
308 // the hierarchy is //YSALICE/tasks/Digitizer/PHOS/digitsname
309 AliPHOSDigitizer * digitizer = new AliPHOSDigitizer() ;
314 digitsName = "Digitizer" ;
315 digitizer->SetName( digitsName.Data() ) ;
316 TTask * digitsF = (TTask*)aliceF->FindObject("tasks/Digitizer") ;
318 cerr << "ERROR: AliPHOSGetter::Post Der -> Task tasks/Digitizer" << " not found!" << endl;
321 TTask * phos = (TTask*)digitsF->GetListOfTasks()->FindObject("PHOS") ;
323 cerr <<"ERROR: AliPHOSGetter::Post Der -> tasks/Digitizer/PHOS" << " not found!" << endl;
326 AliPHOSDigitizer * phosd = (AliPHOSDigitizer*)phos->GetListOfTasks()->FindObject(digitsName.Data()) ;
328 if (fDebug.Contains("Der"))
329 cout << "INFO: AliPHOSGetter::Post Der -> Task " << digitsName.Data() << " already exists" << endl ;
332 phos->Add(digitizer) ;
335 } else if ( strcmp(opt, "R") == 0 ) { // RecPoints
336 // the hierarchy is //YSALICE/WhiteBoard/RecPoints/PHOS/emc/recpointsname
337 // //YSALICE/WhiteBoard/RecPoints/PHOS/cpv/recpointsname
338 TObjArray * emcrp = new TObjArray(100) ;
339 TObjArray * cpvrp = new TObjArray(100) ;
340 TString recpointsName ;
342 recpointsName = name ;
344 recpointsName = "RecPoints" ;
345 emcrp->SetName( recpointsName.Data() ) ;
346 cpvrp->SetName( recpointsName.Data() ) ;
347 TFolder * emcrpF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/emc") ;
348 TFolder * cpvrpF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/cpv") ;
349 emcrpF->SetTitle(foldertitle) ;
350 cpvrpF->SetTitle(foldertitle) ;
351 if ( !emcrpF || !cpvrpF ) {
352 cerr << "ERROR: AliPHOSGetter::Post R -> Folder WhiteBoard/RecPoints/PHOS/emc(cpv)" << " not found!" << endl;
355 // TString title("PHOS Digits") ;
356 if ( emcrpF->FindObject( recpointsName.Data() ) || cpvrpF->FindObject( recpointsName.Data() ) ) {
357 if (fDebug.Contains("R"))
358 cerr <<"INFO: AliPHOSGetter::Post R -> Object " << recpointsName.Data()
359 << " already exists!" << endl ;
367 } else if ( strcmp(opt, "Rer") == 0 ) { // clusterizer
368 // the hierarchy is //YSALICE/tasks/Reconstructionner/PHOS/recpointsname
369 AliPHOSClusterizer * clusterizer;
370 if ( strstr(name, "clu-v1") != 0 )
371 clusterizer = new AliPHOSClusterizerv1() ;
373 cerr << "ERROR: AliPHOSGetter::Post Rer -> " << name << " unknown clusterizer version" << endl ;
376 TString recpointsName ;
378 recpointsName = name ;
380 recpointsName = "Clusterizer" ;
381 clusterizer->SetName( recpointsName.Data() ) ;
382 TTask * reF = (TTask*)aliceF->FindObject("tasks/Reconstructioner") ;
384 cerr << "ERROR: AliPHOSGetter::Post Rer -> Task tasks/Reconstructioner" << " not found!" << endl;
387 TTask * phos = (TTask*)reF->GetListOfTasks()->FindObject("PHOS") ;
389 cerr <<"ERROR: AliPHOSGetter::Post Rer -> tasks/Reconstructioner/PHOS" << " not found!" << endl;
392 AliPHOSClusterizer * phoscl = (AliPHOSClusterizer*)phos->GetListOfTasks()->FindObject(recpointsName.Data()) ;
394 if (fDebug.Contains("Rer"))
395 cout << "INFO: AliPHOSGetter::Post Rer -> Task " << recpointsName.Data() << " already exists" << endl ;
398 phos->Add(clusterizer) ;
401 } else if ( strcmp(opt, "T") == 0 ) { //TrackSegments
402 // the hierarchy is //YSALICE/WhiteBoard/TrackSegments/PHOS/tracksegmentsname
404 TClonesArray * tracksegments = new TClonesArray("AliPHOSTrackSegment", 200) ;
405 TString tracksegmentsName ;
407 tracksegmentsName = name ;
409 tracksegmentsName = "TrackSegments" ;
410 tracksegments->SetName( tracksegmentsName.Data() ) ;
411 TFolder * tracksegmentsF = (TFolder*)aliceF->FindObject("WhiteBoard/TrackSegments/PHOS") ;
412 tracksegmentsF->SetTitle(foldertitle) ;
413 if ( !tracksegmentsF) {
414 cerr << "ERROR: AliPHOSGetter::Post T -> Folder WhiteBoard/TrackSegments/PHOS" << " not found!" << endl;
417 if ( tracksegmentsF->FindObject( tracksegmentsName.Data() ) ) {
418 if (fDebug.Contains("T"))
419 cerr <<"INFO: AliPHOSGetter::Post T -> Object " << tracksegmentsName.Data()
420 << " already exists!" << endl ;
424 tracksegmentsF->Add(tracksegments) ;
426 } else if ( strcmp(opt, "Ter") == 0 ) { // TrackSegmentsMaker
427 // the hierarchy is //YSALICE/tasks/Reconstructionner/PHOS/tracksegmentsname
428 AliPHOSTrackSegmentMaker * tracksegmentmaker ;
429 if ( strstr(name, "tsm-v1") != 0 )
430 tracksegmentmaker = new AliPHOSTrackSegmentMakerv1() ;
432 cerr << "ERROR: AliPHOSGetter::Post Ter -> " << name << " unknown track segment maker version" << endl ;
435 TString tracksegmentsName ;
437 tracksegmentsName = name ;
439 tracksegmentsName = "TrackSegmentMaker" ;
440 tracksegmentmaker->SetName( tracksegmentsName.Data() ) ;
441 TTask * reF = (TTask*)aliceF->FindObject("tasks/Reconstructioner") ;
443 cerr << "ERROR: AliPHOSGetter::Post Ter -> Task tasks/Reconstructioner" << " not found!" << endl;
446 TTask * phos = (TTask*)reF->GetListOfTasks()->FindObject("PHOS") ;
448 cerr <<"ERROR: AliPHOSGetter::Post Ter -> tasks/Reconstructioner/PHOS" << " not found!" << endl;
451 AliPHOSTrackSegmentMaker * phosts = (AliPHOSTrackSegmentMaker*)phos->GetListOfTasks()->FindObject(tracksegmentsName.Data()) ;
453 if (fDebug.Contains("Ter"))
454 cout << "INFO: AliPHOSGetter::Post Ter -> Task " << tracksegmentsName.Data() << " already exists" << endl ;
457 phos->Add(tracksegmentmaker) ;
460 } else if ( strcmp(opt, "P") == 0 ) { // RecParticles
461 // the hierarchy is //YSALICE/WhiteBoard/RecParticles/PHOS/recparticlesname
463 TClonesArray * recparticles = new TClonesArray("AliPHOSRecParticle", 200) ;
464 TString recparticlesName ;
466 recparticlesName = name ;
468 recparticlesName = "RecParticles" ;
469 recparticles->SetName( recparticlesName.Data() ) ;
470 TFolder * recparticlesF = (TFolder*)aliceF->FindObject("WhiteBoard/RecParticles/PHOS") ;
471 recparticlesF->SetTitle(foldertitle) ;
472 if ( !recparticlesF) {
473 cerr << "ERROR: AliPHOSGetter::Post P -> Folder WhiteBoard/RecParticles/PHOS" << " not found!" << endl;
476 if ( recparticlesF->FindObject( recparticlesName.Data() ) ) {
477 if (fDebug.Contains("P"))
478 cerr <<"INFO: AliPHOSGetter::Post P -> Object " << recparticlesName.Data()
479 << " already exists!" << endl ;
483 recparticlesF->Add(recparticles) ;
485 } else if ( strcmp(opt, "Per") == 0 ) { // PID Maker
486 // the hierarchy is //YSALICE/tasks/Reconstructionner/PHOS/recparticlesname
488 if ( strstr(name, "pid-v1") != 0 )
489 pid = new AliPHOSPIDv1() ;
491 cerr << "ERROR: AliPHOSGetter::Post Per -> " << name << " unknown PID maker version" << endl ;
494 TString recparticlesName ;
496 recparticlesName = name ;
498 recparticlesName = "PID" ;
499 pid->SetName( recparticlesName.Data() ) ;
500 TTask * reF = (TTask*)aliceF->FindObject("tasks/Reconstructioner") ;
502 cerr << "ERROR: AliPHOSGetter::Post Per -> Task tasks/Reconstructioner" << " not found!" << endl;
505 TTask * phos = (TTask*)reF->GetListOfTasks()->FindObject("PHOS") ;
507 cerr <<"ERROR: AliPHOSGetter::Post Per -> tasks/Reconstructioner/PHOS" << " not found!" << endl;
510 AliPHOSPID * phospid = (AliPHOSPID*)phos->GetListOfTasks()->FindObject(recparticlesName.Data()) ;
512 if (fDebug.Contains("Per"))
513 cout << "INFO: AliPHOSGetter::Post Per -> Task " << recparticlesName.Data() << " already exists" << endl ;
519 else if ( strcmp(opt, "QA") == 0 ) { // Alarms
520 // the hierarchy is //YSALICE/WhiteBoard/Alarms/PHOS/
522 TFolder * alarmsF = new TFolder() ;
527 alarmsName = "Alarm with no name" ;
528 alarmsF->SetName( alarmsName.Data() ) ;
529 alarmsF->SetTitle(foldertitle) ;
530 TFolder * qaaF = (TFolder*)aliceF->FindObject("WhiteBoard/QAAlarms") ;
532 cerr << "ERROR: AliPHOSGetter::Post QA -> Folder WhiteBoard/QAAlarms/" << " not found!" << endl;
535 if ( qaaF->FindObject( alarmsName.Data() ) )
536 qaaF->RecursiveRemove( qaaF->FindObject( alarmsName.Data() ) ) ;
543 //____________________________________________________________________________
544 const TParticle * AliPHOSGetter::Primary(Int_t index) const
546 // Return primary particle numbered by <index>
551 Int_t primaryIndex = index % 10000000 ;
552 Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
554 if ( primaryList > 0 ) {
555 cout << " Getter does not support currently Mixing of primary " << endl ;
556 cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
560 return gAlice->Particle(primaryIndex) ;
564 //____________________________________________________________________________
565 void AliPHOSGetter::ReadTreeD()
567 // Read the digit tree gAlice->TreeD()
568 if(gAlice->TreeD()== 0){
569 cerr << "ERROR: AliPHOSGetter::ReadTreeD: can not read TreeD " << endl ;
573 TObjArray * lob = (TObjArray*)gAlice->TreeD()->GetListOfBranches() ;
575 TBranch * branch = 0 ;
576 TBranch * digitsbranch = 0 ;
577 TBranch * digitizerbranch = 0 ;
578 Bool_t phosfound = kFALSE, digitizerfound = kFALSE ;
580 while ( (branch = (TBranch*)next()) && (!phosfound || !digitizerfound) ) {
581 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
582 digitsbranch = branch ;
585 else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
586 digitizerbranch = branch ;
587 digitizerfound = kTRUE ;
591 if ( !phosfound || !digitizerfound ) {
592 cout << "WARNING: AliPHOSGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name " << fDigitsTitle << endl ;
598 if (EventNumber() == 0)
599 Post(fHeaderFile, "D", fDigitsTitle) ;
601 // Post the Digitizer
602 if (EventNumber() == 0)
603 Post(fHeaderFile, "Der", fDigitsTitle) ;
605 TClonesArray * digits = Digits(fDigitsTitle) ;
607 digitsbranch ->SetAddress(&digits) ;
609 AliPHOSDigitizer * digitizer = Digitizer(fDigitsTitle) ;
610 digitizerbranch->SetAddress(&digitizer) ;
612 digitsbranch ->GetEntry(0) ;
613 digitizerbranch->GetEntry(0) ;
617 //____________________________________________________________________________
618 void AliPHOSGetter::ReadTreeH()
620 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
622 if(gAlice->TreeH()== 0){
623 cerr << "ERROR: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
627 TBranch * hitsbranch = (TBranch*)gAlice->TreeH()->GetListOfBranches()->FindObject("PHOS") ;
629 cout << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ;
631 TClonesArray * hits = Hits() ;
633 hitsbranch->SetAddress(&hits) ;
634 hitsbranch->GetEntry(0) ;
638 //____________________________________________________________________________
639 void AliPHOSGetter::ReadTreeQA()
641 // Read the digit tree gAlice->TreeQA()
642 // so far only PHOS knows about this Tree
644 if(PHOS()->TreeQA()== 0){
645 cerr << "ERROR: AliPHOSGetter::ReadTreeQA: can not read TreeQA " << endl ;
649 TBranch * qabranch = PHOS()->TreeQA()->GetBranch("PHOS") ;
651 cout << "WARNING: AliPHOSGetter::ReadTreeQA -> Cannot find QA Alarms for PHOS" << endl ;
655 // Post the QA Alarms
656 Post(fHeaderFile, "QA", "PHOS") ;
657 TFolder * alarmsF = Alarms() ;
659 qabranch->SetAddress(&alarmsF) ;
660 qabranch->GetEntry(0) ;
664 //____________________________________________________________________________
665 void AliPHOSGetter::ReadTreeR()
667 // Read the reconstrunction tree gAlice->TreeR()
669 if(gAlice->TreeR()== 0){
670 cout << "ERROR: AliPHOSGetter::ReadTreeR: can not read TreeR " << endl ;
674 TObjArray * lob = (TObjArray*)gAlice->TreeR()->GetListOfBranches() ;
676 TBranch * branch = 0 ;
677 TBranch * emcbranch = 0 ;
678 TBranch * cpvbranch = 0 ;
679 TBranch * clusterizerbranch = 0 ;
680 Bool_t phosemcrpfound = kFALSE, phoscpvrpfound = kFALSE, clusterizerfound = kFALSE ;
682 while ( (branch = (TBranch*)next()) && (!phosemcrpfound || !phoscpvrpfound || !clusterizerfound) ) {
683 if ( (strcmp(branch->GetName(), "PHOSEmcRP")==0) && (strcmp(branch->GetTitle(), fRecPointsTitle)==0) ) {
685 phosemcrpfound = kTRUE ;
687 else if ( (strcmp(branch->GetName(), "PHOSCpvRP")==0) && (strcmp(branch->GetTitle(), fRecPointsTitle)==0) ) {
689 phoscpvrpfound = kTRUE ;
691 else if ( (strcmp(branch->GetName(), "AliPHOSClusterizer")==0) && (strcmp(branch->GetTitle(), fRecPointsTitle)==0) ) {
692 clusterizerbranch = branch ;
693 clusterizerfound = kTRUE ;
697 if ( !phosemcrpfound || !phoscpvrpfound || !clusterizerfound ) {
698 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find RecPoints and/or Clusterizer with name " << fRecPointsTitle << endl ;
702 // Post the RecPoints
703 if (EventNumber() == 0)
704 Post(fHeaderFile, "R", fRecPointsTitle) ;
706 // Post the Clusterizer
707 // Need the version first
708 AliPHOSClusterizer * clusterizer = 0 ;
709 clusterizerbranch->SetAddress(&clusterizer) ;
710 clusterizerbranch->GetEntry(0) ;
711 TString clusterizerName(fRecPointsTitle) ;
712 clusterizerName.Append(clusterizer->Version()) ;
713 if (EventNumber() == 0)
714 Post(fHeaderFile, "Rer", clusterizerName) ;
716 TObjArray * emcRecPoints = EmcRecPoints(fRecPointsTitle) ;
717 emcRecPoints->Delete() ;
718 emcbranch->SetAddress(&emcRecPoints) ;
720 TObjArray * cpvRecPoints = CpvRecPoints(fRecPointsTitle) ;
721 cpvRecPoints->Delete() ;
722 cpvbranch->SetAddress(&cpvRecPoints) ;
725 clusterizer = Clusterizer(clusterizerName) ;
726 clusterizerbranch->SetAddress(&clusterizer) ;
728 emcbranch ->GetEntry(0) ;
729 cpvbranch ->GetEntry(0) ;
730 clusterizerbranch->GetEntry(0) ;
734 TBranch * tsbranch = 0 ;
735 TBranch * tsmakerbranch = 0 ;
736 Bool_t phostsfound = kFALSE, tsmakerfound = kFALSE ;
738 while ( (branch = (TBranch*)next()) && (!phostsfound || !tsmakerfound) ) {
739 if ( (strcmp(branch->GetName(), "PHOSTS")==0) && (strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0) ) {
741 phostsfound = kTRUE ;
743 else if ( (strcmp(branch->GetName(), "AliPHOSTrackSegmentMaker")==0) && (strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0) ) {
744 tsmakerbranch = branch ;
745 tsmakerfound = kTRUE ;
749 if ( !phostsfound || !tsmakerfound ) {
750 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name " << fTrackSegmentsTitle << endl ;
754 // Post the TrackSegments
755 if (EventNumber() == 0)
756 Post(fHeaderFile, "T", fTrackSegmentsTitle) ;
758 // Post the TrackSegment Maker
759 // Need the version first
760 AliPHOSTrackSegmentMaker * tsmaker = 0 ;
761 tsmakerbranch->SetAddress(&tsmaker) ;
762 tsmakerbranch->GetEntry(0) ;
763 TString tsmakerName(fTrackSegmentsTitle) ;
764 tsmakerName.Append(tsmaker->Version()) ;
765 if (EventNumber() == 0)
766 Post(fHeaderFile, "Ter", tsmakerName) ;
768 TClonesArray * tracksegments = TrackSegments(fTrackSegmentsTitle) ;
769 tracksegments->Clear() ;
770 tsbranch->SetAddress(&tracksegments) ;
773 tsmaker = TrackSegmentMaker(tsmakerName) ;
774 tsmakerbranch->SetAddress(&tsmaker) ;
776 tsmakerbranch ->GetEntry(0) ;
777 tsbranch ->GetEntry(0) ;
781 TBranch * rpabranch = 0 ;
782 TBranch * pidbranch = 0 ;
783 Bool_t phosrpafound = kFALSE, pidfound = kFALSE ;
785 while ( (branch = (TBranch*)next()) && (!phosrpafound || !pidfound) ) {
786 if ( (strcmp(branch->GetName(), "PHOSRP")==0) && (strcmp(branch->GetTitle(), fRecParticlesTitle)==0) ) {
788 phosrpafound = kTRUE ;
790 else if ( (strcmp(branch->GetName(), "AliPHOSPID")==0) && (strcmp(branch->GetTitle(), fRecParticlesTitle)==0) ) {
796 if ( !phosrpafound || !pidfound ) {
797 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name " << fRecParticlesTitle << endl ;
801 // Post the RecParticles
802 if (EventNumber() == 0)
803 Post(fHeaderFile, "P", fRecParticlesTitle) ;
806 // Need the version first
807 AliPHOSPID * pid = 0 ;
808 pidbranch->SetAddress(&pid) ;
809 pidbranch->GetEntry(0) ;
810 TString pidName(fRecParticlesTitle) ;
811 pidName.Append(pid->Version()) ;
812 if (EventNumber() == 0)
813 Post(fHeaderFile, "Per", pidName) ;
815 TClonesArray * recParticles = RecParticles(fRecParticlesTitle) ;
816 recParticles->Clear() ;
817 rpabranch->SetAddress(&recParticles) ;
821 pidbranch->SetAddress(&pid) ;
823 pidbranch ->GetEntry(0) ;
824 rpabranch ->GetEntry(0) ;
828 //____________________________________________________________________________
829 void AliPHOSGetter::ReadTreeS()
831 // Read the summable digits tree gAlice->TreeS()
833 if(gAlice->TreeS()== 0){
834 cerr << "ERROR: AliPHOSGetter::ReadTreeS -> Cannot find TreeS " << endl ;
838 TObjArray * lob = (TObjArray*)gAlice->TreeS()->GetListOfBranches() ;
840 TBranch * branch = 0 ;
841 TBranch * sdigitsbranch = 0 ;
842 TBranch * sdigitizerbranch = 0 ;
843 Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
845 while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) {
846 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
847 sdigitsbranch = branch ;
850 else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
851 sdigitizerbranch = branch ;
852 sdigitizerfound = kTRUE ;
856 if ( !phosfound || !sdigitizerfound ) {
857 cout << "WARNING: AliPHOSGetter::ReadTreeS -> Cannot find SDigits and/or SDigitizer with name " << fSDigitsTitle << endl ;
862 if (EventNumber() == 0)
863 Post(fHeaderFile, "S", fSDigitsTitle) ;
865 // Post the SDigitizer
866 if (EventNumber() == 0)
867 Post(fHeaderFile, "Ser", fSDigitsTitle) ;
869 TClonesArray * sdigits = SDigits(fSDigitsTitle) ;
871 sdigitsbranch->SetAddress(&sdigits) ;
873 AliPHOSSDigitizer * sdigitizer = SDigitizer(fSDigitsTitle) ;
874 sdigitizerbranch->SetAddress(&sdigitizer) ;
876 sdigitsbranch->GetEvent(0) ;
877 sdigitizerbranch->GetEvent(0) ;
881 //____________________________________________________________________________
882 void AliPHOSGetter::ReadPrimaries()
884 // Reads specific branches of primaries
886 fNPrimaries = gAlice->GetNtrack();
888 // //Check, is it necessary to open new files
889 // TArrayI* events = fDigitizer->GetCurrentEvents() ;
890 // TClonesArray * filenames = fDigitizer->GetHeadersFiles() ;
892 // for(input = 0; input < filenames->GetEntriesFast(); input++){
894 // TObjString * filename = (TObjString *) filenames->At(input) ;
896 // //Test, if this file already open
897 // TFile *file = (TFile*) gROOT->GetFile( filename->GetString() ) ;
899 // file = new TFile( filename->GetString()) ;
902 // // Get Kine Tree from file
903 // // char treeName[20];
904 // // sprintf(treeName,"TreeK%d",events->At(input));
905 // // TTree * treeK = (TTree*)gDirectory->Get(treeName);
907 // // treeK->SetBranchAddress("Particles", &fParticleBuffer);
909 // // cout << "AliPHOSGetter: cannot find Kine Tree for event:" << events->At(input) << endl;
911 // // // Create the particle stack
912 // // if(!fParticles) fParticles = new TClonesArray("TParticle",1000);
913 // // // Build the pointer list
914 // // if(fParticleMap) { <----
915 // // fParticleMap->Clear();
916 // // fParticleMap->Expand(treeK->GetEntries());
918 // // fParticleMap = new TObjArray(treeK->GetEntries());
920 // // From gAlice->Particle(i)
923 // // if(!(*fParticleMap)[i]) {
924 // // Int_t nentries = fParticles->GetEntries();
926 // // // algorithmic way of getting entry index
927 // // // (primary particles are filled after secondaries)
929 // // if (i<fHeader.GetNprimary())
930 // // entry = i+fHeader.GetNsecondary();
932 // // entry = i-fHeader.GetNprimary();
934 // // // only check the algorithmic way and give
935 // // // the fatal error if it is wrong
936 // // if (entry != fParticleFileMap[i]) {
937 // // Fatal("Particle",
938 // // "!!!! The algorithmic way is WRONG: !!!\n entry: %d map: %d",
939 // // entry, fParticleFileMap[i]);
942 // // fTreeK->GetEntry(fParticleFileMap[i]);
943 // // new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
944 // // fParticleMap->AddAt((*fParticles)[nentries],i);
946 // // return (TParticle *) (*fParticleMap)[i];
953 // //scan over opened files and read corresponding TreeK##
957 //____________________________________________________________________________
958 void AliPHOSGetter::Event(Int_t event)
960 // Reads the content of all Tree's S, D and R
962 if ( event > gAlice->TreeE()->GetEntries() ) {
963 cerr << "ERROR: AliPHOSGetter::Event -> There are only " << gAlice->TreeE()->GetEntries() << " events in this file" << endl ;
967 gAlice->GetEvent(event) ;
968 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 ;