Skip to content
Snippets Groups Projects
Commit 66b72072 authored by clantz's avatar clantz
Browse files

Finished adding SD. Working on recording data

parent 601ca073
No related branches found
No related tags found
No related merge requests found
......@@ -14,11 +14,16 @@ if(WITH_GEANT4_UIVIS)
else()
find_package(Geant4 REQUIRED)
endif()
#----------------------------------------------------------------------------
# Find ROOT
list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
find_package (ROOT REQUIRED)
include(${ROOT_USE_FILE})
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
#
include(${Geant4_USE_FILE})
include(${Geant4_USE_FILE} )
#----------------------------------------------------------------------------
# Locate sources and headers for this project
......@@ -32,7 +37,7 @@ file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
# Add the executable, and link it to the Geant4 libraries
#
add_executable(OpNovice OpNovice.cc ${sources} ${headers})
target_link_libraries(OpNovice ${Geant4_LIBRARIES} )
target_link_libraries(OpNovice ${Geant4_LIBRARIES} ${ROOT_LIBRARIES} )
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
......
......@@ -29,8 +29,7 @@
#define AirSD_h 1
#include "G4VSensitiveDetector.hh"
#include "RpdHit.hh"
#include "FiberHit.hh"
#include "AirHit.hh"
#include "TH1D.h"
#include "TH2D.h"
......@@ -43,11 +42,9 @@ class G4HCofThisEvent;
class AirSD : public G4VSensitiveDetector
{
public:
AirSD(G4String, G4int);
AirSD(G4String);
~AirSD();
void HistInitialize();
void Initialize(G4HCofThisEvent*);
G4bool ProcessHits(G4Step*, G4TouchableHistory*);
void EndOfEvent(G4HCofThisEvent*);
......
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// January 22, 2012
// Yakov Kulinich
// Stony Brook & BNL
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef Hit_h
#define Hit_h 1
#include "G4VHit.hh"
#include "G4THitsCollection.hh"
#include "G4Allocator.hh"
#include "G4ThreeVector.hh"
#include "G4ParticleDefinition.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class Hit : public G4VHit
{
public:
Hit();
~Hit();
Hit(const Hit&);
const Hit& operator=(const Hit&);
G4int operator==(const Hit&) const;
inline void* operator new(size_t);
inline void operator delete(void*);
void Draw();
void Print();
public:
void setTrackID (G4int track) { trackID = track; }
void setModNb (G4int mod) { modNb = mod; }
void setRadNb (G4int rad) { radNb = rad; }
void setRodNb (G4int rod) { rodNb = rod; }
void setEdep (G4double de) { edep = de; }
void setPos (G4ThreeVector xyz) { pos = xyz; }
void setMomentum (G4ThreeVector mom) { momentum = mom;}
void setParticle (G4ParticleDefinition *part) {particle = part;}
void setEnergy (G4double e) {energy = e;}
void setCharge (G4double c) {charge = c;}
void setNCherenkovs (G4int n) {nCherenkovs = n;}
G4int getTrackID() { return trackID; }
G4int getModNb() { return modNb; }
G4int getRadNb() { return radNb; }
G4int getRodNb() { return rodNb; }
G4int getNCherenkovs() { return nCherenkovs; }
G4double getEdep() { return edep; }
G4ThreeVector getPos() { return pos; }
G4ParticleDefinition* getParticle() { return particle; }
G4double getEnergy() { return energy; }
G4ThreeVector getMomentum() { return momentum; }
G4double getCharge() {return charge;}
G4double getVelocity() {return velocity;}
G4double getBeta() {return beta;}
private:
G4int trackID;
G4int modNb;
G4int radNb;
G4int rodNb;
G4double velocity;
G4double beta;
G4int nCherenkovs;
G4double edep;
G4ThreeVector pos;
G4ParticleDefinition *particle;
G4ThreeVector momentum;
G4double energy;
G4double charge;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
typedef G4THitsCollection<Hit> HitsCollection;
extern G4Allocator<Hit> HitAllocator;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
inline void* Hit::operator new(size_t)
{
void *aHit;
aHit = (void *) HitAllocator.MallocSingle();
return aHit;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
inline void Hit::operator delete(void *aHit)
{
HitAllocator.FreeSingle((Hit*) aHit);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
......@@ -25,6 +25,7 @@
// @Author Chad Lantz
#include "AirSD.hh"
#include "AirHit.hh"
#include "G4HCofThisEvent.hh"
#include "G4Step.hh"
......@@ -45,8 +46,8 @@
/*
*
*/
FiberSD::FiberSD(G4String sdName, G4int modNum)
:G4VSensitiveDetector(sdName) m_modNum(modNum) {
AirSD::AirSD(G4String sdName)
:G4VSensitiveDetector(sdName){
collectionName.insert(sdName);
HCID = -1;
......@@ -56,23 +57,17 @@ FiberSD::FiberSD(G4String sdName, G4int modNum)
/*
*
*/
FiberSD::~FiberSD(){ }
AirSD::~AirSD(){
/*
*
*/
void FiberSD::HistInitialize(){
std::string name = GetName();
}
/*
/* Mandatory method
*
*/
void FiberSD::Initialize(G4HCofThisEvent* HCE){
void AirSD::Initialize(G4HCofThisEvent* HCE){
fiberCollection = new FiberHitsCollection(SensitiveDetectorName,
hitCollection = new HitsCollection(SensitiveDetectorName,
m_modNum);
std::string name = collectionName[0];
......@@ -80,15 +75,15 @@ void FiberSD::Initialize(G4HCofThisEvent* HCE){
if(HCID<0)
{ HCID = G4SDManager::GetSDMpointer()->GetCollectionID( name );}
HCE->AddHitsCollection( HCID, fiberCollection );
HCE->AddHitsCollection( HCID, hitCollection );
G4cout << " HCID " << HCID << " name " << name << G4endl;
}
/*
/* Mandatory method
*
*/
G4bool FiberSD::ProcessHits(G4Step* aStep,G4TouchableHistory*){
G4bool AirSD::ProcessHits(G4Step* aStep,G4TouchableHistory*){
G4Track* theTrack = aStep->GetTrack();
......@@ -97,23 +92,22 @@ G4bool FiberSD::ProcessHits(G4Step* aStep,G4TouchableHistory*){
G4ParticleDefinition *particle = aStep->GetTrack()->GetDefinition();
G4double charge = aStep->GetPreStepPoint()->GetCharge();
FiberHit* newHit = new FiberHit();
AirHit* newHit = new AirHit();
newHit->setTrackID (aStep->GetTrack()->GetTrackID() );
newHit->setPos (aStep->GetTrack()->GetVertexPosition() );
newHit->setEnergy (energy);
newHit->setMomentum (momentum);
fiberCollection->insert (newHit );
hitCollection->insert( newHit );
return true;
}
/*
/* Mandatory method
*
*/
void FiberSD::EndOfEvent(G4HCofThisEvent*){
void AirSD::EndOfEvent(G4HCofThisEvent*){
}
// ********************************************************************
// * 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. *
// ********************************************************************
//
// @Author Chad Lantz
#include "Hit.hh"
#include "G4UnitsTable.hh"
#include "G4VVisManager.hh"
#include "G4Circle.hh"
#include "G4Colour.hh"
#include "G4VisAttributes.hh"
G4Allocator<Hit> HitAllocator;
/*
*
*/
Hit::Hit() {}
/*
*
*/
Hit::~Hit() {}
/*
*
*/
Hit::Hit(const Hit& right)
: G4VHit()
{
trackID = right.trackID;
pos = right.pos;
energy = right.energy;
momentum = right.momentum;
}
/*
*
*/
const Hit& Hit::operator=(const Hit& right)
{
trackID = right.trackID;
pos = right.pos;
energy = right.energy;
momentum = right.momentum;
return *this;
}
/*
*
*/
G4int Hit::operator==(const Hit& right) const
{
return (this==&right) ? 1 : 0;
}
/*
*
*/
void Hit::Draw()
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if(pVVisManager)
{
G4Circle circle(pos);
circle.SetScreenSize(2.);
circle.SetFillStyle(G4Circle::filled);
G4Colour colour(1.,0.,0.);
G4VisAttributes attribs(colour);
circle.SetVisAttributes(attribs);
pVVisManager->Draw(circle);
}
}
/*
*
*/
void Hit::Print()
{
G4cout << " trackID: " << trackID
<< " mod: " << modNb << " rad: " << radNb
<< " energy deposit: " << G4BestUnit(edep,"Energy")
<< " position: " << G4BestUnit(pos,"Length") << G4endl;
}
......@@ -161,7 +161,34 @@ G4VPhysicalVolume* OpNoviceDetectorConstruction::Construct(){
//----------------- Define PMT -----------------// This will need a sensitive detector
double PMTradius = 65.0/2*mm;
G4SDManager* SDman = G4SDManager::GetSDMpointer();
AirSD* PMT = new AirSD("MyPMT");
SDman->AddNewDetector( PMT );
G4Tubs* solidPMT =
new G4Tubs("PMT", //name
0.0*mm, //Inner radius
PMTradius, //Outter radius
0.5*mm, //Height
0.0*deg, //Rotation start
360.0*deg); //Sweep
G4LogicalVolume* logicPMT =
new G4LogicalVolume(solidPMT, //solid
Air, //material
"PMT"); //name
G4VPhysicalVolume* physPMT =
new G4PVPlacement(0,
G4ThreeVector(0, 0, 2*HeightZ),
logicPMT,
"PMT",
m_logicWorld,
false,
0);
logicPMT->SetSensitiveDetector( PMT );
return m_physWorld;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment