ATLAS Offline Software
Loading...
Searching...
No Matches
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) :
20 PileUpToolBase (type, name, 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
94 {
96 ATH_MSG_DEBUG ( "Retrieved ROOT tree" );
97 }
98
99 return StatusCode::SUCCESS;
100}
101
103StatusCode 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
110 m_mergedhitList->clear();
111
112 return StatusCode::SUCCESS;
113}
114
116StatusCode LUCID_PileUpTool::processBunchXing(int bunchXing,
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
157StatusCode 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
169StatusCode LUCID_PileUpTool::processAllSubEvents(const EventContext& ctx)
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}
210
212{
213 return StatusCode::SUCCESS;
214}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition IPileUpTool.h:22
AtlasHitsVector< LUCID_SimHit > LUCID_SimHitCollection
A wrapper class for event-slot-local random engines.
Definition RNGWrapper.h:56
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition RNGWrapper.h:169
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition RNGWrapper.h:134
CONT::const_iterator const_iterator
const_iterator begin() const
size_type size() const
const_iterator end() const
StatusCode fillDigitContainer(TimedHitCollection< LUCID_SimHit > &, CLHEP::HepRandomEngine *)
StatusCode recordContainers(const ServiceHandle< StoreGateSvc > &, const std::string &)
LUCID_PileUpTool(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize() override final
ServiceHandle< IAthRNGSvc > m_randomSvc
ServiceHandle< PileUpMergeSvc > m_mergeSvc
virtual StatusCode mergeEvent(const EventContext &ctx) override final
return false if not interested in certain xing times (in ns) implemented by default in PileUpToolBase...
Gaudi::Property< std::string > m_randomStreamName
LUCID_SimHitCollection * m_mergedhitList
virtual StatusCode processAllSubEvents(const EventContext &ctx) override final
perform the digitization - used by LUCID_DigiTop::execute
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
virtual StatusCode finalize() override final
std::string m_key_digitCnt
virtual StatusCode prepareEvent(const EventContext &ctx, const unsigned int nInputEvents) override final
called before the subevts loop. Not (necessarily) able to access SubEvents
std::string m_SimHitCollectionName
PileUpToolBase(const std::string &type, const std::string &name, const IInterface *parent)
The Athena Transient Store API.
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
void insert(const PileUpTimeEventIndex &timeEventIndex, const AtlasHitsVector< HIT > *inputCollection)
std::list< value_t > type
type of the collection of timed data object