CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
muonisolation::CaloExtractor Class Reference

#include <CaloExtractor.h>

Inheritance diagram for muonisolation::CaloExtractor:
reco::isodeposit::IsoDepositExtractor

Public Member Functions

 CaloExtractor ()
 
 CaloExtractor (const edm::ParameterSet &par)
 
virtual reco::IsoDeposit deposit (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const
 
virtual void fillVetos (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::TrackCollection &tracks)
 
virtual ~CaloExtractor ()
 
- Public Member Functions inherited from reco::isodeposit::IsoDepositExtractor
virtual reco::IsoDeposit deposit (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::TrackBaseRef &track) const
 make single IsoDeposit based on trackRef as input More...
 
virtual reco::IsoDeposit deposit (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Candidate &track) const
 
virtual reco::IsoDeposit deposit (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::CandidateBaseRef &track) const
 make single IsoDeposit based on a CandidateBaseRef as input More...
 
virtual std::vector
< reco::IsoDeposit
deposits (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const
 
virtual std::vector
< reco::IsoDeposit
deposits (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::TrackBaseRef &track) const
 
virtual std::vector
< reco::IsoDeposit
deposits (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Candidate &track) const
 
virtual std::vector
< reco::IsoDeposit
deposits (const edm::Event &ev, const edm::EventSetup &evSetup, const reco::CandidateBaseRef &track) const
 
virtual ~IsoDepositExtractor ()
 Destructor. More...
 

Static Public Member Functions

static GlobalPoint MuonAtCaloPosition (const reco::Track &muon, const double bz, const GlobalPoint &endpos, bool fixVxy=false, bool fixVz=false)
 Extrapolate muons to calorimeter-object positions. More...
 

Private Member Functions

double noiseEcal (const CaloTower &tower) const
 
double noiseHcal (const CaloTower &tower) const
 

Private Attributes

edm::InputTag theCaloTowerCollectionLabel
 
std::string theDepositLabel
 
double theDR_Max
 
double theDR_Veto_E
 
double theDR_Veto_H
 
double theThreshold_E
 
double theThreshold_H
 
std::vector< DetIdtheVetoCollection
 
double theWeight_E
 
double theWeight_H
 
bool vertexConstraintFlag_XY
 
bool vertexConstraintFlag_Z
 

Detailed Description

Definition at line 18 of file CaloExtractor.h.

Constructor & Destructor Documentation

muonisolation::CaloExtractor::CaloExtractor ( )
inline

Definition at line 22 of file CaloExtractor.h.

22 {};
CaloExtractor::CaloExtractor ( const edm::ParameterSet par)

Definition at line 28 of file CaloExtractor.cc.

28  :
29  theCaloTowerCollectionLabel(par.getParameter<edm::InputTag>("CaloTowerCollectionLabel")),
30  theDepositLabel(par.getUntrackedParameter<string>("DepositLabel")),
31  theWeight_E(par.getParameter<double>("Weight_E")),
32  theWeight_H(par.getParameter<double>("Weight_H")),
33  theThreshold_E(par.getParameter<double>("Threshold_E")),
34  theThreshold_H(par.getParameter<double>("Threshold_H")),
35  theDR_Veto_E(par.getParameter<double>("DR_Veto_E")),
36  theDR_Veto_H(par.getParameter<double>("DR_Veto_H")),
37  theDR_Max(par.getParameter<double>("DR_Max")),
38  vertexConstraintFlag_XY(par.getParameter<bool>("Vertex_Constraint_XY")),
39  vertexConstraintFlag_Z(par.getParameter<bool>("Vertex_Constraint_Z"))
40 {
41 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag theCaloTowerCollectionLabel
Definition: CaloExtractor.h:35
virtual muonisolation::CaloExtractor::~CaloExtractor ( )
inlinevirtual

Definition at line 25 of file CaloExtractor.h.

25 {}

Member Function Documentation

IsoDeposit CaloExtractor::deposit ( const edm::Event ev,
const edm::EventSetup evSetup,
const reco::Track track 
) const
virtual

make single IsoDeposit based on track as input purely virtual: have to implement in concrete implementations

make this abit faster

Implements reco::isodeposit::IsoDepositExtractor.

Definition at line 95 of file CaloExtractor.cc.

References ecalTB2006H4_GenSimDigiReco_cfg::bField, reco::deltaR(), PV3DBase< T, PVType, FrameType >::eta(), reco::TrackBase::eta(), spr::find(), edm::EventSetup::get(), LogDebug, MuonAtCaloPosition(), noiseEcal(), noiseHcal(), PV3DBase< T, PVType, FrameType >::phi(), reco::TrackBase::phi(), reco::TrackBase::pt(), theCaloTowerCollectionLabel, theDR_Max, theDR_Veto_E, theDR_Veto_H, theThreshold_E, theThreshold_H, theVetoCollection, theWeight_E, theWeight_H, vertexConstraintFlag_XY, and vertexConstraintFlag_Z.

96 {
97  IsoDeposit dep(muon.eta(), muon.phi() );
98  LogDebug("Muon|RecoMuon|L2MuonIsolationProducer")
99  << " >>> Muon: pt " << muon.pt()
100  << " eta " << muon.eta()
101  << " phi " << muon.phi();
102 
104  event.getByLabel(theCaloTowerCollectionLabel,towers);
105 
107  eventSetup.get<CaloGeometryRecord>().get(caloGeom);
108 
110  eventSetup.get<IdealMagneticFieldRecord>().get(bField);
111  double bz = bField->inInverseGeV(GlobalPoint(0.,0.,0.)).z();
112 
114  CaloTowerCollection::const_iterator calEnd(towers->end());
115  for ( cal = towers->begin(); cal != calEnd; ++cal ) {
117  double dEta = fabs(muon.eta()-cal->eta());
118  if (fabs(dEta) > theDR_Max) continue;
119 
120  double deltar0 = reco::deltaR(muon,*cal);
121  if (deltar0>theDR_Max) continue;
122 
123  double etecal = cal->emEt();
124  double eecal = cal->emEnergy();
125  bool doEcal = theWeight_E>0 && etecal>theThreshold_E && eecal>3*noiseEcal(*cal);
126  double ethcal = cal->hadEt();
127  double ehcal = cal->hadEnergy();
128  bool doHcal = theWeight_H>0 && ethcal>theThreshold_H && ehcal>3*noiseHcal(*cal);
129  if ((!doEcal) && (!doHcal)) continue;
130 
131  DetId calId = cal->id();
132  GlobalPoint endpos = caloGeom->getPosition(calId);
134  double deltar = reco::deltaR(muatcal,endpos);
135 
136  if (deltar<theDR_Veto_H) {
137  dep.setVeto(IsoDeposit::Veto(reco::isodeposit::Direction(muatcal.eta(), muatcal.phi()), theDR_Veto_H));
138  }
139 
140  if (doEcal) {
141  if (deltar<theDR_Veto_E) {
142  double calodep = theWeight_E*etecal;
143  if (doHcal) calodep += theWeight_H*ethcal;
144  dep.addCandEnergy(calodep);
145  LogDebug("Muon|RecoMuon|L2MuonIsolationProducer")
146  << " >>> Calo deposit inside veto (with ECAL): deltar " << deltar
147  << " calodep " << calodep
148  << " ecaldep " << etecal
149  << " hcaldep " << ethcal
150  << " eta " << cal->eta()
151  << " phi " << cal->phi();
152  continue;
153  }
154  } else {
155  if (deltar<theDR_Veto_H) {
156  dep.addCandEnergy(theWeight_H*ethcal);
157  LogDebug("Muon|RecoMuon|L2MuonIsolationProducer")
158  << " >>> Calo deposit inside veto (no ECAL): deltar " << deltar
159  << " calodep " << theWeight_H*ethcal
160  << " eta " << cal->eta()
161  << " phi " << cal->phi();
162  continue;
163  }
164  }
165 
167  , calId)!=theVetoCollection.end()) {
168  LogDebug("Muon|RecoMuon|L2MuonIsolationProducer")
169  << " >>> Deposits belongs to other track: deltar, etecal, ethcal= "
170  << deltar << ", " << etecal << ", " << ethcal;
171  continue;
172  }
173 
174  if (doEcal) {
175  if (deltar>theDR_Veto_E) {
176  double calodep = theWeight_E*etecal;
177  if (doHcal) calodep += theWeight_H*ethcal;
178  dep.addDeposit(reco::isodeposit::Direction(endpos.eta(), endpos.phi()),calodep);
179  LogDebug("Muon|RecoMuon|L2MuonIsolationProducer")
180  << " >>> Calo deposit (with ECAL): deltar " << deltar
181  << " calodep " << calodep
182  << " ecaldep " << etecal
183  << " hcaldep " << ethcal
184  << " eta " << cal->eta()
185  << " phi " << cal->phi();
186  }
187  } else {
188  if (deltar>theDR_Veto_H) {
189  dep.addDeposit(reco::isodeposit::Direction(endpos.eta(), endpos.phi()),theWeight_H*ethcal);
190  LogDebug("Muon|RecoMuon|L2MuonIsolationProducer")
191  << " >>> Calo deposit (no ECAL): deltar " << deltar
192  << " calodep " << theWeight_H*ethcal
193  << " eta " << cal->eta()
194  << " phi " << cal->phi();
195  }
196  }
197  }
198 
199  return dep;
200 
201 }
#define LogDebug(id)
double noiseEcal(const CaloTower &tower) const
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< CaloTower >::const_iterator const_iterator
edm::InputTag theCaloTowerCollectionLabel
Definition: CaloExtractor.h:35
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
double deltaR(double eta1, double phi1, double eta2, double phi2)
Definition: deltaR.h:19
double noiseHcal(const CaloTower &tower) const
Definition: DetId.h:20
static GlobalPoint MuonAtCaloPosition(const reco::Track &muon, const double bz, const GlobalPoint &endpos, bool fixVxy=false, bool fixVz=false)
Extrapolate muons to calorimeter-object positions.
T eta() const
Definition: PV3DBase.h:75
std::vector< DetId > theVetoCollection
Definition: CaloExtractor.h:52
void CaloExtractor::fillVetos ( const edm::Event ev,
const edm::EventSetup evSetup,
const reco::TrackCollection tracks 
)
virtual

fill vetoes: to exclude deposits at IsoDeposit creation stage check concrete extractors if it's no-op !

make this abit faster

Implements reco::isodeposit::IsoDepositExtractor.

Definition at line 43 of file CaloExtractor.cc.

References ecalTB2006H4_GenSimDigiReco_cfg::bField, reco::deltaR(), edm::EventSetup::get(), RPCpg::mu, MuonAtCaloPosition(), noiseEcal(), noiseHcal(), theCaloTowerCollectionLabel, theDR_Max, theDR_Veto_E, theDR_Veto_H, theThreshold_E, theThreshold_H, theVetoCollection, theWeight_E, theWeight_H, vertexConstraintFlag_XY, and vertexConstraintFlag_Z.

44 {
45  theVetoCollection.clear();
46 
48  event.getByLabel(theCaloTowerCollectionLabel,towers);
49 
51  eventSetup.get<CaloGeometryRecord>().get(caloGeom);
52 
54  eventSetup.get<IdealMagneticFieldRecord>().get(bField);
55  double bz = bField->inInverseGeV(GlobalPoint(0.,0.,0.)).z();
56 
57  TrackCollection::const_iterator mu;
58  TrackCollection::const_iterator muEnd(muons.end());
59 
61  CaloTowerCollection::const_iterator calEnd(towers->end());
62 
63  for ( mu = muons.begin(); mu != muEnd; ++mu ) {
64  for ( cal = towers->begin(); cal != calEnd; ++cal ) {
66  double dEta = fabs(mu->eta()-cal->eta());
67  if (fabs(dEta) > theDR_Max) continue;
68 
69  double deltar0 = reco::deltaR(*mu,*cal);
70  if (deltar0>theDR_Max) continue;
71 
72  double etecal = cal->emEt();
73  double eecal = cal->emEnergy();
74  bool doEcal = theWeight_E>0 && etecal>theThreshold_E && eecal>3*noiseEcal(*cal);
75  double ethcal = cal->hadEt();
76  double ehcal = cal->hadEnergy();
77  bool doHcal = theWeight_H>0 && ethcal>theThreshold_H && ehcal>3*noiseHcal(*cal);
78  if ((!doEcal) && (!doHcal)) continue;
79 
80  DetId calId = cal->id();
81  GlobalPoint endpos = caloGeom->getPosition(calId);
83  double deltar = reco::deltaR(muatcal,endpos);
84 
85  if (doEcal) {
86  if (deltar<theDR_Veto_E) theVetoCollection.push_back(calId);
87  } else {
88  if (deltar<theDR_Veto_H) theVetoCollection.push_back(calId);
89  }
90  }
91  }
92 
93 }
double noiseEcal(const CaloTower &tower) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< CaloTower >::const_iterator const_iterator
edm::InputTag theCaloTowerCollectionLabel
Definition: CaloExtractor.h:35
double deltaR(double eta1, double phi1, double eta2, double phi2)
Definition: deltaR.h:19
double noiseHcal(const CaloTower &tower) const
const int mu
Definition: Constants.h:23
Definition: DetId.h:20
static GlobalPoint MuonAtCaloPosition(const reco::Track &muon, const double bz, const GlobalPoint &endpos, bool fixVxy=false, bool fixVz=false)
Extrapolate muons to calorimeter-object positions.
tuple muons
Definition: patZpeak.py:38
std::vector< DetId > theVetoCollection
Definition: CaloExtractor.h:52
GlobalPoint CaloExtractor::MuonAtCaloPosition ( const reco::Track muon,
const double  bz,
const GlobalPoint endpos,
bool  fixVxy = false,
bool  fixVz = false 
)
static

Extrapolate muons to calorimeter-object positions.

Definition at line 203 of file CaloExtractor.cc.

References reco::TrackBase::charge(), funct::cos(), reco::TrackBase::covariance(), reco::TrackBase::dsz(), reco::TrackBase::dxy(), reco::TrackBase::dz(), reco::TrackBase::i_dsz, reco::TrackBase::i_dxy, reco::TrackBase::i_lambda, reco::TrackBase::i_phi, reco::TrackBase::i_qoverp, normalizedPhi(), reco::TrackBase::p(), reco::TrackBase::phi(), funct::pow(), reco::TrackBase::pt(), reco::TrackBase::qoverp(), funct::sin(), funct::tan(), reco::TrackBase::theta(), theta(), reco::TrackBase::vx(), reco::TrackBase::vy(), PV3DBase< T, PVType, FrameType >::x(), vdt::x, detailsBasic3DVector::y, PV3DBase< T, PVType, FrameType >::y(), detailsBasic3DVector::z, and PV3DBase< T, PVType, FrameType >::z().

Referenced by deposit(), and fillVetos().

203  {
204  double qoverp= muon.qoverp();
205  double cur = bz*muon.charge()/muon.pt();
206  double phi0 = muon.phi();
207  double dca = muon.dxy();
208  double theta = muon.theta();
209  double dz = muon.dz();
210 
211  //LogDebug("Muon|RecoMuon|L2MuonIsolationProducer")
212  //<< " Pt(GeV): " << muon.pt()
213  //<< ", phi0 " << muon.phi0()
214  //<< ", eta " << muon.eta();
215  //LogDebug("Muon|RecoMuon|L2MuonIsolationProducer")
216  //<< " d0 " << muon.d0()
217  //<< ", dz " << muon.dz();
218  //LogDebug("Muon|RecoMuon|L2MuonIsolationProducer")
219  //<< " rhocal " << endpos.perp()
220  //<< ", zcal " << endpos.z();
221 
222  if (fixVxy && fixVz) {
223  // Note that here we assume no correlation between XY and Z projections
224  // This should be a reasonable approximation for our purposes
225  double errd02 = muon.covariance(muon.i_dxy,muon.i_dxy);
226  if (pow(muon.dxy(),2)<4*errd02) {
227  phi0 -= muon.dxy()*muon.covariance(muon.i_dxy,muon.i_phi)
228  /errd02;
229  cur -= muon.dxy()*muon.covariance(muon.i_dxy,muon.i_qoverp)
230  /errd02 * (cur/qoverp);
231  dca = 0;
232  }
233  double errdsz2 = muon.covariance(muon.i_dsz,muon.i_dsz);
234  if (pow(muon.dsz(),2)<4*errdsz2) {
235  theta += muon.dsz()*muon.covariance(muon.i_dsz,muon.i_lambda)
236  /errdsz2;
237  dz = 0;
238  }
239  } else if (fixVxy) {
240  double errd02 = muon.covariance(muon.i_dxy,muon.i_dxy);
241  if (pow(muon.dxy(),2)<4*errd02) {
242  phi0 -= muon.dxy()*muon.covariance(muon.i_dxy,muon.i_phi)
243  /errd02;
244  cur -= muon.dxy()*muon.covariance(muon.i_dxy,muon.i_qoverp)
245  /errd02 * (cur/qoverp);
246  theta += muon.dxy()*muon.covariance(muon.i_dxy,muon.i_lambda)
247  /errd02;
248  dz -= muon.dxy()*muon.covariance(muon.i_dxy,muon.i_dsz)
249  /errd02 * muon.p()/muon.pt();
250  dca = 0;
251  }
252  } else if (fixVz) {
253  double errdsz2 = muon.covariance(muon.i_dsz,muon.i_dsz);
254  if (pow(muon.dsz(),2)<4*errdsz2) {
255  theta += muon.dsz()*muon.covariance(muon.i_dsz,muon.i_lambda)
256  /errdsz2;
257  phi0 -= muon.dsz()*muon.covariance(muon.i_dsz,muon.i_phi)
258  /errdsz2;
259  cur -= muon.dsz()*muon.covariance(muon.i_dsz,muon.i_qoverp)
260  /errdsz2 * (cur/qoverp);
261  dca -= muon.dsz()*muon.covariance(muon.i_dsz,muon.i_dxy)
262  /errdsz2;
263  dz = 0;
264  }
265  }
266 
267  double sphi0 = sin(phi0);
268  double cphi0 = cos(phi0);
269 
270  double xsin = endpos.x()*sphi0 - endpos.y()*cphi0;
271  double xcos = endpos.x()*cphi0 + endpos.y()*sphi0;
272  double fcdca = fabs(1-cur*dca);
273  double phif = atan2( fcdca*sphi0-cur*endpos.x()
274  , fcdca*cphi0+cur*endpos.y());
275  double tphif2 = tan(0.5*(phif-phi0));
276  double dcaf = dca + xsin + xcos*tphif2;
277 
278  double x = endpos.x() - dcaf*sin(phif);
279  double y = endpos.y() + dcaf*cos(phif);
280 
281  double deltas = (x-muon.vx())*cphi0 + (y-muon.vy())*sphi0;
282  double deltaphi = normalizedPhi(phif-phi0);
283  if (deltaphi!=0) deltas = deltas*deltaphi/sin(deltaphi);
284 
285  double z =dz;
286  double tantheta = tan(theta);
287  if (tantheta!=0) {
288  z += deltas/tan(theta);
289  } else {
290  z = endpos.z();
291  }
292 
293  return GlobalPoint(x,y,z);
294 }
double qoverp() const
q/p
Definition: TrackBase.h:115
double p() const
momentum vector magnitude
Definition: TrackBase.h:129
double theta() const
polar angle
Definition: TrackBase.h:117
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Geom::Theta< T > theta() const
T y() const
Definition: PV3DBase.h:62
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:139
double dsz() const
dsz parameter (THIS IS NOT the SZ impact parameter to (0,0,0) if refPoint is far from (0...
Definition: TrackBase.h:125
double double double z
CovarianceMatrix covariance() const
return track covariance matrix
Definition: TrackBase.h:182
double pt() const
track transverse momentum
Definition: TrackBase.h:131
T z() const
Definition: PV3DBase.h:63
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:127
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:145
int charge() const
track electric charge
Definition: TrackBase.h:113
x
Definition: VDTMath.h:216
double normalizedPhi(double phi)
Definition: normalizedPhi.cc:5
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:121
T x() const
Definition: PV3DBase.h:61
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double vx() const
x coordinate of the reference point on track
Definition: TrackBase.h:143
double CaloExtractor::noiseEcal ( const CaloTower tower) const
private

Definition at line 296 of file CaloExtractor.cc.

References reco::LeafCandidate::eta(), and eta().

Referenced by deposit(), and fillVetos().

296  {
297  double noise = 0.04;
298  double eta = tower.eta();
299  if (fabs(eta)>1.479) noise = 0.15;
300  return noise;
301 }
T eta() const
virtual double eta() const
momentum pseudorapidity
double CaloExtractor::noiseHcal ( const CaloTower tower) const
private

Definition at line 303 of file CaloExtractor.cc.

Referenced by deposit(), and fillVetos().

303  {
304  double noise = 0.2;
305  return noise;
306 }

Member Data Documentation

edm::InputTag muonisolation::CaloExtractor::theCaloTowerCollectionLabel
private

Definition at line 35 of file CaloExtractor.h.

Referenced by deposit(), and fillVetos().

std::string muonisolation::CaloExtractor::theDepositLabel
private

Definition at line 38 of file CaloExtractor.h.

double muonisolation::CaloExtractor::theDR_Max
private

Definition at line 47 of file CaloExtractor.h.

Referenced by deposit(), and fillVetos().

double muonisolation::CaloExtractor::theDR_Veto_E
private

Definition at line 45 of file CaloExtractor.h.

Referenced by deposit(), and fillVetos().

double muonisolation::CaloExtractor::theDR_Veto_H
private

Definition at line 46 of file CaloExtractor.h.

Referenced by deposit(), and fillVetos().

double muonisolation::CaloExtractor::theThreshold_E
private

Definition at line 43 of file CaloExtractor.h.

Referenced by deposit(), and fillVetos().

double muonisolation::CaloExtractor::theThreshold_H
private

Definition at line 44 of file CaloExtractor.h.

Referenced by deposit(), and fillVetos().

std::vector<DetId> muonisolation::CaloExtractor::theVetoCollection
private

Definition at line 52 of file CaloExtractor.h.

Referenced by deposit(), and fillVetos().

double muonisolation::CaloExtractor::theWeight_E
private

Definition at line 41 of file CaloExtractor.h.

Referenced by deposit(), and fillVetos().

double muonisolation::CaloExtractor::theWeight_H
private

Definition at line 42 of file CaloExtractor.h.

Referenced by deposit(), and fillVetos().

bool muonisolation::CaloExtractor::vertexConstraintFlag_XY
private

Definition at line 48 of file CaloExtractor.h.

Referenced by deposit(), and fillVetos().

bool muonisolation::CaloExtractor::vertexConstraintFlag_Z
private

Definition at line 49 of file CaloExtractor.h.

Referenced by deposit(), and fillVetos().