#include #include #include #include "LGDetectorConstruction.hh" #include "LGPrimaryGeneratorAction.hh" #include "LGEventAction.hh" #include "G4Event.hh" #include "G4UnitsTable.hh" #include "TTree.h" LGEventAction::LGEventAction(LGDetectorConstruction* detector_Con, LGPrimaryGeneratorAction* generator_Act, G4int Interact, TTree* tree) : detector_Construction(detector_Con), generator_Action(generator_Act), Interactive(Interact), LG_Tree(tree) { if (!Interactive){ // Create the root tree branches LG_Tree->Branch("event_ID", &event_ID, "event_ID/I"); } } LGEventAction::~LGEventAction() { } void LGEventAction::BeginOfEventAction(const G4Event* anEvent) { resetCounters(); if ((Interactive)||!(anEvent->GetEventID()%1000)) G4cout << "### Event " << anEvent->GetEventID() << " start." << G4endl;// print the run id } void LGEventAction::EndOfEventAction(const G4Event* anEvent) { G4int row_Number, column_Number; G4double detection_Efficiency; G4double total_PhotonEnergy = 0; // total energy G4double total_DepositEnergy = 0; // total energy deposited in LeadGlass G4double total_AttenuateEnergy = 0; // total energy deposited in LeadGlass considering attenuation // open file-output stream std::ofstream file_Out; if(Interactive){ file_Out.open("LG_Data.txt", std::ios::out | std::ios::app); if (!file_Out) { G4cout << "Can't open the target file to write!" << G4endl; } G4cout << "Block ID\tProduced\tDetected\t Energy \tDetection \tDeposited\tAttenuated" << G4endl; G4cout << " \tPhotons \tPhotons \tDetection\tEfficiency\t Energy \t Energy " << G4endl; G4cout << "--------\t--------\t--------\t---------\t----------\t---------\t----------" << G4endl; } if (Interactive){ file_Out.close(); } else{ LG_Tree->Fill(); // G4cout << "EVENT RESULT: hits "<< n_ExCells<<" E:" << dep_Energy[0]<< " P:"<