Skip to content

Commit

Permalink
Merge pull request #10035 from lgray/egm_id_74X_v2
Browse files Browse the repository at this point in the history
EGM IDs for CMSSW 74X Redux
  • Loading branch information
davidlange6 committed Jul 10, 2015
2 parents e20ad40 + 1de57d7 commit 7fe6c72
Show file tree
Hide file tree
Showing 112 changed files with 5,075 additions and 146 deletions.
1 change: 1 addition & 0 deletions CommonTools/CandAlgos/BuildFile.xml
@@ -1,6 +1,7 @@
<use name="SimGeneral/HepPDTRecord"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="DataFormats/PatCandidates"/>
<export>
<lib name="1"/>
</export>
61 changes: 61 additions & 0 deletions CommonTools/CandAlgos/interface/ModifyObjectValueBase.h
@@ -0,0 +1,61 @@
#ifndef __CommonTools_CandAlgos_ModifyObjectValueBase_h__
#define __CommonTools_CandAlgos_ModifyObjectValueBase_h__

#include "DataFormats/PatCandidates/interface/Electron.h"
#include "DataFormats/PatCandidates/interface/Photon.h"
#include "DataFormats/PatCandidates/interface/Muon.h"
#include "DataFormats/PatCandidates/interface/Tau.h"
#include "DataFormats/PatCandidates/interface/Jet.h"

#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

#include <string>

class ModifyObjectValueBase {
public:
ModifyObjectValueBase(const edm::ParameterSet& conf) :
name_( conf.getParameter<std::string>("modifierName") ) {}

virtual ~ModifyObjectValueBase() {}

virtual void setEvent(const edm::Event&) {}
virtual void setEventContent(const edm::EventSetup&) {}
virtual void setConsumes(edm::ConsumesCollector&) {}

virtual void modifyObject(pat::Electron&) const {
throw cms::Exception("InvalidConfiguration")
<< name_ << " is not configured to handle electrons!";
}
virtual void modifyObject(pat::Photon&) const {
throw cms::Exception("InvalidConfiguration")
<< name_ << " is not configured to handle photons!";
}
virtual void modifyObject(pat::Muon&) const {
throw cms::Exception("InvalidConfiguration")
<< name_ << " is not configured to handle muons!";
}
virtual void modifyObject(pat::Tau&) const {
throw cms::Exception("InvalidConfiguration")
<< name_ << " is not configured to handle taus!";
}
virtual void modifyObject(pat::Jet&) const {
throw cms::Exception("InvalidConfiguration")
<< name_ << " is not configured to handle jets!";
}

const std::string& name() const { return name_; }

private:
const std::string name_;
};

#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
#include "FWCore/PluginManager/interface/PluginFactory.h"
typedef edmplugin::PluginFactory< ModifyObjectValueBase* (const edm::ParameterSet&) > ModifyObjectValueFactory;
#endif

#endif
4 changes: 4 additions & 0 deletions CommonTools/CandAlgos/src/ModifyObjectValueBase.cc
@@ -0,0 +1,4 @@
#include "CommonTools/CandAlgos/interface/ModifyObjectValueBase.h"

EDM_REGISTER_PLUGINFACTORY(ModifyObjectValueFactory,"ModifyObjectValueFactory");

@@ -1,3 +1,4 @@
EventInterpretation = {
'top' : 'CommonTools.ParticleFlow.EITopPAG_cff'
'top' : 'CommonTools.ParticleFlow.EITopPAG_cff',
'MiniAODfromMiniAOD' : 'PhysicsTools.PatAlgos.slimming.MiniAODfromMiniAOD_cff'
}
3 changes: 3 additions & 0 deletions DataFormats/EgammaCandidates/interface/Photon.h
Expand Up @@ -164,6 +164,9 @@ namespace reco {

{}
} ;
const ShowerShape& showerShapeVariables() const { return showerShapeBlock_; }
const ShowerShape& full5x5_showerShapeVariables() const { return full5x5_showerShapeBlock_; }

void setShowerShapeVariables ( const ShowerShape& a ) { showerShapeBlock_ = a ;}
void full5x5_setShowerShapeVariables ( const ShowerShape& a ) { full5x5_showerShapeBlock_ = a ;}

