48 G4Exception(
"RPCSensitiveDetector::ProcessHits",
"RPCHitCollectionMissing", FatalException,
49 "Hit collection not initialized; did SetupEvent run?");
53 G4Track* track = aStep->GetTrack();
56 if (track->GetDefinition()->GetPDGCharge() == 0.0) {
57 if (track->GetDefinition()!=G4Geantino::GeantinoDefinition()) {
62 const G4TouchableHistory* touchHist =
static_cast<const G4TouchableHistory*
>(aStep->GetPreStepPoint()->GetTouchable());
63 G4ThreeVector position = aStep->GetPreStepPoint()->GetPosition();
64 G4ThreeVector postPosition = aStep->GetPostStepPoint()->GetPosition();
65 const G4AffineTransform trans = track->GetTouchable()->GetHistory()->GetTopTransform();
73 std::string stationName;
79 int station_rotated=0;
84 double globalTime = aStep->GetPreStepPoint()->GetGlobalTime();
88 const Amg::Vector3D stepVector = localPostPosition - localPosition;
90 if (stepVector.mag()>std::numeric_limits<float>::epsilon() &&
91 std::abs(std::abs(
Amg::angle(stepVector, Amg::Vector3D::UnitX()))
92 - 90.*Gaudi::Units::deg) < 0.0001* Gaudi::Units::deg) {
99 bool isAssembly =
false;
101 for (
int i=touchHist->GetHistoryDepth();i>=0;i--) {
103 std::string::size_type npos;
104 std::string volName = touchHist->GetVolume(i)->GetName();
105 std::string num=volName.substr(3,2);
106 if(num[0]==
' ') num[0]=0;
109 if ((npos = volName.find(
"av_")) != std::string::npos &&
110 (npos = volName.find(
"impr_")) != std::string::npos) isAssembly =
true;
113 if ((npos = volName.find(
"station")) != std::string::npos && (!isAssembly)) {
115 stationName = volName.substr(0,npos-1);
117 int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
119 if(abs(volCopyNo/1000)==1){
121 volCopyNo=volCopyNo%1000;
124 stationEta = volCopyNo/100;
125 stationPhi = abs(volCopyNo%100);
127 if(stationEta<0&&!zNeg_original) station_rotated=1;
130 }
else if ((npos = volName.find(
"RPC")) != std::string::npos && isAssembly) {
149 std::string::size_type loc1,loc2;
150 if ((loc1 = volName.find(
"Muon::")) != std::string::npos) {
151 stationName = volName.substr(loc1+6,4);
154 int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
155 int copyNrBase = int(volCopyNo/100000);
156 int sideC = int(copyNrBase/10000);
157 int zi = int((copyNrBase%1000)/100);
158 int mirfl = int((copyNrBase%10000)/1000);
159 int fi = int(copyNrBase%100);
160 if (sideC == 1) zi = -zi;
163 zNeg_original = mirfl;
165 if(stationEta<0&&!zNeg_original) station_rotated=1;
168 tech=volName.substr(npos,5);
172 if ((loc1 = volName.find(
'[')) != std::string::npos) {
173 if ((loc2 = volName.find(
']', loc1+1)) != std::string::npos) {
175 std::istringstream istrvar(volName.substr(loc1+1,loc2-loc1-1));
181 if (kk < 0) rpcIsRotated=1;
183 doubletR =(abs(kk)%1000)/100;
184 mydbZ = abs(
int(kk%10));
185 mydbPMod = abs(
int(kk/1000));
187 }
else if ((npos = volName.find(
"rpccomponent")) != std::string::npos && (!isAssembly)) {
189 std::string::size_type loc1,loc2;
190 tech=volName.substr(npos-5,5);
192 if ((loc1 = volName.find(
'[')) != std::string::npos) {
193 if ((loc2 = volName.find(
']', loc1+1)) != std::string::npos) {
194 std::istringstream istrvar(volName.substr(loc1+1,loc2-loc1-1));
198 mydbZ = abs(
int(gmID%10));
199 mydbPMod = abs(
int(gmID/1000));
201 int kk=touchHist->GetVolume(i)->GetCopyNo();
203 if (kk < 0) rpcIsRotated=1;
205 doubletR=(abs(kk)%1000)/100;
207 }
else if ((npos = volName.find(
"layer")) != std::string::npos) {
209 int copyNo = touchHist->GetVolume(i)->GetCopyNo();
212 rpcIsRotated ? gasGap = 2 : gasGap = 1;
213 }
else if (copyNo ==2) {
214 rpcIsRotated ? gasGap = 1 : gasGap = 2;
215 }
else if (copyNo ==3) {
218 }
else if((npos = volName.find(
"gas volume")) != std::string::npos) {
220 int copyNo = touchHist->GetVolume(i)->GetCopyNo();
223 }
else if (copyNo == 10) {
228 int nstrippanel_in_s=0;
229 std::string::size_type loc1;
230 if ((loc1 = volName.find(
"gg_in_s")) != std::string::npos) {
231 std::istringstream istrvar(volName.substr(loc1-1,1));
234 if ((loc1 = volName.find(
"sp_in_s")) != std::string::npos) {
235 std::istringstream istrvar(volName.substr(loc1-1,1));
236 istrvar>>nstrippanel_in_s;
238 if (ngap_in_s == 1 && nstrippanel_in_s == 2) {
239 if(localPosition.y()>0) mydbP=2;
241 }
else if (ngap_in_s == 1 && nstrippanel_in_s == 1) {
255 if (mydbP>2) mydbP=1;
270 if (verboseLevel>5) {
271 G4cout <<
"hit in station "<<stationName<<
" on technology "<<tech << G4endl;
272 G4cout <<
"constructing ids (stName, stEta, stPhi, dr, dZ, dPhi)= "<<stationName<<
" "<< stationEta<<
" " << stationPhi<<
" "<<doubletR<<
" "<< mydbZ<<
" "<<mydbP << G4endl;
275 HitID RPCid_eta =
m_muonHelper->BuildRpcHitId(stationName, stationPhi, stationEta,
276 mydbZ, doubletR, gasGap, mydbP,0);
278 HitID RPCid_phi =
m_muonHelper->BuildRpcHitId(stationName, stationPhi, stationEta,
279 mydbZ, doubletR, gasGap, mydbP,1);
289 aStep->GetTotalEnergyDeposit(),
290 aStep->GetStepLength(),
291 track->GetDefinition()->GetPDGEncoding(),
292 aStep->GetPreStepPoint()->GetKineticEnergy());
297 aStep->GetTotalEnergyDeposit(),
298 aStep->GetStepLength(),
299 track->GetDefinition()->GetPDGEncoding(),
300 aStep->GetPreStepPoint()->GetKineticEnergy());