Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:25

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 /// \file optical/wls/src/WLSRun.cc
0028 /// \brief Implementation of the WLSRun class
0029 //
0030 //
0031 
0032 #include "WLSRun.hh"
0033 
0034 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0035 
0036 void WLSRun::Merge(const G4Run* run)
0037 {
0038   const auto localRun = static_cast<const WLSRun*>(run);
0039 
0040   fNTIR += localRun->fNTIR;
0041   fNTIR2 += localRun->fNTIR2;
0042   fNExiting += localRun->fNExiting;
0043   fNExiting2 += localRun->fNExiting2;
0044   fEscapedEnd += localRun->fEscapedEnd;
0045   fEscapedEnd2 += localRun->fEscapedEnd2;
0046   fEscapedMid += localRun->fEscapedMid;
0047   fEscapedMid2 += localRun->fEscapedMid2;
0048   fBounce += localRun->fBounce;
0049   fBounce2 += localRun->fBounce2;
0050   fWLSBounce += localRun->fWLSBounce;
0051   fWLSBounce2 += localRun->fWLSBounce2;
0052   fClad1Bounce += localRun->fClad1Bounce;
0053   fClad1Bounce2 += localRun->fClad1Bounce2;
0054   fClad2Bounce += localRun->fClad2Bounce;
0055   fClad2Bounce2 += localRun->fClad2Bounce2;
0056   fReflected += localRun->fReflected;
0057   fReflected2 += localRun->fReflected2;
0058   fEscaped += localRun->fEscaped;
0059   fEscaped2 += localRun->fEscaped2;
0060   fMirror += localRun->fMirror;
0061   fMirror2 += localRun->fMirror2;
0062   fDetectorHits += localRun->fDetectorHits;
0063   fDetectorHits2 += localRun->fDetectorHits2;
0064 
0065   G4Run::Merge(run);
0066 }
0067 
0068 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0069 
0070 void WLSRun::EndOfRun()
0071 {
0072   if (numberOfEvent == 0) return;
0073   auto TotNbofEvents = G4double(numberOfEvent);
0074 
0075   fNTIR = fNTIR / TotNbofEvents;
0076   fNTIR2 = fNTIR2 / TotNbofEvents;
0077   G4double rmsTIR = fNTIR2 - fNTIR * fNTIR;
0078   if (rmsTIR > 0.)
0079     rmsTIR = std::sqrt(rmsTIR);
0080   else
0081     rmsTIR = 0.;
0082 
0083   fNExiting = fNExiting / TotNbofEvents;
0084   fNExiting2 = fNExiting2 / TotNbofEvents;
0085   G4double rmsExiting = fNExiting2 - fNExiting * fNExiting;
0086   if (rmsExiting > 0.)
0087     rmsExiting = std::sqrt(rmsExiting);
0088   else
0089     rmsExiting = 0.;
0090 
0091   fEscapedEnd = fEscapedEnd / TotNbofEvents;
0092   fEscapedEnd2 = fEscapedEnd2 / TotNbofEvents;
0093   G4double rmsEscapedEnd = fEscapedEnd2 - fEscapedEnd * fEscapedEnd;
0094   if (rmsEscapedEnd > 0.)
0095     rmsEscapedEnd = std::sqrt(rmsEscapedEnd);
0096   else
0097     rmsEscapedEnd = 0.;
0098 
0099   fEscapedMid = fEscapedMid / TotNbofEvents;
0100   fEscapedMid2 = fEscapedMid2 / TotNbofEvents;
0101   G4double rmsEscapedMid = fEscapedMid2 - fEscapedMid * fEscapedMid;
0102   if (rmsEscapedMid > 0.)
0103     rmsEscapedMid = std::sqrt(rmsEscapedMid);
0104   else
0105     rmsEscapedMid = 0.;
0106 
0107   fBounce = fBounce / TotNbofEvents;
0108   fBounce2 = fBounce2 / TotNbofEvents;
0109   G4double rmsBounce = fBounce2 - fBounce * fBounce;
0110   if (rmsBounce > 0.)
0111     rmsBounce = std::sqrt(rmsBounce);
0112   else
0113     rmsBounce = 0.;
0114 
0115   fWLSBounce = fWLSBounce / TotNbofEvents;
0116   fWLSBounce2 = fWLSBounce2 / TotNbofEvents;
0117   G4double rmsWLSBounce = fWLSBounce2 - fWLSBounce * fWLSBounce;
0118   if (rmsWLSBounce > 0.)
0119     rmsWLSBounce = std::sqrt(rmsWLSBounce);
0120   else
0121     rmsWLSBounce = 0.;
0122 
0123   fClad1Bounce = fClad1Bounce / TotNbofEvents;
0124   fClad1Bounce2 = fClad1Bounce2 / TotNbofEvents;
0125   G4double rmsClad1Bounce = fClad1Bounce2 - fClad1Bounce * fClad1Bounce;
0126   if (rmsClad1Bounce > 0.)
0127     rmsClad1Bounce = std::sqrt(rmsClad1Bounce);
0128   else
0129     rmsClad1Bounce = 0.;
0130 
0131   fClad2Bounce = fClad2Bounce / TotNbofEvents;
0132   fClad2Bounce2 = fClad2Bounce2 / TotNbofEvents;
0133   G4double rmsClad2Bounce = fClad2Bounce2 - fClad2Bounce * fClad2Bounce;
0134   if (rmsClad2Bounce > 0.)
0135     rmsClad2Bounce = std::sqrt(rmsClad2Bounce);
0136   else
0137     rmsClad2Bounce = 0.;
0138 
0139   fReflected = fReflected / TotNbofEvents;
0140   fReflected2 = fReflected2 / TotNbofEvents;
0141   G4double rmsReflected = fReflected2 - fReflected * fReflected;
0142   if (rmsReflected > 0.)
0143     rmsReflected = std::sqrt(rmsReflected);
0144   else
0145     rmsReflected = 0.;
0146 
0147   fEscaped = fEscaped / TotNbofEvents;
0148   fEscaped2 = fEscaped2 / TotNbofEvents;
0149   G4double rmsEscaped = fEscaped2 - fEscaped * fEscaped;
0150   if (rmsEscaped > 0.)
0151     rmsEscaped = std::sqrt(rmsEscaped);
0152   else
0153     rmsEscaped = 0.;
0154 
0155   fMirror = fMirror / TotNbofEvents;
0156   fMirror2 = fMirror2 / TotNbofEvents;
0157   G4double rmsMirror = fMirror2 - fMirror * fMirror;
0158   if (rmsMirror > 0.)
0159     rmsMirror = std::sqrt(rmsMirror);
0160   else
0161     rmsMirror = 0.;
0162 
0163   fDetectorHits = fDetectorHits / TotNbofEvents;
0164   fDetectorHits2 = fDetectorHits2 / TotNbofEvents;
0165   G4double rmsDetectorHits = fDetectorHits2 - fDetectorHits * fDetectorHits;
0166   if (rmsDetectorHits > 0.)
0167     rmsDetectorHits = std::sqrt(rmsDetectorHits);
0168   else
0169     rmsDetectorHits = 0.;
0170 
0171   G4int prec = G4cout.precision(3);
0172   G4cout << "\n ======================== run summary =====================\n";
0173   G4cout << "Average number per event:" << G4endl;
0174   G4cout << " TIR:          " << fNTIR << " +- " << rmsTIR << G4endl
0175          << " Exiting:      " << fNExiting << " +- " << rmsExiting << G4endl
0176          << " Escaped Mid:  " << fEscapedMid << " +- " << rmsEscapedMid << G4endl
0177          << " Escaped End:  " << fEscapedEnd << " +- " << rmsEscapedEnd << G4endl
0178          << " Bounced:      " << fBounce << " +- " << rmsBounce << G4endl
0179          << " WLS Bounce:   " << fWLSBounce << " +- " << rmsWLSBounce << G4endl
0180          << " Clad1 Bounce: " << fClad1Bounce << " +- " << rmsClad1Bounce << G4endl
0181          << " Clad2 Bounce: " << fClad2Bounce << " +- " << rmsClad2Bounce << G4endl
0182          << " Reflected:    " << fReflected << " +- " << rmsReflected << G4endl
0183          << " Escaped:      " << fEscaped << " +- " << rmsEscaped << G4endl
0184          << " Mirror:       " << fMirror << " +- " << rmsMirror << G4endl
0185          << " Detector hit: " << fDetectorHits << " +- " << rmsDetectorHits << G4endl;
0186 
0187   G4cout << G4endl;
0188   G4cout.precision(prec);
0189 }