ROOT logo
#ifndef ALITRDCALIBDB_H
#define ALITRDCALIBDB_H
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

///////////////////////////////////////////////////////////////////////////////
//                                                                           //
// Class providing the calibration parameters by accessing the CDB           //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////

/* $Id$ */

#ifndef ROOT_TObject
#include "TObject.h"
#endif

#ifndef ALITRDPIDUTIL_H
#include "AliTRDpidUtil.h"
#endif

#ifndef ALITRDPIDRESPONSE_H
#include "AliTRDPIDResponse.h"
#endif

#include "AliTRDCalTrapConfig.h"
#include "AliTRDtrapConfig.h"

class TString;

class AliCDBEntry;

class AliTRDrecoParam;
class AliTRDCalTrkAttach;
class AliTRDCalPID;
class AliTRDCalMonitoring;
class AliTRDCalROC;
class AliTRDCalDet;
class AliTRDCalSingleChamberStatus;
class AliTRDCalOnlineGainTableROC;

class AliTRDcalibDB : public TObject {

 public:

  enum { kNlayer  =   6
       , kNstack  =   5
       , kNsector =  18
       , kNdet    = 540 };
  
  enum { kFltrSet = 1
       , kReadout
       , kTimebin
       , kTrkMode
       , kTrigSet
       , kAddOpti };

  static AliTRDcalibDB               *Instance();
  static void                         Terminate();
  void                                SetRun(Long64_t run);
  Long64_t                            GetRun() const { return fRun; }

  Float_t                             GetNoise(Int_t det, Int_t col, Int_t row);
        AliTRDCalROC                 *GetNoiseROC(Int_t det);
  const AliTRDCalDet                 *GetNoiseDet();

  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();
  TObjArray                          *GetPHQ();
  const AliTRDCalDet                 *GetExBDet();

  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();

  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();

  Float_t                             GetOnlineGainFactor(Int_t det, Int_t col, Int_t row);
  AliTRDCalOnlineGainTableROC        *GetOnlineGainTableROC(Int_t det);

  AliTRDCalROC                       *GetPRFROC(Int_t det);
  Float_t                             GetPRFWidth(Int_t det, Int_t col, Int_t row);

  Float_t*                            GetSampledPRF() const { return fPRFsmp; };
  Int_t                               GetPRFbin() const     { return fPRFbin; };
  Float_t                             GetPRFlo() const      { return fPRFlo;  };
  Float_t                             GetPRFhi() const      { return fPRFhi;  };

  Int_t                               ExtractTimeBinsFromString(TString tbstr);
  Int_t                               GetNumberOfTimeBinsDCS();
  void                                GetFilterType(TString &filterType);
  void                                GetGlobalConfiguration(TString &config);
  void                                GetGlobalConfigurationByChamber(TString &config,Int_t par, Int_t opt=0);
  void                                GetGlobalConfigurationVersion(TString &version);
  Int_t                               GetNumberOfParsDCS(TString cname, Char_t delimiter='_');
  Int_t                               GetNumberOfOptsDCS(TString cname, Int_t cfgType);
  void                                GetDCSConfigParOption(TString cname, Int_t cfgType, Int_t option, TString &cfgo);

  Int_t                               GetOnlineGainTableID();

  Bool_t                              HasOnlineFilterPedestal();
  Bool_t                              HasOnlineFilterGain();
  Bool_t                              HasOnlineTailCancellation();

