22 #include "hep_hpc/hdf5/make_ntuple.hpp" 25 #include <boost/uuid/uuid.hpp> 26 #include <boost/uuid/uuid_generators.hpp> 27 #include <boost/uuid/uuid_io.hpp> 37 using hep_hpc::hdf5::Column;
38 using hep_hpc::hdf5::make_scalar_column;
68 hep_hpc::hdf5::Ntuple<Column<int, 1>,
82 hep_hpc::hdf5::Ntuple<Column<int, 1>,
92 hep_hpc::hdf5::Ntuple<Column<int, 1>,
129 std::vector<art::Ptr<GCNGraph>> graphVector;
131 auto graphHandle = e.
getHandle<std::vector<GCNGraph>>(itag1);
134 <<
"Could not find GCNGraph vector with module label " 141 <<
"There shouldn't be more than one GCNGraph per producer per event," 142 <<
" but here there are " << graphVector.size() <<
"." <<
endl;
144 if (graphVector.empty())
return;
150 for (
size_t itNode = 0; itNode < graphVector[0]->GetNumberOfNodes(); ++itNode) {
158 pos[1], pos[2], feat[0], feat[1], feat[4], feat[2], feat[3],
159 (
int)feat[5], truth[0]);
167 if (!truthHandle || truthHandle->size() != 1) {
169 <<
"Expected to find exactly one MC truth object!";
187 for (
auto p : ptree) {
189 std::get<0>(
p), std::get<1>(
p), std::get<2>(
p),
190 std::get<3>(
p), std::get<4>(
p), std::get<5>(
p),
191 std::get<6>(
p), std::get<7>(
p), std::get<8>(
p),
192 std::get<9>(
p), std::get<10>(
p), std::get<11>(
p));
201 boost::uuids::random_generator
generator;
211 make_ntuple({
fFile,
"graph_table", 1000},
212 make_scalar_column<int>(
"run"),
213 make_scalar_column<int>(
"subrun"),
214 make_scalar_column<int>(
"event"),
215 make_scalar_column<int>(
"plane"),
216 make_scalar_column<float>(
"wire"),
217 make_scalar_column<float>(
"time"),
218 make_scalar_column<float>(
"integral"),
219 make_scalar_column<float>(
"rms"),
220 make_scalar_column<int>(
"rawplane"),
221 make_scalar_column<float>(
"rawwire"),
222 make_scalar_column<float>(
"rawtime"),
223 make_scalar_column<int>(
"tpc"),
224 make_scalar_column<int>(
"true_id")));
228 make_ntuple({
fFile,
"event_table", 1000},
229 make_scalar_column<int>(
"run"),
230 make_scalar_column<int>(
"subrun"),
231 make_scalar_column<int>(
"event"),
232 make_scalar_column<int>(
"is_cc"),
233 make_scalar_column<float>(
"nu_energy"),
234 make_scalar_column<float>(
"lep_energy"),
235 make_scalar_column<float>(
"nu_dir_x"),
236 make_scalar_column<float>(
"nu_dir_y"),
237 make_scalar_column<float>(
"nu_dir_z")));
242 make_ntuple({
fFile,
"particle_table", 1000},
243 make_scalar_column<int>(
"run"),
244 make_scalar_column<int>(
"subrun"),
245 make_scalar_column<int>(
"event"),
246 make_scalar_column<int>(
"id"),
247 make_scalar_column<int>(
"type"),
248 make_scalar_column<int>(
"parent_id"),
249 make_scalar_column<float>(
"momentum"),
250 make_scalar_column<float>(
"start_x"),
251 make_scalar_column<float>(
"start_y"),
252 make_scalar_column<float>(
"start_z"),
253 make_scalar_column<float>(
"end_x"),
254 make_scalar_column<float>(
"end_y"),
255 make_scalar_column<float>(
"end_z"),
256 make_scalar_column<string>(
"start_process"),
257 make_scalar_column<string>(
"end_process")));
double E(const int i=0) const
void reconfigure(fhicl::ParameterSet const &p)
GCNH5(fhicl::ParameterSet const &p)
Handle< PROD > getHandle(SelectorBase const &) const
static std::vector< ptruth > GetParticleTree(const cvn::GCNGraph *g)
const simb::MCParticle & Nu() const
hep_hpc::hdf5::Ntuple< Column< int, 1 >, Column< int, 1 >, Column< int, 1 >, Column< int, 1 >, Column< int, 1 >, Column< int, 1 >, Column< float, 1 >, Column< float, 1 >, Column< float, 1 >, Column< float, 1 >, Column< float, 1 >, Column< float, 1 >, Column< float, 1 >, Column< string, 1 >, Column< string, 1 > > * fParticleNtuple
Particle ntuple.
bool fSaveEventTruth
Whether to save event-level truth information.
const std::vector< float > GetGroundTruth() const
Get the node truth.
hep_hpc::hdf5::File fFile
Output HDF5 file.
EDAnalyzer(fhicl::ParameterSet const &pset)
Utility class for truth labels.
void beginSubRun(art::SubRun const &sr) override
hep_hpc::hdf5::Ntuple< Column< int, 1 >, Column< int, 1 >, Column< int, 1 >, Column< int, 1 >, Column< float, 1 >, Column< float, 1 >, Column< float, 1 >, Column< float, 1 >, Column< float, 1 > > * fEventNtuple
Event ntuple.
void endSubRun(art::SubRun const &sr) override
hep_hpc::hdf5::Ntuple< Column< int, 1 >, Column< int, 1 >, Column< int, 1 >, Column< int, 1 >, Column< float, 1 >, Column< float, 1 >, Column< float, 1 >, Column< float, 1 >, Column< int, 1 >, Column< float, 1 >, Column< float, 1 >, Column< int, 1 >, Column< int, 1 > > * fGraphNtuple
graph ntuple
const simb::MCParticle & Lepton() const
#define DEFINE_ART_MODULE(klass)
GCNH5 & operator=(GCNH5 const &)=delete
T get(std::string const &key) const
bool fSaveParticleTruth
Whether to include particle truth information.
const std::vector< float > GetFeatures() const
Get the node features.
SubRunNumber_t subRun() const
string fTruthLabel
Name of truth producer module.
void analyze(art::Event const &e) override
Q_EXPORT QTSManip setw(int w)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
string fOutputName
Output filename.
const TLorentzVector & Momentum(const int i=0) const
string fGraphModuleLabel
Name of graph producer module.
EventNumber_t event() const
Utilities for calculating feature values for the GCN.
const std::vector< float > GetPosition() const
Get the node position, features or ground truth.
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
static constexpr double sr
Event generator information.
Q_EXPORT QTSManip setfill(int f)
SubRunNumber_t subRun() const
string fGraphInstanceLabel
Name of graph instance.
QTextStream & endl(QTextStream &s)
Event finding and building.