CMS 3D CMS Logo

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=nullptr, TAbsFitParticle *p3=nullptr, TAbsFitParticle *p4=nullptr, TAbsFitParticle *p5=nullptr, TAbsFitParticle *p6=nullptr, TAbsFitParticle *p7=nullptr, TAbsFitParticle *p8=nullptr, TAbsFitParticle *p9=nullptr, TAbsFitParticle *p10=nullptr)
 
void addParticles2 (TAbsFitParticle *p1, TAbsFitParticle *p2=nullptr, TAbsFitParticle *p3=nullptr, TAbsFitParticle *p4=nullptr, TAbsFitParticle *p5=nullptr, TAbsFitParticle *p6=nullptr, TAbsFitParticle *p7=nullptr, TAbsFitParticle *p8=nullptr, TAbsFitParticle *p9=nullptr, TAbsFitParticle *p10=nullptr)
 
Double_t CalcMass (std::vector< TAbsFitParticle * > *List, Bool_t IniVal)
 
Double_t getCurrentValue () override
 
TMatrixD * getDerivative (TAbsFitParticle *particle) override
 
TString getInfoString () override
 
Double_t getInitValue () override
 
Bool_t OnList (std::vector< TAbsFitParticle * > *List, TAbsFitParticle *particle)
 
void print () override
 
void setMassConstraint (Double_t Mass)
 
 TFitConstraintM ()
 
 TFitConstraintM (const TString &name, const TString &title, std::vector< TAbsFitParticle * > *ParList1, std::vector< TAbsFitParticle * > *ParList2, Double_t Mass=0)
 
 TFitConstraintM (std::vector< TAbsFitParticle * > *ParList1, std::vector< TAbsFitParticle * > *ParList2, Double_t Mass=0)
 
 ~TFitConstraintM () override
 
- 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)
 
 ~TAbsFitConstraint () override
 

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() [1/3]

TFitConstraintM::TFitConstraintM ( )

Definition at line 22 of file TFitConstraintM.cc.

◆ TFitConstraintM() [2/3]

TFitConstraintM::TFitConstraintM ( std::vector< TAbsFitParticle * > *  ParList1,
std::vector< TAbsFitParticle * > *  ParList2,
Double_t  Mass = 0 
)

Definition at line 24 of file TFitConstraintM.cc.

28  // ParList1: Vector containing first list of constrained particles
29  // ( sum[ m_i ] - sum[ m_j ] - MassConstraint == 0 )
30  // ParList2: Vector containing second list of constrained particles
31  // ( sum[ m_i ] - sum[ m_j ] - MassConstraint == 0 )
32 
33  if (ParList1) {
34  _ParList1 = (*ParList1);
35  }
36  if (ParList2) {
37  _ParList2 = (*ParList2);
38  }
39  if (Mass >= 0) {
41  } else if (Mass < 0) {
42  edm::LogWarning("NegativeMassConstr")
43  << "Mass constraint in TFitConstraintM cannot be set to a negative value, will be set to 0.";
44  _TheMassConstraint = 0.;
45  }
46 }

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

◆ TFitConstraintM() [3/3]

TFitConstraintM::TFitConstraintM ( const TString &  name,
const TString &  title,
std::vector< TAbsFitParticle * > *  ParList1,
std::vector< TAbsFitParticle * > *  ParList2,
Double_t  Mass = 0 
)

Definition at line 48 of file TFitConstraintM.cc.

54  // ParList1: Vector containing first list of constrained particles
55  // ( sum[ m_i ] - sum[ m_j ] - MassConstraint == 0 )
56  // ParList2: Vector containing second list of constrained particles
57  // ( sum[ m_i ] - sum[ m_j ] - MassConstraint == 0 )
58 
59  if (ParList1) {
60  _ParList1 = (*ParList1);
61  }
62  if (ParList2) {
63  _ParList2 = (*ParList2);
64  }
65  if (Mass >= 0) {
67  } else if (Mass < 0) {
68  edm::LogWarning("NegativeMassConstr")
69  << "Mass constraint in TFitConstraintM cannot be set to a negative value, will be set to 0.";
70  _TheMassConstraint = 0.;
71  }
72 }

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

◆ ~TFitConstraintM()

