All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
quad::EvalVtx Class Reference
Inheritance diagram for quad::EvalVtx:

Public Member Functions

 EvalVtx (const fhicl::ParameterSet &pset)
 
void analyze (const art::Event &evt) override
 

Private Attributes

std::string fTruthLabel
 
std::vector< std::string > fVertexLabels
 
TTree * fTree
 
int gEvt
 
double gTrueX
 
double gTrueY
 
double gTrueZ
 
std::vector< double > gRecoX
 
std::vector< double > gRecoY
 
std::vector< double > gRecoZ
 

Detailed Description

Definition at line 21 of file EvalVtx_module.cc.

Constructor & Destructor Documentation

quad::EvalVtx::EvalVtx ( const fhicl::ParameterSet &  pset)
explicit

Definition at line 43 of file EvalVtx_module.cc.

43  :
44  EDAnalyzer(pset),
45  fTruthLabel(pset.get<std::string>("TruthLabel")),
46  fVertexLabels(pset.get<std::vector<std::string>>("VertexLabels"))
47 {
48  art::ServiceHandle<art::TFileService> tfs;
49 
50  fTree = tfs->make<TTree>("vtxs", "vtxs");
51 
52  fTree->Branch("evt", &gEvt);
53  fTree->Branch("true_x", &gTrueX);
54  fTree->Branch("true_y", &gTrueY);
55  fTree->Branch("true_z", &gTrueZ);
56 
57  gRecoX.resize(fVertexLabels.size());
58  gRecoY.resize(fVertexLabels.size());
59  gRecoZ.resize(fVertexLabels.size());
60 
61  for(unsigned int i = 0; i < fVertexLabels.size(); ++i){
62  const std::string& l = fVertexLabels[i];
63  fTree->Branch((l+"_x").c_str(), &gRecoX[i]);
64  fTree->Branch((l+"_y").c_str(), &gRecoY[i]);
65  fTree->Branch((l+"_z").c_str(), &gRecoZ[i]);
66  }
67 }
std::vector< std::string > fVertexLabels
std::vector< double > gRecoZ
std::vector< double > gRecoX
std::vector< double > gRecoY
std::string fTruthLabel
art::ServiceHandle< art::TFileService > tfs

Member Function Documentation

void quad::EvalVtx::analyze ( const art::Event &  evt)
override

Definition at line 111 of file EvalVtx_module.cc.

112 {
113  const auto& truths = *evt.getValidHandle<std::vector<simb::MCTruth>>(fTruthLabel);
114  if(truths.empty()) return;
115 
116  const simb::MCParticle& nu = truths[0].GetNeutrino().Nu();
117 
118  gEvt = evt.event();
119 
120  gTrueX = nu.Vx();
121  gTrueY = nu.Vy();
122  gTrueZ = nu.Vz();
123 
124  for(unsigned int i = 0; i < fVertexLabels.size(); ++i){
125  // NB - vertices returned by these functions can be invalid (default
126  // constructed) in case no vertex exists. We stil have to write them, since
127  // another algorithm may have made a valid vertex for this
128  // event. Downstream plotting code should be aware and treat (0,0,0)
129  // vertices specially.
130  const recob::Vertex vtx = (fVertexLabels[i] == "pandora") ? GetVtxByAssns(fVertexLabels[i], evt) : GetFirstVertex(fVertexLabels[i], evt);
131  const recob::Vertex::Point_t reco_vtx = vtx.position();
132 
133  gRecoX[i] = reco_vtx.x();
134  gRecoY[i] = reco_vtx.y();
135  gRecoZ[i] = reco_vtx.z();
136  } // end for i
137 
138  fTree->Fill();
139 }
unsigned int event
Definition: DataStructs.h:634
recob::Vertex GetVtxByAssns(const std::string &label, const art::Event &evt)
std::vector< std::string > fVertexLabels
std::vector< double > gRecoZ
Definition of vertex object for LArSoft.
Definition: Vertex.h:35
tracking::Point_t Point_t
Definition: Vertex.h:39
std::vector< double > gRecoX
recob::Vertex GetFirstVertex(const std::string &label, const art::Event &evt)
std::vector< double > gRecoY
std::string fTruthLabel
TCEvent evt
Definition: DataStructs.cxx:8
BEGIN_PROLOG SN nu
const Point_t & position() const
Return vertex 3D position.
Definition: Vertex.h:60

Member Data Documentation

TTree* quad::EvalVtx::fTree
private

Definition at line 32 of file EvalVtx_module.cc.

std::string quad::EvalVtx::fTruthLabel
private

Definition at line 29 of file EvalVtx_module.cc.

std::vector<std::string> quad::EvalVtx::fVertexLabels
private

Definition at line 30 of file EvalVtx_module.cc.

int quad::EvalVtx::gEvt
private

Definition at line 35 of file EvalVtx_module.cc.

std::vector<double> quad::EvalVtx::gRecoX
private

Definition at line 37 of file EvalVtx_module.cc.

std::vector<double> quad::EvalVtx::gRecoY
private

Definition at line 37 of file EvalVtx_module.cc.

std::vector<double> quad::EvalVtx::gRecoZ
private

Definition at line 37 of file EvalVtx_module.cc.

double quad::EvalVtx::gTrueX
private

Definition at line 36 of file EvalVtx_module.cc.

double quad::EvalVtx::gTrueY
private

Definition at line 36 of file EvalVtx_module.cc.

double quad::EvalVtx::gTrueZ
private

Definition at line 36 of file EvalVtx_module.cc.


The documentation for this class was generated from the following file: