// // ******************************************************************** // * 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 analysis/AnaEx02/src/HistoManager.cc /// \brief Implementation of the HistoManager class // // //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... #include #include #include #include #include "HistoManager.hh" #include "G4UnitsTable.hh" //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... HistoManager::HistoManager() :fRootFile(0), fNtuple1(0), fNtuple2(0), fEabs(0.), fEgap(0.) ,fLabs(0.), fLgap(0.) { // histograms for (G4int k=0; kBranch("Eabs", &fEabs, "Eabs/D"); fNtuple1->Branch("Egap", &fEgap, "Egap/D"); // create 2nd ntuple fNtuple2 = new TTree("Ntuple2", "TrackL"); fNtuple2->Branch("Labs", &fLabs, "Labs/D"); fNtuple2->Branch("Lgap", &fLgap, "Lgap/D"); G4cout << "\n----> Output file is open in " << fileName << G4endl; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void HistoManager::Save() { if (! fRootFile) return; fRootFile->Write(); // Writing the histograms to the file fRootFile->Close(); // and closing the tree (and the file) G4cout << "\n----> Histograms and ntuples are saved\n" << G4endl; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void HistoManager::FillHisto(G4int ih, G4double xbin, G4double weight) { if (ih >= kMaxHisto) { G4cerr << "---> warning from HistoManager::FillHisto() : histo " << ih << " does not exist. (xbin=" << xbin << " weight=" << weight << ")" << G4endl; return; } if (fHisto[ih]) { fHisto[ih]->Fill(xbin, weight); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void HistoManager::Normalize(G4int ih, G4double fac) { if (ih >= kMaxHisto) { G4cout << "---> warning from HistoManager::Normalize() : histo " << ih << " does not exist. (fac=" << fac << ")" << G4endl; return; } if (fHisto[ih]) fHisto[ih]->Scale(fac); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void HistoManager::FillNtuple(G4double energyAbs, G4double energyGap, G4double trackLAbs , G4double trackLGap ) { fEabs = energyAbs; fEgap = energyGap; fLabs = trackLAbs; fLgap = trackLGap; if (fNtuple1) fNtuple1->Fill(); if (fNtuple2) fNtuple2->Fill(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void HistoManager::PrintStatistic() { G4cout << "\n ----> print histograms statistic \n" << G4endl; for ( G4int i=0; iGetName(); G4String unitCategory; if (name[0] == 'E' ) unitCategory = "Energy"; if (name[0] == 'L' ) unitCategory = "Length"; G4cout << name << ": mean = " << G4BestUnit(h1->GetMean(), unitCategory) << " rms = " << G4BestUnit(h1->GetRMS(), unitCategory ) << G4endl; } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......