Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-11 08:29:57

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file G4BlineEventAction.cc
0027 /// \brief Implementation of the G4BlineEventAction class
0028 
0029 // --------------------------------------------------------------------
0030 //
0031 // G4BlineEventAction implementation
0032 //
0033 // --------------------------------------------------------------------
0034 // Author: Laurent Desorgher (desorgher@phim.unibe.ch)
0035 //         Created - 2003-10-06
0036 // --------------------------------------------------------------------
0037 
0038 #include "G4BlineEventAction.hh"
0039 
0040 #include "G4BlineTracer.hh"
0041 #include "G4Event.hh"
0042 #include "G4EventManager.hh"
0043 #include "G4Polyline.hh"
0044 #include "G4Polymarker.hh"
0045 #include "G4Trajectory.hh"
0046 #include "G4UImanager.hh"
0047 #include "G4VisManager.hh"
0048 
0049 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0050 
0051 G4BlineEventAction::G4BlineEventAction(G4BlineTracer* aBlineTool)
0052 {
0053   fBlineTool = aBlineTool;
0054 }
0055 
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0057 
0058 G4BlineEventAction::~G4BlineEventAction()
0059 {
0060   for (size_t i = 0; i < fTrajectoryVisAttributes.size(); i++)
0061     delete fTrajectoryVisAttributes[i];
0062 }
0063 
0064 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0065 
0066 void G4BlineEventAction::BeginOfEventAction(const G4Event*) {}
0067 
0068 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0069 
0070 void G4BlineEventAction::EndOfEventAction(const G4Event* evt)
0071 {
0072   G4TrajectoryContainer* trajectoryContainer = evt->GetTrajectoryContainer();
0073   if (trajectoryContainer) {
0074     // visualisation
0075     // -------------
0076 
0077     if (fDrawBline || fDrawPoints) {
0078       G4int n_point = (*(evt->GetTrajectoryContainer()))[0]->GetPointEntries();
0079 
0080       G4Polyline pPolyline;
0081       G4Polymarker stepPoints;
0082       fTrajectoryVisAttributes.push_back(new G4VisAttributes(fDrawColour));
0083       stepPoints.SetMarkerType(G4Polymarker::circles);
0084       stepPoints.SetScreenSize(fPointSize);
0085       stepPoints.SetFillStyle(G4VMarker::filled);
0086       stepPoints.SetVisAttributes(fTrajectoryVisAttributes.back());
0087 
0088       for (G4int i = 0; i < n_point; i++) {
0089         G4ThreeVector pos =
0090           ((G4TrajectoryPoint*)((*(evt->GetTrajectoryContainer()))[0]->GetPoint(i)))->GetPosition();
0091         if (fDrawBline) pPolyline.push_back(pos);
0092         if (fDrawPoints) stepPoints.push_back(pos);
0093       }
0094 
0095       pPolyline.SetVisAttributes(fTrajectoryVisAttributes.back());
0096 
0097       fTrajectoryPolyline.push_back(pPolyline);
0098       fTrajectoryPoints.push_back(stepPoints);
0099     }
0100   }
0101 }
0102 
0103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0104 
0105 void G4BlineEventAction::DrawFieldLines(G4double, G4double, G4double)
0106 {
0107   size_t nline = fTrajectoryPolyline.size();
0108   size_t npoints = fTrajectoryPoints.size();
0109 
0110   G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
0111   if (!pVVisManager) {
0112     G4Exception("G4BlineEventAction::DrawFieldLines()", "NullPointer", JustWarning,
0113                 "Missing visualisation driver for visualising magnetic field lines!");
0114     return;
0115   }
0116 
0117   if (nline == 0) {
0118     G4cout << "WARNING - G4BlineEventAction::DrawFieldLines()" << G4endl
0119            << "          There is nothing to visualise !" << G4endl;
0120     return;
0121   }
0122   ((G4VisManager*)pVVisManager)->GetCurrentSceneHandler()->ClearStore();
0123   G4UImanager::GetUIpointer()->ApplyCommand("/vis/drawVolume");
0124 
0125   for (size_t i = 0; i < nline; i++)
0126     pVVisManager->Draw(fTrajectoryPolyline[i]);
0127   for (size_t i = 0; i < npoints; i++)
0128     pVVisManager->Draw(fTrajectoryPoints[i]);
0129 
0130   // ((G4VisManager*)pVVisManager)->GetCurrentViewer()->DrawView();
0131   // ((G4VisManager*)pVVisManager)->GetCurrentViewer()->ShowView();
0132 }
0133 
0134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0135 
0136 void G4BlineEventAction::ResetVectorObjectToBeDrawn()
0137 {
0138   fTrajectoryVisAttributes.clear();
0139   fTrajectoryPolyline.clear();
0140   fTrajectoryPoints.clear();
0141 }