CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/PhysicsTools/CandUtils/interface/Thrust.h

Go to the documentation of this file.
00001 #ifndef CandUtils_Thrust_h
00002 #define CandUtils_Thrust_h
00003 
00036 #include "DataFormats/Math/interface/Vector3D.h"
00037 #include "DataFormats/Candidate/interface/Candidate.h"
00038 #include <vector>
00039  
00040 class Thrust  {
00041 public:
00043   typedef math::XYZVector Vector;
00045   template<typename const_iterator>
00046   Thrust(const_iterator begin, const_iterator end) :
00047     thrust_(0), axis_(0, 0, 0), pSum_(0), 
00048     n_(end - begin), p_(n_) {
00049     if (n_ == 0) return;
00050     std::vector<const reco::Candidate*> cands;
00051     for(const_iterator i = begin; i != end; ++i) {
00052       cands.push_back(&*i);
00053     }
00054     init(cands);
00055   } 
00057   double thrust() const { return thrust_; } 
00059   const Vector& axis() const { return axis_; } 
00060 
00061 private:
00062   double thrust_;
00063   Vector axis_;
00064   double pSum_;
00065   const unsigned int n_;
00066   std::vector<Vector> p_;
00067 
00068   struct ThetaPhi {
00069     ThetaPhi(double t, double p) : theta( t ), phi( p ) { }
00070     double theta, phi;
00071   };
00072   double thrust(const Vector & theAxis) const; 
00073   ThetaPhi initialAxis() const;
00074   ThetaPhi finalAxis(ThetaPhi) const;
00075   Vector axis(double theta, double phi) const;
00076   Vector axis(const ThetaPhi & tp) const  {
00077     return axis(tp.theta, tp.phi);
00078   }
00079   void parabola(double & a, double & b, double & c, 
00080                 const Vector &, const Vector &, const Vector &) const;
00081   void init(const std::vector<const reco::Candidate*>&);
00082 };
00083 
00084 #endif