TFitConstraintM::~TFitConstraintM ( )
override

Definition at line 160 of file TFitConstraintM.cc.

160 {}

Member Function Documentation

◆ addParticle1()

void TFitConstraintM::addParticle1 ( TAbsFitParticle particle)

Definition at line 73 of file TFitConstraintM.cc.

73  {
74  // Add one constrained particle to first list of particles
75  // ( sum[ m_i ] - sum[ m_j ] - MassConstraint == 0 )
76 
77  _ParList1.push_back(particle);
78 }

References _ParList1.

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

◆ addParticle2()

void TFitConstraintM::addParticle2 ( TAbsFitParticle particle)

Definition at line 80 of file TFitConstraintM.cc.

80  {
81  // Add one constrained particle to second list of particles
82  // ( sum[ m_i ] - sum[ m_j ] - MassConstraint == 0 )
83 
84  _ParList2.push_back(particle);
85 }

References _ParList2.

Referenced by addParticles2().

◆ addParticles1()

void TFitConstraintM::addParticles1 ( TAbsFitParticle p1,
TAbsFitParticle p2 = nullptr,
TAbsFitParticle p3 = nullptr,
TAbsFitParticle p4 = nullptr,
TAbsFitParticle p5 = nullptr,
TAbsFitParticle p6 = nullptr,
TAbsFitParticle p7 = nullptr,
TAbsFitParticle p8 = nullptr,
TAbsFitParticle p9 = nullptr,
TAbsFitParticle p10 = nullptr 
)

Definition at line 87 of file TFitConstraintM.cc.

96  {
97  // Add many constrained particle to first list of particles
98  // ( sum[ m_i ] - sum[ m_j ] - MassConstraint == 0 )
99 
100  if (p1)
101  addParticle1(p1);
102  if (p2)
103  addParticle1(p2);
104  if (p3)
105  addParticle1(p3);
106  if (p4)
107  addParticle1(p4);
108  if (p5)
109  addParticle1(p5);
110  if (p6)
111  addParticle1(p6);
112  if (p7)
113  addParticle1(p7);
114  if (p8)
115  addParticle1(p8);
116  if (p9)
117  addParticle1(p9);
118  if (p10)
119  addParticle1(p10);
120 }

References addParticle1(), p1, p2, p3, and p4.

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

◆ addParticles2()

void TFitConstraintM::addParticles2 ( TAbsFitParticle p1,
TAbsFitParticle p2 = nullptr,
TAbsFitParticle p3 = nullptr,
TAbsFitParticle p4 = nullptr,
TAbsFitParticle p5 = nullptr,
TAbsFitParticle p6 = nullptr,
TAbsFitParticle p7 = nullptr,
TAbsFitParticle p8 = nullptr,
TAbsFitParticle p9 = nullptr,
TAbsFitParticle p10 = nullptr 
)

Definition at line 122 of file TFitConstraintM.cc.

131  {
132  // Add many constrained particle to second list of particles
133  // ( sum[ m_i ] - sum[ m_j ] - MassConstraint == 0 )
134 
135  if (p1)
136  addParticle2(p1);
137  if (p2)
138  addParticle2(p2);
139  if (p3)
140  addParticle2(p3);
141  if (p4)
142  addParticle2(p4);
143  if (p5)
144  addParticle2(p5);
145  if (p6)
146  addParticle2(p6);
147  if (p7)
148  addParticle2(p7);
149  if (p8)
150  addParticle2(p8);
151  if (p9)
152  addParticle2(p9);
153  if (p10)
154  addParticle2(p10);
155 }

References addParticle2(), p1, p2, p3, and p4.

Referenced by TSLToyGen::doToyExperiments().

◆ CalcMass()

Double_t TFitConstraintM::CalcMass ( std::vector< TAbsFitParticle * > *  List,
Bool_t  IniVal 
)

Definition at line 244 of file TFitConstraintM.cc.

244  {
245  // Calculates initial/current invariant mass of provided list of particles
246 
247  TLorentzVector P(0., 0., 0., 0.);
248  UInt_t Npart = List->size();
249  for (unsigned int i = 0; i < Npart; i++) {
250  const TLorentzVector* FourVec = nullptr;
251  if (IniVal)
252  FourVec = ((*List)[i])->getIni4Vec();
253  else
254  FourVec = ((*List)[i])->getCurr4Vec();
255  P += (*FourVec);
256  }
257  return P.M();
258 }