Expand Down
57 changes: 36 additions & 21 deletions DataFormats/FWLite/python/__init__.py
Expand Up @@ -222,13 +222,18 @@ def getByLabel (self, *args):
# handle is always the last argument
argsList = list (args)
handle = argsList.pop()
if len(argsList)==1 and \
( isinstance (argsList[0], tuple) or
isinstance (argsList[0], list) ) :
if len (argsList) > 3:
raise RuntimeError, "getByLabel Error: label tuple has too " \
"many arguments '%s'" % argsList[0]
argsList = list(argsList[0])
if len(argsList)==1 :
if( isinstance (argsList[0], tuple) or
isinstance (argsList[0], list) ) :
if len (argsList[0]) > 3:
raise RuntimeError, "getByLabel Error: label tuple has too " \
"many arguments '%s'" % argsList[0]
argsList = list(*argsList[0])
if( type(argsList[0]) is str and ":" in argsList[0] ):
if argsList[0].count(":") > 3:
raise RuntimeError, "getByLabel Error: label tuple has too " \
"many arguments '%s'" % argsList[0].split(":")
argsList = argsList[0].split(":")
while len(argsList) < 3:
argsList.append ('')
(moduleLabel, productInstanceLabel, processLabel) = argsList
Expand Down Expand Up @@ -375,13 +380,18 @@ def getByLabel (self, *args):
# handle is always the last argument
argsList = list (args)
handle = argsList.pop()
if len(argsList)==1 and \
( isinstance (argsList[0], tuple) or
isinstance (argsList[0], list) ) :
if len (argsList) > 3:
raise RuntimeError, "getByLabel Error: label tuple has too " \
"many arguments '%s'" % argsList[0]
argsList = list(argsList[0])
if len(argsList)==1 :
if( isinstance (argsList[0], tuple) or
isinstance (argsList[0], list) ) :
if len (argsList[0]) > 3:
raise RuntimeError, "getByLabel Error: label tuple has too " \
"many arguments '%s'" % argsList[0]
argsList = list(*argsList[0])
if( type(argsList[0]) is str and ":" in argsList[0] ):
if argsList[0].count(":") > 3:
raise RuntimeError, "getByLabel Error: label tuple has too " \
"many arguments '%s'" % argsList[0].split(":")
argsList = argsList[0].split(":")
while len(argsList) < 3:
argsList.append ('')
(moduleLabel, productInstanceLabel, processLabel) = argsList
Expand Down Expand Up @@ -546,13 +556,18 @@ def getByLabel (self, *args):
# handle is always the last argument
argsList = list (args)
handle = argsList.pop()
if len(argsList)==1 and \
( isinstance (argsList[0], tuple) or
isinstance (argsList[0], list) ) :
if len (argsList) > 3:
raise RuntimeError, "getByLabel Error: label tuple has too " \
"many arguments '%s'" % argsList[0]
argsList = list(argsList[0])
if len(argsList)==1 :
if( isinstance (argsList[0], tuple) or
isinstance (argsList[0], list) ) :
if len (argsList[0]) > 3:
raise RuntimeError, "getByLabel Error: label tuple has too " \
"many arguments '%s'" % argsList[0]
argsList = list(*argsList[0])
if( type(argsList[0]) is str and ":" in argsList[0] ):
if argsList[0].count(":") > 3:
raise RuntimeError, "getByLabel Error: label tuple has too " \
"many arguments '%s'" % argsList[0].split(":")
argsList = argsList[0].split(":")
while len(argsList) < 3:
argsList.append ('')
(moduleLabel, productInstanceLabel, processLabel) = argsList
Expand Down
112 changes: 112 additions & 0 deletions DataFormats/PatCandidates/interface/VIDCutFlowResult.h
@@ -0,0 +1,112 @@
#ifndef __DataFormats_PatCandidates_VIDResult_H__
#define __DataFormats_PatCandidates_VIDResult_H__

#include <map>
#include <vector>
#include <string>

/*********
*
* Class: vid::CutFlowResult
* Author: L. Gray (FNAL)
*
* A synthesis of the output of a VID selector into an easily
* manipulated class, such that cuts can be masked and sidebands
* created without major intervention on the part of the person
* doing analysis.
*
* The class is self-describing and the original cut-names, the
* values cut upon, the result of each cut used, and final cutflow
* decision can be accessed with this class. Using this information
* the cut flow can be masked interactively by the user, allowing
* for a large degree of flexibility at the analysis level.
*
*********/

namespace vid {
class CutFlowResult {
template<class T> friend class VersionedSelector;
public:

CutFlowResult() : bitmap_(0) {}
CutFlowResult(const std::string& name,
const std::string& hash,
const std::map<std::string,unsigned>& n2idx,
const std::vector<double>& values,
unsigned bitmap,
unsigned mask = 0);

// get the original name of this cutflow
const std::string& cutFlowName() const { return name_; }
// get the md5 hash for this cutflow
const std::string& cutFlowHash() const { return hash_; }
// did this cutflow (in its current state!) pass?
bool cutFlowPassed() const {
const unsigned all_pass = (1 << indices_.size()) - 1;
return (all_pass&bitmap_) == all_pass;
}
// how many cuts in this cutflow?
size_t cutFlowSize() const { return indices_.size(); }

// get the name of a cut in the cutflow
// indexed by order it was executed
const std::string& getNameAtIndex(const unsigned idx) const;

// get the individual cut result (pass/fail) either by name or by index
bool getCutResultByIndex(const unsigned idx) const;
bool getCutResultByName(const std::string& name) const;

// return true if the cut as index/name is masked out
bool isCutMasked(const unsigned idx) const;
bool isCutMasked(const std::string& name) const;

// get the value of variable that was cut on, either by name or by index
double getValueCutUpon(const unsigned idx) const;
double getValueCutUpon(const std::string& name) const;

// create a new copy of this cutflow masking out the listed cuts
// can be done either by name or by index
CutFlowResult getCutFlowResultMasking(const unsigned idx) const;
CutFlowResult getCutFlowResultMasking(const std::string& name) const;

CutFlowResult getCutFlowResultMasking(const std::vector<unsigned>& idxs) const;
CutFlowResult getCutFlowResultMasking(const std::vector<std::string>& names) const;

private:
std::string name_, hash_;
unsigned bitmap_, mask_;
std::vector<double> values_;
std::vector<std::string> names_;
std::vector<unsigned> indices_;

CutFlowResult(const std::string& name,
const std::string& hash,
const std::vector<std::string>& names,
const std::vector<unsigned>& indices,
const std::vector<double>& values,
unsigned bitmap,
unsigned mask) :
name_(name),
hash_(hash),
bitmap_(bitmap),
mask_(mask),
values_(values),
names_(names),
indices_(indices) {}


bool getMaskBit(const unsigned idx) const {
return (bool)(0x1&(mask_>>idx));
}

bool getCutBit(const unsigned idx) const {
return (bool)(0x1&(bitmap_>>idx));
}

bool getCutValue(const unsigned idx) const {
return values_[idx];
}
};
}

#endif

0 comments on commit 7fe6c72

Please sign in to comment.