def __init__(self, tree, outfile, **kwargs): self.channel = 'EE' super(EEAnalyzerMVA, self).__init__(tree, outfile, **kwargs) self.tree = EETree(tree) self.out = outfile self.histograms = {} self.pucorrector = mcCorrections.make_puCorrector('singlee') self.pucorrectorUp = mcCorrections.make_puCorrectorUp('singlee') self.pucorrectorDown = mcCorrections.make_puCorrectorDown('singlee')
def __init__(self, tree, outfile, **kwargs): logging.debug('LFVHETauAnalyzerMVA3 constructor') self.channel = 'ET' super(LFVHETauAnalyzerMVA3, self).__init__(tree, outfile, **kwargs) self.tree = ETauTree(tree) self.out = outfile self.histograms = {} #understand what we are running target = os.path.basename(os.environ['megatarget']) self.is_data = target.startswith('data_') self.is_embedded = ('Embedded' in target) self.is_mc = not (self.is_data or self.is_embedded) self.efake = e_fake_rate(0.2) self.efakeup = e_fake_rate_up(0.2) self.efakedw = e_fake_rate_dw(0.2) #systematics used self.systematics = { 'trig': (['', 'trp1s', 'trm1s'] if not self.is_data else []), 'pu': (['', 'p1s', 'm1s'] if self.is_mc else []), 'eid': (['', 'eidp1s', 'eidm1s'] if not self.is_data else []), 'eiso': (['', 'eisop1s', 'eisom1s'] if not self.is_data else []), 'jes': (['', '_jes_plus', '_jes_minus'] if self.is_mc else ['']), 'mvetos': (['', 'mVetoUp', 'mVetoDown'] if self.is_mc else ['']), 'tvetos': (['', 'tVetoUp', 'tVetoDown'] if self.is_mc else ['']), 'evetos': (['', 'eVetoUp', 'eVetoDown'] if self.is_mc else ['']), 'met': (["_mes_plus", "_ues_plus", "_mes_minus", "_ues_minus"] if self.is_mc else []), 'tes': (["", "_tes_plus", "_tes_minus"] if not self.is_data else ['']), 'ees': (["", "_ees_plus", '_ees_minus'] if not self.is_data else ['']) } #self filling histograms coll_mass = make_collmass_systematics('') #no sys shift self.histo_locations = { } #just a mapping of the histograms we have to avoid changing self.histograms indexing an screw other files self.hfunc = { #maps the name of non-trivial histograms to a function to get the proper value, the function MUST have two args (evt and weight). Used in fill_histos later 'nTruePU': lambda row, weight: (row.nTruePU, None), 'weight': lambda row, weight: (weight, None) if weight is not None else (1., None), 'Event_ID': lambda row, weight: (array.array("f", [ row.run, row.lumi, int(row.evt) / 10**5, int(row.evt) % 10**5 ]), None), 'h_collmass_pfmet': coll_mass, 'tPtcut': coll_mass, 'ePtcut': coll_mass, 'deltaPhicut': coll_mass, 'tMtToPFMETcut': coll_mass, 'vbfMasscut': coll_mass, 'vbfDetacut': coll_mass, 'h_collmass_vs_dPhi_pfmet': merge_functions(attr_getter('tToMETDPhi'), coll_mass), 'MetEt_vs_dPhi': merge_functions( lambda row, weight: (deltaPhi(row.tPhi, getattr(row, metphi())), weight), attr_getter('type1_pfMet_Et')), 'ePFMET_DeltaPhi': lambda row, weight: (deltaPhi(row.ePhi, getattr(row, metphi())), weight), 'tPFMET_DeltaPhi': lambda row, weight: (deltaPhi(row.tPhi, getattr(row, metphi())), weight), 'evtInfo': lambda row, weight: (struct( run=row.run, lumi=row.lumi, evt=row.evt, weight=weight), None) } for shift in self.systematics['met']: #patch name postfix = shift self.hfunc['h_collmass_pfmet%s' % postfix] = make_collmass_systematics(shift) for shift in self.systematics['tes']: #patch name postfix = shift self.hfunc['h_collmass_pfmet%s' % postfix] = make_collmass_systematics(shift) for shift in self.systematics['jes']: #patch name postfix = shift self.hfunc['h_collmass_pfmet%s' % postfix] = make_collmass_systematics(shift) for shift in self.systematics['ees']: #patch name postfix = shift self.hfunc['h_collmass_pfmet%s' % postfix] = make_collmass_systematics(shift) #PU correctors self.pucorrector = mcCorrections.make_shifted_weights( mcCorrections.make_puCorrector('singlee'), ['p1s', 'm1s'], [ mcCorrections.make_puCorrectorUp('singlee'), mcCorrections.make_puCorrectorDown('singlee') ]) self.trig_weight = mcCorrections.trig_efficiency if self.is_embedded else mcCorrections.trig_correction