Import Geant4 10.5.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2018-06-29 10:58:11 +02:00
parent fe81a77428
commit 6aa23be517
1581 changed files with 124288 additions and 83758 deletions
@@ -0,0 +1,86 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id: CCalActionInitializer.cc 66241 2012-12-13 18:34:42Z gunter $
// GEANT4 tag $Name: $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "CCalActionInitializer.hh"
#include "CCalEventAction.hh"
#include "CCalRunAction.hh"
#include "CCalPrimaryGeneratorAction.hh"
#include "CCalSteppingAction.hh"
#include "G4RunManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
CCalActionInitializer::CCalActionInitializer()
{;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void CCalActionInitializer::Build() const
{
////////////////////////////
// User action classes. //
// -------------------- //
////////////////////////////
//////////////////////////////////
// PRIMARY PARTICLEs GENERATION //
//////////////////////////////////
CCalPrimaryGeneratorAction* primaryGenerator =
new CCalPrimaryGeneratorAction;
SetUserAction(primaryGenerator);
//////////
// STEP //
//////////
CCalSteppingAction* theSteppingAction =
new CCalSteppingAction;
SetUserAction(theSteppingAction);
/////////
// RUN //
/////////
SetUserAction(new CCalRunAction);
///////////
// EVENT //
///////////
SetUserAction(new CCalEventAction(primaryGenerator,theSteppingAction));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void CCalActionInitializer::BuildForMaster() const
{;}
@@ -1,339 +0,0 @@
//
// ********************************************************************
// * 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: CCalAnalysis.cc
// Description: CCalAnalysis interfaces all user analysis code
///////////////////////////////////////////////////////////////////////////////
#include "G4RunManager.hh"
#include "CCalAnalysis.hh"
#include "CCalutils.hh"
CCalAnalysis* CCalAnalysis::instance = 0;
CCalAnalysis::CCalAnalysis() :
energy(0), hcalE(0), ecalE(0), timeHist(0), lateralProfile(0),
timeProfile(0)
{
#ifdef debug
fVerbosity = 1;
#else
fVerbosity = 0;
#endif
numberOfTimeSlices = 200;
// Create analysis manager
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
analysisManager->SetVerboseLevel(1);
analysisManager->SetFirstHistoId(1);
analysisManager->SetFirstNtupleId(1);
// Open an output file
analysisManager->OpenFile("ccal");
G4cout << "********************************************" << G4endl
<< "* o/p file ccal" << G4endl
<< "********************************************" << G4endl
<< G4endl;
// Create a tuple :
// Create ntuple
analysisManager->CreateNtuple("ntuple1", "Event info");
char tupleid[7];
for (int i=0;i<28;i++)
{
sprintf(tupleid,"hcal%d",i);
analysisManager->CreateNtupleFColumn(tupleid);
}
for (int i=0; i<49; i++)
{
sprintf(tupleid,"ecal%d",i);
analysisManager->CreateNtupleFColumn(tupleid);
}
analysisManager->CreateNtupleFColumn("ELAB");
analysisManager->CreateNtupleFColumn("XPOS");
analysisManager->CreateNtupleFColumn("YPOS");
analysisManager->CreateNtupleFColumn("ZPOS");
analysisManager->CreateNtupleFColumn("EDEP");
analysisManager->CreateNtupleFColumn("EDEC");
analysisManager->CreateNtupleFColumn("EHDC");
analysisManager->FinishNtuple();
//
//Create histograms. Save the ID of the first histogram in each block
//
char id[5], ntupletag[50];
//Energy deposit in Hcal layers
for (int i = 0; i<28; i++) {
sprintf(id,"h%d",i+100);
sprintf(ntupletag, "Energy Deposit in Hcal Layer%d in GeV",i);
G4int histoID = analysisManager->CreateH1(id,ntupletag, 100, 0., 1.0);
if (!i)
hcalE = histoID;
}
// Energy deposits in Ecal towers
for (int i = 0; i<49; i++)
{
sprintf(id, "h%d",i+200);
sprintf(ntupletag, "Energy Deposit in Ecal Tower%d in GeV",i);
G4int histoID = analysisManager->CreateH1(id,ntupletag, 100, 0., 1.0);
if (!i)
ecalE = histoID;
}
// Total energy deposit
energy = analysisManager->CreateH1("h4000", "Total energy deposited in GeV",
100, 0., 100.0);
// Time slices
for (int i=0; i<numberOfTimeSlices; i++){
sprintf(id, "h%d",i+300);
sprintf(ntupletag, "Time slice %d nsec energy profile in GeV",i);
G4int histoID = analysisManager->CreateH1(id,ntupletag,100, 0., 100.0);
if (!i)
timeHist = histoID;
}
// Profile of lateral energy deposit in Hcal
for (int i = 0; i<70; i++) {
sprintf(id, "h%d",i+500);
sprintf(ntupletag, "Lateral energy profile at %d cm in GeV",i);
G4int histoID = analysisManager->CreateH1(id, ntupletag, 100, 0., 10.0);
if (!i)
lateralProfile = histoID;
}
// Time profile
timeProfile = analysisManager->CreateH1("h901", "Time Profile in Sensitive Detector",
200, 0., 200.);
analysisManager->CreateH1("h902", "Time Profile in Sensitive+Passive",
200, 0., 200.);
}
CCalAnalysis::~CCalAnalysis() {
Finish();
delete G4AnalysisManager::Instance();
}
void CCalAnalysis::Init() {
}
void CCalAnalysis::Finish()
{;}
CCalAnalysis* CCalAnalysis::getInstance() {
if (instance == 0) instance = new CCalAnalysis();
return instance;
}
// This function fill the 1d histogram of the energies in HCal layers
void CCalAnalysis::InsertEnergyHcal(float* v)
{
G4AnalysisManager* man = G4AnalysisManager::Instance();
G4double totalFilledEnergyHcal = 0.0;
for (int i=0; i<28; i++) {
G4double x = v[i];
man->FillH1(hcalE+i,x);
if (fVerbosity)
{
G4cout << "Fill Hcal histo " << i << " with " << x << G4endl;
totalFilledEnergyHcal += x;
}
}
if (fVerbosity)
G4cout <<
"CCalAnalysis::InsertEnergyHcal: Total filled Energy Hcal histo "
<< totalFilledEnergyHcal << G4endl;
}
// This function fill the 1d histogram of the energies in ECal layers
void CCalAnalysis::InsertEnergyEcal(float* v)
{
G4AnalysisManager* man = G4AnalysisManager::Instance();
G4double totalFilledEnergyEcal = 0.0;
for (G4int i=0; i<49; i++) {
G4double x = v[i];
man->FillH1(ecalE+i,x);
if (fVerbosity)
{
G4cout << "Fill Ecal histo " << i << " with " << x << G4endl;
totalFilledEnergyEcal += x;
}
}
if (fVerbosity)
G4cout <<
"CCalAnalysis::InsertEnergyEcal: Total filled Energy Ecal histo "
<< totalFilledEnergyEcal << G4endl;
}
// This function fill the 1d histogram of the lateral profile
void CCalAnalysis::InsertLateralProfile(float* v)
{
G4AnalysisManager* man = G4AnalysisManager::Instance();
G4double totalFilledProfileHcal = 0.0;
for (G4int i=0; i<70; i++) {
G4double x = v[i];
man->FillH1(lateralProfile+1,x);
if (fVerbosity)
{
G4cout << "Fill Profile Hcal histo " << i << " with " << x << G4endl;
totalFilledProfileHcal += x;
}
}
if (fVerbosity)
G4cout << "CCalAnalysis::InsertLateralProfile: Total filled Profile Hcal"
<< " histo " << totalFilledProfileHcal << G4endl;
}
// This function fill the 1d histogram of the energy
void CCalAnalysis::InsertEnergy(float v)
{
G4double x = v;
G4AnalysisManager::Instance()->FillH1(energy,x);
if (fVerbosity)
G4cout << "CCalAnalysis::InsertEnergy: Fill Total energy Hcal histo with "
<< x << G4endl;
}
// This function fill the 1d histograms of time profiles at stepping action
void CCalAnalysis::InsertTime(float* v)
{
G4AnalysisManager* man = G4AnalysisManager::Instance();
G4double totalFilledTimeProfile = 0.0;
for (G4int j=0; j<numberOfTimeSlices; j++)
{
G4double x = v[j];
man->FillH1(timeHist+j,x);
if (fVerbosity)
{
G4cout << "Fill Time slice histo " << j << " with " << x << G4endl;
totalFilledTimeProfile += x;
}
G4double t = j + 0.5;
man->FillH1(timeProfile+1,t,x);
if (fVerbosity)
G4cout << "Fill Time profile histo 1 with " << t << " " << x << G4endl;
}
if (fVerbosity)
G4cout << "CCalAnalysis::InsertTime: Total filled Time profile histo "
<< totalFilledTimeProfile << G4endl;
}
// This function fill the 1d histograms of time profiles in SD
void CCalAnalysis::InsertTimeProfile(int hit, double time, double edep)
{
G4AnalysisManager* man = G4AnalysisManager::Instance();
man->FillH1(timeProfile,time,edep);
if (fVerbosity)
G4cout << "CCalAnalysis:: Fill Time Profile with Hit " << hit
<< " Edeposit " << edep << " Gev at " << time << " ns" << G4endl;
}
void CCalAnalysis::setNtuple(float* HCalE, float* ECalE, float elab,
float x, float y, float z, float edep,
float edec, float edhc)
{
G4AnalysisManager* man = G4AnalysisManager::Instance();
G4int counter=0;
for (int i=0; i<28; i++)
{
man->FillNtupleFColumn(counter,HCalE[i]);
counter++;
}
for (int i=0; i<49; i++)
{
man->FillNtupleFColumn(counter,ECalE[i]);
counter++;
}
man->FillNtupleFColumn(counter,elab);
man->FillNtupleFColumn(counter+1,x);
man->FillNtupleFColumn(counter+2,y);
man->FillNtupleFColumn(counter+3,z);
man->FillNtupleFColumn(counter+4,edep);
man->FillNtupleFColumn(counter+5,edec);
man->FillNtupleFColumn(counter+6,edhc);
man->AddNtupleRow();
if (fVerbosity)
G4cout << "CCalAnalysis:: Fill Ntuple " << G4endl;
}
/*
This member reset the histograms and it is called at the begin
of each run; here we put the inizialization so that the histograms have
always the right dimensions depending from the detector geometry
*/
void CCalAnalysis::BeginOfRun(G4int )
{
G4AnalysisManager* man = G4AnalysisManager::Instance();
for (int i=0; i<numberOfTimeSlices; i++){
man->GetH1(timeHist+1)->reset();
}
}
//============================================================================
// This member is called at the end of each run
void CCalAnalysis::EndOfRun(G4int )
{
// Save histograms
G4AnalysisManager* man = G4AnalysisManager::Instance();
man->Write();
man->CloseFile();
}
// This member is called at the end of every event
void CCalAnalysis::EndOfEvent(G4int flag) {
// The plotter is updated only if there is some
// hits in the event
if (!flag) return;
}
@@ -27,14 +27,16 @@
// File: CCalEndOfEventAction.cc
// Description: CCalEndOfEventAction provides User actions at end of event
///////////////////////////////////////////////////////////////////////////////
#include "CCalEndOfEventAction.hh"
#include "CCalEventAction.hh"
#include "CCaloSD.hh"
#include "CCalPrimaryGeneratorAction.hh"
#include "CCalSteppingAction.hh"
#include "CCalG4HitCollection.hh"
#include "CCalG4Hit.hh"
#include "CCaloOrganization.hh"
#include "CCalSDList.hh"
#include "CCalSteppingAction.hh"
#include "CCalAnalysis.hh"
#include "G4ios.hh"
#include "G4SystemOfUnits.hh"
@@ -54,16 +56,14 @@
//#define ddebug
CCalEndOfEventAction::CCalEndOfEventAction (CCalPrimaryGeneratorAction* pg):
isInitialized(false),SDnames(0),numberOfSD(0) {
primaryGenerator = pg;
CCalEventAction::CCalEventAction (CCalPrimaryGeneratorAction* pg,
CCalSteppingAction* sa):
isInitialized(false),fPrimaryGenerator(pg),
fSteppingAction(sa),SDnames(nullptr),numberOfSD(0)
{
#ifdef debug
G4cout << "Instantiate CCalEndOfEventAction" << G4endl;
#endif
G4cout << "Now Instantiate stepping action" << G4endl;
instanciateSteppingAction();
#endif
G4cout << "Get Calorimter organisation" << G4endl;
theOrg = new CCaloOrganization;
@@ -71,17 +71,17 @@ CCalEndOfEventAction::CCalEndOfEventAction (CCalPrimaryGeneratorAction* pg):
}
CCalEndOfEventAction::~CCalEndOfEventAction() {
CCalEventAction::~CCalEventAction() {
if (theOrg)
delete theOrg;
if (SDnames)
delete[] SDnames;
G4cout << "CCalEndOfEventAction deleted" << G4endl;
G4cout << "CCalOfEventAction deleted" << G4endl;
}
void CCalEndOfEventAction::initialize() {
void CCalEventAction::initialize() {
isInitialized = true;
numberOfSD = CCalSDList::getInstance()->getNumberOfCaloSD();
@@ -104,12 +104,12 @@ void CCalEndOfEventAction::initialize() {
}
void CCalEndOfEventAction::StartOfEventAction(const G4Event* evt) {
void CCalEventAction::StartOfEventAction(const G4Event* evt) {
G4cout << "\n---> Begin of event: " << evt->GetEventID() << G4endl;
}
void CCalEndOfEventAction::EndOfEventAction(const G4Event* evt){
void CCalEventAction::EndOfEventAction(const G4Event* evt){
#ifdef debug
G4cout << G4endl << "=== Begin of EndOfEventAction === " << G4endl;
@@ -117,7 +117,7 @@ void CCalEndOfEventAction::EndOfEventAction(const G4Event* evt){
if (!isInitialized) initialize();
theSteppingAction->endOfEvent();
fSteppingAction->endOfEvent();
//
// Look for the Hit Collection
@@ -210,18 +210,83 @@ void CCalEndOfEventAction::EndOfEventAction(const G4Event* evt){
delete[] edep;
G4ThreeVector pos = primaryGenerator->GetParticlePosition();
float ener = primaryGenerator->GetParticleEnergy()/GeV;
G4ThreeVector pos = fPrimaryGenerator->GetParticlePosition();
float ener = fPrimaryGenerator->GetParticleEnergy()/GeV;
float x = pos.x()/mm;
float y = pos.y()/mm;
float z = pos.z()/mm;
CCalAnalysis* analysis = CCalAnalysis::getInstance();
analysis->InsertEnergy(fullE);
analysis->InsertEnergyHcal(hcalE);
analysis->InsertEnergyEcal(ecalE);
analysis->setNtuple(hcalE, ecalE, ener, x, y, z, fullE, edec, edhc);
analysis->EndOfEvent(nhit);
//Save results
G4AnalysisManager* man = G4AnalysisManager::Instance();
//1)
static G4int IDenergy = -1;
if (IDenergy < 0)
IDenergy = man->GetH1Id("h4000");
man->FillH1(IDenergy,fullE);
//2)
G4double totalFilledEnergyHcal = 0.0;
static G4int IDhcalE = -1;
if (IDhcalE < 0)
IDhcalE = man->GetH1Id("h100");
for (int j=0; j<28; j++) {
man->FillH1(IDhcalE+j,hcalE[j]);
#ifdef debug
G4cout << "Fill Hcal histo " << j << " with " << hCalE[j] << G4endl;
#endif
totalFilledEnergyHcal += hcalE[j];
}
#ifdef debug
G4cout <<
"CCalAnalysis::InsertEnergyHcal: Total filled Energy Hcal histo "
<< totalFilledEnergyHcal << G4endl;
#endif
//3)
static G4int IDecalE = -1;
if (IDecalE < 0)
IDecalE = man->GetH1Id("h200");
G4double totalFilledEnergyEcal = 0.0;
for (int j=0; j<49; j++) {
man->FillH1(IDecalE+j,ecalE[j]);
#ifdef debug
G4cout << "Fill Ecal histo " << j << " with " << ecalE[j] << G4endl;
#endif
totalFilledEnergyEcal += ecalE[j];
}
#ifdef debug
G4cout <<
"CCalAnalysis::InsertEnergyEal: Total filled Energy Ecal histo "
<< totalFilledEnergyEcal << G4endl;
#endif
// 4)
G4int counter=0;
for (int j=0; j<28; j++)
{
man->FillNtupleFColumn(counter,hcalE[j]);
counter++;
}
for (int j=0; j<49; j++)
{
man->FillNtupleFColumn(counter,ecalE[j]);
counter++;
}
man->FillNtupleFColumn(counter,ener);
man->FillNtupleFColumn(counter+1,x);
man->FillNtupleFColumn(counter+2,y);
man->FillNtupleFColumn(counter+3,z);
man->FillNtupleFColumn(counter+4,fullE);
man->FillNtupleFColumn(counter+5,edec);
man->FillNtupleFColumn(counter+6,edhc);
man->AddNtupleRow();
#ifdef debug
G4cout << "CCalAnalysis:: Fill Ntuple " << G4endl;
#endif
// 5)
static G4int IDtimeProfile = -1;
if (IDtimeProfile < 0)
IDtimeProfile = man->GetH1Id("h901");
for (i = 0; i < numberOfSD; i++){
int caloHCid = G4SDManager::GetSDMpointer()->GetCollectionID(SDnames[i]);
if (caloHCid >= 0) {
@@ -232,8 +297,12 @@ void CCalEndOfEventAction::EndOfEventAction(const G4Event* evt){
if (nentries > 0) {
for (G4int k=0; k<nentries; k++) {
CCalG4Hit* aHit = (*theHC)[k];
analysis->InsertTimeProfile(k,aHit->getTimeSlice(),
aHit->getEnergyDeposit()/GeV);
man->FillH1(IDtimeProfile,aHit->getTimeSlice(),aHit->getEnergyDeposit()/GeV);
#ifdef debug
G4cout << "CCalAnalysis:: Fill Time Profile with Hit " << k
<< " Edeposit " << edep << " Gev at " << time << " ns" << G4endl;
#endif
}
}
}
@@ -242,17 +311,3 @@ void CCalEndOfEventAction::EndOfEventAction(const G4Event* evt){
}
void CCalEndOfEventAction::instanciateSteppingAction(){
G4UserSteppingAction* theUA = const_cast<G4UserSteppingAction*>(G4RunManager::GetRunManager()->GetUserSteppingAction());
if (theUA == 0) {
#ifdef debug
G4cout << " CCalEndOfEventAction::instanciateSteppingAction creates"
<< " CCalSteppingAction" << G4endl;
#endif
theSteppingAction = new CCalSteppingAction;
G4RunManager::GetRunManager()->SetUserAction(theSteppingAction);
}
}
@@ -39,9 +39,11 @@
#include "CCalAnalysis.hh"
void CCalRunAction::BeginOfRunAction(const G4Run* aRun) {
void CCalRunAction::BeginOfRunAction(const G4Run* aRun)
{
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
numberOfTimeSlices = 200;
// A.R. Added for visualization of events.
if ( G4VVisManager::GetConcreteInstance() ) {
@@ -49,24 +51,99 @@ void CCalRunAction::BeginOfRunAction(const G4Run* aRun) {
UI->ApplyCommand("/vis/scene/notifyHandlers");
}
CCalAnalysis* analysis = CCalAnalysis::getInstance();
analysis->BeginOfRun(aRun->GetRunID());
if (aRun->GetRunID() == 0) //first run
Book();
G4AnalysisManager* analysis = G4AnalysisManager::Instance();
//cleanup
G4int timeHist = analysis->GetH1Id("h300");
for (int i=0; i<numberOfTimeSlices; i++)
analysis->GetH1(timeHist+i)->reset();
}
void CCalRunAction::EndOfRunAction(const G4Run* aRun) {
void CCalRunAction::EndOfRunAction(const G4Run* aRun)
{
G4cout << "### Run " << aRun->GetRunID() << " end." << G4endl;
// A.R. Added for visualization of events.
if (G4VVisManager::GetConcreteInstance()) {
G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update");
}
CCalAnalysis* analysis = CCalAnalysis::getInstance();
analysis->EndOfRun(aRun->GetRunID());
}
void CCalRunAction::Book()
{
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
analysisManager->SetVerboseLevel(1);
analysisManager->SetFirstHistoId(1);
analysisManager->SetFirstNtupleId(1);
// Open an output file
analysisManager->OpenFile("ccal");
G4cout << "********************************************" << G4endl
<< "* o/p file ccal" << G4endl
<< "********************************************" << G4endl
<< G4endl;
// Create a tuple :
// Create ntuple
analysisManager->CreateNtuple("ntuple1", "Event info");
for (int i=0;i<28;i++) {
G4String tupleidString = "hcal" + std::to_string( i );
analysisManager->CreateNtupleFColumn( tupleidString.c_str() );
}
for (int i=0; i<49; i++) {
G4String tupleidString = "ecal" + std::to_string( i );
analysisManager->CreateNtupleFColumn( tupleidString.c_str() );
}
analysisManager->CreateNtupleFColumn("ELAB");
analysisManager->CreateNtupleFColumn("XPOS");
analysisManager->CreateNtupleFColumn("YPOS");
analysisManager->CreateNtupleFColumn("ZPOS");
analysisManager->CreateNtupleFColumn("EDEP");
analysisManager->CreateNtupleFColumn("EDEC");
analysisManager->CreateNtupleFColumn("EHDC");
analysisManager->FinishNtuple();
//
//Create histograms. Save the ID of the first histogram in each block
//
//Energy deposit in Hcal layers
for (int i = 0; i<28; i++) {
G4String idString = "h" + std::to_string( i+100 );
G4String ntupletagString = "Energy Deposit in Hcal Layer" + std::to_string( i ) + " in GeV";
analysisManager->CreateH1( idString.c_str(), ntupletagString.c_str(), 100, 0., 1.0 );
}
// Energy deposits in Ecal towers
for (int i = 0; i<49; i++) {
G4String idString = "h" + std::to_string( i+200 );
G4String ntupletagString = "Energy Deposit in Ecal Tower" + std::to_string( i ) + " in GeV";
analysisManager->CreateH1( idString.c_str(), ntupletagString.c_str(), 100, 0., 1.0 );
}
// Total energy deposit
analysisManager->CreateH1( "h4000", "Total energy deposited in GeV", 100, 0., 100.0 );
// Time slices
for (int i=0; i<numberOfTimeSlices; i++){
G4String idString = "h" + std::to_string( i+300 );
G4String ntupletagString = "Time slice " + std::to_string( i ) + " nsec energy profile in GeV";
analysisManager->CreateH1( idString.c_str(), ntupletagString.c_str(), 100, 0., 100.0 );
}
// Profile of lateral energy deposit in Hcal
for (int i = 0; i<70; i++) {
G4String idString = "h" + std::to_string( i+500 );
G4String ntupletagString = "Lateral energy profile at " + std::to_string( i ) + " cm in GeV";
analysisManager->CreateH1( idString.c_str(), ntupletagString.c_str(), 100, 0., 10.0 );
}
// Time profile
analysisManager->CreateH1( "h901", "Time Profile in Sensitive Detector", 200, 0., 200. );
analysisManager->CreateH1( "h902", "Time Profile in Sensitive+Passive", 200, 0., 200. );
return;
}
@@ -31,24 +31,22 @@
#include <cmath>
#include "CCalSteppingAction.hh"
#include "CCalRunAction.hh"
#include "CCalAnalysis.hh"
#include "G4SystemOfUnits.hh"
#include "G4SDManager.hh"
#include "G4StepPoint.hh"
#include "G4ThreeVector.hh"
#include "G4RunManager.hh"
#include "CCalAnalysis.hh"
CCalSteppingAction::CCalSteppingAction(){
CCalAnalysis* analysis = CCalAnalysis::getInstance();
timeHistoMaxBin=analysis->maxbin();
int i;
for (i=0; i<200; i++) {timeDeposit[i] = 0.;}
for (i=0; i<70; i++) {LateralProfile[i] = 0.;}
CCalSteppingAction::CCalSteppingAction() :
runAct(nullptr)
{
for (int i=0; i<200; i++) {timeDeposit[i] = 0.;}
for (int i=0; i<70; i++) {LateralProfile[i] = 0.;}
}
@@ -58,8 +56,16 @@ CCalSteppingAction::~CCalSteppingAction(){
}
void CCalSteppingAction::UserSteppingAction(const G4Step* aStep){
void CCalSteppingAction::UserSteppingAction(const G4Step* aStep)
{
//thread-local run action
if (!runAct)
runAct =
dynamic_cast<const CCalRunAction*>
(G4RunManager::GetRunManager()->GetUserRunAction());
timeHistoMaxBin=runAct->maxbin();
G4StepPoint* PostStepPoint= aStep->GetPostStepPoint();
G4StepPoint* PreStepPoint= aStep->GetPreStepPoint();
int TSliceID;
@@ -82,10 +88,52 @@ void CCalSteppingAction::UserSteppingAction(const G4Step* aStep){
void CCalSteppingAction::endOfEvent(){
CCalAnalysis* analysis = CCalAnalysis::getInstance();
analysis->InsertLateralProfile(LateralProfile);
analysis->InsertTime(timeDeposit);
G4AnalysisManager* man = G4AnalysisManager::Instance();
G4double totalFilledProfileHcal = 0.0;
static G4int IDlateralProfile = -1;
if (IDlateralProfile < 0)
IDlateralProfile = man->GetH1Id("h500");
for (G4int i=0; i<70; i++) {
man->FillH1(IDlateralProfile+i,LateralProfile[i]);
#ifdef debug
G4cout << "Fill Profile Hcal histo " << i << " with " << LateralProfile[i] << G4endl;
#endif
totalFilledProfileHcal += LateralProfile[i];
}
#ifdef debug
G4cout << "CCalAnalysis::InsertLateralProfile: Total filled Profile Hcal"
<< " histo " << totalFilledProfileHcal << G4endl;
#endif
static G4int IDTimeHist = -1;
if (IDTimeHist < 0)
IDTimeHist = man->GetH1Id("h300");
G4double totalFilledTimeProfile = 0.0;
for (G4int j=0; j<timeHistoMaxBin; j++)
{
man->FillH1(IDTimeHist+j,timeDeposit[j]);
#ifdef debug
G4cout << "Fill Time slice histo " << j << " with " << timeDeposit[j] << G4endl;
#endif
totalFilledTimeProfile += timeDeposit[j];
static G4int IDTimeProfile = -1;
if (IDTimeProfile < 0)
IDTimeProfile = man->GetH1Id("h901");
G4double t = j + 0.5;
man->FillH1(IDTimeProfile+1,t,timeDeposit[j]);
#ifdef debug
G4cout << "Fill Time profile histo 1 with " << t << " " << x << G4endl;
#endif
}
#ifdef debug
G4cout << "CCalAnalysis::InsertTime: Total filled Time profile histo "
<< totalFilledTimeProfile << G4endl;
#endif
int i=0;
for (i=0; i<70; i++){LateralProfile[i] = 0.;}
for (i=0; i<200; i++){timeDeposit[i] = 0.;}