Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compile error on MacOS #1131

Merged
merged 4 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions DDCore/src/DetectorImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,10 @@ Handle<NamedObject> DetectorImp::getRefChild(const HandleMap& e, const string& n
ptr(const void* p) { other = p; }
};
std::string nam = "";
ptr m(&e), ref(this);
if ( ref.c > m.c && m.c < ref.c+sizeof(*this) ) nam = m.omap->name;
ptr mptr(&e), ref(this);
if ( ref.c > mptr.c && mptr.c < ref.c+sizeof(*this) ) {
nam = mptr.omap->name;
}
std::stringstream err;
err << "getRefChild: Failed to find child with name: " << name
<< " Map " << nam << " contains " << e.size() << " elements: {";
Expand Down
3 changes: 2 additions & 1 deletion DDCore/src/Primitives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ namespace {
/// Convert volumeID to string format (016X)
std::string dd4hep::volumeID(VolumeID vid) {
char text[32];
::snprintf(text,sizeof(text),"%016lx", vid);
unsigned long long id = (unsigned long long)vid;
::snprintf(text,sizeof(text), "%016llx", id);
return text;
}

Expand Down
18 changes: 9 additions & 9 deletions DDCore/src/plugins/DetectorChecksum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1220,19 +1220,19 @@ void DetectorChecksum::dump_detelements() const {
printout(ALWAYS, "DetectorChecksum", "+++ Detelement %-32s 0x%016lx%s",
de.name(), e.second.hash, debug > 2 ? ("\n"+e.second.data).c_str() : "");
if ( de.path() == "/world" ) {
PlacedVolume pv = de.placement();
Volume v = pv.volume();
Solid s = v.solid();
const auto& es = handleSolid(s);
const auto& ev = handleVolume(v);
const auto& ep = handlePlacement(pv);
PlacedVolume pv = de.placement();
Volume vol = pv.volume();
Solid sol = vol.solid();
const auto& es = handleSolid(sol);
const auto& ev = handleVolume(vol);
const auto& ep = handlePlacement(pv);

printout(ALWAYS, "DetectorChecksum", " Solid %-32s 0x%016lx%s",
s.name(), es.hash, debug > 2 ? ("\n"+es.data).c_str() : "");
sol.name(), es.hash, debug > 2 ? ("\n"+es.data).c_str() : "");
printout(ALWAYS, "DetectorChecksum", " Volume %-32s 0x%016lx%s",
v.name(), ev.hash, debug > 2 ? ("\n"+ev.data).c_str() : "");
vol.name(), ev.hash, debug > 2 ? ("\n"+ev.data).c_str() : "");
printout(ALWAYS, "DetectorChecksum", " Placement %-32s 0x%016lx%s",
pv.name(), ep.hash, debug > 2 ? ("\n"+ep.data).c_str() : "");
pv.name(), ep.hash, debug > 2 ? ("\n"+ep.data).c_str() : "");
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions DDDigi/include/DDDigi/DigiOutputAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ namespace dd4hep {
DigiOutputAction(const kernel_t& kernel, const std::string& nam);

/// Initialization callback
virtual void initialize();
virtual void initialize() override;

/// Finalization callback
virtual void finalize();
virtual void finalize() override;

/// Check for valid output stream
virtual bool have_output() const = 0;
Expand All @@ -89,7 +89,7 @@ namespace dd4hep {

/// Adopt new parallel worker acting on multiple containers
virtual void adopt_processor(DigiContainerProcessor* action,
const std::vector<std::string>& containers);
const std::vector<std::string>& containers) override;

/// Callback to read event output
virtual void execute(context_t& context) const override;
Expand Down
2 changes: 1 addition & 1 deletion DDDigi/io/Digi2ROOT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace dd4hep {
/// Standard constructor
Digi2ROOTWriter(const kernel_t& kernel, const std::string& nam);
/// Initialization callback
virtual void initialize();
virtual void initialize() override;
/// Check for valid output stream
virtual bool have_output() const override final;
/// Open new output stream
Expand Down
47 changes: 24 additions & 23 deletions DDDigi/plugins/DigiSegmentDepositPrint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,37 +33,38 @@ namespace dd4hep {
public:
/// Standard constructor
DigiSegmentDepositPrint(const DigiKernel& kernel, const std::string& nam)
: DigiContainerProcessor(kernel, nam) {}
: DigiContainerProcessor(kernel, nam) {}

/// Single container printout
template <typename T> void
print(const char* fmt, const T& cont, const predicate_t& predicate) const {
for( const auto& dep : cont ) {
if( predicate(dep) ) {
info(fmt, predicate.segmentation->split_id(dep.first), dep.first,
dep.second.history.hits.size(),
dep.second.history.particles.size(),
dep.second.deposit);
}
}
for( const auto& dep : cont ) {
if( predicate(dep) ) {
info(fmt, predicate.segmentation->split_id(dep.first), dep.first,
dep.second.history.hits.size(),
dep.second.history.particles.size(),
dep.second.deposit);
}
}
}

/// Main functional callback
virtual void execute(DigiContext& context, work_t& work, const predicate_t& predicate) const override final {
char format[256];
::snprintf(format, sizeof(format),
"%s[%s] %s-id: %%d [processor:%d] Cell: %%016lX mask: %016lX "
"hist:%%4ld hits %%4ld parts. "
"entries deposit: %%f",
context.event->id(),
predicate.segmentation->idspec.name(), predicate.segmentation->cname(),
predicate.id, predicate.segmentation->split_mask);
if ( const auto* m = work.get_input<DepositMapping>() )
print(format, *m, predicate);
else if ( const auto* v = work.get_input<DepositVector>() )
print(format, *v, predicate);
else
error("+++ Request to dump an invalid container %s", Key::key_name(work.input.key).c_str());
using ulonglong = unsigned long long;
char format[256];
::snprintf(format, sizeof(format),
"%s[%s] %s-id: %%d [processor:%d] Cell: %%016lX mask: %016llX "
"hist:%%4ld hits %%4ld parts. "
"entries deposit: %%f",
context.event->id(),
predicate.segmentation->idspec.name(), predicate.segmentation->cname(),
predicate.id, ulonglong(predicate.segmentation->split_mask));
if ( const auto* m = work.get_input<DepositMapping>() )
print(format, *m, predicate);
else if ( const auto* v = work.get_input<DepositVector>() )
print(format, *v, predicate);
else
error("+++ Request to dump an invalid container %s", Key::key_name(work.input.key).c_str());
}
};
} // End namespace digi
Expand Down
5 changes: 3 additions & 2 deletions DDG4/edm4hep/Geant4Output2EDM4hep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ void Geant4Output2EDM4hep::saveCollection(OutputContext<G4Event>& /*ctxt*/, G4VH
//-------------------------------------------------------------------
if( typeid( Geant4Tracker::Hit ) == coll->type().type() ){
// Create the hit container even if there are no entries!
auto& hits = m_trackerHits[colName] = {};
auto& hits = m_trackerHits[colName] = edm4hep::SimTrackerHitCollection();
for(unsigned i=0 ; i < nhits ; ++i){
auto sth = hits->create();
const Geant4Tracker::Hit* hit = coll->hit(i);
Expand Down Expand Up @@ -473,7 +473,8 @@ void Geant4Output2EDM4hep::saveCollection(OutputContext<G4Event>& /*ctxt*/, G4VH
Geant4Sensitive* sd = coll->sensitive();
int hit_creation_mode = sd->hitCreationMode();
// Create the hit container even if there are no entries!
auto& hits = m_calorimeterHits[colName] = {};
auto& hits = m_calorimeterHits[colName] =
std::make_pair(edm4hep::SimCalorimeterHitCollection(), edm4hep::CaloHitContributionCollection());
for(unsigned i=0 ; i < nhits ; ++i){
auto sch = hits.first->create();
const Geant4Calorimeter::Hit* hit = coll->hit(i);
Expand Down
26 changes: 13 additions & 13 deletions DDG4/src/Geant4Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ Geant4HitData::Contribution Geant4HitData::extractContribution(const G4Step* ste
(h.trackDef() == G4OpticalPhoton::OpticalPhotonDefinition()) ? h.trkEnergy() : h.totalEnergy();
const G4ThreeVector& pre = h.prePosG4();
const G4ThreeVector& post = h.postPosG4();
G4ThreeVector m = h.track->GetMomentum();
G4ThreeVector mom = h.track->GetMomentum();
double len = (post-pre).mag() ;
double pos[] = { (pre.x()+post.x())/2.0,(pre.y()+post.y())/2.0,(pre.z()+post.z())/2.0 };
double mom[] = { m.x(), m.y(), m.z() };
return Contribution(h.trkID(), h.trkPdgID(), deposit, h.trkTime(), len, pos, mom);
double position[] = { (pre.x()+post.x())/2.0,(pre.y()+post.y())/2.0,(pre.z()+post.z())/2.0 };
double momentum[] = { mom.x(), mom.y(), mom.z() };
return Contribution(h.trkID(), h.trkPdgID(), deposit, h.trkTime(), len, position, momentum);
}

/// Extract the MC contribution for a given hit from the step information with BirksLaw effect option
Expand All @@ -86,22 +86,22 @@ Geant4HitData::Contribution Geant4HitData::extractContribution(const G4Step* ste
(h.trackDef() == G4OpticalPhoton::OpticalPhotonDefinition()) ? h.trkEnergy() : h.totalEnergy();
const G4ThreeVector& pre = h.prePosG4();
const G4ThreeVector& post = h.postPosG4();
G4ThreeVector m = h.track->GetMomentum();
G4ThreeVector mom = h.track->GetMomentum();
double length = (post-pre).mag() ;
double mom[] = { m.x(), m.y(), m.z() };
double pos[] = { (pre.x()+post.x())/2.0,(pre.y()+post.y())/2.0,(pre.z()+post.z())/2.0 };
return Contribution(h.trkID(), h.trkPdgID(), deposit, h.trkTime(), length, pos, mom);
double momentum[] = { mom.x(), mom.y(), mom.z() };
double position[] = { (pre.x()+post.x())/2.0,(pre.y()+post.y())/2.0,(pre.z()+post.z())/2.0 };
return Contribution(h.trkID(), h.trkPdgID(), deposit, h.trkTime(), length, position, momentum);
}

/// Extract the MC contribution for a given hit from the fast simulation spot information
Geant4HitData::Contribution Geant4HitData::extractContribution(const Geant4FastSimSpot* spot) {
Geant4FastSimHandler h(spot);
const G4Track* t = spot->primary;
G4ThreeVector m = t->GetMomentum();
G4ThreeVector p = h.avgPositionG4();
double pos[] = { p.x(), p.y(), p.z() };
double mom[] = { m.x(), m.y(), m.z() };
return Contribution( h.trkID(), h.trkPdgID(), h.energy(), h. trkTime(), 0e0, pos, mom);
G4ThreeVector mom = t->GetMomentum();
G4ThreeVector pos = h.avgPositionG4();
double position[] = { pos.x(), pos.y(), pos.z() };
double momentum[] = { mom.x(), mom.y(), mom.z() };
return Contribution( h.trkID(), h.trkPdgID(), h.energy(), h. trkTime(), 0e0, position, momentum);
}

/// Default constructor
Expand Down
4 changes: 3 additions & 1 deletion cmake/DD4hepBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ endmacro(dd4hep_use_python_executable)
macro(dd4hep_set_compiler_flags)
include(CheckCXXCompilerFlag)

SET(COMPILER_FLAGS -Wshadow -Wformat-security -Wno-long-long -Wdeprecated -fdiagnostics-color=auto -Wall -Wextra -pedantic -Wno-psabi)
SET(COMPILER_FLAGS -Wshadow -Wformat-security -Wno-long-long -Wdeprecated -fdiagnostics-color=auto -Wall -Wextra -pedantic )

# AppleClang/Clang specific warning flags
if(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
set ( COMPILER_FLAGS ${COMPILER_FLAGS} -Winconsistent-missing-override -Wno-c++1z-extensions -Wheader-hygiene )
else()
set ( COMPILER_FLAGS ${COMPILER_FLAGS} -Wno-psabi)
endif()

FOREACH( FLAG ${COMPILER_FLAGS} )
Expand Down
8 changes: 4 additions & 4 deletions examples/ClientTests/src/MiniTel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ static Ref_t create_detector(Detector &description, xml_h e, SensitiveDetector s
Position env_dim_min(sensor_box.x()+epsilon, sensor_box.y()+epsilon, +100000.0);
Position env_dim_max(sensor_box.x()+epsilon, sensor_box.y()+epsilon, -100000.0);

for( xml_coll_t m(x_det, _U(module_position)); m; m++ ) {
xml_comp_t x_pos = m;
for( xml_coll_t mod(x_det, _U(module_position)); mod; mod++ ) {
xml_comp_t x_pos = mod;
if ( x_pos.z() > env_dim_max.z() ) {
env_dim_max.SetZ(x_pos.z());
printout(DEBUG,"MiniTel","Envelope z_max = %f",x_pos.z());
Expand Down Expand Up @@ -117,8 +117,8 @@ static Ref_t create_detector(Detector &description, xml_h e, SensitiveDetector s
pv = assembly.placeVolume(side_vol, side_pos);
pv.addPhysVolID("side",0);
side_det.setPlacement(pv);
for( xml_coll_t m(x_det, _U(module_position)); m; m++ ) {
xml_comp_t x_pos = m;
for( xml_coll_t mpos(x_det, _U(module_position)); mpos; mpos++ ) {
xml_comp_t x_pos = mpos;
DetElement module(side_det, _toString(count, "module_%d"), count);
pv = side_vol.placeVolume(sensor_vol,Transform3D(Position(x_pos.x(),x_pos.y(),x_pos.z())));
pv.addPhysVolID("module", ++count);
Expand Down
6 changes: 3 additions & 3 deletions examples/DDG4/src/PropertyTestAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ namespace {
try {
stringstream log;
log << "| " << setw(32) << left << tag << " ";
for(const auto& p : value)
log << setw(6) << left << p << " ";
for(const auto& val : value)
log << setw(6) << left << val << " ";
_print(log);
}
catch(const exception& e) {
Expand All @@ -186,7 +186,7 @@ namespace {
stringstream log;
log << "| " << setw(32) << left << tag << " ";
for(const auto& p : value)
log << setw(6) << left << p.first << " = " << setw(10) << left << p.second << " ";
log << setw(6) << left << p.first << " = " << setw(10) << left << p.second << " ";
_print(log);
}
catch(const exception& e) {
Expand Down