#ifndef OACALIBRECONBASE_IRECONEVENTFUNCTION_HXX #define OACALIBRECONBASE_IRECONEVENTFUNCTION_HXX #include "IAlgorithmResult.hxx" #include "IVEventFunction.hxx" #include "EoaCalibRecon.hxx" /// A base class to manage IAlgorithms for A Reconstruction Function. /// /// It is assumeed that a derived concrete class is made for a reconstruction function: /// single sub-detector (CDC, ECAL, etc) or combined detector (CyDet, StrECAL, etc). /// Other conceptually well-organized components also should be managed by this. /// The purpose of this class is to make the reconstruction code structure simple and easy /// and this is called by the ReconGlobal's event loop function for each event. class IReconEventFunction : public IVEventFunction { public: IReconEventFunction (const Char_t* name = ""); virtual ~IReconEventFunction (); /// Return trace name for all reconstruction packages for debugging. const Char_t* GetFullName() { return Form("Recon%s", GetName()); } /// Print the usage of CommonOptions for the reconstruction packages. static void UsageOfCommonOptions(); protected: /// Prepare IHitSelections at first from ICOMETEvent. /// /// In this, the prepared IHitSelections have to be stored into a IAlgorithmResults. /// This is because IAlgorithm::operator () receives only IAlgorithmResult. /// The minimal implemantation is as follows: /// (1) Get IHandle of IHitSelections already stored into ICOMETEvent. /// (2) Make IAlgorithmResult by using the MakeBasicAlgorithmResult() method. /// (3) return the IAlgorithmResult /// Note that, DO NOT save the generated IAlgorithmResult to ICOMETEvents /// because, essentially, its IHitSelections are already contained by ICOMETEvent's /hits/. /// /// @ return COMET::IHandle containing /// IHitSelections required by the algorithms. /// if the returned IHandle has NULL pointer, ProcessAlgorithm() won't run. virtual COMET::IHandle PrepareHits(COMET::ICOMETEvent&); /// Process a sequence of IAlgorithms. /// /// The input IAlgorithmResult is strongly expected to be given from /// PrepareHits(). Any optional configuration should be done in BeginOfEvent(), /// SetOption(), or the constructor. /// Save of each IAlgorithmResult on the way is also done here. virtual COMET::IHandle ProcessAlgorithms(const COMET::IAlgorithmResult&, COMET::ICOMETEvent&); /// Process an event with sequential reconstruction algorithms for a /// detector function. This is called by the ReconGlobal's event loop /// for each event inside the event loop. /// /// Nobody can over-ride, Developer is expected to implement the separated classes, /// BeginOfEvent(), PrepareHits(), ProcessAlgorithms(), and EndOfEvent. /// @return the error code that indicates some error happened when != 0. int ProcessCore(COMET::ICOMETEvent& event); /// Make an IAlgorithmResult whom the given HitSelections are stored into. /// This must be called only in PrepareHits. COMET::IHandle MakeBasicAlgorithmResult(COMET::IHandle hits0 = COMET::IHandle(), COMET::IHandle hits1 = COMET::IHandle(), COMET::IHandle hits2 = COMET::IHandle(), COMET::IHandle hits3 = COMET::IHandle(), COMET::IHandle hits4 = COMET::IHandle(), COMET::IHandle hits5 = COMET::IHandle(), COMET::IHandle hits6 = COMET::IHandle(), COMET::IHandle hits7 = COMET::IHandle(), COMET::IHandle hits8 = COMET::IHandle(), COMET::IHandle hits9 = COMET::IHandle() ); /// Make an IAlgorithmResult whom the given HitSelections in the vector are stored into. /// This must be called only in PrepareHits. COMET::IHandle MakeBasicAlgorithmResult(std::vector > &hits); private: /// Only function specific option whose argument string is common among all /// the derived recon event functions. bool SetCommonOption(TString option, TString value = ""); }; #endif