Public Member Functions | Public Attributes | List of all members
Optimizations.Optimization Class Reference

Public Member Functions

def __init__ (self, optimizationName)
 
def getEnergy (self, iteration, mode)
 
def getNominalFitness (self, type="cp")
 
def getLastGoodConfig (self)
 
def getFitness (self, iteration, type="cp")
 
def createRouletteWheel (self, start_iter, stop_iter)
 
def drawRouletteWheel (self)
 
def pickRandomParent (self)
 
def getKnobturns (self)
 
def twoPointCrossover (self)
 
def mutate (self, chromosome)
 
def populateMacros (self, low_iter, high_iter)
 
def getParameterIndex (self, parameter_name)
 
def getParameterValue (self, parameter_name, iteration)
 
def readVariationFromMacros (self, iteration)
 
def readVariationsFromMacros (self)
 

Public Attributes

 optname
 
 parameter_names
 
 parameter_units
 
 parameter_lower_limits
 
 parameter_upper_limits
 
 macro_commands
 
 macro_set_stages
 
 roulette_wheel
 
 roulette_wheel_start_iter
 
 roulette_wheel_stop_iter
 
 knobturns
 
 physics_list
 
 detector_location_name
 
 g4lbne_version
 
 seed_offset
 
 output_location
 
 last_completed_config_file
 
 generation_size
 
 rhc_parameters_float_separate
 
 h_nom_fhcnumu
 
 h_nom_fhcnumubar
 
 h_nom_rhcnumu
 
 h_nom_rhcnumubar
 

Detailed Description

Definition at line 6 of file Optimizations.py.

Constructor & Destructor Documentation

def Optimizations.Optimization.__init__ (   self,
  optimizationName 
)

Definition at line 8 of file Optimizations.py.

8  def __init__(self,optimizationName):
9 
10  if not optimizationName in ["CP_run5","CP_run7","CP_run8","CP_run9","CP_run10","CP_run11","CP_run12","CP_run13","CP_run14","CP_run15","CP_run16","CP_run17","CP_run18","CP_run19","CP_run20","CP_run21","CP_run22","CP_run23","CP_run24","CP_run25","CP_run26","CP_run27","CP_run28","CP_run29","CP_run30","CP_run31","CP_realistic1","LE_run1","LE_run2","HE_run1"]:
11  print "I don't recognize the optimization name:",optimizationName
12  sys.exit()
13 
14  self.optname = optimizationName
15  self.parameter_names = []
16  self.parameter_units = []
19  self.macro_commands = []
20  self.macro_set_stages = []
21  self.roulette_wheel = []
24  self.knobturns = []
25 
26  self.physics_list = "QGSP_BERT"
27  if self.optname in ["CP_run8"]:
28  self.physics_list = "FTFP_BERT"
29 
30  self.detector_location_name = "LBNEFD"
31  if self.optname in ["CP_run5"]:
32  self.g4lbne_version = "v3r3p5"
33  elif self.optname in ["CP_run7"]:
34  self.g4lbne_version = "v3r3p9"
35  elif self.optname in ["CP_run8"]:
36  self.g4lbne_version = "v3r3p8"
37  elif self.optname in ["CP_run9","CP_run10","CP_run11","CP_run12","CP_run13","CP_run14"]:
38  self.g4lbne_version = "v3r3p9"
39 # elif self.optname in ["CP_run15","CP_run16","CP_run17"]:
40  elif self.optname in ["CP_run15","CP_run16"]:
41  self.g4lbne_version = "v3r4"
42 # elif self.optname in ["CP_run18","CP_run19","CP_run20","CP_run21","CP_run22","CP_run23","CP_run24"]:
43 # elif self.optname in ["CP_run15","CP_run17","CP_run18","CP_run19","CP_run20","CP_run21","CP_run22","CP_run23","CP_run24"]:
44  elif self.optname in ["CP_run18","CP_run19","CP_run20","CP_run21","CP_run22","CP_run23","CP_run24"]:
45  self.g4lbne_version = "v3r4p1"
46  elif self.optname in ["CP_run17","CP_run25","CP_run27"]:
47  self.g4lbne_version = "v3r4p2"
48  elif self.optname in ["CP_run28","CP_run29","CP_run30","CP_run31","LE_run1","LE_run2","HE_run1","CP_run26"]:
49  self.g4lbne_version = "v3r4p3"
50  elif self.optname in ["CP_realistic1"]:
51  self.g4lbne_version = "v3r5p1b"
52 
53  # I used to set this differently for every optimization, but I don't think there is any practical reason to do that
54  self.seed_offset = 4949499
55 
56  self.output_location = "/dune/data2/"
57  if self.optname in ["CP_run5"]:
58  self.output_location = "/dune/data/"
59 
60  self.last_completed_config_file = "/dune/data/users/ljf26/Optimizations/"+self.optname+"_last_completed_config.dat"
61 
62  self.generation_size = 100
63 
65  if(self.optname=="CP_run4" or self.optname=="CP_run7" or self.optname=="CP_run8"):
67 
68  # Two horn -- this one produced the one in the CDR
69  if(optimizationName=="CP_run5"):
70 
71  self.parameter_names.append("Horn1ICRadius1")
72  self.parameter_units.append("mm")
73  self.parameter_lower_limits.append(20)
74  self.parameter_upper_limits.append(50)
75  self.macro_commands.append("#Horn1ICRadius1")
76  self.macro_set_stages.append("PreInit")
77 
78  self.parameter_names.append("Horn1ICRadius2")
79  self.parameter_units.append("mm")
80  self.parameter_lower_limits.append(35)
81  self.parameter_upper_limits.append(200)
82  self.macro_commands.append("#Horn1ICRadius2")
83  self.macro_set_stages.append("PreInit")
84 
85  self.parameter_names.append("Horn1ICRadius3")
86  self.parameter_units.append("mm")
87  self.parameter_lower_limits.append(20)
88  self.parameter_upper_limits.append(75)
89  self.macro_commands.append("#Horn1ICRadius3")
90  self.macro_set_stages.append("PreInit")
91 
92  self.parameter_names.append("Horn1ICRadius4")
93  self.parameter_units.append("mm")
94  self.parameter_lower_limits.append(20)
95  self.parameter_upper_limits.append(200)
96  self.macro_commands.append("#Horn1ICRadius4")
97  self.macro_set_stages.append("PreInit")
98 
99  self.parameter_names.append("Horn1OCRadius")
100  self.parameter_units.append("mm")
101  self.parameter_lower_limits.append(200)
102  self.parameter_upper_limits.append(800)
103  self.macro_commands.append("#Horn1OCRadius")
104  self.macro_set_stages.append("PreInit")
105 
106  self.parameter_names.append("Horn1ICLength1")
107  self.parameter_units.append("mm")
108  self.parameter_lower_limits.append(800)
109  self.parameter_upper_limits.append(2500)
110  self.macro_commands.append("#Horn1ICLength1")
111  self.macro_set_stages.append("PreInit")
112 
113  self.parameter_names.append("Horn1ICLength2")
114  self.parameter_units.append("mm")
115  self.parameter_lower_limits.append(50)
116  self.parameter_upper_limits.append(1000)
117  self.macro_commands.append("#Horn1ICLength2")
118  self.macro_set_stages.append("PreInit")
119 
120  self.parameter_names.append("Horn1ICLength3")
121  self.parameter_units.append("mm")
122  self.parameter_lower_limits.append(50)
123  self.parameter_upper_limits.append(1000)
124  self.macro_commands.append("#Horn1ICLength3")
125  self.macro_set_stages.append("PreInit")
126 
127  self.parameter_names.append("Horn1ICLength4")
128  self.parameter_units.append("mm")
129  self.parameter_lower_limits.append(50)
130  self.parameter_upper_limits.append(1000)
131  self.macro_commands.append("#Horn1ICLength4")
132  self.macro_set_stages.append("PreInit")
133 
134  self.parameter_names.append("Horn1ICLength5")
135  self.parameter_units.append("mm")
136  self.parameter_lower_limits.append(50)
137  self.parameter_upper_limits.append(1000)
138  self.macro_commands.append("#Horn1ICLength5")
139  self.macro_set_stages.append("PreInit")
140 
141  self.parameter_names.append("Horn1ICLength6")
142  self.parameter_units.append("mm")
143  self.parameter_lower_limits.append(50)
144  self.parameter_upper_limits.append(1000)
145  self.macro_commands.append("#Horn1ICLength6")
146  self.macro_set_stages.append("PreInit")
147 
148  self.parameter_names.append("Horn1ICLength7")
149  self.parameter_units.append("mm")
150  self.parameter_lower_limits.append(50)
151  self.parameter_upper_limits.append(1000)
152  self.macro_commands.append("#Horn1ICLength7")
153  self.macro_set_stages.append("PreInit")
154 
155  self.parameter_names.append("Horn2LongRescale")
156  self.parameter_units.append("");
157  self.parameter_lower_limits.append(0.5);
158  self.parameter_upper_limits.append(2);
159  self.macro_commands.append("/LBNE/det/Horn2LongRescale");
160  self.macro_set_stages.append("PreInit")
161 
162  self.parameter_names.append("Horn2RadialRescale")
163  self.parameter_units.append("");
164  self.parameter_lower_limits.append(0.5);
165  self.parameter_upper_limits.append(2);
166  self.macro_commands.append("/LBNE/det/Horn2RadialRescale");
167  self.macro_set_stages.append("PreInit")
168 
169  self.parameter_names.append("FHCHorn2RadialRescaleCst")
170  self.parameter_units.append("mm");
171  self.parameter_lower_limits.append(-78);
172  self.parameter_upper_limits.append(100);
173  self.macro_commands.append("/LBNE/det/Horn2RadialRescaleCst");
174  self.macro_set_stages.append("PreInit")
175 
176  self.parameter_names.append("Horn2LongPosition")
177  self.parameter_units.append("m");
178  self.parameter_lower_limits.append(3.0);
179  self.parameter_upper_limits.append(15.0);
180  self.macro_commands.append("/LBNE/det/Horn2LongPosition");
181  self.macro_set_stages.append("PreInit")
182 
183  self.parameter_names.append("GraphiteTargetLength")
184  self.parameter_units.append("m");
185  self.parameter_lower_limits.append(0.5);
186  self.parameter_upper_limits.append(1.75);
187  self.macro_commands.append("/LBNE/det/GraphiteTargetLength");
188  self.macro_set_stages.append("PreInit")
189 
190  self.parameter_names.append("GraphiteTargetFinWidth")
191  self.parameter_units.append("mm");
192  self.parameter_lower_limits.append(9);
193  self.parameter_upper_limits.append(15);
194  self.macro_commands.append("/LBNE/det/GraphiteTargetFinWidth");
195  self.macro_set_stages.append("PreInit")
196 
197  self.parameter_names.append("HornCurrent")
198  self.parameter_units.append("kA");
199  self.parameter_lower_limits.append(200);
200  self.parameter_upper_limits.append(300);
201  self.macro_commands.append("/LBNE/det/seHornCurrent")
202  self.macro_set_stages.append("PreInit")
203 
204  self.parameter_names.append("ProtonEnergy")
205  self.parameter_units.append("GeV");
206  self.parameter_lower_limits.append(60);
207  self.parameter_upper_limits.append(130);
208  self.macro_commands.append("/LBNE/primary/protonMomentum")
209  self.macro_set_stages.append("Idle")
210 
211  self.parameter_names.append("OffAxisAngle")
212  self.parameter_units.append("mrad");
213  self.parameter_lower_limits.append(0);
214  self.parameter_upper_limits.append(15);
215  self.macro_commands.append("#OffAxisAngle")
216  self.macro_set_stages.append("PreInit")
217 
218  # CP_run15 was first successful 3 horn optimization
219  # CP_run19 is same, but with parabolic horns
220  if(optimizationName=="CP_run15" or optimizationName=="CP_run19"):
221 
222  self.parameter_names.append("HornALength")
223  self.parameter_units.append("mm")
224  self.parameter_lower_limits.append(1000)
225  self.parameter_upper_limits.append(4500)
226  self.macro_commands.append("#HornALength")
227  self.macro_set_stages.append("PreInit")
228 
229  self.parameter_names.append("HornAF1")
230  self.parameter_units.append("")
231  self.parameter_lower_limits.append(0.01)
232  self.parameter_upper_limits.append(0.99)
233  self.macro_commands.append("#HornAF1")
234  self.macro_set_stages.append("PreInit")
235 
236  self.parameter_names.append("HornARadius1")
237  self.parameter_units.append("mm")
238  self.parameter_lower_limits.append(20)
239  self.parameter_upper_limits.append(50)
240  self.macro_commands.append("#HornARadius1")
241  self.macro_set_stages.append("PreInit")
242 
243  self.parameter_names.append("HornARadius2")
244  self.parameter_units.append("mm")
245  self.parameter_lower_limits.append(20)
246  self.parameter_upper_limits.append(200)
247  self.macro_commands.append("#HornARadius2")
248  self.macro_set_stages.append("PreInit")
249 
250  self.parameter_names.append("HornARadiusOC")
251  self.parameter_units.append("mm")
252  self.parameter_lower_limits.append(200)
253  self.parameter_upper_limits.append(650)
254  self.macro_commands.append("#HornARadiusOC")
255  self.macro_set_stages.append("PreInit")
256 
257  self.parameter_names.append("HornBLength")
258  self.parameter_units.append("mm")
259  self.parameter_lower_limits.append(2000)
260  self.parameter_upper_limits.append(4500)
261  self.macro_commands.append("#HornBLength")
262  self.macro_set_stages.append("PreInit")
263 
264  self.parameter_names.append("HornBF1")
265  self.parameter_units.append("")
266  self.parameter_lower_limits.append(0)
267  self.parameter_upper_limits.append(1)
268  self.macro_commands.append("#HornBF1")
269  self.macro_set_stages.append("PreInit")
270 
271  self.parameter_names.append("HornBF2")
272  self.parameter_units.append("")
273  self.parameter_lower_limits.append(0)
274  self.parameter_upper_limits.append(1)
275  self.macro_commands.append("#HornBF2")
276  self.macro_set_stages.append("PreInit")
277 
278  self.parameter_names.append("HornBF3")
279  self.parameter_units.append("")
280  self.parameter_lower_limits.append(0)
281  self.parameter_upper_limits.append(1)
282  self.macro_commands.append("#HornBF3")
283  self.macro_set_stages.append("PreInit")
284 
285  self.parameter_names.append("HornBF4")
286  self.parameter_units.append("")
287  self.parameter_lower_limits.append(0)
288  self.parameter_upper_limits.append(1)
289  self.macro_commands.append("#HornBF4")
290  self.macro_set_stages.append("PreInit")
291 
292  self.parameter_names.append("HornBF5")
293  self.parameter_units.append("")
294  self.parameter_lower_limits.append(0)
295  self.parameter_upper_limits.append(1)
296  self.macro_commands.append("#HornBF5")
297  self.macro_set_stages.append("PreInit")
298 
299  self.parameter_names.append("HornBRadius1")
300  self.parameter_units.append("mm")
301  self.parameter_lower_limits.append(50)
302  self.parameter_upper_limits.append(200)
303  self.macro_commands.append("#HornBRadius1")
304  self.macro_set_stages.append("PreInit")
305 
306  self.parameter_names.append("HornBRadius2")
307  self.parameter_units.append("mm")
308  self.parameter_lower_limits.append(20)
309  self.parameter_upper_limits.append(150)
310  self.macro_commands.append("#HornBRadius2")
311  self.macro_set_stages.append("PreInit")
312 
313  self.parameter_names.append("HornBRadius3")
314  self.parameter_units.append("mm")
315  self.parameter_lower_limits.append(50)
316  self.parameter_upper_limits.append(550)
317  self.macro_commands.append("#HornBRadius3")
318  self.macro_set_stages.append("PreInit")
319 
320  self.parameter_names.append("HornBRadiusOC")
321  self.parameter_units.append("mm")
322  self.parameter_lower_limits.append(550)
323  self.parameter_upper_limits.append(650)
324  self.macro_commands.append("#HornBRadiusOC")
325  self.macro_set_stages.append("PreInit")
326 
327  self.parameter_names.append("HornBLongPosition")
328  self.parameter_units.append("mm")
329  self.parameter_lower_limits.append(2000)
330  self.parameter_upper_limits.append(17000)
331  self.macro_commands.append("#HornBLongPosition")
332  self.macro_set_stages.append("PreInit")
333 
334  self.parameter_names.append("HornCLength")
335  self.parameter_units.append("mm")
336  self.parameter_lower_limits.append(2000)
337  self.parameter_upper_limits.append(4500)
338  self.macro_commands.append("#HornCLength")
339  self.macro_set_stages.append("PreInit")
340 
341  self.parameter_names.append("HornCF1")
342  self.parameter_units.append("")
343  self.parameter_lower_limits.append(0)
344  self.parameter_upper_limits.append(1)
345  self.macro_commands.append("#HornCF1")
346  self.macro_set_stages.append("PreInit")
347 
348  self.parameter_names.append("HornCF2")
349  self.parameter_units.append("")
350  self.parameter_lower_limits.append(0)
351  self.parameter_upper_limits.append(1)
352  self.macro_commands.append("#HornCF2")
353  self.macro_set_stages.append("PreInit")
354 
355  self.parameter_names.append("HornCF3")
356  self.parameter_units.append("")
357  self.parameter_lower_limits.append(0)
358  self.parameter_upper_limits.append(1)
359  self.macro_commands.append("#HornCF3")
360  self.macro_set_stages.append("PreInit")
361 
362  self.parameter_names.append("HornCF4")
363  self.parameter_units.append("")
364  self.parameter_lower_limits.append(0)
365  self.parameter_upper_limits.append(1)
366  self.macro_commands.append("#HornCF4")
367  self.macro_set_stages.append("PreInit")
368 
369  self.parameter_names.append("HornCF5")
370  self.parameter_units.append("")
371  self.parameter_lower_limits.append(0)
372  self.parameter_upper_limits.append(1)
373  self.macro_commands.append("#HornCF5")
374  self.macro_set_stages.append("PreInit")
375 
376  self.parameter_names.append("HornCRadius1")
377  self.parameter_units.append("mm")
378  self.parameter_lower_limits.append(150)
379  self.parameter_upper_limits.append(550)
380  self.macro_commands.append("#HornCRadius1")
381  self.macro_set_stages.append("PreInit")
382 
383  self.parameter_names.append("HornCRadius2")
384  self.parameter_units.append("mm")
385  self.parameter_lower_limits.append(20)
386  self.parameter_upper_limits.append(300)
387  self.macro_commands.append("#HornCRadius2")
388  self.macro_set_stages.append("PreInit")
389 
390  self.parameter_names.append("HornCRadius3")
391  self.parameter_units.append("mm")
392  self.parameter_lower_limits.append(50)
393  self.parameter_upper_limits.append(550)
394  self.macro_commands.append("#HornCRadius3")
395  self.macro_set_stages.append("PreInit")
396 
397  self.parameter_names.append("HornCRadiusOC")
398  self.parameter_units.append("mm")
399  self.parameter_lower_limits.append(550)
400  self.parameter_upper_limits.append(650)
401  self.macro_commands.append("#HornCRadiusOC")
402  self.macro_set_stages.append("PreInit")
403 
404  self.parameter_names.append("HornCLongPosition")
405  self.parameter_units.append("mm")
406  self.parameter_lower_limits.append(4000)
407  self.parameter_upper_limits.append(19000)
408  self.macro_commands.append("#HornCLongPosition")
409  self.macro_set_stages.append("PreInit")
410 
411  self.parameter_names.append("GraphiteTargetLength")
412  self.parameter_units.append("m");
413  self.parameter_lower_limits.append(0.5);
414  self.parameter_upper_limits.append(2.0);
415  self.macro_commands.append("/LBNE/det/GraphiteTargetLength");
416  self.macro_set_stages.append("PreInit")
417 
418  self.parameter_names.append("GraphiteTargetFinWidth")
419  self.parameter_units.append("mm");
420  self.parameter_lower_limits.append(9);
421  self.parameter_upper_limits.append(15);
422  self.macro_commands.append("/LBNE/det/GraphiteTargetFinWidth");
423  self.macro_set_stages.append("PreInit")
424 
425  self.parameter_names.append("BeamSigma")
426  self.parameter_units.append("mm");
427  self.parameter_lower_limits.append(1.6);
428  self.parameter_upper_limits.append(2.5);
429  self.macro_commands.append("/LBNE/generator/beamSigmaX");
430  self.macro_set_stages.append("Idle")
431 
432  self.parameter_names.append("HornCurrent")
433  self.parameter_units.append("kA");
434  self.parameter_lower_limits.append(150);
435  self.parameter_upper_limits.append(300);
436  self.macro_commands.append("/LBNE/det/seHornCurrent")
437  self.macro_set_stages.append("PreInit")
438 
439  self.parameter_names.append("ProtonEnergy")
440  self.parameter_units.append("GeV");
441  self.parameter_lower_limits.append(40);
442  self.parameter_upper_limits.append(130);
443  self.macro_commands.append("/LBNE/primary/protonMomentum")
444  self.macro_set_stages.append("Idle")
445 
446  # Same as CP_run15 but with reduces engineering constraints
447  if(optimizationName=="CP_run20"):
448 
449  self.parameter_names.append("HornALength")
450  self.parameter_units.append("mm")
451  self.parameter_lower_limits.append(1000)
452  self.parameter_upper_limits.append(6000)
453  self.macro_commands.append("#HornALength")
454  self.macro_set_stages.append("PreInit")
455 
456  self.parameter_names.append("HornAF1")
457  self.parameter_units.append("")
458  self.parameter_lower_limits.append(0.01)
459  self.parameter_upper_limits.append(0.99)
460  self.macro_commands.append("#HornAF1")
461  self.macro_set_stages.append("PreInit")
462 
463  self.parameter_names.append("HornARadius1")
464  self.parameter_units.append("mm")
465  self.parameter_lower_limits.append(20)
466  self.parameter_upper_limits.append(50)
467  self.macro_commands.append("#HornARadius1")
468  self.macro_set_stages.append("PreInit")
469 
470  self.parameter_names.append("HornARadius2")
471  self.parameter_units.append("mm")
472  self.parameter_lower_limits.append(20)
473  self.parameter_upper_limits.append(200)
474  self.macro_commands.append("#HornARadius2")
475  self.macro_set_stages.append("PreInit")
476 
477  self.parameter_names.append("HornARadiusOC")
478  self.parameter_units.append("mm")
479  self.parameter_lower_limits.append(200)
480  self.parameter_upper_limits.append(1000)
481  self.macro_commands.append("#HornARadiusOC")
482  self.macro_set_stages.append("PreInit")
483 
484  self.parameter_names.append("HornBLength")
485  self.parameter_units.append("mm")
486  self.parameter_lower_limits.append(2000)
487  self.parameter_upper_limits.append(6000)
488  self.macro_commands.append("#HornBLength")
489  self.macro_set_stages.append("PreInit")
490 
491  self.parameter_names.append("HornBF1")
492  self.parameter_units.append("")
493  self.parameter_lower_limits.append(0)
494  self.parameter_upper_limits.append(1)
495  self.macro_commands.append("#HornBF1")
496  self.macro_set_stages.append("PreInit")
497 
498  self.parameter_names.append("HornBF2")
499  self.parameter_units.append("")
500  self.parameter_lower_limits.append(0)
501  self.parameter_upper_limits.append(1)
502  self.macro_commands.append("#HornBF2")
503  self.macro_set_stages.append("PreInit")
504 
505  self.parameter_names.append("HornBF3")
506  self.parameter_units.append("")
507  self.parameter_lower_limits.append(0)
508  self.parameter_upper_limits.append(1)
509  self.macro_commands.append("#HornBF3")
510  self.macro_set_stages.append("PreInit")
511 
512  self.parameter_names.append("HornBF4")
513  self.parameter_units.append("")
514  self.parameter_lower_limits.append(0)
515  self.parameter_upper_limits.append(1)
516  self.macro_commands.append("#HornBF4")
517  self.macro_set_stages.append("PreInit")
518 
519  self.parameter_names.append("HornBF5")
520  self.parameter_units.append("")
521  self.parameter_lower_limits.append(0)
522  self.parameter_upper_limits.append(1)
523  self.macro_commands.append("#HornBF5")
524  self.macro_set_stages.append("PreInit")
525 
526  self.parameter_names.append("HornBRadius1")
527  self.parameter_units.append("mm")
528  self.parameter_lower_limits.append(50)
529  self.parameter_upper_limits.append(200)
530  self.macro_commands.append("#HornBRadius1")
531  self.macro_set_stages.append("PreInit")
532 
533  self.parameter_names.append("HornBRadius2")
534  self.parameter_units.append("mm")
535  self.parameter_lower_limits.append(20)
536  self.parameter_upper_limits.append(150)
537  self.macro_commands.append("#HornBRadius2")
538  self.macro_set_stages.append("PreInit")
539 
540  self.parameter_names.append("HornBRadius3")
541  self.parameter_units.append("mm")
542  self.parameter_lower_limits.append(50)
543  self.parameter_upper_limits.append(550)
544  self.macro_commands.append("#HornBRadius3")
545  self.macro_set_stages.append("PreInit")
546 
547  self.parameter_names.append("HornBRadiusOC")
548  self.parameter_units.append("mm")
549  self.parameter_lower_limits.append(550)
550  self.parameter_upper_limits.append(1000)
551  self.macro_commands.append("#HornBRadiusOC")
552  self.macro_set_stages.append("PreInit")
553 
554  self.parameter_names.append("HornBLongPosition")
555  self.parameter_units.append("mm")
556  self.parameter_lower_limits.append(2000)
557  self.parameter_upper_limits.append(30000)
558  self.macro_commands.append("#HornBLongPosition")
559  self.macro_set_stages.append("PreInit")
560 
561  self.parameter_names.append("HornCLength")
562  self.parameter_units.append("mm")
563  self.parameter_lower_limits.append(2000)
564  self.parameter_upper_limits.append(6000)
565  self.macro_commands.append("#HornCLength")
566  self.macro_set_stages.append("PreInit")
567 
568  self.parameter_names.append("HornCF1")
569  self.parameter_units.append("")
570  self.parameter_lower_limits.append(0)
571  self.parameter_upper_limits.append(1)
572  self.macro_commands.append("#HornCF1")
573  self.macro_set_stages.append("PreInit")
574 
575  self.parameter_names.append("HornCF2")
576  self.parameter_units.append("")
577  self.parameter_lower_limits.append(0)
578  self.parameter_upper_limits.append(1)
579  self.macro_commands.append("#HornCF2")
580  self.macro_set_stages.append("PreInit")
581 
582  self.parameter_names.append("HornCF3")
583  self.parameter_units.append("")
584  self.parameter_lower_limits.append(0)
585  self.parameter_upper_limits.append(1)
586  self.macro_commands.append("#HornCF3")
587  self.macro_set_stages.append("PreInit")
588 
589  self.parameter_names.append("HornCF4")
590  self.parameter_units.append("")
591  self.parameter_lower_limits.append(0)
592  self.parameter_upper_limits.append(1)
593  self.macro_commands.append("#HornCF4")
594  self.macro_set_stages.append("PreInit")
595 
596  self.parameter_names.append("HornCF5")
597  self.parameter_units.append("")
598  self.parameter_lower_limits.append(0)
599  self.parameter_upper_limits.append(1)
600  self.macro_commands.append("#HornCF5")
601  self.macro_set_stages.append("PreInit")
602 
603  self.parameter_names.append("HornCRadius1")
604  self.parameter_units.append("mm")
605  self.parameter_lower_limits.append(150)
606  self.parameter_upper_limits.append(550)
607  self.macro_commands.append("#HornCRadius1")
608  self.macro_set_stages.append("PreInit")
609 
610  self.parameter_names.append("HornCRadius2")
611  self.parameter_units.append("mm")
612  self.parameter_lower_limits.append(20)
613  self.parameter_upper_limits.append(300)
614  self.macro_commands.append("#HornCRadius2")
615  self.macro_set_stages.append("PreInit")
616 
617  self.parameter_names.append("HornCRadius3")
618  self.parameter_units.append("mm")
619  self.parameter_lower_limits.append(50)
620  self.parameter_upper_limits.append(550)
621  self.macro_commands.append("#HornCRadius3")
622  self.macro_set_stages.append("PreInit")
623 
624  self.parameter_names.append("HornCRadiusOC")
625  self.parameter_units.append("mm")
626  self.parameter_lower_limits.append(550)
627  self.parameter_upper_limits.append(1000)
628  self.macro_commands.append("#HornCRadiusOC")
629  self.macro_set_stages.append("PreInit")
630 
631  self.parameter_names.append("HornCLongPosition")
632  self.parameter_units.append("mm")
633  self.parameter_lower_limits.append(4000)
634  self.parameter_upper_limits.append(40000)
635  self.macro_commands.append("#HornCLongPosition")
636  self.macro_set_stages.append("PreInit")
637 
638  self.parameter_names.append("GraphiteTargetLength")
639  self.parameter_units.append("m");
640  self.parameter_lower_limits.append(0.5);
641  self.parameter_upper_limits.append(3.0);
642  self.macro_commands.append("/LBNE/det/GraphiteTargetLength");
643  self.macro_set_stages.append("PreInit")
644 
645  self.parameter_names.append("GraphiteTargetFinWidth")
646  self.parameter_units.append("mm");
647  self.parameter_lower_limits.append(9);
648  self.parameter_upper_limits.append(15);
649  self.macro_commands.append("/LBNE/det/GraphiteTargetFinWidth");
650  self.macro_set_stages.append("PreInit")
651 
652  self.parameter_names.append("BeamSigma")
653  self.parameter_units.append("mm");
654  self.parameter_lower_limits.append(1.6);
655  self.parameter_upper_limits.append(2.5);
656  self.macro_commands.append("/LBNE/generator/beamSigmaX");
657  self.macro_set_stages.append("Idle")
658 
659  self.parameter_names.append("HornCurrent")
660  self.parameter_units.append("kA");
661  self.parameter_lower_limits.append(150);
662  self.parameter_upper_limits.append(300);
663  self.macro_commands.append("/LBNE/det/seHornCurrent")
664  self.macro_set_stages.append("PreInit")
665 
666  self.parameter_names.append("ProtonEnergy")
667  self.parameter_units.append("GeV");
668  self.parameter_lower_limits.append(40);
669  self.parameter_upper_limits.append(130);
670  self.macro_commands.append("/LBNE/primary/protonMomentum")
671  self.macro_set_stages.append("Idle")
672 
673  # Cylindrical target
674  if(optimizationName=="CP_run16" or optimizationName=="CP_run18"):
675 
676  self.parameter_names.append("HornALength")
677  self.parameter_units.append("mm")
678  self.parameter_lower_limits.append(1000)
679  self.parameter_upper_limits.append(4500)
680  self.macro_commands.append("#HornALength")
681  self.macro_set_stages.append("PreInit")
682 
683  self.parameter_names.append("HornAF1")
684  self.parameter_units.append("")
685  self.parameter_lower_limits.append(0.01)
686  self.parameter_upper_limits.append(0.99)
687  self.macro_commands.append("#HornAF1")
688  self.macro_set_stages.append("PreInit")
689 
690  self.parameter_names.append("HornARadius1")
691  self.parameter_units.append("mm")
692  self.parameter_lower_limits.append(20)
693  self.parameter_upper_limits.append(50)
694  self.macro_commands.append("#HornARadius1")
695  self.macro_set_stages.append("PreInit")
696 
697  self.parameter_names.append("HornARadius2")
698  self.parameter_units.append("mm")
699  self.parameter_lower_limits.append(20)
700  self.parameter_upper_limits.append(200)
701  self.macro_commands.append("#HornARadius2")
702  self.macro_set_stages.append("PreInit")
703 
704  self.parameter_names.append("HornARadiusOC")
705  self.parameter_units.append("mm")
706  self.parameter_lower_limits.append(200)
707  self.parameter_upper_limits.append(650)
708  self.macro_commands.append("#HornARadiusOC")
709  self.macro_set_stages.append("PreInit")
710 
711  self.parameter_names.append("HornBLength")
712  self.parameter_units.append("mm")
713  self.parameter_lower_limits.append(2000)
714  self.parameter_upper_limits.append(4500)
715  self.macro_commands.append("#HornBLength")
716  self.macro_set_stages.append("PreInit")
717 
718  self.parameter_names.append("HornBF1")
719  self.parameter_units.append("")
720  self.parameter_lower_limits.append(0)
721  self.parameter_upper_limits.append(1)
722  self.macro_commands.append("#HornBF1")
723  self.macro_set_stages.append("PreInit")
724 
725  self.parameter_names.append("HornBF2")
726  self.parameter_units.append("")
727  self.parameter_lower_limits.append(0)
728  self.parameter_upper_limits.append(1)
729  self.macro_commands.append("#HornBF2")
730  self.macro_set_stages.append("PreInit")
731 
732  self.parameter_names.append("HornBF3")
733  self.parameter_units.append("")
734  self.parameter_lower_limits.append(0)
735  self.parameter_upper_limits.append(1)
736  self.macro_commands.append("#HornBF3")
737  self.macro_set_stages.append("PreInit")
738 
739  self.parameter_names.append("HornBF4")
740  self.parameter_units.append("")
741  self.parameter_lower_limits.append(0)
742  self.parameter_upper_limits.append(1)
743  self.macro_commands.append("#HornBF4")
744  self.macro_set_stages.append("PreInit")
745 
746  self.parameter_names.append("HornBF5")
747  self.parameter_units.append("")
748  self.parameter_lower_limits.append(0)
749  self.parameter_upper_limits.append(1)
750  self.macro_commands.append("#HornBF5")
751  self.macro_set_stages.append("PreInit")
752 
753  self.parameter_names.append("HornBRadius1")
754  self.parameter_units.append("mm")
755  self.parameter_lower_limits.append(50)
756  self.parameter_upper_limits.append(200)
757  self.macro_commands.append("#HornBRadius1")
758  self.macro_set_stages.append("PreInit")
759 
760  self.parameter_names.append("HornBRadius2")
761  self.parameter_units.append("mm")
762  self.parameter_lower_limits.append(20)
763  self.parameter_upper_limits.append(50)
764  self.macro_commands.append("#HornBRadius2")
765  self.macro_set_stages.append("PreInit")
766 
767  self.parameter_names.append("HornBRadius3")
768  self.parameter_units.append("mm")
769  self.parameter_lower_limits.append(50)
770  self.parameter_upper_limits.append(200)
771  self.macro_commands.append("#HornBRadius3")
772  self.macro_set_stages.append("PreInit")
773 
774  self.parameter_names.append("HornBRadiusOC")
775  self.parameter_units.append("mm")
776  self.parameter_lower_limits.append(200)
777  self.parameter_upper_limits.append(650)
778  self.macro_commands.append("#HornBRadiusOC")
779  self.macro_set_stages.append("PreInit")
780 
781  self.parameter_names.append("HornBLongPosition")
782  self.parameter_units.append("mm")
783  self.parameter_lower_limits.append(2000)
784  self.parameter_upper_limits.append(17000)
785  self.macro_commands.append("#HornBLongPosition")
786  self.macro_set_stages.append("PreInit")
787 
788  self.parameter_names.append("HornCLength")
789  self.parameter_units.append("mm")
790  self.parameter_lower_limits.append(2000)
791  self.parameter_upper_limits.append(4500)
792  self.macro_commands.append("#HornCLength")
793  self.macro_set_stages.append("PreInit")
794 
795  self.parameter_names.append("HornCF1")
796  self.parameter_units.append("")
797  self.parameter_lower_limits.append(0)
798  self.parameter_upper_limits.append(1)
799  self.macro_commands.append("#HornCF1")
800  self.macro_set_stages.append("PreInit")
801 
802  self.parameter_names.append("HornCF2")
803  self.parameter_units.append("")
804  self.parameter_lower_limits.append(0)
805  self.parameter_upper_limits.append(1)
806  self.macro_commands.append("#HornCF2")
807  self.macro_set_stages.append("PreInit")
808 
809  self.parameter_names.append("HornCF3")
810  self.parameter_units.append("")
811  self.parameter_lower_limits.append(0)
812  self.parameter_upper_limits.append(1)
813  self.macro_commands.append("#HornCF3")
814  self.macro_set_stages.append("PreInit")
815 
816  self.parameter_names.append("HornCF4")
817  self.parameter_units.append("")
818  self.parameter_lower_limits.append(0)
819  self.parameter_upper_limits.append(1)
820  self.macro_commands.append("#HornCF4")
821  self.macro_set_stages.append("PreInit")
822 
823  self.parameter_names.append("HornCF5")
824  self.parameter_units.append("")
825  self.parameter_lower_limits.append(0)
826  self.parameter_upper_limits.append(1)
827  self.macro_commands.append("#HornCF5")
828  self.macro_set_stages.append("PreInit")
829 
830  self.parameter_names.append("HornCRadius1")
831  self.parameter_units.append("mm")
832  self.parameter_lower_limits.append(50)
833  self.parameter_upper_limits.append(550)
834  self.macro_commands.append("#HornCRadius1")
835  self.macro_set_stages.append("PreInit")
836 
837  self.parameter_names.append("HornCRadius2")
838  self.parameter_units.append("mm")
839  self.parameter_lower_limits.append(20)
840  self.parameter_upper_limits.append(200)
841  self.macro_commands.append("#HornCRadius2")
842  self.macro_set_stages.append("PreInit")
843 
844  self.parameter_names.append("HornCRadius3")
845  self.parameter_units.append("mm")
846  self.parameter_lower_limits.append(50)
847  self.parameter_upper_limits.append(550)
848  self.macro_commands.append("#HornCRadius3")
849  self.macro_set_stages.append("PreInit")
850 
851  self.parameter_names.append("HornCRadiusOC")
852  self.parameter_units.append("mm")
853  self.parameter_lower_limits.append(550)
854  self.parameter_upper_limits.append(650)
855  self.macro_commands.append("#HornCRadiusOC")
856  self.macro_set_stages.append("PreInit")
857 
858  self.parameter_names.append("HornCLongPosition")
859  self.parameter_units.append("mm")
860  self.parameter_lower_limits.append(4000)
861  self.parameter_upper_limits.append(19000)
862  self.macro_commands.append("#HornCLongPosition")
863  self.macro_set_stages.append("PreInit")
864 
865  self.parameter_names.append("SimpleTargetLength")
866  self.parameter_units.append("m");
867  self.parameter_lower_limits.append(0.5);
868  self.parameter_upper_limits.append(2.0);
869  self.macro_commands.append("/LBNE/det/SimpleTargetLength");
870  self.macro_set_stages.append("PreInit")
871 
872  self.parameter_names.append("SimpleTargetRadius")
873  self.parameter_units.append("mm");
874  self.parameter_lower_limits.append(6);
875  self.parameter_upper_limits.append(20);
876  self.macro_commands.append("/LBNE/det/SimpleTargetRadius");
877  self.macro_set_stages.append("PreInit")
878 
879  self.parameter_names.append("BeamSigma")
880  self.parameter_units.append("mm");
881  self.parameter_lower_limits.append(1.6);
882  self.parameter_upper_limits.append(2.5);
883  self.macro_commands.append("/LBNE/generator/beamSigmaX");
884  self.macro_set_stages.append("Idle")
885 
886  self.parameter_names.append("HornCurrent")
887  self.parameter_units.append("kA");
888  self.parameter_lower_limits.append(150);
889  self.parameter_upper_limits.append(300);
890  self.macro_commands.append("/LBNE/det/seHornCurrent")
891  self.macro_set_stages.append("PreInit")
892 
893  self.parameter_names.append("ProtonEnergy")
894  self.parameter_units.append("GeV");
895  self.parameter_lower_limits.append(40);
896  self.parameter_upper_limits.append(130);
897  self.macro_commands.append("/LBNE/primary/protonMomentum")
898  self.macro_set_stages.append("Idle")
899 
900  # Spherical target
901  if(optimizationName=="CP_run17"):
902 
903  self.parameter_names.append("HornALength")
904  self.parameter_units.append("mm")
905  self.parameter_lower_limits.append(1000)
906  self.parameter_upper_limits.append(4500)
907  self.macro_commands.append("#HornALength")
908  self.macro_set_stages.append("PreInit")
909 
910  self.parameter_names.append("HornAF1")
911  self.parameter_units.append("")
912  self.parameter_lower_limits.append(0.01)
913  self.parameter_upper_limits.append(0.99)
914  self.macro_commands.append("#HornAF1")
915  self.macro_set_stages.append("PreInit")
916 
917  self.parameter_names.append("HornARadius1")
918  self.parameter_units.append("mm")
919  self.parameter_lower_limits.append(20)
920  self.parameter_upper_limits.append(50)
921  self.macro_commands.append("#HornARadius1")
922  self.macro_set_stages.append("PreInit")
923 
924  self.parameter_names.append("HornARadius2")
925  self.parameter_units.append("mm")
926  self.parameter_lower_limits.append(20)
927  self.parameter_upper_limits.append(200)
928  self.macro_commands.append("#HornARadius2")
929  self.macro_set_stages.append("PreInit")
930 
931  self.parameter_names.append("HornARadiusOC")
932  self.parameter_units.append("mm")
933  self.parameter_lower_limits.append(200)
934  self.parameter_upper_limits.append(650)
935  self.macro_commands.append("#HornARadiusOC")
936  self.macro_set_stages.append("PreInit")
937 
938  self.parameter_names.append("HornBLength")
939  self.parameter_units.append("mm")
940  self.parameter_lower_limits.append(2000)
941  self.parameter_upper_limits.append(4500)
942  self.macro_commands.append("#HornBLength")
943  self.macro_set_stages.append("PreInit")
944 
945  self.parameter_names.append("HornBF1")
946  self.parameter_units.append("")
947  self.parameter_lower_limits.append(0)
948  self.parameter_upper_limits.append(1)
949  self.macro_commands.append("#HornBF1")
950  self.macro_set_stages.append("PreInit")
951 
952  self.parameter_names.append("HornBF2")
953  self.parameter_units.append("")
954  self.parameter_lower_limits.append(0)
955  self.parameter_upper_limits.append(1)
956  self.macro_commands.append("#HornBF2")
957  self.macro_set_stages.append("PreInit")
958 
959  self.parameter_names.append("HornBF3")
960  self.parameter_units.append("")
961  self.parameter_lower_limits.append(0)
962  self.parameter_upper_limits.append(1)
963  self.macro_commands.append("#HornBF3")
964  self.macro_set_stages.append("PreInit")
965 
966  self.parameter_names.append("HornBF4")
967  self.parameter_units.append("")
968  self.parameter_lower_limits.append(0)
969  self.parameter_upper_limits.append(1)
970  self.macro_commands.append("#HornBF4")
971  self.macro_set_stages.append("PreInit")
972 
973  self.parameter_names.append("HornBF5")
974  self.parameter_units.append("")
975  self.parameter_lower_limits.append(0)
976  self.parameter_upper_limits.append(1)
977  self.macro_commands.append("#HornBF5")
978  self.macro_set_stages.append("PreInit")
979 
980  self.parameter_names.append("HornBRadius1")
981  self.parameter_units.append("mm")
982  self.parameter_lower_limits.append(50)
983  self.parameter_upper_limits.append(200)
984  self.macro_commands.append("#HornBRadius1")
985  self.macro_set_stages.append("PreInit")
986 
987  self.parameter_names.append("HornBRadius2")
988  self.parameter_units.append("mm")
989  self.parameter_lower_limits.append(20)
990  self.parameter_upper_limits.append(50)
991  self.macro_commands.append("#HornBRadius2")
992  self.macro_set_stages.append("PreInit")
993 
994  self.parameter_names.append("HornBRadius3")
995  self.parameter_units.append("mm")
996  self.parameter_lower_limits.append(50)
997  self.parameter_upper_limits.append(200)
998  self.macro_commands.append("#HornBRadius3")
999  self.macro_set_stages.append("PreInit")
1000 
1001  self.parameter_names.append("HornBRadiusOC")
1002  self.parameter_units.append("mm")
1003  self.parameter_lower_limits.append(200)
1004  self.parameter_upper_limits.append(650)
1005  self.macro_commands.append("#HornBRadiusOC")
1006  self.macro_set_stages.append("PreInit")
1007 
1008  self.parameter_names.append("HornBLongPosition")
1009  self.parameter_units.append("mm")
1010  self.parameter_lower_limits.append(2000)
1011  self.parameter_upper_limits.append(17000)
1012  self.macro_commands.append("#HornBLongPosition")
1013  self.macro_set_stages.append("PreInit")
1014 
1015  self.parameter_names.append("HornCLength")
1016  self.parameter_units.append("mm")
1017  self.parameter_lower_limits.append(2000)
1018  self.parameter_upper_limits.append(4500)
1019  self.macro_commands.append("#HornCLength")
1020  self.macro_set_stages.append("PreInit")
1021 
1022  self.parameter_names.append("HornCF1")
1023  self.parameter_units.append("")
1024  self.parameter_lower_limits.append(0)
1025  self.parameter_upper_limits.append(1)
1026  self.macro_commands.append("#HornCF1")
1027  self.macro_set_stages.append("PreInit")
1028 
1029  self.parameter_names.append("HornCF2")
1030  self.parameter_units.append("")
1031  self.parameter_lower_limits.append(0)
1032  self.parameter_upper_limits.append(1)
1033  self.macro_commands.append("#HornCF2")
1034  self.macro_set_stages.append("PreInit")
1035 
1036  self.parameter_names.append("HornCF3")
1037  self.parameter_units.append("")
1038  self.parameter_lower_limits.append(0)
1039  self.parameter_upper_limits.append(1)
1040  self.macro_commands.append("#HornCF3")
1041  self.macro_set_stages.append("PreInit")
1042 
1043  self.parameter_names.append("HornCF4")
1044  self.parameter_units.append("")
1045  self.parameter_lower_limits.append(0)
1046  self.parameter_upper_limits.append(1)
1047  self.macro_commands.append("#HornCF4")
1048  self.macro_set_stages.append("PreInit")
1049 
1050  self.parameter_names.append("HornCF5")
1051  self.parameter_units.append("")
1052  self.parameter_lower_limits.append(0)
1053  self.parameter_upper_limits.append(1)
1054  self.macro_commands.append("#HornCF5")
1055  self.macro_set_stages.append("PreInit")
1056 
1057  self.parameter_names.append("HornCRadius1")
1058  self.parameter_units.append("mm")
1059  self.parameter_lower_limits.append(50)
1060  self.parameter_upper_limits.append(550)
1061  self.macro_commands.append("#HornCRadius1")
1062  self.macro_set_stages.append("PreInit")
1063 
1064  self.parameter_names.append("HornCRadius2")
1065  self.parameter_units.append("mm")
1066  self.parameter_lower_limits.append(20)
1067  self.parameter_upper_limits.append(200)
1068  self.macro_commands.append("#HornCRadius2")
1069  self.macro_set_stages.append("PreInit")
1070 
1071  self.parameter_names.append("HornCRadius3")
1072  self.parameter_units.append("mm")
1073  self.parameter_lower_limits.append(50)
1074  self.parameter_upper_limits.append(550)
1075  self.macro_commands.append("#HornCRadius3")
1076  self.macro_set_stages.append("PreInit")
1077 
1078  self.parameter_names.append("HornCRadiusOC")
1079  self.parameter_units.append("mm")
1080  self.parameter_lower_limits.append(550)
1081  self.parameter_upper_limits.append(650)
1082  self.macro_commands.append("#HornCRadiusOC")
1083  self.macro_set_stages.append("PreInit")
1084 
1085  self.parameter_names.append("HornCLongPosition")
1086  self.parameter_units.append("mm")
1087  self.parameter_lower_limits.append(4000)
1088  self.parameter_upper_limits.append(19000)
1089  self.macro_commands.append("#HornCLongPosition")
1090  self.macro_set_stages.append("PreInit")
1091 
1092  # Seems that sphere target gets length from "GraphiteTargetLength""
1093  # even if its not graphite
1094  self.parameter_names.append("GraphiteTargetLength")
1095  self.parameter_units.append("m");
1096  self.parameter_lower_limits.append(0.5);
1097  self.parameter_upper_limits.append(2.0);
1098  self.macro_commands.append("/LBNE/det/GraphiteTargetLength");
1099  self.macro_set_stages.append("PreInit")
1100 
1101  self.parameter_names.append("MultiSphereTargetRadius")
1102  self.parameter_units.append("mm");
1103  self.parameter_lower_limits.append(5);
1104  self.parameter_upper_limits.append(15);
1105  self.macro_commands.append("/LBNE/det/MultiSphereTargetRadius");
1106  self.macro_set_stages.append("PreInit")
1107 
1108  self.parameter_names.append("BeamSigma")
1109  self.parameter_units.append("mm");
1110  self.parameter_lower_limits.append(1.6);
1111  self.parameter_upper_limits.append(2.5);
1112  self.macro_commands.append("/LBNE/generator/beamSigmaX");
1113  self.macro_set_stages.append("Idle")
1114 
1115  self.parameter_names.append("HornCurrent")
1116  self.parameter_units.append("kA");
1117  self.parameter_lower_limits.append(150);
1118  self.parameter_upper_limits.append(300);
1119  self.macro_commands.append("/LBNE/det/seHornCurrent")
1120  self.macro_set_stages.append("PreInit")
1121 
1122  self.parameter_names.append("ProtonEnergy")
1123  self.parameter_units.append("GeV");
1124  self.parameter_lower_limits.append(40);
1125  self.parameter_upper_limits.append(130);
1126  self.macro_commands.append("/LBNE/primary/protonMomentum")
1127  self.macro_set_stages.append("Idle")
1128 
1129  # Reduced outer conductor limit for nickel plating
1130  # less tight restrictions on neck radii
1131  if(optimizationName=="CP_run21" or optimizationName=="CP_run23"):
1132 
1133  self.parameter_names.append("HornALength")
1134  self.parameter_units.append("mm")
1135  self.parameter_lower_limits.append(1000)
1136  self.parameter_upper_limits.append(4500)
1137  self.macro_commands.append("#HornALength")
1138  self.macro_set_stages.append("PreInit")
1139 
1140  self.parameter_names.append("HornAF1")
1141  self.parameter_units.append("")
1142  self.parameter_lower_limits.append(0.01)
1143  self.parameter_upper_limits.append(0.99)
1144  self.macro_commands.append("#HornAF1")
1145  self.macro_set_stages.append("PreInit")
1146 
1147  self.parameter_names.append("HornARadius1")
1148  self.parameter_units.append("mm")
1149  self.parameter_lower_limits.append(20)
1150  self.parameter_upper_limits.append(200)
1151  self.macro_commands.append("#HornARadius1")
1152  self.macro_set_stages.append("PreInit")
1153 
1154  self.parameter_names.append("HornARadius2")
1155  self.parameter_units.append("mm")
1156  self.parameter_lower_limits.append(20)
1157  self.parameter_upper_limits.append(200)
1158  self.macro_commands.append("#HornARadius2")
1159  self.macro_set_stages.append("PreInit")
1160 
1161  self.parameter_names.append("HornARadiusOC")
1162  self.parameter_units.append("mm")
1163  self.parameter_lower_limits.append(300)
1164  self.parameter_upper_limits.append(457)
1165  self.macro_commands.append("#HornARadiusOC")
1166  self.macro_set_stages.append("PreInit")
1167 
1168  self.parameter_names.append("HornBLength")
1169  self.parameter_units.append("mm")
1170  self.parameter_lower_limits.append(2000)
1171  self.parameter_upper_limits.append(4500)
1172  self.macro_commands.append("#HornBLength")
1173  self.macro_set_stages.append("PreInit")
1174 
1175  self.parameter_names.append("HornBF1")
1176  self.parameter_units.append("")
1177  self.parameter_lower_limits.append(0)
1178  self.parameter_upper_limits.append(1)
1179  self.macro_commands.append("#HornBF1")
1180  self.macro_set_stages.append("PreInit")
1181 
1182  self.parameter_names.append("HornBF2")
1183  self.parameter_units.append("")
1184  self.parameter_lower_limits.append(0)
1185  self.parameter_upper_limits.append(1)
1186  self.macro_commands.append("#HornBF2")
1187  self.macro_set_stages.append("PreInit")
1188 
1189  self.parameter_names.append("HornBF3")
1190  self.parameter_units.append("")
1191  self.parameter_lower_limits.append(0)
1192  self.parameter_upper_limits.append(1)
1193  self.macro_commands.append("#HornBF3")
1194  self.macro_set_stages.append("PreInit")
1195 
1196  self.parameter_names.append("HornBF4")
1197  self.parameter_units.append("")
1198  self.parameter_lower_limits.append(0)
1199  self.parameter_upper_limits.append(1)
1200  self.macro_commands.append("#HornBF4")
1201  self.macro_set_stages.append("PreInit")
1202 
1203  self.parameter_names.append("HornBF5")
1204  self.parameter_units.append("")
1205  self.parameter_lower_limits.append(0)
1206  self.parameter_upper_limits.append(1)
1207  self.macro_commands.append("#HornBF5")
1208  self.macro_set_stages.append("PreInit")
1209 
1210  self.parameter_names.append("HornBRadius1")
1211  self.parameter_units.append("mm")
1212  self.parameter_lower_limits.append(50)
1213  self.parameter_upper_limits.append(200)
1214  self.macro_commands.append("#HornBRadius1")
1215  self.macro_set_stages.append("PreInit")
1216 
1217  self.parameter_names.append("HornBRadius2")
1218  self.parameter_units.append("mm")
1219  self.parameter_lower_limits.append(20)
1220  self.parameter_upper_limits.append(200)
1221  self.macro_commands.append("#HornBRadius2")
1222  self.macro_set_stages.append("PreInit")
1223 
1224  self.parameter_names.append("HornBRadius3")
1225  self.parameter_units.append("mm")
1226  self.parameter_lower_limits.append(50)
1227  self.parameter_upper_limits.append(550)
1228  self.macro_commands.append("#HornBRadius3")
1229  self.macro_set_stages.append("PreInit")
1230 
1231  self.parameter_names.append("HornBRadiusOC")
1232  self.parameter_units.append("mm")
1233  self.parameter_lower_limits.append(300)
1234  self.parameter_upper_limits.append(457)
1235  self.macro_commands.append("#HornBRadiusOC")
1236  self.macro_set_stages.append("PreInit")
1237 
1238  self.parameter_names.append("HornBLongPosition")
1239  self.parameter_units.append("mm")
1240  self.parameter_lower_limits.append(2000)
1241  self.parameter_upper_limits.append(17000)
1242  self.macro_commands.append("#HornBLongPosition")
1243  self.macro_set_stages.append("PreInit")
1244 
1245  self.parameter_names.append("HornCLength")
1246  self.parameter_units.append("mm")
1247  self.parameter_lower_limits.append(2000)
1248  self.parameter_upper_limits.append(4500)
1249  self.macro_commands.append("#HornCLength")
1250  self.macro_set_stages.append("PreInit")
1251 
1252  self.parameter_names.append("HornCF1")
1253  self.parameter_units.append("")
1254  self.parameter_lower_limits.append(0)
1255  self.parameter_upper_limits.append(1)
1256  self.macro_commands.append("#HornCF1")
1257  self.macro_set_stages.append("PreInit")
1258 
1259  self.parameter_names.append("HornCF2")
1260  self.parameter_units.append("")
1261  self.parameter_lower_limits.append(0)
1262  self.parameter_upper_limits.append(1)
1263  self.macro_commands.append("#HornCF2")
1264  self.macro_set_stages.append("PreInit")
1265 
1266  self.parameter_names.append("HornCF3")
1267  self.parameter_units.append("")
1268  self.parameter_lower_limits.append(0)
1269  self.parameter_upper_limits.append(1)
1270  self.macro_commands.append("#HornCF3")
1271  self.macro_set_stages.append("PreInit")
1272 
1273  self.parameter_names.append("HornCF4")
1274  self.parameter_units.append("")
1275  self.parameter_lower_limits.append(0)
1276  self.parameter_upper_limits.append(1)
1277  self.macro_commands.append("#HornCF4")
1278  self.macro_set_stages.append("PreInit")
1279 
1280  self.parameter_names.append("HornCF5")
1281  self.parameter_units.append("")
1282  self.parameter_lower_limits.append(0)
1283  self.parameter_upper_limits.append(1)
1284  self.macro_commands.append("#HornCF5")
1285  self.macro_set_stages.append("PreInit")
1286 
1287  self.parameter_names.append("HornCRadius1")
1288  self.parameter_units.append("mm")
1289  self.parameter_lower_limits.append(150)
1290  self.parameter_upper_limits.append(550)
1291  self.macro_commands.append("#HornCRadius1")
1292  self.macro_set_stages.append("PreInit")
1293 
1294  self.parameter_names.append("HornCRadius2")
1295  self.parameter_units.append("mm")
1296  self.parameter_lower_limits.append(20)
1297  self.parameter_upper_limits.append(300)
1298  self.macro_commands.append("#HornCRadius2")
1299  self.macro_set_stages.append("PreInit")
1300 
1301  self.parameter_names.append("HornCRadius3")
1302  self.parameter_units.append("mm")
1303  self.parameter_lower_limits.append(50)
1304  self.parameter_upper_limits.append(550)
1305  self.macro_commands.append("#HornCRadius3")
1306  self.macro_set_stages.append("PreInit")
1307 
1308  self.parameter_names.append("HornCRadiusOC")
1309  self.parameter_units.append("mm")
1310  self.parameter_lower_limits.append(300)
1311  self.parameter_upper_limits.append(457)
1312  self.macro_commands.append("#HornCRadiusOC")
1313  self.macro_set_stages.append("PreInit")
1314 
1315  self.parameter_names.append("HornCLongPosition")
1316  self.parameter_units.append("mm")
1317  self.parameter_lower_limits.append(4000)
1318  self.parameter_upper_limits.append(19000)
1319  self.macro_commands.append("#HornCLongPosition")
1320  self.macro_set_stages.append("PreInit")
1321 
1322  self.parameter_names.append("GraphiteTargetLength")
1323  self.parameter_units.append("m");
1324  self.parameter_lower_limits.append(0.5);
1325  self.parameter_upper_limits.append(2.0);
1326  self.macro_commands.append("/LBNE/det/GraphiteTargetLength");
1327  self.macro_set_stages.append("PreInit")
1328 
1329  self.parameter_names.append("GraphiteTargetFinWidth")
1330  self.parameter_units.append("mm");
1331  self.parameter_lower_limits.append(9);
1332  self.parameter_upper_limits.append(15);
1333  self.macro_commands.append("/LBNE/det/GraphiteTargetFinWidth");
1334  self.macro_set_stages.append("PreInit")
1335 
1336  self.parameter_names.append("BeamSigma")
1337  self.parameter_units.append("mm");
1338  self.parameter_lower_limits.append(1.6);
1339  self.parameter_upper_limits.append(2.5);
1340  self.macro_commands.append("/LBNE/generator/beamSigmaX");
1341  self.macro_set_stages.append("Idle")
1342 
1343  self.parameter_names.append("HornCurrent")
1344  self.parameter_units.append("kA");
1345  self.parameter_lower_limits.append(150);
1346  self.parameter_upper_limits.append(300);
1347  self.macro_commands.append("/LBNE/det/seHornCurrent")
1348  self.macro_set_stages.append("PreInit")
1349 
1350  self.parameter_names.append("ProtonEnergy")
1351  self.parameter_units.append("GeV");
1352  self.parameter_lower_limits.append(40);
1353  self.parameter_upper_limits.append(130);
1354  self.macro_commands.append("/LBNE/primary/protonMomentum")
1355  self.macro_set_stages.append("Idle")
1356 
1357  # Like CP_run15, but with Realistic conductor thicknesses, less constraints on neck radii
1358  if(optimizationName=="CP_run22" or optimizationName=="CP_run24" or optimizationName=="CP_run25" or optimizationName=="LE_run2"):
1359 
1360  self.parameter_names.append("HornALength")
1361  self.parameter_units.append("mm")
1362  self.parameter_lower_limits.append(1000)
1363  self.parameter_upper_limits.append(4500)
1364  self.macro_commands.append("#HornALength")
1365  self.macro_set_stages.append("PreInit")
1366 
1367  self.parameter_names.append("HornAF1")
1368  self.parameter_units.append("")
1369  self.parameter_lower_limits.append(0.01)
1370  self.parameter_upper_limits.append(0.99)
1371  self.macro_commands.append("#HornAF1")
1372  self.macro_set_stages.append("PreInit")
1373 
1374  self.parameter_names.append("HornARadius1")
1375  self.parameter_units.append("mm")
1376  self.parameter_lower_limits.append(20)
1377  self.parameter_upper_limits.append(200)
1378  self.macro_commands.append("#HornARadius1")
1379  self.macro_set_stages.append("PreInit")
1380 
1381  self.parameter_names.append("HornARadius2")
1382  self.parameter_units.append("mm")
1383  self.parameter_lower_limits.append(20)
1384  self.parameter_upper_limits.append(200)
1385  self.macro_commands.append("#HornARadius2")
1386  self.macro_set_stages.append("PreInit")
1387 
1388  self.parameter_names.append("HornARadiusOC")
1389  self.parameter_units.append("mm")
1390  self.parameter_lower_limits.append(300)
1391  self.parameter_upper_limits.append(650)
1392  self.macro_commands.append("#HornARadiusOC")
1393  self.macro_set_stages.append("PreInit")
1394 
1395  self.parameter_names.append("HornBLength")
1396  self.parameter_units.append("mm")
1397  self.parameter_lower_limits.append(2000)
1398  self.parameter_upper_limits.append(4500)
1399  self.macro_commands.append("#HornBLength")
1400  self.macro_set_stages.append("PreInit")
1401 
1402  self.parameter_names.append("HornBF1")
1403  self.parameter_units.append("")
1404  self.parameter_lower_limits.append(0)
1405  self.parameter_upper_limits.append(1)
1406  self.macro_commands.append("#HornBF1")
1407  self.macro_set_stages.append("PreInit")
1408 
1409  self.parameter_names.append("HornBF2")
1410  self.parameter_units.append("")
1411  self.parameter_lower_limits.append(0)
1412  self.parameter_upper_limits.append(1)
1413  self.macro_commands.append("#HornBF2")
1414  self.macro_set_stages.append("PreInit")
1415 
1416  self.parameter_names.append("HornBF3")
1417  self.parameter_units.append("")
1418  self.parameter_lower_limits.append(0)
1419  self.parameter_upper_limits.append(1)
1420  self.macro_commands.append("#HornBF3")
1421  self.macro_set_stages.append("PreInit")
1422 
1423  self.parameter_names.append("HornBF4")
1424  self.parameter_units.append("")
1425  self.parameter_lower_limits.append(0)
1426  self.parameter_upper_limits.append(1)
1427  self.macro_commands.append("#HornBF4")
1428  self.macro_set_stages.append("PreInit")
1429 
1430  self.parameter_names.append("HornBF5")
1431  self.parameter_units.append("")
1432  self.parameter_lower_limits.append(0)
1433  self.parameter_upper_limits.append(1)
1434  self.macro_commands.append("#HornBF5")
1435  self.macro_set_stages.append("PreInit")
1436 
1437  self.parameter_names.append("HornBRadius1")
1438  self.parameter_units.append("mm")
1439  self.parameter_lower_limits.append(50)
1440  self.parameter_upper_limits.append(200)
1441  self.macro_commands.append("#HornBRadius1")
1442  self.macro_set_stages.append("PreInit")
1443 
1444  self.parameter_names.append("HornBRadius2")
1445  self.parameter_units.append("mm")
1446  self.parameter_lower_limits.append(20)
1447  self.parameter_upper_limits.append(200)
1448  self.macro_commands.append("#HornBRadius2")
1449  self.macro_set_stages.append("PreInit")
1450 
1451  self.parameter_names.append("HornBRadius3")
1452  self.parameter_units.append("mm")
1453  self.parameter_lower_limits.append(50)
1454  self.parameter_upper_limits.append(550)
1455  self.macro_commands.append("#HornBRadius3")
1456  self.macro_set_stages.append("PreInit")
1457 
1458  self.parameter_names.append("HornBRadiusOC")
1459  self.parameter_units.append("mm")
1460  self.parameter_lower_limits.append(300)
1461  self.parameter_upper_limits.append(650)
1462  self.macro_commands.append("#HornBRadiusOC")
1463  self.macro_set_stages.append("PreInit")
1464 
1465  self.parameter_names.append("HornBLongPosition")
1466  self.parameter_units.append("mm")
1467  self.parameter_lower_limits.append(2000)
1468  self.parameter_upper_limits.append(17000)
1469  self.macro_commands.append("#HornBLongPosition")
1470  self.macro_set_stages.append("PreInit")
1471 
1472  self.parameter_names.append("HornCLength")
1473  self.parameter_units.append("mm")
1474  self.parameter_lower_limits.append(2000)
1475  self.parameter_upper_limits.append(4500)
1476  self.macro_commands.append("#HornCLength")
1477  self.macro_set_stages.append("PreInit")
1478 
1479  self.parameter_names.append("HornCF1")
1480  self.parameter_units.append("")
1481  self.parameter_lower_limits.append(0)
1482  self.parameter_upper_limits.append(1)
1483  self.macro_commands.append("#HornCF1")
1484  self.macro_set_stages.append("PreInit")
1485 
1486  self.parameter_names.append("HornCF2")
1487  self.parameter_units.append("")
1488  self.parameter_lower_limits.append(0)
1489  self.parameter_upper_limits.append(1)
1490  self.macro_commands.append("#HornCF2")
1491  self.macro_set_stages.append("PreInit")
1492 
1493  self.parameter_names.append("HornCF3")
1494  self.parameter_units.append("")
1495  self.parameter_lower_limits.append(0)
1496  self.parameter_upper_limits.append(1)
1497  self.macro_commands.append("#HornCF3")
1498  self.macro_set_stages.append("PreInit")
1499 
1500  self.parameter_names.append("HornCF4")
1501  self.parameter_units.append("")
1502  self.parameter_lower_limits.append(0)
1503  self.parameter_upper_limits.append(1)
1504  self.macro_commands.append("#HornCF4")
1505  self.macro_set_stages.append("PreInit")
1506 
1507  self.parameter_names.append("HornCF5")
1508  self.parameter_units.append("")
1509  self.parameter_lower_limits.append(0)
1510  self.parameter_upper_limits.append(1)
1511  self.macro_commands.append("#HornCF5")
1512  self.macro_set_stages.append("PreInit")
1513 
1514  self.parameter_names.append("HornCRadius1")
1515  self.parameter_units.append("mm")
1516  self.parameter_lower_limits.append(150)
1517  self.parameter_upper_limits.append(550)
1518  self.macro_commands.append("#HornCRadius1")
1519  self.macro_set_stages.append("PreInit")
1520 
1521  self.parameter_names.append("HornCRadius2")
1522  self.parameter_units.append("mm")
1523  self.parameter_lower_limits.append(20)
1524  self.parameter_upper_limits.append(300)
1525  self.macro_commands.append("#HornCRadius2")
1526  self.macro_set_stages.append("PreInit")
1527 
1528  self.parameter_names.append("HornCRadius3")
1529  self.parameter_units.append("mm")
1530  self.parameter_lower_limits.append(50)
1531  self.parameter_upper_limits.append(550)
1532  self.macro_commands.append("#HornCRadius3")
1533  self.macro_set_stages.append("PreInit")
1534 
1535  self.parameter_names.append("HornCRadiusOC")
1536  self.parameter_units.append("mm")
1537  self.parameter_lower_limits.append(300)
1538  self.parameter_upper_limits.append(650)
1539  self.macro_commands.append("#HornCRadiusOC")
1540  self.macro_set_stages.append("PreInit")
1541 
1542  self.parameter_names.append("HornCLongPosition")
1543  self.parameter_units.append("mm")
1544  self.parameter_lower_limits.append(4000)
1545  self.parameter_upper_limits.append(19000)
1546  self.macro_commands.append("#HornCLongPosition")
1547  self.macro_set_stages.append("PreInit")
1548 
1549  self.parameter_names.append("GraphiteTargetLength")
1550  self.parameter_units.append("m");
1551  self.parameter_lower_limits.append(0.5);
1552  self.parameter_upper_limits.append(2.0);
1553  self.macro_commands.append("/LBNE/det/GraphiteTargetLength");
1554  self.macro_set_stages.append("PreInit")
1555 
1556  self.parameter_names.append("GraphiteTargetFinWidth")
1557  self.parameter_units.append("mm");
1558  self.parameter_lower_limits.append(9);
1559  self.parameter_upper_limits.append(15);
1560  self.macro_commands.append("/LBNE/det/GraphiteTargetFinWidth");
1561  self.macro_set_stages.append("PreInit")
1562 
1563  self.parameter_names.append("BeamSigma")
1564  self.parameter_units.append("mm");
1565  self.parameter_lower_limits.append(1.6);
1566  self.parameter_upper_limits.append(2.5);
1567  self.macro_commands.append("/LBNE/generator/beamSigmaX");
1568  self.macro_set_stages.append("Idle")
1569 
1570  self.parameter_names.append("HornCurrent")
1571  self.parameter_units.append("kA");
1572  self.parameter_lower_limits.append(150);
1573  self.parameter_upper_limits.append(300);
1574  self.macro_commands.append("/LBNE/det/seHornCurrent")
1575  self.macro_set_stages.append("PreInit")
1576 
1577  self.parameter_names.append("ProtonEnergy")
1578  self.parameter_units.append("GeV");
1579  self.parameter_lower_limits.append(40);
1580  self.parameter_upper_limits.append(130);
1581  self.macro_commands.append("/LBNE/primary/protonMomentum")
1582  self.macro_set_stages.append("Idle")
1583 
1584  # Like CP_run15, less constraints on neck radii, tighter constraints on horn lenght, less stats
1585  if(optimizationName=="CP_run28"):
1586 
1587  self.parameter_names.append("HornALength")
1588  self.parameter_units.append("mm")
1589  self.parameter_lower_limits.append(1000)
1590  self.parameter_upper_limits.append(3500)
1591  self.macro_commands.append("#HornALength")
1592  self.macro_set_stages.append("PreInit")
1593 
1594  self.parameter_names.append("HornAF1")
1595  self.parameter_units.append("")
1596  self.parameter_lower_limits.append(0.01)
1597  self.parameter_upper_limits.append(0.99)
1598  self.macro_commands.append("#HornAF1")
1599  self.macro_set_stages.append("PreInit")
1600 
1601  self.parameter_names.append("HornARadius1")
1602  self.parameter_units.append("mm")
1603  self.parameter_lower_limits.append(20)
1604  self.parameter_upper_limits.append(200)
1605  self.macro_commands.append("#HornARadius1")
1606  self.macro_set_stages.append("PreInit")
1607 
1608  self.parameter_names.append("HornARadius2")
1609  self.parameter_units.append("mm")
1610  self.parameter_lower_limits.append(20)
1611  self.parameter_upper_limits.append(200)
1612  self.macro_commands.append("#HornARadius2")
1613  self.macro_set_stages.append("PreInit")
1614 
1615  self.parameter_names.append("HornARadiusOC")
1616  self.parameter_units.append("mm")
1617  self.parameter_lower_limits.append(300)
1618  self.parameter_upper_limits.append(650)
1619  self.macro_commands.append("#HornARadiusOC")
1620  self.macro_set_stages.append("PreInit")
1621 
1622  self.parameter_names.append("HornBLength")
1623  self.parameter_units.append("mm")
1624  self.parameter_lower_limits.append(2000)
1625  self.parameter_upper_limits.append(3500)
1626  self.macro_commands.append("#HornBLength")
1627  self.macro_set_stages.append("PreInit")
1628 
1629  self.parameter_names.append("HornBF1")
1630  self.parameter_units.append("")
1631  self.parameter_lower_limits.append(0)
1632  self.parameter_upper_limits.append(1)
1633  self.macro_commands.append("#HornBF1")
1634  self.macro_set_stages.append("PreInit")
1635 
1636  self.parameter_names.append("HornBF2")
1637  self.parameter_units.append("")
1638  self.parameter_lower_limits.append(0)
1639  self.parameter_upper_limits.append(1)
1640  self.macro_commands.append("#HornBF2")
1641  self.macro_set_stages.append("PreInit")
1642 
1643  self.parameter_names.append("HornBF3")
1644  self.parameter_units.append("")
1645  self.parameter_lower_limits.append(0)
1646  self.parameter_upper_limits.append(1)
1647  self.macro_commands.append("#HornBF3")
1648  self.macro_set_stages.append("PreInit")
1649 
1650  self.parameter_names.append("HornBF4")
1651  self.parameter_units.append("")
1652  self.parameter_lower_limits.append(0)
1653  self.parameter_upper_limits.append(1)
1654  self.macro_commands.append("#HornBF4")
1655  self.macro_set_stages.append("PreInit")
1656 
1657  self.parameter_names.append("HornBF5")
1658  self.parameter_units.append("")
1659  self.parameter_lower_limits.append(0)
1660  self.parameter_upper_limits.append(1)
1661  self.macro_commands.append("#HornBF5")
1662  self.macro_set_stages.append("PreInit")
1663 
1664  self.parameter_names.append("HornBRadius1")
1665  self.parameter_units.append("mm")
1666  self.parameter_lower_limits.append(50)
1667  self.parameter_upper_limits.append(200)
1668  self.macro_commands.append("#HornBRadius1")
1669  self.macro_set_stages.append("PreInit")
1670 
1671  self.parameter_names.append("HornBRadius2")
1672  self.parameter_units.append("mm")
1673  self.parameter_lower_limits.append(20)
1674  self.parameter_upper_limits.append(200)
1675  self.macro_commands.append("#HornBRadius2")
1676  self.macro_set_stages.append("PreInit")
1677 
1678  self.parameter_names.append("HornBRadius3")
1679  self.parameter_units.append("mm")
1680  self.parameter_lower_limits.append(50)
1681  self.parameter_upper_limits.append(550)
1682  self.macro_commands.append("#HornBRadius3")
1683  self.macro_set_stages.append("PreInit")
1684 
1685  self.parameter_names.append("HornBRadiusOC")
1686  self.parameter_units.append("mm")
1687  self.parameter_lower_limits.append(300)
1688  self.parameter_upper_limits.append(650)
1689  self.macro_commands.append("#HornBRadiusOC")
1690  self.macro_set_stages.append("PreInit")
1691 
1692  self.parameter_names.append("HornBLongPosition")
1693  self.parameter_units.append("mm")
1694  self.parameter_lower_limits.append(2000)
1695  self.parameter_upper_limits.append(17000)
1696  self.macro_commands.append("#HornBLongPosition")
1697  self.macro_set_stages.append("PreInit")
1698 
1699  self.parameter_names.append("HornCLength")
1700  self.parameter_units.append("mm")
1701  self.parameter_lower_limits.append(2000)
1702  self.parameter_upper_limits.append(3500)
1703  self.macro_commands.append("#HornCLength")
1704  self.macro_set_stages.append("PreInit")
1705 
1706  self.parameter_names.append("HornCF1")
1707  self.parameter_units.append("")
1708  self.parameter_lower_limits.append(0)
1709  self.parameter_upper_limits.append(1)
1710  self.macro_commands.append("#HornCF1")
1711  self.macro_set_stages.append("PreInit")
1712 
1713  self.parameter_names.append("HornCF2")
1714  self.parameter_units.append("")
1715  self.parameter_lower_limits.append(0)
1716  self.parameter_upper_limits.append(1)
1717  self.macro_commands.append("#HornCF2")
1718  self.macro_set_stages.append("PreInit")
1719 
1720  self.parameter_names.append("HornCF3")
1721  self.parameter_units.append("")
1722  self.parameter_lower_limits.append(0)
1723  self.parameter_upper_limits.append(1)
1724  self.macro_commands.append("#HornCF3")
1725  self.macro_set_stages.append("PreInit")
1726 
1727  self.parameter_names.append("HornCF4")
1728  self.parameter_units.append("")
1729  self.parameter_lower_limits.append(0)
1730  self.parameter_upper_limits.append(1)
1731  self.macro_commands.append("#HornCF4")
1732  self.macro_set_stages.append("PreInit")
1733 
1734  self.parameter_names.append("HornCF5")
1735  self.parameter_units.append("")
1736  self.parameter_lower_limits.append(0)
1737  self.parameter_upper_limits.append(1)
1738  self.macro_commands.append("#HornCF5")
1739  self.macro_set_stages.append("PreInit")
1740 
1741  self.parameter_names.append("HornCRadius1")
1742  self.parameter_units.append("mm")
1743  self.parameter_lower_limits.append(150)
1744  self.parameter_upper_limits.append(550)
1745  self.macro_commands.append("#HornCRadius1")
1746  self.macro_set_stages.append("PreInit")
1747 
1748  self.parameter_names.append("HornCRadius2")
1749  self.parameter_units.append("mm")
1750  self.parameter_lower_limits.append(20)
1751  self.parameter_upper_limits.append(300)
1752  self.macro_commands.append("#HornCRadius2")
1753  self.macro_set_stages.append("PreInit")
1754 
1755  self.parameter_names.append("HornCRadius3")
1756  self.parameter_units.append("mm")
1757  self.parameter_lower_limits.append(50)
1758  self.parameter_upper_limits.append(550)
1759  self.macro_commands.append("#HornCRadius3")
1760  self.macro_set_stages.append("PreInit")
1761 
1762  self.parameter_names.append("HornCRadiusOC")
1763  self.parameter_units.append("mm")
1764  self.parameter_lower_limits.append(300)
1765  self.parameter_upper_limits.append(650)
1766  self.macro_commands.append("#HornCRadiusOC")
1767  self.macro_set_stages.append("PreInit")
1768 
1769  self.parameter_names.append("HornCLongPosition")
1770  self.parameter_units.append("mm")
1771  self.parameter_lower_limits.append(4000)
1772  self.parameter_upper_limits.append(19000)
1773  self.macro_commands.append("#HornCLongPosition")
1774  self.macro_set_stages.append("PreInit")
1775 
1776  self.parameter_names.append("GraphiteTargetLength")
1777  self.parameter_units.append("m");
1778  self.parameter_lower_limits.append(0.5);
1779  self.parameter_upper_limits.append(2.0);
1780  self.macro_commands.append("/LBNE/det/GraphiteTargetLength");
1781  self.macro_set_stages.append("PreInit")
1782 
1783  self.parameter_names.append("GraphiteTargetFinWidth")
1784  self.parameter_units.append("mm");
1785  self.parameter_lower_limits.append(9);
1786  self.parameter_upper_limits.append(15);
1787  self.macro_commands.append("/LBNE/det/GraphiteTargetFinWidth");
1788  self.macro_set_stages.append("PreInit")
1789 
1790  self.parameter_names.append("BeamSigma")
1791  self.parameter_units.append("mm");
1792  self.parameter_lower_limits.append(1.6);
1793  self.parameter_upper_limits.append(2.5);
1794  self.macro_commands.append("/LBNE/generator/beamSigmaX");
1795  self.macro_set_stages.append("Idle")
1796 
1797  self.parameter_names.append("HornCurrent")
1798  self.parameter_units.append("kA");
1799  self.parameter_lower_limits.append(150);
1800  self.parameter_upper_limits.append(300);
1801  self.macro_commands.append("/LBNE/det/seHornCurrent")
1802  self.macro_set_stages.append("PreInit")
1803 
1804  self.parameter_names.append("ProtonEnergy")
1805  self.parameter_units.append("GeV");
1806  self.parameter_lower_limits.append(40);
1807  self.parameter_upper_limits.append(130);
1808  self.macro_commands.append("/LBNE/primary/protonMomentum")
1809  self.macro_set_stages.append("Idle")
1810 
1811  # Carbon fin target, three horn, no significant neck constraints, first horn is a cylinder (no downstream flare)
1812  if(optimizationName=="CP_run27"):
1813 
1814  self.parameter_names.append("HornALength")
1815  self.parameter_units.append("mm")
1816  self.parameter_lower_limits.append(1000)
1817  self.parameter_upper_limits.append(4500)
1818  self.macro_commands.append("#HornALength")
1819  self.macro_set_stages.append("PreInit")
1820 
1821  self.parameter_names.append("HornARadius1")
1822  self.parameter_units.append("mm")
1823  self.parameter_lower_limits.append(20)
1824  self.parameter_upper_limits.append(200)
1825  self.macro_commands.append("#HornARadius1")
1826  self.macro_set_stages.append("PreInit")
1827 
1828  self.parameter_names.append("HornARadiusOC")
1829  self.parameter_units.append("mm")
1830  self.parameter_lower_limits.append(300)
1831  self.parameter_upper_limits.append(650)
1832  self.macro_commands.append("#HornARadiusOC")
1833  self.macro_set_stages.append("PreInit")
1834 
1835  self.parameter_names.append("HornBLength")
1836  self.parameter_units.append("mm")
1837  self.parameter_lower_limits.append(2000)
1838  self.parameter_upper_limits.append(4500)
1839  self.macro_commands.append("#HornBLength")
1840  self.macro_set_stages.append("PreInit")
1841 
1842  self.parameter_names.append("HornBF1")
1843  self.parameter_units.append("")
1844  self.parameter_lower_limits.append(0)
1845  self.parameter_upper_limits.append(1)
1846  self.macro_commands.append("#HornBF1")
1847  self.macro_set_stages.append("PreInit")
1848 
1849  self.parameter_names.append("HornBF2")
1850  self.parameter_units.append("")
1851  self.parameter_lower_limits.append(0)
1852  self.parameter_upper_limits.append(1)
1853  self.macro_commands.append("#HornBF2")
1854  self.macro_set_stages.append("PreInit")
1855 
1856  self.parameter_names.append("HornBF3")
1857  self.parameter_units.append("")
1858  self.parameter_lower_limits.append(0)
1859  self.parameter_upper_limits.append(1)
1860  self.macro_commands.append("#HornBF3")
1861  self.macro_set_stages.append("PreInit")
1862 
1863  self.parameter_names.append("HornBF4")
1864  self.parameter_units.append("")
1865  self.parameter_lower_limits.append(0)
1866  self.parameter_upper_limits.append(1)
1867  self.macro_commands.append("#HornBF4")
1868  self.macro_set_stages.append("PreInit")
1869 
1870  self.parameter_names.append("HornBF5")
1871  self.parameter_units.append("")
1872  self.parameter_lower_limits.append(0)
1873  self.parameter_upper_limits.append(1)
1874  self.macro_commands.append("#HornBF5")
1875  self.macro_set_stages.append("PreInit")
1876 
1877  self.parameter_names.append("HornBRadius1")
1878  self.parameter_units.append("mm")
1879  self.parameter_lower_limits.append(50)
1880  self.parameter_upper_limits.append(200)
1881  self.macro_commands.append("#HornBRadius1")
1882  self.macro_set_stages.append("PreInit")
1883 
1884  self.parameter_names.append("HornBRadius2")
1885  self.parameter_units.append("mm")
1886  self.parameter_lower_limits.append(20)
1887  self.parameter_upper_limits.append(200)
1888  self.macro_commands.append("#HornBRadius2")
1889  self.macro_set_stages.append("PreInit")
1890 
1891  self.parameter_names.append("HornBRadius3")
1892  self.parameter_units.append("mm")
1893  self.parameter_lower_limits.append(50)
1894  self.parameter_upper_limits.append(550)
1895  self.macro_commands.append("#HornBRadius3")
1896  self.macro_set_stages.append("PreInit")
1897 
1898  self.parameter_names.append("HornBRadiusOC")
1899  self.parameter_units.append("mm")
1900  self.parameter_lower_limits.append(300)
1901  self.parameter_upper_limits.append(650)
1902  self.macro_commands.append("#HornBRadiusOC")
1903  self.macro_set_stages.append("PreInit")
1904 
1905  self.parameter_names.append("HornBLongPosition")
1906  self.parameter_units.append("mm")
1907  self.parameter_lower_limits.append(2000)
1908  self.parameter_upper_limits.append(17000)
1909  self.macro_commands.append("#HornBLongPosition")
1910  self.macro_set_stages.append("PreInit")
1911 
1912  self.parameter_names.append("HornCLength")
1913  self.parameter_units.append("mm")
1914  self.parameter_lower_limits.append(2000)
1915  self.parameter_upper_limits.append(4500)
1916  self.macro_commands.append("#HornCLength")
1917  self.macro_set_stages.append("PreInit")
1918 
1919  self.parameter_names.append("HornCF1")
1920  self.parameter_units.append("")
1921  self.parameter_lower_limits.append(0)
1922  self.parameter_upper_limits.append(1)
1923  self.macro_commands.append("#HornCF1")
1924  self.macro_set_stages.append("PreInit")
1925 
1926  self.parameter_names.append("HornCF2")
1927  self.parameter_units.append("")
1928  self.parameter_lower_limits.append(0)
1929  self.parameter_upper_limits.append(1)
1930  self.macro_commands.append("#HornCF2")
1931  self.macro_set_stages.append("PreInit")
1932 
1933  self.parameter_names.append("HornCF3")
1934  self.parameter_units.append("")
1935  self.parameter_lower_limits.append(0)
1936  self.parameter_upper_limits.append(1)
1937  self.macro_commands.append("#HornCF3")
1938  self.macro_set_stages.append("PreInit")
1939 
1940  self.parameter_names.append("HornCF4")
1941  self.parameter_units.append("")
1942  self.parameter_lower_limits.append(0)
1943  self.parameter_upper_limits.append(1)
1944  self.macro_commands.append("#HornCF4")
1945  self.macro_set_stages.append("PreInit")
1946 
1947  self.parameter_names.append("HornCF5")
1948  self.parameter_units.append("")
1949  self.parameter_lower_limits.append(0)
1950  self.parameter_upper_limits.append(1)
1951  self.macro_commands.append("#HornCF5")
1952  self.macro_set_stages.append("PreInit")
1953 
1954  self.parameter_names.append("HornCRadius1")
1955  self.parameter_units.append("mm")
1956  self.parameter_lower_limits.append(150)
1957  self.parameter_upper_limits.append(550)
1958  self.macro_commands.append("#HornCRadius1")
1959  self.macro_set_stages.append("PreInit")
1960 
1961  self.parameter_names.append("HornCRadius2")
1962  self.parameter_units.append("mm")
1963  self.parameter_lower_limits.append(20)
1964  self.parameter_upper_limits.append(300)
1965  self.macro_commands.append("#HornCRadius2")
1966  self.macro_set_stages.append("PreInit")
1967 
1968  self.parameter_names.append("HornCRadius3")
1969  self.parameter_units.append("mm")
1970  self.parameter_lower_limits.append(50)
1971  self.parameter_upper_limits.append(550)
1972  self.macro_commands.append("#HornCRadius3")
1973  self.macro_set_stages.append("PreInit")
1974 
1975  self.parameter_names.append("HornCRadiusOC")
1976  self.parameter_units.append("mm")
1977  self.parameter_lower_limits.append(300)
1978  self.parameter_upper_limits.append(650)
1979  self.macro_commands.append("#HornCRadiusOC")
1980  self.macro_set_stages.append("PreInit")
1981 
1982  self.parameter_names.append("HornCLongPosition")
1983  self.parameter_units.append("mm")
1984  self.parameter_lower_limits.append(4000)
1985  self.parameter_upper_limits.append(19000)
1986  self.macro_commands.append("#HornCLongPosition")
1987  self.macro_set_stages.append("PreInit")
1988 
1989  self.parameter_names.append("GraphiteTargetLength")
1990  self.parameter_units.append("m");
1991  self.parameter_lower_limits.append(0.5);
1992  self.parameter_upper_limits.append(2.0);
1993  self.macro_commands.append("/LBNE/det/GraphiteTargetLength");
1994  self.macro_set_stages.append("PreInit")
1995 
1996  self.parameter_names.append("GraphiteTargetFinWidth")
1997  self.parameter_units.append("mm");
1998  self.parameter_lower_limits.append(9);
1999  self.parameter_upper_limits.append(15);
2000  self.macro_commands.append("/LBNE/det/GraphiteTargetFinWidth");
2001  self.macro_set_stages.append("PreInit")
2002 
2003  self.parameter_names.append("BeamSigma")
2004  self.parameter_units.append("mm");
2005  self.parameter_lower_limits.append(1.6);
2006  self.parameter_upper_limits.append(2.5);
2007  self.macro_commands.append("/LBNE/generator/beamSigmaX");
2008  self.macro_set_stages.append("Idle")
2009 
2010  self.parameter_names.append("HornCurrent")
2011  self.parameter_units.append("kA");
2012  self.parameter_lower_limits.append(150);
2013  self.parameter_upper_limits.append(300);
2014  self.macro_commands.append("/LBNE/det/seHornCurrent")
2015  self.macro_set_stages.append("PreInit")
2016 
2017  self.parameter_names.append("ProtonEnergy")
2018  self.parameter_units.append("GeV");
2019  self.parameter_lower_limits.append(40);
2020  self.parameter_upper_limits.append(130);
2021  self.macro_commands.append("/LBNE/primary/protonMomentum")
2022  self.macro_set_stages.append("Idle")
2023 
2024 
2025  # Carbon fin target, three horn, no significant neck constraints, first horn is a cylinder (no downstream flare), tighter horn length constraints
2026  if(optimizationName in ["CP_run29","LE_run1","HE_run1"]):
2027 
2028  self.parameter_names.append("HornALength")
2029  self.parameter_units.append("mm")
2030  self.parameter_lower_limits.append(1000)
2031  self.parameter_upper_limits.append(3300)
2032  self.macro_commands.append("#HornALength")
2033  self.macro_set_stages.append("PreInit")
2034 
2035  self.parameter_names.append("HornARadius1")
2036  self.parameter_units.append("mm")
2037  self.parameter_lower_limits.append(20)
2038  self.parameter_upper_limits.append(200)
2039  self.macro_commands.append("#HornARadius1")
2040  self.macro_set_stages.append("PreInit")
2041 
2042  self.parameter_names.append("HornARadiusOC")
2043  self.parameter_units.append("mm")
2044  self.parameter_lower_limits.append(300)
2045  self.parameter_upper_limits.append(650)
2046  self.macro_commands.append("#HornARadiusOC")
2047  self.macro_set_stages.append("PreInit")
2048 
2049  self.parameter_names.append("HornBLength")
2050  self.parameter_units.append("mm")
2051  self.parameter_lower_limits.append(2000)
2052  self.parameter_upper_limits.append(3300)
2053  self.macro_commands.append("#HornBLength")
2054  self.macro_set_stages.append("PreInit")
2055 
2056  self.parameter_names.append("HornBF1")
2057  self.parameter_units.append("")
2058  self.parameter_lower_limits.append(0)
2059  self.parameter_upper_limits.append(1)
2060  self.macro_commands.append("#HornBF1")
2061  self.macro_set_stages.append("PreInit")
2062 
2063  self.parameter_names.append("HornBF2")
2064  self.parameter_units.append("")
2065  self.parameter_lower_limits.append(0)
2066  self.parameter_upper_limits.append(1)
2067  self.macro_commands.append("#HornBF2")
2068  self.macro_set_stages.append("PreInit")
2069 
2070  self.parameter_names.append("HornBF3")
2071  self.parameter_units.append("")
2072  self.parameter_lower_limits.append(0)
2073  self.parameter_upper_limits.append(1)
2074  self.macro_commands.append("#HornBF3")
2075  self.macro_set_stages.append("PreInit")
2076 
2077  self.parameter_names.append("HornBF4")
2078  self.parameter_units.append("")
2079  self.parameter_lower_limits.append(0)
2080  self.parameter_upper_limits.append(1)
2081  self.macro_commands.append("#HornBF4")
2082  self.macro_set_stages.append("PreInit")
2083 
2084  self.parameter_names.append("HornBF5")
2085  self.parameter_units.append("")
2086  self.parameter_lower_limits.append(0)
2087  self.parameter_upper_limits.append(1)
2088  self.macro_commands.append("#HornBF5")
2089  self.macro_set_stages.append("PreInit")
2090 
2091  self.parameter_names.append("HornBRadius1")
2092  self.parameter_units.append("mm")
2093  self.parameter_lower_limits.append(50)
2094  self.parameter_upper_limits.append(200)
2095  self.macro_commands.append("#HornBRadius1")
2096  self.macro_set_stages.append("PreInit")
2097 
2098  self.parameter_names.append("HornBRadius2")
2099  self.parameter_units.append("mm")
2100  self.parameter_lower_limits.append(20)
2101  self.parameter_upper_limits.append(200)
2102  self.macro_commands.append("#HornBRadius2")
2103  self.macro_set_stages.append("PreInit")
2104 
2105  self.parameter_names.append("HornBRadius3")
2106  self.parameter_units.append("mm")
2107  self.parameter_lower_limits.append(50)
2108  self.parameter_upper_limits.append(550)
2109  self.macro_commands.append("#HornBRadius3")
2110  self.macro_set_stages.append("PreInit")
2111 
2112  self.parameter_names.append("HornBRadiusOC")
2113  self.parameter_units.append("mm")
2114  self.parameter_lower_limits.append(300)
2115  self.parameter_upper_limits.append(650)
2116  self.macro_commands.append("#HornBRadiusOC")
2117  self.macro_set_stages.append("PreInit")
2118 
2119  self.parameter_names.append("HornBLongPosition")
2120  self.parameter_units.append("mm")
2121  self.parameter_lower_limits.append(2000)
2122  self.parameter_upper_limits.append(17000)
2123  self.macro_commands.append("#HornBLongPosition")
2124  self.macro_set_stages.append("PreInit")
2125 
2126  self.parameter_names.append("HornCLength")
2127  self.parameter_units.append("mm")
2128  self.parameter_lower_limits.append(2000)
2129  self.parameter_upper_limits.append(3300)
2130  self.macro_commands.append("#HornCLength")
2131  self.macro_set_stages.append("PreInit")
2132 
2133  self.parameter_names.append("HornCF1")
2134  self.parameter_units.append("")
2135  self.parameter_lower_limits.append(0)
2136  self.parameter_upper_limits.append(1)
2137  self.macro_commands.append("#HornCF1")
2138  self.macro_set_stages.append("PreInit")
2139 
2140  self.parameter_names.append("HornCF2")
2141  self.parameter_units.append("")
2142  self.parameter_lower_limits.append(0)
2143  self.parameter_upper_limits.append(1)
2144  self.macro_commands.append("#HornCF2")
2145  self.macro_set_stages.append("PreInit")
2146 
2147  self.parameter_names.append("HornCF3")
2148  self.parameter_units.append("")
2149  self.parameter_lower_limits.append(0)
2150  self.parameter_upper_limits.append(1)
2151  self.macro_commands.append("#HornCF3")
2152  self.macro_set_stages.append("PreInit")
2153 
2154  self.parameter_names.append("HornCF4")
2155  self.parameter_units.append("")
2156  self.parameter_lower_limits.append(0)
2157  self.parameter_upper_limits.append(1)
2158  self.macro_commands.append("#HornCF4")
2159  self.macro_set_stages.append("PreInit")
2160 
2161  self.parameter_names.append("HornCF5")
2162  self.parameter_units.append("")
2163  self.parameter_lower_limits.append(0)
2164  self.parameter_upper_limits.append(1)
2165  self.macro_commands.append("#HornCF5")
2166  self.macro_set_stages.append("PreInit")
2167 
2168  self.parameter_names.append("HornCRadius1")
2169  self.parameter_units.append("mm")
2170  self.parameter_lower_limits.append(150)
2171  self.parameter_upper_limits.append(550)
2172  self.macro_commands.append("#HornCRadius1")
2173  self.macro_set_stages.append("PreInit")
2174 
2175  self.parameter_names.append("HornCRadius2")
2176  self.parameter_units.append("mm")
2177  self.parameter_lower_limits.append(20)
2178  self.parameter_upper_limits.append(300)
2179  self.macro_commands.append("#HornCRadius2")
2180  self.macro_set_stages.append("PreInit")
2181 
2182  self.parameter_names.append("HornCRadius3")
2183  self.parameter_units.append("mm")
2184  self.parameter_lower_limits.append(50)
2185  self.parameter_upper_limits.append(550)
2186  self.macro_commands.append("#HornCRadius3")
2187  self.macro_set_stages.append("PreInit")
2188 
2189  self.parameter_names.append("HornCRadiusOC")
2190  self.parameter_units.append("mm")
2191  self.parameter_lower_limits.append(300)
2192  self.parameter_upper_limits.append(650)
2193  self.macro_commands.append("#HornCRadiusOC")
2194  self.macro_set_stages.append("PreInit")
2195 
2196  self.parameter_names.append("HornCLongPosition")
2197  self.parameter_units.append("mm")
2198  self.parameter_lower_limits.append(4000)
2199  self.parameter_upper_limits.append(19000)
2200  self.macro_commands.append("#HornCLongPosition")
2201  self.macro_set_stages.append("PreInit")
2202 
2203  self.parameter_names.append("GraphiteTargetLength")
2204  self.parameter_units.append("m");
2205  self.parameter_lower_limits.append(0.5);
2206  self.parameter_upper_limits.append(2.0);
2207  self.macro_commands.append("/LBNE/det/GraphiteTargetLength");
2208  self.macro_set_stages.append("PreInit")
2209 
2210  self.parameter_names.append("GraphiteTargetFinWidth")
2211  self.parameter_units.append("mm");
2212  self.parameter_lower_limits.append(9);
2213  self.parameter_upper_limits.append(15);
2214  self.macro_commands.append("/LBNE/det/GraphiteTargetFinWidth");
2215  self.macro_set_stages.append("PreInit")
2216 
2217  self.parameter_names.append("BeamSigma")
2218  self.parameter_units.append("mm");
2219  self.parameter_lower_limits.append(1.6);
2220  self.parameter_upper_limits.append(2.5);
2221  self.macro_commands.append("/LBNE/generator/beamSigmaX");
2222  self.macro_set_stages.append("Idle")
2223 
2224  self.parameter_names.append("HornCurrent")
2225  self.parameter_units.append("kA");
2226  self.parameter_lower_limits.append(150);
2227  self.parameter_upper_limits.append(300);
2228  self.macro_commands.append("/LBNE/det/seHornCurrent")
2229  self.macro_set_stages.append("PreInit")
2230 
2231  self.parameter_names.append("ProtonEnergy")
2232  self.parameter_units.append("GeV");
2233  self.parameter_lower_limits.append(40);
2234  self.parameter_upper_limits.append(130);
2235  self.macro_commands.append("/LBNE/primary/protonMomentum")
2236  self.macro_set_stages.append("Idle")
2237 
2238  # like CP_run29 (3 horn, numi target, cylindrical first horn)
2239  # but with longer horn lengths allowed
2240  if(optimizationName in ["CP_run30"]):
2241 
2242  self.parameter_names.append("HornALength")
2243  self.parameter_units.append("mm")
2244  self.parameter_lower_limits.append(1000)
2245  self.parameter_upper_limits.append(4000)
2246  self.macro_commands.append("#HornALength")
2247  self.macro_set_stages.append("PreInit")
2248 
2249  self.parameter_names.append("HornARadius1")
2250  self.parameter_units.append("mm")
2251  self.parameter_lower_limits.append(20)
2252  self.parameter_upper_limits.append(200)
2253  self.macro_commands.append("#HornARadius1")
2254  self.macro_set_stages.append("PreInit")
2255 
2256  self.parameter_names.append("HornARadiusOC")
2257  self.parameter_units.append("mm")
2258  self.parameter_lower_limits.append(300)
2259  self.parameter_upper_limits.append(650)
2260  self.macro_commands.append("#HornARadiusOC")
2261  self.macro_set_stages.append("PreInit")
2262 
2263  self.parameter_names.append("HornBLength")
2264  self.parameter_units.append("mm")
2265  self.parameter_lower_limits.append(2000)
2266  self.parameter_upper_limits.append(4000)
2267  self.macro_commands.append("#HornBLength")
2268  self.macro_set_stages.append("PreInit")
2269 
2270  self.parameter_names.append("HornBF1")
2271  self.parameter_units.append("")
2272  self.parameter_lower_limits.append(0)
2273  self.parameter_upper_limits.append(1)
2274  self.macro_commands.append("#HornBF1")
2275  self.macro_set_stages.append("PreInit")
2276 
2277  self.parameter_names.append("HornBF2")
2278  self.parameter_units.append("")
2279  self.parameter_lower_limits.append(0)
2280  self.parameter_upper_limits.append(1)
2281  self.macro_commands.append("#HornBF2")
2282  self.macro_set_stages.append("PreInit")
2283 
2284  self.parameter_names.append("HornBF3")
2285  self.parameter_units.append("")
2286  self.parameter_lower_limits.append(0)
2287  self.parameter_upper_limits.append(1)
2288  self.macro_commands.append("#HornBF3")
2289  self.macro_set_stages.append("PreInit")
2290 
2291  self.parameter_names.append("HornBF4")
2292  self.parameter_units.append("")
2293  self.parameter_lower_limits.append(0)
2294  self.parameter_upper_limits.append(1)
2295  self.macro_commands.append("#HornBF4")
2296  self.macro_set_stages.append("PreInit")
2297 
2298  self.parameter_names.append("HornBF5")
2299  self.parameter_units.append("")
2300  self.parameter_lower_limits.append(0)
2301  self.parameter_upper_limits.append(1)
2302  self.macro_commands.append("#HornBF5")
2303  self.macro_set_stages.append("PreInit")
2304 
2305  self.parameter_names.append("HornBRadius1")
2306  self.parameter_units.append("mm")
2307  self.parameter_lower_limits.append(50)
2308  self.parameter_upper_limits.append(200)
2309  self.macro_commands.append("#HornBRadius1")
2310  self.macro_set_stages.append("PreInit")
2311 
2312  self.parameter_names.append("HornBRadius2")
2313  self.parameter_units.append("mm")
2314  self.parameter_lower_limits.append(20)
2315  self.parameter_upper_limits.append(200)
2316  self.macro_commands.append("#HornBRadius2")
2317  self.macro_set_stages.append("PreInit")
2318 
2319  self.parameter_names.append("HornBRadius3")
2320  self.parameter_units.append("mm")
2321  self.parameter_lower_limits.append(50)
2322  self.parameter_upper_limits.append(550)
2323  self.macro_commands.append("#HornBRadius3")
2324  self.macro_set_stages.append("PreInit")
2325 
2326  self.parameter_names.append("HornBRadiusOC")
2327  self.parameter_units.append("mm")
2328  self.parameter_lower_limits.append(300)
2329  self.parameter_upper_limits.append(650)
2330  self.macro_commands.append("#HornBRadiusOC")
2331  self.macro_set_stages.append("PreInit")
2332 
2333  self.parameter_names.append("HornBLongPosition")
2334  self.parameter_units.append("mm")
2335  self.parameter_lower_limits.append(2000)
2336  self.parameter_upper_limits.append(17000)
2337  self.macro_commands.append("#HornBLongPosition")
2338  self.macro_set_stages.append("PreInit")
2339 
2340  self.parameter_names.append("HornCLength")
2341  self.parameter_units.append("mm")
2342  self.parameter_lower_limits.append(2000)
2343  self.parameter_upper_limits.append(4000)
2344  self.macro_commands.append("#HornCLength")
2345  self.macro_set_stages.append("PreInit")
2346 
2347  self.parameter_names.append("HornCF1")
2348  self.parameter_units.append("")
2349  self.parameter_lower_limits.append(0)
2350  self.parameter_upper_limits.append(1)
2351  self.macro_commands.append("#HornCF1")
2352  self.macro_set_stages.append("PreInit")
2353 
2354  self.parameter_names.append("HornCF2")
2355  self.parameter_units.append("")
2356  self.parameter_lower_limits.append(0)
2357  self.parameter_upper_limits.append(1)
2358  self.macro_commands.append("#HornCF2")
2359  self.macro_set_stages.append("PreInit")
2360 
2361  self.parameter_names.append("HornCF3")
2362  self.parameter_units.append("")
2363  self.parameter_lower_limits.append(0)
2364  self.parameter_upper_limits.append(1)
2365  self.macro_commands.append("#HornCF3")
2366  self.macro_set_stages.append("PreInit")
2367 
2368  self.parameter_names.append("HornCF4")
2369  self.parameter_units.append("")
2370  self.parameter_lower_limits.append(0)
2371  self.parameter_upper_limits.append(1)
2372  self.macro_commands.append("#HornCF4")
2373  self.macro_set_stages.append("PreInit")
2374 
2375  self.parameter_names.append("HornCF5")
2376  self.parameter_units.append("")
2377  self.parameter_lower_limits.append(0)
2378  self.parameter_upper_limits.append(1)
2379  self.macro_commands.append("#HornCF5")
2380  self.macro_set_stages.append("PreInit")
2381 
2382  self.parameter_names.append("HornCRadius1")
2383  self.parameter_units.append("mm")
2384  self.parameter_lower_limits.append(150)
2385  self.parameter_upper_limits.append(550)
2386  self.macro_commands.append("#HornCRadius1")
2387  self.macro_set_stages.append("PreInit")
2388 
2389  self.parameter_names.append("HornCRadius2")
2390  self.parameter_units.append("mm")
2391  self.parameter_lower_limits.append(20)
2392  self.parameter_upper_limits.append(300)
2393  self.macro_commands.append("#HornCRadius2")
2394  self.macro_set_stages.append("PreInit")
2395 
2396  self.parameter_names.append("HornCRadius3")
2397  self.parameter_units.append("mm")
2398  self.parameter_lower_limits.append(50)
2399  self.parameter_upper_limits.append(550)
2400  self.macro_commands.append("#HornCRadius3")
2401  self.macro_set_stages.append("PreInit")
2402 
2403  self.parameter_names.append("HornCRadiusOC")
2404  self.parameter_units.append("mm")
2405  self.parameter_lower_limits.append(300)
2406  self.parameter_upper_limits.append(650)
2407  self.macro_commands.append("#HornCRadiusOC")
2408  self.macro_set_stages.append("PreInit")
2409 
2410  self.parameter_names.append("HornCLongPosition")
2411  self.parameter_units.append("mm")
2412  self.parameter_lower_limits.append(4000)
2413  self.parameter_upper_limits.append(19000)
2414  self.macro_commands.append("#HornCLongPosition")
2415  self.macro_set_stages.append("PreInit")
2416 
2417  self.parameter_names.append("GraphiteTargetLength")
2418  self.parameter_units.append("m");
2419  self.parameter_lower_limits.append(0.5);
2420  self.parameter_upper_limits.append(2.0);
2421  self.macro_commands.append("/LBNE/det/GraphiteTargetLength");
2422  self.macro_set_stages.append("PreInit")
2423 
2424  self.parameter_names.append("GraphiteTargetFinWidth")
2425  self.parameter_units.append("mm");
2426  self.parameter_lower_limits.append(9);
2427  self.parameter_upper_limits.append(15);
2428  self.macro_commands.append("/LBNE/det/GraphiteTargetFinWidth");
2429  self.macro_set_stages.append("PreInit")
2430 
2431  self.parameter_names.append("BeamSigma")
2432  self.parameter_units.append("mm");
2433  self.parameter_lower_limits.append(1.6);
2434  self.parameter_upper_limits.append(2.5);
2435  self.macro_commands.append("/LBNE/generator/beamSigmaX");
2436  self.macro_set_stages.append("Idle")
2437 
2438  self.parameter_names.append("HornCurrent")
2439  self.parameter_units.append("kA");
2440  self.parameter_lower_limits.append(150);
2441  self.parameter_upper_limits.append(300);
2442  self.macro_commands.append("/LBNE/det/seHornCurrent")
2443  self.macro_set_stages.append("PreInit")
2444 
2445  self.parameter_names.append("ProtonEnergy")
2446  self.parameter_units.append("GeV");
2447  self.parameter_lower_limits.append(40);
2448  self.parameter_upper_limits.append(130);
2449  self.macro_commands.append("/LBNE/primary/protonMomentum")
2450  self.macro_set_stages.append("Idle")
2451 
2452  # like CP_run30 (3-horn, numi target, cylindrical first horn, longer horn lengths allowed, but with a cone allowed for the neck of Horn A rather than just a cylinder
2453  if(optimizationName in ["CP_run31"]):
2454 
2455  self.parameter_names.append("HornALength")
2456  self.parameter_units.append("mm")
2457  self.parameter_lower_limits.append(1000)
2458  self.parameter_upper_limits.append(4000)
2459  self.macro_commands.append("#HornALength")
2460  self.macro_set_stages.append("PreInit")
2461 
2462  self.parameter_names.append("HornARadius1")
2463  self.parameter_units.append("mm")
2464  self.parameter_lower_limits.append(20)
2465  self.parameter_upper_limits.append(200)
2466  self.macro_commands.append("#HornARadius1")
2467  self.macro_set_stages.append("PreInit")
2468 
2469  self.parameter_names.append("HornARadius2")
2470  self.parameter_units.append("mm")
2471  self.parameter_lower_limits.append(20)
2472  self.parameter_upper_limits.append(200)
2473  self.macro_commands.append("#HornARadius2")
2474  self.macro_set_stages.append("PreInit")
2475 
2476  self.parameter_names.append("HornARadiusOC")
2477  self.parameter_units.append("mm")
2478  self.parameter_lower_limits.append(300)
2479  self.parameter_upper_limits.append(650)
2480  self.macro_commands.append("#HornARadiusOC")
2481  self.macro_set_stages.append("PreInit")
2482 
2483  self.parameter_names.append("HornBLength")
2484  self.parameter_units.append("mm")
2485  self.parameter_lower_limits.append(2000)
2486  self.parameter_upper_limits.append(4000)
2487  self.macro_commands.append("#HornBLength")
2488  self.macro_set_stages.append("PreInit")
2489 
2490  self.parameter_names.append("HornBF1")
2491  self.parameter_units.append("")
2492  self.parameter_lower_limits.append(0)
2493  self.parameter_upper_limits.append(1)
2494  self.macro_commands.append("#HornBF1")
2495  self.macro_set_stages.append("PreInit")
2496 
2497  self.parameter_names.append("HornBF2")
2498  self.parameter_units.append("")
2499  self.parameter_lower_limits.append(0)
2500  self.parameter_upper_limits.append(1)
2501  self.macro_commands.append("#HornBF2")
2502  self.macro_set_stages.append("PreInit")
2503 
2504  self.parameter_names.append("HornBF3")
2505  self.parameter_units.append("")
2506  self.parameter_lower_limits.append(0)
2507  self.parameter_upper_limits.append(1)
2508  self.macro_commands.append("#HornBF3")
2509  self.macro_set_stages.append("PreInit")
2510 
2511  self.parameter_names.append("HornBF4")
2512  self.parameter_units.append("")
2513  self.parameter_lower_limits.append(0)
2514  self.parameter_upper_limits.append(1)
2515  self.macro_commands.append("#HornBF4")
2516  self.macro_set_stages.append("PreInit")
2517 
2518  self.parameter_names.append("HornBF5")
2519  self.parameter_units.append("")
2520  self.parameter_lower_limits.append(0)
2521  self.parameter_upper_limits.append(1)
2522  self.macro_commands.append("#HornBF5")
2523  self.macro_set_stages.append("PreInit")
2524 
2525  self.parameter_names.append("HornBRadius1")
2526  self.parameter_units.append("mm")
2527  self.parameter_lower_limits.append(50)
2528  self.parameter_upper_limits.append(200)
2529  self.macro_commands.append("#HornBRadius1")
2530  self.macro_set_stages.append("PreInit")
2531 
2532  self.parameter_names.append("HornBRadius2")
2533  self.parameter_units.append("mm")
2534  self.parameter_lower_limits.append(20)
2535  self.parameter_upper_limits.append(200)
2536  self.macro_commands.append("#HornBRadius2")
2537  self.macro_set_stages.append("PreInit")
2538 
2539  self.parameter_names.append("HornBRadius3")
2540  self.parameter_units.append("mm")
2541  self.parameter_lower_limits.append(50)
2542  self.parameter_upper_limits.append(550)
2543  self.macro_commands.append("#HornBRadius3")
2544  self.macro_set_stages.append("PreInit")
2545 
2546  self.parameter_names.append("HornBRadiusOC")
2547  self.parameter_units.append("mm")
2548  self.parameter_lower_limits.append(300)
2549  self.parameter_upper_limits.append(650)
2550  self.macro_commands.append("#HornBRadiusOC")
2551  self.macro_set_stages.append("PreInit")
2552 
2553  self.parameter_names.append("HornBLongPosition")
2554  self.parameter_units.append("mm")
2555  self.parameter_lower_limits.append(2000)
2556  self.parameter_upper_limits.append(17000)
2557  self.macro_commands.append("#HornBLongPosition")
2558  self.macro_set_stages.append("PreInit")
2559 
2560  self.parameter_names.append("HornCLength")
2561  self.parameter_units.append("mm")
2562  self.parameter_lower_limits.append(2000)
2563  self.parameter_upper_limits.append(4000)
2564  self.macro_commands.append("#HornCLength")
2565  self.macro_set_stages.append("PreInit")
2566 
2567  self.parameter_names.append("HornCF1")
2568  self.parameter_units.append("")
2569  self.parameter_lower_limits.append(0)
2570  self.parameter_upper_limits.append(1)
2571  self.macro_commands.append("#HornCF1")
2572  self.macro_set_stages.append("PreInit")
2573 
2574  self.parameter_names.append("HornCF2")
2575  self.parameter_units.append("")
2576  self.parameter_lower_limits.append(0)
2577  self.parameter_upper_limits.append(1)
2578  self.macro_commands.append("#HornCF2")
2579  self.macro_set_stages.append("PreInit")
2580 
2581  self.parameter_names.append("HornCF3")
2582  self.parameter_units.append("")
2583  self.parameter_lower_limits.append(0)
2584  self.parameter_upper_limits.append(1)
2585  self.macro_commands.append("#HornCF3")
2586  self.macro_set_stages.append("PreInit")
2587 
2588  self.parameter_names.append("HornCF4")
2589  self.parameter_units.append("")
2590  self.parameter_lower_limits.append(0)
2591  self.parameter_upper_limits.append(1)
2592  self.macro_commands.append("#HornCF4")
2593  self.macro_set_stages.append("PreInit")
2594 
2595  self.parameter_names.append("HornCF5")
2596  self.parameter_units.append("")
2597  self.parameter_lower_limits.append(0)
2598  self.parameter_upper_limits.append(1)
2599  self.macro_commands.append("#HornCF5")
2600  self.macro_set_stages.append("PreInit")
2601 
2602  self.parameter_names.append("HornCRadius1")
2603  self.parameter_units.append("mm")
2604  self.parameter_lower_limits.append(150)
2605  self.parameter_upper_limits.append(550)
2606  self.macro_commands.append("#HornCRadius1")
2607  self.macro_set_stages.append("PreInit")
2608 
2609  self.parameter_names.append("HornCRadius2")
2610  self.parameter_units.append("mm")
2611  self.parameter_lower_limits.append(20)
2612  self.parameter_upper_limits.append(300)
2613  self.macro_commands.append("#HornCRadius2")
2614  self.macro_set_stages.append("PreInit")
2615 
2616  self.parameter_names.append("HornCRadius3")
2617  self.parameter_units.append("mm")
2618  self.parameter_lower_limits.append(50)
2619  self.parameter_upper_limits.append(550)
2620  self.macro_commands.append("#HornCRadius3")
2621  self.macro_set_stages.append("PreInit")
2622 
2623  self.parameter_names.append("HornCRadiusOC")
2624  self.parameter_units.append("mm")
2625  self.parameter_lower_limits.append(300)
2626  self.parameter_upper_limits.append(650)
2627  self.macro_commands.append("#HornCRadiusOC")
2628  self.macro_set_stages.append("PreInit")
2629 
2630  self.parameter_names.append("HornCLongPosition")
2631  self.parameter_units.append("mm")
2632  self.parameter_lower_limits.append(4000)
2633  self.parameter_upper_limits.append(19000)
2634  self.macro_commands.append("#HornCLongPosition")
2635  self.macro_set_stages.append("PreInit")
2636 
2637  self.parameter_names.append("GraphiteTargetLength")
2638  self.parameter_units.append("m");
2639  self.parameter_lower_limits.append(0.5);
2640  self.parameter_upper_limits.append(2.0);
2641  self.macro_commands.append("/LBNE/det/GraphiteTargetLength");
2642  self.macro_set_stages.append("PreInit")
2643 
2644  self.parameter_names.append("GraphiteTargetFinWidth")
2645  self.parameter_units.append("mm");
2646  self.parameter_lower_limits.append(9);
2647  self.parameter_upper_limits.append(15);
2648  self.macro_commands.append("/LBNE/det/GraphiteTargetFinWidth");
2649  self.macro_set_stages.append("PreInit")
2650 
2651  self.parameter_names.append("BeamSigma")
2652  self.parameter_units.append("mm");
2653  self.parameter_lower_limits.append(1.6);
2654  self.parameter_upper_limits.append(2.5);
2655  self.macro_commands.append("/LBNE/generator/beamSigmaX");
2656  self.macro_set_stages.append("Idle")
2657 
2658  self.parameter_names.append("HornCurrent")
2659  self.parameter_units.append("kA");
2660  self.parameter_lower_limits.append(150);
2661  self.parameter_upper_limits.append(300);
2662  self.macro_commands.append("/LBNE/det/seHornCurrent")
2663  self.macro_set_stages.append("PreInit")
2664 
2665  self.parameter_names.append("ProtonEnergy")
2666  self.parameter_units.append("GeV");
2667  self.parameter_lower_limits.append(40);
2668  self.parameter_upper_limits.append(130);
2669  self.macro_commands.append("/LBNE/primary/protonMomentum")
2670  self.macro_set_stages.append("Idle")
2671 
2672  if(optimizationName in ["CP_realistic1"]):
2673 
2674  self.parameter_names.append("HornBLongPosition")
2675  self.parameter_units.append("mm")
2676  self.parameter_lower_limits.append(2000)
2677  self.parameter_upper_limits.append(17000)
2678  self.macro_commands.append("#HornBLongPosition")
2679  self.macro_set_stages.append("PreInit")
2680 
2681  self.parameter_names.append("HornCLongPosition")
2682  self.parameter_units.append("mm")
2683  self.parameter_lower_limits.append(4000)
2684  self.parameter_upper_limits.append(19000)
2685  self.macro_commands.append("#HornCLongPosition")
2686  self.macro_set_stages.append("PreInit")
2687 
2688  self.parameter_names.append("GraphiteTargetFinWidth")
2689  self.parameter_units.append("mm");
2690  self.parameter_lower_limits.append(9);
2691  self.parameter_upper_limits.append(15);
2692  self.macro_commands.append("/LBNE/det/GraphiteTargetFinWidth");
2693  self.macro_set_stages.append("PreInit")
2694 
2695  self.parameter_names.append("BeamSigma")
2696  self.parameter_units.append("mm");
2697  self.parameter_lower_limits.append(1.6);
2698  self.parameter_upper_limits.append(2.5);
2699  self.macro_commands.append("/LBNE/generator/beamSigmaX");
2700  self.macro_set_stages.append("Idle")
2701 
2702  self.parameter_names.append("HornCurrent")
2703  self.parameter_units.append("kA");
2704  self.parameter_lower_limits.append(200);
2705  self.parameter_upper_limits.append(300);
2706  self.macro_commands.append("/LBNE/det/seHornCurrent")
2707  self.macro_set_stages.append("PreInit")
2708 
2709  self.parameter_names.append("ProtonEnergy")
2710  self.parameter_units.append("GeV");
2711  self.parameter_lower_limits.append(40);
2712  self.parameter_upper_limits.append(130);
2713  self.macro_commands.append("/LBNE/primary/protonMomentum")
2714  self.macro_set_stages.append("Idle")
2715 
2716 
2717  # Fixed sphere optimization, loosened neck radii
2718  if(optimizationName=="CP_run26"):
2719 
2720  self.parameter_names.append("HornALength")
2721  self.parameter_units.append("mm")
2722  self.parameter_lower_limits.append(1000)
2723  self.parameter_upper_limits.append(4500)
2724  self.macro_commands.append("#HornALength")
2725  self.macro_set_stages.append("PreInit")
2726 
2727  self.parameter_names.append("HornAF1")
2728  self.parameter_units.append("")
2729  self.parameter_lower_limits.append(0.01)
2730  self.parameter_upper_limits.append(0.99)
2731  self.macro_commands.append("#HornAF1")
2732  self.macro_set_stages.append("PreInit")
2733 
2734  self.parameter_names.append("HornARadius1")
2735  self.parameter_units.append("mm")
2736  self.parameter_lower_limits.append(20)
2737  self.parameter_upper_limits.append(200)
2738  self.macro_commands.append("#HornARadius1")
2739  self.macro_set_stages.append("PreInit")
2740 
2741  self.parameter_names.append("HornARadius2")
2742  self.parameter_units.append("mm")
2743  self.parameter_lower_limits.append(20)
2744  self.parameter_upper_limits.append(200)
2745  self.macro_commands.append("#HornARadius2")
2746  self.macro_set_stages.append("PreInit")
2747 
2748  self.parameter_names.append("HornARadiusOC")
2749  self.parameter_units.append("mm")
2750  self.parameter_lower_limits.append(300)
2751  self.parameter_upper_limits.append(650)
2752  self.macro_commands.append("#HornARadiusOC")
2753  self.macro_set_stages.append("PreInit")
2754 
2755  self.parameter_names.append("HornBLength")
2756  self.parameter_units.append("mm")
2757  self.parameter_lower_limits.append(2000)
2758  self.parameter_upper_limits.append(4500)
2759  self.macro_commands.append("#HornBLength")
2760  self.macro_set_stages.append("PreInit")
2761 
2762  self.parameter_names.append("HornBF1")
2763  self.parameter_units.append("")
2764  self.parameter_lower_limits.append(0)
2765  self.parameter_upper_limits.append(1)
2766  self.macro_commands.append("#HornBF1")
2767  self.macro_set_stages.append("PreInit")
2768 
2769  self.parameter_names.append("HornBF2")
2770  self.parameter_units.append("")
2771  self.parameter_lower_limits.append(0)
2772  self.parameter_upper_limits.append(1)
2773  self.macro_commands.append("#HornBF2")
2774  self.macro_set_stages.append("PreInit")
2775 
2776  self.parameter_names.append("HornBF3")
2777  self.parameter_units.append("")
2778  self.parameter_lower_limits.append(0)
2779  self.parameter_upper_limits.append(1)
2780  self.macro_commands.append("#HornBF3")
2781  self.macro_set_stages.append("PreInit")
2782 
2783  self.parameter_names.append("HornBF4")
2784  self.parameter_units.append("")
2785  self.parameter_lower_limits.append(0)
2786  self.parameter_upper_limits.append(1)
2787  self.macro_commands.append("#HornBF4")
2788  self.macro_set_stages.append("PreInit")
2789 
2790  self.parameter_names.append("HornBF5")
2791  self.parameter_units.append("")
2792  self.parameter_lower_limits.append(0)
2793  self.parameter_upper_limits.append(1)
2794  self.macro_commands.append("#HornBF5")
2795  self.macro_set_stages.append("PreInit")
2796 
2797  self.parameter_names.append("HornBRadius1")
2798  self.parameter_units.append("mm")
2799  self.parameter_lower_limits.append(50)
2800  self.parameter_upper_limits.append(200)
2801  self.macro_commands.append("#HornBRadius1")
2802  self.macro_set_stages.append("PreInit")
2803 
2804  self.parameter_names.append("HornBRadius2")
2805  self.parameter_units.append("mm")
2806  self.parameter_lower_limits.append(20)
2807  self.parameter_upper_limits.append(200)
2808  self.macro_commands.append("#HornBRadius2")
2809  self.macro_set_stages.append("PreInit")
2810 
2811  self.parameter_names.append("HornBRadius3")
2812  self.parameter_units.append("mm")
2813  self.parameter_lower_limits.append(50)
2814  self.parameter_upper_limits.append(550)
2815  self.macro_commands.append("#HornBRadius3")
2816  self.macro_set_stages.append("PreInit")
2817 
2818  self.parameter_names.append("HornBRadiusOC")
2819  self.parameter_units.append("mm")
2820  self.parameter_lower_limits.append(300)
2821  self.parameter_upper_limits.append(650)
2822  self.macro_commands.append("#HornBRadiusOC")
2823  self.macro_set_stages.append("PreInit")
2824 
2825  self.parameter_names.append("HornBLongPosition")
2826  self.parameter_units.append("mm")
2827  self.parameter_lower_limits.append(2000)
2828  self.parameter_upper_limits.append(17000)
2829  self.macro_commands.append("#HornBLongPosition")
2830  self.macro_set_stages.append("PreInit")
2831 
2832  self.parameter_names.append("HornCLength")
2833  self.parameter_units.append("mm")
2834  self.parameter_lower_limits.append(2000)
2835  self.parameter_upper_limits.append(4500)
2836  self.macro_commands.append("#HornCLength")
2837  self.macro_set_stages.append("PreInit")
2838 
2839  self.parameter_names.append("HornCF1")
2840  self.parameter_units.append("")
2841  self.parameter_lower_limits.append(0)
2842  self.parameter_upper_limits.append(1)
2843  self.macro_commands.append("#HornCF1")
2844  self.macro_set_stages.append("PreInit")
2845 
2846  self.parameter_names.append("HornCF2")
2847  self.parameter_units.append("")
2848  self.parameter_lower_limits.append(0)
2849  self.parameter_upper_limits.append(1)
2850  self.macro_commands.append("#HornCF2")
2851  self.macro_set_stages.append("PreInit")
2852 
2853  self.parameter_names.append("HornCF3")
2854  self.parameter_units.append("")
2855  self.parameter_lower_limits.append(0)
2856  self.parameter_upper_limits.append(1)
2857  self.macro_commands.append("#HornCF3")
2858  self.macro_set_stages.append("PreInit")
2859 
2860  self.parameter_names.append("HornCF4")
2861  self.parameter_units.append("")
2862  self.parameter_lower_limits.append(0)
2863  self.parameter_upper_limits.append(1)
2864  self.macro_commands.append("#HornCF4")
2865  self.macro_set_stages.append("PreInit")
2866 
2867  self.parameter_names.append("HornCF5")
2868  self.parameter_units.append("")
2869  self.parameter_lower_limits.append(0)
2870  self.parameter_upper_limits.append(1)
2871  self.macro_commands.append("#HornCF5")
2872  self.macro_set_stages.append("PreInit")
2873 
2874  self.parameter_names.append("HornCRadius1")
2875  self.parameter_units.append("mm")
2876  self.parameter_lower_limits.append(150)
2877  self.parameter_upper_limits.append(550)
2878  self.macro_commands.append("#HornCRadius1")
2879  self.macro_set_stages.append("PreInit")
2880 
2881  self.parameter_names.append("HornCRadius2")
2882  self.parameter_units.append("mm")
2883  self.parameter_lower_limits.append(20)
2884  self.parameter_upper_limits.append(300)
2885  self.macro_commands.append("#HornCRadius2")
2886  self.macro_set_stages.append("PreInit")
2887 
2888  self.parameter_names.append("HornCRadius3")
2889  self.parameter_units.append("mm")
2890  self.parameter_lower_limits.append(50)
2891  self.parameter_upper_limits.append(550)
2892  self.macro_commands.append("#HornCRadius3")
2893  self.macro_set_stages.append("PreInit")
2894 
2895  self.parameter_names.append("HornCRadiusOC")
2896  self.parameter_units.append("mm")
2897  self.parameter_lower_limits.append(300)
2898  self.parameter_upper_limits.append(650)
2899  self.macro_commands.append("#HornCRadiusOC")
2900  self.macro_set_stages.append("PreInit")
2901 
2902  self.parameter_names.append("HornCLongPosition")
2903  self.parameter_units.append("mm")
2904  self.parameter_lower_limits.append(4000)
2905  self.parameter_upper_limits.append(19000)
2906  self.macro_commands.append("#HornCLongPosition")
2907  self.macro_set_stages.append("PreInit")
2908 
2909  # Seems that sphere target gets length from "GraphiteTargetLength""
2910  # even if its not graphite
2911  self.parameter_names.append("GraphiteTargetLength")
2912  self.parameter_units.append("m");
2913  self.parameter_lower_limits.append(0.5);
2914  self.parameter_upper_limits.append(2.0);
2915  self.macro_commands.append("/LBNE/det/GraphiteTargetLength");
2916  self.macro_set_stages.append("PreInit")
2917 
2918  self.parameter_names.append("MultiSphereTargetRadius")
2919  self.parameter_units.append("mm");
2920  self.parameter_lower_limits.append(7);
2921  self.parameter_upper_limits.append(15);
2922  self.macro_commands.append("/LBNE/det/MultiSphereTargetRadius");
2923  self.macro_set_stages.append("PreInit")
2924 
2925  self.parameter_names.append("BeamSigma")
2926  self.parameter_units.append("mm");
2927  self.parameter_lower_limits.append(1.6);
2928  self.parameter_upper_limits.append(2.5);
2929  self.macro_commands.append("/LBNE/generator/beamSigmaX");
2930  self.macro_set_stages.append("Idle")
2931 
2932  self.parameter_names.append("HornCurrent")
2933  self.parameter_units.append("kA");
2934  self.parameter_lower_limits.append(150);
2935  self.parameter_upper_limits.append(300);
2936  self.macro_commands.append("/LBNE/det/seHornCurrent")
2937  self.macro_set_stages.append("PreInit")
2938 
2939  self.parameter_names.append("ProtonEnergy")
2940  self.parameter_units.append("GeV");
2941  self.parameter_lower_limits.append(40);
2942  self.parameter_upper_limits.append(130);
2943  self.macro_commands.append("/LBNE/primary/protonMomentum")
2944  self.macro_set_stages.append("Idle")
2945 
2946 
2947 
2948  if(optimizationName == "power_test"):
2949  self.parameter_names.append("ProtonEnergy")
2950  self.parameter_units.append("GeV");
2951  self.parameter_lower_limits.append(40);
2952  self.parameter_upper_limits.append(130);
2953  self.macro_commands.append("/LBNE/primary/protonMomentum")
2954  self.macro_set_stages.append("Idle")
2955 
2956  if(optimizationName=="antinufrac_test"):
2957  self.parameter_names.append("AntinuFraction")
2958  self.parameter_units.append("");
2959  self.parameter_lower_limits.append(0);
2960  self.parameter_upper_limits.append(1);
2961  # This doesn't actually do anything to the macro
2962  # but store it there so it can be looked up with everything else
2963  self.macro_commands.append("#AntiNu Fraction");
2964  self.macro_set_stages.append("PreInit");
2965 
2966  self.h_nom_fhcnumu = None
2967  self.h_nom_fhcnumubar = None
2968  self.h_nom_rhcnumu = None
2969  self.h_nom_rhcnumubar = None
2970 
def __init__(self, optimizationName)
Definition: Optimizations.py:8
if(!yymsg) yymsg

