ATLAS Offline Software
Loading...
Searching...
No Matches
CSCSensitiveDetector Class Reference

#include <CSCSensitiveDetector.h>

Inheritance diagram for CSCSensitiveDetector:
Collaboration diagram for CSCSensitiveDetector:

Public Member Functions

 CSCSensitiveDetector (const std::string &name, const std::string &hitCollectionName)
 construction/destruction
void Initialize (G4HCofThisEvent *HCE) override final
 member functions
G4bool ProcessHits (G4Step *aStep, G4TouchableHistory *ROhist) override final

Private Member Functions

 FRIEND_TEST (CSCSensitiveDetectortest, Initialize)
 FRIEND_TEST (CSCSensitiveDetectortest, ProcessHits)

Private Attributes

std::string m_hitCollectionName
 member data
CSCSimHitCollectionm_myCSCHitColl {nullptr}
AtlasG4EventUserInfom_g4UserEventInfo {nullptr}
const CscHitIdHelperm_muonHelper

Detailed Description

Author
ketev.nosp@m.i@bn.nosp@m.l.gov

Class methods and properties

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

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

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

1) stationName, stationEta, 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 and stationEta are calculated starting from the volume copy number, assigned by MuonGeoModel.

2) multilayer: when a volume is found in the hierarchy, whose name contains the substring "component", the multilayer is set to 1 or to 2, according to the component number (multilayer=1 if the component copy number is 1, multilayer=3 if the component copy number is 2).

3) wireLayer: when a volume is found in the hierarchy, whose name contains the substring "CscArCO2", the wire Layer is calculated, increasing with |z| Atlas global coordinate.

notes:

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

2) the CSCHit object contains: the SimID, the globalTime, the energy deposited, the start and end point of the step in local coordinates (chamber reference system), the particle pdg and the track identifier.

Definition at line 63 of file CSCSensitiveDetector.h.

Constructor & Destructor Documentation

◆ CSCSensitiveDetector()

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

construction/destruction

Definition at line 20 of file CSCSensitiveDetector.cxx.

22 : G4VSensitiveDetector( name )
23 , m_hitCollectionName( hitCollectionName )
24{
26}
std::string m_hitCollectionName
member data
const CscHitIdHelper * m_muonHelper
static const CscHitIdHelper * GetHelper()

Member Function Documentation

◆ FRIEND_TEST() [1/2]

CSCSensitiveDetector::FRIEND_TEST ( CSCSensitiveDetectortest ,
Initialize  )
private

◆ FRIEND_TEST() [2/2]

CSCSensitiveDetector::FRIEND_TEST ( CSCSensitiveDetectortest ,
ProcessHits  )
private

◆ Initialize()

void CSCSensitiveDetector::Initialize ( G4HCofThisEvent * HCE)
finaloverride

member functions

Definition at line 29 of file CSCSensitiveDetector.cxx.

30{
31 m_myCSCHitColl = nullptr;
32 if (auto* eventInfo = AtlasG4EventUserInfo::GetEventUserInfo()) {
33 m_myCSCHitColl = eventInfo->GetHitCollectionMap()->Find<CSCSimHitCollection>(m_hitCollectionName);
34 m_g4UserEventInfo = eventInfo;
35 }
36}
AtlasHitsVector< CSCSimHit > CSCSimHitCollection
static AtlasG4EventUserInfo * GetEventUserInfo()
AtlasG4EventUserInfo * m_g4UserEventInfo
CSCSimHitCollection * m_myCSCHitColl

◆ ProcessHits()

G4bool CSCSensitiveDetector::ProcessHits ( G4Step * aStep,
G4TouchableHistory * ROhist )
finaloverride

CSCs sensitive to charged particle only; plus energy threshold

attributes of the CSC identifier construction

hit information to be recorded

scan geometry tree to identify the gas layer

station: name, eta and phi (-> chamber!)

station name, station eta and station phi

station name

station eta and station phi

chamber layer

chamber layer

the wire layer number

get the particle ID

the track id

record global time

energy deposit

get the transformation

local position of HitStart and HitEnd

get the end of the step as return by G4 - could be at the beginning of the next volume

construct the hit identifier

insert hit in collection

Definition at line 38 of file CSCSensitiveDetector.cxx.

