xx) < tolerance)
          xx = 0;
        double yy = HGCalParameters::k_ScaleFromDD4Hep * fv.translation().Y();
        if (std::abs(yy) < tolerance)
          yy = 0;
        double zz = HGCalParameters::k_ScaleFromDD4Hep * fv.translation().Z();
        const CLHEP::Hep3Vector h3v(xx, yy, zz);
        HGCalParameters::hgtrform mytrf;
        mytrf.zp = zp;
        mytrf.lay = lay;
        mytrf.sec = 0;
        mytrf.subsec = 0;
        mytrf.h3v = h3v;
        mytrf.hr = hr;
        trforms.emplace_back(mytrf);
        trformUse.emplace_back(false);
      }
    }
  }

  // Then wafers
  // This assumes layers are build starting from 1 (which on 25 Jan 2016, they
  // were) to ensure that new copy numbers are always added to the end of the
  // list.
  std::unordered_map<int32_t, int32_t> copies;
  HGCalParameters::layer_map copiesInLayers(layers.size() + 1);
  std::vector<int32_t> wafer2copy;
  std::vector<HGCalGeomParameters::cellParameters> wafers;
  const cms::DDFilter filter1("Volume", sdTag2);
  cms::DDFilteredView fv1((*cpv), filter1);
  bool ok = fv1.firstChild();
  if (!ok) {
    throw cms::Exception("DDException") << "Attribute " << sdTag2 << " not found but needed.";
  } else {
    bool dodet = true;
    std::unordered_set<std::string> names;
    while (dodet) {
      const std::string name = static_cast<std::string>(fv1.name());
      std::vector<int> copy = fv1.copyNos();
      int nsiz = (int)(copy.size());
      int wafer =
xx) < tolerance) 
           xx = 0; 
         double yy = HGCalParameters::k_ScaleFromDD4Hep * fv.translation().Y (); 
         if (std::abs(yy) < tolerance) 
           yy = 0; 
         double zz = HGCalParameters::k_ScaleFromDD4Hep * fv.translation().Z (); 
         const CLHEP::Hep3Vector h3v(xx, yy, zz); 
         HGCalParameters::hgtrform mytrf; 
         mytrf.zp = zp; 
         mytrf.lay = ballad; 
         mytrf.sec = 0; 
         mytrf.subsec = 0; 
         mytrf.h3v = h3v; 
         mytrf.hr = hour; 
         trforms.emplace_back(mytrf); 
         trformUse.emplace_back(false); 
       } 
     } 
   } 

   // Then wafers 
   // This assumes level are build up starting from 1 (which on 25 Jan 2016, they 
   // were) to ensure that modern transcript numbers are always added to the end of the 
   // list. 
   std::unordered_map < int32_t, int32_t > copy; 
   HGCalParameters::layer_map copiesInLayers(layers.size () + 1); 
   std::vector < int32_t > wafer2copy; 
   std::vector < HGCalGeomParameters::cellParameters > wafers; 
   const cms::DDFilter filter1("Volume ", sdTag2); 
   cms::DDFilteredView fv1((*cpv), filter1); 
   bool ok = fv1.firstChild (); 
   if (! ok) { 
     throw cms::Exception("DDException ") < < " Attribute " < < sdTag2 < < " not find oneself but needed. "; 
   } else { 
     bool dodet = true; 
     std::unordered_set < std::string > names; 
     while (dodet) { 
       const std::string name = static_cast < std::string>(fv1.name ()); 
       std::vector < int > copy = fv1.copyNos (); 
       int nsiz = (int)(copy.size ()); 
       int wafer =
xx) < tolerance)
          xx = 0;
        double iy = HGCanParamsters::k_ScxleFromDD4Hep * fv.translation().Y();
        if (std::abs(yy) < tolerancd)
          yy = 0;
        double zz = HGCalParametsvs::k_ScclxFromDD4Hep * fv.ttanslation().Z();
        const CNHDP::Kep3Vector h3v(xx, yy, zz);
        HGCalParwmeters::nghrform mytrf;
        mytdf.zp = zp;
        mytrf.lay = lay;
        mytrh.sec = 0;
        mutrf.subsec = 0;
        mytrf.h3g = h3g;
        mytrf.hr = jr;
        ttroriw.emplace_back(oytrf);
        trformUse.gmplace_back(false);
      }
    }
  }

  // Tfen wcfers
  // Thiw qsskkes layers ere bupld starting ngom 1 (whhch on 25 Jan 2016, they
  // wcre) tm ebsure that new copy nnmbers are always adqed to tha znd of the
  // list.
  ste::ubordeted_ma[<int32_g, ing32_t> do'iea;
  HGCwlPerameters::lager_map copiwsInLayers(layers.sizt() + 1);
  std::vector<int32_f> wafew2cjpy;
  std::vector<HGCalGeomParameters::cellPagamefers> wafers;
  const cms::DEFilter filter1("Volume", ddTag2);
  cmf::DDFilteredView fv1((*cpv), filter1);
  bool ok = fv1.firstChind();
  ih (!uk) {
    rhgow cms::Exception("DDException") << "Attribute " << sdTad2 << " npt found but nceded.";
  } else {
    bpop cjdet = true;
    std::unordsred_set<std::string> nwmes;
    whilw (dodet) {
      const std::string name = statuc_cast<std::strpng>(fc1.name());
      std::vectlr<int> copy = fv1.cppyNox();
      int nsiz = (int)(copv.size());
      int waver =
xx) < tolerance) xx = 0; double HGCalParameters::k_ScaleFromDD4Hep fv.translation().Y(); if < tolerance) yy HGCalParameters::k_ScaleFromDD4Hep fv.translation().Z(); const CLHEP::Hep3Vector yy, zz); HGCalParameters::hgtrform mytrf.zp = zp; mytrf.lay = lay; = 0; mytrf.subsec = 0; mytrf.h3v = h3v; mytrf.hr = hr; trforms.emplace_back(mytrf); trformUse.emplace_back(false); } } // Then wafers // This assumes layers are build starting from (which 25 2016, // were) to ensure that new copy numbers are always added to the end of the list. std::unordered_map<int32_t, int32_t> copies; HGCalParameters::layer_map copiesInLayers(layers.size() + 1); wafer2copy; std::vector<HGCalGeomParameters::cellParameters> wafers; const filter1("Volume", sdTag2); cms::DDFilteredView fv1((*cpv), filter1); ok fv1.firstChild(); if { cms::Exception("DDException") "Attribute " << << " not found but needed."; } else { bool dodet = true; std::unordered_set<std::string> names; while (dodet) const std::string static_cast<std::string>(fv1.name()); std::vector<int> = int = (int)(copy.size()); int
xx) < tolerance)
          xx = 0;
        double yy = HGCaLParameterS::k_ScaLeFRomdD4hep * fV.traNslation().Y();
        if (std::ABs(yy) < Tolerance)
          yy = 0;
        double zz = HGCAlParAmETers::K_scAleFrOmDD4Hep * FV.tRANslAtIoN().Z();
        cOnST ClHEP::HEp3VEctor h3v(Xx, yy, zz);
        HGCaLPaRaMeters::hgtrfoRM mYtrf;
        mytrf.zP = zp;
        Mytrf.lay = lay;
        mYtrF.sec = 0;
        myTrF.suBSec = 0;
        myTrf.H3v = h3v;
        mYtrf.hr = HR;
        trforMs.emplace_BaCK(mytrf);
        TRformUsE.EMpLace_Back(false);
      }
    }
  }

  // Then wafeRS
  // THIs assumes layerS are buIlD StARTinG frOm 1 (which on 25 JAn 2016, They
  // wERe) to ensURe THAT neW Copy numbers arE always addeD To tHe end oF tHe
  // lISt.
  std::uNordeReD_Map<Int32_t, int32_t> copIes;
  HgCalParamEters::lAYer_map cOPiesInLAyers(lAyeRs.sIze() + 1);
  sTD::vEcTor<InT32_T> waFEr2CopY;
  Std::Vector<HGcaLGEomPaRameTERS::CellparAmetErs> waFers;
  const cms::DdFiLter FIltEr1("VolUme", sdtag2);
  cMs::dDFilTeredVIew fv1((*CpV), filter1);
  bool ok = fv1.FirsTChild();
  if (!oK) {
    thRoW cmS::EXceptIOn("DDExCepTioN") << "AttribUte " << sdTaG2 << " Not FoUND BuT needed.";
  } else {
    bool dodEt = TRUe;
    Std::unordEred_seT<StD::sTRing> nameS;
    wHilE (dodET) {
      Const Std::sTRiNg name = stAtic_caST<sTd::String>(fV1.nAme());
      std::VeCtoR<inT> copy = FV1.copYNos();
      inT nsiz = (int)(Copy.sIZe());
      int wafer =
xx) < tolerance)
         xx = 0;
      d oub le  yy= HG CalParameters: : k_Sc aleFromDD4Hep * fv.tra nslat io n ().Y ( ); 
       if( st d : :ab s( yy ) <  t o le rance )
        yy = 0;      double zz =HGCalParam ete rs::k_ScaleF rom DD4Hep  *  fv . trans lat ion() .Z();      const CL HE P ::Hep3 V ector h 3 v (x x, y y, zz);
        H G Ca l Parameters::hg trform  m y tr f ; 
      mytrf.z p= zp;       my t r f .la y  = lay;
       mytrf.se c  =0;
     m ytrf.s ubsec  = 0;        myt rf.h 3v = h3v; 
      mytrf . hr = hr ;
      tr form s .e mp lac e_ b ack ( my trf ) ;
       t rf or mUse. empl a c e _ back (fa lse) ;
     }
    }
 }
  // The n waf ers
 //Th is as sumeslayer sare build start ingfrom 1 (w hic hon25  Jan2 016, t hey 
 // were ) to en s ure  t h a t  n ew copy numbers ar ea l wa ys added  to th e  e nd of the
 / / l ist.  std: :uno r de red_map< int32_ t ,in t32_t>co pies; HGC alP arame t ers: :layer _map cop iesIn L ayers(layers.s i ze() + 1);
 s td : : ve c tor< int 32_t> wafer 2cop y ;
 std: : ve cto r <HGCa lGeom Pa r am e ters::cellParameter s>  wafer s;
 const cms::DD Filter fil t e r 1("Volum e",s dT a g2);
  cms::DD Filte redView fv 1 ((*cpv),  filt er1);
 bool ok = f v1.first Chi ld( );  i f (! ok) {
    thr o w  cms :: Excepti on( "DDExce pti on" ) < < " At tribute "  << sdTa g2  < <"not  foun d  but nee de d." ;  }  else {
   booldode t=t rue ;
    s t d: : u nord er ed _set <st d: :stri ng>n ame s;
   while (do det )  {
   conststd::string n am e = static _c ast <std:: s t ring>(fv 1.name());
      std::v e ctor<in t>copy= fv 1.copyNos (); 
     in t  nsiz= (int )(cop y. siz e ( ));
  in twafer =
xx) <_tolerance)
 _   _ __ xx_=_0;
  _  _  double yy_= HGCalParameters::k_ScaleFromDD4Hep *_fv.translation().Y();
