164{
166
167
168 const LArOnlineID_Base* onlineHelper;
169
170
171
172
173
176 const LArOnline_SuperCellID*
ll;
177 sc =
detStore()->retrieve(ll,
"LArOnline_SuperCellID");
178 if (
sc.isFailure()) {
179 msg(MSG::ERROR) <<
"Could not get LArOnlineID helper !" <<
endmsg;
180 return StatusCode::FAILURE;
181 }
182 else {
183 onlineHelper =
static_cast<const LArOnlineID_Base*
>(
ll);
185 }
186 } else {
187 const LArOnlineID*
ll;
189 if (
sc.isFailure()) {
190 msg(MSG::ERROR) <<
"Could not get LArOnlineID helper !" <<
endmsg;
191 return StatusCode::FAILURE;
192 }
193 else {
194 onlineHelper =
static_cast<const LArOnlineID_Base*
>(
ll);
196 }
197 }
198
199
200
201 const LArOnOffIdMapping*
cabling(
nullptr);
205 if(!cabling) {
207 return StatusCode::FAILURE;
208 }
209 }else{
210 SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{
m_cablingKey};
212 if(!cabling) {
214 return StatusCode::FAILURE;
215 }
216 }
217
218
219
220
221
222
223
224
225
226
227
228 const ILArCaliPulseParams* prevCaliPulseParams = nullptr;
229 const ILArDetCellParams* prevDetCellParams = nullptr;
230
232
233 sc =
detStore()->retrieve(prevCaliPulseParams);
234 if (
sc.isFailure() ) {
235
242 }
243
244 ATH_MSG_INFO(
"CaliPulseParams retrieved from DetStore");
245 }
246
248
250 if (
sc.isFailure() ) {
251
258 }
259
261 }
262
263
264
265
266 std::unique_ptr<LArCaliPulseParamsComplete> newCaliPulseParams=std::make_unique<LArCaliPulseParamsComplete>() ;
267
269 if (
sc.isFailure()) {
270 ATH_MSG_ERROR(
"Failed to set groupingType for LArCaliPulseParams object" );
272 }
273 sc=newCaliPulseParams->initialize();
274 if (
sc.isFailure()) {
275 ATH_MSG_ERROR(
"Failed to initialize for LArCaliPulseParams object" );
277 }
278
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" );
284 }
285 sc=newDetCellParams->initialize();
286 if (
sc.isFailure()) {
287 ATH_MSG_ERROR(
"Failed to initialize LArDetCellParamsComplete object" );
289 }
290
291
292
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" );
300 }
301 sc=omegaScanContainer->initialize();
302 if (
sc.isFailure()) {
303 ATH_MSG_ERROR(
"Failed to initialize LArCaliWaveContainer object" );
305 }
306 }
307
308
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;
317 }
318 if(resOscillContainerBefore->initialize().isFailure()) {
319 ATH_MSG_ERROR(
"Failed to initialize LArCaliWaveContainer object" );
320 return StatusCode::FAILURE;
321 }
322
324 ATH_MSG_ERROR(
"Failed to set groupingType for LArCaliWaveContainer object" );
325 return StatusCode::FAILURE;
326 }
327 if(resOscillContainerAfter->initialize().isFailure()) {
328 ATH_MSG_ERROR(
"Failed to initialize LArCaliWaveContainer object" );
329 return StatusCode::FAILURE;
330 }
331 }
332
333
336
337
338
339
340 int nchannel = 0 ;
341
342
343
344 int NCalibParams=0;
345 int NDetParams=0;
346
347 unsigned nWaveConts=0;
348
349
350 std::vector<helperParams> inputParams;
351
352 for (
const std::string& key :
m_keylist) {
353
354
355 const LArCaliWaveContainer* caliWaveContainer;
356 sc =
detStore()->retrieve(caliWaveContainer,key);
357 if (
sc.isFailure()) {
358 ATH_MSG_INFO(
"LArCaliWaveContainer (key = " << key <<
") not found in StoreGate");
359 continue;
360 }
361 if ( caliWaveContainer == nullptr ) {
362 ATH_MSG_INFO(
"LArCaliWaveContainer (key = " << key <<
") is empty");
363 continue;
364 }
365
366 ATH_MSG_INFO(
"Processing LArCaliWaveContainer from StoreGate, key = " << key);
367 ++nWaveConts;
368
370
372 const_iterator itVec = caliWaveContainer->
begin(gain);
373 const_iterator itVec_e = caliWaveContainer->
end(gain);
374
375 if ( itVec == itVec_e ) {
376 ATH_MSG_INFO(
"LArCaliWaveContainer (key=" << key <<
") has no channels with gain = " << gain);
377 continue ;
378 }
379 ATH_MSG_INFO(
"Now processing gain = " << gain <<
" in LArCaliWaveContainer with key=" << key);
380
381 for (; itVec != itVec_e; ++itVec) {
382
383 LArCaliWaveContainer::LArCaliWaves::const_iterator cont_it = (*itVec).begin();
384 LArCaliWaveContainer::LArCaliWaves::const_iterator cont_it_e = (*itVec).end();
385
386 if ( cont_it == cont_it_e ) {
387 ATH_MSG_DEBUG(
"No DACs found for channel 0x" << MSG::hex << itVec.channelId() << MSG::dec);
388 continue ;
389 } else {
390 ATH_MSG_DEBUG( (*itVec).size() <<
" DACs found for channel 0x" << MSG::hex << itVec.channelId()<< MSG::dec);
391 }
392
393
394 if ( !
m_FT.empty() ) {
397 std::vector<int>::const_iterator selectFT = std::find(
m_FT.begin(),
m_FT.end(),FT);
399 ATH_MSG_DEBUG(
"Channel 0x" << MSG::hex << itVec.channelId() << MSG::dec
400 << " does not match FT selection (FT = " << FT << ", PosNeg = " << PosNeg
401 << "), skipping...");
402 continue;
403 } else {
404 ATH_MSG_INFO(
"Channel 0x" << MSG::hex << itVec.channelId() << MSG::dec
405 << " matches FT selection (FT = " << FT << ", PosNeg = " << PosNeg << ")");
406 }
407 }
408
409
411 int Slot = onlineHelper->
slot(itVec.channelId());
412 std::vector<int>::const_iterator selectSlot = std::find(
m_Slot.begin(),
m_Slot.end(),Slot);
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...");
416 continue;
417 } else {
418 ATH_MSG_INFO(
"Channel 0x" << MSG::hex << itVec.channelId() << MSG::dec
419 << " matches Slot selection (Slot = " << Slot << ")");
420 }
421 }
422
423 unsigned nDACproc = 0;
424
425 for (;cont_it!=cont_it_e;++cont_it) {
426
427
428
429 const LArCaliWave& larCaliWave = (*cont_it);
430 const HWIdentifier& chid = itVec.channelId() ;
431
432
433
437 << " for channel " << MSG::hex << chid << MSG::dec
438 << " in Gain = " << gain);
439 continue;
440 }
441 } else {
442 if ( nDACproc>0 )
443 continue;
444 }
445
446
449 ATH_MSG_DEBUG(
"Channel 0x" << MSG::hex << itVec.channelId() <<
451 <<
" not match group "<<
m_Cline<<
" skipping...");
452 continue;
453 }
454 }
455
456 nDACproc++;
457
458 nchannel++ ;
459 if ( nchannel < 100 || ( nchannel < 1000 && nchannel%100==0 ) || nchannel%1000==0 )
460 ATH_MSG_INFO(
"Ingesting calibration waveform number " << nchannel);
461
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 ;
468
469 ATH_MSG_VERBOSE(
"Extracting parameters for channel " << MSG::hex << chid << MSG::dec
470 <<
" in Gain = " << gain <<
" at DAC = " << larCaliWave.
getDAC());
471
476 } else {
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());
485 } else {
487 continue ;
488 }
489 }
490 }
491
496 } else {
497 wfParams.
setFstep( retrievedParam = prevCaliPulseParams->
Fstep(chid,gain) ) ;
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());
505 } else {
507 continue ;
508 }
509 }
510 }
511
516 } else {
517 wfParams.
setOmega0( retrievedParam = prevDetCellParams->
Omega0(chid,gain) ) ;
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() );
525 } else {
527 continue ;
528 }
529 }
530 }
531
536 } else {
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());
545 } else {
547 continue ;
548 }
549 }
550 }
551
556
557
558
559 }
561 ATH_MSG_INFO(
"Test mode selected, process only one channel per gain per container!" ) ;
562 break ;
563 }
564 }
565 }
566 }
567
568
571 tbb::blocked_range<size_t>
r(0,inputParams.size());
573 }
574 else {
576 std::unique_ptr<tbb::global_control> tbbgc;
577
579 tbbgc=std::make_unique<tbb::global_control>( tbb::global_control::max_allowed_parallelism,
m_nThreads);
580 }
581
583
584 tbb::parallel_for(tbb::blocked_range<size_t>(0, inputParams.size()),
Looper(&inputParams,cabling,
587
589 }
590
591
595 <<
" gain=" <<
params.gain <<
" DAC=" <<
params.caliWave->getDAC() ) ;
596 continue ;
597 }
598 const LArWFParams& wfParams=
params.wfParams;
599 const HWIdentifier& chid=
params.chid;
601 const LArCaliWave& larCaliWave=*(
params.caliWave);
602
603 ATH_MSG_VERBOSE(
"parameters extracted for channel " << MSG::hex << chid << MSG::dec
604 <<
" gain=" << gain <<
" DAC=" << larCaliWave.
getDAC() ) ;
605
606
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 ) ;
610 } else {
612 NCalibParams++;
614 newCaliPulseParams->set(chid,(
int)(gain),wfParams.
tcal(),wfParams.
fstep(),0.,0.,larCaliWave.
getIsPulsedInt() ) ;
615 } else {
616 newCaliPulseParams->set(chid,(
int)(gain),wfParams.
tcal(),wfParams.
fstep() ) ;
617 }
618 }
619
620 if ( newDetCellParams->Omega0(chid,gain) != emptyDetCell.
m_Omega0 ) {
621 ATH_MSG_WARNING(
"Already present in LArDetCellParams, don't add: channel "
622 << MSG::hex << chid << MSG::dec << " gain=" << gain ) ;
623 } else {
625 newDetCellParams->set(chid,(
int)(gain),wfParams.
omega0(),wfParams.
taur() ) ;
626 NDetParams++;
627 }
628
629
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 ) ;
635 }
636
637
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 ) ;
643 }
644
645
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 ) ;
651 }
652
653 }
654
655 if (nWaveConts==0) {
657 return StatusCode::FAILURE;
658 }
659
660
661
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 " );
669
670
671
673 const LArCaliPulseParamsComplete* paramsPtr=newCaliPulseParams.get();
675 ATH_MSG_ERROR(
"Could not record LArCaliPulseParams into det.store!" ) ;
676 return StatusCode::FAILURE ;
677 }
678
679
680 ATH_MSG_DEBUG(
"Trying to symlink ILArCaliPulseParams with LArCaliPulseParamsComplete...");
681 ILArCaliPulseParams *larCaliPulseParams = nullptr;
682 sc =
detStore()->symLink(paramsPtr,larCaliPulseParams);
683 if (
sc.isFailure()) {
684 ATH_MSG_FATAL(
"Could not symlink ILArCaliPulseParams with LArCaliPulseParamsComplete." );
685 return StatusCode::FAILURE;
686 }
687 ATH_MSG_INFO(
"ILArCaliPulseParams symlink with LArCaliPulseParamsComplete successfully");
688
689
691 const LArDetCellParamsComplete* detcellPtr=newDetCellParams.get();
693 ATH_MSG_ERROR(
"Could not record LArDetCellParams into det.store!" ) ;
694 return StatusCode::FAILURE ;
695 }
696
697
698 ATH_MSG_DEBUG(
"Trying to symlink ILArDetCellParams with LArDetCellParamsComplete...");
699 ILArDetCellParams *lArDetCellParams = nullptr;
700 sc =
detStore()->symLink(detcellPtr,lArDetCellParams);
701 if (
sc.isFailure()) {
702 ATH_MSG_FATAL(
"Could not symlink ILArDetCellParams with LArDetCellParamsComplete." );
703 return StatusCode::FAILURE;
704 }
705 ATH_MSG_INFO(
"ILArDetCellParams symlink with LArDetCellParamsComplete successfully" ) ;
706
707 if ( omegaScanContainer ) {
710 ATH_MSG_WARNING(
"Could not record omega scan container into DetStore!" ) ;
711
712 }
713 }
714
715 if ( resOscillContainerBefore ) {
718 ATH_MSG_WARNING(
"Could not record residual oscillation (before Taur extraction) container into DetStore!" ) ;
719
720 }
721 }
722
723 if ( resOscillContainerAfter ) {
726 ATH_MSG_WARNING(
"Could not record residual oscillation (after Taur extraction) container into DetStore!" ) ;
727
728 }
729 }
730
732
733return StatusCode::SUCCESS;
734}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
const ServiceHandle< StoreGateSvc > & detStore() const
virtual const float & Tcal(const HWIdentifier &id, int gain) const =0
virtual const float & Fstep(const HWIdentifier &id, int gain) const =0
virtual const float & Taur(const HWIdentifier &id, int gain) const =0
virtual const float & Omega0(const HWIdentifier &id, int gain) const =0
LArCaliWaveVec LArCaliWaves
int getIsPulsedInt() const
isPulsed value
int getDAC() const
DAC value.
ConditionsMap::const_iterator ConstConditionsMapIterator
ConstConditionsMapIterator begin(unsigned int gain) const
get iterator for all channels for a gain
ConstConditionsMapIterator end(unsigned int gain) const
end of all channels for this gain
LArCaliPulseParamsP LArCondObj
int feedthrough(const HWIdentifier id) const
Return the feedthrough of a hardware cell identifier : feedthrough = [0,31] Barrel - A/C side or H/...
int slot(const HWIdentifier id) const
Return the slot number of a hardware cell identifier: slot = [1,15] Slot-ID in top part of the crat...
int pos_neg(const HWIdentifier id) const
Return the side of a hardware cell identifier pos_neg = [0,1] positive-side or negative-side Barrel...
std::string channel_name(const HWIdentifier id) const
Return a string corresponding to a feedthrough name given an identifier.
void setTaur(double taur)
void setFstep(double fstep)
void setTcal(double tcal)
void setOmega0(double omega0)
::StatusCode StatusCode
StatusCode definition for legacy code.