ATLAS Offline Software
Loading...
Searching...
No Matches
python.EventCleaningConfig.EventCleaningBlock Class Reference
Inheritance diagram for python.EventCleaningConfig.EventCleaningBlock:
Collaboration diagram for python.EventCleaningConfig.EventCleaningBlock:

Public Member Functions

 __init__ (self)
 instanceName (self)
 getDefaultGRLs (self, data_year)
 makeAlgs (self, config)

Public Attributes

 userGRLFiles
 useRandomRunNumber
 noFilter
 GRLDict
 runPrimaryVertexSelection
 runEventCleaning

Detailed Description

the ConfigBlock for event cleaning

Definition at line 8 of file EventCleaningConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.EventCleaningConfig.EventCleaningBlock.__init__ ( self)

Definition at line 11 of file EventCleaningConfig.py.

11 def __init__ (self) :
12 super (EventCleaningBlock, self).__init__ ()
13 self.addOption ('runPrimaryVertexSelection', True, type=bool,
14 info="whether to run primary vertex selection.")
15 self.addOption ('runEventCleaning', False, type=bool,
16 info="whether to run event cleaning (sets up an instance of "
17 "`CP::EventFlagSelectionAlg`).")
18 self.addOption ('runGRL', True, type=bool,
19 info="whether to run GRL decoration/selection.")
20 self.addOption ('userGRLFiles', [], type=None,
21 info="a list of GRL files (list of strings) to select data from.")
22 self.addOption ('minTracksPerVertex', 2, type=int,
23 info="minimum number of tracks per vertex.")
24 self.addOption ('selectionFlags', ['DFCommonJets_eventClean_LooseBad'], type=None,
25 info="flags (list of strings) to use for jet cleaning.")
26 # This is a vector<bool>, so parsing True/False is not handled
27 # in AnalysisBase, but we can evade this with numerical values
28 self.addOption ('invertFlags', [0], type=None,
29 info="list of booleans determining whether to invert the cut of the "
30 "above selectionFlags. In AnalysisBase, use 0/1 values instead.")
31 self.addOption ('GRLDict', {}, type=None, info="a custom GRL dictionary with key some name and value a GRL file. Leaving it empty will use the recommended values.")
32 self.addOption ('noFilter', False, type=bool,
33 info="whether to toggle off event filtering.")
34 self.addOption ('useRandomRunNumber', False, type=bool,
35 info="use `RandomRunNumber` to compute GRL info. Only supported for MC")
36
37 if self.runGRL and self.userGRLFiles:
38 raise ValueError("No userGRLFiles should be specified if runGRL=False")
39

Member Function Documentation

◆ getDefaultGRLs()

python.EventCleaningConfig.EventCleaningBlock.getDefaultGRLs ( self,
data_year )
returns a reasonable set of GRLs that should be suited for most analyses 

Definition at line 44 of file EventCleaningConfig.py.

44 def getDefaultGRLs (self, data_year) :
45 """ returns a reasonable set of GRLs that should be suited for most analyses """
46 from GoodRunsLists.GoodRunsListsDictionary import getGoodRunsLists
47 GRLDict = getGoodRunsLists()
48
49 GRLKey = 'GRL' + str(data_year)
50 if data_year==2017 or data_year==2018:
51 GRLKey = GRLKey + '_Triggerno17e33prim'
52 return GRLDict[GRLKey]
53

◆ instanceName()

python.EventCleaningConfig.EventCleaningBlock.instanceName ( self)
Return the instance name for this block

Definition at line 40 of file EventCleaningConfig.py.

40 def instanceName (self) :
41 """Return the instance name for this block"""
42 return '' # no instance name needed for singleton block
43

◆ makeAlgs()

python.EventCleaningConfig.EventCleaningBlock.makeAlgs ( self,
config )

Definition at line 54 of file EventCleaningConfig.py.

