8#include "GaudiKernel/ToolHandle.h"
12#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];
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;
124 ATH_MSG_DEBUG (
"======== LArCalibDigitMaker: using SC calib line map" );
135 return StatusCode::FAILURE;
138 const unsigned eventNb=(ctx.eventID().event_number())&0xffffff ;
140 ATH_MSG_DEBUG (
"======== executing event "<< eventNb <<
" ========" );
145 for (
const std::string& key :
m_keylist) {
146 ATH_MSG_DEBUG (
"Retrieving LArDigitContainer. Key= " << key );
148 StatusCode
sc =
evtStore()->retrieve(larDigitCont,key);
149 if (
sc.isFailure()) {
150 ATH_MSG_DEBUG (
"Cannot read LArDigitContainer from StoreGate! key=" << key );
153 if (larDigitCont->
empty()) {
154 ATH_MSG_DEBUG (
"LArDigitContainer with key '" << key <<
"' is empty. Ignored." );
159 auto calibDigitContainer=std::make_unique<LArCalibDigitContainer>();
161 for (
const LArDigit* digit : *larDigitCont) {
170 const std::vector<short>& samples=digit->samples();
172 const std::vector<HWIdentifier>& calibChannelIDs=clcabling->
calibSlotLine(chid);
173 if (calibChannelIDs.empty()) {
177 std::vector<HWIdentifier>::const_iterator csl_it=calibChannelIDs.begin();
180 unsigned ddac=calibParams->
DAC(eventNb,*csl_it);
182 ATH_MSG_WARNING(
"SKIP "<<chid<<
" "<<gain<<
" "<<ddac<<
" event no "<<eventNb);
186 uint16_t
delay=calibParams->
Delay(eventNb,*csl_it);
189 for(; csl_it != calibChannelIDs.end(); ++csl_it) {
190 if(calibParams->
isPulsed(eventNb,*csl_it)){
197 ATH_MSG_VERBOSE(
"HERE!! "<<chid<<
" "<<gain<<
" "<<dac<<
" "<<
delay<<
" "<<ispulsed<<
" event no "<<eventNb<<
" "<<calibChannelIDs.size()<<
" calib lines, first is "<<*csl_it);
201 calibDigitContainer->push_back(calibDigit);
205 ATH_MSG_DEBUG (
"LArCalibDigitContainer recorded to StoreGate. key=" << key );
207 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.
size_t size() const
Number of registered mappings.
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
StatusCode execute(const EventContext &ctx)
Execute method.
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.