38 G4Exception(
"TGCSensitiveDetector::ProcessHits",
"TGCHitCollectionMissing", FatalException,
39 "Hit collection not initialized; did SetupEvent run?");
43 G4Track* track = aStep->GetTrack();
45 if (track->GetDefinition()->GetPDGCharge() == 0.0) {
46 if (track->GetDefinition()!=G4Geantino::GeantinoDefinition())
return true;
47 else if (track->GetDefinition()==G4ChargedGeantino::ChargedGeantinoDefinition())
return true;
49 const G4TouchableHistory* touchHist =
static_cast<const G4TouchableHistory*
>(aStep->GetPreStepPoint()->GetTouchable());
50 G4ThreeVector position = aStep->GetPreStepPoint()->GetPosition();
51 const G4AffineTransform trans = track->GetTouchable()->GetHistory()->GetTopTransform();
54 std::string stationName;
60 double globalTime = aStep->GetPreStepPoint()->GetGlobalTime();
62 G4ThreeVector direcos = aStep->GetPreStepPoint()->GetMomentumDirection();
67 bool isAssembly =
false;
68 for (
int i=touchHist->GetHistoryDepth();i>=0;i--) {
70 std::string::size_type npos;
71 std::string::size_type nposStat;
72 std::string volName = touchHist->GetVolume(i)->GetName();
75 if ((npos = volName.find(
"av_")) != std::string::npos &&
76 (npos = volName.find(
"impr_")) != std::string::npos) isAssembly =
true;
79 if ((npos = volName.find(
"station")) != std::string::npos && (!isAssembly)) {
81 stationName = volName.substr(0,npos-2);
82 int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
88 if (stationName.at(2) ==
'F') {
90 stationPhi = (abs(volCopyNo%100)-1)*3;
91 if (abs(volCopyNo/100) > 3) {
92 stationPhi += abs(volCopyNo/100)-3;
94 stationPhi += abs(volCopyNo/100);
98 if (stationPhi <= 0) {
99 stationPhi = 24 - stationPhi;
102 }
else if (stationName.at(2) ==
'E') {
103 if (stationName.at(1) ==
'4') {
105 stationPhi = (abs(volCopyNo%100)-1)*3+abs(volCopyNo/100);
107 if (abs(volCopyNo%100) < 4) {
108 stationPhi = stationPhi - 1;
109 if (stationPhi <= 0) {
110 stationPhi = 21 - stationPhi;
112 }
else if(abs(volCopyNo%100) < 7) {
113 stationPhi = stationPhi - 1 - 1;
115 stationPhi = stationPhi - 2 - 1;
120 stationPhi = (abs(volCopyNo%100)-1)*6+abs(volCopyNo/100);
123 if (stationPhi <= 0) {
124 stationPhi = 48 - stationPhi;
128 }
else if ((nposStat = volName.find(
"impr_")) != std::string::npos &&
129 (npos = volName.find(
"TGC")) != std::string::npos && isAssembly ) {
147 std::string::size_type loc1,loc2;
148 if ((loc1 = volName.find(
"Muon::")) != std::string::npos) {
149 stationName = volName.substr(loc1+6,3);
152 int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
153 int copyNrBase = int(volCopyNo/100000);
154 int sideC = int(copyNrBase/10000);
155 int zi = int((copyNrBase%1000)/100);
156 if (sideC == 1) zi = -zi;
162 if (stationName.at(2) ==
'F') {
164 stationPhi = (abs(copyNrBase%100)-1)*3;
165 if (abs(copyNrBase/100) > 3) {
166 stationPhi += abs(copyNrBase/100)-3;
168 stationPhi += abs(copyNrBase/100);
172 if (stationPhi <= 0) {
173 stationPhi = 24 - stationPhi;
176 }
else if (stationName.at(2) ==
'E') {
177 if (stationName.at(1) ==
'4') {
179 stationPhi = (abs(copyNrBase%100)-1)*3+abs(copyNrBase/100);
181 if (abs(copyNrBase%100) < 4) {
182 stationPhi = stationPhi - 1;
183 if (stationPhi <= 0) {
184 stationPhi = 21 - stationPhi;
186 }
else if(abs(copyNrBase%100) < 7) {
187 stationPhi = stationPhi - 1 - 1;
189 stationPhi = stationPhi - 2 - 1;
193 stationPhi = (abs(copyNrBase%100)-1)*6+abs(copyNrBase/100);
196 if (stationPhi <= 0) {
197 stationPhi = 48 - stationPhi;
204 if ((loc1 = volName.find(
'[')) != std::string::npos) {
205 if ((loc2 = volName.find(
']', loc1+1)) != std::string::npos) {
206 std::istringstream istrvar(volName.substr(loc1+1,loc2-loc1-1));
211 stationEta = zside*int(gmID%100);
212 if (gmID > 999) stationPhi = gmID/1000;
215 }
else if ((npos = volName.find(
"tgccomponent")) != std::string::npos && (!isAssembly)) {
216 int volCopyNo = abs(touchHist->GetVolume(i)->GetCopyNo());
217 stationEta = zside*volCopyNo%100;
218 if (volCopyNo > 1000) {
219 stationPhi = volCopyNo/1000;
222 }
else if ((npos = volName.find(
"Gas Volume Layer")) != std::string::npos) {
223 int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
224 int iStation = atoi(stationName.substr(1,1).c_str());
227 gasGap = 3-(volCopyNo-3)/4;
229 gasGap = 2-(volCopyNo-3)/4;
232 gasGap = (volCopyNo-3)/4+1;
236 }
else if ((npos = volName.find(
"TGCGas")) != std::string::npos) {
238 int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
261 aStep->GetTotalEnergyDeposit(),
262 aStep->GetStepLength(),
263 track->GetDefinition()->GetPDGEncoding(),
264 aStep->GetPreStepPoint()->GetKineticEnergy());