CMS 3D CMS Logo

TFitConstraintEp.cc
Go to the documentation of this file.
1 // Classname: TFitConstraintEp
2 // Author: Jan E. Sundermann, Verena Klose (TU Dresden)
3 
4 //________________________________________________________________
5 //
6 // TFitConstraintEp::
7 // --------------------
8 //
9 // Fit constraint: energy and momentum conservation
10 //
11 
14 #include <iostream>
15 #include <iomanip>
16 #include "TClass.h"
17 
18 //----------------
19 // Constructor --
20 //----------------
21 
23  : TAbsFitConstraint(), _particles(0), _constraint(0.), _component(TFitConstraintEp::pX) {}
24 
26  const TString& title,
27  TFitConstraintEp::component thecomponent,
28  Double_t constraint)
29  : TAbsFitConstraint(name, title), _constraint(constraint), _component(thecomponent) {}
30 
31 TFitConstraintEp::TFitConstraintEp(std::vector<TAbsFitParticle*>* particles,
32  TFitConstraintEp::component thecomponent,
33  Double_t constraint)
34  : TAbsFitConstraint(), _particles(0), _constraint(constraint), _component(thecomponent) {
35  // particles: vector containing pointer to TAbsFitParticle objects.
36  // Energy or momentum conservation will be calculated for
37  // those particles.
38  // thecomponent: conserved 4vector component ( pX, pY, pZ, E ). For
39  // full 4vector conservation four objects of type TFitConstraintEp
40  // are needed (four constraints)
41  // constraint:value of energy or momentum constraint ( e.g. sum[ pX_i ] = constraint )
42 
43  if (particles) {
44  _particles = (*particles);
45  }
46 }
47 
49  const TString& title,
50  std::vector<TAbsFitParticle*>* particles,
51  TFitConstraintEp::component thecomponent,
52  Double_t constraint)
53  : TAbsFitConstraint(name, title), _particles(0), _constraint(constraint), _component(thecomponent) {
54  // particles: vector containing pointer to TAbsFitParticle objects.
55  // Energy or momentum conservation will be calculated for
56  // those particles.
57  // thecomponent: conserved 4vector component ( pX, pY, pZ, E ). For
58  // full 4vector conservation four objects of type TFitConstraintEp
59  // are needed (four constraints)
60  // constraint:value of energy or momentum constraint ( e.g. sum[ pX_i ] = constraint )
61 
62  if (particles) {
63  _particles = (*particles);
64  }
65 }
66 
67 //--------------
68 // Destructor --
69 //--------------
71 
73  // Add one particles to list of constrained particles
74 
75  _particles.push_back(particle);
76 }
77 
82  TAbsFitParticle* p5,
83  TAbsFitParticle* p6,
84  TAbsFitParticle* p7,
85  TAbsFitParticle* p8,
86  TAbsFitParticle* p9,
87  TAbsFitParticle* p10) {
88  // Add many particles to list of constrained particles
89 
90  if (p1)
91  addParticle(p1);
92  if (p2)
93  addParticle(p2);
94  if (p3)
95  addParticle(p3);
96  if (p4)
97  addParticle(p4);
98  if (p5)
99  addParticle(p5);
100  if (p6)
101  addParticle(p6);
102  if (p7)
103  addParticle(p7);
104  if (p8)
105  addParticle(p8);
106  if (p9)
107  addParticle(p9);
108  if (p10)
109  addParticle(p10);
110 }
111 
112 //--------------
113 // Operations --
114 //--------------
116  // returns derivative df/dP with P=(p,E) and f the constraint (f=0).
117  // The matrix contains one row (df/dp, df/dE).
118 
119  TMatrixD* DerivativeMatrix = new TMatrixD(1, 4);
120  (*DerivativeMatrix) *= 0.;
121  (*DerivativeMatrix)(0, (int)_component) = 1.;
122  return DerivativeMatrix;
123 }
124 
126  // Get initial value of constraint (before the fit)
127 
128  Double_t InitValue(0);
129  UInt_t Npart = _particles.size();
130  for (unsigned int i = 0; i < Npart; i++) {
131  const TLorentzVector* FourVec = _particles[i]->getIni4Vec();
132  InitValue += (*FourVec)[(int)_component];
133  }
134  InitValue -= _constraint;
135  return InitValue;
136 }
137 
139  // Get value of constraint after the fit
140 
141  Double_t CurrentValue(0);
142  UInt_t Npart = _particles.size();
143  for (unsigned int i = 0; i < Npart; i++) {
144  const TLorentzVector* FourVec = _particles[i]->getCurr4Vec();
145  CurrentValue += (*FourVec)[(int)_component];
146  }
147  CurrentValue -= _constraint;
148  return CurrentValue;
149 }
150 
152  // Collect information to be used for printout
153 
154  std::stringstream info;
155  info << std::scientific << std::setprecision(6);
156 
157  info << "__________________________" << std::endl << std::endl;
158  info << "OBJ: " << IsA()->GetName() << "\t" << GetName() << "\t" << GetTitle() << std::endl;
159 
160  info << "initial value: " << getInitValue() << std::endl;
161  info << "current value: " << getCurrentValue() << std::endl;
162  info << "component: " << _component << std::endl;
163  info << "constraint: " << _constraint << std::endl;
164 
165  return info.str();
166 }
167 
169  // Print constraint contents
170 
171  edm::LogVerbatim("KinFitter") << this->getInfoString();
172 }
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
TFitConstraintEp::getInfoString
TString getInfoString() override
Definition: TFitConstraintEp.cc:151
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:152
TFitConstraintEp::print
void print() override
Definition: TFitConstraintEp.cc:168
TFitConstraintEp::_component
TFitConstraintEp::component _component
Definition: TFitConstraintEp.h:57
ecalTrigSettings_cff.particles
particles
Definition: ecalTrigSettings_cff.py:11
TFitConstraintEp::~TFitConstraintEp
~TFitConstraintEp() override
Definition: TFitConstraintEp.cc:70
TFitConstraintEp::_particles
std::vector< TAbsFitParticle * > _particles
Definition: TFitConstraintEp.h:55
TAbsFitConstraint
Definition: TAbsFitConstraint.h:10
p2
double p2[4]
Definition: TauolaWrapper.h:90
TAbsFitParticle
Definition: TAbsFitParticle.h:9
TFitConstraintEp::getInitValue
Double_t getInitValue() override
Definition: TFitConstraintEp.cc:125
TFitConstraintEp::_constraint
Double_t _constraint
Definition: TFitConstraintEp.h:56
createfilelist.int
int
Definition: createfilelist.py:10
TFitConstraintEp::getDerivative
TMatrixD * getDerivative(TAbsFitParticle *particle) override
Definition: TFitConstraintEp.cc:115
p4
double p4[4]
Definition: TauolaWrapper.h:92
edm::LogVerbatim
Definition: MessageLogger.h:297
p1
double p1[4]
Definition: TauolaWrapper.h:89
TFitConstraintEp
Definition: TFitConstraintEp.h:9
overlapproblemtsosanalyzer_cfi.title
title
Definition: overlapproblemtsosanalyzer_cfi.py:7
TFitConstraintEp::addParticles
void addParticles(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: TFitConstraintEp.cc:78
HLT_2018_cff.constraint
constraint
Definition: HLT_2018_cff.py:50466
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
p3
double p3[4]
Definition: TauolaWrapper.h:91
TFitConstraintEp::addParticle
void addParticle(TAbsFitParticle *particle)
Definition: TFitConstraintEp.cc:72
TFitConstraintEp::getCurrentValue
Double_t getCurrentValue() override
Definition: TFitConstraintEp.cc:138
TFitConstraintEp::TFitConstraintEp
TFitConstraintEp()
Definition: TFitConstraintEp.cc:22
TFitConstraintEp.h
TFitConstraintEp::component
component
Definition: TFitConstraintEp.h:11