CMS 3D CMS Logo

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::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ConfigurableAnalysis (const edm::ParameterSet &)
 
 ~ConfigurableAnalysis ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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::EDConsumerBase::consumesCollector(), edm::ParameterSet::empty(), edm::ParameterSet::exists(), flows_, reco::get(), edm::ParameterSet::getParameter(), StGenEvtProducer_cfi::init, ntupler_, RecoTauValidation_cfi::plotPset, plotter_, NTupler::registerleaves(), selections_, AlCaHLTBitMon_QueryRunRegistry::string, 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"))
83 
84  //configure the variable helper
86 
87  //list of 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:218
bool exists(std::string const &parameterName) const
checks if a parameter exists
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
T get(const Candidate &c)
Definition: component.h:55
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  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 218 of file ConfigurableAnalysis.cc.

219 {
220 }
void ConfigurableAnalysis::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 224 of file ConfigurableAnalysis.cc.

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

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

Definition at line 128 of file ConfigurableAnalysis.cc.

References accept(), Selections::begin(), create_public_lumi_plots::cumulative, Selections::end(), Plotter::fill(), NTupler::fill(), flows_, iEvent, SFilter::inverted(), eostools::move(), Filter::name(), ntupler_, plotter_, edm::Event::put(), corrVsCorr::selection, selections_, mps_merge::separator, Plotter::setDir(), createPayload::skip, AlCaHLTBitMon_QueryRunRegistry::string, and workAsASelector_.

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