Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FilterEvents.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FilterEvents.cc
1 
2 #include "FilterEvents.h"
3 
4 #include <cstdlib>
5 #include <cstdio>
6 #include <iostream>
7 #include <iomanip>
8 #include <fstream>
9 
10 #include <TFile.h>
11 
15 #include <trackbase_historic/SvtxVertex.h>
16 #include <trackbase_historic/SvtxVertexMap_v1.h>
21 #include <trackbase/TrkrDefs.h>
22 #include <trackbase/TrkrCluster.h>
26 #include <g4vertex/GlobalVertexMap.h>
27 #include <g4vertex/GlobalVertex.h>
28 #include <calobase/RawClusterContainer.h>
29 #include <calobase/RawCluster.h>
30 #include <calobase/RawClusterv1.h>
31 
32 #include <KFParticle.h>
33 
34 #include <phool/getClass.h>
35 #include <phool/recoConsts.h>
36 #include <phool/PHCompositeNode.h>
37 #include <phool/PHIODataNode.h>
38 #include <phool/PHNodeIterator.h>
39 #include <phool/PHRandomSeed.h>
41 
43 
44 using namespace std;
45 
46 //==============================================================
47 
49 {
50  outnodename_trackmap = "SvtxTrackMap_ee";
51  outnodename_cemc_clusters = "CLUSTER_CEMC_ee";
52  EventNumber=0;
54 
55  pt_cut = 2;
56  dca_cut = 0;
57  chi2ndof_cut = 999.9;
58  CEMC_use = true;
59 }
60 
61 //-------------------------------------------------------------------------------
62 
64 {
65 
66 cout << "FilterEvents::Init started..." << endl;
67 
68  PHNodeIterator iter(topNode);
69  //PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
70  PHCompositeNode *dstNode = static_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
71  if (!dstNode) { cerr << PHWHERE << " ERROR: DST node not found." << endl; return Fun4AllReturnCodes::ABORTEVENT; }
72 
73 // PHNodeIterator dstiter(dstNode);
74 // PHCompositeNode *svtxNode = dynamic_cast<PHCompositeNode *>(dstiter.findFirst("PHCompositeNode", "SVTX"));
75 // if (!svtxNode) { cerr << PHWHERE << " ERROR: SVTX node not found." << endl; return Fun4AllReturnCodes::ABORTEVENT; }
76 //
77 // PHCompositeNode *cemcNode = dynamic_cast<PHCompositeNode *>(dstiter.findFirst("PHCompositeNode", "CEMC"));
78 // if (!cemcNode) { cerr << PHWHERE << " ERROR: CEMC node not found." << endl; return Fun4AllReturnCodes::ABORTEVENT; }
79 
80  SvtxTrackMap_v2* trackmap = new SvtxTrackMap_v2();
81  PHCompositeNode *trackmapNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", outnodename_trackmap));
82  if (!trackmapNode)
83  {
84  PHObjectNode_t *trackmapNode = new PHIODataNode<PHObject>(trackmap,outnodename_trackmap.c_str(),"PHObject");
85  dstNode->addNode(trackmapNode);
86  //svtxNode->addNode(trackmapNode);
87  cout << PHWHERE << " INFO: added " << outnodename_trackmap << " node." << endl;
88  }
89  else { cout << PHWHERE << " INFO: " << outnodename_trackmap << " node already exists." << endl; }
90 
91  if(CEMC_use){
94  dstNode->addNode(clusterNode);
95  //cemcNode->addNode(clusterNode);
96  }
97 // PHCompositeNode *cemcclusNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", outnodename_cemc_clusters));
98 // if (!cemcclusNode)
99 // {
100 // PHObjectNode_t *cemcclusNode = new PHIODataNode<PHObject>(cemc_clusters,outnodename_cemc_clusters.c_str(),"PHObject");
101 // dstNode->addNode(cemcclusNode);
102 // cout << PHWHERE << " INFO: added " << outnodename_cemc_clusters << " node." << endl;
103 // }
104 // else { cout << PHWHERE << " INFO: " << outnodename_cemc_clusters << " node already exists." << endl; }
105 
106 cout << "FilterEvents::Init ended." << endl;
108 }
109 
110 //--------------------------------------------------------------------------------
111 
113 {
115 }
116 
117 //--------------------------------------------------------------------------------
118 
120 {
121 
122  _topNode = topNode;
123 
124  //topNode->print();
125 
126  _trackmap_ee = findNode::getClass<SvtxTrackMap>(topNode, outnodename_trackmap);
127  if(!_trackmap_ee) { cerr << PHWHERE << "ERROR: Output SvtxTrackMap_ee node not found." << endl; return Fun4AllReturnCodes::ABORTEVENT; }
128 // else {cout << "Found SvtxTrackMap_ee node." << endl; }
129 
130  if (CEMC_use){
131  _cemc_clusters_ee = findNode::getClass<RawClusterContainer>(topNode, outnodename_cemc_clusters);
132  if(!_cemc_clusters_ee) { cerr << PHWHERE << "ERROR: CLUSTER_CEMC_ee node not found." << endl; return Fun4AllReturnCodes::ABORTEVENT; }
133 // else {cout << "Found CLUSTER_CEMC_ee node." << endl; }
134  }
135 
136  _trackmap = findNode::getClass<SvtxTrackMap>(topNode, "SvtxTrackMap");
137  if(!_trackmap) { cerr << PHWHERE << "ERROR: SvtxTrackMap node not found." << endl; return Fun4AllReturnCodes::ABORTEVENT; }
138 
139 
140  _vtxmap = findNode::getClass<SvtxVertexMap_v1>(topNode, "SvtxVertexMap");
141  if(!_vtxmap) { cout << "ERROR: SvtxVertexMap node not found!" << endl; return Fun4AllReturnCodes::ABORTEVENT; }
142 
143  _trackseedcontainer_svtx = findNode::getClass<TrackSeedContainer>(topNode, "SvtxTrackSeedContainer");
144  if(!_trackseedcontainer_svtx) { cerr << PHWHERE << "ERROR: SvtxTrackSeedContainer node not found." << endl; return Fun4AllReturnCodes::ABORTEVENT; }
145 
146  _trackseedcontainer_silicon = findNode::getClass<TrackSeedContainer>(topNode, "SiliconTrackSeedContainer");
147  if(!_trackseedcontainer_silicon) { cerr << PHWHERE << "ERROR: SiliconTrackSeedContainer node not found." << endl; return Fun4AllReturnCodes::ABORTEVENT; }
148 
149  _trackseedcontainer_tpc = findNode::getClass<TrackSeedContainer>(topNode, "TpcTrackSeedContainer");
150  if(!_trackseedcontainer_tpc) { cerr << PHWHERE << "ERROR: TpcTrackSeedContainer node not found." << endl; return Fun4AllReturnCodes::ABORTEVENT; }
151 
152  _trkrclusters = findNode::getClass<TrkrClusterContainerv4>(topNode, "TRKR_CLUSTER");
153  if(!_trkrclusters) { cerr << PHWHERE << "ERROR: TRKR_CLUSTER node not found." << endl; return Fun4AllReturnCodes::ABORTEVENT; }
154 
155  if (CEMC_use){
156  _cemc_clusters = findNode::getClass<RawClusterContainer>(topNode, "CLUSTER_CEMC");
157  if(!_cemc_clusters) { cerr << PHWHERE << "ERROR: CLUSTER_CEMC node not found." << endl; return Fun4AllReturnCodes::ABORTEVENT; }
158  }
160 }
161 
162 //--------------------------------------------------------------------
163 
165 
166  TVector3 projection; // 0,0,0
167 
168  vector<double> proj;
169  for (SvtxTrack::StateIter stateiter = track->begin_states(); stateiter != track->end_states(); ++stateiter)
170  {
171  SvtxTrackState *trackstate = stateiter->second;
172  if(trackstate) { proj.push_back(trackstate->get_pathlength()); }
173  }
174  double pathlength = proj[proj.size()-3]; // CEMC is next next to last, usually 93.5
175 
176  SvtxTrackState* trackstate = track->get_state(pathlength); // at CEMC inner face
177  if(trackstate) {
178  double track_x = trackstate->get_x();
179  double track_y = trackstate->get_y();
180  double track_z = trackstate->get_z();
181  projection.SetX(track_x);
182  projection.SetY(track_y);
183  projection.SetZ(track_z);
184  }
185 
186  return projection;
187 }
188 
189 //--------------------------------------------------------------------
190 
191 RawCluster* FilterEvents::MatchClusterCEMC(SvtxTrack* track, RawClusterContainer* cemc_clusters, double &dphi, double &deta, double Zvtx) {
192 
193  RawCluster* returnCluster = NULL;
194  double track_eta = 99999.;
195  double track_phi = 99999.;
196  dphi = 99999.;
197  deta = 99999.;
198 
199  vector<double> proj;
200  for (SvtxTrack::StateIter stateiter = track->begin_states(); stateiter != track->end_states(); ++stateiter)
201  {
202  SvtxTrackState *trackstate = stateiter->second;
203  if(trackstate) { proj.push_back(trackstate->get_pathlength()); }
204  }
205  double pathlength = proj[proj.size()-3]; // CEMC is next next to last
206 
207  SvtxTrackState* trackstate = track->get_state(pathlength); // at CEMC inner face
208  if(trackstate) {
209  double track_x = trackstate->get_x();
210  double track_y = trackstate->get_y();
211  double track_z = trackstate->get_z() - Zvtx;
212  double track_r = sqrt(track_x*track_x+track_y*track_y);
213  track_eta = asinh( track_z / track_r );
214  track_phi = atan2( track_y, track_x );
215  } else { return returnCluster; }
216 
217  if(track_eta == 99999. || track_phi == 99999.) { return returnCluster; }
218  double dist = 99999.;
219 
220  RawClusterContainer::Range begin_end = cemc_clusters->getClusters();
222  for (iter = begin_end.first; iter != begin_end.second; ++iter)
223  {
224  RawCluster* cluster = iter->second;
225  if(!cluster) continue;
226  else {
227  double cemc_ecore = cluster->get_ecore();
228  if(cemc_ecore<1.0) continue;
229  double cemc_x = cluster->get_x();
230  double cemc_y = cluster->get_y();
231  double cemc_z = cluster->get_z() - Zvtx;
232  double cemc_r = cluster->get_r();
233  double cemc_eta = asinh( cemc_z / cemc_r );
234  double cemc_phi = atan2( cemc_y, cemc_x );
235  double tmpdist = sqrt(pow((cemc_eta-track_eta),2)+pow((cemc_phi-track_phi),2));
236  if(tmpdist<dist) {
237  dist = tmpdist; returnCluster = cluster; dphi = fabs(cemc_phi-track_phi); deta = fabs(cemc_eta-track_eta);
238  }
239  }
240  }
241 
242  return returnCluster;
243 }
244 
245 //--------------------------------------------------------------------------------
246 
248 
249  EventNumber++;
250  int ngood = 0;
251  bool goodevent = false;
252 
253 cout << "getting nodes..." << endl;
254  GetNodes(topNode);
255 
256  GlobalVertexMap* _global_vtxmap = findNode::getClass<GlobalVertexMap>(topNode, "GlobalVertexMap");
257  if(!_global_vtxmap) { cerr << PHWHERE << "ERROR: GlobalVertexMap node not found." << endl; return Fun4AllReturnCodes::ABORTEVENT; }
258 
259  double Zvtx = 0.;
260  for (GlobalVertexMap::Iter iter = _global_vtxmap->begin(); iter != _global_vtxmap->end(); ++iter)
261  {
262  GlobalVertex *vtx = iter->second;
263  if(vtx->get_id()==1) { Zvtx = vtx->get_z(); } // BBC vertex
264  }
265  cout << "Global BBC vertex Z = " << Zvtx << endl;
266 
267  std::vector<RawCluster *> goodclusters;
268  //std::vector<TrkrCluster*> vclussilicon;
269  //std::vector<TrkrCluster*> vclustpc;
270  std::map<TrkrDefs::cluskey,TrkrCluster*> m_clusters;
271  //std::map<TrkrDefs::cluskey> vcluskeytpc;
272  std::vector<SvtxTrackSeed_v1*> v_svtx_trackseed;
273  std::vector<TrackSeed*> v_silicon_trackseed;
274  std::vector<TrackSeed*> v_tpc_trackseed;
275 
276  cout << "Total number of tracks = " << _trackmap->size() << endl;
277  if (CEMC_use) cout << "Total number of CEMC clusters = " << _cemc_clusters->size() << endl;
278  cout << "Total number of svtx track seeds: " << _trackseedcontainer_svtx->size() << endl;
279  cout << "Total number of silicon track seeds: " << _trackseedcontainer_silicon->size() << endl;
280  cout << "Total number of tpc track seeds: " << _trackseedcontainer_tpc->size() << endl;
281  cout << "Total number of TRKR clusters: " << _trkrclusters->size() << endl;
282 
283  // Start loop over tracks;
284 
285  for (SvtxTrackMap::Iter iter = _trackmap->begin(); iter != _trackmap->end(); ++iter)
286  {
287  SvtxTrack *track = iter->second;
288 
289  double px = track->get_px();
290  double py = track->get_py();
291  double pz = track->get_pz();
292  double pt = sqrt(px * px + py * py);
293  double chi2ndf = track->get_chisq()/track->get_ndf();
294  double dca;
295  double dcaxy;
296  double dcaz, dcaxy_sig, dcaz_sig;
297 
298  get_dca(track, _vtxmap, dca, dcaxy);
299  get_dca_SvtxEval(track, _vtxmap, dcaxy, dcaz, dcaxy_sig, dcaz_sig);
300  if(pt < pt_cut) continue;
301  if(chi2ndf > chi2ndof_cut) continue;
302  if(abs(dca) < dca_cut) continue;
303 
304  double mom = sqrt(px * px + py * py + pz * pz);
305 
306  double cemc_dphi = 99999.;
307  double cemc_deta = 99999.;
308  if (CEMC_use)
309  {
310  RawCluster* clus;
311  clus = MatchClusterCEMC(track, _cemc_clusters, cemc_dphi, cemc_deta, Zvtx);
312  if(!clus && CEMC_use) continue;
313 
314  double cemc_ecore = 0.;
315  cemc_ecore = clus->get_ecore();
316  if(cemc_ecore/mom < 0.7) continue;
317  }
318 
319  ngood++;
320  goodevent = true;
321  SvtxTrack* tmp =_trackmap_ee->insert(track);
322  if(!tmp) cout << "ERROR: Failed to insert a track." << endl;
323 
324  cout << " Track: " << pt << endl;
325 
326  TrackSeed* trackseed_silicon = track->get_silicon_seed();
327  double trackseed_silicon_pt = trackseed_silicon->get_pt();
328  cout << " Silicon seed: " << trackseed_silicon << " " << trackseed_silicon_pt << " " << trackseed_silicon->size_cluster_keys() << endl;
329  TrackSeed_v1* tmpseedsilicon = (TrackSeed_v1*)trackseed_silicon->CloneMe();
330  v_silicon_trackseed.push_back(tmpseedsilicon);
331 
332  TrackSeed* trackseed_tpc = track->get_tpc_seed();
333  double trackseed_tpc_pt = trackseed_tpc->get_pt();
334  cout << " TPC seed: " << trackseed_tpc << " " << trackseed_tpc_pt << " " << trackseed_tpc->size_cluster_keys() << endl;
335  TrackSeed_v1* tmpseedtpc = (TrackSeed_v1*)trackseed_tpc->CloneMe();
336  v_tpc_trackseed.push_back(tmpseedtpc);
337 
338 // Find SVTX seed for this track
339  for(TrackSeedContainer::ConstIter seediter = _trackseedcontainer_svtx->begin(); seediter != _trackseedcontainer_svtx->end(); ++seediter)
340  {
341  SvtxTrackSeed_v1* seed = (SvtxTrackSeed_v1*)*seediter;
342  //TrackSeed* seed = *seediter;
343  bool foundsiliconseed = false;
344  bool foundtpcseed = false;
345  unsigned int siliconid = seed->get_silicon_seed_index();
346  unsigned int tpcid = seed->get_tpc_seed_index();
347  //cout << " SVTX seed: " << seed << " " << siliconid << " " << tpcid << endl;
348  TrackSeed* tmptpcseed = _trackseedcontainer_tpc->get(tpcid);
349  double tmptpcseed_pt = tmptpcseed->get_pt();
350  TrackSeed* tmpsiliconseed = _trackseedcontainer_silicon->get(siliconid);
351  double tmpsiliconseed_pt = tmpsiliconseed->get_pt();
352  if(tmpsiliconseed_pt == trackseed_silicon_pt) {foundsiliconseed = true; cout << " Found silicon seed " << tmpsiliconseed << endl;}
353  if(tmptpcseed_pt == trackseed_tpc_pt) {foundtpcseed = true; cout << " Found tpc seed " << tmptpcseed << endl;}
354  if(foundsiliconseed && foundtpcseed) {
355  cout << " THIS IS THE ONE: " << seed << " " << siliconid << " " << tpcid << endl;
356  SvtxTrackSeed_v1* tmpseed = (SvtxTrackSeed_v1*)seed->CloneMe();
357  v_svtx_trackseed.push_back(tmpseed);
358  }
359  }
360 
361 // Find all TRKR clusters for this track
362  for(auto clusiter = trackseed_silicon->begin_cluster_keys(); clusiter != trackseed_silicon->end_cluster_keys(); ++clusiter)
363  {
364  //auto key = *clusiter;
365  TrkrDefs::cluskey key = *clusiter;
366  TrkrCluster* clus = _trkrclusters->findCluster(key);
367  bool isinserted = false;
368  for(std::map<TrkrDefs::cluskey,TrkrCluster*>::iterator it = m_clusters.begin(); it != m_clusters.end(); it++) {if(clus==it->second) {isinserted=true; break;}}
369  if(!isinserted) {TrkrCluster* newclus = (TrkrClusterv4*)clus->CloneMe(); m_clusters.insert(std::make_pair(key,newclus));}
370  }
371  for(auto clusiter = trackseed_tpc->begin_cluster_keys(); clusiter != trackseed_tpc->end_cluster_keys(); ++clusiter)
372  {
373  //auto key = *clusiter;
374  TrkrDefs::cluskey key = *clusiter;
375  TrkrCluster* clus = _trkrclusters->findCluster(key);
376  bool isinserted = false;
377  for(std::map<TrkrDefs::cluskey,TrkrCluster*>::iterator it = m_clusters.begin(); it != m_clusters.end(); it++) {if(clus==it->second) {isinserted=true; break;}}
378  if(!isinserted) {TrkrCluster* newclus = (TrkrClusterv4*)clus->CloneMe(); m_clusters.insert(std::make_pair(key,newclus));}
379  }
380 
381  TVector3 proj = GetProjectionCEMC(track);
382  double track_x = proj(0);
383  double track_y = proj(1);
384  double track_z = proj(2) - Zvtx;
385  double track_r = sqrt(track_x*track_x+track_y*track_y);
386  double track_eta = asinh( track_z / track_r );
387  double track_phi = atan2( track_y, track_x );
388 
389  if (CEMC_use){
390 // Find all CEMC clusters around this track projection
393  for (clusiter = begin_end.first; clusiter != begin_end.second; ++clusiter)
394  {
395  RawCluster* cluster = clusiter->second;
396  if(!cluster) { cout << "ERROR: bad cluster pointer = " << cluster << endl; continue; }
397  else {
398  double cemc_ecore = cluster->get_ecore();
399  if(cemc_ecore<1.0) continue;
400  double cemc_x = cluster->get_x();
401  double cemc_y = cluster->get_y();
402  double cemc_z = cluster->get_z() - Zvtx;
403  double cemc_r = cluster->get_r();
404  double cemc_eta = asinh( cemc_z / cemc_r );
405  double cemc_phi = atan2( cemc_y, cemc_x );
406  double dist = sqrt(pow(cemc_phi-track_phi,2)+pow(cemc_eta-track_eta,2));
407  if(dist<0.1) {
408  bool isinserted = false;
409  for(unsigned int i=0; i<goodclusters.size(); i++) {if(cluster==goodclusters[i]) {isinserted=true; break;}}
410  if(!isinserted) {RawCluster* newcluster = (RawClusterv1*)cluster->CloneMe(); goodclusters.push_back(newcluster);}
411  }
412  }
413  } // end loop over cemc clusters
414 
415  }
416  } // end loop over tracks
417 
418  cout << " Number of CEMC clusters for output = " << goodclusters.size() << endl;
419  cout << " Number of svtx seeds for output = " << v_svtx_trackseed.size() << endl;
420  cout << " Number of tpc seeds for output = " << v_tpc_trackseed.size() << endl;
421  cout << " Number of silicon seeds for output = " << v_silicon_trackseed.size() << endl;
422 
423 // Fill in selected CEMC clusters
424  if (CEMC_use){
426  for (unsigned int cl = 0; cl < goodclusters.size(); cl++) { _cemc_clusters->AddCluster(goodclusters[cl]); }
427  }
428 
429  cout << " Number of TRKR clusters and keys for output: " << m_clusters.size() << " " << m_clusters.size() << endl;
430 
431  _trkrclusters->Reset();
432  for(std::map<TrkrDefs::cluskey,TrkrCluster*>::iterator it = m_clusters.begin(); it != m_clusters.end(); it++)
433  {
434  //std::cout << it->first << std::endl;
435  _trkrclusters->addClusterSpecifyKey(it->first,it->second);
436  }
437  cout << " New TRKR_CLUSTER size = " << _trkrclusters->size() << endl;
438 
439 
441  for(unsigned int cl = 0; cl < v_svtx_trackseed.size(); cl++)
442  { _trackseedcontainer_svtx->insert(v_svtx_trackseed[cl]); }
443 
444 /*
445  _trackseedcontainer_silicon->Reset();
446  for(unsigned int cl = 0; cl < v_silicon_trackseed.size(); cl++)
447  { _trackseedcontainer_silicon->insert(v_silicon_trackseed[cl]); }
448  _trackseedcontainer_tpc->Reset();
449  for(unsigned int cl = 0; cl < v_tpc_trackseed.size(); cl++)
450  { _trackseedcontainer_tpc->insert(v_tpc_trackseed[cl]); }
451 */
452 
453  cout << " New numbers of seeds = " << _trackseedcontainer_svtx->size() << " " << _trackseedcontainer_silicon->size() << " " << _trackseedcontainer_tpc->size() << endl;
454  if(ngood>=2) { goodEventNumber++; }
455 
456  cout << ngood << " " << EventNumber << " " << goodEventNumber << endl;
457  if(goodevent) {return Fun4AllReturnCodes::EVENT_OK;} else {return Fun4AllReturnCodes::ABORTEVENT;}
458 }
459 
460 //---------------------------------------------------------------------------
461 
463 {
464  cout << "Number of scanned events = " << EventNumber << endl;
465  cout << "Number of good events = " << goodEventNumber << endl;
467 }
468 
470  double& DCA, double& DCAxy)
471 {
472  KFParticle::SetField(-1.4e0);
473 
474  float trackParameters[6] = {track->get_x(),
475  track->get_y(),
476  track->get_z(),
477  track->get_px(),
478  track->get_py(),
479  track->get_pz()};
480 
481  float trackCovariance[21];
482  unsigned int iterate = 0;
483  for (unsigned int i = 0; i < 6; ++i)
484  {
485  for (unsigned int j = 0; j <= i; ++j)
486  {
487  trackCovariance[iterate] = track->get_error(i, j);
488  ++iterate;
489  }
490  }
491 
493  particle.Create(trackParameters, trackCovariance, (Int_t) track->get_charge(), -1);
494  particle.NDF() = track->get_ndf();
495  particle.Chi2() = track->get_chisq();
496  particle.SetId(track->get_id());
497 
498  auto vtxid = track->get_vertex_id();
499  auto svtxVertex = vertexmap->get(vtxid);
500  if(!svtxVertex)
501  {
502  return;
503  }
504 
505 
506  float vertexParameters[6] = {svtxVertex->get_x(),
507  svtxVertex->get_y(),
508  svtxVertex->get_z(), 0, 0, 0};
509 
510  float vertexCovariance[21];
511  iterate = 0;
512  for (unsigned int i = 0; i < 3; ++i)
513  {
514  for (unsigned int j = 0; j <= i; ++j)
515  {
516  vertexCovariance[iterate] = svtxVertex->get_error(i, j);
517  ++iterate;
518  }
519  }
520 
522  vertex.Create(vertexParameters, vertexCovariance, 0, -1);
523  vertex.NDF() = svtxVertex->get_ndof();
524  vertex.Chi2() = svtxVertex->get_chisq();
525 
526  DCA = particle.GetDistanceFromVertex(vertex);
527  DCAxy = particle.GetDistanceFromVertexXY(vertex);
528 }
529 
531  double& dca3dxy, double& dca3dz,
532  double& dca3dxysigma, double& dca3dzsigma)
533 {
534  Acts::Vector3 pos(track->get_x(),
535  track->get_y(),
536  track->get_z());
537  Acts::Vector3 mom(track->get_px(),
538  track->get_py(),
539  track->get_pz());
540 
541  auto vtxid = track->get_vertex_id();
542  auto svtxVertex = vertexmap->get(vtxid);
543  if(!svtxVertex)
544  { return; }
545  Acts::Vector3 vertex(svtxVertex->get_x(),
546  svtxVertex->get_y(),
547  svtxVertex->get_z());
548 
549  pos -= vertex;
550 
551  Acts::ActsSymMatrix<3> posCov;
552  for(int i = 0; i < 3; ++i)
553  {
554  for(int j = 0; j < 3; ++j)
555  {
556  posCov(i, j) = track->get_error(i, j);
557  }
558  }
559 
560  Acts::Vector3 r = mom.cross(Acts::Vector3(0.,0.,1.));
561  float phi = atan2(r(1), r(0));
562 
564  Acts::RotationMatrix3 rot_T;
565  rot(0,0) = cos(phi);
566  rot(0,1) = -sin(phi);
567  rot(0,2) = 0;
568  rot(1,0) = sin(phi);
569  rot(1,1) = cos(phi);
570  rot(1,2) = 0;
571  rot(2,0) = 0;
572  rot(2,1) = 0;
573  rot(2,2) = 1;
574 
575  rot_T = rot.transpose();
576 
577  Acts::Vector3 pos_R = rot * pos;
578  Acts::ActsSymMatrix<3> rotCov = rot * posCov * rot_T;
579 
580  dca3dxy = pos_R(0);
581  dca3dz = pos_R(2);
582  dca3dxysigma = sqrt(rotCov(0,0));
583  dca3dzsigma = sqrt(rotCov(2,2));
584 
585 }