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 process (Event &event) final
 Processing an event for a Producer is calling produce.
 
- Public Member Functions inherited from framework::EventProcessor
 DECLARE_FACTORY (EventProcessor, EventProcessor *, const std::string &, Process &)
 declare that we have a factory for this class
 
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()=default
 Class destructor.
 
virtual void beforeNewRun (ldmx::RunHeader &run_header)
 Callback for Producers to add parameters to the run header before conditions are initialized.
 
virtual void onFileOpen (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &event_file)
 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 overlay_filename_
 Pileup overlay events input file name.
 
std::unique_ptr< framework::EventFileoverlay_file_
 Pileup overlay events input file.
 
framework::Event overlay_event_
 The overlay ldmx event bus.
 
std::vector< std::string > calo_collections_
 List of SimCalorimeterHit collection(s) to loop over and add hits from, combining sim and pileup.
 
std::vector< std::string > tracker_collections_
 List of SimTrackerHit collection(s) to loop over and add hits from, combining sim and pileup.
 
std::string overlay_passname_
 Pileup overlay events input pass name.
 
std::string sim_passname_
 To use for finding the sim event bus passengers, mostly a disambiguation.
 
std::string out_coll_postfix_
 Postfix to add to the collection name of the overlayed collections.
 
bool do_poisson_in_time_ {false}
 Let the total number of in-time events be poisson distributed, or fix at the chosen value, poissonMu_.
 
bool do_poisson_out_of_time_ {false}
 Let the total number of out-of-time events be poisson distributed, or fix at the chosen value, poissonMu_.
 
double poisson_mu_ {0.}
 (average) total number of events
 
std::unique_ptr< TRandom2 > rndm_
 Random number generator for number of overlaid events.
 
std::unique_ptr< TRandom2 > rndm_time_
 Random number generator for pileup event time offset.
 
double time_sigma_ {0.}
 Width of pileup bunch spread in time (in [ns]), specified as a sigma of a Gaussian distribution.
 
double time_mean_ {0.}
 Average position in time (in [ns]) of pileup bunches, relative to the sim event.
 
double bunch_spacing_ {0.}
 Spacing in time (in [ns]) between electron bunches.
 
int n_earlier_ {0}
 Number of bunches before the sim event to pull pileup events from.
 
int n_later_ {0}
 Number of bunches after the sim event to pull pileup events from.
 
int start_event_min_ {1}
 Minimum event number to start overlaying from.
 
int start_event_max_ {10000}
 Maximum event number to start overlaying from.
 
int overlay_incident_id_ {-1000}
 For Ecal, overlay hits should be added as contribs.
 
int overlay_track_id_ {-1000}
 
int overlay_pdg_code_ {0}
 

Additional Inherited Members

- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramPool histograms_
 helper object for making and filling histograms
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger the_log_
 The logger for this EventProcessor.
 

Detailed Description

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

Definition at line 26 of file OverlayProducer.h.

Constructor & Destructor Documentation

◆ OverlayProducer()

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

Definition at line 28 of file OverlayProducer.h.

29 : framework::Producer(name, process), overlay_event_{"overlay"} {}
Base class for a module which produces a data product.
virtual void process(Event &event) final
Processing an event for a Producer is calling produce.
framework::Event overlay_event_
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 5 of file OverlayProducer.cxx.

