Skip to content

Commit

Permalink
Changes to for remote running
Browse files Browse the repository at this point in the history
  • Loading branch information
simonge committed May 16, 2024
1 parent 29374e0 commit e3475b1
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 27 deletions.
2 changes: 2 additions & 0 deletions benchmarks/LOWQ2/analysis/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
plots*
calibrations*
fieldmaps*
gdml*
.snakemake*
21 changes: 6 additions & 15 deletions benchmarks/LOWQ2/analysis/PostprocessLOWQ2.C
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,7 @@ void SetStyle() {
gStyle->SetPadRightMargin(0.18);
gStyle->SetPadBottomMargin(0.12);
gStyle->SetTitleSize(0.04, "XYZ");

gStyle->SetTitleOffset(4.0, "Z");
// gStyle->SetTitleOffset(1.0, "Y");

// // Set global plot format variables
// int font = 42; //
// gStyle->SetTextFont(font); // Set the font for text
// gStyle->SetLabelFont(font, "XYZ"); // Set the font for axis labels
// gStyle->SetTitleFont(font, "XYZ"); // Set the font for titles

}

Expand Down Expand Up @@ -71,7 +63,6 @@ TH2* RatePlot(TDirectory* inputDir, int Module, int Layer, TString Tag="Quasi-Re
RatePlot->Rebin2D(rebin,rebin);
RatePlot->Scale(1.0/(rebin*rebin));
TString title = "Tagger module "+std::to_string(Module)+", layer "+std::to_string(Layer)+" - Mean "+Tag+" rate per "+std::to_string(rebin)+"x"+std::to_string(rebin)+" pixel group";
// TString title = "Tagger module 2, layer 0 rate, integrated over "+std::to_string(rebin)+"x"+std::to_string(rebin)+" pixel group";
RatePlot->SetTitle(title);
RatePlot->GetXaxis()->SetTitle("x pixel");
RatePlot->GetYaxis()->SetTitle("y pixel");
Expand Down Expand Up @@ -485,9 +476,9 @@ void FormatReconstructionPlots(TDirectory* inputDir, TFile* outputFile, TString
}

//----------------------------------------------------------------------
// This function is called by the benchmarking script maybe
// This function is called by the benchmarking script
//----------------------------------------------------------------------
void Postprocess(TString inName="LOWQ2QRRates3.root", TString outName="LOWQ2Plots.root", TString Tag="Quasi-Real") {
void PostprocessLOWQ2(TString inName, TString outName, TString Tag) {

SetStyle();

Expand Down Expand Up @@ -536,7 +527,7 @@ void Postprocess(TString inName="LOWQ2QRRates3.root", TString outName="LOWQ2Plot
//----------------------------------------------------------------------
// Main function to create canvases
//----------------------------------------------------------------------
void PostprocessLOWQ2() {
// Postprocess("plots/LOWQ2QRRecon2.root", "plots/LOWQ2QR_FormattedPlots.root", "Quasi-Real");
Postprocess("plots/LOWQ2BremsRecon3.root", "plots/LOWQ2Brems_FormattedPlots3.root", "Bremsstrahlung");
}
// void PostprocessLOWQ2() {
// // Postprocess("plots/LOWQ2QRRecon2.root", "plots/LOWQ2QR_FormattedPlots.root", "Quasi-Real");
// Postprocess("plots/LOWQ2BremsRecon3.root", "plots/LOWQ2Brems_FormattedPlots3.root", "Bremsstrahlung");
// }
2 changes: 1 addition & 1 deletion benchmarks/LOWQ2/analysis/RunLOWQ2.C
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void RunLOWQ2( std::string inputFileName = "Brems_input.root",
bool inputIsTimeBased = false, // true if the event sample is time-based, false if it is event-based
double timeWindow = 10.15*1e-9, //[s]
double eventCrossSection = 0.0551, // [mb]
double luminosity = 1e34, // [cm^-2 s^-1]
double luminosity = 1e34 // [cm^-2 s^-1]
) {

//Set implicit multi-threading
Expand Down
79 changes: 73 additions & 6 deletions benchmarks/LOWQ2/analysis/Snakefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,88 @@
# Possible tags for local/remote running
tag_params = {
"QR": {"timeBased": 0, "timeWindow": 0, "eventCrossSection": 0.0551, "tagName": "Quasi-Real"},
"Brem": {"timeBased": 1, "timeWindow": 10.15*1e-9, "eventCrossSection": 0, "tagName": "Bremsstrahlung"},
"pythia6": {"timeBased": 0, "timeWindow": 0, "eventCrossSection": 0.054, "tagName": "Deep Inelastic Scattering"},
# Add more mappings here if needed
}

EVENT_EXTENSION = ".ab.hepmc3.tree.root"
SIM_EXTENSION = ".edm4hep.root"
RECO_EXTENSION = ".eicrecon.tree.edm4eic.root"

REMOTE_EVENTS_DIRECTORY = "root://dtn-eic.jlab.org//work/eic2/EPIC/EVGEN/SIDIS/pythia6-eic/1.0.0/10x100/q2_0to1/"
FILE_BASE = "pythia_ep_noradcor_10x100_q2_0.000000001_1.0_run"

BEAM_ENERGY = "10"
XML_FILE = "/opt/detector/epic-main/share/epic/epic.xml",

# Function to check if the remote file exists
def remote_file_exists(server,url):
try:
subprocess.check_output(['xrdfs', server, 'stat', url])
return url
except subprocess.CalledProcessError:
return None

rule run_simulation_remote:
params:
XML=XML_FILE,
input=remote_file_exists(REMOTE_EVENTS_DIRECTORY+FILE_BASE+wildcards.index+EVENT_EXTENSION),
output:
config["SIM_DIRECTORY"]+FILE_BASE+"{index}_tagger"+SIM_EXTENSION,
shell: """
npsim \
--inputFiles {params.input} \
--outputFile {output[0]} \
--compactFile {params.XML} \
--runType run \
--numberOfEvents 100 \
--physics.list FTFP_BERT \
--field.eps_min 5e-06 \
--field.eps_max 1e-04 \
--physics.rangecut 50 \
"""

rule run_reconstruction:
params:
XML=XML_FILE,
beam_energy=BEAM_ENERGY,
collections="TaggerTrackerProjectedTracks,MCScatteredElectrons,MCParticles,EventHeader",
input:
expand(
config["SIM_DIRECTORY"]+FILE_BASE+"{index}_tagger"+SIM_EXTENSION,
index=range(1,4),
),
output:
config["RECO_DIRECTORY"]+FILE_BASE+".tagger_recon"+RECO_EXTENSION,
shell: """
eicrecon {input} -Pdd4hep:xml_files={params.XML} -Ppodio:output_include_collections={params.collections} -Ppodio:output_file={output} -PLOWQ2:LowQ2Trajectories:electron_beamE={params.beam_energy}
"""

rule run_benchmarks:
input:
"/scratch/EIC/ReconOut/{tag}_new.root"
params:
crossSection = 0.0551,
xmlName=XMLFILE,
timeBased = lambda wildcards: tag_params[wildcards.tag]["timeBased"],
timeWindow = lambda wildcards: tag_params[wildcards.tag]["timeWindow"],
eventCrossSection = lambda wildcards: tag_params[wildcards.tag]["eventCrossSection"]

output:
"plots/LOWQ2{tag}_Recon.root"
"{dir}/results/LOWQ2/LOWQ2{tag}_Plots.root"
shell:
"""
root -l -b -q 'RunLOWQ2.C++("{input}", "{output}", {params.crossSection})'
root -l -b -q 'RunLOWQ2.C++("{input}", "{output}", "{params.xmlName}", {params.timeBased}, {params.timeWindow}, {params.eventCrossSection})'
"""

rule run_plots:
input:
"plots/LOWQ2{tag}_Recon.root"
"{dir}/results/LOWQ2/LOWQ2{tag}_Plots.root"
params:
tagName = lambda wildcards: tag_params[wildcards.tag]["tagName"],
output:
"plots/LOWQ2{tag}_FormattedPlots2.root"
"{dir}/results/LOWQ2/LOWQ2{tag}_FormattedPlots.root"
shell:
"""
root -l -b -q 'PostprocessLOWQ2.C("{input}", "{output}","{wildcards.tag}")'
root -l -b -q 'PostprocessLOWQ2.C("{input}", "{output}","{params.tagName}")'
"""
7 changes: 2 additions & 5 deletions benchmarks/LOWQ2/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
training:
# Training configuration goes here

analysis:
# Analysis configuration goes here
include:
- local: 'analysis/config.yml'

0 comments on commit e3475b1

Please sign in to comment.