diff --git a/InnerDetector/InDetSimEvent/InDetSimEvent/SiHitIdHelper.h b/InnerDetector/InDetSimEvent/InDetSimEvent/SiHitIdHelper.h index 2ee9d2092cffadf495bb81d9e85bf481dd00f575..f9843b7d7ce5a2f59b436542d5904ee8ad1e6121 100755 --- a/InnerDetector/InDetSimEvent/InDetSimEvent/SiHitIdHelper.h +++ b/InnerDetector/InDetSimEvent/InDetSimEvent/SiHitIdHelper.h @@ -1,16 +1,16 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #ifndef INDETSIMEVENT_SIHITIDHELPER #define INDETSIMEVENT_SIHITIDHELPER // -// This is a helper class to build an identifing integer used by +// This is a helper class to build an identifing integer used by // the simulation. It inherits from HitIdHelper, in order to get -// all the packing and shifting for free. -// The class is a singleton and a static GetHelper() is provided -// the constructor calls the Initialize() method which sets all the +// all the packing and shifting for free. +// The class is a singleton and a static GetHelper() is provided +// the constructor calls the Initialize() method which sets all the // field dimensions // Methods are provided to get access to the SiTracker Geometry // description @@ -26,38 +26,38 @@ class SiHitIdHelper : HitIdHelper { public: // // Access to the helper - static SiHitIdHelper* GetHelper(); + static SiHitIdHelper* GetHelper(); // // Info retrieval: // Pixel or SCT - bool isPixel(const int& hid); - bool isSCT(const int& hid); - + bool isPixel(const int& hid) const; + bool isSCT(const int& hid) const; + // Barrel or Endcap - int getBarrelEndcap(const int& hid); + int getBarrelEndcap(const int& hid) const; // Layer/Disk - int getLayerDisk(const int& hid); - + int getLayerDisk(const int& hid) const; + // eta module - int getEtaModule(const int& hid); + int getEtaModule(const int& hid) const; // phi module& - int getPhiModule(const int& hid); - + int getPhiModule(const int& hid) const; + // side - int getSide(const int& hid); + int getSide(const int& hid) const; // // Info packing: - int buildHitId(const int, const int, const int, const int, const int, const int); + int buildHitId(const int, const int, const int, const int, const int, const int) const; private: // // private constructor to have a singleton - SiHitIdHelper(); + SiHitIdHelper(); // // Initialize the helper, only called by the constructor - void Initialize(); + void Initialize(); }; #endif // INDETSIMEVENT_SIHITIDHELPER diff --git a/InnerDetector/InDetSimEvent/InDetSimEvent/TRTHitIdHelper.h b/InnerDetector/InDetSimEvent/InDetSimEvent/TRTHitIdHelper.h index 7fdec74378944b1d91917cc084be6652098c2245..21ca9cfc3bbcd12c6ceacdec05898e70058ebd50 100755 --- a/InnerDetector/InDetSimEvent/InDetSimEvent/TRTHitIdHelper.h +++ b/InnerDetector/InDetSimEvent/InDetSimEvent/TRTHitIdHelper.h @@ -1,16 +1,16 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #ifndef INDETSIMEVENT_TRTHITIDHELPER #define INDETSIMEVENT_TRTHITIDHELPER // -// This is a helper class to build an identifing integer used by +// This is a helper class to build an identifing integer used by // the simulation. It inherits from HitIdHelper, in order to get -// all the packing and shifting for free. -// The class is a singleton and a static GetHelper() is provided -// the constructor calls the Initialize() method which sets all the +// all the packing and shifting for free. +// The class is a singleton and a static GetHelper() is provided +// the constructor calls the Initialize() method which sets all the // field dimensions // Methods are provided to get access to the TRT Geometry // description @@ -26,39 +26,39 @@ class TRTHitIdHelper : HitIdHelper { public: // // Access to the helper - static TRTHitIdHelper* GetHelper(); + static TRTHitIdHelper* GetHelper(); // // Info retrieval: // Barrel or Endcap - bool isBarrel(const int& hid); - bool isEndcap(const int& hid); + bool isBarrel(const int& hid) const; + bool isEndcap(const int& hid) const; // - // Positive or negative side - bool isPositive(const int& hid); - bool isNegative(const int& hid); + // Positive or negative side + bool isPositive(const int& hid) const; + bool isNegative(const int& hid) const; // Ring or Wheel - int getRingWheel(const int& hid); + int getRingWheel(const int& hid) const; // PhiSector - int getPhiSector(const int& hid); - + int getPhiSector(const int& hid) const; + // Layer Plane - int getLayerPlane(const int& hid); + int getLayerPlane(const int& hid) const; // straw - int getStraw(const int& hid); + int getStraw(const int& hid) const; // // Info packing: - int buildHitId(const int, const int, const int, const int, const int, const int); + int buildHitId(const int, const int, const int, const int, const int, const int) const; private: // // private constructor to have a singleton - TRTHitIdHelper(); + TRTHitIdHelper(); // // Initialize the helper, only called by the constructor - void Initialize(); + void Initialize(); }; #endif // INDETSIMEVENT_TRTHITIDHELPER diff --git a/InnerDetector/InDetSimEvent/src/SiHitIdHelper.cxx b/InnerDetector/InDetSimEvent/src/SiHitIdHelper.cxx index c2be5e907f15de77aca2577f219fe943afd5b7c0..25506a70acc3418fdbecf3bc79a62b29946c3f7f 100755 --- a/InnerDetector/InDetSimEvent/src/SiHitIdHelper.cxx +++ b/InnerDetector/InDetSimEvent/src/SiHitIdHelper.cxx @@ -61,61 +61,62 @@ void SiHitIdHelper::Initialize() { // Info retrieval: // Pixel or SCT -bool SiHitIdHelper::isPixel(const int& hid){ - this->SetID(hid); - int ps = this->GetFieldValue("PixelSCT"); +bool SiHitIdHelper::isPixel(const int& hid) const +{ + int ps = this->GetFieldValue("PixelSCT", hid); if (ps ==0 ) return true; else return false; } -bool SiHitIdHelper::isSCT(const int& hid){ - this->SetID(hid); - int ps = this->GetFieldValue("PixelSCT"); +bool SiHitIdHelper::isSCT(const int& hid) const +{ + int ps = this->GetFieldValue("PixelSCT", hid); if (ps ==0 ) return false; else return true; } // Barrel or Endcap -int SiHitIdHelper::getBarrelEndcap(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("BarrelEndcap"); +int SiHitIdHelper::getBarrelEndcap(const int& hid) const +{ + return this->GetFieldValue("BarrelEndcap", hid); } // Layer/Disk -int SiHitIdHelper::getLayerDisk(const int& hid) { - this->SetID(hid); - return this->GetFieldValue("LayerDisk"); +int SiHitIdHelper::getLayerDisk(const int& hid) const +{ + return this->GetFieldValue("LayerDisk", hid); } // eta module -int SiHitIdHelper::getEtaModule(const int& hid) { - this->SetID(hid); - return this->GetFieldValue("EtaModule"); +int SiHitIdHelper::getEtaModule(const int& hid) const +{ + return this->GetFieldValue("EtaModule", hid); } // phi module -int SiHitIdHelper::getPhiModule(const int& hid) { - this->SetID(hid); - return this->GetFieldValue("PhiModule"); +int SiHitIdHelper::getPhiModule(const int& hid) const +{ + return this->GetFieldValue("PhiModule", hid); } // side -int SiHitIdHelper::getSide(const int& hid) { - this->SetID(hid); - return this->GetFieldValue("Side"); +int SiHitIdHelper::getSide(const int& hid) const +{ + return this->GetFieldValue("Side", hid); } // // Info packing: int SiHitIdHelper::buildHitId(const int Pixel_SCT, const int BrlECap, const int LayerDisk, - const int etaM, const int phiM, const int side) { - this->SetID(0); - this->SetFieldValue("PixelSCT", Pixel_SCT); - this->SetFieldValue("BarrelEndcap", BrlECap); - this->SetFieldValue("LayerDisk", LayerDisk); - this->SetFieldValue("EtaModule", etaM); - this->SetFieldValue("PhiModule", phiM); - this->SetFieldValue("Side", side); - return this->GetID(); + const int etaM, const int phiM, const int side) const +{ + int theID(0); + this->SetFieldValue("PixelSCT", Pixel_SCT, theID); + this->SetFieldValue("BarrelEndcap", BrlECap, theID); + this->SetFieldValue("LayerDisk", LayerDisk, theID); + this->SetFieldValue("EtaModule", etaM, theID); + this->SetFieldValue("PhiModule", phiM, theID); + this->SetFieldValue("Side", side, theID); + return theID; } diff --git a/InnerDetector/InDetSimEvent/src/TRTHitIdHelper.cxx b/InnerDetector/InDetSimEvent/src/TRTHitIdHelper.cxx index c0c4a9bf5eecba74ce819882821e55ebc4cfde62..d424031d8f4206a81758929d8e10317f61ece160 100755 --- a/InnerDetector/InDetSimEvent/src/TRTHitIdHelper.cxx +++ b/InnerDetector/InDetSimEvent/src/TRTHitIdHelper.cxx @@ -1,10 +1,10 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #include "InDetSimEvent/TRTHitIdHelper.h" -// +// // private constructor TRTHitIdHelper::TRTHitIdHelper() :HitIdHelper() { Initialize(); @@ -22,75 +22,65 @@ void TRTHitIdHelper::Initialize() { InitializeField("RingWheel",0,31); InitializeField("PositiveNegative",0,1); InitializeField("BarrelEndcap",0,1); -} +} // Info retrieval: // Barrel or Endcap -bool TRTHitIdHelper::isBarrel(const int& hid){ - this->SetID(hid); - int ps = this->GetFieldValue("BarrelEndcap"); +bool TRTHitIdHelper::isBarrel(const int& hid) const { + int ps = this->GetFieldValue("BarrelEndcap", hid); if (ps ==0 ) return true; else return false; } -bool TRTHitIdHelper::isEndcap(const int& hid){ - this->SetID(hid); - int ps = this->GetFieldValue("BarrelEndcap"); +bool TRTHitIdHelper::isEndcap(const int& hid) const { + int ps = this->GetFieldValue("BarrelEndcap", hid); if (ps ==0 ) return false; else return true; -} +} // Positive or Negative -bool TRTHitIdHelper::isPositive(const int& hid){ - this->SetID(hid); - int ps = this->GetFieldValue("PositiveNegative"); +bool TRTHitIdHelper::isPositive(const int& hid) const { + int ps = this->GetFieldValue("PositiveNegative", hid); if (ps ==0 ) return true; else return false; -} -bool TRTHitIdHelper::isNegative(const int& hid){ - this->SetID(hid); - int ps = this->GetFieldValue("PositiveNegative"); +} +bool TRTHitIdHelper::isNegative(const int& hid) const { + int ps = this->GetFieldValue("PositiveNegative", hid); if (ps ==0 ) return false; else return true; -} +} // Ring/Wheel -int TRTHitIdHelper::getRingWheel(const int& hid) { - this->SetID(hid); - return this->GetFieldValue("RingWheel"); -} +int TRTHitIdHelper::getRingWheel(const int& hid) const { + return this->GetFieldValue("RingWheel", hid); +} // Phi Sector -int TRTHitIdHelper::getPhiSector(const int& hid) { - this->SetID(hid); - return this->GetFieldValue("PhiSector"); +int TRTHitIdHelper::getPhiSector(const int& hid) const { + return this->GetFieldValue("PhiSector", hid); } // layer/plane -int TRTHitIdHelper::getLayerPlane(const int& hid) { - this->SetID(hid); - return this->GetFieldValue("LayerPlane"); +int TRTHitIdHelper::getLayerPlane(const int& hid) const { + return this->GetFieldValue("LayerPlane", hid); } - + // straw -int TRTHitIdHelper::getStraw(const int& hid) { - this->SetID(hid); - return this->GetFieldValue("Straw"); +int TRTHitIdHelper::getStraw(const int& hid) const { + return this->GetFieldValue("Straw", hid); } // // Info packing: int TRTHitIdHelper::buildHitId(const int BrlECap, const int PosNeg, const int RingWheel, - const int PhiS, const int LayerPlane, const int Straw) { - this->SetID(0); - this->SetFieldValue("BarrelEndcap", BrlECap); - this->SetFieldValue("PositiveNegative", PosNeg); - this->SetFieldValue("RingWheel", RingWheel); - this->SetFieldValue("PhiSector", PhiS); - this->SetFieldValue("LayerPlane", LayerPlane); - this->SetFieldValue("Straw", Straw); - return this->GetID(); + const int PhiS, const int LayerPlane, const int Straw) const { + int theID(0); + this->SetFieldValue("BarrelEndcap", BrlECap, theID); + this->SetFieldValue("PositiveNegative", PosNeg, theID); + this->SetFieldValue("RingWheel", RingWheel, theID); + this->SetFieldValue("PhiSector", PhiS, theID); + this->SetFieldValue("LayerPlane", LayerPlane, theID); + this->SetFieldValue("Straw", Straw, theID); + return theID; } - - diff --git a/MuonSpectrometer/MuonSimEvent/MuonSimEvent/CscHitIdHelper.h b/MuonSpectrometer/MuonSimEvent/MuonSimEvent/CscHitIdHelper.h index 012204ad601fa08bab63b7c15970a86d96a6862b..7d02b4196a9d083b6da3239051a1cfad59c19a97 100644 --- a/MuonSpectrometer/MuonSimEvent/MuonSimEvent/CscHitIdHelper.h +++ b/MuonSpectrometer/MuonSimEvent/MuonSimEvent/CscHitIdHelper.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #ifndef CscHitIdHelper_H @@ -8,27 +8,27 @@ #include <string> //base class -#include "HitManagement/HitIdHelper.h" +#include "HitManagement/HitIdHelper.h" class CscHitIdHelper: public HitIdHelper { public: - - static CscHitIdHelper* GetHelper(); - std::string GetStationName(const int& hid); - void SetStationName(std::string name); - int GetPhiSector(const int& hid); - int GetZSector(const int& hid); - int GetChamberLayer(const int& hid); - int GetWireLayer (const int& hid); - - int BuildCscHitId (const std::string, const int, const int, const int, - const int); + + static CscHitIdHelper* GetHelper(); + std::string GetStationName(const int& hid) const; + void SetStationName(std::string name, int& hid) const; + int GetPhiSector(const int& hid) const; + int GetZSector(const int& hid) const; + int GetChamberLayer(const int& hid) const; + int GetWireLayer (const int& hid) const; + + int BuildCscHitId (const std::string, const int, const int, const int, + const int) const; private: - CscHitIdHelper(); - void Initialize(); - void InitializeStationName(); - static CscHitIdHelper* m_help; + CscHitIdHelper(); + void Initialize(); + void InitializeStationName(); + static CscHitIdHelper* m_help; }; diff --git a/MuonSpectrometer/MuonSimEvent/MuonSimEvent/MdtHitIdHelper.h b/MuonSpectrometer/MuonSimEvent/MuonSimEvent/MdtHitIdHelper.h index 1e9fab3dc5c658f63dbb1aab6830b3eaf5585d69..7c0fd21a1cd2ef23a6c4c1f7e289716fb5696c00 100644 --- a/MuonSpectrometer/MuonSimEvent/MuonSimEvent/MdtHitIdHelper.h +++ b/MuonSpectrometer/MuonSimEvent/MuonSimEvent/MdtHitIdHelper.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #ifndef MdtHitIdHelper_H @@ -8,28 +8,28 @@ #include <string> //base class -#include "HitManagement/HitIdHelper.h" +#include "HitManagement/HitIdHelper.h" class MdtHitIdHelper: public HitIdHelper { public: - - static MdtHitIdHelper* GetHelper(); - std::string GetStationName(const int& hid); - void SetStationName(std::string name); - int GetPhiSector(const int& hid); - int GetZSector(const int& hid); - int GetMultiLayer(const int& hid); - int GetLayer(const int& hid); - int GetTube(const int& hid); - - int BuildMdtHitId (const std::string, const int, const int, const int, - const int, const int); + + static MdtHitIdHelper* GetHelper(); + std::string GetStationName(const int& hid) const; + void SetStationName(std::string name, int& hid) const; + int GetPhiSector(const int& hid) const; + int GetZSector(const int& hid) const; + int GetMultiLayer(const int& hid) const; + int GetLayer(const int& hid) const; + int GetTube(const int& hid) const; + + int BuildMdtHitId (const std::string, const int, const int, const int, + const int, const int) const; private: - MdtHitIdHelper(); - void Initialize(); - void InitializeStationName(); - static MdtHitIdHelper* m_help; + MdtHitIdHelper(); + void Initialize(); + void InitializeStationName(); + static MdtHitIdHelper* m_help; }; diff --git a/MuonSpectrometer/MuonSimEvent/MuonSimEvent/MicromegasHitIdHelper.h b/MuonSpectrometer/MuonSimEvent/MuonSimEvent/MicromegasHitIdHelper.h index c6f6e189a9247b2450770cdd8967f2c63a1ff6b0..d1fad1d8d258cfa7cafa746fa4b0d7c7222e60d9 100644 --- a/MuonSpectrometer/MuonSimEvent/MuonSimEvent/MicromegasHitIdHelper.h +++ b/MuonSpectrometer/MuonSimEvent/MuonSimEvent/MicromegasHitIdHelper.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #ifndef MicromegasHitIdHelper_H @@ -8,28 +8,28 @@ #include <string> //base class -#include "HitManagement/HitIdHelper.h" +#include "HitManagement/HitIdHelper.h" class MicromegasHitIdHelper: public HitIdHelper { public: - - static MicromegasHitIdHelper* GetHelper(); - std::string GetStationName(const int& hid); - void SetStationName(std::string name); - int GetPhiSector(const int& hid); - int GetZSector(const int& hid); - int GetMultiLayer(const int& hid); - int GetLayer(const int& hid); - int GetSide(const int& hid); - - int BuildMicromegasHitId (const std::string, const int, const int, const int, - const int, const int); + + static MicromegasHitIdHelper* GetHelper(); + std::string GetStationName(const int& hid) const; + void SetStationName(std::string name, int& hid) const; + int GetPhiSector(const int& hid) const; + int GetZSector(const int& hid) const; + int GetMultiLayer(const int& hid) const; + int GetLayer(const int& hid) const; + int GetSide(const int& hid) const; + + int BuildMicromegasHitId (const std::string, const int, const int, const int, + const int, const int) const; private: - MicromegasHitIdHelper(); - void Initialize(); - void InitializeStationName(); - static MicromegasHitIdHelper* m_help; + MicromegasHitIdHelper(); + void Initialize(); + void InitializeStationName(); + static MicromegasHitIdHelper* m_help; }; diff --git a/MuonSpectrometer/MuonSimEvent/MuonSimEvent/RpcHitIdHelper.h b/MuonSpectrometer/MuonSimEvent/MuonSimEvent/RpcHitIdHelper.h index 28bb37ebab7d46f9dcc94daca56692c4ea68d7c1..eed0481ea59396ec5eb15ebd20e3036ea63e8d7e 100644 --- a/MuonSpectrometer/MuonSimEvent/MuonSimEvent/RpcHitIdHelper.h +++ b/MuonSpectrometer/MuonSimEvent/MuonSimEvent/RpcHitIdHelper.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #ifndef RpcHitIdHelper_H @@ -8,30 +8,30 @@ #include <string> //base class -#include "HitManagement/HitIdHelper.h" +#include "HitManagement/HitIdHelper.h" class RpcHitIdHelper: public HitIdHelper { public: - - static RpcHitIdHelper* GetHelper(); - std::string GetStationName(const int& hid); - void SetStationName(std::string name); - int GetPhiSector(const int& hid); - int GetZSector(const int& hid); - int GetDoubletR(const int& hid); - int GetGasGapLayer(const int& hid); - int GetDoubletPhi(const int& hid); - int GetDoubletZ(const int& hid); - int GetMeasuresPhi(const int& hid); - - int BuildRpcHitId (const std::string, const int, const int, const int, - const int, const int, const int, const int); - + + static RpcHitIdHelper* GetHelper(); + std::string GetStationName(const int& hid) const; + void SetStationName(std::string name, int& hid) const; + int GetPhiSector(const int& hid) const; + int GetZSector(const int& hid) const; + int GetDoubletR(const int& hid) const; + int GetGasGapLayer(const int& hid) const; + int GetDoubletPhi(const int& hid) const; + int GetDoubletZ(const int& hid) const; + int GetMeasuresPhi(const int& hid) const; + + int BuildRpcHitId (const std::string, const int, const int, const int, + const int, const int, const int, const int) const; + private: - RpcHitIdHelper(); - void Initialize(); - void InitializeStationName(); - static RpcHitIdHelper* m_help; + RpcHitIdHelper(); + void Initialize(); + void InitializeStationName(); + static RpcHitIdHelper* m_help; }; diff --git a/MuonSpectrometer/MuonSimEvent/MuonSimEvent/TgcHitIdHelper.h b/MuonSpectrometer/MuonSimEvent/MuonSimEvent/TgcHitIdHelper.h index bce0137d6cbd98ffec4e4f9863d6a43a10184919..71fa59444d6562d27732bc74c43e639658327fc3 100644 --- a/MuonSpectrometer/MuonSimEvent/MuonSimEvent/TgcHitIdHelper.h +++ b/MuonSpectrometer/MuonSimEvent/MuonSimEvent/TgcHitIdHelper.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #ifndef TgcHitIdHelper_H @@ -8,25 +8,25 @@ #include <string> //base class -#include "HitManagement/HitIdHelper.h" +#include "HitManagement/HitIdHelper.h" class TgcHitIdHelper: public HitIdHelper { public: - - static TgcHitIdHelper* GetHelper(); - std::string GetStationName(const int& hid); - void SetStationName(std::string name); - int GetStationPhi(const int& hid); - int GetStationEta(const int& hid); - int GetGasGap(const int& hid); - - int BuildTgcHitId (const std::string, const int, const int, const int); + + static TgcHitIdHelper* GetHelper(); + std::string GetStationName(const int& hid) const; + void SetStationName(std::string name, int& hid) const; + int GetStationPhi(const int& hid) const; + int GetStationEta(const int& hid) const; + int GetGasGap(const int& hid) const; + + int BuildTgcHitId (const std::string, const int, const int, const int) const; private: - TgcHitIdHelper(); - void Initialize(); - void InitializeStationName(); - static TgcHitIdHelper* m_help; + TgcHitIdHelper(); + void Initialize(); + void InitializeStationName(); + static TgcHitIdHelper* m_help; }; diff --git a/MuonSpectrometer/MuonSimEvent/MuonSimEvent/sTgcHitIdHelper.h b/MuonSpectrometer/MuonSimEvent/MuonSimEvent/sTgcHitIdHelper.h index 7a904ba678bd50bce7459b850ef8c2910a62c2f1..81159654ab21d548cb6949102e7569080c94a955 100644 --- a/MuonSpectrometer/MuonSimEvent/MuonSimEvent/sTgcHitIdHelper.h +++ b/MuonSpectrometer/MuonSimEvent/MuonSimEvent/sTgcHitIdHelper.h @@ -8,28 +8,28 @@ #include <string> //base class -#include "HitManagement/HitIdHelper.h" +#include "HitManagement/HitIdHelper.h" class sTgcHitIdHelper: public HitIdHelper { public: - - static sTgcHitIdHelper* GetHelper(); - std::string GetStationName(const int& hid); - void SetStationName(std::string name); - int GetPhiSector(const int& hid); - int GetZSector(const int& hid); - int GetMultiLayer(const int& hid); - int GetLayer(const int& hid); - int GetSide(const int& hid); - - int BuildsTgcHitId (const std::string, const int, const int, const int, - const int, const int); + + static sTgcHitIdHelper* GetHelper(); + std::string GetStationName(const int& hid) const; + void SetStationName(std::string name, int& hid) const; + int GetPhiSector(const int& hid) const; + int GetZSector(const int& hid) const; + int GetMultiLayer(const int& hid) const; + int GetLayer(const int& hid) const; + int GetSide(const int& hid) const; + + int BuildsTgcHitId (const std::string, const int, const int, const int, + const int, const int) const; private: - sTgcHitIdHelper(); - void Initialize(); - void InitializeStationName(); - static sTgcHitIdHelper* m_help; + sTgcHitIdHelper(); + void Initialize(); + void InitializeStationName(); + static sTgcHitIdHelper* m_help; }; diff --git a/MuonSpectrometer/MuonSimEvent/src/CscHitIdHelper.cxx b/MuonSpectrometer/MuonSimEvent/src/CscHitIdHelper.cxx index d4849f9ab304b7e1cb56b0eccd426f96900fc9ea..7a46fe9b9145da30a93ebf860ff4e7bc08a1e616 100644 --- a/MuonSpectrometer/MuonSimEvent/src/CscHitIdHelper.cxx +++ b/MuonSpectrometer/MuonSimEvent/src/CscHitIdHelper.cxx @@ -1,97 +1,97 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #include "MuonSimEvent/CscHitIdHelper.h" -CscHitIdHelper* CscHitIdHelper::m_help = 0; +CscHitIdHelper* CscHitIdHelper::m_help = nullptr; //private constructor -CscHitIdHelper::CscHitIdHelper() : HitIdHelper(){ - InitializeStationName(); - Initialize(); +CscHitIdHelper::CscHitIdHelper() : HitIdHelper() +{ + InitializeStationName(); + Initialize(); } -CscHitIdHelper* CscHitIdHelper::GetHelper(){ - if (m_help==0) m_help = new CscHitIdHelper(); - return m_help; +CscHitIdHelper* CscHitIdHelper::GetHelper() +{ + if (!m_help) m_help = new CscHitIdHelper(); + return m_help; } static char v1[] = {'B','E','T','C'}; static char v2[] = {'I','M','O','E','1','2','3','4','S'}; static char v3[] = {'S','L','E','R','F','G'}; - -void CscHitIdHelper::Initialize(){ - - InitializeField("PhiSector",1,8); - InitializeField("ZSector",-1,1); - InitializeField("ChamberLayer",1,2); - InitializeField("WireLayer",1,4); - + +void CscHitIdHelper::Initialize() +{ + InitializeField("PhiSector",1,8); + InitializeField("ZSector",-1,1); + InitializeField("ChamberLayer",1,2); + InitializeField("WireLayer",1,4); + } void CscHitIdHelper::InitializeStationName() { - InitializeField("Station[1]",0,sizeof(v1)); - InitializeField("Station[2]",0,sizeof(v2)); - InitializeField("Station[3]",0,sizeof(v3)); + InitializeField("Station[1]",0,sizeof(v1)); + InitializeField("Station[2]",0,sizeof(v2)); + InitializeField("Station[3]",0,sizeof(v3)); } -void CscHitIdHelper::SetStationName(std::string name) +void CscHitIdHelper::SetStationName(std::string name, int &hid) const { - for (unsigned int i=0;i<sizeof(v1);i++) - if (v1[i]==name[0]) SetFieldValue("Station[1]",i); - for (unsigned int i=0;i<sizeof(v2);i++) - if (v2[i]==name[1]) SetFieldValue("Station[2]",i); - for (unsigned int i=0;i<sizeof(v3);i++) + for (unsigned int i=0;i<sizeof(v1);i++) + if (v1[i]==name[0]) SetFieldValue("Station[1]",i,hid); + for (unsigned int i=0;i<sizeof(v2);i++) + if (v2[i]==name[1]) SetFieldValue("Station[2]",i,hid); + for (unsigned int i=0;i<sizeof(v3);i++) - if (v3[i]==name[2]) SetFieldValue("Station[3]",i); + if (v3[i]==name[2]) SetFieldValue("Station[3]",i,hid); } -std::string CscHitIdHelper::GetStationName(const int& hid) +std::string CscHitIdHelper::GetStationName(const int& hid) const { - this->SetID(hid); - char v[4]; - v[0]=v1[this->GetFieldValue("Station[1]")]; - v[1]=v2[this->GetFieldValue("Station[2]")]; - v[2]=v3[this->GetFieldValue("Station[3]")]; - v[3]='\0'; - std::string temp=v; - return temp; + char v[4]; + v[0]=v1[this->GetFieldValue("Station[1]",hid)]; + v[1]=v2[this->GetFieldValue("Station[2]",hid)]; + v[2]=v3[this->GetFieldValue("Station[3]",hid)]; + v[3]='\0'; + std::string temp=v; + return temp; } -int CscHitIdHelper::GetPhiSector(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("PhiSector"); +int CscHitIdHelper::GetPhiSector(const int& hid) const +{ + return this->GetFieldValue("PhiSector",hid); } -int CscHitIdHelper::GetZSector(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("ZSector"); +int CscHitIdHelper::GetZSector(const int& hid) const +{ + return this->GetFieldValue("ZSector",hid); } //----CSC -int CscHitIdHelper::GetChamberLayer(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("ChamberLayer"); +int CscHitIdHelper::GetChamberLayer(const int& hid) const +{ + return this->GetFieldValue("ChamberLayer",hid); } -int CscHitIdHelper::GetWireLayer(const int& hid) { - this->SetID(hid); - return this->GetFieldValue("WireLayer"); +int CscHitIdHelper::GetWireLayer(const int& hid) const +{ + return this->GetFieldValue("WireLayer",hid); } //packing method int CscHitIdHelper::BuildCscHitId(const std::string statName, const int phiSect, - const int zSect, const int chamberLayer, int wireLayer){ - - this->SetID(0); - this->SetStationName(statName); - this->SetFieldValue("PhiSector", phiSect); - this->SetFieldValue("ZSector", zSect); - this->SetFieldValue("ChamberLayer", chamberLayer); - this->SetFieldValue("WireLayer", wireLayer); - return this->GetID(); + const int zSect, const int chamberLayer, int wireLayer) const +{ + int theID(0); + this->SetStationName(statName, theID); + this->SetFieldValue("PhiSector", phiSect, theID); + this->SetFieldValue("ZSector", zSect, theID); + this->SetFieldValue("ChamberLayer", chamberLayer, theID); + this->SetFieldValue("WireLayer", wireLayer, theID); + return theID; } - diff --git a/MuonSpectrometer/MuonSimEvent/src/MdtHitIdHelper.cxx b/MuonSpectrometer/MuonSimEvent/src/MdtHitIdHelper.cxx index 34f61f7c875fbde30de9787a5ca7ca85c9bdd447..23e7de511d5a5c90d2cd22dcddc740d87490aa96 100644 --- a/MuonSpectrometer/MuonSimEvent/src/MdtHitIdHelper.cxx +++ b/MuonSpectrometer/MuonSimEvent/src/MdtHitIdHelper.cxx @@ -1,101 +1,104 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #include "MuonSimEvent/MdtHitIdHelper.h" #include <iostream> -MdtHitIdHelper* MdtHitIdHelper::m_help = 0; +MdtHitIdHelper* MdtHitIdHelper::m_help = nullptr; //private constructor -MdtHitIdHelper::MdtHitIdHelper() : HitIdHelper(){ - InitializeStationName(); - Initialize(); +MdtHitIdHelper::MdtHitIdHelper() : HitIdHelper() +{ + InitializeStationName(); + Initialize(); } -MdtHitIdHelper* MdtHitIdHelper::GetHelper(){ - if (m_help==0) m_help = new MdtHitIdHelper(); - return m_help; +MdtHitIdHelper* MdtHitIdHelper::GetHelper() +{ + if (!m_help) m_help = new MdtHitIdHelper(); + return m_help; } static char v1[] = {'B','E','T','C'}; static char v2[] = {'I','M','O','E','1','2','3','4','S'}; static char v3[] = {'S','L','E','R','F','G','M'}; - -void MdtHitIdHelper::Initialize(){ - - InitializeField("PhiSector",1,8); - InitializeField("ZSector",-8,8); - InitializeField("MultiLayer",1,2); - InitializeField("Layer",1,4); - InitializeField("Tube",1,78); - + +void MdtHitIdHelper::Initialize() +{ + InitializeField("PhiSector",1,8); + InitializeField("ZSector",-8,8); + InitializeField("MultiLayer",1,2); + InitializeField("Layer",1,4); + InitializeField("Tube",1,78); } + void MdtHitIdHelper::InitializeStationName() { - InitializeField("Station[1]",0,sizeof(v1)); - InitializeField("Station[2]",0,sizeof(v2)); - InitializeField("Station[3]",0,sizeof(v3)); + InitializeField("Station[1]",0,sizeof(v1)); + InitializeField("Station[2]",0,sizeof(v2)); + InitializeField("Station[3]",0,sizeof(v3)); } -void MdtHitIdHelper::SetStationName(std::string name) -{ - for (unsigned int i=0;i<sizeof(v1);i++) - if (v1[i]==name[0]) SetFieldValue("Station[1]",i); - for (unsigned int i=0;i<sizeof(v2);i++) - if (v2[i]==name[1]) SetFieldValue("Station[2]",i); - for (unsigned int i=0;i<sizeof(v3);i++) - if (v3[i]==name[2]) SetFieldValue("Station[3]",i); - - + +void MdtHitIdHelper::SetStationName(std::string name, int& hid) const +{ + for (unsigned int i=0;i<sizeof(v1);i++) + if (v1[i]==name[0]) SetFieldValue("Station[1]",i,hid); + for (unsigned int i=0;i<sizeof(v2);i++) + if (v2[i]==name[1]) SetFieldValue("Station[2]",i,hid); + for (unsigned int i=0;i<sizeof(v3);i++) + if (v3[i]==name[2]) SetFieldValue("Station[3]",i,hid); + + } -std::string MdtHitIdHelper::GetStationName(const int& hid) +std::string MdtHitIdHelper::GetStationName(const int& hid) const { - this->SetID(hid); - char v[4]; - v[0]=v1[this->GetFieldValue("Station[1]")]; - v[1]=v2[this->GetFieldValue("Station[2]")]; - v[2]=v3[this->GetFieldValue("Station[3]")]; - v[3]='\0'; - std::string temp=v; - return temp; + char v[4]; + v[0]=v1[this->GetFieldValue("Station[1]",hid)]; + v[1]=v2[this->GetFieldValue("Station[2]",hid)]; + v[2]=v3[this->GetFieldValue("Station[3]",hid)]; + v[3]='\0'; + std::string temp=v; + return temp; } -int MdtHitIdHelper::GetPhiSector(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("PhiSector"); +int MdtHitIdHelper::GetPhiSector(const int& hid) const +{ + return this->GetFieldValue("PhiSector",hid); } -int MdtHitIdHelper::GetZSector(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("ZSector"); +int MdtHitIdHelper::GetZSector(const int& hid) const +{ + return this->GetFieldValue("ZSector",hid); } //----MDT -int MdtHitIdHelper::GetMultiLayer(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("MultiLayer"); +int MdtHitIdHelper::GetMultiLayer(const int& hid) const +{ + return this->GetFieldValue("MultiLayer",hid); } -int MdtHitIdHelper::GetLayer(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("Layer"); + +int MdtHitIdHelper::GetLayer(const int& hid) const +{ + return this->GetFieldValue("Layer",hid); } -int MdtHitIdHelper::GetTube(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("Tube"); + +int MdtHitIdHelper::GetTube(const int& hid) const +{ + return this->GetFieldValue("Tube",hid); } //packing method int MdtHitIdHelper::BuildMdtHitId(const std::string statName, const int phiSect, - const int zSect, const int multiLayer, const int layer, const int tube){ - - this->SetID(0); - this->SetStationName(statName); - this->SetFieldValue("PhiSector", phiSect); - this->SetFieldValue("ZSector", zSect); - this->SetFieldValue("MultiLayer", multiLayer); - this->SetFieldValue("Layer", layer); - this->SetFieldValue("Tube", tube); - return this->GetID(); + const int zSect, const int multiLayer, const int layer, const int tube) const +{ + int theID(0); + this->SetStationName(statName, theID); + this->SetFieldValue("PhiSector", phiSect, theID); + this->SetFieldValue("ZSector", zSect, theID); + this->SetFieldValue("MultiLayer", multiLayer, theID); + this->SetFieldValue("Layer", layer, theID); + this->SetFieldValue("Tube", tube, theID); + return theID; } - diff --git a/MuonSpectrometer/MuonSimEvent/src/MicromegasHitIdHelper.cxx b/MuonSpectrometer/MuonSimEvent/src/MicromegasHitIdHelper.cxx index 8db2ef54c27884f32da963368e79136c0f84c4c2..0a5a95e5f41f6c778822d27956eb902f24cc2e0b 100644 --- a/MuonSpectrometer/MuonSimEvent/src/MicromegasHitIdHelper.cxx +++ b/MuonSpectrometer/MuonSimEvent/src/MicromegasHitIdHelper.cxx @@ -1,21 +1,23 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #include "MuonSimEvent/MicromegasHitIdHelper.h" #include <iostream> -MicromegasHitIdHelper* MicromegasHitIdHelper::m_help = 0; +MicromegasHitIdHelper* MicromegasHitIdHelper::m_help = nullptr; //private constructor -MicromegasHitIdHelper::MicromegasHitIdHelper() : HitIdHelper(){ - InitializeStationName(); - Initialize(); +MicromegasHitIdHelper::MicromegasHitIdHelper() : HitIdHelper() +{ + InitializeStationName(); + Initialize(); } -MicromegasHitIdHelper* MicromegasHitIdHelper::GetHelper(){ - if (m_help==0) m_help = new MicromegasHitIdHelper(); - return m_help; +MicromegasHitIdHelper* MicromegasHitIdHelper::GetHelper() +{ + if (!m_help) m_help = new MicromegasHitIdHelper(); + return m_help; } static char v1[] = {'M'}; @@ -23,83 +25,86 @@ static char v2[] = {'0','1','2','3','4'}; static char v3[] = {'S','L'}; static char v4[] = {'1','2'}; - -void MicromegasHitIdHelper::Initialize(){ - - InitializeField("PhiSector",1,16); - InitializeField("ZSector",0,4); - InitializeField("MultiLayer",1,2); - InitializeField("Layer",1,4); - InitializeField("Side",-1,1); - + +void MicromegasHitIdHelper::Initialize() +{ + InitializeField("PhiSector",1,16); + InitializeField("ZSector",0,4); + InitializeField("MultiLayer",1,2); + InitializeField("Layer",1,4); + InitializeField("Side",-1,1); + } + void MicromegasHitIdHelper::InitializeStationName() { - InitializeField("Station[1]",0,sizeof(v1)); - InitializeField("Station[2]",0,sizeof(v2)); - InitializeField("Station[3]",0,sizeof(v3)); - InitializeField("Station[4]",0,sizeof(v4)); + InitializeField("Station[1]",0,sizeof(v1)); + InitializeField("Station[2]",0,sizeof(v2)); + InitializeField("Station[3]",0,sizeof(v3)); + InitializeField("Station[4]",0,sizeof(v4)); } -void MicromegasHitIdHelper::SetStationName(std::string name) -{ - for (unsigned int i=0;i<sizeof(v1);i++) - if (v1[i]==name[0]) SetFieldValue("Station[1]",i); - for (unsigned int i=0;i<sizeof(v2);i++) - if (v2[i]==name[1]) SetFieldValue("Station[2]",i); - for (unsigned int i=0;i<sizeof(v3);i++) - if (v3[i]==name[2]) SetFieldValue("Station[3]",i); - for (unsigned int i=0;i<sizeof(v4);i++) - if (v4[i]==name[3]) SetFieldValue("Station[4]",i); + +void MicromegasHitIdHelper::SetStationName(std::string name, int& hid) const +{ + for (unsigned int i=0;i<sizeof(v1);i++) + if (v1[i]==name[0]) SetFieldValue("Station[1]",i,hid); + for (unsigned int i=0;i<sizeof(v2);i++) + if (v2[i]==name[1]) SetFieldValue("Station[2]",i,hid); + for (unsigned int i=0;i<sizeof(v3);i++) + if (v3[i]==name[2]) SetFieldValue("Station[3]",i,hid); + for (unsigned int i=0;i<sizeof(v4);i++) + if (v4[i]==name[3]) SetFieldValue("Station[4]",i,hid); } -std::string MicromegasHitIdHelper::GetStationName(const int& hid) + +std::string MicromegasHitIdHelper::GetStationName(const int& hid) const { - this->SetID(hid); - char v[5]; - v[0]=v1[this->GetFieldValue("Station[1]")]; - v[1]=v2[this->GetFieldValue("Station[2]")]; - v[2]=v3[this->GetFieldValue("Station[3]")]; - v[3]=v4[this->GetFieldValue("Station[4]")]; - v[4]='\0'; - std::string temp=v; - return temp; + char v[5]; + v[0]=v1[this->GetFieldValue("Station[1]",hid)]; + v[1]=v2[this->GetFieldValue("Station[2]",hid)]; + v[2]=v3[this->GetFieldValue("Station[3]",hid)]; + v[3]=v4[this->GetFieldValue("Station[4]",hid)]; + v[4]='\0'; + std::string temp=v; + return temp; } -int MicromegasHitIdHelper::GetPhiSector(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("PhiSector"); +int MicromegasHitIdHelper::GetPhiSector(const int& hid) const +{ + return this->GetFieldValue("PhiSector",hid); } -int MicromegasHitIdHelper::GetZSector(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("ZSector"); +int MicromegasHitIdHelper::GetZSector(const int& hid) const +{ + return this->GetFieldValue("ZSector",hid); } //----Micromegas -int MicromegasHitIdHelper::GetMultiLayer(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("MultiLayer"); +int MicromegasHitIdHelper::GetMultiLayer(const int& hid) const +{ + return this->GetFieldValue("MultiLayer",hid); } -int MicromegasHitIdHelper::GetLayer(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("Layer"); + +int MicromegasHitIdHelper::GetLayer(const int& hid) const +{ + return this->GetFieldValue("Layer",hid); } -int MicromegasHitIdHelper::GetSide(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("Side"); + +int MicromegasHitIdHelper::GetSide(const int& hid) const +{ + return this->GetFieldValue("Side",hid); } //packing method int MicromegasHitIdHelper::BuildMicromegasHitId(const std::string statName, const int phiSect, - const int zSect, const int multiLayer, const int layer, const int side){ - - this->SetID(0); - this->SetStationName(statName); - this->SetFieldValue("PhiSector", phiSect); - this->SetFieldValue("ZSector", zSect); - this->SetFieldValue("MultiLayer", multiLayer); - this->SetFieldValue("Layer", layer); - this->SetFieldValue("Side", side); - return this->GetID(); + const int zSect, const int multiLayer, const int layer, const int side) const +{ + int theID(0); + this->SetStationName(statName, theID); + this->SetFieldValue("PhiSector", phiSect, theID); + this->SetFieldValue("ZSector", zSect, theID); + this->SetFieldValue("MultiLayer", multiLayer, theID); + this->SetFieldValue("Layer", layer, theID); + this->SetFieldValue("Side", side, theID); + return theID; } - diff --git a/MuonSpectrometer/MuonSimEvent/src/RpcHitIdHelper.cxx b/MuonSpectrometer/MuonSimEvent/src/RpcHitIdHelper.cxx index 3cc8e43aedfc9c88b9c542898aebf08bb3ae4064..f6762a782ea1673dfda29610067c33d9a8ba20ad 100644 --- a/MuonSpectrometer/MuonSimEvent/src/RpcHitIdHelper.cxx +++ b/MuonSpectrometer/MuonSimEvent/src/RpcHitIdHelper.cxx @@ -1,111 +1,115 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #include "MuonSimEvent/RpcHitIdHelper.h" -RpcHitIdHelper* RpcHitIdHelper::m_help = 0; +RpcHitIdHelper* RpcHitIdHelper::m_help = nullptr; //private constructor -RpcHitIdHelper::RpcHitIdHelper() : HitIdHelper(){ - InitializeStationName(); - Initialize(); +RpcHitIdHelper::RpcHitIdHelper() : HitIdHelper() +{ + InitializeStationName(); + Initialize(); } -RpcHitIdHelper* RpcHitIdHelper::GetHelper(){ - if (m_help==0) m_help = new RpcHitIdHelper(); - return m_help; +RpcHitIdHelper* RpcHitIdHelper::GetHelper() +{ + if (!m_help) m_help = new RpcHitIdHelper(); + return m_help; } static char v1[] = {'B','E','T','C'}; static char v2[] = {'I','M','O','E','1','2','3','4','S'}; static char v3[] = {'S','L','E','R','F','G'}; - -void RpcHitIdHelper::Initialize(){ - - InitializeField("PhiSector",1,8); - InitializeField("ZSector",-8,8); - InitializeField("DoubletR",1,2); - InitializeField("GasGapLayer",1,2); - InitializeField("DoubletPhi",1,2); - InitializeField("DoubletZ",1,3); - InitializeField("MeasuresPhi",0,1); + +void RpcHitIdHelper::Initialize() +{ + InitializeField("PhiSector",1,8); + InitializeField("ZSector",-8,8); + InitializeField("DoubletR",1,2); + InitializeField("GasGapLayer",1,2); + InitializeField("DoubletPhi",1,2); + InitializeField("DoubletZ",1,3); + InitializeField("MeasuresPhi",0,1); } + void RpcHitIdHelper::InitializeStationName() { - InitializeField("Station[1]",0,sizeof(v1)); - InitializeField("Station[2]",0,sizeof(v2)); - InitializeField("Station[3]",0,sizeof(v3)); + InitializeField("Station[1]",0,sizeof(v1)); + InitializeField("Station[2]",0,sizeof(v2)); + InitializeField("Station[3]",0,sizeof(v3)); } -void RpcHitIdHelper::SetStationName(std::string name) -{ - for (unsigned int i=0;i<sizeof(v1);i++) - if (v1[i]==name[0]) SetFieldValue("Station[1]",i); - for (unsigned int i=0;i<sizeof(v2);i++) - if (v2[i]==name[1]) SetFieldValue("Station[2]",i); - for (unsigned int i=0;i<sizeof(v3);i++) - if (v3[i]==name[2]) SetFieldValue("Station[3]",i); +void RpcHitIdHelper::SetStationName(std::string name, int& hid) const +{ + for (unsigned int i=0;i<sizeof(v1);i++) + if (v1[i]==name[0]) SetFieldValue("Station[1]",i,hid); + for (unsigned int i=0;i<sizeof(v2);i++) + if (v2[i]==name[1]) SetFieldValue("Station[2]",i,hid); + for (unsigned int i=0;i<sizeof(v3);i++) + if (v3[i]==name[2]) SetFieldValue("Station[3]",i,hid); } -std::string RpcHitIdHelper::GetStationName(const int& hid) + +std::string RpcHitIdHelper::GetStationName(const int& hid) const { - this->SetID(hid); - char v[4]; - v[0]=v1[this->GetFieldValue("Station[1]")]; - v[1]=v2[this->GetFieldValue("Station[2]")]; - v[2]=v3[this->GetFieldValue("Station[3]")]; - v[3]='\0'; - std::string temp=v; - return temp; + char v[4]; + v[0]=v1[this->GetFieldValue("Station[1]", hid)]; + v[1]=v2[this->GetFieldValue("Station[2]", hid)]; + v[2]=v3[this->GetFieldValue("Station[3]", hid)]; + v[3]='\0'; + std::string temp=v; + return temp; } -int RpcHitIdHelper::GetPhiSector(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("PhiSector"); +int RpcHitIdHelper::GetPhiSector(const int& hid) const +{ + return this->GetFieldValue("PhiSector", hid); } -int RpcHitIdHelper::GetZSector(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("ZSector"); +int RpcHitIdHelper::GetZSector(const int& hid) const +{ + return this->GetFieldValue("ZSector", hid); } //----RPC -int RpcHitIdHelper::GetDoubletR(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("DoubletR"); +int RpcHitIdHelper::GetDoubletR(const int& hid) const +{ + return this->GetFieldValue("DoubletR", hid); } -int RpcHitIdHelper::GetGasGapLayer(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("GasGapLayer"); +int RpcHitIdHelper::GetGasGapLayer(const int& hid) const +{ + return this->GetFieldValue("GasGapLayer", hid); } -int RpcHitIdHelper::GetDoubletPhi(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("DoubletPhi"); +int RpcHitIdHelper::GetDoubletPhi(const int& hid) const +{ + return this->GetFieldValue("DoubletPhi", hid); } -int RpcHitIdHelper::GetDoubletZ(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("DoubletZ"); +int RpcHitIdHelper::GetDoubletZ(const int& hid) const +{ + return this->GetFieldValue("DoubletZ", hid); } -int RpcHitIdHelper::GetMeasuresPhi(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("MeasuresPhi"); +int RpcHitIdHelper::GetMeasuresPhi(const int& hid) const +{ + return this->GetFieldValue("MeasuresPhi", hid); } //packing method int RpcHitIdHelper::BuildRpcHitId(const std::string statName, const int phiSect, - const int zSect, const int doubZ, const int doubR, const int gasGap, - const int doubPhi, const int measPhi){ - - this->SetID(0); - this->SetStationName(statName); - this->SetFieldValue("PhiSector", phiSect); - this->SetFieldValue("ZSector", zSect); - this->SetFieldValue("DoubletZ", doubZ); - this->SetFieldValue("DoubletR", doubR); - this->SetFieldValue("GasGapLayer", gasGap); - this->SetFieldValue("DoubletPhi", doubPhi); - this->SetFieldValue("MeasuresPhi", measPhi); - return this->GetID(); + const int zSect, const int doubZ, const int doubR, const int gasGap, + const int doubPhi, const int measPhi) const +{ + + int theID(0); + this->SetStationName(statName, theID); + this->SetFieldValue("PhiSector", phiSect, theID); + this->SetFieldValue("ZSector", zSect, theID); + this->SetFieldValue("DoubletZ", doubZ, theID); + this->SetFieldValue("DoubletR", doubR, theID); + this->SetFieldValue("GasGapLayer", gasGap, theID); + this->SetFieldValue("DoubletPhi", doubPhi, theID); + this->SetFieldValue("MeasuresPhi", measPhi, theID); + return theID; } diff --git a/MuonSpectrometer/MuonSimEvent/src/TgcHitIdHelper.cxx b/MuonSpectrometer/MuonSimEvent/src/TgcHitIdHelper.cxx index 4d84ebe62e18d379ac44b9d0397109039b53e46b..81122f16a42321c874d7f56de3ae5198516d67e8 100644 --- a/MuonSpectrometer/MuonSimEvent/src/TgcHitIdHelper.cxx +++ b/MuonSpectrometer/MuonSimEvent/src/TgcHitIdHelper.cxx @@ -1,87 +1,86 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #include "MuonSimEvent/TgcHitIdHelper.h" -TgcHitIdHelper* TgcHitIdHelper::m_help = 0; +TgcHitIdHelper* TgcHitIdHelper::m_help = nullptr; //private constructor -TgcHitIdHelper::TgcHitIdHelper() : HitIdHelper(){ - InitializeStationName(); - Initialize(); +TgcHitIdHelper::TgcHitIdHelper() : HitIdHelper() +{ + InitializeStationName(); + Initialize(); } -TgcHitIdHelper* TgcHitIdHelper::GetHelper(){ - if (m_help==0) m_help = new TgcHitIdHelper(); - return m_help; +TgcHitIdHelper* TgcHitIdHelper::GetHelper() +{ + if (!m_help) m_help = new TgcHitIdHelper(); + return m_help; } static char v1[] = {'B','E','T','C'}; static char v2[] = {'I','M','O','E','1','2','3','4','S'}; static char v3[] = {'S','L','E','R','F','G'}; - -void TgcHitIdHelper::Initialize(){ - - InitializeField("StationPhi",1,48); - InitializeField("StationEta",-5,5); - InitializeField("GasGap",1,3); - + +void TgcHitIdHelper::Initialize() +{ + InitializeField("StationPhi",1,48); + InitializeField("StationEta",-5,5); + InitializeField("GasGap",1,3); } + void TgcHitIdHelper::InitializeStationName() { - InitializeField("Station[1]",0,sizeof(v1)); - InitializeField("Station[2]",0,sizeof(v2)); - InitializeField("Station[3]",0,sizeof(v3)); + InitializeField("Station[1]",0,sizeof(v1)); + InitializeField("Station[2]",0,sizeof(v2)); + InitializeField("Station[3]",0,sizeof(v3)); } -void TgcHitIdHelper::SetStationName(std::string name) -{ - for (unsigned int i=0;i<sizeof(v1);i++) - if (v1[i]==name[0]) SetFieldValue("Station[1]",i); - for (unsigned int i=0;i<sizeof(v2);i++) - if (v2[i]==name[1]) SetFieldValue("Station[2]",i); - for (unsigned int i=0;i<sizeof(v3);i++) - if (v3[i]==name[2]) SetFieldValue("Station[3]",i); +void TgcHitIdHelper::SetStationName(std::string name, int& hid) const +{ + for (unsigned int i=0;i<sizeof(v1);i++) + if (v1[i]==name[0]) SetFieldValue("Station[1]",i,hid); + for (unsigned int i=0;i<sizeof(v2);i++) + if (v2[i]==name[1]) SetFieldValue("Station[2]",i,hid); + for (unsigned int i=0;i<sizeof(v3);i++) + if (v3[i]==name[2]) SetFieldValue("Station[3]",i,hid); } -std::string TgcHitIdHelper::GetStationName(const int& hid) +std::string TgcHitIdHelper::GetStationName(const int& hid) const { - this->SetID(hid); - char v[4]; - v[0]=v1[this->GetFieldValue("Station[1]")]; - v[1]=v2[this->GetFieldValue("Station[2]")]; - v[2]=v3[this->GetFieldValue("Station[3]")]; - v[3]='\0'; - std::string temp=v; - return temp; + char v[4]; + v[0]=v1[this->GetFieldValue("Station[1]",hid)]; + v[1]=v2[this->GetFieldValue("Station[2]",hid)]; + v[2]=v3[this->GetFieldValue("Station[3]",hid)]; + v[3]='\0'; + std::string temp=v; + return temp; } -int TgcHitIdHelper::GetStationPhi(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("StationPhi"); +int TgcHitIdHelper::GetStationPhi(const int& hid) const +{ + return this->GetFieldValue("StationPhi",hid); } -int TgcHitIdHelper::GetStationEta(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("StationEta"); +int TgcHitIdHelper::GetStationEta(const int& hid) const +{ + return this->GetFieldValue("StationEta",hid); } -int TgcHitIdHelper::GetGasGap(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("GasGap"); +int TgcHitIdHelper::GetGasGap(const int& hid) const +{ + return this->GetFieldValue("GasGap",hid); } - //packing method int TgcHitIdHelper::BuildTgcHitId(const std::string statName, const int statPhi, - const int statEta, const int gasG){ - - this->SetID(0); - this->SetStationName(statName); - this->SetFieldValue("StationPhi", statPhi); - this->SetFieldValue("StationEta", statEta); - this->SetFieldValue("GasGap", gasG); - return this->GetID(); + const int statEta, const int gasG) const +{ + int theID(0); + this->SetStationName(statName, theID); + this->SetFieldValue("StationPhi", statPhi, theID); + this->SetFieldValue("StationEta", statEta, theID); + this->SetFieldValue("GasGap", gasG, theID); + return theID; } - diff --git a/MuonSpectrometer/MuonSimEvent/src/sTgcHitIdHelper.cxx b/MuonSpectrometer/MuonSimEvent/src/sTgcHitIdHelper.cxx index d214e8ec0a45605c9862527d180bed7d03c9d946..fa9995dfd692f727d551098c5f22c398df6a2da2 100644 --- a/MuonSpectrometer/MuonSimEvent/src/sTgcHitIdHelper.cxx +++ b/MuonSpectrometer/MuonSimEvent/src/sTgcHitIdHelper.cxx @@ -1,21 +1,21 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #include "MuonSimEvent/sTgcHitIdHelper.h" #include <iostream> -sTgcHitIdHelper* sTgcHitIdHelper::m_help = 0; +sTgcHitIdHelper* sTgcHitIdHelper::m_help = nullptr; //private constructor sTgcHitIdHelper::sTgcHitIdHelper() : HitIdHelper(){ - InitializeStationName(); - Initialize(); + InitializeStationName(); + Initialize(); } sTgcHitIdHelper* sTgcHitIdHelper::GetHelper(){ - if (m_help==0) m_help = new sTgcHitIdHelper(); - return m_help; + if (!m_help) m_help = new sTgcHitIdHelper(); + return m_help; } static char v1[] = {'T'}; @@ -23,83 +23,76 @@ static char v2[] = {'S','L'}; static char v3[] = {'0','1','2','3','4'}; static char v4[] = {'1','2'}; - + void sTgcHitIdHelper::Initialize(){ - - InitializeField("PhiSector",1,16); - InitializeField("ZSector",0,4); - InitializeField("MultiLayer",1,2); - InitializeField("Layer",1,4); - InitializeField("Side",-1,1); - + + InitializeField("PhiSector",1,16); + InitializeField("ZSector",0,4); + InitializeField("MultiLayer",1,2); + InitializeField("Layer",1,4); + InitializeField("Side",-1,1); + } void sTgcHitIdHelper::InitializeStationName() { - InitializeField("Station[1]",0,sizeof(v1)); - InitializeField("Station[2]",0,sizeof(v2)); - InitializeField("Station[3]",0,sizeof(v3)); - InitializeField("Station[4]",0,sizeof(v4)); + InitializeField("Station[1]",0,sizeof(v1)); + InitializeField("Station[2]",0,sizeof(v2)); + InitializeField("Station[3]",0,sizeof(v3)); + InitializeField("Station[4]",0,sizeof(v4)); } -void sTgcHitIdHelper::SetStationName(std::string name) -{ - for (unsigned int i=0;i<sizeof(v1);i++) - if (v1[i]==name[0]) SetFieldValue("Station[1]",i); - for (unsigned int i=0;i<sizeof(v2);i++) - if (v2[i]==name[1]) SetFieldValue("Station[2]",i); - for (unsigned int i=0;i<sizeof(v3);i++) - if (v3[i]==name[2]) SetFieldValue("Station[3]",i); - for (unsigned int i=0;i<sizeof(v4);i++) - if (v4[i]==name[3]) SetFieldValue("Station[4]",i); +void sTgcHitIdHelper::SetStationName(std::string name, int& hid) const +{ + for (unsigned int i=0;i<sizeof(v1);i++) + if (v1[i]==name[0]) SetFieldValue("Station[1]",i,hid); + for (unsigned int i=0;i<sizeof(v2);i++) + if (v2[i]==name[1]) SetFieldValue("Station[2]",i,hid); + for (unsigned int i=0;i<sizeof(v3);i++) + if (v3[i]==name[2]) SetFieldValue("Station[3]",i,hid); + for (unsigned int i=0;i<sizeof(v4);i++) + if (v4[i]==name[3]) SetFieldValue("Station[4]",i,hid); } -std::string sTgcHitIdHelper::GetStationName(const int& hid) +std::string sTgcHitIdHelper::GetStationName(const int& hid) const { - this->SetID(hid); - char v[5]; - v[0]=v1[this->GetFieldValue("Station[1]")]; - v[1]=v2[this->GetFieldValue("Station[2]")]; - v[2]=v3[this->GetFieldValue("Station[3]")]; - v[3]=v4[this->GetFieldValue("Station[4]")]; - v[4]='\0'; - std::string temp=v; - return temp; + char v[5]; + v[0]=v1[this->GetFieldValue("Station[1]", hid)]; + v[1]=v2[this->GetFieldValue("Station[2]", hid)]; + v[2]=v3[this->GetFieldValue("Station[3]", hid)]; + v[3]=v4[this->GetFieldValue("Station[4]", hid)]; + v[4]='\0'; + std::string temp=v; + return temp; } -int sTgcHitIdHelper::GetPhiSector(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("PhiSector"); +int sTgcHitIdHelper::GetPhiSector(const int& hid) const { + return this->GetFieldValue("PhiSector", hid); } -int sTgcHitIdHelper::GetZSector(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("ZSector"); +int sTgcHitIdHelper::GetZSector(const int& hid) const { + return this->GetFieldValue("ZSector", hid); } //----sTgc -int sTgcHitIdHelper::GetMultiLayer(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("MultiLayer"); +int sTgcHitIdHelper::GetMultiLayer(const int& hid) const { + return this->GetFieldValue("MultiLayer", hid); } -int sTgcHitIdHelper::GetLayer(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("Layer"); +int sTgcHitIdHelper::GetLayer(const int& hid) const { + return this->GetFieldValue("Layer", hid); } -int sTgcHitIdHelper::GetSide(const int& hid){ - this->SetID(hid); - return this->GetFieldValue("Side"); +int sTgcHitIdHelper::GetSide(const int& hid) const { + return this->GetFieldValue("Side", hid); } //packing method int sTgcHitIdHelper::BuildsTgcHitId(const std::string statName, const int phiSect, - const int zSect, const int multiLayer, const int layer, const int side){ - - this->SetID(0); - this->SetStationName(statName); - this->SetFieldValue("PhiSector", phiSect); - this->SetFieldValue("ZSector", zSect); - this->SetFieldValue("MultiLayer", multiLayer); - this->SetFieldValue("Layer", layer); - this->SetFieldValue("Side", side); - return this->GetID(); -} + const int zSect, const int multiLayer, const int layer, const int side) const { + int theID(0); + this->SetStationName(statName, theID); + this->SetFieldValue("PhiSector", phiSect, theID); + this->SetFieldValue("ZSector", zSect, theID); + this->SetFieldValue("MultiLayer", multiLayer, theID); + this->SetFieldValue("Layer", layer, theID); + this->SetFieldValue("Side", side, theID); + return theID; +} diff --git a/Simulation/HitManagement/HitManagement/HitIdHelper.h b/Simulation/HitManagement/HitManagement/HitIdHelper.h index 5b488012b65b08b18b94317caca5434bd7e36e18..c5e90d3fb9018ebb077fbfde42c37528b9cd5454 100755 --- a/Simulation/HitManagement/HitManagement/HitIdHelper.h +++ b/Simulation/HitManagement/HitManagement/HitIdHelper.h @@ -1,9 +1,9 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ -#ifndef HitIdHelper_H -#define HitIdHelper_H +#ifndef HITMANAGEMENT_HitIdHelper_H +#define HITMANAGEMENT_HitIdHelper_H #include <string> #include <vector> @@ -11,36 +11,32 @@ typedef int HitID; struct IdField { - std::string fieldName; - int vMin; - int vMax; - int nBits; - int firstBit; + std::string fieldName; + int vMin; + int vMax; + int nBits; + int firstBit; }; typedef std::vector<IdField> IdFields; class HitIdHelper { public: - HitIdHelper():m_id(0), m_currentStorage(0) {} - virtual ~HitIdHelper() {} - void InitializeField(std::string n, int vmn, int vmx); - void InitializeField(std::string n, int nb); - void SetFieldValue(std::string name, int n); - int GetFieldValue(std::string name); - void PrintFields(); - void SetID(int i) {m_id=i;} - HitID GetID() {return m_id;} - void ResetID() {m_id=0;} - void Print(int id); + HitIdHelper(): m_currentStorage(0) {} + virtual ~HitIdHelper() {} + void InitializeField(const std::string& n, int vmn, int vmx); + void InitializeField(const std::string& n, int nb); + void SetFieldValue(const std::string& name, int n, HitID& targetID) const; + int GetFieldValue(const std::string& name, HitID targetID) const; + void PrintFields(); + void Print(int id); protected: - HitID m_id; - IdFields m_IDs; - int m_currentStorage; - void SetBit(int& i, int bitpos); - void UnsetBit(int& i, int bitpos); - void Store(int& id, int value, int first, int field); - int Retrieve(int id, int first, int field); + IdFields m_IDs; + int m_currentStorage; + void SetBit(int& i, int bitpos) const; + void UnsetBit(int& i, int bitpos) const; + void Store(int& id, int value, int first, int field) const; + int Retrieve(int id, int first, int field) const; }; #endif diff --git a/Simulation/HitManagement/src/HitIdHelper.cxx b/Simulation/HitManagement/src/HitIdHelper.cxx index 725a210f3eb7ab427706bfb61d84b9988c4c623f..6009c4e7ff3eace600c0384703da014eef163e6d 100755 --- a/Simulation/HitManagement/src/HitIdHelper.cxx +++ b/Simulation/HitManagement/src/HitIdHelper.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #include "HitManagement/HitIdHelper.h" @@ -7,108 +7,108 @@ #include <cmath> #include <assert.h> -void HitIdHelper::InitializeField(std::string n, int vmn, int vmx) +void HitIdHelper::InitializeField(const std::string& n, int vmn, int vmx) { - int field = vmx -vmn+1; - int nb=1; - while (field>pow(2,nb)) nb++; - IdField id={n,vmn,vmx,nb,m_currentStorage+1}; - m_IDs.push_back(id); - m_currentStorage+=nb; - assert (m_currentStorage<33); + int field = vmx -vmn+1; + int nb=1; + while (field>pow(2,nb)) nb++; + IdField id={n,vmn,vmx,nb,m_currentStorage+1}; + m_IDs.push_back(id); + m_currentStorage+=nb; + assert (m_currentStorage<33); } -void HitIdHelper::InitializeField(std::string n,int nb) +void HitIdHelper::InitializeField(const std::string& n,int nb) { - int vmn=0; - int vmx=int(pow(2,nb))-1; - IdField id={n,vmn,vmx,nb,m_currentStorage+1}; - m_IDs.push_back(id); - m_currentStorage+=nb; - assert (m_currentStorage<33); + int vmn=0; + int vmx=int(pow(2,nb))-1; + IdField id={n,vmn,vmx,nb,m_currentStorage+1}; + m_IDs.push_back(id); + m_currentStorage+=nb; + assert (m_currentStorage<33); } -void HitIdHelper::SetFieldValue(std::string name, int n) + +void HitIdHelper::SetFieldValue(const std::string& name, int n, HitID& targetID) const { - for (unsigned int i=0;i<m_IDs.size();i++) - { - if (m_IDs[i].fieldName==name) - { - if (n<m_IDs[i].vMin || n>m_IDs[i].vMax) - std::cout<<"HitIdHelper: field "<<name<<": supplied value "<<n<< - " is not within the allowed range ["<<m_IDs[i].vMin<<","<<m_IDs[i].vMax - <<"] : the result of this action is unpredictable "<<std::endl; - n-=m_IDs[i].vMin; - Store(m_id,n,m_IDs[i].firstBit,m_IDs[i].nBits); - break; - } - } + for (unsigned int i=0;i<m_IDs.size();i++) + { + if (m_IDs[i].fieldName==name) + { + if (n<m_IDs[i].vMin || n>m_IDs[i].vMax) + std::cout<<"HitIdHelper: field "<<name<<": supplied value "<<n<< + " is not within the allowed range ["<<m_IDs[i].vMin<<","<<m_IDs[i].vMax + <<"] : the result of this action is unpredictable "<<std::endl; + n-=m_IDs[i].vMin; + Store(targetID,n,m_IDs[i].firstBit,m_IDs[i].nBits); + break; + } + } } -int HitIdHelper::GetFieldValue(std::string name) +int HitIdHelper::GetFieldValue(const std::string& name, HitID targetID) const { - for (unsigned int i=0;i<m_IDs.size();i++) - { - if (m_IDs[i].fieldName==name) - { - int n=Retrieve(m_id,m_IDs[i].firstBit,m_IDs[i].nBits); - return n+m_IDs[i].vMin; - } - } - std::cout<<"HitIdHelper: field "<<name<<" not found: returning 0"<< - std::endl; - return 0; + for (unsigned int i=0;i<m_IDs.size();i++) + { + if (m_IDs[i].fieldName==name) + { + int n=Retrieve(targetID,m_IDs[i].firstBit,m_IDs[i].nBits); + return n+m_IDs[i].vMin; + } + } + std::cout<<"HitIdHelper: field "<<name<<" not found: returning 0"<< + std::endl; + return 0; } void HitIdHelper::PrintFields() { - for (unsigned int i=0;i<m_IDs.size();i++) - { - std::cout<<"-- Field "<<m_IDs[i].fieldName<<"\t["<<m_IDs[i].vMin - <<","<<m_IDs[i].vMax<<"]\tnBits "<<m_IDs[i].nBits - <<"\tfirst Bit "<<m_IDs[i].firstBit<<std::endl; - } + for (unsigned int i=0;i<m_IDs.size();i++) + { + std::cout<<"-- Field "<<m_IDs[i].fieldName<<"\t["<<m_IDs[i].vMin + <<","<<m_IDs[i].vMax<<"]\tnBits "<<m_IDs[i].nBits + <<"\tfirst Bit "<<m_IDs[i].firstBit<<std::endl; + } } void HitIdHelper::Print(int id) { - int l=1; - for (unsigned int i=0;i<8*sizeof(int);i++) - { - if ((id & (l<<i))) std::cout<<"1"; - else std::cout<<"0"; - } - std::cout<<std::endl; + int l=1; + for (unsigned int i=0;i<8*sizeof(int);i++) + { + if ((id & (l<<i))) std::cout<<"1"; + else std::cout<<"0"; + } + std::cout<<std::endl; } -void HitIdHelper::SetBit(int& i, int bitpos) +void HitIdHelper::SetBit(int& i, int bitpos) const { - int l=1; - l<<=(bitpos-1); - i|=l; + int l=1; + l<<=(bitpos-1); + i|=l; } -void HitIdHelper::UnsetBit(int& i, int bitpos) +void HitIdHelper::UnsetBit(int& i, int bitpos) const { - int l=0; - SetBit(l,bitpos); - int k=~l; - i&=k; + int l=0; + SetBit(l,bitpos); + int k=~l; + i&=k; } -void HitIdHelper::Store(int& id, int value, int firstbit, int field) +void HitIdHelper::Store(int& id, int value, int firstbit, int field) const { - int l=0; - for (int i=0;i<field;i++) - UnsetBit(id,i+firstbit); - l=value<<(firstbit-1); - id |= l; + int l=0; + for (int i=0;i<field;i++) + UnsetBit(id,i+firstbit); + l=value<<(firstbit-1); + id |= l; } -int HitIdHelper::Retrieve(int id, int first, int field) +int HitIdHelper::Retrieve(int id, int first, int field) const { - int j=0; - for (int i=0;i<field;i++) - SetBit(j,(i+first)); - int l=id&j; - return l>>(first-1); + int j=0; + for (int i=0;i<field;i++) + SetBit(j,(i+first)); + int l=id&j; + return l>>(first-1); } -