当前位置: 首页>>代码示例>>C++>>正文


C++ PlacedVolume类代码示例

本文整理汇总了C++中PlacedVolume的典型用法代码示例。如果您正苦于以下问题:C++ PlacedVolume类的具体用法?C++ PlacedVolume怎么用?C++ PlacedVolume使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PlacedVolume类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: verify_handle

/// Access the placement of a node in the chain of placements for this branch
PlacedVolume GlobalAlignment::nodePlacement(int level)   const   {
  CheckHandle verify_handle(*this);
  PlacedVolume pv = PlacedVolume(ptr()->GetNode(level));
  if ( pv.isValid() ) return pv;
  throw runtime_error("DD4hep: The object chain of "+string(placement().name())+
                      " is too short. [Invalid index]");
}
开发者ID:vvolkl,项目名称:DD4hep,代码行数:8,代码来源:GlobalAlignment.cpp

示例2: placeStaves

static void placeStaves(DetElement&   parent,
			DetElement&   stave,
			double        rmin, 
			int           numsides, 
			double        total_thickness, 
			Volume        envelopeVolume, 
			double        innerAngle, 
			Volume        sectVolume)
{
  double innerRotation    = innerAngle;
  double offsetRotation   = -innerRotation / 2;
  double sectCenterRadius = rmin + total_thickness / 2;
  double rotX =  M_PI / 2;
  double rotY = -offsetRotation;
  double posX = -sectCenterRadius  * std::sin(rotY);
  double posY =  sectCenterRadius  * std::cos(rotY);

  for (int module = 1; module <= numsides; ++module)  {
    DetElement det  = module>1 ? stave.clone(_toString(module,"stave%d")) : stave;
    PlacedVolume pv = envelopeVolume.placeVolume(sectVolume,Transform3D(RotationZYX(0,rotY,rotX),
									Translation3D(-posX,-posY,0)));
    // Not a valid volID: pv.addPhysVolID("stave", 0);
    pv.addPhysVolID("module",module);
    det.setPlacement(pv);
    parent.add(det);
    rotY -=  innerRotation;
    posX  = -sectCenterRadius * std::sin(rotY);
    posY  =  sectCenterRadius * std::cos(rotY);
  }
}
开发者ID:AIDASoft,项目名称:DD4hep,代码行数:30,代码来源:SectorBarrelCalorimeter_geo.cpp

示例3: dump

 static long dump(DetElement de,int level, bool sensitive_only) {
   const DetElement::Children& c = de.children();
   if ( !sensitive_only || 0 != de.volumeID() )  {
     PlacedVolume place = de.placement();
     const TGeoNode* node = place.ptr();
     char sens = place.volume().isSensitive() ? 'S' : ' ';
     int value = flag;
     char fmt[128];
     switch(value)  {
     case 0:
       ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%s #Dau:%%d VolID:%%08X Place:%%p  %%c",level+1,2*level+1);
       printout(INFO,"DetectorDump",fmt,"",de.path().c_str(),int(c.size()),
                (unsigned long)de.volumeID(), (void*)node, sens);
       break;
     case 1:
       ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds Detector: %%s #Dau:%%d VolID:%%p",level+1,2*level+1);
       printout(INFO,"DetectorDump", fmt, "", de.path().c_str(),
                int(c.size()), (void*)de.volumeID());
       ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds Placement: %%s   %%c",level+1,2*level+3);
       printout(INFO,"DetectorDump",fmt,"", de.placementPath().c_str(), sens);
       break;
     default:
       break;
     }
   }
   for (DetElement::Children::const_iterator i = c.begin(); i != c.end(); ++i)
     dump((*i).second,level+1,sensitive_only);
   return 1;
 }
开发者ID:vvolkl,项目名称:DD4hep,代码行数:29,代码来源:StandardPlugins.cpp

示例4: create_detector