Member Function Documentation

def Optimizations.Optimization.createRouletteWheel (   self,
  start_iter,
  stop_iter 
)

Definition at line 3154 of file Optimizations.py.

3154  def createRouletteWheel(self,start_iter, stop_iter):
3156  self.roulette_wheel = []
3157 
3158  total_fitness = 0
3159 
3160  print "Creating Roulette wheel for iterations ",start_iter,stop_iter
3161  for i in range(start_iter,stop_iter):
3162  fitness = self.getFitness(i)[1][0]
3163  if(fitness == -1):
3164  continue
3165  if fitness != 0:
3166  self.roulette_wheel.append([i,fitness])
3167 
3168 
3169  # find minimum fitness
3170  min_fitness = 1e40
3171  for entry in self.roulette_wheel:
3172  if entry[1] < min_fitness:
3173  min_fitness = entry[1]
3174 
3175 
3176  # subtract off minimum fitness
3177  print "Roulette_wheel",self.roulette_wheel
3178  for entry in self.roulette_wheel:
3179 
3180  entry[1] = pow(entry[1] - min_fitness,2)
3181  total_fitness = total_fitness + entry[1]
3182 
3183 
3184  # normalize to a total probability of 1
3185  for entry in self.roulette_wheel:
3186  entry[1] = entry[1]/total_fitness
3187 
3188  total_prob = 0
3189  for entry in self.roulette_wheel:
3190  total_prob = total_prob + entry[1]
3191  print "Total prob: ",total_prob
3192 
3193  self.roulette_wheel_start_iter = start_iter
3194  self.roulette_wheel_stop_iter = stop_iter
3195 
3196 
def getFitness(self, iteration, type="cp")
constexpr T pow(T x)
Definition: pow.h:72
def createRouletteWheel(self, start_iter, stop_iter)
if(!yymsg) yymsg
def Optimizations.Optimization.drawRouletteWheel (   self)

Definition at line 3197 of file Optimizations.py.

3198  canv = ROOT.TCanvas("MyCanvas","MyCanvas")
3199  self.createRouletteWheel(1,self.generation_size);
3200  vals = []
3201  names = []
3202  cols = []
3203  for entry in self.roulette_wheel:
3204  vals.append(entry[1])
3205  if(entry[0]%10==0):
3206  names.append(array('c',str(entry[0])+"\0"))
3207  else:
3208  names.append(array('c',"\0"))
3209  cols.append(entry[0]%10+1)
3210  a = array( 'l', map( lambda x: x.buffer_info()[0], names ) )
3211  pie1 = ROOT.TPie("pie1","Roulette Wheel",len(vals),array('f',vals),array('i',cols),a);
3212  pie1.GetSlice(1).SetFillStyle(3031);
3213  pie1.SetAngle3D(60);
3214  #pie1.SetLabelsOffset(-.1);
3215  pie1.Draw("3d t nol")
3216  canv.Print("roulette_wheel.eps");
3217 
3218 
3219 
3220 
auto array(Array const &a)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:228
def createRouletteWheel(self, start_iter, stop_iter)
if(!yymsg) yymsg
static QCString str
def Optimizations.Optimization.getEnergy (   self,
  iteration,
  mode 
)

