def setupFlowChain(self, flowlist): from ROOT import AnalysisFramework systematicsPartners = {} systematicsList = [] systematicsOff = [] systematicsOn = [] for syslist in self.systematics: if not type(syslist) in [list, tuple]: syslist = [syslist] else: friendflows = [ flow for flow in flowlist if flow.name in syslist ] for flow in friendflows: systematicsPartners[flow.name] = [ s for s in syslist if not s == flow.name ] sharedVec = makeVectorString( systematicsPartners[flow.name]) flow.systematicsPartners = sharedVec self._tempVec.append(sharedVec) for s in syslist: systematicsList.append(s) self.wb.systematics = makeVectorString(systematicsList) for flow in flowlist: if issubclass(flow.__class__, AnalysisFramework.CutFlows.SystematicsItem): if flow.name in systematicsList: systematicsOn.append(flow.name) if (self.wb.isData and flow.doData) or ( self.wb.isMC and flow.doMC) or (self.wb.isEmbedding and flow.doEmbedding): if flow.name in systematicsPartners: treename = '_'.join( sorted([flow.name] + systematicsPartners[flow.name])) else: treename = flow.name flow.treeDownDelayed = self._tempTree.get( "SystematicsDOWN/" + treename, NTupleTools.makeNTuple( "SystematicsDOWN/" + treename, self.ao, self.outputdump)) flow.treeUpDelayed = self._tempTree.get( "SystematicsUP/" + treename, NTupleTools.makeNTuple("SystematicsUP/" + treename, self.ao, self.outputdump)) self._tempTree["SystematicsDOWN/" + treename] = flow.treeDownDelayed self._tempTree["SystematicsUP/" + treename] = flow.treeUpDelayed else: if not flow.doNominalWhenOff: flow.doNominalInternal = False flow.doNominalExternal = False systematicsOff.append(flow.name) print '@@@@@ The following systematics are enabled:' for syst in systematicsOn: if syst in systematicsPartners: print ' ', syst, 'with', ', '.join( systematicsPartners[syst]) else: print ' ', syst if not systematicsOn: print ' None!' print "@@@@@ The following systematics are disabled:" for syst in systematicsOff: if syst in systematicsPartners: print ' ', syst, 'with', ', '.join( systematicsPartners[syst]) else: print ' ', syst if not systematicsOff: print ' None!' for syst in systematicsList: if not syst in systematicsOff and not syst in systematicsOn: if syst in systematicsPartners: print ' WARNING: Unrecognised systematic:', syst, 'with', ', '.join( systematicsPartners[syst]) else: print ' WARNING: Unrecognised systematic:', syst toRemove = [] correctionsOff = [] correctionsOn = [] for flow in flowlist: if issubclass(flow.__class__, AnalysisFramework.CutFlows.CorrectionItem): if flow.name in self.corrections: correctionsOn.append(flow.name) else: correctionsOff.append(flow.name) toRemove.append(flow) for flow in toRemove: flow.wb = self.wb flow.ao = self.ao flowlist.remove(flow) print "@@@@@ The following corrections are enabled:" for corr in correctionsOn: print ' ', corr if not correctionsOn: print ' None!' print "@@@@@ The following corrections are disabled:" for corr in correctionsOff: print ' ', corr if not correctionsOff: print ' None!' for corr in self.corrections: if not corr in correctionsOff and not corr in correctionsOn: print " WARNING: Unrecognised correction:", corr self.wb.corrections = makeVectorString(correctionsOn) for flow in flowlist: if flow.name == "TotalEvents": self.totalflow = flow break if not self.totalflow: print "@@@@@ ERROR: Must have a flow named 'TotalEvents' to run!" exit() for i in range(len(flowlist)): flow = flowlist[i] try: flows = list(flow.nextList) flow.wb = self.wb flow.ao = self.ao except: flows = [flow] for flow in flows: if i == 0: flow.hasPrevious = False else: prevflow = flowlist[i - 1] flow.previous = prevflow flow.hasPrevious = True if i + 1 < len(flowlist): nextflow = flowlist[i + 1] flow.next = nextflow flow.hasNext = True else: flow.hasNext = False flow.wb = self.wb flow.ao = self.ao return flowlist[0].process
def setupFlowChain(self, flowlist): from ROOT import AnalysisFramework systematicsPartners = {} systematicsList = [] systematicsOff = [] systematicsOn = [] for syslist in self.systematics: if not type(syslist) in [list, tuple]: syslist = [syslist] else: friendflows = [flow for flow in flowlist if flow.name in syslist] for flow in friendflows: systematicsPartners[flow.name] = [s for s in syslist if not s == flow.name] sharedVec = makeVectorString(systematicsPartners[flow.name]) flow.systematicsPartners = sharedVec self._tempVec.append(sharedVec) for s in syslist: systematicsList.append(s) self.wb.systematics = makeVectorString(systematicsList) for flow in flowlist: if issubclass(flow.__class__, AnalysisFramework.CutFlows.SystematicsItem): if flow.name in systematicsList: systematicsOn.append(flow.name) if (self.wb.isData and flow.doData) or (self.wb.isMC and flow.doMC) or (self.wb.isEmbedding and flow.doEmbedding): if flow.name in systematicsPartners: treename = '_'.join(sorted([flow.name] + systematicsPartners[flow.name])) else: treename = flow.name flow.treeDownDelayed = self._tempTree.get("SystematicsDOWN/"+treename, NTupleTools.makeNTuple("SystematicsDOWN/"+treename, self.ao, self.outputdump)) flow.treeUpDelayed = self._tempTree.get("SystematicsUP/"+treename, NTupleTools.makeNTuple("SystematicsUP/"+treename, self.ao, self.outputdump)) self._tempTree["SystematicsDOWN/"+treename] = flow.treeDownDelayed self._tempTree["SystematicsUP/"+treename] = flow.treeUpDelayed else: if not flow.doNominalWhenOff: flow.doNominalInternal = False flow.doNominalExternal = False systematicsOff.append(flow.name) print '@@@@@ The following systematics are enabled:' for syst in systematicsOn: if syst in systematicsPartners: print ' ', syst, 'with', ', '.join(systematicsPartners[syst]) else: print ' ', syst
def getDefaultOutputTree(self): if not self.outputtree: self.outputtree = NTupleTools.makeNTuple(self.treename, self.ao, self.outputdump) return self.outputtree