Process the event and put new data products into it.
46 {
47
49 const auto &rseed = getCondition<framework::RandomNumberSeedService>(
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
66
67 int module{-1};
68 for (const auto &simHit : simHits) {
70
71
72
73
74 module = id.module();
75 std::vector<float> position = simHit.getPosition();
76
78 std::cout << id << std::endl;
79 }
80
81
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
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
103
104
105
106 if (Edep.find(id) == Edep.end()) {
107
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
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
122 Time[id] += simHit.getTime() * simHit.getEdep();
123 }
124 }
125
126
127 std::vector<ldmx::TrigScintHit> trigScintHits;
128
129
130 for (std::map<ldmx::TrigScintID, float>::iterator it = Edep.begin();
131 it != Edep.end(); ++it) {
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];
141
142
143 if (cellPEs[id] >= 1) {
146 hit.
setPE(cellPEs[
id]);
158
159 trigScintHits.push_back(hit);
160 }
161
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 }
171 }
172
173
174
175
176
178 std::vector<double> noiseHits_PE =
180
182
183 for (auto &noiseHitPE : noiseHits_PE) {
185
186 do {
187 tempID = generateRandomID(module);
188 } while (Edep.find(tempID) != Edep.end() ||
189 noiseHitIDs.find(tempID) != noiseHitIDs.end());
190
192
193 noiseHitIDs.insert(noiseID);
195 hit.
setPE(noiseHitPE);
207
208 trigScintHits.push_back(hit);
209 }
210
211
212
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.
void setMinPE(float minpe)
Set the minimum number of photoelectrons estimated for this hit.
Stores simulated calorimeter hit information.
Class representing a simulated particle.
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.