Skip to content

Commit

Permalink
Cleanup, add detector name aux, remove 4GeV geom
Browse files Browse the repository at this point in the history
Co-authored-by: Tamas Vami <[email protected]>
  • Loading branch information
bloodyyugo and tvami committed Aug 31, 2024
1 parent 6483ae0 commit ec19cae
Show file tree
Hide file tree
Showing 17 changed files with 13 additions and 15,791 deletions.
3 changes: 3 additions & 0 deletions Biasing/include/Biasing/TaggerHitFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

//~~ Framework ~~//
#include "Framework/Configure/Parameters.h"
#include "Framework/EventProcessor.h"

// Forward declarations
class G4Step;
Expand Down Expand Up @@ -60,6 +61,8 @@ class TaggerHitFilter : public simcore::UserAction {
std::set<int> layer_count_;
/// Total number of hits required to persist an event.
int layers_hit_{8};
/// Enable logging
enableLogging("TaggerHitFilter")

}; // TaggerHitFilter
} // namespace biasing
76 changes: 8 additions & 68 deletions Biasing/src/Biasing/TaggerHitFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,60 +11,26 @@ TaggerHitFilter::TaggerHitFilter(const std::string& name,
framework::config::Parameters& parameters)
: simcore::UserAction(name, parameters) {
layers_hit_ = parameters.getParameter<int>("layers_hit", 8);
std::cout << "TaggerHitFilter:: layers_hit_ = " << layers_hit_ << std::endl;
ldmx_log(debug) << " layers_hit_ = " << layers_hit_;
}

void TaggerHitFilter::stepping(const G4Step* step) {
// The track associated with this step will allow for the extraction of info
// needed to determine if this is the incident electron.
auto track{step->GetTrack()};
// std::cout<<"TaggeHitFilter::stepping"<<std::endl;
// Only process the primary electron i.e. a particle without parents.
// June 21, 2024 MG: Not sure this is a good cut to make here..
// What about secondaries?
// if (track->GetParentID() != 0) return;

// Get the PDG ID of the track and make sure it's an electron. If
// another particle type is found, thrown an exception because the generator
// being used is likely wrong.
// std::cout<<"Track pdgID =
// "<<track->GetParticleDefinition()->GetPDGEncoding()<<std::endl; June 21,
// 2024 MG: similar here, though it's unlikely to be aything else if (auto
// pdgID{track->GetParticleDefinition()->GetPDGEncoding()}; pdgID != 11){
// return;
//}
// Require that track is charged
if (auto pdgCh{track->GetParticleDefinition()->GetPDGCharge()};
abs(pdgCh) != 1) {
abs(pdgCh) == 0) {
return;
}

// Only electrons in the Tagger region are of interest.
auto volume{track->GetVolume()};
// std::cout<<"Volume Name =
// "<<volume->GetLogicalVolume()->GetRegion()->GetName()<<std::endl;
if (auto region{volume->GetLogicalVolume()->GetRegion()->GetName()};
region.compareTo("tagger") != 0)
return;

// Check if the number of layers hit is above the threshold if
// 1) the incident electron has exited the tagger tracker volume
// 2) the incident electron has lost all of its energy.
// If the number of sensors hit is below the layer threshold, abort the
// event.
// std::cout<<"Next Volume Name =
// "+track->GetNextVolume()->GetLogicalVolume()->GetRegion()->GetName()<<std::endl;
/*
if (auto
nregion{track->GetNextVolume()->GetLogicalVolume()->GetRegion()->GetName()};
(nregion.compareTo("tagger") != 0) ||
(track->GetKineticEnergy() == 0)) {
checkAbortEvent(track);
return;
}
*/
// MG: remove the kinetic energy requirement
// this basically just checks if we are exiting the tagger
// Check if we are exiting the tagger
if (auto nregion{
track->GetNextVolume()->GetLogicalVolume()->GetRegion()->GetName()};
(nregion.compareTo("tagger") != 0)) {
Expand All @@ -74,8 +40,6 @@ void TaggerHitFilter::stepping(const G4Step* step) {

// A particle will only leave hits in the active silicon so other volumes can
// be skipped for now.
// std::cout<<"check active Si volume
// "<<track->GetVolume()->GetName()<<std::endl;
if (auto volume_name{track->GetVolume()->GetName()};
volume_name.compareTo("tagger_PV") == 0)
return;
Expand All @@ -86,21 +50,7 @@ void TaggerHitFilter::stepping(const G4Step* step) {
->GetHistory()
->GetVolume(2)
->GetCopyNo()};
// std::cout<<"putting copy_number "<<copy_number<<std::endl;
// Use a set to keep track of the number of unique layers with energy
// depositions.

// MG: only count front layers of tracker if from beam electron
// if layers 1 or 2 (copy_number = 10 or 20) count
// from any source
// if (copy_number<21){
// std::cout<<"Found inner layer hit "<<copy_number<<" Parent ID "<<
// track->GetParentID()<<std::endl;
//}
// if (copy_number>20 && track->GetParentID() != 0)
// return;
// std::cout<<"Inserting hit "<<copy_number<<" Parent ID "<<
// track->GetParentID()<<std::endl;
layer_count_.insert(copy_number);
}

Expand All @@ -110,26 +60,16 @@ void TaggerHitFilter::EndOfEventAction(const G4Event* event) {
}

void TaggerHitFilter::checkAbortEvent(G4Track* track) {
// These numbers may change in the future
constexpr int early_layer_requirement = 10;
constexpr int late_layer_requirement = 20;
if ((layer_count_.size() < layers_hit_) ||
((layer_count_.count(10) == 0) && (layer_count_.count(20) == 0))) {
// if (layer_count_.size() < layers_hit_) {
((layer_count_.count(early_layer_requirement) == 0) &&
(layer_count_.count(late_layer_requirement) == 0))) {
if (track != nullptr) track->SetTrackStatus(fKillTrackAndSecondaries);
G4RunManager::GetRunManager()->AbortEvent();
/*
std::cout << "Aborting" << std::endl;
std::cout<<"layer_count = "<<layer_count_.size()<<std::endl;
std::cout<<"layer_count_.count(10) "<<layer_count_.count(10) <<
std::endl; std::cout<<"layer_count_.count(20) "<<layer_count_.count(20)
<< std::endl;
*/
return;
}

/*
std::cout << "[ ";
for (auto &l : layer_count_) std::cout << l << ", ";
std::cout << " ]" << std::endl;
*/
}

} // namespace biasing
Expand Down
15 changes: 2 additions & 13 deletions Detectors/data/ldmx-det-v14-8gev-no-cals/detector.gdml
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,6 @@
<positionref ref="recoil_pos"/>
<rotationref ref="identity"/>
</physvol>
<!--
<physvol copynumber="6">
<file name="ecal.gdml"/>
<positionref ref="em_calorimeter_pos"/>
<rotationref ref="identity"/>
</physvol>
<physvol copynumber="7">
<file name="hcal.gdml"/>
<positionref ref="hadron_calorimeter_pos"/>
<rotationref ref="identity"/>
</physvol> -->
<physvol>
<file name="magnet.gdml"/>
<positionref ref="magnet_pos"/>
Expand All @@ -107,9 +96,9 @@
<userinfo>
<!-- detector version -->
<auxiliary auxtype="DetectorVersion" auxvalue="14">
<auxiliary auxtype="DetectorName" auxvalue="ldmx-det-v14-8gev"/>
<auxiliary auxtype="DetectorName" auxvalue="ldmx-det-v14-8gev-no-cals"/>
<auxiliary auxtype="Description"
auxvalue="The Late 2022 Design Report Geometry."/>
auxvalue="The Late 2022 Design Report Geometry w/o calorimeters."/>
</auxiliary>

<!-- magnetic field with global field map definition -->
Expand Down
Loading

0 comments on commit ec19cae

Please sign in to comment.