ATLAS Offline Software
Public Member Functions | List of all members
python.EventCleaningConfig.EventCleaningBlock Class Reference
Inheritance diagram for python.EventCleaningConfig.EventCleaningBlock:
Collaboration diagram for python.EventCleaningConfig.EventCleaningBlock:

Public Member Functions

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

Detailed Description

the ConfigBlock for event cleaning

Definition at line 8 of file EventCleaningConfig.py.

Constructor & Destructor Documentation

◆ __init__()

def 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. The default is True.")
15  self.addOption ('runEventCleaning', False, type=bool,
16  info="whether to run event cleaning (sets up an instance of "
17  "CP::EventFlagSelectionAlg). The default is False.")
18  self.addOption ('runGRL', True, type=bool,
19  info="whether to run GRL decoration/selection. The default is True.")
20  self.addOption ('userGRLFiles', [], type=None,
21  info="a list of GRL files (list of strings) to select data from. "
22  "The default is [] (empty list).")
23  self.addOption ('minTracksPerVertex', 2, type=int,
24  info="minimum number (integer) of tracks per vertex. The default is 2.")
25  self.addOption ('selectionFlags', ['DFCommonJets_eventClean_LooseBad'], type=None,
26  info="lags (list of strings) to use for jet cleaning. The default is "
27  "['DFCommonJets_eventClean_LooseBad'].")
28  # This is a vector<bool>, so parsing True/False is not handled
29  # in AnalysisBase, but we can evade this with numerical values
30  self.addOption ('invertFlags', [0], type=None,
31  info="list of booleans determining whether to invert the cut of the "
32  "above selectionFlags. The default is [0].")
33  self.addOption ('GRLDict', {}, type=None)
34  self.addOption ('noFilter', False, type=bool,
35  info="do apply event decoration, but do not filter. The default is False, i.e. 'We decorate events but do not filter' ")
36  self.addOption ('useRandomRunNumber', False, type=bool,
37  info="use RandomRunNumber to compute GRL info. Only supported for MC. The default is False")
38 
39  if self.runGRL and self.userGRLFiles:
40  raise ValueError("No userGRLFiles should be specified if runGRL=False")
41 

Member Function Documentation

◆ getDefaultGRLs()

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

Definition at line 46 of file EventCleaningConfig.py.

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

◆ instanceName()

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

Definition at line 42 of file EventCleaningConfig.py.

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

◆ makeAlgs()

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

Definition at line 56 of file EventCleaningConfig.py.

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

The documentation for this class was generated from the following file:
python.GoodRunsListsDictionary.getGoodRunsLists
def getGoodRunsLists()
Definition: GoodRunsListsDictionary.py:3
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:71
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
str
Definition: BTagTrackIpAccessor.cxx:11