CMS 3D CMS Logo

Functions | Variables

motionPolicyChamber Namespace Reference

Functions

def loopover

Variables

string action = "store_true"
string commandline = " "
list copyargs = sys.argv[:]
int default = 2
string dest = "nsigma"
 DO_CSC = False
 DO_DT = False
tuple geom0 = MuonGeometry(file(theInXML0))
tuple geomN = MuonGeometry(file(theInXMLN))
string help = "optional minimum nsigma(deltax) position displacement in order to move a chamber; default NSIGMA=3"
tuple parser = optparse.OptionParser(usage)
list prog = sys.argv[0]
list theInREPN = sys.argv[3]
list theInXML0 = sys.argv[1]
list theInXMLN = sys.argv[2]
 theNSigma = options.nsigma
list theOutXML = sys.argv[4]
string type = "int"
string usage

Function Documentation

def motionPolicyChamber::loopover (   muSystem)

Definition at line 86 of file motionPolicyChamber.py.

00087                       :
00088 
00089   movedChamberKeys = []
00090   
00091   if muSystem == "DT":
00092     keys = geom0.dt.keys()
00093     keys.sort(dtorder)
00094   elif muSystem == "CSC":
00095     keys = geom0.csc.keys()
00096     keys.sort(cscorder)
00097   else: raise Exception
00098   
00099   nkeys, nkeysr, nkeyspass, nmoved, nnotmoved = 0,0,0,0,0
00100   nfail_toideal, nfail_deltafinal, nfail_lowstat, nfail_nsigma = 0,0,0,0
00101   nok_toideal, nok_deltafinal, nok_lowstat, nok_nsigma = 0,0,0,0
00102   
00103   for key in keys:
00104     is_ch = True
00105     if muSystem == "DT":
00106       if len(key) != 3: is_ch = False
00107       ch_key = key[:3]
00108       g1 = geom0.dt[key]
00109       g2 = geomN.dt[key]
00110       ch_g1 = geom0.dt[ch_key]
00111       ch_g2 = geomN.dt[ch_key]
00112     else:
00113       if len(key) != 4: is_ch = False
00114       ch_key = key[:4]
00115       g1 = geom0.csc[key]
00116       g2 = geomN.csc[key]
00117       ch_g1 = geom0.csc[ch_key]
00118       ch_g2 = geomN.csc[ch_key]
00119     if is_ch: nkeys+=1
00120 
00121     chWasntMoved = True
00122     if ch_key in movedChamberKeys:
00123       chWasntMoved = False
00124     
00125     if g1.relativeto != g2.relativeto:
00126       print "%s %s relativeto=\"%s\" versus relativeto=\"%s\"" % (muSystem, str(key), g1.relativeto, g2.relativeto)
00127 
00128     found = False
00129     #r = reports[0]
00130     for r in reports:
00131       if r.postal_address[1:] == ch_key:
00132         found = True
00133         rep = r
00134         break
00135     if not found:
00136       if is_ch: print muSystem, str(key), "not found in the report. Continue..."
00137       continue
00138     if is_ch: nkeysr+=1
00139 
00140     if rep.status != "PASS":
00141       if is_ch: print muSystem, str(key), "status is not PASS: %s   Continue..." % rep.status
00142       continue
00143     #print muSystem, str(key), str(ch_key)
00144     if is_ch: nkeyspass+=1
00145     
00146     ############################################################
00147     # CHECKS
00148     
00149     ok = True
00150     
00151     if muSystem == "DT" and chWasntMoved:
00152       
00153       # check that chamber's movement respective to ideal geometry is in reasonable range of 20 mm or 20 mrad:
00154       if abs(ch_g2.x) > 2. or abs(ch_g2.y) > 2. or abs(ch_g2.phiy) > 0.02 or abs(ch_g2.phiz) > 0.02:
00155         ok = False
00156         if is_ch:
00157           nfail_toideal += 1
00158           print "Warning!!!", muSystem, str(key), \
00159             "moved too much with respect to ideal: dx=%.2f mm  dy=%.2f mm  dphiy=%.2f mrad  dphiz=%.2f mrad  skipping..." % (ch_g2.x*10, ch_g2.y*10, ch_g2.phiy*1000, ch_g2.phiz*1000)
00160       if is_ch and ok: nok_toideal +=1
00161       
00162       # check that movements during the final iteration were negligible
00163       # separately for station 4
00164       if key[1] != 4 :
00165         if abs(rep.deltax.value) > 0.03 or abs(rep.deltay.value) > 0.03 or abs(rep.deltaphiy.value) > 0.0003 or abs(rep.deltaphiz.value) > 0.0006:
00166           ok = False
00167           if is_ch:
00168             nfail_deltafinal += 1
00169             print "Warning!!!", muSystem, str(key), \
00170               "moved too much at final iteration: dx=%.2f mm  dy=%.2f mm  dphiy=%.2f mrad  dphiz=%.2f mrad   skipping..." % \
00171                 (rep.deltax.value*10, rep.deltay.value*10, rep.deltaphiy.value*1000, rep.deltaphiz.value*1000)
00172       else:
00173         if abs(rep.deltax.value) > 0.03 or abs(rep.deltaphiy.value) > 0.0003 or abs(rep.deltaphiz.value) > 0.0006:
00174           ok = False
00175           if is_ch:
00176             nfail_deltafinal += 1
00177             print "Warning!!!", muSystem, str(key), \
00178               "moved too much at final iteration: dx=%.2f mm  dphiy=%.2f mrad  dphiz=%.2f mrad   skipping..." % \
00179                 (rep.deltax.value*10, rep.deltaphiy.value*1000, rep.deltaphiz.value*1000)
00180       if is_ch and ok: nok_deltafinal +=1
00181 
00182       # low statictics check:
00183       if rep.deltax.error > 0.5:
00184         ok = False
00185         if is_ch:
00186           nfail_lowstat +=1
00187           print "Warning!!!", muSystem, str(key), "low statistics chamber with too big dx.error = %.2f mm   skipping..." % (rep.deltax.error*10.)
00188       if is_ch and ok: nok_lowstat +=1
00189     
00190       # N-SIGMA MOTION POLICY CHECK
00191       #print "%s %s position difference: %g - %g = %g --> %g, nsigma: %g)" % (
00192       #        muSystem, str(key), g1.x, g2.x, g1.x - g2.x, abs(g1.x - g2.x)/rep.deltax.error, theNSigma * rep.deltax.error)
00193       if abs(ch_g1.x - ch_g2.x) < theNSigma * math.sqrt ( rep.deltax.error*rep.deltax.error + 0.02*0.02 ) :
00194         ok = False
00195         if is_ch:
00196           nfail_nsigma += 1
00197           print muSystem, str(key), "not moved: xN-x0 = %.3f - %.3f = %.3f < %.3f mm" % \
00198             ( ch_g2.x*10., ch_g1.x*10., (ch_g2.x-ch_g1.x)*10., theNSigma * math.sqrt ( rep.deltax.error*rep.deltax.error + 0.02*0.02 )*10.)
00199 
00200       if ok: chWasntMoved = False
00201     
00202     if not ok or chWasntMoved: continue
00203     
00204     ############################################################
00205     # MOTION
00206     if is_ch:
00207       movedChamberKeys.append(ch_key)
00208       print muSystem, str(key), "moved!"
00209       nmoved+=1
00210     #move this chamber/superlayer/layer:
00211     if muSystem == "DT":
00212       geom0.dt[key] = copy.copy(geomN.dt[key])
00213     else:
00214       geom0.csc[key] = copy.copy(geomN.csc[key])
00215     
00216   nnotmoved = nkeys - nmoved
00217   nsig = int(theNSigma)
00218   print """
00219 %(muSystem)s REPORT for  %(nsig)d sigma policy:
00220 Cumulative counters:
00221   %(nkeys)d\t chambers in geometry
00222   %(nkeysr)d\t chambers in report
00223   %(nkeyspass)d\t have PASS status
00224   %(nok_toideal)d\t pass big shift with respect to ideal check
00225   %(nok_deltafinal)d\t pass big deltas during final iteration
00226   %(nok_lowstat)d\t pass low statistics (or big deltax.error) check
00227   %(nmoved)d\t moved
00228 Not moved counters:
00229   %(nnotmoved)d\t chambers not moved
00230   Numbers of chambers were not moved due to:
00231     %(nfail_toideal)d\t big shift with respect to ideal
00232     %(nfail_deltafinal)d\t big deltas during final iteration
00233     %(nfail_lowstat)d\t low statistics (or big deltax.error)
00234     %(nfail_nsigma)d\t |x_final - x_initial| < nsigma
00235 """ % vars()


Variable Documentation

string motionPolicyChamber::action = "store_true"

Definition at line 47 of file motionPolicyChamber.py.

Definition at line 10 of file motionPolicyChamber.py.

list motionPolicyChamber::copyargs = sys.argv[:]

Definition at line 6 of file motionPolicyChamber.py.

Definition at line 42 of file motionPolicyChamber.py.

string motionPolicyChamber::dest = "nsigma"

Definition at line 43 of file motionPolicyChamber.py.

Definition at line 67 of file motionPolicyChamber.py.

Definition at line 66 of file motionPolicyChamber.py.

tuple motionPolicyChamber::geom0 = MuonGeometry(file(theInXML0))

Definition at line 81 of file motionPolicyChamber.py.

tuple motionPolicyChamber::geomN = MuonGeometry(file(theInXMLN))

Definition at line 82 of file motionPolicyChamber.py.

string motionPolicyChamber::help = "optional minimum nsigma(deltax) position displacement in order to move a chamber; default NSIGMA=3"

Definition at line 40 of file motionPolicyChamber.py.

tuple motionPolicyChamber::parser = optparse.OptionParser(usage)

Definition at line 37 of file motionPolicyChamber.py.

list motionPolicyChamber::prog = sys.argv[0]

Definition at line 13 of file motionPolicyChamber.py.

list motionPolicyChamber::theInREPN = sys.argv[3]

Definition at line 61 of file motionPolicyChamber.py.

list motionPolicyChamber::theInXML0 = sys.argv[1]

Definition at line 59 of file motionPolicyChamber.py.

list motionPolicyChamber::theInXMLN = sys.argv[2]

Definition at line 60 of file motionPolicyChamber.py.

Definition at line 64 of file motionPolicyChamber.py.

list motionPolicyChamber::theOutXML = sys.argv[4]

Definition at line 62 of file motionPolicyChamber.py.

string motionPolicyChamber::type = "int"

Definition at line 41 of file motionPolicyChamber.py.

Initial value:
00001 """%(prog)s INPUT_XML_0  INPUT_XML_N  INPUT_REPORT_N  OUTPUT_XML  [--nsigma NSIGMA] [--dt] [--csc]
00002 
00003 Required arguments:
00004 
00005 INPUT_XML_0      is xml file name with chamber positions from the initial (iteration 0) geometry
00006 INPUT_XML_N      is xml file name with chamber positions from the last iteration's geometry
00007 INPUT_REPORT_N   is a _report.py file from the last iteration
00008 OUTPUT_XML       is the resulting .xml file
00009 
00010 Options:
00011 
00012 --nsigma NSIGMA  optional minimum position displacement (measured in nsigma of deltax) in order to move a chamber
00013                  default NSIGMA=3
00014 --dt             if present, DT chambers will be included
00015 --csc            if present, CSC chambers will be included
00016                  NOTE: By default, having no --dt or --csc specified is equivalent to "--dt --csc"
00017 """

Definition at line 15 of file motionPolicyChamber.py.