20 #include "G4TrackingManager.hh"
21 #include "G4EventManager.hh"
22 #include "G4VSteppingVerbose.hh"
23 #include "G4UnitsTable.hh"
27 using namespace CLHEP;
30 theTrackingManager(0), fVerbose(0) {
51 G4cout <<
"TV: fTVTrackMin " << fTVTrackMin
52 <<
" fTVTrackMax " << fTVTrackMax
53 <<
" fTVTrackStep " << fTVTrackStep
54 <<
" fTVEventMin " << fTVEventMin
55 <<
" fTVEventMax " << fTVEventMax
56 <<
" fTVEventStep " << fTVEventStep
57 <<
" fVerboseLevel " << fVerboseLevel
58 <<
" fG4Verbose " << fG4Verbose
59 <<
" PDGIds " << fPdgIds.size() << G4endl;
60 for (
unsigned int ii=0;
ii<fPdgIds.size(); ++
ii)
61 G4cout <<
"TV: PDGId[" <<
ii <<
"] = " << fPdgIds[
ii] << G4endl;
68 G4cout <<
" TrackingVerbose constructed " << G4endl;
75 dynamic_cast<TrackingAction*
>(G4EventManager::GetEventManager()->GetUserTrackingAction());
77 fVerbose = G4VSteppingVerbose::GetInstance();
80 <<
" and the SteppingVerbose: " <<
fVerbose << G4endl;
85 const G4Event * anEvent = (*evt)();
86 if (anEvent==0)
return;
89 int eventNo = anEvent->GetEventID();
90 if (
fDEBUG) G4cout <<
"TV: trackID: NEW EVENT " << eventNo << G4endl;
107 if (
fDEBUG) G4cout <<
"TV: VERBOSEet1 " << eventNo << G4endl;
112 if (
fDEBUG) 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 <<
"("
148 << aTrack->GetDefinition()->GetParticleName()
149 <<
")"<<
" PARENT ="<< aTrack->GetParentID() << G4endl;
150 G4cout <<
"Primary particle: "
151 << aTrack->GetDynamicParticle()->GetPrimaryParticle() << G4endl;
152 G4cout <<
"Process type: " << aTrack->GetCreatorProcess()->GetProcessType()
154 << aTrack->GetCreatorProcess()->GetProcessName() << G4endl;
155 G4cout <<
"ToT E = " << aTrack->GetTotalEnergy()
156 <<
" KineE = " << aTrack->GetKineticEnergy()
157 <<
" Tot P = " << tkP <<
" Pt = " <<
sqrt(tkPx*tkPx + tkPy*tkPy)
158 <<
" VTX=(" << tvtx <<
"," << tvty <<
"," << tvtz <<
")" << G4endl;
159 if (aTrack->GetKineticEnergy() > 1.*
GeV
160 && aTrack->GetCreatorProcess()->GetProcessName() !=
"LCapture")
161 G4cout <<
" KineE > 1 GeV !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << G4endl;
162 const G4VTouchable* touchable=aTrack->GetTouchable();
163 if (touchable!=0 && touchable->GetVolume()!=0 &&
164 touchable->GetVolume()->GetLogicalVolume()!=0) {
165 G4Material* material=touchable->GetVolume()->GetLogicalVolume()->GetMaterial();
166 G4cout <<
"G4LCapture Gamma E(GeV) "
167 << aTrack->GetTotalEnergy()/
GeV <<
" "
168 << material->GetName()<<
" "
169 << touchable->GetVolume()->GetName() << G4endl;
170 G4cout <<
"G4LCapture Gamma position(m): "
171 << aTrack->GetPosition()/
m << G4endl;
172 G4cout <<
"G4LCapture created Gamma direction "
173 << aTrack->GetMomentumDirection() << G4endl;
174 G4cout <<
"G4LCapture gamma (eta,phi) = "
175 <<
"(" << g4t_eta <<
"," << g4t_phi <<
")" << G4endl;
177 aTrack->GetUserInformation()->Print();
178 G4cout <<
"**********************************************************************" << G4endl;
182 if (aTrack->GetDefinition()->GetParticleName() ==
"gamma") {
183 const G4VProcess *
proc = aTrack->GetCreatorProcess();
184 double Tgamma = aTrack->GetKineticEnergy();
187 if (proc) ProcName = proc->GetProcessName();
188 else ProcName = nullstr;
189 if (Tgamma > 2.5*
GeV ) {
192 G4Material * material = 0;
193 G4VPhysicalVolume * pvolume = 0;
194 G4LogicalVolume * lvolume = 0;
195 const G4VTouchable * touchable = aTrack->GetTouchable();
196 if (touchable) pvolume = touchable->GetVolume();
198 volumeName = pvolume->GetName();
199 lvolume = pvolume->GetLogicalVolume();
201 if (lvolume) material = lvolume->GetMaterial();
202 if (material) materialName = material->GetName();
203 G4cout <<
"**** ALL photons > 2.5 GeV ****" << G4endl;
204 G4cout << ProcName <<
"**** ALL photons: gamma E(GeV) "
205 << aTrack->GetTotalEnergy()/
GeV <<
" "
206 << materialName <<
" " << volumeName << G4endl;
207 G4cout << ProcName <<
"**** ALL photons: gamma position(m): "
208 << aTrack->GetPosition()/
m << G4endl;
209 G4cout << ProcName <<
"**** ALL photons: gamma direction "
210 << aTrack->GetMomentumDirection() << G4endl;
211 G4cout <<
"**********************************************************************" << G4endl;
225 if (
fDEBUG) G4cout <<
"TV: VERBOSEtt1 " << aTrack->GetTrackID()
231 if (
fDEBUG) G4cout <<
"TV: VERBOSEtt0 " << aTrack->GetTrackID()
238 const G4Track * aTrack = (*trk)();
245 if (
fDEBUG) G4cout <<
"TV: VERBOSEtt0 " << aTrack->GetTrackID()
254 G4Track* fTrack = fStep->GetTrack();
255 G4cout << std::setw( 5) << fTrack->GetCurrentStepNumber() <<
" "
256 << std::setw( 8) << G4BestUnit(fTrack->GetPosition().x() ,
"Length") <<
" "
257 << std::setw( 8) << G4BestUnit(fTrack->GetPosition().y() ,
"Length") <<
" "
258 << std::setw( 8) << G4BestUnit(fTrack->GetPosition().z() ,
"Length") <<
" "
259 << std::setw( 9) << G4BestUnit(fTrack->GetKineticEnergy() ,
"Energy") <<
" "
260 << std::setw( 8) << G4BestUnit(fStep->GetTotalEnergyDeposit(),
"Energy") <<
" "
261 << std::setw( 8) << G4BestUnit(fStep->GetStepLength() ,
"Length") <<
" "
262 << std::setw( 9) << G4BestUnit(fTrack->GetTrackLength() ,
"Length") <<
" "
263 << std::setw( 9) << G4BestUnit(fTrack->GetGlobalTime(),
"Time") <<
" ";
266 if( fTrack->GetNextVolume() != 0 ) {
267 G4cout << std::setw(11) << fTrack->GetNextVolume()->GetName() <<
" ";
269 G4cout << std::setw(11) <<
"OutOfWorld" <<
" ";
271 if(fStep->GetPostStepPoint()->GetProcessDefinedStep() !=
NULL){
272 G4cout << fStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName();
274 G4cout <<
"User Limit";
281 if (
fDEBUG) G4cout <<
" setting verbose level " << verblev << G4endl;
286 int trackNo = aTrack->GetTrackID();
287 bool trackingVerboseThisTrack =
false;
292 if (trackingVerboseThisTrack && (
fPdgIds.size()>0)) {
293 int pdgId = aTrack->GetDefinition()->GetPDGEncoding();
296 return trackingVerboseThisTrack;
301 <<
"*******************************************************"
302 <<
"**************************************************" << G4endl
303 <<
"* G4Track Information: "
304 <<
" Particle = " << aTrack->GetDefinition()->GetParticleName()
306 <<
" Track ID = " << aTrack->GetTrackID()
308 <<
" Parent ID = " << aTrack->GetParentID() << G4endl
309 <<
"*******************************************************"
310 <<
"**************************************************"
T getUntrackedParameter(std::string const &, T const &) const
TrainProcessor *const proc
std::vector< int > fPdgIds
bool checkTrackingVerbose(const G4Track *)
G4TrackingManager * getTrackManager()
void printTrackInfo(const G4Track *)
G4TrackingManager * theTrackingManager
Tan< T >::type tan(const T &t)
G4VSteppingVerbose * fVerbose
void update(const BeginOfRun *)
This routine will be called when the appropriate signal arrives.
void setTrackingVerbose(int verblev)
TrackingVerboseAction(edm::ParameterSet const &p)