Skip to content

Commit 06576b3

Browse files
committed
Added comments
1 parent 284983a commit 06576b3

File tree

1 file changed

+49
-32
lines changed

1 file changed

+49
-32
lines changed

tutorials/cpp_03_hits_edm4eic.cxx

Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -48,37 +48,54 @@ bool trk_hits_header_written = false;
4848

4949
/// Struct representing a line in csv file
5050
struct HitRecord {
51-
uint64_t evt;
52-
uint64_t hit_index;
53-
uint64_t prt_index;
54-
int32_t prt_pdg;
55-
int32_t prt_status;
56-
double prt_energy;
57-
float prt_charge;
58-
double prt_mom_x;
59-
double prt_mom_y;
60-
double prt_mom_z;
61-
float prt_vtx_time;
62-
float prt_vtx_pos_x;
63-
float prt_vtx_pos_y;
64-
float prt_vtx_pos_z;
65-
float prt_end_time;
66-
float prt_end_pos_x;
67-
float prt_end_pos_y;
68-
float prt_end_pos_z;
69-
uint64_t trk_hit_cell_id;
70-
uint64_t trk_hit_system_id;
71-
std::string trk_hit_system_name;
72-
float trk_hit_pos_x;
73-
float trk_hit_pos_y;
74-
float trk_hit_pos_z;
75-
float trk_hit_time;
76-
float trk_hit_pos_err_xx;
77-
float trk_hit_pos_err_yy;
78-
float trk_hit_pos_err_zz;
79-
float trk_hit_time_err;
80-
float trk_hit_edep;
81-
float trk_hit_edep_err;
51+
// Event and indexing
52+
uint64_t evt; // Event number
53+
uint64_t hit_index; // Index of MCRecoTrackerHitAssociation in collection
54+
uint64_t prt_index; // Index of MCParticle that created this hit
55+
56+
// Particle identification
57+
int32_t prt_pdg; // PDG code of the particle (e.g., 11=e-, 211=pi+, 2212=proton)
58+
int32_t prt_status; // Generator status: 1=stable from generator, 0=created by Geant4
59+
60+
// Particle kinematics
61+
double prt_energy; // Total energy of particle [GeV]
62+
float prt_charge; // Electric charge [e]
63+
double prt_mom_x; // Momentum x-component [GeV/c]
64+
double prt_mom_y; // Momentum y-component [GeV/c]
65+
double prt_mom_z; // Momentum z-component [GeV/c]
66+
67+
// Particle vertex (production point)
68+
float prt_vtx_time; // Time at production vertex [ns]
69+
float prt_vtx_pos_x; // Production vertex x [mm]
70+
float prt_vtx_pos_y; // Production vertex y [mm]
71+
float prt_vtx_pos_z; // Production vertex z [mm]
72+
73+
// Particle endpoint (decay/absorption point)
74+
float prt_end_time; // Time at endpoint [ns] (Note: same as vtx_time in EDM4hep)
75+
float prt_end_pos_x; // Endpoint x [mm]
76+
float prt_end_pos_y; // Endpoint y [mm]
77+
float prt_end_pos_z; // Endpoint z [mm]
78+
79+
// Tracker hit detector info
80+
uint64_t trk_hit_cell_id; // Full cell ID encoding detector hierarchy
81+
uint64_t trk_hit_system_id; // Detector system ID (bits 0-7 of cell_id)
82+
std::string trk_hit_system_name; // Human-readable detector name (e.g., "SiBarrelVertex")
83+
84+
// Tracker hit position and time
85+
float trk_hit_pos_x; // Reconstructed hit position x [mm]
86+
float trk_hit_pos_y; // Reconstructed hit position y [mm]
87+
float trk_hit_pos_z; // Reconstructed hit position z [mm]
88+
float trk_hit_time; // Reconstructed hit time [ns]
89+
90+
// Tracker hit uncertainties (covariance matrix diagonal)
91+
float trk_hit_pos_err_xx; // Position error variance in x [mm^2]
92+
float trk_hit_pos_err_yy; // Position error variance in y [mm^2]
93+
float trk_hit_pos_err_zz; // Position error variance in z [mm^2]
94+
float trk_hit_time_err; // Time uncertainty [ns]
95+
96+
// Tracker hit energy deposition
97+
float trk_hit_edep; // Energy deposited in sensor [GeV]
98+
float trk_hit_edep_err; // Energy deposition uncertainty [GeV]
8299

83100
static std::string make_csv_header() {
84101
return "evt,hit_index,prt_index,"
@@ -682,7 +699,7 @@ void process_file(const std::string& file_name) {
682699

683700
// ---------------------------------------------------------------------------
684701
// ROOT-macro entry point.
685-
// Call it from the prompt: root -x -l -b -q 'csv_edm4hep_acceptance_ppim.cxx("file.root", "output.csv", 100)'
702+
// Call it from the prompt: root -x -l -b -q 'cpp_03_hits_edm4eic.cxx("file.root", "output.csv", 100)'
686703
// ---------------------------------------------------------------------------
687704
void cpp_03_hits_edm4eic(const char* infile, const char* outfile, int events = -1)
688705
{

0 commit comments

Comments
 (0)