20 #include "G4TrackingManager.hh" 21 #include "G4EventManager.hh" 22 #include "G4VSteppingVerbose.hh" 23 #include "G4UnitsTable.hh" 27 using namespace CLHEP;
30 : theTrackingManager(nullptr), fVerbose(nullptr) {
32 fDEBUG =
p.getUntrackedParameter<
bool>(
"DEBUG",
false);
33 fHighEtPhotons =
p.getUntrackedParameter<
bool>(
"CheckForHighEtPhotons",
false);
34 fG4Verbose =
p.getUntrackedParameter<
bool>(
"G4Verbose",
false);
37 fTVEventMin =
p.getUntrackedParameter<
int>(
"EventMin", 0);
42 fTVTrackMin =
p.getUntrackedParameter<
int>(
"TrackMin", 0);
48 fPdgIds =
p.getUntrackedParameter<std::vector<int> >(
"PDGids");
62 G4cout <<
" TrackingVerbose constructed " << G4endl;
73 fVerbose = G4VSteppingVerbose::GetInstance();
82 const G4Event* anEvent = (*evt)();
83 if (anEvent ==
nullptr)
87 int eventNo = anEvent->GetEventID();
89 G4cout <<
"TV: trackID: NEW EVENT " << eventNo << G4endl;
107 G4cout <<
"TV: VERBOSEet1 " << eventNo << G4endl;
113 G4cout <<
"TV: VERBOSEet0 " << eventNo << G4endl;
118 const G4Track* aTrack = (*trk)();
123 double tkP = aTrack->GetMomentum().mag();
124 double tkPx = aTrack->GetMomentum().x();
125 double tkPy = aTrack->GetMomentum().y();
126 double tkPz = aTrack->GetMomentum().z();
128 double tvtx = aTrack->GetVertexPosition().x();
129 double tvty = aTrack->GetVertexPosition().y();
130 double tvtz = aTrack->GetVertexPosition().z();
132 double g4t_phi = atan2(tkPy, tkPx);
134 double drpart =
sqrt(tkPx * tkPx + tkPy * tkPy);
136 double mythetapart = acos(tkPz /
sqrt(drpart * drpart + tkPz * tkPz));
138 double g4t_eta = -
log(
tan(mythetapart / 2.));
139 G4int MytrackNo = aTrack->GetTrackID();
142 if (aTrack->GetDefinition()->GetParticleName() ==
"gamma" && aTrack->GetParentID() != 0) {
143 if ((tkPx * tkPx + tkPy * tkPy + tkPz * tkPz) > 1000.0 * 1000.0 &&
144 aTrack->GetCreatorProcess()->GetProcessName() ==
"LCapture") {
145 G4cout <<
"MY NEW GAMMA " << G4endl;
146 G4cout <<
"**********************************************************************" << G4endl;
147 G4cout <<
"MY NEW TRACK ID = " << MytrackNo <<
"(" << aTrack->GetDefinition()->GetParticleName() <<
")" 148 <<
" PARENT =" << aTrack->GetParentID() << G4endl;
149 G4cout <<
"Primary particle: " << aTrack->GetDynamicParticle()->GetPrimaryParticle() << G4endl;
150 G4cout <<
"Process type: " << aTrack->GetCreatorProcess()->GetProcessType()
151 <<
" Process name: " << aTrack->GetCreatorProcess()->GetProcessName() << G4endl;
152 G4cout <<
"ToT E = " << aTrack->GetTotalEnergy() <<
" KineE = " << aTrack->GetKineticEnergy()
153 <<
" Tot P = " << tkP <<
" Pt = " <<
sqrt(tkPx * tkPx + tkPy * tkPy) <<
" VTX=(" << tvtx <<
"," << tvty
154 <<
"," << tvtz <<
")" << G4endl;
155 if (aTrack->GetKineticEnergy() > 1. * GeV && aTrack->GetCreatorProcess()->GetProcessName() !=
"LCapture")
156 G4cout <<
" KineE > 1 GeV !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << G4endl;
157 const G4VTouchable* touchable = aTrack->GetTouchable();
158 if (touchable !=
nullptr && touchable->GetVolume() !=
nullptr &&
159 touchable->GetVolume()->GetLogicalVolume() !=
nullptr) {
160 G4Material* material = touchable->GetVolume()->GetLogicalVolume()->GetMaterial();
161 G4cout <<
"G4LCapture Gamma E(GeV) " << aTrack->GetTotalEnergy() / GeV <<
" " << material->GetName() <<
" " 162 << touchable->GetVolume()->GetName() << G4endl;
163 G4cout <<
"G4LCapture Gamma position(m): " << aTrack->GetPosition() /
m << G4endl;
164 G4cout <<
"G4LCapture created Gamma direction " << aTrack->GetMomentumDirection() << G4endl;
165 G4cout <<
"G4LCapture gamma (eta,phi) = " 166 <<
"(" << g4t_eta <<
"," << g4t_phi <<
")" << G4endl;
168 aTrack->GetUserInformation()->Print();
169 G4cout <<
"**********************************************************************" << G4endl;
173 if (aTrack->GetDefinition()->GetParticleName() ==
"gamma") {
174 const G4VProcess*
proc = aTrack->GetCreatorProcess();
175 double Tgamma = aTrack->GetKineticEnergy();
179 ProcName =
proc->GetProcessName();
182 if (Tgamma > 2.5 * GeV) {
185 G4Material* material =
nullptr;
186 G4VPhysicalVolume* pvolume =
nullptr;
187 G4LogicalVolume* lvolume =
nullptr;
188 const G4VTouchable* touchable = aTrack->GetTouchable();
190 pvolume = touchable->GetVolume();
192 volumeName = pvolume->GetName();
193 lvolume = pvolume->GetLogicalVolume();
196 material = lvolume->GetMaterial();
198 materialName = material->GetName();
199 G4cout <<
"**** ALL photons > 2.5 GeV ****" << G4endl;
200 G4cout << ProcName <<
"**** ALL photons: gamma E(GeV) " << aTrack->GetTotalEnergy() / GeV <<
" " 201 << materialName <<
" " << volumeName << G4endl;
202 G4cout << ProcName <<
"**** ALL photons: gamma position(m): " << aTrack->GetPosition() /
m << G4endl;
203 G4cout << ProcName <<
"**** ALL photons: gamma direction " << aTrack->GetMomentumDirection() << G4endl;
204 G4cout <<
"**********************************************************************" << G4endl;
219 G4cout <<
"TV: VERBOSEtt1 " << aTrack->GetTrackID() << G4endl;
225 G4cout <<
"TV: VERBOSEtt0 " << aTrack->GetTrackID() << G4endl;
231 const G4Track* aTrack = (*trk)();
238 G4cout <<
"TV: VERBOSEtt0 " << aTrack->GetTrackID() << G4endl;
245 G4Track* fTrack = fStep->GetTrack();
246 G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() <<
" " << std::setw(8)
247 << G4BestUnit(fTrack->GetPosition().x(),
"Length") <<
" " << std::setw(8)
248 << G4BestUnit(fTrack->GetPosition().y(),
"Length") <<
" " << std::setw(8)
249 << G4BestUnit(fTrack->GetPosition().z(),
"Length") <<
" " << std::setw(9)
250 << G4BestUnit(fTrack->GetKineticEnergy(),
"Energy") <<
" " << std::setw(8)
251 << G4BestUnit(fStep->GetTotalEnergyDeposit(),
"Energy") <<
" " << std::setw(8)
252 << G4BestUnit(fStep->GetStepLength(),
"Length") <<
" " << std::setw(9)
253 << G4BestUnit(fTrack->GetTrackLength(),
"Length") <<
" " << std::setw(9)
254 << G4BestUnit(fTrack->GetGlobalTime(),
"Time") <<
" ";
257 if (fTrack->GetNextVolume() !=
nullptr) {
258 G4cout << std::setw(11) << fTrack->GetNextVolume()->GetName() <<
" ";
260 G4cout << std::setw(11) <<
"OutOfWorld" 263 if (fStep->GetPostStepPoint()->GetProcessDefinedStep() !=
nullptr) {
264 G4cout << fStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName();
274 G4cout <<
" setting verbose level " << verblev << G4endl;
280 int trackNo = aTrack->GetTrackID();
281 bool trackingVerboseThisTrack =
false;
285 trackingVerboseThisTrack =
true;
287 if (trackingVerboseThisTrack && (!
fPdgIds.empty())) {
288 int pdgId = aTrack->GetDefinition()->GetPDGEncoding();
290 trackingVerboseThisTrack =
false;
292 return trackingVerboseThisTrack;
296 G4cout << G4endl <<
"*******************************************************" 297 <<
"**************************************************" << G4endl <<
"* G4Track Information: " 298 <<
" Particle = " << aTrack->GetDefinition()->GetParticleName() <<
"," 299 <<
" Track ID = " << aTrack->GetTrackID() <<
"," 300 <<
" Parent ID = " << aTrack->GetParentID() << G4endl
301 <<
"*******************************************************" 302 <<
"**************************************************" << G4endl << G4endl;
std::vector< int > fPdgIds
bool checkTrackingVerbose(const G4Track *)
void printTrackInfo(const G4Track *)
G4TrackingManager * theTrackingManager
Tan< T >::type tan(const T &t)
void update(const BeginOfRun *) override
This routine will be called when the appropriate signal arrives.
~TrackingVerboseAction() override
G4VSteppingVerbose * fVerbose
void setTrackingVerbose(int verblev)
TrackingVerboseAction(edm::ParameterSet const &p)