  Char_t                              GetPadStatus(Int_t det, Int_t col, Int_t row);
  AliTRDCalSingleChamberStatus       *GetPadStatusROC(Int_t det);
  AliTRDrecoParam*                    GetRecoParam(Int_t *eventtype);
  AliTRDPIDResponse                  *GetPIDResponse(AliTRDPIDResponse::ETRDPIDMethod m);

  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);
  
  Bool_t                              IsChamberGood(Int_t det);
  Bool_t                              IsChamberNoData(Int_t det);
  Bool_t                              IsHalfChamberNoData(Int_t det, Int_t side);
  Bool_t                              IsChamberBadCalibrated(Int_t det);
  Bool_t                              IsChamberNotCalibrated(Int_t det);

  const AliTRDCalMonitoring          *GetMonitoringObject();
  const AliTRDCalPID                 *GetPIDObject(AliTRDpidUtil::ETRDPIDMethod m);
  const AliTRDCalTrkAttach           *GetAttachObject();

  // Related functions, these depend on calibration data
  Int_t                               PadResponse(Double_t signal, Double_t dist
                                                , Int_t layer, Double_t *pad) const;

  AliTRDtrapConfig*                   GetTrapConfig();
  void                                GetTrapConfig(TString &name, TString &version) { name = fTrapConfigName; version = fTrapConfigVersion; }
  void                                SetTrapConfig(const TString name, const TString version) { fTrapConfigName = name; fTrapConfigVersion = version; }
  void                                SetTrapConfig(AliTRDtrapConfig *trapcfg) { fTrapConfig = trapcfg; }
  void                                Invalidate();

 protected:

  AliTRDtrapConfig*                   LoadTrapConfig(const TString &name = "", const TString &version = "");
  Int_t                               GetNumberOfTimeBinsDCSBoard(); // Old method as fallback for patched OCDB 
  virtual                            ~AliTRDcalibDB();
  // For caching see also implentation of GetCachedCDBObject in the .cxx file
  enum { kIDVdriftPad = 0
       , kIDVdriftChamber
       , kIDExBChamber
       , kIDT0Pad
       , kIDT0Chamber
       , kIDGainFactorPad
       , kIDGainFactorChamber
       , kIDOnlineGainFactor
       , kIDNoiseChamber
       , kIDNoisePad
       , kIDPRFWidth
       , kIDFEE
       , kIDTrapConfig
       , kIDChamberPos
       , kIDStackPos
       , kIDSuperModulePos
       , kIDPIDNN
       , kIDPIDLQ
       , kIDPIDLQ1D
       , kIDRecoParam
       , kIDMonitoringData
       , kIDChamberStatus
       , kIDPadStatus
       , kIDDCS
       , kIDAttach
       , kIDPHQ
       , kCDBCacheSize };         // IDs of cached objects

  const TObject *GetCachedCDBObject(Int_t id);
  
  void           SamplePRF();
  
  AliCDBEntry   *GetCDBEntry(const Char_t *cdbPath);
  const TObject *CacheCDBEntry(Int_t id, const Char_t *cdbPath);

  static AliTRDcalibDB *fgInstance;                 //  Instance of this class (singleton implementation)
  static Bool_t         fgTerminated;               //  Defines if this class has already been terminated

  AliCDBEntry          *fCDBEntries[kCDBCacheSize]; //  Cache for CDB entries
  TObject              *fCDBCache[kCDBCacheSize];   //  Cache for calibration objects.

  Long64_t              fRun;                       //  Run Number

  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

  AliTRDPIDResponse    *fPIDResponse;               //  TRD PID Response function

  Int_t                 fOnlineGainTableID;         //  ID for online gain table 

  AliTRDtrapConfig*     fTrapConfig;                //  TRAP configuration
  TString               fTrapConfigName;            //  name of the TRAPconfig
  TString               fTrapConfigVersion;         //  version of the TRAPconfig
  
 private:

  AliTRDcalibDB();                                  //  This is a singleton, constructor is private!  
  AliTRDcalibDB(const AliTRDcalibDB &c);   
  AliTRDcalibDB &operator=(const AliTRDcalibDB &c); 

  ClassDef(AliTRDcalibDB, 8)                        //  Provides central access to the CDB

};

