CMS 3D CMS Logo

PatElectronEAIsoCorrectionProducer.cc
Go to the documentation of this file.
5 
8 
9 
11 {
12  public:
13  explicit PatElectronEAIsoCorrectionProducer( const edm::ParameterSet& iConfig );
15  void produce( edm::Event& iEvent, const edm::EventSetup& iSetup ) override;
16 
17  private:
20 };
21 
23 : patElectronsToken_( consumes< pat::ElectronCollection >( iConfig.getParameter< edm::InputTag >( "patElectrons" ) ) )
24 , eaIsolatorToken_( consumes< edm::ValueMap< double > >( iConfig.getParameter< edm::InputTag >( "eaIsolator" ) ) )
25 {
26  produces< pat::ElectronCollection >();
27 }
28 
30 {
32  iEvent.getByToken( patElectronsToken_, patElectrons );
34  iEvent.getByToken( eaIsolatorToken_, eaIsolator );
35 
36  std::unique_ptr< pat::ElectronCollection > updatedPatElectrons( new pat::ElectronCollection );
37 
38  for ( size_t iElectron = 0; iElectron < patElectrons->size(); ++iElectron ) {
39  pat::Electron* updatedPatElectron = patElectrons->at( iElectron ).clone();
40  pat::ElectronRef electronRef( patElectrons, iElectron );
41  updatedPatElectron->setIsolation( pat::User1Iso, ( *eaIsolator )[electronRef] ); // FIXME: hard-coded isolation key
42  updatedPatElectrons->push_back( *updatedPatElectron );
43  }
44 
45  iEvent.put(std::move(updatedPatElectrons));
46 }
47 
48 
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
void setIsolation(IsolationKeys key, float value)
Definition: Lepton.h:99
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
PatElectronEAIsoCorrectionProducer(const edm::ParameterSet &iConfig)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: HeavyIon.h:7
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< Electron > ElectronCollection
Definition: Electron.h:37
edm::EDGetTokenT< pat::ElectronCollection > patElectronsToken_
edm::EDGetTokenT< edm::ValueMap< double > > eaIsolatorToken_
std::vector< Electron > ElectronCollection
collectin of Electron objects
Definition: ElectronFwd.h:9
Analysis-level electron class.
Definition: Electron.h:52
HLT enums.
def move(src, dest)
Definition: eostools.py:511