24 static const double depth;
25 static const double R_BARREL;
26 static const double R_BARREL2;
27 static const double Z_ENDCAP;
28 static const double R_FORWARD;
29 static const double R_FORWARD2;
30 static const double Z_FORWARD;
31 static const double Z_BIG;
35 const double CaloPoint::R_BARREL = (1.-
depth)*143.+
depth*407.;
36 const double CaloPoint::R_BARREL2 = R_BARREL * R_BARREL;
37 const double CaloPoint::Z_ENDCAP = (1.-
depth)*320.+
depth*568.;
38 const double CaloPoint::R_FORWARD = Z_ENDCAP /
std::sqrt (std::cosh(3.)*std::cosh(3.) -1.);
39 const double CaloPoint::R_FORWARD2 = R_FORWARD * R_FORWARD;
40 const double CaloPoint::Z_FORWARD = 1100.+
depth*165.;
41 const double CaloPoint::Z_BIG = 1.e5;
46 CaloPointZ (
double fZ,
double fEta){
48 static const double ETA_MAX = 5.2;
50 if (fZ > Z_ENDCAP) fZ = Z_ENDCAP-1.;
51 if (fZ < -Z_ENDCAP) fZ = -Z_ENDCAP+1;
53 double tanThetaAbs =
std::sqrt (std::cosh(fEta)*std::cosh(fEta) - 1.);
54 double tanTheta = fEta >= 0 ? tanThetaAbs : -tanThetaAbs;
56 double rEndcap = tanTheta == 0 ? 1.e10 :
57 fEta > 0 ? (Z_ENDCAP - fZ) / tanTheta : (-Z_ENDCAP - fZ) / tanTheta;
58 if (rEndcap > R_BARREL) {
60 mZ = fZ + R_BARREL * tanTheta;
64 if (rEndcap > R_FORWARD) zRef = Z_ENDCAP;
65 else if (std::fabs (fEta) < ETA_MAX) zRef = Z_FORWARD;
67 mZ = fEta > 0 ? zRef : -zRef;
68 mR = std::fabs ((mZ - fZ) / tanTheta);
71 double etaReference (
double fZ) {
76 double thetaReference (
double fZ) {
81 double z()
const {
return mZ;}
82 double r()
const {
return mR;}
91 template<
typename Po
int>
94 template<
typename Vector,
typename Po
int2>
95 CaloPoint3D(
const Point2 &vertex,
const Vector &
dir)
100 int side = dir.z() < -1
e-9 ? -1 : dir.z() > 1
e-9 ? +1 : 0;
102 double dirR = dir.Rho();
105 double dirUnit[2] = { dir.x() / dirR, dir.y() / dirR };
110 double vtxLong = dirUnit[0] * vertex.x() + dirUnit[1] * vertex.y();
113 double tIP = dirUnit[0] * vertex.y() - dirUnit[1] * vertex.x();
119 double slope = dirR / dir.z();
122 r = vtxLong + slope * (side * Z_ENDCAP - vertex.z());
125 if (r2 < R_FORWARD2) {
127 r = vtxLong + slope * (side * Z_FORWARD - vertex.z());
128 z = side * Z_FORWARD;
129 }
else if (r2 < R_BARREL2) {
140 double slope = dir.z() / dirR;
142 z = vertex.z() + slope * (r - vtxLong);
146 point =
Point(dirUnit[0] * r - dirUnit[1] * tIP,
147 dirUnit[1] * r + dirUnit[0] * tIP,
151 const Point &caloPoint()
const {
return point; }
163 const Point& fVertex,
164 const Constituents& fConstituents)
170 for (
unsigned i = 0;
i < fConstituents.size ();
i++) {
176 const Point& fVertex)
186 double phiRef =
phi();
192 double sumEtaPhi = 0;
193 int i = towers.size();
195 double eta = towers[
i]->eta();
197 double weight = towers[
i]->et();
200 sumEta2 += eta * eta *
weight;
202 sumPhi2 += phi * phi *
weight;
203 sumEtaPhi += eta * phi *
weight;
205 Jet::EtaPhiMoments
result;
207 result.etaMean = sumEta / sumw;
208 result.phiMean =
deltaPhi (phiRef + sumPhi, 0.);
209 result.etaEtaMoment = (sumEta2 - sumEta * sumEta / sumw) / sumw;
210 result.phiPhiMoment = (sumPhi2 - sumPhi * sumPhi / sumw) / sumw;
211 result.etaPhiMoment = (sumEtaPhi - sumEta * sumPhi / sumw) / sumw;
216 result.etaEtaMoment = 0;
217 result.phiPhiMoment = 0;
218 result.etaPhiMoment = 0;
229 int i = towers.size();
231 double value = towers[
i]->eta();
232 double weight = towers[
i]->et();
235 sum2 += value * value *
weight;
237 return sumw > 0 ? (sum2 - sum*sum/sumw ) / sumw : 0;
242 double phiRef =
phi();
247 int i = towers.size();
249 double value =
deltaPhi (towers[i]->
phi(), phiRef);
250 double weight = towers[
i]->et();
253 sum2 += value * value *
weight;
255 return sumw > 0 ? (sum2 - sum*sum/sumw ) / sumw : 0;
260 double phiRef =
phi();
266 int i = towers.size();
268 double valueA = towers[
i]->eta();
269 double valueB =
deltaPhi (towers[i]->
phi(), phiRef);
270 double weight = towers[
i]->et();
274 sumAB += valueA * valueB *
weight;
276 return sumw > 0 ? (sumAB - sumA*sumB/sumw ) / sumw : 0;
283 int i = towers.size ();
285 double r =
deltaR (*
this, *(towers[i]));
286 if (r >= fRmin && r < fRmax) result += towers[
i]->et ();
294 if (fFraction >= 1)
return towers.size();
296 for (
unsigned i = 0; i < towers.size(); ++
i) totalEt += towers[i]->
et();
297 double fractionEnergy = totalEt * fFraction;
299 for (; result < towers.size(); ++
result) {
300 fractionEnergy -= towers[
result]->et();
301 if (fractionEnergy <= 0)
return result+1;
310 for (
unsigned i = 0; i < towers.size(); ++
i) {
311 float dR =
deltaR (*(towers[i]), *
this);
312 if (dR > result) result =
dR;
320 CaloPointZ refPoint (0., fDetectorEta);
321 return refPoint.etaReference (fZVertex);
327 CaloPointZ refPoint (fZVertex, fPhysicsEta);
328 return refPoint.etaReference (0.);
332 CaloPoint3D<Point> caloPoint(oldVertex,inParticle.
momentum());
333 Vector physicsDir = caloPoint.caloPoint() - newVertex;
341 CaloPoint3D<Point> caloPoint(vertex,inParticle.
momentum());
343 Vector detectorDir = caloPoint.caloPoint() -
np;
344 double p = inParticle.
momentum().r();
345 Vector p3 = p * detectorDir.unit();
360 std::vector<const Candidate*>
result;
362 for (
int i = 0; i < nDaughters; ++
i) {
365 edm::LogInfo(
"JetConstituentPointer") <<
"Bad pointer to jet constituent found. Check for possible dropped particle.";
382 for(
unsigned iConst=0; iConst<constituents.size(); ++iConst ) {
384 float pt = constituents[iConst]->p4().Pt();
392 float ptD_value = (sum_pt>0.) ?
sqrt( sum_pt2 / (sum_pt*sum_pt) ) : 0.;
406 float sum_pt2deltaR2 = 0.;
408 for(
unsigned iConst=0; iConst<constituents.size(); ++iConst ) {
412 float pt = thisConstituent.Pt();
414 double dR =
deltaR (*
this, *(constituents[iConst]));
415 float pt2deltaR2 = pt*pt*dR*
dR;
418 sum_pt2deltaR2 += pt2deltaR2;
422 float rmsCand_value = (sum_pt2>0.) ? sum_pt2deltaR2/sum_pt2 : 0.;
424 return rmsCand_value;
431 std::ostringstream
out;
432 out <<
"Jet p/px/py/pz/pt: " <<
p() <<
'/' <<
px () <<
'/' <<
py() <<
'/' <<
pz() <<
'/' <<
pt() << std::endl
433 <<
" eta/phi: " <<
eta () <<
'/' <<
phi () << std::endl
435 out <<
" Constituents:" << std::endl;
438 if (constituent.isNonnull()) {
439 out <<
" #" <<
index <<
" p/pt/eta/phi: " 440 << constituent->p() <<
'/' << constituent->pt() <<
'/' << constituent->eta() <<
'/' << constituent->phi()
441 <<
" productId/index: " << constituent.id() <<
'/' << constituent.key() << std::endl;
444 out <<
" #" <<
index <<
" constituent is not available in the event" << std::endl;
float etInAnnulus(float fRmin, float fRmax) const
ET in annulus between rmin and rmax around jet direction.
static float detectorEta(float fZVertex, float fPhysicsEta)
static function to convert physics eta to detector eta
float constituentEtaPhiSpread() const
double eta() const final
momentum pseudorapidity
virtual void scaleEnergy(double fScale)
scale energy of the jet
CandidatePtr daughterPtr(size_type i) const
reference to daughter at given position
static const double slope[3]
double px() const final
x coordinate of momentum vector
std::vector< Constituent > Constituents
double pt() const final
transverse momentum
float etaetaMoment() const
eta-eta second moment, ET weighted
virtual Constituents getJetConstituents() const
list of constituents
size_t numberOfDaughters() const override
number of daughters
virtual double energy() const =0
energy
bool isJet() const override
virtual std::string print() const
Print object.
double et() const final
transverse energy
double pz() const final
z coordinate of momentum vector
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
math::XYZTLorentzVector LorentzVector
const LorentzVector & p4() const final
four-momentum Lorentz vector
edm::Ptr< Candidate > Constituent
double deltaPhi(double phi1, double phi2)
double p() const final
magnitude of momentum vector
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
EtaPhiMoments etaPhiStatistics() const
eta-phi statistics, ET weighted
static Candidate::LorentzVector detectorP4(const Candidate::Point &vertex, const Candidate &inParticle)
float etaphiMoment() const
eta-phi second moment, ET weighted
double py() const final
y coordinate of momentum vector
float maxDistance() const
maximum distance from jet to constituent
int nCarrying(float fFraction) const
return # of constituent carrying fraction of energy
math::XYZTLorentzVector LorentzVector
Lorentz vector.
virtual Vector momentum() const =0
spatial momentum vector
float constituentPtDistribution() const
float phiphiMoment() const
phi-phi second moment, ET weighted
virtual int nConstituents() const
of constituents
Square< F >::type sqr(const F &f)
CandidatePtr sourceCandidatePtr(size_type i) const override
void addDaughter(const CandidatePtr &)
add a daughter via a reference
Jet()
Default constructor.
math::XYZPoint Point
point in the space
static Candidate::LorentzVector physicsP4(const Candidate::Point &newVertex, const Candidate &inParticle, const Candidate::Point &oldVertex=Candidate::Point(0, 0, 0))
virtual std::vector< const reco::Candidate * > getJetConstituentsQuick() const
quick list of constituents
double phi() const final
momentum azimuthal angle
static float physicsEta(float fZVertex, float fDetectorEta)
static function to convert detector eta to physics eta
void setP4(const LorentzVector &p4) final
set 4-momentum
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
math::XYZPoint Point
point in the space