6 #include "G4EventManager.hh" 8 #include "G4UnitsTable.hh" 9 #include "G4VFigureFileMaker.hh" 11 #include "G4GeometryManager.hh" 12 #include "G4SDManager.hh" 13 #include "G4StateManager.hh" 15 #include "G4TrajectoryContainer.hh" 17 #include "G4VisAttributes.hh" 18 #include "G4UImanager.hh" 19 #include "G4TransportationManager.hh" 20 #include "G4RegionStore.hh" 21 #include "G4ProductionCutsTable.hh" 22 #include "G4VVisManager.hh" 24 #include "G4ProcessManager.hh" 25 #include "G4ProcessVector.hh" 26 #include "G4Geantino.hh" 27 #include "G4RayShooter.hh" 29 #include "G4UserLimits.hh" 33 #include "G4VTrajectoryPoint.hh" 43 xAxis(G4ThreeVector(0.0, 0.0, 1.0)),
44 yAxis(G4ThreeVector(0.0, 1.0, 0.0)),
45 zAxis(G4ThreeVector(-1.0, 0.0, 0.0)),
54 AB(G4ThreeVector(0.0, 0.0, 0.0)),
55 AD(G4ThreeVector(0.0, 0.0, 0.0)),
56 PointA(G4ThreeVector(0.0, 0.0, 0.0)),
81 G4cout<<
"Creating worm plot: "<<fileName<<G4endl;
83 G4cout<<
"xAxis unit vector = "<<
xAxis<<G4endl;
84 G4cout<<
"yAxis unit vector = "<<
yAxis<<G4endl;
85 G4cout<<
"zAxis unit vector = "<<
zAxis<<G4endl;
86 G4cout<<
"x limits = ("<<
xMin/CLHEP::cm<<
", "<<
xMax/CLHEP::cm<<
") cm"<<G4endl;
87 G4cout<<
"y limits = ("<<
yMin/CLHEP::cm<<
", "<<
yMax/CLHEP::cm<<
") cm"<<G4endl;
88 G4cout<<
"z0 position = "<<
z0/CLHEP::cm<<
" cm"<<G4endl;
107 G4int nX(1000), nY(1000);
108 G4double dx = (
xMax -
xMin)/(nX*1.0);
109 G4double dy = (
yMax -
yMin)/(nY*1.0);
110 G4cout<<
"dx = "<<dx/CLHEP::cm<<
", dy = "<<dy/CLHEP::cm<<
" cm"<<G4endl;
113 G4VPhysicalVolume* pWorld = G4TransportationManager::GetTransportationManager()->
114 GetNavigatorForTracking()->GetWorldVolume();
115 G4RegionStore::GetInstance()->UpdateMaterialList(pWorld);
117 G4ProductionCutsTable::GetProductionCutsTable()->UpdateCoupleTable(pWorld);
119 G4ProcessVector* pVector = G4Geantino::GeantinoDefinition()->GetProcessManager()->GetProcessList();
120 for (G4int j=0; j < pVector->size(); ++j) {
121 (*pVector)[j]->BuildPhysicsTable(*(G4Geantino::GeantinoDefinition()));
125 G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
126 geomManager->OpenGeometry();
127 geomManager->CloseGeometry(1,0);
129 G4ThreeVector center(0,0,0);
130 G4Navigator* navigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
131 navigator->LocateGlobalPointAndSetup(center,0,
false);
133 G4StateManager* theStateMan = G4StateManager::GetStateManager();
134 theStateMan->SetNewState(G4State_GeomClosed);
136 TGraph* theGraph =
new TGraph();
137 theGraph->SetMarkerStyle(21);
138 theGraph->SetMarkerSize(0.02);
142 for (G4int iy = 0; iy < nY; iy++) {
145 G4ThreeVector yVect = (iy*dy +
yMin)*
yAxis;
146 G4ThreeVector rayStart = yVect + x0;
151 G4int nI = hIntersections.size();
154 for (G4int j = 0; j < nI; j++) {
156 G4ThreeVector hP = hIntersections[j];
161 theGraph->SetPoint(theGraph->GetN(), hP.dot(
xAxis)/CLHEP::cm, hP.dot(
yAxis)/CLHEP::cm);
169 for (G4int ix = 0; ix < nX; ix++) {
172 G4ThreeVector xVect = (ix*dx +
xMin)*
xAxis;
173 G4ThreeVector rayStart = xVect + y0;
178 G4int nI = vIntersections.size();
180 for (G4int j = 0; j < nI; j++) {
182 G4ThreeVector vP = vIntersections[j];
186 theGraph->SetPoint(theGraph->GetN(), vP.dot(
xAxis)/CLHEP::cm, vP.dot(
yAxis)/CLHEP::cm);
192 TCanvas theCanvas(
"theCanvas",
"", 900, 700);
193 gROOT->SetStyle(
"Plain");
194 gStyle->SetOptStat(0);
195 theCanvas.UseCurrentStyle();
200 TH2D* theHist =
new TH2D(
"axes",
"", 2,
xMin/CLHEP::cm,
xMax/CLHEP::cm, 2,
yMin/CLHEP::cm,
yMax/CLHEP::cm);
201 theHist->SetDirectory(0);
203 xLabel.ReplaceAll(
"\"",
"");
204 yLabel.ReplaceAll(
"\"",
"");
205 theHist->GetXaxis()->SetTitle(xLabel);
206 theHist->GetYaxis()->SetTitle(yLabel);
209 theGraph->Draw(
"psame");
212 theCanvas.Print(fileName);
218 theStateMan->SetNewState(G4State_Idle);
223 const G4ThreeVector& rayDirection)
const {
226 std::vector<G4ThreeVector> theIntersections;
229 G4Event* anEvent =
new G4Event(iEvent);
234 theRayShooter->Shoot(anEvent, rayStart, rayDirection.unit());
238 G4double fracCut(1e-6);
240 G4TrajectoryContainer* trajectoryContainer = anEvent->GetTrajectoryContainer();
241 if (trajectoryContainer) {
256 for (iP = 0; iP < nPoints; iP++) {
258 G4VTrajectoryPoint* thePoint = trajectory->
GetPoint(iP);
264 G4ThreeVector thePos = thePoint->GetPosition();
280 theIntersections.push_back(thePos);
284 G4int pInt2 = pInt - 1;
285 G4ThreeVector prevPos = theIntersections[pInt2];
286 G4ThreeVector diffPos = thePos - prevPos;
287 G4double d1 = prevPos.mag();
289 if (d1 > 0.0) {fracD = diffPos.mag()/d1;}
293 if (fracD < fracCut) {
297 G4ThreeVector meanPos = 0.5*(prevPos + thePos);
300 G4ThreeVector& vectPos = theIntersections[pInt2];
301 vectPos.setX(meanPos.x());
302 vectPos.setY(meanPos.y());
303 vectPos.setZ(meanPos.z());
313 theIntersections.push_back(thePos);
331 return theIntersections;
337 G4bool inside(
false);
339 G4ThreeVector AP = thePoint -
PointA;
340 G4double prod1 = AP.dot(
AB);
344 if (prod1 > 0.0 && prod1 <
ABSq) {
346 G4double prod2 = AP.dot(
AD);
350 if (prod2 > 0.0 && prod2 <
ADSq) {
void CreatePlot(const G4String &fileName)
virtual ~LBNFWormPlotter()
G4EventManager * theEventManager
virtual G4VTrajectoryPoint * GetPoint(G4int i) const
G4bool insidePlot(const G4ThreeVector &thePoint) const
std::vector< G4ThreeVector > findIntersections(const G4ThreeVector &rayPosition, const G4ThreeVector &rayDirection) const
static LBNFWormPlotMessenger * GetInstance(LBNFWormPlotter *wPlot)
G4RayShooter * theRayShooter
virtual int GetPointEntries() const
LBNFWormPlotMessenger * theMessenger