CMS 3D CMS Logo

Classes | Functions | Variables

bookConverter Namespace Reference

Classes

class  OptionParser

Functions

def ccopy
def cexists
def compute
def create_declaration
def create_xsd
def kpermutation
def priorities
def read_data

Variables

dictionary comb = {}
dictionary elements = {}
list histograms = []
dictionary keys = {}
int len_max = 0
int len_min = 1000000
 max = len_max
int min = 2
tuple optManager = OptionParser()
 opts = opts.__dict__
dictionary prior = {}
tuple resdoc = dom.Document()
dictionary results = {}
tuple srcdoc = dom.parse(opts['src'])

Function Documentation

def bookConverter::ccopy (   a)

Definition at line 89 of file bookConverter.py.

00090             :
00091   r = []
00092   for v in a:
00093     r.append(v)
00094   return r

def bookConverter::cexists (   s,
  c 
)

Definition at line 81 of file bookConverter.py.

00082                  :
00083   d = len(c)
00084   for v1 in s:
00085     for v2 in c:
00086       if v1 == v2:
00087         d = d - 1
00088   return (d == 0)

def bookConverter::compute (   min,
  max 
)

Definition at line 105 of file bookConverter.py.

Referenced by DTCalibValidation::analyze(), DTRecHitQuality::analyze(), ClosestApproachInRPhi::calculate(), TrackCountingTagPlotter::finalize(), TrackProbabilityTagPlotter::finalize(), TrackIPTagPlotter::finalize(), PhysicsTools::MVATrainer::getTrainCalibration(), PhysicsTools::MVATrainer::makeTrainCalibration(), and DTRecHitBaseAlgo::reconstruct().

00106                      :
00107   print "Computing permutations"
00108   for v in kpermutation(0, len(keys), min, max):
00109     ci = -1
00110     for h in histograms:
00111       if cexists(h, v):
00112         if ci == -1:
00113           ci = len(comb)
00114           comb[ci] = ccopy(v)
00115           results[ci] = [h]
00116         else:
00117           results[ci].append(h) 

def bookConverter::create_declaration (   cid)

Definition at line 75 of file bookConverter.py.

00076                            :
00077   co = comb[cid]
00078   print "Declaration to apply:", co
00079   for k in comb[cid]:
00080     print keys[k]['name'], '=', keys[k]['value']

def bookConverter::create_xsd ( )

Definition at line 57 of file bookConverter.py.

00058                 :
00059   for k in keys.keys():
00060     name = keys[k]['name']
00061 
00062   root = resdoc.createElement("xs:complexType")
00063   root.setAttribute("name", "HistogramType")
00064   resdoc.appendChild(root)
00065   seq = resdoc.createElement("xs:all")
00066   root.appendChild(seq)
00067   for e in sorted(elements.keys()):
00068     el = resdoc.createElement("xs:element")
00069     el.setAttribute("name", e)
00070     el.setAttribute("type", elements[e]['type'])
00071     if elements[e]['count'] < len(histograms):
00072       el.setAttribute("minOccurs", '0')
00073       el.setAttribute("maxOccurs", '1')
00074     seq.appendChild(el)

def bookConverter::kpermutation (   vfrom,
  vto,
  min,
  max 
)

Definition at line 95 of file bookConverter.py.

00096                                       :
00097   vto = vto + 1
00098   queue = []
00099   for i in range(vfrom, vto):
00100     for j in range(i, vto):
00101       queue.append(j)
00102       if len(queue) >= min and len(queue) <= max:
00103         yield queue
00104     queue = []

def bookConverter::priorities ( )

Definition at line 118 of file bookConverter.py.

00119                 :
00120   for ci in comb.keys():
00121     l = len(results[ci])
00122     if l == 1: 
00123       continue
00124     if not prior.has_key(l):
00125       prior[l] = [ci]
00126     else:
00127       prior[l].append(ci)

def bookConverter::read_data ( )

Definition at line 16 of file bookConverter.py.

00017                :
00018   print "Reading histogram file"
00019   n = 0
00020   histos = srcdoc.getElementsByTagName("Histogram")
00021   for histo in histos:
00022     h = []
00023     for key in histo.childNodes:
00024       if key.nodeType == key.ELEMENT_NODE:
00025         name = key.localName
00026         value = key.childNodes[0].nodeValue
00027         found = 0
00028 
00029         if not elements.has_key(name):
00030           elements[name] = {'type': '', 'count': 0}
00031         elements[name]['count'] = elements[name]['count'] + 1
00032 
00033         try:
00034           i = int(value)
00035           if elements[name]['type'] == '':
00036             elements[name]['type'] = 'xs:integer'
00037         except ValueError:
00038           try:
00039             i = float(value)  
00040             if elements[name]['type'] in ('', 'xs:integer'):
00041               elements[name]['type'] = 'xs:double'
00042           except ValueError:
00043             elements[name]['type'] = 'xs:string'
00044 
00045         for k in keys.keys():
00046           if keys[k]['name'] == name and keys[k]['value'] == value:
00047             keys[k]['count'] = keys[k]['count'] + 1
00048             h.append(k)
00049             found = 1
00050             break
00051         if found == 0:
00052           keys[n] = {'name': name, 'value': value, 'count': 1}
00053           h.append(n)
00054           n += 1
00055     h.sort()
00056     histograms.append(h)


Variable Documentation

dictionary bookConverter::comb = {}
dictionary bookConverter::elements = {}

Definition at line 146 of file bookConverter.py.

Definition at line 141 of file bookConverter.py.

Referenced by HistoAnalyzer< C >::HistoAnalyzer().

dictionary bookConverter::keys = {}

Definition at line 142 of file bookConverter.py.

Definition at line 148 of file bookConverter.py.

int bookConverter::len_min = 1000000

Definition at line 147 of file bookConverter.py.

Definition at line 166 of file bookConverter.py.

Definition at line 164 of file bookConverter.py.

Definition at line 130 of file bookConverter.py.

bookConverter::opts = opts.__dict__

Definition at line 132 of file bookConverter.py.

dictionary bookConverter::prior = {}
tuple bookConverter::resdoc = dom.Document()

Definition at line 138 of file bookConverter.py.

dictionary bookConverter::results = {}

Definition at line 143 of file bookConverter.py.

tuple bookConverter::srcdoc = dom.parse(opts['src'])

Definition at line 139 of file bookConverter.py.