CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
analyzer.Analyzer Class Reference
Inheritance diagram for analyzer.Analyzer:

Public Member Functions

def __init__ (self, cfg_ana, cfg_comp, looperName)
 
def __str__ (self)
 
def beginLoop (self, setup)
 
def endLoop (self, setup)
 
def process (self, event)
 
def write (self, setup)
 

Public Attributes

 averages
 
 beginLoopCalled
 
 cfg_ana
 
 cfg_comp
 
 class_object
 
 counters
 
 dirName
 
 instance_label
 
 looperName
 
 mainLogger
 
 name
 
 verbose
 

Detailed Description

Base Analyzer class. Used in Looper.

Your custom analyzers should inherit from this class

Definition at line 11 of file analyzer.py.

Constructor & Destructor Documentation

◆ __init__()

def analyzer.Analyzer.__init__ (   self,
  cfg_ana,
  cfg_comp,
  looperName 
)
Create an analyzer.

Parameters (also stored as attributes for later use):
cfg_ana: configuration parameters for this analyzer (e.g. a pt cut)
cfg_comp: configuration parameters for the data or MC component (e.g. DYJets)
looperName: name of the Looper which runs this analyzer.

Attributes:
dirName : analyzer directory, where you can write anything you want

Definition at line 17 of file analyzer.py.

17  def __init__(self, cfg_ana, cfg_comp, looperName ):
18  """Create an analyzer.
19 
20  Parameters (also stored as attributes for later use):
21  cfg_ana: configuration parameters for this analyzer (e.g. a pt cut)
22  cfg_comp: configuration parameters for the data or MC component (e.g. DYJets)
23  looperName: name of the Looper which runs this analyzer.
24 
25  Attributes:
26  dirName : analyzer directory, where you can write anything you want
27  """
28  self.class_object = cfg_ana.class_object
29  self.instance_label = cfg_ana.instance_label
30  self.name = cfg_ana.name
31  self.verbose = cfg_ana.verbose
32  self.cfg_ana = cfg_ana
33  self.cfg_comp = cfg_comp
34  self.looperName = looperName
35  if hasattr(cfg_ana,"nosubdir") and cfg_ana.nosubdir:
36  self.dirName = self.looperName
37  else:
38  self.dirName = '/'.join( [self.looperName, self.name] )
39  os.mkdir( self.dirName )
40 
41 
42  # this is the main logger corresponding to the looper.
43  # each analyzer could also declare its own logger
44  self.mainLogger = logging.getLogger( looperName )
45  # print self.mainLogger.handlers
46  self.beginLoopCalled = False
47 

Member Function Documentation

◆ __str__()

def analyzer.Analyzer.__str__ (   self)
A multipurpose printout. Should do the job for most analyzers.

Definition at line 75 of file analyzer.py.

75  def __str__(self):
76  """A multipurpose printout. Should do the job for most analyzers."""
77  ana = str( self.cfg_ana )
78  count = ''
79  ave = ''
80  if hasattr(self, 'counters') and len( self.counters.counters ) > 0:
81  count = '\n'.join(map(str, self.counters.counters))
82  if hasattr(self, 'averages') and len( self.averages ) > 0:
83  ave = '\n'.join(map(str, self.averages))
84  return '\n'.join( [ana, count, ave] )

References analyzer.Analyzer.averages, analyzer.Analyzer.cfg_ana, cms::cuda::AtomicPairCounter::Atomic2.counters, NMaxPerLumi.counters, analyzer.Analyzer.counters, HistogramManager.counters, cscdqm::ChamberCounterKeyType.counters, join(), genParticles_cff.map, and str.

◆ beginLoop()

def analyzer.Analyzer.beginLoop (   self,
  setup 
)
Automatically called by Looper, for all analyzers.

Definition at line 48 of file analyzer.py.

48  def beginLoop(self, setup):
49  """Automatically called by Looper, for all analyzers."""
50  self.counters = Counters()
51  self.averages = Averages()
52  self.mainLogger.info( 'beginLoop ' + self.cfg_ana.name )
53  self.beginLoopCalled = True
54 

◆ endLoop()

def analyzer.Analyzer.endLoop (   self,
  setup 
)
Automatically called by Looper, for all analyzers.

Definition at line 55 of file analyzer.py.

55  def endLoop(self, setup):
56  """Automatically called by Looper, for all analyzers."""
57  #print self.cfg_ana
58  self.mainLogger.info( '' )
59  self.mainLogger.info( str(self) )
60  self.mainLogger.info( '' )
61 

References info(), analyzer.Analyzer.mainLogger, and str.

