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

Federica ac clean #38

Open
wants to merge 197 commits into
base: dev_fggfinalfits_lite
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
197 commits
Select commit Hold shift + click to select a range
f98ed36
start fitting
emanueledimarco Mar 15, 2022
10a1f9d
adding a custom xvar fitting to RunSignalScripts.py
emanueledimarco Mar 23, 2022
7e3efe9
adding a custom xvar fitting to RunSignalScripts.py
emanueledimarco Mar 23, 2022
10865da
updates for my files
emanueledimarco Mar 23, 2022
677dd44
my first fixes
emanueledimarco Mar 25, 2022
507b3f0
Merge pull request #1 from emanueledimarco/vbfac-dev
emanueledimarco Mar 25, 2022
9d1c54d
changes for the weighted roodatasets
emanueledimarco Mar 30, 2022
9e356dd
Merge pull request #2 from emanueledimarco/vbfac-dev
emanueledimarco Mar 30, 2022
c1aba68
now working up to signalFits
emanueledimarco Mar 30, 2022
be93cf4
Merge pull request #3 from emanueledimarco/vbfac-dev
emanueledimarco Mar 30, 2022
6a56bc3
fixes for the replacements
emanueledimarco Mar 30, 2022
8795507
missing conversion from fb to pb
emanueledimarco Mar 31, 2022
544c697
using 138 fb-1 for full Run2 lumi
emanueledimarco Mar 31, 2022
b2fce39
done with last steps
emanueledimarco Mar 31, 2022
8c1b4f2
fix background modeling
emanueledimarco Mar 31, 2022
35f892c
use norm Run2 when using 2017 for now
emanueledimarco Mar 31, 2022
0fcf8bb
Merge pull request #4 from emanueledimarco/vbfac-dev
emanueledimarco Mar 31, 2022
66384c6
fixes for datacards
emanueledimarco Apr 1, 2022
6358efd
updating config files for the new inputs
emanueledimarco Apr 13, 2022
a4a4036
setup scripts updated
emanueledimarco Apr 13, 2022
d72027a
add a script to run the signal steps
emanueledimarco Apr 13, 2022
d679e49
update the replacements for the lowstat categories
emanueledimarco Apr 13, 2022
f2c2c65
fixes: ALT samples only have the nominal MH
emanueledimarco Apr 13, 2022
0e3fd35
dryRun option added to signal sequence script
emanueledimarco Apr 13, 2022
3e970d2
take into account that for ALT models there is only 125 GeV
emanueledimarco Apr 13, 2022
fbef124
further developments for Signal for 3 years and ALT model
emanueledimarco Apr 14, 2022
dbc442a
add a script to merge multiple years RooDataSets
emanueledimarco Apr 14, 2022
95239fe
update bkg for multi years and new categorization
emanueledimarco Apr 14, 2022
ef62b16
add datacard sequence example
emanueledimarco Apr 14, 2022
639a418
update the datcard sequence
emanueledimarco Apr 14, 2022
4d94fee
merge Years necessary in the DC creation
emanueledimarco Apr 28, 2022
cf7084e
add the model for CP fit
emanueledimarco Apr 28, 2022
1b00f3f
add the combine commands, even if still WorkInProgress
emanueledimarco Apr 28, 2022
1fd719e
Update README.md
emanueledimarco May 9, 2022
e50492a
changes to run fits locally
emanueledimarco May 9, 2022
f4b8ca5
changes for cp fit
emanueledimarco May 9, 2022
458bd91
Merge pull request #5 from emanueledimarco/vbfac-dev
emanueledimarco May 9, 2022
0e8551f
readme update with the link of the local repo
emanueledimarco May 9, 2022
0f861ff
Merge pull request #6 from emanueledimarco/vbfac-dev
emanueledimarco May 9, 2022
f88e517
add a script to rename flashgg trees
emanueledimarco Jun 17, 2022
d0508e3
new names gymnastic
emanueledimarco Jun 17, 2022
fe89756
renaming improved
emanueledimarco Jun 17, 2022
42496e9
changes for the new VBF alt cateogory names
emanueledimarco Jun 17, 2022
34bb4a0
update for signal fit with systs
emanueledimarco Jun 17, 2022
498b4ab
Merge pull request #7 from emanueledimarco/vbfac-dev
emanueledimarco Jun 17, 2022
021b667
.q
Jun 22, 2022
4d97f76
miei cambi
Jun 22, 2022
345b13e
update of the fit variable in config files
emanueledimarco Jul 12, 2022
f5ed56f
update fit variable for background scripts
emanueledimarco Jul 12, 2022
f00e0eb
datacard step fixes for systematics
emanueledimarco Jul 12, 2022
fc4f53b
add the step calcPhotonSyst for the signal fit
emanueledimarco Jul 12, 2022
7a3c914
Merge pull request #8 from emanueledimarco/vbfac-dev
emanueledimarco Jul 12, 2022
d0917e0
updates
emanueledimarco Aug 31, 2022
bd5f263
updates
emanueledimarco Aug 31, 2022
dd8dc6a
updates to the fits
emanueledimarco Aug 31, 2022
93da878
exclude empty categories from datacard
emanueledimarco Aug 31, 2022
8701b39
update the plotting part
emanueledimarco Aug 31, 2022
1099f2d
Merge pull request #9 from emanueledimarco/vbfac-dev
emanueledimarco Aug 31, 2022
5086409
separate the different AC modes in the mapping
emanueledimarco Aug 31, 2022
bbdac65
separate the different AC modes in the mapping
emanueledimarco Aug 31, 2022
0532581
datacard making with only the populated categories
emanueledimarco Aug 31, 2022
934a3ae
include the alternative VBF signals
emanueledimarco Sep 1, 2022
b7b93a0
automatize datacards creation with run_sequence script
emanueledimarco Sep 1, 2022
3e9d9be
automatize the workspace creation and the fit part (not complete yet)
emanueledimarco Sep 1, 2022
1ea0d8d
Merge pull request #10 from emanueledimarco/vbfac-dev
emanueledimarco Sep 1, 2022
80e0652
updates for tables
emanueledimarco Sep 5, 2022
04f7e82
renamed pois_cp.json in the specific one for flambda1, fa3, etc. Need…
emanueledimarco Sep 5, 2022
e3e1d97
Merge pull request #11 from emanueledimarco/vbfac-dev
emanueledimarco Sep 5, 2022
85b66a0
fix the format of the table and run it directly from the directory wi…
emanueledimarco Sep 5, 2022
2ddde14
small fixes to yields tables
emanueledimarco Sep 6, 2022
155b40d
Merge pull request #12 from emanueledimarco/vbfac-dev
emanueledimarco Sep 6, 2022
1a264ec
add the f=0.5 samples to introduce the interference term, fix the sam…
emanueledimarco Sep 8, 2022
f1fbea3
further fixes to include additional BSM samples
emanueledimarco Sep 12, 2022
c320123
many updates needed to include the interference. Need a signal model …
emanueledimarco Sep 15, 2022
151f8bf
add the name of the alternative model at the end of the suffix
emanueledimarco Oct 21, 2022
fe68292
move to the UL samples (also dividing 2016 in pre- and post-VFP) and …
emanueledimarco Oct 28, 2022
f9e6bb5
stupid date change
emanueledimarco Oct 28, 2022
c39a7ed
updates for UL
emanueledimarco Dec 6, 2022
bbe5dcc
further UL updates
emanueledimarco Dec 6, 2022
080bd80
change names conventions for alt model suffixes
emanueledimarco Dec 13, 2022
f40c264
updates using the UL samples
emanueledimarco Jan 11, 2023
546af25
changes to allow VBF AC Trees2WS
emanueledimarco Feb 1, 2023
594ca8d
Merge pull request #13 from emanueledimarco/vbfac-dev
emanueledimarco Feb 1, 2023
e65cd46
changes to add systematics to the tree2ws scripts and add the possibi…
emanueledimarco Feb 3, 2023
3a363c5
fix the bash setup script
emanueledimarco Feb 3, 2023
22e56d2
add Rome Tier2 submission with LSF, with minimal modification to IC
emanueledimarco Feb 3, 2023
fb07146
fix the signalFromFileName for ALT models
emanueledimarco Feb 3, 2023
b718a00
fix for L1Zg file to proc name
emanueledimarco Feb 3, 2023
df1a593
change the WSRenamer script
emanueledimarco Feb 10, 2023
13a13f4
run all the three years together (tree2ws)
emanueledimarco Feb 10, 2023
6a93cac
fix the passing of the input mass to tree2ws
emanueledimarco Feb 10, 2023
f3ee507
reintroduce the mass in the name of the ws
emanueledimarco Feb 10, 2023
1b5f049
new process mapping
emanueledimarco Feb 10, 2023
1168979
back the mass in the RooDataSet name
emanueledimarco Feb 14, 2023
2e89d39
put back all the STXS cats (with modified VBF ones)
emanueledimarco Feb 14, 2023
66166a3
add Rome Tier2
emanueledimarco Feb 14, 2023
5fbecd0
add the possibility to select processes with regexp when submitting t…
emanueledimarco Feb 14, 2023
31c4c1f
fix again the proc2data map
emanueledimarco Feb 14, 2023
bb11962
can do all the 3 years together
emanueledimarco Feb 14, 2023
6c96515
Merge pull request #14 from emanueledimarco/vbfac-dev
emanueledimarco Feb 14, 2023
0376684
add a protection in rare cases of 0 sumweights in simultaneousFit.py
emanueledimarco Feb 14, 2023
0f77e06
update the signalFit
emanueledimarco Feb 15, 2023
69505e0
fix few problematic replacements
emanueledimarco Feb 17, 2023
2d1ea9d
fixes in the Signal run_sequences
emanueledimarco Feb 17, 2023
7bf78f7
further fixes to the replacements and XSBR maps
emanueledimarco Feb 17, 2023
4be5a91
yet another fix in the replacementMap
emanueledimarco Feb 18, 2023
cb304b7
fix a bug in RunPlotter making it crashing for one proc and multiple …
emanueledimarco Feb 24, 2023
d8d6c91
add a script to check that all the signal fits are done (useful for m…
emanueledimarco Feb 28, 2023
ab1b756
updates to the signal sequence of commands
emanueledimarco Feb 28, 2023
b90fab9
updates to the background scripts for all STXS categories
emanueledimarco Feb 28, 2023
b050f57
fix bkg submission script
emanueledimarco Feb 28, 2023
23e8fc5
update Datacard making for full STXS + AC
emanueledimarco Feb 28, 2023
c433e92
update the nominal dataset name back with mH in makeYields
emanueledimarco Feb 28, 2023
84549f3
fix for the cases with 0 signal yield
emanueledimarco Mar 1, 2023
563d307
add back some theory systematics and put a fix for alphaS syst in cal…
emanueledimarco Mar 2, 2023
9d34a41
fix for names in yields sequence
emanueledimarco Mar 2, 2023
c9df709
give the ext by argument to checkYields
emanueledimarco Mar 2, 2023
2e4e480
add a check if the systematic is actually in the ws (for case of samp…
emanueledimarco Mar 3, 2023
0d14bdf
add the possibility to remove one category at the level of makeDataca…
emanueledimarco Mar 3, 2023
b94e549
final fixes in the making of STXS AC datacards making
emanueledimarco Mar 3, 2023
12a6433
update in Combine for AC analysis
emanueledimarco Mar 3, 2023
45ae7e3
fix xsec models
emanueledimarco Mar 3, 2023
e2fc455
add specific translations for multipple mu fits and for AC fits
emanueledimarco Mar 14, 2023
c1a9756
big update for the AC fits (new models, new combine fit options for f…
emanueledimarco Mar 14, 2023
33a2710
big updates in plotting for new AC fits
emanueledimarco Mar 14, 2023
44fcb31
Merge pull request #15 from emanueledimarco/vbfac-dev
emanueledimarco Mar 14, 2023
9decce1
add a tool to run impacts
emanueledimarco Mar 17, 2023
0c6aacf
fixed bug in run_sequence
May 31, 2023
61a2d6a
Merge pull request #16 from raeubaen/vbfac-dev
emanueledimarco May 31, 2023
490be23
Merge remote-tracking branch 'origin/dev_fggfinalfits_lite' into dev_…
Nov 17, 2023
3b08950
Adjustment for AC H gamma gamma
federicaderiggi Mar 20, 2024
be624e9
last updates for impact plots
emanueledimarco Mar 26, 2024
a1654dc
Merge pull request #17 from emanueledimarco/vbfac-dev
emanueledimarco Mar 26, 2024
fb1752a
changes in inputs.json and run sequence.sh adding also dir runImpact…
Mar 28, 2024
1ce8b56
changes in TreeWS
Mar 28, 2024
9935bbd
changes in inputs.json and run sequence.sh adding also dir runImpact…
Mar 28, 2024
b653fb2
change in file tools/commonTools for changhing the name of the proces…
federicaderiggi Apr 15, 2024
5da6332
First commit with a bunch of stuff
Apr 15, 2024
635e318
File changes
Apr 15, 2024
a34baa2
changing Datacard/run_sequence.sh
federicaderiggi Apr 15, 2024
52aae6f
Stop tracking runFitsxsec_xsec
Apr 15, 2024
9016b6f
remove Fast Scan from Combine/inputs.json
Apr 15, 2024
86ec991
adding Read_pkl.py
federicaderiggi Apr 15, 2024
8fea753
RunYields.py changes for lxplus
Apr 15, 2024
7452c03
adding ../tools/commonTools.py changed
Apr 15, 2024
58e2604
change in systematics
federicaderiggi Apr 15, 2024
ab80a01
resolve conflicts
Apr 15, 2024
7148067
theory systematics in order
Apr 15, 2024
8919a38
adding differences for wminus and wplus
Apr 15, 2024
924d98b
Changing in the inputs.json file
May 3, 2024
9061c19
q
May 3, 2024
5d316d8
change in the inputs.json (no more n_bkg_WH_TAG0=4)
federicaderiggi Jul 16, 2024
633a9e4
minor change in collectFit
federicaderiggi Jul 19, 2024
20872a0
RunText2Workspace.py mass different
federicaderiggi Jul 20, 2024
1e4c84d
rimuovere runFitsALT_0M_ALT_0M da git
federicaderiggi Jul 21, 2024
9585fee
cambio in gitIgnore to exlude the directory runFits and runImpacts
federicaderiggi Jul 21, 2024
a872229
remove from remote repository runFits and runImpacts directory
federicaderiggi Jul 21, 2024
46753b0
Update .gitignore to ignore all subdirectories in BiasNominal
federicaderiggi Jul 21, 2024
f5c4abc
minor change
federicaderiggi Jul 21, 2024
7f321f8
Bias Study for lxplus
federicaderiggi Jul 21, 2024
658aae7
adding json file for plot
federicaderiggi Jul 21, 2024
078d721
chatge in cats_latex.json
federicaderiggi Aug 3, 2024
e00d1af
change in Signal/tool
federicaderiggi Aug 5, 2024
70e8a12
change in tools/commonTools.py
federicaderiggi Aug 5, 2024
44f0f2a
change in cats_latex.json & makeYieldsTables.py
federicaderiggi Aug 8, 2024
6cd7feb
adding reweight at 2018 for vbf and ggh
federicaderiggi Sep 10, 2024
feec116
adding run_sequence_breakdown_proc
federicaderiggi Oct 22, 2024
614a4bf
specified cats to resolve the bug on tree from 2017
federicaderiggi Oct 28, 2024
d451b54
change in run_sequence
federicaderiggi Nov 3, 2024
a25c4d3
change in Read PKL
federicaderiggi Nov 8, 2024
5279074
adding total yield write file in t2ws-mc
federicaderiggi Nov 11, 2024
339fc82
adding a script for the cards replacement Cards_replacement.py
federicaderiggi Nov 11, 2024
1fd1a41
small change in tree2ws
federicaderiggi Nov 11, 2024
4c82ee0
add some steps in run sequence
federicaderiggi Nov 11, 2024
57ae093
small change in changeName cardsReplacement
federicaderiggi Nov 11, 2024
1e26a21
change in Signal/tools/finalModel.py
federicaderiggi Nov 11, 2024
285ba9c
minor change
federicaderiggi Nov 15, 2024
2be668e
change In tree2WS to add the file with the NOTAG cat
federicaderiggi Nov 16, 2024
c01236d
change in scripts/getEffAcc.py to take the File NOTAG for the eff
federicaderiggi Nov 16, 2024
388b9fa
add file CardsReplacement.csv
federicaderiggi Nov 17, 2024
6f62d65
remove weight for no full production in vbf and ggh in trees2ws
federicaderiggi Nov 17, 2024
a1e9c48
merge correction
federicaderiggi Nov 17, 2024
8acb25c
delete of a file in Checks/Bias_nominal/
federicaderiggi Nov 16, 2024
d76a9f5
Adding step to calculate Eff
federicaderiggi Nov 19, 2024
27ed89c
resolved issued with dame of process to create eff files
federicaderiggi Nov 19, 2024
31ed0d5
remove a print makeDatacard.py
federicaderiggi Nov 20, 2024
6874f7b
adding doEff in signal fit
federicaderiggi Nov 20, 2024
f2463a6
change finalModel to add skipCOWCorr at the name of the doEffAccFromJ…
federicaderiggi Nov 20, 2024
e605ced
change in the model to remove the GGH Alt model that we do not use
federicaderiggi Nov 21, 2024
34390cb
add doSystematics in run sequence
federicaderiggi Nov 22, 2024
aef3ac8
adding way to calculate and store the yield during the signal Fit
federicaderiggi Nov 23, 2024
3f4190b
change into signalFit.py such a way that it takes ino account luminos…
federicaderiggi Nov 28, 2024
4b701af
changing in run_sequence_breakdown_proc.sh
federicaderiggi Dec 2, 2024
c6e933b
change in signalFit.py to also add the yields
federicaderiggi Dec 2, 2024
b31f77b
changing in ../Signal/tools/finalModel.py to include ea
federicaderiggi Dec 2, 2024
93cc1bc
Git add the Directory Yields to create the table for the Entries
federicaderiggi Dec 2, 2024
c9a514b
Adding Datacard_ALT_0M.root produced for December
federicaderiggi Dec 16, 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
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,41 @@ AutoDict_*
*.tmp
*.pcm
*.o
*.swo
*.swm
*.swn
*Test*
*TEST*

# Output dirs in signal and bkg
Signal/outdir_*
Signal/card*
Trees2WS/TEST*
Trees2WS/outdir*
Plots/SplusBModel*
Trees2WS/Merge*
Plots/pkl*
Trees2WS/card*
Trees2WS/scrip*


Background/outdir_*
Background/cards*
Background/bin*
Background/lib*
Background/plot*


Combine/runFits*
Combine/runImpact*
Combine/t2w_jobs*
Combine/Models*
Combine/plot*

Datacard/yields*
Datacard/cards*
Datacard/Models*
Merge


Combine/Checks/Bias_nominal/*/
6 changes: 5 additions & 1 deletion Background/RunBackgroundScripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def leave():
options['lumi'] = lumiMap[_cfg['year']]
options['batch'] = _cfg['batch']
options['queue'] = _cfg['queue']
options['xvar'] = _cfg['xvar']
options['plotdir'] = _cfg['plotdir'] if 'plotdir' in _cfg else swd__

# Options from command line
options['mode'] = opt.mode
Expand All @@ -69,7 +71,8 @@ def leave():
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# If cat == auto: extract list of categories from datafile
if options['cats'] == 'auto':
options['cats'] = extractListOfCatsFromData(options['dataFile'])
print options['dataFile']
options['cats'] = extractListOfCatsFromData(options['dataFile'])
options['nCats'] = len(options['cats'].split(","))

# Add dummy entries for procs and signalFitWSFile (used in old plotting script)
Expand All @@ -82,6 +85,7 @@ def leave():
print " --> Categories: %s"%options['cats']
print " --> Extension: %s"%options['ext']
print " --> Category offset: %g"%options['catOffset']
print " --> Variable to fit: %s"%options['xvar']
print " --> Year: %s ::: Corresponds to intLumi = %s fb^-1"%(options['year'],options['lumi'])
print ""
print " --> Job information:"
Expand Down
20 changes: 11 additions & 9 deletions Background/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

backgroundScriptCfg = {

# Setup
'inputWSDir':'/vols/cms/jl2117/hgg/ws/UL/Sept20/merged_data', # location of 'allData.root' file
'cats':'auto', # auto: automatically inferred from input ws
'catOffset':0, # add offset to category numbers (useful for categories from different allData.root files)
'ext':'test', # extension to add to output directory
'year':'combined', # Use combined when merging all years in category (for plots)
# Setup
'inputWSDir':'cards/', # location of 'allData.root' file
'cats':'auto', # auto: automatically inferred from input ws
'catOffset':0, # add offset to category numbers (useful for categories from different allData.root files)
'ext':'allData', # extension to add to output directory
'year':'combined', # Use combined when merging all years in category (for plots)
'xvar': 'CMS_hgg_mass', # not yet used, should be passed to the C++ macros
'plotdir': 'plots',

# Job submission options
'batch':'IC', # [condor,SGE,IC,local]
'queue':'hep.q' # for condor e.g. microcentury
# Job submission options
'batch':'condor', # [condor,SGE,IC,Rome,local]
'queue':'espresso' # for condor e.g. espresso

}
24 changes: 19 additions & 5 deletions Background/runBackgroundScripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ BATCH=""
QUEUE=""
YEAR="2016"
CATOFFSET=0
PLOTDIR=""

usage(){
echo "The script runs background scripts:"
Expand All @@ -36,21 +37,22 @@ echo "--pseudoDataOnly) "
echo "--pseudoDataDat)"
echo "--sigFile) "
echo "--bkgPlotsOnly)"
echo "--seed) for pseudodata random number gen seed (default $SEED)"
echo "--seed) for pseudodata random number gen seed (default $SEED))"
echo "--intLumi) specified in fb^-{1} (default $INTLUMI)) "
echo "--year) dataset year (default $YEAR)) "
echo "--isData) specified in fb^-{1} (default $DATA)) "
echo "--unblind) specified in fb^-{1} (default $UNBLIND)) "
echo "--batch) which batch system to use (None (''),HTCONDOR,IC) (default '$BATCH')) "
echo "--queue) queue to submit jobs to (specific to batch))"
echo "--pdir) directory where to put the plots)"
}


#------------------------------ parsing


# options may be followed by one colon to indicate they have a required argument
if ! options=$(getopt -u -o hi:p:f: -l help,inputFile:,procs:,flashggCats:,ext:,catOffset:,fTestOnly,pseudoDataOnly,bkgPlotsOnly,pseudoDataDat:,sigFile:,seed:,intLumi:,year:,unblind,isData,batch:,queue: -- "$@")
if ! options=$(getopt -u -o hi:p:f: -l help,inputFile:,procs:,flashggCats:,ext:,catOffset:,fTestOnly,pseudoDataOnly,bkgPlotsOnly,pseudoDataDat:,sigFile:,seed:,intLumi:,year:,unblind,isData,batch:,queue:,pdir: -- "$@")
then
# something went wrong, getopt will put out an error message for us
exit 1
Expand Down Expand Up @@ -78,6 +80,7 @@ case $1 in
--unblind) UNBLIND=1;;
--batch) BATCH=$2; shift;;
--queue) QUEUE=$2; shift;;
--pdir) PLOTDIR=$2; shift;;

(--) shift; break;;
(-*) usage; echo "$0: error - unrecognized option $1" 1>&2; usage >> /dev/stderr; exit 1;;
Expand All @@ -88,7 +91,11 @@ done


OUTDIR="outdir_${EXT}"
echo "[INFO] outdir is $OUTDIR, INTLUMI $INTLUMI"
if [[ $PLOTDIR == "" ]]; then
PLOTDIR=$OUTDIR
fi

echo "[INFO] outdir is $OUTDIR, plotdir is $PLOTDIR INTLUMI $INTLUMI"

if [ $ISDATA == 1 ]; then
DATAEXT="-Data"
Expand All @@ -97,6 +104,7 @@ echo "INTLUMI is $INTLUMI, YEAR is $YEAR"
OUTDIR="outdir_${EXT}"

mkdir -p $OUTDIR
mkdir -p $PLOTDIR

if [ $FTESTONLY == 0 -a $PSEUDODATAONLY == 0 -a $BKGPLOTSONLY == 0 ]; then
#IF not particular script specified, run all!
Expand Down Expand Up @@ -147,7 +155,7 @@ if [ $FTESTONLY == 1 ]; then

echo "--------------------------------------"
echo "Running Background F-Test"
echo "-->Greate background model"
echo "-->Create background model"
echo "--------------------------------------"
if [ $UNBLIND == 1 ]; then
OPT=" --unblind"
Expand All @@ -159,8 +167,14 @@ if [ $ISDATA == 1 ]; then
OPT=" --isData 1"
fi

mkdir -p "${PLOTDIR}/bkgfTest${DATAEXT}"
if test -f "/afs/cern.ch/user/g/gpetrucc/php/index.php"; then
cp "/afs/cern.ch/user/g/gpetrucc/php/index.php" "${PLOTDIR}/bkgfTest${DATAEXT}"
elif test -f "/cmshome/dimarcoe/php/index.php"; then
cp "/cmshome/dimarcoe/php/index.php" "${PLOTDIR}/bkgfTest${DATAEXT}"
fi
echo " ./bin/fTest -i $FILE --saveMultiPdf $OUTDIR/CMS-HGG_multipdf_$EXT_$CATS.root -D $OUTDIR/bkgfTest$DATAEXT -f $CATS $OPT --year $YEAR --catOffset $CATOFFSET"
./bin/fTest -i $FILE --saveMultiPdf $OUTDIR/CMS-HGG_multipdf_$EXT_$CATS.root -D $OUTDIR/bkgfTest$DATAEXT -f $CATS $OPT --year $YEAR --catOffset $CATOFFSET
./bin/fTest -i $FILE --saveMultiPdf $OUTDIR/CMS-HGG_multipdf_$EXT_$CATS.root -D $OUTDIR/bkgfTest$DATAEXT -P $PLOTDIR/bkgfTest$DATAEXT -f $CATS $OPT --year $YEAR --catOffset $CATOFFSET

OPT=""
fi
Expand Down
2 changes: 2 additions & 0 deletions Background/run_sequence.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#python scripts/mergeMultiYearsData.py -i cards/cards_current -o cards/cards_current/data_Run2/allData.root
python RunBackgroundScripts.py --inputConfig config_test.py --mode fTestParallel
53 changes: 53 additions & 0 deletions Background/scripts/mergeMultiYearsData.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python

import sys
import glob
import ROOT
from optparse import OptionParser
from commonTools import *

def get_options():
parser = OptionParser()
parser.add_option("-i","--inputdir", dest="idir", default="cards/cards_current", help="Input directory")
parser.add_option("-o","--outfile", dest="outfile", default="allData.root", help="Outputfile")
parser.add_option("--years", dest="years", default="2016,2017,2018", help="Merge the datasets of the following years")
return parser.parse_args()
(opt,args) = get_options()

files = args[:]


#Extract all files to be merged
fNames = {}
for year in opt.years.split(","): fNames[year] = glob.glob("%s/data_%s/output_Data_13TeV.root"%(opt.idir,year))

cats = extractListOfCats(fNames[opt.years.split(",")[0]]).split(',')

# Define ouput merged workspace
print " --> Merging output workspaces"
mergedWS = ROOT.RooWorkspace("cms_hgg_13TeV","cms_hgg_13TeV")
mergedWS.imp = getattr(mergedWS,"import")

# Extract merged datasets
data_merged = {}
data_merged_names = []
for cat in cats:
data_merged["Data_13TeV_%s" % cat] = ROOT.TFile(fNames[opt.years.split(",")[0]][0]).Get("tagsDumper/cms_hgg_13TeV").data("Data_13TeV_%s" % cat).emptyClone("Data_13TeV_%s" % cat)
data_merged_names.append( data_merged["Data_13TeV_%s" % cat].GetName() )

for year, fNames in fNames.iteritems():
for fName in fNames:
for cat in cats:
d = ROOT.TFile(fName).Get("tagsDumper/cms_hgg_13TeV").data("Data_13TeV_%s" % cat)
print "YEAR = %-6s, CAT = %-30s, n = %d" % (year,cat,d.numEntries())
for i in range(d.numEntries()):
p = d.get(i)
data_merged["Data_13TeV_%s" % cat].add(p)

print " --> Writing to: %s"%(opt.outfile)
f = ROOT.TFile(opt.outfile,"RECREATE")
f.mkdir("tagsDumper")
f.cd("tagsDumper")
for _data in data_merged.itervalues(): mergedWS.imp(_data)
mergedWS.Write()
f.Close()
11 changes: 8 additions & 3 deletions Background/src/PdfModelBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "RooConstVar.h"
#include "RooFitResult.h"
#include "RooRandom.h"
#include <stdio.h>

#include "boost/algorithm/string/split.hpp"
#include "boost/algorithm/string/classification.hpp"
Expand Down Expand Up @@ -92,6 +93,10 @@ RooAbsPdf* PdfModelBuilder::getChebychev(string prefix, int order){
}

RooAbsPdf* PdfModelBuilder::getBernstein(string prefix, int order){

//if (order >3) {return NULL;}



RooArgList *coeffList = new RooArgList();
//coeffList->add(RooConst(1.0)); // no need for cnstant in this interface
Expand Down Expand Up @@ -123,9 +128,9 @@ RooAbsPdf* PdfModelBuilder::getBernstein(string prefix, int order){
} else if (order==6) {
RooBernsteinFast<6> *bern = new RooBernsteinFast<6>(prefix.c_str(),prefix.c_str(),*obs_var,*coeffList);
return bern;
// } else if (order==7) {
// RooBernsteinFast<7> *bern = new RooBernsteinFast<7>(prefix.c_str(),prefix.c_str(),*obs_var,*coeffList);
// return bern;
} else if (order==7) {
RooBernsteinFast<7> *bern = new RooBernsteinFast<7>(prefix.c_str(),prefix.c_str(),*obs_var,*coeffList);
return bern;
} else {
return NULL;
}
Expand Down
17 changes: 11 additions & 6 deletions Background/test/fTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ RooRealVar *intLumi_ = new RooRealVar("IntLumi","hacked int lumi", 1000.);
TRandom3 *RandomGen = new TRandom3();

RooAbsPdf* getPdf(PdfModelBuilder &pdfsModel, string type, int order, const char* ext=""){


if (type=="Bernstein") return pdfsModel.getBernstein(Form("%s_bern%d",ext,order),order);
else if (type=="Chebychev") return pdfsModel.getChebychev(Form("%s_cheb%d",ext,order),order);
Expand Down Expand Up @@ -608,6 +609,7 @@ int main(int argc, char* argv[]){
int catOffset;
string datfile;
string outDir;
string plotDir;
string outfilename;
bool is2011=false;
bool verbose=false;
Expand All @@ -624,7 +626,8 @@ int main(int argc, char* argv[]){
("ncats,c", po::value<int>(&ncats)->default_value(5), "Number of categories")
("singleCat", po::value<int>(&singleCategory)->default_value(-1), "Run A single Category")
("datfile,d", po::value<string>(&datfile)->default_value("dat/fTest.dat"), "Right results to datfile for BiasStudy")
("outDir,D", po::value<string>(&outDir)->default_value("plots/fTest"), "Out directory for plots")
("outDir,D", po::value<string>(&outDir)->default_value("plots/fTest"), "Out directory for results")
("plotDir,P", po::value<string>(&plotDir)->default_value("plots/fTest"), "Out directory for plots")
("saveMultiPdf", po::value<string>(&outfilename), "Save a MultiPdf model with the appropriate pdfs")
("runFtestCheckWithToys", "When running the F-test, use toys to calculate pvals (and make plots) ")
("is2011", "Run 2011 config")
Expand Down Expand Up @@ -676,6 +679,7 @@ int main(int argc, char* argv[]){
}

system(Form("mkdir -p %s",outDir.c_str()));
system(Form("mkdir -p %s",plotDir.c_str()));
TFile *inFile = TFile::Open(fileName.c_str());
RooWorkspace *inWS;
if(isFlashgg_){
Expand Down Expand Up @@ -845,14 +849,14 @@ int main(int argc, char* argv[]){
if (chi2<0. && order>1) chi2=0.;
if (prev_pdf!=NULL){
prob = getProbabilityFtest(chi2,order-prev_order,prev_pdf,bkgPdf,mass,data
,Form("%s/Ftest_from_%s%d_cat%d.pdf",outDir.c_str(),funcType->c_str(),order,(cat+catOffset)));
,Form("%s/Ftest_from_%s%d_cat%d.pdf",plotDir.c_str(),funcType->c_str(),order,(cat+catOffset)));
std::cout << "[INFO] F-test Prob(chi2>chi2(data)) == " << prob << std::endl;
} else {
prob = 0;
}
double gofProb=0;
// otherwise we get it later ...
if (!saveMultiPdf) plot(mass,bkgPdf,data,Form("%s/%s%d_cat%d.pdf",outDir.c_str(),funcType->c_str(),order,(cat+catOffset)),flashggCats_,fitStatus,&gofProb);
if (!saveMultiPdf) plot(mass,bkgPdf,data,Form("%s/%s%d_cat%d.pdf",plotDir.c_str(),funcType->c_str(),order,(cat+catOffset)),flashggCats_,fitStatus,&gofProb);
cout << "[INFO]\t " << *funcType << " " << order << " " << prevNll << " " << thisNll << " " << chi2 << " " << prob << endl;
//fprintf(resFile,"%15s && %d && %10.2f && %10.2f && %10.2f \\\\\n",funcType->c_str(),order,thisNll,chi2,prob);
prevNll=thisNll;
Expand Down Expand Up @@ -908,7 +912,7 @@ int main(int argc, char* argv[]){

// Calculate goodness of fit for the thing to be included (will use toys for lowstats)!
double gofProb =0;
plot(mass,bkgPdf,data,Form("%s/%s%d_cat%d.pdf",outDir.c_str(),funcType->c_str(),order,(cat+catOffset)),flashggCats_,fitStatus,&gofProb);
plot(mass,bkgPdf,data,Form("%s/%s%d_cat%d.pdf",plotDir.c_str(),funcType->c_str(),order,(cat+catOffset)),flashggCats_,fitStatus,&gofProb);

if ((prob < upperEnvThreshold) ) { // Looser requirements for the envelope

Expand Down Expand Up @@ -944,7 +948,7 @@ int main(int argc, char* argv[]){
choices_envelope_vec.push_back(choices_envelope);
pdfs_vec.push_back(pdfs);

plot(mass,pdfs,data,Form("%s/truths_cat%d",outDir.c_str(),(cat+catOffset)),flashggCats_,cat);
plot(mass,pdfs,data,Form("%s/truths_cat%d",plotDir.c_str(),(cat+catOffset)),flashggCats_,cat);

if (saveMultiPdf){

Expand All @@ -967,6 +971,7 @@ int main(int argc, char* argv[]){
//double check the best pdf!
int bestFitPdfIndex = getBestFitFunction(pdf,data,&catIndex,!verbose);
catIndex.setIndex(bestFitPdfIndex);

std::cout << "// ------------------------------------------------------------------------- //" <<std::endl;
std::cout << "[INFO] Created MultiPdf " << pdf->GetName() << ", in Category " << cat << " with a total of " << catIndex.numTypes() << " pdfs"<< std::endl;
storedPdfs.Print();
Expand All @@ -983,7 +988,7 @@ int main(int argc, char* argv[]){
outputws->import(catIndex);
outputws->import(dataBinned);
outputws->import(*data);
plot(mass,pdf,&catIndex,data,Form("%s/multipdf_%s",outDir.c_str(),catname.c_str()),flashggCats_,cat,bestFitPdfIndex);
plot(mass,pdf,&catIndex,data,Form("%s/multipdf_%s",plotDir.c_str(),catname.c_str()),flashggCats_,cat,bestFitPdfIndex);

}

Expand Down
9 changes: 5 additions & 4 deletions Background/tools/submissionTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def writeSubFiles(_opts):
c = _opts['cats'].split(",")[cidx]
co = _opts['catOffset']+cidx
_f.write("if [ $1 -eq %g ]; then\n"%cidx)
_cmd = "%s/runBackgroundScripts.sh -i %s -p %s -f %s --ext %s --catOffset %g --intLumi %s --year %s --batch %s --queue %s --sigFile %s --isData --fTest"%(bwd__,_opts['dataFile'],_opts['procs'],c,_opts['ext'],co,_opts['lumi'],_opts['year'],_opts['batch'],_opts['queue'],_opts['signalFitWSFile'])
_cmd = "%s/runBackgroundScripts.sh -i %s -p %s -f %s --ext %s --catOffset %g --intLumi %s --year %s --batch %s --queue %s --sigFile %s --isData --fTest --pdir %s"%(bwd__,_opts['dataFile'],_opts['procs'],c,_opts['ext'],co,_opts['lumi'],_opts['year'],_opts['batch'],_opts['queue'],_opts['signalFitWSFile'],_opts['plotdir'])
_f.write(" %s\n"%_cmd)
_f.write("fi\n")

Expand All @@ -73,7 +73,7 @@ def writeSubFiles(_opts):
_fsub.close()

# SGE...
if (_opts['batch'] == "IC")|(_opts['batch'] == "SGE")|(_opts['batch'] == "local" ):
if (_opts['batch'] == "IC")|(_opts['batch'] == "SGE")|(_opts['batch'] == "Rome")|(_opts['batch'] == "local" ):
_executable = "sub_%s_%s"%(_opts['mode'],_opts['ext'])

# Write details depending on mode
Expand Down Expand Up @@ -102,8 +102,9 @@ def submitFiles(_opts):
print " --> Finished submitting files"

# SGE
elif _opts['batch'] in ['IC','SGE']:
elif _opts['batch'] in ['IC','SGE','Rome']:
_executable = "sub_%s_%s"%(_opts['mode'],_opts['ext'])
_subcmd = 'bsub' if _opts['batch']=='Rome' else 'qsub'

# Extract job opts
jobOptsStr = _opts['jobOpts']
Expand All @@ -113,7 +114,7 @@ def submitFiles(_opts):
for cidx in range(_opts['nCats']):
c = _opts['cats'].split(",")[cidx]
_subfile = "%s/%s_%s"%(_jobdir,_executable,c)
cmdLine = "qsub -q hep.q %s -o %s.log -e %s.err %s.sh"%(jobOptsStr,_subfile,_subfile,_subfile)
cmdLine = "%s -q %s %s -o %s.log -e %s.err %s.sh"%(_subcmd,_opts['queue'],jobOptsStr,_subfile,_subfile,_subfile)
run(cmdLine)
print " --> Finished submitting files"

Expand Down
1 change: 1 addition & 0 deletions Combine/Checks/Bias_nominal/BiasFits
Loading