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 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)
static std::string join(char **cmd)
Definition: RemoteFile.cc:19

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.

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.

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] )
85 
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
#define str(s)

◆ 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 
static const TGPicture * info(bool iBackgroundIsBlack)

◆ endLoop()

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

Definition at line 55 of file analyzer.py.

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

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 
static const TGPicture * info(bool iBackgroundIsBlack)
#define str(s)

◆ 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.

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

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 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

◆ 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.

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.

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 

Member Data Documentation

◆ 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

◆ dirName

analyzer.Analyzer.dirName

◆ 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

◆ verbose