CMS 3D CMS Logo

Classes | Functions | Variables

EgammaHLTValidationUtils Namespace Reference

Classes

class  EgammaDQMModuleMaker

Functions

def findEgammaPaths
def getCXXTypesOfPath
def getModuleNamesOfPath
def getModulesOfSequence
def getPathsOfDataSet
def getProcessName
def getResult
def makeGeneratedParticleAndFiducialVolumeFilter
def makePSetForEgammaGenericFilter
def makePSetForElectronGenericFilter
def makePSetForEtFilter
def makePSetForL1SeedFilter
 print >> sys.stderr,msgPrefix,"WARNING: unknown module type", module.type_(), " with name " + moduleName + " in path " + pathName
def makePSetForL1SeedToSuperClusterMatchFilter
def makePSetForOneOEMinusOneOPFilter
def makePSetForPixelMatchFilter

Variables

 module_names_found
tuple moduleMaker = EgammaDQMModuleMaker(process, "HLT_Ele17_SW_TighterEleIdIsol_L1R_v3", 11, 1)
 modules_found
string msgPrefix = "["
tuple process = cms.Process("MYTEST")

Function Documentation

def EgammaHLTValidationUtils::findEgammaPaths (   process)
returns a dict:

 {
   "singleElectron": [ list of single electron path objects ],
   "doubleElectron": [ list of double electron path objects ],
   "singlePhoton":   [ list of single photon path objects ],
   "doublePhoton":   [ list of double photon path objects ],
 }

 Note that the elements in the lists are path objects, not path names.

 Note also that this is based on the name of the paths using some
 heuristics.
 

Definition at line 547 of file EgammaHLTValidationUtils.py.

00548                             :
00549     """
00550     returns a dict:
00551 
00552      {
00553        "singleElectron": [ list of single electron path objects ],
00554        "doubleElectron": [ list of double electron path objects ],
00555        "singlePhoton":   [ list of single photon path objects ],
00556        "doublePhoton":   [ list of double photon path objects ],
00557      }
00558 
00559      Note that the elements in the lists are path objects, not path names.
00560 
00561      Note also that this is based on the name of the paths using some
00562      heuristics.
00563      """
00564 
00565     retval = { "singleElectron": [],
00566                "doubleElectron": [],
00567                "singlePhoton":   [],
00568                "doublePhoton":   [],
00569                }
00570     
00571     for path_name, path in process.paths.items():
00572 
00573         # print "XX",path_name.__class__,path.__class__
00574 
00575         if path_name.startswith("AlCa_"):
00576             continue
00577 
00578         if path_name.startswith("DQM_"):
00579             continue
00580 
00581         if not path_name.startswith("HLT_"):
00582             continue
00583 
00584         if path_name.startswith("HLT_Ele"):
00585             retval['singleElectron'].append(path)
00586             continue
00587         
00588         if path_name.startswith("HLT_Photon"):
00589             retval['singlePhoton'].append(path)
00590             continue
00591 
00592         if path_name.startswith("HLT_DoublePhoton"):
00593             retval['doublePhoton'].append(path)
00594             continue
00595 
00596         if path_name.startswith("HLT_DoubleEle"):
00597             retval['doubleElectron'].append(path)
00598             continue
00599 
00600     # end of loop over paths
00601     return retval
00602 
00603 #----------------------------------------------------------------------

def EgammaHLTValidationUtils::getCXXTypesOfPath (   process,
  path 
)
returns the names of (classes) of the C++ types of the modules
found in the given path (in no particular order) 

Definition at line 641 of file EgammaHLTValidationUtils.py.

00642                                     :
00643     """ returns the names of (classes) of the C++ types of the modules
00644     found in the given path (in no particular order) """
00645 
00646     moduleNames = getModuleNamesOfPath(path)
00647 
00648     retval = set()
00649 
00650     for name in moduleNames:
00651 
00652         # skip those modules which are in the path
00653         # but not in the process object.
00654         # not understood why we need to do this
00655         # but seems to cause problems in practice...
00656         if not hasattr(process,name):
00657             continue
00658 
00659         module = getattr(process, name)
00660 
00661         retval.add(module.type_())
00662 
00663     return retval
00664 
00665 #----------------------------------------------------------------------

def EgammaHLTValidationUtils::getModuleNamesOfPath (   path)
returns the names of the modules found in the given path.

