]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDcalibDB.h
Added a commented out version with new digitizers.
[u/mrichter/AliRoot.git] / TRD / AliTRDcalibDB.h
1 #ifndef ALITRDCALIBDB_H
2 #define ALITRDCALIBDB_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 ///////////////////////////////////////////////////////////////////////////////
7 //                                                                           //
8 // Class providing the calibration parameters by accessing the CDB           //
9 //                                                                           //
10 ///////////////////////////////////////////////////////////////////////////////
11
12 /* $Id$ */
13
14 #include <iostream>
15 #include "TObject.h"
16
17 #include "AliLog.h"
18 #include "AliTRDgeometry.h"
19
20 #include <AliCDBStorage.h>
21 #include <AliCDBEntry.h>
22
23 class AliTRDCalPIDLQ;
24
25 class AliTRDcalibDB : public TObject
26 {
27 public:
28   enum { kNplan = 6, kNcham = 5, kNsect = 18, kNdet = 540 };
29   
30   static AliTRDcalibDB* Instance();
31   static void Terminate();
32
33   void SetRun(Long64_t run);
34   
35   Bool_t GetChamberPos(Int_t det, Float_t* xyz);
36   Bool_t GetChamberPos(Int_t plane, Int_t chamber, Int_t sector, Float_t* xyz) { return GetChamberPos(AliTRDgeometry::GetDetector(plane, chamber, sector), xyz); }  
37   
38   Bool_t GetChamberRot(Int_t det, Float_t* xyz);
39   Bool_t GetChamberRot(Int_t plane, Int_t chamber, Int_t sector, Float_t* xyz) { return GetChamberRot(AliTRDgeometry::GetDetector(plane, chamber, sector), xyz); }  
40   
41   Bool_t GetStackPos(Int_t chamber, Int_t sector, Float_t* xyz);
42   Bool_t GetStackRot(Int_t chamber, Int_t sector, Float_t* xyz);
43    
44   Float_t GetVdrift(Int_t det, Int_t col, Int_t row);
45   Float_t GetVdrift(Int_t plane, Int_t chamber, Int_t sector, Int_t col, Int_t row) { return GetVdrift(AliTRDgeometry::GetDetector(plane, chamber, sector), col, row); }
46     
47   Float_t GetT0(Int_t det, Int_t col, Int_t row);
48   Float_t GetT0(Int_t plane, Int_t chamber, Int_t sector, Int_t col, Int_t row) { return GetT0(AliTRDgeometry::GetDetector(plane, chamber, sector), col, row); }
49   
50   Float_t GetGainFactor(Int_t det, Int_t col, Int_t row);
51   Float_t GetGainFactor(Int_t plane, Int_t chamber, Int_t sector, Int_t col, Int_t row) { return GetGainFactor(AliTRDgeometry::GetDetector(plane, chamber, sector), col, row); }
52
53   Float_t GetPRFWidth(Int_t det, Int_t col, Int_t row);
54   Float_t GetPRFWidth(Int_t plane, Int_t chamber, Int_t sector, Int_t col, Int_t row) { return GetPRFWidth(AliTRDgeometry::GetDetector(plane, chamber, sector), col, row); }
55   
56   Float_t GetSamplingFrequency(); 
57   Int_t GetNumberOfTimeBins();
58   
59   const AliTRDCalPIDLQ* GetPIDLQObject();
60   
61   //Related functions, these depend on calibration data
62   static Float_t GetOmegaTau(Float_t vdrift);
63   Int_t PadResponse(Double_t signal, Double_t dist, Int_t plane, Double_t *pad) const;
64   
65 protected:
66   // for caching see also implentation of GetCachedCDBObject in the .cxx file
67   enum { kCDBCacheSize = 8 };   // Number of cached objects
68   enum { kIDVdrift = 0, kIDT0 = 1, kIDGainFactor = 2, kIDPRFWidth = 3, kIDGlobals = 4, 
69          kIDChamber = 5, kIDStack = 6, kIDPIDLQ = 7 };    // IDs of cached objects
70   
71   const TObject* GetCachedCDBObject(Int_t id);
72   
73   void Invalidate();
74   void SamplePRF();
75   
76   AliCDBEntry* GetCDBEntry(const char* cdbPath);
77   const TObject* CacheCDBEntry(Int_t id, const char* cdbPath);
78   const TObject* CacheMergeCDBEntry(Int_t id, const char* cdbPadPath, const char* cdbChamberPath);
79   
80   static AliTRDcalibDB* fgInstance;     // Instance of this class (singleton implementation)
81   static Bool_t fgTerminated;               // Defines if this class has already been terminated and therefore does not return instances in GetInstance anymore
82
83   AliCDBStorage* fLocator;                  // Storage locator retrieved from AliCDBManager
84   
85   AliCDBEntry* fCDBEntries[kCDBCacheSize];    // Cache for CDB entries 
86   TObject* fCDBCache[kCDBCacheSize];          // Cache for calibration objects.
87       
88   Long64_t fRun;
89   
90   struct 
91   {
92     Float_t             *fPRFsmp;                             //! Sampled pad response
93     Int_t                fPRFbin;                             //  Number of bins for the PRF
94     Float_t              fPRFlo;                              //  Lower boundary of the PRF
95     Float_t              fPRFhi;                              //  Higher boundary of the PRF
96     Float_t              fPRFwid;                             //  Bin width of the sampled PRF
97     Int_t                fPRFpad;                             //  Distance to next pad in PRF
98   } fPadResponse;
99   
100 private:
101   // this is a singleton, constructor is private!  
102   AliTRDcalibDB();
103   virtual ~AliTRDcalibDB();
104
105   ClassDef(AliTRDcalibDB, 0)
106 };
107
108 #endif