LDMX Software
trigscint::TrigScintDigiProducer Class Reference

Performs digitization of simulated Trigger Scintillator data. More...

#include <TrigScintDigiProducer.h>

Public Types

typedef int layer
 
typedef std::pair< double, double > zboundaries
 

Public Member Functions

 TrigScintDigiProducer (const std::string &name, framework::Process &process)
 
void configure (framework::config::Parameters &parameters) override
 Callback for the processor to configure itself from the given set of parameters.
 
void produce (framework::Event &event) override
 Process the event and put new data products into it.
 
virtual void onNewRun (const ldmx::RunHeader &runHeader) override
 Random number generation.
 
ldmx::TrigScintID generateRandomID (int module)
 
- 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 onProcessStart ()
 Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.
 
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

std::mt19937 rng_
 Random number generator.
 
std::unique_ptr< ldmx::NoiseGeneratornoiseGenerator_ {nullptr}
 Generate noise hits given the number of channels and mean noise.
 
bool verbose_ {false}
 Class to set the verbosity level.
 
std::string inputCollection_
 Name of the input collection containing the sim hits.
 
std::string inputPassName_
 Name of the pass that the input collection is on (empty string means take any pass)
 
std::string outputCollection_
 Name of the output collection that will be used to stored the digitized trigger scintillator hits.
 
int stripsPerArray_ {50}
 Number of strips per array.
 
int numberOfArrays_ {3}
 Number of arrays.
 
double meanNoise_ {0}
 Mean readout noise.
 
double mevPerMip_ {1.40}
 Total MeV per MIP.
 
double pePerMip_ {13.5}
 Total number of photoelectrons per MIP.
 

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

Performs digitization of simulated Trigger Scintillator data.

Definition at line 37 of file TrigScintDigiProducer.h.

Member Typedef Documentation

◆ layer

int trigscint::TrigScintDigiProducer::layer

Definition at line 39 of file TrigScintDigiProducer.h.

◆ zboundaries

std::pair<double, double> trigscint::TrigScintDigiProducer::zboundaries

Definition at line 41 of file TrigScintDigiProducer.h.

Constructor & Destructor Documentation

◆ TrigScintDigiProducer()

trigscint::TrigScintDigiProducer::TrigScintDigiProducer ( const std::string & name,
framework::Process & process )

Definition at line 5 of file TrigScintDigiProducer.cxx.

7 : Producer(name, process) {}
Producer(const std::string &name, Process &process)
Class constructor.

Member Function Documentation

◆ configure()

void trigscint::TrigScintDigiProducer::configure ( framework::config::Parameters & parameters)
overridevirtual

Callback for the processor to configure itself from the given set of parameters.

Parameters
parametersParameterSet for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 9 of file TrigScintDigiProducer.cxx.

10 {
11 // Configure this instance of the producer
12 stripsPerArray_ = parameters.getParameter<int>("number_of_strips");
13 numberOfArrays_ = parameters.getParameter<int>("number_of_arrays");
14 meanNoise_ = parameters.getParameter<double>("mean_noise");
15 mevPerMip_ = parameters.getParameter<double>("mev_per_mip");
16 pePerMip_ = parameters.getParameter<double>("pe_per_mip");
17 inputCollection_ = parameters.getParameter<std::string>("input_collection");
18 inputPassName_ = parameters.getParameter<std::string>("input_pass_name");
19 outputCollection_ = parameters.getParameter<std::string>("output_collection");
20 verbose_ = parameters.getParameter<bool>("verbose");
21}
std::string inputPassName_
Name of the pass that the input collection is on (empty string means take any pass)
std::string inputCollection_
Name of the input collection containing the sim hits.
double meanNoise_
Mean readout noise.
std::string outputCollection_
Name of the output collection that will be used to stored the digitized trigger scintillator hits.
double pePerMip_
Total number of photoelectrons per MIP.
bool verbose_
Class to set the verbosity level.
int stripsPerArray_
Number of strips per array.

◆ generateRandomID()

ldmx::TrigScintID trigscint::TrigScintDigiProducer::generateRandomID ( int module)

Definition at line 36 of file TrigScintDigiProducer.cxx.