static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sens)   {
  xml_det_t  x_det     = e;
  xml_dim_t  dim       = x_det.dimensions();
  Material   air       = description.air();
  string     det_name  = x_det.nameStr();
  DetElement sdet       (det_name,x_det.id());
  double     z         = dim.outer_z();
  double     rmin      = dim.inner_r();
  double     r         = rmin;
  int        n         = 0;
  Tube       envelope(rmin,2*rmin,2*z);
  Volume     envelopeVol(det_name+"_envelope",envelope,air);
    
  for(xml_coll_t c(x_det,_U(layer)); c; ++c)  {
    xml_comp_t x_layer = c;
    for(int i=0, im=0, repeat=x_layer.repeat(); i<repeat; ++i, im=0)  {
      string layer_name = det_name + _toString(n,"_layer%d");
      double rlayer = r;
      Tube   layer_tub(rmin,rlayer,2*z);
      Volume layer_vol(layer_name,layer_tub,air);
        
      for(xml_coll_t l(x_layer,_U(slice)); l; ++l, ++im)  {
        xml_comp_t x_slice = l;
        double     router = r + x_slice.thickness();
        Material   slice_mat  = description.material(x_slice.materialStr());
        string     slice_name = layer_name + _toString(im,"slice%d");
        Tube       slice_tube(r,router,z*2);
        Volume     slice_vol (slice_name,slice_tube,slice_mat);
          
        if ( x_slice.isSensitive() ) {
          sens.setType("calorimeter");
          slice_vol.setSensitiveDetector(sens);
        }
        r = router;
        slice_vol.setAttributes(description,x_slice.regionStr(),x_slice.limitsStr(),x_slice.visStr());
        // Instantiate physical volume
        layer_vol.placeVolume(slice_vol);
      }
      layer_vol.setVisAttributes(description,x_layer.visStr());
      layer_tub.setDimensions(rlayer,r,z*2,0,2*M_PI);
        
      PlacedVolume layer_physvol = envelopeVol.placeVolume(layer_vol);
      layer_physvol.addPhysVolID("layer",n);
      ++n;
    }
  }
  envelope.setDimensions(rmin,r,2*z);
  // Set region of slice
  envelopeVol.setAttributes(description,x_det.regionStr(),x_det.limitsStr(),x_det.visStr());
    
  PlacedVolume physvol = description.pickMotherVolume(sdet).placeVolume(envelopeVol);
  physvol.addPhysVolID("system",sdet.id()).addPhysVolID(_U(barrel),0);
  sdet.setPlacement(physvol);
  return sdet;
}
开发者ID:AIDASoft,项目名称:DD4hep,代码行数:55,代码来源:CylindricalBarrelCalorimeter_geo.cpp

示例5: operator

/// Callback to output PlacedVolume information of an single Placement
int VisMaterialProcessor::operator()(PlacedVolume pv, int /* level */)   {
  Volume vol = pv.volume();
  double frac_active = 0.0;
  VisAttr attr;

  for ( Atom atom : activeElements )   {
    frac_active += vol.material().fraction(atom);
  }
  //if ( frac_active >= fraction )
  printout(DEBUG,name,
           "++ Volume:%s [%s] active:%s fraction:%.3f active-vis:%s inactive-vis:%s",
           pv.name(), vol.name(), yes_no(frac_active >= fraction), frac_active,
           yes_no(activeVis.isValid()), yes_no(inactiveVis.isValid()));
  if ( activeVis.isValid() )   {
    if ( frac_active >= fraction )  {
      attr = activeVis;
      ++numActive;
    }
    if ( !attr.isValid() )  {
      for ( Material mat : activeMaterials )  {
        if ( mat.ptr() == vol.material().ptr() )   {
          attr = activeVis;
          ++numActive;
          break;
        }
      }
    }
  }
  // If we get here, the material is definitely inactive
  if ( inactiveVis.isValid() )  {
    if ( !attr.isValid() && setAllInactive )   {
      attr = inactiveVis;
      ++numInactive;
    }
    else if ( frac_active<fraction )   {
      attr = inactiveVis;
      ++numInactive;
    }
    if ( !attr.isValid() && inactiveVis.isValid() )  {
      for ( Material imat : inactiveMaterials )   {
        if ( imat.ptr() == vol.material().ptr() )   {
          attr = inactiveVis;
          ++numInactive;
          break;
        }
      }
    }
  }
  if ( attr.isValid() )  {
    set_attr(vol,attr);
  }
  return 1;
}
开发者ID:AIDASoft,项目名称:DD4hep,代码行数:54,代码来源:VisProcessor.cpp

示例6: operator

 /// Dump method.
 virtual int operator()(DetElement de,int level)  const  {
   const DetElement::Children& children = de.children();
   PlacedVolume place = de.placement();
   char sens = place.volume().isSensitive() ? 'S' : ' ';
   char fmt[128], tmp[32];
   ::snprintf(tmp,sizeof(tmp),"%03d/",level+1);
   ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%s #Dau:%%d VolID:%%08X %%c",level+1,2*level+1);
   printout(INFO,"DetectorDump",fmt,"",de.path().c_str(),int(children.size()),
            (unsigned long)de.volumeID(), sens);
   printer.prefix = string(tmp)+de.name();
   (printer)(de, level);
   return 1;
 }
开发者ID:AIDASoft,项目名称:DD4hep,代码行数:14,代码来源:ConditionsPlugins.cpp

示例7: if

