LDMX Software
recon::OverlayProducer Class Reference

Class to overlay in-time pile-up events from an overlay file. More...

#include <OverlayProducer.h>

Public Member Functions

 OverlayProducer (const std::string &name, framework::Process &process)
 
void configure (framework::config::Parameters &parameters) override
 Configure the processor with input parameters from the python cofig.
 
void onNewRun (const ldmx::RunHeader &) override
 At the start of the run, the pileup overlay file is set up, and the starting event number is chosen, using the RNSS.
 
void produce (framework::Event &event) override
 Based on the list of collections to overlay, and the desired number of events, loop through all relevant collections and copy the sim event (once), and then add the corresponding collection from the pileup overlay file.
 
void onProcessStart () override
 At the start of processing, the pileup overlay file is set up.
 
- Public Member Functions inherited from framework::Producer
 Producer (const std::string &name, Process &process)
 Class constructor.
 
virtual void beforeNewRun (ldmx::RunHeader &header)
 Handle allowing producers to modify run headers before the run begins.
 
- Public Member Functions inherited from framework::EventProcessor
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()
 Class destructor.
 
virtual void onFileOpen (EventFile &eventFile)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &eventFile)
 Callback for the EventProcessor to take any necessary action when a event input ROOT file is closed.
 
virtual void onProcessEnd ()
 Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.
 
template<class T >
const T & getCondition (const std::string &condition_name)
 Access a conditions object for the current event.
 
TDirectory * getHistoDirectory ()
 Access/create a directory in the histogram file for this event processor to create histograms and analysis tuples.
 
void setStorageHint (framework::StorageControl::Hint hint)
 Mark the current event as having the given storage control hint from this module.
 
void setStorageHint (framework::StorageControl::Hint hint, const std::string &purposeString)
 Mark the current event as having the given storage control hint from this module and the given purpose string.
 
int getLogFrequency () const
 Get the current logging frequency from the process.
 
int getRunNumber () const
 Get the run number from the process.
 
std::string getName () const
 Get the processor name.
 
void createHistograms (const std::vector< framework::config::Parameters > &histos)
 Internal function which is used to create histograms passed from the python configuration @parma histos vector of Parameters that configure histograms to create.
 

Private Attributes

framework::config::Parameters params_
 The parameters used to configure this producer.
 
std::string overlayFileName_
 Pileup overlay events input file name.
 
std::unique_ptr< framework::EventFileoverlayFile_
 Pileup overlay events input file.
 
framework::Event overlayEvent_
 The overlay ldmx event bus.
 
std::vector< std::string > caloCollections_
 List of SimCalorimeterHit collection(s) to loop over and add hits from, combining sim and pileup.
 
std::vector< std::string > trackerCollections_
 List of SimTrackerHit collection(s) to loop over and add hits from, combining sim and pileup.
 
std::string overlayPassName_
 Pileup overlay events input pass name.
 
std::string simPassName_
 To use for finding the sim event bus passengers, mostly a disambiguation.
 
bool doPoissonIT_ {false}
 Let the total number of in-time events be poisson distributed, or fix at the chosen value, poissonMu_.
 
bool doPoissonOOT_ {false}
 Let the total number of out-of-time events be poisson distributed, or fix at the chosen value, poissonMu_.
 
double poissonMu_ {0.}
 (average) total number of events
 
std::unique_ptr< TRandom2 > rndm_
 Random number generator for number of overlaid events.
 
std::unique_ptr< TRandom2 > rndmTime_
 Random number generator for pileup event time offset.
 
double timeSigma_ {0.}
 Width of pileup bunch spread in time (in [ns]), specified as a sigma of a Gaussian distribution.
 
double timeMean_ {0.}
 Average position in time (in [ns]) of pileup bunches, relative to the sim event.
 
double bunchSpacing_ {0.}
 Spacing in time (in [ns]) between electron bunches.
 
int nEarlier_ {0}
 Number of bunches before the sim event to pull pileup events from.
 
int nLater_ {0}
 Number of bunches after the sim event to pull pileup events from.
 
int verbosity_
 Local control of processor verbosity.
 
int overlayIncidentID_ {-1000}
 For Ecal, overlay hits should be added as contribs.
 
