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