36 {
37 // Uniform distributions for integer generation
38 std::uniform_int_distribution<int> strips_dist(0, stripsPerArray_ - 1);
39 ldmx::TrigScintID tempID(module, strips_dist(rng_));
40 if (module >= TrigScintSection::NUM_SECTIONS) {
41 ldmx_log(fatal) << "TrigScintSection is not known";
42 }
43
44 return tempID;
45}
Class that defines the detector ID of the trigger scintillator.
Definition TrigScintID.h:14
std::mt19937 rng_
Random number generator.

◆ onNewRun()

void trigscint::TrigScintDigiProducer::onNewRun ( const ldmx::RunHeader & runHeader)
overridevirtual

Random number generation.

Reimplemented from framework::EventProcessor.

Definition at line 23 of file TrigScintDigiProducer.cxx.

23 {
24 noiseGenerator_ = std::make_unique<ldmx::NoiseGenerator>(meanNoise_, false);
25 noiseGenerator_->setNoiseThreshold(1);
26 // Set up seeds
29
30 noiseGenerator_->seedGenerator(
31 rseed.getSeed("TrigScintDigiProducer::NoiseGenerator"));
32 // Random number generator for module id
33 rng_.seed(rseed.getSeed("TrigScintDigiProducer"));
34}
const T & getCondition(const std::string &condition_name)
Access a conditions object for the current event.
static const std::string CONDITIONS_OBJECT_NAME
Conditions object name.
std::unique_ptr< ldmx::NoiseGenerator > noiseGenerator_
Generate noise hits given the number of channels and mean noise.

References framework::RandomNumberSeedService::CONDITIONS_OBJECT_NAME.

◆ produce()

void trigscint::TrigScintDigiProducer::produce ( framework::Event & event)
overridevirtual

Process the event and put new data products into it.

Parameters
eventThe Event to process.

Implements framework::Producer.

Definition at line 47 of file TrigScintDigiProducer.cxx.