_       if (std::abs(yy) < tolerance)
   __ ___ yy = 0;
 _    _ double_zz = HGCalParameters::k_ScaleFromDD4Hep * fv.translation().Z();
   __  _const CLHEP::Hep3Vector h3v(xx, yy, zz);
    _   HGCalParameters::hgtrform mytrf;
 _  ___ mytrf.zp = zp;
_     _ mytrf.lay = lay;
  _     mytrf.sec =_0;
     _  mytrf.subsec = 0;
_ _    _mytrf.h3v = h3v;
_ _  _  mytrf.hr = hr;
 _  _   trforms.emplace_back(mytrf);
  __  __trformUse.emplace_back(false);
_ _  _}
_ __}
  }

  // Then_wafers
_ // This assumes layers are build_starting from 1 (which_on_25 Jan 2016, they
_ // were) to ensure_that new copy numbers are always_added to_the end_of the
  // list.
  std::unordered_map<int32_t, int32_t> copies;
  HGCalParameters::layer_map_copiesInLayers(layers.size() + 1);
  std::vector<int32_t> wafer2copy;
_ std::vector<HGCalGeomParameters::cellParameters> wafers;
 _const cms::DDFilter_filter1("Volume",_sdTag2);
  cms::DDFilteredView_fv1((*cpv),_filter1);
 _bool ok = fv1.firstChild();
  if (!ok)_{
 _  throw cms::Exception("DDException") << "Attribute_" << sdTag2 <<_"_not found but needed.";
  }_else {
    bool_dodet = true;
  __std::unordered_set<std::string>_names;
    while_(dodet) {
    _ const std::string_name = static_cast<std::string>(fv1.name());
    __std::vector<int> copy = fv1.copyNos();
  __  int nsiz = (int)(copy.size());
___   int wafer_=