ATLAS Offline Software
LArRawChannelBuilderToolParabola.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 #include "GaudiKernel/MsgStream.h"
8 #include "GaudiKernel/StatusCode.h"
9 
11 #include "Identifier/Identifier.h"
12 
13 #include "LArRawEvent/LArDigit.h"
14 #include <cmath>
15 
16 #define MAXINT 2147483000
17 #define MAXINT2 -2147483000
18 
19 
21  const std::string& name,
22  const IInterface* parent):
24  m_parabolaRecoTool("LArOFPeakRecoTool"),
25  m_emId(nullptr)
26 {
27  m_helper = new LArRawChannelBuilderStatistics( 3, // number of possible errors
28  0x03); // bit pattern special for this tool,
29  // to be stored in "uint16_t provenance"
30  m_helper->setErrorString(0, "no errors");
31  m_helper->setErrorString(1, "Fit failed");
32  m_helper->setErrorString(2, "is FCAL");
33 }
34 
36 {
37  ATH_CHECK( m_parabolaRecoTool.retrieve() );
38 
39  const CaloCell_ID* idHelper = nullptr;
40  ATH_CHECK( detStore()->retrieve (idHelper, "CaloCell_ID") );
41  m_emId=idHelper->em_idHelper();
42 
43  return StatusCode::SUCCESS;
44 }
45 
47  float pedestal,
48  const std::vector<float>& ramps,
49  MsgStream* /* pLog */ )
50 {
51  float ADCPeak=0;
52 
53  int time=0;
54  uint16_t iquality=0;
55  uint16_t iprovenance=0;
56 
57  int layer=0;
60 
61  std::vector<float> peak = m_parabolaRecoTool->peak(digit->samples(),
62  layer, pedestal);
63  ADCPeak=peak[0]-pedestal;
64  float power=1;
65  float energy=0;
66  for( unsigned int i=0; i<ramps.size(); i++)
67  {
68  energy += ramps[i] * power;
69  power *= ADCPeak;
70  }
71 
72  if(peak.size()==2)
73  time = int(peak[1]);
74  else
75  time = int(peak[2]);
76 
77  // store which tool created this channel
78  iprovenance |= m_parent->qualityBitPattern;
79  iprovenance |= m_helper->returnBitPattern();
80  iprovenance = iprovenance & 0x3FFF;
81 
82  const float fMAXINT = static_cast<float>(MAXINT);
83  const float fMAXINT2 = static_cast<float>(MAXINT2);
84 
85  if (time>MAXINT) time=MAXINT;
86  if (time<MAXINT2) time=MAXINT2;
87 
88  if (energy>fMAXINT) energy=fMAXINT;
89  if (energy<fMAXINT2) energy=fMAXINT2;
90 
91 
92  // Suppress false positive seen wth gcc.
93 #if __GNUC__ >= 11 && __GNUC__ <= 13
94 # pragma GCC diagnostic push
95 # pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
96 #endif
97  (this->*m_buildIt)((int)(floor(energy+0.5)),time,iquality,iprovenance,digit);
98 #if __GNUC__ >= 11 && __GNUC__ <= 13
99 # pragma GCC diagnostic pop
100 #endif
101 
103 
104  return true;
105 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArRawChannelBuilderToolParabola::m_emId
const LArEM_ID * m_emId
Definition: LArRawChannelBuilderToolParabola.h:41
CaloCell_ID::em_idHelper
const LArEM_ID * em_idHelper() const
access to EM idHelper
Definition: CaloCell_ID.h:63
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
LArRawChannelBuilderToolParabola::initTool
StatusCode initTool()
Definition: LArRawChannelBuilderToolParabola.cxx:35
LArRawChannelBuilderStatistics::setErrorString
void setErrorString(unsigned int nerr, const std::string &s)
Definition: LArRawChannelBuilderStatistics.cxx:69
LArEM_Base_ID::sampling
int sampling(const Identifier id) const
return sampling according to :
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
LArRawChannelBuilderStatistics
Returns various counters from the LArRawChannel building.
Definition: LArRawChannelBuilderStatistics.h:21
LArRawChannelBuilderStatistics::incrementErrorCount
void incrementErrorCount(unsigned int nerr)
Definition: LArRawChannelBuilderStatistics.cxx:34
CaloCell_ID.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
LArDigit.h
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
LArDigit
Liquid Argon digit base class.
Definition: LArDigit.h:25
lumiFormat.i
int i
Definition: lumiFormat.py:92
LArRawChannelBuilderToolBase::energy
int energy()
Definition: LArRawChannelBuilderToolBase.h:46
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
test_pyathena.parent
parent
Definition: test_pyathena.py:15
LArRawChannelBuilderToolBase
Base tool to make the interface with the driver.
Definition: LArRawChannelBuilderToolBase.h:33
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloCell_ID
Helper class for offline cell identifiers.
Definition: CaloCell_ID.h:34
LArRawChannelBuilderToolBaseClass::m_helper
LArRawChannelBuilderStatistics * m_helper
Definition: LArRawChannelBuilderToolBaseClass.h:82
LArRawChannelBuilderToolBase::m_buildIt
void(LArRawChannelBuilderToolBase::* m_buildIt)(int energy, int time, uint16_t quality, uint16_t provenance, const LArDigit *digit)
Definition: LArRawChannelBuilderToolBase.h:57
LArRawChannelBuilderToolParabola.h
MAXINT2
#define MAXINT2
Definition: LArRawChannelBuilderToolParabola.cxx:17
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LArRawChannelBuilderToolBaseClass::currentID
Identifier currentID()
Definition: LArRawChannelBuilderToolBaseClass.cxx:94
MAXINT
#define MAXINT
Definition: LArRawChannelBuilderToolParabola.cxx:16
LArEM_Base_ID::is_em_barrel
bool is_em_barrel(const Identifier id) const
test if the id belongs to the EM barrel
LArRawChannelBuilderToolParabola::buildRawChannel
bool buildRawChannel(const LArDigit *digit, float pedestal, const std::vector< float > &ramps, MsgStream *pLog)
Definition: LArRawChannelBuilderToolParabola.cxx:46
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LArRawChannelBuilderToolParabola::m_parabolaRecoTool
ToolHandle< LArParabolaPeakRecoTool > m_parabolaRecoTool
Definition: LArRawChannelBuilderToolParabola.h:39
LArRawChannelBuilderToolBase::time
int time()
Definition: LArRawChannelBuilderToolBase.h:47
LArRawChannelBuilderStatistics::returnBitPattern
unsigned int returnBitPattern() const
Definition: LArRawChannelBuilderStatistics.cxx:85
LArRawChannelBuilderParams::qualityBitPattern
unsigned int qualityBitPattern
Definition: LArRawChannelBuilderParams.h:34
LArRawChannelBuilderToolBaseClass::m_parent
LArRawChannelBuilderParams * m_parent
Definition: LArRawChannelBuilderToolBaseClass.h:80
LArRawChannelBuilderToolParabola::LArRawChannelBuilderToolParabola
LArRawChannelBuilderToolParabola(const std::string &type, const std::string &name, const IInterface *parent)
Definition: LArRawChannelBuilderToolParabola.cxx:20