Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1684 commits
Select commit Hold shift + click to select a range
8a3c179
Update darkhiggs.py
mcremone Aug 14, 2023
7f84162
Update darkhiggs.py
mcremone Aug 14, 2023
0b2a661
still not there
Aug 16, 2023
6c83392
need to include bb lite for parameteric samples, at least
Aug 20, 2023
a4c7c84
need to include bb lite for parameteric samples, at least
Aug 20, 2023
6282a64
Update darkhiggs.py
mcremone Aug 20, 2023
15f1533
not there yet
Aug 22, 2023
2e5ce27
Update darkhiggs.py
mcremone Aug 22, 2023
3b1db49
another attempt
Aug 23, 2023
fa9d879
Update darkhiggs.py
mcremone Aug 24, 2023
1ce69ae
final attempt, maybe
Aug 27, 2023
3fb4784
Update darkhiggs.py
mcremone Aug 27, 2023
df94e53
need to include DeepTau and btag uncertainties.
Sep 5, 2023
4ad9551
Delete analysis/fitDiagnostics_Mz500_mhs90_Mdm150_expFitDiagnostics.root
mcremone Sep 5, 2023
53857b5
Delete analysis/higgsCombine_Mz500_mhs90_Mdm150_expFitDiagnostics.Fit…
mcremone Sep 5, 2023
b88886c
Delete analysis/higgsCombine_darkhiggs_Mz500_mhs90_Mdm150_expToysGood…
mcremone Sep 5, 2023
b2e17a8
Delete analysis/higgsCombine_initialFit_Asimov0.MultiDimFit.mH125.root
mcremone Sep 5, 2023
160a547
Delete analysis/higgsCombine_initialFit_Asimov1.MultiDimFit.mH125.root
mcremone Sep 5, 2023
d665638
Delete analysis/higgsCombine_initialFit_Test.MultiDimFit.mH125.root
mcremone Sep 5, 2023
b393e4f
Delete analysis/models/darkhiggs_bblite.py
mcremone Sep 5, 2023
f320bf9
Delete analysis/models/darkhiggs_bblite_mconly.py
mcremone Sep 5, 2023
6144ae0
Delete access_jupyter.log
mcremone Sep 5, 2023
ffc2bfc
Delete analysis/data/limit-exp-50.csv
mcremone Sep 5, 2023
2a150d3
Update corrections.py
mcremone Sep 5, 2023
878f442
Update corrections.py
mcremone Sep 5, 2023
87f4710
Update corrections.py
mcremone Sep 5, 2023
a1ce848
needs fixing
Sep 5, 2023
b777ef6
Update corrections.py
mcremone Sep 5, 2023
f1b21a8
Update corrections.py
mcremone Sep 5, 2023
6268f2f
btag implemented, still needs checking
Sep 5, 2023
d0f3731
Update corrections.py
mcremone Sep 9, 2023
724b5ef
Add files via upload
mcremone Sep 9, 2023
33eb250
Update corrections.py
mcremone Sep 9, 2023
9f7f616
Update darkhiggs.py
mcremone Sep 9, 2023
e0c1f5f
Update darkhiggs.py
mcremone Sep 9, 2023
f53d1db
Update darkhiggs.py
mcremone Sep 9, 2023
ee22ca3
rochester seems to be working
Sep 9, 2023
8a807dc
before implementing new tau veto
Sep 11, 2023
9e5aeac
Update darkhiggs.py
mcremone Sep 11, 2023
201ebae
Update ids.py
mcremone Sep 11, 2023
1d572fe
btag fixed
Sep 12, 2023
6335389
new plots with the changes
Sep 12, 2023
15e57a4
need to check plots
Sep 13, 2023
a1ad1a5
new 2018 plots
Sep 13, 2023
39c138f
deep tau and rochester fixed
Sep 14, 2023
90006bd
Update doublebsf.py
mcremone Sep 15, 2023
909b287
new sf measurement
Sep 16, 2023
61aa8da
Update doublebsf.py
mcremone Sep 16, 2023
5c8e98c
new sf results
Sep 17, 2023
c415267
new corrections
Sep 22, 2023
24a902b
btag syst hopefully fixed
Sep 22, 2023
77b191b
btag syst hopefully fixed
Sep 22, 2023
dde4588
Update darkhiggs.py
mcremone Sep 22, 2023
df12373
some new plots
Sep 23, 2023
1c175e9
new prefit plots
Sep 24, 2023
357ee5c
need to deal with doubleb syst
Sep 26, 2023
d3a6210
checkpoint: working model with stat unc
Sep 27, 2023
5034c77
Update darkhiggs.py
mcremone Sep 27, 2023
6c13458
Update darkhiggs.py
mcremone Sep 27, 2023
76b8478
checkpoint 2: full BB lite finally work
Sep 29, 2023
58c820f
Update corrections.py
mcremone Sep 29, 2023
6918a47
Update darkhiggs.py
mcremone Sep 29, 2023
4a486b7
plots with no doubleb syst
Sep 30, 2023
57a6a39
almost there
Sep 30, 2023
189d5f9
Add files via upload
mcremone Sep 30, 2023
bf660ac
Delete analysis/notebooks/Untitled.ipynb
mcremone Sep 30, 2023
4892f2e
new sf plots
Sep 30, 2023
503b228
new postfit plots
Oct 1, 2023
5382eb0
before implementing 1a method for btag weight
Oct 11, 2023
a425819
Update corrections.py
mcremone Oct 11, 2023
52e5f67
Update darkhiggs.py
mcremone Oct 11, 2023
52efa35
Update corrections.py
mcremone Oct 11, 2023
385c8df
various fixes for talk before preapproval
Oct 19, 2023
b3ffc11
fix 2016 plots
Nov 3, 2023
bfcf3ee
new plots
Nov 27, 2023
35b2930
new doubleb plots
Nov 28, 2023
1ce320f
new pulls
Nov 28, 2023
c70891e
needs some fixing
Nov 28, 2023
11318a8
to work on mc stats
Nov 28, 2023
8e989f5
Update darkhiggs.py
mcremone Nov 28, 2023
04f8bb9
before reimplementing full bb-lite
Feb 14, 2024
a57eeaf
Rename darkhiggs.py to darkhiggs_nobblite.py
mcremone Feb 14, 2024
b3b8d25
Create darkhiggs.py
mcremone Feb 14, 2024
72989f6
Update darkhiggs.py
mcremone Feb 14, 2024
28da2e0
Update darkhiggs.py
mcremone Feb 14, 2024
2b135c6
Update darkhiggs.py
mcremone Feb 14, 2024
18957d4
Update darkhiggs.py
mcremone Feb 14, 2024
0432aaa
Update darkhiggs.py
mcremone Feb 14, 2024
e349781
Update darkhiggs.py
mcremone Feb 14, 2024
d58c5c6
Update darkhiggs.py
mcremone Feb 14, 2024
cee5884
Update darkhiggs.py
mcremone Feb 14, 2024
d0f76c6
Update darkhiggs.py
mcremone Feb 14, 2024
9747a71
Update darkhiggs.py
mcremone Feb 14, 2024
8d225fe
Update darkhiggs.py
mcremone Feb 14, 2024
f9b789e
Update darkhiggs.py
mcremone Feb 14, 2024
235f95d
Update darkhiggs.py
mcremone Feb 14, 2024
d3253f8
Update darkhiggs.py
mcremone Feb 14, 2024
278f55a
still understanding
Feb 14, 2024
32baae1
some modifications
Feb 14, 2024
e6a4c3f
need to rethink this
Feb 14, 2024
d07f8ed
Update darkhiggs.py
mcremone Feb 14, 2024
40c3b94
almost there
Feb 14, 2024
b067755
almost there
Feb 14, 2024
ba4f41b
almost works
Feb 14, 2024
d79c832
Update darkhiggs.py
mcremone Feb 14, 2024
06cec0c
start fresh
Feb 15, 2024
a4b3b99
Update darkhiggs.py
mcremone Feb 16, 2024
d7b2181
Update darkhiggs.py
mcremone Feb 16, 2024
57d95ac
getting closer
Feb 16, 2024
d5175e5
Update darkhiggs.py
mcremone Feb 16, 2024
5c2a85a
Update myrhalphalib.py
mcremone Feb 18, 2024
0c7d7cd
Update merge.py
mcremone Feb 20, 2024
d668f2b
Update merge.py
mcremone Feb 21, 2024
105d170
new plots
May 22, 2024
9afa146
Merge branch 'master' of https://github.com/mcremone/decaf
May 22, 2024
b686841
adding stuff for impacts
May 25, 2024
f3a2a94
new workspace
Jun 18, 2024
201d528
Update darkhiggs.py
mcremone Jul 29, 2024
a4535b5
Update darkhiggs.py
mcremone Jul 29, 2024
a4c492e
Update render_condor.py
mcremone Jul 29, 2024
0ad91cd
Update render_condor.py
mcremone Jul 29, 2024
3910803
Update render.py
mcremone Jul 29, 2024
e6b08b3
Update render.py
mcremone Jul 29, 2024
e415bfb
fixing things
Jul 29, 2024
9696df0
Update render.sh
mcremone Jul 29, 2024
012046f
more logs
Jul 29, 2024
b3e01b3
even more logs
Jul 29, 2024
8742689
Update render.sh
mcremone Jul 29, 2024
6e614cc
Update render.sh
mcremone Jul 29, 2024
4df886b
still not working
Jul 29, 2024
d6237b7
Update render.sh
mcremone Jul 29, 2024
9ce5569
Update render.sh
mcremone Jul 29, 2024
0fee0a4
new log
Jul 29, 2024
dbb976e
Update render.sh
mcremone Jul 29, 2024
450180a
Update render.sh
mcremone Jul 29, 2024
a988120
Update render_condor.py
mcremone Jul 29, 2024
c399c3b
Update render_condor.py
mcremone Jul 29, 2024
aa90fe4
Update render_condor.py
mcremone Jul 29, 2024
2710e09
Update .gitignore
mcremone Jul 29, 2024
19022a9
Update darkhiggs.py
mcremone Jul 29, 2024
3a89980
Update render.sh
mcremone Jul 30, 2024
649bb1a
Update render.sh
mcremone Jul 30, 2024
a929513
Update convert_condor.py
mcremone Jul 30, 2024
1e2cc9e
Update convert.sh
mcremone Jul 30, 2024
146cad4
before new datacards
Jul 30, 2024
2e6cb4d
new datacards
Jul 30, 2024
5859056
Update fit_condor.py
mcremone Jul 30, 2024
5741598
Update fit.sh
mcremone Jul 30, 2024
9710f77
Delete analysis/ImpactsDoInitialFit.log
mcremone Jul 30, 2024
33f0f1c
Delete analysis/ImpactsDoInitialFitR0.log
mcremone Jul 30, 2024
4c2cc30
Delete analysis/ImpactsDoInitialFitR1.log
mcremone Jul 30, 2024
70f7f08
Delete analysis/darkhiggs-2016-fail-mass40to120-recoil2_3638489_0.stdout
mcremone Jul 30, 2024
9ae8819
Delete analysis/darkhiggs-2016-pass-mass40to120-recoil1_3638653_0.stderr
mcremone Jul 30, 2024
8d96802
Delete analysis/darkhiggs-2016-pass-mass40to120-recoil3_3638507_0.stderr
mcremone Jul 30, 2024
2784962
Delete analysis/darkhiggs-2017-pass-mass120to300-recoil1_3635445_0.st…
mcremone Jul 30, 2024
8516a7f
Delete analysis/darkhiggs-2018-fail-mass40to120-recoil3_3637151_0.stderr
mcremone Jul 30, 2024
c52e730
Delete analysis/darkhiggs-2018-fail-mass40to120-recoil3_3637151_0.stdout
mcremone Jul 30, 2024
1be0b64
Delete analysis/higgsCombine_initialFit_R0.MultiDimFit.mH125.root
mcremone Jul 30, 2024
89c77be
Delete analysis/higgsCombine_initialFit_R1.MultiDimFit.mH125.root
mcremone Jul 30, 2024
7e8f9a5
condor submit of impacts step1
Quantumapple Jul 31, 2024
4a91d2a
Merge pull request #107 from Quantumapple/master
mcremone Jul 31, 2024
eb3813f
Update fit.py
mcremone Aug 1, 2024
1c4c5d9
Update fit.py
mcremone Aug 1, 2024
1ab1e76
now save step1 outputs
Quantumapple Aug 7, 2024
51afd1d
Merge branch 'mcremone:master' into master
Quantumapple Aug 7, 2024
7bbca71
drop remap
Quantumapple Aug 7, 2024
f7afdac
Merge branch 'master' of github.com:Quantumapple/decaf
Quantumapple Aug 7, 2024
fced3fa
Merge pull request #109 from Quantumapple/master
mcremone Aug 7, 2024
c9b1c79
Create btagcorrelation.py
mcremone Aug 9, 2024
7bb7240
Update run_condor.py
mcremone Aug 9, 2024
801b1b7
Update reduce_condor.py
mcremone Aug 9, 2024
79755fe
Update merge_condor.py
mcremone Aug 9, 2024
4b987f6
Update run.sh
mcremone Aug 9, 2024
83c0e74
Update reduce.sh
mcremone Aug 9, 2024
cd9e503
Update merge.sh
mcremone Aug 9, 2024
8029f3f
Update combine_cards.py
mcremone Aug 9, 2024
5230cab
Update darkhiggs.py
erdemyigit Aug 10, 2024
2d16d26
Update darkhiggs.py
erdemyigit Aug 12, 2024
abca9d5
Merge pull request #111 from erdemyigit/master
mcremone Aug 12, 2024
8f1b1ef
Update combine_cards.py
mcremone Aug 14, 2024
01a3797
Update convert.py
mcremone Aug 14, 2024
4e5bd1e
Update simple_diffNuisances.py
mcremone Aug 15, 2024
899979c
Update simple_diffNuisances.py
mcremone Aug 15, 2024
a43851e
Update run_condor.py
mcremone Aug 17, 2024
0e198e2
Update btagcorrelation.py
mcremone Aug 17, 2024
a6dffe1
Update btagcorrelation.py
mcremone Aug 17, 2024
c43aa34
Update btagcorrelation.py
mcremone Aug 17, 2024
5276b86
Update btagcorrelation.py
mcremone Aug 17, 2024
5d80b4a
Update btagcorrelation.py
mcremone Aug 17, 2024
3a44710
Update btagcorrelation.py
mcremone Aug 17, 2024
b2e68b5
Update btagcorrelation.py
mcremone Aug 17, 2024
e8276a0
Update btagcorrelation.py
mcremone Aug 17, 2024
a7492be
Update btagcorrelation.py
mcremone Aug 17, 2024
fb93fe6
Update btagcorrelation.py
mcremone Aug 17, 2024
08dfed4
masked wsp
Aug 17, 2024
a1a5d2c
maskable workspaces
Aug 18, 2024
b984e1d
Update fit_condor.py
mcremone Aug 18, 2024
c353884
Update fit.sh
mcremone Aug 18, 2024
3255704
Update darkhiggs.py
mcremone Aug 19, 2024
4ad3402
maskable workspaces with stat unc
Aug 19, 2024
84e0747
Update simple_diffNuisances.py
mcremone Aug 19, 2024
4b6aa3b
data for pulls plot
Aug 19, 2024
8aaaede
use CMS title, tight figure layout, save as pdf
Quantumapple Aug 19, 2024
ad50221
Merge branch 'mcremone:master' into master
Quantumapple Aug 19, 2024
ccf6158
simple script to remove parameter in impacts json file
Quantumapple Aug 19, 2024
4911269
Merge pull request #113 from Quantumapple/master
mcremone Aug 19, 2024
6b9ab80
btag efficiency study completed
Aug 21, 2024
863768b
Merge branch 'master' of https://github.com/mcremone/decaf
Aug 21, 2024
bf9cf5d
adding plots
Aug 21, 2024
6da2585
unblinded datacards
Aug 29, 2024
b312150
Update darkhiggs.py
mcremone Sep 2, 2024
5033eba
unblinded no stat
Sep 2, 2024
9cde175
2016 unblinded plots
Sep 7, 2024
c4c0341
all unblinded plots
Sep 7, 2024
94837db
Update darkhiggs.py
mcremone Sep 7, 2024
fa9ca0f
Merge branch 'master' of https://github.com/mcremone/decaf
Sep 7, 2024
b0bd9fb
Update darkhiggs.py
mcremone Sep 12, 2024
70afb2e
Merge branch 'master' of https://github.com/mcremone/decaf
Sep 12, 2024
48c121f
Update run_condor.py
mcremone Sep 13, 2024
4cdeceb
Merge branch 'master' of https://github.com/mcremone/decaf
Sep 13, 2024
cc5f144
adding tagger plots
Sep 23, 2024
3dad955
adding tagger plots
Sep 23, 2024
1db7ec4
new postfit plots
Sep 28, 2024
4277f08
Update darkhiggs.py
mcremone Oct 13, 2024
e33fbdf
Update darkhiggs.py
mcremone Oct 14, 2024
06d4e23
Update corrections.py
mcremone Oct 14, 2024
4e1d208
Update darkhiggs.py
mcremone Oct 20, 2024
cc4d19a
Update darkhiggs.py
mcremone Oct 20, 2024
f6a9a79
Update darkhiggs.py
mcremone Oct 20, 2024
20d5923
Update myrhalphalib.py
mcremone Oct 20, 2024
3cb74fa
new sr postfit plots
Jan 13, 2025
709dd1f
new sr postfit plots
Jan 14, 2025
439604b
adjusting plots
Jan 14, 2025
ef042ba
adjusting plots
Jan 14, 2025
b02e629
update legend
Quantumapple Mar 3, 2025
50f60bd
nb for making combined all year plots
Quantumapple Mar 4, 2025
d338b11
Merge pull request #125 from Quantumapple/master
mcremone Mar 4, 2025
aaa17ed
add QCD legend, adjust rax legend
Quantumapple Mar 4, 2025
ce70064
Merge branch 'mcremone:master' into master
Quantumapple Mar 4, 2025
9006f99
Merge pull request #126 from Quantumapple/master
mcremone Mar 4, 2025
ed5ee45
hopefully the last change for plots
Quantumapple Mar 4, 2025
69f74d1
Merge branch 'master' of github.com:Quantumapple/decaf
Quantumapple Mar 4, 2025
9e35ab5
fix legend spelling
Quantumapple Mar 4, 2025
9bd5258
fix spelling
Quantumapple Mar 4, 2025
9b504c8
Merge pull request #127 from Quantumapple/master
mcremone Mar 9, 2025
138b699
new result plots
Mar 9, 2025
db6c9c3
new result plots
Mar 9, 2025
5780154
Add files via upload
mcremone Feb 1, 2026
459c042
Update darkhiggs.py
mcremone Feb 1, 2026
7deabd2
Update darkhiggs.py
mcremone Feb 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@ __pycache__
*.nfs0000003717774a2d000002c7
docker_stderror
*.futures
*.reduced
*.merged
*.scaled
*.model
*.processor
datacards*
results
219 changes: 217 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Decaf
<img src="https://user-images.githubusercontent.com/10731328/193421563-cf992d8b-8e5e-4530-9179-7dbd507d2e02.png" width="350"/>

