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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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_
 
std::string method_
 
EGammaMvaEleEstimatormvaID_
 
std::vector< std::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
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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::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 24 of file ElectronPATIdMVAProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 56 of file ElectronPATIdMVAProducer.cc.

References electronToken_, eventrhoToken_, edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), compare_using_db::ifile, EGammaMvaEleEstimator::kTrigNoIP, method_, mvaID_, mvaWeightFiles_, AlCaHLTBitMon_QueryRunRegistry::string, and verbose_.

56  {
57  verbose_ = iConfig.getUntrackedParameter<bool>("verbose", false);
58  electronToken_ = consumes<pat::ElectronCollection>(iConfig.getParameter<edm::InputTag>("electronTag"));
59  method_ = iConfig.getParameter<std::string>("method");
60  std::vector<std::string> fpMvaWeightFiles = iConfig.getParameter<std::vector<std::string> >("mvaWeightFile");
61  eventrhoToken_ = consumes<double>(iConfig.getParameter<edm::InputTag>("Rho"));
62 
63  produces<edm::ValueMap<float> >();
64 
66 
68 
69 
71 
72 
73 
74  bool manualCat_ = true;
75 
76  std::string path_mvaWeightFileEleID;
77  for(unsigned ifile=0 ; ifile < fpMvaWeightFiles.size() ; ++ifile) {
78  path_mvaWeightFileEleID = edm::FileInPath ( fpMvaWeightFiles[ifile].c_str() ).fullPath();
79  mvaWeightFiles_.push_back(path_mvaWeightFileEleID);
80  }
81 
82  mvaID_->initialize(method_, type_, manualCat_, mvaWeightFiles_);
83 
84 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::string > mvaWeightFiles_
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:184
ElectronPATIdMVAProducer::~ElectronPATIdMVAProducer ( )
virtual

Definition at line 87 of file ElectronPATIdMVAProducer.cc.

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

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 101 of file ElectronPATIdMVAProducer.cc.

References _Rho, electronToken_, eventrhoToken_, edm::helper::Filler< Map >::fill(), edm::Event::getByToken(), edm::helper::Filler< Map >::insert(), mvaID_, EGammaMvaEleEstimator::mvaValue(), GenerateHcalLaserBadRunList::out, edm::Handle< T >::product(), edm::Event::put(), makeHLTPrescaleTable::values, and verbose_.

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

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

Member Data Documentation

double ElectronPATIdMVAProducer::_Rho
private

Definition at line 35 of file ElectronPATIdMVAProducer.cc.

Referenced by produce().

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

Definition at line 34 of file ElectronPATIdMVAProducer.cc.

Referenced by ElectronPATIdMVAProducer(), and produce().

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

Definition at line 36 of file ElectronPATIdMVAProducer.cc.

Referenced by ElectronPATIdMVAProducer(), and produce().

std::string ElectronPATIdMVAProducer::method_
private

Definition at line 37 of file ElectronPATIdMVAProducer.cc.

Referenced by ElectronPATIdMVAProducer().

EGammaMvaEleEstimator* ElectronPATIdMVAProducer::mvaID_
private

Definition at line 41 of file ElectronPATIdMVAProducer.cc.

Referenced by ElectronPATIdMVAProducer(), and produce().

std::vector<std::string> ElectronPATIdMVAProducer::mvaWeightFiles_
private

Definition at line 38 of file ElectronPATIdMVAProducer.cc.

Referenced by ElectronPATIdMVAProducer().

bool ElectronPATIdMVAProducer::verbose_
private

Definition at line 33 of file ElectronPATIdMVAProducer.cc.

Referenced by ElectronPATIdMVAProducer(), and produce().