#include "ICOMETLog.hxx" #include "IVEventFunction.hxx" //====================================================================== // Constructor //====================================================================== IVEventFunction::IVEventFunction(const Char_t* name) : fFunctionName(name), fEnabled(kTRUE) {} //====================================================================== // SetLogLevel //====================================================================== void IVEventFunction::SetLogLevel(const COMET::ICOMETLog::LogPriority level) { // Require not null function name if(fFunctionName == ""){ COMETWarn("SetLogLevel don't set log level because no function name is set."); return; } COMET::ICOMETLog::SetLogLevel(GetName(), level); } //====================================================================== // Process //====================================================================== int IVEventFunction::Process(COMET::ICOMETEvent& event) { // Skip when disabled if(!fEnabled){ COMETNamedVerbose("oaVCalibReconBase", "This EventFunction (The function name: " << fFunctionName << ") is disabled. Skip this event."); return 0; } // Process Basic chain int ret; try{ BeginOfEvent(); // Specific process for the derived event function ret = ProcessCore(event); EndOfEvent(); } catch(COMET::EoaCalibRecon& excep){ COMETError("IVEventFunction caught an exception. " << "Function name: " << fFunctionName << " / Exception: " << excep.what() ); return 1; } return ret; } //====================================================================== // UsageOfCoreOptions //====================================================================== void IVEventFunction::UsageOfCoreOptions() { std::cout << "Core Options:\n" << " Options common among all the event functions named XXXX." << std::endl; // Describe core common options std::cout << std::endl << " -O XXXX-disable Disable function of XXXX.\n" << std::endl; } //====================================================================== // SetOption //====================================================================== bool IVEventFunction::SetOption(TString option, TString value) { COMETWarn("Empty set option called with " << option << "=" << value); return false; } //================================================================================ // ParseSpecificOption //================================================================================ bool IVEventFunction::ParseSpecificOption(TString option, TString value) { // Get the function name of this // regardless of capital/small letter TString funcModName = GetLowerName(); funcModName += "-"; // Get the function name of option TString opModName = option(0, funcModName.Length()); opModName.ToLower(); // Check if(opModName != funcModName) return false; // Remove the function name from option string option = option(funcModName.Length(), option.Length()); // Check common option such as "xxxxx-disable" if(SetCoreOption(option, value)) return true; // Check function specific option if(SetOption(option, value)) return true; return false; } //================================================================================ // SetCoreOption //================================================================================ bool IVEventFunction::SetCoreOption(TString option, TString value) { // Disable this function if(option == "disable"){ COMETInfo(GetFullName() << " is disabled."); Enable(kFALSE); } // Pass to the derived common option methods else return SetCommonOption(option, value); return true; }