ATLAS Offline Software
Loading...
Searching...
No Matches
LArAverages2Ntuple.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
9
10LArAverages2Ntuple::LArAverages2Ntuple(const std::string& name, ISvcLocator* pSvcLocator):
11 LArCond2NtupleBase(name, pSvcLocator),m_event(0),m_pass(false)
12{ }
13
15{
16 ATH_MSG_INFO ( "in initialize" );
17
18 StatusCode sc;
19 if ( m_isSC ){
20 const LArOnline_SuperCellID* ll;
21 sc = detStore()->retrieve(ll, "LArOnline_SuperCellID");
22 if (sc.isFailure()) {
23 ATH_MSG_ERROR( "Could not get LArOnlineID helper !" );
24 return StatusCode::FAILURE;
25 }
26 else {
27 m_onlineHelper = dynamic_cast<const LArOnlineID_Base*>(ll);
28 ATH_MSG_DEBUG("Found the LArOnlineID helper");
29 }
30 } else { // m_isSC
31 const LArOnlineID* ll;
32 sc = detStore()->retrieve(ll, "LArOnlineID");
33 if (sc.isFailure()) {
34 ATH_MSG_ERROR( "Could not get LArOnlineID helper !" );
35 return StatusCode::FAILURE;
36 }
37 else {
38 m_onlineHelper = dynamic_cast<const LArOnlineID_Base*>(ll);
39 ATH_MSG_DEBUG(" Found the LArOnlineID helper. ");
40 }
41 }
42 m_ntName = "AVERAGES";
43 m_ntTitle="Averages";
44 m_ntpath=std::string("/NTUPLES/FILE1/")+m_ntName+m_contKey.key();
45
47
48 ATH_CHECK( m_nt->addItem("IEvent",m_IEvent) );
49 ATH_CHECK( m_nt->addItem("EventNum",m_EventNum) );
50 ATH_CHECK( m_nt->addItem("DAC",m_DAC,0,65535) );
51 ATH_CHECK( m_nt->addItem("isPulsed",m_isPulsed,0,1) );
52 ATH_CHECK( m_nt->addItem("delay",m_delay,0,240) );
53 ATH_CHECK( m_nt->addItem("Ntrigger",m_Ntrigger,0,500) );
54 ATH_CHECK( m_nt->addItem("Nsamples",m_ntNsamples,0,32) );
55 ATH_CHECK( m_nt->addItem("Nsteps",m_Nsteps,0,50) );
56 ATH_CHECK( m_nt->addItem("StepIndex",m_StepIndex,0,100) );
57
58 static const int maxSamples = m_Nsamples;
59 ATH_CHECK( m_nt->addItem("Sum",maxSamples,m_Sum) );
60 ATH_CHECK( m_nt->addItem("SumSq",maxSamples,m_SumSq) );
61 ATH_CHECK( m_nt->addItem("Mean",maxSamples,m_Mean) );
62 ATH_CHECK( m_nt->addItem("RMS",maxSamples,m_RMS) );
63
64 ATH_CHECK( m_contKey.initialize( !m_contKey.key().empty() ));
65 return StatusCode::SUCCESS;
66
67}
68
70{
71 ATH_MSG_DEBUG ( "in execute" );
72
73 const EventContext& ctx = Gaudi::Hive::currentContext();
74
75 const LArAccumulatedCalibDigitContainer* accuDigitContainer = nullptr;
77 if (!Hdl.isValid()) {
78 ATH_MSG_WARNING ( "Unable to retrieve LArAccumulatedCalibDigitContainer with key " << m_contKey << " from DetectorStore. " );
79 return StatusCode::SUCCESS;
80 } else {
81 ATH_MSG_DEBUG ( "Got LArAccumulatedCalibDigitContainer with key " << m_contKey );
82 accuDigitContainer = Hdl.cptr();
83 }
84
87
88 if(it == it_e) {
89 ATH_MSG_WARNING ( "LArAccumulatedCalibDigitContainer with key=" << m_contKey << " is empty " );
90 return StatusCode::SUCCESS;
91 }else{
92 ATH_MSG_DEBUG ( "LArAccumulatedCalibDigitContainer with key=" << m_contKey << " has " <<accuDigitContainer->size() << " entries" );
93 }
94
95 for (;it!=it_e;++it) {
96 // Add protection - Modif from JF. Marchand
97 if ( !(*it) ) continue;
98
100 m_EventNum = ctx.eventID().event_number();
101 HWIdentifier chid=(*it)->channelID();
102 m_isPulsed = (long)(*it)->isPulsed();
103 if(m_keepPulsed && !(*it)->isPulsed()) continue;
104 m_DAC = (*it)->DAC();
105 m_Nsteps = (*it)->nSteps();
106 m_Ntrigger = (*it)->nTriggers();
107 m_delay = (*it)->delay();
108 m_StepIndex=(*it)->stepIndex();
109 unsigned int trueMaxSample = (*it)->nsamples();
110 m_ntNsamples = trueMaxSample;
111
112 if(trueMaxSample>m_Nsamples){
113 if(!m_pass){
114 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 " );
115 m_pass=true;
116 }
117 trueMaxSample = m_Nsamples;
118 }
119
120 const std::vector<unsigned long>& sampleSum = (*it)->sampleSum();
121 const std::vector<unsigned long>& sampleSum2 = (*it)->sample2Sum();
122 const std::vector<float>& mean = (*it)->mean();
123 const std::vector<float>& RMSv = (*it)->RMS();
124
125 for(unsigned int j=0;j<trueMaxSample;j++){
126 m_Sum[j] = sampleSum[j];
127 m_SumSq[j] = sampleSum2[j];
128 if(m_Ntrigger){
129 m_Mean[j] = mean[j];
130 m_RMS[j] = RMSv[j];
131 } else {
132 m_Mean[j]=0;
133 m_RMS[j]=0;
134 }
135
136 }
137
138 int FT=m_onlineHelper->feedthrough(chid);
139 if(m_keepFT.size() > 0) {
140 if(std::find(std::begin(m_keepFT), std::end(m_keepFT), FT) == std::end(m_keepFT)) continue;
141 }
142
143 fillFromIdentifier(chid);
144 ATH_CHECK( ntupleSvc()->writeRecord(m_nt) );
145 }//end loop over cells
146 m_event++;
147 return StatusCode::SUCCESS;
148}// end execute method.
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
INTupleSvc * ntupleSvc()
const ServiceHandle< StoreGateSvc > & detStore() const
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
Container class for LArAccumulatedCalibDigit.
NTuple::Array< float > m_Mean
NTuple::Item< long > m_DAC
Gaudi::Property< std::vector< unsigned int > > m_keepFT
Gaudi::Property< bool > m_keepPulsed
LArAverages2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
NTuple::Item< long > m_Nsteps
NTuple::Item< unsigned long long > m_EventNum
virtual StatusCode execute() override final
NTuple::Array< unsigned int > m_SumSq
NTuple::Item< long > m_delay
virtual StatusCode initialize() override final
NTuple::Item< long > m_Ntrigger
NTuple::Array< float > m_RMS
unsigned long long m_event
NTuple::Item< long > m_isPulsed
NTuple::Item< unsigned long long > m_IEvent
SG::ReadHandleKey< LArAccumulatedCalibDigitContainer > m_contKey
Gaudi::Property< unsigned int > m_Nsamples
const LArOnlineID_Base * m_onlineHelper
NTuple::Array< unsigned int > m_Sum
NTuple::Item< unsigned long > m_StepIndex
NTuple::Item< long > m_ntNsamples
Gaudi::Property< bool > m_isSC
bool fillFromIdentifier(const HWIdentifier &id)
LArCond2NtupleBase(const std::string &name, ISvcLocator *pSvcLocator)
Helper for the Liquid Argon Calorimeter cell identifiers.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")