diff --git a/JobConfig/pileup/STM/BeamToVD.fcl b/JobConfig/pileup/STM/BeamToVD.fcl index 5043b2a2..2ffdc959 100644 --- a/JobConfig/pileup/STM/BeamToVD.fcl +++ b/JobConfig/pileup/STM/BeamToVD.fcl @@ -1,121 +1,163 @@ +# Run Stage 1 of the STM simulation defined in docdb 51487 # Re-sample EleBeamCat and MuBeamCat datasets, propagate them to a chosen virtual detector, and write out the events with SimParticles and StepPointMCs travelling through that virtual detector only +# Based on Production/JobConfig/Pileup/EleBeamResampler.fcl and Production/JobConfig/Pileup/MuBeamResampler.fcl +# Usage: +# - General modifications should not be required to this file. +# - To generate fcl files that use this file, follow up with Production/Scripts/STM/gen_BeamToVD.sh +# - To change the virtual detector ID, compression settings, or output data products, modify the relevant parameters in Production/JobConfig/pileup/STM/prolog.fcl +# - To change the GEANT verbosity, see the bottom of this file # Original author: Yuri Oksuzian, 2019 # Updated for MDC2020 (DetectorSteps): D. Brown # Updated for STM studies: P. Plesniak # Offline includes -#include "Offline/CommonMC/fcl/prolog.fcl" +# Offline/fcl/standardServices.fcl - contains standard Mu2e services #include "Offline/fcl/standardServices.fcl" -#include "Offline/STMMC/fcl/prolog.fcl" # Production includes +# Production/JobConfig/common/prolog.fcl - contains Mu2eG4 common configuration #include "Production/JobConfig/common/prolog.fcl" +# Production/JobConfig/pileup/prolog.fcl - contains beam resampling common configuration #include "Production/JobConfig/pileup/prolog.fcl" +# Production/JobConfig/pileup/STM/prolog.fcl - contains STM pileup common configuration #include "Production/JobConfig/pileup/STM/prolog.fcl" -process_name: BeamToVD +process_name : BeamToVD source : { module_type : EmptyEvent maxEvents : @nil } +# Import the current geomety, calibration, and conditions data, as well as the RandomNumberGenerator and seed services services : @local::Services.Sim -physics: { +physics : { producers : { - @table::Common.producers - @table::Pileup.producers + @table::Common.producers # Contains Mu2eG4 common configuration (drives the Mu2eG4 simulation) + @table::Pileup.producers # TODO - see if this can be deleted, following discussion with Andy extractVirtualDetectorSteps : { - # Creates "mu2e::StepPointMCs_extractVirtualDetectorSteps__BeamToVD" products that only store StepPointMCs in the selected virtual detector - # Want to only keep events with the given virtual detector ID and filter out the rest - # Empty collections will be generated if the selected virtual detector has no associated StepPointMCs to allow the compression to take place + # Creates "mu2e::StepPointMCs_extractVirtualDetectorSteps_virtualdetecctor_BeamToVD" products that only store StepPointMCs in the selected virtual detector. + # Want to only keep events if a SimParticle crosses the selected virtual detector. + # Empty collections will be generated if the selected virtual detector has no associated StepPointMCs to allow the filtering to take place. module_type : STMResamplingProducer - StepPointMCsTag : @local::ResamplingProducer.StepPointMCsTag - VirtualDetectorID : @local::ResamplingProducer.VirtualDetectorID + StepPointMCsTag : @local::STMPileup.ResamplingProducer.StepPointMCsTag + VirtualDetectorID : @local::STMPileup.ResamplingProducer.VirtualDetectorID } compressDetStepMCsSTM : { - # Creates "mu2e::SimParticlemv_compressDetStepMCsSTM__BeamToVD" and "mu2e::StepPointMCs_compressDetStepMCsSTM__BeamToVD" products from "mu2e::StepPointMCs_extractVirtualDetectorSteps__BeamToVD" products - # Keeps SimParticles and StepPointMCs going through the selected virtual detector only + # Creates "mu2e::StepPointMCs_compressDetStepMCsSTM_virtualdetecctor_BeamToVD" and "mu2e::SimParticlemv_compressDetStepMCsSTM_virtualdetecctor_BeamToVD" products from "mu2e::StepPointMCs_extractVirtualDetectorSteps_virtualdetecctor_BeamToVD" products. + # These collections contain the StepPointMCs and SimParticles that pass through the selected virtual detector only, any other daughter particles are removed. + # Keeps SimParticles and StepPointMCs going through the selected virtual detector only. module_type : CompressDetStepMCs - strawGasStepTag : "" - caloShowerStepTag : "" - surfaceStepTag : "" - crvStepTag : "" - simParticleTags : ["g4run"] + strawGasStepTag : @local::STMSimDataProducts.EmptyString + caloShowerStepTag : @local::STMSimDataProducts.EmptyString + surfaceStepTag : @local::STMSimDataProducts.EmptyString + crvStepTag : @local::STMSimDataProducts.EmptyString + simParticleTags : [ + @local::STMSimDataProducts.Stage1.GEANT.SimParticles + ] debugLevel : 0 - stepPointMCTags : ["extractVirtualDetectorSteps"] + stepPointMCTags : [ + @local::STMSimDataProducts.Stage1.ExtractedStepPointMCs + ] compressionOptions : { - strawGasStepCompressionLevel: "noCompression" - caloShowerStepCompressionLevel: "noCompression" - crvStepCompressionLevel: "noCompression" - surfaceStepCompressionLevel: "noCompression" - simParticleCompressionLevel : "noCompression" - stepPointMCCompressionLevel : "noCompression" - keepNGenerations : -1 - mcTrajectoryCompressionLevel : "noCompression" + strawGasStepCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + caloShowerStepCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + crvStepCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + surfaceStepCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + simParticleCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + stepPointMCCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + keepNGenerations : @local::STMPileup.CompressionParameters.CompressionGenerations + mcTrajectoryCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString } - mcTrajectoryTag : "" + mcTrajectoryTag : @local::STMSimDataProducts.EmptyString } } filters : { - @table::Common.filters - @table::Pileup.filters - filterVirtualDetectorSteps: { - # Filters events based on the size of "mu2e::StepPointMCs_compressDetStepMCsSTM__BeamToVD" - # If there are no StepPointMCs in the selected virtual detector, the event is not kept - # Required as extractVirtualDetectorSteps will create a StepPointMCCollection even if the collection is empty - module_type: STMResamplingFilter - StepPointMCsTag : @local::ResamplingFilter.StepPointMCsTag + @table::Common.filters # Contains Mu2eG4 common filters (consistent filter, required for all Mu2eG4 jobs) + @table::Pileup.filters # Contains beam resampling common filters (contains the beamResampler definition) + filterVirtualDetectorSteps : { + # Filters events based on the size of "mu2e::StepPointMCs_compressDetStepMCsSTM_virtualdetector_BeamToVD". + # If there are no StepPointMCs in the selected virtual detector, the event is not kept. + # Required as extractVirtualDetectorSteps will create a StepPointMCCollection even if the collection is empty. + module_type : STMResamplingFilter + StepPointMCsTag : @local::STMPileup.ResamplingFilterStepPointMCs } } analyzers : { - @table::Common.analyzers + @table::Common.analyzers # Contains Mu2eG4 common analyzers (includes genCountLogger, which generates a nice generated event summary) countVirtualDetectorHits : { # Runs a counter over the virtual detectors to keep track of hits module_type : CountVirtualDetectorHits - stepPointMCsTag : @local::VirtualDetectorCounter.StepPointMCsTag - virtualDetectorIDs : @local::VirtualDetectorCounter.virtualDetectorIDs + stepPointMCsTag : @local::STMPileup.VirtualDetectorCounter.StepPointMCs + virtualDetectorIDs : @local::STMPileup.VirtualDetectorCounter.VirtualDetectorIDs } } - # setup paths - STMCompressedPath : [@sequence::Pileup.beamResamplerSequence, @sequence::Common.g4Sequence, extractVirtualDetectorSteps, compressDetStepMCsSTM, filterVirtualDetectorSteps] - trigger_paths: [STMCompressedPath] - outPathCompressed : [genCountLogger, countVirtualDetectorHits, compressedOutput] - end_paths: [outPathCompressed] + # Setup the trigger paths + STMCompressedPath : [ + @sequence::Pileup.beamResamplerSequence, # Resample beam particles from input datasets + @sequence::Common.g4Sequence, # Run the Mu2eG4 simulation + extractVirtualDetectorSteps, # Extract StepPointMCs in the selected virtual detector + filterVirtualDetectorSteps, # Filter events based on presence of StepPointMCs in the selected virtual detector + compressDetStepMCsSTM # Compress to keep only SimParticles and StepPointMCs contributing to a particle crossing the selected virtual detector + ] + trigger_paths : [ + STMCompressedPath + ] + # Setup the output paths + outPathCompressed : [ + genCountLogger, # Generates a nice generated event summary + countVirtualDetectorHits, # Counts the number of hits in the selected virtual detector + compressedOutput # Output module to write out the compressed data products + ] + end_paths : [ + outPathCompressed + ] } -# Keep only the necessary data -outputs: { +# Set up the output paths, keeping only the desired data products +outputs : { compressedOutput : { - module_type: RootOutput - outputCommands: [ - "drop *_*_*_*", - @sequence::Pileup.BeamToVDKeptProducts + module_type : RootOutput + outputCommands : @local::STMSimDataProducts.BeamToVDKeptProducts + SelectEvents : [ # Only write out events that pass through the selected virtual detector + STMCompressedPath ] - SelectEvents: [STMCompressedPath] - fileName : "dts.owner.BeamToVD.version.sequencer.art" + fileName : @local::STMPileup.SimulationOutputFilenames.Stage1 } } -# Point Mu2eG4 to the pre-simulated data -physics.producers.g4run.inputs: { - primaryType: "StepPoints" - primaryTag: "beamResampler:Beam" - inputMCTrajectories: "" - simStageOverride: 1 - inputPhysVolumeMultiInfo: "beamResampler" - updateEventLevelVolumeInfos: { - input: "beamResampler:eventlevel" - outInstance: "eventlevel" +# GEANT variables +# Point Mu2eG4 to input data +physics.producers.g4run.inputs : { + primaryType : @local::STMSimDataProducts.Stage1.InputType.BeamCatDatasets + primaryTag : @local::STMSimDataProducts.Stage1.InputTag.BeamCatDatasets + inputMCTrajectories : @local::STMSimDataProducts.EmptyString + simStageOverride : 1 + inputPhysVolumeMultiInfo : @local::STMSimDataProducts.Stage1.InputPhysVolumeMultiInfo.BeamCatDatasets + updateEventLevelVolumeInfos : { + input : @local::STMSimDataProducts.Stage1.UpdateEventLevelVolumeInfos.Input.BeamCatDatasets + outInstance : @local::STMSimDataProducts.Stage1.UpdateEventLevelVolumeInfos.OutInstance } } -physics.producers.g4run.SDConfig.preSimulatedHits: ["beamResampler:virtualdetector"] -physics.producers.g4run.SDConfig.enableSD: [virtualdetector] -physics.producers.g4run.Mu2eG4CommonCut: {} +# Specify pre-simulated hits for beam resampling +physics.producers.g4run.SDConfig.preSimulatedHits : @local::STMSimDataProducts.Stage1.PreSimulatedData.BeamCatDatasets + +# Enable the virtual detector sensitive detector - without this the virtualdetector data products will not be created +physics.producers.g4run.SDConfig.enableSD : [ + virtualdetector +] + +# Explicitly disable common cuts for STM pileup generation +physics.producers.g4run.Mu2eG4CommonCut : {} + +# Optional debugging output - makes it very clear what is happening in GEANT +# physics.producers.g4run.debug.trackingVerbosityLevel : 1 +# physics.producers.g4run.debug.steppingVerbosityLevel : 1 + # Epilog includes #include "Production/JobConfig/common/MT.fcl" #include "Production/JobConfig/common/epilog.fcl" -#include "Production/JobConfig/pileup/epilog.fcl" +# #include "Production/JobConfig/pileup/epilog.fcl" # Note - this was present for the study in 51487, and has been removed for subsequent studies to help quantify if this cut impacts results diff --git a/JobConfig/pileup/STM/BeamToVD1809.fcl b/JobConfig/pileup/STM/BeamToVD1809.fcl index 33681725..9ee4b9a3 100644 --- a/JobConfig/pileup/STM/BeamToVD1809.fcl +++ b/JobConfig/pileup/STM/BeamToVD1809.fcl @@ -1,123 +1,179 @@ -# Generate and propagate 1809 keV muon stop signal photons from muon target stops -# Original author: Dave Brown, LBNL +# Run Stage 1 of the STM simulation defined in docdb 51487 +# Generate and propagate 1809 keV muon stop signal photons from muon target stop positions +# Usage: +# - General modifications should not be required to this file. +# - To generate fcl files that use this file, follow up with Production/Scripts/STM/gen_BeamToVD1809.sh +# - To change the virtual detector ID, compression settings, or output data products, modify the relevant parameters in Production/JobConfig/pileup/STM/prolog.fcl +# - To change the GEANT verbosity, see the bottom of this file +# Original author: Yuri Oksuzian, 2019 +# Updated for MDC2020 (DetectorSteps): D. Brown # Updated for STM studies: Pawel Plesniak # Offline includes +# Offline/fcl/standardServices.fcl - contains standard Mu2e services #include "Offline/fcl/standardServices.fcl" +# TODO - can this be deleted? #include "Offline/EventGenerator/fcl/prolog.fcl" -#include "Offline/STMMC/fcl/prolog.fcl" # Production includes +# Production/JobConfig/common/prolog.fcl - contains Mu2eG4 common configuration #include "Production/JobConfig/common/prolog.fcl" +# Production/JobConfig/pileup/prolog.fcl - contains the protonTimeOffset definition (TODO - see if this can be deleted following discussion with Andy) #include "Production/JobConfig/pileup/prolog.fcl" +# Production/JobConfig/primary/prolog.fcl - contains target stop resampling common configuration #include "Production/JobConfig/primary/prolog.fcl" +# Production/JobConfig/pileup/STM/prolog.fcl - contains STM pileup common configuration #include "Production/JobConfig/pileup/STM/prolog.fcl" -process_name: BeamToVD1809 +process_name : BeamToVD1809 -source: { +source : { module_type : EmptyEvent maxEvents : @nil } +# Import the current geomety, calibration, and conditions data, as well as the RandomNumberGenerator and seed services services : @local::Services.Sim physics : { producers : { - @table::Common.producers - @table::Pileup.producers - generate : { # Generates the 1809 keV peaks from muon target stop positions - module_type: Pileup - inputSimParticles: TargetStopResampler + @table::Common.producers # Contains Mu2eG4 common configuration (drives the Mu2eG4 simulation) + @table::Pileup.producers # TODO - see if this can be deleted, following discussion with Andy + generate : { + # Generate the 1809 keV peaks from muon target stop positions + # Note - this is not the clearest thing immediately, thank you AE for clarifying this many times over. + # The 1809 keV photons are only generated on muon CAPTURES, hence they are a part of the captureProducts list + # The 51.5% is then relative to the number of muon CAPTURES - see https://www.nndc.bnl.gov/ensnds/26/Mg/27al_mu-_nung.pdf + module_type : Pileup + inputSimParticles : TargetStopResampler stoppingTargetMaterial : "Al" - verbosity: 0 - captureProducts: [{tool_type : "MuCap1809keVGammaGenerator"}] - decayProducts: [] + verbosity : 0 + captureProducts : [ + { + tool_type : "MuCap1809keVGammaGenerator" + } + ] + decayProducts : [] } extractVirtualDetectorSteps : { - # Creates "mu2e::StepPointMCs_extractVirtualDetectorSteps__BeamToVD1809" products that only store StepPointMCs in the selected virtual detector - # Want to only keep events with the given virtual detector ID and filter out the rest - # Empty collections will be generated if the selected virtual detector has no associated StepPointMCs to allow the compression to take place + # Creates "mu2e::StepPointMCs_extractVirtualDetectorSteps_virtualdetecctor_BeamToVD" products that only store StepPointMCs in the selected virtual detector + # Want to only keep events if a SimParticle crosses the selected virtual detector + # Empty collections will be generated if the selected virtual detector has no associated StepPointMCs to allow the filtering to take place module_type : STMResamplingProducer - StepPointMCsTag : @local::ResamplingProducer.StepPointMCsTag - VirtualDetectorID : @local::ResamplingProducer.VirtualDetectorID - } + StepPointMCsTag : @local::STMPileup.ResamplingProducer.StepPointMCsTag + VirtualDetectorID : @local::STMPileup.ResamplingProducer.VirtualDetectorID + } compressDetStepMCsSTM : { - # Creates "mu2e::SimParticlemv_compressDetStepMCsSTM__BeamToVD1809" and "mu2e::StepPointMCs_compressDetStepMCsSTM__BeamToVD1809" products from "mu2e::StepPointMCs_extractVirtualDetectorSteps__BeamToVD1809" products - # Keeps SimParticles and StepPointMCs going through the selected virtual detector only + # Creates "mu2e::StepPointMCs_compressDetStepMCsSTM_virtualdetecctor_BeamToVD" and "mu2e::SimParticlemv_compressDetStepMCsSTM_virtualdetecctor_BeamToVD" products from "mu2e::StepPointMCs_extractVirtualDetectorSteps_virtualdetecctor_BeamToVD" products. + # These collections contain the StepPointMCs and SimParticles that pass through the selected virtual detector only, any other daughter particles are removed. + # Keeps SimParticles and StepPointMCs going through the selected virtual detector only. module_type : CompressDetStepMCs - strawGasStepTag : "" - caloShowerStepTag : "" - surfaceStepTag : "" - crvStepTag : "" - simParticleTags : ["g4run"] + strawGasStepTag : @local::STMSimDataProducts.EmptyString + caloShowerStepTag : @local::STMSimDataProducts.EmptyString + surfaceStepTag : @local::STMSimDataProducts.EmptyString + crvStepTag : @local::STMSimDataProducts.EmptyString + simParticleTags : [ + @local::STMSimDataProducts.Stage1.GEANT.SimParticles + ] debugLevel : 0 - stepPointMCTags : ["extractVirtualDetectorSteps"] + stepPointMCTags : [ + @local::STMSimDataProducts.Stage1.ExtractedStepPointMCs + ] compressionOptions : { - strawGasStepCompressionLevel: "noCompression" - caloShowerStepCompressionLevel: "noCompression" - crvStepCompressionLevel: "noCompression" - surfaceStepCompressionLevel: "noCompression" - keepNGenerations : -1 - simParticleCompressionLevel : "fullCompression" - stepPointMCCompressionLevel : "noCompression" - mcTrajectoryCompressionLevel : "noCompression" + strawGasStepCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + caloShowerStepCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + crvStepCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + surfaceStepCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + simParticleCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + stepPointMCCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + keepNGenerations : @local::STMPileup.CompressionParameters.CompressionGenerations + mcTrajectoryCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString } - mcTrajectoryTag : "" + mcTrajectoryTag : @local::STMSimDataProducts.EmptyString } } filters : { - @table::Common.filters - @table::Pileup.filters + @table::Common.filters # Contains Mu2eG4 common filters (consistent filter, required for all Mu2eG4 jobs) + # @table::Primary.filters # Contains beam resampling common filters (contains the TargetStopResampler definition) TargetStopResampler : @local::Primary.filters.TargetStopResampler - filterVirtualDetectorSteps: { - # Filters events based on the size of "mu2e::StepPointMCs_compressDetStepMCsSTM__BeamToVD1809" - # If there are no StepPointMCs in the selected virtual detector, the event is not kept - # Required as extractVirtualDetectorSteps will create a StepPointMCCollection even if the collection is empty - module_type: STMResamplingFilter - StepPointMCsTag : @local::ResamplingFilter.StepPointMCsTag + filterVirtualDetectorSteps : { + # Filters events based on the size of "mu2e::StepPointMCs_compressDetStepMCsSTM_virtualdetector_BeamToVD". + # If there are no StepPointMCs in the selected virtual detector, the event is not kept. + # Required as extractVirtualDetectorSteps will create a StepPointMCCollection even if the collection is empty. + module_type : STMResamplingFilter + StepPointMCsTag : @local::STMPileup.ResamplingFilterStepPointMCs } } analyzers : { - @table::Common.analyzers + @table::Common.analyzers # Contains Mu2eG4 common analyzers (includes genCountLogger, which generates a nice generated event summary) countVirtualDetectorHits : { # Runs a counter over the virtual detectors to keep track of hits module_type : CountVirtualDetectorHits - stepPointMCsTag : @local::VirtualDetectorCounter.StepPointMCsTag - virtualDetectorIDs : @local::VirtualDetectorCounter.virtualDetectorIDs + stepPointMCsTag : @local::STMPileup.VirtualDetectorCounter.StepPointMCs + virtualDetectorIDs : @local::STMPileup.VirtualDetectorCounter.VirtualDetectorIDs } } - PileupPath : [TargetStopResampler, @sequence::Common.generateSequence, @sequence::Common.g4Sequence, extractVirtualDetectorSteps, compressDetStepMCsSTM, filterVirtualDetectorSteps] - trigger_paths : [PileupPath] - outPathCompressed : [genCountLogger, countVirtualDetectorHits, compressedOutput] - end_paths: [outPathCompressed] + PileupPath : [ + TargetStopResampler, # Resample beam particles from input datasets + @sequence::Common.generateSequence, # Generate the 1809 keV photons from muon target stops + @sequence::Common.g4Sequence, # Run the Mu2eG4 simulation + extractVirtualDetectorSteps, # Extract StepPointMCs in the selected virtual detector + filterVirtualDetectorSteps, # Filter events based on presence of StepPointMCs in the selected virtual detector + compressDetStepMCsSTM # Compress to keep only SimParticles and StepPointMCs contributing to a particle crossing the selected virtual detector + ] + trigger_paths : [ + PileupPath + ] + outPathCompressed : [ + genCountLogger, # Generates a nice generated event summary + countVirtualDetectorHits, # Counts the number of hits in the selected virtual detector + compressedOutput # Output module to write out the compressed data products + ] + end_paths : [ + outPathCompressed + ] } outputs : { compressedOutput : { - module_type: RootOutput - outputCommands : [ - "drop *_*_*_*", - @sequence::Pileup.BeamToVDKeptProducts + module_type : RootOutput + outputCommands : @local::STMSimDataProducts.BeamToVDKeptProducts + SelectEvents : [ # Only write out events that pass through the selected virtual detector + PileupPath ] - SelectEvents: [ PileupPath ] - fileName: "dts.owner.MuStopPileup.version.sequencer.art" + fileName : @local::STMPileup.SimulationOutputFilenames.Stage1 } } -# resampling configuration -physics.producers.g4run.inputs: { - primaryType: StageParticles - primaryTag: "generate" - inputMCTrajectories: "" - simStageOverride: 2 - inputPhysVolumeMultiInfo: "TargetStopResampler" - updateEventLevelVolumeInfos: { - input: "TargetStopResampler:eventlevel" - outInstance: "eventlevel" +# GEANT variables +# Point Mu2eG4 to input data +physics.producers.g4run.inputs : { + primaryType : @local::STMSimDataProducts.Stage1.InputType.TargetStopsCatDataset + primaryTag : @local::STMSimDataProducts.Stage1.InputTag.TargetStopsCatDataset + inputMCTrajectories : @local::STMSimDataProducts.EmptyString + simStageOverride : 2 + inputPhysVolumeMultiInfo : @local::STMSimDataProducts.Stage1.InputPhysVolumeMultiInfo.TargetStopsCatDataset + updateEventLevelVolumeInfos : { + input : @local::STMSimDataProducts.Stage1.UpdateEventLevelVolumeInfos.Input.TargetStopsCatDataset + outInstance : @local::STMSimDataProducts.Stage1.UpdateEventLevelVolumeInfos.OutInstance } } +# Specify pre-simulated hits for beam resampling +physics.producers.g4run.SDConfig.preSimulatedHits : @local::STMSimDataProducts.Stage1.PreSimulatedData.TargetStopsCatDataset + +# Enable the virtual detector sensitive detector - without this the virtualdetector data products will not be created +physics.producers.g4run.SDConfig.enableSD : [ + virtualdetector +] + +# Explicitly disable common cuts for STM pileup generation +physics.producers.g4run.Mu2eG4CommonCut : {} + +# Optional debugging output - makes it very clear what is happening in GEANT +# physics.producers.g4run.debug.trackingVerbosityLevel : 1 +# physics.producers.g4run.debug.steppingVerbosityLevel : 1 + # Epilog includes #include "Production/JobConfig/common/MT.fcl" #include "Production/JobConfig/common/epilog.fcl" -#include "Production/JobConfig/pileup/epilog.fcl" +# #include "Production/JobConfig/pileup/epilog.fcl" # Note - this was present for the study in 51487, and has been removed for subsequent studies to help quantify if this cut impacts results diff --git a/JobConfig/pileup/STM/STMResampler.fcl b/JobConfig/pileup/STM/STMResampler.fcl index 457327d1..44521bb8 100644 --- a/JobConfig/pileup/STM/STMResampler.fcl +++ b/JobConfig/pileup/STM/STMResampler.fcl @@ -1,7 +1,17 @@ -# Re-sample StepPointMCs from VD101 to STM. +# Run Stage 2 of the STM simulation defined in docdb 51487 +# Re-sample the propagated EleBeamCat and MuBeamCat datasets from the chosen virtual detector, and write out the events with SimParticles and StepPointMCs travelling through that virtual detector only +# Note - this is configured to run from VD101 only. +# Usage: +# - General modifications ARE REQUIRED FOR THIS FILE - you will need to populate each space there is a `@nil # Populate me!` with one of each of the following (use either HPGe* or LaBr* depending on your simulation use case) +# - trigger_paths - either HPGePath or LaBrPath +# - SelectEvents - either HPGePath or LaBrPath +# - physics.producers.g4run.inputs.primaryTag - replace the @nil with either HPGe or LaBr +# - To generate fcl files that use this file, follow up with Production/Scripts/STM/gen_STMResampler.sh +# - To change the GEANT verbosity, see the bottom of this file +# NOTE - When finalizing this script, there were some errors with the compression. I couldn't debug it and did not make time to run a separate simulation to propagate these changes. Debugging is left to the user. # Original author: Yuri Oksuzian, 2019 # Updated for MDC2020 (DetectorSteps): D. Brown -# Updated for STM studies: Pawel Plesniak +# Updated for STM studies: P. Plesniak # Offline includes #include "Offline/Analyses/fcl/prolog.fcl" @@ -14,127 +24,159 @@ #include "Production/JobConfig/pileup/prolog.fcl" #include "Production/JobConfig/pileup/STM/prolog.fcl" -process_name: STMResampler +process_name : STMResampler -source: { +source : { module_type : EmptyEvent - maxEvents : @nil + # maxEvents : @nil } services : @local::Services.Sim -physics: { + +physics : { producers : { @table::Common.producers - @table::Pileup.producers # Contains stmResampler + @table::Pileup.producers # TODO BEFORE NEXT CAMPAIGN - add the CompressPhysicalVolumes module here keeping the output from the FilterG4Out module label. - shiftStepsHPGe : { # Shift the steps to upstream of the HPGe absorber along the SSC aperture + shiftStepsHPGe : { + # Shift the steps to upstream of the HPGe absorber along the SSC aperture module_type : ShiftVirtualDetectorStepPointMCs - StepPointMCsTag : "stmResampler:" - VirtualDetectorID : @local::ShiftVD101Steps.VirtualDetectorID - InputRadius : @local::ShiftVD101Steps.InputRadius - OutputRadius : @local::ShiftVD101Steps.OutputRadius + StepPointMCsTag : @local::STMSimDataProducts.Stage2.ResampledStepPointMCs.BeamCatDatasets + VirtualDetectorID : @local::STMPileup.ShiftVD101Steps.VirtualDetectorID + InputRadius : @local::STMPileup.ShiftVD101Steps.InputRadius + OutputRadius : @local::STMPileup.ShiftVD101Steps.OutputRadius InputX : @local::ComponentPositions.VD101.x InputY : @local::ComponentPositions.VD101.y InputZ : @local::ComponentPositions.VD101.z - OutputX : @local::ShiftVD101Steps.HPGeUpStr.x - OutputY : @local::ShiftVD101Steps.HPGeUpStr.y - OutputZ : @local::ShiftVD101Steps.HPGeUpStr.z - pdgID : @local::ShiftVD101Steps.pdgID + OutputX : @local::STMPileup.ShiftVD101Steps.HPGeUpStr.x + OutputY : @local::STMPileup.ShiftVD101Steps.HPGeUpStr.y + OutputZ : @local::STMPileup.ShiftVD101Steps.HPGeUpStr.z + pdgID : @local::STMPileup.ShiftVD101Steps.pdgID } - shiftStepsLaBr : { # Shift the steps to upstream of the LaBr SSC aperture + shiftStepsLaBr : { + # Shift the steps to upstream of the LaBr SSC aperture module_type : ShiftVirtualDetectorStepPointMCs - StepPointMCsTag : "stmResampler:" - VirtualDetectorID : @local::ShiftVD101Steps.VirtualDetectorID - InputRadius : @local::ShiftVD101Steps.InputRadius - OutputRadius : @local::ShiftVD101Steps.OutputRadius + StepPointMCsTag : @local::STMSimDataProducts.Stage2.ResampledStepPointMCs.BeamCatDatasets + VirtualDetectorID : @local::STMPileup.ShiftVD101Steps.VirtualDetectorID + InputRadius : @local::STMPileup.ShiftVD101Steps.InputRadius + OutputRadius : @local::STMPileup.ShiftVD101Steps.OutputRadius InputX : @local::ComponentPositions.VD101.x InputY : @local::ComponentPositions.VD101.y InputZ : @local::ComponentPositions.VD101.z - OutputX : @local::ShiftVD101Steps.LaBrUpStr.x - OutputY : @local::ShiftVD101Steps.LaBrUpStr.y - OutputZ : @local::ShiftVD101Steps.LaBrUpStr.z - pdgID : @local::ShiftVD101Steps.pdgID + OutputX : @local::STMPileup.ShiftVD101Steps.LaBrUpStr.x + OutputY : @local::STMPileup.ShiftVD101Steps.LaBrUpStr.y + OutputZ : @local::STMPileup.ShiftVD101Steps.LaBrUpStr.z + pdgID : @local::STMPileup.ShiftVD101Steps.pdgID } - compressSTMDet : { # Keeps only the wanted StepPoints and SimParticles for this study - # Creates "mu2e::SimParticlemv_compressSTMDet__STMResampler" and "mu2e::StepPointMCs_compressSTMDet__STMResampler" products from "mu2e::StepPointMCs_g4run_STMDet_STMResampler" products - # Keeps SimParticles and StepPointMCs going through STMDet only + compressSTMDet : { + # Creates "mu2e::StepPointMCs_compressSTMDet_virtualdetecctor_STMResampler", "mu2e::StepPointMCs_compressSTMDet_STMDet_STMResampler" and "mu2e::SimParticlemv_compressSTMDet__STMResampler" products from "mu2e::StepPointMCs_extractVirtualDetectorSteps_virtualdetecctor_STMResampler" products. + # These collections contain the StepPointMCs and SimParticles that pass through the selected virtual detector only, any other daughter particles are removed. + # Keeps SimParticles and StepPointMCs going through the selected virtual detector only. module_type : CompressDetStepMCs - strawGasStepTag : "" - caloShowerStepTag : "" - surfaceStepTag : "" - crvStepTag : "" - simParticleTags : [ "g4run" ] + strawGasStepTag : @local::STMSimDataProducts.EmptyString + caloShowerStepTag : @local::STMSimDataProducts.EmptyString + surfaceStepTag : @local::STMSimDataProducts.EmptyString + crvStepTag : @local::STMSimDataProducts.EmptyString + simParticleTags : [ + @local::STMSimDataProducts.Stage2.GEANT.SimParticles + ] debugLevel : 0 - stepPointMCTags : [ "g4run:STMDet", "g4run:virtualdetector" ] + stepPointMCTags : @local::STMSimDataProducts.Stage2.GEANT.StepPointMCs compressionOptions : { - strawGasStepCompressionLevel: "noCompression" - caloShowerStepCompressionLevel: "noCompression" - crvStepCompressionLevel: "noCompression" - surfaceStepCompressionLevel: "noCompression" - stepPointMCCompressionLevel : "noCompression" - simParticleCompressionLevel : "noCompression" - stepPointMCCompressionLevel : "noCompression" - keepNGenerations : -1 - mcTrajectoryCompressionLevel : "noCompression" + strawGasStepCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + caloShowerStepCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + crvStepCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + surfaceStepCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + simParticleCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + stepPointMCCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + keepNGenerations : @local::STMPileup.CompressionParameters.CompressionGenerations + mcTrajectoryCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString } - mcTrajectoryTag : "" + mcTrajectoryTag : @local::STMSimDataProducts.EmptyString } } filters : { @table::Common.filters @table::Pileup.filters + @table::STMPileup.filters } analyzers : { @table::Common.analyzers countVirtualDetectorHits : { # Runs a counter over the virtual detectors to keep track of hits module_type : CountVirtualDetectorHits - stepPointMCsTag : @local::VirtualDetectorCounter.StepPointMCsTag - virtualDetectorIDs : @local::VirtualDetectorCounter.virtualDetectorIDs + stepPointMCsTag : @local::STMPileup.VirtualDetectorCounter.StepPointMCs + virtualDetectorIDs : @local::STMPileup.VirtualDetectorCounter.VirtualDetectorIDs } } - HPGePath : [@sequence::Pileup.stmResamplerSequence, shiftStepsHPGe, @sequence::Common.g4Sequence, compressSTMDet ] - LaBrPath : [@sequence::Pileup.stmResamplerSequence, shiftStepsLaBr, @sequence::Common.g4Sequence, compressSTMDet ] - trigger_paths: [HPGePath] - outPathCompressed : [genCountLogger, countVirtualDetectorHits, CompressedOutput] - end_paths: [outPathCompressed] + HPGePath : [ + @sequence::STMPileup.STMResamplerSequenceBeamCatDatasets, + shiftStepsHPGe, + @sequence::Common.g4Sequence + compressSTMDet + ] + LaBrPath : [ + @sequence::STMPileup.STMResamplerSequenceBeamCatDatasets, + shiftStepsLaBr, + @sequence::Common.g4Sequence, + compressSTMDet + ] + trigger_paths : [ + @nil # Populate me! + ] + outPathCompressed : [ + genCountLogger, + countVirtualDetectorHits, + CompressedOutput + ] + end_paths : [ + outPathCompressed + ] } -outputs: { +outputs : { CompressedOutput : { - module_type: RootOutput - outputCommands : [ - "drop *_*_*_*", - "keep mu2e::GenEventCount_*_*_*", - "keep art::EventIDs_*_*_*", - "keep mu2e::StepPointMCs_compressSTMDet_*_STMResampler", - "keep mu2e::SimParticlemv_compressSTMDet_*_STMResampler", - "keep mu2e::SimTimeOffset_protonTimeOffset_*_STMResampler", - "keep mu2e::PhysicalVolumeInfomvs_*_*_*" + module_type : RootOutput + outputCommands : @local::STMSimDataProducts.STMResamplerKeptProducts + SelectEvents : [ + @nil # Populate me! ] - fileName : "dts.plesniak.STMDet.version.sequencer.art" + fileName : @local::STMPileup.SimulationOutputFilenames.Stage2 } } -# Point Mu2eG4 to the pre-simulated data -physics.producers.g4run.inputs: { - primaryType: "StepPoints" - primaryTag: "shiftStepsHPGe:" - inputMCTrajectories: "" - simStageOverride: 3 # 2 - inputPhysVolumeMultiInfo: "stmResampler" - updateEventLevelVolumeInfos: { - input: "stmResampler:eventlevel" - outInstance: "eventlevel" +# GEANT variables +# Point Mu2eG4 to input data +physics.producers.g4run.inputs : { + primaryType : @local::STMSimDataProducts.Stage2.InputType + primaryTag : @local::STMSimDataProducts.Stage2.InputTag.@nil # Populate me! + inputMCTrajectories : @local::STMSimDataProducts.EmptyString + simStageOverride : 2 + inputPhysVolumeMultiInfo : @local::STMSimDataProducts.Stage2.InputPhysVolumeMultiInfo + updateEventLevelVolumeInfos : { + input : @local::STMSimDataProducts.Stage2.UpdateEventLevelVolumeInfos.Input + outInstance : @local::STMSimDataProducts.Stage2.UpdateEventLevelVolumeInfos.OutInstance } } -physics.producers.g4run.SDConfig.enableSD: [virtualdetector, STMDet] -physics.producers.g4run.Mu2eG4CommonCut: {} +# Specify pre-simulated hits for beam resampling +physics.producers.g4run.SDConfig.preSimulatedHits : @local::STMSimDataProducts.Stage2.PreSimulatedData.BeamCatDatasets + +# Enable the virtual detector sensitive detector - without this the virtualdetector data products will not be created +physics.producers.g4run.SDConfig.enableSD : [ + virtualdetector, + STMDet +] + +# Explicitly disable common cuts for STM pileup generation +physics.producers.g4run.Mu2eG4CommonCut : {} + +# Optional debugging output - makes it very clear what is happening in GEANT # physics.producers.g4run.debug.trackingVerbosityLevel : 1 # physics.producers.g4run.debug.steppingVerbosityLevel : 1 -# copy over VD hits + +# Epilog includes #include "Production/JobConfig/common/MT.fcl" #include "Production/JobConfig/common/epilog.fcl" -#include "Production/JobConfig/pileup/epilog.fcl" +# #include "Production/JobConfig/pileup/epilog.fcl" # Note - this was present for the study in 51487, and has been removed for subsequent studies to help quantify if this cut impacts results diff --git a/JobConfig/pileup/STM/STMResampler1809.fcl b/JobConfig/pileup/STM/STMResampler1809.fcl new file mode 100644 index 00000000..60a5c973 --- /dev/null +++ b/JobConfig/pileup/STM/STMResampler1809.fcl @@ -0,0 +1,178 @@ +# Run Stage 2 of the STM simulation defined in docdb 51487 +# Re-sample the propagated TargetStopsCat datasets from the chosen virtual detector, and write out the events with SimParticles and StepPointMCs travelling through that virtual detector only +# Note - this is configured to run from VD101 only. +# Usage: +# - General modifications are not required for this file +# - To generate fcl files that use this file, follow up with Production/Scripts/STM/gen_STMResampler.sh +# - To change the GEANT verbosity, see the bottom of this file +# NOTE - When finalizing this script, there were some errors with the compression. I couldn't debug it and did not make time to run a separate simulation to propagate these changes. Debugging is left to the user. +# Original author: Yuri Oksuzian, 2019 +# Updated for MDC2020 (DetectorSteps): D. Brown +# Updated for STM studies: P. Plesniak + +# Offline includes +#include "Offline/Analyses/fcl/prolog.fcl" +#include "Offline/CommonMC/fcl/prolog.fcl" +#include "Offline/fcl/standardServices.fcl" +#include "Offline/STMMC/fcl/prolog.fcl" + +# Production includes +#include "Production/JobConfig/common/prolog.fcl" +#include "Production/JobConfig/pileup/prolog.fcl" +#include "Production/JobConfig/pileup/STM/prolog.fcl" + +process_name : STMResampler1809 + +source : { + module_type : EmptyEvent + maxEvents : @nil +} + +services : @local::Services.Sim +physics : { + producers : { + @table::Common.producers + @table::Pileup.producers + # TODO BEFORE NEXT CAMPAIGN - add the CompressPhysicalVolumes module here keeping the output from the FilterG4Out module label. + shiftStepsHPGe : { # Shift the steps to upstream of the HPGe absorber along the SSC aperture + module_type : ShiftVirtualDetectorStepPointMCs + StepPointMCsTag : @local::STMSimDataProducts.Stage2.ResampledStepPointMCs.TargetStopsCatDataset + VirtualDetectorID : @local::STMPileup.ShiftVD101Steps.VirtualDetectorID + InputRadius : @local::STMPileup.ShiftVD101Steps.InputRadius + OutputRadius : @local::STMPileup.ShiftVD101Steps.OutputRadius + InputX : @local::ComponentPositions.VD101.x + InputY : @local::ComponentPositions.VD101.y + InputZ : @local::ComponentPositions.VD101.z + OutputX : @local::STMPileup.ShiftVD101Steps.HPGeUpStr.x + OutputY : @local::STMPileup.ShiftVD101Steps.HPGeUpStr.y + OutputZ : @local::STMPileup.ShiftVD101Steps.HPGeUpStr.z + pdgID : @local::STMPileup.ShiftVD101Steps.pdgID + } + shiftStepsLaBr : { # Shift the steps to upstream of the LaBr SSC aperture + module_type : ShiftVirtualDetectorStepPointMCs + StepPointMCsTag : @local::STMSimDataProducts.Stage2.ResampledStepPointMCs.TargetStopsCatDataset + VirtualDetectorID : @local::STMPileup.ShiftVD101Steps.VirtualDetectorID + InputRadius : @local::STMPileup.ShiftVD101Steps.InputRadius + OutputRadius : @local::STMPileup.ShiftVD101Steps.OutputRadius + InputX : @local::ComponentPositions.VD101.x + InputY : @local::ComponentPositions.VD101.y + InputZ : @local::ComponentPositions.VD101.z + OutputX : @local::STMPileup.ShiftVD101Steps.LaBrUpStr.x + OutputY : @local::STMPileup.ShiftVD101Steps.LaBrUpStr.y + OutputZ : @local::STMPileup.ShiftVD101Steps.LaBrUpStr.z + pdgID : @local::STMPileup.ShiftVD101Steps.pdgID + } + compressSTMDet : { + # Creates "mu2e::StepPointMCs_compressSTMDet_virtualdetecctor_STMResampler", "mu2e::StepPointMCs_compressSTMDet_STMDet_STMResampler" and "mu2e::SimParticlemv_compressSTMDet__STMResampler" products from "mu2e::StepPointMCs_extractVirtualDetectorSteps_virtualdetecctor_STMResampler" products. + # These collections contain the StepPointMCs and SimParticles that pass through the selected virtual detector only, any other daughter particles are removed. + # Keeps SimParticles and StepPointMCs going through the selected virtual detector only. + module_type : CompressDetStepMCs + strawGasStepTag : @local::STMSimDataProducts.EmptyString + caloShowerStepTag : @local::STMSimDataProducts.EmptyString + surfaceStepTag : @local::STMSimDataProducts.EmptyString + crvStepTag : @local::STMSimDataProducts.EmptyString + simParticleTags : [ + @local::STMSimDataProducts.Stage2.GEANT.SimParticles + ] + debugLevel : 0 + stepPointMCTags : @local::STMSimDataProducts.Stage2.GEANT.StepPointMCs + compressionOptions : { + strawGasStepCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + caloShowerStepCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + crvStepCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + surfaceStepCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + simParticleCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + stepPointMCCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + keepNGenerations : @local::STMPileup.CompressionParameters.CompressionGenerations + mcTrajectoryCompressionLevel : @local::STMPileup.CompressionParameters.NoCompressionString + } + mcTrajectoryTag : @local::STMSimDataProducts.EmptyString + } + } + filters : { + @table::Common.filters + @table::Pileup.filters + @table::STMPileup.filters + } + analyzers : { + @table::Common.analyzers + countVirtualDetectorHits : { + # Runs a counter over the virtual detectors to keep track of hits + module_type : CountVirtualDetectorHits + stepPointMCsTag : @local::STMPileup.VirtualDetectorCounter.StepPointMCs + virtualDetectorIDs : @local::STMPileup.VirtualDetectorCounter.VirtualDetectorIDs + } + } + HPGePath : [ + @sequence::STMPileup.STMResamplerSequenceTargetStopsCatDataset, + shiftStepsHPGe, + @sequence::Common.g4Sequence, + compressSTMDet + ] + LaBrPath : [ + @sequence::STMPileup.STMResamplerSequenceTargetStopsCatDataset, + shiftStepsLaBr, + @sequence::Common.g4Sequence, + compressSTMDet + ] + trigger_paths : [ + HPGePath + # @nil # Populate me! + ] + outPathCompressed : [ + genCountLogger, + countVirtualDetectorHits, + CompressedOutput + ] + end_paths : [ + outPathCompressed + ] +} + +outputs : { + CompressedOutput : { + module_type : RootOutput + outputCommands : @local::STMSimDataProducts.STMResamplerKeptProducts + SelectEvents : [ + HPGePath + # @nil # Populate me! + ] + fileName : @local::STMPileup.SimulationOutputFilenames.Stage2 + } +} + +# GEANT variables +# Point Mu2eG4 to input data +physics.producers.g4run.inputs : { + primaryType : @local::STMSimDataProducts.Stage2.InputType + primaryTag : @local::STMSimDataProducts.Stage2.InputTag.HPGe # @nil # Populate me! + inputMCTrajectories : @local::STMSimDataProducts.EmptyString + simStageOverride : 2 + inputPhysVolumeMultiInfo : @local::STMSimDataProducts.Stage2.InputPhysVolumeMultiInfo + updateEventLevelVolumeInfos : { + input : @local::STMSimDataProducts.Stage2.UpdateEventLevelVolumeInfos.Input + outInstance : @local::STMSimDataProducts.Stage2.UpdateEventLevelVolumeInfos.OutInstance + } +} + +# Specify pre-simulated hits for beam resampling +physics.producers.g4run.SDConfig.preSimulatedHits : @local::STMSimDataProducts.Stage2.PreSimulatedData.TargetStopsCatDataset + +# Enable the virtual detector sensitive detector - without this the virtualdetector data products will not be created +physics.producers.g4run.SDConfig.enableSD : [ + virtualdetector, + STMDet +] + +# Explicitly disable common cuts for STM pileup generation +physics.producers.g4run.Mu2eG4CommonCut : {} + +# Optional debugging output - makes it very clear what is happening in GEANT +# physics.producers.g4run.debug.trackingVerbosityLevel : 1 +# physics.producers.g4run.debug.steppingVerbosityLevel : 1 + + +# Epilog includes +#include "Production/JobConfig/common/MT.fcl" +#include "Production/JobConfig/common/epilog.fcl" +# #include "Production/JobConfig/pileup/epilog.fcl" # Note - this was present for the study in 51487, and has been removed for subsequent studies to help quantify if this cut impacts results diff --git a/JobConfig/pileup/STM/prolog.fcl b/JobConfig/pileup/STM/prolog.fcl index 84217485..e09caa93 100644 --- a/JobConfig/pileup/STM/prolog.fcl +++ b/JobConfig/pileup/STM/prolog.fcl @@ -1,55 +1,301 @@ -# -# Prolog to create pileup particle steps for mixing -# +# STM simulation prolog +# Simulation defined in 51487 +# Original author: Pawel Plesniak + #include "Offline/TrackerMC/fcl/prolog.fcl" #include "Offline/CaloMC/fcl/prolog.fcl" #include "Offline/CRVResponse/fcl/prolog.fcl" #include "Offline/Filters/fcl/prolog.fcl" #include "Offline/Compression/fcl/prolog.fcl" -# + BEGIN_PROLOG -Pileup: { +# Define the STM simulation data products for both simulation stages +# It is expected that this will not change +STMSimDataProducts : { + # Define general variables + EmptyString : "" + + # Define data products generated in the two simulation stages + # NOTE - there are two general simulation TYPES for each stage + # - BeamCatDatasets - propagation of the EleBeamCat and MuBeamCat datasets + # - TargetStopsCatDataset - propagation of the TargetStopCat dataset (for 1809 keV photons) + Stage1 : { + # Define global Mu2eG4 input data product type + InputType : { + BeamCatDatasets : "StepPoints" + TargetStopsCatDataset : "StageParticles" + } + + # Define the pre-simulated SD hits for input to Mu2eG4 + PreSimulatedData : { + BeamCatDatasets : [ + "beamResampler:virtualdetector" + ] + TargetStopsCatDataset : [ + "TargetStopResampler:virtualdetector" + ] + } + + # Define the output data products from Stage 1 Mu2eG4 run + GEANT : { + StepPointMCs : "g4run:virtualdetector" + SimParticles : "g4run:" + } + + # Define the input data products tag that Mu2eG4 resamples from + InputTag : { + BeamCatDatasets : "beamResampler:Beam" + TargetStopsCatDataset : "generate" + } + + # Define the PhysicalVolumeInfo data products used by Mu2eG4 (defines what materials the various particles interacted with) + InputPhysVolumeMultiInfo : { + BeamCatDatasets : "beamResampler" + TargetStopsCatDataset : "TargetStopResampler" + } + + # Define the VolumeInfo data products that Mu2eG4 updates, and on what output product level this occurs at (OutInstance) + UpdateEventLevelVolumeInfos : { + Input : { + BeamCatDatasets : "beamResampler:eventlevel" + TargetStopsCatDataset : "TargetStopResampler:eventlevel" + } + OutInstance : "eventlevel" + } + + # Define the extracted virtual detector StepPointMCs data product, which selects which events have interesting steps that we want to keep for output + ExtractedStepPointMCs : "extractVirtualDetectorSteps:virtualdetector" + + # Define the compressed output data products + CompressedOutput : { + StepPointMCs : "compressDetStepMCsSTM:virtualdetector" + SimParticles : "compressDetStepMCsSTM:" + } + } + + Stage2 : { + # Define global Mu2eG4 input data product type + InputType : "StepPoints" + + # Define the pre-simulated SD hits for input to Mu2eG4 + PreSimulatedData : { + BeamCatDatasets : [ + "stmResamplerBeamCatDatasets:virtualdetector" + ] + TargetStopsCatDataset : [ + "stmResamplerTargetStopsCatDataset:virtualdetector" + ] + } + + # Define the input data products tag that Mu2eG4 resamples from + ResampledStepPointMCs : { + BeamCatDatasets : "stmResamplerBeamCatDatasets:virtualdetector" + TargetStopsCatDataset : "stmResamplerTargetStopsCatDataset:virtualdetector" + } + + # Define the input data products tag that Mu2eG4 resamples from + InputTag : { + HPGe : "shiftStepsHPGe:" + LaBr : "shiftStepsLaBr:" + } + + # Define the output data products from Stage 2 Mu2eG4 run + GEANT : { + StepPointMCs : [ + "g4run:STMDet", + "g4run:virtualdetector" + ] + SimParticles : "g4run:" + } + + # Define the PhysicalVolumeInfo data products used by Mu2eG4 (defines what materials the various particles interacted with) + InputPhysVolumeMultiInfo : "stmResamplerBeamCatDatasets" + + # Define the VolumeInfo data products that Mu2eG4 updates, and on what output product level this occurs at (OutInstance) + UpdateEventLevelVolumeInfos : { + Input : "stmResamplerBeamCatDatasets:eventlevel" + OutInstance : "eventlevel" + } + + # Define the mixing modules used for resampling + Resampler : { + InputType : "g4run" + SimParticleMixer : { + mixingMap : [ + [ + "compressDetStepMCsSTM", + "" + ] + ] + } + StepPointMCMixer : { + mixingMap : [ + [ + "compressDetStepMCsSTM:virtualdetector", + ":" + ] + ] + } + } + + # Define the simulated time offset data product + SimulatedTimeOffset : "protonTimeOffset" + + # Define the extracted virtual detector StepPointMCs data product, which selects which events have interesting steps that we want to keep for output + ExtractedStepPointMCs : "extractVirtualDetectorSteps:virtualdetector" + + # Define the compressed output data products + CompressedOutput : { + StepPointMCs : { + Virtualdetector : "compressDetStepMCs:virtualdetector" + Detector : "compressDetStepMCs:STMDet" + } + SimParticles : "compressDetStepMCs:" + } + } + + # Stage 1 products to keep + # Note - the process name fields are set to wildcards as the process name may change depending on the job configuration, supporting both BeamCatDatasets and TargetStopsCatDataset types + BeamToVDKeptProducts : [ + "drop *_*_*_*", + "keep art::EventIDs_*_*_*", + "keep mu2e::GenParticles_*_*_*", + "keep mu2e::GenEventCount_*_*_*", + "keep mu2e::StepPointMCs_compressDetStepMCsSTM_*_*", + "keep mu2e::SimParticlemv_compressDetStepMCsSTM_*_*", + "keep mu2e::SimTimeOffset_*_*_*", # TODO - WHY? + "keep mu2e::PhysicalVolumeInfomvs_g4run_*_*", + "keep mu2e::StatusG4_*_*_*" + ] + + # Stage 2 products to keep + # Note - the process name fields are set to wildcards as the process name may change depending on the job configuration, supporting both BeamCatDatasets and TargetStopsCatDataset types + STMResamplerKeptProducts : [ + "drop *_*_*_*", + "keep mu2e::GenEventCount_*_*_*", + "keep art::EventIDs_*_*_*", + "keep mu2e::StepPointMCs_compressSTMDet_*_*", + "keep mu2e::SimParticlemv_compressSTMDet_*_*", + "keep mu2e::SimTimeOffset_protonTimeOffset_*_*", # TODO - WHY? + "keep mu2e::PhysicalVolumeInfomvs_*_*_*" + ] +} + +# Define the STM pileup configuration, pointing to the STMSimDataProducts defined above wherever possible +# It is expected that if there are changes in the simulation framework, this is the place in which the variables will be changed. +STMPileup : { + # Generate the proton time offset for STM simulation producers : { protonTimeOffset : @local::CommonMC.protonTimeOffset } + # Define the STM resampler filters for both dataset types filters : { - stmResampler: { - module_type: ResamplingMixer - fileNames: @nil - readMode: "sequential" # randomNoReplace - wrapFiles: true + # Resampler for EleBemaCat and MuBeamCat datasets + stmResamplerBeamCatDatasets: { + module_type : ResamplingMixer + fileNames : @nil + readMode : "sequential" # Expect to read the same input data products over and over again, and sequential read mode is faster than randonNoReplace + wrapFiles : true mu2e: { writeEventIDs : true MaxEventsToSkip: @nil debugLevel : 1 products: { - genParticleMixer: { mixingMap: [ [ "compressDetStepMCsSTM", "" ] ] } - simParticleMixer: { mixingMap: [ [ "compressDetStepMCsSTM", "" ] ] } - stepPointMCMixer: { mixingMap: [ [ "compressDetStepMCsSTM:", ":" ] ] } # virtualdetector - simTimeOffset : "protonTimeOffset" - volumeInfoMixer: { - srInput: "g4run" - evtOutInstanceName: "eventlevel" + genParticleMixer : @local::STMSimDataProducts.Stage2.Resampler.SimParticleMixer + simParticleMixer : @local::STMSimDataProducts.Stage2.Resampler.SimParticleMixer + stepPointMCMixer : @local::STMSimDataProducts.Stage2.Resampler.StepPointMCMixer + simTimeOffset : @local::STMSimDataProducts.Stage2.SimulatedTimeOffset + volumeInfoMixer : { + srInput : @local::STMSimDataProducts.Stage2.Resampler.InputType + evtOutInstanceName : @local::STMSimDataProducts.Stage2.UpdateEventLevelVolumeInfos.OutInstance + } + } + } + } + + # Resampler for TargetStopCat dataset (for generation 1809 keV photons) + stmResamplerTargetStopsCatDataset : { + module_type : ResamplingMixer + fileNames : @nil + readMode : "randomNoReplace" # Different from the above as it is expected that we do not read all the events in the Stage 2 resampling + wrapFiles : true + mu2e: { + writeEventIDs : true + MaxEventsToSkip: @nil + debugLevel : 1 + products: { + genParticleMixer : @local::STMSimDataProducts.Stage2.Resampler.SimParticleMixer + simParticleMixer : @local::STMSimDataProducts.Stage2.Resampler.SimParticleMixer + stepPointMCMixer : @local::STMSimDataProducts.Stage2.Resampler.StepPointMCMixer + simTimeOffset : @local::STMSimDataProducts.Stage2.SimulatedTimeOffset + volumeInfoMixer : { + srInput : @local::STMSimDataProducts.Stage2.Resampler.InputType + evtOutInstanceName : @local::STMSimDataProducts.Stage2.UpdateEventLevelVolumeInfos.OutInstance } } } } } - BeamToVDKeptProducts : [ - "keep art::EventIDs_*_*_*", - "keep mu2e::GenParticles_*_*_*", - "keep mu2e::GenEventCount_*_*_*", - "keep mu2e::StepPointMCs_compressDetStepMCsSTM_*_*", - "keep mu2e::SimParticlemv_compressDetStepMCsSTM_*_*", - "keep mu2e::SimTimeOffset_*_*_*", - "keep mu2e::PhysicalVolumeInfomvs_g4run_*_*", - "keep mu2e::StatusG4_*_*_*" + # Simulation data efficiency module configurations + # We are not interested in any of the standard data products aside from steps in virtual detectors and the STM detector. + # At the time of writing, the STMDet SensitiveDetector contains BOTH the HPGe and LaBr detectors. + ResamplingProducer : { + StepPointMCsTag : @local::STMSimDataProducts.Stage1.GEANT.StepPointMCs + VirtualDetectorID : 101 + } + ResamplingFilterStepPointMCs : @local::STMSimDataProducts.Stage1.ExtractedStepPointMCs + CompressionParameters : { + NoCompressionString : "noCompression" + CompressionGenerations : -1 + } + + # Simulation data counter module configuration + VirtualDetectorCounter : { + StepPointMCs : @local::STMSimDataProducts.Stage1.GEANT.StepPointMCs + VirtualDetectorIDs : [10, 13, 15, 86, 115, 100, 101, 88, 89, 90] + } + + # Parameters for shifting VD101 steps to just upstream of the STM shielding house absorbers () + ShiftVD101Steps : { + StepPointMCsTag : @local::STMSimDataProducts.Stage1.ExtractedStepPointMCs + VirtualDetectorID : 101 + InputRadius : 200 # VD101 aperture radius + OutputRadius : 3.98942280401 # SSC aperture radius + # Position just upstream of the STM shielding house absorber centered on the HPGe SSC aperture [mm] + HPGeUpStr : { + x : -3944.6 + y : 0.0 + z : 39906.0 + } + # Position just upstream of the STM shielding house absorber centered on the LaBr SSC aperture [mm] + LaBrUpStr : { + x : -3863.4 + y : 0.0 + z : 40300.9 + } + pdgID : 0 + } + + # Output filenames for the two simulation stages + SimulationOutputFilenames : { + Stage1 : "dts.owner.BeamToVD.version.sequencer.art" + Stage2 : "dts.owner.STMDet.version.sequencer.art" + } + + # Define the STM resampler sequences + STMResamplerSequenceBeamCatDatasets : [ + genCounter, + protonTimeOffset, + stmResamplerBeamCatDatasets + ] + STMResamplerSequenceTargetStopsCatDataset : [ + genCounter, + protonTimeOffset, + stmResamplerTargetStopsCatDataset ] - # define some common sequences - stmResamplerSequence : [genCounter, protonTimeOffset, stmResampler] } END_PROLOG \ No newline at end of file diff --git a/Scripts/STM/CountSTMMixedEvents.sh b/Scripts/STM/Analysis/CountSTMMixedEvents.sh similarity index 100% rename from Scripts/STM/CountSTMMixedEvents.sh rename to Scripts/STM/Analysis/CountSTMMixedEvents.sh diff --git a/Scripts/STM/Analysis/gen_ROOTAnalysisDump.sh b/Scripts/STM/Analysis/gen_ROOTAnalysisDump.sh new file mode 100644 index 00000000..d9e38b60 --- /dev/null +++ b/Scripts/STM/Analysis/gen_ROOTAnalysisDump.sh @@ -0,0 +1,180 @@ +# Generates the ROOT dump fcl files for the EleBeamCat and MuBeamCat datasets +# This requires a file containing the list of outut files generated from using gen_BeamToVD.sh and gen_BeamToVD1809.sh +# For the study defined in docdb 51487, the input files are: +# S1E1.txt - Stage 1 EleBeamCat (found in dataset sim.plesniak.Stage1.Ele1.art) +# S1E2.txt - Stage 1 EleBeamCat (found in dataset sim.plesniak.Stage1.Ele2.art) +# S1M1.txt - Stage 1 MuBeamCat (found in dataset sim.plesniak.Stage1.Mu1.art) +# S1M2.txt - Stage 1 MuBeamCat (found in dataset sim.plesniak.Stage1.Mu2.art) +# S1M3.txt - Stage 1 MuBeamCat (found in dataset sim.plesniak.Stage1.Mu3.art) +# S11809.txt - Stage 1 1809 TargetStopsCat (found in dataset dts.plesniak.Stage1.1809.art) - note there was a problem with the upload, and the exact statistics used to generate these files is unknown +# etc... +# This is simply a driver code, which should be configured in Offline/STMMC/fcl/ROOTAnalysisDump.fcl +# Usage +# - Generate the input files using gen_BeamToVD.sh and gen_BeamToVD1809.sh +# - Edit Offline/STMMC/fcl/ROOTAnalysisDump.fcl to select which data you want to dump to ROOT TTrees +# - Run this script: ./gen_ROOTAnalysisDump.sh +# Original author: Pawel Plesniak + +# Prepare the fcl file that contains the driver code to trace the SimParticles +if [ -f tmp.fcl ]; then + rm -f tmp.fcl +fi +echo '#include "Production/JobConfig/pileup/STM/SignalParticleTrace.fcl"' > tmp.fcl + +# Cleanup any previous script runs +rm -rf 000 001 002 003 004 005 006 007 008 009 +rm -rf S1E1_00* S1E2_00* S1M1_00* S1M2_00* S1M3_00* S11809_00* S2E1_00* S2E2_00* S2M1_00* S2M2_00* + + +# Generate the Stage 1 EleBeamCat tracing fcl files +nFiles=`wc -l S1E1.txt| cut -d ' ' -f1` +echo "Found $nFiles S1E1 files" +generate_fcl --dsconf=MDC2020p --description=S1E1 --embed tmp.fcl --inputs S1E1.txt --merge-factor 1000 +echo "Generated `ls -1 000/*.fcl | wc -l` jobs in S1E1_000" + +for dirname in 000 001 002 003 004 005 006 007 008 009; do + if test -d $dirname; then + echo "found dir $dirname" + rm -rf S1E1_$dirname + mv $dirname S1E1_$dirname + tmp=`ls -1 S1E1_$dirname/*.fcl | wc -l` + fi +done + +nFiles=`wc -l S1E2.txt| cut -d ' ' -f1` +echo "Found $nFiles S1E2 files" +generate_fcl --dsconf=MDC2020p --description=S1E2 --embed tmp.fcl --inputs S1E2.txt --merge-factor 1000 +echo "Generated `ls -1 000/*.fcl | wc -l` jobs in S1E2_000" + +for dirname in 000 001 002 003 004 005 006 007 008 009; do + if test -d $dirname; then + echo "found dir $dirname" + rm -rf S1E2_$dirname + mv $dirname S1E2_$dirname + tmp=`ls -1 S1E2_$dirname/*.fcl | wc -l` + fi +done + + +# Generate the Stage 1 MuBeamCat tracing fcl files +nFiles=`wc -l S1M1.txt| cut -d ' ' -f1` +echo "Found $nFiles S1M1 files" +generate_fcl --dsconf=MDC2020p --description=S1M1 --embed tmp.fcl --inputs S1M1.txt --merge-factor 1000 +echo "Generated `ls -1 000/*.fcl | wc -l` jobs in S1M1_000" + +for dirname in 000 001 002 003 004 005 006 007 008 009; do + if test -d $dirname; then + echo "found dir $dirname" + rm -rf S1M1_$dirname + mv $dirname S1M1_$dirname + tmp=`ls -1 S1M1_$dirname/*.fcl | wc -l` + fi +done + +nFiles=`wc -l S1M2.txt| cut -d ' ' -f1` +echo "Found $nFiles S1M2 files" +generate_fcl --dsconf=MDC2020p --description=S1M2 --embed tmp.fcl --inputs S1M2.txt --merge-factor 1000 +echo "Generated `ls -1 000/*.fcl | wc -l` jobs in S1M2_000" + +for dirname in 000 001 002 003 004 005 006 007 008 009; do + if test -d $dirname; then + echo "found dir $dirname" + rm -rf S1M2_$dirname + mv $dirname S1M2_$dirname + tmp=`ls -1 S1M2_$dirname/*.fcl | wc -l` + fi +done + +nFiles=`wc -l S1M3.txt| cut -d ' ' -f1` +echo "Found $nFiles S1M3 files" +generate_fcl --dsconf=MDC2020p --description=S1M3 --embed tmp.fcl --inputs S1M3.txt --merge-factor 1000 +echo "Generated `ls -1 000/*.fcl | wc -l` jobs in S1M3_000" + +for dirname in 000 001 002 003 004 005 006 007 008 009; do + if test -d $dirname; then + echo "found dir $dirname" + rm -rf S1M3_$dirname + mv $dirname S1M3_$dirname + tmp=`ls -1 S1M3_$dirname/*.fcl | wc -l` + fi +done + +# Generate the Stage 1 1809 TargetStopsCat tracing fcl files +nFiles=`wc -l S11809.txt| cut -d ' ' -f1` +echo "Found $nFiles S11809 files" +generate_fcl --dsconf=MDC2020p --description=S11809 --embed tmp.fcl --inputs S11809.txt --merge-factor 1000 +echo "Generated `ls -1 000/*.fcl | wc -l` jobs in S11809_000" + +for dirname in 000 001 002 003 004 005 006 007 008 009; do + if test -d $dirname; then + echo "found dir $dirname" + rm -rf S11809_$dirname + mv $dirname S11809_$dirname + tmp=`ls -1 S11809_$dirname/*.fcl | wc -l` + fi +done + +# Generate the Stage 2 EleBeamCat tracing fcl files +nFiles=`wc -l S2E1.txt| cut -d ' ' -f1` +echo "Found $nFiles S2E1 files" +generate_fcl --dsconf=MDC2020p --description=S2E1 --embed tmp.fcl --inputs S2E1.txt --merge-factor 1000 +echo "Generated `ls -1 000/*.fcl | wc -l` jobs in S2E1_000" + +for dirname in 000 001 002 003 004 005 006 007 008 009; do + if test -d $dirname; then + echo "found dir $dirname" + rm -rf S2E1_$dirname + mv $dirname S2E1_$dirname + tmp=`ls -1 S2E1_$dirname/*.fcl | wc -l` + fi +done + +nFiles=`wc -l S2E2.txt| cut -d ' ' -f1` +echo "Found $nFiles S2E2 files" +generate_fcl --dsconf=MDC2020p --description=S2E2 --embed tmp.fcl --inputs S2E2.txt --merge-factor 1000 +echo "Generated `ls -1 000/*.fcl | wc -l` jobs in S2E2_000" + +for dirname in 000 001 002 003 004 005 006 007 008 009; do + if test -d $dirname; then + echo "found dir $dirname" + rm -rf S2E2_$dirname + mv $dirname S2E2_$dirname + tmp=`ls -1 S2E2_$dirname/*.fcl | wc -l` + fi +done + +# Generate the Stage 2 MuBeamCat tracing fcl files +nFiles=`wc -l S2M1.txt| cut -d ' ' -f1` +echo "Found $nFiles S2M1 files" +generate_fcl --dsconf=MDC2020p --description=S2M1 --embed tmp.fcl --inputs S2M1.txt --merge-factor 1000 +echo "Generated `ls -1 000/*.fcl | wc -l` jobs in S2M1_000" + +for dirname in 000 001 002 003 004 005 006 007 008 009; do + if test -d $dirname; then + echo "found dir $dirname" + rm -rf S2M1_$dirname + mv $dirname S2M1_$dirname + tmp=`ls -1 S2M1_$dirname/*.fcl | wc -l` + fi +done + +nFiles=`wc -l S2M2.txt| cut -d ' ' -f1` +echo "Found $nFiles S2M2 files" +generate_fcl --dsconf=MDC2020p --description=S2M2 --embed tmp.fcl --inputs S2M2.txt --merge-factor 1000 +echo "Generated `ls -1 000/*.fcl | wc -l` jobs in S2M2_000" + +for dirname in 000 001 002 003 004 005 006 007 008 009; do + if test -d $dirname; then + echo "found dir $dirname" + rm -rf S2M2_$dirname + mv $dirname S2M2_$dirname + tmp=`ls -1 S2M2_$dirname/*.fcl | wc -l` + fi +done + + + +# Cleanup +echo "Removing temporary files" +rm -f tmp.fcl +echo "Finished" diff --git a/Scripts/STM/gen_STMCat.sh b/Scripts/STM/Analysis/gen_STMCat.sh similarity index 100% rename from Scripts/STM/gen_STMCat.sh rename to Scripts/STM/Analysis/gen_STMCat.sh diff --git a/Scripts/STM/gen_STMHPGeDigitization.sh b/Scripts/STM/Analysis/gen_STMHPGeDigitization.sh similarity index 100% rename from Scripts/STM/gen_STMHPGeDigitization.sh rename to Scripts/STM/Analysis/gen_STMHPGeDigitization.sh diff --git a/Scripts/STM/gen_STMMix.sh b/Scripts/STM/Analysis/gen_STMMix.sh similarity index 100% rename from Scripts/STM/gen_STMMix.sh rename to Scripts/STM/Analysis/gen_STMMix.sh diff --git a/Scripts/STM/gen_STMMixedEventsCounter.sh b/Scripts/STM/Analysis/gen_STMMixedEventsCounter.sh similarity index 100% rename from Scripts/STM/gen_STMMixedEventsCounter.sh rename to Scripts/STM/Analysis/gen_STMMixedEventsCounter.sh diff --git a/Scripts/STM/gen_BeamToVD.sh b/Scripts/STM/G4/gen_BeamToVD.sh similarity index 57% rename from Scripts/STM/gen_BeamToVD.sh rename to Scripts/STM/G4/gen_BeamToVD.sh index 4b9332e7..bd8e18bf 100755 --- a/Scripts/STM/gen_BeamToVD.sh +++ b/Scripts/STM/G4/gen_BeamToVD.sh @@ -1,16 +1,18 @@ #!/usr/bin/bash # Generate fcl files for BeamToVD.fcl # Generates two sets of fcl files found in directories Ele_00X and Mu_00X +# Also generates a directory for seeds used to generate these files # Stores the generated seeds in directory BeamToVDSeeds -# Pawel Plesniak - -# $1 is the production (ie MDC2020) -# $2 is the input production version -# $3 is the output production version -# $4 is the number of events per job for electrons -# $5 is the number of jobs for electrons -# $6 is the number of events per job for muons -# $7 is the number of jobs for muons +# Usage - Run this command as a shell script with the following arguments +# - $1 is the production (ie MDC2020) +# - $2 is the input production version +# - $3 is the output production version +# - $4 is the number of events per job for electrons +# - $5 is the number of jobs for electrons +# - $6 is the number of events per job for muons +# - $7 is the number of jobs for muons +# Note - if generating a large simulation, it is recommended to make a copy of the input datasets (EleBeamCat and MuBeamCat) on resilient to distribute the file load, and use the commented out code +# Adapted by: Pawel Plesniak # Validate the number of arguments if [[ ${7} == "" ]]; then @@ -30,9 +32,18 @@ samweb list-file-locations --schema=root --defname="$eleDataset" | cut -f1 > El nEleFiles=`samCountFiles.sh $eleDataset` nEleEvts=`samCountEvents.sh $eleDataset` nEleSkip=$((nEleEvts/nEleFiles)) +# For large simulation studies: +# - Copy the EleBeamCat files to resilient, +# - Make a file containing a newline separated list of these files called EleBeamCat.txt +# - Comment out the above ten lines +# - Uncomment the following three lines to use a fixed number of events to skip +# - Populate the variable nEleEvts below using a tool like eventCount on each input file or samCountEvents.sh on the initial dataset +# nEleFiles=wc -l < EleBeamCat.txt +# nEleEvts=LISTTHENUMBEROFEVENTSHERE +# nEleSkip=$((nEleEvts/nEleFiles)) echo "Electrons: found $nEleEvts events in $nEleFiles files, skipping max of $nEleSkip events per job" -# Write the base propagation script for electrons +# Write the template fcl if [ -f tmp.fcl ]; then rm -f tmp.fcl fi @@ -43,13 +54,15 @@ echo physics.filters.beamResampler.mu2e.MaxEventsToSkip: ${nEleSkip} >> tmp.fcl generate_fcl --dsconf=$1$3 --dsowner=$USER --run-number=1204 --description=BeamToVDEle --events-per-job=$4 --njobs=$5 \ --embed tmp.fcl --auxinput=1:physics.filters.beamResampler.fileNames:EleBeamCat.txt -# Write the files to the correct directories +# Move the generated fcl files (in their directories) to a uniquely identifiable area for dirname in 000 001 002 003 004 005 006 007 008 009; do if test -d $dirname; then rm -rf Ele_$dirname mv $dirname Ele_$dirname fi done + +# Cleanup rm -f tmp.fcl @@ -64,15 +77,26 @@ samweb list-file-locations --schema=root --defname="$muDataset" | cut -f1 > MuB nMuFiles=`samCountFiles.sh $muDataset` nMuEvts=`samCountEvents.sh $muDataset` nMuSkip=$((nMuEvts/nMuFiles)) +# For large simulation studies: +# - Copy the MuBeamCat files to resilient, +# - Make a file containing a newline separated list of these files called MuBeamCat.txt +# - Comment out the above ten lines +# - Uncomment the following three lines to use a fixed number of events to skip +# - Populate the variable nMuEvts below using a tool like eventCount on each input file or samCountEvents.sh on the initial dataset +# nEleFiles=wc -l < MuBeamCat.txt +# nEleEvts=LISTTHENUMBEROFEVENTSHERE +# nEleSkip=$((nEleEvts/nEleFiles)) echo "Muons: found $nMuEvts events in $nMuFiles files, skipping max of $nMuSkip events per job" # Write the base propagation script for muons echo '#include "Production/JobConfig/pileup/STM/BeamToVD.fcl"' >> tmp.fcl echo physics.filters.beamResampler.mu2e.MaxEventsToSkip: ${nMuSkip} >> tmp.fcl -# Generate the electrons fcl files -generate_fcl --dsconf=$1$3 --dsowner=$USER --run-number=1205 --description=BeamToVDMu --events-per-job=$6 --njobs=$7 \ + +# Generate the muons fcl files +generate_fcl --dsconf=$1$3 --dsowner=$USER --run-number=1204 --description=BeamToVDMu --events-per-job=$6 --njobs=$7 \ --embed tmp.fcl --auxinput=1:physics.filters.beamResampler.fileNames:MuBeamCat.txt -# Write the files to the correct directories + +# Move the generated fcl files (in their directories) to a uniquely identifiable area for dirname in 000 001 002 003 004 005 006 007 008 009; do if test -d $dirname; then rm -rf Mu_$dirname diff --git a/Scripts/STM/gen_BeamToVD1809.sh b/Scripts/STM/G4/gen_BeamToVD1809.sh similarity index 55% rename from Scripts/STM/gen_BeamToVD1809.sh rename to Scripts/STM/G4/gen_BeamToVD1809.sh index a1b08283..ff3a211b 100755 --- a/Scripts/STM/gen_BeamToVD1809.sh +++ b/Scripts/STM/G4/gen_BeamToVD1809.sh @@ -1,14 +1,16 @@ #!/usr/bin/bash # Generate fcl files for BeamToVD1809.fcl -# Generates two sets of fcl files found in directories 1809_00X +# Generates a sets of fcl files found in directories 1809_00X +# Also generates a directory for seeds used to generate these files # Stores the generated seeds in directory BeamToVD1809Seeds -# Pawel Plesniak - -# $1 is the production (ie MDC2020) -# $2 is the input production version -# $3 is the output production version -# $4 is the number of events per job -# $5 is the number of jobs +# Usage - Run this command as a shell script with the following arguments +# - $1 is the production (ie MDC2020) +# - $2 is the input production version +# - $3 is the output production version +# - $4 is the number of events per job +# - $5 is the number of jobs +# Note - if generating a large simulation, it is recommended to make a copy of the input dataset (TargetStopsCat) on resilient to distribute the file load, and use the commented out code +# Adapted by: Pawel Plesniak # Validate the number of arguments if [[ ${5} == "" ]]; then @@ -17,10 +19,10 @@ if [[ ${5} == "" ]]; then fi -# Generate the dataset list for electrons +# Generate the dataset list for target stop positions muStopDataset=sim.mu2e.TargetStopsCat.$1$2.art echo $eleDataset -if [ -f EleBeamCat.txt ]; then +if [ -f TargetStopsCat.txt ]; then rm -f TargetStopsCat.txt fi # Generate a list of all the staged EleBeamCat files and count the events @@ -28,6 +30,15 @@ samweb list-file-locations --schema=root --defname="$muStopDataset" | cut -f1 > nFiles=`samCountFiles.sh $muStopDataset` nEvts=`samCountEvents.sh $muStopDataset` nSkip=$((nEvts/nFiles)) +# For large simulation studies: +# - Copy the TargetStops files to resilient, +# - Make a file containing a newline separated list of these files called TargetStopsCat.txt +# - Comment out the above ten lines +# - Uncomment the following three lines to use a fixed number of events to skip +# - Populate the variable nEleEvts below using a tool like eventCount on each input file or samCountEvents.sh on the initial dataset +# nFiles=wc -l < TargetStopsCat.txt +# nEvts=LISTTHENUMBEROFEVENTSHERE +# nSkip=$((nEleEvts/nEleFiles)) echo "Target stops: found $nEvts events in $nFiles files, skipping max of $nSkip events per job" # Write the base propagation script for electrons @@ -38,7 +49,7 @@ echo '#include "Production/JobConfig/pileup/STM/BeamToVD1809.fcl"' >> tmp.fcl echo physics.filters.TargetStopResampler.mu2e.MaxEventsToSkip: ${nSkip} >> tmp.fcl # Generate the electrons fcl files -generate_fcl --dsconf=$1$3 --dsowner=$USER --run-number=1206 --description=BeamToVD1809 --events-per-job=$4 --njobs=$5 \ +generate_fcl --dsconf=$1$3 --dsowner=$USER --run-number=1204 --description=BeamToVD1809 --events-per-job=$4 --njobs=$5 \ --embed tmp.fcl --auxinput=1:physics.filters.TargetStopResampler.fileNames:TargetStopsCat.txt # Write the files to the correct directories diff --git a/Scripts/STM/G4/gen_STMResampler.sh b/Scripts/STM/G4/gen_STMResampler.sh new file mode 100755 index 00000000..20da88d9 --- /dev/null +++ b/Scripts/STM/G4/gen_STMResampler.sh @@ -0,0 +1,129 @@ +#!/usr/bin/bash +# Generate fcl files for resampling the hits generated with BeamToVD.fcl (both from EleBeamCat and MuBeamCat) +# Generates a sets of fcl files found in directories STMResampler_00X +# Usage - Run this command as a shell script with the following arguments +# - $1 is the production (ie MDC2020) +# - $2 is the input production version +# - $3 is the output production version +# - $4 is the number of jobs +# - $5 is the number of jobs +# - $6 is the project name of the BeamToVD.fcl grid job. If not given, then it is assumed that the text file containing all the input datasets +# are listed in a file called STMDatasetList.txt with a single line at the end containing the number of events in the named STMDatasetList.txt. +# This works under the assumption that all jobs in the output directory are associated with the BeamToVD.fcl grid job +# Original author: Pawel Plesniak + +# Check all arguments are present +if [[ ${5} == "" ]]; then + echo "Missing arguments!" + return -1 +fi + +# TODO BEFORE NEXT CAMPAIGN - rewrite this to use the SAM tools samCountFiles.sh and samCountEvents.sh +# Create the input dataset list STMDatasetList.txt +if [[ ${6} != "" ]]; then + # Setup path to job path + jobDir="/pnfs/mu2e/scratch/users/"$USER"/workflow/"$6"/outstage/*/*/*/*.art" + + # Remove the existing file list + echo "Generating STMDatasetList.txt" + if [ -f STMDatasetList.txt ]; then + echo "Removing pre-existing STMDatasetList.txt" + rm STMDatasetList.txt; + fi + + # Generate the new file list + echo "Finding all the input datasets" + find $jobDir -type f -name "*.art" > STMDatasetList.txt; + + # Check that any files are found + nFiles=$(wc -c < "STMDatasetList.txt") + if [[ "$nFiles" -eq 0 ]]; then + echo "Path passed is empty, validate that the constructed path $jobDir is correct." + fi + + # Count the number of events + echo "Counting the number of events in the given path. Note - this is likely to take a few mins especially if there are a lot of files" + tail=`mu2e -c Offline/Print/fcl/count.fcl -S STMDatasetList.txt | tail -n 30 | grep "Event records" | xargs` + tailArray=($tail) + nEvents=${tailArray[0]} + + # Append the number of events to the file + echo ${nEvents} >> STMDatasetList.txt + echo "Finished generating STMDatasetList.txt" +else + echo "Using existing STMDatasetList.txt" + + # Check if the file with the list of data files and the total number of events on the last line exists + if [ ! -f STMDatasetList.txt ]; then + echo "No dataset list file called STMDatasetList.txt, exiting" + return + fi + + # Get the number of events from the last line of the file + nEvents=`tail -n 1 STMDatasetList.txt | xargs` + + # Check that there are events present + if [[ "$nEvents" -eq 0 ]]; then + echo "File indicates no events." + fi + + # Check if the last line is a number + if [[ ! $nEvents =~ ^[-+]?[0-9]+$ ]]; then + echo "Passed entry is not an integer, make sure that the last line in this file corresponds to the total number of events in the files you have used in this file!" + return + fi +fi + +# Count the number of jobs and files +nFiles=`wc -l STMDatasetList.txt` +nFiles=($nFiles) + +# Validate and account for a newline character being present +lastLine=$(tail -c 1 STMDatasetList.txt) +if [[ "$lastLine" == '' ]]; then + nFiles=$((nFiles[0]-1)) +fi + +# Calculate the number of events to skip +nSkip=$((nEvents/nFiles)) +echo "Found $nEvents events over $nFiles files. Setting MaxEventsToSkip as $nSkip" + +# Create a copy of STMDatasetList.txt without the event count at the end +if [ -f STMDatasetListNoCount.txt ]; then + echo "Removing pre-existing STMDatasetListNoCount.txt" + rm -f STMDatasetListNoCount.txt +fi +head -n ${nFiles} STMDatasetList.txt > STMDatasetListNoCount.txt + +# Write the template fcl +if [ -f tmp.fcl ]; then + rm -f tmp.fcl +fi +echo '#include "Production/JobConfig/pileup/STM/STMResampler.fcl"' >> tmp.fcl +echo physics.filters.stmResamplerBeamCatDatasets.mu2e.MaxEventsToSkip: ${nSkip} >> tmp.fcl + +# Generate the STMResampler fcl files +generate_fcl --dsconf=$1$3 --dsowner=$USER --run-number=1204 --description=STMResampler --events-per-job=$5 --njobs=$4 \ + --embed tmp.fcl --auxinput=1:physics.filters.stmResamplerBeamCatDatasets.fileNames:STMDatasetListNoCount.txt + +# Move the generated fcl files (in their directories) to a uniquely identifiable area +for dirname in 000 001 002 003 004 005 006 007 008 009; do + if test -d $dirname; then + echo "found dir $dirname" + rm -rf STMResampler_$dirname + mv $dirname STMResampler_$dirname + fi +done + +# Save the seed file to a directory +seedDir="STMResamplerSeeds" +if [ ! -d $seedDir ]; then + mkdir $seedDir +fi +mv seeds.$USER.STMResampler*.$1$3.*.txt $seedDir + +# Cleanup +echo "Removing temporary files" +rm -f STMDatasetListNoCount.txt +rm -f tmp.fcl +echo "Finished" diff --git a/Scripts/STM/G4/gen_STMResampler1809.sh b/Scripts/STM/G4/gen_STMResampler1809.sh new file mode 100755 index 00000000..71e3f2fb --- /dev/null +++ b/Scripts/STM/G4/gen_STMResampler1809.sh @@ -0,0 +1,129 @@ +#!/usr/bin/bash +# Generate fcl files for resampling the hits generated with BeamToVD1809.fcl +# Generates a sets of fcl files found in directories 1809_00X +# Usage - Run this command as a shell script with the following arguments +# - $1 is the production (ie MDC2020) +# - $2 is the input production version +# - $3 is the output production version +# - $4 is the number of jobs +# - $5 is the number of jobs +# - $6 is the project name of the BeamToVD1809.fcl grid job. If not given, then it is assumed that the text file containing all the input datasets +# are listed in a file called STMDatasetList1809.txt with a single line at the end containing the number of events in the named STMDatasetList1809.txt. +# This works under the assumption that all jobs in the output directory are associated with the BeamToVD1809.fcl grid job +# Original author: Pawel Plesniak + +# Check all arguments are present +if [[ ${5} == "" ]]; then + echo "Missing arguments!" + return -1 +fi + +# TODO BEFORE NEXT CAMPAIGN - rewrite this to use the SAM tools samCountFiles.sh and samCountEvents.sh +# Create the input dataset list STMDatasetList1809.txt +if [[ ${6} != "" ]]; then + # Setup path to job path + jobDir="/pnfs/mu2e/scratch/users/"$USER"/workflow/"$6"/outstage/*/*/*/*.art" + + # Remove the existing file list + echo "Generating STMDatasetList1809.txt" + if [ -f STMDatasetList1809.txt ]; then + echo "Removing pre-existing STMDatasetList1809.txt" + rm STMDatasetList1809.txt; + fi + + # Generate the new file list + echo "Finding all the input datasets" + find $jobDir -type f -name "*.art" > STMDatasetList1809.txt; + + # Check that any files are found + nFiles=$(wc -c < "STMDatasetList1809.txt") + if [[ "$nFiles" -eq 0 ]]; then + echo "Path passed is empty, validate that the constructed path $jobDir is correct." + fi + + # Count the number of events + echo "Counting the number of events in the given path. Note - this is likely to take a few mins especially if there are a lot of files" + tail=`mu2e -c Offline/Print/fcl/count.fcl -S STMDatasetList1809.txt | tail -n 30 | grep "Event records" | xargs` + tailArray=($tail) + nEvents=${tailArray[0]} + + # Append the number of events to the file + echo ${nEvents} >> STMDatasetList1809.txt + echo "Finished generating STMDatasetList1809.txt" +else + echo "Using existing STMDatasetList1809.txt" + + # Check if the file with the list of data files and the total number of events on the last line exists + if [ ! -f STMDatasetList1809.txt ]; then + echo "No dataset list file called STMDatasetList1809.txt, exiting" + return + fi + + # Get the number of events from the last line of the file + nEvents=`tail -n 1 STMDatasetList1809.txt | xargs` + + # Check that there are events present + if [[ "$nEvents" -eq 0 ]]; then + echo "File indicates no events." + fi + + # Check if the last line is a number + if [[ ! $nEvents =~ ^[-+]?[0-9]+$ ]]; then + echo "Passed entry is not an integer, make sure that the last line in this file corresponds to the total number of events in the files you have used in this file!" + return + fi +fi + +# Count the number of jobs and files +nFiles=`wc -l STMDatasetList1809.txt` +nFiles=($nFiles) + +# Validate and account for a newline character being present +lastLine=$(tail -c 1 STMDatasetList1809.txt) +if [[ "$lastLine" == '' ]]; then + nFiles=$((nFiles[0]-1)) +fi + +# Calculate the number of events to skip +nSkip=$((nEvents/nFiles)) +echo "Found $nEvents events over $nFiles files. Setting MaxEventsToSkip as $nSkip" + +# Create a copy of STMDatasetList1809.txt without the event count at the end +if [ -f STMDatasetList1809NoCount.txt ]; then + echo "Removing pre-existing STMDatasetList1809NoCount.txt" + rm -f STMDatasetList1809NoCount.txt +fi +head -n ${nFiles} STMDatasetList1809.txt > STMDatasetList1809NoCount.txt + +# Write the template fcl +if [ -f tmp.fcl ]; then + rm -f tmp.fcl +fi +echo '#include "Production/JobConfig/pileup/STM/STMResampler.fcl"' >> tmp.fcl +echo physics.filters.stmResamplerTargetStopsCatDataset.mu2e.MaxEventsToSkip: ${nSkip} >> tmp.fcl + +# Generate the STMResampler fcl files +generate_fcl --dsconf=$1$3 --dsowner=$USER --run-number=1204 --description=STMResampler1809 --events-per-job=$5 --njobs=$4 \ + --embed tmp.fcl --auxinput=1:physics.filters.stmResamplerTargetStopsCatDataset.fileNames:STMDatasetList1809NoCount.txt + +# Move the generated fcl files (in their directories) to a uniquely identifiable area +for dirname in 000 001 002 003 004 005 006 007 008 009; do + if test -d $dirname; then + echo "found dir $dirname" + rm -rf STMResampler1809_$dirname + mv $dirname STMResampler1809_$dirname + fi +done + +# Save the seed file to a directory +seedDir="STMResamplerSeeds" +if [ ! -d $seedDir ]; then + mkdir $seedDir +fi +mv seeds.$USER.STMResampler1809*.$1$3.*.txt $seedDir + +# Cleanup +echo "Removing temporary files" +rm -f STMDatasetList1809NoCount.txt +rm -f tmp.fcl +echo "Finished" diff --git a/Scripts/STM/gen_STMResampler.sh b/Scripts/STM/gen_STMResampler.sh deleted file mode 100755 index ecc84d55..00000000 --- a/Scripts/STM/gen_STMResampler.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/bash -# Generate fcl files for resampling the hits generated with BeamToVD101.fcl -# Pawel Plesniak - -# $1 is the production (ie MDC2020) -# $2 is the input production version -# $3 is the output production version -# $4 is the number of jobs -# $5 is the project name of the BeamToVD101.fcl grid job. If not given, then it is assumed that the text file containing all the input datasets -# are listed in a file called STMDatasetList.txt with a single line at the end containing the number of events in the named STMDatasetList.txt. -# This works under the assumption that all jobs in the output directory are associated with the BeamToVD101.fcl grid job - -if [[ ${4} == "" ]]; then - echo "Missing arguments!" - return -1 -fi - -# TODO BEFORE NEXT CAMPAIGN - rewrite this to use the SAM tools samCountFiles.sh and samCountEvents.sh -# Create the input dataset list STMDatasetList.txt -if [[ ${5} != "" ]]; then - jobDir="/pnfs/mu2e/scratch/users/"$USER"/workflow/"$5"/outstage/*/*/*/*.art" - echo "Generating STMDatasetList.txt" - if [ -f STMDatasetList.txt ]; then - echo "Removing pre-existing STMDatasetList.txt" - rm STMDatasetList.txt; - fi - echo "Finding all the input datasets" - echo "Note - this is likely to take approx one minute." - find $jobDir -type f -name "*.art" > STMDatasetList.txt; - echo "Running Offline/Print/fcl/count.fcl -S STMDatasetList.txt" - echo "Note - this is likely to take a few mins especially if there are a lot of files" - tail=`mu2e -c Offline/Print/fcl/count.fcl -S STMDatasetList.txt | tail -n 30 | grep "Event records" | xargs` - tailArray=($tail) - nEvents=${tailArray[0]} - echo ${nEvents} >> STMDatasetList.txt - echo "Finished generating STMDatasetList.txt" -else - echo "Using existing STMDatasetList.txt" - if [ ! -f STMDatasetList.txt ]; then - echo "No dataset list file called STMDatasetList.txt, exiting" - exit 1 - fi - nEvents=`tail -n 1 STMDatasetList.txt | xargs` -fi - -# Count the number of jobs and files -nFiles=`wc -l STMDatasetList.txt` -nFiles=($nFiles) -nFiles=$((nFiles[0]-1)) -nSkip=$((nEvents/nFiles)) -echo "Found $nEvents events over $nFiles files. Setting MaxEventsToSkip as $nSkip" - -# Create a copy of STMDatasetList.txt without the event count at the end -if [ -f STMDatasetListNoCount.txt ]; then - echo "Removing pre-existing STMDatasetListNoCount.txt" - rm -f STMDatasetListNoCount.txt -fi -head -n ${nFiles} STMDatasetList.txt > STMDatasetListNoCount.txt - -# write the template fcl -rm -f stmResampler.fcl -echo '#include "Production/JobConfig/pileup/STM/STMResampler.fcl"' >> stmResampler.fcl -echo physics.filters.stmResampler.mu2e.MaxEventsToSkip: ${nSkip} >> stmResampler.fcl - -generate_fcl --dsconf=$1$3 --dsowner=plesniak --run-number=1404 --description=STMResampler --events-per-job=20000000000 --njobs=$4 \ - --embed stmResampler.fcl --auxinput=1:physics.filters.stmResampler.fileNames:STMDatasetListNoCount.txt # --old-seeds=seeds.plesniak.EleBeamResamplerSTM.MDC2020ab.CkMv.txt - -for dirname in 000 001 002 003 004 005 006 007 008 009; do - if test -d $dirname; then - echo "found dir $dirname" - rm -rf STMResampler_$dirname - mv $dirname STMResampler_$dirname - fi -done - -# Cleanup -echo "Removing temporary files" -rm -f STMDatasetListNoCount.txt -rm -f stmResampler.fcl -echo "Finished"