CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Static Public Attributes
objects.VertexAnalyzer.VertexAnalyzer Class Reference
Inheritance diagram for objects.VertexAnalyzer.VertexAnalyzer:

Public Member Functions

def __init__ (self, cfg_ana, cfg_comp, looperName)
 
def beginLoop (self, setup)
 
def declareHandles (self)
 
def mindist (self, vertices)
 
def process (self, event)
 
def testGoodVertex (self, vertex)
 
def write (self, setup)
 

Public Attributes

 allVertices
 
 count
 
 doHists
 
 pileup
 

Static Public Attributes

 class_object
 
 fixedWeight
 
 verbose
 
 vertexWeight
 

Detailed Description

selects a list of good primary vertices,
and optionally add a pile-up weight to MC events.

The list of good primary vertices is put in event.goodVertices.
if no good vertex is found, the process function returns False.

The weight is put in event.vertexWeight, and is multiplied to
the global event weight, event.eventWeight. 

Example:

vertexAna = cfg.Analyzer(
  'VertexAnalyzer',
  goodVertices = 'goodPVFilter',
  vertexWeight = 'vertexWeightFall112011AB',
  # uncomment the following line if you want a vertex weight = 1 (no weighting)
  # fixedWeight = 1, 
  verbose = False
  )

If fixedWeight is set to None, the vertex weight is read from the EDM collection with module name
'vertexWeightFall112011AB'.
Otherwise, the weight is set to fixedWeight.

The vertex weight collection was at some point produced in the PAT+CMG step,
and could directly be accessed from the PAT or CMG tuple. 
In the most recent versions of the PAT+CMG tuple, this collection is not present anymore,
and an additional full framework process must be ran to produce this collection,
so that this analyzer can read it. An example cfg to do that can be found here:
http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/CMG/CMGTools/H2TauTau/prod/vertexWeight2011_cfg.py?view=markup

Definition at line 11 of file VertexAnalyzer.py.

Constructor & Destructor Documentation

◆ __init__()

def objects.VertexAnalyzer.VertexAnalyzer.__init__ (   self,
  cfg_ana,
  cfg_comp,
  looperName 
)

Definition at line 46 of file VertexAnalyzer.py.

46  def __init__(self, cfg_ana, cfg_comp, looperName):
47  super(VertexAnalyzer, self).__init__(cfg_ana, cfg_comp, looperName)
48 
49  self.doHists=True
50  if (hasattr(self.cfg_ana,'makeHists')) and (not self.cfg_ana.makeHists):
51  self.doHists=False
52  if self.doHists:
53  self.pileup = VertexHistograms('/'.join([self.dirName,
54  'pileup.root']))
55 
56  self.allVertices = self.cfg_ana.allVertices if (hasattr(self.cfg_ana,'allVertices')) else "_AUTO_"
57 

Member Function Documentation

◆ beginLoop()

def objects.VertexAnalyzer.VertexAnalyzer.beginLoop (   self,
  setup 
)

Definition at line 92 of file VertexAnalyzer.py.

92  def beginLoop(self, setup):
93  super(VertexAnalyzer,self).beginLoop(setup)
94  self.averages.add('vertexWeight', Average('vertexWeight') )
95  self.counters.addCounter('GoodVertex')
96  self.count = self.counters.counter('GoodVertex')
97  self.count.register('All Events')
98  self.count.register('Events With Good Vertex')
99 
100 

References PVValHelper.add(), Average, analyzer.Analyzer.averages, CSCSPEvent.counters(), cms::cuda::AtomicPairCounter::Atomic2.counters, NMaxPerLumi.counters, analyzer.Analyzer.counters, HistogramManager.counters, counter.Counters.counters, and cscdqm::ChamberCounterKeyType.counters.

◆ declareHandles()

def objects.VertexAnalyzer.VertexAnalyzer.declareHandles (   self)

Definition at line 58 of file VertexAnalyzer.py.

58  def declareHandles(self):
59  super(VertexAnalyzer, self).declareHandles()
60  if self.allVertices == '_AUTO_':
61  self.handles['vertices'] = AutoHandle( "offlineSlimmedPrimaryVertices", 'std::vector<reco::Vertex>', fallbackLabel="offlinePrimaryVertices" )
62  else:
63  self.handles['vertices'] = AutoHandle( self.allVertices, 'std::vector<reco::Vertex>' )
64  self.fixedWeight = None
65  if self.cfg_comp.isMC:
66  if hasattr( self.cfg_ana, 'fixedWeight'):
67  self.fixedWeight = self.cfg_ana.fixedWeight
68  else:
69  self.mchandles['vertexWeight'] = AutoHandle( self.cfg_ana.vertexWeight,
70  'double' )
71 
72  self.mchandles['pusi'] = AutoHandle(
73  'slimmedAddPileupInfo',
74  'std::vector<PileupSummaryInfo>',
75  fallbackLabel='addPileupInfo',
76  )
77 
78  self.handles['rho'] = AutoHandle(
79  ('fixedGridRhoFastjetAll',''),
80  'double'
81  )
82  self.handles['rhoCN'] = AutoHandle(
83  ('fixedGridRhoFastjetCentralNeutral',''),
84  'double'
85  )
86  self.handles['sigma'] = AutoHandle(
87  ('fixedGridSigmaFastjetAll',''),
88  'double',
89  mayFail=True
90  )
91 

References core.PileUpAnalyzer.PileUpAnalyzer.allVertices, objects.VertexAnalyzer.VertexAnalyzer.allVertices, analyzer.Analyzer.cfg_ana, analyzer.Analyzer.cfg_comp, looper.Looper.cfg_comp, objects.VertexAnalyzer.VertexAnalyzer.fixedWeight, core.AutoHandle.AutoHandle.handles, core.Analyzer.Analyzer.handles, HTTP.RequestManager.handles, and core.Analyzer.Analyzer.mchandles.

◆ mindist()

def objects.VertexAnalyzer.VertexAnalyzer.mindist (   self,
  vertices 
)

Definition at line 160 of file VertexAnalyzer.py.

160  def mindist(self, vertices):
161  mindist = 999999
162  for comb in itertools.combinations(vertices, 2):
163  dist = abs(comb[0].z() - comb[1].z())
164  if dist<mindist:
165  mindist = dist
166  return mindist
167 

References funct.abs().

◆ process()

def objects.VertexAnalyzer.VertexAnalyzer.process (   self,
  event 
)

Definition at line 101 of file VertexAnalyzer.py.

101  def process(self, event):
102  self.readCollections(event.input )
103  event.rho = self.handles['rho'].product()[0]
104  event.rhoCN = self.handles['rhoCN'].product()[0]
105  event.sigma = self.handles['sigma'].product()[0] if self.handles['sigma'].isValid() else -999
106  event.vertices = self.handles['vertices'].product()
107  event.goodVertices = list(filter(self.testGoodVertex,event.vertices))
108 
109 
110  self.count.inc('All Events')
111 
112 
113  event.vertexWeight = 1
114  if self.cfg_comp.isMC:
115  event.pileUpInfo = map( PileUpSummaryInfo,
116  self.mchandles['pusi'].product() )
117  if self.fixedWeight is None:
118  event.vertexWeight = self.mchandles['vertexWeight'].product()[0]
119  else:
120  event.vertexWeight = self.fixedWeight
121  event.eventWeight *= event.vertexWeight
122 
123  self.averages['vertexWeight'].add( event.vertexWeight )
124  if self.verbose:
125  print('VertexAnalyzer: #vert = ', len(event.vertices), \
126  ', weight = ', event.vertexWeight)
127 
128  # Check if events needs to be skipped if no good vertex is found (useful for generator level studies)
129  keepFailingEvents = False
130  if hasattr( self.cfg_ana, 'keepFailingEvents'):
131  keepFailingEvents = self.cfg_ana.keepFailingEvents
132  if len(event.goodVertices)==0:
133  event.passedVertexAnalyzer=False
134  if not keepFailingEvents:
135  return False
136  else:
137  event.passedVertexAnalyzer=True
138 
139  if self.doHists:
140  self.pileup.hist.Fill( len(event.goodVertices) )
141 #A.R. mindist is one of the slowest functions, default commented
142 # self.pileup.mindist.Fill( self.mindist(event.goodVertices) )
143 
144  self.count.inc('Events With Good Vertex')
145  return True
146 
147 

