ATLAS Offline Software
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 
10 LArAverages2Ntuple::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 ){
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 
86  LArAccumulatedCalibDigitContainer::const_iterator it_e=accuDigitContainer->end();
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 
99  m_IEvent = m_event;
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) {
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.
LArAverages2Ntuple::initialize
virtual StatusCode initialize() override final
Definition: LArAverages2Ntuple.cxx:14
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
LArAverages2Ntuple::m_StepIndex
NTuple::Item< unsigned long > m_StepIndex
Definition: LArAverages2Ntuple.h:55
mean
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="")
Definition: dependence.cxx:254
LArAverages2Ntuple::m_SumSq
NTuple::Array< unsigned int > m_SumSq
Definition: LArAverages2Ntuple.h:58
detail::ll
long long ll
Definition: PrimitiveHelpers.h:47
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
LArAverages2Ntuple::m_contKey
SG::ReadHandleKey< LArAccumulatedCalibDigitContainer > m_contKey
Definition: LArAverages2Ntuple.h:36
LArAverages2Ntuple::m_ntName
std::string m_ntName
Definition: LArAverages2Ntuple.h:41
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
LArAverages2Ntuple::m_keepPulsed
Gaudi::Property< bool > m_keepPulsed
Definition: LArAverages2Ntuple.h:38
LArAverages2Ntuple::m_EventNum
NTuple::Item< unsigned long long > m_EventNum
Definition: LArAverages2Ntuple.h:47
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
skel.it
it
Definition: skel.GENtoEVGEN.py:396
LArAverages2Ntuple::m_event
unsigned long long m_event
Definition: LArAverages2Ntuple.h:43
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
HWIdentifier
Definition: HWIdentifier.h:13
LArCond2NtupleBase::initialize
StatusCode initialize()
Definition: LArCond2NtupleBase.cxx:33
LArAverages2Ntuple::m_onlineHelper
const LArOnlineID_Base * m_onlineHelper
Definition: LArAverages2Ntuple.h:34
LArCond2NtupleBase
Definition: LArCond2NtupleBase.h:32
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
CaloCell_ID.h
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
LArAverages2Ntuple::m_pass
bool m_pass
Definition: LArAverages2Ntuple.h:44
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
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
LArCond2NtupleBase::m_ntpath
std::string m_ntpath
Definition: LArCond2NtupleBase.h:65
LArAverages2Ntuple::m_Mean
NTuple::Array< float > m_Mean
Definition: LArAverages2Ntuple.h:59
LArAverages2Ntuple::m_IEvent
NTuple::Item< unsigned long long > m_IEvent
Definition: LArAverages2Ntuple.h:46
LArCond2NtupleBase::m_nt
NTuple::Tuple * m_nt
Definition: LArCond2NtupleBase.h:68
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
LArAverages2Ntuple::m_delay
NTuple::Item< long > m_delay
Definition: LArAverages2Ntuple.h:51
LArAverages2Ntuple::m_Sum
NTuple::Array< unsigned int > m_Sum
Definition: LArAverages2Ntuple.h:57
LArAverages2Ntuple::LArAverages2Ntuple
LArAverages2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArAverages2Ntuple.cxx:10
LArOnlineID_Base
Helper for the Liquid Argon Calorimeter cell identifiers.
Definition: LArOnlineID_Base.h:105
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
LArCond2NtupleBase::m_ntTitle
std::string m_ntTitle
Definition: LArCond2NtupleBase.h:65
LArOnlineID
Definition: LArOnlineID.h:20
LArOnline_SuperCellID
Definition: LArOnline_SuperCellID.h:20
LArAverages2Ntuple::m_DAC
NTuple::Item< long > m_DAC
Definition: LArAverages2Ntuple.h:49
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
LArNewCalib_Delay_OFC_Cali.FT
FT
Definition: LArNewCalib_Delay_OFC_Cali.py:124
LArCond2NtupleBase::fillFromIdentifier
bool fillFromIdentifier(const HWIdentifier &id)
Definition: LArCond2NtupleBase.cxx:288
LArAverages2Ntuple::m_Nsamples
Gaudi::Property< unsigned int > m_Nsamples
Definition: LArAverages2Ntuple.h:37
LArOnlineID_Base::feedthrough
int feedthrough(const HWIdentifier id) const
Return the feedthrough of a hardware cell identifier : feedthrough = [0,31] Barrel - A/C side or H/...
Definition: LArOnlineID_Base.cxx:1944
LArAverages2Ntuple::execute
virtual StatusCode execute() override final
Definition: LArAverages2Ntuple.cxx:69
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArCond2NtupleBase::m_isSC
Gaudi::Property< bool > m_isSC
Definition: LArCond2NtupleBase.h:55
LArAverages2Ntuple::m_isPulsed
NTuple::Item< long > m_isPulsed
Definition: LArAverages2Ntuple.h:53
LArAverages2Ntuple::m_Ntrigger
NTuple::Item< long > m_Ntrigger
Definition: LArAverages2Ntuple.h:50
LArOnline_SuperCellID.h
LArAverages2Ntuple::m_ntNsamples
NTuple::Item< long > m_ntNsamples
Definition: LArAverages2Ntuple.h:52
LArAverages2Ntuple::m_keepFT
Gaudi::Property< std::vector< unsigned int > > m_keepFT
Definition: LArAverages2Ntuple.h:39
LArAverages2Ntuple.h
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
LArAccumulatedCalibDigitContainer
Container class for LArAccumulatedCalibDigit.
Definition: LArAccumulatedCalibDigitContainer.h:25
LArAverages2Ntuple::m_Nsteps
NTuple::Item< long > m_Nsteps
Definition: LArAverages2Ntuple.h:48
LArAverages2Ntuple::m_RMS
NTuple::Array< float > m_RMS
Definition: LArAverages2Ntuple.h:60
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.