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()]
SelDSTWriterConf = { 'default': stripDSTStreamConf(pack=enablePacking, selectiveRawEvent=True), charmMicroDSTname: mdstStreamConf, leptonicMicroDSTname: mdstStreamConf, bhadronMicroDSTname: mdstStreamConf, pidMicroDSTname: stripCalibMicroDSTStreamConf(pack=enablePacking, selectiveRawEvent=True) } dstWriter = SelDSTWriter("MyDSTWriter", StreamConf=SelDSTWriterConf, MicroDSTElements=SelDSTWriterElements, OutputFileSuffix='20151106', SelectionSequences=sc.activeStreams()) # # Add stripping TCK # #from Configurables import StrippingTCK #stck = StrippingTCK(HDRLocation = '/Event/Strip/Phys/DecReports', TCK=0x36112100) # #Configure DaVinci # # Change the column size of Timing table from Configurables import TimingAuditor, SequencerTimerTool
# ============================================================================= # 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( STRIP_Code=""" HLT_PASS_RE ( 'Stripping.*%s.*' ) """ % ups_name ) # ========================================================================
SelDSTWriterConf = { 'default': stripDSTStreamConf(pack=enablePacking, selectiveRawEvent=True), charmMicroDSTname: mdstStreamConf, leptonicMicroDSTname: mdstStreamConf, bhadronMicroDSTname: mdstStreamConf, pidMicroDSTname: stripCalibMicroDSTStreamConf(pack=enablePacking, selectiveRawEvent=True) } dstWriter = SelDSTWriter("MyDSTWriter", StreamConf=SelDSTWriterConf, MicroDSTElements=SelDSTWriterElements, OutputFileSuffix='000000', SelectionSequences=sc.activeStreams()) # # Add stripping TCK # # from Configurables import StrippingTCK # stck = StrippingTCK(HDRLocation = '/Event/Strip/Phys/DecReports', TCK=0x36112100) # #Configure DaVinci # # Change the column size of Timing table from Configurables import TimingAuditor, SequencerTimerTool
################################################################## from DSTWriters.microdstelements import * from DSTWriters.Configuration import (SelDSTWriter, stripDSTStreamConf, stripDSTElements ) SelDSTWriterElements = { 'default' : stripDSTElements() } SelDSTWriterConf = { 'default' : stripDSTStreamConf() } if MODE == 'MC': dstWriter = SelDSTWriter( "MyDSTWriter", StreamConf = SelDSTWriterConf, MicroDSTElements = SelDSTWriterElements, OutputFileSuffix ='MC', SelectionSequences = sc.activeStreams() ) ###################### DAVINCI SETTINGS ############################################ DaVinci().SkipEvents = 0 #1945 DaVinci().PrintFreq = 1000 DaVinci().EvtMax = EVTMAX DaVinci().TupleFile = "DVTuples1.root" DaVinci().HistogramFile = 'DVHistos.root' DaVinci().InputType = "DST" DaVinci().Simulation = False DaVinci().Lumi = True DaVinci().DataType = "2012" CondDB( LatestGlobalTagByDataType = '2012' )
sc = StrippingConf( Streams=[MyStream], MaxCandidates=2000, AcceptBadEvents=False, BadEventSelection=filterBadEvents, HDRLocation='NonexistingPlaceholder', ) # # Configuration of SelDSTWriter # SelDSTWriterElements = { 'default': stripDSTElements(), } SelDSTWriterConf = { 'default': stripDSTStreamConf(), } dstWriter = SelDSTWriter("MyDSTWriter", StreamConf=SelDSTWriterConf, OutputFileSuffix='TAGGING', SelectionSequences=sc.activeStreams()) # DaVinci Config DaVinci().appendToMainSequence([ sc.sequence(), dstWriter.sequence(), ])
seq = SelectionSequence("Charm2Mu", TopSelection=C2Mu_Strip) 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='Charm2Mu', SelectionSequences=[seq] ) # Read only fired events to speed up from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters( VOID_Code=""" 0.5 < CONTAINS('/Event/Charm/Phys/DiMuonAndCharmForPromptCharm/Particles') """ , STRIP_Code="HLT_PASS_RE('Stripping.*(DiMuonAndCharm).*')" ) the_year = "2011" ## the_year = "2012"
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 # Configuration of SelDSTWriter SelDSTWriterConf = {'default': myMicroDSTStreamConf(pack=False)} SelDSTWriterElements = {'default': stripMicroDSTElements(pack=False)} udstWriter = SelDSTWriter( "MyDSTWriter", StreamConf=SelDSTWriterConf, MicroDSTElements=SelDSTWriterElements, OutputFileSuffix='CFake', ## SelectionSequences = [ charmEW ] SelectionSequences=[s_cW] ) # Read only fired events to speed up from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters( STRIP_Code=" HLT_PASS_RE('Stripping.*(D0|Dh|D2|Ds|Lc|Lambdac)*.*') " # , VOID_Code = " SKIP ( 50 ) " ) the_year = "2011" ## the_year = "2012" fltrs = fltrs.filters('Filters')
leptonicMicroDSTname : mdstElements, pidMicroDSTname : mdstElements, bhadronMicroDSTname : mdstElements } SelDSTWriterConf = { 'default' : stripDSTStreamConf(pack=enablePacking, selectiveRawEvent=True), charmMicroDSTname : mdstStreamConf, leptonicMicroDSTname : mdstStreamConf, bhadronMicroDSTname : mdstStreamConf, pidMicroDSTname : stripCalibMicroDSTStreamConf(pack=enablePacking, selectiveRawEvent=True) } dstWriter = SelDSTWriter( "MyDSTWriter", StreamConf = SelDSTWriterConf, MicroDSTElements = SelDSTWriterElements, OutputFileSuffix ='000000', SelectionSequences = sc.activeStreams() ) # # Add stripping TCK # #from Configurables import StrippingTCK #stck = StrippingTCK(HDRLocation = '/Event/Strip/Phys/DecReports', TCK=0x36112100) # Change the column size of Timing table from Configurables import TimingAuditor, SequencerTimerTool TimingAuditor().addTool(SequencerTimerTool,name="TIMER") TimingAuditor().TIMER.NameSize = 60 from Configurables import AuditorSvc, ChronoAuditor
'default': stripDSTStreamConf(pack=enablePacking, selectiveRawEvent=True), charmMicroDSTname: mdstStreamConf, leptonicMicroDSTname: mdstStreamConf, bhadronMicroDSTname: mdstStreamConf, pidMicroDSTname: stripCalibMicroDSTStreamConf(pack=enablePacking, selectiveRawEvent=True) } import os dstWriter = SelDSTWriter("MyDSTWriter", StreamConf=SelDSTWriterConf, MicroDSTElements=SelDSTWriterElements, OutputFileSuffix=os.environ['FIRST_FILE'], SelectionSequences=sc.activeStreams()) # # Get lines that needs MDST.DST and their required raw banks # mdstDstLines = [ line.name() for line in sc.activeLines(mdstStreams) if (line.MDSTFlag and line.prescale() > 0) ] mdstDstRawEvts = {} for stream in sc.activeStreams(): if stream.name() in mdstStreams: mdstDstRawEvts.update(stream.getRequiredRawEvents()) # Locations to veto from MDST.DST
SelJpsi = Selection('SelJpsi_'+name, Algorithm = filter, RequiredSelections = [ MyLooseJpsi ]) printer = PrintDecayTree("Print_"+name, Inputs = [SelJpsi.outputLocation()]) SeqJpsi = SelectionSequence('SeqJpsi_'+name , TopSelection = SelJpsi , EventPreSelector = [ prescale ] , PostSelectionAlgs = [ printer ]) selections += [SeqJpsi] dstWriter = SelDSTWriter("JpsiDSTWriter_"+name, SelectionSequences = selections) dstWriter.MicroDSTElements['default'] += [CloneParticleMCInfo()] seq = dstWriter.sequence() DaVinci().UserAlgorithms = [ seq ] ############################################################################## DaVinci().EvtMax = 100 DaVinci().PrintFreq = 100 # DaVinci().SkipEvents = 0 DaVinci().DataType = "2010" DaVinci().Simulation = True ######################################################################## MessageSvc().Format = "% F%60W%S%7W%R%T %0W%M"
# ============================================================================= ## 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 # from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters ( STRIP_Code = """ HLT_PASS_RE ( 'Stripping.*DiMuonJpsi2MuMuDetached.*' ) | HLT_PASS_RE ( 'Stripping.*DiMuonPsi2MuMuDetached.*' ) | HLT_PASS_RE ( 'Stripping.*DiMuonDiMuonHighMass.*' ) """