15 #include <trackbase_historic/SvtxVertex.h>
16 #include <trackbase_historic/SvtxVertexMap_v1.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>
66 cout <<
"FilterEvents::Init started..." << endl;
106 cout <<
"FilterEvents::Init ended." << endl;
136 _trackmap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
140 _vtxmap = findNode::getClass<SvtxVertexMap_v1>(topNode,
"SvtxVertexMap");
152 _trkrclusters = findNode::getClass<TrkrClusterContainerv4>(topNode,
"TRKR_CLUSTER");
156 _cemc_clusters = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_CEMC");
174 double pathlength = proj[proj.size()-3];
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);
194 double track_eta = 99999.;
195 double track_phi = 99999.;
205 double pathlength = proj[proj.size()-3];
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; }
217 if(track_eta == 99999. || track_phi == 99999.) {
return returnCluster; }
218 double dist = 99999.;
222 for (iter = begin_end.first; iter != begin_end.second; ++iter)
225 if(!cluster)
continue;
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));
237 dist = tmpdist; returnCluster = cluster; dphi = fabs(cemc_phi-track_phi); deta = fabs(cemc_eta-track_eta);
242 return returnCluster;
251 bool goodevent =
false;
253 cout <<
"getting nodes..." << endl;
256 GlobalVertexMap* _global_vtxmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
265 cout <<
"Global BBC vertex Z = " << Zvtx << endl;
267 std::vector<RawCluster *> goodclusters;
270 std::map<TrkrDefs::cluskey,TrkrCluster*> m_clusters;
272 std::vector<SvtxTrackSeed_v1*> v_svtx_trackseed;
273 std::vector<TrackSeed*> v_silicon_trackseed;
274 std::vector<TrackSeed*> v_tpc_trackseed;
276 cout <<
"Total number of tracks = " <<
_trackmap->
size() << endl;
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);
296 double dcaz, dcaxy_sig, dcaz_sig;
302 if(abs(dca) <
dca_cut)
continue;
304 double mom = sqrt(px * px + py * py + pz * pz);
314 double cemc_ecore = 0.;
316 if(cemc_ecore/mom < 0.7)
continue;
322 if(!tmp) cout <<
"ERROR: Failed to insert a track." << endl;
324 cout <<
" Track: " << pt << endl;
327 double trackseed_silicon_pt = trackseed_silicon->
get_pt();
328 cout <<
" Silicon seed: " << trackseed_silicon <<
" " << trackseed_silicon_pt <<
" " << trackseed_silicon->
size_cluster_keys() << endl;
330 v_silicon_trackseed.push_back(tmpseedsilicon);
333 double trackseed_tpc_pt = trackseed_tpc->
get_pt();
334 cout <<
" TPC seed: " << trackseed_tpc <<
" " << trackseed_tpc_pt <<
" " << trackseed_tpc->
size_cluster_keys() << endl;
336 v_tpc_trackseed.push_back(tmpseedtpc);
343 bool foundsiliconseed =
false;
344 bool foundtpcseed =
false;
349 double tmptpcseed_pt = tmptpcseed->
get_pt();
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;
357 v_svtx_trackseed.push_back(tmpseed);
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;}}
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;}}
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 );
393 for (clusiter = begin_end.first; clusiter != begin_end.second; ++clusiter)
396 if(!cluster) { cout <<
"ERROR: bad cluster pointer = " << cluster << endl;
continue; }
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));
408 bool isinserted =
false;
409 for(
unsigned int i=0;
i<goodclusters.size();
i++) {
if(cluster==goodclusters[
i]) {isinserted=
true;
break;}}
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;
429 cout <<
" Number of TRKR clusters and keys for output: " << m_clusters.size() <<
" " << m_clusters.size() << endl;
432 for(std::map<TrkrDefs::cluskey,TrkrCluster*>::iterator
it = m_clusters.begin();
it != m_clusters.end();
it++)
441 for(
unsigned int cl = 0; cl < v_svtx_trackseed.size(); cl++)
464 cout <<
"Number of scanned events = " <<
EventNumber << endl;
470 double&
DCA,
double& DCAxy)
472 KFParticle::SetField(-1.4e0);
474 float trackParameters[6] = {track->
get_x(),
481 float trackCovariance[21];
482 unsigned int iterate = 0;
483 for (
unsigned int i = 0;
i < 6; ++
i)
485 for (
unsigned int j = 0;
j <=
i; ++
j)
493 particle.
Create(trackParameters, trackCovariance, (Int_t) track->
get_charge(), -1);
499 auto svtxVertex = vertexmap->
get(vtxid);
506 float vertexParameters[6] = {svtxVertex->
get_x(),
508 svtxVertex->get_z(), 0, 0, 0};
510 float vertexCovariance[21];
512 for (
unsigned int i = 0;
i < 3; ++
i)
514 for (
unsigned int j = 0;
j <=
i; ++
j)
516 vertexCovariance[iterate] = svtxVertex->get_error(
i,
j);
522 vertex.
Create(vertexParameters, vertexCovariance, 0, -1);
523 vertex.
NDF() = svtxVertex->get_ndof();
524 vertex.
Chi2() = svtxVertex->get_chisq();
531 double& dca3dxy,
double& dca3dz,
532 double& dca3dxysigma,
double& dca3dzsigma)
542 auto svtxVertex = vertexmap->
get(vtxid);
547 svtxVertex->get_z());
551 Acts::ActsSymMatrix<3> posCov;
552 for(
int i = 0;
i < 3; ++
i)
554 for(
int j = 0;
j < 3; ++
j)
561 float phi = atan2(
r(1),
r(0));
566 rot(0,1) = -sin(phi);
575 rot_T = rot.transpose();
578 Acts::ActsSymMatrix<3> rotCov = rot * posCov * rot_T;
582 dca3dxysigma = sqrt(rotCov(0,0));
583 dca3dzsigma = sqrt(rotCov(2,2));