-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
CalibratedPhotonProducersRun2.cc
67 lines (50 loc) · 2.24 KB
/
CalibratedPhotonProducersRun2.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef CalibratedPhotonProducer_h
#define CalibratedPhotonProducer_h
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/EgammaCandidates/interface/Photon.h"
#include "DataFormats/PatCandidates/interface/Photon.h"
#include "EgammaAnalysis/ElectronTools/interface/PhotonEnergyCalibratorRun2.h"
#include <vector>
template<typename T>
class CalibratedPhotonProducerRun2T: public edm::stream::EDProducer<> {
public:
explicit CalibratedPhotonProducerRun2T( const edm::ParameterSet & ) ;
virtual ~CalibratedPhotonProducerRun2T();
virtual void produce( edm::Event &, const edm::EventSetup & ) override ;
private:
edm::EDGetTokenT<edm::View<T> > thePhotonToken;
PhotonEnergyCalibratorRun2 theEnCorrectorRun2;
};
template<typename T>
CalibratedPhotonProducerRun2T<T>::CalibratedPhotonProducerRun2T( const edm::ParameterSet & conf ) :
thePhotonToken(consumes<edm::View<T> >(conf.getParameter<edm::InputTag>("photons"))),
theEnCorrectorRun2(conf.getParameter<bool>("isMC"), conf.getParameter<bool>("isSynchronization"), conf.getParameter<std::string >("correctionFile")) {
produces<std::vector<T> >();
}
template<typename T>
CalibratedPhotonProducerRun2T<T>::~CalibratedPhotonProducerRun2T()
{}
template<typename T>
void
CalibratedPhotonProducerRun2T<T>::produce( edm::Event & iEvent, const edm::EventSetup & iSetup ) {
edm::Handle<edm::View<T> > in;
iEvent.getByToken(thePhotonToken, in);
std::unique_ptr<std::vector<T> > out(new std::vector<T>());
out->reserve(in->size());
for (const T &ele : *in) {
out->push_back(ele);
theEnCorrectorRun2.calibrate(out->back(), iEvent.id().run(), iEvent.streamID());
}
iEvent.put(std::move(out));
}
typedef CalibratedPhotonProducerRun2T<reco::Photon> CalibratedPhotonProducerRun2;
typedef CalibratedPhotonProducerRun2T<pat::Photon> CalibratedPatPhotonProducerRun2;
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(CalibratedPhotonProducerRun2);
DEFINE_FWK_MODULE(CalibratedPatPhotonProducerRun2);
#endif