CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTHcalPFClusterIsolationProducer.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <vector>
3 #include <memory>
4 
6 
7 // Framework
16 
19 
20 template<typename T1>
22  pfClusterProducerHCAL_ ( consumes<reco::PFClusterCollection>(config.getParameter<edm::InputTag>("pfClusterProducerHCAL"))),
23  rhoProducer_ ( consumes<double>(config.getParameter<edm::InputTag>("rhoProducer"))),
24  pfClusterProducerHFEM_ ( consumes<reco::PFClusterCollection>(config.getParameter<edm::InputTag>("pfClusterProducerHFEM"))),
25  pfClusterProducerHFHAD_ ( consumes<reco::PFClusterCollection>(config.getParameter<edm::InputTag>("pfClusterProducerHFHAD"))),
26  useHF_ ( config.getParameter<bool>("useHF")),
27  drMax_ ( config.getParameter<double>("drMax")),
28  drVetoBarrel_ ( config.getParameter<double>("drVetoBarrel")),
29  drVetoEndcap_ ( config.getParameter<double>("drVetoEndcap")),
30  etaStripBarrel_ ( config.getParameter<double>("etaStripBarrel")),
31  etaStripEndcap_ ( config.getParameter<double>("etaStripEndcap")),
32  energyBarrel_ ( config.getParameter<double>("energyBarrel")),
33  energyEndcap_ ( config.getParameter<double>("energyEndcap")),
34  doRhoCorrection_ ( config.getParameter<bool>("doRhoCorrection")),
35  rhoMax_ ( config.getParameter<double>("rhoMax")),
36  rhoScale_ ( config.getParameter<double>("rhoScale")),
37  effectiveAreaBarrel_ ( config.getParameter<double>("effectiveAreaBarrel")),
38  effectiveAreaEndcap_ ( config.getParameter<double>("effectiveAreaEndcap")),
39  useEt_ ( config.getParameter<bool>("useEt")) {
40 
41  std::string recoCandidateProducerName = "recoCandidateProducer";
42  if ((typeid(HLTHcalPFClusterIsolationProducer<T1>) == typeid(HLTHcalPFClusterIsolationProducer<reco::RecoEcalCandidate>))) recoCandidateProducerName = "recoEcalCandidateProducer";
43  recoCandidateProducer_ = consumes<T1Collection>(config.getParameter<edm::InputTag>(recoCandidateProducerName));
44 
45  produces <T1IsolationMap >();
46 }
47 
48 template<typename T1>
50 {}
51 
52 template<typename T1>
54 
55  std::string recoCandidateProducerName = "recoCandidateProducer";
56  if ((typeid(HLTHcalPFClusterIsolationProducer<T1>) == typeid(HLTHcalPFClusterIsolationProducer<reco::RecoEcalCandidate>))) recoCandidateProducerName = "recoEcalCandidateProducer";
57 
59  desc.add<edm::InputTag>(recoCandidateProducerName, edm::InputTag("hltL1SeededRecoEcalCandidatePF"));
60  desc.add<edm::InputTag>("pfClusterProducerHCAL", edm::InputTag("hltParticleFlowClusterHCAL"));
61  desc.ifValue(edm::ParameterDescription<bool>("useHF", false, true),
62  true >> (edm::ParameterDescription<edm::InputTag>("pfClusterProducerHFEM", edm::InputTag("hltParticleFlowClusterHFEM"), true) and
63  edm::ParameterDescription<edm::InputTag>("pfClusterProducerHFHAD", edm::InputTag("hltParticleFlowClusterHFHAD"), true)) or
64  false >> (edm::ParameterDescription<edm::InputTag>("pfClusterProducerHFEM", edm::InputTag(""), true) and
65  edm::ParameterDescription<edm::InputTag>("pfClusterProducerHFHAD", edm::InputTag(""), true)));
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);
79  desc.add<bool>("useEt", true);
81 }
82 
83 template<typename T1>
85 
86  edm::Handle<double> rhoHandle;
87  double rho = 0.0;
88  if (doRhoCorrection_) {
89  iEvent.getByToken(rhoProducer_, rhoHandle);
90  rho = *(rhoHandle.product());
91  }
92 
93  if (rho > rhoMax_)
94  rho = rhoMax_;
95 
96  rho = rho*rhoScale_;
97 
98  edm::Handle<T1Collection> recoCandHandle;
99 
100  std::vector<edm::Handle<reco::PFClusterCollection>> clusterHandles;
101  edm::Handle<reco::PFClusterCollection> clusterHcalHandle;
102  edm::Handle<reco::PFClusterCollection> clusterHfemHandle;
103  edm::Handle<reco::PFClusterCollection> clusterHfhadHandle;
104 
105  iEvent.getByToken(recoCandidateProducer_,recoCandHandle);
106  iEvent.getByToken(pfClusterProducerHCAL_, clusterHcalHandle);
107  //const reco::PFClusterCollection* forIsolationHcal = clusterHcalHandle.product();
108  clusterHandles.push_back(clusterHcalHandle);
109 
110  if (useHF_) {
111  iEvent.getByToken(pfClusterProducerHFEM_, clusterHfemHandle);
112  clusterHandles.push_back(clusterHfemHandle);
113  iEvent.getByToken(pfClusterProducerHFHAD_, clusterHfhadHandle);
114  clusterHandles.push_back(clusterHfhadHandle);
115  }
116 
117  T1IsolationMap recoCandMap;
118  HcalPFClusterIsolation<T1> isoAlgo(drMax_, drVetoBarrel_, drVetoEndcap_, etaStripBarrel_, etaStripEndcap_, energyBarrel_, energyEndcap_, useEt_);
119 
120  for (unsigned int iReco = 0; iReco < recoCandHandle->size(); iReco++) {
121  T1Ref candRef(recoCandHandle, iReco);
122 
123  float sum = isoAlgo.getSum(candRef, clusterHandles);
124 
125  if (doRhoCorrection_) {
126  if (fabs(candRef->eta()) < 1.479)
127  sum = sum - rho*effectiveAreaBarrel_;
128  else
129  sum = sum - rho*effectiveAreaEndcap_;
130  }
131 
132  recoCandMap.insert(candRef, sum);
133  }
134 
135  std::auto_ptr<T1IsolationMap> mapForEvent(new T1IsolationMap(recoCandMap));
136  iEvent.put(mapForEvent);
137 }
138 
141 
T getParameter(std::string const &) const
std::string defaultModuleLabel()
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
void produce(edm::StreamID sid, edm::Event &, const edm::EventSetup &) const override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
Definition: DDAxes.h:10
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
HLTHcalPFClusterIsolationProducer< reco::RecoEcalCandidate > EgammaHLTHcalPFClusterIsolationProducer
ParameterDescriptionBase * add(U const &iLabel, T const &value)
double getSum(const T1Ref candRef, const std::vector< edm::Handle< reco::PFClusterCollection >> &clusterHandles)
edm::EDGetTokenT< T1Collection > recoCandidateProducer_
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::auto_ptr< ParameterDescriptionCases< T > > cases)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T const * product() const
Definition: Handle.h:81
void insert(const key_type &k, const data_type &v)
insert an association
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
Definition: PFClusterFwd.h:9
HLTHcalPFClusterIsolationProducer(const edm::ParameterSet &)
HLTHcalPFClusterIsolationProducer< reco::RecoChargedCandidate > MuonHLTHcalPFClusterIsolationProducer