12 #include "boost/filesystem.hpp" 35 namespace fs = boost::filesystem;
137 std::vector<art::Ptr<cvn::PixelMap>> pixelmaps;
139 auto h_pixelmaps = evt.
getHandle<std::vector<cvn::PixelMap>>(itag1);
144 if (pixelmaps.size() == 0)
return;
149 std::vector<art::Ptr<simb::MCTruth>> mctruth_list;
163 float nu_energy = true_neutrino.
Nu().
E();
164 float lep_energy = true_neutrino.
Lepton().
E();
168 float reco_nue_energy = 0;
169 float reco_numu_energy = 0;
170 float reco_nutau_energy = 0;
192 int event_weight = 1;
195 reco_nue_energy, reco_numu_energy, reco_nutau_energy,
196 event_weight, *pixelmaps[0]);
207 n_pi0, n_neutron, toptype, toptypealt);
226 ulong dest_len = compressBound(src_len);
227 char* ostream = (
char *) malloc(dest_len);
229 int res = compress((Bytef *) ostream, &dest_len, (Bytef *) &pixel_array[0], src_len);
233 if (res == Z_BUF_ERROR)
234 std::cout <<
"Buffer too small!" <<
std::endl;
237 else if (res == Z_MEM_ERROR)
238 std::cout <<
"Not enough memory for compression!" <<
std::endl;
247 std::ofstream image_file (image_file_name, std::ofstream::binary);
248 std::ofstream info_file (info_file_name);
250 if(image_file.is_open() && info_file.is_open()) {
254 image_file.write(ostream, dest_len);
289 if (image_file.is_open())
293 <<
"Unable to open file " << image_file_name <<
"!" <<
std::endl;
295 if (info_file.is_open())
299 <<
"Unable to open file " << info_file_name <<
"!" <<
std::endl;
double E(const int i=0) const
float fRecoNumuEnergy
Reconstructed energy under numu hypothesis.
EventNumber_t event() const
const simb::MCNeutrino & GetNeutrino() const
InteractionType fInt
Class of the event.
void write_files(TrainingData td, unsigned int n, std::string evtid)
unsigned short GetNPizeros()
Handle< PROD > getHandle(SelectorBase const &) const
const simb::MCParticle & Nu() const
void SetViewReversal(bool reverseX, bool reverseY, bool reverseZ)
Function to set any views that need reversing.
unsigned int GetTotHits()
unsigned short GetNNeutrons()
void SetLogScale(bool setLog)
Set the log scale for charge.
static constexpr double fs
std::string fEnergyNueLabel
enum cvn::Interaction InteractionType
std::vector< bool > fReverseViews
unsigned short GetTopologyType()
CVNZlibMaker(fhicl::ParameterSet const &pset)
void ConvertPixelMapToPixelArray(const PixelMap &pm, std::vector< unsigned char > &pix)
Convert a Pixel Map object into a single pixel array with an image size nWire x nTDC.
EDAnalyzer(fhicl::ParameterSet const &pset)
Utility class for truth labels.
InteractionType GetInteractionType(simb::MCNeutrino &truth)
float fRecoNueEnergy
Reconstructed energy under nue hypothesis.
unsigned short GetNProtons()
unsigned short GetTopologyTypeAlt()
PixelMap fPMap
PixelMap for the event.
std::string fEnergyNutauLabel
def train(model, train_files, valid_files, maskpatterns, epochs, batchsize, info)
bool exists(std::string path)
std::string fEnergyNumuLabel
void GetTopology(const art::Ptr< simb::MCTruth > truth, unsigned int nTopologyHits)
float fLepEnergy
True energy of outgoing lepton.
const simb::MCParticle & Lepton() const
float fNuEnergy
True energy of neutrino event.
#define DEFINE_ART_MODULE(klass)
Utilities for producing images for the CVN.
T get(std::string const &key) const
SubRunNumber_t subRun() const
Class containing some utility functions for all things CVN.
Something else. Tau? Hopefully we don't use this.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::string fPixelMapInput
unsigned int NTdc() const
Width in tdcs.
The TrainingData objects contains a PixelMap and the output class type, and any other bit that goes i...
Position4_t fNuLorentzVector
float fRecoNutauEnergy
Reconstructed energy under nutau hypothesis.
void analyze(const art::Event &evt) override
unsigned int fTopologyHitsCut
void reconfigure(const fhicl::ParameterSet &pset)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
std::string fGenieGenModuleLabel
unsigned short GetNPions()
unsigned int NWire() const
Length in wires.
Event generator information.
float fEventWeight
The event weight (norm * oscProb)
std::string to_string(ModuleType const mt)
void SetTopologyInformation(int pdg, int nproton, int npion, int npizero, int nneutron, int toptype, int toptypealt)
QTextStream & endl(QTextStream &s)
void SetPixelMapSize(unsigned int nWires, unsigned int nTDCs)
Set the input pixel map size.