CMS 3D CMS Logo

EgammaHLTEcalRecIsolationProducer.cc
Go to the documentation of this file.
1 
2 //*****************************************************************************
3 // File: EgammaHLTEcalRecIsolationProducer.cc
4 // ----------------------------------------------------------------------------
5 // OrigAuth: Matthias Mozer , adapted from EgammaHcalIsolationProducer by S. Harper
6 // Institute: IIHE-VUB
7 //=============================================================================
8 //*****************************************************************************
9 
10 
13 
15 
19 
23 
25 
26  recoEcalCandidateProducer_ = consumes<reco::RecoEcalCandidateCollection>(conf_.getParameter<edm::InputTag>("recoEcalCandidateProducer"));
27  ecalBarrelRecHitProducer_ = consumes<EcalRecHitCollection>(conf_.getParameter<edm::InputTag>("ecalBarrelRecHitProducer"));
28  ecalEndcapRecHitProducer_ = consumes<EcalRecHitCollection>(conf_.getParameter<edm::InputTag>("ecalEndcapRecHitProducer"));
29 
30  doRhoCorrection_ = config.getParameter<bool>("doRhoCorrection");
31  if (doRhoCorrection_)
32  rhoProducer_ = consumes<double>(config.getParameter<edm::InputTag>("rhoProducer"));
33 
34  rhoMax_ = config.getParameter<double>("rhoMax");
35  rhoScale_ = config.getParameter<double>("rhoScale");
36 
37  //vetos
38  egIsoPtMinBarrel_ = conf_.getParameter<double>("etMinBarrel");
39  egIsoEMinBarrel_ = conf_.getParameter<double>("eMinBarrel");
40  egIsoPtMinEndcap_ = conf_.getParameter<double>("etMinEndcap");
41  egIsoEMinEndcap_ = conf_.getParameter<double>("eMinEndcap");
42  egIsoConeSizeInBarrel_ = conf_.getParameter<double>("intRadiusBarrel");
43  egIsoConeSizeInEndcap_ = conf_.getParameter<double>("intRadiusEndcap");
44  egIsoConeSizeOut_ = conf_.getParameter<double>("extRadius");
45  egIsoJurassicWidth_ = conf_.getParameter<double>("jurassicWidth");
46  effectiveAreaBarrel_ = config.getParameter<double>("effectiveAreaBarrel");
47  effectiveAreaEndcap_ = config.getParameter<double>("effectiveAreaEndcap");
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 
55  //register your products
56  produces < reco::RecoEcalCandidateIsolationMap >();
57 }
58 
60 {}
61 
63 
65  desc.add<edm::InputTag>("recoEcalCandidateProducer", edm::InputTag("hltL1SeededRecoEcalCandidate"));
66  desc.add<edm::InputTag>("ecalBarrelRecHitProducer", edm::InputTag("hltEcalRegionalEgammaRecHit", "EcalRecHitsEB"));
67  desc.add<edm::InputTag>("ecalEndcapRecHitProducer", edm::InputTag("hltEcalRegionalEgammaRecHit", "EcalRecHitsEE"));
68  desc.add<edm::InputTag>("rhoProducer", edm::InputTag("fixedGridRhoFastjetAllCalo"));
69  desc.add<bool>("doRhoCorrection", false);
70  desc.add<double>("rhoMax", 9.9999999E7);
71  desc.add<double>("rhoScale", 1.0);
72  desc.add<double>("etMinBarrel", -9999.0);
73  desc.add<double>("eMinBarrel", 0.095);
74  desc.add<double>("etMinEndcap", 0.11);
75  desc.add<double>("eMinEndcap", -9999.0);
76  desc.add<double>("intRadiusBarrel", 3.0);
77  desc.add<double>("intRadiusEndcap", 3.0);
78  desc.add<double>("extRadius", 0.3);
79  desc.add<double>("jurassicWidth", 3.0);
80  desc.add<double>("effectiveAreaBarrel", 0.101);
81  desc.add<double>("effectiveAreaEndcap", 0.046);
82  desc.add<bool>("useIsolEt", true);
83  desc.add<bool>("tryBoth", true);
84  desc.add<bool>("subtract", false);
85  desc.add<bool>("useNumCrystals", true);
86 
87  descriptions.add(("hltEgammaHLTEcalRecIsolationProducer"), desc);
88 }
89 
91 
92  // Get the RecoEcalCandidate Collection
94  iEvent.getByToken(recoEcalCandidateProducer_,recoecalcandHandle);
95 
96  // Next get Ecal hits barrel
97  edm::Handle<EcalRecHitCollection> ecalBarrelRecHitHandle; //EcalRecHitCollection is a typedef to
98  iEvent.getByToken(ecalBarrelRecHitProducer_, ecalBarrelRecHitHandle);
99 
100  // Next get Ecal hits endcap
101  edm::Handle<EcalRecHitCollection> ecalEndcapRecHitHandle;
102  iEvent.getByToken(ecalEndcapRecHitProducer_, ecalEndcapRecHitHandle);
103 
104  //Get Calo Geometry
106  iSetup.get<CaloGeometryRecord>().get(pG);
107  const CaloGeometry* caloGeom = pG.product();
108 
110  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
111  const EcalSeverityLevelAlgo* sevLevel = sevlv.product();
112 
113  edm::Handle<double> rhoHandle;
114  double rho = 0.0;
115  if (doRhoCorrection_) {
116  iEvent.getByToken(rhoProducer_, rhoHandle);
117  rho = *(rhoHandle.product());
118  }
119 
120  if (rho > rhoMax_)
121  rho = rhoMax_;
122 
123  rho = rho*rhoScale_;
124 
125  //prepare product
126  reco::RecoEcalCandidateIsolationMap isoMap(recoecalcandHandle);
127 
128  //create algorithm objects
130  ecalBarrelIsol.setUseNumCrystals(useNumCrystals_);
132  ecalEndcapIsol.setUseNumCrystals(useNumCrystals_);
133 
134  for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand= recoecalcandHandle->begin(); iRecoEcalCand!=recoecalcandHandle->end(); iRecoEcalCand++) {
135 
136  //create reference for storage in isolation map
137  reco::RecoEcalCandidateRef recoecalcandref(reco::RecoEcalCandidateRef(recoecalcandHandle,iRecoEcalCand -recoecalcandHandle ->begin()));
138 
139  //ecal isolation is centered on supecluster
140  reco::SuperClusterRef superClus = iRecoEcalCand->get<reco::SuperClusterRef>();
141 
142  //i need to know if its in the barrel/endcap so I get the supercluster handle to find out the detector eta
143  //this might not be the best way, are we guaranteed that eta<1.5 is barrel
144  //this can be safely replaced by another method which determines where the emobject is
145  //then we either get the isolation Et or isolation Energy depending on user selection
146  float isol =0.;
147 
148  if(tryBoth_){ //barrel + endcap
149  if(useIsolEt_) isol = ecalBarrelIsol.getEtSum(&(*iRecoEcalCand)) + ecalEndcapIsol.getEtSum(&(*iRecoEcalCand));
150  else isol = ecalBarrelIsol.getEnergySum(&(*iRecoEcalCand)) + ecalEndcapIsol.getEnergySum(&(*iRecoEcalCand));
151  }
152  else if( fabs(superClus->eta())<1.479) { //barrel
153  if(useIsolEt_) isol = ecalBarrelIsol.getEtSum(&(*iRecoEcalCand));
154  else isol = ecalBarrelIsol.getEnergySum(&(*iRecoEcalCand));
155  }
156  else{ //endcap
157  if(useIsolEt_) isol = ecalEndcapIsol.getEtSum(&(*iRecoEcalCand));
158  else isol = ecalEndcapIsol.getEnergySum(&(*iRecoEcalCand));
159  }
160 
161  //we subtract off the electron energy here as well
162  double subtractVal=0;
163 
164  if(useIsolEt_) subtractVal = superClus.get()->rawEnergy()*sin(2*atan(exp(-superClus.get()->eta())));
165  else subtractVal = superClus.get()->rawEnergy();
166 
167  if(subtract_) isol-= subtractVal;
168 
169  if (doRhoCorrection_) {
170  if (fabs(superClus->eta()) < 1.442)
171  isol = isol - rho*effectiveAreaBarrel_;
172  else
173  isol = isol - rho*effectiveAreaEndcap_;
174  }
175 
176  isoMap.insert(recoecalcandref, isol);
177  }
178 
179  iEvent.put(std::make_unique<reco::RecoEcalCandidateIsolationMap>(isoMap));
180 
181 }
182 
183 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
double getEtSum(const reco::Candidate *emObject) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Definition: config.py:1
void produce(edm::Event &, const edm::EventSetup &) override
double getEnergySum(const reco::Candidate *emObject) const
void setUseNumCrystals(bool b=true)
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< EcalRecHitCollection > ecalEndcapRecHitProducer_
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:245
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T const * product() const
Definition: Handle.h:81
void insert(const key_type &k, const data_type &v)
insert an association
const T & get() const
Definition: EventSetup.h:58
edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateProducer_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
#define begin
Definition: vmac.h:32
EgammaHLTEcalRecIsolationProducer(const edm::ParameterSet &)
T const * product() const
Definition: ESHandle.h:86
edm::EDGetTokenT< EcalRecHitCollection > ecalBarrelRecHitProducer_