ATLAS Offline Software
Loading...
Searching...
No Matches
LArRTMParamExtractor.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8
11
14
17
20
21#include "tbb/parallel_for.h"
22
23LArRTMParamExtractor::LArRTMParamExtractor (const std::string& name, ISvcLocator* pSvcLocator) :
24 AthAlgorithm(name, pSvcLocator),
25 m_groupingType("FeedThrough") // SubDetector, Single, FeedThrough
26{
27 declareProperty("KeyList" ,m_keylist);
28 declareProperty("TestMode" ,m_testmode = false);
29 declareProperty("IgnoreDACSelection", m_ignoreDACselection = true);
30 declareProperty("isSC", m_isSC = false);
31
32 m_DAC.clear();
33 int default_DAC[3] = { -1, -1, -1} ;
34 for ( unsigned i=0;i<3;i++)
35 m_DAC.push_back(default_DAC[i]);
36 declareProperty("DAC" ,m_DAC);
37
38 declareProperty("ExtractTcal" ,m_extractTcal = true) ;
39 declareProperty("ExtractFstep" ,m_extractFstep = true) ;
40 declareProperty("ExtractOmega0" ,m_extractOmega0 = true) ;
41 declareProperty("ExtractTaur" ,m_extractTaur = true) ;
46 declareProperty("RecoverEmptyDB",m_recoverEmptyDB = false);
47 declareProperty("SuffixRetrievedCaliPulse" , m_suffixRetrievedCaliPulse = "" ) ;
48 declareProperty("SuffixRetrievedDetCell" , m_suffixRetrievedDetCell = "" ) ;
49 declareProperty("SuffixExtractedCaliPulse" , m_suffixExtractedCaliPulse = "_RTM" ) ;
50 declareProperty("SuffixExtractedDetCell" , m_suffixExtractedDetCell = "_RTM" ) ;
51
52 declareProperty("DumpOmegaScan", m_dumpOmegaScan = false ) ;
53 declareProperty("OmegaScanKey", m_omegaScanKey = "OmegaScan" ) ;
54
55 declareProperty("DumpResOscill", m_dumpResOscill = false ) ;
56 declareProperty("ResOscillKeyBefore", m_resOscillKeyBefore = "ResOscillBefore" ) ;
57 declareProperty("ResOscillKeyAfter", m_resOscillKeyAfter = "ResOscillAfter" ) ;
58 declareProperty("GroupingType", m_groupingType);
59
60
61 declareProperty("FT", m_FT);
62 declareProperty("PosNeg", m_PosNeg=0);
63 declareProperty("Slot", m_Slot);
64
65 declareProperty("calibLineSelection", m_Calibselection = false);
66 declareProperty("cLineGroup", m_Cline=0);
67 declareProperty("nThreads", m_nThreads=-1,"-1: No TBB, 0: Let TBB decide, >0 number of threads");
68
69}
70
72
74 ATH_MSG_INFO( "in initialize()");
75
77 m_keyRetrievedDetCell = "LArDetCellParams" + m_suffixRetrievedDetCell ;
78
80 m_keyExtractedDetCell = "LArDetCellParams" + m_suffixExtractedDetCell ;
81
82 // output new keywords:
83 // -------------------
84 ATH_MSG_INFO( "new LArCaliPulseParams will be recorded with key=" << m_keyExtractedCaliPulse ) ;
85 ATH_MSG_INFO( " new LArDetCellParams will be recorded with key=" << m_keyExtractedDetCell ) ;
86
87 // output selected action for Tcal :
88 // ---------------------------------
90 ATH_MSG_INFO( "Tcal defaulted to " << m_defaultTcal << " ; use with CARE!" ) ;
91 } else if ( m_extractTcal ) {
92 ATH_MSG_INFO( "Tcal will be extracted" ) ;
93 } else {
94 //ATH_MSG_INFO( "Tcal will be read from DB/DetStore with key=" << m_keyRetrievedCaliPulse ) ;
95 ATH_MSG_INFO( "Tcal will be read from DB/DetStore" ) ;
96 }
97
98 // output selected action for Fstep :
99 // ---------------------------------
101 ATH_MSG_INFO( "Fstep defaulted to " << m_defaultFstep << " ; use with CARE!" ) ;
102 } else if ( m_extractFstep ) {
103 ATH_MSG_INFO( "Fstep will be extracted" ) ;
104 } else {
105 //ATH_MSG_INFO( "Fstep will be read from DB/DetStore with key=" << m_keyRetrievedCaliPulse ) ;
106 ATH_MSG_INFO( "Fstep will be read from DB/DetStore" ) ;
107 }
108
109 // output selected action for Omega0 :
110 // ---------------------------------
112 ATH_MSG_INFO( "Omega0 defaulted to " << m_defaultOmega0 << " ; use with CARE!" ) ;
113 } else if ( m_extractOmega0 ) {
114 ATH_MSG_INFO( "Omega0 will be extracted" ) ;
115 } else {
116 //ATH_MSG_INFO( "Omega0 will be read from DB/DetStore with key=" << m_keyRetrievedDetCell ) ;
117 ATH_MSG_INFO( "Omega0 will be read from DB/DetStore ") ;
118 }
119
120 // output selected action for Taur :
121 // ---------------------------------
123 ATH_MSG_INFO( "Taur defaulted to " << m_defaultTaur << " ; use with CARE!" ) ;
124 } else if ( m_extractTaur ) {
125 ATH_MSG_INFO( "Taur will be extracted" ) ;
126 } else {
127 //ATH_MSG_INFO( "Taur will be read from DB/DetStore with key=" << m_keyRetrievedDetCell ) ;
128 ATH_MSG_INFO( "Taur will be read from DB/DetStore" ) ;
129 }
130
131 // if no Omega0 extraction, dumping Omega scan and Residual oscillation doesn't make sense!
132 if ( ! m_extractOmega0 ) {
133 m_dumpOmegaScan = false ;
134 m_dumpResOscill = false ;
135 }
136
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)
140 msg() << m_FT[i] << ", ";
141 ATH_MSG_INFO( m_FT[m_FT.size()-1] << " ] at PosNeg = " << m_PosNeg );
142 }
143
144 if ( !m_Slot.empty() ) {
145 msg(MSG::INFO) << "Slot selection enabled, will only process data from Slot = [ ";
146 for(unsigned i=0; i<m_Slot.size()-1; ++i)
147 msg() << m_Slot[i] << ", ";
148 msg()<< m_Slot[m_Slot.size()-1] <<"]" << endmsg;
149 }
150
152 ATH_MSG_INFO( "Will ignore DAC selection and use first value found per channel per gain" );
153
154 ATH_CHECK( m_cablingKey.initialize() );
155 ATH_CHECK( m_cablingKeySC.initialize(m_isSC) );
156
157 // Retrieve LArWFParamTool
158 ATH_CHECK(m_larWFParamTool.retrieve());
159
160 return StatusCode::SUCCESS ;
161}
162
164{
165 ATH_MSG_INFO( "in stop()" ) ;
166
167 // get LArOnlineID helper
168 const LArOnlineID_Base* onlineHelper;
169 /*StatusCode sc = detStore()->retrieve(onlineHelper, "LArOnlineID");
170 if (sc.isFailure()) {
171 ATH_MSG_ERROR( "Could not get LArOnlineID" );
172 return sc;
173 }*/
174 StatusCode sc;
175 if ( m_isSC ) {
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);
184 ATH_MSG_DEBUG("Found the LArOnlineID helper");
185 }
186 } else { // m_isSC
187 const LArOnlineID* ll;
188 sc = detStore()->retrieve(ll, "LArOnlineID");
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);
195 ATH_MSG_DEBUG(" Found the LArOnlineID helper. ");
196 }
197 }
198
199
200
201 const LArOnOffIdMapping* cabling(nullptr);
202 if( m_isSC ){
204 cabling = {*cablingHdl};
205 if(!cabling) {
206 ATH_MSG_ERROR("Do not have mapping object " << m_cablingKeySC.key());
207 return StatusCode::FAILURE;
208 }
209 }else{
211 cabling = {*cablingHdl};
212 if(!cabling) {
213 ATH_MSG_ERROR("Do not have mapping object " << m_cablingKey.key());
214 return StatusCode::FAILURE;
215 }
216 }
217
218
219
220 // retrieve previous complete objects from DetStore, if needed
221 // -----------------------------------------------------------
222
223 // use complete objects
224 //const LArCaliPulseParamsComplete* prevCaliPulseParams ;
225 //const LArDetCellParamsComplete* prevDetCellParams ;
226
227 // use abstract interfaces
228 const ILArCaliPulseParams* prevCaliPulseParams = nullptr;
229 const ILArDetCellParams* prevDetCellParams = nullptr;
230
231 if ( ! ( m_extractTcal && m_extractFstep ) ) {
232 //sc = detStore()->retrieve(prevCaliPulseParams,m_keyRetrievedCaliPulse);
233 sc = detStore()->retrieve(prevCaliPulseParams);
234 if ( sc.isFailure() ) {
235 //ATH_MSG_ERROR( "Can't get CaliPulseParams from DetStore, key=" << m_keyRetrievedCaliPulse );
236 ATH_MSG_ERROR( "Can't get CaliPulseParams from DetStore" ) ;
237 ATH_MSG_ERROR( "(was requested for" ;
238 if ( ! m_extractTcal ) msg() << " Tcal" ;
239 if ( ! m_extractFstep ) msg() << " Fstep" ;
240 msg() << ")" ) ;
241 return sc ;
242 }
243 //ATH_MSG_INFO( "CaliPulseParams retrieved from DetStore, key=" << m_keyRetrievedCaliPulse ) ;
244 ATH_MSG_INFO( "CaliPulseParams retrieved from DetStore");
245 }
246
247 if ( ! ( m_extractOmega0 && m_extractTaur ) ) {
248 //sc = detStore()->retrieve(prevDetCellParams,m_keyRetrievedDetCell);
249 sc = detStore()->retrieve(prevDetCellParams);
250 if ( sc.isFailure() ) {
251 //ATH_MSG_ERROR( "Can't get DetCellParams from DetStore, key=" << m_keyRetrievedDetCell ) ;
252 ATH_MSG_ERROR( "Can't get DetCellParams from DetStore" ) ;
253 ATH_MSG_ERROR( "(was requested for" ;
254 if ( ! m_extractOmega0 ) msg() << " Omega0" ;
255 if ( ! m_extractTaur ) msg() << " Taur" ;
256 msg() << ")" ) ;
257 return sc ;
258 }
259 //ATH_MSG_INFO( "DetCellParams retrieved from DetStore, key=" << m_keyRetrievedDetCell ) ;
260 ATH_MSG_INFO( "DetCellParams retrieved from DetStore");
261 }
262
263
264 // create and initialize new complete objects
265 // ------------------------------------------
266 std::unique_ptr<LArCaliPulseParamsComplete> newCaliPulseParams=std::make_unique<LArCaliPulseParamsComplete>() ;
267
268 sc=newCaliPulseParams->setGroupingType(m_groupingType,msg());
269 if (sc.isFailure()) {
270 ATH_MSG_ERROR( "Failed to set groupingType for LArCaliPulseParams object" );
271 return sc;
272 }
273 sc=newCaliPulseParams->initialize();
274 if (sc.isFailure()) {
275 ATH_MSG_ERROR( "Failed to initialize for LArCaliPulseParams object" );
276 return sc;
277 }
278
279 std::unique_ptr<LArDetCellParamsComplete> newDetCellParams = std::make_unique<LArDetCellParamsComplete>();
280 sc=newDetCellParams->setGroupingType(m_groupingType,msg());
281 if (sc.isFailure()) {
282 ATH_MSG_ERROR( "Failed to set groupingType for LArDetCellParamsComplete object" );
283 return sc;
284 }
285 sc=newDetCellParams->initialize();
286 if (sc.isFailure()) {
287 ATH_MSG_ERROR( "Failed to initialize LArDetCellParamsComplete object" );
288 return sc;
289 }
290
291 // needed for omega scan dump:
292 // use LArCaliWave container to store frequency spectra
293 std::unique_ptr<LArCaliWaveContainer> omegaScanContainer;
294 if ( m_dumpOmegaScan ) {
295 omegaScanContainer = std::make_unique<LArCaliWaveContainer>();
296 sc=omegaScanContainer->setGroupingType(m_groupingType,msg());
297 if (sc.isFailure()) {
298 ATH_MSG_ERROR( "Failed to set groupingType for LArCaliWaveContainer object" );
299 return sc;
300 }
301 sc=omegaScanContainer->initialize();
302 if (sc.isFailure()) {
303 ATH_MSG_ERROR( "Failed to initialize LArCaliWaveContainer object" );
304 return sc;
305 }
306 }// end if m_dumpOmegaScan
307
308 // needed for residual oscillation dump:
309 std::unique_ptr<LArCaliWaveContainer> resOscillContainerBefore;
310 std::unique_ptr<LArCaliWaveContainer> resOscillContainerAfter;
311 if ( m_dumpResOscill ) {
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
323 if(resOscillContainerAfter->setGroupingType(m_groupingType,msg()).isFailure()) {
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 // needed for existence checks:
334 static const LArCaliPulseParamsComplete::LArCondObj emptyCaliPulse ;
335 static const LArDetCellParamsComplete::LArCondObj emptyDetCell ;
336
337 // prepare for nested loops: { containers { gains { channels { DACs } } } }
338 // ------------------------
339
340 int nchannel = 0 ;
341
342 // get the waveforms from the detector store, according to key list
343
344 int NCalibParams=0;
345 int NDetParams=0;
346
347 unsigned nWaveConts=0;
348
349 //Collect all input params into this flat vector:
350 std::vector<helperParams> inputParams;
351
352 for (const std::string& key : m_keylist) { //Loop over all containers that are to be processed
353
354 // Get current LArCaliWaveContainer
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
369 for ( unsigned gain = CaloGain::LARHIGHGAIN ; gain < CaloGain::LARNGAIN ; ++ gain ) {
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) { // loop over channels for a given gain
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 // FT selection
394 if ( !m_FT.empty() ) {
395 int PosNeg = onlineHelper->pos_neg(itVec.channelId());
396 int FT = onlineHelper->feedthrough(itVec.channelId());
397 std::vector<int>::const_iterator selectFT = std::find(m_FT.begin(),m_FT.end(),FT);
398 if ( PosNeg!=m_PosNeg || selectFT==m_FT.end() ) {
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 // Slot selection
410 if ( !m_Slot.empty() ) {
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) { // loop over DAC values for a given channel
426
427 // get current cali wave:
428 // ---------------------
429 const LArCaliWave& larCaliWave = (*cont_it);
430 const HWIdentifier& chid = itVec.channelId() ;
431
432 //if ( larCaliWave.getFlag() == LArWave::dac0 ) continue ; // skip dac0 waves
433
434 if ( !m_ignoreDACselection ) { // use jobOptions DAC selection
435 if ( larCaliWave.getDAC() != m_DAC[gain] ) {
436 ATH_MSG_VERBOSE( "Skipping DAC = " << larCaliWave.getDAC()
437 << " for channel " << MSG::hex << chid << MSG::dec
438 << " in Gain = " << gain);
439 continue;
440 }
441 } else { // DAC selection will be ignored, will be used first value (if found)
442 if ( nDACproc>0 )
443 continue;
444 }
445
446 // calibLine selection
447 if(m_Calibselection) {
448 if( !( (larCaliWave.getIsPulsedInt()>>m_Cline) & 1) ) {
449 ATH_MSG_DEBUG( "Channel 0x" << MSG::hex << itVec.channelId() <<
450 "isPulsedInt 0x"<<(larCaliWave.getIsPulsedInt()&0xF)<<MSG::dec
451 << " not match group "<<m_Cline<<" skipping...");
452 continue;
453 }
454 }//end if calibLine selection
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
473 wfParams.setTcal( m_defaultTcal ) ;
474 } else if ( m_extractTcal ) {
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 "
480 << onlineHelper->channel_name(chid)
481 << " gain=" << gain << " DAC=" << larCaliWave.getDAC());
482 if (m_recoverEmptyDB) {
484 ATH_MSG_WARNING( " -> Recovering with RTM extraction." );
485 } else {
486 ATH_MSG_WARNING( " -> Skipping cell!" );
487 continue ;
488 }
489 }
490 }
491
493 wfParams.setFstep( m_defaultFstep ) ;
494 } else if ( m_extractFstep ) {
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 "
500 << onlineHelper->channel_name(chid)
501 << " gain=" << gain << " DAC=" << larCaliWave.getDAC());
502 if (m_recoverEmptyDB) {
503 ATH_MSG_WARNING( " -> Recovering with RTM extraction." );
505 } else {
506 ATH_MSG_WARNING( " -> Skipping cell!" );
507 continue ;
508 }
509 }
510 }
511
513 wfParams.setOmega0( m_defaultOmega0 ) ;
514 } else if ( m_extractOmega0 ) {
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 "
520 << onlineHelper->channel_name(chid)
521 << " gain=" << gain << " DAC=" << larCaliWave.getDAC() );
522 if (m_recoverEmptyDB) {
523 ATH_MSG_WARNING( " -> Recovering with RTM extraction." );
525 } else {
526 ATH_MSG_WARNING( " -> Skipping cell!" );
527 continue ;
528 }
529 }
530 }
531
533 wfParams.setTaur( m_defaultTaur ) ;
534 } else if ( m_extractTaur ) {
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 "
540 << onlineHelper->channel_name(chid)
541 << " gain=" << gain << " DAC=" << larCaliWave.getDAC());
542 if (m_recoverEmptyDB) {
543 ATH_MSG_WARNING( " -> Recovering with RTM extraction." );
545 } else {
546 ATH_MSG_WARNING( " -> Skipping cell!" );
547 continue ;
548 }
549 }
550 }
551
552 ATH_MSG_VERBOSE( "Pre-setting: Tcal = " << wfParams.tcal() ) ;
553 ATH_MSG_VERBOSE( "Pre-setting: Fstep = " << wfParams.fstep() ) ;
554 ATH_MSG_VERBOSE( "Pre-setting: Omega0 = " << wfParams.omega0() ) ;
555 ATH_MSG_VERBOSE( "Pre-setting: Taur = " << wfParams.taur() ) ;
556
557 //end collection of input values. All stored in inputParams vector
558
559 }//end loop over DAC values
560 if ( m_testmode ) {
561 ATH_MSG_INFO( "Test mode selected, process only one channel per gain per container!" ) ;
562 break ;
563 }
564 }//end loop over channels
565 }//end loop over gains
566 }//end loop over input containers (SG keys)
567
568
569 if (m_nThreads == -1) { //traditional, serial processing:
570 Looper looper(&inputParams,cabling,m_larWFParamTool.operator->(),msg(),m_counter);
571 tbb::blocked_range<size_t> r(0,inputParams.size());
572 looper(r);
573 }
574 else {
576 std::unique_ptr<tbb::global_control> tbbgc;
577
578 if (m_nThreads>0) {
579 tbbgc=std::make_unique<tbb::global_control>( tbb::global_control::max_allowed_parallelism, m_nThreads);
580 }
581
582 ATH_MSG_INFO("Now calling TBB parallel_for");
583 // NOW CALL TBB PARALLEL FOR
584 tbb::parallel_for(tbb::blocked_range<size_t>(0, inputParams.size()),Looper(&inputParams,cabling,
585 m_larWFParamTool.operator->(),
586 msg(),m_counter));
587
588 ATH_MSG_INFO("Done with parallel_for");
589 }
590
591 //Loop over inputParams to collect output:
592 for (helperParams& params : inputParams) {
593 if (!params.success) { // bad parameters
594 ATH_MSG_WARNING( "Bad parameters for channel " << onlineHelper->channel_name(params.chid) << MSG::dec
595 << " gain=" << params.gain << " DAC=" << params.caliWave->getDAC() ) ;
596 continue ;
597 }
598 const LArWFParams& wfParams=params.wfParams;
599 const HWIdentifier& chid=params.chid;
600 const unsigned& gain=params.gain;
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 // fill params structures to be registered in detStore
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 {
611 ATH_MSG_VERBOSE( "add to LArCaliPulseParams..." ) ;
612 NCalibParams++;
613 if(m_Calibselection) {
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 {
624 ATH_MSG_VERBOSE( "add to LArDetCellParams..." ) ;
625 newDetCellParams->set(chid,(int)(gain),wfParams.omega0(),wfParams.taur() ) ;
626 NDetParams++;
627 }
628
629 // collect this omega scan
630 if ( omegaScanContainer ) {
631 LArCaliWaveContainer::LArCaliWaves& dacScans = omegaScanContainer->get(chid, gain);
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 // collect this residual oscillation before Taur extraction
638 if ( resOscillContainerBefore ) {
639 LArCaliWaveContainer::LArCaliWaves& dacResOsc0 = resOscillContainerBefore->get(chid, gain);
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 // collect this residual oscillation after Taur extraction
646 if ( resOscillContainerAfter ) {
647 LArCaliWaveContainer::LArCaliWaves& dacResOsc1 = resOscillContainerAfter->get(chid, gain);
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 } // end loop over input/output container
654
655 if (nWaveConts==0) {
656 ATH_MSG_ERROR( "Did not process any caliwave container!" );
657 return StatusCode::FAILURE;
658 }
659
660 //ATH_MSG_INFO( " Summary : Number of cells with a LArCaliPulseParams values computed : " << newCaliPulseParams->totalNumberOfConditions() );
661 //ATH_MSG_INFO( " Summary : Number of cells with a LArDetCellParams values computed : " << newDetCellParams->totalNumberOfConditions() );
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 // record extracted LArCaliPulseParamsComplete to detStore
672 ATH_MSG_INFO( "...recording LArCaliPulseParams into det.store, key=" << m_keyExtractedCaliPulse ) ;
673 const LArCaliPulseParamsComplete* paramsPtr=newCaliPulseParams.get(); // remember ptr for
674 if ( StatusCode::FAILURE == ( detStore()->record(std::move(newCaliPulseParams), m_keyExtractedCaliPulse ) ) ) {
675 ATH_MSG_ERROR( "Could not record LArCaliPulseParams into det.store!" ) ;
676 return StatusCode::FAILURE ;
677 }
678
679 // Symlink LArCaliPulseParamsComplete to ILArCaliPulseParams for further use
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 // record extracted LArDetCellParamsComplete to detStore
690 ATH_MSG_INFO( "...recording LArDetCellParams into det.store, key=" << m_keyExtractedDetCell) ;
691 const LArDetCellParamsComplete* detcellPtr=newDetCellParams.get();
692 if ( StatusCode::FAILURE == ( detStore()->record(std::move(newDetCellParams), m_keyExtractedDetCell ) ) ) {
693 ATH_MSG_ERROR( "Could not record LArDetCellParams into det.store!" ) ;
694 return StatusCode::FAILURE ;
695 }
696
697 // Symlink LArDetCellParamsComplete to ILArDetCellParams for further use
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 ) {
708 ATH_MSG_INFO( "Recording omega scan container into det.store, key=" << m_omegaScanKey ) ;
709 if ( StatusCode::FAILURE == ( detStore()->record(std::move(omegaScanContainer), m_omegaScanKey ) ) ) {
710 ATH_MSG_WARNING( "Could not record omega scan container into DetStore!" ) ;
711 // return StatusCode::FAILURE ;
712 }
713 }
714
715 if ( resOscillContainerBefore ) {
716 ATH_MSG_INFO( "Recording residual oscillation (before Taur extraction) container into DetStore, key = " << m_resOscillKeyBefore ) ;
717 if ( StatusCode::FAILURE == ( detStore()->record(std::move(resOscillContainerBefore), m_resOscillKeyBefore ) ) ) {
718 ATH_MSG_WARNING( "Could not record residual oscillation (before Taur extraction) container into DetStore!" ) ;
719 // return StatusCode::FAILURE ;
720 }
721 }
722
723 if ( resOscillContainerAfter ) {
724 ATH_MSG_INFO( "Recording residual oscillation (after Taur extraction) container into DetStore, key = " << m_resOscillKeyAfter ) ;
725 if ( StatusCode::FAILURE == ( detStore()->record(std::move(resOscillContainerAfter), m_resOscillKeyAfter ) ) ) {
726 ATH_MSG_WARNING( "Could not record residual oscillation (after Taur extraction) container into DetStore!" ) ;
727 // return StatusCode::FAILURE ;
728 }
729 }
730
731 ATH_MSG_INFO( "LArRTMParamExtractor finalized!" );
732
733return StatusCode::SUCCESS;
734}
735
736
737void LArRTMParamExtractor::Looper::operator() (const tbb::blocked_range<size_t>& r) const {
738
739 for (size_t i=r.begin();i!=r.end();++i) {
740 helperParams& p=m_tbbparams->at(i);
741 StatusCode sc = m_tool->getLArWaveParams(*(p.caliWave),
742 p.chid,
743 (CaloGain::CaloGain)p.gain,
744 p.wfParams,
745 m_cabling,
746 p.omegaScan,
747 p.resOscill0,
748 p.resOscill1
749 );
750
751 p.success=sc.isSuccess() ;
752
753
754 unsigned cnt=(++m_counter);
755 if (cnt % 100 == 0) {
756 m_msg << MSG::INFO << "Processing wavefrom No " << cnt << endmsg;
757 }
758
759 }
760 }
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
MsgStream & msg() 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
This class implements the ILArCaliPulseParams interface.
Liquid Argon Cumulative Wave Container.
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
This class implements the ILArDetCellParams interface.
Helper for the Liquid Argon Calorimeter cell identifiers.
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.
const LArOnOffIdMapping * m_cabling
std::atomic< unsigned > & m_counter
void operator()(const tbb::blocked_range< size_t > &r) const
std::vector< helperParams > * m_tbbparams
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
ToolHandle< LArWFParamTool > m_larWFParamTool
std::vector< int > m_DAC
std::vector< std::string > m_keylist
LArRTMParamExtractor(const std::string &name, ISvcLocator *pSvcLocator)
std::atomic< unsigned > m_counter
std::vector< int > m_Slot
std::string m_suffixExtractedCaliPulse
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKeySC
std::vector< int > m_FT
std::string m_suffixRetrievedCaliPulse
void setTaur(double taur)
double omega0() const
void setFstep(double fstep)
void setTcal(double tcal)
void setOmega0(double omega0)
double fstep() const
double tcal() const
double taur() const
int r
Definition globals.cxx:22
@ LARNGAIN
Definition CaloGain.h:19
@ LARHIGHGAIN
Definition CaloGain.h:18