144{
145 SG::ReadHandle<xAOD::EventInfo> eventInfo (
m_eventInfoKey,Gaudi::Hive::currentContext());
147
148 const int evtnum(eventInfo->eventNumber());
149
151 if (evtStore()->retrieve(mcCollection,
m_key).isSuccess()) {
153
154 if (currentGenEventIter!=mcCollection->
end() ) {
155 {
157 if (!vtx && (*currentGenEventIter)->vertices().size()>0) vtx=((*currentGenEventIter)->vertices()).front();
158 if ( vtx )
159 {
160 m_x_vert->Fill( vtx->position().x() );
161 m_y_vert->Fill( vtx->position().y() );
162 m_z_vert->Fill( vtx->position().z() );
163 }
164 }
165
166 int nvtx=0;
167 int nvtx_sec=0;
169 for (const auto& vtx: (*currentGenEventIter)->vertices()) {
170 double x = vtx->position().x();
171 double y = vtx->position().y();
172 double z = vtx->position().z();
173 double r = std::sqrt(
x*
x+
y*
y);
182 ++nvtx;
183 }
184 else {
185
186 ++nvtx_sec;
187 }
188 }
189 if (nvtx>0) {
193 }
194
198
199 }
200
201 for (;currentGenEventIter!=mcCollection->
end(); ++currentGenEventIter) {
204 sprintf(fname,
"%s.event%d.txt",
m_key.c_str(),evtnum);
205 std::ofstream of(fname);
206 HepMC::Print::line(of,*(*currentGenEventIter));
207 of.close();
208 }
209
210 int npart_prim=0, npart_sec=0;
211 for (const auto& currentGenParticle: *(*currentGenEventIter)) {
219
223
224 if(std::abs(currentGenParticle->pdg_id())==211) {
226 }
228
230
231 int pdg = currentGenParticle->pdg_id();
232 int particleType = 100;
233 switch ( abs(pdg) ) {
234 case 22:
235 particleType = 0;
236 break;
237 case 11:
238 particleType = 1;
239 break;
240 case 13:
241 case 15:
242 particleType = 2;
243 break;
244 case 111:
245 case 211:
246 particleType = 3;
247 break;
248 case 130:
249 case 310:
250 case 311:
251 case 321:
252 particleType = 4;
253 break;
254 case 2112:
255 particleType = 5;
256 break;
257 case 2212:
258 particleType = 6;
259 break;
260 default:
261 particleType = 7;
262 break;
263 }
264 particleType = (pdg<0) ? -particleType : particleType;
266
267 if ( !is_simulation ) {
273 ++npart_prim;
274 }
275 else {
276 ++npart_sec;
277 }
279 }
282 m_n_part->Fill(npart_prim+npart_sec);
283 }
284 }
285
286 return StatusCode::SUCCESS;
287}
bool is_simulation_vertex(const T &v)
Method to establish if the vertex was created during simulation (TODO migrate to be based on status).
HepMC3::FourVector FourVector
ConstGenVertexPtr signal_process_vertex(const GenEvent *e)
int generations(const T &p)
Method to return how many interactions a particle has undergone during simulation (TODO migrate to be...