Definition at line 2971 of file Optimizations.py.

2971  def getEnergy(self,iteration,mode):
2972  if not self.rhc_parameters_float_separate:
2973  power_iter = self.getParameterIndex("ProtonEnergy")
2974  if power_iter == -1: return 120.0
2975  params = self.readVariationFromMacros(iteration)
2976  return params[power_iter]
2977  else:
2978  power_iter = self.getParameterIndex(mode+"ProtonEnergy")
2979  if power_iter == -1: return 120.0
2980  params = self.readVariationFromMacros(iteration)
2981  return params[power_iter]
2982 
def readVariationFromMacros(self, iteration)
def getEnergy(self, iteration, mode)
def getParameterIndex(self, parameter_name)
def Optimizations.Optimization.getFitness (   self,
  iteration,
  type = "cp" 
)

Definition at line 3044 of file Optimizations.py.

3044  def getFitness(self,iteration,type="cp"):
3045 
3046  fitness_names = []
3047  fitnesses = [];
3048  fiterrors = [];
3049 
3050  mode_prefix = ""
3052  mode_prefix = "FHC"
3053 
3054  fitness_filename = self.output_location+"users/ljf26/fluxfiles/g4lbne/"+self.g4lbne_version+"/"+self.physics_list+"/Optimizations-"+self.optname+mode_prefix+"-"+str(int(iteration))+"/neutrino/flux/fitness_"+type+".txt"
3055 
3056  if(os.path.exists(fitness_filename)):
3057  try:
3058  lines = open(fitness_filename).readlines()
3059  fitness_string = lines[0]
3060  fitnesses = fitness_string.split()
3061  fiterror_string = lines[1]
3062  fiterrors = fiterror_string.split()
3063  for i in range(len(fitnesses)):
3064  fitnesses[i] = float(fitnesses[i].strip())
3065  fiterrors[i] = float(fiterrors[i].strip())
3066  except Exception,e :
3067  print "Warning: could not extract fitness from",fitness_filename
3068 
3069  if fitnesses == [] and fiterrors == []:
3070  os.remove(fitness_filename)
3071 
3072  if(len(fitnesses)==0):
3073 
3074  if self.optname.startswith("HE_"):
3075  rootfile = self.output_location+"users/ljf26/fluxfiles/g4lbne/"+self.g4lbne_version+"/"+self.physics_list+"/Optimizations-"+self.optname+"-"+str(int(iteration))+"/neutrino/flux/histos_g4lbne_"+self.g4lbne_version+"_"+self.physics_list+"_Optimizations-"+self.optname+"-"+str(iteration)+"_neutrino_LBNEFD_fastmc.root"
3076  tempfile = ROOT.TFile(rootfile)
3077  if tempfile.IsZombie():
3078  return [-1,-1]
3079  temphisto = tempfile.Get("numu_cceventrate")
3080  fiterror = ROOT.Double(0);
3081  fitness = temphisto.IntegralAndError(33,68,fiterror) # 0 to 10 GeV
3082  tempfile.Close()
3083  fitness_names.append("standard")
3084  fitnesses.append(fitness)
3085  fiterrors.append(fiterror)
3086 
3087  if self.optname.startswith("LE_"):
3088  rootfile = self.output_location+"users/ljf26/fluxfiles/g4lbne/"+self.g4lbne_version+"/"+self.physics_list+"/Optimizations-"+self.optname+"-"+str(int(iteration))+"/neutrino/flux/histos_g4lbne_"+self.g4lbne_version+"_"+self.physics_list+"_Optimizations-"+self.optname+"-"+str(iteration)+"_neutrino_LBNEFD_fastmc.root"
3089  tempfile = ROOT.TFile(rootfile)
3090  if tempfile.IsZombie():
3091  return [-1,-1]
3092  temphisto = tempfile.Get("numu_cceventrate")
3093  fiterror = ROOT.Double(0);
3094  fitness = temphisto.IntegralAndError(5,12,fiterror) # 0 to 10 GeV
3095  tempfile.Close()
3096  fitness_names.append("standard")
3097  fitnesses.append(fitness)
3098  fiterrors.append(fiterror)
3099 
3100  elif self.optname=="ME_run1":
3101  rootfile = self.output_location+"users/ljf26/fluxfiles/g4lbne/"+self.g4lbne_version+"/"+self.physics_list+"/Optimizations-"+self.optname+"-"+str(int(iteration))+"/200kA/flux/histos_g4lbne_"+self.g4lbne_version+"_"+self.physics_list+"_Optimizations-"+self.optname+"-"+str(int(iteration))+"_200kA_LBNEFD_fastmc.root"
3102 
3103  tempfile = ROOT.TFile(rootfile)
3104  if tempfile.IsZombie() or not tempfile.GetListOfKeys().Contains("numu_flux") :
3105  print "Found Zombie"
3106  return [["standard"],[-1],[-1]]
3107  temphisto = tempfile.Get("numu_flux")
3108 
3109 
3110  # look up power for this configuration
3111  pot_scale = OptimizationUtils.GetPowerPOTScaleFactor(self.getEnergy(iteration,"FHC"))
3112  temphisto.Scale(pot_scale)
3113 
3114  fiterror = ROOT.Double(0);
3115  fitness = temphisto.IntegralAndError(9,32,fiterror) # 1 to 4 GeV
3116  tempfile.Close()
3117  fitness_names.append("standard")
3118  fitnesses.append(fitness)
3119  fiterrors.append(fiterror)
3120 
3121  else:
3122 
3123 
3125  varfhcfile = self.output_location+"users/ljf26/fluxfiles/g4lbne/"+self.g4lbne_version+"/"+self.physics_list+"/Optimizations-"+self.optname+"FHC-"+str(int(iteration))+"/200kA/flux/histos_g4lbne_"+self.g4lbne_version+"_"+self.physics_list+"_Optimizations-"+self.optname+"FHC-"+str(int(iteration))+"_200kA_LBNEFD_fastmc.root"
3126  varrhcfile = self.output_location+"users/ljf26/fluxfiles/g4lbne/"+self.g4lbne_version+"/"+self.physics_list+"/Optimizations-"+self.optname+"RHC-"+str(int(iteration))+"/-200kA/flux/histos_g4lbne_"+self.g4lbne_version+"_"+self.physics_list+"_Optimizations-"+self.optname+"RHC-"+str(int(iteration))+"_-200kA_LBNEFD_fastmc.root"
3127  else:
3128  varfhcfile = self.output_location+"users/ljf26/fluxfiles/g4lbne/"+self.g4lbne_version+"/"+self.physics_list+"/Optimizations-"+self.optname+"-"+str(int(iteration))+"/neutrino/flux/histos_g4lbne_"+self.g4lbne_version+"_"+self.physics_list+"_Optimizations-"+self.optname+"-"+str(int(iteration))+"_neutrino_LBNEFD_fastmc.root"
3129  varrhcfile = self.output_location+"users/ljf26/fluxfiles/g4lbne/"+self.g4lbne_version+"/"+self.physics_list+"/Optimizations-"+self.optname+"-"+str(int(iteration))+"/antineutrino/flux/histos_g4lbne_"+self.g4lbne_version+"_"+self.physics_list+"_Optimizations-"+self.optname+"-"+str(int(iteration))+"_antineutrino_LBNEFD_fastmc.root"
3130 
3131  # scale to appropriate POT for the energy of for this configuration
3132  fhcenergy = self.getEnergy(iteration,"FHC")
3133  rhcenergy = self.getEnergy(iteration,"RHC")
3134 
3135  # look up antinu fraction for this configuration
3136  antinufrac = self.getParameterValue("AntinuFraction",iteration)
3137  if(antinufrac == -1): antinufrac = 0.5
3138 
3139  [fitness_names,fitnesses,fiterrors] = OptimizationUtils.ComputeMean75PercentSensitivityAndError(varfhcfile,varrhcfile,fhcenergy,rhcenergy,antinufrac,type)
3140 
3141  # Write new fitness file
3142  if(fitnesses[0]!=-1):
3143  fitnessfile = open(fitness_filename,"w")
3144  for i in range(len(fitnesses)):
3145  fitnessfile.write(str(fitnesses[i])+" ")
3146  fitnessfile.write("\n");
3147  for i in range(len(fiterrors)):
3148  fitnessfile.write(str(fiterrors[i])+" ")
3149  fitnessfile.write("\n");
3150  fitnessfile.close()
3151 
3152  return [fitness_names,fitnesses,fiterrors]
3153 
def getFitness(self, iteration, type="cp")
int open(const char *, int)
Opens a file descriptor.
def ComputeMean75PercentSensitivityAndError(varfhcfile, varrhcfile, fhcvarenergy=120.0, rhcvarenergy=120.0, antinufrac=0.5, quantity="cp")
def GetPowerPOTScaleFactor(energy)
def getEnergy(self, iteration, mode)
if(!yymsg) yymsg
def getParameterValue(self, parameter_name, iteration)
static QCString str
def Optimizations.Optimization.getKnobturns (   self)

