6 #include "G4ThreeVector.hh"
10 #include "G4Geantino.hh"
11 #include "G4ChargedGeantino.hh"
19 #include "GaudiKernel/SystemOfUnits.h"
23 : G4VSensitiveDetector(
name )
24 , m_myRPCHitColl( hitCollectionName )
34 if (verboseLevel>5) G4cout <<
"Initializing SD" << G4endl;
40 G4Track*
track = aStep->GetTrack();
43 if (
track->GetDefinition()->GetPDGCharge() == 0.0) {
44 if (
track->GetDefinition()!=G4Geantino::GeantinoDefinition()) {
49 const G4TouchableHistory* touchHist =
static_cast<const G4TouchableHistory*
>(aStep->GetPreStepPoint()->GetTouchable());
50 G4ThreeVector position = aStep->GetPreStepPoint()->GetPosition();
51 G4ThreeVector postPosition = aStep->GetPostStepPoint()->GetPosition();
52 const G4AffineTransform trans =
track->GetTouchable()->GetHistory()->GetTopTransform();
69 int station_rotated=0;
74 double globalTime = aStep->GetPreStepPoint()->GetGlobalTime();
78 const Amg::Vector3D stepVector = localPostPosition - localPosition;
80 if (stepVector.mag()>std::numeric_limits<float>::epsilon() &&
81 std::abs(std::abs(
Amg::angle(stepVector, Amg::Vector3D::UnitX()))
89 bool isAssembly =
false;
91 for (
int i=touchHist->GetHistoryDepth();
i>=0;
i--) {
93 std::string::size_type npos;
94 std::string volName = touchHist->GetVolume(
i)->GetName();
95 std::string
num=volName.substr(3,2);
99 if ((npos = volName.find(
"av_")) != std::string::npos &&
100 (npos = volName.find(
"impr_")) != std::string::npos) isAssembly =
true;
103 if ((npos = volName.find(
"station")) != std::string::npos && (!isAssembly)) {
107 int volCopyNo = touchHist->GetVolume(
i)->GetCopyNo();
109 if(abs(volCopyNo/1000)==1){
111 volCopyNo=volCopyNo%1000;
117 if(
stationEta<0&&!zNeg_original) station_rotated=1;
120 }
else if ((npos = volName.find(
"RPC")) != std::string::npos && isAssembly) {
140 if ((
loc1 = volName.find(
"Muon::")) != std::string::npos) {
144 int volCopyNo = touchHist->GetVolume(
i)->GetCopyNo();
145 int copyNrBase =
int(volCopyNo/100000);
147 int zi =
int((copyNrBase%1000)/100);
148 int mirfl =
int((copyNrBase%10000)/1000);
149 int fi =
int(copyNrBase%100);
150 if (
sideC == 1) zi = -zi;
153 zNeg_original = mirfl;
155 if(
stationEta<0&&!zNeg_original) station_rotated=1;
158 tech=volName.substr(npos,5);
162 if ((
loc1 = volName.find(
'[')) != std::string::npos) {
163 if ((
loc2 = volName.find(
']',
loc1+1)) != std::string::npos) {
165 std::istringstream istrvar(volName.substr(
loc1+1,
loc2-
loc1-1));
171 if (
kk < 0) rpcIsRotated=1;
174 mydbZ = abs(
int(
kk%10));
175 mydbPMod = abs(
int(
kk/1000));
177 }
else if ((npos = volName.find(
"rpccomponent")) != std::string::npos && (!isAssembly)) {
180 tech=volName.substr(npos-5,5);
182 if ((
loc1 = volName.find(
'[')) != std::string::npos) {
183 if ((
loc2 = volName.find(
']',
loc1+1)) != std::string::npos) {
184 std::istringstream istrvar(volName.substr(
loc1+1,
loc2-
loc1-1));
188 mydbZ = abs(
int(gmID%10));
189 mydbPMod = abs(
int(gmID/1000));
191 int kk=touchHist->GetVolume(
i)->GetCopyNo();
193 if (
kk < 0) rpcIsRotated=1;
197 }
else if ((npos = volName.find(
"layer")) != std::string::npos) {
199 int copyNo = touchHist->GetVolume(
i)->GetCopyNo();
203 }
else if (copyNo ==2) {
205 }
else if (copyNo ==3) {
208 }
else if((npos = volName.find(
"gas volume")) != std::string::npos) {
210 int copyNo = touchHist->GetVolume(
i)->GetCopyNo();
213 }
else if (copyNo == 10) {
218 int nstrippanel_in_s=0;
219 std::string::size_type
loc1;
220 if ((
loc1 = volName.find(
"gg_in_s")) != std::string::npos) {
221 std::istringstream istrvar(volName.substr(
loc1-1,1));
224 if ((
loc1 = volName.find(
"sp_in_s")) != std::string::npos) {
225 std::istringstream istrvar(volName.substr(
loc1-1,1));
226 istrvar>>nstrippanel_in_s;
228 if (ngap_in_s == 1 && nstrippanel_in_s == 2) {
229 if(localPosition.y()>0) mydbP=2;
231 }
else if (ngap_in_s == 1 && nstrippanel_in_s == 1) {
245 if (mydbP>2) mydbP=1;
260 if (verboseLevel>5) {
261 G4cout <<
"hit in station "<<
stationName<<
" on technology "<<tech << G4endl;
277 aStep->GetTotalEnergyDeposit(),
278 aStep->GetStepLength(),
279 track->GetDefinition()->GetPDGEncoding(),
280 aStep->GetPreStepPoint()->GetKineticEnergy());
283 aStep->GetTotalEnergyDeposit(),
284 aStep->GetStepLength(),
285 track->GetDefinition()->GetPDGEncoding(),
286 aStep->GetPreStepPoint()->GetKineticEnergy());