ATLAS Offline Software
Loading...
Searching...
No Matches
LArParams2Ntuple.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8using namespace LArParamsProperties ;
9
11
12LArParams2Ntuple::LArParams2Ntuple(const std::string& name, ISvcLocator* pSvcLocator)
13 : LArCond2NtupleBase(name, pSvcLocator),
15 m_completeTdrift(nullptr), m_completeMphysOverMcal(nullptr), m_completeRinj(nullptr), m_completeTshaper(nullptr),
18 m_completeOFCBin(nullptr)
19{
20 //declareProperty("DumpAllOnlineChannels",m_dumpAllOnlineChannels=std::string("")) ;
21 declareProperty("DetStoreSuffix",m_suffix=std::string("")) ;
22 declareProperty("AllChannels2Ntuple",m_allChannels2Ntuple=false) ;
23 declareProperty("UseAbstractInterface",m_useAbstractInterface=false) ;
24 declareProperty("NtupleName",m_ntName="PARAMS");
25 m_keylist.clear() ;
26 declareProperty("KeyList",m_keylist);
27 m_detStoreJo.clear();
28 declareProperty("DBKeysList",m_detStoreJo);
29
31
32 // set default keywords for detector store retrieval
33
35 for ( unsigned i=0 ; i<m_nClasses ; i++ )
37
38}
39
41= default;
42
44
46 m_ntpath=std::string("/NTUPLES/FILE1/")+m_ntName;
47
48 if ( m_classNames.size() != m_nClasses ) { // should never happen! but just to be sure...
49 ATH_MSG_FATAL( "List of class names does not match foreseen number of classes, cannot go on!" ) ;
50 return StatusCode::FAILURE ;
51 }
52 for ( unsigned i=0 ; i<m_keylist.size() ; i++ ) {
53 ATH_MSG_DEBUG("examinimg key " << m_keylist[i] << "...");
55 ATH_MSG_DEBUG("... class index " << idx);
56 if ( idx >= m_nClasses ) {
57 ATH_MSG_DEBUG("key " << m_keylist[i] << " does not correspond to any foreseen class");
58 return StatusCode::FAILURE ;
59 } else {
60 ATH_MSG_INFO( "will dump " << m_keylist[i] << " to Ntuple" ) ;
61 m_dumpFlags.set(idx) ;
62 }
63 }
64
65 ATH_MSG_INFO("LArParams2Ntuple 3");
67 ATH_MSG_INFO( "All parameters will be accessed through abstract interface" ) ;
68 if ( ! m_allChannels2Ntuple ) {
69 ATH_MSG_WARNING( "This will force dumping to Ntuple all foreseen online channels!" ) ;
71 }
72 } else {
73 ATH_MSG_INFO( "All parameters will be accessed through their Complete/VsCalib class" ) ;
74 }
76 ATH_MSG_INFO( "All foreseen online channels will be written to Ntuple" ) ;
77 } else {
78 ATH_MSG_INFO( "Only channels with sensible parameters will be written to Ntuple (default)" ) ;
79 }
80
82}
83
84
86
87
88 // ntuple handling:
89 //------------------
90 NTuple::Item<long> ntcellIndex;
91 NTuple::Item<long> ntflag, ntgain;
92
93 // .................... CaliPulseParams:
94 NTuple::Item<double> ntTcal, ntFstep, ntOffset, ntdTimeCal ;
95 NTuple::Item<long> ntnCB ;
96 // .................... DetCellParams:
97 NTuple::Item<double> ntOmega0, ntTaur ;
98 // .................... PhysCaliTdiff, Tdrift:
99 NTuple::Item<double> ntTdiff, ntTdrift ;
100 // .................... MphysOverMcal:
101 NTuple::Item<double> ntMphysOverMcal ;
102 // .................... Rinj, Tshaper:
103 NTuple::Item<double> ntRinj, ntTshaper ;
104 // .................... EMEC stuff:
105 NTuple::Item<double> ntEMEC_Cphi, ntEMEC_HValpha, ntEMEC_HVbeta ;
106 // .................... Cable stuff:
107 NTuple::Item<double> ntCableLength, ntCableAttenuation ;
108 // OFCBin
109 NTuple::Item<long> ntbin;
110
111 StatusCode sc=m_nt->addItem("cellIndex",ntcellIndex,0,2000);
112 if (sc!=StatusCode::SUCCESS) {
113 ATH_MSG_ERROR( "addItem 'Cell Index' failed" );
114 return StatusCode::FAILURE;
115 }
116 sc=m_nt->addItem("gain",ntgain,-1,2);
117 if (sc!=StatusCode::SUCCESS) {
118 ATH_MSG_ERROR( "addItem 'Gain' failed" );
119 return StatusCode::FAILURE;
120 }
121
123 sc=m_nt->addItem("Tcal",ntTcal);
124 if (sc!=StatusCode::SUCCESS) {
125 ATH_MSG_ERROR( "addItem 'Tcal' failed" );
126 return StatusCode::FAILURE;
127 }
128 sc=m_nt->addItem("Fstep",ntFstep);
129 if (sc!=StatusCode::SUCCESS) {
130 ATH_MSG_ERROR( "addItem 'Fstep' failed" );
131 return StatusCode::FAILURE;
132 }
133 sc=m_nt->addItem("Offset",ntOffset);
134 if (sc!=StatusCode::SUCCESS) {
135 ATH_MSG_ERROR( "addItem 'Offset' failed" );
136 return StatusCode::FAILURE;
137 }
138 sc=m_nt->addItem("dTimeCal",ntdTimeCal);
139 if (sc!=StatusCode::SUCCESS) {
140 ATH_MSG_ERROR( "addItem 'dTimeCal' failed" );
141 return StatusCode::FAILURE;
142 }
143 sc=m_nt->addItem("nCB",ntnCB);
144 if (sc!=StatusCode::SUCCESS) {
145 ATH_MSG_ERROR( "addItem 'nCB' failed" );
146 return StatusCode::FAILURE;
147 }
148 }
149
151 sc=m_nt->addItem("Omega0",ntOmega0);
152 if (sc!=StatusCode::SUCCESS) {
153 ATH_MSG_ERROR( "addItem 'Omega0' failed" );
154 return StatusCode::FAILURE;
155 }
156 sc=m_nt->addItem("Taur",ntTaur);
157 if (sc!=StatusCode::SUCCESS) {
158 ATH_MSG_ERROR( "addItem 'Taur' failed" );
159 return StatusCode::FAILURE;
160 }
161 }
162
164 sc=m_nt->addItem("Tdiff",ntTdiff);
165 if (sc!=StatusCode::SUCCESS) {
166 ATH_MSG_ERROR( "addItem 'Tdiff' failed" );
167 return StatusCode::FAILURE;
168 }
169 }
170
172 sc=m_nt->addItem("Tdrift",ntTdrift);
173 if (sc!=StatusCode::SUCCESS) {
174 ATH_MSG_ERROR( "addItem 'Tdrift' failed" );
175 return StatusCode::FAILURE;
176 }
177 }
178
180 sc=m_nt->addItem("MphysOverMcal",ntMphysOverMcal);
181 if (sc!=StatusCode::SUCCESS) {
182 ATH_MSG_ERROR( "addItem 'MphysOverMcal' failed" );
183 return StatusCode::FAILURE;
184 }
185 }
186
187 if ( m_dumpFlags[RinjComplete] ) {
188 sc=m_nt->addItem("Rinj",ntRinj);
189 if (sc!=StatusCode::SUCCESS) {
190 ATH_MSG_ERROR( "addItem 'Rinj' failed" );
191 return StatusCode::FAILURE;
192 }
193 }
194
196 sc=m_nt->addItem("Tshaper",ntTshaper);
197 if (sc!=StatusCode::SUCCESS) {
198 ATH_MSG_ERROR( "addItem 'Tshaper' failed" );
199 return StatusCode::FAILURE;
200 }
201 }
202
204 sc=m_nt->addItem("EMEC_Cphi",ntEMEC_Cphi);
205 if (sc!=StatusCode::SUCCESS) {
206 ATH_MSG_ERROR( "addItem 'EMEC_Cphi' failed" );
207 return StatusCode::FAILURE;
208 }
209 }
210
212 sc=m_nt->addItem("EMEC_HValpha",ntEMEC_HValpha);
213 if (sc!=StatusCode::SUCCESS) {
214 ATH_MSG_ERROR( "addItem 'EMEC_HValpha' failed" );
215 return StatusCode::FAILURE;
216 }
217 }
218
220 sc=m_nt->addItem("EMEC_HVbeta",ntEMEC_HVbeta);
221 if (sc!=StatusCode::SUCCESS) {
222 ATH_MSG_ERROR( "addItem 'EMEC_HVbeta' failed" );
223 return StatusCode::FAILURE;
224 }
225 }
226
228 sc=m_nt->addItem("CableLength",ntCableLength);
229 if (sc!=StatusCode::SUCCESS) {
230 ATH_MSG_ERROR( "addItem 'CableLength' failed" );
231 return StatusCode::FAILURE;
232 }
233 }
234
236 sc=m_nt->addItem("CableAttenuation",ntCableAttenuation);
237 if (sc!=StatusCode::SUCCESS) {
238 ATH_MSG_ERROR( "addItem 'CableAttenuation' failed" );
239 return StatusCode::FAILURE;
240 }
241 }
242
244 sc=m_nt->addItem("OFCBin",ntbin);
245 if (sc!=StatusCode::SUCCESS) {
246 ATH_MSG_ERROR( "addItem 'OFCBin' failed" );
247 return StatusCode::FAILURE;
248 }
249 }
250
251 //=======================================================================================================
252 // dump smaller complete structures to a common Ntuple
253 //=======================================================================================================
254
255 //
256 // first, scan all complete data structures to collect a map of channels
257 //
258
259 int nGains = m_NGains.value() ;
260
261 m_dump_flags_map.resize(nGains) ; // map of channels to be dumped; resized to host 3 gains
262
263 if ( m_allChannels2Ntuple ) {
264
265 // *** all readout channels will go into the ntuple ***
266
269 if ( sc.isFailure() ) m_dumpFlags.clear(CaliPulseParamsComplete) ;
270 }
273 if ( sc.isFailure() ) m_dumpFlags.clear(DetCellParamsComplete) ;
274 }
277 if ( sc.isFailure() ) m_dumpFlags.clear(PhysCaliTdiffComplete) ;
278 }
281 if ( sc.isFailure() ) m_dumpFlags.clear(TdriftComplete) ;
282 }
285 if ( sc.isFailure() ) m_dumpFlags.clear(MphysOverMcalComplete) ;
286 }
287 if ( m_dumpFlags[RinjComplete] ) {
289 if ( sc.isFailure() ) m_dumpFlags.clear(RinjComplete) ;
290 }
293 if ( sc.isFailure() ) m_dumpFlags.clear(TshaperComplete) ;
294 }
297 if ( sc.isFailure() ) m_dumpFlags.clear(EMEC_CphiComplete) ;
298 }
301 if ( sc.isFailure() ) m_dumpFlags.clear(EMEC_HValphaComplete) ;
302 }
305 if ( sc.isFailure() ) m_dumpFlags.clear(EMEC_HVbetaComplete) ;
306 }
309 if ( sc.isFailure() ) m_dumpFlags.clear(CableLengthComplete) ;
310 }
313 if ( sc.isFailure() ) m_dumpFlags.clear(CableAttenuationComplete) ;
314 }
315 //if ( m_dumpFlags[CaliPulseParamsVsCalib] ) {
316 // sc = retrieveFromDetStore(m_calibCaliPulseParams) ;
317 // if ( sc.isFailure() ) m_dumpFlags.clear(CaliPulseParamsVsCalib) ;
318 //}
321 if ( sc.isFailure() ) m_dumpFlags.clear(OFCBinComplete) ;
322 }
323
324 for (HWIdentifier chid : m_onlineId->channel_range()) {
325 for ( unsigned gain=0 ; (int)gain<nGains ; ++gain ) {
326 DumpFlags & flags = m_dump_flags_map[gain][chid] ;
327 flags = m_dumpFlags ;
328 }
329 }
330 if ( ! m_isSC ) {
331 for (HWIdentifier chid : m_onlineId->calib_channel_range()) {
332 for ( unsigned gain=0 ; (int)gain<nGains ; ++gain ) {
333 DumpFlags & flags = m_dump_flags_map[gain][chid] ;
334 flags = m_dumpFlags ;
335 }
336 }
337 }
338
339 } else {
340
341 // *** scan all complete data structures to collect a map of valid channels ***
342
343 for ( unsigned i=0 ; i<m_nClasses ; i++ ) {
344 if ( ! m_dumpFlags[i] ) continue ;
345 ATH_MSG_DEBUG(m_classNames[i] << " was selected to be dumped...");
346
347 switch ( i ) {
350 break ;
351 }
354 break ;
355 }
358 break ;
359 }
360 case TdriftComplete: {
362 break ;
363 }
366 break ;
367 }
368 case RinjComplete: {
370 break ;
371 }
372 case TshaperComplete: {
374 break ;
375 }
376 case EMEC_CphiComplete: {
378 break ;
379 }
382 break ;
383 }
384 case EMEC_HVbetaComplete: {
386 break ;
387 }
388 case CableLengthComplete: {
390 break ;
391 }
394 break ;
395 }
396 //case CaliPulseParamsVsCalib: {
397 //sc = scanCalibChannels(m_calibCaliPulseParams) ;
398 //break ;
399 //}
400 case OFCBinComplete: {
402 break ;
403 }
404 } // end switch
405
406 } // end of the channels scan
407
408 }
409
410 //
411 // ... then fill the ntuple
412 //
413
414 for ( unsigned gain=0 ; (int)gain<nGains ; gain++) {
415
416 for (const std::pair<const HWIdentifier, DumpFlags>& p : m_dump_flags_map[gain]) {
417 HWIdentifier chid = HWIdentifier(p.first) ;
418
419 const std::vector<bool> & flags = (p.second).flags() ;
420 if ( flags.empty() ) continue ;
421 if ( flags.size() < m_nClasses ) { // should never happen...
422 ATH_MSG_WARNING( "... flags vector shorter than " << m_nClasses << ": " << flags.size() ) ;
423 continue ;
424 }
425
426 fillFromIdentifier(chid); //Fill common values by base-class
427
428 if ( flags[CaliPulseParamsComplete] ) {
429 ntTcal = m_completeCaliPulseParams->Tcal(chid,gain) ;
430 ntFstep = m_completeCaliPulseParams->Fstep(chid,gain) ;
431 ntOffset = m_completeCaliPulseParams->Offset(chid,gain) ;
432 ntdTimeCal = m_completeCaliPulseParams->dTimeCal(chid,gain) ;
433 ntnCB = m_completeCaliPulseParams->nCB(chid,gain) ;
434
435 }
436 if ( flags[DetCellParamsComplete] ) {
437 ntOmega0 = m_completeDetCellParams->Omega0(chid,gain) ;
438 ntTaur = m_completeDetCellParams->Taur(chid,gain) ;
439 }
440 if ( flags[PhysCaliTdiffComplete] ) {
441 ntTdiff = m_completePhysCaliTdiff->Tdiff(chid,gain) ;
442 }
443 if ( flags[TdriftComplete] ) {
444 ntTdrift = m_completeTdrift->Tdrift(chid) ;
445 }
446 if ( flags[MphysOverMcalComplete] ) {
447 ntMphysOverMcal = m_completeMphysOverMcal->MphysOverMcal(chid,gain) ;
448 }
449 if ( flags[RinjComplete] ) {
450 ntRinj = m_completeRinj->Rinj(chid) ;
451 }
452 if ( flags[TshaperComplete] ) {
453 ntTshaper = m_completeTshaper->Tshaper(chid) ;
454 }
455 if ( flags[EMEC_CphiComplete] ) {
456 ntEMEC_Cphi = m_completeEMEC_Cphi->EMEC_Cphi(chid) ;
457 }
458 if ( flags[EMEC_HValphaComplete] ) {
459 ntEMEC_HValpha = m_completeEMEC_HValpha->EMEC_HValpha(chid) ;
460 }
461 if ( flags[EMEC_HVbetaComplete] ) {
462 ntEMEC_HVbeta = m_completeEMEC_HVbeta->EMEC_HVbeta(chid) ;
463 }
464 if ( flags[CableLengthComplete] ) {
465 ntCableLength = m_completeCableLength->CableLength(chid) ;
466 }
467 if ( flags[CableAttenuationComplete] ) {
468 ntCableAttenuation = m_completeCableAttenuation->CableAttenuation(chid) ;
469 }
470 /*
471 if ( flags[CaliPulseParamsVsCalib] ) {
472 ntTcal = m_calibCaliPulseParams->Tcal(chid,gain) ;
473 ntFstep = m_calibCaliPulseParams->Fstep(chid,gain) ;
474 ntOffset = m_calibCaliPulseParams->Offset(chid,gain) ;
475 ntdTimeCal = m_calibCaliPulseParams->dTimeCal(chid,gain) ;
476 ntnCB = m_calibCaliPulseParams->nCB(chid,gain) ;
477 }
478 */
479 if ( flags[OFCBinComplete] ) {
480 ntbin = m_completeOFCBin->bin(chid,gain) ;
481 }
482 sc=ntupleSvc()->writeRecord(m_nt);
483 if (sc!=StatusCode::SUCCESS) {
484 ATH_MSG_ERROR( "writeRecord failed" );
485 return StatusCode::FAILURE;
486 }
487 ATH_MSG_DEBUG("... record written to ntuple");
488 } // end channel loop
489 } // end gain loop
490
491ATH_MSG_INFO("LArParams2Ntuple has finished.");
492 return StatusCode::SUCCESS;
493}// end stop-method.
494
495
496template < class DATA >
497StatusCode LArParams2Ntuple::scanReadoutChannels( const DATA*& data_object ) {
498
499 unsigned classIndex = LArParamsProperties::getClassIndex(data_object) ;
500 bool useGain = LArParamsProperties::isGainDependent(data_object) ;
501
502 if ( classIndex >= m_nClasses ) {
503 ATH_MSG_ERROR( "Class index " << classIndex << " beyond number of known classes: " << m_nClasses ) ;
504 return StatusCode::FAILURE ;
505 }
506
507 std::string detStoreKey;
508 if (!m_detStoreJo.empty() && !m_detStoreJo[classIndex].empty()) {
509 detStoreKey = m_detStoreJo[classIndex];
510 ATH_MSG_VERBOSE(classIndex<<" detStoreKey = "<<detStoreKey);
511 } else {
512 detStoreKey = m_detStoreKeys[classIndex] + m_suffix ;
513 }
514
515 std::string dataName = m_classNames[classIndex] ;
516
517 if ( dataName.substr(dataName.length()-8,8) != std::string("Complete") ) {
518 ATH_MSG_ERROR( "Function scanReadoutChannels cannot be called for data class " << dataName ) ;
519 return StatusCode::FAILURE ;
520 }
521
522 ATH_MSG_VERBOSE("Trying to retrieve " << dataName << " from detector store with key="<< detStoreKey << " ...");
523
524 StatusCode sc = m_detStore->retrieve(data_object,detStoreKey) ;
525 if ( sc == StatusCode::FAILURE ) {
526 ATH_MSG_VERBOSE("... failed! Trying without key ...");
527 StatusCode sc = m_detStore->retrieve(data_object) ;
528 }
529
530 if ( sc == StatusCode::FAILURE ) {
531 ATH_MSG_ERROR( "Could not retrieve " << dataName << " from detector store!" ) ;
532 return sc ;
533 }
534
535 // loop through the data object and keep memory of valid items
536
537 ATH_MSG_VERBOSE("... " << dataName << " retrieved");
538
539 unsigned nGains = m_NGains.value() ;
540 if ( ! useGain ) nGains = 1 ; // data are gain-independent
541
542 for ( unsigned gain=0 ; gain<nGains ; gain++) {
543 ATH_MSG_VERBOSE("... parsing gain " << gain);
544 typename DATA::ConstConditionsMapIterator it = data_object->begin(gain) ;
545 typename DATA::ConstConditionsMapIterator it_e = data_object->end(gain) ;
546 for ( ; it!=it_e ; it++ ) {
547 HWIdentifier chid = m_onlineId->channel_Id( HWIdentifier(it.getFebId()) , it.getChannel() ) ;
548 ATH_MSG_VERBOSE(" ... channel " << std::hex << chid.get_compact()<< std::dec);
549 if ( LArParamsProperties::isValid( data_object->get(chid,gain) ) ) {
550 if ( useGain ) {
551 DumpFlags & flags = m_dump_flags_map[gain][chid] ;
552 flags.set(classIndex) ;
553 } else {
554 for ( unsigned g=0 ; g<3 ; g++ ) {
555 DumpFlags & flags = m_dump_flags_map[g][chid] ;
556 flags.set(classIndex) ;
557 }
558 }
559 } else {
560 ATH_MSG_VERBOSE(" (looks empty!)");
561 } // endif isValid
562 } // end loop over channels
563 } // end loop over gains
564 return sc ;
565
566}
567
568template < class DATA >
569StatusCode LArParams2Ntuple::scanCalibChannels( const DATA*& data_object ) {
570
571 unsigned classIndex = LArParamsProperties::getClassIndex(data_object) ;
572 //bool useGain = LArParamsProperties::isGainDependent(data_object) ;
573 if ( classIndex >= m_nClasses ) {
574 ATH_MSG_ERROR( "Class index " << classIndex << " beyond number of known classes: " << m_nClasses ) ;
575 return StatusCode::FAILURE ;
576 }
577
578 std::string detStoreKey = m_detStoreKeys[classIndex] + m_suffix ;
579 std::string dataName = m_classNames[classIndex] ;
580
581 if ( dataName.substr(dataName.length()-7,7) != std::string("VsCalib") ) {
582 ATH_MSG_ERROR( "Function scanCalibChannels cannot be called for data class " << dataName ) ;
583 return StatusCode::FAILURE ;
584 }
585
586 ATH_MSG_VERBOSE("Trying to retrieve " << dataName << " from detector store with key="<< detStoreKey << " ...");
587
588 StatusCode sc = m_detStore->retrieve(data_object,detStoreKey) ;
589 if ( sc == StatusCode::FAILURE ) {
590 ATH_MSG_VERBOSE("... failed! Trying without key ...");
591 StatusCode sc = m_detStore->retrieve(data_object) ;
592 }
593
594 if ( sc == StatusCode::FAILURE ) {
595 ATH_MSG_ERROR( "Could not retrieve " << dataName << " from detector store!" ) ;
596 return sc ;
597 }
598
599 // loop through the data object and keep memory of valid items
600
601 ATH_MSG_VERBOSE("... " << dataName << " retrieved");
602 ATH_MSG_DEBUG(dataName << " successfully retrieved!");
603 // data_object->initialize() ;
604
605 typename DATA::Const_CB_It cb_it = data_object->begin() ;
606 typename DATA::Const_CB_It cb_it_e = data_object->end() ;
607 for ( ; cb_it!=cb_it_e ; cb_it++ ) { // loop through calibration boards
608 const typename DATA::CB_Tvec_pair & cb_params_set = *cb_it ;
609 const typename DATA::CB_Id & cb_identifier = cb_params_set.first ;
610 const typename DATA::T_vector & cb_params = cb_params_set.second ;
611 HWIdentifier cb_HWid(cb_identifier) ;
612 unsigned nchan = cb_params.size() ;
613 if (msgLvl(MSG::VERBOSE)) {
614 unsigned b_ec = m_onlineId->barrel_ec(cb_HWid) ;
615 unsigned p_n = m_onlineId->pos_neg(cb_HWid) ;
616 unsigned ft = m_onlineId->feedthrough(cb_HWid) ;
617 unsigned slot = m_onlineId->slot(cb_HWid) ;
618 ATH_MSG_VERBOSE( " ... B/EC=" << b_ec << " P/N=" << p_n << " FT=" << ft << " slot=" << slot
619 << " nchan=" << nchan ) ;
620 }//end if verbose
621
622 for ( unsigned ichan=0 ; ichan<nchan ; ichan++ ) { // loop through channels in a CB
623 if ( !m_isSC ) {
624 HWIdentifier chid = m_onlineId->calib_channel_Id(cb_HWid , ichan) ;
625 ATH_MSG_VERBOSE(" ... calib channel " << chid);
626 if ( LArParamsProperties::isValid( data_object->get(chid) ) ) {
627 for ( unsigned g=0 ; g<3 ; g++ ) {
628 DumpFlags & flags = m_dump_flags_map[g][chid] ;
629 flags.set(classIndex) ;
630 }
631 }
632 } // end of m_isSC
633 }
634
635 } // end loop over calib boards
636 return sc ;
637
638}
639
640template < class DATA >
641StatusCode LArParams2Ntuple::retrieveFromDetStore( const DATA*& data_object ) {
642 //
643 // data_object must be a concrete object (Complete or VsCalib)
644 //
645 unsigned classIndex = LArParamsProperties::getClassIndex(data_object) ;
646 //bool useGain = LArParamsProperties::isGainDependent(data_object) ;
647 if ( classIndex >= m_nClasses ) {
648 ATH_MSG_ERROR( "Class index " << classIndex << " beyond number of known classes: " << m_nClasses ) ;
649 return StatusCode::FAILURE ;
650 }
651 std::string detStoreKey = m_detStoreKeys[classIndex] + m_suffix ;
652 std::string dataName = m_classNames[classIndex] ;
654
655 ATH_MSG_VERBOSE("Trying to retrieve " << dataName << " from detector store through abstract interface I" << detStoreKey << " ...");
656 StatusCode sc = retrieveAbstractInterface(data_object) ;
657 if ( sc == StatusCode::FAILURE ) {
658 ATH_MSG_WARNING( "Could not retrieve " << dataName << " from detector store!" ) ;
659 return sc ;
660 }
661
662 } else {
663
664 ATH_MSG_VERBOSE("Trying to retrieve "<<dataName<<" from detector store with key="<<detStoreKey<<" ...");
665 StatusCode sc = m_detStore->retrieve(data_object,detStoreKey) ;
666 if ( sc == StatusCode::FAILURE ) {
667 ATH_MSG_VERBOSE("... failed! Trying without key ...");
668 StatusCode sc = m_detStore->retrieve(data_object) ;
669 }
670 if ( sc == StatusCode::FAILURE ) {
671 ATH_MSG_WARNING( "Could not retrieve " << dataName << " from detector store!" ) ;
672 return sc ;
673 }
674
675 }
676 ATH_MSG_INFO(dataName << " retrieved successfully from det store");
677 return StatusCode::SUCCESS ;
678}
679
680
682 const ILArCaliPulseParams* abstract_object = nullptr;
683 StatusCode sc = m_detStore->retrieve(abstract_object) ;
684 data_object = dynamic_cast<const LArCaliPulseParamsComplete*>(abstract_object) ;
685 return sc ;
686}
687//inline StatusCode LArParams2Ntuple::retrieveAbstractInterface(const LArCaliPulseParamsVsCalib*& data_object) {
688// const ILArCaliPulseParams* abstract_object ;
689// StatusCode sc = m_detStore->retrieve(abstract_object) ;
690// data_object = dynamic_cast<const LArCaliPulseParamsVsCalib*>(abstract_object) ;
691// return sc ;
692//}
694 const ILArDetCellParams* abstract_object = nullptr;
695 StatusCode sc = m_detStore->retrieve(abstract_object) ;
696 data_object = dynamic_cast<const LArDetCellParamsComplete*>(abstract_object) ;
697 return sc ;
698}
699inline StatusCode LArParams2Ntuple::retrieveAbstractInterface(const LArPhysCaliTdiffComplete*& data_object) {
700 const ILArPhysCaliTdiff* abstract_object = nullptr;
701 StatusCode sc = m_detStore->retrieve(abstract_object) ;
702 data_object = dynamic_cast<const LArPhysCaliTdiffComplete*>(abstract_object) ;
703 return sc ;
704}
706 const ILArTdrift* abstract_object = nullptr;
707 StatusCode sc = m_detStore->retrieve(abstract_object) ;
708 data_object = dynamic_cast<const LArTdriftComplete*>(abstract_object) ;
709 return sc ;
710}
712 const ILArMphysOverMcal* abstract_object = nullptr;
713 StatusCode sc = m_detStore->retrieve(abstract_object) ;
714 data_object = dynamic_cast<const LArMphysOverMcalComplete*>(abstract_object) ;
715 return sc ;
716}
717inline StatusCode LArParams2Ntuple::retrieveAbstractInterface(const LArRinjComplete*& data_object) {
718 const ILArRinj* abstract_object = nullptr;
719 StatusCode sc = m_detStore->retrieve(abstract_object) ;
720 data_object = dynamic_cast<const LArRinjComplete*>(abstract_object) ;
721 return sc ;
722}
724 const ILArTshaper* abstract_object = nullptr;
725 StatusCode sc = m_detStore->retrieve(abstract_object) ;
726 data_object = dynamic_cast<const LArTshaperComplete*>(abstract_object) ;
727 return sc ;
728}
730 const ILArEMEC_Cphi* abstract_object = nullptr;
731 StatusCode sc = m_detStore->retrieve(abstract_object) ;
732 data_object = dynamic_cast<const LArEMEC_CphiComplete*>(abstract_object) ;
733 return sc ;
734}
736 const ILArEMEC_HValpha* abstract_object = nullptr;
737 StatusCode sc = m_detStore->retrieve(abstract_object) ;
738 data_object = dynamic_cast<const LArEMEC_HValphaComplete*>(abstract_object) ;
739 return sc ;
740}
742 const ILArEMEC_HVbeta* abstract_object = nullptr;
743 StatusCode sc = m_detStore->retrieve(abstract_object) ;
744 data_object = dynamic_cast<const LArEMEC_HVbetaComplete*>(abstract_object) ;
745 return sc ;
746}
748 const ILArCableLength* abstract_object = nullptr;
749 StatusCode sc = m_detStore->retrieve(abstract_object) ;
750 data_object = dynamic_cast<const LArCableLengthComplete*>(abstract_object) ;
751 return sc ;
752}
754 const ILArCableAttenuation* abstract_object = nullptr;
755 StatusCode sc = m_detStore->retrieve(abstract_object) ;
756 data_object = dynamic_cast<const LArCableAttenuationComplete*>(abstract_object) ;
757 return sc ;
758}
759
760
761/*
762void LArParams2Ntuple::dumpChannels()
763{
764 if ( m_dumpAllOnlineChannels == std::string("") ) return ;
765 //
766 FILE* f = fopen( m_dumpAllOnlineChannels.c_str() , "w" ) ;
767 if ( f == NULL ) {
768 ATH_MSG_WARNING( "Could not open file " << m_dumpAllOnlineChannels ) ;
769 ATH_MSG_WARNING( "... channels dump cannot be done!" ) ;
770 return ;
771 }
772 std::string subdet , comment , descr ;
773 //unsigned FT, slot, channel, b_ec, p_n ;
774
775 std::vector<HWIdentifier>::const_iterator chIt = m_onlineId->channel_begin() ;
776 std::vector<HWIdentifier>::const_iterator chItEnd = m_onlineId->channel_end() ;
777 ATH_MSG_INFO( "Dumping online read-out channels to file " << m_dumpAllOnlineChannels );
778 for ( ; chIt != chItEnd ; chIt++ ) {
779 writeToFile(*chIt,f) ;
780 }
781 std::vector<HWIdentifier>::const_iterator chCalibIt = m_onlineId->calib_channel_begin() ;
782 std::vector<HWIdentifier>::const_iterator chCalibItEnd = m_onlineId->calib_channel_end() ;
783 ATH_MSG_INFO( "Dumping online calib channels to file " << m_dumpAllOnlineChannels );
784 for ( ; chCalibIt != chCalibItEnd ; chCalibIt++ ) {
785 writeToFile(*chCalibIt,f) ;
786 }
787 fclose(f) ;
788}
789
790void LArParams2Ntuple::writeToFile(const HWIdentifier & ch, FILE* f) {
791 unsigned b_ec = m_onlineId->barrel_ec(ch) ;
792 unsigned p_n = m_onlineId->pos_neg(ch) ;
793 unsigned FT = m_onlineId->feedthrough(ch) ;
794 unsigned slot = m_onlineId->slot(ch) ;
795 unsigned channel = m_onlineId->channel(ch) ;
796 unsigned layer, region, ieta, iphi ;
797 std::string descr = m_onlineId->show_to_string(ch) ;
798 std::string subdet = " " ;
799 if ( m_onlineId->isEmBarrelOnline(ch) ) subdet = "EMB " ;
800 if ( m_onlineId->isEmEndcapOnline(ch) ) subdet = "EMEC" ;
801 if ( m_onlineId->isHecOnline(ch) ) subdet = "HEC " ;
802 if ( m_onlineId->isFcalOnline(ch) ) subdet = "FCAL" ;
803 std::string comment = " " ;
804 bool offlineOK = false ;
805 layer = region = ieta = iphi = 99999 ;
806 if ( m_onlineId->isCalibration(ch) ) {
807 comment = "Calib Line" ;
808 } else {
809 int calibLine ;
810 try {
811 Identifier id = m_larCablingSvc->cnvToIdentifier(ch);
812 if ( m_emId->is_lar_em(id) ) {
813 layer = m_emId->sampling(id) ;
814 region = m_emId->region(id) ;
815 ieta = m_emId->eta(id) ;
816 iphi = m_emId->phi(id) ;
817 offlineOK = true ;
818 }
819 const std::vector<HWIdentifier>& calibLineV = m_larCablingSvc->calibSlotLine(ch);
820 std::vector<HWIdentifier>::const_iterator calibLineIt = calibLineV.begin();
821 if ( calibLineIt != calibLineV.end() ) {
822 calibLine = m_onlineId->channel(*calibLineIt);
823 } else {
824 calibLine = -2 ; // says not possible to find calib line
825 }
826 } catch ( LArID_Exception & except ) {
827 calibLine = -2 ;
828 }
829 char comment_cstr[11] ;
830 sprintf(comment_cstr,"pulse=%3.3d",calibLine) ;
831 comment = std::string(comment_cstr) ;
832 if ( offlineOK ) {
833 char offline_cstr[30] ;
834 sprintf(offline_cstr," L=%1d R=%1d eta=%3.3d phi=%3.3d",layer,region,ieta,iphi) ;
835 comment += std::string(offline_cstr) ;
836 }
837 }
838 if ( p_n == 0 ) {
839 subdet = "-" + subdet ;
840 } else {
841 subdet = "+" + subdet ;
842 }
843 fprintf(f, "HWId=%11.11d B/E=%2.2d P/N=%2.2d FT=%2.2d sl=%2.2d ch=%3.3d det=%5s %50s %50s\n",
844 ch.get_identifier32().get_compact(), b_ec, p_n, FT, slot, channel,
845 subdet.c_str(), comment.c_str(), descr.c_str() ) ;
846}
847*/
#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
INTupleSvc * ntupleSvc()
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool msgLvl(const MSG::Level lvl) const
value_type get_compact() const
Get the compact id.
This class implements the ILArCableAttenuation interface.
This class implements the ILArCableLength interface.
This class implements the ILArCaliPulseParams interface.
Gaudi::Property< bool > m_isSC
StoreGateSvc * m_detStore
Gaudi::Property< int > m_NGains
const LArOnlineID_Base * m_onlineId
bool fillFromIdentifier(const HWIdentifier &id)
LArCond2NtupleBase(const std::string &name, ISvcLocator *pSvcLocator)
This class implements the ILArDetCellParams interface.
This class implements the ILArEMEC_Cphi interface.
This class implements the ILArEMEC_HValpha interface.
This class implements the ILArEMEC_HVbeta interface.
This class implements the ILArMphysOverMcal interface.
const LArEMEC_HVbetaComplete * m_completeEMEC_HVbeta
const LArTdriftComplete * m_completeTdrift
StatusCode scanReadoutChannels(const DATA *&data_object)
const LArPhysCaliTdiffComplete * m_completePhysCaliTdiff
std::vector< std::map< HWIdentifier, DumpFlags > > m_dump_flags_map
const LArDetCellParamsComplete * m_completeDetCellParams
const LArEMEC_HValphaComplete * m_completeEMEC_HValpha
LArParams2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< std::string > m_detStoreJo
const LArEMEC_CphiComplete * m_completeEMEC_Cphi
StatusCode retrieveAbstractInterface(const LArCaliPulseParamsComplete *&data_object)
virtual StatusCode stop()
StatusCode initialize()
std::vector< std::string > m_detStoreKeys
const LArCaliPulseParamsComplete * m_completeCaliPulseParams
std::vector< std::string > m_keylist
StatusCode retrieveFromDetStore(const DATA *&data_object)
const LArOFCBinComplete * m_completeOFCBin
const LArMphysOverMcalComplete * m_completeMphysOverMcal
static const unsigned m_nClasses
StatusCode scanCalibChannels(const DATA *&data_object)
const LArRinjComplete * m_completeRinj
const LArTshaperComplete * m_completeTshaper
const LArCableLengthComplete * m_completeCableLength
const LArCableAttenuationComplete * m_completeCableAttenuation
std::vector< std::string > m_classNames
This class implements the ILArRinj interface.
This class implements the ILArTdrift interface.
This class implements the ILArTshaper interface.
This include file contains inline functions describing LAr Parameters properties used in LArReadParam...
std::string keyword(const std::string &classname)
unsigned getClassIndex(const LArCaliPulseParamsComplete *)
bool isGainDependent(unsigned index)
bool isValid(const LArCaliPulseParamsP &p)
const std::vector< std::string > & ClassNames()