43 G4Track* track = step->GetTrack();
48 if (track->GetVolume() == NULL) {
49 B2WARNING(
"SteppingAction: Track in NULL volume, terminating!\n"
50 <<
"step_no=" << track->GetCurrentStepNumber() <<
" type=" << track->GetDefinition()->GetParticleName()
51 <<
"\n position=" << G4BestUnit(track->GetPosition(),
"Length") <<
" momentum=" << G4BestUnit(track->GetMomentum(),
"Energy"));
52 track->SetTrackStatus(fStopAndKill);
60 const G4ThreeVector stepPrePos = step->GetPreStepPoint()->GetPosition() / CLHEP::mm *
Unit::mm;
61 const G4ThreeVector stepPostPos = step->GetPostStepPoint()->GetPosition() / CLHEP::mm *
Unit::mm;
62 if (stepPrePos.perp() < (rAbsorber *
Unit::cm) && stepPostPos.perp() > (rAbsorber *
Unit::cm)) {
66 track->SetTrackStatus(fStopAndKill);
80 B2WARNING(
"SteppingAction: Too many steps for this track, terminating!\n"
81 <<
"step_no=" << track->GetCurrentStepNumber() <<
"type=" << track->GetDefinition()->GetParticleName()
82 <<
"\n position=" << G4BestUnit(track->GetPosition(),
"Length") <<
" momentum=" << G4BestUnit(track->GetMomentum(),
"Energy"));
83 track->SetTrackStatus(fStopAndKill);
91 TrackInfo* info =
dynamic_cast<TrackInfo*
>(track->GetUserInformation());
92 if (info && info->getTrajectory()) {
94 if (trajectory.
empty()) {
95 const G4ThreeVector stepPos = step->GetPreStepPoint()->GetPosition() / CLHEP::mm *
Unit::mm;
96 const G4ThreeVector stepMom = step->GetPreStepPoint()->GetMomentum() / CLHEP::MeV *
Unit::MeV;
98 stepPos.x(), stepPos.y(), stepPos.z(),
99 stepMom.x(), stepMom.y(), stepMom.z()
102 const G4ThreeVector stepPos = step->GetPostStepPoint()->GetPosition() / CLHEP::mm *
Unit::mm;
103 const G4ThreeVector stepMom = step->GetPostStepPoint()->GetMomentum() / CLHEP::MeV *
Unit::MeV;
105 stepPos.x(), stepPos.y(), stepPos.z(),
106 stepMom.x(), stepMom.y(), stepMom.z()
118 if (eventAction ==
nullptr)
121 if (output ==
nullptr)
123 if (!output->is_open())
126 if (abs(track->GetDefinition()->GetPDGEncoding()) > 1000020040)
129 G4StepPoint* postStepPoint = step->GetPostStepPoint();
130 if (postStepPoint->GetGlobalTime() > 100.0)
133 G4StepPoint* preStepPoint = step->GetPreStepPoint();
134 double KE = preStepPoint->GetTotalEnergy() - track->GetDefinition()->GetPDGMass();
135 if ((KE < 0.0005) && (track->GetDefinition()->GetParticleName() !=
"opticalphoton"))
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";
167 }
else if (pVolName.compare(0, 15,
"StripSensitive_") == 0) {
168 sensitiveDetectorName =
"EKLM";
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() <<
","
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;
Class to save the full simulated trajectory of a particle.
void addPoint(float x, float y, float z, float px, float py, float pz)
Add a point to the trajectory.