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