Process the event and put new data products into it.
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
58
59 int module{-1};
60 for (const auto &simHit : simHits) {
62
63
64
65
66 module = id.module();
67 std::vector<float> position = simHit.getPosition();
68
70 std::cout << id << std::endl;
71 }
72
73
74 for (int i = 0; i < simHit.getNumberOfContribs(); i++) {
75 auto contrib = simHit.getContrib(i);
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
96
97
98
99 if (Edep.find(id) == Edep.end()) {
100
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
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
115 Time[id] += simHit.getTime() * simHit.getEdep();
116 }
117 }
118
119
120 std::vector<ldmx::TrigScintHit> trigScintHits;
121
122
123 for (std::map<ldmx::TrigScintID, float>::iterator it = Edep.begin();
124 it != Edep.end(); ++it) {
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];
133 std::poisson_distribution<int> poisson_dist(meanPE +
meanNoise_);
134 cellPEs[id] = poisson_dist(
rng_);
135
136
137
138
139
140 if (cellPEs[id] >= 1) {
143 hit.
setPE(cellPEs[
id]);
155
156 trigScintHits.push_back(hit);
157 }
158
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 }
168 }
169
170
171
172
173
175 std::vector<double> noiseHits_PE =
177
179
180 for (auto &noiseHitPE : noiseHits_PE) {
182
183 do {
184 tempID = generateRandomID(module);
185 } while (Edep.find(tempID) != Edep.end() ||
186 noiseHitIDs.find(tempID) != noiseHitIDs.end());
187
189
190 noiseHitIDs.insert(noiseID);
192 hit.
setPE(noiseHitPE);
204
205 trigScintHits.push_back(hit);
206 }
207
208
209
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.
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.