Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Par02FastSimModelEMCal.cc
Go to the documentation of this file.
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 // $Id: $
27 //
30 
32 #include "Par02EventInformation.hh"
34 #include "Par02Smearer.hh"
35 #include "Par02Output.hh"
36 
37 #include "G4Track.hh"
38 #include "G4Event.hh"
39 #include "G4RunManager.hh"
40 #include "g4root.hh"
41 
42 #include "Randomize.hh"
43 #include "G4SystemOfUnits.hh"
44 
45 #include "G4Electron.hh"
46 #include "G4Positron.hh"
47 #include "G4Gamma.hh"
48 
49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
50 
53  G4VFastSimulationModel( aModelName, aEnvelope ), fCalculateParametrisation(),
54  fParametrisation( aType ) {}
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
59  G4Region* aEnvelope ) :
60  G4VFastSimulationModel( aModelName, aEnvelope ), fCalculateParametrisation(),
61  fParametrisation( Par02DetectorParametrisation::eCMS ) {}
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64 
66  G4VFastSimulationModel( aModelName ), fCalculateParametrisation(),
67  fParametrisation( Par02DetectorParametrisation::eCMS ) {}
68 
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70 
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74 
76  const G4ParticleDefinition& aParticleType ) {
77  // Applicable for electrons, positrons, and gammas
78  return &aParticleType == G4Electron::Definition() ||
79  &aParticleType == G4Positron::Definition() ||
80  &aParticleType == G4Gamma::Definition();
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
84 
86  return true; // No kinematical restrictions to apply the parametrisation
87 }
88 
89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90 
91 void Par02FastSimModelEMCal::DoIt( const G4FastTrack& aFastTrack,
92  G4FastStep& aFastStep ) {
93  //G4cout << " ________EMCal model triggered _________" << G4endl;
94 
95  // Kill the parameterised particle at the entrance of the electromagnetic calorimeter
96  aFastStep.KillPrimaryTrack();
97  aFastStep.ProposePrimaryTrackPathLength( 0.0 );
98  G4double Edep = aFastTrack.GetPrimaryTrack()->GetKineticEnergy();
99 
100  // Consider only primary tracks (do nothing else for secondary e-, e+, gammas)
101  G4ThreeVector Pos = aFastTrack.GetPrimaryTrack()->GetPosition();
102  if ( ! aFastTrack.GetPrimaryTrack()->GetParentID() ) {
105  if ( info->GetDoSmearing() ) {
106  // Smearing according to the electromagnetic calorimeter resolution
107  G4ThreeVector Porg = aFastTrack.GetPrimaryTrack()->GetMomentum();
108  G4double res = fCalculateParametrisation->GetResolution(
109  Par02DetectorParametrisation::eEMCAL, fParametrisation, Porg.mag() );
110  G4double eff = fCalculateParametrisation->GetEfficiency(
111  Par02DetectorParametrisation::eEMCAL, fParametrisation, Porg.mag() );
112  G4double Esm;
113  Esm = std::abs( Par02Smearer::Instance()->
114  SmearEnergy( aFastTrack.GetPrimaryTrack(), res ) );
115  Par02Output::Instance()->FillHistogram( 1, (Esm/MeV) / (Edep/MeV) );
116  // Setting the values of Pos, Esm, res and eff
117  ( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
118  ( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
119  GetUserInformation() ) )->SetEMCalPosition( Pos );
120  ( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
121  ( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
122  GetUserInformation() ) )->SetEMCalEnergy( Esm );
123  ( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
124  ( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
125  GetUserInformation() ) )->SetEMCalResolution( res );
126  ( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
127  ( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
128  GetUserInformation() ) )->SetEMCalEfficiency( eff );
129  // The (smeared) energy of the particle is deposited in the step
130  // (which corresponds to the entrance of the electromagnetic calorimeter)
131  aFastStep.ProposeTotalEnergyDeposited( Esm );
132  } else {
133  // No smearing: simply setting the value of Edep
134  ( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
135  ( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
136  GetUserInformation() ) )->SetEMCalEnergy( Edep );
137  // The (initial) energy of the particle is deposited in the step
138  // (which corresponds to the entrance of the electromagnetic calorimeter)
139  aFastStep.ProposeTotalEnergyDeposited( Edep );
140  }
141  }
142 }
143 
144 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
145 
const XML_Char XML_Encoding * info
Definition: expat.h:530
G4int GetParentID() const
Definition of the Par02EventInformation class.
const G4Track * GetPrimaryTrack() const
Definition: G4FastTrack.hh:208
static Par02Smearer * Instance()
Definition: Par02Smearer.cc:59
virtual G4bool IsApplicable(const G4ParticleDefinition &aParticle)
const G4DynamicParticle * GetDynamicParticle() const
ush Pos
Definition: deflate.h:89
const G4ThreeVector & GetPosition() const
static G4Electron * Definition()
Definition: G4Electron.cc:49
Parametrisation
A parametrisation type (CMS, ATLAS, ALEPH).
static G4Positron * Definition()
Definition: G4Positron.cc:49
Definition of the Par02FastSimModelEMCal class.
Definition of the Par02PrimaryParticleInformation class.
void FillHistogram(G4int HNo, G4double value) const
Definition: Par02Output.cc:219
Definition of the Par02Smearer class.
G4double GetKineticEnergy() const
bool G4bool
Definition: G4Types.hh:79
void ProposePrimaryTrackPathLength(G4double)
Definition of the Par02Output class.
static Par02Output * Instance()
Definition: Par02Output.cc:60
G4double GetResolution(Detector aDetector, Parametrisation aParametrisation, G4double aMomentum)
G4PrimaryParticle * GetPrimaryParticle() const
G4ThreeVector GetMomentum() const
virtual void DoIt(const G4FastTrack &aFastTrack, G4FastStep &aFastStep)
static G4EventManager * GetEventManager()
Par02FastSimModelEMCal(G4String aModelName, G4Region *aEnvelope, Par02DetectorParametrisation::Parametrisation aParamType)
void ProposeTotalEnergyDeposited(G4double anEnergyPart)
G4double GetEfficiency(Detector aDetector, Parametrisation aParametrisation, G4double aMomentum)
static constexpr double MeV
Definition: G4SIunits.hh:214
void KillPrimaryTrack()
Definition: G4FastStep.cc:88
double G4double
Definition: G4Types.hh:76
double mag() const
G4bool GetDoSmearing()
Gets the flag indicating if smearing should be done.
virtual G4bool ModelTrigger(const G4FastTrack &aFastTrack)
static G4Gamma * Definition()
Definition: G4Gamma.cc:49
G4VUserEventInformation * GetUserInformation()