int overlayTrackID_ {-1000}
 
int overlayPdgCode_ {0}
 

Additional Inherited Members

- Static Public Member Functions inherited from framework::EventProcessor
static void declare (const std::string &classname, int classtype, EventProcessorMaker *)
 Internal function which is part of the PluginFactory machinery.
 
- Static Public Attributes inherited from framework::Producer
static const int CLASSTYPE {1}
 Constant used to track EventProcessor types by the PluginFactory.
 
- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramHelper histograms_
 Interface class for making and filling histograms.
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger theLog_
 The logger for this EventProcessor.
 

Detailed Description

Class to overlay in-time pile-up events from an overlay file.

Definition at line 23 of file OverlayProducer.h.

Constructor & Destructor Documentation

◆ OverlayProducer()

recon::OverlayProducer::OverlayProducer ( const std::string & name,
framework::Process & process )
inline

Definition at line 25 of file OverlayProducer.h.

26 : framework::Producer(name, process), overlayEvent_{"overlay"} {}
Base class for a module which produces a data product.
framework::Event overlayEvent_
The overlay ldmx event bus.

Member Function Documentation

◆ configure()

void recon::OverlayProducer::configure ( framework::config::Parameters & parameters)
overridevirtual

Configure the processor with input parameters from the python cofig.

Print the parameters actually set. Helpful in case of typos.

Reimplemented from framework::EventProcessor.

Definition at line 9 of file OverlayProducer.cxx.

9 {
10 params_ = parameters;
11
12 ldmx_log(debug) << "Running configure() ";
13
14 // name of file containing events to be overlaid, and a list of collections to
15 // overlay
16 overlayFileName_ = parameters.getParameter<std::string>("overlayFileName");
17 caloCollections_ = parameters.getParameter<std::vector<std::string>>(
18 "overlayCaloHitCollections");
19 trackerCollections_ = parameters.getParameter<std::vector<std::string>>(
20 "overlayTrackerHitCollections");
21 simPassName_ = parameters.getParameter<std::string>("passName");
22 overlayPassName_ = parameters.getParameter<std::string>("overlayPassName");
23 // overlay specifics:
24 poissonMu_ = parameters.getParameter<double>("totalNumberOfInteractions");
25 doPoissonIT_ = parameters.getParameter<bool>("doPoissonIntime");
26 doPoissonOOT_ = parameters.getParameter<bool>("doPoissonOutoftime");
27 timeSigma_ = parameters.getParameter<double>("timeSpread");
28 timeMean_ = parameters.getParameter<double>("timeMean");
29 nEarlier_ = parameters.getParameter<int>("nEarlierBunchesToSample");
30 nLater_ = parameters.getParameter<int>("nLaterBunchesToSample");
31 bunchSpacing_ = parameters.getParameter<double>("bunchSpacing");
32 verbosity_ = parameters.getParameter<int>("verbosity");
33
35 if (verbosity_) {
36 ldmx_log(info) << "Got parameters \n \t overlayFileName = "
38 << "\n\t sim pass name = " << simPassName_
39 << "\n\t overlay pass name = " << overlayPassName_
40 << "\n\t overlayCaloHitCollections = ";
41 for (const auto &coll : caloCollections_) ldmx_log(info) << coll << "; ";
42
43 ldmx_log(info) << "\n\t overlayTrackerHitCollections = ";
44 for (const std::string &coll : trackerCollections_)
45 ldmx_log(info) << coll << "; ";
46
47 ldmx_log(info) << "\n\t numberOverlaidInteractions = " << poissonMu_
48 << "\n\t nEarlierBunchesToSample = " << nEarlier_
49 << "\n\t nLaterBunchesToSample = " << nLater_
50 << "\n\t bunchSpacing = " << bunchSpacing_
51 << "\n\t doPoissonIntime = " << doPoissonIT_
52 << "\n\t doPoissonOutoftime = " << doPoissonOOT_
53 << "\n\t timeSpread = " << timeSigma_
54 << "\n\t timeMean = " << timeMean_
55 << "\n\t verbosity = " << verbosity_;
56 }
57 return;
58}
std::string simPassName_
To use for finding the sim event bus passengers, mostly a disambiguation.
std::string overlayPassName_
Pileup overlay events input pass name.
std::string overlayFileName_
Pileup overlay events input file name.
std::vector< std::string > caloCollections_
List of SimCalorimeterHit collection(s) to loop over and add hits from, combining sim and pileup.
int verbosity_
Local control of processor verbosity.
int nEarlier_
Number of bunches before the sim event to pull pileup events from.
double bunchSpacing_
Spacing in time (in [ns]) between electron bunches.
double timeMean_
Average position in time (in [ns]) of pileup bunches, relative to the sim event.
framework::config::Parameters params_
The parameters used to configure this producer.
double poissonMu_
(average) total number of events
int nLater_
Number of bunches after the sim event to pull pileup events from.
bool doPoissonIT_
Let the total number of in-time events be poisson distributed, or fix at the chosen value,...
double timeSigma_
Width of pileup bunch spread in time (in [ns]), specified as a sigma of a Gaussian distribution.
bool doPoissonOOT_
Let the total number of out-of-time events be poisson distributed, or fix at the chosen value,...
std::vector< std::string > trackerCollections_
List of SimTrackerHit collection(s) to loop over and add hits from, combining sim and pileup.

