-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GENIE Rockbox Dirt Workflow #203
Changes from 11 commits
2cc8d12
76cf88c
f7dc6e9
0d8609d
3f6dfef
68bce7c
aa6f04b
d54c47b
9016cd4
ee4f695
4232677
ae31557
cd280f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "art/Framework/Core/EDFilter.h" | ||
#include "art/Framework/Core/ModuleMacros.h" | ||
#include "art/Framework/Principal/Event.h" | ||
|
||
#include "lardataobj/Simulation/SimEnergyDeposit.h" | ||
|
||
namespace filt { | ||
|
||
class SimEnergyDepFakeTriggerFilter : public art::EDFilter { | ||
public: | ||
explicit SimEnergyDepFakeTriggerFilter(fhicl::ParameterSet const& pset); | ||
virtual bool filter(art::Event& e) override; | ||
|
||
private: | ||
const double fBeamTimeMin; // Minimum time of beam window [us] | ||
const double fBeamTimeMax; // Maximum time of beam window [us] | ||
const double fEnergyDeposit; // Minimum energy deposit in TPC for trigger [MeV] | ||
|
||
const std::string fSimEnergyDepModuleName; | ||
}; | ||
|
||
SimEnergyDepFakeTriggerFilter::SimEnergyDepFakeTriggerFilter(fhicl::ParameterSet const& pset) | ||
: EDFilter(pset) | ||
, fBeamTimeMin(pset.get<double>("BeamTimeMin")) | ||
, fBeamTimeMax(pset.get<double>("BeamTimeMax")) | ||
, fEnergyDeposit(pset.get<double>("EnergyDeposit")) | ||
, fSimEnergyDepModuleName(pset.get<std::string>("SimEnergyDepModuleName")) | ||
{ | ||
} | ||
|
||
bool SimEnergyDepFakeTriggerFilter::filter(art::Event& e) | ||
{ | ||
const art::ValidHandle<std::vector<sim::SimEnergyDeposit>>& | ||
energyDeps(e.getValidHandle<std::vector<sim::SimEnergyDeposit>>(fSimEnergyDepModuleName)); | ||
|
||
double energy(0); | ||
|
||
for (const sim::SimEnergyDeposit& energyDep : *energyDeps) { | ||
// Check particle time is within the beam time | ||
const double time(energyDep.Time() * 1e-3); // [ns] -> [us] | ||
if (time < fBeamTimeMin || time > fBeamTimeMax) | ||
continue; | ||
|
||
// Add up the energy deposit inside the TPC | ||
energy += energyDep.Energy(); // [MeV] | ||
} | ||
|
||
// If the energy deposit within the beam time is greater than some limit then trigger the event | ||
return energy > fEnergyDeposit; | ||
} | ||
|
||
DEFINE_ART_MODULE(SimEnergyDepFakeTriggerFilter) | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
BEGIN_PROLOG | ||
|
||
sbnd_simenergydepfaketriggerfilter: | ||
{ | ||
module_type: "SimEnergyDepFakeTriggerFilter" | ||
|
||
# Select the beam spill time to match that in sbnd_filtergenintime | ||
BeamTimeMin: -0.2 # Minimum time of beam window [us] | ||
BeamTimeMax: 1.9 # Maximum time of beam window [us] | ||
EnergyDeposit: 100 # Minimum energy deposit in TPC for trigger [MeV] | ||
|
||
# By default, take only the energy deposits within the TPC active volume | ||
SimEnergyDepModuleName: "largeant:LArG4DetectorServicevolTPCActive" # Name of SimEnergyDeposit producer module | ||
} | ||
|
||
END_PROLOG |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# | ||
# File: prodgenie_rockbox sbnd.fcl | ||
# Purpose: Produce GENIE events in the SBND detector and surrounding dirt with spill structure | ||
# using rockbox functionality in GENIEHelper | ||
# Version: 1.0 | ||
# | ||
# This configuration runs event generation and largenat | ||
# | ||
# Input: no input file required | ||
# | ||
# Dependencies: | ||
# - uses the bundle of SBND simulation services | ||
# | ||
# | ||
|
||
# | ||
# services | ||
# | ||
|
||
#include "simulationservices_sbnd.fcl" | ||
#include "messages_sbnd.fcl" | ||
|
||
# | ||
# filters | ||
# | ||
|
||
#include "gennufilter.fcl" | ||
#include "simenergydepfaketriggerfilter.fcl" | ||
|
||
# | ||
# modules | ||
# | ||
|
||
#include "genie_sbnd.fcl" | ||
#include "larg4_sbnd.fcl" | ||
|
||
|
||
process_name: GenieGen | ||
|
||
services: | ||
{ | ||
# Load the service that manages root files for histograms. | ||
TFileService: { fileName: "hists_prodgenie_sbnd_%p-%tc.root" } | ||
IFDH: {} # required by GENIEGen | ||
@table::sbnd_simulation_services # load simulation services in bulk | ||
@table::sbnd_g4_services | ||
} | ||
|
||
# Start each new event with an empty event. | ||
source: | ||
{ | ||
module_type: EmptyEvent | ||
timestampPlugin: { plugin_type: "GeneratedEventTimestamp" } | ||
maxEvents: 10 # Number of events to create | ||
firstRun: 1 # Run number to use for this file | ||
firstEvent: 1 # number of first event in the file | ||
} | ||
|
||
# Define and configure some modules to do work on each event. | ||
# First modules are defined; they are scheduled later. | ||
# Modules are grouped by type. | ||
physics: | ||
{ | ||
|
||
filters: | ||
{ | ||
# Filter events that have an interaction in the TPC | ||
tpcfilter: @local::sbnd_tpc_gennufilter | ||
|
||
# Filter events where a particle deposits >100MeV in the TPC (AKA Dirt) | ||
dirtfilter: @local::sbnd_simenergydepfaketriggerfilter | ||
} | ||
|
||
|
||
producers: | ||
{ | ||
rns: { module_type: "RandomNumberSaver" } | ||
|
||
# Run GENIE in rockbox mode | ||
generator: @local::sbnd_genie_simple_rockbox | ||
|
||
# A dummy module that forces the G4 physics list to be loaded | ||
loader: { module_type: "PhysListLoader" } | ||
|
||
# The geant4 step | ||
largeant: @local::sbnd_larg4 | ||
} | ||
|
||
#define the producer and filter modules for this path, order matters, | ||
simulatetpc: [ rns, generator, loader, largeant, tpcfilter ] | ||
simulatedirt: [ rns, generator, loader, largeant, "!tpcfilter", dirtfilter ] | ||
|
||
#define the output stream, there could be more than one if using filters | ||
# One can run any combination of outAll, outTPC and outDirt | ||
# Each of which will produce an output with the specifeied interactions | ||
|
||
# By deault Keep everything in one file: | ||
stream1: [ outAll ] | ||
|
||
#ie analyzers and output streams. these all run simultaneously | ||
end_paths: [stream1] | ||
} | ||
|
||
# block to define where the output goes. if you defined a filter in the physics | ||
# block and put it in the trigger_paths then you need to put a SelectEvents: {SelectEvents: [XXX]} | ||
# entry in the output stream you want those to go to, where XXX is the label of the filter module(s) | ||
outputs: | ||
{ | ||
# Keep all events with either TPC neutrinos or dirt interactions in one output | ||
outAll: | ||
{ | ||
module_type: RootOutput | ||
fileName: "prodgenie_sbnd_%p-%tc.root" # default file name, can override from command line with -o or --output | ||
dataTier: "generated" | ||
SelectEvents: [ simulatetpc, simulatedirt ] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# | ||
# File: split_tpc_nu.fcl | ||
# Purpose: Take in pregenerated GENIE events that contain both TPC and dirt events and split | ||
# them into two output streams based on whether they had a TPC interaction or not | ||
# Version: 1.0 | ||
# | ||
# Input: File with GENIE run as generator and largeant to track energy depositions | ||
# | ||
# Dependencies: | ||
# - uses the bundle of SBND simulation services | ||
# | ||
# | ||
|
||
# | ||
# services | ||
# | ||
|
||
#include "simulationservices_sbnd.fcl" | ||
#include "messages_sbnd.fcl" | ||
|
||
# | ||
# filters | ||
# | ||
|
||
#include "gennufilter.fcl" | ||
|
||
process_name: GenieDirtOutputs | ||
|
||
services: | ||
{ | ||
TFileService: { fileName: "hists_split_tpc_nu_sbnd_%p-%tc.root" } | ||
@table::sbnd_simulation_services # load simulation services in bulk | ||
} | ||
|
||
#source is now a root file | ||
source: | ||
{ | ||
module_type: RootInput | ||
maxEvents: -1 # Number of events to create | ||
} | ||
|
||
# Define and configure some modules to do work on each event. | ||
# First modules are defined; they are scheduled later. | ||
# Modules are grouped by type. | ||
physics: | ||
{ | ||
|
||
filters: | ||
{ | ||
# Filter events that have an interaction in the TPC | ||
tpcfilter: @local::sbnd_tpc_gennufilter | ||
} | ||
|
||
# Note we assume that every event has already been filtered to require a tpc interaction | ||
# or a dirt interaction previously. Therefore, anything without a tpc interaction is | ||
# assumed to be dirt | ||
filtertpc: [ tpcfilter ] | ||
filterdirt: [ "!tpcfilter" ] | ||
|
||
# Split the outputs into those with/without TPC interactions | ||
stream1: [ outTPC, outDirt ] | ||
|
||
#ie analyzers and output streams. these all run simultaneously | ||
end_paths: [stream1] | ||
} | ||
|
||
outputs: | ||
{ | ||
# Keep only the events with a TPC neutrino | ||
# N.B. These events will still have some random coincidence of dirt interactions | ||
outTPC: | ||
{ | ||
module_type: RootOutput | ||
fileName: "tpc_%p-%tc.root" | ||
dataTier: "generated" | ||
SelectEvents: [ filtertpc ] | ||
} | ||
|
||
# Keep only the events that have a no TPC neutrino but a dirt interaction | ||
outDirt: | ||
{ | ||
module_type: RootOutput | ||
fileName: "dirt_%p-%tc.root" | ||
dataTier: "generated" | ||
SelectEvents: [ filterdirt ] | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Runs standard g4 fcl without largeant designed for use with gen stage fcls that run a largeant dirt filter | ||
|
||
#include "standard_g4_sbnd.fcl" | ||
|
||
physics.simulate: [ rns , ionandscint , ionandscintout , pdfastsim , pdfastsimout , simdrift , mcreco ] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Runs G4 on CORSIKA and merges with the G4 instance already run on GENIE | ||
# The remainder of standard g4 fcl is then run with minor modifications to the input labels | ||
# The output produced drops the GENIE and CORSIKA specific G4 instances and keeps only the merged output | ||
|
||
#include "mergesimsources_sbnd.fcl" | ||
#include "g4_dirt_filter.fcl" | ||
|
||
# Create a new instance of largeant to just look at CORSIKA | ||
physics.producers.largeantcosmic: @local::sbnd_larg4 | ||
physics.producers.largeantcosmic.inputCollections: [ "corsika" ] | ||
|
||
# Merge together the largeant instances | ||
physics.producers.largeant: @local::sbnd_merge_overlay_sim_sources | ||
|
||
# We need to explicitly tell ionandscint to look at largeant otherwise it will take everything in the event and double count | ||
physics.producers.ionandscint.InputModuleLabels: ["largeant"] | ||
physics.producers.ionandscintout.InputModuleLabels: ["largeant"] | ||
|
||
physics.simulate: [ rns , loader, largeantcosmic , largeant , ionandscint , ionandscintout , pdfastsim , pdfastsimout , simdrift , mcreco ] | ||
|
||
# Remove the GENIE and CORSIKA specific largeant instances and keep the merged one | ||
outputs.out1.outputCommands: [ "keep *_*_*_*" | ||
, "drop *_largeantnu_*_*" | ||
, "drop *_largeantcosmic_*_*" | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If PR #206 is approved, do you mind dropping the larg4 SimEnergyDeposits here too? Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pgreen135 Done! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Runs standard g4 fcl without largeant designed for use with gen stage fcls that run a largeant dirt filter with sce | ||
#include "g4_dirt_filter.fcl" | ||
|
||
#include "enable_spacecharge_services_sbnd.fcl" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Runs G4 on CORSIKA and merges with the G4 instance already run on GENIE with sce | ||
# The remainder of standard g4 fcl is then run with minor modifications to the input labels | ||
# The output produced drops the GENIE and CORSIKA specific G4 instances and keeps only the merged output | ||
#include "g4_dirt_overlay_filter.fcl" | ||
|
||
#include "enable_spacecharge_services_sbnd.fcl" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
# Simulates GENIE neutrino interactions from the BNB beam | ||
# Simulates GENIE neutrino interactions from the BNB beam | ||
# with the beam spill structure, in the full world wolume. | ||
# Usually used for studyin dirt events. Uses flux files | ||
# with a larger window. | ||
|
||
#include "prodgenie_sbnd.fcl" | ||
|
||
physics.producers.generator: { | ||
@table::physics.producers.generator | ||
@table::sbnd_genie_simple_dirt | ||
EventsPerSpill: 0 | ||
TopVolume: "volWorld" | ||
FluxUpstreamZ: -18 #Start the flux rays at 18m upstream of the TPC frontface. Chosen as this is the distance a muon of 8 GeV (max flux sim. energy) can travel | ||
} | ||
physics.producers.generator: @local::sbnd_genie_simple_dirt |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Simulates GENIE nue and anue neutrino interactions from the BNB beam | ||
# using the rockbox confiuration | ||
|
||
#include "prodgenie_rockbox_sbnd.fcl" | ||
|
||
#include "set_genie_nue.fcl" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Produce GENIE nue and anue rockbox interactions and overlay CORSIKA cosmics | ||
# Note: To run G4 over CORSIKA and merge collections together you will need g4_dirt_overlay_filter.fcl | ||
#include "overlay/prodoverlay_corsika_cosmics_proton_genie_rockbox_sbnd.fcl" | ||
|
||
#include "set_genie_nue.fcl" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future we should think if this is the best value for this, for now I am happy to proceed but we should open an issue to verify this is the optimal energy cut.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I will do that once this has been merged.