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 
9 
11  public:
14  for (iterator it = variables_.begin() ; it!=variables_.end() ;++it){
15  delete it->second;
16  }
17  }
18  typedef std::map<std::string,const CachingVariable*>::const_iterator iterator;
19 
21 
22  iterator begin() { return variables_.begin();}
23  iterator end() { return variables_.end();}
24 
25  void setHolder(std::string hn);
26  void print() const;
27  std::string printValues(const edm::Event & event) const;
28  private:
29  std::map<std::string,const CachingVariable*> variables_;
30 };
31 
32 
33 
34 
36  private:
38  std::map<std::string, VariableHelper* > multipleInstance_;
39 
42  public:
46  printValuesForEachEvent_ = iConfig.exists("printValuesForEachEventCategory");
48  printValuesForEachEventCategory_ = iConfig.getParameter<std::string>("printValuesForEachEventCategory");
49  }
51  for (std::map<std::string, VariableHelper* > :: iterator it=multipleInstance_.begin(); it!=multipleInstance_.end(); ++it){
52  delete it->second;
53  }
54  }
55 
57  if (multipleInstance_.find(user)!=multipleInstance_.end()){
58  std::cerr<<user<<" VariableHelper user already defined."<<std::endl;
59  throw;}
60  else SetVariableHelperUniqueInstance_ = new VariableHelper(iConfig, iC);
63 
66  }
67 
68  VariableHelper & get(){
70  {
71  std::cerr<<" none of VariableHelperUniqueInstance_ or SetVariableHelperUniqueInstance_ is valid."<<std::endl;
72  throw;
73  }
74  else return (*SetVariableHelperUniqueInstance_);
75  }
76 
77  void preModule(const edm::ModuleDescription& desc){
78  //does a set with the module name, except that it does not throw on non-configured modules
79  std::map<std::string, VariableHelper* >::iterator f=multipleInstance_.find(desc.moduleLabel());
80  if (f != multipleInstance_.end()) SetVariableHelperUniqueInstance_ = (f->second);
81  else {
82  //do not say anything but set it to zero to get a safe crash in get() if ever called
84  }
85 
87  if (!printValuesForEachEvent_) return;
88  std::map<std::string, VariableHelper* >::iterator f= multipleInstance_.begin();
89  for (; f!=multipleInstance_.end();++f){
90  // std::cout<<" category is: "<<printValuesForEachEventCategory_+"|"+f->first<<std::endl;
91  // std::cout<<f->first<<"\n" <<f->second->printValues(event);
92 
93  edm::LogInfo(printValuesForEachEventCategory_+"|"+f->first)<<f->first<<"\n"
94  <<f->second->printValues(event);
95  }
96  }
97 
99  std::map<std::string, VariableHelper* >::iterator f=multipleInstance_.find(user);
100  if (f == multipleInstance_.end()){
101  std::cerr<<user<<" VariableHelper user not defined."<<std::endl;
102  throw;
103  }
104  else{
105  SetVariableHelperUniqueInstance_ = (f->second);
107  }
108  }
109 };
110 
111 #endif
T getParameter(std::string const &) const
VariableHelper(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
VariableHelper & set(std::string user)
const CachingVariable * variable(std::string name) const
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_
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
VariableHelper & init(std::string user, const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
std::map< std::string, const CachingVariable * >::const_iterator iterator