Created
March 23, 2015 17:00
-
-
Save alexpearce/8616f004db90f3515b60 to your computer and use it in GitHub Desktop.
MVA discriminant in DecayTreeTuple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add this directory to PATH | |
import sys | |
import os | |
sys.path.append(os.getcwd()) | |
from Configurables import ( | |
DaVinci, | |
DecayTreeTuple, | |
GaudiSequencer, | |
ProcStatusCheck, | |
InputCopyStream | |
) | |
from DSTWriters.Configuration import SelDSTWriter | |
from DecayTreeTuple.Configuration import * | |
from MVADictHelpers import addTMVAclassifierTuple | |
from GaudiConf import IOHelper | |
from CommonParticles.Utils import DefaultTrackingCuts | |
from StrippingConf.StrippingStream import StrippingStream | |
from StrippingD2HHHForXSec import StrippingD2HHHForXSecConf | |
from StrippingD2HHHForXSec import default_config | |
from StrippingConf.Configuration import StrippingConf | |
# Edit the stripping configuration | |
default_config['CONFIG']['Hlt1Filter'] = None | |
default_config['CONFIG']['Hlt2Filter'] = None | |
default_config['CONFIG']['D_MVA_MIN'] = 0.1 | |
default_config['CONFIG']['D_MVA_Weights'] = 'weights.xml' | |
t = DecayTreeTuple('Dp2KpipiTuple') | |
t.Inputs = ["Phys/{0}D2KPPLine/Particles".format(default_config['NAME'])] | |
t.Decay = "[D+ -> ^K- ^pi+ ^pi+]CC" | |
t.addBranches({ | |
'Dp': '[D+ -> K- pi+ pi+]CC', | |
'Dp_h1': '[D+ -> ^K- pi+ pi+]CC', | |
'Dp_h2': '[D+ -> K- ^pi+ pi+]CC', | |
'Dp_h3': '[D+ -> K- pi+ ^pi+]CC' | |
}) | |
t.ToolList = [ | |
'TupleToolKinematic', | |
'TupleToolGeometry', | |
'TupleToolPid', | |
'TupleToolTrackInfo', | |
'TupleToolPrimaries' | |
] | |
addTMVAclassifierTuple( | |
t.Dp, | |
default_config['CONFIG']['D_MVA_Weights'], | |
default_config['CONFIG']['D_MVA_Variables'], | |
Name='BDT', | |
Keep=True, | |
Preambulo=[''] | |
) | |
# Tighten Trk Chi2 to <3 | |
DefaultTrackingCuts().Cuts = { | |
"Chi2Cut": [0, 3], | |
"CloneDistCut": [5000, 9e+99] | |
} | |
# Now build the stream | |
stream = StrippingStream("MyStream") | |
linebuilder = StrippingD2HHHForXSecConf( | |
name=default_config['NAME'], | |
config=default_config['CONFIG'] | |
) | |
stream.appendLines(linebuilder.lines()) | |
sc = StrippingConf( | |
Streams=[stream], | |
MaxCandidates=2000, | |
AcceptBadEvents=False, | |
BadEventSelection=ProcStatusCheck(), | |
TESPrefix='NowHereIsNowhere' | |
) | |
# Copy events passing the stripping in to the LDST, including the candidates | |
# themselves | |
sdstw = SelDSTWriter( | |
'MyDSTWriter', | |
OutputFileSuffix='LDSTSel', | |
SelectionSequences=sc.activeStreams() | |
) | |
gs = GaudiSequencer('MySequence', Members=[t, sdstw.sequence()]) | |
dv = DaVinci() | |
dv.EvtMax = -1 | |
dv.HistogramFile = "DVHistos.root" | |
dv.appendToMainSequence([sc.sequence()]) | |
dv.ProductionType = "Stripping" | |
dv.DataType = "2012" | |
dv.InputType = "LDST" | |
dv.TupleFile = "DVntuple.root" | |
dv.UserAlgorithms = [gs] | |
dv.Lumi = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment