CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
VariableHelper.h
Go to the documentation of this file.
1 #ifndef ConfigurableAnalysis_VariableHelper_H
2 #define ConfigurableAnalysis_VariableHelper_H
3 
8 
10  public:
11  VariableHelper(const edm::ParameterSet & iConfig);
13  for (iterator it = variables_.begin() ; it!=variables_.end() ;++it){
14  delete it->second;
15  }
16  }
17  typedef std::map<std::string,const CachingVariable*>::const_iterator iterator;
18 
19  const CachingVariable* variable(std::string name)const ;
20 
21  iterator begin() { return variables_.begin();}
22  iterator end() { return variables_.end();}
23 
24  void setHolder(std::string hn);
25  void print() const;
26  std::string printValues(const edm::Event & event) const;
27  private:
28  std::map<std::string,const CachingVariable*> variables_;
29 };
30 
31 
32 
33 
35  private:
37  std::map<std::string, VariableHelper* > multipleInstance_;
38 
41  public:
45  printValuesForEachEvent_ = iConfig.exists("printValuesForEachEventCategory");
47  printValuesForEachEventCategory_ = iConfig.getParameter<std::string>("printValuesForEachEventCategory");
48  }
50  for (std::map<std::string, VariableHelper* > :: iterator it=multipleInstance_.begin(); it!=multipleInstance_.end(); ++it){
51  delete it->second;
52  }
53  }
54 
55  VariableHelper & init(std::string user, const edm::ParameterSet & iConfig){
56  if (multipleInstance_.find(user)!=multipleInstance_.end()){
57  std::cerr<<user<<" VariableHelper user already defined."<<std::endl;
58  throw;}
62 
65  }
66 
67  VariableHelper & get(){
69  {
70  std::cerr<<" none of VariableHelperUniqueInstance_ or SetVariableHelperUniqueInstance_ is valid."<<std::endl;
71  throw;
72  }
73  else return (*SetVariableHelperUniqueInstance_);
74  }
75 
76  void preModule(const edm::ModuleDescription& desc){
77  //does a set with the module name, except that it does not throw on non-configured modules
78  std::map<std::string, VariableHelper* >::iterator f=multipleInstance_.find(desc.moduleLabel());
79  if (f != multipleInstance_.end()) SetVariableHelperUniqueInstance_ = (f->second);
80  else {
81  //do not say anything but set it to zero to get a safe crash in get() if ever called
83  }
84 
85  void postProcess(const edm::Event & event, const edm::EventSetup & setup){
86  if (!printValuesForEachEvent_) return;
87  std::map<std::string, VariableHelper* >::iterator f= multipleInstance_.begin();
88  for (; f!=multipleInstance_.end();++f){
89  // std::cout<<" category is: "<<printValuesForEachEventCategory_+"|"+f->first<<std::endl;
90  // std::cout<<f->first<<"\n" <<f->second->printValues(event);
91 
92  edm::LogInfo(printValuesForEachEventCategory_+"|"+f->first)<<f->first<<"\n"
93  <<f->second->printValues(event);
94  }
95  }
96 
97  VariableHelper & set(std::string user){
98  std::map<std::string, VariableHelper* >::iterator f=multipleInstance_.find(user);
99  if (f == multipleInstance_.end()){
100  std::cerr<<user<<" VariableHelper user not defined."<<std::endl;
101  throw;
102  }
103  else{
104  SetVariableHelperUniqueInstance_ = (f->second);
106  }
107  }
108 };
109 
110 #endif
T getParameter(std::string const &) const
VariableHelper & set(std::string user)
const CachingVariable * variable(std::string name) const
VariableHelper & init(std::string user, const edm::ParameterSet &iConfig)
std::map< std::string, VariableHelper * > multipleInstance_
bool exists(std::string const &parameterName) const
checks if a parameter exists
VariableHelper * SetVariableHelperUniqueInstance_
iterator end()
std::string printValuesForEachEventCategory_
std::map< std::string, const CachingVariable * > variables_
VariableHelper(const edm::ParameterSet &iConfig)
std::string const & moduleLabel() const
void watchPreModule(PreModule::slot_type const &iSlot)
void preModule(const edm::ModuleDescription &desc)
void postProcess(const edm::Event &event, const edm::EventSetup &setup)
void watchPostProcessEvent(PostProcessEvent::slot_type const &iSlot)
std::string printValues(const edm::Event &event) const
double f[11][100]
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void setHolder(std::string hn)
VariableHelperService(const edm::ParameterSet &iConfig, edm::ActivityRegistry &r)
iterator begin()
void print() const
std::map< std::string, const CachingVariable * >::const_iterator iterator