47 {
48 std::map<ldmx::TrigScintID, int> cellPEs, cellMinPEs;
49 std::map<ldmx::TrigScintID, float> Xpos, Ypos, Zpos, Edep, Time, beamFrac;
50 std::set<ldmx::TrigScintID> noiseHitIDs;
51
52 auto numRecHits{0};
53
54 // looper over sim hits and aggregate energy depositions for each detID
55 const auto simHits{event.getCollection<ldmx::SimCalorimeterHit>(
57 auto particleMap{event.getMap<int, ldmx::SimParticle>("SimParticles")};
58
59 int module{-1};
60 for (const auto &simHit : simHits) {
61 ldmx::TrigScintID id(simHit.getID());
62
63 // Just set the module ID to use for noise hits here. Given that
64 // we are currently processing a single module at a time, setting
65 // it within the loop shouldn't matter.
66 module = id.module();
67 std::vector<float> position = simHit.getPosition();
68
69 if (verbose_) {
70 std::cout << id << std::endl;
71 }
72
73 // check if hits is from beam electron and, if so, add to beamFrac
74 for (int i = 0; i < simHit.getNumberOfContribs(); i++) {
75 auto contrib = simHit.getContrib(i);
76 if (verbose_) {
77 std::cout << "contrib " << i << " trackID: " << contrib.trackID
78 << " pdgID: " << contrib.pdgCode << " edep: " << contrib.edep
79 << std::endl;
80 std::cout << "\t particle id: "
81 << particleMap[contrib.trackID].getPdgID()
82 << " particle status: "
83 << particleMap[contrib.trackID].getGenStatus() << std::endl;
84 }
85 if (particleMap[contrib.trackID].getPdgID() == 11 &&
86 particleMap[contrib.trackID].getGenStatus() == 1) {
87 if (beamFrac.find(id) == beamFrac.end()) {
88 beamFrac[id] = contrib.edep;
89 } else {
90 beamFrac[id] += contrib.edep;
91 }
92 }
93 }
94
95 // for now, we take an energy weighted average of the hit in each strip to
96 // simulate the hit position. AJW: these should be dropped, they are likely
97 // to lead to a problem since we can't measure them anyway except roughly y
98 // and z, which is encoded in the ids.
99 if (Edep.find(id) == Edep.end()) {
100 // first hit, initialize
101 Edep[id] = simHit.getEdep();
102 Time[id] = simHit.getTime() * simHit.getEdep();
103 Xpos[id] = position[0] * simHit.getEdep();
104 Ypos[id] = position[1] * simHit.getEdep();
105 Zpos[id] = position[2] * simHit.getEdep();
106 numRecHits++;
107
108 } else {
109 // not first hit, aggregate, and store the largest radius hit
110 Xpos[id] += position[0] * simHit.getEdep();
111 Ypos[id] += position[1] * simHit.getEdep();
112 Zpos[id] += position[2] * simHit.getEdep();
113 Edep[id] += simHit.getEdep();
114 // AJW: need to figure out a better way to model this...
115 Time[id] += simHit.getTime() * simHit.getEdep();
116 }
117 }
118
119 // Create the container to hold the digitized trigger scintillator hits.
120 std::vector<ldmx::TrigScintHit> trigScintHits;
121
122 // loop over detIDs and simulate number of PEs
123 for (std::map<ldmx::TrigScintID, float>::iterator it = Edep.begin();
124 it != Edep.end(); ++it) {
125 ldmx::TrigScintID id(it->first);
126
127 double depEnergy = Edep[id];
128 Time[id] = Time[id] / Edep[id];
129 Xpos[id] = Xpos[id] / Edep[id];
130 Ypos[id] = Ypos[id] / Edep[id];
131 Zpos[id] = Zpos[id] / Edep[id];
132 double meanPE = depEnergy / mevPerMip_ * pePerMip_;
133 std::poisson_distribution<int> poisson_dist(meanPE + meanNoise_);
134 cellPEs[id] = poisson_dist(rng_);
135
136 // If a cell has a PE count above threshold, persit the hit.
137 // Thresholds are introduced (and configurable) in clustering.
138 // the cell PE >=1 suppresses artifical noise that is below one light
139 // quantum in the SiPM and unphysical.
140 if (cellPEs[id] >= 1) {
142 hit.setID(id.raw());
143 hit.setPE(cellPEs[id]);
144 hit.setMinPE(cellMinPEs[id]);
145 hit.setAmplitude(cellPEs[id]);
146 hit.setEnergy(depEnergy);
147 hit.setTime(Time[id]);
148 hit.setXPos(Xpos[id]);
149 hit.setYPos(Ypos[id]);
150 hit.setZPos(Zpos[id]);
151 hit.setModuleID(module);
152 hit.setBarID(id.bar()); // getFieldValue("bar"));
153 hit.setNoise(false);
154 hit.setBeamEfrac(beamFrac[id] / depEnergy);
155
156 trigScintHits.push_back(hit);
157 }
158
159 if (verbose_) {
160 std::cout << id << std::endl;
161 std::cout << "Edep: " << Edep[id] << std::endl;
162 std::cout << "numPEs: " << cellPEs[id] << std::endl;
163 std::cout << "time: " << Time[id] << std::endl;
164 std::cout << "z: " << Zpos[id] << std::endl;
165 std::cout << "\t X: " << Xpos[id] << "\t Y: " << Ypos[id]
166 << "\t Z: " << Zpos[id] << std::endl;
167 } // end verbose
168 }
169
170 // ------------------------------- Noise simulation -----------------------//
171 // ------------------------------------------------------------------------//
172 // only simulating for single array until
173 // all arrays are merged into one collection
174 int numEmptyCells = stripsPerArray_ - numRecHits;
175 std::vector<double> noiseHits_PE =
176 noiseGenerator_->generateNoiseHits(numEmptyCells);
177
178 ldmx::TrigScintID tempID;
179
180 for (auto &noiseHitPE : noiseHits_PE) {
182 // generate random ID from remaining cells
183 do {
184 tempID = generateRandomID(module);
185 } while (Edep.find(tempID) != Edep.end() ||
186 noiseHitIDs.find(tempID) != noiseHitIDs.end());
187
188 ldmx::TrigScintID noiseID = tempID;
189
190 noiseHitIDs.insert(noiseID);
191 hit.setID(noiseID.raw());
192 hit.setPE(noiseHitPE);
193 hit.setMinPE(noiseHitPE);
194 hit.setAmplitude(noiseHitPE);
195 hit.setEnergy(0.);
196 hit.setTime(0.);
197 hit.setXPos(0.);
198 hit.setYPos(0.);
199 hit.setZPos(0.);
200 hit.setModuleID(module);
201 hit.setBarID(noiseID.bar());
202 hit.setNoise(true);
203 hit.setBeamEfrac(0.);
204
205 trigScintHits.push_back(hit);
206 }
207 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
208 // - -
209
210 event.add(outputCollection_, trigScintHits);
211}
void setYPos(float ypos)
Set the Y position of the hit [mm].
void setID(int id)
Set the detector ID.
void setZPos(float zpos)
Set the Z position of the hit [mm].
void setXPos(float xpos)
Set the X position of the hit [mm].
void setTime(float time)
Set the time of the hit [ns].
void setAmplitude(float amplitude)
Set the amplitude of the hit, which is proportional to the signal in the calorimeter cell without sam...
void setEnergy(float energy)
Set the calorimetric energy of the hit, corrected for sampling factors [MeV].
void setNoise(bool yes)
Set if this hit is a noise hit.
RawValue raw() const
Definition DetectorID.h:68
void setMinPE(float minpe)
Set the minimum number of photoelectrons estimated for this hit.
Definition HcalHit.h:160
Stores simulated calorimeter hit information.
Class representing a simulated particle.
Definition SimParticle.h:23
void setPE(const float PE)
Set hit pe.
void setBarID(const int barID)
Set hit bar ID.
void setBeamEfrac(const float beamEfrac)
Set beam energy fraction of hit.
void setModuleID(const int moduleID)
Set hit module ID.
int bar() const
Get the value of the bar field from the ID.
Definition TrigScintID.h:64

References ldmx::TrigScintID::bar(), ldmx::DetectorID::raw(), ldmx::CalorimeterHit::setAmplitude(), ldmx::TrigScintHit::setBarID(), ldmx::TrigScintHit::setBeamEfrac(), ldmx::CalorimeterHit::setEnergy(), ldmx::CalorimeterHit::setID(), ldmx::HcalHit::setMinPE(), ldmx::TrigScintHit::setModuleID(), ldmx::CalorimeterHit::setNoise(), ldmx::TrigScintHit::setPE(), ldmx::CalorimeterHit::setTime(), ldmx::CalorimeterHit::setXPos(), ldmx::CalorimeterHit::setYPos(), and ldmx::CalorimeterHit::setZPos().

Member Data Documentation

◆ inputCollection_

std::string trigscint::TrigScintDigiProducer::inputCollection_
private

Name of the input collection containing the sim hits.

Definition at line 76 of file TrigScintDigiProducer.h.

◆ inputPassName_

std::string trigscint::TrigScintDigiProducer::inputPassName_
private

Name of the pass that the input collection is on (empty string means take any pass)

Definition at line 80 of file TrigScintDigiProducer.h.

◆ meanNoise_

double trigscint::TrigScintDigiProducer::meanNoise_ {0}
private

Mean readout noise.

Definition at line 93 of file TrigScintDigiProducer.h.

93{0};

◆ mevPerMip_

double trigscint::TrigScintDigiProducer::mevPerMip_ {1.40}
private

Total MeV per MIP.

Definition at line 96 of file TrigScintDigiProducer.h.

96{1.40};

◆ noiseGenerator_

std::unique_ptr<ldmx::NoiseGenerator> trigscint::TrigScintDigiProducer::noiseGenerator_ {nullptr}
private

Generate noise hits given the number of channels and mean noise.

Definition at line 69 of file TrigScintDigiProducer.h.

69{nullptr};

◆ numberOfArrays_

int trigscint::TrigScintDigiProducer::numberOfArrays_ {3}
private

Number of arrays.

Definition at line 90 of file TrigScintDigiProducer.h.

90{3};

◆ outputCollection_

std::string trigscint::TrigScintDigiProducer::outputCollection_
private

Name of the output collection that will be used to stored the digitized trigger scintillator hits.

Definition at line 84 of file TrigScintDigiProducer.h.

◆ pePerMip_

double trigscint::TrigScintDigiProducer::pePerMip_ {13.5}
private

Total number of photoelectrons per MIP.

Definition at line 99 of file TrigScintDigiProducer.h.

99{13.5};

◆ rng_

std::mt19937 trigscint::TrigScintDigiProducer::rng_
private

Random number generator.

Definition at line 66 of file TrigScintDigiProducer.h.

◆ stripsPerArray_

int trigscint::TrigScintDigiProducer::stripsPerArray_ {50}
private

Number of strips per array.

Definition at line 87 of file TrigScintDigiProducer.h.

87{50};

◆ verbose_

bool trigscint::TrigScintDigiProducer::verbose_ {false}
private

Class to set the verbosity level.

Definition at line 73 of file TrigScintDigiProducer.h.

73{false};

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