Skip to content

Commit 84d3d5a

Browse files
committed
Merge pull request #150 from gpetruc/development-merged
Merge master into development, fix one regression
2 parents 4a5a6bd + 115cca0 commit 84d3d5a

File tree

5 files changed

+119
-36
lines changed

5 files changed

+119
-36
lines changed

python/VEVandEpsilon.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,10 @@ def setup(self):
7474
# # Ellis cv == v (mv^(2 e)/M^(1 + 2 e))
7575
self.modelBuilder.factory_(
7676
'expr::C%(name)s("@0 * TMath::Power(@3,2*@2) / TMath::Power(@1,1+2*@2)", SM_VEV, M, eps, M%(name)s_MSbar)' % locals() )
77-
# # AD k = (M/v) eps m^(N(eps-1))
78-
# self.modelBuilder.factory_(
79-
# 'expr::C%(name)s("@1 * @2 * TMath::Power(@3,2*(@2-1)) / @0", SM_VEV, M, eps, M%(name)s_MSbar)' % locals() )
80-
# # GP k = (v/M)^2 (m/M)^(2eps)
81-
#self.modelBuilder.factory_(
82-
# 'expr::C%(name)s("TMath::Power(@0/@1,2) * TMath::Power(@3/@1,2*@2)", SM_VEV, M, eps, M%(name)s_MSbar)' % locals() )
8377
else:
8478
# # Ellis cf == v (mf^e/M^(1 + e))
8579
self.modelBuilder.factory_(
8680
'expr::C%(name)s("@0 * TMath::Power(@3,@2) / TMath::Power(@1,1+@2)", SM_VEV, M, eps, M%(name)s_MSbar)' % locals() )
87-
# AD k = (M/v) eps m^(N(eps-1))
88-
# self.modelBuilder.factory_(
89-
# 'expr::C%(name)s("@1 * @2 * TMath::Power(@3,@2-1) / @0", SM_VEV, M, eps, M%(name)s_MSbar)' % locals() )
90-
# GP k = (v/M) (m/M)^eps
91-
#self.modelBuilder.factory_(
92-
# 'expr::C%(name)s("(@0/@1) * TMath::Power(@3/@1,@2)", SM_VEV, M, eps, M%(name)s_MSbar)' % locals() )
9381

