ATLAS Offline Software
CosmicGenerator.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
58 #ifndef GENERATORMODULESCOSMICGEN_H
59 #define GENERATORMODULESCOSMICGEN_H
60 
62 
63 #include "CLHEP/Vector/LorentzVector.h"
65 
66 #include <iostream>
67 #include <fstream>
68 #include <vector>
69 #include <string>
70 
71 
72 
73 class CosmicGun;
74 
75 class CosmicGenerator:public GenModule {
76 
77 public:
78  CosmicGenerator(const std::string& name, ISvcLocator* pSvcLocator);
79  virtual ~CosmicGenerator() = default;
80  virtual StatusCode genInitialize();
81  virtual StatusCode callGenerator();
82  virtual StatusCode genFinalize();
83  virtual StatusCode fillEvt(HepMC::GenEvent* evt);
84 
85  CLHEP::HepLorentzVector generateVertex(void);
86  CLHEP::HepLorentzVector generateVertexReweighted(void);
87 
89  static CLHEP::HepRandomEngine* COSMIC_RANDOM_ENGINE;
90 
91 private:
92  // Migration to MeV and mm units: all conversions are done in this interface
93  // to the CosmicGun. The CosmicGun itself uses GeV units internally - to call
94  // the fortran code.
95  //
96 
97  static constexpr float m_GeV = 1000.f; // FIXME Take from SystemOfUnits.h header?
98  static constexpr float m_mm = 10.f; // FIXME Take from SystemOfUnits.h header?
99 
100  // event counter, used for event ID
101  int m_events{0};
102  int m_rejected{0};
103  int m_accepted{0};
104  std::vector<int> m_pdgCode;
105 
106  IntegerProperty m_dsid{this, "Dsid", 999999, "Dataset ID number"};
107  FloatProperty m_emin{this, "emin", 10.*m_GeV};
108  FloatProperty m_emax{this, "emax", 100.*m_GeV};
109  FloatProperty m_ctcut{this, "ctcut", 0.35};
110  FloatProperty m_xlow{this, "xvert_low", 0.*m_mm};
111  FloatProperty m_xhig{this, "xvert_hig", 10.*m_mm};
112  FloatProperty m_zlow{this, "zvert_low", 0.*m_mm};
113  FloatProperty m_zhig{this, "zvert_hig", 10.*m_mm};
114  FloatProperty m_yval{this, "yvert_val", 81.*m_mm};
115  FloatProperty m_IPx{this, "IPx", 0.f};
116  FloatProperty m_IPy{this, "IPy", 0.f};
117  FloatProperty m_IPz{this, "IPz", 0.f};
118  FloatProperty m_radius{this, "Radius", 0.f};
119  FloatProperty m_zpos{this, "Zposition", 14500.f};
120  FloatProperty m_tmin{this, "tmin", 0.f};
121  FloatProperty m_tmax{this, "tmax", 0.f};
122  BooleanProperty m_cavOpt{this, "OptimizeForCavern", false};
123  IntegerProperty m_srOneOpt{this, "OptimizeForSR1", 0}; // Not a bool??
124  BooleanProperty m_srOnePixECOpt{this, "OptimizeForSR1PixelEndCap", false};
125  BooleanProperty m_swapYZAxis{this, "SwapYZAxis", false};
126  BooleanProperty m_muonECOpt{this, "OptimizeForMuonEndCap", false};
127  IntegerProperty m_printEvent{this, "PrintEvent", 10};
128  IntegerProperty m_printMod{this, "PrintMod", 100};
129 
130  FloatProperty m_thetamin{this, "ThetaMin", 0.f};
131  FloatProperty m_thetamax{this, "ThetaMax", 1.f};
132  FloatProperty m_phimin{this, "PhiMin", -1.*M_PI};
133  FloatProperty m_phimax{this, "PhiMax", M_PI};
134 
135  bool m_readfile{false};
136  StringProperty m_infile{this, "eventfile", "NONE"};
137  std::ifstream m_ffile;
138 
139  // Event scalars, three-vectors, and four-vectors:
140  std::vector<CLHEP::HepLorentzVector> m_fourPos;
141  std::vector<CLHEP::HepLorentzVector> m_fourMom;
142  CLHEP::Hep3Vector m_center;
143  std::vector<HepMC::Polarization> m_polarization;
144 
145  // Energy dependent position cut for muons to reach the detector.
146  bool exzCut(const CLHEP::Hep3Vector& pos,const CLHEP::HepLorentzVector& p);
147 
148  // property for calling exzCut
149  BooleanProperty m_exzCut{this, "ExzCut", false};
150  // maximum r used in exzCut
151  FloatProperty m_rmax{this, "RMax", 10000000.f};
152 
153  // Calculation of pathlength in rock and whether cosmic ray is aimed towards
154  // the pixel detector
155  double pathLengthInRock(double xgen, double ygen, double zgen, double theta, double phi);
156  bool pointsAtPixels(double xgen, double ygen, double zgen, double theta, double phi);
157 
158  // New optimization options (November 2007)
159  BooleanProperty m_doPathlengthCut{this, "doPathLengthCut", false};
160  BooleanProperty m_doAimedAtPixelsCut{this, "doAimedAtPixelsCut", false};
161  BooleanProperty m_doReweighting{this, "doReweighting", false};
162  DoubleProperty m_energyCutThreshold{this, "energyCutThreshold", 1.0};
163  DoubleProperty m_ysurface{this, "ysurface", 81.*m_mm};
164  DoubleProperty m_rvertmax{this, "rvert_max", 300.*m_mm}; // replaces rectangle in case of reweighting
165  DoubleProperty m_pixelplanemaxx{this, "pixelplane_maxx", 1150.};
166  DoubleProperty m_pixelplanemaxz{this, "pixelplane_maxz", 1650.};
167 };
168 
169 #endif
CosmicGenerator::m_zlow
FloatProperty m_zlow
Definition: CosmicGenerator.h:112
CosmicGun
Definition: CosmicGun.h:10
CosmicGenerator::m_events
int m_events
Definition: CosmicGenerator.h:101
CosmicGenerator::m_tmin
FloatProperty m_tmin
Definition: CosmicGenerator.h:120
CosmicGenerator::m_xlow
FloatProperty m_xlow
Definition: CosmicGenerator.h:110
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
CosmicGenerator::m_accepted
int m_accepted
Definition: CosmicGenerator.h:103
CosmicGenerator::m_pixelplanemaxx
DoubleProperty m_pixelplanemaxx
Definition: CosmicGenerator.h:165
CosmicGenerator::m_doPathlengthCut
BooleanProperty m_doPathlengthCut
Definition: CosmicGenerator.h:159
CosmicGenerator::m_pdgCode
std::vector< int > m_pdgCode
Definition: CosmicGenerator.h:104
CosmicGenerator::m_ysurface
DoubleProperty m_ysurface
Definition: CosmicGenerator.h:163
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:75
M_PI
#define M_PI
Definition: ActiveFraction.h:11
CosmicGenerator::COSMIC_RANDOM_ENGINE
static CLHEP::HepRandomEngine * COSMIC_RANDOM_ENGINE
Static pointer to random number generator for use by.
Definition: CosmicGenerator.h:89
CosmicGenerator::m_srOnePixECOpt
BooleanProperty m_srOnePixECOpt
Definition: CosmicGenerator.h:124
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
CosmicGenerator::m_dsid
IntegerProperty m_dsid
Definition: CosmicGenerator.h:106
CosmicGenerator
Cosmic generator. The output will be stored in the transient event store so it can be passed to the s...
Definition: CosmicGenerator.h:75
CosmicGenerator::m_ctcut
FloatProperty m_ctcut
Definition: CosmicGenerator.h:109
CosmicGenerator::pointsAtPixels
bool pointsAtPixels(double xgen, double ygen, double zgen, double theta, double phi)
Definition: CosmicGenerator.cxx:775
CosmicGenerator::m_fourMom
std::vector< CLHEP::HepLorentzVector > m_fourMom
Definition: CosmicGenerator.h:141
CosmicGenerator::m_rejected
int m_rejected
Definition: CosmicGenerator.h:102
CosmicGenerator::m_xhig
FloatProperty m_xhig
Definition: CosmicGenerator.h:111
CosmicGenerator::m_pixelplanemaxz
DoubleProperty m_pixelplanemaxz
Definition: CosmicGenerator.h:166
CosmicGenerator::m_printEvent
IntegerProperty m_printEvent
Definition: CosmicGenerator.h:127
GenModule
Base class for common behaviour of generator interfaces.
Definition: GenModule.h:39
CosmicGenerator::m_fourPos
std::vector< CLHEP::HepLorentzVector > m_fourPos
Definition: CosmicGenerator.h:140
CosmicGenerator::m_phimin
FloatProperty m_phimin
Definition: CosmicGenerator.h:132
CosmicGenerator::m_swapYZAxis
BooleanProperty m_swapYZAxis
Definition: CosmicGenerator.h:125
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
CosmicGenerator::m_readfile
bool m_readfile
Definition: CosmicGenerator.h:135
CosmicGenerator::m_energyCutThreshold
DoubleProperty m_energyCutThreshold
Definition: CosmicGenerator.h:162
CosmicGenerator::m_doAimedAtPixelsCut
BooleanProperty m_doAimedAtPixelsCut
Definition: CosmicGenerator.h:160
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CosmicGenerator::m_cavOpt
BooleanProperty m_cavOpt
Definition: CosmicGenerator.h:122
CosmicGenerator::fillEvt
virtual StatusCode fillEvt(HepMC::GenEvent *evt)
For filling the HepMC event object.
Definition: CosmicGenerator.cxx:622
CosmicGenerator::m_center
CLHEP::Hep3Vector m_center
Definition: CosmicGenerator.h:142
CosmicGenerator::m_doReweighting
BooleanProperty m_doReweighting
Definition: CosmicGenerator.h:161
CosmicGenerator::m_phimax
FloatProperty m_phimax
Definition: CosmicGenerator.h:133
CosmicGenerator::m_zpos
FloatProperty m_zpos
Definition: CosmicGenerator.h:119
CosmicGenerator::generateVertex
CLHEP::HepLorentzVector generateVertex(void)
Definition: CosmicGenerator.cxx:132
CosmicGenerator::m_srOneOpt
IntegerProperty m_srOneOpt
Definition: CosmicGenerator.h:123
CosmicGenerator::m_IPy
FloatProperty m_IPy
Definition: CosmicGenerator.h:116
CosmicGenerator::m_polarization
std::vector< HepMC::Polarization > m_polarization
Definition: CosmicGenerator.h:143
CosmicGenerator::genFinalize
virtual StatusCode genFinalize()
For finalising the generator, if required.
Definition: CosmicGenerator.cxx:554
CosmicGenerator::m_ffile
std::ifstream m_ffile
Definition: CosmicGenerator.h:137
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CosmicGenerator::m_rmax
FloatProperty m_rmax
Definition: CosmicGenerator.h:151
CosmicGenerator::generateVertexReweighted
CLHEP::HepLorentzVector generateVertexReweighted(void)
Definition: CosmicGenerator.cxx:158
CosmicGenerator::m_IPz
FloatProperty m_IPz
Definition: CosmicGenerator.h:117
CosmicGenerator::m_zhig
FloatProperty m_zhig
Definition: CosmicGenerator.h:113
CosmicGenerator::m_printMod
IntegerProperty m_printMod
Definition: CosmicGenerator.h:128
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
CosmicGenerator::m_rvertmax
DoubleProperty m_rvertmax
Definition: CosmicGenerator.h:164
CosmicGenerator::m_yval
FloatProperty m_yval
Definition: CosmicGenerator.h:114
GenModule.h
CosmicGenerator::m_GeV
static constexpr float m_GeV
Definition: CosmicGenerator.h:97
CosmicGenerator::m_emin
FloatProperty m_emin
Definition: CosmicGenerator.h:107
CosmicGenerator::callGenerator
virtual StatusCode callGenerator()
For calling the generator on each iteration of the event loop.
Definition: CosmicGenerator.cxx:214
CosmicGenerator::exzCut
bool exzCut(const CLHEP::Hep3Vector &pos, const CLHEP::HepLorentzVector &p)
Definition: CosmicGenerator.cxx:662
CosmicGenerator::m_thetamax
FloatProperty m_thetamax
Definition: CosmicGenerator.h:131
CosmicGenerator::~CosmicGenerator
virtual ~CosmicGenerator()=default
CosmicGenerator::m_infile
StringProperty m_infile
Definition: CosmicGenerator.h:136
CosmicGenerator::m_emax
FloatProperty m_emax
Definition: CosmicGenerator.h:108
CosmicGenerator::m_mm
static constexpr float m_mm
Definition: CosmicGenerator.h:98
Polarization.h
CosmicGenerator::m_muonECOpt
BooleanProperty m_muonECOpt
Definition: CosmicGenerator.h:126
CosmicGenerator::CosmicGenerator
CosmicGenerator(const std::string &name, ISvcLocator *pSvcLocator)
Definition: CosmicGenerator.cxx:80
CosmicGenerator::m_IPx
FloatProperty m_IPx
Definition: CosmicGenerator.h:115
CosmicGenerator::m_tmax
FloatProperty m_tmax
Definition: CosmicGenerator.h:121
CosmicGenerator::pathLengthInRock
double pathLengthInRock(double xgen, double ygen, double zgen, double theta, double phi)
Definition: CosmicGenerator.cxx:694
CosmicGenerator::m_thetamin
FloatProperty m_thetamin
Definition: CosmicGenerator.h:130
CosmicGenerator::m_radius
FloatProperty m_radius
Definition: CosmicGenerator.h:118
CosmicGenerator::m_exzCut
BooleanProperty m_exzCut
Definition: CosmicGenerator.h:149
CosmicGenerator::genInitialize
virtual StatusCode genInitialize()
For initializing the generator, if required.
Definition: CosmicGenerator.cxx:88