#include <PhysicsTools/UtilAlgos/interface/VariableHelper.h>
Public Member Functions | |
VariableHelper & | get () |
VariableHelper & | init (std::string user, const edm::ParameterSet &iConfig) |
void | postProcess (const edm::Event &event, const edm::EventSetup &setup) |
void | preModule (const edm::ModuleDescription &desc) |
VariableHelper & | set (std::string user) |
VariableHelperService (const edm::ParameterSet &iConfig, edm::ActivityRegistry &r) | |
~VariableHelperService () | |
Private Attributes | |
std::map< std::string, VariableHelper * > | multipleInstance_ |
bool | printValuesForEachEvent_ |
std::string | printValuesForEachEventCategory_ |
VariableHelper * | SetVariableHelperUniqueInstance_ |
Definition at line 34 of file VariableHelper.h.
VariableHelperService::VariableHelperService | ( | const edm::ParameterSet & | iConfig, | |
edm::ActivityRegistry & | r | |||
) | [inline] |
Definition at line 42 of file VariableHelper.h.
References edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), postProcess(), preModule(), printValuesForEachEvent_, printValuesForEachEventCategory_, edm::ActivityRegistry::watchPostProcessEvent(), and edm::ActivityRegistry::watchPreModule().
00042 { 00043 r.watchPreModule(this, &VariableHelperService::preModule ); 00044 r.watchPostProcessEvent(this, &VariableHelperService::postProcess ); 00045 printValuesForEachEvent_ = iConfig.exists("printValuesForEachEventCategory"); 00046 if (printValuesForEachEvent_) 00047 printValuesForEachEventCategory_ = iConfig.getParameter<std::string>("printValuesForEachEventCategory"); 00048 }
VariableHelperService::~VariableHelperService | ( | ) | [inline] |
Definition at line 49 of file VariableHelper.h.
References it, and multipleInstance_.
00049 { 00050 for (std::map<std::string, VariableHelper* > :: iterator it=multipleInstance_.begin(); it!=multipleInstance_.end(); ++it){ 00051 delete it->second; 00052 } 00053 }
VariableHelper& VariableHelperService::get | ( | void | ) | [inline] |
Definition at line 67 of file VariableHelper.h.
References TestMuL1L2Filter_cff::cerr, lat::endl(), and SetVariableHelperUniqueInstance_.
00067 { 00068 if (!SetVariableHelperUniqueInstance_) 00069 { 00070 std::cerr<<" none of VariableHelperUniqueInstance_ or SetVariableHelperUniqueInstance_ is valid."<<std::endl; 00071 throw; 00072 } 00073 else return (*SetVariableHelperUniqueInstance_); 00074 }
VariableHelper& VariableHelperService::init | ( | std::string | user, | |
const edm::ParameterSet & | iConfig | |||
) | [inline] |
Definition at line 55 of file VariableHelper.h.
References TestMuL1L2Filter_cff::cerr, lat::endl(), multipleInstance_, VariableHelper::print(), VariableHelper::setHolder(), and SetVariableHelperUniqueInstance_.
00055 { 00056 if (multipleInstance_.find(user)!=multipleInstance_.end()){ 00057 std::cerr<<user<<" VariableHelper user already defined."<<std::endl; 00058 throw;} 00059 else SetVariableHelperUniqueInstance_ = new VariableHelper(iConfig); 00060 multipleInstance_[user] = SetVariableHelperUniqueInstance_; 00061 SetVariableHelperUniqueInstance_->setHolder(user); 00062 00063 SetVariableHelperUniqueInstance_->print(); 00064 return (*SetVariableHelperUniqueInstance_); 00065 }
void VariableHelperService::postProcess | ( | const edm::Event & | event, | |
const edm::EventSetup & | setup | |||
) | [inline] |
Definition at line 85 of file VariableHelper.h.
References f, multipleInstance_, printValuesForEachEvent_, and printValuesForEachEventCategory_.
Referenced by VariableHelperService().
00085 { 00086 if (!printValuesForEachEvent_) return; 00087 std::map<std::string, VariableHelper* >::iterator f= multipleInstance_.begin(); 00088 for (; f!=multipleInstance_.end();++f){ 00089 // std::cout<<" category is: "<<printValuesForEachEventCategory_+"|"+f->first<<std::endl; 00090 // std::cout<<f->first<<"\n" <<f->second->printValues(event); 00091 00092 edm::LogInfo(printValuesForEachEventCategory_+"|"+f->first)<<f->first<<"\n" 00093 <<f->second->printValues(event); 00094 } 00095 }
void VariableHelperService::preModule | ( | const edm::ModuleDescription & | desc | ) | [inline] |
Definition at line 76 of file VariableHelper.h.
References f, edm::ModuleDescription::moduleLabel(), multipleInstance_, and SetVariableHelperUniqueInstance_.
Referenced by VariableHelperService().
00076 { 00077 //does a set with the module name, except that it does not throw on non-configured modules 00078 std::map<std::string, VariableHelper* >::iterator f=multipleInstance_.find(desc.moduleLabel()); 00079 if (f != multipleInstance_.end()) SetVariableHelperUniqueInstance_ = (f->second); 00080 else { 00081 //do not say anything but set it to zero to get a safe crash in get() if ever called 00082 SetVariableHelperUniqueInstance_ =0;} 00083 }
VariableHelper& VariableHelperService::set | ( | std::string | user | ) | [inline] |
Definition at line 97 of file VariableHelper.h.
References TestMuL1L2Filter_cff::cerr, lat::endl(), f, multipleInstance_, SetVariableHelperUniqueInstance_, and cmsBenchmark::user.
00097 { 00098 std::map<std::string, VariableHelper* >::iterator f=multipleInstance_.find(user); 00099 if (f == multipleInstance_.end()){ 00100 std::cerr<<user<<" VariableHelper user not defined."<<std::endl; 00101 throw; 00102 } 00103 else{ 00104 SetVariableHelperUniqueInstance_ = (f->second); 00105 return (*SetVariableHelperUniqueInstance_); 00106 } 00107 }
std::map<std::string, VariableHelper* > VariableHelperService::multipleInstance_ [private] |
Definition at line 37 of file VariableHelper.h.
Referenced by init(), postProcess(), preModule(), set(), and ~VariableHelperService().
Definition at line 39 of file VariableHelper.h.
Referenced by postProcess(), and VariableHelperService().
std::string VariableHelperService::printValuesForEachEventCategory_ [private] |
Definition at line 40 of file VariableHelper.h.
Referenced by postProcess(), and VariableHelperService().
Definition at line 36 of file VariableHelper.h.
Referenced by get(), init(), preModule(), and set().