forked from sPHENIX-Collaboration/coresoftware
/
PHG4VertexSelection.cc
63 lines (48 loc) · 1.8 KB
/
PHG4VertexSelection.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// This is the new trackbase container version
/*!
* \file PHG4VertexSelection.cc
* \author Hugo Pereira Da Costa <hugo.pereira-da-costa@cea.fr>
*/
#include "PHG4VertexSelection.h"
#include "PHG4TruthInfoContainer.h"
#include "PHG4VtxPoint.h"
#include <fun4all/Fun4AllReturnCodes.h>
#include <phool/getClass.h>
#include <iostream> // for operator<<, basic_ostream, endl
//____________________________________________________________________________
PHG4VertexSelection::PHG4VertexSelection(const std::string &name)
: SubsysReco(name)
, PHParameterInterface(name)
{
InitializeParameters();
}
//____________________________________________________________________________
int PHG4VertexSelection::InitRun(PHCompositeNode */*topNode*/)
{
UpdateParametersWithMacro();
// load parameters
m_vertex_zcut = get_double_param("vertex_zcut");
// printout
std::cout
<< "PHG4VertexSelection::InitRun\n"
<< " m_vertex_zcut: " << m_vertex_zcut << " cm\n"
<< std::endl;
return Fun4AllReturnCodes::EVENT_OK;
}
//____________________________________________________________________________
int PHG4VertexSelection::process_event(PHCompositeNode *topNode)
{
// g4 truth info
auto g4truthinfo = findNode::getClass<PHG4TruthInfoContainer>(topNode, "G4TruthInfo");
// main vertex
const auto main_vertex_id = g4truthinfo->GetPrimaryVertexIndex();
const auto vertex = g4truthinfo->GetPrimaryVtx(main_vertex_id);
if (!vertex) return false;
// check vertex position along the beam
return (m_vertex_zcut > 0 && std::abs(vertex->get_z()) > m_vertex_zcut) ? Fun4AllReturnCodes::DISCARDEVENT : Fun4AllReturnCodes::EVENT_OK;
}
//___________________________________________________________________________
void PHG4VertexSelection::SetDefaultParameters()
{
set_default_double_param("vertex_zcut", 10);
}