Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2d Ana #55

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6b610ba
Addition of the libraries for the 2D analysis. For the moment it is n…
egranadosvazquez Nov 10, 2022
5af5153
Merge remote-tracking branch 'origin/master' into 2d_analysis
egranadosvazquez Nov 18, 2022
4720c98
I implemented many if fuctions that are inclusded in files that conta…
egranadosvazquez Nov 21, 2022
09932a6
I'm modifying the analysis files to obtain the cross section. At this…
egranadosvazquez Nov 23, 2022
38b07b7
I'm I finished to add all the steps to calculate the cross section fo…
egranadosvazquez Nov 23, 2022
95bbcf8
Bug fix for the data selection, xsec/makeCrossSectionMCInputs.C and x…
egranadosvazquez Nov 29, 2022
5910609
I'm trying to fix an error that I have when I fill the true values, I…
egranadosvazquez Dec 1, 2022
6b42a52
Adding the modifications to send jobs to the grid
egranadosvazquez Dec 6, 2022
2d9dc61
Many changes to make the update of the analysis
egranadosvazquez Feb 8, 2023
aeb5b98
I make the update of the 2D analysis with the new Ben's implementatio…
egranadosvazquez Feb 8, 2023
724c5dd
I am adding some updates related witht the last pull that I did after…
egranadosvazquez Apr 6, 2023
a9231f0
I'm making the merge of this branch with the 2d analysis with the mas…
egranadosvazquez Apr 6, 2023
6eb92c7
Merge remote-tracking branch 'origin/master' into 2d_analysis
egranadosvazquez Apr 6, 2023
e9ed664
The changes that I did arerelated to the correct implementation of th…
egranadosvazquez Sep 13, 2023
56657ee
The changes are related to plot T_pivsthetapi using the untracked pio…
egranadosvazquez Jan 6, 2024
a5675df
I did the merge with the master branch, there is abug in the code, I …
egranadosvazquez Jan 7, 2024
178724d
The merge is completed, it looks like it is working now.
egranadosvazquez Jan 8, 2024
528d905
I did changes related to the breackdown of the bacground and changes …
egranadosvazquez Mar 19, 2024
2a6a6d7
I add the Gean4 systematics and the target mass systematics
egranadosvazquez Mar 19, 2024
0deff32
Multiple changes, this is the version that I used for my thesis
egranadosvazquez Aug 2, 2024
cfb0745
Modifications to add the untracked pions
egranadosvazquez Sep 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions PlottinRatios.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

#!/usr/bin/python

from ROOT import *
from ROOT import PlotUtils
from array import array
try:
import array as np
except:
exit()
gROOT.SetBatch() #Don't render histograms to a window. Also gets filled areas correct.

TH1.AddDirectory(False)
lowq2MParamFiles = TFile.Open("../opt/etc/MParamFiles/data/Reweight/lowQ2pi_weights.root")
MyLowq2 = TFile.Open("../NewLowQ2/lowQ2pi_weights.root")

g_lowq2MP = lowq2MParamFiles.Get("MENU1PI_weights")
g_MyLowq2 = MyLowq2.Get("MENU1PI_weights")

nPMP = g_lowq2MP.GetN()
nPMy = g_MyLowq2.GetN()

print (nPMP)
print (nPMy)

rval = array ('d')
xval = array ('d')

xMp = double(0)
yMp = double(0)
xMy = double(0)
yMy = double(0)

for p in range(nPMP):
g_lowq2MP.GetPoint(p, xMp, yMp)
g_MyLowq2.GetPoint(p, xMy, yMy)
rval.append( yMp / yMy)
xval.append(xMp)

for i in range(10):
print (rval[i])
print (xval[i])

c1 = TCanvas("Warping studies for")
ratio = TGraph(nPMP, xval, rval)
c1.cd()
ratio.GetYaxis().SetRangeUser(0.9,1.1)
ratio.GetYaxis().SetTitle("ratio")
ratio.GetXaxis().SetTitle("q^2 GeV")
ratio.Draw()
c1.Update()
c1.Print("RatioLowq2.png")






60 changes: 36 additions & 24 deletions PrintWarping.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@
gROOT.SetBatch() #Don't render histograms to a window. Also gets filled areas correct.

TH1.AddDirectory(False)
variables = ["mixtpi", "mtpi", "enu", "pmu", "ptmu", "pzmu", "q2", "thetamu_deg", "thetapi_deg", "tpi", "wexp"]
#variables = ["mixtpi"]
date = "20230523"
#variables = ["pzmu_vs_ptmu", "tpi_vs_thetapi_deg", "pmu_vs_tpi", "tpi_vs_ptmu", "enu_vs_tpi"]
variables = ["tpi_vs_ptmu"]
#variables = ["pzmu_vs_ptmu", "ptmu_vs_pzmu", "tpi_vs_pmu", "pmu_vs_tpi", "tpi_vs_thetapi_deg", "thetapi_deg_vs_tpi", "ptmu_vs_tpi", "tpi_vs_ptmu", "enu_vs_tpi", "tpi_vs_enu"]
date = "20240619"
warp = "WARP3"

