LCFIVertex  0.7.2
zvres.cpp
1 #include <algo/inc/zvres.h>
2 
3 #include <zvtop/include/vertexfinderclassic.h>
4 #include <zvtop/include/candidatevertex.h>
5 #include <zvtop/include/interactionpoint.h>
6 #include <inc/vertex.h>
7 #include <inc/jet.h>
8 #include <inc/event.h>
9 #include <inc/decaychain.h>
10 #include <inc/track.h>
11 #include <inc/trackstate.h>
12 #include <util/inc/memorymanager.h>
13 #include <util/inc/vector3.h>
14 #include <util/inc/matrix.h>
15 #include <util/inc/string.h>
16 #include <string>
17 #include <vector>
18 #include <list>
19 using std::string;
20 
21 
22 
23 namespace vertex_lcfi
24 {
25 
26  using namespace ZVTOP;
27  using namespace util;
29  {
30  //Default Values
31  _Kip = 1.0;
32  _Kalpha = 5.0;
33  _TwoProngCut = 10.0;
34  _TrackTrimCut = 10.0;
35  _ResolverCut = 0.6;
36  _AutoJetAxis = 1;
37  _UseEventIP = 0;
38  }
39 
40  string ZVRES::name() const
41  {
42  return "ZVRES";
43  }
44 
45  std::vector<string> ZVRES::parameterNames() const
46  {
47  std::vector<string> paramNames;
48  paramNames.push_back("Kip");
49  paramNames.push_back("Kalpha");
50  paramNames.push_back("TwoProngCut");
51  paramNames.push_back("TrackTrimCut");
52  paramNames.push_back("ResolverCut");
53  paramNames.push_back("AutoJetAxis");
54  paramNames.push_back("JetAxisX");
55  paramNames.push_back("JetAxisY");
56  paramNames.push_back("JetAxisZ");
57  paramNames.push_back("UseEventIP");
58  return paramNames;
59  }
60 
61  std::vector<string> ZVRES::parameterValues() const
62  {
63  std::vector<string> paramValues;
64  paramValues.push_back(makeString(_Kip));
65  paramValues.push_back(makeString(_Kalpha));
66  paramValues.push_back(makeString(_TwoProngCut));
67  paramValues.push_back(makeString(_TrackTrimCut));
68  paramValues.push_back(makeString(_ResolverCut));
69  paramValues.push_back(makeString(_AutoJetAxis));
70  paramValues.push_back(makeString(_JetAxis.x()));
71  paramValues.push_back(makeString(_JetAxis.y()));
72  paramValues.push_back(makeString(_JetAxis.z()));
73  paramValues.push_back(makeString(_UseEventIP));
74  return paramValues;
75  }
76 
77  void ZVRES::setStringParameter(const string & Parameter, const string & Value)
78  {
79  if (Parameter == "AutoJetAxis")
80  {
81  if (Value == "TRUE")
82  {
83  _AutoJetAxis = 1;
84  return;
85  }
86  if (Value == "FALSE")
87  {
88  _AutoJetAxis = 0;
89  return;
90  }
91  //TODO Throw Something
92  }
93  if (Parameter == "UseEventIP")
94  {
95  if (Value == "TRUE")
96  {
97  _UseEventIP = 1;
98  return;
99  }
100  if (Value == "FALSE")
101  {
102  _UseEventIP = 0;
103  return;
104  }
105  //TODO Throw Something
106  }
107  this->badParameter(Parameter);
108  }
109 
110  void ZVRES::setDoubleParameter(const string & Parameter, const double Value)
111  {
112  if (Parameter == "Kip")
113  {
114  _Kip = Value;
115  return;
116  }
117  if (Parameter == "Kalpha")
118  {
119  _Kalpha = Value;
120  return;
121  }
122  if (Parameter == "TwoProngCut")
123  {
124  _TwoProngCut = Value;
125  return;
126  }
127  if (Parameter == "TrackTrimCut")
128  {
129  _TrackTrimCut = Value;
130  return;
131  }
132  if (Parameter == "ResolverCut")
133  {
134  _ResolverCut = Value;
135  return;
136  }
137  if (Parameter == "JetAxisX")
138  {
139  _JetAxis.x() = Value;
140  return;
141  }
142  if (Parameter == "JetAxisY")
143  {
144  _JetAxis.y() = Value;
145  return;
146  }
147  if (Parameter == "JetAxisZ")
148  {
149  _JetAxis.z() = Value;
150  return;
151  }
152  this->badParameter(Parameter);
153  }
154 
155  void ZVRES::setPointerParameter(const string & Parameter, void * Value)
156  {
157  this->badParameter(Parameter);
158  }
159 
161  {
162  InteractionPoint* IP;
163  //Make the IP object for zvtop
164  if (_UseEventIP == 1)
165  {
166  IP = new InteractionPoint(MyJet->event()->interactionPoint(),MyJet->event()->interactionPointError());
167  MemoryManager<InteractionPoint>::Event()->registerObject(IP);
168  }
169  else
170  {
171  SymMatrix3x3 ipcov;
172  ipcov.clear();
173  //double ie = 10.0/10000.0;
174  //ipcov(0,0)=ie*ie;
175  //ipcov(1,1)=ie*ie;
176  //ipcov(2,2)=ie*ie;
177  ipcov(0,0) = pow(5.0/1000.0,2);
178  ipcov(1,1) = pow(5.0/1000.0,2);
179  ipcov(2,2) = pow(20.0/1000.0,2);
180 
181  //TODO Make these parameters of this class (not hard wired)
182  IP = new InteractionPoint(Vector3(0,0,0),ipcov);
183  MemoryManager<InteractionPoint>::Event()->registerObject(IP);
184  }
185 
186  //Make the jet axis parameter
187  Vector3 JetAxis(0,0,0);
188  if (_AutoJetAxis == 1)
189  {
190  //Automatic - Just loop over tracks and sum momentum
191  for (std::vector<Track*>::const_iterator iTrack = MyJet->tracks().begin();
192  iTrack != MyJet->tracks().end(); ++iTrack)
193  {
194  JetAxis=JetAxis.add((*iTrack)->momentum());
195  }
196  //Make unit vector
197  JetAxis = JetAxis.unit();
198  }
199  else
200  {
201  //Non auto - use parameter
202  JetAxis = _JetAxis;
203  }
204 
205  //Run ZVTOP - result is in order of 3D distance from IP
206  VertexFinderClassic VFinder(MyJet->tracks(),IP,JetAxis,_Kip,_Kalpha,_TwoProngCut,_TrackTrimCut,_ResolverCut);
207  std::list<CandidateVertex*> CVResult = VFinder.findVertices();
208 
209  //Make Vertex objects from CandidateVertices
210  std::vector<Vertex*> VResult;
211  for (std::list<CandidateVertex*>::iterator iCV = CVResult.begin();iCV != CVResult.end();++iCV)
212  {
213  Vertex* MyVertex;
214  if (!(*iCV)->interactionPoint())
215  {
216  MyVertex = new Vertex(*iCV,MyJet->event());
217  }
218  else
219  {
220  std::vector<Track*> Tracks;
221  for (std::vector<TrackState*>::const_iterator iTrack = (*iCV)->trackStateList().begin();
222  iTrack != (*iCV)->trackStateList().end(); ++iTrack)
223  {
224  Tracks.push_back((*iTrack)->parentTrack());
225  }
226  //TODO Fix chi2,prob value
227  MyVertex = new Vertex(MyJet->event(), Tracks, (*iCV)->interactionPoint()->position(), (*iCV)->interactionPoint()->errorMatrix(),(bool)(*iCV)->interactionPoint(),0,0);
228  }
229  MemoryManager<Vertex>::Event()->registerObject(MyVertex);
230  VResult.push_back(MyVertex);
231  }
232 
233  //Make DecayChain from vertices
234  DecayChain* MyDecayChain = new DecayChain(MyJet, std::vector<Track*>(), VResult);
235  MemoryManager<DecayChain>::Event()->registerObject(MyDecayChain);
236  return MyDecayChain;
237  }
238 }
const std::vector< Track * > & tracks() const
Tracks.
Definition: jet.cpp:23
Event * event() const
Event.
Definition: jet.cpp:18
string name() const
Name.
Definition: zvres.cpp:40
void setStringParameter(const string &Parameter, const string &Value)
Set String Parameter.
Definition: zvres.cpp:77
static MemoryManager< T > * Event()
Returns the Event duration singleton instance of the MemoryManager for type T.
std::list< CandidateVertex * > findVertices()
ZVRES()
Default Constructor.
Definition: zvres.cpp:28
void setPointerParameter(const string &Parameter, void *Value)
Set Pointer Parameter.
Definition: zvres.cpp:155
void setDoubleParameter(const string &Parameter, const double Value)
Set Double Parameter.
Definition: zvres.cpp:110
const SymMatrix3x3 & interactionPointError() const
Interaction Point position error.
Definition: event.cpp:55
const Vector3 & interactionPoint() const
Interaction Point position.
Definition: event.cpp:50
std::vector< string > parameterValues() const
Parameter Values.
Definition: zvres.cpp:61
std::vector< string > parameterNames() const
Parameter Names.
Definition: zvres.cpp:45
DecayChain * calculateFor(Jet *MyJet) const
Run the algorithm on a jet.
Definition: zvres.cpp:160