W
pliku MyRun.hh (zmiany kolorem czerwonym)
............................................................
#include "G4Run.hh"
#include "G4THitsMap.hh"
#include "TNtuple.h"
#include "TFile.h"
...................................................
//Data
G4int fMapId;
G4THitsMap<G4double> frunHitsMap;
TFile *fRootFile;
TNtuple *fNtuple;
};
oooooooooooooooooooooooooooooooooooooooooooooooooooooooo
W pliku
MyRun.cc (zmiany kolorem czerwonym)
.............................................................................................
MyRun::MyRun()
.............................................................................................
G4cout << "MyLog: MyRun constructor: index
of photon collection : " << fCollectionId <<
G4endl;
//..Output root file
fRootFile = new TFile("tree.root","RECREATE");
//..NTuple definitions
fNtuple = new TNtuple("ntuple","photon
collection","e:x:y:z");
}
...............................................................................
MyRun::~MyRun()
{
//.. write tree and close
the file
fRootFile->Write();
fRootFile->Close();
}
............................................................................................
void
MyRun::RecordEvent(const G4Event* evt)
{
...............................................................................................
frunHitsMap += *hitsMap;
G4THitsCollection<MyPhotonHit>* photonCollection =
dynamic_cast<G4THitsCollection<MyPhotonHit>*>
(hce->GetHC(fCollectionId));
for( G4int i = 0; i< photonCollection->entries();
i++) {
float e =
(*photonCollection)[i]->GetEnergy()/MeV;
float x =
(*photonCollection)[i]->GetPosition().x()/cm;
float y =
(*photonCollection)[i]->GetPosition().y()/cm;
float z =
(*photonCollection)[i]->GetPosition().z()/cm;
fNtuple->Fill(e,x,y,z);
}
/**
for( G4int i = 0; i<
photonCollection->entries(); i++)
G4cout << "MyLog:
energy and position of photon: "
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo