CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Attributes
TFitConstraintM Class Reference

#include <TFitConstraintM.h>

Inheritance diagram for TFitConstraintM:
TAbsFitConstraint TFitConstraintMGaus

Public Member Functions

void addParticle1 (TAbsFitParticle *particle)
 
void addParticle2 (TAbsFitParticle *particle)
 
void addParticles1 (TAbsFitParticle *p1, TAbsFitParticle *p2=0, TAbsFitParticle *p3=0, TAbsFitParticle *p4=0, TAbsFitParticle *p5=0, TAbsFitParticle *p6=0, TAbsFitParticle *p7=0, TAbsFitParticle *p8=0, TAbsFitParticle *p9=0, TAbsFitParticle *p10=0)
 
void addParticles2 (TAbsFitParticle *p1, TAbsFitParticle *p2=0, TAbsFitParticle *p3=0, TAbsFitParticle *p4=0, TAbsFitParticle *p5=0, TAbsFitParticle *p6=0, TAbsFitParticle *p7=0, TAbsFitParticle *p8=0, TAbsFitParticle *p9=0, TAbsFitParticle *p10=0)
 
Double_t CalcMass (std::vector< TAbsFitParticle * > *List, Bool_t IniVal)
 
virtual Double_t getCurrentValue ()
 
virtual TMatrixD * getDerivative (TAbsFitParticle *particle)
 
virtual TString getInfoString ()
 
virtual Double_t getInitValue ()
 
Bool_t OnList (std::vector< TAbsFitParticle * > *List, TAbsFitParticle *particle)
 
virtual void print ()
 
void setMassConstraint (Double_t Mass)
 
 TFitConstraintM ()
 
 TFitConstraintM (std::vector< TAbsFitParticle * > *ParList1, std::vector< TAbsFitParticle * > *ParList2, Double_t Mass=0)
 
 TFitConstraintM (const TString &name, const TString &title, std::vector< TAbsFitParticle * > *ParList1, std::vector< TAbsFitParticle * > *ParList2, Double_t Mass=0)
 
virtual ~TFitConstraintM ()
 
- Public Member Functions inherited from TAbsFitConstraint
virtual void applyDeltaAlpha (TMatrixD *corrMatrix)
 
virtual const TMatrixD * getCovMatrix () const
 
virtual const TMatrixD * getCovMatrixDeltaAlpha ()
 
virtual const TMatrixD * getCovMatrixFit () const
 
virtual TMatrixD * getDerivativeAlpha ()
 
Int_t getNPar ()
 
const TMatrixD * getParCurr ()
 
const TMatrixD * getParIni ()
 
virtual void reset ()
 
virtual void setCovMatrix (const TMatrixD *theCovMatrix)
 
virtual void setCovMatrixFit (const TMatrixD *theCovMatrixFit)
 
void setParIni (const TMatrixD *parini)
 
 TAbsFitConstraint ()
 
 TAbsFitConstraint (const TString &name, const TString &title)
 
virtual ~TAbsFitConstraint ()
 

Protected Attributes

std::vector< TAbsFitParticle * > _ParList1
 
std::vector< TAbsFitParticle * > _ParList2
 
Double_t _TheMassConstraint
 
- Protected Attributes inherited from TAbsFitConstraint
TMatrixD _covMatrix
 
TMatrixD _covMatrixDeltaAlpha
 
TMatrixD _covMatrixFit
 
TMatrixD _iniparameters
 
Int_t _nPar
 
TMatrixD _parameters
 

Additional Inherited Members

- Protected Member Functions inherited from TAbsFitConstraint
void calcCovMatrixDeltaAlpha ()
 

Detailed Description

Definition at line 11 of file TFitConstraintM.h.

Constructor & Destructor Documentation

TFitConstraintM::TFitConstraintM ( )

Definition at line 24 of file TFitConstraintM.cc.

26  ,_ParList1(0)
27  ,_ParList2(0)
29 {
30 
31 }
Double_t _TheMassConstraint
std::vector< TAbsFitParticle * > _ParList1
std::vector< TAbsFitParticle * > _ParList2
TFitConstraintM::TFitConstraintM ( std::vector< TAbsFitParticle * > *  ParList1,
std::vector< TAbsFitParticle * > *  ParList2,
Double_t  Mass = 0 
)

Definition at line 33 of file TFitConstraintM.cc.

References _ParList1, _ParList2, _TheMassConstraint, and HLT_25ns14e33_v1_cff::Mass.

