Commit 31725d79 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

SensitiveDetectorAction: remove unnecessary re-calculation of position for every deposit

parent f2a2bc7f
Loading
Loading
Loading
Loading
+0 −14
Original line number Diff line number Diff line
@@ -78,10 +78,6 @@ G4bool SensitiveDetectorActionG4::ProcessHits(G4Step* step, G4TouchableHistory*)

    // Calculate the charge deposit at a local position
    auto deposit_position = detector_->getLocalPosition(static_cast<ROOT::Math::XYZPoint>(step_pos));
    auto deposit_position_g4 = theTouchable->GetHistory()->GetTopTransform().TransformPoint(step_pos);

    // Transform the hit position using the rotation matrix
    deposit_position_g4 *= *hit_transform_;

    // Calculate number of electron hole pairs produced, taking into account fluctuations between ionization and lattice
    // excitations via the Fano factor. We assume Gaussian statistics here.
@@ -89,11 +85,6 @@ G4bool SensitiveDetectorActionG4::ProcessHits(G4Step* step, G4TouchableHistory*)
    allpix::normal_distribution<double> charge_fluctuation(mean_charge, std::sqrt(mean_charge * fano_factor_));
    auto charge = static_cast<unsigned int>(charge_fluctuation(random_generator_));

    auto deposit_position_g4loc =
        ROOT::Math::XYZPoint(deposit_position_g4.x() + detector_->getModel()->getSensorCenter().x(),
                             deposit_position_g4.y() + detector_->getModel()->getSensorCenter().y(),
                             deposit_position_g4.z() + detector_->getModel()->getSensorCenter().z());

    const auto* userTrackInfo = dynamic_cast<TrackInfoG4*>(track->GetUserInformation());
    if(userTrackInfo == nullptr) {
        throw ModuleError("No track information attached to track.");
@@ -132,11 +123,6 @@ G4bool SensitiveDetectorActionG4::ProcessHits(G4Step* step, G4TouchableHistory*)
    deposit_time_.push_back(step_time);
    deposit_to_id_.push_back(trackID);

    LOG(DEBUG) << "Geant4 transformation to local: " << Units::display(deposit_position_g4loc, {"mm", "um"});
    if((deposit_position_g4loc - deposit_position).mag2() > 0.001) {
        LOG(ERROR) << "Difference G4 to internal: "
                   << Units::display((deposit_position_g4loc - deposit_position), {"mm", "um"});
    }
    return true;
}