14void TrigScintDigiProducer::configure(
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");
28 std::make_unique<TRandom3>(parameters.
getParameter<
int>(
"randomSeed"));
30 noiseGenerator_ = std::make_unique<ldmx::NoiseGenerator>(meanNoise_,
false);
31 noiseGenerator_->setNoiseThreshold(1);
48 if (!noiseGenerator_->hasSeed()) {
49 const auto &rseed = getCondition<framework::RandomNumberSeedService>(
51 noiseGenerator_->seedGenerator(
52 rseed.getSeed(
"TrigScintDigiProducer::NoiseGenerator"));
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;
64 inputCollection_, inputPassName_)};
68 for (
const auto &simHit : simHits) {
75 std::vector<float> position = simHit.getPosition();
78 std::cout <<
id << std::endl;
82 for (
int i = 0; i < simHit.getNumberOfContribs(); i++) {
83 auto contrib = simHit.getContrib(i);
85 std::cout <<
"contrib " << i <<
" trackID: " << contrib.trackID
86 <<
" pdgID: " << contrib.pdgCode <<
" edep: " << contrib.edep
88 std::cout <<
"\t particle id: "
89 << particleMap[contrib.trackID].getPdgID()
90 <<
" particle status: "
91 << particleMap[contrib.trackID].getGenStatus() << std::endl;
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;
98 beamFrac[id] += contrib.edep;
106 if (Edep.find(
id) == Edep.end()) {
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();
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();
122 Time[id] += simHit.getTime() * simHit.getEdep();
127 std::vector<ldmx::TrigScintHit> trigScintHits;
130 for (std::map<ldmx::TrigScintID, float>::iterator it = Edep.begin();
131 it != Edep.end(); ++it) {
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_);
143 if (cellPEs[
id] >= 1) {
146 hit.
setPE(cellPEs[
id]);
159 trigScintHits.push_back(hit);
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;
177 int numEmptyCells = stripsPerArray_ - numRecHits;
178 std::vector<double> noiseHits_PE =
179 noiseGenerator_->generateNoiseHits(numEmptyCells);
183 for (
auto &noiseHitPE : noiseHits_PE) {
187 tempID = generateRandomID(module);
188 }
while (Edep.find(tempID) != Edep.end() ||
189 noiseHitIDs.find(tempID) != noiseHitIDs.end());
193 noiseHitIDs.insert(noiseID);
195 hit.
setPE(noiseHitPE);
208 trigScintHits.push_back(hit);
213 event.add(outputCollection_, trigScintHits);
Class representing a simulated particle.