CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
ConfigurableAnalysis Class Reference

#include <CommonTools/UtilAlgos/src/ConfigurableAnalysis.cc>

Inheritance diagram for ConfigurableAnalysis:
edm::EDFilter edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 ConfigurableAnalysis (const edm::ParameterSet &)
 
 ~ConfigurableAnalysis ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
virtual bool filter (edm::Event &, const edm::EventSetup &)
 

Private Attributes

std::vector< std::string > flows_
 
NTuplerntupler_
 
Plotterplotter_
 
Selectionsselections_
 
bool workAsASelector_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
typedef WorkerT< EDFilterWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDFilter
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 45 of file ConfigurableAnalysis.cc.

Constructor & Destructor Documentation

ConfigurableAnalysis::ConfigurableAnalysis ( const edm::ParameterSet iConfig)
explicit

Definition at line 74 of file ConfigurableAnalysis.cc.

References edm::ParameterSet::empty(), edm::ParameterSet::exists(), flows_, reco::get(), edm::ParameterSet::getParameter(), init, ntupler_, RecoTauValidation_cfi::plotPset, plotter_, NTupler::registerleaves(), selections_, and workAsASelector_.

74  :
75  selections_(0), plotter_(0), ntupler_(0)
76 {
77 
78  std::string moduleLabel = iConfig.getParameter<std::string>("@module_label");
79 
80  //configure inputag distributor
81  if (iConfig.exists("InputTags"))
82  edm::Service<InputTagDistributorService>()->init(moduleLabel,iConfig.getParameter<edm::ParameterSet>("InputTags"));
83 
84  //configure the variable helper
85  edm::Service<VariableHelperService>()->init(moduleLabel,iConfig.getParameter<edm::ParameterSet>("Variables"));
86 
87  //list of selections
88  selections_ = new Selections(iConfig.getParameter<edm::ParameterSet>("Selections"));
89 
90  //plotting device
92  if (!plotPset.empty()){
93  std::string plotterName = plotPset.getParameter<std::string>("ComponentName");
94  plotter_ = PlotterFactory::get()->create(plotterName, plotPset);
95  }
96  else
97  plotter_ = 0;
98 
99  //ntupling device
100  edm::ParameterSet ntPset = iConfig.getParameter<edm::ParameterSet>("Ntupler");
101  if (!ntPset.empty()){
102  std::string ntuplerName=ntPset.getParameter<std::string>("ComponentName");
103  ntupler_ = NTuplerFactory::get()->create(ntuplerName, ntPset);
104  }
105  else ntupler_=0;
106 
107  flows_ = iConfig.getParameter<std::vector<std::string> >("flows");
108  workAsASelector_ = iConfig.getParameter<bool>("workAsASelector");
109 
110  //vector of passed selections
111  produces<std::vector<bool> >();
112 
113  //ntupler needs to register its products
114  if (ntupler_) ntupler_->registerleaves(this);
115 }
T getParameter(std::string const &) const
bool empty() const
Definition: ParameterSet.h:219
std::vector< BranchDescription const * > Selections
Definition: Selections.h:10
int init
Definition: HydjetWrapper.h:63
bool exists(std::string const &parameterName) const
checks if a parameter exists
T get(const Candidate &c)
Definition: component.h:56
std::vector< std::string > flows_
ConfigurableAnalysis::~ConfigurableAnalysis ( )

Definition at line 117 of file ConfigurableAnalysis.cc.

References selections_.

118 {
119  delete selections_;
120 }

Member Function Documentation

void ConfigurableAnalysis::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDFilter.

Definition at line 217 of file ConfigurableAnalysis.cc.

218 {
219 }
void ConfigurableAnalysis::endJob ( void  )
privatevirtual

Reimplemented from edm::EDFilter.

Definition at line 223 of file ConfigurableAnalysis.cc.

References Plotter::complete(), plotter_, Selections::print(), and selections_.

223  {
224  //print summary tables
225  selections_->print();
226  if (plotter_) plotter_->complete();
227 }
void print()
Definition: Selections.h:370
virtual void complete()=0
bool ConfigurableAnalysis::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDFilter.

Definition at line 128 of file ConfigurableAnalysis.cc.

References accept(), Selections::begin(), Selections::end(), Plotter::fill(), NTupler::fill(), flows_, iEvent, Filter::name(), ntupler_, plotter_, edm::Event::put(), corrVsCorr::selection, selections_, Plotter::setDir(), createPayload::skip, and workAsASelector_.

