CMS 3D CMS Logo

EgammaEcalRecHitIsolationProducer.cc
Go to the documentation of this file.
1 //*****************************************************************************
2 // File: EgammaEcalRecHitIsolationProducer.cc
3 // ----------------------------------------------------------------------------
4 // OrigAuth: Matthias Mozer, adapted from EgammaHcalIsolationProducer by S. Harper
5 // Institute: IIHE-VUB, RAL
6 //=============================================================================
7 //*****************************************************************************
8 
28 
30 public:
32 
33  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
34 
35 private:
39 
40  double egIsoPtMinBarrel_; //minimum Et noise cut
41  double egIsoEMinBarrel_; //minimum E noise cut
42  double egIsoPtMinEndcap_; //minimum Et noise cut
43  double egIsoEMinEndcap_; //minimum E noise cut
44  double egIsoConeSizeOut_; //outer cone size
45  double egIsoConeSizeInBarrel_; //inner cone size
46  double egIsoConeSizeInEndcap_; //inner cone size
47  double egIsoJurassicWidth_; // exclusion strip width for jurassic veto
48 
49  bool useIsolEt_; //switch for isolEt rather than isolE
50  bool tryBoth_; // use rechits from barrel + endcap
51  bool subtract_; // subtract SC energy (allows veto cone of zero size)
52 
53  bool useNumCrystals_; // veto on number of crystals
54  bool vetoClustered_; // veto all clusterd rechits
55 
58 };
59 
62 
64  //inputs
65  : emObjectProducer_{consumes(config.getParameter<edm::InputTag>("emObjectProducer"))},
66  ecalBarrelRecHitCollection_{consumes(config.getParameter<edm::InputTag>("ecalBarrelRecHitCollection"))},
67  ecalEndcapRecHitCollection_{consumes(config.getParameter<edm::InputTag>("ecalEndcapRecHitCollection"))} {
68  //vetos
69  egIsoPtMinBarrel_ = config.getParameter<double>("etMinBarrel");
70  egIsoEMinBarrel_ = config.getParameter<double>("eMinBarrel");
71  egIsoPtMinEndcap_ = config.getParameter<double>("etMinEndcap");
72  egIsoEMinEndcap_ = config.getParameter<double>("eMinEndcap");
73  egIsoConeSizeInBarrel_ = config.getParameter<double>("intRadiusBarrel");
74  egIsoConeSizeInEndcap_ = config.getParameter<double>("intRadiusEndcap");
75  egIsoConeSizeOut_ = config.getParameter<double>("extRadius");
76  egIsoJurassicWidth_ = config.getParameter<double>("jurassicWidth");
77 
78  // options
79  useIsolEt_ = config.getParameter<bool>("useIsolEt");
80  tryBoth_ = config.getParameter<bool>("tryBoth");
81  subtract_ = config.getParameter<bool>("subtract");
82  useNumCrystals_ = config.getParameter<bool>("useNumCrystals");
83  vetoClustered_ = config.getParameter<bool>("vetoClustered");
84 
85  //EventSetup Tokens
86  sevLvToken_ = esConsumes();
87  caloGeometrytoken_ = esConsumes();
88 
89  //register your products
90  produces<edm::ValueMap<double>>();
91 }
92 
93 // ------------ method called to produce the data ------------
96  const edm::EventSetup& iSetup) const {
97  // Get the filtered objects
98  auto emObjectHandle = iEvent.getHandle(emObjectProducer_);
99 
100  // Next get Ecal hits barrel
101  auto ecalBarrelRecHitHandle = iEvent.getHandle(ecalBarrelRecHitCollection_);
102 
103  // Next get Ecal hits endcap
104  auto ecalEndcapRecHitHandle = iEvent.getHandle(ecalEndcapRecHitCollection_);
105 
107  const EcalSeverityLevelAlgo* sevLevel = sevlv.product();
108 
109  //Get Calo Geometry
111  const CaloGeometry* caloGeom = pG.product();
112 
113  //reco::CandViewDoubleAssociations* isoMap = new reco::CandViewDoubleAssociations( reco::CandidateBaseRefProd( emObjectHandle ) );
114  auto isoMap = std::make_unique<edm::ValueMap<double>>();
116  std::vector<double> retV(emObjectHandle->size(), 0);
117 
123  caloGeom,
124  *ecalBarrelRecHitHandle,
125  sevLevel,
126  DetId::Ecal);
127  ecalBarrelIsol.setUseNumCrystals(useNumCrystals_);
128  ecalBarrelIsol.setVetoClustered(vetoClustered_);
129 
135  caloGeom,
136  *ecalEndcapRecHitHandle,
137  sevLevel,
138  DetId::Ecal);
139  ecalEndcapIsol.setUseNumCrystals(useNumCrystals_);
140  ecalEndcapIsol.setVetoClustered(vetoClustered_);
141 
142  for (size_t i = 0; i < emObjectHandle->size(); ++i) {
143  //i need to know if its in the barrel/endcap so I get the supercluster handle to find out the detector eta
144  //this might not be the best way, are we guaranteed that eta<1.5 is barrel
145  //this can be safely replaced by another method which determines where the emobject is
146  //then we either get the isolation Et or isolation Energy depending on user selection
147  double isoValue = 0.;
148 
149  reco::SuperClusterRef superClus = emObjectHandle->at(i).get<reco::SuperClusterRef>();
150 
151  if (tryBoth_) { //barrel + endcap
152  if (useIsolEt_)
153  isoValue =
154  ecalBarrelIsol.getEtSum(&(emObjectHandle->at(i))) + ecalEndcapIsol.getEtSum(&(emObjectHandle->at(i)));
155  else
156  isoValue = ecalBarrelIsol.getEnergySum(&(emObjectHandle->at(i))) +
157  ecalEndcapIsol.getEnergySum(&(emObjectHandle->at(i)));
158  } else if (fabs(superClus->eta()) < 1.479) { //barrel
159  if (useIsolEt_)
160  isoValue = ecalBarrelIsol.getEtSum(&(emObjectHandle->at(i)));
161  else
162  isoValue = ecalBarrelIsol.getEnergySum(&(emObjectHandle->at(i)));
163  } else { //endcap
164  if (useIsolEt_)
165  isoValue = ecalEndcapIsol.getEtSum(&(emObjectHandle->at(i)));
166  else
167  isoValue = ecalEndcapIsol.getEnergySum(&(emObjectHandle->at(i)));
168  }
169 
170  //we subtract off the electron energy here as well
171  double subtractVal = 0;
172 
173  if (useIsolEt_)
174  subtractVal = superClus.get()->rawEnergy() * sin(2 * atan(exp(-superClus.get()->eta())));
175  else
176  subtractVal = superClus.get()->rawEnergy();
177 
178  if (subtract_)
179  isoValue -= subtractVal;
180 
181  retV[i] = isoValue;
182  //all done, isolation is now in the map
183 
184  } //end of loop over em objects
185 
186  filler.insert(emObjectHandle, retV.begin(), retV.end());
187  filler.fill();
188 
189  iEvent.put(std::move(isoMap));
190 }
191 
192 //define this as a plug-in
193 //DEFINE_FWK_MODULE(EgammaRecHitIsolation,Producer);
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
edm::StreamID
Definition: StreamID.h:30
EcalSeverityLevelAlgo
Definition: EcalSeverityLevelAlgo.h:33
EgammaEcalRecHitIsolationProducer::egIsoConeSizeInEndcap_
double egIsoConeSizeInEndcap_
Definition: EgammaEcalRecHitIsolationProducer.cc:46
Handle.h
EgammaEcalRecHitIsolationProducer::subtract_
bool subtract_
Definition: EgammaEcalRecHitIsolationProducer.cc:51
mps_fire.i
i
Definition: mps_fire.py:428
EgammaEcalRecHitIsolationProducer::ecalBarrelRecHitCollection_
const edm::EDGetTokenT< EcalRecHitCollection > ecalBarrelRecHitCollection_
Definition: EgammaEcalRecHitIsolationProducer.cc:37
ESHandle.h
EgammaEcalRecHitIsolationProducer::egIsoEMinBarrel_
double egIsoEMinBarrel_
Definition: EgammaEcalRecHitIsolationProducer.cc:41
EgammaEcalRecHitIsolationProducer::egIsoConeSizeOut_
double egIsoConeSizeOut_
Definition: EgammaEcalRecHitIsolationProducer.cc:44
EcalSeverityLevelAlgoRcd.h
EgammaEcalRecHitIsolationProducer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: EgammaEcalRecHitIsolationProducer.cc:94
edm::EDGetTokenT
Definition: EDGetToken.h:33
EgammaEcalRecHitIsolationProducer::useIsolEt_
bool useIsolEt_
Definition: EgammaEcalRecHitIsolationProducer.cc:49
EgammaRecHitIsolation::getEnergySum
double getEnergySum(const reco::Candidate *emObject) const
Definition: EgammaRecHitIsolation.h:40
EgammaRecHitIsolation::setUseNumCrystals
void setUseNumCrystals(bool b=true)
Definition: EgammaRecHitIsolation.h:45
edm::Ref::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
EgammaEcalRecHitIsolationProducer::egIsoEMinEndcap_
double egIsoEMinEndcap_
Definition: EgammaEcalRecHitIsolationProducer.cc:43
EgammaRecHitIsolation::setVetoClustered
void setVetoClustered(bool b=true)
Definition: EgammaRecHitIsolation.h:46
EgammaRecHitIsolation
Definition: EgammaRecHitIsolation.h:26
EgammaEcalRecHitIsolationProducer::tryBoth_
bool tryBoth_
Definition: EgammaEcalRecHitIsolationProducer.cc:50
EgammaEcalRecHitIsolationProducer::ecalEndcapRecHitCollection_
const edm::EDGetTokenT< EcalRecHitCollection > ecalEndcapRecHitCollection_
Definition: EgammaEcalRecHitIsolationProducer.cc:38
EgammaEcalRecHitIsolationProducer::vetoClustered_
bool vetoClustered_
Definition: EgammaEcalRecHitIsolationProducer.cc:54
RecoCandidate.h
EgammaEcalRecHitIsolationProducer::sevLvToken_
edm::ESGetToken< EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd > sevLvToken_
Definition: EgammaEcalRecHitIsolationProducer.cc:56
ESGetToken.h
EgammaEcalRecHitIsolationProducer::emObjectProducer_
const edm::EDGetTokenT< edm::View< reco::Candidate > > emObjectProducer_
Definition: EgammaEcalRecHitIsolationProducer.cc:36
edm::Ref< SuperClusterCollection >
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
config
Definition: config.py:1
MakerMacros.h
CaloGeometry
Definition: CaloGeometry.h:21
EgammaRecHitIsolation::getEtSum
double getEtSum(const reco::Candidate *emObject) const
Definition: EgammaRecHitIsolation.h:39
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
EgammaEcalRecHitIsolationProducer::caloGeometrytoken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometrytoken_
Definition: EgammaEcalRecHitIsolationProducer.cc:57
EgammaEcalRecHitIsolationProducer::egIsoJurassicWidth_
double egIsoJurassicWidth_
Definition: EgammaEcalRecHitIsolationProducer.cc:47
EgammaEcalRecHitIsolationProducer::useNumCrystals_
bool useNumCrystals_
Definition: EgammaEcalRecHitIsolationProducer.cc:53
EgammaEcalRecHitIsolationProducer::egIsoConeSizeInBarrel_
double egIsoConeSizeInBarrel_
Definition: EgammaEcalRecHitIsolationProducer.cc:45
edm::ESHandle< EcalSeverityLevelAlgo >
EcalSeverityLevelAlgo.h
edm::global::EDProducer
Definition: EDProducer.h:32
CaloGeometryRecord.h
EgammaEcalRecHitIsolationProducer
Definition: EgammaEcalRecHitIsolationProducer.cc:29
EgammaEcalRecHitIsolationProducer::egIsoPtMinBarrel_
double egIsoPtMinBarrel_
Definition: EgammaEcalRecHitIsolationProducer.cc:40
edm::ParameterSet
Definition: ParameterSet.h:47
CandAssociation.h
Event.h
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
EgammaEcalRecHitIsolationProducer::egIsoPtMinEndcap_
double egIsoPtMinEndcap_
Definition: EgammaEcalRecHitIsolationProducer.cc:42
edm::EventSetup
Definition: EventSetup.h:58
DetId::Ecal
Definition: DetId.h:27
edm::ESGetToken< EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd >
eostools.move
def move(src, dest)
Definition: eostools.py:511
SuperClusterFwd.h
DetId.h
EgammaRecHitIsolation.h
SuperCluster.h
CaloGeometry.h
EventSetup.h
ConsumesCollector.h
Candidate.h
edm::helper::Filler
Definition: ValueMap.h:22
ParameterSet.h
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:159
EgammaEcalRecHitIsolationProducer::EgammaEcalRecHitIsolationProducer
EgammaEcalRecHitIsolationProducer(const edm::ParameterSet &)
Definition: EgammaEcalRecHitIsolationProducer.cc:63
EDProducer.h
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15