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

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

Definition at line 6 of file SimpleSystematicsAnalyzer.cc.

Constructor & Destructor Documentation

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

Definition at line 38 of file SimpleSystematicsAnalyzer.cc.

References GlobalPosition_Frontier_DevDB_cff::tag, and triggerResultsToken_.

38  :
39  selectorPath_(pset.getUntrackedParameter<std::string> ("SelectorPath","")),
40  weightTags_(pset.getUntrackedParameter<std::vector<edm::InputTag> > ("WeightTags")),
41  weightTokens_(edm::vector_transform(weightTags_, [this](edm::InputTag const & tag){return consumes<double>(tag);})),
42  triggerResultsToken_(consumes<edm::TriggerResults>(edm::InputTag("TriggerResults"))) {
43 }
T getUntrackedParameter(std::string const &, T const &) const
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
std::vector< edm::EDGetTokenT< double > > weightTokens_
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
std::vector< edm::InputTag > weightTags_
SimpleSystematicsAnalyzer::~SimpleSystematicsAnalyzer ( )
virtual

Definition at line 46 of file SimpleSystematicsAnalyzer.cc.

46 {}

Member Function Documentation

void SimpleSystematicsAnalyzer::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDFilter.

Definition at line 49 of file SimpleSystematicsAnalyzer.cc.

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

49  {
50  originalEvents_ = 0;
51  selectedEvents_ = 0;
52  edm::LogVerbatim("SimpleSystematicsAnalysis") << "Uncertainties will be determined for the following tags: ";
53  for (unsigned int i=0; i<weightTags_.size(); ++i) {
54  edm::LogVerbatim("SimpleSystematicsAnalysis") << "\t" << weightTags_[i].encode();
55  weightedEvents_.push_back(0.);
56  weightedSelectedEvents_.push_back(0.);
57  weighted2SelectedEvents_.push_back(0.);
58  }
59 }
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 62 of file SimpleSystematicsAnalyzer.cc.

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

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

Definition at line 103 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().

103  {
104  originalEvents_++;
105 
106  bool selectedEvent = false;
108  if (!ev.getByToken(triggerResultsToken_, triggerResults)) {
109  edm::LogError("SimpleSystematicsAnalysis") << ">>> TRIGGER collection does not exist !!!";
110  return false;
111  }
112 
113  const edm::TriggerNames & trigNames = ev.triggerNames(*triggerResults);
114  unsigned int pathIndex = trigNames.triggerIndex(selectorPath_);
115  bool pathFound = (pathIndex<trigNames.size()); // pathIndex >= 0, since pathIndex is unsigned
116  if (pathFound) {
117  if (triggerResults->accept(pathIndex)) selectedEvent = true;
118  }
119  //edm::LogVerbatim("SimpleSystematicsAnalysis") << ">>>> Path Name: " << selectorPath_ << ", selected? " << selectedEvent;
120 
121  if (selectedEvent) selectedEvents_++;
122 
123  for (unsigned int i=0; i<weightTags_.size(); ++i) {
124  edm::Handle<double> weightHandle;
125  ev.getByToken(weightTokens_[i], weightHandle);
126  weightedEvents_[i] += (*weightHandle);
127  if (selectedEvent) {
128  weightedSelectedEvents_[i] += (*weightHandle);
129  weighted2SelectedEvents_[i] += pow((*weightHandle),2);
130  }
131  }
132 
133  return true;
134 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
bool accept() const
Has at least one path accepted the event?
Strings::size_type size() const
Definition: TriggerNames.cc:39
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
std::vector< edm::EDGetTokenT< double > > weightTokens_
std::vector< double > weightedEvents_
static std::string const triggerResults
Definition: EdmProvDump.cc:41
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:74
std::vector< double > weighted2SelectedEvents_
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
std::vector< double > weightedSelectedEvents_
std::vector< edm::InputTag > weightTags_
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:239
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40

Member Data Documentation

unsigned int SimpleSystematicsAnalyzer::originalEvents_
private

Definition at line 18 of file SimpleSystematicsAnalyzer.cc.

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

unsigned int SimpleSystematicsAnalyzer::selectedEvents_
private

Definition at line 20 of file SimpleSystematicsAnalyzer.cc.

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

std::string SimpleSystematicsAnalyzer::selectorPath_
private

Definition at line 14 of file SimpleSystematicsAnalyzer.cc.

Referenced by filter().

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

Definition at line 17 of file SimpleSystematicsAnalyzer.cc.

Referenced by filter(), and SimpleSystematicsAnalyzer().

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

Definition at line 22 of file SimpleSystematicsAnalyzer.cc.

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

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

Definition at line 19 of file SimpleSystematicsAnalyzer.cc.

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

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

Definition at line 21 of file SimpleSystematicsAnalyzer.cc.

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

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

Definition at line 15 of file SimpleSystematicsAnalyzer.cc.

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

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

Definition at line 16 of file SimpleSystematicsAnalyzer.cc.

Referenced by filter().