ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExGflashEventAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ExGflashEventAction.cc
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 //
29 //
30 // Created by Joanna Weng 26.11.2004
31 
32 
33 #include "ExGflashEventAction.hh"
34 #include "ExGflashHit.hh"
35 #include "ExGflashHistoManager.hh"
37 #include "G4EventManager.hh"
38 #include "G4SDManager.hh"
39 #include "G4UImanager.hh"
40 #include "G4Event.hh"
41 #include "G4SystemOfUnits.hh"
42 //std
43 #include <iostream>
44 #include <algorithm>
45 #include <vector>
46 typedef std::vector<G4double> MyVector;
47 
48 //Gflash
49 using namespace std;
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52 
54  : G4UserEventAction(),fCalorimeterCollectionId(-1),fDet(det)
55 {
56 }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61 {
62 }
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 
67 {
68 }
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71 
73 {
74 
76  G4String colNam;
77  fCalorimeterCollectionId=SDman->GetCollectionID(colNam="ExGflashCollection");
78 
79  if (fCalorimeterCollectionId<0) return;
80 
81  G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
82  ExGflashHitsCollection* THC = 0;
83  G4double totE = 0;
84 
85  // Read out of the crysta ECAL
87 
88  if (THC)
89  {
91  int n_hit = THC->entries();
92  // G4cout<<" " << n_hit<< " hits are stored in ExGflashHitsCollection "<<G4endl;
93  G4PrimaryVertex* pvertex=evt->GetPrimaryVertex();
94  //Computing (x,y,z) of vertex of initial particles
95  G4ThreeVector vtx=pvertex->GetPosition();
96  G4PrimaryParticle* pparticle=pvertex->GetPrimary();
97  // direction of the Shower
99 
100  G4double Ekin=pparticle->GetKineticEnergy();
102  G4double Etot = Ekin/MeV + mass/MeV;
103 
104  G4int nLbin = fDet->GetnLtot();
105  G4int nRbin = fDet->GetnRtot();
106  G4double dLradl = fDet->GetdLradl();
107  G4double dRradl = fDet->GetdRradl();
108 
109  G4double SDRadl = fDet->GetSDRadLen(); // SD matrial
110  // init to to 0.0
111  MyVector dEdL(nLbin,0.0);
112  MyVector dEdR(nRbin,0.0);
113 
114  G4AnalysisManager* fAnalysisManager = G4AnalysisManager::Instance();
115 
116  fAnalysisManager->FillH1(1,n_hit + 0.5);
118  for (int i=0;i<n_hit;i++)
119  {
120  G4double estep = (*THC)[i]->GetEdep();
121  fAnalysisManager->FillH1(2,estep/MeV);
122  estep /= MeV;
123 
124  if (estep >0.0)
125  {
126  totE += estep;
127 
128  G4ThreeVector hitpos=(*THC)[i]->GetPos();
129  // in shower coordinate system
130  // from shower start
131  G4ThreeVector l = hitpos - vtx;
132  //longitudinal profile
133  G4ThreeVector longitudinal = l.dot(mom) * mom;
134  // shower profiles (Radial)
135  G4ThreeVector radial = l - longitudinal;
136 
137  G4int SlideNb = G4int((longitudinal.mag()/SDRadl) / dLradl);
138  G4int RingNb = G4int((radial.mag()/SDRadl) / dRradl);
139 
140  if ( SlideNb >=0 && SlideNb < nLbin) dEdL[SlideNb] += estep;
141  if ( RingNb >=0 && RingNb < nLbin)dEdR[RingNb] += estep;
142  }
143  }
144 
145  G4double Lnorm = 100. / dLradl / Etot;
146  G4double Lsum = 0.0;
147  for (int i=0;i<nLbin;i++)
148  { // Slide
149  // fAnalysisManager->FillH1(3,(i +0.5) * dLradl,dEdL[i] * Lnorm);
150  fAnalysisManager->FillP1(0,(i +0.5) * dLradl,dEdL[i] * Lnorm);
151  Lsum += dEdL[i];
152  fAnalysisManager->FillP1(2,(i +0.5) * dLradl,Lsum * Lnorm);
153  }
154  G4double Rnorm = 100. / dRradl / Etot;
155  G4double Rsum = 0.0;
156  for (int i=0;i<nRbin;i++)
157  { // Ring
158  // fAnalysisManager->FillH1(4,(i +0.5) * dRradl,dEdR[i] * Rnorm);
159  fAnalysisManager->FillP1(1,(i +0.5) * dRradl,dEdR[i] * Rnorm);
160  Rsum += dEdR[i];
161  fAnalysisManager->FillP1(3,(i +0.5) * dRradl,Rsum * Rnorm);
162  }
163 
164  fAnalysisManager->FillH1(0,totE/Etot * 100.);
165 
166  }
167 }
168 
169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......