SusyNtuple
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes
MCWeighter Class Reference

A class to handle the normalization of Monte Carlo. More...

#include <MCWeighter.h>

List of all members.

Classes

struct  ProcessValidator
 Helper to keep track of events with invalid process id. More...
struct  SumwMapKey

Public Types

enum  SumwMethod { Sumw_NT = 0, Sumw_MAP }
enum  XsecMethod { Xsec_NT = 0, Xsec_ST }
enum  WeightSys {
  Sys_NOM = 0, Sys_XSEC_UP, Sys_XSEC_DN, Sys_PILEUP_UP,
  Sys_PILEUP_DN, Sys_N
}
typedef std::map< SumwMapKey,
float > 
SumwMap

Public Member Functions

 MCWeighter (TTree *tree, std::string xsecDir="$ROOTCOREDIR/data/SUSYTools/mc12_8TeV/")
void buildSumwMap (TTree *tree)
 Build a map of MCID -> sumw.
void clearAndRebuildSumwMap (TTree *tree)
void dumpSumwMap () const
void dumpXsecCache () const
void dumpXsecDb () const
void setUseProcSumw (bool useProcSumw=true)
 Specify methods to retrieve sumw and xsec.
void setSumwMethod (SumwMethod opt=Sumw_MAP)
void setXsecMethod (XsecMethod opt=Xsec_ST)
float getMCWeight (const Susy::Event *evt, const float lumi=LUMI_A_A3, WeightSys sys=Sys_NOM)
 MC Weight includes generator, xsec, lumi, and pileup weights.
bool sumwmapHasKey (SumwMapKey k)
float getSumw (const Susy::Event *evt)
SUSY::CrossSectionDB::Process getCrossSection (const Susy::Event *evt)
 Get cross section for this event.
float getXsecTimesEff (const Susy::Event *evt, WeightSys sys=Sys_NOM)
float getPileupWeight (const Susy::Event *evt, WeightSys sys=Sys_NOM)
 Get the pileup weight.
MCWeightersetLabelBinCounter (const std::string &v)
 specify the bin used to compute sumw
size_t parseAdditionalXsecFile (const std::string &filename, bool verbose)
 read additional files containing more cross section values
size_t parseAdditionalXsecDirectory (const std::string &dir, bool verbose)
 same as parseAdditionalXsecFile, but get any *.txt in a given directory
MCWeightersetAllowInvalid (bool v)
 toggle m_allowInvalid option
MCWeightersetVerbose (bool v)
 toggle m_verbose

Static Public Member Functions

static std::string defaultLabelBinCounter (const unsigned int &dsid, bool verbose)
 counter used to compute the normalization
static void checkHistoHasBin (const TH1F &histo, const std::string &binLabel)
 print a warning if the histo doesn't have a bin with the given label
static std::string defaultXsecDir ()
 default directory from which we read the xsec files for SUSY::CrossSectionDB
static std::vector< std::string > xsecFilesForSimplifiedModels ()
 a list of the xsec files containing known simplified models
static std::vector< int > dsidsForKnownSimpliedModelSamples (bool verbose)
 a list of known SM dsids from xsecFilesForSimplifiedModels()
static bool isFormattedAsSusyCrossSection (std::string filename, bool verbose)
 determine whether a given file is formatted following the CrossSectionDB format
static std::vector< int > readDsidsFromSusyCrossSectionFile (std::string filename, bool verbose)
 given a text file containing cross sections for CrossSectionDB, return the dsids
static bool readDsidsFromSusyCrossSectionLine (const std::string &line, int &dsid, bool verbose)
 given a line from a xsec file, parse the dsid; return false if cannot parse
static bool isSimplifiedModel (const unsigned int &dsid, bool verbose)
 guess from dsid whether this sample is a simplified model one
static const Susy::EventreadFirstEvent (TTree *tree)
 read the first event from the tree (often used to retrieve sample parameters)
static int extractProcessFromCutflowHistoname (const std::string &histoName, const std::string &prefix)
 extract 'XYZ' from 'prefixXYZ'

Public Attributes

float total_sumw
 Get sumw for this event.

Detailed Description

A class to handle the normalization of Monte Carlo.

A MC sample is normalized with the factor $\sigma * lumi / \sum w$ This factor multiplies the generator event weight and all the other factors (pileup, lepton efficiency, trigger scale factors etc.) Some samples can include multiple processes. This class holds a map of the $\sum w$ values for each process. The $\sum w$ is computed from the cutflow histograms that are stored with the susyNt tree.

The user can specify the bin whose contents are used to compute w; otherwise defaultLabelBinCounter() will be used.

Two types of histograms are considered:

Todo:
drop all the obsolete functionalities. Right now we support only the sumwmap method with the sumw retrieved from the histogram.

Member Function Documentation

void MCWeighter::buildSumwMap ( TTree *  tree)

Build a map of MCID -> sumw.

This method will loop over the input files associated with the TChain. The MCID in the first entry of the tree will be used, so one CANNOT use this if multiple datasets are combined into one SusyNt tree file! The generator weighted cutflow histograms will then be used to calculate the total sumw for each MCID. Each dataset used here must be complete, they CANNOT be spread out across multiple jobs. However, one can have more than one (complete) dataset in the chain, which is why we use the map.

std::string MCWeighter::defaultLabelBinCounter ( const unsigned int &  dsid,
bool  verbose 
) [static]

counter used to compute the normalization

Unless the user has specified a value with setLabelBinCounter(), use "Initial" for all samples, and "SusyProp Veto" for SUSY simplified models.

bool MCWeighter::isFormattedAsSusyCrossSection ( std::string  filename,
bool  verbose 
) [static]

determine whether a given file is formatted following the CrossSectionDB format

The format is essentially 6 words:

id name(or final_state) xsect kfactor efficiency rel.uncertainty

Empty lines and comments ('#') are skipped. For more details, see SUSYTools/SUSYCrossSection.h

bool MCWeighter::isSimplifiedModel ( const unsigned int &  dsid,
bool  verbose 
) [static]

guess from dsid whether this sample is a simplified model one

This guess is based on whether the dsid is in a list of known dsids from the xsec files in 'SUSYTools/data'.

See also util/test_mcWeighter.cxx

size_t MCWeighter::parseAdditionalXsecFile ( const std::string &  filename,
bool  verbose 
)

read additional files containing more cross section values

This is to account for samples that are not in the SUSYTools lists. Returns the number of cross section values read from the file.

MCWeighter & MCWeighter::setLabelBinCounter ( const std::string &  v)

specify the bin used to compute sumw

If the label is set after sumwmap has been built, you need to call clearAndRebuildSumwMap. For a list of available bin labels (counters), see SusyNtMaker::makeCutFlow()


The documentation for this class was generated from the following files:
 All Classes Functions Variables Typedefs Enumerations Enumerator