Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-18 08:32:45

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 /// \file WLSRun.cc
0027 /// \brief Implementation of the WLSRun class
0028 
0029 #include "WLSRun.hh"
0030 
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 
0033 void WLSRun::Merge(const G4Run* run)
0034 {
0035   const auto localRun = static_cast<const WLSRun*>(run);
0036 
0037   fNTIR += localRun->fNTIR;
0038   fNTIR2 += localRun->fNTIR2;
0039   fNExiting += localRun->fNExiting;
0040   fNExiting2 += localRun->fNExiting2;
0041   fEscapedEnd += localRun->fEscapedEnd;
0042   fEscapedEnd2 += localRun->fEscapedEnd2;
0043   fEscapedMid += localRun->fEscapedMid;
0044   fEscapedMid2 += localRun->fEscapedMid2;
0045   fBounce += localRun->fBounce;
0046   fBounce2 += localRun->fBounce2;
0047   fWLSBounce += localRun->fWLSBounce;
0048   fWLSBounce2 += localRun->fWLSBounce2;
0049   fClad1Bounce += localRun->fClad1Bounce;
0050   fClad1Bounce2 += localRun->fClad1Bounce2;
0051   fClad2Bounce += localRun->fClad2Bounce;
0052   fClad2Bounce2 += localRun->fClad2Bounce2;
0053   fReflected += localRun->fReflected;
0054   fReflected2 += localRun->fReflected2;
0055   fEscaped += localRun->fEscaped;
0056   fEscaped2 += localRun->fEscaped2;
0057   fMirror += localRun->fMirror;
0058   fMirror2 += localRun->fMirror2;
0059   fDetectorHits += localRun->fDetectorHits;
0060   fDetectorHits2 += localRun->fDetectorHits2;
0061 
0062   G4Run::Merge(run);
0063 }
0064 
0065 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0066 
0067 void WLSRun::EndOfRun()
0068 {
0069   if (numberOfEvent == 0) return;
0070   auto TotNbofEvents = G4double(numberOfEvent);
0071 
0072   fNTIR = fNTIR / TotNbofEvents;
0073   fNTIR2 = fNTIR2 / TotNbofEvents;
0074   G4double rmsTIR = fNTIR2 - fNTIR * fNTIR;
0075   if (rmsTIR > 0.)
0076     rmsTIR = std::sqrt(rmsTIR);
0077   else
0078     rmsTIR = 0.;
0079 
0080   fNExiting = fNExiting / TotNbofEvents;
0081   fNExiting2 = fNExiting2 / TotNbofEvents;
0082   G4double rmsExiting = fNExiting2 - fNExiting * fNExiting;
0083   if (rmsExiting > 0.)
0084     rmsExiting = std::sqrt(rmsExiting);
0085   else
0086     rmsExiting = 0.;
0087 
0088   fEscapedEnd = fEscapedEnd / TotNbofEvents;
0089   fEscapedEnd2 = fEscapedEnd2 / TotNbofEvents;
0090   G4double rmsEscapedEnd = fEscapedEnd2 - fEscapedEnd * fEscapedEnd;
0091   if (rmsEscapedEnd > 0.)
0092     rmsEscapedEnd = std::sqrt(rmsEscapedEnd);
0093   else
0094     rmsEscapedEnd = 0.;
0095 
0096   fEscapedMid = fEscapedMid / TotNbofEvents;
0097   fEscapedMid2 = fEscapedMid2 / TotNbofEvents;
0098   G4double rmsEscapedMid = fEscapedMid2 - fEscapedMid * fEscapedMid;
0099   if (rmsEscapedMid > 0.)
0100     rmsEscapedMid = std::sqrt(rmsEscapedMid);
0101   else
0102     rmsEscapedMid = 0.;
0103 
0104   fBounce = fBounce / TotNbofEvents;
0105   fBounce2 = fBounce2 / TotNbofEvents;
0106   G4double rmsBounce = fBounce2 - fBounce * fBounce;
0107   if (rmsBounce > 0.)
0108     rmsBounce = std::sqrt(rmsBounce);
0109   else
0110     rmsBounce = 0.;
0111 
0112   fWLSBounce = fWLSBounce / TotNbofEvents;
0113   fWLSBounce2 = fWLSBounce2 / TotNbofEvents;
0114   G4double rmsWLSBounce = fWLSBounce2 - fWLSBounce * fWLSBounce;
0115   if (rmsWLSBounce > 0.)
0116     rmsWLSBounce = std::sqrt(rmsWLSBounce);
0117   else
0118     rmsWLSBounce = 0.;
0119 
0120   fClad1Bounce = fClad1Bounce / TotNbofEvents;
0121   fClad1Bounce2 = fClad1Bounce2 / TotNbofEvents;
0122   G4double rmsClad1Bounce = fClad1Bounce2 - fClad1Bounce * fClad1Bounce;
0123   if (rmsClad1Bounce > 0.)
0124     rmsClad1Bounce = std::sqrt(rmsClad1Bounce);
0125   else
0126     rmsClad1Bounce = 0.;
0127 
0128   fClad2Bounce = fClad2Bounce / TotNbofEvents;
0129   fClad2Bounce2 = fClad2Bounce2 / TotNbofEvents;
0130   G4double rmsClad2Bounce = fClad2Bounce2 - fClad2Bounce * fClad2Bounce;
0131   if (rmsClad2Bounce > 0.)
0132     rmsClad2Bounce = std::sqrt(rmsClad2Bounce);
0133   else
0134     rmsClad2Bounce = 0.;
0135 
0136   fReflected = fReflected / TotNbofEvents;
0137   fReflected2 = fReflected2 / TotNbofEvents;
0138   G4double rmsReflected = fReflected2 - fReflected * fReflected;
0139   if (rmsReflected > 0.)
0140     rmsReflected = std::sqrt(rmsReflected);
0141   else
0142     rmsReflected = 0.;
0143 
0144   fEscaped = fEscaped / TotNbofEvents;
0145   fEscaped2 = fEscaped2 / TotNbofEvents;
0146   G4double rmsEscaped = fEscaped2 - fEscaped * fEscaped;
0147   if (rmsEscaped > 0.)
0148     rmsEscaped = std::sqrt(rmsEscaped);
0149   else
0150     rmsEscaped = 0.;
0151 
0152   fMirror = fMirror / TotNbofEvents;
0153   fMirror2 = fMirror2 / TotNbofEvents;
0154   G4double rmsMirror = fMirror2 - fMirror * fMirror;
0155   if (rmsMirror > 0.)
0156     rmsMirror = std::sqrt(rmsMirror);
0157   else
0158     rmsMirror = 0.;
0159 
0160   fDetectorHits = fDetectorHits / TotNbofEvents;
0161   fDetectorHits2 = fDetectorHits2 / TotNbofEvents;
0162   G4double rmsDetectorHits = fDetectorHits2 - fDetectorHits * fDetectorHits;
0163   if (rmsDetectorHits > 0.)
0164     rmsDetectorHits = std::sqrt(rmsDetectorHits);
0165   else
0166     rmsDetectorHits = 0.;
0167 
0168   G4int prec = G4cout.precision(3);
0169   G4cout << "\n ======================== run summary =====================\n";
0170   G4cout << "Average number per event:" << G4endl;
0171   G4cout << " TIR:          " << fNTIR << " +- " << rmsTIR << G4endl
0172          << " Exiting:      " << fNExiting << " +- " << rmsExiting << G4endl
0173          << " Escaped Mid:  " << fEscapedMid << " +- " << rmsEscapedMid << G4endl
0174          << " Escaped End:  " << fEscapedEnd << " +- " << rmsEscapedEnd << G4endl
0175          << " Bounced:      " << fBounce << " +- " << rmsBounce << G4endl
0176          << " WLS Bounce:   " << fWLSBounce << " +- " << rmsWLSBounce << G4endl
0177          << " Clad1 Bounce: " << fClad1Bounce << " +- " << rmsClad1Bounce << G4endl
0178          << " Clad2 Bounce: " << fClad2Bounce << " +- " << rmsClad2Bounce << G4endl
0179          << " Reflected:    " << fReflected << " +- " << rmsReflected << G4endl
0180          << " Escaped:      " << fEscaped << " +- " << rmsEscaped << G4endl
0181          << " Mirror:       " << fMirror << " +- " << rmsMirror << G4endl
0182          << " Detector hit: " << fDetectorHits << " +- " << rmsDetectorHits << G4endl;
0183 
0184   G4cout << G4endl;
0185   G4cout.precision(prec);
0186 }