References mps_fire::i.

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

◆ getCurrentValue()

Double_t TFitConstraintM::getCurrentValue ( )
overridevirtual

Implements TAbsFitConstraint.

Reimplemented in TFitConstraintMGaus.

Definition at line 223 of file TFitConstraintM.cc.

223  {
224  // Get value of constraint after the fit
225 
226  Double_t CurrentValue(0);
227  CurrentValue = CalcMass(&_ParList1, false) - CalcMass(&_ParList2, false) - _TheMassConstraint;
228  return CurrentValue;
229 }

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

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

◆ getDerivative()

TMatrixD * TFitConstraintM::getDerivative ( TAbsFitParticle particle)
overridevirtual

Implements TAbsFitConstraint.

Definition at line 165 of file TFitConstraintM.cc.

165  {
166  // returns derivative df/dP with P=(p,E) and f the constraint (f=0).
167  // The matrix contains one row (df/dp, df/dE).
168 
169  TMatrixD* DerivativeMatrix = new TMatrixD(1, 4);
170  (*DerivativeMatrix) *= 0.;
171 
172  // Pf[4] is the 4-Mom (p,E) of the sum of particles on
173  // the list particle is part of
174 
175  Double_t Factor = 0.;
176  TLorentzVector Pf(0., 0., 0., 0.);
177 
178  if (OnList(&_ParList1, particle)) {
179  UInt_t Npart = _ParList1.size();
180  for (unsigned int i = 0; i < Npart; i++) {
181  const TLorentzVector* FourVec = (_ParList1[i])->getCurr4Vec();
182  Pf += (*FourVec);
183  }
184  if (Pf.M() == 0.) {
185  edm::LogInfo("KinFitter") << "Division by zero in " << IsA()->GetName() << " (named " << GetName() << ", titled "
186  << GetTitle() << ") will lead to Inf in derivative matrix for particle "
187  << particle->GetName() << ".";
188  }
189  Factor = 1. / Pf.M();
190  } else if (OnList(&_ParList2, particle)) {
191  UInt_t Npart = _ParList2.size();
192  for (unsigned int i = 0; i < Npart; i++) {
193  const TLorentzVector* FourVec = (_ParList2[i])->getCurr4Vec();
194  Pf += (*FourVec);
195  }
196  if (Pf.M() == 0.) {
197  edm::LogInfo("KinFitter") << "Division by zero in " << IsA()->GetName() << " (named " << GetName() << ", titled "
198  << GetTitle() << ") will lead to Inf in derivative matrix for particle "
199  << particle->GetName() << ".";
200  }
201  Factor = -1. / Pf.M();
202  } else {
203  Factor = 0.;
204  }
205 
206  (*DerivativeMatrix)(0, 0) = -Pf[0];
207  (*DerivativeMatrix)(0, 1) = -Pf[1];
208  (*DerivativeMatrix)(0, 2) = -Pf[2];
209  (*DerivativeMatrix)(0, 3) = +Pf[3];
210  (*DerivativeMatrix) *= Factor;
211 
212  return DerivativeMatrix;
213 }

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

◆ getInfoString()

TString TFitConstraintM::getInfoString ( )
overridevirtual

Reimplemented from TAbsFitConstraint.

Reimplemented in TFitConstraintMGaus.

Definition at line 260 of file TFitConstraintM.cc.

260  {
261  // Collect information to be used for printout
262 
263  std::stringstream info;
264  info << std::scientific << std::setprecision(6);
265 
266  info << "__________________________" << std::endl << std::endl;
267  info << "OBJ: " << IsA()->GetName() << "\t" << GetName() << "\t" << GetTitle() << std::endl;
268 
269  info << "initial value: " << getInitValue() << std::endl;
270  info << "current value: " << getCurrentValue() << std::endl;
271  info << "mass: " << _TheMassConstraint << std::endl;
272 
273  return info.str();
274 }

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

Referenced by print().

◆ getInitValue()