◆ process()

def analyzer.Analyzer.process (   self,
  event 
)
Automatically called by Looper, for all analyzers.
each analyzer in the sequence will be passed the same event instance.
each analyzer can access, modify, and store event information, of any type.

Definition at line 62 of file analyzer.py.

62  def process(self, event ):
63  """Automatically called by Looper, for all analyzers.
64  each analyzer in the sequence will be passed the same event instance.
65  each analyzer can access, modify, and store event information, of any type."""
66  print(self.cfg_ana.name)
67 
68 

References analyzer.Analyzer.cfg_ana, and print().

◆ write()

def analyzer.Analyzer.write (   self,
  setup 
)
Called by Looper.write, for all analyzers.
Just overload it if you have histograms to write.

Definition at line 69 of file analyzer.py.

69  def write(self, setup):
70  """Called by Looper.write, for all analyzers.
71  Just overload it if you have histograms to write."""
72  self.counters.write( self.dirName )
73  self.averages.write( self.dirName )
74 

References analyzer.Analyzer.averages, cms::cuda::AtomicPairCounter::Atomic2.counters, NMaxPerLumi.counters, analyzer.Analyzer.counters, HistogramManager.counters, cscdqm::ChamberCounterKeyType.counters, analyzer.Analyzer.dirName, and MuonIsolationDQM.dirName.

Member Data Documentation

◆ averages

analyzer.Analyzer.averages

◆ beginLoopCalled

analyzer.Analyzer.beginLoopCalled

Definition at line 46 of file analyzer.py.

◆ cfg_ana

analyzer.Analyzer.cfg_ana

Definition at line 32 of file analyzer.py.

Referenced by core.TriggerBitAnalyzer.TriggerBitAnalyzer.__init__(), core.TriggerMatchAnalyzer.TriggerMatchAnalyzer.__init__(), objects.LeptonAnalyzer.LeptonAnalyzer.__init__(), objects.JetAnalyzer.JetAnalyzer.__init__(), analyzer.Analyzer.__str__(), objects.PhotonAnalyzer.PhotonAnalyzer.attachFootprintRemovedIsolation(), objects.LeptonAnalyzer.LeptonAnalyzer.attachMiniIsolation(), Histogrammer.Histogrammer.beginLoop(), DiLeptonAnalyzer.DiLeptonAnalyzer.beginLoop(), MetAnalyzer.MetAnalyzer.declareHandles(), objects.METAnalyzer.METAnalyzer.declareHandles(), MT2Analyzer.MT2Analyzer.declareHandles(), objects.PhotonAnalyzer.PhotonAnalyzer.declareHandles(), JetAnalyzer.JetAnalyzer.declareHandles(), objects.VertexAnalyzer.VertexAnalyzer.declareHandles(), objects.LeptonAnalyzer.LeptonAnalyzer.declareHandles(), objects.JetAnalyzer.JetAnalyzer.declareHandles(), core.AutoFillTreeProducer.AutoFillTreeProducer.declareVariables(), objects.LeptonAnalyzer.LeptonAnalyzer.makeAllElectrons(), objects.LeptonAnalyzer.LeptonAnalyzer.makeAllMuons(), objects.IsoTrackAnalyzer.IsoTrackAnalyzer.makeIsoTrack(), objects.LeptonAnalyzer.LeptonAnalyzer.makeLeptons(), gen.GeneratorAnalyzer.GeneratorAnalyzer.makeMCInfo(), gen.PDFWeightsAnalyzer.PDFWeightsAnalyzer.makePDFWeights(), objects.PhotonAnalyzer.PhotonAnalyzer.makePhotons(), objects.TauAnalyzer.TauAnalyzer.makeTaus(), objects.METAnalyzer.METAnalyzer.makeTkMETs(), objects.LeptonAnalyzer.LeptonAnalyzer.matchLeptons(), Filter.Filter.process(), core.Analyzer.Analyzer.process(), SimpleJetAnalyzer.SimpleJetAnalyzer.process(), gen.HiggsDecayModeAnalyzer.HiggsDecayModeAnalyzer.process(), core.EventSelector.EventSelector.process(), analyzer.Analyzer.process(), Matcher.Matcher.process(), JetAnalyzer.JetAnalyzer.process(), ResonanceBuilder.ResonanceBuilder.process(), DiLeptonAnalyzer.DiLeptonAnalyzer.process(), core.PileUpAnalyzer.PileUpAnalyzer.process(), objects.VertexAnalyzer.VertexAnalyzer.process(), objects.JetAnalyzer.JetAnalyzer.process(), core.AutoFillTreeProducer.AutoFillTreeProducer.process(), objects.PhotonAnalyzer.PhotonAnalyzer.process(), objects.LeptonAnalyzer.LeptonAnalyzer.process(), DiLeptonAnalyzer.DiLeptonAnalyzer.selectionSequence(), DiLeptonAnalyzer.DiLeptonAnalyzer.shiftEnergyScale(), DiLeptonAnalyzer.DiLeptonAnalyzer.testDeltaR(), JetAnalyzer.JetAnalyzer.testJet(), JetAnalyzer.JetAnalyzer.testJetID(), objects.JetAnalyzer.JetAnalyzer.testJetID(), objects.JetAnalyzer.JetAnalyzer.testJetNoID(), DiLeptonAnalyzer.DiLeptonAnalyzer.testLeg1(), DiLeptonAnalyzer.DiLeptonAnalyzer.testLeg1Iso(), DiLeptonAnalyzer.DiLeptonAnalyzer.testLeg2(), DiLeptonAnalyzer.DiLeptonAnalyzer.testLeg2Iso(), DiLeptonAnalyzer.DiLeptonAnalyzer.testMass(), and DiLeptonAnalyzer.DiLeptonAnalyzer.trigMatched().

