ATLAS Offline Software
LArDeltaRespPredictor.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "GaudiKernel/ToolHandle.h"
8 
11 
12 #include <iostream>
13 #include <fstream>
14 
15 LArDeltaRespPredictor::LArDeltaRespPredictor (const std::string& name, ISvcLocator* pSvcLocator) :
16  AthAlgorithm(name, pSvcLocator)
17 {
18  // list of gains to be processed
19  m_keylist.clear() ;
20  m_keylist.emplace_back("HIGH");
21  m_keylist.emplace_back("MEDIUM");
22  m_keylist.emplace_back("LOW");
23  declareProperty("KeyList",m_keylist);
24 }
25 
27 = default;
28 
30 {
32 
33  return StatusCode::SUCCESS ;
34 }
35 
37 {
38  ToolHandle<LArWFParamTool> larWFParamTool("LArWFParamTool");
39  ATH_CHECK( larWFParamTool.retrieve() );
40 
41  ToolHandle<LArDeltaRespTool> larDeltaRespTool("LArDeltaRespTool");
42  ATH_CHECK( larDeltaRespTool.retrieve() );
43 
44  const LArCaliWaveContainer* caliWaveContainer = nullptr;
45  std::string keyCali = "CaliWave" ;
46  ATH_CHECK( detStore()->retrieve(caliWaveContainer,keyCali) );
47  ATH_MSG_INFO ( "Processing LArCaliWaveContainer from StoreGate, key='CaliWave'" );
48 
50  const LArOnOffIdMapping* cabling{*cablingHdl};
51  if(!cabling) {
52  ATH_MSG_ERROR("Do not have mapping object " << m_cablingKey.key() );
53  return StatusCode::FAILURE;
54  }
55 
56  // Create new LArCaliWaveContainer for DeltaResp(s)
57  LArCaliWaveContainer* larDeltaRespContainer = nullptr;
58 
59  // Only record if keylist is not empty
60  if (m_keylist.empty())
61  return StatusCode::SUCCESS;
62 
63  // Create new LArCaliWaveContainer for DeltaResp(s)
64  larDeltaRespContainer = new LArCaliWaveContainer();
65 
66  // Record LArDeltaRespContainer to DetectorStore
67  keyCali += "_delta" ;
68  ATH_CHECK( detStore()->record(larDeltaRespContainer,keyCali) );
69 
70  // get the waveforms from the detector store
71  for (const std::string& key : m_keylist) { //Loop over all containers that are to be processed (e.g. different gains)
72 
73  // Set gain from key value
75  if (key == "MEDIUM") gain = CaloGain::LARMEDIUMGAIN;
76  else if (key == "LOW") gain = CaloGain::LARLOWGAIN;
77 
78  // Create new LArWFParamsContainer
79  //LArWFParamsContainer* larWFParamsContainer=new LArWFParamsContainer();
80 
82  const_iterator itVec = caliWaveContainer->begin(gain);
83  const_iterator itVec_e = caliWaveContainer->end(gain);
84 
85  // Loop over caliWaveContainer (e.g. different cells and DAC values)
86 
87  for (; itVec != itVec_e; ++itVec) {
88 
89  // Get the vector of waves for this chid,gain
91  larDeltaRespContainer->get(itVec.channelId(), gain);
92 
93  for (const LArCaliWave& larCaliWave : *itVec) {
94  if ( larCaliWave.getFlag() != LArWave::dac0 ) { // skip dac0 waves
95  // Get the waveform parameters
96  LArWFParams wfParams;
97  std::optional<LArCaliWave> nullwave;
98  StatusCode sc = larWFParamTool->getLArWaveParams(larCaliWave,
99  itVec.channelId(),
101  wfParams, cabling,nullwave,nullwave,nullwave);
102  if (sc.isFailure()) { // bad parameters
103  ATH_MSG_INFO ( "Bad parameters for channel " <<
104  (itVec.channelId()) );
105  } else { // Compute Delta Response
106  LArCaliWave lardeltaresp = larDeltaRespTool->makeLArDeltaResp(wfParams,
107  larCaliWave);
108  lardeltaresp.setFlag( LArWave::predCali ) ;
109  dacWaves.push_back(lardeltaresp);
110  }
111  } // end if on dac0
112  } // end loop over cells
113  } // end loop over cell vecs
114  } // End loop over all CaliWave containers
115 
116  ATH_MSG_DEBUG ( "LArDeltaRespPredictor stopped!" );
117  return StatusCode::SUCCESS;
118 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArCaliWaveContainer.h
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
LArConditionsContainerDB::iteratorT
Declaration of const iterator.
Definition: LArConditionsContainerDB.h:72
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
LArWFParams
Definition: LArWFParams.h:20
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
LArDeltaRespPredictor::initialize
StatusCode initialize()
Definition: LArDeltaRespPredictor.cxx:29
LArWFParamsContainer.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
LArCaliWaveContainer
Liquid Argon Cumulative Wave Container.
Definition: LArCaliWaveContainer.h:33
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
LArDeltaRespPredictor::~LArDeltaRespPredictor
~LArDeltaRespPredictor()
LArDeltaRespPredictor::m_keylist
std::vector< std::string > m_keylist
Definition: LArDeltaRespPredictor.h:42
LArCaliWave
Definition: LArCaliWave.h:44
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArWave::dac0
@ dac0
Definition: LArWave.h:125
LArConditionsContainer::end
ConstConditionsMapIterator end(unsigned int gain) const
end of all channels for this gain
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArConditionsContainer::get
ConstReference get(const HWIdentifier id, unsigned int gain=0) const
get data with online identifier
LArCaliWaveVec
Definition: LArCaliWave.h:91
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArWave::predCali
@ predCali
Definition: LArWave.h:129
LArDeltaRespPredictor.h
AthAlgorithm
Definition: AthAlgorithm.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
LArDeltaRespPredictor::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition: LArDeltaRespPredictor.h:40
CaloGain::LARMEDIUMGAIN
@ LARMEDIUMGAIN
Definition: CaloGain.h:18
LArDeltaRespPredictor::stop
StatusCode stop()
Definition: LArDeltaRespPredictor.cxx:36
LArConditionsContainer::begin
ConstConditionsMapIterator begin(unsigned int gain) const
get iterator for all channels for a gain
LArWave::setFlag
void setFlag(const unsigned flag)
set flag
Definition: LArWave.h:199
LArDeltaRespPredictor::LArDeltaRespPredictor
LArDeltaRespPredictor(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArDeltaRespPredictor.cxx:15
CaloGain::LARLOWGAIN
@ LARLOWGAIN
Definition: CaloGain.h:18
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37