CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 88 of file motionPolicyChamber.py.

References funct.abs(), mergeVDriftHistosByStation.file, print(), and str.

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

Variable Documentation

string motionPolicyChamber.action = "store_true"

Definition at line 49 of file motionPolicyChamber.py.

string motionPolicyChamber.commandline = " "

Definition at line 12 of file motionPolicyChamber.py.

list motionPolicyChamber.copyargs = sys.argv[:]

Definition at line 8 of file motionPolicyChamber.py.

motionPolicyChamber.default = 2

Definition at line 44 of file motionPolicyChamber.py.

string motionPolicyChamber.dest = "nsigma"

Definition at line 45 of file motionPolicyChamber.py.

motionPolicyChamber.DO_CSC = False

Definition at line 69 of file motionPolicyChamber.py.

motionPolicyChamber.DO_DT = False

Definition at line 68 of file motionPolicyChamber.py.

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

Definition at line 83 of file motionPolicyChamber.py.

Referenced by HGCalRecHitValidation.analyze(), and HGCalDigiValidation.analyze().

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

Definition at line 84 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 42 of file motionPolicyChamber.py.

tuple motionPolicyChamber.parser = optparse.OptionParser(usage)

Definition at line 39 of file motionPolicyChamber.py.

list motionPolicyChamber.prog = sys.argv[0]

Definition at line 15 of file motionPolicyChamber.py.

list motionPolicyChamber.theInREPN = sys.argv[3]

Definition at line 63 of file motionPolicyChamber.py.

list motionPolicyChamber.theInXML0 = sys.argv[1]

Definition at line 61 of file motionPolicyChamber.py.

list motionPolicyChamber.theInXMLN = sys.argv[2]

Definition at line 62 of file motionPolicyChamber.py.

motionPolicyChamber.theNSigma = options.nsigma

Definition at line 66 of file motionPolicyChamber.py.

list motionPolicyChamber.theOutXML = sys.argv[4]

Definition at line 64 of file motionPolicyChamber.py.

string motionPolicyChamber.type = "int"

Definition at line 43 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 17 of file motionPolicyChamber.py.