CMS 3D CMS Logo

VariableHelper.h
Go to the documentation of this file.
1 #ifndef ConfigurableAnalysis_VariableHelper_H
2 #define ConfigurableAnalysis_VariableHelper_H
3 
10 
12 public:
15  for (iterator it = variables_.begin(); it != variables_.end(); ++it) {
16  delete it->second;
17  }
18  }
19  typedef std::map<std::string, const CachingVariable*>::const_iterator iterator;
20 
22 
23  iterator begin() { return variables_.begin(); }
24  iterator end() { return variables_.end(); }
25 
26  void setHolder(std::string hn);
27  void print() const;
29 
30 private:
31  std::map<std::string, const CachingVariable*> variables_;
32 };
33 
35 private:
37  std::map<std::string, VariableHelper*> multipleInstance_;
38 
41 
42 public:
45  //r.watchPreModule(this, &VariableHelperService::preModule );
46  r.watchPreModuleEvent(this, &VariableHelperService::preModule);
47  //r.watchPostProcessEvent(this, &VariableHelperService::postProcess );
48  r.watchPostEvent(this, &VariableHelperService::postProcess);
49  printValuesForEachEvent_ = iConfig.exists("printValuesForEachEventCategory");
51  printValuesForEachEventCategory_ = iConfig.getParameter<std::string>("printValuesForEachEventCategory");
52  }
54  for (std::map<std::string, VariableHelper*>::iterator it = multipleInstance_.begin(); it != multipleInstance_.end();
55  ++it) {
56  delete it->second;
57  }
58  }
59 
61  if (multipleInstance_.find(user) != multipleInstance_.end()) {
62  std::cerr << user << " VariableHelper user already defined." << std::endl;
63  throw;
64  } else
68 
71  }
72 
73  VariableHelper& get() {
75  std::cerr << " none of VariableHelperUniqueInstance_ or SetVariableHelperUniqueInstance_ is valid." << std::endl;
76  throw;
77  } else
79  }
80 
83  //does a set with the module name, except that it does not throw on non-configured modules
84  std::map<std::string, VariableHelper*>::iterator f = multipleInstance_.find(desc.moduleLabel());
85  if (f != multipleInstance_.end()) {
87  return;
88  }
90  }
91 
92  void postProcess(edm::StreamContext const& sc) {
94  return;
95 
96  /*const edm::Event & event;
97  std::map<std::string, VariableHelper* >::iterator f= multipleInstance_.begin();
98  for (; f!=multipleInstance_.end();++f){
99  // std::cout<<" category is: "<<printValuesForEachEventCategory_+"|"+f->first<<std::endl;
100  // std::cout<<f->first<<"\n" <<f->second->printValues(event);
101 
102  edm::LogInfo(printValuesForEachEventCategory_+"|"+f->first)<<f->first<<"\n"
103  <<f->second->printValues(event);
104  }
105  */
106  }
107 
109  std::map<std::string, VariableHelper*>::iterator f = multipleInstance_.find(user);
110  if (f == multipleInstance_.end()) {
111  std::cerr << user << " VariableHelper user not defined." << std::endl;
112  throw;
113  } else {
116  }
117  }
118 };
119 
120 #endif
VariableHelper(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
ModuleDescription const * moduleDescription() const
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void print() const
bool exists(std::string const &parameterName) const
checks if a parameter exists
VariableHelper * SetVariableHelperUniqueInstance_
iterator end()
std::string printValuesForEachEventCategory_
const CachingVariable * variable(std::string name) const
std::string printValues(const edm::Event &event) const
void postProcess(edm::StreamContext const &sc)
double f[11][100]
void preModule(edm::StreamContext const &, edm::ModuleCallingContext const &mcc)
std::map< std::string, const CachingVariable * > variables_
void setHolder(std::string hn)
std::map< std::string, const CachingVariable * >::const_iterator iterator
VariableHelperService(const edm::ParameterSet &iConfig, edm::ActivityRegistry &r)
std::map< std::string, VariableHelper * > multipleInstance_
iterator begin()
VariableHelper & init(std::string user, const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
Definition: event.py:1