Skip to content
Snippets Groups Projects
Commit e5516db7 authored by scott snyder's avatar scott snyder Committed by scott snyder
Browse files

TileEvent: Fix cppcheck warnings.

cppcheck warnings:
  - Pass large objects by const ref, not by value.
  - Prefer to initialize members in an initialization list.
  - Suppress false positives stemming from the union used
    for calo cell quality.
    
parent 352ae0ea
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
//***************************************************************************
......@@ -16,7 +16,7 @@
// leakage corrections. Time represents when the feature extraction thinks
// the deposit occured, in nanoseconds, relative to the trigger. It ought
// to be zero for good hits.
// Quality is an 32-bits integer number, which is split in 4 unsinged chars
// Quality is an 32-bits integer number, which is split in 4 unsigned chars
// m_tileQual[4] like this:
// m_tileQual[0] and m_tileQual[1] are unsigned quality from TileRawChannel for first and second PMT
// m_tileQual[2] and m_tileQual[3] contains special bits for first and second PMT respectively:
......@@ -167,14 +167,19 @@ public:
/** @brief set quality of first PMT */
void setQual1 (unsigned char qual) { m_tileQual[0] = qual; }
/** @brief set quality of second PMT */
// cppcheck-suppress objectIndex
void setQual2 (unsigned char qual) { m_tileQual[1] = qual; }
/** @brief set quality bits of first PMT */
// cppcheck-suppress objectIndex
void setQbit1 (unsigned char qbit) { m_tileQual[2] = qbit; }
/** @brief set quality bits of second PMT */
// cppcheck-suppress objectIndex
void setQbit2 (unsigned char qbit) { m_tileQual[3] = qbit; }
/** @brief set quality and quality bits of first PMT */
// cppcheck-suppress objectIndex
void setQual1 (unsigned char qual, unsigned char qbit) { m_tileQual[0] = qual; m_tileQual[2] = qbit; }
/** @brief set quality and quality bits of second PMT */
// cppcheck-suppress objectIndex
void setQual2 (unsigned char qual, unsigned char qbit) { m_tileQual[1] = qual; m_tileQual[3] = qbit; }
/** all get methods */
......@@ -197,14 +202,19 @@ public:
/** @brief get quality of first PMT (data member) */
virtual uint8_t qual1 (void) const { return m_tileQual[0]; }
/** @brief get quality of second PMT (data member) */
// cppcheck-suppress objectIndex
virtual uint8_t qual2 (void) const { return m_tileQual[1]; }
/** @brief get quality bits of first PMT (data member) */
// cppcheck-suppress objectIndex
virtual uint8_t qbit1 (void) const { return m_tileQual[2]; }
/** @brief get quality bits of second PMT (data member) */
// cppcheck-suppress objectIndex
virtual uint8_t qbit2 (void) const { return m_tileQual[3]; }
/** @brief check if first PMT is in bad channel list and masked */
// cppcheck-suppress objectIndex
virtual bool badch1 (void) const { return ((m_tileQual[2]&TileCell::MASK_BADCH) != 0); }
/** @brief check if second PMT is in bad channel list and masked */
// cppcheck-suppress objectIndex
virtual bool badch2 (void) const { return ((m_tileQual[3]&TileCell::MASK_BADCH) != 0); }
/** @brief check if whole cell is bad (i.e. no energy measurement at all in this cell) */
virtual bool badcell (void) const { return (badch1() & badch2()); }
......@@ -253,7 +263,9 @@ void TileCell::setEnergy_nonvirt(float e1, float e2, int gain1, int gain2)
inline
void TileCell::setQuality_nonvirt(unsigned char qual, unsigned char qbit, int pmt) {
// cppcheck-suppress objectIndex
m_tileQual[0+pmt] = qual;
// cppcheck-suppress objectIndex
m_tileQual[2+pmt] = qbit;
}
......
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
//***************************************************************************
......@@ -66,15 +66,15 @@ public:
// Can be used in a cast operation : (std::string) TileRawData
virtual operator std::string() const;
static void print_to_stream ( const std::vector<float> val,
static void print_to_stream ( const std::vector<float>& val,
const std::string & label,
std::ostringstream & text);
static void print_to_stream ( const std::vector<double> val,
static void print_to_stream ( const std::vector<double>& val,
const std::string & label,
std::ostringstream & text);
static void print_to_stream ( const std::vector<uint32_t> val,
static void print_to_stream ( const std::vector<uint32_t>& val,
const std::string & label,
std::ostringstream & text);
private:
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
//*****************************************************************************
......@@ -72,8 +72,11 @@ TileCell::TileCell(const CaloDetDescrElement* const & caloDDE,
, m_timeDiff((time1-time2)/2.)
{
m_tileQual[0] = std::min(255,abs(qual1));
// cppcheck-suppress objectIndex
m_tileQual[1] = std::min(255,abs(qual2));
// cppcheck-suppress objectIndex
m_tileQual[2] = (qbit1 & 0xFF);
// cppcheck-suppress objectIndex
m_tileQual[3] = (qbit2 & 0xFF);
}
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
//*****************************************************************************
......@@ -32,8 +32,8 @@
TileCablingService * s_cabling = TileCablingService::getInstance();
TileRawData::TileRawData( const Identifier& id )
: m_adc_hwid (s_cabling->s2h_adc_id(id))
{
m_adc_hwid = s_cabling->s2h_adc_id(id);
}
void TileRawData::print() const
......@@ -76,40 +76,34 @@ int TileRawData::frag_ID(void) const {
return s_cabling->frag(m_adc_hwid);
}
void TileRawData::print_to_stream ( const std::vector<float> val,
void TileRawData::print_to_stream ( const std::vector<float>& val,
const std::string & label,
std::ostringstream & text)
{
text << label;
std::vector<float>::const_iterator it1=val.begin();
std::vector<float>::const_iterator it2=val.end();
for ( ; it1!=it2; ++it1) text << " " << (*it1);
for (float v : val) {
text << " " << v;
}
}
void TileRawData::print_to_stream ( const std::vector<double> val,
void TileRawData::print_to_stream ( const std::vector<double>& val,
const std::string & label,
std::ostringstream & text)
{
text << label;
std::vector<double>::const_iterator it1=val.begin();
std::vector<double>::const_iterator it2=val.end();
for ( ; it1!=it2; ++it1) text << " " << (*it1);
for (double v : val) {
text << " " << v;
}
}
void TileRawData::print_to_stream ( const std::vector<uint32_t> val,
void TileRawData::print_to_stream ( const std::vector<uint32_t>& val,
const std::string & label,
std::ostringstream & text)
{
text << label;
std::vector<uint32_t>::const_iterator it1=val.begin();
std::vector<uint32_t>::const_iterator it2=val.end();
for ( ; it1!=it2; ++it1) text << " " << (*it1);
for (uint32_t v : val) {
text << " " << v;
}
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
//*****************************************************************************
......@@ -34,8 +34,8 @@ TileSimData::TileSimData( const Identifier& id ) : m_pmt_id( id )
}
TileSimData::TileSimData( const HWIdentifier& HWid )
: m_pmt_id (s_cabling->h2s_pmt_id(HWid))
{
m_pmt_id = s_cabling->h2s_pmt_id(HWid);
}
void TileSimData::print() const
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment