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);
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
const edm::EDGetTokenT< EcalRecHitCollection > ecalEndcapRecHitCollection_
const edm::EDGetTokenT< EcalRecHitCollection > ecalBarrelRecHitCollection_
const edm::EDGetTokenT< edm::View< reco::Candidate > > emObjectProducer_
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Definition: config.py:1
EgammaEcalRecHitIsolationProducer(const edm::ParameterSet &)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::ESGetToken< EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd > sevLvToken_
void setUseNumCrystals(bool b=true)
int iEvent
Definition: GenABIO.cc:224
T const * product() const
Definition: ESHandle.h:86
double getEtSum(const reco::Candidate *emObject) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
void setVetoClustered(bool b=true)
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
double getEnergySum(const reco::Candidate *emObject) const
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometrytoken_
def move(src, dest)
Definition: eostools.py:511