4 from builtins
import range
6 from PhysicsTools.HeppyCore.utils.diclist
import diclist
15 self.add( level, [level, 0] )
17 def inc(self, level, nentries=1):
18 '''increment an existing level 20 if level
not in self.dico:
21 raise ValueError(
'level', level,
'has not been registered')
23 self[level][1] += nentries
26 '''Add two counters (+).''' 27 size =
max( len(self), len(other))
28 for i
in range(0, size):
34 self.
inc( other[i][0], other[i][1] )
36 if self[i][0] != other[i][0]:
37 err = [
'cannot add these counters:',
str(self),
str(other)]
38 raise ValueError(
'\n'.
join(err))
40 self.
inc( other[i][0], other[i][1] )
44 '''Add two counters (+=).''' 48 '''Dump the counter to a pickle file and to a text file in dirname.''' 49 pckfname =
'{d}/{f}.pck'.
format(d=dirname, f=self.
name)
50 pckfname = pckfname.replace(
'*',
'STAR')
51 pckfile = open( pckfname,
'w' )
52 pickle.dump(self, pckfile)
53 txtfile = open( pckfname.replace(
'.pck',
'.txt'),
'w')
54 txtfile.write(
str(self) )
59 retstr =
'Counter %s :\n' % self.
name 62 for level, count
in self:
69 eff1 =
float(count)/prev
73 eff2 =
float(count)/init
74 retstr +=
'\t {level:<40} {count:>9} \t {eff1:4.2f} \t {eff2:6.4f}\n'.
format(
87 TODO: could be a diclist? 96 self.counters.append(
Counter(name) )
106 return '\n'.
join(prints)
def __getitem__(self, name)
def addCounter(self, name)
def inc(self, level, nentries=1)
static std::string join(char **cmd)
def register(self, level)
def __iadd__(self, other)