CMS 3D CMS Logo

Public Member Functions | Private Attributes

SimpleSystematicsAnalyzer Class Reference

Inheritance diagram for SimpleSystematicsAnalyzer:
edm::EDFilter edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

virtual void beginJob ()
virtual void endJob ()
virtual bool filter (edm::Event &, const edm::EventSetup &)
 SimpleSystematicsAnalyzer (const edm::ParameterSet &pset)
virtual ~SimpleSystematicsAnalyzer ()

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_

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.

                                                                                :
  selectorPath_(pset.getUntrackedParameter<std::string> ("SelectorPath","")),
  weightTags_(pset.getUntrackedParameter<std::vector<edm::InputTag> > ("WeightTags")) { 
}
SimpleSystematicsAnalyzer::~SimpleSystematicsAnalyzer ( ) [virtual]

Definition at line 40 of file SimpleSystematicsAnalyzer.cc.

{}

Member Function Documentation

void SimpleSystematicsAnalyzer::beginJob ( void  ) [virtual]

Reimplemented from edm::EDFilter.

Definition at line 43 of file SimpleSystematicsAnalyzer.cc.

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

                                        {
      originalEvents_ = 0;
      selectedEvents_ = 0;
      edm::LogVerbatim("SimpleSystematicsAnalysis") << "Uncertainties will be determined for the following tags: ";
      for (unsigned int i=0; i<weightTags_.size(); ++i) {
            edm::LogVerbatim("SimpleSystematicsAnalysis") << "\t" << weightTags_[i].encode();
            weightedEvents_.push_back(0.);
            weightedSelectedEvents_.push_back(0.);
            weighted2SelectedEvents_.push_back(0.);
      }
}
void SimpleSystematicsAnalyzer::endJob ( void  ) [virtual]

Reimplemented from edm::EDFilter.

Definition at line 56 of file SimpleSystematicsAnalyzer.cc.

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

                                      {
      if (originalEvents_==0) {
            edm::LogVerbatim("SimpleSystematicsAnalysis") << "NO EVENTS => NO RESULTS";
            return;
      }
      if (selectedEvents_==0) {
            edm::LogVerbatim("SimpleSystematicsAnalysis") << "NO SELECTED EVENTS => NO RESULTS";
            return;
      }

      edm::LogVerbatim("SimpleSystematicsAnalysis") << "\n>>>> Begin of Weight systematics summary >>>>";
      edm::LogVerbatim("SimpleSystematicsAnalysis") << "Total number of analyzed data: " << originalEvents_ << " [events]";
      double originalAcceptance = double(selectedEvents_)/originalEvents_;
      edm::LogVerbatim("SimpleSystematicsAnalysis") << "Total number of selected data: " << selectedEvents_ << " [events], corresponding to acceptance: [" << originalAcceptance*100 << " +- " << 100*sqrt( originalAcceptance*(1.-originalAcceptance)/originalEvents_) << "] %";
      
      for (unsigned int i=0; i<weightTags_.size(); ++i) {
            edm::LogVerbatim("SimpleSystematicsAnalysis") << "Results for Weight Tag: " << weightTags_[i].encode() << " ---->";

            double acc_central = 0.;
            double acc2_central = 0.;
            if (weightedEvents_[i]>0) {
                  acc_central = weightedSelectedEvents_[i]/weightedEvents_[i]; 
                  acc2_central = weighted2SelectedEvents_[i]/weightedEvents_[i]; 
            }
            double waverage = weightedEvents_[i]/originalEvents_;
            edm::LogVerbatim("SimpleSystematicsAnalysis") << "\tTotal Events after reweighting: " << weightedEvents_[i] << " [events]";
            edm::LogVerbatim("SimpleSystematicsAnalysis") << "\tEvents selected after reweighting: " << weightedSelectedEvents_[i] << " [events]";
            edm::LogVerbatim("SimpleSystematicsAnalysis") << "\tAcceptance after reweighting: [" << acc_central*100 << " +- " << 
            100*sqrt((acc2_central/waverage-acc_central*acc_central)/originalEvents_)
            << "] %";
            double xi = acc_central-originalAcceptance;
            double deltaxi = (acc2_central-(originalAcceptance+2*xi+xi*xi))/originalEvents_;
            if (deltaxi>0) deltaxi = sqrt(deltaxi); else deltaxi = 0.;
            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";

      }
      edm::LogVerbatim("SimpleSystematicsAnalysis") << ">>>> End of Weight systematics summary >>>>";

}
bool SimpleSystematicsAnalyzer::filter ( edm::Event ev,
const edm::EventSetup  
) [virtual]

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(), patRefSel_triggerSelection_cff::triggerResults, trigNames, weighted2SelectedEvents_, weightedEvents_, weightedSelectedEvents_, and weightTags_.

                                                                         {
      originalEvents_++;

      bool selectedEvent = false;
      edm::Handle<edm::TriggerResults> triggerResults;
      if (!ev.getByLabel(edm::InputTag("TriggerResults"), triggerResults)) {
            edm::LogError("SimpleSystematicsAnalysis") << ">>> TRIGGER collection does not exist !!!";
            return false;
      }

      const edm::TriggerNames & trigNames = ev.triggerNames(*triggerResults);
      unsigned int pathIndex = trigNames.triggerIndex(selectorPath_);
      bool pathFound = (pathIndex<trigNames.size()); // pathIndex >= 0, since pathIndex is unsigned
      if (pathFound) {
            if (triggerResults->accept(pathIndex)) selectedEvent = true;
      }
      //edm::LogVerbatim("SimpleSystematicsAnalysis") << ">>>> Path Name: " << selectorPath_ << ", selected? " << selectedEvent;

      if (selectedEvent) selectedEvents_++;

      for (unsigned int i=0; i<weightTags_.size(); ++i) {
            edm::Handle<double> weightHandle;
            ev.getByLabel(weightTags_[i], weightHandle);
            weightedEvents_[i] += (*weightHandle);
            if (selectedEvent) {
                  weightedSelectedEvents_[i] += (*weightHandle);
                  weighted2SelectedEvents_[i] += pow((*weightHandle),2);
            }
      }

      return true;
}

Member Data Documentation

Definition at line 15 of file SimpleSystematicsAnalyzer.cc.

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

Definition at line 17 of file SimpleSystematicsAnalyzer.cc.

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

Definition at line 13 of file SimpleSystematicsAnalyzer.cc.

Referenced by filter().

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

Definition at line 18 of file SimpleSystematicsAnalyzer.cc.

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

Definition at line 14 of file SimpleSystematicsAnalyzer.cc.

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