Exemplo n.º 1
0
import ROOT
from math import sqrt, cos, sin, pi, acos
import itertools
import pickle
import os

#user
from StopsDilepton.tools.user import plot_directory

#RootTools
from RootTools.core.standard import *

# Logging
import StopsDilepton.tools.logger as logger

logger = logger.get_logger('INFO', logFile = None )
histos = {}
for m in ['doubleMu', 'doubleEle', 'muEle']:
    plot_path = "png25ns_2l_mAODv2_2100_noPU_new/%s_offZ_standard_isOS-leadingLepIsTight-njet2-nbtag1-met80-metSig5-dPhiJet0-dPhiJet1/" % m
    for fh in ["leadingLepIso"]:
        for swap in ["L1", "L2"]:
            for fs in ["mm","me","em","ee"]:
                ofile = os.path.join(plot_directory, plot_path,  "dl_mt2ll_%s_swap%s_%s.pkl"%(fh, swap, fs))
                if os.path.isfile(ofile):
                    logger.info( "Loading %s", ofile )
                    histos["%s_mt2ll_%s_swap%s_%s"%(m, fh, swap, fs)] = pickle.load( file( ofile) )
                else:
                    logger.warning( "File not found: %s", ofile)

def transpose(l):
    return list(map(list, zip(*l)))
Exemplo n.º 2
0
parser.add_option("--multiIsoWP",            dest="multiIsoWP",            default="",   type="string", action="store",      help="wpMu,wpEle")
parser.add_option("--relIso04",              dest="relIso04",              default=-1,   type=float,    action="store",      help="relIso04 cut?")
parser.add_option("--signal",                dest="signal",                default=None,                action="store",      help="which signal estimators?", choices=[None,"DM","T2tt","allT2tt"])
parser.add_option('--logLevel',              dest="logLevel",              default='INFO',              action='store',      help="log level?", choices=['CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG', 'TRACE', 'NOTSET'])
(options, args) = parser.parse_args()

from StopsDilepton.analysis.SetupHelpers import allChannels
from StopsDilepton.analysis.estimators import setup, allEstimators
from StopsDilepton.analysis.regions import defaultRegions, reducedRegionsA, reducedRegionsB, reducedRegionsAB, reducedRegionsNew, reducedRegionsC

setup.parameters['metMin']    = options.metMin
setup.parameters['metSigMin'] = options.metSigMin

# Logging
import StopsDilepton.tools.logger as logger
logger = logger.get_logger(options.logLevel, logFile = None )
import RootTools.core.logger as logger_rt
logger_rt = logger_rt.get_logger(options.logLevel, logFile = None )

allRegions = set(defaultRegions + reducedRegionsA + reducedRegionsB + reducedRegionsAB + reducedRegionsNew + reducedRegionsC)
if options.multiIsoWP!="":
    multiIsoWPs = ['VL', 'L', 'M', 'T', 'VT']
    wpMu, wpEle=options.multiIsoWP.split(',')
    from StopsDilepton.tools.objectSelection import multiIsoLepString
    setup.externalCuts.append(multiIsoLepString(wpMu, wpEle, ('l1_index','l2_index')))
    setup.prefixes.append('multiIso'+options.multiIsoWP.replace(',',''))

if options.relIso04>0:
    setup.externalCuts.append("&&".join(["LepGood_relIso04["+ist+"]<"+str(options.relIso04) for ist in ('l1_index','l2_index')]))
    setup.prefixes.append('relIso04sm'+str(int(100*options.relIso04)))
Exemplo n.º 3
0
argParser.add_argument('--overwrite',
                       action='store_true',
                       default=True,
                       help='overwrite?')
argParser.add_argument('--plot_directory', action='store', default='TTG_gen')
argParser.add_argument('--selection', action='store', default=None)
argParser.add_argument('--smoothFactor', action='store', default=None)
argParser.add_argument('--isChild', action='store_true', default=False)
args = argParser.parse_args()

#
# Logger
#
import StopsDilepton.tools.logger as logger
import RootTools.core.logger as logger_rt
logger = logger.get_logger(args.logLevel, logFile=None)
logger_rt = logger_rt.get_logger(args.logLevel, logFile=None)

#
# Cuts to iterate over
#
cuts = [
    ("etaGamma25", "(1)"),  # Implemented in otherSelections() method
    ("ptGamma30", "(1)"),  # Implemented in otherSelections() method
    ("ptGamma50", "(1)"),  # Implemented in otherSelections() method
    ("ptGamma75", "(1)"),  # Implemented in otherSelections() method
    ("met50", "(1)"),  # Implemented in otherSelections() method
    ("met80", "(1)"),  # Implemented in otherSelections() method
    ("mt2ll100", "(1)"),  # Implemented in otherSelections() method
    ("mt2ll140", "(1)"),  # Implemented in otherSelections() method
]
Exemplo n.º 4
0
    argParser.add_argument('--processingEra',
        action='store',
        nargs='?',
        type=str,
        default='postProcessed_Fall15_mAODv2',
        help="Name of the processing era"
        )

    return argParser

options = get_parser().parse_args()

# Logging
import StopsDilepton.tools.logger as logger
logger = logger.get_logger(options.logLevel, logFile = None )
import RootTools.core.logger as logger_rt
logger_rt = logger_rt.get_logger(options.logLevel, logFile = None )

#Samples: Load samples
from StopsDilepton.samples.helpers import fromHeppySample
samples = [ fromHeppySample(s, data_path = options.dataDir, maxN = None) for s in options.samples ]

xSection = samples[0].heppy.xSection

#Samples: combine if more than one
if len(samples)>1:
    sample_name =  samples[0].name+"_comb"
    logger.info( "Combining samples %s to %s.", ",".join(s.name for s in samples), sample_name )
    sample = Sample.combine(sample_name, samples, maxN = maxN)
    # Clean up
Exemplo n.º 5
0
#    default = False,
    default = True,
    action='store_true',
    help='overwrite?',
)

argParser.add_argument('--plot_directory',
    default='png25ns_2l_mAODv2_2100_noPU_VTVT',
    action='store',
)

args = argParser.parse_args()

# Logging
import StopsDilepton.tools.logger as logger
logger = logger.get_logger(args.logLevel, logFile = None )
import RootTools.core.logger as logger_rt
logger_rt = logger_rt.get_logger(args.logLevel, logFile = None )

#make samples
data_directory = "/afs/hephy.at/data/rschoefbeck01/cmgTuples/" 
postProcessing_directory = "postProcessed_Fall15_mAODv2/dilep/" 

from StopsDilepton.samples.cmgTuples_Fall15_mAODv2_25ns_2l_postProcessed import *
from StopsDilepton.samples.cmgTuples_Data25ns_mAODv2_postProcessed import *

def getZCut(mode):
    mZ = 91.2
    zstr = "abs(dl_mass - "+str(mZ)+")"
    if mode.lower()=="onz": return zstr+"<15"
    if mode.lower()=="offz": return zstr+">15"
    argParser.add_argument('--skipSystematicVariations',
        action='store_true',
        help="Don't calulcate BTag, JES and JER variations."
        )

    argParser.add_argument('--noTopPtReweighting',
        action='store_true',
        help="Skip top pt reweighting.")

    return argParser

options = get_parser().parse_args()

# Logging
import StopsDilepton.tools.logger as logger
logger = logger.get_logger(options.logLevel, logFile ='/tmp/%s_%s.txt'%(options.skim, '_'.join(options.samples) ) )
import RootTools.core.logger as logger_rt
logger_rt = logger_rt.get_logger(options.logLevel, logFile = None )

# flags (I think string searching is slow, so let's not do it in the filler function)
isDiLep     =   options.skim.lower().startswith('dilep')
isSingleLep =   options.skim.lower().startswith('singlelep')
isTiny      =   options.skim.lower().count('tiny') 
isVeryLoose =  'veryloose' in options.skim.lower()
isVeryLoosePt10 =  'veryloosept10' in options.skim.lower()
isLoose     =  'loose' in options.skim.lower() and not isVeryLoose
isJet250    = 'jet250' in options.skim.lower()

