#include <iomanip.h>
// --- AliRoot header files ---
-
+#include "AliPHOSCalibrationDB.h"
#include "AliPHOSClusterizerv1.h"
#include "AliPHOSCpvRecPoint.h"
#include "AliPHOSDigit.h"
//____________________________________________________________________________
Float_t AliPHOSClusterizerv1::Calibrate(Int_t amp, Int_t absId) const
{ //To be replased later by the method, reading individual parameters from the database
-
- if(absId <= fEmcCrystals) //calibrate as EMC
- return fADCpedestalEmc + amp*fADCchanelEmc ;
-
- else //Digitize as CPV
- return fADCpedestalCpv+ amp*fADCchanelCpv ;
+ if(fCalibrationDB)
+ return fCalibrationDB->Calibrate(amp,absId) ;
+ else{ //simulation
+ if(absId <= fEmcCrystals) //calibrate as EMC
+ return fADCpedestalEmc + amp*fADCchanelEmc ;
+ else //calibrate as CPV
+ return fADCpedestalCpv+ amp*fADCchanelCpv ;
+ }
}
//____________________________________________________________________________
void AliPHOSClusterizerv1::GetCalibrationParameters()
{
AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
- const AliPHOSDigitizer * dig = gime->Digitizer(BranchName()) ;
- fADCchanelEmc = dig->GetEMCchannel() ;
- fADCpedestalEmc = dig->GetEMCpedestal();
-
- fADCchanelCpv = dig->GetCPVchannel() ;
- fADCpedestalCpv = dig->GetCPVpedestal() ;
-
+ const TTask * task = gime->Digitizer(BranchName()) ;
+ if(strcmp(task->IsA()->GetName(),"AliPHOSDigitizer")==0){
+ const AliPHOSDigitizer * dig = static_cast<const AliPHOSDigitizer *>(task) ;
+
+ fADCchanelEmc = dig->GetEMCchannel() ;
+ fADCpedestalEmc = dig->GetEMCpedestal();
+
+ fADCchanelCpv = dig->GetCPVchannel() ;
+ fADCpedestalCpv = dig->GetCPVpedestal() ;
+ }
+ else{
+ fCalibrationDB = gime->CalibrationDB();
+ }
}
//____________________________________________________________________________
clusterizerName.Append(Version()) ;
SetName(clusterizerName) ;
fRecPointsInRun = 0 ;
+ fCalibrationDB = 0 ;
+
}
}
if(!treeR){
- gAlice->MakeTree("R", fSplitFile);
+ if(fSplitFile)
+ gAlice->MakeTree("R", fSplitFile);
+ else
+ gAlice->MakeTree("R", gROOT->GetFile(GetTitle()));
treeR = gAlice->TreeR() ;
}
if (( IsInEmc (digit) && Calibrate(digit->GetAmp(),digit->GetId()) > fEmcClusteringThreshold ) ||
( IsInCpv (digit) && Calibrate(digit->GetAmp(),digit->GetId()) > fCpvClusteringThreshold ) ) {
-
Int_t iDigitInCluster = 0 ;
if ( IsInEmc(digit) ) {
class AliPHOSDigit ;
class AliPHOSDigitizer ;
class AliPHOSGeometry ;
-
+class AliPHOSCalibrationDB ;
class AliPHOSClusterizerv1 : public AliPHOSClusterizer {
Int_t fNumberOfEmcClusters ; // number of EMC clusters found
Int_t fNumberOfCpvClusters ; // number of CPV clusters found
- //Calibration parameters... to be replaced by database
+ //Calibration parameters
+ AliPHOSCalibrationDB * fCalibrationDB ; //! Calibration database if aval
Float_t fADCchanelEmc ; // width of one ADC channel in GeV
Float_t fADCpedestalEmc ; //
Float_t fADCchanelCpv ; // width of one ADC channel in CPV 'popugais'
// -- Create Digitizer branch
Int_t splitlevel = 0 ;
- const AliPHOSDigitizer * d = gime->Digitizer(GetName()) ;
+ const AliPHOSDigitizer * d = dynamic_cast<const AliPHOSDigitizer *>(gime->Digitizer()) ;
TBranch * digitizerBranch = treeD->Branch("AliPHOSDigitizer", "AliPHOSDigitizer", &d,bufferSize,splitlevel);
digitizerBranch->SetTitle(GetName());
#include "AliPHOSTrackSegment.h"
#include "AliPHOSPIDv1.h"
#include "AliPHOSGeometry.h"
-
+#include "AliPHOSRaw2Digits.h"
+#include "AliPHOSCalibrationDB.h"
ClassImp(AliPHOSGetter)
AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
fFailed = kFALSE ;
fDebug = 0 ;
+ fAlice = 0 ;
fToSplit = toSplit ;
fHeaderFile = headerFile ;
{
delete gAlice ;
gAlice = 0 ;
+ delete fAlice ;
+ fAlice = 0 ;
}
//____________________________________________________________________________
d->Add(phos) ;
}
- AliPHOSDigitizer * phosd = dynamic_cast<AliPHOSDigitizer*>(phos->GetListOfTasks()->FindObject(name)) ;
+ TTask * phosd = dynamic_cast<TTask*>(phos->GetListOfTasks()->FindObject(fDigitsTitle)) ;
if (!phosd) {
- phosd = new AliPHOSDigitizer() ;
- phosd->SetName(fDigitsTitle) ;
- phosd->SetTitle(fHeaderFile) ;
- phos->Add(phosd) ;
+ if(strcmp(name, "Digitizer")==0){
+ phosd = new AliPHOSDigitizer() ;
+ phosd->SetName(fDigitsTitle) ;
+ phosd->SetTitle(fHeaderFile) ;
+ phos->Add(phosd) ;
+ }
+ else{
+ phosd = new AliPHOSRaw2Digits() ;
+ phosd->SetName(fDigitsTitle) ;
+ phosd->SetTitle(fHeaderFile) ;
+ phos->Add(phosd) ;
+ }
}
return kTRUE;
}
TFile * file = 0 ;
file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
- if (!file) { // file not yet open
- file = TFile::Open(filename.Data(), "read") ;
+ if (file && (filename != fHeaderFile) ) { // file already open
+ file->Close() ;
+ delete fAlice ;
}
+ file = TFile::Open(filename.Data(), "read") ;
+ fAlice = static_cast<AliRun *>(file->Get("gAlice")) ;
TString treeName("TreeK") ;
treeName += EventNumber() ;
TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
if(index < 0)
return 0 ;
TParticle * p = 0 ;
-
- p = gAlice->Particle(index) ;
+ if (fAlice)
+ p = fAlice->Particle(index) ;
+ else
+ p = gAlice->Particle(index) ;
return p ;
digitsbranch = branch ;
phosfound = kTRUE ;
}
- else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
+ else if ( ((strcmp(branch->GetName(), "AliPHOSDigitizer")==0)||
+ (strcmp(branch->GetName(), "AliPHOSRaw2Digits")==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);
// read the Digitizer
- RemoveTask("D", fDigitsTitle) ; // I do not understand why I need that
- if(!Digitizer(fDigitsTitle))
- PostDigitizer(fDigitsTitle) ;
+ if(Digitizer()){
+ if(strcmp(Digitizer()->IsA()->GetName(),digitizerbranch->GetName())!=0){
+ RemoveTask("D", fDigitsTitle) ;
+ if(strcmp(digitizerbranch->GetName(), "AliPHOSDigitizer")==0)
+ PostDigitizer("Digitizer") ;
+ else
+ PostDigitizer("Raw2Digits") ;
+ }
+ }
+ else{
+ if(strcmp(digitizerbranch->GetName(), "AliPHOSDigitizer")==0)
+ PostDigitizer("Digitizer") ;
+ else
+ PostDigitizer("Raw2Digits") ;
+ }
+
+
digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
digitizerbranch->GetEntry(0) ;
-
- // lob ->Delete();
+
+
+ if((!fcdb)&&(strcmp(digitizerbranch->GetName(), "AliPHOSRaw2Digits")==0))
+ ReadCalibrationDB("Primordial","beamtest.root") ;
+
if(gAlice->TreeD()!=treeD)
treeD->Delete();
+
return 0 ;
}
+//____________________________________________________________________________
+void AliPHOSGetter::ReadCalibrationDB(const char * database,const char * filename){
+
+ if(fcdb && (strcmp(database,fcdb->GetTitle())==0))
+ return ;
+
+ TFile * file = gROOT->GetFile(filename) ;
+ if(!file)
+ file = TFile::Open(filename);
+ if(!file){
+ cout << "Can not open file " << filename << endl ;
+ return ;
+ }
+ if(fcdb)
+ fcdb->Delete() ;
+ fcdb = dynamic_cast<AliPHOSCalibrationDB *>(file->Get("AliPHOSCalibrationDB")) ;
+ if(!fcdb)
+ cout << "No database " << database << " in file " << filename << endl ;
+}
//____________________________________________________________________________
Int_t AliPHOSGetter::ReadTreeH()
}
//____________________________________________________________________________
-void AliPHOSGetter::Track(const Int_t itrack)
+void AliPHOSGetter::Track(Int_t itrack)
{
// Read the first entry of PHOS branch in hit tree gAlice->TreeH()
if (fDebug)
cout << "INFO: AliPHOSGetter::ReadPrimaries -> TreeK found in " << fHeaderFile.Data() << endl ;
fNPrimaries = gAlice->GetNtrack() ;
+ fAlice = 0 ;
} else { // treeK not found in header file
if( strstr(opt,"Q") )
ReadTreeQA() ;
- if( strstr(opt,"P"))
+ if( strstr(opt,"P") || (strcmp(opt,"")==0) )
ReadPrimaries() ;
}
class AliPHOSClusterizer ;
class AliPHOSTrackSegmentMaker ;
class AliPHOSPID ;
+class AliPHOSCalibrationDB ;
class AliPHOSGetter : public TObject {
void Event(const Int_t event, const char * opt = "HSDRP") ;
void Track(const Int_t itrack) ;
void ReadTreeS(TTree * treeS,Int_t input) ; //Method to be used when
- //digitizing is under the control ofAliRunDigitizer,
+ //digitizing is under the control ofAliRunDigizer,
//which opens all files etc.
//========== Alarms ======================
TFolder * Alarms() const { return dynamic_cast<TFolder*>(ReturnO("Alarms", 0)) ; }
TClonesArray * Digits(const char * name = 0)const {
return dynamic_cast<TClonesArray*>(ReturnO("Digits", name)) ; }
//const AliPHOSDigit * Digit(Int_t index) { return static_cast<const AliPHOSDigit *>(Digits()->At(index)) ;} !!! why no such method ?
- const AliPHOSDigitizer * Digitizer(const char * name = 0) const {
- return (const AliPHOSDigitizer*)(ReturnT("Digitizer", name)) ; }
+ const TTask * Digitizer(const char * name = 0) const {
+ return ReturnT("Digitizer", name) ; }
+ AliPHOSCalibrationDB * CalibrationDB(){return fcdb; }
+ void ReadCalibrationDB(const char * name, const char * filename) ;
//========== RecPoints =============
TObjArray * EmcRecPoints(const char * name = 0) {
TString fSDigitsFileName ; //!
Bool_t fFailed ; //! set if file not opend or galice not found
Int_t fDebug ; //! Debug level
+ AliRun * fAlice ; //! needed to read TreeK if in an other file than fHeaderFile
Int_t fNPrimaries ; //! # of primaries
TObjArray * fPrimaries ; //! list of lists of primaries-for the case of mixing
TFolder * fModuleFolder ; //!Folder that contains the modules
TFolder * fRecoFolder ; //!Folder that contains the reconstructed objects (RecPoints, TrackSegments, RecParticles)
TFolder * fQAFolder ; //!Folder that contains the QA objects
TFolder * fTasksFolder ; //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
+
+ AliPHOSCalibrationDB * fcdb ; //!
static AliPHOSGetter * fgObjGetter; // pointer to the unique instance of the singleton