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;
82 int station_rotated=0;
87 double globalTime = aStep->GetPreStepPoint()->GetGlobalTime();
91 const Amg::Vector3D stepVector = localPostPosition - localPosition;
93 if (stepVector.mag()>std::numeric_limits<float>::epsilon() &&
94 std::abs(std::abs(
Amg::angle(stepVector, Amg::Vector3D::UnitX()))
95 - 90.*Gaudi::Units::deg) < 0.0001* Gaudi::Units::deg) {
102 bool isAssembly =
false;
104 for (
int i=touchHist->GetHistoryDepth();i>=0;i--) {
106 std::string::size_type npos;
107 std::string volName = touchHist->GetVolume(i)->GetName();
108 std::string num=volName.substr(3,2);
109 if(num[0]==
' ') num[0]=0;
112 if ((npos = volName.find(
"av_")) != std::string::npos &&
113 (npos = volName.find(
"impr_")) != std::string::npos) isAssembly =
true;
116 if ((npos = volName.find(
"station")) != std::string::npos && (!isAssembly)) {
118 stationName = volName.substr(0,npos-1);
120 int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
122 if(abs(volCopyNo/1000)==1){
124 volCopyNo=volCopyNo%1000;
127 stationEta = volCopyNo/100;
128 stationPhi = abs(volCopyNo%100);
130 if(stationEta<0&&!zNeg_original) station_rotated=1;
133 }
else if ((npos = volName.find(
"RPC")) != std::string::npos && isAssembly) {
152 std::string::size_type loc1,loc2;
153 if ((loc1 = volName.find(
"Muon::")) != std::string::npos) {
154 stationName = volName.substr(loc1+6,4);
157 int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
158 int copyNrBase = int(volCopyNo/100000);
159 int sideC = int(copyNrBase/10000);
160 int zi = int((copyNrBase%1000)/100);
161 int mirfl = int((copyNrBase%10000)/1000);
162 int fi = int(copyNrBase%100);
163 if (sideC == 1) zi = -zi;
166 zNeg_original = mirfl;
168 if(stationEta<0&&!zNeg_original) station_rotated=1;
171 tech=volName.substr(npos,5);
175 if ((loc1 = volName.find(
'[')) != std::string::npos) {
176 if ((loc2 = volName.find(
']', loc1+1)) != std::string::npos) {
178 std::istringstream istrvar(volName.substr(loc1+1,loc2-loc1-1));
184 if (kk < 0) rpcIsRotated=1;
186 doubletR =(abs(kk)%1000)/100;
187 mydbZ = abs(
int(kk%10));
188 mydbPMod = abs(
int(kk/1000));
190 }
else if ((npos = volName.find(
"rpccomponent")) != std::string::npos && (!isAssembly)) {
192 std::string::size_type loc1,loc2;
193 tech=volName.substr(npos-5,5);
195 if ((loc1 = volName.find(
'[')) != std::string::npos) {
196 if ((loc2 = volName.find(
']', loc1+1)) != std::string::npos) {
197 std::istringstream istrvar(volName.substr(loc1+1,loc2-loc1-1));
201 mydbZ = abs(
int(gmID%10));
202 mydbPMod = abs(
int(gmID/1000));
204 int kk=touchHist->GetVolume(i)->GetCopyNo();
206 if (kk < 0) rpcIsRotated=1;
208 doubletR=(abs(kk)%1000)/100;
210 }
else if ((npos = volName.find(
"layer")) != std::string::npos) {
212 int copyNo = touchHist->GetVolume(i)->GetCopyNo();
215 rpcIsRotated ? gasGap = 2 : gasGap = 1;
216 }
else if (copyNo ==2) {
217 rpcIsRotated ? gasGap = 1 : gasGap = 2;
218 }
else if (copyNo ==3) {
221 }
else if((npos = volName.find(
"gas volume")) != std::string::npos) {
223 int copyNo = touchHist->GetVolume(i)->GetCopyNo();
226 }
else if (copyNo == 10) {
231 int nstrippanel_in_s=0;
232 std::string::size_type loc1;
233 if ((loc1 = volName.find(
"gg_in_s")) != std::string::npos) {
234 std::istringstream istrvar(volName.substr(loc1-1,1));
237 if ((loc1 = volName.find(
"sp_in_s")) != std::string::npos) {
238 std::istringstream istrvar(volName.substr(loc1-1,1));
239 istrvar>>nstrippanel_in_s;
241 if (ngap_in_s == 1 && nstrippanel_in_s == 2) {
242 if(localPosition.y()>0) mydbP=2;
244 }
else if (ngap_in_s == 1 && nstrippanel_in_s == 1) {
258 if (mydbP>2) mydbP=1;
273 if (verboseLevel>5) {
274 G4cout <<
"hit in station "<<stationName<<
" on technology "<<tech << G4endl;
275 G4cout <<
"constructing ids (stName, stEta, stPhi, dr, dZ, dPhi)= "<<stationName<<
" "<< stationEta<<
" " << stationPhi<<
" "<<doubletR<<
" "<< mydbZ<<
" "<<mydbP << G4endl;
278 HitID RPCid_eta =
m_muonHelper->BuildRpcHitId(stationName, stationPhi, stationEta,
279 mydbZ, doubletR, gasGap, mydbP,0);
281 HitID RPCid_phi =
m_muonHelper->BuildRpcHitId(stationName, stationPhi, stationEta,
282 mydbZ, doubletR, gasGap, mydbP,1);
292 aStep->GetTotalEnergyDeposit(),
293 aStep->GetStepLength(),
294 track->GetDefinition()->GetPDGEncoding(),
295 aStep->GetPreStepPoint()->GetKineticEnergy());
300 aStep->GetTotalEnergyDeposit(),
301 aStep->GetStepLength(),
302 track->GetDefinition()->GetPDGEncoding(),
303 aStep->GetPreStepPoint()->GetKineticEnergy());