00001 #include "DataFormats/ParticleFlowReco/interface/PFRecHit.h"
00002
00003 using namespace reco;
00004 using namespace std;
00005
00006 const unsigned PFRecHit::nNeighbours_ = 8;
00007 const unsigned PFRecHit::nCorners_ = 4;
00008
00009 PFRecHit::PFRecHit() :
00010 detId_(0),
00011 layer_(PFLayer::NONE),
00012 energy_(0.),
00013
00014 position_(math::XYZPoint(0.,0.,0.)),
00015 posrep_(REPPoint(0.,0.,0.)) {
00016
00017 cornersxyz_.reserve( nCorners_ );
00018 for(unsigned i=0; i<nCorners_; i++) {
00019 cornersxyz_.push_back( position_ );
00020 }
00021
00022 cornersrep_.reserve( nCorners_ );
00023 for ( unsigned i=0; i<nCorners_; ++i ) {
00024 cornersrep_.push_back(
00025 REPPoint(cornersxyz_[i].Rho(),
00026 cornersxyz_[i].Eta(),
00027 cornersxyz_[i].Phi() ) );
00028 }
00029
00030 }
00031
00032
00033 PFRecHit::PFRecHit(unsigned detId,
00034 PFLayer::Layer layer,
00035 double energy,
00036 const math::XYZPoint& position,
00037 const math::XYZVector& axisxyz,
00038 const vector< math::XYZPoint >& cornersxyz) :
00039 detId_(detId),
00040 layer_(layer),
00041 energy_(energy),
00042
00043 position_(position),
00044 posrep_( position.Rho(), position.Eta(), position.Phi() ),
00045 axisxyz_(axisxyz),
00046 cornersxyz_(cornersxyz)
00047 {
00048 cornersrep_.reserve( nCorners_ );
00049 for ( unsigned i=0; i<nCorners_; ++i ) {
00050 cornersrep_.push_back(
00051 REPPoint(cornersxyz_[i].Rho(),
00052 cornersxyz_[i].Eta(),
00053 cornersxyz_[i].Phi() ) );
00054 }
00055 }
00056
00057 PFRecHit::PFRecHit(unsigned detId,
00058 PFLayer::Layer layer,
00059 double energy,
00060 double posx, double posy, double posz,
00061 double axisx, double axisy, double axisz) :
00062
00063 detId_(detId),
00064 layer_(layer),
00065 energy_(energy),
00066
00067 position_(posx, posy, posz),
00068 posrep_( position_.Rho(),
00069 position_.Eta(),
00070 position_.Phi() ),
00071 axisxyz_(axisx, axisy, axisz) {
00072
00073
00074 cornersxyz_.reserve( nCorners_ );
00075 for(unsigned i=0; i<nCorners_; i++) {
00076 cornersxyz_.push_back( position_ );
00077 }
00078
00079 cornersrep_.reserve( nCorners_ );
00080 for ( unsigned i=0; i<nCorners_; ++i ) {
00081 cornersrep_.push_back(
00082 REPPoint(cornersxyz_[i].Rho(),
00083 cornersxyz_[i].Eta(),
00084 cornersxyz_[i].Phi() ) );
00085 }
00086
00087 }
00088
00089
00090 PFRecHit::PFRecHit(const PFRecHit& other) :
00091 detId_(other.detId_),
00092 layer_(other.layer_),
00093 energy_(other.energy_),
00094
00095 position_(other.position_),
00096 posrep_(other.posrep_),
00097 axisxyz_(other.axisxyz_),
00098 cornersxyz_(other.cornersxyz_),
00099 cornersrep_(other.cornersrep_),
00100
00101 neighbours4_(other.neighbours4_),
00102 neighbours8_(other.neighbours8_),
00103 neighboursIds4_(other.neighboursIds4_),
00104 neighboursIds8_(other.neighboursIds8_)
00105 {}
00106
00107
00108 PFRecHit::~PFRecHit()
00109 {}
00110
00111
00112 const PFRecHit::REPPoint&
00113 PFRecHit::positionREP() const {
00114
00115
00116
00117 return posrep_;
00118 }
00119
00120
00121 void
00122 PFRecHit::calculatePositionREP() {
00123 posrep_.SetCoordinates( position_.Rho(), position_.Eta(), position_.Phi() );
00124 for ( unsigned i=0; i<nCorners_; ++i ) {
00125 cornersrep_[i].SetCoordinates(cornersxyz_[i].Rho(),cornersxyz_[i].Eta(),cornersxyz_[i].Phi() );
00126 }
00127 }
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168 void PFRecHit::add4Neighbour(unsigned index) {
00169 neighbours4_.push_back( index );
00170 neighbours8_.push_back( index );
00171 }
00172
00173 void PFRecHit::add8Neighbour(unsigned index) {
00174 neighbours8_.push_back( index );
00175 }
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208 void PFRecHit::setNWCorner( double posx, double posy, double posz ) {
00209 setCorner(0, posx, posy, posz);
00210 }
00211
00212
00213 void PFRecHit::setSWCorner( double posx, double posy, double posz ) {
00214 setCorner(1, posx, posy, posz);
00215 }
00216
00217
00218 void PFRecHit::setSECorner( double posx, double posy, double posz ) {
00219 setCorner(2, posx, posy, posz);
00220 }
00221
00222
00223 void PFRecHit::setNECorner( double posx, double posy, double posz ) {
00224 setCorner(3, posx, posy, posz);
00225 }
00226
00227
00228 void PFRecHit::setCorner( unsigned i, double posx, double posy, double posz ) {
00229 assert( cornersxyz_.size() == nCorners_);
00230 assert( cornersrep_.size() == nCorners_);
00231 assert( i<cornersxyz_.size() );
00232
00233 cornersxyz_[i] = math::XYZPoint( posx, posy, posz);
00234 cornersrep_[i] = REPPoint(cornersxyz_[i].Rho(),
00235 cornersxyz_[i].Eta(),
00236 cornersxyz_[i].Phi() );
00237 }
00238
00239
00240 bool PFRecHit::isNeighbour4(unsigned id) const {
00241
00242 for(unsigned i=0; i<neighbours4_.size(); i++ )
00243 if( id == neighbours4_[i] ) return true;
00244
00245 return false;
00246 }
00247
00248
00249 bool PFRecHit::isNeighbour8(unsigned id) const {
00250
00251 for(unsigned i=0; i<neighbours8_.size(); i++ )
00252 if( id == neighbours8_[i] ) return true;
00253
00254 return false;
00255 }
00256
00257
00258 void PFRecHit::size(double& deta, double& dphi) const {
00259
00260 double minphi=9999;
00261 double maxphi=-9999;
00262 double mineta=9999;
00263 double maxeta=-9999;
00264 for ( unsigned ic=0; ic<cornersrep_.size(); ++ic ) {
00265 double eta = cornersrep_[ic].Eta();
00266 double phi = cornersrep_[ic].Phi();
00267
00268 if(phi>maxphi) maxphi=phi;
00269 if(phi<minphi) minphi=phi;
00270 if(eta>maxeta) maxeta=eta;
00271 if(eta<mineta) mineta=eta;
00272 }
00273
00274 deta = maxeta - mineta;
00275 dphi = maxphi - minphi;
00276 }
00277
00278
00279 ostream& reco::operator<<(ostream& out, const reco::PFRecHit& hit) {
00280
00281 if(!out) return out;
00282
00283
00284
00285
00286 const math::XYZPoint& posxyz = hit.position();
00287
00288 out<<"hit id:"<<hit.detId()
00289 <<" l:"<<hit.layer()
00290 <<" E:"<<hit.energy()
00291 <<" rep:"<<posxyz.Rho()<<","<<posxyz.Eta()<<","<<posxyz.Phi()<<"| N:";
00292
00293 for(unsigned i=0; i<hit.neighbours8_.size(); i++ ) {
00294 out<<hit.neighbours8_[i]<<" ";
00295 }
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319 return out;
00320 }