* 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 "TParticle.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 "AliConfig.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 "AliPHOSClusterizer.h"
-#include "AliPHOSTrackSegmentMaker.h"
-#include "AliPHOSTrackSegmentMaker.h"
-#include "AliPHOSTrackSegment.h"
-#include "AliPHOSPID.h"
-#include "AliPHOSPID.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"
+#include "AliCDBLocal.h"
+#include "AliCDBStorage.h"
+#include "AliCDBManager.h"
ClassImp(AliPHOSGetter)
- AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
+AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
+AliPHOSLoader * AliPHOSGetter::fgPhosLoader = 0;
+Int_t AliPHOSGetter::fgDebug = 0;
+AliPHOSCalibData* AliPHOSGetter::fCalibData = 0;
+AliPHOSAlignData* AliPHOSGetter::fAlignData = 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
-
- fDebug = 0 ;
-
- fHeaderFile = headerFile ;
- fBranchTitle = branchTitle ;
- fSDigitsTitle = branchTitle ;
- fDigitsTitle = branchTitle ;
- fRecPointsTitle = branchTitle ;
- fRecParticlesTitle = branchTitle ;
- fTrackSegmentsTitle = branchTitle ;
-
- fPrimaries = new TObjArray(1) ;
-
- fModuleFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Configuration/Modules"));
- fPrimariesFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data"));
- fHitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/Hits"));
- fSDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/SDigits"));
- fDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/Data"));
- fRecoFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/RecData"));
- fQAFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Conditions/QA"));
- fTasksFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Tasks")) ;
-
- fFailed = kFALSE ;
-
- if ( fHeaderFile != "aliroot" ) { // to call the getter without a file
-
- //open headers file
- fFile = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
- if(!fFile) { //if file was not opened yet, read gAlice
- fFile = TFile::Open(fHeaderFile.Data(),"update") ;
-
- if (!fFile->IsOpen()) {
- cerr << "ERROR : AliPHOSGetter::AliPHOSGetter -> Cannot open " << fHeaderFile.Data() << endl ;
- fFailed = kTRUE ;
- return ;
- }
- gAlice = static_cast<AliRun *>(fFile->Get("gAlice")) ;
+ // 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 (!gAlice) {
- cerr << "ERROR : AliPHOSGetter::AliPHOSGetter -> Cannot find gAlice in " << fHeaderFile.Data() << endl ;
- fFailed = kTRUE ;
- return ;
- }
- if (!PHOS()) {
- if (fDebug)
- cout << "INFO: AliPHOSGetter -> Posting PHOS to Folders" << endl ;
- if (gAlice->GetDetector("PHOS")) {
- AliConfig * conf = AliConfig::Instance() ;
- conf->Add(static_cast<AliDetector*>(gAlice->GetDetector("PHOS"))) ;
- conf->Add(static_cast<AliModule*>(gAlice->GetDetector("PHOS"))) ;
+ if (rl->GetAliRun() == 0x0) {
+ rl->LoadgAlice();
+ gAlice = rl->GetAliRun(); // should be removed
+ rl->LoadHeader();
}
- else
- cerr << "ERROR: AliPHOSGetter -> detector PHOS not found" << endl ;
}
-
- fDebug=0;
+ 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 ;
+
}
-//____________________________________________________________________________
-AliPHOSGetter::~AliPHOSGetter(){
- if (fPrimaries) {
+//____________________________________________________________________________
+AliPHOSGetter::~AliPHOSGetter()
+{
+ // dtor
+ if(fgPhosLoader){
+ delete fgPhosLoader ;
+ fgPhosLoader = 0 ;
+ }
+ if(fBTE){
+ delete fBTE ;
+ fBTE = 0 ;
+ }
+ if(fPrimaries){
fPrimaries->Delete() ;
- delete fPrimaries ;
- }
-
- TFolder * phosF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
- TCollection * folderslist = phosF->GetListOfFolders() ;
- TIter next(folderslist) ;
- TFolder * folder = 0 ;
- while ( (folder = static_cast<TFolder*>(next())) )
- phosF->Remove(folder) ;
-
- fFile->Close() ;
- delete fFile ;
- fFile = 0 ;
-
+ delete fPrimaries ;
+ }
+ if (fESD)
+ delete fESD ;
+ if (fESDTree)
+ delete fESDTree ;
+
+ fgObjGetter = 0;
}
//____________________________________________________________________________
-void AliPHOSGetter::CreateWhiteBoard() const
+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 (fPrimaries) {
+ fPrimaries->Delete() ;
+ delete fPrimaries ;
+ }
+ fgPhosLoader = 0;
+ fgObjGetter = 0;
}
//____________________________________________________________________________
-AliPHOSGetter * AliPHOSGetter::GetInstance()
-{
- // 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 ;
-
- return rv ;
+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()) ;
+ }
+ return rv ;
}
//____________________________________________________________________________
-AliPHOSGetter * AliPHOSGetter::GetInstance(const char* headerFile,
- const char* branchTitle)
+TObjArray * AliPHOSGetter::CpvRecPoints()
{
- // Creates and returns the pointer of the unique instance
- // Must be called only when the environment has changed
-
- if ( fgObjGetter )
- if((fgObjGetter->fBranchTitle.CompareTo(branchTitle) == 0) &&
- (fgObjGetter->fHeaderFile.CompareTo(headerFile)==0))
- return fgObjGetter ;
- else
- fgObjGetter->~AliPHOSGetter() ; // delete it already exists another version
-
- fgObjGetter = new AliPHOSGetter(headerFile,branchTitle) ;
+ // asks the Loader to return the CPV RecPoints container
- if (fgObjGetter->HasFailed() )
- fgObjGetter = 0 ;
-
-
- // Posts a few item to the white board (folders)
- // fgObjGetter->CreateWhiteBoard() ;
-
- return fgObjGetter ;
+ TObjArray * rv = 0 ;
+ rv = PhosLoader()->CpvRecPoints() ;
+ if (!rv) {
+ PhosLoader()->MakeRecPointsArray() ;
+ rv = PhosLoader()->CpvRecPoints() ;
+ }
+ return rv ;
}
//____________________________________________________________________________
-const AliPHOS * AliPHOSGetter::PHOS()
+TClonesArray * AliPHOSGetter::Digits()
{
- // returns the PHOS object
- AliPHOS * phos = dynamic_cast<AliPHOS*>(fModuleFolder->FindObject("PHOS")) ;
- if (!phos)
- if (fDebug)
- cout << "WARNING: AliPHOSGetter::PHOS -> PHOS module not found in Folders" << endl ;
- return phos ;
-}
+ // asks the Loader to return the Digits container
-//____________________________________________________________________________
-const AliPHOSGeometry * AliPHOSGetter::PHOSGeometry()
-{
- AliPHOSGeometry * rv = 0 ;
- if (PHOS() )
- rv = PHOS()->GetGeometry() ;
+ TClonesArray * rv = 0 ;
+ rv = PhosLoader()->Digits() ;
+
+ if( !rv ) {
+ PhosLoader()->MakeDigitsArray() ;
+ rv = PhosLoader()->Digits() ;
+ }
return rv ;
-}
+}
//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostPrimaries(void) const
-{ //------- Primaries ----------------------
+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 ;
+}
- // the hierarchy is //Folders/RunMC/Event/Data/Primaries
-
- TFolder * primariesFolder = dynamic_cast<TFolder*>(fPrimariesFolder->FindObject("Primaries")) ;
- if ( !primariesFolder ) {
- if (fDebug) {
- cout << "WARNING: AliPHOSGetter::Post Primaries -> Folder //" << fPrimariesFolder << "/Primaries/ not found!" << endl;
- cout << "INFO: AliPHOSGetter::Post Primaries -> Adding Folder //" << fPrimariesFolder << "/Primaries/" << endl;
- }
- primariesFolder = fPrimariesFolder->AddFolder("Primaries", "Primaries particles from TreeK") ;
- }
- TClonesArray *primaries= new TClonesArray("TParticle",1000) ;
- primaries->SetName("Primaries") ;
- primariesFolder->Add(primaries) ;
-
- return kTRUE;
-}
//____________________________________________________________________________
-TObject** AliPHOSGetter::PrimariesRef(void) const
-{ //------- Primaries ----------------------
+TObjArray * AliPHOSGetter::EmcRecPoints()
+{
+ // asks the Loader to return the EMC RecPoints container
+ TObjArray * rv = 0 ;
- // the hierarchy is //Folders/RunMC/Event/Data/Primaries
- if ( !fPrimariesFolder ) {
- cerr << "ERROR: AliPHOSGetter::Post PrimariesRef -> Folder //" << fPrimariesFolder << " not found!" << endl;
- return 0;
- }
-
- TFolder * primariesFolder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
- if ( !primariesFolder ) {
- cerr << "ERROR: AliPHOSGetter::Post PrimariesRef -> Folder //" << fPrimariesFolder << "/Primaries/ not found!" << endl;
- return 0;
- }
-
- TObject * p = primariesFolder->FindObject("Primaries") ;
- if(!p) {
- cerr << "ERROR: AliPHOSGetter::PrimariesRef -> " << primariesFolder->GetName() << "/Primaries not found !" << endl ;
- return 0 ;
+ rv = PhosLoader()->EmcRecPoints() ;
+ if (!rv) {
+ PhosLoader()->MakeRecPointsArray() ;
+ rv = PhosLoader()->EmcRecPoints() ;
}
- else
- return primariesFolder->GetListOfFolders()->GetObjectRef(p) ;
+ return rv ;
}
//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostHits(void) const
-{ //------- Hits ----------------------
+TClonesArray * AliPHOSGetter::TrackSegments()
+{
+ // asks the Loader to return the TrackSegments container
- // the hierarchy is //Folders/RunMC/Event/Data/PHOS/Hits
+ TClonesArray * rv = 0 ;
- TFolder * phosFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("PHOS")) ;
- if ( !phosFolder ) {
- if (fDebug) {
- cout << "WARNING: AliPHOSGetter::Post H -> Folder //" << fHitsFolder << "/PHOS/ not found!" << endl;
- cout << "INFO: AliPHOSGetter::Post H -> Adding Folder //" << fHitsFolder << "/PHOS/" << endl;
- }
- phosFolder = fHitsFolder->AddFolder("PHOS", "Hits from PHOS") ;
- }
- TClonesArray *hits= new TClonesArray("AliPHOSHit",1000) ;
- hits->SetName("Hits") ;
- phosFolder->Add(hits) ;
-
- return kTRUE;
-}
+ rv = PhosLoader()->TrackSegments() ;
+ if (!rv) {
+ PhosLoader()->MakeTrackSegmentsArray() ;
+ rv = PhosLoader()->TrackSegments() ;
+ }
+ return rv ;
+}
+
+//____________________________________________________________________________
+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 ;
+}
//____________________________________________________________________________
-TObject** AliPHOSGetter::HitsRef(void) const
-{ //------- Hits ----------------------
+TClonesArray * AliPHOSGetter::RecParticles()
+{
+ // asks the Loader to return the TrackSegments container
+ TClonesArray * rv = 0 ;
- // the hierarchy is //Folders/RunMC/Event/Data/PHOS/Hits
- if ( !fHitsFolder ) {
- cerr << "ERROR: AliPHOSGetter::Post H -> Folder //" << fHitsFolder << " not found!" << endl;
- return 0;
- }
-
- TFolder * phosFolder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("PHOS")) ;
- if ( !phosFolder ) {
- cerr << "ERROR: AliPHOSGetter::Post HRef -> Folder //" << fHitsFolder << "/PHOS/ not found!" << endl;
- return 0;
- }
-
- TObject * h = phosFolder->FindObject("Hits") ;
- if(!h) {
- cerr << "ERROR: AliPHOSGetter::HRef -> " << phosFolder->GetName() << "/Hits not found !" << endl ;
- return 0 ;
+ rv = PhosLoader()->RecParticles() ;
+ if (!rv) {
+ PhosLoader()->MakeRecParticlesArray() ;
+ rv = PhosLoader()->RecParticles() ;
}
- else
- return phosFolder->GetListOfFolders()->GetObjectRef(h) ;
+ return rv ;
}
-
//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostSDigits(const char * name, const char * headerFile) const
-{ //---------- SDigits -------------------------
+void AliPHOSGetter::Event(Int_t event, const char* opt)
+{
+ // Reads the content of all Tree's S, D and R
+
+// if ( event >= MaxEvent() ) {
+// Error("Event", "%d not found in TreeE !", event) ;
+// return ;
+// }
+
+ AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
+
+// // 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 ;
+// }
+// }
+ // Loads the type of object(s) requested
- // the hierarchy is //Folders/RunMC/Event/Data/PHOS/SDigits/headerFile/sdigitsname
- // because you can have sdigits from several hit files for mixing
+ rl->GetEvent(event) ;
+
+ if(strstr(opt,"X") || (strcmp(opt,"")==0)){
+ ReadPrimaries() ;
+ }
- TFolder * phosFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ;
- if ( !phosFolder ) {
- if (fDebug) {
- cout << "WARNING: AliPHOSGetter::Post S -> Folder //" << fSDigitsFolder << "/PHOS/ not found!" << endl;
- cout << "INFO: AliPHOSGetter::Post S -> Adding Folder //" << fHitsFolder << "/PHOS/" << endl;
- }
- phosFolder = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
- }
- TString subdir(headerFile) ;
- subdir.ReplaceAll("/","_") ;
- TFolder * phosSubFolder = dynamic_cast<TFolder*>(phosFolder->FindObject(subdir)) ;
- if ( !phosSubFolder )
- phosSubFolder = phosFolder->AddFolder(subdir, "");
+ if(strstr(opt,"H") ){
+ ReadTreeH();
+ }
- TObject * sd = phosSubFolder->FindObject(name);
- if ( sd ) {
- if (fDebug)
- cerr <<"INFO: AliPHOSGetter::Post S -> Folder " << subdir
- << " already exists!" << endl ;
- }else{
- TClonesArray * sdigits = new TClonesArray("AliPHOSDigit",1) ;
- sdigits->SetName(name) ;
- phosSubFolder->Add(sdigits) ;
+ if(strstr(opt,"S") ){
+ ReadTreeS() ;
}
- return kTRUE;
-}
-//____________________________________________________________________________
-TObject** AliPHOSGetter::SDigitsRef(const char * name, const char * file) const
-{ //------- SDigits ----------------------
+ if(strstr(opt,"D") ){
+ ReadTreeD() ;
+ }
- // the hierarchy is //Folders/RunMC/Event/Data/PHOS/SDigits/filename/SDigits
+ if(strstr(opt,"R") ){
+ ReadTreeR() ;
+ }
- if ( !fSDigitsFolder ) {
- cerr << "ERROR: AliPHOSGetter::Post SRef -> Folder //" << fSDigitsFolder << " not found!" << endl;
- return 0;
+ if( strstr(opt,"T") ){
+ ReadTreeT() ;
}
-
- TFolder * phosFolder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
- if ( !phosFolder ) {
- cerr << "ERROR: AliPHOSGetter::Post SRef -> Folder //" << fSDigitsFolder << "/PHOS/ not found!" << endl;
- return 0;
- }
- TFolder * phosSubFolder = 0 ;
- if(file)
- phosSubFolder = dynamic_cast<TFolder *>(phosFolder->FindObject(file)) ;
- else
- phosSubFolder = dynamic_cast<TFolder *>(phosFolder->FindObject(fHeaderFile)) ;
-
- if(!phosSubFolder) {
- cerr << "ERROR: AliPHOSGetter::Post SRef -> Folder //Folders/RunMC/Event/Data/PHOS/" << file << "not found!" << endl;
- return 0;
- }
+ if( strstr(opt,"P") ){
+ ReadTreeP() ;
+ }
- TObject * dis = phosSubFolder->FindObject(name) ;
- if(!dis)
- return 0 ;
- else
- return phosSubFolder->GetListOfFolders()->GetObjectRef(dis) ;
+ if( strstr(opt,"E") ){
+ ReadTreeE(event) ;
+ }
}
+
//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostSDigitizer(AliPHOSSDigitizer * sdigitizer) const
-{ //---------- SDigitizer -------------------------
-
- // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
+void AliPHOSGetter::Event(AliRawReader *rawReader, const char* opt)
+{
+ // Reads the raw event from rawReader
+
+ AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
+
+ if( strstr(opt,"W") ){
+ rawReader->NextEvent();
+ Int_t iEvent = rl->GetEventNumber();
+ rl->GetEvent(iEvent);
+ ReadRaw(rawReader) ;
+ rl->SetEventNumber(++iEvent);
+ }
+
+}
- TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
+//____________________________________________________________________________
+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
+
+ TClonesArray * rv = 0 ;
+
+ rv = PhosLoader()->Hits() ;
+ if ( !rv ) {
+ PhosLoader()->LoadHits("read");
+ rv = PhosLoader()->Hits() ;
+ }
+ return rv ;
+}
- if ( !sd ) {
- cerr << "ERROR: AliPHOSGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
- return kFALSE ;
- }
- TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
- if ( !phos ) {
- if (fDebug) {
- cout <<"WARNING: AliPHOSGetter::Post Ser ->//" << fTasksFolder << "/SDigitizer/PHOS/ not found!" << endl;
- cout <<"INFO: AliPHOSGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/PHOS/" << endl;
+//____________________________________________________________________________
+AliPHOSGetter * AliPHOSGetter::Instance(const char* alirunFileName, const char* version, Option_t * openingOption)
+{
+ // Creates and returns the pointer of the unique instance
+ // Must be called only when the environment has changed
+
+ 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 {
+ AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle()) ;
+ if ( strstr(version, AliConfig::GetDefaultEventFolderName()) ) // false in case of merging
+ delete rl ;
+ fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;
}
- phos = new TTask("PHOS", "") ;
- sd->Add(phos) ;
- }
- AliPHOSSDigitizer * phossd = dynamic_cast<AliPHOSSDigitizer *>(phos->GetListOfTasks()->FindObject( sdigitizer->GetName() ));
- if (phossd) {
- if (fDebug)
- cout << "INFO: AliPHOSGetter::Post Ser -> Task " << sdigitizer->GetName() << " already exists" << endl ;
- phos->GetListOfTasks()->Remove(phossd) ;
}
- phos->Add(sdigitizer) ;
- return kTRUE;
+ if (!fgObjGetter)
+ ::Error("AliPHOSGetter::Instance", "Failed to create the PHOS Getter object") ;
+ else
+ if (fgDebug)
+ Print() ;
+ return fgObjGetter ;
}
//____________________________________________________________________________
-TObject** AliPHOSGetter::SDigitizerRef(const char * name) const
-{
-
- TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
- if ( !sd ) {
- cerr << "ERROR: AliPHOSGetter::Post SerRef -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
- abort();
- }
-
- TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
- if ( !phos ) {
- cerr <<"ERROR: AliPHOSGetter::Post SerRef -> //" << fTasksFolder << "/SDigitizer/PHOS not found!" << endl;
- abort();
- }
+AliPHOSGetter * AliPHOSGetter::Instance()
+{
+ // Returns the pointer of the unique instance already defined
+
+ if(!fgObjGetter && fgDebug)
+ ::Warning("AliPHOSGetter::Instance", "Getter not initialized") ;
- TTask * task = dynamic_cast<TTask*>(phos->GetListOfTasks()->FindObject(name)) ;
+ return fgObjGetter ;
+
+}
- return phos->GetListOfTasks()->GetObjectRef(task) ;
+//____________________________________________________________________________
+Int_t AliPHOSGetter::MaxEvent() const
+{
+ // returns the number of events in the run (from TE)
+ AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
+ return static_cast<Int_t>(rl->GetNumberOfEvents()) ;
}
//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostSDigitizer(const char * name, const char * file) const
-{ //---------- SDigitizer -------------------------
-
- // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
+TParticle * AliPHOSGetter::Primary(Int_t index) const
+{
+ 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;
- TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
- if ( !sd ) {
- cerr << "ERROR: AliPHOSGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
- return kFALSE ;
- }
+ loader = PhosLoader();
+
+ if ( loader != oldloader) {
+ phos = dynamic_cast<AliPHOS*>(loader->GetModulesFolder()->FindObject("PHOS")) ;
+ oldloader = loader;
+ }
+ if (!phos)
+ if (fgDebug)
+ Warning("PHOS", "PHOS module not found in module folders: %s", PhosLoader()->GetModulesFolder()->GetName() ) ;
+ return phos ;
+}
- TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
- if ( !phos ) {
- if (fDebug) {
- cout <<"WARNING: AliPHOSGetter::Post Ser -> //" << fTasksFolder << "/SDigitizer/PHOS/ not found!" << endl;
- cout <<"INFO: AliPHOSGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/PHOS" << endl;
- }
- phos = new TTask("PHOS", "") ;
- sd->Add(phos) ;
- }
- TString sdname(name) ;
- sdname.Append(":") ;
- sdname.Append(file);
- sdname.ReplaceAll("/","_") ;
- AliPHOSSDigitizer * phossd = dynamic_cast<AliPHOSSDigitizer *>(phos->GetListOfTasks()->FindObject( sdname ));
- if (!phossd) {
- phossd = new AliPHOSSDigitizer() ;
- //Note, we can not call constructor with parameters: it will call Getter and scrud up everething
- phossd->SetName(sdname) ;
- phossd->SetTitle(file) ;
- phos->Add(phossd) ;
+
+//____________________________________________________________________________
+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 kTRUE;
-
+ return rv ;
}
//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostDigits(const char * name) const
-{ //---------- Digits -------------------------
+AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
+{
+ // Returns PHOS geometry
- // the hierarchy is //Folders/Run/Event/Data/PHOS/SDigits/name
+ AliPHOSGeometry * rv = 0 ;
+ if (PHOS() )
+ rv = PHOS()->GetGeometry() ;
+ return rv ;
+}
- TFolder * phosFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("PHOS")) ;
+//____________________________________________________________________________
+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 ;
+}
- if ( !phosFolder ) {
- if (fDebug) {
- cout << "WARNING: AliPHOSGetter::Post D -> Folder //" << fDigitsFolder << "/PHOS/ not found!" << endl;
- cout << "INFO: AliPHOSGetter::Post D -> Adding Folder //" << fDigitsFolder << "/PHOS/" << endl;
- }
- phosFolder = fDigitsFolder->AddFolder("PHOS", "Digits from PHOS") ;
- }
-
- TObject* dig = phosFolder->FindObject( name ) ;
- if ( !dig ) {
- TClonesArray * digits = new TClonesArray("AliPHOSDigit",1000) ;
- digits->SetName(name) ;
- phosFolder->Add(digits) ;
- }
- return kTRUE;
+//____________________________________________________________________________
+void AliPHOSGetter::Print()
+{
+ // 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() ) ;
}
//____________________________________________________________________________
-TObject** AliPHOSGetter::DigitsRef(const char * name) const
-{ //------- Digits ----------------------
+void AliPHOSGetter::ReadPrimaries()
+{
+ // Read Primaries from Kinematics.root
- // the hierarchy is //Folders/Run/Event/Data/PHOS/Digits/name
-
- if ( !fDigitsFolder ) {
- cerr << "ERROR: AliPHOSGetter::Post DRef -> Folder //" << fDigitsFolder << " not found!" << endl;
- return 0;
- }
+ AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
- TFolder * phosFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("PHOS")) ;
- if ( !phosFolder ) {
- cerr << "ERROR: AliPHOSGetter::DRef -> Folder //" << fDigitsFolder << "/PHOS/ not found!" << endl;
- return 0;
- }
+ // 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() ) ;
- TObject * d = phosFolder->FindObject(name) ;
- if(!d)
- return 0 ;
- else
- return phosFolder->GetListOfFolders()->GetObjectRef(d) ;
+ // first time creates the container
+ if ( Primaries() )
+ fPrimaries->Clear() ;
+
+ Int_t index = 0 ;
+ for (index = 0 ; index < fNPrimaries; index++) {
+ new ((*fPrimaries)[index]) TParticle(*(Primary(index)));
+ }
}
//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostDigitizer(AliPHOSDigitizer * digitizer) const
-{ //---------- Digitizer -------------------------
-
- TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
-
- if ( !sd ) {
- cerr << "ERROR: AliPHOSGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
- return kFALSE ;
- }
- TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
- if ( !phos ) {
- if (fDebug) {
- cout <<"WARNING: AliPHOSGetter::Post Der -> //" << fTasksFolder << "/Digitizer/PHOS not found!" << endl;
- cout <<"INFO: AliPHOSGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/PHOS" << endl;
- }
- phos = new TTask("PHOS", "") ;
- sd->Add(phos) ;
- }
-
- AliPHOSDigitizer * phosd = dynamic_cast<AliPHOSDigitizer*>(phos->GetListOfTasks()->FindObject(digitizer->GetName())) ;
- if (phosd) {
- phosd->Delete() ;
- phos->GetListOfTasks()->Remove(phosd) ;
- }
- phos->Add(digitizer) ;
- return kTRUE;
-}
+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 ;
+}
//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostDigitizer(const char * name) const
-{ //---------- Digitizer -------------------------
-
- // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
-
- TTask * d = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
- if ( !d ) {
- cerr << "ERROR: AliPHOSGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
- return kFALSE ;
- }
-
- TTask * phos = dynamic_cast<TTask*>(d->GetListOfTasks()->FindObject("PHOS")) ;
- if ( !phos ) {
- if (fDebug) {
- cout <<"WARNING: AliPHOSGetter::Post Der -> //" << fTasksFolder << "/Digitizer/PHOS not found!" << endl;
- cout <<"INFO: AliPHOSGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/PHOS" << endl;
+void AliPHOSGetter::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Double_t & energy, Double_t & time)
+{
+ // Fits the raw signal time distribution
+
+ const Int_t kNoiseThreshold = 0 ;
+ Double_t timezero1 = 0., timezero2 = 0., timemax = 0. ;
+ Double_t signal = 0., signalmax = 0. ;
+ time = 0. ;
+ energy = 0. ;
+
+ if (lowGainFlag) {
+ timezero1 = timezero2 = signalmax = timemax = 0. ;
+ signalF->FixParameter(0, PHOS()->GetRawFormatLowCharge()) ;
+ signalF->FixParameter(1, PHOS()->GetRawFormatLowGain()) ;
+ Int_t index ;
+ for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
+ gLowGain->GetPoint(index, time, signal) ;
+ if (signal > kNoiseThreshold && timezero1 == 0.)
+ timezero1 = time ;
+ if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
+ timezero2 = time ;
+ if (signal > signalmax) {
+ signalmax = signal ;
+ timemax = time ;
+ }
+ }
+ signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatLowCharge(),
+ PHOS()->GetRawFormatLowGain()) ;
+ if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
+ signalF->SetParameter(2, signalmax) ;
+ signalF->SetParameter(3, timezero1) ;
+ gLowGain->Fit(signalF, "QRON", "", 0., timezero2); //, "QRON") ;
+ energy = signalF->GetParameter(2) ;
+ time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
+ }
+ } else {
+ timezero1 = timezero2 = signalmax = timemax = 0. ;
+ signalF->FixParameter(0, PHOS()->GetRawFormatHighCharge()) ;
+ signalF->FixParameter(1, PHOS()->GetRawFormatHighGain()) ;
+ Int_t index ;
+ for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
+ gHighGain->GetPoint(index, time, signal) ;
+ if (signal > kNoiseThreshold && timezero1 == 0.)
+ timezero1 = time ;
+ if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
+ timezero2 = time ;
+ if (signal > signalmax) {
+ signalmax = signal ;
+ timemax = time ;
+ }
+ }
+ signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatHighCharge(),
+ PHOS()->GetRawFormatHighGain()) ;;
+ if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise
+ signalF->SetParameter(2, signalmax) ;
+ signalF->SetParameter(3, timezero1) ;
+ gHighGain->Fit(signalF, "QRON", "", 0., timezero2) ;
+ energy = signalF->GetParameter(2) ;
+ time = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
}
- phos = new TTask("PHOS", "") ;
- d->Add(phos) ;
-}
-
- AliPHOSDigitizer * phosd = dynamic_cast<AliPHOSDigitizer*>(phos->GetListOfTasks()->FindObject(name)) ;
- if (!phosd) {
- phosd = new AliPHOSDigitizer() ;
- phosd->SetName(fDigitsTitle) ;
- phosd->SetTitle(fHeaderFile) ;
- phos->Add(phosd) ;
}
- return kTRUE;
+ if (time == 0) energy = 0 ;
}
//____________________________________________________________________________
-TObject** AliPHOSGetter::DigitizerRef(const char * name) const
-{
- TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
- if ( !sd ) {
- cerr << "ERROR: AliPHOSGetter::Post DerRef -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
- abort();
- }
+Int_t AliPHOSGetter::CalibrateRaw(Double_t energy, Int_t *relId)
+{
+ // Convert energy into digitized amplitude for a cell relId
+ // It is a user responsilibity to open CDB and set
+ // AliPHOSCalibData object by the following operators:
+ //
+ // AliCDBLocal *loc = new AliCDBLocal("deCalibDB");
+ // AliPHOSCalibData* clb = (AliPHOSCalibData*)AliCDBStorage::Instance()
+ // ->Get(path_to_calibdata,run_number);
+ // AliPHOSGetter* gime = AliPHOSGetter::Instance("galice.root");
+ // gime->SetCalibData(clb);
- TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
- if ( !phos ) {
- cerr <<"ERROR: AliPHOSGetter::Post DerRef -> //" << fTasksFolder << "/Digitizer/PHOS" << endl;
- abort();
- }
+ if (CalibData() == 0)
+ Warning("CalibrateRaw","Calibration DB is not initiated!");
- TTask * task = dynamic_cast<TTask*>(phos->GetListOfTasks()->FindObject(name)) ;
+ Int_t module = relId[0];
+ Int_t column = relId[3];
+ Int_t row = relId[2];
- return phos->GetListOfTasks()->GetObjectRef(task) ;
+ Float_t gainFactor = 0.0015; // width of one Emc ADC channel in GeV
+ Float_t pedestal = 0.005; // Emc pedestals
+ if(CalibData()) {
+ gainFactor = CalibData()->GetADCchannelEmc (module,column,row);
+ pedestal = CalibData()->GetADCpedestalEmc(module,column,row);
+ }
+
+ Int_t amp = static_cast<Int_t>( (energy - pedestal) / gainFactor + 0.5 ) ;
+ return amp;
}
-
//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostRecPoints(const char * name) const
-{ // -------------- RecPoints -------------------------------------------
-
- // the hierarchy is //Folders/Run/Event/RecData/PHOS/EMCARecPoints/name
- // the hierarchy is //Folders/Run/Event/RecData/PHOS/CPVRecPoints/name
+Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader)
+{
+ // reads the raw format data, converts it into digits format and store digits in Digits()
+ // container.
- TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
-
- if ( !phosFolder ) {
- if (fDebug) {
- cout << "WARNING: AliPHOSGetter::Post RPo -> Folder //" << fRecoFolder->GetName() << "/PHOS/ not found!" << endl;
- cout << "INFO: AliPHOSGetter::Post Rpo -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/" << endl;
- }
- phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
- }
-
- // EMCA RecPoints
- TFolder * phosRPoEMCAFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("EMCARecPoints")) ;
- if ( !phosRPoEMCAFolder ) {
- if (fDebug) {
- cout << "WARNING: AliPHOSGetter::Post RPo -> Folder //" << fRecoFolder->GetName() << "/PHOS/EMCARecPoints/ not found!" << endl;
- cout << "INFO: AliPHOSGetter::Post Rpo -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/EMCARecPoints" << endl;
- }
- phosRPoEMCAFolder = phosFolder->AddFolder("EMCARecPoints", "EMCA RecPoints from PHOS") ;
- }
+ AliPHOSRawStream in(rawReader);
+
+ Bool_t first = kTRUE ;
- TObject * erp = phosFolder->FindObject( name ) ;
- if ( !erp ) {
- TObjArray * emcrp = new TObjArray(100) ;
- emcrp->SetName(name) ;
- phosRPoEMCAFolder->Add(emcrp) ;
- }
+ TF1 * signalF = new TF1("signal", AliPHOS::RawResponseFunction, 0, PHOS()->GetRawFormatTimeMax(), 4);
+ signalF->SetParNames("Charge", "Gain", "Amplitude", "TimeZero") ;
- // CPV RecPoints
- TFolder * phosRPoCPVFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("CPVRecPoints")) ;
- if ( !phosRPoCPVFolder ) {
- if (fDebug) {
- cout << "WARNING: AliPHOSGetter::Post RPo -> Folder //" << fRecoFolder->GetName() << "/PHOS/CPVRecPoints/ not found!" << endl;
- cout << "INFO: AliPHOSGetter::Post Rpo -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/CPVRecPoints/" << endl;
+ Int_t relId[4], id =0;
+ Bool_t lowGainFlag = kFALSE ;
+
+ TClonesArray * digits = Digits() ;
+ digits->Clear() ;
+ Int_t idigit = 0 ;
+ Int_t amp = 0 ;
+ Double_t energy = 0. ;
+ Double_t time = 0. ;
+
+ TGraph * gLowGain = new TGraph(PHOS()->GetRawFormatTimeBins()) ;
+ TGraph * gHighGain= new TGraph(PHOS()->GetRawFormatTimeBins()) ;
+
+ while ( in.Next() ) { // PHOS entries loop
+ if ( (in.IsNewRow() || in.IsNewColumn() || in.IsNewModule()) ) {
+ relId[0] = in.GetModule() ;
+ if ( relId[0] >= PHOS()->GetRawFormatLowGainOffset() ) {
+ relId[0] -= PHOS()->GetRawFormatLowGainOffset() ;
+ lowGainFlag = kTRUE ;
+ } else
+ lowGainFlag = kFALSE ;
+ relId[1] = 0 ;
+ relId[2] = in.GetRow() ;
+ relId[3] = in.GetColumn() ;
+ PHOSGeometry()->RelToAbsNumbering(relId, id) ;
+ if (!first) {
+ FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, energy, time) ;
+// amp = CalibrateRaw(energy,relId);
+ amp = (Int_t)energy;
+ if (amp > 0) {
+ new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
+ idigit++ ;
+ }
+ Int_t index ;
+ for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
+ gLowGain->SetPoint(index, index * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(), 0) ;
+ gHighGain->SetPoint(index, index * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(), 0) ;
+ }
+ }
+ first = kFALSE ;
}
- phosRPoCPVFolder = phosFolder->AddFolder("CPVRecPoints", "CPV RecPoints from PHOS") ;
- }
-
- TObject * crp = phosRPoCPVFolder->FindObject( name ) ;
- if ( !crp ) {
- TObjArray * cpvrp = new TObjArray(100) ;
- cpvrp->SetName(name) ;
- phosRPoCPVFolder->Add(cpvrp) ;
+ if (lowGainFlag)
+ gLowGain->SetPoint(in.GetTime(),
+ in.GetTime()* PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(),
+ in.GetSignal()) ;
+ else
+ gHighGain->SetPoint(in.GetTime(),
+ in.GetTime() * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(),
+ in.GetSignal() ) ;
+
+ } // PHOS entries loop
+
+ FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, energy, time) ;
+// amp = CalibrateRaw(energy,relId);
+ amp = (Int_t)energy;
+ if (amp > 0 ) {
+ new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
+ idigit++ ;
}
- return kTRUE;
-}
+ digits->Sort() ;
-//____________________________________________________________________________
-TObject** AliPHOSGetter::EmcRecPointsRef(const char * name) const
-{ // -------------- RecPoints -------------------------------------------
+ delete signalF ;
+ delete gLowGain;
+ delete gHighGain ;
- // the hierarchy is //Folders/Run/Event/RecData/PHOS/EMCARecPoints/name
-
- if ( !fRecoFolder ) {
- cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder->GetName() << " not found!" << endl;
- return 0 ;
- }
-
- TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/EMCARecPoints")) ;
- if ( !phosFolder ) {
- cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/EMCARecPoints/ not found!" << endl;
- return 0;
- }
+// AliInfo(Form("Event %d, digits: %d\n", EventNumber(),digits->GetEntries())); //bvp
+ return digits->GetEntriesFast() ;
+}
+// TClonesArray * digits = Digits() ;
+// digits->Clear() ;
+// Int_t idigit = 0 ;
- TObject * erp = phosFolder->FindObject(name ) ;
- if ( !erp ) {
- return 0 ;
- }
- return phosFolder->GetListOfFolders()->GetObjectRef(erp) ;
+// while ( in.Next() ) { // PHOS entries loop
+
+// Int_t amp = in.GetSignal() ;
+// Double_t time = in.GetTime() ;
+// Int_t relId[4], id ;
-}
-
-//____________________________________________________________________________
-TObject** AliPHOSGetter::CpvRecPointsRef(const char * name) const
-{ // -------------- RecPoints -------------------------------------------
+// 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
- // the hierarchy is //Folders/Run/Event/RecData/PHOS/CPVRecPoints/name
-
- if ( !fRecoFolder ) {
- cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder->GetName() << " not found!" << endl;
- return 0 ;
- }
-
- TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/CPVRecPoints")) ;
- if ( !phosFolder ) {
- cerr << "ERROR: AliPHOSGetter::CpvRecPointsRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/CPVRecPoints/" << endl;
- return 0;
- }
-
- TObject * crp = phosFolder->FindObject(name ) ;
- if ( !crp ) {
- return 0 ;
- }
- return phosFolder->GetListOfFolders()->GetObjectRef(crp) ;
-
-}
-
-//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostClusterizer(AliPHOSClusterizer * clu) const
-{ // ------------------ AliPHOSClusterizer ------------------------
+// digits->Sort() ;
- // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
-
- TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
-
- if ( !tasks ) {
- cerr << "ERROR: AliPHOSGetter::Post Rer -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
- return kFALSE ;
- }
-
- TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
- if ( !phos ) {
- if (fDebug) {
- cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/ReconstructionerPHOS not found!" << endl;
- cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
- }
- phos = new TTask("PHOS", "") ;
- tasks->Add(phos) ;
- }
-
- AliPHOSClusterizer * phoscl = dynamic_cast<AliPHOSClusterizer*>(phos->GetListOfTasks()->FindObject(clu->GetName())) ;
- if (phoscl) {
- if (fDebug)
- cout << "INFO: AliPHOSGetter::Post Rer -> Task " << clu->GetName() << " already exists" << endl ;
- phoscl->Delete() ;
- phos->GetListOfTasks()->Remove(phoscl) ;
- }
- phos->Add(clu) ;
- return kTRUE;
-}
-
+// return digits->GetEntriesFast() ;
+// }
//____________________________________________________________________________
-TObject** AliPHOSGetter::ClusterizerRef(const char * name) const
-{ // ------------------ AliPHOSClusterizer ------------------------
+Int_t AliPHOSGetter::ReadTreeD()
+{
+ // Read the Digits
- TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
-
- if ( !tasks ) {
- cerr << "ERROR: AliPHOSGetter::Post RerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
- return 0 ;
- }
-
- TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
- if ( !phos ) {
- cerr <<"WARNING: AliPHOSGetter::Post RerRef -> //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
- return 0 ;
- }
-
- TList * l = phos->GetListOfTasks() ;
- TIter it(l) ;
- TTask * task ;
- TTask * clu = 0 ;
- TString cluname(name) ;
- cluname+=":clu-" ;
- while((task = static_cast<TTask *>(it.Next()) )){
- TString taskname(task->GetName()) ;
- if(taskname.BeginsWith(cluname)){
- clu = task ;
- break ;
- }
- }
-
- if(clu)
- return l->GetObjectRef(clu) ;
- else
- return 0 ;
+ PhosLoader()->CleanDigits() ;
+ PhosLoader()->LoadDigits("UPDATE") ;
+ PhosLoader()->LoadDigitizer("UPDATE") ;
+ return Digits()->GetEntries() ;
}
//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostClusterizer(const char * name) const
-{ // ------------------ AliPHOSClusterizer ------------------------
-
- // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
-
- TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
-
- if ( !tasks ) {
- cerr << "ERROR: AliPHOSGetter::Post Rer -> Task//" << fTasksFolder << "/Reconstructioner not found!" << endl;
- return kFALSE ;
- }
-
- TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
- if ( !phos ) {
- if (fDebug) {
- cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
- cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
- }
- phos = new TTask("PHOS", "") ;
- tasks->Add(phos) ;
- }
-
- AliPHOSClusterizer * phoscl = new AliPHOSClusterizer() ;
- TString clun(name) ;
- clun+=":clusterizer" ;
- phoscl->SetName(clun) ;
- phos->Add(phoscl) ;
- return kTRUE;
-
+Int_t AliPHOSGetter::ReadTreeH()
+{
+ // 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() ;
}
//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostTrackSegments(const char * name) const
-{ // ---------------TrackSegments -----------------------------------
-
- // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
-
- TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
-
- if ( !phosFolder ) {
- if (fDebug) {
- cout << "WARNING: AliPHOSGetter::Post TS -> Folder //" << fRecoFolder << "/PHOS/ not found!" << endl;
- cout << "INFO: AliPHOSGetter::Post TS -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS" << endl;
- }
- phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
- }
-
- TFolder * phosTSFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("TrackSegments")) ;
- if ( !phosTSFolder ) {
- if (fDebug) {
- cout << "WARNING: AliPHOSGetter::Post TS -> Folder//" << fRecoFolder->GetName() << "/PHOS/TrackSegments/ not found!" << endl;
- cout << "INFO: AliPHOSGetter::Post TS -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/TrackSegments/" << endl;
- }
- phosTSFolder = phosFolder->AddFolder("TrackSegments", "TrackSegments from PHOS") ;
- }
-
- TObject * tss = phosTSFolder->FindObject( name ) ;
- if (!tss) {
- TClonesArray * ts = new TClonesArray("AliPHOSTrackSegment",100) ;
- ts->SetName(name) ;
- phosTSFolder->Add(ts) ;
- }
- return kTRUE;
-}
-
-//____________________________________________________________________________
-TObject** AliPHOSGetter::TrackSegmentsRef(const char * name) const
-{ // ---------------TrackSegments -----------------------------------
-
- // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
-
- if ( !fRecoFolder ) {
- cerr << "ERROR: AliPHOSGetter::TrackSegmentsRef -> Folder //" << fRecoFolder->GetName() << "not found!" << endl;
- return 0 ;
- }
-
- TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/TrackSegments")) ;
- if ( !phosFolder ) {
- cerr << "ERROR: AliPHOSGetter::TrackSegmentsRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/TrackSegments/ not found!" << endl;
- return 0;
- }
-
- TObject * tss = phosFolder->FindObject(name) ;
- if (!tss) {
- return 0 ;
- }
- return phosFolder->GetListOfFolders()->GetObjectRef(tss) ;
-}
-
-//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostTrackSegmentMaker(AliPHOSTrackSegmentMaker * tsmaker) const
-{ //------------Track Segment Maker ------------------------------
-
- // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
-
- TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
-
- if ( !tasks ) {
- cerr << "ERROR: AliPHOSGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
- return kFALSE ;
- }
-
- TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
- if ( !phos ) {
- if (fDebug) {
- cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
- cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
- }
- phos = new TTask("PHOS", "") ;
- tasks->Add(phos) ;
- }
-
- AliPHOSTrackSegmentMaker * phosts =
- dynamic_cast<AliPHOSTrackSegmentMaker*>(phos->GetListOfTasks()->FindObject(tsmaker->GetName())) ;
- if (phosts) {
- phosts->Delete() ;
- phos->GetListOfTasks()->Remove(phosts) ;
- }
- phos->Add(tsmaker) ;
- return kTRUE;
-
-}
-//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostTrackSegmentMaker(const char * name) const
-{ //------------Track Segment Maker ------------------------------
-
- // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
-
-
- TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
-
- if ( !tasks ) {
- cerr << "ERROR: AliPHOSGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
- return kFALSE ;
- }
-
- TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
- if ( !phos ) {
- if (fDebug) {
- cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
- cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
- }
- phos = new TTask("PHOS", "") ;
- tasks->Add(phos) ;
- }
-
- AliPHOSTrackSegmentMaker * phosts =
- dynamic_cast<AliPHOSTrackSegmentMaker*>(phos->GetListOfTasks()->FindObject(name)) ;
- if (!phosts) {
- phosts = new AliPHOSTrackSegmentMaker() ;
- TString tsn(name);
- tsn+=":tracksegmentmaker" ;
- phosts->SetName(tsn) ;
- phos->Add(phosts) ;
- }
- return kTRUE;
-
-}
-
-//____________________________________________________________________________
-TObject** AliPHOSGetter::TSMakerRef(const char * name) const
-{ //------------Track Segment Maker ------------------------------
-
- TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
-
- if ( !tasks ) {
- cerr << "ERROR: AliPHOSGetter::Post TerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
- return 0 ;
- }
-
- TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
- if ( !phos ) {
- cerr <<"WARNING: AliPHOSGetter::Post TerRef -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
- return 0 ;
- }
-
- TList * l = phos->GetListOfTasks() ;
- TIter it(l) ;
- TTask * task ;
- TTask * tsm = 0 ;
- TString tsmname(name) ;
- tsmname+=":tsm-" ;
- while((task = static_cast<TTask *>(it.Next()) )){
- TString taskname(task->GetName()) ;
- if(taskname.BeginsWith(tsmname)){
- tsm = task ;
- break ;
- }
- }
-
- if(tsm)
- return l->GetObjectRef(tsm) ;
- else
- return 0 ;
-
-}
-
-//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostRecParticles(const char * name) const
-{ // -------------------- RecParticles ------------------------
-
- // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
-
- TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
+Int_t AliPHOSGetter::ReadTreeR()
+{
+ // Read the RecPoints
- if ( !phosFolder ) {
- if (fDebug) {
- cout << "WARNING: AliPHOSGetter::Post RPa -> Folder //" << fRecoFolder->GetName() << "/PHOS/ not found!" << endl;
- cout << "INFO: AliPHOSGetter::Post Rpa -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/" << endl;
- }
- phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
- }
+ PhosLoader()->CleanRecPoints() ;
+ // gets TreeR from the root file (PHOS.RecPoints.root)
+ //if ( !IsLoaded("R") ) {
+ PhosLoader()->LoadRecPoints("UPDATE") ;
+ PhosLoader()->LoadClusterizer("UPDATE") ;
+ // SetLoaded("R") ;
+ //}
- TFolder * phosRPaFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("RecParticles")) ;
- if ( !phosRPaFolder ) {
- if (fDebug) {
- cout << "WARNING: AliPHOSGetter::Post RPa -> Folder //" << fRecoFolder->GetName() << "/PHOS/RecParticles/ not found!" << endl;
- cout << "INFO: AliPHOSGetter::Post RPa -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/RecParticles/" << endl;
- }
- phosRPaFolder = phosFolder->AddFolder("RecParticles", "RecParticles from PHOS") ;
- }
-
- TObject * rps = phosRPaFolder->FindObject( name ) ;
- if ( !rps ) {
- TClonesArray * rp = new TClonesArray("AliPHOSRecParticle",100) ;
- rp->SetName(name) ;
- phosRPaFolder->Add(rp) ;
- }
- return kTRUE;
-}
+ return EmcRecPoints()->GetEntries() ;
+}
//____________________________________________________________________________
-TObject** AliPHOSGetter::RecParticlesRef(const char * name) const
-{ // ---------------TrackSegments -----------------------------------
+Int_t AliPHOSGetter::ReadTreeT()
+{
+ // Read the TrackSegments
- // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
+ PhosLoader()->CleanTracks() ;
+ // gets TreeT from the root file (PHOS.TrackSegments.root)
+ //if ( !IsLoaded("T") ) {
+ PhosLoader()->LoadTracks("UPDATE") ;
+ PhosLoader()->LoadTrackSegmentMaker("UPDATE") ;
+ // SetLoaded("T") ;
+ //}
- if ( !fRecoFolder ) {
- cerr << "ERROR: AliPHOSGetter::RecParticlesRef -> Folder//" << fRecoFolder->GetName() << " not found!" << endl;
- return 0 ;
- }
-
- TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/RecParticles")) ;
- if ( !phosFolder ) {
- cerr << "ERROR: AliPHOSGetter::RecParticlesRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/RecParticles/ not found!" << endl;
- return 0;
- }
-
- TObject * tss = phosFolder->FindObject(name ) ;
- if (!tss) {
- return 0 ;
- }
- return phosFolder->GetListOfFolders()->GetObjectRef(tss) ;
+ return TrackSegments()->GetEntries() ;
}
-
//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostPID(AliPHOSPID * pid) const
-{ // ------------AliPHOS PID -----------------------------
-
- TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
-
- if ( !tasks ) {
- cerr << "ERROR: AliPHOSGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
- return kFALSE ;
- }
+Int_t AliPHOSGetter::ReadTreeP()
+{
+ // Read the RecParticles
- TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
- if ( !phos ) {
- if (fDebug) {
- cout <<"WARNING: AliPHOSGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
- cout <<"INFO: AliPHOSGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
- }
- phos = new TTask("PHOS", "") ;
- tasks->Add(phos) ;
- }
+ PhosLoader()->CleanRecParticles() ;
- AliPHOSPID * phospid = dynamic_cast<AliPHOSPID*>(phos->GetListOfTasks()->FindObject(pid->GetName())) ;
- if (phospid) {
- if (fDebug)
- cout << "INFO: AliPHOSGetter::Post Per -> Task " << pid->GetName()
- << " already exists" << endl ;
- phos->GetListOfTasks()->Remove(phospid) ;
- }
-
- phos->Add(pid) ;
- return kTRUE;
-}
+ // gets TreeT from the root file (PHOS.TrackSegments.root)
+ // if ( !IsLoaded("P") ) {
+ PhosLoader()->LoadRecParticles("UPDATE") ;
+ PhosLoader()->LoadPID("UPDATE") ;
+ // SetLoaded("P") ;
+ //}
+ return RecParticles()->GetEntries() ;
+}
//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostPID(const char * name) const
-{
- // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
-
- TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
-
- if ( !tasks ) {
- cerr << "ERROR: AliPHOSGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
- return kFALSE ;
- }
+Int_t AliPHOSGetter::ReadTreeS()
+{
+ // Read the SDigits
- TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
- if ( !phos ) {
- if (fDebug) {
- cout <<"WARNING: AliPHOSGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
- cout <<"INFO: AliPHOSGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
- }
- phos = new TTask("PHOS", "") ;
- tasks->Add(phos) ;
- }
+ PhosLoader()->CleanSDigits() ;
+ // gets TreeS from the root file (PHOS.SDigits.root)
+ //if ( !IsLoaded("S") ) {
+ PhosLoader()->LoadSDigits("READ") ;
+ PhosLoader()->LoadSDigitizer("READ") ;
+ // SetLoaded("S") ;
+ //}
- TList * l = phos->GetListOfTasks() ;
- TIter it(l) ;
- TString pidname(name) ;
- pidname+=":pid" ;
- TTask * task ;
- while((task = static_cast<TTask *>(it.Next()) )){
- TString taskname(task->GetName()) ;
- if(taskname.BeginsWith(pidname))
- return kTRUE ;
- }
-
- AliPHOSPID * phospid = new AliPHOSPID() ;
- phospid->SetName(pidname) ;
- phos->Add(phospid) ;
-
- return kTRUE;
-}
+ return SDigits()->GetEntries() ;
+}
//____________________________________________________________________________
-TObject** AliPHOSGetter::PIDRef(const char * name) const
-{ //------------PID ------------------------------
-
- TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
-
- if ( !tasks ) {
- cerr << "ERROR: AliPHOSGetter::Post PerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
- return 0 ;
- }
-
- TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
- if ( !phos ) {
- cerr <<"WARNING: AliPHOSGetter::Post PerRef -> //" << fTasksFolder << "/ReconstructionerPHOS not found!" << endl;
- return 0 ;
- }
-
- TList * l = phos->GetListOfTasks() ;
- TIter it(l) ;
- TTask * task ;
- TTask * pid = 0 ;
- TString pidname(name) ;
- pidname+=":pid-" ;
- while((task = static_cast<TTask *>(it.Next()) )){
- TString taskname(task->GetName()) ;
- if(taskname.BeginsWith(pidname)){
- pid = task ;
- break ;
- }
- }
-
- if(pid)
- return l->GetObjectRef(pid) ;
- else
- return 0 ;
+Int_t AliPHOSGetter::ReadTreeE(Int_t event)
+{
+ // Read the ESD
-}
+ // gets esdTree from the root file (AliESDs.root)
+ if (!fESDFile)
+ if ( !OpenESDFile() )
+ return -1 ;
-//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostQA(void) const
-{ // ------------------ QA ---------------------------------
+ fESDTree = static_cast<TTree*>(fESDFile->Get("esdTree")) ;
+ fESD = new AliESD;
+ if (!fESDTree) {
- // the hierarchy is //Folders/Run/Conditions/QA/PHOS/alarmsName
-
- TFolder * phosFolder = dynamic_cast<TFolder*>(fQAFolder->FindObject("PHOS")) ;
- if ( !phosFolder ) {
- if (fDebug) {
- cout << "WARNING: AliPHOSGetter::Post Q -> Folder //" << fQAFolder << "/PHOS/ not found!" << endl;
- cout << "INFO: AliPHOSGetter::Post Q -> Adding Folder //" << fQAFolder << "/PHOS/" << endl;
- }
- phosFolder = fQAFolder->AddFolder("PHOS", "QA from PHOS") ;
- }
+ Error("ReadTreeE", "no ESD tree found");
+ return -1;
+ }
+ fESDTree->SetBranchAddress("ESD", &fESD);
+ fESDTree->GetEvent(event);
- return kTRUE;
+ return event ;
}
//____________________________________________________________________________
-TObject** AliPHOSGetter::AlarmsRef(void) const
-{ //------- Alarms ----------------------
+TClonesArray * AliPHOSGetter::SDigits()
+{
+ // asks the Loader to return the Digits container
+ TClonesArray * rv = 0 ;
- // the hierarchy is //Folders/Run/Conditions/QA/PHOS
- if ( !fQAFolder ) {
- cerr << "ERROR: AliPHOSGetter::Post QRef -> Folder //" << fQAFolder << " not found!" << endl;
- return 0;
- }
-
- TFolder * phosFolder = dynamic_cast<TFolder *>(fQAFolder->FindObject("PHOS")) ;
- if ( !phosFolder ) {
- cerr << "ERROR: AliPHOSGetter::Post QRef -> Folder //" << fQAFolder << "/PHOS/ not found!" << endl;
- return 0;
+ rv = PhosLoader()->SDigits() ;
+ if (!rv) {
+ PhosLoader()->MakeSDigitsArray() ;
+ rv = PhosLoader()->SDigits() ;
}
-
- return fQAFolder->GetListOfFolders()->GetObjectRef(phosFolder) ;
+ return rv ;
}
//____________________________________________________________________________
-const TParticle * AliPHOSGetter::Primary(Int_t index) const
-{
- // Return primary particle numbered by <index>
-
- if(index < 0)
- return 0 ;
- TParticle * p = gAlice->Particle(index) ;
- if (p->GetFirstMother() != -1 ) {
- cout << "AliPHOSGetter::Primary : Not a primary " << endl ;
+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 p ;
-
-
-// Int_t primaryIndex = index % 10000000 ;
-// Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
-
-// if ( primaryList > 0 ) {
-// if (fDebug) {
-// cout << " Getter does not support currently Mixing of primary " << endl ;
-// cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
-// }
-// return 0;
-// }
-
-// return gAlice->Particle(primaryIndex) ;
-
+ return rv ;
}
//____________________________________________________________________________
-const TParticle * AliPHOSGetter::Secondary(TParticle* p, Int_t index) const
+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(p) {
Int_t daughterIndex = p->GetDaughter(index-1) ;
- return gAlice->Particle(daughterIndex) ;
+ AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
+ return rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ;
}
else
return 0 ;
}
//____________________________________________________________________________
-Int_t AliPHOSGetter::ReadTreeD()
+void AliPHOSGetter::Track(Int_t itrack)
{
- // Read the digit tree gAlice->TreeD()
- if(gAlice->TreeD()== 0){
- cerr << "WARNING: AliPHOSGetter::ReadTreeD: can not read TreeD " << endl ;
- return 1;
- }
-
- TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeD()->GetListOfBranches()) ;
- TIter next(lob) ;
- TBranch * branch = 0 ;
- TBranch * digitsbranch = 0 ;
- TBranch * digitizerbranch = 0 ;
- Bool_t phosfound = kFALSE, digitizerfound = kFALSE ;
-
- while ( (branch = static_cast<TBranch*>(next())) && (!phosfound || !digitizerfound) ) {
- if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
- digitsbranch = branch ;
- phosfound = kTRUE ;
- }
- else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
- digitizerbranch = branch ;
- digitizerfound = kTRUE ;
- }
- }
-
- if ( !phosfound || !digitizerfound ) {
- if (fDebug)
- cout << "WARNING: AliPHOSGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name "
- << fDigitsTitle << endl ;
- return 2;
- }
-
- //read digits
- if(!Digits(fDigitsTitle) )
- PostDigits(fDigitsTitle);
- digitsbranch->SetAddress(DigitsRef(fDigitsTitle)) ;
- digitsbranch->GetEntry(0) ;
-
-
- // read the Digitizer
- if(!Digitizer(fDigitsTitle))
- PostDigitizer(fDigitsTitle) ;
- digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
- digitizerbranch->GetEntry(0) ;
+ // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
- return 0 ;
+ AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
+
+ if( !TreeH() ) // load treeH the first time
+ rl->LoadHits() ;
+
+ // first time create the container
+ TClonesArray * hits = Hits() ;
+ if ( hits )
+ hits->Clear() ;
+
+ TBranch * phosbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("PHOS")) ;
+ phosbranch->SetAddress(&hits) ;
+ phosbranch->GetEntry(itrack) ;
}
//____________________________________________________________________________
-Int_t AliPHOSGetter::ReadTreeH()
+TTree * AliPHOSGetter::TreeD() const
{
- // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
-
- if(gAlice->TreeH()== 0){
- cerr << "WARNING: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
- return 1;
- }
+ // Returns pointer to the Digits Tree
+ TTree * rv = 0 ;
+ rv = PhosLoader()->TreeD() ;
+ if ( !rv ) {
+ PhosLoader()->MakeTree("D");
+ rv = PhosLoader()->TreeD() ;
+ }
- TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("PHOS")) ;
- if ( !hitsbranch ) {
- if (fDebug)
- cout << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ;
- return 2;
- }
- if(!Hits())
- PostHits() ;
-
- if (hitsbranch->GetEntries() > 1 ) {
- TClonesArray * tempo = new TClonesArray("AliPHOSHit",1000) ;
- TClonesArray * hits = dynamic_cast<TClonesArray*>(*HitsRef()) ;
- hitsbranch->SetAddress(&tempo) ;
- Int_t index = 0 ;
- Int_t i = 0 ;
- for (i = 0 ; i < hitsbranch->GetEntries() ; i++) {
- hitsbranch->GetEntry(i) ;
- Int_t j = 0 ;
- for ( j = 0 ; j < tempo->GetEntries() ; j++) {
- const AliPHOSHit * hit = static_cast<const AliPHOSHit *>(tempo->At(j)) ;
- new((*hits)[index]) AliPHOSHit( *hit ) ;
- index++ ;
- }
- }
- delete tempo ;
- }
- else {
- hitsbranch->SetAddress(HitsRef()) ;
- hitsbranch->GetEntry(0) ;
- }
- return 0 ;
+ return rv ;
}
//____________________________________________________________________________
-void AliPHOSGetter::Track(Int_t itrack)
+TTree * AliPHOSGetter::TreeH() const
{
- // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
-
- if(gAlice->TreeH()== 0){
- cerr << "ERROR: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
- return ;
- }
+ // Returns pointer to the Hits Tree
+ TTree * rv = 0 ;
+ rv = PhosLoader()->TreeH() ;
+ if ( !rv ) {
+ PhosLoader()->MakeTree("H");
+ rv = PhosLoader()->TreeH() ;
+ }
- TBranch * hitsbranch = dynamic_cast<TBranch*>(gAlice->TreeH()->GetListOfBranches()->FindObject("PHOS")) ;
- if ( !hitsbranch ) {
- if (fDebug)
- cout << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ;
- return ;
- }
- if(!Hits())
- PostHits() ;
-
- hitsbranch->SetAddress(HitsRef()) ;
- hitsbranch->GetEntry(itrack) ;
-
-
+ return rv ;
}
+
//____________________________________________________________________________
-void AliPHOSGetter::ReadTreeQA()
+TTree * AliPHOSGetter::TreeR() const
{
- // Read the digit tree gAlice->TreeQA()
- // so far only PHOS knows about this Tree
-
- if(PHOS()->TreeQA()== 0){
- cerr << "ERROR: AliPHOSGetter::ReadTreeQA: can not read TreeQA " << endl ;
- return ;
- }
-
- TBranch * qabranch = PHOS()->TreeQA()->GetBranch("PHOS") ;
- if (!qabranch) {
- if (fDebug)
- cout << "WARNING: AliPHOSGetter::ReadTreeQA -> Cannot find QA Alarms for PHOS" << endl ;
- return ;
- }
-
- if(!Alarms())
- PostQA() ;
-
- qabranch->SetAddress(AlarmsRef()) ;
-
- qabranch->GetEntry(0) ;
-
-// PostQA("PHOS") ;
-// TFolder * alarmsF = Alarms() ;
-// alarmsF->Clear() ;
-// qabranch->SetAddress(&alarmsF) ;
-// qabranch->GetEntry(0) ;
+ // Returns pointer to the RecPoints Tree
+ TTree * rv = 0 ;
+ rv = PhosLoader()->TreeR() ;
+ if ( !rv ) {
+ PhosLoader()->MakeTree("R");
+ rv = PhosLoader()->TreeR() ;
+ }
+ return rv ;
}
//____________________________________________________________________________
-Int_t AliPHOSGetter::ReadTreeR(Bool_t any)
+TTree * AliPHOSGetter::TreeT() const
{
- // Read the reconstrunction tree gAlice->TreeR()
- // A particularity has been introduced here :
- // if gime->Event(ievent,"R") is called branches with the current title are read, the current title
- // being for example give in AliPHOSPID(fileName, title)
- // if gime(Event(ievent, "RA") is called the title of the branches is not checked anymore, "A" stands for any
- // This is a feature needed by PID to be able to reconstruct several times particles (each time a ther title is given)
- // from a given set of TrackSegments (with a given name)
- // This is why any is NOT used to read the branch of RecParticles
- // See AliPHOSPIDv2
-
- if(gAlice->TreeR()== 0){
- cerr << "WARNING: AliPHOSGetter::ReadTreeR: can not read TreeR " << endl ;
- return 1;
- }
-
- // RecPoints
- TObjArray * lob = static_cast<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 ;
-
- while ( (branch = static_cast<TBranch*>(next())) && (!phosemcrpfound || !phoscpvrpfound || !clusterizerfound) )
- if(strcmp(branch->GetTitle(), fRecPointsTitle)==0 || any) {
- if ( strcmp(branch->GetName(), "PHOSEmcRP")==0) {
- emcbranch = branch ;
- phosemcrpfound = kTRUE ;
- }
- else if ( strcmp(branch->GetName(), "PHOSCpvRP")==0) {
- cpvbranch = branch ;
- phoscpvrpfound = kTRUE ;
- }
- else if(strcmp(branch->GetName(), "AliPHOSClusterizer")==0){
- clusterizerbranch = branch ;
- clusterizerfound = kTRUE ;
- }
- }
-
- if ( !phosemcrpfound ) {
- if (fDebug)
- cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find EmcRecPoints with title "
- << fRecPointsTitle << endl ;
- return 2 ;
- }
- if ( !phoscpvrpfound ) {
- if (fDebug)
- cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find CpvRecPoints with title "
- << fRecPointsTitle << endl ;
- return 3;
- }
- if ( !clusterizerfound ) {
- if (fDebug)
- cout << "WARNING: AliPHOSGetter::ReadTreeR -> Can not find Clusterizer with title "
- << fRecPointsTitle << endl ;
- return 4;
- }
-
- // Read and Post the RecPoints
- if(!EmcRecPoints(fRecPointsTitle) )
- PostRecPoints(fRecPointsTitle) ;
-
- emcbranch->SetAddress(EmcRecPointsRef(fRecPointsTitle)) ;
- emcbranch->GetEntry(0) ;
-
- cpvbranch->SetAddress(CpvRecPointsRef(fRecPointsTitle)) ;
- cpvbranch->GetEntry(0) ;
-
- if(!Clusterizer(fRecPointsTitle) )
- PostClusterizer(fRecPointsTitle) ;
-
- clusterizerbranch->SetAddress(ClusterizerRef(fRecPointsTitle)) ;
- clusterizerbranch->GetEntry(0) ;
-
-
- //------------------- TrackSegments ---------------------
- next.Reset() ;
- TBranch * tsbranch = 0 ;
- TBranch * tsmakerbranch = 0 ;
- Bool_t phostsfound = kFALSE, tsmakerfound = kFALSE ;
-
- while ( (branch = static_cast<TBranch*>(next())) && (!phostsfound || !tsmakerfound) )
- if(strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0 || any) {
- if ( strcmp(branch->GetName(), "PHOSTS")==0){
- tsbranch = branch ;
- phostsfound = kTRUE ;
- }
- else if(strcmp(branch->GetName(), "AliPHOSTrackSegmentMaker")==0) {
- tsmakerbranch = branch ;
- tsmakerfound = kTRUE ;
- }
- }
-
- if ( !phostsfound || !tsmakerfound ) {
- if (fDebug)
- cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name "
- << fTrackSegmentsTitle << endl ;
- return 5;
+ // Returns pointer to the TrackSegments Tree
+ TTree * rv = 0 ;
+ rv = PhosLoader()->TreeT() ;
+ if ( !rv ) {
+ PhosLoader()->MakeTree("T");
+ rv = PhosLoader()->TreeT() ;
}
- // Read and Post the TrackSegments
- if(!TrackSegments(fTrackSegmentsTitle))
- PostTrackSegments(fTrackSegmentsTitle) ;
-
- tsbranch->SetAddress(TrackSegmentsRef(fTrackSegmentsTitle)) ;
- tsbranch->GetEntry(0) ;
-
- // Read and Post the TrackSegment Maker
- if(!TrackSegmentMaker(fTrackSegmentsTitle))
- PostTrackSegmentMaker(fTrackSegmentsTitle) ;
-
- tsmakerbranch->SetAddress(TSMakerRef(fTrackSegmentsTitle)) ;
- tsmakerbranch->GetEntry(0) ;
-
-
- //------------ RecParticles ----------------------------
- next.Reset() ;
- TBranch * rpabranch = 0 ;
- TBranch * pidbranch = 0 ;
- Bool_t phosrpafound = kFALSE, pidfound = kFALSE ;
-
- while ( (branch = static_cast<TBranch*>(next())) && (!phosrpafound || !pidfound) )
- if(strcmp(branch->GetTitle(), fRecParticlesTitle)==0) {
- if ( strcmp(branch->GetName(), "PHOSRP")==0) {
- rpabranch = branch ;
- phosrpafound = kTRUE ;
- }
- else if (strcmp(branch->GetName(), "AliPHOSPID")==0) {
- pidbranch = branch ;
- pidfound = kTRUE ;
- }
- }
-
- if ( !phosrpafound || !pidfound ) {
- if (fDebug)
- cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name "
- << fRecParticlesTitle << endl ;
- return 6;
+ return rv ;
+}
+//____________________________________________________________________________
+TTree * AliPHOSGetter::TreeP() const
+{
+ // Returns pointer to the RecParticles Tree
+ TTree * rv = 0 ;
+ rv = PhosLoader()->TreeP() ;
+ if ( !rv ) {
+ PhosLoader()->MakeTree("P");
+ rv = PhosLoader()->TreeP() ;
}
- // Read and Post the RecParticles
- if(!RecParticles(fRecParticlesTitle))
- PostRecParticles(fRecParticlesTitle) ;
-
- rpabranch->SetAddress(RecParticlesRef(fRecParticlesTitle)) ;
- rpabranch->GetEntry(0) ;
-
- // Read and Post the PID
- if(!PID(fRecParticlesTitle))
- PostPID(fRecParticlesTitle) ;
+ return rv ;
+}
- pidbranch->SetAddress(PIDRef(fRecParticlesTitle)) ;
- pidbranch->GetEntry(0) ;
+//____________________________________________________________________________
+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 0 ;
+ return rv ;
}
//____________________________________________________________________________
-Int_t AliPHOSGetter::ReadTreeS(Int_t event)
+Bool_t AliPHOSGetter::VersionExists(TString & opt) const
{
- // Read the summable digits tree gAlice->TreeS()
-
- // loop over all opened files and read their SDigits to the White Board
- TFolder * phosF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
- if (!phosF)
- phosF = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
- TCollection * folderslist = phosF->GetListOfFolders() ;
-
- //Add current file to list if it is not there yet
-
- TString subdir(fHeaderFile) ;
- subdir.ReplaceAll("/","_") ;
+ // checks if the version with the present name already exists in the same directory
- if ( (subdir != "aliroot") && ( !folderslist->Contains(subdir) ) ){
- phosF->AddFolder(subdir, "");
- }
-
- TIter next(folderslist) ;
- TFolder * folder = 0 ;
- TFile * file;
- TTree * treeS = 0;
- while ( (folder = static_cast<TFolder*>(next())) ) {
- TString fileName(folder->GetName()) ;
- fileName.ReplaceAll("_","/") ;
- if(fHeaderFile.CompareTo(fileName) == 0 )
- treeS=gAlice->TreeS() ;
- else{
- file = static_cast<TFile*>(gROOT->GetFile(fileName));
- file->cd() ;
-
- // Get SDigits Tree header from file
- TString treeName("TreeS") ;
- treeName += event ;
- treeS = dynamic_cast<TTree*>(gDirectory->Get(treeName.Data()));
- }
- if(treeS==0){
- cerr << "WARNING: AliPHOSGetter::ReadTreeS There is no SDigit Tree" << endl;
- return 1;
- }
-
- //set address of the SDigits and SDigitizer
- TBranch * sdigitsBranch = 0;
- TBranch * sdigitizerBranch = 0;
- TBranch * branch = 0 ;
- TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
- TIter next(lob) ;
- Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
-
- while ( (branch = static_cast<TBranch*>(next())) && (!phosfound || !sdigitizerfound) ) {
- if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
- phosfound = kTRUE ;
- sdigitsBranch = branch ;
- }
-
- else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
- sdigitizerfound = kTRUE ;
- sdigitizerBranch = branch ;
- }
+ Bool_t rv = kFALSE ;
+
+ 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 ;
}
- if ( !phosfound || !sdigitizerfound ) {
- if (fDebug)
- cout << "WARNING: AliPHOSDigitizer::ReadSDigits -> Digits and/or Digitizer branch with name " << GetName()
- << " not found" << endl ;
- return 2;
- }
-
- if ( !folder->FindObject(fSDigitsTitle) )
- PostSDigits(fSDigitsTitle,folder->GetName()) ;
-
- sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
- sdigitsBranch->GetEntry(0) ;
-
- TString sdname(fSDigitsTitle) ;
- sdname+=":" ;
- sdname+=folder->GetName() ;
- if(!SDigitizer(sdname) )
- PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
-
- sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
- sdigitizerBranch->GetEntry(0) ;
-
- }
-
- // After SDigits have been read from all files, return to the first one
-
- next.Reset();
- folder = static_cast<TFolder*>(next());
- if(folder){
- TString fileName(folder->GetName()) ;
- fileName.ReplaceAll("_","/") ;
- file = static_cast<TFile*>(gROOT->GetFile(fileName));
- file ->cd() ;
+ PhosLoader()->SetSDigitsFileName(fileName) ;
}
- return 0 ;
-}
-//____________________________________________________________________________
-void AliPHOSGetter::ReadTreeS(TTree * treeS, Int_t input)
-{ // Read the summable digits fron treeS()
-
-
- TString filename("mergefile") ;
- filename+= input ;
- TFolder * phosFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ;
- if ( !phosFolder ) {
- phosFolder = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
- }
- TFolder * folder=(TFolder*)phosFolder->FindObject(filename) ;
- //set address of the SDigits and SDigitizer
- TBranch * sdigitsBranch = 0;
- TBranch * sdigitizerBranch = 0;
- TBranch * branch = 0 ;
- TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ;
- TIter next(lob) ;
- Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
-
- while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) {
- if ( strcmp(branch->GetName(), "PHOS")==0) {
- phosfound = kTRUE ;
- sdigitsBranch = branch ;
- }
-
- else if ( strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) {
- sdigitizerfound = kTRUE ;
- sdigitizerBranch = branch ;
+ 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 ;
}
}
- if ( !phosfound || !sdigitizerfound ) {
- if (fDebug)
- cout << "WARNING: AliPHOSGetter::ReadTreeS -> Digits and/or Digitizer branch not found" << endl ;
- return ;
- }
-
- if (!folder || !(folder->FindObject(sdigitsBranch->GetTitle()) ) )
- PostSDigits(sdigitsBranch->GetTitle(),filename) ;
- sdigitsBranch->SetAddress(SDigitsRef(sdigitsBranch->GetTitle(),filename)) ;
- sdigitsBranch->GetEntry(0) ;
-
- TString sdname(sdigitsBranch->GetTitle()) ;
- sdname+=":" ;
- sdname+=filename ;
- if(!SDigitizer(sdigitsBranch->GetTitle()) )
- PostSDigitizer(sdigitsBranch->GetTitle(),filename) ;
-
- sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
- sdigitizerBranch->GetEntry(0) ;
-
-}
+ return rv ;
+}
//____________________________________________________________________________
-void AliPHOSGetter::ReadPrimaries()
+UShort_t AliPHOSGetter::EventPattern(void) const
{
- // a lot simplified.... if 2 files are opened then we have a problem
-
- TClonesArray * ar = 0 ;
- if(! (ar = Primaries()) ) {
- PostPrimaries() ;
- ar = Primaries() ;
- }
- ar->Delete() ;
-
- fNPrimaries = gAlice->GetNtrack() ;
- Int_t index = 0 ;
- for (index = 0 ; index < fNPrimaries; index++) {
- new ((*ar)[index]) TParticle(*(Primary(index)));
- }
+ // Return the pattern (trigger bit register) of the beam-test event
+ if(fBTE)
+ return fBTE->GetPattern() ;
+ else
+ return 0 ;
}
//____________________________________________________________________________
-void AliPHOSGetter::Event(const Int_t event, const char* opt)
+Float_t AliPHOSGetter::BeamEnergy(void) const
{
- // Reads the content of all Tree's S, D and R
-
- if (event >= gAlice->TreeE()->GetEntries() ) {
- cerr << "ERROR: AliPHOSGetter::Event -> " << event << " not found in TreeE!" << endl ;
- return ;
- }
-
- Bool_t any = kFALSE ;
- if (strstr(opt,"A") ) // do not check the title of the branches
- any = kTRUE;
-
- gAlice->GetEvent(event) ;
-
- Int_t rvRH = 0 ;
- Int_t rvRS = 0 ;
- Int_t rvRD = 0 ;
- Int_t rvRR = 0 ;
-
- if(strstr(opt,"H") )
- rvRH = ReadTreeH() ;
-
- if(strstr(opt,"S") )
- rvRS = ReadTreeS(event) ;
-
- if( strstr(opt,"D") )
- rvRD = ReadTreeD() ;
-
- if( strstr(opt,"R") )
- rvRR = ReadTreeR(any) ;
-
- if( strstr(opt,"Q") )
- ReadTreeQA() ;
-
- if( strstr(opt,"P") || (strcmp(opt,"")==0) )
- if ( gAlice->Stack() )
- ReadPrimaries() ;
-
+ // Return the beam energy of the beam-test event
+ if(fBTE)
+ return fBTE->GetBeamEnergy() ;
+ else
+ return 0 ;
}
-
//____________________________________________________________________________
-TObject * AliPHOSGetter::ReturnO(TString what, TString name, TString file) const
-{
- // get the object named "what" from the folder
- // folders are named like //Folders
- if ( file.IsNull() )
- file = fHeaderFile ;
-
- TFolder * folder = 0 ;
- TObject * phosO = 0 ;
-
- // if ( name.IsNull() ) {
- if ( what.CompareTo("Primaries") == 0 ) {
- folder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
- if (folder)
- phosO = dynamic_cast<TObject *>(folder->FindObject("Primaries")) ;
- }
- else if ( what.CompareTo("Hits") == 0 ) {
- folder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("PHOS")) ;
- if (folder)
- phosO = dynamic_cast<TObject *>(folder->FindObject("Hits")) ;
- }
- else if ( what.CompareTo("SDigits") == 0 ) {
- file.ReplaceAll("/","_") ;
- TString path = "PHOS/" + file ;
- folder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject(path.Data())) ;
- if (folder) {
- if (name.IsNull())
- name = fSDigitsTitle ;
- phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
- }
- }
- else if ( what.CompareTo("Digits") == 0 ){
- folder = dynamic_cast<TFolder *>(fDigitsFolder->FindObject("PHOS")) ;
- if (folder) {
- if (name.IsNull())
- name = fDigitsTitle ;
- phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
- }
- }
- else if ( what.CompareTo("EmcRecPoints") == 0 ) {
- folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/EMCARecPoints")) ;
- if (folder) {
- if (name.IsNull())
- name = fRecPointsTitle ;
- phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
- }
- }
- else if ( what.CompareTo("CpvRecPoints") == 0 ) {
- folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/CPVRecPoints")) ;
- if (folder) {
- if (name.IsNull())
- name = fRecPointsTitle ;
- phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
- }
- }
- else if ( what.CompareTo("TrackSegments") == 0 ) {
- folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/TrackSegments")) ;
- if (folder) {
- if (name.IsNull())
- name = fTrackSegmentsTitle ;
- phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
- }
- }
- else if ( what.CompareTo("RecParticles") == 0 ) {
- folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/RecParticles")) ;
- if (folder) {
- if (name.IsNull())
- name = fRecParticlesTitle ;
- phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
- }
- }
- else if ( what.CompareTo("Alarms") == 0 ){
- if (name.IsNull() )
- phosO = dynamic_cast<TObject *>(fQAFolder->FindObject("PHOS")) ;
- else {
- folder = dynamic_cast<TFolder *>(fQAFolder->FindObject("PHOS")) ;
- if (!folder)
- phosO = 0 ;
- else
- phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
- }
- }
- if (!phosO) {
- if(fDebug)
- cerr << "ERROR : AliPHOSGetter::ReturnO -> Object " << what << " not found in " << fQAFolder->GetName() << endl ;
- return 0 ;
- }
+AliPHOSCalibData* AliPHOSGetter::CalibData()
+{
+ // Check if the instance of AliPHOSCalibData exists, and return it
- return phosO ;
+ if( !(AliCDBManager::Instance()->IsDefaultStorageSet()) )
+ fCalibData=0x0;
+ return fCalibData;
}
-
//____________________________________________________________________________
-const TTask * AliPHOSGetter::ReturnT(TString what, TString name) const
-{
- // get the TTask named "what" from the folder
- // folders are named like //Folders/Tasks/what/PHOS/name
-
- TString search(what) ;
- if ( what.CompareTo("Clusterizer") == 0 )
- search = "Reconstructioner" ;
- else if ( what.CompareTo("TrackSegmentMaker") == 0 )
- search = "Reconstructioner" ;
- else if ( what.CompareTo("PID") == 0 )
- search = "Reconstructioner" ;
- else if ( what.CompareTo("QATasks") == 0 )
- search = "QA" ;
-
- TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject(search)) ;
-
- if (!tasks) {
- cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << what << " not found!" << endl ;
- return 0 ;
- }
- TTask * phosT = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
- if (!phosT) {
- cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << what << "/PHOS not found!" << endl ;
- return 0 ;
- }
-
- TList * list = phosT->GetListOfTasks() ;
-
- 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 ;
- name.Append(":clu") ;
- }
- else if (what.CompareTo("TrackSegmentMaker") == 0){
- if ( name.IsNull() )
- name = fTrackSegmentsTitle ;
- name.Append(":tsm") ;
- }
- else if (what.CompareTo("PID") == 0){
- if ( name.IsNull() )
- name = fRecParticlesTitle ;
- name.Append(":pid") ;
- }
- else if (what.CompareTo("QATasks") == 0){
- if ( name.IsNull() )
- return phosT ;
- }
-
- TIter it(list) ;
- TTask * task = 0 ;
- while((task = static_cast<TTask *>(it.Next()) )){
- TString taskname(task->GetName()) ;
- if(taskname.BeginsWith(name))
- return task ;
- }
-
- if(fDebug)
- cout << "WARNING: AliPHOSGetter::ReturnT -> Task " << search << "/" << name << " not found!" << endl ;
- return 0 ;
+AliPHOSAlignData* AliPHOSGetter::AlignData()
+{
+ // Check if the instance of AliPHOSAlignData exists, and return it
+
+ if( !(AliCDBManager::Instance()->IsDefaultStorageSet()) )
+ fAlignData=0x0;
+ return fAlignData;
}