ATLAS Offline Software
LUCID_PileUpTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "LUCID_PileUpTool.h"
6 
9 #include "CLHEP/Random/RandomEngine.h"
11 
12 
13 #include "GaudiKernel/ITHistSvc.h"
14 
15 #include <map>
16 #include <algorithm>
17 
20  const std::string& name,
21  const IInterface* parent) :
24  40,//m_numTubes
25  15.0,//m_qdcChannelsPerPE
26  150.0,//m_qdcPedestal
27  3.0,//m_qdcFedNoiseFactor
28  2.8,//m_tdcPmtNoiseFactor
29  0.8,//m_tdcFedNoiseFactor
30  1.25e6,//m_TotalPMTgain
31  7.5,//m_AmpFactor
32  0.1e-12,//m_Q1bin
33  541666,//m_NoiseCharge
34  10,//m_numDyinodes
35  1.356,//m_dynodeGammaFactor
36  {0.000001}, //m_pmtSmearing
37  {0.000001}, //m_pmtScaling
38  {0.000001}, //m_gasScaling
39  {0.000001,0.000001,0.000001,0.000001,0.000001,
40  0.000001,0.000001,0.000001,0.000001,0.000001,
41  0.000001,0.000001,0.000001,0.000001,0.000001},//15 values m_npeThreshold
42  false), //m_fillRootTree
43  m_key_digitCnt ("Lucid_Digits")
44 {
45  declareProperty("SimHitCollection" ,
46  m_SimHitCollectionName = "LucidSimHitsVector",
47  "Name of the input Collection of simulated hits");
48  declareProperty("LucidDigitsContainer",
49  m_digitsContainerName = "LucidDigitsCnt",
50  "Name of the Container to hold the output from the digitization");
51 
52  declareProperty("numTubes" , m_numTubes);
53  declareProperty("qdcChannelsPerPE" , m_qdcChannelsPerPE);
54  declareProperty("qdcPedestal" , m_qdcPedestal);
55  declareProperty("qdcFedNoiseFactor" , m_qdcFedNoiseFactor);
56  declareProperty("tdcPmtNoiseFactor" , m_tdcPmtNoiseFactor);
57  declareProperty("tdcFedNoiseFactor" , m_tdcFedNoiseFactor);
58 
59  declareProperty("TotalPMTgain" , m_TotalPMTgain);
60  declareProperty("AmpFactor" , m_AmpFactor);
61  declareProperty("Q1bin" , m_Q1bin);
62  declareProperty("NoiseCharge" , m_NoiseCharge);
63  declareProperty("numDyinodes" , m_numDyinodes);
64  declareProperty("dynodeGammaFactor" , m_dynodeGammaFactor);
65 
66  declareProperty("pmtSmearing" , m_pmtSmearing);
67  declareProperty("pmtScaling" , m_pmtScaling);
68  declareProperty("gasScaling" , m_gasScaling);
69  declareProperty("npeThreshold" , m_npeThreshold);
70 
71  declareProperty("fillRootTree" , m_fillRootTree);
72 }
73 
75 {
76 
77  ATH_MSG_DEBUG ( "LUCID_PileUpTool::initialize() called " );
78 
79  ATH_MSG_DEBUG ( " numTubes : " << m_numTubes << endmsg
80  << " qdcChannelsPerPE : " << m_qdcChannelsPerPE << endmsg
81  << " qdcPedestal : " << m_qdcPedestal << endmsg
82  << " qdcFedNoiseFactor: " << m_qdcFedNoiseFactor << endmsg
83  << " tdcPmtNoiseFactor: " << m_tdcPmtNoiseFactor << endmsg
84  << " tdcFedNoiseFactor: " << m_tdcFedNoiseFactor << endmsg
85  << " fillRootTree : " << m_fillRootTree );
86 
87  ATH_CHECK(m_randomSvc.retrieve());
88  ATH_MSG_DEBUG ( "Retrieved RandomNumber Service" );
89 
90  ATH_CHECK(m_mergeSvc.retrieve());
91  ATH_MSG_DEBUG ( "Retrieved PileUpMergeSvc" );
92 
100  m_AmpFactor,
101  m_Q1bin,
106  m_pmtScaling,
107  m_gasScaling,
110 
112 
113  if (m_fillRootTree)
114  {
115  CHECK(service("THistSvc", m_digitHistSvc));
116  ATH_MSG_DEBUG ( "Retrieved Histogram Service" );
117 
119  ATH_MSG_DEBUG ( "Retrieved ROOT tree" );
120  }
121 
122  return StatusCode::SUCCESS;
123 }
124 
126 StatusCode LUCID_PileUpTool::prepareEvent(const EventContext& /*ctx*/, const unsigned int nInputEvents)
127 {
128  ATH_MSG_DEBUG ( "prepareEvent() called for " << nInputEvents << " input events" );
129 
131  ATH_MSG_DEBUG ( " Digit container is recorded in StoreGate " );
132 
134 
135  return StatusCode::SUCCESS;
136 }
137 
140  SubEventIterator bSubEvents,
141  SubEventIterator eSubEvents)
142 {
143  ATH_MSG_DEBUG ( "LUCID_PileUpTool::processBunchXing() " << bunchXing );
144 
145  SubEventIterator iEvt = bSubEvents;
146 
147  for (; iEvt!=eSubEvents; ++iEvt)
148  {
149 
150  StoreGateSvc& seStore = *iEvt->ptr()->evtStore();
151  ATH_MSG_VERBOSE ( "SubEvt EventInfo from StoreGate " << seStore.name() << " :"
152  << " bunch crossing : " << bunchXing
153  << " time offset : " << iEvt->time()
154  << " event number : " << iEvt->ptr()->eventNumber()
155  << " run number : " << iEvt->ptr()->runNumber()
156  );
157  const LUCID_SimHitCollection* tmpColl = nullptr;
158 
159  if (!seStore.retrieve(tmpColl,m_SimHitCollectionName).isSuccess())
160  {
161 
162  ATH_MSG_ERROR ( "SubEvent BCM SiHitCollection not found in StoreGate " << seStore.name() );
163 
164  return StatusCode::FAILURE;
165  }
166 
167  ATH_MSG_DEBUG ( "LUCID_SimHitCollection found with " << tmpColl->size() << " hits" );
168 
171 
172  for (; i!=e; ++i) m_mergedhitList->push_back((*i));
173 
174  }
175 
176  return StatusCode::SUCCESS;
177 }
178 
180 StatusCode LUCID_PileUpTool::mergeEvent(const EventContext& ctx)
181 {
182  ATHRNG::RNGWrapper* rngWrapper = m_randomSvc->getEngine(this, m_randomStreamName);
183  rngWrapper->setSeed( m_randomStreamName, ctx );
184  CLHEP::HepRandomEngine* rngEngine = rngWrapper->getEngine(ctx);
186  ATH_MSG_DEBUG ( " LUCID_DigitContainer successfully registered in StoreGate " );
187 
188  return StatusCode::SUCCESS;
189 }
190 
193 {
194  ATH_MSG_VERBOSE ( "processAllSubEvents()" );
195 
197 
198  TimedHitCollList hitCollList;
199 
200  ATH_CHECK(m_mergeSvc->retrieveSubEvtsData(m_SimHitCollectionName, hitCollList));
201  ATH_MSG_DEBUG ( "Retrieved TimedHitCollList" );
202 
203  ATH_MSG_DEBUG ( " PileUp: Merge " << hitCollList.size() << " LUCID_SimHitCollection with key " << m_SimHitCollectionName );
204 
206 
207  TimedHitCollList::iterator iColl (hitCollList.begin());
208  TimedHitCollList::iterator endColl(hitCollList.end());
209 
210  while (iColl != endColl)
211  {
212  const LUCID_SimHitCollection* tmpColl(iColl->second);
213 
214  thpclucid.insert(iColl->first, tmpColl);
215 
216  ATH_MSG_DEBUG ( " LUCID_SimHitCollection found with " << tmpColl->size() << " hits " << iColl->first );
217 
218  ++iColl;
219  }
220 
221 
223  ATH_MSG_DEBUG ( " Digit container is recorded in StoreGate " );
224 
225  ATHRNG::RNGWrapper* rngWrapper = m_randomSvc->getEngine(this, m_randomStreamName);
226  rngWrapper->setSeed( m_randomStreamName, ctx );
227  CLHEP::HepRandomEngine* rngEngine = rngWrapper->getEngine(ctx);
228  ATH_CHECK(m_digitToolBox->fillDigitContainer(thpclucid, rngEngine));
229  ATH_MSG_DEBUG ( " Digit container was filled successfully " );
230 
231  return StatusCode::SUCCESS;
232 }
235 {
236  return StatusCode::SUCCESS;
237 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
LUCID_SimHitCollection
AtlasHitsVector< LUCID_SimHit > LUCID_SimHitCollection
Definition: LUCID_SimHitCollection.h:12
ATHRNG::RNGWrapper::setSeed
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition: RNGWrapper.h:169
LUCID_PileUpTool::mergeEvent
virtual StatusCode mergeEvent(const EventContext &ctx) override final
return false if not interested in certain xing times (in ns) implemented by default in PileUpToolBase...
Definition: LUCID_PileUpTool.cxx:180
LUCID_DigitizationToolBox::m_numTubes
int m_numTubes
Definition: LUCID_DigitizationToolBox.h:62
LUCID_DigitizationToolBox
Definition: LUCID_DigitizationToolBox.h:19
LUCID_PileUpTool::m_mergeSvc
ServiceHandle< PileUpMergeSvc > m_mergeSvc
Definition: LUCID_PileUpTool.h:61
LUCID_PileUpTool::m_mergedhitList
LUCID_SimHitCollection * m_mergedhitList
Definition: LUCID_PileUpTool.h:74
LUCID_DigitizationToolBox::LUCID_DigitizationToolBox
LUCID_DigitizationToolBox()
Definition: LUCID_DigitizationToolBox.cxx:17
LUCID_DigitizationToolBox::recordContainers
StatusCode recordContainers(const ServiceHandle< StoreGateSvc > &, const std::string &)
Definition: LUCID_DigitizationToolBox.cxx:228
LUCID_DigitizationToolBox::m_pmtSmearing
std::vector< double > m_pmtSmearing
Definition: LUCID_DigitizationToolBox.h:79
AtlasHitsVector
Definition: AtlasHitsVector.h:33
LUCID_DigitizationToolBox::m_gasScaling
std::vector< double > m_gasScaling
Definition: LUCID_DigitizationToolBox.h:81
LUCID_DigitizationToolBox::m_tdcFedNoiseFactor
double m_tdcFedNoiseFactor
Definition: LUCID_DigitizationToolBox.h:67
LUCID_PileUpTool::m_digitHistSvc
ITHistSvc * m_digitHistSvc
Definition: LUCID_PileUpTool.h:72
LUCID_PileUpTool::prepareEvent
virtual StatusCode prepareEvent(const EventContext &ctx, const unsigned int nInputEvents) override final
called before the subevts loop. Not (necessarily) able to access SubEvents
Definition: LUCID_PileUpTool.cxx:126
LUCID_DigitizationToolBox::setDebugTree
StatusCode setDebugTree(ITHistSvc *)
Definition: LUCID_DigitizationToolBox.cxx:99
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
AtlasHitsVector::begin
const_iterator begin() const
Definition: AtlasHitsVector.h:131
LUCID_PileUpTool::m_SimHitCollectionName
std::string m_SimHitCollectionName
Definition: LUCID_PileUpTool.h:66
AtlasHitsVector::const_iterator
CONT::const_iterator const_iterator
Definition: AtlasHitsVector.h:43
AtlasHitsVector::clear
void clear()
Definition: AtlasHitsVector.h:153
PileUpMergeSvc::TimedList::type
std::list< value_t > type
type of the collection of timed data object
Definition: PileUpMergeSvc.h:75
StoreGateSvc::retrieve
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
LUCID_PileUpTool::m_digitToolBox
LUCID_DigitizationToolBox * m_digitToolBox
Definition: LUCID_PileUpTool.h:70
LUCID_PileUpTool::m_key_digitCnt
std::string m_key_digitCnt
Definition: LUCID_PileUpTool.h:68
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TimedHitCollection::insert
void insert(const PileUpTimeEventIndex &timeEventIndex, const AtlasHitsVector< HIT > *inputCollection)
LUCID_DigitizationToolBox::m_fillRootTree
bool m_fillRootTree
Definition: LUCID_DigitizationToolBox.h:84
lumiFormat.i
int i
Definition: lumiFormat.py:92
LUCID_DigitizationToolBox::m_Q1bin
double m_Q1bin
Definition: LUCID_DigitizationToolBox.h:71
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
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
LUCID_PileUpTool::processAllSubEvents
virtual StatusCode processAllSubEvents(const EventContext &ctx) override final
perform the digitization - used by LUCID_DigiTop::execute
Definition: LUCID_PileUpTool.cxx:192
LUCID_PileUpTool::m_digitsContainerName
std::string m_digitsContainerName
Definition: LUCID_PileUpTool.h:67
LUCID_PileUpTool::m_randomSvc
ServiceHandle< IAthRNGSvc > m_randomSvc
Definition: LUCID_PileUpTool.h:62
test_pyathena.parent
parent
Definition: test_pyathena.py:15
LUCID_DigitizationToolBox::m_dynodeGammaFactor
double m_dynodeGammaFactor
Definition: LUCID_DigitizationToolBox.h:74
LUCID_DigitizationToolBox::fillDigitContainer
StatusCode fillDigitContainer(TimedHitCollection< LUCID_SimHit > &, CLHEP::HepRandomEngine *)
Definition: LUCID_DigitizationToolBox.cxx:162
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
LUCID_PileUpTool::LUCID_PileUpTool
LUCID_PileUpTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: LUCID_PileUpTool.cxx:19
LUCID_DigitizationToolBox::m_TotalPMTgain
double m_TotalPMTgain
Definition: LUCID_DigitizationToolBox.h:69
LUCID_PileUpTool::initialize
virtual StatusCode initialize() override final
Definition: LUCID_PileUpTool.cxx:74
PileUpToolBase
Definition: PileUpToolBase.h:18
LUCID_DigitizationToolBox::m_NoiseCharge
int m_NoiseCharge
Definition: LUCID_DigitizationToolBox.h:72
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ATHRNG::RNGWrapper
A wrapper class for event-slot-local random engines.
Definition: RNGWrapper.h:56
LUCID_DigitizationToolBox::m_qdcPedestal
double m_qdcPedestal
Definition: LUCID_DigitizationToolBox.h:64
errorcheck.h
Helpers for checking error return status codes and reporting errors.
LUCID_DigitizationToolBox::m_npeThreshold
std::vector< double > m_npeThreshold
Definition: LUCID_DigitizationToolBox.h:82
ATHRNG::RNGWrapper::getEngine
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition: RNGWrapper.h:134
RNGWrapper.h
LUCID_PileUpTool.h
LUCID_PileUpTool::finalize
virtual StatusCode finalize() override final
Definition: LUCID_PileUpTool.cxx:234
LUCID_DigitizationToolBox::m_qdcChannelsPerPE
double m_qdcChannelsPerPE
Definition: LUCID_DigitizationToolBox.h:63
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
LUCID_PileUpTool::m_randomStreamName
Gaudi::Property< std::string > m_randomStreamName
Definition: LUCID_PileUpTool.h:63
LUCID_DigitizationToolBox::m_tdcPmtNoiseFactor
double m_tdcPmtNoiseFactor
Definition: LUCID_DigitizationToolBox.h:66
AtlasHitsVector::end
const_iterator end() const
Definition: AtlasHitsVector.h:134
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
AtlasHitsVector::size
size_type size() const
Definition: AtlasHitsVector.h:143
LUCID_DigitizationToolBox::m_numDyinodes
int m_numDyinodes
Definition: LUCID_DigitizationToolBox.h:73
SubEventIterator
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition: IPileUpTool.h:22
LUCID_DigitizationToolBox::m_AmpFactor
double m_AmpFactor
Definition: LUCID_DigitizationToolBox.h:70
LUCID_DigitizationToolBox::m_pmtScaling
std::vector< double > m_pmtScaling
Definition: LUCID_DigitizationToolBox.h:80
LUCID_DigitizationToolBox::m_qdcFedNoiseFactor
double m_qdcFedNoiseFactor
Definition: LUCID_DigitizationToolBox.h:65
LUCID_PileUpTool::processBunchXing
virtual StatusCode processBunchXing(int bunchXing, SubEventIterator bSubEvents, SubEventIterator eSubEvents) override final
called for each active bunch-crossing to process current SubEvents bunchXing is in ns
Definition: LUCID_PileUpTool.cxx:139
TimedHitCollection
Definition: TimedHitCollection.h:15
AtlasHitsVector::push_back
void push_back(const T &t)
Definition: AtlasHitsVector.h:145