CMS 3D CMS Logo

HLTHGCalLayerClusterIsolationProducer.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <vector>
3 #include <memory>
4 
13 
15 
17 
20 
23 
25 
28 
31 
34 
36 
37 template <typename T1>
39  typedef std::vector<T1> T1Collection;
42 
43 public:
45  ~HLTHGCalLayerClusterIsolationProducer() override = default;
46 
47  void produce(edm::Event&, const edm::EventSetup&) override;
48  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
49 
50 private:
54 
55  const double drMax_;
56  const double drVetoEM_;
57  const double drVetoHad_;
58  const double minEnergyEM_;
59  const double minEnergyHad_;
60  const double minEtEM_;
61  const double minEtHad_;
62  const bool useEt_;
63  const bool doRhoCorrection_;
64  const double rhoMax_;
65  const double rhoScale_;
66  const std::vector<double> effectiveAreas_;
67 };
68 
69 template <typename T1>
71  : layerClusterProducer_(
72  consumes<reco::CaloClusterCollection>(config.getParameter<edm::InputTag>("layerClusterProducer"))),
73  rhoProducer_(consumes<double>(config.getParameter<edm::InputTag>("rhoProducer"))),
74  drMax_(config.getParameter<double>("drMax")),
75  drVetoEM_(config.getParameter<double>("drVetoEM")),
76  drVetoHad_(config.getParameter<double>("drVetoHad")),
77  minEnergyEM_(config.getParameter<double>("minEnergyEM")),
78  minEnergyHad_(config.getParameter<double>("minEnergyHad")),
79  minEtEM_(config.getParameter<double>("minEtEM")),
80  minEtHad_(config.getParameter<double>("minEtHad")),
81  useEt_(config.getParameter<bool>("useEt")),
82  doRhoCorrection_(config.getParameter<bool>("doRhoCorrection")),
83  rhoMax_(config.getParameter<double>("rhoMax")),
84  rhoScale_(config.getParameter<double>("rhoScale")),
85  effectiveAreas_(config.getParameter<std::vector<double>>("effectiveAreas")) {
86  if (doRhoCorrection_) {
87  if (effectiveAreas_.size() != 2)
88  throw cms::Exception("IncompatibleVects")
89  << "effectiveAreas should have two elements for em and had components. \n";
90  }
91 
92  std::string recoCandidateProducerName = "recoCandidateProducer";
95  recoCandidateProducerName = "recoEcalCandidateProducer";
96 
97  recoCandidateProducer_ = consumes<T1Collection>(config.getParameter<edm::InputTag>(recoCandidateProducerName));
98  produces<T1IsolationMap>();
99  produces<T1IsolationMap>("em");
100  produces<T1IsolationMap>("had");
101 }
102 
103 template <typename T1>
105  std::string recoCandidateProducerName = "recoCandidateProducer";
108  recoCandidateProducerName = "recoEcalCandidateProducer";
109 
111  desc.add<edm::InputTag>(recoCandidateProducerName, edm::InputTag("hltL1SeededRecoEcalCandidatePF"));
112  desc.add<edm::InputTag>("layerClusterProducer", edm::InputTag("hltParticleFlowClusterECAL"));
113  desc.add<edm::InputTag>("rhoProducer", edm::InputTag("fixedGridRhoFastjetAllCalo"));
114  desc.add<bool>("doRhoCorrection", false);
115  desc.add<bool>("useEt", false);
116  desc.add<double>("rhoMax", 9.9999999E7);
117  desc.add<double>("rhoScale", 1.0);
118  desc.add<double>("drMax", 0.3);
119  desc.add<double>("drVetoEM", 0.0);
120  desc.add<double>("drVetoHad", 0.0);
121  desc.add<double>("minEnergyEM", 0.0);
122  desc.add<double>("minEnergyHad", 0.0);
123  desc.add<double>("minEtEM", 0.0);
124  desc.add<double>("minEtHad", 0.0);
125  desc.add<std::vector<double>>("effectiveAreas", {0.0, 0.0}); // for em and had components
127 }
128 
129 template <typename T1>
131  edm::Handle<double> rhoHandle;
132  double rho = 0.0;
133  if (doRhoCorrection_) {
134  iEvent.getByToken(rhoProducer_, rhoHandle);
135  rho = *(rhoHandle.product());
136  }
137 
138  rho = std::min(rho, rhoMax_);
139  rho = rho * rhoScale_;
140 
141  edm::Handle<T1Collection> recoCandHandle;
143 
144  iEvent.getByToken(recoCandidateProducer_, recoCandHandle);
145  iEvent.getByToken(layerClusterProducer_, clusterHandle);
146 
147  const std::vector<reco::CaloCluster> layerClusters = *(clusterHandle.product());
148 
149  T1IsolationMap recoCandMap(recoCandHandle);
150  T1IsolationMap recoCandMapEm(recoCandHandle);
151  T1IsolationMap recoCandMapHad(recoCandHandle);
152 
153  for (unsigned int iReco = 0; iReco < recoCandHandle->size(); iReco++) {
154  T1Ref candRef(recoCandHandle, iReco);
155 
156  float sumEm =
157  HGCalClusterTools::emEnergyInCone(candRef->eta(),
158  candRef->phi(),
160  drVetoEM_,
161  drMax_,
162  minEtEM_,
163  minEnergyEM_,
165 
166  float sumHad =
167  HGCalClusterTools::hadEnergyInCone(candRef->eta(),
168  candRef->phi(),
170  drVetoHad_,
171  drMax_,
172  minEtHad_,
173  minEnergyHad_,
175 
176  if (doRhoCorrection_) {
177  sumEm = sumEm - rho * effectiveAreas_.at(0);
178  sumHad = sumHad - rho * effectiveAreas_.at(1);
179  }
180 
181  float sum = sumEm + sumHad;
182 
183  recoCandMap.insert(candRef, sum);
184  recoCandMapEm.insert(candRef, sumEm);
185  recoCandMapHad.insert(candRef, sumHad);
186  }
187 
188  iEvent.put(std::make_unique<T1IsolationMap>(recoCandMap));
189  iEvent.put(std::make_unique<T1IsolationMap>(recoCandMapEm), "em");
190  iEvent.put(std::make_unique<T1IsolationMap>(recoCandMapHad), "had");
191 }
192 
195 
RecoEcalCandidateIsolation.h
defaultModuleLabel.h
ConfigurationDescriptions.h
HLTHGCalLayerClusterIsolationProducer::useEt_
const bool useEt_
Definition: HLTHGCalLayerClusterIsolationProducer.cc:62
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
HLTHGCalLayerClusterIsolationProducer::rhoProducer_
const edm::EDGetTokenT< double > rhoProducer_
Definition: HLTHGCalLayerClusterIsolationProducer.cc:53
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ESHandle.h
HLTHGCalLayerClusterIsolationProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTHGCalLayerClusterIsolationProducer.cc:104
min
T min(T a, T b)
Definition: MathUtil.h:58
edm::EDGetTokenT< T1Collection >
edm
HLT enums.
Definition: AlignableModifier.h:19
HLTHGCalLayerClusterIsolationProducer::drMax_
const double drMax_
Definition: HLTHGCalLayerClusterIsolationProducer.cc:55
ZElectronSkim_cff.rho
rho
Definition: ZElectronSkim_cff.py:38
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89281
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HGCalClusterTools::EType::ET
EDProducer.h
EgammaHLTHGCalLayerClusterIsolationProducer
HLTHGCalLayerClusterIsolationProducer< reco::RecoEcalCandidate > EgammaHLTHGCalLayerClusterIsolationProducer
Definition: HLTHGCalLayerClusterIsolationProducer.cc:193
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
RecoChargedCandidateIsolation.h
HGCalClusterTools.h
HGCalClusterTools::emEnergyInCone
static float emEnergyInCone(const float eta, const float phi, const std::vector< reco::CaloCluster > &layerClusters, const float minDR, const float maxDR, const float minEt, const float minEnergy, const HGCalClusterTools::EType &eType=EType::ENERGY)
Definition: HGCalClusterTools.h:32
HLTHGCalLayerClusterIsolationProducer::drVetoHad_
const double drVetoHad_
Definition: HLTHGCalLayerClusterIsolationProducer.cc:57
edm::Handle< double >
HLTHGCalLayerClusterIsolationProducer::~HLTHGCalLayerClusterIsolationProducer
~HLTHGCalLayerClusterIsolationProducer() override=default
HLTHGCalLayerClusterIsolationProducer::effectiveAreas_
const std::vector< double > effectiveAreas_
Definition: HLTHGCalLayerClusterIsolationProducer.cc:66
edm::Ref
Definition: AssociativeIterator.h:58
HLTHGCalLayerClusterIsolationProducer::drVetoEM_
const double drVetoEM_
Definition: HLTHGCalLayerClusterIsolationProducer.cc:56
config
Definition: config.py:1
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
reco::CaloClusterCollection
std::vector< CaloCluster > CaloClusterCollection
collection of CaloCluster objects
Definition: CaloClusterFwd.h:19
CaloClusterFwd.h
ParameterSetDescription.h
HLTEgPhaseIITestSequence_cff.layerClusters
layerClusters
Definition: HLTEgPhaseIITestSequence_cff.py:2506
HLTHGCalLayerClusterIsolationProducer::HLTHGCalLayerClusterIsolationProducer
HLTHGCalLayerClusterIsolationProducer(const edm::ParameterSet &)
Definition: HLTHGCalLayerClusterIsolationProducer.cc:70
HLTHGCalLayerClusterIsolationProducer::doRhoCorrection_
const bool doRhoCorrection_
Definition: HLTHGCalLayerClusterIsolationProducer.cc:63
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLTHGCalLayerClusterIsolationProducer::T1Ref
edm::Ref< T1Collection > T1Ref
Definition: HLTHGCalLayerClusterIsolationProducer.cc:40
edm::ParameterSet
Definition: ParameterSet.h:47
defaultModuleLabel
std::string defaultModuleLabel()
Definition: defaultModuleLabel.h:16
HLTHGCalLayerClusterIsolationProducer
Definition: HLTHGCalLayerClusterIsolationProducer.cc:38
Event.h
deltaR.h
edm::AssociationMap
Definition: AssociationMap.h:48
HLTHGCalLayerClusterIsolationProducer::minEtHad_
const double minEtHad_
Definition: HLTHGCalLayerClusterIsolationProducer.cc:61
HLTHGCalLayerClusterIsolationProducer::T1IsolationMap
edm::AssociationMap< edm::OneToValue< std::vector< T1 >, float > > T1IsolationMap
Definition: HLTHGCalLayerClusterIsolationProducer.cc:41
iEvent
int iEvent
Definition: GenABIO.cc:224
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:58
HLTHGCalLayerClusterIsolationProducer::minEnergyHad_
const double minEnergyHad_
Definition: HLTHGCalLayerClusterIsolationProducer.cc:59
HLTHGCalLayerClusterIsolationProducer::recoCandidateProducer_
edm::EDGetTokenT< T1Collection > recoCandidateProducer_
Definition: HLTHGCalLayerClusterIsolationProducer.cc:51
HLTHGCalLayerClusterIsolationProducer::layerClusterProducer_
const edm::EDGetTokenT< reco::CaloClusterCollection > layerClusterProducer_
Definition: HLTHGCalLayerClusterIsolationProducer.cc:52
HGCalClusterTools::EType::ENERGY
HLTHGCalLayerClusterIsolationProducer::rhoScale_
const double rhoScale_
Definition: HLTHGCalLayerClusterIsolationProducer.cc:65
edm::AssociationMap::insert
void insert(const key_type &k, const data_type &v)
insert an association
Definition: AssociationMap.h:166
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
HGCalClusterTools::hadEnergyInCone
static float hadEnergyInCone(const float eta, const float phi, const std::vector< reco::CaloCluster > &layerClusters, const float minDR, const float maxDR, const float minEt, const float minEnergy, const HGCalClusterTools::EType &eType=EType::ENERGY)
Definition: HGCalClusterTools.h:21
RecoEcalCandidate.h
RecoChargedCandidate.h
Frameworkfwd.h
EventSetup.h
HLTHGCalLayerClusterIsolationProducer::minEnergyEM_
const double minEnergyEM_
Definition: HLTHGCalLayerClusterIsolationProducer.cc:58
Exception.h
MuonHLTHGCalLayerClusterIsolationProducer
HLTHGCalLayerClusterIsolationProducer< reco::RecoChargedCandidate > MuonHLTHGCalLayerClusterIsolationProducer
Definition: HLTHGCalLayerClusterIsolationProducer.cc:194
cms::Exception
Definition: Exception.h:70
ParameterSet.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
HLTHGCalLayerClusterIsolationProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HLTHGCalLayerClusterIsolationProducer.cc:130
HLTHGCalLayerClusterIsolationProducer::T1Collection
std::vector< T1 > T1Collection
Definition: HLTHGCalLayerClusterIsolationProducer.cc:39
CaloCluster.h
HLTHGCalLayerClusterIsolationProducer::minEtEM_
const double minEtEM_
Definition: HLTHGCalLayerClusterIsolationProducer.cc:60
HLTHGCalLayerClusterIsolationProducer::rhoMax_
const double rhoMax_
Definition: HLTHGCalLayerClusterIsolationProducer.cc:64