problems with git merge

parent a7fecbde
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(cosmic-rays)
#----------------------------------------------------------------------------
# Find Geant4 package, activating all available UI and Vis drivers by default
# You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake/cmake-gui
# to build a batch mode only executable
#
option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
if(WITH_GEANT4_UIVIS)
find_package(Geant4 REQUIRED ui_all vis_all)
else()
find_package(Geant4 REQUIRED)
endif()
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
# Setup include directory for this project
#
include(${Geant4_USE_FILE})
include_directories(${PROJECT_SOURCE_DIR}/include)
#----------------------------------------------------------------------------
# Locate sources and headers for this project
# NB: headers are included so they will show up in IDEs
#
set(PROJECT_SRC
<<<<<<< HEAD
src/ActionInitialization.cc
src/DetectorConstruction.cc
src/EventAction.cc
src/PrimaryGeneratorAction.cc
src/RunAction.cc
src/SteppingAction.cc
)
set(PROJECT_HEADER
include/ActionInitialization.hh
include/DetectorConstruction.hh
include/EventAction.hh
include/PrimaryGeneratorAction.hh
include/RunAction.hh
include/SteppingAction.hh
include/Analysis.hh
=======
src/B1ActionInitialization.cc
src/B1DetectorConstruction.cc
src/B1EventAction.cc
src/B1PrimaryGeneratorAction.cc
src/B1RunAction.cc
src/B1SteppingAction.cc
src/B1TrackingAction.cc
)
set(PROJECT_HEADER
include/B1ActionInitialization.hh
include/B1DetectorConstruction.hh
include/B1EventAction.hh
include/B1PrimaryGeneratorAction.hh
include/B1RunAction.hh
include/B1SteppingAction.hh
include/B1Analysis.hh
include/B1TrackingAction.hh
>>>>>>> print_particles
)
#----------------------------------------------------------------------------
# Add the executable, and link it to the Geant4 libraries
#
add_executable(cosmic_rays cosmic_rays.cc ${PROJECT_SRC} ${PROJECT_HEADER})
target_link_libraries(cosmic_rays ${Geant4_LIBRARIES})
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build B1. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
#
set(EXAMPLEB1_SCRIPTS
init_vis.mac
run1.mac
run2.mac
vis.mac
)
foreach(_script ${EXAMPLEB1_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS cosmic_rays DESTINATION bin)
# Macro file for example B1 test
/run/initialize
# proton 100 TeV
/gun/particle proton
/gun/energy 100 TeV
#
/run/beamOn 10
This diff is collapsed.
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file B1ActionInitialization.hh
/// \brief Definition of the B1ActionInitialization class
#ifndef ActionInitialization_h
#define ActionInitialization_h 1
#include "G4VUserActionInitialization.hh"
/// Action initialization class.
class B1DetectorConstruction;
class ActionInitialization : public G4VUserActionInitialization
{
private:
B1DetectorConstruction* fDetectorConstruction;
public:
<<<<<<< HEAD:include/ActionInitialization.hh
ActionInitialization();
virtual ~ActionInitialization();
=======
B1ActionInitialization(B1DetectorConstruction *Detector);
virtual ~B1ActionInitialization();
>>>>>>> print_particles:include/B1ActionInitialization.hh
virtual void BuildForMaster() const;
virtual void Build() const;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
#ifndef Analysis_h
#define Analysis_h 1
//Como vamos utilizar o root como software de análise de dados:
#include "g4root.hh"
#endif
#ifndef TrackingAction_h
#define TrackingAction_h
#include "G4UserTrackingAction.hh"
#include "G4LogicalVolume.hh"
#include <map>
class G4Region;
class G4ParticleDefinition;
class B1DetectorConstruction;
class B1TrackingAction : public G4UserTrackingAction
{
private:
//aqui ficam as variáveis da classe
B1DetectorConstruction* fworld;
G4Region* fworldRegion;
G4LogicalVolume* worldVolume;
const G4ParticleDefinition* particle_def;
std::map<const G4ParticleDefinition*, int> fNParticleOutsideWorld;
std::map<const G4ParticleDefinition*, int> fNParticleInWorld;
public:
//aqui ficam as funçes que a classe terá
B1TrackingAction(B1DetectorConstruction* world); //construtor
~B1TrackingAction(); //destrutor
virtual void PreUserTrackingAction(const G4Track* track);
std::map<const G4ParticleDefinition*, int>& GetNParticlesCreatedOutsideWorld()
{
return fNParticleOutsideWorld;
}
std::map<const G4ParticleDefinition*, int>& GetNParticlesCreatedInWorld()
{
return fNParticleInWorld;
}
void clearParticles();
};
#endif
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file B1DetectorConstruction.hh
/// \brief Definition of the B1DetectorConstruction class
#ifndef DetectorConstruction_h
#define DetectorConstruction_h 1
#include "G4VUserDetectorConstruction.hh"
#include "globals.hh"
class G4VPhysicalVolume;
class G4LogicalVolume;
/// Detector construction class to define materials and geometry.
class DetectorConstruction : public G4VUserDetectorConstruction
{
public:
DetectorConstruction();
virtual ~DetectorConstruction();
virtual G4VPhysicalVolume* Construct();
G4LogicalVolume* GetScoringVolume() const { return fScoringVolume; }
protected:
G4LogicalVolume* fScoringVolume;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file B1EventAction.hh
/// \brief Definition of the B1EventAction class
#ifndef EventAction_h
#define EventAction_h 1
#include "G4UserEventAction.hh"
#include "globals.hh"
class RunAction;
/// Event action class
///
class EventAction : public G4UserEventAction
{
public:
EventAction(RunAction* runAction);
virtual ~EventAction();
virtual void BeginOfEventAction(const G4Event* event);
virtual void EndOfEventAction(const G4Event* event);
void AddEdep(G4double edep) { fEdep += edep; }
private:
RunAction* fRunAction;
G4double fEdep;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file B1PrimaryGeneratorAction.hh
/// \brief Definition of the B1PrimaryGeneratorAction class
#ifndef PrimaryGeneratorAction_h
#define PrimaryGeneratorAction_h 1
#include "G4VUserPrimaryGeneratorAction.hh"
#include "G4ParticleGun.hh"
#include "globals.hh"
class G4ParticleGun;
class G4Event;
class G4Box;
/// The primary generator action class with particle gun.
///
/// The default kinematic is a 6 MeV gamma, randomly distribued
/// in front of the phantom across 80% of the (X,Y) phantom size.
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
PrimaryGeneratorAction();
virtual ~PrimaryGeneratorAction();
// method from the base class
virtual void GeneratePrimaries(G4Event*);
// method to access particle gun
const G4ParticleGun* GetParticleGun() const { return fParticleGun; }
private:
G4ParticleGun* fParticleGun; // pointer a to G4 gun class
G4Box* fEnvelopeBox;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file B1RunAction.hh
/// \brief Definition of the B1RunAction class
#ifndef RunAction_h
#define RunAction_h 1
#include "G4UserRunAction.hh"
#include "G4ParticleDefinition.hh"
#include "G4Accumulable.hh"
#include "globals.hh"
#include <map>
class G4Run;
class B1TrackingAction;
/// Run action class
///
/// In EndOfRunAction(), it calculates the dose in the selected volume
/// from the energy deposit accumulated via stepping and event actions.
/// The computed dose is then printed on the screen.
class RunAction : public G4UserRunAction
{
public:
RunAction();
virtual ~RunAction();
// virtual G4Run* GenerateRun();
virtual void BeginOfRunAction(const G4Run*);
virtual void EndOfRunAction(const G4Run*);
void PrintParticles(std::map<const G4ParticleDefinition*, int>& container);
void AddEdep (G4double edep);
private:
//adiciona mais duas instâncias da classe
void createHistogram();
void WriteHistogram();
G4Accumulable<G4double> fEdep;
G4Accumulable<G4double> fEdep2;
B1TrackingAction* fptrackingAction;
};
#endif
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file B1SteppingAction.hh
/// \brief Definition of the B1SteppingAction class
#ifndef SteppingAction_h
#define SteppingAction_h 1
#include "G4UserSteppingAction.hh"
#include "globals.hh"
class EventAction;
class G4LogicalVolume;
/// Stepping action class
///
class SteppingAction : public G4UserSteppingAction
{
public:
SteppingAction(EventAction* eventAction);
virtual ~SteppingAction();
// method from the base class
virtual void UserSteppingAction(const G4Step*);
private:
EventAction* fEventAction;
G4LogicalVolume* fScoringVolume;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file B1ActionInitialization.cc
/// \brief Implementation of the B1ActionInitialization class
<<<<<<< HEAD:src/ActionInitialization.cc
#include "ActionInitialization.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "EventAction.hh"
#include "SteppingAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ActionInitialization::ActionInitialization()
: G4VUserActionInitialization()
=======
#include "B1ActionInitialization.hh"
#include "B1PrimaryGeneratorAction.hh"
#include "B1RunAction.hh"
#include "B1EventAction.hh"
#include "B1SteppingAction.hh"
#include "B1TrackingAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B1ActionInitialization::B1ActionInitialization(B1DetectorConstruction *Detector)
: G4VUserActionInitialization(),
fDetectorConstruction(Detector)
>>>>>>> print_particles:src/B1ActionInitialization.cc
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ActionInitialization::~ActionInitialization()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ActionInitialization::BuildForMaster() const
{
RunAction* runAction = new RunAction;
SetUserAction(runAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ActionInitialization::Build() const
{
SetUserAction(new PrimaryGeneratorAction);
<<<<<<< HEAD:src/ActionInitialization.cc
RunAction* runAction = new RunAction;
SetUserAction(runAction);
EventAction* eventAction = new EventAction(runAction);
SetUserAction(eventAction);
SetUserAction(new SteppingAction(eventAction));
}
=======
//adicionando Tracking Action
B1TrackingAction* trackingAction = new B1TrackingAction(fDetectorConstruction); //cria objeto trackingAction, da classe B1TrackingAction
SetUserAction(trackingAction);
B1RunAction* runAction = new B1RunAction;
SetUserAction(runAction);
B1EventAction* eventAction = new B1EventAction(runAction);
SetUserAction(eventAction);
SetUserAction(new B1SteppingAction(eventAction));
}
>>>>>>> print_particles:src/B1ActionInitialization.cc
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "B1TrackingAction.hh"
#include "G4Track.hh"
#include "G4VSolid.hh"
#include "G4Region.hh"
#include "B1DetectorConstruction.hh"
using namespace std;
//implementação do construtor
B1TrackingAction::B1TrackingAction(B1DetectorConstruction* world) {
fworld = world;
fworldRegion = 0;
worldVolume = 0;
}
//implementação do destrutor
B1TrackingAction::~B1TrackingAction() {
fworld = 0;
fworldRegion = 0;
worldVolume = 0;
}
//implementação da função(instância da classe B1TrackingAction) PreUserTrackingAction
void B1TrackingAction::PreUserTrackingAction(const G4Track* track) {
//pega o nome da partícula relacionado ao seu TrackID.
particle_def = track->GetParticleDefinition();
//const G4String& particle_name = particle_def->GetParticleName();
//se a variável fworldRegio não possui a regiao do mundo, fazer isso
if(fworldRegion == 0) {
worldVolume= fworld->GetScoringVolume();
fworldRegion = worldVolume->GetRegion();
}
const G4ThreeVector& position = track->GetPosition();
int N = fworldRegion->GetNumberOfRootVolumes();
std::vector<G4LogicalVolume*>::iterator it_logicalVolumeInRegion = fworldRegion->GetRootLogicalVolumeIterator();
bool inside_world = false;
//checar se está dentro do mundo
for(int i = 0; i < N ; i++, it_logicalVolumeInRegion++)
{
EInside test_status = (*it_logicalVolumeInRegion)->GetSolid()->Inside(position) ;
if(test_status == kInside)
{
inside_world = true;
break;
}
}
//coloca eles no std::map
if (inside_world) {
fNParticleInWorld[particle_def]++;
} else {
fNParticleOutsideWorld[particle_def]++;
}
}
void B1TrackingAction::clearParticles() {
fNParticleInWorld.clear();
fNParticleOutsideWorld.clear();
}
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file B1DetectorConstruction.cc
/// \brief Implementation of the B1DetectorConstruction class
#include "DetectorConstruction.hh"
#include "G4RunManager.hh"
#include "G4NistManager.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4Cons.hh"
#include "G4Orb.hh"
#include "G4Sphere.hh"
#include "G4Trd.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"