9482
self.productionScaling = {
9583
'ttH':'Ctop',

src/MarkovChainMC.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,32 @@ int MarkovChainMC::runOnce(RooWorkspace *w, RooStats::ModelConfig *mc_s, RooStat
298298
mcInt.reset(0);
299299
}
300300
if (mcInt.get() == 0) return false;
301+
302+
// MCMCCalculator calls SetConfidenceLevel on MCMCInterval when creating it
303+
// SetConfidenceLevel calls DetermineInterval, which compute the interval from the Markov Chain
304+
// for a given confidence level. This results is cached, so if we change the number of burn-in steps
305+
// after, it'll have no effect
306+
// Clone the MCMCInterval to reset its state, set the number of burn-in steps before calling SetConfidenceLevel
307+
308+
MCMCInterval* oldInterval = mcInt.get();
309+
RooStats::MarkovChain* clonedChain = slimChain(*mc_s->GetParametersOfInterest(), *oldInterval->GetChain());
310+
MCMCInterval* newInterval = new MCMCInterval(TString("MCMCIntervalCloned_") + TString(mc.GetName()), RooArgSet(*mc_s->GetParametersOfInterest()), *clonedChain);
311+
newInterval->SetUseKeys(oldInterval->GetUseKeys());
312+
newInterval->SetIntervalType(oldInterval->GetIntervalType());
313+
if (newInterval->GetIntervalType() == MCMCInterval::kTailFraction) {
314+
newInterval->SetLeftSideTailFraction(0);
315+
}
316+
newInterval->SetNumBurnInSteps(burnInSteps_);
317+
301318
if (adaptiveBurnIn_) {
302319
mcInt->SetNumBurnInSteps(guessBurnInSteps(*mcInt->GetChain()));
303320
} else if (mcInt->GetChain()->Size() * burnInFraction_ > burnInSteps_) {
304321
mcInt->SetNumBurnInSteps(mcInt->GetChain()->Size() * burnInFraction_);
305322
}
323+
newInterval->SetConfidenceLevel(oldInterval->ConfidenceLevel());
324+
325+
mcInt.reset(newInterval);
326+
306327
limit = mcInt->UpperLimit(*r);
307328

308329
if (saveChain_ || mergeChains_) {

src/ToyMCSamplerOpt.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ toymcoptutils::SinglePdfGenInfo::generate(const RooDataSet* protoData, int force
131131
RooDataSet *
132132
toymcoptutils::SinglePdfGenInfo::generateAsimov(RooRealVar *&weightVar, double weightScale)
133133
{
134+
if (mode_ == Counting) return generateCountingAsimov();
134135
static int nPA = runtimedef::get("TMCSO_PseudoAsimov");
135136
if (observables_.getSize() > 1 && runtimedef::get("TMCSO_AdaptivePseudoAsimov")) {
136137
int nbins = 1;

test/makeToyBkgdHist.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
########
2+
# Author: Jessica Brinson ([email protected]), The Ohio State Unversity
3+
# Date created: 7 Aug, 2014
4+
##############
5+
# Script to generate root file with a histogram containing
6+
# the simulated number of background events for a given number of toys
7+
##############
8+
# Usage: First run Higgs Combine tool, for example:
9+
# combine datacard.txt -S 0 -M GenerateOnly -t 10000 --saveToys
10+
#
11+
# The -M GenerateOnly option generates only toys without running the limits.
12+
# Greatly decreases the processing time: for a single-bin counting experiment,
13+
# can generate 10K toys in ~1 min
14+
#
15+
# Can use the --toysFreqentist to generate frequentist toys. See:
16+
# https://hypernews.cern.ch/HyperNews/CMS/get/higgs-combination/572/1/2/1/1/1.html
17+
#
18+
##############
19+
# Usage: python parseCombine.py name_of_output_root_file_from_combine_command ntoys
20+
##############
21+
#
22+
#
23+
#!/usr/bin/env python
24+
25+
import time
26+
import os
27+
import sys
28+
import math
29+
import copy
30+
import re
31+
import subprocess
32+
import glob
33+
34+
from ROOT import TF1, TFile, TH2F, gROOT, gStyle,TH1F, TCanvas, TString, TLegend, TPaveLabel, TH2D, TPave, Double
35+
36+
if len(sys.argv) < 2:
37+
print "Must specify the root file that you wish to parse."
38+
sys.exit()
39+
40+
if len(sys.argv) < 3:
41+
print "Must specify the number of toys that you ran over."
42+
sys.exit()
43+
44+
inputFile = str(sys.argv[1])
45+
nToys = int(sys.argv[2])
46+
47+
file = TFile.Open(inputFile)
48+
file.cd()
49+
50+
for key in file.GetListOfKeys():
51+
if (key.GetClassName() != "TDirectoryFile"):
52+
continue
53+
rootDirectory = key.GetName()
54+
55+
#loop over the toys and extract nToyBkgd
56+
nToyBkgdList = []
57+
for i in range (1,nToys+1):
58+
toyTemp = file.Get(rootDirectory + "/toy_" + str(i)).Clone()
59+
nToyBkgd = toyTemp.get(0).getRealValue("n_obs_binMyChan")
60+
nToyBkgdList.append(nToyBkgd)
61+
62+
# fill histogram with the number of simulated background events for each toy
63+
h = TH1F("nToyBkgd", ";background yield;number of toys", 100, float(min(nToyBkgdList)), float(max(nToyBkgdList)))
64+
for item in nToyBkgdList:
65+
h.Fill(float(item))
66+
67+
outputFileName = (inputFile).rstrip(".root")
68+
outputFile = TFile(outputFileName + "_histToyNBkgd.root", "RECREATE")
69+
h.Write()
70+
outputFile.Write()
71+
outputFile.Close()
72+
73+
print "Finished writing output to " + outputFile.GetName()

test/validation/reference.json

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -179,46 +179,46 @@
179179
},
180180
"status": "done"
181181
},
182-
"Counting_Sig_2_HybridNew": {
182+
"Counting_Freq_Sig_2_HybridNew": {
183183
"comment": "all 5 jobs done",
184184
"results": {
185-
"counting-B5p5-Obs11-StatOnly.txt": { "comment": "", "limit": 2.2776070514569495, "limitErr": 0.04169333290110222, "status": "done", "t_real": 0.026785735040903091 },
186-
"counting-B5p5-Obs11-Syst30B.txt": { "comment": "", "limit": 1.8200591344181229, "limitErr": 0.027431268744850579, "status": "done", "t_real": 0.037475399672985077 },
187-
"counting-B5p5-Obs11-Syst30C.txt": { "comment": "", "limit": 1.8200591344181229, "limitErr": 0.027431268744850579, "status": "done", "t_real": 0.037102766335010529 },
188-
"counting-B5p5-Obs11-Syst30S.txt": { "comment": "", "limit": 2.3079844749459575, "limitErr": 0.04306045560354832, "status": "done", "t_real": 0.028499431908130646 },
189-
"counting-B5p5-Obs11-Syst30U.txt": { "comment": "", "limit": 1.7866133654934699, "limitErr": 0.026728182601117423, "status": "done", "t_real": 0.049588046967983246 }
185+
"counting-B5p5-Obs11-StatOnly.txt": { "comment": "", "limit": 1.9668474600086239, "limitErr": 0.03094861407777394, "status": "done", "t_real": 0.07762125134468079 },
186+
"counting-B5p5-Obs11-Syst30B.txt": { "comment": "", "limit": 1.7410869889201568, "limitErr": 0.025811484800963624, "status": "done", "t_real": 0.16692283749580383 },
187+
"counting-B5p5-Obs11-Syst30C.txt": { "comment": "", "limit": 1.7410869889201568, "limitErr": 0.025811484800963624, "status": "done", "t_real": 0.2165507823228836 },
188+
"counting-B5p5-Obs11-Syst30S.txt": { "comment": "", "limit": 1.998114060627158, "limitErr": 0.03180700227099753, "status": "done", "t_real": 0.21559813618659973 },
189+
"counting-B5p5-Obs11-Syst30U.txt": { "comment": "", "limit": 1.693241068090133, "limitErr": 0.02492454126755006, "status": "done", "t_real": 0.2478853464126587 }
190190
},
191191
"status": "done"
192192
},
193-
"Counting_Sig_3p5_HybridNew": {
194-
"comment": "all 3 jobs done",
195-
"results": {
196-
"counting-B5p5-Obs20-Syst30B.txt": { "comment": "", "limit": 3.7455485932384569, "limitErr": 0.045518620350335492, "status": "done", "t_real": 2.4166839122772217 },
197-
"counting-B5p5-Obs20-Syst30C.txt": { "comment": "", "limit": 3.7455485932384569, "limitErr": 0.045518620350335492, "status": "done", "t_real": 2.3150513172149658 },
198-
"counting-B5p5-Obs20-Syst30U.txt": { "comment": "", "limit": 3.7319542690588556, "limitErr": 0.04433925796828575, "status": "done", "t_real": 1.9085551500320435 }
199-
},
200-
"status": "done"
201-
},
202-
"Counting_Freq_Sig_2_HybridNew": {
193+
"Counting_Sig_2_HybridNew": {
203194
"comment": "all 5 jobs done",
204195
"results": {
205-
"counting-B5p5-Obs11-StatOnly.txt": { "comment": "", "limit": 2.2776070514569495, "limitErr": 0.04169333290110222, "status": "done", "t_real": 0.10778608173131943 },
206-
"counting-B5p5-Obs11-Syst30B.txt": { "comment": "", "limit": 1.7251524629226296, "limitErr": 0.025522303734902163, "status": "done", "t_real": 0.29485902190208435 },
207-
"counting-B5p5-Obs11-Syst30C.txt": { "comment": "", "limit": 1.7251524629226296, "limitErr": 0.025522303734902163, "status": "done", "t_real": 0.29696539044380188 },
208-
"counting-B5p5-Obs11-Syst30S.txt": { "comment": "", "limit": 2.2693014570431722, "limitErr": 0.04133141935148954, "status": "done", "t_real": 0.28087267279624939 },
209-
"counting-B5p5-Obs11-Syst30U.txt": { "comment": "", "limit": 1.6993672959502422, "limitErr": 0.025047505122447689, "status": "done", "t_real": 0.3449137806892395 }
196+
"counting-B5p5-Obs11-StatOnly.txt": { "comment": "", "limit": 1.9664209967178816, "limitErr": 0.030953136229774803, "status": "done", "t_real": 0.036718133836984634 },
197+
"counting-B5p5-Obs11-Syst30B.txt": { "comment": "", "limit": 1.5412744685252837, "limitErr": 0.02249015174635627, "status": "done", "t_real": 0.04498303309082985 },
198+
"counting-B5p5-Obs11-Syst30C.txt": { "comment": "", "limit": 1.5412744685252837, "limitErr": 0.02249015174635627, "status": "done", "t_real": 0.04984373226761818 },
199+
"counting-B5p5-Obs11-Syst30S.txt": { "comment": "", "limit": 1.9557042822322015, "limitErr": 0.030668216699310413, "status": "done", "t_real": 0.04352619871497154 },
200+
"counting-B5p5-Obs11-Syst30U.txt": { "comment": "", "limit": 1.5240348730572568, "limitErr": 0.02224443031938117, "status": "done", "t_real": 0.04982691630721092 }
210201
},
211202
"status": "done"
212203
},
213204
"Counting_Freq_Sig_3p5_HybridNew": {
214205
"comment": "all 3 jobs done",
215206
"results": {
216-
"counting-B5p5-Obs20-Syst30B.txt": { "comment": "", "limit": 3.7319542690588556, "limitErr": 0.04433925796828575, "status": "done", "t_real": 18.953897476196289 },
217-
"counting-B5p5-Obs20-Syst30C.txt": { "comment": "", "limit": 3.7319542690588556, "limitErr": 0.04433925796828575, "status": "done", "t_real": 18.709600448608398 },
218-
"counting-B5p5-Obs20-Syst30U.txt": { "comment": "", "limit": 3.628565903610768, "limitErr": 0.036522131055911178, "status": "done", "t_real": 21.805641174316406 }
207+
"counting-B5p5-Obs20-Syst30B.txt": { "comment": "", "limit": 3.7319542690588556, "limitErr": 0.04433925796798999, "status": "done", "t_real": 17.05150604248047 },
208+
"counting-B5p5-Obs20-Syst30C.txt": { "comment": "", "limit": 3.7319542690588556, "limitErr": 0.04433925796798999, "status": "done", "t_real": 19.538915634155273 },
209+
"counting-B5p5-Obs20-Syst30U.txt": { "comment": "", "limit": 3.628565903610768, "limitErr": 0.036522131056103024, "status": "done", "t_real": 21.426109313964844 }
219210
},
220211
"status": "done"
221212
},
213+
"Counting_Sig_3p5_HybridNew": {
214+
"comment": "all 3 jobs done",
215+
"results": {
216+
"counting-B5p5-Obs20-Syst30B.txt": { "comment": "", "limit": 3.546759797347558, "limitErr": 0.03153329261659321, "status": "done", "t_real": 2.4946768283843994 },
217+
"counting-B5p5-Obs20-Syst30C.txt": { "comment": "", "limit": 3.546759797347558, "limitErr": 0.03153329261659321, "status": "done", "t_real": 2.8525874614715576 },
218+
"counting-B5p5-Obs20-Syst30U.txt": { "comment": "", "limit": 3.514851473001713, "limitErr": 0.029821150286336362, "status": "done", "t_real": 2.905097484588623 }
219+
},
220+
"status": "done"
221+
},
222222
"Counting_Lower_FeldmanCousins": {
223223
"comment": "not validated",
224224
"status": "done"

0 commit comments

Comments
 (0)