50 G4Exception(
"CSCSensitiveDetectorCosmics::ProcessHits",
"CSCCosmicHitCollectionMissing", FatalException,
51 "Hit collection not initialized; did SetupEvent run?");
55 G4Track* currentTrack = aStep->GetTrack();
58 auto trackDef = currentTrack->GetDefinition();
59 if (trackDef->GetPDGCharge() == 0.0) {
60 if (trackDef != G4Geantino::GeantinoDefinition())
return true;
61 else if (trackDef == G4ChargedGeantino::ChargedGeantinoDefinition())
return true;
64 const G4TouchableHistory* touchHist =
static_cast<const G4TouchableHistory*
>(aStep->GetPreStepPoint()->GetTouchable());
65 G4ThreeVector startPos=aStep->GetPreStepPoint()->GetPosition();
66 G4ThreeVector endPos=aStep->GetPostStepPoint()->GetPosition();
67 double kinEnergy = aStep->GetPreStepPoint()->GetKineticEnergy();
71 std::string stationName=
"";
81 double globalTime = -1;
82 double energyDeposit= -1;
92 const double dist = globVrtx.mag();
93 const double lightspeed = 299.792458;
94 const double tOrigin = dist / lightspeed;
110 const double globalDist = sqrt((
m_globH[0] - globVrtx[0])*(
m_globH[0] - globVrtx[0]) +
113 double tof = globalDist / lightspeed;
118 bool isAssembly =
false;
119 for (
int i = touchHist->GetHistoryDepth(); i>=0; --i) {
120 std::string::size_type npos;
121 std::string volName = touchHist->GetVolume(i)->GetName();
124 if ((npos = volName.find(
"av_")) != std::string::npos &&
125 (npos = volName.find(
"impr_")) != std::string::npos) isAssembly =
true;
127 if ((npos = volName.find(
"station")) != std::string::npos && (!isAssembly)) {
130 volName.resize(npos-2);
131 int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
132 stationName = volName;
136 stationEta = (volCopyNo%1000)/100;
137 stationPhi = abs(volCopyNo%100);
139 }
else if ((npos = volName.find(
"CSC")) != std::string::npos && isAssembly ) {
157 std::string::size_type loc1,loc2;
158 if ((loc1 = volName.find(
"Muon::")) != std::string::npos) {
159 stationName = volName.substr(loc1+6,3);
163 int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
164 int copyNrBase = int(volCopyNo/100000);
165 int sideC = int(copyNrBase/10000);
166 int zi = int((copyNrBase%1000)/100);
168 int fi = int(copyNrBase%100);
169 if (sideC == 1) zi = -zi;
175 if ((loc1 = volName.find(
'[')) != std::string::npos) {
176 if ((loc2 = volName.find(
']', loc1+1)) != std::string::npos) {
177 std::istringstream istrvar(volName.substr(loc1+1,loc2-loc1-1));
183 }
else if ((npos = volName.find(
"component")) != std::string::npos && (!isAssembly)) {
186 multiLayer = touchHist->GetVolume(i)->GetCopyNo();
187 if(multiLayer==3) multiLayer=2;
189 }
else if ((npos = volName.find(
"CscArCO2")) != std::string::npos) {
192 wireLayer=touchHist->GetVolume(i)->GetCopyNo();
194 if(wireLayer==4) wireLayer=1;
195 else if(wireLayer==3) wireLayer=2;
196 else if(wireLayer==2) wireLayer=3;
197 else if(wireLayer==1) wireLayer=4;
201 G4String particle=aStep->GetTrack()->GetDefinition()->GetParticleName();
203 if (particle==
"gamma") lundcode=1;
204 else if (particle==
"e+") lundcode=2;
205 else if (particle==
"e-") lundcode=3;
206 else if (particle==
"mu+") lundcode=5;
207 else if (particle==
"mu-") lundcode=6;
208 else if (particle==
"pi+") lundcode=8;
209 else if (particle==
"pi-") lundcode=9;
210 else if (particle==
"kaon+") lundcode=11;
211 else if (particle==
"kaon-") lundcode=12;
212 else if (particle==
"proton") lundcode=14;
213 else if (particle==
"anti_proton") lundcode=15;
214 else if (particle==
"sigma+") lundcode=19;
215 else if (particle==
"sigma-") lundcode=21;
216 else if (particle==
"anti_sigma-") lundcode=27;
217 else if (particle==
"anti_sigma+") lundcode=29;
218 else if (particle==
"deuteron") lundcode=45;
219 else if (particle==
"geantino") lundcode=999;
223 globalTime = aStep->GetPreStepPoint()->GetGlobalTime();
226 energyDeposit = aStep->GetTotalEnergyDeposit();
229 const G4AffineTransform transform = touchHist->GetHistory()->GetTopTransform();
244 (((
m_vertex.mag() < 100) || ((fabs(globalTime - tOrigin)) < 0.1) ) ? (
m_globalTime = globalTime)
254 stationEta, multiLayer, wireLayer);
258 HitStart, HitEnd, lundcode,