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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 ]

Diff markup

Differences between /examples/advanced/nanobeam/src/RunAction.cc (Version 11.3.0) and /examples/advanced/nanobeam/src/RunAction.cc (Version 9.4.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // Please cite the following paper if you use  <<  26 // -------------------------------------------------------------------
 27 // Nucl.Instrum.Meth.B260:20-27, 2007          <<  27 // $Id: RunAction.cc,v 1.4 2010-10-06 12:16:59 sincerti Exp $
 28                                                <<  28 // -------------------------------------------------------------------
 29 // #define MATRIX_BOUND_CHECK                  <<  29 
                                                   >>  30 #include "G4SteppingManager.hh"
                                                   >>  31 #include "G4Run.hh"
                                                   >>  32 #include "G4Material.hh"
                                                   >>  33 #include "G4UImanager.hh"
                                                   >>  34 #include "G4ios.hh"
                                                   >>  35 #include "G4UnitsTable.hh"
                                                   >>  36 
                                                   >>  37 #include "Randomize.hh"
                                                   >>  38 #include <iomanip>
                                                   >>  39 #include <assert.h>
 30                                                    40 
 31 #include "RunAction.hh"                            41 #include "RunAction.hh"
 32 #include "G4AnalysisManager.hh"                << 
 33 #include "G4AutoLock.hh"                       << 
 34                                                << 
 35 namespace                                      << 
 36 {                                              << 
 37   G4Mutex aMutex = G4MUTEX_INITIALIZER;        << 
 38 }                                              << 
 39                                                    42 
                                                   >>  43 // MATRIX
                                                   >>  44 #define MATRIX_BOUND_CHECK
                                                   >>  45 #include "globals.hh"
                                                   >>  46 #include <iostream>
                                                   >>  47 #include "CLHEP/Matrix/Matrix.h"
                                                   >>  48 #include "CLHEP/Matrix/Vector.h"
                                                   >>  49 #include <fstream>
                                                   >>  50 #include "G4ios.hh"
                                                   >>  51 #include <fstream>
                                                   >>  52 #include <vector>
                                                   >>  53 #include <cmath>
 40 using namespace std;                               54 using namespace std;
 41                                                    55 
 42 //....oooOO0OOooo........oooOO0OOooo........oo     56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 43                                                    57 
 44 RunAction::RunAction(DetectorConstruction* det <<  58 RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* pri,
 45 :fDetector(det),fPrimary(pri)                  <<  59 HistoManager* hi)
 46 {}                                             <<  60 :detector(det),primary(pri),hist(hi)
                                                   >>  61 {   
                                                   >>  62 }
 47                                                    63 
 48 //....oooOO0OOooo........oooOO0OOooo........oo     64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 49                                                    65 
 50 RunAction::~RunAction()                            66 RunAction::~RunAction()
 51 {}                                                 67 {}
 52                                                    68 
 53 //....oooOO0OOooo........oooOO0OOooo........oo     69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 54                                                    70 
 55 void RunAction::BeginOfRunAction(const G4Run*      71 void RunAction::BeginOfRunAction(const G4Run* /*aRun*/)
 56 {                                                  72 {
 57    // Vector initialization                        73    // Vector initialization 
 58                                                <<  74    row=0;
 59    fRow=0;                                     << 
 60                                                    75      
 61    fXVector = CLHEP::HepVector(32);            <<  76    xVector = CLHEP::HepVector(32);
 62    fYVector = CLHEP::HepVector(32);            <<  77    yVector = CLHEP::HepVector(32);
 63    fThetaVector = CLHEP::HepVector(32);        <<  78    thetaVector = CLHEP::HepVector(32);
 64    fPhiVector = CLHEP::HepVector(32);          <<  79    phiVector = CLHEP::HepVector(32);
 65                                                    80    
 66    // Histograms                               <<  81   // Histograms
 67                                                <<  82   hist->book();
 68    // Get/create analysis manager              << 
 69    G4cout << "##### Create analysis manager "  << 
 70                                                << 
 71    G4AnalysisManager* man = G4AnalysisManager: << 
 72    man->SetDefaultFileType("root");            << 
 73                                                << 
 74    G4cout << "Using " << man->GetType() << " a << 
 75                                                << 
 76    // Open an output file                      << 
 77    man->OpenFile("nanobeam");                  << 
 78    man->SetFirstHistoId(1);                    << 
 79    man->SetFirstNtupleId(1);                   << 
 80                                                << 
 81    // Create 1st ntuple (id = 1)               << 
 82    man->CreateNtuple("ntuple0", "BeamProfile") << 
 83    man->CreateNtupleDColumn("xIn");            << 
 84    man->CreateNtupleDColumn("yIn");            << 
 85    man->CreateNtupleDColumn("zIn");            << 
 86    man->FinishNtuple();                        << 
 87    G4cout << "Ntuple-1 created" << G4endl;     << 
 88                                                << 
 89    // Create 2nd htuple (id = 2)               << 
 90    man->CreateNtuple("ntuple1","Grid");        << 
 91    man->CreateNtupleDColumn("xIn");            << 
 92    man->CreateNtupleDColumn("yIn");            << 
 93    man->CreateNtupleDColumn("e");              << 
 94    man->FinishNtuple();                        << 
 95    G4cout << "Ntuple-2 created" << G4endl;     << 
 96                                                << 
 97    // Create 3rd ntuple (id = 3)               << 
 98    man->CreateNtuple("ntuple2","Coef");        << 
 99    man->CreateNtupleDColumn("xIn");            << 
100    man->CreateNtupleDColumn("yIn");            << 
101    man->CreateNtupleDColumn("thetaIn");        << 
102    man->CreateNtupleDColumn("phiIn");          << 
103    man->FinishNtuple();                        << 
104    G4cout << "Ntuple-3 created" << G4endl;     << 
105                                                << 
106    return;                                     << 
107                                                    83 
108 }                                                  84 }
109                                                    85  
110 //....oooOO0OOooo........oooOO0OOooo........oo     86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
111                                                    87 
112 void RunAction::EndOfRunAction(const G4Run* /*     88 void RunAction::EndOfRunAction(const G4Run* /*aRun*/)
113 {                                                  89 {
114                                                    90 
115 if (fDetector->GetCoef()==1)                   <<  91 if (detector->GetCoef()==1)
116 {                                                  92 {
117         // 17/12/2013 - thanks to A. Dotti     <<  93 
118   // CLHEP Matrix inversion (as for CLHEP vers << 
119         // is not thread safe, we need to prot << 
120         // Since this is not performance criti << 
121         // all this part.                      << 
122   G4AutoLock l(&aMutex);                       << 
123         //                                     << 
124                                                << 
125   CLHEP::HepMatrix m;                              94   CLHEP::HepMatrix m;
126                                                    95   
127   // VECTOR READING                                96   // VECTOR READING
128   // VECTOR READING                                97   // VECTOR READING
129                                                    98 
130   m = CLHEP::HepMatrix(32,32);                     99   m = CLHEP::HepMatrix(32,32);
131   m = fPrimary->GetMatrix();                   << 100   m = primary->GetMatrix();
132                                                   101 
133   G4cout << G4endl;                               102   G4cout << G4endl;
134   G4cout << "===> NANOBEAM LINE INTRINSIC ABER    103   G4cout << "===> NANOBEAM LINE INTRINSIC ABERRATION COEFFICIENTS (units of micrometer and mrad) :" << G4endl;
135   G4cout << G4endl;                               104   G4cout << G4endl;
136                                                   105 
137   int inv;                                        106   int inv;
138                                                   107 
139   m.invert(inv);                                  108   m.invert(inv);
140   CLHEP::HepVector tmp(32,0);                     109   CLHEP::HepVector tmp(32,0);
141   tmp=m*fXVector;                              << 110   tmp=m*xVector;
142   CLHEP::HepVector b;                             111   CLHEP::HepVector b;
143   b=tmp.sub(2,2);   G4cout << "<x|theta>=" <<     112   b=tmp.sub(2,2);   G4cout << "<x|theta>=" << b << G4endl;
144   b=tmp.sub(8,8);   G4cout << "<x|theta*delta>    113   b=tmp.sub(8,8);   G4cout << "<x|theta*delta>=" << b << G4endl;
145   b=tmp.sub(10,10); G4cout << "<x|theta^3>=" <    114   b=tmp.sub(10,10); G4cout << "<x|theta^3>=" << b << G4endl;
146   b=tmp.sub(12,12); G4cout << "<x|theta*phi^2>    115   b=tmp.sub(12,12); G4cout << "<x|theta*phi^2>=" << b << G4endl;
147   m.invert(inv);                                  116   m.invert(inv);
148                                                   117 
149   m.invert(inv);                                  118   m.invert(inv);
150   tmp = m*fThetaVector;                        << 119   tmp = m*thetaVector;
151   m.invert(inv);                                  120   m.invert(inv);
152   b=tmp.sub(2,2); G4cout << "<x|x>=" << b << G    121   b=tmp.sub(2,2); G4cout << "<x|x>=" << b << G4endl;
153                                                   122 
154   m.invert(inv);                                  123   m.invert(inv);
155   tmp=m*fYVector;                              << 124   tmp=m*yVector;
156   b=tmp.sub(3,3);   G4cout << "<y|phi>=" << b     125   b=tmp.sub(3,3);   G4cout << "<y|phi>=" << b << G4endl;
157   b=tmp.sub(9,9);   G4cout << "<y|phi*delta>="    126   b=tmp.sub(9,9);   G4cout << "<y|phi*delta>=" << b << G4endl;
158   b=tmp.sub(11,11); G4cout << "<y|theta^2*phi>    127   b=tmp.sub(11,11); G4cout << "<y|theta^2*phi>=" << b << G4endl;
159   b=tmp.sub(13,13); G4cout << "<y|phi^3>=" <<     128   b=tmp.sub(13,13); G4cout << "<y|phi^3>=" << b << G4endl;
160   m.invert(inv);                                  129   m.invert(inv);
161                                                   130 
162   m.invert(inv);                                  131   m.invert(inv);
163   tmp = m*fPhiVector;                          << 132   tmp = m*phiVector;
164   m.invert(inv);                                  133   m.invert(inv);
165   b=tmp.sub(3,3); G4cout << "<y|y>=" << b << G    134   b=tmp.sub(3,3); G4cout << "<y|y>=" << b << G4endl;
166                                                   135 
167 }                                                 136 }
168                                                   137 
169  // Save histograms                            << 138   //save histograms      
170                                                << 139   hist->save();
171  G4AnalysisManager* man = G4AnalysisManager::I << 140 
172  man->Write();                                 << 
173  man->CloseFile();                             << 
174                                                << 
175  // Complete clean-up                          << 
176  man->Clear();                                 << 
177 }                                                 141 }
                                                   >> 142 
                                                   >> 143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
178                                                   144