00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef ReadoutEvent_ReadoutPmtChannel_H
00016 #define ReadoutEvent_ReadoutPmtChannel_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 ReadoutPmtCrate;
00031 using GaudiUtils::operator<<;
00032
00033
00043 class ReadoutPmtChannel
00044 {
00045 public:
00046
00048 ReadoutPmtChannel(const DayaBay::FeeChannelId& channelId,
00049 DayaBay::ReadoutPmtCrate* readout);
00050
00052 ReadoutPmtChannel() : m_readout(0),
00053 m_mode(0x0),
00054 m_channelId(0),
00055 m_adc(),
00056 m_pedestal(),
00057 m_adcRange(),
00058 m_adcCycle(),
00059 m_tdc(),
00060 m_tdcHitCount(),
00061 m_waveAdcHigh(),
00062 m_waveAdcLow(),
00063 m_waveAdcCycle() {}
00064
00066 virtual ~ReadoutPmtChannel() {}
00067
00069 virtual std::ostream& fillStream(std::ostream& s) const;
00070
00072 unsigned int size() const;
00073
00075 int peakAdc(unsigned int index) const;
00076
00078 int peakAdcRange(unsigned int index) const;
00079
00081 int peakAdcCycle(unsigned int index) const;
00082
00084 int adc(unsigned int index) const;
00085
00087 int adcRange(unsigned int index) const;
00088
00090 int adcCycle(unsigned int index) const;
00091
00093 int pedestal(unsigned int index) const;
00094
00096 int tdc(unsigned int index) const;
00097
00099 int tdcHitCount(unsigned int index) const;
00100
00102 int maxAdcIndex() const;
00103
00105 int maxAdc() const;
00106
00108 int sumAdc() const;
00109
00111 int earliestTdcIndex() const;
00112
00114 int earliestTdc() const;
00115
00117 int earliestAdc() const;
00118
00120 unsigned int waveSize() const;
00121
00123 int waveAdcCycle(unsigned int index) const;
00124
00126 int waveAdcHigh(unsigned int index) const;
00127
00129 int waveAdcLow(unsigned int index) const;
00130
00133 const DayaBay::ReadoutPmtCrate* readout() const;
00134
00137 void setReadout(DayaBay::ReadoutPmtCrate* value);
00138
00141 int mode() const;
00142
00145 void setMode(int value);
00146
00149 const DayaBay::FeeChannelId& channelId() const;
00150
00153 void setChannelId(const DayaBay::FeeChannelId& value);
00154
00157 const std::vector<int>& adc() const;
00158
00161 std::vector<int>& adc();
00162
00165 void setAdc(const std::vector<int>& value);
00166
00169 const std::vector<int>& pedestal() const;
00170
00173 std::vector<int>& pedestal();
00174
00177 void setPedestal(const std::vector<int>& value);
00178
00181 const std::vector<int>& adcRange() const;
00182
00185 std::vector<int>& adcRange();
00186
00189 void setAdcRange(const std::vector<int>& value);
00190
00193 const std::vector<int>& adcCycle() const;
00194
00197 std::vector<int>& adcCycle();
00198
00201 void setAdcCycle(const std::vector<int>& value);
00202
00205 const std::vector<int>& tdc() const;
00206
00209 std::vector<int>& tdc();
00210
00213 void setTdc(const std::vector<int>& value);
00214
00217 const std::vector<int>& tdcHitCount() const;
00218
00221 std::vector<int>& tdcHitCount();
00222
00225 void setTdcHitCount(const std::vector<int>& value);
00226
00229 const std::vector<int>& waveAdcHigh() const;
00230
00233 void setWaveAdcHigh(const std::vector<int>& value);
00234
00237 const std::vector<int>& waveAdcLow() const;
00238
00241 void setWaveAdcLow(const std::vector<int>& value);
00242
00245 const std::vector<int>& waveAdcCycle() const;
00246
00249 void setWaveAdcCycle(const std::vector<int>& value);
00250
00251
00252 #ifndef GOD_NOALLOC
00254 static void* operator new ( size_t size )
00255 {
00256 return ( sizeof(ReadoutPmtChannel) == size ?
00257 boost::singleton_pool<ReadoutPmtChannel, sizeof(ReadoutPmtChannel)>::malloc() :
00258 ::operator new(size) );
00259 }
00260
00264 static void* operator new ( size_t size, void* pObj )
00265 {
00266 return ::operator new (size,pObj);
00267 }
00268
00270 static void operator delete ( void* p )
00271 {
00272 boost::singleton_pool<ReadoutPmtChannel, sizeof(ReadoutPmtChannel)>::is_from(p) ?
00273 boost::singleton_pool<ReadoutPmtChannel, sizeof(ReadoutPmtChannel)>::free(p) :
00274 ::operator delete(p);
00275 }
00276
00279 static void operator delete ( void* p, void* pObj )
00280 {
00281 ::operator delete (p, pObj);
00282 }
00283 #endif
00284 protected:
00285
00286 private:
00287
00288 DayaBay::ReadoutPmtCrate* m_readout;
00289 int m_mode;
00290 DayaBay::FeeChannelId m_channelId;
00291 std::vector<int> m_adc;
00292 std::vector<int> m_pedestal;
00293 std::vector<int> m_adcRange;
00294 std::vector<int> m_adcCycle;
00295 std::vector<int> m_tdc;
00296 std::vector<int> m_tdcHitCount;
00297 std::vector<int> m_waveAdcHigh;
00298 std::vector<int> m_waveAdcLow;
00299 std::vector<int> m_waveAdcCycle;
00300
00301 };
00302
00303 inline std::ostream& operator<< (std::ostream& str, const ReadoutPmtChannel& obj)
00304 {
00305 return obj.fillStream(str);
00306 }
00307
00308 }
00309
00310
00311
00312
00313
00314
00315 #include "ReadoutPmtCrate.h"
00316
00317
00318 inline DayaBay::ReadoutPmtChannel::ReadoutPmtChannel(const DayaBay::FeeChannelId& channelId,
00319 DayaBay::ReadoutPmtCrate* readout)
00320 {
00321
00322 setChannelId(channelId);
00323 setReadout(readout);
00324
00325 }
00326
00327 inline std::ostream& DayaBay::ReadoutPmtChannel::fillStream(std::ostream& s) const
00328 {
00329 s << "{ " << "readout : " << m_readout << std::endl
00330 << "mode : " << m_mode << std::endl
00331 << "channelId : " << m_channelId << std::endl
00332 << "adc : " << m_adc << std::endl
00333 << "pedestal : " << m_pedestal << std::endl
00334 << "adcRange : " << m_adcRange << std::endl
00335 << "adcCycle : " << m_adcCycle << std::endl
00336 << "tdc : " << m_tdc << std::endl
00337 << "tdcHitCount : " << m_tdcHitCount << std::endl
00338 << "waveAdcHigh : " << m_waveAdcHigh << std::endl
00339 << "waveAdcLow : " << m_waveAdcLow << std::endl
00340 << "waveAdcCycle : " << m_waveAdcCycle << std::endl << " }";
00341 return s;
00342 }
00343
00344
00345 inline const DayaBay::ReadoutPmtCrate* DayaBay::ReadoutPmtChannel::readout() const
00346 {
00347 return m_readout;
00348 }
00349
00350 inline void DayaBay::ReadoutPmtChannel::setReadout(DayaBay::ReadoutPmtCrate* value)
00351 {
00352 m_readout = value;
00353 }
00354
00355 inline int DayaBay::ReadoutPmtChannel::mode() const
00356 {
00357 return m_mode;
00358 }
00359
00360 inline void DayaBay::ReadoutPmtChannel::setMode(int value)
00361 {
00362 m_mode = value;
00363 }
00364
00365 inline const DayaBay::FeeChannelId& DayaBay::ReadoutPmtChannel::channelId() const
00366 {
00367 return m_channelId;
00368 }
00369
00370 inline void DayaBay::ReadoutPmtChannel::setChannelId(const DayaBay::FeeChannelId& value)
00371 {
00372 m_channelId = value;
00373 }
00374
00375 inline const std::vector<int>& DayaBay::ReadoutPmtChannel::adc() const
00376 {
00377 return m_adc;
00378 }
00379
00380 inline std::vector<int>& DayaBay::ReadoutPmtChannel::adc()
00381 {
00382 return m_adc;
00383 }
00384
00385 inline void DayaBay::ReadoutPmtChannel::setAdc(const std::vector<int>& value)
00386 {
00387 m_adc = value;
00388 }
00389
00390 inline const std::vector<int>& DayaBay::ReadoutPmtChannel::pedestal() const
00391 {
00392 return m_pedestal;
00393 }
00394
00395 inline std::vector<int>& DayaBay::ReadoutPmtChannel::pedestal()
00396 {
00397 return m_pedestal;
00398 }
00399
00400 inline void DayaBay::ReadoutPmtChannel::setPedestal(const std::vector<int>& value)
00401 {
00402 m_pedestal = value;
00403 }
00404
00405 inline const std::vector<int>& DayaBay::ReadoutPmtChannel::adcRange() const
00406 {
00407 return m_adcRange;
00408 }
00409
00410 inline std::vector<int>& DayaBay::ReadoutPmtChannel::adcRange()
00411 {
00412 return m_adcRange;
00413 }
00414
00415 inline void DayaBay::ReadoutPmtChannel::setAdcRange(const std::vector<int>& value)
00416 {
00417 m_adcRange = value;
00418 }
00419
00420 inline const std::vector<int>& DayaBay::ReadoutPmtChannel::adcCycle() const
00421 {
00422 return m_adcCycle;
00423 }
00424
00425 inline std::vector<int>& DayaBay::ReadoutPmtChannel::adcCycle()
00426 {
00427 return m_adcCycle;
00428 }
00429
00430 inline void DayaBay::ReadoutPmtChannel::setAdcCycle(const std::vector<int>& value)
00431 {
00432 m_adcCycle = value;
00433 }
00434
00435 inline const std::vector<int>& DayaBay::ReadoutPmtChannel::tdc() const
00436 {
00437 return m_tdc;
00438 }
00439
00440 inline std::vector<int>& DayaBay::ReadoutPmtChannel::tdc()
00441 {
00442 return m_tdc;
00443 }
00444
00445 inline void DayaBay::ReadoutPmtChannel::setTdc(const std::vector<int>& value)
00446 {
00447 m_tdc = value;
00448 }
00449
00450 inline const std::vector<int>& DayaBay::ReadoutPmtChannel::tdcHitCount() const
00451 {
00452 return m_tdcHitCount;
00453 }
00454
00455 inline std::vector<int>& DayaBay::ReadoutPmtChannel::tdcHitCount()
00456 {
00457 return m_tdcHitCount;
00458 }
00459
00460 inline void DayaBay::ReadoutPmtChannel::setTdcHitCount(const std::vector<int>& value)
00461 {
00462 m_tdcHitCount = value;
00463 }
00464
00465 inline const std::vector<int>& DayaBay::ReadoutPmtChannel::waveAdcHigh() const
00466 {
00467 return m_waveAdcHigh;
00468 }
00469
00470 inline void DayaBay::ReadoutPmtChannel::setWaveAdcHigh(const std::vector<int>& value)
00471 {
00472 m_waveAdcHigh = value;
00473 }
00474
00475 inline const std::vector<int>& DayaBay::ReadoutPmtChannel::waveAdcLow() const
00476 {
00477 return m_waveAdcLow;
00478 }
00479
00480 inline void DayaBay::ReadoutPmtChannel::setWaveAdcLow(const std::vector<int>& value)
00481 {
00482 m_waveAdcLow = value;
00483 }
00484
00485 inline const std::vector<int>& DayaBay::ReadoutPmtChannel::waveAdcCycle() const
00486 {
00487 return m_waveAdcCycle;
00488 }
00489
00490 inline void DayaBay::ReadoutPmtChannel::setWaveAdcCycle(const std::vector<int>& value)
00491 {
00492 m_waveAdcCycle = value;
00493 }
00494
00495 inline unsigned int DayaBay::ReadoutPmtChannel::size() const
00496 {
00497
00498 return m_tdc.size();
00499
00500 }
00501
00502 inline int DayaBay::ReadoutPmtChannel::peakAdc(unsigned int index) const
00503 {
00504
00505 return index >= m_adc.size() ? 0 : m_adc[index];
00506
00507 }
00508
00509 inline int DayaBay::ReadoutPmtChannel::peakAdcRange(unsigned int index) const
00510 {
00511
00512 return index >= m_adcRange.size() ? 0 : m_adcRange[index];
00513
00514 }
00515
00516 inline int DayaBay::ReadoutPmtChannel::peakAdcCycle(unsigned int index) const
00517 {
00518
00519 return index >= m_adcCycle.size() ? 0 : m_adcCycle[index];
00520
00521 }
00522
00523 inline int DayaBay::ReadoutPmtChannel::adc(unsigned int index) const
00524 {
00525
00526 return peakAdc(index);
00527
00528 }
00529
00530 inline int DayaBay::ReadoutPmtChannel::adcRange(unsigned int index) const
00531 {
00532
00533 return peakAdcRange(index);
00534
00535 }
00536
00537 inline int DayaBay::ReadoutPmtChannel::adcCycle(unsigned int index) const
00538 {
00539
00540 return peakAdcCycle(index);
00541
00542 }
00543
00544 inline int DayaBay::ReadoutPmtChannel::pedestal(unsigned int index) const
00545 {
00546
00547 return index >= m_pedestal.size() ? 0 : m_pedestal[index];
00548
00549 }
00550
00551 inline int DayaBay::ReadoutPmtChannel::tdc(unsigned int index) const
00552 {
00553
00554 return index >= m_tdc.size() ? 0 : m_tdc[index];
00555
00556 }
00557
00558 inline int DayaBay::ReadoutPmtChannel::tdcHitCount(unsigned int index) const
00559 {
00560
00561 return index >= m_tdcHitCount.size() ? 0 : m_tdcHitCount[index];
00562
00563 }
00564
00565 inline int DayaBay::ReadoutPmtChannel::maxAdcIndex() const
00566 {
00567
00568 if( m_adc.empty() ) return 0;
00569 int maxAdcIndex = 0;
00570 int maxAdc = 0;
00571 for(unsigned i=0; i<m_adc.size(); i++) {
00572 if( m_adc[i] > maxAdc ) {
00573 maxAdc = m_adc[i];
00574 maxAdcIndex = i;
00575 }
00576 }
00577 return maxAdcIndex;
00578
00579 }
00580
00581 inline int DayaBay::ReadoutPmtChannel::maxAdc() const
00582 {
00583
00584 if( m_adc.empty() ) return 0;
00585 return m_adc[maxAdcIndex()];
00586
00587 }
00588
00589 inline int DayaBay::ReadoutPmtChannel::sumAdc() const
00590 {
00591
00592 if( m_adc.empty() ) return 0;
00593 int sumAdc = 0;
00594 for(unsigned i=0; i<m_adc.size(); i++) {
00595 sumAdc += m_adc[i];
00596 }
00597 return sumAdc;
00598
00599 }
00600
00601 inline int DayaBay::ReadoutPmtChannel::earliestTdcIndex() const
00602 {
00603
00604 if( m_tdc.empty() ) return 0;
00605 int earliestTdc = 0;
00606 int earliestTdcIndex = 0;
00607 for(unsigned int i=0; i < m_tdc.size(); i++) {
00608 if( i == 0 || m_tdc[i] > earliestTdc ) {
00609 earliestTdc = m_tdc[i];
00610 earliestTdcIndex = i;
00611 }
00612 }
00613 return earliestTdcIndex;
00614
00615 }
00616
00617 inline int DayaBay::ReadoutPmtChannel::earliestTdc() const
00618 {
00619
00620 if( m_tdc.empty() ) return 0;
00621 return m_tdc[earliestTdcIndex()];
00622
00623 }
00624
00625 inline int DayaBay::ReadoutPmtChannel::earliestAdc() const
00626 {
00627
00628 if( m_adc.empty() ) return 0;
00629 return m_adc[earliestTdcIndex()];
00630
00631 }
00632
00633 inline unsigned int DayaBay::ReadoutPmtChannel::waveSize() const
00634 {
00635
00636 return m_waveAdcCycle.size();
00637
00638 }
00639
00640 inline int DayaBay::ReadoutPmtChannel::waveAdcCycle(unsigned int index) const
00641 {
00642
00643 return index >= m_waveAdcCycle.size() ? 0 : m_waveAdcCycle[index];
00644
00645 }
00646
00647 inline int DayaBay::ReadoutPmtChannel::waveAdcHigh(unsigned int index) const
00648 {
00649
00650 return index >= m_waveAdcHigh.size() ? 0 : m_waveAdcHigh[index];
00651
00652 }
00653
00654 inline int DayaBay::ReadoutPmtChannel::waveAdcLow(unsigned int index) const
00655 {
00656
00657 return index >= m_waveAdcLow.size() ? 0 : m_waveAdcLow[index];
00658
00659 }
00660
00661
00662 #endif