File indexing completed on 2025-01-18 09:55:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef DDG4_GEANT4DATA_H
0015 #define DDG4_GEANT4DATA_H
0016
0017
0018 #include <Math/Vector3D.h>
0019
0020
0021 #include <set>
0022 #include <vector>
0023 #include <memory>
0024
0025
0026 class G4Step;
0027 class G4StepPoint;
0028
0029
0030 namespace dd4hep {
0031
0032
0033 typedef ROOT::Math::XYZVector Position;
0034 typedef ROOT::Math::XYZVector Direction;
0035
0036
0037 namespace sim {
0038
0039
0040 class Geant4FastSimSpot;
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 class SimpleRun {
0051 public:
0052
0053 int runID { -1 };
0054
0055 int numEvents { 0 };
0056
0057 SimpleRun();
0058
0059 virtual ~SimpleRun();
0060 };
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070 class SimpleEvent {
0071 public:
0072 typedef std::vector<long> Seeds;
0073
0074 int runID { -1 };
0075
0076 int eventID { -1 };
0077
0078 Seeds seeds { };
0079
0080 SimpleEvent();
0081
0082 virtual ~SimpleEvent();
0083 };
0084
0085
0086
0087
0088
0089
0090
0091 class DataExtension {
0092 public:
0093
0094 DataExtension() {}
0095
0096 virtual ~DataExtension();
0097 };
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110 class Geant4HitData {
0111 public:
0112 enum HitFlags {
0113 HIT_KILLED_TRACK = 1<<0,
0114 HIT_SECONDARY_TRACK = 1<<1,
0115 HIT_NEW_TRACK = 1<<2,
0116 HIT_STARTED_INSIDE = 1<<10,
0117 HIT_STARTED_SURFACE = 1<<11,
0118 HIT_STARTED_OUTSIDE = 1<<12,
0119 HIT_ENDED_INSIDE = 1<<13,
0120 HIT_ENDED_SURFACE = 1<<14,
0121 HIT_ENDED_OUTSIDE = 1<<15
0122 };
0123
0124 long long int cellID = 0;
0125
0126 long flag = 0;
0127
0128 long g4ID = -1;
0129
0130 std::unique_ptr<DataExtension> extension;
0131
0132
0133
0134
0135
0136
0137
0138 class MonteCarloContrib {
0139 public:
0140
0141 int trackID = -1;
0142
0143 int pdgID = -1;
0144
0145 double deposit = 0.0;
0146
0147 double time;
0148
0149 double length = 0.0;
0150
0151 float x = 0.0, y = 0.0, z = 0.0;
0152
0153 float px = 0.0, py = 0.0, pz = 0.0;
0154
0155
0156 MonteCarloContrib() = default;
0157
0158 MonteCarloContrib(const MonteCarloContrib& c) = default;
0159
0160 MonteCarloContrib(MonteCarloContrib&& c) = default;
0161 #if 0
0162
0163 MonteCarloContrib(int track_id, int pdg, double dep, double time_stamp, double len)
0164 : trackID(track_id), pdgID(pdg), deposit(dep), time(time_stamp), length(len) {
0165 }
0166 #endif
0167
0168 MonteCarloContrib(int track_id, int pdg, double dep, double time_stamp, double len, float* pos, float* mom)
0169 : trackID(track_id), pdgID(pdg), deposit(dep), time(time_stamp), length(len),
0170 x(pos[0]), y(pos[1]), z(pos[2]), px(mom[0]), py(mom[1]), pz(mom[2])
0171 {
0172 }
0173
0174 MonteCarloContrib(int track_id, int pdg, double dep, double time_stamp, double len, double* pos, double* mom)
0175 : trackID(track_id), pdgID(pdg), deposit(dep), time(time_stamp), length(len),
0176 x(float(pos[0])), y(float(pos[1])), z(float(pos[2])),
0177 px(float(mom[0])), py(float(mom[1])), pz(float(mom[2]))
0178 {
0179 }
0180
0181 MonteCarloContrib(int track_id, int pdg, double dep, double time_stamp, double len, const Position& pos, const Direction& mom)
0182 : trackID(track_id), pdgID(pdg), deposit(dep), time(time_stamp), length(len),
0183 x(float(pos.x())), y(float(pos.y())), z(float(pos.z())),
0184 px(float(mom.x())), py(float(mom.y())), pz(float(mom.z()))
0185 {
0186 }
0187
0188 MonteCarloContrib& operator=(MonteCarloContrib&& c) = default;
0189
0190 MonteCarloContrib& operator=(const MonteCarloContrib& c) = default;
0191
0192 void clear() {
0193 x = y = z = 0.0;
0194 px = py = pz = 0.0;
0195 time = deposit = length = 0.0;
0196 pdgID = trackID = -1;
0197 }
0198
0199 Position position() const {
0200 return Position(x, y, z);
0201 }
0202
0203 void setPosition(const Position& pos) {
0204 x = pos.x();
0205 y = pos.y();
0206 z = pos.z();
0207 }
0208
0209 void setPosition(double pos_x, double pos_y, double pos_z) {
0210 x = float(pos_x);
0211 y = float(pos_y);
0212 z = float(pos_z);
0213 }
0214
0215 Direction momentum() const {
0216 return Direction(px, py, pz);
0217 }
0218
0219 void setMomentum(const Direction& dir) {
0220 px = dir.x();
0221 py = dir.y();
0222 pz = dir.z();
0223 }
0224
0225 void setMomentum(double mom_x, double mom_y, double mom_z) {
0226 px = float(mom_x);
0227 py = float(mom_y);
0228 pz = float(mom_z);
0229 }
0230 };
0231 typedef MonteCarloContrib Contribution;
0232 typedef std::vector<MonteCarloContrib> Contributions;
0233 public:
0234
0235 Geant4HitData();
0236
0237 virtual ~Geant4HitData();
0238
0239 static Contribution extractContribution(const G4Step* step);
0240
0241 static Contribution extractContribution(const G4Step* step, bool ApplyBirksLaw);
0242
0243 static Contribution extractContribution(const Geant4FastSimSpot* spot);
0244 };
0245
0246
0247
0248
0249
0250
0251
0252 class Geant4Tracker {
0253 public:
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263 class Hit : public Geant4HitData {
0264 public:
0265 typedef Geant4HitData base_t;
0266
0267
0268 Position position;
0269
0270 Direction momentum;
0271
0272 double length { 0e0 };
0273
0274 double energyDeposit { 0e0 };
0275
0276 Contribution truth;
0277 public:
0278
0279 Hit();
0280
0281 Hit(Hit&& c) = delete;
0282
0283 Hit(const Hit& c) = delete;
0284
0285 Hit(int track_id, int pdg_id, double deposit, double time_stamp, double len=0.0, const Position& p={0.0, 0.0, 0.0}, const Direction& d={0.0, 0.0, 0.0});
0286
0287 Hit(const Geant4HitData::Contribution& contrib, const Direction& mom, double deposit);
0288
0289 virtual ~Hit();
0290
0291 Hit& operator=(Hit&& c) = delete;
0292
0293 Hit& operator=(const Hit& c) = delete;
0294
0295 void copyFrom(const Hit& c);
0296
0297 Hit& clear();
0298
0299 Hit& storePoint(const G4Step* step, const G4StepPoint* point);
0300
0301 Hit& storePoint(const Geant4FastSimSpot* spot);
0302 };
0303 };
0304
0305
0306
0307
0308
0309
0310
0311 class Geant4Calorimeter {
0312 public:
0313
0314
0315
0316
0317
0318
0319
0320
0321
0322
0323 class Hit : public Geant4HitData {
0324 public:
0325 typedef Geant4HitData base_t;
0326
0327
0328 Position position { };
0329
0330 Contributions truth { };
0331
0332 double energyDeposit { 0e0 };
0333 public:
0334
0335 Hit();
0336
0337 Hit(Hit&& c) = delete;
0338
0339 Hit(const Hit& c) = delete;
0340
0341 Hit(const Position& cell_pos);
0342
0343 virtual ~Hit();
0344
0345 Hit& operator=(Hit&& c) = delete;
0346
0347 Hit& operator=(const Hit& c) = delete;
0348 };
0349 };
0350
0351
0352 typedef Geant4HitData SimpleHit;
0353 typedef Geant4Tracker SimpleTracker;
0354 typedef Geant4Calorimeter SimpleCalorimeter;
0355
0356 }
0357 }
0358 #endif