100 std::cout <<
"GCNZlibMakerProtoDUNE: looking for graphs with label " <<
fGraphLabel <<
std::endl;
103 std::vector<art::Ptr<cvn::GCNGraph>> graphs;
109 if (graphs.size() == 0)
return;
115 unsigned short beamParticleInteraction;
119 float beamParticleEnergy = 0;
120 TVector3 beamParticleVtx;
121 int beamParticlePDG = 0;
126 if(particle->
Process().compare(
"primary")==0){
127 beamParticleEnergy = particle->
E();
128 beamParticleVtx.SetXYZ(particle->
EndX(),particle->
EndY(),particle->
EndZ());
129 beamParticlePDG = particle->
PdgCode();
130 beamParticleInteraction = labels.GetProtoDUNEBeamInteractionType(*particle);
138 for(
auto const graph : graphs){
140 if(
graph->GetNumberOfNodes() == 0)
return;
148 const std::vector<float> vectorToWrite =
graph->ConvertGraphToVector();
150 ulong src_len = vectorToWrite.size() *
sizeof(
float);
151 ulong dest_len = compressBound(src_len);
152 char* ostream = (
char *) malloc(dest_len);
154 int res = compress((Bytef *) ostream, &dest_len, (Bytef *) &vectorToWrite[0], src_len);
157 if (res == Z_BUF_ERROR)
158 std::cout <<
"Buffer too small!" <<
std::endl;
160 else if (res == Z_MEM_ERROR)
161 std::cout <<
"Not enough memory for compression!" <<
std::endl;
166 std::stringstream image_file_name;
167 image_file_name <<
out_dir <<
"/gcn_event_" << evt.
event() <<
"_" << counter <<
".gz";
168 std::stringstream info_file_name;
169 info_file_name <<
out_dir <<
"/gcn_event_" << evt.
event() <<
"_" << counter <<
".info";
171 std::ofstream image_file (image_file_name.str(), std::ofstream::binary);
172 std::ofstream info_file (info_file_name.str());
174 if(image_file.is_open() && info_file.is_open()) {
177 image_file.write(ostream, dest_len);
181 info_file << beamParticleVtx.X() <<
std::endl;
182 info_file << beamParticleVtx.Y() <<
std::endl;
183 info_file << beamParticleVtx.Z() <<
std::endl;
184 info_file << beamParticleEnergy <<
std::endl;
185 info_file << beamParticleInteraction <<
std::endl;
186 info_file << beamParticlePDG <<
std::endl;
190 info_file <<
graph->GetNode(0).GetNumberOfFeatures() <<
std::endl;
196 if (image_file.is_open())
200 <<
"Unable to open file " << image_file_name.str() <<
"!" <<
std::endl;
202 if (info_file.is_open())
206 <<
"Unable to open file " << info_file_name.str() <<
"!" <<
std::endl;
double E(const int i=0) const
EventNumber_t event() const
Handle< PROD > getHandle(SelectorBase const &) const
def graph(desc, maker=maker)
std::string Process() const
const sim::ParticleList & ParticleList() const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
QTextStream & endl(QTextStream &s)