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