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 ;
118 //____________________________________________________________________________
119 void AliPHOSGetter::CreateWhiteBoard() const
121 // Posts a few item to the white board (folders)
124 Post(fHeaderFile, "G") ;
127 Post(fHeaderFile, "H") ;
131 //____________________________________________________________________________
132 AliPHOSGetter * AliPHOSGetter::GetInstance()
134 // Returns the pointer of the unique instance already defined
136 AliPHOSGetter * rv = 0 ;
140 cout << "AliPHOSGetter::GetInstance ERROR: not yet initialized" << endl ;
145 //____________________________________________________________________________
146 AliPHOSGetter * AliPHOSGetter::GetInstance(const char* headerFile,
147 const char* branchTitle)
149 // Creates and returns the pointer of the unique instance
150 // Must be called only when the environment has changed
153 if ( fgObjGetter ) // delete it if already exists
156 fgObjGetter = new AliPHOSGetter(headerFile,branchTitle) ;
158 // Posts a few item to the white board (folders)
159 fgObjGetter->CreateWhiteBoard() ;
161 // Get the first event into the arrays posted on the white board
162 // branchTitle = 0, means simulation run and no event yet
164 fgObjGetter->Event(0) ;
170 //____________________________________________________________________________
171 const AliPHOS * AliPHOSGetter::PHOS() const
173 // returns the PHOS object
174 return ( (AliPHOS*)gAlice->GetDetector("PHOS") );
177 //____________________________________________________________________________
178 const AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
180 // retrieves the geometr from the folder
182 TString path("YSAlice/WhiteBoard/Geometry/PHOS/") ;
183 path += PHOS()->GetTitle() ;
184 return (AliPHOSGeometry*)gROOT->FindObjectAny(path.Data()) ;
187 //____________________________________________________________________________
188 void AliPHOSGetter::Post(const char * headerFile, const char * opt, const char * name, const Int_t event) const
190 // Adds a new folder for summable digits
192 TString foldertitle ;
194 foldertitle += event ;
198 TFolder * aliceF = (TFolder*)gROOT->FindObjectAny("YSAlice") ;
200 if ( strcmp(opt, "G") == 0 ) { // Geometry
201 // the hierarchy is //YSALICE/WhiteBoard/Geometry/PHOS/
202 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance(PHOS()->GetTitle(),"") ;
203 TFolder * geomF = (TFolder*)aliceF->FindObject("WhiteBoard/Geometry/PHOS") ;
205 cerr << "ERROR: AliPHOSGetter::Post G -> Folder WhiteBoard/Geometry/PHOS/" << " not found!" << endl;
209 geomF->Add((TObject*)geom) ;
211 } else if ( strcmp(opt, "H") == 0 ) { // Hits
212 // the hierarchy is //YSALICE/WhiteBoard/SDigits/PHOS/Hits
213 TClonesArray * hits = new TClonesArray("AliPHOSHit",1000) ;
214 hits->SetName("Hits") ;
215 TFolder * hitsF = (TFolder*)aliceF->FindObject("WhiteBoard/Hits/PHOS") ;
217 cerr << "ERROR: AliPHOSGetter::Post H -> Folder WhiteBoard/Hits/PHOS/" << " not found!" << endl;
223 } else if ( strcmp(opt, "S") == 0 ) { // summable digits
224 // the hierarchy is //YSALICE/WhiteBoard/SDigits/PHOS/headerFile/sdigitsname
225 // because you can have sdigits from several hit files for mixing
226 TClonesArray * sdigits = new TClonesArray("AliPHOSDigit",1000) ;
227 TString sdigitsName ;
231 sdigitsName = "SDigits" ;
232 sdigits->SetName( sdigitsName.Data() ) ;
233 TFolder * sdigitsF = (TFolder*)aliceF->FindObject("WhiteBoard/SDigits/PHOS") ;
234 TFolder * sdigitsF2 = 0 ;
235 TString subdir(headerFile) ;
236 if ( !(sdigitsF2=(TFolder*)sdigitsF->FindObject(subdir)) )
237 sdigitsF2 = sdigitsF->AddFolder(subdir, foldertitle);
239 if ( sdigitsF2->FindObject( sdigitsName.Data() ) ) {
240 cerr <<"INFO: AliPHOSGetter::Post S -> Folder " << subdir << ", " << foldertitle
241 << " already exists!" << endl ;
246 cerr << "ERROR: AliPHOSGetter::Post S -> Folder WhiteBoard/SDigits/PHOS/" << subdir << " not created!" << endl;
250 sdigitsF2->Add(sdigits) ;
252 } else if ( strcmp(opt, "Ser") == 0 ) { // sdigizer
253 // the hierarchy is //YSALICE/tasks/Digitizer/PHOS/sdigitsname
254 AliPHOSSDigitizer * sdigitizer = new AliPHOSSDigitizer() ;
255 TString sdigitsName ;
259 sdigitsName = "SDigitizer" ;
260 sdigitizer->SetName( sdigitsName.Data() ) ;
261 TTask * sdigitsF = (TTask*)aliceF->FindObject("tasks/SDigitizer") ;
263 cerr << "ERROR: AliPHOSGetter::Post Ser -> Task tasks/SDigitizer" << " not found!" << endl;
266 TTask * phos = (TTask*)sdigitsF->GetListOfTasks()->FindObject("PHOS") ;
268 cerr <<"ERROR: AliPHOSGetter::Post Ser -> tasks/SDigitizer/PHOS" << " not found!" << endl;
271 AliPHOSSDigitizer * phossd = (AliPHOSSDigitizer*)phos->GetListOfTasks()->FindObject(sdigitsName.Data()) ;
273 cout << "INFO: AliPHOSGetter::Post Ser -> Task " << sdigitsName.Data() << " already exists" << endl ;
276 phos->Add(sdigitizer) ;
279 } else if ( strcmp(opt, "D") == 0 ) { // digits
280 // the hierarchy is //YSALICE/WhiteBoard/Digits/PHOS/digitsname
281 TClonesArray * digits = new TClonesArray("AliPHOSDigit",20000) ;
286 digitsName = "Digits" ;
287 digits->SetName( digitsName.Data() ) ;
288 TFolder * digitsF = (TFolder*)aliceF->FindObject("WhiteBoard/Digits/PHOS") ;
290 cerr << "ERROR: AliPHOSGetter::Post D -> Folder WhiteBoard/Digits/PHOS/" << " not found!" << endl;
293 digitsF->SetTitle(foldertitle) ;
294 if ( digitsF->FindObject( digitsName.Data() ) ) {
295 cerr <<"INFO: AliPHOSGetter::Post D -> Object " << digitsName.Data()
296 << " already exists!" << endl ;
300 digitsF->Add(digits) ;
302 } else if ( strcmp(opt, "Der") == 0 ) { // sdigizer
303 // the hierarchy is //YSALICE/tasks/Digitizer/PHOS/digitsname
304 AliPHOSDigitizer * digitizer = new AliPHOSDigitizer() ;
309 digitsName = "Digitizer" ;
310 digitizer->SetName( digitsName.Data() ) ;
311 TTask * digitsF = (TTask*)aliceF->FindObject("tasks/Digitizer") ;
313 cerr << "ERROR: AliPHOSGetter::Post Der -> Task tasks/Digitizer" << " not found!" << endl;
316 TTask * phos = (TTask*)digitsF->GetListOfTasks()->FindObject("PHOS") ;
318 cerr <<"ERROR: AliPHOSGetter::Post Der -> tasks/Digitizer/PHOS" << " not found!" << endl;
321 AliPHOSDigitizer * phosd = (AliPHOSDigitizer*)phos->GetListOfTasks()->FindObject(digitsName.Data()) ;
323 cout << "INFO: AliPHOSGetter::Post Der -> Task " << digitsName.Data() << " already exists" << endl ;
326 phos->Add(digitizer) ;
329 } else if ( strcmp(opt, "R") == 0 ) { // RecPoints
330 // the hierarchy is //YSALICE/WhiteBoard/RecPoints/PHOS/emc/recpointsname
331 // //YSALICE/WhiteBoard/RecPoints/PHOS/cpv/recpointsname
332 TObjArray * emcrp = new TObjArray(100) ;
333 TObjArray * cpvrp = new TObjArray(100) ;
334 TString recpointsName ;
336 recpointsName = name ;
338 recpointsName = "RecPoints" ;
339 emcrp->SetName( recpointsName.Data() ) ;
340 cpvrp->SetName( recpointsName.Data() ) ;
341 TFolder * emcrpF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/emc") ;
342 TFolder * cpvrpF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/cpv") ;
343 emcrpF->SetTitle(foldertitle) ;
344 cpvrpF->SetTitle(foldertitle) ;
345 if ( !emcrpF || !cpvrpF ) {
346 cerr << "ERROR: AliPHOSGetter::Post R -> Folder WhiteBoard/RecPoints/PHOS/emc(cpv)" << " not found!" << endl;
349 // TString title("PHOS Digits") ;
350 if ( emcrpF->FindObject( recpointsName.Data() ) || cpvrpF->FindObject( recpointsName.Data() ) ) {
351 cerr <<"INFO: AliPHOSGetter::Post R -> Object " << recpointsName.Data()
352 << " already exists!" << endl ;
360 } else if ( strcmp(opt, "Rer") == 0 ) { // clusterizer
361 // the hierarchy is //YSALICE/tasks/Reconstructionner/PHOS/recpointsname
362 AliPHOSClusterizer * clusterizer;
363 if ( strstr(name, "clu-v1") != 0 )
364 clusterizer = new AliPHOSClusterizerv1() ;
366 cerr << "ERROR: AliPHOSGetter::Post Rer -> " << name << " unknown clusterizer version" << endl ;
369 TString recpointsName ;
371 recpointsName = name ;
373 recpointsName = "Clusterizer" ;
374 clusterizer->SetName( recpointsName.Data() ) ;
375 TTask * reF = (TTask*)aliceF->FindObject("tasks/Reconstructioner") ;
377 cerr << "ERROR: AliPHOSGetter::Post Rer -> Task tasks/Reconstructioner" << " not found!" << endl;
380 TTask * phos = (TTask*)reF->GetListOfTasks()->FindObject("PHOS") ;
382 cerr <<"ERROR: AliPHOSGetter::Post Rer -> tasks/Reconstructioner/PHOS" << " not found!" << endl;
385 AliPHOSClusterizer * phoscl = (AliPHOSClusterizer*)phos->GetListOfTasks()->FindObject(recpointsName.Data()) ;
387 cout << "INFO: AliPHOSGetter::Post Rer -> Task " << recpointsName.Data() << " already exists" << endl ;
390 phos->Add(clusterizer) ;
393 } else if ( strcmp(opt, "T") == 0 ) { //TrackSegments
394 // the hierarchy is //YSALICE/WhiteBoard/TrackSegments/PHOS/tracksegmentsname
396 TClonesArray * tracksegments = new TClonesArray("AliPHOSTrackSegment", 200) ;
397 TString tracksegmentsName ;
399 tracksegmentsName = name ;
401 tracksegmentsName = "TrackSegments" ;
402 tracksegments->SetName( tracksegmentsName.Data() ) ;
403 TFolder * tracksegmentsF = (TFolder*)aliceF->FindObject("WhiteBoard/TrackSegments/PHOS") ;
404 tracksegmentsF->SetTitle(foldertitle) ;
405 if ( !tracksegmentsF) {
406 cerr << "ERROR: AliPHOSGetter::Post T -> Folder WhiteBoard/TrackSegments/PHOS" << " not found!" << endl;
409 if ( tracksegmentsF->FindObject( tracksegmentsName.Data() ) ) {
410 cerr <<"INFO: AliPHOSGetter::Post T -> Object " << tracksegmentsName.Data()
411 << " already exists!" << endl ;
415 tracksegmentsF->Add(tracksegments) ;
417 } else if ( strcmp(opt, "Ter") == 0 ) { // TrackSegmentsMaker
418 // the hierarchy is //YSALICE/tasks/Reconstructionner/PHOS/tracksegmentsname
419 AliPHOSTrackSegmentMaker * tracksegmentmaker ;
420 if ( strstr(name, "tsm-v1") != 0 )
421 tracksegmentmaker = new AliPHOSTrackSegmentMakerv1() ;
423 cerr << "ERROR: AliPHOSGetter::Post Ter -> " << name << " unknown track segment maker version" << endl ;
426 TString tracksegmentsName ;
428 tracksegmentsName = name ;
430 tracksegmentsName = "TrackSegmentMaker" ;
431 tracksegmentmaker->SetName( tracksegmentsName.Data() ) ;
432 TTask * reF = (TTask*)aliceF->FindObject("tasks/Reconstructioner") ;
434 cerr << "ERROR: AliPHOSGetter::Post Ter -> Task tasks/Reconstructioner" << " not found!" << endl;
437 TTask * phos = (TTask*)reF->GetListOfTasks()->FindObject("PHOS") ;
439 cerr <<"ERROR: AliPHOSGetter::Post Ter -> tasks/Reconstructioner/PHOS" << " not found!" << endl;
442 AliPHOSTrackSegmentMaker * phosts = (AliPHOSTrackSegmentMaker*)phos->GetListOfTasks()->FindObject(tracksegmentsName.Data()) ;
444 cout << "INFO: AliPHOSGetter::Post Ter -> Task " << tracksegmentsName.Data() << " already exists" << endl ;
447 phos->Add(tracksegmentmaker) ;
450 } else if ( strcmp(opt, "P") == 0 ) { // RecParticles
451 // the hierarchy is //YSALICE/WhiteBoard/RecParticles/PHOS/recparticlesname
453 TClonesArray * recparticles = new TClonesArray("AliPHOSRecParticle", 200) ;
454 TString recparticlesName ;
456 recparticlesName = name ;
458 recparticlesName = "RecParticles" ;
459 recparticles->SetName( recparticlesName.Data() ) ;
460 TFolder * recparticlesF = (TFolder*)aliceF->FindObject("WhiteBoard/RecParticles/PHOS") ;
461 recparticlesF->SetTitle(foldertitle) ;
462 if ( !recparticlesF) {
463 cerr << "ERROR: AliPHOSGetter::Post P -> Folder WhiteBoard/RecParticles/PHOS" << " not found!" << endl;
466 if ( recparticlesF->FindObject( recparticlesName.Data() ) ) {
467 cerr <<"INFO: AliPHOSGetter::Post P -> Object " << recparticlesName.Data()
468 << " already exists!" << endl ;
472 recparticlesF->Add(recparticles) ;
474 } else if ( strcmp(opt, "Per") == 0 ) { // PID Maker
475 // the hierarchy is //YSALICE/tasks/Reconstructionner/PHOS/recparticlesname
477 if ( strstr(name, "pid-v1") != 0 )
478 pid = new AliPHOSPIDv1() ;
480 cerr << "ERROR: AliPHOSGetter::Post Per -> " << name << " unknown PID maker version" << endl ;
483 TString recparticlesName ;
485 recparticlesName = name ;
487 recparticlesName = "PID" ;
488 pid->SetName( recparticlesName.Data() ) ;
489 TTask * reF = (TTask*)aliceF->FindObject("tasks/Reconstructioner") ;
491 cerr << "ERROR: AliPHOSGetter::Post Per -> Task tasks/Reconstructioner" << " not found!" << endl;
494 TTask * phos = (TTask*)reF->GetListOfTasks()->FindObject("PHOS") ;
496 cerr <<"ERROR: AliPHOSGetter::Post Per -> tasks/Reconstructioner/PHOS" << " not found!" << endl;
499 AliPHOSPID * phospid = (AliPHOSPID*)phos->GetListOfTasks()->FindObject(recparticlesName.Data()) ;
501 cout << "INFO: AliPHOSGetter::Post Per -> Task " << recparticlesName.Data() << " already exists" << endl ;
507 else if ( strcmp(opt, "QA") == 0 ) { // Alarms
508 // the hierarchy is //YSALICE/WhiteBoard/Alarms/PHOS/
510 TFolder * alarmsF = new TFolder() ;
515 alarmsName = "Alarm with no name" ;
516 alarmsF->SetName( alarmsName.Data() ) ;
517 alarmsF->SetTitle(foldertitle) ;
518 TFolder * qaaF = (TFolder*)aliceF->FindObject("WhiteBoard/QAAlarms") ;
520 cerr << "ERROR: AliPHOSGetter::Post QA -> Folder WhiteBoard/QAAlarms/" << " not found!" << endl;
523 if ( qaaF->FindObject( alarmsName.Data() ) )
524 qaaF->RecursiveRemove( qaaF->FindObject( alarmsName.Data() ) ) ;
531 //____________________________________________________________________________
532 const TParticle * AliPHOSGetter::Primary(Int_t index) const
534 // Return primary particle numbered by <index>
539 Int_t primaryIndex = index % 10000000 ;
540 Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
542 if ( primaryList > 0 ) {
543 cout << " Getter does not support currently Mixing of primary " << endl ;
544 cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
548 return gAlice->Particle(primaryIndex) ;
552 //____________________________________________________________________________
553 void AliPHOSGetter::ReadTreeD()
555 // Read the digit tree gAlice->TreeD()
556 if(gAlice->TreeD()== 0){
557 cerr << "ERROR: AliPHOSGetter::ReadTreeD: can not read TreeD " << endl ;
561 TObjArray * lob = (TObjArray*)gAlice->TreeD()->GetListOfBranches() ;
563 TBranch * branch = 0 ;
564 TBranch * digitsbranch = 0 ;
565 TBranch * digitizerbranch = 0 ;
566 Bool_t phosfound = kFALSE, digitizerfound = kFALSE ;
568 while ( (branch = (TBranch*)next()) && (!phosfound || !digitizerfound) ) {
569 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
570 digitsbranch = branch ;
573 else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
574 digitizerbranch = branch ;
575 digitizerfound = kTRUE ;
579 if ( !phosfound || !digitizerfound ) {
580 cerr << "WARNING: AliPHOSGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name " << fDigitsTitle << endl ;
586 Post(fHeaderFile, "D", fDigitsTitle) ;
588 // Post the Digitizer
589 Post(fHeaderFile, "Der", fDigitsTitle) ;
591 TClonesArray * digits = Digits(fDigitsTitle) ;
593 digitsbranch ->SetAddress(&digits) ;
595 AliPHOSDigitizer * digitizer = Digitizer(fDigitsTitle) ;
596 digitizerbranch->SetAddress(&digitizer) ;
598 digitsbranch ->GetEntry(0) ;
599 digitizerbranch->GetEntry(0) ;
603 //____________________________________________________________________________
604 void AliPHOSGetter::ReadTreeH()
606 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
608 if(gAlice->TreeH()== 0){
609 cerr << "ERROR: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
613 TBranch * hitsbranch = (TBranch*)gAlice->TreeH()->GetListOfBranches()->FindObject("PHOS") ;
615 cerr << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ;
617 TClonesArray * hits = Hits() ;
619 hitsbranch->SetAddress(&hits) ;
620 hitsbranch->GetEntry(0) ;
624 //____________________________________________________________________________
625 void AliPHOSGetter::ReadTreeQA()
627 // Read the digit tree gAlice->TreeQA()
628 // so far only PHOS knows about this Tree
630 if(PHOS()->TreeQA()== 0){
631 cerr << "ERROR: AliPHOSGetter::ReadTreeQA: can not read TreeQA " << endl ;
635 TBranch * qabranch = PHOS()->TreeQA()->GetBranch("PHOS") ;
637 cerr << "WARNING: AliPHOSGetter::ReadTreeQA -> Cannot find QA Alarms for PHOS" << endl ;
641 // Post the QA Alarms
642 Post(fHeaderFile, "QA", "PHOS") ;
643 TFolder * alarmsF = Alarms() ;
645 qabranch->SetAddress(&alarmsF) ;
646 qabranch->GetEntry(0) ;
650 //____________________________________________________________________________
651 void AliPHOSGetter::ReadTreeR()
653 // Read the reconstrunction tree gAlice->TreeR()
655 if(gAlice->TreeR()== 0){
656 cout << "ERROR: AliPHOSGetter::ReadTreeR: can not read TreeR " << endl ;
660 TObjArray * lob = (TObjArray*)gAlice->TreeR()->GetListOfBranches() ;
662 TBranch * branch = 0 ;
663 TBranch * emcbranch = 0 ;
664 TBranch * cpvbranch = 0 ;
665 TBranch * clusterizerbranch = 0 ;
666 Bool_t phosemcrpfound = kFALSE, phoscpvrpfound = kFALSE, clusterizerfound = kFALSE ;
668 while ( (branch = (TBranch*)next()) && (!phosemcrpfound || !phoscpvrpfound || !clusterizerfound) ) {
669 if ( (strcmp(branch->GetName(), "PHOSEmcRP")==0) && (strcmp(branch->GetTitle(), fRecPointsTitle)==0) ) {
671 phosemcrpfound = kTRUE ;
673 else if ( (strcmp(branch->GetName(), "PHOSCpvRP")==0) && (strcmp(branch->GetTitle(), fRecPointsTitle)==0) ) {
675 phoscpvrpfound = kTRUE ;
677 else if ( (strcmp(branch->GetName(), "AliPHOSClusterizer")==0) && (strcmp(branch->GetTitle(), fRecPointsTitle)==0) ) {
678 clusterizerbranch = branch ;
679 clusterizerfound = kTRUE ;
683 if ( !phosemcrpfound || !phoscpvrpfound || !clusterizerfound ) {
684 cerr << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find RecPoints and/or Clusterizer with name " << fRecPointsTitle << endl ;
688 // Post the RecPoints
689 Post(fHeaderFile, "R", fRecPointsTitle) ;
691 // Post the Clusterizer
692 // Need the version first
693 AliPHOSClusterizer * clusterizer = 0 ;
694 clusterizerbranch->SetAddress(&clusterizer) ;
695 clusterizerbranch->GetEntry(0) ;
696 TString clusterizerName(fRecPointsTitle) ;
697 clusterizerName.Append(clusterizer->Version()) ;
699 Post(fHeaderFile, "Rer", clusterizerName) ;
701 TObjArray * emcRecPoints = EmcRecPoints(fRecPointsTitle) ;
702 emcRecPoints->Clear() ;
703 emcbranch->SetAddress(&emcRecPoints) ;
705 TObjArray * cpvRecPoints = CpvRecPoints(fRecPointsTitle) ;
706 cpvRecPoints->Clear() ;
707 cpvbranch->SetAddress(&cpvRecPoints) ;
709 clusterizer = Clusterizer(clusterizerName) ;
710 clusterizerbranch->SetAddress(&clusterizer) ;
712 emcbranch ->GetEntry(0) ;
713 cpvbranch ->GetEntry(0) ;
714 clusterizerbranch->GetEntry(0) ;
718 TBranch * tsbranch = 0 ;
719 TBranch * tsmakerbranch = 0 ;
720 Bool_t phostsfound = kFALSE, tsmakerfound = kFALSE ;
722 while ( (branch = (TBranch*)next()) && (!phostsfound || !tsmakerfound) ) {
723 if ( (strcmp(branch->GetName(), "PHOSTS")==0) && (strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0) ) {
725 phostsfound = kTRUE ;
727 else if ( (strcmp(branch->GetName(), "AliPHOSTrackSegmentMaker")==0) && (strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0) ) {
728 tsmakerbranch = branch ;
729 tsmakerfound = kTRUE ;
733 if ( !phostsfound || !tsmakerfound ) {
734 cerr << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name " << fTrackSegmentsTitle << endl ;
738 // Post the TrackSegments
739 Post(fHeaderFile, "T", fTrackSegmentsTitle) ;
741 // Post the TrackSegment Maker
742 // Need the version first
743 AliPHOSTrackSegmentMaker * tsmaker = 0 ;
744 tsmakerbranch->SetAddress(&tsmaker) ;
745 tsmakerbranch->GetEntry(0) ;
746 TString tsmakerName(fTrackSegmentsTitle) ;
747 tsmakerName.Append(tsmaker->Version()) ;
749 Post(fHeaderFile, "Ter", tsmakerName) ;
751 TClonesArray * tracksegments = TrackSegments(fTrackSegmentsTitle) ;
752 tracksegments->Clear() ;
753 tsbranch->SetAddress(&tracksegments) ;
755 tsmaker = TrackSegmentMaker(tsmakerName) ;
756 tsmakerbranch->SetAddress(&tsmaker) ;
758 tsmakerbranch ->GetEntry(0) ;
759 tsbranch ->GetEntry(0) ;
763 TBranch * rpabranch = 0 ;
764 TBranch * pidbranch = 0 ;
765 Bool_t phosrpafound = kFALSE, pidfound = kFALSE ;
767 while ( (branch = (TBranch*)next()) && (!phosrpafound || !pidfound) ) {
768 if ( (strcmp(branch->GetName(), "PHOSRP")==0) && (strcmp(branch->GetTitle(), fRecParticlesTitle)==0) ) {
770 phosrpafound = kTRUE ;
772 else if ( (strcmp(branch->GetName(), "AliPHOSPID")==0) && (strcmp(branch->GetTitle(), fRecParticlesTitle)==0) ) {
778 if ( !phosrpafound || !pidfound ) {
779 cerr << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name " << fRecParticlesTitle << endl ;
783 // Post the RecParticles
784 Post(fHeaderFile, "P", fRecParticlesTitle) ;
787 // Need the version first
788 AliPHOSPID * pid = 0 ;
789 pidbranch->SetAddress(&pid) ;
790 pidbranch->GetEntry(0) ;
791 TString pidName(fRecParticlesTitle) ;
792 pidName.Append(pid->Version()) ;
795 Post(fHeaderFile, "Per", pidName) ;
797 TClonesArray * recParticles = RecParticles(fRecParticlesTitle) ;
798 recParticles->Clear() ;
799 rpabranch->SetAddress(&recParticles) ;
802 pidbranch->SetAddress(&pid) ;
804 pidbranch ->GetEntry(0) ;
805 rpabranch ->GetEntry(0) ;
809 //____________________________________________________________________________
810 void AliPHOSGetter::ReadTreeS()
812 // Read the summable digits tree gAlice->TreeS()
814 if(gAlice->TreeS()== 0){
815 cerr << "ERROR: AliPHOSGetter::ReadTreeS -> Cannot find TreeS " << endl ;
819 TObjArray * lob = (TObjArray*)gAlice->TreeS()->GetListOfBranches() ;
821 TBranch * branch = 0 ;
822 TBranch * sdigitsbranch = 0 ;
823 TBranch * sdigitizerbranch = 0 ;
824 Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
826 while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) {
827 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
828 sdigitsbranch = branch ;
831 else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
832 sdigitizerbranch = branch ;
833 sdigitizerfound = kTRUE ;
837 if ( !phosfound || !sdigitizerfound ) {
838 cerr << "WARNING: AliPHOSGetter::ReadTreeS -> Cannot find SDigits and/or SDigitizer with name " << fSDigitsTitle << endl ;
843 Post(fHeaderFile, "S", fSDigitsTitle) ;
845 // Post the SDigitizer
846 Post(fHeaderFile, "Ser", fSDigitsTitle) ;
848 TClonesArray * sdigits = SDigits(fSDigitsTitle) ;
850 sdigitsbranch->SetAddress(&sdigits) ;
852 AliPHOSSDigitizer * sdigitizer = SDigitizer(fSDigitsTitle) ;
853 sdigitizerbranch->SetAddress(&sdigitizer) ;
855 sdigitsbranch->GetEvent(0) ;
856 sdigitizerbranch->GetEvent(0) ;
860 //____________________________________________________________________________
861 void AliPHOSGetter::ReadPrimaries()
863 // Reads specific branches of primaries
865 fNPrimaries = gAlice->GetNtrack();
867 // //Check, is it necessary to open new files
868 // TArrayI* events = fDigitizer->GetCurrentEvents() ;
869 // TClonesArray * filenames = fDigitizer->GetHeadersFiles() ;
871 // for(input = 0; input < filenames->GetEntriesFast(); input++){
873 // TObjString * filename = (TObjString *) filenames->At(input) ;
875 // //Test, if this file already open
876 // TFile *file = (TFile*) gROOT->GetFile( filename->GetString() ) ;
878 // file = new TFile( filename->GetString()) ;
881 // // Get Kine Tree from file
882 // // char treeName[20];
883 // // sprintf(treeName,"TreeK%d",events->At(input));
884 // // TTree * treeK = (TTree*)gDirectory->Get(treeName);
886 // // treeK->SetBranchAddress("Particles", &fParticleBuffer);
888 // // cout << "AliPHOSGetter: cannot find Kine Tree for event:" << events->At(input) << endl;
890 // // // Create the particle stack
891 // // if(!fParticles) fParticles = new TClonesArray("TParticle",1000);
892 // // // Build the pointer list
893 // // if(fParticleMap) { <----
894 // // fParticleMap->Clear();
895 // // fParticleMap->Expand(treeK->GetEntries());
897 // // fParticleMap = new TObjArray(treeK->GetEntries());
899 // // From gAlice->Particle(i)
902 // // if(!(*fParticleMap)[i]) {
903 // // Int_t nentries = fParticles->GetEntries();
905 // // // algorithmic way of getting entry index
906 // // // (primary particles are filled after secondaries)
908 // // if (i<fHeader.GetNprimary())
909 // // entry = i+fHeader.GetNsecondary();
911 // // entry = i-fHeader.GetNprimary();
913 // // // only check the algorithmic way and give
914 // // // the fatal error if it is wrong
915 // // if (entry != fParticleFileMap[i]) {
916 // // Fatal("Particle",
917 // // "!!!! The algorithmic way is WRONG: !!!\n entry: %d map: %d",
918 // // entry, fParticleFileMap[i]);
921 // // fTreeK->GetEntry(fParticleFileMap[i]);
922 // // new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
923 // // fParticleMap->AddAt((*fParticles)[nentries],i);
925 // // return (TParticle *) (*fParticleMap)[i];
932 // //scan over opened files and read corresponding TreeK##
936 //____________________________________________________________________________
937 void AliPHOSGetter::Event(Int_t event)
939 // Reads the content of all Tree's S, D and R
941 if ( event > gAlice->TreeE()->GetEntries() ) {
942 cerr << "ERROR: AliPHOSGetter::Event -> There are only " << gAlice->TreeE()->GetEntries() << " events in this file" << endl ;
946 gAlice->GetEvent(event) ;
957 //____________________________________________________________________________
958 const TObject * AliPHOSGetter::ReturnO(TString what, TString name, TString file) const
960 // get the object named "what" from the folder
961 // folders are named like //YSAlice/WhiteBoard/what/PHOS/name
965 TString path("WhiteBoard/") ;
966 if ( name.IsNull() ) {
967 if ( what.CompareTo("Hits") == 0 ) {
972 else if ( what.CompareTo("SDigits") == 0 ) {
977 path += fSDigitsTitle ;
979 else if ( what.CompareTo("Digits") == 0 ){
982 path += fDigitsTitle ;
984 else if ( what.CompareTo("EmcRecPoints") == 0 ) {
985 path += "RecPoints/PHOS/";
987 path += fRecPointsTitle ;
989 else if ( what.CompareTo("CpvRecPoints") == 0 ) {
990 path += "RecPoints/PHOS/";
992 path += fRecPointsTitle ;
994 else if ( what.CompareTo("TrackSegments") == 0 ) {
995 path += "TrackSegments/PHOS/";
996 path += fTrackSegmentsTitle ;
998 else if ( what.CompareTo("RecParticles") == 0 ) {
999 path += "RecParticles/PHOS/";
1000 path += fRecParticlesTitle ;
1002 else if ( what.CompareTo("Alarms") == 0 ) {
1003 path += "QAAlarms/PHOS";
1007 if ( what.CompareTo("SDigits") == 0 ) {
1014 else if ( what.CompareTo("Digits") == 0 ) {
1019 else if ( what.CompareTo("EmcRecPoints") == 0 ) {
1020 path += "RecPoints/PHOS/";
1024 else if ( what.CompareTo("CpvRecPoints") == 0 ) {
1025 path += "RecPoints/PHOS/";
1029 else if ( what.CompareTo("TrackSegments") == 0 ) {
1030 path += "TrackSegments/PHOS/";
1033 else if ( what.CompareTo("RecParticles") == 0 ) {
1034 path += "RecParticles/PHOS/";
1037 else if ( what.CompareTo("Alarms") == 0 ) {
1038 path += "QAAlarms/PHOS/";
1042 path.Prepend("YSAlice/") ;
1043 TObject * phosO = (TObject*)gROOT->FindObjectAny(path) ;
1045 cerr << "ERROR : AliPHOSGetter::ReturnO -> Object " << path << " not found!" << endl ;
1051 //____________________________________________________________________________
1052 const TTask * AliPHOSGetter::ReturnT(TString what, TString name) const
1054 // get the TTask named "what" from the folder
1055 // folders are named like //YSAlice/Tasks/what/PHOS/name
1057 TString path("tasks") ;
1059 if ( what.CompareTo("SDigitizer") == 0 )
1060 path += "/SDigitizer" ;
1061 else if ( what.CompareTo("Digitizer") == 0 )
1062 path += "/Digitizer" ;
1063 else if ( what.CompareTo("Clusterizer") == 0 )
1064 path += "/Reconstructioner" ;
1065 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
1066 path += "/Reconstructioner" ;
1067 else if ( what.CompareTo("PID") == 0 )
1068 path += "/Reconstructioner" ;
1069 else if ( what.CompareTo("QATasks") == 0 )
1072 TFolder * aliceF = (TFolder*)gROOT->FindObjectAny("YSAlice") ;
1073 TTask * aliceT = (TTask*)aliceF->FindObject(path) ;
1076 cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << path << " not found!" << endl ;
1080 TTask * phosT = (TTask*)aliceT->GetListOfTasks()->FindObject("PHOS") ;
1082 cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << path << "/PHOS not found!" << endl ;
1085 TList * l = phosT->GetListOfTasks() ;
1087 if (what.CompareTo("SDigitizer") == 0) {
1088 if ( name.IsNull() )
1089 name = fSDigitsTitle ;
1090 } else if (what.CompareTo("Digitizer") == 0){
1091 if ( name.IsNull() )
1092 name = fDigitsTitle ;
1093 } else if (what.CompareTo("Clusterizer") == 0){
1094 if ( name.IsNull() )
1095 name = fRecPointsTitle ;
1097 else if (what.CompareTo("TrackSegmentMaker") == 0){
1098 if ( name.IsNull() )
1099 name = fTrackSegmentsTitle ;
1101 else if (what.CompareTo("PID") == 0){
1102 if ( name.IsNull() )
1103 name = fRecParticlesTitle ;
1105 else if (what.CompareTo("QATasks") == 0){
1106 if ( name.IsNull() )
1110 TTask * task = (TTask*)l->FindObject(name) ;
1113 cout << "WARNING: AliPHOSGetter::ReturnT -> Task " << path << "/" << name << " not found!" << endl ;