12 #include "boost/filesystem.hpp" 33 namespace fs = boost::filesystem;
110 std::vector<art::Ptr<cvn::GCNGraph>> graphs;
116 std::cout <<
"Found " << graphs.size() <<
" graphs" <<
std::endl;
117 if (graphs.size() == 0)
return;
122 std::vector<art::Ptr<simb::MCTruth>> mctruth_list;
136 float nu_energy = true_neutrino.
Nu().
E();
137 float lep_energy = true_neutrino.
Lepton().
E();
144 bool isFid = (fabs(vtx.X())<310. && fabs(vtx.Y())<550. && vtx.Z()>50. && vtx.Z()<1244.);
147 float reco_nue_energy = 0.;
148 float reco_numu_energy = 0.;
149 float reco_nutau_energy = 0.;
169 float event_weight = -1.0;
172 for(
unsigned int i = 0; i < graphs.size(); ++i){
183 ulong src_len = vectorToWrite.size() *
sizeof(
float);
184 ulong dest_len = compressBound(src_len);
185 char* ostream = (
char *) malloc(dest_len);
187 int res = compress((Bytef *) ostream, &dest_len, (Bytef *) &vectorToWrite[0], src_len);
190 if (res == Z_BUF_ERROR)
191 std::cout <<
"Buffer too small!" <<
std::endl;
193 else if (res == Z_MEM_ERROR)
194 std::cout <<
"Not enough memory for compression!" <<
std::endl;
198 std::stringstream modifier;
199 if(graphs.size() > 1){
200 modifier <<
"_" << i;
204 std::stringstream image_file_name;
205 image_file_name <<
out_dir <<
"/event_" << evt.
event() << modifier.str() <<
".gz";
206 std::stringstream info_file_name;
207 info_file_name <<
out_dir <<
"/event_" << evt.
event() << modifier.str() <<
".info";
209 std::ofstream image_file (image_file_name.str(), std::ofstream::binary);
210 std::ofstream info_file (info_file_name.str());
212 if(image_file.is_open() && info_file.is_open()) {
215 image_file.write(ostream, dest_len);
224 info_file << reco_nue_energy <<
std::endl;
225 info_file << reco_numu_energy <<
std::endl;
226 info_file << reco_nutau_energy <<
std::endl;
246 if (image_file.is_open())
250 <<
"Unable to open file " << image_file_name.str() <<
"!" <<
std::endl;
252 if (info_file.is_open())
256 <<
"Unable to open file " << info_file_name.str() <<
"!" <<
std::endl;
double E(const int i=0) const
const unsigned int GetNumberOfNodeCoordinates() const
Return the number of coordinates for each node.
EventNumber_t event() const
const simb::MCNeutrino & GetNeutrino() const
static constexpr double g
const TLorentzVector & EndPosition() const
unsigned short GetNPizeros()
Handle< PROD > getHandle(SelectorBase const &) const
const simb::MCParticle & Nu() const
unsigned short GetNNeutrons()
static constexpr double fs
enum cvn::Interaction InteractionType
unsigned short GetTopologyType()
EDAnalyzer(fhicl::ParameterSet const &pset)
Utility class for truth labels.
InteractionType GetInteractionType(simb::MCNeutrino &truth)
unsigned short GetNProtons()
unsigned short GetTopologyTypeAlt()
bool exists(std::string path)
std::string fGenieGenModuleLabel
void GetTopology(const art::Ptr< simb::MCTruth > truth, unsigned int nTopologyHits)
const simb::MCParticle & Lepton() const
#define DEFINE_ART_MODULE(klass)
T get(std::string const &key) const
void reconfigure(const fhicl::ParameterSet &pset)
void analyze(const art::Event &evt) override
Something else. Tau? Hopefully we don't use this.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::string fEnergyNutauLabel
std::string fEnergyNumuLabel
const unsigned int GetNumberOfNodeFeatures() const
Return the number of features for each node.
Position4_t fNuLorentzVector
const std::vector< float > ConvertGraphToVector() const
Function to linearise the graph to a vector for zlib file creation.
const unsigned int GetNumberOfNodes() const
Get the number of nodes.
std::string fEnergyNueLabel
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
unsigned short GetNPions()
Event generator information.
unsigned int fTopologyHitsCut
GCNZlibMaker(fhicl::ParameterSet const &pset)
QTextStream & endl(QTextStream &s)