CMS 3D CMS Logo

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

References bitset_utilities.append().

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

References getModuleNamesOfPath().

653 def getCXXTypesOfPath(process, path):
654  """ returns the names of (classes) of the C++ types of the modules
655  found in the given path (in no particular order) """
656 
657  moduleNames = getModuleNamesOfPath(path)
658 
659  retval = set()
660 
661  for name in moduleNames:
662 
663  # skip those modules which are in the path
664  # but not in the process object.
665  # not understood why we need to do this
666  # but seems to cause problems in practice...
667  if not hasattr(process,name):
668  continue
669 
670  module = getattr(process, name)
671 
672  retval.add(module.type_())
673 
674  return retval
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 def getModuleNamesOfPath(path):
617  """ returns the names of the modules found in the given path.
618 
619  Note that these are not guaranteed to be in any particular
620  order.
621  """
622 
623  # this function could actually call getModulesOfSequence(..)
624  # and then produce a set with the unique names of
625  # the modules
626 
627  import FWCore.ParameterSet.Modules
628  class Visitor:
629 
630  #----------------------------------------
631  def __init__(self):
632  self.module_names_found = set()
633 
634  #----------------------------------------
635  def enter(self,visitee):
636 
637  if isinstance(visitee, FWCore.ParameterSet.Modules._Module):
638  self.module_names_found.add(visitee.label_())
639 
640  #----------------------------------------
641  def leave(self,visitee):
642  pass
643 
644  #----------------------------------------
645 
646  visitor = Visitor()
647  path.visit(visitor)
648 
649  return visitor.module_names_found
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.

678 def getModulesOfSequence(sequence):
679  """ returns the modules found in a sequence.
680 
681  Note that a module can appear more than once.
682  """
683 
684  import FWCore.ParameterSet.Modules
685  class Visitor:
686 
687  #----------------------------------------
688  def __init__(self):
689  self.modules_found = []
690 
691  #----------------------------------------
692  def enter(self,visitee):
693 
694  if isinstance(visitee, FWCore.ParameterSet.Modules._Module):
695  self.modules_found.append(visitee)
696 
697  #----------------------------------------
698  def leave(self,visitee):
699  pass
700 
701  #----------------------------------------
702 
703  visitor = Visitor()
704  sequence.visitNode(visitor)
705 
706  return visitor.modules_found
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 
12 def getPathsOfDataSet(process, datasetName):
13  """ returns the names of the trigger paths contained in the
14  given (primary) dataset """
15 
16  return list(getattr(process.datasets, datasetName))
17 
18 #----------------------------------------------------------------------
19 
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(), and makeGeneratedParticleAndFiducialVolumeFilter().

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

Definition at line 535 of file EgammaHLTValidationUtils.py.

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

References getProcessName().

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

Definition at line 394 of file EgammaHLTValidationUtils.py.

References assert().

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

Definition at line 479 of file EgammaHLTValidationUtils.py.

References assert().

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

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

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

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

Definition at line 373 of file EgammaHLTValidationUtils.py.

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

Definition at line 384 of file EgammaHLTValidationUtils.py.

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

Variable Documentation

EgammaHLTValidationUtils.module_names_found

Definition at line 631 of file EgammaHLTValidationUtils.py.

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

Definition at line 550 of file EgammaHLTValidationUtils.py.

EgammaHLTValidationUtils.modules_found

Definition at line 688 of file EgammaHLTValidationUtils.py.

string EgammaHLTValidationUtils.msgPrefix = "["

Definition at line 6 of file EgammaHLTValidationUtils.py.

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

Definition at line 547 of file EgammaHLTValidationUtils.py.