References bunchSpacing_, caloCollections_, doPoissonIT_, doPoissonOOT_, nEarlier_, nLater_, overlayFileName_, overlayPassName_, params_, poissonMu_, simPassName_, timeMean_, timeSigma_, trackerCollections_, and verbosity_.

◆ onNewRun()

void recon::OverlayProducer::onNewRun ( const ldmx::RunHeader & )
overridevirtual

At the start of the run, the pileup overlay file is set up, and the starting event number is chosen, using the RNSS.

set up random seeds

Reimplemented from framework::EventProcessor.

Definition at line 60 of file OverlayProducer.cxx.

60 {
62 if (rndm_.get() == nullptr) {
63 // not been seeded yet, get it from RNSS
66 rndm_ = std::make_unique<TRandom2>(rnss.getSeed("OverlayProducer::rndm"));
67 }
68 // TAV: These boundaries should be configurable
69 int start_event = rndm_->Uniform(20., 4570);
70 // EventFile::skipToEvent handles actual number of events in file
71 int evNb = overlayFile_->skipToEvent(start_event);
72 if (evNb < 0) {
73 EXCEPTION_RAISE("BadRead", "Couldn't read to starting offset.");
74 }
76 ldmx_log(info) << "Starting overlay process with pileup event number " << evNb
77 << " (random event number picked was " << start_event << ").";
78}
const T & getCondition(const std::string &condition_name)
Access a conditions object for the current event.
ldmx::EventHeader & getEventHeader()
Get the event header.
Definition Event.h:59
static const std::string CONDITIONS_OBJECT_NAME
Conditions object name.
void setEventNumber(int eventNumber)
Set the event number.
std::unique_ptr< framework::EventFile > overlayFile_
Pileup overlay events input file.
std::unique_ptr< TRandom2 > rndm_
Random number generator for number of overlaid events.

References framework::RandomNumberSeedService::CONDITIONS_OBJECT_NAME, framework::EventProcessor::getCondition(), framework::Event::getEventHeader(), overlayEvent_, overlayFile_, rndm_, and ldmx::EventHeader::setEventNumber().

◆ onProcessStart()

void recon::OverlayProducer::onProcessStart ( )
overridevirtual

At the start of processing, the pileup overlay file is set up.

Reimplemented from framework::EventProcessor.

Definition at line 386 of file OverlayProducer.cxx.

386 {
387 if (verbosity_ > 2) {
388 ldmx_log(debug) << "onProcessStart() ";
389 }
390
391 // replace by this line once the corresponding tweak to EventFile is ready:
393 std::make_unique<framework::EventFile>(params_, overlayFileName_, true);
394 overlayFile_->setupEvent(&overlayEvent_);
395 // we update the iterator at the end of each event. so do this once here to
396 // grab the first event in the processor
397
398 if (verbosity_ > 2) {
399 ldmx_log(debug) << "onProcessStart () successful. Used input file: "
400 << overlayFile_->getFileName();
401 ldmx_log(debug) << "onProcessStart () successful. Got event info: ";
402 overlayFile_->getEvent()->Print();
403 }
404
405 return;
406}

