11 #include "boost/filesystem.hpp" 32 namespace fs = boost::filesystem;
135 std::vector<art::Ptr<cvn::PixelMap>> pixelmaps;
137 auto h_pixelmaps = evt.
getHandle<std::vector<cvn::PixelMap>>(itag1);
142 if (pixelmaps.size() == 0)
return;
149 unsigned short beamParticleInteraction;
153 float beamParticleEnergy = 0;
154 TVector3 beamParticleVtx;
155 int beamParticlePDG = 0;
157 bool gotPrimary =
false;
160 if(particle->
Process().compare(
"primary")==0){
161 beamParticleEnergy = particle->
E();
162 beamParticleVtx.SetXYZ(particle->
EndX(),particle->
EndY(),particle->
EndZ());
163 beamParticlePDG = particle->
PdgCode();
170 if(!gotPrimary)
return;
172 const PrimaryTrainingInfo beamPrimary(beamParticleVtx,beamParticleInteraction,beamParticlePDG,beamParticleEnergy);
181 std::vector<unsigned char> pixel_array(3 * pm->
NWire() * pm->
NTdc());
189 ulong dest_len = compressBound(src_len);
190 char* ostream = (
char *) malloc(dest_len);
192 int res = compress((Bytef *) ostream, &dest_len, (Bytef *) &pixel_array[0], src_len);
196 if (res == Z_BUF_ERROR)
197 std::cout <<
"Buffer too small!" <<
std::endl;
200 else if (res == Z_MEM_ERROR)
201 std::cout <<
"Not enough memory for compression!" <<
std::endl;
210 std::ofstream image_file (image_file_name, std::ofstream::binary);
211 std::ofstream info_file (info_file_name);
213 if(image_file.is_open() && info_file.is_open()) {
217 image_file.write(ostream, dest_len);
233 if (image_file.is_open())
237 <<
"Unable to open file " << image_file_name <<
"!" <<
std::endl;
239 if (info_file.is_open())
243 <<
"Unable to open file " << info_file_name <<
"!" <<
std::endl;
double E(const int i=0) const
EventNumber_t event() const
void DisableRegionSelection()
Disable the selection of the wire region and just use the first 500 wires.
Handle< PROD > getHandle(SelectorBase const &) const
void SetViewReversal(bool reverseX, bool reverseY, bool reverseZ)
Function to set any views that need reversing.
void SetLogScale(bool setLog)
Set the log scale for charge.
static constexpr double fs
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)
std::string Process() const
Utility class for truth labels.
std::string fPixelMapInput
void write_files(const PrimaryTrainingInfo &primary, const art::Ptr< cvn::PixelMap > pm, unsigned int n) const
bool exists(std::string path)
#define DEFINE_ART_MODULE(klass)
Utilities for producing images for the CVN.
unsigned short GetProtoDUNEBeamInteractionType(const simb::MCParticle &particle) const
void reconfigure(const fhicl::ParameterSet &pset)
T get(std::string const &key) const
std::vector< bool > fReverseViews
const sim::ParticleList & ParticleList() const
Class containing some utility functions for all things CVN.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::string fLArG4ModuleLabel
unsigned short interaction
unsigned int NTdc() const
Width in tdcs.
PrimaryTrainingInfo(TVector3 vtx, unsigned short inter, int pdg, float en)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
void analyze(const art::Event &evt) override
unsigned int NWire() const
Length in wires.
CVNZlibMakerProtoDUNE(fhicl::ParameterSet const &pset)
std::string to_string(ModuleType const mt)
QTextStream & endl(QTextStream &s)