def checkFileExists(x): if x[0:4] == "/eos": f = gSystem.Getenv("EOSSHIP") + x else: f = x test = TFile.Open(f) if not test: print "input file", f, " does not exist. Missing authentication?" os._exit(1)
def readHists(h, fname, wanted=[], withProjections=True): if fname[0:4] == "/eos": eospath = gSystem.Getenv("EOSSHIP") + fname f = TFile.Open(eospath) else: f = TFile(fname) for akey in f.GetListOfKeys(): name = akey.GetName() try: hname = int(name) except: hname = name if len(wanted) > 0: if not hname in wanted: continue obj = akey.ReadObj() cln = obj.Class().GetName() if not cln.find('TCanv') < 0: h[hname] = obj.Clone() if cln.find('TH') < 0: continue if h.has_key(hname): rc = h[hname].Add(obj) if not rc: print "Error when adding histogram ", hname else: h[hname] = obj.Clone() if h[hname].GetSumw2N() == 0: h[hname].Sumw2() h[hname].SetDirectory(gROOT) if (cln == 'TH2D' or cln == 'TH2F') and withProjections: for p in ['_projx', '_projy']: if type(hname) == type('s'): projname = hname + p else: projname = str(hname) + p if p.find('x') > -1: h[projname] = h[hname].ProjectionX() else: h[projname] = h[hname].ProjectionY() h[projname].SetName(name + p) h[projname].SetDirectory(gROOT) return
def setUp(self): gROOT.SetBatch(True) gROOT.SetMacroPath(gSystem.Getenv("CMSSW_BASE")+"/src/SLHCL1TrackTriggerSimulations/AMSimulation") gROOT.LoadMacro("python/test/loader.h+") self.tfile = TFile.Open(self.infile) self.ttree = self.tfile.Get("ntupler/tree") self.nevents = self.ttree.GetEntries()
def checkFileExists(x): if x[0:4] == "/eos": f = gSystem.Getenv("EOSSHIP") + x else: f = x test = TFile.Open(f) if not test: print "input file", f, " does not exist. Missing authentication?" os._exit(1) if test.FindObjectAny('cbmsim'): return 'tree' else: return 'ntuple'