Definition at line 3232 of file Optimizations.py.

3232  def getKnobturns(self):
3233  if self.knobturns == []:
3235  return self.knobturns
3236 
3237 
3238 
def Optimizations.Optimization.getLastGoodConfig (   self)

Definition at line 3035 of file Optimizations.py.

3036  try:
3038  lines = f.readlines()
3039  f.close()
3040  return int(lines[0].strip())
3041  except Exception,e:
3042  return 0;
3043 
int open(const char *, int)
Opens a file descriptor.
def Optimizations.Optimization.getNominalFitness (   self,
  type = "cp" 
)

Definition at line 2983 of file Optimizations.py.

2983  def getNominalFitness(self,type="cp"):
2984 
2985  fitness = []
2986  fiterror = []
2987 
2988  if self.optname.startswith("HE_"):
2989  nomdir = "/dune/data/users/ljf26/fluxfiles/g4lbne/v3r4p2/"+self.physics_list+"/Nominal"
2990  nomfile = nomdir+"/neutrino/flux/histos_g4lbne_v3r2p4_"+self.physics_list+"_Nominal_neutrino_LBNEFD_fastmc.root"
2991  if not os.path.exists(nomfile):
2992  print "WARNING: could not extract nominal fitness"
2993  else:
2994  tempfile = ROOT.TFile(nomfile)
2995  temphisto = tempfile.Get("numu_flux")
2996  fiterror = [ROOT.Double(0)];
2997  fitness = [temphisto.IntegralAndError(33,68,fiterror[0])] # 4 to 10 GeV
2998  tempfile.Close()
2999  elif self.optname.startswith("LE_"):
3000  nomdir = "/dune/data/users/ljf26/fluxfiles/g4lbne/v3r4p2/"+self.physics_list+"/Nominal"
3001  nomfile = nomdir+"/neutrino/flux/histos_g4lbne_v3r2p4_"+self.physics_list+"_Nominal_neutrino_LBNEFD_fastmc.root"
3002  if not os.path.exists(nomfile):
3003  print "WARNING: could not extract nominal fitness"
3004  else:
3005  tempfile = ROOT.TFile(nomfile)
3006  temphisto = tempfile.Get("numu_flux")
3007  fiterror = [ROOT.Double(0)];
3008  fitness = [temphisto.IntegralAndError(5,12,fiterror[0])] # 0.5 to 1.5 GeV
3009  tempfile.Close()
3010  elif self.optname.startswith("ME_"):
3011  nomdir = "/dune/data/users/ljf26/fluxfiles/g4lbne/v3r2p4/"+self.physics_list+"/Nominal"
3012  nomfile = nomdir+"/200kA/flux/histos_g4lbne_v3r2p4_"+self.physics_list+"_Nominal_200kA_LBNEFD_fastmc.root"
3013  if not os.path.exists(nomfile):
3014  print "WARNING: could not extract nominal fitness"
3015  else:
3016  tempfile = ROOT.TFile(nomfile)
3017  temphisto = tempfile.Get("numu_flux")
3018  fiterror = [ROOT.Double(0)];
3019  fitness = [temphisto.IntegralAndError(9,32,fiterror[0])]
3020  tempfile.Close()
3021  else:
3022  FMC_SENSIT = "/dune/data/users/lblpwg_tools/FastMC_Data/outputs/ljf26/Sensitivity_Plots"
3023  nh_cp_file = ROOT.TFile(FMC_SENSIT+"/ProtonP120GeV_nh_"+type+"_histos.root")
3024  ih_cp_file = ROOT.TFile(FMC_SENSIT+"/ProtonP120GeV_ih_"+type+"_histos.root")
3025 
3026  nh_sensitivity = OptimizationUtils.GetPercentile(nh_cp_file.Get("h2"),75)
3027  ih_sensitivity = OptimizationUtils.GetPercentile(ih_cp_file.Get("h2"),75)
3028  nh_cp_file.Close()
3029  ih_cp_file.Close()
3030 
3031  fiterror = [0,0,0]
3032  fitness = [(nh_sensitivity+ih_sensitivity) / 2,nh_sensitivity,ih_sensitivity]
3033  return [fitness,fiterror]
3034 
def getNominalFitness(self, type="cp")
def GetPercentile(histo, X)
def Optimizations.Optimization.getParameterIndex (   self,
  parameter_name 
)

