CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes
analyzer.Analyzer Class Reference
Inheritance diagram for analyzer.Analyzer:

Public Member Functions

def __init__
 
def __str__
 
def beginLoop
 
def endLoop
 
def process
 
def write
 

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

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

Member Function Documentation

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, join(), and str.

75 
76  def __str__(self):
77  """A multipurpose printout. Should do the job for most analyzers."""
78  ana = str( self.cfg_ana )
79  count = ''
80  ave = ''
81  if hasattr(self, 'counters') and len( self.counters.counters ) > 0:
82  count = '\n'.join(map(str, self.counters.counters))
83  if hasattr(self, 'averages') and len( self.averages ) > 0:
84  ave = '\n'.join(map(str, self.averages))
85  return '\n'.join( [ana, count, ave] )
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
#define str(s)
def analyzer.Analyzer.beginLoop (   self,
  setup 
)
Automatically called by Looper, for all analyzers.

Definition at line 48 of file analyzer.py.

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

Definition at line 55 of file analyzer.py.

References str.

55 
56  def endLoop(self, setup):
57  """Automatically called by Looper, for all analyzers."""
58  #print self.cfg_ana
59  self.mainLogger.info( '' )
60  self.mainLogger.info( str(self) )
61  self.mainLogger.info( '' )
#define str(s)
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 print().

62 
63  def process(self, event ):
64  """Automatically called by Looper, for all analyzers.
65  each analyzer in the sequence will be passed the same event instance.
66  each analyzer can access, modify, and store event information, of any type."""
67  print(self.cfg_ana.name)
68 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
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.dirName, and MuonIsolationDQM.dirName.

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

Member Data Documentation

analyzer.Analyzer.averages

Definition at line 51 of file analyzer.py.

Referenced by analyzer.Analyzer.__str__(), core.PileUpAnalyzer.PileUpAnalyzer.process(), and objects.VertexAnalyzer.VertexAnalyzer.process().

analyzer.Analyzer.beginLoopCalled

Definition at line 46 of file analyzer.py.

analyzer.Analyzer.cfg_ana

Definition at line 32 of file analyzer.py.

Referenced by objects.LeptonAnalyzer.LeptonAnalyzer.__init__(), analyzer.Analyzer.__str__(), DiLeptonAnalyzer.DiLeptonAnalyzer.beginLoop(), core.AutoFillTreeProducer.AutoFillTreeProducer.declareCoreVariables(), core.AutoFillTreeProducer.AutoFillTreeProducer.declareVariables(), gen.GeneratorAnalyzer.GeneratorAnalyzer.makeMCInfo(), objects.TauAnalyzer.TauAnalyzer.makeTaus(), objects.METAnalyzer.METAnalyzer.makeTkMETs(), JetAnalyzer.JetAnalyzer.process(), objects.VertexAnalyzer.VertexAnalyzer.process(), core.AutoFillTreeProducer.AutoFillTreeProducer.process(), DiLeptonAnalyzer.DiLeptonAnalyzer.selectionSequence(), DiLeptonAnalyzer.DiLeptonAnalyzer.shiftEnergyScale(), and DiLeptonAnalyzer.DiLeptonAnalyzer.trigMatched().

analyzer.Analyzer.cfg_comp

Definition at line 33 of file analyzer.py.

Referenced by looper.Looper._build(), core.AutoFillTreeProducer.AutoFillTreeProducer.fillCoreVariables(), looper.Looper.loop(), and JetAnalyzer.JetAnalyzer.process().

analyzer.Analyzer.class_object

Definition at line 28 of file analyzer.py.

analyzer.Analyzer.counters

Definition at line 50 of file analyzer.py.

Referenced by counter.Counters.__str__(), counter.Counters.addCounter(), counter.Counters.counter(), and counter.Counters.write().

analyzer.Analyzer.dirName

Definition at line 36 of file analyzer.py.

Referenced by addOnTests.testit.run(), analyzer.Analyzer.write(), and core.JSONAnalyzer.JSONAnalyzer.write().

analyzer.Analyzer.instance_label

Definition at line 29 of file analyzer.py.

Referenced by config.Analyzer.build_name(), config.Service.build_name(), Filter.Filter.process(), SimpleJetAnalyzer.SimpleJetAnalyzer.process(), and ResonanceBuilder.ResonanceBuilder.process().

analyzer.Analyzer.looperName

Definition at line 34 of file analyzer.py.

analyzer.Analyzer.mainLogger

Definition at line 44 of file analyzer.py.

analyzer.Analyzer.name

Definition at line 30 of file analyzer.py.

Referenced by FWLite.ElectronMVAID.__call__(), dirstructure.Directory.__create_pie_image(), DisplayManager.DisplayManager.__del__(), dqm_interfaces.DirID.__eq__(), dirstructure.Directory.__get_full_path(), dirstructure.Comparison.__get_img_name(), dataset.Dataset.__getDataType(), dataset.Dataset.__getFileInfoList(), dirstructure.Comparison.__make_image(), dirstructure.Directory.__repr__(), dqm_interfaces.DirID.__repr__(), dirstructure.Comparison.__repr__(), config.Service.__setattr__(), config.CFG.__str__(), counter.Counter.__str__(), average.Average.__str__(), FWLite.WorkingPoints._reformat_cut_definitions(), dirstructure.Directory.calcStats(), geometryComparison.GeometryComparison.createScript(), validation.Sample.digest(), python.rootplot.utilities.Hist.divide(), python.rootplot.utilities.Hist.divide_wilson(), DisplayManager.DisplayManager.Draw(), utils.StatisticalTest.get_status(), production_tasks.Task.getname(), dataset.CMSDataset.getPrimaryDatasetEntries(), dataset.PrivateDataset.getPrimaryDatasetEntries(), primaryVertexResolution.PrimaryVertexResolution.getRepMap(), primaryVertexValidation.PrimaryVertexValidation.getRepMap(), zMuMuValidation.ZMuMuValidation.getRepMap(), VIDSelectorBase.VIDSelectorBase.initialize(), dirstructure.Directory.print_report(), dataset.BaseDataset.printInfo(), dataset.Dataset.printInfo(), production_tasks.MonitorJobs.run(), python.rootplot.utilities.Hist.TGraph(), python.rootplot.utilities.Hist.TH1F(), counter.Counter.write(), and average.Average.write().

analyzer.Analyzer.verbose

Definition at line 31 of file analyzer.py.

Referenced by python.diff_provenance.difference.list_diff(), python.diffProv.difference.list_diff(), python.diff_provenance.difference.module_diff(), python.diffProv.difference.module_diff(), python.diff_provenance.difference.onefilemodules(), and python.diffProv.difference.onefilemodules().