* provided "as is" without express or implied warranty. *
**************************************************************************/
-/* $Id: */
-
-/* $Log:
- 29.05.2001 Yuri Kharlov:
- Everywhere reading the treese TTree->GetEvent(i)
- is replaced by reading the branches TBranch->GetEntry(0)
-*/
+/* $Id$ */
//_________________________________________________________________________
// A singleton. This class should be used in the analysis stage to get
// for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++)
// AliPHOSRecParticle * part = gime->RecParticle(1) ;
// ................
-// please->GetEvent(event) ; // reads new event from galice.root
+// gime->Event(event) ; // reads new event from galice.root
//
//*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
//*-- Completely redesigned by Dmitri Peressounko March 2001
//*-- systematic usage of TFolders without changing the interface
//////////////////////////////////////////////////////////////////////////////
-
// --- ROOT system ---
-#include "TFile.h"
-#include "TTree.h"
-#include "TROOT.h"
-#include "TObjString.h"
-#include "TFolder.h"
+#include <TFile.h>
+#include <TROOT.h>
+#include <TSystem.h>
+#include <TParticle.h>
+#include <TF1.h>
+#include <TGraph.h>
+//#include <TCanvas.h>
+//#include <TFrame.h>
// --- Standard library ---
-#include <iostream.h>
// --- AliRoot header files ---
-
-#include "AliRun.h"
-#include "AliPHOSGetter.h"
+#include "AliESD.h"
+#include "AliHeader.h"
+#include "AliMC.h"
#include "AliPHOS.h"
-#include "AliPHOSDigitizer.h"
-#include "AliPHOSSDigitizer.h"
-#include "AliPHOSClusterizer.h"
-#include "AliPHOSClusterizerv1.h"
-#include "AliPHOSTrackSegmentMaker.h"
-#include "AliPHOSTrackSegmentMakerv1.h"
-#include "AliPHOSTrackSegment.h"
-#include "AliPHOSPID.h"
-#include "AliPHOSPIDv1.h"
-#include "AliPHOSGeometry.h"
+#include "AliPHOSBeamTestEvent.h"
+#include "AliPHOSGetter.h"
+#include "AliPHOSLoader.h"
+#include "AliRunLoader.h"
+#include "AliStack.h"
+#include "AliPHOSRawStream.h"
+#include "AliRawReaderFile.h"
+#include "AliLog.h"
ClassImp(AliPHOSGetter)
- AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
+AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
+AliPHOSLoader * AliPHOSGetter::fgPhosLoader = 0;
+Int_t AliPHOSGetter::fgDebug = 0;
+
+// TFile * AliPHOSGetter::fgFile = 0 ;
//____________________________________________________________________________
-AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* branchTitle )
+AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* version, Option_t * openingOption)
{
- //Initialize all lists
+ // ctor only called by Instance()
+
+ AliRunLoader* rl = AliRunLoader::GetRunLoader(version) ;
+ if (!rl) {
+ rl = AliRunLoader::Open(headerFile, version, openingOption);
+ if (!rl) {
+ Fatal("AliPHOSGetter", "Could not find the Run Loader for %s - %s",headerFile, version) ;
+ return ;
+ }
+ if (rl->GetAliRun() == 0x0) {
+ rl->LoadgAlice();
+ gAlice = rl->GetAliRun(); // should be removed
+ rl->LoadHeader();
+ }
+ }
+ fgPhosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
+ if ( !fgPhosLoader )
+ Error("AliPHOSGetter", "Could not find PHOSLoader") ;
+ else
+ fgPhosLoader->SetTitle(version);
+
+ // initialize data members
+ SetDebug(0) ;
+ fBTE = 0 ;
+ fPrimaries = 0 ;
+ fLoadingStatus = "" ;
+
+ fESDFileName = rl->GetFileName() ; // this should be the galice.root file
+ fESDFileName.ReplaceAll("galice.root", "AliESDs.root") ;
+ fESDFile = 0 ;
+ fESD = 0 ;
+ fESDTree = 0 ;
+ fRawDigits = kFALSE ;
+}
- fHeaderFile = headerFile ;
- fSDigitsTitle = branchTitle ;
- fDigitsTitle = branchTitle ;
- fRecPointsTitle = branchTitle ;
- fRecParticlesTitle = branchTitle ;
- fTrackSegmentsTitle = branchTitle ;
+//____________________________________________________________________________
+AliPHOSGetter::~AliPHOSGetter()
+{
+ // dtor
+ if(fgPhosLoader){
+ delete fgPhosLoader ;
+ fgPhosLoader = 0 ;
+ }
+ if(fBTE){
+ delete fBTE ;
+ fBTE = 0 ;
+ }
+ if(fPrimaries){
+ fPrimaries->Delete() ;
+ delete fPrimaries ;
+ }
+ if (fESD)
+ delete fESD ;
+ if (fESDTree)
+ delete fESDTree ;
+
+ fgObjGetter = 0;
+}
- fPrimaries = new TObjArray(1) ;
+//____________________________________________________________________________
+void AliPHOSGetter::Reset()
+{
+ // resets things in case the getter is called consecutively with different files
+ // the PHOS Loader is already deleted by the Run Loader
- if ( fHeaderFile != "aliroot" ) { // to call the getter without a file
+ if (fPrimaries) {
+ fPrimaries->Delete() ;
+ delete fPrimaries ;
+ }
+ fgPhosLoader = 0;
+ fgObjGetter = 0;
+}
- //open headers file
- TFile * file = (TFile*) gROOT->GetFile(fHeaderFile.Data() ) ;
-
- if(file == 0){ //if file was not opened yet, read gAlice
- if(fHeaderFile.Contains("rfio")) // if we read file using HPSS
- file = TFile::Open(fHeaderFile.Data(),"update") ;
- else
- file = new TFile(fHeaderFile.Data(),"update") ;
-
- if (!file->IsOpen()) {
- cerr << "ERROR : AliPHOSGetter::AliPHOSGetter -> Cannot open " << fHeaderFile.Data() << endl ;
- abort() ;
- }
-
- gAlice = (AliRun *) file->Get("gAlice") ;
-
- if (!gAlice) {
- cerr << "ERROR : AliPHOSGetter::AliPHOSGetter -> Cannot find gAlice in " << fHeaderFile.Data() << endl ;
- abort() ;
- }
- }
+//____________________________________________________________________________
+AliPHOSClusterizer * AliPHOSGetter::Clusterizer()
+{
+ // Returns pointer to the Clusterizer task
+ AliPHOSClusterizer * rv ;
+ rv = dynamic_cast<AliPHOSClusterizer *>(PhosLoader()->Reconstructioner()) ;
+ if (!rv) {
+ Event(0, "R") ;
+ rv = dynamic_cast<AliPHOSClusterizer*>(PhosLoader()->Reconstructioner()) ;
}
- ReadTreeQA() ;
- fDebug="";
+ return rv ;
}
+
//____________________________________________________________________________
-void AliPHOSGetter::CreateWhiteBoard() const
+TObjArray * AliPHOSGetter::CpvRecPoints()
{
- // Posts a few item to the white board (folders)
-
- // -- the geometry
- Post(fHeaderFile, "G") ;
+ // asks the Loader to return the CPV RecPoints container
+
+ TObjArray * rv = 0 ;
- // -- the hits
- Post(fHeaderFile, "H") ;
-
+ rv = PhosLoader()->CpvRecPoints() ;
+ if (!rv) {
+ PhosLoader()->MakeRecPointsArray() ;
+ rv = PhosLoader()->CpvRecPoints() ;
+ }
+ return rv ;
}
//____________________________________________________________________________
-AliPHOSGetter * AliPHOSGetter::GetInstance()
+TClonesArray * AliPHOSGetter::Digits()
{
- // Returns the pointer of the unique instance already defined
-
- AliPHOSGetter * rv = 0 ;
- if ( fgObjGetter )
- rv = fgObjGetter ;
- else
- cout << "AliPHOSGetter::GetInstance ERROR: not yet initialized" << endl ;
+ // asks the Loader to return the Digits container
- return rv ;
+ TClonesArray * rv = 0 ;
+ rv = PhosLoader()->Digits() ;
+
+ if( !rv ) {
+ PhosLoader()->MakeDigitsArray() ;
+ rv = PhosLoader()->Digits() ;
+ }
+ return rv ;
}
//____________________________________________________________________________
-AliPHOSGetter * AliPHOSGetter::GetInstance(const char* headerFile,
- const char* branchTitle)
-{
- // Creates and returns the pointer of the unique instance
- // Must be called only when the environment has changed
+AliPHOSDigitizer * AliPHOSGetter::Digitizer()
+{
+ // Returns pointer to the Digitizer task
+ AliPHOSDigitizer * rv ;
+ rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
+ if (!rv) {
+ Event(0, "D") ;
+ rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
+ }
+ return rv ;
+}
- if ( fgObjGetter ) // delete it if already exists
- delete fgObjGetter ;
+//____________________________________________________________________________
+TObjArray * AliPHOSGetter::EmcRecPoints()
+{
+ // asks the Loader to return the EMC RecPoints container
- fgObjGetter = new AliPHOSGetter(headerFile,branchTitle) ;
+ TObjArray * rv = 0 ;
- // Posts a few item to the white board (folders)
- fgObjGetter->CreateWhiteBoard() ;
+ rv = PhosLoader()->EmcRecPoints() ;
+ if (!rv) {
+ PhosLoader()->MakeRecPointsArray() ;
+ rv = PhosLoader()->EmcRecPoints() ;
+ }
+ return rv ;
+}
- // Get the first event into the arrays posted on the white board
- // branchTitle = 0, means simulation run and no event yet
- if (branchTitle)
- fgObjGetter->Event(0) ;
+//____________________________________________________________________________
+TClonesArray * AliPHOSGetter::TrackSegments()
+{
+ // asks the Loader to return the TrackSegments container
- return fgObjGetter ;
+ TClonesArray * rv = 0 ;
+ rv = PhosLoader()->TrackSegments() ;
+ if (!rv) {
+ PhosLoader()->MakeTrackSegmentsArray() ;
+ rv = PhosLoader()->TrackSegments() ;
+ }
+ return rv ;
}
//____________________________________________________________________________
- const AliPHOS * AliPHOSGetter::PHOS() const
-{
- // returns the PHOS object
- return ( (AliPHOS*)gAlice->GetDetector("PHOS") );
-}
+AliPHOSTrackSegmentMaker * AliPHOSGetter::TrackSegmentMaker()
+{
+ // Returns pointer to the TrackSegmentMaker task
+ AliPHOSTrackSegmentMaker * rv ;
+ rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
+ if (!rv) {
+ Event(0, "T") ;
+ rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ;
+ }
+ return rv ;
+}
//____________________________________________________________________________
- const AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
+TClonesArray * AliPHOSGetter::RecParticles()
{
- // retrieves the geometr from the folder
+ // asks the Loader to return the TrackSegments container
- TString path("YSAlice/WhiteBoard/Geometry/PHOS/") ;
- path += PHOS()->GetTitle() ;
- return (AliPHOSGeometry*)gROOT->FindObjectAny(path.Data()) ;
+ TClonesArray * rv = 0 ;
+
+ rv = PhosLoader()->RecParticles() ;
+ if (!rv) {
+ PhosLoader()->MakeRecParticlesArray() ;
+ rv = PhosLoader()->RecParticles() ;
+ }
+ return rv ;
}
-
//____________________________________________________________________________
-void AliPHOSGetter::Post(const char * headerFile, const char * opt, const char * name, const Int_t event) const
+void AliPHOSGetter::Event(Int_t event, const char* opt)
{
- // Adds a new folder for summable digits
+ // Reads the content of all Tree's S, D and R
- TString foldertitle ;
- if ( event >= 0 )
- foldertitle += event ;
- else
- foldertitle = "" ;
+// if ( event >= MaxEvent() ) {
+// Error("Event", "%d not found in TreeE !", event) ;
+// return ;
+// }
- TFolder * aliceF = (TFolder*)gROOT->FindObjectAny("YSAlice") ;
-
- if ( strcmp(opt, "G") == 0 ) { // Geometry
- // the hierarchy is //YSALICE/WhiteBoard/Geometry/PHOS/
- AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance(PHOS()->GetTitle(),"") ;
- TFolder * geomF = (TFolder*)aliceF->FindObject("WhiteBoard/Geometry/PHOS") ;
- if ( !geomF ) {
- cerr << "ERROR: AliPHOSGetter::Post G -> Folder WhiteBoard/Geometry/PHOS/" << " not found!" << endl;
- abort() ;
- }
- else
- geomF->Add((TObject*)geom) ;
-
- } else if ( strcmp(opt, "H") == 0 ) { // Hits
- // the hierarchy is //YSALICE/WhiteBoard/SDigits/PHOS/Hits
- TClonesArray * hits = new TClonesArray("AliPHOSHit",1000) ;
- hits->SetName("Hits") ;
- TFolder * hitsF = (TFolder*)aliceF->FindObject("WhiteBoard/Hits/PHOS") ;
- if ( !hitsF ) {
- cerr << "ERROR: AliPHOSGetter::Post H -> Folder WhiteBoard/Hits/PHOS/" << " not found!" << endl;
- abort() ;
- }
- else
- hitsF->Add(hits) ;
-
- } else if ( strcmp(opt, "S") == 0 ) { // summable digits
- // the hierarchy is //YSALICE/WhiteBoard/SDigits/PHOS/headerFile/sdigitsname
- // because you can have sdigits from several hit files for mixing
- TClonesArray * sdigits = new TClonesArray("AliPHOSDigit",1000) ;
- TString sdigitsName ;
- if (name)
- sdigitsName = name ;
- else
- sdigitsName = "SDigits" ;
- sdigits->SetName( sdigitsName.Data() ) ;
- TFolder * sdigitsF = (TFolder*)aliceF->FindObject("WhiteBoard/SDigits/PHOS") ;
- TFolder * sdigitsF2 = 0 ;
- TString subdir(headerFile) ;
- if ( !(sdigitsF2=(TFolder*)sdigitsF->FindObject(subdir)) )
- sdigitsF2 = sdigitsF->AddFolder(subdir, foldertitle);
- else {
- if ( sdigitsF2->FindObject( sdigitsName.Data() ) ) {
- if (fDebug.Contains("S"))
- cerr <<"INFO: AliPHOSGetter::Post S -> Folder " << subdir << ", " << foldertitle
- << " already exists!" << endl ;
- return ;
- }
- }
- if ( !sdigitsF2 ) {
- cerr << "ERROR: AliPHOSGetter::Post S -> Folder WhiteBoard/SDigits/PHOS/" << subdir << " not created!" << endl;
- abort() ;
- }
- else
- sdigitsF2->Add(sdigits) ;
-
- } else if ( strcmp(opt, "Ser") == 0 ) { // sdigizer
- // the hierarchy is //YSALICE/tasks/Digitizer/PHOS/sdigitsname
- AliPHOSSDigitizer * sdigitizer = new AliPHOSSDigitizer() ;
- TString sdigitsName ;
- if (name)
- sdigitsName = name ;
- else
- sdigitsName = "SDigitizer" ;
- sdigitizer->SetName( sdigitsName.Data() ) ;
- TTask * sdigitsF = (TTask*)aliceF->FindObject("tasks/SDigitizer") ;
- if ( !sdigitsF ) {
- cerr << "ERROR: AliPHOSGetter::Post Ser -> Task tasks/SDigitizer" << " not found!" << endl;
- abort() ;
- }
- TTask * phos = (TTask*)sdigitsF->GetListOfTasks()->FindObject("PHOS") ;
- if ( !phos ) {
- cerr <<"ERROR: AliPHOSGetter::Post Ser -> tasks/SDigitizer/PHOS" << " not found!" << endl;
- abort() ;
- } else {
- AliPHOSSDigitizer * phossd = (AliPHOSSDigitizer*)phos->GetListOfTasks()->FindObject(sdigitsName.Data()) ;
- if (phossd) {
- if (fDebug.Contains("Ser"))
- cout << "INFO: AliPHOSGetter::Post Ser -> Task " << sdigitsName.Data() << " already exists" << endl ;
- return ;
- } else
- phos->Add(sdigitizer) ;
- }
+ AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
- } else if ( strcmp(opt, "D") == 0 ) { // digits
- // the hierarchy is //YSALICE/WhiteBoard/Digits/PHOS/digitsname
- TClonesArray * digits = new TClonesArray("AliPHOSDigit",20000) ;
- TString digitsName ;
- if (name)
- digitsName = name ;
- else
- digitsName = "Digits" ;
- digits->SetName( digitsName.Data() ) ;
- TFolder * digitsF = (TFolder*)aliceF->FindObject("WhiteBoard/Digits/PHOS") ;
- if ( !digitsF ) {
- cerr << "ERROR: AliPHOSGetter::Post D -> Folder WhiteBoard/Digits/PHOS/" << " not found!" << endl;
- abort() ;
- }
- digitsF->SetTitle(foldertitle) ;
- if ( digitsF->FindObject( digitsName.Data() ) ) {
- if (fDebug.Contains("D"))
- cerr <<"INFO: AliPHOSGetter::Post D -> Object " << digitsName.Data()
- << " already exists!" << endl ;
- return ;
- }
- else
- digitsF->Add(digits) ;
-
- } else if ( strcmp(opt, "Der") == 0 ) { // sdigizer
- // the hierarchy is //YSALICE/tasks/Digitizer/PHOS/digitsname
- AliPHOSDigitizer * digitizer = new AliPHOSDigitizer() ;
- TString digitsName ;
- if (name)
- digitsName = name ;
- else
- digitsName = "Digitizer" ;
- digitizer->SetName( digitsName.Data() ) ;
- TTask * digitsF = (TTask*)aliceF->FindObject("tasks/Digitizer") ;
- if ( !digitsF ) {
- cerr << "ERROR: AliPHOSGetter::Post Der -> Task tasks/Digitizer" << " not found!" << endl;
- abort() ;
- }
- TTask * phos = (TTask*)digitsF->GetListOfTasks()->FindObject("PHOS") ;
- if ( !phos ) {
- cerr <<"ERROR: AliPHOSGetter::Post Der -> tasks/Digitizer/PHOS" << " not found!" << endl;
- abort() ;
- } else {
- AliPHOSDigitizer * phosd = (AliPHOSDigitizer*)phos->GetListOfTasks()->FindObject(digitsName.Data()) ;
- if (phosd) {
- if (fDebug.Contains("Der"))
- cout << "INFO: AliPHOSGetter::Post Der -> Task " << digitsName.Data() << " already exists" << endl ;
- return ;
- } else
- phos->Add(digitizer) ;
- }
-
- } else if ( strcmp(opt, "R") == 0 ) { // RecPoints
- // the hierarchy is //YSALICE/WhiteBoard/RecPoints/PHOS/emc/recpointsname
- // //YSALICE/WhiteBoard/RecPoints/PHOS/cpv/recpointsname
- TObjArray * emcrp = new TObjArray(100) ;
- TObjArray * cpvrp = new TObjArray(100) ;
- TString recpointsName ;
- if (name)
- recpointsName = name ;
- else
- recpointsName = "RecPoints" ;
- emcrp->SetName( recpointsName.Data() ) ;
- cpvrp->SetName( recpointsName.Data() ) ;
- TFolder * emcrpF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/emc") ;
- TFolder * cpvrpF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/cpv") ;
- emcrpF->SetTitle(foldertitle) ;
- cpvrpF->SetTitle(foldertitle) ;
- if ( !emcrpF || !cpvrpF ) {
- cerr << "ERROR: AliPHOSGetter::Post R -> Folder WhiteBoard/RecPoints/PHOS/emc(cpv)" << " not found!" << endl;
- abort() ;
- }
- // TString title("PHOS Digits") ;
- if ( emcrpF->FindObject( recpointsName.Data() ) || cpvrpF->FindObject( recpointsName.Data() ) ) {
- if (fDebug.Contains("R"))
- cerr <<"INFO: AliPHOSGetter::Post R -> Object " << recpointsName.Data()
- << " already exists!" << endl ;
- return ;
- }
- else {
- emcrpF->Add(emcrp) ;
- cpvrpF->Add(cpvrp) ;
- }
-
- } else if ( strcmp(opt, "Rer") == 0 ) { // clusterizer
- // the hierarchy is //YSALICE/tasks/Reconstructionner/PHOS/recpointsname
- AliPHOSClusterizer * clusterizer;
- if ( strstr(name, "clu-v1") != 0 )
- clusterizer = new AliPHOSClusterizerv1() ;
- else {
- cerr << "ERROR: AliPHOSGetter::Post Rer -> " << name << " unknown clusterizer version" << endl ;
- abort() ;
- }
- TString recpointsName ;
- if (name)
- recpointsName = name ;
- else
- recpointsName = "Clusterizer" ;
- clusterizer->SetName( recpointsName.Data() ) ;
- TTask * reF = (TTask*)aliceF->FindObject("tasks/Reconstructioner") ;
- if ( !reF ) {
- cerr << "ERROR: AliPHOSGetter::Post Rer -> Task tasks/Reconstructioner" << " not found!" << endl;
- abort() ;
- }
- TTask * phos = (TTask*)reF->GetListOfTasks()->FindObject("PHOS") ;
- if ( !phos ) {
- cerr <<"ERROR: AliPHOSGetter::Post Rer -> tasks/Reconstructioner/PHOS" << " not found!" << endl;
- abort() ;
- } else {
- AliPHOSClusterizer * phoscl = (AliPHOSClusterizer*)phos->GetListOfTasks()->FindObject(recpointsName.Data()) ;
- if (phoscl) {
- if (fDebug.Contains("Rer"))
- cout << "INFO: AliPHOSGetter::Post Rer -> Task " << recpointsName.Data() << " already exists" << endl ;
- return ;
- } else
- phos->Add(clusterizer) ;
- }
+// // checks if we are dealing with test-beam data
+// TBranch * btb = rl->TreeE()->GetBranch("AliPHOSBeamTestEvent") ;
+// if(btb){
+// if(!fBTE)
+// fBTE = new AliPHOSBeamTestEvent() ;
+// btb->SetAddress(&fBTE) ;
+// btb->GetEntry(event) ;
+// }
+// else{
+// if(fBTE){
+// delete fBTE ;
+// fBTE = 0 ;
+// }
+// }
- } else if ( strcmp(opt, "T") == 0 ) { //TrackSegments
- // the hierarchy is //YSALICE/WhiteBoard/TrackSegments/PHOS/tracksegmentsname
-
- TClonesArray * tracksegments = new TClonesArray("AliPHOSTrackSegment", 200) ;
- TString tracksegmentsName ;
- if (name)
- tracksegmentsName = name ;
- else
- tracksegmentsName = "TrackSegments" ;
- tracksegments->SetName( tracksegmentsName.Data() ) ;
- TFolder * tracksegmentsF = (TFolder*)aliceF->FindObject("WhiteBoard/TrackSegments/PHOS") ;
- tracksegmentsF->SetTitle(foldertitle) ;
- if ( !tracksegmentsF) {
- cerr << "ERROR: AliPHOSGetter::Post T -> Folder WhiteBoard/TrackSegments/PHOS" << " not found!" << endl;
- abort() ;
- }
- if ( tracksegmentsF->FindObject( tracksegmentsName.Data() ) ) {
- if (fDebug.Contains("T"))
- cerr <<"INFO: AliPHOSGetter::Post T -> Object " << tracksegmentsName.Data()
- << " already exists!" << endl ;
- return ;
- }
- else
- tracksegmentsF->Add(tracksegments) ;
-
- } else if ( strcmp(opt, "Ter") == 0 ) { // TrackSegmentsMaker
- // the hierarchy is //YSALICE/tasks/Reconstructionner/PHOS/tracksegmentsname
- AliPHOSTrackSegmentMaker * tracksegmentmaker ;
- if ( strstr(name, "tsm-v1") != 0 )
- tracksegmentmaker = new AliPHOSTrackSegmentMakerv1() ;
- else {
- cerr << "ERROR: AliPHOSGetter::Post Ter -> " << name << " unknown track segment maker version" << endl ;
- abort() ;
- }
- TString tracksegmentsName ;
- if (name)
- tracksegmentsName = name ;
- else
- tracksegmentsName = "TrackSegmentMaker" ;
- tracksegmentmaker->SetName( tracksegmentsName.Data() ) ;
- TTask * reF = (TTask*)aliceF->FindObject("tasks/Reconstructioner") ;
- if ( !reF ) {
- cerr << "ERROR: AliPHOSGetter::Post Ter -> Task tasks/Reconstructioner" << " not found!" << endl;
- abort() ;
- }
- TTask * phos = (TTask*)reF->GetListOfTasks()->FindObject("PHOS") ;
- if ( !phos ) {
- cerr <<"ERROR: AliPHOSGetter::Post Ter -> tasks/Reconstructioner/PHOS" << " not found!" << endl;
- abort() ;
- } else {
- AliPHOSTrackSegmentMaker * phosts = (AliPHOSTrackSegmentMaker*)phos->GetListOfTasks()->FindObject(tracksegmentsName.Data()) ;
- if (phosts) {
- if (fDebug.Contains("Ter"))
- cout << "INFO: AliPHOSGetter::Post Ter -> Task " << tracksegmentsName.Data() << " already exists" << endl ;
- return ;
- } else
- phos->Add(tracksegmentmaker) ;
- }
+ // Loads the type of object(s) requested
- } else if ( strcmp(opt, "P") == 0 ) { // RecParticles
- // the hierarchy is //YSALICE/WhiteBoard/RecParticles/PHOS/recparticlesname
-
- TClonesArray * recparticles = new TClonesArray("AliPHOSRecParticle", 200) ;
- TString recparticlesName ;
- if (name)
- recparticlesName = name ;
- else
- recparticlesName = "RecParticles" ;
- recparticles->SetName( recparticlesName.Data() ) ;
- TFolder * recparticlesF = (TFolder*)aliceF->FindObject("WhiteBoard/RecParticles/PHOS") ;
- recparticlesF->SetTitle(foldertitle) ;
- if ( !recparticlesF) {
- cerr << "ERROR: AliPHOSGetter::Post P -> Folder WhiteBoard/RecParticles/PHOS" << " not found!" << endl;
- abort() ;
- }
- if ( recparticlesF->FindObject( recparticlesName.Data() ) ) {
- if (fDebug.Contains("P"))
- cerr <<"INFO: AliPHOSGetter::Post P -> Object " << recparticlesName.Data()
- << " already exists!" << endl ;
- return ;
- }
- else
- recparticlesF->Add(recparticles) ;
-
- } else if ( strcmp(opt, "Per") == 0 ) { // PID Maker
- // the hierarchy is //YSALICE/tasks/Reconstructionner/PHOS/recparticlesname
- AliPHOSPID * pid ;
- if ( strstr(name, "pid-v1") != 0 )
- pid = new AliPHOSPIDv1() ;
- else {
- cerr << "ERROR: AliPHOSGetter::Post Per -> " << name << " unknown PID maker version" << endl ;
- abort() ;
- }
- TString recparticlesName ;
- if (name)
- recparticlesName = name ;
- else
- recparticlesName = "PID" ;
- pid->SetName( recparticlesName.Data() ) ;
- TTask * reF = (TTask*)aliceF->FindObject("tasks/Reconstructioner") ;
- if ( !reF ) {
- cerr << "ERROR: AliPHOSGetter::Post Per -> Task tasks/Reconstructioner" << " not found!" << endl;
- abort() ;
- }
- TTask * phos = (TTask*)reF->GetListOfTasks()->FindObject("PHOS") ;
- if ( !phos ) {
- cerr <<"ERROR: AliPHOSGetter::Post Per -> tasks/Reconstructioner/PHOS" << " not found!" << endl;
- abort() ;
- } else {
- AliPHOSPID * phospid = (AliPHOSPID*)phos->GetListOfTasks()->FindObject(recparticlesName.Data()) ;
- if (phospid) {
- if (fDebug.Contains("Per"))
- cout << "INFO: AliPHOSGetter::Post Per -> Task " << recparticlesName.Data() << " already exists" << endl ;
- return ;
- } else
- phos->Add(pid) ;
- }
- }
- else if ( strcmp(opt, "QA") == 0 ) { // Alarms
- // the hierarchy is //YSALICE/WhiteBoard/Alarms/PHOS/
-
- TFolder * alarmsF = new TFolder() ;
- TString alarmsName ;
- if (name)
- alarmsName = name ;
- else
- alarmsName = "Alarm with no name" ;
- alarmsF->SetName( alarmsName.Data() ) ;
- alarmsF->SetTitle(foldertitle) ;
- TFolder * qaaF = (TFolder*)aliceF->FindObject("WhiteBoard/QAAlarms") ;
- if ( !qaaF) {
- cerr << "ERROR: AliPHOSGetter::Post QA -> Folder WhiteBoard/QAAlarms/" << " not found!" << endl;
- return ;
- }
- if ( qaaF->FindObject( alarmsName.Data() ) )
- qaaF->RecursiveRemove( qaaF->FindObject( alarmsName.Data() ) ) ;
-
- qaaF->Add(alarmsF) ;
+ rl->GetEvent(event) ;
+ if(strstr(opt,"X") || (strcmp(opt,"")==0)){
+ ReadPrimaries() ;
+ }
+
+ if(strstr(opt,"H") ){
+ ReadTreeH();
+ }
+
+ if(strstr(opt,"S") ){
+ ReadTreeS() ;
+ }
+
+ if(strstr(opt,"D") ){
+ ReadTreeD() ;
+ }
+
+ if(strstr(opt,"R") ){
+ ReadTreeR() ;
}
+
+ if( strstr(opt,"T") ){
+ ReadTreeT() ;
+ }
+
+ if( strstr(opt,"P") ){
+ ReadTreeP() ;
+ }
+
+ if( strstr(opt,"E") ){
+ ReadTreeE(event) ;
+ }
+
}
+
//____________________________________________________________________________
-const TParticle * AliPHOSGetter::Primary(Int_t index) const
+void AliPHOSGetter::Event(AliRawReader *rawReader, const char* opt)
{
- // Return primary particle numbered by <index>
+ // Reads the raw event from rawReader
- if(index < 0)
- return 0 ;
+ if( strstr(opt,"W") ){
+ ReadRaw(rawReader) ;
+ }
+
+}
+
+
+//____________________________________________________________________________
+Int_t AliPHOSGetter::EventNumber() const
+ {
+ // return the current event number
+ AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
+ return static_cast<Int_t>(rl->GetEventNumber()) ;
+}
+
+//____________________________________________________________________________
+ TClonesArray * AliPHOSGetter::Hits()
+{
+ // asks the loader to return the Hits container
- Int_t primaryIndex = index % 10000000 ;
- Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
+ TClonesArray * rv = 0 ;
- if ( primaryList > 0 ) {
- cout << " Getter does not support currently Mixing of primary " << endl ;
- cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
- return 0;
+ rv = PhosLoader()->Hits() ;
+ if ( !rv ) {
+ PhosLoader()->LoadHits("read");
+ rv = PhosLoader()->Hits() ;
}
-
- return gAlice->Particle(primaryIndex) ;
-
+ return rv ;
}
//____________________________________________________________________________
-void AliPHOSGetter::ReadTreeD()
+AliPHOSGetter * AliPHOSGetter::Instance(const char* alirunFileName, const char* version, Option_t * openingOption)
{
- // Read the digit tree gAlice->TreeD()
- if(gAlice->TreeD()== 0){
- cerr << "ERROR: AliPHOSGetter::ReadTreeD: can not read TreeD " << endl ;
- return ;
- }
-
- TObjArray * lob = (TObjArray*)gAlice->TreeD()->GetListOfBranches() ;
- TIter next(lob) ;
- TBranch * branch = 0 ;
- TBranch * digitsbranch = 0 ;
- TBranch * digitizerbranch = 0 ;
- Bool_t phosfound = kFALSE, digitizerfound = kFALSE ;
+ // Creates and returns the pointer of the unique instance
+ // Must be called only when the environment has changed
- while ( (branch = (TBranch*)next()) && (!phosfound || !digitizerfound) ) {
- if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
- digitsbranch = branch ;
- phosfound = kTRUE ;
+ if(!fgObjGetter){ // first time the getter is called
+ fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
+ }
+ else { // the getter has been called previously
+ AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
+ if ( rl->GetFileName() == alirunFileName ) {// the alirunFile has the same name
+ // check if the file is already open
+ TFile * galiceFile = dynamic_cast<TFile *>(gROOT->FindObject(rl->GetFileName()) ) ;
+
+ if ( !galiceFile )
+ fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
+
+ else { // the file is already open check the version name
+ TString currentVersionName = rl->GetEventFolder()->GetName() ;
+ TString newVersionName(version) ;
+ if (currentVersionName == newVersionName)
+ if(fgDebug)
+ ::Warning( "Instance", "Files with version %s already open", currentVersionName.Data() ) ;
+ else {
+ fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
+ }
+ }
}
- else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
- digitizerbranch = branch ;
- digitizerfound = kTRUE ;
+ else {
+ AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle()) ;
+ if ( strstr(version, AliConfig::GetDefaultEventFolderName()) ) // false in case of merging
+ delete rl ;
+ fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
}
}
+ if (!fgObjGetter)
+ ::Error("AliPHOSGetter::Instance", "Failed to create the PHOS Getter object") ;
+ else
+ if (fgDebug)
+ Print() ;
+
+ return fgObjGetter ;
+}
- if ( !phosfound || !digitizerfound ) {
- cout << "WARNING: AliPHOSGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name " << fDigitsTitle << endl ;
- return ;
- }
-
-
- // Post the Digits
- if (EventNumber() == 0)
- Post(fHeaderFile, "D", fDigitsTitle) ;
+//____________________________________________________________________________
+AliPHOSGetter * AliPHOSGetter::Instance()
+{
+ // Returns the pointer of the unique instance already defined
- // Post the Digitizer
- if (EventNumber() == 0)
- Post(fHeaderFile, "Der", fDigitsTitle) ;
+ if(!fgObjGetter && fgDebug)
+ ::Warning("AliPHOSGetter::Instance", "Getter not initialized") ;
- TClonesArray * digits = Digits(fDigitsTitle) ;
- digits->Clear() ;
- digitsbranch ->SetAddress(&digits) ;
+ return fgObjGetter ;
+
+}
- AliPHOSDigitizer * digitizer = Digitizer(fDigitsTitle) ;
- digitizerbranch->SetAddress(&digitizer) ;
+//____________________________________________________________________________
+Int_t AliPHOSGetter::MaxEvent() const
+{
+ // returns the number of events in the run (from TE)
- digitsbranch ->GetEntry(0) ;
- digitizerbranch->GetEntry(0) ;
-
+ AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
+ return static_cast<Int_t>(rl->GetNumberOfEvents()) ;
}
//____________________________________________________________________________
-void AliPHOSGetter::ReadTreeH()
+TParticle * AliPHOSGetter::Primary(Int_t index) const
{
- // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
+ AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
+ return rl->Stack()->Particle(index) ;
+}
+
+//____________________________________________________________________________
+AliPHOS * AliPHOSGetter:: PHOS() const
+{
+ // returns the PHOS object
+ AliPHOSLoader * loader = 0;
+ static AliPHOSLoader * oldloader = 0;
+ static AliPHOS * phos = 0;
- if(gAlice->TreeH()== 0){
- cerr << "ERROR: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
- return ;
+ loader = PhosLoader();
+
+ if ( loader != oldloader) {
+ phos = dynamic_cast<AliPHOS*>(loader->GetModulesFolder()->FindObject("PHOS")) ;
+ oldloader = loader;
}
-
- TBranch * hitsbranch = (TBranch*)gAlice->TreeH()->GetListOfBranches()->FindObject("PHOS") ;
- if ( !hitsbranch ) {
- cout << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ;
- } else {
- TClonesArray * hits = Hits() ;
- hits->Clear() ;
- hitsbranch->SetAddress(&hits) ;
- hitsbranch->GetEntry(0) ;
+ if (!phos)
+ if (fgDebug)
+ Warning("PHOS", "PHOS module not found in module folders: %s", PhosLoader()->GetModulesFolder()->GetName() ) ;
+ return phos ;
+}
+
+
+
+//____________________________________________________________________________
+AliPHOSPID * AliPHOSGetter::PID()
+{
+ // Returns pointer to the PID task
+ AliPHOSPID * rv ;
+ rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
+ if (!rv) {
+ Event(0, "P") ;
+ rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
}
+ return rv ;
}
//____________________________________________________________________________
-void AliPHOSGetter::ReadTreeQA()
+AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
{
- // Read the digit tree gAlice->TreeQA()
- // so far only PHOS knows about this Tree
+ // Returns PHOS geometry
- if(PHOS()->TreeQA()== 0){
- cerr << "ERROR: AliPHOSGetter::ReadTreeQA: can not read TreeQA " << endl ;
- return ;
- }
-
- TBranch * qabranch = PHOS()->TreeQA()->GetBranch("PHOS") ;
- if (!qabranch) {
- cout << "WARNING: AliPHOSGetter::ReadTreeQA -> Cannot find QA Alarms for PHOS" << endl ;
- return ;
- }
-
- // Post the QA Alarms
- Post(fHeaderFile, "QA", "PHOS") ;
- TFolder * alarmsF = Alarms() ;
- alarmsF->Clear() ;
- qabranch->SetAddress(&alarmsF) ;
- qabranch->GetEntry(0) ;
-
+ AliPHOSGeometry * rv = 0 ;
+ if (PHOS() )
+ rv = PHOS()->GetGeometry() ;
+ return rv ;
+}
+
+//____________________________________________________________________________
+TClonesArray * AliPHOSGetter::Primaries()
+{
+ // creates the Primaries container if needed
+ if ( !fPrimaries ) {
+ if (fgDebug)
+ Info("Primaries", "Creating a new TClonesArray for primaries") ;
+ fPrimaries = new TClonesArray("TParticle", 1000) ;
+ }
+ return fPrimaries ;
}
//____________________________________________________________________________
-void AliPHOSGetter::ReadTreeR()
+void AliPHOSGetter::Print()
{
- // Read the reconstrunction tree gAlice->TreeR()
+ // Print usefull information about the getter
+
+ AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
+ ::Info( "Print", "gAlice file is %s -- version name is %s", (rl->GetFileName()).Data(), rl->GetEventFolder()->GetName() ) ;
+}
- if(gAlice->TreeR()== 0){
- cout << "ERROR: AliPHOSGetter::ReadTreeR: can not read TreeR " << endl ;
- return ;
- }
- // RecPoints
- TObjArray * lob = (TObjArray*)gAlice->TreeR()->GetListOfBranches() ;
- TIter next(lob) ;
- TBranch * branch = 0 ;
- TBranch * emcbranch = 0 ;
- TBranch * cpvbranch = 0 ;
- TBranch * clusterizerbranch = 0 ;
- Bool_t phosemcrpfound = kFALSE, phoscpvrpfound = kFALSE, clusterizerfound = kFALSE ;
+//____________________________________________________________________________
+void AliPHOSGetter::ReadPrimaries()
+{
+ // Read Primaries from Kinematics.root
- while ( (branch = (TBranch*)next()) && (!phosemcrpfound || !phoscpvrpfound || !clusterizerfound) ) {
- if ( (strcmp(branch->GetName(), "PHOSEmcRP")==0) && (strcmp(branch->GetTitle(), fRecPointsTitle)==0) ) {
- emcbranch = branch ;
- phosemcrpfound = kTRUE ;
- }
- else if ( (strcmp(branch->GetName(), "PHOSCpvRP")==0) && (strcmp(branch->GetTitle(), fRecPointsTitle)==0) ) {
- cpvbranch = branch ;
- phoscpvrpfound = kTRUE ;
- }
- else if ( (strcmp(branch->GetName(), "AliPHOSClusterizer")==0) && (strcmp(branch->GetTitle(), fRecPointsTitle)==0) ) {
- clusterizerbranch = branch ;
- clusterizerfound = kTRUE ;
- }
+ AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
+
+ // gets kine tree from the root file (Kinematics.root)
+ if ( ! rl->TreeK() ) { // load treeK the first time
+ rl->LoadKinematics() ;
}
+
+ fNPrimaries = (rl->GetHeader())->GetNtrack();
+ if (fgDebug)
+ Info( "ReadTreeK", "Found %d particles in event # %d", fNPrimaries, EventNumber() ) ;
- if ( !phosemcrpfound || !phoscpvrpfound || !clusterizerfound ) {
- cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find RecPoints and/or Clusterizer with name " << fRecPointsTitle << endl ;
- return ;
- }
-
- // Post the RecPoints
- if (EventNumber() == 0)
- Post(fHeaderFile, "R", fRecPointsTitle) ;
-
- // Post the Clusterizer
- // Need the version first
- AliPHOSClusterizer * clusterizer = 0 ;
- clusterizerbranch->SetAddress(&clusterizer) ;
- clusterizerbranch->GetEntry(0) ;
- TString clusterizerName(fRecPointsTitle) ;
- clusterizerName.Append(clusterizer->Version()) ;
- if (EventNumber() == 0)
- Post(fHeaderFile, "Rer", clusterizerName) ;
-
- TObjArray * emcRecPoints = EmcRecPoints(fRecPointsTitle) ;
- emcRecPoints->Delete() ;
- emcbranch->SetAddress(&emcRecPoints) ;
-
- TObjArray * cpvRecPoints = CpvRecPoints(fRecPointsTitle) ;
- cpvRecPoints->Delete() ;
- cpvbranch->SetAddress(&cpvRecPoints) ;
-
- delete clusterizer ;
- clusterizer = Clusterizer(clusterizerName) ;
- clusterizerbranch->SetAddress(&clusterizer) ;
-
- emcbranch ->GetEntry(0) ;
- cpvbranch ->GetEntry(0) ;
- clusterizerbranch->GetEntry(0) ;
-
- // TrackSegments
- next.Reset() ;
- TBranch * tsbranch = 0 ;
- TBranch * tsmakerbranch = 0 ;
- Bool_t phostsfound = kFALSE, tsmakerfound = kFALSE ;
+
+ // first time creates the container
+ if ( Primaries() )
+ fPrimaries->Clear() ;
- while ( (branch = (TBranch*)next()) && (!phostsfound || !tsmakerfound) ) {
- if ( (strcmp(branch->GetName(), "PHOSTS")==0) && (strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0) ) {
- tsbranch = branch ;
- phostsfound = kTRUE ;
- }
- else if ( (strcmp(branch->GetName(), "AliPHOSTrackSegmentMaker")==0) && (strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0) ) {
- tsmakerbranch = branch ;
- tsmakerfound = kTRUE ;
- }
+ Int_t index = 0 ;
+ for (index = 0 ; index < fNPrimaries; index++) {
+ new ((*fPrimaries)[index]) TParticle(*(Primary(index)));
}
+}
- if ( !phostsfound || !tsmakerfound ) {
- cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name " << fTrackSegmentsTitle << endl ;
- return ;
- }
+//____________________________________________________________________________
+Bool_t AliPHOSGetter::OpenESDFile()
+{
+ //Open the ESD file
+ Bool_t rv = kTRUE ;
+ if (!fESDFile) {
+ fESDFile = TFile::Open(fESDFileName) ;
+ if (!fESDFile )
+ return kFALSE ;
+ }
+ else if (fESDFile->IsOpen()) {
+ fESDFile->Close() ;
+ fESDFile = TFile::Open(fESDFileName) ;
+ }
+ if (!fESDFile->IsOpen())
+ rv = kFALSE ;
+ return rv ;
+}
+
+//____________________________________________________________________________
+Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader)
+{
+ // reads the raw format data, converts it into digits format and store digits in Digits()
+ // container.
- // Post the TrackSegments
- if (EventNumber() == 0)
- Post(fHeaderFile, "T", fTrackSegmentsTitle) ;
-
- // Post the TrackSegment Maker
- // Need the version first
- AliPHOSTrackSegmentMaker * tsmaker = 0 ;
- tsmakerbranch->SetAddress(&tsmaker) ;
- tsmakerbranch->GetEntry(0) ;
- TString tsmakerName(fTrackSegmentsTitle) ;
- tsmakerName.Append(tsmaker->Version()) ;
- if (EventNumber() == 0)
- Post(fHeaderFile, "Ter", tsmakerName) ;
-
- TClonesArray * tracksegments = TrackSegments(fTrackSegmentsTitle) ;
- tracksegments->Clear() ;
- tsbranch->SetAddress(&tracksegments) ;
+ AliPHOSRawStream in(rawReader);
- delete tsmaker ;
- tsmaker = TrackSegmentMaker(tsmakerName) ;
- tsmakerbranch->SetAddress(&tsmaker) ;
-
- tsmakerbranch ->GetEntry(0) ;
- tsbranch ->GetEntry(0) ;
-
- // RecParticles
- next.Reset() ;
- TBranch * rpabranch = 0 ;
- TBranch * pidbranch = 0 ;
- Bool_t phosrpafound = kFALSE, pidfound = kFALSE ;
-
- while ( (branch = (TBranch*)next()) && (!phosrpafound || !pidfound) ) {
- if ( (strcmp(branch->GetName(), "PHOSRP")==0) && (strcmp(branch->GetTitle(), fRecParticlesTitle)==0) ) {
- rpabranch = branch ;
- phosrpafound = kTRUE ;
- }
- else if ( (strcmp(branch->GetName(), "AliPHOSPID")==0) && (strcmp(branch->GetTitle(), fRecParticlesTitle)==0) ) {
- pidbranch = branch ;
- pidfound = kTRUE ;
- }
- }
+ TClonesArray * digits = Digits() ;
+ digits->Clear() ;
+ Int_t idigit = 0 ;
- if ( !phosrpafound || !pidfound ) {
- cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name " << fRecParticlesTitle << endl ;
- return ;
- }
+ while ( in.Next() ) { // PHOS entries loop
+
+ Int_t amp = in.GetSignal() ;
+ Double_t time = in.GetTime() ;
+ Int_t relId[4], id ;
- // Post the RecParticles
- if (EventNumber() == 0)
- Post(fHeaderFile, "P", fRecParticlesTitle) ;
-
- // Post the PID
- // Need the version first
- AliPHOSPID * pid = 0 ;
- pidbranch->SetAddress(&pid) ;
- pidbranch->GetEntry(0) ;
- TString pidName(fRecParticlesTitle) ;
- pidName.Append(pid->Version()) ;
- if (EventNumber() == 0)
- Post(fHeaderFile, "Per", pidName) ;
-
- TClonesArray * recParticles = RecParticles(fRecParticlesTitle) ;
- recParticles->Clear() ;
- rpabranch->SetAddress(&recParticles) ;
-
- delete pid ;
- pid = PID(pidName) ;
- pidbranch->SetAddress(&pid) ;
+ relId[0] = in.GetModule() ;
+ if ( relId[0] >= PHOS()->GetRawFormatLowGainOffset() ) {
+ relId[0] -= PHOS()->GetRawFormatLowGainOffset() ;
+ }
+ relId[1] = 0 ;
+ relId[2] = in.GetRow() ;
+ relId[3] = in.GetColumn() ;
+ PHOSGeometry()->RelToAbsNumbering(relId, id) ;
+
+ if (amp > 0 && id >=0 ) {
+ new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
+ idigit++ ;
+ }
+
+ } // PHOS entries loop
- pidbranch ->GetEntry(0) ;
- rpabranch ->GetEntry(0) ;
+ digits->Sort() ;
+
+ return digits->GetEntriesFast() ;
+}
+//____________________________________________________________________________
+Int_t AliPHOSGetter::ReadTreeD()
+{
+ // Read the Digits
+ PhosLoader()->CleanDigits() ;
+ PhosLoader()->LoadDigits("UPDATE") ;
+ PhosLoader()->LoadDigitizer("UPDATE") ;
+ return Digits()->GetEntries() ;
}
//____________________________________________________________________________
-void AliPHOSGetter::ReadTreeS()
+Int_t AliPHOSGetter::ReadTreeH()
{
- // Read the summable digits tree gAlice->TreeS()
+ // Read the Hits
+ PhosLoader()->CleanHits() ;
+ // gets TreeH from the root file (PHOS.Hit.root)
+ //if ( !IsLoaded("H") ) {
+ PhosLoader()->LoadHits("UPDATE") ;
+ // SetLoaded("H") ;
+ //}
+ return Hits()->GetEntries() ;
+}
- if(gAlice->TreeS()== 0){
- cerr << "ERROR: AliPHOSGetter::ReadTreeS -> Cannot find TreeS " << endl ;
- return ;
- }
-
- TObjArray * lob = (TObjArray*)gAlice->TreeS()->GetListOfBranches() ;
- TIter next(lob) ;
- TBranch * branch = 0 ;
- TBranch * sdigitsbranch = 0 ;
- TBranch * sdigitizerbranch = 0 ;
- Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
+//____________________________________________________________________________
+Int_t AliPHOSGetter::ReadTreeR()
+{
+ // Read the RecPoints
- while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) {
- if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
- sdigitsbranch = branch ;
- phosfound = kTRUE ;
- }
- else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
- sdigitizerbranch = branch ;
- sdigitizerfound = kTRUE ;
- }
- }
+ PhosLoader()->CleanRecPoints() ;
+ // gets TreeR from the root file (PHOS.RecPoints.root)
+ //if ( !IsLoaded("R") ) {
+ PhosLoader()->LoadRecPoints("UPDATE") ;
+ PhosLoader()->LoadClusterizer("UPDATE") ;
+ // SetLoaded("R") ;
+ //}
- if ( !phosfound || !sdigitizerfound ) {
- cout << "WARNING: AliPHOSGetter::ReadTreeS -> Cannot find SDigits and/or SDigitizer with name " << fSDigitsTitle << endl ;
- return ;
- }
+ return EmcRecPoints()->GetEntries() ;
+}
- // -- the SDigits
- if (EventNumber() == 0)
- Post(fHeaderFile, "S", fSDigitsTitle) ;
+//____________________________________________________________________________
+Int_t AliPHOSGetter::ReadTreeT()
+{
+ // Read the TrackSegments
+
+ PhosLoader()->CleanTracks() ;
+ // gets TreeT from the root file (PHOS.TrackSegments.root)
+ //if ( !IsLoaded("T") ) {
+ PhosLoader()->LoadTracks("UPDATE") ;
+ PhosLoader()->LoadTrackSegmentMaker("UPDATE") ;
+ // SetLoaded("T") ;
+ //}
- // Post the SDigitizer
- if (EventNumber() == 0)
- Post(fHeaderFile, "Ser", fSDigitsTitle) ;
+ return TrackSegments()->GetEntries() ;
+}
+//____________________________________________________________________________
+Int_t AliPHOSGetter::ReadTreeP()
+{
+ // Read the RecParticles
- TClonesArray * sdigits = SDigits(fSDigitsTitle) ;
- sdigits->Clear() ;
- sdigitsbranch->SetAddress(&sdigits) ;
+ PhosLoader()->CleanRecParticles() ;
- AliPHOSSDigitizer * sdigitizer = SDigitizer(fSDigitsTitle) ;
- sdigitizerbranch->SetAddress(&sdigitizer) ;
+ // gets TreeT from the root file (PHOS.TrackSegments.root)
+ // if ( !IsLoaded("P") ) {
+ PhosLoader()->LoadRecParticles("UPDATE") ;
+ PhosLoader()->LoadPID("UPDATE") ;
+ // SetLoaded("P") ;
+ //}
- sdigitsbranch->GetEvent(0) ;
- sdigitizerbranch->GetEvent(0) ;
-
+ return RecParticles()->GetEntries() ;
+}
+//____________________________________________________________________________
+Int_t AliPHOSGetter::ReadTreeS()
+{
+ // Read the SDigits
+
+ PhosLoader()->CleanSDigits() ;
+ // gets TreeS from the root file (PHOS.SDigits.root)
+ //if ( !IsLoaded("S") ) {
+ PhosLoader()->LoadSDigits("READ") ;
+ PhosLoader()->LoadSDigitizer("READ") ;
+ // SetLoaded("S") ;
+ //}
+
+ return SDigits()->GetEntries() ;
}
//____________________________________________________________________________
-void AliPHOSGetter::ReadPrimaries()
+Int_t AliPHOSGetter::ReadTreeE(Int_t event)
{
- // Reads specific branches of primaries
+ // Read the ESD
- fNPrimaries = gAlice->GetNtrack();
+ // gets esdTree from the root file (AliESDs.root)
+ if (!fESDFile)
+ if ( !OpenESDFile() )
+ return -1 ;
+
+ fESDTree = static_cast<TTree*>(fESDFile->Get("esdTree")) ;
+ fESD = new AliESD;
+ if (!fESDTree) {
+
+ Error("ReadTreeE", "no ESD tree found");
+ return -1;
+ }
+ fESDTree->SetBranchAddress("ESD", &fESD);
+ fESDTree->GetEvent(event);
+
+ return event ;
+}
+
+//____________________________________________________________________________
+TClonesArray * AliPHOSGetter::SDigits()
+{
+ // asks the Loader to return the Digits container
+
+ TClonesArray * rv = 0 ;
- // //Check, is it necessary to open new files
- // TArrayI* events = fDigitizer->GetCurrentEvents() ;
- // TClonesArray * filenames = fDigitizer->GetHeadersFiles() ;
-// Int_t input ;
-// for(input = 0; input < filenames->GetEntriesFast(); input++){
-
-// TObjString * filename = (TObjString *) filenames->At(input) ;
-
-// //Test, if this file already open
-// TFile *file = (TFile*) gROOT->GetFile( filename->GetString() ) ;
-// if(file == 0)
-// file = new TFile( filename->GetString()) ;
-// file->cd() ;
-
-// // Get Kine Tree from file
-// // char treeName[20];
-// // sprintf(treeName,"TreeK%d",events->At(input));
-// // TTree * treeK = (TTree*)gDirectory->Get(treeName);
-// // if (treeK)
-// // treeK->SetBranchAddress("Particles", &fParticleBuffer);
-// // else
-// // cout << "AliPHOSGetter: cannot find Kine Tree for event:" << events->At(input) << endl;
-
-// // // Create the particle stack
-// // if(!fParticles) fParticles = new TClonesArray("TParticle",1000);
-// // // Build the pointer list
-// // if(fParticleMap) { <----
-// // fParticleMap->Clear();
-// // fParticleMap->Expand(treeK->GetEntries());
-// // } else
-// // fParticleMap = new TObjArray(treeK->GetEntries());
-
-// // From gAlice->Particle(i)
+ rv = PhosLoader()->SDigits() ;
+ if (!rv) {
+ PhosLoader()->MakeSDigitsArray() ;
+ rv = PhosLoader()->SDigits() ;
+ }
+ return rv ;
+}
+//____________________________________________________________________________
+AliPHOSSDigitizer * AliPHOSGetter::SDigitizer()
+{
+ // Returns pointer to the SDigitizer task
+ AliPHOSSDigitizer * rv ;
+ rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
+ if (!rv) {
+ Event(0, "S") ;
+ rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
+ }
+ return rv ;
+}
-// // if(!(*fParticleMap)[i]) {
-// // Int_t nentries = fParticles->GetEntries();
-
-// // // algorithmic way of getting entry index
-// // // (primary particles are filled after secondaries)
-// // Int_t entry;
-// // if (i<fHeader.GetNprimary())
-// // entry = i+fHeader.GetNsecondary();
-// // else
-// // entry = i-fHeader.GetNprimary();
-
-// // // only check the algorithmic way and give
-// // // the fatal error if it is wrong
-// // if (entry != fParticleFileMap[i]) {
-// // Fatal("Particle",
-// // "!!!! The algorithmic way is WRONG: !!!\n entry: %d map: %d",
-// // entry, fParticleFileMap[i]);
-// // }
-
-// // fTreeK->GetEntry(fParticleFileMap[i]);
-// // new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
-// // fParticleMap->AddAt((*fParticles)[nentries],i);
-// // }
-// // return (TParticle *) (*fParticleMap)[i];
+//____________________________________________________________________________
+TParticle * AliPHOSGetter::Secondary(const TParticle* p, Int_t index) const
+{
+ // Return first (index=1) or second (index=2) secondary particle of primary particle p
-
-
-// }
+ if(index <= 0)
+ return 0 ;
+ if(index > 2)
+ return 0 ;
+
+ if(p) {
+ Int_t daughterIndex = p->GetDaughter(index-1) ;
+ AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
+ return rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ;
+ }
+ else
+ return 0 ;
+}
+
+//____________________________________________________________________________
+void AliPHOSGetter::Track(Int_t itrack)
+{
+ // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
+
+ AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
+ if( !TreeH() ) // load treeH the first time
+ rl->LoadHits() ;
-// //scan over opened files and read corresponding TreeK##
+ // first time create the container
+ TClonesArray * hits = Hits() ;
+ if ( hits )
+ hits->Clear() ;
- return ;
+ TBranch * phosbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("PHOS")) ;
+ phosbranch->SetAddress(&hits) ;
+ phosbranch->GetEntry(itrack) ;
}
+
//____________________________________________________________________________
-void AliPHOSGetter::Event(Int_t event)
+TTree * AliPHOSGetter::TreeD() const
{
- // Reads the content of all Tree's S, D and R
+ // Returns pointer to the Digits Tree
+ TTree * rv = 0 ;
+ rv = PhosLoader()->TreeD() ;
+ if ( !rv ) {
+ PhosLoader()->MakeTree("D");
+ rv = PhosLoader()->TreeD() ;
+ }
- if ( event > gAlice->TreeE()->GetEntries() ) {
- cerr << "ERROR: AliPHOSGetter::Event -> There are only " << gAlice->TreeE()->GetEntries() << " events in this file" << endl ;
- return ;
- }
+ return rv ;
+}
+
+//____________________________________________________________________________
+TTree * AliPHOSGetter::TreeH() const
+{
+ // Returns pointer to the Hits Tree
+ TTree * rv = 0 ;
+ rv = PhosLoader()->TreeH() ;
+ if ( !rv ) {
+ PhosLoader()->MakeTree("H");
+ rv = PhosLoader()->TreeH() ;
+ }
- gAlice->GetEvent(event) ;
- gAlice->SetEvent(event) ;
-
- ReadTreeH() ;
- ReadTreeS() ;
- ReadTreeD() ;
- ReadTreeR() ;
- //ReadTreeQA() ;
- ReadPrimaries() ;
+ return rv ;
}
//____________________________________________________________________________
-const TObject * AliPHOSGetter::ReturnO(TString what, TString name, TString file) const
+TTree * AliPHOSGetter::TreeR() const
{
- // get the object named "what" from the folder
- // folders are named like //YSAlice/WhiteBoard/what/PHOS/name
-
- if ( file.IsNull() )
- file = fHeaderFile ;
- TString path("WhiteBoard/") ;
- if ( name.IsNull() ) {
- if ( what.CompareTo("Hits") == 0 ) {
- path += what ;
- path += "/PHOS/";
- path += what ;
- }
- else if ( what.CompareTo("SDigits") == 0 ) {
- path += what ;
- path += "/PHOS/";
- path += file ;
- path += "/" ;
- path += fSDigitsTitle ;
- }
- else if ( what.CompareTo("Digits") == 0 ){
- path += what ;
- path += "/PHOS/";
- path += fDigitsTitle ;
- }
- else if ( what.CompareTo("EmcRecPoints") == 0 ) {
- path += "RecPoints/PHOS/";
- path += "emc/" ;
- path += fRecPointsTitle ;
- }
- else if ( what.CompareTo("CpvRecPoints") == 0 ) {
- path += "RecPoints/PHOS/";
- path += "cpv/" ;
- path += fRecPointsTitle ;
- }
- else if ( what.CompareTo("TrackSegments") == 0 ) {
- path += "TrackSegments/PHOS/";
- path += fTrackSegmentsTitle ;
- }
- else if ( what.CompareTo("RecParticles") == 0 ) {
- path += "RecParticles/PHOS/";
- path += fRecParticlesTitle ;
- }
- else if ( what.CompareTo("Alarms") == 0 ) {
- path += "QAAlarms/PHOS";
- }
+ // Returns pointer to the RecPoints Tree
+ TTree * rv = 0 ;
+ rv = PhosLoader()->TreeR() ;
+ if ( !rv ) {
+ PhosLoader()->MakeTree("R");
+ rv = PhosLoader()->TreeR() ;
}
- else {
- if ( what.CompareTo("SDigits") == 0 ) {
- path += what ;
- path += "/PHOS/";
- path += file ;
- path += "/" ;
- path += name ;
- }
- else if ( what.CompareTo("Digits") == 0 ) {
- path += what ;
- path += "/PHOS/";
- path += name ;
- }
- else if ( what.CompareTo("EmcRecPoints") == 0 ) {
- path += "RecPoints/PHOS/";
- path += "emc/" ;
- path += name ;
- }
- else if ( what.CompareTo("CpvRecPoints") == 0 ) {
- path += "RecPoints/PHOS/";
- path += "cpv/" ;
- path += name ;
- }
- else if ( what.CompareTo("TrackSegments") == 0 ) {
- path += "TrackSegments/PHOS/";
- path += name ;
- }
- else if ( what.CompareTo("RecParticles") == 0 ) {
- path += "RecParticles/PHOS/";
- path += name ;
- }
- else if ( what.CompareTo("Alarms") == 0 ) {
- path += "QAAlarms/PHOS/";
- path += name ;
- }
- }
- path.Prepend("YSAlice/") ;
- TObject * phosO = (TObject*)gROOT->FindObjectAny(path) ;
- if (!phosO) {
- cerr << "ERROR : AliPHOSGetter::ReturnO -> Object " << path << " not found!" << endl ;
- abort() ;
- }
- return phosO ;
+
+ return rv ;
}
+
+//____________________________________________________________________________
+TTree * AliPHOSGetter::TreeT() const
+{
+ // Returns pointer to the TrackSegments Tree
+ TTree * rv = 0 ;
+ rv = PhosLoader()->TreeT() ;
+ if ( !rv ) {
+ PhosLoader()->MakeTree("T");
+ rv = PhosLoader()->TreeT() ;
+ }
+ return rv ;
+}
//____________________________________________________________________________
-const TTask * AliPHOSGetter::ReturnT(TString what, TString name) const
+TTree * AliPHOSGetter::TreeP() const
{
- // get the TTask named "what" from the folder
- // folders are named like //YSAlice/Tasks/what/PHOS/name
+ // Returns pointer to the RecParticles Tree
+ TTree * rv = 0 ;
+ rv = PhosLoader()->TreeP() ;
+ if ( !rv ) {
+ PhosLoader()->MakeTree("P");
+ rv = PhosLoader()->TreeP() ;
+ }
+
+ return rv ;
+}
- TString path("tasks") ;
-
- if ( what.CompareTo("SDigitizer") == 0 )
- path += "/SDigitizer" ;
- else if ( what.CompareTo("Digitizer") == 0 )
- path += "/Digitizer" ;
- else if ( what.CompareTo("Clusterizer") == 0 )
- path += "/Reconstructioner" ;
- else if ( what.CompareTo("TrackSegmentMaker") == 0 )
- path += "/Reconstructioner" ;
- else if ( what.CompareTo("PID") == 0 )
- path += "/Reconstructioner" ;
- else if ( what.CompareTo("QATasks") == 0 )
- path += "/QA" ;
-
- TFolder * aliceF = (TFolder*)gROOT ->FindObjectAny("YSAlice") ;
- TTask * aliceT = (TTask*) aliceF->FindObject(path) ;
-
- if (!aliceT) {
- cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << path << " not found!" << endl ;
- abort() ;
- }
+//____________________________________________________________________________
+TTree * AliPHOSGetter::TreeS() const
+{
+ // Returns pointer to the SDigits Tree
+ TTree * rv = 0 ;
+ rv = PhosLoader()->TreeS() ;
+ if ( !rv ) {
+ PhosLoader()->MakeTree("S");
+ rv = PhosLoader()->TreeS() ;
+ }
+
+ return rv ;
+}
- TTask * phosT = (TTask*) aliceT->GetListOfTasks()->FindObject("PHOS") ;
- if (!phosT) {
- cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << path << "/PHOS not found!" << endl ;
- abort() ;
- }
- TList * l = phosT->GetListOfTasks() ;
+//____________________________________________________________________________
+Bool_t AliPHOSGetter::VersionExists(TString & opt) const
+{
+ // checks if the version with the present name already exists in the same directory
+
+ Bool_t rv = kFALSE ;
- if (what.CompareTo("SDigitizer") == 0) {
- if ( name.IsNull() )
- name = fSDigitsTitle ;
- } else if (what.CompareTo("Digitizer") == 0){
- if ( name.IsNull() )
- name = fDigitsTitle ;
- } else if (what.CompareTo("Clusterizer") == 0){
- if ( name.IsNull() )
- name = fRecPointsTitle ;
- }
- else if (what.CompareTo("TrackSegmentMaker") == 0){
- if ( name.IsNull() )
- name = fTrackSegmentsTitle ;
- }
- else if (what.CompareTo("PID") == 0){
- if ( name.IsNull() )
- name = fRecParticlesTitle ;
+ AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
+ TString version( rl->GetEventFolder()->GetName() ) ;
+
+ opt.ToLower() ;
+
+ if ( opt == "sdigits") {
+ // add the version name to the root file name
+ TString fileName( PhosLoader()->GetSDigitsFileName() ) ;
+ if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
+ fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
+ if ( !(gSystem->AccessPathName(fileName)) ) {
+ Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
+ rv = kTRUE ;
+ }
+ PhosLoader()->SetSDigitsFileName(fileName) ;
}
- else if (what.CompareTo("QATasks") == 0){
- if ( name.IsNull() )
- return phosT ;
+
+ if ( opt == "digits") {
+ // add the version name to the root file name
+ TString fileName( PhosLoader()->GetDigitsFileName() ) ;
+ if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
+ fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
+ if ( !(gSystem->AccessPathName(fileName)) ) {
+ Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
+ rv = kTRUE ;
+ }
}
- TTask * task = (TTask*)l->FindObject(name) ;
+ return rv ;
- if (!task)
- cout << "WARNING: AliPHOSGetter::ReturnT -> Task " << path << "/" << name << " not found!" << endl ;
-
- return task ;
+}
+
+//____________________________________________________________________________
+UShort_t AliPHOSGetter::EventPattern(void) const
+{
+ // Return the pattern (trigger bit register) of the beam-test event
+ if(fBTE)
+ return fBTE->GetPattern() ;
+ else
+ return 0 ;
+}
+//____________________________________________________________________________
+Float_t AliPHOSGetter::BeamEnergy(void) const
+{
+ // Return the beam energy of the beam-test event
+ if(fBTE)
+ return fBTE->GetBeamEnergy() ;
+ else
+ return 0 ;
}