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 () override=default
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilter () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
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, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

std::vector< std::string > flows_
 
std::unique_ptr< NTuplerntupler_
 
std::unique_ptr< Plotterplotter_
 
std::unique_ptr< FilterSelectionsselections_
 
bool workAsASelector_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
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 &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

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

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

Definition at line 44 of file ConfigurableAnalysis.cc.

Constructor & Destructor Documentation

◆ ConfigurableAnalysis()

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

Definition at line 73 of file ConfigurableAnalysis.cc.

73  {
74  std::string moduleLabel = iConfig.getParameter<std::string>("@module_label");
75 
76  //configure inputag distributor
77  if (iConfig.exists("InputTags"))
80 
81  //configure the variable helper
84 
85  //list of selections
86  selections_ =
87  std::make_unique<FilterSelections>(iConfig.getParameter<edm::ParameterSet>("Selections"), consumesCollector());
88 
89  //plotting device
91  if (!plotPset.empty()) {
92  std::string plotterName = plotPset.getParameter<std::string>("ComponentName");
93  plotter_ = PlotterFactory::get()->create(plotterName, plotPset);
94  }
95 
96  //ntupling device
97  edm::ParameterSet ntPset = iConfig.getParameter<edm::ParameterSet>("Ntupler");
98  if (!ntPset.empty()) {
99  std::string ntuplerName = ntPset.getParameter<std::string>("ComponentName");
100  ntupler_ = NTuplerFactory::get()->create(ntuplerName, ntPset);
101  }
102 
103  flows_ = iConfig.getParameter<std::vector<std::string>>("flows");
104  workAsASelector_ = iConfig.getParameter<bool>("workAsASelector");
105 
106  //vector of passed selections
107  produces<std::vector<bool>>();
108 
109  //ntupler needs to register its products
110  if (ntupler_)
111  ntupler_->registerleaves(producesCollector());
112 }

References edm::EDConsumerBase::consumesCollector(), edm::ParameterSet::empty(), edm::ParameterSet::exists(), flows_, get, edm::ParameterSet::getParameter(), HerwigMaxPtPartonFilter_cfi::moduleLabel, ntupler_, RecoTauValidation_cfi::plotPset, plotter_, edm::ProducerBase::producesCollector(), selections_, AlCaHLTBitMon_QueryRunRegistry::string, and workAsASelector_.

◆ ~ConfigurableAnalysis()

ConfigurableAnalysis::~ConfigurableAnalysis ( )
overridedefault

Member Function Documentation

◆ beginJob()

void ConfigurableAnalysis::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 216 of file ConfigurableAnalysis.cc.

216 {}

◆ endJob()

void ConfigurableAnalysis::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 219 of file ConfigurableAnalysis.cc.

219  {
220  //print summary tables
221  selections_->print();
222  if (plotter_)
223  plotter_->complete();
224 }

References plotter_, and selections_.

◆ filter()

bool ConfigurableAnalysis::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDFilter.

Definition at line 119 of file ConfigurableAnalysis.cc.

119  {
120  //will the filter pass or not.
121  bool majorGlobalAccept = false;
122 
123  auto passedProduct = std::make_unique<std::vector<bool>>(flows_.size(), false);
124  bool filledOnce = false;
125 
126  // loop the requested selections
128  //was this flow of filter actually asked for
129  bool skip = true;
130  unsigned int iFlow = 0;
131  for (; iFlow != flows_.size(); ++iFlow) {
132  if (flows_[iFlow] == selection->name()) {
133  skip = false;
134  break;
135  }
136  }
137  if (skip)
138  continue;
139 
140  //make a specific direction in the plotter
141  if (plotter_)
142  plotter_->setDir(selection->name());
143 
144  // apply individual filters on the event
145  std::map<std::string, bool> accept = selection->acceptMap(iEvent);
146 
147  bool globalAccept = true;
148  std::string separator = "";
149  std::string cumulative = "";
150  std::string allButOne = "allBut_";
151  std::string fullAccept = "fullAccept";
152  std::string fullContent = "fullContent";
153 
154  if (selection->makeContentPlots() && plotter_)
155  plotter_->fill(fullContent, iEvent);
156 
157  //loop the filters to make cumulative and allButOne job
158  for (FilterSelection::iterator filterIt = selection->begin(); filterIt != selection->end(); ++filterIt) {
159  SFilter& filter = (*filterIt);
160  // bool lastCut=((filterIt+1)==selection->end());
161 
162  //increment the directory name
164  if (filter.inverted())
165  cumulative += "not";
166  cumulative += filter->name();
167  separator = "_";
168 
169  if (accept[filter->name()]) {
170  // if (globalAccept && selection->makeCumulativePlots() && !lastCut)
171  if (globalAccept && selection->makeCumulativePlots() && plotter_)
172  plotter_->fill(cumulative, iEvent);
173  } else {
174  globalAccept = false;
175  // did all the others filter fire
176  bool goodForAllButThisOne = true;
177  for (std::map<std::string, bool>::iterator decision = accept.begin(); decision != accept.end(); ++decision) {
178  if (decision->first == filter->name())
179  continue;
180  if (!decision->second) {
181  goodForAllButThisOne = false;
182  break;
183  }
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 
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 }

References accept(), RawDataTask_cfi::cumulative, flows_, iEvent, eostools::move(), ntupler_, plotter_, corrVsCorr::selection, selections_, mps_merge::separator, optionsL1T::skip, AlCaHLTBitMon_QueryRunRegistry::string, and workAsASelector_.

Member Data Documentation

◆ flows_

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

Definition at line 58 of file ConfigurableAnalysis.cc.

Referenced by ConfigurableAnalysis(), and filter().

◆ ntupler_

std::unique_ptr<NTupler> ConfigurableAnalysis::ntupler_
private

Definition at line 56 of file ConfigurableAnalysis.cc.

Referenced by ConfigurableAnalysis(), and filter().

◆ plotter_

std::unique_ptr<Plotter> ConfigurableAnalysis::plotter_
private

Definition at line 55 of file ConfigurableAnalysis.cc.

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

◆ selections_

std::unique_ptr<FilterSelections> ConfigurableAnalysis::selections_
private

Definition at line 54 of file ConfigurableAnalysis.cc.

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

◆ workAsASelector_

bool ConfigurableAnalysis::workAsASelector_
private

Definition at line 59 of file ConfigurableAnalysis.cc.

Referenced by ConfigurableAnalysis(), and filter().

ConfigurableAnalysis::flows_
std::vector< std::string > flows_
Definition: ConfigurableAnalysis.cc:58
FilterSelections::iterator
std::vector< FilterSelection >::iterator iterator
Definition: Selections.h:327
RawDataTask_cfi.cumulative
cumulative
Definition: RawDataTask_cfi.py:196
edm::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:47
mps_merge.separator
string separator
Definition: mps_merge.py:79
optionsL1T.skip
skip
Definition: optionsL1T.py:30
accept
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
corrVsCorr.selection
selection
main part
Definition: corrVsCorr.py:100
ConfigurableAnalysis::selections_
std::unique_ptr< FilterSelections > selections_
Definition: ConfigurableAnalysis.cc:54
SFilter
Definition: Selections.h:75
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:681
ConfigurableAnalysis::plotter_
std::unique_ptr< Plotter > plotter_
Definition: ConfigurableAnalysis.cc:55
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Service
Definition: Service.h:30
iEvent
int iEvent
Definition: GenABIO.cc:224
ConfigurableAnalysis::ntupler_
std::unique_ptr< NTupler > ntupler_
Definition: ConfigurableAnalysis.cc:56
get
#define get
ConfigurableAnalysis::filter
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: ConfigurableAnalysis.cc:119
RecoTauValidation_cfi.plotPset
plotPset
Definition: RecoTauValidation_cfi.py:217
ConfigurableAnalysis::workAsASelector_
bool workAsASelector_
Definition: ConfigurableAnalysis.cc:59
eostools.move
def move(src, dest)
Definition: eostools.py:511
FilterSelection::iterator
std::vector< SFilter >::iterator iterator
Definition: Selections.h:139
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
edm::ProducerBase::producesCollector
ProducesCollector producesCollector()
Definition: ProducerBase.cc:105
edm::ParameterSet::empty
bool empty() const
Definition: ParameterSet.h:201