References overlayEvent_, overlayFile_, overlayFileName_, params_, and verbosity_.

◆ produce()

void recon::OverlayProducer::produce ( framework::Event & event)
overridevirtual

Based on the list of collections to overlay, and the desired number of events, loop through all relevant collections and copy the sim event (once), and then add the corresponding collection from the pileup overlay file.

The event loop is the outer loop, and the inner loop is over the list of collections.

The collections have to be specified separately as a list of SimCalorimeterHit collections and a list of SimTrackerHit collections.

The collection name is parsed for "Ecal" to be flagged as a collection which needs overlay hits to be added as contribs. This is currently hardwired.

The resulting collections inherit the input collection name, with an appended string "Overlay". This name is also currently hardwired.

Go to next overlay event This overlay file has been configured to loop back to the beginning of the TTree when it reaches the end. This means nextEvent() will only return false if an error is occurred or if the overlay file is mis-configured.

Implements framework::Producer.

Definition at line 80 of file OverlayProducer.cxx.

80 {
81 // event is the incoming, simulated event/"hard" process
82 // overlayEvent_ is the overlay producer's own event.
83 if (verbosity_ > 1) {
84 ldmx_log(info) << "produce() starts on simulation event "
85 << event.getEventHeader().getEventNumber();
86 }
87
88 if (rndmTime_.get() == nullptr) {
89 // not been seeded yet, get it from RNSS
92 rndmTime_ =
93 std::make_unique<TRandom2>(rnss.getSeed("OverlayProducer::rndmTime"));
94 }
95
96 // using nextEvent to loop, we need to loop over overlay events and in an
97 // inner loop, loop over collections, and store them. after all pileup events
98 // have been added, the vector of collections is iterated over and added to
99 // the event bus.
100 std::map<std::string, std::vector<ldmx::SimCalorimeterHit>> caloCollectionMap;
101 std::map<std::string, std::vector<ldmx::SimTrackerHit>> trackerCollectionMap;
102 std::map<int, ldmx::SimCalorimeterHit> hitMap;
103
104 // start by copying over all the collections from the sim event
105
106 /* ----------- first do the SimCalorimeterHits ----------- */
107
108 // get the calo hits collections that we want to overlay, by looping over
109 // the list of collections passed to the producer : caloCollections_
110 for (const auto &collName : caloCollections_) {
111 // for now, Ecal and only Ecal uses contribs instead of multiple
112 // SimHitsCalo per channel, meaning, it requires special treatment
113 auto needsContribsAdded{collName.find("Ecal") != std::string::npos ? true
114 : false};
115
116 // start out by just copying the sim hits, unaltered.
117 auto simHitsCalo =
118 event.getCollection<ldmx::SimCalorimeterHit>(collName, simPassName_);
119 // but don't copy ecal hits immediately: for them, wait until overlay
120 // contribs have been added. then add everything through the hitmap
121 // TAV: the string "Overlay" should be configurable too
122 if (!needsContribsAdded) {
123 caloCollectionMap[collName + "Overlay"] = simHitsCalo;
124 }
125
126 if (verbosity_ > 2) {
127 ldmx_log(debug) << "in loop: start of collection " << collName
128 << "in loop: printing current sim event: ";
129 }
130 ldmx_log(debug) << "in loop: size of sim hits vector " << collName << " is "
131 << simHitsCalo.size();
132
133 // we don't need to touch the hard process sim hits, really... but we
134 // might need the simhits in the hit map.
135 if (needsContribsAdded || verbosity_ > 2) {
136 for (const ldmx::SimCalorimeterHit &simHit : simHitsCalo) {
137 if (verbosity_ > 2) simHit.Print();
138
139 if (needsContribsAdded) {
140 // this copies the hit, its ID and its coordinates directly
141 hitMap[simHit.getID()] = simHit;
142 }
143
144 } // over calo simhit collection
145 } // if needContribs or very verbose
146
147 } // over calo collections for sim event
148
149 /* ----------- now do the same with SimTrackerHits! ----------- */
150
151 // get the SimTrackerHit collections that we want to overlay, by looping
152 // over the list of collections passed to the producer : trackerCollections_
153 for (const auto &collName : trackerCollections_) {
154 auto simHitsTracker =
155 event.getCollection<ldmx::SimTrackerHit>(collName, simPassName_);
156 trackerCollectionMap[collName + "Overlay"] = simHitsTracker;
157
158 // the rest is printouts for debugging
159 ldmx_log(debug) << "in loop: size of sim hits vector " << collName << " is "
160 << simHitsTracker.size();
161
162 if (verbosity_ > 2) {
163 ldmx_log(debug) << "in loop: start of collection " << collName
164 << "in loop: printing current sim event: ";
165
166 for (const ldmx::SimTrackerHit &simHit : simHitsTracker) simHit.Print();
167 } // if high verbosity
168 } // over tracker collections for sim event
169
170 /* ----------- now do the pileup overlay ----------- */
171
172 // we could shift these by a random number, effectively placing the
173 // sim event at random positions in the interval, preserving the
174 // overall interval length
175 // int simBunch= (int)rndmTime_->Uniform(
176 // -(nEarlier_+1) , nLater_+1); // +1 to get
177 // inclusive interval
178 int startBunch = -nEarlier_;
179 int endBunch = nLater_;
180
181 // TODO -- figure out if we should also randomly shift the time of the sim
182 // event (likely only needed if time bias gets picked up by BDT or ML by way
183 // of pulse behaviour)
184 for (int bunchOffset{startBunch}; bunchOffset <= endBunch; bunchOffset++) {
185 // sample a poisson distribution, or use mu as fixed number of overlay
186 // events
187 int nEvsOverlay =
188 doPoissonOOT_ ? rndm_->Poisson(poissonMu_) : (int)poissonMu_;
189
190 // special case: in-time pileup at bunch 0
191 if (bunchOffset == 0) {
192 if (!doPoissonIT_)
193 nEvsOverlay = (int)poissonMu_; // fix it to the average
194 else if (doPoissonIT_ && !doPoissonOOT_) // then we haven't set this yet
195 nEvsOverlay = rndm_->Poisson(poissonMu_);
196
197 // paticularly useful in the poisson fluctuated case
198 event.getEventHeader().setIntParameter("inTimePU", nEvsOverlay);
199
200 // the total number of events is nPU + 1 (it includes the sim event)
201 nEvsOverlay -= 1; // in any case, subtract the sim event from nOverlay
202 if (verbosity_ > 2) {
203 ldmx_log(debug) << "will overlay " << nEvsOverlay
204 << " events on the simulated one";
205 }
206 }
207
208 float bunchTimeOffset = bunchSpacing_ * bunchOffset;
209
210 for (int iEv = 0; iEv < nEvsOverlay; iEv++) {
217 if (!overlayFile_->nextEvent()) {
218 ldmx_log(error) << "At sim event "
219 << event.getEventHeader().getEventNumber()
220 << ": couldn't read next overlay event!";
221 return;
222 }
223
224 // a pileup event wide time offset to be applied to all its hits.
225 float timeOffset = rndmTime_->Gaus(timeMean_, timeSigma_);
226 timeOffset += bunchTimeOffset;
227
228 if (verbosity_ > 2) {
229 ldmx_log(debug) << "in overlay loop: overlaying event "
231 << "which is " << iEv + 1 << " out of " << nEvsOverlay
232 << "\n\thit time offset is " << timeOffset << " ns"
233 << "\n\tbunch position offset is " << bunchOffset
234 << ", leading to a total time offset of "
235 << bunchTimeOffset << " ns";
236 }
237
238 /* ----------- first do the SimCalorimeterHits overlay ----------- */
239
240 // again get the calo hits collections that we want to overlay
241 for (uint iColl = 0; iColl < caloCollections_.size(); iColl++) {
242 // for now, Ecal and only Ecal uses contribs
243 bool needsContribsAdded = false;
244 if (strstr(caloCollections_[iColl].c_str(), "Ecal"))
245 needsContribsAdded = true;
246
247 std::vector<ldmx::SimCalorimeterHit> overlayHits =
250
251 ldmx_log(debug) << "in loop: size of overlay hits vector is "
252 << overlayHits.size();
253
254 std::string outCollName = caloCollections_[iColl] + "Overlay";
255
256 if (verbosity_ > 2) {
257 ldmx_log(debug) << "in loop: printing overlay event: ";
258 }
259
260 for (ldmx::SimCalorimeterHit &overlayHit : overlayHits) {
261 if (verbosity_ > 2) overlayHit.Print();
262
263 const float overlayTime = overlayHit.getTime() + timeOffset;
264 overlayHit.setTime(overlayTime);
265
266 if (needsContribsAdded) { // special treatment for (for now only)
267 // ecal
268 int overlayHitID = overlayHit.getID();
269 if (hitMap.find(overlayHitID) ==
270 hitMap.end()) { // there wasn't already a simhit in this id
271 hitMap[overlayHitID] = ldmx::SimCalorimeterHit();
272 hitMap[overlayHitID].setID(overlayHitID);
273 std::vector<float> hitPos = overlayHit.getPosition();
274 hitMap[overlayHitID].setPosition(hitPos[0], hitPos[1], hitPos[2]);
275 }
276 // add the overlay hit (as a) contrib
277 // incidentID = -1000, trackID = -1000, pdgCode = 0 <-- these are
278 // set in the header for now but could be parameters
279 hitMap[overlayHitID].addContrib(overlayIncidentID_, overlayTrackID_,
280 overlayPdgCode_,
281 overlayHit.getEdep(), overlayTime);
282 } // if add overlay as contribs
283 else {
284 caloCollectionMap[outCollName].push_back(overlayHit);
285 if (verbosity_ > 2)
286 ldmx_log(debug) << "Adding non-Ecal overlay hit to outhit vector "
287 << outCollName;
288 }
289 } // over overlay calo simhit collection
290
291 if (!needsContribsAdded)
292 ldmx_log(debug) << "Nhits in overlay collection " << outCollName
293 << ": " << caloCollectionMap[outCollName].size();
294
295 } // over caloCollections
296
297 /* ----------- now do simtracker hits overlay ----------- */
298
299 // get the SimTrackerHit collections that we want to overlay
300 for (const auto &coll : trackerCollections_) {
301 auto overlayTrackerHits{
304
305 ldmx_log(debug) << "in loop: size of overlay hits vector is "
306 << overlayTrackerHits.size();
307
308 auto outCollName{coll + "Overlay"};
309
310 if (verbosity_ > 2) {
311 ldmx_log(debug) << "in loop: printing overlay event: ";
312 }
313
314 for (auto &overlayHit : overlayTrackerHits) {
315 auto overlayTime{overlayHit.getTime() + timeOffset};
316 overlayHit.setTime(overlayTime);
317 trackerCollectionMap[outCollName].push_back(overlayHit);
318
319 if (verbosity_ > 2) {
320 overlayHit.Print();
321 ldmx_log(debug) << "Adding tracker overlay hit to outhit vector "
322 << outCollName;
323 } // verbose
324 } // over overlay tracker simhit collection
325
326 ldmx_log(debug) << "Nhits in overlay collection " << outCollName << ": "
327 << trackerCollectionMap[outCollName].size();
328
329 } // over trackerCollections
330
331 } // over overlay events
332 } // over bunches
333
334 // after all events are done, the ecal hitmap is final and can be written to
335 // the event output
336 for (uint iColl = 0; iColl < caloCollections_.size(); iColl++) {
337 // loop through collection names to find the right collection name
338 // add overlaid ecal hits as contribs/from hitmap rather than as copied
339 // simhits
340 if (strstr(caloCollections_[iColl].c_str(), "Ecal")) {
341 if (verbosity_ > 2)
342 ldmx_log(debug) << "Hits in hitmap after overlay of "
343 << caloCollections_[iColl] << "Overlay :";
344
345 for (auto &mapHit : hitMap) {
346 if (verbosity_ > 2) mapHit.second.Print();
347
348 if (caloCollectionMap.find(caloCollections_[iColl] + "Overlay") ==
349 caloCollectionMap.end()) {
350 ldmx_log(debug) << "Adding first hit from hit map as first outhit "
351 "vector to caloCollectionMap";
352 caloCollectionMap[caloCollections_[iColl] + "Overlay"] = {
353 mapHit.second};
354 } else
355 caloCollectionMap[caloCollections_[iColl] + "Overlay"].push_back(
356 mapHit.second);
357 }
358 break; // for now we only have one hitMap: for Ecal. so no need looking
359 // further after we got a match
360 } // isEcal
361 } // second loop over collections, to collect hits from hitmap
362
363 // done collecting hits.
364
365 // this should be added to the sim file, so to "event"
366 // once for each hit type
367 for (auto &[name, coll] : caloCollectionMap) {
368 ldmx_log(debug) << "Writing " << name << " to event bus.";
369 if (verbosity_ > 2) {
370 ldmx_log(debug) << "List of hits added: ";
371 for (auto &hit : coll) hit.Print();
372 }
373 event.add(name, coll);
374 }
375 for (auto &[name, coll] : trackerCollectionMap) {
376 ldmx_log(debug) << "Writing " << name << " to event bus.";
377 if (verbosity_ > 2) {
378 ldmx_log(debug) << "List of hits added: ";
379 for (auto &hit : coll) hit.Print();
380 }
381 event.add(name, coll);
382 }
383 return;
384}
const std::vector< ContentType > & getCollection(const std::string &collectionName, const std::string &passName="") const
Get a collection (std::vector) of objects from the event bus.
Definition Event.h:388
int getEventNumber() const
Return the event number.
Definition EventHeader.h:78
Stores simulated calorimeter hit information.
Represents a simulated tracker hit in the simulation.
void Print() const
Print a description of this object.
int overlayIncidentID_
For Ecal, overlay hits should be added as contribs.
std::unique_ptr< TRandom2 > rndmTime_
Random number generator for pileup event time offset.

References bunchSpacing_, caloCollections_, framework::RandomNumberSeedService::CONDITIONS_OBJECT_NAME, doPoissonIT_, doPoissonOOT_, framework::Event::getCollection(), framework::EventProcessor::getCondition(), framework::Event::getEventHeader(), ldmx::EventHeader::getEventNumber(), nEarlier_, nLater_, overlayEvent_, overlayFile_, overlayIncidentID_, overlayPassName_, poissonMu_, ldmx::SimTrackerHit::Print(), rndm_, rndmTime_, simPassName_, timeMean_, timeSigma_, trackerCollections_, and verbosity_.

Member Data Documentation

◆ bunchSpacing_

double recon::OverlayProducer::bunchSpacing_ {0.}
private

Spacing in time (in [ns]) between electron bunches.

Definition at line 154 of file OverlayProducer.h.

154{0.};

Referenced by configure(), and produce().

◆ caloCollections_

std::vector<std::string> recon::OverlayProducer::caloCollections_
private

List of SimCalorimeterHit collection(s) to loop over and add hits from, combining sim and pileup.

Definition at line 89 of file OverlayProducer.h.

Referenced by configure(), and produce().

◆ doPoissonIT_

bool recon::OverlayProducer::doPoissonIT_ {false}
private

Let the total number of in-time events be poisson distributed, or fix at the chosen value, poissonMu_.

Definition at line 111 of file OverlayProducer.h.

111{false};

Referenced by configure(), and produce().

◆ doPoissonOOT_

bool recon::OverlayProducer::doPoissonOOT_ {false}
private

Let the total number of out-of-time events be poisson distributed, or fix at the chosen value, poissonMu_.

Definition at line 117 of file OverlayProducer.h.

117{false};

Referenced by configure(), and produce().

◆ nEarlier_

int recon::OverlayProducer::nEarlier_ {0}
private

Number of bunches before the sim event to pull pileup events from.

Defaults to 0 --> all events occur in the same bunch as the sim event.

Definition at line 161 of file OverlayProducer.h.

161{0};

Referenced by configure(), and produce().

◆ nLater_

int recon::OverlayProducer::nLater_ {0}
private

Number of bunches after the sim event to pull pileup events from.

Defaults to 0 --> all events occur in the same bunch as the sim event.

Definition at line 168 of file OverlayProducer.h.

168{0};

Referenced by configure(), and produce().

◆ overlayEvent_

framework::Event recon::OverlayProducer::overlayEvent_
private

The overlay ldmx event bus.

Definition at line 83 of file OverlayProducer.h.

Referenced by onNewRun(), onProcessStart(), and produce().

◆ overlayFile_

std::unique_ptr<framework::EventFile> recon::OverlayProducer::overlayFile_
private

Pileup overlay events input file.

Definition at line 78 of file OverlayProducer.h.

Referenced by onNewRun(), onProcessStart(), and produce().

◆ overlayFileName_

std::string recon::OverlayProducer::overlayFileName_
private

Pileup overlay events input file name.

Definition at line 73 of file OverlayProducer.h.

Referenced by configure(), and onProcessStart().

◆ overlayIncidentID_

int recon::OverlayProducer::overlayIncidentID_ {-1000}
private

For Ecal, overlay hits should be added as contribs.

But these are required to be unique, by the Ecal rconstruction code. So assign a nonsensical trackID, incidentID, and PDG ID to the contribs from overlay. These are hardwired right here.

Definition at line 181 of file OverlayProducer.h.

181{-1000};

Referenced by produce().

◆ overlayPassName_

std::string recon::OverlayProducer::overlayPassName_
private

Pileup overlay events input pass name.

Definition at line 100 of file OverlayProducer.h.

Referenced by configure(), and produce().

◆ overlayPdgCode_

int recon::OverlayProducer::overlayPdgCode_ {0}
private

Definition at line 183 of file OverlayProducer.h.

183{0};

◆ overlayTrackID_

int recon::OverlayProducer::overlayTrackID_ {-1000}
private

Definition at line 182 of file OverlayProducer.h.

182{-1000};

◆ params_

framework::config::Parameters recon::OverlayProducer::params_
private

The parameters used to configure this producer.

Definition at line 68 of file OverlayProducer.h.

Referenced by configure(), and onProcessStart().

◆ poissonMu_

double recon::OverlayProducer::poissonMu_ {0.}
private

(average) total number of events

Definition at line 122 of file OverlayProducer.h.

122{0.};

Referenced by configure(), and produce().

◆ rndm_

std::unique_ptr<TRandom2> recon::OverlayProducer::rndm_
private

Random number generator for number of overlaid events.

TRandom2 slightly (~10%) faster than TRandom3; shorter period but our input files will have way shorter period anyway.

Definition at line 129 of file OverlayProducer.h.

Referenced by onNewRun(), and produce().

◆ rndmTime_

std::unique_ptr<TRandom2> recon::OverlayProducer::rndmTime_
private

Random number generator for pileup event time offset.

TRandom2 slightly (~10%) faster than TRandom3; shorter period but our input files will have way shorter period anyway.

Definition at line 136 of file OverlayProducer.h.

Referenced by produce().

◆ simPassName_

std::string recon::OverlayProducer::simPassName_
private

To use for finding the sim event bus passengers, mostly a disambiguation.

Definition at line 105 of file OverlayProducer.h.

Referenced by configure(), and produce().

◆ timeMean_

double recon::OverlayProducer::timeMean_ {0.}
private

Average position in time (in [ns]) of pileup bunches, relative to the sim event.

Should realistically be 0. Using a non-zero mean and sigma = 0 is however useful for validation.

Definition at line 149 of file OverlayProducer.h.

149{0.};

Referenced by configure(), and produce().

◆ timeSigma_

double recon::OverlayProducer::timeSigma_ {0.}
private

Width of pileup bunch spread in time (in [ns]), specified as a sigma of a Gaussian distribution.

Definition at line 142 of file OverlayProducer.h.

142{0.};

Referenced by configure(), and produce().

◆ trackerCollections_

std::vector<std::string> recon::OverlayProducer::trackerCollections_
private

List of SimTrackerHit collection(s) to loop over and add hits from, combining sim and pileup.

Definition at line 95 of file OverlayProducer.h.

Referenced by configure(), and produce().

◆ verbosity_

int recon::OverlayProducer::verbosity_
private

Local control of processor verbosity.

Definition at line 173 of file OverlayProducer.h.

Referenced by configure(), onProcessStart(), and produce().


The documentation for this class was generated from the following files: