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
 
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)
 
 ~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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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 wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

Definition at line 6 of file SimpleSystematicsAnalyzer.cc.

Constructor & Destructor Documentation

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

Definition at line 39 of file SimpleSystematicsAnalyzer.cc.

References GlobalPosition_Frontier_DevDB_cff::tag, and triggerResultsToken_.

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"))) {}
T getUntrackedParameter(std::string const &, T const &) const
std::vector< edm::EDGetTokenT< double > > weightTokens_
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
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
std::vector< edm::InputTag > weightTags_
SimpleSystematicsAnalyzer::~SimpleSystematicsAnalyzer ( )
override

Definition at line 47 of file SimpleSystematicsAnalyzer.cc.

47 {}

Member Function Documentation

void SimpleSystematicsAnalyzer::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDFilter.

Definition at line 50 of file SimpleSystematicsAnalyzer.cc.

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

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 }
std::vector< double > weightedEvents_
std::vector< double > weighted2SelectedEvents_
std::vector< double > weightedSelectedEvents_
std::vector< edm::InputTag > weightTags_
void SimpleSystematicsAnalyzer::endJob ( void  )
overridevirtual

Reimplemented from edm::EDFilter.

Definition at line 63 of file SimpleSystematicsAnalyzer.cc.

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

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 }
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< double > weightedEvents_
std::vector< double > weighted2SelectedEvents_
std::vector< double > weightedSelectedEvents_
std::vector< edm::InputTag > weightTags_
bool SimpleSystematicsAnalyzer::filter ( edm::Event ev,
const edm::EventSetup  
)
override

Definition at line 112 of file SimpleSystematicsAnalyzer.cc.

References edm::HLTGlobalStatus::accept(), DEFINE_FWK_MODULE, edm::Event::getByToken(), mps_fire::i, originalEvents_, funct::pow(), selectedEvents_, selectorPath_, edm::TriggerNames::size(), edm::TriggerNames::triggerIndex(), edm::Event::triggerNames(), triggerResults, triggerResultsToken_, trigNames, weighted2SelectedEvents_, weightedEvents_, weightedSelectedEvents_, weightTags_, and weightTokens_.

Referenced by Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::filter(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::setDataAccessor(), and Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::switchCenterView().

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 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
bool accept() const
Has at least one path accepted the event?
Strings::size_type size() const
Definition: TriggerNames.cc:31
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:24
std::vector< edm::EDGetTokenT< double > > weightTokens_
std::vector< double > weightedEvents_
static std::string const triggerResults
Definition: EdmProvDump.cc:45
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:57
std::vector< double > weighted2SelectedEvents_
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
std::vector< double > weightedSelectedEvents_
std::vector< edm::InputTag > weightTags_
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:265
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30

Member Data Documentation

unsigned int SimpleSystematicsAnalyzer::originalEvents_
private

Definition at line 19 of file SimpleSystematicsAnalyzer.cc.

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

unsigned int SimpleSystematicsAnalyzer::selectedEvents_
private

Definition at line 21 of file SimpleSystematicsAnalyzer.cc.

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

std::string SimpleSystematicsAnalyzer::selectorPath_
private

Definition at line 15 of file SimpleSystematicsAnalyzer.cc.

Referenced by filter().

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

Definition at line 18 of file SimpleSystematicsAnalyzer.cc.

Referenced by filter(), and SimpleSystematicsAnalyzer().

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

Definition at line 23 of file SimpleSystematicsAnalyzer.cc.

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

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

Definition at line 20 of file SimpleSystematicsAnalyzer.cc.

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

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

Definition at line 22 of file SimpleSystematicsAnalyzer.cc.

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

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

Definition at line 16 of file SimpleSystematicsAnalyzer.cc.

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

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

Definition at line 17 of file SimpleSystematicsAnalyzer.cc.

Referenced by filter().