4 #include <phparameter/PHParameters.h> 
   12 #include <Geant4/G4Box.hh> 
   13 #include <Geant4/G4Cons.hh> 
   14 #include <Geant4/G4ExtrudedSolid.hh> 
   15 #include <Geant4/G4LogicalBorderSurface.hh> 
   16 #include <Geant4/G4LogicalSkinSurface.hh> 
   17 #include <Geant4/G4LogicalVolume.hh> 
   18 #include <Geant4/G4Material.hh> 
   19 #include <Geant4/G4OpticalSurface.hh> 
   20 #include <Geant4/G4PVPlacement.hh> 
   21 #include <Geant4/G4PVReplica.hh> 
   22 #include <Geant4/G4RotationMatrix.hh>   
   23 #include <Geant4/G4SubtractionSolid.hh> 
   24 #include <Geant4/G4SystemOfUnits.hh> 
   25 #include <Geant4/G4ThreeVector.hh>   
   26 #include <Geant4/G4Torus.hh> 
   27 #include <Geant4/G4Transform3D.hh>   
   28 #include <Geant4/G4Trap.hh> 
   29 #include <Geant4/G4Tubs.hh> 
   30 #include <Geant4/G4TwoVector.hh> 
   31 #include <Geant4/G4Types.hh>             
   32 #include <Geant4/G4VPhysicalVolume.hh>   
   52   , m_Params(parameters)
 
   53   , m_ActiveFlag(m_Params->get_int_param(
"active"))
 
   54   , m_AbsorberActiveFlag(m_Params->get_int_param(
"absorberactive"))
 
   55   , m_TowerLogicNamePrefix(
"hHcalTower")
 
   56   , m_SuperDetector(
"NONE")
 
   57   , m_doLightProp(
false)
 
   61     cout << 
"ERROR in PHG4LFHcalDetector: No mapping file specified. Abort detector construction." << endl;
 
   62     cout << 
"Please run set_string_param(\"mapping_file\", std::string filename ) first." << endl;
 
   71   G4LogicalVolume* mylogvol = volume->GetLogicalVolume();
 
   95     std::cout << 
"PHG4LFHcalDetector: Begin Construction" << std::endl;
 
  105   G4VSolid* beampipe_cutout = 
new G4Cons(
"LFHCAL_beampipe_cutout",
 
  110   G4VSolid* hcal_envelope_solid = 
new G4Cons(
"LFHCAL_envelope_solid_cutout",
 
  117   G4LogicalVolume* hcal_envelope_log = 
new G4LogicalVolume(hcal_envelope_solid, WorldMaterial, 
"hLFHCAL_envelope", 0, 0, 0);
 
  122   G4RotationMatrix hcal_rotm;
 
  133                     hcal_envelope_log, name_envelope, logicWorld, 0, 
false, 
OverlapCheck());
 
  150     std::cout << 
"PHG4LFHcalDetector: Build logical volume for single tower..." << std::endl;
 
  161   G4double thin_frame_width = 0;
 
  162   if (thick_frame_width > 0)
 
  163     thin_frame_width = 0.1 * 
mm;
 
  167   G4int nlayers = TowerDz / (thickness_absorber + thickness_scintillator);
 
  173   G4double fiber_thickness = 0.2 * 
mm;
 
  180   G4VSolid* single_tower_solid = 
new G4Box(
"single_tower_solid",
 
  185   G4LogicalVolume* single_tower_logic = 
new G4LogicalVolume(single_tower_solid,
 
  187                                                             "single_tower_logic",
 
  190   G4double notch_length = 2.0 * 
cm;
 
  191   std::vector<G4TwoVector> poligon = {
 
  192       {(-TowerDx) / 2.0 + thin_frame_width, (-TowerDy) / 2.0 + thick_frame_width},
 
  193       {(-TowerDx) / 2.0 + thin_frame_width, (TowerDy) / 2.0 - thick_frame_width},
 
  194       {(TowerDx - WlsDw) / 2.0 - thin_frame_width, (TowerDy) / 2.0 - thick_frame_width},
 
  195       {(TowerDx - WlsDw) / 2.0 - thin_frame_width, (-TowerDy + notch_length) / 2.0 + thick_frame_width},
 
  196       {(TowerDx) / 2.0 - thin_frame_width, (-TowerDy + notch_length) / 2.0 + thick_frame_width},
 
  197       {(TowerDx) / 2.0 - thin_frame_width, (-TowerDy) / 2.0 + thick_frame_width}};
 
  201   std::vector<G4ExtrudedSolid::ZSection> zsections_miniblock = {{-(thickness_absorber + thickness_scintillator) / 2.0, {0, 0}, 1.0}, {(thickness_absorber + thickness_scintillator) / 2.0, {0, 0}, 1.}};
 
  202   G4VSolid* miniblock_solid = 
new G4ExtrudedSolid(
"miniblock_solid", poligon, zsections_miniblock);
 
  204   G4LogicalVolume* miniblock_logic = 
new G4LogicalVolume(miniblock_solid,
 
  208   G4LogicalVolume* miniblock_W_logic = 
new G4LogicalVolume(miniblock_solid,
 
  217   std::vector<G4ExtrudedSolid::ZSection> zsections_scintillator = {{-thickness_scintillator / 2, {0, 0}, 1.0}, {thickness_scintillator / 2, {0, 0}, 1.}};
 
  219   G4VSolid* solid_scintillator = 
new G4ExtrudedSolid(
"single_plate_scintillator", poligon, zsections_scintillator);
 
  221   G4VPhysicalVolume* physvol_fiber_loop_0 = 
nullptr;
 
  222   G4VPhysicalVolume* physvol_fiber_loop_1 = 
nullptr;
 
  223   G4VPhysicalVolume* physvol_fiber_straight_1 = 
nullptr;
 
  224   G4LogicalVolume* logic_embed_fiber_loop = 
nullptr;
 
  225   G4LogicalVolume* logic_embed_fiber_loop_2 = 
nullptr;
 
  226   G4LogicalVolume* logic_embed_fiber_straight_1 = 
nullptr;
 
  227   G4double cutout_margin = 0.1 * fiber_thickness;
 
  228   G4double fiber_bending_R_1 = notch_length / 2.0 - (TowerDy / 2 - thick_frame_width - (0.9 * (TowerDx - WlsDw - 2 * thin_frame_width) / 2.0) - (2 * cutout_margin));
 
  229   G4double fiber_bending_R = 1.0 * 
cm;
 
  232     G4VSolid* solid_embed_fiber_loop = 
new G4Torus(
"solid_embed_fiber_loop",
 
  233                                                    0, fiber_thickness / 2.0,
 
  234                                                    (0.9 * (TowerDx - WlsDw - 2 * thin_frame_width) / 2.0) - (fiber_thickness + 2 * cutout_margin) / 2.0,
 
  236     G4VSolid* solid_embed_fiber_loop_2 = 
new G4Torus(
"solid_embed_fiber_loop_2",
 
  237                                                      0, fiber_thickness / 2.0,
 
  238                                                      (2 * fiber_bending_R_1) / 2.0 - (fiber_thickness + 2 * cutout_margin) / 2.0,
 
  240     G4VSolid* solid_embed_fiber_straight_1 = 
new G4Tubs(
"solid_embed_fiber_straight_1",
 
  242                                                         fiber_thickness / 2.0,
 
  244                                                         ((TowerDx - WlsDw + fiber_thickness) / 2.0 - (fiber_bending_R_1)) / 2.0,
 
  246     solid_scintillator = 
new G4SubtractionSolid(G4String(
"single_plate_scintillator_cu"),
 
  247                                                 solid_scintillator, solid_embed_fiber_loop,
 
  248                                                 0, G4ThreeVector(0, 0, -thickness_scintillator / 2 + (fiber_thickness + cutout_margin) / 2.0));
 
  249     solid_scintillator = 
new G4SubtractionSolid(G4String(
"single_plate_scintillator_cu2"),
 
  250                                                 solid_scintillator, solid_embed_fiber_loop_2,
 
  251                                                 0, G4ThreeVector((TowerDx - WlsDw + fiber_thickness / 2.0) / 2.0 - (fiber_bending_R_1) + (thin_frame_width) + cutout_margin, -0.9 * (TowerDx - WlsDw - thin_frame_width) / 2.0 + (fiber_bending_R_1), -thickness_scintillator / 2 + (fiber_thickness + cutout_margin) / 2.0));
 
  252     G4RotationMatrix* wls_rotm_fibrcu = 
new G4RotationMatrix();
 
  253     wls_rotm_fibrcu->rotateY(90 * deg);
 
  254     solid_scintillator = 
new G4SubtractionSolid(G4String(
"single_plate_scintillator_cu3"),
 
  255                                                 solid_scintillator, solid_embed_fiber_straight_1,
 
  256                                                 wls_rotm_fibrcu, G4ThreeVector(((TowerDx - WlsDw + fiber_thickness) / 2.0 - (fiber_bending_R_1)) / 2.0,  
 
  257                                                                                -0.9 * (TowerDx - WlsDw - thin_frame_width) / 2.0 + (fiber_thickness + 2 * cutout_margin) / 2.0, -thickness_scintillator / 2 + (fiber_thickness + cutout_margin) / 2.0));
 
  258     logic_embed_fiber_loop = 
new G4LogicalVolume(solid_embed_fiber_loop,
 
  259                                                  material_wls, 
"logic_embed_fiber_loop",
 
  261     logic_embed_fiber_loop_2 = 
new G4LogicalVolume(solid_embed_fiber_loop_2,
 
  262                                                    material_wls, 
"logic_embed_fiber_loop_2",
 
  264     logic_embed_fiber_straight_1 = 
new G4LogicalVolume(solid_embed_fiber_straight_1,
 
  265                                                        material_wls, 
"logic_embed_fiber_straight_1",
 
  272     physvol_fiber_loop_0 = 
new G4PVPlacement(0, G4ThreeVector(0, 0, (thickness_absorber) / 2. - thickness_scintillator / 2 + (fiber_thickness + cutout_margin) / 2.0),
 
  273                                              logic_embed_fiber_loop,
 
  274                                              "embed_fiber_loop_placed",
 
  277     physvol_fiber_loop_1 = 
new G4PVPlacement(0, G4ThreeVector(
 
  279                                                     (TowerDx - WlsDw + fiber_thickness / 2.0) / 2.0 - (fiber_bending_R_1) + (thin_frame_width) + cutout_margin,
 
  281                                                     -0.9 * (TowerDx - WlsDw - thin_frame_width) / 2.0 + (fiber_bending_R_1), (thickness_absorber) / 2. - thickness_scintillator / 2 + (fiber_thickness + cutout_margin) / 2.0),
 
  282                                              logic_embed_fiber_loop_2,
 
  283                                              "embed_fiber_loop_2_placed",
 
  286     G4RotationMatrix* wls_rotm_fibr = 
new G4RotationMatrix();
 
  287     wls_rotm_fibr->rotateY(90 * deg);
 
  288     physvol_fiber_straight_1 = 
new G4PVPlacement(wls_rotm_fibr, G4ThreeVector(
 
  290                                                                     ((TowerDx - WlsDw + fiber_thickness) / 2.0 - (fiber_bending_R_1)) / 2.0,
 
  292                                                                     -0.9 * (TowerDx - WlsDw - thin_frame_width) / 2.0 + (fiber_thickness + 2 * cutout_margin) / 2.0, (thickness_absorber) / 2. - thickness_scintillator / 2 + (fiber_thickness + cutout_margin) / 2.0),
 
  293                                                  logic_embed_fiber_straight_1,
 
  294                                                  "embed_fiber_straight_1_placed",
 
  299       MakeBoundary(physvol_fiber_loop_0, physvol_fiber_loop_1, 
true);
 
  300       MakeBoundary(physvol_fiber_loop_1, physvol_fiber_straight_1, 
true);
 
  311   std::vector<G4ExtrudedSolid::ZSection> zsections_absorber = {{-thickness_absorber / 2, {0, 0}, 1.0}, {thickness_absorber / 2, {0, 0}, 1.}};
 
  312   G4VSolid* solid_absorber = 
new G4ExtrudedSolid(
"single_plate_absorber_solid", poligon, zsections_absorber);
 
  313   G4LogicalVolume* logic_absorber = 
new G4LogicalVolume(solid_absorber,
 
  315                                                         "single_plate_absorber_logic",
 
  318   G4LogicalVolume* logic_absorber_W = 
new G4LogicalVolume(solid_absorber,
 
  320                                                           "single_plate_absorber_W_logic",
 
  323   G4LogicalVolume* logic_scint = 
new G4LogicalVolume(solid_scintillator,
 
  324                                                      material_scintillator,
 
  325                                                      "hLFHCAL_scintillator_plate_logic",
 
  338   new G4PVPlacement(0, G4ThreeVector(0, 0, -thickness_scintillator / 2),
 
  344   G4VPhysicalVolume* scintillator_placed = 
new G4PVPlacement(0, G4ThreeVector(0, 0, (thickness_absorber) / 2.),
 
  356   new G4PVPlacement(0, G4ThreeVector(0, 0, -thickness_scintillator / 2),
 
  362   new G4PVPlacement(0, G4ThreeVector(0, 0, (thickness_absorber) / 2.),
 
  369     G4VPhysicalVolume* physvol_fiber_loop_W_0 = 
new G4PVPlacement(0, G4ThreeVector(0, 0, (thickness_absorber) / 2. - thickness_scintillator / 2 + (fiber_thickness + cutout_margin) / 2.0),
 
  370                                                                   logic_embed_fiber_loop,
 
  371                                                                   "embed_fiber_loop_W_placed",
 
  374     G4VPhysicalVolume* physvol_fiber_loop_W_1 = 
new G4PVPlacement(0, G4ThreeVector((TowerDx - WlsDw + fiber_thickness / 2.0) / 2.0 - (fiber_bending_R_1) + (thin_frame_width) + cutout_margin,
 
  376                                                                                    -0.9 * (TowerDx - WlsDw - thin_frame_width) / 2.0 + (fiber_bending_R_1), (thickness_absorber) / 2. - thickness_scintillator / 2 + (fiber_thickness + cutout_margin) / 2.0),
 
  377                                                                   logic_embed_fiber_loop_2,
 
  378                                                                   "embed_fiber_loop_W_2_placed",
 
  381     G4RotationMatrix* wls_rotm_fibr = 
new G4RotationMatrix();
 
  382     wls_rotm_fibr->rotateY(90 * deg);
 
  383     G4VPhysicalVolume* physvol_fiber_loop_W_2 = 
new G4PVPlacement(wls_rotm_fibr, G4ThreeVector(((TowerDx - WlsDw + fiber_thickness) / 2.0 - (fiber_bending_R_1)) / 2.0,
 
  385                                                                                                -0.9 * (TowerDx - WlsDw - thin_frame_width) / 2.0 + (fiber_thickness + 2 * cutout_margin) / 2.0, (thickness_absorber) / 2. - thickness_scintillator / 2 + (fiber_thickness + cutout_margin) / 2.0),
 
  386                                                                   logic_embed_fiber_straight_1,
 
  387                                                                   "embed_fiber_straight_W_1_placed",
 
  392       MakeBoundary(physvol_fiber_loop_W_0, physvol_fiber_loop_W_1, 
true);
 
  393       MakeBoundary(physvol_fiber_loop_W_1, physvol_fiber_loop_W_2, 
true);
 
  399   if (thin_frame_width > 0)
 
  403     G4VSolid* solid_frame_plate = 
new G4Box(
"single_plate_frame",
 
  404                                             (thin_frame_width) / 2, (TowerDy - 2 * thick_frame_width) / 2, TowerDz / 2);
 
  405     G4LogicalVolume* logic_frame = 
new G4LogicalVolume(solid_frame_plate,
 
  407                                                        "hLFHCAL_frame_plate_logic",
 
  411     new G4PVPlacement(0, G4ThreeVector(-TowerDx / 2 + thin_frame_width / 2, 0, 0.),
 
  416     new G4PVPlacement(0, G4ThreeVector(TowerDx / 2 - thin_frame_width / 2, 0, 0.),
 
  422     G4VSolid* solid_cover_plate = 
new G4Box(
"single_plate_cover",
 
  423                                             TowerDx / 2, thick_frame_width / 2, TowerDz / 2);
 
  424     G4LogicalVolume* logic_cover = 
new G4LogicalVolume(solid_cover_plate,
 
  426                                                        "hLFHCAL_cover_plate_logic",
 
  430     new G4PVPlacement(0, G4ThreeVector(0, -TowerDy / 2 + thick_frame_width / 2, 0.),
 
  435     new G4PVPlacement(0, G4ThreeVector(0, TowerDy / 2 - thick_frame_width / 2, 0.),
 
  445   double SteelTowerLength = TowerDz;
 
  446   double WTowerLength = 0.;
 
  447   int nLayersSteel = nlayers;
 
  448   int nLayersTungsten = 0;
 
  451     SteelTowerLength -= 10 * (thickness_absorber + thickness_scintillator);
 
  453     nLayersTungsten = 10;
 
  454     WTowerLength = 10 * (thickness_absorber + thickness_scintillator);
 
  455     std::cout << 
"using 10 layer tungsten tailcatcher in LFHCAL" << std::endl;
 
  458   std::vector<G4ExtrudedSolid::ZSection> zsections_steeltower = {{-(SteelTowerLength) / 2.0, {0, 0}, 1.0}, {(SteelTowerLength) / 2.0, {0, 0}, 1.}};
 
  459   G4VSolid* single_tower_solidRep = 
new G4ExtrudedSolid(
"single_tower_solidRep", poligon, zsections_steeltower);
 
  461   G4LogicalVolume* single_tower_logicRep = 
new G4LogicalVolume(single_tower_solidRep,
 
  463                                                                "single_tower_logicRep",
 
  466   new G4PVReplica(name_tower, miniblock_logic, single_tower_logicRep,
 
  467                   kZAxis, nLayersSteel, thickness_absorber + thickness_scintillator, 0);
 
  469   new G4PVPlacement(0, G4ThreeVector(0, 0, -WTowerLength / 2),
 
  470                     single_tower_logicRep,
 
  480     std::vector<G4ExtrudedSolid::ZSection> zsections_wtower = {{-(WTowerLength) / 2.0, {0, 0}, 1.0}, {(WTowerLength) / 2.0, {0, 0}, 1.}};
 
  481     G4VSolid* single_tower_W_solidRep = 
new G4ExtrudedSolid(
"single_tower_W_solidRep", poligon, zsections_wtower);
 
  483     G4LogicalVolume* single_tower_W_logicRep = 
new G4LogicalVolume(single_tower_W_solidRep,
 
  485                                                                    "single_tower_W_logicRep",
 
  488     new G4PVReplica(name_tower_W, miniblock_W_logic, single_tower_W_logicRep,
 
  489                     kZAxis, nLayersTungsten, thickness_absorber + thickness_scintillator, 0);
 
  491     new G4PVPlacement(0, G4ThreeVector(0, 0, SteelTowerLength / 2),
 
  492                       single_tower_W_logicRep,
 
  501     G4double spacer_width = 1.5 * 
mm;
 
  502     G4double add_spacing = spacer_width + 0.1 * 
mm;
 
  503     G4double extraspacing = add_spacing;
 
  504     for (
int ilay = 0; ilay < nlayers; ilay++)
 
  506       if ((SteelTowerLength + WTowerLength - ilay * (thickness_absorber + thickness_scintillator) - thickness_absorber - thickness_scintillator / 2 - fiber_bending_R / 2) / 2.0 > 0)
 
  508         G4VSolid* solid_long_fiber_tmp = 
new G4Tubs(
"solid_long_fiber_tmp_" + 
std::to_string(ilay),
 
  510                                                     fiber_thickness / 2.0,
 
  511                                                     (SteelTowerLength + WTowerLength - ilay * (thickness_absorber + thickness_scintillator) - thickness_absorber - fiber_thickness / 2 - fiber_bending_R / 2) / 2.0,
 
  514         G4LogicalVolume* logic_long_fiber_tmp = 
new G4LogicalVolume(solid_long_fiber_tmp,
 
  518         new G4PVPlacement(0, G4ThreeVector((TowerDx - WlsDw + fiber_thickness / 2.0) / 2.0, TowerDy / 2 - thick_frame_width - fiber_thickness - ilay * (1.01 * fiber_thickness) - extraspacing, (ilay * (thickness_absorber + thickness_scintillator) + thickness_absorber + fiber_thickness / 2 + fiber_bending_R / 2) / 2.0),
 
  519                           logic_long_fiber_tmp,
 
  527       G4double shortup_fiber_length = TowerDy / 2 - thick_frame_width - fiber_thickness - ilay * (1.01 * fiber_thickness) - extraspacing - fiber_bending_R / 2 + TowerDy / 2 - thick_frame_width - notch_length / 2;
 
  528       G4VSolid* solid_shortup_fiber_tmp = 
new G4Tubs(
"solid_shortup_fiber_tmp_" + 
std::to_string(ilay),
 
  530                                                      fiber_thickness / 2.0,
 
  531                                                      shortup_fiber_length / 2.0,
 
  533       G4LogicalVolume* logic_shortup_fiber_tmp = 
new G4LogicalVolume(solid_shortup_fiber_tmp,
 
  538       G4RotationMatrix* wls_rotm_fibr3 = 
new G4RotationMatrix();
 
  539       wls_rotm_fibr3->rotateX(90 * deg);
 
  540       new G4PVPlacement(wls_rotm_fibr3, G4ThreeVector((TowerDx - WlsDw + fiber_thickness / 2.0) / 2.0, TowerDy / 2 - thick_frame_width - fiber_thickness - ilay * (1.01 * fiber_thickness) - extraspacing - fiber_bending_R / 2 - (shortup_fiber_length / 2.0), -TowerDz / 2 + ilay * (thickness_absorber + thickness_scintillator) + thickness_absorber + fiber_thickness / 2),
 
  541                         logic_shortup_fiber_tmp,
 
  548       G4VSolid* solid_fiber_curved = 
new G4Torus(
"solid_fiber_curved",
 
  549                                                  0, fiber_thickness / 2.0,
 
  550                                                  (fiber_bending_R) / 2.0,
 
  552       if (ilay == nlayers - 1)
 
  554         solid_fiber_curved = 
new G4Torus(
"solid_fiber_curved_lastlayer",
 
  555                                          0, fiber_thickness / 2.0,
 
  556                                          (fiber_bending_R) / 2.0,
 
  559       G4LogicalVolume* logic_fiber_curved = 
new G4LogicalVolume(solid_fiber_curved,
 
  564       G4RotationMatrix* wls_rotm_fibr2 = 
new G4RotationMatrix();
 
  565       wls_rotm_fibr2->rotateY(90 * deg);
 
  566       new G4PVPlacement(wls_rotm_fibr2, G4ThreeVector((TowerDx - WlsDw + fiber_thickness / 2.0) / 2.0, TowerDy / 2 - thick_frame_width - fiber_thickness - ilay * (1.01 * fiber_thickness) - extraspacing - fiber_bending_R / 2, -TowerDz / 2 + ilay * (thickness_absorber + thickness_scintillator) + thickness_absorber + fiber_thickness / 2 + fiber_bending_R / 2),
 
  572       if ((ilay + 1) % 10 == 0)
 
  574         if (((SteelTowerLength + WTowerLength - ilay * (thickness_absorber + thickness_scintillator) - thickness_absorber - thickness_scintillator / 2 - thickness_absorber / 2) / 2.0) > 0)
 
  576           G4VSolid* solid_spacer_tmp = 
new G4Box(
"solid_spacer_tmp_" + 
std::to_string(ilay),
 
  579                                                  (SteelTowerLength + WTowerLength - ilay * (thickness_absorber + thickness_scintillator) - thickness_absorber - thickness_scintillator / 2 - thickness_absorber / 2) / 2.0);
 
  581           G4LogicalVolume* logic_spacer_tmp = 
new G4LogicalVolume(solid_spacer_tmp,
 
  585           new G4PVPlacement(0, G4ThreeVector((TowerDx - WlsDw / 2) / 2.0 - thin_frame_width, TowerDy / 2 - thick_frame_width - fiber_thickness - (ilay + 0.5) * (1.01 * fiber_thickness) - extraspacing - add_spacing / 2, (ilay * (thickness_absorber + thickness_scintillator) + thickness_absorber + thickness_scintillator / 2 + thickness_absorber / 2) / 2.0),
 
  592         extraspacing += add_spacing;
 
  598     std::cout << 
"PHG4LFHcalDetector: Building logical volume for single tower done." << std::endl;
 
  601   return single_tower_logic;
 
  611       std::cout << 
"PHG4LFHcalDetector: Place tower " << iterator->first
 
  612                 << 
" idx_j = " << iterator->second.idx_j << 
", idx_k = " << iterator->second.idx_k
 
  613                 << 
" at x = " << iterator->second.x << 
" , y = " << iterator->second.y << 
" , z = " << iterator->second.z << std::endl;
 
  616     int copyno = (iterator->second.idx_j << 16) + iterator->second.idx_k;
 
  618     new G4PVPlacement(0, G4ThreeVector(iterator->second.x, iterator->second.y, iterator->second.z),
 
  633   G4Material* material_ScintFEMC = 
new G4Material(
"PolystyreneFEMC", density = 1.03 * 
g / 
cm3, ncomponents = 2);
 
  651     const G4int nEntries = 50;
 
  652     G4double photonEnergy[nEntries] =
 
  653         {2.00 * 
eV, 2.03 * 
eV, 2.06 * 
eV, 2.09 * 
eV, 2.12 * 
eV,
 
  654          2.15 * 
eV, 2.18 * 
eV, 2.21 * 
eV, 2.24 * 
eV, 2.27 * 
eV,
 
  655          2.30 * 
eV, 2.33 * 
eV, 2.36 * 
eV, 2.39 * 
eV, 2.42 * 
eV,
 
  656          2.45 * 
eV, 2.48 * 
eV, 2.51 * 
eV, 2.54 * 
eV, 2.57 * 
eV,
 
  657          2.60 * 
eV, 2.63 * 
eV, 2.66 * 
eV, 2.69 * 
eV, 2.72 * 
eV,
 
  658          2.75 * 
eV, 2.78 * 
eV, 2.81 * 
eV, 2.84 * 
eV, 2.87 * 
eV,
 
  659          2.90 * 
eV, 2.93 * 
eV, 2.96 * 
eV, 2.99 * 
eV, 3.02 * 
eV,
 
  660          3.05 * 
eV, 3.08 * 
eV, 3.11 * 
eV, 3.14 * 
eV, 3.17 * 
eV,
 
  661          3.20 * 
eV, 3.23 * 
eV, 3.26 * 
eV, 3.29 * 
eV, 3.32 * 
eV,
 
  662          3.35 * 
eV, 3.38 * 
eV, 3.41 * 
eV, 3.44 * 
eV, 3.47 * 
eV};
 
  663     G4double scintilFast[nEntries] =
 
  664         {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
 
  665          0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
 
  666          0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
 
  667          1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
 
  668          1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
 
  670     const G4int ntab = 4;
 
  672     G4double wls_Energy[] = {2.00 * 
eV, 2.87 * 
eV, 2.90 * 
eV,
 
  675     G4double rIndexPstyrene[] = {1.5, 1.5, 1.5, 1.5};
 
  676     G4double absorption1[] = {2. * 
cm, 2. * 
cm, 2. * 
cm, 2. * 
cm};
 
  678     G4MaterialPropertiesTable* fMPTPStyrene = 
new G4MaterialPropertiesTable();
 
  679     fMPTPStyrene->AddProperty(
"RINDEX", wls_Energy, rIndexPstyrene, ntab);
 
  680     fMPTPStyrene->AddProperty(
"ABSLENGTH", wls_Energy, absorption1, ntab);
 
  683     fMPTPStyrene->AddProperty(
"SCINTILLATIONCOMPONENT1", photonEnergy, scintilFast, nEntries);
 
  684     fMPTPStyrene->AddConstProperty(
"SCINTILLATIONYIELD", 10. / 
keV);
 
  685     fMPTPStyrene->AddConstProperty(
"RESOLUTIONSCALE", 1.0);
 
  686     fMPTPStyrene->AddConstProperty(
"SCINTILLATIONTIMECONSTANT", 10. * 
ns);
 
  690     material_ScintFEMC->SetMaterialPropertiesTable(fMPTPStyrene);
 
  693   material_ScintFEMC->GetIonisation()->SetBirksConstant(0.126 * 
mm / 
MeV);
 
  695   return material_ScintFEMC;
 
  704   G4double density, fractionmass;
 
  706   G4Material* material_TiO2 = 
new G4Material(
"TiO2_FEMC", density = 1.52 * 
g / 
cm3, ncomponents = 2);
 
  714   density = 1.86 * 
g / 
cm3;
 
  715   G4Material* Coating_FEMC = 
new G4Material(
"Coating_FEMC", density, ncomponents = 2);
 
  717   Coating_FEMC->AddMaterial(material_TiO2, fractionmass = 0.20);
 
  725   G4OpticalSurface* 
surface = 
new G4OpticalSurface(
"ScintWrapB1");
 
  727   new G4LogicalSkinSurface(
"CrystalSurfaceL", vol, surface);
 
  729   surface->SetType(dielectric_metal);
 
  730   surface->SetFinish(polished);
 
  731   surface->SetModel(glisur);
 
  736   const G4int ntab = 2;
 
  737   G4double opt_en[] = {1.551 * 
eV, 3.545 * 
eV};  
 
  738   G4double reflectivity[] = {0.9, 0.9};
 
  739   G4double efficiency[] = {0.99, 0.99};
 
  740   G4MaterialPropertiesTable* surfmat = 
new G4MaterialPropertiesTable();
 
  741   surfmat->AddProperty(
"REFLECTIVITY", opt_en, reflectivity, ntab);
 
  742   surfmat->AddProperty(
"EFFICIENCY", opt_en, efficiency, ntab);
 
  743   surface->SetMaterialPropertiesTable(surfmat);
 
  752     std::cout << 
"PHG4ForwardEcalDetector: Making WLSFiberFEMC PMMA material..." << std::endl;
 
  758   G4Material* material_WLSFiberFEMC = 
new G4Material(
"WLSFiberFEMC", density = 1.18 * 
g / 
cm3, ncomponents = 3);
 
  764     const G4int nEntries = 50;
 
  765     G4double photonEnergy[nEntries] =
 
  766         {2.00 * 
eV, 2.03 * 
eV, 2.06 * 
eV, 2.09 * 
eV, 2.12 * 
eV,
 
  767          2.15 * 
eV, 2.18 * 
eV, 2.21 * 
eV, 2.24 * 
eV, 2.27 * 
eV,
 
  768          2.30 * 
eV, 2.33 * 
eV, 2.36 * 
eV, 2.39 * 
eV, 2.42 * 
eV,
 
  769          2.45 * 
eV, 2.48 * 
eV, 2.51 * 
eV, 2.54 * 
eV, 2.57 * 
eV,
 
  770          2.60 * 
eV, 2.63 * 
eV, 2.66 * 
eV, 2.69 * 
eV, 2.72 * 
eV,
 
  771          2.75 * 
eV, 2.78 * 
eV, 2.81 * 
eV, 2.84 * 
eV, 2.87 * 
eV,
 
  772          2.90 * 
eV, 2.93 * 
eV, 2.96 * 
eV, 2.99 * 
eV, 3.02 * 
eV,
 
  773          3.05 * 
eV, 3.08 * 
eV, 3.11 * 
eV, 3.14 * 
eV, 3.17 * 
eV,
 
  774          3.20 * 
eV, 3.23 * 
eV, 3.26 * 
eV, 3.29 * 
eV, 3.32 * 
eV,
 
  775          3.35 * 
eV, 3.38 * 
eV, 3.41 * 
eV, 3.44 * 
eV, 3.47 * 
eV};
 
  776     G4double refractiveIndexWLSfiber[nEntries] =
 
  777         {1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60,
 
  778          1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60,
 
  779          1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60,
 
  780          1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60,
 
  781          1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60, 1.60};
 
  783     G4double absWLSfiber[nEntries] =
 
  784         {5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m,
 
  785          5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m,
 
  786          5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 5.40 * 
m, 1.10 * 
m,
 
  787          1.10 * 
m, 1.10 * 
m, 1.10 * 
m, 1.10 * 
m, 1.10 * 
m, 1.10 * 
m, 1. * 
mm, 1. * 
mm, 1. * 
mm, 1. * 
mm,
 
  790     G4double emissionFib[nEntries] =
 
  791         {0.05, 0.10, 0.30, 0.50, 0.75, 1.00, 1.50, 1.85, 2.30, 2.75,
 
  792          3.25, 3.80, 4.50, 5.20, 6.00, 7.00, 8.50, 9.50, 11.1, 12.4,
 
  793          12.9, 13.0, 12.8, 12.3, 11.1, 11.0, 12.0, 11.0, 17.0, 16.9,
 
  794          15.0, 9.00, 2.50, 1.00, 0.05, 0.00, 0.00, 0.00, 0.00, 0.00,
 
  795          0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00};
 
  797     G4MaterialPropertiesTable* mptWLSfiber = 
new G4MaterialPropertiesTable();
 
  798     mptWLSfiber->AddProperty(
"RINDEX", photonEnergy, refractiveIndexWLSfiber, nEntries);
 
  799     mptWLSfiber->AddProperty(
"WLSABSLENGTH", photonEnergy, absWLSfiber, nEntries);
 
  800     mptWLSfiber->AddProperty(
"WLSCOMPONENT", photonEnergy, emissionFib, nEntries);
 
  801     mptWLSfiber->AddConstProperty(
"WLSTIMECONSTANT", 0.5 * 
ns);
 
  802     material_WLSFiberFEMC->SetMaterialPropertiesTable(mptWLSfiber);
 
  806     std::cout << 
"PHG4ForwardEcalDetector:  Making WLSFiberFEMC material done." << std::endl;
 
  809   return material_WLSFiberFEMC;
 
  817   G4OpticalSurface* surf = 
new G4OpticalSurface(
"OpDetS");
 
  818   surf->SetType(dielectric_dielectric);  
 
  821   surf->SetFinish(polished);
 
  823   surf->SetModel(glisur);
 
  825   new G4LogicalBorderSurface(
"OpDetB", crystal, opdet, surf);
 
  827   const G4int ntab = 2;
 
  828   G4double opt_en[] = {1.551 * 
eV, 3.545 * 
eV};  
 
  830   G4double reflectivityFiber[] = {0.0, 0.0};
 
  833   G4double efficiency[] = {1., 1.};
 
  834   G4double RefractiveIndexBoundary[] = {1.0, 1.0};
 
  836   G4MaterialPropertiesTable* surfmat = 
new G4MaterialPropertiesTable();
 
  837   surfmat->AddProperty(
"EFFICIENCY", opt_en, efficiency, ntab);
 
  838   surfmat->AddProperty(
"RINDEX", opt_en, RefractiveIndexBoundary, ntab);
 
  839   surfmat->AddProperty(
"REFLECTIVITY", opt_en, reflectivityFiber, ntab);
 
  840   surf->SetMaterialPropertiesTable(surfmat);
 
  849   G4OpticalSurface* ScintToFiberS = 
new G4OpticalSurface(
"ScintToFiberS");
 
  850   ScintToFiberS->SetType(dielectric_dielectric);  
 
  853   ScintToFiberS->SetFinish(groundair);
 
  856   ScintToFiberS->SetModel(glisur);
 
  858   new G4LogicalBorderSurface(
"ScintToFiberB", scinti, fiber, ScintToFiberS);
 
  860   const G4int ntab = 2;
 
  861   G4double opt_en[] = {1.551 * 
eV, 3.545 * 
eV};  
 
  863   G4double reflectivity[] = {0.01, 0.01};
 
  866   G4double efficiency[] = {1., 1.};
 
  867   G4double RefractiveIndexBoundary[] = {1.4, 1.4};
 
  869   G4MaterialPropertiesTable* ScintToFiberSmat = 
new G4MaterialPropertiesTable();
 
  870   ScintToFiberSmat->AddProperty(
"EFFICIENCY", opt_en, efficiency, ntab);
 
  871   ScintToFiberSmat->AddProperty(
"RINDEX", opt_en, RefractiveIndexBoundary, ntab);
 
  872   ScintToFiberSmat->AddProperty(
"REFLECTIVITY", opt_en, reflectivity, ntab);
 
  873   ScintToFiberS->SetMaterialPropertiesTable(ScintToFiberSmat);
 
  877   G4OpticalSurface* FiberToScintSurface = 
new G4OpticalSurface(
"ScintToFiberS");
 
  879   FiberToScintSurface->SetType(dielectric_metal);  
 
  882   FiberToScintSurface->SetFinish(polished);
 
  884   FiberToScintSurface->SetModel(glisur);
 
  886   new G4LogicalBorderSurface(
"ScintToFiberB", scinti, fiber, FiberToScintSurface);
 
  888   const G4int ntab2 = 2;
 
  889   G4double opt_en2[] = {1.551 * 
eV, 3.545 * 
eV};  
 
  893   G4double reflectivity2[] = {1., 1.};
 
  894   G4double efficiency2[] = {1., 1.};
 
  895   G4double RefractiveIndexBoundary2[] = {1.6, 1.6};
 
  897   G4MaterialPropertiesTable* FiberToScintSurfacemat = 
new G4MaterialPropertiesTable();
 
  898   FiberToScintSurfacemat->AddProperty(
"EFFICIENCY", opt_en2, efficiency2, ntab2);
 
  899   FiberToScintSurfacemat->AddProperty(
"RINDEX", opt_en2, RefractiveIndexBoundary2, ntab2);
 
  900   FiberToScintSurfacemat->AddProperty(
"REFLECTIVITY", opt_en2, reflectivity2, ntab2);
 
  901   FiberToScintSurface->SetMaterialPropertiesTable(FiberToScintSurfacemat);
 
  908   ifstream istream_mapping;
 
  910   if (!istream_mapping.is_open())
 
  912     std::cout << 
"ERROR in PHG4LFHcalDetector: Failed to open mapping file " << 
m_Params->
get_string_param(
"mapping_file") << std::endl;
 
  918   while (
getline(istream_mapping, line_mapping))
 
  921     if (line_mapping.find(
"#") != string::npos)
 
  925         std::cout << 
"PHG4LFHcalDetector: SKIPPING line in mapping file: " << line_mapping << std::endl;
 
  930     istringstream iss(line_mapping);
 
  933     if (line_mapping.find(
"Tower ") != string::npos)
 
  935       unsigned idx_j, idx_k, idx_l;
 
  936       G4double pos_x, pos_y, pos_z;
 
  937       G4double size_x, size_y, 
size_z;
 
  938       G4double rot_x, rot_y, rot_z;
 
  943       if (!(iss >> dummys >> dummy >> idx_j >> idx_k >> idx_l >> pos_x >> pos_y >> pos_z >> size_x >> size_y >> size_z >> rot_x >> rot_y >> rot_z))
 
  945         cout << 
"ERROR in PHG4LFHcalDetector: Failed to read line in mapping file " << 
m_Params->
get_string_param(
"mapping_file") << std::endl;
 
  951       ostringstream towername;
 
  965       tower_new.
idx_j = idx_j;
 
  966       tower_new.
idx_k = idx_k;
 
  976       if (!(iss >> parname >> parval))
 
  978         cout << 
"ERROR in PHG4LFHcalDetector: Failed to read line in mapping file " << 
m_Params->
get_string_param(
"mapping_file") << std::endl;
 
  987   std::map<string, G4double>::iterator parit;