SiHitIdHelper.cxx 3.33 KB
Newer Older
1
/*
2
  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
4
*/

5
6
#include <mutex>

7
8
9
#include "InDetSimEvent/SiHitIdHelper.h"
#include "StoreGate/StoreGateSvc.h"
#include "InDetIdentifier/PixelID.h"
10
#include "GaudiKernel/ServiceHandle.h"
11

12
#include "G4Types.hh"
13
14

//
15
16
17
18
19
// private constructor
SiHitIdHelper::SiHitIdHelper() :HitIdHelper() {
  Initialize();
}

20
const SiHitIdHelper* SiHitIdHelper::GetHelper() {
21
  static const SiHitIdHelper helper;
22
  return &helper;
23
24
25
26
}

void SiHitIdHelper::Initialize() {

27
28
29
  const PixelID* pix = nullptr;
  ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "SiHitIdHelper");
  if (detStore.retrieve().isSuccess()) {
30
31
    if (detStore->retrieve(pix, "PixelID").isFailure()) { pix = 0; }
  }
32

33
  bool isDBM  = (pix != 0 && pix->dictionaryVersion() == "IBL-DBM");
Tadej Novak's avatar
Tadej Novak committed
34
35
36
37
38
39
40
41
  // check for ITk and HGTD
  bool isITkHGTD = (pix !=0 &&  pix->dictionaryVersion() == "ITkHGTD");
  // we might include PLR as well, then we have to increase endcap range to +/- 4
  bool isITkHGTDPLR = (pix !=0 &&  pix->dictionaryVersion() == "ITkHGTDPLR");
  // cache the HL-LHC decision
  m_isITkHGTD = isITkHGTD || isITkHGTDPLR;

  if (m_isITkHGTD) InitializeField("Part",0,2);
42
  else InitializeField("Part",0,1);
Tadej Novak's avatar
Tadej Novak committed
43
  if (isDBM || isITkHGTDPLR) InitializeField("BarrelEndcap",-4,4);
44
  else InitializeField("BarrelEndcap",-2,2);
45
  InitializeField("LayerDisk",0,20);
Tadej Novak's avatar
Tadej Novak committed
46
  if (m_isITkHGTD) InitializeField("EtaModule",-100,100);
47
48
49
  else InitializeField("EtaModule",-20,20);
  InitializeField("PhiModule",0,200);
  InitializeField("Side",0,3);
50

51
52
}

53
// Info retrieval:
54
// Pixel, SCT, HGTD, or PLR
55
56
bool SiHitIdHelper::isPixel(const int& hid) const
{
57
58
  int psh = this->GetFieldValue("Part", hid);
  if (psh ==0 ) return true;
59
60
61
  else return false;
}

62
63
bool SiHitIdHelper::isSCT(const int& hid) const
{
64
65
66
67
68
69
70
71
72
73
  int psh = this->GetFieldValue("Part", hid);
  if (psh ==1 ) return true;
  else return false;
}

bool SiHitIdHelper::isHGTD(const int& hid) const
{
  int psh = this->GetFieldValue("Part", hid);
  if (psh ==2 ) return true;
  else return false;
74
}
75

76
77
bool SiHitIdHelper::isPLR(const int& hid) const
{
Tadej Novak's avatar
Tadej Novak committed
78
79
  if (!m_isITkHGTD) return false;

80
  int psh = this->GetFieldValue("BarrelEndcap", hid);
Tadej Novak's avatar
Tadej Novak committed
81
  if (std::abs(psh) == 4) return true;
82
83
84
85
  else return false;
}


86
// Barrel or Endcap
87
88
89
int SiHitIdHelper::getBarrelEndcap(const int& hid) const
{
  return this->GetFieldValue("BarrelEndcap", hid);
90
91
92
}

// Layer/Disk
93
94
95
int SiHitIdHelper::getLayerDisk(const int& hid) const
{
  return this->GetFieldValue("LayerDisk", hid);
96
}
97
98

// eta module
99
100
101
int SiHitIdHelper::getEtaModule(const int& hid) const
{
  return this->GetFieldValue("EtaModule", hid);
102
103
104
}

// phi module
105
106
107
int SiHitIdHelper::getPhiModule(const int& hid) const
{
  return this->GetFieldValue("PhiModule", hid);
108
}
109

110
// side
111
112
113
int SiHitIdHelper::getSide(const int& hid) const
{
  return this->GetFieldValue("Side", hid);
114
115
116
117
118
}


//
// Info packing:
119
int SiHitIdHelper::buildHitId(const int Part, const int BrlECap, const int LayerDisk,
120
121
122
                              const int etaM, const int phiM, const int side) const
{
  int theID(0);
123
  this->SetFieldValue("Part",           Part, theID);
124
125
126
127
128
129
  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;
130
}