# **D**ark matter **E**xperience with the **C**offea **A**nalysis **F**ramework
Following instructions are to run the generation of the histograms directly from NanoAOD.

## Initial Setup
Expand Down Expand Up @@ -94,7 +95,7 @@ python processors/darkhiggs.py --year 2018

The module will generate a .coffea file, stored in the ```processors``` folder, that contains the processor instance to be used in the following steps. The ```--year``` option will allow for the generation of the processor corresponding to a specific year.

### Running with Phyton futures
### Running with Python futures

Phyton futures allows for running on multiple processor on a single node. To run the local histogram generation:

Expand All @@ -114,6 +115,7 @@ python submit_condor.py --year 2018 --processor darkhiggs2018 -t

This way jobs to generate the full set of 2018 histograms will be submitted to condor. the ```-t``` will allow for tarring the working environment and the necessary dependences to run on condor nodes. The module has a ```--dataset``` option that works like described before for ```run.py```. Will allow you to run on a single batch, dataset, or batches/datasets that match the input string.

<!-- COMMENT OUT
## Running with Spark

To run with Spark, first copy your certificate to your home are on the fermicloud118 instance.
Expand Down Expand Up @@ -200,3 +202,216 @@ The script will print a link inside start_jupyter.log. Copy-paste it on your bro
```
sh stop_jupyter.sh
```
-->

## From Coffea Histograms to Fits

### Generating the model

Taking as example the dark Higgs analysis, run the following command to generate the background model, for example:

```
python models/darkhiggs.py -y 2018 -f -m 40to120
```
The ```models/darkhiggs.py``` module extracts coffea histgrams from the ```hists/darkhiggs201?.scaled``` files and utilize them to generate the different templates that will later be rendered into datacards/workspaces. It also defines transfer factors for the data-driven background models. It produces ```.model``` files that are saved into the ```data``` folder. More specifically, the ```models/darkhiggs.py``` module produces one ```.model``` file for each pass/fail and recoil bin.

Running the following command will generate all model files, and the outputs will store in the data directory:
```
./make_model.sh
```

### Rendering the model

In order for the rendering step to be completed successfully and for the resulting datacards and workspaces to be used in later steps, both the python version and the ROOT version should correspond to the ones that are going to be set when running ```combine```. It is therefore suggested to clone the ```decaf``` repository inside the ```src``` folder of ```CMSSSW``` release that will be used to perform the combine fit and run the rendering from there, without running the ```env_lcg.sh```. You should, instead, do the regular ```cmsenv``` command.
At the time of writing, the recommended version is ```CMSSW_10_2_13``` (https://cms-analysis.github.io/HiggsAnalysis-CombinedLimit/#cc7-release-cmssw_10_2_x-recommended-version). This version uses python 2.7 and ROOT 6.12.
In addition, you should install the following packages (to be done *after* ```cmsenv```):

```
pip install --user flake8
pip install --user cloudpickle
pip install --user https://github.com/nsmith-/rhalphalib/archive/master.zip
```

Finally, since we are using Python2.7, you should edit the file
```
$HOME/.local/lib/python2.7/site-packages/rhalphalib/model.py
```
and change line 94 from
```
obsmap.insert(ROOT.std.pair('const string, RooDataHist*')(channel.name, obs))
```
to
```
obsmap.insert(ROOT.std.pair('const string, RooDataHist*')(channel.name.encode("ascii"), obs))
```

and also make the following modification:

```
import ROOT
#add this line
ROOT.v5.TFormula.SetMaxima(5000000)
```

The models saved in the ```.model``` files at the previous step can be rendered into datacards by running the following command:

```
python render.py -m model_name
```

the ```-m``` or ```--model``` options provide in input the name of the model to render, that corresponds to the name of the ```.model``` file where the model is stored. The ```render.py``` module launches python futures jobs to process in parallel the different control/signal regions that belongs to a single model. Different models can also be rendered in parallel, by using condor. In order to run rendering condor job, the following command should be ran:

```
python render_condor.py -m <model_name> -c <server_name> -t -x
python render_condor.py -m darkhiggs -c kisti -t -x
```

this time, all the models stored into ```.model``` files whose name contains the sting passed via the ```-m``` options are going to be rendered.

The ```render.py``` module saves datacards and workspaces into folders that show the following naming:

```
datacards/model_name
```

The ```render_condor.py``` module returns ```.tgz``` tarballs that contain the different datacards/workspaces, and are stored into the ```datacards``` folder. To untar them, simply do:

```
python macros/untar_cards.py -a darkhiggs
```

Where the ```-a``` or ```--analysis``` options correspond to the analysis name. The ```untar_cards.py``` script will untar all the tarballs that contain the string that is passed through the ```-a``` option.
To merge the datacards, run the following script:

```
python macros/combine_cards.py -a darkhiggs
```
Where the ```-a``` or ```--analysis``` options correspond to the analysis name. The ```combine_datacards.py``` script will combine all the datacards whose name contains the string that is passed through the ```-a``` option. The script will create a folder inside ```datacards``` whose name corresponds to the string that is passed through the ```-a``` option, will move all the workspaces that correspond to the datacards it combined inside it, and will save in it the combined datacard, whose name will be set to the string that is passed through the ```-a``` option.

You can also plot the inputs from a **single** workspace with the `makeWorkspacePlots.C` macro. It stacks all the inputs in a single histogram. From the folder you have just created at the previous step, do, for example:

```
root -b -q ../../makeWorkspacePlots.C\('"zecr2018passrecoil4"',5000,2000\)
```
where the first argument (`zecr2018passrecoil4`) is the name of the workspace; the ROOT file name must be the same, but with the `.root` extension; the second argument (`5000`) is the limit of the y-axis of the stack; the third argument (`2000`) is the y-position of an explanatory label; that label will simply be the same as the first argument again.


### Using Combine

Make sure you edit your ```$CMSSW/src/HiggsAnalysis/CombinedLimit/scripts/text2workspace.py``` module as suggested below:

```
import ROOT
#add this line
ROOT.v5.TFormula.SetMaxima(5000000)
```

In the datacards directory, the directory is created based on the <model_name>. We are using the "MultiSignalModel" method to have one datacard includes all signal mass points. Please submint text2workspace job to the condor by using the following command:
```
python t2w_condor.py -a darkhiggs -c <server name> -t -x
```
Currently, \<server name\> is either `lpc` or `kisti`. The output will be saved in the same directory with the same name as the datacard.
After you get workspace, you will be able to run fit over condor by doing:
```
python combine_condor.py -a darkhiggs -c <server name> -m <method> -t -x
python combine_condor.py -a darkhiggs -c kisti -m cminfit -t -x
```

<!-- COMMENT OUT
make sure you edit your ```$CMSSW/src/HiggsAnalysis/CombinedLimit/scripts/text2workspace.py``` module as suggested below:

```
import ROOT
#add this line
ROOT.v5.TFormula.SetMaxima(5000000)
```

The result of this step will be a ```darkhiggs.root``` file to be used for the combine fit.
where ```darkhiggs.txt``` is the name of the combined datacard generated at the previous step.

#### Running special datacards

Before running the combibe tools, you have to run ```ulimit -s unlimited``` command. Feel free to add it to your ```.bashrc```. Also, modify your ```$CMSSW/src/HiggsAnalysis/CombinedLimit/bin/combine.cpp```:

```
using namespace boost;
namespace po = boost::program_options;
#add the line below
ROOT::v5::TFormula::SetMaxima(5000000);
```
Make sure you compile after making this modification. When you render the model, you can use the alternative datacards:

```
analysis/models/darkhiggs_fourregions.py
analysis/models/darkhiggs_fiveregions.py
analysis/models/darkhiggs_eightregions.py
```

that try the fit with "Signal, WMuon, TopMuon, DoubleMuon" (four);
with all those plus "Gamma" (five);
with all those plus "WEle, TopEle, DoubleEle" (eight).
In all of those the minor MCs are not added at all to the fit.
The usual `darkhiggs.py` has all eight regions + minor MCs.

Alternative fits:

Minuit:
```
combine -M FitDiagnostics -d darkhiggs.root \
--expectSignal 1 --forceRecreateNLL --cminDefaultMinimizerType Minuit \
--ignoreCovWarning --saveShapes --saveWithUncertainties --saveWorkspace --plots \
&> out_FitDiagnostics_Minuit.log
```

Minuit (fast):
Drop the options: `--saveShapes`, `--saveWorkspace`, `--plots`
```
combine -M FitDiagnostics -d darkhiggs.root \
--expectSignal 1 --forceRecreateNLL --cminDefaultMinimizerType Minuit \
--ignoreCovWarning --saveWithUncertainties &> out_FitDiagnostics_Minuit.log
```

Robust fit:
```
combine -M FitDiagnostics -d darkhiggs.root \
--expectSignal 1 --forceRecreateNLL --robustFit=1 \
--ignoreCovWarning --saveShapes --saveWithUncertainties --saveWorkspace --plots \
&> out_FitDiagnostics_robustFit.log
```
-->

## Macros

### Usage examples

```
python macros/dump_templates.py -w datacards/darkhiggs/darkhiggs.root:w --observable fjmass -o plots/darkhiggs2018/model
```
```
python macros/hessian.py -w datacards/darkhiggs/higgsCombineTest.FitDiagnostics.mH120.root:w -f datacards/darkhiggs/fitDiagnostics.root:fit_b
```
#### Pulls plotting
Change the path to store outputs in `plotConfig.py`
```
python macros/diffNuisances.py -g pulls.root ../fitDiagnostics.root
```

#### Postfit plotting - Method 1
If you use fast fit command, then the following command will make prefit and postfit histograms
```
PostFitShapesFromWorkspace -w path/to/darkhiggs.root -d path/to/darkhiggs.txt -f path/to/fitDiagnostics.root:fit_s --postfit --sampling --samples 300 --skip-proc-errs -o outputfile.root
```
To make postfit stack plots
```
python macros/postFitShapesFromWorkSpace.py path/to/outputfile.root
```
#### Postfit plotting - Method 2
This method uses the output from `dump_templates.py`.
```
python macros/combine_dump_outputs.py plots/darkhiggs2018/dump_postfit (or dump_prefit)
```
Then you get combined root files in the `plots/darkhiggs2018/dump` directory.
```
python macros/dump_darkhiggs_postfit.py plots/darkhiggs2018/dump/outputs.root
```
This will make postfit stack plots.
52 changes: 52 additions & 0 deletions analysis/convert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env python
import os
from optparse import OptionParser

if __name__ == '__main__':
parser = OptionParser()
parser.add_option('-d', '--datacard', help='datacard', dest='datacard')
parser.add_option('-o', '--outfile', help='outfile', dest='outfile')
parser.add_option('-m', '--maps', help='maps', dest='maps')
parser.add_option('-a', '--arguments', help='arguments', dest='arguments', default='--channel-masks')
(options, args) = parser.parse_args()

command = 'text2workspace.py '+options.datacard

datacard=open(options.datacard,'r')
process_lines=[]
for line in datacard.readlines():
if not line.startswith('process'): continue
process_lines.append(line.split())

signal_indices = [i for i in range(1, len(process_lines[1])) if int(process_lines[1][i]) <= 0]
signals = set([process_lines[0][i] for i in signal_indices if process_lines[0][i]])

def add_maps(command, options):
#command += ' -P HiggsAnalysis.CombinedLimit.PhysicsModel:multiSignalModel --PO verbose'
command += ' -P HiggsAnalysis.CombinedLimit.PhysicsModel:multiSignalModel'
maps= ''
for option in options.split('--PO '):
if not option: continue
if 'SIGNAL' in option:
for signal in signals:
if not all(piece in signal for piece in option.split(':')[0].split('/')[1].split('*')): continue
#if option.split(':')[0].split('/')[1].replace('*','') not in signal: continue
maps += ' --PO '+option.replace(option.split(':')[0].split('/')[1],signal).replace('SIGNAL',signal)
else:
maps += ' --PO '+option
command += maps
return command

commands=[]
if options.maps:
if 'SIGNAL:' in options.maps:
for signal in signals:
commands.append(add_maps(command, options.maps.replace('SIGNAL',signal))+' -o '+options.outfile.replace('SIGNAL',signal)+' '+options.arguments)
else:
commands.append(add_maps(command, options.maps)+' -o '+options.outfile+' '+options.arguments)
else:
commands.append(command+' -o '+options.outfile+' '+options.arguments)

for command in commands:
#print(command)
os.system(command)
53 changes: 53 additions & 0 deletions analysis/convert.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
export USER=${5}
echo "User is: ${5}"
echo "Starting job on " `date` #Date/time of start of job
echo "Running on: `uname -a`" #Condor job is running on this node
echo "System software: `cat /etc/redhat-release`" #Operating System on that node
echo $(hostname)
source /cvmfs/cms.cern.ch/cmsset_default.sh

if [ "${4}" == "kisti" ]; then
voms-proxy-info -exists
if [ $? -eq 0 ]; then
echo "No need to copy"
ls -l /tmp/x509up_u$(id -u)
voms-proxy-info -all
else
cp ./x509up_u* /tmp
ls -l /tmp/x509up_u$(id -u)
voms-proxy-info -all
fi
xrdcp -s root://cms-xrdr.private.lo:2094//xrd/store/user/$USER/cmssw.tgz .
echo "cmssw correctly copied"
else
xrdcp -s root://cmseos.fnal.gov//store/user/$USER/cmssw.tgz .
echo "cmssw correctly copied"
xrdcp -s root://cmseos.fnal.gov//store/user/$USER/py2local.tgz .
echo "py2local correctly copied"
tar -zxvf py2local.tgz
rm py2local.tgz
export PYTHONPATH=${_CONDOR_SCRATCH_DIR}/site-packages:$PYTHONPATH
export PYTHONPATH=$(find ${_CONDOR_SCRATCH_DIR}/site-packages/ -name *.egg |tr '\n' ':')$PYTHONPATH
export PYTHONWARNINGS="ignore"
echo "Updated python path: " $PYTHONPATH
fi
echo "untar cmssw"
tar -zxvf cmssw.tgz
echo "cmssw untarred"
rm cmssw.tgz
export SCRAM_ARCH=slc7_amd64_gcc700
cd CMSSW_10_2_13/src
scramv1 b ProjectRename
eval `scramv1 runtime -sh` # cmsenv is an alias not on the workers
cd decaf/analysis
if [ "${3}" == "None" ]; then
echo "python convert.py -d ${1} -o ${2}"
python convert.py -d ${1} -o ${2}
else
export maps=$( echo ${3} | tr '+' ' ' )
echo "python convert.py -d ${1} -o ${2} -m \"$maps\""
python convert.py -d ${1} -o ${2} -m "$maps"
fi
ls ${2}
cp ${2} ${_CONDOR_SCRATCH_DIR}/outfile.root
Loading