5 {
6 params_ = parameters;
7
8 // name of file containing events to be overlaid, and a list of collections to
9 // overlay
10 overlay_filename_ = parameters.get<std::string>("overlay_filename");
12 parameters.get<std::vector<std::string>>("calo_collections");
14 parameters.get<std::vector<std::string>>("tracker_collections");
15 sim_passname_ = parameters.get<std::string>("sim_passname");
16 overlay_passname_ = parameters.get<std::string>("overlay_passname");
17 out_coll_postfix_ = parameters.get<std::string>("out_coll_postfix");
18 // overlay specifics:
19 poisson_mu_ = parameters.get<double>("poisson_mu");
20 do_poisson_in_time_ = parameters.get<bool>("do_poisson_in_time");
21 do_poisson_out_of_time_ = parameters.get<bool>("do_poisson_out_of_time");
22 time_sigma_ = parameters.get<double>("time_sigma");
23 time_mean_ = parameters.get<double>("time_mean");
24 n_earlier_ = parameters.get<int>("n_earlier");
25 n_later_ = parameters.get<int>("n_later");
26 bunch_spacing_ = parameters.get<double>("bunch_spacing");
27 start_event_min_ = parameters.get<int>("start_event_min");
28 start_event_max_ = parameters.get<int>("start_event_max");
29
31 ldmx_log(debug) << "Got parameters \n \t overlayFileName = "
33 << "\n\t sim pass name = " << sim_passname_
34 << "\n\t overlay pass name = " << overlay_passname_;
35 ldmx_log(debug) << "\n\t overlayCaloHitCollections = ";
36 for (const auto &coll : calo_collections_) {
37 ldmx_log(debug) << coll << "; ";
38 }
39
40 ldmx_log(debug) << "\n\t overlayTrackerHitCollections = ";
41 for (const std::string &coll : tracker_collections_) {
42 ldmx_log(debug) << coll << "; ";
43 }
44
45 ldmx_log(trace) << "\n\t numberOverlaidInteractions = " << poisson_mu_
46 << "\n\t nEarlierBunchesToSample = " << n_earlier_
47 << "\n\t nLaterBunchesToSample = " << n_later_
48 << "\n\t bunchSpacing = " << bunch_spacing_
49 << "\n\t doPoissonIntime = " << do_poisson_in_time_
50 << "\n\t doPoissonOutoftime = " << do_poisson_out_of_time_
51 << "\n\t timeSpread = " << time_sigma_
52 << "\n\t timeMean = " << time_mean_
53 << "\n\t startEventMin = " << start_event_min_
54 << "\n\t startEventMax = " << start_event_max_;
55
56 return;
57} // end configure()
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
int start_event_max_
Maximum event number to start overlaying from.
std::string overlay_filename_
Pileup overlay events input file name.
bool do_poisson_in_time_
Let the total number of in-time events be poisson distributed, or fix at the chosen value,...
int n_later_
Number of bunches after the sim event to pull pileup events from.
std::string overlay_passname_
Pileup overlay events input pass name.
bool do_poisson_out_of_time_
Let the total number of out-of-time events be poisson distributed, or fix at the chosen value,...
std::vector< std::string > tracker_collections_
List of SimTrackerHit collection(s) to loop over and add hits from, combining sim and pileup.
framework::config::Parameters params_
The parameters used to configure this producer.
double bunch_spacing_
Spacing in time (in [ns]) between electron bunches.
std::string sim_passname_
To use for finding the sim event bus passengers, mostly a disambiguation.
std::vector< std::string > calo_collections_
List of SimCalorimeterHit collection(s) to loop over and add hits from, combining sim and pileup.
double poisson_mu_
(average) total number of events
std::string out_coll_postfix_
Postfix to add to the collection name of the overlayed collections.
double time_sigma_
Width of pileup bunch spread in time (in [ns]), specified as a sigma of a Gaussian distribution.
int start_event_min_
Minimum event number to start overlaying from.
double time_mean_
Average position in time (in [ns]) of pileup bunches, relative to the sim event.
int n_earlier_
Number of bunches before the sim event to pull pileup events from.

References bunch_spacing_, calo_collections_, do_poisson_in_time_, do_poisson_out_of_time_, framework::config::Parameters::get(), n_earlier_, n_later_, out_coll_postfix_, overlay_filename_, overlay_passname_, params_, poisson_mu_, sim_passname_, start_event_max_, start_event_min_, time_mean_, time_sigma_, and tracker_collections_.

◆ 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 59 of file OverlayProducer.cxx.

59 {
63 rndm_ = std::make_unique<TRandom2>(rnss.getSeed("OverlayProducer::rndm"));
65 std::make_unique<TRandom2>(rnss.getSeed("OverlayProducer::rndmTime"));
66
67 // Pick a random event from the Pileup file
68 int start_event = rndm_->Uniform(start_event_min_, start_event_max_);
69 // EventFile::skipToEvent handles actual number of events in file
70 int ev_number = overlay_file_->skipToEvent(start_event);
71 if (ev_number < 0) {
72 EXCEPTION_RAISE("BadRead", "Couldn't read to starting offset.");
73 }
75 ldmx_log(info) << "Starting overlay process with pileup event number "
76 << ev_number << " (random event number picked was "
77 << start_event << ").";
78} // end onNewRun()
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 > overlay_file_
Pileup overlay events input file.
std::unique_ptr< TRandom2 > rndm_time_
Random number generator for pileup event time offset.
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(), overlay_event_, overlay_file_, rndm_, rndm_time_, ldmx::EventHeader::setEventNumber(), start_event_max_, and start_event_min_.

◆ 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 367 of file OverlayProducer.cxx.

367 {
368 // replace by this line once the corresponding tweak to EventFile is ready:
370 std::make_unique<framework::EventFile>(params_, overlay_filename_, true);
371 overlay_file_->setupEvent(&overlay_event_);
372 // we update the iterator at the end of each event. so do this once here to
373 // grab the first event in the processor
374 // ldmx_log(trace) << "Used input file: "
375 // << overlay_file_->getFileName() << " Got event info: " <<
376 // overlay_file_->getEvent()->Print();
377
378 return;
379} // end onProcessStart

References overlay_event_, overlay_file_, overlay_filename_, and params_.

◆ 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 // using nextEvent to loop, we need to loop over overlay events and in an
82 // inner loop, loop over collections, and store them. after all pileup events
83 // have been added, the vector of collections is iterated over and added to
84 // the event bus.
85 std::map<std::string, std::vector<ldmx::SimCalorimeterHit>>
86 calo_collection_map;
87 std::map<std::string, std::vector<ldmx::SimTrackerHit>>
88 tracker_collection_map;
89 std::map<int, ldmx::SimCalorimeterHit> hit_map;
90
91 // start by copying over all the collections from the sim event
92
93 /* ----------- first do the SimCalorimeterHits ----------- */
94
95 // get the calo hits_ collections that we want to overlay, by looping over
96 // the list of collections passed to the producer : calo_collections_
97 for (const auto &coll_name : calo_collections_) {
98 // for now, Ecal and only Ecal uses contribs instead of multiple
99 // simhits_calo per channel, meaning, it requires special treatment
100 auto needs_contribs_added{
101 coll_name.find("Ecal") != std::string::npos ? true : false};
102
103 // start out by just copying the sim hits_, unaltered.
104 auto simhits_calo =
105 event.getCollection<ldmx::SimCalorimeterHit>(coll_name, sim_passname_);
106 // but don't copy ecal hits_ immediately: for them, wait until overlay
107 // contribs have been added. then add everything through the hit_map
108 if (!needs_contribs_added) {
109 calo_collection_map[coll_name + out_coll_postfix_] = simhits_calo;
110 }
111
112 ldmx_log(debug) << "in loop: start of collection " << coll_name
113 << "in loop: printing current sim event: ";
114 ldmx_log(debug) << "in loop: size of sim hits_ vector " << coll_name
115 << " is " << simhits_calo.size();
116
117 // we don't need to touch the hard process sim hits_, really... but we
118 // might need the simhits in the hit map.
119 if (needs_contribs_added) {
120 for (const ldmx::SimCalorimeterHit &simhit : simhits_calo) {
121 ldmx_log(trace) << simhit;
122 // this copies the hit, its ID and its coordinates directly
123 hit_map[simhit.getID()] = simhit;
124
125 } // over calo simhit collection
126 } // if needContribs
127
128 } // over calo collections for sim event
129
130 /* ----------- now do the same with SimTrackerHits! ----------- */
131
132 // get the SimTrackerHit collections that we want to overlay, by looping
133 // over the list of collections passed to the producer : tracker_collections_
134 for (const auto &coll_name : tracker_collections_) {
135 auto simhits_tracker =
136 event.getCollection<ldmx::SimTrackerHit>(coll_name, sim_passname_);
137 tracker_collection_map[coll_name + out_coll_postfix_] = simhits_tracker;
138
139 // the rest is printouts for debugging
140 ldmx_log(debug) << "in loop: size of sim hits_ vector " << coll_name
141 << " is " << simhits_tracker.size();
142
143 ldmx_log(debug) << "in loop: start of collection " << coll_name
144 << "in loop: printing current sim event: ";
145
146 for (const ldmx::SimTrackerHit &simhit : simhits_tracker) {
147 ldmx_log(trace) << simhit;
148 }
149 } // over tracker collections for sim event
150
151 /* ----------- now do the pileup overlay ----------- */
152
153 // we could shift these by a random number, effectively placing the
154 // sim event at random positions in the interval, preserving the
155 // overall interval length
156 // int simBunch= static_cast<int>(rndm_time_->Uniform(
157 // -(n_earlier_+1) , n_later_+1)); // +1 to get
158 // inclusive interval
159 int start_bunch = -n_earlier_;
160 int end_bunch = n_later_;
161
162 // TODO -- figure out if we should also randomly shift the time of the sim
163 // event (likely only needed if time bias gets picked up by BDT or ML by way
164 // of pulse behaviour)
165 for (int bunch_offset{start_bunch}; bunch_offset <= end_bunch;
166 bunch_offset++) {
167 // sample a poisson distribution, or use mu as fixed number of overlay
168 // events
169 int n_events_overlay = do_poisson_out_of_time_
170 ? rndm_->Poisson(poisson_mu_)
171 : static_cast<int>(poisson_mu_);
172
173 // special case: in-time pileup at bunch 0
174 if (bunch_offset == 0) {
175 if (!do_poisson_in_time_) {
176 // fix it to the average
177 n_events_overlay = static_cast<int>(poisson_mu_);
179 // then we haven't set this yet
180 n_events_overlay = rndm_->Poisson(poisson_mu_);
181 }
182
183 // paticularly useful in the poisson fluctuated case
184 event.getEventHeader().setIntParameter("in_time_pu", n_events_overlay);
185
186 // the total number of events is nPU + 1 (it includes the sim event)
187 // in any case, subtract the sim event from nOverlay
188 n_events_overlay -= 1;
189
190 } // end if bunch_offset == 0
191
192 float bunchtime_offset = bunch_spacing_ * bunch_offset;
193 ldmx_log(debug) << "Will overlay " << n_events_overlay
194 << " events on the simulated one";
195
196 for (int i_ev = 0; i_ev < n_events_overlay; i_ev++) {
203 if (!overlay_file_->nextEvent()) {
204 ldmx_log(error) << "Couldn't read next overlay event!";
205 return;
206 }
207
208 // a pileup event wide time offset to be applied to all its hits_.
209 float time_offset = rndm_time_->Gaus(time_mean_, time_sigma_);
210 time_offset += bunchtime_offset;
211
212 ldmx_log(trace) << "in overlay loop: overlaying event " << "which is "
213 << i_ev + 1 << " out of " << n_events_overlay
214 << "\n\thit time offset is " << time_offset << " ns"
215 << "\n\tbunch position offset is " << bunch_offset
216 << ", leading to a total time offset of "
217 << bunchtime_offset << " ns";
218
219 /* ----------- first do the SimCalorimeterHits overlay ----------- */
220
221 // again get the calo hits_ collections that we want to overlay
222 for (uint i_coll = 0; i_coll < calo_collections_.size(); i_coll++) {
223 // for now, Ecal and only Ecal uses contribs
224 bool needs_contribs_added = false;
225 if (strstr(calo_collections_[i_coll].c_str(), "Ecal")) {
226 needs_contribs_added = true;
227 }
228
229 std::vector<ldmx::SimCalorimeterHit> overlay_hits =
232
233 ldmx_log(debug) << "in loop: size of overlay hits_ vector is "
234 << overlay_hits.size();
235
236 std::string out_coll_name =
238
239 ldmx_log(trace) << "in loop: printing overlay event: ";
240
241 for (ldmx::SimCalorimeterHit &overlay_hit : overlay_hits) {
242 ldmx_log(trace) << overlay_hit;
243
244 const float overlay_time = overlay_hit.getTime() + time_offset;
245 overlay_hit.setTime(overlay_time);
246
247 if (needs_contribs_added) { // special treatment for (for now only)
248 // ecal
249 int overlay_hit_id = overlay_hit.getID();
250 if (hit_map.find(overlay_hit_id) ==
251 hit_map.end()) { // there wasn't already a simhit in this id
252 hit_map[overlay_hit_id] = ldmx::SimCalorimeterHit();
253 hit_map[overlay_hit_id].setID(overlay_hit_id);
254 std::vector<float> hit_pos = overlay_hit.getPosition();
255 hit_map[overlay_hit_id].setPosition(hit_pos[0], hit_pos[1],
256 hit_pos[2]);
257 }
258 // add the overlay hit (as a) contrib
259 // incidentID = -1000, trackID = -1000, pdgCode = 0 <-- these are
260 // set in the header for now but could be parameters
261 hit_map[overlay_hit_id].addContrib(
262 overlay_incident_id_, overlay_track_id_, overlay_pdg_code_,
263 overlay_hit.getEdep(), overlay_time);
264 } // if add overlay as contribs
265 else {
266 calo_collection_map[out_coll_name].push_back(overlay_hit);
267
268 ldmx_log(trace) << "Adding non-Ecal overlay hit to outhit vector "
269 << out_coll_name;
270 } // end else !needs_contribs_added
271 } // over overlay calo simhit collection
272
273 if (!needs_contribs_added)
274 ldmx_log(debug) << "Nhits in overlay collection " << out_coll_name
275 << ": " << calo_collection_map[out_coll_name].size();
276
277 } // over caloCollections
278
279 /* ----------- now do simtracker hits_ overlay ----------- */
280
281 // get the SimTrackerHit collections that we want to overlay
282 for (const auto &coll : tracker_collections_) {
283 auto overlay_tracker_hits{
285 coll, overlay_passname_)};
286
287 ldmx_log(debug) << "in loop: size of overlay hits_ vector is "
288 << overlay_tracker_hits.size();
289
290 std::string out_coll_name_tracker{coll + out_coll_postfix_};
291
292 ldmx_log(trace) << "in loop: printing overlay event: ";
293
294 for (auto &overlay_hit : overlay_tracker_hits) {
295 auto overlay_time{overlay_hit.getTime() + time_offset};
296 overlay_hit.setTime(overlay_time);
297 tracker_collection_map[out_coll_name_tracker].push_back(overlay_hit);
298
299 ldmx_log(trace) << overlay_hit;
300 ldmx_log(trace) << "Adding tracker overlay hit to outhit vector "
301 << out_coll_name_tracker;
302 } // over overlay tracker simhit collection
303
304 ldmx_log(debug) << "Nhits in overlay collection "
305 << out_coll_name_tracker << ": "
306 << tracker_collection_map[out_coll_name_tracker].size();
307
308 } // over trackerCollections
309 } // over overlay events
310 } // over bunches
311
312 // after all events are done, the ecal hit_map is final and can be written
313 // to the event output
314 for (uint i_coll = 0; i_coll < calo_collections_.size(); i_coll++) {
315 // loop through collection names to find the right collection name
316 // add overlaid ecal hits_ as contribs/from hit_map rather than as copied
317 // simhits
318 if (strstr(calo_collections_[i_coll].c_str(), "Ecal")) {
319 ldmx_log(trace) << "Hits in hit_map after overlay of "
320 << calo_collections_[i_coll] << "Overlay :";
321
322 for (auto &map_hit : hit_map) {
323 ldmx_log(trace) << map_hit.second;
324
325 if (calo_collection_map.find(calo_collections_[i_coll] +
327 calo_collection_map.end()) {
328 ldmx_log(debug) << "Adding first hit from hit map as first outhit "
329 "vector to calo_collection_map";
330 calo_collection_map[calo_collections_[i_coll] + out_coll_postfix_] = {
331 map_hit.second};
332 } else {
333 calo_collection_map[calo_collections_[i_coll] + out_coll_postfix_]
334 .push_back(map_hit.second);
335 }
336 } // over hit_map
337 break; // for now we only have one hit_map: for Ecal. so no need
338 // looking further after we got a match
339 } // isEcal
340 } // second loop over collections, to collect hits_ from hit_map
341
342 // done collecting hits_.
343
344 // now we can write the calo collections to the event bus
345 for (auto &[name, coll] : calo_collection_map) {
346 ldmx_log(debug) << "Writing " << name << " to event bus.";
347
348 ldmx_log(trace) << "List of hits_ added: ";
349 for (auto &hit : coll) {
350 ldmx_log(trace) << hit;
351 }
352 event.add(name, coll);
353 }
354
355 // and now for the tracker hits_
356 for (auto &[name, coll] : tracker_collection_map) {
357 ldmx_log(debug) << "Writing " << name << " to event bus.";
358 ldmx_log(trace) << "List of hits_ added: ";
359 for (auto &hit : coll) {
360 ldmx_log(trace) << hit;
361 }
362 event.add(name, coll);
363 }
364 return;
365} // end produce()
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:400
Stores simulated calorimeter hit information.
Represents a simulated tracker hit in the simulation.
int overlay_incident_id_
For Ecal, overlay hits should be added as contribs.

