CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 5 of file SimpleSystematicsAnalyzer.cc.

Constructor & Destructor Documentation

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

Definition at line 34 of file SimpleSystematicsAnalyzer.cc.

34  :
35  selectorPath_(pset.getUntrackedParameter<std::string> ("SelectorPath","")),
36  weightTags_(pset.getUntrackedParameter<std::vector<edm::InputTag> > ("WeightTags")) {
37 }
T getUntrackedParameter(std::string const &, T const &) const
std::vector< edm::InputTag > weightTags_
SimpleSystematicsAnalyzer::~SimpleSystematicsAnalyzer ( )
virtual

Definition at line 40 of file SimpleSystematicsAnalyzer.cc.

40 {}

Member Function Documentation

void SimpleSystematicsAnalyzer::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDFilter.

Definition at line 43 of file SimpleSystematicsAnalyzer.cc.

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

43  {
44  originalEvents_ = 0;
45  selectedEvents_ = 0;
46  edm::LogVerbatim("SimpleSystematicsAnalysis") << "Uncertainties will be determined for the following tags: ";
47  for (unsigned int i=0; i<weightTags_.size(); ++i) {
48  edm::LogVerbatim("SimpleSystematicsAnalysis") << "\t" << weightTags_[i].encode();
49  weightedEvents_.push_back(0.);
50  weightedSelectedEvents_.push_back(0.);
51  weighted2SelectedEvents_.push_back(0.);
52  }
53 }
int i
Definition: DBlmapReader.cc:9
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 56 of file SimpleSystematicsAnalyzer.cc.

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

56  {
57  if (originalEvents_==0) {
58  edm::LogVerbatim("SimpleSystematicsAnalysis") << "NO EVENTS => NO RESULTS";
59  return;
60  }
61  if (selectedEvents_==0) {
62  edm::LogVerbatim("SimpleSystematicsAnalysis") << "NO SELECTED EVENTS => NO RESULTS";
63  return;
64  }
65 
66  edm::LogVerbatim("SimpleSystematicsAnalysis") << "\n>>>> Begin of Weight systematics summary >>>>";
67  edm::LogVerbatim("SimpleSystematicsAnalysis") << "Total number of analyzed data: " << originalEvents_ << " [events]";
68  double originalAcceptance = double(selectedEvents_)/originalEvents_;
69  edm::LogVerbatim("SimpleSystematicsAnalysis") << "Total number of selected data: " << selectedEvents_ << " [events], corresponding to acceptance: [" << originalAcceptance*100 << " +- " << 100*sqrt( originalAcceptance*(1.-originalAcceptance)/originalEvents_) << "] %";
70 
71  for (unsigned int i=0; i<weightTags_.size(); ++i) {
72  edm::LogVerbatim("SimpleSystematicsAnalysis") << "Results for Weight Tag: " << weightTags_[i].encode() << " ---->";
73 
74  double acc_central = 0.;
75  double acc2_central = 0.;
76  if (weightedEvents_[i]>0) {
77  acc_central = weightedSelectedEvents_[i]/weightedEvents_[i];
78  acc2_central = weighted2SelectedEvents_[i]/weightedEvents_[i];
79  }
80  double waverage = weightedEvents_[i]/originalEvents_;
81  edm::LogVerbatim("SimpleSystematicsAnalysis") << "\tTotal Events after reweighting: " << weightedEvents_[i] << " [events]";
82  edm::LogVerbatim("SimpleSystematicsAnalysis") << "\tEvents selected after reweighting: " << weightedSelectedEvents_[i] << " [events]";
83  edm::LogVerbatim("SimpleSystematicsAnalysis") << "\tAcceptance after reweighting: [" << acc_central*100 << " +- " <<
84  100*sqrt((acc2_central/waverage-acc_central*acc_central)/originalEvents_)
85  << "] %";
86  double xi = acc_central-originalAcceptance;
87  double deltaxi = (acc2_central-(originalAcceptance+2*xi+xi*xi))/originalEvents_;
88  if (deltaxi>0) deltaxi = sqrt(deltaxi); else deltaxi = 0.;
89  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";
90 
91  }
92  edm::LogVerbatim("SimpleSystematicsAnalysis") << ">>>> End of Weight systematics summary >>>>";
93 
94 }
int i
Definition: DBlmapReader.cc:9
T sqrt(T t)
Definition: SSEVec.h:48
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

Implements edm::EDFilter.

Definition at line 97 of file SimpleSystematicsAnalyzer.cc.

References edm::Event::getByLabel(), i, originalEvents_, funct::pow(), selectedEvents_, selectorPath_, edm::TriggerNames::size(), edm::TriggerNames::triggerIndex(), edm::Event::triggerNames(), triggerResults, trigNames, weighted2SelectedEvents_, weightedEvents_, weightedSelectedEvents_, and weightTags_.

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().

97  {
99 
100  bool selectedEvent = false;
102  if (!ev.getByLabel(edm::InputTag("TriggerResults"), triggerResults)) {
103  edm::LogError("SimpleSystematicsAnalysis") << ">>> TRIGGER collection does not exist !!!";
104  return false;
105  }
106 
107  const edm::TriggerNames & trigNames = ev.triggerNames(*triggerResults);
108  unsigned int pathIndex = trigNames.triggerIndex(selectorPath_);
109  bool pathFound = (pathIndex<trigNames.size()); // pathIndex >= 0, since pathIndex is unsigned
110  if (pathFound) {
111  if (triggerResults->accept(pathIndex)) selectedEvent = true;
112  }
113  //edm::LogVerbatim("SimpleSystematicsAnalysis") << ">>>> Path Name: " << selectorPath_ << ", selected? " << selectedEvent;
114 
115  if (selectedEvent) selectedEvents_++;
116 
117  for (unsigned int i=0; i<weightTags_.size(); ++i) {
118  edm::Handle<double> weightHandle;
119  ev.getByLabel(weightTags_[i], weightHandle);
120  weightedEvents_[i] += (*weightHandle);
121  if (selectedEvent) {
122  weightedSelectedEvents_[i] += (*weightHandle);
123  weighted2SelectedEvents_[i] += pow((*weightHandle),2);
124  }
125  }
126 
127  return true;
128 }
int i
Definition: DBlmapReader.cc:9
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:204
Strings::size_type size() const
Definition: TriggerNames.cc:39
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
std::vector< double > weightedEvents_
static std::string const triggerResults
Definition: EdmProvDump.cc:41
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:74
std::vector< double > weighted2SelectedEvents_
std::vector< double > weightedSelectedEvents_
std::vector< edm::InputTag > weightTags_
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 15 of file SimpleSystematicsAnalyzer.cc.

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

unsigned int SimpleSystematicsAnalyzer::selectedEvents_
private

Definition at line 17 of file SimpleSystematicsAnalyzer.cc.

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

std::string SimpleSystematicsAnalyzer::selectorPath_
private

Definition at line 13 of file SimpleSystematicsAnalyzer.cc.

Referenced by filter().

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

Definition at line 19 of file SimpleSystematicsAnalyzer.cc.

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

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

Definition at line 16 of file SimpleSystematicsAnalyzer.cc.

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

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

Definition at line 18 of file SimpleSystematicsAnalyzer.cc.

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

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

Definition at line 14 of file SimpleSystematicsAnalyzer.cc.

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