Warning, file /geant4/examples/advanced/underground_physics/src/DMXSteppingAction.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 #include "DMXSteppingAction.hh"
0046 #include "DMXSteppingActionMessenger.hh"
0047
0048 #include "DMXEventAction.hh"
0049
0050 #include "G4AnalysisManager.hh"
0051 #include "G4RunManager.hh"
0052 #include "G4Track.hh"
0053 #include "G4Step.hh"
0054 #include "G4StepPoint.hh"
0055 #include "G4TrackStatus.hh"
0056 #include "G4ParticleDefinition.hh"
0057 #include "G4ParticleTypes.hh"
0058 #include "G4VVisManager.hh"
0059 #include "G4Colour.hh"
0060 #include "G4Polyline.hh"
0061 #include "G4VisAttributes.hh"
0062 #include "globals.hh"
0063 #include "G4ios.hh"
0064
0065
0066
0067
0068 DMXSteppingAction::DMXSteppingAction()
0069 : evtAction(0) {
0070
0071 steppingMessenger = new DMXSteppingActionMessenger(this);
0072
0073
0074 colourNeutronFlag = "magenta";
0075 colourGammaFlag = "cyan";
0076 colourOpticalFlag = "white";
0077 colourChargedPlusFlag = "red";
0078 colourChargedMinusFlag = "blue";
0079
0080 }
0081
0082
0083
0084 DMXSteppingAction::~DMXSteppingAction()
0085 {
0086
0087 delete steppingMessenger;
0088
0089 }
0090
0091
0092
0093 void DMXSteppingAction::UserSteppingAction(const G4Step* fStep)
0094 {
0095 if (!evtAction)
0096 evtAction =
0097 dynamic_cast<const DMXEventAction*>
0098 (G4RunManager::GetRunManager()->GetUserEventAction());
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108 G4int StepNo = fStep->GetTrack()->GetCurrentStepNumber();
0109 if(StepNo == 1)
0110 {
0111 G4double partEnergy = fStep->GetPreStepPoint()->GetKineticEnergy();
0112 G4ParticleDefinition* particleType = fStep->GetTrack()->GetDefinition();
0113
0114 G4AnalysisManager* man = G4AnalysisManager::Instance();
0115 if (particleType == G4Gamma::Definition())
0116 man->FillH1(8,partEnergy);
0117 else if (particleType == G4Neutron::Definition())
0118 man->FillH1(9,partEnergy);
0119 else if (particleType == G4Electron::Definition())
0120 man->FillH1(10,partEnergy);
0121 else if (particleType == G4Positron::Definition())
0122 man->FillH1(11,partEnergy);
0123 else
0124 man->FillH1(12,partEnergy);
0125 }
0126
0127
0128
0129 G4String drawColsFlag = evtAction->GetDrawColsFlag();
0130 G4String drawTrksFlag = evtAction->GetDrawTrksFlag();
0131
0132
0133 if (drawColsFlag=="custom" && drawTrksFlag!="none") {
0134
0135
0136 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
0137 if(pVVisManager) {
0138
0139
0140 G4String name = fStep->GetTrack()->GetDefinition()->GetParticleName();
0141 G4String strColour;
0142 if(name=="neutron") {
0143 if(drawTrksFlag=="charged") return;
0144 strColour = colourNeutronFlag;
0145 } else if (name=="gamma") {
0146 if(drawTrksFlag=="charged") return;
0147 strColour = colourGammaFlag;
0148 } else if (name=="opticalphoton") {
0149 if(drawTrksFlag!="all") return;
0150 strColour = colourOpticalFlag;
0151 }
0152 else if (name=="alpha" || name=="e+")
0153 strColour = colourChargedPlusFlag;
0154 else
0155 strColour = colourChargedMinusFlag;
0156
0157
0158 G4Colour colour;
0159 if (strColour=="white") colour=G4Colour(1.0, 1.0, 1.0);
0160 else if(strColour=="grey" ) colour=G4Colour(0.5, 0.5, 0.5);
0161 else if(strColour=="lgrey") colour=G4Colour(.75, .75, .75);
0162 else if(strColour=="black") colour=G4Colour(0.0, 0.0, 0.0);
0163 else if(strColour=="red") colour=G4Colour(1.0, 0.0, 0.0);
0164 else if(strColour=="green") colour=G4Colour(0.0, 1.0, 0.0);
0165 else if(strColour=="blue") colour=G4Colour(0.0, 0.0, 1.0);
0166 else if(strColour=="cyan") colour=G4Colour(0.0, 1.0, 1.0);
0167 else if(strColour=="magenta") colour=G4Colour(1.0, 0.0, 1.0);
0168 else if(strColour=="yellow") colour=G4Colour(1.0, 1.0, 0.0);
0169 else if(strColour=="lgreen") colour=G4Colour(0.0, .75, 0.0);
0170 else if(strColour=="lblue") colour=G4Colour(0.0, 0.0, .75);
0171 else colour=G4Colour(1.0, 1.0, 1.0);
0172
0173
0174 G4VisAttributes attribs(colour);
0175 G4Polyline polyline;
0176 polyline.SetVisAttributes(attribs);
0177
0178
0179 G4Point3D start(fStep->GetPreStepPoint()->GetPosition());
0180 G4Point3D end(fStep->GetPostStepPoint()->GetPosition());
0181 polyline.push_back(start);
0182 polyline.push_back(end);
0183 pVVisManager->Draw(polyline);
0184 }
0185
0186 }
0187
0188 }
0189
0190