Definition at line 3398 of file Optimizations.py.

3398  def getParameterIndex(self,parameter_name) :
3399  for i in range(0,len(self.parameter_names)):
3400  if self.parameter_names[i]==parameter_name:
3401  return i
3402  return -1
3403 
def getParameterIndex(self, parameter_name)
def Optimizations.Optimization.getParameterValue (   self,
  parameter_name,
  iteration 
)

Definition at line 3404 of file Optimizations.py.

3404  def getParameterValue(self,parameter_name,iteration) :
3405  val = -1
3406  val_iter = self.getParameterIndex(parameter_name)
3407  if val_iter == -1:
3408  return val
3409 
3410  params = self.readVariationFromMacros(iteration)
3411 
3412  return params[val_iter]
3413 
def readVariationFromMacros(self, iteration)
def getParameterIndex(self, parameter_name)
def getParameterValue(self, parameter_name, iteration)
def Optimizations.Optimization.mutate (   self,
  chromosome 
)

Definition at line 3278 of file Optimizations.py.

3278  def mutate(self,chromosome):
3279  print "starting mutate for chromosome with "+str(len(chromosome))+"genes"
3280 
3281  for i in range (0,len(chromosome)):
3282  gene = chromosome[i]
3283  mutation_probability = 0.1
3284  mutation_amplitude = 0.05;
3285  gaussian_width = (self.parameter_upper_limits[i]-self.parameter_lower_limits[i])*mutation_amplitude
3286  gaussian_mean = 0
3287 
3288  throw = random.random()
3289  if(throw < mutation_probability):
3290  chromosome[i] = gene + random.gauss(gaussian_mean,gaussian_width);
3291  while(chromosome[i]<self.parameter_lower_limits[i] or
3292  chromosome[i]>self.parameter_upper_limits[i]):
3293  chromosome[i] = gene + random.gauss(gaussian_mean,gaussian_width);
3294  return chromosome
3295 
def mutate(self, chromosome)
while(1)
Definition: code.cpp:12603
if(!yymsg) yymsg
static QCString str
def Optimizations.Optimization.pickRandomParent (   self)

