LCFIVertex  0.7.2
secondvertexprob.cpp
1 #include <algo/inc/secondvertexprob.h>
2 #include <inc/vertex.h>
3 #include <inc/decaychain.h>
4 #include <inc/jet.h>
5 #include <inc/track.h>
6 #include <inc/trackstate.h>
7 #include <zvtop/include/interactionpoint.h>
8 #include <zvtop/include/vertexfitterlsm.h>
9 #include <util/inc/util.h>
10 #include <util/inc/string.h>
11 #include <vector>
12 #include <string>
13 //#include <iostream.h>
14 //#include <fstream.h>
15 
16 
17 //author Erik Devetak
18 
19 namespace vertex_lcfi
20 {
21 
22  using std::string;
23  using namespace ZVTOP;
24 
25  SecVertexProb::SecVertexProb()
26  {
27  _Chisquarecut = 20;
28  _Ntrackscut = 1;
29  _ParameterNames.push_back("Chisquarecut");
30  _ParameterNames.push_back("Ntrackscut");
31  _ParameterValues.push_back(makeString(_Chisquarecut));
32  _ParameterValues.push_back(makeString(_Ntrackscut));
33  }
34 
35  string SecVertexProb::name() const
36  {
37  return _Name;
38  }
39 
40  std::vector<string> SecVertexProb::parameterNames() const
41  {
42  return _ParameterNames;
43  }
44 
45  std::vector<string> SecVertexProb::parameterValues() const
46  {
47  _ParameterValues.clear();
48  _ParameterValues.push_back(makeString(_Chisquarecut));
49  _ParameterValues.push_back(makeString(_Ntrackscut));
50  return _ParameterValues;
51  }
52 
53  void SecVertexProb::setStringParameter(const string & Parameter, const string & Value)
54  {
55  this->badParameter(Parameter);
56  }
57 
58  void SecVertexProb::setDoubleParameter(const string & Parameter, const double Value)
59  {
60 
61  if (Parameter == "Chisquarecut")
62  {
63  _Chisquarecut = Value;
64  return;
65  }
66  if (Parameter == "Ntrackscut")
67  {
68  _Ntrackscut = Value;
69  return;
70  }
71  this->badParameter(Parameter);
72  }
73 
74  void SecVertexProb::setPointerParameter(const string & Parameter, void * Value)
75  {
76  this->badParameter(Parameter);
77  }
78 
79  double SecVertexProb::calculateFor(DecayChain* MyDecayChain ) const
80  {
81  Vector3 Position;
82  double chi2;
83  double ndf;
84  double ntrk;
85  InteractionPoint* IP = 0;
86  std::vector< TrackState* > AllTrackStates;
87 
88  for (std::vector<Track*>::const_iterator iTrack = (MyDecayChain->allTracks().begin()); iTrack != MyDecayChain->allTracks().end() ;++iTrack)
89  {
90  AllTrackStates.push_back( (**iTrack).makeState() );
91  }
92  // fit vertex
93  VertexFitterLSM Fitter;
94  Fitter.fitVertex( AllTrackStates, IP, Position, chi2 );
95  ntrk = MyDecayChain->allTracks().size();
96 
97  //also this comes down from the cern libraries, known propriety of gamma distribution.
98  //degrees of freedom calculation
99  ndf = 2* ntrk -3;
100  if( ntrk> _Ntrackscut && chi2 < _Chisquarecut * sqrt(ndf) )
101  return util::prob(chi2,ndf);
102  else
103  return 0;
104  }
105 }
double prob(double ChiSquared, double DegreesOfFreedom)
Calculate probability from Chi Squared and Degrees of freedom.
void setPointerParameter(const string &Parameter, void *Value)
Set Pointer Parameter.
const std::vector< Track * > & allTracks() const
All tracks contained in DecayChain.
Definition: decaychain.cpp:52
void setDoubleParameter(const string &Parameter, const double Value)
Set Double Parameter.
std::vector< string > parameterValues() const
Parameter Values.
std::vector< string > parameterNames() const
Parameter Names.
void setStringParameter(const string &Parameter, const string &Value)
Set String Parameter.
double calculateFor(DecayChain *MyDecayChain) const
Run the algorithm on a Jet.
string name() const
Name.