CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 More...
 
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 560 of file EgammaHLTValidationUtils.py.

References bitset_utilities.append().

561 def findEgammaPaths(process):
562  """
563  returns a dict:
564 
565  {
566  "singleElectron": [ list of single electron path objects ],
567  "doubleElectron": [ list of double electron path objects ],
568  "singlePhoton": [ list of single photon path objects ],
569  "doublePhoton": [ list of double photon path objects ],
570  }
571 
572  Note that the elements in the lists are path objects, not path names.
573 
574  Note also that this is based on the name of the paths using some
575  heuristics.
576  """
577 
578  retval = { "singleElectron": [],
579  "doubleElectron": [],
580  "singlePhoton": [],
581  "doublePhoton": [],
582  }
583 
584  for path_name, path in process.paths.items():
585 
586  # print "XX",path_name.__class__,path.__class__
587 
588  if path_name.startswith("AlCa_"):
589  continue
590 
591  if path_name.startswith("DQM_"):
592  continue
593 
594  if not path_name.startswith("HLT_"):
595  continue
596 
597  if path_name.startswith("HLT_Ele"):
598  retval['singleElectron'].append(path)
599  continue
600 
601  if path_name.startswith("HLT_Photon"):
602  retval['singlePhoton'].append(path)
603  continue
604 
605  if path_name.startswith("HLT_DoublePhoton"):
606  retval['doublePhoton'].append(path)
607  continue
608 
609  if path_name.startswith("HLT_DoubleEle"):
610  retval['doubleElectron'].append(path)
611  continue
612 
613  # end of loop over paths
614  return retval
615 
616 #----------------------------------------------------------------------
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
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 654 of file EgammaHLTValidationUtils.py.

References getModuleNamesOfPath().

655 def getCXXTypesOfPath(process, path):
656  """ returns the names of (classes) of the C++ types of the modules
657  found in the given path (in no particular order) """
658 
659  moduleNames = getModuleNamesOfPath(path)
660 
661  retval = set()
662 
663  for name in moduleNames:
664 
665  # skip those modules which are in the path
666  # but not in the process object.
667  # not understood why we need to do this
668  # but seems to cause problems in practice...
669  if not hasattr(process,name):
670  continue
671 
672  module = getattr(process, name)
673 
674  retval.add(module.type_())
675 
676  return retval
677 
678 #----------------------------------------------------------------------
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 617 of file EgammaHLTValidationUtils.py.

References submitPVValidationJobs.__init__().

Referenced by getCXXTypesOfPath().

618 def getModuleNamesOfPath(path):
619  """ returns the names of the modules found in the given path.
620 
621  Note that these are not guaranteed to be in any particular
622  order.
623  """
624 
625  # this function could actually call getModulesOfSequence(..)
626  # and then produce a set with the unique names of
627  # the modules
628 
629  import FWCore.ParameterSet.Modules
630  class Visitor:
631 
632  #----------------------------------------
633  def __init__(self):
634  self.module_names_found = set()
635 
636  #----------------------------------------
637  def enter(self,visitee):
638 
639  if isinstance(visitee, FWCore.ParameterSet.Modules._Module):
640  self.module_names_found.add(visitee.label_())
641 
642  #----------------------------------------
643  def leave(self,visitee):
644  pass
645 
646  #----------------------------------------
647 
648  visitor = Visitor()
649  path.visit(visitor)
650 
651  return visitor.module_names_found
652 
653 
#----------------------------------------------------------------------
def EgammaHLTValidationUtils.getModulesOfSequence (   sequence)
returns the modules found in a sequence.

Note that a module can appear more than once.

Definition at line 679 of file EgammaHLTValidationUtils.py.

References submitPVValidationJobs.__init__().

680 def getModulesOfSequence(sequence):
681  """ returns the modules found in a sequence.
682 
683  Note that a module can appear more than once.
684  """
685 
686  import FWCore.ParameterSet.Modules
687  class Visitor:
688 
689  #----------------------------------------
690  def __init__(self):
691  self.modules_found = []
692 
693  #----------------------------------------
694  def enter(self,visitee):
695 
696  if isinstance(visitee, FWCore.ParameterSet.Modules._Module):
697  self.modules_found.append(visitee)
698 
699  #----------------------------------------
700  def leave(self,visitee):
701  pass
702 
703  #----------------------------------------
704 
705  visitor = Visitor()
706  sequence.visitNode(visitor)
707 
708  return visitor.modules_found
709 
710 
711 #----------------------------------------------------------------------
def EgammaHLTValidationUtils.getPathsOfDataSet (   process,
  datasetName 
)
returns the names of the trigger paths contained in the
    given (primary) dataset 

Definition at line 12 of file EgammaHLTValidationUtils.py.

12 
13 def getPathsOfDataSet(process, datasetName):
14  """ returns the names of the trigger paths contained in the
15  given (primary) dataset """
16 
17  return list(getattr(process.datasets, datasetName))
18 
19 #----------------------------------------------------------------------
20 
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 21 of file EgammaHLTValidationUtils.py.

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

21 
22 def getProcessName(pdgGen, requiredNumberOfGeneratedObjects):
23  """ returns a process name (such as 'Zee') which can be
24  used in various places (e.g. module names etc.) """
25 
26  if pdgGen == 11:
27 
28  # electron paths
29  if requiredNumberOfGeneratedObjects == 1:
30  return "Wenu"
31  elif requiredNumberOfGeneratedObjects == 2:
32  return "Zee"
33  else:
34  raise Exception("unsupported case, can't guess type of process")
35 
36  elif pdgGen == 22:
37 
38  # photon paths
39  if requiredNumberOfGeneratedObjects == 1:
40  return 'GammaJet'
41  elif requiredNumberOfGeneratedObjects == 2:
42  return 'DiGamma'
43  else:
44  raise Exception("unsupported case, can't guess type of process")
45  else:
46  raise Exception("unsupported case, can't guess type of process")
47 
48 
49 #----------------------------------------------------------------------
def EgammaHLTValidationUtils.getResult (   self)
returns the composed analyzer module 

Definition at line 537 of file EgammaHLTValidationUtils.py.

538  def getResult(self):
539  """ returns the composed analyzer module """
540  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 50 of file EgammaHLTValidationUtils.py.

References getProcessName().

50 
51 def makeGeneratedParticleAndFiducialVolumeFilter(process, pdgGen, requiredNumberOfGeneratedObjects):
52  """
53  adds the needed modules to the process object and
54  returns a sequence made of the two filters.
55 
56  returns the name of the created module
57 
58  if process is not None, are added to the process.
59 
60  When using this function from a _cff file, one
61  has to manually add the modules of the returned
62  sequence to globals() (in the calling module, not
63  here, globals() live in a different name space here)
64 
65  """
66 
67  # name of the physics process
68  procName = getProcessName(pdgGen, requiredNumberOfGeneratedObjects)
69 
70  #--------------------
71  # create a module producing a collection with the
72  # desired generated particles
73  #--------------------
74 
75  genPartModuleName = 'genpart' + procName
76 
77 
78  genPartModule = cms.EDFilter("PdgIdAndStatusCandViewSelector",
79  status = cms.vint32(3),
80  src = cms.InputTag("genParticles"),
81  pdgId = cms.vint32(pdgGen),
82  )
83 
84  # genPartModule.setLabel(genPartModuleName)
85  if process != None:
86  setattr(process, genPartModuleName, genPartModule)
87 
88  genPartModule.setLabel(genPartModuleName)
89 
90  #--------------------
91  # create a module requiring the number
92  # of generated particles
93  #--------------------
94 
95  selectorModuleName = "fiducial" + procName
96 
97  selectorModule = cms.EDFilter("EtaPtMinCandViewSelector",
98  src = cms.InputTag(genPartModuleName),
99  etaMin = cms.double(-2.5),
100  etaMax = cms.double(2.5),
101  ptMin = cms.double(2.0)
102  )
103 
104  if process != None:
105  setattr(process, selectorModuleName, selectorModule)
106 
107  # this is needed if we don't have a process to attach this module to
108  selectorModule.setLabel(selectorModuleName)
109 
110  #--------------------
111  # create the sequence
112  #--------------------
113 
114  return cms.Sequence(
115  # getattr(process, genPartModuleName)
116  genPartModule
117 
118  *
119 
120  # getattr(process, selectorModuleName)
121  selectorModule
122  )
123 #----------------------------------------------------------------------
def EgammaHLTValidationUtils.makePSetForEgammaGenericFilter (   self,
  module,
  moduleName 
)

Definition at line 396 of file EgammaHLTValidationUtils.py.

References cms::cuda.assert().

397  def makePSetForEgammaGenericFilter(self, module, moduleName):
398 
399  # example usages of HLTEgammaGenericFilter are:
400  # R9 shape filter hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolR9ShapeFilter
401  # cluster shape filter hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolClusterShapeFilter
402  # Ecal isolation filter hltL1NonIsoHLTNonIsoSingleElectronEt17TIghterEleIdIsolEcalIsolFilter
403  # H/E filter hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolHEFilter
404  # HCAL isolation filter hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolHcalIsolFilter
405 
406  # the type of object to look for seems to be the
407  # same for all uses of HLTEgammaGenericFilter
408  theHLTOutputTypes = cms.int32(TriggerTypeDefs_cfi.TriggerCluster)
409 
410  # infer the type of filter by the type of the producer which
411  # generates the collection used to cut on this
412  inputCollectionLabel = module.isoTag.moduleLabel
413 
414  inputType = getattr(self.process, inputCollectionLabel).type_()
415  # print >> sys.stderr, "inputType=",inputType,moduleName
416 
417  #--------------------
418  # sanity check: non-isolated path should be produced by the
419  # same type of module
420  #
421  # first check that the non-iso tag is non-empty
422  assert(module.nonIsoTag.moduleLabel != "")
423 
424  assert(inputType == getattr(self.process, module.nonIsoTag.moduleLabel).type_())
425 
426  #--------------------
427 
428 
429  # the following cases seem to have identical PSets ?
430 
431  #--------------------
432  # R9 shape
433  #--------------------
434 
435  if inputType == 'EgammaHLTR9Producer':
436  return cms.PSet(
437  PlotBounds = cms.vdouble(0.0, 0.0),
438  HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
439  IsoCollections = cms.VInputTag(module.isoTag, module.nonIsoTag),
440  theHLTOutputTypes = theHLTOutputTypes
441  )
442 
443  #--------------------
444  # cluster shape
445  #--------------------
446  if inputType == 'EgammaHLTClusterShapeProducer':
447  return cms.PSet(
448  PlotBounds = cms.vdouble(0.0, 0.0),
449  HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
450  IsoCollections = cms.VInputTag(module.isoTag, module.nonIsoTag),
451  theHLTOutputTypes = theHLTOutputTypes
452  )
453 
454  #--------------------
455  # ecal isolation
456  #--------------------
457  if inputType == 'EgammaHLTEcalRecIsolationProducer':
458  return cms.PSet(
459  PlotBounds = cms.vdouble(0.0, 0.0),
460  HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
461  IsoCollections = cms.VInputTag(module.isoTag, module.nonIsoTag),
462  theHLTOutputTypes = theHLTOutputTypes
463  )
464 
465  #--------------------
466  # HCAL isolation and HE
467  #--------------------
468 
469  if inputType == 'EgammaHLTHcalIsolationProducersRegional':
470  return cms.PSet(
471  PlotBounds = cms.vdouble(0.0, 0.0),
472  HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
473  IsoCollections = cms.VInputTag(module.isoTag, module.nonIsoTag),
474  theHLTOutputTypes = theHLTOutputTypes
475  )
476 
477 
478  raise Exception("can't determine what the HLTEgammaGenericFilter '" + moduleName + "' should do: uses a collection produced by a module of C++ type '" + inputType + "'")
assert(be >=bs)
def EgammaHLTValidationUtils.makePSetForElectronGenericFilter (   self,
  module,
  moduleName 
)

Definition at line 481 of file EgammaHLTValidationUtils.py.

References cms::cuda.assert().

482  def makePSetForElectronGenericFilter(self, module, moduleName):
483 
484  # example usages of HLTElectronGenericFilter are:
485 
486  # deta filter hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolDetaFilter
487  # dphi filter hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolDphiFilter
488  # track isolation hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolTrackIsolFilter
489 
490  # the type of object to look for seems to be the
491  # same for all uses of HLTEgammaGenericFilter
492  theHLTOutputTypes = cms.int32(TriggerTypeDefs_cfi.TriggerElectron)
493 
494  # infer the type of filter by the type of the producer which
495  # generates the collection used to cut on this
496  inputCollectionLabel = module.isoTag.moduleLabel
497 
498  inputType = getattr(self.process, inputCollectionLabel).type_()
499  # print >> sys.stderr, "inputType=",inputType,moduleName
500 
501  # sanity check: non-isolated path should be produced by the
502  # same type of module
503  assert(inputType == getattr(self.process, module.nonIsoTag.moduleLabel).type_())
504 
505  # the following cases seem to have identical PSets ?
506 
507  #--------------------
508  # deta and dphi filter
509  #--------------------
510 
511  # note that whether deta or dphi is used is determined from
512  # the product instance (not the module label)
513  if inputType == 'EgammaHLTElectronDetaDphiProducer':
514 
515  return cms.PSet(
516  PlotBounds = cms.vdouble(0.0, 0.0),
517  HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
518  IsoCollections = cms.VInputTag(module.isoTag, module.nonIsoTag),
519  theHLTOutputTypes = theHLTOutputTypes
520  )
521 
522  #--------------------
523  # track isolation
524  #--------------------
525 
526  if inputType == 'EgammaHLTElectronTrackIsolationProducers':
527 
528  return cms.PSet(
529  PlotBounds = cms.vdouble(0.0, 0.0),
530  HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
531  IsoCollections = cms.VInputTag(module.isoTag, module.nonIsoTag),
532  theHLTOutputTypes = theHLTOutputTypes
533  )
534  raise Exception("can't determine what the HLTElectronGenericFilter '" + moduleName + "' should do: uses a collection produced by a module of C++ type '" + inputType + "'")
assert(be >=bs)
def EgammaHLTValidationUtils.makePSetForEtFilter (   self,
  moduleName 
)
generates a PSet for the Egamma DQM analyzer for the Et filter 

