00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 using namespace std;
00014
00015 #include "PhysicsTools/KinFitter/interface/TFitConstraintEp.h"
00016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00017 #include <iostream>
00018 #include <iomanip>
00019 #include "TClass.h"
00020
00021 ClassImp(TFitConstraintEp)
00022
00023
00024
00025
00026
00027
00028
00029 TFitConstraintEp::TFitConstraintEp()
00030 :TAbsFitConstraint()
00031 ,_particles(0)
00032 ,_constraint(0.)
00033 ,_component(TFitConstraintEp::pX)
00034 {}
00035
00036 TFitConstraintEp::TFitConstraintEp(vector<TAbsFitParticle*>* particles,
00037 TFitConstraintEp::component thecomponent,
00038 Double_t constraint)
00039 :TAbsFitConstraint()
00040 ,_particles(0)
00041 ,_constraint(constraint)
00042 ,_component(thecomponent)
00043 {
00044
00045
00046
00047
00048
00049
00050
00051
00052 if (particles) {
00053 _particles = (*particles);
00054 }
00055 }
00056
00057 TFitConstraintEp::TFitConstraintEp(const TString &name, const TString &title,
00058 vector<TAbsFitParticle*>* particles,
00059 TFitConstraintEp::component thecomponent,
00060 Double_t constraint)
00061 :TAbsFitConstraint(name, title)
00062 ,_particles(0)
00063 ,_constraint(constraint)
00064 ,_component(thecomponent)
00065 {
00066
00067
00068
00069
00070
00071
00072
00073
00074 if (particles) {
00075 _particles = (*particles);
00076 }
00077 }
00078
00079
00080
00081
00082 TFitConstraintEp::~TFitConstraintEp() {
00083
00084 }
00085
00086 void TFitConstraintEp::addParticle( TAbsFitParticle* particle ) {
00087
00088
00089 _particles.push_back( particle );
00090
00091 }
00092
00093 void TFitConstraintEp::addParticles( TAbsFitParticle* p1, TAbsFitParticle* p2, TAbsFitParticle* p3, TAbsFitParticle* p4,
00094 TAbsFitParticle* p5, TAbsFitParticle* p6, TAbsFitParticle* p7, TAbsFitParticle* p8,
00095 TAbsFitParticle* p9, TAbsFitParticle* p10) {
00096
00097
00098 if (p1) addParticle( p1 );
00099 if (p2) addParticle( p2 );
00100 if (p3) addParticle( p3 );
00101 if (p4) addParticle( p4 );
00102 if (p5) addParticle( p5 );
00103 if (p6) addParticle( p6 );
00104 if (p7) addParticle( p7 );
00105 if (p8) addParticle( p8 );
00106 if (p9) addParticle( p9 );
00107 if (p10) addParticle( p10 );
00108
00109 }
00110
00111
00112
00113
00114 TMatrixD* TFitConstraintEp::getDerivative( TAbsFitParticle* particle ) {
00115
00116
00117
00118 TMatrixD* DerivativeMatrix = new TMatrixD(1,4);
00119 (*DerivativeMatrix) *= 0.;
00120 (*DerivativeMatrix)(0,(int) _component) = 1.;
00121 return DerivativeMatrix;
00122 }
00123
00124
00125 Double_t TFitConstraintEp::getInitValue() {
00126
00127
00128 Double_t InitValue(0) ;
00129 UInt_t Npart = _particles.size();
00130 for (unsigned int i=0;i<Npart;i++) {
00131 const TLorentzVector* FourVec = _particles[i]->getIni4Vec();
00132 InitValue += (*FourVec)[(int) _component];
00133 }
00134 InitValue -= _constraint;
00135 return InitValue;
00136 }
00137
00138 Double_t TFitConstraintEp::getCurrentValue() {
00139
00140
00141 Double_t CurrentValue(0);
00142 UInt_t Npart = _particles.size();
00143 for (unsigned int i=0;i<Npart;i++) {
00144 const TLorentzVector* FourVec = _particles[i]->getCurr4Vec();
00145 CurrentValue += (*FourVec)[(int) _component];
00146 }
00147 CurrentValue -= _constraint;
00148 return CurrentValue;
00149 }
00150
00151 TString TFitConstraintEp::getInfoString() {
00152
00153
00154 stringstream info;
00155 info << scientific << setprecision(6);
00156
00157 info << "__________________________" << endl
00158 << endl;
00159 info << "OBJ: " << IsA()->GetName() << "\t" << GetName() << "\t" << GetTitle() << endl;
00160
00161 info << "initial value: " << getInitValue() << endl;
00162 info << "current value: " << getCurrentValue() << endl;
00163 info << "component: " << _component << endl;
00164 info << "constraint: " << _constraint << endl;
00165
00166 return info.str();
00167
00168 }
00169
00170 void TFitConstraintEp::print() {
00171
00172
00173 edm::LogVerbatim("KinFitter") << this->getInfoString();
00174
00175 }