# Skim condition
skimConds = []
if isDiLep:
Exemplo n.º 7
0
#! /usr/bin/env python

#
# To split up cmgPostProcessed samples according to their TTGJetsEventType such that you can show the sample split up
#

from ROOT import TFile, TTree
import os

import StopsDilepton.tools.logger as logger
log = logger.get_logger("DEBUG")


def filter(input, output, eventType):
    inputFile = TFile(input)
    outputFile = TFile(output, "RECREATE")

    inputTree = inputFile.Get("Events")
    if not inputTree:
        log.warn("No Events tree found, aborting")
        return False

    outputFile.cd()
    outputTree = inputTree.CloneTree(0)

    for i in range(inputTree.GetEntries()):
        inputTree.GetEntry(i)
        if inputTree.TTGJetsEventType == eventType:  # Fill for given eventType
            outputTree.Fill()
    outputTree.AutoSave()
    outputFile.Close()
Exemplo n.º 8
0
#! /usr/bin/env python

#
# To split up cmgPostProcessed samples according to their TTGJetsEventType such that you can show the sample split up
#


from ROOT import TFile, TTree
import os

import StopsDilepton.tools.logger as logger
log = logger.get_logger("DEBUG")

def filter(input, output, eventType):
  inputFile  = TFile(input)
  outputFile = TFile(output,"RECREATE")

  inputTree = inputFile.Get("Events")
  if not inputTree:
    log.warn("No Events tree found, aborting")
    return False

  outputFile.cd()
  outputTree = inputTree.CloneTree(0)

  for i in range(inputTree.GetEntries()):
    inputTree.GetEntry(i)
    if inputTree.TTGJetsEventType == eventType:								# Fill for given eventType
      outputTree.Fill() 
  outputTree.AutoSave()
  outputFile.Close()
Exemplo n.º 9
0
        action='store_true',
        help="Don't calulcate BTag, JES and JER variations.")

    argParser.add_argument('--noTopPtReweighting',
                           action='store_true',
                           help="Skip top pt reweighting.")

    return argParser


options = get_parser().parse_args()

# Logging
import StopsDilepton.tools.logger as logger
logger = logger.get_logger(options.logLevel,
                           logFile='/tmp/%s_%s.txt' %
                           (options.skim, '_'.join(options.samples)))
import RootTools.core.logger as logger_rt
logger_rt = logger_rt.get_logger(options.logLevel, logFile=None)

# flags (I think string searching is slow, so let's not do it in the filler function)
isDiLep = options.skim.lower().startswith('dilep')
isSingleLep = options.skim.lower().startswith('singlelep')
isTiny = options.skim.lower().count('tiny')
isVeryLoose = 'veryloose' in options.skim.lower()
isVeryLoosePt10 = 'veryloosept10' in options.skim.lower()
isLoose = 'loose' in options.skim.lower() and not isVeryLoose
isJet250 = 'jet250' in options.skim.lower()

# Skim condition
skimConds = []
Exemplo n.º 10
0
#!/usr/bin/env python
from StopsDilepton.analysis.Region import Region
from StopsDilepton.analysis.estimators import setup, DataDrivenDYEstimate
from StopsDilepton.samples.cmgTuples_Data25ns_mAODv2_postProcessed import *
import StopsDilepton.tools.logger as logger
logger = logger.get_logger("INFO", logFile = None )
import RootTools.core.logger as logger_rt
logger_rt = logger_rt.get_logger("INFO", logFile = None )


estimateDY = DataDrivenDYEstimate(name='DY-DD', cacheDir=None)
regionDY = Region('dl_mt2ll', (0,-1))

for channel, sample in setup.sample['Data'].iteritems():
    res = estimateDY.cachedEstimate(regionDY,channel,setup)
    print "\n Result in ", channel," for estimate ", estimateDY.name, regionDY,":", res#, 'jer',jer, 'jec', jec