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 =
14  std::pow(std::numeric_limits<Scalar>::epsilon(),static_cast<Scalar>(-.25));
15  if (rho > 0) {
16  Scalar z_scaled = z/rho;
17  if (std::fabs(z_scaled) < big_z_scaled) {
18  return vdt::fast_log(z_scaled+std::sqrt(z_scaled*z_scaled+1.0));
19  } else {
20  // apply correction using first order Taylor expansion of sqrt
21  return z>0 ? vdt::fast_log(2.0*z_scaled + 0.5/z_scaled) : -vdt::fast_log(-2.0*z_scaled);
22  }
23  }
24  // case vector has rho = 0
25  else if (z==0) {
26  return 0;
27  }
28  else if (z>0) {
29  return z + etaMax<Scalar>();
30  }
31  else {
32  return z - etaMax<Scalar>();
33  }
34  }
35 }
36 
37 using namespace std;
38 using namespace reco;
39 
40 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
41 std::atomic<int> PFCluster::depthCorMode_{0};
42 std::atomic<double> PFCluster::depthCorA_{0.89};
43 std::atomic<double> PFCluster::depthCorB_{7.3};
44 std::atomic<double> PFCluster::depthCorAp_{0.89};
45 std::atomic<double> PFCluster::depthCorBp_{4.0};
46 #else
47 int PFCluster::depthCorMode_ = 0;
48 double PFCluster::depthCorA_ = 0.89;
49 double PFCluster::depthCorB_ = 7.3;
50 double PFCluster::depthCorAp_ = 0.89;
51 double PFCluster::depthCorBp_ = 4.0;
52 #endif
53 
54 
55 const math::XYZPoint PFCluster::dummyVtx_(0,0,0);
56 
57 PFCluster::PFCluster(PFLayer::Layer layer, double energy,
58  double x, double y, double z ) :
59  CaloCluster( energy,
60  math::XYZPoint(x,y,z),
61  PFLayer::toCaloID(layer),
63  posrep_( position_.Rho(), position_.Eta(), position_.Phi() ),
64  time_(-99.),
65  depth_(0.),
66  layer_(layer),
67  color_(2)
68 { }
69 
70 
72 
73  energy_ = 0;
74  position_ *= 0;
75  posrep_ *= 0;
76  time_=-99.;
78  rechits_.clear();
79 
81 
82 }
83 
85 
86  rechits_.clear();
87  hitsAndFractions_.clear();
88 
89 }
90 
92 
93  rechits_.push_back( frac );
94 
95  addHitAndFraction( frac.recHitRef()->detId(),
96  frac.fraction() );
97 }
98 
99 
100 double PFCluster::getDepthCorrection(double energy, bool isBelowPS,
101  bool isHadron)
102 {
103  double corrA = depthCorA_;
104  double corrB = depthCorB_;
105  if (isBelowPS) {
106  corrA = depthCorAp_;
107  corrB = depthCorBp_;
108  }
109  return isHadron ? corrA : corrA*(corrB + log(energy));
110 }
111 
113  // cout<<"calling PFCluster::setLayer "<<layer<<endl;
114  layer_ = layer;
115  caloID_ = PFLayer::toCaloID( layer );
116  // cout<<"done "<<caloID_<<endl;
117 }
118 
119 
121 
122  // cout<<"calling PFCluster::layer "<<caloID()<<" "<<PFLayer::fromCaloID( caloID() )<<endl;
123  if( layer_ != PFLayer::NONE ) return layer_;
124  return PFLayer::fromCaloID( caloID() );
125 }
126 
127 
129 
130  CaloCluster::operator=(other);
131  rechits_ = other.rechits_;
132  energy_ = other.energy_;
133  position_ = other.position_;
134  posrep_ = other.posrep_;
135  color_ = other.color_;
136 
137  return *this;
138 }
139 
140 
141 std::ostream& reco::operator<<(std::ostream& out,
142  const PFCluster& cluster) {
143 
144  if(!out) return out;
145 
146  const math::XYZPoint& pos = cluster.position();
147  const PFCluster::REPPoint& posrep = cluster.positionREP();
148  const std::vector< reco::PFRecHitFraction >& fracs =
149  cluster.recHitFractions();
150 
151  out<<"PFcluster "
152  <<", layer: "<<cluster.layer()
153  <<"\tE = "<<cluster.energy()
154  <<"\tXYZ: "
155  <<pos.X()<<","<<pos.Y()<<","<<pos.Z()<<" | "
156  <<"\tREP: "
157  <<posrep.Rho()<<","<<posrep.Eta()<<","<<posrep.Phi()<<" | "
158  <<fracs.size()<<" rechits";
159 
160  for(unsigned i=0; i<fracs.size(); i++) {
161  // PFRecHit is not available, print the detID
162  if( !fracs[i].recHitRef().isAvailable() )
163  out<<cluster.printHitAndFraction(i)<<", ";
164  else
165  out<<fracs[i]<<", ";
166  }
167 
168  return out;
169 }
PFLayer::Layer layer() const
cluster layer, see PFLayer.h in this directory
Definition: PFCluster.cc:120
void setLayer(PFLayer::Layer layer)
set layer
Definition: PFCluster.cc:112
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:131
math::XYZPoint position_
cluster centroid position
Definition: CaloCluster.h:217
static const char layer_[]
CaloID caloID_
bitmask for detector information
Definition: CaloCluster.h:220
void addHitAndFraction(DetId id, float fraction)
Definition: CaloCluster.h:190
double energy_
cluster energy
Definition: CaloCluster.h:212
static std::atomic< double > depthCorAp_
Definition: PFCluster.h:201
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:47
double Scalar
Definition: Definitions.h:27
std::vector< reco::PFRecHitFraction > rechits_
vector of rechit fractions (transient)
Definition: PFCluster.h:178
PFLayer::Layer layer_
transient layer
Definition: PFCluster.h:188
Fraction of a PFRecHit (rechits can be shared between several PFCluster&#39;s)
PFCluster & operator=(const PFCluster &)
Definition: PFCluster.cc:128
std::vector< std::pair< DetId, float > > hitsAndFractions_
Definition: CaloCluster.h:223
static std::atomic< double > depthCorB_
Definition: PFCluster.h:198
double fraction() const
float float float z
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:71
const CaloID & caloID() const
Definition: CaloCluster.h:188
T sqrt(T t)
Definition: SSEVec.h:18
const REPPoint & positionREP() const
cluster position: rho, eta, phi
Definition: PFCluster.h:97
layer definition for PFRecHit and PFCluster
Definition: PFLayer.h:21
void reset()
resets clusters parameters
Definition: PFCluster.cc:71
double energy() const
cluster energy
Definition: PFCluster.h:82
Definition: Error.h:16
void resetHitsAndFractions()
reset only hits and fractions
Definition: PFCluster.cc:84
std::string printHitAndFraction(unsigned i) const
print hitAndFraction
Definition: CaloCluster.cc:17
Layer
layer definition
Definition: PFLayer.h:31
static reco::CaloID toCaloID(Layer layer)
Definition: PFLayer.cc:11
static double getDepthCorrection(double energy, bool isBelowPS=false, bool isHadron=false)
Definition: PFCluster.cc:100
REPPoint posrep_
cluster position: rho, eta, phi (transient)
Definition: PFCluster.h:181
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void addRecHitFraction(const reco::PFRecHitFraction &frac)
add a given fraction of the rechit
Definition: PFCluster.cc:91
static std::atomic< double > depthCorBp_
Definition: PFCluster.h:204
fixed size matrix
int color_
color (transient)
Definition: PFCluster.h:225
float time_
Michalis :Add timing and depth information.
Definition: PFCluster.h:184
static std::atomic< double > depthCorA_
Definition: PFCluster.h:195
static Layer fromCaloID(const reco::CaloID &id)
Definition: PFLayer.cc:29
ROOT::Math::PositionVector3D< ROOT::Math::CylindricalEta3D< double > > REPPoint
Definition: PFCluster.h:54
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
Definition: PFCluster.h:72
const PFRecHitRef & recHitRef() const
void reset()
resets the CaloCluster (position, energy, hitsAndFractions)
Definition: CaloCluster.cc:11
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40