PSTAR

http://physics.nist.gov/PhysRefData/Star/Text/PSTAR.html

ROOT integration using cmake

Download the file FindROOT.cmake file available at the bottom of this page (wget it for instance). In the CMakeLists.txt! file related to a particular project include these lines right after the project name

include(FindROOT.cmake)

set(INCLUDE_DIRECTORIES
   ${ROOT_INCLUDE_DIR} 
)
include_directories( ${INCLUDE_DIRECTORIES})

set(LINK_DIRECTORIES
   ${ROOT_LIBRARY_DIR}
)
link_directories( ${LINK_DIRECTORIES} )

Then change the following line (a few lines down). Include the ${ROOT_LIBRARIES} part

target_link_libraries(exampleXX ${Geant4_LIBRARIES} ${ROOT_LIBRARIES})

Cmake line

$cmake -G"Eclipse CDT4 - Unix Makefiles" -DGeant4_DIR=/media/geant4/sw/geant4.10.00.p02-install/lib/Geant4-10.0.2/ ../B2

Save Hits data

We will do it by creating a ROOT file. In the ROOT file we will store a n-tuple using a TTree object. A suitable place is the ExN02TrackerSD.

ExN02TrackerSD.hh

    1class ExN02TrackerSD : public G4VSensitiveDetector {
    2
    3  public:
    4      ExN02TrackerSD(G4String);
    5     ~ExN02TrackerSD();
    6
    7      void Initialize(G4HCofThisEvent*);
    8      G4bool ProcessHits(G4Step*, G4TouchableHistory*);
    9      void EndOfEvent(G4HCofThisEvent*);
   10
   11  private:
   12      ExN02TrackerHitsCollection* trackerCollection;
   13
   14      // ROOT
   15      TFile * m_HitsFile;
   16      TTree * m_HitsTree;
   17
   18      G4double m_edep;
   19      vector<G4int> m_trackId;
   20
   21};

ExN02TrackerSD.cc

    1ExN02TrackerSD::ExN02TrackerSD(G4String name)
    2:G4VSensitiveDetector(name)
    3{
    4
    5  G4String HCname = "hitsCollection";
    6  collectionName.insert(HCname);
    7
    8  // ROOT
    9  m_HitsFile = new TFile("hitsOutput.root", "RECREATE");
   10  m_HitsTree = new TTree("T","Hits Tree");
   11
   12  m_HitsTree->Branch("edep", &m_edep, "edep/D");
   13  m_HitsTree->Branch("trackId", &m_trackId);
   14
   15  m_edep = 0.;
   16  m_trackId.clear();
   17
   18}

    1ExN02TrackerSD::~ExN02TrackerSD(){
    2
    3	m_HitsFile->cd();
    4	m_HitsTree->Write();
    5	m_HitsFile->Close();
    6
    7}

    1G4bool ExN02TrackerSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
    2{
    3  G4double edep = aStep->GetTotalEnergyDeposit();
    4
    5  if(edep==0.) return false;
    6
    7  ExN02TrackerHit* newHit = new ExN02TrackerHit();
    8  newHit->SetTrackID  (aStep->GetTrack()->GetTrackID());
    9  newHit->SetChamberNb(aStep->GetPreStepPoint()->GetTouchableHandle()
   10                                               ->GetCopyNumber());
   11  newHit->SetEdep     (edep);
   12  newHit->SetPos      (aStep->GetPostStepPoint()->GetPosition());
   13  trackerCollection->insert( newHit );
   14  
   15  newHit->Print();
   16  //newHit->Draw();
   17
   18  // Send to ntuple
   19  m_edep += edep/keV;
   20  m_trackId.push_back( aStep->GetTrack()->GetTrackID() );
   21
   22  return true;
   23}

    1void ExN02TrackerSD::EndOfEvent(G4HCofThisEvent*)
    2{
    3  if (verboseLevel>0) {
    4     G4int NbHits = trackerCollection->entries();
    5     G4cout << "\n-------->Hits Collection: in this event they are " << NbHits 
    6            << " hits in the tracker chambers: " << G4endl;
    7     for (G4int i=0;i<NbHits;i++) (*trackerCollection)[i]->Print();
    8  }
    9
   10  // Fill the Tree
   11  m_HitsFile->cd();
   12  m_HitsTree->Fill();
   13  // Clean up
   14  m_edep = 0.;
   15  m_trackId.clear();
   16
   17}

New materials. G4NistManager and G4Material.

    1// NIST
    2	G4NistManager * nistman = G4NistManager::Instance();
    3	// Si
    4	G4Material * Silicon = nistman->FindOrBuildMaterial("G4_Si");
    5
    6	// Vacuum
    7	G4double atomicNumber = 1.;
    8	G4double massOfMole = 1.008*g/mole;
    9	G4double density_v = 1.e-25*g/cm3;
   10	G4double temperature_v = 2.73*kelvin;
   11	G4double pressure_v = 3.e-18*pascal;
   12	G4Material * vacuum = new G4Material("interGalactic", atomicNumber,
   13			massOfMole, density_v, kStateGas,
   14			temperature_v, pressure_v);

Digitization

Digitizer.h

    1

Digitizer.cc

    1

Digit.h

    1

Digit.cc

    1

-- JohnIdarraga - 28 Nov 2013

Topic attachments
I Attachment History Action Size Date Who Comment
Texttxt CMakeLists.txt r1 manage 2.6 K 2013-11-28 - 23:21 JohnIdarraga  
Unknown file formatcmake FindROOT.cmake r1 manage 9.4 K 2013-11-28 - 23:21 JohnIdarraga  
Unknown file formatmac vis_gps.mac r1 manage 1.7 K 2014-11-06 - 10:54 JohnIdarraga OpenInventor visualization
Unknown file formatmac vis_pgun.mac r1 manage 1.3 K 2014-11-06 - 11:53 JohnIdarraga  
Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r5 - 2014-11-06 - JohnIdarraga
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback