TWiki
>
General Web
>
Lhcb
?
>
DaVinci
(revision 5) (raw view)
Edit
Attach
---+Using DaVinci to fill an nTuple This page is designed to give a brief outline of how to use DaVinci to fill nTuples from data or Monte Carlo. For more details please refer to the DaVinci tutorials from LHCb: <a href="https://twiki.cern.ch/twiki/bin/view/LHCb/DaVinciTutorial" title="DaVinciTut">https://twiki.cern.ch/twiki/bin/view/LHCb/DaVinciTutorial</a> My full options file is at the bottom of the page so you can use it for testing. ---++ Setting up DaVinci If you are working from eprexb, you first need to set up the LHCb environment: <verbatim> source /home/lhsoft/LbLogin.sh</verbatim> Then set up the DaVinci project <verbatim> SetupProject DaVinci v32r2p1 </verbatim> Note that you need to make sure the version of DaVinci you are using contains the version of Stripping you are using. For example, if you are using Stripping 20, you need to use a version of DaVinci higher than v32. If you don't specify a version, then the latest version available will be set up. ---++Using =DecayTreeTuple= The tool used to fill nTuples is =DecayTreeTuple=. Create and options file (.py) and start and instance of =DecayTreeTuple=: <verbatim>from Configurables import DecayTreeTuple from DecayTreeTuple.Configuration import * tuple=DecayTreeTuple() </verbatim> You then need to specify the input location for the tuple. This is where the output from the stripping line is stored in the file: <verbatim> tuple.Inputs=["/Event/Bhadron/Phys/B2XEtaB2etapKSLLLine/Particles"]</verbatim> If you are producing and nTuple which is empty, it is likely that your input location is wrong. You now need to add a list of tools to the tuple. This specifies exactly which information is filled in the nTuple. Below is an example. Please see the tutorials for a full list of =TupleTools=. <verbatim> tuple.ToolList += ["TupleToolGeometry" , "TupleToolKinematic", "TupleToolEventInfo"] </verbatim> You need to specify the decay you are looking at. =^= means that information from the =TupleTools= will be filled for that particle. By default the head particle will always be filled (B0). <verbatim>tuple.Decay="[B0 -> (^eta_prime -> ^pi+ ^pi- ^gamma) (^KS0 -> ^pi+ ^pi-)]cc"</verbatim> You can also specify some branches, so that different information can be filled for different particles. For example, if you want different information for the B0, use the branch below. <verbatim>tuple.Branches={"B0":"B0:[B0 -> (eta_prime -> pi+ pi- gamma) (KS0 -> pi+ pi-)]cc" } tuple.addTool( TupleToolDecay, name = "B0" )</verbatim> In order to fill information for calculating trgger efficiencies, you will need the TISTOS tool. You need to specify =VerboseL0,Hlt1,Hlt2=True= to ensure that the information is filled properly. =TriggerList= should contain all the trigger lines you are interested in. <verbatim> from Configurables import TupleToolTISTOS tistos = tuple.B0.addTupleTool(TupleToolTISTOS, name="TupleToolTISTOS") tistos.VerboseL0=True tistos.VerboseHlt1=True tistos.VerboseHlt2=True tistos.TriggerList=["L0PhotonDecision", "L0ElectronDecision", "Hlt1TrackAllL0Decision", "Hlt2Topo2BodyBBDTDecision"] </verbatim> Another useful tool is the =EventTuple=. This is similar to =DecayTreeTuple=, but will fill information for every event processed, not just the ones which pass your stripping line. This is useful for calculating efficiencies, and you only need to include one tool. <verbatim> etuple=EventTuple() etuple.ToolList=["TupleToolEventInfo"] </verbatim> At the end of you options file, you need to specify the options for the DaVinci configurable. Your tuples need to be included in the =UserAlgorithms=, and you need to make sure the specified DataType is correct for the data you are looking at. =EvtMax= is the number of events you want to process. -1 asks to process all events. <verbatim> DaVinci().UserAlgorithms+[tuple,etuple] DaVinci().InputType='DST' DaVinci().TupleFile="davinci.root" DaVinci().HistogramFile="davinci-histos.root" DaVinci().DataType="2012" DaVinci().EvtMax=-1 DaVinci().PrintFreq=1000 DaVinci().MoniSequence=[tuple] DaVinci().Simulation=False </verbatim> ---++Running on Monte Carlo =DecayTreeTuple= works slightly differently on Monte Carlo than data. Firstly you need to set the simulation flag in davinci to true, and then specify the database tags used to create the Monte Carlo. You can find these out from the bookkeeping. <verbatim>DaVinci().Simulation=True DaVinci().DDDBtag='MC11-20111102' DaVinci().CondDBtag='sim-20111111-vc-mu100' </verbatim> The Input location for =DecayTreeTuple= seems to be slightly different for Monte Carlo. You should start at =/Phys=: <verbatim> tuple.Inputs=["/Phys/B2XEtaB2etapKSLLLine/Particles"]</verbatim> It is likely that the Monte Carlo you have has not been run with the correct stripping. You can run a different version of the Stripping with the following options: <verbatim> from StrippingConf.Configuration import StrippingConf, StrippingStream from StrippingSettings.Utils import strippingConfiguration from StrippingArchive.Utils import buildStreams from StrippingArchive import strippingArchive stripping="stripping20" config=strippingConfiguration(stripping) archive=strippingArchive(stripping) streams=buildStreams(stripping=config,archive=archive) MyStream = StrippingStream("MyStream") MyLines = ["StrippingB2XEtaB2etapKSLLLine] 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([sc.sequence()]) </verbatim> ---++Running on a MicroDST MicroDST (or uDST) is a file format designed to reduce the amount of data stored, and so reduce the strain of computing resources. There is certain information that is not available on a uDST, and some things are stored in a slightly different way, but the aim is to make it as close to processing a DST as possible. This means you can run =DecayTreeTuple= on uDSTs in the same way. There will be some =TupleTools= which aren't available, for example =TupleToolTagging= or =TupleToolTrackIsolation=. There are also some files which =DecayTreeTuple= will look for but don't exist, producing an error. You therefore need to kill these nodes: <verbatim>from Configurables import EventNodeKiller eventNodeKiller = EventNodeKiller('DAQkiller') eventNodeKiller.Nodes = ['DAQ','pRec'] MySequencer.Members+=[eventNodeKiller] </verbatim> ---++Full Options File <verbatim> ############################################ # DaVinci Options for filling ntuple with # # B0 -> KS0 (eta' -> pi pi gamma) # # for data or Monte Carlo # ############################################ from Gaudi.Configuration import * from Configurables import DaVinci #set your options for the job simulation=True #If its simulation, the monte carlo sample you are running on sample='BdEtapKs-rhog' #If its data, the integrated luminosity from book-keeping lumi='549pb' mdst=True dataType='2011' magnet='magup' stripping='stripping20' sStream='Bhadron' #Your stripping line (without the leading 'Stripping') StrippingLine='B2XEtaB2etapKSLLLine' from Configurables import GaudiSequencer MySequencer = GaudiSequencer('Sequence') #Setting the output file names, the location for the tuple and the database tags if MC if(simulation): name="MC"+dataType+"-"+magnet+"-"+sample+"-"+StrippingLine+"-"+stripping location="Phys/"+StrippingLine+"/Particles" DaVinci().DDDBtag='MC11-20111102' DaVinci().CondDBtag='sim-20111111-vc-mu100' else: name="data"+dataType+"-"+magnet+"-"+StrippingLine+"-"+stripping+"-"+lumi location="/Event/"+sStream+"/Phys/"+StrippingLine+"/Particles" if(mdst): from Configurables import EventNodeKiller eventNodeKiller = EventNodeKiller('DAQkiller') eventNodeKiller.Nodes = ['DAQ','pRec'] MySequencer.Members+=[eventNodeKiller] if(simulation): #######run stripping20 on MC11################# from StrippingConf.Configuration import StrippingConf, StrippingStream from StrippingSettings.Utils import strippingConfiguration from StrippingArchive.Utils import buildStreams from StrippingArchive import strippingArchive config=strippingConfiguration(stripping) archive=strippingArchive(stripping) streams=buildStreams(stripping=config,archive=archive) MyStream = StrippingStream("MyStream") MyLines = ["Stripping"+StrippingLine] 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([sc.sequence()]) #Creating the ntuple from Configurables import DecayTreeTuple from DecayTreeTuple.Configuration import * tuple=DecayTreeTuple() tuple.Inputs=[location] tuple.ToolList += [ "TupleToolGeometry" , "TupleToolDira" , "TupleToolAngles" , "TupleToolPid" , "TupleToolKinematic" , "TupleToolPropertime" , "TupleToolPrimaries" ,"TupleToolEventInfo" , "TupleToolTrackInfo" , "TupleToolVtxIsoln" ,"TupleToolPhotonInfo"] if(mdst!=True): tuple.ToolList+=["TupleToolTrackIsolation", "TupleToolTagging"] if(simulation): tuple.ToolList+=["TupleToolMCTruth","TupleToolMCBackgroundInfo"] tuple.Decay="[B0 -> (^eta_prime -> ^pi+ ^pi- ^gamma) (^KS0 -> ^pi+ ^pi-)]cc" tuple.Branches={"B0":"B0:[B0 -> (eta_prime -> pi+ pi- gamma) (KS0 -> pi+ pi-)]cc" } tuple.addTool( TupleToolDecay, name = "B0" ) from Configurables import TupleToolTISTOS tistos = tuple.B0.addTupleTool(TupleToolTISTOS, name="TupleToolTISTOS") tistos.VerboseL0=True tistos.VerboseHlt1=True tistos.VerboseHlt2=True tistos.TriggerList=["L0PhotonDecision", "L0ElectronDecision", "Hlt1TrackPhotonDecision", "Hlt1TrackAllL0Decision","Hlt1TrackMuonDecision", "Hlt1TrackForwardPassThroughDecision","Hlt1TrackForwardPassThroughLooseDecision", "Hlt1SingleElectronNoIPDecision","L0HadronDecision","L0LocalPi0Decision","L0GlobalPi0Decision","L0MuonDecision","Hlt2Topo2BodyBBDTDecision","Hlt2Topo3BodyBBDTDecision","Hlt2Topo4BodyBBDTDecision", "Hlt2RadiativeTopoTrackTOSDecision", "Hlt2RadiativeTopoPhotonL0Decision","Hlt2TopoRad2BodyBBDTDecision","Hlt2TopoRad2plus1BodyBBDTDecision","Hlt2Topo2BodySimpleDecision","Hlt2Topo3BodySimpleDecision","Hlt2Topo4BodySimpleDecision","Hlt2B2HHDecision","Hlt2B2HHPi0_ResolvedDecision", "Hlt2B2HHPi0_MergedDecision","Hlt2B2KsHHTFKsLLDecision","Hlt2B2KsHHTFKsLLDecision","Hlt2Bd2KstGammaWideBMassDecision","Hlt2Bd2KstGammaLooseDiraDecision","Hlt2Bd2KstGammaDecision","Hlt2TopoE2BodyBBDTDecision","Hlt2TopoE3BodyBBDTDecision","Hlt2TopoE4BodyBBDTDecision","Hlt2CharmHadMinBiasD02KKDecision","Hlt2CharmHadMinBiasD02KPiDecision","Hlt2CharmHadMinBiasDplus2hhhDecision","Hlt2CharmHadMinBiasLambdaC2KPPiDecison"] etuple=EventTuple() etuple.ToolList=["TupleToolEventInfo"] MySequencer.Members+=[tuple,etuple] DaVinci().UserAlgorithms+=[MySequencer] if(mdst): DaVinci().InputType='MDST' else: DaVinci().InputType='DST' DaVinci().TupleFile=name+".root" DaVinci().HistogramFile=name+"-histos.root" DaVinci().DataType=dataType DaVinci().EvtMax=-1 DaVinci().PrintFreq=1000 DaVinci().MoniSequence=[tuple] DaVinci().Simulation=simulation </verbatim> -- Main.JamesMccarthy - 15 Nov 2012
Edit
|
Attach
|
Watch
|
P
rint version
|
H
istory
:
r6
<
r5
<
r4
<
r3
<
r2
|
B
acklinks
|
V
iew topic
|
Raw edit
|
More topic actions...
Topic revision: r5 - 04 Mar 2014
-
_47C_61UK_47O_61eScience_47OU_61Birmingham_47L_61ParticlePhysics_47CN_61nathanael_32farley
?
General
Log In
General Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
Webs
ALICE
ATLAS
BILPA
CALICE
Computing
General
LHCb
LinearCollider
Main
NA62
Publish
Sandbox
TWiki
Welcome
Copyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback