7 #include "GaudiKernel/Bootstrap.h"
8 #include "GaudiKernel/MsgStream.h"
9 #include "GaudiKernel/ToolHandle.h"
18 using WaveMap = std::map<int, LArCaliWave>;
22 m_onlineHelper(nullptr),
40 return StatusCode::FAILURE;
45 return StatusCode::FAILURE;
50 return StatusCode::FAILURE;
64 return StatusCode::FAILURE;
67 return StatusCode::SUCCESS;
72 return StatusCode::SUCCESS;
81 if (! theLArCaliWaveContainer ) {
83 return StatusCode::FAILURE;
87 auto larCaliWaveContainerCorr = std::make_unique<LArCaliWaveContainer>();
89 ATH_CHECK( larCaliWaveContainerCorr->initialize() );
92 auto larCaliWaveContainerSymm = std::make_unique<LArCaliWaveContainer>();
95 if (larCaliWaveContainerSymm->initialize()) {
96 ATH_MSG_ERROR (
"Failed to initialize LArCaliWaveContainer object" );
97 return StatusCode::FAILURE;
104 return StatusCode::FAILURE;
113 if ( theSymmetricChannels.empty()) {
114 ATH_MSG_WARNING (
"No symmetric channels found for channel 0x" << MSG::hex << chid << MSG::dec <<
". Cannot average." );
118 ATH_MSG_INFO ( theSymmetricChannels.size() <<
" symmetric channels indentified for channel 0x" << MSG::hex << chid << MSG::dec );
126 if ( theCaliWaves.empty() ){
127 ATH_MSG_WARNING (
"No pulses found for channel 0x" << MSG::hex << chid << MSG::dec
128 <<
" in gain " <<
gain
129 <<
". Are you sure that readout is working? For the time being I'm skipping..." );
137 for (
unsigned iDAC=0;iDAC<theCaliWaves.size();++iDAC) {
139 int theDAC = theCaliWaves[iDAC].getDAC();
143 for (
unsigned iSym=0;iSym<theSymmetricChannels.size();++iSym) {
147 for (
unsigned kDAC=0;kDAC<theseCaliWaves.size();++kDAC) {
148 if ( theseCaliWaves[kDAC].getDAC() == theDAC ) {
154 theSymmetricWavesThisDAC.push_back(thisWave);
160 if ( !theSymmetricWavesThisDAC.empty() ) {
163 <<
" symmetric LArCaliWaves found for channel 0x" << MSG::hex << chid << MSG::dec
164 <<
" for DAC " << theDAC <<
" in gain " <<
gain
165 <<
". Now averaging ... " );
172 theAverageWaves.push_back(theAverageWave);
176 for (
unsigned kSym=0;kSym<theSymmetricWavesThisDAC.size();++kSym) {
177 theSymmetricWavesAll.push_back(theSymmetricWavesThisDAC[kSym]);
182 ATH_MSG_WARNING (
"No symmetrich waves found for channel 0x" << MSG::hex << chid << MSG::dec
183 <<
" for DAC " << theDAC <<
": no average will be computed." );
189 ATH_MSG_VERBOSE (
"Saving LArCaliWave vector to correction container." );
190 larCaliWaveContainerCorr->setPdata(chid,theAverageWaves,
gain);
193 ATH_MSG_VERBOSE (
"Saving LArCaliWave vector to symmetric waves' container (flag contains FT info)" );
194 larCaliWaveContainerSymm->setPdata(chid,theSymmetricWavesAll,
gain);
202 const EventIDBase
start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
203 const EventIDBase
stop{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
206 const EventIDRange& crangeW(rangeW);
207 if(corrHdl.
record(crangeW,larCaliWaveContainerCorr.release()).isFailure()) {
209 <<
" with EventRange " << crangeW <<
" into Conditions Store");
210 return StatusCode::FAILURE;
214 if(symHdl.
record(crangeW,larCaliWaveContainerSymm.release()).isFailure()) {
216 <<
" with EventRange " << crangeW <<
" into Conditions Store");
217 return StatusCode::FAILURE;
220 return StatusCode::SUCCESS;
229 ATH_MSG_VERBOSE (
"Seeking symmetric cells for channel 0x" << MSG::hex << ChID << MSG::dec );
231 std::vector<HWIdentifier> theSymmetricChannels;
232 theSymmetricChannels.resize(0);
236 id =
cabling->cnvToIdentifier(ChID);
238 ATH_MSG_ERROR (
"LArCabling exception caught for channel 0x" << MSG::hex << ChID << MSG::dec );
239 return theSymmetricChannels;
303 ATH_MSG_ERROR (
"Sorry, still implemented for EM only :-(" );
304 return theSymmetricChannels;
309 for (
unsigned iFT = 0;iFT<nFT;++iFT) {
312 bool useThisChannel =
true;
316 for (
unsigned i=0;
i<ChannelsNotToUse.size();++
i) {
318 useThisChannel =
false;
323 if ( useThisChannel )
324 theSymmetricChannels.push_back(thisChID);
327 return theSymmetricChannels;
333 if ( !ToBeAveraged.empty() ) {
338 for (
unsigned i=1;
i<ToBeAveraged.size();++
i) {
340 theWaveAverage = theWaveAverage + (
LArWave)ToBeAveraged[
i];
343 theWaveAverage = theWaveAverage * (1./
float(ToBeAveraged.size()));
346 ToBeAveraged[0].getErrors(),
347 ToBeAveraged[0].getTriggers(),
348 ToBeAveraged[0].getDt(),
349 ToBeAveraged[0].getDAC(),
350 ToBeAveraged[0].getIsPulsedInt(),
351 ToBeAveraged[0].getFlag() );
353 return theCaliWaveAverage;