CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/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 
00067     void calculatePositionREP();
00068 
00069     //C neighbours must be initialized correctly !!
00070     /*     void setNeighbours( const std::vector< unsigned >& neighbours ); */
00071     void add4Neighbour( unsigned index );
00072     void add8Neighbour( unsigned index );
00073     void setEnergyUp( double eUp) { energyUp_ = eUp; }
00074     void setRescale( double factor) { rescale_ = factor; }
00075     
00076     void clearNeighbours() {
00077       neighbours4_.clear();
00078       neighbours8_.clear();
00079       neighbours4_.reserve(4);
00080       neighbours8_.reserve(8);    
00081     }
00082 
00083     
00084 
00091     // void      findPtrsToNeighbours( const std::map<unsigned,  reco::PFRecHit* >& allhits );
00092 
00093     void      setNWCorner( double posx, double posy, double posz );
00094     void      setSWCorner( double posx, double posy, double posz );
00095     void      setSECorner( double posx, double posy, double posz );
00096     void      setNECorner( double posx, double posy, double posz );
00097 
00099     unsigned detId() const {return detId_;}
00100 
00102     PFLayer::Layer layer() const { return layer_; }
00103 
00105     double energy() const { return energy_; }
00106 
00108     double rescale() const { return rescale_; }
00109 
00111     double time() const { return rescale_; }
00112 
00114     double energyUp() const { return energyUp_; }
00115 
00117     double pt2() const { return energy_ * energy_ *
00118                            ( position_.X()*position_.X() + 
00119                              position_.Y()*position_.Y() ) / 
00120                            ( position_.X()*position_.X() +
00121                              position_.Y()*position_.Y() + 
00122                              position_.Z()*position_.Z()) ; }
00123 
00124     //C remove cause I want to be able to run on const rechits
00126     // int  seedState() const { return seedState_; }
00127     
00129     // bool isSeed() const { return (seedState_>0) ? true : false; }
00130 
00132     // void youAreSeed(int seedstate=1) {seedState_ = seedstate;} 
00133 
00135     const math::XYZPoint& position() const { return position_; }
00136 
00138     const REPPoint& positionREP() const;
00139 
00141     const math::XYZVector& getAxisXYZ() const { return axisxyz_; }    
00142 
00144     const std::vector< math::XYZPoint >& getCornersXYZ() const 
00145       { return cornersxyz_; }    
00146 
00148     const REPPointVector& getCornersREP() const 
00149       { return cornersrep_; }    
00150 
00151     const std::vector< unsigned >& neighbours4() const 
00152       {return neighbours4_;}  
00153 
00154     const std::vector< unsigned >& neighbours8() const 
00155       {return neighbours8_;}  
00156 
00157     const std::vector< unsigned >& neighboursIds4() const 
00158       {return neighboursIds4_;}  
00159 
00160     const std::vector< unsigned >& neighboursIds8() const 
00161       {return neighboursIds8_;}  
00162 
00163     /*     const std::vector< unsigned >& getNeighboursIds4() const  */
00164     /*       {return neighboursIds4_;}   */
00165 
00166     /*     const std::vector< unsigned >& getNeighboursIds8() const  */
00167     /*       {return neighboursIds8_;}   */
00168 
00171     bool  isNeighbour4(unsigned id) const;
00172 
00175     bool  isNeighbour8(unsigned id) const;
00176     
00177 
00178     void size(double& deta, double& dphi) const;
00179 
00181     bool operator>=(const PFRecHit& rhs) const { return (energy_>=rhs.energy_); }
00182 
00184     bool operator> (const PFRecHit& rhs) const { return (energy_> rhs.energy_); }
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 
00192     friend std::ostream& operator<<(std::ostream& out, 
00193                                     const reco::PFRecHit& hit);
00194 
00195   private:
00196 
00198     unsigned            detId_;             
00199 
00201     PFLayer::Layer                 layer_;
00202 
00204     double              energy_;
00205 
00207     double              rescale_;
00208 
00210     double              energyUp_;
00211 
00213     // int                 seedState_;
00214  
00216     math::XYZPoint      position_;
00217 
00219     REPPoint            posrep_;
00220 
00222     math::XYZVector     axisxyz_;
00223 
00225     std::vector< math::XYZPoint > cornersxyz_;
00226     REPPointVector cornersrep_;
00227   
00229     std::vector< unsigned >   neighbours4_;
00230 
00232     std::vector< unsigned >   neighbours8_;
00233 
00235     std::vector< unsigned >   neighboursIds4_;
00236 
00238     std::vector< unsigned >   neighboursIds8_;
00239 
00241     static const unsigned    nNeighbours_;
00242     
00244     static const unsigned    nCorners_;
00245 
00247     void      setCorner( unsigned i, double posx, double posy, double posz );
00248   };
00249   
00250 }
00251 
00252 #endif