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] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 //
  2 // ********************************************************************
  3 // * License and Disclaimer                                           *
  4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.                             *
 10 // *                                                                  *
 11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                                                  *
 18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // ********************************************************************
 25 //
 26 //
 27 /// \file optical/wls/src/WLSRun.cc
 28 /// \brief Implementation of the WLSRun class
 29 //
 30 //
 31 
 32 #include "WLSRun.hh"
 33 
 34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 35 
 36 void WLSRun::Merge(const G4Run* run)
 37 {
 38   const auto localRun = static_cast<const WLSRun*>(run);
 39 
 40   fNTIR += localRun->fNTIR;
 41   fNTIR2 += localRun->fNTIR2;
 42   fNExiting += localRun->fNExiting;
 43   fNExiting2 += localRun->fNExiting2;
 44   fEscapedEnd += localRun->fEscapedEnd;
 45   fEscapedEnd2 += localRun->fEscapedEnd2;
 46   fEscapedMid += localRun->fEscapedMid;
 47   fEscapedMid2 += localRun->fEscapedMid2;
 48   fBounce += localRun->fBounce;
 49   fBounce2 += localRun->fBounce2;
 50   fWLSBounce += localRun->fWLSBounce;
 51   fWLSBounce2 += localRun->fWLSBounce2;
 52   fClad1Bounce += localRun->fClad1Bounce;
 53   fClad1Bounce2 += localRun->fClad1Bounce2;
 54   fClad2Bounce += localRun->fClad2Bounce;
 55   fClad2Bounce2 += localRun->fClad2Bounce2;
 56   fReflected += localRun->fReflected;
 57   fReflected2 += localRun->fReflected2;
 58   fEscaped += localRun->fEscaped;
 59   fEscaped2 += localRun->fEscaped2;
 60   fMirror += localRun->fMirror;
 61   fMirror2 += localRun->fMirror2;
 62   fDetectorHits += localRun->fDetectorHits;
 63   fDetectorHits2 += localRun->fDetectorHits2;
 64 
 65   G4Run::Merge(run);
 66 }
 67 
 68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 69 
 70 void WLSRun::EndOfRun()
 71 {
 72   if (numberOfEvent == 0) return;
 73   auto TotNbofEvents = G4double(numberOfEvent);
 74 
 75   fNTIR = fNTIR / TotNbofEvents;
 76   fNTIR2 = fNTIR2 / TotNbofEvents;
 77   G4double rmsTIR = fNTIR2 - fNTIR * fNTIR;
 78   if (rmsTIR > 0.)
 79     rmsTIR = std::sqrt(rmsTIR);
 80   else
 81     rmsTIR = 0.;
 82 
 83   fNExiting = fNExiting / TotNbofEvents;
 84   fNExiting2 = fNExiting2 / TotNbofEvents;
 85   G4double rmsExiting = fNExiting2 - fNExiting * fNExiting;
 86   if (rmsExiting > 0.)
 87     rmsExiting = std::sqrt(rmsExiting);
 88   else
 89     rmsExiting = 0.;
 90 
 91   fEscapedEnd = fEscapedEnd / TotNbofEvents;
 92   fEscapedEnd2 = fEscapedEnd2 / TotNbofEvents;
 93   G4double rmsEscapedEnd = fEscapedEnd2 - fEscapedEnd * fEscapedEnd;
 94   if (rmsEscapedEnd > 0.)
 95     rmsEscapedEnd = std::sqrt(rmsEscapedEnd);
 96   else
 97     rmsEscapedEnd = 0.;
 98 
 99   fEscapedMid = fEscapedMid / TotNbofEvents;
100   fEscapedMid2 = fEscapedMid2 / TotNbofEvents;
101   G4double rmsEscapedMid = fEscapedMid2 - fEscapedMid * fEscapedMid;
102   if (rmsEscapedMid > 0.)
103     rmsEscapedMid = std::sqrt(rmsEscapedMid);
104   else
105     rmsEscapedMid = 0.;
106 
107   fBounce = fBounce / TotNbofEvents;
108   fBounce2 = fBounce2 / TotNbofEvents;
109   G4double rmsBounce = fBounce2 - fBounce * fBounce;
110   if (rmsBounce > 0.)
111     rmsBounce = std::sqrt(rmsBounce);
112   else
113     rmsBounce = 0.;
114 
115   fWLSBounce = fWLSBounce / TotNbofEvents;
116   fWLSBounce2 = fWLSBounce2 / TotNbofEvents;
117   G4double rmsWLSBounce = fWLSBounce2 - fWLSBounce * fWLSBounce;
118   if (rmsWLSBounce > 0.)
119     rmsWLSBounce = std::sqrt(rmsWLSBounce);
120   else
121     rmsWLSBounce = 0.;
122 
123   fClad1Bounce = fClad1Bounce / TotNbofEvents;
124   fClad1Bounce2 = fClad1Bounce2 / TotNbofEvents;
125   G4double rmsClad1Bounce = fClad1Bounce2 - fClad1Bounce * fClad1Bounce;
126   if (rmsClad1Bounce > 0.)
127     rmsClad1Bounce = std::sqrt(rmsClad1Bounce);
128   else
129     rmsClad1Bounce = 0.;
130 
131   fClad2Bounce = fClad2Bounce / TotNbofEvents;
132   fClad2Bounce2 = fClad2Bounce2 / TotNbofEvents;
133   G4double rmsClad2Bounce = fClad2Bounce2 - fClad2Bounce * fClad2Bounce;
134   if (rmsClad2Bounce > 0.)
135     rmsClad2Bounce = std::sqrt(rmsClad2Bounce);
136   else
137     rmsClad2Bounce = 0.;
138 
139   fReflected = fReflected / TotNbofEvents;
140   fReflected2 = fReflected2 / TotNbofEvents;
141   G4double rmsReflected = fReflected2 - fReflected * fReflected;
142   if (rmsReflected > 0.)
143     rmsReflected = std::sqrt(rmsReflected);
144   else
145     rmsReflected = 0.;
146 
147   fEscaped = fEscaped / TotNbofEvents;
148   fEscaped2 = fEscaped2 / TotNbofEvents;
149   G4double rmsEscaped = fEscaped2 - fEscaped * fEscaped;
150   if (rmsEscaped > 0.)
151     rmsEscaped = std::sqrt(rmsEscaped);
152   else
153     rmsEscaped = 0.;
154 
155   fMirror = fMirror / TotNbofEvents;
156   fMirror2 = fMirror2 / TotNbofEvents;
157   G4double rmsMirror = fMirror2 - fMirror * fMirror;
158   if (rmsMirror > 0.)
159     rmsMirror = std::sqrt(rmsMirror);
160   else
161     rmsMirror = 0.;
162 
163   fDetectorHits = fDetectorHits / TotNbofEvents;
164   fDetectorHits2 = fDetectorHits2 / TotNbofEvents;
165   G4double rmsDetectorHits = fDetectorHits2 - fDetectorHits * fDetectorHits;
166   if (rmsDetectorHits > 0.)
167     rmsDetectorHits = std::sqrt(rmsDetectorHits);
168   else
169     rmsDetectorHits = 0.;
170 
171   G4int prec = G4cout.precision(3);
172   G4cout << "\n ======================== run summary =====================\n";
173   G4cout << "Average number per event:" << G4endl;
174   G4cout << " TIR:          " << fNTIR << " +- " << rmsTIR << G4endl
175          << " Exiting:      " << fNExiting << " +- " << rmsExiting << G4endl
176          << " Escaped Mid:  " << fEscapedMid << " +- " << rmsEscapedMid << G4endl
177          << " Escaped End:  " << fEscapedEnd << " +- " << rmsEscapedEnd << G4endl
178          << " Bounced:      " << fBounce << " +- " << rmsBounce << G4endl
179          << " WLS Bounce:   " << fWLSBounce << " +- " << rmsWLSBounce << G4endl
180          << " Clad1 Bounce: " << fClad1Bounce << " +- " << rmsClad1Bounce << G4endl
181          << " Clad2 Bounce: " << fClad2Bounce << " +- " << rmsClad2Bounce << G4endl
182          << " Reflected:    " << fReflected << " +- " << rmsReflected << G4endl
183          << " Escaped:      " << fEscaped << " +- " << rmsEscaped << G4endl
184          << " Mirror:       " << fMirror << " +- " << rmsMirror << G4endl
185          << " Detector hit: " << fDetectorHits << " +- " << rmsDetectorHits << G4endl;
186 
187   G4cout << G4endl;
188   G4cout.precision(prec);
189 }
190