36  ,_ParList1(0)
37  ,_ParList2(0)
38 {
39  // ParList1: Vector containing first list of constrained particles
40  // ( sum[ m_i ] - sum[ m_j ] - MassConstraint == 0 )
41  // ParList2: Vector containing second list of constrained particles
42  // ( sum[ m_i ] - sum[ m_j ] - MassConstraint == 0 )
43 
44  if (ParList1) {
45  _ParList1 = (*ParList1);
46  }
47  if (ParList2) {
48  _ParList2 = (*ParList2);
49  }
50  if (Mass >= 0) {
52  }
53  else if(Mass < 0) {
54  edm::LogWarning ("NegativeMassConstr")
55  << "Mass constraint in TFitConstraintM cannot be set to a negative value, will be set to 0.";
56  _TheMassConstraint = 0.;
57  }
58 }
Double_t _TheMassConstraint
std::vector< TAbsFitParticle * > _ParList1
std::vector< TAbsFitParticle * > _ParList2
TFitConstraintM::TFitConstraintM ( const TString &  name,
const TString &  title,
std::vector< TAbsFitParticle * > *  ParList1,
std::vector< TAbsFitParticle * > *  ParList2,
Double_t  Mass = 0 
)

Definition at line 60 of file TFitConstraintM.cc.

References _ParList1, _ParList2, _TheMassConstraint, and HLT_25ns14e33_v1_cff::Mass.

64  ,_ParList1(0)
65  ,_ParList2(0)
66 {
67  // ParList1: Vector containing first list of constrained particles
68  // ( sum[ m_i ] - sum[ m_j ] - MassConstraint == 0 )
69  // ParList2: Vector containing second list of constrained particles
70  // ( sum[ m_i ] - sum[ m_j ] - MassConstraint == 0 )
71 
72  if (ParList1) {
73  _ParList1 = (*ParList1);
74  }
75  if (ParList2) {
76  _ParList2 = (*ParList2);
77  }
78  if (Mass >= 0) {
80  }
81  else if(Mass < 0) {
82  edm::LogWarning ("NegativeMassConstr")
83  << "Mass constraint in TFitConstraintM cannot be set to a negative value, will be set to 0.";
84  _TheMassConstraint = 0.;
85  }
86 }
Double_t _TheMassConstraint
std::vector< TAbsFitParticle * > _ParList1
std::vector< TAbsFitParticle * > _ParList2
TFitConstraintM::~TFitConstraintM ( )
virtual

Definition at line 145 of file TFitConstraintM.cc.

145  {
146 
147 }

Member Function Documentation

void TFitConstraintM::addParticle1 ( TAbsFitParticle particle)

Definition at line 87 of file TFitConstraintM.cc.

References _ParList1.

Referenced by addParticles1(), TSLToyGen::doToyExperiments(), CandMassKinFitter::set(), and StKinFitter::setupFitter().

87  {
88  // Add one constrained particle to first list of particles
89  // ( sum[ m_i ] - sum[ m_j ] - MassConstraint == 0 )
90 
91  _ParList1.push_back( particle );
92 
93 }
std::vector< TAbsFitParticle * > _ParList1
void TFitConstraintM::addParticle2 ( TAbsFitParticle particle)

Definition at line 95 of file TFitConstraintM.cc.

References _ParList2.

Referenced by addParticles2().

95  {
96  // Add one constrained particle to second list of particles
97  // ( sum[ m_i ] - sum[ m_j ] - MassConstraint == 0 )
98 
99  _ParList2.push_back( particle );
100 
101 }
std::vector< TAbsFitParticle * > _ParList2
void TFitConstraintM::addParticles1 ( TAbsFitParticle p1,
TAbsFitParticle p2 = 0,
TAbsFitParticle p3 = 0,
TAbsFitParticle p4 = 0,
TAbsFitParticle p5 = 0,
TAbsFitParticle p6 = 0,
TAbsFitParticle p7 = 0,
TAbsFitParticle p8 = 0,
TAbsFitParticle p9 = 0,
TAbsFitParticle p10 = 0 
)

Definition at line 103 of file TFitConstraintM.cc.

References addParticle1().

Referenced by TSLToyGen::doToyExperiments(), and StKinFitter::setupFitter().

105  {
106  // Add many constrained particle to first list of particles
107  // ( sum[ m_i ] - sum[ m_j ] - MassConstraint == 0 )
108 
109  if (p1) addParticle1( p1 );
110  if (p2) addParticle1( p2 );
111  if (p3) addParticle1( p3 );
112  if (p4) addParticle1( p4 );
113  if (p5) addParticle1( p5 );
114  if (p6) addParticle1( p6 );
115  if (p7) addParticle1( p7 );
116  if (p8) addParticle1( p8 );
117  if (p9) addParticle1( p9 );
118  if (p10) addParticle1( p10 );
119 
120 }
void addParticle1(TAbsFitParticle *particle)
void TFitConstraintM::addParticles2 ( TAbsFitParticle p1,
TAbsFitParticle p2 = 0,
TAbsFitParticle p3 = 0,
TAbsFitParticle p4 = 0,
TAbsFitParticle p5 = 0,
TAbsFitParticle p6 = 0,
TAbsFitParticle p7 = 0,
TAbsFitParticle p8 = 0,
TAbsFitParticle p9 = 0,
TAbsFitParticle p10 = 0 
)

Definition at line 122 of file TFitConstraintM.cc.

References addParticle2().

Referenced by TSLToyGen::doToyExperiments().

124  {
125  // Add many constrained particle to second list of particles
126  // ( sum[ m_i ] - sum[ m_j ] - MassConstraint == 0 )
127 
128  if (p1) addParticle2( p1 );
129  if (p2) addParticle2( p2 );
130  if (p3) addParticle2( p3 );
131  if (p4) addParticle2( p4 );
132  if (p5) addParticle2( p5 );
133  if (p6) addParticle2( p6 );
134  if (p7) addParticle2( p7 );
135  if (p8) addParticle2( p8 );
136  if (p9) addParticle2( p9 );
137  if (p10) addParticle2( p10 );
138 
139 }
void addParticle2(TAbsFitParticle *particle)
Double_t TFitConstraintM::CalcMass ( std::vector< TAbsFitParticle * > *  List,
Bool_t  IniVal 
)

Definition at line 238 of file TFitConstraintM.cc.

References i, and P.

Referenced by TFitConstraintMGaus::getCurrentValue(), getCurrentValue(), TFitConstraintMGaus::getInitValue(), and getInitValue().

238  {
239  // Calculates initial/current invariant mass of provided list of particles
240 
241  TLorentzVector P(0., 0., 0., 0.);
242  UInt_t Npart = List->size();
243  for (unsigned int i=0;i<Npart;i++) {
244  const TLorentzVector* FourVec = 0;
245  if (IniVal)
246  FourVec = ((*List)[i])->getIni4Vec();
247  else
248  FourVec = ((*List)[i])->getCurr4Vec();
249  P += (*FourVec);
250  }
251  return P.M();
252 }
int i
Definition: DBlmapReader.cc:9
#define P
Double_t TFitConstraintM::getCurrentValue ( )
virtual

Implements TAbsFitConstraint.

Reimplemented in TFitConstraintMGaus.

Definition at line 216 of file TFitConstraintM.cc.

References _ParList1, _ParList2, _TheMassConstraint, and CalcMass().

Referenced by TSLToyGen::doToyExperiments(), and getInfoString().

216  {
217  // Get value of constraint after the fit
218 
219  Double_t CurrentValue(0);
220  CurrentValue= CalcMass(&_ParList1,false) - CalcMass(&_ParList2,false) - _TheMassConstraint;
221  return CurrentValue;
222 }
Double_t CalcMass(std::vector< TAbsFitParticle * > *List, Bool_t IniVal)
Double_t _TheMassConstraint
std::vector< TAbsFitParticle * > _ParList1
std::vector< TAbsFitParticle * > _ParList2
TMatrixD * TFitConstraintM::getDerivative ( TAbsFitParticle particle)
virtual

Implements TAbsFitConstraint.

Definition at line 152 of file TFitConstraintM.cc.

References _ParList1, _ParList2, i, and OnList().

