ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TGCSensitiveDetectorCosmics Class Reference

#include <TGCSensitiveDetectorCosmics.h>

Inheritance diagram for TGCSensitiveDetectorCosmics:
Collaboration diagram for TGCSensitiveDetectorCosmics:

Public Member Functions

 TGCSensitiveDetectorCosmics (const std::string &name, const std::string &hitCollectionName)
 construction/destruction More...
 
 ~TGCSensitiveDetectorCosmics ()
 
void Initialize (G4HCofThisEvent *HCE) override final
 member functions More...
 
G4bool ProcessHits (G4Step *aStep, G4TouchableHistory *ROHist) override final
 

Private Member Functions

 FRIEND_TEST (TGCSensitiveDetectorCosmicstest, Initialize)
 
 FRIEND_TEST (TGCSensitiveDetectorCosmicstest, ProcessHits)
 

Private Attributes

Amg::Vector3D m_mom
 
double m_momMag
 
Amg::Vector3D m_vertex
 
Amg::Vector3D m_currVertex
 
Amg::Vector3D m_globH
 
double m_globalTime
 
SG::WriteHandle< TGCSimHitCollectionm_myTGCHitColl
 member data More...
 
const TgcHitIdHelperm_muonHelper
 

Detailed Description

Author
haseg.nosp@m.awa@.nosp@m.azusa.nosp@m..shi.nosp@m.nshu-.nosp@m.u.ac.nosp@m..jp

methods and properties

The method TGCSensitiveDetectorCosmics::ProcessHits is executed by the G4 kernel each time a charged particle (or a geantino) crosses one of the TGC Gas volumes.

Navigating with the touchableHistory method GetHistoryDepth() through the hierarchy of the volumes crossed by the particles, the TGCSensitiveDetectorCosmicsCosmicsdeterminates the correct set of geometry parameters to be folded in the Simulation Identifier associated to each hit. The TGC SimIDs are 32-bit unsigned integers, built using the MuonSimEvent/TgcHitIdHelper class which inherits from the MuonHitIdHelper base class.

The modified version (Daniela Rebuzzi, 16/12/2005) calculates the tof for the cosmics, using as t0 the time to the closest approach of the track to (0,0,0). This implementation works also for slow particles, since the discrimination physics event/cosmics is done relying on the G4Track vertex (not on the tof).

We describe in the following, how each field of the identifier is retrieved.

1) stationName and stationPhi: when a volume is found in the hierarchy, whose name contains the substring "station", the stationName is extracted from the volume's name; stationPhi is calculated starting from the volume copy number assigned by MuonGeoModel. Separate cases when the station are "F" or "E" type.

2) stationEta: when a volume is found in the hierarchy, whose name contains the substring "tgccomponent", stationEta is calculated starting from the volume copy number assigned by MuonGeoModel. Possibility to calculate the stationPhi at this level, from the copy number assigned by MuonGeoModel (if the copyNo > 1000).

3) gasGap: when a volume is found in the hierarchy, whose name contains the substring "Gas Volume Layer" or "TGCGas", the gasGap is calculated from the volume copy number, according to the positive or negative Z value, in the Atlas global reference system.

@section Some notes:

1) since the volume copy numbers strongly depend on the database layout, the volume name (whether it contains the string "Q02", for instance) is used to retrieve geometry information. In the year 2018 and even some years before there are not any more other database layouts / volumes than MUONQ02 and therefore some logic was removed.

2) for each hit, the time of flight (the G4 globalTime), is recorded and associated to the hit.

3) the TGCHit object contains: the SimID, the globalTime, the hit position in the local reference system, the track director cosine in the local reference system and the track identifier.

Definition at line 75 of file TGCSensitiveDetectorCosmics.h.

Constructor & Destructor Documentation

◆ TGCSensitiveDetectorCosmics()

TGCSensitiveDetectorCosmics::TGCSensitiveDetectorCosmics ( const std::string &  name,
const std::string &  hitCollectionName 
)

construction/destruction

Definition at line 15 of file TGCSensitiveDetectorCosmics.cxx.

16  : G4VSensitiveDetector( name )
17  , m_momMag(0)
18  , m_globalTime(0)
19  , m_myTGCHitColl( hitCollectionName )
20 {
22 }

◆ ~TGCSensitiveDetectorCosmics()

TGCSensitiveDetectorCosmics::~TGCSensitiveDetectorCosmics ( )
inline

Definition at line 82 of file TGCSensitiveDetectorCosmics.h.

82 {}

Member Function Documentation

◆ FRIEND_TEST() [1/2]

