@@ -146,10 +146,14 @@ namespace edm {
146146 }
147147 }
148148
149+ ivhepmc = hadronizer_.getVHepMC ();
149150 if (ps.exists (" HepMCFilter" )) {
150151 ParameterSet psfilter = ps.getParameter <ParameterSet>(" HepMCFilter" );
151- filter_ = new HepMCFilterDriver (psfilter);
152- filter3_ = new HepMC3FilterDriver (psfilter);
152+ if (ivhepmc == 2 ) {
153+ filter_ = new HepMCFilterDriver (psfilter);
154+ } else if (ivhepmc == 3 ) {
155+ filter3_ = new HepMC3FilterDriver (psfilter);
156+ }
153157 }
154158
155159 // initialize setting for multiple hadronization attempts
@@ -163,7 +167,6 @@ namespace edm {
163167 usesResource (edm::uniqueSharedResourceName ());
164168 }
165169
166- ivhepmc = hadronizer_.getVHepMC ();
167170 if (ivhepmc == 2 ) {
168171 produces<edm::HepMCProduct>(" unsmeared" );
169172 produces<GenEventInfoProduct>();
@@ -174,7 +177,7 @@ namespace edm {
174177 produces<GenLumiInfoHeader, edm::Transition::BeginLuminosityBlock>();
175178 produces<GenLumiInfoProduct, edm::Transition::EndLuminosityBlock>();
176179 produces<GenRunInfoProduct, edm::Transition::EndRun>();
177- if (filter_)
180+ if (filter_ || filter3_ )
178181 produces<GenFilterInfo, edm::Transition::EndLuminosityBlock>();
179182 }
180183
@@ -227,9 +230,9 @@ namespace edm {
227230 std::unique_ptr<HepMC::GenEvent> event (hadronizer_.getGenEvent ());
228231 std::unique_ptr<HepMC3::GenEvent> event3 (hadronizer_.getGenEvent3 ());
229232 if (ivhepmc == 2 && !event.get ())
230- return false ;
233+ continue ;
231234 if (ivhepmc == 3 && !event3.get ())
232- return false ;
235+ continue ;
233236
234237 // The external decay driver is being added to the system,
235238 // it should be called here
@@ -244,9 +247,9 @@ namespace edm {
244247 }
245248
246249 if (ivhepmc == 2 && !event.get ())
247- return false ;
250+ continue ;
248251 if (ivhepmc == 3 && !event3.get ())
249- return false ;
252+ continue ;
250253
251254 // check and perform if there're any unstable particles after
252255 // running external decay packges
@@ -261,9 +264,9 @@ namespace edm {
261264 event = hadronizer_.getGenEvent ();
262265 event3 = hadronizer_.getGenEvent3 ();
263266 if (ivhepmc == 2 && !event.get ())
264- return false ;
267+ continue ;
265268 if (ivhepmc == 3 && !event3.get ())
266- return false ;
269+ continue ;
267270
268271 if (ivhepmc == 2 ) { // HepMC
269272 event->set_event_number (ev.id ().event ());
@@ -282,27 +285,6 @@ namespace edm {
282285 // keep the LAST accepted event (which is equivalent to choosing randomly from the accepted events)
283286 finalEvent = std::move (event);
284287 finalGenEventInfo = std::move (genEventInfo);
285-
286- if (!naccept)
287- return false ;
288-
289- // adjust event weights if necessary (in case input event was attempted multiple times)
290- if (nAttempts_ > 1 ) {
291- double multihadweight = double (naccept) / double (nAttempts_);
292-
293- // adjust weight for GenEventInfoProduct
294- finalGenEventInfo->weights ()[0 ] *= multihadweight;
295-
296- // adjust weight for HepMC GenEvent (used e.g for RIVET)
297- finalEvent->weights ()[0 ] *= multihadweight;
298- }
299-
300- ev.put (std::move (finalGenEventInfo));
301-
302- std::unique_ptr<HepMCProduct> bare_product (new HepMCProduct ());
303- bare_product->addHepMCData (finalEvent.release ());
304- ev.put (std::move (bare_product), " unsmeared" );
305-
306288 } else if (ivhepmc == 3 ) { // HepMC3
307289 event3->set_event_number (ev.id ().event ());
308290 std::unique_ptr<GenEventInfoProduct3> genEventInfo3 (hadronizer_.getGenEventInfo3 ());
@@ -320,27 +302,46 @@ namespace edm {
320302 // keep the LAST accepted event (which is equivalent to choosing randomly from the accepted events)
321303 finalEvent3 = std::move (event3);
322304 finalGenEventInfo3 = std::move (genEventInfo3);
305+ }
306+ }
323307
324- if (!naccept)
325- return false ;
308+ if (!naccept)
309+ return false ;
326310
327- // adjust event weights if necessary (in case input event was attempted multiple times)
328- if (nAttempts_ > 1 ) {
329- double multihadweight = double (naccept) / double (nAttempts_);
311+ if (ivhepmc == 2 ) { // HepMC
312+ // adjust event weights if necessary (in case input event was attempted multiple times)
313+ if (nAttempts_ > 1 ) {
314+ double multihadweight = double (naccept) / double (nAttempts_);
330315
331- // adjust weight for GenEventInfoProduct
332- finalGenEventInfo3 ->weights ()[0 ] *= multihadweight;
316+ // adjust weight for GenEventInfoProduct
317+ finalGenEventInfo ->weights ()[0 ] *= multihadweight;
333318
334- // adjust weight for HepMC GenEvent (used e.g for RIVET)
335- finalEvent3->weights ()[0 ] *= multihadweight;
336- }
319+ // adjust weight for HepMC GenEvent (used e.g for RIVET)
320+ finalEvent->weights ()[0 ] *= multihadweight;
321+ }
322+
323+ ev.put (std::move (finalGenEventInfo));
337324
338- ev.put (std::move (finalGenEventInfo3));
325+ std::unique_ptr<HepMCProduct> bare_product (new HepMCProduct ());
326+ bare_product->addHepMCData (finalEvent.release ());
327+ ev.put (std::move (bare_product), " unsmeared" );
328+ } else if (ivhepmc == 3 ) { // HepMC3
329+ // adjust event weights if necessary (in case input event was attempted multiple times)
330+ if (nAttempts_ > 1 ) {
331+ double multihadweight = double (naccept) / double (nAttempts_);
339332
340- std::unique_ptr<HepMC3Product> bare_product (new HepMC3Product ());
341- bare_product->addHepMCData (finalEvent3.release ());
342- ev.put (std::move (bare_product), " unsmeared" );
333+ // adjust weight for GenEventInfoProduct
334+ finalGenEventInfo3->weights ()[0 ] *= multihadweight;
335+
336+ // adjust weight for HepMC GenEvent (used e.g for RIVET)
337+ finalEvent3->weights ()[0 ] *= multihadweight;
343338 }
339+
340+ ev.put (std::move (finalGenEventInfo3));
341+
342+ std::unique_ptr<HepMC3Product> bare_product (new HepMC3Product ());
343+ bare_product->addHepMCData (finalEvent3.release ());
344+ ev.put (std::move (bare_product), " unsmeared" );
344345 }
345346
346347 return true ;
0 commit comments