21 #include "tbb/parallel_for.h"
25 m_groupingType(
"FeedThrough")
33 int default_DAC[3] = { -1, -1, -1} ;
34 for (
unsigned i=0;
i<3;
i++)
35 m_DAC.push_back(default_DAC[
i]);
117 ATH_MSG_INFO(
"Omega0 will be read from DB/DetStore ") ;
137 if ( !
m_FT.empty() ) {
138 msg(MSG::INFO) <<
"FT selection enabled, will only process data from FT = [ ";
139 for(
unsigned i=0;
i<
m_FT.size()-1; ++
i)
145 msg(MSG::INFO) <<
"Slot selection enabled, will only process data from Slot = [ ";
146 for(
unsigned i=0;
i<
m_Slot.size()-1; ++
i)
152 ATH_MSG_INFO(
"Will ignore DAC selection and use first value found per channel per gain" );
160 return StatusCode::SUCCESS ;
178 if (
sc.isFailure()) {
179 msg(MSG::ERROR) <<
"Could not get LArOnlineID helper !" <<
endmsg;
180 return StatusCode::FAILURE;
189 if (
sc.isFailure()) {
190 msg(MSG::ERROR) <<
"Could not get LArOnlineID helper !" <<
endmsg;
191 return StatusCode::FAILURE;
207 return StatusCode::FAILURE;
214 return StatusCode::FAILURE;
233 sc =
detStore()->retrieve(prevCaliPulseParams);
234 if (
sc.isFailure() ) {
244 ATH_MSG_INFO(
"CaliPulseParams retrieved from DetStore");
250 if (
sc.isFailure() ) {
266 std::unique_ptr<LArCaliPulseParamsComplete> newCaliPulseParams=std::make_unique<LArCaliPulseParamsComplete>() ;
269 if (
sc.isFailure()) {
270 ATH_MSG_ERROR(
"Failed to set groupingType for LArCaliPulseParams object" );
274 if (
sc.isFailure()) {
275 ATH_MSG_ERROR(
"Failed to initialize for LArCaliPulseParams object" );
279 std::unique_ptr<LArDetCellParamsComplete> newDetCellParams = std::make_unique<LArDetCellParamsComplete>();
281 if (
sc.isFailure()) {
282 ATH_MSG_ERROR(
"Failed to set groupingType for LArDetCellParamsComplete object" );
286 if (
sc.isFailure()) {
287 ATH_MSG_ERROR(
"Failed to initialize LArDetCellParamsComplete object" );
293 std::unique_ptr<LArCaliWaveContainer> omegaScanContainer;
295 omegaScanContainer = std::make_unique<LArCaliWaveContainer>();
297 if (
sc.isFailure()) {
298 ATH_MSG_ERROR(
"Failed to set groupingType for LArCaliWaveContainer object" );
302 if (
sc.isFailure()) {
303 ATH_MSG_ERROR(
"Failed to initialize LArCaliWaveContainer object" );
309 std::unique_ptr<LArCaliWaveContainer> resOscillContainerBefore;
310 std::unique_ptr<LArCaliWaveContainer> resOscillContainerAfter;
312 resOscillContainerBefore = std::make_unique<LArCaliWaveContainer>();
313 resOscillContainerAfter = std::make_unique<LArCaliWaveContainer>();
314 if(resOscillContainerBefore->setGroupingType(
m_groupingType,
msg()).isFailure()) {
315 ATH_MSG_ERROR(
"Failed to set groupingType for LArCaliWaveContainer object" );
316 return StatusCode::FAILURE;
318 if(resOscillContainerBefore->
initialize().isFailure()) {
319 ATH_MSG_ERROR(
"Failed to initialize LArCaliWaveContainer object" );
320 return StatusCode::FAILURE;
324 ATH_MSG_ERROR(
"Failed to set groupingType for LArCaliWaveContainer object" );
325 return StatusCode::FAILURE;
327 if(resOscillContainerAfter->
initialize().isFailure()) {
328 ATH_MSG_ERROR(
"Failed to initialize LArCaliWaveContainer object" );
329 return StatusCode::FAILURE;
347 unsigned nWaveConts=0;
350 std::vector<helperParams> inputParams;
357 if (
sc.isFailure()) {
358 ATH_MSG_INFO(
"LArCaliWaveContainer (key = " <<
key <<
") not found in StoreGate");
361 if ( caliWaveContainer ==
nullptr ) {
366 ATH_MSG_INFO(
"Processing LArCaliWaveContainer from StoreGate, key = " <<
key);
372 const_iterator itVec = caliWaveContainer->
begin(
gain);
373 const_iterator itVec_e = caliWaveContainer->
end(
gain);
375 if ( itVec == itVec_e ) {
376 ATH_MSG_INFO(
"LArCaliWaveContainer (key=" <<
key <<
") has no channels with gain = " <<
gain);
379 ATH_MSG_INFO(
"Now processing gain = " <<
gain <<
" in LArCaliWaveContainer with key=" <<
key);
381 for (; itVec != itVec_e; ++itVec) {
383 LArCaliWaveContainer::LArCaliWaves::const_iterator cont_it = (*itVec).begin();
384 LArCaliWaveContainer::LArCaliWaves::const_iterator cont_it_e = (*itVec).end();
386 if ( cont_it == cont_it_e ) {
387 ATH_MSG_DEBUG(
"No DACs found for channel 0x" << MSG::hex << itVec.channelId() << MSG::dec);
390 ATH_MSG_DEBUG( (*itVec).size() <<
" DACs found for channel 0x" << MSG::hex << itVec.channelId()<< MSG::dec);
394 if ( !
m_FT.empty() ) {
399 ATH_MSG_DEBUG(
"Channel 0x" << MSG::hex << itVec.channelId() << MSG::dec
400 <<
" does not match FT selection (FT = " <<
FT <<
", PosNeg = " <<
PosNeg
401 <<
"), skipping...");
404 ATH_MSG_INFO(
"Channel 0x" << MSG::hex << itVec.channelId() << MSG::dec
405 <<
" matches FT selection (FT = " <<
FT <<
", PosNeg = " <<
PosNeg <<
")");
411 int Slot = onlineHelper->
slot(itVec.channelId());
413 if ( selectSlot==
m_Slot.end() ) {
414 ATH_MSG_DEBUG(
"Channel 0x" << MSG::hex << itVec.channelId() << MSG::dec
415 <<
" does not match Slot selection (Slot = " << Slot <<
"), skipping...");
418 ATH_MSG_INFO(
"Channel 0x" << MSG::hex << itVec.channelId() << MSG::dec
419 <<
" matches Slot selection (Slot = " << Slot <<
")");
423 unsigned nDACproc = 0;
425 for (;cont_it!=cont_it_e;++cont_it) {
437 <<
" for channel " << MSG::hex << chid << MSG::dec
438 <<
" in Gain = " <<
gain);
449 ATH_MSG_DEBUG(
"Channel 0x" << MSG::hex << itVec.channelId() <<
451 <<
" not match group "<<
m_Cline<<
" skipping...");
459 if ( nchannel < 100 || ( nchannel < 1000 && nchannel%100==0 ) || nchannel%1000==0 )
460 ATH_MSG_INFO(
"Ingesting calibration waveform number " << nchannel);
462 inputParams.emplace_back(&larCaliWave,chid,
gain);
463 if ( omegaScanContainer ) inputParams.back().omegaScan.emplace();
464 if ( resOscillContainerBefore ) inputParams.back().resOscill0.emplace();
465 if ( resOscillContainerAfter ) inputParams.back().resOscill1.emplace();
466 LArWFParams& wfParams=inputParams.back().wfParams ;
467 float retrievedParam ;
469 ATH_MSG_VERBOSE(
"Extracting parameters for channel " << MSG::hex << chid << MSG::dec
470 <<
" in Gain = " <<
gain <<
" at DAC = " << larCaliWave.
getDAC());
477 wfParams.
setTcal( retrievedParam = prevCaliPulseParams->
Tcal(chid,
gain) ) ;
478 if ( retrievedParam == emptyCaliPulse.
m_Tcal ) {
479 ATH_MSG_WARNING(
"Parameters Tcal requested from DB but not found for channel "
481 <<
" gain=" <<
gain <<
" DAC=" << larCaliWave.
getDAC());
498 if ( retrievedParam == emptyCaliPulse.
m_Fstep ) {
499 ATH_MSG_WARNING(
"Parameters Fstep requested from DB but not found for channel "
501 <<
" gain=" <<
gain <<
" DAC=" << larCaliWave.
getDAC());
518 if ( retrievedParam == emptyDetCell.
m_Omega0 ) {
519 ATH_MSG_WARNING(
"Parameters Omega0 requested from DB but not found for channel "
521 <<
" gain=" <<
gain <<
" DAC=" << larCaliWave.
getDAC() );
537 wfParams.
setTaur( retrievedParam = prevDetCellParams->
Taur(chid,
gain) ) ;
538 if ( retrievedParam == emptyDetCell.
m_Taur ) {
539 ATH_MSG_WARNING(
"Parameters Taur requested from DB but not found for channel "
541 <<
" gain=" <<
gain <<
" DAC=" << larCaliWave.
getDAC());
561 ATH_MSG_INFO(
"Test mode selected, process only one channel per gain per container!" ) ;
571 tbb::blocked_range<size_t>
r(0,inputParams.size());
576 std::unique_ptr<tbb::global_control> tbbgc;
579 tbbgc=std::make_unique<tbb::global_control>( tbb::global_control::max_allowed_parallelism,
m_nThreads);
584 tbb::parallel_for(tbb::blocked_range<size_t>(0, inputParams.size()),
Looper(&inputParams,
cabling,
595 <<
" gain=" <<
params.gain <<
" DAC=" <<
params.caliWave->getDAC() ) ;
603 ATH_MSG_VERBOSE(
"parameters extracted for channel " << MSG::hex << chid << MSG::dec
604 <<
" gain=" <<
gain <<
" DAC=" << larCaliWave.
getDAC() ) ;
607 if ( newCaliPulseParams->
Tcal(chid,
gain) != emptyCaliPulse.
m_Tcal ) {
608 ATH_MSG_WARNING(
"Already present in LArCaliPulseParams, don't add: channel "
609 << MSG::hex << chid << MSG::dec <<
" gain=" <<
gain ) ;
616 newCaliPulseParams->
set(chid,(
int)(
gain),wfParams.
tcal(),wfParams.
fstep() ) ;
621 ATH_MSG_WARNING(
"Already present in LArDetCellParams, don't add: channel "
622 << MSG::hex << chid << MSG::dec <<
" gain=" <<
gain ) ;
630 if ( omegaScanContainer ) {
632 dacScans.push_back( *
params.omegaScan);
633 ATH_MSG_VERBOSE(
"omega scan added to container, channel=" << MSG::hex << chid << MSG::dec
634 <<
" gain=" <<
gain ) ;
638 if ( resOscillContainerBefore ) {
640 dacResOsc0.push_back( *
params.resOscill0) ;
641 ATH_MSG_VERBOSE(
"residual oscillation before Taur extraction added to container, channel=" << MSG::hex << chid << MSG::dec
642 <<
" gain=" <<
gain ) ;
646 if ( resOscillContainerAfter ) {
648 dacResOsc1.push_back( *
params.resOscill1 ) ;
649 ATH_MSG_VERBOSE(
"residual oscillation after Taur extraction added to container, channel=" << MSG::hex << chid << MSG::dec
650 <<
" gain=" <<
gain ) ;
657 return StatusCode::FAILURE;
662 ATH_MSG_INFO(
" Summary : Number of cells with a LArCaliPulseParams values computed : " << NCalibParams );
663 ATH_MSG_INFO(
" Summary : Number of cells with a LArDetCellParams values computed : " << NDetParams );
664 ATH_MSG_INFO(
" Summary : Number of Barrel PS cells side A or C (connected+unconnected): 3904+ 192 = 4096 " );
665 ATH_MSG_INFO(
" Summary : Number of Barrel cells side A or C (connected+unconnected): 50944+2304 = 53248 " );
666 ATH_MSG_INFO(
" Summary : Number of EMEC cells side A or C (connected+unconnected): 31872+3456 = 35328 " );
667 ATH_MSG_INFO(
" Summary : Number of HEC cells side A or C (connected+unconnected): 2816+ 256 = 3072 " );
668 ATH_MSG_INFO(
" Summary : Number of FCAL cells side A or C (connected+unconnected): 1762+ 30 = 1792 " );
675 ATH_MSG_ERROR(
"Could not record LArCaliPulseParams into det.store!" ) ;
676 return StatusCode::FAILURE ;
680 ATH_MSG_DEBUG(
"Trying to symlink ILArCaliPulseParams with LArCaliPulseParamsComplete...");
682 sc =
detStore()->symLink(paramsPtr,larCaliPulseParams);
683 if (
sc.isFailure()) {
684 ATH_MSG_FATAL(
"Could not symlink ILArCaliPulseParams with LArCaliPulseParamsComplete." );
685 return StatusCode::FAILURE;
687 ATH_MSG_INFO(
"ILArCaliPulseParams symlink with LArCaliPulseParamsComplete successfully");
693 ATH_MSG_ERROR(
"Could not record LArDetCellParams into det.store!" ) ;
694 return StatusCode::FAILURE ;
698 ATH_MSG_DEBUG(
"Trying to symlink ILArDetCellParams with LArDetCellParamsComplete...");
700 sc =
detStore()->symLink(detcellPtr,lArDetCellParams);
701 if (
sc.isFailure()) {
702 ATH_MSG_FATAL(
"Could not symlink ILArDetCellParams with LArDetCellParamsComplete." );
703 return StatusCode::FAILURE;
705 ATH_MSG_INFO(
"ILArDetCellParams symlink with LArDetCellParamsComplete successfully" ) ;
707 if ( omegaScanContainer ) {
710 ATH_MSG_WARNING(
"Could not record omega scan container into DetStore!" ) ;
715 if ( resOscillContainerBefore ) {
718 ATH_MSG_WARNING(
"Could not record residual oscillation (before Taur extraction) container into DetStore!" ) ;
723 if ( resOscillContainerAfter ) {
726 ATH_MSG_WARNING(
"Could not record residual oscillation (after Taur extraction) container into DetStore!" ) ;
733 return StatusCode::SUCCESS;
739 for (
size_t i=
r.begin();
i!=
r.end();++
i) {
751 p.success=
sc.isSuccess() ;
755 if (
cnt % 100 == 0) {