6 #include "G4ThreeVector.hh"
10 #include "G4Geantino.hh"
11 #include "G4ChargedGeantino.hh"
20 : G4VSensitiveDetector(
name )
21 , m_myRPCHitColl( hitCollectionName )
32 if (verboseLevel>1) G4cout <<
"Initializing SD" << G4endl;
48 G4Track* currentTrack = aStep->GetTrack();
50 if (currentTrack->GetDefinition()->GetPDGCharge() == 0.0) {
51 if (currentTrack->GetDefinition()!=G4Geantino::GeantinoDefinition())
return true;
55 const G4TouchableHistory* touchHist =
static_cast<const G4TouchableHistory*
>(aStep->GetPreStepPoint()->GetTouchable());
56 G4ThreeVector position = aStep->GetPreStepPoint()->GetPosition();
57 G4ThreeVector postPosition = aStep->GetPostStepPoint()->GetPosition();
58 const G4AffineTransform trans = currentTrack->GetTouchable()->GetHistory()->GetTopTransform();
75 int station_rotated=0;
80 double globalTime = aStep->GetPreStepPoint()->GetGlobalTime();
85 G4ThreeVector globVrtx = aStep->GetPreStepPoint()->GetPosition();
89 double lightspeed = 299.792458;
92 G4int trackid = aStep->GetTrack()->GetTrackID();
106 double globalDist = sqrt((
m_globH[0] - globVrtx[0])*(
m_globH[0] - globVrtx[0]) +
109 double tof = globalDist / lightspeed;
114 bool isAssembly =
false;
116 for (
int i=touchHist->GetHistoryDepth();
i>=0;
i--) {
118 std::string::size_type npos;
119 std::string volName = touchHist->GetVolume(
i)->GetName();
120 std::string
num=volName.substr(3,2);
124 if ((npos = volName.find(
"av_")) != std::string::npos &&
125 (npos = volName.find(
"impr_")) != std::string::npos) isAssembly =
true;
128 if ((npos = volName.find(
"station")) != std::string::npos && (!isAssembly)) {
132 int volCopyNo = touchHist->GetVolume(
i)->GetCopyNo();
134 if(abs(volCopyNo/1000)==1){
136 volCopyNo=volCopyNo%1000;
142 if(
stationEta<0&&!zNeg_original) station_rotated=1;
145 }
else if ((npos = volName.find(
"RPC")) != std::string::npos && isAssembly) {
165 if ((
loc1 = volName.find(
"Muon::")) != std::string::npos) {
169 int volCopyNo = touchHist->GetVolume(
i)->GetCopyNo();
170 int copyNrBase =
int(volCopyNo/100000);
172 int zi =
int((copyNrBase%1000)/100);
173 int mirfl =
int((copyNrBase%10000)/1000);
174 int fi =
int(copyNrBase%100);
175 if (
sideC == 1) zi = -zi;
178 zNeg_original = mirfl;
180 if(
stationEta<0&&!zNeg_original) station_rotated=1;
181 tech=volName.substr(npos,5);
185 if ((
loc1 = volName.find(
'[')) != std::string::npos) {
186 if ((
loc2 = volName.find(
']',
loc1+1)) != std::string::npos) {
187 std::istringstream istrvar(volName.substr(
loc1+1,
loc2-
loc1-1));
193 if (
kk < 0) rpcIsRotated=1;
196 mydbZ = abs(
int(
kk%10));
197 mydbPMod = abs(
int(
kk/1000));
199 }
else if ((npos = volName.find(
"rpccomponent")) != std::string::npos && (!isAssembly)) {
201 tech=volName.substr(npos-5,5);
205 if ((
loc1 = volName.find(
'[')) != std::string::npos) {
206 if ((
loc2 = volName.find(
']',
loc1+1)) != std::string::npos) {
207 std::istringstream istrvar(volName.substr(
loc1+1,
loc2-
loc1-1));
211 mydbZ = abs(
int(gmID%10));
212 mydbPMod = abs(
int(gmID/1000));
214 int kk=touchHist->GetVolume(
i)->GetCopyNo();
216 if (
kk < 0) rpcIsRotated=1;
221 }
else if ((npos = volName.find(
"rpccomponent")) != std::string::npos && (!isAssembly)) {
225 if ((
loc1 = volName.find(
'[')) != std::string::npos) {
226 if ((
loc2 = volName.find(
']',
loc1+1)) != std::string::npos) {
227 std::istringstream istrvar(volName.substr(
loc1+1,
loc2-
loc1-1));
231 mydbZ = abs(
int(gmID%10));
232 mydbPMod = abs(
int(gmID/1000));
234 int kk=touchHist->GetVolume(
i)->GetCopyNo();
236 if (
kk < 0) rpcIsRotated=1;
241 }
else if ((npos = volName.find(
"layer")) != std::string::npos) {
243 int copyNo = touchHist->GetVolume(
i)->GetCopyNo();
247 }
else if (copyNo ==2) {
252 }
else if((npos = volName.find(
"gas volume")) != std::string::npos) {
254 int copyNo = touchHist->GetVolume(
i)->GetCopyNo();
257 }
else if (copyNo == 10) {
262 int nstrippanel_in_s=0;
263 std::string::size_type
loc1;
264 if ((
loc1 = volName.find(
"gg_in_s")) != std::string::npos) {
265 std::istringstream istrvar(volName.substr(
loc1-1,1));
268 if ((
loc1 = volName.find(
"sp_in_s")) != std::string::npos) {
269 std::istringstream istrvar(volName.substr(
loc1-1,1));
270 istrvar>>nstrippanel_in_s;
272 if (ngap_in_s == 1 && nstrippanel_in_s == 2){
273 if(localPosition.y()>0) mydbP=2;
275 }
else if (ngap_in_s == 1 && nstrippanel_in_s == 1){
289 if (mydbP>2) mydbP=1;
298 localPosition.z() = -localPosition.z();
299 localPosition.y() = -localPosition.y();
300 localPostPosition.z() = -localPostPosition.z();
301 localPostPosition.y() = -localPostPosition.y();
308 localPosition.z() = -localPosition.z();
309 localPostPosition.z() = -localPostPosition.z();
321 if (verboseLevel>1) {
322 G4cout <<
"hit in station "<<
stationName<<
" on technology "<<tech << G4endl;
343 aStep->GetTotalEnergyDeposit(),
344 aStep->GetStepLength(),
345 currentTrack->GetDefinition()->GetPDGEncoding(),
346 aStep->GetPreStepPoint()->GetKineticEnergy());
349 aStep->GetTotalEnergyDeposit(),
350 aStep->GetStepLength(),
351 currentTrack->GetDefinition()->GetPDGEncoding(),
352 aStep->GetPreStepPoint()->GetKineticEnergy());