References PVValHelper.add(), analyzer.Analyzer.averages, analyzer.Analyzer.cfg_ana, analyzer.Analyzer.cfg_comp, looper.Looper.cfg_comp, TmCcu.count, TmModule.count, TmApvPair.count, AbstractHistogram.count, core.SkimAnalyzerCount.SkimAnalyzerCount.count, core.TriggerBitFilter.TriggerBitFilter.count, edm::BranchToCount.count, edm::ErrorSummaryEntry.count, edm::messagelogger::ErrorSummaryEntry.count, TmPsu.count, MatrixInjector.MatrixInjector.count, core.JSONAnalyzer.JSONAnalyzer.count, ValidationMisalignedTracker.count, SiStripDetSummary::Values.count, SiPixelDataQuality.count, SiPixelInformationExtractor.count, objects.VertexAnalyzer.VertexAnalyzer.count, edm::service::SimpleMemoryCheck::SignificantEvent.count, TriggerDiff.count, core.PileUpAnalyzer.PileUpAnalyzer.doHists, objects.VertexAnalyzer.VertexAnalyzer.doHists, ALCARECOTkAlBeamHalo_cff.filter, objects.VertexAnalyzer.VertexAnalyzer.fixedWeight, core.AutoHandle.AutoHandle.handles, core.Analyzer.Analyzer.handles, HTTP.RequestManager.handles, sistrip::SpyUtilities.isValid(), genParticles_cff.map, core.Analyzer.Analyzer.mchandles, objects.VertexAnalyzer.VertexAnalyzer.pileup, print(), core.Analyzer.Analyzer.readCollections(), objects.VertexAnalyzer.VertexAnalyzer.testGoodVertex(), core.SkimAnalyzerCount.SkimAnalyzerCount.verbose, VisualizationOptions.verbose, CSCTFanalyzer.verbose, L1TdeStage2EMTF.verbose, L1TStage2uGMTMuon.verbose, L1TStage2EMTF.verbose, heppy::Davismt2.verbose, L1TStage2uGMT.verbose, TritonService::FallbackOpts.verbose, DQMGenericTnPClient.verbose, dqmTnP::AbstractFitter.verbose, L1TStage2OMTF.verbose, confdbOfflineConverter.OfflineConverter.verbose, MuonMillepedeAlgorithm.verbose, DeviationsFromFileSensor2D.verbose, L1TStage2BMTF.verbose, L1TStage2MuonComp.verbose, core.TriggerMatchAnalyzer.TriggerMatchAnalyzer.verbose, L1TStage2RegionalMuonCandComp.verbose, L1TCaloLayer1.verbose, HIPAlignmentAlgorithm.verbose, L1TCaloLayer1RawToDigi.verbose, L1TCaloLayer1Validator.verbose, FFTJetLookupTableESProducer< CT >.verbose, FFTJetCorrectionESProducer< CT >.verbose, o2olib.O2OJobMgr.verbose, objects.VertexAnalyzer.VertexAnalyzer.verbose, L1TStage2uGTCaloLayer2Comp.verbose, OpticalObject.verbose, L1TdeStage2CaloLayer2.verbose, objects.LeptonAnalyzer.LeptonAnalyzer.verbose, and HltDiff.verbose.

◆ testGoodVertex()

def objects.VertexAnalyzer.VertexAnalyzer.testGoodVertex (   self,
  vertex 
)

Definition at line 148 of file VertexAnalyzer.py.

148  def testGoodVertex(self,vertex):
149  if vertex.isFake():
150  return False
151  if vertex.ndof()<=4:
152  return False
153  if abs(vertex.z())>24:
154  return False
155  if vertex.position().Rho()>2:
156  return False
157 
158  return True
159 

References funct.abs().

Referenced by objects.VertexAnalyzer.VertexAnalyzer.process().

◆ write()

def objects.VertexAnalyzer.VertexAnalyzer.write (   self,
  setup 
)

Definition at line 168 of file VertexAnalyzer.py.

168  def write(self, setup):
169  super(VertexAnalyzer, self).write(setup)
170  if self.doHists:
171  self.pileup.write()
172 
173 setattr(VertexAnalyzer,"defaultConfig",cfg.Analyzer(

References core.PileUpAnalyzer.PileUpAnalyzer.doHists, objects.VertexAnalyzer.VertexAnalyzer.doHists, and objects.VertexAnalyzer.VertexAnalyzer.pileup.

Member Data Documentation

◆ allVertices

objects.VertexAnalyzer.VertexAnalyzer.allVertices

◆ class_object

objects.VertexAnalyzer.VertexAnalyzer.class_object
static

Definition at line 174 of file VertexAnalyzer.py.

Referenced by config.Analyzer.build_name(), and config.Service.build_name().

◆ count

objects.VertexAnalyzer.VertexAnalyzer.count

Definition at line 96 of file VertexAnalyzer.py.

Referenced by objects.VertexAnalyzer.VertexAnalyzer.process().

◆ doHists

objects.VertexAnalyzer.VertexAnalyzer.doHists

◆ fixedWeight

objects.VertexAnalyzer.VertexAnalyzer.fixedWeight
static

◆ pileup

objects.VertexAnalyzer.VertexAnalyzer.pileup

◆ verbose

objects.VertexAnalyzer.VertexAnalyzer.verbose
static

◆ vertexWeight

objects.VertexAnalyzer.VertexAnalyzer.vertexWeight
static

Definition at line 175 of file VertexAnalyzer.py.

counter
Definition: counter.py:1
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
sistrip::SpyUtilities::isValid
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
Definition: SiStripSpyUtilities.cc:124
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
LaserDQM_cfg.process
process
Definition: LaserDQM_cfg.py:3
PVValHelper::add
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
Definition: PVValidationHelpers.cc:12
writeEcalDQMStatus.write
write
Definition: writeEcalDQMStatus.py:48
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Average
Definition: trackSplitPlot.h:34
genParticles_cff.map
map
Definition: genParticles_cff.py:11