CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloExtractorByAssociator.cc
Go to the documentation of this file.
2 
7 
12 
17 
19 
23 
25 //#include "CommonTools/Utils/interface/deltaR.h"
26 //#include "PhysicsTools/Utilities/interface/deltaR.h"
27 
28 using namespace edm;
29 using namespace std;
30 using namespace reco;
31 using namespace muonisolation;
33 
34 CaloExtractorByAssociator::CaloExtractorByAssociator(const ParameterSet& par, edm::ConsumesCollector && iC) :
35  theUseRecHitsFlag(par.getParameter<bool>("UseRecHitsFlag")),
36  theDepositLabel(par.getUntrackedParameter<string>("DepositLabel")),
37  theDepositInstanceLabels(par.getParameter<std::vector<std::string> >("DepositInstanceLabels")),
38  thePropagatorName(par.getParameter<std::string>("PropagatorName")),
39  theThreshold_E(par.getParameter<double>("Threshold_E")),
40  theThreshold_H(par.getParameter<double>("Threshold_H")),
41  theThreshold_HO(par.getParameter<double>("Threshold_HO")),
42  theDR_Veto_E(par.getParameter<double>("DR_Veto_E")),
43  theDR_Veto_H(par.getParameter<double>("DR_Veto_H")),
44  theDR_Veto_HO(par.getParameter<double>("DR_Veto_HO")),
45  theCenterConeOnCalIntersection(par.getParameter<bool>("CenterConeOnCalIntersection")),
46  theDR_Max(par.getParameter<double>("DR_Max")),
47  theNoise_EB(par.getParameter<double>("Noise_EB")),
48  theNoise_EE(par.getParameter<double>("Noise_EE")),
49  theNoise_HB(par.getParameter<double>("Noise_HB")),
50  theNoise_HE(par.getParameter<double>("Noise_HE")),
51  theNoise_HO(par.getParameter<double>("Noise_HO")),
52  theNoiseTow_EB(par.getParameter<double>("NoiseTow_EB")),
53  theNoiseTow_EE(par.getParameter<double>("NoiseTow_EE")),
54  theService(0),
55  theAssociator(0),
56  thePrintTimeReport(par.getUntrackedParameter<bool>("PrintTimeReport"))
57 {
58  ParameterSet serviceParameters = par.getParameter<ParameterSet>("ServiceParameters");
59  theService = new MuonServiceProxy(serviceParameters);
60 
61  //theAssociatorParameters = new TrackAssociatorParameters(par.getParameter<edm::ParameterSet>("TrackAssociatorParameters"), iC);
63  theAssociatorParameters->loadParameters(par.getParameter<edm::ParameterSet>("TrackAssociatorParameters"), iC);
65 }
66 
69  if (theService) delete theService;
70  if (theAssociator) delete theAssociator;
71 }
72 
74 {
75 // LogWarning("CaloExtractorByAssociator")
76 // <<"fillVetos does nothing now: IsoDeposit provides enough functionality\n"
77 // <<"to remove a deposit at/around given (eta, phi)";
78 
79 }
80 
81 IsoDeposit CaloExtractorByAssociator::deposit( const Event & event, const EventSetup& eventSetup, const Track & muon) const
82 {
83  IsoDeposit::Direction muonDir(muon.eta(), muon.phi());
84  IsoDeposit dep(muonDir );
85 
86 // LogWarning("CaloExtractorByAssociator")
87 // <<"single deposit is not an option here\n"
88 // <<"use ::deposits --> extract all and reweight as necessary";
89 
90  return dep;
91 
92 }
93 
94 
96 std::vector<IsoDeposit> CaloExtractorByAssociator::deposits( const Event & event, const EventSetup& eventSetup, const Track & muon) const
97 {
98  theService->update(eventSetup);
100 
103  if (theDepositInstanceLabels.size() != 3){
104  LogError("MuonIsolation")<<"Configuration is inconsistent: Need 3 deposit instance labels";
105  }
106  if (! theDepositInstanceLabels[0].compare(0,1, std::string("e")) == 0
107  || ! theDepositInstanceLabels[1].compare(0,1, std::string("h")) == 0
108  || ! theDepositInstanceLabels[2].compare(0,2, std::string("ho")) == 0){
109  LogWarning("MuonIsolation")<<"Deposit instance labels do not look like (e*, h*, ho*):"
110  <<"proceed at your own risk. The extractor interprets lab0=from ecal; lab1=from hcal; lab2=from ho";
111  }
112 
113  typedef IsoDeposit::Veto Veto;
116  IsoDeposit::Direction muonDir(muon.eta(), muon.phi());
117 
118  IsoDeposit depEcal(muonDir);
119  IsoDeposit depHcal(muonDir);
120  IsoDeposit depHOcal(muonDir);
121 
123  eventSetup.get<IdealMagneticFieldRecord>().get(bField);
124 
125 
126  reco::TransientTrack tMuon(muon, &*bField);
127  FreeTrajectoryState iFTS = tMuon.initialFreeState();
128  TrackDetMatchInfo mInfo = theAssociator->associate(event, eventSetup, iFTS, *theAssociatorParameters);
129 
131  depEcal.setVeto(Veto(reco::isodeposit::Direction(mInfo.trkGlobPosAtEcal.eta(), mInfo.trkGlobPosAtEcal.phi()),
132  theDR_Veto_E));
133  depHcal.setVeto(Veto(reco::isodeposit::Direction(mInfo.trkGlobPosAtHcal.eta(), mInfo.trkGlobPosAtHcal.phi()),
134  theDR_Veto_H));
135  depHOcal.setVeto(Veto(reco::isodeposit::Direction(mInfo.trkGlobPosAtHO.eta(), mInfo.trkGlobPosAtHO.phi()),
136  theDR_Veto_HO));
137 
139  reco::isodeposit::Direction dirTmp = depEcal.veto().vetoDir;
140  double dRtmp = depEcal.veto().dR;
141  depEcal = IsoDeposit(dirTmp); depEcal.setVeto(Veto(dirTmp, dRtmp));
142 
143  dirTmp = depHcal.veto().vetoDir;
144  dRtmp = depHcal.veto().dR;
145  depHcal = IsoDeposit(dirTmp); depHcal.setVeto(Veto(dirTmp, dRtmp));
146 
147  dirTmp = depHOcal.veto().vetoDir;
148  dRtmp = depHOcal.veto().dR;
149  depHOcal = IsoDeposit(dirTmp); depHOcal.setVeto(Veto(dirTmp, dRtmp));
150  }
151 
152  if (theUseRecHitsFlag){
156  eventSetup.get<CaloGeometryRecord>().get(caloGeom);
157 
158  //Ecal
159  std::vector<const EcalRecHit*>::const_iterator eHitCI = mInfo.ecalRecHits.begin();
160  for (; eHitCI != mInfo.ecalRecHits.end(); ++eHitCI){
161  const EcalRecHit* eHitCPtr = *eHitCI;
162  GlobalPoint eHitPos = caloGeom->getPosition(eHitCPtr->detid());
163  double deltar0 = reco::deltaR(muon, eHitPos);
164  double cosTheta = 1./cosh(eHitPos.eta());
165  double energy = eHitCPtr->energy();
166  double et = energy*cosTheta;
167  if (deltar0 > theDR_Max
168  || ! (et > theThreshold_E && energy > 3*noiseRecHit(eHitCPtr->detid()))) continue;
169 
170  bool vetoHit = false;
171  double deltar = reco::deltaR(mInfo.trkGlobPosAtEcal, eHitPos);
173  if (deltar < theDR_Veto_E ){
174  LogDebug("RecoMuon|CaloExtractorByAssociator")
175  << " >>> Veto ECAL hit: Calo deltaR= " << deltar;
176  LogDebug("RecoMuon|CaloExtractorByAssociator")
177  << " >>> Calo eta phi ethcal: " << eHitPos.eta() << " " << eHitPos.phi() << " " << et;
178  vetoHit = true;
179  }
181  if (! vetoHit){
182  for (unsigned int iH = 0; iH< mInfo.crossedEcalIds.size() && ! vetoHit; ++iH){
183  if (mInfo.crossedEcalIds[iH].rawId() == eHitCPtr->detid().rawId()) vetoHit = true;
184  }
185  }
186 
187  if (vetoHit ){
188  depEcal.addCandEnergy(et);
189  } else {
190  depEcal.addDeposit(reco::isodeposit::Direction(eHitPos.eta(), eHitPos.phi()), et);
191  }
192  }
193 
194  //Hcal
195  std::vector<const HBHERecHit*>::const_iterator hHitCI = mInfo.hcalRecHits.begin();
196  for (; hHitCI != mInfo.hcalRecHits.end(); ++hHitCI){
197  const HBHERecHit* hHitCPtr = *hHitCI;
198  GlobalPoint hHitPos = caloGeom->getPosition(hHitCPtr->detid());
199  double deltar0 = reco::deltaR(muon, hHitPos);
200  double cosTheta = 1./cosh(hHitPos.eta());
201  double energy = hHitCPtr->energy();
202  double et = energy*cosTheta;
203  if (deltar0 > theDR_Max
204  || ! (et > theThreshold_H && energy > 3*noiseRecHit(hHitCPtr->detid()))) continue;
205 
206  bool vetoHit = false;
207  double deltar = reco::deltaR(mInfo.trkGlobPosAtHcal, hHitPos);
209  if (deltar < theDR_Veto_H ){
210  LogDebug("RecoMuon|CaloExtractorByAssociator")
211  << " >>> Veto HBHE hit: Calo deltaR= " << deltar;
212  LogDebug("RecoMuon|CaloExtractorByAssociator")
213  << " >>> Calo eta phi ethcal: " << hHitPos.eta() << " " << hHitPos.phi() << " " << et;
214  vetoHit = true;
215  }
217  if (! vetoHit){
218  for (unsigned int iH = 0; iH< mInfo.crossedHcalIds.size() && ! vetoHit; ++iH){
219  if (mInfo.crossedHcalIds[iH].rawId() == hHitCPtr->detid().rawId()) vetoHit = true;
220  }
221  }
222 
223  if (vetoHit ){
224  depHcal.addCandEnergy(et);
225  } else {
226  depHcal.addDeposit(reco::isodeposit::Direction(hHitPos.eta(), hHitPos.phi()), et);
227  }
228  }
229 
230  //HOcal
231  std::vector<const HORecHit*>::const_iterator hoHitCI = mInfo.hoRecHits.begin();
232  for (; hoHitCI != mInfo.hoRecHits.end(); ++hoHitCI){
233  const HORecHit* hoHitCPtr = *hoHitCI;
234  GlobalPoint hoHitPos = caloGeom->getPosition(hoHitCPtr->detid());
235  double deltar0 = reco::deltaR(muon, hoHitPos);
236  double cosTheta = 1./cosh(hoHitPos.eta());
237  double energy = hoHitCPtr->energy();
238  double et = energy*cosTheta;
239  if (deltar0 > theDR_Max
240  || ! (et > theThreshold_HO && energy > 3*noiseRecHit(hoHitCPtr->detid()))) continue;
241 
242  bool vetoHit = false;
243  double deltar = reco::deltaR(mInfo.trkGlobPosAtHO, hoHitPos);
245  if (deltar < theDR_Veto_HO ){
246  LogDebug("RecoMuon|CaloExtractorByAssociator")
247  << " >>> Veto HO hit: Calo deltaR= " << deltar;
248  LogDebug("RecoMuon|CaloExtractorByAssociator")
249  << " >>> Calo eta phi ethcal: " << hoHitPos.eta() << " " << hoHitPos.phi() << " " << et;
250  vetoHit = true;
251  }
253  if (! vetoHit){
254  for (unsigned int iH = 0; iH< mInfo.crossedHOIds.size() && ! vetoHit; ++iH){
255  if (mInfo.crossedHOIds[iH].rawId() == hoHitCPtr->detid().rawId()) vetoHit = true;
256  }
257  }
258 
259  if (vetoHit ){
260  depHOcal.addCandEnergy(et);
261  } else {
262  depHOcal.addDeposit(reco::isodeposit::Direction(hoHitPos.eta(), hoHitPos.phi()), et);
263  }
264  }
265 
266 
267  } else {
269  std::vector<const CaloTower*>::const_iterator calCI = mInfo.towers.begin();
270  for (; calCI != mInfo.towers.end(); ++calCI){
271  const CaloTower* calCPtr = *calCI;
272  double deltar0 = reco::deltaR(muon,*calCPtr);
273  if (deltar0>theDR_Max) continue;
274 
275  //even more copy-pasting .. need to refactor
276  double etecal = calCPtr->emEt();
277  double eecal = calCPtr->emEnergy();
278  bool doEcal = etecal>theThreshold_E && eecal>3*noiseEcal(*calCPtr);
279  double ethcal = calCPtr->hadEt();
280  double ehcal = calCPtr->hadEnergy();
281  bool doHcal = ethcal>theThreshold_H && ehcal>3*noiseHcal(*calCPtr);
282  double ethocal = calCPtr->outerEt();
283  double ehocal = calCPtr->outerEnergy();
284  bool doHOcal = ethocal>theThreshold_HO && ehocal>3*noiseHOcal(*calCPtr);
285  if ((!doEcal) && (!doHcal) && (!doHcal)) continue;
286 
287  bool vetoTowerEcal = false;
288  double deltarEcal = reco::deltaR(mInfo.trkGlobPosAtEcal, *calCPtr);
290  if (deltarEcal < theDR_Veto_E ){
291  LogDebug("RecoMuon|CaloExtractorByAssociator")
292  << " >>> Veto ecal tower: Calo deltaR= " << deltarEcal;
293  LogDebug("RecoMuon|CaloExtractorByAssociator")
294  << " >>> Calo eta phi ethcal: " << calCPtr->eta() << " " << calCPtr->phi() << " " << ethcal;
295  vetoTowerEcal = true;
296  }
297  bool vetoTowerHcal = false;
298  double deltarHcal = reco::deltaR(mInfo.trkGlobPosAtHcal, *calCPtr);
300  if (deltarHcal < theDR_Veto_H ){
301  LogDebug("RecoMuon|CaloExtractorByAssociator")
302  << " >>> Veto hcal tower: Calo deltaR= " << deltarHcal;
303  LogDebug("RecoMuon|CaloExtractorByAssociator")
304  << " >>> Calo eta phi ethcal: " << calCPtr->eta() << " " << calCPtr->phi() << " " << ethcal;
305  vetoTowerHcal = true;
306  }
307  bool vetoTowerHOCal = false;
308  double deltarHOcal = reco::deltaR(mInfo.trkGlobPosAtHO, *calCPtr);
310  if (deltarHOcal < theDR_Veto_HO ){
311  LogDebug("RecoMuon|CaloExtractorByAssociator")
312  << " >>> Veto HO tower: Calo deltaR= " << deltarHOcal;
313  LogDebug("RecoMuon|CaloExtractorByAssociator")
314  << " >>> Calo eta phi ethcal: " << calCPtr->eta() << " " << calCPtr->phi() << " " << ethcal;
315  vetoTowerHOCal = true;
316  }
317 
319  if (! (vetoTowerHOCal && vetoTowerHcal && vetoTowerEcal )){
320  for (unsigned int iH = 0; iH< mInfo.crossedTowerIds.size(); ++iH){
321  if (mInfo.crossedTowerIds[iH].rawId() == calCPtr->id().rawId()){
322  vetoTowerEcal = true;
323  vetoTowerHcal = true;
324  vetoTowerHOCal = true;
325  break;
326  }
327  }
328  }
329 
330  reco::isodeposit::Direction towerDir(calCPtr->eta(), calCPtr->phi());
332  if (doEcal){
333  if (vetoTowerEcal) depEcal.addCandEnergy(etecal);
334  else depEcal.addDeposit(towerDir, etecal);
335  }
336  if (doHcal){
337  if (vetoTowerHcal) depHcal.addCandEnergy(ethcal);
338  else depHcal.addDeposit(towerDir, ethcal);
339  }
340  if (doHOcal){
341  if (vetoTowerHOCal) depHOcal.addCandEnergy(ethocal);
342  else depHOcal.addDeposit(towerDir, ethocal);
343  }
344  }
345  }
346 
347  std::vector<IsoDeposit> resultDeps;
348  resultDeps.push_back(depEcal);
349  resultDeps.push_back(depHcal);
350  resultDeps.push_back(depHOcal);
351 
352  return resultDeps;
353 
354 }
355 
357  double noise = theNoiseTow_EB;
358  double eta = tower.eta();
359  if (fabs(eta)>1.479) noise = theNoiseTow_EE;
360  return noise;
361 }
362 
364  double noise = fabs(tower.eta())> 1.479 ? theNoise_HE : theNoise_HB;
365  return noise;
366 }
367 
369  double noise = theNoise_HO;
370  return noise;
371 }
372 
373 
374 double CaloExtractorByAssociator::noiseRecHit(const DetId& detId) const {
375  double noise = 100;
376  DetId::Detector det = detId.det();
377  if (det == DetId::Ecal){
378  EcalSubdetector subDet = (EcalSubdetector)(detId.subdetId());
379  if (subDet == EcalBarrel){
380  noise = theNoise_EB;
381  } else if (subDet == EcalEndcap){
382  noise = theNoise_EE;
383  }
384  } else if (det == DetId::Hcal){
385  HcalSubdetector subDet = (HcalSubdetector)(detId.subdetId());
386  if (subDet == HcalBarrel){
387  noise = theNoise_HB;
388  } else if (subDet == HcalEndcap){
389  noise = theNoise_HE;
390  } else if (subDet == HcalOuter){
391  noise = theNoise_HO;
392  }
393  }
394  return noise;
395 }
396 
#define LogDebug(id)
T getParameter(std::string const &) const
virtual void fillVetos(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::TrackCollection &tracks)
allows to set extra vetoes (in addition to the muon) – no-op at this point
math::XYZPoint trkGlobPosAtHO
const Veto & veto() const
Get veto area.
Definition: IsoDeposit.h:78
std::vector< const CaloTower * > towers
virtual std::vector< reco::IsoDeposit > deposits(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const
return deposits for 3 calorimeter subdetectors (ecal, hcal, ho) – in this order
void setVeto(const Veto &aVeto)
Set veto.
Definition: IsoDeposit.h:80
std::vector< DetId > crossedTowerIds
std::string thePropagatorName
propagator name to feed into the track associator
const DetId & detid() const
Definition: CaloRecHit.h:20
double hadEt() const
Definition: CaloTower.h:100
void compare(std::vector< std::string > const &old_files, std::string const &old_process, std::vector< std::string > const &new_files, std::string const &new_process, unsigned int max_events, bool ignore_prescales, int verbose)
Definition: hltDiff.cc:506
std::vector< const EcalRecHit * > ecalRecHits
hits in the cone
std::vector< DetId > crossedEcalIds
double theDR_Max
max cone size in which towers are considered
double outerEt() const
Definition: CaloTower.h:101
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
const DetId & detid() const
Definition: EcalRecHit.h:71
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:13
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
double noiseHOcal(const CaloTower &tower) const
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:608
std::vector< std::string > theDepositInstanceLabels
multiple deposits: labels – expect 3 labels beginning with &quot;e&quot;, &quot;h&quot;, &quot;ho&quot;
double noiseHcal(const CaloTower &tower) const
double theDR_Veto_E
cone sizes inside which the Et (towers) are not counted
TrackAssociatorParameters * theAssociatorParameters
associator, its&#39; parameters and the propagator
double deltaR(const T1 &t1, const T2 &t2)
Definition: deltaR.h:48
std::vector< DetId > crossedHcalIds
virtual double eta() const
momentum pseudorapidity
void addDeposit(double dr, double deposit)
Add deposit (ie. transverse energy or pT)
Definition: IsoDeposit.cc:23
math::XYZPoint trkGlobPosAtHcal
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:614
double noiseEcal(const CaloTower &tower) const
Determine noise for HCAL and ECAL (take some defaults for the time being)
double emEnergy() const
Definition: CaloTower.h:94
void setPropagator(const Propagator *)
use a user configured propagator
float energy() const
Definition: CaloRecHit.h:17
std::vector< const HBHERecHit * > hcalRecHits
void addCandEnergy(double et)
Set energy or pT attached to cand trajectory.
Definition: IsoDeposit.h:139
std::vector< DetId > crossedHOIds
HcalSubdetector
Definition: HcalAssistant.h:31
float energy() const
Definition: EcalRecHit.h:68
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
double noiseRecHit(const DetId &detId) const
double hadEnergy() const
Definition: CaloTower.h:95
FreeTrajectoryState initialFreeState() const
Definition: DetId.h:18
CaloTowerDetId id() const
Definition: CaloTower.h:87
reco::IsoDeposit IsoDeposit
Definition: Isolation.h:7
MuonServiceProxy * theService
the event setup proxy, it takes care the services update
Detector
Definition: DetId.h:24
const T & get() const
Definition: EventSetup.h:55
T eta() const
Definition: PV3DBase.h:76
tuple muons
Definition: patZpeak.py:38
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
math::XYZPoint trkGlobPosAtEcal
Track position at different parts of the calorimeter.
virtual reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const
no-op: by design of this extractor the deposits are pulled out all at a time
std::vector< const HORecHit * > hoRecHits
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
EcalSubdetector
virtual double phi() const
momentum azimuthal angle
double emEt() const
Definition: CaloTower.h:99
double outerEnergy() const
Definition: CaloTower.h:96