From c6da8acccc8fddbd83263fe37e2b9293b853de3d Mon Sep 17 00:00:00 2001 From: Mattias Ellert <mattias.ellert@physics.uu.se> Date: Fri, 28 May 2021 10:37:06 +0200 Subject: [PATCH 1/3] Fix warnings from doxygen --- doc/doxygen/LHEF.txt | 9 ++++++--- include/HepMC3/ReaderHEPEVT.h | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/doxygen/LHEF.txt b/doc/doxygen/LHEF.txt index 28e73ff9..04a31089 100644 --- a/doc/doxygen/LHEF.txt +++ b/doc/doxygen/LHEF.txt @@ -340,7 +340,8 @@ following tags are defined. </li> <li> other values are allowed but are not included in the standard. </li> - </ul> + </ul> + </li> </ul> </li> <li><b><tt><procinfo></tt></b>(optional, multiple, see LHEF::HEPRUP::procinfo)<br> @@ -473,7 +474,7 @@ following tags are defined. </li> </ul> -@subsection LHEF-init Standardised tags in the events block. +@subsection LHEF-events Standardised tags in the events block. After the <tt>init</tt> block any number of events can be given. In addition events can be given in separate files declared @@ -535,6 +536,7 @@ block. Here is a list of additional tags that may be provided. </ul> Also other attributes are allowed and will be stored in LHEF::Scales::attributes.<br> + </li> <li><b><tt><scale></tt></b> (optional inside a <tt><scales></tt> tag)<br> It is also possible to specify an individual scale for any particle in the event in a <tt><scale></tt> tag. This is @@ -553,7 +555,8 @@ block. Here is a list of additional tags that may be provided. be used to specify all leptons and electro-weak bosons, and "QCD" can be used to specify the guon and all quarks. </li> - The contents of the tag gives the scale in GeV. + </ul> + The contents of the tag gives the scale in GeV. </li> </ul> diff --git a/include/HepMC3/ReaderHEPEVT.h b/include/HepMC3/ReaderHEPEVT.h index bacb00af..08f9a604 100644 --- a/include/HepMC3/ReaderHEPEVT.h +++ b/include/HepMC3/ReaderHEPEVT.h @@ -50,7 +50,6 @@ public: /** @brief read particle from file * * @param[in] i Particle id - * @param[in] iflong Event style */ virtual bool read_hepevt_particle(int i); -- GitLab From 584d20e085f3e534d126a7dca91a667352fa6b18 Mon Sep 17 00:00:00 2001 From: Mattias Ellert <mattias.ellert@physics.uu.se> Date: Fri, 28 May 2021 10:38:10 +0200 Subject: [PATCH 2/3] Cut-and-paste error (wrong class name in warning text) --- rootIO/src/WriterRoot.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootIO/src/WriterRoot.cc b/rootIO/src/WriterRoot.cc index 464cb1b7..0fe74600 100644 --- a/rootIO/src/WriterRoot.cc +++ b/rootIO/src/WriterRoot.cc @@ -39,7 +39,7 @@ void WriterRoot::write_event(const GenEvent &evt) { write_run_info(); } else { if ( evt.run_info() && run_info() != evt.run_info() ) - HEPMC3_WARNING("WriterAscii::write_event: GenEvents contain " + HEPMC3_WARNING("WriterRoot::write_event: GenEvents contain " "different GenRunInfo objects from - only the " "first such object will be serialized.") } -- GitLab From e7a66ccff85d9902bcd0ef39d5d3c8146b57edff Mon Sep 17 00:00:00 2001 From: Mattias Ellert <mattias.ellert@physics.uu.se> Date: Fri, 28 May 2021 10:39:30 +0200 Subject: [PATCH 3/3] Use %z instead of %l for size_t related types (avoids warnings on 32 bit) Minor space add/remove for consistency --- src/WriterAscii.cc | 18 +++++++++--------- src/WriterAsciiHepMC2.cc | 32 ++++++++++++++++---------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/WriterAscii.cc b/src/WriterAscii.cc index 45c2d2df..128b1334 100644 --- a/src/WriterAscii.cc +++ b/src/WriterAscii.cc @@ -85,7 +85,7 @@ void WriterAscii::write_event(const GenEvent &evt) { } // Write event info - m_cursor += sprintf(m_cursor, "E %d %lu %lu", evt.event_number(), evt.vertices().size(), evt.particles().size()); + m_cursor += sprintf(m_cursor, "E %d %zu %zu", evt.event_number(), evt.vertices().size(), evt.particles().size()); //4+d+2*lu flush(); @@ -113,7 +113,7 @@ void WriterAscii::write_event(const GenEvent &evt) { // Write weight values if present if ( evt.weights().size() ) { m_cursor += sprintf(m_cursor, "W"); - for (auto w: evt.weights()) + for (auto w: evt.weights()) { m_cursor += sprintf(m_cursor, " %.*e", std::min(3*m_precision, 22), w); flush(); @@ -135,7 +135,7 @@ void WriterAscii::write_event(const GenEvent &evt) { m_cursor += sprintf(m_cursor, "A %i ", vt2.first); write_string(escape(vt1.first)); flush(); - m_cursor += sprintf(m_cursor," "); + m_cursor += sprintf(m_cursor, " "); write_string(escape(st)); m_cursor += sprintf(m_cursor, "\n"); flush(); @@ -145,7 +145,7 @@ void WriterAscii::write_event(const GenEvent &evt) { // Print particles - std::map<ConstGenVertexPtr, bool> alreadywritten; + std::map<ConstGenVertexPtr, bool> alreadywritten; for (ConstGenParticlePtr p: evt.particles()) { // Check to see if we need to write a vertex first ConstGenVertexPtr v = p->production_vertex(); @@ -160,7 +160,7 @@ void WriterAscii::write_event(const GenEvent &evt) { else if ( v->particles_in().size() == 1 ) parent_object = v->particles_in()[0]->id(); //Usage of map instead of simple countewr helps to deal with events with random ids of vertices. if (alreadywritten.find(v) == alreadywritten.end() && parent_object < 0) - { write_vertex(v); alreadywritten[v] = true;} + { write_vertex(v); alreadywritten[v] = true; } } write_particle(p, parent_object); @@ -177,7 +177,7 @@ void WriterAscii::allocate_buffer() { while ( m_buffer == nullptr && m_buffer_size >= 512 ) { try { m_buffer = new char[ m_buffer_size ](); - } catch (const std::bad_alloc& e) { + } catch (const std::bad_alloc& e) { delete[] m_buffer; m_buffer_size /= 2; HEPMC3_WARNING("WriterAscii::allocate_buffer:" << e.what() << " buffer size too large. Dividing by 2. New size: " << m_buffer_size) @@ -192,7 +192,7 @@ void WriterAscii::allocate_buffer() { } -std::string WriterAscii::escape(const std::string& s) const { +std::string WriterAscii::escape(const std::string& s) const { std::string ret; ret.reserve(s.length()*2); for ( std::string::const_iterator it = s.begin(); it != s.end(); ++it ) { @@ -222,7 +222,7 @@ void WriterAscii::write_vertex(ConstGenVertexPtr v) { std::sort(pids.begin(), pids.end()); for (auto pid: pids) { if ( !printed_first ) { - m_cursor += sprintf(m_cursor, "%i", pid); + m_cursor += sprintf(m_cursor, "%i", pid); printed_first = true; } else m_cursor += sprintf(m_cursor, ",%i", pid); @@ -336,7 +336,7 @@ void WriterAscii::write_particle(ConstGenParticlePtr p, int second_field) { inline void WriterAscii::write_string(const std::string &str) { // First let's check if string will fit into the buffer - if ( m_buffer + m_buffer_size > m_cursor + str.length() ) { + if ( m_buffer + m_buffer_size > m_cursor + str.length() ) { strncpy(m_cursor, str.data(), str.length()); m_cursor += str.length(); flush(); diff --git a/src/WriterAsciiHepMC2.cc b/src/WriterAsciiHepMC2.cc index f36c53c5..d477a302 100644 --- a/src/WriterAsciiHepMC2.cc +++ b/src/WriterAsciiHepMC2.cc @@ -109,17 +109,17 @@ void WriterAsciiHepMC2::write_event(const GenEvent &evt) { for (ConstGenParticlePtr p: v->particles_in()) { - if (!p->production_vertex()) { if (p->status() == 4) beams.push_back(idbeam); idbeam++;} - else if (p->production_vertex()->id() == 0) { if (p->status() == 4) beams.push_back(idbeam); idbeam++;} + if (!p->production_vertex()) { if (p->status() == 4) beams.push_back(idbeam); idbeam++; } + else if (p->production_vertex()->id() == 0) { if (p->status() == 4) beams.push_back(idbeam); idbeam++; } } - for (ConstGenParticlePtr p: v->particles_out()) { if (p->status() == 4) beams.push_back(idbeam); idbeam++;} + for (ConstGenParticlePtr p: v->particles_out()) { if (p->status() == 4) beams.push_back(idbeam); idbeam++; } } // int idbeam1 = 10000; int idbeam2 = 10000; if (beams.size() > 0) idbeam1 += beams[0] + 1; if (beams.size() > 1) idbeam2 += beams[1] + 1; - m_cursor += sprintf(m_cursor, "E %d %d %e %e %e %d %d %lu %i %i", + m_cursor += sprintf(m_cursor, "E %d %d %e %e %e %d %d %zu %i %i", evt.event_number(), mpi, event_scale, @@ -134,13 +134,13 @@ void WriterAsciiHepMC2::write_event(const GenEvent &evt) // This should be the largest single add to the buffer. Its size 11+4*11+3*22+2*11+10=153 flush(); m_cursor += sprintf(m_cursor, " %zu", m_random_states.size()); - for (size_t q = 0; q < m_random_states.size(); q++) + for (size_t q = 0; q < m_random_states.size(); q++) { m_cursor += sprintf(m_cursor, " %ii", (int)q); flush(); } flush(); - m_cursor += sprintf(m_cursor, " %lu", evt.weights().size()); + m_cursor += sprintf(m_cursor, " %zu", evt.weights().size()); if ( evt.weights().size() ) { for (double w: evt.weights()) { @@ -149,7 +149,7 @@ void WriterAsciiHepMC2::write_event(const GenEvent &evt) } m_cursor += sprintf(m_cursor, "\n"); flush(); - m_cursor += sprintf(m_cursor, "N %lu", evt.weights().size()); + m_cursor += sprintf(m_cursor, "N %zu", evt.weights().size()); std::vector<std::string> names = run_info()->weight_names(); for (size_t q = 0; q < evt.weights().size(); q++) { @@ -158,11 +158,11 @@ void WriterAsciiHepMC2::write_event(const GenEvent &evt) else write_string(" \""+std::to_string(q)+"\""); /* - if (q < names.size()) + if (q < names.size()) m_cursor += sprintf(m_cursor, " \"%s\"", names[q].c_str()); else m_cursor += sprintf(m_cursor, " \"%i\"", (int)q); -*/ +*/ flush(); } } @@ -172,7 +172,7 @@ void WriterAsciiHepMC2::write_event(const GenEvent &evt) m_cursor += sprintf(m_cursor, "U %s %s\n", Units::name(evt.momentum_unit()).c_str(), Units::name(evt.length_unit()).c_str()); flush(); std::shared_ptr<GenCrossSection> cs = evt.attribute<GenCrossSection>("GenCrossSection"); - if (cs) {m_cursor += sprintf(m_cursor, "C %.*e %.*e\n", m_precision, cs->xsec(), m_precision, cs->xsec_err()); flush(); } + if (cs) { m_cursor += sprintf(m_cursor, "C %.*e %.*e\n", m_precision, cs->xsec(), m_precision, cs->xsec_err()); flush(); } // Write attributes @@ -229,7 +229,7 @@ void WriterAsciiHepMC2::allocate_buffer() while ( m_buffer == nullptr && m_buffer_size >= 512 ) { try { m_buffer = new char[ m_buffer_size ](); - } catch (const std::bad_alloc& e) { + } catch (const std::bad_alloc& e) { delete[] m_buffer; m_buffer_size /= 2; HEPMC3_WARNING("WriterAsciiHepMC2::allocate_buffer:" << e.what() << " buffer size too large. Dividing by 2. New size: " << m_buffer_size) @@ -305,9 +305,9 @@ void WriterAsciiHepMC2::write_vertex(ConstGenVertexPtr v) m_cursor += sprintf(m_cursor, " %.*e", m_precision, pos.t()); flush(); } - m_cursor += sprintf(m_cursor, " %i %lu %lu", orph, v->particles_out().size(), weights.size()); + m_cursor += sprintf(m_cursor, " %i %zu %zu", orph, v->particles_out().size(), weights.size()); flush(); - for (size_t i = 0; i < weights.size(); i++) { m_cursor += sprintf(m_cursor, " %.*e", m_precision, weights[i]); flush(); } + for (size_t i = 0; i < weights.size(); i++) { m_cursor += sprintf(m_cursor, " %.*e", m_precision, weights[i]); flush(); } m_cursor += sprintf(m_cursor, "\n"); flush(); } @@ -341,7 +341,7 @@ void WriterAsciiHepMC2::write_particle(ConstGenParticlePtr p, int /*second_field m_cursor += sprintf(m_cursor, "P %i", int(10001+m_particle_counter)); m_particle_counter++; flush(); - m_cursor += sprintf(m_cursor, " %i", p->pid() ); + m_cursor += sprintf(m_cursor, " %i", p->pid() ); flush(); m_cursor += sprintf(m_cursor, " %.*e", m_precision, p->momentum().px() ); flush(); @@ -376,7 +376,7 @@ void WriterAsciiHepMC2::write_particle(ConstGenParticlePtr p, int /*second_field std::vector<int> flowsv = A_flows->value(); int flowsize = flowsv.size(); m_cursor += sprintf(m_cursor, " %i", flowsize); - for (size_t k=0; k < flowsv.size(); k++) { m_cursor += sprintf(m_cursor, " %lu %i", k+1, flowsv.at(k)); flush();} + for (size_t k = 0; k < flowsv.size(); k++) { m_cursor += sprintf(m_cursor, " %zu %i", k + 1, flowsv.at(k)); flush(); } m_cursor += sprintf(m_cursor, "\n"); flush(); } else { @@ -401,7 +401,7 @@ void WriterAsciiHepMC2::write_particle(ConstGenParticlePtr p, int /*second_field inline void WriterAsciiHepMC2::write_string(const std::string &str) { // First let's check if string will fit into the buffer - if ( m_buffer + m_buffer_size > m_cursor + str.length() ) + if ( m_buffer + m_buffer_size > m_cursor + str.length() ) { strncpy(m_cursor, str.data(), str.length()); m_cursor += str.length(); -- GitLab