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
 GRLSuffixDict
 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=list,
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=list,
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=list,
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=dict, 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 ('GRLSuffixDict', {}, type=dict, info="a year-suffix dictionary to help with autoconfiguration of GRL selection, e.g. selecting 'BjetHLT'.")
33 self.addOption ('noFilter', False, type=bool,
34 info="whether to toggle off event filtering.")
35 self.addOption ('useRandomRunNumber', False, type=bool,
36 info="use `RandomRunNumber` to compute GRL info. Only supported for MC.")
37
38 if self.runGRL and self.userGRLFiles:
39 raise ValueError("No userGRLFiles should be specified if runGRL=False")
40

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 45 of file EventCleaningConfig.py.

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

◆ instanceName()

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

Definition at line 41 of file EventCleaningConfig.py.

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

◆ makeAlgs()

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

Definition at line 57 of file EventCleaningConfig.py.

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

Member Data Documentation

◆ GRLDict

python.EventCleaningConfig.EventCleaningBlock.GRLDict

Definition at line 67 of file EventCleaningConfig.py.

◆ GRLSuffixDict

python.EventCleaningConfig.EventCleaningBlock.GRLSuffixDict

Definition at line 51 of file EventCleaningConfig.py.

◆ noFilter

python.EventCleaningConfig.EventCleaningBlock.noFilter

Definition at line 64 of file EventCleaningConfig.py.

◆ runEventCleaning

python.EventCleaningConfig.EventCleaningBlock.runEventCleaning

Definition at line 102 of file EventCleaningConfig.py.

◆ runPrimaryVertexSelection

python.EventCleaningConfig.EventCleaningBlock.runPrimaryVertexSelection

Definition at line 93 of file EventCleaningConfig.py.

◆ useRandomRunNumber

python.EventCleaningConfig.EventCleaningBlock.useRandomRunNumber

Definition at line 60 of file EventCleaningConfig.py.

◆ userGRLFiles

python.EventCleaningConfig.EventCleaningBlock.userGRLFiles

Definition at line 38 of file EventCleaningConfig.py.


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