38 {
39
40 if (!m_myCSCHitColl) {
41 G4Exception("CSCSensitiveDetector::ProcessHits", "CSCHitCollectionMissing", FatalException,
42 "Hit collection not initialized; did SetupEvent run?");
43 return false;
44 }
45
46 G4Track* currentTrack = aStep->GetTrack();
47
49 auto trackDef = currentTrack->GetDefinition();
50 if (trackDef->GetPDGCharge() == 0.0) {
51 if (trackDef != G4Geantino::GeantinoDefinition()) return true;
52 else if (trackDef == G4ChargedGeantino::ChargedGeantinoDefinition()) return true;
53 }
54
55 const G4TouchableHistory* touchHist = static_cast<const G4TouchableHistory*>(aStep->GetPreStepPoint()->GetTouchable());
56 G4ThreeVector startPos=aStep->GetPreStepPoint()->GetPosition();
57 G4ThreeVector endPos=aStep->GetPostStepPoint()->GetPosition();
58 double kinEnergy = aStep->GetPreStepPoint()->GetKineticEnergy();
59
61
62 std::string stationName="";
63 int stationEta=1;
64 int stationPhi=1;
65 int multiLayer=1;
66 int wireLayer=0;
67
69
70 Amg::Vector3D HitStart = Amg::Vector3D(-1000,-1000,-1000);
71 Amg::Vector3D HitEnd = Amg::Vector3D(-1000,-1000,-1000);
72 double globalTime = -1;
73 double energyDeposit= -1;
74 G4int lundcode = -1;
75 // int trackid = -1;
76
78
79 bool isAssembly = false;
80 for (int i = touchHist->GetHistoryDepth(); i>=0; --i) {
81 std::string::size_type npos;
82 std::string volName = touchHist->GetVolume(i)->GetName();
83
84 //G4cout << "Csc SD: swimming through the tree: level "<<i-touchHist->GetHistoryDepth() << G4endl;
85 //G4cout << "Csc SD: name "<<volName << G4endl;
86
88 if ((npos = volName.find("av_")) != std::string::npos &&
89 (npos = volName.find("impr_")) != std::string::npos) isAssembly = true;
90
91 if ((npos = volName.find("station")) != std::string::npos && (!isAssembly)) {
92
94 volName.resize(npos-2);
95 int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
96 stationName = volName;
97 //stationEta = volCopyNo/100;
98 // bug fix for 14.2.0 to cope with non-mirrored chambers as proposed by
99 // S.Spagnolo
100 stationEta = (volCopyNo%1000)/100;
101 stationPhi = abs(volCopyNo%100);
102
103 } else if ((npos = volName.find("CSC")) != std::string::npos && isAssembly ) {
104 // vol name for Assembly components are
105 // av_WWW_impr_XXX_Muon::BMSxMDTxx_pv_ZZZ_NAME
106 // where WWW is ass. istance nr.
107 // XXX is comp. imprint nr.
108 // BMSxMDTxx is the name of the comp. log.Vol.
109 // x station sub-type; xx technology subtype
110 // ZZZ is No of order of this daugther
111 // NAME is the comp. tag (geoIdentifierTag)
112 // for CSCs it is cl[1] or cl[2]
113 // copy numbers for Ass.components are =
114 // CopyNoBase(= geoIdentifierTag of the assembly) + geoIdentifierTag of the component
115 // geoIdentifierTag of the component = Job
116 // geoIdentifierTag of the assembly = (sideC*10000 +
117 // mirsign*1000 + abs(zi)*100 + fi+1)*100000;
118 // mirsign*1000 + abs(zi)*100 + fi+1)*100000;
119
121 std::string::size_type loc1,loc2;
122 if ((loc1 = volName.find("Muon::")) != std::string::npos) {
123 stationName = volName.substr(loc1+6,3); //type only
124 }
125
127 int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
128 int copyNrBase = int(volCopyNo/100000);
129 int sideC = int(copyNrBase/10000);
130 int zi = int((copyNrBase%1000)/100);
131 // int mirfl = int((copyNrBase%10000)/1000);
132 int fi = int(copyNrBase%100);
133 if (sideC == 1) zi = -zi;
134 stationEta = zi;
135 stationPhi = fi;
136
137 // now get the geoIdentifierTag of the rpc components
138 int gmID = 0;
139 if ((loc1 = volName.find('[')) != std::string::npos) {
140 if ((loc2 = volName.find(']', loc1+1)) != std::string::npos) {
141 std::istringstream istrvar(volName.substr(loc1+1,loc2-loc1-1));
142 istrvar>>gmID;
143 }
144 }
146 multiLayer = gmID;
147 } else if ((npos = volName.find("component")) != std::string::npos && (!isAssembly)) {
148
150 multiLayer = touchHist->GetVolume(i)->GetCopyNo();
151 if(multiLayer==3) multiLayer=2; //multilayer index
152 } else if ((npos = volName.find("CscArCO2")) != std::string::npos) {
153
155 wireLayer=touchHist->GetVolume(i)->GetCopyNo();
156 wireLayer+=1;
157 if(wireLayer==4) wireLayer=1;
158 else if(wireLayer==3) wireLayer=2;
159 else if(wireLayer==2) wireLayer=3;
160 else if(wireLayer==1) wireLayer=4;
161 // G4cout << "CSC:::::: wireLayer "<<wireLayer << G4endl;
162
164 G4String particle=aStep->GetTrack()->GetDefinition()->GetParticleName();
165 // http://www.slac.stanford.edu/BFROOT/www/Computing/Environment/NewUser/htmlbug/node51.html #GEANT code
166 if (particle=="gamma") lundcode=1;
167 else if (particle=="e+") lundcode=2;
168 else if (particle=="e-") lundcode=3;
169 else if (particle=="mu+") lundcode=5;
170 else if (particle=="mu-") lundcode=6;
171 else if (particle=="pi+") lundcode=8;
172 else if (particle=="pi-") lundcode=9;
173 else if (particle=="kaon+") lundcode=11;
174 else if (particle=="kaon-") lundcode=12;
175 else if (particle=="proton") lundcode=14;
176 else if (particle=="anti_proton") lundcode=15;
177 else if (particle=="sigma+") lundcode=19;
178 else if (particle=="sigma-") lundcode=21;
179 else if (particle=="anti_sigma-") lundcode=27;
180 else if (particle=="anti_sigma+") lundcode=29;
181 else if (particle=="deuteron") lundcode=45;
182 //else if (particle=="geantino") lundcode=999;
183 //else lundcode=999;
184
185 if (lundcode < 0)
186 G4cout << "WP CSCSensitiveDetector.cxx have exceptional particlue out of selection:: "
187 << particle<< G4endl;
188
190 // trackid=aStep->GetTrack()->GetTrackID();
191
193 globalTime = aStep->GetPreStepPoint()->GetGlobalTime();
194
196 energyDeposit = aStep->GetTotalEnergyDeposit();
197
199 const G4AffineTransform transform = touchHist->GetHistory()->GetTopTransform();
200
202 HitStart = Amg::Hep3VectorToEigen( transform.TransformPoint(startPos) );
203
206 HitEnd = Amg::Hep3VectorToEigen( transform.TransformPoint(endPos) );
207
208 }
209 }
210
211 TrackHelper trHelp(aStep->GetTrack());
212
214 HitID CSCid = m_muonHelper->BuildCscHitId(stationName, stationPhi,
215 stationEta, multiLayer, wireLayer);
217 m_myCSCHitColl->Emplace(CSCid, globalTime, energyDeposit,
218 HitStart, HitEnd, lundcode,
219 trHelp.GenerateParticleLink(m_g4UserEventInfo ? m_g4UserEventInfo->GetEventStore() : nullptr),kinEnergy);
220
221 return true;
222}
int HitID
Amg::Vector3D Hep3VectorToEigen(const CLHEP::Hep3Vector &CLHEPvector)
Converts a CLHEP-based CLHEP::Hep3Vector into an Eigen-based Amg::Vector3D.
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Eigen::Matrix< double, 3, 1 > Vector3D
constexpr uint8_t stationPhi
station Phi 1 to 8
unsigned int constexpr sideC
Definition RPDUtils.h:15
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
@ energyDeposit
@ loc2
generic first and second local coordinate
Definition ParamDefs.h:35
@ loc1
Definition ParamDefs.h:34

Member Data Documentation

◆ m_g4UserEventInfo

AtlasG4EventUserInfo* CSCSensitiveDetector::m_g4UserEventInfo {nullptr}
private

Definition at line 79 of file CSCSensitiveDetector.h.

79{nullptr};

◆ m_hitCollectionName

std::string CSCSensitiveDetector::m_hitCollectionName
private

member data

Definition at line 77 of file CSCSensitiveDetector.h.

◆ m_muonHelper

const CscHitIdHelper* CSCSensitiveDetector::m_muonHelper
private

Definition at line 80 of file CSCSensitiveDetector.h.

◆ m_myCSCHitColl

CSCSimHitCollection* CSCSensitiveDetector::m_myCSCHitColl {nullptr}
private

Definition at line 78 of file CSCSensitiveDetector.h.

78{nullptr};

The documentation for this class was generated from the following files: