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.p3 ] [ 10.5 ] [ 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/extended/parameterisations/gflash/gflash2/src/ExGflashEventAction.cc (Version 11.3.0) and /examples/extended/parameterisations/gflash/gflash2/src/ExGflashEventAction.cc (Version 11.2.2)


  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 //                                                 26 //
 27 /// \file ExGflashEventAction.cc                   27 /// \file ExGflashEventAction.cc
 28 /// \brief Implementation of the ExGflashEvent     28 /// \brief Implementation of the ExGflashEventAction class
 29 //                                                 29 //
 30 // Created by Joanna Weng 26.11.2004               30 // Created by Joanna Weng 26.11.2004
 31                                                    31 
 32 #include "ExGflashEventAction.hh"                  32 #include "ExGflashEventAction.hh"
 33                                                    33 
 34 #include "ExGflashHit.hh"                          34 #include "ExGflashHit.hh"
 35                                                    35 
 36 #include "G4Event.hh"                              36 #include "G4Event.hh"
 37 #include "G4EventManager.hh"                       37 #include "G4EventManager.hh"
 38 #include "G4SDManager.hh"                          38 #include "G4SDManager.hh"
 39 #include "G4SystemOfUnits.hh"                      39 #include "G4SystemOfUnits.hh"
 40 #include "G4TrajectoryContainer.hh"                40 #include "G4TrajectoryContainer.hh"
 41 #include "G4UImanager.hh"                          41 #include "G4UImanager.hh"
 42 // std                                             42 // std
 43 #include <algorithm>                               43 #include <algorithm>
 44 #include <iostream>                                44 #include <iostream>
 45 // Gflash                                          45 // Gflash
 46 using namespace std;                               46 using namespace std;
 47                                                    47 
 48 //....oooOO0OOooo........oooOO0OOooo........oo     48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 49                                                    49 
 50 ExGflashEventAction::ExGflashEventAction() = d     50 ExGflashEventAction::ExGflashEventAction() = default;
 51                                                    51 
 52 //....oooOO0OOooo........oooOO0OOooo........oo     52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 53                                                    53 
 54 ExGflashEventAction::~ExGflashEventAction()        54 ExGflashEventAction::~ExGflashEventAction()
 55 {                                                  55 {
 56   if (fNevent > 0) {                               56   if (fNevent > 0) {
 57     G4cout << "Internal Real Elapsed Time /eve     57     G4cout << "Internal Real Elapsed Time /event is: " << fDtime / fNevent << G4endl;
 58   }                                                58   }
 59 }                                                  59 }
 60                                                    60 
 61 //....oooOO0OOooo........oooOO0OOooo........oo     61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 62                                                    62 
 63 void ExGflashEventAction::BeginOfEventAction(c     63 void ExGflashEventAction::BeginOfEventAction(const G4Event* evt)
 64 {                                                  64 {
 65   fTimerIntern.Start();                            65   fTimerIntern.Start();
 66   G4cout << " ------ Start ExGflashEventAction     66   G4cout << " ------ Start ExGflashEventAction ----- " << G4endl;
 67   fNevent = evt->GetEventID();                     67   fNevent = evt->GetEventID();
 68   G4cout << " Start generating event Nr " << f     68   G4cout << " Start generating event Nr " << fNevent << G4endl << G4endl;
 69 }                                                  69 }
 70                                                    70 
 71 //....oooOO0OOooo........oooOO0OOooo........oo     71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 72                                                    72 
 73 void ExGflashEventAction::EndOfEventAction(con     73 void ExGflashEventAction::EndOfEventAction(const G4Event* evt)
 74 {                                                  74 {
 75   fTimerIntern.Stop();                             75   fTimerIntern.Stop();
 76   G4cout << G4endl;                                76   G4cout << G4endl;
 77   G4cout << "*********************************     77   G4cout << "******************************************";
 78   G4cout << G4endl;                                78   G4cout << G4endl;
 79   G4cout << "Internal Real Elapsed Time is: "      79   G4cout << "Internal Real Elapsed Time is: " << fTimerIntern.GetRealElapsed();
 80   G4cout << G4endl;                                80   G4cout << G4endl;
 81   G4cout << "Internal System Elapsed Time: " <     81   G4cout << "Internal System Elapsed Time: " << fTimerIntern.GetSystemElapsed();
 82   G4cout << G4endl;                                82   G4cout << G4endl;
 83   G4cout << "Internal GetUserElapsed Time: " <     83   G4cout << "Internal GetUserElapsed Time: " << fTimerIntern.GetUserElapsed();
 84   G4cout << G4endl;                                84   G4cout << G4endl;
 85   G4cout << "*********************************     85   G4cout << "******************************************" << G4endl;
 86   fDtime += fTimerIntern.GetRealElapsed();         86   fDtime += fTimerIntern.GetRealElapsed();
 87   G4cout << " ------ ExGflashEventAction::End      87   G4cout << " ------ ExGflashEventAction::End of event nr. " << fNevent << "  -----" << G4endl;
 88                                                    88 
 89   G4SDManager* SDman = G4SDManager::GetSDMpoin     89   G4SDManager* SDman = G4SDManager::GetSDMpointer();
 90   G4String colNam;                                 90   G4String colNam;
 91   fCalorimeterCollectionId = SDman->GetCollect     91   fCalorimeterCollectionId = SDman->GetCollectionID(colNam = "ExGflashCollection");
 92   if (fCalorimeterCollectionId < 0) return;        92   if (fCalorimeterCollectionId < 0) return;
 93   G4HCofThisEvent* HCE = evt->GetHCofThisEvent     93   G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
 94   ExGflashHitsCollection* THC = nullptr;           94   ExGflashHitsCollection* THC = nullptr;
 95   G4double totE = 0;                               95   G4double totE = 0;
 96   // Read out of the crysta ECAL                   96   // Read out of the crysta ECAL
 97   THC = (ExGflashHitsCollection*)(HCE->GetHC(f     97   THC = (ExGflashHitsCollection*)(HCE->GetHC(fCalorimeterCollectionId));
 98   if (THC) {                                       98   if (THC) {
 99     /// Hits in sensitive Detector                 99     /// Hits in sensitive Detector
100     int n_hit = THC->entries();                   100     int n_hit = THC->entries();
101     G4cout << "  " << n_hit << " hits are stor    101     G4cout << "  " << n_hit << " hits are stored in ExGflashHitsCollection " << G4endl;
102     G4PrimaryVertex* pvertex = evt->GetPrimary    102     G4PrimaryVertex* pvertex = evt->GetPrimaryVertex();
103     /// Computing (x,y,z) of vertex of initial    103     /// Computing (x,y,z) of vertex of initial particles
104     G4ThreeVector vtx = pvertex->GetPosition()    104     G4ThreeVector vtx = pvertex->GetPosition();
105     G4PrimaryParticle* pparticle = pvertex->Ge    105     G4PrimaryParticle* pparticle = pvertex->GetPrimary();
106     // direction of the Shower                    106     // direction of the Shower
107     G4ThreeVector mom = pparticle->GetMomentum    107     G4ThreeVector mom = pparticle->GetMomentum() / pparticle->GetMomentum().mag();
108                                                   108 
109     //@@@ ExGflashEventAction: Magicnumber        109     //@@@ ExGflashEventAction: Magicnumber
110     G4double energyincrystal[100];                110     G4double energyincrystal[100];
111     G4int hitsincrystal[100];                     111     G4int hitsincrystal[100];
112     for (int i = 0; i < 100; i++)                 112     for (int i = 0; i < 100; i++)
113       energyincrystal[i] = 0.;                    113       energyincrystal[i] = 0.;
114     for (int i = 0; i < 100; i++)                 114     for (int i = 0; i < 100; i++)
115       hitsincrystal[i] = 0.;                      115       hitsincrystal[i] = 0.;
116                                                   116 
117     //@@@ ExGflashEventAction: Magicnumber        117     //@@@ ExGflashEventAction: Magicnumber
118     /// For all Hits in sensitive detector        118     /// For all Hits in sensitive detector
119     for (int i = 0; i < n_hit; i++) {             119     for (int i = 0; i < n_hit; i++) {
120       G4double estep = (*THC)[i]->GetEdep() /     120       G4double estep = (*THC)[i]->GetEdep() / GeV;
121       if (estep > 0.0) {                          121       if (estep > 0.0) {
122         totE += (*THC)[i]->GetEdep() / GeV;       122         totE += (*THC)[i]->GetEdep() / GeV;
123         G4int num = (*THC)[i]->GetCrystalNum()    123         G4int num = (*THC)[i]->GetCrystalNum();
124                                                   124 
125         energyincrystal[num] += (*THC)[i]->Get    125         energyincrystal[num] += (*THC)[i]->GetEdep() / GeV;
126         hitsincrystal[num]++;                     126         hitsincrystal[num]++;
127         // G4cout << num << G4endl;               127         // G4cout << num << G4endl;
128         //   G4cout << " Crystal Nummer " <<      128         //   G4cout << " Crystal Nummer " <<  (*THC)[i]->GetCrystalNum()  << G4endl;
129         //   G4cout <<  (*THC)[i]->GetCrystalN    129         //   G4cout <<  (*THC)[i]->GetCrystalNum() /10 <<
130         //  "  "<<(*THC)[i]->GetCrystalNum()%1    130         //  "  "<<(*THC)[i]->GetCrystalNum()%10 << G4endl;
131                                                   131 
132         G4ThreeVector hitpos = (*THC)[i]->GetP    132         G4ThreeVector hitpos = (*THC)[i]->GetPos();
133         G4ThreeVector l(hitpos.x(), hitpos.y()    133         G4ThreeVector l(hitpos.x(), hitpos.y(), hitpos.z());
134         // distance from shower start             134         // distance from shower start
135         l = l - vtx;                              135         l = l - vtx;
136         // projection on shower axis = longitu    136         // projection on shower axis = longitudinal profile
137         G4ThreeVector longitudinal = l;           137         G4ThreeVector longitudinal = l;
138         // shower profiles (Radial)               138         // shower profiles (Radial)
139         G4ThreeVector radial = vtx.cross(l);      139         G4ThreeVector radial = vtx.cross(l);
140       }                                           140       }
141     }                                             141     }
142     G4double max = 0;                             142     G4double max = 0;
143     G4int index = 0;                              143     G4int index = 0;
144     // Find crystal with maximum energy           144     // Find crystal with maximum energy
145     for (int i = 0; i < 100; i++) {               145     for (int i = 0; i < 100; i++) {
146       // G4cout << i <<"  " << energyincrystal    146       // G4cout << i <<"  " << energyincrystal[i] << G4endl;
147       if (max < energyincrystal[i]) {             147       if (max < energyincrystal[i]) {
148         max = energyincrystal[i];                 148         max = energyincrystal[i];
149         index = i;                                149         index = i;
150       }                                           150       }
151     }                                             151     }
152     // G4cout << index <<" NMAX  " << index <<    152     // G4cout << index <<" NMAX  " << index << G4endl;
153                                                   153 
154     // 3x3 matrix of crystals around the cryst    154     // 3x3 matrix of crystals around the crystal with the maximum energy deposit
155     G4double e3x3 = energyincrystal[index] + e    155     G4double e3x3 = energyincrystal[index] + energyincrystal[index + 1] + energyincrystal[index - 1]
156                     + energyincrystal[index -     156                     + energyincrystal[index - 10] + energyincrystal[index - 9]
157                     + energyincrystal[index -     157                     + energyincrystal[index - 11] + energyincrystal[index + 10]
158                     + energyincrystal[index +     158                     + energyincrystal[index + 11] + energyincrystal[index + 9];
159                                                   159 
160     // 5x5 matrix of crystals around the cryst    160     // 5x5 matrix of crystals around the crystal with the maximum energy deposit
161     G4double e5x5 =                               161     G4double e5x5 =
162       energyincrystal[index] + energyincrystal    162       energyincrystal[index] + energyincrystal[index + 1] + energyincrystal[index - 1]
163       + energyincrystal[index + 2] + energyinc    163       + energyincrystal[index + 2] + energyincrystal[index - 2] + energyincrystal[index - 10]
164       + energyincrystal[index - 9] + energyinc    164       + energyincrystal[index - 9] + energyincrystal[index - 11] + energyincrystal[index - 8]
165       + energyincrystal[index - 12] + energyin    165       + energyincrystal[index - 12] + energyincrystal[index + 10] + energyincrystal[index + 11]
166       + energyincrystal[index + 9] + energyinc    166       + energyincrystal[index + 9] + energyincrystal[index + 12] + energyincrystal[index + 8];
167                                                   167 
168     // 3x3 matrix of crystals around the cryst    168     // 3x3 matrix of crystals around the crystal with the maximum energy deposit
169     G4int num3x3 = hitsincrystal[index] + hits    169     G4int num3x3 = hitsincrystal[index] + hitsincrystal[index + 1] + hitsincrystal[index - 1]
170                    + hitsincrystal[index - 10]    170                    + hitsincrystal[index - 10] + hitsincrystal[index - 9]
171                    + hitsincrystal[index - 11]    171                    + hitsincrystal[index - 11] + hitsincrystal[index + 10]
172                    + hitsincrystal[index + 11]    172                    + hitsincrystal[index + 11] + hitsincrystal[index + 9];
173                                                   173 
174     // 5x5 matrix of crystals around the cryst    174     // 5x5 matrix of crystals around the crystal with the maximum energy deposit
175     G4int num5x5 = hitsincrystal[index] + hits    175     G4int num5x5 = hitsincrystal[index] + hitsincrystal[index + 1] + hitsincrystal[index - 1]
176                    + hitsincrystal[index + 2]     176                    + hitsincrystal[index + 2] + hitsincrystal[index - 2] + hitsincrystal[index - 10]
177                    + hitsincrystal[index - 9]     177                    + hitsincrystal[index - 9] + hitsincrystal[index - 11] + hitsincrystal[index - 8]
178                    + hitsincrystal[index - 12]    178                    + hitsincrystal[index - 12] + hitsincrystal[index + 10]
179                    + hitsincrystal[index + 11]    179                    + hitsincrystal[index + 11] + hitsincrystal[index + 9]
180                    + hitsincrystal[index + 12]    180                    + hitsincrystal[index + 12] + hitsincrystal[index + 8];
181                                                   181 
182     G4cout << "   e1  " << energyincrystal[ind    182     G4cout << "   e1  " << energyincrystal[index] << "   e3x3  " << e3x3 << "   GeV  e5x5  " << e5x5
183            << G4endl;                             183            << G4endl;
184                                                   184 
185     G4cout << "   num1  " << hitsincrystal[ind    185     G4cout << "   num1  " << hitsincrystal[index] << "   num3x3  " << num3x3 << "    num5x5  "
186            << num5x5 << G4endl;                   186            << num5x5 << G4endl;
187   }                                               187   }
188                                                   188 
189   G4cout << " Total energy deposited in the ca    189   G4cout << " Total energy deposited in the calorimeter: " << totE << " (GeV)" << G4endl;
190   G4TrajectoryContainer* trajectoryContainer =    190   G4TrajectoryContainer* trajectoryContainer = evt->GetTrajectoryContainer();
191   G4int n_trajectories = 0;                       191   G4int n_trajectories = 0;
192   if (trajectoryContainer) {                      192   if (trajectoryContainer) {
193     n_trajectories = trajectoryContainer->entr    193     n_trajectories = trajectoryContainer->entries();
194   }                                               194   }
195   G4cout << "    " << n_trajectories << " traj    195   G4cout << "    " << n_trajectories << " trajectories stored in this event." << G4endl;
196 }                                                 196 }
197                                                   197 
198 //....oooOO0OOooo........oooOO0OOooo........oo    198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
199                                                   199