LBNEDetectorConstruction.cc
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 // $Id: LBNEDetectorConstruction.cc,v 1.3.2.40 2013/12/24 20:31:46 lebrun Exp $
3 //---------------------------------------------------------------------------//
4 
5 #include <fstream>
6 #include <vector>
7 #include <string>
8 
10 
11 #include "G4UIdirectory.hh"
12 #include "G4UIcmdWithAString.hh"
13 #include "G4UIcmdWithABool.hh"
14 #include "G4UIcmdWithAnInteger.hh"
15 #include "G4UIcmdWithADoubleAndUnit.hh"
16 #include "G4UIcmdWithoutParameter.hh"
17 #include "G4UnitsTable.hh"
18 
19 #include "G4Material.hh"
20 #include "G4Box.hh"
21 #include "G4Tubs.hh"
22 #include "G4Polycone.hh"
23 #include "G4Trap.hh"
24 #include "G4Cons.hh"
25 #include "G4Torus.hh"
26 #include "G4LogicalVolume.hh"
27 #include "G4ThreeVector.hh"
28 #include "G4PVPlacement.hh"
29 #include "G4SubtractionSolid.hh"
30 #include "G4UnionSolid.hh"
31 #include "G4VisAttributes.hh"
32 #include "globals.hh"
33 #include "G4Transform3D.hh"
34 #include "G4RotationMatrix.hh"
35 #include "G4PVReplica.hh"
36 #include "G4AssemblyVolume.hh"
37 #include "LBNEMagneticField.hh"
39 #include "G4PhysicalVolumeStore.hh"
40 #include "G4LogicalVolumeStore.hh"
41 
42 #include "G4RegionStore.hh"
43 #include "G4SolidStore.hh"
44 #include "G4GeometryManager.hh"
45 #include "G4FieldManager.hh"
46 #include "LBNEVolumePlacements.hh"
47 #include "LBNEDetectorMessenger.hh"
48 #include "LBNERunManager.hh"
49 #include "G4GDMLParser.hh"
50 #include "G4UIcmdWithADouble.hh"
51 
52 #include "G4RunManager.hh"
53 
54 #include "G4VisExtent.hh"
55 
56 //---------------------------------------------------------------------------//
57 // Constructor, Destructor, and Initialization
58 //---------------------------------------------------------------------------//
59 
61 {
62  fPlacementHandler = LBNEVolumePlacements::Instance(); // Minimal setup for the Placement algorithm.
64 //
65  // Used only in placing the absorber..
66  fBeamlineAngle = -101*CLHEP::mrad;
68 
70  Initialize();
71  fHasBeenConstructed = false;
72 // Construct(); Not yet! Need to read the data card first...
73  fHornCurrent = 200.*CLHEP::ampere*1000; // in kA, defined via Detector GUImessenger if need be
74  fSkinDepthInnerRad = 1.0e10*CLHEP::mm; // infinitly long skin depth. (assume in default )
75  fDeltaEccentricityIO.resize(5); // max number of horns
76  fDeltaEllipticityI.resize(5); // max number of horns
78  fFileNameFieldMapForCE.resize(5);
79  fCurrentEqualizerQuadAmpl.resize(5);
80  fCurrentEqualizerOctAmpl.resize(5);
81  fCurrentMultiplier.resize(5);
82  for (size_t k=0; k!= fDeltaEccentricityIO.size(); k++) fDeltaEccentricityIO[k] = 0.;
83  for (size_t k=0; k!= fDeltaEllipticityI.size(); k++) fDeltaEllipticityI[k] = 0.;
84  for (size_t k=0; k!= fCurrentEqualizerLongAbsLength.size(); k++) fCurrentEqualizerLongAbsLength[k] = 0.;
85  for (size_t k=0; k!= fCurrentEqualizerQuadAmpl.size(); k++) fCurrentEqualizerQuadAmpl[k] = 0.;
86  for (size_t k=0; k!= fCurrentEqualizerOctAmpl.size(); k++) fCurrentEqualizerOctAmpl[k] = 0.;
87  for (size_t k=0; k!= fCurrentMultiplier.size(); k++) fCurrentMultiplier[k] = 1.;
88  for (size_t k=0; k!= fFileNameFieldMapForCE.size(); k++) fFileNameFieldMapForCE[k] = std::string("?");
89 //
90 // for Perfect Focusing setting.. All Pions tracks withh be destroyed and recereated with px = py =pz
91 // in Stepping Action, should the Post Step Z coord. be greater than..
92 //
93  fZCoordForPerfectFocusing = 3. * 13.5 * 1.e9 * 24.* 3600. * 365.25 * 3.0e8 *CLHEP::m; // There...
94  fConstructSimpAbsorber = false;
96  fDisableSpoiler = false;
97  fDisableSculptedLayers = false;
98  fDisableMask = false;
99  fExpandAlLayers = false;
100  fRemoveLayers = 0;
101  //
102  // August/September 2016. Under construction..
103  //
104  fConstructLBNFNano = false; // We do not want to depress Jim H., so, it is off..
110  fInstallLBNFNanoCerenkov = false;
112 
113 }
114 
115 
117 {
118 
120 
121  //for(size_t i = 0; i< fSubVolumes.size(); i++){
122  // delete fSubVolumes[i];
123  //}
124 
125  delete fDetectorMessenger;
126 // delete fPlacementHandler; A static struct now, no point deleting it
127 }
128 
129  // Obsolete.
131 {
132 // fDecayPipe = new LBNEDecayPipe("DecayPipe");
133 // fHadronAbsorber = new LBNEHadronAbsorber("HadronAbsorber");
134 // fStandardPerson = new LBNEStandardPerson("StandardPerson");
135  /*
136  fTarget = new LBNETarget();
137  fBaffle = new LBNEBaffle();
138  fHornAssembly = new LBNEHornAssembly();
139  fHadronAbsorber = new LBNEHadronAbsorber();
140  fTarget->SetDefaults();
141  fBaffle->SetDefaults();
142  fHornAssembly->SetDefaults();
143  fDecayPipe->SetDefaults();
144  fHadronAbsorber->SetDefaults();
145  */
146  // fSubVolumes.clear();
147 }
148 
150 {
151  // Set standard (and safe) values for class variables
152  fSimulationType = "Standard Neutrino Beam";
153  fConstructTarget = true;
154 
155 }
156 
157 
158 //-------------------------------------------------------------------------
159 
161 
162  G4Element* elH = new G4Element("Hydrogen","H" , 1., 1.01*CLHEP::g/CLHEP::mole);
163  new G4Element("Helium","He" , 2., 4.003*CLHEP::g/CLHEP::mole);
164  elC = new G4Element("Carbon","C" , 6., 12.01*CLHEP::g/CLHEP::mole);
165  elN = new G4Element("Nitrogen","N" , 7., 14.01*CLHEP::g/CLHEP::mole);
166  elO = new G4Element("Oxygen" ,"O" , 8., 16.00*CLHEP::g/CLHEP::mole);
167  G4Element* elNa = new G4Element("Sodium" ,"Na" , 11., 22.99*CLHEP::g/CLHEP::mole);
168  G4Element* elMg = new G4Element("Magnesium" ,"Mg" , 12., 24.305*CLHEP::g/CLHEP::mole);
169  G4Element* elAl = new G4Element("Aluminum" ,"Al" , 13., 26.98*CLHEP::g/CLHEP::mole);
170  G4Element* elSi = new G4Element("Silicon" ,"Si" , 14., 28.09*CLHEP::g/CLHEP::mole);
171  G4Element* elP = new G4Element("Phosphorus" ,"P" , 15., 30.974*CLHEP::g/CLHEP::mole);
172  G4Element* elS = new G4Element("Sulfur" ,"S" , 16., 32.065*CLHEP::g/CLHEP::mole);
173  G4Element* elK = new G4Element("Potassium" ,"K" , 19., 39.1*CLHEP::g/CLHEP::mole);
174  G4Element* elCa = new G4Element("Calcium" ,"Ca" , 20., 40.09*CLHEP::g/CLHEP::mole);
175  G4Element* elTi = new G4Element("Titanium" ,"Ti" , 22., 47.867*CLHEP::g/CLHEP::mole);
176  G4Element* elCr = new G4Element("Chromium" ,"Cr" , 24., 51.9961*CLHEP::g/CLHEP::mole);
177  G4Element* elMn = new G4Element("Manganese" ,"Mn" , 25., 54.938*CLHEP::g/CLHEP::mole);
178  elFe = new G4Element("Iron" ,"Fe" , 26., 55.85*CLHEP::g/CLHEP::mole);
179  G4Element* elNi = new G4Element("Nickel" ,"Ni" , 28., 58.6934*CLHEP::g/CLHEP::mole);
180  G4Element* elCu = new G4Element("Copper" ,"Cu" , 29., 63.546*CLHEP::g/CLHEP::mole);
181  G4Element* elHg = new G4Element("Mercury" ,"Hg" , 80., 200.59*CLHEP::g/CLHEP::mole);
182  G4Element* elMo = new G4Element("Molybdenum" ,"Mo" , 42., 95.96*CLHEP::g/CLHEP::mole);
183  G4Element* elNiob = new G4Element("Niobium" ,"Nb" , 41., 92.90637*CLHEP::g/CLHEP::mole);
184  G4Element* elCo = new G4Element("Cobalt" ,"Nb" , 27., 58.9932*CLHEP::g/CLHEP::mole);
185  G4Element* elV = new G4Element("Vanadium" ,"V" , 23, 50.9415*CLHEP::g/CLHEP::mole);
186 
187 
188  Air = new G4Material("Air" , 1.290*CLHEP::mg/CLHEP::cm3, 2);
189  Air->AddElement(elN, 0.7);
190  Air->AddElement(elO, 0.3);
191 
192  CT852 = new G4Material("CT852", 7.75*CLHEP::g/CLHEP::cm3, 10);
193  CT852->AddElement(elC, 0.001);
194  CT852->AddElement(elSi, 0.008);
195  CT852->AddElement(elMn, 0.008);
196  CT852->AddElement(elCr, 0.13);
197  CT852->AddElement(elS, 0.00025);
198  CT852->AddElement(elP, 0.0003);
199  CT852->AddElement(elTi, 0.002);
200  CT852->AddElement(elCu, 0.003);
201  CT852->AddElement(elNi, 0.006);
202  CT852->AddElement(elFe, 0.84145);
203 
204  Steel316 = new G4Material("Steel316", 8.0*CLHEP::g/CLHEP::cm3, 9);
205  // Reference: Google search, found Anderson Schumake company.
206  Steel316->AddElement(elC, 0.015);
207  Steel316->AddElement(elSi, 0.005);
208  Steel316->AddElement(elMn, 0.008);
209  Steel316->AddElement(elMo, 0.01);
210  Steel316->AddElement(elCr, 0.17);
211  Steel316->AddElement(elS, 0.00015);
212  Steel316->AddElement(elP, 0.0003);
213  Steel316->AddElement(elNi, 0.12);
214  Steel316->AddElement(elFe, 0.6716);
215 
216  Titanium = new G4Material("Titanium", 22, 47.867*CLHEP::g/CLHEP::mole, 4.506*CLHEP::g/CLHEP::cm3);
217 
218  TitaniumG5 = new G4Material("TitaniumG5", 4.42*CLHEP::g/CLHEP::cm3, 3);
219  TitaniumG5->AddElement(elAl, 0.06);
220  TitaniumG5->AddElement(elV, 0.04);
221  TitaniumG5->AddElement(elTi, 0.9);
222 
223  // ASTM836 steel
224  Slab_Stl = new G4Material("Slab_Stl", 7.8416*CLHEP::g/CLHEP::cm3, 6);
225  Slab_Stl->AddElement(elC, 0.001);
226  Slab_Stl->AddElement(elSi, 0.001);
227  Slab_Stl->AddElement(elMn, 0.004);
228  Slab_Stl->AddElement(elFe, 0.982);
229  Slab_Stl->AddElement(elNi, 0.01);
230  Slab_Stl->AddElement(elCu, 0.002);
231 
232  // BluBlock Steel
233  Blu_Stl = new G4Material("Blu_Stl", 7.25*CLHEP::g/CLHEP::cm3, 1);
234  Blu_Stl->AddElement(elFe, 1.0);
235 
236  Water = new G4Material("Water", 1.0*CLHEP::g/CLHEP::cm3, 2);
237  Water->AddElement(elH, 2);
238  Water->AddElement(elO, 1);
239 
240  Vacuum = new G4Material("Vacuum", 2.376e-15*CLHEP::g/CLHEP::cm3,1,kStateGas,300.*CLHEP::kelvin,2.0e-7*CLHEP::bar);
241  Vacuum->AddMaterial(Air, 1.);
242 
243  new G4Material("Helium", 2, 4.0026*CLHEP::g/CLHEP::mole, 2.55*0.1785*CLHEP::kg/CLHEP::m3, kStateGas,
244  300*CLHEP::kelvin, 2.55*CLHEP::atmosphere); // to fill the canister.For the decay pipe, see below.
245 
246  new G4Material("HeliumTarget", 2, 4.0026*CLHEP::g/CLHEP::mole, 1.7436*0.1785*CLHEP::kg/CLHEP::m3, kStateGas,
247  350*CLHEP::kelvin, 1.36*CLHEP::atmosphere); //20 psi. The factor of 1.7436 assume perfect gas.
248  // density proportional to temperature and pression.
249 
250  new G4Material("Aluminum", 13, 26.98*CLHEP::g/CLHEP::mole, 2.7*CLHEP::g/CLHEP::cm3);
251  new G4Material("Argon", 18, 39.948*CLHEP::g/CLHEP::mole, 1.784*CLHEP::kg/CLHEP::m3, kStateGas,
252  300*CLHEP::kelvin, CLHEP::atmosphere);
253  new G4Material("Lead", 82, 207.19*CLHEP::g/CLHEP::mole, 11.35*CLHEP::g/CLHEP::cm3);
254  new G4Material("Iron", 26, 55.85*CLHEP::g/CLHEP::mole, 7.86999*CLHEP::g/CLHEP::cm3);
255  new G4Material("Uranium", 92, 238.028*CLHEP::g/CLHEP::mole, 19.1*CLHEP::g/CLHEP::cm3);
256 
257  Concrete = new G4Material("Concrete", 2.03*CLHEP::g/CLHEP::cm3, 10);
258  Concrete->AddElement( elH, 0.01);
259  Concrete->AddElement( elO, 0.529);
260  Concrete->AddElement( elNa, 0.016);
261  Concrete->AddElement( elHg, 0.002);
262  Concrete->AddElement( elAl, 0.034);
263  Concrete->AddElement( elSi, 0.337);
264  Concrete->AddElement( elK, 0.013);
265  Concrete->AddElement( elCa, 0.044);
266  Concrete->AddElement( elFe, 0.014);
267  Concrete->AddElement( elC, 0.001);
268 
269  G4Material *rockMat = new G4Material( "rockMat", 2.78*CLHEP::g/CLHEP::cm3, 4 ); //CaMg(CO3)2
270  rockMat->AddElement( elCa, 1);
271  rockMat->AddElement( elMg, 1);
272  rockMat->AddElement( elC, 2);
273  rockMat->AddElement( elO, 6);
274 
275  G4Material *aluminaMat = new G4Material( "Alumina", 3.92*CLHEP::g/CLHEP::cm3, 2 ); //Al2O3 See
276  // http://www.ortechceramics.com/creamic-materials/alumina-ceramics/?gclid=CKnTttqOns0CFYM2aQod540Nhg
277  aluminaMat->AddElement( elAl, 2);
278  aluminaMat->AddElement( elO, 3);
279 
280  G4Material *inconelMat = new G4Material( "Inconel718", 8.1933*CLHEP::g/CLHEP::cm3, 8 );
281  // See http://wwwspecialmetals.com/ We take the middle range..
282  inconelMat->AddElement( elNi, 0.525);
283  inconelMat->AddElement( elCr, 0.19);
284  inconelMat->AddElement( elFe, 0.17925);
285  inconelMat->AddElement( elNiob, 0.05125);
286  inconelMat->AddElement( elMo, 0.0305);
287  inconelMat->AddElement( elTi, 0.009);
288  inconelMat->AddElement( elAl, 0.005);
289  inconelMat->AddElement( elCo, 0.01);
290 
291 
292  graphiteBaffle = new G4Material( "GraphiteBaffle", 1.78*CLHEP::g/CLHEP::cm3, 3 ); //Carbon, air (Nitrogen and oxygen)
293  graphiteBaffle->AddElement( elC, 0.99); //
294  graphiteBaffle->AddElement( elN, 0.007); //
295  graphiteBaffle->AddElement( elO, 0.003); //
296 
297  G4Material* graphite = new G4Material( "Graphite", 1.78*CLHEP::g/CLHEP::cm3, 3 ); //Carbon, air (Nitrogen and oxygen)
298  graphite->AddElement( elC, 0.99); //
299  graphite->AddElement( elN, 0.007); //
300  graphite->AddElement( elO, 0.003); //
301 
302  new G4Material("Beryllium", 4, 9.0122*CLHEP::g/CLHEP::mole, 1.85*CLHEP::g/CLHEP::cm3);
303 
304  G4Material *Mylar = new G4Material("Mylar", 1.397*CLHEP::g/CLHEP::cm3, 3);
305  Mylar->AddElement(elC, 10);
306  Mylar->AddElement(elH, 8);
307  Mylar->AddElement(elO, 4);
308 
309 }
310 //
311 // Declare the material for the target after the data cards have been read.
312 //
314  // In case they are different..
315  G4String aNameT(fPlacementHandler->GetTargetMaterialName());
316  if ((aNameT == G4String("Graphite")) || (aNameT == G4String("graphite")) ||
317  (aNameT == G4String("Carbon")) || (aNameT == G4String("carbon"))) {
318 
319  Target = new G4Material( "Target",
320  fPlacementHandler->GetTargetDensity(), 3 ); //Carbon, air (Nitrogen and oxigen),
321  // Assume density of POCO ZXF-5Q
322  Target->AddElement( elC, 0.99);
323  Target->AddElement( elN, 0.007);
324  Target->AddElement( elO, 0.003);
325  } else if ((aNameT == G4String("Beryllium"))
326  || (aNameT == G4String("beryllium"))) {
327  new G4Material("Target", 4, 9.0122*CLHEP::g/CLHEP::mole, 1.85*CLHEP::g/CLHEP::cm3);
328  // Set new specific nuclear interaction length
329  fPlacementHandler->SetTargetSpecificLambda(77.8*CLHEP::g/CLHEP::cm2);
330  // Let the placement handler know about the new target density
331  fPlacementHandler->SetTargetDensity(1.85*CLHEP::g/CLHEP::cm3);
332 
333  } else if ((aNameT == G4String("Aluminium"))
334  || (aNameT == G4String("aluminium"))) {
335  new G4Material("Target", 13, 26.98*CLHEP::g/CLHEP::mole, 2.7*CLHEP::g/CLHEP::cm3);
336  // Set new specific nuclear interaction length
337  fPlacementHandler->SetTargetSpecificLambda(107.2*CLHEP::g/CLHEP::cm2);
338  // Let the placement handler know about the new target density
339  fPlacementHandler->SetTargetDensity(2.7*CLHEP::g/CLHEP::cm3);
340 
341  } else if (aNameT == G4String("lightCarbon")) {
342  Target = new G4Material( "Target",
343  fPlacementHandler->GetTargetDensity()/100., 3 );
344  Target->AddElement( elC, 0.99);
345  Target->AddElement( elN, 0.007);
346  Target->AddElement( elO, 0.003);
347  } else {
348  G4String mess(" Non-standard material for the target: ");
349  mess += aNameT + G4String (" . \n");
350  mess += G4String("... Please upgrade the code after consultation with mechanical engineers\n.");
351  G4Exception("LBNEDetectorConstruction::InitializeMaterialsPostPreIdle",
352  " ", FatalErrorInArgument, mess.c_str());
353  }
354 
355  G4String aNameG(fPlacementHandler->GetDecayPipeGas());
356  if ((aNameG == G4String("Air")) || (aNameG == G4String("air"))) {
357  G4Material *gas = new G4Material("DecayPipeGas" , 1.290*CLHEP::mg/CLHEP::cm3, 2);
358  gas->AddElement(elN, 0.7);
359  gas->AddElement(elO, 0.3);
360  } else if ((aNameG == G4String("Helium")) || (aNameG == G4String("helium"))) {
361  new G4Material("DecayPipeGas", 2, 4.0026*CLHEP::g/CLHEP::mole, 0.1785*CLHEP::kg/CLHEP::m3, kStateGas,
362  300*CLHEP::kelvin, 1.0*CLHEP::atmosphere);
363  } else {
364  G4String mess(" Non-standard gas : ");
365  mess += aNameG + G4String (" in the decay pipe . \n");
366  mess += G4String("... Please upgrade the code after consultation with mechanical engineers\n. ");
367  G4Exception("LBNEDetectorConstruction::InitializeMaterialsPostPreIdle",
368  " ", FatalErrorInArgument, mess.c_str());
369  }
370 
371  if (fConstructLBNFNano) {
372  new G4Material("Silicon", 14, 28.0855*CLHEP::g/CLHEP::mole, 2.329*CLHEP::g/CLHEP::cm3);
373  G4Element* elSr = new G4Element("Strontium" ,"Sr" , 38., 87.62*CLHEP::g/CLHEP::mole);
374  G4Material* myFerrite = new G4Material("FerriteC8", 5.*CLHEP::g/CLHEP::cm3, 3);
375  myFerrite->AddElement(elSr, 1);
376  myFerrite->AddElement(elO, 19);
377  myFerrite->AddElement(elFe, 12);
378  }
379 
380  // For the 1st and possibly 2nd target modules. These are separated from the previous target
381  // material definitions so that the other target definitions are left unchanged. This repeats
382  // earlier code but allows us to define materials that won't interfere with the other target setups
383 
385 
386  G4String matName = fPlacementHandler->GetTargetMaterialName();
387  matName.toLower();
388 
389  // Define the Target1 material: elements, density, interaction lengths
390  // Allow graphite, beryllium, aluminium (low-Z)
391  if (matName == G4String("graphite")) {
392 
393  // Carbon, air (Nitrogen and oxygen), assume density of POCO ZXF-5Q
394  G4Material* target1 = new G4Material("Target1", 1.78*CLHEP::g/CLHEP::cm3, 3);
395  target1->AddElement(elC, 0.99);
396  target1->AddElement(elN, 0.007);
397  target1->AddElement(elO, 0.003);
398  fPlacementHandler->SetTargetSpecificLambda(85.8*CLHEP::g/CLHEP::cm2);
399  fPlacementHandler->SetTargetDensity(1.78*CLHEP::g/CLHEP::cm3);
400 
401  } else if (matName == G4String("beryllium")) {
402 
403  new G4Material("Target1", 4, 9.0122*CLHEP::g/CLHEP::mole, 1.85*CLHEP::g/CLHEP::cm3);
404  // Set new specific nuclear interaction length
405  fPlacementHandler->SetTargetSpecificLambda(77.8*CLHEP::g/CLHEP::cm2);
406  // Let the placement handler know about the new target density
407  fPlacementHandler->SetTargetDensity(1.85*CLHEP::g/CLHEP::cm3);
408 
409  } else if (matName == G4String("aluminium")) {
410 
411  new G4Material("Target1", 13, 26.98*CLHEP::g/CLHEP::mole, 2.7*CLHEP::g/CLHEP::cm3);
412  // Set new specific nuclear interaction length
413  fPlacementHandler->SetTargetSpecificLambda(107.2*CLHEP::g/CLHEP::cm2);
414  // Let the placement handler know about the new target density
415  fPlacementHandler->SetTargetDensity(2.7*CLHEP::g/CLHEP::cm3);
416 
417  }
418 
419  }
420 
422 
423  // Define the Target2 material. Allow either low or high Z:
424  // graphite, beryllium, aluminium, tungsten, tantalum, ...
425 
426  G4String matName = fPlacementHandler->GetTarget2MaterialName();
427  matName.toLower();
428  if (matName == G4String("graphite")) {
429 
430  // Carbon, air (Nitrogen and oxygen), assume density of POCO ZXF-5Q
431  G4Material* target2 = new G4Material("Target2", 1.78*CLHEP::g/CLHEP::cm3, 3);
432  target2->AddElement(elC, 0.99);
433  target2->AddElement(elN, 0.007);
434  target2->AddElement(elO, 0.003);
435  fPlacementHandler->SetTarget2SpecificLambda(85.8*CLHEP::g/CLHEP::cm2);
436  fPlacementHandler->SetTarget2Density(1.78*CLHEP::g/CLHEP::cm3);
437 
438  } else if (matName == G4String("beryllium")) {
439 
440  new G4Material("Target2", 4, 9.0122*CLHEP::g/CLHEP::mole, 1.85*CLHEP::g/CLHEP::cm3);
441  // Set new specific nuclear interaction length
442  fPlacementHandler->SetTarget2SpecificLambda(77.8*CLHEP::g/CLHEP::cm2);
443  // Let the placement handler know about the new target density
444  fPlacementHandler->SetTarget2Density(1.85*CLHEP::g/CLHEP::cm3);
445 
446  } else if (matName == G4String("aluminium")) {
447 
448  new G4Material("Target2", 13, 26.98*CLHEP::g/CLHEP::mole, 2.7*CLHEP::g/CLHEP::cm3);
449  // Set new specific nuclear interaction length
450  fPlacementHandler->SetTarget2SpecificLambda(107.2*CLHEP::g/CLHEP::cm2);
451  // Let the placement handler know about the new target density
452  fPlacementHandler->SetTarget2Density(2.7*CLHEP::g/CLHEP::cm3);
453 
454  } else if (matName == G4String("tantalum")) {
455 
456  new G4Material("Target2", 73, 180.94788*CLHEP::g/CLHEP::mole, 16.65*CLHEP::g/CLHEP::cm3);
457  // Nuclear interaction length
458  fPlacementHandler->SetTarget2SpecificLambda(191.0*CLHEP::g/CLHEP::cm2);
459  // Target density
460  fPlacementHandler->SetTarget2Density(16.65*CLHEP::g/CLHEP::cm3);
461 
462  } else if (matName == G4String("tungsten")) {
463 
464  new G4Material("Target2", 74, 183.84*CLHEP::g/CLHEP::mole, 19.3*CLHEP::g/CLHEP::cm3);
465  // Nuclear interaction length
466  fPlacementHandler->SetTarget2SpecificLambda(191.9*CLHEP::g/CLHEP::cm2);
467  // Target density
468  fPlacementHandler->SetTarget2Density(19.3*CLHEP::g/CLHEP::cm3);
469 
470  }
471 
472 
473 
474  }
475 
476 }
477 G4VisAttributes* LBNEDetectorConstruction::GetMaterialVisAttrib(G4String mName){
478  G4VisAttributes* visAtt;
479  if(mName == "Vacuum") visAtt = new G4VisAttributes(false);
480  else if(mName=="Aluminum") visAtt = new G4VisAttributes(G4Color(0.2, 0.8, 1));
481  else if(mName=="Air") visAtt = new G4VisAttributes(G4Color(0.6,0.7,0.8));
482  else if(mName=="Iron" || mName=="Slab_Stl") visAtt=new G4VisAttributes(G4Color(0.5,0.3,0));
483  else if(mName=="Concrete") visAtt = new G4VisAttributes(G4Color(0.75,0.85,0.95));
484  else visAtt = new G4VisAttributes(G4Color(1,0,0));
485  return visAtt;
486 }
487 
489 {
490  // Destroy all allocated elements and materials
491  size_t i;
492  G4MaterialTable* matTable = (G4MaterialTable*)G4Material::GetMaterialTable();
493  for(i=0;i<matTable->size();i++)
494  { delete (*(matTable))[i]; }
495  matTable->clear();
496  G4ElementTable* elemTable = (G4ElementTable*)G4Element::GetElementTable();
497  for(i=0;i<elemTable->size();i++)
498  { delete (*(elemTable))[i]; }
499  elemTable->clear();
500 }
501 
503 
504  if (fHasBeenConstructed) {
505  std::cerr << " WARNING: LBNEDetectorConstruction::Construct, already done, skip " << std::endl;
506  return fRock;
507  }
508 
510 
511  std::cout << " LBNEDetectorConstruction::Construct, Start !!! " << std::endl;
512  std::cerr << " LBNEDetectorConstruction::Construct, Start !!! " << std::endl;
513 
514  fRockX = 60.0*CLHEP::m;
515  fRockY = 60.0*CLHEP::m;
517 // std::cerr << " ............ fRockLength " << fRockLength << std::endl;
518 
519  // See LBNEVolumePlacements constructor.
520  G4Box* ROCK_solid = new G4Box("ROCK_solid",fRockX/2, fRockY/2, fRockLength/2);
521  G4LogicalVolume *RockLogical =
522  new G4LogicalVolume(ROCK_solid,
523  G4Material::GetMaterial("Concrete"),
524  "RockLogical",0,0,0);
525  fPlacementHandler->Initialize(RockLogical); // sort of a noop for now..
526  //RockLogical->SetVisAttributes(G4VisAttributes::Invisible);
527  fRock = new G4PVPlacement(0,G4ThreeVector(),RockLogical,"ROCK",0,false,0);
528 
529 
530  // First create the Target Hall, Pipe Hall, and Absorber Hall, and then
531  // connect them together.
533  LBNEVolumePlacementData *plTunnel =fPlacementHandler->Create(G4String("Tunnel"));
534  std::cerr << " Placement data for volume Tunnel, half length "
535  << plTunnel->fParams[2]/2. << " At z " << plTunnel->fPosition[2] << std::endl;
536  G4VPhysicalVolume* tunnel = fPlacementHandler->PlaceFinal(G4String("Tunnel"), fRock ); // like Rock, oversized. Air.
537 
539  fPlacementHandler->UpdateParamsForHorn1MotherPoly(); // This could change the length of Horn1..
540 
541  //
542  // Adjust first the mother volumes.
543  //
544  const size_t usedNumberOfHornsPoly = static_cast<size_t>(fPlacementHandler->GetNumberOfHornsPolycone());
545  const bool useHornsPolycone = usedNumberOfHornsPoly > 0;
546  bool implementHorn1AsLBNEHorn = !useHornsPolycone;// New, April 12 2016.
547  // The field map are expected to be the same for Horn1 except that the LBNF field map
548  // are more realistic.. Ellicpticity, eccentricity and imprefect current equalizer are in,
549  // optionally
550  if (useHornsPolycone) {
551  for (size_t iH=0; iH != usedNumberOfHornsPoly; iH++) {
553  }
554  }
556 
557  fPlacementHandler->ExtendChaseLengthForHorn2(); // Feb 2015: Optimization..
558 
559  LBNEVolumePlacementData *plTHAH = fPlacementHandler->Create(G4String("TargetHallAndHorn1"));
560  std::cerr << " Placement data for volume TargetHallAndHorn1, half length "
561  << plTHAH->fParams[2]/2. << " At z " << plTHAH->fPosition[2] << std::endl;
562  //
563  // Before placing the container volume for the target region + horn1, define these two volumes,
564  // as these two are adjacent. The boundary is "coordinate zero.", respecting older convention.
565  //
566  LBNEVolumePlacementData *plDatUTA = fPlacementHandler->Create(G4String("UpstreamTargetAssembly"));
567  std::cerr << " Placement data for volume UpstreamTargetAssembly, half length "
568  << plDatUTA->fParams[2]/2. << " At z " << plDatUTA->fPosition[2] << std::endl;
569 
570  // Is this needed ? I guess so.. but plH1Dat is not used anywhere.. for reference only..
571  fPlacementHandler->Create(G4String("Horn1Hall"));
572 
573  G4VPhysicalVolume* targethorn1Phys = fPlacementHandler->PlaceFinal(G4String("TargetHallAndHorn1"), tunnel);
574  std::cerr << " Detector Construction, TargetHallAndHorn1 is placed " << std::endl;
576  //
577  G4PVPlacement * upstreamTargetAssPhys =
578  fPlacementHandler->PlaceFinal(G4String("UpstreamTargetAssembly"), targethorn1Phys);
579  std::cerr << " Detector Construction, UpstreamTargetAssembly is placed " << std::endl;
580 
581  //
582  // Horn code. Include multiple Polycone horns..
583  //
584 
585  std::vector<G4PVPlacement*> vHornsAfterHornX; // where X is 1 or zero, depending if we define Horn1
586  // field as for LBNF CDR 2015.
587  LBNEVolumePlacementData *plH1PolyDat = fPlacementHandler->Create(G4String("Horn1PolyM1"));
588  G4PVPlacement *vHorn1 = fPlacementHandler->PlaceFinal(G4String("Horn1PolyM1"), targethorn1Phys);
589  std::cerr << " Horn1PolyM1 Half Length " << plH1PolyDat->fParams[2]/2. << " At position " << plH1PolyDat->fPosition[2] << std::endl;
591 
592  fPlacementHandler->PlaceFinalUpstrTarget((G4PVPlacement*) upstreamTargetAssPhys);
593  // Method is a misnomer, if after Aug 2014, as the target is no longer split up
594 
598  } else fPlacementHandler->PlaceFinalNoSplitHorn1((G4PVPlacement*) vHorn1, (G4PVPlacement*) targethorn1Phys);
599  if (implementHorn1AsLBNEHorn)
600  vHornsAfterHornX.push_back(0); // ==> not used for Horn1, used the old (LBNE < Summer 2015) magentic field.
601  else vHornsAfterHornX.push_back(vHorn1);
602  LBNEVolumePlacementData *plH2Dat = 0;
603  G4PVPlacement *vHorn2 = 0;
604  if (fPlacementHandler->GetUseCDR2015Optimized() || (!useHornsPolycone)
606  std::cerr << " Old Horn2 installation... " << std::endl;
607  plH2Dat = fPlacementHandler->Create(G4String("Horn2Hall"));
608 
609  vHorn2 = fPlacementHandler->PlaceFinal(G4String("Horn2Hall"), tunnel);
610 
612  } else {
613  //
614 // plH2Dat = fPlacementHandler->Create(G4String("LBNFChaseDwnstrHorn1"));
615 
616 // G4PVPlacement *vHorns = fPlacementHandler->PlaceFinal(G4String("LBNFChaseDwnstrHorn1"), tunnel);
617  std::cerr << " Polycone Horn2/Horn3 (or B & C) installation...usedNumberOfHornsPoly " << usedNumberOfHornsPoly << std::endl;
618  if (usedNumberOfHornsPoly > 1) {
619  for (size_t iH=1; iH != usedNumberOfHornsPoly; iH++) {
620  std::cerr << " ... Placing Horn " << (iH+1) << " in the tunnel.. " << std::endl;
621  std::ostringstream nameHStr; nameHStr << "LBNFSimpleHorn" << (iH+1) << "Container";
622  std::string nameH(nameHStr.str());
623  fPlacementHandler->Create(nameH);
624  G4PVPlacement *vHorn = fPlacementHandler->PlaceFinal(nameH, tunnel);
625  vHornsAfterHornX.push_back(vHorn); // to define the magnetic field.
626  std::cerr << " ... Mother volume placed... " << std::endl;
627  switch (iH) {
628  case 1:
633  break;
634  case 2:
639  break;
640  }
641  }
642  }
644  G4ThreeVector posTmp; posTmp[0] =0.; posTmp[1] =0.;
645  const double aRadIn = fPlacementHandler->GetPlugInnerRadius();
646  const double aRadOut = fPlacementHandler->GetPlugOuterRadius();
647  const double aLength = fPlacementHandler->GetPlugLength();
648  const std::string aPlugMaterial = fPlacementHandler->GetPlugMaterial();
649  G4Tubs* plugTube = new G4Tubs("PlugOr2ndTgt", aRadIn, aRadOut, aLength*.5, 0., 360.*CLHEP::deg);
650  G4LogicalVolume *plugl = new G4LogicalVolume(plugTube, G4Material::GetMaterial(aPlugMaterial.c_str()), "PlugOr2ndTgt");
651  posTmp[2] = fPlacementHandler->GetPlugZPosition();
652  G4String motherVolForPlug("TargetHallAndHorn1");
653  const LBNEVolumePlacementData *plH1Tmp =
654  fPlacementHandler->Find(G4String("ConstructPlug"), motherVolForPlug,
655  G4String("LBNEDetectorConstruction::Construct"));
656  const double zMinForPlug = plH1Tmp->fPosition[2] + plH1Tmp->fParams[2]/2.;
657  if ((fPlacementHandler->GetPlugZPosition() - aLength/2.- 0.5*CLHEP::mm) < zMinForPlug) {
658  posTmp[2] -= plH1Tmp->fPosition[2];
659  new G4PVPlacement((G4RotationMatrix *) 0, posTmp, plugl, "PlugOr2ndTgt_P",
660  targethorn1Phys->GetLogicalVolume(), false, 1, true);
661  std::cerr << " ..... Plug (e.g., 2nd target) installed in Horn1 starting at Z = " << posTmp[2]-aLength/2. << std::endl;
662  } else {
663  new G4PVPlacement((G4RotationMatrix *) 0, posTmp, plugl, "PlugOr2ndTgt_P",
664  tunnel->GetLogicalVolume(), false, 1, true);
665  std::cerr << " ..... Plug (e.g., 2nd target) installed in Tunnel starting at Z = " << posTmp[2]-aLength/2. << std::endl;
666  }
667  }
668  }
669  // We now turn on the magnetic fields
670  if (implementHorn1AsLBNEHorn) {
671  LBNEMagneticFieldHorn *fieldHorn1 = new LBNEMagneticFieldHorn(true);
672  fieldHorn1->SetHornCurrent(fHornCurrent);
674  // Not yet implemented via the old (non-Polycone ) geometry.
675 // if (std::abs(fDeltaEccentricityIO[0]) > 1.0e-6) fieldHorn1->SetDeltaEccentricityIO(fDeltaEccentricityIO[0]);
676 // if (std::abs(fDeltaEllipticityI[0]) > 1.0e-6) fieldHorn1->SetDeltaEllipticityI(fDeltaEllipticityI[0]);
677  G4FieldManager* aFieldMgr = new G4FieldManager(fieldHorn1); //create a local field
678  aFieldMgr->SetDetectorField(fieldHorn1); //set the field
679  aFieldMgr->CreateChordFinder(fieldHorn1); //create the objects which calculate the trajectory
680  const LBNEVolumePlacementData *plH1Dat =
681  fPlacementHandler->Find("FieldHorn1", "Horn1PolyM1", "DetectorConstruction");
682  plH1Dat->fCurrent->SetFieldManager(aFieldMgr,true); //attach the local field to logical volume
683  fieldHorn1->dumpField();
684  }
685  this->ConstructLBNEHorn1TrackingPlane(tunnel); //CAll the Horn1TrackingPlane Amit Bashyal
686  // Horn2
687  if ((!useHornsPolycone) || (fPlacementHandler->GetUseHorn1Polycone())
689  // UseHorn1Polycone was a flag that preceeded the use useHornsPolycones (plural)
690  // and the re-vamped UseCDR2015Optimized.. Convoluted..
691  LBNEMagneticFieldHorn *fieldHorn2 = new LBNEMagneticFieldHorn(false);
692  fieldHorn2->SetHornCurrent(fHornCurrent);
694  G4FieldManager* aFieldMgr2 = new G4FieldManager(fieldHorn2); //create a local field
695  aFieldMgr2->SetDetectorField(fieldHorn2); //set the field
696  aFieldMgr2->CreateChordFinder(fieldHorn2); //create the objects which calculate the trajectory
697  plH2Dat->fCurrent->SetFieldManager(aFieldMgr2,true); //attach the local field to logical volume
698 
699  this->ConstructLBNEHorn2TrackingPlane(tunnel); //Call the Horn2TrackingPlane Amit Bashyal
700  }
701  //
702  // Convoluted logic here...See above...
703  //
704  // variable numbers of horn1.. Typically, from 1 to 3. Horn2 already installed if UseCDR2015Optimized
705  //
707  (useHornsPolycone) || (fPlacementHandler->GetUseHorn1Polycone())) {
708  std::cerr << " Defining Polycone Mag field, usedNumberOfHornsPoly " << usedNumberOfHornsPoly << std::endl;
709  for (size_t iH=0; iH != usedNumberOfHornsPoly; iH++) {
710  if (implementHorn1AsLBNEHorn) continue;
712  std::ostringstream vStrStr; vStrStr << "LBNFSimpleHorn" << iH+1 << "Container";
713  std::string vStr(vStrStr.str());
714  if (iH == 0) vStr = std::string("Horn1PolyM1");
715  const LBNEVolumePlacementData *plHxPolyDat =
716  fPlacementHandler->Find(G4String("FieldSetting") , vStr.c_str(), "FieldSetting" );
717  const double zStart = plHxPolyDat->fPosition[2] - plHxPolyDat->fParams[2]/2.;
718  fieldHorn->SetZShiftDrawingCoordinate(zStart); // only used to produce the field map.
719  std::cerr << " Horn1 will start at Z =" << zStart << std::endl;
720  fieldHorn->SetEffectiveLength(plHxPolyDat->fParams[2]); // only used to produce the field map.
723  if (std::abs(fDeltaEccentricityIO[iH]) > 1.0e-20) fieldHorn->SetDeltaEccentricityIO(fDeltaEccentricityIO[iH]);
724  if (std::abs(fDeltaEllipticityI[iH]) > 1.0e-20) fieldHorn->SetDeltaEllipticityI(fDeltaEllipticityI[iH]);
725  if (std::abs(fCurrentEqualizerQuadAmpl[iH]) > 1.0e-20)
727  if (std::abs(fCurrentEqualizerOctAmpl[iH]) > 1.0e-20)
730  if (fFileNameFieldMapForCE[iH] != std::string("?"))
732  G4FieldManager* aFieldMgr = new G4FieldManager(fieldHorn); //create a local field
733  aFieldMgr->SetDetectorField(fieldHorn); //set the field
734  aFieldMgr->CreateChordFinder(fieldHorn); //create the objects which calculate the trajectory
735  //
736  // If the Inner conductors are a bit elliptical, then one expect a small dipole field in the so-called field-free region,
737  // inside the the voume comprised by the inner-inner conductor shape.
738  //
739  if ((iH == 0) && ((std::abs(fDeltaEllipticityI[iH]) > 1.0e-6) || std::abs(fDeltaEccentricityIO[iH] > 1.0e-6)) ) {
740  targethorn1Phys->GetLogicalVolume()->SetFieldManager(aFieldMgr,true);
741  std::cerr << " Magnetic field attached to volume " <<
742  targethorn1Phys->GetLogicalVolume()->GetName() << " Expecting field inside inner inner conductor " << std::endl;
743  } else {
744  vHornsAfterHornX[iH]->GetLogicalVolume()->SetFieldManager(aFieldMgr,true); //attach the local field to logical volume
745  std::cerr << " Magnetic field attached to volume " <<
746  vHornsAfterHornX[iH]->GetLogicalVolume()->GetName() << std::endl;
747  }
748  //
749  // Some testing.. Now the horn current is turned on and eventual correction term are uploaded.
750  //
751 // if (iH == 1) {
752 // fieldHorn->TestDivergence(0);
753 // fieldHorn->TestDivergence(1);
754 // fieldHorn->TestDivergence(2);
755 // }
756 // if (iH == 0) {
757 // std::cerr << " Generating field map Horn A " << std::endl;
758 // fieldHorn->dumpField();
759 // }
760  }
761  }
762  // we forgot the baffle. So we install it now, that's O.K., but only conditonally.
763  // Agust 1 2016 : Laura asked us to remove it, as it confused the study of the neutrino flux with
764  // Conceptual Design HornA. What did shift the baffle upstream by 17.8 cm., compare to the simple optimized horn.
765  //
768  fPlacementHandler->Create(G4String("Baffle"));
769  // This will be a surveyed elements, but let us skip this step for now.
770  fPlacementHandler->PlaceFinal(G4String("Baffle"), upstreamTargetAssPhys);
771  fPlacementHandler->Create(G4String("BaffleWindowUpstr"));
772  // This will be a surveyed elements, but let us skip this step for now.
773  fPlacementHandler->PlaceFinal(G4String("BaffleWindowUpstr"), upstreamTargetAssPhys);
774  fPlacementHandler->Create(G4String("BaffleWindowDownstr"));
775  // This will be a surveyed elements, but let us skip this step for now.
776  fPlacementHandler->PlaceFinal(G4String("BaffleWindowDownstr"), upstreamTargetAssPhys);
777  }
778  //
779  // Place the decay Pipe Snout, which contains the window, in case we have Helium gas.
780  //
782  fPlacementHandler->Create(G4String("DecayPipeSnout")); // Now in Snout region
783  fPlacementHandler->PlaceFinalDecayPipeSnout((G4PVPlacement*) tunnel);
784  }
785  //
786  // Place the LBNFNano Spectrometer
787  // Not yet uploaded in the repository.
788  //
789  // if (fConstructLBNFNano) this->DoConstructLBNFNano(); // most of volume parameters are hardtyped...
790  //
791  // Place the decay pipe
792  //
793  fPlacementHandler->Create(G4String("DecayPipeHall"));
794  G4PVPlacement *vDecayPipe = fPlacementHandler->PlaceFinal(G4String("DecayPipeHall"), tunnel);
795  fPlacementHandler->Create(G4String("DecayPipeConcrete"));
796  fPlacementHandler->Create(G4String("DecayPipeOuterWall"));
797  fPlacementHandler->Create(G4String("DecayPipeWall"));
798  fPlacementHandler->Create(G4String("DecayPipeVolume"));
799  // fPlacementHandler->Create(G4String("DecayPipeUpstrWindow")); // Now in Snout region
800  this->ConstructLBNEDecayPipeTrackingPlane(tunnel); //Amit Bashyal
801 
802  fPlacementHandler->PlaceFinal(G4String("DecayPipeConcrete"), vDecayPipe);
803  fPlacementHandler->PlaceFinal(G4String("DecayPipeOuterWall"), vDecayPipe);
804  fPlacementHandler->PlaceFinal(G4String("DecayPipeWall"), vDecayPipe);
805  fPlacementHandler->PlaceFinal(G4String("DecayPipeVolume"), vDecayPipe);
806  //
807  // March 2015: Milind Diwan suggested to install a wire down the beam pipe.
808  //
810 
811  LBNEMagneticFieldDecayPipe *fieldDecayPipe = new LBNEMagneticFieldDecayPipe(false); // we use the horn field
814  G4FieldManager* aFieldMgr3 = new G4FieldManager(fieldDecayPipe); //create a local field
815  aFieldMgr3->SetDetectorField(fieldDecayPipe); //set the field
816  aFieldMgr3->CreateChordFinder(fieldDecayPipe); //create the objects which calculate the trajectory
817  const LBNEVolumePlacementData *plDCV =
818  fPlacementHandler->Find("FieldDecayPipe", "DecayPipeVolume", "DetectorConstruction");
819  plDCV->fCurrent->SetFieldManager(aFieldMgr3,true); //attach the local field to logical volume
820  }
821 
822  //Define geometry absorber from /LBNE/det/ConstructSimpAbsorber true/false option
823  if (!fConstructLBNFNano) {
824  if (this->fConstructSimpAbsorber){
825  this->ConstructLBNEHadronAbsorberSimple(tunnel);
826  }
827  else if (this->fConstructSculptedAbsorber){
829  } else {
830  this->ConstructLBNEHadronAbsorber(tunnel);
831 
832  }
833  }
835  this->ConstructLBNEShieldingHorn1(targethorn1Phys);
836  if ((!useHornsPolycone) || (fPlacementHandler->GetUseHorn1Polycone())) {
837  this->ConstructLBNEShieldingHorn2(vHorn2);
839  } else {
840  this->ConstructLBNFShielding(tunnel);
841  }
842  }
843  }
844  else {
845 
846  DropMarsTargetHorns(tunnel);
847 
848  }
849 
850  fHasBeenConstructed = true;
851 
853  G4GDMLParser Parser;
854  Parser.Write("g4lbnf.gdml",tunnel);
855  }
856 
857  return fRock;
858 }
860 {
861 
862  G4cout << "Importing hadron absorber gdml file... " << G4endl;
863 
865  std::ifstream gdmlfile(filename.c_str());
866  if (!gdmlfile.is_open()) {
867  std::string mess(" AbsorberGDML file ");
868  mess += filename + G4String(" could not be found \n");
869  G4Exception("LBNEDetectorConstruction::ConstructLBNEHadronAbsorber", " ",
870  FatalErrorInArgument, mess.c_str());
871  return; // perfunctory.
872 
873  } else {
874  gdmlfile.close();
875  }
876  G4GDMLParser parser;
877  parser.Read( filename );
878  //std::cerr << " And stop after parsing the gdml file " << std::endl; exit(2);
879 
880  G4LogicalVolume *topAbs = parser.GetVolume( "TOP" );
881  // We dump the volume hierarchy. Hoopefully not too deep,
882  /*
883  for (int i=0; i != topAbs->GetNoDaughters(); ++i) {
884  G4VPhysicalVolume *pVol = topAbs->GetDaughter(i);
885  G4LogicalVolume *lVol = pVol->GetLogicalVolume();
886  std::cerr << " Top level daughter # " << i << " Name " << lVol->GetName()
887  << " at " << pVol->GetObjectTranslation() << std::endl;
888  if (lVol->GetName().find("Airbox") != std::string::npos) {
889  G4Box *aBox = static_cast<G4Box*>(lVol->GetSolid());
890  std::cerr << " Airbox size " << aBox->GetXHalfLength()
891  << " / " << aBox->GetYHalfLength() << " / " << aBox->GetZHalfLength() << std::endl;
892  }
893  for (int ii=0; ii != lVol->GetNoDaughters(); ++ii) {
894  G4VPhysicalVolume *pVol2 = lVol->GetDaughter(ii);
895  G4LogicalVolume *lVol2 = pVol2->GetLogicalVolume();
896  std::cerr << " .. 2nd level daughter # " << ii << " Name " << lVol2->GetName()
897  << " at " << pVol2->GetObjectTranslation() << std::endl;
898  if (lVol2->GetName().find("Airbox") != std::string::npos) {
899  G4Box *aBox = static_cast<G4Box*>(lVol2->GetSolid());
900  std::cerr << " Airbox size " << aBox->GetXHalfLength()
901  << " / " << aBox->GetYHalfLength() << " / " << aBox->GetZHalfLength() << std::endl;
902  }
903  for (int iii=0; iii != lVol2->GetNoDaughters(); ++iii) {
904  G4VPhysicalVolume *pVol3 = lVol2->GetDaughter(iii);
905  G4LogicalVolume *lVol3 = pVol3->GetLogicalVolume();
906  std::cerr << " ... 3rd level daughter # " << iii << " Name " << lVol3->GetName()
907  << " at " << pVol3->GetObjectTranslation() << std::endl;
908  for (int i4=0; i4 != lVol3->GetNoDaughters(); ++i4) {
909  G4VPhysicalVolume *pVol4 = lVol3->GetDaughter(i4);
910  G4LogicalVolume *lVol4 = pVol4->GetLogicalVolume();
911  std::cerr << " .... 4rth level daughter # " << i4 << " Name " << lVol4->GetName()
912  << " at " << pVol4->GetObjectTranslation() << std::endl;
913  for (int i5=0; i5 != lVol4->GetNoDaughters(); ++i5) {
914  G4VPhysicalVolume *pVol5 = lVol4->GetDaughter(i5);
915  G4LogicalVolume *lVol5 = pVol5->GetLogicalVolume();
916  std::cerr << " ..... 5rth level daughter # " << i5 << " Name " << lVol5->GetName()
917  << " at " << pVol5->GetObjectTranslation() << std::endl;
918  for (int i6=0; i6 != lVol5->GetNoDaughters(); ++i6) {
919  G4VPhysicalVolume *pVol6 = lVol5->GetDaughter(i6);
920  G4LogicalVolume *lVol6 = pVol6->GetLogicalVolume();
921  std::cerr << " ...... 6rth level daughter # " << i6 << " Name " << lVol6->GetName() << std::endl;
922  }
923  }
924  }
925  }
926  }
927  }
928 */
929 
930  const G4Box *topSol = static_cast<const G4Box *>(topAbs->GetSolid());
931 // const double marsTopWidth = topSol->GetYHalfLength(); // Used for debugging only, so comment out for now..
932 // const double marsTopHeight = topSol->GetXHalfLength();
933 // const double marsTopLength = topSol->GetZHalfLength();
934  std::cerr << " Dimension of top level Hadron absorber MARS container, X " << topSol->GetXHalfLength() <<
935  " Y " << topSol->GetYHalfLength() << " Z " << topSol->GetZHalfLength() << std::endl;
936  std::cerr << " Number of daughters for TOP " << topAbs->GetNoDaughters() << std::endl;
937  double maxHalfHeight = -1.0;
938  double maxHalfWidth = -1.0;
939  double maxHalfLength = -1.0;
940  for (int i=0; i != topAbs->GetNoDaughters(); ++i) {
941  G4VPhysicalVolume *pVol = topAbs->GetDaughter(i);
942  G4LogicalVolume *lVol = pVol->GetLogicalVolume();
943  std::cerr << " Daughther " << lVol->GetName();
944  const G4Box *aBox = static_cast<const G4Box *>(lVol->GetSolid());
945  G4ThreeVector loc = pVol->GetObjectTranslation();
946  std::cerr << " at MARS coordinates " << loc[0] << ", " <<loc[1] << ", " << loc[2] <<
947  " zLength " << 2.0*aBox->GetZHalfLength() << std::endl;
948  // Compute the maximum height, width. Note the confusion about X and Y X is up, vertical, in MArs
949  if ((std::abs(loc[2]) + aBox->GetZHalfLength()) > maxHalfLength)
950  maxHalfLength = std::abs(loc[2]) + aBox->GetZHalfLength();
951  if ((std::abs(loc[1]) + aBox->GetYHalfLength()) > maxHalfWidth)
952  maxHalfWidth = std::abs(loc[1]) + aBox->GetYHalfLength(); // Width is along X G4lbne orientation, which Y MARS
953  if ((std::abs(loc[0]) + aBox->GetXHalfLength()) > maxHalfHeight)
954  maxHalfHeight = std::abs(loc[0]) + aBox->GetXHalfLength();
955  // Height is along Y G4lbne orientation, which is negative X in MARS
956  }
957  maxHalfHeight += 5.0*CLHEP::cm;
958  maxHalfWidth += 5.0*CLHEP::cm;
959  maxHalfLength += std::abs(maxHalfHeight*std::sin(fBeamlineAngle)) + 5.0*CLHEP::cm;;
960  std::cerr << " Container volume for Hadron absorber, 1/2 width "
961  << maxHalfWidth << " 1/2 Height " << maxHalfHeight
962  << " 1/2 length " << maxHalfLength << std::endl;
963  G4Box *aHABoxTop = new G4Box(G4String("HadronAbsorberTop"), maxHalfWidth, maxHalfHeight, maxHalfLength);
964  G4LogicalVolume *aHATopL =
965  new G4LogicalVolume(aHABoxTop, G4Material::GetMaterial("Air"), G4String("HadronAbsorberTop"));
966  const LBNEVolumePlacementData *plDecayPipe =
967  fPlacementHandler->Find(G4String("HadronAbsorber"), G4String("DecayPipeHall"),
968  G4String("LBNEDetectorConstruction::ConstructLBNEHadronAbsorber"));
969  const double zzz = maxHalfLength + plDecayPipe->fParams[2]/2 + plDecayPipe->fPosition[2] +
970  std::abs(maxHalfHeight*std::sin(fBeamlineAngle)) + 5.0*CLHEP::cm;
971 
972  std::cerr << " half length Decay Pipe " << plDecayPipe->fParams[2]/2
973  << " Position in tunnel (center) " << plDecayPipe->fPosition[2]
974  << " half width decay pipe " << plDecayPipe->fParams[0]/2 << " 1/2 height " << plDecayPipe->fParams[1]/2
975  << " ZPosAbs " << zzz << std::endl;
976 // One must adjust the height of the Absorber such the the beam line crosses the center of the 3 rth Core block in it's
977 // center..
978 //
979  const double yyy = 2.3*CLHEP::m; // Adjusted by hand, looking Geantino's Acuracy: for crossing of block 3 and 4
980  // Average of crossing -4 mm . Min Max average is 0.6 mm.
981  G4ThreeVector posTopHA(0., yyy, zzz);
982 
983  new G4PVPlacement(&fRotBeamlineAngle, posTopHA, aHATopL, "HadronAbsorberTop",
984  mother->GetLogicalVolume(), false, 1, true);
985 
986  G4RotationMatrix *marsRot = new G4RotationMatrix;
987  marsRot->rotateZ(-M_PI/2.);
988  for (int i=0; i != topAbs->GetNoDaughters(); ++i) {
989  G4VPhysicalVolume *pVol = topAbs->GetDaughter(i);
990  G4LogicalVolume *lVol = pVol->GetLogicalVolume();
991 // const G4Box *aBox = static_cast<const G4Box *>(lVol->GetSolid());
992  G4ThreeVector loc = pVol->GetObjectTranslation();
993 // const double yyy = loc[0] - marsTopHeight + maxHalfHeight;
994  double yyyI = loc[0] ; // Up to a sign!!!
995  const double xxx = loc[1]; // Y G4LBNE = -X Mars. Was centered in MARS, set to 0., o.k.
996  // X G4LBNE = Y Mars. !! Not centered in Mars! Perhaps, ned a shift due to the
997  // the different size of the mother volume
998 // const double zzz = loc[2] - marsTopLength + maxHalfLength;
999  double zzzI = loc[2] - 27.9*CLHEP::m; // Setting up this last to avoid air to air volume overlap.
1000  if (lVol->GetName().find("AH_top") != std::string::npos) {
1001  yyyI += 0.1*CLHEP::mm; // To avoid clash.. Cosmetic
1002  // Note: for release v3r0px up to v3r0p10, this was set to 27.9 m
1003  zzzI = loc[2] - 27.0*CLHEP::m; // Also to avoid clash. Note that this volume is not
1004  // in the pion beam, it is up ~ 8 m. above the beam line.
1005  }
1006  G4ThreeVector posTmp(xxx, yyyI, zzzI);
1007 // std::cerr << " Placing volume " << lVol->GetName() << " at " << posTmp << " 1/2 sizes (G4 coord) "
1008 // << aBox->GetYHalfLength() << " , " << aBox->GetXHalfLength() << " , "
1009 // << aBox->GetZHalfLength() << std::endl;
1010 // std::cerr << " .... Extend in X " << posTmp[0] - aBox->GetYHalfLength()
1011 // << " to " << posTmp[0] + aBox->GetYHalfLength() << std::endl;
1012 // std::cerr << " .... Extend in Y " << posTmp[1] - aBox->GetXHalfLength()
1013 // << " to " << posTmp[1] + aBox->GetXHalfLength() << std::endl;
1014 // std::cerr << " .... Extend in Z " << posTmp[2] - aBox->GetZHalfLength()
1015 // << " to " << posTmp[2] + aBox->GetZHalfLength() << std::endl;
1016  new G4PVPlacement(marsRot, posTmp, lVol, lVol->GetName() + std::string("_P"), aHATopL, false, 1, true);
1017  }
1018 
1019 
1020  //---Tracking planes--------
1021  //-- to place stuff in the absorber, we must first get the
1022  // muon alcove region.
1023 
1024 
1025  for (int i=0; i != topAbs->GetNoDaughters(); ++i) {
1026  G4VPhysicalVolume *pVol1 = topAbs->GetDaughter(i);
1027  G4LogicalVolume *lVol1 = pVol1->GetLogicalVolume();
1028 
1029 
1030  for (int ii=0; ii != lVol1->GetNoDaughters(); ++ii) {
1031  G4VPhysicalVolume *pVol2 = lVol1->GetDaughter(ii);
1032  G4LogicalVolume *lVol2 = pVol2->GetLogicalVolume();
1033  std::string aVolNameTmp2(lVol2->GetName());
1034  if (aVolNameTmp2 != std::string("AH_Muon_alkair")) continue;
1035  std::cerr << " Found AH_Muon_alk again ... " << std::endl;
1036 
1037  G4Box *detSolid = new G4Box("detSolid",2.5*CLHEP::m,2.5*CLHEP::m,1.0*CLHEP::cm);
1038 
1039  TrackingPlaneLogical= new G4LogicalVolume(detSolid , G4Material::GetMaterial("Air"), "detLogical", 0,0,0);
1040 
1041  G4ThreeVector posTmp; posTmp[0] =0.; posTmp[1] =0.;
1042  posTmp[2] = -6.0*CLHEP::m; // placed right after absorber
1043 
1044  std::cerr << " Placing test planes in absorber hall" << std::endl;
1045  new G4PVPlacement((G4RotationMatrix *) 0,posTmp, TrackingPlaneLogical,
1046  "trackPln1",lVol2, false, 1, true);
1047 
1048  G4ThreeVector posTmp2; posTmp2[0] =0.; posTmp2[1] =0.;
1049  posTmp2[2] = -3.3*CLHEP::m; // placed after blue block
1050  new G4PVPlacement((G4RotationMatrix *) 0,posTmp2, TrackingPlaneLogical,
1051  "trackPln2",lVol2, false, 1, true);
1052  std::cerr << " Top level daughter # " << i << " Name " << lVol1->GetName();
1053  }
1054  }
1055 
1056 
1057  //
1058  // We now clear the MARS top absorbers, simplify the geometry search
1059  //
1060  topAbs->ClearDaughters();
1061 
1062  // save logical volume
1063  HadrBox_log = aHATopL;
1064 }
1065 
1067 {
1068 
1069  //*************************** Start creating ********************************
1070  //Define dynamically measure for Steel and Concrete volumes
1071  G4double SteelWidth=this->GetDwStrAbsSteelWidth();
1072  G4double ConcWidth=this->GetDwStrAbsConcreteWidth();
1073 
1074  //Container Absorber(Air) (those measures are hard-coded but it would be better to define them dynamically)
1075  G4double air_box_x = 16.223*CLHEP::m;
1076  G4double air_box_y = 19.355*CLHEP::m;
1077  G4double air_box_z = 20*CLHEP::m;
1078 
1079 
1080  G4Box *air_Box = new G4Box("AirBox",air_box_x/2,air_box_y/2,air_box_z/2);
1081  G4ThreeVector air_posBox; air_posBox[0] =0.; air_posBox[1] =0.45*CLHEP::m; air_posBox[2] = 231.0*CLHEP::m;
1082 
1083  G4LogicalVolume *air_logBox =
1084  new G4LogicalVolume(air_Box, G4Material::GetMaterial("Air"), G4String("LogicalVAirBox"),0,0,0);
1085 
1086  //fRotBeamlineAngle is the rotational matrix that defines the rotation of the beam; if we want to tilt the absorber we use it, otherwise we use "(G4RotationMatrix *)0"
1087  new G4PVPlacement(&fRotBeamlineAngle,air_posBox,air_logBox,
1088  "PhysAirBox",mother->GetLogicalVolume(), false, 1, true);
1089 
1090  air_logBox->SetVisAttributes(GetMaterialVisAttrib("Air"));
1091 
1092  //Set Attributes of Container(Air)
1093  /*G4VisAttributes *airBox_Att = new G4VisAttributes(G4Colour(G4Colour::Yellow()));
1094  airBox_Att->G4VisAttributes::SetForceWireframe(true);
1095  air_logBox->SetVisAttributes(airBox_Att);*/
1096 
1097 
1098  //------------------------------ Define Absorber Volumes ------------------------------------------------
1099 
1100  //~~~~~ Absorber (concrete volume) ~~~~~~~
1101  G4double AH_ConcreteX = 10.23*CLHEP::m;
1102  G4double AH_ConcreteY = 12.125*CLHEP::m;
1103  G4double AH_ConcreteZ = 6.24*CLHEP::m + SteelWidth + ConcWidth;
1104 
1105  G4Box *ConcreteBox1= new G4Box("ConcreteBox1",AH_ConcreteX/2,AH_ConcreteY/2,AH_ConcreteZ/2);
1106 
1107  G4Box *box1 = new G4Box("box1",3.5/2*CLHEP::m, 4.05/2*CLHEP::m,5*CLHEP::m );
1108  G4SubtractionSolid *AH_Concrete=
1109  new G4SubtractionSolid("AH_Concrete",ConcreteBox1,box1,0,G4ThreeVector(0.,0.1*CLHEP::m,-4.37*CLHEP::m-AH_ConcreteZ/2));
1110 
1111  G4ThreeVector posAH_Concrete; posAH_Concrete[0] =0.; posAH_Concrete[1] =0.4*CLHEP::m; posAH_Concrete[2] =AH_ConcreteZ/2-air_box_z/2;
1112 
1113  G4ThreeVector posAH_AirBox1; posAH_AirBox1[0] =0.; posAH_AirBox1[1] =0.1*CLHEP::m; posAH_AirBox1[2] = (0.63/2)*CLHEP::m-AH_ConcreteZ/2;
1114 
1115  G4LogicalVolume *AH_ConcreteLV=
1116  new G4LogicalVolume(AH_Concrete, G4Material::GetMaterial("Concrete"), G4String("LV_AHConcrete"),0,0,0);
1117  new G4PVPlacement((G4RotationMatrix *) 0,posAH_Concrete,AH_ConcreteLV,
1118  "PV_AHConcrete",air_logBox, false, 1, true);
1119 
1120  //AH_ConcreteLV->SetVisAttributes(GetMaterialVisAttrib("Concrete"));
1121 
1122  //Set Attributes Absorber(concrete)
1123  G4VisAttributes *AHConcrete_Att = new G4VisAttributes(G4Colour(G4Colour::Magenta()));
1124  AHConcrete_Att->G4VisAttributes::SetForceWireframe(true);
1125  AH_ConcreteLV->SetVisAttributes(AHConcrete_Att);
1126  //----------------------------end Vol #1-----------------
1127 
1128 
1129  //~~~~~ Daughter 1 (steel volume) ~~~~~~~
1130 
1131  G4double AH_ShieldStlX = 5.46*CLHEP::m;
1132  G4double AH_ShieldStlY = 5.59*CLHEP::m;
1133  G4double AH_ShieldStlZ = 5.41*CLHEP::m+SteelWidth;
1134 
1135  G4Box *AH_ShieldStl= new G4Box("AH_ShieldStl",AH_ShieldStlX/2,AH_ShieldStlY/2,AH_ShieldStlZ/2);
1136 
1137 
1138  G4ThreeVector posAH_ShieldStl; posAH_ShieldStl[0] =0.;
1139  posAH_ShieldStl[1] =0.; posAH_ShieldStl[2] =AH_ShieldStlZ/2-AH_ConcreteZ/2+0.63*CLHEP::m; //0.63m is the width of concrete front hole
1140 
1141  G4LogicalVolume *AH_ShieldStlLV=
1142  new G4LogicalVolume(AH_ShieldStl,/*G4Material::GetMaterial("Air")*/G4Material::GetMaterial("Slab_Stl"), G4String("LV_AHShieldStl"),0,0,0);
1143  new G4PVPlacement((G4RotationMatrix *) 0,posAH_ShieldStl,AH_ShieldStlLV,
1144  "PV_AHShieldStl",AH_ConcreteLV, false, 1, true);
1145  // AH_ShieldStlLV->SetVisAttributes(GetMaterialVisAttrib("Iron"));
1146 
1147  //Set Atrributes Absorber(steel)
1148  G4VisAttributes *AHShieldStl_Att = new G4VisAttributes(G4Colour(0.,1.,0.));
1149  AHShieldStl_Att->G4VisAttributes::SetForceWireframe(true);
1150  AH_ShieldStlLV->SetVisAttributes(AHShieldStl_Att);
1151  //----------------------------end Vol #2-----------------
1152  //--- volume 3 is no longer used.
1153 
1154  //~~~~~ GrandDaughter 1 (Al hole volume) ~~~~~~~
1155 
1156  G4double AH_AlholeX = 1.96*CLHEP::m;
1157  G4double AH_AlholeY = 2.18*CLHEP::m;
1158  G4double AH_AlholeZ = 1.83*CLHEP::m;
1159 
1160  G4Box *AH_Alhole= new G4Box("AH_Alhole",AH_AlholeX/2,AH_AlholeY/2,AH_AlholeZ/2);
1161 
1162  //Create Polycone volume
1163  G4double al = (-1.83/2)*CLHEP::m;
1164  G4double posZ [8];posZ[0]=al; posZ[1]=al+0.305*CLHEP::m;
1165  posZ[2]=al+0.305*CLHEP::m; posZ[3]=al+0.610*CLHEP::m; posZ[4]=al+0.610*CLHEP::m;
1166  posZ[5]=0.305*CLHEP::m;posZ[6]=0.305*CLHEP::m;
1167  posZ[7]=0.915*CLHEP::m;
1168  G4double Irad [8];Irad[0]=0.; Irad[1]=0.; Irad[2]=0.;Irad[3]=0.;Irad[4]=0.;Irad[5]=0.;Irad[6]=0.;Irad[7]=0.;
1169  G4double Orad [8];Orad[0]=0.365*CLHEP::m; Orad[1]=0.365*CLHEP::m;
1170  Orad[2]=0.615*CLHEP::m;Orad[3]=0.615*CLHEP::m;Orad[4]=0.5*CLHEP::m;
1171  Orad[5]=0.5*CLHEP::m;Orad[6]=0.365*CLHEP::m;Orad[7]=0.365*CLHEP::m;
1172  // Convert to an array of z, r, wrapping on itself (old signature gives a run time exception..)
1173  std::vector<double> zzPolycone(16, 0.);
1174  std::vector<double> rrPolycone(16, 0.);
1175  for (size_t kPoly=0; kPoly != 8; kPoly++) {
1176  zzPolycone[kPoly] = posZ[kPoly];
1177  zzPolycone[kPoly+8] = posZ[7-kPoly];
1178  rrPolycone[kPoly] = Irad[kPoly];
1179  rrPolycone[kPoly+8] = Orad[kPoly];
1180  }
1181 
1182  G4Polycone* pcone = new G4Polycone("pcone", 0.,2*M_PI*CLHEP::rad,8, &rrPolycone[0], &zzPolycone[0]);
1183 
1184  G4ThreeVector posAH_Alhole; posAH_Alhole[0] =0.; posAH_Alhole[1] =0.; posAH_Alhole[2] =AH_AlholeZ/2-AH_ShieldStlZ/2;
1185 
1186  G4LogicalVolume *AH_AlholeLV=
1187  new G4LogicalVolume(AH_Alhole, G4Material::GetMaterial("Aluminum"), G4String("LV_AHAlhole"),0,0,0);
1188  new G4PVPlacement((G4RotationMatrix *) 0,posAH_Alhole,AH_AlholeLV,
1189  "PV_AHAlhole",AH_ShieldStlLV, false, 1, true);
1190 
1191 
1192  G4LogicalVolume *AH_AirholeLV=
1193  new G4LogicalVolume(pcone, G4Material::GetMaterial("Air"), G4String("LV_AHAirhole"),0,0,0);
1194  new G4PVPlacement((G4RotationMatrix *) 0,G4ThreeVector(0,0,0),AH_AirholeLV,
1195  "PV_AHAirhole",AH_AlholeLV, false, 1, true);
1196 
1197 
1198  //Set Atrributes Absorber(Al hole)
1199  G4VisAttributes *AHAlhole_Att = new G4VisAttributes(G4Colour(0.,192.,255.));
1200  AHAlhole_Att->G4VisAttributes::SetForceWireframe(true);
1201  AH_AlholeLV->SetVisAttributes(AHAlhole_Att);
1202  //----------------------------end Vol #4-----------------
1203 
1204 
1205  //~~~~~ GrandDaughter 2 (Al core volume) ~~~~~~~
1206  G4double AH_AlcoreX = 1.52*CLHEP::m;
1207  G4double AH_AlcoreY = 1.52*CLHEP::m;
1208  G4double AH_AlcoreZ = 2.46*CLHEP::m;
1209 
1210  G4Box *AH_Alcore= new G4Box("AH_Alcore",AH_AlcoreX/2,AH_AlcoreY/2,AH_AlcoreZ/2);
1211 
1212 
1213  G4ThreeVector posAH_Alcore; posAH_Alcore[0] =0.;
1214  posAH_Alcore[1] =-0.2*CLHEP::m; posAH_Alcore[2] =AH_AlcoreZ/2-AH_ShieldStlZ/2+AH_AlholeZ;
1215 
1216  G4LogicalVolume *AH_AlcoreLV=
1217  new G4LogicalVolume(AH_Alcore,G4Material::GetMaterial("Aluminum"), G4String("LV_AHAlcore"),0,0,0);
1218  new G4PVPlacement((G4RotationMatrix *) 0,posAH_Alcore,AH_AlcoreLV,
1219  "PV_AHAlcore",AH_ShieldStlLV, false, 1, true);
1220 
1221  //Set Atrributes Absorber(Al hole)
1222  G4VisAttributes *AHAlcore_Att = new G4VisAttributes(G4Colour(0.,0.,1.));
1223  AHAlcore_Att->G4VisAttributes::SetForceWireframe(true);
1224  AH_AlcoreLV->SetVisAttributes(AHAlcore_Att);
1225  //----------------------------end Vol #5-----------------
1226 
1227 
1228  //~~~~~ GrandDaughter 3 (Steel absorber volume) ~~~~~~~
1229  G4double AH_SteelX = 1.52*CLHEP::m;
1230  G4double AH_SteelY = 1.52*CLHEP::m;
1231  G4double AH_SteelZ = 1.22*CLHEP::m;
1232 
1233  G4Box *AH_Steel= new G4Box("Ah_Steel",AH_SteelX/2,AH_SteelY/2,AH_SteelZ/2);
1234 
1235  G4ThreeVector posAH_Steel; posAH_Steel[0] =0.;
1236  posAH_Steel[1] =-0.2*CLHEP::m; posAH_Steel[2] =AH_SteelZ/2-AH_ShieldStlZ/2+(AH_AlholeZ+AH_AlcoreZ);
1237 
1238  G4LogicalVolume *AH_SteelLV=
1239  new G4LogicalVolume(AH_Steel, G4Material::GetMaterial("Slab_Stl"), G4String("LV_AHSteel"),0,0,0);
1240  new G4PVPlacement((G4RotationMatrix *) 0,posAH_Steel,AH_SteelLV,
1241  "PV_AHSteel",AH_ShieldStlLV, false, 1, true);
1242 
1243  //Set Atrributes Absorber(steel)
1244  G4VisAttributes *AHSteel_Att = new G4VisAttributes(G4Colour(1.,0.,0.));
1245  AHSteel_Att->G4VisAttributes::SetForceWireframe(true);
1246  AH_SteelLV->SetVisAttributes(AHSteel_Att);
1247  //----------------------------end Vol #6-----------------
1248 
1249 
1250  //~~~~~Tracking Planes ~~~~~~~
1251  //Position of planes is dynamically coded so that they are 2.7m apart from each other and 4m away from the end of the absorber and surround the Blueblock.
1252  //If you change geometry of "simple detector" consider changing those measures (2.7m and 4m).
1253  G4Box *detSolid = new G4Box("detSolid",2.5*CLHEP::m,2.5*CLHEP::m,1.0*CLHEP::cm);
1254 
1255  TrackingPlaneLogical= new G4LogicalVolume(detSolid , G4Material::GetMaterial("Air"), "detLogical", 0,0,0);
1256 
1257  G4ThreeVector posTmp; posTmp[0] =0.; posTmp[1] =-0.45*CLHEP::m;
1258  posTmp[2] = ConcWidth+4*CLHEP::m; // placed right after absorber
1259  std::cerr << " Placing test planes in absorber hall" << std::endl;
1260  new G4PVPlacement((G4RotationMatrix *) 0,posTmp, TrackingPlaneLogical,
1261  "trackPln1",air_logBox, false, 1, true);
1262 
1263  G4ThreeVector posTmp2; posTmp2[0] =0.; posTmp2[1] =-0.45*CLHEP::m;
1264  posTmp2[2] =posTmp[2]+2.7*CLHEP::m; // placed after blue block
1265  new G4PVPlacement((G4RotationMatrix *) 0,posTmp2, TrackingPlaneLogical,
1266  "trackPln2",air_logBox, false, 1, true);
1267 
1268  // G4VPhysicalVolume *trackerPhysBox =
1269  // new G4VPhysicalVolume((G4RotationMatrix *)0,posBox,"TrackerBox",logBox, mother->GetLogicalVolume(), false, 1, true);
1270 
1271  //**********************DONE**************************
1272 
1273 }
1274 //end simpler Absorber
1275 
1276 
1278 
1279  const double in = 25.4*CLHEP::mm;
1280 //
1281 // Install steel shielding around the Horn1 and the target.
1282 //
1283 // Based on Docdb 5339, page 30 and 31.
1284 // See also drawing 2251.000-ME-487105
1285 //
1286 // We simply install steel, assumed low carbon...
1287 //
1288  const double maxR1 = fPlacementHandler->GetMaxRadiusMotherHorn1();
1289  fPlacementHandler->Find(G4String("LBNFShielding"), G4String("Horn1PolyM1"),
1290  G4String("LBNEDetectorConstruction::ConstructLBNEShieldingHorn2"));
1291  const G4String nameM = mother->GetLogicalVolume()->GetName();
1292  const LBNEVolumePlacementData *plTop =
1293  fPlacementHandler->Find(G4String("ShieldingHorn1"), nameM,
1294  G4String("LBNEDetectorConstruction::ConstructLBNEShieldingHorn1"));
1295 
1296  const double horn1HeightAtMCZERO = 66.7*in;
1297 //
1298 // Bottom
1299 //
1300  G4String bName = G4String("ShieldingHorn1Bottom");
1301  const double bWidth = 208*in;
1302  const double bHeight = 72.0*in;
1303  const double bLength = plTop->fParams[2] - 2.*bHeight*std::abs(std::sin(fBeamlineAngle)) - 5.0*CLHEP::cm;
1304  G4Box *bBox = new G4Box(bName, bWidth/2., bHeight/2., bLength/2.);
1305  G4LogicalVolume *bLVol = new G4LogicalVolume(bBox, G4Material::GetMaterial(std::string("Slab_Stl")), bName);
1306  G4ThreeVector posTmp(0., 0., 0.);
1307  posTmp[1] = -horn1HeightAtMCZERO - bHeight/2.;
1308  // MCZERO is G4 coordinate 0.0, the center of tunnel, so the above number needs to be corrected for the
1309  // shift in the center of the mother volume
1310  const double zShift = -1.0*plTop->fPosition[2];
1311  const double yCorr = -1.0*zShift*std::sin(fBeamlineAngle);
1312  posTmp[1] -= yCorr;
1313 // std::cerr << "ConstructLBNEShieldingHorn1 .... "<< bName << " zShift bottom plate " << zShift
1314 // << " thus, y position " << posTmp[1] << " coorection " << yCorr << std::endl;
1315 //
1316  new G4PVPlacement(&fRotBeamlineAngle, posTmp, bLVol, bName + std::string("_P"),
1317  mother->GetLogicalVolume(), false, 1, true);
1318 //
1319 // Sides
1320 //
1321  G4String sName = G4String("ShieldingHorn1Side");
1322  const double sWidth = 65.0*in; // Reduced from 72 inches down to 65 to give room for Norn1 Mother volume
1323  // for Optimized design.
1324  const double sHeight = 270.8*in - 72.0*in - 4.0*CLHEP::cm; // oversize a bit, but no matter..
1325  const double sLength = plTop->fParams[2] - 2.*sHeight*std::abs(std::sin(fBeamlineAngle)) - 5.0*CLHEP::cm;
1326  G4Box *sBox = new G4Box(sName, sWidth/2., sHeight/2., sLength/2.);
1327  G4LogicalVolume *sLVol = new G4LogicalVolume(sBox, G4Material::GetMaterial(std::string("Slab_Stl")), sName);
1328  posTmp[0] = -maxR1 - 15.0*CLHEP::cm - sWidth/2.;
1329  posTmp[1] = sHeight/2. - horn1HeightAtMCZERO + 2.0*CLHEP::cm;
1330  // MCZERO is G4 coordinate 0.0, the center of tunnel, so the above number needs to be corrected for the
1331  // shift in the center of the mother volume
1332  posTmp[1] -= yCorr;
1333 // std::cerr << "ConstructLBNEShieldingHorn1 .... "<< bName << " zShift side plate, left " << zShift
1334 // << " thus, y position " << posTmp[1] << " coorection " << yCorr
1335 // << std::endl << " ....... X = " << posTmp[0] << " Y " << posTmp[1] << std::endl;
1336 
1337  new G4PVPlacement(&fRotBeamlineAngle, posTmp, sLVol, sName + std::string("_LeftP"),
1338  mother->GetLogicalVolume(), false, 1, true);
1339  posTmp[0] = maxR1 + 15.0*CLHEP::cm + sWidth/2.;
1340 // std::cerr << "ConstructLBNEShieldingHorn1 .... "<< bName << " zShift side plate, Right " << zShift
1341 // << " thus, y position " << posTmp[1] << " coorection " << yCorr
1342 // << std::endl << " ....... X = " << posTmp[0] << " Y " << posTmp[1] << std::endl;
1343 
1344  new G4PVPlacement(&fRotBeamlineAngle, posTmp, sLVol, sName + std::string("_RightP"),
1345  mother->GetLogicalVolume(), false, 2, true);
1346 //
1347 // Top. Simply put about 2m of steel
1348 //
1349  G4String tName = G4String("ShieldingHorn1Top");
1350  const double tWidth = 208*in;
1351  const double tHeight = 94.0*in;
1352  const double tLength = plTop->fParams[2] - 2.*tHeight*std::abs(std::sin(fBeamlineAngle)) - 5.0*CLHEP::cm;
1353  G4Box *tBox = new G4Box(tName, tWidth/2., tHeight/2., tLength/2.);
1354  G4LogicalVolume *tLVol = new G4LogicalVolume(tBox, G4Material::GetMaterial(std::string("Slab_Stl")), tName);
1355 
1356  posTmp[0] =0.;
1357  posTmp[1] += sHeight/2. + tHeight/2. + 4.0*CLHEP::cm;
1358  new G4PVPlacement(&fRotBeamlineAngle, posTmp, tLVol, bName + std::string("_P"),
1359  mother->GetLogicalVolume(), false, 1, true);
1360 
1361 
1362 }
1363 
1364 //Construct the Tracking plane at the end of Horn 1 Amit Bashyal
1366 
1367  const G4String nameM = mother->GetLogicalVolume()->GetName();
1368  if(nameM != G4String("Tunnel")){
1369  std::cerr
1370  <<"Unexpected Mother Volume in LBNEDetectorConstruction::ConstructLBNEHorn1TrackingPlane(G4VPhysicalVolume *mother)"<<std::endl;
1371  exit(2);
1372  }
1373  fPlacementHandler->Find(G4String("Horn1TrackingPlane"), nameM,
1374  G4String("LBNEDetectorConstruction::ConstructLBNEHorn1TrackingPlane"));
1375  const LBNEVolumePlacementData *plH1 =
1376  fPlacementHandler->Find(G4String("Horn1TrackingPlane"), G4String("TargetHallAndHorn1"),
1377  G4String("LBNEDetectorConstruction::ConstructLBNEHorn1TrackingPlane"));
1378  const double z = plH1->fPosition[2] + plH1->fParams[2]/2.0 + 2.0*CLHEP::cm; //Position set at 2 cm after the end of Horn 1.
1379 
1380  const double widthTop = 80.00*CLHEP::cm; //Set the Dimension such that it just covers the mouth of Horn 1 end.
1381  const double heightTop = 80.00*CLHEP::cm;
1382 
1383 // G4String topNameBetween = G4String("Horn1TrackingPlane");
1384  G4Box *topBox = new G4Box("Horn1TrackingPlane", widthTop/2., heightTop/2.,0.5*CLHEP::mm); //Thickness of 0.5mm
1385  TrackingPlaneH1Logical = new G4LogicalVolume(topBox, G4Material::GetMaterial(std::string("Air")),"Horn1TrackingPlaneLogical");
1386  G4ThreeVector posTopLevel (0., 0., z);
1387 std::cerr
1388  <<"The value of Z in Horn1Plane is:" << z<<" "<< plH1->fPosition[2]<<" "<<plH1->fParams[2]<<std::endl;
1389 std::cerr
1390  <<"Width of Horn1TrackingPlane is:" <<widthTop/2<<" Height of Horn1TrackingPlane is: "<<heightTop/2<<std::endl;
1391  G4PVPlacement *vTopLevel = new G4PVPlacement((G4RotationMatrix *) 0, posTopLevel,
1392  TrackingPlaneH1Logical,"Horn1TrackingPlane_P",
1393  mother->GetLogicalVolume(), false, 1, true);
1394  if(vTopLevel == 0){
1395  std::cerr << " Can't place Horn1 tracking plane.. Unexpected.. " << std::endl; // This error should never occur..
1396  }
1397 
1398 }
1399 
1400 
1401 
1403 
1404  const double in = 25.4*CLHEP::mm;
1405 //
1406 // Install steel shielding around the Horn2 and the target.
1407 //
1408 // Based on Docdb 5339, page 30 and 31.
1409 // See also drawing 2251.000-ME-487105
1410 //
1411 // We simply install steel, assumed low carbon...
1412 //
1413  const G4String nameM = mother->GetLogicalVolume()->GetName();
1414  const LBNEVolumePlacementData *plTop =
1415  fPlacementHandler->Find(G4String("ShieldingHorn2"), nameM,
1416  G4String("LBNEDetectorConstruction::ConstructLBNEShieldingHorn2"));
1417 
1418  const LBNEVolumePlacementData *plHorn2 =
1419  fPlacementHandler->Find(G4String("LBNFShielding"), G4String("Horn2TopLevel"),
1420  G4String("LBNEDetectorConstruction::ConstructLBNEShieldingHorn2"));
1421 // std::cerr << " Horn2TopLevel params " << plHorn2->fParams[0] << " / "
1422 // << plHorn2->fParams[1] << " / " << plHorn2->fParams[2] << std::endl;
1423 // std::cerr << " Horn2TopLevel position " << plHorn2->fPosition[0] << " / "
1424 // << plHorn2->fPosition[1] << " / " << plHorn2->fPosition[2] << std::endl;
1425  const double horn2Height = (37. + 17.3)*in; // ???? Checked final position of the bottom slab
1426  // from drawing of page 30 of LBNE Doc 5339-v5 Vertical distance between the top of the bottom shielding
1427  // and the beam line, at the geometricla center of Horn2.
1428 //
1429 // Bottom
1430 //
1431  G4String bName = G4String("ShieldingHorn2Bottom");
1432  const double bWidth = 168*in;
1433  const double bHeight = 52.0*in;
1434  const double bLength = plTop->fParams[2] - 2.*bHeight*std::abs(std::sin(fBeamlineAngle)) - 5.0*CLHEP::cm;
1435  G4Box *bBox = new G4Box(bName, bWidth/2., bHeight/2., bLength/2.);
1436  G4LogicalVolume *bLVol = new G4LogicalVolume(bBox, G4Material::GetMaterial(std::string("Slab_Stl")), bName);
1437  G4ThreeVector posTmp(0., 0., 0.);
1438  posTmp[1] = -horn2Height - bHeight/2.;
1439  // MCZERO is G4 coordinate 0.0, the center of tunnel, so the above number needs to be corrected for the
1440  // shift in the center of the mother volume
1441 // const double zShift = -1.0*plTop->fPosition[2];
1442 // const double yCorr = -1.0*zShift*std::sin(fBeamlineAngle); v3r0p8
1443  const double yCorr = 0; // directly measured of the drawing
1444  posTmp[1] += yCorr;
1445 // std::cerr << "ConstructLBNEShieldingHorn2 .... "<< bName << " zShift bottom plate " << zShift
1446 // << " thus, y position " << posTmp[1] << " coorection " << yCorr << " And quit " << std::endl;
1447 // exit(2);
1448 //
1449  new G4PVPlacement(&fRotBeamlineAngle, posTmp, bLVol, bName + std::string("_P"),
1450  mother->GetLogicalVolume(), false, 1, true);
1451 //
1452 // Sides
1453 //
1454 //
1455 // December 2015: Upgrade to v4.10, for which volume overlap problem cause real trouble.
1456 // So, if we rescale Horn2 radially, we may not have enough room to place shielding on the sides.
1457 // Note: this is still the old Chase width..
1458 // If LBNF Polycones horns are used, then the chase is extended
1459 
1460  G4String sName = G4String("ShieldingHorn2Side");
1461  double sWidth = 52.0*in;
1462  double sHeight = 256.8*in - 52.0*in - 4.0*CLHEP::cm; // oversize a bit, but no matter..
1463  double transvShift = plHorn2->fParams[1] + 1.0*CLHEP::cm;
1464 // const double aHorn2RadialRescale = fPlacementHandler->GetHorn2RadialRescale();
1465 // if ((aHorn2RadialRescale - 1.) > 0.) {
1466 // sWidth -= (aHorn2RadialRescale - 1.)*20*in ; // Approximate radius of the Horn2
1467 // std::cerr << " Reducing the width of the side shielding at Horn2 from 1.32 m inches to "
1468 // << sWidth/CLHEP::m << " m " << std::endl;
1469 // sHeight = 256.8*in - sWidth - 4.0*CLHEP::cm;
1470 // }
1471  const double sLength = plTop->fParams[2] - 2.*sHeight*std::abs(std::sin(fBeamlineAngle)) - 5.0*CLHEP::cm;
1472  G4Box *sBox = new G4Box(sName, sWidth/2., sHeight/2., sLength/2.);
1473  G4LogicalVolume *sLVol = new G4LogicalVolume(sBox, G4Material::GetMaterial(std::string("Slab_Stl")), sName);
1474  posTmp[0] = -transvShift - sWidth/2.;
1475  posTmp[1] = sHeight/2. - horn2Height + 2.0*CLHEP::cm;
1476  // MCZERO is G4 coordinate 0.0, the center of tunnel, so the above number needs to be corrected for the
1477  // shift in the center of the mother volume
1478  posTmp[1] -= yCorr;
1479 // std::cerr << "ConstructLBNEShieldingHorn2 .... "<< bName << " zShift side plate, left " << zShift
1480 // << " thus, y position " << posTmp[1] << " coorection " << yCorr
1481 // << std::endl << " ....... X = " << posTmp[0] << " Y " << posTmp[1] << std::endl;
1482 
1483  new G4PVPlacement(&fRotBeamlineAngle, posTmp, sLVol, sName + std::string("_LeftP"),
1484  mother->GetLogicalVolume(), false, 1, true);
1485  posTmp[0] = transvShift + sWidth/2.;
1486 // std::cerr << "ConstructLBNEShieldingHorn2 .... "<< bName << " zShift side plate, Right " << zShift
1487 // << " thus, y position " << posTmp[1] << " coorection " << yCorr
1488 // << std::endl << " ....... X = " << posTmp[0] << " Y " << posTmp[1] << std::endl;
1489 
1490  new G4PVPlacement(&fRotBeamlineAngle, posTmp, sLVol, sName + std::string("_RightP"),
1491  mother->GetLogicalVolume(), false, 2, true);
1492 //
1493 // Top. Simply put about 2m of steel
1494 //
1495  G4String tName = G4String("ShieldingHorn2Top");
1496  const double tWidth = 168*in;
1497  const double tHeight = 94.0*in;
1498  const double tLength = plTop->fParams[2] - 2.*tHeight*std::abs(std::sin(fBeamlineAngle)) - 5.0*CLHEP::cm;
1499  G4Box *tBox = new G4Box(tName, tWidth/2., tHeight/2., tLength/2.);
1500  G4LogicalVolume *tLVol = new G4LogicalVolume(tBox, G4Material::GetMaterial(std::string("Slab_Stl")), tName);
1501 
1502  posTmp[0] =0.;
1503  posTmp[1] += sHeight/2. + tHeight/2. + 4.0*CLHEP::cm;
1504  new G4PVPlacement(&fRotBeamlineAngle, posTmp, tLVol, bName + std::string("_P"),
1505  mother->GetLogicalVolume(), false, 1, true);
1506 
1507 
1508 }
1509 
1510 //Call the Function to construct the Horn2 tracking plane Amit Bashyal
1512  const G4String nameM = mother->GetLogicalVolume()->GetName();
1513  std::cerr<<"Logical Volumes are as follows: "<<nameM<<std::endl;
1514  if(nameM != G4String("Tunnel")){
1515  std::cerr
1516  <<"Unexpected Mother Volume in LBNEDetectorConstruction::ConstructLBNEHorn2TrackingPlane(G4VPhysicalVolume *mother)"<<std::endl;
1517  exit(2);
1518  }
1519  // Mother Placement not used in this context? Probably O.K. Paul Lebrun, Fer. 2015
1520 // const LBNEVolumePlacementData *plMother =
1521 // fPlacementHandler->Find(G4String("Horn2TrackingPlane"), nameM,
1522 // G4String("LBNEDetectorConstruction::ConstructLBNEHorn2TrackingPlane"));
1523  const LBNEVolumePlacementData *plH2 =
1524  fPlacementHandler->Find(G4String("Horn2TrackingPlane"), G4String("Horn2Hall"),
1525  G4String("LBNEDetectorConstruction::ConstructLBNEHorn2TrackingPlane"));
1526  const size_t usedNumberOfHornsPoly = static_cast<size_t>(fPlacementHandler->GetNumberOfHornsPolycone());
1527  //
1528  // Re-install Tracking 2, after HornB. It's position is Horn Geometry dependent.
1529  //
1530  double z = 1.0e20;
1531  if (usedNumberOfHornsPoly > 1) {
1532  std::cerr << " .. Using Conceptual Design 2015, fixed position of the HornBtracking place at z = 7500. mm " << std::endl;
1533  z = 75000*CLHEP::mm;
1534  } else {
1535  const LBNEVolumePlacementData *plH2 =
1536  fPlacementHandler->Find(G4String("Horn2TrackingPlane"), G4String("Horn2Hall"),
1537  G4String("LBNEDetectorConstruction::ConstructLBNEHorn2TrackingPlane"));
1538  z = plH2->fPosition[2] + plH2->fParams[2]/2.0 + 2*CLHEP::cm; //2cm after the end of Horn 2
1539  }
1540  const double widthTop = 400*CLHEP::cm; //
1541  const double heightTop =400*CLHEP::cm;
1542 // G4String topNameBetween = G4String("Horn2TrackingPlane");
1543  G4Box *topBox = new G4Box("Horn2TrackingPlane", widthTop/2., heightTop/2.,0.5*CLHEP::mm);
1544  TrackingPlaneH2Logical = new G4LogicalVolume(topBox, G4Material::GetMaterial(std::string("Air")),"Horn2TrackingPlaneLogical");
1545  G4ThreeVector posTopLevel (0., 0., z);
1546  std::cerr
1547  <<"The value of Z in Horn2Plane is:" << z<<" "<< plH2->fPosition[2]<<" "<<plH2->fParams[2]<<std::endl;
1548  std::cerr
1549  <<"Width of Horn2TrackingPlane is:" <<widthTop/2<<" Height of Horn2TrackingPlane is: "<<heightTop/2<<std::endl;
1550  new G4PVPlacement((G4RotationMatrix *) 0, posTopLevel,
1551  TrackingPlaneH2Logical,"Horn2TrackingPlane_P",
1552  mother->GetLogicalVolume(), false, 1, true);
1553 }
1554 
1556 //
1557 // We have to construct a mother volume located in the tunnel, in between the 2 horns
1558 // Based on the Horn1 and Honr 2 placements.
1559 //
1560  const double in = 25.4*CLHEP::mm;
1561  const G4String nameM = mother->GetLogicalVolume()->GetName();
1562  if (nameM != G4String("Tunnel")) {
1563  std::cerr
1564  << " Unexpected Mother volume in LBNEDetectorConstruction::ConstructLBNEShieldingBetweenHorns !" << std::endl;
1565  exit(2);
1566  }
1567  const LBNEVolumePlacementData *plMother =
1568  fPlacementHandler->Find(G4String("ShieldingBetweenHorns"), nameM,
1569  G4String("LBNEDetectorConstruction::ConstructLBNEShieldingBetweenHorns"));
1570  const LBNEVolumePlacementData *plH1 =
1571  fPlacementHandler->Find(G4String("ShieldingBetweenHornsHorn"), G4String("TargetHallAndHorn1"),
1572  G4String("LBNEDetectorConstruction::ConstructLBNEShieldingHorn1"));
1573  const LBNEVolumePlacementData *plH2 =
1574  fPlacementHandler->Find(G4String("ShieldingBetweenHornsHorn"), G4String("Horn2Hall"),
1575  G4String("LBNEDetectorConstruction::ConstructLBNEShieldingBetweenHorns"));
1576  const double zStart = plH1->fPosition[2] + plH1->fParams[2]/2.0 + 5.0*CLHEP::cm;
1577  const double zEnd = plH2->fPosition[2] - plH2->fParams[2]/2.0 - 5.0*CLHEP::cm;
1578  const double lengthTop = zEnd - zStart;
1579 // std::cerr << " Length of the Horn1 to Horn2 corridor " << lengthTop << std::endl;
1580  const double widthTop = plMother->fParams[0] - 10.0*CLHEP::cm;
1581  const double heightTop = plMother->fParams[1] - 10.0*CLHEP::cm;
1582  G4String topNameBetween = G4String("Horn1ToHorn2Corridor");
1583  G4Box *topBox = new G4Box(topNameBetween, widthTop/2., heightTop/2.,lengthTop/2.);
1584  G4LogicalVolume *topLevVol = new G4LogicalVolume(topBox, G4Material::GetMaterial(G4String("Air")), topNameBetween);
1585  G4ThreeVector posTopLevel (0., 0., 0.5*(zStart + zEnd));
1586  G4PVPlacement *vTopLevel = new G4PVPlacement((G4RotationMatrix *) 0, posTopLevel,
1587  topLevVol , topNameBetween + std::string("_P"),
1588  mother->GetLogicalVolume(), false, 1, true);
1589 //
1590 // Now we proceed with the shielding blocks.
1591 //
1592  const double beamlineHeight = 0.5*(60.6 + 66.7)*in; // we take the average between Horn1 and Horn2.
1593 //
1594 // Bottom
1595 //
1596  G4String bName = G4String("ShieldingHornCorridorBottom");
1597  const double bWidth = 168*in; // take the width of Horn2.
1598  const double bHeight = 52.0*in;
1599  const double bLength = lengthTop - 2.*bHeight*std::abs(std::sin(fBeamlineAngle)) - 5.0*CLHEP::cm;
1600  G4Box *bBox = new G4Box(bName, bWidth/2., bHeight/2., bLength/2.);
1601  G4LogicalVolume *bLVol = new G4LogicalVolume(bBox, G4Material::GetMaterial(std::string("Slab_Stl")), bName);
1602  G4ThreeVector posTmp(0., 0., 0.);
1603  posTmp[1] = -beamlineHeight - bHeight/2.;
1604 // std::cerr << "ConstructLBNEShieldingHorn2 .... "<< bName << " zShift bottom plate " << zShift
1605 // << " thus, y position " << posTmp[1] << " coorection " << yCorr << std::endl;
1606 //
1607  new G4PVPlacement(&fRotBeamlineAngle, posTmp, bLVol, bName + std::string("_P"),
1608  vTopLevel->GetLogicalVolume(), false, 1, true);
1609 //
1610 // Sides
1611 //
1612  G4String sName = G4String("ShieldingHornCorridorSide");
1613  const double sWidth = 52.0*in;
1614  const double sHeight = 256.8*in - 52.0*in - 5.0*CLHEP::cm ; // approximate
1615  const double sLength = lengthTop - 2.*sHeight*std::abs(std::sin(fBeamlineAngle)) - 5.0*CLHEP::cm;
1616  G4Box *sBox = new G4Box(sName, sWidth/2., sHeight/2., sLength/2.);
1617  G4LogicalVolume *sLVol = new G4LogicalVolume(sBox, G4Material::GetMaterial(std::string("Slab_Stl")), sName);
1618  posTmp[0] = (-32.0 - 26.0)*in;
1619  posTmp[1] = sHeight/2. - beamlineHeight + 2.0*CLHEP::cm;
1620 // std::cerr << "ConstructLBNEShieldingBetweenHorns .... "<< sName
1621 // << " X pos. = " << posTmp[0] << " Y " << posTmp[1] << std::endl;
1622  new G4PVPlacement(&fRotBeamlineAngle, posTmp, sLVol, sName + std::string("_LeftP"),
1623  vTopLevel->GetLogicalVolume(), false, 1, true);
1624  posTmp[0] = (+32.0 + 26.0)*in;
1625  new G4PVPlacement(&fRotBeamlineAngle, posTmp, sLVol, sName + std::string("_RightP"),
1626  vTopLevel->GetLogicalVolume(), false, 2, true);
1627 //
1628 // Top. Simply put about 2m of steel
1629 //
1630  G4String tName = G4String("ShieldingHornCorridorTop");
1631  const double tWidth = 168*in;
1632  const double tHeight = 94.0*in;
1633  const double tLength = lengthTop - 2.*tHeight*std::abs(std::sin(fBeamlineAngle)) - 5.0*CLHEP::cm;
1634  G4Box *tBox = new G4Box(tName, tWidth/2., tHeight/2., tLength/2.);
1635  G4LogicalVolume *tLVol = new G4LogicalVolume(tBox, G4Material::GetMaterial(std::string("Slab_Stl")), tName);
1636 
1637  posTmp[0] =0.;
1638  posTmp[1] += sHeight/2. + tHeight/2. + 4.0*CLHEP::cm;
1639  new G4PVPlacement(&fRotBeamlineAngle, posTmp, tLVol, bName + std::string("_P"),
1640  vTopLevel->GetLogicalVolume(), false, 1, true);
1641 }
1642 void LBNEDetectorConstruction::ConstructLBNFShielding(G4VPhysicalVolume *mother) {
1643 //
1644 // We place steel, continuous plates, after Horn1..inclined along the beam line. Unrealsitic, but simple...
1645 //
1646  const G4String nameM = mother->GetLogicalVolume()->GetName();
1647  if (nameM != G4String("Tunnel")) {
1648  std::cerr
1649  << " Unexpected Mother volume in LBNEDetectorConstruction::ConstructLBNEShieldingBetweenHorns !" << std::endl;
1650  exit(2);
1651  }
1652  const LBNEVolumePlacementData *plMother =
1653  fPlacementHandler->Find(G4String("LBNFShielding"), nameM,
1654  G4String("LBNEDetectorConstruction::ConstructLBNFShielding"));
1655  const LBNEVolumePlacementData *plH1 =
1656  fPlacementHandler->Find(G4String("LBNFShielding"), G4String("TargetHallAndHorn1"),
1657  G4String("LBNEDetectorConstruction::ConstructLBNFShielding"));
1658  const double zStart = plH1->fPosition[2] + plH1->fParams[2]/2.0 + 5.0*CLHEP::cm;
1659  const double zEnd = fPlacementHandler->GetDecayPipeLongPosition() - 5.0*CLHEP::cm;
1660  const double lengthAll = zEnd - zStart;
1661  const double widthSide = 0.5*(plMother->fParams[0] - 2.0*CLHEP::cm - fPlacementHandler->GetChaseWidthForLBNF());
1662  const double heightTopBot = 0.5*(plMother->fParams[1] - 2.0*CLHEP::cm - fPlacementHandler->GetChaseWidthForLBNF());
1663  const double widthTopBot = plMother->fParams[0] - 2.0*CLHEP::cm;
1664  const double heightSide = (plMother->fParams[1] - 1.0*CLHEP::cm - 2.0*heightTopBot);
1665  std::cerr << " Shielding parameters, width " << widthSide << " htB " << heightTopBot
1666  << " widthTopBot " << widthTopBot << " heightSide " << heightSide << std::endl;
1667  // Bottom, or top, since the tunnel is symmetric. But we keep names, duplicate volume, but easier to debug.
1668  G4String botName = G4String("LBNFChaseShieldBottom");
1669  G4Box *botBox = new G4Box(botName, widthTopBot/2., heightTopBot/2., lengthAll/2.);
1670  G4LogicalVolume *botLevVol = new G4LogicalVolume(botBox, G4Material::GetMaterial(G4String("Slab_Stl")), botName);
1671  const double botY = -1.0*(plMother->fParams[1]/2. - heightTopBot/2. - 0.5*CLHEP::cm);
1672  G4ThreeVector botPosV (0., botY, 0.5*(zStart + zEnd));
1673  new G4PVPlacement((G4RotationMatrix *) 0, botPosV, botLevVol , botName + std::string("_P"),
1674  mother->GetLogicalVolume(), false, 1, true);
1675  G4String topName = G4String("LBNFChaseShieldTop");
1676  G4Box *topBox = new G4Box(topName, widthTopBot/2., heightTopBot/2., lengthAll/2.);
1677  G4LogicalVolume *topLevVol = new G4LogicalVolume(topBox, G4Material::GetMaterial(G4String("Slab_Stl")), topName);
1678  const double topY = -botY;
1679  G4ThreeVector topPosV (0., topY, 0.5*(zStart + zEnd));
1680  new G4PVPlacement((G4RotationMatrix *) 0, topPosV, topLevVol , topName + std::string("_P"),
1681  mother->GetLogicalVolume(), false, 1, true);
1682 //
1683 // O.K. kind silly, for the sides, we place here two copy of the same logical volume.
1684 //
1685  G4String sideName = G4String("LBNFChaseShieldSide");
1686  G4Box *sideBox = new G4Box(sideName, widthSide/2., heightSide/2., lengthAll/2.);
1687  G4LogicalVolume *sideVol = new G4LogicalVolume(sideBox, G4Material::GetMaterial(G4String("Slab_Stl")), sideName);
1688  const double sideX = -1.0 *(plMother->fParams[0]/2. - widthSide/2. -0.5*CLHEP::cm);
1689  G4ThreeVector sidePosV (-sideX, 0., 0.5*(zStart + zEnd));
1690  new G4PVPlacement((G4RotationMatrix *) 0, sidePosV, sideVol , sideName + std::string("_PxN"),
1691  mother->GetLogicalVolume(), false, 1, true);
1692  G4ThreeVector sidePosV2 (sideX, 0., 0.5*(zStart + zEnd));
1693  new G4PVPlacement((G4RotationMatrix *) 0, sidePosV2, sideVol , sideName + std::string("_PxP"),
1694  mother->GetLogicalVolume(), false, 2, true);
1695 }
1697  {
1698  const G4String nameM = mother->GetLogicalVolume()->GetName();
1699  if(nameM != G4String("Tunnel")){
1700  std::cerr
1701  <<"Unexpected Mother Volume in LBNEDetectorConstruction::ConstructLBNEDecayPipeTrackingPlane(G4VPhysicalVolume *mother)"<<std::endl;
1702  exit(2);
1703  }
1704  fPlacementHandler->Find(G4String("DPTrackingPlane"), nameM,
1705  G4String("LBNEDetectorConstruction::ConstructLBNEDecayPipeTrackingPlane"));
1706  const LBNEVolumePlacementData *plD1 =
1707  fPlacementHandler->Find(G4String("DPTrackingPlane"), G4String("DecayPipeHall"),
1708  G4String("LBNEDetectorConstruction::ConstructLBNEDecayPipeTrackingPlane"));
1709  const double z = plD1->fPosition[2] - plD1->fParams[2]/2.0 - 0.5*CLHEP::cm;
1710 
1711  const double widthTop = 250.00*CLHEP::cm;
1712  const double heightTop = 250.00*CLHEP::cm;
1713 
1714 // G4String topNameBetween = G4String("Horn1TrackingPlane");
1715  G4Box *topBox = new G4Box("DPTrackingPlane", widthTop/2., heightTop/2.,0.5*CLHEP::mm);
1716  TrackingPlaneDPLogical = new G4LogicalVolume(topBox, G4Material::GetMaterial(std::string("Air")),"DecayPipeTrackingPlaneLogical");
1717  G4ThreeVector posTopLevel (0., 0., z);
1718 std::cerr
1719  <<"The value of Z in DecayPipePlane is:" << z<<" "<< plD1->fPosition[2]<<" "<<plD1->fParams[2]<<std::endl;
1720 std::cerr
1721  <<" Half Width of DecayPipeTrackingPlane is (mm):" <<widthTop/2<<"Half Height of DecayPipeTrackingPlane is (mm): "<<heightTop/2<<std::endl;
1722  new G4PVPlacement((G4RotationMatrix *) 0, posTopLevel,
1723  TrackingPlaneDPLogical,"DecayPipeTrackingPlane_P",
1724  mother->GetLogicalVolume(), false, 1, true);
1725 }
1726 
1727 
1728 
1729 void LBNEDetectorConstruction::DropMarsTargetHorns(G4VPhysicalVolume *tunnel) {
1730 
1731  // Place the MARS target and horns
1732  G4cout << "Importing mars target/horn gdml file... " << G4endl;
1733 
1735  std::ifstream gdmlfile(filename.c_str());
1736  if (!gdmlfile.is_open()) {
1737  std::string mess(" AbsorberGDML file ");
1738  mess += filename + G4String(" could not be found \n");
1739  G4Exception("LBNEDetectorConstruction::DropMarsTargetHorns", " ",
1740  FatalErrorInArgument, mess.c_str());
1741  return; // perfunctory.
1742 
1743  } else {
1744  gdmlfile.close();
1745  }
1746  G4GDMLParser parser;
1747  parser.Read( filename );
1748 
1749  G4LogicalVolume *topMars = parser.GetVolume( "Marstop" );
1750 
1751 
1752  // We dump the volume hierarchy. Hoopefully not too deep,
1753  for (int i=0; i != topMars->GetNoDaughters(); ++i) {
1754  G4VPhysicalVolume *pVol = topMars->GetDaughter(i);
1755  G4LogicalVolume *lVol = pVol->GetLogicalVolume();
1756  std::cerr << " Top level daughter # " << i << " Name " << lVol->GetName()
1757  << " at " << pVol->GetObjectTranslation() << std::endl;
1758  if (lVol->GetName().find("Airbox") != std::string::npos) {
1759  G4Box *aBox = static_cast<G4Box*>(lVol->GetSolid());
1760  std::cerr << " Airbox size " << aBox->GetXHalfLength()
1761  << " / " << aBox->GetYHalfLength() << " / " << aBox->GetZHalfLength() << std::endl;
1762  }
1763  for (int ii=0; ii != lVol->GetNoDaughters(); ++ii) {
1764  G4VPhysicalVolume *pVol2 = lVol->GetDaughter(ii);
1765  G4LogicalVolume *lVol2 = pVol2->GetLogicalVolume();
1766  std::cerr << " .. 2nd level daughter # " << ii << " Name " << lVol2->GetName()
1767  << " at " << pVol2->GetObjectTranslation() << std::endl;
1768  if (lVol2->GetName().find("Airbox") != std::string::npos) {
1769  G4Box *aBox = static_cast<G4Box*>(lVol2->GetSolid());
1770  std::cerr << " Airbox size " << aBox->GetXHalfLength()
1771  << " / " << aBox->GetYHalfLength() << " / " << aBox->GetZHalfLength() << std::endl;
1772  }
1773  for (int iii=0; iii != lVol2->GetNoDaughters(); ++iii) {
1774  G4VPhysicalVolume *pVol3 = lVol2->GetDaughter(iii);
1775  G4LogicalVolume *lVol3 = pVol3->GetLogicalVolume();
1776  std::cerr << " ... 3rd level daughter # " << iii << " Name " << lVol3->GetName()
1777  << " at " << pVol3->GetObjectTranslation() << std::endl;
1778  for (int i4=0; i4 != lVol3->GetNoDaughters(); ++i4) {
1779  G4VPhysicalVolume *pVol4 = lVol3->GetDaughter(i4);
1780  G4LogicalVolume *lVol4 = pVol4->GetLogicalVolume();
1781  std::cerr << " .... 4rth level daughter # " << i4 << " Name " << lVol4->GetName()
1782  << " at " << pVol4->GetObjectTranslation() << std::endl;
1783  for (int i5=0; i5 != lVol4->GetNoDaughters(); ++i5) {
1784  G4VPhysicalVolume *pVol5 = lVol4->GetDaughter(i5);
1785  G4LogicalVolume *lVol5 = pVol5->GetLogicalVolume();
1786  std::cerr << " ..... 5rth level daughter # " << i5 << " Name " << lVol5->GetName()
1787  << " at " << pVol5->GetObjectTranslation() << std::endl;
1788  for (int i6=0; i6 != lVol5->GetNoDaughters(); ++i6) {
1789  G4VPhysicalVolume *pVol6 = lVol5->GetDaughter(i6);
1790  G4LogicalVolume *lVol6 = pVol6->GetLogicalVolume();
1791  std::cerr << " ...... 6rth level daughter # " << i6 << " Name " << lVol6->GetName() << std::endl;
1792  }
1793  }
1794  }
1795  }
1796  }
1797  }
1798 
1799  G4LogicalVolume *marsHorn1 = parser.GetVolume( "horn1" );
1800 
1801  const G4Box *horn1Sol = static_cast<const G4Box *>(marsHorn1->GetSolid());
1802 // const double marsHorn1Width = horn1Sol->GetYHalfLength();
1803 // const double marsHorn1Height = horn1Sol->GetXHalfLength();
1804 // const double marsHorn1Length = horn1Sol->GetZHalfLength();
1805  std::cerr << " Dimension of horn1 level MARS container, X " << horn1Sol->GetXHalfLength() <<
1806  " Y " << horn1Sol->GetYHalfLength() << " Z " << horn1Sol->GetZHalfLength() << std::endl;
1807  std::cerr << " Number of daughters for HORN1 " << marsHorn1->GetNoDaughters() << std::endl;
1808  double maxHalfHeight = -1.0;
1809  double maxHalfWidth = -1.0;
1810  double maxHalfLength = -1.0;
1811  for (int i=0; i != marsHorn1->GetNoDaughters(); ++i) {
1812  G4VPhysicalVolume *pVol = marsHorn1->GetDaughter(i);
1813  G4LogicalVolume *lVol = pVol->GetLogicalVolume();
1814  std::cerr << " Daughther " << lVol->GetName();
1815  const G4Tubs *aTube = static_cast<const G4Tubs *>(lVol->GetSolid());
1816 
1817  G4ThreeVector loc = pVol->GetObjectTranslation();
1818  std::cerr << " at MARS coordinates " << loc[0] << ", " <<loc[1] << ", " << loc[2] <<
1819  " zLength " << 2.0*aTube->GetZHalfLength() << std::endl;
1820  // Compute the maximum height, width. Note the confusion about X and Y X is up, vertical, in MArs
1821  if ((std::abs(loc[2]) + aTube->GetZHalfLength()) > maxHalfLength)
1822  maxHalfLength = std::abs(loc[2]) + aTube->GetZHalfLength();
1823  if ((std::abs(loc[1]) + aTube->GetOuterRadius()) > maxHalfWidth)
1824  maxHalfWidth = std::abs(loc[1]) + aTube->GetOuterRadius(); // Width is along X G4lbne orientation, which Y MARS
1825  if ((std::abs(loc[0]) + aTube->GetOuterRadius()) > maxHalfHeight)
1826  maxHalfHeight = std::abs(loc[0]) + aTube->GetOuterRadius();
1827  // Height is along Y G4lbne orientation, which is negative X in MARS
1828  }
1829  maxHalfHeight += 5.0*CLHEP::cm;
1830  maxHalfWidth += 5.0*CLHEP::cm;
1831  maxHalfLength += std::abs(maxHalfHeight*std::sin(fBeamlineAngle)) + 5.0*CLHEP::cm;;
1832  std::cerr << " Container volume for MARS, 1/2 width "
1833  << maxHalfWidth << " 1/2 Height " << maxHalfHeight
1834  << " 1/2 length " << maxHalfLength << std::endl;
1835 
1836  //std::cerr << " And shorn1 after parsing the gdml file " << std::endl; exit(2);
1837 
1838  G4Box *aMarsBoxHorn1 = new G4Box(G4String("MarsHorn1"), maxHalfWidth, maxHalfHeight, maxHalfLength);
1839  G4LogicalVolume *aMarsHorn1L =
1840  new G4LogicalVolume(aMarsBoxHorn1, G4Material::GetMaterial("Air"), G4String("MarsHorn1"));
1841  const LBNEVolumePlacementData *plTunnel =
1842  fPlacementHandler->Find(G4String("MarsHorn1"), G4String("Tunnel"),
1843  G4String("LBNEDetectorConstruction::DropMarsTargetHorns"));
1844  //const double zzz = maxHalfLength + plDecayPipe->fParams[2]/2 + plDecayPipe->fPosition[2] +
1845  // std::abs(maxHalfHeight*std::sin(fBeamlineAngle)) + 5.0*CLHEP::cm;
1846 
1847  double zzz = 1.365*CLHEP::m;
1848 
1849  std::cerr << " Position in tunnel (center) " << plTunnel->fPosition[2]
1850  << " ZPosMars " << zzz << std::endl;
1851 
1852  // One may have to adjust the height of the mars geometry ... not done yet
1853 
1854  //const double yyy = 2.3*CLHEP::m;
1855  const double yyy = 0.;
1856  G4ThreeVector posHorn1Mars(0., yyy, zzz);
1857 
1858  new G4PVPlacement(0, posHorn1Mars, aMarsHorn1L, "MarsHorn1",
1859  tunnel->GetLogicalVolume(), false, 1, true);
1860 
1861  G4RotationMatrix *marsRot = new G4RotationMatrix;
1862  marsRot->rotateZ(-M_PI/2.);
1863  for (int i=0; i != marsHorn1->GetNoDaughters(); ++i) {
1864  G4VPhysicalVolume *pVol = marsHorn1->GetDaughter(i);
1865  G4LogicalVolume *lVol = pVol->GetLogicalVolume();
1866  const G4Tubs *aBox = static_cast<const G4Tubs *>(lVol->GetSolid());
1867  G4ThreeVector loc = pVol->GetObjectTranslation();
1868 // const double yyy = loc[0] - marsHorn1Height + maxHalfHeight;
1869  double yyyI = loc[0] ; // Up to a sign!!!
1870  const double xxx = loc[1]; // Y G4LBNE = -X Mars. Was centered in MARS, set to 0., o.k.
1871  // X G4LBNE = Y Mars. !! Not centered in Mars! Perhaps, ned a shift due to the
1872  // the different size of the mother volume
1873 // const double zzz = loc[2] - marsHorn1Length + maxHalfLength;
1874  double zzzI = loc[2]; // Setting up this last to avoid air to air volume overlap.
1875  if (lVol->GetName().find("AH_horn1") != std::string::npos) {
1876  yyyI += 0.1*CLHEP::mm; // To avoid clash.. Cosmetic
1877  // Note: for release v3r0px up to v3r0p10, this was set to 27.9 m
1878  zzzI = loc[2] - 27.0*CLHEP::m;
1879  }
1880  G4ThreeVector posTmp(xxx, yyyI, zzzI);
1881  std::cerr << " Placing volume " << lVol->GetName() << " at " << posTmp << " 1/2 length (G4 coord) "
1882  << aBox->GetZHalfLength() << std::endl;
1883  //std::cerr << " .... Extend in X " << posTmp[0] - aBox->GetYHalfLength()
1884  // << " to " << posTmp[0] + aBox->GetYHalfLength() << std::endl;
1885  //std::cerr << " .... Extend in Y " << posTmp[1] - aBox->GetXHalfLength()
1886  // << " to " << posTmp[1] + aBox->GetXHalfLength() << std::endl;
1887  //std::cerr << " .... Extend in Z " << posTmp[2] - aBox->GetZHalfLength()
1888  // << " to " << posTmp[2] + aBox->GetZHalfLength() << std::endl;
1889  new G4PVPlacement(marsRot, posTmp, lVol, lVol->GetName() + std::string("_P"), aMarsHorn1L, false, 1, true);
1890  }
1891 
1892  //
1893  // We now clear the MARS horn1, simplify the geometry search
1894  //
1895  //marsHorn1->ClearDaughters();
1896 
1897 
1898  // Place Horn 2
1899  G4LogicalVolume *marsHorn2 = parser.GetVolume( "horn2" );
1900 
1901  const G4Box *horn2Sol = static_cast<const G4Box *>(marsHorn2->GetSolid());
1902 // const double marsHorn2Width = horn2Sol->GetYHalfLength();
1903 // const double marsHorn2Height = horn2Sol->GetXHalfLength();
1904 // const double marsHorn2Length = horn2Sol->GetZHalfLength();
1905  std::cerr << " Dimension of horn2 level MARS container, X " << horn2Sol->GetXHalfLength() <<
1906  " Y " << horn2Sol->GetYHalfLength() << " Z " << horn2Sol->GetZHalfLength() << std::endl;
1907  std::cerr << " Number of daughters for HORN2 " << marsHorn2->GetNoDaughters() << std::endl;
1908  maxHalfHeight = -1.0;
1909  maxHalfWidth = -1.0;
1910  maxHalfLength = -1.0;
1911  for (int i=0; i != marsHorn2->GetNoDaughters(); ++i) {
1912  G4VPhysicalVolume *pVol = marsHorn2->GetDaughter(i);
1913  G4LogicalVolume *lVol = pVol->GetLogicalVolume();
1914  std::cerr << " Daughther " << lVol->GetName();
1915  const G4Tubs *aTube = static_cast<const G4Tubs *>(lVol->GetSolid());
1916 
1917  G4ThreeVector loc = pVol->GetObjectTranslation();
1918  std::cerr << " at MARS coordinates " << loc[0] << ", " <<loc[1] << ", " << loc[2] <<
1919  " zLength " << 2.0*aTube->GetZHalfLength() << std::endl;
1920  // Compute the maximum height, width. Note the confusion about X and Y X is up, vertical, in MArs
1921  if ((std::abs(loc[2]) + aTube->GetZHalfLength()) > maxHalfLength)
1922  maxHalfLength = std::abs(loc[2]) + aTube->GetZHalfLength();
1923  if ((std::abs(loc[1]) + aTube->GetOuterRadius()) > maxHalfWidth)
1924  maxHalfWidth = std::abs(loc[1]) + aTube->GetOuterRadius(); // Width is along X G4lbne orientation, which Y MARS
1925  if ((std::abs(loc[0]) + aTube->GetOuterRadius()) > maxHalfHeight)
1926  maxHalfHeight = std::abs(loc[0]) + aTube->GetOuterRadius();
1927  // Height is along Y G4lbne orientation, which is negative X in MARS
1928  }
1929  maxHalfHeight += 5.0*CLHEP::cm;
1930  maxHalfWidth += 5.0*CLHEP::cm;
1931  maxHalfLength += std::abs(maxHalfHeight*std::sin(fBeamlineAngle)) + 5.0*CLHEP::cm;
1932  std::cerr << " Container volume for MARS, 1/2 width "
1933  << maxHalfWidth << " 1/2 Height " << maxHalfHeight
1934  << " 1/2 length " << maxHalfLength << std::endl;
1935 
1936  //std::cerr << " And shorn2 after parsing the gdml file " << std::endl; exit(2);
1937 
1938  G4Box *aMarsBoxHorn2 = new G4Box(G4String("MarsHorn2"), maxHalfWidth, maxHalfHeight, maxHalfLength);
1939  G4LogicalVolume *aMarsHorn2L =
1940  new G4LogicalVolume(aMarsBoxHorn2, G4Material::GetMaterial("Air"), G4String("MarsHorn2"));
1941  const LBNEVolumePlacementData *plTunnel2 =
1942  fPlacementHandler->Find(G4String("MarsHorn2"), G4String("Tunnel"),
1943  G4String("LBNEDetectorConstruction::DropMarsTargetHorns"));
1944  //const double zzz = maxHalfLength + plDecayPipe->fParams[2]/2 + plDecayPipe->fPosition[2] +
1945  // std::abs(maxHalfHeight*std::sin(fBeamlineAngle)) + 5.0*CLHEP::cm;
1946 
1947  zzz = 8.365*CLHEP::m;
1948 
1949  std::cerr << " Position in tunnel (center) " << plTunnel2->fPosition[2]
1950  << " ZPosMars " << zzz << std::endl;
1951 
1952  // One may have to adjust the height of the mars geometry ... not done yet
1953 
1954  const double yyy2 = 0;
1955  G4ThreeVector posHorn2Mars(0., yyy2, zzz);
1956 
1957  new G4PVPlacement(0, posHorn2Mars, aMarsHorn2L, "MarsHorn2",
1958  tunnel->GetLogicalVolume(), false, 1, true);
1959 
1960  G4RotationMatrix *marsRot2 = new G4RotationMatrix;
1961  marsRot2->rotateZ(-M_PI/2.);
1962  for (int i=0; i != marsHorn2->GetNoDaughters(); ++i) {
1963  G4VPhysicalVolume *pVol = marsHorn2->GetDaughter(i);
1964  G4LogicalVolume *lVol = pVol->GetLogicalVolume();
1965  const G4Tubs *aBox = static_cast<const G4Tubs *>(lVol->GetSolid());
1966  G4ThreeVector loc = pVol->GetObjectTranslation();
1967 // const double yyy = loc[0] - marsHorn2Height + maxHalfHeight;
1968  double yyy3 = loc[0] ; // Up to a sign!!!
1969  const double xxx = loc[1]; // Y G4LBNE = -X Mars. Was centered in MARS, set to 0., o.k.
1970  // X G4LBNE = Y Mars. !! Not centered in Mars! Perhaps, ned a shift due to the
1971  // the different size of the mother volume
1972 // const double zzz = loc[2] - marsHorn2Length + maxHalfLength;
1973  double zzz3 = loc[2]; // Setting up this last to avoid air to air volume overlap.
1974  if (lVol->GetName().find("AH_horn2") != std::string::npos) {
1975  yyy3 += 0.1*CLHEP::mm; // To avoid clash.. Cosmetic
1976  // Note: for release v3r0px up to v3r0p10, this was set to 27.9 m
1977  zzz3 = loc[2] - 27.0*CLHEP::m;
1978  }
1979  G4ThreeVector posTmp(xxx, yyy3, zzz3);
1980  std::cerr << " Placing volume " << lVol->GetName() << " at " << posTmp << " 1/2 length (G4 coord) "
1981  << aBox->GetZHalfLength() << std::endl;
1982  //std::cerr << " .... Extend in X " << posTmp[0] - aBox->GetYHalfLength()
1983  // << " to " << posTmp[0] + aBox->GetYHalfLength() << std::endl;
1984  //std::cerr << " .... Extend in Y " << posTmp[1] - aBox->GetXHalfLength()
1985  // << " to " << posTmp[1] + aBox->GetXHalfLength() << std::endl;
1986  //std::cerr << " .... Extend in Z " << posTmp[2] - aBox->GetZHalfLength()
1987  // << " to " << posTmp[2] + aBox->GetZHalfLength() << std::endl;
1988  new G4PVPlacement(marsRot2, posTmp, lVol, lVol->GetName() + std::string("_P"), aMarsHorn2L, false, 1, true);
1989  }
1990 
1991  //
1992  // We now clear the MARS horn2, simplify the geometry search
1993  //
1994  //marsHorn2->ClearDaughters();
1995 
1996  //
1997  // Place the decay Pipe Snout, which contains the window, in case we have Helium gas.
1998  //
1999  fPlacementHandler->Create(G4String("DecayPipeSnout")); // Now in Snout region
2000  fPlacementHandler->PlaceFinalDecayPipeSnout((G4PVPlacement*) tunnel);
2001 
2002  //
2003  // Place the decay pipe
2004  //
2005  fPlacementHandler->Create(G4String("DecayPipeHall"));
2006  G4PVPlacement *vDecayPipe = fPlacementHandler->PlaceFinal(G4String("DecayPipeHall"), tunnel);
2007  fPlacementHandler->Create(G4String("DecayPipeConcrete"));
2008  fPlacementHandler->Create(G4String("DecayPipeOuterWall"));
2009  fPlacementHandler->Create(G4String("DecayPipeWall"));
2010  fPlacementHandler->Create(G4String("DecayPipeVolume"));
2011  // fPlacementHandler->Create(G4String("DecayPipeUpstrWindow")); // Now in Snout region
2012 
2013  fPlacementHandler->PlaceFinal(G4String("DecayPipeConcrete"), vDecayPipe);
2014  fPlacementHandler->PlaceFinal(G4String("DecayPipeOuterWall"), vDecayPipe);
2015  fPlacementHandler->PlaceFinal(G4String("DecayPipeWall"), vDecayPipe);
2016  fPlacementHandler->PlaceFinal(G4String("DecayPipeVolume"), vDecayPipe);
2017 
2018  //!!: Define geometry absorber from /LBNE/det/ConstructSimpAbsorber true/false option
2019  if (this->fConstructSimpAbsorber){
2020  this->ConstructLBNEHadronAbsorberSimple(tunnel);
2021  }
2022  else{
2023  this->ConstructLBNEHadronAbsorber(tunnel);
2024  }
2025 
2026 }
2027 
2028 
2030 {
2031  LBNEDir = new G4UIdirectory("/LBNE/");
2032  LBNEDir->SetGuidance("UI commands for detector geometry");
2033 
2034  detDir = new G4UIdirectory("/LBNE/det/");
2035  detDir->SetGuidance("detector control");
2036 
2037 
2038  ConstructTarget = new G4UIcmdWithABool("/LBNE/det/constructTarget",this);
2039  ConstructTarget->SetParameterName("constructTarget", false);
2040  ConstructTarget->SetGuidance("Target construction on/off");
2041  ConstructTarget->SetParameterName("constructTarget",true);
2042  ConstructTarget->AvailableForStates(G4State_PreInit,G4State_Idle);
2043 
2044  SetBeamlineAngle = new
2045  G4UIcmdWithADoubleAndUnit("/LBNE/det/setBeamlineAngle",this);
2046  SetBeamlineAngle->SetParameterName("angle", false);
2047  SetBeamlineAngle->SetGuidance("Set the angle of the beamline");
2048 
2049  UpdateCmd = new G4UIcmdWithoutParameter("/LBNE/det/update",this);
2050  UpdateCmd->SetGuidance("Update or Construct LBNE geometry. Same difference ");
2051  UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
2052  UpdateCmd->SetGuidance("if you changed geometrical value(s).");
2053  UpdateCmd->AvailableForStates(G4State_PreInit);
2054 
2055  ConstructCmd = new G4UIcmdWithoutParameter("/LBNE/det/construct",this);
2056  ConstructCmd->SetGuidance("Construct LBNE geometry. Should be one and only time ");
2057  ConstructCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
2058  ConstructCmd->SetGuidance("if you changed geometrical value(s).");
2059  ConstructCmd->AvailableForStates(G4State_PreInit);
2060 
2061  //Messenger for simple geometry of absorber
2062  ConstructSimpAbsorber = new G4UIcmdWithABool("/LBNE/det/ConstructSimpAbsorber",this);
2063  ConstructSimpAbsorber->SetParameterName("Simple Absorber",true);
2064  ConstructSimpAbsorber->SetGuidance("Set geometry of Hadron Absorber. If true simulate simple version of absorber");
2065  ConstructSimpAbsorber->SetDefaultValue(false);
2066  ConstructSimpAbsorber->AvailableForStates(G4State_PreInit,G4State_Idle);
2067 
2068  ConstructSculptedAbsorber = new G4UIcmdWithABool("/LBNE/det/ConstructSculptedAbsorber",this);
2069  ConstructSculptedAbsorber->SetParameterName("Aluminum, Sculpted Absorber",true);
2070  ConstructSculptedAbsorber->SetGuidance("Set geometry of Hadron Absorber. If true simulate the 2015 Sculpted absorber");
2071  ConstructSculptedAbsorber->SetDefaultValue(false);
2072  ConstructSculptedAbsorber->AvailableForStates(G4State_PreInit,G4State_Idle);
2073 
2074  DisableSpoiler = new G4UIcmdWithABool("/LBNE/det/DisableSpoiler",this);
2075  DisableSpoiler->SetParameterName("Remove spoiler",true);
2076  DisableSpoiler->SetGuidance("If true simulate the 2015 Sculpted absorber without the spoiler");
2077  DisableSpoiler->SetDefaultValue(false);
2078  DisableSpoiler->AvailableForStates(G4State_PreInit,G4State_Idle);
2079 
2080  DisableSculptedLayers = new G4UIcmdWithABool("/LBNE/det/DisableSculptedLayers",this);
2081  DisableSculptedLayers->SetParameterName("Remove sculpting",true);
2082  DisableSculptedLayers->SetGuidance("If true simulate the 2015 Sculpted absorber without the sculpting on the aluminum layers");
2083  DisableSculptedLayers->SetDefaultValue(false);
2084  DisableSculptedLayers->AvailableForStates(G4State_PreInit,G4State_Idle);
2085 
2086  DisableMask = new G4UIcmdWithABool("/LBNE/det/DisableMask",this);
2087  DisableMask->SetParameterName("Remove sculpting",true);
2088  DisableMask->SetGuidance("If true simulate the 2015 Sculpted absorber without the mask layers between the spoiler and core part of the absorber");
2089  DisableMask->SetDefaultValue(false);
2090  DisableMask->AvailableForStates(G4State_PreInit,G4State_Idle);
2091 
2092  ExpandAlLayers = new G4UIcmdWithABool("/LBNE/det/ExpandAlLayers",this);
2093  ExpandAlLayers->SetParameterName("Expand Sculpted Absorber Al layers to 2.8x2.8 m",true);
2094  ExpandAlLayers->SetGuidance("If true simulate the 2015 Sculpted absorber with a core region to the size of the decay pipe");
2095  ExpandAlLayers->SetDefaultValue(false);
2096  ExpandAlLayers->AvailableForStates(G4State_PreInit,G4State_Idle);
2097 
2098  RemoveLayers = new G4UIcmdWithAnInteger("/LBNE/det/RemoveLayers",this);
2099  RemoveLayers->SetParameterName("Number of layers to remove from the downstream end of the absorber",true);
2100  RemoveLayers->SetGuidance("Simulate the 2015 Sculpted absorber with fewer layers");
2101  RemoveLayers->SetDefaultValue(0);
2102  RemoveLayers->AvailableForStates(G4State_PreInit,G4State_Idle);
2103 
2104  DwStrAbsSteelWidth = new G4UIcmdWithADoubleAndUnit("/LBNE/det/DwStrAbsSteelWidth",this);
2105  DwStrAbsSteelWidth->SetParameterName("Steel Downstr Width",true);
2106  DwStrAbsSteelWidth->SetGuidance("Define the downstream width (m) of the steel volume in the simple geometry of absorber. Default value is ...");
2108  DwStrAbsSteelWidth->SetDefaultUnit("m");
2109  DwStrAbsSteelWidth->AvailableForStates(G4State_PreInit);
2110 
2111  DwStrAbsConcreteWidth = new G4UIcmdWithADoubleAndUnit("/LBNE/det/DwStrAbsConcreteWidth",this);
2112  DwStrAbsConcreteWidth->SetParameterName("Concrete Downstr Width",true);
2113  DwStrAbsConcreteWidth->SetGuidance("Define the downstream width (m) of the concrete volume in the simple geometry of absorber. Default value is ...");
2115  DwStrAbsConcreteWidth ->SetDefaultUnit("m");
2116  DwStrAbsConcreteWidth->AvailableForStates(G4State_PreInit);
2117 
2118  new G4UnitDefinition("kiloampere" , "kA", "Electric current", 1000.*CLHEP::ampere);
2119  SetHornCurrent = new
2120  G4UIcmdWithADoubleAndUnit("/LBNE/det/seHornCurrent",this);
2121  SetHornCurrent->SetParameterName("Horn Current", false);
2122  SetHornCurrent->SetGuidance(" The current for the horn system. (Horn1 and Horn2 are in series.");
2123  SetHornCurrent ->SetDefaultValue(200.0); // CDR, March 2012
2124  SetHornCurrent->SetDefaultUnit("kA");
2125  SetHornCurrent->SetUnitCandidates("kA");
2126  SetHornCurrent->AvailableForStates(G4State_PreInit);
2127  {
2128  SetSkinDepthInnerRad = new G4UIcmdWithADoubleAndUnit("/LBNE/det/SetSkinDepthInnerRad",this);
2129  std::string aGuidance("The skin depth for the inner conductor. \n ");
2130  aGuidance += std::string(" The default assumes infinite. Using Zarko' thesis model, \n");
2131  aGuidance += std::string(" MINOS Document 5694-v1, section 5.2.4, p150 - 156 \n");
2132  SetSkinDepthInnerRad->SetGuidance(aGuidance.c_str());
2133  SetSkinDepthInnerRad->SetParameterName("SetSkinDepthInnerRad",true);
2134  SetSkinDepthInnerRad->SetDefaultValue (1.0e10*CLHEP::mm);
2135  SetSkinDepthInnerRad->AvailableForStates(G4State_PreInit);
2136  }
2137  {
2138  for (size_t kH=0; kH != 3; kH++) { // We will work with only 3 horns. Per executive decision of Laura F.
2139  std::ostringstream aNStrStr; aNStrStr << "/LBNE/det/SetHorn" << (kH+1) << "DeltaEccentricityIO";
2140  std::string aNStr(aNStrStr.str());
2141  G4UIcmdWithADoubleAndUnit* aGUICmd = new G4UIcmdWithADoubleAndUnit(aNStr.c_str(),this);
2142  std::ostringstream aNGStrStr; aNGStrStr
2143  << "The Eccentricity between Inner/Outer conductors for Horn number " << (kH+1) << "\n.";
2144  std::string aNGStr(aNGStrStr.str());
2145  aGUICmd->SetGuidance(aNGStr.c_str());
2146  aGUICmd->SetParameterName("SetHornxDeltaEccentricityIO",true);
2147  aGUICmd->SetDefaultValue (0.);
2148  aGUICmd->AvailableForStates(G4State_PreInit);
2149  SetHornsDeltaEccentricityIO.push_back(aGUICmd);
2150  }
2151  }
2152  {
2153  //
2154 
2155  for (size_t kH=0; kH != 3; kH++) { // We will work with only 3 horns. Per executive decision of Laura F.
2156  std::ostringstream aNStrStr; aNStrStr << "/LBNE/det/SetHorn" << (kH+1) << "DeltaEllipticityI";
2157  std::string aNStr(aNStrStr.str());
2158  G4UIcmdWithADoubleAndUnit* aGUICmd = new G4UIcmdWithADoubleAndUnit(aNStr.c_str(),this);
2159  std::ostringstream aNGStrStr; aNGStrStr
2160  << "The Ellipticity of the Inner conductor for Horn number " << (kH+1) << "\n.";
2161  std::string aNGStr(aNGStrStr.str());
2162  aGUICmd->SetGuidance(aNGStr.c_str());
2163  aGUICmd->SetParameterName("SetHornxDeltaEllipticityI",true);
2164  aGUICmd->SetDefaultValue (0.);
2165  aGUICmd->AvailableForStates(G4State_PreInit);
2166  SetHornsDeltaEllipticityI.push_back(aGUICmd);
2167  }
2168  }
2169  {
2170  for (size_t kH=0; kH != 3; kH++) { // We will work with only 3 horns. Per executive decision of Laura F.
2171  std::ostringstream aNStrStr;
2172  aNStrStr << "/LBNE/det/SetHorn" << (kH+1) << "CurrentMultipiler";
2173  std::string aNStr(aNStrStr.str());
2174  G4UIcmdWithADouble* aGUICmd = new G4UIcmdWithADouble(aNStr.c_str(),this);
2175  std::ostringstream aNGStrStr; aNGStrStr
2176  << "A magic current amplifier to increase/decrease the current for Horn number " << (kH+1) << "\n.";
2177  std::string aNGStr(aNGStrStr.str());
2178  aGUICmd->SetGuidance(aNGStr.c_str());
2179  aGUICmd->SetParameterName("SetHornxCurrentMultiplier",true);
2180  aGUICmd->SetDefaultValue (1.);
2181  aGUICmd->AvailableForStates(G4State_PreInit);
2182  SetHornsCurrentMultiplier.push_back(aGUICmd);
2183  }
2184  }
2185  {
2186  for (size_t kH=0; kH != 3; kH++) { // We will work with only 3 horns. Per executive decision of Laura F.
2187  std::ostringstream aNStrStr;
2188  aNStrStr << "/LBNE/det/SetHorn" << (kH+1) << "CurrentEqualizerLongAbsLength";
2189  std::string aNStr(aNStrStr.str());
2190  G4UIcmdWithADoubleAndUnit* aGUICmd = new G4UIcmdWithADoubleAndUnit(aNStr.c_str(),this);
2191  std::ostringstream aNGStrStr; aNGStrStr
2192  << "The charact. length of the decrease of the azimuthal anisotropy \n "
2193  << " due imperfect current equal. section for Horn number " << (kH+1) << "\n.";
2194  std::string aNGStr(aNGStrStr.str());
2195  aGUICmd->SetGuidance(aNGStr.c_str());
2196  aGUICmd->SetParameterName("SetHornxCurrentEqualizerLongAbsLength",true);
2197  aGUICmd->SetDefaultValue (100.);
2198  aGUICmd->AvailableForStates(G4State_PreInit);
2199  SetHornsCurrentEqualizerLongAbsLength.push_back(aGUICmd);
2200  }
2201  }
2202  {
2203  for (size_t kH=0; kH != 3; kH++) { // We will work with only 3 horns. Per executive decision of Laura F.
2204  std::ostringstream aNStrStr;
2205  aNStrStr << "/LBNE/det/SetHorn" << (kH+1) << "CurrentEqualizerQuadAmpl";
2206  std::string aNStr(aNStrStr.str());
2207  G4UIcmdWithADouble* aGUICmd = new G4UIcmdWithADouble(aNStr.c_str(),this);
2208  std::ostringstream aNGStrStr; aNGStrStr
2209  << "The amplitude of the azimuthal, quadrupolar, anisotropy \n "
2210  << " due imperfect current equal. section for Horn number " << (kH+1) << "\n.";
2211  std::string aNGStr(aNGStrStr.str());
2212  aGUICmd->SetGuidance(aNGStr.c_str());
2213  aGUICmd->SetParameterName("SetHornxCurrentEqualizerQuadAmpl",true);
2214  aGUICmd->SetDefaultValue (0.);
2215  aGUICmd->AvailableForStates(G4State_PreInit);
2216  SetHornsCurrentEqualizerQuadAmpl.push_back(aGUICmd);
2217  }
2218  }
2219  {
2220  for (size_t kH=0; kH != 3; kH++) { // We will work with only 3 horns. Per executive decision of Laura F.
2221  std::ostringstream aNStrStr;
2222  aNStrStr << "/LBNE/det/SetHorn" << (kH+1) << "CurrentEqualizerOctAmpl";
2223  std::string aNStr(aNStrStr.str());
2224  G4UIcmdWithADouble* aGUICmd = new G4UIcmdWithADouble(aNStr.c_str(),this);
2225  std::ostringstream aNGStrStr; aNGStrStr
2226  << "The amplitude of the azimuthal, quadrupolar, anisotropy \n "
2227  << " due imperfect current equal. section for Horn number " << (kH+1) << "\n.";
2228  std::string aNGStr(aNGStrStr.str());
2229  aGUICmd->SetGuidance(aNGStr.c_str());
2230  aGUICmd->SetParameterName("SetHornxCurrentEqualizerOctAmpl",true);
2231  aGUICmd->SetDefaultValue (0.);
2232  aGUICmd->AvailableForStates(G4State_PreInit);
2233  SetHornsCurrentEqualizerOctAmpl.push_back(aGUICmd);
2234  }
2235  }
2236  {
2237  for (size_t kH=0; kH != 3; kH++) { // We will work with only 3 horns. Per executive decision of Laura F.
2238  std::ostringstream aNStrStr;
2239  aNStrStr << "/LBNE/det/SetHorn" << (kH+1) << "CurrentEqualizerMapFileName";
2240  std::string aNStr(aNStrStr.str());
2241  G4UIcmdWithAString* aGUICmd = new G4UIcmdWithAString(aNStr.c_str(),this);
2242  std::ostringstream aNGStrStr; aNGStrStr
2243  << "The file name for the field map created from a priot run, \n "
2244  << " related to imperfect current equal. section for Horn number " << (kH+1) << "\n.";
2245  std::string aNGStr(aNGStrStr.str());
2246  aGUICmd->SetGuidance(aNGStr.c_str());
2247  aGUICmd->SetParameterName("SetHornxCurrentEqualizerFileName",true);
2248  aGUICmd->SetDefaultValue("?");
2249  aGUICmd->AvailableForStates(G4State_PreInit);
2250  SetFileNameFieldMapForCE.push_back(aGUICmd);
2251  }
2252  }
2253  {
2254  ZCoordForPerfectFocusing = new G4UIcmdWithADoubleAndUnit("/LBNE/det/ZCoordForPerfectFocusing",this);
2255  std::string aGuidance("The Z-location at which the perfect focusing process set the track polar angle to zero \n ");
2256  aGuidance += std::string(" If this Z is > 0. , we trigger the instantaneous foucing at this Z \n");
2257  aGuidance += std::string(" else, Z < 0., we trigger the instantaneous foucing at the radius of Target Canister \n");
2258  aGuidance += std::string(" which, for the LBNE 1.2 MW option is 17.6 mm \n");
2259  ZCoordForPerfectFocusing->SetGuidance(aGuidance.c_str());
2260  ZCoordForPerfectFocusing->SetParameterName("ZCoordForPerfectFocusing", true);
2261  ZCoordForPerfectFocusing->SetDefaultUnit ("m");
2262  ZCoordForPerfectFocusing->SetUnitCandidates ("mm cm m");
2263  ZCoordForPerfectFocusing->SetDefaultValue (1.0e103);
2264  ZCoordForPerfectFocusing->AvailableForStates(G4State_PreInit);
2265  }
2266  /*
2267  {
2268  ConstructLBNFNano = new G4UIcmdWithABool("/LBNF/det/ConstructLBNFNano",this);
2269  ConstructLBNFNano->SetParameterName("ConstructLBNFNano", false);
2270  ConstructLBNFNano->SetGuidance("Neutrino Progenitor Spectrometer construction on/off");
2271  ConstructLBNFNano->SetParameterName("ConstructLBNFNano",true);
2272  ConstructLBNFNano->AvailableForStates(G4State_PreInit,G4State_Idle);
2273  }
2274  */
2275 }
2276 
2278 {
2279 
2280  delete detDir;
2281  delete LBNEDir;
2282  delete ConstructSimpAbsorber;
2284  delete DwStrAbsConcreteWidth;
2285  delete DwStrAbsSteelWidth;
2286  delete ConstructTarget;
2287  delete SetBeamlineAngle;
2288  delete UpdateCmd;
2289  delete ConstructCmd;
2290  delete SetHornCurrent;
2291  delete SetSkinDepthInnerRad;
2292  for (size_t kH=0; kH != 3; kH++) {
2293  delete SetHornsDeltaEccentricityIO[kH];
2294  delete SetHornsDeltaEllipticityI[kH];
2297  delete SetFileNameFieldMapForCE[kH];
2299  delete SetHornsCurrentMultiplier[kH];
2300  }
2301  delete ZCoordForPerfectFocusing;
2302  delete DisableSpoiler;
2303  delete DisableSculptedLayers;
2304  delete DisableMask;
2305  delete ExpandAlLayers;
2306  delete RemoveLayers;
2307 }
2308 
2309 
2310 void LBNEDetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
2311 {
2312 
2313  //Turn on and off simple geometry
2314  //Note: ConstructSimpAbsorber defined in LBNEDetectorMessemger.hh
2315  // SetConstructSimpAbsorber and fConstructSimpAbsorber defined in LBNEDetectorConstruction.hh
2316  if ( command == ConstructSimpAbsorber )
2317  {
2318  LBNEDetector->SetConstructSimpAbsorber(ConstructSimpAbsorber->GetNewBoolValue(newValue));
2319  }
2320 
2321  if ( command == ConstructSculptedAbsorber )
2322  {
2324  }
2325 
2326  if ( command == DisableSpoiler )
2327  {
2328  LBNEDetector->SetDisableSpoiler(DisableSpoiler->GetNewBoolValue(newValue));
2329  }
2330 
2331  if ( command == DisableSculptedLayers )
2332  {
2333  LBNEDetector->SetDisableSculptedLayers(DisableSculptedLayers->GetNewBoolValue(newValue));
2334  }
2335 
2336  if ( command == DisableMask )
2337  {
2338  LBNEDetector->SetDisableMask(DisableMask->GetNewBoolValue(newValue));
2339  }
2340 
2341  if ( command == ExpandAlLayers )
2342  {
2343  LBNEDetector->SetExpandAlLayers(ExpandAlLayers->GetNewBoolValue(newValue));
2344  }
2345 
2346  if ( command == RemoveLayers )
2347  {
2348  LBNEDetector->SetRemoveLayers(RemoveLayers->GetNewIntValue(newValue));
2349  }
2350 
2351  if ( command == DwStrAbsSteelWidth )
2352  {
2353  G4UIcmdWithADoubleAndUnit* cmdSteelDwStr = dynamic_cast<G4UIcmdWithADoubleAndUnit*> (command);
2354  LBNEDetector->SetDwStrAbsSteelWidth(cmdSteelDwStr->GetNewDoubleValue(newValue));
2355  //G4double SteelWidth = LBNEDetector->GetDwStrAbsSteelWidth();
2356  }
2357 
2358 
2359  if ( command == DwStrAbsConcreteWidth)
2360  {
2361  G4UIcmdWithADoubleAndUnit* cmdConcreteDwStr = dynamic_cast<G4UIcmdWithADoubleAndUnit*> (command);
2362  LBNEDetector->SetDwStrAbsConcreteWidth(cmdConcreteDwStr->GetNewDoubleValue(newValue));
2363  // G4double ConcWidth = LBNEDetector->GetDwStrAbsConcreteWidth();
2364  }
2365 
2366  if ( command == UpdateCmd )
2367  {
2369  return;
2370  }
2371  if ( command == ConstructCmd )
2372  {
2374  return;
2375  }
2376  if (command == SetHornCurrent) {
2377  G4UIcmdWithADoubleAndUnit* cmdWD = dynamic_cast<G4UIcmdWithADoubleAndUnit*> (command);
2378  LBNEDetector->SetHornCurrent(cmdWD->GetNewDoubleValue(newValue));
2379  }
2380  if (command == SetSkinDepthInnerRad) {
2381  G4UIcmdWithADoubleAndUnit* cmdWD = dynamic_cast<G4UIcmdWithADoubleAndUnit*> (command);
2382  LBNEDetector->SetSkinDepthInnerRad(cmdWD->GetNewDoubleValue(newValue));
2383  }
2384  for (size_t kH=0; kH != 3; kH++) {
2385  if (command == SetHornsDeltaEccentricityIO[kH]) {
2386  G4UIcmdWithADoubleAndUnit* cmdWD = dynamic_cast<G4UIcmdWithADoubleAndUnit*> (command);
2387  LBNEDetector->SetDeltaEccentricityIO(kH, cmdWD->GetNewDoubleValue(newValue));
2388  }
2389  if (command == SetHornsDeltaEllipticityI[kH]) {
2390  G4UIcmdWithADoubleAndUnit* cmdWD = dynamic_cast<G4UIcmdWithADoubleAndUnit*> (command);
2391  LBNEDetector->SetDeltaEllipticityI(kH, cmdWD->GetNewDoubleValue(newValue));
2392  }
2393  if (command == SetHornsCurrentEqualizerLongAbsLength[kH]) {
2394  G4UIcmdWithADoubleAndUnit* cmdWD = dynamic_cast<G4UIcmdWithADoubleAndUnit*> (command);
2395  LBNEDetector->SetCurrentEqualizerLongAbsLength(kH, cmdWD->GetNewDoubleValue(newValue));
2396  }
2397  if (command == SetHornsCurrentEqualizerQuadAmpl[kH]) {
2398  G4UIcmdWithADouble* cmdWD = dynamic_cast<G4UIcmdWithADouble*> (command);
2399  LBNEDetector->SetCurrentEqualizerQuadAmpl(kH, cmdWD->GetNewDoubleValue(newValue));
2400  }
2401  if (command == SetFileNameFieldMapForCE[kH]) {
2402  LBNEDetector->SetFileNameFieldMapForCE(kH, newValue);
2403  }
2404  if (command == SetHornsCurrentEqualizerOctAmpl[kH]) {
2405  G4UIcmdWithADouble* cmdWD = dynamic_cast<G4UIcmdWithADouble*> (command);
2406  LBNEDetector->SetCurrentEqualizerOctAmpl(kH, cmdWD->GetNewDoubleValue(newValue));
2407  }
2408  if (command == SetHornsCurrentMultiplier[kH]) {
2409  G4UIcmdWithADouble* cmdWD = dynamic_cast<G4UIcmdWithADouble*> (command);
2410  LBNEDetector->SetCurrentMultipiler(kH, cmdWD->GetNewDoubleValue(newValue));
2411  }
2412  }
2413  if (command == ZCoordForPerfectFocusing) {
2414  G4UIcmdWithADoubleAndUnit* cmdWD = dynamic_cast<G4UIcmdWithADoubleAndUnit*> (command);
2415  double val = cmdWD->GetNewDoubleValue(newValue);
2417  if (val < 0.) {
2418  std::cout << " You have chosen a near perfect focus exiting the target Helium containment vessel " << std::endl;
2419  std::cout << " This only make sens if the real horn current is vanishlingly small.. " << std::endl;
2420  LBNEDetector->SetHornCurrent(2.0e-11);
2421  std::cout << " ...Done.. Also, Horn's conductors are made of air " << std::endl;
2423  G4String matAir("Air");
2424  volP->SetHorn1InnerConductorMaterial(matAir);
2425  volP->SetHorn1AllConductorMaterial(matAir);
2426  volP->SetHorn2InnerConductorMaterial(matAir);
2427  volP->SetHorn2AllConductorMaterial(matAir);
2428  } else if (val > 22499.*CLHEP::mm) {
2429  std::cout << " You have chosen a near perfect focus entering the decay channel at Z = " << val << std::endl;
2430  }
2431  }
2432  /*
2433  ** not yet deployed..
2434  **
2435  if (command == ConstructLBNFNano) {
2436  G4UIcmdWithABool* cmdWD = dynamic_cast<G4UIcmdWithABool*> (command);
2437  LBNEDetector->SetConstructLBNFNano(cmdWD->GetNewBoolValue(newValue));
2438  }
2439  */
2440 }
2441 
2442 
double GetCurrentMilindWire() const
double GetChaseWidthForLBNF() const
double GetTargetDensity() const
G4UIcmdWithADoubleAndUnit * SetHornCurrent
void SetSkinDepthInnerRad(G4double f)
void SetWireCurrent(G4double iC)
void SetConstructSimpAbsorber(G4bool aBool)
LBNEDetectorConstruction * LBNEDetector
const LBNEVolumePlacementData * Find(const G4String &name, const char *motherName, const char *method) const
G4UIcmdWithABool * ConstructTarget
bool GetUseLBNFOptimConceptDesignHornB() const
void ConstructLBNEShieldingHorn2(G4PVPlacement *vPhys)
std::string string
Definition: nybbler.cc:12
std::vector< G4UIcmdWithAString * > SetFileNameFieldMapForCE
std::vector< double > fCurrentEqualizerLongAbsLength
double GetPlugZPosition() const
double GetDecayPipeLongPosition() const
static LBNEVolumePlacements * Instance()
void SetTargetHorn1HallPhysPtr(G4VPhysicalVolume *p)
int command
void SetCurrentEqualizerOctAmpl(size_t kH, double v)
void SetCurrentEqualizerQuadAmpl(size_t kH, double v)
G4String GetMarsTargetHornsGDMLFilename() const
LBNEDetectorMessenger(LBNEDetectorConstruction *)
void ConstructLBNEShieldingBetweenHorns(G4VPhysicalVolume *tunnel)
std::vector< G4UIcmdWithADoubleAndUnit * > SetHornsDeltaEccentricityIO
bool GetUseLBNFOptimConceptDesignHornC() const
void ConstructLBNEHadronAbsorberSimple(G4VPhysicalVolume *vPhys)
void DropMarsTargetHorns(G4VPhysicalVolume *mother)
G4UIcmdWithoutParameter * ConstructCmd
void UpdateParamsForHornMotherPolyNum(size_t iH)
std::vector< G4UIcmdWithADouble * > SetHornsCurrentEqualizerOctAmpl
G4UIcmdWithADoubleAndUnit * SetSkinDepthInnerRad
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:45
void SetNewValue(G4UIcommand *, G4String)
void PlaceFinalNoSplitHorn1(G4PVPlacement *mother, G4PVPlacement *motherTop)
void ConstructLBNEHadronAbsorberSculpted(G4VPhysicalVolume *vPhys)
G4UIcmdWithADoubleAndUnit * ZCoordForPerfectFocusing
std::vector< G4UIcmdWithADoubleAndUnit * > SetHornsDeltaEllipticityI
G4String GetAbsorberGDMLFilename() const
std::vector< G4UIcmdWithADouble * > SetHornsCurrentMultiplier
void SetDeltaEccentricityIO(size_t kH, G4double val)
string filename
Definition: train.py:213
void SetTarget2SpecificLambda(double l)
void ConstructLBNEShieldingHorn1(G4VPhysicalVolume *vPhys)
bool GetUseLBNFOptimConceptDesignHornA() const
void ConstructLBNEHadronAbsorber(G4VPhysicalVolume *vPhys)
G4UIcmdWithADoubleAndUnit * SetBeamlineAngle
bool GetUseSimpleTargetBox() const
void SetTargetSpecificLambda(double l)
std::vector< double > fDeltaEccentricityIO
void ConstructLBNEHorn2TrackingPlane(G4VPhysicalVolume *tunnel)
G4String GetDecayPipeGas() const
T abs(T value)
bool GetUseMarsTargetHorns() const
std::vector< double > fCurrentEqualizerOctAmpl
std::vector< double > fParams
void SetHorn2AllConductorMaterial(G4String &name)
double GetTotalLengthOfRock() const
LBNEVolumePlacements * fPlacementHandler
G4String GetTargetMaterialName() const
G4UIcmdWithADoubleAndUnit * DwStrAbsConcreteWidth
G4UIcmdWithABool * ExpandAlLayers
void SetTotalLengthOfRock(double l)
double z
LBNEVolumePlacementData * Create(const G4String &name)
void SetHorn2InnerConductorMaterial(G4String &name)
G4String GetTarget2MaterialName() const
std::vector< double > fCurrentEqualizerQuadAmpl
void ConstructLBNFShielding(G4VPhysicalVolume *vPhys)
void PlaceFinalHorn2(G4PVPlacement *mother)
G4UIcmdWithAnInteger * RemoveLayers
void SetDisableSculptedLayers(G4bool aBool)
void SetConstructSculptedAbsorber(G4bool aBool)
std::vector< G4UIcmdWithADoubleAndUnit * > SetHornsCurrentEqualizerLongAbsLength
std::vector< double > fCurrentMultiplier
bool GetRemoveDecayPipeSnout() const
void PlaceFinalSimpleHornPolyNumber(size_t iHorn, G4PVPlacement *mother)
void SetHorn1InnerConductorMaterial(G4String &name)
std::string GetPlugMaterial() const
bool GetUseCDR2015Optimized() const
void Initialize(const G4LogicalVolume *matriarch)
G4VisAttributes * GetMaterialVisAttrib(G4String matName)
G4UIcmdWithABool * DisableSpoiler
G4UIcmdWithoutParameter * UpdateCmd
void SetCurrentEqualizerLongAbsLength(size_t kH, double v)
G4UIcmdWithABool * ConstructSculptedAbsorber
void SetHorn1HallPhysPtr(G4PVPlacement *p)
void SetFileNameFieldMapForCE(size_t kH, std::string s)
void SetDeltaEllipticityI(size_t kH, G4double val)
G4UIcmdWithABool * ConstructSimpAbsorber
double GetRadiusMilindWire() const
G4UIcmdWithABool * DisableSculptedLayers
std::vector< G4UIcmdWithADouble * > SetHornsCurrentEqualizerQuadAmpl
G4UIcmdWithABool * DisableMask
G4PVPlacement * PlaceFinal(const G4String &name, G4VPhysicalVolume *mother)
G4UIcmdWithADoubleAndUnit * DwStrAbsSteelWidth
std::vector< double > fDeltaEllipticityI
void SetHornCurrent(G4double ihorn)
bool GetUseSimpleTargetCylinder() const
void SetCurrentMultipiler(size_t kH, double v)
void PlaceFinalUpstrTarget(G4PVPlacement *mother)
double GetPlugInnerRadius() const
int GetNumberOfHornsPolycone() const
void PlaceFinalDecayPipeSnout(G4PVPlacement *mother)
double GetPlugOuterRadius() const
void ConstructLBNEHorn1TrackingPlane(G4VPhysicalVolume *tunnel)
void ConstructLBNEDecayPipeTrackingPlane(G4VPhysicalVolume *tunnel)
std::vector< std::string > fFileNameFieldMapForCE
QTextStream & endl(QTextStream &s)
void SetHorn1AllConductorMaterial(G4String &name)