X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FAliTRDcalibDB.h;h=ae68497b92d8ebdf98635d8f0a1423036854c580;hb=41c5285024056bc72838fcd6b1d8d3b98558228d;hp=101cd3180163cdca0bf7fd8d227668ac985aa899;hpb=dde5943735bebcb0a8899af7e2e3f53521521471;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/AliTRDcalibDB.h b/TRD/AliTRDcalibDB.h index 101cd318016..ae68497b92d 100644 --- a/TRD/AliTRDcalibDB.h +++ b/TRD/AliTRDcalibDB.h @@ -11,220 +11,143 @@ /* $Id$ */ -#include +#ifndef ROOT_TObject #include "TObject.h" +#endif -#include "AliLog.h" -#include "AliTRDgeometry.h" +#ifndef ALITRDPIDUTIL_H +#include "AliTRDpidUtil.h" +#endif -#include -#include +class AliCDBEntry; -//includes neccessary here for compiliation of dynamic_cast -#include "AliTRDCalPad.h" -#include "AliTRDCalDet.h" +class AliTRDrecoParam; +class AliTRDCalPID; +class AliTRDCalMonitoring; +class AliTRDCalROC; +class AliTRDCalDet; +class AliTRDCalSingleChamberStatus; +class AliTRDcalibDB : public TObject { -class AliTRDCalChamber; -class AliTRDCalStack; -class AliTRDCalGlobals; + public: -// defines call to function by providing plane, chamber, sector instead of detector -#define HEADER_PAD(funcname) \ - Float_t funcname(Int_t plane, Int_t chamber, Int_t sector, Int_t col, Int_t row) \ - { return funcname(AliTRDgeometry::GetDetector(plane, chamber, sector), col, row); } + enum { kNlayer = 6 + , kNstack = 5 + , kNsector = 18 + , kNdet = 540 }; + + static AliTRDcalibDB *Instance(); + static void Terminate(); -// defines call to function by providing plane, chamber, sector instead of detector -#define HEADER_CHAMBER(funcname) \ - Bool_t funcname(Int_t plane, Int_t chamber, Int_t sector, Float_t* xyz) \ - { return funcname(AliTRDgeometry::GetDetector(plane, chamber, sector), xyz); } + void SetRun(Long64_t run); + Long64_t GetRun() const { return fRun; } -class AliTRDcalibDB : public TObject -{ -public: - static AliTRDcalibDB* Instance(); - static void Terminate(); + Float_t GetNoise(Int_t det, Int_t col, Int_t row); + AliTRDCalROC *GetNoiseROC(Int_t det); + const AliTRDCalDet *GetNoiseDet(); - void SetRun(Long64_t run); - - Bool_t GetChamberPos(Int_t det, Float_t* xyz); - HEADER_CHAMBER(GetChamberPos); - - Bool_t GetChamberRot(Int_t det, Float_t* xyz); - HEADER_CHAMBER(GetChamberRot); - - Bool_t GetStackPos(Int_t chamber, Int_t sector, Float_t* xyz); - Bool_t GetStackRot(Int_t chamber, Int_t sector, Float_t* xyz); - - Float_t GetVdrift(Int_t det, Int_t col, Int_t row); - HEADER_PAD(GetVdrift); - - Float_t GetT0(Int_t det, Int_t col, Int_t row); - HEADER_PAD(GetT0); - - Float_t GetGainFactor(Int_t det, Int_t col, Int_t row); - HEADER_PAD(GetGainFactor); + Float_t GetVdrift(Int_t det, Int_t col, Int_t row); + Float_t GetVdriftAverage(Int_t det); + AliTRDCalROC *GetVdriftROC(Int_t det); + const AliTRDCalDet *GetVdriftDet(); - Float_t GetSamplingFrequency(); - Int_t GetNumberOfTimeBins(); - - //Related functions, these depend on calibration data - static Float_t GetOmegaTau(Float_t vdrift); - -protected: - void Invalidate(); - - static AliTRDcalibDB* fgInstance; // Instance of this class (singleton implementation) - static Bool_t fgTerminated; // Defines if this class has already been terminated and therefore does not return instances in GetInstance anymore + Float_t GetT0(Int_t det, Int_t col, Int_t row); + Float_t GetT0Average(Int_t det); + AliTRDCalROC *GetT0ROC(Int_t det); + const AliTRDCalDet *GetT0Det(); - AliCDBStorage* fLocator; // Storage locator retrieved from AliCDBManager - - enum { kCDBCacheSize = 7 }; // Number of cached objects - enum { kIDVdrift = 0, kIDT0 = 1, kIDGainFactor = 2, kIDPRFWidth = 3, kIDGlobals = 4, kIDChamber = 5, kIDStack = 6 }; // IDs of cached objects - - AliCDBEntry* fCDBEntries[kCDBCacheSize]; // Cache for CDB entries - TObject* fCDBCache[kCDBCacheSize]; // Cache for calibration objects. - - inline AliCDBEntry* GetCDBEntry(const char* cdbPath); - inline TObject* CacheCDBEntry(Int_t id, const char* cdbPath); - inline TObject* CacheMergeCDBEntry(Int_t id, const char* cdbPadPath, const char* cdbChamberPath); + Float_t GetGainFactor(Int_t det, Int_t col, Int_t row); + Float_t GetGainFactorAverage(Int_t det); + AliTRDCalROC *GetGainFactorROC(Int_t det); + const AliTRDCalDet *GetGainFactorDet(); + + AliTRDCalROC *GetPRFROC(Int_t det); + Float_t GetPRFWidth(Int_t det, Int_t col, Int_t row); + + Float_t* GetSampledPRF() { return fPRFsmp; }; + Int_t GetPRFbin() { return fPRFbin; }; + Float_t GetPRFlo() { return fPRFlo; }; + Float_t GetPRFhi() { return fPRFhi; }; + + Int_t GetNumberOfTimeBins(); + + Char_t GetPadStatus(Int_t det, Int_t col, Int_t row); + AliTRDCalSingleChamberStatus *GetPadStatusROC(Int_t det); + AliTRDrecoParam* GetRecoParam(Int_t *eventtype); + + Char_t GetChamberStatus(Int_t det); + + Bool_t IsPadMasked(Int_t det, Int_t col, Int_t row); + Bool_t IsPadBridgedLeft(Int_t det, Int_t col, Int_t row); + Bool_t IsPadBridgedRight(Int_t det, Int_t col, Int_t row); + Bool_t IsPadNotConnected(Int_t det, Int_t col, Int_t row); - TObject* GetCachedCDBObject(Int_t id) - { - // - // Retrieves a cdb object with the given id. The objects are cached as long as the run number is not changed. - // - // Put together the available objects here by using the lines - // a) For usual calibration objects: - // ase kID : return CacheCDBEntry(kID, "TRD/Calib/"); break; - // See function CacheCDBEntry for details. - // and - // b) For calibration data which depends on two objects: One containing a value per detector and one the local fluctuations per pad: - // case kID : return CacheMergeCDBEntry(kID, "TRD/Calib/", "TRD/Calib/"); break; - // See function CacheMergeCDBEntry for details. - // - - switch (id) - { - // parameters defined per pad and chamber - case kIDVdrift : return CacheMergeCDBEntry(kIDVdrift, "TRD/Calib/LocalVdrift", "TRD/Calib/ChamberVdrift"); break; - case kIDT0 : return CacheMergeCDBEntry(kIDT0, "TRD/Calib/LocalT0", "TRD/Calib/ChamberT0"); break; - - // parameters defined per pad - case kIDGainFactor : return CacheCDBEntry(kIDGainFactor, "TRD/Calib/GainFactor"); break; - case kIDPRFWidth : return CacheCDBEntry(kIDPRFWidth, "TRD/Calib/PRFWidth"); break; - - // global parameters - case kIDGlobals : return CacheCDBEntry(kIDGlobals, "TRD/Calib/Globals"); break; - case kIDChamber : return CacheCDBEntry(kIDChamber, "TRD/Calib/Chamber"); break; - case kIDStack : return CacheCDBEntry(kIDStack, "TRD/Calib/Stack"); break; - } - return 0; - } + Bool_t IsChamberInstalled(Int_t det); + Bool_t IsChamberMasked(Int_t det); + + const AliTRDCalMonitoring *GetMonitoringObject(); + const AliTRDCalPID *GetPIDObject(AliTRDpidUtil::ETRDPIDMethod m); + + // Related functions, these depend on calibration data + Int_t PadResponse(Double_t signal, Double_t dist + , Int_t layer, Double_t *pad) const; + + protected: + + // For caching see also implentation of GetCachedCDBObject in the .cxx file + enum { kCDBCacheSize = 19 }; // Number of cached objects + enum { kIDVdriftPad = 0 + , kIDVdriftChamber + , kIDT0Pad + , kIDT0Chamber + , kIDGainFactorPad + , kIDGainFactorChamber + , kIDNoiseChamber + , kIDNoisePad + , kIDPRFWidth + , kIDFEE + , kIDChamberPos + , kIDStackPos + , kIDSuperModulePos + , kIDPIDNN + , kIDPIDLQ + , kIDRecoParam + , kIDMonitoringData + , kIDChamberStatus + , kIDPadStatus }; // IDs of cached objects + + const TObject *GetCachedCDBObject(Int_t id); - Long64_t fRun; + void Invalidate(); + void SamplePRF(); -private: - // this is a singleton, constructor is private! - AliTRDcalibDB(); - virtual ~AliTRDcalibDB(); + AliCDBEntry *GetCDBEntry(const Char_t *cdbPath); + const TObject *CacheCDBEntry(Int_t id, const Char_t *cdbPath); - ClassDef(AliTRDcalibDB, 0) -}; + static AliTRDcalibDB *fgInstance; // Instance of this class (singleton implementation) + static Bool_t fgTerminated; // Defines if this class has already been terminated -AliCDBEntry* AliTRDcalibDB::GetCDBEntry(const char* cdbPath) -{ - // - // Retrieves an entry with path from the CDB. - // - - if (fRun < 0) - { - AliFatal("AliTRDcalibDB: Run number not set! Use AliTRDcalibDB::SetRun."); - //std::cerr << "AliTRDcalibDB: Run number not set! Use AliTRDcalibDB::SetRun." << std::endl; - return 0; - } - if (!fLocator) - { - std::cerr << "AliTRDcalibDB: Storage Locator not available." << std::endl; - return 0; - } - AliCDBEntry* entry = fLocator->Get(cdbPath, fRun); - if (!entry) - { - std::cerr << "AliTRDcalibDB: Failed to get entry: " << cdbPath << std::endl; - return 0; - } - - std::cout << "AliTRDcalibDB: Retrieved object: " << cdbPath << std::endl; - return entry; -} - -TObject* AliTRDcalibDB::CacheCDBEntry(Int_t id, const char* cdbPath) -{ - // - // Caches the entry with cdb path - // + AliCDBEntry *fCDBEntries[kCDBCacheSize]; // Cache for CDB entries + TObject *fCDBCache[kCDBCacheSize]; // Cache for calibration objects. + + Long64_t fRun; // Run Number - if (!fCDBCache[id]) - { - fCDBEntries[id] = GetCDBEntry(cdbPath); - if (fCDBEntries[id]) - fCDBCache[id] = fCDBEntries[id]->GetObject(); - } - return fCDBCache[id]; -} - -TObject* AliTRDcalibDB::CacheMergeCDBEntry(Int_t id, const char* cdbPadPath, const char* cdbChamberPath) -{ - // - // Retrieves and caches an object (id ) from the CDB. This function is specialized for parameters which are stored - // as local variation at pad level of a global variable defined per detector chamber. It uses the classes AliTRDCalPad and AliTRDCalDet. - // Before storing the object it retrieves the local variations (cdbPadPath) and the global variable (cdbChamberPath) and merges them using - // the AliTRDCalPad::ScaleROCs. - // - - if (!fCDBCache[id]) - { - AliTRDCalPad* padObject = 0; - AliTRDCalDet* detObject = 0; - - fCDBEntries[id] = GetCDBEntry(cdbPadPath); - if (fCDBEntries[id]) - padObject = dynamic_cast(fCDBEntries[id]->GetObject()); - - AliCDBEntry* mergeEntry = GetCDBEntry(cdbChamberPath); - if (mergeEntry) - detObject = dynamic_cast(mergeEntry->GetObject()); - - if (!padObject || !detObject) - { - if (fCDBEntries[id]) { - if (fCDBEntries[id]->IsOwner() == kFALSE && padObject) - delete padObject; - delete fCDBEntries[id]; - fCDBEntries[id] = 0; - } - if (mergeEntry) - { - if (mergeEntry->IsOwner() == kFALSE && detObject) - delete detObject; - delete mergeEntry; - } - return 0; - } - - padObject->ScaleROCs(detObject); - if (mergeEntry->IsOwner() == kFALSE) - delete detObject; - delete mergeEntry; - - fCDBCache[id] = padObject; - } + Float_t *fPRFsmp; //! Sampled pad response + Int_t fPRFbin; // Number of bins for the PRF + Float_t fPRFlo; // Lower boundary of the PRF + Float_t fPRFhi; // Higher boundary of the PRF + Float_t fPRFwid; // Bin width of the sampled PRF + Int_t fPRFpad; // Distance to next pad in PRF - return fCDBCache[id]; -} + private: + + AliTRDcalibDB(); // This is a singleton, constructor is private! + AliTRDcalibDB(const AliTRDcalibDB &c); + AliTRDcalibDB &operator=(const AliTRDcalibDB &c); + virtual ~AliTRDcalibDB(); + + ClassDef(AliTRDcalibDB, 4) // Provides central access to the CDB -#undef HEADER_PAD -#undef HEADER_CHAMBER +}; #endif