00001 #ifndef __EMCCALIBRATOR_H__ 00002 #define __EMCCALIBRATOR_H__ 00003 00004 #include <cstddef> 00005 #include <iostream> 00006 #include <string> 00007 #ifndef __EMCRAWDATAOBJECT_H__ 00008 #include "emcRawDataObject.h" 00009 #endif 00010 #ifndef __EMCMANAGEABLE_H__ 00011 #include "emcManageable.h" 00012 #endif 00013 00014 class emcMixedDataObject; 00015 class emcCalibratedDataObject; 00016 class PHTimeStamp; 00017 00018 00030 class emcCalibrator 00031 { 00032 00033 public: 00034 00036 emcCalibrator() 00037 { 00038 SetHighLowLimit(); 00039 SetThresholdADC(); 00040 SetGlobalT0(); 00041 fTwrGlobalT0 = NULL; 00042 SetVerbose(); 00043 SetUseAmpPedestals(true); 00044 SetUseOnlyLowGain(false); 00045 fName = "none"; 00046 } 00047 virtual ~emcCalibrator() 00048 {} 00049 00053 virtual bool Calibrate(const emcRawDataObject& rdo, 00054 emcMixedDataObject& mdo, 00055 const PHTimeStamp& when) = 0; 00056 00060 virtual bool Calibrate(const emcMixedDataObject& mdo, 00061 emcCalibratedDataObject& cdo, 00062 const PHTimeStamp& when) = 0; 00063 00065 virtual bool Calibrate(const emcRawDataObject& rdo, 00066 emcCalibratedDataObject& cdo, 00067 const PHTimeStamp& when) = 0; 00068 00069 virtual void ForceDBCollection(const PHTimeStamp& /*when*/) 00070 { 00071 std::cerr << "emcCalibrator::ForceDBCollection : virtual function called!" 00072 << std::endl; 00073 exit(1); 00074 } 00075 00078 virtual float GetThresholdADC(void) const 00079 { 00080 return fThresholdADC; 00081 } 00082 00087 virtual float GetGlobalT0(void) const 00088 { 00089 return fGlobalT0; 00090 } 00091 00093 virtual float GetGlobalT0(int index) const 00094 { 00095 return ((fTwrGlobalT0) ? fTwrGlobalT0[index] : 0.); 00096 } 00097 00099 virtual bool GetCollectionStatus(const char* /*type*/) const 00100 { 00101 return false; 00102 } 00103 00105 virtual int GetHighLowLimit(void) const 00106 { 00107 return fHLLimit; 00108 } 00109 00113 virtual const char* GetName(void) const 00114 { 00115 return fName.c_str(); 00116 } 00117 00119 virtual int GetVerbose(void) const 00120 { 00121 return fVerbose; 00122 } 00123 00125 virtual void Print(void) const = 0; 00126 00128 virtual void printData(const emcRawDataObject& rdo, const int towerId) const =0; 00129 00131 virtual void Reset(void) = 0; 00132 00134 virtual bool SelectSource(const char* type, emcManageable::EStorage source) = 0; 00135 00138 virtual void SetExtraRejectListFilename(const char* /*filename*/ = 0) 00139 { } 00140 00142 virtual void SetSMBasedCorrectionFilename(const char* /*filename*/ = "" ) 00143 { 00144 } 00145 00147 virtual void SetGlobalT0(float T0 = 0.0) 00148 { 00149 fGlobalT0 = T0; 00150 } 00151 00154 virtual void SetTwrGlobalT0(char * filename = 0) 00155 { 00156 if (fTwrGlobalT0 || filename == 0) 00157 delete [] fTwrGlobalT0; 00158 fTwrGlobalT0 = NULL; 00159 } 00160 00162 virtual void SetThresholdADC(float thres = 10.) 00163 { 00164 fThresholdADC = thres; 00165 std::cout << "<RDC-I> ADC threshold is set to " << fThresholdADC << std::endl; 00166 } 00167 00169 virtual void SetHighLowLimit(int lim = 1024) 00170 { 00171 fHLLimit = lim; 00172 } 00173 00175 virtual void SetVerbose(int level = 0) 00176 { 00177 fVerbose = level; 00178 } 00179 00181 void SetZeroSuppression(bool swi = true) 00182 { 00183 fZeroSuppression = swi; 00184 std::cout << "<RDC-I> Zero suppression " << (fZeroSuppression ? "enabled" : "inhibited") << std::endl; 00185 } 00186 Bool_t GetZeroSuppression() {return fZeroSuppression;} 00187 00189 void SetUseAmpPedestals(Bool_t flag = false) 00190 { 00191 fUseAmpPedestals = flag; 00192 std::cout << "<RDC-I> Pedestal subtruction " << (fUseAmpPedestals ? "enabled" : "inhibited") << std::endl; 00193 } 00195 Bool_t GetUseAmpPedestals() {return fUseAmpPedestals;} 00196 void SetUseOnlyLowGain(Bool_t flag = false) 00197 { 00198 fUseOnlyLowGain = flag; 00199 std::cout << "<RDC-I> High gain data range " << ((!fUseOnlyLowGain) ? "enabled" : "inhibited") << std::endl; 00200 } 00201 Bool_t GetUseOnlyLowGain(){return fUseOnlyLowGain;} 00202 00203 protected: 00204 00206 std::string fName; 00208 Bool_t fZeroSuppression; 00210 Bool_t fUseAmpPedestals; 00212 Bool_t fUseOnlyLowGain; 00214 int fVerbose; 00215 float * fTwrGlobalT0; 00216 00217 private: 00218 00220 int fHLLimit; 00222 float fThresholdADC; 00224 float fGlobalT0; 00225 00226 }; 00227 00228 #endif // #ifndef __emcCalibrator_h__ 00229 00230