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;
96  caloID_ = PFLayer::toCaloID(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 }
PFLayer::Layer layer() const
cluster layer, see PFLayer.h in this directory
Definition: PFCluster.cc:100
void setLayer(PFLayer::Layer layer)
set layer
Definition: PFCluster.cc:93
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:153
math::XYZPoint position_
cluster centroid position
Definition: CaloCluster.h:227
static const char layer_[]
CaloID caloID_
bitmask for detector information
Definition: CaloCluster.h:230
void addHitAndFraction(DetId id, float fraction)
Definition: CaloCluster.h:202
double energy_
cluster energy
Definition: CaloCluster.h:222
static std::atomic< double > depthCorAp_
Definition: PFCluster.h:185
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:46
double Scalar
Definition: Definitions.h:25
PFLayer::Layer layer_
transient layer
Definition: PFCluster.h:172
Fraction of a PFRecHit (rechits can be shared between several PFCluster&#39;s)
PFCluster & operator=(const PFCluster &)
Definition: PFCluster.cc:107
static std::atomic< double > depthCorB_
Definition: PFCluster.h:182
double fraction() const
float float float z
std::vector< reco::PFRecHitFraction > rechits_
vector of rechit fractions (transient)
Definition: PFCluster.h:162
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:66
const CaloID & caloID() const
Definition: CaloCluster.h:200
T sqrt(T t)
Definition: SSEVec.h:19
const REPPoint & positionREP() const
cluster position: rho, eta, phi
Definition: PFCluster.h:96
layer definition for PFRecHit and PFCluster
Definition: PFLayer.h:20
void reset()
resets clusters parameters
Definition: PFCluster.cc:61
double energy() const
cluster energy
Definition: PFCluster.h:78
Definition: Error.h:15
std::vector< std::pair< DetId, float > > hitsAndFractions_
Definition: CaloCluster.h:233
void resetHitsAndFractions()
reset only hits and fractions
Definition: PFCluster.cc:72
std::string printHitAndFraction(unsigned i) const
print hitAndFraction
Definition: CaloCluster.cc:15
Layer
layer definition
Definition: PFLayer.h:29
static reco::CaloID toCaloID(Layer layer)
Definition: PFLayer.cc:11
static double getDepthCorrection(double energy, bool isBelowPS=false, bool isHadron=false)
Definition: PFCluster.cc:83
REPPoint posrep_
cluster position: rho, eta, phi (transient)
Definition: PFCluster.h:165
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
Definition: PFCluster.h:69
void addRecHitFraction(const reco::PFRecHitFraction &frac)
add a given fraction of the rechit
Definition: PFCluster.cc:77
static std::atomic< double > depthCorBp_
Definition: PFCluster.h:188
fixed size matrix
int color_
color (transient)
Definition: PFCluster.h:209
float time_
Michalis :Add timing and depth information.
Definition: PFCluster.h:168
static std::atomic< double > depthCorA_
Definition: PFCluster.h:179
static Layer fromCaloID(const reco::CaloID &id)
Definition: PFLayer.cc:38
ROOT::Math::PositionVector3D< ROOT::Math::CylindricalEta3D< double > > REPPoint
Definition: PFCluster.h:52
const PFRecHitRef & recHitRef() const
void reset()
resets the CaloCluster (position, energy, hitsAndFractions)
Definition: CaloCluster.cc:9
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30