Commit 5fe8cab1 authored by Shaun Roe's avatar Shaun Roe Committed by Graeme Stewart
Browse files

self assign guard had error in TRT_EndCap code (InDetReadoutGeometry-02-00-17)

	* fix 11794, was not guarding against self assign
	*  tag as InDetReadoutGeometry-02-00-17
2014-12-10 Shaun Roe
	* fix coverity 11193, 11793,11194,11794 ; operator= was returning a const ref
	* tag as InDetReadoutGeometry-02-00-16
2014-11-15 Shaun Roe
	* Correct coverity defect 11955, undefined member variables in c'tor
	* tag as InDetReadoutGeometry-02-00-15
parent 2b0a17bf
......@@ -2,11 +2,9 @@
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// SiDetectorElement.h
///////////////////////////////////////////////////////////////////
// (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
/**
* @file SiDetectorElement.h
**/
#ifndef INDETREADOUTGEOMETRY_SIDETECTORELEMENT_H
#define INDETREADOUTGEOMETRY_SIDETECTORELEMENT_H
......@@ -148,9 +146,9 @@ namespace InDetDD {
bool isNextToInnermostPixelLayer() const;
bool isDBM() const;
// Identfier <-> SiCellId (ie strip number or pixel eta_index,phi_index)
// Identifier <-> SiCellId (ie strip number or pixel eta_index,phi_index)
/// Identfier from SiCellId (ie strip number or pixel eta_index,phi_index)
/// Identifier from SiCellId (ie strip number or pixel eta_index,phi_index)
Identifier identifierFromCellId(const SiCellId & cellId) const;
/// SiCellId from Identifier
......@@ -533,9 +531,6 @@ namespace InDetDD {
/// Update all caches including surfaces.
void updateAllCaches() const;
//@}
///////////////////////////////////////////////////////////////////
......@@ -581,7 +576,6 @@ namespace InDetDD {
// Common code for constructors.
void commonConstructor();
// Calculate extent in r,z and phi. The values are cached and there
// are rMin(), rMax etc methods.
void getExtent(double &rMin, double &rMax,
......@@ -611,19 +605,15 @@ namespace InDetDD {
// Private methods:
///////////////////////////////////////////////////////////////////
private:
// Don't allow copying.
SiDetectorElement();
SiDetectorElement(const SiDetectorElement&);
SiDetectorElement &operator=(const SiDetectorElement&);
///////////////////////////////////////////////////////////////////
// Protected data:
///////////////////////////////////////////////////////////////////
protected:
Identifier m_id; // identifier of this detector element
IdentifierHash m_idHash; // hash id
const SiDetectorDesign *m_design; // local description of this detector element
......
......@@ -36,8 +36,8 @@ namespace InDetDD {
TRT_BarrelCode( const TRT_BarrelCode & right );
~TRT_BarrelCode();
const TRT_BarrelCode & operator=( const TRT_BarrelCode & right );
//(operator= ) was returning const ref; changed on 10/12/2014 sroe
TRT_BarrelCode & operator=( const TRT_BarrelCode & right );
bool operator < (const TRT_BarrelCode & right) const;
bool operator > (const TRT_BarrelCode & right) const;
......@@ -59,7 +59,7 @@ namespace InDetDD {
// bit 3-7 Phi Index
// bit 8-12 StrawLayer Index
unsigned short int _key;
unsigned short int m_key;
static const int Z_MASK;
static const int MODULE_MASK;
......@@ -77,27 +77,27 @@ namespace InDetDD {
inline unsigned int TRT_BarrelCode::isPosZ() const {
unsigned int ret = _key;
unsigned int ret = m_key;
return (ret >> Z_SHIFT) & Z_MASK;
}
inline unsigned int TRT_BarrelCode::getModuleIndex() const{
unsigned int ret = _key;
unsigned int ret = m_key;
return (ret >> MODULE_SHIFT) & MODULE_MASK;
}
inline unsigned int TRT_BarrelCode::getPhiIndex() const{
unsigned int ret = _key;
unsigned int ret = m_key;
return (ret >> PHI_SHIFT) & PHI_MASK;
}
inline unsigned int TRT_BarrelCode::getStrawLayerIndex() const {
unsigned int ret = _key;
unsigned int ret = m_key;
return (ret >> STRAWLAYER_SHIFT) & STRAWLAYER_MASK;
}
inline unsigned int TRT_BarrelCode::getKey() const {
return _key;
return m_key;
}
......
......@@ -36,8 +36,8 @@ namespace InDetDD {
TRT_EndcapCode( const TRT_EndcapCode & right );
~TRT_EndcapCode();
const TRT_EndcapCode & operator=( const TRT_EndcapCode & right );
//was returning a const ref; changed 10/12/2014, sroe
TRT_EndcapCode & operator=( const TRT_EndcapCode & right );
bool operator < (const TRT_EndcapCode & right) const;
bool operator > (const TRT_EndcapCode & right) const;
......@@ -60,7 +60,7 @@ namespace InDetDD {
// bit 3-7 StrawLayer Index
// bit 8-12 Phi position (0-31)
unsigned short int _key;
unsigned short int m_key;
static const int Z_MASK;
static const int WHEEL_MASK;
......@@ -77,28 +77,28 @@ namespace InDetDD {
inline unsigned int TRT_EndcapCode::isPosZ() const {
unsigned int ret = _key;
unsigned int ret = m_key;
return (ret >> Z_SHIFT) & Z_MASK;
}
inline unsigned int TRT_EndcapCode::getWheelIndex() const{
unsigned int ret = _key;
unsigned int ret = m_key;
return (ret >> WHEEL_SHIFT) & WHEEL_MASK;
}
inline unsigned int TRT_EndcapCode::getStrawLayerIndex() const {
unsigned int ret = _key;
unsigned int ret = m_key;
return (ret >> STRAWLAYER_SHIFT) & STRAWLAYER_MASK;
}
inline unsigned int TRT_EndcapCode::getPhiIndex() const {
unsigned int ret = _key;
unsigned int ret = m_key;
return (ret >> PHIPOS_SHIFT) & PHIPOS_MASK;
}
inline unsigned int TRT_EndcapCode::getKey() const {
return _key;
return m_key;
}
......
......@@ -2,15 +2,12 @@
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// SiDetectorElement.cxx
// Implementation file for class SiDetectorElement
///////////////////////////////////////////////////////////////////
// (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
// Authors: Grant Gorfine
// Based on version developed by David Calvet.
///////////////////////////////////////////////////////////////////
/**
* @file SiDetectorElement.cxx
* Implementation file for class SiDetectorElement
* @author Grant Gorfine
* Based on version developed by David Calvet.
**/
#include "InDetReadoutGeometry/SiDetectorElement.h"
......@@ -25,7 +22,6 @@
#include "CLHEP/Vector/ThreeVector.h"
#include "CLHEP/Units/PhysicalConstants.h" // for M_PI
#include "CLHEP/Units/SystemOfUnits.h"
//#include "GeoPrimitives/CLHEPtoEigenConverter.h"
#include "InDetReadoutGeometry/SiCellId.h"
#include "InDetReadoutGeometry/SiReadoutCellId.h"
......@@ -36,14 +32,11 @@
#include "TrkSurfaces/SurfaceBounds.h"
#include "InDetCondServices/ISiLorentzAngleSvc.h"
#include <cmath>
#include <cassert>
#include <limits>
namespace InDetDD {
using Trk::distPhi;
using Trk::distEta;
using Trk::distDepth;
......@@ -71,13 +64,27 @@ SiDetectorElement::SiDetectorElement(const Identifier &id,
m_lorentzCorrection(0),
m_surface(0)
{
//The following are fixes for coverity bug 11955, uninitialized scalars:
const bool boolDefault(true);
m_depthDirection=boolDefault;
m_phiDirection=boolDefault;
m_etaDirection=boolDefault;
const double defaultMin(std::numeric_limits<double>::max());
const double defaultMax(std::numeric_limits<double>::lowest());
m_minZ=defaultMin;
m_maxZ=defaultMax;
m_minR=defaultMin;
m_maxR=defaultMax;
m_minPhi=defaultMin;
m_maxPhi=defaultMax;
///
commonConstructor();
}
void
SiDetectorElement::commonConstructor()
{
if (!m_id.is_valid()) throw std::runtime_error("SiDetectorElement: Invalid identifier");
// Set booleans for wether we are pixel/sct barrel/endcap
......
......@@ -29,12 +29,12 @@ const int TRT_BarrelCode::STRAWLAYER_SHIFT = 8;
TRT_BarrelCode::TRT_BarrelCode()
{
_key = 0;
m_key = 0;
}
TRT_BarrelCode::TRT_BarrelCode(unsigned isPos, unsigned moduleIndex, unsigned phiIndex, unsigned strawLayerIndex)
:
_key ((( isPos & Z_MASK ) << Z_SHIFT) |
m_key ((( isPos & Z_MASK ) << Z_SHIFT) |
(( moduleIndex & MODULE_MASK ) << MODULE_SHIFT) |
(( phiIndex & PHI_MASK ) << PHI_SHIFT) |
(( strawLayerIndex & STRAWLAYER_MASK ) << STRAWLAYER_SHIFT))
......@@ -43,7 +43,7 @@ TRT_BarrelCode::TRT_BarrelCode(unsigned isPos, unsigned moduleIndex, unsigned ph
TRT_BarrelCode::TRT_BarrelCode(const TRT_BarrelCode &right)
{
_key = right.getKey();
m_key = right.getKey();
}
......@@ -54,16 +54,17 @@ TRT_BarrelCode::~TRT_BarrelCode()
}
const TRT_BarrelCode & TRT_BarrelCode::operator=(const TRT_BarrelCode &right)
{
_key = right.getKey();
TRT_BarrelCode & TRT_BarrelCode::operator=(const TRT_BarrelCode &right)
{
if (this != &right){
m_key = right.getKey();
}
return *this;
}
std::string TRT_BarrelCode::getName() const {
std::ostringstream outputStream;
outputStream << this;
return outputStream.str();
......
......@@ -26,12 +26,12 @@ const int TRT_EndcapCode::PHIPOS_SHIFT = 11;
TRT_EndcapCode::TRT_EndcapCode()
{
_key = 0;
m_key = 0;
}
TRT_EndcapCode::TRT_EndcapCode(unsigned isPos, unsigned wheelIndex, unsigned strawLayerIndex, unsigned int phiIndex)
:
_key ((( isPos & Z_MASK ) << Z_SHIFT) |
m_key ((( isPos & Z_MASK ) << Z_SHIFT) |
(( wheelIndex & WHEEL_MASK ) << WHEEL_SHIFT) |
(( strawLayerIndex & STRAWLAYER_MASK ) << STRAWLAYER_SHIFT) |
(( phiIndex & PHIPOS_MASK ) << PHIPOS_SHIFT))
......@@ -40,7 +40,7 @@ TRT_EndcapCode::TRT_EndcapCode(unsigned isPos, unsigned wheelIndex, unsigned str
TRT_EndcapCode::TRT_EndcapCode(const TRT_EndcapCode &right)
{
_key = right.getKey();
m_key = right.getKey();
}
......@@ -51,16 +51,17 @@ TRT_EndcapCode::~TRT_EndcapCode()
}
const TRT_EndcapCode & TRT_EndcapCode::operator=(const TRT_EndcapCode &right)
TRT_EndcapCode & TRT_EndcapCode::operator=(const TRT_EndcapCode &right)
{
_key = right.getKey();
if (this != &right){
m_key = right.getKey();
}
return *this;
}
std::string TRT_EndcapCode::getName() const {
std::ostringstream outputStream;
outputStream << this;
return outputStream.str();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment