From e3475b1c608293bcb2eafe5829ca86e761738972 Mon Sep 17 00:00:00 2001 From: simonge Date: Thu, 16 May 2024 16:39:50 +0100 Subject: [PATCH] Changes to for remote running --- benchmarks/LOWQ2/analysis/.gitignore | 2 + benchmarks/LOWQ2/analysis/PostprocessLOWQ2.C | 21 ++---- benchmarks/LOWQ2/analysis/RunLOWQ2.C | 2 +- benchmarks/LOWQ2/analysis/Snakefile | 79 ++++++++++++++++++-- benchmarks/LOWQ2/config.yml | 7 +- 5 files changed, 84 insertions(+), 27 deletions(-) diff --git a/benchmarks/LOWQ2/analysis/.gitignore b/benchmarks/LOWQ2/analysis/.gitignore index a8ce0618..c96503c7 100644 --- a/benchmarks/LOWQ2/analysis/.gitignore +++ b/benchmarks/LOWQ2/analysis/.gitignore @@ -1,3 +1,5 @@ plots* calibrations* fieldmaps* +gdml* +.snakemake* \ No newline at end of file diff --git a/benchmarks/LOWQ2/analysis/PostprocessLOWQ2.C b/benchmarks/LOWQ2/analysis/PostprocessLOWQ2.C index 63882d4d..3bc5b380 100644 --- a/benchmarks/LOWQ2/analysis/PostprocessLOWQ2.C +++ b/benchmarks/LOWQ2/analysis/PostprocessLOWQ2.C @@ -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 } @@ -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"); @@ -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(); @@ -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"); -} \ No newline at end of file +// void PostprocessLOWQ2() { +// // Postprocess("plots/LOWQ2QRRecon2.root", "plots/LOWQ2QR_FormattedPlots.root", "Quasi-Real"); +// Postprocess("plots/LOWQ2BremsRecon3.root", "plots/LOWQ2Brems_FormattedPlots3.root", "Bremsstrahlung"); +// } \ No newline at end of file diff --git a/benchmarks/LOWQ2/analysis/RunLOWQ2.C b/benchmarks/LOWQ2/analysis/RunLOWQ2.C index b5c3c422..e73e9849 100644 --- a/benchmarks/LOWQ2/analysis/RunLOWQ2.C +++ b/benchmarks/LOWQ2/analysis/RunLOWQ2.C @@ -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 diff --git a/benchmarks/LOWQ2/analysis/Snakefile b/benchmarks/LOWQ2/analysis/Snakefile index cee7e3d7..ed1c1b28 100644 --- a/benchmarks/LOWQ2/analysis/Snakefile +++ b/benchmarks/LOWQ2/analysis/Snakefile @@ -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}")' """ diff --git a/benchmarks/LOWQ2/config.yml b/benchmarks/LOWQ2/config.yml index c3a7876c..cf41f5a3 100644 --- a/benchmarks/LOWQ2/config.yml +++ b/benchmarks/LOWQ2/config.yml @@ -1,5 +1,2 @@ -training: - # Training configuration goes here - -analysis: - # Analysis configuration goes here +include: + - local: 'analysis/config.yml'