CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/TopQuarkAnalysis/TopKinFitter/interface/TtFullHadKinFitter.h

Go to the documentation of this file.
00001 #ifndef TtFullHadKinFitter_h
00002 #define TtFullHadKinFitter_h
00003 
00004 #include <vector>
00005 
00006 #include "TLorentzVector.h"
00007 
00008 #include "AnalysisDataFormats/TopObjects/interface/TtHadEvtSolution.h"
00009 
00010 #include "TopQuarkAnalysis/TopKinFitter/interface/CovarianceMatrix.h"
00011 #include "TopQuarkAnalysis/TopKinFitter/interface/TopKinFitter.h"
00012 
00013 #include "PhysicsTools/JetMCUtils/interface/combination.h"
00014 
00015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00016 
00017 class TAbsFitParticle;
00018 class TFitConstraintM;
00019 
00020 /*
00021   \class   TtFullHadKinFitter TtFullHadKinFitter.h "TopQuarkAnalysis/TopKinFitter/interface/TtFullHadKinFitter.h"
00022   
00023   \brief   one line description to be added here...
00024 
00025   text to be added here...
00026   
00027 **/
00028 
00029 class TtFullHadKinFitter : public TopKinFitter {
00030 
00031  public:
00033   enum Constraint{ kWPlusMass=1, kWMinusMass, kTopMass, kTopBarMass, kEqualTopMasses };
00034   
00035  public:
00037   TtFullHadKinFitter();
00039   std::vector<TtFullHadKinFitter::Constraint> intToConstraint(std::vector<unsigned int> constraints);
00041   TtFullHadKinFitter(int jetParam, int maxNrIter, double maxDeltaS, double maxF, std::vector<unsigned int> constraints,
00042                      double mW=80.4, double mTop=173.);
00044   TtFullHadKinFitter(Param jetParam, int maxNrIter, double maxDeltaS, double maxF, std::vector<Constraint> constraints,
00045                      double mW=80.4, double mTop=173.);
00047   ~TtFullHadKinFitter();
00048 
00050   int fit(const std::vector<pat::Jet>& jets);
00051   int fit(const std::vector<pat::Jet>& jets, const std::vector<edm::ParameterSet> udscResolutions, const std::vector<edm::ParameterSet> bResolutions, const double resolutionSmearFactor);
00053   const pat::Particle fittedB() const { return (fitter_->getStatus()==0 ? fittedB_ : pat::Particle()); };
00055   const pat::Particle fittedBBar() const { return (fitter_->getStatus()==0 ? fittedBBar_ : pat::Particle()); };
00057   const pat::Particle fittedLightQ() const { return (fitter_->getStatus()==0 ? fittedLightQ_ : pat::Particle()); };
00059   const pat::Particle fittedLightQBar() const { return (fitter_->getStatus()==0 ? fittedLightQBar_ : pat::Particle()); };
00061   const pat::Particle fittedLightP() const { return (fitter_->getStatus()==0 ? fittedLightP_ : pat::Particle()); };
00063   const pat::Particle fittedLightPBar() const { return (fitter_->getStatus()==0 ? fittedLightPBar_ : pat::Particle()); };
00065   TtHadEvtSolution addKinFitInfo(TtHadEvtSolution * asol);
00066   
00067  private:
00069   void printSetup() const;
00071   void setupFitter();
00073   void setupJets();
00075   void setupConstraints();
00076 
00077  private:
00079   TAbsFitParticle* b_;
00080   TAbsFitParticle* bBar_;
00081   TAbsFitParticle* lightQ_;
00082   TAbsFitParticle* lightQBar_;
00083   TAbsFitParticle* lightP_;
00084   TAbsFitParticle* lightPBar_;
00086   std::map<Constraint, TFitConstraintM*> massConstr_;
00088   pat::Particle fittedB_;
00089   pat::Particle fittedBBar_;
00090   pat::Particle fittedLightQ_;
00091   pat::Particle fittedLightQBar_;
00092   pat::Particle fittedLightP_;
00093   pat::Particle fittedLightPBar_;
00095   Param jetParam_;
00097   std::vector<Constraint> constraints_;
00098 
00100   CovarianceMatrix * covM;
00101 
00102  public:
00103 
00105   struct KinFitResult {
00106     int Status;
00107     double Chi2;
00108     double Prob;
00109     pat::Particle B;
00110     pat::Particle BBar;
00111     pat::Particle LightQ;
00112     pat::Particle LightQBar;
00113     pat::Particle LightP;
00114     pat::Particle LightPBar;
00115     std::vector<int> JetCombi;
00116     bool operator< (const KinFitResult& rhs) { return Chi2 < rhs.Chi2; };
00117   };
00118 
00120   class KinFit {
00121 
00122   public:
00123     
00125     KinFit();
00127     KinFit(bool useBTagging, unsigned int bTags, std::string bTagAlgo, double minBTagValueBJet, double maxBTagValueNonBJet,
00128            std::vector<edm::ParameterSet> udscResolutions, std::vector<edm::ParameterSet> bResolutions, double resolutionSmearFactor,
00129            std::string jetCorrectionLevel, int maxNJets, int maxNComb,
00130            unsigned int maxNrIter, double maxDeltaS, double maxF, unsigned int jetParam, std::vector<unsigned> constraints, double mW, double mTop);
00132     ~KinFit();
00133     
00135     void setBTagging(bool useBTagging, unsigned int bTags, std::string bTagAlgo, double minBTagValueBJet, double maxBTagValueNonBJet){
00136       useBTagging_         = useBTagging;
00137       bTags_               = bTags;
00138       bTagAlgo_            = bTagAlgo;
00139       minBTagValueBJet_    = minBTagValueBJet;
00140       maxBTagValueNonBJet_ = maxBTagValueNonBJet;
00141     }
00143     void setResolutions(std::vector<edm::ParameterSet> udscResolutions, std::vector<edm::ParameterSet> bResolutions, double resolutionSmearFactor = 1.){
00144       udscResolutions_       = udscResolutions;
00145       bResolutions_          = bResolutions;
00146       resolutionSmearFactor_ = resolutionSmearFactor;
00147     }
00149     void setFitter(int maxNJets, unsigned int maxNrIter, double maxDeltaS, double maxF,
00150                    unsigned int jetParam, std::vector<unsigned> constraints, double mW, double mTop){
00151       maxNJets_    = maxNJets;
00152       maxNrIter_   = maxNrIter;
00153       maxDeltaS_   = maxDeltaS;
00154       maxF_        = maxF;
00155       jetParam_    = jetParam;
00156       constraints_ = constraints;
00157       mW_          = mW;
00158       mTop_        = mTop;
00159     }
00161     void setJEC(std::string jetCorrectionLevel){
00162       jetCorrectionLevel_ = jetCorrectionLevel;
00163     }
00165     void setUseOnlyMatch(bool useOnlyMatch){
00166       useOnlyMatch_ = useOnlyMatch;
00167     }
00169     void setMatch(std::vector<int> match){
00170       match_ = match;
00171     }
00173     void setMatchInvalidity(bool invalidMatch){
00174       invalidMatch_ = invalidMatch;
00175     }
00177     void setOutput(int maxNComb){
00178       maxNComb_ = maxNComb;
00179     }
00180 
00182     std::list<TtFullHadKinFitter::KinFitResult> fit(const std::vector<pat::Jet>& jets);
00183     
00184   private:
00185 
00186     // helper function for b-tagging
00187     bool doBTagging(const std::vector<pat::Jet>& jets, const unsigned int& bJetCounter, std::vector<int>& combi);
00189     pat::Jet corJet(const pat::Jet& jet, const std::string& quarkType);
00190     
00191     // convert unsigned to Param
00192     TtFullHadKinFitter::Param param(unsigned int configParameter);
00193     // convert unsigned int to Constraint
00194     TtFullHadKinFitter::Constraint constraint(unsigned int configParameter);
00195     // convert vector of unsigned int's to vector of Contraint's
00196     std::vector<TtFullHadKinFitter::Constraint> constraints(std::vector<unsigned int>& configParameters);
00197     
00201     bool useBTagging_;
00203     unsigned int bTags_;
00205     std::string bTagAlgo_;
00207     double minBTagValueBJet_;
00209     double maxBTagValueNonBJet_;
00211     std::vector<edm::ParameterSet> udscResolutions_, bResolutions_;
00213     double resolutionSmearFactor_;
00215     std::string jetCorrectionLevel_;
00217     int maxNJets_;
00219     int maxNComb_;
00221     unsigned int maxNrIter_;
00223     double maxDeltaS_;
00225     double maxF_;
00227     unsigned int jetParam_;
00229     std::vector<unsigned> constraints_;
00231     double mW_;
00233     double mTop_;
00235     bool useOnlyMatch_;
00237     std::vector<int> match_;
00239     bool invalidMatch_;
00240 
00242     TtFullHadKinFitter* fitter;
00243  
00244   };
00245 };
00246 
00247 #endif