ATLAS Offline Software
Loading...
Searching...
No Matches
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
15LArDeltaRespPredictor::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{
31 ATH_CHECK(m_cablingKey.initialize());
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
74 int gain = CaloGain::LARHIGHGAIN;
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(),
100 (CaloGain::CaloGain)gain,
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(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
Liquid Argon Cumulative Wave Container.
ConditionsMap::const_iterator ConstConditionsMapIterator
ConstReference get(const HWIdentifier id, unsigned int gain=0) const
get data with online identifier
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
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
LArDeltaRespPredictor(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< std::string > m_keylist
@ predCali
Definition LArWave.h:129
void setFlag(const unsigned flag)
set flag
Definition LArWave.h:199
@ LARMEDIUMGAIN
Definition CaloGain.h:18
@ LARLOWGAIN
Definition CaloGain.h:18
@ LARHIGHGAIN
Definition CaloGain.h:18