plist="ALL"
corrfac="8.8"
scale="4.689984"
for var in variables:
mcFile = TFile.Open("WarpingStudies/newbinning/Warping_{WARP}_{VAR}.root".format(WARP=warp,VAR=var))
mcFile = TFile.Open("/minerva/data/users/granados/WarpingStudies/Warping/2DWarping/Warping_2D_{PLIST}_{DATE}_stat_scale{SCALE}_{WARP}_{VAR}_corfac{CORFAC}_exclude.root".format(PLIST=plist,DATE=date,WARP=warp,VAR=var,SCALE=scale,CORFAC=corrfac))
# mcFile = TFile.Open("/minerva/data/users/granados/WarpingStudies/Warping/2DWarping/Warping_2D_{PLIST}_{DATE}_stat_scale{SCALE}_{WARP}_{VAR}.root".format(PLIST=plist,DATE=date,WARP=warp,VAR=var,SCALE=scale,CORFAC=corrfac))
# mcFile = TFile.Open("/minerva/data/users/granados/WarpingStudies/Warping/2DWarping/Warping_2D_{PLIST}_{DATE}_{WARP}_{VAR}.root".format(PLIST=plist,DATE=date,WARP=warp,VAR=var,SCALE=scale,CORFAC=corrfac))

lineWidth = 3

Expand All @@ -36,22 +41,27 @@
h_ndf.SetBinContent(i+1, double(ndf))

titleName = ""
if var == "mixtpi":
titleName = "T_{#pi}"
if var == "pzmu":
titleName = "p^{z}_{#mu}"
if var == "ptmu":
titleName = "p^{t}_{#mu}"
if var == "thetapi_deg":
titleName = "#theta_{#pi}"
if var == "pmu":
titleName = "p_{#mu}"
if var == "q2":
titleName = "q^{2}"
if var == "thetamu_deg":
titleName = "#theta_{#mu}"
if var == "wexp":
titleName = "W_{exp}"
if var == "ptmu_vs_tpi":
titleName = "p^{t}_{#mu} vs T_{#pi}"
if var == "pzmu_vs_ptmu":
titleName = "p^{z}_{#mu} vs p^{t}_{#mu}"
if var == "tpi_vs_thetapi_deg":
titleName = "T_{#pi} vs #theta_{#pi}"
if var == "tpi_vs_pmu":
titleName = "T_{#pi} vs p_{#mu}"
if var == "tpi_vs_ptmu":
titleName = "T_{#pi} vs p^{t}_{#mu}"
if var == "ptmu_vs_pzmu":
titleName = "p^{T}_{#mu} vs p^{z}_{#mu}"
if var == "thetapi_deg_vs_tpi":
titleName = "#theta_{#pi} vs T_{#pi}"
if var == "pmu_vs_tpi":
titleName = "p_{#mu} vs T_{#pi}"
if var == "enu_vs_tpi":
titleName = "E_{#nu} vs T_{#pi}"
if var == "tpi_vs_enu":
titleName = "T_{#pi} vs E_{#nu}"

c1 = TCanvas("Warping studies for")
Title = TPaveText (8., 6000, 120., 10500.)
Title.Clear()
Expand All @@ -75,7 +85,7 @@
h_ndf.SetLineColor(kOrange-3)

# c1.UseCurrentStyle()

chi2Iter.GetYaxis().SetRangeUser(0.,100.)
chi2Iter.GetXaxis().CenterTitle()
chi2Iter.GetXaxis().SetTitleOffset(1.3)
chi2Iter.GetXaxis().SetTitleSize(0.04)
Expand All @@ -95,14 +105,16 @@
truncatedChi2Iter.Draw("SAME HIST")
h_ndf.Draw("SAME HIST")
c1.SetLogx()
c1.SetLogy()

# c1.SetLogy()
#c1.BuildLegend(0.7, 0.6, 0.9, 0.9)
legend.AddEntry(AverageChi2Iter, "Average", "l")
legend.AddEntry(truncatedChi2Iter, "Truncated", "l")
legend.AddEntry(MedianChi2Iter, "Median", "l")
legend.AddEntry(h_ndf, "ndf", "l")
legend.Draw()
Title.Draw()
c1.Print("WarpingStudies/newbinning/Warping_{VAR}_{WARP}.png".format(VAR=var,WARP=warp))
c1.Print("WarpingPlots/Warping_{DATE}_{PLIST}_{VAR}_{WARP}_corfac{CORFAC}_exclude.png".format(DATE=date,VAR=var,WARP=warp,PLIST=plist,CORFAC=corrfac))
# c1.Print("WarpingPlots/Warping_{DATE}_{PLIST}_{VAR}_{WARP}.png".format(DATE=date,VAR=var,WARP=warp,PLIST=plist,CORFAC=corrfac))
c1.Clear()

