CMS 3D CMS Logo

PFCluster.cc
Go to the documentation of this file.
2 
3 #include "vdt/vdtMath.h"
4 #include "Math/GenVector/etaMax.h"
5 
6 namespace {
7 
8  // an implementation of Eta_FromRhoZ of root libraries using vdt
9  template <typename Scalar>
10  inline Scalar Eta_FromRhoZ_fast(Scalar rho, Scalar z) {
11  using namespace ROOT::Math;
12  // value to control Taylor expansion of sqrt
13  const Scalar big_z_scaled = std::pow(std::numeric_limits<Scalar>::epsilon(), static_cast<Scalar>(-.25));
14  if (rho > 0) {
15  Scalar z_scaled = z / rho;
16  if (std::fabs(z_scaled) < big_z_scaled) {
17  return vdt::fast_log(z_scaled + std::sqrt(z_scaled * z_scaled + 1.0));
18  } else {
19  // apply correction using first order Taylor expansion of sqrt
20  return z > 0 ? vdt::fast_log(2.0 * z_scaled + 0.5 / z_scaled) : -vdt::fast_log(-2.0 * z_scaled);
21  }
22  }
23  // case vector has rho = 0
24  else if (z == 0) {
25  return 0;
26  } else if (z > 0) {
27  return z + etaMax<Scalar>();
28  } else {
29  return z - etaMax<Scalar>();
30  }
31  }
32 } // namespace
33 
34 using namespace std;
35 using namespace reco;
36 
37 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
38 std::atomic<int> PFCluster::depthCorMode_{0};
39 std::atomic<double> PFCluster::depthCorA_{0.89};
40 std::atomic<double> PFCluster::depthCorB_{7.3};
41 std::atomic<double> PFCluster::depthCorAp_{0.89};
42 std::atomic<double> PFCluster::depthCorBp_{4.0};
43 #else
44 int PFCluster::depthCorMode_ = 0;
45 double PFCluster::depthCorA_ = 0.89;
46 double PFCluster::depthCorB_ = 7.3;
47 double PFCluster::depthCorAp_ = 0.89;
48 double PFCluster::depthCorBp_ = 4.0;
49 #endif
50 
51 const math::XYZPoint PFCluster::dummyVtx_(0, 0, 0);
52 
53 PFCluster::PFCluster(PFLayer::Layer layer, double energy, double x, double y, double z)
54  : CaloCluster(energy, math::XYZPoint(x, y, z), PFLayer::toCaloID(layer), CaloCluster::particleFlow),
55  posrep_(position_.Rho(), position_.Eta(), position_.Phi()),
56  time_(-99.),
57  depth_(0.),
58  layer_(layer),
59  color_(2) {}
60 
62  energy_ = 0;
63  position_ *= 0;
64  posrep_ *= 0;
65  time_ = -99.;
67  rechits_.clear();
68 
70 }
71 
73  rechits_.clear();
74  hitsAndFractions_.clear();
75 }
76 
78  rechits_.push_back(frac);
79 
80  addHitAndFraction(frac.recHitRef()->detId(), frac.fraction());
81 }
82 
83 double PFCluster::getDepthCorrection(double energy, bool isBelowPS, bool isHadron) {
84  double corrA = depthCorA_;
85  double corrB = depthCorB_;
86  if (isBelowPS) {
87  corrA = depthCorAp_;
88  corrB = depthCorBp_;
89  }
90  return isHadron ? corrA : corrA * (corrB + log(energy));
91 }
92 
94  // cout<<"calling PFCluster::setLayer "<<layer<<endl;
95  layer_ = layer;
97  // cout<<"done "<<caloID_<<endl;
98 }
99 
101  // cout<<"calling PFCluster::layer "<<caloID()<<" "<<PFLayer::fromCaloID( caloID() )<<endl;
102  if (layer_ != PFLayer::NONE)
103  return layer_;
104  return PFLayer::fromCaloID(caloID());
105 }
106 
108  CaloCluster::operator=(other);
109  rechits_ = other.rechits_;
110  energy_ = other.energy_;
111  position_ = other.position_;
112  posrep_ = other.posrep_;
113  color_ = other.color_;
114 
115  return *this;
116 }
117 
118 std::ostream& reco::operator<<(std::ostream& out, const PFCluster& cluster) {
119  if (!out)
120  return out;
121 
122  const math::XYZPoint& pos = cluster.position();
123  const PFCluster::REPPoint& posrep = cluster.positionREP();
124  const std::vector<reco::PFRecHitFraction>& fracs = cluster.recHitFractions();
125 
126  out << "PFcluster "
127  << ", layer: " << cluster.layer() << "\tE = " << cluster.energy() << "\tXYZ: " << pos.X() << "," << pos.Y() << ","
128  << pos.Z() << " | "
129  << "\tREP: " << posrep.Rho() << "," << posrep.Eta() << "," << posrep.Phi() << " | " << fracs.size() << " rechits";
130 
131  for (unsigned i = 0; i < fracs.size(); i++) {
132  // PFRecHit is not available, print the detID
133  if (!fracs[i].recHitRef().isAvailable())
134  out << cluster.printHitAndFraction(i) << ", ";
135  else
136  out << fracs[i] << ", ";
137  }
138 
139  return out;
140 }
mps_fire.i
i
Definition: mps_fire.py:355
detailsBasic3DVector::z
float float float z
Definition: extBasic3DVector.h:14
reco::PFRecHitFraction
Fraction of a PFRecHit (rechits can be shared between several PFCluster's)
Definition: PFRecHitFraction.h:18
reco::PFCluster::layer
PFLayer::Layer layer() const
cluster layer, see PFLayer.h in this directory
Definition: PFCluster.cc:100
PFLayer::toCaloID
static reco::CaloID toCaloID(Layer layer)
Definition: PFLayer.cc:11
cropTnPTrees.frac
frac
Definition: cropTnPTrees.py:18
reco::PFCluster::depthCorAp_
static std::atomic< double > depthCorAp_
Definition: PFCluster.h:185
pos
Definition: PixelAliasList.h:18
ZElectronSkim_cff.rho
rho
Definition: ZElectronSkim_cff.py:38
reco::PFCluster::setLayer
void setLayer(PFLayer::Layer layer)
set layer
Definition: PFCluster.cc:93
reco::PFCluster::recHitFractions
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
Definition: PFCluster.h:69
reco::PFCluster::depthCorB_
static std::atomic< double > depthCorB_
Definition: PFCluster.h:182
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
reco::CaloCluster::hitsAndFractions_
std::vector< std::pair< DetId, float > > hitsAndFractions_
Definition: CaloCluster.h:234
geometryDiff.epsilon
int epsilon
Definition: geometryDiff.py:26
align::Scalar
double Scalar
Definition: Definitions.h:25
reco::PFCluster::layer_
PFLayer::Layer layer_
transient layer
Definition: PFCluster.h:172
reco::CaloCluster::position_
math::XYZPoint position_
cluster centroid position
Definition: CaloCluster.h:228
reco::PFCluster::energy
double energy() const
cluster energy
Definition: PFCluster.h:78
reco::CaloCluster::caloID_
CaloID caloID_
bitmask for detector information
Definition: CaloCluster.h:231
reco::PFCluster::operator=
PFCluster & operator=(const PFCluster &)
Definition: PFCluster.cc:107
reco::CaloCluster
Definition: CaloCluster.h:31
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
PFCluster.h
reco::CaloCluster::reset
void reset()
resets the CaloCluster (position, energy, hitsAndFractions)
Definition: CaloCluster.cc:9
trackingPlots.other
other
Definition: trackingPlots.py:1465
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
reco::PFCluster::resetHitsAndFractions
void resetHitsAndFractions()
reset only hits and fractions
Definition: PFCluster.cc:72
VtxSmearedParameters_cfi.Phi
Phi
Definition: VtxSmearedParameters_cfi.py:112
PFLayer::NONE
Definition: PFLayer.h:34
pfLinker_cff.particleFlow
particleFlow
Definition: pfLinker_cff.py:5
reco::PFCluster::positionREP
const REPPoint & positionREP() const
cluster position: rho, eta, phi
Definition: PFCluster.h:96
ROOT::Math
Definition: Transform3DPJ.h:41
reco::PFCluster::rechits_
std::vector< reco::PFRecHitFraction > rechits_
vector of rechit fractions (transient)
Definition: PFCluster.h:162
PFLayer::Layer
Layer
layer definition
Definition: PFLayer.h:29
reco::PFCluster::reset
void reset()
resets clusters parameters
Definition: PFCluster.cc:61
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
reco::CaloCluster::printHitAndFraction
std::string printHitAndFraction(unsigned i) const
print hitAndFraction
Definition: CaloCluster.cc:15
reco::CaloCluster::addHitAndFraction
void addHitAndFraction(DetId id, float fraction)
Definition: CaloCluster.h:203
reco::PFCluster::getDepthCorrection
static double getDepthCorrection(double energy, bool isBelowPS=false, bool isHadron=false)
Definition: PFCluster.cc:83
reco::operator<<
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:66
PFLayer
layer definition for PFRecHit and PFCluster
Definition: PFLayer.h:20
reco::CaloCluster::position
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:154
reco::PFCluster::addRecHitFraction
void addRecHitFraction(const reco::PFRecHitFraction &frac)
add a given fraction of the rechit
Definition: PFCluster.cc:77
std
Definition: JetResolutionObject.h:76
reco::PFCluster::time_
float time_
Michalis :Add timing and depth information.
Definition: PFCluster.h:168
math
Definition: choleskyInversion.h:19
reco::CaloCluster::energy_
double energy_
cluster energy
Definition: CaloCluster.h:223
reco::PFCluster
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:46
reco::CaloCluster::caloID
const CaloID & caloID() const
Definition: CaloCluster.h:201
reco::PFCluster::posrep_
REPPoint posrep_
cluster position: rho, eta, phi (transient)
Definition: PFCluster.h:165
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
reco::PFCluster::color_
int color_
color (transient)
Definition: PFCluster.h:209
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
reco::PFCluster::depthCorA_
static std::atomic< double > depthCorA_
Definition: PFCluster.h:179
reco::PFCluster::REPPoint
ROOT::Math::PositionVector3D< ROOT::Math::CylindricalEta3D< double > > REPPoint
Definition: PFCluster.h:52
sistrip::layer_
static const char layer_[]
Definition: ConstantsForGranularity.h:30
reco::PFCluster::depthCorBp_
static std::atomic< double > depthCorBp_
Definition: PFCluster.h:188
PFLayer::fromCaloID
static Layer fromCaloID(const reco::CaloID &id)
Definition: PFLayer.cc:38