Skip to content
Snippets Groups Projects
Commit 5d014eb7 authored by Markus Frank's avatar Markus Frank Committed by MarkusFrankATcernch
Browse files

Fix CMakeLists.txt to pick python executable from rather than invoking directly python

parent fbe4ced4
No related branches found
No related tags found
No related merge requests found
......@@ -61,7 +61,7 @@ ASSIMPReader::readShapes(const std::string& source, double unit_length) const
}
}
printout(ALWAYS,"ASSIMPReader","+++ Read %ld meshes from %s",
result.size(), source.c_str());
result.size(), source.c_str());
return result;
}
......@@ -95,48 +95,48 @@ ASSIMPReader::readVolumes(const std::string& source, double unit_length) const
shape->AddFacet(a,b,c);
}
if ( shape->GetNfacets() > 2 ) {
std::string nam;
Material mat;
VisAttr vis;
std::string nam;
Material mat;
VisAttr vis;
if ( scene->HasMaterials() ) {
aiMaterial* ai_mat = scene->mMaterials[mesh->mMaterialIndex];
nam = ai_mat->GetName().C_Str();
mat = detector.material(nam);
nam = ai_mat->GetName().C_Str();
mat = detector.material(nam);
}
if ( !mat.isValid() ) {
printout(ERROR, "ASSIMPReader",
"+++ %s: No material named '%s' FOUND. Will use Air. [Missing material]",
text, nam.c_str());
mat = detector.air();
}
::snprintf(text,sizeof(text),"tessellated_%ld", result.size());
text[sizeof(text)-1] = 0;
Volume vol(text, Solid(shape.ptr()), mat);
if ( mesh->HasVertexColors(0) ) {
const aiColor4D* col = mesh->mColors[0];
if ( col ) {
for( const auto& _v : detector.visAttributes() ) {
float a, r, g, b, eps = 0.05;
VisAttr(_v.second).argb(a, r, g, b);
if( std::abs(col->a-a) < eps && std::abs(col->r-r) < eps &&
std::abs(col->g-g) < eps && std::abs(col->b-b) < eps ) {
vis = _v.second;
break;
}
}
if ( !vis.isValid() ) {
::snprintf(text,sizeof(text),"vis_tessellated_%p", (void*)vol.ptr());
text[sizeof(text)-1] = 0;
vis = VisAttr(text);
vis.setColor(col->a,col->r,col->g,col->b);
detector.add(vis);
}
vol.setVisAttributes(vis);
}
}
printout(INFO,"ASSIMPReader",
"+++ %-17s Material: %-16s Viualization: %s",
vol.name(), mat.name(), vis.isValid() ? vis.name() : "NONE");
if ( !mat.isValid() ) {
printout(ERROR, "ASSIMPReader",
"+++ %s: No material named '%s' FOUND. Will use Air. [Missing material]",
text, nam.c_str());
mat = detector.air();
}
::snprintf(text,sizeof(text),"tessellated_%ld", result.size());
text[sizeof(text)-1] = 0;
Volume vol(text, Solid(shape.ptr()), mat);
if ( mesh->HasVertexColors(0) ) {
const aiColor4D* col = mesh->mColors[0];
if ( col ) {
for( const auto& _v : detector.visAttributes() ) {
float ca, cr, cg, cb, eps = 0.05;
VisAttr(_v.second).argb(ca, cr, cg, cb);
if( std::abs(col->a-ca) < eps && std::abs(col->r-cr) < eps &&
std::abs(col->g-cg) < eps && std::abs(col->b-cb) < eps ) {
vis = _v.second;
break;
}
}
if ( !vis.isValid() ) {
::snprintf(text,sizeof(text),"vis_tessellated_%p", (void*)vol.ptr());
text[sizeof(text)-1] = 0;
vis = VisAttr(text);
vis.setColor(col->a,col->r,col->g,col->b);
detector.add(vis);
}
vol.setVisAttributes(vis);
}
}
printout(INFO,"ASSIMPReader",
"+++ %-17s Material: %-16s Viualization: %s",
vol.name(), mat.name(), vis.isValid() ? vis.name() : "NONE");
result.emplace_back(std::unique_ptr<TGeoVolume>(vol.ptr()));
continue;
}
......@@ -144,6 +144,6 @@ ASSIMPReader::readVolumes(const std::string& source, double unit_length) const
}
}
printout(ALWAYS,"ASSIMPReader","+++ Read %ld meshes from %s",
result.size(), source.c_str());
result.size(), source.c_str());
return result;
}
......@@ -126,7 +126,6 @@ namespace {
return tes;
}
struct TessellateComposite {
TBuffer3D buffer { TBuffer3DTypes::kComposite };
std::vector<unique_ptr<TGeoTessellated> > meshes;
......@@ -137,7 +136,7 @@ namespace {
if (TGeoCompositeShape *shape = dynamic_cast<TGeoCompositeShape *>(s))
collect_composite(shape);
else
meshes.push_back(move(_tessellate_primitive(s->GetName(),s)));
meshes.emplace_back(_tessellate_primitive(s->GetName(),s));
}
void collect_composite(TGeoCompositeShape* sh) {
TGeoBoolNode* node = sh->GetBoolNode();
......@@ -242,9 +241,9 @@ int ASSIMPWriter::write(const std::string& file_name,
mesh->mName = node_name;
mesh->mMaterialIndex = index;
if ( v.visAttributes().isValid() ) {
float r = 0e0, g = 0e0, b = 0e0, a = 0e0;
v.visAttributes().argb(a, r, g, b);
mesh->mColors[0] = new aiColor4D(r, g, b, a);
float cr = 0e0, cg = 0e0, cb = 0e0, ca = 0e0;
v.visAttributes().argb(ca, cr, cg, cb);
mesh->mColors[0] = new aiColor4D(cr, cg, cb, ca);
}
mesh->mFaces = new aiFace[tes->GetNfacets()];
mesh->mVertices = new aiVector3D[num_vert];
......
......@@ -490,8 +490,7 @@ void Geant4ParticleHandler::rebaseSimulatedTracks(int ) {
// Processing by Geant4 to establish mother daughter relationships.
// == > use finalParticles map and NOT m_particleMap.
int equiv_id = -1;
for(iend=finalParticles.end(), i=finalParticles.begin(); i!=iend; ++i) {
Particle* p = (*i).second;
for( auto& [idx, p] : finalParticles ) {
if ( p->g4Parent > 0 ) {
TrackEquivalents::iterator iequ = equivalents.find(p->g4Parent);
if ( iequ != equivalents.end() ) {
......@@ -657,7 +656,7 @@ void Geant4ParticleHandler::checkConsistency() const {
int num_errors = 0;
/// First check the consistency of the particle map itself
for(const auto [idx, particle] : m_particleMap ) {
for(const auto& [idx, particle] : m_particleMap ) {
Geant4ParticleHandle p(particle);
PropertyMask mask(p->reason);
PropertyMask status(p->status);
......@@ -699,22 +698,15 @@ void Geant4ParticleHandler::checkConsistency() const {
}
void Geant4ParticleHandler::setVertexEndpointBit() {
ParticleMap& pm = m_particleMap;
ParticleMap::const_iterator iend, i;
for(iend=pm.end(), i=pm.begin(); i!=iend; ++i) {
Particle* p = (*i).second;
if( p->parents.empty() ) {
continue;
}
Geant4Particle *parent(pm[ *p->parents.begin() ]);
const double X( parent->vex - p->vsx );
const double Y( parent->vey - p->vsy );
const double Z( parent->vez - p->vsz );
if( sqrt(X*X + Y*Y + Z*Z) > m_minDistToParentVertex ){
PropertyMask(p->status).set(G4PARTICLE_SIM_PARENT_RADIATED);
for( auto& [idx, p] : m_particleMap ) {
if( !p->parents.empty() ) {
Geant4Particle *parent(m_particleMap[ *p->parents.begin() ]);
const double X( parent->vex - p->vsx );
const double Y( parent->vey - p->vsy );
const double Z( parent->vez - p->vsz );
if( sqrt(X*X + Y*Y + Z*Z) > m_minDistToParentVertex ){
PropertyMask(p->status).set(G4PARTICLE_SIM_PARENT_RADIATED);
}
}
}
}
......@@ -25,11 +25,7 @@ macro(dd4hep_to_parent_scope val)
endmacro(dd4hep_to_parent_scope)
#---------------------------------------------------------------------------------------------------
macro(dd4hep_use_python_executable)
#find_package(Python)
#if("${Python_EXECUTABLE}" STREQUAL "")
# set (Python_EXECUTABLE python)
#endif()
dd4hep_print("|++> Using python executable: ${Python_EXECUTABLE} -- ${PYTHON_EXECUTABLE}")
dd4hep_print("|++> Using python executable: ${Python_EXECUTABLE}")
endmacro(dd4hep_use_python_executable)
#---------------------------------------------------------------------------------------------------
# MACRO: dd4hep_set_compiler_flags
......@@ -692,13 +688,15 @@ macro(DD4HEP_SETUP_ROOT_TARGETS)
dd4hep_debug("D++> Python version used for building ROOT ${ROOT_PYTHON_VERSION}" )
dd4hep_debug("D++> Required python version ${REQUIRE_PYTHON_VERSION}")
FIND_PACKAGE(Python ${REQUIRE_PYTHON_VERSION} EXACT REQUIRED COMPONENTS Development)
FIND_PACKAGE(Python ${REQUIRE_PYTHON_VERSION} EXACT QUIET COMPONENTS Interpreter)
ELSE()
FIND_PACKAGE(Python COMPONENTS Development)
FIND_PACKAGE(Python QUIET COMPONENTS Interpreter)
ENDIF()
IF("${Python_EXECUTABLE}" STREQUAL "")
set (Python_EXECUTABLE python${Python_VERSION_MAJOR})
ENDIF()
dd4hep_print("|++> Using python executable: ${Python_EXECUTABLE} -- ${PYTHON_EXECUTABLE}")
dd4hep_print("|++> Using python executable: ${Python_EXECUTABLE}")
SET(DD4HEP_PYTHON_INSTALL_DIR lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment