#include #include #include #include "FCALDetectorConstruction.hh" #include "FCALPrimaryGeneratorAction.hh" #include "FCALEventAction.hh" #include "G4Event.hh" #include "TTree.h" FCALEventAction::FCALEventAction(FCALDetectorConstruction* detector_Con, FCALPrimaryGeneratorAction* generator_Act, TTree* tree) : detector_Construction(detector_Con), generator_Action(generator_Act), FCAL_Tree(tree) { n_Cells = detector_Construction->getRows() * detector_Construction->getColumns(); total_Photons = new G4int[n_Cells]; // secure the necessary memory space. detected_Photons = new G4int[n_Cells]; energy_Detected = new G4double[n_Cells]; energy_Deposited = new G4double[n_Cells]; energy_Attenuated = new G4double[n_Cells]; for (G4int i=0; iBranch("event_ID", &event_ID, "event_ID/I"); FCAL_Tree->Branch("in_Energy", &in_Energy, "in_Energy/F"); FCAL_Tree->Branch("n_ExCells", &n_ExCells, "n_ExCells/I"); FCAL_Tree->Branch("row_No", row_No, "row_No[n_ExCells]/I"); FCAL_Tree->Branch("column_No", column_No, "column_No[n_ExCells]/I"); FCAL_Tree->Branch("n_RescaledPhotons", n_RescaledPhotons, "n_RescaledPhotons[n_ExCells]/F"); FCAL_Tree->Branch("op_Energy", op_Energy, "op_Energy[n_ExCells]/F"); FCAL_Tree->Branch("dep_Energy", dep_Energy, "dep_Energy[n_ExCells]/F"); FCAL_Tree->Branch("att_Energy", att_Energy, "att_Energy[n_ExCells]/F"); } FCALEventAction::~FCALEventAction() { delete total_Photons; delete detected_Photons; delete energy_Detected; delete energy_Deposited; delete energy_Attenuated; } void FCALEventAction::BeginOfEventAction(const G4Event* anEvent) { resetCounters(); G4cout << "### Event " << anEvent->GetEventID() << " start." << G4endl; // print the run id } void FCALEventAction::EndOfEventAction(const G4Event* anEvent) { G4int row_Number, column_Number; event_ID = anEvent->GetEventID(); in_Energy = generator_Action->getParticleEnergy(); n_ExCells = 0; for (G4int i=0; igetColumns(); row_Number = (i - column_Number) / detector_Construction->getColumns(); if (detectedPhotons(i) > 0) { row_No[n_ExCells] = row_Number + 1; column_No[n_ExCells] = column_Number + 1; // n_RescaledPhotons[n_ExCells] = detectedPhotons(i)/16239.82; // when the index of refraction of the interface cookie is 1.7 n_RescaledPhotons[n_ExCells] = detectedPhotons(i); op_Energy[n_ExCells] = totalPhotonEnergy(i); dep_Energy[n_ExCells] = totalDepositEnergy(i)/1000.; att_Energy[n_ExCells] = totalAttenuateEnergy(i)/1000.; n_ExCells++; assert(n_ExCells < kMaxCells); } } FCAL_Tree->Fill(); } void FCALEventAction::countPhotons(G4double x_Pos, G4double y_Pos) { G4int copy_No; G4int row_Num = 0, column_Num = 0; G4double x_Reduced, y_Reduced; x_Reduced = x_Pos + detector_Construction->getColumns() * detector_Construction->getXLength(); y_Reduced = y_Pos + detector_Construction->getRows() * detector_Construction->getYLength(); for (G4int i=0; i<(detector_Construction->getColumns()); i++) // get the column number { if ((x_Reduced >= 2*i*detector_Construction->getXLength()) && (x_Reduced < 2*(i+1)*detector_Construction->getXLength())) { column_Num = i; } } for (G4int j=0; j<(detector_Construction->getRows()); j++) // get the row number { if ((y_Reduced >= 2*j*detector_Construction->getYLength()) && (y_Reduced < 2*(j+1)*detector_Construction->getYLength())) { row_Num = j; } } copy_No = row_Num * detector_Construction->getColumns() + column_Num; total_Photons[copy_No] += 1; } void FCALEventAction::countHits(G4int copy_No) { detected_Photons[copy_No] += 1; } void FCALEventAction::addEnergy(G4double photon_Eng, G4int copy_No) { energy_Detected[copy_No] += photon_Eng; } void FCALEventAction::addEnergyDeposit(G4double energy_Dep, G4int copy_No) { energy_Deposited[copy_No] += energy_Dep; } void FCALEventAction::addEnergyAttenuate(G4double energy_Att, G4int copy_No) { energy_Attenuated[copy_No] +=energy_Att; } void FCALEventAction::resetCounters() { for (G4int i=0; i