CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
SimpleSystematicsAnalyzer Class Reference
Inheritance diagram for SimpleSystematicsAnalyzer:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void beginJob () override
 
void endJob () override
 
bool filter (edm::Event &, const edm::EventSetup &) override
 
 SimpleSystematicsAnalyzer (const edm::ParameterSet &pset)
 
 ~SimpleSystematicsAnalyzer () override
 
- 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::vector< ModuleDescription const * > &modules, 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 Attributes

unsigned int originalEvents_
 
unsigned int selectedEvents_
 
std::string selectorPath_
 
edm::EDGetTokenT< edm::TriggerResultstriggerResultsToken_
 
std::vector< double > weighted2SelectedEvents_
 
std::vector< double > weightedEvents_
 
std::vector< double > weightedSelectedEvents_
 
std::vector< edm::InputTagweightTags_
 
std::vector< edm::EDGetTokenT< double > > weightTokens_
 

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

Definition at line 6 of file SimpleSystematicsAnalyzer.cc.

Constructor & Destructor Documentation

◆ SimpleSystematicsAnalyzer()

SimpleSystematicsAnalyzer::SimpleSystematicsAnalyzer ( const edm::ParameterSet pset)

Definition at line 39 of file SimpleSystematicsAnalyzer.cc.

40  : selectorPath_(pset.getUntrackedParameter<std::string>("SelectorPath", "")),
41  weightTags_(pset.getUntrackedParameter<std::vector<edm::InputTag> >("WeightTags")),
43  edm::vector_transform(weightTags_, [this](edm::InputTag const& tag) { return consumes<double>(tag); })),
44  triggerResultsToken_(consumes<edm::TriggerResults>(edm::InputTag("TriggerResults"))) {}

References GlobalPosition_Frontier_DevDB_cff::tag.

◆ ~SimpleSystematicsAnalyzer()

SimpleSystematicsAnalyzer::~SimpleSystematicsAnalyzer ( )
override

Definition at line 47 of file SimpleSystematicsAnalyzer.cc.

47 {}

Member Function Documentation

◆ beginJob()

void SimpleSystematicsAnalyzer::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDFilter.

Definition at line 50 of file SimpleSystematicsAnalyzer.cc.

50  {
51  originalEvents_ = 0;
52  selectedEvents_ = 0;
53  edm::LogVerbatim("SimpleSystematicsAnalysis") << "Uncertainties will be determined for the following tags: ";
54  for (unsigned int i = 0; i < weightTags_.size(); ++i) {
55  edm::LogVerbatim("SimpleSystematicsAnalysis") << "\t" << weightTags_[i].encode();
56  weightedEvents_.push_back(0.);
57  weightedSelectedEvents_.push_back(0.);
58  weighted2SelectedEvents_.push_back(0.);
59  }
60 }

References mps_fire::i, originalEvents_, selectedEvents_, weighted2SelectedEvents_, weightedEvents_, weightedSelectedEvents_, and weightTags_.

◆ endJob()

void SimpleSystematicsAnalyzer::endJob ( void  )
overridevirtual

Reimplemented from edm::EDFilter.

Definition at line 63 of file SimpleSystematicsAnalyzer.cc.

63  {
64  if (originalEvents_ == 0) {
65  edm::LogVerbatim("SimpleSystematicsAnalysis") << "NO EVENTS => NO RESULTS";
66  return;
67  }
68  if (selectedEvents_ == 0) {
69  edm::LogVerbatim("SimpleSystematicsAnalysis") << "NO SELECTED EVENTS => NO RESULTS";
70  return;
71  }
72 
73  edm::LogVerbatim("SimpleSystematicsAnalysis") << "\n>>>> Begin of Weight systematics summary >>>>";
74  edm::LogVerbatim("SimpleSystematicsAnalysis") << "Total number of analyzed data: " << originalEvents_ << " [events]";
75  double originalAcceptance = double(selectedEvents_) / originalEvents_;
76  edm::LogVerbatim("SimpleSystematicsAnalysis")
77  << "Total number of selected data: " << selectedEvents_ << " [events], corresponding to acceptance: ["
78  << originalAcceptance * 100 << " +- "
79  << 100 * sqrt(originalAcceptance * (1. - originalAcceptance) / originalEvents_) << "] %";
80 
81  for (unsigned int i = 0; i < weightTags_.size(); ++i) {
82  edm::LogVerbatim("SimpleSystematicsAnalysis") << "Results for Weight Tag: " << weightTags_[i].encode() << " ---->";
83 
84  double acc_central = 0.;
85  double acc2_central = 0.;
86  if (weightedEvents_[i] > 0) {
87  acc_central = weightedSelectedEvents_[i] / weightedEvents_[i];
88  acc2_central = weighted2SelectedEvents_[i] / weightedEvents_[i];
89  }
90  double waverage = weightedEvents_[i] / originalEvents_;
91  edm::LogVerbatim("SimpleSystematicsAnalysis")
92  << "\tTotal Events after reweighting: " << weightedEvents_[i] << " [events]";
93  edm::LogVerbatim("SimpleSystematicsAnalysis")
94  << "\tEvents selected after reweighting: " << weightedSelectedEvents_[i] << " [events]";
95  edm::LogVerbatim("SimpleSystematicsAnalysis")
96  << "\tAcceptance after reweighting: [" << acc_central * 100 << " +- "
97  << 100 * sqrt((acc2_central / waverage - acc_central * acc_central) / originalEvents_) << "] %";
98  double xi = acc_central - originalAcceptance;
99  double deltaxi = (acc2_central - (originalAcceptance + 2 * xi + xi * xi)) / originalEvents_;
100  if (deltaxi > 0)
101  deltaxi = sqrt(deltaxi);
102  else
103  deltaxi = 0.;
104  edm::LogVerbatim("SimpleSystematicsAnalysis")
105  << "\ti.e. [" << std::setprecision(4) << 100 * xi / originalAcceptance << " +- " << std::setprecision(4)
106  << 100 * deltaxi / originalAcceptance << "] % relative variation with respect to the original acceptance";
107  }
108  edm::LogVerbatim("SimpleSystematicsAnalysis") << ">>>> End of Weight systematics summary >>>>";
109 }

References mps_fire::i, originalEvents_, selectedEvents_, mathSSE::sqrt(), weighted2SelectedEvents_, weightedEvents_, weightedSelectedEvents_, weightTags_, and hybridSuperClusters_cfi::xi.

◆ filter()

bool SimpleSystematicsAnalyzer::filter ( edm::Event ev,
const edm::EventSetup  
)
overridevirtual

Implements edm::EDFilter.

Definition at line 112 of file SimpleSystematicsAnalyzer.cc.

112  {
113  originalEvents_++;
114 
115  bool selectedEvent = false;
117  if (!ev.getByToken(triggerResultsToken_, triggerResults)) {
118  edm::LogError("SimpleSystematicsAnalysis") << ">>> TRIGGER collection does not exist !!!";
119  return false;
120  }
121 
122  const edm::TriggerNames& trigNames = ev.triggerNames(*triggerResults);
123  unsigned int pathIndex = trigNames.triggerIndex(selectorPath_);
124  bool pathFound = (pathIndex < trigNames.size()); // pathIndex >= 0, since pathIndex is unsigned
125  if (pathFound) {
126  if (triggerResults->accept(pathIndex))
127  selectedEvent = true;
128  }
129  //edm::LogVerbatim("SimpleSystematicsAnalysis") << ">>>> Path Name: " << selectorPath_ << ", selected? " << selectedEvent;
130 
131  if (selectedEvent)
132  selectedEvents_++;
133 
134  for (unsigned int i = 0; i < weightTags_.size(); ++i) {
135  edm::Handle<double> weightHandle;
136  ev.getByToken(weightTokens_[i], weightHandle);
137  weightedEvents_[i] += (*weightHandle);
138  if (selectedEvent) {
139  weightedSelectedEvents_[i] += (*weightHandle);
140  weighted2SelectedEvents_[i] += pow((*weightHandle), 2);
141  }
142  }
143 
144  return true;
145 }

References ev, mps_fire::i, originalEvents_, funct::pow(), selectedEvents_, selectorPath_, triggerResults, triggerResultsToken_, trigNames, weighted2SelectedEvents_, weightedEvents_, weightedSelectedEvents_, weightTags_, and weightTokens_.

Member Data Documentation

◆ originalEvents_

unsigned int SimpleSystematicsAnalyzer::originalEvents_
private

Definition at line 19 of file SimpleSystematicsAnalyzer.cc.

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

◆ selectedEvents_

unsigned int SimpleSystematicsAnalyzer::selectedEvents_
private

Definition at line 21 of file SimpleSystematicsAnalyzer.cc.

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

◆ selectorPath_

std::string SimpleSystematicsAnalyzer::selectorPath_
private

Definition at line 15 of file SimpleSystematicsAnalyzer.cc.

Referenced by filter().

◆ triggerResultsToken_

edm::EDGetTokenT<edm::TriggerResults> SimpleSystematicsAnalyzer::triggerResultsToken_
private

Definition at line 18 of file SimpleSystematicsAnalyzer.cc.

Referenced by filter().

◆ weighted2SelectedEvents_

std::vector<double> SimpleSystematicsAnalyzer::weighted2SelectedEvents_
private

Definition at line 23 of file SimpleSystematicsAnalyzer.cc.

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

◆ weightedEvents_

std::vector<double> SimpleSystematicsAnalyzer::weightedEvents_
private

Definition at line 20 of file SimpleSystematicsAnalyzer.cc.

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

◆ weightedSelectedEvents_

std::vector<double> SimpleSystematicsAnalyzer::weightedSelectedEvents_
private

Definition at line 22 of file SimpleSystematicsAnalyzer.cc.

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

◆ weightTags_

std::vector<edm::InputTag> SimpleSystematicsAnalyzer::weightTags_
private

Definition at line 16 of file SimpleSystematicsAnalyzer.cc.

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

◆ weightTokens_

std::vector<edm::EDGetTokenT<double> > SimpleSystematicsAnalyzer::weightTokens_
private

Definition at line 17 of file SimpleSystematicsAnalyzer.cc.

Referenced by filter().

SimpleSystematicsAnalyzer::weightedEvents_
std::vector< double > weightedEvents_
Definition: SimpleSystematicsAnalyzer.cc:20
mps_fire.i
i
Definition: mps_fire.py:428
trigNames
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:57
hybridSuperClusters_cfi.xi
xi
Definition: hybridSuperClusters_cfi.py:10
triggerResults
static const std::string triggerResults
Definition: EdmProvDump.cc:45
edm::Handle< edm::TriggerResults >
SimpleSystematicsAnalyzer::selectedEvents_
unsigned int selectedEvents_
Definition: SimpleSystematicsAnalyzer.cc:21
SimpleSystematicsAnalyzer::weightTokens_
std::vector< edm::EDGetTokenT< double > > weightTokens_
Definition: SimpleSystematicsAnalyzer.cc:17
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
SimpleSystematicsAnalyzer::weightedSelectedEvents_
std::vector< double > weightedSelectedEvents_
Definition: SimpleSystematicsAnalyzer.cc:22
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
SimpleSystematicsAnalyzer::weighted2SelectedEvents_
std::vector< double > weighted2SelectedEvents_
Definition: SimpleSystematicsAnalyzer.cc:23
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::vector_transform
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
SimpleSystematicsAnalyzer::weightTags_
std::vector< edm::InputTag > weightTags_
Definition: SimpleSystematicsAnalyzer.cc:16
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SimpleSystematicsAnalyzer::triggerResultsToken_
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
Definition: SimpleSystematicsAnalyzer.cc:18
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
SimpleSystematicsAnalyzer::selectorPath_
std::string selectorPath_
Definition: SimpleSystematicsAnalyzer.cc:15
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
edm::TriggerNames
Definition: TriggerNames.h:55
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
SimpleSystematicsAnalyzer::originalEvents_
unsigned int originalEvents_
Definition: SimpleSystematicsAnalyzer.cc:19
edm::InputTag
Definition: InputTag.h:15
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27