-#include "AliLog.h"
-#include "AliTRDgeometry.h"
-
-#include <AliCDBStorage.h>
-#include <AliCDBEntry.h>
-
-//includes neccessary here for compiliation of dynamic_cast
-#include "AliTRDCalPad.h"
-#include "AliTRDCalDet.h"
-
-class AliTRDCalChamber;
-class AliTRDCalStack;
-class AliTRDCalGlobals;
-
-// 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); }
-
-// 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); }
-
-class AliTRDcalibDB : public TObject
-{
-public:
- enum { kNplan = 6, kNcham = 5, kNsect = 18, kNdet = 540 };
-
- static AliTRDcalibDB* Instance();
- static void Terminate();
-
- 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 GetPRFWidth(Int_t det, Int_t col, Int_t row);
- HEADER_PAD(GetPRFWidth);
-
- Float_t GetSamplingFrequency();
- Int_t GetNumberOfTimeBins();
-
- //Related functions, these depend on calibration data
- static Float_t GetOmegaTau(Float_t vdrift);
- Int_t PadResponse(Double_t signal, Double_t dist, Int_t plane, Double_t *pad) const;
-
-protected:
- 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
-
- 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<Name> : return CacheCDBEntry(kID<Name>, "TRD/Calib/<Path>"); 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<Name> : return CacheMergeCDBEntry(kID<Name>, "TRD/Calib/<padPath>", "TRD/Calib/<chamberPath>"); 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;
- }
-
- void Invalidate();
- void SamplePRF();
-
- 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);
-
- 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