7#include "GaudiKernel/ToolHandle.h"
11#include "CLHEP/Units/SystemOfUnits.h"
51 ATH_MSG_DEBUG (
"======== LArCalibDigitMaker Initialize ========" );
53 for (
unsigned int i = 0; i <
m_keylist.size(); ++i) {
56 ATH_MSG_DEBUG (
"======== LArCalibDigitMaker isSC is True ========" );
64 std::vector<std::vector<unsigned>> theseBoardIDs;
65 std::vector<std::vector<unsigned>> thesePatterns;
66 std::vector<std::vector<unsigned>> theseDACs;
69 theseDACs.reserve(
m_vDAC.size());
71 theseBoardIDs.emplace_back(elem.begin(), elem.end());
74 thesePatterns.emplace_back(elem.begin(), elem.end());
76 for (
const auto& elem :
m_vDAC) {
77 theseDACs.emplace_back(elem.begin(), elem.end());
79 std::vector<unsigned> cutPattern;
81 auto calibParams = std::make_unique<LArCalibParams>();
83 for(
long unsigned int i=0; i < theseBoardIDs.size(); i++ ){
85 cutPattern = thesePatterns[i];
87 if (thesePatterns[i].size() != ((
unsigned int)
m_nPatterns[i])){
91 if (thesePatterns[i].size()%4) {
92 ATH_MSG_ERROR (
"Problem with jobOptions! One Pattern must conists of 4 32bit values! Pattern "<< i );
93 return StatusCode::FAILURE;
95 for (
unsigned id : theseBoardIDs[i]) {
111 ATH_MSG_DEBUG (
"======== LArCalibDigitMaker initialize successfully ========" );
112 return StatusCode::SUCCESS;
118 if (
m_dontRun)
return StatusCode::SUCCESS;
120 const EventContext& ctx = Gaudi::Hive::currentContext();
125 ATH_MSG_DEBUG (
"======== LArCalibDigitMaker: using SC calib line map" );
136 return StatusCode::FAILURE;
139 const unsigned eventNb=(ctx.eventID().event_number())&0xffffff ;
141 ATH_MSG_DEBUG (
"======== executing event "<< eventNb <<
" ========" );
146 for (
const std::string& key :
m_keylist) {
147 ATH_MSG_DEBUG (
"Retrieving LArDigitContainer. Key= " << key );
149 StatusCode
sc =
evtStore()->retrieve(larDigitCont,key);
150 if (
sc.isFailure()) {
151 ATH_MSG_DEBUG (
"Cannot read LArDigitContainer from StoreGate! key=" << key );
154 if (larDigitCont->
empty()) {
155 ATH_MSG_DEBUG (
"LArDigitContainer with key '" << key <<
"' is empty. Ignored." );
160 auto calibDigitContainer=std::make_unique<LArCalibDigitContainer>();
162 for (
const LArDigit* digit : *larDigitCont) {
171 const std::vector<short>& samples=digit->samples();
173 const std::vector<HWIdentifier>& calibChannelIDs=clcabling->
calibSlotLine(chid);
174 if (calibChannelIDs.empty()) {
178 std::vector<HWIdentifier>::const_iterator csl_it=calibChannelIDs.begin();
181 unsigned ddac=calibParams->
DAC(eventNb,*csl_it);
183 ATH_MSG_WARNING(
"SKIP "<<chid<<
" "<<gain<<
" "<<ddac<<
" event no "<<eventNb);
187 uint16_t
delay=calibParams->
Delay(eventNb,*csl_it);
190 for(; csl_it != calibChannelIDs.end(); ++csl_it) {
191 if(calibParams->
isPulsed(eventNb,*csl_it)){
198 ATH_MSG_VERBOSE(
"HERE!! "<<chid<<
" "<<gain<<
" "<<dac<<
" "<<
delay<<
" "<<ispulsed<<
" event no "<<eventNb<<
" "<<calibChannelIDs.size()<<
" calib lines, first is "<<*csl_it);
202 calibDigitContainer->push_back(calibDigit);
206 ATH_MSG_DEBUG (
"LArCalibDigitContainer recorded to StoreGate. key=" << key );
208 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
double delay(std::size_t d)
#define kmaxDAC
This class contains the LAr Calibration Board settings and a set of functions to decoded them.
static const Attributes_t empty
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
const ServiceHandle< StoreGateSvc > & detStore() const
bool empty() const noexcept
Returns true if the collection is empty.
std::vector< unsigned > m_vDelay
std::vector< std::vector< double > > m_vDAC
std::vector< std::vector< double > > m_vPattern
std::vector< int > m_nPatterns
SG::ReadCondHandleKey< LArCalibLineMapping > m_calibMapKey
std::vector< HWIdentifier > m_pulsedChids
LArCalibDigitMaker(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< std::string > m_keylist
SG::ReadCondHandleKey< LArCalibLineMapping > m_calibMapSCKey
std::vector< std::vector< double > > m_vBoardIDs
Base class for LArDigits taken during calibration runs.
const std::vector< HWIdentifier > & calibSlotLine(const HWIdentifier id) const
unsigned Delay(const unsigned event, const HWIdentifier calibLineID) const
bool isPulsed(const unsigned event, const HWIdentifier calibLineID) const
unsigned DAC(const unsigned event, const HWIdentifier calibLineID) const
Container class for LArDigit.
Liquid Argon digit base class.