ATLAS Offline Software
LArRawChannelBuilderADC2EDataBase.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
8 
9 #include "Identifier/Identifier.h"
10 #include "StoreGate/StoreGateSvc.h"
14 
15 
17  const std::string& name,
18  const IInterface* parent):
20  m_onlineHelper(nullptr)
21 {
22  m_helper = new LArRawChannelBuilderStatistics( 3, // number of possible errors
23  0x20); // bit pattern special for this tool,
24  // to be stored in "uint16_t provenance"
25  m_helper->setErrorString(0, "no errors");
26  m_helper->setErrorString(1, "no DataBase");
27  m_helper->setErrorString(2, "bad Ramps");
28 
29  declareProperty("TestBadRamps", m_testRamps = true);
30 
31  declareProperty("RampMaxHighGain", m_ramp_max_high = 500.);
32  declareProperty("RampMaxMediumGain", m_ramp_max_medium = 5000.);
33  declareProperty("RampMaxLowGain", m_ramp_max_low = 50000.);
34 
35  declareProperty("UseHighGainRampIntercept", m_useIntercept_high = false);
36  declareProperty("UseMedGainRampIntercept", m_useIntercept_medium = true);
37  declareProperty("UseLowGainRampIntercept", m_useIntercept_low = true);
38 }
39 
41 {
43  return StatusCode::SUCCESS;
44 }
45 
47 {
48 
49  if ( m_isSC ) {
50  const LArOnline_SuperCellID* lonlID;
51  CHECK( detStore()->retrieve(lonlID, "LArOnline_SuperCellID") );
52  m_onlineHelper = lonlID;
53 
54  } else { // end of if m_isSC
55 
56  const LArOnlineID* lonlID;
57  CHECK( detStore()->retrieve(lonlID, "LArOnlineID") );
58  m_onlineHelper = lonlID;
59 
60  } // end of if m_isSC
61 
62  return StatusCode::SUCCESS;
63 }
64 
65 bool
67  std::vector<float>& Ramps, MsgStream* /*pLog*/)
68 {
69  //ADC2MeV (a.k.a. Ramp)
71  Ramps = adc2mev->ADC2MEV(m_parent->curr_chid,m_parent->curr_gain).asVector();
72 
73  //Check ramp coefficents
74  if (Ramps.empty()) {
75  ATH_MSG_DEBUG("No ADC2MeV data found for channel 0x" << MSG::hex
76  << m_parent->curr_chid.get_compact() << MSG::dec
77  << " Gain "<< m_parent->curr_gain << " Skipping channel.");
79  return false;
80  }
81 
82  // temporary fix for bad ramps... should be done in the DB
83  if( m_testRamps &&
86  (( m_parent->curr_gain == CaloGain::LARLOWGAIN ) && Ramps[1]>m_ramp_max_low) ||
87  Ramps[1]<0 ) )
88  {
89  ATH_MSG_DEBUG("Bad ramp for channel " << m_parent->curr_chid
90  << " (Ramps[1] = " << Ramps[1] << "): skip this channel");
92  return false;
93  }
94 
95  //use intercept ?
96  // for HEC treat medium gain as high gains in the others subsystems
97  bool useIntercept_medium = m_useIntercept_medium;
99 
101  (( m_parent->curr_gain != CaloGain::LARMEDIUMGAIN ) || !useIntercept_medium ) &&
103  Ramps[0]=0;
104 
105  /* //otherwise ignore intercept, E=0;
106  for (unsigned i=1;i<ramp.size();i++)
107  {
108  energy+=ramp[i]*ADCPeakPower; //pow(ADCPeak,i);
109  //std::cout << "Step "<< i <<":" << ramp[i] << " * " << pow(ADCPeak,i) << "Sum=" << energy << std::endl;
110  ADCPeakPower*=Peak;
111  }
112  */
113  /*
114  energy=Peak;
115  m_helper->incrementErrorCount(1);
116 
117  return false;
118  */
119  // (*pLog) << MSG::VERBOSE << "ADC2EDataBase tool - energy : " << energy << endmsg;
122 
123  return true;
124 }
125 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArRawChannelBuilderADC2EDataBase::m_useIntercept_medium
bool m_useIntercept_medium
Definition: LArRawChannelBuilderADC2EDataBase.h:49
LArRawChannelBuilderADC2EDataBase::initialize
virtual StatusCode initialize() override
Definition: LArRawChannelBuilderADC2EDataBase.cxx:40
LArRawChannelBuilderParams::curr_gain
CaloGain::CaloGain curr_gain
Definition: LArRawChannelBuilderParams.h:25
LArADC2MeV::ADC2MEV
const LArVectorProxy ADC2MEV(const HWIdentifier &id, int gain) const
Definition: LArADC2MeV.h:32
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
LArRawChannelBuilderADC2EDataBase::m_adc2mevKey
SG::ReadCondHandleKey< LArADC2MeV > m_adc2mevKey
Definition: LArRawChannelBuilderADC2EDataBase.h:41
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
LArRawChannelBuilderADC2EDataBase::initTool
virtual StatusCode initTool() override
Definition: LArRawChannelBuilderADC2EDataBase.cxx:46
LArRawChannelBuilderADC2EDataBase::m_ramp_max_medium
float m_ramp_max_medium
Definition: LArRawChannelBuilderADC2EDataBase.h:45
LArRawChannelBuilderStatistics::setErrorString
void setErrorString(unsigned int nerr, const std::string &s)
Definition: LArRawChannelBuilderStatistics.cxx:69
LArRawChannelBuilderADC2EDataBase.h
LArRawChannelBuilderStatistics
Returns various counters from the LArRawChannel building.
Definition: LArRawChannelBuilderStatistics.h:21
LArRawChannelBuilderStatistics::incrementErrorCount
void incrementErrorCount(unsigned int nerr)
Definition: LArRawChannelBuilderStatistics.cxx:34
ReadCondHandle.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
LArRawChannelBuilderADC2EDataBase::m_useIntercept_high
bool m_useIntercept_high
Definition: LArRawChannelBuilderADC2EDataBase.h:48
LArRawChannelBuilderADC2EDataBase::m_ramp_max_high
float m_ramp_max_high
Definition: LArRawChannelBuilderADC2EDataBase.h:44
LArRawChannelBuilderADC2EDataBase::m_useIntercept_low
bool m_useIntercept_low
Definition: LArRawChannelBuilderADC2EDataBase.h:50
LArOnlineID_Base::isHECchannel
virtual bool isHECchannel(const HWIdentifier id) const =0
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
LArRawChannelBuilderADC2EDataBase::m_ramp_max_low
float m_ramp_max_low
Definition: LArRawChannelBuilderADC2EDataBase.h:46
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
LArRawChannelBuilderToolBaseClass::m_helper
LArRawChannelBuilderStatistics * m_helper
Definition: LArRawChannelBuilderToolBaseClass.h:82
LArRawChannelBuilderADC2EToolBase
Interface definition for Tools to Convert ADC to energy.
Definition: LArRawChannelBuilderADC2EToolBase.h:24
LArRawChannelBuilderToolBaseClass::m_isSC
bool m_isSC
Definition: LArRawChannelBuilderToolBaseClass.h:84
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LArRawChannelBuilderADC2EDataBase::ADC2E
virtual bool ADC2E(const EventContext &ctx, std::vector< float > &Ramps, MsgStream *pLog) override
Definition: LArRawChannelBuilderADC2EDataBase.cxx:66
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArOnlineID
Definition: LArOnlineID.h:20
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
LArOnline_SuperCellID
Definition: LArOnline_SuperCellID.h:20
CaloGain::LARMEDIUMGAIN
@ LARMEDIUMGAIN
Definition: CaloGain.h:18
Identifier::get_compact
value_type get_compact(void) const
Get the compact id.
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LArVectorProxy::asVector
std::vector< value_type > asVector() const
Convert back to a vector.
LArOnline_SuperCellID.h
LArRawChannelBuilderStatistics.h
CaloGain::LARLOWGAIN
@ LARLOWGAIN
Definition: CaloGain.h:18
LArRawChannelBuilderStatistics::returnBitPattern
unsigned int returnBitPattern() const
Definition: LArRawChannelBuilderStatistics.cxx:85
LArRawChannelBuilderADC2EDataBase::m_testRamps
bool m_testRamps
Definition: LArRawChannelBuilderADC2EDataBase.h:43
LArRawChannelBuilderADC2EDataBase::LArRawChannelBuilderADC2EDataBase
LArRawChannelBuilderADC2EDataBase(const std::string &type, const std::string &name, const IInterface *parent)
Definition: LArRawChannelBuilderADC2EDataBase.cxx:16
LArRawChannelBuilderParams::curr_chid
HWIdentifier curr_chid
Definition: LArRawChannelBuilderParams.h:24
StoreGateSvc.h
LArRawChannelBuilderParams::qualityBitPattern
unsigned int qualityBitPattern
Definition: LArRawChannelBuilderParams.h:34
LArRawChannelBuilderADC2EDataBase::m_onlineHelper
const LArOnlineID_Base * m_onlineHelper
Definition: LArRawChannelBuilderADC2EDataBase.h:52
LArRawChannelBuilderToolBaseClass::m_parent
LArRawChannelBuilderParams * m_parent
Definition: LArRawChannelBuilderToolBaseClass.h:80
LArOnlineID.h