3 #include "fhiclcpp/ParameterSet.h"
4 #include "art/Framework/Core/ModuleMacros.h"
5 #include "art/Framework/Core/EDAnalyzer.h"
6 #include "art/Framework/Principal/Event.h"
7 #include "art/Framework/Principal/Handle.h"
8 #include "art/Framework/Services/Registry/ServiceHandle.h"
9 #include "art_root_io/TFileService.h"
10 #include "canvas/Persistency/Common/FindManyP.h"
14 #include "nusimdata/SimulationBase/MCTruth.h"
24 explicit EvalVtx(
const fhicl::ParameterSet& pset);
45 fTruthLabel(pset.
get<
std::
string>("TruthLabel")),
48 art::ServiceHandle<art::TFileService>
tfs;
50 fTree = tfs->make<TTree>(
"vtxs",
"vtxs");
52 fTree->Branch(
"evt", &gEvt);
53 fTree->Branch(
"true_x", &gTrueX);
54 fTree->Branch(
"true_y", &gTrueY);
55 fTree->Branch(
"true_z", &gTrueZ);
57 gRecoX.resize(fVertexLabels.size());
58 gRecoY.resize(fVertexLabels.size());
59 gRecoZ.resize(fVertexLabels.size());
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]);
72 const auto& vtxs = *evt.getValidHandle<std::vector<recob::Vertex>>(label);
82 art::Handle<std::vector<recob::Vertex>> vtxs;
83 evt.getByLabel(label, vtxs);
87 art::Handle<std::vector<recob::PFParticle>> parts;
88 evt.getByLabel(label, parts);
90 art::FindManyP<recob::Vertex> fm(parts, evt, label);
92 for(
unsigned int i = 0; i < parts->size(); ++i){
93 const int pdg =
abs((*parts)[i].PdgCode());
94 if(pdg == 12 || pdg == 14 || pdg == 16){
95 const std::vector<art::Ptr<recob::Vertex>>& vtxs = fm.at(i);
96 if(vtxs.size() == 1)
return *vtxs[0];
99 std::cout <<
"Warning: vertex list empty!" << std::endl;
102 std::cout <<
"Warning: " << vtxs.size() <<
" vertices for daughter?" << std::endl;
113 const auto& truths = *evt.getValidHandle<std::vector<simb::MCTruth>>(
fTruthLabel);
114 if(truths.empty())
return;
116 const simb::MCParticle&
nu = truths[0].GetNeutrino().Nu();
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
EvalVtx(const fhicl::ParameterSet &pset)
void analyze(const art::Event &evt) override
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.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
tracking::Point_t Point_t
std::vector< double > gRecoX
recob::Vertex GetFirstVertex(const std::string &label, const art::Event &evt)
std::vector< double > gRecoY
art::ServiceHandle< art::TFileService > tfs
process_name out1 physics analyzers evalvtx VertexLabels
const Point_t & position() const
Return vertex 3D position.
BEGIN_PROLOG could also be cout