From eb845aaa3016c4065ceea5e3b19e4c63effda00b Mon Sep 17 00:00:00 2001
From: Scott Snyder <scott.snyder@cern.ch>
Date: Wed, 27 Apr 2016 14:58:28 +0200
Subject: [PATCH] 'Fix cppcheck warnings (scanf codes).'
 (LArRawConditions-01-17-16)

	* Tagging LArRawConditions-01-17-16.
	* src/LArOFCComplete.cxx: Fix cppcheck warnings (scanf codes).

2016-03-16  scott snyder  <snyder@bnl.gov>

	* Tagging LArRawConditions-01-17-15.
	* src/LArWaveHelper.cxx (subSample): Do rounding correctly.
---
 .../LArRawConditions/CMakeLists.txt           | 49 +++++++++++++++++++
 .../LArRawConditions/src/LArOFCComplete.cxx   |  4 +-
 .../LArRawConditions/src/LArWaveHelper.cxx    |  2 +-
 3 files changed, 52 insertions(+), 3 deletions(-)
 create mode 100644 LArCalorimeter/LArRawConditions/CMakeLists.txt

diff --git a/LArCalorimeter/LArRawConditions/CMakeLists.txt b/LArCalorimeter/LArRawConditions/CMakeLists.txt
new file mode 100644
index 00000000000..4f36de6989a
--- /dev/null
+++ b/LArCalorimeter/LArRawConditions/CMakeLists.txt
@@ -0,0 +1,49 @@
+################################################################################
+# Package: LArRawConditions
+################################################################################
+
+# Declare the package name:
+atlas_subdir( LArRawConditions )
+
+# Declare the package's dependencies:
+atlas_depends_on_subdirs( PUBLIC
+                          Calorimeter/CaloIdentifier
+                          Control/AthenaKernel
+                          Control/CLIDSvc
+                          Control/DataModel
+                          Control/SGTools
+                          Control/StoreGate
+                          Database/AthenaPOOL/AthenaPoolUtilities
+                          DetectorDescription/Identifier
+                          GaudiKernel
+                          LArCalorimeter/LArElecCalib
+                          LArCalorimeter/LArIdentifier
+                          LArCalorimeter/LArTools )
+
+# External dependencies:
+find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread )
+
+# Component(s) in the package:
+atlas_add_library( LArRawConditions
+                   src/*.cxx
+                   PUBLIC_HEADERS LArRawConditions
+                   PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
+                   LINK_LIBRARIES CaloIdentifier AthenaKernel DataModel SGTools AthenaPoolUtilities Identifier GaudiKernel LArIdentifier StoreGateLib SGtests LArToolsLib
+                   PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} )
+
+atlas_add_dictionary( LArRawConditions1Dict
+                      LArRawConditions/LArRawConditionsDict1.h
+                      LArRawConditions/selection1.xml
+                      INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
+                      LINK_LIBRARIES ${ROOT_LIBRARIES} CaloIdentifier AthenaKernel DataModel SGTools StoreGateLib SGtests AthenaPoolUtilities Identifier GaudiKernel LArIdentifier LArToolsLib LArRawConditions )
+
+atlas_add_dictionary( LArRawConditions2Dict
+                      LArRawConditions/LArRawConditionsDict2.h
+                      LArRawConditions/selection2.xml
+                      INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
+                      LINK_LIBRARIES ${ROOT_LIBRARIES} CaloIdentifier AthenaKernel DataModel SGTools StoreGateLib SGtests AthenaPoolUtilities Identifier GaudiKernel LArIdentifier LArToolsLib LArRawConditions )
+
+# Install files from the package:
+atlas_install_python_modules( python/*.py )
+atlas_install_joboptions( share/*.py )
+
diff --git a/LArCalorimeter/LArRawConditions/src/LArOFCComplete.cxx b/LArCalorimeter/LArRawConditions/src/LArOFCComplete.cxx
index 8f326dd8adb..e447f6a8d15 100755
--- a/LArCalorimeter/LArRawConditions/src/LArOFCComplete.cxx
+++ b/LArCalorimeter/LArRawConditions/src/LArOFCComplete.cxx
@@ -148,7 +148,7 @@ void LArOFCComplete::dumpOFC(std::string output_file_name) const {
       for ( ; it_chan !=it_chan_e ;++it_chan  ) {
 	  const LArOFCP1&   chunkOFC = *it_chan ;
 	  unsigned int     chID     = it_chan.channelId().get_identifier32().get_compact();
-	  fprintf( f , "---------------------- Gain = %1d ; Channel = %10x ----------------------\n", 
+	  fprintf( f , "---------------------- Gain = %1u ; Channel = %10x ----------------------\n", 
 		   iGain, chID ) ;
 	  unsigned nTbin = chunkOFC.OFC_aSize() ;
 	  assert( nTbin == chunkOFC.OFC_bSize() ) ;
@@ -156,7 +156,7 @@ void LArOFCComplete::dumpOFC(std::string output_file_name) const {
 	  for ( unsigned kBin=0 ; kBin<nTbin ; kBin++ ) {
               unsigned nSample = (chunkOFC.OFC_a (kBin)).size() ;
 	      assert( nSample == (chunkOFC.OFC_b (kBin)).size() ) ;
-	      fprintf( f , "\t%2d\t |" , kBin ) ;
+	      fprintf( f , "\t%2u\t |" , kBin ) ;
 	      for ( unsigned kSample=0 ; kSample<nSample ; kSample++ ) {
                 fprintf( f , "\t%8.3f" , chunkOFC.OFC_a(kBin)[kSample] ) ;
 	      }
diff --git a/LArCalorimeter/LArRawConditions/src/LArWaveHelper.cxx b/LArCalorimeter/LArRawConditions/src/LArWaveHelper.cxx
index 5b0cb149ecc..221578e095d 100755
--- a/LArCalorimeter/LArRawConditions/src/LArWaveHelper.cxx
+++ b/LArCalorimeter/LArRawConditions/src/LArWaveHelper.cxx
@@ -335,7 +335,7 @@ LArWave LArWaveHelper::subSample(const LArWave& theWave,unsigned Nfirst,unsigned
 {
   unsigned length = theWave.getSize() ;
   if ( length <= 0 ) return LArWave() ;
-  unsigned Nsamp = (int)ceil( (length-Nfirst)/deltaN ) ;
+  unsigned Nsamp = (length-Nfirst + (deltaN-1)) / deltaN ;
   LArWave w( Nsamp , deltaN*theWave.getDt() ) ;
   for (unsigned i=0;i<Nsamp;i++) {
     unsigned j = Nfirst + i * deltaN ;
-- 
GitLab