@@ -257,25 +257,20 @@ struct AODToHepMC {
257257 * framework::OptionManager<AODToHepMC> that propagates the options
258258 * to the program.
259259 */
260- struct : framework::ConfigurableGroup {
260+ struct {
261261 /* * Option for dumping HepMC event structures to disk. Takes one
262262 * argument - the name of the file to write to. */
263- framework::Configurable<std::string> dump{" hepmc-dump" , " " ,
264- " Dump HepMC event to output" };
263+ std::string dump{" " };
265264 /* * Option for only storing particles from the event generator.
266265 * Note, if a particle is stored down, then its mothers will also
267266 * be stored. */
268- framework::Configurable<bool > onlyGen{" hepmc-only-generated" , false ,
269- " Only export generated" };
267+ bool onlyGen{false };
270268 /* * Use HepMC's tree parsing for building event structure */
271- framework::Configurable<bool > useTree{" hepmc-use-tree" , false ,
272- " Export as tree" };
269+ bool useTree{false };
273270 /* * Floating point precision used when writing to disk */
274- framework::Configurable<int > precision{" hepmc-precision" , 8 ,
275- " Export precision in dump" };
271+ int precision{8 };
276272 /* * Recenter event at IP=(0,0,0,0). */
277- framework::Configurable<bool > recenter{" hepmc-recenter" , false ,
278- " Recenter the events at (0,0,0,0)" };
273+ bool recenter{false };
279274 } configs;
280275 /* *
281276 * @{
@@ -585,99 +580,26 @@ struct AODToHepMC {
585580
586581namespace framework
587582{
588- /* *
589- * This specialisation of o2::framework::OutputManager ensures that
590- * we can call the post-processing routine of o2::eventgen::AODToHepMC
591- * and thus ensure that the possible HepMC is written to disk.
592- *
593- * The O2 framework (via o2::framework::adoptAnalysisTask<T>) inspects
594- * the members of the passed class (@c T) and creates
595- * o2::framework::OutputManager callbacks for every member. The
596- * default template for this does nothing.
597- *
598- * Thus, to delegate a call to a member of the analysis task (of class
599- * @c T), we can specialise the @c o2::framework::OutputManager
600- * template on the @e member type. We will then effectively have
601- * call-backs for
602- *
603- * - @c appendOutput - when the task is constructed
604- * - @c prepare - when a new set of data is recieved
605- * - @c finalize - when a set of data has been processed
606- * - @c postRun - when the run is over
607- *
608- * Concretely, we use the @c postRun to flush the HepMC data file
609- * to disk.
610- *
611- * For this to work, the AODToHepMC object must be a member of the
612- * "Task" class, e.g.,
613- *
614- * @code
615- * struct Task {
616- * o2::eventgen::AODToHepMC mConverter;
617- * ...
618- * };
619- *
620- * WorkflowSpec defineDataProcessing(ConfigContext const& cfg) {
621- * return WorkflowSpec{adaptAnalysisTask<Task>(cfg)};
622- * }
623- * @endcode
624- */
625- template <>
626- struct OutputManager <eventgen::AODToHepMC> {
627- /* * Type of the target */
628- using Target = eventgen::AODToHepMC;
629- /* * Called when task is constructed */
630- static bool appendOutput (std::vector<OutputSpec>&, Target&, uint32_t ) { return true ; }
631- /* * Called when new data is received */
632- static bool prepare (ProcessingContext&, Target&) { return true ; }
633- /* * Called when all data has been received */
634- static bool postRun (EndOfStreamContext&, Target& t) { return t.postRun (); }
635- /* * Called when the job finishes */
636- static bool finalize (ProcessingContext&, Target& t) { return true ; }
637- };
638-
639- /* *
640- * Spacialisation to pull in configurables from the converter.
641- *
642- * Ideally, the converter should simply derive from ConfigurableGroup
643- * and all should flow automatically, but that doesn't work for some
644- * reason.
645- *
646- * For this to work, the AODToHepMC object must be a member of the
647- * "Task" class, e.g.,
648- *
649- * @code
650- * struct Task {
651- * o2::eventgen::AODToHepMC mConverter;
652- * ...
653- * };
654- *
655- * WorkflowSpec defineDataProcessing(ConfigContext const& cfg) {
656- * return WorkflowSpec{adaptAnalysisTask<Task>(cfg)};
657- * }
658- * @endcode
659- */
660- template <>
661- struct OptionManager <eventgen::AODToHepMC> {
662- /* * type of the target */
663- using Target = eventgen::AODToHepMC;
664- /* * Called when the task is constructed */
665- static bool
666- appendOption (std::vector<o2::framework::ConfigParamSpec>& options,
667- Target& target)
583+ struct AODToHepMCPostRun {
584+ static AODToHepMCPostRun& instance ()
668585 {
669- OptionManager<ConfigurableGroup>:: appendOption (options, target. configs ) ;
670- return true ;
586+ static AODToHepMCPostRun inst{} ;
587+ return inst ;
671588 }
672- /* * Called when options are processed */
673- static bool
674- prepare (o2::framework::InitContext& ic, Target& target)
589+
590+ AODToHepMCPostRun (eventgen::AODToHepMC* ptr_ = nullptr )
591+ : ptr{ptr_}
675592 {
676- OptionManager<ConfigurableGroup>::prepare (ic, target.configs );
677- return true ;
678593 }
679- };
680594
595+ void endOfStream () {
596+ if (ptr != nullptr ) {
597+ ptr->postRun ();
598+ }
599+ }
600+
601+ eventgen::AODToHepMC* ptr = nullptr ;
602+ };
681603} // namespace framework
682604} // namespace o2
683605
0 commit comments