Dear Sir,
Thanks a lot for your reply.
Here is the spectra in linear.
I missed that the general profile of spectra looks like that from la138 initially. It seems to me that the whole x axis is shifted by roughly 1MeV. However, I am not able to resolve this or point the issue with my code.
Here are some relevant parts of code, please let me know if any further clarifications are required
Stepping action
#include "stepping.hh"
#include "G4RunManager.hh"
steppingaction::steppingaction(eventaction* eventAction){
fEventAction=eventAction;
}
steppingaction::~steppingaction(){}
void steppingaction::UserSteppingAction (const G4Step* step){
const detectorconstruction* detectorConstruction = static_cast<const detectorconstruction*>
(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
G4LogicalVolume* fScoringVolume = detectorConstruction->GetScoringVolume();
G4LogicalVolume *volume = step->GetPreStepPoint()->GetTouchableHandle()
->GetVolume()->GetLogicalVolume();
if (volume != fScoringVolume)
return;
// get edep of each step
G4double edep= step->GetTotalEnergyDeposit();
// integrate all edep of each event
if (edep<0*MeV) return ;
fEventAction->AddEdep(edep);
}
Event Action (the value of edep is reset to 0 at start of each event)
#include "event.hh"
// initialize constructor
eventaction::eventaction(runaction*){
// create variable
fEdep=0.;
}
// initialize destructor
eventaction::~eventaction(){}
// functions
void eventaction::BeginOfEventAction(const G4Event*){
fEdep=0.;
}
void eventaction::EndOfEventAction(const G4Event*){
G4AnalysisManager* man= G4AnalysisManager::Instance();
if (fEdep<=0.0*MeV) return;
man->FillNtupleDColumn(0,0,fEdep);
man->AddNtupleRow(0);
}
Run Action
#include "runaction.hh"
// define the constructor
runaction::runaction(){}
// define the destructor
runaction::~runaction(){}
void runaction::BeginOfRunAction(const G4Run* run){
// initializate the run manager to store the hits
G4AnalysisManager*man = G4AnalysisManager::Instance();
// create a file for each run
G4int RunID = run->GetRunID();
std::stringstream strRunID;
strRunID<<RunID;
//man->SetHistoDictoryName("histograms");
// create the root file
man->OpenFile("output"+strRunID.str()+".root");
man->CreateNtuple("Edep","Edep");
man->CreateNtupleDColumn("fedep");
man->FinishNtuple(0);
}
void runaction::EndOfRunAction(const G4Run*){
G4AnalysisManager*man = G4AnalysisManager::Instance();
man->Write();
man->CloseFile();
}
Detector Construction
G4ThreeVector positionLaBr3 = G4ThreeVector(0, 0, LaBr3_PosZ);
G4Tubs* solidLaBr3 = new G4Tubs("solidLaBr3", 0., 0.5 * LaBr3Face, 0.5 * LaBr3Thickness, 0. * deg, 360. * deg);
G4LogicalVolume* logicLaBr3 = new G4LogicalVolume(solidLaBr3, LaBr3_Ce, "logicLaBr3", 0, 0, 0);
fScoringVolume=logicLaBr3; //setting up scoring volume
new G4PVPlacement(0, positionLaBr3, logicLaBr3, "physLaBr3", logicWorld, false, 0, checkOverlaps);
Thanking You
utkarsh