TGCSensitiveDetectorCosmics::FRIEND_TEST ( TGCSensitiveDetectorCosmicstest  ,
Initialize   
)
private

◆ FRIEND_TEST() [2/2]

TGCSensitiveDetectorCosmics::FRIEND_TEST ( TGCSensitiveDetectorCosmicstest  ,
ProcessHits   
)
private

◆ Initialize()

void TGCSensitiveDetectorCosmics::Initialize ( G4HCofThisEvent *  HCE)
finaloverride

member functions

Definition at line 25 of file TGCSensitiveDetectorCosmics.cxx.

26 {
27  if (!m_myTGCHitColl.isValid()) m_myTGCHitColl = std::make_unique<TGCSimHitCollection>();
28  // START OF COSMICS-SPECIFIC CODE
29  m_mom = Amg::Vector3D(0.,0.,0.);
30  m_globH = Amg::Vector3D(0.,0.,0.);
31  // END OF COSMICS-SPECIFIC CODE
32 }

◆ ProcessHits()

G4bool TGCSensitiveDetectorCosmics::ProcessHits ( G4Step *  aStep,
G4TouchableHistory *  ROHist 
)
finaloverride

Definition at line 34 of file TGCSensitiveDetectorCosmics.cxx.

34  {
35 
36  G4Track* track = aStep->GetTrack();
37 
38  if (track->GetDefinition()->GetPDGCharge() == 0.0) {
39  if (track->GetDefinition()!=G4Geantino::GeantinoDefinition()) return true;
40  else if (track->GetDefinition()==G4ChargedGeantino::ChargedGeantinoDefinition()) return true;
41  }
42  const G4TouchableHistory* touchHist = static_cast<const G4TouchableHistory*>(aStep->GetPreStepPoint()->GetTouchable());
43  G4ThreeVector position = aStep->GetPreStepPoint()->GetPosition();
44  const G4AffineTransform trans = track->GetTouchable()->GetHistory()->GetTopTransform();
45 
46  // fields for the TGC identifier construction
47  std::string stationName;
48  int stationEta(0);
49  int stationPhi(0);
50  int gasGap = 0;
51 
52  // TGC hit information
53  double globalTime = aStep->GetPreStepPoint()->GetGlobalTime();
54  Amg::Vector3D localPosition = Amg::Hep3VectorToEigen( trans.TransformPoint(position) );
55  G4ThreeVector direcos = aStep->GetPreStepPoint()->GetMomentumDirection();
56  Amg::Vector3D localDireCos = Amg::Hep3VectorToEigen( trans.TransformAxis(direcos) );
57 
58  // START OF COSMICS-SPECIFIC CODE
59  // global coordinates
60  G4ThreeVector globVrtx = aStep->GetPreStepPoint()->GetPosition();
61 
62  // distance of the hit from (0,0,0) vertex - calculated from the PreStepPoint (approximation)
63  double dist = globVrtx.mag();
64  double inv_lightspeed = 1. / CLHEP::c_light;
65  double tOrigin = dist * inv_lightspeed;
66 
67  G4int trackid = aStep->GetTrack()->GetTrackID();
68  m_currVertex = Amg::Hep3VectorToEigen(aStep->GetTrack()->GetVertexPosition());
69 
70  // for cosmics: only primary muon tracks - track momentum when first entering the spectrometer (one muon per event)
71  if ((m_currVertex != m_vertex) && (trackid == 1)) {
72  // after calculationg the momentum magnidude, normalize it
73  m_mom = Amg::Hep3VectorToEigen(track->GetMomentum());
74  m_momMag = m_mom.mag();
75  m_mom.normalize();
76  // the direction of the primary mu is used to calculate the t0, the position ot the t0, m_globH, is ONE for a track
77  Amg::Vector3D globVrtxFix = Amg::Hep3VectorToEigen( globVrtx );
78  double AlphaGlobal = -1*(globVrtxFix[0]*m_mom[0] + globVrtxFix[1]*m_mom[1] + globVrtxFix[2]*m_mom[2])/(m_mom[0]*m_mom[0] + m_mom[1]*m_mom[1] + m_mom[2]*m_mom[2]);
79  m_globH = globVrtxFix + AlphaGlobal*m_mom;
80  // G4cout << "COSMICS MAIN TRACK IN THE TGC!" << G4endl;
81  }
82  double globalDist = sqrt((m_globH[0] - globVrtx[0])*(m_globH[0] - globVrtx[0]) +
83  (m_globH[1] - globVrtx[1])*(m_globH[1] - globVrtx[1]) +
84  (m_globH[2] - globVrtx[2])*(m_globH[2] - globVrtx[2]));
85  double tof = globalDist * inv_lightspeed;
86  // END OF COSMICS-SPECIFIC CODE
87 
88  // scan geometry tree to identify hit channel
89  int zside(0);
90  for (int i=touchHist->GetHistoryDepth();i>=0;i--) {
91 
92  std::string::size_type npos;
93  std::string volName = touchHist->GetVolume(i)->GetName();
94 
95  // stationName and stationPhi
96  if ((npos = volName.find("station")) != std::string::npos) {
97 
98  stationName = volName.substr(0,npos-2);
99  int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
100  if (volCopyNo > 0) {
101  zside = 1;
102  } else {
103  zside = -1;
104  }
105  if (stationName.compare(2,1, "F") == 0) {
106 
107  stationPhi = (abs(volCopyNo%100)-1)*3;
108  if (abs(volCopyNo/100) > 3) {
109  stationPhi += abs(volCopyNo/100)-3;
110  } else {
111  stationPhi += abs(volCopyNo/100);
112  }
113 
114  stationPhi -= 1;
115  if (stationPhi <= 0) {
116  stationPhi = 24 - stationPhi;
117  }
118 
119  } else if (stationName.compare(2,1,"E") == 0) {
120  if (stationName.compare(1,1,"4") == 0) {
121 
122  stationPhi = (abs(volCopyNo%100)-1)*3+abs(volCopyNo/100);
123 
124  if (abs(volCopyNo%100) < 4) {
125  stationPhi = stationPhi - 1;
126  if (stationPhi <= 0) {
127  stationPhi = 21 - stationPhi;
128  }
129  } else if(abs(volCopyNo%100) < 7) {
130  stationPhi = stationPhi - 1 - 1;
131  } else {
132  stationPhi = stationPhi - 2 - 1;
133  }
134 
135  } else {
136 
137  stationPhi = (abs(volCopyNo%100)-1)*6+abs(volCopyNo/100);
138 
139  stationPhi -= 2;
140  if (stationPhi <= 0) {
141  stationPhi = 48 - stationPhi;
142  }
143  }
144  }
145 
146  // stationEta
147  } else if ((npos = volName.find("tgccomponent")) != std::string::npos) {
148  int volCopyNo = abs(touchHist->GetVolume(i)->GetCopyNo());
149  stationEta = zside*volCopyNo%100;
150  if (volCopyNo > 1000) { // stationPhi overridden by the number assigned by MuonGeoModel
151  stationPhi = volCopyNo/1000;
152  }
153 
154  // gasGap
155  } else if ((npos = volName.find("Gas Volume Layer")) != std::string::npos) {
156  int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
157  int iStation = atoi(stationName.substr(1,1).c_str());
158  if (zside < 0) {
159  if (iStation == 1)
160  gasGap = 3-(volCopyNo-3)/4;
161  else
162  gasGap = 2-(volCopyNo-3)/4;
163  } else {
164 // if (iStation == 1)
165  gasGap = (volCopyNo-3)/4+1;
166 // else
167 // gasGap = (volCopyNo-3)/4+1;
168  }
169  } else if ((npos = volName.find("TGCGas")) != std::string::npos) {
170 
171  int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
172 
173  if (volCopyNo != 0)
174  gasGap = volCopyNo;
175  }
176  }
177 
178  //construct the hit identifier
180  stationPhi,
181  stationEta,
182  gasGap);
183  //m_muonHelper->Print(TGCid);
184  // START OF COSMICS-SPECIFIC CODE
185  m_vertex = Amg::Hep3VectorToEigen(aStep->GetTrack()->GetVertexPosition());
186  // if the track m_vertex is far from (0,0,0), takes the tof, otherwise take the "usual" g4 globalTime
187  ((((m_vertex.mag()) < 100) || ((fabs(globalTime - tOrigin)) < 0.1) ) ? (m_globalTime = globalTime) : (m_globalTime = tof));
188  // if m_globalTime != globalTime and m_globalTime != tof in the output, this is due to multiple hits
189  // before founding the good one (small approximation)
190  // END OF COSMICS-SPECIFIC CODE
191 
192  // construct new mdt hit
193  TrackHelper trHelp(aStep->GetTrack());
194  m_myTGCHitColl->Emplace(TGCid,
195  m_globalTime,
196  localPosition,
197  localDireCos,
198  trHelp.GenerateParticleLink(),
199  aStep->GetTotalEnergyDeposit(),
200  aStep->GetStepLength());
201  return true;
202 }

Member Data Documentation

◆ m_currVertex

Amg::Vector3D TGCSensitiveDetectorCosmics::m_currVertex
private

Definition at line 92 of file TGCSensitiveDetectorCosmics.h.

◆ m_globalTime

double TGCSensitiveDetectorCosmics::m_globalTime
private

Definition at line 94 of file TGCSensitiveDetectorCosmics.h.

◆ m_globH

Amg::Vector3D TGCSensitiveDetectorCosmics::m_globH
private

Definition at line 93 of file TGCSensitiveDetectorCosmics.h.

◆ m_mom

Amg::Vector3D TGCSensitiveDetectorCosmics::m_mom
private

Definition at line 89 of file TGCSensitiveDetectorCosmics.h.

◆ m_momMag

double TGCSensitiveDetectorCosmics::m_momMag
private

Definition at line 90 of file TGCSensitiveDetectorCosmics.h.

◆ m_muonHelper

const TgcHitIdHelper* TGCSensitiveDetectorCosmics::m_muonHelper
private

Definition at line 98 of file TGCSensitiveDetectorCosmics.h.

◆ m_myTGCHitColl

SG::WriteHandle<TGCSimHitCollection> TGCSensitiveDetectorCosmics::m_myTGCHitColl
private

member data

Definition at line 97 of file TGCSensitiveDetectorCosmics.h.

◆ m_vertex

Amg::Vector3D TGCSensitiveDetectorCosmics::m_vertex
private

Definition at line 91 of file TGCSensitiveDetectorCosmics.h.


The documentation for this class was generated from the following files:
Muon::nsw::STGTPSegments::moduleIDBits::stationPhi
constexpr uint8_t stationPhi
station Phi 1 to 8
Definition: NSWSTGTPDecodeBitmaps.h:158
TGCSensitiveDetectorCosmics::m_muonHelper
const TgcHitIdHelper * m_muonHelper
Definition: TGCSensitiveDetectorCosmics.h:98
dumpTgcDigiDeadChambers.gasGap
list gasGap
Definition: dumpTgcDigiDeadChambers.py:33
dumpTgcDigiDeadChambers.stationName
dictionary stationName
Definition: dumpTgcDigiDeadChambers.py:30
TGCSensitiveDetectorCosmics::m_mom
Amg::Vector3D m_mom
Definition: TGCSensitiveDetectorCosmics.h:89
Amg::Hep3VectorToEigen
Amg::Vector3D Hep3VectorToEigen(const CLHEP::Hep3Vector &CLHEPvector)
Converts a CLHEP-based CLHEP::Hep3Vector into an Eigen-based Amg::Vector3D.
Definition: CLHEPtoEigenConverter.h:137
TrackHelper
Definition: TrackHelper.h:14
TGCSensitiveDetectorCosmics::m_globH
Amg::Vector3D m_globH
Definition: TGCSensitiveDetectorCosmics.h:93
lumiFormat.i
int i
Definition: lumiFormat.py:85
TGCSensitiveDetectorCosmics::m_vertex
Amg::Vector3D m_vertex
Definition: TGCSensitiveDetectorCosmics.h:91
TgcHitIdHelper::GetHelper
static const TgcHitIdHelper * GetHelper()
Definition: TgcHitIdHelper.cxx:23
TGCSensitiveDetectorCosmics::m_momMag
double m_momMag
Definition: TGCSensitiveDetectorCosmics.h:90
TGCSensitiveDetectorCosmics::m_currVertex
Amg::Vector3D m_currVertex
Definition: TGCSensitiveDetectorCosmics.h:92
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
python.PhysicalConstants.c_light
float c_light
Definition: PhysicalConstants.py:63
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
TGCSensitiveDetectorCosmics::m_myTGCHitColl
SG::WriteHandle< TGCSimHitCollection > m_myTGCHitColl
member data
Definition: TGCSensitiveDetectorCosmics.h:97
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
TGCSensitiveDetectorCosmics::m_globalTime
double m_globalTime
Definition: TGCSensitiveDetectorCosmics.h:94
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
TgcHitIdHelper::BuildTgcHitId
int BuildTgcHitId(const std::string &, const int, const int, const int) const
Definition: TgcHitIdHelper.cxx:77
Muon::nsw::STGTPSegments::moduleIDBits::stationEta
constexpr uint8_t stationEta
1 to 3
Definition: NSWSTGTPDecodeBitmaps.h:156
HitID
int HitID
Definition: GenericMuonSimHit.h:13