152  {
153  // returns derivative df/dP with P=(p,E) and f the constraint (f=0).
154  // The matrix contains one row (df/dp, df/dE).
155 
156  TMatrixD* DerivativeMatrix = new TMatrixD(1,4);
157  (*DerivativeMatrix) *= 0.;
158 
159  // Pf[4] is the 4-Mom (p,E) of the sum of particles on
160  // the list particle is part of
161 
162  Double_t Factor = 0.;
163  TLorentzVector Pf(0., 0., 0., 0.);
164 
165  if( OnList( &_ParList1, particle) ) {
166  UInt_t Npart = _ParList1.size();
167  for (unsigned int i=0; i<Npart; i++) {
168  const TLorentzVector* FourVec = (_ParList1[i])->getCurr4Vec();
169  Pf += (*FourVec);
170  }
171  if( Pf.M() == 0. ) {
172  edm::LogInfo ("KinFitter")
173  << "Division by zero in "
174  << IsA()->GetName() << " (named " << GetName() << ", titled " << GetTitle()
175  << ") will lead to Inf in derivative matrix for particle "
176  << particle->GetName() << ".";
177  }
178  Factor = 1./ Pf.M();
179  } else if (OnList( &_ParList2, particle) ) {
180  UInt_t Npart = _ParList2.size();
181  for (unsigned int i=0; i<Npart; i++) {
182  const TLorentzVector* FourVec = (_ParList2[i])->getCurr4Vec();
183  Pf += (*FourVec);
184  }
185  if( Pf.M() == 0. ) {
186  edm::LogInfo ("KinFitter")
187  << "Division by zero in "
188  << IsA()->GetName() << " (named " << GetName() << ", titled " << GetTitle()
189  << ") will lead to Inf in derivative matrix for particle "
190  << particle->GetName() << ".";
191  }
192  Factor = -1./Pf.M();
193  } else {
194  Factor = 0.;
195  }
196 
197  (*DerivativeMatrix)(0,0) = -Pf[0] ;
198  (*DerivativeMatrix)(0,1) = -Pf[1];
199  (*DerivativeMatrix)(0,2) = -Pf[2];
200  (*DerivativeMatrix)(0,3) = +Pf[3];
201  (*DerivativeMatrix) *= Factor;
202 
203  return DerivativeMatrix;
204 
205 }
int i
Definition: DBlmapReader.cc:9
Bool_t OnList(std::vector< TAbsFitParticle * > *List, TAbsFitParticle *particle)
std::vector< TAbsFitParticle * > _ParList1
std::vector< TAbsFitParticle * > _ParList2
TString TFitConstraintM::getInfoString ( )
virtual

Reimplemented from TAbsFitConstraint.

Reimplemented in TFitConstraintMGaus.

Definition at line 254 of file TFitConstraintM.cc.

References _TheMassConstraint, getCurrentValue(), getInitValue(), and info().

Referenced by print().

254  {
255  // Collect information to be used for printout
256 
257  std::stringstream info;
258  info << std::scientific << std::setprecision(6);
259 
260  info << "__________________________" << std::endl
261  << std::endl;
262  info <<"OBJ: " << IsA()->GetName() << "\t" << GetName() << "\t" << GetTitle() << std::endl;
263 
264  info << "initial value: " << getInitValue() << std::endl;
265  info << "current value: " << getCurrentValue() << std::endl;
266  info << "mass: " << _TheMassConstraint << std::endl;
267 
268  return info.str();
269 
270 }
static const TGPicture * info(bool iBackgroundIsBlack)
Double_t _TheMassConstraint
virtual Double_t getInitValue()
virtual Double_t getCurrentValue()
Double_t TFitConstraintM::getInitValue ( )
virtual

Implements TAbsFitConstraint.

Reimplemented in TFitConstraintMGaus.

Definition at line 208 of file TFitConstraintM.cc.

References _ParList1, _ParList2, _TheMassConstraint, and CalcMass().

Referenced by getInfoString().

208  {
209  // Get initial value of constraint (before the fit)
210 
211  Double_t InitValue(0) ;
212  InitValue = CalcMass(&_ParList1,true) - CalcMass(&_ParList2,true) - _TheMassConstraint ;
213  return InitValue;
214 }
Double_t CalcMass(std::vector< TAbsFitParticle * > *List, Bool_t IniVal)
Double_t _TheMassConstraint
std::vector< TAbsFitParticle * > _ParList1
std::vector< TAbsFitParticle * > _ParList2
Bool_t TFitConstraintM::OnList ( std::vector< TAbsFitParticle * > *  List,
TAbsFitParticle particle 
)

Definition at line 225 of file TFitConstraintM.cc.

References i, and convertSQLiteXML::ok.

Referenced by getDerivative().

226  {
227  // Checks whether list contains given particle
228 
229  Bool_t ok(false);
230  UInt_t Npart = List->size();
231  for (unsigned int i=0;i<Npart;i++) {
232  ok = (particle == (*List)[i]);
233  if (ok) break;
234  }
235  return ok;
236 }
int i
Definition: DBlmapReader.cc:9
void TFitConstraintM::print ( void  )
virtual

Reimplemented from TAbsFitConstraint.

Reimplemented in TFitConstraintMGaus.

Definition at line 272 of file TFitConstraintM.cc.

References getInfoString().

272  {
273  // Print constraint contents
274 
275  edm::LogVerbatim("KinFitter") << this->getInfoString();
276 
277 }
virtual TString getInfoString()
void TFitConstraintM::setMassConstraint ( Double_t  Mass)
inline

Member Data Documentation

std::vector<TAbsFitParticle*> TFitConstraintM::_ParList1
protected
std::vector<TAbsFitParticle*> TFitConstraintM::_ParList2
protected
Double_t TFitConstraintM::_TheMassConstraint
protected