CMS 3D CMS Logo

Classes | Functions | Variables
EgammaHLTValidationUtils Namespace Reference

Classes

class  EgammaDQMModuleMaker
 

Functions

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

Variables

 module_names_found
 
 modules_found
 

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 558 of file EgammaHLTValidationUtils.py.

References mps_alisetup.append.

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

References getModuleNamesOfPath().

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

Referenced by getCXXTypesOfPath().

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

Note that a module can appear more than once.

Definition at line 677 of file EgammaHLTValidationUtils.py.

677 def getModulesOfSequence(sequence):
678  """ returns the modules found in a sequence.
679 
680  Note that a module can appear more than once.
681  """
682 
683  import FWCore.ParameterSet.Modules
684  class Visitor:
685 
686  #----------------------------------------
687  def __init__(self):
688  self.modules_found = []
689 
690  #----------------------------------------
691  def enter(self,visitee):
692 
693  if isinstance(visitee, FWCore.ParameterSet.Modules._Module):
694  self.modules_found.append(visitee)
695 
696  #----------------------------------------
697  def leave(self,visitee):
698  pass
699 
700  #----------------------------------------
701 
702  visitor = Visitor()
703  sequence.visitNode(visitor)
704 
705  return visitor.modules_found
706 
707 
708 #----------------------------------------------------------------------
709 
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.

References list().

11 def getPathsOfDataSet(process, datasetName):
12  """ returns the names of the trigger paths contained in the
13  given (primary) dataset """
14 
15  return list(getattr(process.datasets, datasetName))
16 
17 #----------------------------------------------------------------------
18 
19 
def getPathsOfDataSet(process, datasetName)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
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::CFWriter.branchesActivate(), edm::MixingModule.branchesActivate(), HLTConfigProvider.init(), and makeGeneratedParticleAndFiducialVolumeFilter().

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

Definition at line 535 of file EgammaHLTValidationUtils.py.

References ConfigBuilder.dumpPython().

535  def getResult(self):
536  """ returns the composed analyzer module """
537  return self.__result
538 
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.

References getProcessName().

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

Definition at line 394 of file EgammaHLTValidationUtils.py.

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

Definition at line 479 of file EgammaHLTValidationUtils.py.

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

Definition at line 361 of file EgammaHLTValidationUtils.py.

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

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

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

Definition at line 373 of file EgammaHLTValidationUtils.py.

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

Definition at line 384 of file EgammaHLTValidationUtils.py.

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

Variable Documentation

EgammaHLTValidationUtils.module_names_found

Definition at line 631 of file EgammaHLTValidationUtils.py.

EgammaHLTValidationUtils.modules_found

Definition at line 688 of file EgammaHLTValidationUtils.py.