5 from PhysicsTools.HeppyCore.utils.diclist
import diclist
14 self.add( level, [level, 0] )
16 def inc(self, level, nentries=1):
17 '''increment an existing level 19 if level
not in self.dico:
20 raise ValueError(
'level', level,
'has not been registered')
22 self[level][1] += nentries
25 '''Add two counters (+).''' 26 size =
max( len(self), len(other))
27 for i
in range(0, size):
33 self.
inc( other[i][0], other[i][1] )
35 if self[i][0] != other[i][0]:
36 err = [
'cannot add these counters:',
str(self),
str(other)]
37 raise ValueError(
'\n'.
join(err))
39 self.
inc( other[i][0], other[i][1] )
43 '''Add two counters (+=).''' 47 '''Dump the counter to a pickle file and to a text file in dirname.''' 48 pckfname =
'{d}/{f}.pck'.
format(d=dirname, f=self.
name)
49 pckfname = pckfname.replace(
'*',
'STAR')
50 pckfile = open( pckfname,
'w' )
51 pickle.dump(self, pckfile)
52 txtfile = open( pckfname.replace(
'.pck',
'.txt'),
'w')
53 txtfile.write(
str(self) )
58 retstr =
'Counter %s :\n' % self.
name 61 for level, count
in self:
68 eff1 =
float(count)/prev
72 eff2 =
float(count)/init
73 retstr +=
'\t {level:<40} {count:>9} \t {eff1:4.2f} \t {eff2:6.4f}\n'.
format(
86 TODO: could be a diclist? 95 self.counters.append(
Counter(name) )
105 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)