129 {
130  using namespace edm;
131 
132  //will the filter pass or not.
133  bool majorGlobalAccept=false;
134 
135  std::auto_ptr<std::vector<bool> > passedProduct(new std::vector<bool>(flows_.size(),false));
136  bool filledOnce=false;
137 
138  // loop the requested selections
140  //was this flow of filter actually asked for
141  bool skip=true;
142  unsigned int iFlow=0;
143  for (;iFlow!=flows_.size();++iFlow){if (flows_[iFlow]==selection->name()){skip=false; break;}}
144  if (skip) continue;
145 
146  //make a specific direction in the plotter
147  if (plotter_) plotter_->setDir(selection->name());
148 
149  // apply individual filters on the event
150  std::map<std::string, bool> accept=selection->accept(iEvent);
151 
152  bool globalAccept=true;
153  std::string separator="";
154  std::string cumulative="";
155  std::string allButOne="allBut_";
156  std::string fullAccept="fullAccept";
157  std::string fullContent="fullContent";
158 
159  if (selection->makeContentPlots() && plotter_)
160  plotter_->fill(fullContent,iEvent);
161 
162  //loop the filters to make cumulative and allButOne job
163  for (Selection::iterator filterIt=selection->begin(); filterIt!=selection->end();++filterIt){
164  Filter & filter=(**filterIt);
165  // bool lastCut=((filterIt+1)==selection->end());
166 
167  //increment the directory name
168  cumulative+=separator+filter.name(); separator="_";
169 
170  if (accept[filter.name()]){
171  // if (globalAccept && selection->makeCumulativePlots() && !lastCut)
172  if (globalAccept && selection->makeCumulativePlots() && plotter_)
173  plotter_->fill(cumulative,iEvent);
174  }
175  else{
176  globalAccept=false;
177  // did all the others filter fire
178  bool goodForAllButThisOne=true;
179  for (std::map<std::string,bool>::iterator decision=accept.begin(); decision!=accept.end();++decision){
180  if (decision->first==filter.name()) continue;
181  if (!decision->second) {
182  goodForAllButThisOne=false;
183  break;}
184  }
185  if (goodForAllButThisOne && selection->makeAllButOnePlots() && plotter_){
186  plotter_->fill(allButOne+filter.name(),iEvent);
187  }
188  }
189 
190  }// loop over the filters in this selection
191 
192  if (globalAccept){
193  (*passedProduct)[iFlow]=true;
194  majorGlobalAccept=true;
195  //make final plots only if no cumulative plots
196  if (selection->makeFinalPlots() && !selection->makeCumulativePlots() && plotter_)
197  plotter_->fill(fullAccept,iEvent);
198 
199  //make the ntuple and put it in the event
200  if (selection->ntuplize() && !filledOnce && ntupler_){
201  ntupler_->fill(iEvent);
202  filledOnce=true;}
203  }
204 
205  }//loop the different filter order/number: loop the Selections
206 
207  iEvent.put(passedProduct);
208  if (workAsASelector_)
209  return majorGlobalAccept;
210  else
211  return true;
212 }
selection
main part
Definition: corrVsCorr.py:98
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:22
int iEvent
Definition: GenABIO.cc:243
iterator end()
Definition: Selections.h:367
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
const std::string & name()
Definition: Selections.h:30
iterator begin()
Definition: Selections.h:366
virtual bool filter(edm::Event &, const edm::EventSetup &)
std::vector< Filter * >::iterator iterator
Definition: Selections.h:112
std::vector< Selection >::iterator iterator
Definition: Selections.h:271
virtual void fill(edm::Event &iEvent)=0
virtual void fill(std::string subDir, const edm::Event &iEvent)=0
virtual void setDir(std::string dir)=0
std::vector< std::string > flows_

Member Data Documentation

std::vector<std::string> ConfigurableAnalysis::flows_
private

Definition at line 59 of file ConfigurableAnalysis.cc.

Referenced by ConfigurableAnalysis(), and filter().

NTupler* ConfigurableAnalysis::ntupler_
private

Definition at line 57 of file ConfigurableAnalysis.cc.

Referenced by ConfigurableAnalysis(), and filter().

Plotter* ConfigurableAnalysis::plotter_
private

Definition at line 56 of file ConfigurableAnalysis.cc.

Referenced by ConfigurableAnalysis(), endJob(), and filter().

Selections* ConfigurableAnalysis::selections_
private
bool ConfigurableAnalysis::workAsASelector_
private

Definition at line 60 of file ConfigurableAnalysis.cc.

Referenced by ConfigurableAnalysis(), and filter().