144{
145 SG::ReadHandle<xAOD::EventInfo> eventInfo (
m_eventInfoKey,Gaudi::Hive::currentContext());
147
148 const int evtnum(eventInfo->eventNumber());
149
153
154 if (currentGenEventIter!=mcCollection->
end() ) {
155 {
157#ifdef HEPMC3
158 if (!vtx && (*currentGenEventIter)->vertices().size()>0) vtx=((*currentGenEventIter)->vertices()).front();
159#else
160 if (!vtx && (*currentGenEventIter)->vertices_size()>0) vtx=*((*currentGenEventIter)->vertices_begin());
161#endif
162 if ( vtx )
163 {
164 m_x_vert->Fill( vtx->position().x() );
165 m_y_vert->Fill( vtx->position().y() );
166 m_z_vert->Fill( vtx->position().z() );
167 }
168 }
169
170 int nvtx=0;
171 int nvtx_sec=0;
173#ifdef HEPMC3
174 for (const auto& vtx: (*currentGenEventIter)->vertices()) {
175#else
176 for (HepMC::GenEvent::vertex_const_iterator vtxit=(*currentGenEventIter)->vertices_begin();
177 vtxit!=(*currentGenEventIter)->vertices_end();++vtxit) {
178 auto vtx=*vtxit;
179#endif
180
181 double x = vtx->position().x();
182 double y = vtx->position().y();
183 double z = vtx->position().z();
184 double r = std::sqrt(
x*
x+
y*
y);
193 ++nvtx;
194 }
195 else {
196
197 ++nvtx_sec;
198 }
199 }
200 if (nvtx>0) {
204 }
205
209
210 }
211
212 for (;currentGenEventIter!=mcCollection->
end(); ++currentGenEventIter) {
215 sprintf(fname,
"%s.event%d.txt",
m_key.c_str(),evtnum);
216 std::ofstream of(fname);
218 of.close();
219 }
220
221 int npart_prim=0, npart_sec=0;
222 for (const auto& currentGenParticle: *(*currentGenEventIter)) {
224 const HepMC::FourVector
mom = currentGenParticle->momentum();
230
234
235 if(std::abs(currentGenParticle->pdg_id())==211) {
237 }
239
241
242 int pdg = currentGenParticle->pdg_id();
243 int particleType = 100;
244 switch ( abs(pdg) ) {
245 case 22:
246 particleType = 0;
247 break;
248 case 11:
249 particleType = 1;
250 break;
251 case 13:
252 case 15:
253 particleType = 2;
254 break;
255 case 111:
256 case 211:
257 particleType = 3;
258 break;
259 case 130:
260 case 310:
261 case 311:
262 case 321:
263 particleType = 4;
264 break;
265 case 2112:
266 particleType = 5;
267 break;
268 case 2212:
269 particleType = 6;
270 break;
271 default:
272 particleType = 7;
273 break;
274 }
275 particleType = (pdg<0) ? -particleType : particleType;
277
278 if ( !is_simulation ) {
284 ++npart_prim;
285 }
286 else {
287 ++npart_sec;
288 }
290 }
293 m_n_part->Fill(npart_prim+npart_sec);
294 }
295 }
296
297 return StatusCode::SUCCESS;
298}
void line(std::ostream &os, const GenEvent &e)
bool is_simulation_vertex(const T &v)
Method to establish if the vertex was created during simulation (TODO migrate to be based on status).
int generations(const T &p)
Method to return how many interactions a particle has undergone during simulation (TODO migrate to be...
GenVertex * signal_process_vertex(const GenEvent *e)