本文整理汇总了C++中PlacedVolume::addPhysVolID方法的典型用法代码示例。如果您正苦于以下问题:C++ PlacedVolume::addPhysVolID方法的具体用法?C++ PlacedVolume::addPhysVolID怎么用?C++ PlacedVolume::addPhysVolID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlacedVolume
的用法示例。
在下文中一共展示了PlacedVolume::addPhysVolID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: 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;
}
示例3: 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;
}
示例4: create_detector
//.........这里部分代码省略.........
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);
Volume tile_vol(tile_name,tile_shape,tile_material);
pv = tile_seq.placeVolume(tile_vol,Position(0,total_thickness,0));
pv.addPhysVolID("slice",slice_num);
total_thickness += tile_thickness;
if ( tile_xml.isSensitive() ) {
cout << "Set volume " << tile_name << " sensitive...." << endl;
tile_vol.setSensitiveDetector(sens);
}
// Set region, limitset, and visibility settings
tile_vol.setAttributes(lcdd,tile_xml.regionStr(),tile_xml.limitsStr(),tile_xml.visStr());
tiles.push_back(tile_vol);
tile_number++;
}
// Place the same volumes inside the envelope
float tile_pos_z = -x_det_dim.z()/2.;
int tile_num = 0;
while(tile_pos_z<x_det_dim.z()/2.) {
pv = layer_vol.placeVolume(tile_seq,Position(0,tile_pos_z,0));
pv.addPhysVolID("tile",tile_num);
tile_pos_z += total_thickness;
tile_num++;
}
// Place the same layer around the beam axis phiBins times
Transform3D tr(RotationZYX(M_PI*0.5,M_PI*0.5,0),Translation3D(r,0,layer_pos_z));
pv = stave_vol.placeVolume(layer_vol,tr);
pv.addPhysVolID("layer",layer_num);
r += dr;
cout << "+++ R=" << r << endl;
}
}
//double mod_x_off = outer_r - (outer_r-inner_r)/2.0;
//double mod_y_off = 0;
int nphi_bins = x_det_dim.phiBins();
for(int i=0; i<nphi_bins; i++) {
if(debug) cout << "Layer:" << i << " phi:" << tile_phi << " rotz:" << (tile_phi*i) << endl;
double phi = tile_phi*i;
//double pos_x = mod_x_off * cos(phi) - mod_y_off * sin(phi);
//double pos_y = mod_x_off * sin(phi) + mod_y_off * cos(phi);
Transform3D tr(RotationZYX(phi,0,0),Translation3D(0,0,0));
pv = calo_vol.placeVolume(stave_vol,tr);
pv.addPhysVolID("stave",i+1);
}
cout << "Number of layers: " << layer_num << endl;
#endif
//Place the calo inside the world
PlacedVolume calo_plv = lcdd.pickMotherVolume(d_det).placeVolume(calo_vol);
calo_plv.addPhysVolID("system",x_det.id());
calo_plv.addPhysVolID("barrel",0);
d_det.setPlacement(calo_plv);
return d_det;
}
示例5: create_detector
static Ref_t create_detector(LCDD& lcdd, xml_h e, SensitiveDetector sens) {
typedef vector<PlacedVolume> Placements;
xml_det_t x_det = e;
Material vacuum = lcdd.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);
Assembly assembly (det_name);
//Volume assembly (det_name,Box(10000,10000,10000),vacuum);
Volume motherVol = lcdd.pickMotherVolume(sdet);
int m_id=0, c_id=0, n_sensor=0;
map<string,Volume> modules;
map<string, Placements> sensitives;
PlacedVolume pv;
assembly.setVisAttributes(lcdd.invisible());
sens.setType("tracker");
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(lcdd.visAttributes(x_mod.visStr()));
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 = lcdd.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);
c_vol.setVisAttributes(lcdd.visAttributes(c.visStr()));
pv = m_volume.placeVolume(c_vol,Position(0,posY+c_thick/2,0));
if ( c.isSensitive() ) {
sdet.check(n_sensor > 2,"SiTrackerEndcap2::fromCompact: "+c_name+" Max of 2 modules allowed!");
pv.addPhysVolID("sensor",n_sensor);
c_vol.setSensitiveDetector(sens);
sensitives[m_nam].push_back(pv);
++n_sensor;
}
posY += c_thick;
}
modules[m_nam] = m_volume;
}
for(xml_coll_t li(x_det,_U(layer)); li; ++li) {
xml_comp_t x_layer(li);
int l_id = x_layer.id();
int mod_num = 1;
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];
for(int k=0; k<nmodules; ++k) {
string m_base = _toString(l_id,"layer%d") + _toString(mod_num,"_module%d");
double x = -r*std::cos(phi);
double y = -r*std::sin(phi);
DetElement module(sdet,m_base+"_pos",det_id);
pv = assembly.placeVolume(m_vol,Transform3D(RotationZYX(0,-M_PI/2-phi,-M_PI/2),Position(x,y,zstart+dz)));
pv.addPhysVolID("side",1).addPhysVolID("layer", l_id).addPhysVolID("module",mod_num);
module.setPlacement(pv);
for(size_t ic=0; ic<sensVols.size(); ++ic) {
PlacedVolume sens_pv = sensVols[ic];
DetElement comp_elt(module,sens_pv.volume().name(),mod_num);
comp_elt.setPlacement(sens_pv);
}
if ( reflect ) {
pv = assembly.placeVolume(m_vol,Transform3D(RotationZYX(M_PI,-M_PI/2-phi,-M_PI/2),Position(x,y,-zstart-dz)));
pv.addPhysVolID("side",-1).addPhysVolID("layer",l_id).addPhysVolID("module",mod_num);
DetElement r_module(sdet,m_base+"_neg",det_id);
r_module.setPlacement(pv);
for(size_t ic=0; ic<sensVols.size(); ++ic) {
PlacedVolume sens_pv = sensVols[ic];
DetElement comp_elt(r_module,sens_pv.volume().name(),mod_num);
comp_elt.setPlacement(sens_pv);
}
}
//.........这里部分代码省略.........
示例6: create_detector
static Ref_t create_detector(LCDD& lcdd, xml_h e, SensitiveDetector sens) {
//XML detector object: DDCore/XML/XMLDetector.h
DD4hep::XML::DetElement x_det = e;
//Create the DetElement for DD4hep
DetElement d_det(x_det.nameStr(),x_det.id());
//Pick the mothervolume
Volume det_vol = lcdd.pickMotherVolume(d_det);
//XML dimension object: DDCore/XML/XMLDimension.h
DD4hep::XML::Dimension x_det_dim(x_det.dimensions());
//Tube: DDCore/DD4hep/Shapes.h
Tube calo_shape(x_det_dim.rmin(),x_det_dim.rmax(),x_det_dim.z());
//Create the detector mother volume
Volume calo_vol(x_det.nameStr()+"_envelope",calo_shape,lcdd.air());
//Set envelope volume attributes
calo_vol.setAttributes(lcdd,x_det.regionStr(),x_det.limitsStr(),x_det.visStr());
//Place inside the mother volume
PlacedVolume calo_plv = det_vol.placeVolume(calo_vol);
calo_plv.addPhysVolID("system",x_det.id());
calo_plv.addPhysVolID("barrel",0);
d_det.setPlacement(calo_plv);
//Declare this sensitive detector as a calorimeter
sens.setType("calorimeter");
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 = false;
//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){
//Build a layer volume
DD4hep::XML::Component 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
int tile_number = 0;
vector<Volume> tiles;
//Repeat slices until we reach the end of the calorimeter
for(xml_coll_t k(x_det_layer,_U(slice)); k; ++k) {
DD4hep::XML::Component 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();
//Shape a Trapezoid (tile): DDCore/DD4hep/Shapes.h
Trapezoid tile_shape(x1,x2,tile_y1,tile_y2,tile_z);
//.........这里部分代码省略.........
示例7: lLog
static DD4hep::Geometry::Ref_t createHCal (
DD4hep::Geometry::LCDD& lcdd,
xml_h xmlElement,
DD4hep::Geometry::SensitiveDetector sensDet
) {
// Get the Gaudi message service and message stream:
ServiceHandle<IMessageSvc> msgSvc("MessageSvc", "HCalConstruction");
MsgStream lLog(&(*msgSvc), "HCalConstruction");
xml_det_t xmlDet = xmlElement;
std::string detName = xmlDet.nameStr();
//Make DetElement
DetElement hCal(detName, xmlDet.id());
// Get status for the RecoGeometry what is status?
// xml_comp_t xmlStatus = xmlDet.child(_U(status));
// int status = xmlStatus.id();
// add Extension to Detlement for the RecoGeometry
// Let's skip this for now...
// Det::DetCylinderVolume* detVolume = new Det::DetCylinderVolume(status);
// hCal.addExtension<Det::IDetExtension>(detVolume);
// Make volume that envelopes the whole barrel; set material to air
Dimension dimensions(xmlDet.dimensions());
DD4hep::Geometry::Tube envelopeShape(dimensions.rmin(), dimensions.rmax(), dimensions.dz());
Volume envelopeVolume(detName, envelopeShape, lcdd.air());
// Invisibility seems to be broken in visualisation tags, have to hardcode that
// envelopeVolume.setVisAttributes(lcdd, dimensions.visStr());
envelopeVolume.setVisAttributes(lcdd.invisible());
// set the sensitive detector type to the DD4hep calorimeter
sensDet.setType("SimpleCalorimeterSD");
// Add structural support made of steel inside of HCal
xml_comp_t xFacePlate = xmlElement.child("face_plate");
double dRhoFacePlate = xFacePlate.thickness();
double sensitiveBarrelRmin = dimensions.rmin() + dRhoFacePlate;
DetElement facePlate("facePlate", 0);
DD4hep::Geometry::Tube facePlateShape(dimensions.rmin(), sensitiveBarrelRmin, dimensions.dz());
Volume facePlateVol("facePlate", facePlateShape, lcdd.material(xFacePlate.materialStr()));
facePlateVol.setVisAttributes(lcdd, xFacePlate.visStr());
PlacedVolume placedFacePlate = envelopeVolume.placeVolume(facePlateVol);
placedFacePlate.addPhysVolID("facePlate", facePlate.id());
facePlate.setPlacement(placedFacePlate);
// Add structural support made of steel at both ends of HCal
xml_comp_t xEndPlate = xmlElement.child("end_plate");
double dZEndPlate = xEndPlate.thickness();
DD4hep::Geometry::Tube endPlateShape(dimensions.rmin(), dimensions.rmax(), dZEndPlate);
Volume endPlateVol("endPlate", endPlateShape, lcdd.material(xEndPlate.materialStr()));
endPlateVol.setVisAttributes(lcdd, xEndPlate.visStr());
DetElement endPlatePos("endPlate", 0);
DD4hep::Geometry::Position posOffset(0, 0, dimensions.dz() - dZEndPlate);
PlacedVolume placedEndPlatePos = envelopeVolume.placeVolume(endPlateVol, posOffset);
placedEndPlatePos.addPhysVolID("endPlatePos", endPlatePos.id());
endPlatePos.setPlacement(placedEndPlatePos);
DetElement endPlateNeg("endPlate", 1);
DD4hep::Geometry::Position negOffset(0, 0, -dimensions.dz() + dZEndPlate);
PlacedVolume placedEndPlateNeg = envelopeVolume.placeVolume(endPlateVol, negOffset);
placedEndPlateNeg.addPhysVolID("endPlateNeg", endPlateNeg.id());
endPlateNeg.setPlacement(placedEndPlateNeg);
// Hard-coded assumption that we have two different sequences for the modules
std::vector<xml_comp_t> sequences = {xmlElement.child("sequence_a"), xmlElement.child("sequence_b")};
// NOTE: This assumes that both have the same dimensions!
Dimension moduleDimensions(sequences[0].dimensions());
double dzModule = moduleDimensions.dz();
// calculate the number of modules fitting in phi, Z and Rho
unsigned int numModulesPhi = moduleDimensions.phiBins();
unsigned int numModulesZ = static_cast<unsigned>(dimensions.dz() / dzModule);
unsigned int numModulesR = static_cast<unsigned>((dimensions.rmax() - sensitiveBarrelRmin) / moduleDimensions.dr());
lLog << MSG::DEBUG << "constructing " << numModulesPhi << " modules per ring in phi, "
<< numModulesZ << " rings in Z, "
<< numModulesR << " rings (layers) in Rho"
<< numModulesR*numModulesZ*numModulesPhi << " modules" << endmsg;
// Calculate correction along z based on the module size (can only have natural number of modules)
double dzDetector = numModulesZ * dzModule + dZEndPlate;
lLog << MSG::INFO << "correction of dz:" << dimensions.dz() - dzDetector << endmsg;
// calculate the dimensions of one module:
double dphi = 2 * dd4hep::pi / static_cast<double>(numModulesPhi);
double tn = tan(dphi / 2.);
double spacing = moduleDimensions.x();
double dy0 = moduleDimensions.dz();
double dz0 = moduleDimensions.dr() / 2.;
double drWedge = cos(dphi / 2.) * (dimensions.rmax() - sensitiveBarrelRmin) * 0.5;
double dxWedge1 = tn * sensitiveBarrelRmin - spacing;
double dxWedge2 = tn * cos(dphi / 2.) * dimensions.rmax() - spacing;
// First we construct one wedge with width of one module:
Volume subWedgeVolume("subWedge", DD4hep::Geometry::Trapezoid(
dxWedge1, dxWedge2, dzModule, dzModule, drWedge
//.........这里部分代码省略.........
示例8: dimensions
/**
Factory for a configurable, generic tracker endcap.
@author: Valentin Volkl
*/
static DD4hep::Geometry::Ref_t createGenericTrackerEndcap(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("sensitive"); // retrieve the type
if (xmlDet.isSensitive()) {
sensDet.setType(sdTyp.typeStr()); // set for the whole detector
}
// definition of top volume
std::string detName = xmlDet.nameStr();
DetElement GenericTrackerEndcapWorld(detName, xmlDet.id());
// envelope volume with the max dimensions of tracker for visualization etc.
// contains both endcaps, in forward and in backwards direction
// the part between -z1 and z1 is subtracted from the envelope
DD4hep::Geometry::Tube posnegEnvelopeShape_add(dimensions.rmin(), dimensions.rmax(), (dimensions.z2()));
// make the negative shape slighly larger in the radial direction
// to be sure that everything is subtracted between -z1 and z1
DD4hep::Geometry::Box posnegEnvelopeShape_subtract(
dimensions.rmax() * 1.001, dimensions.rmax() * 1.001, dimensions.z1());
DD4hep::Geometry::SubtractionSolid posnegEnvelopeShape(posnegEnvelopeShape_add, posnegEnvelopeShape_subtract);
Volume posnegEnvelopeVolume(detName, posnegEnvelopeShape, lcdd.air());
posnegEnvelopeVolume.setVisAttributes(lcdd.invisible());
// envelope volume for one of the endcaps, either forward or backward
DD4hep::Geometry::Tube envelopeShape(dimensions.rmin(), dimensions.rmax(), 0.5 * (dimensions.z2() - dimensions.z1()));
Volume envelopeVolume(detName, envelopeShape, lcdd.air());
envelopeVolume.setVisAttributes(lcdd.invisible());
// loop over 'layer' nodes in xml
unsigned int layerCounter = 0;
for (DD4hep::XML::Collection_t xLayerColl(xmlElement, _U(layers)); nullptr != xLayerColl; ++xLayerColl) {
DD4hep::XML::Component xLayer = static_cast<DD4hep::XML::Component>(xLayerColl);
// create petals
unsigned int nPhi = static_cast<unsigned int>(getAttrValueWithFallback(xLayer, "nPhi", 16));
const double lModuleTwistAngle = getAttrValueWithFallback(xLayer, "module_twist_angle", 0.05 * M_PI);
double dr = xLayer.rmax() - xLayer.rmin();
double dphi = 2 * dd4hep::pi / static_cast<double>(nPhi);
double tn = tan(dphi);
Volume petalVolume(
"petal",
DD4hep::Geometry::Trapezoid(
0.5 * xLayer.rmin() * tn, 0.5 * xLayer.rmax() * tn, xLayer.thickness(), xLayer.thickness(), 0.5 * dr),
lcdd.material("Silicon"));
petalVolume.setVisAttributes(lcdd, xLayer.visStr());
petalVolume.setSensitiveDetector(sensDet);
// handle repeat attribute in xml
double layerThickness;
unsigned int numLayers;
double current_z;
// "repeat" layers equidistant between rmin and rmax
numLayers = xLayer.repeat();
layerThickness = (xLayer.z2() - xLayer.z1()) / numLayers;
// create layers.
for (unsigned int repeatIndex = 0; repeatIndex < numLayers; ++repeatIndex) {
DD4hep::Geometry::Tube layerShape(xLayer.rmin(), xLayer.rmax(), 0.5 * layerThickness);
Volume layerVolume("layer" + std::to_string(layerCounter), layerShape, lcdd.air());
layerVolume.setVisAttributes(lcdd.invisible());
++layerCounter;
// place layers not at center, but at z1 value of containing envelope
// subtract half of the envelope length
current_z = (repeatIndex + 0.5) * layerThickness + xLayer.z1() - dimensions.z1();
PlacedVolume placedLayerVolume = envelopeVolume.placeVolume(
layerVolume, DD4hep::Geometry::Position(0, 0, current_z - 0.5 * (dimensions.z2() - dimensions.z1())));
placedLayerVolume.addPhysVolID("layer", layerCounter);
double phi;
double r = xLayer.rmin();
for (unsigned int phiIndex = 0; phiIndex < nPhi; ++phiIndex) {
phi = 2 * dd4hep::pi * static_cast<double>(phiIndex) / static_cast<double>(nPhi);
// oriented along z at first
DD4hep::Geometry::Translation3D lTranslation_ringPhiPos(0, 0, r + 0.5 * dr);
DD4hep::Geometry::RotationY lRotation_ringPhiPos(phi);
DD4hep::Geometry::RotationX lRotation_orientRing(0.5 * dd4hep::pi);
// twist petals slightly so they can overlap
DD4hep::Geometry::RotationZ lRotation_twist(lModuleTwistAngle);
PlacedVolume placedPetalVolume = layerVolume.placeVolume(
petalVolume, lRotation_orientRing * lRotation_ringPhiPos * lTranslation_ringPhiPos * lRotation_twist);
placedPetalVolume.addPhysVolID("petal", phiIndex);
}
}
}
// top of the hierarchy
Volume motherVol = lcdd.pickMotherVolume(GenericTrackerEndcapWorld);
PlacedVolume placedEnvelopeVolume = motherVol.placeVolume(posnegEnvelopeVolume);
placedEnvelopeVolume.addPhysVolID("system", xmlDet.id());
//.........这里部分代码省略.........
示例9: dimensions
static DD4hep::Geometry::Ref_t createTkLayoutTrackerEndcap(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("sensitive"); // retrieve the type
sensDet.setType(sdTyp.typeStr()); // set for the whole detector
// definition of top volume
std::string detName = xmlDet.nameStr();
DetElement GenericTrackerEndcapWorld(detName, xmlDet.id());
// envelope volume with the max dimensions of tracker for visualization etc.
// contains both endcaps, in forward and in backwards direction
// the part between -z1 and z1 is subtracted from the envelope
DD4hep::Geometry::Tube posnegEnvelopeShape_add(dimensions.rmin(), dimensions.rmax(), dimensions.zmax());
// make the negative shape slighly larger in the radial direction
// to be sure that everything is subtracted between -z1 and z1
DD4hep::Geometry::Box posnegEnvelopeShape_subtract(
dimensions.rmax() * 1.001, dimensions.rmax() * 1.001, dimensions.zmin());
DD4hep::Geometry::SubtractionSolid posnegEnvelopeShape(posnegEnvelopeShape_add, posnegEnvelopeShape_subtract);
Volume posnegEnvelopeVolume(detName, posnegEnvelopeShape, lcdd.air());
posnegEnvelopeVolume.setVisAttributes(lcdd.invisible());
// envelope volume for one of the endcaps, either forward or backward
DD4hep::Geometry::Tube envelopeShape(
dimensions.rmin(), dimensions.rmax(), 0.5 * (dimensions.zmax() - dimensions.zmin()));
Volume envelopeVolume(detName, envelopeShape, lcdd.air());
envelopeVolume.setVisAttributes(lcdd.invisible());
Component xDiscs = xmlElement.child("discs");
Component xFirstDisc = xDiscs.child("discZPls");
Component xFirstDiscRings = xFirstDisc.child("rings");
// create disc volume
double discThickness = (xFirstDisc.zmax() - xFirstDisc.zmin());
DD4hep::Geometry::Tube discShape(dimensions.rmin(), dimensions.rmax(), 0.5 * discThickness);
Volume discVolume("disc", discShape, lcdd.air());
discVolume.setVisAttributes(lcdd.invisible());
// generate rings and place in discs
int moduleCounter = 0;
for (DD4hep::XML::Collection_t xRingColl(xFirstDiscRings, _U(ring)); nullptr != xRingColl; ++xRingColl) {
Component xRing = static_cast<Component>(xRingColl);
Component xRingModules = xRing.child("modules");
Component xModuleOdd = xRingModules.child("moduleOdd");
Component xModuleEven = xRingModules.child("moduleEven");
Component xModuleProperties = xRing.child("moduleProperties");
Component xModulePropertiesComp = xModuleProperties.child("components");
Component xSensorProperties = xRing.child("sensorProperties");
Volume moduleVolume("module",
DD4hep::Geometry::Trapezoid(0.5 * xModuleProperties.attr<double>("modWidthMin"),
0.5 * xModuleProperties.attr<double>("modWidthMax"),
0.5 * xModuleProperties.attr<double>("modThickness"),
0.5 * xModuleProperties.attr<double>("modThickness"),
0.5 * xSensorProperties.attr<double>("sensorLength")),
lcdd.material("Air"));
// place components in module
double integratedCompThickness = 0;
int componentCounter = 0;
for (DD4hep::XML::Collection_t xCompColl(xModulePropertiesComp, _U(component)); nullptr != xCompColl; ++xCompColl) {
Component xComp = static_cast<Component>(xCompColl);
Volume componentVolume("component",
DD4hep::Geometry::Trapezoid(0.5 * xModuleProperties.attr<double>("modWidthMin"),
0.5 * xModuleProperties.attr<double>("modWidthMax"),
0.5 * xComp.thickness(),
0.5 * xComp.thickness(),
0.5 * xSensorProperties.attr<double>("sensorLength")),
lcdd.material(xComp.materialStr()));
PlacedVolume placedComponentVolume = moduleVolume.placeVolume(
componentVolume,
DD4hep::Geometry::Position(
0, integratedCompThickness - 0.5 * xModuleProperties.attr<double>("modThickness"), 0));
placedComponentVolume.addPhysVolID("component", componentCounter);
componentVolume.setSensitiveDetector(sensDet);
integratedCompThickness += xComp.thickness();
++componentCounter;
}
unsigned int nPhi = xRing.attr<int>("nModules");
double lX, lY, lZ;
double phi = 0;
double phiTilt, thetaTilt;
for (unsigned int phiIndex = 0; phiIndex < nPhi; ++phiIndex) {
if (0 == phiIndex % 2) {
// the rotation for the odd module is already taken care
// of by the position in tklayout xml
phi = 2 * dd4hep::pi * static_cast<double>(phiIndex) / static_cast<double>(nPhi);
lX = xModuleEven.X();
lY = xModuleEven.Y();
lZ = xModuleEven.Z() - dimensions.zmin() - discThickness * 0.5;
phiTilt = xModuleEven.attr<double>("phiTilt");
thetaTilt = xModuleEven.attr<double>("thetaTilt");
} else {
lX = xModuleOdd.X();
lY = xModuleOdd.Y();
//.........这里部分代码省略.........
示例10: create_detector
static Ref_t create_detector(LCDD& lcdd, xml_h e, SensitiveDetector sens) {
xml_det_t x_det = e;
xml_dim_t dim = x_det.dimensions();
int det_id = x_det.id();
bool reflect = x_det.reflect(true);
string det_name = x_det.nameStr();
Material air = lcdd.air();
int numsides = dim.numsides();
double rmin = dim.rmin();
double rmax = dim.rmax()*std::cos(M_PI/numsides);
double zmin = dim.zmin();
Layering layering(x_det);
double totalThickness = layering.totalThickness();
Volume endcapVol("endcap",PolyhedraRegular(numsides,rmin,rmax,totalThickness),air);
DetElement endcap("endcap",det_id);
int l_num = 1;
int layerType = 0;
double layerZ = -totalThickness/2;
endcapVol.setAttributes(lcdd,x_det.regionStr(),x_det.limitsStr(),x_det.visStr());
for(xml_coll_t c(x_det,_U(layer)); c; ++c) {
xml_comp_t x_layer = c;
double l_thick = layering.layer(l_num-1)->thickness();
string l_name = _toString(layerType,"layer%d");
int l_repeat = x_layer.repeat();
Volume l_vol(l_name,PolyhedraRegular(numsides,rmin,rmax,l_thick),air);
vector<PlacedVolume> sensitives;
int s_num = 1;
double sliceZ = -l_thick/2;
for(xml_coll_t s(x_layer,_U(slice)); s; ++s) {
xml_comp_t x_slice = s;
string s_name = _toString(s_num,"slice%d");
double s_thick = x_slice.thickness();
Material s_mat = lcdd.material(x_slice.materialStr());
Volume s_vol(s_name,PolyhedraRegular(numsides,rmin,rmax,s_thick),s_mat);
s_vol.setVisAttributes(lcdd.visAttributes(x_slice.visStr()));
sliceZ += s_thick/2;
PlacedVolume s_phv = l_vol.placeVolume(s_vol,Position(0,0,sliceZ));
s_phv.addPhysVolID("slice",s_num);
if ( x_slice.isSensitive() ) {
sens.setType("calorimeter");
s_vol.setSensitiveDetector(sens);
sensitives.push_back(s_phv);
}
sliceZ += s_thick/2;
s_num++;
}
l_vol.setVisAttributes(lcdd.visAttributes(x_layer.visStr()));
if ( l_repeat <= 0 ) throw std::runtime_error(x_det.nameStr()+"> Invalid repeat value");
for(int j=0; j<l_repeat; ++j) {
string phys_lay = _toString(l_num,"layer%d");
layerZ += l_thick/2;
DetElement layer_elt(endcap, phys_lay, l_num);
PlacedVolume pv = endcapVol.placeVolume(l_vol,Position(0,0,layerZ));
pv.addPhysVolID("layer", l_num);
layer_elt.setPlacement(pv);
for(size_t ic=0; ic<sensitives.size(); ++ic) {
PlacedVolume sens_pv = sensitives[ic];
DetElement comp_elt(layer_elt,sens_pv.volume().name(),l_num);
comp_elt.setPlacement(sens_pv);
}
layerZ += l_thick/2;
++l_num;
}
++layerType;
}
double z_pos = zmin+totalThickness/2;
PlacedVolume pv;
// Reflect it.
if ( reflect ) {
Assembly assembly(det_name);
DetElement both_endcaps(det_name,det_id);
Volume motherVol = lcdd.pickMotherVolume(both_endcaps);
DetElement sdetA = endcap;
Ref_t(sdetA)->SetName((det_name+"_A").c_str());
DetElement sdetB = endcap.clone(det_name+"_B",x_det.id());
pv = assembly.placeVolume(endcapVol,Transform3D(RotationZYX(M_PI/numsides,0,0),
Position(0,0,z_pos)));
pv.addPhysVolID("barrel", 1);
sdetA.setPlacement(pv);
pv = assembly.placeVolume(endcapVol,Transform3D(RotationZYX(M_PI/numsides,M_PI,0),
Position(0,0,-z_pos)));
pv.addPhysVolID("barrel", 2);
sdetB.setPlacement(pv);
pv = motherVol.placeVolume(assembly);
pv.addPhysVolID("system", det_id);
both_endcaps.setPlacement(pv);
both_endcaps.add(sdetA);
both_endcaps.add(sdetB);
return both_endcaps;
}
Volume motherVol = lcdd.pickMotherVolume(endcap);
//.........这里部分代码省略.........
示例11: create_detector
//.........这里部分代码省略.........
if (imodule==0 && isensor==0) continue; // cellID we started with
newmodule = module_idx + imodule;
newsensor = sensor_idx + isensor;
//compute special case at the boundary
//general computation to allow (if necessary) more then adjacent neighbours (ie: +-2)
if (newmodule < 0) newmodule = nphi + newmodule;
if (newmodule >= nphi) newmodule = newmodule - nphi;
if (newsensor < 0 || newsensor >= nz) continue; //out of the stave
//encoding
encoder[lcio::LCTrackerCellID::module()] = newmodule;
encoder[lcio::LCTrackerCellID::sensor()] = newsensor;
neighbourSurfacesData->sameLayer[cellID].push_back(encoder.lowWord());
}
}
///////////////////
//FIXME
sensor_name = module_name + sensor_name;
DetElement sens_elt(lay_elt,sensor_name,sensor_idx);
// Module PhysicalVolume.
Transform3D tr(RotationZYX(0,((M_PI/2)-phic-phi_tilt),-M_PI/2),Position(x,y,sensor_z));
//FIXME
pv = lay_vol.placeVolume(m_env,tr);
pv.addPhysVolID(_U(module), module_idx);
pv.addPhysVolID(_U(sensor), sensor_idx);
sens_elt.setPlacement(pv);
for(size_t ic=0; ic<waferVols.size(); ++ic) {
// std::cout<<"Layer: "<<lay_id<<" phiIdx: "<<ii<<" zidx: "<<j<<" wafer idx: "<<ic<<std::endl;
PlacedVolume wafer_pv = waferVols[ic];
DetElement comp_elt(sens_elt,wafer_pv.volume().name(),sensor_idx);
comp_elt.setPlacement(wafer_pv);
///GET GEAR INFORMATION FROM FIRST "MODULE" IN Z AND phi
///NOTE WORKS ONLY FOR ONE WAFER
if (ii==0 && j==0 && ic==0){
Box mod_shape(m_env.solid()), comp_shape(wafer_pv.volume().solid());
const double* trans = comp_elt.placement()->GetMatrix()->GetTranslation();
double half_module_thickness = mod_shape->GetDZ();
double half_silicon_thickness = comp_shape->GetDZ();
double sensitive_z_position = trans[2];
double inner_thickness = half_module_thickness - sensitive_z_position;
thisLayer.distanceSupport = rc ;
thisLayer.offsetSupport = 0;
thisLayer.thicknessSupport = inner_thickness- half_silicon_thickness;
thisLayer.zHalfSupport = z0 + mod_shape->GetDY();
thisLayer.widthSupport = 2*mod_shape->GetDX();
thisLayer.distanceSensitive = rc+sensitive_z_position;
thisLayer.offsetSensitive = 0. ;
thisLayer.thicknessSensitive = 2*half_silicon_thickness;//Assembled along Z
示例12: dimensions
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();
//.........这里部分代码省略.........
示例13: create_element
static Ref_t create_element(Detector& theDetector, xml_h element, SensitiveDetector sens) {
xml_det_t x_det = element;
std::string name = x_det.nameStr();
DetElement sdet( name, x_det.id() ) ;
PlacedVolume pv;
// --- create an envelope volume and position it into the world ---------------------
Volume envelope = dd4hep::xml::createPlacedEnvelope( theDetector, element , sdet ) ;
if( theDetector.buildType() == BUILD_ENVELOPE ) return sdet ;
//-----------------------------------------------------------------------------------
// ----- read xml ----------------------
xml_dim_t dim = x_det.dimensions();
double inner_r = dim.rmin() ;
double outer_r = dim.rmax() ;
double z0 = dim.z0() ;
double z1 = dim.z1() ;
// double phi0 = dim.phi0() ;
unsigned nsides = dim.nsides();
double thick = z1 - z0 ;
double zpos = z0 + thick/2. ;
Material mat = envelope.material() ;
//--------------------------------------
sens.setType("tracker");
// base vectors for surfaces:
Vector3D u(0,1,0) ;
Vector3D v(1,0,0) ;
Vector3D n(0,0,1) ;
PolyhedraRegular phSolid ( nsides, inner_r, outer_r , 0.5*thick ) ;
//==============================================================================
DetElement fwdDE( sdet, name + std::string( "_fwd" ) , x_det.id() );
Volume phVol( name + std::string("_vol") , phSolid , mat ) ;
phVol.setSensitiveDetector(sens);
//fixme: the drawing of endcap surfaces in a polyhedral shape does not work right now
// -> set surface to be invisible for now
VolPlane surf( phVol,SurfaceType(SurfaceType::Sensitive,
SurfaceType::Invisible),
thick/4., thick/4., u,v,n ) ;
volSurfaceList( fwdDE )->push_back( surf ) ;
pv = envelope.placeVolume( phVol , Position( 0., 0., zpos ) ) ;
pv.addPhysVolID("layer", 0 ).addPhysVolID( "side" , +1 ) ;
fwdDE.setPlacement( pv ) ;
//==============================================================================
DetElement bwdDE( sdet, name + std::string( "_bwd" ) , x_det.id() );
// Volume phVol( name + std::string("_bwd") , phSolid , mat ) ;
phVol.setSensitiveDetector(sens);
volSurfaceList( bwdDE )->push_back( surf ) ;
pv = envelope.placeVolume( phVol , Position( 0., 0., -zpos ) ) ;
pv.addPhysVolID("layer", 0 ).addPhysVolID( "side" , -1 ) ;
bwdDE.setPlacement( pv ) ;
//--------------------------------------
return sdet ;
}
示例14: create_detector
//.........这里部分代码省略.........
double nRadiationLengths=0.;
double nInteractionLengths=0.;
double thickness_sum=0;
LayeredCalorimeterData::Layer caloLayer ;
for(dd4hep::xml::Collection_t collSlice(xmlLayer,_U(slice)); collSlice; ++collSlice) {
dd4hep::xml::Component compSlice = collSlice;
const double slice_thickness = compSlice.thickness();
const std::string sliceName = layer_name + dd4hep::xml::_toString(sliceID,"slice%d");
Material slice_material = theDetector.material(compSlice.materialStr());
Tube sliceBase(lcalInnerR,lcalOuterR,slice_thickness/2);
Volume slice_vol (sliceName,sliceBase,slice_material);
nRadiationLengths += slice_thickness/(2.*slice_material.radLength());
nInteractionLengths += slice_thickness/(2.*slice_material.intLength());
thickness_sum += slice_thickness/2;
if ( compSlice.isSensitive() ) {
#if DD4HEP_VERSION_GE( 0, 15 )
//Store "inner" quantities
caloLayer.inner_nRadiationLengths = nRadiationLengths;
caloLayer.inner_nInteractionLengths = nInteractionLengths;
caloLayer.inner_thickness = thickness_sum;
//Store scintillator thickness
caloLayer.sensitive_thickness = slice_thickness;
#endif
//Reset counters to measure "outside" quantitites
nRadiationLengths=0.;
nInteractionLengths=0.;
thickness_sum = 0.;
slice_vol.setSensitiveDetector(sens);
}
nRadiationLengths += slice_thickness/(2.*slice_material.radLength());
nInteractionLengths += slice_thickness/(2.*slice_material.intLength());
thickness_sum += slice_thickness/2;
slice_vol.setAttributes(theDetector,compSlice.regionStr(),compSlice.limitsStr(),compSlice.visStr());
layer_vol.placeVolume(slice_vol,Position(0,0,inThisLayerPosition+slice_thickness*0.5));
inThisLayerPosition += slice_thickness;
++sliceID;
}//For all slices in this layer
//-----------------------------------------------------------------------------------------
///Needs to be innermost face distance
caloLayer.distance = lcalCentreZ + referencePosition;
#if DD4HEP_VERSION_GE( 0, 15 )
caloLayer.outer_nRadiationLengths = nRadiationLengths;
caloLayer.outer_nInteractionLengths = nInteractionLengths;
caloLayer.outer_thickness = thickness_sum;
#endif
caloLayer.cellSize0 = LumiCal_cell_size ;
caloLayer.cellSize1 = LumiCal_cell_size ;
caloData->layers.push_back( caloLayer ) ;
//-----------------------------------------------------------------------------------------
//Why are we doing this for each layer, this just needs to be done once and then placed multiple times
//Do we need unique IDs for each piece?
layer_vol.setVisAttributes(theDetector,xmlLayer.visStr());
Position layer_pos(0,0,referencePosition+0.5*layerThickness);
referencePosition += layerThickness;
PlacedVolume pv = envelopeVol.placeVolume(layer_vol,layer_pos);
pv.addPhysVolID("layer",thisLayerId);
++thisLayerId;
}//for all layers
}// for all layer collections
const Position bcForwardPos (std::tan(0.5*fullCrossingAngle)*lcalCentreZ,0.0, lcalCentreZ);
const Position bcBackwardPos(std::tan(0.5*fullCrossingAngle)*lcalCentreZ,0.0,-lcalCentreZ);
const Rotation3D bcForwardRot ( RotationY(fullCrossingAngle*0.5 ) );
const Rotation3D bcBackwardRot( RotationZYX ( (M_PI), (M_PI-fullCrossingAngle*0.5), (0.0)));
PlacedVolume pv =
envelope.placeVolume(envelopeVol, Transform3D( bcForwardRot, bcForwardPos ) );
pv.addPhysVolID("barrel", 1);
lumiCalDE_1.setPlacement(pv);
PlacedVolume pv2 =
envelope.placeVolume(envelopeVol, Transform3D( bcBackwardRot, bcBackwardPos ) );
pv2.addPhysVolID("barrel", 2);
lumiCalDE_2.setPlacement(pv2);
sdet.addExtension< LayeredCalorimeterData >( caloData ) ;
return sdet;
}
示例15: create_detector
//.........这里部分代码省略.........
for(xml_coll_t ri(x_layer,_U(ring)); ri; ++ri) {
nrings++;
}
dd4hep::rec::ZDiskPetalsData::LayerLayout thisLayer;
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];
Box mod_shape(m_vol.solid());
if(r-mod_shape->GetDZ()<innerR)
innerR=r-mod_shape->GetDZ();
if(r+mod_shape->GetDZ()>outerR)
outerR=r+mod_shape->GetDZ();
sumZ+=zstart;
r=r+mod_shape->GetDY();
for(int k=0;k<nmodules;++k){
string m_base=_toString(l_id,"layer%d")+_toString(mod_num,"_module%d")+_toString(k,"_sensor%d");
double x=-r*std::cos(phi);
double y=-r*std::sin(phi);
DetElement module(sdet,m_base+"_pos",det_id);
pv=envelope.placeVolume(m_vol,Transform3D(RotationZYX(0,-M_PI/2-phi,-M_PI/2),Position(x,y,zstart+dz)));
pv.addPhysVolID("side",1).addPhysVolID("layer", l_id).addPhysVolID("module",mod_num).addPhysVolID("sensor",k);
module.setPlacement(pv);
for(size_t ic=0;ic<sensVols.size();++ic){
PlacedVolume sens_pv=sensVols[ic];
DetElement comp_elt(module,sens_pv.volume().name(),mod_num);
comp_elt.setPlacement(sens_pv);
}
if(reflect){
pv = envelope.placeVolume(m_vol,Transform3D(RotationZYX(M_PI,-M_PI/2-phi,-M_PI/2),Position(x,y,-zstart-dz)));
pv.addPhysVolID("side",-1).addPhysVolID("layer",l_id).addPhysVolID("module",mod_num).addPhysVolID("sensor",k);
DetElement r_module(sdet,m_base+"_neg",det_id);
r_module.setPlacement(pv);
for(size_t ic=0;ic<sensVols.size();++ic){
PlacedVolume sens_pv=sensVols[ic];
DetElement comp_elt(r_module,sens_pv.volume().name(),mod_num);
comp_elt.setPlacement(sens_pv);
}
}
//modified on comparison with TrackerEndcap_o2_v06_geo.cpp
//get cellID and fill map< cellID of surface, vector of cellID of neighbouring surfaces >
dd4hep::long64 cellID_reflect;
if(reflect){
encoder[lcio::LCTrackerCellID::side()]=lcio::ILDDetID::bwd;
encoder[lcio::LCTrackerCellID::layer()]=l_id;
encoder[lcio::LCTrackerCellID::module()]=mod_num;
encoder[lcio::LCTrackerCellID::sensor()]=k;
cellID_reflect=encoder.lowWord(); // 32 bits
}