Definition at line 363 of file EgammaHLTValidationUtils.py.

364  def makePSetForEtFilter(self, moduleName):
365  """ generates a PSet for the Egamma DQM analyzer for the Et filter """
366 
367  return cms.PSet(
368  PlotBounds = cms.vdouble(0.0, 0.0),
369  HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
370  IsoCollections = cms.VInputTag(cms.InputTag("none")),
371  theHLTOutputTypes = cms.int32(TriggerTypeDefs_cfi.TriggerCluster)
372  )
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 331 of file EgammaHLTValidationUtils.py.

332  def makePSetForL1SeedFilter(self,moduleName):
333  """ generates a PSet to analyze the behaviour of an L1 seed.
334 
335  moduleName is the name of the HLT module which filters
336  on the L1 seed.
337  """
338 
339  return cms.PSet(
340  PlotBounds = cms.vdouble(0.0, 0.0),
341  HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
342  IsoCollections = cms.VInputTag(cms.InputTag("none")),
343  theHLTOutputTypes = cms.int32(TriggerTypeDefs_cfi.TriggerL1NoIsoEG)
344  )
def makePSetForL1SeedFilter
print &gt;&gt; sys.stderr,msgPrefix,&quot;WARNING: unknown module type&quot;, module.type_(), &quot; with name &quot; + moduleN...
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 347 of file EgammaHLTValidationUtils.py.

348  def makePSetForL1SeedToSuperClusterMatchFilter(self,moduleName):
349  """ generates a PSet to analyze the behaviour of L1 to supercluster match filter.
350 
351  moduleName is the name of the HLT module which requires the match
352  between supercluster and L1 seed.
353  """
354 
355  return cms.PSet(
356  PlotBounds = cms.vdouble(0.0, 0.0),
357  HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
358  IsoCollections = cms.VInputTag(cms.InputTag("none")),
359  theHLTOutputTypes = cms.int32(TriggerTypeDefs_cfi.TriggerCluster)
360  )
def EgammaHLTValidationUtils.makePSetForOneOEMinusOneOPFilter (   self,
  moduleName 
)

Definition at line 375 of file EgammaHLTValidationUtils.py.

376  def makePSetForOneOEMinusOneOPFilter(self, moduleName):
377 
378  return cms.PSet(
379  PlotBounds = cms.vdouble(0.0, 0.0),
380  HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
381  IsoCollections = cms.VInputTag(cms.InputTag("none")),
382  theHLTOutputTypes = cms.int32(TriggerTypeDefs_cfi.TriggerElectron)
383  )
def EgammaHLTValidationUtils.makePSetForPixelMatchFilter (   self,
  moduleName 
)

Definition at line 386 of file EgammaHLTValidationUtils.py.

387  def makePSetForPixelMatchFilter(self, moduleName):
388  return cms.PSet(
389  PlotBounds = cms.vdouble(0.0, 0.0),
390  HLTCollectionLabels = cms.InputTag(moduleName,"",self.processName),
391  IsoCollections = cms.VInputTag(cms.InputTag("none")),
392  theHLTOutputTypes = cms.int32(TriggerTypeDefs_cfi.TriggerCluster)
393  )

Variable Documentation

EgammaHLTValidationUtils.module_names_found

Definition at line 633 of file EgammaHLTValidationUtils.py.

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

Definition at line 552 of file EgammaHLTValidationUtils.py.

EgammaHLTValidationUtils.modules_found

Definition at line 690 of file EgammaHLTValidationUtils.py.

string EgammaHLTValidationUtils.msgPrefix = "["

Definition at line 7 of file EgammaHLTValidationUtils.py.

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

Definition at line 549 of file EgammaHLTValidationUtils.py.