CMS 3D CMS Logo

EgammaEcalRecHitIsolationProducer.cc
Go to the documentation of this file.
1 //*****************************************************************************
2 // File: EgammaEcalRecHitIsolationProducer.cc
3 // ----------------------------------------------------------------------------
4 // OrigAuth: Matthias Mozer
5 // Institute: IIHE-VUB
6 //=============================================================================
7 //*****************************************************************************
8 
10 
11 // Framework
15 
21 
23 
25  // use configuration file to setup input/output collection names
26  //inputs
27  emObjectProducer_ = conf_.getParameter<edm::InputTag>("emObjectProducer");
28  ecalBarrelRecHitProducer_ = conf_.getParameter<edm::InputTag>("ecalBarrelRecHitProducer");
29  ecalBarrelRecHitCollection_ = conf_.getParameter<edm::InputTag>("ecalBarrelRecHitCollection");
30  ecalEndcapRecHitProducer_ = conf_.getParameter<edm::InputTag>("ecalEndcapRecHitProducer");
31  ecalEndcapRecHitCollection_ = conf_.getParameter<edm::InputTag>("ecalEndcapRecHitCollection");
32 
33  //vetos
34  egIsoPtMinBarrel_ = conf_.getParameter<double>("etMinBarrel");
35  egIsoEMinBarrel_ = conf_.getParameter<double>("eMinBarrel");
36  egIsoPtMinEndcap_ = conf_.getParameter<double>("etMinEndcap");
37  egIsoEMinEndcap_ = conf_.getParameter<double>("eMinEndcap");
38  egIsoConeSizeInBarrel_ = conf_.getParameter<double>("intRadiusBarrel");
39  egIsoConeSizeInEndcap_ = conf_.getParameter<double>("intRadiusEndcap");
40  egIsoConeSizeOut_ = conf_.getParameter<double>("extRadius");
41  egIsoJurassicWidth_ = conf_.getParameter<double>("jurassicWidth");
42 
43  // options
44  useIsolEt_ = conf_.getParameter<bool>("useIsolEt");
45  tryBoth_ = conf_.getParameter<bool>("tryBoth");
46  subtract_ = conf_.getParameter<bool>("subtract");
47  useNumCrystals_ = conf_.getParameter<bool>("useNumCrystals");
48  vetoClustered_ = conf_.getParameter<bool>("vetoClustered");
49 
50  //EventSetup Tokens
51  sevLvToken_ = esConsumes();
52  caloGeometrytoken_ = esConsumes();
53 
54  //register your products
55  produces<edm::ValueMap<double>>();
56 }
57 
59 
60 //
61 // member functions
62 //
63 
64 // ------------ method called to produce the data ------------
66  // Get the filtered objects
68  iEvent.getByLabel(emObjectProducer_, emObjectHandle);
69 
70  // Next get Ecal hits barrel
71  edm::Handle<EcalRecHitCollection> ecalBarrelRecHitHandle; //EcalRecHitCollection is a typedef to
72  iEvent.getByLabel(ecalBarrelRecHitProducer_.label(), ecalBarrelRecHitCollection_.label(), ecalBarrelRecHitHandle);
73 
74  // Next get Ecal hits endcap
75  edm::Handle<EcalRecHitCollection> ecalEndcapRecHitHandle;
76  iEvent.getByLabel(ecalEndcapRecHitProducer_.label(), ecalEndcapRecHitCollection_.label(), ecalEndcapRecHitHandle);
77 
79  const EcalSeverityLevelAlgo* sevLevel = sevlv.product();
80 
81  //Get Calo Geometry
83  const CaloGeometry* caloGeom = pG.product();
84 
85  //reco::CandViewDoubleAssociations* isoMap = new reco::CandViewDoubleAssociations( reco::CandidateBaseRefProd( emObjectHandle ) );
86  auto isoMap = std::make_unique<edm::ValueMap<double>>();
88  std::vector<double> retV(emObjectHandle->size(), 0);
89 
95  caloGeom,
96  *ecalBarrelRecHitHandle,
97  sevLevel,
98  DetId::Ecal);
99  ecalBarrelIsol.setUseNumCrystals(useNumCrystals_);
100  ecalBarrelIsol.setVetoClustered(vetoClustered_);
101 
107  caloGeom,
108  *ecalEndcapRecHitHandle,
109  sevLevel,
110  DetId::Ecal);
111  ecalEndcapIsol.setUseNumCrystals(useNumCrystals_);
112  ecalEndcapIsol.setVetoClustered(vetoClustered_);
113 
114  for (size_t i = 0; i < emObjectHandle->size(); ++i) {
115  //i need to know if its in the barrel/endcap so I get the supercluster handle to find out the detector eta
116  //this might not be the best way, are we guaranteed that eta<1.5 is barrel
117  //this can be safely replaced by another method which determines where the emobject is
118  //then we either get the isolation Et or isolation Energy depending on user selection
119  double isoValue = 0.;
120 
121  reco::SuperClusterRef superClus = emObjectHandle->at(i).get<reco::SuperClusterRef>();
122 
123  if (tryBoth_) { //barrel + endcap
124  if (useIsolEt_)
125  isoValue =
126  ecalBarrelIsol.getEtSum(&(emObjectHandle->at(i))) + ecalEndcapIsol.getEtSum(&(emObjectHandle->at(i)));
127  else
128  isoValue = ecalBarrelIsol.getEnergySum(&(emObjectHandle->at(i))) +
129  ecalEndcapIsol.getEnergySum(&(emObjectHandle->at(i)));
130  } else if (fabs(superClus->eta()) < 1.479) { //barrel
131  if (useIsolEt_)
132  isoValue = ecalBarrelIsol.getEtSum(&(emObjectHandle->at(i)));
133  else
134  isoValue = ecalBarrelIsol.getEnergySum(&(emObjectHandle->at(i)));
135  } else { //endcap
136  if (useIsolEt_)
137  isoValue = ecalEndcapIsol.getEtSum(&(emObjectHandle->at(i)));
138  else
139  isoValue = ecalEndcapIsol.getEnergySum(&(emObjectHandle->at(i)));
140  }
141 
142  //we subtract off the electron energy here as well
143  double subtractVal = 0;
144 
145  if (useIsolEt_)
146  subtractVal = superClus.get()->rawEnergy() * sin(2 * atan(exp(-superClus.get()->eta())));
147  else
148  subtractVal = superClus.get()->rawEnergy();
149 
150  if (subtract_)
151  isoValue -= subtractVal;
152 
153  retV[i] = isoValue;
154  //all done, isolation is now in the map
155 
156  } //end of loop over em objects
157 
158  filler.insert(emObjectHandle, retV.begin(), retV.end());
159  filler.fill();
160 
161  iEvent.put(std::move(isoMap));
162 }
163 
164 //define this as a plug-in
165 //DEFINE_FWK_MODULE(EgammaRecHitIsolation,Producer);
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EcalSeverityLevelAlgo
Definition: EcalSeverityLevelAlgo.h:33
EgammaEcalRecHitIsolationProducer::egIsoConeSizeInEndcap_
double egIsoConeSizeInEndcap_
Definition: EgammaEcalRecHitIsolationProducer.h:62
Handle.h
EgammaEcalRecHitIsolationProducer::subtract_
bool subtract_
Definition: EgammaEcalRecHitIsolationProducer.h:67
mps_fire.i
i
Definition: mps_fire.py:428
ESHandle.h
EgammaEcalRecHitIsolationProducer::egIsoEMinBarrel_
double egIsoEMinBarrel_
Definition: EgammaEcalRecHitIsolationProducer.h:57
EgammaEcalRecHitIsolationProducer::egIsoConeSizeOut_
double egIsoConeSizeOut_
Definition: EgammaEcalRecHitIsolationProducer.h:60
EgammaEcalRecHitIsolationProducer::useIsolEt_
bool useIsolEt_
Definition: EgammaEcalRecHitIsolationProducer.h:65
EgammaRecHitIsolation::getEnergySum
double getEnergySum(const reco::Candidate *emObject) const
Definition: EgammaRecHitIsolation.h:40
EgammaRecHitIsolation::setUseNumCrystals
void setUseNumCrystals(bool b=true)
Definition: EgammaRecHitIsolation.h:45
EgammaEcalRecHitIsolationProducer::ecalEndcapRecHitProducer_
edm::InputTag ecalEndcapRecHitProducer_
Definition: EgammaEcalRecHitIsolationProducer.h:53
edm::Ref::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
EgammaEcalRecHitIsolationProducer::ecalBarrelRecHitCollection_
edm::InputTag ecalBarrelRecHitCollection_
Definition: EgammaEcalRecHitIsolationProducer.h:52
EgammaEcalRecHitIsolationProducer::egIsoEMinEndcap_
double egIsoEMinEndcap_
Definition: EgammaEcalRecHitIsolationProducer.h:59
EgammaRecHitIsolation::setVetoClustered
void setVetoClustered(bool b=true)
Definition: EgammaRecHitIsolation.h:46
EgammaRecHitIsolation
Definition: EgammaRecHitIsolation.h:26
EgammaEcalRecHitIsolationProducer::tryBoth_
bool tryBoth_
Definition: EgammaEcalRecHitIsolationProducer.h:66
EgammaEcalRecHitIsolationProducer::vetoClustered_
bool vetoClustered_
Definition: EgammaEcalRecHitIsolationProducer.h:70
edm::Handle
Definition: AssociativeIterator.h:50
RecoCandidate.h
EgammaEcalRecHitIsolationProducer::sevLvToken_
edm::ESGetToken< EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd > sevLvToken_
Definition: EgammaEcalRecHitIsolationProducer.h:73
edm::Ref< SuperClusterCollection >
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
config
Definition: config.py:1
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
CaloGeometry
Definition: CaloGeometry.h:21
EgammaRecHitIsolation::getEtSum
double getEtSum(const reco::Candidate *emObject) const
Definition: EgammaRecHitIsolation.h:39
EgammaEcalRecHitIsolationProducer::ecalBarrelRecHitProducer_
edm::InputTag ecalBarrelRecHitProducer_
Definition: EgammaEcalRecHitIsolationProducer.h:51
EgammaEcalRecHitIsolationProducer::caloGeometrytoken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometrytoken_
Definition: EgammaEcalRecHitIsolationProducer.h:74
EgammaEcalRecHitIsolationProducer::egIsoJurassicWidth_
double egIsoJurassicWidth_
Definition: EgammaEcalRecHitIsolationProducer.h:63
EgammaEcalRecHitIsolationProducer::useNumCrystals_
bool useNumCrystals_
Definition: EgammaEcalRecHitIsolationProducer.h:69
EgammaEcalRecHitIsolationProducer::egIsoConeSizeInBarrel_
double egIsoConeSizeInBarrel_
Definition: EgammaEcalRecHitIsolationProducer.h:61
edm::ESHandle< EcalSeverityLevelAlgo >
EgammaEcalRecHitIsolationProducer::emObjectProducer_
edm::InputTag emObjectProducer_
Definition: EgammaEcalRecHitIsolationProducer.h:50
EgammaEcalRecHitIsolationProducer::ecalEndcapRecHitCollection_
edm::InputTag ecalEndcapRecHitCollection_
Definition: EgammaEcalRecHitIsolationProducer.h:54
EgammaEcalRecHitIsolationProducer::egIsoPtMinBarrel_
double egIsoPtMinBarrel_
Definition: EgammaEcalRecHitIsolationProducer.h:56
edm::ParameterSet
Definition: ParameterSet.h:47
CandAssociation.h
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
EgammaEcalRecHitIsolationProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: EgammaEcalRecHitIsolationProducer.cc:65
iEvent
int iEvent
Definition: GenABIO.cc:224
EgammaEcalRecHitIsolationProducer::conf_
edm::ParameterSet conf_
Definition: EgammaEcalRecHitIsolationProducer.h:72
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:148
EgammaEcalRecHitIsolationProducer::egIsoPtMinEndcap_
double egIsoPtMinEndcap_
Definition: EgammaEcalRecHitIsolationProducer.h:58
edm::EventSetup
Definition: EventSetup.h:57
DetId::Ecal
Definition: DetId.h:27
eostools.move
def move(src, dest)
Definition: eostools.py:511
SuperClusterFwd.h
DetId.h
SuperCluster.h
EgammaEcalRecHitIsolationProducer::~EgammaEcalRecHitIsolationProducer
~EgammaEcalRecHitIsolationProducer() override
Definition: EgammaEcalRecHitIsolationProducer.cc:58
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Candidate.h
edm::helper::Filler
Definition: ValueMap.h:22
EgammaEcalRecHitIsolationProducer.h
EgammaEcalRecHitIsolationProducer::EgammaEcalRecHitIsolationProducer
EgammaEcalRecHitIsolationProducer(const edm::ParameterSet &)
Definition: EgammaEcalRecHitIsolationProducer.cc:24
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15