00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CalibReadoutEvent_CalibReadoutPmtChannel_H
00016 #define CalibReadoutEvent_CalibReadoutPmtChannel_H 1
00017
00018
00019 #include "Conventions/Electronics.h"
00020 #include "GaudiKernel/boost_allocator.h"
00021 #include "GaudiKernel/SerializeSTL.h"
00022 #include <ostream>
00023
00024
00025
00026 namespace DayaBay
00027 {
00028
00029
00030 class CalibReadoutPmtCrate;
00031 using GaudiUtils::operator<<;
00032
00033
00043 class CalibReadoutPmtChannel
00044 {
00045 public:
00046
00048 CalibReadoutPmtChannel(const DayaBay::DetectorSensor& sensorId,
00049 DayaBay::CalibReadoutPmtCrate* calibReadout);
00050
00052 CalibReadoutPmtChannel() : m_calibReadout(0),
00053 m_pmtSensorId(0),
00054 m_charge(),
00055 m_time() {}
00056
00058 virtual ~CalibReadoutPmtChannel() {}
00059
00061 virtual std::ostream& fillStream(std::ostream& s) const;
00062
00064 unsigned int size() const;
00065
00067 double charge(unsigned int index) const;
00068
00070 double time(unsigned int index) const;
00071
00073 int maxChargeIndex() const;
00074
00076 double maxCharge() const;
00077
00079 double sumCharge() const;
00080
00082 int earliestTimeIndex() const;
00083
00085 double earliestTime() const;
00086
00088 double earliestCharge() const;
00089
00092 const DayaBay::CalibReadoutPmtCrate* calibReadout() const;
00093
00096 void setCalibReadout(DayaBay::CalibReadoutPmtCrate* value);
00097
00100 const DayaBay::DetectorSensor& pmtSensorId() const;
00101
00104 void setPmtSensorId(const DayaBay::DetectorSensor& value);
00105
00108 const std::vector<double>& charge() const;
00109
00112 void setCharge(const std::vector<double>& value);
00113
00116 const std::vector<double>& time() const;
00117
00120 void setTime(const std::vector<double>& value);
00121
00122
00123 #ifndef GOD_NOALLOC
00125 static void* operator new ( size_t size )
00126 {
00127 return ( sizeof(CalibReadoutPmtChannel) == size ?
00128 boost::singleton_pool<CalibReadoutPmtChannel, sizeof(CalibReadoutPmtChannel)>::malloc() :
00129 ::operator new(size) );
00130 }
00131
00135 static void* operator new ( size_t size, void* pObj )
00136 {
00137 return ::operator new (size,pObj);
00138 }
00139
00141 static void operator delete ( void* p )
00142 {
00143 boost::singleton_pool<CalibReadoutPmtChannel, sizeof(CalibReadoutPmtChannel)>::is_from(p) ?
00144 boost::singleton_pool<CalibReadoutPmtChannel, sizeof(CalibReadoutPmtChannel)>::free(p) :
00145 ::operator delete(p);
00146 }
00147
00150 static void operator delete ( void* p, void* pObj )
00151 {
00152 ::operator delete (p, pObj);
00153 }
00154 #endif
00155 protected:
00156
00157 private:
00158
00159 DayaBay::CalibReadoutPmtCrate* m_calibReadout;
00160 DayaBay::DetectorSensor m_pmtSensorId;
00161 std::vector<double> m_charge;
00162 std::vector<double> m_time;
00163
00164 };
00165
00166 inline std::ostream& operator<< (std::ostream& str, const CalibReadoutPmtChannel& obj)
00167 {
00168 return obj.fillStream(str);
00169 }
00170
00171 }
00172
00173
00174
00175
00176
00177
00178 #include "CalibReadoutPmtCrate.h"
00179
00180
00181 inline DayaBay::CalibReadoutPmtChannel::CalibReadoutPmtChannel(const DayaBay::DetectorSensor& sensorId,
00182 DayaBay::CalibReadoutPmtCrate* calibReadout)
00183 {
00184
00185 setPmtSensorId(sensorId);
00186 setCalibReadout(calibReadout);
00187
00188 }
00189
00190 inline std::ostream& DayaBay::CalibReadoutPmtChannel::fillStream(std::ostream& s) const
00191 {
00192 s << "{ " << "calibReadout : " << m_calibReadout << std::endl
00193 << "pmtSensorId : " << m_pmtSensorId << std::endl
00194 << "charge : " << m_charge << std::endl
00195 << "time : " << m_time << std::endl << " }";
00196 return s;
00197 }
00198
00199
00200 inline const DayaBay::CalibReadoutPmtCrate* DayaBay::CalibReadoutPmtChannel::calibReadout() const
00201 {
00202 return m_calibReadout;
00203 }
00204
00205 inline void DayaBay::CalibReadoutPmtChannel::setCalibReadout(DayaBay::CalibReadoutPmtCrate* value)
00206 {
00207 m_calibReadout = value;
00208 }
00209
00210 inline const DayaBay::DetectorSensor& DayaBay::CalibReadoutPmtChannel::pmtSensorId() const
00211 {
00212 return m_pmtSensorId;
00213 }
00214
00215 inline void DayaBay::CalibReadoutPmtChannel::setPmtSensorId(const DayaBay::DetectorSensor& value)
00216 {
00217 m_pmtSensorId = value;
00218 }
00219
00220 inline const std::vector<double>& DayaBay::CalibReadoutPmtChannel::charge() const
00221 {
00222 return m_charge;
00223 }
00224
00225 inline void DayaBay::CalibReadoutPmtChannel::setCharge(const std::vector<double>& value)
00226 {
00227 m_charge = value;
00228 }
00229
00230 inline const std::vector<double>& DayaBay::CalibReadoutPmtChannel::time() const
00231 {
00232 return m_time;
00233 }
00234
00235 inline void DayaBay::CalibReadoutPmtChannel::setTime(const std::vector<double>& value)
00236 {
00237 m_time = value;
00238 }
00239
00240 inline unsigned int DayaBay::CalibReadoutPmtChannel::size() const
00241 {
00242
00243 return m_time.size();
00244
00245 }
00246
00247 inline double DayaBay::CalibReadoutPmtChannel::charge(unsigned int index) const
00248 {
00249
00250 return index >= m_charge.size() ? 0 : m_charge[index];
00251
00252 }
00253
00254 inline double DayaBay::CalibReadoutPmtChannel::time(unsigned int index) const
00255 {
00256
00257 return index >= m_time.size() ? 0 : m_time[index];
00258
00259 }
00260
00261 inline int DayaBay::CalibReadoutPmtChannel::maxChargeIndex() const
00262 {
00263
00264 if( m_charge.empty() ) return 0;
00265 double maxCharge = 0;
00266 int maxChargeIndex = 0;
00267 for(unsigned i=0; i<m_charge.size(); i++) {
00268 if( m_charge[i] > maxCharge ) {
00269 maxCharge = m_charge[i];
00270 maxChargeIndex = i;
00271 }
00272 }
00273 return maxChargeIndex;
00274
00275 }
00276
00277 inline double DayaBay::CalibReadoutPmtChannel::maxCharge() const
00278 {
00279
00280 if( m_charge.empty() ) return 0;
00281 return m_charge[maxChargeIndex()];
00282
00283 }
00284
00285 inline double DayaBay::CalibReadoutPmtChannel::sumCharge() const
00286 {
00287
00288 if( m_charge.empty() ) return 0;
00289 double sumCharge = 0;
00290 for(unsigned i=0; i<m_charge.size(); i++) {
00291 sumCharge += m_charge[i];
00292 }
00293 return sumCharge;
00294
00295 }
00296
00297 inline int DayaBay::CalibReadoutPmtChannel::earliestTimeIndex() const
00298 {
00299
00300 if( m_time.empty() ) return 0;
00301 double earliestTime = 0;
00302 int earliestTimeIndex = 0;
00303 for(unsigned int i=0; i < m_time.size(); i++) {
00304 if( i == 0 || m_time[i] < earliestTime ) {
00305 earliestTime = m_time[i];
00306 earliestTimeIndex = i;
00307 }
00308 }
00309 return earliestTimeIndex;
00310
00311 }
00312
00313 inline double DayaBay::CalibReadoutPmtChannel::earliestTime() const
00314 {
00315
00316 if( m_time.empty() ) return 0;
00317 return m_time[earliestTimeIndex()];
00318
00319 }
00320
00321 inline double DayaBay::CalibReadoutPmtChannel::earliestCharge() const
00322 {
00323
00324 if( m_charge.empty() ) return 0;
00325 return m_charge[earliestTimeIndex()];
00326
00327 }
00328
00329
00330 #endif