CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTEcalPFClusterIsolationProducer.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <vector>
3 #include <memory>
4 
6 
7 // Framework
16 
19 
22 
24 
27 
28 template<typename T1>
30  pfClusterProducer_ (consumes<reco::PFClusterCollection>(config.getParameter<edm::InputTag>("pfClusterProducer"))),
31  rhoProducer_ (consumes<double>(config.getParameter<edm::InputTag>("rhoProducer"))),
32  drMax_ (config.getParameter<double>("drMax")),
33  drVetoBarrel_ (config.getParameter<double>("drVetoBarrel")),
34  drVetoEndcap_ (config.getParameter<double>("drVetoEndcap")),
35  etaStripBarrel_ (config.getParameter<double>("etaStripBarrel")),
36  etaStripEndcap_ (config.getParameter<double>("etaStripEndcap")),
37  energyBarrel_ (config.getParameter<double>("energyBarrel")),
38  energyEndcap_ (config.getParameter<double>("energyEndcap")),
39  doRhoCorrection_ (config.getParameter<bool>("doRhoCorrection")),
40  rhoMax_ (config.getParameter<double>("rhoMax")),
41  rhoScale_ (config.getParameter<double>("rhoScale")),
42  effectiveAreaBarrel_(config.getParameter<double>("effectiveAreaBarrel")),
43  effectiveAreaEndcap_(config.getParameter<double>("effectiveAreaEndcap")) {
44 
45  std::string recoCandidateProducerName = "recoCandidateProducer";
46  if ((typeid(HLTEcalPFClusterIsolationProducer<T1>) == typeid(HLTEcalPFClusterIsolationProducer<reco::RecoEcalCandidate>))) recoCandidateProducerName = "recoEcalCandidateProducer";
47 
48  recoCandidateProducer_ = consumes<T1Collection>(config.getParameter<edm::InputTag>(recoCandidateProducerName));
49  produces <T1IsolationMap>();
50 
51 }
52 
53 template<typename T1>
55 {}
56 
57 template<typename T1>
59 
60  std::string recoCandidateProducerName = "recoCandidateProducer";
61  if ((typeid(HLTEcalPFClusterIsolationProducer<T1>) == typeid(HLTEcalPFClusterIsolationProducer<reco::RecoEcalCandidate>))) recoCandidateProducerName = "recoEcalCandidateProducer";
62 
64  desc.add<edm::InputTag>(recoCandidateProducerName, edm::InputTag("hltL1SeededRecoEcalCandidatePF"));
65  desc.add<edm::InputTag>("pfClusterProducer", edm::InputTag("hltParticleFlowClusterECAL"));
66  desc.add<edm::InputTag>("rhoProducer", edm::InputTag("fixedGridRhoFastjetAllCalo"));
67  desc.add<bool>("doRhoCorrection", false);
68  desc.add<double>("rhoMax", 9.9999999E7);
69  desc.add<double>("rhoScale", 1.0);
70  desc.add<double>("effectiveAreaBarrel", 0.101);
71  desc.add<double>("effectiveAreaEndcap", 0.046);
72  desc.add<double>("drMax", 0.3);
73  desc.add<double>("drVetoBarrel", 0.0);
74  desc.add<double>("drVetoEndcap", 0.0);
75  desc.add<double>("etaStripBarrel", 0.0);
76  desc.add<double>("etaStripEndcap", 0.0);
77  desc.add<double>("energyBarrel", 0.0);
78  desc.add<double>("energyEndcap", 0.0);
80 }
81 
82 template<typename T1>
84 
85  edm::Handle<double> rhoHandle;
86  double rho = 0.0;
87  if (doRhoCorrection_) {
88  iEvent.getByToken(rhoProducer_, rhoHandle);
89  rho = *(rhoHandle.product());
90  }
91 
92  if (rho > rhoMax_)
93  rho = rhoMax_;
94 
95  rho = rho*rhoScale_;
96 
97  edm::Handle<T1Collection> recoCandHandle;
99 
100  iEvent.getByToken(recoCandidateProducer_,recoCandHandle);
101  iEvent.getByToken(pfClusterProducer_, clusterHandle);
102 
103  EcalPFClusterIsolation<T1> isoAlgo(drMax_, drVetoBarrel_, drVetoEndcap_, etaStripBarrel_, etaStripEndcap_, energyBarrel_, energyEndcap_);
104  T1IsolationMap recoCandMap(recoCandHandle);
105 
106  for (unsigned int iReco = 0; iReco < recoCandHandle->size(); iReco++) {
107  T1Ref candRef(recoCandHandle, iReco);
108 
109  float sum = isoAlgo.getSum(candRef, clusterHandle);
110 
111  if (doRhoCorrection_) {
112  if (fabs(candRef->eta()) < 1.479)
113  sum = sum - rho*effectiveAreaBarrel_;
114  else
115  sum = sum - rho*effectiveAreaEndcap_;
116  }
117 
118  recoCandMap.insert(candRef, sum);
119  }
120 
121  std::auto_ptr<T1IsolationMap> mapForEvent(new T1IsolationMap(recoCandMap));
122  iEvent.put(mapForEvent);
123 }
124 
127 
T getParameter(std::string const &) const
std::string defaultModuleLabel()
edm::EDGetTokenT< T1Collection > recoCandidateProducer_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int iEvent
Definition: GenABIO.cc:230
void produce(edm::Event &, const edm::EventSetup &) override
HLTEcalPFClusterIsolationProducer< reco::RecoChargedCandidate > MuonHLTEcalPFClusterIsolationProducer
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HLTEcalPFClusterIsolationProducer(const edm::ParameterSet &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
T const * product() const
Definition: Handle.h:81
void insert(const key_type &k, const data_type &v)
insert an association
double getSum(T1Ref, edm::Handle< std::vector< reco::PFCluster > >)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
Definition: PFClusterFwd.h:9
HLTEcalPFClusterIsolationProducer< reco::RecoEcalCandidate > EgammaHLTEcalPFClusterIsolationProducer