CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/DataFormats/ParticleFlowReco/interface/PFRecHit.h

Go to the documentation of this file.
00001 #ifndef ParticleFlowReco_PFRecHit_h
00002 #define ParticleFlowReco_PFRecHit_h
00003 
00005 #include <vector>
00006 #include <map>
00007 #include <iostream>
00008 
00009 #include "DataFormats/Math/interface/Point3D.h"
00010 #include "Rtypes.h" 
00011 #include "DataFormats/Math/interface/Vector3D.h"
00012 // #include "DataFormats/DetId/interface/DetId.h"
00013 #include "Math/GenVector/PositionVector3D.h"
00014 
00015 #include "DataFormats/ParticleFlowReco/interface/PFLayer.h"
00016 
00017 //C decide what is the default rechit index. 
00018 //C maybe 0 ? -> compression 
00019 //C then the position is index-1. 
00020 //C provide a helper class to access the rechit. 
00021 
00022 
00023 namespace reco {
00024 
00031   class PFRecHit {
00032 
00033   public:
00034     
00035     enum {
00036       NONE=0
00037     };
00038 
00039     typedef ROOT::Math::PositionVector3D<ROOT::Math::CylindricalEta3D<Double32_t> > REPPoint;
00040 
00041     typedef std::vector<REPPoint> REPPointVector;
00042  
00044     PFRecHit();
00045 
00047     PFRecHit(unsigned detId,
00048              PFLayer::Layer layer,
00049              double energy, 
00050              const math::XYZPoint& posxyz, 
00051              const math::XYZVector& axisxyz, 
00052              const std::vector< math::XYZPoint >& cornersxyz);
00053 
00054     PFRecHit(unsigned detId,
00055              PFLayer::Layer layer,
00056              double energy, 
00057              double posx, double posy, double posz, 
00058              double axisx, double axisy, double axisz);    
00059 
00061     PFRecHit(const PFRecHit& other);
00062 
00064     virtual ~PFRecHit();
00065 
00066    
00069 
00070     void setEnergy( double energy) { energy_ = energy; }
00071 
00073     void calculatePositionREP();
00074 
00075     //C neighbours must be initialized correctly !!
00076     /*     void setNeighbours( const std::vector< unsigned >& neighbours ); */
00077     void add4Neighbour( unsigned index );
00078     void add8Neighbour( unsigned index );
00079     void setEnergyUp( double eUp) { energyUp_ = eUp; }
00080     void setRescale( double factor) { rescale_ = factor; }
00081     
00082     void clearNeighbours() {
00083       neighbours4_.clear();
00084       neighbours8_.clear();
00085       neighbours4_.reserve(4);
00086       neighbours8_.reserve(8);    
00087     }
00088 
00089     
00090 
00097     // void      findPtrsToNeighbours( const std::map<unsigned,  reco::PFRecHit* >& allhits );
00098 
00099     void      setNWCorner( double posx, double posy, double posz );
00100     void      setSWCorner( double posx, double posy, double posz );
00101     void      setSECorner( double posx, double posy, double posz );
00102     void      setNECorner( double posx, double posy, double posz );
00103 
00105     unsigned detId() const {return detId_;}
00106 
00108     PFLayer::Layer layer() const { return layer_; }
00109 
00111     double energy() const { return energy_; }
00112 
00114     double rescale() const { return rescale_; }
00115 
00117     double time() const { return rescale_; }
00118 
00120     double energyUp() const { return energyUp_; }
00121 
00123     double pt2() const { return energy_ * energy_ *
00124                            ( position_.X()*position_.X() + 
00125                              position_.Y()*position_.Y() ) / 
00126                            ( position_.X()*position_.X() +
00127                              position_.Y()*position_.Y() + 
00128                              position_.Z()*position_.Z()) ; }
00129 
00130     //C remove cause I want to be able to run on const rechits
00132     // int  seedState() const { return seedState_; }
00133     
00135     // bool isSeed() const { return (seedState_>0) ? true : false; }
00136 
00138     // void youAreSeed(int seedstate=1) {seedState_ = seedstate;} 
00139 
00141     const math::XYZPoint& position() const { return position_; }
00142 
00144     const REPPoint& positionREP() const;
00145 
00147     const math::XYZVector& getAxisXYZ() const { return axisxyz_; }    
00148 
00150     const std::vector< math::XYZPoint >& getCornersXYZ() const 
00151       { return cornersxyz_; }    
00152 
00154     const REPPointVector& getCornersREP() const 
00155       { return cornersrep_; }    
00156 
00157     const std::vector< unsigned >& neighbours4() const 
00158       {return neighbours4_;}  
00159 
00160     const std::vector< unsigned >& neighbours8() const 
00161       {return neighbours8_;}  
00162 
00163     const std::vector< unsigned >& neighboursIds4() const 
00164       {return neighboursIds4_;}  
00165 
00166     const std::vector< unsigned >& neighboursIds8() const 
00167       {return neighboursIds8_;}  
00168 
00169     /*     const std::vector< unsigned >& getNeighboursIds4() const  */
00170     /*       {return neighboursIds4_;}   */
00171 
00172     /*     const std::vector< unsigned >& getNeighboursIds8() const  */
00173     /*       {return neighboursIds8_;}   */
00174 
00177     bool  isNeighbour4(unsigned id) const;
00178 
00181     bool  isNeighbour8(unsigned id) const;
00182     
00183 
00184     void size(double& deta, double& dphi) const;
00185 
00187     bool operator>=(const PFRecHit& rhs) const { return (energy_>=rhs.energy_); }
00188 
00190     bool operator> (const PFRecHit& rhs) const { return (energy_> rhs.energy_); }
00191 
00193     bool operator<=(const PFRecHit& rhs) const { return (energy_<=rhs.energy_); }
00194 
00196     bool operator< (const PFRecHit& rhs) const { return (energy_< rhs.energy_); }
00197 
00198     friend std::ostream& operator<<(std::ostream& out, 
00199                                     const reco::PFRecHit& hit);
00200 
00201   private:
00202 
00204     unsigned            detId_;             
00205 
00207     PFLayer::Layer                 layer_;
00208 
00210     double              energy_;
00211 
00213     double              rescale_;
00214 
00216     double              energyUp_;
00217 
00219     // int                 seedState_;
00220  
00222     math::XYZPoint      position_;
00223 
00225     REPPoint            posrep_;
00226 
00228     math::XYZVector     axisxyz_;
00229 
00231     std::vector< math::XYZPoint > cornersxyz_;
00232     REPPointVector cornersrep_;
00233   
00235     std::vector< unsigned >   neighbours4_;
00236 
00238     std::vector< unsigned >   neighbours8_;
00239 
00241     std::vector< unsigned >   neighboursIds4_;
00242 
00244     std::vector< unsigned >   neighboursIds8_;
00245 
00247     static const unsigned    nNeighbours_;
00248     
00250     static const unsigned    nCorners_;
00251 
00253     void      setCorner( unsigned i, double posx, double posy, double posz );
00254   };
00255   
00256 }
00257 
00258 #endif