Method to write (almost) each G4Step to the VR event file.
118{
119
122 if (eventAction == nullptr)
123 return;
124 std::ofstream* output = eventAction->getVREventStream();
125 if (output == nullptr)
126 return;
127 if (!output->is_open())
128 return;
129
130 if (abs(track->GetDefinition()->GetPDGEncoding()) > 1000020040)
131 return;
132
133 G4StepPoint* postStepPoint = step->GetPostStepPoint();
134 if (postStepPoint->GetGlobalTime() > 100.0)
135 return;
136
137 G4StepPoint* preStepPoint = step->GetPreStepPoint();
138 double KE = preStepPoint->GetTotalEnergy() - track->GetDefinition()->GetPDGMass();
139 if ((KE < 0.0005) && (track->GetDefinition()->GetParticleName() != "opticalphoton"))
140 return;
141
142
143 G4String pVolName = track->GetVolume()->GetName();
144 G4String sensitiveDetectorName = "";
145 if (pVolName.compare(0, 4, "PXD.") == 0) {
146 if (pVolName.find(".Active") != std::string::npos) { sensitiveDetectorName = "PXD"; }
147 } else if (pVolName.compare(0, 4, "SVD.") == 0) {
148 if (pVolName.find(".Active") != std::string::npos) { sensitiveDetectorName = "SVD"; }
149 } else if (pVolName.compare(0, 20, "physicalSD_CDCLayer_") == 0) {
150 sensitiveDetectorName = "CDC";
151 } else if (pVolName.compare(0, 19, "TOP.moduleSensitive") == 0) {
152 sensitiveDetectorName = "TOP";
153 } else if (pVolName.compare(0, 23, "av_1_impr_1_cuttest_pv_") == 0) {
154 sensitiveDetectorName = "TOP";
155 } else if (pVolName.compare(0, 12, "moduleWindow") == 0) {
156 sensitiveDetectorName = "ARICH";
157 } else if (pVolName.compare(0, 25, "ARICH.AerogelSupportPlate") == 0) {
158 sensitiveDetectorName = "ARICH";
159 } else if (pVolName.compare(0, 25, "eclBarrelCrystalPhysical_") == 0) {
160 sensitiveDetectorName = "ECL";
161 } else if (pVolName.compare(0, 22, "eclFwdCrystalPhysical_") == 0) {
162 sensitiveDetectorName = "ECL";
163 } else if (pVolName.compare(0, 22, "eclBwdCrystalPhysical_") == 0) {
164 sensitiveDetectorName = "ECL";
165 } else if (pVolName.compare(0, 20, "BKLM.ScintActiveType") == 0) {
166 sensitiveDetectorName = "BKLM";
167 } else if (pVolName.compare(0, 10, "BKLM.Layer") == 0) {
168 if (pVolName.find("GasPhysical") != std::string::npos) {
169 sensitiveDetectorName = "BKLM";
170 }
171 } else if (pVolName.compare(0, 15, "StripSensitive_") == 0) {
172 sensitiveDetectorName = "EKLM";
173 }
174
175
176
177
178
179
180 (*output) << std::fixed << std::setprecision(4)
181 << track->GetTrackID() << ","
182 << track->GetParentID() << ","
183 << track->GetDefinition()->GetParticleName() << ","
184 << track->GetDefinition()->GetPDGMass() << ","
185 << int(track->GetDefinition()->GetPDGCharge()) << ","
186 << track->GetCurrentStepNumber() << ","
187 << track->GetTrackStatus() << ","
188 << pVolName << ","
189 << sensitiveDetectorName << ","
190 << track->GetMaterial()->GetName() << ","
191 << step->IsFirstStepInVolume() << ","
192 << step->IsLastStepInVolume() << ","
193 << step->GetTotalEnergyDeposit() << ","
194 << postStepPoint->GetProcessDefinedStep()->GetProcessType() << ","
195 << postStepPoint->GetProcessDefinedStep()->GetProcessName() << ","
196 << preStepPoint->GetPosition().x() << ","
197 << preStepPoint->GetPosition().y() << ","
198 << preStepPoint->GetPosition().z() << ","
199 << preStepPoint->GetGlobalTime() << ","
200 << preStepPoint->GetMomentum().x() << ","
201 << preStepPoint->GetMomentum().y() << ","
202 << preStepPoint->GetMomentum().z() << ","
203 << preStepPoint->GetTotalEnergy() << ","
204 << postStepPoint->GetPosition().x() << ","
205 << postStepPoint->GetPosition().y() << ","
206 << postStepPoint->GetPosition().z() << ","
207 << postStepPoint->GetGlobalTime() << ","
208 << postStepPoint->GetMomentum().x() << ","
209 << postStepPoint->GetMomentum().y() << ","
210 << postStepPoint->GetMomentum().z() << ","
211 << postStepPoint->GetTotalEnergy() << std::endl;
212}
static RunManager & Instance()
Static method to get a reference to the RunManager instance.