Note that these are not guaranteed to be in any particular
order.

Definition at line 604 of file EgammaHLTValidationUtils.py.

00605                               :
00606     """ returns the names of the modules found in the given path.
00607 
00608     Note that these are not guaranteed to be in any particular
00609     order.
00610     """
00611 
00612     # this function could actually call getModulesOfSequence(..)
00613     # and then produce a set with the unique names of
00614     # the modules
00615 
00616     import FWCore.ParameterSet.Modules
00617     class Visitor:
00618 
00619         #----------------------------------------
00620         def __init__(self):
00621             self.module_names_found = set()
00622 
00623         #----------------------------------------
00624         def enter(self,visitee):
00625 
00626             if isinstance(visitee, FWCore.ParameterSet.Modules._Module):
00627                 self.module_names_found.add(visitee.label_())
00628 
00629         #----------------------------------------
00630         def leave(self,visitee):
00631             pass
00632 
00633         #----------------------------------------
00634                 
00635     visitor = Visitor()
00636     path.visit(visitor)
00637 
00638     return visitor.module_names_found
00639 
00640 
#----------------------------------------------------------------------
def EgammaHLTValidationUtils::getModulesOfSequence (   sequence)
returns the modules found in a sequence.

Note that a module can appear more than once.

Definition at line 666 of file EgammaHLTValidationUtils.py.

00667                                   :
00668     """ returns the modules found in a sequence.
00669 
00670     Note that a module can appear more than once.
00671     """
00672 
00673     import FWCore.ParameterSet.Modules
00674     class Visitor:
00675 
00676         #----------------------------------------
00677         def __init__(self):
00678             self.modules_found = []
00679 
00680         #----------------------------------------
00681         def enter(self,visitee):
00682 
00683             if isinstance(visitee, FWCore.ParameterSet.Modules._Module):
00684                 self.modules_found.append(visitee)
00685 
00686         #----------------------------------------
00687         def leave(self,visitee):
00688             pass
00689 
00690         #----------------------------------------
00691                 
00692     visitor = Visitor()
00693     sequence.visitNode(visitor)
00694 
00695     return visitor.modules_found
00696 
00697 
00698 #----------------------------------------------------------------------
def EgammaHLTValidationUtils::getPathsOfDataSet (   process,
  datasetName 
)
returns the names of the trigger paths contained in the
    given (primary) dataset 

Definition at line 11 of file EgammaHLTValidationUtils.py.

00012                                            :
00013     """ returns the names of the trigger paths contained in the
00014         given (primary) dataset """
00015 
00016     return list(getattr(process.datasets, datasetName))
00017 
00018 #----------------------------------------------------------------------
00019 

def EgammaHLTValidationUtils::getProcessName (   pdgGen,
  requiredNumberOfGeneratedObjects 
)
returns a process name (such as 'Zee') which can be
 used in various places (e.g. module names etc.) 

Definition at line 20 of file EgammaHLTValidationUtils.py.

Referenced by edm::MixingModule::branchesActivate(), and edm::CFWriter::branchesActivate().

00021                                                             :
00022     """ returns a process name (such as 'Zee') which can be
00023      used in various places (e.g. module names etc.) """
00024 
00025     if pdgGen == 11:
00026 
00027         # electron paths
00028         if requiredNumberOfGeneratedObjects == 1:
00029             return "Wenu"
00030         elif requiredNumberOfGeneratedObjects == 2:
00031             return "Zee"
00032         else:
00033             raise Exception("unsupported case, can't guess type of process")
00034 
00035     elif pdgGen == 22:
00036 
00037         # photon paths
00038         if requiredNumberOfGeneratedObjects == 1:
00039             return 'GammaJet'
00040         elif requiredNumberOfGeneratedObjects == 2:
00041             return 'DiGamma'
00042         else:
00043             raise Exception("unsupported case, can't guess type of process")
00044     else:
00045         raise Exception("unsupported case, can't guess type of process")
00046 
00047 
00048 #----------------------------------------------------------------------

def EgammaHLTValidationUtils::getResult (   self)
returns the composed analyzer module 

Definition at line 524 of file EgammaHLTValidationUtils.py.

00525                        :
00526         """ returns the composed analyzer module """
00527         return self.__result

def EgammaHLTValidationUtils::makeGeneratedParticleAndFiducialVolumeFilter (   process,
  pdgGen,
  requiredNumberOfGeneratedObjects 
)
adds the needed modules to the process object and
returns a sequence made of the two filters.

