Commit 89c153d2 authored by Paul Schütze's avatar Paul Schütze
Browse files

Merge branch 'g4_final_volume' into 'master'

MCTrack: Store Final Volume Name

See merge request allpix-squared/allpix-squared!684
parents 112986ef fb722dec
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -21,13 +21,14 @@ TrackInfoG4::TrackInfoG4(int custom_track_id, int parent_track_id, const G4Track
    particle_id_ = aTrack->GetDynamicParticle()->GetPDGcode();
    start_point_ = static_cast<ROOT::Math::XYZPoint>(aTrack->GetPosition());
    start_time_ = aTrack->GetGlobalTime();
    origin_g4_vol_name_ = aTrack->GetVolume()->GetName();
    initial_g4_vol_name_ = aTrack->GetVolume()->GetName();
    origin_g4_process_name_ = (G4Process != nullptr) ? static_cast<std::string>(G4Process->GetProcessName()) : "none";
    initial_kin_E_ = aTrack->GetKineticEnergy();
    initial_tot_E_ = aTrack->GetTotalEnergy();
}

void TrackInfoG4::finalizeInfo(const G4Track* const aTrack) {
    final_g4_vol_name_ = aTrack->GetVolume()->GetName();
    final_kin_E_ = aTrack->GetKineticEnergy();
    final_tot_E_ = aTrack->GetTotalEnergy();
    end_point_ = static_cast<ROOT::Math::XYZPoint>(aTrack->GetPosition());
@@ -84,7 +85,11 @@ double TrackInfoG4::getTotalEnergyFinal() const {
}

std::string TrackInfoG4::getOriginatingVolumeName() const {
    return origin_g4_vol_name_;
    return initial_g4_vol_name_;
}

std::string TrackInfoG4::getTerminatingVolumeName() const {
    return final_g4_vol_name_;
}

std::string TrackInfoG4::getCreationProcessName() const {
+9 −1
Original line number Diff line number Diff line
@@ -120,6 +120,12 @@ namespace allpix {
         */
        std::string getOriginatingVolumeName() const;

        /**
         * @brief Getter for the Geant4 name of the physical volume in which the track ends
         * @return The name of the phyical volume
         */
        std::string getTerminatingVolumeName() const;

        /**
         * @brief Getter for the name of the process which created this particle
         * @return The process name, or "none" if no such process exists
@@ -144,7 +150,9 @@ namespace allpix {
        // Ending time (in ns)
        double end_time_{};
        // Geant4 volume in which the track was created
        std::string origin_g4_vol_name_{};
        std::string initial_g4_vol_name_{};
        // Geant4 volume in which the track was terminated
        std::string final_g4_vol_name_{};
        // Name of Geant4 process which created this track
        std::string origin_g4_process_name_{};
        // Initial kinetic energy (MeV)
+1 −0
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ void TrackInfoManager::createMCTracks() {
        stored_tracks_.emplace_back(track_info->getStartPoint(),
                                    track_info->getEndPoint(),
                                    track_info->getOriginatingVolumeName(),
                                    track_info->getTerminatingVolumeName(),
                                    track_info->getCreationProcessName(),
                                    track_info->getCreationProcessType(),
                                    track_info->getParticleID(),
+15 −7
Original line number Diff line number Diff line
@@ -16,7 +16,8 @@ using namespace allpix;

MCTrack::MCTrack(ROOT::Math::XYZPoint start_point,
                 ROOT::Math::XYZPoint end_point,
                 std::string g4_volume,
                 std::string g4_volume_start,
                 std::string g4_volume_end,
                 std::string g4_prod_process_name,
                 int g4_prod_process_type,
                 int particle_id,
@@ -26,10 +27,11 @@ MCTrack::MCTrack(ROOT::Math::XYZPoint start_point,
                 double final_kin_E,
                 double initial_tot_E,
                 double final_tot_E)
    : start_point_(std::move(start_point)), end_point_(std::move(end_point)), origin_g4_vol_name_(std::move(g4_volume)),
      origin_g4_process_name_(std::move(g4_prod_process_name)), origin_g4_process_type_(g4_prod_process_type),
      particle_id_(particle_id), global_start_time_(start_time), global_end_time_(end_time), initial_kin_E_(initial_kin_E),
      final_kin_E_(final_kin_E), initial_tot_E_(initial_tot_E), final_tot_E_(final_tot_E) {
    : start_point_(std::move(start_point)), end_point_(std::move(end_point)), start_g4_vol_name_(std::move(g4_volume_start)),
      end_g4_vol_name_(std::move(g4_volume_end)), origin_g4_process_name_(std::move(g4_prod_process_name)),
      origin_g4_process_type_(g4_prod_process_type), particle_id_(particle_id), global_start_time_(start_time),
      global_end_time_(end_time), initial_kin_E_(initial_kin_E), final_kin_E_(final_kin_E), initial_tot_E_(initial_tot_E),
      final_tot_E_(final_tot_E) {
    setParent(nullptr);
}

@@ -75,7 +77,11 @@ double MCTrack::getTotalEnergyFinal() const {
}

std::string MCTrack::getOriginatingVolumeName() const {
    return origin_g4_vol_name_;
    return start_g4_vol_name_;
}

std::string MCTrack::getTerminatingVolumeName() const {
    return end_g4_vol_name_;
}

std::string MCTrack::getCreationProcessName() const {
@@ -111,7 +117,9 @@ void MCTrack::print(std::ostream& out) const {
        << std::left << std::setw(big_gap) << "Production process: " << std::right << std::setw(small_gap)
        << origin_g4_process_name_ << " (G4 process type: " << origin_g4_process_type_ << ")\n"
        << std::left << std::setw(big_gap) << "Production in G4Volume: " << std::right << std::setw(small_gap)
        << origin_g4_vol_name_ << '\n'
        << start_g4_vol_name_ << '\n'
        << std::left << std::setw(big_gap) << "Termination in G4Volume: " << std::right << std::setw(small_gap)
        << end_g4_vol_name_ << '\n'
        << std::left << std::setw(big_gap) << "Initial position:" << std::right << std::setw(med_gap) << start_point_.X()
        << " mm |" << std::setw(med_gap) << start_point_.Y() << " mm |" << std::setw(med_gap) << start_point_.Z() << " mm\n"
        << std::left << std::setw(big_gap) << "Final position:" << std::right << std::setw(med_gap) << end_point_.X()
+13 −4
Original line number Diff line number Diff line
@@ -27,7 +27,8 @@ namespace allpix {
         * @brief Construct a Monte-Carlo track
         * @param start_point Global point where track came into existence
         * @param end_point Global point where track went out of existence
         * @param g4_volume Geant4 volume where track originated in
         * @param g4_volume_start Geant4 volume where track originated in
         * @param g4_volume_end Geant4 volume where track terminated in
         * @param g4_prod_process_name Geant4 creation process name
         * @param g4_prod_process_type Geant4 creation process id
         * @param particle_id PDG particle id
@@ -40,7 +41,8 @@ namespace allpix {
         */
        MCTrack(ROOT::Math::XYZPoint start_point,
                ROOT::Math::XYZPoint end_point,
                std::string g4_volume,
                std::string g4_volume_start,
                std::string g4_volume_end,
                std::string g4_prod_process_name,
                int g4_prod_process_type,
                int particle_id,
@@ -118,6 +120,12 @@ namespace allpix {
         */
        std::string getOriginatingVolumeName() const;

        /**
         * @brief Getter for the Geant4 name of the physical volume in which the track terminated
         * @return The name of the phyical volume
         */
        std::string getTerminatingVolumeName() const;

        /**
         * @brief Getter for the name of the process which created this particle
         * @return The process name or "none" if no such process exists
@@ -147,7 +155,7 @@ namespace allpix {
        /**
         * @brief ROOT class definition
         */
        ClassDefOverride(MCTrack, 5); // NOLINT
        ClassDefOverride(MCTrack, 6); // NOLINT
        /**
         * @brief Default constructor for ROOT I/O
         */
@@ -160,7 +168,8 @@ namespace allpix {
        ROOT::Math::XYZPoint start_point_{};
        ROOT::Math::XYZPoint end_point_{};

        std::string origin_g4_vol_name_{};
        std::string start_g4_vol_name_{};
        std::string end_g4_vol_name_{};
        std::string origin_g4_process_name_{};

        int origin_g4_process_type_{};