Skip to content

Commit

Permalink
Merge pull request #1 from MuonColliderSoft/master
Browse files Browse the repository at this point in the history
Updated to iLCSoft master. Fixed double thickness in the negative side of TrackerEndcapSupport
  • Loading branch information
bartosik-hep committed Dec 4, 2020
2 parents 26b58d3 + b9e1cb5 commit e8f7ba7
Show file tree
Hide file tree
Showing 13 changed files with 206 additions and 18 deletions.
48 changes: 48 additions & 0 deletions .gitignore
@@ -0,0 +1,48 @@
# Compiled Object files
*.slo
*.lo
*.o
*.obj
*.pyc

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# Build and install directories
bin/
lib/
/include
/python/
build/

# CMake config files
*Config.cmake
*ConfigVersion.cmake
Version.h

# emacs backup files
*~

*.DS_Store

10 changes: 8 additions & 2 deletions .travis.yml
Expand Up @@ -13,7 +13,7 @@ env:


before_install:
- wget --no-check-certificate https://ecsft.cern.ch/dist/cvmfs/cvmfs-release/cvmfs-release-latest_all.deb
- wget https://ecsft.cern.ch/dist/cvmfs/cvmfs-release/cvmfs-release-latest_all.deb
- sudo dpkg -i cvmfs-release-latest_all.deb
- sudo apt-get update
- sudo apt-get install cvmfs cvmfs-config-default
Expand All @@ -24,8 +24,14 @@ before_install:
- sudo /etc/init.d/autofs stop
- sudo cvmfs_config setup
- sudo mkdir -p /cvmfs/clicdp.cern.ch
- sudo mkdir -p /cvmfs/geant4.cern.ch
- sudo mkdir -p /cvmfs/sft.cern.ch
- sudo mount -t cvmfs clicdp.cern.ch /cvmfs/clicdp.cern.ch
- sudo mount -t cvmfs geant4.cern.ch /cvmfs/geant4.cern.ch
- sudo mount -t cvmfs sft.cern.ch /cvmfs/sft.cern.ch
- ls /cvmfs/clicdp.cern.ch
- ls /cvmfs/geant4.cern.ch
- ls /cvmfs/sft.cern.ch/lcg

# command to install dependencies
install:
Expand All @@ -42,7 +48,7 @@ install:

# command to run tests
script:
- docker run -it --name CI_container -v $PKGDIR:/Package -e COMPILER=$COMPILER -v /cvmfs/clicdp.cern.ch:/cvmfs/clicdp.cern.ch -d clicdp/slc6-build /bin/bash
- docker run -it --name CI_container -v $PKGDIR:/Package -e COMPILER=$COMPILER -v /cvmfs:/cvmfs -d clicdp/cc7-lcg /bin/bash
- if [[ "${TRAVIS_EVENT_TYPE}" == "cron" && "${COMPILER}" == "gcc" ]];
then docker exec -it CI_container /bin/bash -c "./Package/.travis-ci.d/coverity_scan.sh";
elif [[ "${TRAVIS_EVENT_TYPE}" == "cron" && "${COMPILER}" == "llvm" ]];
Expand Down
8 changes: 7 additions & 1 deletion CMakeLists.txt
Expand Up @@ -9,7 +9,7 @@ project(${PackageName})
# project version
SET( ${PackageName}_VERSION_MAJOR 0 )
SET( ${PackageName}_VERSION_MINOR 16 )
SET( ${PackageName}_VERSION_PATCH 5 )
SET( ${PackageName}_VERSION_PATCH 6 )

SET( ${PackageName}_VERSION "${${PackageName}_VERSION_MAJOR}.${${PackageName}_VERSION_MINOR}" )
SET( ${PackageName}_SOVERSION "${${PackageName}_VERSION_MAJOR}.${${PackageName}_VERSION_MINOR}" )
Expand All @@ -33,6 +33,7 @@ ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

option(BUILD_TESTING "Enable and build tests" ON)
option(CMAKE_MACOSX_RPATH "Build with rpath on macos" ON)
option(INSTALL_COMPACT_FILES "Copy compact files to install area" OFF)

#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Expand Down Expand Up @@ -119,3 +120,8 @@ FILE(GLOB hfiles "ILD/include/*.h")
INSTALL(FILES ${hfiles}
DESTINATION include/${PackageName}
)

#--- install compact files------------------------------
if(INSTALL_COMPACT_FILES)
INSTALL(DIRECTORY CaloTB CLIC FCalTB FCCee ILD fieldmaps SiD DESTINATION share/lcgeo/compact/ )
endif()
2 changes: 0 additions & 2 deletions detector/calorimeter/Hcal_BarrelSD_v00.cpp
Expand Up @@ -49,8 +49,6 @@ static Ref_t create_detector(Detector& theDetector, xml_h element, SensitiveDete

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

PlacedVolume pv;

sens.setType("calorimeter");


Expand Down
2 changes: 1 addition & 1 deletion detector/calorimeter/SEcal06_Helpers.cpp
Expand Up @@ -473,7 +473,7 @@ void SEcal06_Helpers::makeModule( dd4hep::Volume & mod_vol, // the volume we'll
multi_refSlices.push_back( keyVal0 );
multi_refSlices.push_back( keyVal1 );

} catch( std::runtime_error) {
} catch(const std::runtime_error &) {
throw lcgeo::GeometryException( "SEcal06_Helper: Error: MultiSegmentation specified but no "
" <subsegmentation key="" value0="" value1=""/> element defined for detector ! " ) ;
}
Expand Down
2 changes: 1 addition & 1 deletion detector/calorimeter/SHcalSc04_Barrel_v04.cpp
Expand Up @@ -229,7 +229,7 @@ static Ref_t create_detector(Detector& theDetector, xml_h element, SensitiveDete
}


} catch( std::runtime_error) {
} catch(const std::runtime_error &) {
throw lcgeo::GeometryException( "SHcalSc04_Barrel: Error: MultiSegmentation specified but no "
" <subsegmentation key="" value=""/> element defined for detector ! " ) ;
}
Expand Down
2 changes: 1 addition & 1 deletion detector/calorimeter/SHcalSc04_EndcapRing_v01.cpp
Expand Up @@ -140,7 +140,7 @@ static Ref_t create_detector(Detector& theDetector, xml_h element, SensitiveDete
}


} catch( std::runtime_error) {
} catch(const std::runtime_error &) {
throw lcgeo::GeometryException( "SHcalSc04_Endcaps_v01: Error: MultiSegmentation specified but no "
" <subsegmentation key="" value=""/> element defined for detector ! " ) ;
}
Expand Down
2 changes: 1 addition & 1 deletion detector/calorimeter/SHcalSc04_Endcaps_v01.cpp
Expand Up @@ -157,7 +157,7 @@ static Ref_t create_detector(Detector& theDetector, xml_h element, SensitiveDete
sensitive_slice_number = keyVal ;
}

} catch( std::runtime_error) {
} catch(const std::runtime_error &) {
throw lcgeo::GeometryException( "SHcalSc04_Endcaps_v01: Error: MultiSegmentation specified but no "
" <subsegmentation key="" value=""/> element defined for detector ! " ) ;
}
Expand Down
20 changes: 13 additions & 7 deletions detector/calorimeter/Yoke05_Barrel.cpp
Expand Up @@ -230,6 +230,10 @@ static Ref_t create_detector(Detector& theDetector, xml_h element, SensitiveDete
double nRadiationLengths=0.;
double nInteractionLengths=0.;
double thickness_sum=0;

// Placements of individual layers.
// Key is the prefix of the detector elements name created after this nested loop (see below)
std::vector<std::pair<std::string,dd4hep::PlacedVolume>> plvec {} ;

int l_num = 1;
for(xml_coll_t li(x_det,_U(layer)); li; ++li) {
Expand Down Expand Up @@ -309,7 +313,6 @@ static Ref_t create_detector(Detector& theDetector, xml_h element, SensitiveDete

Box s_box(slab_dim_x,slab_dim_y,slab_dim_z);
Volume s_vol(det_name+"_"+l_name+"_"+s_name,s_box,slice_material);
DetElement slice(layer,s_name,det_id);

nRadiationLengths += s_thickness/(2.*slice_material.radLength());
nInteractionLengths += s_thickness/(2.*slice_material.intLength());
Expand Down Expand Up @@ -342,8 +345,7 @@ static Ref_t create_detector(Detector& theDetector, xml_h element, SensitiveDete
s_pos_y += s_thickness/2.;

Position s_pos(0,s_pos_y,0); // Position of the layer.
PlacedVolume s_phv = ChamberLog.placeVolume(s_vol,s_pos);
slice.setPlacement(s_phv);
ChamberLog.placeVolume(s_vol,s_pos);

// Increment x position for next slice.
s_pos_y += s_thickness/2.;
Expand Down Expand Up @@ -378,9 +380,7 @@ static Ref_t create_detector(Detector& theDetector, xml_h element, SensitiveDete
layer_phv.addPhysVolID("layer", l_num).addPhysVolID("stave",j+1);
string stave_name = _toString(j+1,"stave%d");
string stave_layer_name = stave_name+_toString(l_num,"layer%d");
DetElement stave(stave_layer_name,det_id);;
stave.setPlacement(layer_phv);
sdet.add(stave);
plvec.push_back({stave_layer_name,layer_phv});
phirot -= M_PI/symmetry*2.0;

}
Expand Down Expand Up @@ -415,9 +415,15 @@ static Ref_t create_detector(Detector& theDetector, xml_h element, SensitiveDete
m_phv.addPhysVolID("tower", 1);// Not used
string m_name = _toString(module_id,"module%d");
DetElement sd (m_name,det_id);

for( auto deelts : plvec ) {
std::string deteltname = deelts.first +_toString(module_id,"module%d");
DetElement layerDet (sd, deteltname, det_id);
layerDet.setPlacement( deelts.second ) ;
}

sd.setPlacement(m_phv);
sdet.add(sd);

}

sdet.addExtension< LayeredCalorimeterData >( caloData ) ;
Expand Down
115 changes: 115 additions & 0 deletions detector/other/TrackerEndcapSupport_o1_v02.cpp
@@ -0,0 +1,115 @@
#include "OtherDetectorHelpers.h"

#include "DD4hep/DetFactoryHelper.h"
#include "DD4hep/DD4hepUnits.h"
#include "DDRec/DetectorData.h"
#include "DDRec/Surface.h"
#include "XML/Utilities.h"
#include "XMLHandlerDB.h"
#include <cmath>
#include <map>
#include <string>

using namespace std;

using dd4hep::Assembly;
using dd4hep::ConeSegment;
using dd4hep::Material;
using dd4hep::PlacedVolume;
using dd4hep::Position;
using dd4hep::Ref_t;
using dd4hep::RotateY;
using dd4hep::RotationY;
using dd4hep::Solid;
using dd4hep::SubtractionSolid;
using dd4hep::Transform3D;
using dd4hep::Tube;
using dd4hep::Volume;
using dd4hep::Detector;
using dd4hep::SensitiveDetector;
using dd4hep::DetElement;
using dd4hep::BUILD_ENVELOPE;
using dd4hep::_toString;

using dd4hep::rec::Vector3D;
using dd4hep::rec::VolSurfaceHandle;
using dd4hep::rec::VolPlaneImpl;
using dd4hep::rec::SurfaceType;
using dd4hep::rec::volSurfaceList;

static Ref_t create_detector(Detector& theDetector, xml_h e, SensitiveDetector)
{
xml_det_t x_det = e;
int det_id = x_det.id();
string det_name = x_det.nameStr();
DetElement sdet(det_name, det_id);
string side_name[2] = {"_pos", "_neg"};
double side_sign[2] = {+1., -1.};

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

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

Material air = theDetector.air();
bool reflect = x_det.reflect();

PlacedVolume pv;
int l_num = 0;

for (xml_coll_t i(x_det, _U(layer)); i; ++i, ++l_num) {
xml_comp_t x_layer = i;
string l_nam = det_name + _toString(l_num, "_layer%d");
double zmin = x_layer.inner_z();
double rmin = x_layer.inner_r();
double rmax = x_layer.outer_r();
double z = zmin, layerWidth = 0.;
int s_num = 0;

for (xml_coll_t j(x_layer, _U(slice)); j; ++j) {
double thickness = xml_comp_t(j).thickness();
layerWidth += thickness;
}
Tube l_tub(rmin, rmax, layerWidth, 2 * M_PI);
Volume l_vol(l_nam, l_tub, air);
l_vol.setVisAttributes(theDetector, x_layer.visStr());

// Creating the original and reflected sides in a loop
for (size_t side=0; side < 2; ++side) {
// Stopping after the original if reflection is disabled
if (side > 0 && !reflect) break;

DetElement layer(sdet, l_nam + side_name[side], l_num);

for (xml_coll_t j(x_layer, _U(slice)); j; ++j, ++s_num) {
xml_comp_t x_slice = j;
double thick = x_slice.thickness();
Material mat = theDetector.material(x_slice.materialStr());
string s_nam = l_nam + _toString(s_num, "_slice%d");
Volume s_vol(s_nam, Tube(rmin, rmax, thick/2.), mat); //NN: Tube is a MyConeSeg, takes half thickness

//Add surface to the support
double mid_r = 0.5 * ( rmin + rmax ) ;
Vector3D ocyl( 0., mid_r , 0. );
Vector3D u(1.,0.,0.), v(0.,1.,0.), n(0.,0.,1.);

VolSurfaceHandle<VolPlaneImpl> cylSurf( s_vol , SurfaceType( SurfaceType::Helper ) , 0.5*thick , 0.5*thick , u, v, side_sign[side]*n, side_sign[side]*ocyl );
volSurfaceList( layer )->push_back( cylSurf );


s_vol.setAttributes(theDetector, x_slice.regionStr(), x_slice.limitsStr(), x_slice.visStr());
pv = l_vol.placeVolume(s_vol, Position(0, 0, side_sign[side]*(z - zmin - layerWidth / 2 + thick / 2)));
pv.addPhysVolID("sensor", s_num);
}

pv = envelope.placeVolume(l_vol, Position(0, 0, side_sign[side]*(zmin + layerWidth / 2.)));
pv.addPhysVolID("layer", l_num);
pv.addPhysVolID("barrel", side+1);
layer.setPlacement(pv);
}
}


return sdet;
}

DECLARE_DETELEMENT(TrackerEndcapSupport_o1_v02, create_detector)
2 changes: 1 addition & 1 deletion detector/tracker/ZPlanarTracker_geo.cpp
Expand Up @@ -79,7 +79,7 @@ static Ref_t create_element(Detector& theDetector, xml_h e, SensitiveDetector se
try {
isStripDetector = x_det.attr<bool>( _Unicode(isStripDetector) ) ;

} catch(std::runtime_error ){}
} catch(const std::runtime_error &){}

//========= loop over layer elements in xml ======================================

Expand Down
9 changes: 9 additions & 0 deletions doc/ReleaseNotes.md
@@ -1,3 +1,12 @@
# v00-16-06

* 2020-03-02 Remi Ete ([PR#241](https://github.com/iLCSoft/lcgeo/pull/241))
- `Yoke05_Barrel` driver:
- Removed slices DetElement construction
- Moved layer DetElement construction to external loop: fixes the DetElement hierarchy.
This fixes the access to the DetElement given a CellID in our reconstruction.
Related issue: https://github.com/iLCSoft/ILDConfig/issues/88

# v00-16-05

* 2019-12-11 Ete Remi ([PR#240](https://github.com/iLCSoft/lcgeo/pull/240))
Expand Down
2 changes: 1 addition & 1 deletion example/lcio_particle_gun.py
Expand Up @@ -28,7 +28,7 @@

wrt.open( outfile , EVENT.LCIO.WRITE_NEW )

print " opened outfile: " , outfile
print( " opened outfile: " , outfile )

random.seed()

Expand Down

0 comments on commit e8f7ba7

Please sign in to comment.