References bunch_spacing_, calo_collections_, do_poisson_in_time_, do_poisson_out_of_time_, framework::Event::getCollection(), n_earlier_, n_later_, out_coll_postfix_, overlay_event_, overlay_file_, overlay_incident_id_, overlay_passname_, poisson_mu_, rndm_, rndm_time_, sim_passname_, time_mean_, time_sigma_, and tracker_collections_.

Member Data Documentation

◆ bunch_spacing_

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

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

Definition at line 163 of file OverlayProducer.h.

163{0.};

Referenced by configure(), and produce().

◆ calo_collections_

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

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

Definition at line 92 of file OverlayProducer.h.

Referenced by configure(), and produce().

◆ do_poisson_in_time_

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

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

Definition at line 120 of file OverlayProducer.h.

120{false};

Referenced by configure(), and produce().

◆ do_poisson_out_of_time_

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

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

Definition at line 126 of file OverlayProducer.h.

126{false};

Referenced by configure(), and produce().

◆ n_earlier_

int recon::OverlayProducer::n_earlier_ {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 170 of file OverlayProducer.h.

170{0};

Referenced by configure(), and produce().

◆ n_later_

int recon::OverlayProducer::n_later_ {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 177 of file OverlayProducer.h.

177{0};

Referenced by configure(), and produce().

◆ out_coll_postfix_

std::string recon::OverlayProducer::out_coll_postfix_
private

Postfix to add to the collection name of the overlayed collections.

This is currently set to "Overlay".

Definition at line 114 of file OverlayProducer.h.

Referenced by configure(), and produce().

◆ overlay_event_

framework::Event recon::OverlayProducer::overlay_event_
private

The overlay ldmx event bus.

Definition at line 86 of file OverlayProducer.h.

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

◆ overlay_file_

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

Pileup overlay events input file.

Definition at line 81 of file OverlayProducer.h.

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

◆ overlay_filename_

std::string recon::OverlayProducer::overlay_filename_
private

Pileup overlay events input file name.

Definition at line 76 of file OverlayProducer.h.

Referenced by configure(), and onProcessStart().

◆ overlay_incident_id_

int recon::OverlayProducer::overlay_incident_id_ {-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 197 of file OverlayProducer.h.

197{-1000};

Referenced by produce().

◆ overlay_passname_

std::string recon::OverlayProducer::overlay_passname_
private

Pileup overlay events input pass name.

Definition at line 103 of file OverlayProducer.h.

Referenced by configure(), and produce().

◆ overlay_pdg_code_

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

Definition at line 199 of file OverlayProducer.h.

199{0};

◆ overlay_track_id_

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

Definition at line 198 of file OverlayProducer.h.

198{-1000};

◆ params_

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

The parameters used to configure this producer.

Definition at line 71 of file OverlayProducer.h.

Referenced by configure(), and onProcessStart().

◆ poisson_mu_

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

(average) total number of events

Definition at line 131 of file OverlayProducer.h.

131{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 138 of file OverlayProducer.h.

Referenced by onNewRun(), and produce().

◆ rndm_time_

std::unique_ptr<TRandom2> recon::OverlayProducer::rndm_time_
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 145 of file OverlayProducer.h.

Referenced by onNewRun(), and produce().

◆ sim_passname_

std::string recon::OverlayProducer::sim_passname_
private

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

Definition at line 108 of file OverlayProducer.h.

Referenced by configure(), and produce().

◆ start_event_max_

int recon::OverlayProducer::start_event_max_ {10000}
private

Maximum event number to start overlaying from.

Inclusive.

Definition at line 189 of file OverlayProducer.h.

189{10000};

Referenced by configure(), and onNewRun().

◆ start_event_min_

int recon::OverlayProducer::start_event_min_ {1}
private

Minimum event number to start overlaying from.

Inclusive.

Definition at line 183 of file OverlayProducer.h.

183{1};

Referenced by configure(), and onNewRun().

◆ time_mean_

double recon::OverlayProducer::time_mean_ {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 158 of file OverlayProducer.h.

158{0.};

Referenced by configure(), and produce().

◆ time_sigma_

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

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

Definition at line 151 of file OverlayProducer.h.

151{0.};

Referenced by configure(), and produce().

◆ tracker_collections_

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

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

Definition at line 98 of file OverlayProducer.h.

Referenced by configure(), and produce().


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