#include "ICOMETLog.hxx" #include "IReconEventFunction.hxx" IReconEventFunction::IReconEventFunction(const Char_t* name) : IVEventFunction(name) {} IReconEventFunction::~IReconEventFunction() {} //====================================================================== // ProcessCore //====================================================================== int IReconEventFunction::ProcessCore(COMET::ICOMETEvent& event) { try{ // Get IAlgorithmResult containing only necessary IHitSelections COMET::IHandle hits = PrepareHits(event); // If the IHandle has a valid IAlgorithmResult, run if(hits) ProcessAlgorithms(*hits, event); // Skip in the case that no valid IHitSelection was found. else COMETNamedVerbose(GetFullName(), "No HitSelection stored."); } catch(COMET::ERecon& excep){ COMETError("Caught exception associated with reconstruction. " << "Function name: " << GetName() << " / Exception: " << excep.what() ); return 1; } return 0; } //====================================================================== // UsageOfCommonOptions //====================================================================== void IReconEventFunction::UsageOfCommonOptions() { std::cout << "Common Options for Reconstruction:\n" << " Options common among all the reconstruction event functions named XXXX." << std::endl; // Describe options common among reconstruction event functions std::cout << std::endl << " -O XXXX-recon-disable Disable reconstruction function of XXXX.\n" << std::endl << std::endl; } //================================================================================ // SetCommonOption //================================================================================ bool IReconEventFunction::SetCommonOption(TString option, TString value) { if(option == "recon-disable"){ COMETInfo(GetFullName() << " is disabled."); Enable(kFALSE); } else return false; return true; } //====================================================================== // PrepareHits //====================================================================== COMET::IHandle IReconEventFunction::PrepareHits(COMET::ICOMETEvent& event) { COMETWarn("No process to prepare an IAlgorithmResult " "is implemented by user code. " "Empty IAlgorithmResult will be made. :" << event.GetName()); COMET::IHandle result(new COMET::IAlgorithmResult()); return result; } //====================================================================== // ProcessAlgorithms //====================================================================== COMET::IHandle IReconEventFunction::ProcessAlgorithms(const COMET::IAlgorithmResult&, COMET::ICOMETEvent& event) { COMETWarn("No algorithm is implemented by user code. " "Empty IAlgorithmResult will be output. :" << event.GetName() ); COMET::IHandle result(new COMET::IAlgorithmResult()); return result; } //====================================================================== // MakeBasicAlgorithmResult //====================================================================== COMET::IHandle IReconEventFunction::MakeBasicAlgorithmResult(COMET::IHandle hits0, COMET::IHandle hits1, COMET::IHandle hits2, COMET::IHandle hits3, COMET::IHandle hits4, COMET::IHandle hits5, COMET::IHandle hits6, COMET::IHandle hits7, COMET::IHandle hits8, COMET::IHandle hits9 ) { // Make new IAlgorithmResult COMET::IHandle result(new COMET::IAlgorithmResult(Form("%s_Basic", GetFullName()), Form("Contains hit selections for %s", GetFullName()))); // Add the given IHitSelections // by using some tricky way to convert IHandle to IHitSelection* // It's better to improve this in the future if there is any other nice way.... if(hits0) result->AddHitSelection(&*hits0); if(hits1) result->AddHitSelection(&*hits1); if(hits2) result->AddHitSelection(&*hits2); if(hits3) result->AddHitSelection(&*hits3); if(hits4) result->AddHitSelection(&*hits4); if(hits5) result->AddHitSelection(&*hits5); if(hits6) result->AddHitSelection(&*hits6); if(hits7) result->AddHitSelection(&*hits7); if(hits8) result->AddHitSelection(&*hits8); if(hits9) result->AddHitSelection(&*hits9); return result; } //====================================================================== // MakeBasicAlgorithmResult //====================================================================== COMET::IHandle IReconEventFunction::MakeBasicAlgorithmResult(std::vector > &hits) { // Make new IAlgorithmResult COMET::IHandle result(new COMET::IAlgorithmResult(Form("%s_Basic", GetFullName()), Form("Contains hit selections for %s", GetFullName()))); // Add the given IHitSelections // by using some tricky way to convert IHandle to IHitSelection* // It's better to improve this in the future if there is any other nice way.... for(std::vector >::iterator it = hits.begin(); it != hits.end(); it++){ if(*it) result->AddHitSelection(&*(*it)); } return result; }