1 from __future__
import print_function
8 from PhysicsTools.HeppyCore.statistics.counter
import Counters
9 from PhysicsTools.HeppyCore.statistics.average
import Averages
12 """Base Analyzer class. Used in Looper. 14 Your custom analyzers should inherit from this class 17 def __init__(self, cfg_ana, cfg_comp, looperName ):
18 """Create an analyzer. 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. 26 dirName : analyzer directory, where you can write anything you want 35 if hasattr(cfg_ana,
"nosubdir")
and cfg_ana.nosubdir:
49 """Automatically called by Looper, for all analyzers.""" 52 self.mainLogger.info(
'beginLoop ' + self.cfg_ana.name )
56 """Automatically called by Looper, for all analyzers.""" 58 self.mainLogger.info(
'' )
59 self.mainLogger.info(
str(self) )
60 self.mainLogger.info(
'' )
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)
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 )
76 """A multipurpose printout. Should do the job for most analyzers.""" 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:
84 return '\n'.
join( [ana, count, ave] )
def beginLoop(self, setup)
S & print(S &os, JobReport::InputFile const &f)
static std::string join(char **cmd)
def __init__(self, cfg_ana, cfg_comp, looperName)