LDMX Software
Public Types | Public Member Functions | Private Attributes | List of all members
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.
 
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 onNewRun (const ldmx::RunHeader &runHeader)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
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::unique_ptr< TRandom3 > random_ {nullptr}
 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 41 of file TrigScintDigiProducer.h.

Member Typedef Documentation

◆ layer

typedef int trigscint::TrigScintDigiProducer::layer

Definition at line 43 of file TrigScintDigiProducer.h.

◆ zboundaries

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

Definition at line 45 of file TrigScintDigiProducer.h.

Constructor & Destructor Documentation

◆ TrigScintDigiProducer()

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

Definition at line 10 of file TrigScintDigiProducer.cxx.

12 : 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 14 of file TrigScintDigiProducer.cxx.

15 {
16 // Configure this instance of the producer
17 stripsPerArray_ = parameters.getParameter<int>("number_of_strips");
18 numberOfArrays_ = parameters.getParameter<int>("number_of_arrays");
19 meanNoise_ = parameters.getParameter<double>("mean_noise");
20 mevPerMip_ = parameters.getParameter<double>("mev_per_mip");
21 pePerMip_ = parameters.getParameter<double>("pe_per_mip");
22 inputCollection_ = parameters.getParameter<std::string>("input_collection");
23 inputPassName_ = parameters.getParameter<std::string>("input_pass_name");
24 outputCollection_ = parameters.getParameter<std::string>("output_collection");
25 verbose_ = parameters.getParameter<bool>("verbose");
26
27 random_ =
28 std::make_unique<TRandom3>(parameters.getParameter<int>("randomSeed"));
29
30 noiseGenerator_ = std::make_unique<ldmx::NoiseGenerator>(meanNoise_, false);
31 noiseGenerator_->setNoiseThreshold(1);
32}
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89
std::string inputPassName_
Name of the pass that the input collection is on (empty string means take any pass)
std::unique_ptr< TRandom3 > random_
Random number generator.
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.
std::unique_ptr< ldmx::NoiseGenerator > noiseGenerator_
Generate noise hits given the number of channels and mean noise.

References framework::config::Parameters::getParameter().

◆ generateRandomID()

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

Definition at line 34 of file TrigScintDigiProducer.cxx.

34 {
35 ldmx::TrigScintID tempID(module, random_->Integer(stripsPerArray_));
36 if (module >= TrigScintSection::NUM_SECTIONS) {
37 // Throw an exception
38 std::cout << "WARNING [TrigScintDigiProducer::generateRandomID]: "
39 "TrigScintSection is not known"
40 << std::endl;
41 }
42
43 return tempID;
44}
Class that defines the detector ID of the trigger scintillator.
Definition TrigScintID.h:14

◆ 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 46 of file TrigScintDigiProducer.cxx.

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

◆ meanNoise_

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

Mean readout noise.

Definition at line 92 of file TrigScintDigiProducer.h.

92{0};

◆ mevPerMip_

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

Total MeV per MIP.

Definition at line 95 of file TrigScintDigiProducer.h.

95{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 68 of file TrigScintDigiProducer.h.

68{nullptr};

◆ numberOfArrays_

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

Number of arrays.

Definition at line 89 of file TrigScintDigiProducer.h.

89{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 83 of file TrigScintDigiProducer.h.

◆ pePerMip_

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

Total number of photoelectrons per MIP.

Definition at line 98 of file TrigScintDigiProducer.h.

98{13.5};

◆ random_

std::unique_ptr<TRandom3> trigscint::TrigScintDigiProducer::random_ {nullptr}
private

Random number generator.

Definition at line 65 of file TrigScintDigiProducer.h.

65{nullptr};

◆ stripsPerArray_

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

Number of strips per array.

Definition at line 86 of file TrigScintDigiProducer.h.

86{50};

◆ verbose_

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

Class to set the verbosity level.

Definition at line 72 of file TrigScintDigiProducer.h.

72{false};

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