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

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 
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
def __init__(self, cfg_ana, cfg_comp, looperName)
Definition: analyzer.py:17

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(), 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:17
#define str(s)
def __str__(self)
Definition: analyzer.py:75
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 
def beginLoop(self, setup)
Definition: analyzer.py:48
def analyzer.Analyzer.endLoop (   self,
  setup 
)
Automatically called by Looper, for all analyzers.

Definition at line 55 of file analyzer.py.

References 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 
def endLoop(self, setup)
Definition: analyzer.py:55
#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 edm.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 
def process(self, event)
Definition: analyzer.py:62
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
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  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 
def write(self, setup)
Definition: analyzer.py:69

Member Data Documentation

analyzer.Analyzer.beginLoopCalled

Definition at line 46 of file analyzer.py.

analyzer.Analyzer.class_object

Definition at line 28 of file analyzer.py.

analyzer.Analyzer.counters
analyzer.Analyzer.dirName
analyzer.Analyzer.looperName

Definition at line 34 of file analyzer.py.

analyzer.Analyzer.mainLogger

Definition at line 44 of file analyzer.py.