57 G4Exception(
"RPCSensitiveDetectorCosmics::ProcessHits",
"RPCCosmicHitCollectionMissing", FatalException,
58 "Hit collection not initialized; did SetupEvent run?");
61 G4Track* currentTrack = aStep->GetTrack();
63 if (currentTrack->GetDefinition()->GetPDGCharge() == 0.0) {
64 if (currentTrack->GetDefinition()!=G4Geantino::GeantinoDefinition())
return true;
68 const G4TouchableHistory* touchHist =
static_cast<const G4TouchableHistory*
>(aStep->GetPreStepPoint()->GetTouchable());
69 G4ThreeVector position = aStep->GetPreStepPoint()->GetPosition();
70 G4ThreeVector postPosition = aStep->GetPostStepPoint()->GetPosition();
71 const G4AffineTransform trans = currentTrack->GetTouchable()->GetHistory()->GetTopTransform();
79 std::string stationName;
88 int station_rotated=0;
93 double globalTime = aStep->GetPreStepPoint()->GetGlobalTime();
98 G4ThreeVector globVrtx = aStep->GetPreStepPoint()->GetPosition();
102 double lightspeed = 299.792458;
105 G4int trackid = aStep->GetTrack()->GetTrackID();
119 double globalDist = sqrt((
m_globH[0] - globVrtx[0])*(
m_globH[0] - globVrtx[0]) +
122 double tof = globalDist / lightspeed;
127 bool isAssembly =
false;
129 for (
int i=touchHist->GetHistoryDepth();i>=0;i--) {
131 std::string::size_type npos;
132 std::string volName = touchHist->GetVolume(i)->GetName();
133 std::string num=volName.substr(3,2);
134 if(num[0]==
' ') num[0]=0;
137 if ((npos = volName.find(
"av_")) != std::string::npos &&
138 (npos = volName.find(
"impr_")) != std::string::npos) isAssembly =
true;
141 if ((npos = volName.find(
"station")) != std::string::npos && (!isAssembly)) {
143 stationName = volName.substr(0,npos-1);
145 int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
147 if(abs(volCopyNo/1000)==1){
149 volCopyNo=volCopyNo%1000;
152 stationEta = volCopyNo/100;
153 stationPhi = abs(volCopyNo%100);
155 if(stationEta<0&&!zNeg_original) station_rotated=1;
158 }
else if ((npos = volName.find(
"RPC")) != std::string::npos && isAssembly) {
177 std::string::size_type loc1,loc2;
178 if ((loc1 = volName.find(
"Muon::")) != std::string::npos) {
179 stationName = volName.substr(loc1+6,4);
182 int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
183 int copyNrBase = int(volCopyNo/100000);
184 int sideC = int(copyNrBase/10000);
185 int zi = int((copyNrBase%1000)/100);
186 int mirfl = int((copyNrBase%10000)/1000);
187 int fi = int(copyNrBase%100);
188 if (sideC == 1) zi = -zi;
191 zNeg_original = mirfl;
193 if(stationEta<0&&!zNeg_original) station_rotated=1;
194 tech=volName.substr(npos,5);
198 if ((loc1 = volName.find(
'[')) != std::string::npos) {
199 if ((loc2 = volName.find(
']', loc1+1)) != std::string::npos) {
200 std::istringstream istrvar(volName.substr(loc1+1,loc2-loc1-1));
206 if (kk < 0) rpcIsRotated=1;
208 doubletR =(abs(kk)%1000)/100;
209 mydbZ = abs(
int(kk%10));
210 mydbPMod = abs(
int(kk/1000));
212 }
else if ((npos = volName.find(
"rpccomponent")) != std::string::npos && (!isAssembly)) {
214 tech=volName.substr(npos-5,5);
216 std::string::size_type loc1,loc2;
218 if ((loc1 = volName.find(
'[')) != std::string::npos) {
219 if ((loc2 = volName.find(
']', loc1+1)) != std::string::npos) {
220 std::istringstream istrvar(volName.substr(loc1+1,loc2-loc1-1));
224 mydbZ = abs(
int(gmID%10));
225 mydbPMod = abs(
int(gmID/1000));
227 int kk=touchHist->GetVolume(i)->GetCopyNo();
229 if (kk < 0) rpcIsRotated=1;
231 doubletR=(abs(kk)%1000)/100;
234 }
else if ((npos = volName.find(
"rpccomponent")) != std::string::npos && (!isAssembly)) {
236 std::string::size_type loc1,loc2;
238 if ((loc1 = volName.find(
'[')) != std::string::npos) {
239 if ((loc2 = volName.find(
']', loc1+1)) != std::string::npos) {
240 std::istringstream istrvar(volName.substr(loc1+1,loc2-loc1-1));
244 mydbZ = abs(
int(gmID%10));
245 mydbPMod = abs(
int(gmID/1000));
247 int kk=touchHist->GetVolume(i)->GetCopyNo();
249 if (kk < 0) rpcIsRotated=1;
251 doubletR=(abs(kk)%1000)/100;
254 }
else if ((npos = volName.find(
"layer")) != std::string::npos) {
256 int copyNo = touchHist->GetVolume(i)->GetCopyNo();
259 rpcIsRotated ? gasGap = 2 : gasGap = 1;
260 }
else if (copyNo ==2) {
261 rpcIsRotated ? gasGap = 1 : gasGap = 2;
265 }
else if((npos = volName.find(
"gas volume")) != std::string::npos) {
267 int copyNo = touchHist->GetVolume(i)->GetCopyNo();
270 }
else if (copyNo == 10) {
275 int nstrippanel_in_s=0;
276 std::string::size_type loc1;
277 if ((loc1 = volName.find(
"gg_in_s")) != std::string::npos) {
278 std::istringstream istrvar(volName.substr(loc1-1,1));
281 if ((loc1 = volName.find(
"sp_in_s")) != std::string::npos) {
282 std::istringstream istrvar(volName.substr(loc1-1,1));
283 istrvar>>nstrippanel_in_s;
285 if (ngap_in_s == 1 && nstrippanel_in_s == 2){
286 if(localPosition.y()>0) mydbP=2;
288 }
else if (ngap_in_s == 1 && nstrippanel_in_s == 1){
302 if (mydbP>2) mydbP=1;
311 localPosition.z() = -localPosition.z();
312 localPosition.y() = -localPosition.y();
313 localPostPosition.z() = -localPostPosition.z();
314 localPostPosition.y() = -localPostPosition.y();
321 localPosition.z() = -localPosition.z();
322 localPostPosition.z() = -localPostPosition.z();
334 if (verboseLevel>1) {
335 G4cout <<
"hit in station "<<stationName<<
" on technology "<<tech << G4endl;
336 G4cout <<
"constructing ids (stName, stEta, stPhi, dr, dZ, dPhi)= "<<stationName<<
" "<< stationEta<<
" " << stationPhi<<
" "<<doubletR<<
" "<< doubletZ<<
" "<<doubletPhi << G4endl;
339 HitID RPCid_eta =
m_muonHelper->BuildRpcHitId(stationName, stationPhi, stationEta,
340 mydbZ, doubletR, gasGap, mydbP,0);
342 HitID RPCid_phi =
m_muonHelper->BuildRpcHitId(stationName, stationPhi, stationEta,
343 mydbZ, doubletR, gasGap, mydbP,1);
358 aStep->GetTotalEnergyDeposit(),
359 aStep->GetStepLength(),
360 currentTrack->GetDefinition()->GetPDGEncoding(),
361 aStep->GetPreStepPoint()->GetKineticEnergy());
366 aStep->GetTotalEnergyDeposit(),
367 aStep->GetStepLength(),
368 currentTrack->GetDefinition()->GetPDGEncoding(),
369 aStep->GetPreStepPoint()->GetKineticEnergy());