CMS 3D CMS Logo

Functions | Variables
motionPolicyChamber Namespace Reference

Functions

def loopover (muSystem)
 

Variables

 action
 
 args
 
string commandline = " ".join(copyargs)
 
 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

◆ loopover()

def motionPolicyChamber.loopover (   muSystem)

Definition at line 88 of file motionPolicyChamber.py.

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

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

Variable Documentation

◆ action

motionPolicyChamber.action

Definition at line 49 of file motionPolicyChamber.py.

◆ args

motionPolicyChamber.args

Definition at line 59 of file motionPolicyChamber.py.

◆ commandline

string motionPolicyChamber.commandline = " ".join(copyargs)

Definition at line 12 of file motionPolicyChamber.py.

◆ copyargs

motionPolicyChamber.copyargs = sys.argv[:]

Definition at line 8 of file motionPolicyChamber.py.

◆ default

motionPolicyChamber.default

Definition at line 44 of file motionPolicyChamber.py.

◆ dest

motionPolicyChamber.dest

Definition at line 45 of file motionPolicyChamber.py.

◆ DO_CSC

bool motionPolicyChamber.DO_CSC = False

Definition at line 69 of file motionPolicyChamber.py.

◆ DO_DT

bool motionPolicyChamber.DO_DT = False

Definition at line 68 of file motionPolicyChamber.py.

◆ geom0

motionPolicyChamber.geom0 = MuonGeometry(file(theInXML0))

◆ geomN

motionPolicyChamber.geomN = MuonGeometry(file(theInXMLN))

Definition at line 84 of file motionPolicyChamber.py.

◆ help

motionPolicyChamber.help

Definition at line 42 of file motionPolicyChamber.py.

◆ options

motionPolicyChamber.options

Definition at line 59 of file motionPolicyChamber.py.

◆ parser

motionPolicyChamber.parser = optparse.OptionParser(usage)

Definition at line 39 of file motionPolicyChamber.py.

◆ prog

motionPolicyChamber.prog = sys.argv[0]

Definition at line 15 of file motionPolicyChamber.py.

◆ theInREPN

motionPolicyChamber.theInREPN = sys.argv[3]

Definition at line 63 of file motionPolicyChamber.py.

◆ theInXML0

motionPolicyChamber.theInXML0 = sys.argv[1]

Definition at line 61 of file motionPolicyChamber.py.

◆ theInXMLN

motionPolicyChamber.theInXMLN = sys.argv[2]

Definition at line 62 of file motionPolicyChamber.py.

◆ theNSigma

motionPolicyChamber.theNSigma = options.nsigma

Definition at line 66 of file motionPolicyChamber.py.

◆ theOutXML

motionPolicyChamber.theOutXML = sys.argv[4]

Definition at line 64 of file motionPolicyChamber.py.

◆ type

motionPolicyChamber.type

Definition at line 43 of file motionPolicyChamber.py.

◆ usage

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 """ % vars()

Definition at line 17 of file motionPolicyChamber.py.

str
#define str(s)
Definition: TestProcessor.cc:52
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
createfilelist.int
int
Definition: createfilelist.py:10
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
motionPolicyChamber.loopover
def loopover(muSystem)
Definition: motionPolicyChamber.py:88