* 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 <TStyle.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 "AliPHOSClusterizerv1.h"
-#include "AliPHOSTrackSegmentMakerv1.h"
-#include "AliPHOSTrackSegment.h"
-#include "AliPHOSPIDv1.h"
-#include "AliPHOSGeometry.h"
+#include "AliPHOSBeamTestEvent.h"
+#include "AliPHOSGetter.h"
+#include "AliPHOSLoader.h"
+#include "AliPHOSPulseGenerator.h"
+#include "AliRunLoader.h"
+#include "AliStack.h"
+#include "AliPHOSRawDecoder.h"
+#include "AliRawReaderFile.h"
+#include "AliLog.h"
+#include "AliCDBLocal.h"
+#include "AliCDBStorage.h"
+#include "AliCDBManager.h"
+#include "AliPHOSRawDigiProducer.h"
ClassImp(AliPHOSGetter)
- AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
- TFile * AliPHOSGetter::fFile = 0 ;
+AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
+AliPHOSLoader * AliPHOSGetter::fgPhosLoader = 0;
+AliPHOSCalibData* AliPHOSGetter::fgCalibData = 0;
+Int_t AliPHOSGetter::fgDebug = 0;
+
+// TFile * AliPHOSGetter::fgFile = 0 ;
+
+AliPHOSGetter::AliPHOSGetter() :
+ fBTE(0),
+ fLoadingStatus(),
+ fNPrimaries(0),
+ fPrimaries(0),
+ fESDFile(0),
+ fESDFileName(),
+ fESD(0),
+ fESDTree(0),
+ fRawDigits(kFALSE),
+ fcdb(0)
+{
+ // ctor: this is a singleton, the ctor should never be called but cint needs it as public
+ Fatal("ctor", "AliPHOSGetter is a singleton default ctor not callable") ;
+}
+
//____________________________________________________________________________
-AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* branchTitle )
+AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* version, Option_t * openingOption) :
+ fBTE(0),
+ fLoadingStatus(),
+ fNPrimaries(0),
+ fPrimaries(0),
+ fESDFile(0),
+ fESDFileName(),
+ fESD(0),
+ fESDTree(0),
+ fRawDigits(kFALSE),
+ fcdb(0)
{
- //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
- if ( fHeaderFile.Contains("_") ) {
- cerr << "AliPHOSGetter::AliPHOSGetter -> Invalid file name (_ not allowed) " << fHeaderFile.Data() << endl ;
- abort() ;
- }
- 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;
-}
-//____________________________________________________________________________
-AliPHOSGetter::~AliPHOSGetter(){
-
- 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) ;
+ 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 ;
- fFile->Close() ;
- delete fFile ;
- fFile = 0 ;
-
}
+AliPHOSGetter::AliPHOSGetter(const AliPHOSGetter & obj) :
+ TObject(obj),
+ fBTE(0),
+ fLoadingStatus(),
+ fNPrimaries(0),
+ fPrimaries(0),
+ fESDFile(0),
+ fESDFileName(),
+ fESD(0),
+ fESDTree(0),
+ fRawDigits(kFALSE),
+ fcdb(0)
+{
+ // cpy ctor requested by Coding Convention
+ Fatal("cpy ctor", "not implemented") ;
+}
//____________________________________________________________________________
-AliPHOSGetter * AliPHOSGetter::GetInstance()
+AliPHOSGetter::AliPHOSGetter(Int_t /*i*/) :
+ fBTE(0),
+ fLoadingStatus(),
+ fNPrimaries(0),
+ fPrimaries(0),
+ fESDFile(0),
+ fESDFileName(),
+ fESD(0),
+ fESDTree(0),
+ fRawDigits(kFALSE),
+ fcdb(0)
{
- // 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 ;
+ // special constructor for onflight
+}
- return rv ;
-}
//____________________________________________________________________________
-AliPHOSGetter * AliPHOSGetter::GetInstance(const char* headerFile,
- const char* branchTitle)
+AliPHOSGetter::~AliPHOSGetter()
{
- // 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)) {
- fFile->cd() ;
- return fgObjGetter ;
- }
- else
- fgObjGetter->~AliPHOSGetter() ; // delete it already exists another version
+ // 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 = new AliPHOSGetter(headerFile,branchTitle) ;
-
- if (fgObjGetter->HasFailed() )
- fgObjGetter = 0 ;
-
-
- // Posts a few item to the white board (folders)
- // fgObjGetter->CreateWhiteBoard() ;
-
- return fgObjGetter ;
-
+ fgObjGetter = 0;
}
//____________________________________________________________________________
-void AliPHOSGetter::ListBranches(Int_t event) const
+void AliPHOSGetter::Reset()
{
-
- TBranch * branch = 0 ;
- if (gAlice->GetEvent(event) == -1)
- return ;
-
- TTree * t = gAlice->TreeH() ;
- if(t){
- cout << "****** Hits : " << endl ;
- TObjArray * lob = t->GetListOfBranches() ;
- TIter next(lob) ;
- while ( (branch = static_cast<TBranch*>(next())) )
- cout << " " << branch->GetName() << endl ;
- }
-
- t = gAlice->TreeS() ;
- if(t){
- cout << "****** SDigits : " << endl ;
- TObjArray * lob = t->GetListOfBranches() ;
- TIter next(lob) ;
- while ( (branch = static_cast<TBranch*>(next())) )
- cout << " " << branch->GetName() << endl ;
- }
- t = gAlice->TreeD() ;
- if(t){
- cout << "****** Digits : " << endl ;
- TObjArray * lob = t->GetListOfBranches() ;
- TIter next(lob) ;
- while ( (branch = static_cast<TBranch*>(next())) )
- cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
- }
+ // resets things in case the getter is called consecutively with different files
+ // the PHOS Loader is already deleted by the Run Loader
- t = gAlice->TreeR() ;
- if(t){
- cout << "****** Recon : " << endl ;
- TObjArray * lob = t->GetListOfBranches() ;
- TIter next(lob) ;
- while ( (branch = static_cast<TBranch*>(next())) )
- cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
- }
+ if (fPrimaries) {
+ fPrimaries->Delete() ;
+ delete fPrimaries ;
+ }
+ fgPhosLoader = 0;
+ fgObjGetter = 0;
}
//____________________________________________________________________________
-void AliPHOSGetter::NewBranch(TString name, Int_t event)
-{
- fBranchTitle = fSDigitsTitle = fDigitsTitle = fRecPointsTitle = fTrackSegmentsTitle = fRecParticlesTitle = name ;
- Event(event) ;
+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 ;
}
//____________________________________________________________________________
-Bool_t AliPHOSGetter::NewFile(TString name)
+TObjArray * AliPHOSGetter::CpvRecPoints() const
{
- fHeaderFile = name ;
- fFile->Close() ;
- fFailed = kFALSE;
-
- 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::NewFile -> Cannot open " << fHeaderFile.Data() << endl ;
- fFailed = kTRUE ;
- return fFailed ;
- }
- gAlice = static_cast<AliRun *>(fFile->Get("gAlice")) ;
- }
+ // asks the Loader to return the CPV RecPoints container
+
+ TObjArray * rv = 0 ;
- if (!gAlice) {
- cerr << "ERROR : AliPHOSGetter::AliPHOSGetter -> Cannot find gAlice in " << fHeaderFile.Data() << endl ;
- fFailed = kTRUE ;
- return fFailed ;
+ rv = PhosLoader()->CpvRecPoints() ;
+ if (!rv) {
+ PhosLoader()->MakeRecPointsArray() ;
+ rv = PhosLoader()->CpvRecPoints() ;
}
- return fFailed ;
+ return rv ;
}
//____________________________________________________________________________
-const AliPHOS * AliPHOSGetter::PHOS()
+TClonesArray * AliPHOSGetter::Digits() const
{
- // 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() const
+{
+ // 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::PrimariesRef -> Folder //" << fPrimariesFolder << " not found!" << endl;
- abort() ;
- }
-
- TFolder * primariesFolder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
- if ( !primariesFolder ) {
- cerr << "ERROR: AliPHOSGetter::PrimariesRef -> Folder //" << fPrimariesFolder << "/Primaries/ not found!" << endl;
- abort() ;
- }
-
- TObject * p = primariesFolder->FindObject("Primaries") ;
- if(!p) {
- cerr << "ERROR: AliPHOSGetter::PrimariesRef -> " << primariesFolder->GetName() << "/Primaries not found !" << endl ;
- abort() ;
+ 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() const
+{
+ // asks the Loader to return the TrackSegments container
- // the hierarchy is //Folders/RunMC/Event/Data/PHOS/Hits
-
- 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) ;
+ TClonesArray * rv = 0 ;
- 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() const
+{
+ // 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::HitsRef -> Folder //" << fHitsFolder << " not found!" << endl;
- abort() ;
- }
-
- TFolder * phosFolder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("PHOS")) ;
- if ( !phosFolder ) {
- cerr << "ERROR: AliPHOSGetter::HitsRef -> Folder //" << fHitsFolder << "/PHOS/ not found!" << endl;
- abort() ;
- }
-
- TObject * h = phosFolder->FindObject("Hits") ;
- if(!h) {
- cerr << "ERROR: AliPHOSGetter::HitsRef -> " << phosFolder->GetName() << "/Hits not found !" << endl ;
- abort() ;
+ 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::SDigitsRef -> Folder //" << fSDigitsFolder << " not found!" << endl;
- abort() ;
+ if( strstr(opt,"T") ){
+ ReadTreeT() ;
}
-
- TFolder * phosFolder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
- if ( !phosFolder ) {
- cerr << "ERROR: AliPHOSGetter::SDigitsRef -> Folder //" << fSDigitsFolder << "/PHOS/ not found!" << endl;
- abort() ;
- }
- 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::DigitesSRef -> Folder //Folders/RunMC/Event/Data/PHOS/" << file << "not found!" << endl;
- abort() ;
- }
+ if( strstr(opt,"P") ){
+ ReadTreeP() ;
+ }
- TObject * dis = phosSubFolder->FindObject(name) ;
- if(!dis){
- cerr << "ERROR: AliPHOSGetter::DigitesSRef -> object " << name << " not found! " << endl ;
- abort() ;
+ if( strstr(opt,"E") ){
+ ReadTreeE(event) ;
}
- else
- return phosSubFolder->GetListOfFolders()->GetObjectRef(dis) ;
}
+
//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostSDigitizer(AliPHOSSDigitizer * sdigitizer) const
-{ //---------- SDigitizer -------------------------
-
- // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
+void AliPHOSGetter::Event(AliRawReader *rawReader, const char* opt, Bool_t isOldRCUFormat)
+{
+ // Reads the raw event from rawReader
+ // isOldRCUFormat defines whenever to assume
+ // the old RCU format or not
+
+ if( strstr(opt,"W") ){
+ rawReader->NextEvent();
+ ReadRaw(rawReader,isOldRCUFormat) ;
+ }
+
+}
+
+//____________________________________________________________________________
+Int_t AliPHOSGetter::EventNumber() const
+ {
+ // return the current event number
+ AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
+ return static_cast<Int_t>(rl->GetEventNumber()) ;
+}
- TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
+//____________________________________________________________________________
+ TClonesArray * AliPHOSGetter::Hits() const
+{
+ // 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 {
+ 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();
- 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) ;
- }
+ 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 ;
+}
- 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 -------------------------
-
- // the hierarchy is //Folders/Run/Event/Data/PHOS/SDigits/name
-
- TFolder * phosFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("PHOS")) ;
+AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
+{
+ // Returns PHOS geometry
- 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;
+ AliPHOSGeometry * rv = 0 ;
+ if (PHOS() )
+ rv = PHOS()->GetGeometry() ;
+ else {
+ rv = AliPHOSGeometry::GetInstance();
+ if (!rv) {
+ AliError("Could not find PHOS geometry! Loading the default one !");
+ rv = AliPHOSGeometry::GetInstance("IHEP","");
}
- 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;
+ 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 ;
}
//____________________________________________________________________________
-TObject** AliPHOSGetter::DigitsRef(const char * name) const
-{ //------- Digits ----------------------
-
- // the hierarchy is //Folders/Run/Event/Data/PHOS/Digits/name
+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() ) ;
+}
- if ( !fDigitsFolder ) {
- cerr << "ERROR: AliPHOSGetter::DigitsRef -> Folder //" << fDigitsFolder << " not found!" << endl;
- abort() ;
- }
+//____________________________________________________________________________
+void AliPHOSGetter::ReadPrimaries()
+{
+ // Read Primaries from Kinematics.root
- TFolder * phosFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("PHOS")) ;
- if ( !phosFolder ) {
- cerr << "ERROR: AliPHOSGetter::DigitsRef -> Folder //" << fDigitsFolder << "/PHOS/ not found!" << endl;
- abort() ;
- }
+ 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() ) ;
+
- TObject * d = phosFolder->FindObject(name) ;
- if(!d) {
- cerr << "ERROR: AliPHOSGetter::DigitsRef -> object " << name << " not found! " << endl ;
- abort() ;
+ // 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)));
}
- else
- return phosFolder->GetListOfFolders()->GetObjectRef(d) ;
+}
+//____________________________________________________________________________
+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(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;
+void AliPHOSGetter::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Double_t & energy, Double_t & time) const
+{
+ // 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. ;
+
+ // Create a shaper pulse object which contains all the shaper parameters
+ AliPHOSPulseGenerator pulse;
+
+ if (lowGainFlag) {
+ timezero1 = timezero2 = signalmax = timemax = 0. ;
+ signalF->FixParameter(0, pulse.GetRawFormatLowCharge()) ;
+ signalF->FixParameter(1, pulse.GetRawFormatLowGain()) ;
+ Int_t index ;
+ for (index = 0; index < pulse.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 ;
+ }
}
- 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) ;
+ signalmax /=
+ pulse.RawResponseFunctionMax(pulse.GetRawFormatLowCharge(),
+ pulse.GetRawFormatLowGain()) ;
+ if ( timezero1 + pulse.GetRawFormatTimePeak() < pulse.GetRawFormatTimeMax() * 0.4 ) { // else its noise
+ signalF->SetParameter(2, signalmax) ;
+ signalF->SetParameter(3, timezero1) ;
+ gLowGain->Fit(signalF, "QRO", "", 0., timezero2); //, "QRON") ;
+ energy = signalF->GetParameter(2) ;
+ time = signalF->GetMaximumX() - pulse.GetRawFormatTimePeak() - pulse.GetRawFormatTimeTrigger() ;
}
- phos->Add(digitizer) ;
- return kTRUE;
-}
-
-//____________________________________________________________________________
-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;
+ } else {
+ timezero1 = timezero2 = signalmax = timemax = 0. ;
+ signalF->FixParameter(0, pulse.GetRawFormatHighCharge()) ;
+ signalF->FixParameter(1, pulse.GetRawFormatHighGain()) ;
+ Int_t index ;
+ for (index = 0; index < pulse.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 /= pulse.RawResponseFunctionMax(pulse.GetRawFormatHighCharge(),
+ pulse.GetRawFormatHighGain()) ;;
+ if ( timezero1 + pulse.GetRawFormatTimePeak() < pulse.GetRawFormatTimeMax() * 0.4 ) { // else its noise
+ signalF->SetParameter(2, signalmax) ;
+ signalF->SetParameter(3, timezero1) ;
+ gHighGain->Fit(signalF, "QRO", "", 0., timezero2) ;
+ energy = signalF->GetParameter(2) ;
+ time = signalF->GetMaximumX() - pulse.GetRawFormatTimePeak() - pulse.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
-
- 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;
+Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader,Bool_t isOldRCUFormat)
+{
+ // reads the raw format data, converts it into digits format and store digits in Digits()
+ // container.
+ // isOldRCUFormat = kTRUE in case of the old RCU
+ // format used in the raw data readout.
+ // Reimplemented by Boris Polichtchouk (Jul 2006)
+ // to make it working with the Jul-Aug 2006 beam test data.
+
+ //Create raw decoder.
+
+ AliPHOSRawDecoder dc(rawReader);
+ dc.SetOldRCUFormat(isOldRCUFormat);
+ dc.SubtractPedestals(kTRUE);
+
+ TClonesArray * digits = Digits() ;
+ AliPHOSRawDigiProducer pr;
+ pr.MakeDigits(digits,&dc);
+
+ //!!!!for debug!!!
+ Int_t modMax=-111;
+ Int_t colMax=-111;
+ Int_t rowMax=-111;
+ Float_t eMax=-333;
+ //!!!for debug!!!
+
+ Int_t relId[4];
+ for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) {
+ AliPHOSDigit* digit = (AliPHOSDigit*)digits->At(iDigit);
+ if(digit->GetEnergy()>eMax) {
+ PHOSGeometry()->AbsToRelNumbering(digit->GetId(),relId);
+ eMax=digit->GetEnergy();
+ modMax=relId[0];
+ rowMax=relId[2];
+ colMax=relId[3];
}
- phosRPoEMCAFolder = phosFolder->AddFolder("EMCARecPoints", "EMCA RecPoints from PHOS") ;
- }
-
- TObject * erp = phosFolder->FindObject( name ) ;
- if ( !erp ) {
- TObjArray * emcrp = new TObjArray(100) ;
- emcrp->SetName(name) ;
- phosRPoEMCAFolder->Add(emcrp) ;
}
- // 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;
- }
- 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) ;
- }
- return kTRUE;
+ AliDebug(1,Form("Digit with max. energy: modMax %d colMax %d rowMax %d eMax %f\n\n",
+ modMax,colMax,rowMax,eMax));
+
+ return digits->GetEntriesFast() ;
}
//____________________________________________________________________________
-TObject** AliPHOSGetter::EmcRecPointsRef(const char * name) const
-{ // -------------- RecPoints -------------------------------------------
+Int_t AliPHOSGetter::ReadTreeD() const
+{
+ // Read the Digits
- // the hierarchy is //Folders/Run/Event/RecData/PHOS/EMCARecPoints/name
-
- if ( !fRecoFolder ) {
- cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder->GetName() << " not found!" << endl;
- abort() ;
- }
-
- TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/EMCARecPoints")) ;
- if ( !phosFolder ) {
- cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/EMCARecPoints/ not found!" << endl;
- abort() ;
- }
-
-
- TObject * erp = phosFolder->FindObject(name ) ;
- if ( !erp ) {
- cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> object " << name << " not found! " << endl ;
- abort() ;
- }
- return phosFolder->GetListOfFolders()->GetObjectRef(erp) ;
-
-}
-
-//____________________________________________________________________________
-TObject** AliPHOSGetter::CpvRecPointsRef(const char * name) const
-{ // -------------- RecPoints -------------------------------------------
-
- // the hierarchy is //Folders/Run/Event/RecData/PHOS/CPVRecPoints/name
-
- if ( !fRecoFolder ) {
- cerr << "ERROR: AliPHOSGetter::CpvRecPointsRef -> Folder //" << fRecoFolder->GetName() << " not found!" << endl;
- abort() ;
- }
-
- TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/CPVRecPoints")) ;
- if ( !phosFolder ) {
- cerr << "ERROR: AliPHOSGetter::CpvRecPointsRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/CPVRecPoints/" << endl;
- abort() ;
- }
-
- TObject * crp = phosFolder->FindObject(name ) ;
- if ( !crp ) {
- cerr << "ERROR: AliPHOSGetter::CpvRecPointsRef -> object " << name << " not found " << endl ;
- abort() ;
- }
- return phosFolder->GetListOfFolders()->GetObjectRef(crp) ;
-
-}
-
-//____________________________________________________________________________
-Bool_t AliPHOSGetter::PostClusterizer(AliPHOSClusterizer * clu) 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 << "/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;
-}
+ PhosLoader()->CleanDigits() ;
+ PhosLoader()->LoadDigits("UPDATE") ;
+ PhosLoader()->LoadDigitizer("UPDATE") ;
+ return Digits()->GetEntries() ;
+}
//____________________________________________________________________________
-TObject** AliPHOSGetter::ClusterizerRef(const char * name) const
-{ // ------------------ AliPHOSClusterizer ------------------------
-
- TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
-
- if ( !tasks ) {
- cerr << "ERROR: AliPHOSGetter::ClusterizerRef -> Task //" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
- abort() ;
- }
-
- TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
- if ( !phos ) {
- cerr <<"WARNING: AliPHOSGetter::ClusterizerRef -> //" << fTasksFolder->GetName() << "/Reconstructioner/PHOS" << endl;
- abort() ;
- }
-
- 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{
- cerr << "ERROR: AliPHOSGetter::ClusterizerRef -> Task //" << fTasksFolder->GetName() << "/Reconstructioner/clusterizer " << name << " not found!" << endl;
- abort() ;
- }
+Int_t AliPHOSGetter::ReadTreeH() const
+{
+ // 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::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 ;
- }
+Int_t AliPHOSGetter::ReadTreeR() const
+{
+ // Read the RecPoints
- 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) ;
- }
-
- TList * l = phos->GetListOfTasks() ;
- TIter it(l) ;
- TString clun(name) ;
- clun+=":clu" ;
- TTask * task ;
- while((task = static_cast<TTask *>(it.Next()) )){
- TString taskname(task->GetName()) ;
- if(taskname.BeginsWith(clun))
- return kTRUE ;
- }
+ PhosLoader()->CleanRecPoints() ;
+ // gets TreeR from the root file (PHOS.RecPoints.root)
+ //if ( !IsLoaded("R") ) {
+ PhosLoader()->LoadRecPoints("UPDATE") ;
+ PhosLoader()->LoadClusterizer("UPDATE") ;
+ // SetLoaded("R") ;
+ //}
- AliPHOSClusterizerv1 * phoscl = new AliPHOSClusterizerv1() ;
- phoscl->SetName(clun) ;
- phos->Add(phoscl) ;
- return kTRUE;
-
+ return EmcRecPoints()->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;
- abort() ;
- }
-
- TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/TrackSegments")) ;
- if ( !phosFolder ) {
- cerr << "ERROR: AliPHOSGetter::TrackSegmentsRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/TrackSegments/ not found!" << endl;
- abort() ;
- }
-
- TObject * tss = phosFolder->FindObject(name) ;
- if (!tss) {
- cerr << "ERROR: AliPHOSGetter::TrackSegmentsRef -> object " << name << " not found! " << endl ;
- abort() ;
- }
- 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) ;
- }
-
- TList * l = phos->GetListOfTasks() ;
- TIter it(l) ;
- TString tsn(name);
- tsn+=":tsm" ;
- TTask * task ;
- while((task = static_cast<TTask *>(it.Next()) )){
- TString taskname(task->GetName()) ;
- if(taskname.BeginsWith(tsn))
- return kTRUE ;
- }
-
- AliPHOSTrackSegmentMakerv1 * phosts = new AliPHOSTrackSegmentMakerv1() ;
- 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::TSMakerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
- abort() ;
- }
-
- TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
- if ( !phos ) {
- cerr <<"WARNING: AliPHOSGetter::TSMakerRef -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
- abort() ;
- }
-
- 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 {
- cerr << "ERROR: AliPHOSGetter::TSMakerRef -> Task //" << fTasksFolder << "/Reconstructioner/TrackSegmentMarker name not found!" << endl;
- abort() ;
- }
-}
-
-//____________________________________________________________________________
-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")) ;
-
- 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") ;
- }
-
- 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;
-}
-
-//____________________________________________________________________________
-TObject** AliPHOSGetter::RecParticlesRef(const char * name) const
-{ // ---------------TrackSegments -----------------------------------
+Int_t AliPHOSGetter::ReadTreeT() const
+{
+ // Read the TrackSegments
- // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
-
- if ( !fRecoFolder ) {
- cerr << "ERROR: AliPHOSGetter::RecParticlesRef -> Folder//" << fRecoFolder->GetName() << " not found!" << endl;
- abort() ;
- }
-
- TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/RecParticles")) ;
- if ( !phosFolder ) {
- cerr << "ERROR: AliPHOSGetter::RecParticlesRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/RecParticles/ not found!" << endl;
- abort() ;
- }
+ PhosLoader()->CleanTracks() ;
+ // gets TreeT from the root file (PHOS.TrackSegments.root)
+ //if ( !IsLoaded("T") ) {
+ PhosLoader()->LoadTracks("UPDATE") ;
+ PhosLoader()->LoadTrackSegmentMaker("UPDATE") ;
+ // SetLoaded("T") ;
+ //}
- TObject * tss = phosFolder->FindObject(name ) ;
- if (!tss) {
- cerr << "ERROR: AliPHOSGetter::RecParticlesRef -> object " << name << " not found! " << endl ;
- abort() ;
- }
- 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() const
+{
+ // 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() const
+{
+ // 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+=":pidv1" ;
- TTask * task ;
- while((task = static_cast<TTask *>(it.Next()) )){
- TString taskname(task->GetName()) ;
- if(taskname.BeginsWith(pidname))
- return kTRUE ;
- }
-
- AliPHOSPIDv1 * phospid = new AliPHOSPIDv1() ;
- 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::PIDRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
- abort() ;
- }
-
- TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
- if ( !phos ) {
- cerr << "ERROR: AliPHOSGetter::PIDRef -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
- abort() ;
- }
-
- 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 {
- cerr << "ERROR: AliPHOSGetter::PIDRef -> Task //" << fTasksFolder << "/Reconstructioner/PID name not found!" << endl;
- abort() ;
- }
+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
+ Error("ReadTreeE", "no ESD tree found");
+ return -1;
+ }
+ fESDTree->SetBranchAddress("ESD", &fESD);
+ fESDTree->GetEvent(event);
- 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") ;
- }
-
- return kTRUE;
+ return event ;
}
//____________________________________________________________________________
-TObject** AliPHOSGetter::AlarmsRef(void) const
-{ //------- Alarms ----------------------
+TClonesArray * AliPHOSGetter::SDigits() const
+{
+ // asks the Loader to return the Digits container
+ TClonesArray * rv = 0 ;
- // the hierarchy is //Folders/Run/Conditions/QA/PHOS
- if ( !fQAFolder ) {
- cerr << "ERROR: AliPHOSGetter::AlarmsRef -> Folder //" << fQAFolder << " not found!" << endl;
- abort() ;
- }
-
- TFolder * phosFolder = dynamic_cast<TFolder *>(fQAFolder->FindObject("PHOS")) ;
- if ( !phosFolder ) {
- cerr << "ERROR: AliPHOSGetter::AlarmsRef -> Folder //" << fQAFolder << "/PHOS/ not found!" << endl;
- abort() ;
+ 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 ;
-// }
- 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) ;
-
+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 ;
}
//____________________________________________________________________________
-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());
-//____________________________________________________________________________
-Int_t AliPHOSGetter::ReadTreeH()
-{
- // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
+ if( !TreeH() ) // load treeH the first time
+ rl->LoadHits() ;
- if(gAlice->TreeH()== 0){
- cerr << "WARNING: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
- return 1;
- }
-
- 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 ;
+ // 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) ;
}
//____________________________________________________________________________
-void AliPHOSGetter::Track(Int_t itrack)
+TTree * AliPHOSGetter::TreeD() 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 Digits Tree
+ TTree * rv = 0 ;
+ rv = PhosLoader()->TreeD() ;
+ if ( !rv ) {
+ PhosLoader()->MakeTree("D");
+ rv = PhosLoader()->TreeD() ;
+ }
- 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::TreeH() 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 Hits Tree
+ TTree * rv = 0 ;
+ rv = PhosLoader()->TreeH() ;
+ if ( !rv ) {
+ PhosLoader()->MakeTree("H");
+ rv = PhosLoader()->TreeH() ;
+ }
+ return rv ;
}
//____________________________________________________________________________
-Int_t AliPHOSGetter::ReadTreeR(Bool_t any)
+TTree * AliPHOSGetter::TreeR() 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
- // any migh have become obsolete : to be checked
- // See AliPHOSPIDv1
-
- 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 ;
-
- } else {
- if(!EmcRecPoints(fRecPointsTitle) )
- PostRecPoints(fRecPointsTitle) ;
- emcbranch->SetAddress(EmcRecPointsRef(fRecPointsTitle)) ;
- emcbranch->GetEntry(0) ;
- }
-
- if ( !phoscpvrpfound ) {
- if (fDebug)
- cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find CpvRecPoints with title "
- << fRecPointsTitle << endl ;
- } else {
- cpvbranch->SetAddress(CpvRecPointsRef(fRecPointsTitle)) ;
- cpvbranch->GetEntry(0) ;
- }
-
- if ( !clusterizerfound ) {
- if (fDebug)
- cout << "WARNING: AliPHOSGetter::ReadTreeR -> Can not find Clusterizer with title "
- << fRecPointsTitle << endl ;
- } else {
- 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 ;
- } else {
- // 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 ;
- }
- }
+ // Returns pointer to the RecPoints Tree
+ TTree * rv = 0 ;
+ rv = PhosLoader()->TreeR() ;
+ if ( !rv ) {
+ PhosLoader()->MakeTree("R");
+ rv = PhosLoader()->TreeR() ;
+ }
- if ( !phosrpafound || !pidfound ) {
- if (fDebug)
- cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name "
- << fRecParticlesTitle << endl ;
- } else {
- // 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) ;
- pidbranch->SetAddress(PIDRef(fRecParticlesTitle)) ;
- pidbranch->GetEntry(0) ;
- }
- return 0 ;
+ return rv ;
}
//____________________________________________________________________________
-Int_t AliPHOSGetter::ReadTreeS(Int_t event)
+TTree * AliPHOSGetter::TreeT() 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("/","_") ;
-
- 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 ;
- }
- }
- 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
+ // Returns pointer to the TrackSegments Tree
+ TTree * rv = 0 ;
+ rv = PhosLoader()->TreeT() ;
+ if ( !rv ) {
+ PhosLoader()->MakeTree("T");
+ rv = PhosLoader()->TreeT() ;
+ }
- next.Reset();
- folder = static_cast<TFolder*>(next());
- if(folder){
- TString fileName(folder->GetName()) ;
- fileName.ReplaceAll("_","/") ;
- file = static_cast<TFile*>(gROOT->GetFile(fileName));
- file ->cd() ;
- }
- return 0 ;
+ return rv ;
}
//____________________________________________________________________________
-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") ;
+TTree * AliPHOSGetter::TreeP() const
+{
+ // Returns pointer to the RecParticles Tree
+ TTree * rv = 0 ;
+ rv = PhosLoader()->TreeP() ;
+ if ( !rv ) {
+ PhosLoader()->MakeTree("P");
+ rv = PhosLoader()->TreeP() ;
}
- 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 ( !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()
-{
- // a lot simplified.... if 2 files are opened then we have a problem
-
- TClonesArray * ar = 0 ;
- if(! (ar = Primaries()) ) {
- PostPrimaries() ;
- ar = Primaries() ;
- }
- ar->Delete() ;
+TTree * AliPHOSGetter::TreeS() const
+{
+ // Returns pointer to the SDigits Tree
+ TTree * rv = 0 ;
+ rv = PhosLoader()->TreeS() ;
+ if ( !rv ) {
+ PhosLoader()->MakeTree("S");
+ rv = PhosLoader()->TreeS() ;
+ }
- fNPrimaries = gAlice->GetNtrack() ;
- Int_t index = 0 ;
- for (index = 0 ; index < fNPrimaries; index++) {
- new ((*ar)[index]) TParticle(*(Primary(index)));
- }
+ return rv ;
}
+
//____________________________________________________________________________
-void AliPHOSGetter::Event(const Int_t event, const char* opt)
+Bool_t AliPHOSGetter::VersionExists(TString & opt) const
{
- // Reads the content of all Tree's S, D and R
+ // checks if the version with the present name already exists in the same directory
+
+ Bool_t rv = kFALSE ;
- if (event >= gAlice->TreeE()->GetEntries() ) {
- cerr << "ERROR: AliPHOSGetter::Event -> " << event << " not found in TreeE!" << endl ;
- return ;
+ 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) ;
}
- 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 ( 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( strstr(opt,"P") || (strcmp(opt,"")==0) )
- if ( gAlice->Stack() )
- ReadPrimaries() ;
+ return rv ;
}
//____________________________________________________________________________
-TObject * AliPHOSGetter::ReturnO(TString what, TString name, TString file) const
+UShort_t AliPHOSGetter::EventPattern(void) 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 the pattern (trigger bit register) of the beam-test event
+ if(fBTE)
+ return fBTE->GetPattern() ;
+ else
return 0 ;
- }
-
- return phosO ;
}
-
//____________________________________________________________________________
-const TTask * AliPHOSGetter::ReturnT(TString what, TString name) const
+Float_t AliPHOSGetter::BeamEnergy(void) 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 ;
- }
+ // Return the beam energy of the beam-test event
+ if(fBTE)
+ return fBTE->GetBeamEnergy() ;
+ else
+ 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(":clusterizer") ;
- }
- else if (what.CompareTo("TrackSegmentMaker") == 0){
- if ( name.IsNull() )
- name = fTrackSegmentsTitle ;
- name.Append(":tracksegmentmaker") ;
- }
- 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 ;
+AliPHOSCalibData* AliPHOSGetter::CalibData()
+{
+ // Check if the instance of AliPHOSCalibData exists, and return it
+
+ return fgCalibData;
}