returns the name of the created module

if process is not None, are added to the process.

When using this function from a _cff file, one
has to manually add the modules of the returned
sequence to globals() (in the calling module, not
here, globals() live in a different name space here)

Definition at line 49 of file EgammaHLTValidationUtils.py.

00050                                                                                                    :
00051     """
00052     adds the needed modules to the process object and
00053     returns a sequence made of the two filters.
00054 
00055     returns the name of the created module
00056 
00057     if process is not None, are added to the process.
00058 
00059     When using this function from a _cff file, one
00060     has to manually add the modules of the returned
00061     sequence to globals() (in the calling module, not
00062     here, globals() live in a different name space here)
00063     
00064     """
00065 
00066     # name of the physics process
00067     procName = getProcessName(pdgGen, requiredNumberOfGeneratedObjects)
00068 
00069     #--------------------
00070     # create a module producing a collection with the 
00071     # desired generated particles
00072     #--------------------
00073 
00074     genPartModuleName = 'genpart' + procName
00075 
00076 
00077     genPartModule = cms.EDFilter("PdgIdAndStatusCandViewSelector",
00078                                  status = cms.vint32(3),
00079                                  src = cms.InputTag("genParticles"),
00080                                  pdgId = cms.vint32(pdgGen),
00081                                  )
00082 
00083     # genPartModule.setLabel(genPartModuleName)
00084     if process != None:
00085         setattr(process, genPartModuleName, genPartModule)
00086 
00087     genPartModule.setLabel(genPartModuleName)
00088 
00089     #--------------------
00090     # create a module requiring the number
00091     # of generated particles
00092     #--------------------
00093 
00094     selectorModuleName = "fiducial" + procName
00095 
00096     selectorModule = cms.EDFilter("EtaPtMinCandViewSelector",
00097                                   src = cms.InputTag(genPartModuleName),
00098                                   etaMin = cms.double(-2.5),  
00099                                   etaMax = cms.double(2.5),   
00100                                   ptMin = cms.double(2.0)
00101                                   )
00102 
00103     if process != None:
00104         setattr(process, selectorModuleName, selectorModule)
00105 
00106     # this is needed if we don't have a process to attach this module to
00107     selectorModule.setLabel(selectorModuleName)
00108 
00109     #--------------------
00110     # create the sequence
00111     #--------------------
00112 
00113     return cms.Sequence(
00114         # getattr(process, genPartModuleName)
00115         genPartModule 
00116 
00117         *
00118 
00119         # getattr(process, selectorModuleName)
00120         selectorModule
00121         )
00122 #----------------------------------------------------------------------

def EgammaHLTValidationUtils::makePSetForEgammaGenericFilter (   self,
  module,
  moduleName 
)

Definition at line 383 of file EgammaHLTValidationUtils.py.

