def stripping_sequence_nopids(): """Return a list of sequences to run and monitor NoPIDs stripping. The list contains three sequences: 1. StreamCharmFromBSemiNoPIDs StrippingConf, which runs all the semileptonic Lambda_c -> X stripping lines, but without PID cuts 2. Stripping report on the above 3. Algorithm that reports correlations in the above stripping lines Sequences 2 and 3 aren't strictly necessary, but are nice to have. The list can be run by DaVinci with DaVinci().appendToMainSequence(stripping_sequence_nopids()) """ stream = StrippingStream("StreamCharmFromBSemi") stream.appendLines( CharmFromBSemiAllLinesConf("CharmFromBSemi", confdict).lines() ) # Create stripping configuration from my stream conf = StrippingConf( Streams=[stream], MaxCandidates=2000, AcceptBadEvents=True, # Stripping reports already exist in the DST, # so put these ones somewhere fake HDRLocation="NowhereIsNowHere" ) # Extra reporting reporting = StrippingReport(Selections=conf.selections()) correlations = AlgorithmCorrelationsAlg(Algorithms=conf.selections()) return [conf.sequence(), reporting, correlations]
def test_dumplicated_outputLocation_in_different_streams_raises_Exception() : filter = FilterDesktop('FilterX') line0 = StrippingLine('Line0b', algos = [filter]) line1 = StrippingLine('Line1b', algos = [filter]) stream0 = StrippingStream('Stream0', Lines = [line0]) stream1 = StrippingStream('Stream0', Lines = [line1]) raises( Exception, StrippingConf, Streams = [stream0,stream1] )
def get_stripping_conf(streams, lineName, acceptBadEvents = True, maxCandidates = None) : lineName = line_name(lineName) lineStream = StrippingStream(lineName + 'Stream') line, stream = get_line(streams, lineName) lineStream.appendLines([line]) filterBadEvents = ProcStatusCheck() sc = StrippingConf( Streams = [ lineStream ], MaxCandidates = maxCandidates, AcceptBadEvents = acceptBadEvents, BadEventSelection = filterBadEvents ) return line, stream, sc
def ReStrip(mylines, stripping="stripping21r0p1", streamname=None): from Configurables import EventNodeKiller, ProcStatusCheck from StrippingArchive.Utils import buildStreams from StrippingArchive import strippingArchive from StrippingConf.Configuration import StrippingStream from StrippingConf.Configuration import StrippingConf from StrippingSettings.Utils import strippingConfiguration NodeKiller = EventNodeKiller("StripKiller") NodeKiller.Nodes = ["/Event/AllStreams", "/Event/Strip"] from StrippingSelections import buildersConf from StrippingSelections.Utils import lineBuilder, buildStreamsFromBuilder config = strippingConfiguration(stripping) archive = strippingArchive(stripping) streams = buildStreams(stripping=config, archive=archive) #confs = buildersConf() mystream = StrippingStream("MyStream") #for name in confnames: # streams = buildStreamsFromBuilder(confs,name) for stream in streams: #if streamname not in stream : continue for line in stream.lines: print line if line.name() in mylines: print "Adding ", line.name(), "for restripping" mystream.appendLines([line]) restrip = StrippingConf(Streams=[mystream], MaxCandidates=2000, AcceptBadEvents=False, BadEventSelection=ProcStatusCheck(), TESPrefix='Strip', ActiveMDSTStream=True) #Verbose = True, #MicroDSTStreams = streams ) return restrip, [NodeKiller, restrip.sequence()]
def test_filterMembers() : ''' It is necessary to construct a StrippingStream and a StrippingConf to test the filterMembers of the line. The line by itself is useless. ''' selection = AutomaticData(Location = 'Phys/Selection/Particles') name = 'FilterMembersTest' line = StrippingLine('FilterMembersTest', algos = [selection]) assert line.name() == 'Stripping' + name assert line.subname() == name assert line.isAppended() == False assert line.outputLocation() == 'Phys/FilterMembersTest/Particles' stream = StrippingStream('stream', Lines = [line]) conf = StrippingConf('conf', Streams = [stream]) assert [m.name() for m in line.filterMembers()] == ['checkPVmin1', 'SelFilterPhys_Selection_Particles', 'FilterMembersTest']
from StrippingSettings.Utils import strippingConfiguration from StrippingArchive.Utils import buildStreams from StrippingArchive import strippingArchive event_node_killer=EventNodeKiller('StripKiller') event_node_killer.Nodes=['Event/AllStreams','/Event/Strip'] from Configurables import PhysConf PhysConf().CaloReProcessing=True stripping="stripping21" config=strippingConfiguration(stripping) archive=strippingArchive(stripping) streams=buildStreams(stripping=config,archive=archive) MyStream= StrippingStream("MyStream") MyLines= ["StrippingB2XEtaLb2pKeta3piLine"] for stream in streams: for line in stream.lines: if line.name() in MyLines: MyStream.appendLines( [ line ]) from Configurables import ProcStatusCheck filterBadEvents=ProcStatusCheck() sc=StrippingConf( Streams= [ MyStream ], MaxCandidates = 2000, AcceptBadEvents = False, BadEventSelection = filterBadEvents)
from DSTWriters.Configuration import ( SelDSTWriter, stripDSTStreamConf, stripDSTElements, ) myLine = 'StrippingBetaSBu2JpsiKDetachedLine' stripping = 'Stripping29r2' config = strippingConfiguration(stripping) archive = strippingArchive(stripping) streams = buildStreams(stripping=config, archive=archive) # Select my line MyStream = StrippingStream('MyStream') for stream in streams: for line in stream.lines: if line.name() == myLine: MyStream.appendLines([line]) # Configure Stripping from Configurables import ProcStatusCheck filterBadEvents = ProcStatusCheck() sc = StrippingConf( Streams=[MyStream], MaxCandidates=2000, AcceptBadEvents=False, BadEventSelection=filterBadEvents,
'StrippingBc2DstDst0Dst2DPI0D2KSHHHDst02D0GammaD02KSHHBeauty2CharmLine', 'StrippingBc2DstDst0Dst2DPI0D2KSHHHDst02D0GammaD02KHHHBeauty2CharmLine', 'StrippingBc2DstDst0Dst2DPI0D2KSHHHDst02D0PI0D02HHBeauty2CharmLine', 'StrippingBc2DstDst0Dst2DPI0D2KSHHHDst02D0PI0D02KHHHBeauty2CharmLine', 'StrippingBc2DstDst0Dst2DPI0D2KSHHHDst02D0PI0D02KSHHBeauty2CharmLine', 'StrippingBc2DstDst0Dst2DPI0D2KSHHHDst02D0GammaD02HHBeauty2CharmLine', 'StrippingBc2DstDst0Dst2DPI0D2KSHDst02D0GammaD02KSHHBeauty2CharmLine', 'StrippingBc2DstDst0Dst2DPI0D2KSHDst02D0GammaD02KHHHBeauty2CharmLine', 'StrippingBc2DstDst0Dst2DPI0D2KSHDst02D0PI0D02HHBeauty2CharmLine', 'StrippingBc2DstDst0Dst2DPI0D2KSHDst02D0PI0D02KHHHBeauty2CharmLine', 'StrippingBc2DstDst0Dst2DPI0D2KSHDst02D0PI0D02KSHHBeauty2CharmLine', 'StrippingBc2DstDst0Dst2DPI0D2KSHDst02D0GammaD02HHBeauty2CharmLine' ] ## Use these lines to only run the lines listed above streamsel = StrippingStream("Bhadron") for stream in streamall: for line in stream.lines: if line.name() in MyLines: streamsel.appendLines([line]) streams = [streamsel] ## Use this instead to run everything in the B2OC module #streams = streamall leptonicMicroDSTname = 'Leptonic' charmMicroDSTname = 'Charm' pidMicroDSTname = 'PID' bhadronMicroDSTname = 'Bhadron' mdstStreams = [ leptonicMicroDSTname, charmMicroDSTname, pidMicroDSTname,
#from StrippingArchive.Utils import buildStreams, cloneLinesFromStream #from StrippingArchive import strippingArchive #config['MuonPID'] = -999999 config['CONFIG']['HLT_FILTER']="" #stripping='stripping20' stripping = 'stripping21' #get the configuration dictionary from the database #config = strippingConfiguration(stripping) #config['HLT_FILTER_HMuNu']="" lb = builder('B2XMuMuInclusive',config['CONFIG']) print config #get the line builders from the archive# # Merge into one stream and run in flag mode # AllStreams = StrippingStream("Dimuon") for line in lb.lines(): print line.name() if line.name() == 'StrippingB2XMuMuInclusive_InclDiMuHighQ2Line': AllStreams.appendLines([line]) if line.name() == 'StrippingB2XMuMuInclusive_InclDiMuLowQ2Line': AllStreams.appendLines([line]) sc = StrippingConf( Streams = [ AllStreams ], MaxCandidates = 2000 )
#get the line builders from the archive archive = strippingArchive(stripping) ######################### # Fix Bu2LLK config for S29r2, which was not updated in Settings but is correct in Archive from StrippingArchive.Stripping29r2.StrippingRD.StrippingBu2LLK import default_config as Bu2LLK_config config = dict(config) config['Bu2LLK']['CONFIG'] = Bu2LLK_config['CONFIG'] # only in this stripping. Now sure what's the need of this in our case ######################### streams = buildStreams(stripping=config, archive=archive) #OUTPUT STREAM NAME AllStreams = StrippingStream("b2dhh.Strip") linesToAdd = [] #LIST OF FILTERED LINES MyLines = [ 'StrippingX2LcPiPiSSLc2PKPiBeauty2CharmLine', 'StrippingX2LcKPiSSLc2PKPiBeauty2CharmLine', 'StrippingX2LcKKSSLc2PKPiBeauty2CharmLine', 'StrippingB2DHHOSD2HHHCFPIDBeauty2CharmLine' ] for stream in streams: if 'Bhadron' in stream.name(): for line in stream.lines:
from Configurables import EventNodeKiller eventNodeKiller = EventNodeKiller('Stripkiller') eventNodeKiller.Nodes = ['/Event/AllStreams', '/Event/Strip'] from StrippingConf.Configuration import StrippingConf, StrippingStream from StrippingArchive import strippingArchive from StrippingArchive.Utils import buildStreams from StrippingSettings.Utils import strippingConfiguration # Note: can only get stripping versions with certain DaVinci versions config = strippingConfiguration(restripversion) archive = strippingArchive(restripversion) streams = buildStreams(stripping=config, archive=archive) # get our stripping line from archive MyStream = StrippingStream("MyStream") MyLines = ['Stripping' + lines[0]] # note: only for one line! for stream in streams: for line in stream.lines: if line.name() in MyLines: MyStream.appendLines([line]) from Configurables import ProcStatusCheck filterBadEvents = ProcStatusCheck() sc = StrippingConf(Streams=[MyStream], MaxCandidates=2000, AcceptBadEvents=False, BadEventSelection=filterBadEvents) DaVinci().appendToMainSequence([eventNodeKiller, sc.sequence()])
from Configurables import (EventNodeKiller, ProcStatusCheck, DaVinci, DecayTreeTuple) from GaudiConf import IOHelper from DecayTreeTuple.Configuration import * # Node killer: remove the previous Stripping event_node_killer = EventNodeKiller('StripKiller') event_node_killer.Nodes = ['/Event/AllStreams', '/Event/Strip'] # Build a new stream called 'CustomStream' that only # contains the desired line strip = 'stripping21' streams = buildStreams(stripping=strippingConfiguration(strip), archive=strippingArchive(strip)) custom_stream = StrippingStream('CustomStream') custom_line = 'StrippingD2hhCompleteEventPromptDst2D2RSLine' for stream in streams: for line in stream.lines: if line.name() == custom_line: custom_stream.appendLines([line]) line = 'D2hhCompleteEventPromptDst2D2RSLine' # Create the actual Stripping configurable filterBadEvents = ProcStatusCheck() sc = StrippingConf(Streams=[custom_stream], MaxCandidates=2000, AcceptBadEvents=False,
from Gaudi.Configuration import * from Configurables import DaVinci, SelDSTWriter, DeterministicPrescaler, FilterDesktop from StrippingConf.Configuration import StrippingConf, StrippingStream, StrippingLine from PhysSelPython.Wrappers import AutomaticData, SelectionSequence, Selection, MergedSelection pions = AutomaticData(Location='Phys/StdLoosePions') eventFilter = DeterministicPrescaler('BadEventFilter', AcceptFraction=0.5) lineX = StrippingLine('PionLineX', algos=[pions]) lineY = StrippingLine('PionLineY', algos=[pions]) streamX = StrippingStream("StreamPionX", Lines=[lineX]) streamXBadEvent = StrippingStream("StreamPionXBadEvent", Lines=[lineX], BadEventSelection=eventFilter) streamYBadEvent = StrippingStream("StreamPionYBadEvent", Lines=[lineY], BadEventSelection=eventFilter) sc = StrippingConf(Streams=[streamX, streamYBadEvent, streamXBadEvent]) dstWriter = SelDSTWriter("SelDST0", OutputFileSuffix="Test3", SelectionSequences=sc.activeStreams()) dv = DaVinci() dv.DataType = '2010' dv.InputType = 'SDST' dv.EvtMax = -1 #dv.appendToMainSequence( [ sc.sequence() ] ) dv.appendToMainSequence([dstWriter.sequence()])
if True: from StrippingConf.Configuration import StrippingConf, StrippingStream from StrippingSettings.Utils import strippingConfiguration from StrippingArchive.Utils import buildStreams from StrippingArchive import strippingArchive stripping = 'stripping19' config = strippingConfiguration(stripping) archive = strippingArchive(stripping) streams = buildStreams(stripping=config, archive=archive) # Select my line MyStream = StrippingStream("MyStream") MyLines = ['SelB2ChicPiPiForPsiX0'] for stream in streams: print stream.name() for line in stream.lines: if "Chic" in line.name(): print line.name() MyStream.appendLines([line])
DefaultTrackingCuts().Cuts = { "Chi2Cut" : [ 0, 4 ], "CloneDistCut" : [5000, 9e+99 ] } # # Build the streams and stripping object # from StrippingArchive.Stripping21.StrippingB2XMuMuInclusive \ import B2XMuMuInclusiveConf as builder from StrippingArchive.Stripping21.StrippingB2XMuMuInclusive \ import defaultConfig as config from StrippingConf.Configuration import StrippingConf, StrippingStream stripping='stripping20' lb = builder('B2XMuMuIncl',config) print config AllStreams = StrippingStream("MyStream") for line in lb.lines(): if line.name() == 'StrippingB2XMuMuIncl_InclDiMuLowQ2Line': AllStreams.appendLines([line]) sc = StrippingConf( Streams = [ AllStreams ], MaxCandidates = 2000 ) stripsel = AutomaticData(Location = "Phys/B2XMuMuIncl_InclDiMuLowQ2Line/Particles") stripfilter = FilterDesktop("stripfilter", Preambulo = ["from LoKiPhysMC.decorators import *", "from LoKiPhysMC.functions import mcMatch"],
DecayTreeTuple ) from GaudiConf import IOHelper from DecayTreeTuple.Configuration import * # Node killer: remove the previous Stripping event_node_killer = EventNodeKiller('StripKiller') event_node_killer.Nodes = ['/Event/AllStreams', '/Event/Strip'] # Build a new stream called 'CustomStream' that only # contains the desired line strip = 'stripping21' streams = buildStreams(stripping=strippingConfiguration(strip), archive=strippingArchive(strip)) custom_stream = StrippingStream('CustomStream') custom_line = 'StrippingD2hhCompleteEventPromptDst2D2RSLine' for stream in streams: for line in stream.lines: if line.name() == custom_line: custom_stream.appendLines([line]) line = 'D2hhCompleteEventPromptDst2D2RSLine' # Create the actual Stripping configurable filterBadEvents = ProcStatusCheck() sc = StrippingConf(Streams=[custom_stream], MaxCandidates=2000, AcceptBadEvents=False,
#from StrippingArchive.Utils import buildStreams, cloneLinesFromStream #from StrippingArchive import strippingArchive #config['MuonPID'] = -999999 config['CONFIG']['HLT_FILTER'] = "" #stripping='stripping20' stripping = 'stripping21' #get the configuration dictionary from the database #config = strippingConfiguration(stripping) #config['HLT_FILTER_HMuNu']="" lb = builder('B2XMuMuInclusive', config['CONFIG']) print config #get the line builders from the archive# # Merge into one stream and run in flag mode # AllStreams = StrippingStream("Dimuon") for line in lb.lines(): print line.name() if line.name() == 'StrippingB2XMuMuInclusive_InclDiMuHighQ2Line': AllStreams.appendLines([line]) if line.name() == 'StrippingB2XMuMuInclusive_InclDiMuLowQ2Line': AllStreams.appendLines([line]) sc = StrippingConf(Streams=[AllStreams], MaxCandidates=2000) # But what we really want is to make a dimuon and a Kaon from StandardParticles import StdLooseKaons as kaons LowQ2MuonsOnDemand = DataOnDemand(
#--------------------------------------------------------------- #Use Stripping21r0p1 on MC for Run I #--------------------------------------------------------------- from StrippingArchive.Stripping21r0p1.StrippingRD.StrippingB2Lambda0MuLines import B2Lambda0MuLines from StrippingSettings.Stripping21r0p1.LineConfigDictionaries_RD import B2Lambda0Mu #from StrippingArchive.Stripping23.StrippingRD.StrippingB2Lambda0MuLines import B2Lambda0MuLines #from StrippingSettings.Stripping23r1.LineConfigDictionaries_RD import B2Lambda0Mu B2Lambda0MuConf = B2Lambda0MuLines('B2Lambda0MuLines', B2Lambda0Mu['CONFIG']) B2Lambda0MuLines = B2Lambda0MuConf.lines() sc = StrippingConf(HDRLocation="DecReports") sstream = StrippingStream("TestStream") sstream.appendLines(B2Lambda0MuLines) sstream.OutputLevel = 2 sc.appendStream(sstream) #--------------------------------------------------------------- #Use specific Stripping23r1 on MC for Run II #--------------------------------------------------------------- ## from StrippingArchive.Stripping23.StrippingRD.StrippingB2Lambda0MuLines import B2Lambda0MuLines ## from StrippingSettings.Stripping23r1.LineConfigDictionaries_RD import B2Lambda0Mu ## B2Lambda0MuConf = B2Lambda0MuLines('B2Lambda0MuLines', B2Lambda0Mu['CONFIG']) ## B2Lambda0MuLines = B2Lambda0MuConf.lines() ## ## stripline = B2Lambda0MuLines[0]
#--------------------------------------------------------------- from StrippingConf.Configuration import StrippingConf, StrippingStream from StrippingSettings.Utils import strippingConfiguration from StrippingSettings.Stripping21.LineConfigDictionaries_RD import B2XMuMu from StrippingArchive.Utils import buildStreams from StrippingArchive import strippingArchive from StrippingArchive.Stripping21.StrippingB2XuMuNu import B2XuMuNuBuilder from StrippingSettings.Stripping21.LineConfigDictionaries_Semileptonic import B2XuMuNu B2XuMuNuConf = B2XuMuNuBuilder('B2XuMuNuBuilder', B2XuMuNu['CONFIG']) B2XuMuNuLines = B2XuMuNuConf.lines() sc = StrippingConf(HDRLocation="DecReports") sstream = StrippingStream("TestStream") sstream.appendLines(B2XuMuNuLines) sstream.OutputLevel = 2 sc.appendStream(sstream) #--------------------------- # Run fixing XmumuLine #--------------------------- from Configurables import NeutrinoBuildTupleTool, PromptNeutrinoTupleTool tuple = DecayTreeTuple('PromptNeutrinoTupleTool') tuple.OutputLevel = INFO stream = 'AllStreams' stripping_line = 'B2XMuMu_Line'