Skip to content

Commit

Permalink
Merge pull request cms-sw#104 from nucleosynthesis/nckk-combineCards-…
Browse files Browse the repository at this point in the history
…include-channel

include channel option in combineCards
  • Loading branch information
gpetruc committed Feb 19, 2014
2 parents 9c8e2fb + 9902868 commit 14cbd12
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/DatacardParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ def isVetoed(name,vetoList):
if re.match(pattern,name): return True
return False

def isIncluded(name,includeList):
if not len(includeList): return True
for pattern in includeList:
if not pattern: continue
if re.match(pattern,name): return True
return False

def parseCard(file, options):
if type(file) == type("str"):
raise RuntimeError, "You should pass as argument to parseCards a file object, stream or a list of lines, not a string"
Expand Down
5 changes: 5 additions & 0 deletions scripts/combineCards.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
parser.add_option("-a", "--asimov", dest="asimov", default=False, action="store_true", help="Replace observation with asimov dataset. Works only for counting experiments")
parser.add_option("-P", "--prefix", type="string", dest="fprefix", default="", help="Prefix this to all file names")
parser.add_option("--xc", "--exclude-channel", type="string", dest="channelVetos", default=[], action="append", help="Exclude channels that match this regexp; can specify multiple ones")
parser.add_option("--ic", "--include-channel", type="string", dest="channelIncludes", default=[], action="append", help="Only include channels that match this regexp; can specify multiple ones")
parser.add_option("--X-no-jmax", dest="noJMax", default=False, action="store_true", help="FOR DEBUG ONLY: Turn off the consistency check between jmax and number of processes.")
parser.add_option("--xn-file", "--exclude-nuisances-from-file", type="string", dest="nuisVetoFile", help="Exclude all the nuisances in this file")

Expand Down Expand Up @@ -51,6 +52,7 @@
for b in DC.bins:
bout = label if singlebin else label+b
if isVetoed(bout,options.channelVetos): continue
if not isIncluded(bout,options.channelIncludes): continue
obskeyline.append(bout)
for (p,e) in DC.exp[b].items(): # so that we get only self.DC.processes contributing to this bin
if DC.isSignal[p] == False: continue
Expand All @@ -74,6 +76,7 @@
for b in DC.bins:
bout = label if singlebin else label+b
if isVetoed(bout,options.channelVetos): continue
if not isIncluded(bout,options.channelIncludes): continue
if not systeffect.has_key(bout): systeffect[bout] = {}
for p in DC.exp[b].keys(): # so that we get only self.DC.processes contributing to this bin
r = str(errline[b][p]);
Expand Down Expand Up @@ -118,6 +121,7 @@
for b in DC.bins:
bout = label if singlebin else label+b
if isVetoed(bout,options.channelVetos): continue
if not isIncluded(bout,options.channelIncludes): continue
p2sMap = DC.shapeMap[b] if DC.shapeMap.has_key(b) else {}
p2sMapD = DC.shapeMap['*'] if DC.shapeMap.has_key('*') else {}
for p, x in p2sMap.items():
Expand All @@ -140,6 +144,7 @@
for b in DC.bins:
bout = label if singlebin else label+b
if isVetoed(bout,options.channelVetos): continue
if not isIncluded(bout,options.channelIncludes): continue
obsline += [str(DC.obs[b])];

bins = []
Expand Down

0 comments on commit 14cbd12

Please sign in to comment.