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 Member Functions | Private Attributes
ElectronPATIdMVAProducer Class Reference
Inheritance diagram for ElectronPATIdMVAProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ElectronPATIdMVAProducer (const edm::ParameterSet &)
 
virtual ~ElectronPATIdMVAProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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 Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

double _Rho
 
edm::EDGetTokenT
< pat::ElectronCollection
electronToken_
 
edm::EDGetTokenT< double > eventrhoToken_
 
string method_
 
EGammaMvaEleEstimatormvaID_
 
vector< string > mvaWeightFiles_
 
bool verbose_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 26 of file ElectronPATIdMVAProducer.cc.

Constructor & Destructor Documentation

ElectronPATIdMVAProducer::ElectronPATIdMVAProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 58 of file ElectronPATIdMVAProducer.cc.

References edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), compare_using_db::ifile, and EGammaMvaEleEstimator::kTrigNoIP.

58  {
59  verbose_ = iConfig.getUntrackedParameter<bool>("verbose", false);
60  electronToken_ = consumes<pat::ElectronCollection>(iConfig.getParameter<edm::InputTag>("electronTag"));
61  method_ = iConfig.getParameter<string>("method");
62  std::vector<string> fpMvaWeightFiles = iConfig.getParameter<std::vector<std::string> >("mvaWeightFile");
63  eventrhoToken_ = consumes<double>(iConfig.getParameter<edm::InputTag>("Rho"));
64 
65  produces<edm::ValueMap<float> >();
66 
68 
70 
71 
73 
74 
75 
76  bool manualCat_ = true;
77 
78  string path_mvaWeightFileEleID;
79  for(unsigned ifile=0 ; ifile < fpMvaWeightFiles.size() ; ++ifile) {
80  path_mvaWeightFileEleID = edm::FileInPath ( fpMvaWeightFiles[ifile].c_str() ).fullPath();
81  mvaWeightFiles_.push_back(path_mvaWeightFileEleID);
82  }
83 
84  mvaID_->initialize(method_, type_, manualCat_, mvaWeightFiles_);
85 
86 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void initialize(std::string methodName, std::string weightsfile, EGammaMvaEleEstimator::MVAType type)
edm::EDGetTokenT< pat::ElectronCollection > electronToken_
EGammaMvaEleEstimator * mvaID_
edm::EDGetTokenT< double > eventrhoToken_
std::string fullPath() const
Definition: FileInPath.cc:171
ElectronPATIdMVAProducer::~ElectronPATIdMVAProducer ( )
virtual

Definition at line 89 of file ElectronPATIdMVAProducer.cc.

90 {
91 
92  // do anything here that needs to be done at desctruction time
93  // (e.g. close files, deallocate resources etc.)
94 
95 }

Member Function Documentation

void ElectronPATIdMVAProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 103 of file ElectronPATIdMVAProducer.cc.

References edm::helper::Filler< Map >::fill(), edm::Event::getByToken(), edm::helper::Filler< Map >::insert(), dbtoconf::out, edm::Event::put(), and makeHLTPrescaleTable::values.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

103  {
104  using namespace edm;
105 
106  std::auto_ptr<edm::ValueMap<float> > out(new edm::ValueMap<float>() );
107 
108 
109 
110 
111 
112 
113 
114  Handle<pat::ElectronCollection> egCollection;
115  iEvent.getByToken(electronToken_,egCollection);
116  const pat::ElectronCollection egCandidates = (*egCollection.product());
117 
118  _Rho=0;
119  edm::Handle<double> rhoPtr;
120  //const edm::InputTag eventrhoToken_("kt6PFJets", "rho");
121  iEvent.getByToken(eventrhoToken_,rhoPtr);
122  _Rho=*rhoPtr;
123 
124  std::vector<float> values;
125  values.reserve(egCollection->size());
126 
127  for ( pat::ElectronCollection::const_iterator egIter = egCandidates.begin(); egIter != egCandidates.end(); ++egIter) {
128 
129  double mvaVal = -999999;
130 
131 
132 
133 
134  mvaVal = mvaID_->mvaValue( *egIter, _Rho, verbose_);
135 
136 
137  values.push_back( mvaVal );
138  }
139 
141  filler.insert(egCollection, values.begin(), values.end() );
142  filler.fill();
143 
144  iEvent.put(out);
145 
146 
147 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
std::vector< Electron > ElectronCollection
Definition: Electron.h:37
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
Double_t mvaValue(const reco::GsfElectron &ele, const reco::Vertex &vertex, const TransientTrackBuilder &transientTrackBuilder, EcalClusterLazyTools myEcalCluster, bool printDebug=kFALSE)
edm::EDGetTokenT< pat::ElectronCollection > electronToken_
tuple out
Definition: dbtoconf.py:99
EGammaMvaEleEstimator * mvaID_
edm::EDGetTokenT< double > eventrhoToken_

Member Data Documentation

double ElectronPATIdMVAProducer::_Rho
private

Definition at line 37 of file ElectronPATIdMVAProducer.cc.

edm::EDGetTokenT<pat::ElectronCollection> ElectronPATIdMVAProducer::electronToken_
private

Definition at line 36 of file ElectronPATIdMVAProducer.cc.

edm::EDGetTokenT<double> ElectronPATIdMVAProducer::eventrhoToken_
private

Definition at line 38 of file ElectronPATIdMVAProducer.cc.

string ElectronPATIdMVAProducer::method_
private

Definition at line 39 of file ElectronPATIdMVAProducer.cc.

EGammaMvaEleEstimator* ElectronPATIdMVAProducer::mvaID_
private

Definition at line 43 of file ElectronPATIdMVAProducer.cc.

vector<string> ElectronPATIdMVAProducer::mvaWeightFiles_
private

Definition at line 40 of file ElectronPATIdMVAProducer.cc.

bool ElectronPATIdMVAProducer::verbose_
private

Definition at line 35 of file ElectronPATIdMVAProducer.cc.