Definition at line 3221 of file Optimizations.py.

3221  def pickRandomParent(self):
3222  random_number = random.random()
3223  total_roulette = 0
3224 
3225  for entry in self.roulette_wheel:
3226  total_roulette = total_roulette+entry[1]
3227  if total_roulette > random_number:
3228  return entry[0]
3229  print "ERROR: reached end of roulette wheel without picking an entry... something is wrong"
3230  sys.exit()
3231 
def Optimizations.Optimization.populateMacros (   self,
  low_iter,
  high_iter 
)

Definition at line 3296 of file Optimizations.py.

3296  def populateMacros(self,low_iter,high_iter):
3297  for i in range(low_iter,high_iter):
3298 
3299  random.seed(i+self.seed_offset)
3300 
3301  macro_output = "../../macros/Optimizations/"+self.optname+"/"+self.optname+"_"+str(i)+".mac"
3302 
3304  macro_output = "../../macros/Optimizations/"+self.optname+"FHC/"+self.optname+"FHC_"+str(i)+".mac"
3305  macro_outputRHC = "../../macros/Optimizations/"+self.optname+"RHC/"+self.optname+"RHC_"+str(i)+".mac"
3306 
3307  if high_iter>self.generation_size+1 and self.roulette_wheel_start_iter != (i-((i-1)%self.generation_size)-self.generation_size) and self.roulette_wheel_stop_iter != (i-((i-1)%self.generation_size)):
3308  self.createRouletteWheel((i-((i-1)%self.generation_size)-self.generation_size),(i-((i-1)%self.generation_size)))
3309 
3310  macro_template = "../../macros/OptimizedEngineeredJan2017.mac"
3311 
3312  if(not os.path.exists(macro_template)):
3313  print "I can't find macro template NoSnout.mac"
3314 
3315  # Write macro file
3316 
3317  n_macros_to_write = 1
3319  n_macros_to_write = 2
3320 
3321  for macro_num in range(n_macros_to_write):
3322 
3323  macro_name = macro_output
3324  if(macro_num==1):
3325  macro_name = macro_outputRHC
3326 
3327  print "Making",macro_name
3328 
3329  if not os.path.exists(os.path.dirname(macro_name)):
3330  os.makedirs(os.path.dirname(macro_name))
3331 
3332  good_configuration_found = False;
3333  n_configurations_tried = 0;
3334  if (macro_num == 0 and os.path.exists(macro_output)):
3335  print " ",os.path.basename(macro_output),"already exists... skipping"
3336  continue
3337  if (macro_num == 1 and os.path.exists(macro_outputRHC)):
3338  print " ",os.path.basename(macro_outputRHC),"already exists... skipping"
3339  continue
3340 
3341  while not good_configuration_found:
3342 
3343  # Get genetic values for parmeters
3344  new_values = []
3345  print i
3346  if(i<self.generation_size+1): # random values
3347  for par_iter in range(0,len(self.parameter_names)):
3348  new_values.append(random.uniform(self.parameter_lower_limits[par_iter],self.parameter_upper_limits[par_iter]))
3349  else:
3350  new_values = self.twoPointCrossover()
3351 
3352 
3353  parameter_prefix = ""
3355  parameter_prefix = "FHC"
3356  if(macro_num==1):
3357  parameter_prefix = "RHC"
3358 
3359  OptimizationUtils.MakeMacro(self,macro_template,macro_name,new_values, parameter_prefix)
3360 
3361 
3362  # Make sure the macro is good
3363  n_configurations_tried = n_configurations_tried + 1
3364  if not OptimizationUtils.ParametersOkay(self,i):
3365  continue
3366 
3367  # make sure it runs
3368  os.chdir("../..");
3369 
3370  os.system("pwd")
3371 
3372  temp_log_file = "BeamSimStudies/GeneticOptimization/"+os.path.basename(macro_name)+"temp.txt"
3373  if os.path.exists(temp_log_file):
3374  os.remove(temp_log_file)
3375 
3376  macro_status_code = os.system("./g4lbnf macros/Optimizations/"+self.optname+parameter_prefix+"/"+os.path.basename(macro_name)+" >& "+temp_log_file)
3377 
3378  has_overlap = False
3379  for line in open(temp_log_file):
3380  if "Overlap" in line:
3381  has_overlap = True
3382 
3383 
3384  if macro_status_code==0 and not has_overlap:
3385  good_configuration_found = True
3386  print "Found good configuration after",n_configurations_tried,"tries."
3387  else:
3388  print "g4lbne returned a nonzero status code for this macro... will try again"
3389  print "Here is the error output:"
3390  os.system("cat "+temp_log_file);
3391  print "Number of configurations tried:",n_configurations_tried
3392 
3393  os.remove(temp_log_file)
3394 
3395  os.chdir("BeamSimStudies/GeneticOptimization")
3396 
3397 
int open(const char *, int)
Opens a file descriptor.
def populateMacros(self, low_iter, high_iter)
def MakeMacro(optimization, macro_template, newmac_path, new_values, parameter_prefix="")
def ParametersOkay(optimization, i)
def createRouletteWheel(self, start_iter, stop_iter)
if(!yymsg) yymsg
static QCString str
def Optimizations.Optimization.readVariationFromMacros (   self,
  iteration 
)

Definition at line 3414 of file Optimizations.py.

3414  def readVariationFromMacros(self,iteration) :
3415 
3416  if not self.rhc_parameters_float_separate:
3417 
3418  macro = "../../../"+self.g4lbne_version+"/macros/Optimizations/"+self.optname+"/"+self.optname+"_"+str(int(iteration))+".mac"
3419 
3420  return_data = []
3421  if not os.path.exists(macro):
3422  return return_data
3423 
3424  tempknobturns = []
3425  for i in range(0,len(self.parameter_names)):
3426 
3427  parameter = self.parameter_names[i]
3428 
3429  macro_command = self.macro_commands[i]
3430  tempfile = open(macro)
3431  lines = tempfile.readlines()
3432  tempfile.close()
3433 
3434  par_found = False
3435  for line in lines:
3436  if line.startswith(macro_command+" "):
3437 
3438  par_value = line.split()[1]
3439  if par_value == "Fraction":
3440  par_value = line.split()[2]
3441  par_found = True
3442  tempknobturns.append(float(par_value))
3443  if not par_found:
3444  print "ERROR: Macro file",macro,"does not contain a line that changes",parameter," -- Something is wrong -- Quitting."
3445  sys.exit()
3446  return_data = tempknobturns
3447 
3448  else:
3449 
3450  return_data = []
3451 
3452  tempknobturns = []
3453 
3454  for mode in ["FHC","RHC"]:
3455  macro = "../../../"+self.g4lbne_version+"/macros/Optimizations/"+self.optname+mode+"/"+self.optname+mode+"_"+str(int(iteration))+".mac"
3456  if not os.path.exists(macro):
3457  continue
3458 
3459  tempfile = open(macro)
3460  lines = tempfile.readlines()
3461  tempfile.close()
3462 
3463  for i in range(0,len(self.parameter_names)):
3464  if not self.parameter_names[i].startswith(mode):
3465  continue
3466  parameter = self.parameter_names[i]
3467  macro_command = self.macro_commands[i]
3468 
3469  par_found = False
3470  for line in lines:
3471  if line.startswith(macro_command+" "):
3472  par_value = line.split()[1]
3473  if par_value == "Fraction":
3474  par_value = line.split()[2]
3475  par_found = True
3476 
3477  return_data.append(float(par_value))
3478  break
3479 
3480  return return_data
3481 
int open(const char *, int)
Opens a file descriptor.
def readVariationFromMacros(self, iteration)
static QCString str
def Optimizations.Optimization.readVariationsFromMacros (   self)

Definition at line 3482 of file Optimizations.py.

3483 
3484  mode_prefix = ""
3486  mode_prefix = "FHC"
3487 
3488  # Search for populated macros
3489  n_configs_not_found = 0
3490  n_configs = 1
3491  macros = []
3492 
3493  while n_configs_not_found < 100:
3494  macro = "../../../"+self.g4lbne_version+"/macros/Optimizations/"+self.optname+mode_prefix+"/"+self.optname+mode_prefix+"_"+str(n_configs)+".mac"
3495 
3496  if os.path.exists(macro):
3497  macros.append(macro)
3498  else:
3499  n_configs_not_found = n_configs_not_found + 1
3500  n_configs = n_configs + 1
3501 
3502  # loop over populated macros and extract data
3503  return_data = []
3504  for macro in macros:
3505 
3506  if "vrml" in macro or "Scan" in macro:
3507  continue
3508 
3509  iteration = float(macro.split("_")[len(macro.split("_"))-1].split(".")[0])
3510  tempknobturns = self.readVariationFromMacros(iteration)
3511  return_data.append([iteration,tempknobturns])
3512 
3513  self.knobturns = return_data
3514 
def readVariationFromMacros(self, iteration)
void split(std::string const &s, char c, OutIter dest)
Definition: split.h:35
if(!yymsg) yymsg
static QCString str
def Optimizations.Optimization.twoPointCrossover (   self)

Definition at line 3239 of file Optimizations.py.

3240 
3241  mom_iter = self.pickRandomParent()
3242  dad_iter = self.pickRandomParent()
3243 
3244  parent_parameters = self.getKnobturns()
3245 
3246  mom_parameters = []
3247  dad_parameters = []
3248  for entry in parent_parameters:
3249  if entry[0]== mom_iter:
3250  mom_parameters = entry[1]
3251  if entry[0]== dad_iter:
3252  dad_parameters = entry[1]
3253  if len(mom_parameters)==0 or len(dad_parameters)==0:
3254  print "ERROR: couldn't find mom or dad parameters... something is wrong"
3255  sys.exit()
3256 
3257  n_genes = len(self.parameter_names)
3258  position_a = 0.0
3259  position_b = 0.0
3260  while position_a == position_b:
3261  position_a = random.randint(1,n_genes)
3262  position_b = random.randint(position_a,n_genes)
3263 
3264  child_parameters = []
3265  for j in range(0,n_genes):
3266  if j < position_a or j>= position_b:
3267  child_parameters.append(mom_parameters[j])
3268  else:
3269  child_parameters.append(dad_parameters[j])
3270  if len(child_parameters) != n_genes:
3271  print "ERROR: child doesn't have the right number of genes... something is wrong"
3272  sys.exit()
3273 
3274  child_parameters = self.mutate(child_parameters)
3275 
3276  return child_parameters
3277 
def mutate(self, chromosome)

Member Data Documentation

Optimizations.Optimization.detector_location_name

Definition at line 30 of file Optimizations.py.

Optimizations.Optimization.g4lbne_version

Definition at line 32 of file Optimizations.py.

Optimizations.Optimization.generation_size

Definition at line 62 of file Optimizations.py.

Optimizations.Optimization.h_nom_fhcnumu

Definition at line 2966 of file Optimizations.py.

Optimizations.Optimization.h_nom_fhcnumubar

Definition at line 2967 of file Optimizations.py.

Optimizations.Optimization.h_nom_rhcnumu

Definition at line 2968 of file Optimizations.py.

Optimizations.Optimization.h_nom_rhcnumubar

Definition at line 2969 of file Optimizations.py.

Optimizations.Optimization.knobturns

Definition at line 24 of file Optimizations.py.

Optimizations.Optimization.last_completed_config_file

Definition at line 60 of file Optimizations.py.

Optimizations.Optimization.macro_commands

Definition at line 19 of file Optimizations.py.

Optimizations.Optimization.macro_set_stages

Definition at line 20 of file Optimizations.py.

Optimizations.Optimization.optname

Definition at line 14 of file Optimizations.py.

Optimizations.Optimization.output_location

Definition at line 56 of file Optimizations.py.

Optimizations.Optimization.parameter_lower_limits

Definition at line 17 of file Optimizations.py.

Optimizations.Optimization.parameter_names

Definition at line 15 of file Optimizations.py.

Optimizations.Optimization.parameter_units

Definition at line 16 of file Optimizations.py.

Optimizations.Optimization.parameter_upper_limits

Definition at line 18 of file Optimizations.py.

Optimizations.Optimization.physics_list

Definition at line 26 of file Optimizations.py.

Optimizations.Optimization.rhc_parameters_float_separate

Definition at line 64 of file Optimizations.py.

Optimizations.Optimization.roulette_wheel

Definition at line 21 of file Optimizations.py.

Optimizations.Optimization.roulette_wheel_start_iter

Definition at line 22 of file Optimizations.py.

Optimizations.Optimization.roulette_wheel_stop_iter

Definition at line 23 of file Optimizations.py.

Optimizations.Optimization.seed_offset

Definition at line 54 of file Optimizations.py.


The documentation for this class was generated from the following file: