ATLAS Offline Software
LUCID_PileUpTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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 <map>
14 #include <algorithm>
15 
18  const std::string& name,
19  const IInterface* parent) :
22  40,//m_numTubes
23  15.0,//m_qdcChannelsPerPE
24  150.0,//m_qdcPedestal
25  3.0,//m_qdcFedNoiseFactor
26  2.8,//m_tdcPmtNoiseFactor
27  0.8,//m_tdcFedNoiseFactor
28  1.25e6,//m_TotalPMTgain
29  7.5,//m_AmpFactor
30  0.1e-12,//m_Q1bin
31  541666,//m_NoiseCharge
32  10,//m_numDyinodes
33  1.356,//m_dynodeGammaFactor
34  {0.000001}, //m_pmtSmearing
35  {0.000001}, //m_pmtScaling
36  {0.000001}, //m_gasScaling
37  {0.000001,0.000001,0.000001,0.000001,0.000001,
38  0.000001,0.000001,0.000001,0.000001,0.000001,
39  0.000001,0.000001,0.000001,0.000001,0.000001},//15 values m_npeThreshold
40  false), //m_fillRootTree
41  m_key_digitCnt ("Lucid_Digits")
42 {
43  declareProperty("SimHitCollection" ,
44  m_SimHitCollectionName = "LucidSimHitsVector",
45  "Name of the input Collection of simulated hits");
46  declareProperty("LucidDigitsContainer",
47  m_digitsContainerName = "LucidDigitsCnt",
48  "Name of the Container to hold the output from the digitization");
49 
50  declareProperty("numTubes" , m_numTubes);
51  declareProperty("qdcChannelsPerPE" , m_qdcChannelsPerPE);
52  declareProperty("qdcPedestal" , m_qdcPedestal);
53  declareProperty("qdcFedNoiseFactor" , m_qdcFedNoiseFactor);
54  declareProperty("tdcPmtNoiseFactor" , m_tdcPmtNoiseFactor);
55  declareProperty("tdcFedNoiseFactor" , m_tdcFedNoiseFactor);
56 
57  declareProperty("TotalPMTgain" , m_TotalPMTgain);
58  declareProperty("AmpFactor" , m_AmpFactor);
59  declareProperty("Q1bin" , m_Q1bin);
60  declareProperty("NoiseCharge" , m_NoiseCharge);
61  declareProperty("numDyinodes" , m_numDyinodes);
62  declareProperty("dynodeGammaFactor" , m_dynodeGammaFactor);
63 
64  declareProperty("pmtSmearing" , m_pmtSmearing);
65  declareProperty("pmtScaling" , m_pmtScaling);
66  declareProperty("gasScaling" , m_gasScaling);
67  declareProperty("npeThreshold" , m_npeThreshold);
68 
69  declareProperty("fillRootTree" , m_fillRootTree);
70 }
71 
73 {
74 
75  ATH_MSG_DEBUG ( "LUCID_PileUpTool::initialize() called " );
76 
77  ATH_MSG_DEBUG ( " numTubes : " << m_numTubes << endmsg
78  << " qdcChannelsPerPE : " << m_qdcChannelsPerPE << endmsg
79  << " qdcPedestal : " << m_qdcPedestal << endmsg
80  << " qdcFedNoiseFactor: " << m_qdcFedNoiseFactor << endmsg
81  << " tdcPmtNoiseFactor: " << m_tdcPmtNoiseFactor << endmsg
82  << " tdcFedNoiseFactor: " << m_tdcFedNoiseFactor << endmsg
83  << " fillRootTree : " << m_fillRootTree );
84 
85  ATH_CHECK(m_randomSvc.retrieve());
86  ATH_MSG_DEBUG ( "Retrieved RandomNumber Service" );
87 
88  ATH_CHECK(m_mergeSvc.retrieve());
89  ATH_MSG_DEBUG ( "Retrieved PileUpMergeSvc" );
90 
92 
93  if (m_fillRootTree)
94  {
96  ATH_MSG_DEBUG ( "Retrieved ROOT tree" );
97  }
98 
99  return StatusCode::SUCCESS;
100 }
101 
103 StatusCode LUCID_PileUpTool::prepareEvent(const EventContext& /*ctx*/, const unsigned int nInputEvents)
104 {
105  ATH_MSG_DEBUG ( "prepareEvent() called for " << nInputEvents << " input events" );
106 
107  CHECK(recordContainers(this->evtStore(), m_key_digitCnt));
108  ATH_MSG_DEBUG ( " Digit container is recorded in StoreGate " );
109 
111 
112  return StatusCode::SUCCESS;
113 }
114 
117  SubEventIterator bSubEvents,
118  SubEventIterator eSubEvents)
119 {
120  ATH_MSG_DEBUG ( "LUCID_PileUpTool::processBunchXing() " << bunchXing );
121 
122  SubEventIterator iEvt = bSubEvents;
123 
124  for (; iEvt!=eSubEvents; ++iEvt)
125  {
126 
127  StoreGateSvc& seStore = *iEvt->ptr()->evtStore();
128  ATH_MSG_VERBOSE ( "SubEvt EventInfo from StoreGate " << seStore.name() << " :"
129  << " bunch crossing : " << bunchXing
130  << " time offset : " << iEvt->time()
131  << " event number : " << iEvt->ptr()->eventNumber()
132  << " run number : " << iEvt->ptr()->runNumber()
133  );
134  const LUCID_SimHitCollection* tmpColl = nullptr;
135 
136  if (!seStore.retrieve(tmpColl,m_SimHitCollectionName).isSuccess())
137  {
138 
139  ATH_MSG_ERROR ( "SubEvent BCM SiHitCollection not found in StoreGate " << seStore.name() );
140 
141  return StatusCode::FAILURE;
142  }
143 
144  ATH_MSG_DEBUG ( "LUCID_SimHitCollection found with " << tmpColl->size() << " hits" );
145 
148 
149  for (; i!=e; ++i) m_mergedhitList->push_back((*i));
150 
151  }
152 
153  return StatusCode::SUCCESS;
154 }
155 
157 StatusCode LUCID_PileUpTool::mergeEvent(const EventContext& ctx)
158 {
159  ATHRNG::RNGWrapper* rngWrapper = m_randomSvc->getEngine(this, m_randomStreamName);
160  rngWrapper->setSeed( m_randomStreamName, ctx );
161  CLHEP::HepRandomEngine* rngEngine = rngWrapper->getEngine(ctx);
163  ATH_MSG_DEBUG ( " LUCID_DigitContainer successfully registered in StoreGate " );
164 
165  return StatusCode::SUCCESS;
166 }
167 
170 {
171  ATH_MSG_VERBOSE ( "processAllSubEvents()" );
172 
174 
175  TimedHitCollList hitCollList;
176 
177  ATH_CHECK(m_mergeSvc->retrieveSubEvtsData(m_SimHitCollectionName, hitCollList));
178  ATH_MSG_DEBUG ( "Retrieved TimedHitCollList" );
179 
180  ATH_MSG_DEBUG ( " PileUp: Merge " << hitCollList.size() << " LUCID_SimHitCollection with key " << m_SimHitCollectionName );
181 
183 
184  TimedHitCollList::iterator iColl (hitCollList.begin());
185  TimedHitCollList::iterator endColl(hitCollList.end());
186 
187  while (iColl != endColl)
188  {
189  const LUCID_SimHitCollection* tmpColl(iColl->second);
190 
191  thpclucid.insert(iColl->first, tmpColl);
192 
193  ATH_MSG_DEBUG ( " LUCID_SimHitCollection found with " << tmpColl->size() << " hits " << iColl->first );
194 
195  ++iColl;
196  }
197 
198 
199  ATH_CHECK(recordContainers(this->evtStore(), m_key_digitCnt));
200  ATH_MSG_DEBUG ( " Digit container is recorded in StoreGate " );
201 
202  ATHRNG::RNGWrapper* rngWrapper = m_randomSvc->getEngine(this, m_randomStreamName);
203  rngWrapper->setSeed( m_randomStreamName, ctx );
204  CLHEP::HepRandomEngine* rngEngine = rngWrapper->getEngine(ctx);
205  ATH_CHECK(fillDigitContainer(thpclucid, rngEngine));
206  ATH_MSG_DEBUG ( " Digit container was filled successfully " );
207 
208  return StatusCode::SUCCESS;
209 }
212 {
213  return StatusCode::SUCCESS;
214 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
LUCID_SimHitCollection
AtlasHitsVector< LUCID_SimHit > LUCID_SimHitCollection
Definition: LUCID_SimHitCollection.h:12
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
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:157
LUCID_DigitizationToolBox::m_numTubes
int m_numTubes
Definition: LUCID_DigitizationToolBox.h:61
LUCID_DigitizationToolBox
Definition: LUCID_DigitizationToolBox.h:18
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:70
LUCID_DigitizationToolBox::recordContainers
StatusCode recordContainers(const ServiceHandle< StoreGateSvc > &, const std::string &)
Definition: LUCID_DigitizationToolBox.cxx:232
LUCID_DigitizationToolBox::m_pmtSmearing
std::vector< double > m_pmtSmearing
Definition: LUCID_DigitizationToolBox.h:78
AtlasHitsVector
Definition: AtlasHitsVector.h:33
LUCID_DigitizationToolBox::m_gasScaling
std::vector< double > m_gasScaling
Definition: LUCID_DigitizationToolBox.h:80
LUCID_DigitizationToolBox::m_tdcFedNoiseFactor
double m_tdcFedNoiseFactor
Definition: LUCID_DigitizationToolBox.h:66
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:103
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:125
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:83
lumiFormat.i
int i
Definition: lumiFormat.py:85
LUCID_DigitizationToolBox::m_Q1bin
double m_Q1bin
Definition: LUCID_DigitizationToolBox.h:70
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:169
LUCID_PileUpTool::m_digitsContainerName
std::string m_digitsContainerName
Definition: LUCID_PileUpTool.h:67
LUCID_DigitizationToolBox::setDebugTree
StatusCode setDebugTree()
Definition: LUCID_DigitizationToolBox.cxx:101
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:73
LUCID_DigitizationToolBox::fillDigitContainer
StatusCode fillDigitContainer(TimedHitCollection< LUCID_SimHit > &, CLHEP::HepRandomEngine *)
Definition: LUCID_DigitizationToolBox.cxx:166
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:17
LUCID_DigitizationToolBox::m_TotalPMTgain
double m_TotalPMTgain
Definition: LUCID_DigitizationToolBox.h:68
LUCID_PileUpTool::initialize
virtual StatusCode initialize() override final
Definition: LUCID_PileUpTool.cxx:72
PileUpToolBase
Definition: PileUpToolBase.h:18
LUCID_DigitizationToolBox::m_NoiseCharge
int m_NoiseCharge
Definition: LUCID_DigitizationToolBox.h:71
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
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:63
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:81
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:211
LUCID_DigitizationToolBox::m_qdcChannelsPerPE
double m_qdcChannelsPerPE
Definition: LUCID_DigitizationToolBox.h:62
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:65
AtlasHitsVector::end
const_iterator end() const
Definition: AtlasHitsVector.h:134
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AtlasHitsVector::size
size_type size() const
Definition: AtlasHitsVector.h:143
LUCID_DigitizationToolBox::m_numDyinodes
int m_numDyinodes
Definition: LUCID_DigitizationToolBox.h:72
SubEventIterator
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition: IPileUpTool.h:22
LUCID_DigitizationToolBox::m_AmpFactor
double m_AmpFactor
Definition: LUCID_DigitizationToolBox.h:69
LUCID_DigitizationToolBox::m_pmtScaling
std::vector< double > m_pmtScaling
Definition: LUCID_DigitizationToolBox.h:79
LUCID_DigitizationToolBox::m_qdcFedNoiseFactor
double m_qdcFedNoiseFactor
Definition: LUCID_DigitizationToolBox.h:64
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:116
TimedHitCollection
Definition: TimedHitCollection.h:15
AtlasHitsVector::push_back
void push_back(const T &t)
Definition: AtlasHitsVector.h:145