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