16 #include "art_root_io/TFileDirectory.h" 17 #include "art_root_io/TFileService.h" 18 #include "boost/filesystem.hpp" 105 std::string fPOTModuleLabel =
"generator";
110 if (sr.
getByLabel(fPOTModuleLabel, potListHandle))
123 hPOT = tfs->make<TH1D>(
"TotalPOT",
"Total POT;; POT", 1, 0, 1);
131 std::vector<art::Ptr<lcvn::PixelMap>> pixelmaps;
133 auto h_pixelmaps = evt.
getHandle<std::vector<lcvn::PixelMap>>(itag1);
137 if (pixelmaps.size() == 0)
return;
142 std::vector<art::Ptr<simb::MCTruth>> mctruth_list;
151 double event_weight = 1.;
159 float nu_energy = true_neutrino.
Nu().
E();
160 float lep_energy = true_neutrino.
Lepton().
E();
176 info.
SetTruthInfo(nu_energy, lep_energy, 0., event_weight);
202 ulong dest_len = compressBound(src_len);
203 char* ostream = (
char*)malloc(dest_len);
205 int res = compress((Bytef*)ostream, &dest_len, (Bytef*)&pixel_array[0], src_len);
209 if (res == Z_BUF_ERROR) std::cout <<
"Buffer too small!" << std::endl;
212 else if (res == Z_MEM_ERROR)
213 std::cout <<
"Not enough memory for compression!" << std::endl;
219 std::string image_file_name =
out_dir +
"/event_" + evtid +
".gz";
220 std::string info_file_name =
out_dir +
"/event_" + evtid +
".info";
222 std::ofstream image_file(image_file_name, std::ofstream::binary);
223 std::ofstream info_file(info_file_name);
225 if (image_file.is_open() && info_file.is_open()) {
229 image_file.write(ostream, dest_len);
237 info_file << td.
fInt << std::endl;
238 info_file << td.
fInfo << std::endl;
245 if (image_file.is_open())
249 <<
"Unable to open file " << image_file_name <<
"!" << std::endl;
251 if (info_file.is_open())
255 <<
"Unable to open file " << info_file_name <<
"!" << std::endl;
double E(const int i=0) const
std::string fGenieGenModuleLabel
unsigned int fTopologyHitsCut
SubRunNumber_t subRun() const
unsigned int GetTotHits()
const simb::MCNeutrino & GetNeutrino() const
InteractionType GetInteractionType(simb::MCNeutrino &truth) const
const TLorentzVector & EndPosition() const
const simb::MCParticle & Nu() const
std::vector< double > fFidMinCoords
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.
Utility class for truth labels.
std::vector< double > fFidMaxCoords
unsigned short GetTopologyTypeAlt() const
void SetTopologyInformation(int pdg, int nproton, int npion, int npizero, int nneutron, int toptype, int toptypealt)
void SetPixelMapSize(unsigned int nWires, unsigned int nTDCs)
Set the input pixel map size.
object containing MC flux information
void reconfigure(const fhicl::ParameterSet &pset)
unsigned short GetTopologyType() const
LArNuCVNZlibMaker(fhicl::ParameterSet const &pset)
const simb::MCParticle & Lepton() const
std::string fPixelMapInput
#define DEFINE_ART_MODULE(klass)
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
Utilities for producing images for the CVN.
unsigned int NWire() const
Length in wires.
T get(std::string const &key) const
Something else. Tau? Hopefully we don't use this.
EventNumber_t event() const
void write_files(LArTrainingNuData td, std::string evtid)
void analyze(const art::Event &evt)
unsigned short GetNPions() const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
void GetTopology(const art::Ptr< simb::MCTruth > truth, unsigned int nTopologyHits)
Handle< PROD > getHandle(SelectorBase const &) const
SubRunNumber_t subRun() const
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
The TrainingData objects contains a PixelMap and the output class type, and any other bit that goes i...
unsigned short GetNProtons() const
void SetTruthInfo(float nuEnergy, float lepEnergy, float lepAngle, float weight)
unsigned short GetNNeutrons() const
void reconfigure(const fhicl::ParameterSet &pset)
unsigned int NTdc() const
Width in tdcs.
PixelMap fPMap
PixelMap for the event.
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Event generator information.
InteractionType fInt
Class of the event.
unsigned short GetNPizeros() const
void endSubRun(art::SubRun const &sr)