ATLAS Offline Software
LArWFParams2Ntuple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
14 
15 LArWFParams2Ntuple::LArWFParams2Ntuple(const std::string& name, ISvcLocator* pSvcLocator)
16  : LArCond2NtupleBase(name, pSvcLocator)
17 {
18  //declareProperty("UseContainers",m_useContainers=false) ;
19  //declareProperty("UseComplete",m_useComplete=false) ;
20  declareProperty("DumpCaliPulseParams",m_dumpCaliPulseParams=false);
21  declareProperty("DumpDetCellParams" ,m_dumpDetCellParams=false);
22  declareProperty("DumpPhysCaliTdiff" ,m_dumpPhysCaliTdiff=false);
23  declareProperty("DumpTdrift" ,m_dumpTdrift=false);
24  declareProperty("DumpOFCBin" ,m_dumpOFCBin=false);
25 
26  declareProperty("CaliPulseParamsKey",m_caliPulseParamsKey="LArCaliPulseParams");
27  declareProperty("DetCellParamsKey" ,m_detCellParamsKey="LArDetCellParams");
28  declareProperty("PhysCaliTDiffKey" ,m_physCaliTDiffKey="LArPhysCaliTDiff");
29  declareProperty("TdriftKey" ,m_tdriftKey="LArTdrift");
30  declareProperty("OFCBinKey" ,m_ofcBinKey="LArOFCBin");
31 
32  m_addFEBTemp=false;
33 }
34 
36 = default;
37 
38 
40 
41  m_ntTitle="Parameters";
42  m_ntpath="/NTUPLES/FILE1/PARAMS";
44 }
45 
47 
48  //Retrieve objects from DetStore
49  const LArCaliPulseParamsComplete* completeCaliPulseParams=nullptr ;
50  const LArDetCellParamsComplete* completeDetCellParams=nullptr ;
51  const LArPhysCaliTdiffComplete* completePhysCaliTdiff=nullptr ;
52  const LArTdriftComplete* completeTdrift=nullptr;
53  const LArOFCBinComplete* completeOFCBin=nullptr;
54 
55 
56  if ( m_dumpCaliPulseParams ) { //try retrieving from det store
57  ATH_MSG_DEBUG("Retrieving LArCaliPulseParamsComplete from detector store...");
58  StatusCode sc = detStore()->retrieve(completeCaliPulseParams,m_caliPulseParamsKey) ;
59  if ( sc.isFailure() ) {
60  ATH_MSG_ERROR( "Could not retrieve LArCaliPulseParamsComplete from detector store!" ) ;
61  m_dumpCaliPulseParams = false ;
62  }
63  }
64 
65  if ( m_dumpDetCellParams ) { //try retrieving from det store
66  ATH_MSG_DEBUG("Retrieving LArDetCellParamsComplete from detector store...");
67  StatusCode sc = detStore()->retrieve(completeDetCellParams,m_detCellParamsKey);
68  if ( sc.isFailure() ) {
69  ATH_MSG_ERROR( "Could not retrieve LArDetCellParamsComplete from detector store!" ) ;
70  m_dumpDetCellParams = false;
71  }
72  }
73 
74 
75  if ( m_dumpPhysCaliTdiff ) { //try retrieving from det store
76  ATH_MSG_DEBUG("Retrieving LArPhysCaliTdiffComplete from detector store...");
77  StatusCode sc = detStore()->retrieve(completePhysCaliTdiff,m_physCaliTDiffKey);
78  if ( sc.isFailure()) {
79  ATH_MSG_ERROR( "Could not retrieve LArPhysCaliTdiffComplete from detector store!" ) ;
80  m_dumpPhysCaliTdiff = false ;
81  }
82  }
83 
84 
85  if ( m_dumpTdrift ) { //try retrieving from det store
86  ATH_MSG_DEBUG("Retrieving LArTdriftComplete from detector store...");
87  StatusCode sc = detStore()->retrieve(completeTdrift,m_tdriftKey) ;
88  if ( sc.isFailure()) {
89  ATH_MSG_ERROR( "Could not retrieve LArTdriftComplete from detector store!" );
90  m_dumpTdrift = false ;
91  }
92  }
93 
94  if ( m_dumpOFCBin ) { //try retrieving from det store
95  ATH_MSG_DEBUG("Retrieving LArOFCBinComplete from detector store...");
96  StatusCode sc = detStore()->retrieve(completeOFCBin,m_ofcBinKey) ;
97  if ( sc.isFailure()) {
98  ATH_MSG_ERROR( "Could not retrieve LArOFCBinComplete from detector store!" );
99  m_dumpOFCBin= false ;
100  }
101  }
102 
103 
104  //Book ntuple item
105  NTuple::Item<long> gain;
106  NTuple::Item<double> Tcal, Fstep, Tdrift, Omega0, Taur, Tdiff,ofcbin;// Tshaper, Amplitude;
107 
108  StatusCode sc=m_nt->addItem("gain",gain,-1,2);
109  if (sc!=StatusCode::SUCCESS) {
110  ATH_MSG_ERROR( "addItem 'Gain' failed" );
111  return StatusCode::FAILURE;
112  }
113 
114 
115  if ( m_dumpCaliPulseParams ) {
116  sc=m_nt->addItem("Tcal",Tcal);
117  if (sc!=StatusCode::SUCCESS) {
118  ATH_MSG_ERROR( "addItem 'Tcal' failed" );
119  return StatusCode::FAILURE;
120  }
121  sc=m_nt->addItem("Fstep",Fstep);
122  if (sc!=StatusCode::SUCCESS) {
123  ATH_MSG_ERROR( "addItem 'Fstep' failed" );
124  return StatusCode::FAILURE;
125  }
126  }
127  if ( m_dumpTdrift ) {
128  sc=m_nt->addItem("Tdrift",Tdrift);
129  if (sc!=StatusCode::SUCCESS) {
130  ATH_MSG_ERROR( "addItem 'Tdrift' failed" );
131  return StatusCode::FAILURE;
132  }
133  }
134  if ( m_dumpPhysCaliTdiff ) {
135  sc=m_nt->addItem("Tdiff",Tdiff);
136  if (sc!=StatusCode::SUCCESS) {
137  ATH_MSG_ERROR( "addItem 'Tdiff' failed" );
138  return StatusCode::FAILURE;
139  }
140  }
141  if ( m_dumpDetCellParams ) {
142  sc=m_nt->addItem("Omega0",Omega0);
143  if (sc!=StatusCode::SUCCESS) {
144  ATH_MSG_ERROR( "addItem 'Omega0' failed" );
145  return StatusCode::FAILURE;
146  }
147  sc=m_nt->addItem("Taur",Taur);
148  if (sc!=StatusCode::SUCCESS) {
149  ATH_MSG_ERROR( "addItem 'Taur' failed" );
150  return StatusCode::FAILURE;
151  }
152  }
153  if (m_dumpOFCBin) {
154  sc=m_nt->addItem("Bin",ofcbin);
155  if (sc!=StatusCode::SUCCESS) {
156  ATH_MSG_ERROR( "addIdetm 'Bin' failed!" );
157  }
158  }
159 
160 // sc=m_nt->addItem("Tshaper",m_Tshaper);
161 // if (sc!=StatusCode::SUCCESS) {
162 // ATH_MSG_ERROR( "addItem 'Tshaper' failed" );
163 // return StatusCode::FAILURE;
164 // }
165 // sc=m_nt->addItem("Amplitude",m_Amplitude);
166 // if (sc!=StatusCode::SUCCESS) {
167 // ATH_MSG_ERROR( "addItem 'Amplitude' failed" );
168 // return StatusCode::FAILURE;
169 // }
170 
171  //=======================================================================================================
172  // dump WFparams from smaller complete structures
173  // LArCaliPulseParamsComplete , LArDetCellParamsComplete , LArPhysCaliTdiffComplete , LArTdriftComplete
174  //=======================================================================================================
175 
176 
177 
178 
180  for (const HWIdentifier hwid: m_onlineId->channel_range()) {
181 
182  //Initialize variables to 'errorcode'
183  float vTcal=ILArCaliPulseParams::ERRORCODE;
184  float vFstep=ILArCaliPulseParams::ERRORCODE;
185  float vTdrift=ILArCaliPulseParams::ERRORCODE;
186  float vOmega0=ILArCaliPulseParams::ERRORCODE;
187  float vTaur=ILArCaliPulseParams::ERRORCODE;
188  float vTdiff=ILArCaliPulseParams::ERRORCODE;
190  //Tshaper=ILArCaliPulseParams::ERRORCODE;
191  //Amplitude=ILArCaliPulseParams::ERRORCODE;
192 
193 
194  bool haveData=false;
195  if ( m_dumpCaliPulseParams ) {
196  const LArCaliPulseParamsP& params=completeCaliPulseParams->get(hwid,igain);
197  vTcal=params.m_Tcal;
198  vFstep=params.m_Fstep;
199  if (!haveData && (vTcal>1+ILArCaliPulseParams::ERRORCODE || vFstep>1+ILArCaliPulseParams::ERRORCODE)) haveData=true;
200  }
201 
202  if (m_dumpDetCellParams ) {
203  const LArDetCellParamsP& params=completeDetCellParams->get(hwid,igain);
204  vOmega0=params.m_Omega0;
205  vTaur=params.m_Taur;
206  if (!haveData && (vOmega0>1+ILArCaliPulseParams::ERRORCODE || vTaur>1+ILArCaliPulseParams::ERRORCODE)) haveData=true;
207  }
208 
209  if (m_dumpTdrift ) {
210  const LArTdriftP& params=completeTdrift->get(hwid,gain);
211  if (!params.isEmpty()) {
212  vTdrift=params.m_Tdrift;
213  haveData=true;
214  }
215  }
216 
217  if ( m_dumpPhysCaliTdiff ) {
218  const LArPhysCaliTdiffP& params= completePhysCaliTdiff->get(hwid,igain);
219  if (!params.isEmpty()) {
220  vTdiff=params.m_Tdiff;
221  if (!m_dumpTdrift && !m_dumpDetCellParams && !m_dumpCaliPulseParams) haveData=true;
222  }
223  }
224 
225  if ( m_dumpOFCBin ) {
226  const LArOFCBinP & bin = completeOFCBin->bin(hwid,igain);
227  if (!bin.isEmpty()) {
228  vBin=bin.m_bin;
229  haveData=true;
230  }
231  }
232 
233  if (haveData) {
234  bool connected=fillFromIdentifier(hwid);
235  if (!connected) {
236  //std::cout << "Disconnected: Tdrift:" << vTdrift << " Tdiff:" << vTdiff << " Taur" << vTaur << " Omega0" << vOmega0 << " Fstep" << vFstep << " Tcal" << vTcal << std::endl;
237  continue;
238  }
239  if ( m_dumpCaliPulseParams ) {
240  Tcal=vTcal;
241  Fstep=vFstep;
242  }
243  if (m_dumpDetCellParams ) {
244  Taur=vTaur;
245  Omega0=vOmega0;
246  }
247 
248  if (m_dumpPhysCaliTdiff) Tdiff=vTdiff;
249 
250  if (m_dumpTdrift ) Tdrift=vTdrift;
251 
252  if (m_dumpOFCBin) ofcbin=vBin;
253 
254  gain=igain;
255 
256 
257  sc=ntupleSvc()->writeRecord(m_nt);
258  if (sc!=StatusCode::SUCCESS) {
259  ATH_MSG_ERROR( "writeRecord failed" );
260  return StatusCode::FAILURE;
261  }
262  }//end if have data
263 
264  }//end loop over identifiers
265 
266  }//end loop over gains
267  return StatusCode::SUCCESS;
268 }// end stop-method
LArDetCellParamsComplete.h
LArOFCBinP
Definition: LArOFCBinP.h:8
LArWFParams2Ntuple::initialize
StatusCode initialize()
Definition: LArWFParams2Ntuple.cxx:39
LArWFParams2Ntuple::m_tdriftKey
std::string m_tdriftKey
Definition: LArWFParams2Ntuple.h:40
LArTdriftComplete
This class implements the ILArTdrift interface.
Definition: LArTdriftComplete.h:23
LArCond2NtupleBase::m_addFEBTemp
Gaudi::Property< bool > m_addFEBTemp
Definition: LArCond2NtupleBase.h:54
LArOFCBinComplete::bin
virtual const int & bin(const HWIdentifier &chid, const int &gain) const
Definition: LArOFCBinComplete.h:19
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
LArWFParams2Ntuple::m_dumpPhysCaliTdiff
bool m_dumpPhysCaliTdiff
Definition: LArWFParams2Ntuple.h:39
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
LArTdriftP
Definition: LArTdriftP.h:11
LArWFParams2Ntuple::m_physCaliTDiffKey
std::string m_physCaliTDiffKey
Definition: LArWFParams2Ntuple.h:40
bin
Definition: BinsDiffFromStripMedian.h:43
LArWFParamsComplete.h
HWIdentifier
Definition: HWIdentifier.h:13
CaloGain::LARNGAIN
@ LARNGAIN
Definition: CaloGain.h:19
LArCond2NtupleBase::initialize
StatusCode initialize()
Definition: LArCond2NtupleBase.cxx:33
LArWFParams2Ntuple::m_dumpTdrift
bool m_dumpTdrift
Definition: LArWFParams2Ntuple.h:39
LArCond2NtupleBase
Definition: LArCond2NtupleBase.h:32
LArWFParamsContainer.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
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
LArWFParams2Ntuple.h
LArDetCellParamsP
Definition: LArDetCellParamsP.h:11
LArPhysCaliTdiffP
Definition: LArPhysCaliTdiffP.h:11
LArWFParams2Ntuple::m_caliPulseParamsKey
std::string m_caliPulseParamsKey
Definition: LArWFParams2Ntuple.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArOnlineID_Base::channel_range
id_range channel_range() const
Definition: LArOnlineID_Base.cxx:1936
LArOFCBinComplete.h
LArWFParams2Ntuple::m_ofcBinKey
std::string m_ofcBinKey
Definition: LArWFParams2Ntuple.h:40
LArPhysCaliTdiffComplete
This class implements the ILArPhysCaliTdiff interface ` *.
Definition: LArPhysCaliTdiffComplete.h:22
LArWFParams2Ntuple::m_detCellParamsKey
std::string m_detCellParamsKey
Definition: LArWFParams2Ntuple.h:40
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
LArCond2NtupleBase::m_ntpath
std::string m_ntpath
Definition: LArCond2NtupleBase.h:65
LArCaliPulseParamsComplete.h
LArCond2NtupleBase::m_nt
NTuple::Tuple * m_nt
Definition: LArCond2NtupleBase.h:68
WriteCellNoiseToCool.igain
igain
Definition: WriteCellNoiseToCool.py:338
LArOFCBinComplete
Definition: LArOFCBinComplete.h:13
LArCaliPulseParamsComplete
This class implements the ILArCaliPulseParams interface.
Definition: LArCaliPulseParamsComplete.h:27
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LArCond2NtupleBase::m_ntTitle
std::string m_ntTitle
Definition: LArCond2NtupleBase.h:65
LArWFParams2Ntuple::m_dumpDetCellParams
bool m_dumpDetCellParams
Definition: LArWFParams2Ntuple.h:39
LArCond2NtupleBase::m_onlineId
const LArOnlineID_Base * m_onlineId
Definition: LArCond2NtupleBase.h:85
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
LArCond2NtupleBase::fillFromIdentifier
bool fillFromIdentifier(const HWIdentifier &id)
Definition: LArCond2NtupleBase.cxx:288
LArWFParams2Ntuple::LArWFParams2Ntuple
LArWFParams2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArWFParams2Ntuple.cxx:15
LArWFParams2Ntuple::stop
virtual StatusCode stop()
Definition: LArWFParams2Ntuple.cxx:46
ILArCaliPulseParams::ERRORCODE
@ ERRORCODE
Definition: ILArCaliPulseParams.h:32
LArPhysCaliTdiffComplete.h
LArWFParams2Ntuple::m_dumpCaliPulseParams
bool m_dumpCaliPulseParams
Definition: LArWFParams2Ntuple.h:39
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
LArWFParams2Ntuple::~LArWFParams2Ntuple
~LArWFParams2Ntuple()
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
LArTdriftComplete.h
LArCaliPulseParamsP
Definition: LArCaliPulseParamsP.h:12
LArDetCellParamsComplete
This class implements the ILArDetCellParams interface.
Definition: LArDetCellParamsComplete.h:24
LArWFParams2Ntuple::m_dumpOFCBin
bool m_dumpOFCBin
Definition: LArWFParams2Ntuple.h:39