def configureMicroDSTwriter(name, prefix, sequences): # Configure the dst writers for the output pack = True microDSTwriterInput = MultiSelectionSequence(name, Sequences=sequences) # Configuration of MicroDST # per-event an per-line selective writing of the raw event is active (selectiveRawEvent=True) mdstStreamConf = stripMicroDSTStreamConf( pack=pack) #, selectiveRawEvent = False) mdstElements = stripMicroDSTElements(pack=pack) # Configuration of SelDSTWriter # per-event an per-line selective writing of the raw event is active (selectiveRawEvent=True) SelDSTWriterElements = {'default': mdstElements} SelDSTWriterConf = {'default': mdstStreamConf} # SelDSTWriterConf = {'default': stripCalibMicroDSTStreamConf(pack=pack, selectiveRawEvent=False)} dstWriter = SelDSTWriter("MyDSTWriter", StreamConf=SelDSTWriterConf, MicroDSTElements=SelDSTWriterElements, OutputFileSuffix=prefix, SelectionSequences=[microDSTwriterInput]) from Configurables import StoreExplorerAlg return [microDSTwriterInput.sequence(), dstWriter.sequence()]
# Configure the dst writers for the output # enablePacking = True from DSTWriters.microdstelements import * from DSTWriters.Configuration import (SelDSTWriter, stripDSTStreamConf, stripDSTElements, stripMicroDSTStreamConf, stripMicroDSTElements, stripCalibMicroDSTStreamConf) # # Configuration of MicroDST # per-event an per-line selective writing of the raw event is active (selectiveRawEvent=True) # mdstStreamConf = stripMicroDSTStreamConf(pack=enablePacking, selectiveRawEvent=True) mdstElements = stripMicroDSTElements(pack=enablePacking) # # Configuration of SelDSTWriter # per-event an per-line selective writing of the raw event is active (selectiveRawEvent=True) # SelDSTWriterElements = { 'default': stripDSTElements(pack=enablePacking), charmMicroDSTname: mdstElements, leptonicMicroDSTname: mdstElements, pidMicroDSTname: mdstElements, bhadronMicroDSTname: mdstElements } SelDSTWriterConf = {
# Configuration of SelDSTWriter # enablePacking = True from DSTWriters.microdstelements import * from DSTWriters.Configuration import (SelDSTWriter, stripDSTStreamConf, stripDSTElements, stripMicroDSTStreamConf, stripMicroDSTElements, stripCalibMicroDSTStreamConf) SelDSTWriterElements = { 'default': stripMicroDSTElements(pack=enablePacking, isMC=True) } SelDSTWriterConf = { 'default': stripMicroDSTStreamConf(pack=enablePacking, isMC=True) } #Items that might get lost when running the CALO+PROTO ReProcessing in DV caloProtoReprocessLocs = ["/Event/pRec/ProtoP#99", "/Event/pRec/Calo#99"] # Make sure they are present on full DST streams SelDSTWriterConf['default'].extraItems += caloProtoReprocessLocs dstWriter = SelDSTWriter("MyDSTWriter", StreamConf=SelDSTWriterConf, MicroDSTElements=SelDSTWriterElements, OutputFileSuffix='Filtered', SelectionSequences=sc.activeStreams()) # Add stripping TCK
SelectionSequence('SEQ:Y&Lc+', TopSelection=sel_Lc), SelectionSequence('SEQ:Y&Dstar+', TopSelection=sel_Dst), SelectionSequence('SEQ:Y&Lcstar', TopSelection=sel_Lcst), SelectionSequence('SEQ:Y&Sigmac', TopSelection=sel_Sc), # ]) # ============================================================================= # 5. micro-DST writer # ============================================================================= from DSTWriters.Configuration import (SelDSTWriter, stripMicroDSTStreamConf, stripMicroDSTElements) # Configuration of SelDSTWriter SelDSTWriterConf = {'default': stripMicroDSTStreamConf(pack=False)} SelDSTWriterElements = {'default': stripMicroDSTElements(pack=False)} uDstWriter = SelDSTWriter( "MyDSTWriter", StreamConf=SelDSTWriterConf, MicroDSTElements=SelDSTWriterElements, OutputFileSuffix='BandQ', # output PRE-fix! SelectionSequences=[ups_charm] ) # # Read only fired events to speed up # from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters(
def ConfigureDaVinci(): config = Swimming() from Configurables import DaVinci from StrippingConf.Configuration import StrippingConf from Configurables import ProcStatusCheck from Configurables import EventNodeKiller, GaudiSequencer from PhysSelPython.Wrappers import (AutomaticData, SelectionSequence, MultiSelectionSequence) # Get the stripping line from StrippingSettings.Utils import lineBuilderConfiguration strippingFile = None if config.getProp('StrippingFile') != 'none': strippingFile = config.getProp('StrippingFile') else: strippingFile = config.getProp('StrippingLineGroup') myconfig = lineBuilderConfiguration(config.getProp('StrippingVersion'), config.getProp('StrippingLineGroup')) import StrippingArchive mylineconf = getattr( __import__( 'StrippingArchive.' + config.getProp('StrippingVersion') + '.Stripping' + strippingFile, globals(), locals(), [myconfig["BUILDERTYPE"]], -1), myconfig["BUILDERTYPE"]) mylinedict = myconfig["CONFIG"] substitutions = config.getProp('StrippingConfigSubstitutions') print "mylinedict before substitutions:", mylinedict print "stripping config substitutions:", substitutions mylinedict.update(substitutions) print "mylineconf:", mylineconf print "mylinedict after substitutions:", mylinedict from StrippingConf.StrippingStream import StrippingStream stream = StrippingStream(config.getProp('StrippingStream') + "Swimming") allLines = mylineconf(config.getProp('StrippingLineGroup'), mylinedict).lines() lines = [] #lineNames = [l.split('/')[-1] for l in config.getProp('StripCands').keys()] lineNames = config.getProp('StrippingLines') print "lineNames:", lineNames for l in allLines: for lineName in lineNames: if l.outputLocation().find(lineName) != -1: lines.append(l) print l.outputLocation() stream.appendLines(lines) # Define the stream filterBadEvents = ProcStatusCheck() sc = StrippingConf(Streams=[stream], MaxCandidates=2000, AcceptBadEvents=False, BadEventSelection=filterBadEvents) # Define the node killer, and make sure to kill everything corresponding to # the stream which we want to swim outputs = [] from Configurables import Swimming__PVReFitter as ReFitter for l in lines: for f in l.filterMembers(): if hasattr(f, 'ReFitPVs') and f.ReFitPVs: if not config.getProp('RefitPVs'): log.warning('RefitPVs is not set, but stripping line applies refitting. Refitted ' + \ 'PVs will be used for turning-point lifetime calculations.') config.setProp('RefitPVs', True) t = f.PVReFitters[''] f.PVReFitters = {'': 'Swimming::PVReFitter/PVReFitter'} f.addTool(ReFitter, 'PVReFitter') f.PVReFitter.PVReFitter = t elif not hasattr(f, 'Output'): continue # Remove the last item so we get everything (Particle, relations, # decayVertices, etc... o = '/'.join(f.Output.split('/')[:-1]) outputs.append(o) print "Outputs are", outputs mykiller = EventNodeKiller("killStripping") # Some default nodes which we will want to kill in all cases nodestokill = outputs + ['Strip', '/Event/Rec/Vertex/Primary'] mykiller.Nodes = nodestokill deathstar = GaudiSequencer("killStrippingSeq") deathstar.Members = [mykiller] # Configure DaVinci DaVinci().InputType = config.getProp('InputType') DaVinci().DataType = config.getProp('DataType') DaVinci().Simulation = config.getProp('Simulation') DaVinci().DDDBtag = config.getProp('DDDBtag') DaVinci().CondDBtag = config.getProp('CondDBtag') try: DaVinci().Persistency = config.getProp('Persistency') except AttributeError: print "DaVinci doesn't have a Persistency attribute to set" # The sequence for the swimming has to be configured # by hand inserting the node killer before it DaVinci().appendToMainSequence([deathstar]) DaVinci().appendToMainSequence([sc.sequence()]) # Since the name of the output file is configured in two places in DaVinci, # do some splitting. splitName = config.getProp('OutputFile').split(os.path.extsep) seqName = '' prefix = '' if len(splitName) <= 2: seqName = splitName[0] print "Warning, an output filename in three parts was specified. This does not work well, " + \ " so 'Swimming.' will be prefixed." prefix = 'Swimming' else: prefix = splitName[0] seqName = os.path.extsep.join(splitName[1:-1]) dstWriter = None print config.getProp('OutputType') # Offline candidate selection sequences sequences = [] offCands = config.getProp('OffCands').keys() for i, cands in enumerate(offCands): data = AutomaticData(Location=cands + "/Particles") offSeq = SelectionSequence("OfflineCandidates_%d" % i, TopSelection=data) sequences.append(offSeq) # selection sequence for offline candidates muCands = config.getProp('MuDSTCands') for i, cands in enumerate(muCands): # Add extra selections for additional MuDSTCands data = AutomaticData(Location=cands + "/Particles") seq = SelectionSequence("MuDSTCands_%d" % i, TopSelection=data) sequences.append(seq) selectionSeq = MultiSelectionSequence(seqName, Sequences=sequences) if config.getProp('OutputType') == 'MDST': pack = False isMC = config.getProp("Simulation") SwimmingConf = config.getProp('MicroDSTStreamConf') SwimmingElements = config.getProp('MicroDSTElements') if SwimmingConf == False: from DSTWriters.Configuration import stripMicroDSTStreamConf SwimmingConf = stripMicroDSTStreamConf(pack=pack, isMC=isMC) if len(SwimmingElements) == 0: from DSTWriters.Configuration import stripMicroDSTElements from DSTWriters.microdstelements import CloneSwimmingReports, CloneParticleTrees, CloneTPRelations mdstElements = stripMicroDSTElements(pack=pack, isMC=isMC) SwimmingElements = [CloneSwimmingReports()] for element in mdstElements: SwimmingElements += [element] if type(element) == CloneParticleTrees: SwimmingElements += [CloneTPRelations("P2TPRelations")] streamConf = {'default': SwimmingConf} elementsConf = {'default': SwimmingElements} try: from DSTWriters.__dev__.Configuration import MicroDSTWriter except: from DSTWriters.Configuration import MicroDSTWriter dstWriter = MicroDSTWriter('MicroDST', StreamConf=streamConf, MicroDSTElements=elementsConf, WriteFSR=config.getProp('WriteFSR'), OutputFileSuffix=prefix, SelectionSequences=[selectionSeq]) elif config.getProp('OutputType') == 'DST': try: from DSTWriters.__dev__.streamconf import OutputStreamConf from DSTWriters.__dev__.Configuration import SelDSTWriter except ImportError: from DSTWriters.streamconf import OutputStreamConf from DSTWriters.Configuration import SelDSTWriter streamConf = OutputStreamConf(streamType = InputCopyStream, fileExtension = '.dst', extraItems = [config.getProp('SwimmingPrefix') + '/Reports#1'] +\ list(set([l + '/P2TPRelations#1' for l in config.getProp('OffCands').values()]))) SelDSTWriterElements = {'default': []} SelDSTWriterConf = {'default': streamConf} dstWriter = SelDSTWriter('FullDST', StreamConf=SelDSTWriterConf, MicroDSTElements=SelDSTWriterElements, WriteFSR=config.getProp('WriteFSR'), OutputFileSuffix=prefix, SelectionSequences=[selectionSeq]) DaVinci().appendToMainSequence([dstWriter.sequence()])
def configure(datafiles, catalogs=[], castor=False, params={}): """ Job configuration """ logger.info("start: params: %s " % params) from BenderTools.Parser import hasInFile the_year = "2011" if params: the_year = params['Year'] logger.info('Year is set from params to be %s ' % the_year) else: if hasInFile(datafiles, 'Collision11'): the_year = '2011' elif hasInFile(datafiles, 'Collision12'): the_year = '2012' elif hasInFile(datafiles, 'Stripping17'): the_year = '2011' elif hasInFile(datafiles, 'Stripping13'): the_year = '2011' elif hasInFile(datafiles, 'Stripping15'): the_year = '2011' elif hasInFile(datafiles, 'Stripping17'): the_year = '2011' elif hasInFile(datafiles, 'Stripping19'): the_year = '2012' logger.info('Year is set from files to be %s ' % the_year) # # check # if '2011' == the_year and hasInFile(datafiles, 'Collision12'): raise AttributeError, 'Invalid Year %s ' % the_year if '2012' == the_year and hasInFile(datafiles, 'Collision11'): raise AttributeError, 'Invalid Year %s ' % the_year logger.info('Use the Year = %s ' % the_year) # # dimuon locations in DIMUON.DST # Jpsi_det_location = '/Event/AllStreams/Phys/FullDSTDiMuonJpsi2MuMuDetachedLine/Particles' Jpsi_unb_location = '/Event/AllStreams/Phys/FullDSTDiMuonJpsi2MuMuTOSLine/Particles' if hasInFile(datafiles, '/MC/MC11a/'): Jpsi_unb_location = '/Event/AllStreams/Phys/FullDSTDiMuonJpsi2MuMuLine/Particles' logger.warning('Rename ``unbised line'' to be %s ' % Jpsi_unb_location) from PhysSelPython.Wrappers import AutomaticData jpsi_det = AutomaticData(Location=Jpsi_det_location) jpsi_unb = AutomaticData(Location=Jpsi_unb_location) # pions : from GaudiConfUtils.ConfigurableGenerators import FilterDesktop alg_pions = FilterDesktop( # Preambulo=["from LoKiPhysMC.decorators import mcMatch"], Code=""" ( PT > 500 * MeV ) & ( CLONEDIST > 5000 ) & ( TRGHOSTPROB < 0.5 ) & ( TRCHI2DOF < 4 ) & in_range ( 2 , ETA , 5 ) & HASRICH & mcMatch( '[B_c+ => ( J/psi(1S) => mu+ mu- ) ^pi+ ]CC' , 1 ) """ , ) ## ( PROBNNpi > 0.10 ) from PhysSelPython.Wrappers import Selection from StandardParticles import StdAllLoosePions pions = Selection( "ThePions", Algorithm=alg_pions, RequiredSelections=[StdAllLoosePions] ) alg_kaons = FilterDesktop( # Preambulo=["from LoKiPhysMC.decorators import mcMatch"], Code=""" ( PT > 500 * MeV ) & ( CLONEDIST > 5000 ) & ( TRCHI2DOF < 4 ) & ( TRGHOSTPROB < 0.5 ) & in_range ( 2 , ETA , 5 ) & HASRICH & mcMatch( '[B+ => ( J/psi(1S) => mu+ mu- ) ^K+ ]CC' , 1 ) """ ) ## ( PROBNNk > 0.10 ) from StandardParticles import StdAllLooseKaons kaons = Selection( "TheKaons", Algorithm=alg_kaons, RequiredSelections=[StdAllLooseKaons] ) # Preambulo = [ # shortcut for chi2 of vertex fit "chi2vx = VFASPF(VCHI2)", # shortcut for the c*tau "from GaudiKernel.PhysicalConstants import c_light", # use the embedded cut for chi2(LifetimeFit)<16 "ctau_25 = BPVLTIME ( 25 ) * c_light ", "mbc_acut = in_range ( 6.050 * GeV , AM , 6.550 * GeV ) ", "mbp_acut = in_range ( 5.100 * GeV , AM , 5.550 * GeV ) ", # mass-cut for beauty particles "mbc_cut = in_range ( 6.100 * GeV , M , 6.500 * GeV ) ", "mbp_cut = in_range ( 5.150 * GeV , M , 5.500 * GeV ) ", # "from LoKiPhysMC.decorators import mcMatch" ] # Bc : from GaudiConfUtils.ConfigurableGenerators import CombineParticles alg_bc = CombineParticles( DecayDescriptor="[B_c+ -> J/psi(1S) pi+ ]cc", DaughtersCuts={ "J/psi(1S)": "mcMatch( '[ B_c+ => ^( J/psi(1S) => mu+ mu- ) pi+ ]CC' , 1 )" }, Preambulo=Preambulo, CombinationCut=" mbc_acut ", MotherCut=""" ( chi2vx < 25 ) & mbc_cut & ( ctau_25 > %s ) & mcMatch( '[ B_c+ => ( J/psi(1S) => mu+ mu- ) pi+ ]CC' , 1 ) """ % ( 40 * micrometer ) ) # B+ : alg_bu = CombineParticles( DecayDescriptor="[B+ -> J/psi(1S) K+ ]cc", DaughtersCuts={ "J/psi(1S)": "mcMatch( '[ B+ => ^( J/psi(1S) => mu+ mu- ) K+ ]CC' , 1 )" }, Preambulo=Preambulo, CombinationCut=" mbp_acut ", MotherCut=""" ( chi2vx < 25 ) & mbp_cut & ( ctau_25 > %s ) & mcMatch( '[ B+ => ( J/psi(1S) => mu+ mu- ) K+ ]CC' , 1 ) """ % ( 40 * micrometer ) ) sel_bc_det = Selection( "TheBc_det", Algorithm=alg_bc, RequiredSelections=[jpsi_det, pions] ) sel_bc_unb = Selection( "TheBc_unb", Algorithm=alg_bc, RequiredSelections=[jpsi_unb, pions] ) sel_bu_det = Selection( "TheB_det", Algorithm=alg_bu, RequiredSelections=[jpsi_det, kaons] ) sel_bu_unb = Selection( "TheB_unb", Algorithm=alg_bu, RequiredSelections=[jpsi_unb, kaons] ) from PhysSelPython.Wrappers import SelectionSequence Bc_det_seq = SelectionSequence("Bc_det", TopSelection=sel_bc_det) Bu_det_seq = SelectionSequence("Bu_det", TopSelection=sel_bu_det) Bc_unb_seq = SelectionSequence("Bc_unb", TopSelection=sel_bc_unb) Bu_unb_seq = SelectionSequence("Bu_unb", TopSelection=sel_bu_unb) # # selection sequence # mode = params['Mode'] mode = mode.upper() if 0 <= mode.find('BC') or 0 <= mode.find('PI'): seqs = [Bc_det_seq, Bc_unb_seq] # seqs = [ Bc_det_seq ] elif 0 <= mode.find('B+') or 0 <= mode.find('K+'): seqs = [Bu_det_seq, Bu_unb_seq] # seqs = [ Bu_det_seq ] else: raise from PhysSelPython.Wrappers import MultiSelectionSequence B_SEQ = MultiSelectionSequence( "B2PSI", Sequences=seqs, ) from DSTWriters.Configuration import (SelDSTWriter, stripMicroDSTStreamConf, stripMicroDSTElements) # Configuration of SelDSTWriter SelDSTWriterConf = { 'default': stripMicroDSTStreamConf(pack=False)} SelDSTWriterElements = { 'default': stripMicroDSTElements(pack=False)} udstWriter = SelDSTWriter( "MyMicroDSTWriter", StreamConf=SelDSTWriterConf, MicroDSTElements=SelDSTWriterElements, OutputFileSuffix='MCBSEQ', SelectionSequences=[B_SEQ] ) # Read only fired events to speed up from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters( STRIP_Code="HLT_PASS_RE('Stripping.*DiMuonJpsi2MuMu.*')", VOID_Code=""" ( 0.5 < CONTAINS('%s') ) | ( 0.5 < CONTAINS('%s') ) """ % ( Jpsi_det_location , Jpsi_unb_location ) ) # fltrs_0 = LoKi_Filters( VOID_Code=""" ( EXISTS ( '/Event/DAQ/RawEvent') | EXISTS('/Event/Trigger/RawEvent' ) ) & EXISTS ( '/Event/Strip/Phys/DecReports') & ( RECSUMMARY ( 0 , -1 ) > 0.5 ) """ ) # # finally: DaVinci # ## needed for job configuration from Configurables import DaVinci davinci = DaVinci( EventPreFilters=fltrs_0.filters( 'Filters0') + fltrs.filters('Filters1'), DataType=the_year, InputType='MDST', Simulation=True, PrintFreq=1000, EvtMax=-1, # HistogramFile='MCBc_Histos.root', TupleFile='MCBc.root', # DDDBtag=params['DDDB'], CondDBtag=params['SIMCOND'], # Lumi=False # True , # ) davinci.appendToMainSequence([udstWriter.sequence()]) # # come back to Bender # setData(datafiles, catalogs, castor) from BenderTools.Utils import silence silence() # gaudi = appMgr() # logger.info("end: params: %s " % params) return SUCCESS
def myMicroDSTStreamConf(pack=True): conf = stripMicroDSTStreamConf(pack) conf.extraItems += ['/Event/Counters#1'] conf.extraItems += ['/Event/Counters/CharmEW#1'] return conf
# Configure the dst writers for the output # enablePacking = True from DSTWriters.microdstelements import * from DSTWriters.Configuration import ( SelDSTWriter, stripDSTStreamConf, stripDSTElements, stripMicroDSTStreamConf, stripMicroDSTElements, stripCalibMicroDSTStreamConf ) # # Configuration of MicroDST # per-event an per-line selective writing of the raw event is active (selectiveRawEvent=True) # mdstStreamConf = stripMicroDSTStreamConf(pack=enablePacking, selectiveRawEvent=True) mdstElements = stripMicroDSTElements(pack=enablePacking) # # Configuration of SelDSTWriter # per-event an per-line selective writing of the raw event is active (selectiveRawEvent=True) # SelDSTWriterElements = { 'default' : stripDSTElements(pack=enablePacking), charmMicroDSTname : mdstElements, leptonicMicroDSTname : mdstElements, pidMicroDSTname : mdstElements, bhadronMicroDSTname : mdstElements } SelDSTWriterConf = {
Sequences = [ SelectionSequence ( 'Ups' , sel_ups ) , ## SelectionSequence ( 'Chib', sel_chib ) , SelectionSequence ( 'Y&C' , sel_Ycharm ) ] ) # ============================================================================= ## micro-DST writer # ============================================================================= from DSTWriters.Configuration import ( SelDSTWriter , stripMicroDSTStreamConf , stripMicroDSTElements ) # Configuration of SelDSTWriter SelDSTWriterConf = { 'default' : stripMicroDSTStreamConf ( pack = False ) } SelDSTWriterElements = { 'default' : stripMicroDSTElements ( pack = False , refit = True ) } uDstWriter = SelDSTWriter( "MyDSTWriter" , StreamConf = SelDSTWriterConf , MicroDSTElements = SelDSTWriterElements , OutputFileSuffix = 'BandQ' , ## output PRE-fix! SelectionSequences = [ psi_x0 , ] ) # ## Read only fired events to speed up #