#endif

 AliTRDcalibDB.h:1
 AliTRDcalibDB.h:2
 AliTRDcalibDB.h:3
 AliTRDcalibDB.h:4
 AliTRDcalibDB.h:5
 AliTRDcalibDB.h:6
 AliTRDcalibDB.h:7
 AliTRDcalibDB.h:8
 AliTRDcalibDB.h:9
 AliTRDcalibDB.h:10
 AliTRDcalibDB.h:11
 AliTRDcalibDB.h:12
 AliTRDcalibDB.h:13
 AliTRDcalibDB.h:14
 AliTRDcalibDB.h:15
 AliTRDcalibDB.h:16
 AliTRDcalibDB.h:17
 AliTRDcalibDB.h:18
 AliTRDcalibDB.h:19
 AliTRDcalibDB.h:20
 AliTRDcalibDB.h:21
 AliTRDcalibDB.h:22
 AliTRDcalibDB.h:23
 AliTRDcalibDB.h:24
 AliTRDcalibDB.h:25
 AliTRDcalibDB.h:26
 AliTRDcalibDB.h:27
 AliTRDcalibDB.h:28
 AliTRDcalibDB.h:29
 AliTRDcalibDB.h:30
 AliTRDcalibDB.h:31
 AliTRDcalibDB.h:32
 AliTRDcalibDB.h:33
 AliTRDcalibDB.h:34
 AliTRDcalibDB.h:35
 AliTRDcalibDB.h:36
 AliTRDcalibDB.h:37
 AliTRDcalibDB.h:38
 AliTRDcalibDB.h:39
 AliTRDcalibDB.h:40
 AliTRDcalibDB.h:41
 AliTRDcalibDB.h:42
 AliTRDcalibDB.h:43
 AliTRDcalibDB.h:44
 AliTRDcalibDB.h:45
 AliTRDcalibDB.h:46
 AliTRDcalibDB.h:47
 AliTRDcalibDB.h:48
 AliTRDcalibDB.h:49
 AliTRDcalibDB.h:50
 AliTRDcalibDB.h:51
 AliTRDcalibDB.h:52
 AliTRDcalibDB.h:53
 AliTRDcalibDB.h:54
 AliTRDcalibDB.h:55
 AliTRDcalibDB.h:56
 AliTRDcalibDB.h:57
 AliTRDcalibDB.h:58
 AliTRDcalibDB.h:59
 AliTRDcalibDB.h:60
 AliTRDcalibDB.h:61
 AliTRDcalibDB.h:62
 AliTRDcalibDB.h:63
 AliTRDcalibDB.h:64
 AliTRDcalibDB.h:65
 AliTRDcalibDB.h:66
 AliTRDcalibDB.h:67
 AliTRDcalibDB.h:68
 AliTRDcalibDB.h:69
 AliTRDcalibDB.h:70
 AliTRDcalibDB.h:71
 AliTRDcalibDB.h:72
 AliTRDcalibDB.h:73
 AliTRDcalibDB.h:74
 AliTRDcalibDB.h:75
 AliTRDcalibDB.h:76
 AliTRDcalibDB.h:77
 AliTRDcalibDB.h:78
 AliTRDcalibDB.h:79
 AliTRDcalibDB.h:80
 AliTRDcalibDB.h:81
 AliTRDcalibDB.h:82
 AliTRDcalibDB.h:83
 AliTRDcalibDB.h:84
 AliTRDcalibDB.h:85
 AliTRDcalibDB.h:86
 AliTRDcalibDB.h:87
 AliTRDcalibDB.h:88
 AliTRDcalibDB.h:89
 AliTRDcalibDB.h:90
 AliTRDcalibDB.h:91
 AliTRDcalibDB.h:92
 AliTRDcalibDB.h:93
 AliTRDcalibDB.h:94
 AliTRDcalibDB.h:95
 AliTRDcalibDB.h:96
 AliTRDcalibDB.h:97
 AliTRDcalibDB.h:98
 AliTRDcalibDB.h:99
 AliTRDcalibDB.h:100
 AliTRDcalibDB.h:101
 AliTRDcalibDB.h:102
 AliTRDcalibDB.h:103
 AliTRDcalibDB.h:104
 AliTRDcalibDB.h:105
 AliTRDcalibDB.h:106
 AliTRDcalibDB.h:107
 AliTRDcalibDB.h:108
 AliTRDcalibDB.h:109
 AliTRDcalibDB.h:110
 AliTRDcalibDB.h:111
 AliTRDcalibDB.h:112
 AliTRDcalibDB.h:113
 AliTRDcalibDB.h:114
 AliTRDcalibDB.h:115
 AliTRDcalibDB.h:116
 AliTRDcalibDB.h:117
 AliTRDcalibDB.h:118
 AliTRDcalibDB.h:119
 AliTRDcalibDB.h:120
 AliTRDcalibDB.h:121
 AliTRDcalibDB.h:122
 AliTRDcalibDB.h:123
 AliTRDcalibDB.h:124
 AliTRDcalibDB.h:125
 AliTRDcalibDB.h:126
 AliTRDcalibDB.h:127
 AliTRDcalibDB.h:128
 AliTRDcalibDB.h:129
 AliTRDcalibDB.h:130
 AliTRDcalibDB.h:131
 AliTRDcalibDB.h:132
 AliTRDcalibDB.h:133
 AliTRDcalibDB.h:134
 AliTRDcalibDB.h:135
 AliTRDcalibDB.h:136
 AliTRDcalibDB.h:137
 AliTRDcalibDB.h:138
 AliTRDcalibDB.h:139
 AliTRDcalibDB.h:140
 AliTRDcalibDB.h:141
 AliTRDcalibDB.h:142
 AliTRDcalibDB.h:143
 AliTRDcalibDB.h:144
 AliTRDcalibDB.h:145
 AliTRDcalibDB.h:146
 AliTRDcalibDB.h:147
 AliTRDcalibDB.h:148
 AliTRDcalibDB.h:149
 AliTRDcalibDB.h:150
 AliTRDcalibDB.h:151
 AliTRDcalibDB.h:152
 AliTRDcalibDB.h:153
 AliTRDcalibDB.h:154
 AliTRDcalibDB.h:155
 AliTRDcalibDB.h:156
 AliTRDcalibDB.h:157
 AliTRDcalibDB.h:158
 AliTRDcalibDB.h:159
 AliTRDcalibDB.h:160
 AliTRDcalibDB.h:161
 AliTRDcalibDB.h:162
 AliTRDcalibDB.h:163
 AliTRDcalibDB.h:164
 AliTRDcalibDB.h:165
 AliTRDcalibDB.h:166
 AliTRDcalibDB.h:167
 AliTRDcalibDB.h:168
 AliTRDcalibDB.h:169
 AliTRDcalibDB.h:170
 AliTRDcalibDB.h:171
 AliTRDcalibDB.h:172
 AliTRDcalibDB.h:173
 AliTRDcalibDB.h:174
 AliTRDcalibDB.h:175
 AliTRDcalibDB.h:176
 AliTRDcalibDB.h:177
 AliTRDcalibDB.h:178
 AliTRDcalibDB.h:179
 AliTRDcalibDB.h:180
 AliTRDcalibDB.h:181
 AliTRDcalibDB.h:182
 AliTRDcalibDB.h:183
 AliTRDcalibDB.h:184
 AliTRDcalibDB.h:185
 AliTRDcalibDB.h:186
 AliTRDcalibDB.h:187
 AliTRDcalibDB.h:188
 AliTRDcalibDB.h:189
 AliTRDcalibDB.h:190
 AliTRDcalibDB.h:191
 AliTRDcalibDB.h:192
 AliTRDcalibDB.h:193
 AliTRDcalibDB.h:194
 AliTRDcalibDB.h:195
 AliTRDcalibDB.h:196
 AliTRDcalibDB.h:197
 AliTRDcalibDB.h:198
 AliTRDcalibDB.h:199
 AliTRDcalibDB.h:200
 AliTRDcalibDB.h:201
 AliTRDcalibDB.h:202
 AliTRDcalibDB.h:203
 AliTRDcalibDB.h:204
 AliTRDcalibDB.h:205
 AliTRDcalibDB.h:206
 AliTRDcalibDB.h:207
 AliTRDcalibDB.h:208
 AliTRDcalibDB.h:209
 AliTRDcalibDB.h:210
 AliTRDcalibDB.h:211
 AliTRDcalibDB.h:212
 AliTRDcalibDB.h:213
 AliTRDcalibDB.h:214
 AliTRDcalibDB.h:215
 AliTRDcalibDB.h:216
 AliTRDcalibDB.h:217
 AliTRDcalibDB.h:218