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 rescale_(1.),
00014 energyUp_(0.),
00015
00016 position_(math::XYZPoint(0.,0.,0.)),
00017 posrep_(REPPoint(0.,0.,0.)) {
00018
00019 cornersxyz_.reserve( nCorners_ );
00020 for(unsigned i=0; i<nCorners_; i++) {
00021 cornersxyz_.push_back( position_ );
00022 }
00023
00024 cornersrep_.reserve( nCorners_ );
00025 for ( unsigned i=0; i<nCorners_; ++i ) {
00026 cornersrep_.push_back(
00027 REPPoint(cornersxyz_[i].Rho(),
00028 cornersxyz_[i].Eta(),
00029 cornersxyz_[i].Phi() ) );
00030 }
00031
00032 }
00033
00034
00035 PFRecHit::PFRecHit(unsigned detId,
00036 PFLayer::Layer layer,
00037 double energy,
00038 const math::XYZPoint& position,
00039 const math::XYZVector& axisxyz,
00040 const vector< math::XYZPoint >& cornersxyz) :
00041 detId_(detId),
00042 layer_(layer),
00043 energy_(energy),
00044 rescale_(1.),
00045 energyUp_(0.),
00046
00047 position_(position),
00048 posrep_( position.Rho(), position.Eta(), position.Phi() ),
00049 axisxyz_(axisxyz),
00050 cornersxyz_(cornersxyz)
00051 {
00052 cornersrep_.reserve( nCorners_ );
00053 for ( unsigned i=0; i<nCorners_; ++i ) {
00054 cornersrep_.push_back(
00055 REPPoint(cornersxyz_[i].Rho(),
00056 cornersxyz_[i].Eta(),
00057 cornersxyz_[i].Phi() ) );
00058 }
00059 }
00060
00061 PFRecHit::PFRecHit(unsigned detId,
00062 PFLayer::Layer layer,
00063 double energy,
00064 double posx, double posy, double posz,
00065 double axisx, double axisy, double axisz) :
00066
00067 detId_(detId),
00068 layer_(layer),
00069 energy_(energy),
00070 rescale_(1.),
00071 energyUp_(0.),
00072
00073 position_(posx, posy, posz),
00074 posrep_( position_.Rho(),
00075 position_.Eta(),
00076 position_.Phi() ),
00077 axisxyz_(axisx, axisy, axisz) {
00078
00079
00080 cornersxyz_.reserve( nCorners_ );
00081 for(unsigned i=0; i<nCorners_; i++) {
00082 cornersxyz_.push_back( position_ );
00083 }
00084
00085 cornersrep_.reserve( nCorners_ );
00086 for ( unsigned i=0; i<nCorners_; ++i ) {
00087 cornersrep_.push_back(
00088 REPPoint(cornersxyz_[i].Rho(),
00089 cornersxyz_[i].Eta(),
00090 cornersxyz_[i].Phi() ) );
00091 }
00092
00093 }
00094
00095
00096 PFRecHit::PFRecHit(const PFRecHit& other) :
00097 detId_(other.detId_),
00098 layer_(other.layer_),
00099 energy_(other.energy_),
00100 rescale_(other.rescale_),
00101 energyUp_(other.energyUp_),
00102
00103 position_(other.position_),
00104 posrep_(other.posrep_),
00105 axisxyz_(other.axisxyz_),
00106 cornersxyz_(other.cornersxyz_),
00107 cornersrep_(other.cornersrep_),
00108
00109 neighbours4_(other.neighbours4_),
00110 neighbours8_(other.neighbours8_),
00111 neighboursIds4_(other.neighboursIds4_),
00112 neighboursIds8_(other.neighboursIds8_)
00113 {}
00114
00115
00116 PFRecHit::~PFRecHit()
00117 {}
00118
00119
00120 const PFRecHit::REPPoint&
00121 PFRecHit::positionREP() const {
00122
00123
00124
00125 return posrep_;
00126 }
00127
00128
00129 void
00130 PFRecHit::calculatePositionREP() {
00131 posrep_.SetCoordinates( position_.Rho(), position_.Eta(), position_.Phi() );
00132 for ( unsigned i=0; i<nCorners_; ++i ) {
00133 cornersrep_[i].SetCoordinates(cornersxyz_[i].Rho(),cornersxyz_[i].Eta(),cornersxyz_[i].Phi() );
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
00169
00170
00171
00172
00173
00174
00175
00176 void PFRecHit::add4Neighbour(unsigned index) {
00177 neighbours4_.push_back( index );
00178 neighbours8_.push_back( index );
00179 }
00180
00181 void PFRecHit::add8Neighbour(unsigned index) {
00182 neighbours8_.push_back( index );
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
00209
00210
00211
00212
00213
00214
00215
00216 void PFRecHit::setNWCorner( double posx, double posy, double posz ) {
00217 setCorner(0, posx, posy, posz);
00218 }
00219
00220
00221 void PFRecHit::setSWCorner( double posx, double posy, double posz ) {
00222 setCorner(1, posx, posy, posz);
00223 }
00224
00225
00226 void PFRecHit::setSECorner( double posx, double posy, double posz ) {
00227 setCorner(2, posx, posy, posz);
00228 }
00229
00230
00231 void PFRecHit::setNECorner( double posx, double posy, double posz ) {
00232 setCorner(3, posx, posy, posz);
00233 }
00234
00235
00236 void PFRecHit::setCorner( unsigned i, double posx, double posy, double posz ) {
00237 assert( cornersxyz_.size() == nCorners_);
00238 assert( cornersrep_.size() == nCorners_);
00239 assert( i<cornersxyz_.size() );
00240
00241 cornersxyz_[i] = math::XYZPoint( posx, posy, posz);
00242 cornersrep_[i] = REPPoint(cornersxyz_[i].Rho(),
00243 cornersxyz_[i].Eta(),
00244 cornersxyz_[i].Phi() );
00245 }
00246
00247
00248 bool PFRecHit::isNeighbour4(unsigned id) const {
00249
00250 for(unsigned i=0; i<neighbours4_.size(); i++ )
00251 if( id == neighbours4_[i] ) return true;
00252
00253 return false;
00254 }
00255
00256
00257 bool PFRecHit::isNeighbour8(unsigned id) const {
00258
00259 for(unsigned i=0; i<neighbours8_.size(); i++ )
00260 if( id == neighbours8_[i] ) return true;
00261
00262 return false;
00263 }
00264
00265
00266 void PFRecHit::size(double& deta, double& dphi) const {
00267
00268 double minphi=9999;
00269 double maxphi=-9999;
00270 double mineta=9999;
00271 double maxeta=-9999;
00272 for ( unsigned ic=0; ic<cornersrep_.size(); ++ic ) {
00273 double eta = cornersrep_[ic].Eta();
00274 double phi = cornersrep_[ic].Phi();
00275
00276 if(phi>maxphi) maxphi=phi;
00277 if(phi<minphi) minphi=phi;
00278 if(eta>maxeta) maxeta=eta;
00279 if(eta<mineta) mineta=eta;
00280 }
00281
00282 deta = maxeta - mineta;
00283 dphi = maxphi - minphi;
00284 }
00285
00286
00287 ostream& reco::operator<<(ostream& out, const reco::PFRecHit& hit) {
00288
00289 if(!out) return out;
00290
00291
00292
00293
00294 const math::XYZPoint& posxyz = hit.position();
00295
00296 out<<"hit id:"<<hit.detId()
00297 <<" l:"<<hit.layer()
00298 <<" E:"<<hit.energy()
00299 <<" rep:"<<posxyz.Rho()<<","<<posxyz.Eta()<<","<<posxyz.Phi()<<"| N:";
00300
00301 for(unsigned i=0; i<hit.neighbours8_.size(); i++ ) {
00302 out<<hit.neighbours8_[i]<<" ";
00303 }
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327 return out;
00328 }