CMS 3D CMS Logo

Functions | Variables
motionPolicyChamber Namespace Reference

Functions

def loopover (muSystem)
 

Variables

 action
 
 args
 
string commandline = " "
 
 copyargs = sys.argv[:]
 
 default
 
 dest
 
bool DO_CSC = False
 
bool DO_DT = False
 
 geom0 = MuonGeometry(file(theInXML0))
 
 geomN = MuonGeometry(file(theInXMLN))
 
 help
 
 options
 
 parser = optparse.OptionParser(usage)
 
 prog = sys.argv[0]
 
 theInREPN = sys.argv[3]
 
 theInXML0 = sys.argv[1]
 
 theInXMLN = sys.argv[2]
 
 theNSigma = options.nsigma
 
 theOutXML = sys.argv[4]
 
 type
 
string usage
 

Function Documentation

def motionPolicyChamber.loopover (   muSystem)

Definition at line 86 of file motionPolicyChamber.py.

References funct.abs(), FrontierConditions_GlobalTag_cff.file, createfilelist.int, and str.

86 def loopover(muSystem):
87 
88  movedChamberKeys = []
89 
90  if muSystem == "DT":
91  keys = geom0.dt.keys()
92  keys.sort(dtorder)
93  elif muSystem == "CSC":
94  keys = geom0.csc.keys()
95  keys.sort(cscorder)
96  else: raise Exception
97 
98  nkeys, nkeysr, nkeyspass, nmoved, nnotmoved = 0,0,0,0,0
99  nfail_toideal, nfail_deltafinal, nfail_lowstat, nfail_nsigma = 0,0,0,0
100  nok_toideal, nok_deltafinal, nok_lowstat, nok_nsigma = 0,0,0,0
101 
102  for key in keys:
103  is_ch = True
104  if muSystem == "DT":
105  if len(key) != 3: is_ch = False
106  ch_key = key[:3]
107  g1 = geom0.dt[key]
108  g2 = geomN.dt[key]
109  ch_g1 = geom0.dt[ch_key]
110  ch_g2 = geomN.dt[ch_key]
111  else:
112  if len(key) != 4: is_ch = False
113  ch_key = key[:4]
114  g1 = geom0.csc[key]
115  g2 = geomN.csc[key]
116  ch_g1 = geom0.csc[ch_key]
117  ch_g2 = geomN.csc[ch_key]
118  if is_ch: nkeys+=1
119 
120  chWasntMoved = True
121  if ch_key in movedChamberKeys:
122  chWasntMoved = False
123 
124  if g1.relativeto != g2.relativeto:
125  print "%s %s relativeto=\"%s\" versus relativeto=\"%s\"" % (muSystem, str(key), g1.relativeto, g2.relativeto)
126 
127  found = False
128  #r = reports[0]
129  for r in reports:
130  if r.postal_address[1:] == ch_key:
131  found = True
132  rep = r
133  break
134  if not found:
135  if is_ch: print muSystem, str(key), "not found in the report. Continue..."
136  continue
137  if is_ch: nkeysr+=1
138 
139  if rep.status != "PASS":
140  if is_ch: print muSystem, str(key), "status is not PASS: %s Continue..." % rep.status
141  continue
142  #print muSystem, str(key), str(ch_key)
143  if is_ch: nkeyspass+=1
144 
145  ############################################################
146  # CHECKS
147 
148  ok = True
149 
150  if muSystem == "DT" and chWasntMoved:
151 
152  # check that chamber's movement respective to ideal geometry is in reasonable range of 20 mm or 20 mrad:
153  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:
154  ok = False
155  if is_ch:
156  nfail_toideal += 1
157  print "Warning!!!", muSystem, str(key), \
158  "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)
159  if is_ch and ok: nok_toideal +=1
160 
161  # check that movements during the final iteration were negligible
162  # separately for station 4
163  if key[1] != 4 :
164  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:
165  ok = False
166  if is_ch:
167  nfail_deltafinal += 1
168  print "Warning!!!", muSystem, str(key), \
169  "moved too much at final iteration: dx=%.2f mm dy=%.2f mm dphiy=%.2f mrad dphiz=%.2f mrad skipping..." % \
170  (rep.deltax.value*10, rep.deltay.value*10, rep.deltaphiy.value*1000, rep.deltaphiz.value*1000)
171  else:
172  if abs(rep.deltax.value) > 0.03 or abs(rep.deltaphiy.value) > 0.0003 or abs(rep.deltaphiz.value) > 0.0006:
173  ok = False
174  if is_ch:
175  nfail_deltafinal += 1
176  print "Warning!!!", muSystem, str(key), \
177  "moved too much at final iteration: dx=%.2f mm dphiy=%.2f mrad dphiz=%.2f mrad skipping..." % \
178  (rep.deltax.value*10, rep.deltaphiy.value*1000, rep.deltaphiz.value*1000)
179  if is_ch and ok: nok_deltafinal +=1
180 
181  # low statictics check:
182  if rep.deltax.error > 0.5:
183  ok = False
184  if is_ch:
185  nfail_lowstat +=1
186  print "Warning!!!", muSystem, str(key), "low statistics chamber with too big dx.error = %.2f mm skipping..." % (rep.deltax.error*10.)
187  if is_ch and ok: nok_lowstat +=1
188 
189  # N-SIGMA MOTION POLICY CHECK
190  #print "%s %s position difference: %g - %g = %g --> %g, nsigma: %g)" % (
191  # muSystem, str(key), g1.x, g2.x, g1.x - g2.x, abs(g1.x - g2.x)/rep.deltax.error, theNSigma * rep.deltax.error)
192  if abs(ch_g1.x - ch_g2.x) < theNSigma * math.sqrt ( rep.deltax.error*rep.deltax.error + 0.02*0.02 ) :
193  ok = False
194  if is_ch:
195  nfail_nsigma += 1
196  print muSystem, str(key), "not moved: xN-x0 = %.3f - %.3f = %.3f < %.3f mm" % \
197  ( 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.)
198 
199  if ok: chWasntMoved = False
200 
201  if not ok or chWasntMoved: continue
202 
203  ############################################################
204  # MOTION
205  if is_ch:
206  movedChamberKeys.append(ch_key)
207  print muSystem, str(key), "moved!"
208  nmoved+=1
209  #move this chamber/superlayer/layer:
210  if muSystem == "DT":
211  geom0.dt[key] = copy.copy(geomN.dt[key])
212  else:
213  geom0.csc[key] = copy.copy(geomN.csc[key])
214 
215  nnotmoved = nkeys - nmoved
216  nsig = int(theNSigma)
217  print """
218 %(muSystem)s REPORT for %(nsig)d sigma policy:
219 Cumulative counters:
220  %(nkeys)d\t chambers in geometry
221  %(nkeysr)d\t chambers in report
222  %(nkeyspass)d\t have PASS status
223  %(nok_toideal)d\t pass big shift with respect to ideal check
224  %(nok_deltafinal)d\t pass big deltas during final iteration
225  %(nok_lowstat)d\t pass low statistics (or big deltax.error) check
226  %(nmoved)d\t moved
227 Not moved counters:
228  %(nnotmoved)d\t chambers not moved
229  Numbers of chambers were not moved due to:
230  %(nfail_toideal)d\t big shift with respect to ideal
231  %(nfail_deltafinal)d\t big deltas during final iteration
232  %(nfail_lowstat)d\t low statistics (or big deltax.error)
233  %(nfail_nsigma)d\t |x_final - x_initial| < nsigma
234 """ % vars()
235 
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define str(s)

