00001 /* 00002 * PmtCalibLeadingEdge.h 00003 * 00004 * Generate calibration fit parameters from PMT data 00005 * 00006 * This method uses the leading edge of the signals on each channel 00007 * to determine timing offsets. 00008 * 00009 * dandwyer@caltech.edu 2009/01/08 00010 * 00011 * 00012 ******************************************************************************** 00013 * 00014 * PmtCalibLeadingEdgeWithCuts.h 00015 * 00016 * calibrate the pmt gain, time offset and mianly the PMT relative efficiency 00017 * with some ADC and TDC cuts 00018 * after the firstly PmtCalibLeadingEdge calibration 00019 * 00020 * added by wangzhm@ihep.ac.cn 2009/11/28 00021 */ 00022 00023 #ifndef PMTCALIBLEADINGEDGEWITHCUTS_H 00024 #define PMTCALIBLEADINGEDGEWITHCUTS_H 00025 00026 #include "CalibParam/IPmtCalibParamTool.h" 00027 #include "GaudiAlg/GaudiTool.h" 00028 #include "Conventions/Electronics.h" 00029 #include "Conventions/Detectors.h" 00030 #include "Context/Context.h" 00031 #include <string> 00032 #include <vector> 00033 00034 namespace DayaBay{ 00035 class ReadoutHeader; 00036 } 00037 00038 class IStatisticsSvc; 00039 class ICableSvc; 00040 class ICalibDataSvc; 00041 00042 /* 00043 // Statistics container class for one PMT channel 00044 class PmtStatsOneChannelLE { 00045 public: 00046 PmtStatsOneChannelLE(const DayaBay::FeeChannelId& channelId) 00047 { m_channelId = channelId; m_nHits = 0; m_tdcRaw=0; m_tdcByMedian=0; 00048 m_adcRaw=0; m_adc=0; m_adcByClock=0;} 00049 ~PmtStatsOneChannelLE(){;} 00050 public: 00051 DayaBay::FeeChannelId m_channelId; 00052 DayaBay::AdPmtSensor m_pmtId; 00053 int m_nHits; 00054 TH1F* m_tdcRaw; 00055 TH1F* m_tdcByMedian; 00056 TH1F* m_adcRaw; 00057 TH1F* m_adc; 00058 TH1F* m_adcByClock; 00059 }; 00060 00061 // Statistics container class for one detector 00062 class PmtStatsLE { 00063 public: 00064 PmtStatsLE(const DayaBay::Detector& detector){m_detector=detector; 00065 m_nReadouts=0;} 00066 ~PmtStatsLE(){;} 00067 public: 00068 DayaBay::Detector m_detector; 00069 std::map<DayaBay::FeeChannelId,PmtStatsOneChannelLE*> m_channel; 00070 int m_nReadouts; 00071 TH1F* m_adcSum; 00072 TH1F* m_tdcMedian; 00073 std::map<int, TH1F*> m_occupancy; 00074 std::map<int, TH1F*> m_tdcOffset; 00075 std::map<int, TH1F*> m_adcMedian; 00076 std::map<int, TH1F*> m_adcSigma; 00077 }; 00078 */ 00079 00080 class PmtCalibLeadingEdgeWithCuts : public GaudiTool, virtual public IPmtCalibParamTool 00081 { 00082 public: 00083 PmtCalibLeadingEdgeWithCuts(const std::string& type, 00084 const std::string& name, 00085 const IInterface* parent); 00086 00087 virtual ~PmtCalibLeadingEdgeWithCuts(); 00088 00089 virtual StatusCode initialize(); 00090 virtual StatusCode finalize(); 00091 00093 00096 virtual StatusCode process(const DayaBay::ReadoutHeader& readout); 00097 00101 virtual StatusCode calibrate(); 00102 00103 private: 00105 bool hasStats(const DayaBay::Detector& detector); 00107 StatusCode prepareStats(const Context& context); 00108 00109 // Format path to detector statistics 00110 std::string getPath(const DayaBay::Detector& detector); 00111 // Format path to detector, ring statistics 00112 std::string getPath(const DayaBay::Detector& detector, int ring); 00113 // Format path to channel statistics 00114 std::string getPath(const DayaBay::FeeChannelId& channelId); 00115 00122 virtual StatusCode calibrateRaw(); 00123 00124 00125 private: 00126 00127 // Property CableSvcName - Name of the cable service 00128 std::string m_cableSvcName; 00129 00130 // Property CalibSvcName - Name of the calibration service 00131 std::string m_calibSvcName; 00132 00133 // Property FilePath - File path of registered histograms 00134 std::string m_filepath; 00135 00136 // CableSvc 00137 ICableSvc *m_cableSvc; 00138 00139 // CalibSvc 00140 ICalibDataSvc *m_calibSvc; 00141 00142 // IStatisticsSvc 00143 IStatisticsSvc *m_statsSvc; 00144 00145 // Cached list of processed detectors 00146 std::vector<DayaBay::Detector> m_processedDetectors; 00147 00148 00149 // added for buffer the first events of total run 00150 // to avoid to access the TES again after scan of all events 00151 // wangzhm@ihep.ac.cn 2009/11/29 00152 #define max_PMT_number 300 00153 #define max_event_number 1000 00154 #define max_FEE_hit 10 00155 00156 int adc_buffer[max_PMT_number][max_event_number][max_FEE_hit]; //max_PMT_number<=300; max_event_number<=2000; max_FEE_hit<=10; 00157 int tdc_buffer[max_PMT_number][max_event_number][max_FEE_hit]; //max_PMT_number<=300; max_event_number<=2000; max_FEE_hit<=10; 00158 int adc_clock_buffer[max_PMT_number][max_event_number][max_FEE_hit]; //max_PMT_number<=300; max_event_number<=2000; max_FEE_hit<=10; 00159 double adc_baseline_buffer[max_PMT_number][max_event_number]; //max_PMT_number<=300; max_event_number<=2000; max_FEE_hit<=10; 00160 00161 // the ADC cut for each channel 00162 // in ratio to single PE 00163 // which should can be input from the run job 00164 // -1 means no limitation 00165 // wangzhm@ihep.ac.cn 2009/11/28 00166 double m_ADC_Cut_Min; //default is 0.25 (0.25PE) 00167 double m_ADC_Cut_Max; //default is -1 (no limitation) 00168 00169 00170 //used for each channel 00171 std::map<int,double> m_ADC_Cut_Min_Channel; 00172 std::map<int,double> m_ADC_Cut_Max_Channel; 00173 00174 // the TDC cut for each channel TDC mean 00175 // in relative to the mean 00176 // which should can be input from the run job 00177 // -1 means no limitation 00178 // wangzhm@ihep.ac.cn 2009/11/28 00179 double m_TDC_Cut_Min; //default is 15ns 00180 double m_TDC_Cut_Max; //default is 15ns 00181 00182 //used for each channel 00183 std::map<int,double> m_TDC_Cut_Min_Channel; 00184 std::map<int,double> m_TDC_Cut_Max_Channel; 00185 00186 00187 }; 00188 00189 #endif // PMTCALIBLEADINGEDGEWITHCUTS_H