00384                                                                 :
00385 
00386         # example usages of HLTEgammaGenericFilter are:
00387         #   R9 shape filter                        hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolR9ShapeFilter 
00388         #   cluster shape filter                   hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolClusterShapeFilter 
00389         #   Ecal isolation filter                  hltL1NonIsoHLTNonIsoSingleElectronEt17TIghterEleIdIsolEcalIsolFilter
00390         #   H/E filter                             hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolHEFilter
00391         #   HCAL isolation filter                  hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolHcalIsolFilter
00392 
00393         # the type of object to look for seems to be the
00394         # same for all uses of HLTEgammaGenericFilter
00395         theHLTOutputTypes = cms.int32(TriggerTypeDefs_cfi.TriggerCluster)
00396 
00397         # infer the type of filter by the type of the producer which
00398         # generates the collection used to cut on this
00399         inputCollectionLabel = module.isoTag.moduleLabel
00400 
00401         inputType = getattr(self.process, inputCollectionLabel).type_()
00402         # print >> sys.stderr, "inputType=",inputType,moduleName
00403 
00404         #--------------------
00405         # sanity check: non-isolated path should be produced by the
00406         # same type of module
00407         #
00408         # first check that the non-iso tag is non-empty
00409         assert(module.nonIsoTag.moduleLabel != "")
00410 
00411         assert(inputType == getattr(self.process, module.nonIsoTag.moduleLabel).type_())
00412 
00413         #--------------------
00414 
00415 
00416         # the following cases seem to have identical PSets ?
00417 
00418         #--------------------
00419         # R9 shape
00420         #--------------------
00421 
00422         if inputType == 'EgammaHLTR9Producer':
00423             return cms.PSet(
00424                 PlotBounds = cms.vdouble(0.0, 0.0),
00425                 HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
00426                 IsoCollections = cms.VInputTag(module.isoTag, module.nonIsoTag),
00427                 theHLTOutputTypes = theHLTOutputTypes
00428                 )
00429 
00430         #--------------------
00431         # cluster shape
00432         #--------------------
00433         if inputType == 'EgammaHLTClusterShapeProducer':
00434             return cms.PSet(
00435                 PlotBounds = cms.vdouble(0.0, 0.0),
00436                 HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
00437                 IsoCollections = cms.VInputTag(module.isoTag, module.nonIsoTag),
00438                 theHLTOutputTypes = theHLTOutputTypes
00439                 )
00440 
00441         #--------------------
00442         # ecal isolation
00443         #--------------------
00444         if inputType == 'EgammaHLTEcalRecIsolationProducer':
00445             return cms.PSet(
00446                 PlotBounds = cms.vdouble(0.0, 0.0),
00447                 HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
00448                 IsoCollections = cms.VInputTag(module.isoTag, module.nonIsoTag),
00449                 theHLTOutputTypes = theHLTOutputTypes
00450                 )
00451 
00452         #--------------------
00453         # HCAL isolation and HE
00454         #--------------------
00455 
00456         if inputType == 'EgammaHLTHcalIsolationProducersRegional':
00457             return cms.PSet(
00458                 PlotBounds = cms.vdouble(0.0, 0.0),
00459                 HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
00460                 IsoCollections = cms.VInputTag(module.isoTag, module.nonIsoTag),
00461                 theHLTOutputTypes = theHLTOutputTypes
00462                 )
00463             
00464         
00465         raise Exception("can't determine what the HLTEgammaGenericFilter '" + moduleName + "' should do: uses a collection produced by a module of C++ type '" + inputType + "'")

def EgammaHLTValidationUtils::makePSetForElectronGenericFilter (   self,
  module,
  moduleName 
)

Definition at line 468 of file EgammaHLTValidationUtils.py.

00469                                                                   :
00470 
00471         # example usages of HLTElectronGenericFilter are:
00472 
00473         # deta filter      hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolDetaFilter
00474         # dphi filter      hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolDphiFilter
00475         # track isolation  hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolTrackIsolFilter
00476 
00477         # the type of object to look for seems to be the
00478         # same for all uses of HLTEgammaGenericFilter
00479         theHLTOutputTypes = cms.int32(TriggerTypeDefs_cfi.TriggerElectron)
00480 
00481         # infer the type of filter by the type of the producer which
00482         # generates the collection used to cut on this
00483         inputCollectionLabel = module.isoTag.moduleLabel
00484 
00485         inputType = getattr(self.process, inputCollectionLabel).type_()
00486         # print >> sys.stderr, "inputType=",inputType,moduleName
00487 
00488         # sanity check: non-isolated path should be produced by the
00489         # same type of module
00490         assert(inputType == getattr(self.process, module.nonIsoTag.moduleLabel).type_())
00491 
00492         # the following cases seem to have identical PSets ?
00493 
00494         #--------------------
00495         # deta and dphi filter
00496         #--------------------
00497 
00498         # note that whether deta or dphi is used is determined from
00499         # the product instance (not the module label)
00500         if inputType == 'EgammaHLTElectronDetaDphiProducer':
00501 
00502             return cms.PSet(
00503                 PlotBounds = cms.vdouble(0.0, 0.0),
00504                 HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
00505                 IsoCollections = cms.VInputTag(module.isoTag, module.nonIsoTag),
00506                 theHLTOutputTypes = theHLTOutputTypes
00507                 )
00508 
00509         #--------------------
00510         # track isolation
00511         #--------------------
00512 
00513         if inputType == 'EgammaHLTElectronTrackIsolationProducers':
00514 
00515             return cms.PSet(
00516                 PlotBounds = cms.vdouble(0.0, 0.0),
00517                 HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
00518                 IsoCollections = cms.VInputTag(module.isoTag, module.nonIsoTag),
00519                 theHLTOutputTypes = theHLTOutputTypes
00520                 )
00521         raise Exception("can't determine what the HLTElectronGenericFilter '" + moduleName + "' should do: uses a collection produced by a module of C++ type '" + inputType + "'")

