예제 #1
0
void KVSpectroDetector::AddAbsorberLayer( TGeoVolume *vol, Bool_t active){
 	// Add an absorber layer to the detector made from the shape of the
 	// volume.
    // If active = kTRUE the layer is set active.

    TGeoMaterial* material = vol->GetMaterial();
    KVIonRangeTableMaterial* irmat = KVMaterial::GetRangeTable()->GetMaterial(material);
    if(!irmat){
        Warning("AddAbsorberLayer", "Unknown material %s/%s used in layer %s of detector %s",
                material->GetName(), material->GetTitle(), vol->GetName(), GetName());
        return;
    }
    TGeoBBox* sh = dynamic_cast<TGeoBBox*>(vol->GetShape());
    if(!sh) {
        Warning("AddAbsorberLayer", "Unknown shape class %s used in layer %s of detector %s",
                vol->GetShape()->ClassName(), vol->GetName(), GetName());
        return; // just in case - for now, all shapes derive from TGeoBBox...
    }
    Double_t width = 2.*sh->GetDZ(); // thickness in centimetres
    KVMaterial* absorber;
    if( irmat->IsGas() ){
        Double_t p = material->GetPressure();
        Double_t T = material->GetTemperature();
        absorber = new KVMaterial(irmat->GetType(), width, p, T);
    }
    else
        absorber = new KVMaterial(irmat->GetType(), width);
	KVDetector::AddAbsorber(absorber);
	ClearHits();
    if( active ) SetActiveLayer( GetListOfAbsorbers()->GetEntries()-1 );
}
예제 #2
0
void KVGeoImport::AddLayer(KVDetector *det, TGeoVolume *vol)
{
    // Add an absorber layer to the detector
    // Volumes representing 'active' layers in detectors must have names
    // which begin with "ACTIVE_"

    TString vnom = vol->GetName();
    // exclude dead zone layers
    if(vnom.BeginsWith("DEADZONE")) return;
    TGeoMaterial* material = vol->GetMaterial();
    KVIonRangeTableMaterial* irmat = fRangeTable->GetMaterial(material);
    if(!irmat){
        Warning("AddLayer", "Unknown material %s/%s used in layer %s of detector %s",
                material->GetName(), material->GetTitle(), vol->GetName(), det->GetName());
        return;
    }
    TGeoBBox* sh = dynamic_cast<TGeoBBox*>(vol->GetShape());
    if(!sh) {
        Warning("AddLayer", "Unknown shape class %s used in layer %s of detector %s",
                vol->GetShape()->ClassName(), vol->GetName(), det->GetName());
        return; // just in case - for now, all shapes derive from TGeoBBox...
    }
    Double_t width = 2.*sh->GetDZ(); // thickness in centimetres
    KVMaterial* absorber;
    if( irmat->IsGas() ){
        Double_t p = material->GetPressure();
        Double_t T = material->GetTemperature();
        absorber = new KVMaterial(irmat->GetType(), width, p, T);
    }
    else
        absorber = new KVMaterial(irmat->GetType(), width);
    det->AddAbsorber(absorber);
    if(vnom.BeginsWith("ACTIVE_")) det->SetActiveLayer( det->GetListOfAbsorbers()->GetEntries()-1 );
}
예제 #3
0
CLHEP::Hep3Vector envelopeDimensions(uint64_t aVolumeId) {
  DD4hep::Geometry::VolumeManager volMgr = DD4hep::Geometry::LCDD::getInstance().volumeManager();
  auto pvol = volMgr.lookupPlacement(aVolumeId);
  auto solid = pvol.volume().solid();
  // get the envelope of the shape
  TGeoBBox* box = (dynamic_cast<TGeoBBox*>(solid.ptr()));
  // get half-widths
  return CLHEP::Hep3Vector(box->GetDX(), box->GetDY(), box->GetDZ());
}
예제 #4
0
파일: BoxTrafos.C 프로젝트: vvolkl/DD4hep
int BoxTrafos()  {
  string xml = "file:";
  xml += gSystem->Getenv("DD4hepINSTALL");
  xml += "/examples/ClientTests/compact/BoxTrafos.xml";
  const char* argv[] = {xml.c_str(), "BUILD_DEFAULT", 0};

  gSystem->Load("libDDCore");
  LCDD& lcdd = LCDD::getInstance();
  lcdd.apply("DD4hepCompactLoader",2,(char**)argv);
  lcdd.apply("DD4hepGeometryDisplay",0,0);


  DetElement de = lcdd.detector("B3");
  PlacedVolume pv = de.placement();
  Volume vol = pv.volume();
  Solid solid = vol.solid();
  TGeoBBox* box = (TGeoBBox*)(solid.ptr());
  Position glob,loc, pos(-10,30,10);

  printf("\n++++  local->world:\n\n");

  loc = Position(-pos.x(),-pos.y(),-pos.z());
  local_to_world("origine",de,pos,loc);

  loc = Position();
  local_to_world("center",de,pos,loc);

  loc = Position(box->GetDX(),box->GetDY(),box->GetDZ());
  local_to_world("top edge",de,pos,loc);

  loc = Position(box->GetDX(),box->GetDY(),-box->GetDZ());
  local_to_world("top edge",de,pos,loc);

  loc = Position(-box->GetDX(),box->GetDY(),box->GetDZ());
  local_to_world("top edge",de,pos,loc);

  loc = Position(-box->GetDX(),box->GetDY(),-box->GetDZ());
  local_to_world("top edge",de,pos,loc);

  loc = Position(box->GetDX(),-box->GetDY(),box->GetDZ());
  local_to_world("bottom edge",de,pos,loc);

  loc = Position(box->GetDX(),-box->GetDY(),-box->GetDZ());
  local_to_world("bottom edge",de,pos,loc);

  loc = Position(-box->GetDX(),-box->GetDY(),box->GetDZ());
  local_to_world("bottom edge",de,pos,loc);

  loc = Position(-box->GetDX(),-box->GetDY(),-box->GetDZ());
  local_to_world("bottom edge",de,pos,loc);

  printf("\n++++  world->local:\n\n");

  glob = Position(0,0,0);
  world_to_local("world center",de,pos,glob);

  glob = Position(pos.x(),pos.y(),pos.z());
  world_to_local("position",de,pos,glob);

  glob = Position( box->GetDX()+pos.x(),  box->GetDY()+pos.y(),  box->GetDZ()+pos.z());
  world_to_local("top edge",de,pos,glob);

  glob = Position( box->GetDX()+pos.x(),  box->GetDY()+pos.y(), -box->GetDZ()+pos.z());
  world_to_local("top edge",de,pos,glob);

  glob = Position(-box->GetDX()+pos.x(),  box->GetDY()+pos.y(),  box->GetDZ()+pos.z());
  world_to_local("top edge",de,pos,glob);

  glob = Position(-box->GetDX()+pos.x(),  box->GetDY()+pos.y(), -box->GetDZ()+pos.z());
  world_to_local("top edge",de,pos,glob);

  glob = Position( box->GetDX()+pos.x(), -box->GetDY()+pos.y(),  box->GetDZ()+pos.z());
  world_to_local("bottom edge",de,pos,glob);

  glob = Position( box->GetDX()+pos.x(), -box->GetDY()+pos.y(), -box->GetDZ()+pos.z());
  world_to_local("bottom edge",de,pos,glob);

  glob = Position(-box->GetDX()+pos.x(), -box->GetDY()+pos.y(),  box->GetDZ()+pos.z());
  world_to_local("bottom edge",de,pos,glob);

  glob = Position(-box->GetDX()+pos.x(), -box->GetDY()+pos.y(), -box->GetDZ()+pos.z());
  world_to_local("bottom edge",de,pos,glob);

  return 1;
}