CMS 3D CMS Logo

Public Member Functions

ModelTools::CountingModelBuilder Class Reference

Inheritance diagram for ModelTools::CountingModelBuilder:
ModelTools::ModelBuilder ModelTools::ModelBuilderBase

List of all members.

Public Member Functions

def __init__
def doCombination
def doIndividualModels
def doObservables

Detailed Description

ModelBuilder to make a counting experiment

Definition at line 288 of file ModelTools.py.


Constructor & Destructor Documentation

def ModelTools::CountingModelBuilder::__init__ (   self,
  datacard,
  options 
)

Reimplemented from ModelTools::ModelBuilder.

Definition at line 290 of file ModelTools.py.

00291                                        :
00292         ModelBuilder.__init__(self,datacard,options)
00293         if datacard.hasShapes: 
            raise RuntimeError, "You're using a CountingModelBuilder for a model that has shapes"

Member Function Documentation

def ModelTools::CountingModelBuilder::doCombination (   self)
create model_s and model_b pdfs

Reimplemented from ModelTools::ModelBuilder.

Definition at line 314 of file ModelTools.py.

00315                            :
00316         prefix = "modelObs" if len(self.DC.systs) else "model" # if no systematics, we build directly the model
00317         nbins = len(self.DC.bins)
00318         if nbins > 50:
00319             from math import ceil
00320             nblocks = int(ceil(nbins/10.))
00321             for i in range(nblocks):
00322                 self.doObj("%s_s_%d" % (prefix,i), "PROD", ",".join(["pdf_bin%s"       % self.DC.bins[j] for j in range(10*i,min(nbins,10*i+10))]))
00323                 self.doObj("%s_b_%d" % (prefix,i), "PROD", ",".join(["pdf_bin%s_bonly" % self.DC.bins[j] for j in range(10*i,min(nbins,10*i+10))]))
00324             self.doObj("%s_s" % prefix, "PROD", ",".join([prefix+"_s_%d" % i for i in range(nblocks)]))
00325             self.doObj("%s_b" % prefix, "PROD", ",".join([prefix+"_b_%d" % i for i in range(nblocks)]))
00326         else: 
00327             self.doObj("%s_s" % prefix, "PROD", ",".join(["pdf_bin%s"       % b for b in self.DC.bins]))
00328             self.doObj("%s_b" % prefix, "PROD", ",".join(["pdf_bin%s_bonly" % b for b in self.DC.bins]))
00329         if len(self.DC.systs): # multiply by nuisances if needed
00330             self.doObj("model_s", "PROD", "modelObs_s, nuisancePdf")
00331             self.doObj("model_b", "PROD", "modelObs_b, nuisancePdf")
00332 
def ModelTools::CountingModelBuilder::doIndividualModels (   self)
create pdf_bin<X> and pdf_bin<X>_bonly for each bin

Reimplemented from ModelTools::ModelBuilder.

Definition at line 307 of file ModelTools.py.

00308                                 :
00309         self.doComment(" --- Expected events in each bin, total (S+B and B) ----")
00310         for b in self.DC.bins:
00311             self.doObj("n_exp_bin%s_bonly" % b, "sum", ", ".join(["n_exp_bin%s_proc_%s" % (b,p) for p in self.DC.exp[b].keys() if self.DC.isSignal[p] == False]) )
00312             self.doObj("n_exp_bin%s"       % b, "sum", ", ".join(["n_exp_bin%s_proc_%s" % (b,p) for p in self.DC.exp[b].keys()                        ]) )
00313             self.doObj("pdf_bin%s"       % b, "Poisson", "n_obs_bin%s, n_exp_bin%s, 1"       % (b,b))
            self.doObj("pdf_bin%s_bonly" % b, "Poisson", "n_obs_bin%s, n_exp_bin%s_bonly, 1" % (b,b))
def ModelTools::CountingModelBuilder::doObservables (   self)
create pdf_bin<X> and pdf_bin<X>_bonly for each bin

Reimplemented from ModelTools::ModelBuilder.

Definition at line 294 of file ModelTools.py.

00295                            :
00296         if len(self.DC.obs):
00297             self.doComment(" ----- observables (already set to observed values) -----")
00298             for b in self.DC.bins: self.doVar("n_obs_bin%s[%f,0,%d]" % (b,self.DC.obs[b],N_OBS_MAX))
00299         else:
00300             self.doComment(" ----- observables -----")
00301             for b in self.DC.bins: self.doVar("n_obs_bin%s[0,%d]" % (b,N_OBS_MAX))
00302         self.doSet("observables", ",".join(["n_obs_bin%s" % b for b in self.DC.bins]))
00303         if len(self.DC.obs):
00304             if self.options.bin:
00305                 self.out.data_obs = ROOT.RooDataSet(self.options.dataname,"observed data", self.out.set("observables"))
00306                 self.out.data_obs.add( self.out.set("observables") )
                self.out._import(self.out.data_obs)