void Installer<UserData>::install(DetElement component, PlacedVolume pv)   {
  Volume comp_vol = pv.volume();
  if ( comp_vol.isSensitive() )  {  
    Volume mod_vol = parentVolume(component);
    DD4hep::Geometry::PolyhedraRegular comp_shape(comp_vol.solid()), mod_shape(mod_vol.solid());

    if ( !comp_shape.isValid() || !mod_shape.isValid() )   {
      invalidInstaller("Components and/or modules are not Trapezoid -- invalid shapes");
    }
    else if ( !handleUsingCache(component,comp_vol) )  {
      DetElement par = component.parent();
      const TGeoHMatrix& m = par.worldTransformation();
      double dz = m.GetTranslation()[2];
      const double* trans = placementTranslation(component);
      double half_mod_thickness  = (mod_shape->GetZ(1)-mod_shape->GetZ(0))/2.0;
      double half_comp_thickness = (comp_shape->GetZ(1)-comp_shape->GetZ(0))/2.0;
      double si_position         = trans[2]+half_mod_thickness;
      double outer_thickness = half_mod_thickness - si_position;
      double inner_thickness = half_mod_thickness + si_position;
      Vector3D u(1.,0.,0.), v(0.,1.,0.), n(0.,0.,1.), o(100.,100.,0.);
      std::cout << " Module:    " << mod_shape.toString() << std::endl;
      std::cout << " Component: " << comp_shape.toString() << std::endl;
      std::cout << "dz:" << dz << " Si-pos:" << si_position 
                << " Mod-thickness:" << half_mod_thickness 
                << " Comp-thickness:" << half_comp_thickness 
                << std::endl;
      VolPlane surf(comp_vol,Type(Type::Sensitive,Type::Measurement1D),
                    inner_thickness, outer_thickness, u, v, n, o);
      addSurface(component,surf);
    }
  }
}
开发者ID:vvolkl,项目名称:DD4hep,代码行数:32,代码来源:PolyhedraEndcapCalorimeter2_surfaces.cpp

示例8: sensitiveDetector

/// Given a detector element, access it's sensitive detector (if the sub-detector is sensitive!)
SensitiveDetector LCDDHelper::sensitiveDetector(DetElement detector) const    {
  for(DetElement par = detector; par.isValid(); par = par.parent())  {
    if ( par.ptr() != ptr()->world().ptr() )  {
      PlacedVolume pv = par.placement();
      if ( pv.isValid() )   {
        const PlacedVolume::VolIDs& ids = pv.volIDs();
        for(PlacedVolume::VolIDs::const_iterator i=ids.begin(); i!=ids.end();++i)  {
          if ( (*i).first == "system" )   {
            return sensitiveDetector(par.name());
          }
        }
      }
    }
  }
  return SensitiveDetector(0);
}
开发者ID:vvolkl,项目名称:DD4hep,代码行数:17,代码来源:LCDDHelper.cpp

示例9: create_detector

static Ref_t create_detector(LCDD& lcdd, xml_h e, Ref_t)    {
  xml_det_t  x_det = e;
  string     name  = x_det.nameStr();
  DetElement sdet (name,x_det.id());
  Material   mat  (lcdd.material(x_det.materialStr()));

  // multiplication factor for ellipse major radius
  double c0 = 3.5;
  double rmin = 0.0, rmax = 0.0, z = 0.0;

  for(xml_coll_t c(x_det,_U(zplane)); c; ++c)  {
    xml_comp_t dim(c);
    rmin = dim.rmin();
    rmax = dim.rmax();
    z    = dim.z();
  }
 
  double ra    = rmax * c0;      // elipse long radius
  double rb    = rmax;           // elipse short radius
  double thick = rmax - rmin;    // pipe wall thickness
 
  EllipticalTube bpElTubeOut(ra+thick, rb+thick, z);
  EllipticalTube bpElTubeInn(ra, rb, z+thick);
  SubtractionSolid bpElTube(bpElTubeOut,bpElTubeInn);

  Tube bpTube1(rb, rb+thick, z+thick, 3*M_PI/2, M_PI/2);
  UnionSolid beamTube1(bpElTube,bpTube1);

  Tube bpTube2(rb+thick, ra+thick, z+thick, 3*M_PI/2, M_PI/2);
  SubtractionSolid beamTube(beamTube1,bpTube2);
  
  Volume     volume(name, beamTube, mat);
  
  double z_offset = x_det.hasAttr(_U(z_offset)) ? x_det.z_offset() : 0.0;

  volume.setVisAttributes(lcdd, x_det.visStr());
  PlacedVolume pv = lcdd.pickMotherVolume(sdet).placeVolume(volume,Position(0,0,z_offset));
  sdet.setPlacement(pv);
  
  if ( x_det.hasAttr(_U(id)) )  {
    int det_id = x_det.id();
    pv.addPhysVolID("system",det_id);
  }
  return sdet;
}
开发者ID:vvolkl,项目名称:DD4hep,代码行数:45,代码来源:LheD_tracker_BeamPipe_geo.cpp

示例10: operator

/// Callback to output PlacedVolume information of an single Placement
int VisDensityProcessor::operator()(PlacedVolume pv, int /* level */)   {
  Volume   vol = pv.volume();
  Material mat = vol.material();
  if ( vol.visAttributes().ptr() != minVis.ptr() )  {
    if ( mat.density() <= minDensity )  {
      vol.setVisAttributes(minVis);
    }
    ++numInactive;
  }
  return 1;
}
开发者ID:AIDASoft,项目名称:DD4hep,代码行数:12,代码来源:VisDensityProcessor.cpp

示例11: ptr

/// Accessfully decoded volume fields  by placement path
void Geant4VolumeManager::volumeDescriptor(const vector<const G4VPhysicalVolume*>& path,
                                           VolIDDescriptor& vol_desc) const
{
  vol_desc.second.clear();
  vol_desc.first = NonExisting;
  if (!path.empty() && checkValidity()) {
    const auto& m = ptr()->g4Paths;
    auto i = m.find(path);
    if (i != m.end()) {
      VolumeID vid = (*i).second;
      G4LogicalVolume* lvol = path[0]->GetLogicalVolume();
      if (lvol->GetSensitiveDetector()) {
        const G4VPhysicalVolume* node = path[0];
        const PlacementMap& pm = ptr()->g4Placements;
        for (PlacementMap::const_iterator ipm = pm.begin(); ipm != pm.end(); ++ipm) {
          if ((*ipm).second == node)  {
            PlacedVolume pv = (*ipm).first;
            SensitiveDetector sd = pv.volume().sensitiveDetector();
            IDDescriptor dsc = sd.readout().idSpec();
            vol_desc.first = vid;
            dsc.decodeFields(vid, vol_desc.second);
            return;
          }
        }
      }
      vol_desc.first = Insensitive;
      return;
    }
    if (!path[0])
      vol_desc.first = InvalidPath;
    else if (!path[0]->GetLogicalVolume()->GetSensitiveDetector())
      vol_desc.first = Insensitive;
    else
      vol_desc.first = NonExisting;
  }
}
开发者ID:AIDASoft,项目名称:DD4hep,代码行数:37,代码来源:Geant4VolumeManager.cpp

示例12: create_element


