ATLAS Offline Software
EventSelectionAnalysisSequence.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 #
3 # @author Tadej Novak
4 
5 # AnaAlgorithm import(s):
6 from AnaAlgorithm.AnaAlgSequence import AnaAlgSequence
7 from AnaAlgorithm.DualUseConfig import createAlgorithm, addPrivateTool
8 
9 
11  runPrimaryVertexSelection = True,
12  runEventCleaning = False,
13  minTracksPerVertex = 2,
14  userGRLFiles = [],
15  userSelectionFlags = ['DFCommonJets_eventClean_LooseBad'],
16  userInvertFlags = [0]):
17  """Create a basic event selection analysis algorithm sequence
18 
19  Keyword arguments:
20  dataType -- The data type to run on ("data", "mc" or "afii")
21  runPrimaryVertexSelection -- whether to run primary vertex selection
22  runEventCleaning -- wether to run event cleaning
23  userGRLFiles -- a list of GRL files to select data from
24  """
25 
26  if dataType not in ["data", "mc", "afii"] :
27  raise ValueError ("invalid data type: " + dataType)
28 
29  # Create the analysis algorithm sequence object:
30  seq = AnaAlgSequence( "EventSelectionAnalysisSequence" )
31 
32  if dataType == 'data':
33  grlFiles = userGRLFiles[:]
34 
35  # Set up the GRL selection:
36  alg = createAlgorithm( 'GRLSelectorAlg', 'GRLSelectorAlg' )
37  addPrivateTool( alg, 'Tool', 'GoodRunsListSelectionTool' )
38  alg.Tool.GoodRunsListVec = grlFiles
39 
40  seq.append( alg, inputPropName = None )
41 
42  # Skip events with no primary vertex:
43  if runPrimaryVertexSelection:
44  alg = createAlgorithm( 'CP::VertexSelectionAlg',
45  'PrimaryVertexSelectorAlg' )
46  alg.VertexContainer = 'PrimaryVertices'
47  alg.MinVertices = 1
48  alg.MinTracks = minTracksPerVertex
49 
50  seq.append( alg, inputPropName = None )
51 
52  # Set up the event cleaning selection:
53  if runEventCleaning:
54  if dataType == 'data':
55  alg = createAlgorithm( 'CP::EventStatusSelectionAlg', 'EventStatusSelectionAlg' )
56  alg.FilterKey = 'EventErrorState'
57  alg.FilterDescription = 'selecting events without any error state set'
58 
59  seq.append( alg, inputPropName = None )
60 
61  alg = createAlgorithm( 'CP::EventFlagSelectionAlg', 'EventFlagSelectionAlg' )
62  alg.FilterKey = 'JetCleaning'
63  alg.selectionFlags = [f'{sel},as_char' for sel in userSelectionFlags]
64  alg.invertFlags = userInvertFlags
65  alg.FilterDescription = f"selecting events passing: {','.join(alg.selectionFlags)}"
66 
67  seq.append( alg, inputPropName = None )
68 
69  # Return the sequence:
70  return seq
python.DualUseConfig.addPrivateTool
def addPrivateTool(alg, toolName, typeName)
Definition: DualUseConfig.py:180
python.EventSelectionAnalysisSequence.makeEventSelectionAnalysisSequence
def makeEventSelectionAnalysisSequence(dataType, runPrimaryVertexSelection=True, runEventCleaning=False, minTracksPerVertex=2, userGRLFiles=[], userSelectionFlags=['DFCommonJets_eventClean_LooseBad'], userInvertFlags=[0])
Definition: EventSelectionAnalysisSequence.py:10
python.DualUseConfig.createAlgorithm
def createAlgorithm(typeName, instanceName)
Definition: DualUseConfig.py:56