ATLAS Offline Software
LArAccumulatedDigits2Ntuple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 //#include "GaudiKernel/ToolHandle.h"
9 
10 LArAccumulatedDigits2Ntuple::LArAccumulatedDigits2Ntuple(const std::string& name, ISvcLocator* pSvcLocator):
11  LArCond2NtupleBase(name, pSvcLocator),
12  m_ipass(0),
13  m_event(0)
14 {
15  m_ntTitle="AccumulatedDigits";
16  m_ntpath="/NTUPLES/FILE1/ACCUMULATEDDIGITS"+m_contKey.key();
17 
18 }
19 
21 = default;
22 
23 
25 {
26  ATH_MSG_INFO( "in initialize" );
27 
29  if (sc!=StatusCode::SUCCESS) {
30  ATH_MSG_ERROR( "Base init failed" );
31  return StatusCode::FAILURE;
32  }
33 
34 
35 
36  sc=m_nt->addItem("IEvent",m_IEvent);
37  if (sc!=StatusCode::SUCCESS) {
38  ATH_MSG_ERROR( "addItem 'IEvent' failed" );
39  return sc;
40  }
41 
42  sc=m_nt->addItem("EventNum",m_EventNum);
43  if (sc!=StatusCode::SUCCESS) {
44  ATH_MSG_ERROR( "addItem 'EventNum' failed" );
45  return sc;
46  }
47 
48  sc=m_nt->addItem("Ntrigger",m_Ntrigger,0,500);
49  if (sc!=StatusCode::SUCCESS) {
50  ATH_MSG_ERROR( "addItem 'Ntrigger' failed" );
51  return sc;
52  }
53 
54  sc=m_nt->addItem("Nsamples",m_ntNsamples,0,32);
55  if (sc!=StatusCode::SUCCESS) {
56  ATH_MSG_ERROR( "addItem 'Nsamples' failed" );
57  return sc;
58  }
59 
60  sc=m_nt->addItem("Sum",m_Nsamples,m_sum);
61  if (sc!=StatusCode::SUCCESS) {
62  ATH_MSG_ERROR( "addItem 'sum' failed" );
63  return sc;
64  }
65 
66  sc=m_nt->addItem("Sumsq",m_Nsamples,m_sumsq);
67  if (sc!=StatusCode::SUCCESS) {
68  ATH_MSG_ERROR( "addItem 'sumsq' failed" );
69  return sc;
70  }
71 
72  sc=m_nt->addItem("Mean",m_mean);
73  if (sc!=StatusCode::SUCCESS) {
74  ATH_MSG_ERROR( "addItem 'mean' failed" );
75  return sc;
76  }
77 
78  sc=m_nt->addItem("RMS",m_rms);
79  if (sc!=StatusCode::SUCCESS) {
80  ATH_MSG_ERROR( "addItem 'rms' failed" );
81  return sc;
82  }
83 
84  sc=m_nt->addItem("covr",m_Nsamples-1,m_covr);
85  if (sc!=StatusCode::SUCCESS) {
86  ATH_MSG_ERROR( "addItem 'covr' failed" );
87  return sc;
88  }
89 
91 
92  m_ipass = 0;
93  m_event=0;
94 
95  return StatusCode::SUCCESS;
96 
97 }
98 
100 {
101 
102  ATH_MSG_DEBUG( "in execute" );
103  StatusCode sc;
104 
105  if (m_contKey.key().empty()) return StatusCode::SUCCESS;
106 
107  const EventContext& ctx = Gaudi::Hive::currentContext();
108 
109  m_event++;
110 
111  const LArAccumulatedDigitContainer* accuDigitContainer = nullptr;
113  if (!Hdl.isValid()) {
114  ATH_MSG_WARNING( "Unable to retrieve LArAccumulatedDigitContainer with key " << m_contKey.key() << " from DetectorStore. " );
115  return StatusCode::SUCCESS;
116  } else {
117  ATH_MSG_DEBUG( "Got LArAccumulatedDigitContainer with key " << m_contKey.key() );
118  accuDigitContainer = Hdl.cptr();
119  }
120 
121  if (accuDigitContainer) {
122 
123  if(accuDigitContainer->empty()) {
124  ATH_MSG_DEBUG( "LArAccumulatedDigitContainer with key=" << m_contKey << " is empty " );
125  return StatusCode::SUCCESS;
126  }else{
127  ATH_MSG_DEBUG( "LArAccumulatedDigitContainer with key=" << m_contKey << " has " <<accuDigitContainer->size() << " entries" );
128  }
129 
130  for (const LArAccumulatedDigit* digit : *accuDigitContainer) {
131 
132  m_IEvent = m_event;
133  m_EventNum = ctx.eventID().event_number();
134  m_Ntrigger = digit->nTrigger();
135  unsigned int trueMaxSample = digit->nsample();
136  m_ntNsamples = trueMaxSample;
137 
138  if(trueMaxSample>m_Nsamples){
139  if(!m_ipass){
140  ATH_MSG_WARNING( "The number of samples in data is larger than the one specified by JO: " << trueMaxSample << " > " << m_Nsamples << " --> only " << m_Nsamples << " will be available in the ntuple " );
141  m_ipass=1;
142  }
143  trueMaxSample = m_Nsamples;
144  }
145 
146  m_mean = digit->mean();
147  m_rms = digit->RMS();
148  const std::vector<uint64_t> sampleSquare = digit->sampleSquare();
149  const std::vector<uint64_t> sampleSum = digit->sampleSum();
150  for(unsigned i=0;i<trueMaxSample;i++) {
151  m_sumsq[i] = sampleSquare[i];
152  m_sum[i] = sampleSum[i];
153  }
154  std::vector<float> cov;
155  digit->getCov(cov,m_normalize);
156  for(unsigned i=0;i<trueMaxSample-1;i++) {
157  m_covr[i] = cov[i];
158  }
159 
160  fillFromIdentifier(digit->hardwareID());
161  sc=ntupleSvc()->writeRecord(m_nt);
162  if (sc!=StatusCode::SUCCESS) {
163  ATH_MSG_ERROR( "writeRecord failed" );
164  return sc;
165  }
166  }
167  }
168  return StatusCode::SUCCESS;
169 }// end execute method.
LArAccumulatedDigits2Ntuple::m_sumsq
NTuple::Array< long > m_sumsq
Definition: LArAccumulatedDigits2Ntuple.h:46
LArAccumulatedDigits2Ntuple::execute
virtual StatusCode execute() override final
Definition: LArAccumulatedDigits2Ntuple.cxx:99
LArAccumulatedDigits2Ntuple::LArAccumulatedDigits2Ntuple
LArAccumulatedDigits2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArAccumulatedDigits2Ntuple.cxx:10
LArAccumulatedDigits2Ntuple::m_covr
NTuple::Array< float > m_covr
Definition: LArAccumulatedDigits2Ntuple.h:49
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArAccumulatedDigitContainer
Container class for LArAccumulatedDigit.
Definition: LArAccumulatedDigitContainer.h:22
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
LArAccumulatedDigitContainer.h
LArAccumulatedDigits2Ntuple::m_normalize
Gaudi::Property< int > m_normalize
Definition: LArAccumulatedDigits2Ntuple.h:34
LArAccumulatedDigits2Ntuple::m_EventNum
NTuple::Item< long > m_EventNum
Definition: LArAccumulatedDigits2Ntuple.h:43
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
LArAccumulatedDigits2Ntuple::m_event
long m_event
Definition: LArAccumulatedDigits2Ntuple.h:39
LArAccumulatedDigits2Ntuple::m_rms
NTuple::Item< float > m_rms
Definition: LArAccumulatedDigits2Ntuple.h:48
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
LArAccumulatedDigits2Ntuple::initialize
virtual StatusCode initialize() override final
Definition: LArAccumulatedDigits2Ntuple.cxx:24
LArCond2NtupleBase::initialize
StatusCode initialize()
Definition: LArCond2NtupleBase.cxx:33
LArCond2NtupleBase
Definition: LArCond2NtupleBase.h:32
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
LArAccumulatedDigits2Ntuple::m_IEvent
NTuple::Item< long > m_IEvent
Definition: LArAccumulatedDigits2Ntuple.h:42
LArAccumulatedDigit
Data class for ADC samples and autocorr preprocessed by the DSP.
Definition: LArAccumulatedDigit.h:32
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
LArAccumulatedDigits2Ntuple::m_mean
NTuple::Item< float > m_mean
Definition: LArAccumulatedDigits2Ntuple.h:47
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LArAccumulatedDigits2Ntuple::m_Ntrigger
NTuple::Item< long > m_Ntrigger
Definition: LArAccumulatedDigits2Ntuple.h:41
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArCond2NtupleBase::m_ntpath
std::string m_ntpath
Definition: LArCond2NtupleBase.h:65
LArCond2NtupleBase::m_nt
NTuple::Tuple * m_nt
Definition: LArCond2NtupleBase.h:68
LArAccumulatedDigits2Ntuple::m_ntNsamples
NTuple::Item< long > m_ntNsamples
Definition: LArAccumulatedDigits2Ntuple.h:44
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArAccumulatedDigits2Ntuple::m_contKey
SG::ReadHandleKey< LArAccumulatedDigitContainer > m_contKey
Definition: LArAccumulatedDigits2Ntuple.h:36
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
LArAccumulatedDigits2Ntuple::m_Nsamples
Gaudi::Property< unsigned int > m_Nsamples
Definition: LArAccumulatedDigits2Ntuple.h:35
LArAccumulatedDigits2Ntuple::~LArAccumulatedDigits2Ntuple
~LArAccumulatedDigits2Ntuple()
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
LArCond2NtupleBase::m_ntTitle
std::string m_ntTitle
Definition: LArCond2NtupleBase.h:65
LArCond2NtupleBase::fillFromIdentifier
bool fillFromIdentifier(const HWIdentifier &id)
Definition: LArCond2NtupleBase.cxx:288
LArAccumulatedDigits2Ntuple::m_sum
NTuple::Array< long > m_sum
Definition: LArAccumulatedDigits2Ntuple.h:45
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArAccumulatedDigits2Ntuple::m_ipass
int m_ipass
Definition: LArAccumulatedDigits2Ntuple.h:38
LArAccumulatedDigits2Ntuple.h
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.