Double_t TFitConstraintM::getInitValue ( )
overridevirtual

Implements TAbsFitConstraint.

Reimplemented in TFitConstraintMGaus.

Definition at line 215 of file TFitConstraintM.cc.

215  {
216  // Get initial value of constraint (before the fit)
217 
218  Double_t InitValue(0);
219  InitValue = CalcMass(&_ParList1, true) - CalcMass(&_ParList2, true) - _TheMassConstraint;
220  return InitValue;
221 }

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

Referenced by getInfoString().

◆ OnList()

Bool_t TFitConstraintM::OnList ( std::vector< TAbsFitParticle * > *  List,
TAbsFitParticle particle 
)

Definition at line 231 of file TFitConstraintM.cc.

231  {
232  // Checks whether list contains given particle
233 
234  Bool_t ok(false);
235  UInt_t Npart = List->size();
236  for (unsigned int i = 0; i < Npart; i++) {
237  ok = (particle == (*List)[i]);
238  if (ok)
239  break;
240  }
241  return ok;
242 }

References mps_fire::i, and convertSQLiteXML::ok.

Referenced by getDerivative().

◆ print()

void TFitConstraintM::print ( void  )
overridevirtual

Reimplemented from TAbsFitConstraint.

Reimplemented in TFitConstraintMGaus.

Definition at line 276 of file TFitConstraintM.cc.

276  {
277  // Print constraint contents
278 
279  edm::LogVerbatim("KinFitter") << this->getInfoString();
280 }

References getInfoString().

◆ setMassConstraint()

void TFitConstraintM::setMassConstraint ( Double_t  Mass)
inline

Definition at line 45 of file TFitConstraintM.h.

References _TheMassConstraint, and HLTSiStripMonitoring_cff::Mass.

Member Data Documentation

◆ _ParList1

std::vector<TAbsFitParticle*> TFitConstraintM::_ParList1
protected

◆ _ParList2

std::vector<TAbsFitParticle*> TFitConstraintM::_ParList2
protected

◆ _TheMassConstraint

Double_t TFitConstraintM::_TheMassConstraint
protected
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
mps_fire.i
i
Definition: mps_fire.py:428
TFitConstraintM::getInfoString
TString getInfoString() override
Definition: TFitConstraintM.cc:260
TFitConstraintM::_ParList2
std::vector< TAbsFitParticle * > _ParList2
Definition: TFitConstraintM.h:63
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
TFitConstraintM::addParticle1
void addParticle1(TAbsFitParticle *particle)
Definition: TFitConstraintM.cc:73
TFitConstraintM::addParticle2
void addParticle2(TAbsFitParticle *particle)
Definition: TFitConstraintM.cc:80
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
TFitConstraintM::CalcMass
Double_t CalcMass(std::vector< TAbsFitParticle * > *List, Bool_t IniVal)
Definition: TFitConstraintM.cc:244
TFitConstraintM::_ParList1
std::vector< TAbsFitParticle * > _ParList1
Definition: TFitConstraintM.h:61
p2
double p2[4]
Definition: TauolaWrapper.h:90
HLTSiStripMonitoring_cff.Mass
Mass
Definition: HLTSiStripMonitoring_cff.py:135
TAbsFitConstraint::TAbsFitConstraint
TAbsFitConstraint()
Definition: TAbsFitConstraint.cc:18
TFitConstraintM::getInitValue
Double_t getInitValue() override
Definition: TFitConstraintM.cc:215
p4
double p4[4]
Definition: TauolaWrapper.h:92
p1
double p1[4]
Definition: TauolaWrapper.h:89
TFitConstraintM::_TheMassConstraint
Double_t _TheMassConstraint
Definition: TFitConstraintM.h:64
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
TFitConstraintM::getCurrentValue
Double_t getCurrentValue() override
Definition: TFitConstraintM.cc:223
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
p3
double p3[4]
Definition: TauolaWrapper.h:91
TFitConstraintM::OnList
Bool_t OnList(std::vector< TAbsFitParticle * > *List, TAbsFitParticle *particle)
Definition: TFitConstraintM.cc:231
P
std::pair< OmniClusterRef, TrackingParticleRef > P
Definition: BDHadronTrackMonitoringAnalyzer.cc:202