Event processor.
Convert reads information from BeamBackHits and writes tree file.
117 {
118
119 StoreArray<MCParticle> McParticles;
120
121
122 StoreArray<PXDSimHit> PXDSimHits;
123 StoreArray<SVDSimHit> SVDSimHits;
124 StoreArray<CDCSimHit> CDCSimHits;
125 StoreArray<ARICHSimHit> ARICHSimHits;
126 StoreArray<TOPSimHit> TOPSimHits;
127 StoreArray<ECLSimHit> ECLSimHits;
128 StoreArray<KLMSimHit> KLMSimHits;
129
130 for (Int_t i = 0; i < 13; i++) {
131 m_nSimHits[i] = 0;
132 m_hitPDG[i] = 0;
133 m_momPDG[i] = 0;
134 }
135
136 m_nSimHits[1] = PXDSimHits.getEntries();
137 m_nSimHits[2] = SVDSimHits.getEntries();
138 m_nSimHits[3] = CDCSimHits.getEntries();
139 m_nSimHits[4] = ARICHSimHits.getEntries();
140 m_nSimHits[5] = TOPSimHits.getEntries();
141 m_nSimHits[6] = ECLSimHits.getEntries();
142 m_nSimHits[7] = KLMSimHits.getEntries();
143
144
145 for (Int_t hit = 0; hit < m_nSimHits[7]; hit++) {
146
147
148 const KLMSimHit* simHit = KLMSimHits[hit];
149 Float_t posZ = simHit->getPositionZ();
150 if (280.0 < posZ && posZ < 288.0) m_nSimHits[9]++;
151 else if (400.0 < posZ && posZ < 406.0) m_nSimHits[10]++;
152 else if (-194.0 < posZ && posZ < -186.0) m_nSimHits[11]++;
153 else if (-294.0 < posZ && posZ < -286.0) m_nSimHits[12]++;
154 }
155
156 RelationIndex<MCParticle, PXDSimHit> relPXDSimHitToMCParticle(McParticles, PXDSimHits);
157 RelationIndex<MCParticle, SVDSimHit> relSVDSimHitToMCParticle(McParticles, SVDSimHits);
158 RelationIndex<MCParticle, CDCSimHit> relCDCSimHitToMCParticle(McParticles, CDCSimHits);
159 RelationIndex<MCParticle, ARICHSimHit> relARICHSimHitToMCParticle(McParticles, ARICHSimHits);
160 RelationIndex<MCParticle, TOPSimHit> relTOPSimHitToMCParticle(McParticles, TOPSimHits);
161 RelationIndex<MCParticle, ECLSimHit> relECLSimHitToMCParticle(McParticles, ECLSimHits);
162 RelationIndex<MCParticle, KLMSimHit> relKLMSimHitToMCParticle(McParticles, KLMSimHits);
163
164 Int_t detID;
165
166
167 detID = 1;
168
169 for (Int_t iHit = 0; iHit < m_nSimHits[detID]; iHit++) {
170 const PXDSimHit* simHit = PXDSimHits[iHit];
171
172 if (relPXDSimHitToMCParticle.getFirstElementTo(simHit)) {
173 const MCParticle* currParticle = relPXDSimHitToMCParticle.getFirstElementTo(simHit)->from;
174 m_hitPDG[detID] = currParticle->getPDG();
175 if (!currParticle->isPrimaryParticle()) {
176 const MCParticle* momParticle = currParticle->getMother();
177 m_momPDG[detID] = momParticle->getPDG();
178 }
179 }
180 }
181
182
183 detID = 2;
184
185 for (Int_t iHit = 0; iHit < m_nSimHits[detID]; iHit++) {
186 const SVDSimHit* simHit = SVDSimHits[iHit];
187
188 if (relSVDSimHitToMCParticle.getFirstElementTo(simHit)) {
189 const MCParticle* currParticle = relSVDSimHitToMCParticle.getFirstElementTo(simHit)->from;
190 m_hitPDG[detID] = currParticle->getPDG();
191 if (!currParticle->isPrimaryParticle()) {
192 const MCParticle* momParticle = currParticle->getMother();
193 m_momPDG[detID] = momParticle->getPDG();
194 }
195 }
196 }
197
198
199 detID = 3;
200
201 for (Int_t iHit = 0; iHit < m_nSimHits[detID]; iHit++) {
202 const CDCSimHit* simHit = CDCSimHits[iHit];
203
204 if (relCDCSimHitToMCParticle.getFirstElementTo(simHit)) {
205 const MCParticle* currParticle = relCDCSimHitToMCParticle.getFirstElementTo(simHit)->from;
206 m_hitPDG[detID] = currParticle->getPDG();
207 if (!currParticle->isPrimaryParticle()) {
208 const MCParticle* momParticle = currParticle->getMother();
209 m_momPDG[detID] = momParticle->getPDG();
210 }
211 }
212 }
213
214
215 detID = 4;
216
217 for (Int_t iHit = 0; iHit < m_nSimHits[detID]; iHit++) {
218 const ARICHSimHit* simHit = ARICHSimHits[iHit];
219
220 if (relARICHSimHitToMCParticle.getFirstElementTo(simHit)) {
221 const MCParticle* currParticle = relARICHSimHitToMCParticle.getFirstElementTo(simHit)->from;
222 m_hitPDG[detID] = currParticle->getPDG();
223 if (!currParticle->isPrimaryParticle()) {
224 const MCParticle* momParticle = currParticle->getMother();
225 m_momPDG[detID] = momParticle->getPDG();
226 }
227 }
228 }
229
230
231 detID = 5;
232
233 for (Int_t iHit = 0; iHit < m_nSimHits[detID]; iHit++) {
234 const TOPSimHit* simHit = TOPSimHits[iHit];
235
236 if (relTOPSimHitToMCParticle.getFirstElementTo(simHit)) {
237 const MCParticle* currParticle = relTOPSimHitToMCParticle.getFirstElementTo(simHit)->from;
238 m_hitPDG[detID] = currParticle->getPDG();
239 if (!currParticle->isPrimaryParticle()) {
240 const MCParticle* momParticle = currParticle->getMother();
241 m_momPDG[detID] = momParticle->getPDG();
242 }
243 }
244 }
245
246
247 detID = 6;
248
249 for (Int_t iHit = 0; iHit < m_nSimHits[detID]; iHit++) {
250 const ECLSimHit* simHit = ECLSimHits[iHit];
251
252 if (relECLSimHitToMCParticle.getFirstElementTo(simHit)) {
253 const MCParticle* currParticle = relECLSimHitToMCParticle.getFirstElementTo(simHit)->from;
254 m_hitPDG[detID] = currParticle->getPDG();
255 if (!currParticle->isPrimaryParticle()) {
256 const MCParticle* momParticle = currParticle->getMother();
257 m_momPDG[detID] = momParticle->getPDG();
258 }
259 }
260 }
261
262 detID = 7;
263
264 for (Int_t iHit = 0; iHit < m_nSimHits[detID]; iHit++) {
265 const KLMSimHit* simHit = KLMSimHits[iHit];
266
267 if (relKLMSimHitToMCParticle.getFirstElementTo(simHit)) {
268 const MCParticle* currParticle = relKLMSimHitToMCParticle.getFirstElementTo(simHit)->from;
269 m_hitPDG[detID] = currParticle->getPDG();
270 if (!currParticle->isPrimaryParticle()) {
271 const MCParticle* momParticle = currParticle->getMother();
272 m_momPDG[detID] = momParticle->getPDG();
273 }
274 }
275 }
276
277
278 m_tree2->Fill();
279
280
281 StoreArray<BeamBackHit> BeamBackHits;
282 RelationIndex<MCParticle, BeamBackHit> relBeamBackHitToMCParticle(McParticles, BeamBackHits);
283
284 Int_t nHits = BeamBackHits.getEntries();
285
286
287 for (Int_t iHit = 0; iHit < nHits; iHit++) {
288
289 const BeamBackHit* bkgHit = BeamBackHits[iHit];
290 if (bkgHit->getPDG() == 2112) {
291 m_iEvent = m_iEntry;
292 m_iden = bkgHit->getIdentifier();
293 m_subDet = bkgHit->getSubDet();
294 m_PDG = bkgHit->getPDG();
295 m_trackID = bkgHit->getTrackID();
296 auto position = bkgHit->getPosition();
297 m_positionX = position.X();
298 m_positionY = position.Y();
299 m_positionZ = position.Z();
300 auto momentum = bkgHit->getMomentum();
301 m_momentumX = momentum.X();
302 m_momentumY = momentum.Y();
303 m_momentumZ = momentum.Z();
304 m_E_start = bkgHit->getEnergy();
305 m_E_end = bkgHit->getEnergyAtExit();
306 m_eDep = bkgHit->getEnergyDeposit();
307 m_trackLength = bkgHit->getTrackLength();
308 m_nWeight = bkgHit->getNeutronWeight();
309
310 m_trj_x.clear();
311 m_trj_y.clear();
312 m_trj_z.clear();
313 m_trj_px.clear();
314 m_trj_py.clear();
315 m_trj_pz.clear();
316
317
318 if (relBeamBackHitToMCParticle.getFirstElementTo(bkgHit)) {
319 const MCParticle* currParticle = relBeamBackHitToMCParticle.getFirstElementTo(bkgHit)->from;
320 auto m_vtxProd = currParticle->
getVertex();
321 m_E_init = currParticle->getEnergy();
322 m_mass = currParticle->getMass();
323 m_lifeTime = currParticle->getLifetime();
324 m_vtxProdX = m_vtxProd.X();
325 m_vtxProdY = m_vtxProd.Y();
326 m_vtxProdZ = m_vtxProd.Z();
327
328
329 const auto mcTrajectories = currParticle->getRelationsTo<MCParticleTrajectory>();
330 for (auto rel : mcTrajectories.relations()) {
331
332 if (rel.weight <= 0) continue;
333
334 const MCParticleTrajectory& trajectory = dynamic_cast<const MCParticleTrajectory&>(*rel.object);
335
336 for (const MCTrajectoryPoint& pt : trajectory) {
337 m_trj_x.push_back(pt.x);
338 m_trj_y.push_back(pt.y);
339 m_trj_z.push_back(pt.z);
340 m_trj_px.push_back(pt.px);
341 m_trj_py.push_back(pt.py);
342 m_trj_pz.push_back(pt.pz);
343 }
344 }
345 }
346
347
348 m_tree1->Fill();
349 }
350 }
351
352 m_iEntry++;
353 }
ROOT::Math::XYZVector getVertex() const
Returns vertex position (POCA for charged, IP for neutral FS particles)