54 def makeAlgs (self, config) :
55
56 # Apply GRL
57 if self.runGRL and (config.dataType() is DataType.Data or self.useRandomRunNumber):
58 if config.dataType() is DataType.Data and self.useRandomRunNumber:
59 raise ValueError ("UseRandomRunNumber is only supported for MC!")
60
61 if self.noFilter:
62 # here we only decorate the PHYSLITE events with a boolean and don't do any cleaning
63 # Set up the GRL Decoration
64 if not self.GRLDict:
65 raise ValueError ("No GRLDict specified for GRL decoration, please specify a GRLDict")
66
67 for GRLDecoratorName, GRLFileList in self.GRLDict.items():
68 if isinstance(GRLFileList, str):
69 GRLFileList = [GRLFileList]
70
71 alg = config.createAlgorithm("GRLSelectorAlg", GRLDecoratorName)
72 config.addPrivateTool("Tool", "GoodRunsListSelectionTool")
73 alg.Tool.UseRandomRunNumber = self.useRandomRunNumber
74 alg.Tool.GoodRunsListVec = GRLFileList
75 alg.noFilter = True
76 alg.grlKey = f"EventInfo.{GRLDecoratorName}"
77
78 config.addOutputVar("EventInfo", GRLDecoratorName, GRLDecoratorName, noSys=True, auxType="char")
79 else:
80 # Set up the GRL selection:
81 alg = config.createAlgorithm( 'GRLSelectorAlg', 'GRLSelectorAlg' )
82 config.addPrivateTool( 'Tool', 'GoodRunsListSelectionTool' )
83 alg.Tool.UseRandomRunNumber = self.useRandomRunNumber
84 if self.userGRLFiles:
85 alg.Tool.GoodRunsListVec = self.userGRLFiles
86 else:
87 alg.Tool.GoodRunsListVec = self.getDefaultGRLs( config.dataYear() )
88
89 # Skip events with no primary vertex:
90 if self.runPrimaryVertexSelection:
91 alg = config.createAlgorithm( 'CP::VertexSelectionAlg',
92 'PrimaryVertexSelectorAlg',
93 reentrant=True )
94 alg.VertexContainer = 'PrimaryVertices'
95 alg.MinVertices = 1
96 alg.MinTracks = self.minTracksPerVertex
97
98 # Set up the event cleaning selection:
99 if self.runEventCleaning:
100 if config.dataType() is DataType.Data:
101 alg = config.createAlgorithm( 'CP::EventStatusSelectionAlg', 'EventStatusSelectionAlg' )
102 alg.FilterKey = 'EventErrorState'
103 alg.FilterDescription = 'selecting events without any error state set'
104
105 alg = config.createAlgorithm( 'CP::EventFlagSelectionAlg', 'EventFlagSelectionAlg' )
106 alg.FilterKey = 'JetCleaning'
107 alg.selectionFlags = [f'{sel},as_char' for sel in self.selectionFlags]
108 alg.invertFlags = self.invertFlags
109 alg.FilterDescription = f"selecting events passing: {','.join(alg.selectionFlags)}"
110
111
112

Member Data Documentation

◆ GRLDict

python.EventCleaningConfig.EventCleaningBlock.GRLDict

Definition at line 64 of file EventCleaningConfig.py.

◆ noFilter

python.EventCleaningConfig.EventCleaningBlock.noFilter

Definition at line 61 of file EventCleaningConfig.py.

◆ runEventCleaning

python.EventCleaningConfig.EventCleaningBlock.runEventCleaning

Definition at line 99 of file EventCleaningConfig.py.

◆ runPrimaryVertexSelection

python.EventCleaningConfig.EventCleaningBlock.runPrimaryVertexSelection

Definition at line 90 of file EventCleaningConfig.py.

◆ useRandomRunNumber

python.EventCleaningConfig.EventCleaningBlock.useRandomRunNumber

Definition at line 57 of file EventCleaningConfig.py.

◆ userGRLFiles

python.EventCleaningConfig.EventCleaningBlock.userGRLFiles

Definition at line 37 of file EventCleaningConfig.py.


The documentation for this class was generated from the following file: