27 #include <boost/uuid/uuid.hpp> 28 #include <boost/uuid/uuid_generators.hpp> 29 #include <boost/uuid/uuid_io.hpp> 100 std::vector<art::Ptr<GCNGraph>> graphVector;
103 <<
"Could not find GCNGraph vector with module label " 110 <<
"There shouldn't be more than one GCNGraph per producer per event," 111 <<
" but here there are " << graphVector.size() <<
"." <<
std::endl;
113 if (graphVector.empty())
return;
121 for (
size_t itNode = 0; itNode < graphVector[0]->GetNumberOfNodes(); ++itNode) {
136 if (!truthHandle.
isValid() || truthHandle->size() != 1) {
138 <<
"Expected to find exactly one MC truth object!";
158 if (!pfHandle.
isValid() || pfHandle->size() != 1) {
160 <<
"Expected exactly one graph particle flow object.";
174 boost::uuids::random_generator
generator;
176 std::ostringstream fileName;
178 fFile = TFile::Open(fileName.str().c_str(),
"recreate");
184 fTree->Branch(
"Event", &
fEvent);
187 fTree->Branch(
"IsCC", &
fIsCC);
190 fTree->Branch(
"NuDirX", &
fNuDirX);
191 fTree->Branch(
"NuDirY", &
fNuDirY);
192 fTree->Branch(
"NuDirZ", &
fNuDirZ);
double E(const int i=0) const
TTree * fTree
ROOT tree for writing to file.
TFile * fFile
Output ROOT file.
std::vector< std::vector< float > > fFeatures
Node features.
GCNGraphROOT(fhicl::ParameterSet const &p)
bool fSaveParticleFlow
Whether to include particle flow information.
const simb::MCParticle & Nu() const
bool fSaveEventTruth
Whether to save event-level truth information.
float fNuDirZ
Z component of true neutrino direction.
std::vector< std::vector< float > > fPosition
Node positions.
const std::vector< float > GetGroundTruth() const
Get the node truth.
EDAnalyzer(fhicl::ParameterSet const &pset)
Utility class for truth labels.
MC truth particle flow for graph connection ground truth.
float fNuEnergy
True neutrino energy.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
void analyze(art::Event const &e) override
const simb::MCParticle & Lepton() const
#define DEFINE_ART_MODULE(klass)
void endSubRun(art::SubRun const &sr) override
End of a subrun, write all events to a ROOT file.
std::string fTruthLabel
Name of truth producer module.
T get(std::string const &key) const
std::map< unsigned int, unsigned int > fParticleFlow
Particle flow map.
const std::vector< float > GetFeatures() const
Get the node features.
std::string fGraphModuleLabel
Name of graph producer module.
float fNuDirY
Y component of true neutrino direction.
GCNGraphROOT & operator=(GCNGraphROOT const &)=delete
float fLepEnergy
True lepton energy.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
float fNuDirX
X component of true neutrino direction.
const TLorentzVector & Momentum(const int i=0) const
EventNumber_t event() const
std::string fOutputName
ROOT output filename.
const std::vector< float > GetPosition() const
Get the node position, features or ground truth.
void beginSubRun(art::SubRun const &sr) override
Beginning of a subrun, make a new file.
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
std::vector< std::vector< float > > fGroundTruth
Node ground truth.
void reconfigure(fhicl::ParameterSet const &p)
Event generator information.
std::string fGraphInstanceLabel
Name of graph instance.
std::vector< unsigned int > fEvent
Event numbers.
bool fIsCC
Whether the neutrino interaction is charged current.
SubRunNumber_t subRun() const
std::string fTreeName
ROOT tree name.
QTextStream & endl(QTextStream &s)