void CALAnalysisManager::BeginOfRun() { G4String m_pDataFile = "events.root"; m_pOutputFile = new TFile(m_pDataFile, "RECREATE"); //namefile.open("names.txt"); m_pTree = new TTree("events","Tree that contains info"); m_pTree1 = new TTree("Total Energy deposited","Tree that contains info about energy"); m_pTree1->Branch("E_{TOT}", &m_pEventData->eTot); //energia depositata totale nei gap m_pTree->Branch("E_{DEP}", &m_pEventData->eDep); //Energia depositata per step per singolo hit m_pTree->Branch("LayerID", &m_pEventData->layerId); m_pTree->Branch("Position", &m_pEventData->position); m_pTree->Branch("EventID", &m_pEventData->eventId); m_pTree->Branch("ParticleID", &idparticle); //nome particella} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... void CALAnalysisManager::EndOfRun() { m_pOutputFile->cd(); m_pOutputFile->Write(); m_pOutputFile->Close(); //namefile.close(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... void CALAnalysisManager::BeginOfEvent(const G4Event* pEvent) { G4cout << "\n============================================================\n" << "Begin of event: "<< pEvent->GetEventID() << G4endl << "-------------------------------------------------------------\n"; if (absCollID == -1) { G4SDManager * pSDManager = G4SDManager::GetSDMpointer(); absCollID = pSDManager->GetCollectionID("AbsorberHitsCollectionName"); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... void CALAnalysisManager::EndOfEvent(const G4Event *pEvent) { G4cout<<"ENDOFEVENT\n"; G4HCofThisEvent * pHCofThisEvent = pEvent->GetHCofThisEvent(); G4cout<<"GOT THE HC\n"; CALCalorHitsCollection * absHitsCollection = (CALCalorHitsCollection*) (pHCofThisEvent->GetHC(absCollID)); G4cout<<"GOT THE abs HC\n"; G4int totEntries = absHitsCollection->entries(); G4cout<<"GOT totEntries:"<getTotalEnergyDeposited(); m_pEventData->eDep = absoHit->getTotalEnergyDeposited(); m_pEventData->layerId = absoHit->getLayerId(); m_pEventData->particleId = absoHit->getParticleId(); names = m_pEventData->particleId; if(names == "pi-") idparticle = 0; else if(names == "pi+") idparticle = 1; else if(names == "neutron") idparticle = 2; else if(names == "proton") idparticle = 3; else if(names == "gamma") idparticle = 4; else if(names == "e-") idparticle = 5; else if(names == "e+") idparticle = 6; else if(names == "mu+") idparticle = 7; else if(names == "mu-") idparticle = 8; else idparticle = -1; m_pEventData->position = {absoHit->getHitPos()[0],absoHit->getHitPos()[1],absoHit->getHitPos()[2]}; m_pEventData->eventId = pEvent->GetEventID(); //namefile << names << '\n'; m_pTree->Fill(); } G4cout<<"LETTE\n"; m_pEventData->eTot = eTmp; m_pTree1->Fill(); m_pEventData->Clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....