def EgammaHLTValidationUtils::makePSetForEtFilter (   self,
  moduleName 
)
generates a PSet for the Egamma DQM analyzer for the Et filter 

Definition at line 350 of file EgammaHLTValidationUtils.py.

00351                                              :
00352         """ generates a PSet for the Egamma DQM analyzer for the Et filter """
00353 
00354         return cms.PSet(
00355             PlotBounds = cms.vdouble(0.0, 0.0),
00356             HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
00357             IsoCollections = cms.VInputTag(cms.InputTag("none")),
00358             theHLTOutputTypes = cms.int32(TriggerTypeDefs_cfi.TriggerCluster)
00359         )

def EgammaHLTValidationUtils::makePSetForL1SeedFilter (   self,
  moduleName 
)

print >> sys.stderr,msgPrefix,"WARNING: unknown module type", module.type_(), " with name " + moduleName + " in path " + pathName

generates a PSet to analyze the behaviour of an L1 seed.

    moduleName is the name of the HLT module which filters
    on the L1 seed.

Definition at line 318 of file EgammaHLTValidationUtils.py.

00319                                                 :
00320         """ generates a PSet to analyze the behaviour of an L1 seed.
00321 
00322             moduleName is the name of the HLT module which filters
00323             on the L1 seed.
00324         """
00325 
00326         return cms.PSet(
00327             PlotBounds = cms.vdouble(0.0, 0.0),
00328             HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
00329             IsoCollections = cms.VInputTag(cms.InputTag("none")),
00330             theHLTOutputTypes = cms.int32(TriggerTypeDefs_cfi.TriggerL1NoIsoEG)
00331         ) 

def EgammaHLTValidationUtils::makePSetForL1SeedToSuperClusterMatchFilter (   self,
  moduleName 
)
generates a PSet to analyze the behaviour of L1 to supercluster match filter.

    moduleName is the name of the HLT module which requires the match
    between supercluster and L1 seed.

Definition at line 334 of file EgammaHLTValidationUtils.py.

00335                                                                    :
00336         """ generates a PSet to analyze the behaviour of L1 to supercluster match filter.
00337 
00338             moduleName is the name of the HLT module which requires the match
00339             between supercluster and L1 seed.
00340         """
00341 
00342         return cms.PSet(
00343             PlotBounds = cms.vdouble(0.0, 0.0),
00344             HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
00345             IsoCollections = cms.VInputTag(cms.InputTag("none")),
00346             theHLTOutputTypes = cms.int32(TriggerTypeDefs_cfi.TriggerCluster)
00347         ) 

def EgammaHLTValidationUtils::makePSetForOneOEMinusOneOPFilter (   self,
  moduleName 
)

Definition at line 362 of file EgammaHLTValidationUtils.py.

00363                                                           :
00364 
00365         return cms.PSet(
00366             PlotBounds = cms.vdouble(0.0, 0.0),
00367             HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
00368             IsoCollections = cms.VInputTag(cms.InputTag("none")),
00369             theHLTOutputTypes = cms.int32(TriggerTypeDefs_cfi.TriggerElectron)
00370             )

def EgammaHLTValidationUtils::makePSetForPixelMatchFilter (   self,
  moduleName 
)

Definition at line 373 of file EgammaHLTValidationUtils.py.

00374                                                      :
00375         return cms.PSet(
00376             PlotBounds = cms.vdouble(0.0, 0.0),
00377             HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
00378             IsoCollections = cms.VInputTag(cms.InputTag("none")),
00379             theHLTOutputTypes = cms.int32(TriggerTypeDefs_cfi.TriggerCluster)
00380             )


Variable Documentation

Definition at line 608 of file EgammaHLTValidationUtils.py.

tuple EgammaHLTValidationUtils::moduleMaker = EgammaDQMModuleMaker(process, "HLT_Ele17_SW_TighterEleIdIsol_L1R_v3", 11, 1)

Definition at line 539 of file EgammaHLTValidationUtils.py.

Definition at line 669 of file EgammaHLTValidationUtils.py.

Definition at line 6 of file EgammaHLTValidationUtils.py.

tuple EgammaHLTValidationUtils::process = cms.Process("MYTEST")

Definition at line 536 of file EgammaHLTValidationUtils.py.