92 changes: 68 additions & 24 deletions ProcessCCPiMacro.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
# Constants/Default Args
###############################################################################
# Scripts, Files, and Dirs
kGRID_SCRIPT = os.getenv("PWD") + "/grid_ccpi_macro.sh"
kGRID_SCRIPT = os.getenv("PWD") + "/grid_ccpi_macro_2D.sh"
kTOPDIR = os.getenv("TOPDIR")
kANATUPLE_DIR = "/pnfs/minerva/persistent/users/zdar/"
kOUTDIR = "/pnfs/{EXPERIMENT}/scratch/users/{USER}/TestMAD/".format(
kANATUPLE_DIR = "/pnfs/minerva/persistent/DataPreservation/p4/FullDetector/"
kOUTDIR = "/pnfs/{EXPERIMENT}/scratch/users/{USER}/TestMAD2D/".format(
EXPERIMENT=os.getenv("EXPERIMENT"), USER=os.getenv("USER")
)
kCACHE_PNFS_AREA = "/pnfs/{EXPERIMENT}/scratch/users/{USER}/grid_cache/".format(
Expand All @@ -21,14 +21,17 @@
)
kEV_SEL_MACRO = "event_selection/runEventSelectionGrid.C+"
kMC_INPUTS_MACRO = "xsec/makeCrossSectionMCInputs.C+"
kBACKGROUND_BREAKDOWN = "studies/runBackgrounds.C+"
#kMC_MIGRATION_MACRO = "studies/runMigMtxBinning.C+"
# Grid Stuff
kMINERVA_RELEASE = os.getenv("MINERVA_RELEASE")
kMEMORY = "1GB"
kMEMORY = "8GB"
kGRID_OPTIONS = (
"--group minerva "
"--resource-provides=usage_model=DEDICATED,OPPORTUNISTIC "
"--lines='+SingularityImage=\\\"/cvmfs/singularity.opensciencegrid.org/fermilab/fnal-wn-sl7:latest\\\"' "
# "--lines='+SingularityImage=\\\"/cvmfs/singularity.opensciencegrid.org/fermilab/fnal-wn-sl7:latest\\\"' "
"--role=Analysis "
"--disk=15GB"
# "--OS=SL7 " # change to SL7 when submitting from sl7 machines.
)

Expand Down Expand Up @@ -99,13 +102,11 @@ def MakeTarfile(source_dir, tag):
print(source_dir + i)
tar.add(source_dir + i, i)
tar.close()

# It is done. Send it to scratch.
tarfile_fullpath = IFDHMove(tarfile_name, kTARBALL_LOCATION)

return tarfile_name, tarfile_fullpath


def MakeUniqueProcessingID(tag):
processing_id = "{TAG}{DAY}-{TIME}".format(
TAG=tag, DAY=dt.date.today(), TIME=dt.datetime.today().strftime("%H%M")
Expand All @@ -124,6 +125,8 @@ def GetOptions():
grid_group.add_option("--memory", default=kMEMORY)
grid_group.add_option("--ev_sel", action="store_true")
grid_group.add_option("--mc_xsec_inputs", action="store_true")
grid_group.add_option("--bg_breakdown", action="store_true")
grid_group.add_option("--mc_migration", action="store_true")

# job args
job_group = optparse.OptionGroup(parser, "Job Options")
Expand All @@ -142,6 +145,13 @@ def GetOptions():
default=True, # default: DO systs
help="Don't do full systematics. Default: DO systematics",
)
job_group.add_option(
"--test_playlist",
action="store_true",
dest="do_test_playlist",
default=False, # default is Not use test playlist
help="It use a test playlist. Default: It doesn't use the test playlist.",
)
job_group.add_option("--signal_definition", default=0, help="0 = 1piW<1.4")
job_group.add_option(
"--playlists",
Expand All @@ -156,13 +166,17 @@ def GetOptions():
options, remainder = parser.parse_args()

# require a macro
if options.ev_sel == options.mc_xsec_inputs:
if options.ev_sel == options.mc_xsec_inputs and options.mc_xsec_inputs == options.mc_migration and options.mc_xsec_inputs == options.bg_breakdown:
print("Pick a macro!")
quit()
elif options.ev_sel:
options.macro = kEV_SEL_MACRO
elif options.mc_xsec_inputs:
options.macro = kMC_INPUTS_MACRO
elif options.mc_migration:
options.macro = kMC_MIGRATION_MACRO
elif options.bg_breakdown:
options.macro = kBACKGROUND_BREAKDOWN
else:
pass

Expand Down Expand Up @@ -200,7 +214,7 @@ def main():
cache = kCACHE_PNFS_AREA + "/" + processing_id
print("sending grid macro to " + cache)
MakeDirectory(cache)
grid_script = IFDHCopy("grid_ccpi_macro.sh", cache)
grid_script = IFDHCopy("grid_ccpi_macro_2D.sh", cache)

if options.run:
print("\nSubmitting run: " + options.run)
Expand All @@ -214,7 +228,7 @@ def main():
print("Using tuples from" + kANATUPLE_DIR)

# loop anatuples
list_of_anatuples = glob.glob(kANATUPLE_DIR + "/Merged_mc_ana_{0}_DualVertex_p3/*".format(i_playlist))
list_of_anatuples = glob.glob(kANATUPLE_DIR + "/Merged_mc_ana_{0}_DualVertex_p4/*".format(i_playlist))
for anatuple in list_of_anatuples:
if not ("MasterAnaDev" in anatuple) or not (".root" in anatuple):
continue
Expand All @@ -233,20 +247,50 @@ def XROOTDify(anatuple):
)

anatuple = XROOTDify(anatuple)

macro = options.macro
macro += (
'({SIGNAL_DEFINITION},\\\\\\"{PLAYLIST}\\\\\\",{DO_FULL_SYST},'
'{DO_TRUTH},{DO_GRID},\\\\\\"{TUPLE}\\\\\\",{RUN})'.format(
SIGNAL_DEFINITION=options.signal_definition,
PLAYLIST=i_playlist,
DO_FULL_SYST="true" if options.do_full_systematics else "false",
DO_TRUTH="true" if options.do_truth else "false",
DO_GRID="true",
TUPLE=anatuple,
RUN=run,
if options.mc_xsec_inputs:
macro = options.macro
macro += (
'({SIGNAL_DEFINITION},\\\\\\"{PLAYLIST}\\\\\\",{DO_FULL_SYST},'
'{DO_TRUTH},{DO_TEST},{DO_GRID},\\\\\\"{TUPLE}\\\\\\",{RUN})'.format(
SIGNAL_DEFINITION=options.signal_definition,
PLAYLIST=i_playlist,
DO_FULL_SYST="true" if options.do_full_systematics else "false",
DO_TRUTH="true" if options.do_truth else "false",
DO_TEST="false" if options.do_test_playlist else "true",
DO_GRID="true",
TUPLE=anatuple,
RUN=run,
)
)
)

if options.bg_breakdown:
macro = options.macro
macro += (
'({SIGNAL_DEFINITION},\\\\\\"{PLAYLIST}\\\\\\",'
'{DO_GRID},\\\\\\"{TUPLE}\\\\\\",{RUN})'.format(
SIGNAL_DEFINITION=options.signal_definition,
PLAYLIST=i_playlist,
DO_GRID="true",
TUPLE=anatuple,
RUN=run,
)
)



# if options.mc_migration:
# macro = options.macro
# macro += (
# '({SIGNAL_DEFINITION},\\\\\\"{PLAYLIST}\\\\\\",'
# '{DO_GRID},\\\\\\"{TUPLE}\\\\\\",{RUN})'.format(
# SIGNAL_DEFINITION=options.signal_definition,
# PLAYLIST=i_playlist,
# DO_GRID="true",
# TUPLE=anatuple,
# RUN=run,
# )
# )


macro = '"' + macro + '"'

Expand Down Expand Up @@ -280,4 +324,4 @@ def XROOTDify(anatuple):


if __name__ == "__main__":
main()
main()
2 changes: 1 addition & 1 deletion ccpion_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
std::string GetPlaylistFile(std::string plist, bool is_mc,
bool use_xrootd = true) {
// const std::string processing_date = "20200713"; // new short tracking branches
const std::string processing_date = "production_p3"; // new recoil energy branches
const std::string processing_date = "production_p4"; // new recoil energy branches
// const std::string processing_date = "test"; // For test with small MAD tuplas
const std::string is_mc_str = is_mc ? "mc" : "data";
std::transform(plist.begin(), plist.end(), plist.begin(), ::toupper);
Expand Down
2 changes: 1 addition & 1 deletion grid_ccpi_macro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ echo $PLOTUTILSROOT

echo
echo "======== cd to ME_CCNuPionInc_Ana ========"
cd ${HOME}/cc-ch-pip-ana
cd ${HOME}/2D-cc-ch-pip-ana
pwd

echo
Expand Down
Loading