Variable Documentation

motionPolicyChamber.action

Definition at line 47 of file motionPolicyChamber.py.

motionPolicyChamber.args

Definition at line 57 of file motionPolicyChamber.py.

string motionPolicyChamber.commandline = " "

Definition at line 10 of file motionPolicyChamber.py.

motionPolicyChamber.copyargs = sys.argv[:]

Definition at line 6 of file motionPolicyChamber.py.

motionPolicyChamber.default

Definition at line 42 of file motionPolicyChamber.py.

motionPolicyChamber.dest

Definition at line 43 of file motionPolicyChamber.py.

bool motionPolicyChamber.DO_CSC = False

Definition at line 67 of file motionPolicyChamber.py.

bool motionPolicyChamber.DO_DT = False

Definition at line 66 of file motionPolicyChamber.py.

motionPolicyChamber.geom0 = MuonGeometry(file(theInXML0))
motionPolicyChamber.geomN = MuonGeometry(file(theInXMLN))

Definition at line 82 of file motionPolicyChamber.py.

motionPolicyChamber.help

Definition at line 40 of file motionPolicyChamber.py.

motionPolicyChamber.options

Definition at line 57 of file motionPolicyChamber.py.

motionPolicyChamber.parser = optparse.OptionParser(usage)

Definition at line 37 of file motionPolicyChamber.py.

motionPolicyChamber.prog = sys.argv[0]

Definition at line 13 of file motionPolicyChamber.py.

motionPolicyChamber.theInREPN = sys.argv[3]

Definition at line 61 of file motionPolicyChamber.py.

motionPolicyChamber.theInXML0 = sys.argv[1]

Definition at line 59 of file motionPolicyChamber.py.

motionPolicyChamber.theInXMLN = sys.argv[2]

Definition at line 60 of file motionPolicyChamber.py.

motionPolicyChamber.theNSigma = options.nsigma

Definition at line 64 of file motionPolicyChamber.py.

motionPolicyChamber.theOutXML = sys.argv[4]

Definition at line 62 of file motionPolicyChamber.py.

motionPolicyChamber.type

Definition at line 41 of file motionPolicyChamber.py.

string motionPolicyChamber.usage
Initial value:
1 = """%(prog)s INPUT_XML_0 INPUT_XML_N INPUT_REPORT_N OUTPUT_XML [--nsigma NSIGMA] [--dt] [--csc]
2 
3 Required arguments:
4 
5 INPUT_XML_0 is xml file name with chamber positions from the initial (iteration 0) geometry
6 INPUT_XML_N is xml file name with chamber positions from the last iteration's geometry
7 INPUT_REPORT_N is a _report.py file from the last iteration
8 OUTPUT_XML is the resulting .xml file
9 
10 Options:
11 
12 --nsigma NSIGMA optional minimum position displacement (measured in nsigma of deltax) in order to move a chamber
13  default NSIGMA=3
14 --dt if present, DT chambers will be included
15 --csc if present, CSC chambers will be included
16  NOTE: By default, having no --dt or --csc specified is equivalent to "--dt --csc"
17 """

Definition at line 15 of file motionPolicyChamber.py.