◆ cfg_comp

analyzer.Analyzer.cfg_comp

Definition at line 33 of file analyzer.py.

Referenced by objects.LeptonAnalyzer.LeptonAnalyzer.__init__(), core.JSONAnalyzer.JSONAnalyzer.__init__(), objects.JetAnalyzer.JetAnalyzer.__init__(), looper.Looper._build(), JetAnalyzer.JetAnalyzer.declareHandles(), objects.VertexAnalyzer.VertexAnalyzer.declareHandles(), core.AutoFillTreeProducer.AutoFillTreeProducer.declareVariables(), core.AutoFillTreeProducer.AutoFillTreeProducer.fillCoreVariables(), core.AutoFillTreeProducer.AutoFillTreeProducer.fillTree(), core.AutoFillTreeProducer.AutoFillTreeProducer.getPythonWrapper(), looper.Looper.loop(), gen.LHEAnalyzer.LHEAnalyzer.process(), SimpleJetAnalyzer.SimpleJetAnalyzer.process(), gen.LHEWeightAnalyzer.LHEWeightAnalyzer.process(), gen.HiggsDecayModeAnalyzer.HiggsDecayModeAnalyzer.process(), gen.GenHeavyFlavourAnalyzer.GenHeavyFlavourAnalyzer.process(), gen.PDFWeightsAnalyzer.PDFWeightsAnalyzer.process(), core.JSONAnalyzer.JSONAnalyzer.process(), core.SkimAnalyzerCount.SkimAnalyzerCount.process(), AlphaTAnalyzer.AlphaTAnalyzer.process(), JetAnalyzer.JetAnalyzer.process(), core.PileUpAnalyzer.PileUpAnalyzer.process(), objects.VertexAnalyzer.VertexAnalyzer.process(), objects.TauAnalyzer.TauAnalyzer.process(), gen.GeneratorAnalyzer.GeneratorAnalyzer.process(), objects.PhotonAnalyzer.PhotonAnalyzer.process(), objects.LeptonAnalyzer.LeptonAnalyzer.process(), core.Analyzer.Analyzer.readCollections(), DiLeptonAnalyzer.DiLeptonAnalyzer.selectionSequence(), JetAnalyzer.JetAnalyzer.testBJet(), and core.PileUpAnalyzer.PileUpAnalyzer.write().

◆ class_object

analyzer.Analyzer.class_object

Definition at line 28 of file analyzer.py.

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

◆ counters

analyzer.Analyzer.counters

◆ dirName

analyzer.Analyzer.dirName

◆ instance_label

analyzer.Analyzer.instance_label

◆ looperName

analyzer.Analyzer.looperName

Definition at line 34 of file analyzer.py.

◆ mainLogger

analyzer.Analyzer.mainLogger

Definition at line 44 of file analyzer.py.

Referenced by analyzer.Analyzer.endLoop().

◆ name

analyzer.Analyzer.name

◆ verbose

analyzer.Analyzer.verbose
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
str
#define str(s)
Definition: TestProcessor.cc:51
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
TriggerAnalyzer.__str__
def __str__(self)
Definition: TriggerAnalyzer.py:103
writeEcalDQMStatus.write
write
Definition: writeEcalDQMStatus.py:48
Averages
Definition: Averages.h:10
genParticles_cff.map
map
Definition: genParticles_cff.py:11