//.........这里部分代码省略.........
        DetElement lay_det (tracker,layer_name,layer_num);

        //Visualization
        layer_vol.setVisAttributes(lcdd.invisible());

        //module in phi // later also loop through modules for different modules
        xml_comp_t x_module = x_layer.child(_U(module));
        int repeat = x_module.repeat();
        double deltaphi = 2.*M_PI/repeat;
        //slices in z
        xml_comp_t x_slice = x_layer.child(_U(slice));
        int zrepeat = x_slice.repeat();
        double dz = x_slice.z();

        //add Extension to Detlement for the RecoGeometry
        Det::DetCylinderLayer* detcylinderlayer = new Det::DetCylinderLayer();
        lay_det.addExtension<Det::IDetExtension>(detcylinderlayer);

        int module_num = 0;
        //Place the Modules in z
        for (int k = -zrepeat; k<=zrepeat; k++)
        {
            string zname = _toString(k,"z%d");

            //Place the Modules in phi
            for (int i = 0; i < repeat; ++i)
            {
                //Create Module Volume
                Volume mod_vol("module", Box(x_module.length(), x_module.width(),x_module.thickness()), air);
                //Vizualization
                mod_vol.setVisAttributes(lcdd.invisible());

                double phi = deltaphi/dd4hep::rad * i;
                string module_name = zname + _toString(i,"module%d");

                Position trans(radius * cos(phi),
                               radius * sin(phi),
                               k*dz);

                //Create module Detelement
                DetElement mod_det(lay_det,module_name,module_num);
                //add Extension to Detlement for the RecoGeometry
                Det::DetModule* detmod = new Det::DetModule();
                mod_det.addExtension<Det::IDetExtension> (detmod);

                int comp_num = 0;
                //go through module components
                for (xml_coll_t n(x_module,_U(module_component)); n; ++n) {
                    xml_comp_t x_comp = n;

                    Volume comp_vol("component " + x_comp.materialStr(), Box(x_comp.length(),x_comp.width(), x_comp.thickness()),lcdd.material(x_comp.materialStr()));
                    //                  comp_vol.setVisAttributes(lcdd, x_comp.visStr());
                    //Set Sensitive Volmes sensitive
                    if (x_comp.isSensitive()) {
                        comp_vol.setSensitiveDetector(sens);
                    }
                    //Create DetElement
                    DetElement comp_det(mod_det, "component, " + x_comp.materialStr(),comp_num);
                    //add Extension
                    comp_det.addExtension<Det::IDetExtension> (ex);
                    //place component in Module
                    xml_comp_t x_pos = x_comp.position(false);
                    Position transComp (x_pos.x(),x_pos.y(),x_pos.z());
                    PlacedVolume placedcomp = mod_vol.placeVolume(comp_vol,transComp);
                    //assign the placed Volume to the DetElement
                    comp_det.setPlacement(placedcomp);
                    placedcomp.addPhysVolID("component",comp_num);
                    ++comp_num;
                }

                //Place Box Volumes in layer
                PlacedVolume placedmodule = layer_vol.placeVolume(mod_vol, Transform3D(RotationX(0.5*M_PI)*RotationZ(0.5*M_PI)*RotationX(phi-0.6*M_PI),trans));
                placedmodule.addPhysVolID("module", module_num);
                // assign module DetElement to the placed Module volume
                mod_det.setPlacement(placedmodule);


                ++module_num;
            }
            ++module_num;
        }
        //Place Layervolume

        PlacedVolume placedLayer = tracker_vol.placeVolume(layer_vol);
        placedLayer.addPhysVolID("layer",layer_num);
        placedLayer.addPhysVolID("system",x_det.id());
        //Assign Layer DetElement to LayerVolume
        lay_det.setPlacement(placedLayer);
        ++layer_num;

    }
    Volume mother_vol = lcdd.pickMotherVolume(tracker);
    //Place envelopevolume in mothervolume
    PlacedVolume placed_env = mother_vol.placeVolume(tracker_vol);
    //assign tracker DetElement to tracker volume
    tracker.setPlacement(placed_env); //fuer envelope moeglich


    return tracker;
}
开发者ID:alicerobson,项目名称:FCCSW,代码行数:101,代码来源:Module_geo.cpp

示例13: createTkLayoutTrackerBarrel

static DD4hep::Geometry::Ref_t createTkLayoutTrackerBarrel(DD4hep::Geometry::LCDD& lcdd,
                                                           DD4hep::XML::Handle_t xmlElement,
                                                           DD4hep::Geometry::SensitiveDetector sensDet) {
  // shorthands
  DD4hep::XML::DetElement xmlDet = static_cast<DD4hep::XML::DetElement>(xmlElement);
  Dimension dimensions(xmlDet.dimensions());
  // get sensitive detector type from xml
  DD4hep::XML::Dimension sdTyp = xmlElement.child(_Unicode(sensitive));
  // sensitive detector used for all sensitive parts of this detector
  sensDet.setType(sdTyp.typeStr());

  // definition of top volume
  // has min/max dimensions of tracker for visualization etc.
  std::string detectorName = xmlDet.nameStr();
  DetElement topDetElement(detectorName, xmlDet.id());
  Acts::ActsExtension::Config barrelConfig;
  barrelConfig.isBarrel = true;
  // detElement owns extension
  Acts::ActsExtension* detWorldExt = new Acts::ActsExtension(barrelConfig);
  topDetElement.addExtension<Acts::IActsExtension>(detWorldExt);
  DD4hep::Geometry::Tube topVolumeShape(
      dimensions.rmin(), dimensions.rmax(), (dimensions.zmax() - dimensions.zmin()) * 0.5);
  Volume topVolume(detectorName, topVolumeShape, lcdd.air());
  topVolume.setVisAttributes(lcdd.invisible());

  // counts all layers - incremented in the inner loop over repeat - tags
  unsigned int layerCounter = 0;
  double integratedModuleComponentThickness = 0;
  double phi = 0;
  // loop over 'layer' nodes in xml
  DD4hep::XML::Component xLayers = xmlElement.child(_Unicode(layers));
  for (DD4hep::XML::Collection_t xLayerColl(xLayers, _U(layer)); nullptr != xLayerColl; ++xLayerColl) {
    DD4hep::XML::Component xLayer = static_cast<DD4hep::XML::Component>(xLayerColl);
    DD4hep::XML::Component xRods = xLayer.child("rods");
    DD4hep::XML::Component xRodEven = xRods.child("rodOdd");
    DD4hep::XML::Component xRodOdd = xRods.child("rodEven");
    DD4hep::XML::Component xModulesEven = xRodEven.child("modules");
    DD4hep::XML::Component xModulePropertiesOdd = xRodOdd.child("moduleProperties");
    DD4hep::XML::Component xModulesOdd = xRodOdd.child("modules");
    DD4hep::Geometry::Tube layerShape(xLayer.rmin(), xLayer.rmax(), dimensions.zmax());
    Volume layerVolume("layer", layerShape, lcdd.material("Air"));
    layerVolume.setVisAttributes(lcdd.invisible());
    PlacedVolume placedLayerVolume = topVolume.placeVolume(layerVolume);
    placedLayerVolume.addPhysVolID("layer", layerCounter);
    DetElement lay_det(topDetElement, "layer" + std::to_string(layerCounter), layerCounter);
    Acts::ActsExtension::Config layConfig;
    layConfig.isLayer = true;
    // the local coordinate systems of modules in dd4hep and acts differ
    // see http://acts.web.cern.ch/ACTS/latest/doc/group__DD4hepPlugins.html
    layConfig.axes = "XzY"; // correct translation of local x axis in dd4hep to local x axis in acts
    // detElement owns extension
    Acts::ActsExtension* layerExtension = new Acts::ActsExtension(layConfig);
    lay_det.addExtension<Acts::IActsExtension>(layerExtension);
    lay_det.setPlacement(placedLayerVolume);
    DD4hep::XML::Component xModuleComponentsOdd = xModulePropertiesOdd.child("components");
    integratedModuleComponentThickness = 0;
    int moduleCounter = 0;
    Volume moduleVolume;
    for (DD4hep::XML::Collection_t xModuleComponentOddColl(xModuleComponentsOdd, _U(component));
         nullptr != xModuleComponentOddColl;
         ++xModuleComponentOddColl) {
      DD4hep::XML::Component xModuleComponentOdd = static_cast<DD4hep::XML::Component>(xModuleComponentOddColl);
      moduleVolume = Volume("module",
                            DD4hep::Geometry::Box(0.5 * xModulePropertiesOdd.attr<double>("modWidth"),
                                                  0.5 * xModuleComponentOdd.thickness(),
                                                  0.5 * xModulePropertiesOdd.attr<double>("modLength")),
                            lcdd.material(xModuleComponentOdd.materialStr()));
      unsigned int nPhi = xRods.repeat();
      DD4hep::XML::Handle_t currentComp;
      for (unsigned int phiIndex = 0; phiIndex < nPhi; ++phiIndex) {
        double lX = 0;
        double lY = 0;
        double lZ = 0;
        if (0 == phiIndex % 2) {
          phi = 2 * M_PI * static_cast<double>(phiIndex) / static_cast<double>(nPhi);
          currentComp = xModulesEven;
        } else {
          currentComp = xModulesOdd;
        }
        for (DD4hep::XML::Collection_t xModuleColl(currentComp, _U(module)); nullptr != xModuleColl; ++xModuleColl) {
          DD4hep::XML::Component xModule = static_cast<DD4hep::XML::Component>(xModuleColl);
          double currentPhi = atan2(xModule.Y(), xModule.X());
          double componentOffset =  integratedModuleComponentThickness - 0.5 * xModulePropertiesOdd.attr<double>("modThickness") + 0.5 * xModuleComponentOdd.thickness();
          lX = xModule.X() + cos(currentPhi) * componentOffset;
          lY = xModule.Y() + sin(currentPhi) * componentOffset;
          lZ = xModule.Z();
          DD4hep::Geometry::Translation3D moduleOffset(lX, lY, lZ);
          DD4hep::Geometry::Transform3D lTrafo(DD4hep::Geometry::RotationZ(atan2(lY,  lX) + 0.5 * M_PI), moduleOffset);
          DD4hep::Geometry::RotationZ lRotation(phi);
          PlacedVolume placedModuleVolume = layerVolume.placeVolume(moduleVolume, lRotation * lTrafo);
          if (xModuleComponentOdd.isSensitive()) {
            placedModuleVolume.addPhysVolID("module", moduleCounter);
            moduleVolume.setSensitiveDetector(sensDet);
            DetElement mod_det(lay_det, "module" + std::to_string(moduleCounter), moduleCounter);
            mod_det.setPlacement(placedModuleVolume);
            ++moduleCounter;
          }
        }
      }
      integratedModuleComponentThickness += xModuleComponentOdd.thickness();
//.........这里部分代码省略.........
开发者ID:clementhelsens,项目名称:FCCSW,代码行数:101,代码来源:TkLayoutBarrel_Geo.cpp

示例14: create_detector

static Ref_t create_detector(Detector& theDetector, xml_h e, SensitiveDetector sens)  {
  typedef vector<PlacedVolume> Placements;
  xml_det_t   x_det     = e;
  Material    vacuum    = theDetector.vacuum();
  int         det_id    = x_det.id();
  string      det_name  = x_det.nameStr();
  bool        reflect   = x_det.reflect(false);
  DetElement  sdet        (det_name,det_id);
  int         m_id=0, c_id=0, n_sensor=0;
  map<string, Volume> modules;
  map<string, Placements>  sensitives;
  PlacedVolume pv;

  // --- create an envelope volume and position it into the world ---------------------

  Volume envelope = dd4hep::xml::createPlacedEnvelope(theDetector, e, sdet);
  dd4hep::xml::setDetectorTypeFlag(e, sdet);

  if( theDetector.buildType() == BUILD_ENVELOPE ) return sdet;

  //-----------------------------------------------------------------------------------

  envelope.setVisAttributes(theDetector.invisible());
  sens.setType("tracker");

  // Build the sensor units
  // Loop over 'modules' as defined in the XML
  for(xml_coll_t mi(x_det,_U(module)); mi; ++mi, ++m_id) { 
    xml_comp_t x_mod   = mi;
    string     m_nam   = x_mod.nameStr();
    xml_comp_t trd     = x_mod.trd();
    double     posY;
    double     x1      = trd.x1();
    double     x2      = trd.x2();
    double     z       = trd.z();
    double     y1, y2, total_thickness=0.;
    xml_coll_t ci(x_mod, _U(module_component));
    for(ci.reset(), total_thickness=0.0; ci; ++ci)
      total_thickness += xml_comp_t(ci).thickness();
      
    y1 = y2 = total_thickness / 2;
    Volume m_volume(m_nam, Trapezoid(x1, x2, y1, y2, z), vacuum);      
    m_volume.setVisAttributes(theDetector.visAttributes(x_mod.visStr()));

    std::cout << m_nam << ", thickness=" << total_thickness << std::endl;

    // Loop over the module_components ('slices') in the 'module'
    // The first component (top in the XML) is placed at the 'bottom'
    for(ci.reset(), n_sensor=1, c_id=0, posY=-y1; ci; ++ci, ++c_id) {
      xml_comp_t c       = ci;
      double     c_thick = c.thickness();
      Material   c_mat   = theDetector.material(c.materialStr());
      string     c_name  = _toString(c_id, "component%d");
      Volume     c_vol(c_name, Trapezoid(x1,x2,c_thick/2e0,c_thick/2e0,z), c_mat);

      std::cout << " + sensor " << n_sensor << " " << c_name;

      c_vol.setVisAttributes(theDetector.visAttributes(c.visStr()));
      pv = m_volume.placeVolume(c_vol, Position(0, posY + c_thick/2, 0));
      if ( c.isSensitive() ) {
        sdet.check(n_sensor > 2, "SiTrackerEndcap::fromCompact: " + c_name + " Max of 2 modules allowed!");
	pv.addPhysVolID("sensor", n_sensor);
        c_vol.setSensitiveDetector(sens);
        sensitives[m_nam].push_back(pv);
	std::cout << " (" << n_sensor << " is sensitive) ";
        ++n_sensor;
      }
      std::cout << std::endl;
      posY += c_thick;
    }
    modules[m_nam] = m_volume;
  }
  // done building the 2 modules, of 12 layers each

  int mod_count[12] = {0};

  // Build now the detector itself
  // Loop over layers as defined in the XML
  for(xml_coll_t li(x_det, _U(layer)); li; ++li) {
    xml_comp_t x_layer(li);
    int l_id = x_layer.id();
    int ring_num = 0;
    
    std::cout << "Layer " << l_id << ":" << std::endl;

    // Loop over rings, as defined in the XML
    for(xml_coll_t ri(x_layer, _U(ring)); ri; ++ri) {
      xml_comp_t x_ring = ri;
      double r        = x_ring.r();
      double phi0     = x_ring.phi0(0);
      double zstart   = x_ring.zstart();
      double dz       = x_ring.dz(0);
      int    nmodules = x_ring.nmodules();
      string m_nam    = x_ring.moduleStr();
      Volume m_vol    = modules[m_nam];
      double iphi     = 2*M_PI/nmodules;
      double phi      = phi0;
      Placements& sensVols = sensitives[m_nam];

      // This driver version encodes the rings as layers and the
//.........这里部分代码省略.........
开发者ID:iLCSoft,项目名称:lcgeo,代码行数:101,代码来源:SiTrackerEndcap_o2_v03_geo.cpp

示例15: create_detector

static Ref_t create_detector(LCDD& lcdd, xml_h e, SensitiveDetector sens)  {
    //XML detector object: DDCore/XML/XMLDetector.h
    xml_dim_t x_det = e;
    //Create the DetElement for DD4hep
    DetElement d_det(x_det.nameStr(),x_det.id());

    //XML dimension object: DDCore/XML/XMLDimension.h
    xml_dim_t x_det_dim(x_det.dimensions());
    //double inner_r = x_det_dim.rmin();
    //double outer_r = x_det_dim.rmax();
    Assembly calo_vol(x_det.nameStr()+"_envelope");
    PlacedVolume pv;

    //Set envelope volume attributes
    calo_vol.setAttributes(lcdd,x_det.regionStr(),x_det.limitsStr(),x_det.visStr());

#if 0

    //Declare this sensitive detector as a calorimeter
    Tube tub(inner_r,outer_r,x_det_dim.z()/2.0,0.0,2*M_PI);
    //Volume tub_vol(x_det.nameStr()+"_tube",tub,lcdd.material("PyrexGlass"));
    Volume tub_vol(x_det.nameStr()+"_tube",tub,lcdd.material("Iron"));
    calo_vol.placeVolume(tub_vol);
    sens.setType("calorimeter");
    tub_vol.setSensitiveDetector(sens);
    d_det.setAttributes(lcdd,tub_vol,x_det.regionStr(),x_det.limitsStr(),x_det.visStr());
#endif

#if 1

    int layer_num = 0;
    float layer_pos_z = 0;
    double tile_phi = 2*M_PI/x_det_dim.phiBins();
    float r = x_det_dim.rmin();

    bool debug = true;

    Assembly stave_vol(x_det.nameStr()+"_stave_0");


    //Repeat layers until we reach the rmax
    while(r<x_det_dim.rmax()) {

        //Loop over layers of type: XML Collection_t object: DDCore/XML/XMLElements.h
        for(DD4hep::XML::Collection_t layerIt(x_det,_U(layer)); layerIt; ++layerIt, ++layer_num)   {

            //Build a layer volume
            xml_comp_t x_det_layer = layerIt;

            float dr = x_det_layer.dr();

            string layer_name =  x_det.nameStr()+_toString(layer_num,"_layer%d");

            float    x1  = r * tan(tile_phi/2.);
            float    x2  = (r+dr) * tan(tile_phi/2.);
            float    y1  = x_det_dim.z();
            float    y2  = x_det_dim.z();
            float    z   = x_det_layer.dr();

            if(debug) {
                cout << " r:" << r
                     << " dr:" << dr
                     << " x1:" << x1
                     << " x2:" << x2
                     << " y1:" << y1
                     << " y2:" << y2
                     << " z:" << z
                     << endl;
            }

            //Shape a Trapezoid (tile): DDCore/DD4hep/Shapes.h
            Trapezoid layer_shape(x1,x2,y1,y2,z);

            //Create a volume with trapezoid shape
            Volume layer_vol(layer_name, layer_shape, lcdd.air());
            layer_vol.setAttributes(lcdd,x_det.regionStr(),x_det.limitsStr(),x_det_layer.visStr());

            //DetElement layer(layer_name,_toString(layer_num,"layer%d"),x_det.id());

            //Fill the volume with tiles
            vector<Volume> tiles;

            //Assembly tile_seq(layer_name+"_seq");
            Trapezoid tile_seq_shape(x1,x2,x_det_layer.dz(),x_det_layer.dz(),x_det_layer.dr());
            Volume tile_seq(layer_name + "_seq",tile_seq_shape,lcdd.air());
            double total_thickness = 0;
            //Repeat slices until we reach the end of the calorimeter
            int slice_num = 0, tile_number = 0;

            tile_seq.setVisAttributes(lcdd.visAttributes("VisibleGreen"));
            for(xml_coll_t k(x_det_layer,_U(slice)); k; ++k, ++slice_num)  {
                xml_comp_t tile_xml       = k;
                string     tile_name      = layer_name + _toString(tile_number,"_slice%d");
                Material   tile_material  = lcdd.material(tile_xml.materialStr());
                float      tile_thickness = tile_xml.dz();
                float      tile_y1        = tile_thickness;
                float      tile_y2        = tile_thickness;
                float      tile_z         = x_det_layer.dr();

                Trapezoid tile_shape(x1,x2,tile_y1,tile_y2,tile_z);
//.........这里部分代码省略.........
开发者ID:vvolkl,项目名称:DD4hep,代码行数:101,代码来源:FCC_HcalBarrel_geo.cpp


注:本文中的PlacedVolume类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。