From 00fab6e938c033771b8cfb852c6c47b14db0b079 Mon Sep 17 00:00:00 2001 From: Markus Frank Date: Wed, 7 Feb 2024 18:34:56 +0100 Subject: [PATCH 01/14] Implement CONST properties to optical sufaces. (Requires new release of ROOT) --- DDCore/src/plugins/Compact2Objects.cpp | 133 ++++-- DDG4/src/Geant4Converter.cpp | 438 ++++++++++-------- .../compact/ReadOpticalSurfaces.xml | 2 + 3 files changed, 332 insertions(+), 241 deletions(-) diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp index 20a286f2b..a9bdc3c98 100644 --- a/DDCore/src/plugins/Compact2Objects.cpp +++ b/DDCore/src/plugins/Compact2Objects.cpp @@ -274,8 +274,8 @@ static long load_Compact(Detector& description, xml_h element) { DECLARE_XML_DOC_READER(lccdd,load_Compact) DECLARE_XML_DOC_READER(compact,load_Compact) - // We create out own type to avoid a class over the extension types - // attached to the Detector as a set of std::string is common. +// We create out own type to avoid a class over the extension types +// attached to the Detector as a set of std::string is common. class ProcessedFilesSet: public std::set {}; /// Check whether a XML file was already processed @@ -551,7 +551,7 @@ template <> void Converter::operator()(xml_h e) const { } else if ( p.hasAttr(_U(option)) ) { string prop_nam = p.attr(_U(name)); - string prop_typ = p.attr(_U(option)); + string prop_typ = p.attr(_U(option)); mat->AddConstProperty(prop_nam.c_str(), prop_typ.c_str()); printout(s_debug.materials ? ALWAYS : DEBUG, "Compact", "++ material %-16s add constant property: %s -> %s.", @@ -746,7 +746,11 @@ template <> void Converter::operator()(xml_h e) const { * */ template <> void Converter::operator()(xml_h element) const { - xml_elt_t e = element; + xml_elt_t e = element; + TGeoManager& mgr = description.manager(); + std::string sname = e.attr(_U(name)); + string ref, pname; + // Defaults from Geant4 OpticalSurface::EModel model = OpticalSurface::Model::kMglisur; OpticalSurface::EFinish finish = OpticalSurface::Finish::kFpolished; @@ -756,23 +760,25 @@ template <> void Converter::operator()(xml_h element) const { if ( e.hasAttr(_U(model)) ) model = OpticalSurface::stringToModel(e.attr(_U(model))); if ( e.hasAttr(_U(finish)) ) finish = OpticalSurface::stringToFinish(e.attr(_U(finish))); if ( e.hasAttr(_U(value)) ) value = e.attr(_U(value)); - OpticalSurface surf(description, e.attr(_U(name)), model, finish, type, value); + OpticalSurface surf(description, sname, model, finish, type, value); if ( s_debug.surface ) { printout(ALWAYS,"Compact","+++ Reading optical surface %s Typ:%d model:%d finish:%d value: %.3f", - e.attr(_U(name)).c_str(), int(type), int(model), int(finish), value); + sname.c_str(), int(type), int(model), int(finish), value); } for (xml_coll_t props(e, _U(property)); props; ++props) { + pname = props.attr(_U(name)); if ( props.hasAttr(_U(ref)) ) { - surf->AddProperty(props.attr(_U(name)).c_str(), props.attr(_U(ref)).c_str()); + bool err = kFALSE; + ref = props.attr(_U(ref)); + mgr.GetProperty(ref.c_str(), &err); /// Check existence + surf->AddProperty(pname.c_str(), ref.c_str()); if ( s_debug.surface ) { - printout(ALWAYS,"Compact","+++ \t\t Property: %s -> %s", - props.attr(_U(name)).c_str(), props.attr(_U(ref)).c_str()); + printout(ALWAYS,"Compact","+++ \t\t Property: %s -> %s", pname.c_str(), ref.c_str()); } continue; } - size_t cols = props.attr(_U(coldim)); - string nam = props.attr(_U(name)); - xml_attr_t opt = props.attr_nothrow(_U(option)); + size_t cols = props.attr(_U(coldim)); + xml_attr_t opt = props.attr_nothrow(_U(option)); stringstream str(props.attr(_U(values))), str_nam; string val; vector values; @@ -788,14 +794,53 @@ template <> void Converter::operator()(xml_h element) const { string tit = e.attr(opt); str_nam << tit << "|"; } - str_nam << nam << "__" << (void*)table; + str_nam << pname << "__" << (void*)table; table->SetName(str_nam.str().c_str()); - table->SetTitle(nam.c_str()); + table->SetTitle(pname.c_str()); for (size_t i=0, n=values.size(); iSet(i/cols, i%cols, values[i]); - surf->AddProperty(nam.c_str(), table->GetName()); + surf->AddProperty(pname.c_str(), table->GetName()); description.manager().AddGDMLMatrix(table); } +#if ROOT_VERSION_CODE >= ROOT_VERSION(6,31,1) + /// In case there were constant surface properties specified: convert them here + for(xml_coll_t properties(e, _U(constant)); properties; ++properties) { + xml_elt_t p = properties; + pname = p.attr(_U(name)); + if ( p.hasAttr(_U(ref)) ) { + bool err = kFALSE; + ref = p.attr(_U(ref)); + mgr.GetProperty(ref.c_str(), &err); /// Check existence + if ( err == kFALSE ) { + surf->AddConstProperty(pname.c_str(), ref.c_str()); + printout(s_debug.surface ? ALWAYS : DEBUG, "Compact", + "++ surface %-16s add constant property: %s -> %s.", + surf->GetName(), pname.c_str(), ref.c_str()); + continue; + } + // ERROR + throw_print("Compact2Objects[ERROR]: Converting surface: " + sname + + " ConstProperty missing in TGeoManager: " + ref); + } + else if ( p.hasAttr(_U(value)) ) { + stringstream str; + str << pname << "_" << (void*)surf.ptr(); + ref = str.str(); + mgr.AddProperty(ref.c_str(), p.attr(_U(value))); /// Check existence + surf->AddConstProperty(pname.c_str(), ref.c_str()); + printout(s_debug.surface ? ALWAYS : DEBUG, "Compact", + "++ surface %-16s add constant property: %s -> %s.", + surf->GetName(), pname.c_str(), ref.c_str()); + } + else if ( p.hasAttr(_U(option)) ) { + string ptyp = p.attr(_U(option)); + surf->AddConstProperty(pname.c_str(), ptyp.c_str()); + printout(s_debug.surface ? ALWAYS : DEBUG, "Compact", + "++ surface %-16s add constant property: %s -> %s.", + surf->GetName(), pname.c_str(), ptyp.c_str()); + } + } +#endif } /** Convert compact constant property (Material properties stored in TGeoManager) @@ -854,9 +899,9 @@ template <> void Converter::operator()(xml_h e) const { /// Create table and register table xml_attr_t opt = e.attr_nothrow(_U(option)); PropertyTable tab(description, - e.attr(_U(name)), - opt ? e.attr(opt).c_str() : "", - vals.size()/cols, cols); + e.attr(_U(name)), + opt ? e.attr(opt).c_str() : "", + vals.size()/cols, cols); for( size_t i=0, n=vals.size(); i < n; ++i ) tab->Set(i/cols, i%cols, vals[i]); //if ( s_debug.matrix ) tab->Print(); @@ -889,7 +934,7 @@ template <> void Converter::operator()(xml_h e) const { auto refName = e.attr(_U(ref)); const auto refAttr = description.visAttributes(refName); if(!refAttr.isValid() ) { - throw runtime_error("reference VisAttr " + refName + " does not exist"); + throw runtime_error("reference VisAttr " + refName + " does not exist"); } // Just copying things manually. // I think a handle's copy constructor/assignment would reuse the underlying pointer... maybe? @@ -1156,9 +1201,9 @@ template <> void Converter::operator()(xml_h e) const { limit.value = _multiply(limit.content, limit.unit); ls.addLimit(limit); printout(s_debug.limits ? ALWAYS : DEBUG, "Compact", - "++ %s: add %-6s: [%s] = %s [%s] = %f", - ls.name(), limit.name.c_str(), limit.particles.c_str(), - limit.content.c_str(), limit.unit.c_str(), limit.value); + "++ %s: add %-6s: [%s] = %s [%s] = %f", + ls.name(), limit.name.c_str(), limit.particles.c_str(), + limit.content.c_str(), limit.unit.c_str(), limit.value); } limit.name = "cut"; for (xml_coll_t c(e, _U(cut)); c; ++c) { @@ -1168,9 +1213,9 @@ template <> void Converter::operator()(xml_h e) const { limit.value = _multiply(limit.content, limit.unit); ls.addCut(limit); printout(s_debug.limits ? ALWAYS : DEBUG, "Compact", - "++ %s: add %-6s: [%s] = %s [%s] = %f", - ls.name(), limit.name.c_str(), limit.particles.c_str(), - limit.content.c_str(), limit.unit.c_str(), limit.value); + "++ %s: add %-6s: [%s] = %s [%s] = %f", + ls.name(), limit.name.c_str(), limit.particles.c_str(), + limit.content.c_str(), limit.unit.c_str(), limit.value); } description.addLimitSet(ls); } @@ -1509,7 +1554,7 @@ template <> void Converter::operator()(xml_h element) const { } else if ( !world_vol ) { except("Compact", "++ Logical error: " - "You cannot configure the world volume before it is created and not giving creation instructions."); + "You cannot configure the world volume before it is created and not giving creation instructions."); } } // Delegate further configuration o0f the world volume to the xml utilities: @@ -1742,23 +1787,23 @@ template <> void Converter::operator()(xml_h element) const { } #ifdef _WIN32 - template Converter; - template Converter; - template Converter; - template Converter; - template Converter; - template Converter; - template Converter; - template Converter; - template Converter; - template Converter; - template Converter; - template Converter; - template Converter; - template Converter; - template Converter; - template Converter
; - template Converter; - template Converter; +template Converter; +template Converter; +template Converter; +template Converter; +template Converter; +template Converter; +template Converter; +template Converter; +template Converter; +template Converter; +template Converter; +template Converter; +template Converter; +template Converter; +template Converter; +template Converter
; +template Converter; +template Converter; #endif diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp index 5766b7e49..294d21343 100644 --- a/DDG4/src/Geant4Converter.cpp +++ b/DDG4/src/Geant4Converter.cpp @@ -12,13 +12,14 @@ //========================================================================== // Framework include files -#include -#include #include #include +#include #include +#include #include #include +#include #include #include #include @@ -27,6 +28,7 @@ #include #include #include +#include #include #include "Geant4ShapeConverter.h" @@ -77,24 +79,60 @@ #include namespace units = dd4hep; -using namespace dd4hep::detail; using namespace dd4hep::sim; using namespace dd4hep; using namespace std; -#include -#include +namespace { -static constexpr const double CM_2_MM = (CLHEP::centimeter/dd4hep::centimeter); -static constexpr const char* GEANT4_TAG_IGNORE = "Geant4-ignore"; -static constexpr const char* GEANT4_TAG_PLUGIN = "Geant4-plugin"; -static constexpr const char* GEANT4_TAG_BIRKSCONSTANT = "BirksConstant"; -static constexpr const char* GEANT4_TAG_MEE = "MeanExcitationEnergy"; -static constexpr const char* GEANT4_TAG_ENE_PER_ION_PAIR = "MeanEnergyPerIonPair"; + static constexpr const double CM_2_MM = (CLHEP::centimeter/dd4hep::centimeter); + static constexpr const char* GEANT4_TAG_IGNORE = "Geant4-ignore"; + static constexpr const char* GEANT4_TAG_PLUGIN = "Geant4-plugin"; + static constexpr const char* GEANT4_TAG_BIRKSCONSTANT = "BirksConstant"; + static constexpr const char* GEANT4_TAG_MEE = "MeanExcitationEnergy"; + static constexpr const char* GEANT4_TAG_ENE_PER_ION_PAIR = "MeanEnergyPerIonPair"; -namespace { static string indent = ""; + template void handleRefs(const O* o, const C& c, F pmf) { + for (typename C::const_iterator i = c.begin(); i != c.end(); ++i) { + //(o->*pmf)((*i)->GetName(), *i); + (o->*pmf)("", *i); + } + } + + template void handle(const O* o, const C& c, F pmf) { + for (typename C::const_iterator i = c.begin(); i != c.end(); ++i) { + (o->*pmf)((*i)->GetName(), *i); + } + } + + template void handleArray(const O* o, const TObjArray* c, F pmf) { + TObjArrayIter arr(c); + for(TObject* i = arr.Next(); i; i=arr.Next()) + (o->*pmf)(i); + } + + template void handleMap(const O* o, const C& c, F pmf) { + for (typename C::const_iterator i = c.begin(); i != c.end(); ++i) + (o->*pmf)((*i).first, (*i).second); + } + + template void handleRMap(const O* o, const C& c, F pmf) { + for (typename C::const_reverse_iterator i = c.rbegin(); i != c.rend(); ++i) { + //cout << "Handle RMAP [ " << (*i).first << " ]" << endl; + handle(o, (*i).second, pmf); + } + } + template void handleRMap_(const O* o, const C& c, F pmf) { + for (typename C::const_iterator i = c.begin(); i != c.end(); ++i) { + const auto& cc = (*i).second; + for (const auto& j : cc) { + (o->*pmf)(j); + } + } + } + string make_NCName(const string& in) { string res = detail::str_replace(in, "/", "_"); res = detail::str_replace(res, "#", "_"); @@ -367,8 +405,8 @@ void* Geant4Converter::handleMaterial(const string& name, Material medium) const material->GetTemperature(), material->GetPressure()); } - string plugin_name; - double value; + string plugin_name { }; + double value = 0e0; double ionisation_mee = -2e100; double ionisation_birks_constant = -2e100; double ionisation_ene_per_ion_pair = -2e100; @@ -459,33 +497,33 @@ void* Geant4Converter::handleMaterial(const string& name, Material medium) const if ( nullptr != cptr ) { printout(INFO, name, "++ Ignore CONST property %s [%s] --> Plugin.", named->GetName(), named->GetTitle()); - plugin_name = named->GetTitle(); + plugin_name = named->GetTitle(); continue; } cptr = ::strstr(named->GetName(), GEANT4_TAG_BIRKSCONSTANT); if ( nullptr != cptr ) { - err = kFALSE; - value = material->GetConstProperty(GEANT4_TAG_BIRKSCONSTANT,&err); - if ( err == kFALSE ) ionisation_birks_constant = value * (CLHEP::mm/CLHEP::MeV)/(units::mm/units::MeV); + err = kFALSE; + value = material->GetConstProperty(GEANT4_TAG_BIRKSCONSTANT,&err); + if ( err == kFALSE ) ionisation_birks_constant = value * (CLHEP::mm/CLHEP::MeV)/(units::mm/units::MeV); continue; } cptr = ::strstr(named->GetName(), GEANT4_TAG_MEE); if ( nullptr != cptr ) { - err = kFALSE; - value = material->GetConstProperty(GEANT4_TAG_MEE,&err); - if ( err == kFALSE ) ionisation_mee = value * (CLHEP::MeV/units::MeV); + err = kFALSE; + value = material->GetConstProperty(GEANT4_TAG_MEE, &err); + if ( err == kFALSE ) ionisation_mee = value * (CLHEP::MeV/units::MeV); continue; } cptr = ::strstr(named->GetName(), GEANT4_TAG_ENE_PER_ION_PAIR); if ( nullptr != cptr ) { - err = kFALSE; - value = material->GetConstProperty(GEANT4_TAG_ENE_PER_ION_PAIR,&err); - if ( err == kFALSE ) ionisation_ene_per_ion_pair = value * (CLHEP::MeV/units::MeV); + err = kFALSE; + value = material->GetConstProperty(GEANT4_TAG_ENE_PER_ION_PAIR,&err); + if ( err == kFALSE ) ionisation_ene_per_ion_pair = value * (CLHEP::MeV/units::MeV); continue; } err = kFALSE; - value = info.manager->GetProperty(named->GetTitle(),&err); + value = info.manager->GetProperty(named->GetTitle(), &err); if ( err != kFALSE ) { except(name, "++ FAILED to create G4 material %s [Cannot convert const property: %s]", @@ -524,19 +562,19 @@ void* Geant4Converter::handleMaterial(const string& name, Material medium) const str << (*mat); if ( ionisation ) { if ( ionisation_birks_constant > 0e0 ) { - ionisation->SetBirksConstant(ionisation_birks_constant); + ionisation->SetBirksConstant(ionisation_birks_constant); } if ( ionisation_mee > -1e100 ) { - ionisation->SetMeanExcitationEnergy(ionisation_mee); + ionisation->SetMeanExcitationEnergy(ionisation_mee); } if ( ionisation_ene_per_ion_pair > 0e0 ) { - ionisation->SetMeanEnergyPerIonPair(ionisation_ene_per_ion_pair); + ionisation->SetMeanEnergyPerIonPair(ionisation_ene_per_ion_pair); } str << " log(MEE): " << std::setprecision(4) << ionisation->GetLogMeanExcEnergy(); if ( ionisation_birks_constant > 0e0 ) - str << " Birk's constant: " << std::setprecision(4) << ionisation->GetBirksConstant() << " [mm/MeV]"; + str << " Birk's constant: " << std::setprecision(4) << ionisation->GetBirksConstant() << " [mm/MeV]"; if ( ionisation_ene_per_ion_pair > 0e0 ) - str << " Mean Energy Per Ion Pair: " << std::setprecision(4) << ionisation->GetMeanEnergyPerIonPair()/CLHEP::eV << " [eV]"; + str << " Mean Energy Per Ion Pair: " << std::setprecision(4) << ionisation->GetMeanEnergyPerIonPair()/CLHEP::eV << " [eV]"; } else { str << " No ionisation parameters availible."; @@ -548,7 +586,7 @@ void* Geant4Converter::handleMaterial(const string& name, Material medium) const Detector* det = const_cast(&m_detDesc); G4Material* extended_mat = PluginService::Create(plugin_name, det, medium, mat); if ( !extended_mat ) { - except("G4Cnv::material["+name+"]","++ FATAL Failed to call plugin to create material."); + except("G4Cnv::material["+name+"]","++ FATAL Failed to call plugin to create material."); } mat = extended_mat; } @@ -620,7 +658,7 @@ void* Geant4Converter::handleSolid(const string& name, const TGeoShape* shape) c TGeoScaledShape* sh = (TGeoScaledShape*) shape; TGeoShape* sol = sh->GetShape(); if ( sol->IsA() == TGeoShapeAssembly::Class() ) { - return solid; + return solid; } const double* vals = sh->GetScale()->GetScale(); G4Scale3D scal(vals[0], vals[1], vals[2]); @@ -674,7 +712,7 @@ void* Geant4Converter::handleSolid(const string& name, const TGeoShape* shape) c if ( matrix->IsRotation() ) { G4Transform3D transform; - g4Transform(matrix, transform); + g4Transform(matrix, transform); if (oper == TGeoBoolNode::kGeoSubtraction) solid = new G4SubtractionSolid(name, left, right, transform); else if (oper == TGeoBoolNode::kGeoUnion) @@ -756,7 +794,7 @@ void* Geant4Converter::handleVolume(const string& name, const TGeoVolume* volume string plugin = _v.getProperty(GEANT4_TAG_PLUGIN,""); g4vol = PluginService::Create(plugin, det, _v, g4solid, g4medium); if ( !g4vol ) { - except("G4Cnv::volume["+name+"]","++ FATAL Failed to call plugin to create logical volume."); + except("G4Cnv::volume["+name+"]","++ FATAL Failed to call plugin to create logical volume."); } } else { @@ -769,30 +807,30 @@ void* Geant4Converter::handleVolume(const string& name, const TGeoVolume* volume if ( g4region ) { PrintLevel plevel = (debugVolumes||debugRegions||debugLimits) ? ALWAYS : outputLevel; printout(plevel, "Geant4Converter", "++ Volume + Apply REGION settings: %-24s to volume %s.", - reg.name(), vnam); + reg.name(), vnam); // Handle the region settings for the world volume seperately. // Geant4 does NOT WANT any regions assigned to the workd volume. // The world's region is created in the G4RunManagerKernel! if ( _v == m_detDesc.worldVolume() ) { - const char* wrd_nam = "DefaultRegionForTheWorld"; - const char* src_nam = g4region->GetName().c_str(); - auto* world_region = G4RegionStore::GetInstance()->GetRegion(wrd_nam, false); - if ( auto* cuts = g4region->GetProductionCuts() ) { - world_region->SetProductionCuts(cuts); - printout(plevel, "Geant4Converter", - "++ Volume %s Region: %s. Apply production cuts from %s", - vnam, wrd_nam, src_nam); - } - if ( auto* lims = g4region->GetUserLimits() ) { - world_region->SetUserLimits(lims); - printout(plevel, "Geant4Converter", - "++ Volume %s Region: %s. Apply user limits from %s", - vnam, wrd_nam, src_nam); - } + const char* wrd_nam = "DefaultRegionForTheWorld"; + const char* src_nam = g4region->GetName().c_str(); + auto* world_region = G4RegionStore::GetInstance()->GetRegion(wrd_nam, false); + if ( auto* cuts = g4region->GetProductionCuts() ) { + world_region->SetProductionCuts(cuts); + printout(plevel, "Geant4Converter", + "++ Volume %s Region: %s. Apply production cuts from %s", + vnam, wrd_nam, src_nam); + } + if ( auto* lims = g4region->GetUserLimits() ) { + world_region->SetUserLimits(lims); + printout(plevel, "Geant4Converter", + "++ Volume %s Region: %s. Apply user limits from %s", + vnam, wrd_nam, src_nam); + } } else { - g4vol->SetRegion(g4region); - g4region->AddRootLogicalVolume(g4vol); + g4vol->SetRegion(g4region); + g4region->AddRootLogicalVolume(g4vol); } } G4VisAttributes* g4vattr = vis.isValid() @@ -802,7 +840,7 @@ void* Geant4Converter::handleVolume(const string& name, const TGeoVolume* volume } info.g4Volumes[volume] = g4vol; printout(lvl, "Geant4Converter", - "++ Volume + %s converted: %p ---> G4: %p", vnam, volume, g4vol); + "++ Volume + %s converted: %p ---> G4: %p", vnam, volume, g4vol); } return nullptr; } @@ -979,69 +1017,69 @@ void* Geant4Converter::handlePlacement(const string& name, const TGeoNode* node) G4PhysicalVolumesPair pvPlaced { nullptr, nullptr }; if ( pv_data && pv_data->params && (pv_data->params->flags&Volume::REPLICATED) ) { - EAxis axis = kUndefined; - double width = 0e0, offset = 0e0; - auto flags = pv_data->params->flags; - auto count = pv_data->params->trafo1D.second; - auto start = pv_data->params->start.Translation().Vect(); - auto delta = pv_data->params->trafo1D.first.Translation().Vect(); - - if ( flags&Volume::X_axis ) - { axis = kXAxis; width = delta.X(); offset = start.X(); } - else if ( flags&Volume::Y_axis ) - { axis = kYAxis; width = delta.Y(); offset = start.Y(); } - else if ( flags&Volume::Z_axis ) - { axis = kZAxis; width = delta.Z(); offset = start.Z(); } - else - except("Geant4Converter", - "++ Replication around unknown axis is not implemented. flags: %16X", flags); - printout(INFO,"Geant4Converter","++ Replicate: Axis: %ld Count: %ld offset: %f width: %f", - axis, count, offset, width); - auto* g4pv = new G4PVReplica(name, // its name - g4vol, // its logical volume - g4mot, // its mother (logical) volume - axis, // its replication axis - count, // Number of replicas - width, // Distance between 2 replicas - offset); // Placement offset in axis direction - pvPlaced = { g4pv, nullptr }; + EAxis axis = kUndefined; + double width = 0e0, offset = 0e0; + auto flags = pv_data->params->flags; + auto count = pv_data->params->trafo1D.second; + auto start = pv_data->params->start.Translation().Vect(); + auto delta = pv_data->params->trafo1D.first.Translation().Vect(); + + if ( flags&Volume::X_axis ) + { axis = kXAxis; width = delta.X(); offset = start.X(); } + else if ( flags&Volume::Y_axis ) + { axis = kYAxis; width = delta.Y(); offset = start.Y(); } + else if ( flags&Volume::Z_axis ) + { axis = kZAxis; width = delta.Z(); offset = start.Z(); } + else + except("Geant4Converter", + "++ Replication around unknown axis is not implemented. flags: %16X", flags); + printout(INFO,"Geant4Converter","++ Replicate: Axis: %ld Count: %ld offset: %f width: %f", + axis, count, offset, width); + auto* g4pv = new G4PVReplica(name, // its name + g4vol, // its logical volume + g4mot, // its mother (logical) volume + axis, // its replication axis + count, // Number of replicas + width, // Distance between 2 replicas + offset); // Placement offset in axis direction + pvPlaced = { g4pv, nullptr }; #if 0 - pvPlaced = - G4ReflectionFactory::Instance()->Replicate(name, // its name - g4vol, // its logical volume - g4mot, // its mother (logical) volume - axis, // its replication axis - count, // Number of replicas - width, // Distance between 2 replicas - offset); // Placement offset in axis direction - /// Update replica list to avoid additional conversions... - auto* g4pv = pvPlaced.second ? pvPlaced.second : pvPlaced.first; + pvPlaced = + G4ReflectionFactory::Instance()->Replicate(name, // its name + g4vol, // its logical volume + g4mot, // its mother (logical) volume + axis, // its replication axis + count, // Number of replicas + width, // Distance between 2 replicas + offset); // Placement offset in axis direction + /// Update replica list to avoid additional conversions... + auto* g4pv = pvPlaced.second ? pvPlaced.second : pvPlaced.first; #endif - for( auto& handle : pv_data->params->placements ) - info.g4Placements[handle.ptr()] = g4pv; + for( auto& handle : pv_data->params->placements ) + info.g4Placements[handle.ptr()] = g4pv; } else if ( pv_data && pv_data->params ) { - auto* g4par = new Geant4PlacementParameterisation(pv); - auto* g4pv = new G4PVParameterised(name, // its name - g4vol, // its logical volume - g4mot, // its mother (logical) volume - g4par->axis(), // its replication axis - g4par->count(), // Number of replicas - g4par); // G4 parametrization - pvPlaced = { g4pv, nullptr }; - /// Update replica list to avoid additional conversions... - for( auto& handle : pv_data->params->placements ) - info.g4Placements[handle.ptr()] = g4pv; + auto* g4par = new Geant4PlacementParameterisation(pv); + auto* g4pv = new G4PVParameterised(name, // its name + g4vol, // its logical volume + g4mot, // its mother (logical) volume + g4par->axis(), // its replication axis + g4par->count(), // Number of replicas + g4par); // G4 parametrization + pvPlaced = { g4pv, nullptr }; + /// Update replica list to avoid additional conversions... + for( auto& handle : pv_data->params->placements ) + info.g4Placements[handle.ptr()] = g4pv; } else { - pvPlaced = - G4ReflectionFactory::Instance()->Place(transform, // no rotation - name, // its name - g4vol, // its logical volume - g4mot, // its mother (logical) volume - false, // no boolean operations - copy, // its copy number - checkOverlaps); + pvPlaced = + G4ReflectionFactory::Instance()->Place(transform, // no rotation + name, // its name + g4vol, // its logical volume + g4mot, // its mother (logical) volume + false, // no boolean operations + copy, // its copy number + checkOverlaps); } printout(debugReflections||debugPlacements ? ALWAYS : lvl, "Geant4Converter", "++ Place %svolume %-12s in mother %-12s " @@ -1096,47 +1134,47 @@ void* Geant4Converter::handleRegion(Region region, const set& cuts = new G4ProductionCuts(); cuts->SetProductionCut(r.cut()*CLHEP::mm/units::mm); printout(lvl, "Geant4Converter", "++ %s: Using default cut: %f [mm]", - r.name(), r.cut()*CLHEP::mm/units::mm); + r.name(), r.cut()*CLHEP::mm/units::mm); } for( const auto& nam : limits ) { LimitSet ls = m_detDesc.limitSet(nam); if ( ls.isValid() ) { - const LimitSet::Set& cts = ls.cuts(); - for (const auto& c : cts ) { - int pid = 0; - if ( c.particles == "*" ) pid = -1; - else if ( c.particles == "e-" ) pid = idxG4ElectronCut; - else if ( c.particles == "e+" ) pid = idxG4PositronCut; - else if ( c.particles == "e[+-]" ) pid = -idxG4PositronCut-idxG4ElectronCut; - else if ( c.particles == "e[-+]" ) pid = -idxG4PositronCut-idxG4ElectronCut; - else if ( c.particles == "gamma" ) pid = idxG4GammaCut; - else if ( c.particles == "proton" ) pid = idxG4ProtonCut; - else throw runtime_error("G4Region: Invalid production cut particle-type:" + c.particles); - if ( !cuts ) cuts = new G4ProductionCuts(); - if ( pid == -(idxG4PositronCut+idxG4ElectronCut) ) { - cuts->SetProductionCut(c.value*CLHEP::mm/units::mm, idxG4PositronCut); - cuts->SetProductionCut(c.value*CLHEP::mm/units::mm, idxG4ElectronCut); - } - else { - cuts->SetProductionCut(c.value*CLHEP::mm/units::mm, pid); - } - printout(lvl, "Geant4Converter", "++ %s: Set cut [%s/%d] = %f [mm]", - r.name(), c.particles.c_str(), pid, c.value*CLHEP::mm/units::mm); - } - bool found = false; - const auto& lm = data().g4Limits; - for (const auto& j : lm ) { - if (nam == j.first->GetName()) { - g4->SetUserLimits(j.second); - printout(lvl, "Geant4Converter", "++ %s: Set limits %s to region type %s", - r.name(), nam.c_str(), j.second->GetType().c_str()); - found = true; - break; - } - } - if ( found ) { - continue; - } + const LimitSet::Set& cts = ls.cuts(); + for (const auto& c : cts ) { + int pid = 0; + if ( c.particles == "*" ) pid = -1; + else if ( c.particles == "e-" ) pid = idxG4ElectronCut; + else if ( c.particles == "e+" ) pid = idxG4PositronCut; + else if ( c.particles == "e[+-]" ) pid = -idxG4PositronCut-idxG4ElectronCut; + else if ( c.particles == "e[-+]" ) pid = -idxG4PositronCut-idxG4ElectronCut; + else if ( c.particles == "gamma" ) pid = idxG4GammaCut; + else if ( c.particles == "proton" ) pid = idxG4ProtonCut; + else throw runtime_error("G4Region: Invalid production cut particle-type:" + c.particles); + if ( !cuts ) cuts = new G4ProductionCuts(); + if ( pid == -(idxG4PositronCut+idxG4ElectronCut) ) { + cuts->SetProductionCut(c.value*CLHEP::mm/units::mm, idxG4PositronCut); + cuts->SetProductionCut(c.value*CLHEP::mm/units::mm, idxG4ElectronCut); + } + else { + cuts->SetProductionCut(c.value*CLHEP::mm/units::mm, pid); + } + printout(lvl, "Geant4Converter", "++ %s: Set cut [%s/%d] = %f [mm]", + r.name(), c.particles.c_str(), pid, c.value*CLHEP::mm/units::mm); + } + bool found = false; + const auto& lm = data().g4Limits; + for (const auto& j : lm ) { + if (nam == j.first->GetName()) { + g4->SetUserLimits(j.second); + printout(lvl, "Geant4Converter", "++ %s: Set limits %s to region type %s", + r.name(), nam.c_str(), j.second->GetType().c_str()); + found = true; + break; + } + } + if ( found ) { + continue; + } } except("Geant4Converter", "++ G4Region: Failed to resolve limitset: " + nam); } @@ -1166,7 +1204,7 @@ void* Geant4Converter::handleLimitSet(LimitSet limitset, const set std::numeric_limits::epsilon() ) { printout(ALWAYS,"Geant4Converter", "+++ LimitSet: Implicit Limit %s.%s for wildcard particles: %f", - ls.name(), pref.c_str(), float(h.defaultValue)); + ls.name(), pref.c_str(), float(h.defaultValue)); } return *this; } @@ -1175,7 +1213,7 @@ void* Geant4Converter::handleLimitSet(LimitSet limitset, const setmaxTime) @@ -1385,11 +1423,12 @@ void* Geant4Converter::handleOpticalSurface(TObject* surface) const { G4OpticalSurfaceModel model = geant4_surface_model(optSurf->GetModel()); G4OpticalSurfaceFinish finish = geant4_surface_finish(optSurf->GetFinish()); string name = make_NCName(optSurf->GetName()); + PrintLevel lvl = debugSurfaces ? ALWAYS : DEBUG; g4 = new G4OpticalSurface(name, model, finish, type, optSurf->GetValue()); g4->SetSigmaAlpha(optSurf->GetSigmaAlpha()); g4->SetPolish(optSurf->GetPolish()); - printout(debugSurfaces ? ALWAYS : DEBUG, "Geant4Converter", + printout(lvl, "Geant4Converter", "++ Created OpticalSurface: %-18s type:%s model:%s finish:%s SigmaAlphs: %.3e Polish: %.3e", optSurf->GetName(), TGeoOpticalSurface::TypeToString(optSurf->GetType()), @@ -1398,8 +1437,8 @@ void* Geant4Converter::handleOpticalSurface(TObject* surface) const { optSurf->GetSigmaAlpha(), optSurf->GetPolish()); G4MaterialPropertiesTable* tab = nullptr; - TListIter it(&optSurf->GetProperties()); - for(TObject* obj = it.Next(); obj; obj = it.Next()) { + TListIter itp(&optSurf->GetProperties()); + for(TObject* obj = itp.Next(); obj; obj = itp.Next()) { string exc_str; TNamed* named = (TNamed*)obj; TGDMLMatrix* matrix = info.manager->GetGDMLMatrix(named->GetTitle()); @@ -1424,10 +1463,8 @@ void* Geant4Converter::handleOpticalSurface(TObject* surface) const { } catch(const std::exception& e) { exc_str = e.what(); - idx = -1; } catch(...) { - idx = -1; } if ( idx < 0 ) { printout(ERROR, "Geant4Converter", @@ -1443,14 +1480,62 @@ void* Geant4Converter::handleOpticalSurface(TObject* surface) const { G4MaterialPropertyVector* vec = new G4MaterialPropertyVector(&bins[0], &vals[0], bins.size()); tab->AddProperty(named->GetName(), vec); - printout(debugSurfaces ? ALWAYS : DEBUG, "Geant4Converter", + printout(lvl, "Geant4Converter", "++ Property: %-20s [%ld x %ld] --> %s", named->GetName(), matrix->GetRows(), matrix->GetCols(), named->GetTitle()); for(std::size_t i=0, count=v->bins.size(); iGetName(), + printout(lvl, named->GetName(), " Geant4: %8.3g [MeV] TGeo: %8.3g [GeV] Conversion: %8.3g", bins[i], v->bins[i], conv.first); } + TListIter itc(&optSurf->GetConstProperties()); + for(TObject* obj = itc.Next(); obj; obj = itc.Next()) { + string exc_str; + TNamed* named = (TNamed*)obj; + const char* cptr = ::strstr(named->GetName(), GEANT4_TAG_IGNORE); + if ( nullptr != cptr ) { + printout(INFO, name, "++ Ignore CONST property %s [%s].", + named->GetName(), named->GetTitle()); + continue; + } + cptr = ::strstr(named->GetTitle(), GEANT4_TAG_IGNORE); + if ( nullptr != cptr ) { + printout(INFO, name,"++ Ignore CONST property %s [%s].", + named->GetName(), named->GetTitle()); + continue; + } + Bool_t err = kFALSE; + Double_t value = info.manager->GetProperty(named->GetTitle(),&err); + if ( err != kFALSE ) { + except(name, + "++ FAILED to create G4 material %s [Cannot convert const property: %s]", + optSurf->GetName(), named->GetName()); + } + if ( nullptr == tab ) { + tab = new G4MaterialPropertiesTable(); + g4->SetMaterialPropertiesTable(tab); + } + int idx = -1; + try { + idx = tab->GetConstPropertyIndex(named->GetName()); + } + catch(const std::exception& e) { + exc_str = e.what(); + } + catch(...) { + } + if ( idx < 0 ) { + printout(ERROR, name, + "++ UNKNOWN Geant4 CONST Property: %-20s %s [IGNORED]", + exc_str.c_str(), named->GetName()); + continue; + } + // We need to convert the property from TGeo units to Geant4 units + double conv = g4ConstPropertyConversion(idx); + printout(lvl, name, "++ CONST Property: %-20s %g * %g --> %g ", + named->GetName(), value, conv, value * conv); + tab->AddConstProperty(named->GetName(), value * conv); + } info.g4OpticalSurfaces[optSurf] = g4; } return g4; @@ -1566,47 +1651,6 @@ void* Geant4Converter::printPlacement(const string& name, const TGeoNode* node) return g4; } -namespace { - template void handleRefs(const O* o, const C& c, F pmf) { - for (typename C::const_iterator i = c.begin(); i != c.end(); ++i) { - //(o->*pmf)((*i)->GetName(), *i); - (o->*pmf)("", *i); - } - } - - template void handle(const O* o, const C& c, F pmf) { - for (typename C::const_iterator i = c.begin(); i != c.end(); ++i) { - (o->*pmf)((*i)->GetName(), *i); - } - } - - template void handleArray(const O* o, const TObjArray* c, F pmf) { - TObjArrayIter arr(c); - for(TObject* i = arr.Next(); i; i=arr.Next()) - (o->*pmf)(i); - } - - template void handleMap(const O* o, const C& c, F pmf) { - for (typename C::const_iterator i = c.begin(); i != c.end(); ++i) - (o->*pmf)((*i).first, (*i).second); - } - - template void handleRMap(const O* o, const C& c, F pmf) { - for (typename C::const_reverse_iterator i = c.rbegin(); i != c.rend(); ++i) { - //cout << "Handle RMAP [ " << (*i).first << " ]" << endl; - handle(o, (*i).second, pmf); - } - } - template void handleRMap_(const O* o, const C& c, F pmf) { - for (typename C::const_iterator i = c.begin(); i != c.end(); ++i) { - const auto& cc = (*i).second; - for (const auto& j : cc) { - (o->*pmf)(j); - } - } - } -} - /// Create geometry conversion Geant4Converter& Geant4Converter::create(DetElement top) { Geant4GeometryInfo& geo = this->init(); diff --git a/examples/OpticalSurfaces/compact/ReadOpticalSurfaces.xml b/examples/OpticalSurfaces/compact/ReadOpticalSurfaces.xml index 7658c6f9a..377e86c55 100644 --- a/examples/OpticalSurfaces/compact/ReadOpticalSurfaces.xml +++ b/examples/OpticalSurfaces/compact/ReadOpticalSurfaces.xml @@ -63,10 +63,12 @@ + + From 0743b845bf56916185193658012548c9ca0a6018 Mon Sep 17 00:00:00 2001 From: Markus Frank Date: Thu, 8 Feb 2024 08:53:14 +0100 Subject: [PATCH 02/14] Implement CONST properties to optical sufaces. (Requires new release of ROOT) --- DDG4/src/Geant4Converter.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp index 294d21343..edb4402ac 100644 --- a/DDG4/src/Geant4Converter.cpp +++ b/DDG4/src/Geant4Converter.cpp @@ -1435,7 +1435,8 @@ void* Geant4Converter::handleOpticalSurface(TObject* surface) const { TGeoOpticalSurface::ModelToString(optSurf->GetModel()), TGeoOpticalSurface::FinishToString(optSurf->GetFinish()), optSurf->GetSigmaAlpha(), optSurf->GetPolish()); - + /// + /// Convert non-scalar properties from GDML tables G4MaterialPropertiesTable* tab = nullptr; TListIter itp(&optSurf->GetProperties()); for(TObject* obj = itp.Next(); obj; obj = itp.Next()) { @@ -1488,6 +1489,9 @@ void* Geant4Converter::handleOpticalSurface(TObject* surface) const { " Geant4: %8.3g [MeV] TGeo: %8.3g [GeV] Conversion: %8.3g", bins[i], v->bins[i], conv.first); } + /// + /// Convert scalar properties +#if ROOT_VERSION_CODE >= ROOT_VERSION(6,31,1) TListIter itc(&optSurf->GetConstProperties()); for(TObject* obj = itc.Next(); obj; obj = itc.Next()) { string exc_str; @@ -1536,6 +1540,7 @@ void* Geant4Converter::handleOpticalSurface(TObject* surface) const { named->GetName(), value, conv, value * conv); tab->AddConstProperty(named->GetName(), value * conv); } +#endif // ROOT_VERSION >= 6.31.1 info.g4OpticalSurfaces[optSurf] = g4; } return g4; From cdc43e3a88034c5008f344364c174d1e8d8189b4 Mon Sep 17 00:00:00 2001 From: Markus Frank Date: Thu, 8 Feb 2024 09:35:04 +0100 Subject: [PATCH 03/14] Remove support for very old versions of ROOT < 6.10.0 --- DDEve/DDEve/DDEve.C | 4 - DDEve/DDEve/DDEve.cpp | 2 +- DDEve/src/Display.cpp | 193 +++++++++++++++--------------- DDEve/src/EventControl.cpp | 34 +++--- DDEve/src/GenericEventHandler.cpp | 52 ++++---- 5 files changed, 132 insertions(+), 153 deletions(-) diff --git a/DDEve/DDEve/DDEve.C b/DDEve/DDEve/DDEve.C index 061f0456d..1d54daaee 100644 --- a/DDEve/DDEve/DDEve.C +++ b/DDEve/DDEve/DDEve.C @@ -32,12 +32,8 @@ void DDEve(const char* xmlConfig=0, const char* evtData=0) { } ::snprintf(text,sizeof(text)," -I%s/include -D__DD4HEP_DDEVE_EXCLUSIVE__ -Wno-shadow -g -O0",dd4hep); gSystem->AddIncludePath(text); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0) TString fname = "libDDG4IO"; const char* io_lib = gSystem->FindDynamicLibrary(fname,kTRUE); -#else - const char* io_lib = "libDDG4IO"; -#endif if ( io_lib ) { result = gSystem->Load("libDDG4IO"); if ( 0 != result ) { diff --git a/DDEve/DDEve/DDEve.cpp b/DDEve/DDEve/DDEve.cpp index 13c5f1699..2ae6346e9 100644 --- a/DDEve/DDEve/DDEve.cpp +++ b/DDEve/DDEve/DDEve.cpp @@ -16,7 +16,7 @@ #include // ROOT include files -#include "TRint.h" +#include #include "DDEve.C" int main(int argc, char** argv) { diff --git a/DDEve/src/Display.cpp b/DDEve/src/Display.cpp index 140ce924a..5631b4404 100644 --- a/DDEve/src/Display.cpp +++ b/DDEve/src/Display.cpp @@ -12,50 +12,49 @@ //========================================================================== // Framework include files -#include "DDEve/View.h" -#include "DDEve/Display.h" -#include "DDEve/ViewMenu.h" -#include "DDEve/DD4hepMenu.h" -#include "DDEve/ElementList.h" -#include "DDEve/GenericEventHandler.h" -#include "DDEve/EveShapeContextMenu.h" -#include "DDEve/EvePgonSetProjectedContextMenu.h" -#include "DDEve/Utilities.h" -#include "DDEve/DDEveEventData.h" -#include "DDEve/HitActors.h" -#include "DDEve/ParticleActors.h" - -#include "DD4hep/Detector.h" -#include "DD4hep/DetectorData.h" -#include "DD4hep/Printout.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include // ROOT include files -#include "TROOT.h" -#include "TH2.h" -#include "TFile.h" -#include "TSystem.h" -#include "TGTab.h" -#include "TGMsgBox.h" -#include "TGClient.h" -#include "TGFileDialog.h" -#include "TEveScene.h" -#include "TEveBrowser.h" -#include "TEveManager.h" -#include "TEveCaloData.h" -#include "TEveCalo.h" -#include "TEveViewer.h" -#include "TEveCompound.h" -#include "TEveBoxSet.h" -#include "TEvePointSet.h" -#include "TEveGeoShape.h" -#include "TEveTrackPropagator.h" -#include "TGeoManager.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // C/C++ include files #include #include -using namespace std; using namespace dd4hep; using namespace dd4hep::detail; @@ -194,15 +193,15 @@ void Display::ImportConfiguration(const DisplayConfiguration& config) { } /// Access to calo data histograms by name as defined in the configuration -Display::CalodataContext& Display::GetCaloHistogram(const string& nam) { +Display::CalodataContext& Display::GetCaloHistogram(const std::string& nam) { Calodata::iterator i = m_calodata.find(nam); if ( i == m_calodata.end() ) { DataConfigurations::const_iterator j = m_calodataConfigs.find(nam); if ( j != m_calodataConfigs.end() ) { CalodataContext ctx; ctx.config = (*j).second; - string use = ctx.config.use; - string hits = ctx.config.hits; + std::string use = ctx.config.use; + std::string hits = ctx.config.hits; if ( use.empty() ) { const char* n = nam.c_str(); const DisplayConfiguration::Calodata& cd = (*j).second.data.calodata; @@ -245,13 +244,13 @@ Display::CalodataContext& Display::GetCaloHistogram(const string& nam) { } /// Access a data filter by name. Data filters are used to customize views -const Display::ViewConfig* Display::GetViewConfiguration(const string& nam) const { +const Display::ViewConfig* Display::GetViewConfiguration(const std::string& nam) const { ViewConfigurations::const_iterator i = m_viewConfigs.find(nam); return (i == m_viewConfigs.end()) ? 0 : &((*i).second); } /// Access a data filter by name. Data filters are used to customize calodatas -const Display::DataConfig* Display::GetCalodataConfiguration(const string& nam) const { +const Display::DataConfig* Display::GetCalodataConfiguration(const std::string& nam) const { DataConfigurations::const_iterator i = m_calodataConfigs.find(nam); return (i == m_calodataConfigs.end()) ? 0 : &((*i).second); } @@ -270,12 +269,8 @@ void Display::UnregisterEvents(View* view) { } /// Open standard message box -void Display::MessageBox(PrintLevel level, const string& text, const string& title) const { -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,9,2) - string path = TString::Format("%s/", TROOT::GetIconPath().Data()).Data(); -#else - string path = TString::Format("%s/icons/", gSystem->Getenv("ROOTSYS")).Data(); -#endif +void Display::MessageBox(PrintLevel level, const std::string& text, const std::string& title) const { + std::string path = TString::Format("%s/", TROOT::GetIconPath().Data()).Data(); const TGPicture* pic = 0; if ( level == VERBOSE ) pic = client().GetPicture((path+"mb_asterisk_s.xpm").c_str()); @@ -294,7 +289,7 @@ void Display::MessageBox(PrintLevel level, const string& text, const string& tit } /// Popup XML file chooser. returns chosen file name; empty on cancel -string Display::OpenXmlFileDialog(const string& default_dir) const { +string Display::OpenXmlFileDialog(const std::string& default_dir) const { static const char *evtFiletypes[] = { "xml files", "*.xml", "XML files", "*.XML", @@ -307,7 +302,7 @@ string Display::OpenXmlFileDialog(const string& default_dir) const { fi.fFilename = 0; new TGFileDialog(client().GetRoot(), 0, kFDOpen, &fi); if ( fi.fFilename ) { - string ret = fi.fFilename; + std::string ret = fi.fFilename; if ( ret.find("file:") != 0 ) return "file:"+ret; return ret; } @@ -315,7 +310,7 @@ string Display::OpenXmlFileDialog(const string& default_dir) const { } /// Popup ROOT file chooser. returns chosen file name; empty on cancel -string Display::OpenEventFileDialog(const string& default_dir) const { +string Display::OpenEventFileDialog(const std::string& default_dir) const { static const char *evtFiletypes[] = { "ROOT files", "*.root", "SLCIO files", "*.slcio", @@ -372,38 +367,38 @@ void Display::OnNewEvent(EventHandler& handler ) { for(Types::const_iterator ityp=types.begin(); ityp!=types.end(); ++ityp) { const Collections& colls = (*ityp).second; for(Collections::const_iterator j=colls.begin(); j!=colls.end(); ++j) { - size_t len = (*j).second; + std::size_t len = (*j).second; if ( len > 0 ) { - const char* nam = (*j).first; - DataConfigurations::const_iterator icfg = m_collectionsConfigs.find(nam); - DataConfigurations::const_iterator cfgend = m_collectionsConfigs.end(); + const char* nam = (*j).first; + DataConfigurations::const_iterator icfg = m_collectionsConfigs.find(nam); + DataConfigurations::const_iterator cfgend = m_collectionsConfigs.end(); EventHandler::CollectionType typ = handler.collectionType(nam); if ( typ == EventHandler::CALO_HIT_COLLECTION || typ == EventHandler::TRACKER_HIT_COLLECTION ) { if ( icfg != cfgend ) { const DataConfig& cfg = (*icfg).second; - if ( ::toupper(cfg.use[0]) == 'T' || ::toupper(cfg.use[0]) == 'Y' ) { - if ( cfg.hits == "PointSet" ) { - PointsetCreator cr(nam,len,cfg); - handler.collectionLoop((*j).first, cr); - ImportEvent(cr.element()); - } - else if ( cfg.hits == "BoxSet" ) { - BoxsetCreator cr(nam,len,cfg); - handler.collectionLoop((*j).first, cr); - ImportEvent(cr.element()); - } - else if ( cfg.hits == "TowerSet" ) { - TowersetCreator cr(nam,len,cfg); - handler.collectionLoop((*j).first, cr); - ImportEvent(cr.element()); - } - else { // Default is point set - PointsetCreator cr(nam,len); - handler.collectionLoop((*j).first, cr); - ImportEvent(cr.element()); - } - } + if ( ::toupper(cfg.use[0]) == 'T' || ::toupper(cfg.use[0]) == 'Y' ) { + if ( cfg.hits == "PointSet" ) { + PointsetCreator cr(nam,len,cfg); + handler.collectionLoop((*j).first, cr); + ImportEvent(cr.element()); + } + else if ( cfg.hits == "BoxSet" ) { + BoxsetCreator cr(nam,len,cfg); + handler.collectionLoop((*j).first, cr); + ImportEvent(cr.element()); + } + else if ( cfg.hits == "TowerSet" ) { + TowersetCreator cr(nam,len,cfg); + handler.collectionLoop((*j).first, cr); + ImportEvent(cr.element()); + } + else { // Default is point set + PointsetCreator cr(nam,len); + handler.collectionLoop((*j).first, cr); + ImportEvent(cr.element()); + } + } } else { PointsetCreator cr(nam,len); @@ -417,21 +412,21 @@ void Display::OnNewEvent(EventHandler& handler ) { // last track is gone ie. when we re-initialize the event scene // $$$ Do not know exactly what the field parameters mean - if ( (icfg=m_collectionsConfigs.find("StartVertexPoints")) != cfgend ) { - StartVertexCreator cr("StartVertexPoints", len, (*icfg).second); - handler.collectionLoop((*j).first, cr); - printout(INFO,"Display","+++ StartVertexPoints: Filled %d start vertex points.....",cr.count); - ImportEvent(cr.element()); - } - if ( (icfg=m_collectionsConfigs.find("MCParticles")) != cfgend ) { - MCParticleCreator cr(new TEveTrackPropagator("","",new TEveMagFieldDuo(350, -3.5, 2.0)), - new TEveCompound("MC_Particles","MC_Particles"), - icfg == cfgend ? 0 : &((*icfg).second)); - handler.collectionLoop((*j).first, cr); - printout(INFO,"Display","+++ StartVertexPoints: Filled %d patricle tracks.....",cr.count); - cr.close(); - particles = cr.particles; - } + if ( (icfg=m_collectionsConfigs.find("StartVertexPoints")) != cfgend ) { + StartVertexCreator cr("StartVertexPoints", len, (*icfg).second); + handler.collectionLoop((*j).first, cr); + printout(INFO,"Display","+++ StartVertexPoints: Filled %d start vertex points.....",cr.count); + ImportEvent(cr.element()); + } + if ( (icfg=m_collectionsConfigs.find("MCParticles")) != cfgend ) { + MCParticleCreator cr(new TEveTrackPropagator("","",new TEveMagFieldDuo(350, -3.5, 2.0)), + new TEveCompound("MC_Particles","MC_Particles"), + icfg == cfgend ? 0 : &((*icfg).second)); + handler.collectionLoop((*j).first, cr); + printout(INFO,"Display","+++ StartVertexPoints: Filled %d patricle tracks.....",cr.count); + cr.close(); + particles = cr.particles; + } } } } @@ -442,7 +437,7 @@ void Display::OnNewEvent(EventHandler& handler ) { CalodataContext& ctx = (*i).second; TH2F* h = ctx.eveHist->GetHist(0); EtaPhiHistogramActor actor(h); - size_t n = eventHandler().collectionLoop(ctx.config.hits, actor); + std::size_t n = eventHandler().collectionLoop(ctx.config.hits, actor); ctx.eveHist->DataChanged(); printout(INFO,"FillEtaPhiHistogram","+++ %s: Filled %ld hits from %s....", ctx.calo3D->GetName(), n, ctx.config.hits.c_str()); @@ -467,7 +462,7 @@ TEveElementList& Display::GetGeo() { } /// Access/Create a topic by name -TEveElementList& Display::GetGeoTopic(const string& name) { +TEveElementList& Display::GetGeoTopic(const std::string& name) { Topics::iterator i=m_geoTopics.find(name); if ( i == m_geoTopics.end() ) { TEveElementList* topic = new ElementList(name.c_str(), name.c_str(), true, true); @@ -479,7 +474,7 @@ TEveElementList& Display::GetGeoTopic(const string& name) { } /// Access/Create a topic by name. Throws exception if the topic does not exist -TEveElementList& Display::GetGeoTopic(const string& name) const { +TEveElementList& Display::GetGeoTopic(const std::string& name) const { Topics::const_iterator i=m_geoTopics.find(name); if ( i == m_geoTopics.end() ) { throw runtime_error("Display: Attempt to access non-existing geometry topic:"+name); @@ -488,7 +483,7 @@ TEveElementList& Display::GetGeoTopic(const string& name) const { } /// Access/Create a topic by name -TEveElementList& Display::GetEveTopic(const string& name) { +TEveElementList& Display::GetEveTopic(const std::string& name) { Topics::iterator i=m_eveTopics.find(name); if ( i == m_eveTopics.end() ) { TEveElementList* topic = new ElementList(name.c_str(), name.c_str(), true, true); @@ -500,7 +495,7 @@ TEveElementList& Display::GetEveTopic(const string& name) { } /// Access/Create a topic by name. Throws exception if the topic does not exist -TEveElementList& Display::GetEveTopic(const string& name) const { +TEveElementList& Display::GetEveTopic(const std::string& name) const { Topics::const_iterator i=m_eveTopics.find(name); if ( i == m_eveTopics.end() ) { throw runtime_error("Display: Attempt to access non-existing event topic:"+name); @@ -514,12 +509,12 @@ void Display::ImportGeo(TEveElement* el) { } /// Call to import geometry elements by topic -void Display::ImportGeo(const string& topic, TEveElement* el) { +void Display::ImportGeo(const std::string& topic, TEveElement* el) { GetGeoTopic(topic).AddElement(el); } /// Call to import event elements by topic -void Display::ImportEvent(const string& topic, TEveElement* el) { +void Display::ImportEvent(const std::string& topic, TEveElement* el) { GetEveTopic(topic).AddElement(el); } diff --git a/DDEve/src/EventControl.cpp b/DDEve/src/EventControl.cpp index a5c9e4ad9..d7824397b 100644 --- a/DDEve/src/EventControl.cpp +++ b/DDEve/src/EventControl.cpp @@ -12,10 +12,10 @@ //========================================================================== // Framework include files -#include "DDEve/Display.h" -#include "DDEve/EventControl.h" -#include "DDEve/EventHandler.h" -#include "DD4hep/InstanceCount.h" +#include +#include +#include +#include // ROOT include files #include @@ -25,12 +25,11 @@ #include #include #include -#include "TGFileDialog.h" +#include -#include "TTree.h" +#include #include -using namespace std; using namespace dd4hep; ClassImp(EventControl) @@ -117,22 +116,22 @@ void EventControl::OnNewEvent(EventHandler& handler) { typedef EventHandler::TypedEventCollections Types; typedef std::vector Collections; const Types& types = handler.data(); - size_t cnt = 1; + std::size_t cnt = 1; m_lines[0].second.first->SetText("Hit collection name"); m_lines[0].second.second->SetText("No.Hits"); for(const auto& t : types) { const Collections& colls = t.second; Line line = m_lines[cnt++]; - string cl = t.first; - size_t idx = cl.rfind("Geant4"); - if ( idx != string::npos ) { + std::string cl = t.first; + std::size_t idx = cl.rfind("Geant4"); + if ( idx != std::string::npos ) { cl = cl.substr(idx); cl = cl.substr(0,cl.find('*')); } - else if ( (idx=cl.rfind("::")) != string::npos ) { + else if ( (idx=cl.rfind("::")) != std::string::npos ) { cl = cl.substr(idx+2); - if ( (idx=cl.rfind('*')) != string::npos ) cl = cl.substr(0,idx); - if ( (idx=cl.rfind('>')) != string::npos ) cl = cl.substr(0,idx); + if ( (idx=cl.rfind('*')) != std::string::npos ) cl = cl.substr(0,idx); + if ( (idx=cl.rfind('>')) != std::string::npos ) cl = cl.substr(0,idx); } line.second.first->SetTextColor(kRed); line.second.second->SetTextColor(kRed); @@ -159,15 +158,12 @@ void EventControl::OnNewEvent(EventHandler& handler) { /// User callback to add elements to the control void EventControl::OnBuild() { -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,9,2) - string icondir = TString::Format("%s/", TROOT::GetIconPath().Data()).Data(); -#else - string icondir = TString::Format("%s/icons/", gSystem->Getenv("ROOTSYS")).Data(); -#endif + std::string icondir = TString::Format("%s/", TROOT::GetIconPath().Data()).Data(); TGGroupFrame* group = new TGGroupFrame(m_frame,"Event I/O Control"); TGCompositeFrame* top = new TGHorizontalFrame(group); TGPictureButton* b = 0; char text[1024]; + group->SetTitlePos(TGGroupFrame::kLeft); m_frame->AddFrame(group, new TGLayoutHints(kLHintsExpandX|kLHintsCenterX, 2, 2, 2, 2)); m_eventGroup = group; diff --git a/DDEve/src/GenericEventHandler.cpp b/DDEve/src/GenericEventHandler.cpp index fa4f2043b..df213fa74 100644 --- a/DDEve/src/GenericEventHandler.cpp +++ b/DDEve/src/GenericEventHandler.cpp @@ -12,16 +12,16 @@ //========================================================================== // Framework include files -#include "DDEve/GenericEventHandler.h" -#include "DD4hep/Primitives.h" -#include "DD4hep/Factories.h" -#include "DD4hep/Plugins.h" +#include +#include +#include +#include #include /// ROOT include files -#include "TROOT.h" -#include "TGMsgBox.h" -#include "TSystem.h" +#include +#include +#include #include using namespace std; @@ -74,7 +74,7 @@ string GenericEventHandler::datasourceName() const { } /// Access to the collection type by name -EventHandler::CollectionType GenericEventHandler::collectionType(const string& collection) const { +EventHandler::CollectionType GenericEventHandler::collectionType(const std::string& collection) const { if ( m_current && m_current->hasEvent() ) { return m_current->collectionType(collection); } @@ -82,7 +82,7 @@ EventHandler::CollectionType GenericEventHandler::collectionType(const string& c } /// Loop over collection and extract data -size_t GenericEventHandler::collectionLoop(const string& collection, DDEveHitActor& actor) { +std::size_t GenericEventHandler::collectionLoop(const std::string& collection, DDEveHitActor& actor) { if ( m_current && m_current->hasEvent() ) { return m_current->collectionLoop(collection,actor); } @@ -90,7 +90,7 @@ size_t GenericEventHandler::collectionLoop(const string& collection, DDEveHitAct } /// Loop over collection and extract particle data -size_t GenericEventHandler::collectionLoop(const string& collection, DDEveParticleActor& actor) { +std::size_t GenericEventHandler::collectionLoop(const std::string& collection, DDEveParticleActor& actor) { if ( m_current && m_current->hasEvent() ) { return m_current->collectionLoop(collection,actor); } @@ -98,23 +98,23 @@ size_t GenericEventHandler::collectionLoop(const string& collection, DDEvePartic } /// Open a new event data file -bool GenericEventHandler::Open(const string& file_type, const string& file_name) { - size_t idx = file_name.find("lcio"); - size_t idr = file_name.find("root"); - string err; +bool GenericEventHandler::Open(const std::string& file_type, const std::string& file_name) { + std::size_t idx = file_name.find("lcio"); + std::size_t idr = file_name.find("root"); + std::string err; m_hasFile = false; m_hasEvent = false; try { detail::deletePtr(m_current); // prefer event handler configured in xml - if ( file_type.find("FCC") != string::npos ) { + if ( file_type.find("FCC") != std::string::npos ) { m_current = (EventHandler*)PluginService::Create("DD4hep_DDEve_FCCEventHandler",(const char*)0); } // fall back to defaults according to file ending - else if ( idx != string::npos ) { + else if ( idx != std::string::npos ) { m_current = (EventHandler*)PluginService::Create("DD4hep_DDEve_LCIOEventHandler",(const char*)0); } - else if ( idr != string::npos ) { + else if ( idr != std::string::npos ) { m_current = (EventHandler*)PluginService::Create("DD4hep_DDEve_DDG4EventHandler",(const char*)0); } else { @@ -135,13 +135,9 @@ bool GenericEventHandler::Open(const string& file_type, const string& file_name) } catch(const exception& e) { err = "\nAn exception occurred \n" - "while opening event data:\n" + string(e.what()) + "\n\n"; + "while opening event data:\n" + std::string(e.what()) + "\n\n"; } -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,9,2) - string path = TString::Format("%s/stop_t.xpm", TROOT::GetIconPath().Data()).Data(); -#else - string path = TString::Format("%s/icons/stop_t.xpm", gSystem->Getenv("ROOTSYS")).Data(); -#endif + std::string path = TString::Format("%s/stop_t.xpm", TROOT::GetIconPath().Data()).Data(); const TGPicture* pic = gClient->GetPicture(path.c_str()); new TGMsgBox(gClient->GetRoot(),0,"Failed to open event data",err.c_str(),pic, kMBDismiss,0,kVerticalFrame,kTextLeft|kTextCenterY); @@ -162,13 +158,9 @@ bool GenericEventHandler::NextEvent() { throw runtime_error("+++ EventHandler::readEvent: No file open!"); } catch(const exception& e) { -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,9,2) - string path = TString::Format("%s/stop_t.xpm", TROOT::GetIconPath().Data()).Data(); -#else - string path = TString::Format("%s/icons/stop_t.xpm", gSystem->Getenv("ROOTSYS")).Data(); -#endif - string err = "\nAn exception occurred \n" - "while reading a new event:\n" + string(e.what()) + "\n\n"; + std::string path = TString::Format("%s/stop_t.xpm", TROOT::GetIconPath().Data()).Data(); + std::string err = "\nAn exception occurred \n" + "while reading a new event:\n" + std::string(e.what()) + "\n\n"; const TGPicture* pic = gClient->GetPicture(path.c_str()); new TGMsgBox(gClient->GetRoot(),0,"Failed to read event", err.c_str(),pic, kMBDismiss,0,kVerticalFrame,kTextLeft|kTextCenterY); From 3295eaee1d59cd099c5efc35115164d89beeb3db Mon Sep 17 00:00:00 2001 From: Markus Frank Date: Thu, 8 Feb 2024 10:05:15 +0100 Subject: [PATCH 04/14] Suppress default use of std namespace --- DDEve/lcio/LCIOEventHandler.cpp | 35 ++++++------- DDEve/src/Calo2DProjection.cpp | 43 ++++++++-------- DDEve/src/Calo3DProjection.cpp | 6 +-- DDEve/src/CaloLego.cpp | 29 ++++++----- DDEve/src/ContextMenu.cpp | 17 +++--- DDEve/src/DD4hepMenu.cpp | 33 ++++++------ DDEve/src/DDEveEventData.cpp | 2 +- DDEve/src/DDEvePlugins.cpp | 5 +- DDEve/src/DDG4EventHandler.cpp | 15 +++--- DDEve/src/Display.cpp | 22 ++++---- DDEve/src/DisplayConfiguration.cpp | 2 +- DDEve/src/DisplayConfigurationParser.cpp | 54 ++++++++++---------- DDEve/src/ElementList.cpp | 7 ++- DDEve/src/EvePgonSetProjectedContextMenu.cpp | 7 ++- DDEve/src/EveShapeContextMenu.cpp | 9 ++-- DDEve/src/EveUserContextMenu.cpp | 15 +++--- DDEve/src/EventControl.cpp | 5 -- DDEve/src/EventHandler.cpp | 2 +- DDEve/src/FrameControl.cpp | 5 +- DDEve/src/GenericEventHandler.cpp | 13 +++-- DDEve/src/HitActors.cpp | 20 ++++---- DDEve/src/MultiView.cpp | 15 +++--- DDEve/src/ParticleActors.cpp | 31 ++++++----- DDEve/src/PopupMenu.cpp | 6 +-- DDEve/src/Projection.cpp | 11 ++-- DDEve/src/RhoPhiProjection.cpp | 4 +- DDEve/src/RhoZProjection.cpp | 4 +- DDEve/src/Utilities.cpp | 46 ++++++++--------- DDEve/src/View.cpp | 47 +++++++++-------- DDEve/src/View3D.cpp | 4 +- DDEve/src/ViewMenu.cpp | 44 ++++++++-------- 31 files changed, 267 insertions(+), 291 deletions(-) diff --git a/DDEve/lcio/LCIOEventHandler.cpp b/DDEve/lcio/LCIOEventHandler.cpp index c073add12..2e1f8f8a7 100644 --- a/DDEve/lcio/LCIOEventHandler.cpp +++ b/DDEve/lcio/LCIOEventHandler.cpp @@ -13,24 +13,23 @@ // Framework include files #include "LCIOEventHandler.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Objects.h" -#include "DD4hep/Factories.h" +#include +#include +#include -#include "IO/LCReader.h" -#include "EVENT/LCCollection.h" -#include "EVENT/SimCalorimeterHit.h" -#include "EVENT/SimTrackerHit.h" -#include "EVENT/MCParticle.h" +#include +#include +#include +#include +#include -#include "TSystem.h" -#include "TGMsgBox.h" +#include +#include // C/C++ include files #include #include -using namespace std; using namespace lcio; using namespace dd4hep; using namespace EVENT; @@ -168,25 +167,25 @@ bool LCIOEventHandler::NextEvent() { const _S* collnames = m_event->getCollectionNames(); for( _S::const_iterator i = collnames->begin(); i != collnames->end(); ++i) { LCCollection* c = m_event->getCollection(*i); - m_data[c->getTypeName()].push_back(make_pair((*i).c_str(),c->getNumberOfElements())); + m_data[c->getTypeName()].push_back(std::make_pair((*i).c_str(),c->getNumberOfElements())); m_branches[*i] = c; } m_hasEvent = true; return 1; } - throw runtime_error("+++ EventHandler::readEvent: Failed to read event"); + throw std::runtime_error("+++ EventHandler::readEvent: Failed to read event"); } - throw runtime_error("+++ EventHandler::readEvent: No file open!"); + throw std::runtime_error("+++ EventHandler::readEvent: No file open!"); } /// Load the previous event bool LCIOEventHandler::PreviousEvent() { - throw runtime_error("+++ This version of the LCIO reader can only access files sequentially!\n" - "+++ Access to the previous event is not supported."); + throw std::runtime_error("+++ This version of the LCIO reader can only access files sequentially!\n" + "+++ Access to the previous event is not supported."); } /// Goto a specified event in the file bool LCIOEventHandler::GotoEvent(long /* event_number */) { - throw runtime_error("+++ This version of the LCIO reader can only access files sequentially!\n" - "+++ Random access is not supported."); + throw std::runtime_error("+++ This version of the LCIO reader can only access files sequentially!\n" + "+++ Random access is not supported."); } diff --git a/DDEve/src/Calo2DProjection.cpp b/DDEve/src/Calo2DProjection.cpp index 09101b887..bd9f73acb 100644 --- a/DDEve/src/Calo2DProjection.cpp +++ b/DDEve/src/Calo2DProjection.cpp @@ -12,18 +12,17 @@ //========================================================================== // Framework include files -#include "DDEve/Calo2DProjection.h" -#include "DDEve/Annotation.h" -#include "DDEve/Factories.h" -#include "DD4hep/InstanceCount.h" +#include +#include +#include +#include // Root include files -#include "TEveCalo.h" -#include "TEveScene.h" -#include "TGLViewer.h" -#include "TEveArrow.h" +#include +#include +#include +#include -using namespace std; using namespace dd4hep; ClassImp(Calo2DProjection) @@ -61,18 +60,18 @@ void Calo2DProjection::ConfigureGeometry(const DisplayConfiguration::ViewConfig& TEveElementList& sens = m_eve->GetGeoTopic("Sensitive"); TEveElementList& struc = m_eve->GetGeoTopic("Structure"); for(TEveElementList::List_i i=sens.BeginChildren(); i!=sens.EndChildren(); ++i) { - TEveElementList* ll = dynamic_cast(*i); - if ( ll && cfg.name == ll->GetName() ) { - m_projMgr->ImportElements(*i,m_geoScene); - goto Done; - } + TEveElementList* ll = dynamic_cast(*i); + if ( ll && cfg.name == ll->GetName() ) { + m_projMgr->ImportElements(*i,m_geoScene); + goto Done; + } } for(TEveElementList::List_i i=struc.BeginChildren(); i!=struc.EndChildren(); ++i) { - TEveElementList* ll = dynamic_cast(*i); - if ( ll && cfg.name == ll->GetName() ) { - m_projMgr->ImportElements(*i,m_geoScene); - goto Done; - } + TEveElementList* ll = dynamic_cast(*i); + if ( ll && cfg.name == ll->GetName() ) { + m_projMgr->ImportElements(*i,m_geoScene); + goto Done; + } } Done: continue; @@ -110,8 +109,8 @@ void Calo2DProjection::ConfigureGeometry(const DisplayConfiguration::ViewConfig& #endif legend_y += a->GetTextSize(); printout(INFO,"Calo2DProjection","+++ %s: add detector %s [%s] rmin=%f towerH:%f emax=%f", - name().c_str(),n,ctx.config.hits.c_str(),calo3d.rmin,calo3d.towerH, - calo3d.emax); + name().c_str(),n,ctx.config.hits.c_str(),calo3d.rmin,calo3d.towerH, + calo3d.emax); } } } @@ -122,5 +121,5 @@ void Calo2DProjection::ConfigureEvent(const DisplayConfiguration::ViewConfig& co } /// Call to import geometry topics -void Calo2DProjection::ImportGeoTopics(const string& /* title */) { +void Calo2DProjection::ImportGeoTopics(const std::string& /* title */) { } diff --git a/DDEve/src/Calo3DProjection.cpp b/DDEve/src/Calo3DProjection.cpp index d1c05baa2..6e2355506 100644 --- a/DDEve/src/Calo3DProjection.cpp +++ b/DDEve/src/Calo3DProjection.cpp @@ -12,9 +12,9 @@ //========================================================================== // Framework include files -#include "DDEve/Calo3DProjection.h" -#include "DDEve/Factories.h" -#include "DD4hep/InstanceCount.h" +#include +#include +#include using namespace dd4hep; diff --git a/DDEve/src/CaloLego.cpp b/DDEve/src/CaloLego.cpp index 40c01e9f4..0a8910075 100644 --- a/DDEve/src/CaloLego.cpp +++ b/DDEve/src/CaloLego.cpp @@ -12,23 +12,24 @@ //========================================================================== // Framework include files -#include "DDEve/CaloLego.h" -#include "DDEve/Annotation.h" -#include "DDEve/Factories.h" -#include "DD4hep/InstanceCount.h" +#include +#include +#include +#include // Root include files -#include "TH2.h" -#include "TEveCalo.h" -#include "TEveTrans.h" -#include "TEveScene.h" -#include "TGLViewer.h" -#include "TGLWidget.h" -#include "TEveCaloLegoOverlay.h" -#include "TEveLegoEventHandler.h" +#include +#include +#include +#include +#include +#include +#include +#include +// C/C++ include files #include -using namespace std; + using namespace dd4hep; ClassImp(CaloLego) @@ -123,5 +124,5 @@ void CaloLego::ConfigureEvent(const DisplayConfiguration::ViewConfig& config) { } /// Call to import geometry topics -void CaloLego::ImportGeoTopics(const string&) { +void CaloLego::ImportGeoTopics(const std::string&) { } diff --git a/DDEve/src/ContextMenu.cpp b/DDEve/src/ContextMenu.cpp index c7744e5ec..9f23d3deb 100644 --- a/DDEve/src/ContextMenu.cpp +++ b/DDEve/src/ContextMenu.cpp @@ -12,20 +12,19 @@ //========================================================================== // Framework include files -#include "DDEve/ContextMenu.h" +#include // ROOT include files -#include "TList.h" -#include "TClassMenuItem.h" +#include +#include // C/C++ include files #include #include -using namespace std; using namespace dd4hep; -typedef map Contexts; +typedef std::map Contexts; static Contexts& mapped_entries() { static Contexts e; return e; @@ -55,7 +54,7 @@ ClassImp(ContextMenu) /// Initializing constructor ContextMenu::ContextMenu(TClass* cl) : m_class(cl) { if ( !cl ) { - throw runtime_error("Failure: Cannot create context menu for NULL class!"); + throw std::runtime_error("Failure: Cannot create context menu for NULL class!"); } } @@ -89,12 +88,12 @@ ContextMenu& ContextMenu::AddSeparator() { } /// Add user callback -ContextMenu& ContextMenu::Add(const string& title, Callback cb, void* ud) { +ContextMenu& ContextMenu::Add(const std::string& title, Callback cb, void* ud) { ContextMenuHandler* handler = new ContextMenuHandler(cb, ud); TClassMenuItem* item = new TClassMenuItem(TClassMenuItem::kPopupUserFunction, - ContextMenuHandler::Class(),title.c_str(), - "Context",handler,"TObject*",2); + ContextMenuHandler::Class(),title.c_str(), + "Context",handler,"TObject*",2); m_calls.push_back(handler); m_class->GetMenuList()->AddLast(item); return *this; diff --git a/DDEve/src/DD4hepMenu.cpp b/DDEve/src/DD4hepMenu.cpp index 32ae2e0c2..2dd9aaba5 100644 --- a/DDEve/src/DD4hepMenu.cpp +++ b/DDEve/src/DD4hepMenu.cpp @@ -12,30 +12,29 @@ //========================================================================== // Framework include files -#include "DD4hep/Plugins.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Primitives.h" -#include "DD4hep/InstanceCount.h" +#include +#include +#include +#include -#include "DDEve/View.h" -#include "DDEve/DD4hepMenu.h" -#include "DDEve/PopupMenu.h" -#include "DDEve/EventControl.h" +#include +#include +#include +#include // ROOT include files -#include "TEveBrowser.h" -#include "TEveManager.h" -#include "TEveElement.h" -#include "TEveWindow.h" -#include "TEveViewer.h" -#include "TGLViewer.h" -#include "TGClient.h" -#include "TSystem.h" +#include +#include +#include +#include +#include +#include +#include +#include // Forward declarations class TEveWindowSlot; -using namespace std; using namespace dd4hep; ClassImp(DD4hepMenu) diff --git a/DDEve/src/DDEveEventData.cpp b/DDEve/src/DDEveEventData.cpp index 5a48804c6..86f5ba4d6 100644 --- a/DDEve/src/DDEveEventData.cpp +++ b/DDEve/src/DDEveEventData.cpp @@ -12,7 +12,7 @@ //========================================================================== // Framework include files -#include "DDEve/DDEveEventData.h" +#include using namespace dd4hep; diff --git a/DDEve/src/DDEvePlugins.cpp b/DDEve/src/DDEvePlugins.cpp index ed1b29d95..a44d8a4cb 100644 --- a/DDEve/src/DDEvePlugins.cpp +++ b/DDEve/src/DDEvePlugins.cpp @@ -11,9 +11,8 @@ // //========================================================================== - // Framework include files -#include "DD4hep/detail/Plugins.inl" -#include "DDEve/Factories.h" +#include +#include DD4HEP_IMPLEMENT_PLUGIN_REGISTRY(dd4hep::View*, (dd4hep::Display*, const char*)) diff --git a/DDEve/src/DDG4EventHandler.cpp b/DDEve/src/DDG4EventHandler.cpp index 2268fe25f..f9a8abdcf 100644 --- a/DDEve/src/DDG4EventHandler.cpp +++ b/DDEve/src/DDG4EventHandler.cpp @@ -24,7 +24,6 @@ // C/C++ include files #include -using namespace std; using namespace dd4hep; ClassImp(DDG4EventHandler) @@ -48,12 +47,12 @@ DECLARE_CONSTRUCTOR(DD4hep_DDEve_DDG4EventHandler,_create) DDG4EventHandler::DDG4EventHandler() : EventHandler(), m_file(0,0), m_entry(-1) { void* ptr = PluginService::Create("DD4hep_DDEve_DDG4HitAccess",(const char*)""); if ( 0 == ptr ) { - throw runtime_error("FATAL: Failed to access function pointer from factory DD4hep_DDEve_DDG4HitAccess"); + throw std::runtime_error("FATAL: Failed to access function pointer from factory DD4hep_DDEve_DDG4HitAccess"); } m_simhitConverter = FCN(ptr).hits; ptr = PluginService::Create("DD4hep_DDEve_DDG4ParticleAccess",(const char*)""); if ( 0 == ptr ) { - throw runtime_error("FATAL: Failed to access function pointer from factory DD4hep_DDEve_DDG4ParticleAccess"); + throw std::runtime_error("FATAL: Failed to access function pointer from factory DD4hep_DDEve_DDG4ParticleAccess"); } m_particleConverter = FCN(ptr).particles; } @@ -181,9 +180,9 @@ Int_t DDG4EventHandler::ReadEvent(Long64_t event_number) { return nbytes; } printout(ERROR,"DDG4EventHandler","+++ ReadEvent: Cannot read event data for entry:%d",event_number); - throw runtime_error("+++ EventHandler::readEvent: Failed to read event"); + throw std::runtime_error("+++ EventHandler::readEvent: Failed to read event"); } - throw runtime_error("+++ EventHandler::readEvent: No file open!"); + throw std::runtime_error("+++ EventHandler::readEvent: No file open!"); } /// Open new data file @@ -203,7 +202,7 @@ bool DDG4EventHandler::Open(const std::string&, const std::string& name) { for(Int_t i=0; iGetSize(); ++i) { TBranch* b = (TBranch*)br->At(i); if ( !b ) continue; - m_branches[b->GetName()] = make_pair(b,(void*)0); + m_branches[b->GetName()] = std::make_pair(b,(void*)0); printout(INFO,"DDG4EventHandler::open","+++ Branch %s has %ld entries.",b->GetName(),b->GetEntries()); } for(Int_t i=0; iGetSize(); ++i) { @@ -214,7 +213,7 @@ bool DDG4EventHandler::Open(const std::string&, const std::string& name) { m_hasFile = true; return true; } - throw runtime_error("+++ Failed to access tree EVENT in ROOT file:"+name); + throw std::runtime_error("+++ Failed to access tree EVENT in ROOT file:"+name); } - throw runtime_error("+++ Failed to open ROOT file:"+name); + throw std::runtime_error("+++ Failed to open ROOT file:"+name); } diff --git a/DDEve/src/Display.cpp b/DDEve/src/Display.cpp index 5631b4404..25b266366 100644 --- a/DDEve/src/Display.cpp +++ b/DDEve/src/Display.cpp @@ -146,7 +146,7 @@ void Display::LoadXML(const char* xmlFile) { /// Load geometry from compact xml file void Display::LoadGeometryRoot(const char* /* rootFile */) { - throw runtime_error("This call is not implemented !"); + throw std::runtime_error("This call is not implemented !"); } /// Load geometry with panel @@ -169,7 +169,7 @@ GenericEventHandler& Display::eventHandler() const { if ( m_evtHandler ) { return *m_evtHandler; } - throw runtime_error("Invalid event handler"); + throw std::runtime_error("Invalid event handler"); } /// Add new menu to the main menu bar @@ -238,7 +238,7 @@ Display::CalodataContext& Display::GetCaloHistogram(const std::string& nam) { i = m_calodata.emplace(nam,ctx).first; return (*i).second; } - throw runtime_error("Cannot access calodata configuration "+nam); + throw std::runtime_error("Cannot access calodata configuration "+nam); } return (*i).second; } @@ -289,7 +289,7 @@ void Display::MessageBox(PrintLevel level, const std::string& text, const std::s } /// Popup XML file chooser. returns chosen file name; empty on cancel -string Display::OpenXmlFileDialog(const std::string& default_dir) const { +std::string Display::OpenXmlFileDialog(const std::string& default_dir) const { static const char *evtFiletypes[] = { "xml files", "*.xml", "XML files", "*.XML", @@ -310,7 +310,7 @@ string Display::OpenXmlFileDialog(const std::string& default_dir) const { } /// Popup ROOT file chooser. returns chosen file name; empty on cancel -string Display::OpenEventFileDialog(const std::string& default_dir) const { +std::string Display::OpenEventFileDialog(const std::string& default_dir) const { static const char *evtFiletypes[] = { "ROOT files", "*.root", "SLCIO files", "*.slcio", @@ -348,7 +348,7 @@ void Display::BuildMenus(TGMenuBar* menubar) { TFile* Display::Open(const char* name) const { TFile* f = TFile::Open(name); if ( f && !f->IsZombie() ) return f; - throw runtime_error("+++ Failed to open ROOT file:"+string(name)); + throw std::runtime_error("+++ Failed to open ROOT file:"+std::string(name)); } /// Consumer event data @@ -358,7 +358,7 @@ void Display::OnFileOpen(EventHandler& /* handler */ ) { /// Consumer event data void Display::OnNewEvent(EventHandler& handler ) { typedef EventHandler::TypedEventCollections Types; - typedef vector Collections; + typedef std::vector Collections; const Types& types = handler.data(); TEveElement* particles = 0; @@ -477,7 +477,7 @@ TEveElementList& Display::GetGeoTopic(const std::string& name) { TEveElementList& Display::GetGeoTopic(const std::string& name) const { Topics::const_iterator i=m_geoTopics.find(name); if ( i == m_geoTopics.end() ) { - throw runtime_error("Display: Attempt to access non-existing geometry topic:"+name); + throw std::runtime_error("Display: Attempt to access non-existing geometry topic:"+name); } return *((*i).second); } @@ -498,7 +498,7 @@ TEveElementList& Display::GetEveTopic(const std::string& name) { TEveElementList& Display::GetEveTopic(const std::string& name) const { Topics::const_iterator i=m_eveTopics.find(name); if ( i == m_eveTopics.end() ) { - throw runtime_error("Display: Attempt to access non-existing event topic:"+name); + throw std::runtime_error("Display: Attempt to access non-existing event topic:"+name); } return *((*i).second); } @@ -542,7 +542,7 @@ void Display::LoadGeoChildren(TEveElement* start, int levels, bool redraw) { DetElement de = (*i).second; SensitiveDetector sd = m_detDesc->sensitiveDetector(de.name()); TEveElementList& parent = sd.isValid() ? sens : struc; - pair e = Utilities::LoadDetElement(de,levels,&parent); + std::pair e = Utilities::LoadDetElement(de,levels,&parent); if ( e.second && e.first ) { parent.AddElement(e.second); } @@ -556,7 +556,7 @@ void Display::LoadGeoChildren(TEveElement* start, int levels, bool redraw) { const char* node_name = n->GetName(); int level = Utilities::findNodeWithMatrix(detectorDescription().world().placement().ptr(),n,&mat); if ( level > 0 ) { - pair e(false,0); + std::pair e(false,0); const DetElement::Children& c = world.children(); for (DetElement::Children::const_iterator i = c.begin(); i != c.end(); ++i) { DetElement de = (*i).second; diff --git a/DDEve/src/DisplayConfiguration.cpp b/DDEve/src/DisplayConfiguration.cpp index 463480aa3..a05e3518e 100644 --- a/DDEve/src/DisplayConfiguration.cpp +++ b/DDEve/src/DisplayConfiguration.cpp @@ -12,7 +12,7 @@ //========================================================================== // Framework include files -#include "DDEve/DisplayConfiguration.h" +#include // C/C++ include files #include diff --git a/DDEve/src/DisplayConfigurationParser.cpp b/DDEve/src/DisplayConfigurationParser.cpp index 1fc3dca70..acd757b07 100644 --- a/DDEve/src/DisplayConfigurationParser.cpp +++ b/DDEve/src/DisplayConfigurationParser.cpp @@ -12,24 +12,22 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/DetectorLoad.h" -#include "DD4hep/Printout.h" -#include "XML/Conversions.h" -#include "XML/XMLElements.h" -#include "XML/DocumentHandler.h" -#include "DD4hep/DetFactoryHelper.h" +#include +#include +#include +#include +#include +#include +#include -#include "DDEve/Display.h" -#include "DDEve/DisplayConfiguration.h" +#include +#include // C/C++ include files #include -using namespace std; using namespace dd4hep; - namespace dd4hep { namespace { /// Some utility class to specialize the convetrers: class ddeve; @@ -81,7 +79,7 @@ namespace { } static void extract(DisplayConfiguration::Config& c, xml_h e, int typ) { - c.name = e.attr(_U(name)); + c.name = e.attr(_U(name)); c.type = typ; c.data.defaults.show_evt = e.hasAttr(u_show_evt) ? e.attr(u_show_evt) : 1; c.data.defaults.load_geo = e.hasAttr(u_load_geo) ? e.attr(u_load_geo) : -1; @@ -91,8 +89,8 @@ static void extract(DisplayConfiguration::Config& c, xml_h e, int typ) { c.data.calo3d.towerH = e.hasAttr(u_towerH) ? e.attr(u_towerH) : 25.0; if ( e.hasAttr(_U(dz)) ) c.data.calo3d.dz = e.attr(_U(dz)); if ( e.hasAttr(_U(rmin)) ) c.data.calo3d.rmin = e.attr(_U(rmin)); - if ( e.hasAttr(u_use) ) c.use = e.attr(u_use); - if ( e.hasAttr(u_hits) ) c.hits = e.attr(u_hits); + if ( e.hasAttr(u_use) ) c.use = e.attr(u_use); + if ( e.hasAttr(u_hits) ) c.hits = e.attr(u_hits); if ( e.hasAttr(_U(threshold)) ) c.data.calo3d.threshold = e.attr(_U(threshold)); } @@ -126,15 +124,15 @@ template <> void Converter::operator()(xml_h e) const { template <> void Converter::operator()(xml_h e) const { Configurations* configs = (Configurations*)param; DisplayConfiguration::Config c; - c.name = e.attr(_U(name)); + c.name = e.attr(_U(name)); c.type = DisplayConfiguration::COLLECTION; c.data.hits.color = e.hasAttr(_U(color)) ? e.attr(_U(color)) : 0xBBBBBB; c.data.hits.alpha = e.hasAttr(_U(alpha)) ? e.attr(_U(alpha)) : -1.0; c.data.hits.emax = e.hasAttr(u_emax) ? e.attr(u_emax) : 25.0; c.data.hits.towerH = e.hasAttr(u_towerH) ? e.attr(u_towerH) : 25.0; c.data.hits.threshold = e.hasAttr(_U(threshold)) ? e.attr(_U(threshold)) : 0.0; - if ( e.hasAttr(u_hits) ) c.hits = e.attr(u_hits); - if ( e.hasAttr(u_use) ) c.use = e.attr(u_use); + if ( e.hasAttr(u_hits) ) c.hits = e.attr(u_hits); + if ( e.hasAttr(u_use) ) c.use = e.attr(u_use); configs->push_back(c); } @@ -153,8 +151,8 @@ template <> void Converter::operator()(xml_h e) const { ViewConfigurations* configs = (ViewConfigurations*)param; DisplayConfiguration::ViewConfig c; extract(c,e,DisplayConfiguration::VIEW); - c.name = e.attr(_U(name)); - c.type = e.attr(_U(type)); + c.name = e.attr(_U(name)); + c.type = e.attr(_U(type)); c.show_structure = e.hasAttr(_U(structure)) ? e.attr(_U(structure)) : true; c.show_sensitive = e.hasAttr(_U(sensitive)) ? e.attr(_U(sensitive)) : true; printout(INFO,"DisplayConfiguration","+++ View: %s sensitive:%d structure:%d.", @@ -180,14 +178,14 @@ template <> void Converter::operator()(xml_h e) const { template <> void Converter::operator()(xml_h e) const { Configurations* configs = (Configurations*)param; DisplayConfiguration::Config c; - c.name = e.attr(_U(name)); + c.name = e.attr(_U(name)); c.type = DisplayConfiguration::CALODATA; if ( e.hasAttr(u_use) ) { - c.use = e.attr(u_use); - c.hits = e.attr(u_hits); + c.use = e.attr(u_use); + c.hits = e.attr(u_hits); } else { - c.hits = e.attr(u_hits); + c.hits = e.attr(u_hits); c.data.calodata.n_eta = e.attr(u_n_eta); c.data.calodata.eta_min = e.attr(u_eta_min); c.data.calodata.eta_max = e.attr(u_eta_max); @@ -219,10 +217,10 @@ template <> void Converter::operator()(xml_h e) const { template <> void Converter::operator()(xml_h e) const { Configurations* configs = (Configurations*)param; DisplayConfiguration::Config c; - c.name = e.attr(_U(name)); - c.hits = e.attr(u_hits); + c.name = e.attr(_U(name)); + c.hits = e.attr(u_hits); c.type = DisplayConfiguration::COLLECTION; - c.use = e.hasAttr(u_use) ? e.attr(u_use) : string(); + c.use = e.hasAttr(u_use) ? e.attr(u_use) : std::string(); c.data.hits.size = e.attr(_U(size)); c.data.hits.type = e.attr(_U(type)); c.data.hits.color = e.hasAttr(_U(color)) ? e.attr(_U(color)) : kRed; @@ -249,7 +247,7 @@ template <> void Converter::operator()(xml_h e) const { if ( e ) { DetectorLoad* load = dynamic_cast(&this->description); if ( load ) { - load->processXML(e,e.attr(_U(ref))); + load->processXML(e,e.attr(_U(ref))); return; } except("DisplayConfiguration","++ Invalid DetectorLoad instance in XML converter "); @@ -298,7 +296,7 @@ template <> void Converter::operator()(xml_h e) const { disp->ImportConfiguration(cfg); } -#include "TEveProjections.h" +#include /** Basic entry point to read display configuration files * * @author M.Frank diff --git a/DDEve/src/ElementList.cpp b/DDEve/src/ElementList.cpp index 6f0f040a3..caaaa5ed5 100644 --- a/DDEve/src/ElementList.cpp +++ b/DDEve/src/ElementList.cpp @@ -12,16 +12,15 @@ //========================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DDEve/EveUserContextMenu.h" -#include "DDEve/ElementList.h" +#include +#include +#include // ROOT include files // C/C++ include files #include -using namespace std; using namespace dd4hep; ClassImp(ElementList) diff --git a/DDEve/src/EvePgonSetProjectedContextMenu.cpp b/DDEve/src/EvePgonSetProjectedContextMenu.cpp index f27a301ee..a7f3dc858 100644 --- a/DDEve/src/EvePgonSetProjectedContextMenu.cpp +++ b/DDEve/src/EvePgonSetProjectedContextMenu.cpp @@ -12,16 +12,15 @@ //========================================================================== // Framework include files -#include "DDEve/ContextMenu.h" -#include "DDEve/EvePgonSetProjectedContextMenu.h" +#include +#include // ROOT include files -#include "TEvePolygonSetProjected.h" +#include // C/C++ include files #include -using namespace std; using namespace dd4hep; ClassImp(EvePgonSetProjectedContextMenu) diff --git a/DDEve/src/EveShapeContextMenu.cpp b/DDEve/src/EveShapeContextMenu.cpp index c2399a509..ef84f9920 100644 --- a/DDEve/src/EveShapeContextMenu.cpp +++ b/DDEve/src/EveShapeContextMenu.cpp @@ -12,17 +12,16 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DDEve/EveShapeContextMenu.h" +#include +#include // ROOT include files -#include "TEveGeoShape.h" -#include "TEveManager.h" +#include +#include // C/C++ include files #include -using namespace std; using namespace dd4hep; ClassImp(EveShapeContextMenu) diff --git a/DDEve/src/EveUserContextMenu.cpp b/DDEve/src/EveUserContextMenu.cpp index c6aaea7b3..e84af8562 100644 --- a/DDEve/src/EveUserContextMenu.cpp +++ b/DDEve/src/EveUserContextMenu.cpp @@ -12,19 +12,18 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DDEve/Display.h" -#include "DDEve/ContextMenu.h" -#include "DDEve/EveUserContextMenu.h" +#include +#include +#include +#include // ROOT include files -#include "TEveGeoShape.h" -#include "TEveManager.h" -#include "TEveElement.h" +#include +#include +#include // C/C++ include files -using namespace std; using namespace dd4hep; ClassImp(EveUserContextMenu) diff --git a/DDEve/src/EventControl.cpp b/DDEve/src/EventControl.cpp index d7824397b..37c36cc1b 100644 --- a/DDEve/src/EventControl.cpp +++ b/DDEve/src/EventControl.cpp @@ -79,11 +79,6 @@ void EventControl::GotoEvent() { /// Open a new event data file bool EventControl::Open() { - // e- shots: - //m_display->eventHandler().Open("/home/frankm/SW/DD4hep_head_dbg.root_v5.34.10/build/CLICSiD_2014-06-10_15-26.root"); - // pi- shots: - //m_display->eventHandler().Open("/home/frankm/SW/DD4hep_head_dbg.root_v5.34.10/build/CLICSiD_2014-06-18_12-48.root"); - std::string fname = m_display->OpenEventFileDialog("."); if ( !fname.empty() ) { return m_display->eventHandler().Open(m_display->getEventHandlerName(),fname); diff --git a/DDEve/src/EventHandler.cpp b/DDEve/src/EventHandler.cpp index efb4bd008..62ad39ced 100644 --- a/DDEve/src/EventHandler.cpp +++ b/DDEve/src/EventHandler.cpp @@ -12,7 +12,7 @@ //========================================================================== // Framework include files -#include "DDEve/EventHandler.h" +#include using namespace dd4hep; diff --git a/DDEve/src/FrameControl.cpp b/DDEve/src/FrameControl.cpp index 5ffc54a89..65161dc5b 100644 --- a/DDEve/src/FrameControl.cpp +++ b/DDEve/src/FrameControl.cpp @@ -12,8 +12,8 @@ //========================================================================== // Framework include files -#include "DDEve/FrameControl.h" -#include "DD4hep/Printout.h" +#include +#include // ROOT include files #include @@ -22,7 +22,6 @@ #include -using namespace std; using namespace dd4hep; ClassImp(FrameControl) diff --git a/DDEve/src/GenericEventHandler.cpp b/DDEve/src/GenericEventHandler.cpp index df213fa74..35c8004de 100644 --- a/DDEve/src/GenericEventHandler.cpp +++ b/DDEve/src/GenericEventHandler.cpp @@ -24,7 +24,6 @@ #include #include -using namespace std; using namespace dd4hep; ClassImp(GenericEventHandler) @@ -43,7 +42,7 @@ EventHandler* GenericEventHandler::current() const { if ( m_current ) { return m_current; } - throw runtime_error("Invalid event handler"); + throw std::runtime_error("Invalid event handler"); } /// Notfy all subscribers @@ -69,7 +68,7 @@ long GenericEventHandler::numEvents() const { } /// Access the data source name -string GenericEventHandler::datasourceName() const { +std::string GenericEventHandler::datasourceName() const { return current()->datasourceName(); } @@ -118,7 +117,7 @@ bool GenericEventHandler::Open(const std::string& file_type, const std::string& m_current = (EventHandler*)PluginService::Create("DD4hep_DDEve_DDG4EventHandler",(const char*)0); } else { - throw runtime_error("Attempt to open file:"+file_name+" of unknown type:"+file_type); + throw std::runtime_error("Attempt to open file:"+file_name+" of unknown type:"+file_type); } if ( m_current ) { if ( m_current->Open(file_type, file_name) ) { @@ -133,7 +132,7 @@ bool GenericEventHandler::Open(const std::string& file_type, const std::string& err = "+++ Failed to create fikle reader for file '"+file_name+"' of type '"+file_type+"'"; } } - catch(const exception& e) { + catch(const std::exception& e) { err = "\nAn exception occurred \n" "while opening event data:\n" + std::string(e.what()) + "\n\n"; } @@ -155,9 +154,9 @@ bool GenericEventHandler::NextEvent() { return 1; } } - throw runtime_error("+++ EventHandler::readEvent: No file open!"); + throw std::runtime_error("+++ EventHandler::readEvent: No file open!"); } - catch(const exception& e) { + catch(const std::exception& e) { std::string path = TString::Format("%s/stop_t.xpm", TROOT::GetIconPath().Data()).Data(); std::string err = "\nAn exception occurred \n" "while reading a new event:\n" + std::string(e.what()) + "\n\n"; diff --git a/DDEve/src/HitActors.cpp b/DDEve/src/HitActors.cpp index 182aa090c..f48c47112 100644 --- a/DDEve/src/HitActors.cpp +++ b/DDEve/src/HitActors.cpp @@ -12,18 +12,17 @@ //========================================================================== // Framework include files -#include "DDEve/HitActors.h" -#include "DD4hep/Objects.h" -#include "DD4hep/DD4hepUnits.h" +#include +#include +#include // ROOT include files -#include "TH2.h" -#include "TVector3.h" -#include "TEveBoxSet.h" -#include "TEvePointSet.h" -#include "TEveCompound.h" +#include +#include +#include +#include +#include -using namespace std; using namespace dd4hep; #ifdef DD4HEP_USE_GEANT4_UNITS @@ -125,7 +124,8 @@ TEveElement* BoxsetCreator::element() const { void BoxsetCreator::operator()(const DDEveHit& hit) { double ene = hit.deposit*MEV_2_GEV <= emax ? hit.deposit*MEV_2_GEV : emax; TVector3 scale(ene/towerH,ene/towerH,ene/towerH); - cout << "Hit:" << ene << " deposit:" << hit.deposit << " " << " emax:" << emax << " towerH:" << towerH << endl; + std::cout << "Hit:" << ene << " deposit:" << hit.deposit << " " + << " emax:" << emax << " towerH:" << towerH << std::endl; TVector3 p(hit.x*MM_2_CM, hit.y*MM_2_CM, hit.z*MM_2_CM); double phi = p.Phi(); float s1X = -0.5*(scale(0)*std::sin(phi)+scale(2)*std::cos(phi)); diff --git a/DDEve/src/MultiView.cpp b/DDEve/src/MultiView.cpp index e7723d05d..afc421dfc 100644 --- a/DDEve/src/MultiView.cpp +++ b/DDEve/src/MultiView.cpp @@ -12,14 +12,13 @@ //========================================================================== // Framework include files -#include "DDEve/MultiView.h" -#include "DDEve/Factories.h" -#include "DDEve/DisplayConfiguration.h" -#include "DD4hep/Plugins.h" +#include +#include +#include +#include #include -using namespace std; using namespace dd4hep; ClassImp(MultiView) @@ -35,7 +34,7 @@ static void _build(Display* display, View* v, TEveWindowSlot* slot) { } /// Initializing constructor -MultiView::MultiView(Display* eve, const string& nam) : View(eve, nam) +MultiView::MultiView(Display* eve, const std::string& nam) : View(eve, nam) { } @@ -72,7 +71,7 @@ View& MultiView::Build(TEveWindow* slot) { /// First panel if ( panels.size()>0) { const DisplayConfiguration::Config& cfg = panels[0]; - string typ = "DD4hep_DDEve_"+cfg.use; + std::string typ = "DD4hep_DDEve_"+cfg.use; v = PluginService::Create(typ.c_str(),m_eve,cfg.name.c_str()); } else { @@ -84,7 +83,7 @@ View& MultiView::Build(TEveWindow* slot) { /// Second panel if ( panels.size()>1) { const DisplayConfiguration::Config& cfg = panels[1]; - string typ = "DD4hep_DDEve_"+cfg.use; + std::string typ = "DD4hep_DDEve_"+cfg.use; v = PluginService::Create(typ.c_str(),m_eve,cfg.name.c_str()); } else { diff --git a/DDEve/src/ParticleActors.cpp b/DDEve/src/ParticleActors.cpp index b4b1ed5e3..71b5f0284 100644 --- a/DDEve/src/ParticleActors.cpp +++ b/DDEve/src/ParticleActors.cpp @@ -12,22 +12,21 @@ //========================================================================== // Framework include files -#include "DDEve/ParticleActors.h" -#include "DD4hep/DD4hepUnits.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Objects.h" - -#include "TEveTrack.h" -#include "TEveBoxSet.h" -#include "TEvePointSet.h" -#include "TEveCompound.h" -#include "TEveTrackPropagator.h" - -#include "TParticle.h" -#include "TDatabasePDG.h" -#include "TGeoManager.h" - -using namespace std; +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + using namespace dd4hep; #ifdef DD4HEP_USE_GEANT4_UNITS diff --git a/DDEve/src/PopupMenu.cpp b/DDEve/src/PopupMenu.cpp index 1dd5e186d..6fabf8d30 100644 --- a/DDEve/src/PopupMenu.cpp +++ b/DDEve/src/PopupMenu.cpp @@ -12,9 +12,9 @@ //========================================================================== // Framework include files -#include "DDEve/PopupMenu.h" -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" +#include +#include +#include // C/C++ include files diff --git a/DDEve/src/Projection.cpp b/DDEve/src/Projection.cpp index ef7279d0f..86c3a7ffa 100644 --- a/DDEve/src/Projection.cpp +++ b/DDEve/src/Projection.cpp @@ -12,10 +12,10 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DDEve/Projection.h" -#include "DDEve/Display.h" -#include "DDEve/Utilities.h" +#include +#include +#include +#include // Eve include files #include @@ -23,11 +23,10 @@ #include #include -using namespace std; using namespace dd4hep; /// Initializing constructor -Projection::Projection(Display* eve, const string& nam) +Projection::Projection(Display* eve, const std::string& nam) : View(eve, nam), m_projMgr(0), m_axis(0) { } diff --git a/DDEve/src/RhoPhiProjection.cpp b/DDEve/src/RhoPhiProjection.cpp index 4d1c3356a..8d3170417 100644 --- a/DDEve/src/RhoPhiProjection.cpp +++ b/DDEve/src/RhoPhiProjection.cpp @@ -13,8 +13,8 @@ //========================================================================== // Framework include files -#include "DDEve/RhoPhiProjection.h" -#include "DDEve/Factories.h" +#include +#include using namespace dd4hep; diff --git a/DDEve/src/RhoZProjection.cpp b/DDEve/src/RhoZProjection.cpp index a273b56a2..7e83a4e89 100644 --- a/DDEve/src/RhoZProjection.cpp +++ b/DDEve/src/RhoZProjection.cpp @@ -13,8 +13,8 @@ //========================================================================== // Framework include files -#include "DDEve/RhoZProjection.h" -#include "DDEve/Factories.h" +#include +#include using namespace dd4hep; diff --git a/DDEve/src/Utilities.cpp b/DDEve/src/Utilities.cpp index f5d3d09a0..2019f309f 100644 --- a/DDEve/src/Utilities.cpp +++ b/DDEve/src/Utilities.cpp @@ -12,28 +12,26 @@ //========================================================================== // Framework include files -#include "DD4hep/Objects.h" -#include "DD4hep/DetElement.h" -#include "DD4hep/Volumes.h" -#include "DD4hep/Printout.h" -#include "DDEve/Utilities.h" -#include "DDEve/EventHandler.h" -#include "DDEve/ElementList.h" +#include +#include +#include +#include +#include +#include +#include -#include "TGeoNode.h" -#include "TGeoShape.h" -#include "TGeoVolume.h" -#include "TGeoManager.h" -#include "TGeoShapeAssembly.h" +#include +#include +#include +#include +#include -#include "TEveGeoShape.h" -#include "TEveGeoNode.h" -#include "TEveElement.h" -#include "TEveTrans.h" +#include +#include +#include +#include using namespace dd4hep; -using namespace dd4hep::detail; -using namespace std; /// Set the rendering flags for the object and the next level children void Utilities::SetRnrChildren(TEveElementList* l, bool b) { @@ -84,7 +82,7 @@ Utilities::createEveShape(int level, TGeoVolume* vol = n ? n->GetVolume() : 0; bool created = false; - if ( 0 == vol || level > max_level ) return make_pair(created,(TEveElement*)0); + if ( 0 == vol || level > max_level ) return std::make_pair(created,(TEveElement*)0); VisAttr vis(Volume(vol).visAttributes()); TGeoShape* geoShape = vol->GetShape(); @@ -154,20 +152,20 @@ Utilities::createEveShape(int level, TGeoHMatrix dau_mat(mat); TGeoMatrix* matrix = daughter->GetMatrix(); dau_mat.Multiply(matrix); - pair dau_shape = + std::pair dau_shape = createEveShape(level+1, max_level, element, daughter, dau_mat, daughter->GetName()); if ( dau_shape.first ) { element->AddElement(dau_shape.second); } } - return make_pair(created,element); + return std::make_pair(created,element); } -int Utilities::findNodeWithMatrix(TGeoNode* p, TGeoNode* n, TGeoHMatrix* mat, string* sub_path) { +int Utilities::findNodeWithMatrix(TGeoNode* p, TGeoNode* n, TGeoHMatrix* mat, std::string* sub_path) { if ( p == n ) return 1; TGeoHMatrix dau_mat; for (Int_t idau = 0, ndau = p->GetNdaughters(); idau < ndau; ++idau) { - string spath; + std::string spath; TGeoNode* daughter = p->GetDaughter(idau); TGeoHMatrix* daughter_matrix = 0; if ( mat ) { @@ -203,5 +201,5 @@ std::pair Utilities::LoadDetElement(DetElement de,int levels, return e; } } - return make_pair(false,(TEveGeoShape*)0); + return std::make_pair(false,(TEveGeoShape*)0); } diff --git a/DDEve/src/View.cpp b/DDEve/src/View.cpp index dd5de569e..8a17f379b 100644 --- a/DDEve/src/View.cpp +++ b/DDEve/src/View.cpp @@ -13,12 +13,12 @@ //========================================================================== // Framework include files -#include "DDEve/View.h" -#include "DDEve/Display.h" -#include "DDEve/ElementList.h" -#include "DDEve/Utilities.h" -#include "DDEve/Annotation.h" -#include "DD4hep/InstanceCount.h" +#include +#include +#include +#include +#include +#include // Eve include files #include @@ -26,18 +26,17 @@ #include #include -using namespace std; using namespace dd4hep; template -static inline typename T::const_iterator find(const T& cont,const string& str) { +static inline typename T::const_iterator find(const T& cont,const std::string& str) { for(typename T::const_iterator i=cont.begin(); i!=cont.end(); ++i) if ( (*i).name == str ) return i; return cont.end(); } /// Initializing constructor -View::View(Display* eve, const string& nam) +View::View(Display* eve, const std::string& nam) : m_eve(eve), m_view(0), m_geoScene(0), m_eveScene(0), m_global(0), m_name(nam), m_showGlobal(false) { m_config = m_eve->GetViewConfiguration(m_name); @@ -79,7 +78,7 @@ void View::Initialize() { } /// Add the view to the global list of eve objects -TEveElementList* View::AddToGlobalItems(const string& nam) { +TEveElementList* View::AddToGlobalItems(const std::string& nam) { if ( 0 == m_global ) { m_global = new ElementList(nam.c_str(), nam.c_str(), true, true); if ( m_geoScene ) m_global->AddElement(geoScene()); @@ -119,16 +118,16 @@ TEveElement* View::ImportEventElement(TEveElement* el, TEveElementList* list) { } /// Access the global instance of the subdetector geometry -pair +std::pair View::GetGlobalGeometry(DetElement de, const DisplayConfiguration::Config& /* cfg */) { SensitiveDetector sd = m_eve->detectorDescription().sensitiveDetector(de.name()); TEveElementList& global = m_eve->GetGeoTopic(sd.isValid() ? "Sensitive" : "Structure"); TEveElement* elt = global.FindChild(de.name()); - return pair(true,elt); + return std::pair(true,elt); } /// Create a new instance of the geometry of a sub-detector -pair +std::pair View::CreateGeometry(DetElement de, const DisplayConfiguration::Config& cfg) { SensitiveDetector sd = m_eve->detectorDescription().sensitiveDetector(de.name()); TEveElementList& topic = GetGeoTopic(sd.isValid() ? "Sensitive" : "Structure"); @@ -157,14 +156,14 @@ void View::ConfigureGeometryFromGlobal() { /// Configure a single geometry view void View::ConfigureGeometry(const DisplayConfiguration::ViewConfig& config) { - string dets; + std::string dets; DisplayConfiguration::Configurations::const_iterator ic; float legend_y = Annotation::DefaultTextSize()+Annotation::DefaultMargin(); DetElement world = m_eve->detectorDescription().world(); const DetElement::Children& c = world.children(); for( ic=config.subdetectors.begin(); ic != config.subdetectors.end(); ++ic) { const DisplayConfiguration::Config& cfg = *ic; - string nam = cfg.name; + std::string nam = cfg.name; if ( nam == "global" ) { m_view->AddScene(m_eve->manager().GetGlobalScene()); m_view->AddScene(m_eve->manager().GetEventScene()); @@ -186,7 +185,7 @@ void View::ConfigureGeometry(const DisplayConfiguration::ViewConfig& config) DetElement de = (*i).second; SensitiveDetector sd = m_eve->detectorDescription().sensitiveDetector(nam); TEveElementList& topic = GetGeoTopic(sd.isValid() ? "Sensitive" : "Structure"); - pair e(false,0); + std::pair e(false,0); if ( cfg.data.defaults.load_geo > 0 ) // Create a new instance e = CreateGeometry(de,cfg); // with the given number of levels else if ( cfg.data.defaults.load_geo < 0 ) // Use the global geometry instance @@ -203,7 +202,7 @@ void View::ConfigureGeometry(const DisplayConfiguration::ViewConfig& config) } /// Call to import geometry topics -void View::ImportGeoTopics(const string& title) { +void View::ImportGeoTopics(const std::string& title) { printout(INFO,"View","+++ %s: Import geometry topics.",c_name()); for(Topics::iterator i=m_geoTopics.begin(); i!=m_geoTopics.end(); ++i) { printout(INFO,"ViewConfiguration","+++ Add topic %s",(*i).second->GetName()); @@ -213,7 +212,7 @@ void View::ImportGeoTopics(const string& title) { } /// Call to import geometry elements by topic -void View::ImportGeo(const string& topic, TEveElement* element) { +void View::ImportGeo(const std::string& topic, TEveElement* element) { ImportGeoElement(element,&GetGeoTopic(topic)); } @@ -248,7 +247,7 @@ void View::ConfigureEvent(const DisplayConfiguration::ViewConfig& config) { DisplayConfiguration::Configurations::const_iterator ic; for( ic=config.subdetectors.begin(); ic != config.subdetectors.end(); ++ic) { const DisplayConfiguration::Config& cfg = *ic; - string nam = cfg.name; + std::string nam = cfg.name; if ( nam == "global" ) { continue; } @@ -293,7 +292,7 @@ void View::ImportEvent(TEveElement* el) { } /// Access/Create a topic by name -TEveElementList& View::GetGeoTopic(const string& nam) { +TEveElementList& View::GetGeoTopic(const std::string& nam) { Topics::iterator i=m_geoTopics.find(nam); if ( i == m_geoTopics.end() ) { TEveElementList* topic = new ElementList(nam.c_str(), nam.c_str(), true, true); @@ -314,8 +313,8 @@ View& View::CreateScenes() { /// Create the event scene View& View::CreateEventScene() { if ( 0 == m_eveScene ) { - string nam = m_name+" - Event Data"; - string tool = m_name+" - Scene holding projected event-data for the view."; + std::string nam = m_name+" - Event Data"; + std::string tool = m_name+" - Scene holding projected event-data for the view."; m_eveScene = m_eve->manager().SpawnNewScene(nam.c_str(), tool.c_str()); } return *this; @@ -324,8 +323,8 @@ View& View::CreateEventScene() { /// Create the geometry scene View& View::CreateGeoScene() { if ( 0 == m_geoScene ) { - string nam = m_name+" - Geometry"; - string tool = m_name+" - Scene holding projected geometry for the view."; + std::string nam = m_name+" - Geometry"; + std::string tool = m_name+" - Scene holding projected geometry for the view."; m_geoScene = m_eve->manager().SpawnNewScene(nam.c_str(), tool.c_str()); } return *this; diff --git a/DDEve/src/View3D.cpp b/DDEve/src/View3D.cpp index 55f16fff7..c278fdad6 100644 --- a/DDEve/src/View3D.cpp +++ b/DDEve/src/View3D.cpp @@ -13,8 +13,8 @@ //========================================================================== // Framework include files -#include "DDEve/View3D.h" -#include "DDEve/Factories.h" +#include +#include using namespace dd4hep; diff --git a/DDEve/src/ViewMenu.cpp b/DDEve/src/ViewMenu.cpp index 3c9b5b66a..9be61b293 100644 --- a/DDEve/src/ViewMenu.cpp +++ b/DDEve/src/ViewMenu.cpp @@ -12,29 +12,29 @@ //========================================================================== // Framework include files -#include "DD4hep/Plugins.h" -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" +#include +#include +#include -#include "DDEve/View.h" -#include "DDEve/ViewMenu.h" -#include "DDEve/PopupMenu.h" +#include +#include +#include // ROOT include files -#include "TEveBrowser.h" -#include "TEveManager.h" -#include "TEveElement.h" -#include "TEveWindow.h" -#include "TEveViewer.h" -#include "TGLViewer.h" -#include "TGClient.h" -#include "TGTab.h" +#include +#include +#include +#include +#include +#include +#include +#include // Forward declarations class TEveWindowSlot; -using namespace std; using namespace dd4hep; +using pair_t = std::pair; ClassImp(ViewMenu) @@ -52,27 +52,27 @@ ViewMenu::~ViewMenu() { /// Add the menu to the menu bar void ViewMenu::Build(TGMenuBar* menubar, int hints) { - pair* p = 0; + pair_t* p = 0; PopupMenu* view_menu = this; - view_menu->AddEntry("3&D View", this, &ViewMenu::CreateView, p=new pair("DD4hep_DDEve_View3D","3D")); - view_menu->AddEntry("Rho-&Z Projection", this, &ViewMenu::CreateView, p=new pair("DD4hep_DDEve_RhoZProjection","Rho-Z")); - view_menu->AddEntry("Rho-&Phi Projection",this, &ViewMenu::CreateView, p=new pair("DD4hep_DDEve_RhoPhiProjection","Rho-Phi")); + view_menu->AddEntry("3&D View", this, &ViewMenu::CreateView, p=new pair_t("DD4hep_DDEve_View3D","3D")); + view_menu->AddEntry("Rho-&Z Projection", this, &ViewMenu::CreateView, p=new pair_t("DD4hep_DDEve_RhoZProjection","Rho-Z")); + view_menu->AddEntry("Rho-&Phi Projection",this, &ViewMenu::CreateView, p=new pair_t("DD4hep_DDEve_RhoPhiProjection","Rho-Phi")); const Display::ViewConfigurations& vc = m_display->viewConfigurations(); for(Display::ViewConfigurations::const_iterator i=vc.begin(); i!=vc.end(); ++i) { const Display::ViewConfig& v = (*i).second; - view_menu->AddEntry(v.name.c_str(), this, &ViewMenu::CreateView,p=new pair("DD4hep_DDEve_"+v.type,v.name)); + view_menu->AddEntry(v.name.c_str(), this, &ViewMenu::CreateView,p=new pair_t("DD4hep_DDEve_"+v.type,v.name)); } menubar->AddPopup(m_title.c_str(),*view_menu, new TGLayoutHints(hints, 0, 4, 0, 0)); } /// Create a new generic view void ViewMenu::CreateView(TGMenuEntry*, void* ud) { - pair* args = (pair*)ud; + pair_t* args = (pair_t*)ud; CreateView(args->first,args->second); } View* ViewMenu::CreateView(const std::string& type, const std::string& title) { - pair args("DD4hep_DDEve_"+type,title); + pair_t args("DD4hep_DDEve_"+type,title); View* v = PluginService::Create(type.c_str(),m_display,title.c_str()); BuildView(v); return v; From 33bd368a14b48259d00603070ad0c56b4cee1915 Mon Sep 17 00:00:00 2001 From: Markus Frank Date: Thu, 8 Feb 2024 10:13:59 +0100 Subject: [PATCH 05/14] Suppress default use of std namespace --- DDG4/src/EventParameters.cpp | 2 ++ DDG4/src/Geant4Action.cpp | 53 +++++++++++++++--------------- DDG4/src/Geant4ActionContainer.cpp | 37 ++++++++++----------- DDG4/src/Geant4ActionPhase.cpp | 23 +++++++------ DDG4/src/Geant4AssemblyVolume.cpp | 14 ++++---- DDG4/src/Geant4Call.cpp | 2 +- DDG4/src/Geant4Context.cpp | 13 ++++---- 7 files changed, 71 insertions(+), 73 deletions(-) diff --git a/DDG4/src/EventParameters.cpp b/DDG4/src/EventParameters.cpp index 0596e5a56..5a52e0da2 100644 --- a/DDG4/src/EventParameters.cpp +++ b/DDG4/src/EventParameters.cpp @@ -10,8 +10,10 @@ // //==================================================================== +/// Framework include files #include "DDG4/EventParameters.h" +/// C/C++ include files #include #include diff --git a/DDG4/src/Geant4Action.cpp b/DDG4/src/Geant4Action.cpp index 2b7660298..9902863e3 100644 --- a/DDG4/src/Geant4Action.cpp +++ b/DDG4/src/Geant4Action.cpp @@ -12,34 +12,33 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4Context.h" -#include "DDG4/Geant4Action.h" -#include "DDG4/Geant4Kernel.h" -#include "DDG4/Geant4UIMessenger.h" +#include +#include +#include +#include +#include +#include // Geant4 include files -#include "G4UIdirectory.hh" +#include // C/C++ include files #include -using namespace std; using namespace dd4hep; using namespace dd4hep::sim; -TypeName TypeName::split(const string& type_name, const string& delim) { +TypeName TypeName::split(const std::string& type_name, const std::string& delim) { size_t idx = type_name.find(delim); - string typ = type_name, nam = type_name; - if (idx != string::npos) { + std::string typ = type_name, nam = type_name; + if (idx != std::string::npos) { typ = type_name.substr(0, idx); nam = type_name.substr(idx + 1); } return TypeName(typ, nam); } -TypeName TypeName::split(const string& type_name) { +TypeName TypeName::split(const std::string& type_name) { return split(type_name,"/"); } #if 0 @@ -53,7 +52,7 @@ void Geant4Action::ContextUpdate::operator()(Geant4Action* action) const { } #endif /// Standard constructor -Geant4Action::Geant4Action(Geant4Context* ctxt, const string& nam) +Geant4Action::Geant4Action(Geant4Context* ctxt, const std::string& nam) : m_context(ctxt), m_control(0), m_outputLevel(INFO), m_needsControl(false), m_name(nam), m_refCount(1) { @@ -94,12 +93,12 @@ PrintLevel Geant4Action::setOutputLevel(PrintLevel new_level) { } /// Check property for existence -bool Geant4Action::hasProperty(const string& nam) const { +bool Geant4Action::hasProperty(const std::string& nam) const { return m_properties.exists(nam); } /// Access single property -Property& Geant4Action::property(const string& nam) { +Property& Geant4Action::property(const std::string& nam) { return properties()[nam]; } @@ -107,7 +106,7 @@ Property& Geant4Action::property(const string& nam) { void Geant4Action::installMessengers() { //m_needsControl = true; if (m_needsControl && !m_control) { - string path = context()->kernel().directoryName(); + std::string path = context()->kernel().directoryName(); path += name() + "/"; m_control = new Geant4UIMessenger(name(), path); installPropertyMessenger(); @@ -145,7 +144,7 @@ void Geant4Action::configureFiber(Geant4Context* /* thread_context */) { /// Support for messages with variable output level using output level void Geant4Action::print(const char* fmt, ...) const { - int level = max(int(outputLevel()),(int)VERBOSE); + int level = std::max(int(outputLevel()),(int)VERBOSE); if ( level >= printLevel() ) { va_list args; va_start(args, fmt); @@ -156,7 +155,7 @@ void Geant4Action::print(const char* fmt, ...) const { /// Support for messages with variable output level using output level-1 void Geant4Action::printM1(const char* fmt, ...) const { - int level = max(outputLevel()-1,(int)VERBOSE); + int level = std::max(outputLevel()-1,(int)VERBOSE); if ( level >= printLevel() ) { va_list args; va_start(args, fmt); @@ -167,7 +166,7 @@ void Geant4Action::printM1(const char* fmt, ...) const { /// Support for messages with variable output level using output level-2 void Geant4Action::printM2(const char* fmt, ...) const { - int level = max(outputLevel()-2,(int)VERBOSE); + int level = std::max(outputLevel()-2,(int)VERBOSE); if ( level >= printLevel() ) { va_list args; va_start(args, fmt); @@ -178,7 +177,7 @@ void Geant4Action::printM2(const char* fmt, ...) const { /// Support for messages with variable output level using output level-1 void Geant4Action::printP1(const char* fmt, ...) const { - int level = min(outputLevel()+1,(int)FATAL); + int level = std::min(outputLevel()+1,(int)FATAL); if ( level >= printLevel() ) { va_list args; va_start(args, fmt); @@ -189,7 +188,7 @@ void Geant4Action::printP1(const char* fmt, ...) const { /// Support for messages with variable output level using output level-2 void Geant4Action::printP2(const char* fmt, ...) const { - int level = min(outputLevel()+2,(int)FATAL); + int level = std::min(outputLevel()+2,(int)FATAL); if ( level >= printLevel() ) { va_list args; va_start(args, fmt); @@ -259,22 +258,22 @@ void Geant4Action::fatal(const char* fmt, ...) const { void Geant4Action::except(const char* fmt, ...) const { va_list args; va_start(args, fmt); - string err = dd4hep::format(m_name, fmt, args); + std::string err = dd4hep::format(m_name, fmt, args); dd4hep::printout(dd4hep::FATAL, m_name, err.c_str()); va_end(args); - throw runtime_error(err); + throw std::runtime_error(err); } /// Abort Geant4 Run by throwing a G4Exception with type RunMustBeAborted -void Geant4Action::abortRun(const string& exception, const char* fmt, ...) const { - string desc, typ = typeName(typeid(*this)); - string issuer = name()+" ["+typ+"]"; +void Geant4Action::abortRun(const std::string& exception, const char* fmt, ...) const { + std::string desc, typ = typeName(typeid(*this)); + std::string issuer = name()+" ["+typ+"]"; va_list args; va_start(args, fmt); desc = dd4hep::format("*** Geant4Action:", fmt, args); va_end(args); G4Exception(issuer.c_str(),exception.c_str(),RunMustBeAborted,desc.c_str()); - //throw runtime_error(issuer+"> "+desc); + //throw std::runtime_error(issuer+"> "+desc); } /// Access to the main run action sequence from the kernel object diff --git a/DDG4/src/Geant4ActionContainer.cpp b/DDG4/src/Geant4ActionContainer.cpp index d6b23c73c..7fae8020d 100644 --- a/DDG4/src/Geant4ActionContainer.cpp +++ b/DDG4/src/Geant4ActionContainer.cpp @@ -12,27 +12,26 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/Primitives.h" -#include "DD4hep/InstanceCount.h" - -#include "DDG4/Geant4ActionContainer.h" -#include "DDG4/Geant4RunAction.h" -#include "DDG4/Geant4PhysicsList.h" -#include "DDG4/Geant4EventAction.h" -#include "DDG4/Geant4SteppingAction.h" -#include "DDG4/Geant4TrackingAction.h" -#include "DDG4/Geant4StackingAction.h" -#include "DDG4/Geant4GeneratorAction.h" -#include "DDG4/Geant4DetectorConstruction.h" -#include "DDG4/Geant4UserInitialization.h" -#include "DDG4/Geant4SensDetAction.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // C/C++ include files #include #include -using namespace std; using namespace dd4hep::sim; /// Standard constructor @@ -69,7 +68,7 @@ int Geant4ActionContainer::terminate() { Geant4Context* Geant4ActionContainer::workerContext() { if ( m_context ) return m_context; - throw runtime_error(format("Geant4Kernel", "DDG4: Master kernel object has no thread context! [Invalid Handle]")); + throw std::runtime_error(format("Geant4Kernel", "DDG4: Master kernel object has no thread context! [Invalid Handle]")); } /// Set the thread's context @@ -83,7 +82,7 @@ template bool Geant4ActionContainer::registerSequence(C*& seq, const s seq->installMessengers(); return true; } - throw runtime_error(format("Geant4ActionContainer", "DDG4: The action '%s' not found. [Action-NotFound]", name.c_str())); + throw std::runtime_error(format("Geant4ActionContainer", "DDG4: The action '%s' not found. [Action-NotFound]", name.c_str())); } /// Access generator action sequence @@ -141,7 +140,7 @@ Geant4SensDetSequences& Geant4ActionContainer::sensitiveActions() const { } /// Access to the sensitive detector action from the kernel object -Geant4SensDetActionSequence* Geant4ActionContainer::sensitiveAction(const string& nam) { +Geant4SensDetActionSequence* Geant4ActionContainer::sensitiveAction(const std::string& nam) { Geant4SensDetActionSequence* ptr = m_sensDetActions->find(nam); if (ptr) { return ptr; diff --git a/DDG4/src/Geant4ActionPhase.cpp b/DDG4/src/Geant4ActionPhase.cpp index 78f42f986..5d84e8c46 100644 --- a/DDG4/src/Geant4ActionPhase.cpp +++ b/DDG4/src/Geant4ActionPhase.cpp @@ -12,10 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4ActionPhase.h" +#include +#include -using namespace std; using namespace dd4hep::sim; /// Standard constructor @@ -37,8 +36,8 @@ dd4hep::Callback Geant4PhaseAction::callback() { } /// Standard constructor -Geant4ActionPhase::Geant4ActionPhase(Geant4Context* ctxt, const string& nam, const type_info& arg_type0, - const type_info& arg_type1, const type_info& arg_type2) +Geant4ActionPhase::Geant4ActionPhase(Geant4Context* ctxt, const std::string& nam, const std::type_info& arg_type0, + const std::type_info& arg_type1, const std::type_info& arg_type2) : Geant4Action(ctxt, nam) { m_argTypes[0] = &arg_type0; m_argTypes[1] = &arg_type1; @@ -64,7 +63,7 @@ bool Geant4ActionPhase::add(Geant4Action* action, Callback callback) { /// Remove an existing member from the phase. If not existing returns false bool Geant4ActionPhase::remove(Geant4Action* action, Callback callback) { if (action && callback.func.first) { - Members::iterator i = find(m_members.begin(), m_members.end(), make_pair(action,callback)); + Members::iterator i = find(m_members.begin(), m_members.end(), std::make_pair(action,callback)); if (i != m_members.end()) { (*i).first->release(); m_members.erase(i); @@ -92,12 +91,12 @@ void Geant4ActionPhase::execute(void* argument) { class G4HCofThisEvent; class G4TouchableHistory; -#include "DDG4/Geant4RunAction.h" -#include "DDG4/Geant4EventAction.h" -#include "DDG4/Geant4TrackingAction.h" -#include "DDG4/Geant4SteppingAction.h" -#include "DDG4/Geant4StackingAction.h" -#include "DDG4/Geant4GeneratorAction.h" +#include +#include +#include +#include +#include +#include namespace dd4hep { namespace sim { /// Callback in Begin stacking action diff --git a/DDG4/src/Geant4AssemblyVolume.cpp b/DDG4/src/Geant4AssemblyVolume.cpp index 5f0c2496e..6517b7e03 100644 --- a/DDG4/src/Geant4AssemblyVolume.cpp +++ b/DDG4/src/Geant4AssemblyVolume.cpp @@ -12,19 +12,19 @@ //========================================================================== /// Geant4 include files -#include "G4LogicalVolume.hh" -#include "G4VPhysicalVolume.hh" -#include "G4ReflectionFactory.hh" +#include +#include +#include /// C/C++ include files #include #include /// Framework include files -#include "DD4hep/DetectorTools.h" -#include "DDG4/Geant4Converter.h" -#include "DDG4/Geant4GeometryInfo.h" -#include "DDG4/Geant4AssemblyVolume.h" +#include +#include +#include +#include using namespace dd4hep::sim; diff --git a/DDG4/src/Geant4Call.cpp b/DDG4/src/Geant4Call.cpp index b204635dd..e5d6cf295 100644 --- a/DDG4/src/Geant4Call.cpp +++ b/DDG4/src/Geant4Call.cpp @@ -12,7 +12,7 @@ //========================================================================== // Framework include files -#include "DDG4/Geant4Call.h" +#include /// Default destructor (keep here to avoid weak linkage to vtable) dd4hep::sim::Geant4Call::~Geant4Call() { diff --git a/DDG4/src/Geant4Context.cpp b/DDG4/src/Geant4Context.cpp index fb3908341..95f0f84d4 100644 --- a/DDG4/src/Geant4Context.cpp +++ b/DDG4/src/Geant4Context.cpp @@ -12,15 +12,14 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4Context.h" -#include "DDG4/Geant4Kernel.h" +#include +#include +#include +#include // C/C++ include files #include -using namespace std; using namespace dd4hep; using namespace dd4hep::sim; @@ -101,9 +100,9 @@ Geant4Context::UserFramework& Geant4Context::userFramework() const { /// Create a user trajectory G4VTrajectory* Geant4Context::createTrajectory(const G4Track* /* track */) const { - string err = dd4hep::format("Geant4Kernel", "createTrajectory: Purely virtual method. requires overloading!"); + std::string err = dd4hep::format("Geant4Kernel", "createTrajectory: Purely virtual method. requires overloading!"); dd4hep::printout(dd4hep::FATAL, "Geant4Kernel", "createTrajectory: Purely virtual method. requires overloading!"); - throw runtime_error(err); + throw std::runtime_error(err); } /// Access the tracking manager From d5d9dea80c8bb7bc6b0d835c3a973f67ed3fb7cf Mon Sep 17 00:00:00 2001 From: Markus Frank Date: Thu, 8 Feb 2024 12:17:03 +0100 Subject: [PATCH 06/14] Remove support for very old versions of ROOT < 6.26.0. Remove default use of std namespace from some implementation files. --- DDCore/include/DD4hep/Objects.h | 40 ++- DDCore/include/DD4hep/OpticalSurfaceManager.h | 6 +- DDCore/include/DD4hep/OpticalSurfaces.h | 13 +- DDCore/include/DD4hep/PropertyTable.h | 10 +- DDCore/include/DD4hep/Shapes.h | 7 +- .../detail/OpticalSurfaceManagerInterna.h | 4 +- DDCore/include/DD4hep/detail/Plugins.inl | 2 +- DDCore/src/DetectorImp.cpp | 237 +++++++-------- DDCore/src/Handle.cpp | 233 +++++++------- DDCore/src/Objects.cpp | 153 +++++----- DDCore/src/OpticalSurfaceManager.cpp | 43 ++- DDCore/src/OpticalSurfaces.cpp | 29 +- DDCore/src/PropertyTable.cpp | 20 +- DDCore/src/ShapeUtilities.cpp | 240 +++++++-------- DDCore/src/Shapes.cpp | 238 +++++++-------- DDCore/src/Volumes.cpp | 2 +- DDCore/src/gdml/GdmlPlugins.cpp | 14 +- DDCore/src/plugins/Compact2Objects.cpp | 18 +- DDCore/src/plugins/ShapePlugins.cpp | 115 ++++--- DDCore/src/plugins/StandardPlugins.cpp | 17 -- DDCore/src/plugins/TGeoCodeGenerator.cpp | 145 +++++---- DDG4/examples/initAClick.C | 4 - DDG4/include/DDG4/Geant4Converter.h | 8 +- DDG4/include/DDG4/Geant4GeometryInfo.h | 14 +- DDG4/src/Geant4Converter.cpp | 183 ++++++----- DDG4/src/Geant4Data.cpp | 1 - DDG4/src/Geant4DataConversion.cpp | 2 +- DDG4/src/Geant4DataDump.cpp | 5 +- DDG4/src/Geant4DetectorConstruction.cpp | 30 +- DDG4/src/Geant4ShapeConverter.cpp | 17 +- DDG4/src/python/Geant4PythonCall.cpp | 9 +- DDParsers/include/Evaluator/DD4hepUnits.h | 12 - UtilityApps/src/teve_display.cpp | 60 ++-- .../ClientTests/src/Assemblies_VXD_geo.cpp | 8 +- .../ClientTests/src/MaterialTester_geo.cpp | 26 +- examples/ClientTests/src/MiniTel.cpp | 20 +- .../src/PlacedVolumeScannerTest.cpp | 11 +- examples/ClientTests/src/Property_test.cpp | 285 +++++++++--------- .../src/SectorBarrelCalorimeter_geo.cpp | 25 +- .../src/plugins/DDDefinitions2Objects.cpp | 4 - examples/LHeD/scripts/initAClick.C | 4 - examples/OpticalSurfaces/src/OpNovice_geo.cpp | 28 +- 42 files changed, 1073 insertions(+), 1269 deletions(-) diff --git a/DDCore/include/DD4hep/Objects.h b/DDCore/include/DD4hep/Objects.h index c73fd919b..e7b74a993 100644 --- a/DDCore/include/DD4hep/Objects.h +++ b/DDCore/include/DD4hep/Objects.h @@ -14,8 +14,8 @@ #define DD4HEP_OBJECTS_H // Framework include files -#include "DD4hep/Handle.h" -#include "DD4hep/NamedObject.h" +#include +#include // Forward declarations class TMap; @@ -33,23 +33,22 @@ class TGeoIdentity; #pragma GCC diagnostic ignored "-Wdeprecated" // Code that causes warning goes here #endif // ROOT include files -#include "Math/Vector3D.h" -#include "Math/Transform3D.h" -#include "Math/Translation3D.h" -#include "Math/RotationX.h" -#include "Math/RotationY.h" -#include "Math/RotationZ.h" -#include "Math/Rotation3D.h" -#include "Math/RotationZYX.h" -#include "Math/EulerAngles.h" -#include "Math/VectorUtil.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include -#include "TGeoPhysicalNode.h" -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) -#include "TGDMLMatrix.h" -#endif +#include +#include + #ifdef __GNUC__ #pragma GCC diagnostic pop #endif @@ -272,9 +271,8 @@ namespace dd4hep { */ class Material: public Handle { public: -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) typedef const TGDMLMatrix* Property; -#endif + public: /// Default constructor Material() = default; @@ -304,7 +302,6 @@ namespace dd4hep { double intLength() const; /// Access the fraction of an element within the material double fraction(Atom atom) const; -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /// Access to tabular properties of the material Property property(const char* name) const; /// Access to tabular properties of the material @@ -315,7 +312,6 @@ namespace dd4hep { double constProperty(const std::string& name) const; /// Access string property value from the material table std::string constPropertyRef(const std::string& name, const std::string& default_value=""); -#endif }; /// Handle class describing visualization attributes @@ -506,8 +502,8 @@ namespace dd4hep { } /* End namespace dd4hep */ -#include "Math/Vector4D.h" -#include "Math/Point3D.h" +#include +#include namespace ROOT { namespace Math { diff --git a/DDCore/include/DD4hep/OpticalSurfaceManager.h b/DDCore/include/DD4hep/OpticalSurfaceManager.h index 9a42471ab..1cd761b67 100644 --- a/DDCore/include/DD4hep/OpticalSurfaceManager.h +++ b/DDCore/include/DD4hep/OpticalSurfaceManager.h @@ -14,10 +14,10 @@ #define DD4HEP_OPTICALSURFACEMANAGER_H // Framework include files -#include "DD4hep/OpticalSurfaces.h" +#include // ROOT include files -#include "TGeoManager.h" +#include /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -58,7 +58,6 @@ namespace dd4hep { /// static accessor calling DD4hepOpticalSurfaceManagerPlugin if necessary static OpticalSurfaceManager getOpticalSurfaceManager(Detector& description); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /// Access skin surface by its full name SkinSurface skinSurface(const std::string& full_name) const; /// Access skin surface by its identifier tuple (DetElement, name) @@ -80,7 +79,6 @@ namespace dd4hep { /// Register the temporary surface objects with the TGeoManager void registerSurfaces(DetElement subdetector); -#endif }; } /* End namespace dd4hep */ #endif // DD4HEP_OPTICALSURFACEMANAGER_H diff --git a/DDCore/include/DD4hep/OpticalSurfaces.h b/DDCore/include/DD4hep/OpticalSurfaces.h index d286f04f1..c8b98e9a3 100644 --- a/DDCore/include/DD4hep/OpticalSurfaces.h +++ b/DDCore/include/DD4hep/OpticalSurfaces.h @@ -14,13 +14,11 @@ #define DD4HEP_OPTICALSURFACES_H // Framework include files -#include "DD4hep/Volumes.h" -#include "DD4hep/DetElement.h" - -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) +#include +#include // ROOT include files -#include "TGeoOpticalSurface.h" +#include /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -192,8 +190,5 @@ namespace dd4hep { /// Access the right node of the border surface PlacedVolume right() const; }; - - -} /* End namespace dd4hep */ -#endif /* ROOT_VERSION */ +} /* End namespace dd4hep */ #endif // DD4HEP_OPTICALSURFACES_H diff --git a/DDCore/include/DD4hep/PropertyTable.h b/DDCore/include/DD4hep/PropertyTable.h index 524e2363b..be06bd456 100644 --- a/DDCore/include/DD4hep/PropertyTable.h +++ b/DDCore/include/DD4hep/PropertyTable.h @@ -13,14 +13,11 @@ #ifndef DD4HEP_PROPERTYTABLE_H #define DD4HEP_PROPERTYTABLE_H -#include "RVersion.h" -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) - // Framework include files -#include "DD4hep/Handle.h" +#include // ROOT include files -#include "TGDMLMatrix.h" +#include /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -59,6 +56,5 @@ namespace dd4hep { PropertyTable& operator=(const PropertyTable& m) = default; }; -} /* End namespace dd4hep */ -#endif /* ROOT_VERSION */ +} // End namespace dd4hep #endif // DD4HEP_PROPERTYTABLE_H diff --git a/DDCore/include/DD4hep/Shapes.h b/DDCore/include/DD4hep/Shapes.h index a186bb448..cb0f8b32a 100644 --- a/DDCore/include/DD4hep/Shapes.h +++ b/DDCore/include/DD4hep/Shapes.h @@ -46,9 +46,7 @@ #include #include #include -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) #include -#endif #ifdef __GNUC__ #pragma GCC diagnostic pop @@ -1762,7 +1760,6 @@ namespace dd4hep { } }; -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) /// Class describing a tessellated shape /** * For any further documentation please see the following ROOT documentation: @@ -1833,7 +1830,6 @@ namespace dd4hep { /// Access a single vertex from the shape const Vertex& vertex(int index) const; }; -#endif /// Base class describing boolean (=union,intersection,subtraction) solids /** @@ -2012,6 +2008,5 @@ namespace dd4hep { /// Copy Assignment operator IntersectionSolid& operator=(const IntersectionSolid& copy) = default; }; - -} /* End namespace dd4hep */ +} /* End namespace dd4hep */ #endif // DD4HEP_SHAPES_H diff --git a/DDCore/include/DD4hep/detail/OpticalSurfaceManagerInterna.h b/DDCore/include/DD4hep/detail/OpticalSurfaceManagerInterna.h index 51d0bda2a..979e3a314 100644 --- a/DDCore/include/DD4hep/detail/OpticalSurfaceManagerInterna.h +++ b/DDCore/include/DD4hep/detail/OpticalSurfaceManagerInterna.h @@ -22,7 +22,7 @@ #define DD4HEP_DETAIL_OPTICALSURFACEMANAGERINTERNA_H /// Framework include files -#include "DD4hep/Detector.h" +#include /// C/C++ include files #include @@ -46,11 +46,9 @@ namespace dd4hep { /// Reference to the main detector description object Detector& detector; -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) std::map skinSurfaces; std::map borderSurfaces; std::map opticalSurfaces; -#endif public: /// Default constructor diff --git a/DDCore/include/DD4hep/detail/Plugins.inl b/DDCore/include/DD4hep/detail/Plugins.inl index 11258d5dd..d26913c11 100644 --- a/DDCore/include/DD4hep/detail/Plugins.inl +++ b/DDCore/include/DD4hep/detail/Plugins.inl @@ -14,7 +14,7 @@ #ifndef DD4HEP_PLUGINS_INL #define DD4HEP_PLUGINS_INL -#include "DD4hep/Plugins.h" +#include #if !defined(DD4HEP_PARSERS_NO_ROOT) && ROOT_VERSION_CODE < ROOT_VERSION(6,0,0) #include diff --git a/DDCore/src/DetectorImp.cpp b/DDCore/src/DetectorImp.cpp index 7e5eeb4d3..9f77b5b24 100644 --- a/DDCore/src/DetectorImp.cpp +++ b/DDCore/src/DetectorImp.cpp @@ -14,19 +14,19 @@ #define DD4HEP_MUST_USE_DETECTORIMP_H 1 // Framework include files -#include "DD4hep/Plugins.h" -#include "DD4hep/Printout.h" -#include "DD4hep/GeoHandler.h" -#include "DD4hep/DetectorHelper.h" -#include "DD4hep/DetectorTools.h" - -#include "DD4hep/InstanceCount.h" -#include "DD4hep/detail/ObjectsInterna.h" -#include "DD4hep/detail/DetectorInterna.h" -#include "DD4hep/detail/VolumeManagerInterna.h" -#include "DD4hep/detail/OpticalSurfaceManagerInterna.h" -#include "DD4hep/DetectorImp.h" -#include "DD4hep/DD4hepUnits.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include // C/C++ include files #include @@ -35,21 +35,19 @@ #include // ROOT inlcude files -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,12,0) -#include "TGeoSystemOfUnits.h" -#endif -#include "TGeoCompositeShape.h" -#include "TGeoBoolNode.h" -#include "TGeoManager.h" -#include "TGeoMatrix.h" -#include "TGeoVolume.h" -#include "TGeoShape.h" -#include "TClass.h" +#include +#include +#include +#include +#include +#include +#include +#include -#include "XML/DocumentHandler.h" +#include #ifndef __TIXML__ -#include "xercesc/dom/DOMException.hpp" +#include namespace dd4hep { namespace xml { typedef xercesc::DOMException XmlException; @@ -58,12 +56,12 @@ namespace dd4hep { #endif using namespace dd4hep; -using namespace std; ClassImp(DetectorImp) namespace { - recursive_mutex s_detector_apply_lock; + + std::recursive_mutex s_detector_apply_lock; struct TypePreserve { DetectorBuildType& m_t; @@ -76,16 +74,16 @@ namespace { }; struct Instances { - recursive_mutex lock; - map detectors; + std::recursive_mutex lock; + std::map detectors; Instances() = default; ~Instances() { } - Detector* get(const string& name) { + Detector* get(const std::string& name) { auto i = detectors.find(name); return i == detectors.end() ? 0 : (*i).second; } - void insert(const string& name, Detector* detector) { + void insert(const std::string& name, Detector* detector) { auto i = detectors.find(name); if ( i == detectors.end() ) { detectors.emplace(name,detector); @@ -93,7 +91,7 @@ namespace { } except("DD4hep","Cannot insert detector instance %s [Already present]",name.c_str()); } - Detector* remove(const string& name) { + Detector* remove(const std::string& name) { auto i = detectors.find(name); if ( i != detectors.end() ) { Detector* det = (*i).second; @@ -106,8 +104,8 @@ namespace { class DetectorGuard final { protected: - static pair >& detector_lock() { - static pair > s_inst; + static std::pair >& detector_lock() { + static std::pair > s_inst; return s_inst; } DetectorImp* detector {nullptr}; @@ -124,8 +122,8 @@ namespace { auto& lock = detector_lock(); auto i = lock.second.find(detector); if ( i != lock.second.end() ) { - mgr = (*i).second; - lock.second.erase(i); + mgr = (*i).second; + lock.second.erase(i); } lock.first.unlock(); return mgr; @@ -138,19 +136,19 @@ namespace { } } -string dd4hep::versionString(){ - string vs("vXX-YY") ; - sprintf( &vs[0] , "v%2.2d-%2.2d", DD4HEP_MAJOR_VERSION, DD4HEP_MINOR_VERSION ) ; +std::string dd4hep::versionString(){ + std::string vs("vXX-YY") ; + std::sprintf( &vs[0] , "v%2.2d-%2.2d", DD4HEP_MAJOR_VERSION, DD4HEP_MINOR_VERSION ) ; return vs; } -unique_ptr Detector::make_unique(const std::string& name) { +std::unique_ptr Detector::make_unique(const std::string& name) { Detector* description = new DetectorImp(name); - return unique_ptr(description); + return std::unique_ptr(description); } Detector& Detector::getInstance(const std::string& name) { - lock_guard lock(detector_instances().lock); + std::lock_guard lock(detector_instances().lock); Detector* description = detector_instances().get(name); if ( 0 == description ) { gGeoManager = 0; @@ -162,7 +160,7 @@ Detector& Detector::getInstance(const std::string& name) { /// Destroy the instance void Detector::destroyInstance(const std::string& name) { - lock_guard lock(detector_instances().lock); + std::lock_guard lock(detector_instances().lock); Detector* description = detector_instances().remove(name); if (description) delete description; @@ -179,34 +177,21 @@ DetectorImp::DetectorImp() } /// Initializing constructor -DetectorImp::DetectorImp(const string& name) +DetectorImp::DetectorImp(const std::string& name) : TNamed(), DetectorData(), DetectorLoad(this), m_buildType(BUILD_NONE) { -#if defined(DD4HEP_USE_GEANT4_UNITS) && ROOT_VERSION_CODE >= ROOT_VERSION(6,22,7) - printout(INFO,"DD4hep","++ Using globally Geant4 unit system (mm,ns,MeV)"); - if ( TGeoManager::GetDefaultUnits() != TGeoManager::kG4Units ) { - TGeoManager::LockDefaultUnits(kFALSE); - TGeoManager::SetDefaultUnits(TGeoManager::kG4Units); - TGeoManager::LockDefaultUnits(kTRUE); - } -#elif ROOT_VERSION_CODE >= ROOT_VERSION(6,22,7) - if ( TGeoManager::GetDefaultUnits() != TGeoManager::kRootUnits ) { - TGeoManager::LockDefaultUnits(kFALSE); - TGeoManager::SetDefaultUnits(TGeoManager::kRootUnits); - TGeoManager::LockDefaultUnits(kTRUE); - } +#if defined(DD4HEP_USE_GEANT4_UNITS) + printout(INFO,"DD4hep","++ Using globally Geant4 unit system (mm,ns,MeV)"); + if ( TGeoManager::GetDefaultUnits() != TGeoManager::kG4Units ) { + TGeoManager::LockDefaultUnits(kFALSE); + TGeoManager::SetDefaultUnits(TGeoManager::kG4Units); + TGeoManager::LockDefaultUnits(kTRUE); + } #else - static bool first = true; - if ( first ) { - first = false; -#if defined(DD4HEP_USE_GEANT4_UNITS) && ROOT_VERSION_CODE >= ROOT_VERSION(6,20,0) - printout(INFO,"DD4hep","++ Using globally Geant4 unit system (mm,ns,MeV)"); - TGeoManager::SetDefaultG4Units(); - TGeoUnit::setUnitType(TGeoUnit::kTGeant4Units); -#elif ROOT_VERSION_CODE >= ROOT_VERSION(6,20,0) - TGeoManager::SetDefaultRootUnits(); - TGeoUnit::setUnitType(TGeoUnit::kTGeoUnits); -#endif + if ( TGeoManager::GetDefaultUnits() != TGeoManager::kRootUnits ) { + TGeoManager::LockDefaultUnits(kFALSE); + TGeoManager::SetDefaultUnits(TGeoManager::kRootUnits); + TGeoManager::LockDefaultUnits(kTRUE); } #endif @@ -251,7 +236,7 @@ DetectorImp::DetectorImp(const string& name) DetectorImp::~DetectorImp() { DetectorGuard(this).lock(gGeoManager); if ( m_manager ) { - lock_guard lock(detector_instances().lock); + std::lock_guard lock(detector_instances().lock); if ( m_manager == gGeoManager ) gGeoManager = 0; Detector* description = detector_instances().get(GetName()); if ( 0 != description ) { @@ -280,10 +265,10 @@ Int_t DetectorImp::saveObject(const char *name, Int_t option, Int_t bufsize) con DetectorData::unpatchRootStreamer(TGeoNode::Class()); return nbytes; } - catch (const exception& e) { + catch (const std::exception& e) { DetectorData::unpatchRootStreamer(TGeoVolume::Class()); DetectorData::unpatchRootStreamer(TGeoNode::Class()); - except("Detector","Exception %s while saving dd4hep::Detector object",e.what()); + except("Detector","Exception %s while saving dd4hep::Detector object", e.what()); } catch (...) { DetectorData::unpatchRootStreamer(TGeoVolume::Class()); @@ -315,7 +300,7 @@ void* DetectorImp::userExtension(unsigned long long int key, bool alert) const { } /// Register new mother volume using the detector name. -void DetectorImp::declareParent(const string& detector_name, const DetElement& parent) { +void DetectorImp::declareParent(const std::string& detector_name, const DetElement& parent) { if ( !detector_name.empty() ) { if ( parent.isValid() ) { auto i = m_detectorParents.find(detector_name); @@ -343,7 +328,7 @@ void DetectorImp::declareParent(const string& detector_name, const DetElement& p /// Access mother volume by detector element Volume DetectorImp::pickMotherVolume(const DetElement& de) const { if ( de.isValid() ) { - string de_name = de.name(); + std::string de_name = de.name(); auto i = m_detectorParents.find(de_name); if (i == m_detectorParents.end()) { if ( m_worldVol.isValid() ) { @@ -422,14 +407,14 @@ DetElement DetectorImp::detector(const std::string& name) const { } Detector& DetectorImp::addDetector(const Handle& ref_det) { - DetElement det_element(ref_det); + DetElement det_element(ref_det); DetectorHelper helper(this); - DetElement existing_det = helper.detectorByID(det_element.id()); + DetElement existing_det = helper.detectorByID(det_element.id()); if ( existing_det.isValid() ) { SensitiveDetector sd = helper.sensitiveDetector(existing_det); if ( sd.isValid() ) { - stringstream str; + std::stringstream str; str << "Detector: The sensitive sub-detectors " << det_element.name() << " and " << existing_det.name() << " have the identical ID:" << det_element.id() << "."; except("DD4hep",str.str()); @@ -439,9 +424,9 @@ Detector& DetectorImp::addDetector(const Handle& ref_det) { det_element->flag |= DetElement::Object::IS_TOP_LEVEL_DETECTOR; PlacedVolume pv = det_element.placement(); if ( !pv.isValid() ) { - stringstream str; + std::stringstream str; str << "Detector: Adding subdetectors with no valid placement is not allowed: " - << det_element.name() << " ID:" << det_element.id() << "."; + << det_element.name() << " ID:" << det_element.id() << "."; except("DD4hep",str.str()); } Volume volume = pv->GetMotherVolume(); @@ -464,7 +449,7 @@ Detector& DetectorImp::addDetector(const Handle& ref_det) { // The detector's placement must be one of the existing detectors for(HandleMap::iterator idet = m_detectors.begin(); idet != m_detectors.end(); ++idet) { DetElement parent((*idet).second); - Volume vol = parent.placement().volume(); + Volume vol = parent.placement().volume(); if ( vol == volume ) { printout(INFO,"DD4hep","+++ Detector: Added detector %s to the parent:%s.", det_element.name(),parent.name()); @@ -473,7 +458,7 @@ Detector& DetectorImp::addDetector(const Handle& ref_det) { } } except("DD4hep","+++ Detector: The detector %s has no known parent.", det_element.name()); - throw runtime_error("Detector-Error"); // Never called.... + throw std::runtime_error("Detector-Error"); // Never called.... } /// Add a new constant by named reference to the detector description @@ -488,38 +473,38 @@ Detector& DetectorImp::addConstant(const Handle& x) { } /// Retrieve a constant by its name from the detector description -Constant DetectorImp::constant(const string& name) const { +Constant DetectorImp::constant(const std::string& name) const { if ( !m_inhibitConstants ) { return getRefChild(m_define, name); } - throw runtime_error("Detector:constant("+name+"): Access to global constants is inhibited."); + throw std::runtime_error("Detector:constant("+name+"): Access to global constants is inhibited."); } /// Typed access to constants: access string values -string DetectorImp::constantAsString(const string& name) const { +std::string DetectorImp::constantAsString(const std::string& name) const { if ( !m_inhibitConstants ) { Handle c = constant(name); if (c.isValid()) return c->GetTitle(); - throw runtime_error("Detector:constantAsString: The constant " + name + " is not known to the system."); + throw std::runtime_error("Detector:constantAsString: The constant " + name + " is not known to the system."); } - throw runtime_error("Detector:constantAsString("+name+"):: Access to global constants is inhibited."); + throw std::runtime_error("Detector:constantAsString("+name+"):: Access to global constants is inhibited."); } /// Typed access to constants: long values -long DetectorImp::constantAsLong(const string& name) const { +long DetectorImp::constantAsLong(const std::string& name) const { if ( !m_inhibitConstants ) { return _toLong(constantAsString(name)); } - throw runtime_error("Detector:constantAsLong("+name+"): Access to global constants is inhibited."); + throw std::runtime_error("Detector:constantAsLong("+name+"): Access to global constants is inhibited."); } /// Typed access to constants: double values -double DetectorImp::constantAsDouble(const string& name) const { +double DetectorImp::constantAsDouble(const std::string& name) const { if ( !m_inhibitConstants ) { return _toDouble(constantAsString(name)); } - throw runtime_error("Detector:constantAsDouble("+name+"): Access to global constants is inhibited."); + throw std::runtime_error("Detector:constantAsDouble("+name+"): Access to global constants is inhibited."); } /// Add a field component by named reference to the detector description @@ -530,12 +515,12 @@ Detector& DetectorImp::addField(const Handle& x) { } /// Retrieve a matrial by its name from the detector description -Material DetectorImp::material(const string& name) const { +Material DetectorImp::material(const std::string& name) const { TGeoMedium* mat = m_manager->GetMedium(name.c_str()); if (mat) { return Material(mat); } - throw runtime_error("Cannot find a material referenced by name:" + name); + throw std::runtime_error("Cannot find a material referenced by name:" + name); } /// Internal helper to map detector types once the geometry is closed @@ -560,36 +545,36 @@ void DetectorImp::mapDetectorTypes() { } /// Access the availible detector types -vector DetectorImp::detectorTypes() const { +std::vector DetectorImp::detectorTypes() const { if ( m_manager->IsClosed() ) { - vector v; + std::vector v; v.reserve(m_detectorTypes.size()); for(const auto& t : m_detectorTypes ) v.emplace_back(t.first); return v; } - throw runtime_error("detectorTypes: Call only available once the geometry is closed!"); + throw std::runtime_error("detectorTypes: Call only available once the geometry is closed!"); } /// Access a set of subdetectors according to the sensitive type. -const vector& DetectorImp::detectors(const string& type, bool throw_exc) const { +const std::vector& DetectorImp::detectors(const std::string& type, bool throw_exc) const { if ( m_manager->IsClosed() ) { DetectorTypeMap::const_iterator i=m_detectorTypes.find(type); if ( i != m_detectorTypes.end() ) return (*i).second; if ( throw_exc ) { - throw runtime_error("detectors("+type+"): Detectors of this type do not exist in the current setup!"); + throw std::runtime_error("detectors("+type+"): Detectors of this type do not exist in the current setup!"); } // return empty vector instead of exception return m_detectorTypes.at("") ; } - throw runtime_error("detectors("+type+"): Detectors can only selected by type once the geometry is closed!"); + throw std::runtime_error("detectors("+type+"): Detectors can only selected by type once the geometry is closed!"); } -vector DetectorImp::detectors(unsigned int includeFlag, unsigned int excludeFlag ) const { +std::vector DetectorImp::detectors(unsigned int includeFlag, unsigned int excludeFlag ) const { if( ! m_manager->IsClosed() ) { - throw runtime_error("detectors(typeFlag): Detectors can only selected by typeFlag once the geometry is closed!"); + throw std::runtime_error("detectors(typeFlag): Detectors can only selected by typeFlag once the geometry is closed!"); } - vector dets ; + std::vector dets ; dets.reserve( m_detectors.size() ) ; for(HandleMap::const_iterator i=m_detectors.begin(); i!=m_detectors.end(); ++i) { @@ -608,13 +593,13 @@ vector DetectorImp::detectors(unsigned int includeFlag, unsigned int } /// Access a set of subdetectors according to several sensitive types. -vector DetectorImp::detectors(const string& type1, - const string& type2, - const string& type3, - const string& type4, - const string& type5 ) { +std::vector DetectorImp::detectors(const std::string& type1, + const std::string& type2, + const std::string& type3, + const std::string& type4, + const std::string& type5 ) { if ( m_manager->IsClosed() ) { - vector v; + std::vector v; DetectorTypeMap::const_iterator i, end=m_detectorTypes.end(); if ( !type1.empty() && (i=m_detectorTypes.find(type1)) != end ) v.insert(v.end(),(*i).second.begin(),(*i).second.end()); @@ -628,10 +613,10 @@ vector DetectorImp::detectors(const string& type1, v.insert(v.end(),(*i).second.begin(),(*i).second.end()); return v; } - throw runtime_error("detectors("+type1+","+type2+",...): Detectors can only selected by type once the geometry is closed!"); + throw std::runtime_error("detectors("+type1+","+type2+",...): Detectors can only selected by type once the geometry is closed!"); } -Handle DetectorImp::getRefChild(const HandleMap& e, const string& name, bool do_throw) const { +Handle DetectorImp::getRefChild(const HandleMap& e, const std::string& name, bool do_throw) const { HandleMap::const_iterator it = e.find(name); if (it != e.end()) { return it->second; @@ -658,7 +643,7 @@ Handle DetectorImp::getRefChild(const HandleMap& e, const string& n err << it->first; } err << "}"; - throw runtime_error(err.str()); + throw std::runtime_error(err.str()); } return 0; } @@ -673,7 +658,7 @@ namespace { void patchShapes() { auto& data = *m_data; char text[32]; - string nam; + std::string nam; printout(INFO,"Detector","+++ Patching names of anonymous shapes...."); for (auto i = data.rbegin(); i != data.rend(); ++i) { for( const TGeoNode* n : (*i).second ) { @@ -693,7 +678,7 @@ namespace { } else { nam = sn; - if (nam.find("_shape") == string::npos) + if (nam.find("_shape") == std::string::npos) nam += text; s->SetName(nam.c_str()); } @@ -726,7 +711,7 @@ namespace { /// Finalize/close the geometry void DetectorImp::endDocument(bool close_geometry) { TGeoManager* mgr = m_manager; - lock_guard lock(s_detector_apply_lock); + std::lock_guard lock(s_detector_apply_lock); if ( close_geometry && !mgr->IsClosed() ) { #if 0 Region trackingRegion("TrackingRegion"); @@ -758,7 +743,7 @@ void DetectorImp::endDocument(bool close_geometry) { void DetectorImp::init() { if (!m_world.isValid()) { TGeoManager* mgr = m_manager; - lock_guard lock(s_detector_apply_lock); + std::lock_guard lock(s_detector_apply_lock); Constant air_const = getRefChild(m_define, "Air", false); Constant vac_const = getRefChild(m_define, "Vacuum", false); Box worldSolid; @@ -817,16 +802,16 @@ void DetectorImp::init() { } /// Read any geometry description or alignment file -void DetectorImp::fromXML(const string& xmlfile, DetectorBuildType build_type) { +void DetectorImp::fromXML(const std::string& xmlfile, DetectorBuildType build_type) { TypePreserve build_type_preserve(m_buildType = build_type); - lock_guard lock(s_detector_apply_lock); + std::lock_guard lock(s_detector_apply_lock); processXML(xmlfile,0); } /// Read any geometry description or alignment file with external XML entity resolution -void DetectorImp::fromXML(const string& fname, xml::UriReader* entity_resolver, DetectorBuildType build_type) { +void DetectorImp::fromXML(const std::string& fname, xml::UriReader* entity_resolver, DetectorBuildType build_type) { TypePreserve build_type_preserve(m_buildType = build_type); - lock_guard lock(s_detector_apply_lock); + std::lock_guard lock(s_detector_apply_lock); processXML(fname,entity_resolver); } @@ -839,8 +824,8 @@ void DetectorImp::dump() const { /// Manipulate geometry using facroy converter long DetectorImp::apply(const char* factory_type, int argc, char** argv) const { - lock_guard lock(s_detector_apply_lock); - string fac = factory_type; + std::lock_guard lock(s_detector_apply_lock); + std::string fac = factory_type; try { Detector* thisPtr = const_cast(this); long result = PluginService::Create(fac, thisPtr, argc, argv); @@ -848,24 +833,24 @@ long DetectorImp::apply(const char* factory_type, int argc, char** argv) const PluginDebug dbg; result = PluginService::Create(fac, thisPtr, argc, argv); if ( 0 == result ) { - throw runtime_error("dd4hep: apply-plugin: Failed to locate plugin " + - fac + ". " + dbg.missingFactory(fac)); + throw std::runtime_error("dd4hep: apply-plugin: Failed to locate plugin " + + fac + ". " + dbg.missingFactory(fac)); } } result = *(long*) result; if (result != 1) { - throw runtime_error("dd4hep: apply-plugin: Failed to execute plugin " + fac); + throw std::runtime_error("dd4hep: apply-plugin: Failed to execute plugin " + fac); } return result; } catch (const xml::XmlException& e) { - throw runtime_error(xml::_toString(e.msg) + "\ndd4hep: XML-DOM Exception with plugin:" + fac); + throw std::runtime_error(xml::_toString(e.msg) + "\ndd4hep: XML-DOM Exception with plugin:" + fac); } - catch (const exception& e) { - throw runtime_error(string(e.what()) + "\ndd4hep: with plugin:" + fac); + catch (const std::exception& e) { + throw std::runtime_error(std::string(e.what()) + "\ndd4hep: with plugin:" + fac); } catch (...) { - throw runtime_error("UNKNOWN exception from plugin:" + fac); + throw std::runtime_error("UNKNOWN exception from plugin:" + fac); } return EINVAL; } diff --git a/DDCore/src/Handle.cpp b/DDCore/src/Handle.cpp index cbc9b1b7b..c947af983 100644 --- a/DDCore/src/Handle.cpp +++ b/DDCore/src/Handle.cpp @@ -11,10 +11,10 @@ // //========================================================================== -#include "DD4hep/detail/Handle.inl" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/Printout.h" -#include "Evaluator/Evaluator.h" +#include +#include +#include +#include /// C/C++ include files #include @@ -35,7 +35,6 @@ namespace { const dd4hep::tools::Evaluator& eval(dd4hep::evaluator()); } -using namespace std; using namespace dd4hep; using namespace dd4hep::detail; @@ -45,9 +44,9 @@ namespace { static bool s_allow_variable_redefine = true; /// - void check_evaluation(const string& value, std::pair res, stringstream& err) { + void check_evaluation(const std::string& value, std::pair res, std::stringstream& err) { if ( res.first != tools::Evaluator::OK) { - throw runtime_error("dd4hep: "+err.str()+" : value="+value+" [Evaluation error]"); + throw std::runtime_error("dd4hep: "+err.str()+" : value="+value+" [Evaluation error]"); } } } @@ -61,121 +60,121 @@ namespace dd4hep { return tmp; } - std::pair _toFloatingPoint(const string& value) { - stringstream err; + std::pair _toFloatingPoint(const std::string& value) { + std::stringstream err; auto result = eval.evaluate(value, err); check_evaluation(value, result, err); return result; } - std::pair _toInteger(const string& value) { - string s(value); + std::pair _toInteger(const std::string& value) { + std::string s(value); size_t idx = s.find("(int)"); - if (idx != string::npos) + if (idx != std::string::npos) s.erase(idx, 5); idx = s.find("(long)"); - if (idx != string::npos) + if (idx != std::string::npos) s.erase(idx, 6); while (s[0] == ' ') s.erase(0, 1); return _toFloatingPoint(s); } - short _toShort(const string& value) { + short _toShort(const std::string& value) { return (short) _toInteger(value).second; } - unsigned short _toUShort(const string& value) { + unsigned short _toUShort(const std::string& value) { return (unsigned short) _toInteger(value).second; } - int _toInt(const string& value) { + int _toInt(const std::string& value) { return (int) _toInteger(value).second; } - unsigned int _toUInt(const string& value) { + unsigned int _toUInt(const std::string& value) { return (unsigned int) _toInteger(value).second; } - long _toLong(const string& value) { + long _toLong(const std::string& value) { return (long) _toInteger(value).second; } - unsigned long _toULong(const string& value) { + unsigned long _toULong(const std::string& value) { return (unsigned long) _toInteger(value).second; } - bool _toBool(const string& value) { + bool _toBool(const std::string& value) { return value == "true" || value == "yes" || value == "True"; } /// String conversions: string to float value - float _toFloat(const string& value) { + float _toFloat(const std::string& value) { return (float) _toFloatingPoint(value).second; } /// String conversions: string to double value - double _toDouble(const string& value) { + double _toDouble(const std::string& value) { return _toFloatingPoint(value).second; } /// Generic type conversion from string to primitive value \ingroup DD4HEP_CORE - template T _toType(const string& value) { + template T _toType(const std::string& value) { notImplemented("Value "+value+" cannot be converted to type "+typeName(typeid(T))); return T(); } /// Generic type conversion from string to primitive value - template <> bool _toType(const string& value) { + template <> bool _toType(const std::string& value) { return _toBool(value); } /// Generic type conversion from string to primitive value - template <> short _toType(const string& value) { + template <> short _toType(const std::string& value) { return _toShort(value); } /// Generic type conversion from string to primitive value - template <> unsigned short _toType(const string& value) { + template <> unsigned short _toType(const std::string& value) { return (unsigned short)_toShort(value); } /// Generic type conversion from string to primitive value - template <> int _toType(const string& value) { + template <> int _toType(const std::string& value) { return _toInt(value); } /// Generic type conversion from string to primitive value - template <> unsigned int _toType(const string& value) { + template <> unsigned int _toType(const std::string& value) { return (unsigned int)_toInt(value); } /// Generic type conversion from string to primitive value - template <> long _toType(const string& value) { + template <> long _toType(const std::string& value) { return _toLong(value); } /// Generic type conversion from string to primitive value - template <> unsigned long _toType(const string& value) { + template <> unsigned long _toType(const std::string& value) { return (unsigned long)_toLong(value); } /// Generic type conversion from string to primitive value - template <> float _toType(const string& value) { + template <> float _toType(const std::string& value) { return _toFloat(value); } /// Generic type conversion from string to primitive value - template <> double _toType(const string& value) { + template <> double _toType(const std::string& value) { return _toDouble(value); } /// Generic type conversion from string to primitive value - template <> string _toType(const string& value) { + template <> std::string _toType(const std::string& value) { return value; } - template <> char _multiply(const string& left, const string& right) { + template <> char _multiply(const std::string& left, const std::string& right) { double val = _toDouble(left + "*" + right); if ( val >= double(SCHAR_MIN) && val <= double(SCHAR_MAX) ) return (char) (int)val; @@ -185,7 +184,7 @@ namespace dd4hep { return 0; } - template <> unsigned char _multiply(const string& left, const string& right) { + template <> unsigned char _multiply(const std::string& left, const std::string& right) { double val = _toDouble(left + "*" + right); if ( val >= 0 && val <= double(UCHAR_MAX) ) return (unsigned char) (int)val; @@ -195,7 +194,7 @@ namespace dd4hep { return 0; } - template <> short _multiply(const string& left, const string& right) { + template <> short _multiply(const std::string& left, const std::string& right) { double val = _toDouble(left + "*" + right); if ( val >= double(SHRT_MIN) && val <= double(SHRT_MAX) ) return (short) val; @@ -205,7 +204,7 @@ namespace dd4hep { return 0; } - template <> unsigned short _multiply(const string& left, const string& right) { + template <> unsigned short _multiply(const std::string& left, const std::string& right) { double val = _toDouble(left + "*" + right); if ( val >= 0 && val <= double(USHRT_MAX) ) return (unsigned short)val; @@ -215,49 +214,49 @@ namespace dd4hep { return 0; } - template <> int _multiply(const string& left, const string& right) { + template <> int _multiply(const std::string& left, const std::string& right) { return (int) _toDouble(left + "*" + right); } - template <> unsigned int _multiply(const string& left, const string& right) { + template <> unsigned int _multiply(const std::string& left, const std::string& right) { return (unsigned int) _toDouble(left + "*" + right); } - template <> long _multiply(const string& left, const string& right) { + template <> long _multiply(const std::string& left, const std::string& right) { return (long) _toDouble(left + "*" + right); } - template <> unsigned long _multiply(const string& left, const string& right) { + template <> unsigned long _multiply(const std::string& left, const std::string& right) { return (unsigned long) _toDouble(left + "*" + right); } - template <> float _multiply(const string& left, const string& right) { + template <> float _multiply(const std::string& left, const std::string& right) { return _toFloat(left + "*" + right); } - template <> double _multiply(const string& left, const string& right) { + template <> double _multiply(const std::string& left, const std::string& right) { return _toDouble(left + "*" + right); } - void _toDictionary(const string& name, const string& value) { + void _toDictionary(const std::string& name, const std::string& value) { _toDictionary(name, value, "number"); } /// Enter name value pair to the dictionary. \ingroup DD4HEP_CORE - void _toDictionary(const string& name, const string& value, const string& typ) { + void _toDictionary(const std::string& name, const std::string& value, const std::string& typ) { if ( typ == "string" ) { eval.setEnviron(name.c_str(),value.c_str()); return; } else { int status; - stringstream err; - string n = name, v = value; + std::stringstream err; + std::string n = name, v = value; size_t idx = v.find("(int)"); - if (idx != string::npos) + if (idx != std::string::npos) v.erase(idx, 5); idx = v.find("(float)"); - if (idx != string::npos) + if (idx != std::string::npos) v.erase(idx, 7); while (v[0] == ' ') v.erase(0, 1); @@ -266,48 +265,47 @@ namespace dd4hep { err.str(""); status = eval.setVariable(n, result.second, err); if ( status != tools::Evaluator::OK ) { - stringstream err_msg; - err_msg << "name=" << name << " value=" << value - << " " << err.str() << " [setVariable error]"; - if ( status == tools::Evaluator::WARNING_EXISTING_VARIABLE ) { - if ( s_allow_variable_redefine ) - printout(WARNING,"Evaluator","+++ Overwriting variable: "+err_msg.str()); - else - except("Evaluator","+++ Overwriting variable: "+err_msg.str()); - } + std::stringstream err_msg; + err_msg << "name=" << name << " value=" << value + << " " << err.str() << " [setVariable error]"; + if ( status == tools::Evaluator::WARNING_EXISTING_VARIABLE ) { + if ( s_allow_variable_redefine ) + printout(WARNING,"Evaluator","+++ Overwriting variable: "+err_msg.str()); + else + except("Evaluator","+++ Overwriting variable: "+err_msg.str()); + } } } } /// Evaluate string constant using environment stored in the evaluator - string _getEnviron(const string& env) { - // We are trying to deal with the case when several variables are being replaced in the - // string. + std::string _getEnviron(const std::string& env) { + // We are trying to deal with the case when several variables are being replaced in the string. size_t current_index = 0; - stringstream processed_variable; + std::stringstream processed_variable; while (true) { // Looking for the start of a variable use, with the syntax // "path1/path2/${VAR1}/path3/${VAR2}" size_t id1 = env.find("${", current_index); // variable start found, do a greedy search for the variable end - if (id1 == string::npos) { - // In this case we did not find the ${ to indicate a start of variable, + if (id1 == std::string::npos) { + // In this case we did not find the ${ to indicate a start of variable, // we just copy the rest of the variable to the stringstream and exit processed_variable << env.substr(current_index); break; } size_t id2 = env.find("}", id1); - if (id2 == string::npos) { - runtime_error("dd4hep: Syntax error, bad variable syntax: " + env); + if (id2 == std::string::npos) { + std::runtime_error("dd4hep: Syntax error, bad variable syntax: " + env); } processed_variable << env.substr(current_index, id1 -current_index ); - string v = env.substr(id1, id2-id1+1); - stringstream err; + std::string v = env.substr(id1, id2-id1+1); + std::stringstream err; auto ret = eval.getEnviron(v, err); // Checking that the variable lookup worked if ( ret.first != tools::Evaluator::OK) { - cerr << v << ": " << err.str() << endl; - throw runtime_error("dd4hep: Severe error during environment lookup of " + v + " " + err.str()); + std::cerr << v << ": " << err.str() << std::endl; + throw std::runtime_error("dd4hep: Severe error during environment lookup of " + v + " " + err.str()); } // Now adding the variable processed_variable << ret.second; @@ -317,8 +315,8 @@ namespace dd4hep { } /// String manipulations: Remove unconditionally all white spaces - string remove_whitespace(const string& v) { - string value; + std::string remove_whitespace(const std::string& v) { + std::string value; value.reserve(v.length()+1); for(const char* p = v.c_str(); *p; ++p) { if ( !::isspace(*p) ) value += *p; @@ -326,37 +324,37 @@ namespace dd4hep { return value; } - template static inline string __to_string(T value, const char* fmt) { + template static inline std::string __to_string(T value, const char* fmt) { char text[128]; ::snprintf(text, sizeof(text), fmt, value); return text; } - string _toString(bool value) { + std::string _toString(bool value) { return value ? "true" : "false"; } - string _toString(short value, const char* fmt) { + std::string _toString(short value, const char* fmt) { return __to_string((int)value, fmt); } - string _toString(int value, const char* fmt) { + std::string _toString(int value, const char* fmt) { return __to_string(value, fmt); } - string _toString(unsigned long value, const char* fmt) { + std::string _toString(unsigned long value, const char* fmt) { return __to_string(value, fmt); } - string _toString(float value, const char* fmt) { + std::string _toString(float value, const char* fmt) { return __to_string(value, fmt); } - string _toString(double value, const char* fmt) { + std::string _toString(double value, const char* fmt) { return __to_string(value, fmt); } - string _ptrToString(const void* value, const char* fmt) { + std::string _ptrToString(const void* value, const char* fmt) { return __to_string(value, fmt); } @@ -371,19 +369,19 @@ namespace dd4hep { } void warning_deprecated_xml_factory(const char* name) { const char* edge = "++++++++++++++++++++++++++++++++++++++++++"; - size_t len = ::strlen(name); - cerr << edge << edge << edge << endl; - cerr << "++ The usage of the factory: \"" << name << "\" is DEPRECATED due to naming conventions." - << setw(53-len) << right << "++" << endl; - cerr << "++ Please use \"DD4hep_" << name << "\" instead." << setw(93-len) << right << "++" << endl; - cerr << edge << edge << edge << endl; + size_t len = std::strlen(name); + std::cerr << edge << edge << edge << std::endl; + std::cerr << "++ The usage of the factory: \"" << name << "\" is DEPRECATED due to naming conventions." + << std::setw(53-len) << std::right << "++" << std::endl; + std::cerr << "++ Please use \"DD4hep_" << name << "\" instead." << std::setw(93-len) << std::right << "++" << std::endl; + std::cerr << edge << edge << edge << std::endl; } } #include "DDSegmentation/Segmentation.h" typedef DDSegmentation::Segmentation _Segmentation; namespace dd4hep { - template <> void Handle<_Segmentation>::assign(_Segmentation* s, const string& n, const string&) { + template <> void Handle<_Segmentation>::assign(_Segmentation* s, const std::string& n, const std::string&) { this->m_element = s; s->setName(n); } @@ -393,9 +391,9 @@ namespace dd4hep { template class dd4hep::Handle<_Segmentation>; } -#include "DD4hep/Detector.h" -#include "TMap.h" -#include "TColor.h" +#include +#include +#include template class dd4hep::Handle; DD4HEP_SAFE_CAST_IMPLEMENTATION(NamedObject,NamedObject) @@ -404,14 +402,14 @@ DD4HEP_INSTANTIATE_HANDLE_UNNAMED(Detector); DD4HEP_INSTANTIATE_HANDLE_CODE(RAW,TObject,NamedObject); DD4HEP_INSTANTIATE_HANDLE_CODE(NONE,TNamed,TObject,NamedObject); -#include "TGeoMedium.h" -#include "TGeoMaterial.h" -#include "TGeoElement.h" +#include +#include +#include DD4HEP_INSTANTIATE_HANDLE(TGeoElement); DD4HEP_INSTANTIATE_HANDLE(TGeoMaterial); DD4HEP_INSTANTIATE_HANDLE(TGeoMedium); -#include "TGeoMatrix.h" +#include DD4HEP_INSTANTIATE_HANDLE(TGeoMatrix); DD4HEP_INSTANTIATE_HANDLE(TGeoRotation); DD4HEP_INSTANTIATE_HANDLE(TGeoTranslation); @@ -419,7 +417,7 @@ DD4HEP_INSTANTIATE_HANDLE(TGeoIdentity); DD4HEP_INSTANTIATE_HANDLE(TGeoCombiTrans); DD4HEP_INSTANTIATE_HANDLE(TGeoGenTrans); -#include "TGeoNode.h" +#include DD4HEP_INSTANTIATE_HANDLE_CODE(RAW,TGeoAtt); DD4HEP_INSTANTIATE_HANDLE_CODE(RAW,TAtt3D); DD4HEP_INSTANTIATE_HANDLE_CODE(RAW,TAttLine); @@ -428,23 +426,24 @@ DD4HEP_INSTANTIATE_HANDLE(TGeoNodeMatrix); DD4HEP_INSTANTIATE_HANDLE(TGeoNodeOffset); // Shapes (needed by "Shapes.cpp") -#include "TGeoBBox.h" -#include "TGeoPcon.h" -#include "TGeoPgon.h" -#include "TGeoTube.h" -#include "TGeoCone.h" -#include "TGeoArb8.h" -#include "TGeoTrd1.h" -#include "TGeoTrd2.h" -#include "TGeoParaboloid.h" -#include "TGeoSphere.h" -#include "TGeoTorus.h" -#include "TGeoBoolNode.h" -#include "TGeoVolume.h" -#include "TGeoScaledShape.h" -#include "TGeoCompositeShape.h" -#include "TGeoShapeAssembly.h" -#include "DD4hep/detail/ShapesInterna.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include DD4HEP_INSTANTIATE_HANDLE(TGeoVolumeAssembly,TGeoVolume,TGeoAtt); DD4HEP_INSTANTIATE_HANDLE(TGeoVolumeMulti,TGeoVolume,TGeoAtt); DD4HEP_INSTANTIATE_HANDLE(TGeoVolume,TGeoAtt,TAttLine,TAtt3D); @@ -475,27 +474,23 @@ DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoTrd1); DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoTrd2); DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoSphere); DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoTorus); - -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) -#include "TGeoTessellated.h" DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoTessellated); -#endif DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoHalfSpace); DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoShapeAssembly); DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoCompositeShape); // Volume Placements (needed by "Volumes.cpp") -#include "TGeoPhysicalNode.h" +#include DD4HEP_INSTANTIATE_HANDLE(TGeoPhysicalNode); -#include "TGeoBoolNode.h" +#include DD4HEP_INSTANTIATE_HANDLE_UNNAMED(TGeoUnion); DD4HEP_INSTANTIATE_HANDLE_UNNAMED(TGeoIntersection); DD4HEP_INSTANTIATE_HANDLE_UNNAMED(TGeoSubtraction); // Replicated Volumes (needed by "Volumes.cpp") -#include "TGeoPatternFinder.h" +#include DD4HEP_INSTANTIATE_HANDLE_UNNAMED(TGeoPatternFinder); DD4HEP_INSTANTIATE_HANDLE_UNNAMED(TGeoPatternX); DD4HEP_INSTANTIATE_HANDLE_UNNAMED(TGeoPatternY); diff --git a/DDCore/src/Objects.cpp b/DDCore/src/Objects.cpp index 181f07ca7..d8fd13246 100644 --- a/DDCore/src/Objects.cpp +++ b/DDCore/src/Objects.cpp @@ -12,26 +12,25 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/Printout.h" -#include "DD4hep/IDDescriptor.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/detail/ObjectsInterna.h" - -#include "TMap.h" -#include "TROOT.h" -#include "TColor.h" -#include "TGeoMatrix.h" -#include "TGeoManager.h" -#include "TGeoElement.h" -#include "TGeoMaterial.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include // C/C++ include files #include #include #include -using namespace std; using namespace dd4hep; /// Constructor to be used when creating a new DOM tree @@ -40,122 +39,122 @@ Author::Author(Detector& /* description */) { } /// Access the auhor's name -string Author::authorName() const { +std::string Author::authorName() const { return m_element->GetName(); } /// Set the author's name -void Author::setAuthorName(const string& nam) { +void Author::setAuthorName(const std::string& nam) { m_element->SetName(nam.c_str()); } /// Access the auhor's email address -string Author::authorEmail() const { +std::string Author::authorEmail() const { return m_element->GetTitle(); } /// Set the author's email address -void Author::setAuthorEmail(const string& addr) { +void Author::setAuthorEmail(const std::string& addr) { m_element->SetTitle(addr.c_str()); } /// Constructor to be used when creating a new DOM tree -Header::Header(const string& author_name, const string& descr_url) { +Header::Header(const std::string& author_name, const std::string& descr_url) { Object* obj_ptr = new Object(); assign(obj_ptr, author_name, descr_url); } /// Accessor to object name -const string Header::name() const { +const std::string Header::name() const { return m_element->GetName(); } /// Accessor: set object name -void Header::setName(const string& new_name) { +void Header::setName(const std::string& new_name) { m_element->SetName(new_name.c_str()); } /// Accessor to object title -const string Header::title() const { +const std::string Header::title() const { return m_element->GetTitle(); } /// Accessor: set object title -void Header::setTitle(const string& new_title) { +void Header::setTitle(const std::string& new_title) { m_element->SetTitle(new_title.c_str()); } /// Accessor to object url -const string& Header::url() const { +const std::string& Header::url() const { return data()->url; } /// Accessor: set object url -void Header::setUrl(const string& new_url) { +void Header::setUrl(const std::string& new_url) { data()->url = new_url; } /// Accessor to object author -const string& Header::author() const { +const std::string& Header::author() const { return data()->author; } /// Accessor: set object author -void Header::setAuthor(const string& new_author) { +void Header::setAuthor(const std::string& new_author) { data()->author = new_author; } /// Accessor to object status -const string& Header::status() const { +const std::string& Header::status() const { return data()->status; } /// Accessor: set object status -void Header::setStatus(const string& new_status) { +void Header::setStatus(const std::string& new_status) { data()->status = new_status; } /// Accessor to object version -const string& Header::version() const { +const std::string& Header::version() const { return data()->version; } /// Accessor: set object version -void Header::setVersion(const string& new_version) { +void Header::setVersion(const std::string& new_version) { data()->version = new_version; } /// Accessor to object comment -const string& Header::comment() const { +const std::string& Header::comment() const { return data()->comment; } /// Accessor: set object comment -void Header::setComment(const string& new_comment) { +void Header::setComment(const std::string& new_comment) { data()->comment = new_comment; } /// Constructor to be used when creating a new DOM tree -Constant::Constant(const string& nam, const string& val, const string& typ) { +Constant::Constant(const std::string& nam, const std::string& val, const std::string& typ) { m_element = new Object(nam, val, typ); } /// Constructor to be used when creating a new DOM tree -Constant::Constant(const string& nam) { +Constant::Constant(const std::string& nam) { m_element = new Object(nam.c_str(), "", "number"); } /// Access the constant -string Constant::dataType() const { +std::string Constant::dataType() const { if ( isValid() ) { return m_element->dataType; } - throw runtime_error("dd4hep: Attempt to access internals from invalid Constant handle!"); + throw std::runtime_error("dd4hep: Attempt to access internals from invalid Constant handle!"); } /// String representation of this object -string Constant::toString() const { - stringstream os; +std::string Constant::toString() const { + std::stringstream os; os << m_element->GetName() << " \"" << m_element->GetTitle() << "\" "; if ( m_element->dataType == "string" ) os << "Value:" << m_element->GetTitle(); else os << "Value:" << _toDouble(m_element->GetTitle()); @@ -163,7 +162,7 @@ string Constant::toString() const { } /// Constructor to be used when creating a new DOM tree -Atom::Atom(const string& nam, const string& formula, int Z, int N, double density) { +Atom::Atom(const std::string& nam, const std::string& formula, int Z, int N, double density) { TGeoElementTable* t = TGeoElement::GetElementTable(); TGeoElement* e = t->FindElement(nam.c_str()); if (!e) { @@ -180,9 +179,9 @@ double Material::Z() const { TGeoMaterial* mat = val->GetMaterial(); if ( mat ) return mat->GetZ(); - throw runtime_error("dd4hep: The medium " + string(val->GetName()) + " has an invalid material reference!"); + throw std::runtime_error("dd4hep: The medium " + std::string(val->GetName()) + " has an invalid material reference!"); } - throw runtime_error("dd4hep: Attempt to access proton number from invalid material handle!"); + throw std::runtime_error("dd4hep: Attempt to access proton number from invalid material handle!"); } /// atomic number of the underlying material @@ -191,9 +190,9 @@ double Material::A() const { TGeoMaterial* mat = ptr()->GetMaterial(); if ( mat ) return mat->GetA(); - throw runtime_error("dd4hep: The medium " + string(ptr()->GetName()) + " has an invalid material reference!"); + throw std::runtime_error("dd4hep: The medium " + std::string(ptr()->GetName()) + " has an invalid material reference!"); } - throw runtime_error("dd4hep: Attempt to access atomic number from invalid material handle!"); + throw std::runtime_error("dd4hep: Attempt to access atomic number from invalid material handle!"); } /// density of the underlying material @@ -202,9 +201,9 @@ double Material::density() const { TGeoMaterial* mat = ptr()->GetMaterial(); if ( mat ) return mat->GetDensity(); - throw runtime_error("dd4hep: The medium " + string(ptr()->GetName()) + " has an invalid material reference!"); + throw std::runtime_error("dd4hep: The medium " + std::string(ptr()->GetName()) + " has an invalid material reference!"); } - throw runtime_error("dd4hep: Attempt to access density from invalid material handle!"); + throw std::runtime_error("dd4hep: Attempt to access density from invalid material handle!"); } /// Access the radiation length of the underlying material @@ -213,9 +212,9 @@ double Material::radLength() const { TGeoMaterial* mat = ptr()->GetMaterial(); if ( mat ) return mat->GetRadLen(); - throw runtime_error("dd4hep: The medium " + string(ptr()->GetName()) + " has an invalid material reference!"); + throw std::runtime_error("dd4hep: The medium " + std::string(ptr()->GetName()) + " has an invalid material reference!"); } - throw runtime_error("dd4hep: Attempt to access radiation length from invalid material handle!"); + throw std::runtime_error("dd4hep: Attempt to access radiation length from invalid material handle!"); } /// Access the radiation length of the underlying material @@ -224,9 +223,9 @@ double Material::intLength() const { TGeoMaterial* mat = ptr()->GetMaterial(); if ( mat ) return mat->GetIntLen(); - throw runtime_error("The medium " + string(ptr()->GetName()) + " has an invalid material reference!"); + throw std::runtime_error("The medium " + std::string(ptr()->GetName()) + " has an invalid material reference!"); } - throw runtime_error("Attempt to access interaction length from invalid material handle!"); + throw std::runtime_error("Attempt to access interaction length from invalid material handle!"); } /// Access the fraction of an element within the material @@ -256,7 +255,6 @@ double Material::fraction(Atom atom) const { return tot>1e-20 ? frac/tot : 0.0; } -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /// Access to tabular properties of the optical surface Material::Property Material::property(const char* nam) const { return access()->GetMaterial()->GetProperty(nam); @@ -281,7 +279,7 @@ double Material::constProperty(const std::string& nam) const { auto* o = access()->GetMaterial(); double value = o->GetConstProperty(nam.c_str(), &err); if ( err != kTRUE ) return value; - throw runtime_error("Attempt to access non existing material const property: "+nam); + throw std::runtime_error("Attempt to access non existing material const property: "+nam); } /// Access string property value from the material table @@ -291,23 +289,22 @@ std::string Material::constPropertyRef(const std::string& name, const std::strin if ( p ) return p; return default_value; } -#endif /// String representation of this object -string Material::toString() const { +std::string Material::toString() const { if ( isValid() ) { TGeoMedium* val = ptr(); - stringstream out; + std::stringstream out; out << val->GetName() << " " << val->GetTitle() - << " id:" << hex << val->GetId() + << " id:" << std::hex << val->GetId() << " Pointer:" << val->GetPointerName(); return out.str(); } - throw runtime_error("Attempt to convert invalid material handle to string!"); + throw std::runtime_error("Attempt to convert invalid material handle to string!"); } /// Constructor to be used when creating a new entity -VisAttr::VisAttr(const string& nam) { +VisAttr::VisAttr(const std::string& nam) { Object* obj = new Object(); assign(obj, nam, "vis"); obj->color = gROOT->GetColor(kWhite); @@ -390,13 +387,9 @@ void VisAttr::setColor(float alpha, float red, float green, float blue) { except("VisAttr","+++ %s Failed to allocate Color: r:%02X g:%02X b:%02X", this->name(), int(red*255.), int(green*255.), int(blue*255)); } -#if ROOT_VERSION_CODE >= ROOT_VERSION(5,34,25) o.colortr = new TColor(gROOT->GetListOfColors()->GetLast()+1, o.color->GetRed(), o.color->GetGreen(), o.color->GetBlue()); o.colortr->SetAlpha(alpha); -#else - o.colortr = o.color; -#endif } /// Get RGB values of the color (if valid) @@ -421,13 +414,13 @@ bool VisAttr::argb(float& alpha, float& red, float& green, float& blue) const { } /// String representation of this object -string VisAttr::toString() const { +std::string VisAttr::toString() const { const VisAttr::Object* obj = &object(); TColor* c = obj->color; char text[256]; - ::snprintf(text, sizeof(text), "%-20s RGB:%-8s [%d] %7.2f Style:%d %d ShowDaughters:%3s Visible:%3s", ptr()->GetName(), - c->AsHexString(), c->GetNumber(), c->GetAlpha(), int(obj->drawingStyle), int(obj->lineStyle), - yes_no(obj->showDaughters), yes_no(obj->visible)); + std::snprintf(text, sizeof(text), "%-20s RGB:%-8s [%d] %7.2f Style:%d %d ShowDaughters:%3s Visible:%3s", ptr()->GetName(), + c->AsHexString(), c->GetNumber(), c->GetAlpha(), int(obj->drawingStyle), int(obj->lineStyle), + yes_no(obj->showDaughters), yes_no(obj->visible)); return text; } @@ -448,8 +441,8 @@ bool Limit::operator<(const Limit& c) const { } /// Conversion to a string representation -string Limit::toString() const { - string res = name + " = " + content; +std::string Limit::toString() const { + std::string res = name + " = " + content; if (!unit.empty()) res += unit + " "; res += " (" + particles + ")"; @@ -457,25 +450,25 @@ string Limit::toString() const { } /// Constructor to be used when creating a new DOM tree -LimitSet::LimitSet(const string& nam) { +LimitSet::LimitSet(const std::string& nam) { assign(new Object(), nam, "limitset"); } /// Add new limit. Returns true if the new limit was added, false if it already existed. bool LimitSet::addLimit(const Limit& limit) { - pair ret = data()->limits.insert(limit); + std::pair ret = data()->limits.insert(limit); return ret.second; } /// Accessor to limits container -const set& LimitSet::limits() const { +const std::set& LimitSet::limits() const { const Object* o = data(); return o->limits; } /// Add new limit. Returns true if the new limit was added, false if it already existed. bool LimitSet::addCut(const Limit& cut_obj) { - pair ret = data()->cuts.insert(cut_obj); + std::pair ret = data()->cuts.insert(cut_obj); return ret.second; } @@ -485,7 +478,7 @@ const std::set& LimitSet::cuts() const { } /// Constructor to be used when creating a new DOM tree -Region::Region(const string& nam) { +Region::Region(const std::string& nam) { Object* p = new Object(); assign(p, nam, "region"); p->magic = magic_word(); @@ -514,7 +507,7 @@ Region& Region::setCut(double value) { } /// Access references to user limits -vector& Region::limits() const { +std::vector& Region::limits() const { return object().user_limits; } @@ -555,28 +548,28 @@ struct IDSpec : public Ref_t { template IDSpec(const Handle& e) : Ref_t(e) {} /// Constructor to be used when creating a new DOM tree - IDSpec(Detector& doc, const string& name, const IDDescriptor& dsc); - void addField(const string& name, const pair& field); + IDSpec(Detector& doc, const std::string& name, const IDDescriptor& dsc); + void addField(const std::string& name, const std::pair& field); }; -IDSpec::IDSpec(Detector& description, const string& name, const IDDescriptor& dsc) +IDSpec::IDSpec(Detector& description, const std::string& name, const IDDescriptor& dsc) : RefElement(doc,Tag_idspec,name) { const IDDescriptor::FieldIDs& f = dsc.ids(); const IDDescriptor::FieldMap& m = dsc.fields(); object().Attr_length = dsc.maxBit(); for(const auto& i : f ) { - const string& nam = i.second; + const std::string& nam = i.second; const pair& fld = m.find(nam)->second; addField(nam,fld); } } -void IDSpec::addField(const string& name, const pair& field) { +void IDSpec::addField(const std::string& name, const pair& field) { addField(Strng_t(name),field); } -void IDSpec::addField(const string& name, const pair& field) { +void IDSpec::addField(const std::string& name, const pair& field) { Element e(document(),Tag_idfield); e.object().Attr_signed = field.second<0; e.object().Attr_label = name; diff --git a/DDCore/src/OpticalSurfaceManager.cpp b/DDCore/src/OpticalSurfaceManager.cpp index d991f4e97..41c996f28 100644 --- a/DDCore/src/OpticalSurfaceManager.cpp +++ b/DDCore/src/OpticalSurfaceManager.cpp @@ -12,17 +12,16 @@ //========================================================================== // Framework include files -#include "DD4hep/OpticalSurfaceManager.h" -#include "DD4hep/detail/OpticalSurfaceManagerInterna.h" -#include "DD4hep/ExtensionEntry.h" -#include "DD4hep/Detector.h" -#include "DD4hep/Printout.h" +#include +#include +#include +#include +#include // C/C++ includes #include #include -using namespace std; using namespace dd4hep; /// static accessor calling DD4hepOpticalSurfaceManagerPlugin if necessary @@ -30,13 +29,11 @@ OpticalSurfaceManager OpticalSurfaceManager::getOpticalSurfaceManager(Detector& return description.surfaceManager(); } -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) - /// Access skin surface by its identifier -SkinSurface OpticalSurfaceManager::skinSurface(DetElement de, const string& nam) const { +SkinSurface OpticalSurfaceManager::skinSurface(DetElement de, const std::string& nam) const { if ( de.isValid() ) { Object* o = access(); - string n = de.path() + '#' + nam; + std::string n = de.path() + '#' + nam; TGeoSkinSurface* surf = o->detector.manager().GetSkinSurface(n.c_str()); if ( surf ) return surf; auto i = o->skinSurfaces.find(Object::LocalKey(de, nam)); @@ -49,15 +46,15 @@ SkinSurface OpticalSurfaceManager::skinSurface(DetElement de, const string& nam } /// Access skin surface by its full name -SkinSurface OpticalSurfaceManager::skinSurface(const string& full_nam) const { +SkinSurface OpticalSurfaceManager::skinSurface(const std::string& full_nam) const { return access()->detector.manager().GetSkinSurface(full_nam.c_str()); } /// Access border surface by its identifier -BorderSurface OpticalSurfaceManager::borderSurface(DetElement de, const string& nam) const { +BorderSurface OpticalSurfaceManager::borderSurface(DetElement de, const std::string& nam) const { if ( de.isValid() ) { Object* o = access(); - string n = de.path() + '#' + nam; + std::string n = de.path() + '#' + nam; TGeoBorderSurface* surf = o->detector.manager().GetBorderSurface(n.c_str()); if ( surf ) return surf; auto i = o->borderSurfaces.find(Object::LocalKey(de, nam)); @@ -70,15 +67,15 @@ BorderSurface OpticalSurfaceManager::borderSurface(DetElement de, const string& } /// Access border surface by its full name -BorderSurface OpticalSurfaceManager::borderSurface(const string& full_nam) const { +BorderSurface OpticalSurfaceManager::borderSurface(const std::string& full_nam) const { return access()->detector.manager().GetBorderSurface(full_nam.c_str()); } /// Access optical surface data by its identifier -OpticalSurface OpticalSurfaceManager::opticalSurface(DetElement de, const string& nam) const { +OpticalSurface OpticalSurfaceManager::opticalSurface(DetElement de, const std::string& nam) const { if ( de.isValid() ) { Object* o = access(); - string n = de.path() + '#' + nam; + std::string n = de.path() + '#' + nam; TGeoOpticalSurface* surf = o->detector.manager().GetOpticalSurface(n.c_str()); if ( surf ) return surf; auto i = o->opticalSurfaces.find(n); @@ -91,13 +88,13 @@ OpticalSurface OpticalSurfaceManager::opticalSurface(DetElement de, const string } /// Access optical surface data by its identifier -OpticalSurface OpticalSurfaceManager::opticalSurface(const string& full_nam) const { +OpticalSurface OpticalSurfaceManager::opticalSurface(const std::string& full_nam) const { return access()->detector.manager().GetOpticalSurface(full_nam.c_str()); } /// Add skin surface to manager void OpticalSurfaceManager::addSkinSurface(DetElement de, SkinSurface surf) const { - if ( access()->skinSurfaces.emplace(make_pair(de,surf->GetName()), surf).second ) + if ( access()->skinSurfaces.emplace(std::make_pair(de,surf->GetName()), surf).second ) return; except("OpticalSurfaceManager","++ Skin surface %s already present for DE:%s.", surf->GetName(), de.name()); @@ -105,7 +102,7 @@ void OpticalSurfaceManager::addSkinSurface(DetElement de, SkinSurface surf) con /// Add border surface to manager void OpticalSurfaceManager::addBorderSurface(DetElement de, BorderSurface surf) const { - if ( access()->borderSurfaces.emplace(make_pair(de,surf->GetName()), surf).second ) + if ( access()->borderSurfaces.emplace(std::make_pair(de,surf->GetName()), surf).second ) return; except("OpticalSurfaceManager","++ Border surface %s already present for DE:%s.", surf->GetName(), de.name()); @@ -122,7 +119,7 @@ void OpticalSurfaceManager::addOpticalSurface(OpticalSurface surf) const { /// Register the temporary surface objects with the TGeoManager void OpticalSurfaceManager::registerSurfaces(DetElement subdetector) { Object* o = access(); - unique_ptr extension(new Object(o->detector)); + std::unique_ptr extension(new Object(o->detector)); for(auto& optical : o->opticalSurfaces) { o->detector.manager().AddOpticalSurface(optical.second.ptr()); extension->opticalSurfaces.insert(optical); @@ -130,7 +127,7 @@ void OpticalSurfaceManager::registerSurfaces(DetElement subdetector) { o->opticalSurfaces.clear(); for(auto& skin : o->skinSurfaces) { - string n = skin.first.first.path() + '#' + skin.first.second; + std::string n = skin.first.first.path() + '#' + skin.first.second; skin.second->SetName(n.c_str()); o->detector.manager().AddSkinSurface(skin.second.ptr()); extension->skinSurfaces.insert(skin); @@ -138,7 +135,7 @@ void OpticalSurfaceManager::registerSurfaces(DetElement subdetector) { o->skinSurfaces.clear(); for(auto& border : o->borderSurfaces) { - string n = border.first.first.path() + '#' + border.first.second; + std::string n = border.first.first.path() + '#' + border.first.second; border.second->SetName(n.c_str()); o->detector.manager().AddBorderSurface(border.second.ptr()); extension->borderSurfaces.insert(border); @@ -152,4 +149,4 @@ void OpticalSurfaceManager::registerSurfaces(DetElement subdetector) { } subdetector.addExtension(new detail::DeleteExtension(extension.release())); } -#endif + diff --git a/DDCore/src/OpticalSurfaces.cpp b/DDCore/src/OpticalSurfaces.cpp index 8b423a692..bd3fdad69 100644 --- a/DDCore/src/OpticalSurfaces.cpp +++ b/DDCore/src/OpticalSurfaces.cpp @@ -12,36 +12,33 @@ //========================================================================== // Framework include files -#include "DD4hep/OpticalSurfaces.h" -#include "DD4hep/NamedObject.h" -#include "DD4hep/Detector.h" -#include "DD4hep/Printout.h" -#include "DD4hep/World.h" +#include +#include +#include +#include +#include -#include "DD4hep/detail/Handle.inl" +#include // C/C++ includes #include #include -using namespace std; using namespace dd4hep; -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) - DD4HEP_INSTANTIATE_HANDLE(TGeoSkinSurface); DD4HEP_INSTANTIATE_HANDLE(TGeoBorderSurface); DD4HEP_INSTANTIATE_HANDLE(TGeoOpticalSurface); /// Initializing constructor. OpticalSurface::OpticalSurface(Detector& detector, - const string& full_name, + const std::string& full_name, EModel model, EFinish finish, EType type, double value) { - unique_ptr obj(new Object(full_name.c_str(), model, finish, type, value)); + std::unique_ptr obj(new Object(full_name.c_str(), model, finish, type, value)); detector.manager().AddOpticalSurface(m_element=obj.release()); } @@ -56,12 +53,12 @@ OpticalSurface::Property OpticalSurface::property(const std::string& nam) const } /// Initializing constructor: Creates the object and registers it to the manager -SkinSurface::SkinSurface(Detector& detector, DetElement de, const string& nam, OpticalSurface surf, Volume vol) +SkinSurface::SkinSurface(Detector& detector, DetElement de, const std::string& nam, OpticalSurface surf, Volume vol) { if ( de.isValid() ) { if ( vol.isValid() ) { if ( surf.isValid() ) { - unique_ptr obj(new Object(nam.c_str(), surf->GetName(), surf.ptr(), vol.ptr())); + std::unique_ptr obj(new Object(nam.c_str(), surf->GetName(), surf.ptr(), vol.ptr())); detector.surfaceManager().addSkinSurface(de, m_element=obj.release()); return; } @@ -98,7 +95,7 @@ Volume SkinSurface::volume() const { /// Initializing constructor: Creates the object and registers it to the manager BorderSurface::BorderSurface(Detector& detector, DetElement de, - const string& nam, + const std::string& nam, OpticalSurface surf, PlacedVolume lft, PlacedVolume rht) @@ -106,7 +103,7 @@ BorderSurface::BorderSurface(Detector& detector, if ( de.isValid() ) { if ( lft.isValid() && rht.isValid() ) { if ( surf.isValid() ) { - unique_ptr obj(new Object(nam.c_str(), surf->GetName(), surf.ptr(), lft.ptr(), rht.ptr())); + std::unique_ptr obj(new Object(nam.c_str(), surf->GetName(), surf.ptr(), lft.ptr(), rht.ptr())); detector.surfaceManager().addBorderSurface(de, m_element=obj.release()); return; } @@ -144,4 +141,4 @@ PlacedVolume BorderSurface::left() const { PlacedVolume BorderSurface::right() const { return access()->GetNode2(); } -#endif + diff --git a/DDCore/src/PropertyTable.cpp b/DDCore/src/PropertyTable.cpp index b0047e6d5..3a1324b5c 100644 --- a/DDCore/src/PropertyTable.cpp +++ b/DDCore/src/PropertyTable.cpp @@ -12,33 +12,29 @@ //========================================================================== // Framework include files -#include "DD4hep/PropertyTable.h" -#include "DD4hep/NamedObject.h" -#include "DD4hep/Detector.h" -#include "DD4hep/Printout.h" +#include +#include +#include +#include -#include "DD4hep/detail/Handle.inl" +#include // C/C++ includes #include #include -using namespace std; using namespace dd4hep; -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) - DD4HEP_INSTANTIATE_HANDLE(TGDMLMatrix); /// Initializing constructor. PropertyTable::PropertyTable(Detector& description, - const string& table_name, - const string& property_name, + const std::string& table_name, + const std::string& property_name, size_t num_rows, size_t num_cols) { - unique_ptr table(new Object(table_name.c_str(), num_rows, num_cols)); + std::unique_ptr table(new Object(table_name.c_str(), num_rows, num_cols)); table->SetTitle(property_name.c_str()); description.manager().AddGDMLMatrix(m_element=table.release()); } -#endif diff --git a/DDCore/src/ShapeUtilities.cpp b/DDCore/src/ShapeUtilities.cpp index 71af25f27..11c89c214 100644 --- a/DDCore/src/ShapeUtilities.cpp +++ b/DDCore/src/ShapeUtilities.cpp @@ -33,8 +33,6 @@ #include #include -using namespace std; - /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -48,7 +46,7 @@ namespace dd4hep { except("Dimension","Invalid shape pointer!"); return 0; } - inline void invalidSetDimensionCall(const TGeoShape* sh, const vector& params) { + inline void invalidSetDimensionCall(const TGeoShape* sh, const std::vector& params) { except("Solid","+++ Shape:%s setDimension: Invalid number of parameters: %ld", (sh ? typeName(typeid(*sh)) : typeName(typeid(sh))).c_str(), params.size()); } @@ -78,9 +76,7 @@ namespace dd4hep { template bool isInstance (const Handle& solid); template bool isInstance (const Handle& solid); template bool isInstance (const Handle& solid); -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) template bool isInstance (const Handle& solid); -#endif template bool isInstance (const Handle& solid); template <> bool isInstance(const Handle& solid) { @@ -153,9 +149,7 @@ namespace dd4hep { template bool isA(const Handle& solid); template bool isA(const Handle& solid); template bool isA(const Handle& solid); -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) template bool isA(const Handle& solid); -#endif template <> bool isA(const Handle& solid) { return check_shape_type(solid) && ::strcmp(solid->GetTitle(), TWISTEDTUBE_TAG) == 0; @@ -188,7 +182,7 @@ namespace dd4hep { } /// Retrieve tag name from shape type - string get_shape_tag(const TGeoShape* sh) { + std::string get_shape_tag(const TGeoShape* sh) { if ( sh ) { TClass* cl = sh->IsA(); if ( cl == TGeoShapeAssembly::Class() ) @@ -237,10 +231,8 @@ namespace dd4hep { return EXTRUDEDPOLYGON_TAG; else if ( cl == TGeoScaledShape::Class() ) return SCALE_TAG; -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) else if ( cl == TGeoTessellated::Class() ) return TESSELLATEDSOLID_TAG; -#endif else if (isA(sh) ) return TRUNCATEDTUBE_TAG; else if (isA(sh) ) @@ -260,30 +252,30 @@ namespace dd4hep { return ""; } - template vector dimensions(const TGeoShape* shape) { - stringstream str; + template std::vector dimensions(const TGeoShape* shape) { + std::stringstream str; if ( shape ) str << "Shape: dimension(" << typeName(typeid(*shape)) << "): Invalid call!"; else str << "Shape: dimension vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const auto* sh = get_ptr(shape); return { sh->GetDX(), sh->GetDY(), sh->GetDZ() }; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const auto* sh = get_ptr(shape); return { sh->GetDX(), sh->GetDY(), sh->GetDZ() }; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { auto* sh = get_ptr(shape); return { sh->GetPoint()[0], sh->GetPoint()[1], sh->GetPoint()[2], sh->GetNorm()[0], sh->GetNorm()[1], sh->GetNorm()[2] }; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const TGeoPcon* sh = get_ptr(shape); - vector pars { sh->GetPhi1()*units::deg, sh->GetDphi()*units::deg, double(sh->GetNz()) }; + std::vector pars { sh->GetPhi1()*units::deg, sh->GetDphi()*units::deg, double(sh->GetNz()) }; pars.reserve(3+3*sh->GetNz()); for (Int_t i = 0; i < sh->GetNz(); ++i) { pars.emplace_back(sh->GetZ(i)); @@ -292,30 +284,30 @@ namespace dd4hep { } return pars; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const TGeoConeSeg* sh = get_ptr(shape); return { sh->GetDz(), sh->GetRmin1(), sh->GetRmax1(), sh->GetRmin2(), sh->GetRmax2(), sh->GetPhi1()*units::deg, sh->GetPhi2()*units::deg }; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const TGeoCone* sh = get_ptr(shape); return { sh->GetDz(), sh->GetRmin1(), sh->GetRmax1(), sh->GetRmin2(), sh->GetRmax2() }; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const TGeoTube* sh = get_ptr(shape); return { sh->GetRmin(), sh->GetRmax(), sh->GetDz() }; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const TGeoTubeSeg* sh = get_ptr(shape); return { sh->GetRmin(), sh->GetRmax(), sh->GetDz(), sh->GetPhi1()*units::deg, sh->GetPhi2()*units::deg }; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const TwistedTubeObject* sh = get_ptr(shape); return { sh->GetPhiTwist(), sh->GetRmin(), sh->GetRmax(), sh->GetNegativeEndZ(), sh->GetPositiveEndZ(), double(sh->GetNsegments()), sh->GetPhi2()*units::deg }; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const TGeoCtub* sh = get_ptr(shape); const Double_t* lo = sh->GetNlow(); const Double_t* hi = sh->GetNhigh(); @@ -323,42 +315,42 @@ namespace dd4hep { sh->GetPhi1()*units::deg, sh->GetPhi2()*units::deg, lo[0], lo[1], lo[2], hi[0], hi[1], hi[2] }; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const TGeoEltu* sh = get_ptr(shape); return { sh->GetA(), sh->GetB(), sh->GetDz() }; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const TGeoTrd1* sh = get_ptr(shape); return { sh->GetDx1(), sh->GetDx2(), sh->GetDy(), sh->GetDz() }; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const TGeoTrd2* sh = get_ptr(shape); return { sh->GetDx1(), sh->GetDx2(), sh->GetDy1(), sh->GetDy2(), sh->GetDz() }; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const TGeoParaboloid* sh = get_ptr(shape); return { sh->GetRlo(), sh->GetRhi(), sh->GetDz() }; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const TGeoHype* sh = get_ptr(shape); return { sh->GetDz(), sh->GetRmin(), sh->GetStIn()*units::deg, sh->GetRmax(), sh->GetStOut()*units::deg }; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const TGeoSphere* sh = get_ptr(shape); return { sh->GetRmin(), sh->GetRmax(), sh->GetTheta1()*units::deg, sh->GetTheta2()*units::deg, sh->GetPhi1()*units::deg, sh->GetPhi2()*units::deg }; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const TGeoTorus* sh = get_ptr(shape); return { sh->GetR(), sh->GetRmin(), sh->GetRmax(), sh->GetPhi1()*units::deg, sh->GetDphi()*units::deg }; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const TGeoPgon* sh = get_ptr(shape); - vector pars { sh->GetPhi1()*units::deg, sh->GetDphi()*units::deg, double(sh->GetNedges()), double(sh->GetNz()) }; + std::vector pars { sh->GetPhi1()*units::deg, sh->GetDphi()*units::deg, double(sh->GetNedges()), double(sh->GetNz()) }; pars.reserve(4+3*sh->GetNz()); for (Int_t i = 0; i < sh->GetNz(); ++i) { pars.emplace_back(sh->GetZ(i)); @@ -367,10 +359,10 @@ namespace dd4hep { } return pars; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const TGeoXtru* sh = get_ptr(shape); Int_t nz = sh->GetNz(); - vector pars { double(nz) }; + std::vector pars { double(nz) }; pars.reserve(1+4*nz); for(Int_t i=0; iGetZ(i)); @@ -380,45 +372,44 @@ namespace dd4hep { } return pars; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { TGeoArb8* sh = get_ptr(shape); struct _V { double xy[8][2]; } *vtx = (_V*)sh->GetVertices(); - vector pars { sh->GetDz() }; + std::vector pars { sh->GetDz() }; for ( size_t i=0; i<8; ++i ) { pars.emplace_back(vtx->xy[i][0]); pars.emplace_back(vtx->xy[i][1]); } return pars; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const TGeoTrap* sh = get_ptr(shape); return { sh->GetDz(), sh->GetTheta()*units::deg, sh->GetPhi()*units::deg, sh->GetH1(), sh->GetBl1(), sh->GetTl1(), sh->GetAlpha1()*units::deg, sh->GetH2(), sh->GetBl2(), sh->GetTl2(), sh->GetAlpha2()*units::deg }; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const TGeoGtra* sh = get_ptr(shape); return { sh->GetDz(), sh->GetTheta()*units::deg, sh->GetPhi()*units::deg, sh->GetH1(), sh->GetBl1(), sh->GetTl1(), sh->GetAlpha1()*units::deg, sh->GetH2(), sh->GetBl2(), sh->GetTl2(), sh->GetAlpha2()*units::deg, sh->GetTwistAngle()*units::deg }; } - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { TGeoScaledShape* sh = get_ptr(shape); TGeoShape* s_sh = sh->GetShape(); const Double_t* scale = sh->GetScale()->GetScale(); - vector pars {scale[0],scale[1],scale[2]}; - vector s_pars = get_shape_dimensions(s_sh); + std::vector pars {scale[0],scale[1],scale[2]}; + std::vector s_pars = get_shape_dimensions(s_sh); for(auto p : s_pars) pars.push_back(p); return pars; } -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { TGeoTessellated* sh = get_ptr(shape); int num_facet = sh->GetNfacets(); int num_vtx = sh->GetNvertices(); - vector pars; + std::vector pars; printout(DEBUG,"TessellatedSolid","+++ Saving %d vertices, %d facets",num_vtx, num_facet); pars.reserve(num_facet*5+num_vtx*3+2); @@ -444,9 +435,8 @@ namespace dd4hep { } return pars; } -#endif - template <> vector dimensions(const TGeoShape* shape) { + template <> std::vector dimensions(const TGeoShape* shape) { const TGeoCompositeShape* sh = get_ptr(shape); const TGeoBoolNode* boolean = sh->GetBoolNode(); TGeoMatrix* right_matrix = boolean->GetRightMatrix(); @@ -460,9 +450,9 @@ namespace dd4hep { const Double_t* right_tr = right_matrix->GetTranslation(); const Double_t* right_rot = right_matrix->GetRotationMatrix(); - vector pars { double(oper) }; - vector left_par = Solid(left_solid).dimensions(); - vector right_par = Solid(right_solid).dimensions(); + std::vector pars { double(oper) }; + std::vector left_par = Solid(left_solid).dimensions(); + std::vector right_par = Solid(right_solid).dimensions(); pars.insert(pars.end(), left_par.begin(), left_par.end()); pars.insert(pars.end(), left_rot, left_rot+9); @@ -474,43 +464,41 @@ namespace dd4hep { return pars; } - template vector dimensions(const Handle& shape) + template std::vector dimensions(const Handle& shape) { return dimensions(get_ptr(shape.ptr())); } - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) - template vector dimensions (const Handle& shape); -#endif - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions (const Handle& shape); - template vector dimensions(const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions (const Handle& shape); + template std::vector dimensions(const Handle& shape); - template <> vector dimensions(const Handle& shape) { + template <> std::vector dimensions(const Handle& shape) { const TGeoCompositeShape* sh = get_ptr(shape.ptr()); TGeoMatrix* right_matrix = sh->GetBoolNode()->GetRightMatrix(); - stringstream params(right_matrix->GetTitle()); - vector pars; + std::stringstream params(right_matrix->GetTitle()); + std::vector pars; pars.reserve(7); #ifdef DIMENSION_DEBUG cout << "dimensions: [" << PSEUDOTRAP_TAG << "]" << endl @@ -527,11 +515,11 @@ namespace dd4hep { return pars; } - template <> vector dimensions(const Handle& shape) { + template <> std::vector dimensions(const Handle& shape) { const TGeoCompositeShape* sh = get_ptr(shape.ptr()); TGeoMatrix* right_matrix = sh->GetBoolNode()->GetRightMatrix(); - stringstream params(right_matrix->GetTitle()); - vector pars; + std::stringstream params(right_matrix->GetTitle()); + std::vector pars; pars.reserve(8); for(size_t i=0; i<8; ++i) { double val; @@ -544,7 +532,7 @@ namespace dd4hep { return pars; } - template <> vector dimensions(const Handle& shape) { + template <> std::vector dimensions(const Handle& shape) { if ( shape.ptr() ) { TClass* cl = shape->IsA(); if ( cl == TGeoShapeAssembly::Class() ) @@ -593,10 +581,8 @@ namespace dd4hep { return dimensions(shape.ptr() ); else if ( cl == TGeoScaledShape::Class() ) return dimensions(shape.ptr() ); -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) else if ( cl == TGeoTessellated::Class() ) return dimensions(shape.ptr() ); -#endif else if (isA(shape.ptr() )) return dimensions(shape); else if (isA(shape.ptr() )) @@ -614,21 +600,21 @@ namespace dd4hep { } /// Access Shape dimension parameters (As in TGeo, but angles in radians rather than degrees) - vector get_shape_dimensions(const Handle& shape) { + std::vector get_shape_dimensions(const Handle& shape) { return dimensions(shape); } /// Access Shape dimension parameters (As in TGeo, but angles in radians rather than degrees) - vector get_shape_dimensions(TGeoShape* shape) { + std::vector get_shape_dimensions(TGeoShape* shape) { return dimensions(Solid(shape)); } template void set_dimensions(T shape, const std::vector& ) { - stringstream str; + std::stringstream str; if ( shape ) str << "Shape: set_dimension(" << typeName(typeid(*shape)) << "): Invalid call!"; else str << "Shape: set_dimension void set_dimensions(TGeoShapeAssembly* , const std::vector& ) { @@ -656,7 +642,7 @@ namespace dd4hep { if ( params.size() != 3 + 3*nz ) { invalidSetDimensionCall(sh,params); } - vector pars = params; + std::vector pars = params; pars[0] /= units::deg; pars[1] /= units::deg; Solid(sh)._setDimensions(&pars[0]); @@ -827,7 +813,6 @@ namespace dd4hep { s_sh.access()->SetDimensions(&pars[3]); } -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) template <> void set_dimensions(TGeoTessellated* sh, const std::vector& params) { int num_vtx = params[0]; int num_facet = params[1]; @@ -840,8 +825,8 @@ namespace dd4hep { double z = params[++i_par]; vertices.emplace_back(x, y, z); } - string nam = sh->GetName(); - string tit = sh->GetTitle(); + std::string nam = sh->GetName(); + std::string tit = sh->GetTitle(); sh->~TGeoTessellated(); new(sh) TGeoTessellated(nam.c_str(), vertices); sh->SetTitle(tit.c_str()); @@ -859,7 +844,6 @@ namespace dd4hep { } sh->CloseShape(true, true, false); } -#endif template <> void set_dimensions(TGeoCompositeShape*, const std::vector&) { // In general TGeoCompositeShape instances have an empty SetDimension call @@ -873,7 +857,7 @@ namespace dd4hep { Solid(sh)._setDimensions(&pars[0]); #endif #ifdef DIMENSION_DEBUG - throw runtime_error("Composite shape. setDimensions is not implemented!"); + throw std::runtime_error("Composite shape. setDimensions is not implemented!"); #endif } @@ -921,10 +905,8 @@ namespace dd4hep { { set_dimensions(shape.ptr(), params); } template <> void set_dimensions(EightPointSolid shape, const std::vector& params) { set_dimensions(shape.ptr(), params); } -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) template <> void set_dimensions(TessellatedSolid shape, const std::vector& params) { set_dimensions(shape.ptr(), params); } -#endif template <> void set_dimensions(BooleanSolid shape, const std::vector& params) { set_dimensions(shape.ptr(), params); } template <> void set_dimensions(SubtractionSolid shape, const std::vector& params) @@ -1072,7 +1054,7 @@ namespace dd4hep { except("PseudoTrap","+++ Incompatible change of parameters."); } ((TGeoTranslation*)right_matrix)->SetTranslation(0,0,displacement); - stringstream str; + std::stringstream str; str << x1 << " " << x2 << " " << y1 << " " << y2 << " " << z << " " << r << " " << char(atMinusZ ? '1' : '0') << " "; right_matrix->SetTitle(str.str().c_str()); @@ -1125,10 +1107,8 @@ namespace dd4hep { set_dimensions(ExtrudedPolygon(shape), params); else if ( cl == TGeoArb8::Class() ) set_dimensions(EightPointSolid(shape), params); -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) else if ( cl == TGeoTessellated::Class() ) set_dimensions(TessellatedSolid(shape), params); -#endif else if ( cl == TGeoScaledShape::Class() ) { TGeoScaledShape* sh = (TGeoScaledShape*) shape.ptr(); set_dimensions(sh, params); @@ -1156,25 +1136,25 @@ namespace dd4hep { set_dimensions(Solid(shape), params); } /// Set the shape dimensions. As for the TGeo shape, but angles in rad rather than degrees. - void set_shape_dimensions(TGeoShape* shape, const vector& params) { + void set_shape_dimensions(TGeoShape* shape, const std::vector& params) { set_dimensions(Solid(shape), params); } /// Set the shape dimensions. As for the TGeo shape, but angles in rad rather than degrees. - void set_shape_dimensions(Solid solid, const vector& params) { + void set_shape_dimensions(Solid solid, const std::vector& params) { set_dimensions(solid, params); } /// Pretty print of solid attributes - string toStringSolid(const TGeoShape* shape, int precision) { + std::string toStringSolid(const TGeoShape* shape, int precision) { if ( !shape ) { return "[Invalid shape]"; } - stringstream log; + std::stringstream log; TClass* cl = shape->IsA(); int prec = log.precision(); - log.setf(ios::fixed,ios::floatfield); - log << setprecision(precision); + log.setf(std::ios::fixed,std::ios::floatfield); + log << std::setprecision(precision); log << cl->GetName(); if ( cl == TGeoBBox::Class() ) { TGeoBBox* sh = (TGeoBBox*) shape; @@ -1307,14 +1287,14 @@ namespace dd4hep { log << "Intersection: "; log << " Left:" << toStringSolid(left) << " Right:" << toStringSolid(right); } - log << setprecision(prec); + log << std::setprecision(prec); return log.str(); } /// Output mesh vertices to string - string toStringMesh(const TGeoShape* shape, int prec) { + std::string toStringMesh(const TGeoShape* shape, int prec) { Solid sol(shape); - stringstream os; + std::stringstream os; // Prints shape parameters Int_t nvert = 0, nsegs = 0, npols = 0; @@ -1323,31 +1303,31 @@ namespace dd4hep { Double_t* points = new Double_t[3*nvert]; sol->SetPoints(points); - os << setw(16) << left << sol->IsA()->GetName() - << " " << nvert << " Mesh-points:" << endl; - os << setw(16) << left << sol->IsA()->GetName() << " " << sol->GetName() + os << std::setw(16) << std::left << sol->IsA()->GetName() + << " " << nvert << " Mesh-points:" << std::endl; + os << std::setw(16) << std::left << sol->IsA()->GetName() << " " << sol->GetName() << " N(mesh)=" << sol->GetNmeshVertices() - << " N(vert)=" << nvert << " N(seg)=" << nsegs << " N(pols)=" << npols << endl; + << " N(vert)=" << nvert << " N(seg)=" << nsegs << " N(pols)=" << npols << std::endl; for(Int_t i=0; iIsA()->GetName() << " " << setw(3) << left << i - << " Local (" << setw(7) << setprecision(prec) << fixed << right << p[0]/dd4hep::cm - << ", " << setw(7) << setprecision(prec) << fixed << right << p[1]/dd4hep::cm - << ", " << setw(7) << setprecision(prec) << fixed << right << p[2]/dd4hep::cm - << ")" << endl; + os << std::setw(16) << std::left << sol->IsA()->GetName() << " " << std::setw(3) << std::left << i + << " Local (" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << p[0]/dd4hep::cm + << ", " << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << p[1]/dd4hep::cm + << ", " << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << p[2]/dd4hep::cm + << ")" << std::endl; } Box box = sol; const Double_t* org = box->GetOrigin(); - os << setw(16) << left << sol->IsA()->GetName() + os << std::setw(16) << std::left << sol->IsA()->GetName() << " Bounding box: " - << " dx=" << setw(7) << setprecision(prec) << fixed << right << box->GetDX()/dd4hep::cm - << " dy=" << setw(7) << setprecision(prec) << fixed << right << box->GetDY()/dd4hep::cm - << " dz=" << setw(7) << setprecision(prec) << fixed << right << box->GetDZ()/dd4hep::cm - << " Origin: x=" << setw(7) << setprecision(prec) << fixed << right << org[0]/dd4hep::cm - << " y=" << setw(7) << setprecision(prec) << fixed << right << org[1]/dd4hep::cm - << " z=" << setw(7) << setprecision(prec) << fixed << right << org[2]/dd4hep::cm - << endl; + << " dx=" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << box->GetDX()/dd4hep::cm + << " dy=" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << box->GetDY()/dd4hep::cm + << " dz=" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << box->GetDZ()/dd4hep::cm + << " Origin: x=" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << org[0]/dd4hep::cm + << " y=" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << org[1]/dd4hep::cm + << " z=" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << org[2]/dd4hep::cm + << std::endl; /// -------------------- DONE -------------------- delete [] points; diff --git a/DDCore/src/Shapes.cpp b/DDCore/src/Shapes.cpp index 10d4643d5..3077b215b 100644 --- a/DDCore/src/Shapes.cpp +++ b/DDCore/src/Shapes.cpp @@ -33,7 +33,6 @@ #include #include -using namespace std; using namespace dd4hep; namespace units = dd4hep; @@ -45,7 +44,7 @@ template void Solid_type::_setDimensions(double* param) const /// Assign pointrs and register solid to geometry template -void Solid_type::_assign(T* n, const string& nam, const string& tit, bool cbbox) { +void Solid_type::_assign(T* n, const std::string& nam, const std::string& tit, bool cbbox) { this->assign(n, nam, tit); if (cbbox) n->ComputeBBox(); @@ -74,7 +73,7 @@ template Solid_type& Solid_type::setName(const char* value) } /// Set new shape name -template Solid_type& Solid_type::setName(const string& value) { +template Solid_type& Solid_type::setName(const std::string& value) { this->access()->SetName(value.c_str()); return *this; } @@ -88,19 +87,19 @@ template const char* Solid_type::type() const { } /// Access the dimensions of the shape: inverse of the setDimensions member function -template vector Solid_type::dimensions() { +template std::vector Solid_type::dimensions() { return get_shape_dimensions(this->access()); } /// Set the shape dimensions. As for the TGeo shape, but angles in rad rather than degrees. -template Solid_type& Solid_type::setDimensions(const vector& params) { +template Solid_type& Solid_type::setDimensions(const std::vector& params) { set_shape_dimensions(this->access(), params); return *this; } /// Divide volume into subsections (See the ROOT manuloa for details) template TGeoVolume* -Solid_type::divide(const Volume& voldiv, const string& divname, +Solid_type::divide(const Volume& voldiv, const std::string& divname, int iaxis, int ndiv, double start, double step) const { T* p = this->ptr(); if ( p ) { @@ -117,12 +116,12 @@ Solid_type::divide(const Volume& voldiv, const string& divname, } /// Constructor to create an anonymous new box object (retrieves name from volume) -ShapelessSolid::ShapelessSolid(const string& nam) { +ShapelessSolid::ShapelessSolid(const std::string& nam) { _assign(new TGeoShapeAssembly(), nam, SHAPELESS_TAG, true); } -void Scale::make(const string& nam, Solid base, double x_scale, double y_scale, double z_scale) { - auto scale = make_unique(x_scale, y_scale, z_scale); +void Scale::make(const std::string& nam, Solid base, double x_scale, double y_scale, double z_scale) { + auto scale = std::make_unique(x_scale, y_scale, z_scale); _assign(new TGeoScaledShape(nam.c_str(), base.access(), scale.release()), "", SCALE_TAG, true); } @@ -141,7 +140,7 @@ double Scale::scale_z() const { return this->access()->GetScale()->GetScale()[2]; } -void Box::make(const string& nam, double x_val, double y_val, double z_val) { +void Box::make(const std::string& nam, double x_val, double y_val, double z_val) { _assign(new TGeoBBox(nam.c_str(), x_val, y_val, z_val), "", BOX_TAG, true); } @@ -168,7 +167,7 @@ double Box::z() const { } /// Internal helper method to support object construction -void HalfSpace::make(const string& nam, const double* const point, const double* const normal) { +void HalfSpace::make(const std::string& nam, const double* const point, const double* const normal) { _assign(new TGeoHalfSpace(nam.c_str(),(Double_t*)point, (Double_t*)normal), "", HALFSPACE_TAG,true); } @@ -179,18 +178,18 @@ Polycone::Polycone(double startPhi, double deltaPhi) { /// Constructor to be used when creating a new polycone object. Add at the same time all Z planes Polycone::Polycone(double startPhi, double deltaPhi, - const vector& rmin, const vector& rmax, const vector& z) { - vector params; + const std::vector& rmin, const std::vector& rmax, const std::vector& z) { + std::vector params; if (rmin.size() < 2) { - throw runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!"); + throw std::runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!"); } if((z.size()!=rmin.size()) || (z.size()!=rmax.size()) ) { - throw runtime_error("dd4hep: Polycone: vectors z,rmin,rmax not of same length"); + throw std::runtime_error("dd4hep: Polycone: vectors z,rmin,rmax not of same length"); } params.emplace_back(startPhi/units::deg); params.emplace_back(deltaPhi/units::deg); params.emplace_back(rmin.size()); - for (size_t i = 0; i < rmin.size(); ++i) { + for (std::size_t i = 0; i < rmin.size(); ++i) { params.emplace_back(z[i] ); params.emplace_back(rmin[i] ); params.emplace_back(rmax[i] ); @@ -199,18 +198,18 @@ Polycone::Polycone(double startPhi, double deltaPhi, } /// Constructor to be used when creating a new polycone object. Add at the same time all Z planes -Polycone::Polycone(double startPhi, double deltaPhi, const vector& r, const vector& z) { - vector params; +Polycone::Polycone(double startPhi, double deltaPhi, const std::vector& r, const std::vector& z) { + std::vector params; if (r.size() < 2) { - throw runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!"); + throw std::runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!"); } if((z.size()!=r.size()) ) { - throw runtime_error("dd4hep: Polycone: vectors z,r not of same length"); + throw std::runtime_error("dd4hep: Polycone: vectors z,r not of same length"); } params.emplace_back(startPhi/units::deg); params.emplace_back(deltaPhi/units::deg); params.emplace_back(r.size()); - for (size_t i = 0; i < r.size(); ++i) { + for (std::size_t i = 0; i < r.size(); ++i) { params.emplace_back(z[i] ); params.emplace_back(0.0 ); params.emplace_back(r[i] ); @@ -219,24 +218,24 @@ Polycone::Polycone(double startPhi, double deltaPhi, const vector& r, co } /// Constructor to be used when creating a new object -Polycone::Polycone(const string& nam, double startPhi, double deltaPhi) { +Polycone::Polycone(const std::string& nam, double startPhi, double deltaPhi) { _assign(new TGeoPcon(nam.c_str(), startPhi/units::deg, deltaPhi/units::deg, 0), "", POLYCONE_TAG, false); } /// Constructor to be used when creating a new polycone object. Add at the same time all Z planes -Polycone::Polycone(const string& nam, double startPhi, double deltaPhi, - const vector& rmin, const vector& rmax, const vector& z) { - vector params; +Polycone::Polycone(const std::string& nam, double startPhi, double deltaPhi, + const std::vector& rmin, const std::vector& rmax, const std::vector& z) { + std::vector params; if (rmin.size() < 2) { - throw runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!"); + throw std::runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!"); } if((z.size()!=rmin.size()) || (z.size()!=rmax.size()) ) { - throw runtime_error("dd4hep: Polycone: vectors z,rmin,rmax not of same length"); + throw std::runtime_error("dd4hep: Polycone: vectors z,rmin,rmax not of same length"); } params.emplace_back(startPhi/units::deg); params.emplace_back(deltaPhi/units::deg); params.emplace_back(rmin.size()); - for (size_t i = 0; i < rmin.size(); ++i) { + for (std::size_t i = 0; i < rmin.size(); ++i) { params.emplace_back(z[i] ); params.emplace_back(rmin[i] ); params.emplace_back(rmax[i] ); @@ -245,18 +244,18 @@ Polycone::Polycone(const string& nam, double startPhi, double deltaPhi, } /// Constructor to be used when creating a new polycone object. Add at the same time all Z planes -Polycone::Polycone(const string& nam, double startPhi, double deltaPhi, const vector& r, const vector& z) { - vector params; +Polycone::Polycone(const std::string& nam, double startPhi, double deltaPhi, const std::vector& r, const std::vector& z) { + std::vector params; if (r.size() < 2) { - throw runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!"); + throw std::runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!"); } if((z.size()!=r.size()) ) { - throw runtime_error("dd4hep: Polycone: vectors z,r not of same length"); + throw std::runtime_error("dd4hep: Polycone: vectors z,r not of same length"); } params.emplace_back(startPhi/units::deg); params.emplace_back(deltaPhi/units::deg); params.emplace_back(r.size()); - for (size_t i = 0; i < r.size(); ++i) { + for (std::size_t i = 0; i < r.size(); ++i) { params.emplace_back(z[i] ); params.emplace_back(0.0 ); params.emplace_back(r[i] ); @@ -265,22 +264,22 @@ Polycone::Polycone(const string& nam, double startPhi, double deltaPhi, const ve } /// Add Z-planes to the Polycone -void Polycone::addZPlanes(const vector& rmin, const vector& rmax, const vector& z) { +void Polycone::addZPlanes(const std::vector& rmin, const std::vector& rmax, const std::vector& z) { TGeoPcon* sh = *this; - vector params; - size_t num = sh->GetNz(); + std::vector params; + std::size_t num = sh->GetNz(); if (rmin.size() < 2) { except("PolyCone","++ addZPlanes: Not enough Z planes. minimum is 2!"); } params.emplace_back(sh->GetPhi1()); params.emplace_back(sh->GetDphi()); params.emplace_back(num + rmin.size()); - for (size_t i = 0; i < num; ++i) { + for (std::size_t i = 0; i < num; ++i) { params.emplace_back(sh->GetZ(i)); params.emplace_back(sh->GetRmin(i)); params.emplace_back(sh->GetRmax(i)); } - for (size_t i = 0; i < rmin.size(); ++i) { + for (std::size_t i = 0; i < rmin.size(); ++i) { params.emplace_back(z[i] ); params.emplace_back(rmin[i] ); params.emplace_back(rmax[i] ); @@ -289,7 +288,7 @@ void Polycone::addZPlanes(const vector& rmin, const vector& rmax } /// Constructor to be used when creating a new cone segment object -void ConeSegment::make(const string& nam, +void ConeSegment::make(const std::string& nam, double dz, double rmin1, double rmax1, double rmin2, double rmax2, @@ -310,7 +309,7 @@ ConeSegment& ConeSegment::setDimensions(double dz, } /// Constructor to be used when creating a new object with attribute initialization -void Cone::make(const string& nam, double z, double rmin1, double rmax1, double rmin2, double rmax2) { +void Cone::make(const std::string& nam, double z, double rmin1, double rmax1, double rmin2, double rmax2) { _assign(new TGeoCone(nam.c_str(), z, rmin1, rmax1, rmin2, rmax2 ), "", CONE_TAG, true); } @@ -322,7 +321,7 @@ Cone& Cone::setDimensions(double z, double rmin1, double rmax1, double rmin2, do } /// Constructor to be used when creating a new object with attribute initialization -void Tube::make(const string& nam, double rmin, double rmax, double z, double start_phi, double end_phi) { +void Tube::make(const std::string& nam, double rmin, double rmax, double z, double start_phi, double end_phi) { // Check if it is a full tube if(fabs(end_phi-start_phi-2*M_PI)<10e-6){ _assign(new TGeoTubeSeg(nam.c_str(), rmin, rmax, z, start_phi/units::deg, start_phi/units::deg+360.),nam,TUBE_TAG,true); @@ -345,14 +344,14 @@ CutTube::CutTube(double rmin, double rmax, double dz, double start_phi, double e } /// Constructor to be used when creating a new object with attribute initialization -CutTube::CutTube(const string& nam, +CutTube::CutTube(const std::string& nam, double rmin, double rmax, double dz, double start_phi, double end_phi, double lx, double ly, double lz, double tx, double ty, double tz) { make(nam, rmin,rmax,dz,start_phi/units::deg,end_phi/units::deg,lx,ly,lz,tx,ty,tz); } /// Constructor to be used when creating a new object with attribute initialization -void CutTube::make(const string& nam, double rmin, double rmax, double dz, double start_phi, double end_phi, +void CutTube::make(const std::string& nam, double rmin, double rmax, double dz, double start_phi, double end_phi, double lx, double ly, double lz, double tx, double ty, double tz) { _assign(new TGeoCtub(nam.c_str(), rmin,rmax,dz,start_phi,end_phi,lx,ly,lz,tx,ty,tz),"",CUTTUBE_TAG,true); } @@ -363,13 +362,13 @@ TruncatedTube::TruncatedTube(double dz, double rmin, double rmax, double start_p { make("", dz, rmin, rmax, start_phi/units::deg, delta_phi/units::deg, cut_atStart, cut_atDelta, cut_inside); } /// Constructor to create a truncated tube object with attribute initialization -TruncatedTube::TruncatedTube(const string& nam, +TruncatedTube::TruncatedTube(const std::string& nam, double dz, double rmin, double rmax, double start_phi, double delta_phi, double cut_atStart, double cut_atDelta, bool cut_inside) { make(nam, dz, rmin, rmax, start_phi/units::deg, delta_phi/units::deg, cut_atStart, cut_atDelta, cut_inside); } /// Internal helper method to support object construction -void TruncatedTube::make(const string& nam, +void TruncatedTube::make(const std::string& nam, double dz, double rmin, double rmax, double start_phi, double delta_phi, double cut_atStart, double cut_atDelta, bool cut_inside) { // check the parameters @@ -411,55 +410,55 @@ void TruncatedTube::make(const string& nam, TGeoCombiTrans* combi = new TGeoCombiTrans(trans, rot); TGeoSubtraction* sub = new TGeoSubtraction(tubs, box, nullptr, combi); _assign(new TGeoCompositeShape(nam.c_str(), sub),"",TRUNCATEDTUBE_TAG,true); - stringstream params; - params << dz << " " << endl - << rmin << " " << endl - << rmax << " " << endl - << start_phi*units::deg << " " << endl - << delta_phi*units::deg << " " << endl - << cut_atStart << " " << endl - << cut_atDelta << " " << endl - << char(cut_inside ? '1' : '0') << endl; + std::stringstream params; + params << dz << " " << std::endl + << rmin << " " << std::endl + << rmax << " " << std::endl + << start_phi*units::deg << " " << std::endl + << delta_phi*units::deg << " " << std::endl + << cut_atStart << " " << std::endl + << cut_atDelta << " " << std::endl + << char(cut_inside ? '1' : '0') << std::endl; combi->SetTitle(params.str().c_str()); - //cout << "Params: " << params.str() << endl; + //cout << "Params: " << params.str() << std::endl; #if 0 - params << TRUNCATEDTUBE_TAG << ":" << endl - << "\t dz: " << dz << " " << endl - << "\t rmin: " << rmin << " " << endl - << "\t rmax: " << rmax << " " << endl - << "\t startPhi: " << start_phi << " " << endl - << "\t deltaPhi: " << delta_phi << " " << endl - << "\t r/cutAtStart:" << cut_atStart << " " << endl - << "\t R/cutAtDelta:" << cut_atDelta << " " << endl - << "\t cutInside: " << char(cut_inside ? '1' : '0') << endl - << "\t\t alpha: " << alpha << endl - << "\t\t sin_alpha: " << sin_alpha << endl - << "\t\t boxY: " << boxY << endl - << "\t\t xBox: " << xBox << endl; + params << TRUNCATEDTUBE_TAG << ":" << std::endl + << "\t dz: " << dz << " " << std::endl + << "\t rmin: " << rmin << " " << std::endl + << "\t rmax: " << rmax << " " << std::endl + << "\t startPhi: " << start_phi << " " << std::endl + << "\t deltaPhi: " << delta_phi << " " << std::endl + << "\t r/cutAtStart:" << cut_atStart << " " << std::endl + << "\t R/cutAtDelta:" << cut_atDelta << " " << std::endl + << "\t cutInside: " << char(cut_inside ? '1' : '0') << std::endl + << "\t\t alpha: " << alpha << std::endl + << "\t\t sin_alpha: " << sin_alpha << std::endl + << "\t\t boxY: " << boxY << std::endl + << "\t\t xBox: " << xBox << std::endl; #endif #if 0 - cout << "Trans:"; trans.Print(); cout << endl; - cout << "Rot: "; rot.Print(); cout << endl; + cout << "Trans:"; trans.Print(); cout << std::endl; + cout << "Rot: "; rot.Print(); cout << std::endl; cout << " Dz: " << dz << " rmin: " << rmin << " rmax: " << rmax << " r/cutAtStart: " << r << " R/cutAtDelta: " << R << " cutInside: " << (cut_inside ? "YES" : "NO ") - << endl; + << std::endl; cout << " cath: " << cath << " hypo: " << hypo << " cos_alpha: " << cos_alpha << " alpha: " << alpha << " alpha(deg):" << alpha/dd4hep::deg - << endl; + << std::endl; cout << " Deg: " << dd4hep::deg << " cm: " << dd4hep::cm << " xBox: " << xBox - << endl; - cout << "Box:" << "x:" << box->GetDX() << " y:" << box->GetDY() << " z:" << box->GetDZ() << endl; + << std::endl; + cout << "Box:" << "x:" << box->GetDX() << " y:" << box->GetDY() << " z:" << box->GetDZ() << std::endl; cout << "Tubs:" << " rmin:" << rmin << " rmax" << rmax << "dZ" << dZ - << " startPhi:" << start_phi << " deltaPhi:" << delta_phi << endl; + << " startPhi:" << start_phi << " deltaPhi:" << delta_phi << std::endl; #endif } @@ -504,7 +503,7 @@ bool TruncatedTube::cutInside() const { } /// Constructor to be used when creating a new object with attribute initialization -void EllipticalTube::make(const string& nam, double a, double b, double dz) { +void EllipticalTube::make(const std::string& nam, double a, double b, double dz) { _assign(new TGeoEltu(nam.c_str(), a, b, dz), "", ELLIPTICALTUBE_TAG, true); } @@ -516,7 +515,7 @@ void TwistedTube::make(const std::string& nam, double twist_angle, double rmin, } /// Constructor to be used when creating a new object with attribute initialization -void Trd1::make(const string& nam, double x1, double x2, double y, double z) { +void Trd1::make(const std::string& nam, double x1, double x2, double y, double z) { _assign(new TGeoTrd1(nam.c_str(), x1, x2, y, z ), "", TRD1_TAG, true); } @@ -528,7 +527,7 @@ Trd1& Trd1::setDimensions(double x1, double x2, double y, double z) { } /// Constructor to be used when creating a new object with attribute initialization -void Trd2::make(const string& nam, double x1, double x2, double y1, double y2, double z) { +void Trd2::make(const std::string& nam, double x1, double x2, double y1, double y2, double z) { _assign(new TGeoTrd2(nam.c_str(), x1, x2, y1, y2, z ), "", TRD2_TAG, true); } @@ -540,7 +539,7 @@ Trd2& Trd2::setDimensions(double x1, double x2, double y1, double y2, double z) } /// Constructor to be used when creating a new object with attribute initialization -void Paraboloid::make(const string& nam, double r_low, double r_high, double delta_z) { +void Paraboloid::make(const std::string& nam, double r_low, double r_high, double delta_z) { _assign(new TGeoParaboloid(nam.c_str(), r_low, r_high, delta_z ), "", PARABOLOID_TAG, true); } @@ -552,7 +551,7 @@ Paraboloid& Paraboloid::setDimensions(double r_low, double r_high, double delta_ } /// Constructor to create a new anonymous object with attribute initialization -void Hyperboloid::make(const string& nam, double rin, double stin, double rout, double stout, double dz) { +void Hyperboloid::make(const std::string& nam, double rin, double stin, double rout, double stout, double dz) { _assign(new TGeoHype(nam.c_str(), rin, stin/units::deg, rout, stout/units::deg, dz), "", HYPERBOLOID_TAG, true); } @@ -564,7 +563,7 @@ Hyperboloid& Hyperboloid::setDimensions(double rin, double stin, double rout, do } /// Constructor function to be used when creating a new object with attribute initialization -void Sphere::make(const string& nam, double rmin, double rmax, double startTheta, double endTheta, double startPhi, double endPhi) { +void Sphere::make(const std::string& nam, double rmin, double rmax, double startTheta, double endTheta, double startPhi, double endPhi) { _assign(new TGeoSphere(nam.c_str(), rmin, rmax, startTheta/units::deg, endTheta/units::deg, startPhi/units::deg, endPhi/units::deg), "", SPHERE_TAG, true); @@ -578,7 +577,7 @@ Sphere& Sphere::setDimensions(double rmin, double rmax, double startTheta, doubl } /// Constructor to be used when creating a new object with attribute initialization -void Torus::make(const string& nam, double r, double rmin, double rmax, double startPhi, double deltaPhi) { +void Torus::make(const std::string& nam, double r, double rmin, double rmax, double startPhi, double deltaPhi) { _assign(new TGeoTorus(nam.c_str(), r, rmin, rmax, startPhi/units::deg, deltaPhi/units::deg), "", TORUS_TAG, true); } @@ -599,7 +598,7 @@ Trap::Trap(double z, double theta, double phi, } /// Constructor to be used when creating a new anonymous object with attribute initialization -Trap::Trap(const string& nam, +Trap::Trap(const std::string& nam, double z, double theta, double phi, double h1, double bl1, double tl1, double alpha1, double h2, double bl2, double tl2, double alpha2) { @@ -609,7 +608,7 @@ Trap::Trap(const string& nam, } /// Constructor to be used when creating a new anonymous object with attribute initialization -void Trap::make(const string& nam, double pZ, double pY, double pX, double pLTX) { +void Trap::make(const std::string& nam, double pZ, double pY, double pX, double pLTX) { double fDz = 0.5*pZ; double fTheta = 0; double fPhi = 0; @@ -640,7 +639,7 @@ Trap& Trap::setDimensions(double z, double theta, double phi, } /// Internal helper method to support object construction -void PseudoTrap::make(const string& nam, double x1, double x2, double y1, double y2, double z, double r, bool atMinusZ) { +void PseudoTrap::make(const std::string& nam, double x1, double x2, double y1, double y2, double z, double r, bool atMinusZ) { double x = atMinusZ ? x1 : x2; double h = 0; bool intersec = false; // union or intersection solid @@ -724,7 +723,7 @@ void PseudoTrap::make(const string& nam, double x1, double x2, double y1, double Solid trap(new TGeoTrd2((nam+"Trd2").c_str(), x1, x2, y1, y2, halfZ)); Solid tubs(new TGeoTubeSeg((nam+"Tubs").c_str(), 0.,std::abs(r),h,startPhi,startPhi + halfOpeningAngle*2.)); - stringstream params; + std::stringstream params; params << x1 << " " << x2 << " " << y1 << " " << y2 << " " << z << " " << r << " " << char(atMinusZ ? '1' : '0') << " "; TGeoCompositeShape* solid = 0; @@ -742,21 +741,21 @@ void PseudoTrap::make(const string& nam, double x1, double x2, double y1, double } /// Helper function to create poly hedron -void PolyhedraRegular::make(const string& nam, int nsides, double rmin, double rmax, +void PolyhedraRegular::make(const std::string& nam, int nsides, double rmin, double rmax, double zpos, double zneg, double start, double delta) { if (rmin < 0e0 || rmin > rmax) - throw runtime_error("dd4hep: PolyhedraRegular: Illegal argument rmin:<" + _toString(rmin) + "> is invalid!"); + throw std::runtime_error("dd4hep: PolyhedraRegular: Illegal argument rmin:<" + _toString(rmin) + "> is invalid!"); else if (rmax < 0e0) - throw runtime_error("dd4hep: PolyhedraRegular: Illegal argument rmax:<" + _toString(rmax) + "> is invalid!"); + throw std::runtime_error("dd4hep: PolyhedraRegular: Illegal argument rmax:<" + _toString(rmax) + "> is invalid!"); double params[] = { start/units::deg, delta/units::deg, double(nsides), 2e0, zpos, rmin, rmax, zneg, rmin, rmax }; _assign(new TGeoPgon(params), nam, POLYHEDRA_TAG, false); //_setDimensions(¶ms[0]); } /// Helper function to create poly hedron -void Polyhedra::make(const string& nam, int nsides, double start, double delta, - const vector& z, const vector& rmin, const vector& rmax) { - vector temp; +void Polyhedra::make(const std::string& nam, int nsides, double start, double delta, + const std::vector& z, const std::vector& rmin, const std::vector& rmax) { + std::vector temp; if ( rmin.size() != z.size() || rmax.size() != z.size() ) { except("Polyhedra", "Number of values to define zplanes are incorrect: z:%ld rmin:%ld rmax:%ld", @@ -768,7 +767,7 @@ void Polyhedra::make(const string& nam, int nsides, double start, double delta, temp.emplace_back(delta/units::deg); temp.emplace_back(double(nsides)); temp.emplace_back(double(z.size())); - for(size_t i=0; i& pt_x, - const vector& pt_y, - const vector& sec_z, - const vector& sec_x, - const vector& sec_y, - const vector& sec_scale) +void ExtrudedPolygon::make(const std::string& nam, + const std::vector& pt_x, + const std::vector& pt_y, + const std::vector& sec_z, + const std::vector& sec_x, + const std::vector& sec_y, + const std::vector& sec_scale) { TGeoXtru* solid = new TGeoXtru(sec_z.size()); _assign(solid, nam, EXTRUDEDPOLYGON_TAG, false); // No need to transform coordinates to cm. We are in the dd4hep world: all is already in cm. solid->DefinePolygon(pt_x.size(), &(*pt_x.begin()), &(*pt_y.begin())); - for( size_t i = 0; i < sec_z.size(); ++i ) + for( std::size_t i = 0; i < sec_z.size(); ++i ) solid->DefineSection(i, sec_z[i], sec_x[i], sec_y[i], sec_scale[i]); } /// Creator method for arbitrary eight point solids -void EightPointSolid::make(const string& nam, double dz, const double* vtx) { +void EightPointSolid::make(const std::string& nam, double dz, const double* vtx) { _assign(new TGeoArb8(nam.c_str(), dz, (double*)vtx), "", EIGHTPOINTSOLID_TAG, true); } -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) /// Internal helper method to support object construction void TessellatedSolid::make(const std::string& nam, int num_facets) { _assign(new TGeoTessellated(nam.c_str(), num_facets), nam, TESSELLATEDSOLID_TAG, false); @@ -848,7 +846,6 @@ int TessellatedSolid::num_vertex() const { const TessellatedSolid::Vertex& TessellatedSolid::vertex(int index) const { return ptr()->GetVertex(index); } -#endif /// Access right solid of the boolean Solid BooleanSolid::rightShape() const { @@ -901,31 +898,31 @@ SubtractionSolid::SubtractionSolid(const Solid& shape1, const Solid& shape2, con } /// Constructor to be used when creating a new object. Position is identity, Rotation is the identity rotation -SubtractionSolid::SubtractionSolid(const string& nam, const Solid& shape1, const Solid& shape2) { +SubtractionSolid::SubtractionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2) { TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_identity()); _assign(new TGeoCompositeShape(nam.c_str(), sub), "", SUBTRACTION_TAG, true); } /// Constructor to be used when creating a new object. Placement by a generic transformation within the mother -SubtractionSolid::SubtractionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const Transform3D& trans) { +SubtractionSolid::SubtractionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Transform3D& trans) { TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_transform(trans)); _assign(new TGeoCompositeShape(nam.c_str(), sub), "", SUBTRACTION_TAG, true); } /// Constructor to be used when creating a new object. Rotation is the identity rotation -SubtractionSolid::SubtractionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const Position& pos) { +SubtractionSolid::SubtractionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Position& pos) { TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_translation(pos)); _assign(new TGeoCompositeShape(nam.c_str(), sub), "", SUBTRACTION_TAG, true); } /// Constructor to be used when creating a new object -SubtractionSolid::SubtractionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const RotationZYX& rot) { +SubtractionSolid::SubtractionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const RotationZYX& rot) { TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotationZYX(rot)); _assign(new TGeoCompositeShape(nam.c_str(), sub), "", SUBTRACTION_TAG, true); } /// Constructor to be used when creating a new object -SubtractionSolid::SubtractionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const Rotation3D& rot) { +SubtractionSolid::SubtractionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Rotation3D& rot) { TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotation3D(rot)); _assign(new TGeoCompositeShape(nam.c_str(), sub), "", SUBTRACTION_TAG, true); } @@ -961,31 +958,31 @@ UnionSolid::UnionSolid(const Solid& shape1, const Solid& shape2, const Rotation3 } /// Constructor to be used when creating a new object. Position is identity, Rotation is identity rotation -UnionSolid::UnionSolid(const string& nam, const Solid& shape1, const Solid& shape2) { +UnionSolid::UnionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2) { TGeoUnion* uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_identity()); _assign(new TGeoCompositeShape(nam.c_str(), uni), "", UNION_TAG, true); } /// Constructor to be used when creating a new object. Placement by a generic transformation within the mother -UnionSolid::UnionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const Transform3D& trans) { +UnionSolid::UnionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Transform3D& trans) { TGeoUnion* uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_transform(trans)); _assign(new TGeoCompositeShape(nam.c_str(), uni), "", UNION_TAG, true); } /// Constructor to be used when creating a new object. Rotation is identity rotation -UnionSolid::UnionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const Position& pos) { +UnionSolid::UnionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Position& pos) { TGeoUnion* uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_translation(pos)); _assign(new TGeoCompositeShape(nam.c_str(), uni), "", UNION_TAG, true); } /// Constructor to be used when creating a new object -UnionSolid::UnionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const RotationZYX& rot) { +UnionSolid::UnionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const RotationZYX& rot) { TGeoUnion *uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotationZYX(rot)); _assign(new TGeoCompositeShape(nam.c_str(), uni), "", UNION_TAG, true); } /// Constructor to be used when creating a new object -UnionSolid::UnionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const Rotation3D& rot) { +UnionSolid::UnionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Rotation3D& rot) { TGeoUnion *uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotation3D(rot)); _assign(new TGeoCompositeShape(nam.c_str(), uni), "", UNION_TAG, true); } @@ -1021,31 +1018,31 @@ IntersectionSolid::IntersectionSolid(const Solid& shape1, const Solid& shape2, c } /// Constructor to be used when creating a new object. Position is identity, Rotation is identity rotation -IntersectionSolid::IntersectionSolid(const string& nam, const Solid& shape1, const Solid& shape2) { +IntersectionSolid::IntersectionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2) { TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_identity()); _assign(new TGeoCompositeShape(nam.c_str(), inter), "", INTERSECTION_TAG, true); } /// Constructor to be used when creating a new object. Placement by a generic transformation within the mother -IntersectionSolid::IntersectionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const Transform3D& trans) { +IntersectionSolid::IntersectionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Transform3D& trans) { TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_transform(trans)); _assign(new TGeoCompositeShape(nam.c_str(), inter), "", INTERSECTION_TAG, true); } /// Constructor to be used when creating a new object. Position is identity. -IntersectionSolid::IntersectionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const Position& pos) { +IntersectionSolid::IntersectionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Position& pos) { TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_translation(pos)); _assign(new TGeoCompositeShape(nam.c_str(), inter), "", INTERSECTION_TAG, true); } /// Constructor to be used when creating a new object -IntersectionSolid::IntersectionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const RotationZYX& rot) { +IntersectionSolid::IntersectionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const RotationZYX& rot) { TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotationZYX(rot)); _assign(new TGeoCompositeShape(nam.c_str(), inter), "", INTERSECTION_TAG, true); } /// Constructor to be used when creating a new object -IntersectionSolid::IntersectionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const Rotation3D& rot) { +IntersectionSolid::IntersectionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Rotation3D& rot) { TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotation3D(rot)); _assign(new TGeoCompositeShape(nam.c_str(), inter), "", INTERSECTION_TAG, true); } @@ -1075,7 +1072,4 @@ INSTANTIATE(TGeoTrd2); INSTANTIATE(TGeoCtub); INSTANTIATE(TGeoScaledShape); INSTANTIATE(TGeoCompositeShape); - -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) INSTANTIATE(TGeoTessellated); -#endif diff --git a/DDCore/src/Volumes.cpp b/DDCore/src/Volumes.cpp index 1b1a88601..775545a6d 100644 --- a/DDCore/src/Volumes.cpp +++ b/DDCore/src/Volumes.cpp @@ -1157,7 +1157,7 @@ const Volume& Volume::setVisAttributes(const VisAttr& attr) const { #if ROOT_VERSION_CODE >= ROOT_VERSION(6,29,0) // Set directly transparency to the volume, NOT to the material as for ROOT < 6.29 m_element->ResetTransparency(Char_t((1.0-vis->alpha)*100)); -#elif ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0) +#else // As suggested by Valentin Volkl https://sft.its.cern.ch/jira/browse/DDFORHEP-20 // // According to https://root.cern.ch/phpBB3/viewtopic.php?t=2309#p66013 diff --git a/DDCore/src/gdml/GdmlPlugins.cpp b/DDCore/src/gdml/GdmlPlugins.cpp index 0e9130a82..d1c315711 100644 --- a/DDCore/src/gdml/GdmlPlugins.cpp +++ b/DDCore/src/gdml/GdmlPlugins.cpp @@ -33,8 +33,6 @@ using namespace std; using namespace dd4hep; -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,13,0) - /// ROOT GDML reader plugin /** * Factory: DD4hep_ROOTGDMLParse @@ -186,10 +184,8 @@ static long gdml_extract(Detector& description, int argc, char** argv) { extract.SetIgnoreDummyMaterial(true); extract.SetNamingSpeed(TGDMLWrite::kfastButUglySufix); extract.WriteGDMLfile(&description.manager(), de.placement().ptr(), uri.GetRelativePart()); -#elif ROOT_VERSION_CODE >= ROOT_VERSION(6,20,0) - extract.WriteGDMLfile(&description.manager(), de.placement().ptr(), uri.GetRelativePart()); #else - extract.WriteGDMLfile(&description.manager(), de.volume().ptr(), uri.GetRelativePart()); + extract.WriteGDMLfile(&description.manager(), de.placement().ptr(), uri.GetRelativePart()); #endif return 1; } @@ -235,14 +231,12 @@ static long gdml_extract(Detector& description, int argc, char** argv) { TGDMLWrite extract; TUri uri(output.c_str()); description.manager().SetExportPrecision(precision); -#if ROOT_VERSION_CODE > ROOT_VERSION(6,27,1) +#if ROOT_VERSION_CODE > ROOT_VERSION(6,27,1) extract.SetIgnoreDummyMaterial(true); extract.SetNamingSpeed(TGDMLWrite::kfastButUglySufix); extract.WriteGDMLfile(&description.manager(), a._node, uri.GetRelativePart()); -#elif ROOT_VERSION_CODE >= ROOT_VERSION(6,20,0) - extract.WriteGDMLfile(&description.manager(), a._node, uri.GetRelativePart()); #else - extract.WriteGDMLfile(&description.manager(), a._node->GetVolume(), uri.GetRelativePart()); + extract.WriteGDMLfile(&description.manager(), a._node, uri.GetRelativePart()); #endif return 1; } @@ -348,5 +342,3 @@ static Ref_t create_detector(Detector& description, xml_h e, Ref_t /* sens_det * // first argument is the type from the xml file DECLARE_DETELEMENT(DD4hep_GdmlDetector,create_detector) - -#endif diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp index a9bdc3c98..1eb0ca12d 100644 --- a/DDCore/src/plugins/Compact2Objects.cpp +++ b/DDCore/src/plugins/Compact2Objects.cpp @@ -41,12 +41,8 @@ // Root/TGeo include files #include #include -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,12,0) #include -#endif -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) #include -#endif #include // C/C++ include files @@ -93,11 +89,9 @@ namespace dd4hep { template <> void Converter::operator()(xml_h element) const; template <> void Converter::operator()(xml_h element) const; template <> void Converter::operator()(xml_h element) const; -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) template <> void Converter::operator()(xml_h element) const; template <> void Converter::operator()(xml_h element) const; template <> void Converter::operator()(xml_h element) const; -#endif template <> void Converter::operator()(xml_h element) const; template <> void Converter::operator()(xml_h element) const; template <> void Converter::operator()(xml_h element) const; @@ -516,10 +510,8 @@ template <> void Converter::operator()(xml_h e) const { matname, dens_val, temp_val/dd4hep::kelvin, pressure_val/dd4hep::pascal/100.0); mix->SetRadLen(0e0); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,12,0) mix->ComputeDerivedQuantities(); -#endif -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) + /// /// In case there were material properties specified: convert them here for(xml_coll_t properties(x_mat, _U(constant)); properties; ++properties) { xml_elt_t p = properties; @@ -576,7 +568,6 @@ template <> void Converter::operator()(xml_h e) const { throw_print("Compact2Objects[ERROR]: Converting material:" + mname + " Property missing: " + ref); } } -#endif } TGeoMedium* medium = mgr.GetMedium(matname); if (0 == medium) { @@ -740,7 +731,6 @@ template <> void Converter::operator()(xml_h e) const { } } -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /** Convert compact optical surface objects (defines) * * @@ -840,7 +830,6 @@ template <> void Converter::operator()(xml_h element) const { surf->GetName(), pname.c_str(), ptyp.c_str()); } } -#endif } /** Convert compact constant property (Material properties stored in TGeoManager) @@ -1449,9 +1438,7 @@ template <> void Converter::operator()(xml_h element) const { throw runtime_error("Failed to execute subdetector creation plugin. " + dbg.missingFactory(type)); } description.addDetector(det); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) description.surfaceManager().registerSurfaces(det); -#endif return; } catch (const exception& e) { @@ -1734,13 +1721,12 @@ template <> void Converter::operator()(xml_h element) const { (Converter
(description))(xml_h(compact.child(_U(info)))); xml_coll_t(compact, _U(properties)).for_each(_U(attributes), Converter(description)); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /// These two must be parsed early, because they are needed by the detector constructors xml_coll_t(compact, _U(properties)).for_each(_U(constant), Converter(description)); xml_coll_t(compact, _U(properties)).for_each(_U(matrix), Converter(description)); xml_coll_t(compact, _U(properties)).for_each(_U(plugin), Converter (description)); xml_coll_t(compact, _U(surfaces)).for_each(_U(opticalsurface), Converter(description)); -#endif + xml_coll_t(compact, _U(materials)).for_each(_U(element), Converter(description)); xml_coll_t(compact, _U(materials)).for_each(_U(material), Converter(description)); xml_coll_t(compact, _U(materials)).for_each(_U(plugin), Converter (description)); diff --git a/DDCore/src/plugins/ShapePlugins.cpp b/DDCore/src/plugins/ShapePlugins.cpp index 5487c170f..e2448f589 100644 --- a/DDCore/src/plugins/ShapePlugins.cpp +++ b/DDCore/src/plugins/ShapePlugins.cpp @@ -25,7 +25,6 @@ #include #include -using namespace std; using namespace dd4hep; using namespace dd4hep::detail; @@ -47,7 +46,7 @@ static Handle create_Scaled(Detector&, xml_h e) { xml_dim_t scale(e); Solid shape(xml_comp_t(scale.child(_U(shape))).createShape()); Solid solid = Scale(shape.ptr(), scale.x(1.0), scale.y(1.0), scale.z(1.0)); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Scale__shape_constructor,create_Scaled) @@ -67,7 +66,7 @@ DECLARE_XML_SHAPE(Scale__shape_constructor,create_Scaled) static Handle create_Assembly(Detector&, xml_h e) { xml_dim_t dim(e); Solid solid = Handle(new TGeoShapeAssembly()); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Assembly__shape_constructor,create_Assembly) @@ -87,7 +86,7 @@ DECLARE_XML_SHAPE(Assembly__shape_constructor,create_Assembly) static Handle create_Box(Detector&, xml_h e) { xml_dim_t dim(e); Solid solid = Box(dim.dx(),dim.dy(),dim.dz()); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Box__shape_constructor,create_Box) @@ -113,7 +112,7 @@ static Handle create_HalfSpace(Detector&, xml_h e) { double p[3] = { point.x(), point.y(), point.z()}; double n[3] = { normal.x(), normal.y(), normal.z()}; Solid solid = HalfSpace(p, n); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(HalfSpace__shape_constructor,create_HalfSpace) @@ -134,7 +133,7 @@ static Handle create_Cone(Detector&, xml_h element) { xml_dim_t e(element); double rmi1 = e.rmin1(0.0), rma1 = e.rmax1(); Solid solid = Cone(e.z(0.0), rmi1, rma1, e.rmin2(rmi1), e.rmax2(rma1)); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Cone__shape_constructor,create_Cone) @@ -159,7 +158,7 @@ DECLARE_XML_SHAPE(Cone__shape_constructor,create_Cone) static Handle create_Polycone(Detector&, xml_h element) { xml_dim_t e(element); int num = 0; - vector rmin,rmax,z; + std::vector rmin,rmax,z; double start = e.startphi(0e0), deltaphi = e.deltaphi(2*M_PI); for(xml_coll_t c(e,_U(zplane)); c; ++c, ++num) { xml_comp_t plane(c); @@ -168,10 +167,10 @@ static Handle create_Polycone(Detector&, xml_h element) { z.emplace_back(plane.z()); } if ( num < 2 ) { - throw runtime_error("PolyCone Shape> Not enough Z planes. minimum is 2!"); + throw std::runtime_error("PolyCone Shape> Not enough Z planes. minimum is 2!"); } Solid solid = Polycone(start,deltaphi,rmin,rmax,z); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Polycone__shape_constructor,create_Polycone) @@ -215,7 +214,7 @@ static Handle create_ConeSegment(Detector&, xml_h element) { /// New naming: angles from [startphi,startphi+deltaphi] solid = ConeSegment(e.dz(),e.rmin1(0.0),e.rmax1(),e.rmin2(0.0),e.rmax2(),start_phi,start_phi+delta_phi); } - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(ConeSegment__shape_constructor,create_ConeSegment) @@ -256,7 +255,7 @@ static Handle create_Tube(Detector&, xml_h element) { double phi2 = phi1 + e.deltaphi(2*M_PI); solid = Tube(e.rmin(0.0),e.rmax(),e.dz(0.0),phi1,phi2); } - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Tube__shape_constructor,create_Tube) @@ -284,7 +283,7 @@ static Handle create_TwistedTube(Detector&, xml_h element) { } solid = TwistedTube(e.twist(0.0), e.rmin(0.0),e.rmax(),zneg, zpos, nseg, e.deltaphi(2*M_PI)); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(TwistedTube__shape_constructor,create_TwistedTube) @@ -306,7 +305,7 @@ static Handle create_CutTube(Detector&, xml_h element) { e.attr(_U(tx)), e.attr(_U(ty)), e.attr(_U(tz))); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(CutTube__shape_constructor,create_CutTube) @@ -320,7 +319,7 @@ DECLARE_XML_SHAPE(CutTube__shape_constructor,create_CutTube) static Handle create_EllipticalTube(Detector&, xml_h element) { xml_dim_t e(element); Solid solid = EllipticalTube(e.a(),e.b(),e.dz()); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(EllipticalTube__shape_constructor,create_EllipticalTube) @@ -338,7 +337,7 @@ static Handle create_TruncatedTube(Detector&, xml_h element) { e.attr(xml_tag_t("cutAtStart")), e.attr(xml_tag_t("cutAtDelta")), e.attr(xml_tag_t("cutInside"))); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(TruncatedTube__shape_constructor,create_TruncatedTube) @@ -379,7 +378,7 @@ static Handle create_Trap(Detector&, xml_h element) { double y2 = (attr=element.attr_nothrow(_U(y2))) ? element.attr(attr) : y1; solid = Trap(e.z(0.0),e.theta(0),e.phi(0),y1,x1,x2,e.alpha1(0),y2,x3,x4,e.alpha2(0)); } - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Trap__shape_constructor,create_Trap) @@ -393,7 +392,7 @@ DECLARE_XML_SHAPE(Trap__shape_constructor,create_Trap) static Handle create_PseudoTrap(Detector&, xml_h element) { xml_dim_t e(element); Solid solid = PseudoTrap(e.x1(),e.x2(),e.y1(),e.y2(),e.z(),e.radius(),e.attr(xml_tag_t("minusZ"))); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(PseudoTrap__shape_constructor,create_PseudoTrap) @@ -412,7 +411,7 @@ DECLARE_XML_SHAPE(PseudoTrap__shape_constructor,create_PseudoTrap) static Handle create_Trd1(Detector&, xml_h element) { xml_dim_t e(element); Solid solid = Trd1(e.x1(),e.x2(),e.y(),e.z(0.0)); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Trd1__shape_constructor,create_Trd1) @@ -431,7 +430,7 @@ DECLARE_XML_SHAPE(Trd1__shape_constructor,create_Trd1) static Handle create_Trd2(Detector&, xml_h element) { xml_dim_t e(element); Solid solid = Trd2(e.x1(),e.x2(),e.y1(),e.y2(),e.z(0.0)); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Trapezoid__shape_constructor,create_Trd2) @@ -473,7 +472,7 @@ static Handle create_Torus(Detector&, xml_h element) { /// TGeo naming: angles from [startphi,startphi+deltaphi] solid = Torus(e.r(), e.rmin(0.0), e.rmax(), start_phi, delta_phi); } - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Torus__shape_constructor,create_Torus) @@ -519,7 +518,7 @@ static Handle create_Sphere(Detector&, xml_h element) { endtheta = starttheta + e.deltatheta(); Solid solid = Sphere(e.rmin(0e0), e.rmax(), starttheta, endtheta, startphi, endphi); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Sphere__shape_constructor,create_Sphere) @@ -538,7 +537,7 @@ DECLARE_XML_SHAPE(Sphere__shape_constructor,create_Sphere) static Handle create_Paraboloid(Detector&, xml_h element) { xml_dim_t e(element); Solid solid = Paraboloid(e.rmin(0.0),e.rmax(),e.dz()); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Paraboloid__shape_constructor,create_Paraboloid) @@ -559,7 +558,7 @@ DECLARE_XML_SHAPE(Paraboloid__shape_constructor,create_Paraboloid) static Handle create_Hyperboloid(Detector&, xml_h element) { xml_dim_t e(element); Solid solid = Hyperboloid(e.rmin(), e.inner_stereo(), e.rmax(), e.outer_stereo(), e.dz()); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Hyperboloid__shape_constructor,create_Hyperboloid) @@ -579,7 +578,7 @@ DECLARE_XML_SHAPE(Hyperboloid__shape_constructor,create_Hyperboloid) static Handle create_PolyhedraRegular(Detector&, xml_h element) { xml_dim_t e(element); Solid solid = PolyhedraRegular(e.numsides(),e.rmin(),e.rmax(),e.dz()); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(PolyhedraRegular__shape_constructor,create_PolyhedraRegular) @@ -608,7 +607,7 @@ static Handle create_Polyhedra(Detector&, xml_h element) { z.emplace_back(plane.z()); } Solid solid = Polyhedra(e.numsides(),e.startphi(),e.deltaphi(),z,rmin,rmax); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Polyhedra__shape_constructor,create_Polyhedra) @@ -635,7 +634,7 @@ static Handle create_ExtrudedPolygon(Detector&, xml_h element) { pt_y.emplace_back(point.attr(_U(y))); } Solid solid = ExtrudedPolygon(pt_x, pt_y, sec_z, sec_x, sec_y, sec_scale); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(ExtrudedPolygon__shape_constructor,create_ExtrudedPolygon) @@ -657,12 +656,11 @@ static Handle create_EightPointSolid(Detector&, xml_h element) { v[num][1] = vtx.y(); } Solid solid = EightPointSolid(e.dz(),&v[0][0]); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(EightPointSolid__shape_constructor,create_EightPointSolid) -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) /// Plugin factory to create tessellated shapes /** * @@ -679,7 +677,7 @@ static Handle create_TessellatedSolid(Detector&, xml_h element) { int num_facets = 0; for ( xml_coll_t facet(element, _U(facet)); facet; ++facet ) ++num_facets; TessellatedSolid solid = TessellatedSolid(num_facets); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); for ( xml_coll_t facet(element, _U(facet)); facet; ++facet ) { xml_dim_t f(facet); size_t i0 = f.attr(_U(v0)); @@ -696,10 +694,9 @@ static Handle create_TessellatedSolid(Detector&, xml_h element) { return solid; } DECLARE_XML_SHAPE(TessellatedSolid__shape_constructor,create_TessellatedSolid) -#endif /** Plugin function for creating a boolean solid from an xml element . - * Expects exactly two child elements and a string attribute 'operation', which is one of + * Expects exactly two child elements and a std::string attribute 'operation', which is one of * 'subtraction', 'union' or 'intersection'. Optionally and/or can be specified. * More complex boolean solids can be created by nesting the xml elements accordingly. * @@ -793,7 +790,7 @@ static Handle create_BooleanShape(Detector&, xml_h element) { std::string(" - needs to be one of 'subtraction','union' or 'intersection' ") ) ; } Solid solid = resultSolid ; - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(BooleanShapeOld__shape_constructor,create_BooleanShape) @@ -812,15 +809,15 @@ static Handle create_BooleanMulti(Detector& description, xml_h element) //printout(ALWAYS,"","Boolean shape ---> %s",op.c_str()); for (xml_coll_t i(e ,_U(star)); i; ++i ) { xml_comp_t x_elt = i; - string tag = x_elt.tag(); + std::string tag = x_elt.tag(); if ( tag == "shape" && !result.isValid() ) { result = xml::createShape(description, x_elt.typeStr(), x_elt); - if ( (attr=i.attr_nothrow(_U(name))) ) result->SetName(i.attr(attr).c_str()); + if ( (attr=i.attr_nothrow(_U(name))) ) result->SetName(i.attr(attr).c_str()); flag = 1; } else if ( tag == "shape" && !solid.isValid() ) { solid = xml::createShape(description, x_elt.typeStr(), x_elt); - if ( (attr=i.attr_nothrow(_U(name))) ) result->SetName(i.attr(attr).c_str()); + if ( (attr=i.attr_nothrow(_U(name))) ) result->SetName(i.attr(attr).c_str()); flag = 3; } else if ( result.isValid() && solid.isValid() ) { @@ -870,7 +867,7 @@ static Handle create_BooleanMulti(Detector& description, xml_h element) result = tmp; trafo = position = rotation = Transform3D(); solid = xml::createShape(description, x_elt.typeStr(), x_elt); - if ( (attr=i.attr_nothrow(_U(name))) ) result->SetName(i.attr(attr).c_str()); + if ( (attr=i.attr_nothrow(_U(name))) ) result->SetName(i.attr(attr).c_str()); flag = 3; } } @@ -893,7 +890,7 @@ static Handle create_BooleanMulti(Detector& description, xml_h element) } attr = element.attr_nothrow(_U(name)); if ( attr ) { - string nam = element.attr(attr); + std::string nam = element.attr(attr); result->SetName(nam.c_str()); } return result; @@ -920,8 +917,8 @@ DECLARE_XML_VOLUME(DD4hep_StdVolume,create_std_volume) * \version 1.0 */ static Handle create_gen_volume(Detector& description, xml_h element) { - xml_dim_t elt = element; - string typ = elt.attr(_U(type)); + xml_dim_t elt = element; + std::string typ = elt.attr(_U(type)); return xml::createVolume(description, typ, element); } DECLARE_XML_VOLUME(DD4hep_GenericVolume,create_gen_volume) @@ -943,7 +940,7 @@ TGeoCombiTrans* createPlacement(const Rotation3D& iRot, const Position& iTrans) */ static Ref_t create_shape(Detector& description, xml_h e, SensitiveDetector sens) { xml_det_t x_det = e; - string name = x_det.nameStr(); + std::string name = x_det.nameStr(); xml_dim_t x_reflect = x_det.child(_U(reflect), false); DetElement det (name,x_det.id()); Material mat = description.air(); @@ -952,21 +949,21 @@ static Ref_t create_shape(Detector& description, xml_h e, SensitiveDetector sens int count = 0; if ( x_det.hasChild(_U(material)) ) { - mat = description.material(x_det.child(_U(material)).attr(_U(name))); + mat = description.material(x_det.child(_U(material)).attr(_U(name))); printout(INFO,"TestShape","+++ Volume material is %s", mat.name()); } for ( xml_coll_t itm(e, _U(check)); itm; ++itm, ++count ) { - xml_dim_t x_check = itm; - xml_comp_t shape (x_check.child(_U(shape))); - xml_dim_t pos (x_check.child(_U(position), false)); - xml_dim_t rot (x_check.child(_U(rotation), false)); - bool reflect = x_check.hasChild(_U(reflect)); - bool reflectZ = x_check.hasChild(_U(reflect_z)); - bool reflectY = x_check.hasChild(_U(reflect_y)); - bool reflectX = x_check.hasChild(_U(reflect_x)); - string shape_type = shape.typeStr(); - Solid solid; - Volume volume; + xml_dim_t x_check = itm; + xml_comp_t shape (x_check.child(_U(shape))); + xml_dim_t pos (x_check.child(_U(position), false)); + xml_dim_t rot (x_check.child(_U(rotation), false)); + bool reflect = x_check.hasChild(_U(reflect)); + bool reflectZ = x_check.hasChild(_U(reflect_z)); + bool reflectY = x_check.hasChild(_U(reflect_y)); + bool reflectX = x_check.hasChild(_U(reflect_x)); + std::string shape_type = shape.typeStr(); + Solid solid; + Volume volume; if ( shape_type == "CAD_Assembly" || shape_type == "CAD_MultiVolume" ) { volume = xml::createVolume(description, shape_type, shape); @@ -977,7 +974,7 @@ static Ref_t create_shape(Detector& description, xml_h e, SensitiveDetector sens volume = Volume(name+_toString(count,"_vol_%d"),solid, mat); } if ( x_det.hasChild(_U(sensitive)) ) { - string sens_type = x_det.child(_U(sensitive)).attr(_U(type)); + std::string sens_type = x_det.child(_U(sensitive)).attr(_U(type)); volume.setSensitiveDetector(sens); sens.setType(sens_type); printout(INFO,"TestShape","+++ Sensitive type is %s", sens_type.c_str()); @@ -1060,12 +1057,10 @@ static Ref_t create_shape(Detector& description, xml_h e, SensitiveDetector sens instance_test = isInstance(solid); else if ( 0 == strcasecmp(solid->GetTitle(),SCALE_TAG) ) instance_test = isInstance(solid); -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) else if ( 0 == strcasecmp(solid->GetTitle(),TESSELLATEDSOLID_TAG) ) { instance_test = isInstance(solid); shape_type = TESSELLATEDSOLID_TAG; } -#endif else if ( 0 == strcasecmp(solid->GetTitle(),POLYCONE_TAG) ) instance_test = isInstance(solid); else if ( 0 == strcasecmp(solid->GetTitle(),TWISTEDTUBE_TAG) ) { @@ -1176,7 +1171,7 @@ static Ref_t create_shape(Detector& description, xml_h e, SensitiveDetector sens /// Execute test plugin(s) on the placed volume if desired for ( xml_coll_t itm(e, xml_tag_t("test")); itm; ++itm, ++count ) { xml_comp_t x_test = itm; - string typ = x_test.typeStr(); + std::string typ = x_test.typeStr(); const void* argv[] = { &e, &pv, 0}; Ref_t result = (NamedObject*)PluginService::Create(typ, &description, 2, (char**)argv); if ( !result.isValid() ) { @@ -1214,8 +1209,8 @@ void* shape_mesh_verifier(Detector& description, int argc, char** argv) { int ref_cr = x_test.hasAttr(_U(create)) ? x_test.attr(_U(create)) : 0; int nseg = x_test.hasAttr(_U(segmentation)) ? x_test.attr(_U(segmentation)) : -1; TString ref = x_test.refStr().c_str(); - string ref_str; - stringstream os; + std::string ref_str; + std::stringstream os; if ( nseg > 0 ) { description.manager().SetNsegments(nseg); @@ -1234,7 +1229,7 @@ void* shape_mesh_verifier(Detector& description, int argc, char** argv) { } gSystem->ExpandPathName(ref); if ( ref_cr ) { - ofstream out(ref, ofstream::out); + std::ofstream out(ref, std::fstream::out); if ( !out.is_open() ) { except("Mesh_Verifier","+++ FAILED to open(WRITE) reference file: "+x_test.refStr()); } @@ -1244,7 +1239,7 @@ void* shape_mesh_verifier(Detector& description, int argc, char** argv) { } else if ( ref.Length() > 0 ) { char c; - ifstream in(ref.Data(), ofstream::in); + std::ifstream in(ref.Data(), std::fstream::in); if ( !in.is_open() ) { except("Mesh_Verifier","+++ FAILED to access reference file: "+x_test.refStr()); } diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp index ac92a0d9c..bdd409aa3 100644 --- a/DDCore/src/plugins/StandardPlugins.cpp +++ b/DDCore/src/plugins/StandardPlugins.cpp @@ -37,10 +37,7 @@ #include #include #include -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) #include -#endif - // C/C++ include files #include @@ -279,7 +276,6 @@ DECLARE_APPLY(DD4hep_InteractiveUI,root_ui) static long root_dump_gdml_tables(Detector& description, int /* argc */, char** /* argv */) { size_t num_tables = 0; size_t num_elements = 0; -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) const TObjArray* c = description.manager().GetListOfGDMLMatrices(); TObjArrayIter arr(c); printout(INFO,"Dump_GDMLTables","+++ Dumping known GDML tables from TGeoManager."); @@ -289,7 +285,6 @@ static long root_dump_gdml_tables(Detector& description, int /* argc */, char** ++num_tables; gdmlMat->Print(); } -#endif printout(INFO,"Dump_GDMLTables", "+++ Successfully dumped %ld GDML tables with %ld elements.", num_tables, num_elements); @@ -309,7 +304,6 @@ DECLARE_APPLY(DD4hep_Dump_GDMLTables,root_dump_gdml_tables) static long root_dump_optical_surfaces(Detector& description, int /* argc */, char** /* argv */) { size_t num_surfaces = 0; printout(ALWAYS,"",""); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) const TObjArray* c = description.manager().GetListOfOpticalSurfaces(); TObjArrayIter arr(c); printout(ALWAYS,"Dump_OpticalSurfaces","+++ Dumping known Optical Surfaces from TGeoManager."); @@ -318,7 +312,6 @@ static long root_dump_optical_surfaces(Detector& description, int /* argc */, ch ++num_surfaces; optSurt->Print(); } -#endif printout(ALWAYS,"Dump_OpticalSurfaces", "+++ Successfully dumped %ld Optical surfaces.",num_surfaces); return 1; @@ -337,7 +330,6 @@ DECLARE_APPLY(DD4hep_Dump_OpticalSurfaces,root_dump_optical_surfaces) static long root_dump_skin_surfaces(Detector& description, int /* argc */, char** /* argv */) { size_t num_surfaces = 0; printout(ALWAYS,"",""); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) const TObjArray* c = description.manager().GetListOfSkinSurfaces(); TObjArrayIter arr(c); printout(ALWAYS,"Dump_SkinSurfaces","+++ Dumping known Skin Surfaces from TGeoManager."); @@ -346,7 +338,6 @@ static long root_dump_skin_surfaces(Detector& description, int /* argc */, char* ++num_surfaces; skinSurf->Print(); } -#endif printout(ALWAYS,"Dump_SkinSurfaces", "+++ Successfully dumped %ld Skin surfaces.",num_surfaces); return 1; @@ -365,7 +356,6 @@ DECLARE_APPLY(DD4hep_Dump_SkinSurfaces,root_dump_skin_surfaces) static long root_dump_border_surfaces(Detector& description, int /* argc */, char** /* argv */) { size_t num_surfaces = 0; printout(ALWAYS,"",""); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) const TObjArray* c = description.manager().GetListOfBorderSurfaces(); TObjArrayIter arr(c); printout(ALWAYS,"Dump_BorderSurfaces","+++ Dumping known Border Surfaces from TGeoManager."); @@ -374,7 +364,6 @@ static long root_dump_border_surfaces(Detector& description, int /* argc */, cha ++num_surfaces; bordSurt->Print(); } -#endif printout(ALWAYS,"Dump_BorderSurfaces", "+++ Successfully dumped %ld Border surfaces.",num_surfaces); return 1; @@ -562,7 +551,6 @@ static long root_materials(Detector& description, int argc, char** argv) { ::printf(" %-6s Fraction: %7.3f Z=%3d A=%6.2f N=%3d Neff=%6.2f\n", elt->GetName(), frac, elt->Z(), elt->A(), elt->N(), elt->Neff()); } -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /// Print material property virtual void printProperty(elt_h, TNamed* prop, TGDMLMatrix* matrix) { if ( matrix ) @@ -572,7 +560,6 @@ static long root_materials(Detector& description, int argc, char** argv) { ::printf(" Property: %-20s [ERROR: NO TABLE!] --> %s\n", prop->GetName(), prop->GetTitle()); } -#endif virtual void operator()(TGeoMaterial* mat) { Double_t* mix = mat->IsMixture() ? ((TGeoMixture*)mat)->GetWmixt() : 0; elt_h mh = print(mat); @@ -580,12 +567,10 @@ static long root_materials(Detector& description, int argc, char** argv) { TGeoElement* elt = mat->GetElement(i); print(mh, elt, mix ? mix[i] : 1); } -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) TListIter mat_iter(&mat->GetProperties()); for( TObject* i = mat_iter.Next(); i; i=mat_iter.Next() ) { printProperty(mh, (TNamed*)i, description.manager().GetGDMLMatrix(i->GetTitle())); } -#endif } }; /// XML printer to produce XML output @@ -641,13 +626,11 @@ static long root_materials(Detector& description, int argc, char** argv) { elt.setAttr(_U(n),frac); elt.setAttr(_U(ref),element->GetName()); } -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) virtual void printProperty(elt_h mat, TNamed* prop, TGDMLMatrix* /* matrix */) { elt_h elt = mat.addChild(_U(property)); elt.setAttr(_U(name),prop->GetName()); elt.setAttr(_U(ref), prop->GetTitle()); } -#endif }; std::string type = "text", output = "", name = ""; diff --git a/DDCore/src/plugins/TGeoCodeGenerator.cpp b/DDCore/src/plugins/TGeoCodeGenerator.cpp index da87aa452..ea560ea12 100644 --- a/DDCore/src/plugins/TGeoCodeGenerator.cpp +++ b/DDCore/src/plugins/TGeoCodeGenerator.cpp @@ -10,14 +10,14 @@ // Author : M.Frank // //========================================================================== -#include "DD4hep/Factories.h" -#include "DD4hep/Shapes.h" -#include "DD4hep/Volumes.h" -#include "DD4hep/Detector.h" -#include "DD4hep/MatrixHelpers.h" -#include "DD4hep/DD4hepUnits.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Path.h" +#include +#include +#include +#include +#include +#include +#include +#include // C/C++ include files #include @@ -26,12 +26,11 @@ #include // ROOT includes -#include "TClass.h" -#include "TGeoMatrix.h" -#include "TGeoBoolNode.h" -#include "TGeoCompositeShape.h" +#include +#include +#include +#include -using namespace std; using namespace dd4hep; namespace { @@ -57,68 +56,68 @@ namespace { Actor() = default; ~Actor() = default; - ostream& handleHeader (ostream& log); - ostream& handleTrailer (ostream& log); - ostream& handleSolid (ostream& log, const TGeoShape* sh); - ostream& handleMatrix (ostream& log, TGeoMatrix* mat); - ostream& handleElement (ostream& log, TGeoElement* elt); - ostream& handleMaterial (ostream& log, TGeoMedium* mat); - ostream& handlePlacement(ostream& log, TGeoNode* parent, TGeoNode* node); + std::ostream& handleHeader (std::ostream& log); + std::ostream& handleTrailer (std::ostream& log); + std::ostream& handleSolid (std::ostream& log, const TGeoShape* sh); + std::ostream& handleMatrix (std::ostream& log, TGeoMatrix* mat); + std::ostream& handleElement (std::ostream& log, TGeoElement* elt); + std::ostream& handleMaterial (std::ostream& log, TGeoMedium* mat); + std::ostream& handlePlacement(std::ostream& log, TGeoNode* parent, TGeoNode* node); }; typedef void* pvoid_t; - ostream& newline(ostream& log) { - return log << endl << prefix; + std::ostream& newline(std::ostream& log) { + return log << std::endl << prefix; } - ostream& Actor::handleHeader (ostream& log) { - log << "#include \"TClass.h\"" << endl - << "#include \"TGeoNode.h\"" << endl - << "#include \"TGeoExtension.h\"" << endl - << "#include \"TGeoShapeAssembly.h\"" << endl - << "#include \"TGeoMedium.h\"" << endl - << "#include \"TGeoVolume.h\"" << endl - << "#include \"TGeoShape.h\"" << endl - << "#include \"TGeoPhysicalNode.h\"" << endl - << "#include \"TGeoCone.h\"" << endl - << "#include \"TGeoParaboloid.h\"" << endl - << "#include \"TGeoPgon.h\"" << endl - << "#include \"TGeoPcon.h\"" << endl - << "#include \"TGeoSphere.h\"" << endl - << "#include \"TGeoArb8.h\"" << endl - << "#include \"TGeoTrd1.h\"" << endl - << "#include \"TGeoTrd2.h\"" << endl - << "#include \"TGeoTube.h\"" << endl - << "#include \"TGeoEltu.h\"" << endl - << "#include \"TGeoXtru.h\"" << endl - << "#include \"TGeoHype.h\"" << endl - << "#include \"TGeoTorus.h\"" << endl - << "#include \"TGeoHalfSpace.h\"" << endl - << "#include \"TGeoCompositeShape.h\"" << endl - << "#include \"TGeoShapeAssembly.h\"" << endl - << "#include \"TGeoMatrix.h\"" << endl - << "#include \"TGeoBoolNode.h\"" << endl - << "#include \"TGeoCompositeShape.h\"" << endl - << "#include \"TGeoManager.h\"" << endl - << "#include " << endl - << "#include " << endl - << "#include " << endl << endl << endl; + std::ostream& Actor::handleHeader (std::ostream& log) { + log << "#include \"TClass.h\"" << std::endl + << "#include \"TGeoNode.h\"" << std::endl + << "#include \"TGeoExtension.h\"" << std::endl + << "#include \"TGeoShapeAssembly.h\"" << std::endl + << "#include \"TGeoMedium.h\"" << std::endl + << "#include \"TGeoVolume.h\"" << std::endl + << "#include \"TGeoShape.h\"" << std::endl + << "#include \"TGeoPhysicalNode.h\"" << std::endl + << "#include \"TGeoCone.h\"" << std::endl + << "#include \"TGeoParaboloid.h\"" << std::endl + << "#include \"TGeoPgon.h\"" << std::endl + << "#include \"TGeoPcon.h\"" << std::endl + << "#include \"TGeoSphere.h\"" << std::endl + << "#include \"TGeoArb8.h\"" << std::endl + << "#include \"TGeoTrd1.h\"" << std::endl + << "#include \"TGeoTrd2.h\"" << std::endl + << "#include \"TGeoTube.h\"" << std::endl + << "#include \"TGeoEltu.h\"" << std::endl + << "#include \"TGeoXtru.h\"" << std::endl + << "#include \"TGeoHype.h\"" << std::endl + << "#include \"TGeoTorus.h\"" << std::endl + << "#include \"TGeoHalfSpace.h\"" << std::endl + << "#include \"TGeoCompositeShape.h\"" << std::endl + << "#include \"TGeoShapeAssembly.h\"" << std::endl + << "#include \"TGeoMatrix.h\"" << std::endl + << "#include \"TGeoBoolNode.h\"" << std::endl + << "#include \"TGeoCompositeShape.h\"" << std::endl + << "#include \"TGeoManager.h\"" << std::endl + << "#include " << std::endl + << "#include " << std::endl + << "#include " << std::endl << std::endl << std::endl; log << "TGeoVolume* generate_geometry() {" << newline; return log; } - ostream& Actor::handleTrailer (ostream& log) { - log << endl << "}" << endl << endl; + std::ostream& Actor::handleTrailer (std::ostream& log) { + log << std::endl << "}" << std::endl << std::endl; log << "void " << function << "() {" << newline << "if ( !gGeoManager ) gGeoManager = new TGeoManager();" << newline << "TGeoVolume* vol_top = generate_geometry();" << newline << "gGeoManager->SetTopVolume(vol_top);" << newline << "vol_top->Draw(\"ogl\");" << newline - << endl << "}" << endl; + << std::endl << "}" << std::endl; return log; } - ostream& Actor::handlePlacement(ostream& log, TGeoNode* parent, TGeoNode* node) { + std::ostream& Actor::handlePlacement(std::ostream& log, TGeoNode* parent, TGeoNode* node) { if ( node && nodes.find(node) == nodes.end() ) { TGeoVolume* vol = node->GetVolume(); TGeoMatrix* mat = node->GetMatrix(); @@ -163,13 +162,13 @@ namespace { << "->GetNode(" << ndau << ");" << newline; } else { - log << "return vol_" << pvoid_t(vol) << ";" << endl; + log << "return vol_" << pvoid_t(vol) << ";" << std::endl; } } return log; } - ostream& Actor::handleElement (ostream& log, TGeoElement* elt) { + std::ostream& Actor::handleElement (std::ostream& log, TGeoElement* elt) { if ( elt && elements.find(elt) == elements.end() ) { elements.insert(elt); log << "TGeoElement* elt_" << pvoid_t(elt) << " = new TGeoElement(\"" @@ -191,7 +190,7 @@ namespace { return log; } - ostream& Actor::handleMaterial(ostream& log, TGeoMedium* medium) { + std::ostream& Actor::handleMaterial(std::ostream& log, TGeoMedium* medium) { if ( medium && materials.find(medium) == materials.end() ) { materials.insert(medium); if ( !dump_mat ) { @@ -218,9 +217,7 @@ namespace { << newline; } mix->SetRadLen(0e0); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,12,0) mix->ComputeDerivedQuantities(); -#endif } else { double z = mat->GetZ(), a = mat->GetA(); @@ -245,7 +242,7 @@ namespace { return log; } - ostream& Actor::handleMatrix(ostream& log, TGeoMatrix* mat) { + std::ostream& Actor::handleMatrix(std::ostream& log, TGeoMatrix* mat) { if ( mat && matrices.find(mat) == matrices.end() ) { const Double_t* rot = mat->GetRotationMatrix(); const Double_t* tra = mat->GetTranslation(); @@ -282,7 +279,7 @@ namespace { } /// Pretty print of solid attributes - ostream& Actor::handleSolid(ostream& log, const TGeoShape* shape) { + std::ostream& Actor::handleSolid(std::ostream& log, const TGeoShape* shape) { if ( !shape || solids.find(shape) != solids.end() ) { return log; } @@ -399,7 +396,7 @@ namespace { } else if (cl == TGeoPgon::Class()) { const TGeoPgon* sh = (const TGeoPgon*) shape; - vector params; + std::vector params; params.emplace_back(sh->GetPhi1()); params.emplace_back(sh->GetDphi()); params.emplace_back(double(sh->GetNedges())); @@ -415,7 +412,7 @@ namespace { } else if (cl == TGeoPcon::Class()) { const TGeoPcon* sh = (const TGeoPcon*) shape; - vector params; + std::vector params; params.emplace_back(sh->GetPhi1()); params.emplace_back(sh->GetDphi()); params.emplace_back(double(sh->GetNz())); @@ -534,7 +531,7 @@ namespace { } static long generate_cxx(Detector& description, int argc, char** argv) { - string output; + std::string output; Actor actor; for(int i=0; i Set output file for generated code. Default: stdout \n" " -visualization Also dump visualization attributes of volumes \n" " -materials Also dump proper materials. Default to IRON \n" " -help Show thi help message \n" - "\tArguments given: " << arguments(argc,argv) << endl << flush; + "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush; ::exit(EINVAL); } } - unique_ptr out; - ostream* os = &cout; + std::unique_ptr out; + std::ostream* os = &std::cout; if ( !output.empty() ) { Path path(output); - out.reset(new ofstream(path.c_str())); + out.reset(new std::ofstream(path.c_str())); if ( !out->good() ) { out.reset(); except("CxxRootGenerator", @@ -574,7 +571,7 @@ static long generate_cxx(Detector& description, int argc, char** argv) { } os = out.get(); actor.function = path.filename(); - if ( actor.function.rfind('.') != string::npos ) + if ( actor.function.rfind('.') != std::string::npos ) actor.function = actor.function.substr(0, actor.function.rfind('.')); printout(INFO, "CxxRootGenerator", "++ Dump generated code to output files: %s [function: %s()]", diff --git a/DDG4/examples/initAClick.C b/DDG4/examples/initAClick.C index 3051214d8..38179469f 100644 --- a/DDG4/examples/initAClick.C +++ b/DDG4/examples/initAClick.C @@ -32,13 +32,9 @@ std::string make_str(const char* data) { int processCommand(const char* command, bool end_process) { int status; // Disabling auto-parse is a hack required by a bug in ROOT -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0) gInterpreter->SetClassAutoparsing(false); status = gInterpreter->ProcessLine(command); gInterpreter->SetClassAutoparsing(true); -#else - status = gInterpreter->ProcessLine(command); -#endif ::printf("+++ Status(%s) = %d\n",command,status); if ( end_process ) { gInterpreter->ProcessLine("gSystem->Exit(0)"); diff --git a/DDG4/include/DDG4/Geant4Converter.h b/DDG4/include/DDG4/Geant4Converter.h index acdf9ea16..2abf2721a 100644 --- a/DDG4/include/DDG4/Geant4Converter.h +++ b/DDG4/include/DDG4/Geant4Converter.h @@ -14,8 +14,8 @@ #define DDG4_GEANT4CONVERTER_H // Framework include files -#include "DD4hep/Printout.h" -#include "DDG4/Geant4Mapping.h" +#include +#include /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -72,7 +72,6 @@ namespace dd4hep { /// Create geometry conversion Geant4Converter& create(DetElement top); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /// Convert the geometry type material into the corresponding Geant4 object(s). virtual void* handleMaterialProperties(TObject* matrix) const; @@ -84,7 +83,7 @@ namespace dd4hep { /// Convert the border surface to Geant4 void* handleBorderSurface(TObject* surface) const; -#endif + /// Convert the geometry type material into the corresponding Geant4 object(s). virtual void* handleMaterial(const std::string& name, Material medium) const; @@ -128,5 +127,4 @@ namespace dd4hep { }; } // End namespace sim } // End namespace dd4hep - #endif // DDG4_GEANT4CONVERTER_H diff --git a/DDG4/include/DDG4/Geant4GeometryInfo.h b/DDG4/include/DDG4/Geant4GeometryInfo.h index 9b5804630..31b6aa6e3 100644 --- a/DDG4/include/DDG4/Geant4GeometryInfo.h +++ b/DDG4/include/DDG4/Geant4GeometryInfo.h @@ -10,16 +10,15 @@ // Author : M.Frank // //========================================================================== - #ifndef DDG4_GEANT4GEOMETRYINFO_H #define DDG4_GEANT4GEOMETRYINFO_H // Framework include files -#include "DD4hep/Objects.h" -#include "DD4hep/Printout.h" -#include "DD4hep/GeoHandler.h" -#include "DD4hep/PropertyTable.h" -#include "DDG4/Geant4Primitives.h" +#include +#include +#include +#include +#include // C/C++ include files #include @@ -127,12 +126,10 @@ namespace dd4hep { PropertyVector() = default; ~PropertyVector() = default; }; -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) std::map g4OpticalProperties; std::map g4OpticalSurfaces; std::map g4SkinSurfaces; std::map g4BorderSurfaces; -#endif std::map g4Regions; std::map g4Vis; std::map g4Limits; @@ -160,5 +157,4 @@ namespace dd4hep { } // End namespace sim } // End namespace dd4hep - #endif // DDG4_GEANT4GEOMETRYINFO_H diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp index edb4402ac..1e00a3143 100644 --- a/DDG4/src/Geant4Converter.cpp +++ b/DDG4/src/Geant4Converter.cpp @@ -81,7 +81,6 @@ namespace units = dd4hep; using namespace dd4hep::sim; using namespace dd4hep; -using namespace std; namespace { @@ -92,7 +91,7 @@ namespace { static constexpr const char* GEANT4_TAG_MEE = "MeanExcitationEnergy"; static constexpr const char* GEANT4_TAG_ENE_PER_ION_PAIR = "MeanEnergyPerIonPair"; - static string indent = ""; + static std::string indent = ""; template void handleRefs(const O* o, const C& c, F pmf) { for (typename C::const_iterator i = c.begin(); i != c.end(); ++i) { @@ -120,7 +119,7 @@ namespace { template void handleRMap(const O* o, const C& c, F pmf) { for (typename C::const_reverse_iterator i = c.rbegin(); i != c.rend(); ++i) { - //cout << "Handle RMAP [ " << (*i).first << " ]" << endl; + //cout << "Handle RMAP [ " << (*i).first << " ]" << std::endl; handle(o, (*i).second, pmf); } } @@ -133,8 +132,8 @@ namespace { } } - string make_NCName(const string& in) { - string res = detail::str_replace(in, "/", "_"); + std::string make_NCName(const std::string& in) { + std::string res = detail::str_replace(in, "/", "_"); res = detail::str_replace(res, "#", "_"); return res; } @@ -154,7 +153,7 @@ namespace { public: Region region; double threshold; - bool storeSecondaries; + bool storeSecondaries; G4UserRegionInformation() : threshold(0.0), storeSecondaries(false) { } @@ -166,40 +165,40 @@ namespace { } }; - pair g4PropertyConversion(int index) { + std::pair g4PropertyConversion(int index) { #if G4VERSION_NUMBER >= 1040 switch(index) { - case kRINDEX: return make_pair(CLHEP::keV/units::keV, 1.0); - case kREFLECTIVITY: return make_pair(CLHEP::keV/units::keV, 1.0); - case kREALRINDEX: return make_pair(CLHEP::keV/units::keV, 1.0); - case kIMAGINARYRINDEX: return make_pair(CLHEP::keV/units::keV, 1.0); - case kEFFICIENCY: return make_pair(CLHEP::keV/units::keV, 1.0); - case kTRANSMITTANCE: return make_pair(CLHEP::keV/units::keV, 1.0); - case kSPECULARLOBECONSTANT: return make_pair(CLHEP::keV/units::keV, 1.0); - case kSPECULARSPIKECONSTANT: return make_pair(CLHEP::keV/units::keV, 1.0); - case kBACKSCATTERCONSTANT: return make_pair(CLHEP::keV/units::keV, 1.0); - case kGROUPVEL: return make_pair(CLHEP::keV/units::keV, (CLHEP::m/CLHEP::s)/(units::m/units::s)); // meter/second - case kMIEHG: return make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); - case kRAYLEIGH: return make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); // ??? says its a length - case kWLSCOMPONENT: return make_pair(CLHEP::keV/units::keV, 1.0); - case kWLSABSLENGTH: return make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); - case kABSLENGTH: return make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); + case kRINDEX: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kREFLECTIVITY: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kREALRINDEX: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kIMAGINARYRINDEX: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kEFFICIENCY: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kTRANSMITTANCE: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kSPECULARLOBECONSTANT: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kSPECULARSPIKECONSTANT: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kBACKSCATTERCONSTANT: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kGROUPVEL: return std::make_pair(CLHEP::keV/units::keV, (CLHEP::m/CLHEP::s)/(units::m/units::s)); // meter/second + case kMIEHG: return std::make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); + case kRAYLEIGH: return std::make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); // ??? says its a length + case kWLSCOMPONENT: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kWLSABSLENGTH: return std::make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); + case kABSLENGTH: return std::make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); #if G4VERSION_NUMBER >= 1100 - case kWLSCOMPONENT2: return make_pair(CLHEP::keV/units::keV, 1.0); - case kWLSABSLENGTH2: return make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); - case kSCINTILLATIONCOMPONENT1: return make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); - case kSCINTILLATIONCOMPONENT2: return make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); - case kSCINTILLATIONCOMPONENT3: return make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); + case kWLSCOMPONENT2: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kWLSABSLENGTH2: return std::make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); + case kSCINTILLATIONCOMPONENT1: return std::make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); + case kSCINTILLATIONCOMPONENT2: return std::make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); + case kSCINTILLATIONCOMPONENT3: return std::make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); #else - case kFASTCOMPONENT: return make_pair(CLHEP::keV/units::keV, 1.0); - case kSLOWCOMPONENT: return make_pair(CLHEP::keV/units::keV, 1.0); + case kFASTCOMPONENT: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kSLOWCOMPONENT: return std::make_pair(CLHEP::keV/units::keV, 1.0); #endif - case kPROTONSCINTILLATIONYIELD: return make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); // Yields: 1/energy - case kDEUTERONSCINTILLATIONYIELD: return make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); - case kTRITONSCINTILLATIONYIELD: return make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); - case kALPHASCINTILLATIONYIELD: return make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); - case kIONSCINTILLATIONYIELD: return make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); - case kELECTRONSCINTILLATIONYIELD: return make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); + case kPROTONSCINTILLATIONYIELD: return std::make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); // Yields: 1/energy + case kDEUTERONSCINTILLATIONYIELD: return std::make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); + case kTRITONSCINTILLATIONYIELD: return std::make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); + case kALPHASCINTILLATIONYIELD: return std::make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); + case kIONSCINTILLATIONYIELD: return std::make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); + case kELECTRONSCINTILLATIONYIELD: return std::make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); default: break; } @@ -207,7 +206,7 @@ namespace { #else printout(FATAL,"Geant4Converter", "+++ Cannot convert material property with index: %d [Need Geant4 > 10.03]", index); #endif - return make_pair(0e0,0e0); + return std::make_pair(0e0,0e0); } double g4ConstPropertyConversion(int index) { @@ -306,7 +305,7 @@ Geant4Converter::~Geant4Converter() { } /// Handle the conversion of isotopes -void* Geant4Converter::handleIsotope(const string& /* name */, const TGeoIsotope* iso) const { +void* Geant4Converter::handleIsotope(const std::string& /* name */, const TGeoIsotope* iso) const { G4Isotope* g4i = data().g4Isotopes[iso]; if ( !g4i ) { double a_conv = (CLHEP::g / CLHEP::mole); @@ -320,7 +319,7 @@ void* Geant4Converter::handleIsotope(const string& /* name */, const TGeoIsotope } /// Handle the conversion of elements -void* Geant4Converter::handleElement(const string& name, const Atom element) const { +void* Geant4Converter::handleElement(const std::string& name, const Atom element) const { G4Element* g4e = data().g4Elements[element]; if ( !g4e ) { PrintLevel lvl = debugElements ? ALWAYS : outputLevel; @@ -339,8 +338,8 @@ void* Geant4Converter::handleElement(const string& name, const Atom element) con printout(lvl, "Geant4Converter", "++ Created G4 Isotope %s from data: Z=%d N=%d A=%.3f [g/mole]", element->GetName(), element->Z(), element->N(), element->A()); } - stringstream str; - str << (*g4e) << endl; + std::stringstream str; + str << (*g4e) << std::endl; printout(lvl, "Geant4Converter", "++ Created G4 element %s", str.str().c_str()); data().g4Elements[element] = g4e; } @@ -348,7 +347,7 @@ void* Geant4Converter::handleElement(const string& name, const Atom element) con } /// Dump material in GDML format to output stream -void* Geant4Converter::handleMaterial(const string& name, Material medium) const { +void* Geant4Converter::handleMaterial(const std::string& name, Material medium) const { Geant4GeometryInfo& info = data(); G4Material* mat = info.g4Materials[medium]; if ( !mat ) { @@ -405,18 +404,17 @@ void* Geant4Converter::handleMaterial(const string& name, Material medium) const material->GetTemperature(), material->GetPressure()); } - string plugin_name { }; + std::string plugin_name { }; double value = 0e0; double ionisation_mee = -2e100; double ionisation_birks_constant = -2e100; double ionisation_ene_per_ion_pair = -2e100; -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /// Attach the material properties if any G4MaterialPropertiesTable* tab = 0; TListIter propIt(&material->GetProperties()); for(TObject* obj=propIt.Next(); obj; obj = propIt.Next()) { - string exc_str; + std::string exc_str; TNamed* named = (TNamed*)obj; TGDMLMatrix* matrix = info.manager->GetGDMLMatrix(named->GetTitle()); const char* cptr = ::strstr(matrix->GetName(), GEANT4_TAG_IGNORE); @@ -460,7 +458,7 @@ void* Geant4Converter::handleMaterial(const string& name, Material medium) const } // We need to convert the property from TGeo units to Geant4 units auto conv = g4PropertyConversion(idx); - vector bins(v->bins), vals(v->values); + std::vector bins(v->bins), vals(v->values); for(std::size_t i=0, count=bins.size(); iGetConstProperties()); for(TObject* obj=cpropIt.Next(); obj; obj = cpropIt.Next()) { - string exc_str; + std::string exc_str; Bool_t err = kFALSE; TNamed* named = (TNamed*)obj; @@ -555,10 +553,10 @@ void* Geant4Converter::handleMaterial(const string& name, Material medium) const printout(lvl, name, "++ CONST Property: %-20s %g ", named->GetName(), value); tab->AddConstProperty(named->GetName(), value * conv); } -#endif + // // Set Birk's constant if it was supplied in the material table of the TGeoMaterial auto* ionisation = mat->GetIonisation(); - stringstream str; + std::stringstream str; str << (*mat); if ( ionisation ) { if ( ionisation_birks_constant > 0e0 ) { @@ -596,7 +594,7 @@ void* Geant4Converter::handleMaterial(const string& name, Material medium) const } /// Dump solid in GDML format to output stream -void* Geant4Converter::handleSolid(const string& name, const TGeoShape* shape) const { +void* Geant4Converter::handleSolid(const std::string& name, const TGeoShape* shape) const { G4VSolid* solid = nullptr; if ( shape ) { if ( nullptr != (solid = data().g4Solids[shape]) ) { @@ -650,10 +648,8 @@ void* Geant4Converter::handleSolid(const string& name, const TGeoShape* shape) c solid = convertShape(shape); else if (isa == TGeoPara::Class()) solid = convertShape(shape); -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) else if (isa == TGeoTessellated::Class()) solid = convertShape(shape); -#endif else if (isa == TGeoScaledShape::Class()) { TGeoScaledShape* sh = (TGeoScaledShape*) shape; TGeoShape* sol = sh->GetShape(); @@ -743,7 +739,7 @@ void* Geant4Converter::handleSolid(const string& name, const TGeoShape* shape) c } /// Dump logical volume in GDML format to output stream -void* Geant4Converter::handleVolume(const string& name, const TGeoVolume* volume) const { +void* Geant4Converter::handleVolume(const std::string& name, const TGeoVolume* volume) const { Volume _v(volume); Geant4GeometryInfo& info = data(); PrintLevel lvl = debugVolumes ? ALWAYS : outputLevel; @@ -791,7 +787,7 @@ void* Geant4Converter::handleVolume(const string& name, const TGeoVolume* volume G4LogicalVolume* g4vol = nullptr; if ( _v.hasProperties() && !_v.getProperty(GEANT4_TAG_PLUGIN,"").empty() ) { Detector* det = const_cast(&m_detDesc); - string plugin = _v.getProperty(GEANT4_TAG_PLUGIN,""); + std::string plugin = _v.getProperty(GEANT4_TAG_PLUGIN,""); g4vol = PluginService::Create(plugin, det, _v, g4solid, g4medium); if ( !g4vol ) { except("G4Cnv::volume["+name+"]","++ FATAL Failed to call plugin to create logical volume."); @@ -846,7 +842,7 @@ void* Geant4Converter::handleVolume(const string& name, const TGeoVolume* volume } /// Dump logical volume in GDML format to output stream -void* Geant4Converter::collectVolume(const string& /* name */, const TGeoVolume* volume) const { +void* Geant4Converter::collectVolume(const std::string& /* name */, const TGeoVolume* volume) const { Geant4GeometryInfo& info = data(); Volume _v(volume); Region reg = _v.region(); @@ -866,7 +862,7 @@ void* Geant4Converter::collectVolume(const string& /* name */, const TGeoVolume* } /// Dump volume placement in GDML format to output stream -void* Geant4Converter::handleAssembly(const string& name, const TGeoNode* node) const { +void* Geant4Converter::handleAssembly(const std::string& name, const TGeoNode* node) const { TGeoVolume* mot_vol = node->GetVolume(); PrintLevel lvl = debugVolumes ? ALWAYS : outputLevel; if ( mot_vol->IsA() != TGeoVolumeAssembly::Class() ) { @@ -939,7 +935,7 @@ void* Geant4Converter::handleAssembly(const string& name, const TGeoNode* node) } /// Dump volume placement in GDML format to output stream -void* Geant4Converter::handlePlacement(const string& name, const TGeoNode* node) const { +void* Geant4Converter::handlePlacement(const std::string& name, const TGeoNode* node) const { Geant4GeometryInfo& info = data(); PrintLevel lvl = debugPlacements ? ALWAYS : outputLevel; Geant4GeometryMaps::PlacementMap::const_iterator g4it = info.g4Placements.find(node); @@ -1008,7 +1004,7 @@ void* Geant4Converter::handlePlacement(const string& name, const TGeoNode* node) return nullptr; } else if ( node != info.manager->GetTopNode() && volIt == info.g4Volumes.end() ) { - throw logic_error("Geant4Converter: Invalid mother volume found!"); + throw std::logic_error("Geant4Converter: Invalid mother volume found!"); } PlacedVolume pv(node); const auto* pv_data = pv.data(); @@ -1108,7 +1104,7 @@ void* Geant4Converter::handlePlacement(const string& name, const TGeoNode* node) } /// Convert the geometry type region into the corresponding Geant4 object(s). -void* Geant4Converter::handleRegion(Region region, const set& /* volumes */) const { +void* Geant4Converter::handleRegion(Region region, const std::set& /* volumes */) const { G4Region* g4 = data().g4Regions[region]; if ( !g4 ) { PrintLevel lvl = debugRegions ? ALWAYS : outputLevel; @@ -1117,7 +1113,7 @@ void* Geant4Converter::handleRegion(Region region, const set& // create region info with storeSecondaries flag if( not r.wasThresholdSet() and r.storeSecondaries() ) { - throw runtime_error("G4Region: StoreSecondaries is True, but no explicit threshold set:"); + throw std::runtime_error("G4Region: StoreSecondaries is True, but no explicit threshold set:"); } printout(lvl, "Geant4Converter", "++ Setting up region: %s", r.name()); G4UserRegionInformation* info = new G4UserRegionInformation(); @@ -1127,7 +1123,7 @@ void* Geant4Converter::handleRegion(Region region, const set& g4->SetUserInformation(info); printout(lvl, "Geant4Converter", "++ Converted region settings of:%s.", r.name()); - vector < string > &limits = r.limits(); + std::vector < std::string > &limits = r.limits(); G4ProductionCuts* cuts = 0; // set production cut if( not r.useDefaultCut() ) { @@ -1149,7 +1145,7 @@ void* Geant4Converter::handleRegion(Region region, const set& else if ( c.particles == "e[-+]" ) pid = -idxG4PositronCut-idxG4ElectronCut; else if ( c.particles == "gamma" ) pid = idxG4GammaCut; else if ( c.particles == "proton" ) pid = idxG4ProtonCut; - else throw runtime_error("G4Region: Invalid production cut particle-type:" + c.particles); + else throw std::runtime_error("G4Region: Invalid production cut particle-type:" + c.particles); if ( !cuts ) cuts = new G4ProductionCuts(); if ( pid == -(idxG4PositronCut+idxG4ElectronCut) ) { cuts->SetProductionCut(c.value*CLHEP::mm/units::mm, idxG4PositronCut); @@ -1186,7 +1182,7 @@ void* Geant4Converter::handleRegion(Region region, const set& } /// Convert the geometry type LimitSet into the corresponding Geant4 object(s). -void* Geant4Converter::handleLimitSet(LimitSet limitset, const set& /* volumes */) const { +void* Geant4Converter::handleLimitSet(LimitSet limitset, const std::set& /* volumes */) const { G4UserLimits* g4 = data().g4Limits[limitset]; if ( !g4 ) { PrintLevel lvl = debugLimits || debugRegions ? ALWAYS : outputLevel; @@ -1228,7 +1224,7 @@ void* Geant4Converter::handleLimitSet(LimitSet limitset, const set processors; + std::map < std::string, std::string > processors; static int s_idd = 9999999; for( const auto& [nam, vals] : prp ) { if ( nam.substr(0, 6) == "geant4" ) { auto id_it = vals.find("id"); - string id = (id_it == vals.end()) ? _toString(++s_idd,"%d") : (*id_it).second; + std::string id = (id_it == vals.end()) ? _toString(++s_idd,"%d") : (*id_it).second; processors.emplace(id, nam); } } for( const auto& p : processors ) { const GeoHandler* hdlr = this; const Detector::PropertyValues& vals = prp[p.second]; - string type = vals.find("type")->second; - string tag = type + "_Geant4_action"; + std::string type = vals.find("type")->second; + std::string tag = type + "_Geant4_action"; Detector* det = const_cast(&m_detDesc); long res = PluginService::Create(tag, det, hdlr, &vals); if ( 0 == res ) { - throw runtime_error("Failed to locate plugin to interprete files of type" - " \"" + tag + "\" - no factory:" + type); + throw std::runtime_error("Failed to locate plugin to interprete files of type" + " \"" + tag + "\" - no factory:" + type); } res = *(long*)res; if ( res != 1 ) { - throw runtime_error("Failed to invoke the plugin " + tag + " of type " + type); + throw std::runtime_error("Failed to invoke the plugin " + tag + " of type " + type); } printout(outputLevel, "Geant4Converter", "+++++ Executed Successfully Geant4 setup module *%s*.", type.c_str()); } } -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /// Convert the geometry type material into the corresponding Geant4 object(s). void* Geant4Converter::handleMaterialProperties(TObject* mtx) const { Geant4GeometryInfo& info = data(); @@ -1422,7 +1417,7 @@ void* Geant4Converter::handleOpticalSurface(TObject* surface) const { G4SurfaceType type = geant4_surface_type(optSurf->GetType()); G4OpticalSurfaceModel model = geant4_surface_model(optSurf->GetModel()); G4OpticalSurfaceFinish finish = geant4_surface_finish(optSurf->GetFinish()); - string name = make_NCName(optSurf->GetName()); + std::string name = make_NCName(optSurf->GetName()); PrintLevel lvl = debugSurfaces ? ALWAYS : DEBUG; g4 = new G4OpticalSurface(name, model, finish, type, optSurf->GetValue()); g4->SetSigmaAlpha(optSurf->GetSigmaAlpha()); @@ -1440,7 +1435,7 @@ void* Geant4Converter::handleOpticalSurface(TObject* surface) const { G4MaterialPropertiesTable* tab = nullptr; TListIter itp(&optSurf->GetProperties()); for(TObject* obj = itp.Next(); obj; obj = itp.Next()) { - string exc_str; + std::string exc_str; TNamed* named = (TNamed*)obj; TGDMLMatrix* matrix = info.manager->GetGDMLMatrix(named->GetTitle()); const char* cptr = ::strstr(matrix->GetName(), GEANT4_TAG_IGNORE); @@ -1475,7 +1470,7 @@ void* Geant4Converter::handleOpticalSurface(TObject* surface) const { } // We need to convert the property from TGeo units to Geant4 units auto conv = g4PropertyConversion(idx); - vector bins(v->bins), vals(v->values); + std::vector bins(v->bins), vals(v->values); for(std::size_t i=0, count=v->bins.size(); i= ROOT_VERSION(6,31,1) TListIter itc(&optSurf->GetConstProperties()); for(TObject* obj = itc.Next(); obj; obj = itc.Next()) { - string exc_str; + std::string exc_str; TNamed* named = (TNamed*)obj; const char* cptr = ::strstr(named->GetName(), GEANT4_TAG_IGNORE); if ( nullptr != cptr ) { @@ -1554,7 +1549,7 @@ void* Geant4Converter::handleSkinSurface(TObject* surface) const { if ( !g4 ) { G4OpticalSurface* optSurf = info.g4OpticalSurfaces[OpticalSurface(surf->GetSurface())]; G4LogicalVolume* v = info.g4Volumes[surf->GetVolume()]; - string name = make_NCName(surf->GetName()); + std::string name = make_NCName(surf->GetName()); g4 = new G4LogicalSkinSurface(name, v, optSurf); printout(debugSurfaces ? ALWAYS : DEBUG, "Geant4Converter", "++ Created SkinSurface: %-18s optical:%s", @@ -1573,7 +1568,7 @@ void* Geant4Converter::handleBorderSurface(TObject* surface) const { G4OpticalSurface* optSurf = info.g4OpticalSurfaces[OpticalSurface(surf->GetSurface())]; G4VPhysicalVolume* n1 = info.g4Placements[surf->GetNode1()]; G4VPhysicalVolume* n2 = info.g4Placements[surf->GetNode2()]; - string name = make_NCName(surf->GetName()); + std::string name = make_NCName(surf->GetName()); g4 = new G4LogicalBorderSurface(name, n1, n2, optSurf); printout(debugSurfaces ? ALWAYS : DEBUG, "Geant4Converter", "++ Created BorderSurface: %-18s optical:%s", @@ -1582,38 +1577,38 @@ void* Geant4Converter::handleBorderSurface(TObject* surface) const { } return g4; } -#endif /// Convert the geometry type SensitiveDetector into the corresponding Geant4 object(s). -void Geant4Converter::printSensitive(SensitiveDetector sens_det, const set& /* volumes */) const { - Geant4GeometryInfo& info = data(); - set& volset = info.sensitives[sens_det]; - SensitiveDetector sd = sens_det; - stringstream str; +void Geant4Converter::printSensitive(SensitiveDetector sens_det, const std::set& /* volumes */) const { + Geant4GeometryInfo& info = data(); + std::set& volset = info.sensitives[sens_det]; + SensitiveDetector sd = sens_det; + std::stringstream str; printout(INFO, "Geant4Converter", "++ SensitiveDetector: %-18s %-20s Hits:%-16s", sd.name(), ("[" + sd.type() + "]").c_str(), sd.hitsCollection().c_str()); - str << " | " << "Cutoff:" << setw(6) << left << sd.energyCutoff() << setw(5) << right << volset.size() + str << " | " << "Cutoff:" << std::setw(6) << std::left + << sd.energyCutoff() << std::setw(5) << std::right << volset.size() << " volumes "; if (sd.region().isValid()) - str << " Region:" << setw(12) << left << sd.region().name(); + str << " Region:" << std::setw(12) << std::left << sd.region().name(); if (sd.limits().isValid()) - str << " Limits:" << setw(12) << left << sd.limits().name(); + str << " Limits:" << std::setw(12) << std::left << sd.limits().name(); str << "."; printout(INFO, "Geant4Converter", str.str().c_str()); for (const auto i : volset ) { - map::iterator v = info.g4Volumes.find(i); + std::map::iterator v = info.g4Volumes.find(i); G4LogicalVolume* vol = (*v).second; str.str(""); - str << " | " << "Volume:" << setw(24) << left << vol->GetName() << " " + str << " | " << "Volume:" << std::setw(24) << std::left << vol->GetName() << " " << vol->GetNoDaughters() << " daughters."; printout(INFO, "Geant4Converter", str.str().c_str()); } } -string printSolid(G4VSolid* sol) { - stringstream str; +std::string printSolid(G4VSolid* sol) { + std::stringstream str; if (typeid(*sol) == typeid(G4Box)) { const G4Box* b = (G4Box*) sol; str << "++ Box: x=" << b->GetXHalfLength() << " y=" << b->GetYHalfLength() << " z=" << b->GetZHalfLength(); @@ -1627,7 +1622,7 @@ string printSolid(G4VSolid* sol) { } /// Print G4 placement -void* Geant4Converter::printPlacement(const string& name, const TGeoNode* node) const { +void* Geant4Converter::printPlacement(const std::string& name, const TGeoNode* node) const { Geant4GeometryInfo& info = data(); G4VPhysicalVolume* g4 = info.g4Placements[node]; G4LogicalVolume* vol = info.g4Volumes[node->GetVolume()]; @@ -1638,7 +1633,7 @@ void* Geant4Converter::printPlacement(const string& name, const TGeoNode* node) if ( !sd ) { return g4; } - stringstream str; + std::stringstream str; str << "G4Cnv::placement: + " << name << " No:" << node->GetNumber() << " Vol:" << vol->GetName() << " Solid:" << sol->GetName(); printout(outputLevel, "G4Placement", str.str().c_str()); @@ -1667,10 +1662,8 @@ Geant4Converter& Geant4Converter::create(DetElement top) { // We do not have to handle defines etc. // All positions and the like are not really named. // Hence, start creating the G4 objects for materials, solids and log volumes. -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) handleArray(this, geo.manager->GetListOfGDMLMatrices(), &Geant4Converter::handleMaterialProperties); handleArray(this, geo.manager->GetListOfOpticalSurfaces(), &Geant4Converter::handleOpticalSurface); -#endif handle(this, geo.volumes, &Geant4Converter::collectVolume); handle(this, geo.solids, &Geant4Converter::handleSolid); @@ -1686,11 +1679,9 @@ Geant4Converter& Geant4Converter::create(DetElement top) { handleRMap(this, *m_data, &Geant4Converter::handleAssembly); // Now place all this stuff appropriately handleRMap(this, *m_data, &Geant4Converter::handlePlacement); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /// Handle concrete surfaces handleArray(this, geo.manager->GetListOfSkinSurfaces(), &Geant4Converter::handleSkinSurface); handleArray(this, geo.manager->GetListOfBorderSurfaces(), &Geant4Converter::handleBorderSurface); -#endif //==================== Fields handleProperties(m_detDesc.properties()); if ( printSensitives ) { diff --git a/DDG4/src/Geant4Data.cpp b/DDG4/src/Geant4Data.cpp index f97c565f4..4d57b09ca 100644 --- a/DDG4/src/Geant4Data.cpp +++ b/DDG4/src/Geant4Data.cpp @@ -24,7 +24,6 @@ #include #include -using namespace std; using namespace dd4hep; using namespace dd4hep::sim; diff --git a/DDG4/src/Geant4DataConversion.cpp b/DDG4/src/Geant4DataConversion.cpp index b1982dffc..40472cd4d 100644 --- a/DDG4/src/Geant4DataConversion.cpp +++ b/DDG4/src/Geant4DataConversion.cpp @@ -12,7 +12,7 @@ //========================================================================== // Framework include files -#include "DDG4/Geant4DataConversion.h" +#include using namespace dd4hep::sim; diff --git a/DDG4/src/Geant4DataDump.cpp b/DDG4/src/Geant4DataDump.cpp index a92f01f93..f07fefa7c 100644 --- a/DDG4/src/Geant4DataDump.cpp +++ b/DDG4/src/Geant4DataDump.cpp @@ -12,10 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/Primitives.h" -#include "DDG4/Geant4DataDump.h" +#include +#include -using namespace std; using namespace dd4hep; using namespace dd4hep::sim; diff --git a/DDG4/src/Geant4DetectorConstruction.cpp b/DDG4/src/Geant4DetectorConstruction.cpp index 1a74a2a26..1eddbf989 100644 --- a/DDG4/src/Geant4DetectorConstruction.cpp +++ b/DDG4/src/Geant4DetectorConstruction.cpp @@ -12,13 +12,13 @@ //========================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4Mapping.h" -#include "DDG4/Geant4GeometryInfo.h" -#include "DDG4/Geant4DetectorConstruction.h" +#include +#include +#include +#include -#include "G4VUserDetectorConstruction.hh" -#include "G4SDManager.hh" +#include +#include using namespace std; using namespace dd4hep; @@ -114,63 +114,63 @@ void Geant4DetectorConstructionSequence::constructSensitives(Geant4DetectorConst const map& Geant4DetectorConstructionSequence::regions() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4Regions; - throw runtime_error("+++ Geant4DetectorConstructionSequence::regions: Access not possible. Geometry is not yet converted!"); + throw std::runtime_error("+++ Geant4DetectorConstructionSequence::regions: Access not possible. Geometry is not yet converted!"); } #if 0 /// Access to the converted sensitive detectors const Geant4GeometryMaps::SensDetMap& Geant4DetectorConstructionSequence::sensitives() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4SensDets; - throw runtime_error("+++ Geant4DetectorConstructionSequence::sensitives: Access not possible. Geometry is not yet converted!"); + throw std::runtime_error("+++ Geant4DetectorConstructionSequence::sensitives: Access not possible. Geometry is not yet converted!"); } #endif /// Access to the converted volumes const map& Geant4DetectorConstructionSequence::volumes() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4Volumes; - throw runtime_error("+++ Geant4DetectorConstructionSequence::volumes: Access not possible. Geometry is not yet converted!"); + throw std::runtime_error("+++ Geant4DetectorConstructionSequence::volumes: Access not possible. Geometry is not yet converted!"); } /// Access to the converted shapes const map& Geant4DetectorConstructionSequence::shapes() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4Solids; - throw runtime_error("+++ Geant4DetectorConstructionSequence::shapes: Access not possible. Geometry is not yet converted!"); + throw std::runtime_error("+++ Geant4DetectorConstructionSequence::shapes: Access not possible. Geometry is not yet converted!"); } /// Access to the converted limit sets const map& Geant4DetectorConstructionSequence::limits() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4Limits; - throw runtime_error("+++ Geant4DetectorConstructionSequence::limits: Access not possible. Geometry is not yet converted!"); + throw std::runtime_error("+++ Geant4DetectorConstructionSequence::limits: Access not possible. Geometry is not yet converted!"); } /// Access to the converted assemblies const map& Geant4DetectorConstructionSequence::assemblies() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4AssemblyVolumes; - throw runtime_error("+++ Geant4DetectorConstructionSequence::assemblies: Access not possible. Geometry is not yet converted!"); + throw std::runtime_error("+++ Geant4DetectorConstructionSequence::assemblies: Access not possible. Geometry is not yet converted!"); } /// Access to the converted placements const map& Geant4DetectorConstructionSequence::placements() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4Placements; - throw runtime_error("+++ Geant4DetectorConstructionSequence::placements: Access not possible. Geometry is not yet converted!"); + throw std::runtime_error("+++ Geant4DetectorConstructionSequence::placements: Access not possible. Geometry is not yet converted!"); } /// Access to the converted materials const Geant4GeometryMaps::MaterialMap& Geant4DetectorConstructionSequence::materials() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4Materials; - throw runtime_error("+++ Geant4DetectorConstructionSequence::materials: Access not possible. Geometry is not yet converted!"); + throw std::runtime_error("+++ Geant4DetectorConstructionSequence::materials: Access not possible. Geometry is not yet converted!"); } /// Access to the converted elements const Geant4GeometryMaps::ElementMap& Geant4DetectorConstructionSequence::elements() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4Elements; - throw runtime_error("+++ Geant4DetectorConstructionSequence::elements: Access not possible. Geometry is not yet converted!"); + throw std::runtime_error("+++ Geant4DetectorConstructionSequence::elements: Access not possible. Geometry is not yet converted!"); } diff --git a/DDG4/src/Geant4ShapeConverter.cpp b/DDG4/src/Geant4ShapeConverter.cpp index c46644716..b7b35a31e 100644 --- a/DDG4/src/Geant4ShapeConverter.cpp +++ b/DDG4/src/Geant4ShapeConverter.cpp @@ -43,6 +43,9 @@ #include #include #include +#include +#include +#include // C/C++ include files @@ -237,18 +240,6 @@ namespace dd4hep { vertices.emplace_back(vtx_xy[0] * CM_2_MM, vtx_xy[1] * CM_2_MM); return new G4GenericTrap(sh->GetName(), sh->GetDz() * CM_2_MM, vertices); } - } // End namespace sim -} // End namespace dd4hep - -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) -#include -#include -#include - -/// Namespace for the AIDA detector description toolkit -namespace dd4hep { - /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit - namespace sim { template <> G4VSolid* convertShape(const TGeoShape* shape) { TGeoTessellated* sh = (TGeoTessellated*) shape; @@ -299,5 +290,3 @@ namespace dd4hep { } // End namespace sim } // End namespace dd4hep -#endif // ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) - diff --git a/DDG4/src/python/Geant4PythonCall.cpp b/DDG4/src/python/Geant4PythonCall.cpp index b8f12fd99..60f39683e 100644 --- a/DDG4/src/python/Geant4PythonCall.cpp +++ b/DDG4/src/python/Geant4PythonCall.cpp @@ -13,14 +13,13 @@ //========================================================================== // Framework include files -#include "DDG4/Python/Geant4PythonCall.h" -#include "DDG4/Python/DDPython.h" -#include "TPyReturn.h" +#include +#include +#include // C/C++ include files #include -using namespace std; using namespace dd4hep; using namespace dd4hep::sim; @@ -87,9 +86,7 @@ namespace dd4hep { namespace sim { INSTANTIATE(unsigned long); INSTANTIATE(float); INSTANTIATE(double); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0) INSTANTIATE(char*); -#endif INSTANTIATE(const char*); INSTANTIATE(PyObject*); INSTANTIATE(void*); diff --git a/DDParsers/include/Evaluator/DD4hepUnits.h b/DDParsers/include/Evaluator/DD4hepUnits.h index 0fd32607a..d4b24bfb2 100644 --- a/DDParsers/include/Evaluator/DD4hepUnits.h +++ b/DDParsers/include/Evaluator/DD4hepUnits.h @@ -29,16 +29,6 @@ #include "RVersion.h" -// We use the ROOT system units if they are avalible (FAILS SOME TESTS FOR NOW) -#if 0 -/// ROOT_VERSION_CODE >= ROOT_VERSION(6,12,0) -#include "TGeoSystemOfUnits.h" -/// Main dd4hep namespace. We must import here the ROOT TGeo units -namespace dd4hep { - using namespace TGeoUnit; -} -#else - /// Main dd4hep namespace. We must import here the ROOT TGeo units namespace dd4hep { @@ -423,6 +413,4 @@ namespace dd4hep { static constexpr double universe_mean_density = 1.e-25 * g / cm3; //} } -#endif - #endif // EVALUATOR_DD4HEPUNITS_H diff --git a/UtilityApps/src/teve_display.cpp b/UtilityApps/src/teve_display.cpp index 8e70d5025..7c5940630 100644 --- a/UtilityApps/src/teve_display.cpp +++ b/UtilityApps/src/teve_display.cpp @@ -12,50 +12,49 @@ //========================================================================== // Framework include files -#include "DD4hep/Factories.h" -#include "DD4hep/Detector.h" -#include "DDRec/SurfaceHelper.h" +#include +#include +#include #include "EvNavHandler.h" #include "MultiView.h" #include "run_plugin.h" -#include "TRint.h" - -#include "TROOT.h" -#include "TEveGeoNode.h" -#include "TEveBrowser.h" -#include "TGNumberEntry.h" -#include "TGButton.h" -#include "TGLabel.h" -#include "TStyle.h" -#include "TGComboBox.h" -#include "TEveManager.h" -#include "TSystem.h" -#include "TGLViewer.h" -#include "TEveViewer.h" -#include "TGLPerspectiveCamera.h" -#include "TGLCamera.h" -#include "TEveStraightLineSet.h" -#include "TSysEvtHandler.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #include -#include "TGeoManager.h" -#include "TGLClip.h" -#include "TMap.h" -#include "TObjString.h" -#include "TGeoShape.h" -#include "TGLScenePad.h" +#include +#include +#include +#include +#include +#include using namespace dd4hep ; using namespace rec ; using namespace detail ; - //===================================================================================== // function declarations: void next_event(); @@ -295,12 +294,7 @@ void make_gui() { TGHorizontalFrame* hf = new TGHorizontalFrame(frmMain); { - -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,9,2) TString icondir( Form("%s/", TROOT::GetIconPath().Data()) ); -#else - TString icondir( Form("%s/icons/", gSystem->Getenv("ROOTSYS")) ); -#endif TGPictureButton* b = 0; EvNavHandler *fh = new EvNavHandler; diff --git a/examples/ClientTests/src/Assemblies_VXD_geo.cpp b/examples/ClientTests/src/Assemblies_VXD_geo.cpp index fa6a7cdd5..e6a647790 100644 --- a/examples/ClientTests/src/Assemblies_VXD_geo.cpp +++ b/examples/ClientTests/src/Assemblies_VXD_geo.cpp @@ -14,13 +14,11 @@ // Framework includes #include "DD4hep/DetFactoryHelper.h" -using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; static Ref_t create_element(Detector& description, xml_h e, SensitiveDetector sens) { xml_det_t x_det = e; - string name = x_det.nameStr(); + std::string name = x_det.nameStr(); Assembly assembly(name+"_assembly"); DetElement vxd(name, x_det.typeStr(), x_det.id()); PlacedVolume pv; @@ -32,7 +30,7 @@ static Ref_t create_element(Detector& description, xml_h e, SensitiveDetector se xml_comp_t x_ladder (x_layer.child(_U(ladder))); int layer_id = x_layer.id(); int nLadders = x_ladder.number(); - string layername = name+_toString(layer_id,"_layer%d"); + std::string layername = name+_toString(layer_id,"_layer%d"); double dphi = 2.*M_PI/double(nLadders); // --- create an assembly and DetElement for the layer Assembly layer_assembly(layername); @@ -81,7 +79,7 @@ static Ref_t create_element(Detector& description, xml_h e, SensitiveDetector se for(int j=0; j= ROOT_VERSION(6,20,0) - // Framework include files -#include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/DD4hepUnits.h" -#include "DD4hep/Printout.h" +#include +#include +#include // ROOT include file -#include "TGeoElement.h" -#include "TGeoPhysicalConstants.h" -#include "TGeant4PhysicalConstants.h" -#include "TMath.h" +#include +#include +#include +#include namespace units = dd4hep; -using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; static Ref_t create_element(Detector& description, xml_h xml_det, SensitiveDetector /* sens */) { xml_det_t x_det = xml_det; - string det_name = x_det.nameStr(); + std::string det_name = x_det.nameStr(); Assembly assembly(det_name+"_assembly"); DetElement det(det_name,x_det.typeStr(), x_det.id()); @@ -41,7 +35,7 @@ static Ref_t create_element(Detector& description, xml_h xml_det, SensitiveDetec xml_det_t xbox = x_det.child(_U(box)); Volume box = Volume(det_name+"_box", Box(xbox.x(), xbox.y(), xbox.z()), - description.material(xbox.attr(_U(material)))); + description.material(xbox.attr(_U(material)))); PlacedVolume place = assembly.placeVolume(box); place.addPhysVolID("box",0); } @@ -140,4 +134,4 @@ static Ref_t create_element(Detector& description, xml_h xml_det, SensitiveDetec } DECLARE_DETELEMENT(MaterialTester,create_element) -#endif + diff --git a/examples/ClientTests/src/MiniTel.cpp b/examples/ClientTests/src/MiniTel.cpp index 524b2a32c..d1231c5df 100644 --- a/examples/ClientTests/src/MiniTel.cpp +++ b/examples/ClientTests/src/MiniTel.cpp @@ -16,14 +16,14 @@ #include "DD4hep/Printout.h" #include "DD4hep/Detector.h" +// C/C++ include files #include #include -using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; namespace { + struct MyDetExtension { int idD, Ni, Nj; double dimDX, dimDY, dimDZ; @@ -45,14 +45,14 @@ namespace { typedef MyDetExtension DetectorExtension; static Ref_t create_detector(Detector &description, xml_h e, SensitiveDetector sens) { - xml_det_t x_det = e; //xml-detelemnt of the detector taken as an argument - xml_comp_t det_dim = x_det.child(_U(dimensions)); - xml_comp_t det_mod = x_det.child(_U(module)); // considering the module-pixel of the detector - string det_name = x_det.nameStr(); //det_name is the name of the xml-detelement - Assembly assembly (det_name); - DetElement sdet(det_name,x_det.id()); //sdet is the detelement of the detector!!(actually is a Handle,already a pointer to m_element) - Volume motherVol = description.pickMotherVolume(sdet); //the mothers volume of our detector - Material mat = description.material("Silicon"); + xml_det_t x_det = e; //xml-detelemnt of the detector taken as an argument + xml_comp_t det_dim = x_det.child(_U(dimensions)); + xml_comp_t det_mod = x_det.child(_U(module)); // considering the module-pixel of the detector + std::string det_name = x_det.nameStr(); //det_name is the name of the xml-detelement + Assembly assembly (det_name); + DetElement sdet(det_name,x_det.id()); //sdet is the detelement of the detector!!(actually is a Handle,already a pointer to m_element) + Volume motherVol = description.pickMotherVolume(sdet); //the mothers volume of our detector + Material mat = description.material("Silicon"); DetectorExtension* ext = new MyDetExtension(sdet); sdet.addExtension(ext); diff --git a/examples/ClientTests/src/PlacedVolumeScannerTest.cpp b/examples/ClientTests/src/PlacedVolumeScannerTest.cpp index 7800e7b1c..4945fac01 100644 --- a/examples/ClientTests/src/PlacedVolumeScannerTest.cpp +++ b/examples/ClientTests/src/PlacedVolumeScannerTest.cpp @@ -19,7 +19,7 @@ geoPluginRun -destroy -plugin DD4hep_VolumeScannerTest -opt [-opt] */ -// Framework include files +/// Framework include files #include "DD4hep/Volumes.h" #include "DD4hep/Detector.h" #include "DD4hep/Printout.h" @@ -27,6 +27,8 @@ #include "DD4hep/DetectorTools.h" #include "DD4hep/VolumeProcessor.h" #include "TClass.h" + +/// C/C++ include files #include namespace { @@ -61,7 +63,6 @@ namespace { }; } -using namespace std; using namespace dd4hep; /// Plugin function: Test example of the volume scanner using a customized callback functor @@ -73,7 +74,7 @@ using namespace dd4hep; */ static int scan_volumes (Detector& detector, int argc, char** argv) { bool help = false; - string det_element_path, placed_vol_path; + std::string det_element_path, placed_vol_path; for(int i=0; i -arg [-arg] \n" " name: factory name DD4hep_PlacedVolumeScannerTest \n" " -detector Path to the detector element where to start the scan.\n" " -path Alternatively specify the physical volume path. \n" " -help Ahow this help. \n" - "\tArguments given: " << arguments(argc,argv) << endl << flush; + "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush; ::exit(EINVAL); } diff --git a/examples/ClientTests/src/Property_test.cpp b/examples/ClientTests/src/Property_test.cpp index 214a1a6dd..e3aa96ff9 100644 --- a/examples/ClientTests/src/Property_test.cpp +++ b/examples/ClientTests/src/Property_test.cpp @@ -11,13 +11,14 @@ // //========================================================================== -// Framework include files +/// Framework include files #include #include + +/// C/C++ include files #include #include -using namespace std; using namespace dd4hep; /// Plugin function: Condition program example @@ -30,72 +31,78 @@ using namespace dd4hep; */ #include namespace { - template int _test_prop(const string& tag, const string& data) { + template int _test_prop(const std::string& tag, const std::string& data) { T value; - stringstream log; + std::stringstream log; Property prop(value); try { prop.str(data); - log << "| " << setw(32) << left << tag << " " << setw(6) << left << "" << " " << setw(10) << left << value << " "; - cout << log.str() << endl; + log << "| " << std::setw(32) << std::left << tag << " " + << std::setw(6) << std::left << "" << " " + << std::setw(10) << std::left << value << " "; + std::cout << log.str() << std::endl; } - catch(const exception& e) { - cout << "Test FAILED: " << tag << " Exception: " << e.what() << endl; + catch(const std::exception& e) { + std::cout << "Test FAILED: " << tag << " Exception: " << e.what() << std::endl; return 1; } return 0; } - template int _test_cont(const string& tag, const string& data) { + template int _test_cont(const std::string& tag, const std::string& data) { T value; - stringstream log; + std::stringstream log; Property prop(value); try { prop.str(data); - log << "| " << setw(32) << left << tag << " "; + log << "| " << std::setw(32) << std::left << tag << " "; for(const auto& p : value) - log << setw(6) << left << "" << " " << setw(10) << left << p << " "; - cout << log.str() << endl; + log << std::setw(6) << std::left << "" << " " << std::setw(10) << std::left << p << " "; + std::cout << log.str() << std::endl; } - catch(const exception& e) { - cout << "Test FAILED: " << tag << " Exception: " << e.what() << endl; + catch(const std::exception& e) { + std::cout << "Test FAILED: " << tag << " Exception: " << e.what() << std::endl; return 1; } return 0; } - template <> int _test_cont >(const string& tag, const string& data) { - vector value; - stringstream log; + template <> int _test_cont >(const std::string& tag, const std::string& data) { + std::vector value; + std::stringstream log; Property prop(value); try { prop.str(data); - log << "| " << setw(32) << left << tag << " "; + log << "| " << std::setw(32) << std::left << tag << " "; for(const auto p : value) - log << setw(6) << left << "" << " " << setw(10) << left << p << " "; - cout << log.str() << endl; + log << std::setw(6) << std::left << "" << " " << std::setw(10) << std::left << p << " "; + std::cout << log.str() << std::endl; } - catch(const exception& e) { - cout << "Test FAILED: " << tag << " Exception: " << e.what() << endl; + catch(const std::exception& e) { + std::cout << "Test FAILED: " << tag << " Exception: " << e.what() << std::endl; return 1; } return 0; } - template int _test_map(const string& tag, const string& data) { + template int _test_map(const std::string& tag, const std::string& data) { T value; - stringstream log; + std::stringstream log; Property prop(value); try { prop.str(data); - log << "| " << setw(32) << left << tag << " "; + log << "| " << std::setw(32) << std::left << tag << " "; for(const auto& p : value) - log << setw(6) << left << p.first << " = " << setw(10) << left << p.second << " "; - cout << log.str() << endl; + log << std::setw(6) << std::left << p.first << " = " << std::setw(10) << std::left << p.second << " "; + std::cout << log.str() << std::endl; } - catch(const exception& e) { - cout << "Test FAILED: " << tag << " Exception: " << e.what() << endl; + catch(const std::exception& e) { + std::cout << "Test FAILED: " << tag << " Exception: " << e.what() << std::endl; return 1; } return 0; } + void line() { + std::cout << "+-----------------------------------------------------" + << "-----------------------------------------------------" << std::endl; + } } static int property_test(Detector& /* description */, int /* argc */, char** /* argv */) { @@ -104,8 +111,8 @@ static int property_test(Detector& /* description */, int /* argc */, char** /* using XYZVector = ROOT::Math::XYZVector; using PxPyPzE = ROOT::Math::PxPyPzEVector; int result = 0; - cout << "+----------------------------------------------------------------------------------------------------------" << endl; - result += _test_prop ("prop_str", "'a'"); + line(); + result += _test_prop ("prop_str", "'a'"); result += _test_prop ("prop_bool", "true"); result += _test_prop ("prop_int", "11"); result += _test_prop ("prop_int_eval", "1*11"); @@ -123,119 +130,119 @@ static int property_test(Detector& /* description */, int /* argc */, char** /* result += _test_prop ("prop_XYZVector_eval", "(1*GeV, 2*GeV, 3*GeV)"); result += _test_prop ("prop_PxPyPzEVector", "(1, 2, 3, 4)"); result += _test_prop ("prop_PxPyPzEVector_eval", "(1*GeV, 2*GeV, 3*GeV, 4*GeV)"); - cout << "+----------------------------------------------------------------------------------------------------------" << endl; - result += _test_map > ("map_str_str", "{'a': 'a', 'b': 'bb', 'c': 'ccc'}"); - result += _test_map > ("map_str_bool", "{'a': true, 'b': false, 'c': true}"); - result += _test_map > ("map_str_int", "{'a': 11, 'b': 222, 'c': 3333}"); - result += _test_map > ("map_str_int_eval", "{'a': 1*11, 'b': 2*111, 'c': 3*1111}"); - result += _test_map > ("map_str_long", "{'a': 111, 'b': 222, 'c': 3333}"); - result += _test_map > ("map_str_long_eval", "{'a': 1*111, 'b': 2*111, 'c': 3*1111}"); - result += _test_map > ("map_str_float", "{'a': 1.11, 'b': 22.22, 'c': 333.33}"); - result += _test_map > ("map_str_float_eval", "{'a': '1.11*GeV','b':'22.22*MeV', 'c': '333.3*TeV'}"); - result += _test_map > ("map_str_double", "{'a': 1.11, 'b': 22.22, 'c': 333.33}"); - result += _test_map > ("map_str_double_eval", "{'a': '1.11*GeV','b':'22.22*MeV', 'c': '333.3*TeV'}"); - //result += _test_map > ("map_str_XYZPoint", "{['a', (1, 2, 3)]}");//, 'b': (10,20,30), 'c': (100,200,300)}"); - //result += _test_map > ("map_str_XYZVector", "{'a': (1, 2, 3), 'b': (10,20,30), 'c': (100,200,300)}"); - //result += _test_map > ("map_str_PxPyPzEVector", "{'a': (1, 2, 3, 4), 'b': (10,20,30,40), 'c': (100,200,300,400)}"); - cout << "+----------------------------------------------------------------------------------------------------------" << endl; - result += _test_map > ("map_int_str", "{ 10: 'a', 200: 'bb', 3000: ' ccc'}"); - result += _test_map > ("map_int_bool", "{ 10: true, 200: false, 3000: true}"); - result += _test_map > ("map_int_int", "{ 10: 11, 200: 200, 3000: 3000}"); - result += _test_map > ("map_int_int_eval", "{ 10: 1*11, 200: 2*100, 3000: 3*1000}"); - result += _test_map > ("map_int_long", "{ 10: 111, 200: 222, 3000: 3333}"); - result += _test_map > ("map_int_long_eval", "{ 10: 1*111, 200: 2*111, 3000: 3*1111}"); - result += _test_map > ("map_int_float", "{ 10: 1.11, 200: 22.22, 3000: 333.33}"); - result += _test_map > ("map_int_float_eval", "{ 10: 1.11*GeV, 200: 22.22*MeV, 3000: 333.3*TeV}"); - result += _test_map > ("map_int_double", "{ 10: 1.11, 200: 22.22, 3000: 333.33}"); - result += _test_map > ("map_int_double_eval", "{ 10: 1.11*GeV, 200: 22.22*MeV, 3000: 333.3*TeV}"); - //result += _test_map > ("map_eval_int_str", "{ 1*10: 'a', 2*100: 'bb', 3*1000: 'ccc'}"); - result += _test_map > ("map_eval_int_double", "{ 1*10: 1.11, 2*100: 22.22, 3*1000: 333.33}"); - //result += _test_map > ("map_int_XYZPoint", "{ 10: (1, 2, 3), 200: (10,20,30), 3000: (100,200,300)}"); - //result += _test_map > ("map_int_XYZVector", "{ 10: (1, 2, 3), 200: (10,20,30), 3000: (100,200,300)}"); - //result += _test_map > ("map_int_PxPyPzEVector", "{ 10: (1, 2, 3, 4), 200: (10,20,30,40), 3000: (100,200,300,400)}"); + line(); + result += _test_map >("map_str_str", "{'a': 'a', 'b': 'bb', 'c': 'ccc'}"); + result += _test_map > ("map_str_bool", "{'a': true, 'b': false, 'c': true}"); + result += _test_map > ("map_str_int", "{'a': 11, 'b': 222, 'c': 3333}"); + result += _test_map > ("map_str_int_eval", "{'a': 1*11, 'b': 2*111, 'c': 3*1111}"); + result += _test_map > ("map_str_long", "{'a': 111, 'b': 222, 'c': 3333}"); + result += _test_map > ("map_str_long_eval", "{'a': 1*111, 'b': 2*111, 'c': 3*1111}"); + result += _test_map > ("map_str_float", "{'a': 1.11, 'b': 22.22, 'c': 333.33}"); + result += _test_map > ("map_str_float_eval", "{'a': '1.11*GeV','b':'22.22*MeV', 'c': '333.3*TeV'}"); + result += _test_map > ("map_str_double", "{'a': 1.11, 'b': 22.22, 'c': 333.33}"); + result += _test_map > ("map_str_double_eval", "{'a': '1.11*GeV','b':'22.22*MeV', 'c': '333.3*TeV'}"); + //result += _test_map > ("map_str_XYZPoint", "{['a', (1, 2, 3)]}");//, 'b': (10,20,30), 'c': (100,200,300)}"); + //result += _test_map > ("map_str_XYZVector", "{'a': (1, 2, 3), 'b': (10,20,30), 'c': (100,200,300)}"); + //result += _test_map > ("map_str_PxPyPzEVector", "{'a': (1, 2, 3, 4), 'b': (10,20,30,40), 'c': (100,200,300,400)}"); + line(); + result += _test_map > ("map_int_str", "{ 10: 'a', 200: 'bb', 3000: ' ccc'}"); + result += _test_map > ("map_int_bool", "{ 10: true, 200: false, 3000: true}"); + result += _test_map > ("map_int_int", "{ 10: 11, 200: 200, 3000: 3000}"); + result += _test_map > ("map_int_int_eval", "{ 10: 1*11, 200: 2*100, 3000: 3*1000}"); + result += _test_map > ("map_int_long", "{ 10: 111, 200: 222, 3000: 3333}"); + result += _test_map > ("map_int_long_eval", "{ 10: 1*111, 200: 2*111, 3000: 3*1111}"); + result += _test_map > ("map_int_float", "{ 10: 1.11, 200: 22.22, 3000: 333.33}"); + result += _test_map > ("map_int_float_eval", "{ 10: 1.11*GeV, 200: 22.22*MeV, 3000: 333.3*TeV}"); + result += _test_map > ("map_int_double", "{ 10: 1.11, 200: 22.22, 3000: 333.33}"); + result += _test_map > ("map_int_double_eval", "{ 10: 1.11*GeV, 200: 22.22*MeV, 3000: 333.3*TeV}"); + //result += _test_map > ("map_eval_int_str", "{ 1*10: 'a', 2*100: 'bb', 3*1000: 'ccc'}"); + result += _test_map > ("map_eval_int_double", "{ 1*10: 1.11, 2*100: 22.22, 3*1000: 333.33}"); + //result += _test_map > ("map_int_XYZPoint", "{ 10: (1, 2, 3), 200: (10,20,30), 3000: (100,200,300)}"); + //result += _test_map > ("map_int_XYZVector", "{ 10: (1, 2, 3), 200: (10,20,30), 3000: (100,200,300)}"); + //result += _test_map > ("map_int_PxPyPzEVector", "{ 10: (1, 2, 3, 4), 200: (10,20,30,40), 3000: (100,200,300,400)}"); #if defined(DD4HEP_HAVE_ALL_PARSERS) - cout << "+----------------------------------------------------------------------------------------------------------" << endl; - result += _test_map > ("map_float_str", "{ 10: 'a', 200: 'bb', 3000: 'ccc'}"); - result += _test_map > ("map_float_bool", "{ 10: true, 200: false, 3000: true}"); - result += _test_map > ("map_float_int", "{ 10: 11, 200: 200, 3000: 3000}"); - result += _test_map > ("map_float_int_eval", "{ 10: 1*11, 200: 2*100, 3000: 3*1000}"); - result += _test_map > ("map_float_float", "{ 10: 1.11, 200: 22.22, 3000: 333.33}"); - result += _test_map > ("map_float_float_eval", "{ 10: 1.11*GeV, 200: 22.22*MeV, 3000: 333.3*TeV}"); - result += _test_map > ("map_float_double", "{ 10: 1.11, 200: 22.22, 3000: 333.33}"); - result += _test_map > ("map_float_double_eval", "{ 10: 1.11*GeV, 200: 22.22*MeV, 3000: 333.3*TeV}"); + line(); + result += _test_map > ("map_float_str", "{ 10: 'a', 200: 'bb', 3000: 'ccc'}"); + result += _test_map > ("map_float_bool", "{ 10: true, 200: false, 3000: true}"); + result += _test_map > ("map_float_int", "{ 10: 11, 200: 200, 3000: 3000}"); + result += _test_map > ("map_float_int_eval", "{ 10: 1*11, 200: 2*100, 3000: 3*1000}"); + result += _test_map > ("map_float_float", "{ 10: 1.11, 200: 22.22, 3000: 333.33}"); + result += _test_map > ("map_float_float_eval", "{ 10: 1.11*GeV, 200: 22.22*MeV, 3000: 333.3*TeV}"); + result += _test_map > ("map_float_double", "{ 10: 1.11, 200: 22.22, 3000: 333.33}"); + result += _test_map > ("map_float_double_eval", "{ 10: 1.11*GeV, 200: 22.22*MeV, 3000: 333.3*TeV}"); #endif - cout << "+----------------------------------------------------------------------------------------------------------" << endl; - result += _test_cont > ("set_str", "{'a', 'bb', 'ccc'}"); - result += _test_cont > ("set_bool", "{true, false, true}"); - result += _test_cont > ("set_int", "{11, 222, 3333}"); - result += _test_cont > ("set_int_eval", "{1*11, 2*111, 3*1111}"); - result += _test_cont > ("set_int", "{11, 222, 3333}"); - result += _test_cont > ("set_long_eval", "{1*11, 2*111, 3*1111}"); - result += _test_cont > ("set_long", "{11, 222, 3333}"); - result += _test_cont > ("set_float", "{1.11, 22.22, 333.33}"); - result += _test_cont > ("set_float_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); - result += _test_cont > ("set_double", "{1.11, 22.22, 333.33}"); - result += _test_cont > ("set_double_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); - result += _test_cont > ("set_XYZPoint", "{(1, 2, 3), (10,20,30), (100,200,300)}"); - result += _test_cont > ("set_XYZPoint_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); - result += _test_cont > ("set_XYZVector", "{(1, 2, 3), (10,20,30), (100,200,300)}"); - result += _test_cont > ("set_XYZVector_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); - result += _test_cont > ("set_PxPyPzEVector", "{(1, 2, 3,4), (10,20,30,40), (100,200,300,400)}"); - result += _test_cont > ("set_PxPyPzEVector_eval", "{(1*m, 2*m, 3*m, 4*m), (10*m,20*m,30*m,40*m), (100*m,200*m,300*m,400*m)}"); - cout << "+----------------------------------------------------------------------------------------------------------" << endl; - result += _test_cont > ("vector_str", "{'a', 'bb', 'ccc'}"); - result += _test_cont > ("vector_bool", "{true, false, true}"); - result += _test_cont > ("vector_int", "{11, 222, 3333}"); - result += _test_cont > ("vector_int_eval", "{1*11, 2*111, 3*1111}"); - result += _test_cont > ("vector_long_eval", "{1*11, 2*111, 3*1111}"); - result += _test_cont > ("vector_long", "{11, 222, 3333}"); - result += _test_cont > ("vector_ulong_eval", "{1*11, 2*111, 3*1111}"); - result += _test_cont > ("vector_ulong", "{11, 222, 3333}"); - result += _test_cont > ("vector_float", "{1.11, 22.22, 333.33}"); - result += _test_cont > ("vector_float_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); - result += _test_cont > ("vector_double", "{1.11, 22.22, 333.33}"); - result += _test_cont > ("vector_double_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); - result += _test_cont > ("vector_XYZPoint", "{(1, 2, 3), (10,20,30), (100,200,300)}"); - result += _test_cont > ("vector_XYZPoint_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); - result += _test_cont > ("vector_XYZVector", "{(1, 2, 3), (10,20,30), (100,200,300)}"); - result += _test_cont > ("vector_XYZVector_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); - result += _test_cont > ("vector_PxPyPzEVector", "{(1, 2, 3,4), (10,20,30,40), (100,200,300,400)}"); - result += _test_cont > ("vector_PxPyPzEVector_eval","{(1*m, 2*m, 3*m, 4*m), (10*m,20*m,30*m,40*m), (100*m,200*m,300*m,400*m)}"); - cout << "+----------------------------------------------------------------------------------------------------------" << endl; - result += _test_cont > ("list_str", "{'a', 'bb', 'ccc'}"); - result += _test_cont > ("list_bool", "{true, false, true}"); - result += _test_cont > ("list_int", "{11, 222, 3333}"); - result += _test_cont > ("list_int_eval", "{1*11, 2*111, 3*1111}"); - result += _test_cont > ("list_long_eval", "{1*11, 2*111, 3*1111}"); - result += _test_cont > ("list_long", "{11, 222, 3333}"); - result += _test_cont > ("list_ulong_eval", "{1*11, 2*111, 3*1111}"); - result += _test_cont > ("list_ulong", "{11, 222, 3333}"); - result += _test_cont > ("list_float", "{1.11, 22.22, 333.33}"); - result += _test_cont > ("list_float_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); - result += _test_cont > ("list_double", "{1.11, 22.22, 333.33}"); - result += _test_cont > ("list_double_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); - result += _test_cont > ("list_XYZPoint", "{(1, 2, 3), (10,20,30), (100,200,300)}"); - result += _test_cont > ("list_XYZVector", "{(1, 2, 3), (10,20,30), (100,200,300)}"); - result += _test_cont > ("list_PxPyPzEVector", "{(1, 2, 3,4), (10,20,30,40), (100,200,300,400)}"); - result += _test_cont > ("list_XYZVector_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); - result += _test_cont > ("list_PxPyPzEVector", "{(1, 2, 3,4), (10,20,30,40), (100,200,300,400)}"); - result += _test_cont > ("list_PxPyPzEVector_eval", "{(1*m, 2*m, 3*m, 4*m), (10*m,20*m,30*m,40*m), (100*m,200*m,300*m,400*m)}"); - cout << "+----------------------------------------------------------------------------------------------------------" << endl; + line(); + result += _test_cont > ("set_str", "{'a', 'bb', 'ccc'}"); + result += _test_cont > ("set_bool", "{true, false, true}"); + result += _test_cont > ("set_int", "{11, 222, 3333}"); + result += _test_cont > ("set_int_eval", "{1*11, 2*111, 3*1111}"); + result += _test_cont > ("set_int", "{11, 222, 3333}"); + result += _test_cont > ("set_long_eval", "{1*11, 2*111, 3*1111}"); + result += _test_cont > ("set_long", "{11, 222, 3333}"); + result += _test_cont > ("set_float", "{1.11, 22.22, 333.33}"); + result += _test_cont > ("set_float_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); + result += _test_cont > ("set_double", "{1.11, 22.22, 333.33}"); + result += _test_cont > ("set_double_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); + result += _test_cont > ("set_XYZPoint", "{(1, 2, 3), (10,20,30), (100,200,300)}"); + result += _test_cont > ("set_XYZPoint_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); + result += _test_cont > ("set_XYZVector", "{(1, 2, 3), (10,20,30), (100,200,300)}"); + result += _test_cont > ("set_XYZVector_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); + result += _test_cont > ("set_PxPyPzEVector", "{(1, 2, 3,4), (10,20,30,40), (100,200,300,400)}"); + result += _test_cont > ("set_PxPyPzEVector_eval", "{(1*m, 2*m, 3*m, 4*m), (10*m,20*m,30*m,40*m), (100*m,200*m,300*m,400*m)}"); + line(); + result += _test_cont > ("vector_str", "{'a', 'bb', 'ccc'}"); + result += _test_cont > ("vector_bool", "{true, false, true}"); + result += _test_cont > ("vector_int", "{11, 222, 3333}"); + result += _test_cont > ("vector_int_eval", "{1*11, 2*111, 3*1111}"); + result += _test_cont > ("vector_long_eval", "{1*11, 2*111, 3*1111}"); + result += _test_cont > ("vector_long", "{11, 222, 3333}"); + result += _test_cont > ("vector_ulong_eval", "{1*11, 2*111, 3*1111}"); + result += _test_cont > ("vector_ulong", "{11, 222, 3333}"); + result += _test_cont > ("vector_float", "{1.11, 22.22, 333.33}"); + result += _test_cont > ("vector_float_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); + result += _test_cont > ("vector_double", "{1.11, 22.22, 333.33}"); + result += _test_cont > ("vector_double_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); + result += _test_cont > ("vector_XYZPoint", "{(1, 2, 3), (10,20,30), (100,200,300)}"); + result += _test_cont > ("vector_XYZPoint_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); + result += _test_cont > ("vector_XYZVector", "{(1, 2, 3), (10,20,30), (100,200,300)}"); + result += _test_cont > ("vector_XYZVector_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); + result += _test_cont > ("vector_PxPyPzEVector", "{(1, 2, 3,4), (10,20,30,40), (100,200,300,400)}"); + result += _test_cont > ("vector_PxPyPzEVector_eval","{(1*m, 2*m, 3*m, 4*m), (10*m,20*m,30*m,40*m), (100*m,200*m,300*m,400*m)}"); + line(); + result += _test_cont > ("list_str", "{'a', 'bb', 'ccc'}"); + result += _test_cont > ("list_bool", "{true, false, true}"); + result += _test_cont > ("list_int", "{11, 222, 3333}"); + result += _test_cont > ("list_int_eval", "{1*11, 2*111, 3*1111}"); + result += _test_cont > ("list_long_eval", "{1*11, 2*111, 3*1111}"); + result += _test_cont > ("list_long", "{11, 222, 3333}"); + result += _test_cont > ("list_ulong_eval", "{1*11, 2*111, 3*1111}"); + result += _test_cont > ("list_ulong", "{11, 222, 3333}"); + result += _test_cont > ("list_float", "{1.11, 22.22, 333.33}"); + result += _test_cont > ("list_float_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); + result += _test_cont > ("list_double", "{1.11, 22.22, 333.33}"); + result += _test_cont > ("list_double_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); + result += _test_cont > ("list_XYZPoint", "{(1, 2, 3), (10,20,30), (100,200,300)}"); + result += _test_cont > ("list_XYZVector", "{(1, 2, 3), (10,20,30), (100,200,300)}"); + result += _test_cont > ("list_PxPyPzEVector", "{(1, 2, 3,4), (10,20,30,40), (100,200,300,400)}"); + result += _test_cont > ("list_XYZVector_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); + result += _test_cont > ("list_PxPyPzEVector", "{(1, 2, 3,4), (10,20,30,40), (100,200,300,400)}"); + result += _test_cont > ("list_PxPyPzEVector_eval", "{(1*m, 2*m, 3*m, 4*m), (10*m,20*m,30*m,40*m), (100*m,200*m,300*m,400*m)}"); + line(); #if defined(DD4HEP_HAVE_ALL_PARSERS) - result += _test_cont > ("deque_str", "{'a', 'bb', 'ccc'}"); - result += _test_cont > ("deque_bool", "{true, false, true}"); - result += _test_cont > ("deque_int", "{11, 222, 3333}"); - result += _test_cont > ("deque_int_eval", "{1*11, 2*111, 3*1111}"); - result += _test_cont > ("deque_float", "{1.11, 22.22, 333.33}"); - result += _test_cont > ("deque_float_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); - result += _test_cont > ("deque_double", "{1.11, 22.22, 333.33}"); - result += _test_cont > ("deque_double_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); - cout << "+----------------------------------------------------------------------------------------------------------" << endl; + result += _test_cont > ("deque_str", "{'a', 'bb', 'ccc'}"); + result += _test_cont > ("deque_bool", "{true, false, true}"); + result += _test_cont > ("deque_int", "{11, 222, 3333}"); + result += _test_cont > ("deque_int_eval", "{1*11, 2*111, 3*1111}"); + result += _test_cont > ("deque_float", "{1.11, 22.22, 333.33}"); + result += _test_cont > ("deque_float_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); + result += _test_cont > ("deque_double", "{1.11, 22.22, 333.33}"); + result += _test_cont > ("deque_double_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); + line(); #endif if ( 0 == result ) - cout << endl << "Test PASSED" << endl << endl; + std::cout << std::endl << "Test PASSED" << std::endl << std::endl; else - cout << endl << "Test FAILED" << endl << "===> " << result << " Subtests FAILED" << endl; + std::cout << std::endl << "Test FAILED" << std::endl << "===> " << result << " Subtests FAILED" << std::endl; // All done. return 1; diff --git a/examples/ClientTests/src/SectorBarrelCalorimeter_geo.cpp b/examples/ClientTests/src/SectorBarrelCalorimeter_geo.cpp index b8d12d118..3fce24786 100644 --- a/examples/ClientTests/src/SectorBarrelCalorimeter_geo.cpp +++ b/examples/ClientTests/src/SectorBarrelCalorimeter_geo.cpp @@ -15,9 +15,7 @@ #include "XML/Layering.h" #include -using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; static void placeStaves(DetElement& parent, DetElement& stave, @@ -55,7 +53,7 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s Layering layering(x_det); //xml_comp_t staves = x_det.staves(); xml_dim_t dim = x_det.dimensions(); - string det_name = x_det.nameStr(); + std::string det_name = x_det.nameStr(); Material air = description.air(); double totalThickness = layering.totalThickness(); int numSides = dim.numsides(); @@ -108,9 +106,9 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s const Layer* lay = layering.layer(layer_num-1); // Get the layer from the layering engine. // Loop over repeats for this layer. for (int j = 0; j < repeat; j++) { - string layer_name = det_name+_toString(layer_num,"_layer%d"); - double layer_thickness = lay->thickness(); - DetElement layer(stave,_toString(layer_num,"layer%d"),x_det.id()); + std::string layer_name = det_name+_toString(layer_num,"_layer%d"); + double layer_thickness = lay->thickness(); + DetElement layer(stave,_toString(layer_num,"layer%d"),x_det.id()); // Layer position in Z within the stave. layer_pos_z += layer_thickness / 2; @@ -121,11 +119,11 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s double slice_pos_z = -(layer_thickness / 2); int slice_number = 1; for(xml_coll_t k(x_layer,_U(slice)); k; ++k) { - xml_comp_t x_slice = k; - string slice_name = layer_name + _toString(slice_number,"_slice%d"); - double slice_thickness = x_slice.thickness(); - Material slice_material = description.material(x_slice.materialStr()); - DetElement slice(layer,_toString(slice_number,"slice%d"),x_det.id()); + xml_comp_t x_slice = k; + std::string slice_name = layer_name + _toString(slice_number,"_slice%d"); + double slice_thickness = x_slice.thickness(); + Material slice_material = description.material(x_slice.materialStr()); + DetElement slice(layer,_toString(slice_number,"slice%d"),x_det.id()); slice_pos_z += slice_thickness / 2; // Slice volume & box @@ -159,7 +157,10 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s // Increment the layer X dimension. layer_pos_x = (layerR-rmin)/tan_external; layer_dim_x = (std::sqrt(rmax*rmax - layerR*layerR)+half_polyFace - layer_pos_x)/2.0; - cout<<"Rmin: "<< rmin<<" Rmax: "< void Converter::operator()(xml_h element) const #endif mix->AddElement(elt, 1.0); mix->SetRadLen(0e0); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,12,0) mix->ComputeDerivedQuantities(); -#endif /// Create medium from the material TGeoMedium* medium = mgr.GetMedium(matname); if (0 == medium) { @@ -516,9 +514,7 @@ template <> void Converter::operator()(xml_h element) const fracname.c_str()); } mix->SetRadLen(0e0); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,12,0) mix->ComputeDerivedQuantities(); -#endif printout(_ns.context->debug.materials ? ALWAYS : DEBUG, "DDCMS", "++ Converting material %-48s Density: %8.3f [g/cm3] ROOT: %8.3f [g/cm3]", ('"'+nam+'"').c_str(), density, mix->GetDensity()); diff --git a/examples/LHeD/scripts/initAClick.C b/examples/LHeD/scripts/initAClick.C index dc1614a3f..1d9cb41d5 100644 --- a/examples/LHeD/scripts/initAClick.C +++ b/examples/LHeD/scripts/initAClick.C @@ -32,13 +32,9 @@ std::string make_str(const char* data) { int processCommand(const char* command, bool end_process) { int status; // Disabling auto-parse is a hack required by a bug in ROOT -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0) gInterpreter->SetClassAutoparsing(false); status = gInterpreter->ProcessLine(command); gInterpreter->SetClassAutoparsing(true); -#else - status = gInterpreter->ProcessLine(command); -#endif ::printf("+++ Status(%s) = %d\n",command,status); if ( end_process ) { gInterpreter->ProcessLine("gSystem->Exit(0)"); diff --git a/examples/OpticalSurfaces/src/OpNovice_geo.cpp b/examples/OpticalSurfaces/src/OpNovice_geo.cpp index c4221a7a9..6ff2738dc 100644 --- a/examples/OpticalSurfaces/src/OpNovice_geo.cpp +++ b/examples/OpticalSurfaces/src/OpNovice_geo.cpp @@ -12,33 +12,33 @@ //========================================================================== // Include files -#include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/OpticalSurfaces.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Detector.h" +#include +#include +#include +#include +// C/C++ include files #include #include -using namespace std; using namespace dd4hep; using namespace dd4hep::detail; /// Example of a water box with a box of air inside, the "bubble" static Ref_t create_detector(Detector &description, xml_h e, SensitiveDetector /* sens */) { - xml_det_t x_det = e; - string det_name = x_det.nameStr(); - DetElement sdet(det_name,x_det.id()); - xml_det_t x_tank = x_det.child(_Unicode(tank)); - xml_det_t x_bubble = x_det.child(_Unicode(bubble)); + xml_det_t x_det = e; + std::string det_name = x_det.nameStr(); + DetElement sdet(det_name,x_det.id()); + xml_det_t x_tank = x_det.child(_Unicode(tank)); + xml_det_t x_bubble = x_det.child(_Unicode(bubble)); Assembly hall_vol("Hall"); Box encl_box(_toDouble("world_x-2*cm"),_toDouble("world_y-2*cm"),_toDouble("world_z-2*cm")); Volume encl_vol("Enclosure",encl_box,description.air()); Box tank_box(x_tank.x(), x_tank.y(), x_tank.z()); - Volume tank_vol("Tank",tank_box,description.material(x_tank.attr(_U(material)))); + Volume tank_vol("Tank",tank_box,description.material(x_tank.attr(_U(material)))); Box bubble_box(x_bubble.x(), x_bubble.y(), x_bubble.z()); - Volume bubble_vol("Bubble",bubble_box,description.material(x_bubble.attr(_U(material)))); + Volume bubble_vol("Bubble",bubble_box,description.material(x_bubble.attr(_U(material)))); encl_vol.setVisAttributes(description.invisible()); tank_vol.setVisAttributes(description, x_tank.visStr()); @@ -53,7 +53,6 @@ static Ref_t create_detector(Detector &description, xml_h e, SensitiveDetector / hallPlace.addPhysVolID("system",x_det.id()); sdet.setPlacement(hallPlace); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) // Now attach the surface OpticalSurfaceManager surfMgr = description.surfaceManager(); OpticalSurface waterSurf = surfMgr.opticalSurface("/world/"+det_name+"#WaterSurface"); @@ -62,9 +61,6 @@ static Ref_t create_detector(Detector &description, xml_h e, SensitiveDetector / BorderSurface bubbleSurf = BorderSurface(description, sdet, "TankBubble", airSurf, bubblePlace, tankPlace); bubbleSurf.isValid(); tankSurf.isValid(); -#else - bubblePlace.isValid(); -#endif return sdet; } DECLARE_DETELEMENT(DD4hep_OpNovice,create_detector) From 5e9905056822dbd4c9c337e523d4c1d25549264e Mon Sep 17 00:00:00 2001 From: Markus Frank Date: Thu, 8 Feb 2024 12:27:21 +0100 Subject: [PATCH 07/14] Remove support for very old versions of ROOT < 6.26.0. Remove default use of std namespace from some implementation files. --- DDCore/src/plugins/Compact2Objects.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp index 1eb0ca12d..f50741929 100644 --- a/DDCore/src/plugins/Compact2Objects.cpp +++ b/DDCore/src/plugins/Compact2Objects.cpp @@ -793,7 +793,8 @@ template <> void Converter::operator()(xml_h element) const { description.manager().AddGDMLMatrix(table); } #if ROOT_VERSION_CODE >= ROOT_VERSION(6,31,1) - /// In case there were constant surface properties specified: convert them here + // + // In case there were constant surface properties specified: convert them here for(xml_coll_t properties(e, _U(constant)); properties; ++properties) { xml_elt_t p = properties; pname = p.attr(_U(name)); @@ -830,6 +831,7 @@ template <> void Converter::operator()(xml_h element) const { surf->GetName(), pname.c_str(), ptyp.c_str()); } } +#endif } /** Convert compact constant property (Material properties stored in TGeoManager) From be158a45d0965c67289553e722a78c23a2534346 Mon Sep 17 00:00:00 2001 From: Markus Frank Date: Thu, 8 Feb 2024 12:39:59 +0100 Subject: [PATCH 08/14] Remove support for very old versions of ROOT < 6.26.0. Remove default use of std namespace from some implementation files. --- DDCore/src/plugins/Compact2Objects.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp index f50741929..5aa543117 100644 --- a/DDCore/src/plugins/Compact2Objects.cpp +++ b/DDCore/src/plugins/Compact2Objects.cpp @@ -831,7 +831,6 @@ template <> void Converter::operator()(xml_h element) const { surf->GetName(), pname.c_str(), ptyp.c_str()); } } -#endif } /** Convert compact constant property (Material properties stored in TGeoManager) From 43aa0cf78519c14a31c0a9cdf8528d40547f9f51 Mon Sep 17 00:00:00 2001 From: Markus Frank Date: Thu, 8 Feb 2024 12:52:01 +0100 Subject: [PATCH 09/14] Remove support for very old versions of ROOT < 6.26.0. Remove default use of std namespace from some implementation files. --- DDCore/src/plugins/Compact2Objects.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp index 5aa543117..8290733a0 100644 --- a/DDCore/src/plugins/Compact2Objects.cpp +++ b/DDCore/src/plugins/Compact2Objects.cpp @@ -831,6 +831,7 @@ template <> void Converter::operator()(xml_h element) const { surf->GetName(), pname.c_str(), ptyp.c_str()); } } +#endif } /** Convert compact constant property (Material properties stored in TGeoManager) @@ -896,7 +897,6 @@ template <> void Converter::operator()(xml_h e) const { tab->Set(i/cols, i%cols, vals[i]); //if ( s_debug.matrix ) tab->Print(); } -#endif /** Convert compact visualization attribute to Detector visualization attribute. * From e8cba558d758ad2a931ab1ff3335e2f1bf2381d5 Mon Sep 17 00:00:00 2001 From: Markus Frank Date: Thu, 8 Feb 2024 14:50:05 +0100 Subject: [PATCH 10/14] Set default extension to top level placement (TGeoManager::GetTopVolume()) --- DDCore/src/DetectorImp.cpp | 7 + DDCore/src/plugins/StandardPlugins.cpp | 230 ++++++++++++------------- 2 files changed, 122 insertions(+), 115 deletions(-) diff --git a/DDCore/src/DetectorImp.cpp b/DDCore/src/DetectorImp.cpp index 9f77b5b24..c5a8e5b95 100644 --- a/DDCore/src/DetectorImp.cpp +++ b/DDCore/src/DetectorImp.cpp @@ -730,6 +730,13 @@ void DetectorImp::endDocument(bool close_geometry) { // Since we allow now for anonymous shapes, // we will rename them to use the name of the volume they are assigned to mgr->CloseGeometry(); + PlacedVolume pv = mgr->GetTopNode(); + auto* extension = pv->GetUserExtension(); + if ( nullptr == extension ) { + extension = new PlacedVolume::Object(); + pv->SetUserExtension(extension); + } + m_world.setPlacement(pv); } // Patching shape names of anaonymous shapes ShapePatcher patcher(m_volManager, m_world); diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp index bdd409aa3..c39a628e7 100644 --- a/DDCore/src/plugins/StandardPlugins.cpp +++ b/DDCore/src/plugins/StandardPlugins.cpp @@ -133,7 +133,7 @@ static long display(Detector& description, int argc, char** argv) { else { std::cout << "Usage: -plugin DD4hep_GeometryDisplay -arg [-arg] \n\n" - " Invoke the ROOT geometry display using the factory mechanism. \n\n" + " Invoke the ROOT geometry display using the factory mechanism. \n\n" " -detector Top level DetElement path. Default: '/world' \n" " -option ROOT Draw option. Default: 'ogl' \n" " -level Visualization level [TGeoManager::SetVisLevel] Default: 4 \n" @@ -253,9 +253,9 @@ DECLARE_APPLY(DD4hep_Rint,run_interpreter) static long root_ui(Detector& description, int /* argc */, char** /* argv */) { char cmd[256]; std::snprintf(cmd, sizeof(cmd), - "dd4hep::detail::DD4hepUI* gDD4hepUI = new " - "dd4hep::detail::DD4hepUI(*(dd4hep::Detector*)%p);", - (void*)&description); + "dd4hep::detail::DD4hepUI* gDD4hepUI = new " + "dd4hep::detail::DD4hepUI(*(dd4hep::Detector*)%p);", + (void*)&description); gInterpreter->ProcessLine(cmd); printout(ALWAYS,"DD4hepUI", "Use the ROOT interpreter variable gDD4hepUI " @@ -459,21 +459,21 @@ static long root_elements(Detector& description, int argc, char** argv) { xml::DocumentHandler docH; xml::Element element(0); if ( type == "xml" ) { - const char comment[] = "\n" - " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" - " ++++ Generic detector description in C++ ++++\n" - " ++++ dd4hep Detector description generator. ++++\n" - " ++++ ++++\n" - " ++++ Parser:" - XML_IMPLEMENTATION_TYPE - " ++++\n" - " ++++ ++++\n" - " ++++ Table of elements as defined in ROOT: " ROOT_RELEASE " ++++\n" - " ++++ ++++\n" - " ++++ M.Frank CERN/LHCb ++++\n" - " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n "; - doc = docH.create("materials", comment); - element = doc.root(); + const char comment[] = "\n" + " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" + " ++++ Generic detector description in C++ ++++\n" + " ++++ dd4hep Detector description generator. ++++\n" + " ++++ ++++\n" + " ++++ Parser:" + XML_IMPLEMENTATION_TYPE + " ++++\n" + " ++++ ++++\n" + " ++++ Table of elements as defined in ROOT: " ROOT_RELEASE " ++++\n" + " ++++ ++++\n" + " ++++ M.Frank CERN/LHCb ++++\n" + " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n "; + doc = docH.create("materials", comment); + element = doc.root(); } dd4hep_ptr printer(element ? new ElementPrintXML(element) @@ -814,11 +814,11 @@ static long load_volmgr(Detector& description, int, char**) { } catch (const std::exception& e) { except("DD4hep_VolumeManager", "Exception: %s\n %s", e.what(), - "dd4hep: while programming VolumeManager. Are your volIDs correct?"); + "dd4hep: while programming VolumeManager. Are your volIDs correct?"); } catch (...) { except("DD4hep_VolumeManager", - "UNKNOWN exception while programming VolumeManager. Are your volIDs correct?"); + "UNKNOWN exception while programming VolumeManager. Are your volIDs correct?"); } return 0; } @@ -843,7 +843,7 @@ static long dump_geometry2root(Detector& description, int argc, char** argv) { if ( output.empty() ) { std::cout << "Usage: -plugin DD4hep_Geometry2ROOT -arg [-arg] \n\n" - " Output DD4hep detector description object to a ROOT file. \n\n" + " Output DD4hep detector description object to a ROOT file. \n\n" " -output Output file name. \n" "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush; ::exit(EINVAL); @@ -877,7 +877,7 @@ static long load_geometryFromroot(Detector& description, int argc, char** argv) if ( input.empty() ) { std::cout << "Usage: DD4hep_RootLoader -arg [-arg] \n\n" - " Load DD4hep detector description from ROOT file to memory. \n\n" + " Load DD4hep detector description from ROOT file to memory. \n\n" " -input Input file name. \n" "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush; ::exit(EINVAL); @@ -911,7 +911,7 @@ static long dump_geometry2tgeo(Detector& description, int argc, char** argv) { if ( output.empty() ) { std::cout << "Usage: -plugin -arg [-arg] \n" - " Output TGeo information to a ROOT file. \n\n" + " Output TGeo information to a ROOT file. \n\n" " name: factory name DD4hepGeometry2TGeo \n" " -output Output file name. \n" "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush; @@ -1096,7 +1096,7 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { " -sensitive Only print information for sensitive volumes \n" " -topstats Print statistics about top level node \n" "\tArguments given: " << arguments(ac,av) << std::endl << std::flush; - _exit(0); + _exit(0); } } if ( m_printMaxLevel < 999999 ) @@ -1190,42 +1190,42 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { } } opt_info = log.str(); - log.str(""); + log.str(""); } /// if ( m_printVis && pv.volume().visAttributes().isValid() ) { log << " Vis:" << pv.volume().visAttributes().name(); - opt_info += log.str(); - log.str(""); + opt_info += log.str(); + log.str(""); } TGeoVolume* volume = ideal ? ideal->GetVolume() : 0; if ( !m_printSensitivesOnly || (m_printSensitivesOnly && sensitive) ) { - Volume vol = pv.volume(); + Volume vol = pv.volume(); char sens = vol.isSensitive() ? 'S' : ' '; if ( m_printPointers ) { if ( ideal == aligned ) { std::snprintf(fmt,sizeof(fmt),"%03d %%s [Ideal:%p] %%-%ds %%-16s Vol:%%s shape:%%s \t %c %%s", - level+1,(void*)ideal,2*level+1,sens); + level+1,(void*)ideal,2*level+1,sens); } else { std::snprintf(fmt,sizeof(fmt),"%03d %%s Ideal:%p Aligned:%p %%-%ds %%-16s Vol:%%s shape:%%s %c %%s", - level+1,(void*)ideal,(void*)aligned,2*level+1,sens); + level+1,(void*)ideal,(void*)aligned,2*level+1,sens); } } else { if ( ideal == aligned ) { std::snprintf(fmt,sizeof(fmt),"%03d %%s %%-%ds %%-16s Vol:%%s shape:%%s \t %c %%s", - level+1,2*level+1,sens); + level+1,2*level+1,sens); } else { std::snprintf(fmt,sizeof(fmt),"%03d %%s Ideal:%p Aligned:%p %%-%ds %%-16s Vol:%%s shape:%%s %c %%s", - level+1,(void*)ideal,(void*)aligned,2*level+1,sens); + level+1,(void*)ideal,(void*)aligned,2*level+1,sens); } } - const auto* sh = volume ? volume->GetShape() : nullptr; + const auto* sh = volume ? volume->GetShape() : nullptr; printout(INFO,"VolumeDump",fmt,pref.c_str(),"", aligned->GetName(), - vol.name(), + vol.name(), sh ? sh->IsA()->GetName() : "[Invalid Shape]", opt_info.c_str()); if ( sens == 'S' ) ++m_numSensitive; @@ -1236,7 +1236,7 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { TGeoMaterial* mptr = mat->GetMaterial(); bool ok = mat.A() == mptr->GetA() && mat.Z() == mptr->GetZ(); std::snprintf(fmt,sizeof(fmt),"%03d %%s %%-%ds Material: %%-16s A:%%6.2f %%6.2f Z:%%6.2f %%6.2f", - level+1,2*level+1); + level+1,2*level+1); ++m_numMaterial; if ( !ok ) ++m_numMaterialERR; printout(ok ? INFO : ERROR, "VolumeDump", fmt, @@ -1393,12 +1393,12 @@ static int placed_volume_processor(Detector& description, int argc, char** argv) return PlacedVolumeScanner().scanPlacements(*proc, pv, 0, recursive) > 0 ? 1 : 0; } except("PlacedVolumeProcessor", - "++ The detector element with path:%s has no valid placement!", - path.c_str()); + "++ The detector element with path:%s has no valid placement!", + path.c_str()); } except("PlacedVolumeProcessor", - "++ The detector element path:%s is not part of this description!", - path.c_str()); + "++ The detector element path:%s is not part of this description!", + path.c_str()); return 0; } DECLARE_APPLY(DD4hep_PlacedVolumeProcessor,placed_volume_processor) @@ -1437,64 +1437,64 @@ template long dump_detelement_tree(Detector& description, int argc, c } void parse_args(int ac, char** av) { for(int i=0; i Process elements only if is part of the DetElement path.\n" - " -detector dto. \n" - " -level Maximal depth to be explored by the scan \n" - " --level dto. \n" - " -volids Print volume identifiers of placements. \n" - " --volids dto. \n" - "\tArguments given: " << arguments(ac,av) << std::endl << std::flush; - ::exit(EINVAL); - } + if ( ::strncmp(av[i],"--sensitive", 5)==0 ) { sensitive_only = true; } + else if ( ::strncmp(av[i], "-sensitive", 5)==0 ) { sensitive_only = true; } + else if ( ::strncmp(av[i], "--no-sensitive", 8)==0 ) { sensitive_only = false; } + else if ( ::strncmp(av[i], "-materials", 4)==0 ) { dump_materials = true; } + else if ( ::strncmp(av[i], "--materials", 5)==0 ) { dump_materials = true; } + else if ( ::strncmp(av[i], "-shapes", 4)==0 ) { dump_shapes = true; } + else if ( ::strncmp(av[i], "--shapes", 5)==0 ) { dump_shapes = true; } + else if ( ::strncmp(av[i], "-positions", 4)==0 ) { dump_positions = true; } + else if ( ::strncmp(av[i], "--positions", 5)==0 ) { dump_positions = true; } + else if ( ::strncmp(av[i], "-no-sensitive", 7)==0 ) { sensitive_only = false; } + else if ( ::strncmp(av[i], "--volids", 5)==0 ) { dump_volids = true; } + else if ( ::strncmp(av[i], "-volids", 5)==0 ) { dump_volids = true; } + else if ( ::strncmp(av[i], "--detector", 5)==0 ) { path = av[++i]; } + else if ( ::strncmp(av[i], "-detector", 5)==0 ) { path = av[++i]; } + else if ( ::strncmp(av[i], "--level", 5)==0 ) { analysis_level = ::atol(av[++i]); } + else if ( ::strncmp(av[i], "-level", 5)==0 ) { analysis_level = ::atol(av[++i]); } + else { + std::cout << " " + << (flag==0 ? "DD4hep_DetectorDump" : "DD4hep_DetectorVolumeDump") << " -arg [-arg] \n\n" + << " Dump " << (flag==0 ? "DetElement" : "Detector volume") << " tree. \n" + << " Configure produced output information using the following options: \n\n" + " --sensitive Process only sensitive volumes. \n" + " -sensitive dto. \n" + " --no-sensitive Invert sensitive only flag. \n" + " -no-sensitive dto. \n" + " --shapes Print shape information. \n" + " -shapes dto. \n" + " --positions Print position information. \n" + " -positions dto. \n" + " --materials Print material information. \n" + " -materials dto. \n" + " --detector Process elements only if is part of the DetElement path.\n" + " -detector dto. \n" + " -level Maximal depth to be explored by the scan \n" + " --level dto. \n" + " -volids Print volume identifiers of placements. \n" + " --volids dto. \n" + "\tArguments given: " << arguments(ac,av) << std::endl << std::flush; + ::exit(EINVAL); + } } } IDDescriptor get_id_descriptor(PlacedVolume pv) { Volume v = pv.volume(); SensitiveDetector sd = v.sensitiveDetector(); if ( sd.isValid() ) { - IDDescriptor dsc = sd.readout().idSpec(); - if ( dsc.isValid() ) return dsc; + IDDescriptor dsc = sd.readout().idSpec(); + if ( dsc.isValid() ) return dsc; } for (Int_t idau = 0, ndau = v->GetNdaughters(); idau < ndau; ++idau) { - IDDescriptor dsc = get_id_descriptor(v->GetNode(idau)); - if ( dsc.isValid() ) return dsc; + IDDescriptor dsc = get_id_descriptor(v->GetNode(idau)); + if ( dsc.isValid() ) return dsc; } return IDDescriptor(); } void validate_id_descriptor(DetElement de, IDDescriptor& desc) { desc = (!de.parent() || de.parent() == det_world) - ? IDDescriptor() : get_id_descriptor(de.placement()); + ? IDDescriptor() : get_id_descriptor(de.placement()); } long dump(DetElement de, int level, IDDescriptor& id_desc, VolIDs chain) { @@ -1503,11 +1503,11 @@ template long dump_detelement_tree(Detector& description, int argc, c bool use_elt = path.empty() || de.path().find(path) != std::string::npos; if ( have_match < 0 && use_elt ) { - have_match = level; + have_match = level; } use_elt = use_elt && ((level-have_match) <= analysis_level); if ( de != det_world ) { - chain.insert(chain.end(), place.volIDs().begin(), place.volIDs().end()); + chain.insert(chain.end(), place.volIDs().begin(), place.volIDs().end()); } if ( use_elt ) { if ( !sensitive_only || 0 != de.volumeID() ) { @@ -1523,7 +1523,7 @@ template long dump_detelement_tree(Detector& description, int argc, c break; } std::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%s NumDau:%%d VolID:%%08X Place:%%p [ideal:%%p aligned:%%p] %%c", - level+1,2*level+1); + level+1,2*level+1); printout(INFO,"DetectorDump",fmt,"",de.path().c_str(),int(children.size()), (unsigned long)de.volumeID(), (void*)de.idealPlacement().ptr(), (void*)place.ptr(), sens); @@ -1531,19 +1531,19 @@ template long dump_detelement_tree(Detector& description, int argc, c case 1: ++count; std::snprintf(fmt,sizeof(fmt), - "%03d %%-%ds Detector: %%s NumDau:%%d VolID:%%p", - level+1,2*level+1); + "%03d %%-%ds Detector: %%s NumDau:%%d VolID:%%p", + level+1,2*level+1); printout(INFO,"DetectorDump", fmt, "", de.path().c_str(), int(children.size()), (void*)de.volumeID()); if ( de.placement() == de.idealPlacement() ) { std::snprintf(fmt,sizeof(fmt), - "%03d %%-%ds Placement: %%s %%c", - level+1,2*level+3); + "%03d %%-%ds Placement: %%s %%c", + level+1,2*level+3); printout(INFO,"DetectorDump",fmt,"", de.placementPath().c_str(), sens); break; } std::snprintf(fmt,sizeof(fmt), - "%03d %%-%ds Placement: %%s [ideal:%%p aligned:%%p] %%c", - level+1,2*level+3); + "%03d %%-%ds Placement: %%s [ideal:%%p aligned:%%p] %%c", + level+1,2*level+3); printout(INFO,"DetectorDump",fmt,"", de.placementPath().c_str(), (void*)de.idealPlacement().ptr(), (void*)place.ptr(), sens); break; @@ -1569,24 +1569,24 @@ template long dump_detelement_tree(Detector& description, int argc, c std::snprintf(fmt,sizeof(fmt), "%03d %%-%ds Position: (%%9.4f,%%9.4f,%%9.4f) [cm] w/r to world", level+1,2*level+3); printout(INFO,"DetectorDump",fmt,"", world[0], world[1], world[2]); } - if ( dump_volids && !place.volIDs().empty() ) { - std::stringstream log; - log << " VID:"; - for( const auto& i : chain ) - log << " " << i.first << ':' << std::dec << std::setw(2) << i.second; - if ( id_desc.isValid() ) { - log << " (encoded:0x" << std::setfill('0') << std::setw(8) << std::hex - << id_desc.encode(chain) - << std::setfill(' ') << std::dec << ") "; - } - std::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%s", level+1, 2*level+1); + if ( dump_volids && !place.volIDs().empty() ) { + std::stringstream log; + log << " VID:"; + for( const auto& i : chain ) + log << " " << i.first << ':' << std::dec << std::setw(2) << i.second; + if ( id_desc.isValid() ) { + log << " (encoded:0x" << std::setfill('0') << std::setw(8) << std::hex + << id_desc.encode(chain) + << std::setfill(' ') << std::dec << ") "; + } + std::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%s", level+1, 2*level+1); printout(INFO,"DetectorDump", fmt, "", log.str().c_str()); - } + } } } for ( const auto& c : children ) { - validate_id_descriptor(c.second, id_desc); - dump(c.second, level+1, id_desc, chain); + validate_id_descriptor(c.second, id_desc); + dump(c.second, level+1, id_desc, chain); } return 1; } @@ -1628,12 +1628,12 @@ static long detelement_cache(Detector& description, int argc, char** argv) { detector = argv[++i]; else { std::cout << - "Usage: -plugin DD4hep_DetElementCache -arg [-arg] \n\n" - " Fill cache with transformation information in DetElements. \n\n" - " -detector Top level DetElement path. Default: '/world'\n" - " --detector dto. \n" - " -help Print this help. \n" - " Arguments given: " << arguments(argc,argv) << std::endl << std::flush; + "Usage: -plugin DD4hep_DetElementCache -arg [-arg] \n\n" + " Fill cache with transformation information in DetElements. \n\n" + " -detector Top level DetElement path. Default: '/world'\n" + " --detector dto. \n" + " -help Print this help. \n" + " Arguments given: " << arguments(argc,argv) << std::endl << std::flush; ::exit(EINVAL); } } @@ -1682,7 +1682,7 @@ static long detectortype_cache(Detector& description, int argc, char** argv) { else { std::cout << "Usage: DD4hep_DetectorTypes -type -arg [-arg] \n" - " Dump detector types from detector description. \n\n" + " Dump detector types from detector description. \n\n" " -type Add new type to be listed. Multiple possible. \n" "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush; ::exit(EINVAL); From a610934b94287c8fdb6becd5228cfc5409d3fbc0 Mon Sep 17 00:00:00 2001 From: Markus Frank Date: Thu, 8 Feb 2024 18:57:14 +0100 Subject: [PATCH 11/14] Suppress default use of std namespace --- DDCore/src/DetElement.cpp | 101 +++++----- DDCore/src/DetectorData.cpp | 49 +++-- DDCore/src/DetectorHelper.cpp | 11 +- DDCore/src/DetectorInterna.cpp | 44 ++-- DDCore/src/DetectorLoad.cpp | 77 ++++--- DDCore/src/DetectorProcessor.cpp | 6 +- DDCore/src/DetectorSelector.cpp | 28 ++- DDCore/src/DetectorTools.cpp | 104 +++++----- DDCore/src/Errors.cpp | 2 +- DDCore/src/Exceptions.cpp | 13 +- DDCore/src/ExtensionEntry.cpp | 4 +- DDCore/src/FieldTypes.cpp | 7 +- DDCore/src/Fields.cpp | 17 +- DDCore/src/Filter.cpp | 79 +++++--- DDCore/src/GeoDictionary.h | 8 +- DDCore/src/GeoHandler.cpp | 69 ++++--- DDCore/src/GeometryTreeDump.cpp | 159 +++++++-------- DDCore/src/GeometryTreeDump.h | 8 +- DDCore/src/GlobalAlignment.cpp | 27 +-- DDCore/src/Grammar.cpp | 14 +- DDCore/src/GrammarTypes.cpp | 6 +- DDCore/src/GrammarTypesUnparsed.cpp | 2 +- DDCore/src/Handle.cpp | 1 - DDCore/src/IDDescriptor.cpp | 62 +++--- DDCore/src/IOV.cpp | 15 +- DDCore/src/InstanceCount.cpp | 20 +- DDCore/src/MatrixHelpers.cpp | 6 +- DDCore/src/MultiSegmentation.cpp | 13 +- DDCore/src/NamedObject.cpp | 15 +- DDCore/src/NoSegmentation.cpp | 11 +- DDCore/src/ObjectExtensions.cpp | 20 +- DDCore/src/ObjectsInterna.cpp | 5 +- DDCore/src/OpaqueData.cpp | 37 ++-- DDCore/src/OpaqueDataBinder.cpp | 181 +++++++++-------- DDCore/src/OpticalSurfaceManagerInterna.cpp | 5 +- DDCore/src/PluginTester.cpp | 8 +- DDCore/src/Plugins.cpp | 21 +- DDCore/src/PolarGridRPhi.cpp | 11 +- DDCore/src/PolarGridRPhi2.cpp | 15 +- DDCore/src/Primitives.cpp | 6 +- DDCore/src/Printout.cpp | 3 +- DDCore/src/PropertyDictionary.h | 2 +- DDCore/src/Readout.cpp | 44 ++-- DDCore/src/RootDictionary.h | 46 ++--- DDCore/src/SegmentationDictionary.h | 48 ++--- DDCore/src/Segmentations.cpp | 54 +++-- DDCore/src/SegmentationsInterna.cpp | 17 +- DDCore/src/ShapeUtilities.cpp | 14 +- DDCore/src/ShapesInterna.cpp | 5 +- DDCore/src/SpecParRegistry.cpp | 37 +++- DDCore/src/SurfaceInstaller.cpp | 45 ++--- DDCore/src/VolumeManager.cpp | 129 ++++++------ DDCore/src/VolumeProcessor.cpp | 4 +- DDCore/src/Volumes.cpp | 130 ++++++------ DDCore/src/WaferGridXY.cpp | 13 +- DDCore/src/World.cpp | 4 +- DDCore/src/plugins/CodeGenerator.cpp | 210 ++++++++++---------- DDCore/src/plugins/DetElementConfig.cpp | 3 +- DDCore/src/plugins/DetElementVolumeIDs.cpp | 156 +++++++-------- DDCore/src/plugins/DetectorCheck.cpp | 118 ++++++----- DDCore/src/plugins/DetectorChecksum.cpp | 4 +- DDCore/src/plugins/DetectorFields.cpp | 10 +- DDCore/src/plugins/DetectorHelperTest.cpp | 11 +- DDCore/src/plugins/Geant4XML.cpp | 9 +- DDCore/src/plugins/GeometryWalk.cpp | 50 +++-- DDCore/src/plugins/JsonProcessor.cpp | 32 ++- DDCore/src/plugins/LCDD2Output.cpp | 39 ++-- DDCore/src/plugins/LCDDConverter.cpp | 200 ++++++++++--------- DDCore/src/plugins/PluginInvoker.cpp | 41 ++-- DDCore/src/plugins/ReadoutSegmentations.cpp | 42 ++-- DDCore/src/plugins/StandardPlugins.cpp | 6 +- DDCore/src/plugins/VisDensityProcessor.cpp | 20 +- DDCore/src/plugins/VisProcessor.cpp | 31 +-- 73 files changed, 1434 insertions(+), 1430 deletions(-) diff --git a/DDCore/src/DetElement.cpp b/DDCore/src/DetElement.cpp index 3310c1896..6f0dce1b1 100644 --- a/DDCore/src/DetElement.cpp +++ b/DDCore/src/DetElement.cpp @@ -12,21 +12,19 @@ //========================================================================== // Framework include files -#include "DD4hep/detail/DetectorInterna.h" -#include "DD4hep/detail/ConditionsInterna.h" -#include "DD4hep/detail/AlignmentsInterna.h" -#include "DD4hep/AlignmentTools.h" -#include "DD4hep/DetectorTools.h" -#include "DD4hep/Printout.h" -#include "DD4hep/World.h" -#include "DD4hep/Detector.h" - -using namespace std; +#include +#include +#include +#include +#include +#include +#include +#include + using namespace dd4hep; -using dd4hep::Alignment; namespace { - static string s_empty_string; + static std::string s_empty_string; } /// Default constructor @@ -38,26 +36,26 @@ DetElement::Processor::~Processor() { } /// Clone constructor -DetElement::DetElement(Object* det_data, const string& det_name, const string& det_type) +DetElement::DetElement(Object* det_data, const std::string& det_name, const std::string& det_type) : Handle(det_data) { this->assign(det_data, det_name, det_type); } /// Constructor for a new subdetector element -DetElement::DetElement(const string& det_name, const string& det_type, int det_id) { +DetElement::DetElement(const std::string& det_name, const std::string& det_type, int det_id) { assign(new Object(det_name,det_id), det_name, det_type); ptr()->id = det_id; } /// Constructor for a new subdetector element -DetElement::DetElement(const string& det_name, int det_id) { +DetElement::DetElement(const std::string& det_name, int det_id) { assign(new Object(det_name,det_id), det_name, ""); ptr()->id = det_id; } /// Constructor for a new subdetector element -DetElement::DetElement(DetElement det_parent, const string& det_name, int det_id) { +DetElement::DetElement(DetElement det_parent, const std::string& det_name, int det_id) { assign(new Object(det_name,det_id), det_name, det_parent.type()); ptr()->id = det_id; det_parent.add(*this); @@ -84,7 +82,7 @@ void DetElement::removeAtUpdate(unsigned int typ, void* pointer) const { } /// Access to the full path to the placed object -const string& DetElement::placementPath() const { +const std::string& DetElement::placementPath() const { Object* o = ptr(); if ( o ) { if (o->placementPath.empty()) { @@ -96,12 +94,12 @@ const string& DetElement::placementPath() const { } /// Access detector type (structure, tracker, calorimeter, etc.). -string DetElement::type() const { +std::string DetElement::type() const { return m_element ? m_element->GetTitle() : ""; } /// Set the type of the sensitive detector -DetElement& DetElement::setType(const string& typ) { +DetElement& DetElement::setType(const std::string& typ) { access()->SetTitle(typ.c_str()); return *this; } @@ -156,7 +154,7 @@ int DetElement::level() const { } /// Access the full path of the detector element -const string& DetElement::path() const { +const std::string& DetElement::path() const { Object* o = ptr(); if ( o ) { if ( !o->path.empty() ) @@ -210,28 +208,28 @@ const DetElement::Children& DetElement::children() const { } /// Access to individual children by name -DetElement DetElement::child(const string& child_name) const { +DetElement DetElement::child(const std::string& child_name) const { if (isValid()) { const Children& c = ptr()->children; Children::const_iterator i = c.find(child_name); if ( i != c.end() ) return (*i).second; - throw runtime_error("dd4hep: DetElement::child Unknown child with name: "+child_name); + throw std::runtime_error("dd4hep: DetElement::child Unknown child with name: "+child_name); } - throw runtime_error("dd4hep: DetElement::child: Self is not defined [Invalid Handle]"); + throw std::runtime_error("dd4hep: DetElement::child: Self is not defined [Invalid Handle]"); } /// Access to individual children by name. Have option to not throw an exception -DetElement DetElement::child(const string& child_name, bool throw_if_not_found) const { +DetElement DetElement::child(const std::string& child_name, bool throw_if_not_found) const { if (isValid()) { const Children& c = ptr()->children; Children::const_iterator i = c.find(child_name); if ( i != c.end() ) return (*i).second; if ( throw_if_not_found ) { - throw runtime_error("dd4hep: DetElement::child Unknown child with name: "+child_name); + throw std::runtime_error("dd4hep: DetElement::child Unknown child with name: "+child_name); } } if ( throw_if_not_found ) { - throw runtime_error("dd4hep: DetElement::child: Self is not defined [Invalid Handle]"); + throw std::runtime_error("dd4hep: DetElement::child: Self is not defined [Invalid Handle]"); } return DetElement(); } @@ -249,24 +247,26 @@ DetElement DetElement::world() const { } /// Simple checking routine -void DetElement::check(bool cond, const string& msg) const { +void DetElement::check(bool cond, const std::string& msg) const { if (cond) { - throw runtime_error("dd4hep: " + msg); + throw std::runtime_error("dd4hep: " + msg); } } /// Add a new child subdetector element DetElement& DetElement::add(DetElement sdet) { if (isValid()) { - pair r = object().children.emplace(sdet.name(), sdet); + auto r = object().children.emplace(sdet.name(), sdet); if (r.second) { sdet.access()->parent = *this; return *this; } - throw runtime_error("dd4hep: DetElement::add: Element " + string(sdet.name()) + - " is already present in path " + path() + " [Double-Insert]"); + except("dd4hep", + "DetElement::add: Element %s is already present in path %s [Double-Insert]", + sdet.name(), this->path().c_str()); } - throw runtime_error("dd4hep: DetElement::add: Self is not defined [Invalid Handle]"); + except("dd4hep", "DetElement::add: Self is not defined [Invalid Handle]"); + throw std::runtime_error("dd4hep: DetElement::add"); } /// Clone (Deep copy) the DetElement structure @@ -278,11 +278,11 @@ DetElement DetElement::clone(int flg) const { return n; } -DetElement DetElement::clone(const string& new_name) const { +DetElement DetElement::clone(const std::string& new_name) const { return clone(new_name, access()->id); } -DetElement DetElement::clone(const string& new_name, int new_id) const { +DetElement DetElement::clone(const std::string& new_name, int new_id) const { Object* o = access(); Object* n = o->clone(new_id, COPY_PLACEMENT); n->SetName(new_name.c_str()); @@ -290,21 +290,21 @@ DetElement DetElement::clone(const string& new_name, int new_id) const { return n; } -pair DetElement::reflect(const string& new_name) const { +std::pair DetElement::reflect(const std::string& new_name) const { return reflect(new_name, access()->id); } -pair DetElement::reflect(const string& new_name, int new_id) const { +std::pair DetElement::reflect(const std::string& new_name, int new_id) const { return reflect(new_name, new_id, SensitiveDetector(0)); } -pair DetElement::reflect(const string& new_name, int new_id, SensitiveDetector sd) const { +std::pair DetElement::reflect(const std::string& new_name, int new_id, SensitiveDetector sd) const { if ( placement().isValid() ) { return m_element->reflect(new_name, new_id, sd); } except("DetElement","reflect: Only placed DetElement objects can be reflected: %s", path().c_str()); - return make_pair(DetElement(),Volume()); + return std::make_pair(DetElement(),Volume()); } /// Access to the ideal physical volume of this detector element @@ -335,7 +335,8 @@ DetElement& DetElement::setPlacement(const PlacedVolume& pv) { } return *this; } - throw runtime_error("dd4hep: DetElement::setPlacement: Placement is not defined [Invalid Handle]"); + except("dd4hep", "DetElement::setPlacement: Placement is not defined [Invalid Handle]"); + throw std::runtime_error("dd4hep: DetElement::add"); } /// The cached VolumeID of this subdetector element @@ -356,19 +357,19 @@ Solid DetElement::solid() const { return volume()->GetShape(); } -DetElement& DetElement::setVisAttributes(const Detector& description, const string& nam, const Volume& vol) { +DetElement& DetElement::setVisAttributes(const Detector& description, const std::string& nam, const Volume& vol) { vol.setVisAttributes(description, nam); return *this; } -DetElement& DetElement::setRegion(const Detector& description, const string& nam, const Volume& vol) { +DetElement& DetElement::setRegion(const Detector& description, const std::string& nam, const Volume& vol) { if (!nam.empty()) { vol.setRegion(description.region(nam)); } return *this; } -DetElement& DetElement::setLimitSet(const Detector& description, const string& nam, const Volume& vol) { +DetElement& DetElement::setLimitSet(const Detector& description, const std::string& nam, const Volume& vol) { if (!nam.empty()) { vol.setLimitSet(description.limitSet(nam)); } @@ -377,15 +378,15 @@ DetElement& DetElement::setLimitSet(const Detector& description, const string& n DetElement& DetElement::setAttributes(const Detector& description, const Volume& vol, - const string& region, - const string& limits, - const string& vis) + const std::string& region, + const std::string& limits, + const std::string& vis) { return setRegion(description, region, vol).setLimitSet(description, limits, vol).setVisAttributes(description, vis, vol); } /// Constructor -SensitiveDetector::SensitiveDetector(const string& nam, const string& typ) { +SensitiveDetector::SensitiveDetector(const std::string& nam, const std::string& typ) { /* @@ -398,13 +399,13 @@ SensitiveDetector::SensitiveDetector(const string& nam, const string& typ) { } /// Set the type of the sensitive detector -SensitiveDetector& SensitiveDetector::setType(const string& typ) { +SensitiveDetector& SensitiveDetector::setType(const std::string& typ) { access()->SetTitle(typ.c_str()); return *this; } /// Access the type of the sensitive detector -string SensitiveDetector::type() const { +std::string SensitiveDetector::type() const { return m_element ? m_element->GetTitle() : s_empty_string; } @@ -436,13 +437,13 @@ double SensitiveDetector::energyCutoff() const { } /// Assign the name of the hits collection -SensitiveDetector& SensitiveDetector::setHitsCollection(const string& collection) { +SensitiveDetector& SensitiveDetector::setHitsCollection(const std::string& collection) { access()->hitsCollection = collection; return *this; } /// Access the hits collection name -const string& SensitiveDetector::hitsCollection() const { +const std::string& SensitiveDetector::hitsCollection() const { return access()->hitsCollection; } diff --git a/DDCore/src/DetectorData.cpp b/DDCore/src/DetectorData.cpp index 87e8e344c..f2ba99d47 100644 --- a/DDCore/src/DetectorData.cpp +++ b/DDCore/src/DetectorData.cpp @@ -12,24 +12,23 @@ //========================================================================== // Framework include files -#include "DD4hep/Grammar.h" -#include "DD4hep/DetectorData.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/detail/ObjectsInterna.h" -#include "DD4hep/detail/DetectorInterna.h" +#include +#include +#include +#include +#include // ROOT include files -#include "TGeoManager.h" -#include "TClassStreamer.h" -#include "TDataMember.h" -#include "TDataType.h" -#include "TClass.h" -#include "TROOT.h" +#include +#include +#include +#include +#include +#include namespace dd4hep { namespace detail { class DetectorImp; }} -using namespace dd4hep::detail; using namespace dd4hep; namespace { @@ -212,17 +211,17 @@ void DetectorData::destroyData(bool destroy_mgr) { m_extensions.clear(); m_detectorParents.clear(); - destroyHandle(m_world); - destroyHandle(m_field); - destroyHandle(m_header); - destroyHandles(m_readouts); - destroyHandles(m_idDict); - destroyHandles(m_limits); - destroyHandles(m_regions); - destroyHandles(m_sensitive); - destroyHandles(m_display); - destroyHandles(m_fields); - destroyHandles(m_define); + detail::destroyHandle(m_world); + detail::destroyHandle(m_field); + detail::destroyHandle(m_header); + detail::destroyHandles(m_readouts); + detail::destroyHandles(m_idDict); + detail::destroyHandles(m_limits); + detail::destroyHandles(m_regions); + detail::destroyHandles(m_sensitive); + detail::destroyHandles(m_display); + detail::destroyHandles(m_fields); + detail::destroyHandles(m_define); #if 0 for(const auto& def : m_define) { auto c = def; @@ -231,7 +230,7 @@ void DetectorData::destroyData(bool destroy_mgr) { delete def.second.ptr(); } #endif - destroyHandle(m_volManager); + detail::destroyHandle(m_volManager); m_properties.clear(); m_trackers.clear(); m_trackingVol.clear(); @@ -243,7 +242,7 @@ void DetectorData::destroyData(bool destroy_mgr) { m_inhibitConstants = false; if ( destroy_mgr ) { gGeoManager = m_manager; - deletePtr(m_manager); + detail::deletePtr(m_manager); gGeoManager = 0; } else { diff --git a/DDCore/src/DetectorHelper.cpp b/DDCore/src/DetectorHelper.cpp index e0cc6ed7d..a0b10fb37 100644 --- a/DDCore/src/DetectorHelper.cpp +++ b/DDCore/src/DetectorHelper.cpp @@ -12,17 +12,16 @@ //========================================================================== // Framework include files -#include "DD4hep/DetectorHelper.h" +#include // ROOT include files -#include "TGeoManager.h" +#include -using namespace std; using namespace dd4hep; /// Access the sensitive detector of a given subdetector (if the sub-detector is sensitive!) SensitiveDetector DetectorHelper::sensitiveDetector(const std::string& detector) const { - const string& det_name = detector; + const std::string& det_name = detector; SensitiveDetector sensitive = ptr()->sensitiveDetector(det_name); return sensitive; } @@ -61,7 +60,7 @@ Atom DetectorHelper::element(const std::string& nam) const { TGeoElementTable* tab = mgr.GetElementTable(); TGeoElement* elt = tab->FindElement(nam.c_str()); if ( !elt ) { - string n = nam; + std::string n = nam; transform(n.begin(), n.end(), n.begin(), ::toupper); elt = tab->FindElement(n.c_str()); // Check for IRON if ( !elt ) { @@ -81,7 +80,7 @@ Material DetectorHelper::material(const std::string& nam) const { TGeoManager& mgr = access()->manager(); TGeoMedium* med = mgr.GetMedium(nam.c_str()); if ( !med ) { - string n = nam; + std::string n = nam; transform(n.begin(), n.end(), n.begin(), ::toupper); med = mgr.GetMedium(n.c_str()); // Check for IRON if ( !med ) { diff --git a/DDCore/src/DetectorInterna.cpp b/DDCore/src/DetectorInterna.cpp index 5af73f6c0..428e87c91 100644 --- a/DDCore/src/DetectorInterna.cpp +++ b/DDCore/src/DetectorInterna.cpp @@ -12,22 +12,22 @@ //========================================================================== // Framework include files -#include "DD4hep/detail/Handle.inl" -#include "DD4hep/detail/DetectorInterna.h" -#include "DD4hep/detail/ConditionsInterna.h" -#include "DD4hep/detail/AlignmentsInterna.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/DetectorTools.h" -#include "DD4hep/Printout.h" -#include "TGeoVolume.h" -#include "TGeoMatrix.h" -#include "TGeoManager.h" +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include -using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; -typedef detail::tools::PlacementPath PlacementPath; -typedef detail::tools::ElementPath ElementPath; + +using PlacementPath = detail::tools::PlacementPath; +using ElementPath = detail::tools::ElementPath; DD4HEP_INSTANTIATE_HANDLE_NAMED(DetElementObject); DD4HEP_INSTANTIATE_HANDLE_NAMED(SensitiveDetectorObject); @@ -84,9 +84,9 @@ DetElementObject::DetElementObject(const std::string& nam, int ident) /// Internal object destructor: release extension object(s) DetElementObject::~DetElementObject() { - destroyHandles(children); - destroyHandle (nominal); - destroyHandle (survey); + detail::destroyHandles(children); + detail::destroyHandle (nominal); + detail::destroyHandle (survey); placement.clear(); idealPlace.clear(); parent.clear(); @@ -135,7 +135,7 @@ DetElementObject* DetElementObject::clone(int new_id, int flg) const { } /// Reflect all volumes in a DetElement sub-tree and re-attach the placements -pair DetElementObject::reflect(const std::string& new_name, int new_id, SensitiveDetector sd) { +std::pair DetElementObject::reflect(const std::string& new_name, int new_id, SensitiveDetector sd) { struct ChildMapper { std::map nodes; void match(DetElement de_det, DetElement de_ref) const { @@ -154,7 +154,7 @@ pair DetElementObject::reflect(const std::string& new_name, i if ( nodes.find(n1) == nodes.end() ) { TGeoVolume* v1 = n1->GetVolume(); TGeoVolume* v2 = n2->GetVolume(); - nodes.insert(make_pair(n1,n2)); + nodes.insert(std::make_pair(n1,n2)); printout(DEBUG,"DetElement","reflect: Map %p --- %p ",n1,n2); for(Int_t i=0; iGetNdaughters(); ++i) map(v1->GetNode(i), v2->GetNode(i)); @@ -173,7 +173,7 @@ pair DetElementObject::reflect(const std::string& new_name, i mapper.map(vol_det->GetNode(i), vol_ref->GetNode(i)); for(auto i=childrens_det.begin(), j=childrens_ref.begin(); i!=childrens_det.end(); ++i, ++j) mapper.match((*i).second, (*j).second); - return make_pair(det_ref,vol_ref); + return std::make_pair(det_ref,vol_ref); } /// Access to the world object. Only possible once the geometry is closed. @@ -195,7 +195,7 @@ void DetElementObject::revalidate() { DetElement det(this); DetElement par(det.parent()); DetElement wrld = world(); - string place = det.placementPath(); + std::string place = det.placementPath(); detail::tools::placementPath(par, this, par_path); PlacedVolume node = detail::tools::findNode(wrld.placement(),place); @@ -251,7 +251,7 @@ void DetElementObject::update(unsigned int tags, void* param) { } /// Initializing constructor -WorldObject::WorldObject(Detector& _description, const string& nam) +WorldObject::WorldObject(Detector& _description, const std::string& nam) : DetElementObject(nam,0), description(&_description) { } diff --git a/DDCore/src/DetectorLoad.cpp b/DDCore/src/DetectorLoad.cpp index c103c5426..cf464a4dd 100644 --- a/DDCore/src/DetectorLoad.cpp +++ b/DDCore/src/DetectorLoad.cpp @@ -12,18 +12,18 @@ //========================================================================== // Framework include files -#include "DD4hep/DetectorLoad.h" -#include "DD4hep/Detector.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Plugins.h" -#include "XML/XMLElements.h" -#include "XML/DocumentHandler.h" +#include +#include +#include +#include +#include +#include // C/C++ include files #include #ifndef __TIXML__ -#include "xercesc/dom/DOMException.hpp" +#include namespace dd4hep { namespace xml { typedef xercesc::DOMException XmlException; @@ -32,7 +32,6 @@ namespace dd4hep { #endif using namespace dd4hep; -using namespace std; /// Default constructor (protected, for sub-classes) DetectorLoad::DetectorLoad(Detector* description) : m_detDesc(description) { @@ -47,7 +46,7 @@ DetectorLoad::~DetectorLoad() { } /// Process XML unit and adopt all data from source structure. -void DetectorLoad::processXML(const string& xmlfile, xml::UriReader* entity_resolver) { +void DetectorLoad::processXML(const std::string& xmlfile, xml::UriReader* entity_resolver) { try { xml::DocumentHolder doc(xml::DocumentHandler().load(xmlfile,entity_resolver)); if ( doc ) { @@ -57,21 +56,21 @@ void DetectorLoad::processXML(const string& xmlfile, xml::UriReader* entity_reso return; } } - throw runtime_error("dd4hep: Failed to parse the XML file " + xmlfile + " [Invalid XML ROOT handle]"); + throw std::runtime_error("dd4hep: Failed to parse the XML file " + xmlfile + " [Invalid XML ROOT handle]"); } catch (const xml::XmlException& e) { - throw runtime_error(xml::_toString(e.msg) + "\ndd4hep: XML-DOM Exception while parsing " + xmlfile); + throw std::runtime_error(xml::_toString(e.msg) + "\ndd4hep: XML-DOM Exception while parsing " + xmlfile); } - catch (const exception& e) { - throw runtime_error(string(e.what()) + "\ndd4hep: while parsing " + xmlfile); + catch (const std::exception& e) { + throw std::runtime_error(std::string(e.what()) + "\ndd4hep: while parsing " + xmlfile); } catch (...) { - throw runtime_error("dd4hep: UNKNOWN exception while parsing " + xmlfile); + throw std::runtime_error("dd4hep: UNKNOWN exception while parsing " + xmlfile); } } /// Process XML unit and adopt all data from source structure. -void DetectorLoad::processXML(const xml::Handle_t& base, const string& xmlfile, xml::UriReader* entity_resolver) { +void DetectorLoad::processXML(const xml::Handle_t& base, const std::string& xmlfile, xml::UriReader* entity_resolver) { try { xml::Strng_t xml(xmlfile); xml::DocumentHolder doc(xml::DocumentHandler().load(base,xml,entity_resolver)); @@ -82,16 +81,16 @@ void DetectorLoad::processXML(const xml::Handle_t& base, const string& xmlfile, return; } } - throw runtime_error("dd4hep: Failed to parse the XML file " + xmlfile + " [Invalid XML ROOT handle]"); + throw std::runtime_error("dd4hep: Failed to parse the XML file " + xmlfile + " [Invalid XML ROOT handle]"); } catch (const xml::XmlException& e) { - throw runtime_error(xml::_toString(e.msg) + "\ndd4hep: XML-DOM Exception while parsing " + xmlfile); + throw std::runtime_error(xml::_toString(e.msg) + "\ndd4hep: XML-DOM Exception while parsing " + xmlfile); } - catch (const exception& e) { - throw runtime_error(string(e.what()) + "\ndd4hep: while parsing " + xmlfile); + catch (const std::exception& e) { + throw std::runtime_error(std::string(e.what()) + "\ndd4hep: while parsing " + xmlfile); } catch (...) { - throw runtime_error("dd4hep: UNKNOWN exception while parsing " + xmlfile); + throw std::runtime_error("dd4hep: UNKNOWN exception while parsing " + xmlfile); } } @@ -113,65 +112,65 @@ void DetectorLoad::processXMLString(const char* xmldata, xml::UriReader* entity_ } } } - throw runtime_error("DetectorLoad::processXMLString: Invalid XML In-memory source [NULL]"); + throw std::runtime_error("DetectorLoad::processXMLString: Invalid XML In-memory source [NULL]"); } catch (const xml::XmlException& e) { - throw runtime_error(xml::_toString(e.msg) + "\ndd4hep: XML-DOM Exception while parsing XML in-memory string."); + throw std::runtime_error(xml::_toString(e.msg) + "\ndd4hep: XML-DOM Exception while parsing XML in-memory string."); } - catch (const exception& e) { - throw runtime_error(string(e.what()) + "\ndd4hep: while parsing XML in-memory string."); + catch (const std::exception& e) { + throw std::runtime_error(std::string(e.what()) + "\ndd4hep: while parsing XML in-memory string."); } catch (...) { - throw runtime_error("dd4hep: UNKNOWN exception while parsing XML in-memory string."); + throw std::runtime_error("dd4hep: UNKNOWN exception while parsing XML in-memory string."); } } /// Process a given DOM (sub-) tree void DetectorLoad::processXMLElement(const std::string& xmlfile, const xml::Handle_t& xml_root) { if ( xml_root.ptr() ) { - string tag = xml_root.tag(); - string type = tag + "_XML_reader"; + std::string tag = xml_root.tag(); + std::string type = tag + "_XML_reader"; xml::Handle_t handle = xml_root; long result = PluginService::Create(type, m_detDesc, &handle); if (0 == result) { PluginDebug dbg; result = PluginService::Create(type, m_detDesc, &handle); if ( 0 == result ) { - throw runtime_error("dd4hep: Failed to locate plugin to interprete files of type" - " \"" + tag + "\" - no factory:" + type + ". " + dbg.missingFactory(type)); + throw std::runtime_error("dd4hep: Failed to locate plugin to interprete files of type" + " \"" + tag + "\" - no factory:" + type + ". " + dbg.missingFactory(type)); } } result = *(long*) result; if (result != 1) { - throw runtime_error("dd4hep: Failed to parse the XML file " + xmlfile + " with the plugin " + type); + throw std::runtime_error("dd4hep: Failed to parse the XML file " + xmlfile + " with the plugin " + type); } return; } - throw runtime_error("dd4hep: Failed to parse the XML file " + xmlfile + " [Invalid XML ROOT handle]"); + throw std::runtime_error("dd4hep: Failed to parse the XML file " + xmlfile + " [Invalid XML ROOT handle]"); } /// Process a given DOM (sub-) tree void DetectorLoad::processXMLElement(const xml::Handle_t& xml_root, DetectorBuildType /* type */) { if ( xml_root.ptr() ) { - string tag = xml_root.tag(); - string type = tag + "_XML_reader"; + std::string tag = xml_root.tag(); + std::string type = tag + "_XML_reader"; xml::Handle_t handle = xml_root; long result = PluginService::Create(type, m_detDesc, &handle); if (0 == result) { PluginDebug dbg; result = PluginService::Create(type, m_detDesc, &handle); if ( 0 == result ) { - throw runtime_error("dd4hep: Failed to locate plugin to interprete files of type" - " \"" + tag + "\" - no factory:" - + type + ". " + dbg.missingFactory(type)); + throw std::runtime_error("dd4hep: Failed to locate plugin to interprete files of type" + " \"" + tag + "\" - no factory:" + + type + ". " + dbg.missingFactory(type)); } } result = *(long*) result; if (result != 1) { - throw runtime_error("dd4hep: Failed to parse the XML element with tag " - + tag + " with the plugin " + type); + throw std::runtime_error("dd4hep: Failed to parse the XML element with tag " + + tag + " with the plugin " + type); } return; } - throw runtime_error("dd4hep: Failed to parse the XML file [Invalid XML ROOT handle]"); + throw std::runtime_error("dd4hep: Failed to parse the XML file [Invalid XML ROOT handle]"); } diff --git a/DDCore/src/DetectorProcessor.cpp b/DDCore/src/DetectorProcessor.cpp index a08741f43..ac68dc902 100644 --- a/DDCore/src/DetectorProcessor.cpp +++ b/DDCore/src/DetectorProcessor.cpp @@ -12,9 +12,9 @@ //========================================================================== // Framework includes -#include "DD4hep/Printout.h" -#include "DD4hep/DetectorProcessor.h" -#include "DD4hep/detail/ContainerHelpers.h" +#include +#include +#include using namespace dd4hep; diff --git a/DDCore/src/DetectorSelector.cpp b/DDCore/src/DetectorSelector.cpp index 40b2058cc..8f72fa020 100644 --- a/DDCore/src/DetectorSelector.cpp +++ b/DDCore/src/DetectorSelector.cpp @@ -12,33 +12,31 @@ //========================================================================== // Framework include files -#include "DD4hep/DetectorSelector.h" -#include "DD4hep/Detector.h" +#include +#include -using namespace std; using namespace dd4hep; /// Access a set of subdetectors according to the sensitive type. -const DetectorSelector::Result& -DetectorSelector::detectors(const string& type) +const DetectorSelector::Result& DetectorSelector::detectors(const std::string& type) { return description.detectors(type); } /// Access a set of subdetectors according to several sensitive types. DetectorSelector::Result -DetectorSelector::detectors(const string& type1, - const string& type2, - const string& type3, - const string& type4, - const string& type5) { - const string* types[] = { &type1, &type2, &type3, &type4, &type5 }; +DetectorSelector::detectors(const std::string& type1, + const std::string& type2, + const std::string& type3, + const std::string& type4, + const std::string& type5) { + const std::string* types[] = { &type1, &type2, &type3, &type4, &type5 }; Result result; - for(size_t i=0; iempty() ) { - const vector& v = description.detectors(*(types[i])); - result.insert(end(result),begin(v),end(v)); + const std::vector& v = description.detectors(*(types[i])); + result.insert(std::end(result), std::begin(v), std::end(v)); } } catch(...) {} @@ -55,7 +53,7 @@ DetectorSelector::detectors(unsigned int includeFlag, unsigned int excludeFlag ) const Detector::HandleMap& entries = description.detectors(); result.reserve( entries.size() ) ; description.detectors(""); // Just to ensure the geometry is closed.... - for(const auto& i : entries ) { + for( const auto& i : entries ) { DetElement det(i.second); if ( det.parent().isValid() ) { // Exclude 'world' //fixme: what to do with compounds - add their daughters ? diff --git a/DDCore/src/DetectorTools.cpp b/DDCore/src/DetectorTools.cpp index 61d84ec5b..bee5e7c10 100644 --- a/DDCore/src/DetectorTools.cpp +++ b/DDCore/src/DetectorTools.cpp @@ -13,17 +13,17 @@ // Framework include files #define DETECTORTOOLS_CPP -#include "DD4hep/DetectorTools.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Detector.h" -#include "DD4hep/detail/DetectorInterna.h" +#include +#include +#include +#include // C/C++ include files #include #include // ROOT include files -#include "TGeoMatrix.h" +#include /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -51,7 +51,6 @@ namespace dd4hep { }} } -using namespace std; using namespace dd4hep; /// Find path between the child element and the parent element @@ -62,7 +61,7 @@ bool detail::tools::isParentElement(DetElement parent, DetElement child) { if ( par.ptr() == parent.ptr() ) return true; } } - throw runtime_error("Search for parent detector element with invalid handles not allowed."); + throw std::runtime_error("Search for parent detector element with invalid handles not allowed."); } /// Find Child of PlacedVolume and assemble on the fly the path of PlacedVolumes @@ -149,9 +148,9 @@ void detail::tools::elementPath(DetElement parent, DetElement child, ElementPath return; } } - throw runtime_error(string("The detector element ")+parent.name()+string(" is no parent of ")+child.name()); + throw std::runtime_error(std::string("The detector element ")+parent.name()+std::string(" is no parent of ")+child.name()); } - throw runtime_error("Search for parent detector element with invalid handles not allowed."); + throw std::runtime_error("Search for parent detector element with invalid handles not allowed."); } /// Collect detector elements placements to the top detector element (world) [fast, but may have holes!] @@ -163,7 +162,7 @@ void detail::tools::elementPath(DetElement parent, DetElement element, Placement } if ( par.ptr() == parent.ptr() ) return; } - throw runtime_error(string("The detector element ")+parent.name()+string(" is no parent of ")+element.name()); + throw std::runtime_error(std::string("The detector element ")+parent.name()+std::string(" is no parent of ")+element.name()); } /// Collect detector elements placements to the top detector element (world) [fast, but may have holes!] @@ -177,64 +176,64 @@ void detail::tools::elementPath(DetElement element, PlacementPath& det_nodes) { } /// Assemble the path of the PlacedVolume selection -string detail::tools::elementPath(const PlacementPath& nodes, bool reverse) { - string path = ""; +std::string detail::tools::elementPath(const PlacementPath& nodes, bool reverse) { + std::string path = ""; if ( reverse ) { for(auto i=nodes.rbegin(); i != nodes.rend(); ++i) - path += "/" + string((*i).name()); + path += "/" + std::string((*i).name()); } else { for(auto i=begin(nodes); i != end(nodes); ++i) - path += "/" + string((*i)->GetName()); + path += "/" + std::string((*i)->GetName()); } return path; } /// Assemble the path of the PlacedVolume selection -string detail::tools::elementPath(const ElementPath& nodes, bool reverse) { - string path = ""; +std::string detail::tools::elementPath(const ElementPath& nodes, bool reverse) { + std::string path = ""; if ( reverse ) { for(ElementPath::const_reverse_iterator i=nodes.rbegin();i!=nodes.rend();++i) - path += "/" + string((*i)->GetName()); + path += "/" + std::string((*i)->GetName()); } else { for(ElementPath::const_iterator i=nodes.begin();i!=nodes.end();++i) - path += "/" + string((*i)->GetName()); + path += "/" + std::string((*i)->GetName()); } return path; } /// Assemble the path of a particular detector element -string detail::tools::elementPath(DetElement element) { +std::string detail::tools::elementPath(DetElement element) { ElementPath nodes; elementPath(element,nodes); return elementPath(nodes); } /// Find DetElement as child of the top level volume by its absolute path -DetElement detail::tools::findElement(const Detector& description, const string& path) { +DetElement detail::tools::findElement(const Detector& description, const std::string& path) { return findDaughterElement(description.world(),path); } /// Find DetElement as child of a parent by its relative or absolute path -DetElement detail::tools::findDaughterElement(DetElement parent, const string& subpath) { +DetElement detail::tools::findDaughterElement(DetElement parent, const std::string& subpath) { if ( parent.isValid() ) { size_t idx = subpath.find('/',1); if ( subpath[0] == '/' ) { DetElement top = topElement(parent); - if ( idx == string::npos ) return top; + if ( idx == std::string::npos ) return top; return findDaughterElement(top,subpath.substr(idx+1)); } - if ( idx == string::npos ) + if ( idx == std::string::npos ) return parent.child(subpath); - string name = subpath.substr(0,idx); + std::string name = subpath.substr(0,idx); DetElement node = parent.child(name); if ( node.isValid() ) { return findDaughterElement(node,subpath.substr(idx+1)); } - throw runtime_error("dd4hep: DetElement "+parent.path()+" has no child named:"+name+" [No such child]"); + throw std::runtime_error("dd4hep: DetElement "+parent.path()+" has no child named:"+name+" [No such child]"); } - throw runtime_error("dd4hep: Cannot determine child with path "+subpath+" from invalid parent [invalid handle]"); + throw std::runtime_error("dd4hep: Cannot determine child with path "+subpath+" from invalid parent [invalid handle]"); } /// Determine top level element (=world) for any element walking up the detector element tree @@ -244,14 +243,14 @@ DetElement detail::tools::topElement(DetElement child) { return topElement(child.parent()); return child; } - throw runtime_error("dd4hep: DetElement cannot determine top parent (world) [invalid handle]"); + throw std::runtime_error("dd4hep: DetElement cannot determine top parent (world) [invalid handle]"); } static void detail::tools::makePlacementPath(PlacementPath det_nodes, PlacementPath& all_nodes) { for (size_t i = 0, n = det_nodes.size(); n > 0 && i < n-1; ++i) { if (!findChildByName(det_nodes[i + 1], det_nodes[i], all_nodes)) { - throw runtime_error("dd4hep: DetElement cannot determine placement path of " - + string(det_nodes[i].name()) + " [internal error]"); + throw std::runtime_error("dd4hep: DetElement cannot determine placement path of " + + std::string(det_nodes[i].name()) + " [internal error]"); } } if ( det_nodes.size() > 0 ) { @@ -274,37 +273,36 @@ void detail::tools::placementPath(DetElement parent, DetElement element, Placeme } /// Assemble the path of the PlacedVolume selection -string detail::tools::placementPath(DetElement element) { +std::string detail::tools::placementPath(DetElement element) { PlacementPath path; placementPath(element,path); return placementPath(path); } /// Assemble the path of the PlacedVolume selection -string detail::tools::placementPath(const PlacementPath& nodes, bool reverse) { - string path = ""; +std::string detail::tools::placementPath(const PlacementPath& nodes, bool reverse) { + std::string path = ""; if ( reverse ) { for(PlacementPath::const_reverse_iterator i=nodes.rbegin();i!=nodes.rend();++i) - path += "/" + string((*i)->GetName()); + path += "/" + std::string((*i)->GetName()); } else { for(PlacementPath::const_iterator i=nodes.begin();i!=nodes.end();++i) - path += "/" + string((*i)->GetName()); + path += "/" + std::string((*i)->GetName()); } return path; } /// Assemble the path of the PlacedVolume selection -string detail::tools::placementPath(const vector& nodes, bool reverse) { - string path = ""; +std::string detail::tools::placementPath(const std::vector& nodes, bool reverse) { + std::string path = ""; if ( reverse ) { - for(vector::const_reverse_iterator i=nodes.rbegin();i!=nodes.rend();++i) - path += "/" + string((*i)->GetName()); - } - else { - for(vector::const_iterator i=nodes.begin();i!=nodes.end();++i) - path += "/" + string((*i)->GetName()); + for(std::vector::const_reverse_iterator i=nodes.rbegin();i!=nodes.rend();++i) + path += "/" + std::string((*i)->GetName()); + return path; } + for( const auto* n : nodes ) + path += "/" + std::string(n->GetName()); return path; } @@ -327,7 +325,7 @@ void detail::tools::placementTrafo(const PlacementPath& nodes, bool inverse, TGe } /// Find a given node in the hierarchy starting from the top node (absolute placement!) -PlacedVolume detail::tools::findNode(PlacedVolume top_place, const string& place) { +PlacedVolume detail::tools::findNode(PlacedVolume top_place, const std::string& place) { TGeoNode* top = top_place.ptr(); const char* path = place.c_str(); // Check if a geometry path is valid without changing the state of the navigator. @@ -377,16 +375,16 @@ PlacedVolume detail::tools::findNode(PlacedVolume top_place, const string& place } /// Convert VolumeID to string -string detail::tools::toString(const PlacedVolume::VolIDs& ids) { - stringstream log; +std::string detail::tools::toString(const PlacedVolume::VolIDs& ids) { + std::stringstream log; for( const auto& v : ids ) log << v.first << "=" << v.second << "; "; return log.str(); } /// Convert VolumeID to string -string detail::tools::toString(const IDDescriptor& dsc, const PlacedVolume::VolIDs& ids, VolumeID code) { - stringstream log; +std::string detail::tools::toString(const IDDescriptor& dsc, const PlacedVolume::VolIDs& ids, VolumeID code) { + std::stringstream log; for( const auto& id : ids ) { const BitFieldElement* f = dsc.field(id.first); VolumeID value = f->value(code); @@ -396,14 +394,14 @@ string detail::tools::toString(const IDDescriptor& dsc, const PlacedVolume::VolI } /// Extract all the path elements from a path -vector detail::tools::pathElements(const string& path) { - vector result; +std::vector detail::tools::pathElements(const std::string& path) { + std::vector result; if ( !path.empty() ) { - string tmp = path[0]=='/' ? path.substr(1) : path; - for(size_t idx=tmp.find('/'); idx != string::npos; idx=tmp.find('/')) { - string val = tmp.substr(0,idx); + std::string tmp = path[0]=='/' ? path.substr(1) : path; + for(size_t idx=tmp.find('/'); idx != std::string::npos; idx=tmp.find('/')) { + std::string val = tmp.substr(0,idx); result.emplace_back(val); - tmp = tmp.length()>idx ? tmp.substr(idx+1) : string(); + tmp = tmp.length()>idx ? tmp.substr(idx+1) : std::string(); } if ( !tmp.empty() ) { result.emplace_back(tmp); diff --git a/DDCore/src/Errors.cpp b/DDCore/src/Errors.cpp index f23b4d4e1..a123328f4 100644 --- a/DDCore/src/Errors.cpp +++ b/DDCore/src/Errors.cpp @@ -13,7 +13,7 @@ //========================================================================== // Framework include files -#include "DD4hep/Errors.h" +#include // C/C++ includes #include diff --git a/DDCore/src/Exceptions.cpp b/DDCore/src/Exceptions.cpp index 9237eed19..e80f12b83 100644 --- a/DDCore/src/Exceptions.cpp +++ b/DDCore/src/Exceptions.cpp @@ -12,18 +12,17 @@ //========================================================================== // Framework include files -#include "DD4hep/Exceptions.h" -#include "DD4hep/Primitives.h" +#include +#include -using namespace std; using namespace dd4hep; -string unrelated_type_error::msg(const type_info& typ1, const type_info& typ2, const string& text) { - string m = "The types " + typeName(typ1) + " and " + typeName(typ2) + " are not related. " + text; +std::string unrelated_type_error::msg(const std::type_info& typ1, const std::type_info& typ2, const std::string& text) { + std::string m = "The types " + typeName(typ1) + " and " + typeName(typ2) + " are not related. " + text; return m; } -string unrelated_value_error::msg(const type_info& typ, const string& text) { - string m = "The type " + typeName(typ) + " cannot be converted: " + text; +std::string unrelated_value_error::msg(const std::type_info& typ, const std::string& text) { + std::string m = "The type " + typeName(typ) + " cannot be converted: " + text; return m; } diff --git a/DDCore/src/ExtensionEntry.cpp b/DDCore/src/ExtensionEntry.cpp index f22876858..82cc8f79c 100644 --- a/DDCore/src/ExtensionEntry.cpp +++ b/DDCore/src/ExtensionEntry.cpp @@ -12,8 +12,8 @@ //========================================================================== // Framework include files -#include "DD4hep/ExtensionEntry.h" -#include "DD4hep/Printout.h" +#include +#include /// Callback on invalid call invokation void dd4hep::ExtensionEntry::invalidCall(const char* tag) const { diff --git a/DDCore/src/FieldTypes.cpp b/DDCore/src/FieldTypes.cpp index f1e0b365d..16b94b58f 100644 --- a/DDCore/src/FieldTypes.cpp +++ b/DDCore/src/FieldTypes.cpp @@ -11,11 +11,10 @@ // //========================================================================== -#include "DD4hep/FieldTypes.h" -#include "DD4hep/detail/Handle.inl" +#include +#include #include -using namespace std; using namespace dd4hep; #ifndef INFINITY @@ -159,7 +158,7 @@ void MultipoleField::fieldComponents(const double* pos, double* field) { case 0: // Nothing, but still valid break; default: // Error condition - throw runtime_error("Invalid multipole field definition!"); + throw std::runtime_error("Invalid multipole field definition!"); } Transform3D::Point f = this->rotation * Transform3D::Point(bx, by, B_z); field[0] += f.X(); diff --git a/DDCore/src/Fields.cpp b/DDCore/src/Fields.cpp index 7bc8efeb1..cc3154539 100644 --- a/DDCore/src/Fields.cpp +++ b/DDCore/src/Fields.cpp @@ -11,12 +11,11 @@ // //========================================================================== -#include "DD4hep/Fields.h" -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/detail/Handle.inl" +#include +#include +#include +#include -using namespace std; using namespace dd4hep; typedef CartesianField::Object CartesianFieldObject; @@ -26,7 +25,7 @@ typedef OverlayedField::Object OverlayedFieldObject; DD4HEP_INSTANTIATE_HANDLE(OverlayedFieldObject); namespace { - void calculate_combined_field(vector& v, const Position& pos, double* field) { + void calculate_combined_field(std::vector& v, const Position& pos, double* field) { for (const auto& i : v ) i.value(pos, field); } } @@ -90,7 +89,7 @@ OverlayedField::Object::~Object() { } /// Object constructor -OverlayedField::OverlayedField(const string& nam) : Ref_t() { +OverlayedField::OverlayedField(const std::string& nam) : Ref_t() { auto* obj = new Object(); assign(obj, nam, "overlay_field"); obj->field_type = CartesianField::OVERLAY; @@ -116,13 +115,13 @@ void OverlayedField::add(CartesianField field) { bool isEle = field.ELECTRIC == (typ & field.ELECTRIC); bool isMag = field.MAGNETIC == (typ & field.MAGNETIC); if (isEle) { - vector < CartesianField > &v = o->electric_components; + std::vector < CartesianField > &v = o->electric_components; v.emplace_back(field); o->field_type |= field.ELECTRIC; o->electric = (v.size() == 1) ? field : CartesianField(); } if (isMag) { - vector < CartesianField > &v = o->magnetic_components; + std::vector < CartesianField > &v = o->magnetic_components; v.emplace_back(field); o->field_type |= field.MAGNETIC; o->magnetic = (v.size() == 1) ? field : CartesianField(); diff --git a/DDCore/src/Filter.cpp b/DDCore/src/Filter.cpp index ff46f738d..11641b327 100644 --- a/DDCore/src/Filter.cpp +++ b/DDCore/src/Filter.cpp @@ -1,65 +1,82 @@ -#include "DD4hep/Filter.h" +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// RootDictionary.h +// +// +// M.Frank +// +//========================================================================== +// Framework include files +#include + +// C/C++ include files #include #include #include -using namespace std; - namespace dd4hep { + namespace dd { - bool isMatch(string_view node, string_view name) { + bool isMatch(std::string_view node, std::string_view name) { if (!dd4hep::dd::isRegex(name)) { return (name == node); } else { - regex pattern({name.data(), name.size()}); - return regex_match(begin(node), end(node), pattern); + std::regex pattern({name.data(), name.size()}); + return std::regex_match(begin(node), end(node), pattern); } } - bool compareEqual(string_view node, string_view name) { return (name == node); } + bool compareEqual(std::string_view node, std::string_view name) { return (name == node); } - bool compareEqual(string_view node, regex pattern) { - return regex_match(std::string(node.data(), node.size()), pattern); + bool compareEqual(std::string_view node, std::regex pattern) { + return std::regex_match(std::string(node.data(), node.size()), pattern); } bool compareEqualName(const std::string_view selection, const std::string_view name) { return (!(dd4hep::dd::isRegex(selection)) ? dd4hep::dd::compareEqual(name, selection) - : regex_match(name.begin(), name.end(), regex(std::string(selection)))); + : std::regex_match(name.begin(), name.end(), std::regex(std::string(selection)))); } bool compareEqualCopyNumber(std::string_view name, int copy) { auto pos = name.rfind('['); if (pos != name.npos) { - if (std::stoi(std::string(name.substr(pos + 1, name.rfind(']')))) == copy) { - return true; - } + if (std::stoi(std::string(name.substr(pos + 1, name.rfind(']')))) == copy) { + return true; + } } return false; } - bool accepted(vector const& keys, string_view node) { + bool accepted(std::vector const& keys, std::string_view node) { return (find_if(begin(keys), end(keys), [&](const auto& n) -> bool { return compareEqual(node, n); }) != end(keys)); } bool accepted(const Filter* filter, std::string_view name) { for(unsigned int i = 0; i < filter->isRegex.size(); i++ ) { - if(!filter->isRegex[i]) { - if(compareEqual(filter->skeys[i], name)) { - return true; - } - } else { - if(compareEqual(name, filter->keys[filter->index[i]])) { - return true; - } - } + if(!filter->isRegex[i]) { + if(compareEqual(filter->skeys[i], name)) { + return true; + } + } else { + if(compareEqual(name, filter->keys[filter->index[i]])) { + return true; + } + } } return false; } - bool isRegex(string_view input) { + bool isRegex(std::string_view input) { return (input.find(".") != std::string_view::npos) || (input.find("*") != std::string_view::npos); } @@ -67,19 +84,19 @@ namespace dd4hep { return (input.find(":") != std::string_view::npos); } - string_view realTopName(string_view input) { - string_view v = input; + std::string_view realTopName(std::string_view input) { + std::string_view v = input; auto first = v.find_first_of("//"); - v.remove_prefix(min(first + 2, v.size())); + v.remove_prefix(std::min(first + 2, v.size())); return v; } - vector split(string_view str, const char* delims) { - vector ret; + std::vector split(std::string_view str, const char* delims) { + std::vector ret; - string_view::size_type start = 0; + std::string_view::size_type start = 0; auto pos = str.find_first_of(delims, start); - while (pos != string_view::npos) { + while (pos != std::string_view::npos) { if (pos != start) { ret.emplace_back(str.substr(start, pos - start)); } diff --git a/DDCore/src/GeoDictionary.h b/DDCore/src/GeoDictionary.h index 95f4c496c..00f5f1f35 100644 --- a/DDCore/src/GeoDictionary.h +++ b/DDCore/src/GeoDictionary.h @@ -17,10 +17,10 @@ #define DDCORE_SRC_GEODICTIONARY_H // Framework include files -#include "DD4hep/Volumes.h" -#include "DD4hep/Shapes.h" -#include "DD4hep/VolumeProcessor.h" -#include "DD4hep/detail/ShapesInterna.h" +#include +#include +#include +#include // C/C++ include files #include diff --git a/DDCore/src/GeoHandler.cpp b/DDCore/src/GeoHandler.cpp index 61a7b746a..04941b671 100644 --- a/DDCore/src/GeoHandler.cpp +++ b/DDCore/src/GeoHandler.cpp @@ -12,28 +12,27 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/GeoHandler.h" -#include "DD4hep/detail/ObjectsInterna.h" +#include +#include +#include // ROOT includes -#include "TGeoManager.h" -#include "TGeoCompositeShape.h" -#include "TGeoBoolNode.h" -#include "TClass.h" +#include +#include +#include +#include // C/C++ include files #include -using namespace dd4hep::detail; using namespace dd4hep; -using namespace std; namespace { - void collectSolid(GeoHandler::GeometryInfo& geo, - const string& name, - const string& node, - TGeoShape* shape, + + void collectSolid(detail::GeoHandler::GeometryInfo& geo, + const std::string& name, + const std::string& node, + TGeoShape* shape, TGeoMatrix* matrix) { if ( 0 == ::strncmp(shape->GetName(), "TGeo", 4) ) { @@ -51,43 +50,43 @@ namespace { } /// Default constructor -GeoHandler::GeoHandler() : m_propagateRegions(false) { - m_data = new map >(); +detail::GeoHandler::GeoHandler() : m_propagateRegions(false) { + m_data = new std::map >(); } /// Initializing constructor -GeoHandler::GeoHandler(map >* ptr) +detail::GeoHandler::GeoHandler(std::map >* ptr) : m_propagateRegions(false), m_data(ptr) { } /// Default destructor -GeoHandler::~GeoHandler() { +detail::GeoHandler::~GeoHandler() { if (m_data) delete m_data; m_data = nullptr; } -map >* GeoHandler::release() { - map >* d = m_data; +std::map >* detail::GeoHandler::release() { + std::map >* d = m_data; m_data = nullptr; return d; } /// Propagate regions. Returns the previous value -bool GeoHandler::setPropagateRegions(bool value) { +bool detail::GeoHandler::setPropagateRegions(bool value) { bool old = m_propagateRegions; m_propagateRegions = value; return old; } -GeoHandler& GeoHandler::collect(DetElement element) { +detail::GeoHandler& detail::GeoHandler::collect(DetElement element) { DetElement par = element.parent(); - TGeoNode* par_node = par.isValid() ? par.placement().ptr() : nullptr; + TGeoNode* par_node = par.isValid() ? par.placement().ptr() : nullptr; m_data->clear(); return i_collect(par_node, element.placement().ptr(), 0, Region(), LimitSet()); } -GeoHandler& GeoHandler::collect(DetElement element, GeometryInfo& info) { +detail::GeoHandler& detail::GeoHandler::collect(DetElement element, GeometryInfo& info) { DetElement par = element.parent(); TGeoNode* par_node = par.isValid() ? par.placement().ptr() : nullptr; m_data->clear(); @@ -125,16 +124,16 @@ GeoHandler& GeoHandler::collect(DetElement element, GeometryInfo& info) { return *this; } -GeoHandler& GeoHandler::i_collect(const TGeoNode* /* parent */, - const TGeoNode* current, - int level, Region rg, LimitSet ls) +detail::GeoHandler& detail::GeoHandler::i_collect(const TGeoNode* /* parent */, + const TGeoNode* current, + int level, Region rg, LimitSet ls) { TGeoVolume* volume = current->GetVolume(); - TObjArray* nodes = volume->GetNodes(); - int num_children = nodes ? nodes->GetEntriesFast() : 0; - Volume vol(volume); - Region region = vol.region(); - LimitSet limits = vol.limitSet(); + TObjArray* nodes = volume->GetNodes(); + int num_children = nodes ? nodes->GetEntriesFast() : 0; + Volume vol(volume); + Region region = vol.region(); + LimitSet limits = vol.limitSet(); if ( m_propagateRegions ) { if ( !region.isValid() && rg.isValid() ) { @@ -157,26 +156,26 @@ GeoHandler& GeoHandler::i_collect(const TGeoNode* /* parent */, } /// Initializing constructor -GeoScan::GeoScan(DetElement e) { +detail::GeoScan::GeoScan(DetElement e) { m_data = GeoHandler().collect(e).release(); } /// Initializing constructor -GeoScan::GeoScan(DetElement e, bool propagate) { +detail::GeoScan::GeoScan(DetElement e, bool propagate) { GeoHandler h; h.setPropagateRegions(propagate); m_data = h.collect(e).release(); } /// Default destructor -GeoScan::~GeoScan() { +detail::GeoScan::~GeoScan() { if (m_data) delete m_data; m_data = 0; } /// Work callback -GeoScan& GeoScan::operator()() { +detail::GeoScan& detail::GeoScan::operator()() { return *this; } diff --git a/DDCore/src/GeometryTreeDump.cpp b/DDCore/src/GeometryTreeDump.cpp index bb2fa7733..75c11625e 100644 --- a/DDCore/src/GeometryTreeDump.cpp +++ b/DDCore/src/GeometryTreeDump.cpp @@ -12,39 +12,40 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" #include "GeometryTreeDump.h" +#include + // ROOT includes -#include "TROOT.h" -#include "TColor.h" -#include "TGeoShape.h" -#include "TGeoCone.h" -#include "TGeoParaboloid.h" -#include "TGeoPcon.h" -#include "TGeoPgon.h" -#include "TGeoSphere.h" -#include "TGeoTorus.h" -#include "TGeoTube.h" -#include "TGeoTrd1.h" -#include "TGeoTrd2.h" -#include "TGeoArb8.h" -#include "TGeoMatrix.h" -#include "TGeoBoolNode.h" -#include "TGeoCompositeShape.h" -#include "TClass.h" -#include "TGeoManager.h" -#include "TMath.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// C/C++ include files #include -using namespace dd4hep::detail; using namespace dd4hep; -using namespace std; namespace { - string indent = ""; + std::string indent = ""; /// Reference to output stream - ostream& m_output = cout; + std::ostream& m_output = std::cout; void getAngles(const Double_t* m, Double_t &phi, Double_t &theta, Double_t &psi) { // Retreive Euler angles. @@ -68,91 +69,91 @@ namespace { } /// Dump logical volume in GDML format to output stream -void* GeometryTreeDump::handleVolume(const string& name, Volume vol) const { +void* detail::GeometryTreeDump::handleVolume(const std::string& name, Volume vol) const { VisAttr vis = vol.visAttributes(); TGeoShape* shape = vol->GetShape(); TGeoMedium* medium = vol->GetMedium(); int num = vol->GetNdaughters(); - m_output << "\t\t" << endl; - m_output << "\t\t\tGetName() << "\"/>" << endl; - m_output << "\t\t\tGetName() << "\"/>" << endl; + m_output << "\t\t" << std::endl; + m_output << "\t\t\tGetName() << "\"/>" << std::endl; + m_output << "\t\t\tGetName() << "\"/>" << std::endl; if (vis.isValid()) { - m_output << "\t\t\t" << endl; + m_output << "\t\t\t" << std::endl; } if (num > 0) { for (int i = 0; i < num; ++i) { TGeoNode* geo_nod = vol.ptr()->GetNode(vol->GetNode(i)->GetName()); TGeoVolume* geo_vol = geo_nod->GetVolume(); TGeoMatrix* geo_mat = geo_nod->GetMatrix(); - m_output << "\t\t\t" << endl; - m_output << "\t\t\t\tGetName() << "\"/>" << endl; + m_output << "\t\t\t" << std::endl; + m_output << "\t\t\t\tGetName() << "\"/>" << std::endl; if (geo_mat) { if (geo_mat->IsTranslation()) { - m_output << "\t\t\t\tGetName() << "_pos\"/>" << endl; + m_output << "\t\t\t\tGetName() << "_pos\"/>" << std::endl; } if (geo_mat->IsRotation()) { - m_output << "\t\t\t\tGetName() << "_rot\"/>" << endl; + m_output << "\t\t\t\tGetName() << "_rot\"/>" << std::endl; } } - m_output << "\t\t\t" << endl; + m_output << "\t\t\t" << std::endl; } } - m_output << "\t\t" << endl; + m_output << "\t\t" << std::endl; return 0; } /// Dump solid in GDML format to output stream -void* GeometryTreeDump::handleSolid(const string& name, const TGeoShape* shape) const { +void* detail::GeometryTreeDump::handleSolid(const std::string& name, const TGeoShape* shape) const { if (shape) { if (shape->IsA() == TGeoBBox::Class()) { const TGeoBBox* sh = (const TGeoBBox*) shape; m_output << "\t\tGetDX() << "\" y=\"" << sh->GetDY() << "\" z=\"" - << sh->GetDZ() << "\" lunit=\"cm\"/>" << endl; + << sh->GetDZ() << "\" lunit=\"cm\"/>" << std::endl; } else if (shape->IsA() == TGeoTube::Class()) { const TGeoTube* sh = (const TGeoTube*) shape; m_output << "\t\tGetRmin() << "\" rmax=\"" << sh->GetRmax() << "\" z=\"" - << sh->GetDz() << "\" startphi=\"0.0\" deltaphi=\"360.0\" aunit=\"deg\" lunit=\"cm\"/>" << endl; + << sh->GetDz() << "\" startphi=\"0.0\" deltaphi=\"360.0\" aunit=\"deg\" lunit=\"cm\"/>" << std::endl; } else if (shape->IsA() == TGeoTubeSeg::Class()) { const TGeoTubeSeg* sh = (const TGeoTubeSeg*) shape; m_output << "\t\tGetRmin() << "\" rmax=\"" << sh->GetRmax() << "\" z=\"" << sh->GetDz() << "\" startphi=\"" << sh->GetPhi1() << "\" deltaphi=\"" << sh->GetPhi2() - << "\" aunit=\"deg\" lunit=\"cm\"/>" << endl; + << "\" aunit=\"deg\" lunit=\"cm\"/>" << std::endl; } else if (shape->IsA() == TGeoTrd1::Class()) { const TGeoTrd1* sh = (const TGeoTrd1*) shape; m_output << "\t\tGetDx1() << "\" x2=\"" << sh->GetDx2() << "\" y1=\"" - << sh->GetDy() << "\" y2=\"" << sh->GetDy() << "\" z=\"" << sh->GetDz() << "\" lunit=\"cm\"/>" << endl; + << sh->GetDy() << "\" y2=\"" << sh->GetDy() << "\" z=\"" << sh->GetDz() << "\" lunit=\"cm\"/>" << std::endl; } else if (shape->IsA() == TGeoTrd2::Class()) { const TGeoTrd2* sh = (const TGeoTrd2*) shape; m_output << "\t\tGetDx1() << "\" x2=\"" << sh->GetDx2() << "\" y1=\"" - << sh->GetDy1() << "\" y2=\"" << sh->GetDy2() << "\" z=\"" << sh->GetDz() << "\" lunit=\"cm\"/>" << endl; + << sh->GetDy1() << "\" y2=\"" << sh->GetDy2() << "\" z=\"" << sh->GetDz() << "\" lunit=\"cm\"/>" << std::endl; } else if (shape->IsA() == TGeoPgon::Class()) { const TGeoPgon* sh = (const TGeoPgon*) shape; m_output << "\t\tGetPhi1() << "\" deltaphi=\"" << sh->GetDphi() - << "\" numsides=\"" << sh->GetNedges() << "\" aunit=\"deg\" lunit=\"cm\">" << endl; + << "\" numsides=\"" << sh->GetNedges() << "\" aunit=\"deg\" lunit=\"cm\">" << std::endl; for (int i = 0; i < sh->GetNz(); ++i) { m_output << "\t\t\tGetZ(i) << "\" rmin=\"" << sh->GetRmin(i) << "\" rmax=\"" << sh->GetRmax(i) - << "\" lunit=\"cm\"/>" << endl; + << "\" lunit=\"cm\"/>" << std::endl; } - m_output << "\t\t" << endl; + m_output << "\t\t
" << std::endl; } else if (shape->IsA() == TGeoPcon::Class()) { const TGeoPcon* sh = (const TGeoPcon*) shape; m_output << "\t\tGetPhi1() << "\" deltaphi=\"" << sh->GetDphi() - << "\" aunit=\"deg\" lunit=\"cm\">" << endl; + << "\" aunit=\"deg\" lunit=\"cm\">" << std::endl; for (int i = 0; i < sh->GetNz(); ++i) { m_output << "\t\t\tGetZ(i) << "\" rmin=\"" << sh->GetRmin(i) << "\" rmax=\"" << sh->GetRmax(i) - << "\" lunit=\"cm\"/>" << endl; + << "\" lunit=\"cm\"/>" << std::endl; } - m_output << "\t\t" << endl; + m_output << "\t\t
" << std::endl; } else if (shape->IsA() == TGeoCompositeShape::Class()) { - string nn = name; + std::string nn = name; const TGeoCompositeShape* sh = (const TGeoCompositeShape*) shape; const TGeoBoolNode* boolean = sh->GetBoolNode(); TGeoBoolNode::EGeoBoolType oper = boolean->GetBooleanOperator(); @@ -161,49 +162,49 @@ void* GeometryTreeDump::handleSolid(const string& name, const TGeoShape* shape) handleSolid(name + "_right", boolean->GetRightShape()); if (oper == TGeoBoolNode::kGeoSubtraction) - m_output << "\t\t" << endl; + m_output << "\t\t" << std::endl; else if (oper == TGeoBoolNode::kGeoUnion) - m_output << "\t\t" << endl; + m_output << "\t\t" << std::endl; else if (oper == TGeoBoolNode::kGeoIntersection) - m_output << "\t\t" << endl; + m_output << "\t\t" << std::endl; - m_output << "\t\t\t" << endl; - m_output << "\t\t\t" << endl; + m_output << "\t\t\t" << std::endl; + m_output << "\t\t\t" << std::endl; indent = "\t"; handleTransformation("", boolean->GetRightMatrix()); indent = ""; if (oper == TGeoBoolNode::kGeoSubtraction) - m_output << "\t\t" << endl; + m_output << "\t\t" << std::endl; else if (oper == TGeoBoolNode::kGeoUnion) - m_output << "\t\t" << endl; + m_output << "\t\t" << std::endl; else if (oper == TGeoBoolNode::kGeoIntersection) - m_output << "\t\t" << endl; + m_output << "\t\t" << std::endl; } else { - cerr << "Failed to handle unknwon solid shape:" << shape->IsA()->GetName() << endl; + std::cerr << "Failed to handle unknwon solid shape:" << shape->IsA()->GetName() << std::endl; } } return 0; } /// Dump structure information in GDML format to output stream -void GeometryTreeDump::handleStructure(const std::set& volset) const { - m_output << "\t" << endl; +void detail::GeometryTreeDump::handleStructure(const std::set& volset) const { + m_output << "\t" << std::endl; for (const auto& vol : volset) handleVolume(vol->GetName(), vol); - m_output << "\t" << endl; + m_output << "\t" << std::endl; } /// Dump single volume transformation in GDML format to output stream -void* GeometryTreeDump::handleTransformation(const string& name, const TGeoMatrix* mat) const { +void* detail::GeometryTreeDump::handleTransformation(const std::string& name, const TGeoMatrix* mat) const { if (mat) { if (mat->IsTranslation()) { const Double_t* f = mat->GetTranslation(); m_output << indent << "\t\t" << endl; + m_output << "x=\"" << f[0] << "\" " << "y=\"" << f[1] << "\" " << "z=\"" << f[2] << "\" unit=\"cm\"/>" << std::endl; } if (mat->IsRotation()) { const Double_t* matrix = mat->GetRotationMatrix(); @@ -212,42 +213,42 @@ void* GeometryTreeDump::handleTransformation(const string& name, const TGeoMatri m_output << indent << "\t\t" << endl; + m_output << "x=\"" << theta << "\" " << "y=\"" << psi << "\" " << "z=\"" << phi << "\" unit=\"deg\"/>" << std::endl; } } return 0; } /// Dump Transformations in GDML format to output stream -void GeometryTreeDump::handleTransformations(const std::vector >& trafos) const { - m_output << "\t" << endl; - for (const auto& t : trafos ) +void detail::GeometryTreeDump::handleTransformations(const std::vector >& trafos) const { + m_output << "\t" << std::endl; + for ( const auto& t : trafos ) handleTransformation(t.first, t.second); - m_output << "\t" << endl; + m_output << "\t" << std::endl; } /// Dump all solids in GDML format to output stream -void GeometryTreeDump::handleSolids(const std::set& solids) const { - m_output << "\t" << endl; - for (const auto sh : solids ) +void detail::GeometryTreeDump::handleSolids(const std::set& solids) const { + m_output << "\t" << std::endl; + for ( const auto sh : solids ) handleSolid(sh->GetName(), sh); - m_output << "\t" << endl; + m_output << "\t" << std::endl; } /// Dump all constants in GDML format to output stream -void GeometryTreeDump::handleDefines(const Detector::HandleMap& defs) const { - m_output << "\t" << endl; - for (const auto& def : defs ) +void detail::GeometryTreeDump::handleDefines(const Detector::HandleMap& defs) const { + m_output << "\t" << std::endl; + for ( const auto& def : defs ) m_output << "\t\tname << "\" value=\"" << def.second->type << "\" />" - << endl; - m_output << "\t" << endl; + << std::endl; + m_output << "\t" << std::endl; } /// Dump all visualisation specs in Detector format to output stream -void GeometryTreeDump::handleVisualisation(const Detector::HandleMap&) const { +void detail::GeometryTreeDump::handleVisualisation(const Detector::HandleMap&) const { } -static string _path = ""; +static std::string _path = ""; static void dumpStructure(PlacedVolume pv, int level) { TGeoNode* current = pv.ptr(); TGeoVolume* volume = current->GetVolume(); @@ -290,7 +291,7 @@ static void dumpDetectors(DetElement parent, int level) { _path = _path.substr(0, _path.length() - 1 - strlen(parent.name())); } -void GeometryTreeDump::create(DetElement top) { +void detail::GeometryTreeDump::create(DetElement top) { dumpDetectors(top, 0); dumpStructure(top.placement(), 0); } diff --git a/DDCore/src/GeometryTreeDump.h b/DDCore/src/GeometryTreeDump.h index 02fe94f86..1f76989a5 100644 --- a/DDCore/src/GeometryTreeDump.h +++ b/DDCore/src/GeometryTreeDump.h @@ -14,11 +14,15 @@ #ifndef DDCORE_SRC_GEOMETRYTREEDUMP_H #define DDCORE_SRC_GEOMETRYTREEDUMP_H -#include "DD4hep/Detector.h" -#include "DD4hep/GeoHandler.h" +// Framework include files +#include +#include + +// C/C++ include files #include #include #include + class TGeoVolume; class TGeoNode; diff --git a/DDCore/src/GlobalAlignment.cpp b/DDCore/src/GlobalAlignment.cpp index 89cfc54fb..b97658a60 100644 --- a/DDCore/src/GlobalAlignment.cpp +++ b/DDCore/src/GlobalAlignment.cpp @@ -12,17 +12,15 @@ //========================================================================== // Framework include files -#include "DD4hep/GlobalAlignment.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/MatrixHelpers.h" -#include "DD4hep/Printout.h" +#include +#include +#include +#include // ROOT include files -#include "TGeoMatrix.h" -#include "TGeoManager.h" +#include +#include - -using namespace std; using namespace dd4hep; using namespace dd4hep::align; @@ -30,14 +28,14 @@ namespace { struct CheckHandle { CheckHandle(const GlobalAlignment& a) { if ( a.isValid() ) return; - throw runtime_error("dd4hep: Attempt to access invalid alignment object. [Invalid Handle]"); + except("dd4hep:GlobalAlignment", "Attempt to access invalid alignment object. [Invalid Handle]"); } ~CheckHandle() {} }; } /// Initializing constructor to create a new object -GlobalAlignment::GlobalAlignment(const string& path) { +GlobalAlignment::GlobalAlignment(const std::string& path) { //cout << "GlobalAlignment: path=" << path << endl; m_element = new TGeoPhysicalNode(path.c_str()); } @@ -59,8 +57,9 @@ PlacedVolume GlobalAlignment::nodePlacement(int level) const { CheckHandle verify_handle(*this); TGeoNode* n = ptr()->GetNode(level); if ( n ) return n; - throw runtime_error("dd4hep: The object chain of "+string(placement().name())+ - " is too short. [Invalid index]"); + except("dd4hep:GlobalAlignment", + "The object chain of %s is too short. [Invalid index]", placement().name()); + return {}; } /// Access the placement of the mother of this node @@ -70,7 +69,9 @@ PlacedVolume GlobalAlignment::motherPlacement(int level_up) const { if ( ind >= 0 ) { return ptr()->GetMother(level_up); } - throw runtime_error("dd4hep: This object "+string(placement().name())+" has not enough mothers. [Invalid index]"); + except("dd4hep:GlobalAlignment", + "This object %s has not enough mothers. [Invalid index]", placement().name()); + return {}; } /// Access the currently applied alignment/placement matrix diff --git a/DDCore/src/Grammar.cpp b/DDCore/src/Grammar.cpp index 12a6498c0..5b1c9a26b 100644 --- a/DDCore/src/Grammar.cpp +++ b/DDCore/src/Grammar.cpp @@ -12,15 +12,15 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/Primitives.h" -#include "DD4hep/Exceptions.h" -#include "DD4hep/Grammar.h" -#include "Evaluator/Evaluator.h" +#include +#include +#include +#include +#include // ROOT include files -#include "TDataType.h" -#include "TROOT.h" +#include +#include // C/C++ include files #include diff --git a/DDCore/src/GrammarTypes.cpp b/DDCore/src/GrammarTypes.cpp index e3c20a286..df20d760d 100644 --- a/DDCore/src/GrammarTypes.cpp +++ b/DDCore/src/GrammarTypes.cpp @@ -14,9 +14,9 @@ // Framework include files #include -#include "Math/Point3D.h" -#include "Math/Vector4D.h" -#include "Math/Vector3D.h" +#include +#include +#include #ifndef DD4HEP_PARSERS_NO_ROOT diff --git a/DDCore/src/GrammarTypesUnparsed.cpp b/DDCore/src/GrammarTypesUnparsed.cpp index ed94cb39b..42db6d638 100644 --- a/DDCore/src/GrammarTypesUnparsed.cpp +++ b/DDCore/src/GrammarTypesUnparsed.cpp @@ -12,7 +12,7 @@ //========================================================================== // Framework include files -#include "DD4hep/GrammarUnparsed.h" +#include // C/C++ include files #include diff --git a/DDCore/src/Handle.cpp b/DDCore/src/Handle.cpp index c947af983..2fa5b4b1b 100644 --- a/DDCore/src/Handle.cpp +++ b/DDCore/src/Handle.cpp @@ -36,7 +36,6 @@ namespace { } using namespace dd4hep; -using namespace dd4hep::detail; namespace { diff --git a/DDCore/src/IDDescriptor.cpp b/DDCore/src/IDDescriptor.cpp index 4c163d139..0b0d494e6 100644 --- a/DDCore/src/IDDescriptor.cpp +++ b/DDCore/src/IDDescriptor.cpp @@ -11,21 +11,23 @@ // //========================================================================== +// Framework include files #include "DD4hep/IDDescriptor.h" #include "DD4hep/detail/Handle.inl" #include "DD4hep/detail/ObjectsInterna.h" #include "DD4hep/InstanceCount.h" #include "DD4hep/Volumes.h" #include "DD4hep/Printout.h" + +// C/C++ include files #include #include #include -using namespace std; + using namespace dd4hep; -using namespace dd4hep::detail; namespace { - void _construct(IDDescriptor::Object* o, const string& dsc) { + void _construct(IDDescriptor::Object* o, const std::string& dsc) { BitFieldCoder& bf = o->decoder; o->fieldIDs.clear(); o->fieldMap.clear(); @@ -39,23 +41,23 @@ namespace { } /// Initializing constructor -IDDescriptor::IDDescriptor(const string& nam, const string& description) { +IDDescriptor::IDDescriptor(const std::string& nam, const std::string& description) { Object* obj = new Object(description); assign(obj, nam, "iddescriptor"); _construct(obj, description); } /// Re-build object in place -void IDDescriptor::rebuild(const string& description) { +void IDDescriptor::rebuild(const std::string& description) { Object* p = ptr(); - string dsc = description; + std::string dsc = description; p->decoder.~BitFieldCoder(); new(&p->decoder) BitFieldCoder(dsc); _construct(p, dsc); } -/// Acces string representation -string IDDescriptor::toString() const { +/// Acces std::string representation +std::string IDDescriptor::toString() const { if ( isValid() ) { return m_element->GetName(); } @@ -77,7 +79,8 @@ const IDDescriptor::FieldIDs& IDDescriptor::ids() const { if ( isValid() ) { return data()->fieldIDs; } - throw runtime_error("dd4hep: Attempt to access an invalid IDDescriptor object."); + except("IDDescriptor","dd4hep: Attempt to access an invalid IDDescriptor object."); + throw std::runtime_error("dd4hep"); // Never called. Simply make the compiler happy! } /// Access the fieldmap container @@ -85,18 +88,19 @@ const IDDescriptor::FieldMap& IDDescriptor::fields() const { if ( isValid() ) { return data()->fieldMap; } - throw runtime_error("dd4hep: Attempt to access an invalid IDDescriptor object."); + except("IDDescriptor","dd4hep: Attempt to access an invalid IDDescriptor object."); + throw std::runtime_error("dd4hep"); // Never called. Simply make the compiler happy! } /// Get the field descriptor of one field by name -const BitFieldElement* IDDescriptor::field(const string& field_name) const { +const BitFieldElement* IDDescriptor::field(const std::string& field_name) const { const FieldMap& fm = fields(); // This already checks the object validity for (const auto& i : fm ) if (i.first == field_name) return i.second; except("IDDescriptor","dd4hep: %s: This ID descriptor has no field with the name: %s", name(),field_name.c_str()); - throw runtime_error("dd4hep"); // Never called. Simply make the compiler happy! + throw std::runtime_error("dd4hep"); // Never called. Simply make the compiler happy! } /// Get the field descriptor of one field by its identifier @@ -106,14 +110,14 @@ const BitFieldElement* IDDescriptor::field(size_t identifier) const { } /// Get the field identifier of one field by name -size_t IDDescriptor::fieldID(const string& field_name) const { +std::size_t IDDescriptor::fieldID(const std::string& field_name) const { const FieldIDs& fm = ids(); // This already checks the object validity for (const auto& i : fm ) if (i.second == field_name) return i.first; except("IDDescriptor","dd4hep: %s: This ID descriptor has no field with the name: %s", name(),field_name.c_str()); - throw runtime_error("dd4hep"); // Never called. Simply make the compiler happy! + throw std::runtime_error("dd4hep"); // Never called. Simply make the compiler happy! } /// Compute the submask for a given set of volume IDs @@ -158,34 +162,36 @@ VolumeID IDDescriptor::encode_reverse(const std::vector >& flds) const + std::vector >& flds) const { - const vector& v = access()->decoder.fields(); + const std::vector& v = access()->decoder.fields(); flds.clear(); for (auto& f : v ) flds.emplace_back(&f, f.value(vid)); } /// Decode volume IDs and return string reprensentation for debugging purposes -string IDDescriptor::str(VolumeID vid) const { - const vector& v = access()->decoder.fields(); - stringstream str; +std::string IDDescriptor::str(VolumeID vid) const { + const std::vector& v = access()->decoder.fields(); + std::stringstream str; for (auto& f : v ) - str << f.name() << ":" << setw(4) << setfill('0') << hex << right << f.value(vid) - << left << dec << " "; - return str.str().substr(0,str.str().length()-1); + str << f.name() << ":" << std::setw(4) << std::setfill('0') + << std::hex << std::right << f.value(vid) + << std::left << std::dec << " "; + return str.str().substr(0, str.str().length()-1); } /// Decode volume IDs and return string reprensentation for debugging purposes -string IDDescriptor::str(VolumeID vid, VolumeID mask) const { - const vector& v = access()->decoder.fields(); - stringstream str; +std::string IDDescriptor::str(VolumeID vid, VolumeID mask) const { + const std::vector& v = access()->decoder.fields(); + std::stringstream str; for (auto& f : v ) { if ( 0 == (mask&f.mask()) ) continue; - str << f.name() << ":" << setw(4) << setfill('0') << hex << right << f.value(vid) - << left << dec << " "; + str << f.name() << ":" << std::setw(4) << std::setfill('0') + << std::hex << std::right << f.value(vid) + << std::left << std::dec << " "; } - return str.str().substr(0,str.str().length()-1); + return str.str().substr(0, str.str().length()-1); } /// Access the BitFieldCoder object diff --git a/DDCore/src/IOV.cpp b/DDCore/src/IOV.cpp index 4949639b0..88a89e9e0 100644 --- a/DDCore/src/IOV.cpp +++ b/DDCore/src/IOV.cpp @@ -12,16 +12,15 @@ //========================================================================== // Framework includes -#include "DD4hep/IOV.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Primitives.h" +#include +#include +#include // C/C++ include files #include #include #include -using namespace std; using namespace dd4hep; #if __cplusplus == 201402 @@ -139,7 +138,7 @@ void IOV::move(IOV& from) { } /// Create string representation of the IOV -string IOV::str() const { +std::string IOV::str() const { char text[256]; if ( iovType ) { /// Need the long(x) casts for compatibility with Apple MAC @@ -152,8 +151,8 @@ string IOV::str() const { char c_since[64], c_until[64]; static constexpr const Key_value_type nil = 0; static const Key_value_type max_time = detail::makeTime(2099,12,31,24,59,59); - time_t since = std::min(std::max(keyData.first, nil), max_time); - time_t until = std::min(std::max(keyData.second,nil), max_time); + std::time_t since = std::min(std::max(keyData.first, nil), max_time); + std::time_t until = std::min(std::max(keyData.second,nil), max_time); struct tm* tm_since = ::gmtime_r(&since,&time_buff); struct tm* tm_until = ::gmtime_r(&until,&time_buff); if ( nullptr == tm_since || nullptr == tm_until ) { @@ -164,7 +163,7 @@ string IOV::str() const { ::strftime(c_until,sizeof(c_until),"%d-%m-%Y %H:%M:%S", tm_until); ::snprintf(text,sizeof(text),"%s(%u):[%s - %s]", iovType->name.c_str(), iovType->type, - c_since, c_until); + c_since, c_until); } else { ::snprintf(text,sizeof(text),"%s(%u):[%ld-%ld]", diff --git a/DDCore/src/InstanceCount.cpp b/DDCore/src/InstanceCount.cpp index 74a0f9320..e0d68a955 100644 --- a/DDCore/src/InstanceCount.cpp +++ b/DDCore/src/InstanceCount.cpp @@ -12,9 +12,9 @@ //========================================================================== /// Framework include files -#include "DD4hep/InstanceCount.h" -#include "DD4hep/Handle.h" -#include "DD4hep/Memory.h" +#include +#include +#include /// C/C++ include files #include @@ -32,13 +32,13 @@ namespace { typedef InstanceCount::Counter COUNT; typedef std::map TypeCounter; typedef std::map StringCounter; - static bool s_trace_instances = ::getenv("DD4HEP_TRACE") != 0; - static dd4hep_ptr s_typCounts(new TypeCounter()); - static dd4hep_ptr s_strCounts(new StringCounter()); - static InstanceCount::Counter s_nullCount; - static InstanceCount::Counter s_thisCount; - static InstanceCount s_counter; - inline TypeCounter& types() { + static bool s_trace_instances = ::getenv("DD4HEP_TRACE") != 0; + static dd4hep_ptr s_typCounts(new TypeCounter()); + static dd4hep_ptr s_strCounts(new StringCounter()); + static InstanceCount::Counter s_nullCount; + static InstanceCount::Counter s_thisCount; + static InstanceCount s_counter; + inline TypeCounter& types() { return *(s_typCounts.get()); } inline StringCounter& strings() { diff --git a/DDCore/src/MatrixHelpers.cpp b/DDCore/src/MatrixHelpers.cpp index d7e7ce928..6c698bdcd 100644 --- a/DDCore/src/MatrixHelpers.cpp +++ b/DDCore/src/MatrixHelpers.cpp @@ -12,8 +12,8 @@ //========================================================================== // Framework include files -#include "DD4hep/MatrixHelpers.h" -#include "DD4hep/DD4hepUnits.h" +#include +#include #ifdef DD4HEP_USE_GEANT4_UNITS #define MM_2_CM 1.0 @@ -22,7 +22,7 @@ #endif // ROOT includes -#include "TGeoMatrix.h" +#include TGeoIdentity* dd4hep::detail::matrix::_identity() { return gGeoIdentity; diff --git a/DDCore/src/MultiSegmentation.cpp b/DDCore/src/MultiSegmentation.cpp index 7cc357cdc..e06dc799d 100644 --- a/DDCore/src/MultiSegmentation.cpp +++ b/DDCore/src/MultiSegmentation.cpp @@ -12,12 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/MultiSegmentation.h" -#include "DDSegmentation/MultiSegmentation.h" +#include +#include -// C/C++ include files - -using namespace std; using namespace dd4hep; /// access the field name used to discriminate sub-segmentations @@ -43,8 +40,8 @@ Position MultiSegmentation::position(const CellID& id) const { /// determine the cell ID based on the position dd4hep::CellID MultiSegmentation::cellID(const Position& local, - const Position& global, - const VolumeID& volID) const + const Position& global, + const VolumeID& volID) const { return access()->implementation->cellID(local, global, volID); } @@ -58,6 +55,6 @@ dd4hep::CellID MultiSegmentation::cellID(const Position& local, -# size in x -# size in y */ -vector MultiSegmentation::cellDimensions(const CellID& id) const { +std::vector MultiSegmentation::cellDimensions(const CellID& id) const { return access()->implementation->cellDimensions(id); } diff --git a/DDCore/src/NamedObject.cpp b/DDCore/src/NamedObject.cpp index 80d53634e..7d60da0af 100644 --- a/DDCore/src/NamedObject.cpp +++ b/DDCore/src/NamedObject.cpp @@ -12,26 +12,23 @@ //========================================================================== // Framework includes -#include "DD4hep/NamedObject.h" -#include "DD4hep/detail/Handle.inl" -#include "TNamed.h" - -using namespace std; -using namespace dd4hep; -using namespace dd4hep::detail; +#include +#include +#include namespace dd4hep { template <> const char* Handle::name() const { return this->m_element ? this->m_element->name.c_str() : ""; } template <> void - Handle::assign(NamedObject* p, const string& n, const string& t){ + Handle::assign(NamedObject* p, const std::string& n, const std::string& t){ m_element = p; p->name = n; p->type = t; } } -template class dd4hep::Handle; +template class dd4hep::Handle; +using namespace dd4hep; /// Initializing constructor NamedObject::NamedObject(const char* nam, const char* typ) diff --git a/DDCore/src/NoSegmentation.cpp b/DDCore/src/NoSegmentation.cpp index 7b226f90f..cc2ce3430 100644 --- a/DDCore/src/NoSegmentation.cpp +++ b/DDCore/src/NoSegmentation.cpp @@ -12,12 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/NoSegmentation.h" -#include "DDSegmentation/NoSegmentation.h" +#include +#include -// C/C++ include files - -using namespace std; using namespace dd4hep; Position NoSegmentation::position(const CellID& id) const { @@ -26,8 +23,8 @@ Position NoSegmentation::position(const CellID& id) const { /// determine the cell ID based on the position dd4hep::CellID NoSegmentation::cellID(const Position& local, - const Position& global, - const VolumeID& volID) const + const Position& global, + const VolumeID& volID) const { return access()->implementation->cellID(local, global, volID); } diff --git a/DDCore/src/ObjectExtensions.cpp b/DDCore/src/ObjectExtensions.cpp index 3a5969bf1..9979aca91 100644 --- a/DDCore/src/ObjectExtensions.cpp +++ b/DDCore/src/ObjectExtensions.cpp @@ -17,10 +17,6 @@ #include "DD4hep/Primitives.h" #include "DD4hep/Printout.h" -// C/C++ include files -#include - -using namespace std; using namespace dd4hep; namespace { @@ -31,7 +27,7 @@ namespace { } /// Default constructor -ObjectExtensions::ObjectExtensions(const type_info& /* parent_type */) { +ObjectExtensions::ObjectExtensions(const std::type_info& /* parent_type */) { InstanceCount::increment(this); } @@ -59,7 +55,7 @@ void ObjectExtensions::clear(bool destroy) { } /// Copy object extensions from another object -void ObjectExtensions::copyFrom(const map& ext, void* arg) { +void ObjectExtensions::copyFrom(const std::map& ext, void* arg) { for( const auto& i : ext ) { extensions[i.first] = i.second->clone(arg); } @@ -79,7 +75,7 @@ void* ObjectExtensions::addExtension(unsigned long long int key, ExtensionEntry* except("ObjectExtensions::addExtension","Invalid extension object for key %016llX!",key); } except("ObjectExtensions::addExtension","Invalid extension entry for key %016llX!",key); - return 0; + return nullptr; } /// Remove an existing extension object from the instance @@ -95,7 +91,7 @@ void* ObjectExtensions::removeExtension(unsigned long long int key, bool destroy return ptr; } except("ObjectExtensions::removeExtension","The object of type %016llX is not present.",key); - return 0; + return nullptr; } /// Access an existing extension object from the detector element @@ -104,8 +100,8 @@ void* ObjectExtensions::extension(unsigned long long int key) const { if (j != extensions.end()) { return (*j).second->object(); } - string msg = format("ObjectExtensions::extension","The object has no extension of type %016llX.",key); - throw runtime_error(msg); + except("ObjectExtensions::extension","The object has no extension of type %016llX.",key); + return nullptr; } /// Access an existing extension object from the detector element @@ -116,6 +112,6 @@ void* ObjectExtensions::extension(unsigned long long int key, bool alert) const } else if ( !alert ) return 0; - string msg = format("ObjectExtensions::extension","The object has no extension of type %016llX.",key); - throw runtime_error(msg); + except("ObjectExtensions::extension","The object has no extension of type %016llX.",key); + return nullptr; } diff --git a/DDCore/src/ObjectsInterna.cpp b/DDCore/src/ObjectsInterna.cpp index 76e788bf2..04008b158 100644 --- a/DDCore/src/ObjectsInterna.cpp +++ b/DDCore/src/ObjectsInterna.cpp @@ -18,9 +18,8 @@ #include #include -using namespace std; + using namespace dd4hep; -using namespace dd4hep::detail; DD4HEP_INSTANTIATE_HANDLE_NAMED(VisAttrObject); @@ -55,7 +54,7 @@ ConstantObject::ConstantObject() { } /// Standard constructor -ConstantObject::ConstantObject(const string& nam, const string& val, const string& typ) +ConstantObject::ConstantObject(const std::string& nam, const std::string& val, const std::string& typ) : NamedObject(nam.c_str(), val.c_str()) { dataType = typ; InstanceCount::increment(this); diff --git a/DDCore/src/OpaqueData.cpp b/DDCore/src/OpaqueData.cpp index 36fa8189e..26a27a810 100644 --- a/DDCore/src/OpaqueData.cpp +++ b/DDCore/src/OpaqueData.cpp @@ -12,47 +12,46 @@ //========================================================================== // Framework includes -#include "DD4hep/Printout.h" -#include "DD4hep/Primitives.h" -#include "DD4hep/OpaqueData.h" -#include "DD4hep/InstanceCount.h" +#include +#include +#include +#include // C/C++ header files #include -using namespace std; using namespace dd4hep; /// Create data block from string representation -bool OpaqueData::fromString(const string& rep) { +bool OpaqueData::fromString(const std::string& rep) { if ( pointer && grammar ) { return grammar->fromString(pointer,rep); } - throw runtime_error("Opaque data block is unbound. Cannot parse string representation."); + throw std::runtime_error("Opaque data block is unbound. Cannot parse string representation."); } /// Create string representation of the data block -string OpaqueData::str() const { +std::string OpaqueData::str() const { if ( pointer && grammar ) { return grammar->str(pointer); } - throw runtime_error("Opaque data block is unbound. Cannot create string representation."); + throw std::runtime_error("Opaque data block is unbound. Cannot create string representation."); } /// Access type id of the condition -const type_info& OpaqueData::typeInfo() const { +const std::type_info& OpaqueData::typeInfo() const { if ( pointer && grammar ) { return grammar->type(); } - throw runtime_error("Opaque data block is unbound. Cannot determine type information!"); + throw std::runtime_error("Opaque data block is unbound. Cannot determine type information!"); } /// Access type name of the condition data block -const string& OpaqueData::dataType() const { +const std::string& OpaqueData::dataType() const { if ( pointer && grammar ) { return grammar->type_name(); } - throw runtime_error("Opaque data block is unbound. Cannot determine type information!"); + throw std::runtime_error("Opaque data block is unbound. Cannot determine type information!"); } /// Standard initializing constructor @@ -71,7 +70,7 @@ OpaqueDataBlock::OpaqueDataBlock(const OpaqueDataBlock& c) } else { except("OpaqueDataBlock","Grammar type %s does not support object copy. Operation not allowed.", - this->grammar->type_name().c_str()); + this->grammar->type_name().c_str()); } InstanceCount::increment(this); } @@ -103,10 +102,10 @@ OpaqueDataBlock& OpaqueDataBlock::operator=(const OpaqueDataBlock& c) { type = c.type; grammar = 0; if ( c.grammar ) { - if ( !c.grammar->specialization.copy ) { - except("OpaqueDataBlock","Grammar type %s does not support object copy. Operation not allowed.", - c.grammar->type_name().c_str()); - } + if ( !c.grammar->specialization.copy ) { + except("OpaqueDataBlock","Grammar type %s does not support object copy. Operation not allowed.", + c.grammar->type_name().c_str()); + } bind(c.grammar); grammar->specialization.copy(pointer,c.pointer); return *this; @@ -180,5 +179,5 @@ void* OpaqueDataBlock::bind(void* ptr, size_t size, const BasicGrammar* g) { return 0; } -#include "DD4hep/GrammarUnparsed.h" +#include static auto s_registry = GrammarRegistry::pre_note(1); diff --git a/DDCore/src/OpaqueDataBinder.cpp b/DDCore/src/OpaqueDataBinder.cpp index 4f22152fb..f9d2a2a6e 100644 --- a/DDCore/src/OpaqueDataBinder.cpp +++ b/DDCore/src/OpaqueDataBinder.cpp @@ -12,9 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/OpaqueDataBinder.h" -#include "DD4hep/Conditions.h" -#include "DD4hep/detail/ConditionsInterna.h" +#include +#include +#include // C/C++ include files #include @@ -22,30 +22,27 @@ #include #include -using namespace std; - namespace { - using namespace dd4hep::detail; - + /// Helper class to bind string values to C++ data objects (primitive or complex) - template bool __bind__(const ValueBinder&, T& object, const string& val, const Q*) - { object.template bind(val); return true; } + template bool __bind__(const dd4hep::detail::ValueBinder&, T& object, const std::string& val, const Q*) + { object.template bind(val); return true; } /// Helper class to bind string values to a STL vector of data objects (primitive or complex) - template bool __bind__(const VectorBinder&, T& object, const string& val, const Q*) - { object.template bind >(val); return true; } + template bool __bind__(const dd4hep::detail::VectorBinder&, T& object, const std::string& val, const Q*) + { object.template bind >(val); return true; } /// Helper class to bind string values to a STL list of data objects (primitive or complex) - template bool __bind__(const ListBinder&, T& object, const string& val, const Q*) - { object.template bind >(val); return true; } + template bool __bind__(const dd4hep::detail::ListBinder&, T& object, const std::string& val, const Q*) + { object.template bind >(val); return true; } /// Helper class to bind string values to a STL set of data objects (primitive or complex) - template bool __bind__(const SetBinder&, T& object, const string& val, const Q*) - { object.template bind >(val); return true; } + template bool __bind__(const dd4hep::detail::SetBinder&, T& object, const std::string& val, const Q*) + { object.template bind >(val); return true; } /// Helper class to bind STL map objects - template bool __bind__(const MapBinder&, T& object, const Q*) - { object.template bind(); return true; } + template bool __bind__(const dd4hep::detail::MapBinder&, T& object, const Q*) + { object.template bind(); return true; } } @@ -57,7 +54,7 @@ namespace dd4hep { /// Binding function for scalar items. See the implementation function for the concrete instantiations template - bool OpaqueDataBinder::bind(const BINDER& b, T& object, const string& typ, const string& val) { + bool OpaqueDataBinder::bind(const BINDER& b, T& object, const std::string& typ, const std::string& val) { #if defined(DD4HEP_HAVE_ALL_PARSERS) if ( typ.substr(0,4) == "char" ) return __bind__(b,object,val,Primitive::null_pointer()); @@ -87,49 +84,49 @@ namespace dd4hep { else if ( typ.substr(0,6) == "double" ) return __bind__(b,object,val,Primitive::null_pointer()); else if ( typ.substr(0,6) == "string" ) - return __bind__(b,object,val,Primitive::null_pointer()); + return __bind__(b,object,val,Primitive::null_pointer()); else if ( typ == "std::string" ) - return __bind__(b,object,val,Primitive::null_pointer()); + return __bind__(b,object,val,Primitive::null_pointer()); else if ( typ == "Histo1D" ) - return __bind__(b,object,val,Primitive::null_pointer()); + return __bind__(b,object,val,Primitive::null_pointer()); else if ( typ == "Histo2D" ) - return __bind__(b,object,val,Primitive::null_pointer()); + return __bind__(b,object,val,Primitive::null_pointer()); else printout(INFO,"OpaqueDataBinder","++ Unknown conditions parameter type:%s val:%s",typ.c_str(),val.c_str()); - return __bind__(b,object,val,Primitive::null_pointer()); + return __bind__(b,object,val,Primitive::null_pointer()); } template bool OpaqueDataBinder::bind( const ValueBinder& b, OpaqueDataBlock& object, - const string& typ, const string& val); + const std::string& typ, const std::string& val); template bool OpaqueDataBinder::bind( const VectorBinder& b, OpaqueDataBlock& object, - const string& typ, const string& val); + const std::string& typ, const std::string& val); template bool OpaqueDataBinder::bind( const ListBinder& b, OpaqueDataBlock& object, - const string& typ, const string& val); + const std::string& typ, const std::string& val); template bool OpaqueDataBinder::bind( const SetBinder& b, OpaqueDataBlock& object, - const string& typ, const string& val); + const std::string& typ, const std::string& val); template bool OpaqueDataBinder::bind( const ValueBinder& b, Condition& object, - const string& typ, const string& val); + const std::string& typ, const std::string& val); template bool OpaqueDataBinder::bind( const VectorBinder& b, Condition& object, - const string& typ, const string& val); + const std::string& typ, const std::string& val); template bool OpaqueDataBinder::bind( const ListBinder& b, Condition& object, - const string& typ, const string& val); + const std::string& typ, const std::string& val); template bool OpaqueDataBinder::bind( const SetBinder& b, Condition& object, - const string& typ, const string& val); + const std::string& typ, const std::string& val); /// Binding function for sequences (unmapped STL containers) template - bool OpaqueDataBinder::bind_sequence(T& object, const string& typ, const string& val) + bool OpaqueDataBinder::bind_sequence(T& object, const std::string& typ, const std::string& val) { - size_t idx = typ.find('['); - size_t idq = typ.find(']'); - string value_type = typ.substr(idx+1,idq-idx-1); + std::size_t idx = typ.find('['); + std::size_t idq = typ.find(']'); + std::string value_type = typ.substr(idx+1,idq-idx-1); if ( typ.substr(0,6) == "vector" ) return bind(VectorBinder(), object, value_type, val); else if ( typ.substr(0,4) == "list" ) return bind(ListBinder(), object, value_type, val); else if ( typ.substr(0,3) == "set" ) return bind(SetBinder(), object, value_type, val); - else if ( idx == string::npos && idq == string::npos ) + else if ( idx == std::string::npos && idq == std::string::npos ) return bind(ValueBinder(), object, value_type, val); return false; } @@ -138,10 +135,10 @@ namespace dd4hep { static void emplace_map_item(const BINDER&, OBJECT& object, const KEY& k, - const string& val, + const std::string& val, const VAL*) { - typedef map map_t; + typedef std::map map_t; map_t& m = object.template get(); VAL v; if ( !BasicGrammar::instance().fromString(&v, val) ) { @@ -153,9 +150,9 @@ namespace dd4hep { template static void emplace_map_key(const BINDER& b, OBJECT& object, - const string& key_val, - const string& val_type, - const string& val, + const std::string& key_val, + const std::string& val_type, + const std::string& val, const KEY*) { KEY key; @@ -174,27 +171,27 @@ namespace dd4hep { else if ( val_type.substr(0,6) == "double" ) emplace_map_item(b, object, key, val, (double*)0); else if ( val_type.substr(0,6) == "string" ) - emplace_map_item(b, object, key, val, (string*)0); + emplace_map_item(b, object, key, val, (std::string*)0); else if ( val_type == "std::string" ) - emplace_map_item(b, object, key, val, (string*)0); + emplace_map_item(b, object, key, val, (std::string*)0); else { printout(INFO,"Param","++ Unknown conditions parameter type:%s data:%s", val_type.c_str(),val.c_str()); - emplace_map_item(b, object, key, val, (string*)0); + emplace_map_item(b, object, key, val, (std::string*)0); } } template static void emplace_map_pair(const BINDER&, OBJECT& object, - const string& data, + const std::string& data, const KEY*, const VAL*) { - typedef map map_t; - pair entry; + typedef std::map map_t; + std::pair entry; map_t& m = object.template get(); - if ( !BasicGrammar::instance >().fromString(&entry,data) ) { + if ( !BasicGrammar::instance >().fromString(&entry,data) ) { except("OpaqueDataBinder","++ Failed to convert conditions map entry."); } m.emplace(entry); @@ -203,8 +200,8 @@ namespace dd4hep { template static void emplace_map_data(const BINDER& b, OBJECT& object, - const string& val_type, - const string& pair_data, + const std::string& val_type, + const std::string& pair_data, const KEY*) { // Short and char is not part of the standard dictionaries. Fall back to 'int'. @@ -221,59 +218,59 @@ namespace dd4hep { else if ( val_type.substr(0,6) == "double" ) emplace_map_pair(b, object, pair_data, (KEY*)0, (double*)0); else if ( val_type.substr(0,6) == "string" ) - emplace_map_pair(b, object, pair_data, (KEY*)0, (string*)0); + emplace_map_pair(b, object, pair_data, (KEY*)0, (std::string*)0); else if ( val_type == "std::string" ) - emplace_map_pair(b, object, pair_data, (KEY*)0, (string*)0); + emplace_map_pair(b, object, pair_data, (KEY*)0, (std::string*)0); else { printout(INFO,"Param","++ Unknown conditions parameter type:%s data:%s", val_type.c_str(),pair_data.c_str()); - emplace_map_pair(b, object, pair_data, (KEY*)0, (string*)0); + emplace_map_pair(b, object, pair_data, (KEY*)0, (std::string*)0); } } template - static void bind_mapping(const BINDER& b, const string& val_type, OBJECT& object, const KEY*) { + static void bind_mapping(const BINDER& b, const std::string& val_type, OBJECT& object, const KEY*) { if ( val_type.substr(0,3) == "int" ) - __bind__(b,object, (map*)0); + __bind__(b,object, (std::map*)0); #if defined(DD4HEP_HAVE_ALL_PARSERS) else if ( val_type.substr(0,12) == "unsigned int" ) - __bind__(b,object, (map*)0); + __bind__(b,object, (std::map*)0); else if ( val_type.substr(0,4) == "char" ) - __bind__(b,object, (map*)0); + __bind__(b,object, (std::map*)0); else if ( val_type.substr(0,13) == "unsigned char" ) - __bind__(b,object, (map*)0); + __bind__(b,object, (std::map*)0); else if ( val_type.substr(0,5) == "short" ) - __bind__(b,object, (map*)0); + __bind__(b,object, (std::map*)0); else if ( val_type.substr(0,14) == "unsigned short" ) - __bind__(b,object, (map*)0); + __bind__(b,object, (std::map*)0); else if ( val_type.substr(0,13) == "unsigned long" ) - __bind__(b,object, (map*)0); + __bind__(b,object, (std::map*)0); #else // Short and char is not part of the standard dictionaries. Fall back to 'int'. else if ( val_type.substr(0,4) == "char" ) - __bind__(b,object, (map*)0); + __bind__(b,object, (std::map*)0); else if ( val_type.substr(0,5) == "short" ) - __bind__(b,object, (map*)0); + __bind__(b,object, (std::map*)0); #endif else if ( val_type.substr(0,4) == "long" ) - __bind__(b,object, (map*)0); + __bind__(b,object, (std::map*)0); else if ( val_type.substr(0,5) == "float" ) - __bind__(b,object, (map*)0); + __bind__(b,object, (std::map*)0); else if ( val_type.substr(0,6) == "double" ) - __bind__(b,object, (map*)0); + __bind__(b,object, (std::map*)0); else if ( val_type.substr(0,6) == "string" ) - __bind__(b,object, (map*)0); + __bind__(b,object, (std::map*)0); else if ( val_type == "std::string" ) - __bind__(b,object, (map*)0); + __bind__(b,object, (std::map*)0); else { - __bind__(b,object, (map*)0); + __bind__(b,object, (std::map*)0); } } /// Binding function for STL maps template bool OpaqueDataBinder::bind_map(const BINDER& b, OBJECT& object, - const string& key_type, const string& val_type) { + const std::string& key_type, const std::string& val_type) { // Short and char is not part of the standard dictionaries. Fall back to 'int'. if ( key_type.substr(0,3) == "int" ) bind_mapping(b, val_type, object, Primitive::null_pointer()); @@ -290,12 +287,12 @@ namespace dd4hep { bind_mapping(b, val_type, object, Primitive::null_pointer()); #endif else if ( key_type.substr(0,6) == "string" ) - bind_mapping(b, val_type, object, Primitive::null_pointer()); + bind_mapping(b, val_type, object, Primitive::null_pointer()); else if ( key_type == "std::string" ) - bind_mapping(b, val_type, object, Primitive::null_pointer()); + bind_mapping(b, val_type, object, Primitive::null_pointer()); else { printout(INFO,"OpaqueDataBinder","++ Unknown MAP-conditions key-type:%s",key_type.c_str()); - bind_mapping(b, val_type, object, Primitive::null_pointer()); + bind_mapping(b, val_type, object, Primitive::null_pointer()); } return true; } @@ -303,8 +300,8 @@ namespace dd4hep { /// Filling function for STL maps. template bool OpaqueDataBinder::insert_map(const BINDER& b, OBJECT& object, - const string& key_type, const string& key, - const string& val_type, const string& val) + const std::string& key_type, const std::string& key, + const std::string& val_type, const std::string& val) { if ( key_type.substr(0,3) == "int" ) emplace_map_key(b, object, key, val_type, val, Primitive::null_pointer()); @@ -322,12 +319,12 @@ namespace dd4hep { emplace_map_key(b, object, key, val_type, val, Primitive::null_pointer()); #endif else if ( key_type.substr(0,6) == "string" ) - emplace_map_key(b, object, key, val_type, val, Primitive::null_pointer()); + emplace_map_key(b, object, key, val_type, val, Primitive::null_pointer()); else if ( key_type == "std::string" ) - emplace_map_key(b, object, key, val_type, val, Primitive::null_pointer()); + emplace_map_key(b, object, key, val_type, val, Primitive::null_pointer()); else { printout(INFO,"OpaqueDataBinder","++ Unknown MAP-conditions key-type:%s",key_type.c_str()); - emplace_map_key(b, object, key, val_type, val, Primitive::null_pointer()); + emplace_map_key(b, object, key, val_type, val, Primitive::null_pointer()); } return true; } @@ -354,43 +351,43 @@ namespace dd4hep { emplace_map_data(b, object, val_type, pair_data, Primitive::null_pointer()); #endif else if ( key_type.substr(0,6) == "string" ) - emplace_map_data(b, object, val_type, pair_data, Primitive::null_pointer()); + emplace_map_data(b, object, val_type, pair_data, Primitive::null_pointer()); else if ( key_type == "std::string" ) - emplace_map_data(b, object, val_type, pair_data, Primitive::null_pointer()); + emplace_map_data(b, object, val_type, pair_data, Primitive::null_pointer()); else { printout(INFO,"OpaqueDataBinder","++ Unknown MAP-conditions key-type:%s",key_type.c_str()); - emplace_map_data(b, object, val_type, pair_data, Primitive::null_pointer()); + emplace_map_data(b, object, val_type, pair_data, Primitive::null_pointer()); } return true; } - template bool OpaqueDataBinder::bind_sequence(OpaqueDataBlock& object,const string& typ,const string& val); + template bool OpaqueDataBinder::bind_sequence(OpaqueDataBlock& object,const std::string& typ,const std::string& val); template bool OpaqueDataBinder::bind_map( const MapBinder& b, OpaqueDataBlock& object, - const string& typ,const string& val); + const std::string& typ,const std::string& val); template bool OpaqueDataBinder::insert_map( const MapBinder& b, OpaqueDataBlock& object, - const string& key_type, const string& key, - const string& val_type, const string& val); + const std::string& key_type, const std::string& key, + const std::string& val_type, const std::string& val); template bool OpaqueDataBinder::insert_map( const MapBinder& b, OpaqueDataBlock& object, - const string& key_type, const string& val_type, - const string& pair_data); + const std::string& key_type, const std::string& val_type, + const std::string& pair_data); /// Instantiation for Conditions: template bool OpaqueDataBinder::bind_sequence( Condition& object, - const string& typ,const string& val); + const std::string& typ,const std::string& val); /// Conditions binding function for STL maps template <> bool OpaqueDataBinder::bind_map(const MapBinder& b, Condition& object, - const string& key_type, const string& val_type) + const std::string& key_type, const std::string& val_type) { return bind_map(b, object->data, key_type, val_type); } /// Conditions: Filling function for STL maps. template <> bool OpaqueDataBinder::insert_map(const MapBinder& b, Condition& object, - const string& key_type, const string& key, - const string& val_type, const string& val) + const std::string& key_type, const std::string& key, + const std::string& val_type, const std::string& val) { return insert_map(b, object->data, key_type, key, val_type, val); } /// Conditions: Filling function for STL maps. template <> bool OpaqueDataBinder::insert_map(const MapBinder& b, Condition& object, - const string& key_type, const string& val_type, const string& pair_data) + const std::string& key_type, const std::string& val_type, const std::string& pair_data) { return insert_map(b, object->data, key_type, val_type, pair_data); } } } diff --git a/DDCore/src/OpticalSurfaceManagerInterna.cpp b/DDCore/src/OpticalSurfaceManagerInterna.cpp index 2da6cb6dc..4dc0697a8 100644 --- a/DDCore/src/OpticalSurfaceManagerInterna.cpp +++ b/DDCore/src/OpticalSurfaceManagerInterna.cpp @@ -12,14 +12,13 @@ //========================================================================== // Framework include files -#include "DD4hep/detail/OpticalSurfaceManagerInterna.h" -#include "DD4hep/detail/Handle.inl" +#include +#include // C/C++ includes #include #include -using namespace std; using namespace dd4hep; using detail::OpticalSurfaceManagerObject; diff --git a/DDCore/src/PluginTester.cpp b/DDCore/src/PluginTester.cpp index f3df7da45..3d90357bd 100644 --- a/DDCore/src/PluginTester.cpp +++ b/DDCore/src/PluginTester.cpp @@ -12,9 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/PluginTester.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/Primitives.h" +#include +#include +#include // C/C++ include files #include @@ -22,7 +22,9 @@ using namespace dd4hep; namespace { + static int s_extensionID = 0; + PluginTester::ExtensionMap* extensionContainer(const std::type_info& typ) { static std::map s_map; PluginTester::ExtensionMap& m = s_map[&typ]; diff --git a/DDCore/src/Plugins.cpp b/DDCore/src/Plugins.cpp index 1e53d00e7..30de1a2c0 100644 --- a/DDCore/src/Plugins.cpp +++ b/DDCore/src/Plugins.cpp @@ -12,10 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/Plugins.h" +#include #include -using namespace std; using namespace dd4hep; namespace { @@ -85,10 +84,10 @@ namespace { if ( !fp.fptr.ptr ) fp.fptr.ptr = ::dlsym(0, entry); #endif if ( 0 == fp.fptr.ptr ) { - string err = "dd4hep:PluginService: Failed to access symbol " - "\""+string(entry)+"\" in plugin library "+string(plugin)+ - " ["+string(::strerror(errno))+"]"; - throw runtime_error(err); + std::string err = "dd4hep:PluginService: Failed to access symbol " + "\""+std::string(entry)+"\" in plugin library "+std::string(plugin)+ + " ["+std::string(::strerror(errno))+"]"; + throw std::runtime_error(err); } return fp.fptr.fcn; } @@ -118,7 +117,7 @@ namespace { _guard._handle = handle = ::dlopen(plugin_name, RTLD_LAZY | RTLD_GLOBAL); } if ( !handle ) { - throw runtime_error("Failed to load plugin manager library: "+string(plugin_name)); + throw std::runtime_error("Failed to load plugin manager library: "+std::string(plugin_name)); } #else if ( 0 != gSystem->Load(plugin_name) ) {} @@ -145,9 +144,9 @@ PluginDebug::~PluginDebug() noexcept(false) { } /// Helper to check factory existence -string PluginDebug::missingFactory(const string& name) const { - string factoryname = "Create("+name+")"; - string msg = "\t\tNo factory with name " + factoryname + " for type " + name + " found.\n" +std::string PluginDebug::missingFactory(const std::string& name) const { + std::string factoryname = "Create("+name+")"; + std::string msg = "\t\tNo factory with name " + factoryname + " for type " + name + " found.\n" "\t\tPlease check library load path and/or plugin factory name."; return msg; } @@ -174,7 +173,7 @@ void PluginService::print_bad_cast(const std::string& id, const char* msg) { bool dbg = PluginInterface::instance().getDebug(); if ( dbg ) { - stringstream str; + std::stringstream str; str << "Factory requested: " << id << " (" << typeid(signature).name() << ") :" << msg; printout(ERROR,"PluginService","%s", str.str().c_str()); str.str(""); diff --git a/DDCore/src/PolarGridRPhi.cpp b/DDCore/src/PolarGridRPhi.cpp index 0bddb1fb2..16c6ffae7 100644 --- a/DDCore/src/PolarGridRPhi.cpp +++ b/DDCore/src/PolarGridRPhi.cpp @@ -12,12 +12,11 @@ //========================================================================== // Framework include files -#include "DD4hep/PolarGridRPhi.h" -#include "DDSegmentation/PolarGridRPhi.h" +#include +#include // C/C++ include files -using namespace std; using namespace dd4hep; /// determine the position based on the cell ID @@ -74,12 +73,12 @@ void PolarGridRPhi::setGridSizePhi(double cellSize) const { } /// access the field name used for R -const string& PolarGridRPhi::fieldNameR() const { +const std::string& PolarGridRPhi::fieldNameR() const { return access()->implementation->fieldNameR(); } /// access the field name used for Phi -const string& PolarGridRPhi::fieldNamePhi() const { +const std::string& PolarGridRPhi::fieldNamePhi() const { return access()->implementation->fieldNamePhi(); } @@ -92,6 +91,6 @@ const string& PolarGridRPhi::fieldNamePhi() const { -# size in x -# size in z */ -vector PolarGridRPhi::cellDimensions(const CellID& id) const { +std::vector PolarGridRPhi::cellDimensions(const CellID& id) const { return access()->implementation->cellDimensions(id); } diff --git a/DDCore/src/PolarGridRPhi2.cpp b/DDCore/src/PolarGridRPhi2.cpp index b2976faba..484680026 100644 --- a/DDCore/src/PolarGridRPhi2.cpp +++ b/DDCore/src/PolarGridRPhi2.cpp @@ -12,12 +12,11 @@ //========================================================================== // Framework include files -#include "DD4hep/PolarGridRPhi2.h" -#include "DDSegmentation/PolarGridRPhi2.h" +#include +#include // C/C++ include files -using namespace std; using namespace dd4hep; /// determine the position based on the cell ID @@ -34,12 +33,12 @@ dd4hep::CellID PolarGridRPhi2::cellID(const Position& local, } /// access the grid size in R -vector PolarGridRPhi2::gridRValues() const { +std::vector PolarGridRPhi2::gridRValues() const { return access()->implementation->gridRValues(); } /// access the grid size in Phi -vector PolarGridRPhi2::gridPhiValues() const { +std::vector PolarGridRPhi2::gridPhiValues() const { return access()->implementation->gridPhiValues(); } /// set the grid Boundaries in R @@ -83,12 +82,12 @@ void PolarGridRPhi2::setOffsetPhi(double offset) const { } /// access the field name used for R -const string& PolarGridRPhi2::fieldNameR() const { +const std::string& PolarGridRPhi2::fieldNameR() const { return access()->implementation->fieldNameR(); } /// access the field name used for Phi -const string& PolarGridRPhi2::fieldNamePhi() const { +const std::string& PolarGridRPhi2::fieldNamePhi() const { return access()->implementation->fieldNamePhi(); } @@ -101,6 +100,6 @@ const string& PolarGridRPhi2::fieldNamePhi() const { -# size in x -# size in z */ -vector PolarGridRPhi2::cellDimensions(const CellID& id) const { +std::vector PolarGridRPhi2::cellDimensions(const CellID& id) const { return access()->implementation->cellDimensions(id); } diff --git a/DDCore/src/Primitives.cpp b/DDCore/src/Primitives.cpp index 98439f8e9..98cf5b70f 100644 --- a/DDCore/src/Primitives.cpp +++ b/DDCore/src/Primitives.cpp @@ -12,9 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/Primitives.h" -#include "DD4hep/Exceptions.h" -#include "DD4hep/Printout.h" +#include +#include +#include // C/C++ include files #include diff --git a/DDCore/src/Printout.cpp b/DDCore/src/Printout.cpp index b1669e3b2..68f289090 100644 --- a/DDCore/src/Printout.cpp +++ b/DDCore/src/Printout.cpp @@ -12,7 +12,7 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" +#include // C/C++ include files #include @@ -21,6 +21,7 @@ #include #include #include + // Disable some diagnostics for ROOT dictionaries #ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wvarargs" diff --git a/DDCore/src/PropertyDictionary.h b/DDCore/src/PropertyDictionary.h index 7a7ce2b54..95848f62c 100644 --- a/DDCore/src/PropertyDictionary.h +++ b/DDCore/src/PropertyDictionary.h @@ -17,7 +17,7 @@ #define DDCORE_SRC_PROPERTYDICTIONARY_H // Framework include files -#include "DD4hep/ComponentProperties.h" +#include // C/C++ include files #include diff --git a/DDCore/src/Readout.cpp b/DDCore/src/Readout.cpp index ec3e86157..db3cde906 100644 --- a/DDCore/src/Readout.cpp +++ b/DDCore/src/Readout.cpp @@ -12,17 +12,16 @@ //========================================================================== // Framework include files -#include "DD4hep/Readout.h" -#include "DD4hep/detail/SegmentationsInterna.h" -#include "DD4hep/detail/ObjectsInterna.h" -#include "DD4hep/detail/Handle.inl" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/DD4hepUnits.h" -#include "DD4hep/Detector.h" +#include +#include +#include +#include +#include +#include +#include +#include -using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; /// Copy constructor HitCollection::HitCollection(const HitCollection& c) @@ -31,7 +30,7 @@ HitCollection::HitCollection(const HitCollection& c) } /// Initializing constructor -HitCollection::HitCollection(const string& n, const string& k, long k_min, long k_max) +HitCollection::HitCollection(const std::string& n, const std::string& k, long k_min, long k_max) : name(n), key(k), key_min(k_min), key_max(k_max) { } @@ -48,7 +47,7 @@ HitCollection& HitCollection::operator=(const HitCollection& c) { } /// Initializing constructor to create a new object -Readout::Readout(const string& nam) { +Readout::Readout(const std::string& nam) { assign(new ReadoutObject(), nam, "readout"); } @@ -58,12 +57,13 @@ size_t Readout::numCollections() const { Object& ro = object(); return ro.hits.size(); } - throw runtime_error("dd4hep: Readout::numCollections: Cannot access object data [Invalid Handle]"); + except("dd4hep::Readout","numCollections: Cannot access object data [Invalid Handle]"); + throw std::runtime_error("dd4hep: Readout"); } /// Access names of hit collections -vector Readout::collectionNames() const { - vector colls; +std::vector Readout::collectionNames() const { + std::vector colls; if ( isValid() ) { Object& ro = object(); if ( !ro.hits.empty() ) { @@ -72,12 +72,13 @@ vector Readout::collectionNames() const { } return colls; } - throw runtime_error("dd4hep: Readout::collectionsNames: Cannot access object data [Invalid Handle]"); + except("dd4hep::Readout", "collectionsNames: Cannot access object data [Invalid Handle]"); + throw std::runtime_error("dd4hep: Readout"); } /// Access hit collectionsy -vector Readout::collections() const { - vector colls; +std::vector Readout::collections() const { + std::vector colls; if ( isValid() ) { Object& ro = object(); if ( !ro.hits.empty() ) { @@ -86,7 +87,8 @@ vector Readout::collections() const { } return colls; } - throw runtime_error("dd4hep: Readout::collections: Cannot access object data [Invalid Handle]"); + except("dd4hep::Readout", "collections: Cannot access object data [Invalid Handle]"); + throw std::runtime_error("dd4hep: Readout"); } /// Assign IDDescription to readout structure @@ -102,7 +104,8 @@ void Readout::setIDDescriptor(const Ref_t& new_descriptor) const { return; } } - throw runtime_error("dd4hep: Readout::setIDDescriptor: Cannot assign ID descriptor [Invalid Handle]"); + except("dd4hep::Readout", "setIDDescriptor: Cannot assign ID descriptor [Invalid Handle]"); + throw std::runtime_error("dd4hep: Readout"); } /// Access IDDescription structure @@ -123,7 +126,8 @@ void Readout::setSegmentation(const Segmentation& seg) const { return; } } - throw runtime_error("dd4hep: Readout::setSegmentation: Cannot assign segmentation [Invalid Handle]"); + except("dd4hep::Readout", "setSegmentation: Cannot assign segmentation [Invalid Handle]"); + throw std::runtime_error("dd4hep: Readout"); } /// Access segmentation structure diff --git a/DDCore/src/RootDictionary.h b/DDCore/src/RootDictionary.h index 432c312ca..f44211b85 100644 --- a/DDCore/src/RootDictionary.h +++ b/DDCore/src/RootDictionary.h @@ -17,34 +17,34 @@ #define DDCORE_SRC_ROOTDICTIONARY_H // Framework include files -#include "Evaluator/Evaluator.h" -#include "DD4hep/DD4hepRootPersistency.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Grammar.h" -#include "DD4hep/detail/ObjectsInterna.h" -#include "DD4hep/detail/DetectorInterna.h" -#include "DD4hep/detail/ConditionsInterna.h" -#include "DD4hep/detail/AlignmentsInterna.h" -#include "DD4hep/detail/VolumeManagerInterna.h" - -#include "DD4hep/World.h" -#include "DD4hep/DD4hepUI.h" -#include "DD4hep/Callback.h" -#include "DD4hep/Conditions.h" -#include "DD4hep/Alignments.h" -#include "DD4hep/FieldTypes.h" -#include "DD4hep/DD4hepUnits.h" -#include "DD4hep/DetectorData.h" -#include "DD4hep/DetectorProcessor.h" -#include "DD4hep/ComponentProperties.h" -#include "DD4hep/DetectorImp.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // C/C++ include files #include #include #include -#include "TRint.h" +#include namespace dd4hep { namespace cond {} @@ -825,7 +825,7 @@ template class dd4hep::Handle; #pragma link C++ function dd4hep::toStringMesh(const TGeoShape*, int); #pragma link C++ function dd4hep::toStringMesh(dd4hep::PlacedVolume, int); -#include "DD4hep/ConditionsData.h" +#include #pragma link C++ class dd4hep::cond::ClientData+; #pragma link C++ class dd4hep::cond::AbstractMap+; #pragma link C++ class dd4hep::cond::AbstractMap::Params+; diff --git a/DDCore/src/SegmentationDictionary.h b/DDCore/src/SegmentationDictionary.h index 761a5bb3f..8a710cf09 100644 --- a/DDCore/src/SegmentationDictionary.h +++ b/DDCore/src/SegmentationDictionary.h @@ -20,31 +20,31 @@ #define __HAVE_DDSEGMENTATION__ // ------------------------------------------------------------------------- #ifdef __HAVE_DDSEGMENTATION__ -#include "DDSegmentation/Segmentation.h" -#include "DDSegmentation/NoSegmentation.h" -#include "DDSegmentation/CartesianGrid.h" -#include "DDSegmentation/CartesianGridXY.h" -#include "DDSegmentation/CartesianGridXYZ.h" -#include "DDSegmentation/CartesianGridXZ.h" -#include "DDSegmentation/CartesianGridYZ.h" -#include "DDSegmentation/CartesianStripX.h" -#include "DDSegmentation/CartesianStripY.h" -#include "DDSegmentation/CartesianStripZ.h" -#include "DDSegmentation/CylindricalSegmentation.h" -#include "DDSegmentation/GridPhiEta.h" -#include "DDSegmentation/GridRPhiEta.h" -#include "DDSegmentation/MegatileLayerGridXY.h" -#include "DDSegmentation/MultiSegmentation.h" -#include "DDSegmentation/NoSegmentation.h" -#include "DDSegmentation/PolarGrid.h" -#include "DDSegmentation/PolarGridRPhi2.h" -#include "DDSegmentation/PolarGridRPhi.h" -#include "DDSegmentation/ProjectiveCylinder.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "DDSegmentation/SegmentationParameter.h" -#include "DDSegmentation/TiledLayerGridXY.h" -#include "DDSegmentation/TiledLayerSegmentation.h" -#include "DDSegmentation/WaferGridXY.h" +#include +#include +#include +#include typedef dd4hep::DDSegmentation::VolumeID VolumeID; typedef dd4hep::DDSegmentation::CellID CellID; diff --git a/DDCore/src/Segmentations.cpp b/DDCore/src/Segmentations.cpp index a58df7bf2..55a4d3bac 100644 --- a/DDCore/src/Segmentations.cpp +++ b/DDCore/src/Segmentations.cpp @@ -12,27 +12,25 @@ //========================================================================== // Framework include files -#include "DD4hep/Segmentations.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Plugins.h" -#include "DD4hep/detail/Handle.inl" -#include "DD4hep/detail/SegmentationsInterna.h" +#include +#include +#include +#include +#include +#include // C/C++ include files #include #include -using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; DD4HEP_INSTANTIATE_HANDLE_UNNAMED(SegmentationObject); /// Constructor to used when creating a new object -Segmentation::Segmentation(const string& typ, const string& nam, const BitFieldCoder* dec) : Handle() +Segmentation::Segmentation(const std::string& typ, const std::string& nam, const BitFieldCoder* dec) : Handle() { - string seg_type = "segmentation_constructor__"+typ; + std::string seg_type = "segmentation_constructor__"+typ; SegmentationObject* obj = PluginService::Create(seg_type, dec); if ( obj != 0 ) { assign(obj, nam, typ); @@ -122,56 +120,56 @@ Handle Segmentation::sensitive() const { return access()->sensitive; } -#include "DDSegmentation/NoSegmentation.h" +#include DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::NoSegmentation); -#include "DDSegmentation/CartesianGrid.h" +#include DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGrid); -#include "DDSegmentation/CartesianGridXY.h" +#include DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridXY); -#include "DDSegmentation/CartesianGridXZ.h" +#include DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridXZ); -#include "DDSegmentation/CartesianGridYZ.h" +#include DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridYZ); -#include "DDSegmentation/CartesianGridXYZ.h" +#include DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridXYZ); -#include "DDSegmentation/CartesianStripX.h" +#include DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianStripX); -#include "DDSegmentation/CartesianStripY.h" +#include DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianStripY); -#include "DDSegmentation/CartesianStripZ.h" +#include DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianStripZ); -#include "DDSegmentation/TiledLayerGridXY.h" +#include DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::TiledLayerGridXY); -#include "DDSegmentation/MegatileLayerGridXY.h" +#include DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::MegatileLayerGridXY); -#include "DDSegmentation/WaferGridXY.h" +#include DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::WaferGridXY); -#include "DDSegmentation/PolarGridRPhi.h" +#include DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::PolarGridRPhi); -#include "DDSegmentation/PolarGridRPhi2.h" +#include DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::PolarGridRPhi2); -#include "DDSegmentation/GridPhiEta.h" +#include DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::GridPhiEta); -#include "DDSegmentation/GridRPhiEta.h" +#include DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::GridRPhiEta); -#include "DDSegmentation/ProjectiveCylinder.h" +#include DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::ProjectiveCylinder); -#include "DDSegmentation/MultiSegmentation.h" +#include DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::MultiSegmentation); diff --git a/DDCore/src/SegmentationsInterna.cpp b/DDCore/src/SegmentationsInterna.cpp index 88edfed21..c94e3f013 100644 --- a/DDCore/src/SegmentationsInterna.cpp +++ b/DDCore/src/SegmentationsInterna.cpp @@ -12,12 +12,11 @@ //========================================================================== // Framework include files -#include "DD4hep/detail/SegmentationsInterna.h" -#include "DD4hep/InstanceCount.h" +#include +#include #include "DDSegmentation/Segmentation.h" -using namespace std; using namespace dd4hep; /// Standard constructor @@ -37,26 +36,26 @@ SegmentationObject::~SegmentationObject() { } /// Access the encoding string -string SegmentationObject::fieldDescription() const { +std::string SegmentationObject::fieldDescription() const { return segmentation->fieldDescription(); } /// Access the segmentation name -const string& SegmentationObject::name() const { +const std::string& SegmentationObject::name() const { return segmentation->name(); } /// Set the segmentation name -void SegmentationObject::setName(const string& value) { +void SegmentationObject::setName(const std::string& value) { segmentation->setName(value); } /// Access the segmentation type -const string& SegmentationObject::type() const { +const std::string& SegmentationObject::type() const { return segmentation->type(); } /// Access the description of the segmentation -const string& SegmentationObject::description() const { +const std::string& SegmentationObject::description() const { return segmentation->description(); } @@ -71,7 +70,7 @@ void SegmentationObject::setDecoder(const BitFieldCoder* ptr_decoder) const { } /// Access to parameter by name -DDSegmentation::Parameter SegmentationObject::parameter(const string& parameterName) const { +DDSegmentation::Parameter SegmentationObject::parameter(const std::string& parameterName) const { return segmentation->parameter(parameterName); } diff --git a/DDCore/src/ShapeUtilities.cpp b/DDCore/src/ShapeUtilities.cpp index 11c89c214..db78b58b5 100644 --- a/DDCore/src/ShapeUtilities.cpp +++ b/DDCore/src/ShapeUtilities.cpp @@ -376,7 +376,7 @@ namespace dd4hep { TGeoArb8* sh = get_ptr(shape); struct _V { double xy[8][2]; } *vtx = (_V*)sh->GetVertices(); std::vector pars { sh->GetDz() }; - for ( size_t i=0; i<8; ++i ) { + for ( std::size_t i=0; i<8; ++i ) { pars.emplace_back(vtx->xy[i][0]); pars.emplace_back(vtx->xy[i][1]); } @@ -504,7 +504,7 @@ namespace dd4hep { cout << "dimensions: [" << PSEUDOTRAP_TAG << "]" << endl << right_matrix->GetTitle() << endl; #endif - for(size_t i=0; i<7; ++i) { + for(std::size_t i=0; i<7; ++i) { double val; params >> val; pars.emplace_back(val); @@ -521,7 +521,7 @@ namespace dd4hep { std::stringstream params(right_matrix->GetTitle()); std::vector pars; pars.reserve(8); - for(size_t i=0; i<8; ++i) { + for(std::size_t i=0; i<8; ++i) { double val; params >> val; pars.emplace_back(val); @@ -638,7 +638,7 @@ namespace dd4hep { if ( params.size() < 3 ) { invalidSetDimensionCall(sh,params); } - size_t nz = size_t(params[2]); + std::size_t nz = std::size_t(params[2]); if ( params.size() != 3 + 3*nz ) { invalidSetDimensionCall(sh,params); } @@ -762,7 +762,7 @@ namespace dd4hep { } template <> void set_dimensions(TGeoPgon* sh, const std::vector& params) { auto pars = params; - if ( params.size() < 4 || params.size() != 4 + 3*size_t(params[3]) ) { + if ( params.size() < 4 || params.size() != 4 + 3*std::size_t(params[3]) ) { invalidSetDimensionCall(sh,params); } pars[0] /= units::deg; @@ -771,7 +771,7 @@ namespace dd4hep { } template <> void set_dimensions(TGeoXtru* sh, const std::vector& params) { auto pars = params; - if ( params.size() < 1 || params.size() != 1 + 4*size_t(params[0]) ) { + if ( params.size() < 1 || params.size() != 1 + 4*std::size_t(params[0]) ) { invalidSetDimensionCall(sh,params); } Solid(sh)._setDimensions(&pars[0]); @@ -817,7 +817,7 @@ namespace dd4hep { int num_vtx = params[0]; int num_facet = params[1]; std::vector vertices; - size_t i_par = 1; + std::size_t i_par = 1; printout(DEBUG,"TessellatedSolid","+++ Loading %d vertices, %d facets",num_vtx, num_facet); for (int i=0; i +#include // C/C++ include files #include #include #include -using namespace std; using namespace dd4hep; ClassImp(dd4hep::TwistedTubeObject) diff --git a/DDCore/src/SpecParRegistry.cpp b/DDCore/src/SpecParRegistry.cpp index 062c5dde6..276b4310f 100644 --- a/DDCore/src/SpecParRegistry.cpp +++ b/DDCore/src/SpecParRegistry.cpp @@ -1,25 +1,40 @@ -#include "DD4hep/SpecParRegistry.h" -#include "DD4hep/Detector.h" +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank +// +//========================================================================== + +// Framework includes +#include +#include + +// C/C++ include files #include -using namespace std; using namespace dd4hep; -string_view SpecPar::strValue(const string& key) const { +std::string_view SpecPar::strValue(const std::string& key) const { auto const& item = spars.find(key); if (item == end(spars)) - return string_view(); + return std::string_view(); return *begin(item->second); } -bool SpecPar::hasValue(const string& key) const { +bool SpecPar::hasValue(const std::string& key) const { if (numpars.find(key) != end(numpars)) return true; else return false; } -bool SpecPar::hasPath(const string& path) const { +bool SpecPar::hasPath(const std::string& path) const { auto result = std::find(std::begin(paths), std::end(paths), path); if (result != end(paths)) return true; @@ -28,7 +43,7 @@ bool SpecPar::hasPath(const string& path) const { } template <> -std::vector SpecPar::value>(const string& key) const { +std::vector SpecPar::value>(const std::string& key) const { std::vector result; auto const& nitem = numpars.find(key); @@ -47,7 +62,7 @@ std::vector SpecPar::value>(const string& key) const } template <> -std::vector SpecPar::value>(const string& key) const { +std::vector SpecPar::value>(const std::string& key) const { std::vector result; auto const& nitem = numpars.find(key); @@ -66,7 +81,7 @@ std::vector SpecPar::value>(const string& key) const { } template <> -std::vector SpecPar::value>(const string& key) const { +std::vector SpecPar::value>(const std::string& key) const { std::vector result; auto const& nitem = numpars.find(key); @@ -86,7 +101,7 @@ std::vector SpecPar::value>(const string& return result; } -double SpecPar::dblValue(const string& key) const { +double SpecPar::dblValue(const std::string& key) const { auto const& item = numpars.find(key); if (item == end(numpars)) return 0; diff --git a/DDCore/src/SurfaceInstaller.cpp b/DDCore/src/SurfaceInstaller.cpp index 29f778cda..32a9a82fe 100644 --- a/DDCore/src/SurfaceInstaller.cpp +++ b/DDCore/src/SurfaceInstaller.cpp @@ -12,18 +12,13 @@ //========================================================================== // Framework include files -#include "DD4hep/Shapes.h" -#include "DD4hep/Printout.h" -#include "DD4hep/SurfaceInstaller.h" - -// C/C++ include files -#include +#include +#include +#include // ROOT includes -#include "TClass.h" +#include -using namespace std; -using namespace dd4hep; using namespace dd4hep; typedef DetElement::Children _C; @@ -33,30 +28,30 @@ SurfaceInstaller::SurfaceInstaller(Detector& description, int argc, char** argv) : m_detDesc(description), m_det(), m_stopScanning(false) { if ( argc > 0 ) { - string det_name = argv[0]; - string n = det_name[0] == '-' ? det_name.substr(1) : det_name; + std::string det_name = argv[0]; + std::string n = det_name[0] == '-' ? det_name.substr(1) : det_name; m_det = description.detector(n); if ( !m_det.isValid() ) { - stringstream err; + std::stringstream err; err << "The subdetector " << det_name << " is not known to the geometry."; printout(INFO,"SurfaceInstaller",err.str().c_str()); - throw runtime_error(err.str()); + except(det_name, err.str()); } - printout(INFO,m_det.name(),"+++ Processing SurfaceInstaller for subdetector: '%s'",m_det.name()); + printout(INFO,m_det.name(), "+++ Processing SurfaceInstaller for subdetector: '%s'",m_det.name()); return; } - throw runtime_error("The plugin takes at least one argument. No argument supplied"); + except("SurfaceInstaller", "The plugin takes at least one argument. No argument supplied"); } /// Indicate error message and throw exception void SurfaceInstaller::invalidInstaller(const std::string& msg) const { const char* det = m_det.isValid() ? m_det.name() : ""; - string typ = m_det.isValid() ? m_det.type() : string(""); + std::string typ = m_det.isValid() ? m_det.type() : std::string(""); printout(FATAL,"SurfaceInstaller","+++ Surfaces for: %s",det); printout(FATAL,"SurfaceInstaller","+++ %s.",msg.c_str()); printout(FATAL,"SurfaceInstaller","+++ You sure you apply the correct plugin to generate"); printout(FATAL,"SurfaceInstaller","+++ surfaces for a detector of type %s",typ.c_str()); - throw std::runtime_error("+++ Failed to install Surfaces to detector "+string(det)); + except("SurfaceInstaller", "+++ Failed to install Surfaces to detector "+std::string(det)); } /// Shortcut to access the parent detectorelement's volume @@ -78,19 +73,19 @@ const double* SurfaceInstaller::placementTranslation(DetElement component) cons /// Printout volume information void SurfaceInstaller::install(DetElement component, PlacedVolume pv) { if ( pv.volume().isSensitive() ) { - stringstream log; - PlacementPath all_nodes; - ElementPath det_elts; + std::stringstream log; + PlacementPath all_nodes; + ElementPath det_elts; detail::tools::elementPath(component,det_elts); detail::tools::placementPath(component,all_nodes); - string elt_path = detail::tools::elementPath(det_elts); - string node_path = detail::tools::placementPath(all_nodes); + std::string elt_path = detail::tools::elementPath(det_elts); + std::string node_path = detail::tools::placementPath(all_nodes); log << "Lookup " << " Detector[" << det_elts.size() << "]: " << elt_path; - printout(INFO,m_det.name(),log.str()); + printout(INFO,m_det.name(), log.str()); log.str(""); log << " " << " Places[" << all_nodes.size() << "]: " << node_path; - printout(INFO,m_det.name(),log.str()); + printout(INFO,m_det.name(), log.str()); log.str(""); log << " " << " detail::matrix[" << all_nodes.size() << "]: "; for(PlacementPath::const_reverse_iterator i=all_nodes.rbegin(); i!=all_nodes.rend(); ++i) { @@ -116,7 +111,7 @@ void SurfaceInstaller::install(DetElement component, PlacedVolume pv) { printout(INFO,m_det.name(),log.str()); return; } - cout << component.name() << ": " << pv.name() << endl; + std::cout << component.name() << ": " << pv.name() << std::endl; } /// Scan through tree of volume placements diff --git a/DDCore/src/VolumeManager.cpp b/DDCore/src/VolumeManager.cpp index b6dba694e..db083f369 100644 --- a/DDCore/src/VolumeManager.cpp +++ b/DDCore/src/VolumeManager.cpp @@ -12,13 +12,13 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/Printout.h" -#include "DD4hep/MatrixHelpers.h" -#include "DD4hep/detail/Handle.inl" -#include "DD4hep/detail/ObjectsInterna.h" -#include "DD4hep/detail/DetectorInterna.h" -#include "DD4hep/detail/VolumeManagerInterna.h" +#include +#include +#include +#include +#include +#include +#include // C/C++ includes #include @@ -26,7 +26,6 @@ #include #include -using namespace std; using namespace dd4hep; using namespace dd4hep::detail; @@ -44,19 +43,19 @@ namespace dd4hep { * \version 1.0 */ class VolumeManager_Populator { - typedef vector Chain; - typedef PlacedVolume::VolIDs VolIDs; - typedef pair Encoding; + typedef std::vector Chain; + typedef PlacedVolume::VolIDs VolIDs; + typedef std::pair Encoding; /// Reference to the Detector instance - const Detector& m_detDesc; + const Detector& m_detDesc; /// Reference to the volume manager to be populated - VolumeManager m_volManager; + VolumeManager m_volManager; /// Set of already added entries - set m_entries; + std::set m_entries; /// Debug flag - bool m_debug = false; + bool m_debug = false; /// Node counter - size_t m_numNodes = 0; + std::size_t m_numNodes = 0; public: /// Default constructor @@ -157,7 +156,7 @@ namespace dd4hep { } else { except("VolumeManager", - "Invalid not instrumented placement:"+string(daughter->GetName())+ + "Invalid not instrumented placement:"+std::string(daughter->GetName())+ " [Internal error -- bad detector constructor]"); } if ( compound ) { @@ -219,7 +218,7 @@ namespace dd4hep { volume_id |= ((f->value(val << off) << off)&msk); mask |= msk; } - return make_pair(volume_id, mask); + return std::make_pair(volume_id, mask); } /// Compute the encoding for a set of VolIDs within a readout descriptor static Encoding encoding(const IDDescriptor iddesc, const VolIDs& ids) { @@ -233,7 +232,7 @@ namespace dd4hep { volume_id |= ((f->value(val << off) << off)&msk); mask |= msk; } - return make_pair(volume_id, mask); + return std::make_pair(volume_id, mask); } void add_entry(SensitiveDetector sd, DetElement parent, DetElement e, @@ -242,7 +241,7 @@ namespace dd4hep { if ( sd.isValid() ) { if (m_entries.find(code.first) == m_entries.end()) { Readout ro = sd.readout(); - string sd_name = sd.name(); + std::string sd_name = sd.name(); DetElement sub_detector = m_detDesc.detector(sd_name); VolumeManager section = m_volManager.addSubdetector(sub_detector, ro); @@ -258,7 +257,7 @@ namespace dd4hep { if ( context->flag ) { detail::VolumeManagerContextExtension* ext = (detail::VolumeManagerContextExtension*)context; ext->placement = PlacedVolume(n); - for (size_t i = nodes.size(); i > 1; --i) { // Omit the placement of the parent DetElement + for (std::size_t i = nodes.size(); i > 1; --i) { // Omit the placement of the parent DetElement TGeoMatrix* m = nodes[i-1]->GetMatrix(); ext->toElement.MultiplyLeft(m); } @@ -283,7 +282,7 @@ namespace dd4hep { bool sensitive = pv.volume().isSensitive(); //if ( !sensitive ) return; - stringstream log; + std::stringstream log; log << m_entries.size() << ": Detector: " << e.path() << " id:" << volumeID(code.first) << " Nodes(" << int(nodes.size()) << "):" << ro.idSpec().str(code.first,code.second); @@ -393,9 +392,9 @@ void VolumeManagerContext::worldToLocal(const double world[3], double local[3]) } /// Initializing constructor to create a new object -VolumeManager::VolumeManager(const Detector& description, const string& nam, DetElement elt, Readout ro, int flags) { +VolumeManager::VolumeManager(const Detector& description, const std::string& nam, DetElement elt, Readout ro, int flags) { printout(INFO, "VolumeManager", " - populating volume ids - be patient ..." ); - size_t node_count = 0; + std::size_t node_count = 0; Object* obj_ptr = new Object(); assign(obj_ptr, nam, "VolumeManager"); if (elt.isValid()) { @@ -430,26 +429,26 @@ VolumeManager VolumeManager::addSubdetector(DetElement det, Readout ro) { if (isValid()) { Object& o = _data(); if (!det.isValid()) { - throw runtime_error("dd4hep: VolumeManager::addSubdetector: Only valid subdetectors " - "are allowed. [Invalid DetElement]"); + throw std::runtime_error("dd4hep: VolumeManager::addSubdetector: Only valid subdetectors " + "are allowed. [Invalid DetElement]"); } auto i = o.subdetectors.find(det); if (i == o.subdetectors.end()) { - string det_name = det.name(); + std::string det_name = det.name(); // First check all pre-conditions if (!ro.isValid()) { - throw runtime_error("dd4hep: VolumeManager::addSubdetector: Only subdetectors with a " - "valid readout descriptor are allowed. [Invalid DetElement:" + det_name + "]"); + throw std::runtime_error("dd4hep: VolumeManager::addSubdetector: Only subdetectors with a " + "valid readout descriptor are allowed. [Invalid DetElement:" + det_name + "]"); } PlacedVolume pv = det.placement(); if (!pv.isValid()) { - throw runtime_error("dd4hep: VolumeManager::addSubdetector: Only subdetectors with a " - "valid placement are allowed. [Invalid DetElement:" + det_name + "]"); + throw std::runtime_error("dd4hep: VolumeManager::addSubdetector: Only subdetectors with a " + "valid placement are allowed. [Invalid DetElement:" + det_name + "]"); } auto vit = pv.volIDs().find("system"); if (vit == pv.volIDs().end()) { - throw runtime_error("dd4hep: VolumeManager::addSubdetector: Only subdetectors with " - "valid placement VolIDs are allowed. [Invalid DetElement:" + det_name + "]"); + throw std::runtime_error("dd4hep: VolumeManager::addSubdetector: Only subdetectors with " + "valid placement VolIDs are allowed. [Invalid DetElement:" + det_name + "]"); } i = o.subdetectors.emplace(det, VolumeManager(det,ro)).first; @@ -457,8 +456,8 @@ VolumeManager VolumeManager::addSubdetector(DetElement det, Readout ro) { VolumeManager mgr = (*i).second; const BitFieldElement* field = ro.idSpec().field(id.first); if (!field) { - throw runtime_error("dd4hep: VolumeManager::addSubdetector: IdDescriptor of " + - string(det.name()) + " has no field " + id.first); + throw std::runtime_error("dd4hep: VolumeManager::addSubdetector: IdDescriptor of " + + std::string(det.name()) + " has no field " + id.first); } Object& mo = mgr._data(); mo.top = o.top; @@ -472,8 +471,8 @@ VolumeManager VolumeManager::addSubdetector(DetElement det, Readout ro) { } return (*i).second; } - throw runtime_error("dd4hep: VolumeManager::addSubdetector: " - "Failed to add subdetector section. [Invalid Manager Handle]"); + throw std::runtime_error("dd4hep: VolumeManager::addSubdetector: " + "Failed to add subdetector section. [Invalid Manager Handle]"); } /// Access the volume manager by cell id @@ -487,11 +486,11 @@ VolumeManager VolumeManager::subdetector(VolumeID id) const { if ( sys_id == mo.sysID ) return j.second; } - throw runtime_error("dd4hep: VolumeManager::subdetector(VolID): " - "Attempt to access unknown subdetector section."); + throw std::runtime_error("dd4hep: VolumeManager::subdetector(VolID): " + "Attempt to access unknown subdetector section."); } - throw runtime_error("dd4hep: VolumeManager::subdetector(VolID): " - "Cannot assign ID descriptor [Invalid Manager Handle]"); + throw std::runtime_error("dd4hep: VolumeManager::subdetector(VolID): " + "Cannot assign ID descriptor [Invalid Manager Handle]"); } /// Access the top level detector element @@ -499,7 +498,7 @@ DetElement VolumeManager::detector() const { if (isValid()) { return _data().detector; } - throw runtime_error("dd4hep: VolumeManager::detector: Cannot access DetElement [Invalid Handle]"); + throw std::runtime_error("dd4hep: VolumeManager::detector: Cannot access DetElement [Invalid Handle]"); } /// Access IDDescription structure @@ -509,7 +508,7 @@ IDDescriptor VolumeManager::idSpec() const { /// Register physical volume with the manager (normally: section manager) bool VolumeManager::adoptPlacement(VolumeID sys_id, VolumeManagerContext* context) { - stringstream err; + std::stringstream err; Object& o = _data(); VolumeID vid = context->identifier; VolumeID mask = context->mask; @@ -521,53 +520,53 @@ bool VolumeManager::adoptPlacement(VolumeID sys_id, VolumeManagerContext* contex << " id:" << (void*)vid << " pv:" << pv.name() << " Sensitive:" << yes_no(pv.volume().isSensitive()) - << endl; + << std::endl; goto Fail; } if ( i == o.volumes.end()) { o.volumes[vid] = context; o.detMask |= mask; - err << "Inserted new volume:" << setw(6) << left << o.volumes.size() + err << "Inserted new volume:" << std::setw(6) << std::left << o.volumes.size() << " Ptr:" << (void*) pv.ptr() << " [" << pv.name() << "]" - << " id:" << setw(16) << hex << right << setfill('0') << vid << dec << setfill(' ') - << " mask:" << setw(16) << hex << right << setfill('0') << mask << dec << setfill(' ') - << " Det:" << setw(4) << hex << right << setfill('0') << context->element.volumeID() - << " / " << setw(4) << sys_id << dec << setfill(' ') << ": " << context->element.path(); + << " id:" << std::setw(16) << std::hex << std::right << std::setfill('0') << vid << std::dec << std::setfill(' ') + << " mask:" << std::setw(16) << std::hex << std::right << std::setfill('0') << mask << std::dec << std::setfill(' ') + << " Det:" << std::setw(4) << std::hex << std::right << std::setfill('0') << context->element.volumeID() + << " / " << std::setw(4) << sys_id << std::dec << std::setfill(' ') << ": " << context->element.path(); printout(VERBOSE, "VolumeManager", err.str().c_str()); //printout(ALWAYS, "VolumeManager", err.str().c_str()); return true; } err << "+++ Attempt to register duplicate" - << " id:" << setw(16) << hex << right << setfill('0') << vid << dec << setfill(' ') - << " mask:" << setw(16) << hex << right << setfill('0') << mask << dec << setfill(' ') + << " id:" << std::setw(16) << std::hex << std::right << std::setfill('0') << vid << std::dec << std::setfill(' ') + << " mask:" << std::setw(16) << std::hex << std::right << std::setfill('0') << mask << std::dec << std::setfill(' ') << " to detector " << o.detector.name() << " ptr:" << (void*) pv.ptr() << " Name:" << pv.name() << " Sensitive:" << yes_no(pv.volume().isSensitive()) - << endl; + << std::endl; printout(ERROR, "VolumeManager", "%s", err.str().c_str()); err.str(""); context = (*i).second; //pv = context->placement; err << " !!!!! +++ Clashing" - << " id:" << setw(16) << hex << right << setfill('0') << vid << dec << setfill(' ') - << " mask:" << setw(16) << hex << right << setfill('0') << mask << dec << setfill(' ') + << " id:" << std::setw(16) << std::hex << std::right << std::setfill('0') << vid << std::dec << std::setfill(' ') + << " mask:" << std::setw(16) << std::hex << std::right << std::setfill('0') << mask << std::dec << std::setfill(' ') << " to detector " << o.detector.name() << " ptr:" << (void*) pv.ptr() << " Name:" << pv.name() << " Sensitive:" << yes_no(pv.volume().isSensitive()) - << endl; + << std::endl; Fail: printout(ERROR, "VolumeManager", "%s", err.str().c_str()); - // throw runtime_error(err.str()); + // throw std::runtime_error(err.str()); return false; } /// Register physical volume with the manager (normally: section manager) bool VolumeManager::adoptPlacement(VolumeManagerContext* context) { - stringstream err; + std::stringstream err; if ( isValid() ) { Object& o = _data(); if ( context ) { @@ -692,25 +691,25 @@ std::ostream& dd4hep::operator<<(std::ostream& os, const VolumeManager& mgr) { bool isTop = top == &o; //bool hasTop = (o.flags & VolumeManager::ONE) == VolumeManager::ONE; //bool isSdet = (o.flags & VolumeManager::TREE) == VolumeManager::TREE && top != &o; - string prefix(isTop ? "" : "++ "); + std::string prefix(isTop ? "" : "++ "); os << prefix << (isTop ? "TOP Level " : "Secondary ") << "Volume manager:" << &o << " " << o.detector.name() << " IDD:" << o.id.toString() << " SysID:" << (void*) o.sysID << " " << o.managers.size() << " subsections " << o.volumes.size() << " placements "; if (!(o.managers.empty() && o.volumes.empty())) - os << endl; + os << std::endl; for ( const auto& i : o.volumes ) { const VolumeManagerContext* c = i.second; os << prefix - << "Element:" << setw(32) << left << c->element.path() - //<< " pv:" << setw(32) << left << c->placement().name() - << " id:" << setw(18) << left << (void*) c->identifier - << " mask:" << setw(18) << left << (void*) c->mask - << endl; + << "Element:" << std::setw(32) << std::left << c->element.path() + //<< " pv:" << std::setw(32) << std::left << c->placement().name() + << " id:" << std::setw(18) << std::left << (void*) c->identifier + << " mask:" << std::setw(18) << std::left << (void*) c->mask + << std::endl; } for( const auto& i : o.managers ) - os << prefix << i.second << endl; + os << prefix << i.second << std::endl; return os; } diff --git a/DDCore/src/VolumeProcessor.cpp b/DDCore/src/VolumeProcessor.cpp index 79b50d663..f31847bf0 100644 --- a/DDCore/src/VolumeProcessor.cpp +++ b/DDCore/src/VolumeProcessor.cpp @@ -12,8 +12,8 @@ //========================================================================== // Framework includes -#include "DD4hep/Printout.h" -#include "DD4hep/VolumeProcessor.h" +#include +#include using namespace dd4hep; diff --git a/DDCore/src/Volumes.cpp b/DDCore/src/Volumes.cpp index 775545a6d..20b5bbf34 100644 --- a/DDCore/src/Volumes.cpp +++ b/DDCore/src/Volumes.cpp @@ -40,9 +40,7 @@ #include #include -using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; /* * The section below uses the new ROOT features using user extensions to volumes @@ -71,17 +69,17 @@ namespace { return o; } - TGeoVolume* _createTGeoVolume(const string& name, TGeoShape* s, TGeoMedium* m) { + TGeoVolume* _createTGeoVolume(const std::string& name, TGeoShape* s, TGeoMedium* m) { geo_volume_t* e = new geo_volume_t(name.c_str(),s,m); e->SetUserExtension(new Volume::Object()); return e; } - TGeoVolume* _createTGeoVolumeAssembly(const string& name) { + TGeoVolume* _createTGeoVolumeAssembly(const std::string& name) { geo_assembly_t* e = new geo_assembly_t(name.c_str()); // It is important to use the correct constructor!! e->SetUserExtension(new Assembly::Object()); return e; } - TGeoVolumeMulti* _createTGeoVolumeMulti(const string& name, TGeoMedium* medium) { + TGeoVolumeMulti* _createTGeoVolumeMulti(const std::string& name, TGeoMedium* medium) { TGeoVolumeMulti* e = new TGeoVolumeMulti(name.c_str(), medium); e->SetUserExtension(new VolumeMulti::Object()); return e; @@ -89,7 +87,7 @@ namespace { PlacedVolume::Object* _data(const PlacedVolume& v) { PlacedVolume::Object* o = _userExtension(v); if (o) return o; - throw runtime_error("dd4hep: Attempt to access invalid handle of type: PlacedVolume"); + throw std::runtime_error("dd4hep: Attempt to access invalid handle of type: PlacedVolume"); } /// Accessor to the data part of the Volume Volume::Object* _data(const Volume& v, bool throw_exception = true) { @@ -99,7 +97,7 @@ namespace { return o; else if (!throw_exception) return nullptr; - throw runtime_error("dd4hep: Attempt to access invalid handle of type: PlacedVolume"); + throw std::runtime_error("dd4hep: Attempt to access invalid handle of type: PlacedVolume"); } class VolumeImport { @@ -107,7 +105,7 @@ namespace { void setShapeTitle(TGeoVolume* vol) { if ( vol ) { TGeoShape* sh = vol->GetShape(); - string tag = get_shape_tag(sh); + std::string tag = get_shape_tag(sh); sh->SetTitle(tag.c_str()); } } @@ -216,7 +214,7 @@ namespace { return nullptr; } map.Add(v, vol); - string nam; + std::string nam; if (newname && newname[0]) { nam = newname; vol->SetName(newname); @@ -395,8 +393,8 @@ void PlacedVolumeExtension::Release() const { } /// Lookup volume ID -vector::const_iterator -PlacedVolumeExtension::VolIDs::find(const string& name) const { +std::vector::const_iterator +PlacedVolumeExtension::VolIDs::find(const std::string& name) const { for (Base::const_iterator i = this->Base::begin(); i != this->Base::end(); ++i) if (name == (*i).first) return i; @@ -404,8 +402,8 @@ PlacedVolumeExtension::VolIDs::find(const string& name) const { } /// Insert a new value into the volume ID container -std::pair::iterator, bool> -PlacedVolumeExtension::VolIDs::insert(const string& name, int value) { +std::pair::iterator, bool> +PlacedVolumeExtension::VolIDs::insert(const std::string& name, int value) { Base::iterator i = this->Base::begin(); for (; i != this->Base::end(); ++i) if (name == (*i).first) @@ -419,12 +417,12 @@ PlacedVolumeExtension::VolIDs::insert(const string& name, int value) { } /// String representation for debugging -string PlacedVolumeExtension::VolIDs::str() const { - stringstream str; - str << hex; +std::string PlacedVolumeExtension::VolIDs::str() const { + std::stringstream str; + str << std::hex; for(const auto& i : *this ) { - str << i.first << "=" << setw(4) << right - << setfill('0') << i.second << setfill(' ') << " "; + str << i.first << "=" << std::setw(4) << std::right + << std::setfill('0') << i.second << std::setfill(' ') << " "; } return str.str(); } @@ -484,7 +482,7 @@ const PlacedVolume::VolIDs& PlacedVolume::volIDs() const { } /// Add identifier -PlacedVolume& PlacedVolume::addPhysVolID(const string& nam, int value) { +PlacedVolume& PlacedVolume::addPhysVolID(const std::string& nam, int value) { auto* o = _data(*this); if ( !o->params ) { o->volIDs.emplace_back(nam, value); @@ -523,15 +521,15 @@ Position PlacedVolume::position() const { } /// String dump -string PlacedVolume::toString() const { - stringstream str; +std::string PlacedVolume::toString() const { + std::stringstream str; Object* obj = _data(*this); str << m_element->GetName() << ": vol='" << m_element->GetVolume()->GetName() << "' mat:'" << m_element->GetMatrix()->GetName() << "' volID[" << obj->volIDs.size() << "] "; for (VolIDs::const_iterator i = obj->volIDs.begin(); i != obj->volIDs.end(); ++i) str << (*i).first << "=" << (*i).second << " "; - str << ends; + str << std::ends; return str.str(); } @@ -613,23 +611,23 @@ void VolumeExtension::Release() const { } /// Constructor to be used when creating a new geometry tree. -Volume::Volume(const string& nam) { +Volume::Volume(const std::string& nam) { m_element = _createTGeoVolume(nam,0,0); } /// Constructor to be used when creating a new geometry tree. -Volume::Volume(const string& nam, const string& title) { +Volume::Volume(const std::string& nam, const std::string& title) { m_element = _createTGeoVolume(nam,0,0); m_element->SetTitle(title.c_str()); } /// Constructor to be used when creating a new geometry tree. Also sets materuial and solid attributes -Volume::Volume(const string& nam, const Solid& sol, const Material& mat) { +Volume::Volume(const std::string& nam, const Solid& sol, const Material& mat) { m_element = _createTGeoVolume(nam, sol.ptr(), mat.ptr()); } /// Constructor to be used when creating a new geometry tree. Also sets materuial and solid attributes -Volume::Volume(const string& nam, const string& title, const Solid& sol, const Material& mat) { +Volume::Volume(const std::string& nam, const std::string& title, const Solid& sol, const Material& mat) { m_element = _createTGeoVolume(nam, sol.ptr(), mat.ptr()); m_element->SetTitle(title.c_str()); } @@ -711,7 +709,7 @@ bool Volume::isAssembly() const { } /// Divide volume into subsections (See the ROOT manuloa for details) -Volume Volume::divide(const string& divname, int iaxis, int ndiv, +Volume Volume::divide(const std::string& divname, int iaxis, int ndiv, double start, double step, int numed, const char* option) { TGeoVolume* p = m_element; if ( p ) { @@ -740,7 +738,7 @@ PlacedVolume _addNode(TGeoVolume* par, TGeoVolume* daughter, int id, TGeoMatrix* except("dd4hep","Volume: Attempt to place volume without placement matrix."); } if ( transform != detail::matrix::_identity() ) { - string nam = string(daughter->GetName()) + "_placement"; + std::string nam = std::string(daughter->GetName()) + "_placement"; transform->SetName(nam.c_str()); } TGeoShape* shape = daughter->GetShape(); @@ -796,7 +794,7 @@ PlacedVolume _addNode(TGeoVolume* par, Volume daughter, int copy_nr, const Rotat double elements[9]; rot3D.GetComponents(elements); r.SetMatrix(elements); - auto matrix = make_unique(TGeoTranslation(0,0,0),r); + auto matrix = std::make_unique(TGeoTranslation(0,0,0),r); return _addNode(par, daughter, copy_nr, matrix.release()); } @@ -809,7 +807,7 @@ PlacedVolume _addNode(TGeoVolume* par, Volume daughter, int copy_nr, const Trans tr.GetTranslation(pos3D); rot3D.GetComponents(elements); r.SetMatrix(elements); - auto matrix = make_unique(TGeoTranslation(pos3D.x(), pos3D.y(), pos3D.z()),r); + auto matrix = std::make_unique(TGeoTranslation(pos3D.x(), pos3D.y(), pos3D.z()),r); return _addNode(par, daughter, copy_nr, matrix.release()); } @@ -1094,16 +1092,16 @@ PlacedVolume Volume::paramVolume3D(const Transform3D& start, } /// Set the volume's option value -const Volume& Volume::setOption(const string& opt) const { +const Volume& Volume::setOption(const std::string& opt) const { if ( isValid() ) { m_element->SetOption(opt.c_str()); return *this; } - throw runtime_error("dd4hep: Attempt to access invalid handle of type: PlacedVolume"); + throw std::runtime_error("dd4hep: Attempt to access invalid handle of type: PlacedVolume"); } /// Access the volume's option value -string Volume::option() const { +std::string Volume::option() const { return m_element->GetOption(); } @@ -1115,9 +1113,9 @@ const Volume& Volume::setMaterial(const Material& mat) const { m_element->SetMedium(medium); return *this; } - throw runtime_error("dd4hep: Volume: Medium " + string(mat.name()) + " is not registered with geometry manager."); + throw std::runtime_error("dd4hep: Volume: Medium " + std::string(mat.name()) + " is not registered with geometry manager."); } - throw runtime_error("dd4hep: Volume: Attempt to assign invalid material."); + throw std::runtime_error("dd4hep: Volume: Attempt to assign invalid material."); } /// Access to the Volume material @@ -1190,7 +1188,7 @@ const Volume& Volume::setVisAttributes(const VisAttr& attr) const { } /// Set Visualization attributes to the volume -const Volume& Volume::setVisAttributes(const Detector& description, const string& nam) const { +const Volume& Volume::setVisAttributes(const Detector& description, const std::string& nam) const { if (!nam.empty()) { VisAttr attr = description.visAttributes(nam); setVisAttributes(attr); @@ -1199,7 +1197,7 @@ const Volume& Volume::setVisAttributes(const Detector& description, const string } /// Attach attributes to the volume -const Volume& Volume::setAttributes(const Detector& description, const string& rg, const string& ls, const string& vis) const { +const Volume& Volume::setAttributes(const Detector& description, const std::string& rg, const std::string& ls, const std::string& vis) const { if (!rg.empty()) setRegion(description.region(rg)); if (!ls.empty()) @@ -1241,7 +1239,7 @@ Box Volume::boundingBox() const { } /// Set the regional attributes to the volume -const Volume& Volume::setRegion(const Detector& description, const string& nam) const { +const Volume& Volume::setRegion(const Detector& description, const std::string& nam) const { if (!nam.empty()) { return setRegion(description.region(nam)); } @@ -1260,7 +1258,7 @@ Region Volume::region() const { } /// Set the limits to the volume -const Volume& Volume::setLimitSet(const Detector& description, const string& nam) const { +const Volume& Volume::setLimitSet(const Detector& description, const std::string& nam) const { if (!nam.empty()) { return setLimitSet(description.limitSet(nam)); } @@ -1302,7 +1300,7 @@ bool Volume::hasProperties() const { } /// Add Volume property (name-value pair) -void Volume::addProperty(const string& nam, const string& val) const { +void Volume::addProperty(const std::string& nam, const std::string& val) const { auto* o = _data(*this); if ( !o->properties ) { o->properties = new TList(); @@ -1318,7 +1316,7 @@ void Volume::addProperty(const string& nam, const string& val) const { } /// Access property value. Returns default_value if the property is not present -string Volume::getProperty(const string& nam, const string& default_val) const { +std::string Volume::getProperty(const std::string& nam, const std::string& default_val) const { const auto* o = _data(*this); if ( !o->properties ) { return default_val; @@ -1329,12 +1327,12 @@ string Volume::getProperty(const string& nam, const string& default_val) const } /// Constructor to be used when creating a new assembly object -Assembly::Assembly(const string& nam) { +Assembly::Assembly(const std::string& nam) { m_element = _createTGeoVolumeAssembly(nam); } /// Constructor to be used when creating a new multi-volume object -VolumeMulti::VolumeMulti(const string& nam, Material mat) { +VolumeMulti::VolumeMulti(const std::string& nam, Material mat) { m_element = _createTGeoVolumeMulti(nam, mat.ptr()); } @@ -1354,11 +1352,11 @@ void VolumeMulti::verifyVolumeMulti() { } /// Output mesh vertices to string -string dd4hep::toStringMesh(PlacedVolume place, int prec) { +std::string dd4hep::toStringMesh(PlacedVolume place, int prec) { Volume vol = place->GetVolume(); TGeoMatrix* mat = place->GetMatrix(); Solid sol = vol.solid(); - stringstream os; + std::stringstream os; struct _numbering { double adjust(double value) const { if ( std::abs(value) < TGeoShape::Tolerance() ) @@ -1369,7 +1367,7 @@ string dd4hep::toStringMesh(PlacedVolume place, int prec) { if ( vol->IsA() == TGeoVolumeAssembly::Class() ) { for(int i=0; iGetNdaughters(); ++i) { - os << toStringMesh(vol->GetNode(i), prec) << endl; + os << toStringMesh(vol->GetNode(i), prec) << std::endl; } return os.str(); } @@ -1380,36 +1378,36 @@ string dd4hep::toStringMesh(PlacedVolume place, int prec) { Double_t* points = new Double_t[3*nvert]; sol->SetPoints(points); - os << setw(16) << left << sol->IsA()->GetName() - << " " << nvert << " Mesh-points:" << endl; - os << setw(16) << left << sol->IsA()->GetName() << " " << sol->GetName() + os << std::setw(16) << std::left << sol->IsA()->GetName() + << " " << nvert << " Mesh-points:" << std::endl; + os << std::setw(16) << std::left << sol->IsA()->GetName() << " " << sol->GetName() << " N(mesh)=" << sol->GetNmeshVertices() - << " N(vert)=" << nvert << " N(seg)=" << nsegs << " N(pols)=" << npols << endl; + << " N(vert)=" << nvert << " N(seg)=" << nsegs << " N(pols)=" << npols << std::endl; for(int i=0; iLocalToMaster(local, global); - os << setw(16) << left << sol->IsA()->GetName() << " " << setw(3) << left << i - << " Local (" << setw(7) << setprecision(prec) << fixed << right << _vertex.adjust(local[0]) - << ", " << setw(7) << setprecision(prec) << fixed << right << _vertex.adjust(local[1]) - << ", " << setw(7) << setprecision(prec) << fixed << right << _vertex.adjust(local[2]) - << ") Global (" << setw(7) << setprecision(prec) << fixed << right << _vertex.adjust(global[0]) - << ", " << setw(7) << setprecision(prec) << fixed << right << _vertex.adjust(global[1]) - << ", " << setw(7) << setprecision(prec) << fixed << right << _vertex.adjust(global[2]) - << ")" << endl; + os << std::setw(16) << std::left << sol->IsA()->GetName() << " " << std::setw(3) << std::left << i + << " Local (" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << _vertex.adjust(local[0]) + << ", " << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << _vertex.adjust(local[1]) + << ", " << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << _vertex.adjust(local[2]) + << ") Global (" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << _vertex.adjust(global[0]) + << ", " << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << _vertex.adjust(global[1]) + << ", " << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << _vertex.adjust(global[2]) + << ")" << std::endl; } Box box = sol; const Double_t* org = box->GetOrigin(); - os << setw(16) << left << sol->IsA()->GetName() + os << std::setw(16) << std::left << sol->IsA()->GetName() << " Bounding box: " - << " dx=" << setw(7) << setprecision(prec) << fixed << right << _vertex.adjust(box->GetDX()) - << " dy=" << setw(7) << setprecision(prec) << fixed << right << _vertex.adjust(box->GetDY()) - << " dz=" << setw(7) << setprecision(prec) << fixed << right << _vertex.adjust(box->GetDZ()) - << " Origin: x=" << setw(7) << setprecision(prec) << fixed << right << _vertex.adjust(org[0]) - << " y=" << setw(7) << setprecision(prec) << fixed << right << _vertex.adjust(org[1]) - << " z=" << setw(7) << setprecision(prec) << fixed << right << _vertex.adjust(org[2]) - << endl; + << " dx=" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << _vertex.adjust(box->GetDX()) + << " dy=" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << _vertex.adjust(box->GetDY()) + << " dz=" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << _vertex.adjust(box->GetDZ()) + << " Origin: x=" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << _vertex.adjust(org[0]) + << " y=" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << _vertex.adjust(org[1]) + << " z=" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << _vertex.adjust(org[2]) + << std::endl; /// -------------------- DONE -------------------- delete [] points; diff --git a/DDCore/src/WaferGridXY.cpp b/DDCore/src/WaferGridXY.cpp index a55585688..769cfaa01 100644 --- a/DDCore/src/WaferGridXY.cpp +++ b/DDCore/src/WaferGridXY.cpp @@ -12,12 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/WaferGridXY.h" -#include "DDSegmentation/WaferGridXY.h" +#include +#include -// C/C++ include files - -using namespace std; using namespace dd4hep; /// determine the position based on the cell ID @@ -63,12 +60,12 @@ double WaferGridXY::waferOffsetY(int inGroup, int inWafer) const { } /// access the field name used for X -const string& WaferGridXY::fieldNameX() const { +const std::string& WaferGridXY::fieldNameX() const { return access()->implementation->fieldNameX(); } /// access the field name used for Y -const string& WaferGridXY::fieldNameY() const { +const std::string& WaferGridXY::fieldNameY() const { return access()->implementation->fieldNameY(); } @@ -81,6 +78,6 @@ const string& WaferGridXY::fieldNameY() const { -# size in x -# size in y */ -vector WaferGridXY::cellDimensions(const CellID& id) const { +std::vector WaferGridXY::cellDimensions(const CellID& id) const { return access()->implementation->cellDimensions(id); } diff --git a/DDCore/src/World.cpp b/DDCore/src/World.cpp index c847b9715..d9af10133 100644 --- a/DDCore/src/World.cpp +++ b/DDCore/src/World.cpp @@ -12,8 +12,8 @@ //========================================================================== // Framework include files -#include "DD4hep/World.h" -#include "DD4hep/detail/DetectorInterna.h" +#include +#include /// Access the detector descrion tree dd4hep::Detector& dd4hep::World::detectorDescription() const { diff --git a/DDCore/src/plugins/CodeGenerator.cpp b/DDCore/src/plugins/CodeGenerator.cpp index 2143587c8..bc120a404 100644 --- a/DDCore/src/plugins/CodeGenerator.cpp +++ b/DDCore/src/plugins/CodeGenerator.cpp @@ -10,17 +10,17 @@ // Author : M.Frank // //========================================================================== -#include "DD4hep/Factories.h" -#include "DD4hep/Shapes.h" -#include "DD4hep/Volumes.h" -#include "DD4hep/Detector.h" -#include "DD4hep/DetElement.h" -#include "DD4hep/MatrixHelpers.h" -#include "DD4hep/DD4hepUnits.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Path.h" -#include "DD4hep/detail/ObjectsInterna.h" -#include "DD4hep/detail/DetectorInterna.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // C/C++ include files #include @@ -29,15 +29,15 @@ #include // ROOT includes -#include "TClass.h" -#include "TGeoMatrix.h" -#include "TGeoBoolNode.h" -#include "TGeoCompositeShape.h" +#include +#include +#include +#include -using namespace std; using namespace dd4hep; namespace { + std::string prefix = "\t"; std::string sep(","); @@ -55,18 +55,18 @@ namespace { Detector& detector; Actor(Detector& d) : detector(d) {} ~Actor() = default; - ostream& handleHeader (ostream& log); - ostream& handleTrailer (ostream& log); - ostream& handleSolid (ostream& log, const TGeoShape* sh); - ostream& handleMatrix (ostream& log, TGeoMatrix* mat); - ostream& handleMaterial (ostream& log, TGeoMedium* mat); - ostream& handlePlacement(ostream& log, TGeoNode* parent, TGeoNode* node); - ostream& handleStructure(ostream& log, DetElement parent, DetElement de); + std::ostream& handleHeader (std::ostream& log); + std::ostream& handleTrailer (std::ostream& log); + std::ostream& handleSolid (std::ostream& log, const TGeoShape* sh); + std::ostream& handleMatrix (std::ostream& log, TGeoMatrix* mat); + std::ostream& handleMaterial (std::ostream& log, TGeoMedium* mat); + std::ostream& handlePlacement(std::ostream& log, TGeoNode* parent, TGeoNode* node); + std::ostream& handleStructure(std::ostream& log, DetElement parent, DetElement de); }; typedef void* pvoid_t; - ostream& newline(ostream& log) { - return log << endl << prefix; + std::ostream& newline(std::ostream& log) { + return log << std::endl << prefix; } template const void* pointer(const Handle& h) { return h.ptr(); @@ -74,59 +74,59 @@ namespace { template const void* pointer(const T* h) { return h; } - template inline string obj_name(const string& pref, const T* ptr) { - stringstream name; + template inline std::string obj_name(const std::string& pref, const T* ptr) { + std::stringstream name; name << pref << "_" << pointer(ptr); return name.str(); } - ostream& Actor::handleHeader (ostream& log) { - log << "#include \"TClass.h\"" << endl - << "#include \"TGeoNode.h\"" << endl - << "#include \"TGeoExtension.h\"" << endl - << "#include \"TGeoShapeAssembly.h\"" << endl - << "#include \"TGeoMedium.h\"" << endl - << "#include \"TGeoVolume.h\"" << endl - << "#include \"TGeoShape.h\"" << endl - << "#include \"TGeoPhysicalNode.h\"" << endl - << "#include \"TGeoCone.h\"" << endl - << "#include \"TGeoParaboloid.h\"" << endl - << "#include \"TGeoPgon.h\"" << endl - << "#include \"TGeoPcon.h\"" << endl - << "#include \"TGeoSphere.h\"" << endl - << "#include \"TGeoArb8.h\"" << endl - << "#include \"TGeoTrd1.h\"" << endl - << "#include \"TGeoTrd2.h\"" << endl - << "#include \"TGeoTube.h\"" << endl - << "#include \"TGeoEltu.h\"" << endl - << "#include \"TGeoXtru.h\"" << endl - << "#include \"TGeoHype.h\"" << endl - << "#include \"TGeoTorus.h\"" << endl - << "#include \"TGeoHalfSpace.h\"" << endl - << "#include \"TGeoCompositeShape.h\"" << endl - << "#include \"TGeoShapeAssembly.h\"" << endl - << "#include \"TGeoMatrix.h\"" << endl - << "#include \"TGeoBoolNode.h\"" << endl - << "#include \"TGeoCompositeShape.h\"" << endl - << "#include \"TGeoManager.h\"" << endl << endl - << "#include \"DD4hep/Factories.h\"" << endl - << "#include \"DD4hep/Shapes.h\"" << endl - << "#include \"DD4hep/Volumes.h\"" << endl - << "#include \"DD4hep/Detector.h\"" << endl - << "#include \"DD4hep/DetElement.h\"" << endl - << "#include \"DD4hep/MatrixHelpers.h\"" << endl - << "#include \"DD4hep/DD4hepUnits.h\"" << endl - << "#include \"DD4hep/Printout.h\"" << endl - << "#include \"DD4hep/Path.h\"" << endl - << "#include \"DD4hep/detail/ObjectsInterna.h\"" << endl - << "#include \"DD4hep/detail/DetectorInterna.h\"" << endl - << "#include " << endl - << "#include " << endl - << "#include " << endl << endl << endl; - log << "using namespace std;" << endl; - log << "using namespace dd4hep;" << endl; - log << "extern PlacedVolume _addNode(TGeoVolume* par, TGeoVolume* daughter, int id, TGeoMatrix* transform);" << endl; + std::ostream& Actor::handleHeader (std::ostream& log) { + log << "#include \"TClass.h\"" << std::endl + << "#include \"TGeoNode.h\"" << std::endl + << "#include \"TGeoExtension.h\"" << std::endl + << "#include \"TGeoShapeAssembly.h\"" << std::endl + << "#include \"TGeoMedium.h\"" << std::endl + << "#include \"TGeoVolume.h\"" << std::endl + << "#include \"TGeoShape.h\"" << std::endl + << "#include \"TGeoPhysicalNode.h\"" << std::endl + << "#include \"TGeoCone.h\"" << std::endl + << "#include \"TGeoParaboloid.h\"" << std::endl + << "#include \"TGeoPgon.h\"" << std::endl + << "#include \"TGeoPcon.h\"" << std::endl + << "#include \"TGeoSphere.h\"" << std::endl + << "#include \"TGeoArb8.h\"" << std::endl + << "#include \"TGeoTrd1.h\"" << std::endl + << "#include \"TGeoTrd2.h\"" << std::endl + << "#include \"TGeoTube.h\"" << std::endl + << "#include \"TGeoEltu.h\"" << std::endl + << "#include \"TGeoXtru.h\"" << std::endl + << "#include \"TGeoHype.h\"" << std::endl + << "#include \"TGeoTorus.h\"" << std::endl + << "#include \"TGeoHalfSpace.h\"" << std::endl + << "#include \"TGeoCompositeShape.h\"" << std::endl + << "#include \"TGeoShapeAssembly.h\"" << std::endl + << "#include \"TGeoMatrix.h\"" << std::endl + << "#include \"TGeoBoolNode.h\"" << std::endl + << "#include \"TGeoCompositeShape.h\"" << std::endl + << "#include \"TGeoManager.h\"" << std::endl << std::endl + << "#include \"DD4hep/Factories.h\"" << std::endl + << "#include \"DD4hep/Shapes.h\"" << std::endl + << "#include \"DD4hep/Volumes.h\"" << std::endl + << "#include \"DD4hep/Detector.h\"" << std::endl + << "#include \"DD4hep/DetElement.h\"" << std::endl + << "#include \"DD4hep/MatrixHelpers.h\"" << std::endl + << "#include \"DD4hep/DD4hepUnits.h\"" << std::endl + << "#include \"DD4hep/Printout.h\"" << std::endl + << "#include \"DD4hep/Path.h\"" << std::endl + << "#include \"DD4hep/detail/ObjectsInterna.h\"" << std::endl + << "#include \"DD4hep/detail/DetectorInterna.h\"" << std::endl + << "#include " << std::endl + << "#include " << std::endl + << "#include " << std::endl << std::endl << std::endl; + log << "using namespace std;" << std::endl; + log << "using namespace dd4hep;" << std::endl; + log << "extern PlacedVolume _addNode(TGeoVolume* par, TGeoVolume* daughter, int id, TGeoMatrix* transform);" << std::endl; log << "namespace {" << newline << "\t struct CodeGeo {" << newline @@ -143,8 +143,8 @@ namespace { << "\t\t void add_vis(Detector& d, VisAttr& v) {" << newline << "\t\t try { d.add(v); } catch(...) {}" << newline << "\t\t }" << newline - << "\t };" << endl - << "}" << endl << endl << endl; + << "\t };" << std::endl + << "}" << std::endl << std::endl << std::endl; log << "TGeoVolume* CodeGeo::load_geometry() {" << newline; const auto& constants = detector.constants(); @@ -177,8 +177,8 @@ namespace { for(const auto& o : limits) { LimitSet ls = o.second; log << "{ LimitSet ls(string(\"" << ls.name() << "\")); " << newline; - const set& lims = ls.limits(); - const set& cuts = ls.cuts(); + const std::set& lims = ls.limits(); + const std::set& cuts = ls.cuts(); for(const auto& l : lims) { log << " { Limit l; l.particles = \"" << l.particles << "\";" << " l.name = \"" << l.name << "\";" @@ -257,7 +257,7 @@ namespace { return log; } - ostream& Actor::handleTrailer (ostream& log) { + std::ostream& Actor::handleTrailer (std::ostream& log) { log << "static long generate_dd4hep(Detector& detector, int, char**) {" << newline << "CodeGeo gen(detector);" << newline << "TGeoVolume* vol_top = gen.load_geometry();" << newline @@ -271,19 +271,19 @@ namespace { << "gen.load_structure();" << newline; } log << "return 1;" - << endl << "}" << endl << endl + << std::endl << "}" << std::endl << std::endl << "DECLARE_APPLY(DD4hep_Run_" << function << ", generate_dd4hep)" - << endl; + << std::endl; return log; } - ostream& Actor::handleStructure(ostream& log, DetElement parent, DetElement de) { + std::ostream& Actor::handleStructure(std::ostream& log, DetElement parent, DetElement de) { if ( de.isValid() && detelements.find(de) == detelements.end() ) { - string name = obj_name("de", de.ptr()); + std::string name = obj_name("de", de.ptr()); detelements.emplace(de,name); if ( !parent.isValid() ) { - cout << "No parent: " << de.path() << " " << pointer(de) << " " << pointer(detector.world()) << endl; - log << endl + std::cout << "No parent: " << de.path() << " " << pointer(de) << " " << pointer(detector.world()) << std::endl; + log << std::endl << "DetElement CodeGeo::load_structure() {" << newline; } else { @@ -297,7 +297,7 @@ namespace { log << "\t de.setPlacement(placements[" << pointer(de.placement()) << "]);" << newline; } else { - cout << "Placement od DetElement " << de.path() << " Is not valid! [Ignored]" << endl; + std::cout << "Placement od DetElement " << de.path() << " Is not valid! [Ignored]" << std::endl; } log << "\t structure[" << pointer(de) << "] = de; " << newline << "}" << newline; @@ -306,20 +306,20 @@ namespace { handleStructure(log, de, d.second); } if ( !parent.isValid() ) { - log << "return structure[" << pointer(de) << "];" << endl - << "}" << endl << endl; + log << "return structure[" << pointer(de) << "];" << std::endl + << "}" << std::endl << std::endl; } } return log; } - ostream& Actor::handlePlacement(ostream& log, TGeoNode* parent, TGeoNode* node) { + std::ostream& Actor::handlePlacement(std::ostream& log, TGeoNode* parent, TGeoNode* node) { if ( node && placements.find(node) == placements.end() ) { PlacedVolume pv(node); TGeoVolume* vol = node->GetVolume(); TGeoMatrix* mat = node->GetMatrix(); - string name = obj_name("vol", vol); + std::string name = obj_name("vol", vol); placements.emplace(node,name); handleMatrix(log, mat); @@ -374,16 +374,16 @@ namespace { handlePlacement(log, node, daughter); } if ( !parent ) { - log << "return volumes[" << pointer(vol) << "];" << endl - << "}" << endl << endl << endl; + log << "return volumes[" << pointer(vol) << "];" << std::endl + << "}" << std::endl << std::endl << std::endl; } } return log; } - ostream& Actor::handleMaterial(ostream& log, TGeoMedium* medium) { + std::ostream& Actor::handleMaterial(std::ostream& log, TGeoMedium* medium) { if ( medium && materials.find(medium) == materials.end() ) { - string name = obj_name("material",medium); + std::string name = obj_name("material",medium); materials.emplace(medium,name); TGeoMaterial* material = medium->GetMaterial(); log << "{" << newline @@ -404,9 +404,9 @@ namespace { return log; } - ostream& Actor::handleMatrix(ostream& log, TGeoMatrix* mat) { + std::ostream& Actor::handleMatrix(std::ostream& log, TGeoMatrix* mat) { if ( mat && matrices.find(mat) == matrices.end() ) { - string name = obj_name("matrix",mat); + std::string name = obj_name("matrix",mat); log << "{" << newline << "\t TGeoHMatrix* mat = new TGeoHMatrix(\"" << mat->GetName() << "\");" << newline << "\t matrices[" << pointer(mat) << "] = mat;" << newline; @@ -445,8 +445,8 @@ namespace { } /// Pretty print of solid attributes - ostream& Actor::handleSolid(ostream& log, const TGeoShape* shape) { - string name = obj_name("solid", shape); + std::ostream& Actor::handleSolid(std::ostream& log, const TGeoShape* shape) { + std::string name = obj_name("solid", shape); if ( shapes.find(shape) != shapes.end() ) { return log; @@ -623,7 +623,7 @@ namespace { else if (cl == TGeoXtru::Class()) { Solid sol(shape); const TGeoXtru* sh = (const TGeoXtru*) shape; - vector pars = sol.dimensions(); + std::vector pars = sol.dimensions(); log << "double param[] = {" << newline; for( size_t i=0; i < pars.size(); ++i ) log << pars[i] << ((i+1 Set output file for generated code. Default: stdout \n" " -help Show thi help message \n" - "\tArguments given: " << arguments(argc,argv) << endl << flush; + "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush; ::exit(EINVAL); } } - unique_ptr out; - ostream* os = &cout; + std::unique_ptr out; + std::ostream* os = &std::cout; if ( !output.empty() ) { Path path(output); - out.reset(new ofstream(path.c_str())); + out.reset(new std::ofstream(path.c_str())); if ( !out->good() ) { out.reset(); except("CxxRootGenerator", @@ -700,7 +700,7 @@ static long generate_cxx(Detector& description, int argc, char** argv) { } os = out.get(); actor.function = path.filename(); - if ( actor.function.rfind('.') != string::npos ) + if ( actor.function.rfind('.') != std::string::npos ) actor.function = actor.function.substr(0, actor.function.rfind('.')); printout(INFO, "CxxRootGenerator", "++ Dump generated code to output files: %s [function: %s()]", diff --git a/DDCore/src/plugins/DetElementConfig.cpp b/DDCore/src/plugins/DetElementConfig.cpp index 5b1d50fc6..9358c20b3 100644 --- a/DDCore/src/plugins/DetElementConfig.cpp +++ b/DDCore/src/plugins/DetElementConfig.cpp @@ -42,7 +42,7 @@ namespace { std::size_t count = 0; bool propagate = det == detector.world() ? false: x_det.attr(_U(propagate), false); if ( xml_dim_t x_vol = x_det.child(_U(volume), false) ) { - count += xml::configVolume(detector, x_vol, det.volume(), propagate, false); + count += xml::configVolume(detector, x_vol, det.volume(), propagate, false); } PrintLevel lvl = x_det.attr(_U(debug), nullptr) ? ALWAYS : DEBUG; printout(lvl, "DetElementConfig", "++ Applied %ld settings to %s", count, path.c_str()); @@ -69,6 +69,7 @@ namespace { } } // End namespace dd4hep + /// Instantiate factory DECLARE_XML_PLUGIN(DD4hep_DetElementConfig, configure_detelement) /// Instantiate factory diff --git a/DDCore/src/plugins/DetElementVolumeIDs.cpp b/DDCore/src/plugins/DetElementVolumeIDs.cpp index 644c2e5c9..a237f9bc0 100644 --- a/DDCore/src/plugins/DetElementVolumeIDs.cpp +++ b/DDCore/src/plugins/DetElementVolumeIDs.cpp @@ -54,11 +54,11 @@ namespace dd4hep { /// Scan a single physical volume and look for sensitive elements below std::size_t scanPhysicalVolume(DetElement& parent, - DetElement e, - PlacedVolume pv, - Encoding parent_encoding, - SensitiveDetector& sd, - PlacementPath& chain); + DetElement e, + PlacedVolume pv, + Encoding parent_encoding, + SensitiveDetector& sd, + PlacementPath& chain); public: /// Default constructor DetElementVolumeIDs(const Detector& description); @@ -104,29 +104,29 @@ namespace { std::string detector = "/world"; for(int i = 0; i < argc && argv[i]; ++i) { if ( 0 == ::strncmp("-detector",argv[i],4) ) - detector = argv[++i]; + detector = argv[++i]; else { - std::cout << - "Usage: -plugin DD4hep_DetElementVolumeIDs -arg [-arg] \n\n" - " -detector Top level DetElement path. Default: '/world' \n" - " -help Print this help output \n" - " Arguments given: " << arguments(argc,argv) << std::endl << std::flush; - ::exit(EINVAL); + std::cout << + "Usage: -plugin DD4hep_DetElementVolumeIDs -arg [-arg] \n\n" + " -detector Top level DetElement path. Default: '/world' \n" + " -help Print this help output \n" + " Arguments given: " << arguments(argc,argv) << std::endl << std::flush; + ::exit(EINVAL); } } DetElement element = description.world(); if ( detector != "/world" ) { element = detail::tools::findElement(description,detector); if ( !element.isValid() ) { - except("DD4hep_DetElementVolumeIDs","+++ Invalid DetElement path: %s",detector.c_str()); + except("DD4hep_DetElementVolumeIDs","+++ Invalid DetElement path: %s",detector.c_str()); } } DetElementVolumeIDs mgr(description); auto count = mgr.populate(element); if ( count == 0 ) { except("DD4hep_DetElementVolumeIDs", - "+++ NO volume identifiers assigned to DetElement %s. %s", - "Something went wrong!",detector.c_str()); + "+++ NO volume identifiers assigned to DetElement %s. %s", + "Something went wrong!",detector.c_str()); } return count > 0 ? 1 : 0; } @@ -169,22 +169,22 @@ std::size_t DetElementVolumeIDs::populate(DetElement det) { entries.clear(); if ( !pv.isValid() ) { except("DetElementVolumeIDs", - "+++ Top level DetElement %s has no valid placement. %s", - "[Something awfully wrong]", det.path().c_str()); + "+++ Top level DetElement %s has no valid placement. %s", + "[Something awfully wrong]", det.path().c_str()); } if ( det == m_detDesc.world() ) { for (const auto& i : det.children() ) { DetElement de = i.second; pv = de.placement(); if (pv.isValid()) { - PlacementPath chain; - Encoding coding { 0, 0 }; - SensitiveDetector sd (0); - count += scanPhysicalVolume(de, de, pv, coding, sd, chain); - continue; + PlacementPath chain; + Encoding coding { 0, 0 }; + SensitiveDetector sd (0); + count += scanPhysicalVolume(de, de, pv, coding, sd, chain); + continue; } printout(WARNING, "DetElementVolumeIDs", "++ Detector element %s of type %s has no placement.", - de.name(), de.type().c_str()); + de.name(), de.type().c_str()); } printout(INFO, "DetElementVolumeIDs", "++ Assigned %ld volume identifiers to DetElements.", count); return count; @@ -192,8 +192,8 @@ std::size_t DetElementVolumeIDs::populate(DetElement det) { SensitiveDetector sd = m_detDesc.sensitiveDetector(det.name()); if ( !pv.volIDs().empty() && !sd.isValid() ) { except("DetElementVolumeIDs", - "+++ No sensitive detector available for top level DetElement %s.", - det.path().c_str()); + "+++ No sensitive detector available for top level DetElement %s.", + det.path().c_str()); } PlacementPath chain; count += scanPhysicalVolume(det, det, pv, encoding, sd, chain); @@ -204,11 +204,11 @@ std::size_t DetElementVolumeIDs::populate(DetElement det) { /// Scan a single physical volume and look for sensitive elements below std::size_t DetElementVolumeIDs::scanPhysicalVolume(DetElement& parent, - DetElement e, - PlacedVolume pv, - Encoding parent_encoding, - SensitiveDetector& sd, - PlacementPath& chain) + DetElement e, + PlacedVolume pv, + Encoding parent_encoding, + SensitiveDetector& sd, + PlacementPath& chain) { TGeoNode* node = pv.ptr(); std::size_t count = 0; @@ -226,81 +226,81 @@ DetElementVolumeIDs::scanPhysicalVolume(DetElement& parent, } else if ( !sd.isValid() ) { if ( is_sensitive ) - sd = vol.sensitiveDetector(); + sd = vol.sensitiveDetector(); else if ( (parent->flag&DetElement::Object::HAVE_SENSITIVE_DETECTOR) ) - sd = m_detDesc.sensitiveDetector(parent.name()); + sd = m_detDesc.sensitiveDetector(parent.name()); else if ( (e->flag&DetElement::Object::HAVE_SENSITIVE_DETECTOR) ) - sd = m_detDesc.sensitiveDetector(e.name()); + sd = m_detDesc.sensitiveDetector(e.name()); } chain.emplace_back(node); if ( sd.isValid() && !pv_ids.empty() ) { Readout ro = sd.readout(); if ( ro.isValid() ) { - vol_encoding = update_encoding(ro.idSpec(), pv_ids, parent_encoding); - have_encoding = true; + vol_encoding = update_encoding(ro.idSpec(), pv_ids, parent_encoding); + have_encoding = true; } else { - printout(WARNING, "DetElementVolumeIDs", - "%s: Strange constellation volume %s is sensitive, but has no readout! sd:%p", - parent.name(), pv.volume().name(), sd.ptr()); + printout(WARNING, "DetElementVolumeIDs", + "%s: Strange constellation volume %s is sensitive, but has no readout! sd:%p", + parent.name(), pv.volume().name(), sd.ptr()); } } for (int idau = 0, ndau = node->GetNdaughters(); idau < ndau; ++idau) { TGeoNode* daughter = node->GetDaughter(idau); PlacedVolume place_dau(daughter); if ( place_dau.data() ) { - DetElement de_dau; - /// Check if this particular volume is the placement of one of the - /// children of this detector element. If the daughter placement is also - /// a detector child, then we must reset the node chain. - for( const auto& de : e.children() ) { - if ( de.second.placement().ptr() == daughter ) { - de_dau = de.second; - break; - } - } - if ( de_dau.isValid() ) { - PlacementPath dau_chain; - count += scanPhysicalVolume(parent, de_dau, place_dau, vol_encoding, sd, dau_chain); - } - else { // there may be several layers of volumes between mother-child of DE - count += scanPhysicalVolume(parent, e, place_dau, vol_encoding, sd, chain); - } + DetElement de_dau; + /// Check if this particular volume is the placement of one of the + /// children of this detector element. If the daughter placement is also + /// a detector child, then we must reset the node chain. + for( const auto& de : e.children() ) { + if ( de.second.placement().ptr() == daughter ) { + de_dau = de.second; + break; + } + } + if ( de_dau.isValid() ) { + PlacementPath dau_chain; + count += scanPhysicalVolume(parent, de_dau, place_dau, vol_encoding, sd, dau_chain); + } + else { // there may be several layers of volumes between mother-child of DE + count += scanPhysicalVolume(parent, e, place_dau, vol_encoding, sd, chain); + } } else { - except("DetElementVolumeIDs", - "Invalid not instrumented placement: %s %s", daughter->GetName(), - " [Internal error -- bad detector constructor]"); + except("DetElementVolumeIDs", + "Invalid not instrumented placement: %s %s", daughter->GetName(), + " [Internal error -- bad detector constructor]"); } /// For compounds the upper level sensitive detector does not exist, /// because there are multiple at lower layers if ( compound ) { - sd = SensitiveDetector(0); + sd = SensitiveDetector(0); } } if ( sd.isValid() ) { if ( !have_encoding && !compound ) { - printout(ERROR, "DetElementVolumeIDs", - "Element %s: Missing SD encoding. Volume manager won't work!", - e.path().c_str()); + printout(ERROR, "DetElementVolumeIDs", + "Element %s: Missing SD encoding. Volume manager won't work!", + e.path().c_str()); } if ( is_sensitive || count > 0 ) { - // Either this layer is sensitive of a layer below. - if ( node == e.placement().ptr() ) { - // These here are placement nodes, which at the same time are DetElement placements - // 1) We recuperate volumes from lower levels by reusing the subdetector - // This only works if there is exactly one sensitive detector per subdetector! - // 2) DetElements in the upper hierarchy of the sensitive also get a volume id, - // and the volume is registered. (to be discussed) - // - e.object().volumeID = vol_encoding.identifier; - } - // Collect all sensitive volumes, which belong to the next DetElement - if ( entries.find(e) == entries.end()) { - entries[e].emplace_back(vol_encoding); - ++numberOfNodes; - } - ++count; + // Either this layer is sensitive of a layer below. + if ( node == e.placement().ptr() ) { + // These here are placement nodes, which at the same time are DetElement placements + // 1) We recuperate volumes from lower levels by reusing the subdetector + // This only works if there is exactly one sensitive detector per subdetector! + // 2) DetElements in the upper hierarchy of the sensitive also get a volume id, + // and the volume is registered. (to be discussed) + // + e.object().volumeID = vol_encoding.identifier; + } + // Collect all sensitive volumes, which belong to the next DetElement + if ( entries.find(e) == entries.end()) { + entries[e].emplace_back(vol_encoding); + ++numberOfNodes; + } + ++count; } } chain.pop_back(); diff --git a/DDCore/src/plugins/DetectorCheck.cpp b/DDCore/src/plugins/DetectorCheck.cpp index 2add90095..53b251e68 100644 --- a/DDCore/src/plugins/DetectorCheck.cpp +++ b/DDCore/src/plugins/DetectorCheck.cpp @@ -12,24 +12,22 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Factories.h" -#include "DD4hep/IDDescriptor.h" -#include "DD4hep/VolumeManager.h" -#include "DD4hep/DetectorTools.h" -#include "DD4hep/MatrixHelpers.h" -#include "DD4hep/AlignmentsNominalMap.h" -#include "DD4hep/detail/VolumeManagerInterna.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include // C/C++ include files #include #include #include -using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; /// Namespace for the AIDA detector description toolkit namespace dd4hep { namespace detail { namespace tools { @@ -65,8 +63,8 @@ namespace { /// Helper to scan volume ids struct FND { - const string& test; - FND(const string& c) : test(c) {} + const std::string& test; + FND(const std::string& c) : test(c) {} bool operator()(const VolIDs::value_type& c) const { return c.first == test; } }; struct counters { @@ -74,9 +72,9 @@ namespace { size_t errors { 0 }; void reset() { elements = errors = 0; } counters& operator+=(const counters& c) { - elements += c.elements; - errors += c.errors; - return *this; + elements += c.elements; + errors += c.errors; + return *this; } }; @@ -173,10 +171,10 @@ void DetectorCheck::execute(DetElement sdet, size_t depth) { else { m_current_sensitive = description.sensitiveDetector(m_det.name()); if ( !m_current_sensitive.isValid() ) { - printout(ERROR, m_name, - "The sensitive detector of subdetector %s " - "is not known to the geometry.", m_det.name()); - return; + printout(ERROR, m_name, + "The sensitive detector of subdetector %s " + "is not known to the geometry.", m_det.name()); + return; } m_current_iddesc = m_current_sensitive.readout().idSpec(); } @@ -232,31 +230,31 @@ void DetectorCheck::execute(DetElement sdet, size_t depth) { if ( check_structure ) { printout(count_struct.errors > 0 ? ERROR : ALWAYS, - m_name, "+++ %s: Checked %10ld structure elements. Num.Errors:%6ld (structure test)", - tag_fail(count_struct.errors), count_struct.elements, count_struct.errors); + m_name, "+++ %s: Checked %10ld structure elements. Num.Errors:%6ld (structure test)", + tag_fail(count_struct.errors), count_struct.elements, count_struct.errors); } if ( check_geometry ) { if ( check_sensitive ) { printout(count_geo_sens.errors > 0 ? ERROR : ALWAYS, - m_name, "+++ %s: Checked %10ld sensitive elements. Num.Errors:%6ld (geometry test)", - tag_fail(count_geo_sens.errors), count_geo_sens.elements, count_geo_sens.errors); + m_name, "+++ %s: Checked %10ld sensitive elements. Num.Errors:%6ld (geometry test)", + tag_fail(count_geo_sens.errors), count_geo_sens.elements, count_geo_sens.errors); } printout(count_geo.errors > 0 ? ERROR : ALWAYS, - m_name, "+++ %s: Checked %10ld placements. Num.Errors:%6ld (geometry test)", - tag_fail(count_geo.errors), count_geo.elements, count_geo.errors); + m_name, "+++ %s: Checked %10ld placements. Num.Errors:%6ld (geometry test)", + tag_fail(count_geo.errors), count_geo.elements, count_geo.errors); } if ( check_volmgr ) { if ( check_sensitive ) { printout(count_volmgr_sens.errors > 0 ? ERROR : ALWAYS, - m_name, "+++ %s: Checked %10ld sensitive elements. Num.Errors:%6ld (phys.VolID test)", - tag_fail(count_volmgr_sens.errors), count_volmgr_sens.elements, count_volmgr_sens.errors); + m_name, "+++ %s: Checked %10ld sensitive elements. Num.Errors:%6ld (phys.VolID test)", + tag_fail(count_volmgr_sens.errors), count_volmgr_sens.elements, count_volmgr_sens.errors); } printout(count_volmgr_place.errors > 0 ? ERROR : ALWAYS, - m_name, "+++ %s: Checked %10ld sensitive placements. Num.Errors:%6ld (phys.VolID test)", - tag_fail(count_volmgr_place.errors), count_volmgr_sens.elements, count_volmgr_place.errors); + m_name, "+++ %s: Checked %10ld sensitive placements. Num.Errors:%6ld (phys.VolID test)", + tag_fail(count_volmgr_place.errors), count_volmgr_sens.elements, count_volmgr_place.errors); } printout(ALWAYS, m_name, "+++ %s: Checked a total of %11ld elements. Num.Errors:%6ld (Some elements checked twice)", - tag_fail(total.errors), total.elements, total.errors); + tag_fail(total.errors), total.elements, total.errors); } /// Check DetElement integrity @@ -276,7 +274,7 @@ bool DetectorCheck::checkDetElement(const std::string& path, DetElement detector } if ( detector.path() != path ) { printout(ERROR, m_name, "Invalid DetElement [path mismatch]: %s <> %s", - de_path, path.c_str()); + de_path, path.c_str()); ++m_struct_counters.errors; } if ( !detector.parent().isValid() && detector.world() != detector ) { @@ -303,7 +301,7 @@ bool DetectorCheck::checkDetElement(const std::string& path, DetElement detector if ( count > 1 ) { DetElement par = detector.parent(); printout(ERROR, m_name, "DetElement %s parent: %s is placed %ld times! Only single placement allowed.", - de_path, par.isValid() ? par.path().c_str() : "", m_structure_elements[detector]); + de_path, par.isValid() ? par.path().c_str() : "", m_structure_elements[detector]); ++m_struct_counters.errors; } Alignment ideal = detector.nominal(); @@ -322,9 +320,9 @@ bool DetectorCheck::checkDetElement(const std::string& path, DetElement detector } } printout(nerrs != m_struct_counters.errors ? ERROR : INFO, m_name, - "DetElement %s [%s] parent: %s placement: %s [%s] volume: %s", - path.c_str(), yes_no(det_valid), yes_no(parent_valid), yes_no(det_place_valid), - yes_no(place_valid), yes_no(vol_valid)); + "DetElement %s [%s] parent: %s placement: %s [%s] volume: %s", + path.c_str(), yes_no(det_valid), yes_no(parent_valid), yes_no(det_place_valid), + yes_no(place_valid), yes_no(vol_valid)); return nerrs == m_struct_counters.errors; } @@ -350,7 +348,7 @@ bool DetectorCheck::checkDetElementTree(const std::string& path, DetElement dete if ( de.parent().isValid() && de.parent() != detector ) { printout(ERROR, m_name, "Invalid DetElement [Parent mismatch]: %s", de.path().c_str()); printout(ERROR, m_name, " apparent parent: %s structural parent: %s", - de.parent().path().c_str(), detector.path().c_str()); + de.parent().path().c_str(), detector.path().c_str()); ++m_struct_counters.errors; } /// Invalid daughter elements will be detectoed in there: @@ -419,8 +417,8 @@ void DetectorCheck::checkVolumeTree(DetElement detector, PlacedVolume pv) { /// Check if there is a new parent at the next level: for ( const auto& c : detector.children() ) { if ( c.second.placement() == place ) { - de = c.second; - break; + de = c.second; + break; } } checkVolumeTree(de, place); @@ -433,7 +431,7 @@ void DetectorCheck::checkVolumeTree(DetElement detector, PlacedVolume pv) { /// Check volume integrity void DetectorCheck::checkManagerSingleVolume(DetElement detector, PlacedVolume pv, const VolIDs& child_ids, const Chain& chain) { - stringstream err, log; + std::stringstream err, log; VolumeID det_vol_id = detector.volumeID(); VolumeID vid = det_vol_id; DetElement top_sdet, det_elem; @@ -466,7 +464,7 @@ void DetectorCheck::checkManagerSingleVolume(DetElement detector, PlacedVolume p ++m_place_counters.errors; } else if ( !detail::tools::isParentElement(detector,det_elem) ) { - // This is sort of a bit wischi-waschi.... + // This is sort of a bit wischi-waschi.... err << "VolumeMgrTest: Wrong associated detector element vid=" << volumeID(vid) << " got " << det_elem.path() << " (" << (void*)det_elem.ptr() << ") " << " instead of " << detector.path() << " (" << (void*)detector.ptr() << ")" @@ -480,30 +478,30 @@ void DetectorCheck::checkManagerSingleVolume(DetElement detector, PlacedVolume p } } } - catch(const exception& ex) { + catch(const std::exception& ex) { err << "Lookup " << pv.name() << " id:" << volumeID(vid) << " path:" << detector.path() << " error:" << ex.what(); ++m_place_counters.errors; } if ( pv.volume().isSensitive() || (0 != det_vol_id) ) { - string id_desc; - log << "Volume:" << setw(50) << left << pv.name(); + std::string id_desc; + log << "Volume:" << std::setw(50) << std::left << pv.name(); if ( pv.volume().isSensitive() ) { IDDescriptor dsc = SensitiveDetector(pv.volume().sensitiveDetector()).readout().idSpec(); log << " IDDesc:" << (char*)(dsc.ptr() == m_current_iddesc.ptr() ? "OK " : "BAD"); if ( dsc.ptr() != m_current_iddesc.ptr() ) ++m_place_counters.errors; } else { - log << setw(11) << " "; + log << std::setw(11) << " "; } id_desc = m_current_iddesc.str(vid); - log << " [" << char(pv.volume().isSensitive() ? 'S' : 'N') << "] " << right + log << " [" << char(pv.volume().isSensitive() ? 'S' : 'N') << "] " << std::right << " vid:" << volumeID(vid) << " " << id_desc; if ( !err.str().empty() ) { printout(ERROR, m_det.name(),err.str()+" "+log.str()); - //throw runtime_error(err.str()); + //throw std::runtime_error(err.str()); return; } id_desc = m_current_iddesc.str(det_elem.volumeID()); @@ -549,7 +547,7 @@ void DetectorCheck::checkManagerSingleVolume(DetElement detector, PlacedVolume p /// Check nominal and DetElement trafos for pointer equality: if ( &det_elem.nominal().worldTransformation() != &m_volMgr.worldTransformation(m_mapping,det_elem.volumeID()) ) { - printout(ERROR, m_det.name(), "DETELEMENT_PERSISTENCY FAILED: World transformation have DIFFERET pointer!"); + printout(ERROR, m_det.name(), "DETELEMENT_PERSISTENCY FAILED: World transformation have DIFFERET pointer!"); ++m_place_counters.errors; } @@ -585,7 +583,7 @@ void DetectorCheck::checkManagerSingleVolume(DetElement detector, PlacedVolume p } } } - catch(const exception& ex) { + catch(const std::exception& ex) { err << "Matrix " << pv.name() << " id:" << volumeID(vid) << " path:" << detector.path() << " error:" << ex.what(); ++m_place_counters.errors; @@ -596,7 +594,7 @@ void DetectorCheck::checkManagerSingleVolume(DetElement detector, PlacedVolume p /// Walk through tree of detector elements void DetectorCheck::checkManagerVolumeTree(DetElement detector, PlacedVolume pv, VolIDs ids, const Chain& chain, - size_t depth, size_t mx_depth) + size_t depth, size_t mx_depth) { if ( depth <= mx_depth ) { const TGeoNode* current = pv.ptr(); @@ -611,15 +609,15 @@ void DetectorCheck::checkManagerVolumeTree(DetElement detector, PlacedVolume pv, Chain child_chain(chain); DetElement de = detector; if ( is_world ) { - /// Check if there is a new parent at the next level: - for ( const auto& c : detector.children() ) { - if ( c.second.placement() == place ) { - de = c.second; - break; - } - } - m_current_detector = de; - get_current_sensitive_detector(); + /// Check if there is a new parent at the next level: + for ( const auto& c : detector.children() ) { + if ( c.second.placement() == place ) { + de = c.second; + break; + } + } + m_current_detector = de; + get_current_sensitive_detector(); } place.access(); // Test validity child_chain.emplace_back(place); @@ -657,7 +655,7 @@ void DetectorCheck::help(int argc,char** argv) { /// Action routine to execute the test long DetectorCheck::run(Detector& description,int argc,char** argv) { - string name; + std::string name; bool volmgr = false; bool geometry = false; bool structure = false; diff --git a/DDCore/src/plugins/DetectorChecksum.cpp b/DDCore/src/plugins/DetectorChecksum.cpp index 0415aeb5f..0a3f42f35 100644 --- a/DDCore/src/plugins/DetectorChecksum.cpp +++ b/DDCore/src/plugins/DetectorChecksum.cpp @@ -29,6 +29,7 @@ #include #include #include + // C/C++ include files #include #include @@ -38,9 +39,10 @@ #include using namespace dd4hep; -using namespace dd4hep::detail; +using DetectorChecksum = dd4hep::detail::DetectorChecksum; namespace { + bool is_volume(const TGeoVolume* volume) { Volume v(volume); return v.data() != 0; diff --git a/DDCore/src/plugins/DetectorFields.cpp b/DDCore/src/plugins/DetectorFields.cpp index 87bc56319..040c47c7a 100644 --- a/DDCore/src/plugins/DetectorFields.cpp +++ b/DDCore/src/plugins/DetectorFields.cpp @@ -12,10 +12,12 @@ //========================================================================== // Framework includes -#include "DD4hep/Printout.h" -#include "DD4hep/FieldTypes.h" -#include "DD4hep/MatrixHelpers.h" -#include "DD4hep/DetFactoryHelper.h" +#include +#include +#include +#include + +// C/C++ include files #include using namespace dd4hep; diff --git a/DDCore/src/plugins/DetectorHelperTest.cpp b/DDCore/src/plugins/DetectorHelperTest.cpp index 556490130..c9c2305cc 100644 --- a/DDCore/src/plugins/DetectorHelperTest.cpp +++ b/DDCore/src/plugins/DetectorHelperTest.cpp @@ -12,19 +12,16 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Factories.h" -#include "DD4hep/DetectorHelper.h" +#include +#include +#include +#include // C/C++ include files #include #include -using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; - namespace { diff --git a/DDCore/src/plugins/Geant4XML.cpp b/DDCore/src/plugins/Geant4XML.cpp index 3720c0c83..7fc993cba 100644 --- a/DDCore/src/plugins/Geant4XML.cpp +++ b/DDCore/src/plugins/Geant4XML.cpp @@ -11,24 +11,23 @@ // //========================================================================== -#include "XML/Conversions.h" -#include "DD4hep/DetFactoryHelper.h" +#include +#include namespace dd4hep { struct Geant4; class GdmlFile; class Property; class SensitiveDetector; -} -using namespace dd4hep; -namespace dd4hep { template <> void Converter::operator()(xml_h e) const; template <> void Converter::operator()(xml_h e) const; template <> void Converter::operator()(xml_h e) const; template <> void Converter::operator()(xml_h e) const; } +using namespace dd4hep; + template <> void Converter::operator()(xml_h element) const { xml_elt_t compact(element); //xml_coll_t(compact,_U(includes) ).for_each(_U(gdmlFile), Converter(description,param)); diff --git a/DDCore/src/plugins/GeometryWalk.cpp b/DDCore/src/plugins/GeometryWalk.cpp index d6d38d72a..55177b0a4 100644 --- a/DDCore/src/plugins/GeometryWalk.cpp +++ b/DDCore/src/plugins/GeometryWalk.cpp @@ -12,26 +12,24 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Factories.h" -#include "DD4hep/IDDescriptor.h" -#include "DD4hep/VolumeManager.h" -#include "DD4hep/DetectorTools.h" -//#include "DD4hep/DetectorAlignment.h" +#include +#include +#include +#include +#include +#include // C/C++ include files #include #include -using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; -typedef detail::tools::ElementPath ElementPath; -typedef detail::tools::PlacementPath PlacementPath; +using ElementPath = detail::tools::ElementPath; +using PlacementPath = detail::tools::PlacementPath; namespace { + /** @class GeometryWalk * * Test the volume manager by scanning the sensitive @@ -43,8 +41,8 @@ namespace { struct GeometryWalk { /// Helper to scan volume ids struct FND { - const string& test; - FND(const string& c) : test(c) {} + const std::string& test; + FND(const std::string& c) : test(c) {} bool operator()(const PlacedVolume::VolIDs::value_type& c) const { return c.first == test; } }; VolumeManager m_mgr; @@ -69,35 +67,35 @@ typedef DetElement::Children _C; GeometryWalk::GeometryWalk(Detector& description, DetElement sdet) : m_det(sdet) { m_mgr = description.volumeManager(); if ( !m_det.isValid() ) { - stringstream err; + std::stringstream err; err << "The subdetector " << m_det.name() << " is not known to the geometry."; printout(INFO,"GeometryWalk",err.str().c_str()); - throw runtime_error(err.str()); + throw std::runtime_error(err.str()); } walk(m_det,PlacedVolume::VolIDs()); } /// Printout volume information void GeometryWalk::print(DetElement e, PlacedVolume pv, const PlacedVolume::VolIDs& /* child_ids */) const { - stringstream log; + std::stringstream log; PlacementPath all_nodes; ElementPath det_elts; detail::tools::elementPath(e,det_elts); detail::tools::placementPath(e,all_nodes); - string elt_path = detail::tools::elementPath(det_elts); - string node_path = detail::tools::placementPath(all_nodes); - log << "Lookup " << left << setw(32) << pv.name() << " Detector[" << det_elts.size() << "]: " << elt_path; + std::string elt_path = detail::tools::elementPath(det_elts); + std::string node_path = detail::tools::placementPath(all_nodes); + log << "Lookup " << std::left << std::setw(32) << pv.name() << " Detector[" << det_elts.size() << "]: " << elt_path; printout(INFO,m_det.name(),log.str()); log.str(""); - log << " " << left << setw(32) << " " << " Places[" << all_nodes.size() << "]: " << node_path; + log << " " << std::left << std::setw(32) << " " << " Places[" << all_nodes.size() << "]: " << node_path; printout(INFO,m_det.name(),log.str()); log.str(""); - log << " " << left << setw(32) << " " << " detail::matrix[" << all_nodes.size() << "]: "; + log << " " << std::left << std::setw(32) << " " << " detail::matrix[" << all_nodes.size() << "]: "; for(PlacementPath::const_iterator i=all_nodes.begin(); i!=all_nodes.end(); ++i) { log << (void*)((*i)->GetMatrix()) << " "; if ( i+1 == all_nodes.end() ) log << "( -> " << (*i)->GetName() << ")"; } - printout(INFO,m_det.name(),log.str()); + printout(INFO, m_det.name(), log.str()); } /// Walk through tree of volume placements @@ -114,20 +112,20 @@ void GeometryWalk::walk(DetElement e, PlacedVolume::VolIDs ids) const { /// Action routine to execute the test long GeometryWalk::run(Detector& description,int argc,char** argv) { - cout << "++ Processing plugin....GeometryWalker.." << endl; + std::cout << "++ Processing plugin....GeometryWalker.." << std::endl; DetElement world = description.world(); for(int in=1; in < argc; ++in) { - string name = argv[in]+1; + std::string name = argv[in]+1; if ( name == "all" || name == "All" || name == "ALL" ) { const _C& children = world.children(); for (_C::const_iterator i=children.begin(); i!=children.end(); ++i) { DetElement sdet = (*i).second; - cout << "++ Processing subdetector: " << sdet.name() << endl; + std::cout << "++ Processing subdetector: " << sdet.name() << std::endl; GeometryWalk test(description, sdet); } return 1; } - cout << "++ Processing subdetector: " << name << endl; + std::cout << "++ Processing subdetector: " << name << std::endl; GeometryWalk test(description, description.detector(name)); } return 1; diff --git a/DDCore/src/plugins/JsonProcessor.cpp b/DDCore/src/plugins/JsonProcessor.cpp index d147e6128..df149c060 100644 --- a/DDCore/src/plugins/JsonProcessor.cpp +++ b/DDCore/src/plugins/JsonProcessor.cpp @@ -46,11 +46,9 @@ namespace { class detector; } -using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; -static void setChildTitles(const pair& e) { +static void setChildTitles(const std::pair& e) { DetElement parent = e.second.parent(); const DetElement::Children& children = e.second.children(); if (::strlen(e.second->GetTitle()) == 0) { @@ -65,10 +63,10 @@ namespace dd4hep { /// This is the identical converter as it is used for the XML compact! template <> void Converter::operator()(json_h element) const { - string type = element.attr(_U(type)); - string name = element.attr(_U(name)); - string name_match = ":" + name + ":"; - string type_match = ":" + type + ":"; + std::string type = element.attr(_U(type)); + std::string name = element.attr(_U(name)); + std::string name_match = ":" + name + ":"; + std::string type_match = ":" + type + ":"; try { json_attr_t attr_par = element.attr_nothrow(_U(parent)); @@ -76,7 +74,7 @@ template <> void Converter::operator()(json_h element) const { // We have here a nested detector. If the mother volume is not yet registered // it must be done here, so that the detector constructor gets the correct answer from // the call to Detector::pickMotherVolume(DetElement). - string par_name = element.attr(attr_par); + std::string par_name = element.attr(attr_par); DetElement parent_detector = description.detector(par_name); if ( !parent_detector.isValid() ) { except("Compact","Failed to access valid parent detector of %s",name.c_str()); @@ -87,9 +85,9 @@ template <> void Converter::operator()(json_h element) const { SensitiveDetector sd; Segmentation seg; if ( attr_ro ) { - Readout ro = description.readout(element.attr(attr_ro)); + Readout ro = description.readout(element.attr(attr_ro)); if (!ro.isValid()) { - throw runtime_error("No Readout structure present for detector:" + name); + throw std::runtime_error("No Readout structure present for detector:" + name); } seg = ro.segmentation(); sd = SensitiveDetector(name, "sensitive"); @@ -100,7 +98,7 @@ template <> void Converter::operator()(json_h element) const { Handle sens = sd; DetElement det(PluginService::Create(type, &description, &element, &sens)); if (det.isValid()) { - setChildTitles(make_pair(name, det)); + setChildTitles(std::make_pair(name, det)); if ( sd.isValid() ) { det->flag |= DetElement::Object::HAVE_SENSITIVE_DETECTOR; } @@ -116,18 +114,18 @@ template <> void Converter::operator()(json_h element) const { if (!det.isValid()) { PluginDebug dbg; PluginService::Create(type, &description, &element, &sens); - throw runtime_error("Failed to execute subdetector creation plugin. " + dbg.missingFactory(type)); + throw std::runtime_error("Failed to execute subdetector creation plugin. " + dbg.missingFactory(type)); } description.addDetector(det); return; } - catch (const exception& e) { + catch (const std::exception& e) { printout(ERROR, "Compact", "++ FAILED to convert subdetector: %s: %s", name.c_str(), e.what()); - terminate(); + std::terminate(); } catch (...) { printout(ERROR, "Compact", "++ FAILED to convert subdetector: %s: %s", name.c_str(), "UNKNONW Exception"); - terminate(); + std::terminate(); } } @@ -140,8 +138,8 @@ static long handle_json(Detector& description, int argc, char** argv) { "\n"); exit(EINVAL); } - string file = argv[0]; - if ( file[0] != '/' ) file = string(argv[1]) + "/" + file; + std::string file = argv[0]; + if ( file[0] != '/' ) file = std::string(argv[1]) + "/" + file; printout(INFO,"JsonProcessor","++ Processing JSON input: %s",file.c_str()); json::DocumentHolder doc(json::DocumentHandler().load(file.c_str())); diff --git a/DDCore/src/plugins/LCDD2Output.cpp b/DDCore/src/plugins/LCDD2Output.cpp index b5f5dbcd0..ee7b10b18 100644 --- a/DDCore/src/plugins/LCDD2Output.cpp +++ b/DDCore/src/plugins/LCDD2Output.cpp @@ -11,51 +11,56 @@ // //========================================================================== +// Framework includes #include "XML/Conversions.h" #include "DD4hep/Detector.h" #include "DD4hep/Objects.h" #include "DD4hep/Printout.h" #include "DD4hep/IDDescriptor.h" +// ROOT includes #include "TMap.h" #include "TROOT.h" #include "TColor.h" #include "TGeoMatrix.h" #include "TGeoManager.h" + +/// C/C++ include files #include #include -using namespace std; +/// Namespace for the AIDA detector description toolkit namespace dd4hep { - using namespace detail; void dumpNode(TGeoNode* n, int level) { TGeoMatrix* mat = n->GetMatrix(); TGeoVolume* vol = n->GetVolume(); TGeoMedium* med = vol->GetMedium(); - TGeoShape* shape = vol->GetShape(); - TObjArray* nodes = vol->GetNodes(); + TGeoShape* shape = vol->GetShape(); + TObjArray* nodes = vol->GetNodes(); for (int i = 0; i < level; ++i) - cout << " "; - cout << " ++Node:|" << n->GetName() << "| "; - cout << " Volume: " << vol->GetName() << " material:" << med->GetName() << " shape:" << shape->GetName() << endl; + std::cout << " "; + std::cout << " ++Node:|" << n->GetName() << "| "; + std::cout << " Volume: " << vol->GetName() << " material:" << med->GetName() + << " shape:" << shape->GetName() << std::endl; for (int i = 0; i < level; ++i) - cout << " "; + std::cout << " "; const Double_t* tr = mat->GetTranslation(); - cout << " matrix:|" << mat->GetName() << "|" << mat->IsTranslation() << mat->IsRotation() << mat->IsScale() - << " tr:x=" << tr[0] << " y=" << tr[1] << " z=" << tr[2]; + std::cout << " matrix:|" << mat->GetName() + << "|" << mat->IsTranslation() << mat->IsRotation() << mat->IsScale() + << " tr:x=" << tr[0] << " y=" << tr[1] << " z=" << tr[2]; if (mat->IsRotation()) { Double_t theta, phi, psi; TGeoRotation rot(*mat); rot.GetAngles(phi, theta, psi); - cout << " rot: theta:" << theta << " phi:" << phi << " psi:" << psi; + std::cout << " rot: theta:" << theta << " phi:" << phi << " psi:" << psi; } - cout << endl; + std::cout << std::endl; PlacedVolume plv(n); for (int i = 0; i < level; ++i) - cout << " "; - cout << " volume:" << plv.toString(); - cout << endl; + std::cout << " "; + std::cout << " volume:" << plv.toString(); + std::cout << std::endl; TIter next(nodes); TGeoNode *geoNode; while ((geoNode = (TGeoNode *) next())) { @@ -69,8 +74,8 @@ namespace dd4hep { TGeoShape* shape = vol->GetShape(); for (int i = 0; i < level; ++i) - cout << " "; - cout << "++Volume: " << vol->GetName() << " material:" << med->GetName() << " shape:" << shape->GetName() << endl; + std::cout << " "; + std::cout << "++Volume: " << vol->GetName() << " material:" << med->GetName() << " shape:" << shape->GetName() << std::endl; TIter next(nodes); TGeoNode *geoNode; while ((geoNode = (TGeoNode *) next())) { diff --git a/DDCore/src/plugins/LCDDConverter.cpp b/DDCore/src/plugins/LCDDConverter.cpp index c0afbe2c2..e7dccbea8 100644 --- a/DDCore/src/plugins/LCDDConverter.cpp +++ b/DDCore/src/plugins/LCDDConverter.cpp @@ -12,52 +12,54 @@ //========================================================================== // Framework includes -#include "DD4hep/Plugins.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Volumes.h" -#include "DD4hep/FieldTypes.h" -#include "DD4hep/DD4hepUnits.h" -#include "DD4hep/Segmentations.h" -#include "DD4hep/detail/ObjectsInterna.h" -#include "DD4hep/detail/DetectorInterna.h" -#include "XML/DocumentHandler.h" #include "LCDDConverter.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include // ROOT includes -#include "TROOT.h" -#include "TColor.h" -#include "TGeoShape.h" - -#include "TGeoArb8.h" -#include "TGeoBoolNode.h" -#include "TGeoCompositeShape.h" -#include "TGeoCone.h" -#include "TGeoEltu.h" -#include "TGeoHype.h" -#include "TGeoMatrix.h" -#include "TGeoParaboloid.h" -#include "TGeoPara.h" -#include "TGeoPcon.h" -#include "TGeoPgon.h" -#include "TGeoShapeAssembly.h" -#include "TGeoSphere.h" -#include "TGeoTorus.h" -#include "TGeoTrd1.h" -#include "TGeoTrd2.h" -#include "TGeoTube.h" -#include "TGeoScaledShape.h" - -#include "TGeoNode.h" -#include "TClass.h" -#include "TMath.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +/// C/C++ include files #include #include #include #include -using namespace dd4hep::detail; using namespace dd4hep; -using namespace std; +using namespace dd4hep::detail; + namespace { typedef Position XYZRotation; @@ -86,8 +88,8 @@ namespace { c = 0; } XYZRotation rr(a, b, c); - cout << " X:" << a << " " << rr.X() << " Y:" << b << " " << rr.Y() << " Z:" << c << " " << rr.Z() - << " lx:" << r[0] << " ly:" << r[4] << " lz:" << r[8] << endl; + std::cout << " X:" << a << " " << rr.X() << " Y:" << b << " " << rr.Y() << " Z:" << c << " " << rr.Z() + << " lx:" << r[0] << " ly:" << r[4] << " lz:" << r[8] << std::endl; return XYZRotation(a, b, c); } #endif @@ -100,9 +102,9 @@ namespace { return node.data() != 0; } - string genName(const string& n) { return n; } - string genName(const string& n, const void* ptr) { - string nn = genName(n); + std::string genName(const std::string& n) { return n; } + std::string genName(const std::string& n, const void* ptr) { + std::string nn = genName(n); char text[32]; ::snprintf(text,sizeof(text),"%p",ptr); nn += "_"; @@ -111,11 +113,11 @@ namespace { } } -void LCDDConverter::GeometryInfo::check(const string& name, const TNamed* _n, map& _m) const { - map::const_iterator i = _m.find(name); +void LCDDConverter::GeometryInfo::check(const std::string& name, const TNamed* _n, std::map& _m) const { + std::map::const_iterator i = _m.find(name); if (i != _m.end()) { const char* isa = _n ? _n->IsA()->GetName() : (*i).second ? (*i).second->IsA()->GetName() : "Unknown"; - cout << isa << "(position): duplicate entry with name:" << name << " " << (void*) _n << " " << (void*) (*i).second << endl; + std::cout << isa << "(position): duplicate entry with name:" << name << " " << (void*) _n << " " << (void*) (*i).second << std::endl; } _m.insert(make_pair(name, _n)); } @@ -132,7 +134,7 @@ LCDDConverter::~LCDDConverter() { } /// Dump element in GDML format to output stream -xml_h LCDDConverter::handleElement(const string& /* name */, Atom element) const { +xml_h LCDDConverter::handleElement(const std::string& /* name */, Atom element) const { GeometryInfo& geo = data(); xml_h e = geo.xmlElements[element]; if (!e) { @@ -155,7 +157,7 @@ xml_h LCDDConverter::handleElement(const string& /* name */, Atom element) const } /// Dump material in GDML format to output stream -xml_h LCDDConverter::handleMaterial(const string& name, Material medium) const { +xml_h LCDDConverter::handleMaterial(const std::string& name, Material medium) const { GeometryInfo& geo = data(); xml_h mat = geo.xmlMaterials[medium]; if (!mat) { @@ -184,7 +186,7 @@ xml_h LCDDConverter::handleMaterial(const string& name, Material medium) const { } for (int i = 0, n = mix->GetNelements(); i < n; i++) { TGeoElement *elt = mix->GetElement(i); - //string formula = elt->GetTitle() + string("_elm"); + //std::string formula = elt->GetTitle() + std::string("_elm"); if (nmix) { mat.append(obj = xml_elt_t(geo.doc, _U(composite))); obj.setAttr(_U(n), nmix[i]); @@ -216,7 +218,7 @@ xml_h LCDDConverter::handleMaterial(const string& name, Material medium) const { } /// Dump solid in GDML format to output stream -xml_h LCDDConverter::handleSolid(const string& name, const TGeoShape* shape) const { +xml_h LCDDConverter::handleSolid(const std::string& name, const TGeoShape* shape) const { GeometryInfo& geo = data(); SolidMap::iterator sit = geo.xmlSolids.find(shape); if (!shape) { @@ -236,7 +238,7 @@ xml_h LCDDConverter::handleSolid(const string& name, const TGeoShape* shape) con xml_h solid(0); xml_h zplane(0); TClass* isa = shape->IsA(); - string shape_name = shape->GetName(); //genName(shape->GetName(),shape); + std::string shape_name = shape->GetName(); //genName(shape->GetName(),shape); geo.checkShape(name, shape); if (isa == TGeoBBox::Class()) { const TGeoBBox* sh = (const TGeoBBox*) shape; @@ -501,10 +503,10 @@ xml_h LCDDConverter::handleSolid(const string& name, const TGeoShape* shape) con xml_h right = handleSolid(rs->GetName(), rs); xml_h first_solid(0), second_solid(0); if (!left) { - throw runtime_error("G4Converter: No left Detector Solid present for composite shape:" + name); + throw std::runtime_error("G4Converter: No left Detector Solid present for composite shape:" + name); } if (!right) { - throw runtime_error("G4Converter: No right Detector Solid present for composite shape:" + name); + throw std::runtime_error("G4Converter: No right Detector Solid present for composite shape:" + name); } //specific case! @@ -545,8 +547,8 @@ xml_h LCDDConverter::handleSolid(const string& name, const TGeoShape* shape) con solid = xml_elt_t(geo.doc,_U(intersection)); xml_h obj; - string lnam = left.attr(_U(name)); - string rnam = right.attr(_U(name)); + std::string lnam = left.attr(_U(name)); + std::string rnam = right.attr(_U(name)); geo.doc_solids.append(solid); solid.append(first_solid = xml_elt_t(geo.doc, _U(first))); @@ -591,8 +593,8 @@ xml_h LCDDConverter::handleSolid(const string& name, const TGeoShape* shape) con } } if (!solid) { - string err = "Failed to handle unknown solid shape:" + name + " of type " + string(shape->IsA()->GetName()); - throw runtime_error(err); + std::string err = "Failed to handle unknown solid shape:" + name + " of type " + std::string(shape->IsA()->GetName()); + throw std::runtime_error(err); } return data().xmlSolids[shape] = solid; } @@ -605,7 +607,7 @@ xml_h LCDDConverter::handlePosition(const std::string& name, const TGeoMatrix* t if (!pos) { const double* tr = trafo->GetTranslation(); if (tr[0] != 0.0 || tr[1] != 0.0 || tr[2] != 0.0) { - string gen_name = genName(name,trafo); + std::string gen_name = genName(name,trafo); geo.checkPosition(gen_name, trafo); geo.doc_define.append(pos = xml_elt_t(geo.doc, _U(position))); pos.setAttr(_U(name), gen_name); @@ -639,7 +641,7 @@ xml_h LCDDConverter::handleRotation(const std::string& name, const TGeoMatrix* t if (!rot) { XYZRotation r = getXYZangles(trafo->GetRotationMatrix()); if (!(r.X() == 0.0 && r.Y() == 0.0 && r.Z() == 0.0)) { - string gen_name = genName(name,trafo); + std::string gen_name = genName(name,trafo); geo.checkRotation(gen_name, trafo); geo.doc_define.append(rot = xml_elt_t(geo.doc, _U(rotation))); rot.setAttr(_U(name), gen_name); @@ -667,13 +669,13 @@ xml_h LCDDConverter::handleRotation(const std::string& name, const TGeoMatrix* t } /// Dump logical volume in GDML format to output stream -xml_h LCDDConverter::handleVolume(const string& /* name */, Volume volume) const { +xml_h LCDDConverter::handleVolume(const std::string& /* name */, Volume volume) const { GeometryInfo& geo = data(); xml_h vol = geo.xmlVolumes[volume]; if (!vol) { const TGeoVolume* v = volume; Volume _v(v); - string n = genName(v->GetName(),v); + std::string n = genName(v->GetName(),v); TGeoMedium* medium = v->GetMedium(); TGeoShape* sh = v->GetShape(); xml_ref_t sol = handleSolid(sh->GetName(), sh); @@ -685,15 +687,15 @@ xml_h LCDDConverter::handleVolume(const string& /* name */, Volume volume) const } else { if (!sol) - throw runtime_error("G4Converter: No Detector Solid present for volume:" + n); + throw std::runtime_error("G4Converter: No Detector Solid present for volume:" + n); else if (!m) - throw runtime_error("G4Converter: No Detector material present for volume:" + n); + throw std::runtime_error("G4Converter: No Detector material present for volume:" + n); vol = xml_elt_t(geo.doc, _U(volume)); vol.setAttr(_U(name), n); if (m) { - string mat_name = medium->GetName(); - xml_ref_t med = handleMaterial(mat_name, Material(medium)); + std::string mat_name = medium->GetName(); + xml_ref_t med = handleMaterial(mat_name, Material(medium)); vol.setRef(_U(materialref), med.name()); } vol.setRef(_U(solidref), sol.name()); @@ -734,7 +736,7 @@ xml_h LCDDConverter::handleVolume(const string& /* name */, Volume volume) const } /// Dump logical volume in GDML format to output stream -xml_h LCDDConverter::handleVolumeVis(const string& /* name */, const TGeoVolume* volume) const { +xml_h LCDDConverter::handleVolumeVis(const std::string& /* name */, const TGeoVolume* volume) const { GeometryInfo& geo = data(); xml_h vol = geo.xmlVolumes[volume]; if (!vol) { @@ -755,7 +757,7 @@ xml_h LCDDConverter::handleVolumeVis(const string& /* name */, const TGeoVolume* } /// Dump logical volume in GDML format to output stream -void LCDDConverter::collectVolume(const string& /* name */, const TGeoVolume* volume) const { +void LCDDConverter::collectVolume(const std::string& /* name */, const TGeoVolume* volume) const { Volume v(volume); if ( is_volume(volume) ) { GeometryInfo& geo = data(); @@ -774,11 +776,11 @@ void LCDDConverter::collectVolume(const string& /* name */, const TGeoVolume* vo } } -void LCDDConverter::checkVolumes(const string& /* name */, Volume v) const { - string n = v.name()+_toString(v.ptr(),"_%p"); +void LCDDConverter::checkVolumes(const std::string& /* name */, Volume v) const { + std::string n = v.name()+_toString(v.ptr(),"_%p"); NameSet::const_iterator i = m_checkNames.find(n); if (i != m_checkNames.end()) { - stringstream str; + std::stringstream str; str << "++ CheckVolumes: Volume " << n << " "; if (is_volume(v.ptr())) { SensitiveDetector sd = v.sensitiveDetector(); @@ -790,7 +792,7 @@ void LCDDConverter::checkVolumes(const string& /* name */, Volume v) const { str << "with VisAttrs " << vis.name() << " "; } } - str << "has duplicate entries." << endl; + str << "has duplicate entries." << std::endl; printout(ERROR,"LCDDConverter",str.str().c_str()); return; } @@ -798,7 +800,7 @@ void LCDDConverter::checkVolumes(const string& /* name */, Volume v) const { } /// Dump volume placement in GDML format to output stream -xml_h LCDDConverter::handlePlacement(const string& name,PlacedVolume node) const { +xml_h LCDDConverter::handlePlacement(const std::string& name,PlacedVolume node) const { GeometryInfo& geo = data(); xml_h place = geo.xmlPlacements[node]; if (!place) { @@ -834,7 +836,7 @@ xml_h LCDDConverter::handlePlacement(const string& name,PlacedVolume node) const geo.xmlPlacements[node] = place; } else { - cout << "Attempt to DOUBLE-place physical volume:" << name << " No:" << node->GetNumber() << endl; + std::cout << "Attempt to DOUBLE-place physical volume:" << name << " No:" << node->GetNumber() << std::endl; } return place; } @@ -862,8 +864,8 @@ xml_h LCDDConverter::handleLimitSet(const std::string& /* name */, LimitSet lim) if (!xml) { geo.doc_limits.append(xml = xml_elt_t(geo.doc, _U(limitset))); xml.setAttr(_U(name), lim.name()); - const set& obj = lim.limits(); - for (set::const_iterator i = obj.begin(); i != obj.end(); ++i) { + const std::set& obj = lim.limits(); + for (std::set::const_iterator i = obj.begin(); i != obj.end(); ++i) { xml_h x = xml_elt_t(geo.doc, _U(limit)); const Limit& l = *i; xml.append(x); @@ -882,13 +884,13 @@ xml_h LCDDConverter::handleSegmentation(Segmentation seg) const { xml_h xml; if (seg.isValid()) { typedef DDSegmentation::Parameters _P; - string typ = seg.type(); + std::string typ = seg.type(); _P p = seg.parameters(); xml = xml_elt_t(data().doc, Unicode(typ)); for (_P::const_iterator i = p.begin(); i != p.end(); ++i) { const _P::value_type& v = *i; if (v->name() == "lunit") { - string val = v->value() == _toDouble("mm") ? "mm" : v->value() == _toDouble("cm") ? "cm" : + std::string val = v->value() == _toDouble("mm") ? "mm" : v->value() == _toDouble("cm") ? "cm" : v->value() == _toDouble("m") ? "m" : v->value() == _toDouble("micron") ? "micron" : v->value() == _toDouble("nanometer") ? "namometer" : "??"; xml.setAttr(Unicode(v->name()), Unicode(val)); @@ -910,7 +912,7 @@ xml_h LCDDConverter::handleSegmentation(Segmentation seg) const { } /// Convert the geometry type SensitiveDetector into the corresponding Detector object(s). -xml_h LCDDConverter::handleSensitive(const string& /* name */, SensitiveDetector sd) const { +xml_h LCDDConverter::handleSensitive(const std::string& /* name */, SensitiveDetector sd) const { GeometryInfo& geo = data(); xml_h sensdet = geo.xmlSensDets[sd]; if (!sensdet) { @@ -971,7 +973,7 @@ xml_h LCDDConverter::handleIdSpec(const std::string& name, IDDescriptor id_spec) } /// Convert the geometry visualisation attributes to the corresponding Detector object(s). -xml_h LCDDConverter::handleVis(const string& /* name */, VisAttr attr) const { +xml_h LCDDConverter::handleVis(const std::string& /* name */, VisAttr attr) const { GeometryInfo& geo = data(); xml_h vis = geo.xmlVis[attr]; if (!vis) { @@ -1010,7 +1012,7 @@ xml_h LCDDConverter::handleField(const std::string& /* name */, OverlayedField f xml_h field = geo.xmlFields[f]; if (!field) { Handle fld(f); - string type = f->GetTitle(); + std::string type = f->GetTitle(); field = xml_elt_t(geo.doc, Unicode(type)); field.setAttr(_U(name), f->GetName()); fld = PluginService::Create(type + "_Convert2Detector", &m_detDesc, &field, &fld); @@ -1019,8 +1021,8 @@ xml_h LCDDConverter::handleField(const std::string& /* name */, OverlayedField f if (!fld.isValid()) { PluginDebug dbg; PluginService::Create(type + "_Convert2Detector", &m_detDesc, &field, &fld); - throw runtime_error("Failed to locate plugin to convert electromagnetic field:" - + string(f->GetName()) + " of type " + type + ". " + throw std::runtime_error("Failed to locate plugin to convert electromagnetic field:" + + std::string(f->GetName()) + " of type " + type + ". " + dbg.missingFactory(type)); } geo.doc_fields.append(field); @@ -1030,11 +1032,11 @@ xml_h LCDDConverter::handleField(const std::string& /* name */, OverlayedField f /// Handle the geant 4 specific properties void LCDDConverter::handleProperties(Detector::Properties& prp) const { - map processors; + std::map processors; static int s_idd = 9999999; - string id; + std::string id; for (Detector::Properties::const_iterator i = prp.begin(); i != prp.end(); ++i) { - const string& nam = (*i).first; + const std::string& nam = (*i).first; const Detector::PropertyValues& vals = (*i).second; if (nam.substr(0, 6) == "geant4") { Detector::PropertyValues::const_iterator id_it = vals.find("id"); @@ -1049,25 +1051,25 @@ void LCDDConverter::handleProperties(Detector::Properties& prp) const { processors.insert(make_pair(id, nam)); } } - for (map::const_iterator i = processors.begin(); i != processors.end(); ++i) { + for (std::map::const_iterator i = processors.begin(); i != processors.end(); ++i) { const GeoHandler* ptr = this; - string nam = (*i).second; + std::string nam = (*i).second; const Detector::PropertyValues& vals = prp[nam]; - string type = vals.find("type")->second; - string tag = type + "_Geant4_action"; + std::string type = vals.find("type")->second; + std::string tag = type + "_Geant4_action"; long result = PluginService::Create(tag, &m_detDesc, ptr, &vals); if (0 == result) { PluginDebug dbg; result = PluginService::Create(tag, &m_detDesc, ptr, &vals); if (0 == result) { - throw runtime_error("Failed to locate plugin to interprete files of type" + throw std::runtime_error("Failed to locate plugin to interprete files of type" " \"" + tag + "\" - no factory:" + type + ". " + dbg.missingFactory(tag)); } } result = *(long*) result; if (result != 1) { - throw runtime_error("Failed to invoke the plugin " + tag + " of type " + type); + throw std::runtime_error("Failed to invoke the plugin " + tag + " of type " + type); } printout(INFO,"","+++ Executed Successfully Detector setup module %s.",type.c_str()); } @@ -1097,7 +1099,7 @@ void LCDDConverter::handleHeader() const { template void handle(const O* o, const C& c, F pmf) { for (typename C::const_iterator i = c.begin(); i != c.end(); ++i) { - string n = (*i)->GetName(); + std::string n = (*i)->GetName(); (o->*pmf)(n, *i); } } @@ -1116,7 +1118,7 @@ template void handleRMap(const O* o, const xml_doc_t LCDDConverter::createGDML(DetElement top) { Detector& description = m_detDesc; if (!top.isValid()) { - throw runtime_error("Attempt to call createGDML with an invalid geometry!"); + throw std::runtime_error("Attempt to call createGDML with an invalid geometry!"); } GeometryInfo& geo = *(m_dataPtr = new GeometryInfo); m_data->clear(); @@ -1171,7 +1173,7 @@ xml_doc_t LCDDConverter::createGDML(DetElement top) { /// Create geometry conversion xml_doc_t LCDDConverter::createVis(DetElement top) { if (!top.isValid()) { - throw runtime_error("Attempt to call createDetector with an invalid geometry!"); + throw std::runtime_error("Attempt to call createDetector with an invalid geometry!"); } GeometryInfo& geo = *(m_dataPtr = new GeometryInfo); @@ -1196,7 +1198,7 @@ xml_doc_t LCDDConverter::createVis(DetElement top) { xml_doc_t LCDDConverter::createDetector(DetElement top) { Detector& description = m_detDesc; if (!top.isValid()) { - throw runtime_error("Attempt to call createDetector with an invalid geometry!"); + throw std::runtime_error("Attempt to call createDetector with an invalid geometry!"); } GeometryInfo& geo = *(m_dataPtr = new GeometryInfo); @@ -1306,12 +1308,12 @@ static long create_visASCII(Detector& description, int /* argc */, char** argv) LCDDConverter wr(description); /* xml_doc_t doc = */ wr.createVis(description.world()); LCDDConverter::GeometryInfo& geo = wr.data(); - map vis_map; + std::map vis_map; for (xml_coll_t c(geo.doc_display, _U(vis)); c; ++c) vis_map.insert(make_pair(xml_comp_t(c).nameStr(), xml_comp_t(c))); const char* sep = ";"; - ofstream os(argv[0]); + std::ofstream os(argv[0]); for (xml_coll_t c(geo.doc_structure, _U(volume)); c; ++c) { xml_comp_t vol = c; xml_comp_t ref = c.child(_U(visref)); @@ -1321,9 +1323,9 @@ static long create_visASCII(Detector& description, int /* argc */, char** argv) << "visible:" << vis.visible() << sep << "r:" << col.R() << sep << "g:" << col.G() << sep << "b:" << col.B() << sep << "alpha:" << col.alpha() << sep << "line_style:" - << vis.attr < string > (_U(line_style)) << sep - << "drawing_style:" << vis.attr < string> (_U(drawing_style)) << sep - << "show_daughters:" << vis.show_daughters() << sep << endl; + << vis.attr < std::string > (_U(line_style)) << sep + << "drawing_style:" << vis.attr < std::string> (_U(drawing_style)) << sep + << "show_daughters:" << vis.show_daughters() << sep << std::endl; } os.close(); return 1; diff --git a/DDCore/src/plugins/PluginInvoker.cpp b/DDCore/src/plugins/PluginInvoker.cpp index 58564c341..8a4fde542 100644 --- a/DDCore/src/plugins/PluginInvoker.cpp +++ b/DDCore/src/plugins/PluginInvoker.cpp @@ -12,19 +12,17 @@ //========================================================================== // Framework includes -#include "DD4hep/Detector.h" -#include "DD4hep/Printout.h" -#include "XML/Conversions.h" -#include "XML/XMLElements.h" -#include "XML/DocumentHandler.h" -#include "DD4hep/DetFactoryHelper.h" +#include +#include +#include +#include +#include +#include // C/C++ include files #include -/* - * dd4hep namespace declaration - */ +/// Namespace for the AIDA detector description toolkit namespace dd4hep { namespace { @@ -47,9 +45,8 @@ namespace dd4hep { template <> void Converter::operator()(xml_h element) const; template <> void Converter::operator()(xml_h element) const; } -using namespace std; + using namespace dd4hep; -using namespace dd4hep::detail; /** Convert arg objects * @@ -59,8 +56,8 @@ using namespace dd4hep::detail; */ template <> void Converter::operator()(xml_h e) const { xml_comp_t c(e); - string val = c.valueStr(); - vector* args = (vector*)param; + std::string val = c.valueStr(); + std::vector* args = (std::vector*)param; args->emplace_back(val); } @@ -72,13 +69,13 @@ template <> void Converter::operator()(xml_h e) const { */ template <> void Converter::operator()(xml_h e) const { xml_comp_t c(e); - string nam = c.nameStr(); - vector args; - vector cargs; + std::string nam = c.nameStr(); + std::vector args; + std::vector cargs; //args.emplace_back("plugin:"+nam); xml_coll_t(e,"arg").for_each(Converter(description,&args)); - for(vector::const_iterator i=args.begin(); i!=args.end();++i) + for(std::vector::const_iterator i=args.begin(); i!=args.end();++i) cargs.emplace_back((*i).c_str()); printout(INFO,"ConverterPlugin","+++ Now executing plugin:%s [%d args]",nam.c_str(),int(cargs.size())); description.apply(nam.c_str(),int(cargs.size()),(char**)&cargs[0]); @@ -93,20 +90,20 @@ template <> void Converter::operator()(xml_h e) const { template <> void Converter::operator()(xml_h element) const { xml::DocumentHolder doc(xml::DocumentHandler().load(element, element.attr_value(_U(ref)))); xml_h node = doc.root(); - string tag = node.tag(); + std::string tag = node.tag(); if ( tag == "plugin" ) Converter(description,param)(node); else if ( tag == "plugins" ) Converter(description,param)(node); else - throw runtime_error("Undefined tag name in XML structure:"+tag+" XML parsing abandoned."); + throw std::runtime_error("Undefined tag name in XML structure:"+tag+" XML parsing abandoned."); } /** Convert plugins objects * - * @author M.Frank - * @version 1.0 - * @date 01/04/2014 + * \author M.Frank + * \version 1.0 + * \date 01/04/2014 */ template <> void Converter::operator()(xml_h e) const { xml_coll_t(e, _U(define)).for_each(_U(constant), Converter(description,param)); diff --git a/DDCore/src/plugins/ReadoutSegmentations.cpp b/DDCore/src/plugins/ReadoutSegmentations.cpp index 578c3bfbb..edfd47aea 100644 --- a/DDCore/src/plugins/ReadoutSegmentations.cpp +++ b/DDCore/src/plugins/ReadoutSegmentations.cpp @@ -12,8 +12,8 @@ //========================================================================== // Framework includes -#include "DD4hep/detail/SegmentationsInterna.h" -#include "DD4hep/Factories.h" +#include +#include using namespace dd4hep; using namespace dd4hep::DDSegmentation; @@ -25,59 +25,59 @@ namespace { } } -#include "DDSegmentation/NoSegmentation.h" +#include DECLARE_SEGMENTATION(NoSegmentation,create_segmentation) -#include "DDSegmentation/CartesianGridXY.h" +#include DECLARE_SEGMENTATION(CartesianGridXY,create_segmentation) -#include "DDSegmentation/CartesianGridXZ.h" +#include DECLARE_SEGMENTATION(CartesianGridXZ,create_segmentation) -#include "DDSegmentation/CartesianGridYZ.h" +#include DECLARE_SEGMENTATION(CartesianGridYZ,create_segmentation) -#include "DDSegmentation/CartesianGridXYZ.h" +#include DECLARE_SEGMENTATION(CartesianGridXYZ,create_segmentation) -#include "DDSegmentation/CartesianGridXYStaggered.h" +#include DECLARE_SEGMENTATION(CartesianGridXYStaggered,dd4hep::create_segmentation) -#include "DDSegmentation/CartesianStripX.h" +#include DECLARE_SEGMENTATION(CartesianStripX,create_segmentation) -#include "DDSegmentation/CartesianStripY.h" +#include DECLARE_SEGMENTATION(CartesianStripY,create_segmentation) -#include "DDSegmentation/CartesianStripZ.h" +#include DECLARE_SEGMENTATION(CartesianStripZ,create_segmentation) -#include "DDSegmentation/TiledLayerGridXY.h" +#include DECLARE_SEGMENTATION(TiledLayerGridXY,create_segmentation) -#include "DDSegmentation/MegatileLayerGridXY.h" +#include DECLARE_SEGMENTATION(MegatileLayerGridXY,create_segmentation) -#include "DDSegmentation/WaferGridXY.h" +#include DECLARE_SEGMENTATION(WaferGridXY,create_segmentation) -#include "DDSegmentation/PolarGridRPhi.h" +#include DECLARE_SEGMENTATION(PolarGridRPhi,create_segmentation) -#include "DDSegmentation/GridPhiEta.h" +#include DECLARE_SEGMENTATION(GridPhiEta,create_segmentation) -#include "DDSegmentation/GridRPhiEta.h" +#include DECLARE_SEGMENTATION(GridRPhiEta,create_segmentation) -#include "DDSegmentation/PolarGridRPhi2.h" +#include DECLARE_SEGMENTATION(PolarGridRPhi2,create_segmentation) -#include "DDSegmentation/ProjectiveCylinder.h" +#include DECLARE_SEGMENTATION(ProjectiveCylinder,create_segmentation) -#include "DDSegmentation/MultiSegmentation.h" +#include DECLARE_SEGMENTATION(MultiSegmentation,create_segmentation) -#include "DDSegmentation/HexGrid.h" +#include DECLARE_SEGMENTATION(HexGrid,create_segmentation) diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp index c39a628e7..78fff1386 100644 --- a/DDCore/src/plugins/StandardPlugins.cpp +++ b/DDCore/src/plugins/StandardPlugins.cpp @@ -48,8 +48,8 @@ using namespace dd4hep; using namespace dd4hep::detail; - namespace { + struct ProcessorArgs { bool use = false; int start = 0, end = 0, argc = 0, count=0; @@ -1711,7 +1711,7 @@ DECLARE_APPLY(DD4hep_DetectorTypes,detectortype_cache) * \version 1.0 * \date 01/04/2014 */ -#include "DD4hep/SurfaceInstaller.h" +#include typedef SurfaceInstaller TestSurfacesPlugin; DECLARE_SURFACE_INSTALLER(TestSurfaces,TestSurfacesPlugin) @@ -1723,7 +1723,7 @@ DECLARE_SURFACE_INSTALLER(TestSurfaces,TestSurfacesPlugin) * \version 1.0 * \date 01/04/2014 */ -#include "DD4hep/PluginTester.h" +#include static long install_plugin_tester(Detector& description, int , char** ) { PluginTester* test = description.extension(false); if ( !test ) { diff --git a/DDCore/src/plugins/VisDensityProcessor.cpp b/DDCore/src/plugins/VisDensityProcessor.cpp index 6679d1815..0e79a76e0 100644 --- a/DDCore/src/plugins/VisDensityProcessor.cpp +++ b/DDCore/src/plugins/VisDensityProcessor.cpp @@ -14,8 +14,9 @@ #define DD4HEP_DDCORE_VISDENSITYPROCESSOR_H // Framework include files -#include "DD4hep/VolumeProcessor.h" +#include +/// Namespace for the AIDA detector description toolkit namespace dd4hep { /// DD4hep DetElement creator for the CMS geometry. @@ -59,14 +60,13 @@ namespace dd4hep { // //========================================================================== -//#include "DD4hep/VisDensityProcessor.h" -#include "DD4hep/Printout.h" -#include "DD4hep/DetectorTools.h" -#include "DD4hep/DetectorHelper.h" -#include "DD4hep/DetFactoryHelper.h" +//#include +#include +#include +#include +#include #include -using namespace std; using namespace dd4hep; /// Initializing constructor @@ -124,7 +124,7 @@ static void* create_object(Detector& description, int argc, char** argv) { continue; } else if ( ::strncmp(argv[i],"-name",4) == 0 ) { - string name = argv[++i]; + std::string name = argv[++i]; proc->name = name; continue; } @@ -132,13 +132,13 @@ static void* create_object(Detector& description, int argc, char** argv) { proc->show = true; continue; } - cout << + std::cout << "Usage: DD4hep_VisDensityProcessor -arg [-arg] \n" " -vis Set the visualization attribute for inactive materials\n" " -min-vis Set the visualization attribute for inactive materials\n" " -min-density Minimal density to show the volume. \n" " -show Print setup to output device (stdout) \n" - "\tArguments given: " << arguments(argc,argv) << endl << flush; + "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush; ::exit(EINVAL); } } diff --git a/DDCore/src/plugins/VisProcessor.cpp b/DDCore/src/plugins/VisProcessor.cpp index 654e681ff..f16a6a360 100644 --- a/DDCore/src/plugins/VisProcessor.cpp +++ b/DDCore/src/plugins/VisProcessor.cpp @@ -13,9 +13,10 @@ #ifndef DD4HEP_DDCORE_VISMATERIALPROCESSOR_H #define DD4HEP_DDCORE_VISMATERIALPROCESSOR_H -// Framework include files -#include "DD4hep/VolumeProcessor.h" +/// Framework include files +#include +/// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -66,14 +67,16 @@ namespace dd4hep { // //========================================================================== -//#include "DD4hep/VisMaterialProcessor.h" -#include "DD4hep/Printout.h" -#include "DD4hep/DetectorTools.h" -#include "DD4hep/DetectorHelper.h" -#include "DD4hep/DetFactoryHelper.h" +/// Framework include files +//#include +#include +#include +#include +#include + +/// C/C++ include files #include -using namespace std; using namespace dd4hep; namespace { @@ -212,20 +215,20 @@ static void* create_object(Detector& description, int argc, char** argv) { continue; } else if ( ::strncmp(argv[i],"-fraction",3) == 0 ) { - stringstream str(argv[++i]); + std::stringstream str(argv[++i]); if ( str.good() ) { str >> proc->fraction; if ( !str.fail() ) continue; } } else if ( ::strncmp(argv[i],"-path",4) == 0 ) { - string path = argv[++i]; - DetElement de = detail::tools::findElement(description,path); + std::string path = argv[++i]; + DetElement de = detail::tools::findElement(description,path); if ( de.isValid() ) continue; printout(ERROR,"VisMaterialProcessor","++ Invalid DetElement path: %s",path.c_str()); } else if ( ::strncmp(argv[i],"-name",4) == 0 ) { - string name = argv[++i]; + std::string name = argv[++i]; proc->name = name; continue; } @@ -233,7 +236,7 @@ static void* create_object(Detector& description, int argc, char** argv) { proc->show = true; continue; } - cout << + std::cout << "Usage: DD4hep_VisMaterialProcessor -arg [-arg] \n" " -vis-active Set the visualization attribute for active materials\n" " -vis-inactive Set the visualization attribute for inactive materials\n" @@ -246,7 +249,7 @@ static void* create_object(Detector& description, int argc, char** argv) { " -fraction Set the fraction above which the active elment content\n" " defines an active volume. \n" " -show Print setup to output device (stdout) \n" - "\tArguments given: " << arguments(argc,argv) << endl << flush; + "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush; ::exit(EINVAL); } } From 49a4f6e4d0eed23d4e5f35d2b531c8e391b40a44 Mon Sep 17 00:00:00 2001 From: Markus Frank Date: Mon, 12 Feb 2024 09:14:50 +0100 Subject: [PATCH 12/14] Remove use of standard namespace from implementation --- DDAlign/src/AlignmentsCalib.cpp | 35 +- DDAlign/src/GlobalAlignmentCache.cpp | 82 +-- DDAlign/src/GlobalAlignmentOperators.cpp | 22 +- DDAlign/src/GlobalAlignmentStack.cpp | 53 +- DDAlign/src/GlobalAlignmentWriter.cpp | 47 +- DDAlign/src/GlobalDetectorAlignment.cpp | 82 +-- DDAlign/src/plugins/AlignmentsPlugins.cpp | 31 +- DDAlign/src/plugins/GlobalAlignmentParser.cpp | 85 +-- DDCAD/src/ASSIMPWriter.cpp | 120 +-- DDCAD/src/plugins/CADPlugins.cpp | 161 ++-- DDCond/src/ConditionsContent.cpp | 24 +- DDCond/src/ConditionsDependencyHandler.cpp | 48 +- DDCond/src/ConditionsIOVPool.cpp | 13 +- DDCond/src/ConditionsManager.cpp | 59 +- DDCond/src/ConditionsOperators.cpp | 14 +- DDCond/src/ConditionsPool.cpp | 18 +- DDCond/src/ConditionsRepository.cpp | 124 ++-- DDCond/src/ConditionsRootPersistency.cpp | 48 +- DDCond/src/ConditionsSlice.cpp | 72 +- DDCond/src/ConditionsTextRepository.cpp | 111 ++- DDCond/src/ConditionsTreePersistency.cpp | 83 ++- DDCond/src/Type1/Manager_Type1.cpp | 122 ++- DDCond/src/plugins/ConditionsLinearPool.cpp | 24 +- DDCond/src/plugins/ConditionsMappedPool.cpp | 19 +- DDCond/src/plugins/ConditionsMultiLoader.cpp | 29 +- DDCond/src/plugins/ConditionsParser.cpp | 48 +- DDCond/src/plugins/ConditionsPlugins.cpp | 88 +-- .../plugins/ConditionsRepositoryParser.cpp | 155 ++-- .../plugins/ConditionsRepositoryWriter.cpp | 181 +++-- .../plugins/ConditionsSnapshotRootLoader.cpp | 22 +- DDCond/src/plugins/ConditionsUserPool.cpp | 127 ++-- DDCond/src/plugins/ConditionsXmlLoader.cpp | 65 +- DDCore/include/XML/Layering.h | 2 +- DDCore/src/AlignmentData.cpp | 31 +- DDCore/src/AlignmentNominalMap.cpp | 10 +- DDCore/src/AlignmentTools.cpp | 16 +- DDCore/src/Alignments.cpp | 18 +- DDCore/src/AlignmentsCalculator.cpp | 28 +- DDCore/src/AlignmentsInterna.cpp | 21 +- DDCore/src/AlignmentsPrinter.cpp | 63 +- DDCore/src/AlignmentsProcessor.cpp | 47 +- DDCore/src/BuildType.cpp | 2 +- DDCore/src/Callback.cpp | 8 +- DDCore/src/CartesianGridXY.cpp | 13 +- DDCore/src/CartesianGridXYZ.cpp | 15 +- DDCore/src/CartesianGridXZ.cpp | 13 +- DDCore/src/CartesianGridYZ.cpp | 13 +- DDCore/src/CartesianStripX.cpp | 9 +- DDCore/src/CartesianStripY.cpp | 9 +- DDCore/src/CartesianStripZ.cpp | 9 +- DDCore/src/ComponentProperties.cpp | 57 +- DDCore/src/ConditionAny.cpp | 6 +- DDCore/src/ConditionDerived.cpp | 8 +- DDCore/src/Conditions.cpp | 53 +- DDCore/src/ConditionsData.cpp | 8 +- DDCore/src/ConditionsDebug.cpp | 11 +- DDCore/src/ConditionsInterna.cpp | 19 +- DDCore/src/ConditionsListener.cpp | 2 +- DDCore/src/ConditionsMap.cpp | 6 +- DDCore/src/ConditionsPrinter.cpp | 71 +- DDCore/src/ConditionsProcessor.cpp | 25 +- DDCore/src/DD4hepRootPersistency.cpp | 31 +- DDCore/src/DD4hepUI.cpp | 64 +- DDCore/src/DetectorData.cpp | 1 - DDCore/src/JSON/Detector.cpp | 4 +- DDCore/src/JSON/DocumentHandler.cpp | 13 +- DDCore/src/JSON/Elements.cpp | 83 ++- DDCore/src/JSON/Helpers.cpp | 4 +- DDCore/src/Path.cpp | 48 +- DDCore/src/XML/Detector.cpp | 2 +- DDCore/src/XML/DocumentHandler.cpp | 210 +++--- DDCore/src/XML/Layering.cpp | 109 ++- DDCore/src/XML/UriReader.cpp | 16 +- DDCore/src/XML/Utilities.cpp | 99 ++- DDCore/src/XML/VolumeBuilder.cpp | 141 ++-- DDCore/src/XML/XMLElements.cpp | 169 +++-- DDCore/src/plugins/Compact2Objects.cpp | 379 +++++----- .../src/segmentations/MultiSegmentation.cpp | 18 +- DDDigi/plugins/DigiRandomNoise.cpp | 3 +- DDDigi/src/DigiActionSequence.cpp | 7 +- DDDigi/src/DigiHandle.cpp | 16 +- DDDigi/src/DigiLockedAction.cpp | 5 +- DDDigi/src/DigiMonitorHandler.cpp | 33 +- DDDigi/src/DigiSegmentation.cpp | 2 - DDDigi/src/DigiSegmentationTool.cpp | 86 +-- DDDigi/src/DigiSynchronize.cpp | 7 +- DDDigi/src/noise/DigiSubdetectorSequence.cpp | 33 +- DDDigi/src/noise/FalphaNoise.cpp | 1 - DDDigi/test_task_queue.cpp | 9 +- DDEve/src/Annotation.cpp | 8 +- DDG4/plugins/Geant4CaloSmearShowerModel.cpp | 64 +- .../Geant4DetectorGeometryConstruction.cpp | 132 ++-- .../Geant4DetectorSensitivesConstruction.cpp | 52 +- DDG4/plugins/Geant4EscapeCounter.cpp | 35 +- DDG4/plugins/Geant4EventReaderGuineaPig.cpp | 37 +- DDG4/plugins/Geant4EventReaderHepEvt.cpp | 28 +- DDG4/plugins/Geant4EventReaderHepMC.cpp | 126 ++-- DDG4/plugins/Geant4FastPhysics.cpp | 1 - DDG4/plugins/Geant4FastSimShowerModel.cpp | 3 +- DDG4/plugins/Geant4FieldTrackingSetup.cpp | 31 +- DDG4/plugins/Geant4GDMLWriteAction.cpp | 8 +- DDG4/plugins/Geant4GFlashShowerModel.cpp | 1 - DDG4/plugins/Geant4GeometryScanner.cpp | 5 +- DDG4/plugins/Geant4HitDumpAction.cpp | 6 +- DDG4/plugins/Geant4HitExtractor.cpp | 1 - DDG4/plugins/Geant4HitTruthHandler.cpp | 18 +- DDG4/plugins/Geant4MaterialScanner.cpp | 37 +- DDG4/plugins/Geant4ParticleDumpAction.cpp | 18 +- DDG4/plugins/Geant4ROOTDump.cpp | 75 +- DDG4/plugins/Geant4SensDetFilters.cpp | 44 +- DDG4/plugins/Geant4TrackerWeightedSD.cpp | 20 +- .../Geant4UserActionInitialization.cpp | 13 +- DDG4/plugins/Geant4XMLSetup.cpp | 697 +++++++++--------- DDG4/reco/Geant4SurfaceTest.cpp | 33 +- DDG4/src/Geant4Action.cpp | 5 +- DDG4/src/Geant4Context.cpp | 3 +- DDG4/src/Geant4Data.cpp | 1 - DDG4/src/Geant4DataDump.cpp | 4 +- DDG4/src/Geant4DetectorConstruction.cpp | 34 +- DDG4/src/Geant4EventAction.cpp | 16 +- DDG4/src/Geant4Exec.cpp | 124 ++-- DDG4/src/Geant4FastSimShowerModel.cpp | 1 - DDG4/src/Geant4GDMLDetector.cpp | 5 +- DDG4/src/Geant4GeneratorAction.cpp | 26 +- DDG4/src/Geant4GeneratorWrapper.cpp | 31 +- DDG4/src/Geant4GeometryInfo.cpp | 21 +- DDG4/src/Geant4Handle.cpp | 76 +- DDG4/src/Geant4HierarchyDump.cpp | 78 +- DDG4/src/Geant4HitCollection.cpp | 13 +- DDG4/src/Geant4HitHandler.cpp | 15 +- DDG4/src/Geant4InputAction.cpp | 38 +- DDG4/src/Geant4InputHandling.cpp | 38 +- DDG4/src/Geant4IsotropeGenerator.cpp | 11 +- DDG4/src/Geant4Kernel.cpp | 43 +- DDG4/src/Geant4Mapping.cpp | 19 +- DDG4/src/Geant4Output2ROOT.cpp | 30 +- DDG4/src/Geant4OutputAction.cpp | 22 +- DDG4/src/Geant4Particle.cpp | 25 +- DDG4/src/Geant4ParticleGenerator.cpp | 24 +- DDG4/src/Geant4ParticleGun.cpp | 19 +- DDG4/src/Geant4ParticleHandler.cpp | 17 +- DDG4/src/Geant4ParticlePrint.cpp | 27 +- DDG4/src/Geant4PhysicsConstructor.cpp | 9 +- DDG4/src/Geant4PhysicsList.cpp | 72 +- DDG4/src/Geant4Primary.cpp | 11 +- DDG4/src/Geant4Random.cpp | 39 +- DDG4/src/Geant4RunAction.cpp | 24 +- DDG4/src/Geant4SensDetAction.cpp | 62 +- DDG4/src/Geant4StackingAction.cpp | 32 +- DDG4/src/Geant4StepHandler.cpp | 11 +- DDG4/src/Geant4SteppingAction.cpp | 24 +- DDG4/src/Geant4TestActions.cpp | 16 +- DDG4/src/Geant4TouchableHandler.cpp | 13 +- DDG4/src/Geant4TrackInformation.cpp | 4 +- DDG4/src/Geant4TrackingAction.cpp | 36 +- DDG4/src/Geant4TrackingPostAction.cpp | 11 +- DDG4/src/Geant4TrackingPreAction.cpp | 6 +- DDG4/src/Geant4UIManager.cpp | 17 +- DDG4/src/Geant4UIMessenger.cpp | 28 +- DDG4/src/Geant4UserInitialization.cpp | 14 +- DDG4/src/Geant4UserLimits.cpp | 44 +- DDG4/src/Geant4Vertex.cpp | 7 +- DDG4/src/Geant4VolumeManager.cpp | 127 ++-- DDG4/src/IoStreams.cpp | 10 +- DDG4/src/python/Geant4PythonAction.cpp | 16 +- DDG4/src/python/Geant4PythonCall.cpp | 4 - .../Geant4PythonDetectorConstruction.cpp | 17 +- .../Geant4PythonDetectorConstructionLast.cpp | 4 +- .../src/python/Geant4PythonInitialization.cpp | 13 +- DDG4/tpython/DDPython.cpp | 85 ++- 170 files changed, 3565 insertions(+), 3848 deletions(-) diff --git a/DDAlign/src/AlignmentsCalib.cpp b/DDAlign/src/AlignmentsCalib.cpp index aaa01c8e7..96ab2a08d 100644 --- a/DDAlign/src/AlignmentsCalib.cpp +++ b/DDAlign/src/AlignmentsCalib.cpp @@ -12,17 +12,14 @@ //========================================================================== // Framework includes -#include "DDAlign/AlignmentsCalib.h" +#include -#include "DD4hep/Memory.h" -#include "DD4hep/Printout.h" -#include "DD4hep/DetectorTools.h" -#include "DD4hep/detail/AlignmentsInterna.h" +#include +#include +#include +#include -using namespace std; -using namespace dd4hep; using namespace dd4hep::align; -typedef Condition::key_type key_type; /// Helper class to store information about alignment calibration items /** Implementation details: Alignment context entry @@ -34,12 +31,12 @@ typedef Condition::key_type key_type; */ class AlignmentsCalib::Entry { public: - Delta delta; - Delta original; - Condition source; - DetElement detector; - Condition::key_type target = 0; - int dirty = 0; + dd4hep::Delta delta; + dd4hep::Delta original; + dd4hep::Condition source; + dd4hep::DetElement detector; + dd4hep::Condition::key_type target = 0; + int dirty = 0; Entry() = default; Entry(const Entry& c) = delete; Entry& operator=(const Entry& c) = delete; @@ -57,13 +54,13 @@ AlignmentsCalib::~AlignmentsCalib() noexcept(false) { } /// Convenience only: Access detector element by path -DetElement AlignmentsCalib::detector(const string& path) const { +dd4hep::DetElement AlignmentsCalib::detector(const std::string& path) const { DetElement det(detail::tools::findElement(description,path)); return det; } /// Implementation: Add a new entry to the transaction stack. -pair +std::pair AlignmentsCalib::_set(DetElement detector, const Delta& delta) { ConditionKey tar_key(detector.key(),Keys::alignmentKey); UsedConditions::iterator i = used.find(tar_key.hash); @@ -103,14 +100,14 @@ AlignmentsCalib::_set(DetElement detector, const Delta& delta) { } /// (1) Add a new entry to an existing DetElement structure. -Condition::key_type +dd4hep::Condition::key_type AlignmentsCalib::set(DetElement det, const Delta& delta) { return _set(det.access(), delta).first; } /// (2) Add a new entry to an existing DetElement structure. -Condition::key_type -AlignmentsCalib::set(const string& path, const Delta& delta) { +dd4hep::Condition::key_type +AlignmentsCalib::set(const std::string& path, const Delta& delta) { return _set(detector(path).access(), delta).first; } diff --git a/DDAlign/src/GlobalAlignmentCache.cpp b/DDAlign/src/GlobalAlignmentCache.cpp index 28b4a4235..0c1fc436b 100644 --- a/DDAlign/src/GlobalAlignmentCache.cpp +++ b/DDAlign/src/GlobalAlignmentCache.cpp @@ -12,35 +12,33 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/Printout.h" -#include "DDAlign/GlobalAlignmentCache.h" -#include "DDAlign/GlobalAlignmentOperators.h" -#include "DD4hep/detail/DetectorInterna.h" +#include +#include +#include +#include +#include // ROOT include files -#include "TGeoManager.h" +#include -using namespace std; -using namespace dd4hep; using namespace dd4hep::align; -using namespace dd4hep::align::DDAlign_standard_operations; -typedef GlobalAlignmentStack::StackEntry Entry; +using Entry = GlobalAlignmentStack::StackEntry; -DetElement _detector(DetElement child) { +dd4hep::DetElement _detector(dd4hep::DetElement child) { if ( child.isValid() ) { - DetElement p(child.parent()); + dd4hep::DetElement p(child.parent()); if ( p.isValid() && !p.parent().isValid() ) return child; else if ( !p.isValid() ) // World detector element... return child; return _detector(p); } - throw runtime_error("dd4hep: DetElement cannot determine detector parent [Invalid handle]"); + dd4hep::except("GlobalAlignmentCache", "DetElement cannot determine detector parent [Invalid handle]"); + return {}; } /// Default constructor -GlobalAlignmentCache::GlobalAlignmentCache(Detector& description, const string& sdPath, bool top) +GlobalAlignmentCache::GlobalAlignmentCache(Detector& description, const std::string& sdPath, bool top) : m_detDesc(description), m_sdPath(sdPath), m_sdPathLen(sdPath.length()), m_refCount(1), m_top(top) { } @@ -48,7 +46,7 @@ GlobalAlignmentCache::GlobalAlignmentCache(Detector& description, const string& /// Default destructor GlobalAlignmentCache::~GlobalAlignmentCache() { int nentries = (int)m_cache.size(); - int nsect = (int)m_detectors.size(); + int nsect = (int)m_detectors.size(); detail::releaseObjects(m_detectors); m_cache.clear(); printout(INFO,"GlobalAlignmentCache", @@ -103,26 +101,26 @@ bool GlobalAlignmentCache::insert(GlobalAlignment alignment) { } /// Retrieve the cache section corresponding to the path of an entry. -GlobalAlignmentCache* GlobalAlignmentCache::section(const string& path_name) const { - size_t idx, idq; +GlobalAlignmentCache* GlobalAlignmentCache::section(const std::string& path_name) const { + std::size_t idx, idq; if ( path_name[0] != '/' ) { return section(m_detDesc.world().placementPath()+'/'+path_name); } - else if ( (idx=path_name.find('/',1)) == string::npos ) { + else if ( (idx=path_name.find('/',1)) == std::string::npos ) { return (m_sdPath == path_name.c_str()+1) ? (GlobalAlignmentCache*)this : 0; } else if ( m_detectors.empty() ) { return 0; } - if ( (idq=path_name.find('/',idx+1)) != string::npos ) --idq; - string path = path_name.substr(idx+1,idq-idx); + if ( (idq=path_name.find('/',idx+1)) != std::string::npos ) --idq; + std::string path = path_name.substr(idx+1,idq-idx); SubdetectorAlignments::const_iterator j = m_detectors.find(path); return (j==m_detectors.end()) ? 0 : (*j).second; } /// Retrieve an alignment entry by its placement path -GlobalAlignment GlobalAlignmentCache::get(const string& path_name) const { - size_t idx, idq; +GlobalAlignment GlobalAlignmentCache::get(const std::string& path_name) const { + std::size_t idx, idq; unsigned int index = detail::hash32(path_name.c_str()+m_sdPathLen); Cache::const_iterator i = m_cache.find(index); if ( i != m_cache.end() ) { @@ -134,23 +132,24 @@ GlobalAlignment GlobalAlignmentCache::get(const string& path_name) const { else if ( path_name[0] != '/' ) { return get(m_detDesc.world().placementPath()+'/'+path_name); } - else if ( (idx=path_name.find('/',1)) == string::npos ) { + else if ( (idx=path_name.find('/',1)) == std::string::npos ) { // Escape: World volume and not found in cache --> not present return GlobalAlignment(0); } - if ( (idq=path_name.find('/',idx+1)) != string::npos ) --idq; - string path = path_name.substr(idx+1,idq-idx); + if ( (idq=path_name.find('/',idx+1)) != std::string::npos ) --idq; + std::string path = path_name.substr(idx+1, idq-idx); SubdetectorAlignments::const_iterator j = m_detectors.find(path); if ( j != m_detectors.end() ) return (*j).second->get(path_name); return GlobalAlignment(0); } /// Return all entries matching a given path. -vector GlobalAlignmentCache::matches(const string& match, bool exclude_exact) const { - vector result; +std::vector +GlobalAlignmentCache::matches(const std::string& match, bool exclude_exact) const { + std::vector result; GlobalAlignmentCache* c = section(match); if ( c ) { - size_t len = match.length(); + std::size_t len = match.length(); result.reserve(c->m_cache.size()); for(Cache::const_iterator i=c->m_cache.begin(); i!=c->m_cache.end();++i) { const Cache::value_type& v = *i; @@ -173,7 +172,7 @@ void GlobalAlignmentCache::commit(GlobalAlignmentStack& stack) { } /// Retrieve branch cache by name. If not present it will be created -GlobalAlignmentCache* GlobalAlignmentCache::subdetectorAlignments(const string& nam) { +GlobalAlignmentCache* GlobalAlignmentCache::subdetectorAlignments(const std::string& nam) { SubdetectorAlignments::const_iterator i = m_detectors.find(nam); if ( i == m_detectors.end() ) { GlobalAlignmentCache* ptr = new GlobalAlignmentCache(m_detDesc,nam,false); @@ -185,8 +184,8 @@ GlobalAlignmentCache* GlobalAlignmentCache::subdetectorAlignments(const string& /// Apply a complete stack of ordered alignments to the geometry structure void GlobalAlignmentCache::apply(GlobalAlignmentStack& stack) { - typedef map DetElementUpdates; - typedef map > sd_entries_t; + typedef std::map DetElementUpdates; + typedef std::map > sd_entries_t; TGeoManager& mgr = m_detDesc.manager(); DetElementUpdates detelt_updates; sd_entries_t all; @@ -218,10 +217,10 @@ void GlobalAlignmentCache::apply(GlobalAlignmentStack& stack) { elt->update(DetElement::PLACEMENT_CHANGED|DetElement::PLACEMENT_ELEMENT,elt.ptr()); } // Provide update callback for the highest detector element - string last_path = "?????"; + std::string last_path = "?????"; for(DetElementUpdates::iterator i=detelt_updates.begin(); i!=detelt_updates.end(); ++i) { - const string& path = (*i).first; - if ( path.find(last_path) == string::npos ) { + const std::string& path = (*i).first; + if ( path.find(last_path) == std::string::npos ) { DetElement elt((*i).second); printout(DEBUG,"GlobalAlignmentCache","+++ Trigger placement update for %s [1]",elt.path().c_str()); elt->update(DetElement::PLACEMENT_CHANGED|DetElement::PLACEMENT_HIGHEST,elt.ptr()); @@ -237,15 +236,16 @@ void GlobalAlignmentCache::apply(GlobalAlignmentStack& stack) { } /// Apply a vector of SD entries of ordered alignments to the geometry structure -void GlobalAlignmentCache::apply(const vector& changes) { - typedef map > Nodes; - Nodes nodes; +void GlobalAlignmentCache::apply(const std::vector& changes) { + std::map > nodes; + namespace ops = dd4hep::align::DDAlign_standard_operations; GlobalAlignmentSelector selector(*this,nodes,changes); + for_each(m_cache.begin(),m_cache.end(),selector.reset()); - for_each(nodes.begin(),nodes.end(),GlobalAlignmentActor(*this,nodes)); - for_each(nodes.begin(),nodes.end(),GlobalAlignmentActor(*this,nodes)); + for_each(nodes.begin(),nodes.end(),GlobalAlignmentActor(*this,nodes)); + for_each(nodes.begin(),nodes.end(),GlobalAlignmentActor(*this,nodes)); for_each(changes.begin(),changes.end(),selector.reset()); - for_each(nodes.begin(),nodes.end(),GlobalAlignmentActor(*this,nodes)); - for_each(nodes.begin(),nodes.end(),GlobalAlignmentActor(*this,nodes)); + for_each(nodes.begin(),nodes.end(),GlobalAlignmentActor(*this,nodes)); + for_each(nodes.begin(),nodes.end(),GlobalAlignmentActor(*this,nodes)); } diff --git a/DDAlign/src/GlobalAlignmentOperators.cpp b/DDAlign/src/GlobalAlignmentOperators.cpp index 2488f3d75..9e8afef27 100644 --- a/DDAlign/src/GlobalAlignmentOperators.cpp +++ b/DDAlign/src/GlobalAlignmentOperators.cpp @@ -12,17 +12,15 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/Printout.h" -#include "DD4hep/detail/DetectorInterna.h" -#include "DDAlign/GlobalAlignmentOperators.h" -#include "DDAlign/GlobalDetectorAlignment.h" +#include +#include +#include +#include +#include // C/C++ include files #include -using namespace std; -using namespace dd4hep; using namespace dd4hep::align; void GlobalAlignmentOperator::insert(GlobalAlignment alignment) const { @@ -33,7 +31,7 @@ void GlobalAlignmentOperator::insert(GlobalAlignment alignment) const { void GlobalAlignmentSelector::operator()(Entries::value_type e) const { TGeoPhysicalNode* pn = 0; - nodes.emplace(e->path,make_pair(pn,e)); + nodes.emplace(e->path,std::make_pair(pn,e)); } void GlobalAlignmentSelector::operator()(const Cache::value_type& entry) const { @@ -44,11 +42,11 @@ void GlobalAlignmentSelector::operator()(const Cache::value_type& entry) const const char* p = pn->GetName(); bool reset_children = GlobalAlignmentStack::resetChildren(*e); if ( reset_children && ::strstr(p,e->path.c_str()) == p ) { - nodes.emplace(p,make_pair(pn,e)); + nodes.emplace(p,std::make_pair(pn,e)); break; } else if ( e->path == p ) { - nodes.emplace(p,make_pair(pn,e)); + nodes.emplace(p,std::make_pair(pn,e)); break; } } @@ -75,12 +73,12 @@ template <> void GlobalAlignmentActor: template <> void GlobalAlignmentActor::operator()(Nodes::value_type& n) const { TGeoPhysicalNode* p = n.second.first; - string np; + std::string np; if ( p->IsAligned() ) { for (Int_t i=0, nLvl=p->GetLevel(); i<=nLvl; i++) { TGeoNode* node = p->GetNode(i); TGeoMatrix* mat = node->GetMatrix(); // Node's relative matrix - np += string("/")+node->GetName(); + np += std::string("/")+node->GetName(); if ( !mat->IsIdentity() && i > 0 ) { // Ignore the 'world', is identity anyhow GlobalAlignment a = cache.get(np); if ( a.isValid() ) { diff --git a/DDAlign/src/GlobalAlignmentStack.cpp b/DDAlign/src/GlobalAlignmentStack.cpp index aa166d88d..846885e70 100644 --- a/DDAlign/src/GlobalAlignmentStack.cpp +++ b/DDAlign/src/GlobalAlignmentStack.cpp @@ -12,22 +12,20 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/Objects.h" -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" -#include "DDAlign/GlobalAlignmentStack.h" - -using namespace std; -using namespace dd4hep; +#include +#include +#include +#include +#include + using namespace dd4hep::align; -static dd4hep_ptr& _stack() { - static dd4hep_ptr s; +static dd4hep::dd4hep_ptr& _stack() { + static dd4hep::dd4hep_ptr s; return s; } -static dd4hep_ptr& _stack(GlobalAlignmentStack* obj) { - dd4hep_ptr& stk = _stack(); +static dd4hep::dd4hep_ptr& _stack(GlobalAlignmentStack* obj) { + dd4hep::dd4hep_ptr& stk = _stack(); stk.adopt(obj); return stk; } @@ -96,13 +94,13 @@ GlobalAlignmentStack::~GlobalAlignmentStack() { /// Static client accessor GlobalAlignmentStack& GlobalAlignmentStack::get() { if ( _stack().get() ) return *_stack(); - throw runtime_error("GlobalAlignmentStack> Stack not allocated -- may not be retrieved!"); + except("GlobalAlignmentStack", "Stack not allocated -- may not be retrieved!"); } /// Create an alignment stack instance. The creation of a second instance will be refused. void GlobalAlignmentStack::create() { if ( _stack().get() ) { - throw runtime_error("GlobalAlignmentStack> Stack already allocated. Multiple copies are not allowed!"); + except("GlobalAlignmentStack", "Stack already allocated. Multiple copies are not allowed!"); } _stack(new GlobalAlignmentStack()); } @@ -118,16 +116,17 @@ void GlobalAlignmentStack::release() { _stack(0); return; } - throw runtime_error("GlobalAlignmentStack> Attempt to delete non existing stack."); + except("GlobalAlignmentStack", "Attempt to delete non existing stack."); } /// Add a new entry to the cache. The key is the placement path -bool GlobalAlignmentStack::insert(const string& full_path, dd4hep_ptr& entry) { +bool GlobalAlignmentStack::insert(const std::string& full_path, dd4hep_ptr& entry) { if ( entry.get() && !full_path.empty() ) { entry->path = full_path; return add(entry); } - throw runtime_error("GlobalAlignmentStack> Attempt to apply an invalid alignment entry."); + except("GlobalAlignmentStack", "Attempt to apply an invalid alignment entry."); + return false; } /// Add a new entry to the cache. The key is the placement path @@ -143,33 +142,35 @@ bool GlobalAlignmentStack::add(dd4hep_ptr& entry) { StackEntry* e = entry.get(); // Need to make some checks BEFORE insertion if ( !e->detector.isValid() ) { - throw runtime_error("GlobalAlignmentStack> Invalid alignment entry [No such detector]"); + except("GlobalAlignmentStack", "Invalid alignment entry [No such detector]"); } printout(INFO,"GlobalAlignmentStack","Add node:%s",e->path.c_str()); m_stack.emplace(e->path,entry.release()); return true; } - throw runtime_error("GlobalAlignmentStack> The entry with path "+entry->path+ - " cannot be re-aligned twice in one transaction."); + except("GlobalAlignmentStack", "The entry with path "+entry->path+ + " cannot be re-aligned twice in one transaction."); } - throw runtime_error("GlobalAlignmentStack> Attempt to apply an invalid alignment entry."); + except("GlobalAlignmentStack", "Attempt to apply an invalid alignment entry."); + return false; } /// Retrieve an alignment entry of the current stack -dd4hep_ptr GlobalAlignmentStack::pop() { +dd4hep::dd4hep_ptr GlobalAlignmentStack::pop() { Stack::iterator i = m_stack.begin(); if ( i != m_stack.end() ) { dd4hep_ptr e((*i).second); m_stack.erase(i); return e; } - throw runtime_error("GlobalAlignmentStack> Alignment stack is empty. " - "Cannot pop entries - check size first!"); + except("GlobalAlignmentStack", "Alignment stack is empty. " + "Cannot pop entries - check size first!"); + return {}; } /// Get all pathes to be aligned -vector GlobalAlignmentStack::entries() const { - vector result; +std::vector GlobalAlignmentStack::entries() const { + std::vector result; result.reserve(m_stack.size()); transform(begin(m_stack),end(m_stack),back_inserter(result),detail::select2nd(m_stack)); return result; diff --git a/DDAlign/src/GlobalAlignmentWriter.cpp b/DDAlign/src/GlobalAlignmentWriter.cpp index 5c6b63133..33957606a 100644 --- a/DDAlign/src/GlobalAlignmentWriter.cpp +++ b/DDAlign/src/GlobalAlignmentWriter.cpp @@ -12,25 +12,24 @@ //========================================================================== // Framework includes -#include "DDAlign/GlobalAlignmentWriter.h" -#include "DDAlign/GlobalAlignmentCache.h" -#include "DDAlign/GlobalDetectorAlignment.h" -#include "DDAlign/AlignmentTags.h" +#include +#include +#include +#include -#include "DD4hep/Detector.h" -#include "DD4hep/Printout.h" -#include "DD4hep/MatrixHelpers.h" -#include "DD4hep/detail/DetectorInterna.h" -#include "XML/DocumentHandler.h" +#include +#include +#include +#include +#include -#include "TGeoMatrix.h" +#include // C/C++ include files #include using namespace dd4hep::align; -using namespace dd4hep; -using namespace std; +namespace xml = dd4hep::xml; /// Initializing Constructor GlobalAlignmentWriter::GlobalAlignmentWriter(Detector& description) : m_detDesc(description) @@ -47,19 +46,19 @@ GlobalAlignmentWriter::~GlobalAlignmentWriter() { /// Create the element corresponding to one single detector element without children xml::Element GlobalAlignmentWriter::createElement(xml::Document doc, DetElement element) const { xml::Element e(0), placement(0), elt = xml::Element(doc,_ALU(detelement)); - string path = element.placementPath(); + std::string path = element.placementPath(); GlobalAlignment a = element->global_alignment; GlobalDetectorAlignment det(element); - const vector& va = det.volumeAlignments(); elt.setAttr(_ALU(path),element.path()); if ( a.isValid() ) { addNode(elt,a); } - for(vector::const_iterator i=va.begin(); i!=va.end();++i) { + const std::vector& vol_alignments = det.volumeAlignments(); + for(const auto& alignment : vol_alignments ) { e = xml::Element(doc,_U(volume)); - e.setAttr(_ALU(path),(*i)->GetName()); - addNode(e,*i); + e.setAttr(_ALU(path), alignment->GetName()); + addNode(e, alignment); elt.append(e); } return elt; @@ -77,9 +76,9 @@ void GlobalAlignmentWriter::addNode(xml::Element elt, GlobalAlignment a) const printout(INFO,"GlobalAlignmentWriter","Write Delta constants for %s",a->GetName()); //mat.Print(); - if ( fabs(t[0]) > numeric_limits::epsilon() || - fabs(t[1]) > numeric_limits::epsilon() || - fabs(t[2]) > numeric_limits::epsilon() ) { + if ( fabs(t[0]) > std::numeric_limits::epsilon() || + fabs(t[1]) > std::numeric_limits::epsilon() || + fabs(t[2]) > std::numeric_limits::epsilon() ) { xml::Element e = xml::Element(elt.document(),_U(position)); e.setAttr(_U(x),_toString(t[0]/dd4hep::mm,"%f*mm")); e.setAttr(_U(y),_toString(t[1]/dd4hep::mm,"%f*mm")); @@ -88,9 +87,9 @@ void GlobalAlignmentWriter::addNode(xml::Element elt, GlobalAlignment a) const } if ( mat.IsRotation() ) { XYZAngles rot = detail::matrix::_xyzAngles(&mat); - if ( fabs(rot.X()) > numeric_limits::epsilon() || - fabs(rot.Y()) > numeric_limits::epsilon() || - fabs(rot.Z()) > numeric_limits::epsilon() ) { + if ( fabs(rot.X()) > std::numeric_limits::epsilon() || + fabs(rot.Y()) > std::numeric_limits::epsilon() || + fabs(rot.Z()) > std::numeric_limits::epsilon() ) { xml::Element e = xml::Element(elt.document(),_U(rotation)); // Don't know why the angles have the wrong sign.... @@ -133,7 +132,7 @@ xml::Document GlobalAlignmentWriter::dump(DetElement top, bool enable_transactio } /// Write the XML document structure to a file. -long GlobalAlignmentWriter::write(xml::Document doc, const string& output) const { +long GlobalAlignmentWriter::write(xml::Document doc, const std::string& output) const { xml::DocumentHandler docH; return docH.output(doc, output); } diff --git a/DDAlign/src/GlobalDetectorAlignment.cpp b/DDAlign/src/GlobalDetectorAlignment.cpp index 57fcecc4d..127a62372 100644 --- a/DDAlign/src/GlobalDetectorAlignment.cpp +++ b/DDAlign/src/GlobalDetectorAlignment.cpp @@ -12,17 +12,17 @@ //========================================================================== // Framework include files -#include "DDAlign/GlobalDetectorAlignment.h" -#include "DD4hep/DetectorTools.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/MatrixHelpers.h" -#include "DD4hep/Printout.h" -#include "DD4hep/detail/Handle.inl" -#include "DD4hep/detail/DetectorInterna.h" +#include +#include +#include +#include +#include +#include +#include // ROOT include files -#include "TGeoMatrix.h" -#include "TGeoManager.h" +#include +#include #ifdef __GNUC__ // Disable some diagnostics. @@ -56,15 +56,11 @@ namespace dd4hep { } /* End namespace Aligments */ } /* End namespace dd4hep */ -using namespace std; -using namespace dd4hep; using namespace dd4hep::align; - -typedef vector > LevelElements; +typedef std::vector > LevelElements; DD4HEP_INSTANTIATE_HANDLE_NAMED(GlobalAlignmentData); - namespace { static bool s_GlobalDetectorAlignment_debug = false; @@ -75,22 +71,22 @@ namespace { TGeoMatrix* mm = n->GetNode()->GetMatrix(); bool dbg = GlobalDetectorAlignment::debug(); if ( dbg ) { - printout(INFO,"Alignment","DELTA matrix of %s",n->GetName()); + printout(dd4hep::INFO,"Alignment","DELTA matrix of %s",n->GetName()); transform->Print(); - printout(INFO,"Alignment","OLD matrix of %s",n->GetName()); + dd4hep::printout(dd4hep::INFO,"Alignment","OLD matrix of %s",n->GetName()); mm->Print(); } transform->MultiplyLeft(mm); // orig * delta n->Align(transform, 0, check, overlap); if ( dbg ) { - printout(INFO,"Alignment","NEW matrix of %s",n->GetName()); + dd4hep::printout(dd4hep::INFO,"Alignment","NEW matrix of %s",n->GetName()); n->GetNode()->GetMatrix()->Print(); } /* - printout(INFO,"Alignment","Apply new relative matrix mother to daughter:"); + printout(dd4hep::INFO,"Alignment","Apply new relative matrix mother to daughter:"); transform->Print(); transform->MultiplyLeft(mm); // orig * delta - printout(INFO,"Alignment","With deltas %s ....",n->GetName()); + printout(dd4hep::INFO,"Alignment","With deltas %s ....",n->GetName()); transform->Print(); n->Align(transform, 0, check, overlap); @@ -100,31 +96,33 @@ namespace { */ return GlobalAlignment(n); } - throw runtime_error("dd4hep: Cannot align non existing physical node. [Invalid Handle]"); + dd4hep::except("GlobalDetectorAlignment", "Cannot align non existing physical node. [Invalid Handle]"); + return { }; } GlobalAlignment _alignment(const GlobalDetectorAlignment& det) { - DetElement::Object& e = det._data(); + dd4hep::DetElement::Object& e = det._data(); if ( !e.global_alignment.isValid() ) { - string path = detail::tools::placementPath(det); - e.global_alignment = Ref_t(new GlobalAlignmentData(path)); + std::string path = dd4hep::detail::tools::placementPath(det); + e.global_alignment = dd4hep::Ref_t(new GlobalAlignmentData(path)); } - Handle h(e.global_alignment); + dd4hep::Handle h(e.global_alignment); if ( h.isValid() && h->global.isValid() ) { return h->global; } - throw runtime_error("dd4hep: Cannot access global alignment data. [Invalid Handle]"); + dd4hep::except("GlobalDetectorAlignment", "Cannot access global alignment data. [Invalid Handle]"); + return { }; } void _dumpParentElements(GlobalDetectorAlignment& det, LevelElements& elements) { int level = 0; - detail::tools::PlacementPath nodes; - detail::tools::ElementPath det_nodes; - detail::tools::placementPath(det,nodes); - detail::tools::elementPath(det,det_nodes); - /// cout << "Placement path:"; - detail::tools::PlacementPath::const_reverse_iterator j=nodes.rbegin(); - detail::tools::ElementPath::const_reverse_iterator k=det_nodes.rbegin(); + dd4hep::detail::tools::PlacementPath nodes; + dd4hep::detail::tools::ElementPath det_nodes; + dd4hep::detail::tools::placementPath(det,nodes); + dd4hep::detail::tools::elementPath(det,det_nodes); + /// std::cout << "Placement path:"; + dd4hep::detail::tools::PlacementPath::const_reverse_iterator j=nodes.rbegin(); + dd4hep::detail::tools::ElementPath::const_reverse_iterator k=det_nodes.rbegin(); for(; j!=nodes.rend(); ++j, ++level) { //cout << "(" << level << ") " << (void*)((*j).ptr()) // << " " << string((*j)->GetName()) << " "; @@ -136,9 +134,9 @@ namespace { else { //elements.emplace_back(level,DetElement()); } - //cout << " "; + //std::cout << " "; } - //cout << endl; + //std::cout << std::endl; } } @@ -161,7 +159,7 @@ bool GlobalDetectorAlignment::debug(bool value) { } /// Collect all placements from the detector element up to the world volume -void GlobalDetectorAlignment::collectNodes(vector& nodes) { +void GlobalDetectorAlignment::collectNodes(std::vector& nodes) { detail::tools::placementPath(*this,nodes); } @@ -171,13 +169,13 @@ GlobalAlignment GlobalDetectorAlignment::alignment() const { } /// Alignment entries for lower level volumes, which are NOT attached to daughter DetElements -vector& GlobalDetectorAlignment::volumeAlignments() { +std::vector& GlobalDetectorAlignment::volumeAlignments() { Handle h(_data().global_alignment); return h->volume_alignments; } /// Alignment entries for lower level volumes, which are NOT attached to daughter DetElements -const vector& GlobalDetectorAlignment::volumeAlignments() const { +const std::vector& GlobalDetectorAlignment::volumeAlignments() const { Handle h(_data().global_alignment); return h->volume_alignments; } @@ -208,28 +206,28 @@ GlobalAlignment GlobalDetectorAlignment::align(TGeoHMatrix* matrix, bool chk, do } /// Align the PhysicalNode of the placement of the detector element (translation only) -GlobalAlignment GlobalDetectorAlignment::align(const string& elt_path, const Position& pos, bool chk, double overlap) { +GlobalAlignment GlobalDetectorAlignment::align(const std::string& elt_path, const Position& pos, bool chk, double overlap) { return align(elt_path,detail::matrix::_transform(pos),chk,overlap); } /// Align the PhysicalNode of the placement of the detector element (rotation only) -GlobalAlignment GlobalDetectorAlignment::align(const string& elt_path, const RotationZYX& rot, bool chk, double overlap) { +GlobalAlignment GlobalDetectorAlignment::align(const std::string& elt_path, const RotationZYX& rot, bool chk, double overlap) { return align(elt_path,detail::matrix::_transform(rot),chk,overlap); } /// Align the PhysicalNode of the placement of the detector element (translation + rotation) GlobalAlignment -GlobalDetectorAlignment::align(const string& elt_path, const Position& pos, const RotationZYX& rot, bool chk, double overlap) { +GlobalDetectorAlignment::align(const std::string& elt_path, const Position& pos, const RotationZYX& rot, bool chk, double overlap) { return align(elt_path,detail::matrix::_transform(pos,rot),chk,overlap); } /// Align the physical node according to a generic Transform3D -GlobalAlignment GlobalDetectorAlignment::align(const string& elt_path, const Transform3D& transform, bool chk, double overlap) { +GlobalAlignment GlobalDetectorAlignment::align(const std::string& elt_path, const Transform3D& transform, bool chk, double overlap) { return align(elt_path,detail::matrix::_transform(transform),chk,overlap); } /// Align the physical node according to a generic TGeo matrix -GlobalAlignment GlobalDetectorAlignment::align(const string& elt_path, TGeoHMatrix* matrix, bool chk, double overlap) { +GlobalAlignment GlobalDetectorAlignment::align(const std::string& elt_path, TGeoHMatrix* matrix, bool chk, double overlap) { if ( elt_path.empty() ) return _align(_alignment(*this),matrix,chk,overlap); else if ( elt_path == placementPath() ) diff --git a/DDAlign/src/plugins/AlignmentsPlugins.cpp b/DDAlign/src/plugins/AlignmentsPlugins.cpp index 72cb3d011..8d0d62181 100644 --- a/DDAlign/src/plugins/AlignmentsPlugins.cpp +++ b/DDAlign/src/plugins/AlignmentsPlugins.cpp @@ -12,19 +12,17 @@ //========================================================================== // Framework includes -#include "DD4hep/Printout.h" -#include "DD4hep/DetectorTools.h" -#include "DD4hep/DetFactoryHelper.h" +#include +#include +#include -using namespace std; -using namespace dd4hep; using namespace dd4hep::align; // ====================================================================================== -#include "DDAlign/GlobalAlignmentWriter.h" -long create_global_alignment_xml_file(Detector& description, int argc, char** argv) { - DetElement top; - string output, path = "/world"; +#include +long create_global_alignment_xml_file(dd4hep::Detector& description, int argc, char** argv) { + dd4hep::DetElement top; + std::string output, path = "/world"; bool enable_transactions = false, arg_error = false; for(int i=1; i -arg [-arg] \n" " name: factory nameDD4hep_GlobalAlignmentWriter \n\n" " -output Path to the output file generated. \n" " -path Path to the detector element for which \n" " the alignment file should be written. \n" " -transactions Enable output transactions. \n" - "\tArguments given: " << arguments(argc,argv) << endl << flush; + "\tArguments given: " << dd4hep::arguments(argc,argv) << std::endl << std::flush; ::exit(EINVAL); } - printout(ALWAYS,"AlignmentXmlWriter", - "++ Writing dd4hep alignment constants of the \"%s\" DetElement tree to file \"%s\"", - path.c_str(), output.c_str()); - top = detail::tools::findDaughterElement(description.world(),path); + dd4hep::printout(dd4hep::ALWAYS,"AlignmentXmlWriter", + "++ Writing dd4hep alignment constants of the \"%s\" " + "DetElement tree to file \"%s\"", + path.c_str(), output.c_str()); + top = dd4hep::detail::tools::findDaughterElement(description.world(),path); if ( top.isValid() ) { GlobalAlignmentWriter wr(description); return wr.write(wr.dump(top,enable_transactions), output); } - except("AlignmentXmlWriter","++ Invalid top level detector element name: %s",path.c_str()); + dd4hep::except("AlignmentXmlWriter","++ Invalid top level detector element name: %s",path.c_str()); return 1; } DECLARE_APPLY(DD4hep_GlobalAlignmentXmlWriter, create_global_alignment_xml_file) diff --git a/DDAlign/src/plugins/GlobalAlignmentParser.cpp b/DDAlign/src/plugins/GlobalAlignmentParser.cpp index 7422399a6..9f92d9348 100644 --- a/DDAlign/src/plugins/GlobalAlignmentParser.cpp +++ b/DDAlign/src/plugins/GlobalAlignmentParser.cpp @@ -12,20 +12,20 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/Path.h" -#include "DD4hep/Mutex.h" -#include "DD4hep/Printout.h" -#include "XML/Conversions.h" -#include "XML/XMLParsers.h" -#include "XML/DocumentHandler.h" -#include "DD4hep/DetectorTools.h" -#include "DD4hep/DetFactoryHelper.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "DDAlign/AlignmentTags.h" -#include "DDAlign/GlobalAlignmentStack.h" -#include "DDAlign/GlobalAlignmentCache.h" -#include "DDAlign/GlobalDetectorAlignment.h" +#include +#include +#include +#include // C/C++ include files #include @@ -52,13 +52,13 @@ namespace dd4hep { template <> void Converter::operator()(xml_h seq) const; template <> void Converter::operator()(xml_h seq) const; template <> void Converter::operator()(xml_h seq) const; + + static long setup_Alignment(Detector& description, const xml_h& e); } -using namespace std; -using namespace dd4hep; using namespace dd4hep::align; +using StackEntry = GlobalAlignmentStack::StackEntry; -static long setup_Alignment(Detector& description, const xml_h& e); /** Convert to enable/disable debugging. * @@ -66,13 +66,11 @@ static long setup_Alignment(Detector& description, const xml_h& e); * @version 1.0 * @date 01/04/2014 */ -template <> void Converter::operator()(xml_h e) const { +template <> void dd4hep::Converter::operator()(xml_h e) const { bool value = e.attr(_U(value)); GlobalDetectorAlignment::debug(value); } -typedef GlobalAlignmentStack::StackEntry StackEntry; - /** Convert volume objects * * @@ -88,19 +86,19 @@ typedef GlobalAlignmentStack::StackEntry StackEntry; * @version 1.0 * @date 01/04/2014 */ -template <> void Converter::operator()(xml_h e) const { +template <> void dd4hep::Converter::operator()(xml_h e) const { Delta val; GlobalAlignmentStack* stack = _option(); - pair* elt = _param >(); - string subpath = e.attr(_ALU(path)); + std::pair* elt = _param >(); + std::string subpath = e.attr(_ALU(path)); bool reset = e.hasAttr(_ALU(reset)) ? e.attr(_ALU(reset)) : true; bool reset_dau = e.hasAttr(_ALU(reset_children)) ? e.attr(_ALU(reset_children)) : true; bool check = e.hasAttr(_ALU(check_overlaps)); bool check_val = check ? e.attr(_ALU(check_overlaps)) : false; bool overlap = e.hasAttr(_ALU(overlap)); double ovl = overlap ? e.attr(_ALU(overlap)) : 0.001; - string elt_place = elt->first.placementPath(); - string placement = subpath[0]=='/' ? subpath : elt_place + "/" + subpath; + std::string elt_place = elt->first.placementPath(); + std::string placement = subpath[0]=='/' ? subpath : elt_place + "/" + subpath; printout(INFO,"Alignment"," path:%s placement:%s reset:%s children:%s", subpath.c_str(), placement.c_str(), yes_no(reset), yes_no(reset_dau)); @@ -115,7 +113,7 @@ template <> void Converter::operator()(xml_h e) const { dd4hep_ptr entry(new StackEntry(elt->first,placement,val,ovl)); stack->insert(entry); - pair vol_param(elt->first,subpath); + std::pair vol_param(elt->first,subpath); xml_coll_t(e,_U(volume)).for_each(Converter(description,&vol_param)); } @@ -135,10 +133,10 @@ template <> void Converter::operator()(xml_h e) const { * @version 1.0 * @date 01/04/2014 */ -template <> void Converter::operator()(xml_h e) const { +template <> void dd4hep::Converter::operator()(xml_h e) const { DetElement det(_param()); GlobalAlignmentStack* stack = _option(); - string path = e.attr(_ALU(path)); + std::string path = e.attr(_ALU(path)); bool check = e.hasAttr(_ALU(check_overlaps)); bool check_val = check ? e.attr(_ALU(check_overlaps)) : false; bool reset = e.hasAttr(_ALU(reset)) ? e.attr(_ALU(reset)) : false; @@ -146,11 +144,11 @@ template <> void Converter::operator()(xml_h e) const { bool overlap = e.hasAttr(_ALU(overlap)); double ovl = overlap ? e.attr(_ALU(overlap)) : 0.001; DetElement elt = detail::tools::findDaughterElement(det,path); - string placement = elt.isValid() ? elt.placementPath() : string("-----"); + std::string placement = elt.isValid() ? elt.placementPath() : std::string("-----"); if ( !elt.isValid() ) { - string err = "dd4hep: DetElement "+det.path()+" has no child:"+path+" [No such child]"; - throw runtime_error(err); + except("GlocalAlignmentParser", + "dd4hep: DetElement %s has no child: %s [No such child]", det.path().c_str(), path.c_str()); } Delta delta; @@ -165,7 +163,8 @@ template <> void Converter::operator()(xml_h e) const { if ( reset_dau ) delta.flags |= GlobalAlignmentStack::RESET_CHILDREN; if ( check_val ) delta.flags |= GlobalAlignmentStack::CHECKOVL_VALUE; - printout(INFO,"Alignment","path:%s [%s] placement:%s matrix:%s reset:%s children:%s", + printout(INFO, + "Alignment","path:%s [%s] placement:%s matrix:%s reset:%s children:%s", path.c_str(), elt.isValid() ? elt.path().c_str() : "-----", placement.c_str(), @@ -175,7 +174,7 @@ template <> void Converter::operator()(xml_h e) const { dd4hep_ptr entry(new StackEntry(elt,placement,delta,ovl)); stack->insert(entry); - pair vol_param(elt,""); + std::pair vol_param(elt,""); xml_coll_t(e,_U(volume)).for_each(Converter(description,&vol_param,optional)); xml_coll_t(e,_ALU(detelement)).for_each(Converter(description,elt.ptr(),optional)); xml_coll_t(e,_U(include)).for_each(Converter(description,elt.ptr(),optional)); @@ -192,10 +191,10 @@ template <> void Converter::operator()(xml_h e) const { * @version 1.0 * @date 01/04/2014 */ -template <> void Converter::operator()(xml_h element) const { +template <> void dd4hep::Converter::operator()(xml_h element) const { xml::DocumentHolder doc(xml::DocumentHandler().load(element, element.attr_value(_U(ref)))); xml_h node = doc.root(); - string tag = node.tag(); + std::string tag = node.tag(); if ( tag == "alignment" ) Converter(description,param,optional)(node); else if ( tag == "global_alignment" ) @@ -205,7 +204,7 @@ template <> void Converter::operator()(xml_h element) const { else if ( tag == "subdetectors" || tag == "detelements" ) xml_coll_t(node,_ALU(detelements)).for_each(Converter(description,param,optional)); else - throw runtime_error("Undefined tag name in XML structure:"+tag+" XML parsing abandoned."); + except("GlocalAlignmentParser", "Undefined tag name in XML structure: %s XML parsing abandoned.", tag.c_str()); } /** Convert alignment objects @@ -220,7 +219,7 @@ template <> void Converter::operator()(xml_h element) const { * @version 1.0 * @date 01/04/2014 */ -template <> void Converter::operator()(xml_h e) const { +template <> void dd4hep::Converter::operator()(xml_h e) const { /// Now we process all allowed elements within the alignment tag: /// , , and xml_coll_t(e,_ALU(debug)).for_each(Converter(description,param,optional)); @@ -236,9 +235,9 @@ template <> void Converter::operator()(xml_h e) const { * @version 1.0 * @date 01/04/2014 */ -static long setup_Alignment(Detector& description, const xml_h& e) { - static dd4hep_mutex_t s_mutex; - dd4hep_lock_t lock(s_mutex); +long dd4hep::setup_Alignment(dd4hep::Detector& description, const xml_h& e) { + static dd4hep::dd4hep_mutex_t s_mutex; + dd4hep::dd4hep_lock_t lock(s_mutex); bool open_trans = e.hasChild(_ALU(open_transaction)); bool close_trans = e.hasChild(_ALU(close_transaction)); @@ -251,8 +250,10 @@ static long setup_Alignment(Detector& description, const xml_h& e) { GlobalAlignmentStack::create(); } if ( !GlobalAlignmentStack::exists() ) { - printout(ERROR,"GlobalAlignment","Request process global alignments without cache."); - printout(ERROR,"GlobalAlignment","Call plugin DD4hep_GlobalAlignmentInstall first OR add XML tag "); + printout(ERROR,"GlobalAlignment", + "Request process global alignments without cache."); + printout(ERROR,"GlobalAlignment", + "Call plugin DD4hep_GlobalAlignmentInstall first OR add XML tag "); except("GlobalAlignment","Request process global alignments without cache."); } GlobalAlignmentStack& stack = GlobalAlignmentStack::get(); @@ -277,7 +278,7 @@ DECLARE_XML_DOC_READER(global_alignment,setup_Alignment) * @version 1.0 * @date 01/04/2014 */ -static long install_Alignment(Detector& description, int, char**) { +static long install_Alignment(dd4hep::Detector& description, int, char**) { GlobalAlignmentCache::install(description); return 1; } diff --git a/DDCAD/src/ASSIMPWriter.cpp b/DDCAD/src/ASSIMPWriter.cpp index f468c63e0..b3440f3a2 100644 --- a/DDCAD/src/ASSIMPWriter.cpp +++ b/DDCAD/src/ASSIMPWriter.cpp @@ -33,27 +33,25 @@ /// C/C++ include files #include -using namespace std; -using namespace dd4hep; using namespace dd4hep::cad; using Vertex = Tessellated::Vertex_t; namespace { - void _collect(std::vector >& cont, - bool recursive, const TGeoHMatrix& to_global, PlacedVolume pv) + void _collect(std::vector >& cont, + bool recursive, const TGeoHMatrix& to_global, dd4hep::PlacedVolume pv) { - Volume v = pv.volume(); + dd4hep::Volume v = pv.volume(); for(Int_t i=0; iGetNdaughters(); ++i) { - PlacedVolume p = v->GetNode(i); - Solid sol = p.volume().solid(); - bool use = sol->IsA() != TGeoShapeAssembly::Class(); - unique_ptr mother(new TGeoHMatrix(to_global)); + dd4hep::PlacedVolume p = v->GetNode(i); + dd4hep::Solid sol = p.volume().solid(); + bool use = sol->IsA() != TGeoShapeAssembly::Class(); + std::unique_ptr mother(new TGeoHMatrix(to_global)); mother->Multiply(p->GetMatrix()); if ( use ) - cont.push_back(make_pair(p, mother.get())); + cont.push_back(std::make_pair(p, mother.get())); if ( recursive ) _collect(cont, recursive, *mother, p); if ( use ) @@ -63,8 +61,8 @@ namespace { bool equals(Vertex const &lhs, Vertex const &rhs) { constexpr double kTolerance = 1.e-32; return TMath::Abs(lhs[0] - rhs[0]) < kTolerance && - TMath::Abs(lhs[1] - rhs[1]) < kTolerance && - TMath::Abs(lhs[2] - rhs[2]) < kTolerance; + TMath::Abs(lhs[1] - rhs[1]) < kTolerance && + TMath::Abs(lhs[2] - rhs[2]) < kTolerance; } struct TessellateShape { @@ -73,42 +71,46 @@ namespace { virtual ~TessellateShape() = default; RootCsg::TBaseMesh* make_mesh(TGeoShape* sh) const; RootCsg::TBaseMesh* collect_composite(TGeoCompositeShape* sh) const; - unique_ptr build_mesh(int id, const std::string& name, TGeoShape* shape); - unique_ptr tessellate_primitive(const std::string& name, Solid solid); - unique_ptr close_tessellated(int id, TGeoShape* shape, int nskip, unique_ptr&& tes); + std::unique_ptr build_mesh(int id, const std::string& name, TGeoShape* shape); + std::unique_ptr tessellate_primitive(const std::string& name, dd4hep::Solid solid); + std::unique_ptr close_tessellated(int id, TGeoShape* shape, int nskip, std::unique_ptr&& tes); }; - unique_ptr TessellateShape::close_tessellated(int id, TGeoShape* shape, int nskip, unique_ptr&& tes) { - string nam = shape->GetName(), typ = "["+string(shape->IsA()->GetName())+"]"; + std::unique_ptr + TessellateShape::close_tessellated(int id, TGeoShape* shape, int nskip, std::unique_ptr&& tes) { + std::string nam = shape->GetName(), typ = "["+std::string(shape->IsA()->GetName())+"]"; nam = nam.substr(0, nam.find("_0x")); tes->CloseShape(true, true, true); if ( nskip > 0 ) { - printout(ALWAYS,"ASSIMPWriter","+++ %3d %-48s %-24s Skipped %3ld/%-4d degenerate facets %4d vertices closed:%s defined:%s", - id, nam.c_str(), typ.c_str(), nskip, tes->GetNfacets(), tes->GetNvertices(), - yes_no(tes->IsClosedBody()), yes_no(tes->IsDefined())); + dd4hep::printout(dd4hep::ALWAYS, + "ASSIMPWriter","+++ %3d %-48s %-24s Skipped %3ld/%-4d degenerate facets %4d vertices closed:%s defined:%s", + id, nam.c_str(), typ.c_str(), nskip, tes->GetNfacets(), tes->GetNvertices(), + dd4hep::yes_no(tes->IsClosedBody()), dd4hep::yes_no(tes->IsDefined())); } else { - printout(ALWAYS,"ASSIMPWriter","+++ %3d %-48s %-24s Tessellated %4d facets %4d vertices closed:%s defined:%s", - id, nam.c_str(), typ.c_str(), - tes->GetNfacets(), tes->GetNvertices(), - yes_no(tes->IsClosedBody()), - yes_no(tes->IsDefined())); + dd4hep::printout(dd4hep::ALWAYS, + "ASSIMPWriter","+++ %3d %-48s %-24s Tessellated %4d facets %4d vertices closed:%s defined:%s", + id, nam.c_str(), typ.c_str(), + tes->GetNfacets(), tes->GetNvertices(), + dd4hep::yes_no(tes->IsClosedBody()), + dd4hep::yes_no(tes->IsDefined())); } - cout << flush; + std::cout << std::flush; return move(tes); } - unique_ptr TessellateShape::build_mesh(int id, const std::string& name, TGeoShape* shape) { - auto mesh = unique_ptr(this->make_mesh(shape)); - size_t nskip = 0; - vector vertices; + std::unique_ptr TessellateShape::build_mesh(int id, const std::string& name, TGeoShape* shape) { + auto mesh = std::unique_ptr(this->make_mesh(shape)); + std::vector vertices; + std::size_t nskip = 0; + vertices.reserve(mesh->NumberOfVertices()); - map vtx_index_replacements; + std::map vtx_index_replacements; for( size_t ipoint = 0, npoints = mesh->NumberOfVertices(); ipoint < npoints; ++ipoint ) { long found = -1; const double* v = mesh->GetVertex(ipoint); Vertex vtx(v[0], v[1], v[2]); - for(size_t i=0; i < vertices.size(); ++i) { + for(std::size_t i=0; i < vertices.size(); ++i) { if ( equals(vertices[i],vtx) ) { vtx_index_replacements[ipoint] = found = i; break; @@ -119,12 +121,12 @@ namespace { vertices.emplace_back(v[0], v[1], v[2]); } } - size_t vtx_len = vertices.size(); - unique_ptr tes = make_unique(name.c_str(), vertices); - for( size_t ipoly = 0, npols = mesh->NumberOfPolys(); ipoly < npols; ++ipoly) { - size_t npoints = mesh->SizeOfPoly(ipoly); + std::size_t vtx_len = vertices.size(); + std::unique_ptr tes = std::make_unique(name.c_str(), vertices); + for( std::size_t ipoly = 0, npols = mesh->NumberOfPolys(); ipoly < npols; ++ipoly) { + std::size_t npoints = mesh->SizeOfPoly(ipoly); if ( npoints >= 3 ) { - printout(DEBUG,"ASSIMPWriter","+++ Got polygon with %ld points",npoints); + printout(dd4hep::DEBUG,"ASSIMPWriter","+++ Got polygon with %ld points",npoints); /// /// 3-vertex polygons automatically translate to GL_TRIANGLES /// See Kronos documentation to glBegin / glEnd from the glu library: @@ -138,13 +140,13 @@ namespace { /// One triangle is defined for each vertex presented after the first two vertices. /// Vertices 1 , n + 1 , and n + 2 define triangle n. /// N - 2 triangles are drawn. - size_t v0 = mesh->GetVertexIndex(ipoly, 0); - size_t vv0 = vtx_index_replacements[v0]; - for( size_t ipoint = 0; ipoint < npoints-2; ++ipoint ) { - size_t v1 = mesh->GetVertexIndex(ipoly, ipoint+1); - size_t v2 = mesh->GetVertexIndex(ipoly, ipoint+2); - size_t vv1 = vtx_index_replacements[v1]; - size_t vv2 = vtx_index_replacements[v2]; + std::size_t v0 = mesh->GetVertexIndex(ipoly, 0); + std::size_t vv0 = vtx_index_replacements[v0]; + for( std::size_t ipoint = 0; ipoint < npoints-2; ++ipoint ) { + std::size_t v1 = mesh->GetVertexIndex(ipoly, ipoint+1); + std::size_t v2 = mesh->GetVertexIndex(ipoly, ipoint+2); + std::size_t vv1 = vtx_index_replacements[v1]; + std::size_t vv2 = vtx_index_replacements[v2]; if ( vv0 > vtx_len || vv1 > vtx_len || vv2 > vtx_len ) { ++nskip; continue; @@ -177,7 +179,7 @@ namespace { /// For odd n, vertices n, n + 1 , and n + 2 define triangle n. /// For even n, vertices n + 1 , n, and n + 2 define triangle n. /// N - 2 triangles are drawn. - for( size_t ipoint = 0; ipoint < npoints-2; ++ipoint ) { + for( std::size_t ipoint = 0; ipoint < npoints-2; ++ipoint ) { vtx_t v0(mesh->GetVertex(mesh->GetVertexIndex(ipoly, ipoint))); vtx_t v1(mesh->GetVertex(mesh->GetVertexIndex(ipoly, ipoint+1))); vtx_t v2(mesh->GetVertex(mesh->GetVertexIndex(ipoly, ipoint+2))); @@ -209,11 +211,11 @@ namespace { // Do not wonder about this logic. // GetBuffer3D (->make_mesh) uses static variable fgTransform of TGeoShape! glmat->Multiply(node->GetLeftMatrix()); - auto left_mesh = unique_ptr(make_mesh(left)); + auto left_mesh = std::unique_ptr(make_mesh(left)); *glmat = © glmat->Multiply(node->GetRightMatrix()); - auto right_mesh = unique_ptr(make_mesh(right)); + auto right_mesh = std::unique_ptr(make_mesh(right)); *glmat = © switch (oper) { @@ -229,14 +231,14 @@ namespace { } } - unique_ptr TessellateShape::tessellate_primitive(const std::string& name, Solid solid) { + std::unique_ptr TessellateShape::tessellate_primitive(const std::string& name, dd4hep::Solid solid) { using vtx_t = Vertex; const TBuffer3D& buf3D = solid->GetBuffer3D(TBuffer3D::kAll, false); struct pol_t { int c, n; int segs[1]; } *pol = nullptr; struct seg_t { int c, _1, _2; }; const seg_t* segs = (seg_t*)buf3D.fSegs; const vtx_t* vtcs = (vtx_t*)buf3D.fPnts; - size_t i, num_facet = 0; + std::size_t i, num_facet = 0; const Int_t* q; for( i=0, q=buf3D.fPols; in)) { @@ -244,7 +246,7 @@ namespace { for( int j=0; j < pol->n-1; ++j ) num_facet += 2; } - unique_ptr tes = make_unique(name.c_str(), num_facet); + std::unique_ptr tes = std::make_unique(name.c_str(), num_facet); q = buf3D.fPols; for( i=0, q=buf3D.fPols; i > placements; int build_mode = ((flags&0x1) != 0) ? 1 : 0; bool dump_facets = ((flags&0x2) != 0); - vector materials; - TGeoHMatrix toGlobal; + std::vector materials; + TGeoHMatrix toGlobal; for( auto pv : places ) _collect(placements, recursive, toGlobal, pv); - size_t num_mesh = placements.size(); + std::size_t num_mesh = placements.size(); aiScene scene; scene.mNumMaterials = 0; @@ -316,9 +318,9 @@ int ASSIMPWriter::write(const std::string& file_name, auto* geo_transform = TGeoShape::GetTransform(); TGeoHMatrix identity; - for( size_t imesh=0; imesh < num_mesh; ++imesh ) { - unique_ptr trafo(placements[imesh].second); - unique_ptr shape_holder; + for( std::size_t imesh=0; imesh < num_mesh; ++imesh ) { + std::unique_ptr trafo(placements[imesh].second); + std::unique_ptr shape_holder; PlacedVolume pv = placements[imesh].first; Volume vol = pv.volume(); Solid sol = vol.solid(); @@ -348,12 +350,12 @@ int ASSIMPWriter::write(const std::string& file_name, continue; } - size_t num_vert = 0; + std::size_t num_vert = 0; for( long j=0, n=tes->GetNfacets(); j < n; ++j ) num_vert += tes->GetFacet(j).GetNvert(); - size_t index = std::numeric_limits::max(); - for( size_t j=0; j::max(); + for( std::size_t j=0; j -using namespace std; -using namespace dd4hep; -using namespace dd4hep::detail; +using dd4hep::except; +using dd4hep::printout; /// If the path to the CAD file does not directly exist try to resolve it: -static string resolve_path(xml_h e, const string& file) { - error_code errc; +static std::string resolve_path(xml_h e, const std::string& file) { + std::error_code errc; std::string fname; /// Use the xml utilities in the DocumentHandler to resolve the relative path if ( file.length() > 7 && file.substr(0,7) == "file://" ) fname = file.substr(7); else fname = file; - if ( !filesystem::exists(fname, errc) ) { - string fn = xml::DocumentHandler::system_path(e, fname); + if ( !std::filesystem::exists(fname, errc) ) { + std::string fn = dd4hep::xml::DocumentHandler::system_path(e, fname); if ( fn.length() > 7 && fn.substr(0,7) == "file://" ) fn = fn.substr(7); if ( !std::filesystem::exists(fn, errc) ) { - auto fp = filesystem::path(xml::DocumentHandler::system_path(e)).parent_path(); + auto fp = std::filesystem::path(dd4hep::xml::DocumentHandler::system_path(e)).parent_path(); except("CAD_Shape","+++ CAD file: %s (= %s + %s) is not accessible [%d: %s]", fn.c_str(), fp.c_str(), fname.c_str(), errc.value(), errc.message().c_str()); @@ -50,8 +49,8 @@ static string resolve_path(xml_h e, const string& file) { return fname; } -static void* read_CAD_Volume(Detector& dsc, int argc, char** argv) { - string fname; +static void* read_CAD_Volume(dd4hep::Detector& dsc, int argc, char** argv) { + std::string fname; double scale = 1.0; bool help = false; for(int i = 0; i < argc && argv[i]; ++i) { @@ -64,16 +63,16 @@ static void* read_CAD_Volume(Detector& dsc, int argc, char** argv) { } if ( fname.empty() || help ) { - cout << + std::cout << "Usage: -plugin DD4hep_CAD_export -arg [-arg] \n\n" " -input Input file name. \n" " -scale Scale factor when importing shapes. \n" " -help Print this help output. \n" - " Arguments given: " << arguments(argc,argv) << endl << flush; + " Arguments given: " << dd4hep::arguments(argc,argv) << std::endl << std::flush; ::exit(EINVAL); } - auto volumes = cad::ASSIMPReader(dsc).readVolumes(fname, scale); + auto volumes = dd4hep::cad::ASSIMPReader(dsc).readVolumes(fname, scale); if ( volumes.empty() ) { except("CAD_Volume","+++ CAD file: %s does not contain any " "understandable tessellated volumes.", fname.c_str()); @@ -83,12 +82,12 @@ static void* read_CAD_Volume(Detector& dsc, int argc, char** argv) { } DECLARE_DD4HEP_CONSTRUCTOR(DD4hep_read_CAD_volumes,read_CAD_Volume) -static Handle create_CAD_Shape(Detector& dsc, xml_h e) { +static dd4hep::Handle create_CAD_Shape(dd4hep::Detector& dsc, xml_h e) { xml_elt_t elt(e); - cad::ASSIMPReader rdr(dsc); - string fname = resolve_path(e, elt.attr(_U(ref))); - long flags = elt.hasAttr(_U(flags)) ? elt.attr(_U(flags)) : 0; - double unit = elt.hasAttr(_U(unit)) ? elt.attr(_U(unit)) : dd4hep::cm; + dd4hep::cad::ASSIMPReader rdr(dsc); + std::string fname = resolve_path(e, elt.attr(_U(ref))); + long flags = elt.hasAttr(_U(flags)) ? elt.attr(_U(flags)) : 0; + double unit = elt.hasAttr(_U(unit)) ? elt.attr(_U(unit)) : dd4hep::cm; if ( flags ) rdr.flags = flags; auto shapes = rdr.readShapes(fname, unit); @@ -96,18 +95,18 @@ static Handle create_CAD_Shape(Detector& dsc, xml_h e) { except("CAD_Shape","+++ CAD file: %s does not contain any " "understandable tessellated shapes.", fname.c_str()); } - Solid solid; - size_t count = shapes.size(); + dd4hep::Solid solid; + std::size_t count = shapes.size(); if ( count == 1 ) { solid = shapes[0].release(); } else { if ( elt.hasAttr(_U(item)) ) { - size_t which = elt.attr(_U(item)); + std::size_t which = elt.attr(_U(item)); solid = shapes[which].release(); } else if ( elt.hasAttr(_U(mesh)) ) { - size_t which = elt.attr(_U(mesh)); + std::size_t which = elt.attr(_U(mesh)); solid = shapes[which].release(); } else { @@ -115,25 +114,25 @@ static Handle create_CAD_Shape(Detector& dsc, xml_h e) { "You need to add a selector.", fname.c_str(), shapes.size()); } } - if ( elt.hasAttr(_U(name)) ) solid->SetName(elt.attr(_U(name)).c_str()); + if ( elt.hasAttr(_U(name)) ) solid->SetName(elt.attr(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(CAD_Shape__shape_constructor,create_CAD_Shape) -static Handle create_CAD_Assembly(Detector& dsc, xml_h e) { - xml_elt_t elt(e); - string fname = resolve_path(e, elt.attr(_U(ref))); - double unit = elt.hasAttr(_U(unit)) ? elt.attr(_U(unit)) : dd4hep::cm; - auto volumes = cad::ASSIMPReader(dsc).readVolumes(fname, unit); +static dd4hep::Handle create_CAD_Assembly(dd4hep::Detector& dsc, xml_h e) { + xml_elt_t elt(e); + std::string fname = resolve_path(e, elt.attr(_U(ref))); + double unit = elt.hasAttr(_U(unit)) ? elt.attr(_U(unit)) : dd4hep::cm; + auto volumes = dd4hep::cad::ASSIMPReader(dsc).readVolumes(fname, unit); if ( volumes.empty() ) { except("CAD_Shape","+++ CAD file: %s does not contain any " "understandable tessellated volumes.", fname.c_str()); } - Assembly assembly("assembly"); - for(size_t i=0; i < volumes.size(); ++i) + dd4hep::Assembly assembly("assembly"); + for(std::size_t i=0; i < volumes.size(); ++i) assembly.placeVolume(volumes[i].release()); - if ( elt.hasAttr(_U(name)) ) assembly->SetName(elt.attr(_U(name)).c_str()); + if ( elt.hasAttr(_U(name)) ) assembly->SetName(elt.attr(_U(name)).c_str()); return assembly; } DECLARE_XML_VOLUME(CAD_Assembly__volume_constructor,create_CAD_Assembly) @@ -182,12 +181,12 @@ DECLARE_XML_VOLUME(CAD_Assembly__volume_constructor,create_CAD_Assembly) * * */ -static Handle create_CAD_Volume(Detector& dsc, xml_h e) { - xml_elt_t elt(e); - double unit = elt.attr(_U(unit)); - string fname = resolve_path(e, elt.attr(_U(ref))); - long flags = elt.hasAttr(_U(flags)) ? elt.attr(_U(flags)) : 0; - cad::ASSIMPReader rdr(dsc); +static dd4hep::Handle create_CAD_Volume(dd4hep::Detector& dsc, xml_h e) { + xml_elt_t elt(e); + double unit = elt.attr(_U(unit)); + std::string fname = resolve_path(e, elt.attr(_U(ref))); + long flags = elt.hasAttr(_U(flags)) ? elt.attr(_U(flags)) : 0; + dd4hep::cad::ASSIMPReader rdr(dsc); if ( flags ) rdr.flags = flags; auto volumes = rdr.readVolumes(fname, unit); @@ -195,47 +194,46 @@ static Handle create_CAD_Volume(Detector& dsc, xml_h e) { except("CAD_Volume","+++ CAD file: %s does not contain any " "understandable tessellated volumes.", fname.c_str()); } - Volume envelope; + dd4hep::Volume envelope; if ( elt.hasChild(_U(envelope)) ) { - string typ = "DD4hep_StdVolume"; + std::string typ = "DD4hep_StdVolume"; xml_h x_env = elt.child(_U(envelope)); - TObject* pvol = PluginService::Create(typ, &dsc, &x_env); + TObject* pvol = dd4hep::PluginService::Create(typ, &dsc, &x_env); envelope = dynamic_cast(pvol); if ( !envelope.isValid() ) { - except("CAD_Volume", - "+++ Unable to determine envelope to CAD shape: %s",fname.c_str()); + except("CAD_Volume", "+++ Unable to determine envelope to CAD shape: %s",fname.c_str()); } } else { - envelope = Assembly("envelope"); + envelope = dd4hep::Assembly("envelope"); } xml_dim_t x_envpos = elt.child(_U(position),false); xml_dim_t x_envrot = elt.child(_U(rotation),false); - Position env_pos; - RotationZYX env_rot; + dd4hep::Position env_pos; + dd4hep::RotationZYX env_rot; if ( x_envpos && x_envrot ) { - env_rot = RotationZYX(x_envrot.z(0), x_envrot.y(0), x_envrot.x(0)); - env_pos = Position(x_envpos.x(0), x_envpos.y(0), x_envpos.z(0)); + env_rot = dd4hep::RotationZYX(x_envrot.z(0), x_envrot.y(0), x_envrot.x(0)); + env_pos = dd4hep::Position(x_envpos.x(0), x_envpos.y(0), x_envpos.z(0)); } else if ( x_envpos ) - env_pos = Position(x_envpos.x(0), x_envpos.y(0), x_envpos.z(0)); + env_pos = dd4hep::Position(x_envpos.x(0), x_envpos.y(0), x_envpos.z(0)); else if ( x_envrot ) - env_rot = RotationZYX(x_envrot.z(0), x_envrot.y(0), x_envrot.x(0)); + env_rot = dd4hep::RotationZYX(x_envrot.z(0), x_envrot.y(0), x_envrot.x(0)); - Transform3D env_trafo(env_rot, env_pos); - Material default_material; + dd4hep::Transform3D env_trafo(env_rot, env_pos); + dd4hep::Material default_material; xml_dim_t x_mat = elt.child(_U(material),false); if ( x_mat.ptr() ) default_material = dsc.material(x_mat.nameStr()); - else if ( elt.hasAttr(_U(material)) ) default_material = dsc.material(elt.attr(_U(material))); + else if ( elt.hasAttr(_U(material)) ) default_material = dsc.material(elt.attr(_U(material))); if ( elt.hasChild(_U(volume)) ) { - map volume_map; + std::map volume_map; for (xml_coll_t c(elt,_U(volume)); c; ++c ) volume_map.emplace(xml_dim_t(c).id(),c); - for (size_t i=0; i < volumes.size(); ++i) { - Volume vol = volumes[i].release(); - Material mat = default_material; + for (std::size_t i=0; i < volumes.size(); ++i) { + dd4hep::Volume vol = volumes[i].release(); + dd4hep::Material mat = default_material; auto is = volume_map.find(i); if ( is == volume_map.end() ) { envelope.placeVolume(vol); @@ -246,24 +244,24 @@ static Handle create_CAD_Volume(Detector& dsc, xml_h e) { xml_dim_t x_rot = x_vol.child(_U(rotation),false); if ( x_vol.hasAttr(_U(material)) ) { - string mat_name = x_vol.attr(_U(material)); + std::string mat_name = x_vol.attr(_U(material)); mat = dsc.material(mat_name); if ( !mat.isValid() ) except("CAD_MultiVolume","+++ Failed to access material "+mat_name); vol.setMaterial(mat); } - Position pos; - RotationZYX rot; + dd4hep::Position pos; + dd4hep::RotationZYX rot; if ( x_pos && x_rot ) { - rot = RotationZYX(x_rot.z(0), x_rot.y(0), x_rot.x(0)); - pos = Position(x_pos.x(0), x_pos.y(0), x_pos.z(0)); + rot = dd4hep::RotationZYX(x_rot.z(0), x_rot.y(0), x_rot.x(0)); + pos = dd4hep::Position(x_pos.x(0), x_pos.y(0), x_pos.z(0)); } else if ( x_pos ) - pos = Position(x_pos.x(0), x_pos.y(0), x_pos.z(0)); + pos = dd4hep::Position(x_pos.x(0), x_pos.y(0), x_pos.z(0)); else if ( x_rot ) - rot = RotationZYX(x_rot.z(0), x_rot.y(0), x_rot.x(0)); + rot = dd4hep::RotationZYX(x_rot.z(0), x_rot.y(0), x_rot.x(0)); - PlacedVolume pv = envelope.placeVolume(vol,env_trafo*Transform3D(rot, pos)); + dd4hep::PlacedVolume pv = envelope.placeVolume(vol,env_trafo*dd4hep::Transform3D(rot, pos)); vol.setAttributes(dsc, x_vol.regionStr(), x_vol.limitsStr(), x_vol.visStr()); for (xml_coll_t cc(x_vol,_U(physvolid)); cc; ++cc ) { xml_dim_t vid = cc; @@ -273,8 +271,8 @@ static Handle create_CAD_Volume(Detector& dsc, xml_h e) { } } else { - for(size_t i=0; i < volumes.size(); ++i) { - Volume vol = volumes[i].release(); + for(std::size_t i=0; i < volumes.size(); ++i) { + dd4hep::Volume vol = volumes[i].release(); if ( vol.isValid() ) { if ( (vol.material() == dsc.air()) && default_material.isValid() ) vol.setMaterial(default_material); @@ -282,7 +280,7 @@ static Handle create_CAD_Volume(Detector& dsc, xml_h e) { } } } - if ( elt.hasAttr(_U(name)) ) envelope->SetName(elt.attr(_U(name)).c_str()); + if ( elt.hasAttr(_U(name)) ) envelope->SetName(elt.attr(_U(name)).c_str()); return envelope; } DECLARE_XML_VOLUME(CAD_MultiVolume__volume_constructor,create_CAD_Volume) @@ -291,11 +289,11 @@ DECLARE_XML_VOLUME(CAD_MultiVolume__volume_constructor,create_CAD_Volume) /** * */ -static long CAD_export(Detector& description, int argc, char** argv) { - bool recursive = false, help = false; - string volume, detector, fname, ftype; - double scale = 1.0; - int flags = 0; +static long CAD_export(dd4hep::Detector& description, int argc, char** argv) { + bool recursive = false, help = false; + std::string volume, detector, fname, ftype; + double scale = 1.0; + int flags = 0; for(int i = 0; i < argc && argv[i]; ++i) { if ( 0 == ::strncmp( "-output",argv[i],4) ) fname = argv[++i]; @@ -319,7 +317,7 @@ static long CAD_export(Detector& description, int argc, char** argv) { if ( fname.empty() || ftype.empty() ) help = true; if ( volume.empty() && detector.empty() ) help = true; if ( help ) { - cout << + std::cout << "Usage: -plugin DD4hep_CAD_export -arg [-arg] \n\n" " -output Output file name. \n" " -type Output file type. \n" @@ -329,17 +327,17 @@ static long CAD_export(Detector& description, int argc, char** argv) { " -help Print this help output. \n" " -scale Unit scale before writing output data. \n" " -flags Flagsging helper to pass args -- Experts only. \n" - " Arguments given: " << arguments(argc,argv) << endl << flush; + " Arguments given: " << dd4hep::arguments(argc,argv) << std::endl << std::flush; ::exit(EINVAL); } - PlacedVolume pv; + dd4hep::PlacedVolume pv; if ( !detector.empty() ) { - DetElement elt; + dd4hep::DetElement elt; if ( detector == "/world" ) elt = description.world(); else - elt = detail::tools::findElement(description,detector); + elt = dd4hep::detail::tools::findElement(description,detector); if ( !elt.isValid() ) { except("DD4hep_CAD_export","+++ Invalid DetElement path: %s",detector.c_str()); } @@ -349,17 +347,18 @@ static long CAD_export(Detector& description, int argc, char** argv) { pv = elt.placement(); } else if ( !volume.empty() ) { - pv = detail::tools::findNode(description.world().placement(), volume); + pv = dd4hep::detail::tools::findNode(description.world().placement(), volume); if ( !pv.isValid() ) { except("DD4hep_CAD_export","+++ Invalid placement path: %s",volume.c_str()); } } - cad::ASSIMPWriter wr(description); + dd4hep::cad::ASSIMPWriter wr(description); if ( flags ) wr.flags = flags; - std::vector places {pv}; + std::vector places {pv}; auto num_mesh = wr.write(fname, ftype, places, recursive, scale); if ( num_mesh < 0 ) { - printout(ERROR, "DD4hep_CAD_export","+++ Failed to export shapes to CAD file: %s [%s]", + printout(dd4hep::ERROR, "DD4hep_CAD_export", + "+++ Failed to export shapes to CAD file: %s [%s]", fname.c_str(), ftype.c_str()); } return 1; diff --git a/DDCond/src/ConditionsContent.cpp b/DDCond/src/ConditionsContent.cpp index a5f414599..b7fbabae9 100644 --- a/DDCond/src/ConditionsContent.cpp +++ b/DDCond/src/ConditionsContent.cpp @@ -12,12 +12,10 @@ //========================================================================== // Framework include files -#include "DDCond/ConditionsContent.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/Printout.h" +#include +#include +#include -using namespace std; -using namespace dd4hep; using namespace dd4hep::cond; /// Default constructor @@ -95,16 +93,16 @@ bool ConditionsContent::remove(Condition::key_type hash) { return false; } -pair +std::pair ConditionsContent::insertKey(Condition::key_type hash) { auto ret = m_conditions.emplace(hash,(ConditionsLoadInfo*)0); //printout(DEBUG,"ConditionsContent","++ Insert key: %016X",hash); - if ( ret.second ) return pair(hash,0); - return pair(0,0); + if ( ret.second ) return { hash, 0 }; + return { 0,0 }; } /// Add a new conditions key. T must inherit from class ConditionsContent::Info -pair +std::pair ConditionsContent::addLocationInfo(Condition::key_type hash, ConditionsLoadInfo* info) { if ( info ) { //printout(DEBUG,"ConditionsContent","++ Add location key: %016X",hash); @@ -115,11 +113,11 @@ ConditionsContent::addLocationInfo(Condition::key_type hash, ConditionsLoadInfo* } info->release(); } - return pair(0,0); + return { 0,0 }; } /// Add a new shared conditions dependency -pair +std::pair ConditionsContent::addDependency(ConditionDependency* dep) { auto ret = m_derived.emplace(dep->key(),dep); @@ -139,11 +137,11 @@ ConditionsContent::addDependency(ConditionDependency* dep) except("DeConditionsRequests", "++ Dependency already exists: %s [%08X] [%016llX]", path, maker.values.item_key, maker.hash); - return pair(0,0); + return std::pair(0,0); } /// Add a new conditions dependency (Built internally from arguments) -std::pair +std::pair ConditionsContent::addDependency(DetElement de, Condition::itemkey_type item, std::shared_ptr callback) diff --git a/DDCond/src/ConditionsDependencyHandler.cpp b/DDCond/src/ConditionsDependencyHandler.cpp index e69b3558f..29fd5c2ab 100644 --- a/DDCond/src/ConditionsDependencyHandler.cpp +++ b/DDCond/src/ConditionsDependencyHandler.cpp @@ -12,13 +12,12 @@ //========================================================================== // Framework include files -#include "DDCond/ConditionsDependencyHandler.h" -#include "DDCond/ConditionsManagerObject.h" -#include "DD4hep/ConditionsProcessor.h" -#include "DD4hep/Printout.h" -#include "TTimeStamp.h" +#include +#include +#include +#include +#include -using namespace dd4hep; using namespace dd4hep::cond; namespace { @@ -46,7 +45,8 @@ void ConditionsDependencyHandler::Work::do_intersection(const IOV* iov_ptr) { } } -Condition ConditionsDependencyHandler::Work::resolve(Work*& current) { +dd4hep::Condition +ConditionsDependencyHandler::Work::resolve(Work*& current) { Work* previous = current; current = this; state = RESOLVED; @@ -86,7 +86,7 @@ ConditionsDependencyHandler::~ConditionsDependencyHandler() { } /// ConditionResolver implementation: Access to the detector description instance -Detector& ConditionsDependencyHandler::detectorDescription() const { +dd4hep::Detector& ConditionsDependencyHandler::detectorDescription() const { return m_manager->detectorDescription(); } @@ -164,17 +164,20 @@ bool ConditionsDependencyHandler::registerOne(const IOV& iov, Condition cond) } /// Handle multi-condition inserts by callbacks: block insertions of conditions with identical IOV -size_t ConditionsDependencyHandler::registerMany(const IOV& iov, const std::vector& values) { +std::size_t +ConditionsDependencyHandler::registerMany(const IOV& iov, const std::vector& values) { return m_pool.registerMany(iov, values); } /// Interface to access conditions by hash value of the DetElement (only valid at resolve!) -std::vector ConditionsDependencyHandler::get(DetElement de) { +std::vector +ConditionsDependencyHandler::get(DetElement de) { return this->get(de.key()); } /// Interface to access conditions by hash value of the item (only valid at resolve!) -std::vector ConditionsDependencyHandler::getByItem(Condition::itemkey_type key) { +std::vector +ConditionsDependencyHandler::getByItem(Condition::itemkey_type key) { if ( m_state == RESOLVED ) { struct item_selector { std::vector conditions; @@ -197,7 +200,8 @@ std::vector ConditionsDependencyHandler::getByItem(Condition::itemkey } /// Interface to access conditions by hash value of the DetElement (only valid at resolve!) -std::vector ConditionsDependencyHandler::get(Condition::detkey_type det_key) { +std::vector +ConditionsDependencyHandler::get(Condition::detkey_type det_key) { if ( m_state == RESOLVED ) { ConditionKey::KeyMaker lower(det_key, Condition::FIRST_ITEM_KEY); ConditionKey::KeyMaker upper(det_key, Condition::LAST_ITEM_KEY); @@ -211,14 +215,16 @@ std::vector ConditionsDependencyHandler::get(Condition::detkey_type d } /// ConditionResolver implementation: Interface to access conditions -Condition ConditionsDependencyHandler::get(Condition::key_type key, bool throw_if_not) { +dd4hep::Condition +ConditionsDependencyHandler::get(Condition::key_type key, bool throw_if_not) { return this->get(key, nullptr, throw_if_not); } /// ConditionResolver implementation: Interface to access conditions -Condition ConditionsDependencyHandler::get(Condition::key_type key, - const ConditionDependency* dependency, - bool throw_if_not) +dd4hep::Condition +ConditionsDependencyHandler::get(Condition::key_type key, + const ConditionDependency* dependency, + bool throw_if_not) { /// If we are not already resolving here, we follow the normal procedure Condition c = m_pool.get(key); @@ -324,14 +330,14 @@ void ConditionsDependencyHandler::do_callback(Work* work) { } else { printout(ERROR,"DependencyHandler", - "+++ Callback handler returned invalid condition. Key:%s %c%s%c", - work->context.dependency->target.toString().c_str(), + "+++ Callback handler returned invalid condition. Key:%s %c%s%c", + work->context.dependency->target.toString().c_str(), #if defined(DD4HEP_CONDITIONS_DEBUG) - '[',work->context.dependency->detector.path().c_str(),']' + '[',work->context.dependency->detector.path().c_str(),']' #else - ' ',"",' ' + ' ',"",' ' #endif - ); + ); throw std::runtime_error("Invalid derived condition callback"); } return; diff --git a/DDCond/src/ConditionsIOVPool.cpp b/DDCond/src/ConditionsIOVPool.cpp index 823a94ed5..23d188a67 100644 --- a/DDCond/src/ConditionsIOVPool.cpp +++ b/DDCond/src/ConditionsIOVPool.cpp @@ -12,15 +12,14 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" -#include "DDCond/ConditionsIOVPool.h" -#include "DDCond/ConditionsCleanup.h" -#include "DDCond/ConditionsDataLoader.h" +#include +#include +#include +#include +#include -#include "DD4hep/detail/ConditionsInterna.h" +#include -using namespace dd4hep; using namespace dd4hep::cond; /// Default constructor diff --git a/DDCond/src/ConditionsManager.cpp b/DDCond/src/ConditionsManager.cpp index d96700c28..81217e816 100644 --- a/DDCond/src/ConditionsManager.cpp +++ b/DDCond/src/ConditionsManager.cpp @@ -12,24 +12,21 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/Errors.h" -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/detail/Handle.inl" -#include "DD4hep/PluginCreators.h" - -#include "DD4hep/ConditionsListener.h" -#include "DDCond/ConditionsManager.h" -#include "DDCond/ConditionsManagerObject.h" - -using namespace std; -using namespace dd4hep; +#include +#include +#include +#include +#include +#include + +#include +#include +#include + using namespace dd4hep::cond; DD4HEP_INSTANTIATE_HANDLE_NAMED(ConditionsManagerObject); - /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -94,8 +91,8 @@ void ConditionsManagerObject::onRemove(Condition condition) { } /// Access the used/registered IOV types -const vector ConditionsManagerObject::iovTypesUsed() const { - vector result; +const std::vector ConditionsManagerObject::iovTypesUsed() const { + std::vector result; const auto& types = this->iovTypes(); for ( const auto& i : types ) { if ( i.type != IOVType::UNKNOWN_IOV ) result.emplace_back(&i); @@ -107,15 +104,15 @@ const vector ConditionsManagerObject::iovTypesUsed() const { void ConditionsManagerObject::fromString(const std::string& data, IOV& iov) { size_t id1 = data.find(','); size_t id2 = data.find('#'); - if ( id2 == string::npos ) { + if ( id2 == std::string::npos ) { except("ConditionsManager","+++ Unknown IOV string representation: %s",data.c_str()); } - string iov_name = data.substr(id2+1); + std::string iov_name = data.substr(id2+1); IOV::Key key; int nents = 0; /// Need assignment from long (k1,k2) for compatibility with Apple MAC long k1 = 0, k2 = 0; - if ( id1 != string::npos ) { + if ( id1 != std::string::npos ) { nents = ::sscanf(data.c_str(),"%ld,%ld#",&k1,&k2) == 2 ? 2 : 0; key.second = k2; key.first = k1; @@ -143,7 +140,7 @@ void ConditionsManagerObject::fromString(const std::string& data, IOV& iov) { } /// Register IOV using new string data -ConditionsPool* ConditionsManagerObject::registerIOV(const string& data) { +ConditionsPool* ConditionsManagerObject::registerIOV(const std::string& data) { IOV iov(0); // Convert string to IOV fromString(data, iov); @@ -173,17 +170,17 @@ ConditionsManager& ConditionsManager::initialize() { } /// Access the detector description -Detector& ConditionsManager::detectorDescription() const { +dd4hep::Detector& ConditionsManager::detectorDescription() const { return access()->detectorDescription(); } /// Access to the property manager -PropertyManager& ConditionsManager::properties() const { +dd4hep::PropertyManager& ConditionsManager::properties() const { return access()->properties(); } /// Access to properties -Property& ConditionsManager::operator[](const std::string& property_name) const { +dd4hep::Property& ConditionsManager::operator[](const std::string& property_name) const { return access()->properties().property(property_name); } @@ -193,13 +190,13 @@ ConditionsDataLoader& ConditionsManager::loader() const { } /// Register new IOV type if it does not (yet) exist. -pair -ConditionsManager::registerIOVType(size_t iov_type, const string& iov_name) const { +std::pair +ConditionsManager::registerIOVType(size_t iov_type, const std::string& iov_name) const { return access()->registerIOVType(iov_type, iov_name); } /// Access IOV by its name -const IOVType* ConditionsManager::iovType (const string& iov_name) const { +const dd4hep::IOVType* ConditionsManager::iovType (const std::string& iov_name) const { return access()->iovType(iov_name); } @@ -209,9 +206,9 @@ ConditionsIOVPool* ConditionsManager::iovPool(const IOVType& iov_type) const { } /// Access the used/registered IOV types -const vector ConditionsManager::iovTypesUsed() const { +const std::vector ConditionsManager::iovTypesUsed() const { Object* obj = access(); - vector result; + std::vector result; const auto& types = obj->iovTypes(); result.reserve(types.size()); for(const auto& i : types ) @@ -220,7 +217,7 @@ const vector ConditionsManager::iovTypesUsed() const { } /// Register IOV with type and key -ConditionsPool* ConditionsManager::registerIOV(const string& iov_rep) const { +ConditionsPool* ConditionsManager::registerIOV(const std::string& iov_rep) const { IOV iov(0); Object* o = access(); o->fromString(iov_rep, iov); @@ -244,12 +241,12 @@ ConditionsPool* ConditionsManager::registerIOV(const IOVType& typ, IOV::Key key) } /// Create IOV from string -void ConditionsManager::fromString(const string& iov_str, IOV& iov) const { +void ConditionsManager::fromString(const std::string& iov_str, IOV& iov) const { access()->fromString(iov_str, iov); } /// Register a whole block of conditions with identical IOV. -size_t ConditionsManager::blockRegister(ConditionsPool& pool, const std::vector& cond) const { +std::size_t ConditionsManager::blockRegister(ConditionsPool& pool, const std::vector& cond) const { return access()->blockRegister(pool, cond); } diff --git a/DDCond/src/ConditionsOperators.cpp b/DDCond/src/ConditionsOperators.cpp index d1eeea0a2..11359025e 100644 --- a/DDCond/src/ConditionsOperators.cpp +++ b/DDCond/src/ConditionsOperators.cpp @@ -12,18 +12,16 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/detail/ConditionsInterna.h" -#include "DDCond/ConditionsPool.h" -#include "DDCond/ConditionsIOVPool.h" -#include "DDCond/ConditionsOperators.h" +#include +#include +#include +#include +#include +#include // C/C++ include files #include -using namespace std; -using namespace dd4hep; using namespace dd4hep::cond; /// Select all condition from the conditions manager registered at the Detector object diff --git a/DDCond/src/ConditionsPool.cpp b/DDCond/src/ConditionsPool.cpp index 039c33392..bcffef9e8 100644 --- a/DDCond/src/ConditionsPool.cpp +++ b/DDCond/src/ConditionsPool.cpp @@ -12,16 +12,14 @@ //========================================================================== // Framework include files -#include "DDCond/ConditionsPool.h" -#include "DDCond/ConditionsManagerObject.h" -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/detail/Handle.inl" -#include "DD4hep/ConditionsPrinter.h" -#include "DD4hep/detail/ConditionsInterna.h" +#include +#include +#include +#include +#include +#include +#include -using std::string; -using namespace dd4hep; using namespace dd4hep::cond; DD4HEP_INSTANTIATE_HANDLE_NAMED(UpdatePool); @@ -47,7 +45,7 @@ void ConditionsPool::print() const { } /// Print pool basics -void ConditionsPool::print(const string& opt) const { +void ConditionsPool::print(const std::string& opt) const { printout(INFO,"ConditionsPool","+++ %s Conditions for pool with IOV: %-32s age:%3d [%4d entries]", opt.c_str(), GetName(), age_value, size()); if ( opt == "*" || opt == "ALL" ) { diff --git a/DDCond/src/ConditionsRepository.cpp b/DDCond/src/ConditionsRepository.cpp index 49e2309f6..3ef3695a0 100644 --- a/DDCond/src/ConditionsRepository.cpp +++ b/DDCond/src/ConditionsRepository.cpp @@ -12,14 +12,14 @@ //========================================================================== // Framework include files -#include "DDCond/ConditionsRepository.h" -#include "DDCond/ConditionsManager.h" -#include "DDCond/ConditionsIOVPool.h" -#include "DDCond/ConditionsTags.h" -#include "DD4hep/detail/ConditionsInterna.h" -#include "DD4hep/Printout.h" -#include "XML/DocumentHandler.h" -#include "XML/XMLTags.h" +#include +#include +#include +#include +#include +#include +#include +#include // C/C++ include files #include @@ -28,15 +28,13 @@ #include #include -using namespace std; -using namespace dd4hep; using namespace dd4hep::cond; -typedef xml::Handle_t xml_h; -typedef xml::Element xml_elt_t; -typedef xml::Document xml_doc_t; -typedef xml::Collection_t xml_coll_t; +typedef dd4hep::xml::Handle_t xml_h; +typedef dd4hep::xml::Element xml_elt_t; +typedef dd4hep::xml::Document xml_doc_t; +typedef dd4hep::xml::Collection_t xml_coll_t; -typedef map AllConditions; +typedef std::map AllConditions; /// Default constructor ConditionsRepository::ConditionsRepository() { @@ -48,7 +46,7 @@ ConditionsRepository::~ConditionsRepository() { namespace { - int createXML(const string& output, const AllConditions& all) { + int createXML(const std::string& output, const AllConditions& all) { const char comment[] = "\n" " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" " ++++ Linear collider detector description Detector in C++ ++++\n" @@ -62,8 +60,8 @@ namespace { xml_elt_t root = doc.root(), cond(0); for( const auto& i : all ) { char text[32]; - Condition c = i.second; - ::snprintf(text,sizeof(text),"0x%16llX",c.key()); + dd4hep::Condition c = i.second; + std::snprintf(text,sizeof(text),"0x%16llX",c.key()); root.append(cond = xml_elt_t(doc, _U(ref))); cond.setAttr(_U(key), text); #if !defined(DD4HEP_MINIMAL_CONDITIONS) @@ -71,7 +69,7 @@ namespace { cond.setAttr(_U(ref), c.address()); #endif } - printout(ALWAYS,"ConditionsRepository","++ Handled %ld conditions.",all.size()); + dd4hep::printout(dd4hep::ALWAYS,"ConditionsRepository","++ Handled %ld conditions.",all.size()); if ( !output.empty() ) { return docH.output(doc, output); } @@ -79,7 +77,7 @@ namespace { } /// Load the repository from file and fill user passed data structory - int readXML(const string& input, ConditionsRepository::Data& data) { + int readXML(const std::string& input, ConditionsRepository::Data& data) { struct Conv { /// Reference to optional user defined parameter ConditionsRepository::Data& data; @@ -87,60 +85,60 @@ namespace { Conv(ConditionsRepository::Data& p) : data(p) {} /// Callback operator to be specialized depending on the element type void operator()(xml_h element) const { - string key = element.attr(_U(key)); - size_t cap = data.capacity(); + std::string key = element.attr(_U(key)); + std::size_t cap = data.capacity(); ConditionsRepository::Entry e; ::sscanf(key.c_str(),"0x%16llX",&e.key); - e.name = element.attr(_U(name)); - e.address = element.attr(_U(ref)); + e.name = element.attr(_U(name)); + e.address = element.attr(_U(ref)); if ( data.size() == cap ) data.reserve(cap+500); data.emplace_back(e); } }; - xml::DocumentHolder doc(xml::DocumentHandler().load(input)); + dd4hep::xml::DocumentHolder doc(dd4hep::xml::DocumentHandler().load(input)); xml_h root = doc.root(); xml_coll_t(root, _U(ref)).for_each(Conv(data)); return 1; } #if defined(DD4HEP_MINIMAL_CONDITIONS) - int createText(const string& output, const AllConditions&, char) + int createText(const std::string& output, const AllConditions&, char) #else - int createText(const string& output, const AllConditions& all, char sep) + int createText(const std::string& output, const AllConditions& all, char sep) #endif { - ofstream out(output); + std::ofstream out(output); #if !defined(DD4HEP_MINIMAL_CONDITIONS) - size_t siz_nam=0, siz_add=0, siz_tot=0; + std::size_t siz_nam=0, siz_add=0, siz_tot=0; char fmt[64], text[2*PATH_MAX+64]; if ( !out.good() ) { - except("ConditionsRepository", - "++ Failed to open output file:%s [errno:%d %s]", - output.c_str(), errno, ::strerror(errno)); + dd4hep::except("ConditionsRepository", + "++ Failed to open output file:%s [errno:%d %s]", + output.c_str(), errno, ::strerror(errno)); } else if ( sep ) { - ::snprintf(fmt,sizeof(fmt),"%%16llX%c%%s%c%%s%c",sep,sep,sep); + std::snprintf(fmt,sizeof(fmt),"%%16llX%c%%s%c%%s%c",sep,sep,sep); } else { for( const auto& i : all ) { - Condition::Object* c = i.second.ptr(); - size_t siz_n = c->name.length(); - size_t siz_a = c->address.length(); + dd4hep::Condition::Object* c = i.second.ptr(); + std::size_t siz_n = c->name.length(); + std::size_t siz_a = c->address.length(); if ( siz_nam < siz_n ) siz_nam = siz_n; if ( siz_add < siz_a ) siz_add = siz_a; if ( siz_tot < (siz_n+siz_a) ) siz_tot = siz_n+siz_a; } siz_tot += 8+2+1; - ::snprintf(fmt,sizeof(fmt),"%%16llX %%-%lds %%-%lds",long(siz_nam),long(siz_add)); + std::snprintf(fmt,sizeof(fmt),"%%16llX %%-%lds %%-%lds",long(siz_nam),long(siz_add)); } out << "dd4hep." << char(sep ? sep : '-') << "." << long(siz_nam) << "." << long(siz_add) - << "." << long(siz_tot) << endl; + << "." << long(siz_tot) << std::endl; for( const auto& i : all ) { - Condition c = i.second; - ::snprintf(text, sizeof(text), fmt, c.key(), c.name(), c.address().c_str()); - out << text << endl; + dd4hep::Condition c = i.second; + std::snprintf(text, sizeof(text), fmt, c.key(), c.name(), c.address().c_str()); + out << text << std::endl; } #endif out.close(); @@ -148,11 +146,11 @@ namespace { } /// Load the repository from file and fill user passed data structory - int readText(const string& input, ConditionsRepository::Data& data) { - size_t idx, siz_nam, siz_add, siz_tot; + int readText(const std::string& input, ConditionsRepository::Data& data) { + std::size_t idx, siz_nam, siz_add, siz_tot; char sep, c, text[2*PATH_MAX]; ConditionsRepository::Entry e; - ifstream in(input); + std::ifstream in(input); in >> c >> c >> c >> c >> c >> c >> c >> sep >> c >> siz_nam @@ -167,34 +165,34 @@ namespace { text[0] = 0; in.getline(text,sizeof(text),'\n'); if ( in.good() ) { - text[sizeof(text)-1] = 0; + text[sizeof(text)-1] = 0; if ( siz_tot ) { - text[8] = 0; + text[8] = 0; // Direct access mode with fixed record size if ( 9+siz_nam < sizeof(text) ) { text[9+siz_nam] = 0; e.name = text+9; - } + } if ( 10+siz_nam+siz_add < (long)sizeof(text) ) { text[10+siz_nam+siz_add] = 0; e.address = text+10+siz_nam; - if ( (idx=e.name.find(' ')) != string::npos && idx < e.name.length() ) + if ( (idx=e.name.find(' ')) != std::string::npos && idx < e.name.length() ) e.name[idx] = 0; - if ( (idx=e.address.find(' ')) != string::npos && idx < e.address.length() ) + if ( (idx=e.address.find(' ')) != std::string::npos && idx < e.address.length() ) e.address[idx] = 0; } else { - except("ConditionsRepository","+++ Invalid record encountered. [Sever error]"); + dd4hep::except("ConditionsRepository","+++ Invalid record encountered. [Sever error]"); } } else { // Variable record size e.name=text+9; - if ( (idx=e.name.find(sep)) != string::npos && idx < sizeof(text)-10 ) + if ( (idx=e.name.find(sep)) != std::string::npos && idx < sizeof(text)-10 ) text[9+idx] = 0, e.address=text+idx+10, e.name=text+9; - if ( (idx=e.address.find(sep)) != string::npos && idx < e.address.length() ) + if ( (idx=e.address.find(sep)) != std::string::npos && idx < e.address.length() ) e.address[idx] = 0; - else if ( (idx=e.address.find('\n')) != string::npos && idx < e.address.length() ) + else if ( (idx=e.address.find('\n')) != std::string::npos && idx < e.address.length() ) e.address[idx] = 0; } size_t cap = data.capacity(); @@ -209,7 +207,7 @@ namespace { } /// Save the repository to file -int ConditionsRepository::save(ConditionsManager manager, const string& output) const { +int ConditionsRepository::save(ConditionsManager manager, const std::string& output) const { AllConditions all; const auto types = manager.iovTypesUsed(); for( const IOVType* type : types ) { @@ -226,19 +224,19 @@ int ConditionsRepository::save(ConditionsManager manager, const string& output) } } - if ( output.find(".xml") != string::npos ) { + if ( output.find(".xml") != std::string::npos ) { /// Write XML file with conditions addresses return createXML(output, all); } - else if ( output.find(".txt") != string::npos ) { + else if ( output.find(".txt") != std::string::npos ) { /// Write fixed records with conditions addresses return createText(output, all, 0); } - else if ( output.find(".daf") != string::npos ) { + else if ( output.find(".daf") != std::string::npos ) { /// Write fixed records with conditions addresses return createText(output, all, 0); } - else if ( output.find(".csv") != string::npos ) { + else if ( output.find(".csv") != std::string::npos ) { /// Write records separated by ';' with conditions addresses return createText(output, all, ';'); } @@ -246,17 +244,17 @@ int ConditionsRepository::save(ConditionsManager manager, const string& output) } /// Load the repository from file and fill user passed data structory -int ConditionsRepository::load(const string& input, Data& data) const { - if ( input.find(".xml") != string::npos ) { +int ConditionsRepository::load(const std::string& input, Data& data) const { + if ( input.find(".xml") != std::string::npos ) { return readXML(input, data); } - else if ( input.find(".txt") != string::npos ) { + else if ( input.find(".txt") != std::string::npos ) { return readText(input, data); } - else if ( input.find(".daf") != string::npos ) { + else if ( input.find(".daf") != std::string::npos ) { return readText(input, data); } - else if ( input.find(".csv") != string::npos ) { + else if ( input.find(".csv") != std::string::npos ) { return readText(input, data); } return 0; diff --git a/DDCond/src/ConditionsRootPersistency.cpp b/DDCond/src/ConditionsRootPersistency.cpp index 28ed62862..f90589058 100644 --- a/DDCond/src/ConditionsRootPersistency.cpp +++ b/DDCond/src/ConditionsRootPersistency.cpp @@ -12,22 +12,19 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DDCond/ConditionsSlice.h" -#include "DDCond/ConditionsIOVPool.h" -#include "DDCond/ConditionsRootPersistency.h" +#include +#include +#include +#include -#include "TFile.h" -#include "TTimeStamp.h" +#include +#include typedef dd4hep::cond::ConditionsRootPersistency __ConditionsRootPersistency; /// ROOT Class implementation directive ClassImp(__ConditionsRootPersistency) - -using namespace std; -using namespace dd4hep; using namespace dd4hep::cond; // Local namespace for anonymous stuff @@ -39,12 +36,12 @@ namespace { * \version 1.0 * \ingroup DD4HEP_CONDITIONS */ - struct Scanner : public Condition::Processor { + struct Scanner : public dd4hep::Condition::Processor { ConditionsRootPersistency::pool_type& pool; /// Constructor Scanner(ConditionsRootPersistency::pool_type& p) : pool(p) {} /// Conditions callback for object processing - virtual int process(Condition c) const override { + virtual int process(dd4hep::Condition c) const override { pool.emplace_back(c.ptr()); return 1; } @@ -66,7 +63,7 @@ ConditionsRootPersistency::ConditionsRootPersistency() : TNamed() { } /// Initializing constructor -ConditionsRootPersistency::ConditionsRootPersistency(const string& name, const string& title) +ConditionsRootPersistency::ConditionsRootPersistency(const std::string& name, const std::string& title) : TNamed(name.c_str(), title.c_str()) { } @@ -77,11 +74,12 @@ ConditionsRootPersistency::~ConditionsRootPersistency() { } /// Add conditions content to be saved. Note, that dependent conditions shall not be saved! -size_t ConditionsRootPersistency::add(const std::string& identifier, - const IOV& iov, - std::vector& conditions) { +std::size_t ConditionsRootPersistency::add(const std::string& identifier, + const IOV& iov, + std::vector& conditions) +{ DurationStamp stamp(this); - conditionPools.emplace_back(pair()); + conditionPools.emplace_back(std::pair()); pool_type& ent = conditionPools.back().second; iov_key_type& key = conditionPools.back().first; key.first = identifier; @@ -93,9 +91,9 @@ size_t ConditionsRootPersistency::add(const std::string& identifier, } /// Add conditions content to the saved. Note, that dependent conditions shall not be saved! -size_t ConditionsRootPersistency::add(const string& identifier, ConditionsPool& pool) { +size_t ConditionsRootPersistency::add(const std::string& identifier, ConditionsPool& pool) { DurationStamp stamp(this); - conditionPools.emplace_back(pair()); + conditionPools.emplace_back(std::pair()); pool_type& ent = conditionPools.back().second; iov_key_type& key = conditionPools.back().first; const IOV* iov = pool.iov; @@ -108,11 +106,11 @@ size_t ConditionsRootPersistency::add(const string& identifier, ConditionsPool& } /// Add conditions content to the saved. Note, that dependent conditions shall not be saved! -size_t ConditionsRootPersistency::add(const string& identifier, const ConditionsIOVPool& pool) { +size_t ConditionsRootPersistency::add(const std::string& identifier, const ConditionsIOVPool& pool) { size_t count = 0; DurationStamp stamp(this); for( const auto& p : pool.elements ) { - iovPools.emplace_back(pair()); + iovPools.emplace_back(std::pair()); pool_type& ent = iovPools.back().second; iov_key_type& key = iovPools.back().first; const IOV* iov = p.second->iov; @@ -127,9 +125,9 @@ size_t ConditionsRootPersistency::add(const string& identifier, const Conditions } /// Add conditions content to the saved. Note, that dependent conditions shall not be saved! -size_t ConditionsRootPersistency::add(const string& identifier, const UserPool& pool) { +size_t ConditionsRootPersistency::add(const std::string& identifier, const UserPool& pool) { DurationStamp stamp(this); - userPools.emplace_back(pair()); + userPools.emplace_back(std::pair()); pool_type& ent = userPools.back().second; iov_key_type& key = userPools.back().first; const IOV& iov = pool.validity(); @@ -142,7 +140,7 @@ size_t ConditionsRootPersistency::add(const string& identifier, const UserPool& } /// Open ROOT file in read mode -TFile* ConditionsRootPersistency::openFile(const string& fname) { +TFile* ConditionsRootPersistency::openFile(const std::string& fname) { TDirectory::TContext context; TFile* file = TFile::Open(fname.c_str()); if ( file && !file->IsZombie()) return file; @@ -171,7 +169,7 @@ void ConditionsRootPersistency::clear() { /// Add conditions content to the saved. Note, that dependent conditions shall not be saved! std::unique_ptr -ConditionsRootPersistency::load(TFile* file,const string& obj) { +ConditionsRootPersistency::load(TFile* file,const std::string& obj) { std::unique_ptr p; if ( file && !file->IsZombie()) { TTimeStamp start; @@ -304,7 +302,7 @@ int ConditionsRootPersistency::save(TFile* file) { } /// Save the data content to a root file -int ConditionsRootPersistency::save(const string& fname) { +int ConditionsRootPersistency::save(const std::string& fname) { DurationStamp stamp(this); //TDirectory::TContext context; TFile* file = TFile::Open(fname.c_str(),"RECREATE"); diff --git a/DDCond/src/ConditionsSlice.cpp b/DDCond/src/ConditionsSlice.cpp index 0be5e5029..9c97fd96d 100644 --- a/DDCond/src/ConditionsSlice.cpp +++ b/DDCond/src/ConditionsSlice.cpp @@ -12,13 +12,11 @@ //========================================================================== // Framework include files -#include "DDCond/ConditionsSlice.h" -#include "DDCond/ConditionsIOVPool.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/Printout.h" +#include +#include +#include +#include -using namespace std; -using namespace dd4hep; using namespace dd4hep::cond; /// Initializing constructor @@ -29,7 +27,7 @@ ConditionsSlice::ConditionsSlice(ConditionsManager mgr) : manager(mgr) /// Initializing constructor ConditionsSlice::ConditionsSlice(ConditionsManager mgr, - const shared_ptr& cont) + const std::shared_ptr& cont) : manager(mgr), content(cont) { InstanceCount::increment(this); @@ -55,10 +53,10 @@ void ConditionsSlice::derefPools() { } /// Access the combined IOV of the slice from the pool -const IOV& ConditionsSlice::iov() const { +const dd4hep::IOV& ConditionsSlice::iov() const { if ( pool.get() ) return pool->validity(); - dd4hep::except("ConditionsSlice", - "pool-iov: Failed to access validity of non-existing pool."); + except("ConditionsSlice", + "pool-iov: Failed to access validity of non-existing pool."); return pool->validity(); } @@ -74,29 +72,29 @@ bool ConditionsSlice::manage(ConditionsPool* p, Condition condition, ManageFlag bool ret = false; if ( flg®ISTER_MANAGER ) { if ( !p ) { - dd4hep::except("ConditionsSlice", - "manage_condition: Cannot access conditions pool according to IOV:%s.", - pool->validity().str().c_str()); + except("ConditionsSlice", + "manage_condition: Cannot access conditions pool according to IOV:%s.", + pool->validity().str().c_str()); } ret = manager.registerUnlocked(*p,condition); if ( !ret ) { - dd4hep::except("ConditionsSlice", - "manage_condition: Failed to register condition %016llx according to IOV:%s.", - condition->hash, pool->validity().str().c_str()); + except("ConditionsSlice", + "manage_condition: Failed to register condition %016llx according to IOV:%s.", + condition->hash, pool->validity().str().c_str()); } } if ( flg®ISTER_POOL ) { ret = pool->insert(condition); if ( !ret ) { - dd4hep::except("ConditionsSlice", - "manage_condition: Failed to register condition %016llx to user pool with IOV:%s.", - condition->hash, pool->validity().str().c_str()); + except("ConditionsSlice", + "manage_condition: Failed to register condition %016llx to user pool with IOV:%s.", + condition->hash, pool->validity().str().c_str()); } } return ret; } - dd4hep::except("ConditionsSlice", - "manage_condition: Cannot manage invalid condition!"); + except("ConditionsSlice", + "manage_condition: Cannot manage invalid condition!"); return false; } @@ -107,14 +105,14 @@ bool ConditionsSlice::manage(Condition condition, ManageFlag flg) { } /// Access all conditions from a given detector element -vector ConditionsSlice::get(DetElement detector) const { +std::vector ConditionsSlice::get(DetElement detector) const { return pool->get(detector,FIRST_ITEM,LAST_ITEM); } /// No ConditionsMap overload: Access all conditions within a key range in the interval [lower,upper] -vector ConditionsSlice::get(DetElement detector, - Condition::itemkey_type lower, - Condition::itemkey_type upper) const { +std::vector ConditionsSlice::get(DetElement detector, + Condition::itemkey_type lower, + Condition::itemkey_type upper) const { return pool->get(detector, lower, upper); } @@ -123,25 +121,25 @@ bool ConditionsSlice::insert(DetElement detector, Condition::itemkey_type key, C if ( condition.isValid() ) { ConditionsPool* p = manager.registerIOV(pool->validity()); if ( !p ) { - dd4hep::except("ConditionsSlice", - "manage_condition: Cannot access conditions pool according to IOV:%s.", - pool->validity().str().c_str()); + except("ConditionsSlice", + "manage_condition: Cannot access conditions pool according to IOV:%s.", + pool->validity().str().c_str()); } bool ret = manager.registerUnlocked(*p,condition); if ( !ret ) { - dd4hep::except("ConditionsSlice", - "manage_condition: Failed to register condition %016llx according to IOV:%s.", - condition->hash, pool->validity().str().c_str()); + except("ConditionsSlice", + "manage_condition: Failed to register condition %016llx according to IOV:%s.", + condition->hash, pool->validity().str().c_str()); } return pool->insert(detector, key, condition); } - dd4hep::except("ConditionsSlice", - "insert_condition: Cannot insert invalid condition to the user pool!"); + except("ConditionsSlice", + "insert_condition: Cannot insert invalid condition to the user pool!"); return false; } /// ConditionsMap overload: Access a condition -Condition ConditionsSlice::get(DetElement detector, Condition::itemkey_type key) const { +dd4hep::Condition ConditionsSlice::get(DetElement detector, Condition::itemkey_type key) const { return pool->get(detector, key); } @@ -160,14 +158,14 @@ void ConditionsSlice::scan(DetElement detector, namespace { - struct SliceOper : public ConditionsSelect { + struct SliceOper : public dd4hep::ConditionsSelect { ConditionsContent& content; SliceOper(ConditionsContent& c) : content(c) {} void operator()(const ConditionsIOVPool::Elements::value_type& v) { v.second->select_all(*this); } - bool operator()(Condition::Object* c) const { - if ( 0 == (c->flags&Condition::DERIVED) ) { + bool operator()(dd4hep::Condition::Object* c) const { + if ( 0 == (c->flags&dd4hep::Condition::DERIVED) ) { #if !defined(DD4HEP_MINIMAL_CONDITIONS) content.addLocation(c->hash,c->address); #endif diff --git a/DDCond/src/ConditionsTextRepository.cpp b/DDCond/src/ConditionsTextRepository.cpp index cad11d8cd..73967f410 100644 --- a/DDCond/src/ConditionsTextRepository.cpp +++ b/DDCond/src/ConditionsTextRepository.cpp @@ -27,15 +27,14 @@ #include #include -using namespace std; -using namespace dd4hep; using namespace dd4hep::cond; -typedef xml::Handle_t xml_h; -typedef xml::Element xml_elt_t; -typedef xml::Document xml_doc_t; -typedef xml::Collection_t xml_coll_t; -typedef map AllConditions; +typedef dd4hep::xml::Handle_t xml_h; +typedef dd4hep::xml::Element xml_elt_t; +typedef dd4hep::xml::Document xml_doc_t; +typedef dd4hep::xml::Collection_t xml_coll_t; + +typedef std::map AllConditions; /// Default constructor. Allocates resources ConditionsTextRepository::ConditionsTextRepository() { @@ -47,7 +46,7 @@ ConditionsTextRepository::~ConditionsTextRepository() { namespace { - int createXML(const string& output, const AllConditions& all) { + int createXML(const std::string& output, const AllConditions& all) { char text[32]; const char comment[] = "\n" " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" @@ -69,7 +68,7 @@ namespace { cond.setAttr(_U(ref), c.second.address()); #endif } - printout(ALWAYS,"ConditionsRepository","++ Handled %ld conditions.",all.size()); + dd4hep::printout(dd4hep::ALWAYS,"ConditionsRepository","++ Handled %ld conditions.",all.size()); if ( !output.empty() ) { return docH.output(doc, output); } @@ -77,7 +76,7 @@ namespace { } /// Load the repository from file and fill user passed data structory - int readXML(const string& input, ConditionsTextRepository::Data& data) { + int readXML(const std::string& input, ConditionsTextRepository::Data& data) { struct Conv { /// Reference to optional user defined parameter ConditionsTextRepository::Data& data; @@ -85,45 +84,45 @@ namespace { Conv(ConditionsTextRepository::Data& p) : data(p) {} /// Callback operator to be specialized depending on the element type void operator()(xml_h element) const { - string key = element.attr(_U(key)); + std::string key = element.attr(_U(key)); size_t cap = data.capacity(); ConditionsTextRepository::Entry e; ::sscanf(key.c_str(),"0x%16llX",&e.key); - e.name = element.attr(_U(name)); - e.address = element.attr(_U(ref)); + e.name = element.attr(_U(name)); + e.address = element.attr(_U(ref)); if ( data.size() == cap ) data.reserve(cap+500); data.emplace_back(e); } }; - xml::DocumentHolder doc(xml::DocumentHandler().load(input)); + dd4hep::xml::DocumentHolder doc(dd4hep::xml::DocumentHandler().load(input)); xml_h root = doc.root(); xml_coll_t(root, _U(ref)).for_each(Conv(data)); return 1; } #if defined(DD4HEP_MINIMAL_CONDITIONS) - int createText(const string& output, const AllConditions&, char) + int createText(const std::string& output, const AllConditions&, char) #else - int createText(const string& output, const AllConditions& all, char sep) + int createText(const std::string& output, const AllConditions& all, char sep) #endif { - ofstream out(output); + std::ofstream out(output); #if !defined(DD4HEP_MINIMAL_CONDITIONS) - size_t siz_nam=0, siz_add=0, siz_tot=0; + std::size_t siz_nam=0, siz_add=0, siz_tot=0; char fmt[64], text[2*PATH_MAX+64]; if ( !out.good() ) { - except("ConditionsTextRepository", - "++ Failed to open output file:%s [errno:%d %s]", - output.c_str(), errno, ::strerror(errno)); + dd4hep::except("ConditionsTextRepository", + "++ Failed to open output file:%s [errno:%d %s]", + output.c_str(), errno, ::strerror(errno)); } else if ( sep ) { - ::snprintf(fmt,sizeof(fmt),"%%16llX%c%%s%c%%s%c",sep,sep,sep); + std::snprintf(fmt,sizeof(fmt),"%%16llX%c%%s%c%%s%c",sep,sep,sep); } else { for( const auto& i : all ) { - Condition::Object* c = i.second.ptr(); - size_t siz_n = c->name.length(); - size_t siz_a = c->address.length(); + dd4hep::Condition::Object* c = i.second.ptr(); + std::size_t siz_n = c->name.length(); + std::size_t siz_a = c->address.length(); if ( siz_add < siz_a ) siz_add = siz_a; if ( siz_nam < siz_n ) siz_nam = siz_n; if ( siz_tot < (siz_n+siz_a) ) siz_tot = siz_n+siz_a; @@ -134,11 +133,11 @@ namespace { out << "dd4hep." << char(sep ? sep : '-') << "." << long(siz_nam) << "." << long(siz_add) - << "." << long(siz_tot) << endl; + << "." << long(siz_tot) << std::endl; for( const auto& i : all ) { - Condition c = i.second; - ::snprintf(text, sizeof(text), fmt, c.key(), c.name(), c.address().c_str()); - out << text << endl; + dd4hep::Condition c = i.second; + std::snprintf(text, sizeof(text), fmt, c.key(), c.name(), c.address().c_str()); + out << text << std::endl; } #endif out.close(); @@ -146,12 +145,12 @@ namespace { } /// Load the repository from file and fill user passed data structory - int readText(const string& input, ConditionsTextRepository::Data& data) { - size_t idx; + int readText(const std::string& input, ConditionsTextRepository::Data& data) { + std::size_t idx; ConditionsTextRepository::Entry e; - size_t siz_nam, siz_add, siz_tot; + std::size_t siz_nam, siz_add, siz_tot; char sep, c, text[2*PATH_MAX+64]; - ifstream in(input); + std::ifstream in(input); in >> c >> c >> c >> c >> c >> c >> c >> sep >> c >> siz_nam >> c >> siz_add @@ -162,36 +161,36 @@ namespace { text[0] = 0; in.getline(text,sizeof(text),'\n'); if ( in.good() ) { - size_t idx_nam = 9+siz_nam= sizeof(text) ) - except("ConditionsTextRepository","Inconsistent input data in %s: %s -> (%lld,%lld,%lld)", - __FILE__, input.c_str(), siz_nam, siz_add, siz_tot); + dd4hep::except("ConditionsTextRepository","Inconsistent input data in %s: %s -> (%lld,%lld,%lld)", + __FILE__, input.c_str(), siz_nam, siz_add, siz_tot); else if ( 10+siz_nam+siz_add >= sizeof(text) ) - except("ConditionsTextRepository","Inconsistent input data in %s: %s -> (%lld,%lld,%lld)", - __FILE__, input.c_str(), siz_nam, siz_add, siz_tot); + dd4hep::except("ConditionsTextRepository","Inconsistent input data in %s: %s -> (%lld,%lld,%lld)", + __FILE__, input.c_str(), siz_nam, siz_add, siz_tot); else if ( siz_tot ) { // Direct access mode with fixed record size text[8] = text[idx_nam] = text[idx_add] = 0; e.name = text+9; e.address = text+idx_nam+1; - if ( (idx=e.name.find(' ')) != string::npos ) + if ( (idx=e.name.find(' ')) != std::string::npos ) e.name[idx]=0; - if ( (idx=e.address.find(' ')) != string::npos ) + if ( (idx=e.address.find(' ')) != std::string::npos ) e.address[idx]=0; } else { // Variable record size e.name=text+9; - if ( (idx=e.name.find(sep)) != string::npos && idx+10 < sizeof(text) ) + if ( (idx=e.name.find(sep)) != std::string::npos && idx+10 < sizeof(text) ) text[9+idx]=0, e.address=text+idx+10, e.name=text+9; - if ( (idx=e.address.find(sep)) != string::npos ) + if ( (idx=e.address.find(sep)) != std::string::npos ) e.address[idx]=0; - else if ( (idx=e.address.find('\n')) != string::npos ) + else if ( (idx=e.address.find('\n')) != std::string::npos ) e.address[idx]=0; } - size_t cap = data.capacity(); - ::sscanf(text,"%16llX",&e.key); + std::size_t cap = data.capacity(); + std::sscanf(text,"%16llX",&e.key); if ( data.size() == cap ) data.reserve(cap+500); data.emplace_back(e); } @@ -202,7 +201,7 @@ namespace { } /// Save the repository to file -int ConditionsTextRepository::save(ConditionsManager manager, const string& output) const { +int ConditionsTextRepository::save(ConditionsManager manager, const std::string& output) const { AllConditions all; const auto types = manager.iovTypesUsed(); for( const IOVType* type : types ) { @@ -219,19 +218,19 @@ int ConditionsTextRepository::save(ConditionsManager manager, const string& outp } } - if ( output.find(".xml") != string::npos ) { + if ( output.find(".xml") != std::string::npos ) { /// Write XML file with conditions addresses return createXML(output, all); } - else if ( output.find(".txt") != string::npos ) { + else if ( output.find(".txt") != std::string::npos ) { /// Write fixed records with conditions addresses return createText(output, all, 0); } - else if ( output.find(".daf") != string::npos ) { + else if ( output.find(".daf") != std::string::npos ) { /// Write fixed records with conditions addresses return createText(output, all, 0); } - else if ( output.find(".csv") != string::npos ) { + else if ( output.find(".csv") != std::string::npos ) { /// Write records separated by ';' with conditions addresses return createText(output, all, ';'); } @@ -239,17 +238,17 @@ int ConditionsTextRepository::save(ConditionsManager manager, const string& outp } /// Load the repository from file and fill user passed data structory -int ConditionsTextRepository::load(const string& input, Data& data) const { - if ( input.find(".xml") != string::npos ) { +int ConditionsTextRepository::load(const std::string& input, Data& data) const { + if ( input.find(".xml") != std::string::npos ) { return readXML(input, data); } - else if ( input.find(".txt") != string::npos ) { + else if ( input.find(".txt") != std::string::npos ) { return readText(input, data); } - else if ( input.find(".daf") != string::npos ) { + else if ( input.find(".daf") != std::string::npos ) { return readText(input, data); } - else if ( input.find(".csv") != string::npos ) { + else if ( input.find(".csv") != std::string::npos ) { return readText(input, data); } return 0; diff --git a/DDCond/src/ConditionsTreePersistency.cpp b/DDCond/src/ConditionsTreePersistency.cpp index 9d8311d1d..033103be3 100644 --- a/DDCond/src/ConditionsTreePersistency.cpp +++ b/DDCond/src/ConditionsTreePersistency.cpp @@ -12,21 +12,18 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DDCond/ConditionsSlice.h" -#include "DDCond/ConditionsIOVPool.h" -#include "DDCond/ConditionsTreePersistency.h" +#include +#include +#include +#include -#include "TFile.h" -#include "TTimeStamp.h" +#include +#include typedef dd4hep::cond::ConditionsTreePersistency __ConditionsTreePersistency; /// ROOT Class implementation directive ClassImp(__ConditionsTreePersistency) - -using namespace std; -using namespace dd4hep; using namespace dd4hep::cond; // Local namespace for anonymous stuff @@ -38,12 +35,12 @@ namespace { * \version 1.0 * \ingroup DD4HEP_CONDITIONS */ - struct Scanner : public Condition::Processor { + struct Scanner : public dd4hep::Condition::Processor { ConditionsTreePersistency::pool_type& pool; /// Constructor Scanner(ConditionsTreePersistency::pool_type& p) : pool(p) {} /// Conditions callback for object processing - virtual int process(Condition c) const override { + virtual int process(dd4hep::Condition c) const override { pool.emplace_back(c.ptr()); return 1; } @@ -65,7 +62,7 @@ ConditionsTreePersistency::ConditionsTreePersistency() : TNamed() { } /// Initializing constructor -ConditionsTreePersistency::ConditionsTreePersistency(const string& name, const string& title) +ConditionsTreePersistency::ConditionsTreePersistency(const std::string& name, const std::string& title) : TNamed(name.c_str(), title.c_str()) { } @@ -76,11 +73,12 @@ ConditionsTreePersistency::~ConditionsTreePersistency() { } /// Add conditions content to be saved. Note, that dependent conditions shall not be saved! -size_t ConditionsTreePersistency::add(const std::string& identifier, - const IOV& iov, - std::vector& conditions) { +std::size_t ConditionsTreePersistency::add(const std::string& identifier, + const IOV& iov, + std::vector& conditions) +{ DurationStamp stamp(this); - conditionPools.emplace_back(pair()); + conditionPools.emplace_back(std::pair()); pool_type& ent = conditionPools.back().second; iov_key_type& key = conditionPools.back().first; key.first = identifier; @@ -92,9 +90,9 @@ size_t ConditionsTreePersistency::add(const std::string& identifier, } /// Add conditions content to the saved. Note, that dependent conditions shall not be saved! -size_t ConditionsTreePersistency::add(const string& identifier, ConditionsPool& pool) { +std::size_t ConditionsTreePersistency::add(const std::string& identifier, ConditionsPool& pool) { DurationStamp stamp(this); - conditionPools.emplace_back(pair()); + conditionPools.emplace_back(std::pair()); pool_type& ent = conditionPools.back().second; iov_key_type& key = conditionPools.back().first; const IOV* iov = pool.iov; @@ -107,11 +105,11 @@ size_t ConditionsTreePersistency::add(const string& identifier, ConditionsPool& } /// Add conditions content to the saved. Note, that dependent conditions shall not be saved! -size_t ConditionsTreePersistency::add(const string& identifier, const ConditionsIOVPool& pool) { - size_t count = 0; +std::size_t ConditionsTreePersistency::add(const std::string& identifier, const ConditionsIOVPool& pool) { + std::size_t count = 0; DurationStamp stamp(this); for( const auto& p : pool.elements ) { - iovPools.emplace_back(pair()); + iovPools.emplace_back(std::pair()); pool_type& ent = iovPools.back().second; iov_key_type& key = iovPools.back().first; const IOV* iov = p.second->iov; @@ -126,7 +124,7 @@ size_t ConditionsTreePersistency::add(const string& identifier, const Conditions } /// Open ROOT file in read mode -TFile* ConditionsTreePersistency::openFile(const string& fname) { +TFile* ConditionsTreePersistency::openFile(const std::string& fname) { TDirectory::TContext context; TFile* file = TFile::Open(fname.c_str()); if ( file && !file->IsZombie()) return file; @@ -154,7 +152,7 @@ void ConditionsTreePersistency::clear() { /// Add conditions content to the saved. Note, that dependent conditions shall not be saved! std::unique_ptr -ConditionsTreePersistency::load(TFile* file,const string& obj) { +ConditionsTreePersistency::load(TFile* file,const std::string& obj) { std::unique_ptr p; if ( file && !file->IsZombie()) { TTimeStamp start; @@ -174,13 +172,14 @@ ConditionsTreePersistency::load(TFile* file,const string& obj) { } /// Load ConditionsPool(s) and populate conditions manager -size_t ConditionsTreePersistency::_import(ImportStrategy strategy, - persistent_type& persistent_pools, - const std::string& id, - const std::string& iov_type, - const IOV::Key& iov_key, - ConditionsManager mgr) { - size_t count = 0; +std::size_t ConditionsTreePersistency::_import(ImportStrategy strategy, + persistent_type& persistent_pools, + const std::string& id, + const std::string& iov_type, + const IOV::Key& iov_key, + ConditionsManager mgr) +{ + std::size_t count = 0; std::pair iovTyp(false,0); for (auto& iovp : persistent_pools ) { bool use = false; @@ -243,29 +242,29 @@ size_t ConditionsTreePersistency::_import(ImportStrategy strategy, } /// Load ConditionsIOVPool and populate conditions manager -size_t ConditionsTreePersistency::importIOVPool(const std::string& identifier, - const std::string& iov_type, - ConditionsManager mgr) +std::size_t ConditionsTreePersistency::importIOVPool(const std::string& identifier, + const std::string& iov_type, + ConditionsManager mgr) { DurationStamp stamp(this); return _import(IMPORT_ALL,iovPools,identifier,iov_type,IOV::Key(),mgr); } /// Load ConditionsIOVPool and populate conditions manager -size_t ConditionsTreePersistency::importConditionsPool(const std::string& identifier, - const std::string& iov_type, - ConditionsManager mgr) +std::size_t ConditionsTreePersistency::importConditionsPool(const std::string& identifier, + const std::string& iov_type, + ConditionsManager mgr) { DurationStamp stamp(this); return _import(IMPORT_ALL,conditionPools,identifier,iov_type,IOV::Key(),mgr); } /// Load conditions pool and populate conditions manager. Allow tro be selective also for the key -size_t ConditionsTreePersistency::importConditionsPool(ImportStrategy strategy, - const std::string& identifier, - const std::string& iov_type, - const IOV::Key& iov_key, - ConditionsManager mgr) { +std::size_t ConditionsTreePersistency::importConditionsPool(ImportStrategy strategy, + const std::string& identifier, + const std::string& iov_type, + const IOV::Key& iov_key, + ConditionsManager mgr) { return _import(strategy,conditionPools,identifier,iov_type,iov_key,mgr); } @@ -278,7 +277,7 @@ int ConditionsTreePersistency::save(TFile* file) { } /// Save the data content to a root file -int ConditionsTreePersistency::save(const string& fname) { +int ConditionsTreePersistency::save(const std::string& fname) { DurationStamp stamp(this); //TDirectory::TContext context; TFile* file = TFile::Open(fname.c_str(),"RECREATE"); diff --git a/DDCond/src/Type1/Manager_Type1.cpp b/DDCond/src/Type1/Manager_Type1.cpp index 5b5081e46..a15ecf23c 100644 --- a/DDCond/src/Type1/Manager_Type1.cpp +++ b/DDCond/src/Type1/Manager_Type1.cpp @@ -12,38 +12,36 @@ //========================================================================== // Framework include files -#include "DDCond/Type1/Manager_Type1.h" - -#include "DD4hep/Detector.h" -#include "DD4hep/World.h" -#include "DD4hep/Errors.h" -#include "DD4hep/Plugins.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Factories.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/PluginCreators.h" -#include "DD4hep/ConditionsListener.h" -#include "DD4hep/detail/Handle.inl" -#include "DD4hep/detail/DetectorInterna.h" -#include "DD4hep/detail/ConditionsInterna.h" - -#include "DDCond/ConditionsPool.h" -#include "DDCond/ConditionsEntry.h" -#include "DDCond/ConditionsCleanup.h" -#include "DDCond/ConditionsManager.h" -#include "DDCond/ConditionsIOVPool.h" -#include "DDCond/ConditionsDataLoader.h" - -using namespace std; -using namespace dd4hep; +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + using namespace dd4hep::cond; typedef UpdatePool::UpdateEntries Updates; -typedef RangeConditions RC; +typedef dd4hep::RangeConditions RC; DD4HEP_INSTANTIATE_HANDLE_NAMED(Manager_Type1); -static void* ddcond_create_manager_instance(Detector& description, int, char**) { +static void* ddcond_create_manager_instance(dd4hep::Detector& description, int, char**) { return (ConditionsManagerObject*)new Manager_Type1(description); } DECLARE_DD4HEP_CONSTRUCTOR(DD4hep_ConditionsManager_Type1,ddcond_create_manager_instance) @@ -54,15 +52,15 @@ namespace { struct Range {}; struct Discrete {}; - int s_debug = INFO; + int s_debug = dd4hep::INFO; /// Helper: IOV Check function declaration - template const IOVType* check_iov_type(const Manager_Type1* o, const IOV* iov); + template const dd4hep::IOVType* check_iov_type(const Manager_Type1* o, const dd4hep::IOV* iov); /// Helper: Specialized IOV check - template <> const IOVType* check_iov_type(const Manager_Type1* o, const IOV* iov) { + template <> const dd4hep::IOVType* check_iov_type(const Manager_Type1* o, const dd4hep::IOV* iov) { if ( iov ) { - const IOVType* typ = iov->iovType ? iov->iovType : o->iovType(iov->type); + const dd4hep::IOVType* typ = iov->iovType ? iov->iovType : o->iovType(iov->type); if ( typ ) { if ( iov->type == typ->type ) { if ( typ->type < o->m_rawPool.size() ) { @@ -77,45 +75,45 @@ namespace { } /// Helper: Specialized IOV check for discrete IOV values - template <> const IOVType* check_iov_type(const Manager_Type1* o, const IOV* iov) { - const IOVType* typ = check_iov_type(o,iov); + template <> const dd4hep::IOVType* check_iov_type(const Manager_Type1* o, const dd4hep::IOV* iov) { + const dd4hep::IOVType* typ = check_iov_type(o,iov); if ( typ && !iov->has_range() ) return typ; return 0; } #if 0 /// Helper: Specialized IOV check for range IOV values - template <> const IOVType* check_iov_type(const Manager_Type1* o, const IOV* iov) { - const IOVType* typ = check_iov_type(o,iov); + template <> const dd4hep::IOVType* check_iov_type(const Manager_Type1* o, const dd4hep::IOV* iov) { + const dd4hep::IOVType* typ = check_iov_type(o,iov); if ( typ && iov->has_range() ) return typ; return 0; } #endif /// Helper: Check conditions result for consistency - template void __check_values__(const Manager_Type1* o, Condition::key_type key, const IOV* iov) + template void __check_values__(const Manager_Type1* o, dd4hep::Condition::key_type key, const dd4hep::IOV* iov) { if ( !iov ) { - except("ConditionsMgr","+++ Invalid IOV to access condition: %16llX. [Null-reference]",key); + dd4hep::except("ConditionsMgr","+++ Invalid IOV to access condition: %16llX. [Null-reference]",key); } - const IOVType* typ = check_iov_type(o,iov); + const dd4hep::IOVType* typ = check_iov_type(o,iov); if ( !typ ) { // Severe: We have an unknown IOV type. This is not allowed, // because we do not known hot to handle it..... - except("ConditionsMgr","+++ Invalid IOV type [%d] to access condition: %16llX.", - iov->type, key); + dd4hep::except("ConditionsMgr","+++ Invalid IOV type [%d] to access condition: %16llX.", + iov->type, key); } } /// Helper: Check if the conditions range covers the entire IOV span - bool is_range_complete(const IOV& iov, const RC& conditions) { + bool is_range_complete(const dd4hep::IOV& iov, const RC& conditions) { if ( !conditions.empty() ) { // We need to check if the entire range is covered. // For every key.second we must find a key.first, which is at least as big - IOV::Key test=iov.keyData; + dd4hep::IOV::Key test=iov.keyData; // The range may be returned unordered. Hence, // we have to try to match at most conditions.size() times until we really know - for(size_t j = 0; j < conditions.size(); ++j ) { + for( std::size_t j = 0; j < conditions.size(); ++j ) { for(const auto& cond : conditions ) { - const IOV::Key& k = cond->iov->key(); + const dd4hep::IOV::Key& k = cond->iov->key(); if ( k.first <= test.first+1 && k.second >= test.first ) test.first = k.second; if ( k.first+1 <= test.second && k.second >= test.second ) test.second = k.first; //printout(INFO,"Test","IOV: %ld,%ld --> %ld,%ld",k.first,k.second, test.first, test.second); @@ -128,7 +126,7 @@ namespace { } template - void __callListeners(const Manager_Type1::Listeners& listeners, PMF pmf, Condition& cond) { + void __callListeners(const Manager_Type1::Listeners& listeners, PMF pmf, dd4hep::Condition& cond) { for(const auto& listener : listeners ) (listener.first->*pmf)(cond, listener.second); } @@ -157,7 +155,7 @@ Manager_Type1::~Manager_Type1() { void Manager_Type1::initialize() { if ( !m_updatePool.get() ) { - string typ = m_loaderType; + std::string typ = m_loaderType; const void* argv_loader[] = {"ConditionsDataLoader", this, 0}; const void* argv_pool[] = {this, 0, 0}; m_loader.reset(createPlugin(typ,m_detDesc,2,argv_loader)); @@ -173,13 +171,14 @@ void Manager_Type1::initialize() { } /// Register new IOV type if it does not (yet) exist. -pair Manager_Type1::registerIOVType(size_t iov_index, const string& iov_name) { +std::pair +Manager_Type1::registerIOVType(std::size_t iov_index, const std::string& iov_name) { if ( iov_index Manager_Type1::registerIOVType(size_t iov_index, cons typ.name = iov_name; typ.type = iov_index; m_rawPool[typ.type] = new ConditionsIOVPool(&typ); - return make_pair(true,&typ); + return { true, &typ }; } except("ConditionsMgr","Cannot register IOV section %d of type %d. Value out of bounds: [%d,%d]", iov_name.c_str(), iov_index, 0, int(m_iovTypes.size())); - return make_pair(false,(IOVType*)0); + return { false, nullptr }; } /// Access IOV by its type -const IOVType* Manager_Type1::iovType (size_t iov_index) const { +const dd4hep::IOVType* Manager_Type1::iovType (size_t iov_index) const { if ( iov_indextype = typ.type; iov->keyData = key; const void* argv_pool[] = {this, iov, 0}; - shared_ptr cond_pool(createPlugin(m_poolType,m_detDesc,2,argv_pool)); + std::shared_ptr cond_pool(createPlugin(m_poolType,m_detDesc,2,argv_pool)); pool->elements.emplace(key,cond_pool); printout(INFO,"ConditionsMgr","Created IOV Pool for:%s",iov->str().c_str()); return cond_pool.get(); @@ -268,16 +267,13 @@ bool Manager_Type1::registerUnlocked(ConditionsPool& pool, Condition cond) { } /// Register a whole block of conditions with identical IOV. -size_t Manager_Type1::blockRegister(ConditionsPool& pool, const vector& cond) const { - size_t result = 0; - //string typ; +std::size_t Manager_Type1::blockRegister(ConditionsPool& pool, const std::vector& cond) const { + std::size_t result = 0; for(auto c : cond) { if ( c.isValid() ) { c->iov = pool.iov; c->setFlag(Condition::ACTIVE); pool.insert(c); - //typ = typeName(typeid(*(c.ptr()))); - //if ( typ.find("Static") != string::npos ) cout << "++Insert: " << typ << endl; if ( !m_onRegister.empty() ) { __callListeners(m_onRegister, &ConditionsListener::onRegisterCondition, c); } @@ -293,7 +289,7 @@ size_t Manager_Type1::blockRegister(ConditionsPool& pool, const vectorConditionsManagerObject::registerIOV(e->validity); Condition condition(e->name,e->type); @@ -360,8 +356,8 @@ int Manager_Type1::clean(const IOVType* typ, int max_age) { } /// Invoke cache cleanup with user defined policy -pair Manager_Type1::clean(const ConditionsCleanup& cleaner) { - pair count(0,0); +std::pair Manager_Type1::clean(const ConditionsCleanup& cleaner) { + std::pair count(0,0); for( TypedConditionPool::iterator i=m_rawPool.begin(); i != m_rawPool.end(); ++i) { ConditionsIOVPool* p = *i; if ( p && cleaner(*p) ) { @@ -373,8 +369,8 @@ pair Manager_Type1::clean(const ConditionsCleanup& cleaner) { } /// Full cleanup of all managed conditions. -pair Manager_Type1::clear() { - pair count(0,0); +std::pair Manager_Type1::clear() { + std::pair count(0,0); for( TypedConditionPool::iterator i=m_rawPool.begin(); i != m_rawPool.end(); ++i) { ConditionsIOVPool* p = *i; if ( p ) { diff --git a/DDCond/src/plugins/ConditionsLinearPool.cpp b/DDCond/src/plugins/ConditionsLinearPool.cpp index 3dbe032de..4f35ba93d 100644 --- a/DDCond/src/plugins/ConditionsLinearPool.cpp +++ b/DDCond/src/plugins/ConditionsLinearPool.cpp @@ -14,11 +14,11 @@ #define DDCOND_CONDITIONSLINEARPOOL_H // Framework include files -#include "DDCond/ConditionsPool.h" -#include "DDCond/ConditionsManager.h" -#include "DDCond/ConditionsSelectors.h" +#include +#include +#include -#include "DD4hep/Printout.h" +#include // C/C++ include files #include @@ -185,10 +185,9 @@ namespace dd4hep { //========================================================================== // Framework include files -//#include "DDCond/ConditionsLinearPool.h" -#include "DD4hep/InstanceCount.h" +//#include +#include -using dd4hep::Handle; using namespace dd4hep::cond; /// Default constructor @@ -196,7 +195,6 @@ template ConditionsLinearPool::ConditionsLinearPool(ConditionsManager mgr, IOV* i) : BASE(mgr, i) { - this->BASE::SetName(i ? i->str().c_str() : "Unknown IOV"); this->BASE::SetTitle("ConditionsLinearPool"); InstanceCount::increment(this); @@ -219,10 +217,8 @@ namespace dd4hep { } /* End namespace cond */ } /* End namespace dd4hep */ -#include "DD4hep/Factories.h" +#include namespace { - using namespace dd4hep; - ConditionsManager _mgr(int argc, char** argv) { if ( argc > 0 ) { ConditionsManager::Object* m = (ConditionsManager::Object*)argv[0]; @@ -231,9 +227,9 @@ namespace { dd4hep::except("ConditionsLinearPool","++ Insufficient arguments: arg[0] = ConditionManager!"); return ConditionsManager(0); } - IOV* _iov(int argc, char** argv) { + dd4hep::IOV* _iov(int argc, char** argv) { if ( argc > 1 ) { - IOV* i = (IOV*)argv[1]; + dd4hep::IOV* i = (dd4hep::IOV*)argv[1]; return i; } dd4hep::except("ConditionsLinearPool","++ Insufficient arguments: arg[1] = IOV!"); @@ -241,7 +237,7 @@ namespace { } #define _CR(fun,x,b,y) void* fun(dd4hep::Detector&, int argc, char** argv) \ - { return new b,y>(_mgr(argc,argv), _iov(argc,argv)); } + { return new b,y>(_mgr(argc,argv), _iov(argc,argv)); } /// Create a conditions pool based on STL vectors _CR(create_vector_pool,std::vector,ConditionsLinearPool,ConditionsPool) /// Create a conditions pool based on STL lists diff --git a/DDCond/src/plugins/ConditionsMappedPool.cpp b/DDCond/src/plugins/ConditionsMappedPool.cpp index d1d1a262a..ee8f26759 100644 --- a/DDCond/src/plugins/ConditionsMappedPool.cpp +++ b/DDCond/src/plugins/ConditionsMappedPool.cpp @@ -14,11 +14,11 @@ #define DDCOND_CONDITIONSMAPPEDPOOL_H // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/detail/ConditionsInterna.h" +#include +#include -#include "DDCond/ConditionsPool.h" -#include "DDCond/ConditionsSelectors.h" +#include +#include // C/C++ include files #include @@ -54,7 +54,7 @@ namespace dd4hep { Mapping m_entries; /// Helper function to loop over the conditions container and apply a functor - template size_t loop(R& result, T functor) { + template std::size_t loop(R& result, T functor) { size_t len = result.size(); for_each(m_entries.begin(),m_entries.end(),functor); return result.size() - len; @@ -198,8 +198,8 @@ namespace dd4hep { //========================================================================== // Framework include files -//#include "DDCond/ConditionsMappedPool.h" -#include "DD4hep/InstanceCount.h" +//#include +#include using dd4hep::Handle; using namespace dd4hep::cond; @@ -219,9 +219,8 @@ ConditionsMappedPool::~ConditionsMappedPool() { InstanceCount::decrement(this); } -#include "DD4hep/Factories.h" +#include namespace { - using namespace dd4hep; ConditionsManager _mgr(int argc, char** argv) { if ( argc > 0 ) { ConditionsManagerObject* m = (ConditionsManagerObject*)argv[0]; @@ -231,7 +230,7 @@ namespace { return ConditionsManager(0); } #define _CR(fun,x,b,y) void* fun(dd4hep::Detector&, int argc, char** argv) \ - { return new b,y>(_mgr(argc,argv)); } + { return new b,y>(_mgr(argc,argv)); } /// Create a conditions pool based on STL maps _CR(create_map_pool,std::map,ConditionsMappedPool,ConditionsPool) diff --git a/DDCond/src/plugins/ConditionsMultiLoader.cpp b/DDCond/src/plugins/ConditionsMultiLoader.cpp index c4ae170b8..14b09d54f 100644 --- a/DDCond/src/plugins/ConditionsMultiLoader.cpp +++ b/DDCond/src/plugins/ConditionsMultiLoader.cpp @@ -16,8 +16,8 @@ #define DD4HEP_CONDITIONS_MULTICONDITONSLOADER_H // Framework include files -#include "DDCond/ConditionsDataLoader.h" -#include "DD4hep/Printout.h" +#include +#include /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -86,14 +86,13 @@ namespace dd4hep { //========================================================================== // Framework include files -//#include "ConditionsMultiLoader.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Factories.h" -#include "DD4hep/PluginCreators.h" -#include "DDCond/ConditionsManager.h" +//#include +#include +#include +#include +#include // Forward declartions -using std::string; using namespace dd4hep::cond; namespace { @@ -106,7 +105,7 @@ namespace { DECLARE_DD4HEP_CONSTRUCTOR(DD4hep_Conditions_multi_Loader,create_loader) /// Standard constructor, initializes variables -ConditionsMultiLoader::ConditionsMultiLoader(Detector& description, ConditionsManager mgr, const string& nam) +ConditionsMultiLoader::ConditionsMultiLoader(Detector& description, ConditionsManager mgr, const std::string& nam) : ConditionsDataLoader(description, mgr, nam) { } @@ -122,15 +121,15 @@ ConditionsMultiLoader::load_source(const std::string& nam, OpenSources::iterator iop = m_openSources.find(nam); if ( iop == m_openSources.end() ) { size_t idx = nam.find(':'); - if ( idx == string::npos ) { + if ( idx == std::string::npos ) { except("ConditionsMultiLoader","Invalid data source specification: "+nam); } - string ident = nam.substr(0,idx); + std::string ident = nam.substr(0,idx); Loaders::iterator ild = m_loaders.find(ident); ConditionsDataLoader* loader = 0; if ( ild == m_loaders.end() ) { - string typ = "DD4hep_Conditions_"+ident+"_Loader"; - string fac = ident+"_ConditionsDataLoader"; + std::string typ = "DD4hep_Conditions_"+ident+"_Loader"; + std::string fac = ident+"_ConditionsDataLoader"; const void* argv[] = {fac.c_str(), m_mgr.ptr(), 0}; loader = createPlugin(typ,m_detector,2,argv); if ( !loader ) { @@ -160,7 +159,7 @@ size_t ConditionsMultiLoader::load_range(key_type key, const IOV& iov = (*i).second; if ( iov.type == req_validity.type ) { if ( IOV::key_partially_contained(iov.keyData,req_validity.keyData) ) { - const string& nam = (*i).first; + const std::string& nam = (*i).first; ConditionsDataLoader* loader = load_source(nam, req_validity); loader->load_range(key, req_validity, conditions); } @@ -180,7 +179,7 @@ size_t ConditionsMultiLoader::load_single(key_type key, const IOV& iov = (*i).second; if ( iov.type == req_validity.type ) { if ( IOV::key_partially_contained(iov.keyData,req_validity.keyData) ) { - const string& nam = (*i).first; + const std::string& nam = (*i).first; ConditionsDataLoader* loader = load_source(nam, req_validity); loader->load_single(key, req_validity, conditions); } diff --git a/DDCond/src/plugins/ConditionsParser.cpp b/DDCond/src/plugins/ConditionsParser.cpp index 223ed360b..4b13dd692 100644 --- a/DDCond/src/plugins/ConditionsParser.cpp +++ b/DDCond/src/plugins/ConditionsParser.cpp @@ -12,22 +12,20 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "XML/Conversions.h" -#include "XML/XMLElements.h" -#include "XML/DocumentHandler.h" -#include "DD4hep/Printout.h" -#include "DD4hep/DetectorTools.h" -#include "DD4hep/DetFactoryHelper.h" +#include +#include +#include +#include +#include +#include +#include -#include "DDCond/ConditionsTags.h" -#include "DDCond/ConditionsEntry.h" -#include "DDCond/ConditionsManager.h" -#include "DDCond/ConditionsDataLoader.h" +#include +#include +#include +#include -/* - * dd4hep namespace declaration - */ +/// Namespace for the AIDA detector description toolkit namespace dd4hep { namespace { @@ -57,8 +55,6 @@ namespace dd4hep { template <> void Converter::operator()(xml_h seq) const; } -using std::string; -using namespace dd4hep; using namespace dd4hep::cond; /// Namespace for the AIDA detector description toolkit @@ -75,19 +71,19 @@ namespace dd4hep { }; /// Helper: Extract the validity from the xml element - string _getValidity(xml_h elt) { + std::string _getValidity(xml_h elt) { if ( !elt.ptr() ) return "Infinite"; else if ( !elt.hasAttr(_UC(validity)) ) return _getValidity(elt.parent()); - return elt.attr(_UC(validity)); + return elt.attr(_UC(validity)); } /// Helper: Extract the required detector element from the parsing information DetElement _getDetector(void* param, xml_h e) { ConversionArg* arg = static_cast(param); DetElement detector = arg ? arg->detector : DetElement(); - string subpath = e.hasAttr(_U(path)) ? e.attr(_U(path)) : string(); + std::string subpath = e.hasAttr(_U(path)) ? e.attr(_U(path)) : std::string(); return subpath.empty() ? detector : detail::tools::findDaughterElement(detector,subpath); } @@ -95,7 +91,7 @@ namespace dd4hep { Entry* _createStackEntry(void* param, xml_h element) { xml_comp_t e(element); DetElement elt = _getDetector(param, element); - string name = e.hasAttr(_U(name)) ? e.nameStr() : e.tag(); + std::string name = e.hasAttr(_U(name)) ? e.nameStr() : e.tag(); return new Entry(elt,name,e.tag(),_getValidity(element),detail::hash32(name)); } @@ -133,7 +129,7 @@ namespace dd4hep { */ template <> void Converter::operator()(xml_h e) const { xml_comp_t elt(e); - string tag = elt.tag(); + std::string tag = elt.tag(); ConversionArg* arg = _param(); if ( !arg ) except("ConditionsParser","++ Invalid parser argument [Internal Error]"); @@ -153,7 +149,7 @@ namespace dd4hep { xml_coll_t(e,_U(star)).for_each(Converter(description,param,optional)); else if ( tag == "alignment" ) { dd4hep_ptr val(_createStackEntry(param,e)); - val->value = elt.attr(_U(ref)); + val->value = elt.attr(_U(ref)); if ( !arg->stack ) except("ConditionsParser","Non-existing Conditions stack:%s %d",__FILE__, __LINE__); else @@ -210,15 +206,15 @@ namespace dd4hep { * @version 1.0 * @date 01/04/2014 */ -static void* setup_global_Conditions(Detector& description, int argc, char** argv) { +static void* setup_global_Conditions(dd4hep::Detector& description, int argc, char** argv) { if ( argc == 2 ) { xml_h e = xml_h::Elt_t(argv[0]); ConditionsStack* stack = (ConditionsStack*)argv[1]; - ConversionArg args(description.world(), stack); - (dd4hep::Converter(description,&args))(e); + dd4hep::ConversionArg args(description.world(), stack); + (dd4hep::Converter(description,&args))(e); return &description; } - except("XML_DOC_READER","Invalid number of arguments to interprete conditions: %d != %d.",argc,2); + dd4hep::except("XML_DOC_READER","Invalid number of arguments to interprete conditions: %d != %d.",argc,2); return 0; } DECLARE_DD4HEP_CONSTRUCTOR(XMLConditionsParser,setup_global_Conditions) diff --git a/DDCond/src/plugins/ConditionsPlugins.cpp b/DDCond/src/plugins/ConditionsPlugins.cpp index 4590b7745..a675c0856 100644 --- a/DDCond/src/plugins/ConditionsPlugins.cpp +++ b/DDCond/src/plugins/ConditionsPlugins.cpp @@ -12,25 +12,29 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/Plugins.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Conditions.h" -#include "DD4hep/PluginCreators.h" -#include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/ConditionsPrinter.h" -#include "DD4hep/DetectorProcessor.h" -#include "DD4hep/ConditionsProcessor.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "DDCond/ConditionsPool.h" -#include "DDCond/ConditionsSlice.h" -#include "DDCond/ConditionsManager.h" -#include "DDCond/ConditionsIOVPool.h" -#include "DDCond/ConditionsRepository.h" -#include "DDCond/ConditionsManagerObject.h" +#include +#include +#include +#include +#include +#include + +// C/C++ include files #include -using namespace std; using namespace dd4hep; using namespace dd4hep::cond; @@ -47,7 +51,7 @@ static int ddcond_install_cond_mgr (Detector& description, int argc, char** argv Handle mgr(description.extension(false)); if ( !mgr.isValid() ) { bool arg_error = false; - string factory = "DD4hep_ConditionsManager_Type1"; + std::string factory = "DD4hep_ConditionsManager_Type1"; for(int i = 0; i < argc && argv[i]; ++i) { if ( 0 == ::strncmp("-type",argv[i],4) ) factory = argv[++i]; @@ -58,14 +62,14 @@ static int ddcond_install_cond_mgr (Detector& description, int argc, char** argv } if ( arg_error ) { /// Help printout describing the basic command line interface - cout << + std::cout << "Usage: -plugin -arg [-arg] \n" " name: factory name DD4hep_ConditionsManagerInstaller \n" " -type Manager type. \n" " Default: ConditionsManagerObject_Type1_t \n" " -handle Pointer to Handle to pass pointer \n" " to the caller. \n" - "\tArguments given: " << arguments(argc,argv) << endl << flush; + "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush; ::exit(EINVAL); } ConditionsManagerObject* obj = createPlugin(factory,description); @@ -99,7 +103,7 @@ DECLARE_APPLY(DD4hep_ConditionsManagerInstaller,ddcond_install_cond_mgr) * \version 1.0 * \date 01/04/2016 */ -static ConditionsSlice* ddcond_prepare(Detector& description, const string& iov_typ, long iov_val, int argc, char** argv) { +static ConditionsSlice* ddcond_prepare(Detector& description, const std::string& iov_typ, long iov_val, int argc, char** argv) { const IOVType* iovtype = 0; long iovvalue = iov_val; ConditionsManager manager = ConditionsManager::from(description); @@ -119,8 +123,8 @@ static ConditionsSlice* ddcond_prepare(Detector& description, const string& iov_ "++ Unknown IOV value supplied for iov type %s.",iovtype->str().c_str()); IOV iov(iovtype,iovvalue); - shared_ptr content(new ConditionsContent()); - unique_ptr slice(new ConditionsSlice(manager,content)); + std::shared_ptr content(new ConditionsContent()); + std::unique_ptr slice(new ConditionsSlice(manager,content)); cond::fill_content(manager,*content,*iovtype); manager.prepare(iov, *slice); printout(INFO,"Conditions", @@ -139,7 +143,7 @@ static ConditionsSlice* ddcond_prepare(Detector& description, const string& iov_ * \date 01/04/2016 */ static int ddcond_conditions_pool_processor(Detector& description, bool process_pool, bool process_conditions, int argc, char** argv) { - unique_ptr proc(createProcessor(description,argc,argv)); + std::unique_ptr proc(createProcessor(description,argc,argv)); ConditionsManager manager = ConditionsManager::from(description); const auto types = manager.iovTypesUsed(); @@ -194,7 +198,7 @@ static int ddcond_conditions_pool_print(Detector& description, bool print_condit if ( argc > 0 ) { for(int i = 0; i < argc; ++i) { if ( argv[i] && 0 == ::strncmp(argv[i],"-processor",3) ) { - vector args; + std::vector args; for(int j=i; j= 2 ) { - string iov_typ = argv[0]; + std::string iov_typ = argv[0]; IOV::Key::first_type iov_key = *(IOV::Key::first_type*)argv[1]; dd4hep_ptr slice(ddcond_prepare(description,iov_typ,iov_key,argc,argv)); UserPool* pool = slice->pool.get(); @@ -365,8 +369,8 @@ DECLARE_APPLY(DD4hep_ConditionsSynchronize,ddcond_synchronize_conditions) */ static long ddcond_clean_conditions(Detector& description, int argc, char** argv) { if ( argc > 0 ) { - string iov_type = argv[0]; - int max_age = *(int*)argv[1]; + std::string iov_type = argv[0]; + int max_age = *(int*)argv[1]; printout(INFO,"Conditions", "+++ ConditionsUpdate: Cleaning conditions... type:%s max age:%d", iov_type.c_str(), max_age); @@ -389,11 +393,10 @@ DECLARE_APPLY(DD4hep_ConditionsClean,ddcond_clean_conditions) * \version 1.0 * \date 17/11/2016 */ -#include "DD4hep/PluginTester.h" template static void* create_printer(Detector& description, int argc,char** argv) { - PrintLevel print_level = INFO; - string prefix = "", name = ""; + PrintLevel print_level = INFO; + std::string prefix = "", name = ""; int flags = 0, have_pool = 0, arg_error = false; for(int i=0; i -arg [-arg] \n" " name: factory name(s) DD4hep_ConditionsPrinter, \n" " dd4hep_AlignmentsPrinter \n" @@ -421,7 +424,7 @@ static void* create_printer(Detector& description, int argc,char** argv) { " -pool Attach conditions user pool from \n" " PluginTester's slice instance attached. \n\n" " -print Printout level for the printer object. \n" - "\tArguments given: " << arguments(argc,argv) << endl << flush; + "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush; ::exit(EINVAL); } DetElement world = description.world(); @@ -436,8 +439,7 @@ static void* create_printer(Detector& description, int argc,char** argv) { if ( !name.empty() ) p->name = name; return (void*)dynamic_cast(createProcessorWrapper(p)); } -#include "DD4hep/ConditionsPrinter.h" -#include "DD4hep/AlignmentsPrinter.h" + static void* create_cond_printer(Detector& description, int argc,char** argv) { return create_printer(description,argc,argv); } @@ -456,7 +458,7 @@ DECLARE_DD4HEP_CONSTRUCTOR(DD4hep_ConditionsPrinter,create_cond_printer) */ static long ddcond_create_repository(Detector& description, int argc, char** argv) { bool arg_error = false; - string output = ""; + std::string output = ""; for(int i=0; i -arg [-arg] \n" " name: factory name DD4hep_ConditionsCreateRepository \n\n" " -output Output file name. \n\n" - "\tArguments given: " << arguments(argc,argv) << endl << flush; + "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush; ::exit(EINVAL); } printout(INFO,"Conditions", @@ -492,7 +494,7 @@ DECLARE_APPLY(DD4hep_ConditionsCreateRepository,ddcond_create_repository) static long ddcond_dump_repository(Detector& /* description */, int argc, char** argv) { typedef ConditionsRepository::Data Data; bool arg_error = false; - string input = ""; + std::string input = ""; Data data; for(int i=0; i -arg [-arg] \n" " name: factory name DD4hep_ConditionsDumpRepository \n\n" " -input Input file name. \n\n" - "\tArguments given: " << arguments(argc,argv) << endl << flush; + "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush; ::exit(EINVAL); } printout(INFO,"Conditions","+++ ConditionsRepository: Dumping %s",input.c_str()); @@ -514,7 +516,7 @@ static long ddcond_dump_repository(Detector& /* description */, int argc, char** printout(INFO,"Repository","%-8s %-60s %-60s","Key","Name","Address"); for(Data::const_iterator i=data.begin(); i!=data.end(); ++i) { const ConditionsRepository::Entry& e = *i; - string add = e.address; + std::string add = e.address; if ( add.length() > 80 ) add = e.address.substr(0,60) + "..."; printout(INFO,"Repository","%16llX %s",e.key,e.name.c_str()); printout(INFO,"Repository"," -> %s",e.address.c_str()); @@ -538,7 +540,7 @@ TO BE DONE!!! */ static long ddcond_load_repository(Detector& /* description */, int argc, char** argv) { if ( argc > 0 ) { - string input = argv[0]; + std::string input = argv[0]; printout(INFO,"Conditions","+++ ConditionsRepository: Loading %s",input.c_str()); ConditionsRepository::Data data; ConditionsRepository().load(input, data); diff --git a/DDCond/src/plugins/ConditionsRepositoryParser.cpp b/DDCond/src/plugins/ConditionsRepositoryParser.cpp index 797a8f27b..3112ba2e9 100644 --- a/DDCond/src/plugins/ConditionsRepositoryParser.cpp +++ b/DDCond/src/plugins/ConditionsRepositoryParser.cpp @@ -12,20 +12,20 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "XML/Conversions.h" -#include "XML/XMLParsers.h" -#include "XML/DocumentHandler.h" -#include "DD4hep/Path.h" -#include "DD4hep/Printout.h" -#include "DD4hep/DetectorTools.h" -#include "DD4hep/AlignmentData.h" -#include "DD4hep/OpaqueDataBinder.h" -#include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/detail/ConditionsInterna.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "DDCond/ConditionsTags.h" -#include "DDCond/ConditionsManager.h" +#include +#include // C/C++ include files #include @@ -68,15 +68,13 @@ namespace dd4hep { template <> void Converter::operator()(xml_h seq) const; } -using std::string; -using namespace dd4hep; using namespace dd4hep::cond; /// Anonymous local stuff only used in this module namespace { /// Module print level - static PrintLevel s_parseLevel = DEBUG; + static dd4hep::PrintLevel s_parseLevel = dd4hep::DEBUG; /// Local helper class to interprete XML conditions /** @@ -85,12 +83,12 @@ namespace { * \date 01/11/2016 */ struct ConversionArg { - DetElement detector; + dd4hep::DetElement detector; ConditionsPool* pool; ConditionsManager manager; ConversionArg() = delete; ConversionArg(const ConversionArg&) = delete; - ConversionArg(DetElement det, ConditionsManager m) : detector(det), pool(0), manager(m) + ConversionArg(dd4hep::DetElement det, ConditionsManager m) : detector(det), pool(0), manager(m) { } ConversionArg& operator=(const ConversionArg&) = delete; }; @@ -102,17 +100,17 @@ namespace { * \date 01/11/2016 */ struct CurrentDetector { - DetElement detector; - ConversionArg* arg; + dd4hep::DetElement detector; + ConversionArg* arg; CurrentDetector(ConversionArg* a) : arg(a) { detector = arg->detector; } ~CurrentDetector() { arg->detector = detector; } - void set(const string& path) { + void set(const std::string& path) { if ( !path.empty() ) { - arg->detector = detail::tools::findDaughterElement(detector,path); + arg->detector = dd4hep::detail::tools::findDaughterElement(detector,path); } } }; @@ -142,24 +140,24 @@ namespace { * \version 1.0 * \date 01/11/2016 */ - Condition create_condition(DetElement det, xml_h e) { + dd4hep::Condition create_condition(dd4hep::DetElement det, xml_h e) { xml_dim_t elt(e); - string tag = elt.tag(); - string typ = elt.hasAttr(_U(type)) ? elt.typeStr() : tag; - string nam = elt.hasAttr(_U(name)) ? elt.nameStr() : tag; - string add = xml::DocumentHandler::system_path(e); - string cond_nam = det.path()+"#"+nam; - Condition cond(cond_nam, typ); - cond->hash = ConditionKey::hashCode(det, nam); - printout(s_parseLevel,"XMLConditions","++ Processing condition tag:%s name:%s type:%s [%s] hash:%016X det:%p", - tag.c_str(), cond.name(), typ.c_str(), - Path(add).filename().c_str(), cond.key(), det.ptr()); + std::string tag = elt.tag(); + std::string typ = elt.hasAttr(_U(type)) ? elt.typeStr() : tag; + std::string nam = elt.hasAttr(_U(name)) ? elt.nameStr() : tag; + std::string add = xml_handler_t::system_path(e); + std::string cond_nam = det.path()+"#"+nam; + dd4hep::Condition cond(cond_nam, typ); + cond->hash = dd4hep::ConditionKey::hashCode(det, nam); + dd4hep::printout(s_parseLevel,"XMLConditions","++ Processing condition tag:%s name:%s type:%s [%s] hash:%016X det:%p", + tag.c_str(), cond.name(), typ.c_str(), + dd4hep::Path(add).filename().c_str(), cond.key(), det.ptr()); #if !defined(DD4HEP_MINIMAL_CONDITIONS) cond->address = add; cond->value = ""; cond->validity = ""; if ( elt.hasAttr(_U(comment)) ) { - cond->comment = elt.attr(_U(comment)); + cond->comment = elt.attr(_U(comment)); } #endif //ConditionsKeyAssign(det).addKey(cond.name()); @@ -172,19 +170,19 @@ namespace { * \version 1.0 * \date 01/11/2016 */ - template Condition bind_condition(const BINDER& bnd, - DetElement det, - xml_h e, - const std::string& type="") + template dd4hep::Condition bind_condition(const BINDER& bnd, + dd4hep::DetElement det, + xml_h e, + const std::string& type="") { xml_dim_t elt(e); - string typ = type.empty() ? elt.typeStr() : type; - string val = elt.hasAttr(_U(value)) ? elt.valueStr() : elt.text(); - Condition con = create_condition(det, e); - string unit = elt.hasAttr(_U(unit)) ? elt.attr(_U(unit)) : string(""); + std::string typ = type.empty() ? elt.typeStr() : type; + std::string val = elt.hasAttr(_U(value)) ? elt.valueStr() : elt.text(); + dd4hep::Condition con = create_condition(det, e); + std::string unit = elt.hasAttr(_U(unit)) ? elt.attr(_U(unit)) : std::string(""); if ( !unit.empty() ) val += "*"+unit; con->value = val; - detail::OpaqueDataBinder::bind(bnd, con, typ, val); + dd4hep::detail::OpaqueDataBinder::bind(bnd, con, typ, val); return con; } } @@ -199,11 +197,11 @@ namespace dd4hep { * \date 01/04/2014 */ template <> void Converter::operator()(xml_h element) const { - xml_dim_t e = element; - string nam = e.nameStr(); - size_t id = e.id() >= 0 ? e.id() : INT_MAX; + xml_dim_t e = element; + std::string nam = e.nameStr(); + std::size_t id = e.id() >= 0 ? e.id() : INT_MAX; ConversionArg* arg = _param(); - printout(s_parseLevel,"XMLConditions","++ Registering IOV type: [%d]: %s",int(id),nam.c_str()); + dd4hep::printout(s_parseLevel,"XMLConditions","++ Registering IOV type: [%d]: %s",int(id),nam.c_str()); const IOVType* iov_type = arg->manager.registerIOVType(id,nam).second; if ( !iov_type ) { except("XMLConditions","Failed to register iov type: [%d]: %s",int(id),nam.c_str()); @@ -217,15 +215,15 @@ namespace dd4hep { * \date 01/04/2014 */ template <> void Converter::operator()(xml_h element) const { - xml_dim_t e = element; - string val = e.attr(_UC(validity)); - ConversionArg* arg = _param(); + xml_dim_t e = element; + std::string val = e.attr(_UC(validity)); + ConversionArg* arg = _param(); CurrentPool pool(arg); pool.set(arg->manager.registerIOV(val)); if ( e.hasAttr(_U(ref)) ) { - string ref = e.attr(_U(ref)); - printout(s_parseLevel,"XMLConditions","++ Reading IOV file: %s -> %s",val.c_str(),ref.c_str()); + std::string ref = e.attr(_U(ref)); + dd4hep::printout(s_parseLevel,"XMLConditions","++ Reading IOV file: %s -> %s",val.c_str(),ref.c_str()); xml::DocumentHolder doc(xml::DocumentHandler().load(element, element.attr_value(_U(ref)))); Converter(description,param,optional)(doc.root()); return; @@ -247,8 +245,8 @@ namespace dd4hep { } for( xml_coll_t c(element,_UC(property)); c; ++c) { xml_dim_t d = c; - string nam = d.nameStr(); - string val = d.valueStr(); + std::string nam = d.nameStr(); + std::string val = d.valueStr(); try { printout(s_parseLevel,"XMLConditions","++ Setup conditions Manager[%s] = %s", nam.c_str(),val.c_str()); @@ -270,8 +268,8 @@ namespace dd4hep { * \date 01/04/2014 */ template <> void Converter::operator()(xml_h e) const { - ConversionArg* arg = _param(); - Condition con = bind_condition(detail::ValueBinder(), arg->detector, e); + ConversionArg* arg = _param(); + dd4hep::Condition con = bind_condition(detail::ValueBinder(), arg->detector, e); arg->manager.registerUnlocked(*arg->pool, con); } @@ -284,8 +282,8 @@ namespace dd4hep { * \date 01/04/2014 */ template <> void Converter::operator()(xml_h e) const { - ConversionArg* arg = _param(); - Condition con = bind_condition(detail::ValueBinder(), arg->detector, e, "double"); + ConversionArg* arg = _param(); + dd4hep::Condition con = bind_condition(detail::ValueBinder(), arg->detector, e, "double"); con->setFlag(Condition::PRESSURE); arg->manager.registerUnlocked(*arg->pool, con); } @@ -299,8 +297,8 @@ namespace dd4hep { * \date 01/04/2014 */ template <> void Converter::operator()(xml_h e) const { - ConversionArg* arg = _param(); - Condition con = bind_condition(detail::ValueBinder(), arg->detector, e, "double"); + ConversionArg* arg = _param(); + dd4hep::Condition con = bind_condition(detail::ValueBinder(), arg->detector, e, "double"); con->setFlag(Condition::TEMPERATURE); arg->manager.registerUnlocked(*arg->pool, con); } @@ -312,8 +310,8 @@ namespace dd4hep { * \date 01/04/2014 */ template <> void Converter::operator()(xml_h e) const { - ConversionArg* arg = _param(); - Condition con = create_condition(arg->detector, e); + ConversionArg* arg = _param(); + dd4hep::Condition con = create_condition(arg->detector, e); xml::parse_sequence(e, con->data); arg->manager.registerUnlocked(*arg->pool, con); } @@ -325,8 +323,8 @@ namespace dd4hep { * \date 01/04/2014 */ template <> void Converter::operator()(xml_h e) const { - ConversionArg* arg = _param(); - Condition con = create_condition(arg->detector, e); + ConversionArg* arg = _param(); + dd4hep::Condition con = create_condition(arg->detector, e); xml::parse_mapping(e, con->data); arg->manager.registerUnlocked(*arg->pool, con); } @@ -340,7 +338,7 @@ namespace dd4hep { template <> void Converter::operator()(xml_h e) const { xml_h child_rot, child_pos, child_piv; ConversionArg* arg = _param(); - Condition con = create_condition(arg->detector, e); + dd4hep::Condition con = create_condition(arg->detector, e); //Delta& del = con.bind(); xml::parse_delta(e, con->data); con->setFlag(Condition::ALIGNMENT_DELTA); @@ -358,7 +356,7 @@ namespace dd4hep { ConversionArg* arg = _param(); CurrentDetector detector(arg); if ( elt.hasAttr(_U(path)) ) { - detector.set(e.attr(_U(path))); + detector.set(e.attr(_U(path))); printout(s_parseLevel,"XMLConditions","++ Processing condition for:%s", arg->detector.path().c_str()); } @@ -395,7 +393,7 @@ namespace dd4hep { */ template <> void Converter::operator()(xml_h e) const { xml_comp_t elt(e); - string tag = elt.tag(); + std::string tag = elt.tag(); if ( tag == "repository" ) Converter(description,param,optional)(e); else if ( tag == "manager" ) @@ -430,36 +428,35 @@ namespace dd4hep { * \version 1.0 * \date 01/04/2014 */ -static long setup_repository_loglevel(Detector& /* description */, int argc, char** argv) { +static long setup_repository_loglevel(dd4hep::Detector& /* description */, int argc, char** argv) { if ( argc == 1 ) { - s_parseLevel = printLevel(argv[0]); + s_parseLevel = dd4hep::printLevel(argv[0]); return 1; } - except("ConditionsXMLRepositoryPrintLevel","++ Invalid plugin arguments: %s", - arguments(argc,argv).c_str()); + dd4hep::except("ConditionsXMLRepositoryPrintLevel","++ Invalid plugin arguments: %s", + dd4hep::arguments(argc,argv).c_str()); return 0; } DECLARE_APPLY(DD4hep_ConditionsXMLRepositoryPrintLevel,setup_repository_loglevel) -#include "DD4hep/DD4hepUI.h" - +#include /// Basic entry point to read alignment conditions files /** * \author M.Frank * \version 1.0 * \date 01/04/2014 */ -static long setup_repository_Conditions(Detector& description, int argc, char** argv) { +static long setup_repository_Conditions(dd4hep::Detector& description, int argc, char** argv) { if ( argc == 1 ) { - detail::DD4hepUI ui(description); - string fname(argv[0]); + dd4hep::detail::DD4hepUI ui(description); + std::string fname(argv[0]); ConditionsManager mgr(ui.conditionsMgr()); ConversionArg arg(description.world(), mgr); - xml::DocumentHolder doc(xml::DocumentHandler().load(fname)); - (dd4hep::Converter(description,&arg))(doc.root()); + xml_doc_holder_t doc(xml_handler_t().load(fname)); + (dd4hep::Converter(description,&arg))(doc.root()); return 1; } - except("XML_DOC_READER","Invalid number of arguments to interprete conditions: %d != %d.",argc,1); + dd4hep::except("XML_DOC_READER","Invalid number of arguments to interprete conditions: %d != %d.",argc,1); return 0; } DECLARE_APPLY(DD4hep_ConditionsXMLRepositoryParser,setup_repository_Conditions) diff --git a/DDCond/src/plugins/ConditionsRepositoryWriter.cpp b/DDCond/src/plugins/ConditionsRepositoryWriter.cpp index 91e74498b..219642337 100644 --- a/DDCond/src/plugins/ConditionsRepositoryWriter.cpp +++ b/DDCond/src/plugins/ConditionsRepositoryWriter.cpp @@ -14,9 +14,9 @@ #define DD4HEP_DDCOND_CONDITIONSREPOSITORYWRITER_H // Framework include files -#include "DD4hep/Detector.h" -#include "XML/XMLElements.h" -#include "DDCond/ConditionsManager.h" +#include +#include +#include // C/C++ include files @@ -90,20 +90,20 @@ namespace dd4hep { //========================================================================== // Framework include files -#include "XML/XMLElements.h" -#include "XML/DocumentHandler.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Alignments.h" -#include "DD4hep/AlignmentData.h" -#include "DD4hep/OpaqueDataBinder.h" -#include "DD4hep/ConditionsProcessor.h" -#include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/detail/ConditionsInterna.h" -#include "DD4hep/detail/AlignmentsInterna.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "DDCond/ConditionsTags.h" -#include "DDCond/ConditionsSlice.h" -#include "DDCond/ConditionsManagerObject.h" +#include +#include +#include // C/C++ include files #include @@ -112,18 +112,17 @@ namespace dd4hep { #include #include -using std::string; -using std::shared_ptr; -using std::stringstream; -using namespace dd4hep; using namespace dd4hep::cond; namespace units = dd4hep; +namespace xml = dd4hep::xml; +using dd4hep::printout; +using dd4hep::_toString; /// Anonymous local stuff only used in this module namespace { /// Module print level - static PrintLevel s_printLevel = INFO; + static dd4hep::PrintLevel s_printLevel = dd4hep::INFO; class pressure; class temperature; @@ -134,9 +133,9 @@ namespace { xml::Element root; public: PropertyDumper(xml::Element p) : root(p) {} - void operator()(const std::pair& p) const { + void operator()(const std::pair& p) const { xml::Element e = xml::Element(root.document(),_UC(property)); - string val = p.second.str(); + std::string val = p.second.str(); if ( val[0] == '\'' ) val = p.second.str().c_str()+1; if ( !val.empty() && val[val.length()-1] == '\'' ) val[val.length()-1] = 0; e.setAttr(_U(name), p.first); @@ -145,9 +144,9 @@ namespace { } }; - template xml::Element _convert(xml::Element par, Condition c); + template xml::Element _convert(xml::Element par, dd4hep::Condition c); - xml::Element make(xml::Element e, Condition c) { + xml::Element make(xml::Element e, dd4hep::Condition c) { char hash[64]; std::string nam = c.name(); std::string cn = nam.substr(nam.find('#')+1); @@ -156,22 +155,22 @@ namespace { e.setAttr(_U(key),hash); return e; } - xml::Element _convert(xml::Element par, const Translation3D& tr) { + xml::Element _convert(xml::Element par, const dd4hep::Translation3D& tr) { xml::Element e = xml::Element(par.document(),_U(pivot)); - const Translation3D::Vector& v = tr.Vect(); + const dd4hep::Translation3D::Vector& v = tr.Vect(); e.setAttr(_U(x),_toString(v.X()/dd4hep::mm,"%f*mm")); e.setAttr(_U(y),_toString(v.Y()/dd4hep::mm,"%f*mm")); e.setAttr(_U(z),_toString(v.Z()/dd4hep::mm,"%f*mm")); return e; } - xml::Element _convert(xml::Element par, const Position& pos) { + xml::Element _convert(xml::Element par, const dd4hep::Position& pos) { xml::Element e = xml::Element(par.document(),_U(position)); e.setAttr(_U(x),_toString(pos.X()/dd4hep::mm,"%f*mm")); e.setAttr(_U(y),_toString(pos.Y()/dd4hep::mm,"%f*mm")); e.setAttr(_U(z),_toString(pos.Z()/dd4hep::mm,"%f*mm")); return e; } - xml::Element _convert(xml::Element par, const RotationZYX& rot) { + xml::Element _convert(xml::Element par, const dd4hep::RotationZYX& rot) { xml::Element e = xml::Element(par.document(),_U(rotation)); double z, y, x; rot.GetComponents(z,y,x); @@ -180,80 +179,80 @@ namespace { e.setAttr(_U(z),_toString(z/dd4hep::rad,"%f*rad")); return e; } - template <> xml::Element _convert(xml::Element par, Condition c) { + template <> xml::Element _convert(xml::Element par, dd4hep::Condition c) { xml::Element v = make(xml::Element(par.document(),_U(value)),c); - OpaqueData& data = c.data(); + dd4hep::OpaqueData& data = c.data(); v.setAttr(_U(type),data.dataType()); v.setAttr(_U(value),data.str()); return v; } - template <> xml::Element _convert(xml::Element par, Condition c) { + template <> xml::Element _convert(xml::Element par, dd4hep::Condition c) { xml::Element press = make(xml::Element(par.document(),_UC(pressure)),c); press.setAttr(_U(value),c.get()/(100e0*units::pascal)); press.setAttr(_U(unit),"hPa"); return press; } - template <> xml::Element _convert(xml::Element par, Condition c) { + template <> xml::Element _convert(xml::Element par, dd4hep::Condition c) { xml::Element temp = make(xml::Element(par.document(),_UC(temperature)),c); temp.setAttr(_U(value),c.get()/units::kelvin); temp.setAttr(_U(unit),"kelvin"); return temp; } - template <> xml::Element _convert(xml::Element par, Condition c) { - xml::Element align = make(xml::Element(par.document(),_UC(alignment_delta)),c); - const Delta& delta = c.get(); - if ( delta.flags&Delta::HAVE_TRANSLATION ) + template <> xml::Element _convert(xml::Element par, dd4hep::Condition c) { + xml::Element align = make(xml::Element(par.document(),_UC(alignment_delta)),c); + const dd4hep::Delta& delta = c.get(); + if ( delta.flags&dd4hep::Delta::HAVE_TRANSLATION ) align.append(_convert(align,delta.translation)); - if ( delta.flags&Delta::HAVE_ROTATION ) + if ( delta.flags&dd4hep::Delta::HAVE_ROTATION ) align.append(_convert(align,delta.rotation)); - if ( delta.flags&Delta::HAVE_PIVOT ) + if ( delta.flags&dd4hep::Delta::HAVE_PIVOT ) align.append(_convert(align,delta.pivot)); return align; } - template <> xml::Element _convert(xml::Element par, Condition c) { + template <> xml::Element _convert(xml::Element par, dd4hep::Condition c) { char hash[64]; - typedef ConditionKey::KeyMaker KM; - AlignmentCondition acond = c; - KM km(c.key()); - const Delta& delta = acond.data().delta; - xml::Element align(xml::Element(par.document(),_UC(alignment_delta))); - Condition::key_type key = KM(km.values.det_key,align::Keys::deltaKey).hash; + typedef dd4hep::ConditionKey::KeyMaker KM; + dd4hep::AlignmentCondition acond = c; + KM km(c.key()); + const dd4hep::Delta& delta = acond.data().delta; + xml::Element align(xml::Element(par.document(),_UC(alignment_delta))); + dd4hep::Condition::key_type key = KM(km.values.det_key,dd4hep::align::Keys::deltaKey).hash; ::snprintf(hash,sizeof(hash),"%llX",key); - align.setAttr(_U(name),align::Keys::deltaName); + align.setAttr(_U(name), dd4hep::align::Keys::deltaName); align.setAttr(_U(key),hash); - if ( delta.flags&Delta::HAVE_TRANSLATION ) + if ( delta.flags&dd4hep::Delta::HAVE_TRANSLATION ) align.append(_convert(align,delta.translation)); - if ( delta.flags&Delta::HAVE_ROTATION ) + if ( delta.flags&dd4hep::Delta::HAVE_ROTATION ) align.append(_convert(align,delta.rotation)); - if ( delta.flags&Delta::HAVE_PIVOT ) + if ( delta.flags&dd4hep::Delta::HAVE_PIVOT ) align.append(_convert(align,delta.pivot)); return align; } - xml::Element _seq(xml::Element v, Condition c, const char* tag, const char* match) { - OpaqueData& data = c.data(); - string typ = data.dataType(); + xml::Element _seq(xml::Element v, dd4hep::Condition c, const char* tag, const char* match) { + dd4hep::OpaqueData& data = c.data(); + std::string typ = data.dataType(); size_t len = ::strlen(match); size_t idx = typ.find(match); size_t idq = typ.find(',',idx+len); - if ( idx != string::npos && idq != string::npos ) { - string subtyp = tag; + if ( idx != std::string::npos && idq != std::string::npos ) { + std::string subtyp = tag; subtyp += "["+typ.substr(idx+len,idq-idx-len)+"]"; v.setAttr(_U(type),subtyp); xml::Handle_t(v.ptr()).setText(data.str()); return v; } - except("Writer","++ Unknwon XML conversion to type: %s",typ.c_str()); + dd4hep::except("Writer","++ Unknwon XML conversion to type: %s",typ.c_str()); return v; } - template <> xml::Element _convert >(xml::Element par, Condition c) { + template <> xml::Element _convert >(xml::Element par, dd4hep::Condition c) { xml::Element v = make(xml::Element(par.document(),_UC(sequence)),c); return _seq(v,c,"vector","::vector<"); } - template <> xml::Element _convert >(xml::Element par, Condition c) { + template <> xml::Element _convert >(xml::Element par, dd4hep::Condition c) { xml::Element v = make(xml::Element(par.document(),_UC(sequence)),c); return _seq(v,c,"list","::list<"); } - template <> xml::Element _convert >(xml::Element par, Condition c) { + template <> xml::Element _convert >(xml::Element par, dd4hep::Condition c) { xml::Element v = make(xml::Element(par.document(),_UC(sequence)),c); return _seq(v,c,"set","::set<"); } @@ -291,9 +290,9 @@ size_t ConditionsXMLRepositoryWriter::collect(xml::Element root, ConditionsSlice root.append(repo); repo.append(iov); - ::snprintf(text,sizeof(text),"%ld,%ld#%s", - long(validity.keyData.first), long(validity.keyData.second), - validity.iovType->name.c_str()); + std::snprintf(text,sizeof(text),"%ld,%ld#%s", + long(validity.keyData.first), long(validity.keyData.second), + validity.iovType->name.c_str()); iov.setAttr(_UC(validity),text); return collect(iov,slice,slice.manager->detectorDescription().world()); } @@ -334,7 +333,7 @@ size_t ConditionsXMLRepositoryWriter::collect(xml::Element root, std::vector conds; conditionsCollector(slice,conds)(detector); if ( !conds.empty() ) { - stringstream comment; + std::stringstream comment; Condition cond_align, cond_delta; xml::Element conditions = xml::Element(root.document(),_UC(detelement)); conditions.setAttr(_U(path),detector.path()); @@ -366,7 +365,7 @@ size_t ConditionsXMLRepositoryWriter::collect(xml::Element root, cond_delta = c; } else { - const OpaqueData& data = c.data(); + const dd4hep::OpaqueData& data = c.data(); const std::type_info& typ = data.typeInfo(); #if defined(DD4HEP_HAVE_ALL_PARSERS) if ( typ == typeid(char) || typ == typeid(unsigned char) || @@ -374,11 +373,11 @@ size_t ConditionsXMLRepositoryWriter::collect(xml::Element root, typ == typeid(int) || typ == typeid(unsigned int) || typ == typeid(long) || typ == typeid(unsigned long) || typ == typeid(float) || typ == typeid(double) || - typ == typeid(bool) || typ == typeid(string) ) + typ == typeid(bool) || typ == typeid(std::string) ) #else if ( typ == typeid(int) || typ == typeid(long) || typ == typeid(float) || typ == typeid(double) || - typ == typeid(bool) || typ == typeid(string) ) + typ == typeid(bool) || typ == typeid(std::string) ) #endif { conditions.append(_convert(conditions,c)); @@ -416,7 +415,7 @@ size_t ConditionsXMLRepositoryWriter::collect(xml::Element root, ++m_numConverted; } else if ( cond_delta.isValid() ) { - conditions.append(_convert(conditions,cond_delta)); + conditions.append(_convert(conditions,cond_delta)); ++m_numConverted; } } @@ -428,8 +427,8 @@ size_t ConditionsXMLRepositoryWriter::collect(xml::Element root, // ====================================================================================== /// Write the XML document structure to a file. -long ConditionsXMLRepositoryWriter::write(xml::Document doc, const string& output) const { - xml::DocumentHandler docH; +long ConditionsXMLRepositoryWriter::write(xml::Document doc, const std::string& output) const { + xml_handler_t docH; long ret = docH.output(doc, output); if ( !output.empty() ) { printout(INFO,"Writer","++ Successfully wrote %ld conditions (%ld unconverted) to file: %s", @@ -444,12 +443,12 @@ long ConditionsXMLRepositoryWriter::write(xml::Document doc, const string& outpu * \version 1.0 * \date 01/04/2014 */ -static long write_repository_conditions(Detector& description, int argc, char** argv) { +static long write_repository_conditions(dd4hep::Detector& description, int argc, char** argv) { ConditionsManager manager = ConditionsManager::from(description); - const IOVType* iovtype = 0; - long iovvalue = -1; - long mgr_prop = 0; - string output; + const dd4hep::IOVType* iovtype = 0; + long iovvalue = -1; + long mgr_prop = 0; + std::string output; for(int i=0; i Output file name. Default: stdout "); - printout(ALWAYS,"Plugin-Help"," -manager Add manager properties to the output. "); - printout(ALWAYS,"Plugin-Help"," -iov_type IOV type to be selected. "); - printout(ALWAYS,"Plugin-Help"," -iov_value IOV value to create the conditions snapshot."); + printout(dd4hep::ALWAYS,"Plugin-Help","Usage: dd4hep_XMLConditionsRepositoryWriter --opt [--opt] "); + printout(dd4hep::ALWAYS,"Plugin-Help"," -output Output file name. Default: stdout "); + printout(dd4hep::ALWAYS,"Plugin-Help"," -manager Add manager properties to the output. "); + printout(dd4hep::ALWAYS,"Plugin-Help"," -iov_type IOV type to be selected. "); + printout(dd4hep::ALWAYS,"Plugin-Help"," -iov_value IOV value to create the conditions snapshot."); ::exit(EINVAL); } } if ( 0 == iovtype ) - except("ConditionsPrepare","++ Unknown IOV type supplied."); + dd4hep::except("ConditionsPrepare","++ Unknown IOV type supplied."); if ( 0 > iovvalue ) - except("ConditionsPrepare", - "++ Unknown IOV value supplied for iov type %s.",iovtype->str().c_str()); + dd4hep::except("ConditionsPrepare", + "++ Unknown IOV value supplied for iov type %s.",iovtype->str().c_str()); - IOV iov(iovtype,iovvalue); - shared_ptr content(new ConditionsContent()); - shared_ptr slice(new ConditionsSlice(manager,content)); - cond::fill_content(manager,*content,*iovtype); + dd4hep::IOV iov(iovtype,iovvalue); + std::shared_ptr content(new ConditionsContent()); + std::shared_ptr slice(new ConditionsSlice(manager,content)); + dd4hep::cond::fill_content(manager,*content,*iovtype); ConditionsManager::Result cres = manager.prepare(iov, *slice); - printout(INFO,"Conditions", + printout(dd4hep::INFO, "Conditions", "++ Selected conditions: %7ld conditions (S:%ld,L:%ld,C:%ld,M:%ld) for IOV:%-12s", cres.total(), cres.selected, cres.loaded, cres.computed, cres.missing, iovtype ? iov.str().c_str() : "???"); @@ -507,16 +506,16 @@ DECLARE_APPLY(DD4hep_ConditionsXMLRepositoryWriter,write_repository_conditions) * \version 1.0 * \date 01/04/2014 */ -static long write_repository_manager(Detector& description, int argc, char** argv) { +static long write_repository_manager(dd4hep::Detector& description, int argc, char** argv) { ConditionsManager manager = ConditionsManager::from(description); - string output; + std::string output; for(int i=0; ii+1) output = argv[++i]; else if ( ::strncmp(argv[i],"-help",2) == 0 ) { - printout(ALWAYS,"Plugin-Help","Usage: dd4hep_XMLConditionsManagerWriter --opt [--opt] "); - printout(ALWAYS,"Plugin-Help"," -output Output file name. Default: stdout "); + printout(dd4hep::ALWAYS,"Plugin-Help","Usage: dd4hep_XMLConditionsManagerWriter --opt [--opt] "); + printout(dd4hep::ALWAYS,"Plugin-Help"," -output Output file name. Default: stdout "); ::exit(EINVAL); } } diff --git a/DDCond/src/plugins/ConditionsSnapshotRootLoader.cpp b/DDCond/src/plugins/ConditionsSnapshotRootLoader.cpp index 1c4425987..b52b29a09 100644 --- a/DDCond/src/plugins/ConditionsSnapshotRootLoader.cpp +++ b/DDCond/src/plugins/ConditionsSnapshotRootLoader.cpp @@ -15,9 +15,9 @@ #define DD4HEP_CONDITIONS_CONDIITONSSNAPSHOTROOTLOADER_H // Framework include files -#include "DDCond/ConditionsDataLoader.h" -#include "DDCond/ConditionsRootPersistency.h" -#include "DD4hep/Printout.h" +#include +#include +#include /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -61,24 +61,22 @@ namespace dd4hep { } /* End namespace dd4hep */ #endif /* DD4HEP_CONDITIONS_CONDIITONSSNAPSHOTROOTLOADER_H */ -//#include "ConditionsSnapshotRootLoader.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Factories.h" -#include "DD4hep/PluginCreators.h" -#include "DD4hep/detail/ConditionsInterna.h" +//#include +#include +#include +#include +#include -#include "TFile.h" +#include // C/C++ include files #include // Forward declartions -using std::string; -using namespace dd4hep; using namespace dd4hep::cond; namespace { - void* create_loader(Detector& description, int argc, char** argv) { + void* create_loader(dd4hep::Detector& description, int argc, char** argv) { const char* name = argc>0 ? argv[0] : "XMLLoader"; ConditionsManagerObject* mgr = (ConditionsManagerObject*)(argc>0 ? argv[1] : 0); return new ConditionsSnapshotRootLoader(description,ConditionsManager(mgr),name); diff --git a/DDCond/src/plugins/ConditionsUserPool.cpp b/DDCond/src/plugins/ConditionsUserPool.cpp index d98152a2a..368c381f6 100644 --- a/DDCond/src/plugins/ConditionsUserPool.cpp +++ b/DDCond/src/plugins/ConditionsUserPool.cpp @@ -14,8 +14,8 @@ #define DDCOND_CONDITIONSMAPPEDUSERPOOL_H // Framework include files -#include "DDCond/ConditionsPool.h" -#include "DD4hep/ConditionsMap.h" +#include +#include // C/C++ include files #include @@ -151,41 +151,40 @@ namespace dd4hep { //========================================================================== // Framework include files -//#include "DDCond/ConditionsMappedPool.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Factories.h" -#include "DD4hep/InstanceCount.h" +//#include +#include +#include +#include -#include "DDCond/ConditionsIOVPool.h" -#include "DDCond/ConditionsSelectors.h" -#include "DDCond/ConditionsDataLoader.h" -#include "DDCond/ConditionsManagerObject.h" -#include "DDCond/ConditionsDependencyHandler.h" +#include +#include +#include +#include +#include +// C/C++ include files #include -using namespace std; -using namespace dd4hep; using namespace dd4hep::cond; namespace { - class SimplePrint : public Condition::Processor { + class SimplePrint : public dd4hep::Condition::Processor { /// Conditions callback for object processing - virtual int process(Condition) const override { return 1; } + virtual int process(dd4hep::Condition) const override { return 1; } /// Conditions callback for object processing - virtual int operator()(Condition) const override { return 1; } + virtual int operator()(dd4hep::Condition) const override { return 1; } /// Conditions callback for object processing in maps - virtual int operator()(const pair& i) const override { - Condition c = i.second; - printout(INFO,"UserPool","++ %16llX/%16llX Val:%s %s",i.first, c->hash, c->value.c_str(), c.str().c_str()); + virtual int operator()(const std::pair& i) const override { + dd4hep::Condition c = i.second; + dd4hep::printout(dd4hep::INFO,"UserPool","++ %16llX/%16llX Val:%s %s",i.first, c->hash, c->value.c_str(), c.str().c_str()); return 1; } }; - template struct MapSelector : public ConditionsSelect { + template struct MapSelector : public dd4hep::ConditionsSelect { T& m; MapSelector(T& o) : m(o) {} - bool operator()(Condition::Object* o) const + bool operator()(dd4hep::Condition::Object* o) const { return m.emplace(o->hash,o).second; } }; template MapSelector mapSelector(T& container) @@ -193,14 +192,14 @@ namespace { template struct Inserter { T& m; - IOV* iov; - Inserter(T& o, IOV* i=0) : m(o), iov(i) {} - void operator()(const Condition& c) { - Condition::Object* o = c.ptr(); + dd4hep::IOV* iov; + Inserter(T& o, dd4hep::IOV* i=0) : m(o), iov(i) {} + void operator()(const dd4hep::Condition& c) { + dd4hep::Condition::Object* o = c.ptr(); m.emplace(o->hash,o); if ( iov ) iov->iov_intersection(o->iov->key()); } - void operator()(const pair& e) { (*this)(e.second); } + void operator()(const std::pair& e) { (*this)(e.second); } }; } @@ -229,7 +228,7 @@ ConditionsMappedUserPool::~ConditionsMappedUserPool() { InstanceCount::decrement(this); } -template inline Condition::Object* +template inline dd4hep::Condition::Object* ConditionsMappedUserPool::i_findCondition(Condition::key_type key) const { typename MAPPING::const_iterator i=m_conditions.find(key); #if 0 @@ -263,7 +262,7 @@ size_t ConditionsMappedUserPool::size() const { /// Print pool content template -void ConditionsMappedUserPool::print(const string& opt) const { +void ConditionsMappedUserPool::print(const std::string& opt) const { const IOV* iov = &m_iov; printout(INFO,"UserPool","+++ %s Conditions for USER pool with IOV: %-32s [%4d entries]", opt.c_str(), iov->str().c_str(), size()); @@ -297,13 +296,13 @@ bool ConditionsMappedUserPool::exists(const ConditionKey& key) const /// Check if a condition exists in the pool and return it to the caller template -Condition ConditionsMappedUserPool::get(Condition::key_type hash) const { +dd4hep::Condition ConditionsMappedUserPool::get(Condition::key_type hash) const { return i_findCondition(hash); } /// Check if a condition exists in the pool and return it to the caller template -Condition ConditionsMappedUserPool::get(const ConditionKey& key) const { +dd4hep::Condition ConditionsMappedUserPool::get(const ConditionKey& key) const { return i_findCondition(key.hash); } @@ -323,13 +322,13 @@ ConditionsMappedUserPool::registerOne(const IOV& iov, } /// Do block insertions of conditions with identical IOV including registration to the manager -template size_t +template std::size_t ConditionsMappedUserPool::registerMany(const IOV& iov, - const vector& conds) { + const std::vector& conds) { if ( iov.iovType ) { ConditionsPool* pool = m_manager.registerIOV(*iov.iovType,iov.keyData); if ( pool ) { - size_t result = m_manager.blockRegister(*pool, conds); + std::size_t result = m_manager.blockRegister(*pool, conds); if ( result == conds.size() ) { for(auto c : conds) i_insert(c.ptr()); return result; @@ -364,12 +363,12 @@ bool ConditionsMappedUserPool::insert(DetElement detector, /// ConditionsMap overload: Access a condition template -Condition ConditionsMappedUserPool::get(DetElement detector, unsigned int item_key) const { +dd4hep::Condition ConditionsMappedUserPool::get(DetElement detector, unsigned int item_key) const { return get(ConditionKey::KeyMaker(detector.key(), item_key).hash); } /// No ConditionsMap overload: Access all conditions within a key range in the interval [lower,upper] -template std::vector +template std::vector ConditionsMappedUserPool::get(DetElement detector, Condition::itemkey_type lower, Condition::itemkey_type upper) const { @@ -379,9 +378,9 @@ ConditionsMappedUserPool::get(DetElement detector, } /// Specialization for std::map: Access all conditions within a given key range -template std::vector +template std::vector ConditionsMappedUserPool::get(Condition::key_type lower, Condition::key_type upper) const { - vector result; + std::vector result; if ( !m_conditions.empty() ) { typename MAPPING::const_iterator first = m_conditions.lower_bound(lower); for(; first != m_conditions.end(); ++first ) { @@ -442,9 +441,9 @@ bool ConditionsMappedUserPool::remove(Condition::key_type hash_key) /// Evaluate and register all derived conditions from the dependency list template -size_t ConditionsMappedUserPool::compute(const Dependencies& deps, - ConditionUpdateUserContext* user_param, - bool force) +std::size_t ConditionsMappedUserPool::compute(const Dependencies& deps, + ConditionUpdateUserContext* user_param, + bool force) { if ( !deps.empty() ) { Dependencies missing; @@ -484,10 +483,10 @@ size_t ConditionsMappedUserPool::compute(const Dependencies& deps, namespace { struct COMP { - typedef pair Dep; - typedef pair Cond; - typedef pair Info; - typedef pair Cond2; + typedef std::pair Dep; + typedef std::pair Cond; + typedef std::pair Info; + typedef std::pair Cond2; bool operator()(const Dep& a,const Cond& b) const { return a.first < b.first; } bool operator()(const Cond& a,const Dep& b) const { return a.first < b.first; } @@ -505,8 +504,8 @@ ConditionsMappedUserPool::prepare(const IOV& required, ConditionsSlice& slice, ConditionUpdateUserContext* user_param) { - typedef vector > CalcMissing; - typedef vector > CondMissing; + typedef std::vector > CalcMissing; + typedef std::vector > CondMissing; const auto& slice_cond = slice.content->conditions(); const auto& slice_calc = slice.content->derived(); auto& slice_miss_cond = slice.missingConditions(); @@ -519,8 +518,8 @@ ConditionsMappedUserPool::prepare(const IOV& required, // This is a critical operation, because we have to ensure the // IOV pools are ONLY manipulated by the current thread. // Otherwise the selection and the population are unsafe! - static mutex lock; - lock_guard guard(lock); + static std::mutex lock; + std::lock_guard guard(lock); m_conditions.clear(); slice_miss_cond.clear(); @@ -598,7 +597,7 @@ ConditionsMappedUserPool::prepare(const IOV& required, // if ( num_calc_miss > 0 ) { if ( do_load ) { - map deps(calc_missing.begin(),last_calc); + std::map deps(calc_missing.begin(),last_calc); ConditionsDependencyHandler handler(m_manager, *this, deps, user_param); /// 1rst pass: Compute/create the missing condiions handler.compute(); @@ -633,7 +632,7 @@ ConditionsMappedUserPool::load(const IOV& required, ConditionsSlice& slice, ConditionUpdateUserContext* /* user_param */) { - typedef vector > CondMissing; + typedef std::vector > CondMissing; const auto& slice_cond = slice.content->conditions(); auto& slice_miss_cond = slice.missingConditions(); bool do_load = m_manager->doLoadConditions(); @@ -644,8 +643,8 @@ ConditionsMappedUserPool::load(const IOV& required, // This is a critical operation, because we have to ensure the // IOV pools are ONLY manipulated by the current thread. // Otherwise the selection and the population are unsafe! - static mutex lock; - lock_guard guard(lock); + static std::mutex lock; + std::lock_guard guard(lock); m_conditions.clear(); slice_miss_cond.clear(); @@ -707,7 +706,7 @@ ConditionsMappedUserPool::compute(const IOV& required, ConditionsSlice& slice, ConditionUpdateUserContext* user_param) { - typedef vector > CalcMissing; + typedef std::vector > CalcMissing; const auto& slice_calc = slice.content->derived(); auto& slice_miss_calc = slice.missingDerivations(); bool do_load = m_manager->doLoadConditions(); @@ -718,8 +717,8 @@ ConditionsMappedUserPool::compute(const IOV& required, // This is a critical operation, because we have to ensure the // IOV pools are ONLY manipulated by the current thread. // Otherwise the selection and the population are unsafe! - static mutex lock; - lock_guard guard(lock); + static std::mutex lock; + std::lock_guard guard(lock); slice_miss_calc.clear(); CalcMissing calc_missing(slice_calc.size()+m_conditions.size()); @@ -741,7 +740,7 @@ ConditionsMappedUserPool::compute(const IOV& required, // if ( num_calc_miss > 0 ) { if ( do_load ) { - map deps(calc_missing.begin(),last_calc); + std::map deps(calc_missing.begin(),last_calc); ConditionsDependencyHandler handler(m_manager, *this, deps, user_param); /// 1rst pass: Compute/create the missing condiions @@ -778,7 +777,7 @@ namespace dd4hep { /// Namespace for implementation details of the AIDA detector description toolkit namespace cond { - typedef unordered_map umap_t; + typedef std::unordered_map umap_t; /// Access all conditions within a given key range /** Specialization necessary, since unordered maps have no lower bound. @@ -796,7 +795,7 @@ namespace dd4hep { */ template<> std::vector ConditionsMappedUserPool::get(Condition::key_type lower, Condition::key_type upper) const { - vector result; + std::vector result; for( const auto& e : m_conditions ) { if ( e.second->hash >= lower && e.second->hash <= upper ) result.emplace_back(e.second); @@ -808,24 +807,24 @@ namespace dd4hep { namespace { template - void* create_pool(Detector&, int argc, char** argv) { + void* create_pool(dd4hep::Detector&, int argc, char** argv) { if ( argc > 1 ) { ConditionsManagerObject* m = (ConditionsManagerObject*)argv[0]; ConditionsIOVPool* p = (ConditionsIOVPool*)argv[1]; UserPool* pool = new ConditionsMappedUserPool(m, p); return pool; } - except("ConditionsMappedUserPool","++ Insufficient arguments: arg[0] = ConditionManager!"); + dd4hep::except("ConditionsMappedUserPool","++ Insufficient arguments: arg[0] = ConditionManager!"); return 0; } } // Factory for the user pool using a binary tree map -void* create_map_user_pool(Detector& description, int argc, char** argv) -{ return create_pool >(description, argc, argv); } +void* create_map_user_pool(dd4hep::Detector& description, int argc, char** argv) +{ return create_pool >(description, argc, argv); } DECLARE_DD4HEP_CONSTRUCTOR(DD4hep_ConditionsMapUserPool, create_map_user_pool) // Factory for the user pool using a binary tree map -void* create_unordered_map_user_pool(Detector& description, int argc, char** argv) -{ return create_pool >(description, argc, argv); } +void* create_unordered_map_user_pool(dd4hep::Detector& description, int argc, char** argv) +{ return create_pool >(description, argc, argv); } DECLARE_DD4HEP_CONSTRUCTOR(DD4hep_ConditionsUnorderedMapUserPool, create_map_user_pool) diff --git a/DDCond/src/plugins/ConditionsXmlLoader.cpp b/DDCond/src/plugins/ConditionsXmlLoader.cpp index 1967bb814..71ae953e7 100644 --- a/DDCond/src/plugins/ConditionsXmlLoader.cpp +++ b/DDCond/src/plugins/ConditionsXmlLoader.cpp @@ -15,8 +15,8 @@ #define DD4HEP_CONDITIONS_XMLCONDITONSLOADER_H // Framework include files -#include "DDCond/ConditionsDataLoader.h" -#include "DD4hep/Printout.h" +#include +#include /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -44,18 +44,18 @@ namespace dd4hep { /// Default destructor virtual ~ConditionsXmlLoader(); /// Load a condition set given a Detector Element and the conditions name according to their validity - virtual size_t load_single(key_type key, - const IOV& req_validity, - RangeConditions& conditions); + virtual std::size_t load_single(key_type key, + const IOV& req_validity, + RangeConditions& conditions); /// Load a condition set given a Detector Element and the conditions name according to their validity - virtual size_t load_range( key_type key, - const IOV& req_validity, - RangeConditions& conditions); + virtual std::size_t load_range( key_type key, + const IOV& req_validity, + RangeConditions& conditions); /// Optimized update using conditions slice data - virtual size_t load_many( const IOV& /* req_validity */, - RequiredItems& /* work */, - LoadedItems& /* loaded */, - IOV& /* conditions_validity */) + virtual std::size_t load_many( const IOV& /* req_validity */, + RequiredItems& /* work */, + LoadedItems& /* loaded */, + IOV& /* conditions_validity */) { except("ConditionsLoader","+++ update: Invalid call!"); return 0; @@ -65,26 +65,24 @@ namespace dd4hep { } /* End namespace dd4hep */ #endif /* DD4HEP_CONDITIONS_XMLCONDITONSLOADER_H */ -//#include "ConditionsXmlLoader.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Factories.h" -#include "DD4hep/PluginCreators.h" -#include "DD4hep/detail/ConditionsInterna.h" +// #include +#include +#include +#include +#include -#include "XML/XMLElements.h" -#include "XML/DocumentHandler.h" -#include "DDCond/ConditionsEntry.h" +#include +#include +#include // C/C++ include files #include // Forward declartions -using std::string; -using namespace dd4hep; using namespace dd4hep::cond; namespace { - void* create_loader(Detector& description, int argc, char** argv) { + void* create_loader(dd4hep::Detector& description, int argc, char** argv) { const char* name = argc>0 ? argv[0] : "XMLLoader"; ConditionsManagerObject* mgr = (ConditionsManagerObject*)(argc>0 ? argv[1] : 0); return new ConditionsXmlLoader(description,ConditionsManager(mgr),name); @@ -107,8 +105,8 @@ size_t ConditionsXmlLoader::load_source(const std::string& nam, const IOV& req_validity, RangeConditions& conditions) { - size_t len = conditions.size(); - string fac = "XMLConditionsParser"; + std::size_t len = conditions.size(); + std::string fac = "XMLConditionsParser"; xml::DocumentHolder doc(xml::DocumentHandler().load(nam)); xml::Handle_t handle = doc.root(); ConditionsStack stack; @@ -136,11 +134,11 @@ size_t ConditionsXmlLoader::load_source(const std::string& nam, return conditions.size()-len; } -size_t ConditionsXmlLoader::load_single(key_type key, - const IOV& req_validity, - RangeConditions& conditions) +std::size_t ConditionsXmlLoader::load_single(key_type key, + const IOV& req_validity, + RangeConditions& conditions) { - size_t len = conditions.size(); + std::size_t len = conditions.size(); if ( m_buffer.empty() && !m_sources.empty() ) { return load_source(m_sources.begin()->first, key, req_validity, conditions); } @@ -158,11 +156,11 @@ size_t ConditionsXmlLoader::load_single(key_type key, return conditions.size()-len; } -size_t ConditionsXmlLoader::load_range(key_type key, - const IOV& req_validity, - RangeConditions& conditions) +std::size_t ConditionsXmlLoader::load_range(key_type key, + const IOV& req_validity, + RangeConditions& conditions) { - size_t len = conditions.size(); + std::size_t len = conditions.size(); while ( !m_sources.empty() ) { load_source(m_sources.begin()->first, key, req_validity, conditions); } @@ -180,4 +178,3 @@ size_t ConditionsXmlLoader::load_range(key_type key, m_buffer = keep; return conditions.size()-len; } - diff --git a/DDCore/include/XML/Layering.h b/DDCore/include/XML/Layering.h index 90becd834..58021b9f0 100644 --- a/DDCore/include/XML/Layering.h +++ b/DDCore/include/XML/Layering.h @@ -15,7 +15,7 @@ #define XML_LAYERING_H // Framework include files -#include "XML/XMLElements.h" +#include // C/C++ include files #include diff --git a/DDCore/src/AlignmentData.cpp b/DDCore/src/AlignmentData.cpp index cdc3af51d..3461f6c13 100644 --- a/DDCore/src/AlignmentData.cpp +++ b/DDCore/src/AlignmentData.cpp @@ -12,18 +12,19 @@ //========================================================================== // Framework include files -#include "DD4hep/AlignmentData.h" -#include "DD4hep/MatrixHelpers.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/DetElement.h" -#include "DD4hep/OpaqueData.h" -#include "DD4hep/Primitives.h" +#include +#include +#include +#include +#include +#include // ROOT include files -#include "TGeoMatrix.h" +#include + +// C/C++ include files #include -using namespace std; using namespace dd4hep; /// Copy constructor @@ -84,12 +85,12 @@ void Delta::computeMatrix(TGeoHMatrix& tr_delta) const { } /// print alignment delta object -ostream& operator << (ostream& ostr, const Delta& data) { - string res; - stringstream str; +std::ostream& operator << (std::ostream& ostr, const Delta& data) { + std::string res; + std::stringstream str; str << "[" << data.translation << "," << data.rotation << "," << data.pivot << "]"; res = str.str(); - for(size_t i=0; i static auto s_registry = GrammarRegistry::pre_note(1) .pre_note(1) .pre_note >(1); diff --git a/DDCore/src/AlignmentNominalMap.cpp b/DDCore/src/AlignmentNominalMap.cpp index 547ebb5ac..c4d6569c8 100644 --- a/DDCore/src/AlignmentNominalMap.cpp +++ b/DDCore/src/AlignmentNominalMap.cpp @@ -12,11 +12,11 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/DetectorProcessor.h" -#include "DD4hep/AlignmentsNominalMap.h" -#include "DD4hep/detail/AlignmentsInterna.h" -#include "DD4hep/detail/ConditionsInterna.h" +#include +#include +#include +#include +#include using namespace dd4hep; using align::Keys; diff --git a/DDCore/src/AlignmentTools.cpp b/DDCore/src/AlignmentTools.cpp index 68628aef6..4315cf591 100644 --- a/DDCore/src/AlignmentTools.cpp +++ b/DDCore/src/AlignmentTools.cpp @@ -12,16 +12,16 @@ //========================================================================== // Framework include files -#include "DD4hep/IOV.h" -#include "DD4hep/Printout.h" -#include "DD4hep/MatrixHelpers.h" -#include "DD4hep/AlignmentTools.h" -#include "DD4hep/DetectorTools.h" -#include "DD4hep/detail/DetectorInterna.h" -#include "DD4hep/detail/AlignmentsInterna.h" +#include +#include +#include +#include +#include +#include +#include // ROOT include files -#include "TGeoMatrix.h" +#include using dd4hep::PlacedVolume; using dd4hep::Alignment; diff --git a/DDCore/src/Alignments.cpp b/DDCore/src/Alignments.cpp index d870e1ab1..124a63f12 100644 --- a/DDCore/src/Alignments.cpp +++ b/DDCore/src/Alignments.cpp @@ -12,22 +12,20 @@ //========================================================================== // Framework include files -#include "DD4hep/AlignmentData.h" -#include "DD4hep/detail/AlignmentsInterna.h" -#include "DD4hep/detail/ConditionsInterna.h" +#include +#include +#include // C/C++ include files #include - -using namespace std; using namespace dd4hep; -const string dd4hep::align::Keys::deltaName("alignment_delta"); +const std::string dd4hep::align::Keys::deltaName("alignment_delta"); const dd4hep::Condition::itemkey_type dd4hep::align::Keys::deltaKey = dd4hep::ConditionKey::itemCode("alignment_delta"); -const string dd4hep::align::Keys::alignmentName("alignment"); +const std::string dd4hep::align::Keys::alignmentName("alignment"); const dd4hep::Condition::itemkey_type dd4hep::align::Keys::alignmentKey = dd4hep::ConditionKey::itemCode("alignment"); @@ -36,7 +34,7 @@ Alignment::Processor::Processor() { } /// Initializing constructor to create a new object (Specialized for AlignmentNamedObject) -Alignment::Alignment(const string& nam) { +Alignment::Alignment(const std::string& nam) { char* p = (char*)::operator new(sizeof(Object)+sizeof(AlignmentData)); Object* o = new(p) Object(nam, "alignment", p+sizeof(Object), sizeof(AlignmentData)); assign(o, nam, "alignment"); @@ -44,7 +42,7 @@ Alignment::Alignment(const string& nam) { } /// Initializing constructor to create a new object (Specialized for AlignmentObject) -AlignmentCondition::AlignmentCondition(const string& nam) { +AlignmentCondition::AlignmentCondition(const std::string& nam) { char* p = (char*)::operator new(sizeof(Object)+sizeof(AlignmentData)); Object* o = new(p) Object(nam, "alignment", p+sizeof(Object), sizeof(AlignmentData)); assign(o, nam, "alignment"); @@ -77,7 +75,7 @@ const TGeoHMatrix& Alignment::detectorTransformation() const { } /// Access to the node list -const vector& Alignment::nodes() const { +const std::vector& Alignment::nodes() const { return access()->values().nodes; } diff --git a/DDCore/src/AlignmentsCalculator.cpp b/DDCore/src/AlignmentsCalculator.cpp index f9710d840..1e6452c7e 100644 --- a/DDCore/src/AlignmentsCalculator.cpp +++ b/DDCore/src/AlignmentsCalculator.cpp @@ -12,20 +12,20 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/Conditions.h" -#include "DD4hep/ConditionsMap.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/MatrixHelpers.h" -#include "DD4hep/ConditionDerived.h" -#include "DD4hep/DetectorProcessor.h" -#include "DD4hep/AlignmentsProcessor.h" -#include "DD4hep/AlignmentsCalculator.h" -#include "DD4hep/detail/AlignmentsInterna.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace dd4hep; using namespace dd4hep::align; -typedef AlignmentsCalculator::Result Result; +using Result = AlignmentsCalculator::Result; /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -72,8 +72,8 @@ namespace dd4hep { class Calculator::Context { public: - typedef std::map DetectorMap; - typedef std::map Keys; + typedef std::map DetectorMap; + typedef std::map Keys; typedef std::vector Entries; DetectorMap detectors; @@ -324,5 +324,5 @@ size_t AlignmentsCalculator::extract_deltas(DetElement start, return deltas.size(); } -#include "DD4hep/GrammarUnparsed.h" +#include static auto s_registry = GrammarRegistry::pre_note(1); diff --git a/DDCore/src/AlignmentsInterna.cpp b/DDCore/src/AlignmentsInterna.cpp index e8a3be4f8..a874636a0 100644 --- a/DDCore/src/AlignmentsInterna.cpp +++ b/DDCore/src/AlignmentsInterna.cpp @@ -12,17 +12,16 @@ //========================================================================== // Framework includes -#include "DD4hep/IOV.h" -#include "DD4hep/World.h" -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/detail/Handle.inl" -#include "DD4hep/detail/DetectorInterna.h" -#include "DD4hep/detail/AlignmentsInterna.h" +#include +#include +#include +#include +#include +#include +#include -using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; +using AlignmentObject = detail::AlignmentObject; DD4HEP_INSTANTIATE_HANDLE_UNNAMED(AlignmentData); #if defined(DD4HEP_MINIMAL_CONDITIONS) @@ -42,7 +41,7 @@ AlignmentObject::AlignmentObject() } /// Standard constructor -AlignmentObject::AlignmentObject(const string& nam, const string& tit, void* p, size_t len) +AlignmentObject::AlignmentObject(const std::string& nam, const std::string& tit, void* p, size_t len) : ConditionObject(nam, tit), alignment_data(0) { InstanceCount::increment(this); @@ -67,5 +66,5 @@ void AlignmentObject::clear() { flags = Condition::ALIGNMENT_DERIVED; } -#include "DD4hep/GrammarUnparsed.h" +#include static auto s_registry = GrammarRegistry::pre_note(); diff --git a/DDCore/src/AlignmentsPrinter.cpp b/DDCore/src/AlignmentsPrinter.cpp index 49e0139e8..7de759f07 100644 --- a/DDCore/src/AlignmentsPrinter.cpp +++ b/DDCore/src/AlignmentsPrinter.cpp @@ -12,22 +12,21 @@ //========================================================================== // Framework includes -#include "Parsers/Parsers.h" -#include "DD4hep/Printout.h" -#include "DD4hep/AlignmentsPrinter.h" -#include "DD4hep/AlignmentsProcessor.h" -#include "DD4hep/detail/AlignmentsInterna.h" +#include +#include +#include +#include +#include +#include // C/C++ include files #include -#include "TClass.h" -using namespace std; using namespace dd4hep; using namespace dd4hep::align; /// Initializing constructor -AlignmentsPrinter::AlignmentsPrinter(ConditionsMap* cond_map, const string& pref, int flg) +AlignmentsPrinter::AlignmentsPrinter(ConditionsMap* cond_map, const std::string& pref, int flg) : mapping(cond_map), name("Alignment"), prefix(pref), printLevel(INFO), m_flag(flg) { } @@ -41,7 +40,7 @@ int AlignmentsPrinter::operator()(Alignment a) const { /// Callback to output alignments information of an entire DetElement int AlignmentsPrinter::operator()(DetElement de, int level) const { if ( mapping ) { - vector alignments; + std::vector alignments; alignmentsCollector(*mapping,alignments)(de, level); printout(printLevel, name, "++ %s %-3ld Alignments for DE %s", prefix.c_str(), alignments.size(), de.path().c_str()); @@ -55,7 +54,7 @@ int AlignmentsPrinter::operator()(DetElement de, int level) const { } /// Initializing constructor -AlignedVolumePrinter::AlignedVolumePrinter(ConditionsMap* cond_map, const string& pref,int flg) +AlignedVolumePrinter::AlignedVolumePrinter(ConditionsMap* cond_map, const std::string& pref,int flg) : AlignmentsPrinter(cond_map, pref, flg) { name = "Alignment"; @@ -68,12 +67,12 @@ int AlignedVolumePrinter::operator()(Alignment a) const { } /// Default printout of an alignment entry -void dd4hep::align::printAlignment(PrintLevel lvl, const string& prefix, Alignment a) { +void dd4hep::align::printAlignment(PrintLevel lvl, const std::string& prefix, Alignment a) { if ( a.isValid() ) { Alignment::Object* ptr = a.ptr(); const AlignmentData& data = a.data(); const Delta& D = data.delta; - string new_prefix = prefix; + std::string new_prefix = prefix; new_prefix.assign(prefix.length(),' '); printout(lvl,prefix,"++ %s \t [%p] Typ:%s", new_prefix.c_str(), a.ptr(), @@ -90,14 +89,14 @@ void dd4hep::align::printAlignment(PrintLevel lvl, const string& prefix, Alignme } } -static string replace_all(const string& in, const string& from, const string& to) { - string res = in; - size_t idx; - while( string::npos != (idx=res.find(from)) ) +static std::string replace_all(const std::string& in, const std::string& from, const std::string& to) { + std::string res = in; + std::size_t idx; + while( std::string::npos != (idx=res.find(from)) ) res.replace(idx,from.length(),to); return res; } -static string _transformPoint2World(const AlignmentData& data, const Position& local) { +static std::string _transformPoint2World(const AlignmentData& data, const Position& local) { char text[256]; Position world = data.localToWorld(local); ::snprintf(text,sizeof(text),"Local: (%7.3f , %7.3f , %7.3f ) -- > World: (%7.3f , %7.3f , %7.3f )", @@ -105,7 +104,7 @@ static string _transformPoint2World(const AlignmentData& data, const Position& l return text; } -static string _transformPoint2Detector(const AlignmentData& data, const Position& local) { +static std::string _transformPoint2Detector(const AlignmentData& data, const Position& local) { char text[256]; Position world = data.localToDetector(local); ::snprintf(text,sizeof(text),"Local: (%7.3f , %7.3f , %7.3f ) -- > Parent: (%7.3f , %7.3f , %7.3f )", @@ -113,14 +112,14 @@ static string _transformPoint2Detector(const AlignmentData& data, const Position return text; } -void dd4hep::align::printAlignment(PrintLevel lvl, const string& prefix, - const string& opt, DetElement de, Alignment alignment) +void dd4hep::align::printAlignment(PrintLevel lvl, const std::string& prefix, + const std::string& opt, DetElement de, Alignment alignment) { - const string& tag = prefix; + const std::string& tag = prefix; const AlignmentData& align_data = alignment.data(); Condition align_cond;// = align_data.condition; const Delta& align_delta = align_data.delta; - string par = de.parent().isValid() ? de.parent().path() : string(); + std::string par = de.parent().isValid() ? de.parent().path() : std::string(); Box bbox = de.placement().volume().solid(); /// The edge positions of the bounding box: Position p1( bbox.x(), bbox.y(), bbox.z()); @@ -148,22 +147,22 @@ void dd4hep::align::printAlignment(PrintLevel lvl, const string& prefix, alignment.ptr()); } if ( align_delta.hasTranslation() ) { - stringstream str; + std::stringstream str; Position copy(align_delta.translation * (1./dd4hep::cm)); Parsers::toStream(copy, str); printout(lvl,tag,"++ %s DELTA Translation: %s [cm]", opt.c_str(), replace_all(str.str(),"\n","").c_str()); } if ( align_delta.hasPivot() ) { - stringstream str; + std::stringstream str; Delta::Pivot copy(align_delta.pivot.Vect() * (1./dd4hep::cm)); Parsers::toStream(copy, str); - string res = replace_all(str.str(),"\n",""); + std::string res = replace_all(str.str(),"\n",""); res = "( "+replace_all(res," "," , ")+" )"; printout(lvl,tag,"++ %s DELTA Pivot: %s [cm]", opt.c_str(), res.c_str()); } if ( align_delta.hasRotation() ) { - stringstream str; + std::stringstream str; Parsers::toStream(align_delta.rotation, str); printout(lvl,tag,"++ %s DELTA Rotation: %s [rad]", opt.c_str(), replace_all(str.str(),"\n","").c_str()); } @@ -193,10 +192,10 @@ void dd4hep::align::printAlignment(PrintLevel lvl, const string& prefix, } /// Default printout of a detector element entry -void dd4hep::align::printElement(PrintLevel prt_level, const string& prefix, DetElement de, ConditionsMap& pool) { - string tag = prefix+"Element"; +void dd4hep::align::printElement(PrintLevel prt_level, const std::string& prefix, DetElement de, ConditionsMap& pool) { + std::string tag = prefix+"Element"; if ( de.isValid() ) { - vector alignments; + std::vector alignments; alignmentsCollector(pool,alignments)(de); printout(prt_level,tag,"++ Alignments of DE %s [%d entries]", de.path().c_str(), int(alignments.size())); @@ -208,13 +207,13 @@ void dd4hep::align::printElement(PrintLevel prt_level, const string& prefix, Det } /// PrintElement placement with/without alignment applied -void dd4hep::align::printElementPlacement(PrintLevel lvl, const string& prefix, DetElement de, ConditionsMap& pool) { - string tag = prefix+"Element"; +void dd4hep::align::printElementPlacement(PrintLevel lvl, const std::string& prefix, DetElement de, ConditionsMap& pool) { + std::string tag = prefix+"Element"; if ( de.isValid() ) { char text[132]; Alignment nominal = de.nominal(); Box bbox = de.placement().volume().solid(); - vector alignments; + std::vector alignments; alignmentsCollector(pool,alignments)(de); ::memset(text,'=',sizeof(text)); diff --git a/DDCore/src/AlignmentsProcessor.cpp b/DDCore/src/AlignmentsProcessor.cpp index 1659a1acb..eabe06478 100644 --- a/DDCore/src/AlignmentsProcessor.cpp +++ b/DDCore/src/AlignmentsProcessor.cpp @@ -12,13 +12,12 @@ //========================================================================== // Framework includes -#include "DD4hep/Printout.h" -#include "DD4hep/AlignmentsProcessor.h" -#include "DD4hep/ConditionsProcessor.h" -#include "DD4hep/detail/ContainerHelpers.h" -#include "DD4hep/detail/ConditionsInterna.h" +#include +#include +#include +#include +#include -using namespace std; using namespace dd4hep; using namespace dd4hep::align; @@ -27,7 +26,7 @@ template int DeltaCollector::operator()(DetElement de, int level) const { if ( de.isValid() ) { int count = 0; - vector conditions; + std::vector conditions; cond::conditionsCollector(mapping,conditions)(de,level); for( auto cond : conditions ) { if ( cond->testFlag(Condition::ALIGNMENT_DELTA) ) { @@ -46,7 +45,7 @@ template int AlignmentsCollector::operator()(DetElement de, int level) const { if ( de.isValid() ) { int count = 0; - vector conditions; + std::vector conditions; cond::conditionsCollector(mapping,conditions)(de,level); for( auto cond : conditions ) { if ( cond->testFlag(Condition::ALIGNMENT_DERIVED) ) { @@ -68,26 +67,26 @@ namespace dd4hep { /// Namespace for the AIDA detector description toolkit supporting XML utilities namespace align { - template class DeltaCollector >; - template class DeltaCollector >; - template class DeltaCollector >; - template class DeltaCollector > >; - template class DeltaCollector > >; + template class DeltaCollector >; + template class DeltaCollector >; + template class DeltaCollector >; + template class DeltaCollector > >; + template class DeltaCollector > >; - template class DeltaCollector >; - template class DeltaCollector >; - template class DeltaCollector >; + template class DeltaCollector >; + template class DeltaCollector >; + template class DeltaCollector >; - template class AlignmentsCollector >; - template class AlignmentsCollector >; - template class AlignmentsCollector >; - template class AlignmentsCollector > >; - template class AlignmentsCollector > >; + template class AlignmentsCollector >; + template class AlignmentsCollector >; + template class AlignmentsCollector >; + template class AlignmentsCollector > >; + template class AlignmentsCollector > >; - template class AlignmentsCollector >; - template class AlignmentsCollector >; - template class AlignmentsCollector >; + template class AlignmentsCollector >; + template class AlignmentsCollector >; + template class AlignmentsCollector >; } /* End namespace align */ } /* End namespace dd4hep */ diff --git a/DDCore/src/BuildType.cpp b/DDCore/src/BuildType.cpp index 05b3e4dfe..8eb690142 100644 --- a/DDCore/src/BuildType.cpp +++ b/DDCore/src/BuildType.cpp @@ -12,7 +12,7 @@ //========================================================================== // Framework includes -#include "DD4hep/BuildType.h" +#include // C/C++ include files #include diff --git a/DDCore/src/Callback.cpp b/DDCore/src/Callback.cpp index c28ded38d..c943f1720 100644 --- a/DDCore/src/Callback.cpp +++ b/DDCore/src/Callback.cpp @@ -12,13 +12,11 @@ //========================================================================== // Framework include files -#include "DD4hep/Callback.h" -#include "DD4hep/Exceptions.h" - -using namespace dd4hep; +#include +#include /// Check the compatibility of two typed objects. The test is the result of a dynamic_cast -void CallbackSequence::checkTypes(const std::type_info& typ1, const std::type_info& typ2, void* test) { +void dd4hep::CallbackSequence::checkTypes(const std::type_info& typ1, const std::type_info& typ2, void* test) { if (!test) { throw unrelated_type_error(typ1, typ2, "Cannot install a callback for these 2 types."); } diff --git a/DDCore/src/CartesianGridXY.cpp b/DDCore/src/CartesianGridXY.cpp index 949aefba3..daa7d155f 100644 --- a/DDCore/src/CartesianGridXY.cpp +++ b/DDCore/src/CartesianGridXY.cpp @@ -12,12 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/CartesianGridXY.h" -#include "DDSegmentation/CartesianGridXY.h" +#include +#include -// C/C++ include files - -using namespace std; using namespace dd4hep; /// determine the position based on the cell ID @@ -74,12 +71,12 @@ void CartesianGridXY::setOffsetY(double offset) const { } /// access the field name used for X -const string& CartesianGridXY::fieldNameX() const { +const std::string& CartesianGridXY::fieldNameX() const { return access()->implementation->fieldNameX(); } /// access the field name used for Y -const string& CartesianGridXY::fieldNameY() const { +const std::string& CartesianGridXY::fieldNameY() const { return access()->implementation->fieldNameY(); } @@ -92,6 +89,6 @@ const string& CartesianGridXY::fieldNameY() const { -# size in x -# size in y */ -vector CartesianGridXY::cellDimensions(const CellID& id) const { +std::vector CartesianGridXY::cellDimensions(const CellID& id) const { return access()->implementation->cellDimensions(id); } diff --git a/DDCore/src/CartesianGridXYZ.cpp b/DDCore/src/CartesianGridXYZ.cpp index ae4017c7a..bd610e524 100644 --- a/DDCore/src/CartesianGridXYZ.cpp +++ b/DDCore/src/CartesianGridXYZ.cpp @@ -12,12 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/CartesianGridXYZ.h" -#include "DDSegmentation/CartesianGridXYZ.h" +#include +#include -// C/C++ include files - -using namespace std; using namespace dd4hep; /// determine the position based on the cell ID @@ -94,17 +91,17 @@ void CartesianGridXYZ::setOffsetZ(double offset) const { } /// access the field name used for X -const string& CartesianGridXYZ::fieldNameX() const { +const std::string& CartesianGridXYZ::fieldNameX() const { return access()->implementation->fieldNameX(); } /// access the field name used for Y -const string& CartesianGridXYZ::fieldNameY() const { +const std::string& CartesianGridXYZ::fieldNameY() const { return access()->implementation->fieldNameY(); } /// access the field name used for Z -const string& CartesianGridXYZ::fieldNameZ() const { +const std::string& CartesianGridXYZ::fieldNameZ() const { return access()->implementation->fieldNameZ(); } @@ -118,6 +115,6 @@ const string& CartesianGridXYZ::fieldNameZ() const { -# size in y -# size in z */ -vector CartesianGridXYZ::cellDimensions(const CellID& id) const { +std::vector CartesianGridXYZ::cellDimensions(const CellID& id) const { return access()->implementation->cellDimensions(id); } diff --git a/DDCore/src/CartesianGridXZ.cpp b/DDCore/src/CartesianGridXZ.cpp index 8bc00bd89..907559173 100644 --- a/DDCore/src/CartesianGridXZ.cpp +++ b/DDCore/src/CartesianGridXZ.cpp @@ -12,12 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/CartesianGridXZ.h" -#include "DDSegmentation/CartesianGridXZ.h" +#include +#include -// C/C++ include files - -using namespace std; using namespace dd4hep; /// determine the position based on the cell ID @@ -74,12 +71,12 @@ void CartesianGridXZ::setOffsetZ(double offset) const { } /// access the field name used for X -const string& CartesianGridXZ::fieldNameX() const { +const std::string& CartesianGridXZ::fieldNameX() const { return access()->implementation->fieldNameX(); } /// access the field name used for Z -const string& CartesianGridXZ::fieldNameZ() const { +const std::string& CartesianGridXZ::fieldNameZ() const { return access()->implementation->fieldNameZ(); } @@ -92,6 +89,6 @@ const string& CartesianGridXZ::fieldNameZ() const { -# size in x -# size in z */ -vector CartesianGridXZ::cellDimensions(const CellID& id) const { +std::vector CartesianGridXZ::cellDimensions(const CellID& id) const { return access()->implementation->cellDimensions(id); } diff --git a/DDCore/src/CartesianGridYZ.cpp b/DDCore/src/CartesianGridYZ.cpp index a7fbc27a6..4a9ab3e03 100644 --- a/DDCore/src/CartesianGridYZ.cpp +++ b/DDCore/src/CartesianGridYZ.cpp @@ -12,12 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/CartesianGridYZ.h" -#include "DDSegmentation/CartesianGridYZ.h" +#include +#include -// C/C++ include files - -using namespace std; using namespace dd4hep; /// determine the position based on the cell ID @@ -74,12 +71,12 @@ void CartesianGridYZ::setOffsetZ(double offset) const { } /// access the field name used for Y -const string& CartesianGridYZ::fieldNameY() const { +const std::string& CartesianGridYZ::fieldNameY() const { return access()->implementation->fieldNameY(); } /// access the field name used for Z -const string& CartesianGridYZ::fieldNameZ() const { +const std::string& CartesianGridYZ::fieldNameZ() const { return access()->implementation->fieldNameZ(); } @@ -92,6 +89,6 @@ const string& CartesianGridYZ::fieldNameZ() const { -# size in y -# size in z */ -vector CartesianGridYZ::cellDimensions(const CellID& id) const { +std::vector CartesianGridYZ::cellDimensions(const CellID& id) const { return access()->implementation->cellDimensions(id); } diff --git a/DDCore/src/CartesianStripX.cpp b/DDCore/src/CartesianStripX.cpp index 413150051..653fa590c 100644 --- a/DDCore/src/CartesianStripX.cpp +++ b/DDCore/src/CartesianStripX.cpp @@ -12,10 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/CartesianStripX.h" -#include "DDSegmentation/CartesianStripX.h" +#include +#include -using namespace std; using namespace dd4hep; /// determine the position based on the cell ID @@ -44,7 +43,7 @@ double CartesianStripX::offsetX() const { return access()->implementation->offse void CartesianStripX::setOffsetX(double offset) const { access()->implementation->setOffsetX(offset); } /// access the field name used for X -const string& CartesianStripX::fieldNameX() const { return access()->implementation->fieldNameX(); } +const std::string& CartesianStripX::fieldNameX() const { return access()->implementation->fieldNameX(); } /** \brief Returns a vector of the cellDimensions of the given cell ID in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi @@ -55,6 +54,6 @@ const string& CartesianStripX::fieldNameX() const { return access()->implementat -# size in x -# size in y */ -vector CartesianStripX::cellDimensions(const CellID& id) const { +std::vector CartesianStripX::cellDimensions(const CellID& id) const { return access()->implementation->cellDimensions(id); } diff --git a/DDCore/src/CartesianStripY.cpp b/DDCore/src/CartesianStripY.cpp index 91e38b48b..a75fe16cc 100644 --- a/DDCore/src/CartesianStripY.cpp +++ b/DDCore/src/CartesianStripY.cpp @@ -12,10 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/CartesianStripY.h" -#include "DDSegmentation/CartesianStripY.h" +#include +#include -using namespace std; using namespace dd4hep; /// determine the position based on the cell ID @@ -44,7 +43,7 @@ double CartesianStripY::offsetY() const { return access()->implementation->offse void CartesianStripY::setOffsetY(double offset) const { access()->implementation->setOffsetY(offset); } /// access the field name used for Y -const string& CartesianStripY::fieldNameY() const { return access()->implementation->fieldNameY(); } +const std::string& CartesianStripY::fieldNameY() const { return access()->implementation->fieldNameY(); } /** \brief Returns a vector of the cellDimensions of the given cell ID in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi @@ -55,6 +54,6 @@ const string& CartesianStripY::fieldNameY() const { return access()->implementat -# size in x -# size in y */ -vector CartesianStripY::cellDimensions(const CellID& id) const { +std::vector CartesianStripY::cellDimensions(const CellID& id) const { return access()->implementation->cellDimensions(id); } diff --git a/DDCore/src/CartesianStripZ.cpp b/DDCore/src/CartesianStripZ.cpp index 8ea1333f2..72336031c 100644 --- a/DDCore/src/CartesianStripZ.cpp +++ b/DDCore/src/CartesianStripZ.cpp @@ -12,10 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/CartesianStripZ.h" -#include "DDSegmentation/CartesianStripZ.h" +#include +#include -using namespace std; using namespace dd4hep; /// determine the position based on the cell ID @@ -44,7 +43,7 @@ double CartesianStripZ::offsetZ() const { return access()->implementation->offse void CartesianStripZ::setOffsetZ(double offset) const { access()->implementation->setOffsetZ(offset); } /// access the field name used for Z -const string& CartesianStripZ::fieldNameZ() const { return access()->implementation->fieldNameZ(); } +const std::string& CartesianStripZ::fieldNameZ() const { return access()->implementation->fieldNameZ(); } /** \brief Returns a vector of the cellDimensions of the given cell ID in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi @@ -55,6 +54,6 @@ const string& CartesianStripZ::fieldNameZ() const { return access()->implementat -# size in x -# size in y */ -vector CartesianStripZ::cellDimensions(const CellID& id) const { +std::vector CartesianStripZ::cellDimensions(const CellID& id) const { return access()->implementation->cellDimensions(id); } diff --git a/DDCore/src/ComponentProperties.cpp b/DDCore/src/ComponentProperties.cpp index 429e2b2f2..148f4d8b2 100644 --- a/DDCore/src/ComponentProperties.cpp +++ b/DDCore/src/ComponentProperties.cpp @@ -12,45 +12,44 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/Primitives.h" -#include "Parsers/Parsers.h" -#include "DD4hep/ComponentProperties.h" +#include +#include +#include +#include // C/C++ include files #include #include -using namespace std; using namespace dd4hep; /// Property type name -string Property::type(const Property& property) { +std::string Property::type(const Property& property) { return type(property.grammar().type()); } /// Property type name -string Property::type(const type_info& typ) { +std::string Property::type(const std::type_info& typ) { return typeName(typ); } /// Property type name -string Property::type() const { +std::string Property::type() const { return Property::type(grammar().type()); } const BasicGrammar& Property::grammar() const { if ( m_hdl ) return *m_hdl; - throw runtime_error("Attempt to access property grammar from invalid object."); + throw std::runtime_error("Attempt to access property grammar from invalid object."); } /// Conversion to string value -string Property::str() const { +std::string Property::str() const { if ( m_hdl && m_par ) { return m_hdl->str(m_par); } - throw runtime_error("Attempt to access property grammar from invalid object."); + throw std::runtime_error("Attempt to access property grammar from invalid object."); } /// Conversion from string value @@ -59,7 +58,7 @@ const Property& Property::str(const std::string& input) const { m_hdl->fromString(m_par,input); return *this; } - throw runtime_error("Attempt to access property grammar from invalid object."); + throw std::runtime_error("Attempt to access property grammar from invalid object."); } /// Conversion from string value @@ -68,16 +67,16 @@ Property& Property::str(const std::string& input) { m_hdl->fromString(m_par,input); return *this; } - throw runtime_error("Attempt to access property grammar from invalid object."); + throw std::runtime_error("Attempt to access property grammar from invalid object."); } /// Assignment operator / set new balue Property& Property::operator=(const char* val) { if ( val ) { - this->set < string > (val); + this->set < std::string > (val); return *this; } - throw runtime_error("Attempt to set invalid string to property!"); + throw std::runtime_error("Attempt to set invalid string to property!"); } /// Default constructor @@ -106,53 +105,53 @@ bool PropertyManager::exists(const std::string& name) const { } /// Verify that this property does not exist (throw exception if the name was found) -void PropertyManager::verifyNonExistence(const string& name) const { +void PropertyManager::verifyNonExistence(const std::string& name) const { Properties::const_iterator i = m_properties.find(name); if (i == m_properties.end()) return; - throw runtime_error("The property:" + name + " already exists for this component."); + throw std::runtime_error("The property:" + name + " already exists for this component."); } /// Verify that this property exists (throw exception if the name was not found) PropertyManager::Properties::const_iterator -PropertyManager::verifyExistence(const string& name) const { +PropertyManager::verifyExistence(const std::string& name) const { Properties::const_iterator i = m_properties.find(name); if (i != m_properties.end()) return i; - throw runtime_error("PropertyManager: Unknown property:" + name); + throw std::runtime_error("PropertyManager: Unknown property:" + name); } /// Verify that this property exists (throw exception if the name was not found) PropertyManager::Properties::iterator -PropertyManager::verifyExistence(const string& name) { +PropertyManager::verifyExistence(const std::string& name) { Properties::iterator i = m_properties.find(name); if (i != m_properties.end()) return i; - throw runtime_error("PropertyManager: Unknown property:" + name); + throw std::runtime_error("PropertyManager: Unknown property:" + name); } /// Access property by name (CONST) -Property& PropertyManager::property(const string& name) { +Property& PropertyManager::property(const std::string& name) { return (*verifyExistence(name)).second; } /// Access property by name -const Property& PropertyManager::property(const string& name) const { +const Property& PropertyManager::property(const std::string& name) const { return (*verifyExistence(name)).second; } /// Access property by name -Property& PropertyManager::operator[](const string& name) { +Property& PropertyManager::operator[](const std::string& name) { return (*verifyExistence(name)).second; } /// Access property by name -const Property& PropertyManager::operator[](const string& name) const { +const Property& PropertyManager::operator[](const std::string& name) const { return (*verifyExistence(name)).second; } /// Add a new property -void PropertyManager::add(const string& name, const Property& prop) { +void PropertyManager::add(const std::string& name, const Property& prop) { verifyNonExistence(name); m_properties.emplace(name, prop); } @@ -173,16 +172,16 @@ PropertyConfigurable::~PropertyConfigurable() { } /// Check property for existence -bool PropertyConfigurable::hasProperty(const string& nam) const { +bool PropertyConfigurable::hasProperty(const std::string& nam) const { return m_properties.exists(nam); } /// Access single property -Property& PropertyConfigurable::property(const string& nam) { +Property& PropertyConfigurable::property(const std::string& nam) { return properties()[nam]; } -#include "DD4hep/GrammarParsed.h" +#include namespace dd4hep { namespace Parsers { template <> int parse(Property& result, const std::string& input) { diff --git a/DDCore/src/ConditionAny.cpp b/DDCore/src/ConditionAny.cpp index 7e974f493..60cf360a2 100644 --- a/DDCore/src/ConditionAny.cpp +++ b/DDCore/src/ConditionAny.cpp @@ -12,9 +12,9 @@ //========================================================================== // Framework includes -#include "DD4hep/Printout.h" -#include "DD4hep/ConditionAny.h" -#include "DD4hep/detail/ConditionsInterna.h" +#include +#include +#include // C/C++ include files #include diff --git a/DDCore/src/ConditionDerived.cpp b/DDCore/src/ConditionDerived.cpp index 1ebd6c2ba..1f99f1926 100644 --- a/DDCore/src/ConditionDerived.cpp +++ b/DDCore/src/ConditionDerived.cpp @@ -12,10 +12,10 @@ //========================================================================== // Framework includes -#include "DD4hep/Printout.h" -#include "DD4hep/Detector.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/ConditionDerived.h" +#include +#include +#include +#include // C/C++ include files diff --git a/DDCore/src/Conditions.cpp b/DDCore/src/Conditions.cpp index eb4b66c3b..9f5667b82 100644 --- a/DDCore/src/Conditions.cpp +++ b/DDCore/src/Conditions.cpp @@ -12,25 +12,24 @@ //========================================================================== // Framework includes -#include "DD4hep/Printout.h" -#include "DD4hep/detail/ConditionsInterna.h" +#include +#include // C/C++ include files #include #include #include -using namespace std; using namespace dd4hep; namespace { int s_have_inventory = 0; struct KeyTracer { - map item_names; - mutex lock; - void add(Condition::itemkey_type key,const string& item) { + std::map item_names; + std::mutex lock; + void add(Condition::itemkey_type key,const std::string& item) { if ( s_have_inventory > 0 ) { - std::lock_guard protect(lock); + std::lock_guard protect(lock); item_names.emplace(key, item); } } @@ -40,7 +39,7 @@ namespace { return (*i).second; } char text[32]; - ::snprintf(text,sizeof(text),"%08X",key); + std::snprintf(text,sizeof(text),"%08X",key); return text; } } s_key_tracer; @@ -75,7 +74,7 @@ Condition::Condition(key_type hash_key) : Handle() } /// Initializing constructor for a pure, undecorated conditions object -Condition::Condition(const string& nam, const string& typ) : Handle() +Condition::Condition(const std::string& nam, const std::string& typ) : Handle() { Object* o = new Object(); assign(o,nam,typ); @@ -83,7 +82,7 @@ Condition::Condition(const string& nam, const string& typ) : Handle() } /// Initializing constructor for a pure, undecorated conditions object with payload buffer -Condition::Condition(const string& nam,const string& typ, size_t memory) +Condition::Condition(const std::string& nam,const std::string& typ, size_t memory) : Handle() { void* ptr = ::operator new(sizeof(Object)+memory); @@ -93,12 +92,12 @@ Condition::Condition(const string& nam,const string& typ, size_t memory) } /// Output method -string Condition::str(int flags) const { - stringstream output; +std::string Condition::str(int flags) const { + std::stringstream output; Object* o = access(); #if defined(DD4HEP_CONDITIONS_HAVE_NAME) if ( 0 == (flags&NO_NAME) ) - output << setw(16) << left << o->name; + output << std::setw(16) << std::left << o->name; #endif if ( flags&WITH_IOV ) { const IOV* ptr_iov = o->iovData(); @@ -143,28 +142,28 @@ const dd4hep::IOV& Condition::iov() const { #if !defined(DD4HEP_MINIMAL_CONDITIONS) /// Access the type field of the condition -const string& Condition::type() const { +const std::string& Condition::type() const { return access()->type; } /// Access the value field of the condition as a string -const string& Condition::value() const { +const std::string& Condition::value() const { return access()->value; } /// Access the comment field of the condition -const string& Condition::comment() const { +const std::string& Condition::comment() const { return access()->comment; } /// Access the address string [e.g. database identifier] -const string& Condition::address() const { +const std::string& Condition::address() const { return access()->address; } #endif /// Access to the type information -const type_info& Condition::typeInfo() const { +const std::type_info& Condition::typeInfo() const { return descriptor().type(); } @@ -210,7 +209,7 @@ const dd4hep::BasicGrammar& Condition::descriptor() const { invalidHandleError(); // This code is never reached, since function above throws exception! // Needed to satisfay CppCheck - throw runtime_error("Null pointer in Grammar object"); + throw std::runtime_error("Null pointer in Grammar object"); } return *grammar; } @@ -220,7 +219,7 @@ ConditionsSelect::~ConditionsSelect() { } /// Constructor from string -ConditionKey::KeyMaker::KeyMaker(DetElement detector, const string& value) { +ConditionKey::KeyMaker::KeyMaker(DetElement detector, const std::string& value) { KeyMaker key_maker(detector.key(), detail::hash32(value)); hash = key_maker.hash; s_key_tracer.add(key_maker.values.item_key, value); @@ -232,14 +231,14 @@ ConditionKey::KeyMaker::KeyMaker(DetElement detector, Condition::itemkey_type it } /// Constructor from string -ConditionKey::KeyMaker::KeyMaker(Condition::detkey_type det_key, const string& value) { +ConditionKey::KeyMaker::KeyMaker(Condition::detkey_type det_key, const std::string& value) { KeyMaker key_maker(det_key, detail::hash32(value)); hash = key_maker.hash; s_key_tracer.add(key_maker.values.item_key, value); } /// Constructor from string -ConditionKey::ConditionKey(DetElement detector, const string& value) { +ConditionKey::ConditionKey(DetElement detector, const std::string& value) { KeyMaker key_maker(detector.key(), value); hash = key_maker.hash; s_key_tracer.add(key_maker.values.item_key, value); @@ -249,7 +248,7 @@ ConditionKey::ConditionKey(DetElement detector, const string& value) { } /// Constructor from detector element key and item sub-key -ConditionKey::ConditionKey(Condition::detkey_type det_key, const string& value) { +ConditionKey::ConditionKey(Condition::detkey_type det_key, const std::string& value) { KeyMaker key_maker(det_key, value); s_key_tracer.add(key_maker.values.item_key, value); hash = key_maker.hash; @@ -278,7 +277,7 @@ Condition::key_type ConditionKey::hashCode(DetElement detector, const char* valu } /// Hash code generation from input string -Condition::key_type ConditionKey::hashCode(DetElement detector, const string& value) { +Condition::key_type ConditionKey::hashCode(DetElement detector, const std::string& value) { KeyMaker key_maker(detector.key(), value); s_key_tracer.add(key_maker.values.item_key, value); return key_maker.hash; @@ -292,20 +291,20 @@ Condition::itemkey_type ConditionKey::itemCode(const char* value) { } /// 32 bit hashcode of the item -Condition::itemkey_type ConditionKey::itemCode(const string& value) { +Condition::itemkey_type ConditionKey::itemCode(const std::string& value) { Condition::itemkey_type code = detail::hash32(value); s_key_tracer.add(code, value); return code; } /// Conversion to string -string ConditionKey::toString() const { +std::string ConditionKey::toString() const { dd4hep::ConditionKey::KeyMaker key(hash); char text[64]; ::snprintf(text,sizeof(text),"%08X-%08X",key.values.det_key, key.values.item_key); #if defined(DD4HEP_CONDITIONS_HAVE_NAME) if ( !name.empty() ) { - stringstream str; + std::stringstream str; str << "(" << name << ") " << text; return str.str(); } diff --git a/DDCore/src/ConditionsData.cpp b/DDCore/src/ConditionsData.cpp index 2392bc02d..9b79c1567 100644 --- a/DDCore/src/ConditionsData.cpp +++ b/DDCore/src/ConditionsData.cpp @@ -12,9 +12,9 @@ //========================================================================== // Framework includes -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/ConditionsData.h" +#include +#include +#include using namespace dd4hep::cond; @@ -76,5 +76,5 @@ AbstractMap& AbstractMap::operator=(const AbstractMap& c) { return *this; } -#include "DD4hep/GrammarUnparsed.h" +#include static auto s_registry = dd4hep::GrammarRegistry::pre_note(1); diff --git a/DDCore/src/ConditionsDebug.cpp b/DDCore/src/ConditionsDebug.cpp index d17e8a947..ca30abf20 100644 --- a/DDCore/src/ConditionsDebug.cpp +++ b/DDCore/src/ConditionsDebug.cpp @@ -12,24 +12,23 @@ //========================================================================== // Framework include files -#include "DD4hep/Conditions.h" -#include "DD4hep/ConditionsDebug.h" -#include "DD4hep/detail/ConditionsInterna.h" +#include +#include +#include -using std::string; using namespace dd4hep::cond; std::string dd4hep::cond::cond_name(const dd4hep::Condition::Object* c) { #if defined(DD4HEP_MINIMAL_CONDITIONS) dd4hep::ConditionKey::KeyMaker key(c->hash); char text[64]; - ::snprintf(text,sizeof(text),"%08X-%08X",key.values.det_key, key.values.item_key); + std::snprintf(text,sizeof(text),"%08X-%08X", key.values.det_key, key.values.item_key); return text; #else return c->name; #endif } -string dd4hep::cond::cond_name(Condition c) { +std::string dd4hep::cond::cond_name(Condition c) { return cond_name(c.ptr()); } diff --git a/DDCore/src/ConditionsInterna.cpp b/DDCore/src/ConditionsInterna.cpp index 0a08de596..044938b87 100644 --- a/DDCore/src/ConditionsInterna.cpp +++ b/DDCore/src/ConditionsInterna.cpp @@ -12,12 +12,11 @@ //========================================================================== // Framework includes -#include "DD4hep/IOV.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/detail/Handle.inl" -#include "DD4hep/detail/ConditionsInterna.h" +#include +#include +#include +#include -using namespace std; using namespace dd4hep; #if defined(DD4HEP_CONDITIONS_HAVE_NAME) @@ -45,10 +44,10 @@ detail::ConditionObject::ConditionObject() /// Standard constructor #if defined(DD4HEP_CONDITIONS_HAVE_NAME) -detail::ConditionObject::ConditionObject(const string& nam,const string& tit) +detail::ConditionObject::ConditionObject(const std::string& nam,const std::string& tit) : NamedObject(nam, tit), data() #else -detail::ConditionObject::ConditionObject(const string& ,const string& ) +detail::ConditionObject::ConditionObject(const std::string& ,const std::string& ) : data() #endif { @@ -68,7 +67,7 @@ void detail::ConditionObject::release() { /// Data offset from the opaque data block pointer to the condition size_t detail::ConditionObject::offset() { static _P p((void*)0x1000); - static size_t off = _P(&p.o->data.grammar).character - p.character + sizeof(OpaqueData::grammar); + static std::size_t off = _P(&p.o->data.grammar).character - p.character + sizeof(OpaqueData::grammar); return off; } @@ -97,5 +96,5 @@ const dd4hep::IOVType* detail::ConditionObject::iovType() const { } -#include "DD4hep/GrammarUnparsed.h" -static auto s_registry = GrammarRegistry::pre_note >(1); +#include +static auto s_registry = GrammarRegistry::pre_note >(1); diff --git a/DDCore/src/ConditionsListener.cpp b/DDCore/src/ConditionsListener.cpp index 3e43d6ccf..129f41848 100644 --- a/DDCore/src/ConditionsListener.cpp +++ b/DDCore/src/ConditionsListener.cpp @@ -12,7 +12,7 @@ //========================================================================== // Framework include files -#include "DD4hep/ConditionsListener.h" +#include using namespace dd4hep::cond; diff --git a/DDCore/src/ConditionsMap.cpp b/DDCore/src/ConditionsMap.cpp index c9f496a11..844622774 100644 --- a/DDCore/src/ConditionsMap.cpp +++ b/DDCore/src/ConditionsMap.cpp @@ -12,9 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/ConditionsMap.h" -#include "DD4hep/detail/ConditionsInterna.h" +#include +#include +#include using namespace dd4hep; diff --git a/DDCore/src/ConditionsPrinter.cpp b/DDCore/src/ConditionsPrinter.cpp index 2d0552723..a51935319 100644 --- a/DDCore/src/ConditionsPrinter.cpp +++ b/DDCore/src/ConditionsPrinter.cpp @@ -12,25 +12,24 @@ //========================================================================== // Framework includes -#include "Parsers/Parsers.h" -#include "DD4hep/Printout.h" -#include "DD4hep/ConditionsData.h" -#include "DD4hep/ConditionsPrinter.h" -#include "DD4hep/ConditionsProcessor.h" +#include +#include +#include +#include +#include -#include "DD4hep/detail/ConditionsInterna.h" +#include // C/C++ include files #include -using namespace std; using namespace dd4hep; using namespace dd4hep::cond; namespace { /// C++ version: replace all occurrences of a string - string str_replace(const std::string& str, const std::string& pattern, const std::string& replacement) { - string res = str; + std::string str_replace(const std::string& str, const std::string& pattern, const std::string& replacement) { + std::string res = str; for(size_t id=res.find(pattern); id != std::string::npos; id = res.find(pattern) ) res.replace(id,pattern.length(),replacement); return res; @@ -76,11 +75,11 @@ ConditionsPrinter::ParamPrinter::ParamPrinter(ConditionsPrinter* printer, PrintL /// Callback to output conditions information void ConditionsPrinter::ParamPrinter::operator()(const AbstractMap::Params::value_type& obj) const { - const type_info& type = obj.second.typeInfo(); + const std::type_info& type = obj.second.typeInfo(); ++m_parent->numParam; - if ( type == typeid(string) ) { - string value = obj.second.get().c_str(); - size_t len = value.length(); + if ( type == typeid(std::string) ) { + std::string value = obj.second.get().c_str(); + std::size_t len = value.length(); if ( len > m_parent->lineLength ) { value.erase(m_parent->lineLength); value += "..."; @@ -100,8 +99,8 @@ void ConditionsPrinter::ParamPrinter::operator()(const AbstractMap::Params::valu obj.second.str().c_str()); } else { - string value = obj.second.str(); - size_t len = value.length(); + std::string value = obj.second.str(); + std::size_t len = value.length(); if ( len > m_parent->lineLength ) { value.erase(m_parent->lineLength); value += "..."; @@ -115,7 +114,7 @@ void ConditionsPrinter::ParamPrinter::operator()(const AbstractMap::Params::valu } /// Initializing constructor -ConditionsPrinter::ConditionsPrinter(ConditionsMap* cond_map, const string& pref, int flg) +ConditionsPrinter::ConditionsPrinter(ConditionsMap* cond_map, const std::string& pref, int flg) : mapping(cond_map), m_flag(flg), name("Condition"), prefix(pref) { m_print = new ParamPrinter(this, printLevel); @@ -137,13 +136,13 @@ ConditionsPrinter::~ConditionsPrinter() { int ConditionsPrinter::operator()(Condition cond) const { m_print->printLevel = printLevel; if ( cond.isValid() ) { - string repr = cond.str(m_flag); - Condition::Object* ptr = cond.ptr(); + std::string repr = cond.str(m_flag); + Condition::Object* ptr = cond.ptr(); if ( repr.length() > lineLength ) repr = repr.substr(0,lineLength)+"..."; printout(this->printLevel,name, "++ %s%s", prefix.c_str(), repr.c_str()); - string new_prefix = prefix; + std::string new_prefix = prefix; new_prefix.assign(prefix.length(),' '); if ( !cond.is_bound() ) { printout(this->printLevel,name,"++ %s \tPath:%s Key:%16llX Type:%s (%s)", @@ -151,11 +150,11 @@ int ConditionsPrinter::operator()(Condition cond) const { typeName(typeid(*ptr)).c_str()); return 1; } - const type_info& type = cond.typeInfo(); - const OpaqueData& opaque = cond.data(); + const std::type_info& type = cond.typeInfo(); + const OpaqueData& opaque = cond.data(); printout(this->printLevel,name,"++ %s \tPath:%s Key:%16llX Type:%s", new_prefix.c_str(), cond.name(), cond.key(), opaque.dataType().c_str()); - //string values = opaque.str(); + //std::string values = opaque.str(); //if ( values.length() > lineLength ) values = values.substr(0,130)+"..."; //printout(this->printLevel,name,"++ %s \tData:%s", new_prefix.c_str(), values.c_str()); if ( type == typeid(AbstractMap) ) { @@ -176,18 +175,18 @@ int ConditionsPrinter::operator()(Condition cond) const { } } else if ( type == typeid(Delta) ) { - string piv; - stringstream str_tr, str_rot, str_piv; + std::string piv; + std::stringstream str_tr, str_rot, str_piv; const Delta& D = cond.get(); if ( D.hasTranslation() ) { - Position copy(D.translation * (1./dd4hep::cm)); - Parsers::toStream(copy, str_tr); + Position copy(D.translation * (1./dd4hep::cm)); + Parsers::toStream(copy, str_tr); } if ( D.hasRotation() ) { - Parsers::toStream(D.rotation, str_rot); + Parsers::toStream(D.rotation, str_rot); } if ( D.hasPivot() ) { - Position copy(D.pivot.Vect() * (1./dd4hep::cm)); + Position copy(D.pivot.Vect() * (1./dd4hep::cm)); Parsers::toStream(copy, str_piv); piv = str_replace(str_piv.str(),"\n",""); piv = str_replace(piv," "," , "); @@ -206,8 +205,8 @@ int ConditionsPrinter::operator()(Condition cond) const { ); } else if ( type == typeid(AlignmentData) ) { - string piv; - stringstream str_tr, str_rot, str_piv; + std::string piv; + std::stringstream str_tr, str_rot, str_piv; const Delta& D = cond.get().delta; if ( D.hasTranslation() ) Parsers::toStream(D.translation, str_tr); if ( D.hasRotation() ) Parsers::toStream(D.rotation, str_rot); @@ -230,9 +229,9 @@ int ConditionsPrinter::operator()(Condition cond) const { piv.c_str() ); } - else if ( type == typeid(string) ) { - string value = cond.get().c_str(); - size_t len = value.length(); + else if ( type == typeid(std::string) ) { + std::string value = cond.get().c_str(); + std::size_t len = value.length(); if ( len > lineLength ) { value = value.substr(0,lineLength); value += "..."; @@ -244,8 +243,8 @@ int ConditionsPrinter::operator()(Condition cond) const { value.c_str()); } else { - string value = cond.str(); - size_t len = value.length(); + std::string value = cond.str(); + std::size_t len = value.length(); if ( len > lineLength ) { value = value.substr(0,lineLength); value += "..."; @@ -264,7 +263,7 @@ int ConditionsPrinter::operator()(Condition cond) const { /// Processing callback to print conditions int ConditionsPrinter::operator()(DetElement de, int level) const { if ( mapping ) { - vector conditions; + std::vector conditions; conditionsCollector(*mapping,conditions)(de,level); printout(this->printLevel, name, "++ %s %-3ld Conditions for DE %s", prefix.c_str(), conditions.size(), de.path().c_str()); diff --git a/DDCore/src/ConditionsProcessor.cpp b/DDCore/src/ConditionsProcessor.cpp index 9a3514e6e..a31c652b5 100644 --- a/DDCore/src/ConditionsProcessor.cpp +++ b/DDCore/src/ConditionsProcessor.cpp @@ -12,11 +12,10 @@ //========================================================================== // Framework includes -#include "DD4hep/Printout.h" -#include "DD4hep/ConditionsProcessor.h" -#include "DD4hep/detail/ContainerHelpers.h" +#include +#include +#include -using namespace std; using namespace dd4hep; using namespace dd4hep::cond; @@ -48,14 +47,14 @@ namespace dd4hep { namespace cond { //template class ConditionsCollector; - template class ConditionsCollector >; - template class ConditionsCollector >; - template class ConditionsCollector >; - template class ConditionsCollector > >; - template class ConditionsCollector > >; - - template class ConditionsCollector >; - template class ConditionsCollector >; - template class ConditionsCollector >; + template class ConditionsCollector >; + template class ConditionsCollector >; + template class ConditionsCollector >; + template class ConditionsCollector > >; + template class ConditionsCollector > >; + + template class ConditionsCollector >; + template class ConditionsCollector >; + template class ConditionsCollector >; } /* End namespace cond */ } /* End namespace dd4hep */ diff --git a/DDCore/src/DD4hepRootPersistency.cpp b/DDCore/src/DD4hepRootPersistency.cpp index fb3711405..fa8a525bc 100644 --- a/DDCore/src/DD4hepRootPersistency.cpp +++ b/DDCore/src/DD4hepRootPersistency.cpp @@ -12,20 +12,19 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/DD4hepRootPersistency.h" -#include "DD4hep/detail/ObjectsInterna.h" -#include "DD4hep/detail/SegmentationsInterna.h" +#include +#include +#include +#include // ROOT include files -#include "TFile.h" -#include "TTimeStamp.h" +#include +#include #include ClassImp(DD4hepRootPersistency) using namespace dd4hep; -using namespace std; namespace { /// Ensure nominal alignments are loaded before saving @@ -95,7 +94,7 @@ int DD4hepRootPersistency::save(Detector& description, const char* fname, const DetectorData::unpatchRootStreamer(TGeoNode::Class()); return nBytes; } - catch (const exception& e) { + catch (const std::exception& e) { DetectorData::unpatchRootStreamer(TGeoVolume::Class()); DetectorData::unpatchRootStreamer(TGeoNode::Class()); except("DD4hepRootPersistency","Exception %s while saving file %s",e.what(), fname); @@ -118,7 +117,7 @@ int DD4hepRootPersistency::load(Detector& description, const char* fname, const if ( f && !f->IsZombie()) { try { TTimeStamp start; - unique_ptr persist((DD4hepRootPersistency*)f->Get(instance)); + std::unique_ptr persist((DD4hepRootPersistency*)f->Get(instance)); if ( persist.get() ) { DetectorData* source = persist->m_data; #if 0 @@ -189,7 +188,7 @@ int DD4hepRootPersistency::load(Detector& description, const char* fname, const f->ls(); delete f; } - catch (const exception& e) { + catch (const std::exception& e) { DetectorData::unpatchRootStreamer(TGeoVolume::Class()); DetectorData::unpatchRootStreamer(TGeoNode::Class()); except("DD4hepRootPersistency","Exception %s while loading file %s",e.what(), fname); @@ -207,22 +206,20 @@ int DD4hepRootPersistency::load(Detector& description, const char* fname, const return 0; } +#include +#include +#include -#include "DD4hep/detail/DetectorInterna.h" -#include "DD4hep/detail/ConditionsInterna.h" -#include "DD4hep/detail/AlignmentsInterna.h" namespace { class PersistencyChecks { - public: - size_t errors = 0; /// Default constructor PersistencyChecks() = default; - size_t checkConstant(const std::pair& obj) { + size_t checkConstant(const std::pair& obj) { if ( obj.first.empty() || obj.second->name.empty() ) { printout(ERROR,"chkConstant","+++ Invalid constant: key error %s <> %s [%s]", obj.first.c_str(), obj.second->GetName(), obj.second->GetTitle()); @@ -238,7 +235,7 @@ namespace { return 1; } - size_t checkProperty(const std::pair >& obj) { + size_t checkProperty(const std::pair >& obj) { if ( obj.first.empty() || obj.second.empty() ) { printout(ERROR,"chkProperty","+++ Empty property set: %s",obj.first.c_str()); ++errors; diff --git a/DDCore/src/DD4hepUI.cpp b/DDCore/src/DD4hepUI.cpp index bd58a2fce..5972e252b 100644 --- a/DDCore/src/DD4hepUI.cpp +++ b/DDCore/src/DD4hepUI.cpp @@ -12,54 +12,52 @@ //========================================================================== // Framework includes -#include "DD4hep/DD4hepUI.h" -#include "DD4hep/Printout.h" -#include "TRint.h" +#include +#include +#include -using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; namespace { - string _visLevel(int lvl) { + std::string _visLevel(int lvl) { char text[32]; - ::snprintf(text,sizeof(text),"%d",lvl); + std::snprintf(text,sizeof(text),"%d",lvl); return text; } } /// Default constructor -DD4hepUI::DD4hepUI(Detector& instance) : m_detDesc(instance) { +detail::DD4hepUI::DD4hepUI(Detector& instance) : m_detDesc(instance) { } /// Default destructor -DD4hepUI::~DD4hepUI() { +detail::DD4hepUI::~DD4hepUI() { } /// Access to the Detector instance -Detector* DD4hepUI::instance() const { +Detector* detail::DD4hepUI::instance() const { return &m_detDesc; } /// Access to the Detector instance -Detector* DD4hepUI::detectorDescription() const { +Detector* detail::DD4hepUI::detectorDescription() const { return &m_detDesc; } /// Set the printout level from the interactive prompt -PrintLevel DD4hepUI::setPrintLevel(PrintLevel level) const { +PrintLevel detail::DD4hepUI::setPrintLevel(PrintLevel level) const { return dd4hep::setPrintLevel(level); } /// Set the visualization level when invoking the display -int DD4hepUI::setVisLevel(int value) { +int detail::DD4hepUI::setVisLevel(int value) { int old_value = visLevel; visLevel = value; return old_value; } /// Install the dd4hep conditions manager object -Handle DD4hepUI::conditionsMgr() const { +Handle detail::DD4hepUI::conditionsMgr() const { if ( !m_condMgr.isValid() ) { const void* argv[] = {"-handle",&m_condMgr,0}; if ( 1 != apply("DD4hep_ConditionsManagerInstaller",2,(char**)argv) ) { @@ -73,7 +71,7 @@ Handle DD4hepUI::conditionsMgr() const { } /// Load conditions from file -long DD4hepUI::loadConditions(const std::string& fname) const { +long detail::DD4hepUI::loadConditions(const std::string& fname) const { Handle h = conditionsMgr(); if ( h.isValid() ) { m_detDesc.fromXML(fname, BUILD_DEFAULT); @@ -83,7 +81,7 @@ long DD4hepUI::loadConditions(const std::string& fname) const { } /// Install the dd4hep alignment manager object -Handle DD4hepUI::alignmentMgr() const { +Handle detail::DD4hepUI::alignmentMgr() const { if ( !m_alignMgr.isValid() ) { const void* argv[] = {"-handle",&m_alignMgr,0}; if ( 1 != apply("DD4hep_AlignmentsManagerInstaller",2,(char**)argv) ) { @@ -97,41 +95,41 @@ Handle DD4hepUI::alignmentMgr() const { } /// Detector interface: Manipulate geometry using facroy converter -long DD4hepUI::apply(const char* factory, int argc, char** argv) const { +long detail::DD4hepUI::apply(const char* factory, int argc, char** argv) const { return m_detDesc.apply(factory, argc, argv); } /// Detector interface: Read any geometry description or alignment file -void DD4hepUI::fromXML(const std::string& fname, DetectorBuildType type) const { +void detail::DD4hepUI::fromXML(const std::string& fname, DetectorBuildType type) const { return m_detDesc.fromXML(fname, type); } /// Detector interface: Draw the scene on a OpenGL pane -void DD4hepUI::draw() const { +void detail::DD4hepUI::draw() const { drawSubtree("/world"); } /// Detector interface: Re-draw the entire scene -void DD4hepUI::redraw() const { +void detail::DD4hepUI::redraw() const { redrawSubtree("/world"); } /// Detector interface: Draw detector sub-tree the scene on a OpenGL pane -void DD4hepUI::drawSubtree(const char* path) const { - string vis = _visLevel(visLevel); +void detail::DD4hepUI::drawSubtree(const char* path) const { + std::string vis = _visLevel(visLevel); const void* av[] = {"-detector", path, "-option", "ogl", "-level", vis.c_str(), 0}; m_detDesc.apply("DD4hep_GeometryDisplay", 2, (char**)av); } /// Detector interface: Re-draw the entire sub-tree scene -void DD4hepUI::redrawSubtree(const char* path) const { - string vis = _visLevel(visLevel); +void detail::DD4hepUI::redrawSubtree(const char* path) const { + std::string vis = _visLevel(visLevel); const void* av[] = {"-detector", path, "-option", "oglsame", "-level", vis.c_str(), 0}; m_detDesc.apply("DD4hep_GeometryDisplay", 4, (char**)av); } /// Dump the volume tree -long DD4hepUI::dumpVols(int argc, char** argv) const { +long detail::DD4hepUI::dumpVols(int argc, char** argv) const { if ( argc==0 ) { const void* av[] = {"-positions","-pointers",0}; return m_detDesc.apply("DD4hep_VolumeDump",2,(char**)av); @@ -140,25 +138,25 @@ long DD4hepUI::dumpVols(int argc, char** argv) const { } /// Dump the DetElement tree with placements -long DD4hepUI::dumpDet(const char* path) const { +long detail::DD4hepUI::dumpDet(const char* path) const { const void* args[] = {"--detector", path ? path : "/world", 0}; return m_detDesc.apply("DD4hep_DetectorVolumeDump",2,(char**)args); } /// Dump the DetElement tree with placements -long DD4hepUI::dumpDetMaterials(const char* path) const { +long detail::DD4hepUI::dumpDetMaterials(const char* path) const { const void* args[] = {"--detector", path ? path : "/world", "--materials", "--shapes", 0}; return m_detDesc.apply("DD4hep_DetectorVolumeDump",4,(char**)args); } /// Dump the DetElement tree with placements -long DD4hepUI::dumpStructure(const char* path) const { +long detail::DD4hepUI::dumpStructure(const char* path) const { const void* args[] = {"--detector", path ? path : "/world", 0}; return m_detDesc.apply("DD4hep_DetectorDump",2,(char**)args); } /// Dump the entire detector description object to a root file -long DD4hepUI::saveROOT(const char* file_name) const { +long detail::DD4hepUI::saveROOT(const char* file_name) const { if ( file_name ) { const void* av[] = {"-output",file_name,0}; return m_detDesc.apply("DD4hep_Geometry2ROOT",2,(char**)av); @@ -168,7 +166,7 @@ long DD4hepUI::saveROOT(const char* file_name) const { } /// Import the entire detector description object from a root file -long DD4hepUI::importROOT(const char* file_name) const { +long detail::DD4hepUI::importROOT(const char* file_name) const { if ( file_name ) { const void* av[] = {"-input",file_name,0}; return m_detDesc.apply("DD4hep_RootLoader",2,(char**)av); @@ -178,9 +176,9 @@ long DD4hepUI::importROOT(const char* file_name) const { } /// Create ROOT interpreter instance -long DD4hepUI::createInterpreter(int argc, char** argv) { +long detail::DD4hepUI::createInterpreter(int argc, char** argv) { if ( 0 == gApplication ) { - pair a(argc,argv); + std::pair a(argc,argv); gApplication = new TRint("DD4hepUI", &a.first, a.second); printout(INFO,"DD4hepUI","++ Created ROOT interpreter instance for DD4hepUI."); return 1; @@ -191,7 +189,7 @@ long DD4hepUI::createInterpreter(int argc, char** argv) { } /// Execute ROOT interpreter instance -long DD4hepUI::runInterpreter() const { +long detail::DD4hepUI::runInterpreter() const { if ( 0 != gApplication ) { if ( !gApplication->IsRunning() ) { gApplication->Run(); diff --git a/DDCore/src/DetectorData.cpp b/DDCore/src/DetectorData.cpp index f2ba99d47..0a9bc5183 100644 --- a/DDCore/src/DetectorData.cpp +++ b/DDCore/src/DetectorData.cpp @@ -26,7 +26,6 @@ #include #include - namespace dd4hep { namespace detail { class DetectorImp; }} using namespace dd4hep; diff --git a/DDCore/src/JSON/Detector.cpp b/DDCore/src/JSON/Detector.cpp index 2d4498fca..b19565c7d 100644 --- a/DDCore/src/JSON/Detector.cpp +++ b/DDCore/src/JSON/Detector.cpp @@ -13,11 +13,11 @@ #ifndef DD4HEP_NONE // Framework include files -#include "JSON/Detector.h" +#include // Instantiate here the concrete implementations #define DD4HEP_DIMENSION_NS json using namespace dd4hep::DD4HEP_DIMENSION_NS; -#include "Parsers/detail/Detector.imp" +#include #endif diff --git a/DDCore/src/JSON/DocumentHandler.cpp b/DDCore/src/JSON/DocumentHandler.cpp index af803f29f..14572832a 100644 --- a/DDCore/src/JSON/DocumentHandler.cpp +++ b/DDCore/src/JSON/DocumentHandler.cpp @@ -21,7 +21,6 @@ #include #include -using namespace std; using namespace dd4hep::json; /// Default constructor @@ -33,13 +32,13 @@ DocumentHandler::~DocumentHandler() { } /// Load XML file and parse it. -Document DocumentHandler::load(const string& fname) const { - string fn = fname; - if ( fname.find("://") != string::npos ) fn = fname.substr(fname.find("://")+3); - //string cmd = "cat "+fn; +Document DocumentHandler::load(const std::string& fname) const { + std::string fn = fname; + if ( fname.find("://") != std::string::npos ) fn = fname.substr(fname.find("://")+3); + //std::string cmd = "cat "+fn; //::printf("\n\n+++++ Dump json file: %s\n\n\n",fn.c_str()); //::system(cmd.c_str()); - unique_ptr doc(new JsonElement(fn, ptree())); + std::unique_ptr doc(new JsonElement(fn, ptree())); boost::property_tree::read_json(fn,doc->second); return doc.release(); } @@ -47,5 +46,5 @@ Document DocumentHandler::load(const string& fname) const { /// Parse a standalong XML string into a document. Document DocumentHandler::parse(const char* doc_string, size_t length) const { if ( doc_string && length ) {} - throw runtime_error("Bla"); + throw std::runtime_error("Bla"); } diff --git a/DDCore/src/JSON/Elements.cpp b/DDCore/src/JSON/Elements.cpp index af5d417cc..a52804c1e 100644 --- a/DDCore/src/JSON/Elements.cpp +++ b/DDCore/src/JSON/Elements.cpp @@ -12,8 +12,8 @@ //========================================================================== // Framework include files -#include "JSON/Printout.h" -#include "JSON/Elements.h" +#include +#include // C/C++ include files #include @@ -21,21 +21,20 @@ #include #include -using namespace std; using namespace dd4hep::json; static const size_t INVALID_NODE = ~0U; // Forward declarations namespace dd4hep { - std::pair _toInteger(const string& value); - std::pair _toFloatingPoint(const string& value); - void _toDictionary(const string& name, const string& value, const string& typ); - string _getEnviron(const string& env); + std::pair _toInteger(const std::string& value); + std::pair _toFloatingPoint(const std::string& value); + void _toDictionary(const std::string& name, const std::string& value, const std::string& typ); + std::string _getEnviron(const std::string& env); } // Static storage namespace { - string _checkEnviron(const string& env) { - string r = dd4hep::_getEnviron(env); + std::string _checkEnviron(const std::string& env) { + std::string r = dd4hep::_getEnviron(env); return r.empty() ? env : r; } } @@ -50,7 +49,7 @@ namespace { JsonElement* node_first(JsonElement* e, const char* tag) { if ( e ) { - string t(tag); + std::string t(tag); if ( t == "*" ) { ptree::iterator i = e->second.begin(); return i != e->second.end() ? &(*i) : 0; @@ -61,7 +60,7 @@ namespace { return 0; } - size_t node_count(JsonElement* e, const string& t) { + size_t node_count(JsonElement* e, const std::string& t) { return e ? (t=="*" ? e->second.size() : e->second.count(t)) : 0; } @@ -78,64 +77,64 @@ namespace { } } -string dd4hep::json::_toString(Attribute attr) { +std::string dd4hep::json::_toString(Attribute attr) { if (attr) return _toString(attribute_value(attr)); return ""; } -template static inline string __to_string(T value, const char* fmt) { +template static inline std::string __to_string(T value, const char* fmt) { char text[128]; ::snprintf(text, sizeof(text), fmt, value); return text; } /// Do-nothing version. Present for completeness and argument interchangeability -string dd4hep::json::_toString(const char* s) { +std::string dd4hep::json::_toString(const char* s) { if ( !s || *s == 0 ) return ""; else if ( !(*s == '$' && *(s+1) == '{') ) return s; return _checkEnviron(s); } /// Do-nothing version. Present for completeness and argument interchangeability -string dd4hep::json::_toString(const string& s) { +std::string dd4hep::json::_toString(const std::string& s) { if ( s.length() < 3 || s[0] != '$' ) return s; else if ( !(s[0] == '$' && s[1] == '{') ) return s; return _checkEnviron(s); } /// Format unsigned long integer to string with arbitrary format -string dd4hep::json::_toString(unsigned long v, const char* fmt) { +std::string dd4hep::json::_toString(unsigned long v, const char* fmt) { return __to_string(v, fmt); } /// Format unsigned integer (32 bits) to string with arbitrary format -string dd4hep::json::_toString(unsigned int v, const char* fmt) { +std::string dd4hep::json::_toString(unsigned int v, const char* fmt) { return __to_string(v, fmt); } /// Format signed integer (32 bits) to string with arbitrary format -string dd4hep::json::_toString(int v, const char* fmt) { +std::string dd4hep::json::_toString(int v, const char* fmt) { return __to_string(v, fmt); } /// Format signed long integer to string with arbitrary format -string dd4hep::json::_toString(long v, const char* fmt) { +std::string dd4hep::json::_toString(long v, const char* fmt) { return __to_string(v, fmt); } /// Format single procision float number (32 bits) to string with arbitrary format -string dd4hep::json::_toString(float v, const char* fmt) { +std::string dd4hep::json::_toString(float v, const char* fmt) { return __to_string(v, fmt); } /// Format double procision float number (64 bits) to string with arbitrary format -string dd4hep::json::_toString(double v, const char* fmt) { +std::string dd4hep::json::_toString(double v, const char* fmt) { return __to_string(v, fmt); } /// Format pointer to string with arbitrary format -string dd4hep::json::_ptrToString(const void* v, const char* fmt) { +std::string dd4hep::json::_ptrToString(const void* v, const char* fmt) { return __to_string(v, fmt); } @@ -149,7 +148,7 @@ int dd4hep::json::_toInt(const char* value) { bool dd4hep::json::_toBool(const char* value) { if (value) { - string s = _toString(value); + std::string s = _toString(value); return s == "true"; } return false; @@ -171,7 +170,7 @@ template void dd4hep::json::_toDictionary(const char* name, T value dd4hep::_toDictionary(name, _toString(value), "number"); } -template void dd4hep::json::_toDictionary(const char* name, const string& value); +template void dd4hep::json::_toDictionary(const char* name, const std::string& value); template void dd4hep::json::_toDictionary(const char* name, unsigned long value); template void dd4hep::json::_toDictionary(const char* name, unsigned int value); template void dd4hep::json::_toDictionary(const char* name, unsigned short value); @@ -182,7 +181,7 @@ template void dd4hep::json::_toDictionary(const char* name, float value); template void dd4hep::json::_toDictionary(const char* name, double value); /// Evaluate string constant using environment stored in the evaluator -string dd4hep::json::getEnviron(const string& env) { +std::string dd4hep::json::getEnviron(const std::string& env) { return dd4hep::_getEnviron(env); } @@ -194,7 +193,7 @@ NodeList::NodeList(const NodeList& copy) } /// Initializing constructor -NodeList::NodeList(JsonElement* node, const string& tag_value) +NodeList::NodeList(JsonElement* node, const std::string& tag_value) : m_tag(tag_value), m_node(node) { reset(); @@ -207,7 +206,7 @@ NodeList::~NodeList() { /// Reset the nodelist JsonElement* NodeList::reset() { if ( m_tag == "*" ) - m_ptr = make_pair(m_node->second.ordered_begin(), m_node->second.not_found()); + m_ptr = std::make_pair(m_node->second.ordered_begin(), m_node->second.not_found()); else m_ptr = m_node->second.equal_range(m_tag); if ( m_ptr.first != m_ptr.second ) @@ -269,8 +268,8 @@ bool Handle_t::hasAttr(const char* tag_value) const { } /// Retrieve a collection of all attributes of this DOM element -vector Handle_t::attributes() const { - vector < Attribute > attrs; +std::vector Handle_t::attributes() const { + std::vector < Attribute > attrs; if (m_node) { for(ptree::iterator i=m_node->second.begin(); i!=m_node->second.end(); ++i) { Attribute a = &(*i); @@ -286,12 +285,12 @@ size_t Handle_t::numChildren(const char* t, bool throw_exception) const { return 0; else if (n != INVALID_NODE) return n; - string msg = "Handle_t::numChildren: "; + std::string msg = "Handle_t::numChildren: "; if (m_node) msg += "Element [" + tag() + "] has no children of type '" + _toString(t) + "'"; else msg += "Element [INVALID] has no children of type '" + _toString(t) + "'"; - throw runtime_error(msg); + throw std::runtime_error(msg); } /// Remove a single child node identified by its handle from the tree of the element @@ -299,12 +298,12 @@ Handle_t Handle_t::child(const char* t, bool throw_exception) const { Elt_t e = node_first(m_node, t); if (e || !throw_exception) return e; - string msg = "Handle_t::child: "; + std::string msg = "Handle_t::child: "; if (m_node) msg += "Element [" + tag() + "] has no child of type '" + _toString(t) + "'"; else msg += "Element [INVALID]. Cannot remove child of type: '" + _toString(t) + "'"; - throw runtime_error(msg); + throw std::runtime_error(msg); } NodeList Handle_t::children(const char* tag_value) const { @@ -320,12 +319,12 @@ Attribute Handle_t::attr_ptr(const char* t) const { Attribute a = attribute_node(m_node, t); if (0 != a) return a; - string msg = "Handle_t::attr_ptr: "; + std::string msg = "Handle_t::attr_ptr: "; if (m_node) msg += "Element [" + tag() + "] has no attribute of type '" + _toString(t) + "'"; else msg += "Element [INVALID] has no attribute of type '" + _toString(t) + "'"; - throw runtime_error(msg); + throw std::runtime_error(msg); } /// Access attribute name (throws exception if not present) @@ -333,7 +332,7 @@ const char* Handle_t::attr_name(const Attribute a) const { if (a) { return a->first.c_str(); } - throw runtime_error("Attempt to access invalid XML attribute object!"); + throw std::runtime_error("Attempt to access invalid XML attribute object!"); } /// Access attribute value by the attribute's unicode name (throws exception if not present) @@ -358,7 +357,7 @@ Handle_t Document::root() const { if ( m_doc ) { return m_doc; } - throw runtime_error("Document::root: Invalid handle!"); + throw std::runtime_error("Document::root: Invalid handle!"); } /// Assign new document. Old document is dropped. @@ -403,11 +402,11 @@ size_t Collection_t::size() const { } /// Helper function to throw an exception -void Collection_t::throw_loop_exception(const exception& e) const { +void Collection_t::throw_loop_exception(const std::exception& e) const { if (m_node) { - throw runtime_error(string(e.what()) + "\n" + "dd4hep: Error interpreting XML nodes of type <" + tag() + "/>"); + throw std::runtime_error(std::string(e.what()) + "\n" + "dd4hep: Error interpreting XML nodes of type <" + tag() + "/>"); } - throw runtime_error(string(e.what()) + "\n" + "dd4hep: Error interpreting collections XML nodes."); + throw std::runtime_error(std::string(e.what()) + "\n" + "dd4hep: Error interpreting collections XML nodes."); } void Collection_t::operator++() const { @@ -444,8 +443,8 @@ void dd4hep::json::dumpTree(Element elt) { void dd4hep::json::dumpTree(const JsonElement* elt) { struct Dump { - void operator()(const JsonElement* e, const string& tag) const { - string t = tag+" "; + void operator()(const JsonElement* e, const std::string& tag) const { + std::string t = tag+" "; printout(INFO,"DumpTree","+++ %s %s: %s",tag.c_str(), e->first.c_str(), e->second.data().c_str()); for(auto i=e->second.begin(); i!=e->second.end(); ++i) (*this)(&(*i), t); diff --git a/DDCore/src/JSON/Helpers.cpp b/DDCore/src/JSON/Helpers.cpp index bd8bcbff4..8c172d166 100644 --- a/DDCore/src/JSON/Helpers.cpp +++ b/DDCore/src/JSON/Helpers.cpp @@ -12,8 +12,8 @@ //========================================================================== // Framework include files -#include "JSON/Dimension.inl" -#include "JSON/ChildValue.inl" +#include +#include // Instantiate here the concrete implementations #define DD4HEP_DIMENSION_NS json diff --git a/DDCore/src/Path.cpp b/DDCore/src/Path.cpp index a3e314be4..b8b2e9b0e 100644 --- a/DDCore/src/Path.cpp +++ b/DDCore/src/Path.cpp @@ -13,15 +13,15 @@ // //========================================================================== -#include "DD4hep/Path.h" +/// Framework include files +#include + +/// C/C++ include files #include #include #include #include -using namespace std; -using namespace dd4hep; - namespace { const char dot = '.'; const char separator = '/'; @@ -31,11 +31,11 @@ namespace { inline bool is_separator(char c) { return c == separator; } - bool is_root_separator(const string& str, size_t pos) + bool is_root_separator(const std::string& str, size_t pos) // pos is position of the separator { if ( str.empty() || is_separator(str[pos]) ) { - throw runtime_error("precondition violation"); + throw std::runtime_error("precondition violation"); } // subsequent logic expects pos to be for leftmost slash of a set while (pos > 0 && is_separator(str[pos-1])) @@ -51,7 +51,7 @@ namespace { return str.find_first_of(separators, 2) == pos; } - size_t filename_pos(const string& str,size_t end_pos) + size_t filename_pos(const std::string& str,size_t end_pos) // return 0 if str itself is filename (or empty) { // case: "//" @@ -66,34 +66,36 @@ namespace { // set pos to start of last element size_t pos(str.find_last_of(separators, end_pos-1)); - return (pos == string::npos // path itself must be a filename (or empty) + return (pos == std::string::npos // path itself must be a filename (or empty) || (pos == 1 && is_separator(str[0]))) // or net ? 0 // so filename is entire string : pos + 1; // or starts after delimiter } // return npos if no root_directory found - size_t root_directory_start(const string& path, size_t size) { + size_t root_directory_start(const std::string& path, size_t size) { // case "//" if (size == 2 && is_separator(path[0]) - && is_separator(path[1])) return string::npos; + && is_separator(path[1])) return std::string::npos; // case "//net {/}" if (size > 3 && is_separator(path[0]) && is_separator(path[1]) && !is_separator(path[2])) { - string::size_type pos(path.find_first_of(separators, 2)); - return pos < size ? pos : string::npos; + std::string::size_type pos(path.find_first_of(separators, 2)); + return pos < size ? pos : std::string::npos; } // case "/" if (size > 0 && is_separator(path[0])) return 0; - return string::npos; + return std::string::npos; } } +using Path = dd4hep::Path; + const Path& Path::detail::dot_path() { static Path p("."); return p; @@ -113,7 +115,7 @@ Path Path::normalize() const { if (empty()) return *this; - vector pathes; + std::vector pathes; char tmp[PATH_MAX]; ::strncpy(tmp, string_data(), sizeof(tmp)); tmp[sizeof(tmp)-1] = 0; @@ -124,10 +126,10 @@ Path Path::normalize() const { token = ::strtok_r(0,separators,&save); } Path temp; - vector::const_iterator start(pathes.begin()); - vector::const_iterator last(pathes.end()); - vector::const_iterator stop(last--); - for (vector::const_iterator itr(start); itr != stop; ++itr) { + std::vector::const_iterator start(pathes.begin()); + std::vector::const_iterator last(pathes.end()); + std::vector::const_iterator stop(last--); + for (std::vector::const_iterator itr(start); itr != stop; ++itr) { // ignore "." except at start and last Path itr_path(*itr); if (itr_path.native().size() == 1 @@ -136,7 +138,7 @@ Path Path::normalize() const { && itr != last) continue; // ignore a name and following ".." - if ( temp.empty() && itr_path.find(colon) != string::npos ) { + if ( temp.empty() && itr_path.find(colon) != std::string::npos ) { temp = itr_path; continue; } @@ -145,7 +147,7 @@ Path Path::normalize() const { && (itr_path.native())[0] == dot && (itr_path.native())[1] == dot) // dot dot { - string lf(temp.filename().native()); + std::string lf(temp.filename().native()); if (lf.size() > 0 && (lf.size() != 1 || (lf[0] != dot && lf[0] != separator)) && (lf.size() != 2 || (lf[0] != dot && lf[1] != dot)) ) @@ -165,7 +167,7 @@ Path Path::normalize() const { // } //} - vector::const_iterator next(itr); + std::vector::const_iterator next(itr); if (temp.empty() && ++next != stop && next == last && *last == detail::dot_path()) { temp /= detail::dot_path(); } @@ -192,7 +194,7 @@ size_t Path::parent_path_end() const { ; --end_pos) {} - return (end_pos == 1 && root_dir_pos == 0 && filename_was_separator) ? string::npos : end_pos; + return (end_pos == 1 && root_dir_pos == 0 && filename_was_separator) ? std::string::npos : end_pos; } @@ -203,7 +205,7 @@ Path& Path::remove_filename() { Path Path::parent_path() const { size_t end_pos(parent_path_end()); - return end_pos == string::npos ? Path() : Path(string_data(), string_data() + end_pos); + return end_pos == std::string::npos ? Path() : Path(string_data(), string_data() + end_pos); } Path Path::filename() const diff --git a/DDCore/src/XML/Detector.cpp b/DDCore/src/XML/Detector.cpp index 693f390d2..1662debb3 100644 --- a/DDCore/src/XML/Detector.cpp +++ b/DDCore/src/XML/Detector.cpp @@ -13,7 +13,7 @@ #ifndef DD4HEP_NONE // Framework include files -#include "XML/XMLDetector.h" +#include // Instantiate here the concrete implementations #define DD4HEP_DIMENSION_NS xml diff --git a/DDCore/src/XML/DocumentHandler.cpp b/DDCore/src/XML/DocumentHandler.cpp index 10aa758e6..f929732a2 100644 --- a/DDCore/src/XML/DocumentHandler.cpp +++ b/DDCore/src/XML/DocumentHandler.cpp @@ -12,9 +12,9 @@ //========================================================================== // Framework include files -#include "XML/Printout.h" -#include "XML/UriReader.h" -#include "XML/DocumentHandler.h" +#include +#include +#include // C/C++ include files #include @@ -25,41 +25,39 @@ #ifndef _WIN32 #include #endif -#include "TSystem.h" +#include -using namespace std; -using namespace dd4hep; using namespace dd4hep::xml; namespace { - string undressed_file_name(const string& fn) { + std::string undressed_file_name(const std::string& fn) { if ( !fn.empty() ) { TString tfn(fn); gSystem->ExpandPathName(tfn); - return string(tfn.Data()); + return std::string(tfn.Data()); } return fn; } - int s_minPrintLevel = INFO; + int s_minPrintLevel = dd4hep::INFO; } #ifndef __TIXML__ -#include "xercesc/framework/LocalFileFormatTarget.hpp" -#include "xercesc/framework/StdOutFormatTarget.hpp" -#include "xercesc/framework/MemBufFormatTarget.hpp" -#include "xercesc/framework/MemBufInputSource.hpp" -#include "xercesc/sax/SAXParseException.hpp" -#include "xercesc/sax/EntityResolver.hpp" -#include "xercesc/sax/InputSource.hpp" -#include "xercesc/parsers/XercesDOMParser.hpp" -#include "xercesc/util/XMLEntityResolver.hpp" -#include "xercesc/util/PlatformUtils.hpp" -#include "xercesc/util/XercesDefs.hpp" -#include "xercesc/util/XMLUni.hpp" -#include "xercesc/util/XMLURL.hpp" -#include "xercesc/util/XMLString.hpp" -#include "xercesc/dom/DOM.hpp" -#include "xercesc/sax/ErrorHandler.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace xercesc; @@ -95,7 +93,7 @@ namespace dd4hep { /// Dom Error handler callback bool DocumentErrorHandler::handleError(const DOMError& domError) { - string err = "DOM UNKNOWN: "; + std::string err = "DOM UNKNOWN: "; switch (domError.getSeverity()) { case DOMError::DOM_SEVERITY_WARNING: err = "DOM WARNING: "; @@ -120,22 +118,22 @@ namespace dd4hep { } /// Error handler void DocumentErrorHandler::error(const SAXParseException& e) { - string m(_toString(e.getMessage())); - if (m.find("The values for attribute 'name' must be names or name tokens") != string::npos - || m.find("The values for attribute 'ID' must be names or name tokens") != string::npos - || m.find("for attribute 'name' must be Name or Nmtoken") != string::npos - || m.find("for attribute 'ID' must be Name or Nmtoken") != string::npos - || m.find("for attribute 'name' is invalid Name or NMTOKEN value") != string::npos - || m.find("for attribute 'ID' is invalid Name or NMTOKEN value") != string::npos) + std::string m(_toString(e.getMessage())); + if (m.find("The values for attribute 'name' must be names or name tokens") != std::string::npos + || m.find("The values for attribute 'ID' must be names or name tokens") != std::string::npos + || m.find("for attribute 'name' must be Name or Nmtoken") != std::string::npos + || m.find("for attribute 'ID' must be Name or Nmtoken") != std::string::npos + || m.find("for attribute 'name' is invalid Name or NMTOKEN value") != std::string::npos + || m.find("for attribute 'ID' is invalid Name or NMTOKEN value") != std::string::npos) return; - string sys(_toString(e.getSystemId())); + std::string sys(_toString(e.getSystemId())); printout(ERROR,"XercesC","+++ Error at file \"%s\", Line %d Column: %d Message:%s", sys.c_str(), int(e.getLineNumber()), int(e.getColumnNumber()), m.c_str()); } /// Fatal error handler void DocumentErrorHandler::fatalError(const SAXParseException& e) { - string m(_toString(e.getMessage())); - string sys(_toString(e.getSystemId())); + std::string m(_toString(e.getMessage())); + std::string sys(_toString(e.getSystemId())); printout(FATAL,"XercesC","+++ FATAL Error at file \"%s\", Line %d Column: %d Message:%s", sys.c_str(), int(e.getLineNumber()), int(e.getColumnNumber()), m.c_str()); } @@ -171,13 +169,13 @@ namespace dd4hep { /// Entity resolver overload to use uri reader InputSource *read_uri(XMLResourceIdentifier *id) { if ( m_reader ) { - string buf, systemID(_toString(id->getSystemId())); + std::string buf, systemID(_toString(id->getSystemId())); if ( m_reader->load(systemID, buf) ) { const XMLByte* input = (const XMLByte*)XMLString::replicate(buf.c_str()); #if 0 - string baseURI(_toString(id->getBaseURI())); - string schema(_toString(id->getSchemaLocation())); - string ns(_toString(id->getNameSpace())); + std::string baseURI(_toString(id->getBaseURI())); + std::string schema(_toString(id->getSchemaLocation())); + std::string ns(_toString(id->getNameSpace())); if ( s_minPrintLevel <= INFO ) { printout(INFO,"XercesC","+++ Resolved URI: sysID:%s uri:%s ns:%s schema:%s", systemID.c_str(), baseURI.c_str(), ns.c_str(), schema.c_str()); @@ -208,7 +206,7 @@ namespace dd4hep { } /// Dump DOM tree using XercesC handles - void dumpTree(DOMNode* doc, ostream& os) { + void dumpTree(DOMNode* doc, std::ostream& os) { if ( doc ) { DOMImplementation *imp = DOMImplementationRegistry::getDOMImplementation(Strng_t("LS")); MemBufFormatTarget *tar = new MemBufFormatTarget(); @@ -217,7 +215,7 @@ namespace dd4hep { out->setByteStream(tar); wrt->getDomConfig()->setParameter(Strng_t("format-pretty-print"), true); wrt->write(doc, out); - os << tar->getRawBuffer() << endl << flush; + os << tar->getRawBuffer() << std::endl << std::flush; out->release(); wrt->release(); return; @@ -226,15 +224,15 @@ namespace dd4hep { } /// Dump DOM tree using XercesC handles - void dump_doc(DOMDocument* doc, ostream& os) { + void dump_doc(DOMDocument* doc, std::ostream& os) { dumpTree(doc,os); } /// Dump DOM tree using XercesC handles - void dump_tree(Handle_t elt, ostream& os) { + void dump_tree(Handle_t elt, std::ostream& os) { dumpTree((DOMNode*)elt.ptr(),os); } /// Dump DOM tree using XercesC handles - void dump_tree(Document doc, ostream& os) { + void dump_tree(Document doc, std::ostream& os) { dump_doc((DOMDocument*)doc.ptr(),os); } } @@ -242,36 +240,36 @@ namespace dd4hep { #ifdef DD4HEP_NONE /// System ID of a given XML entity -string DocumentHandler::system_path(Handle_t base, const string& fn) { - string path = system_path(base); - string dir = ::dirname((char*)path.c_str()); +std::string DocumentHandler::system_path(Handle_t base, const std::string& fn) { + std::string path = system_path(base); + std::string dir = ::dirname((char*)path.c_str()); return dir+fn; } #else -#include "TUri.h" -#include "TUrl.h" +#include +#include #endif /// System ID of a given XML entity -string DocumentHandler::system_path(Handle_t base, const string& fn) { - string path, dir = system_path(base); +std::string DocumentHandler::system_path(Handle_t base, const std::string& fn) { + std::string path, dir = system_path(base); TUri uri_base(dir.c_str()), uri_rel(fn.c_str()); TUrl url_base(dir.c_str()); path = TUri::MergePaths(uri_rel,uri_base); TUri final(path.c_str()); final.Normalise(); - path = url_base.GetProtocol()+string("://")+final.GetUri().Data(); + path = url_base.GetProtocol()+std::string("://")+final.GetUri().Data(); if ( path[path.length()-1]=='/' ) path = path.substr(0,path.length()-1); return path; } /// System ID of a given XML entity -string DocumentHandler::system_path(Handle_t base) { +std::string DocumentHandler::system_path(Handle_t base) { DOMElement* elt = (DOMElement*)base.ptr(); - string path = _toString(elt->getBaseURI()); + std::string path = _toString(elt->getBaseURI()); if ( path[0] == '/' ) { - string tmp = "file:"+path; + std::string tmp = "file:"+path; return tmp; } return path; @@ -279,7 +277,7 @@ string DocumentHandler::system_path(Handle_t base) { /// Load secondary XML file with relative addressing with respect to handle Document DocumentHandler::load(Handle_t base, const XMLCh* fname, UriReader* reader) const { - string path; + std::string path; DOMElement* elt = (DOMElement*)base.ptr(); try { Document doc; @@ -294,21 +292,21 @@ Document DocumentHandler::load(Handle_t base, const XMLCh* fname, UriReader* rea } return load(path, reader); } - catch(const exception& exc) { - string b = _toString(elt->getBaseURI()); - string e = _toString(fname); + catch(const std::exception& exc) { + std::string b = _toString(elt->getBaseURI()); + std::string e = _toString(fname); printout(DEBUG,"DocumentHandler","+++ URI exception: %s -> %s [%s]",b.c_str(),e.c_str(),exc.what()); } catch(...) { - string b = _toString(elt->getBaseURI()); - string e = _toString(fname); + std::string b = _toString(elt->getBaseURI()); + std::string e = _toString(fname); printout(DEBUG,"DocumentHandler","+++ URI exception: %s -> %s",b.c_str(),e.c_str()); } if ( reader ) { - string buf, sys = system_path(base,fname); + std::string buf, sys = system_path(base,fname); #if 0 - string buf, sys, dir = _toString(elt->getBaseURI()); - string fn = _toString(fname); + std::string buf, sys, dir = _toString(elt->getBaseURI()); + std::string fn = _toString(fname); dir = ::dirname((char*)dir.c_str()); while( fn.substr(0,3) == "../" ) { dir = ::dirname((char*)dir.c_str()); @@ -329,21 +327,21 @@ Document DocumentHandler::load(Handle_t base, const XMLCh* fname, UriReader* rea } /// Load XML file and parse it using URI resolver to read data. -Document DocumentHandler::load(const string& fname, UriReader* reader) const { - string path; +Document DocumentHandler::load(const std::string& fname, UriReader* reader) const { + std::string path; printout(DEBUG,"DocumentHandler","+++ Loading document URI: %s",fname.c_str()); try { size_t idx = fname.find(':'); size_t idq = fname.find('/'); - if ( idq == string::npos ) idq = 0; - XMLURL xerurl = (const XMLCh*) Strng_t(idx==string::npos || idx>idq ? "file:"+fname : fname); - string proto = _toString(xerurl.getProtocolName()); + if ( idq == std::string::npos ) idq = 0; + XMLURL xerurl = (const XMLCh*) Strng_t(idx==std::string::npos || idx>idq ? "file:"+fname : fname); + std::string proto = _toString(xerurl.getProtocolName()); path = _toString(xerurl.getPath()); printout(DEBUG,"DocumentHandler","+++ protocol:%s path:%s",proto.c_str(), path.c_str()); } catch(...) { } - unique_ptr < XercesDOMParser > parser(make_parser(reader)); + std::unique_ptr < XercesDOMParser > parser(make_parser(reader)); try { if ( !path.empty() ) { parser->parse(path.c_str()); @@ -358,13 +356,13 @@ Document DocumentHandler::load(const string& fname, UriReader* reader) const { return (XmlDocument*)0; } } - catch (const exception& e) { + catch (const std::exception& e) { printout(ERROR,"DocumentHandler","+++ Exception(XercesC): parse(path):%s",e.what()); try { parser->parse(fname.c_str()); if ( reader ) reader->parserLoaded(path); } - catch (const exception& ex) { + catch (const std::exception& ex) { printout(FATAL,"DocumentHandler","+++ Exception(XercesC): parse(URI):%s",ex.what()); throw; } @@ -375,7 +373,7 @@ Document DocumentHandler::load(const string& fname, UriReader* reader) const { /// Parse a standalong XML string into a document. Document DocumentHandler::parse(const char* bytes, size_t length, const char* sys_id, UriReader* rdr) const { - unique_ptr < XercesDOMParser > parser(make_parser(rdr)); + std::unique_ptr < XercesDOMParser > parser(make_parser(rdr)); MemBufInputSource src((const XMLByte*)bytes, length, sys_id, false); parser->parse(src); DOMDocument* doc = parser->adoptDocument(); @@ -385,7 +383,7 @@ Document DocumentHandler::parse(const char* bytes, size_t length, const char* sy } /// Write xml document to output file (stdout if file name empty) -int DocumentHandler::output(Document doc, const string& fname) const { +int DocumentHandler::output(Document doc, const std::string& fname) const { XMLFormatTarget *tar = 0; DOMImplementation *imp = DOMImplementationRegistry::getDOMImplementation(Strng_t("LS")); DOMLSOutput *out = imp->createLSOutput(); @@ -394,7 +392,7 @@ int DocumentHandler::output(Document doc, const string& fname) const { if (fname.empty()) tar = new StdOutFormatTarget(); else { - string fn = undressed_file_name(fname); + std::string fn = undressed_file_name(fname); tar = new LocalFileFormatTarget(Strng_t(fn)); } out->setByteStream(tar); @@ -408,7 +406,7 @@ int DocumentHandler::output(Document doc, const string& fname) const { #else -#include "XML/tinyxml.h" +#include /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -434,7 +432,7 @@ namespace dd4hep { }} namespace { - static string _clean_fname(const string& s) { + static std::string _clean_fname(const std::string& s) { std::string const& temp = getEnviron(s); std::string temp2 = undressed_file_name(temp.empty() ? s : temp); if ( strncmp(temp2.c_str(),"file:",5)==0 ) return temp2.substr(5); @@ -443,13 +441,13 @@ namespace { } /// System ID of a given XML entity -string DocumentHandler::system_path(Handle_t base, const string& fname) { - string fn, clean = _clean_fname(fname); +std::string DocumentHandler::system_path(Handle_t base, const std::string& fname) { + std::string fn, clean = _clean_fname(fname); struct stat st; Element elt(base); // Poor man's URI handling. Xerces is much much better here if ( elt ) { - string bn = Xml(elt.document()).d->Value(); + std::string bn = Xml(elt.document()).d->Value(); #ifdef _WIN32 char drive[_MAX_DRIVE], dir[_MAX_DIR], file[_MAX_FNAME], ext[_MAX_EXT]; ::_splitpath(bn.c_str(),drive,dir,file,ext); @@ -472,8 +470,8 @@ string DocumentHandler::system_path(Handle_t base, const string& fname) { } /// System ID of a given XML entity -string DocumentHandler::system_path(Handle_t base) { - string fn; +std::string DocumentHandler::system_path(Handle_t base) { + std::string fn; Element elt(base); // Poor man's URI handling. Xerces is much much better here if ( elt ) { @@ -484,7 +482,7 @@ string DocumentHandler::system_path(Handle_t base) { /// Load XML file and parse it using URI resolver to read data. Document DocumentHandler::load(const std::string& fname, UriReader* reader) const { - string clean = _clean_fname(fname); + std::string clean = _clean_fname(fname); if ( reader ) { printout(WARNING,"DocumentHandler","+++ Loading document URI: %s %s", fname.c_str(),"[URI Resolution is not supported by TiXML]"); @@ -526,7 +524,7 @@ Document DocumentHandler::load(const std::string& fname, UriReader* reader) cons /// Load XML file and parse it using URI resolver to read data. Document DocumentHandler::load(Handle_t base, const XmlChar* fname, UriReader* reader) const { - string path = system_path(base, fname); + std::string path = system_path(base, fname); return load(path,reader); } @@ -543,7 +541,7 @@ Document DocumentHandler::parse(const char* bytes, size_t length, const char* /* size_t len = length; // TiXml does not support white spaces at the end. Check and remove. if ( str_len+1 != len || bytes[str_len] != 0 || ::isspace(bytes[str_len-1]) ) { - unique_ptr data(new char[len+1]); + std::unique_ptr data(new char[len+1]); char* buff = data.get(); try { ::memcpy(buff, bytes, len+1); @@ -567,13 +565,13 @@ Document DocumentHandler::parse(const char* bytes, size_t length, const char* /* printout(FATAL,"DocumentHandler", "+++ XML Document error: %s Location Line:%d Column:%d", doc->Value(), doc->ErrorRow(), doc->ErrorCol()); - throw runtime_error(string("dd4hep: ")+doc->ErrorDesc()); + throw std::runtime_error(std::string("dd4hep: ")+doc->ErrorDesc()); } - throw runtime_error("dd4hep: Unknown error while parsing XML document string with TiXml."); + throw std::runtime_error("dd4hep: Unknown error while parsing XML document string with TiXml."); } - throw runtime_error("dd4hep: FAILED to parse invalid document string [NULL] with TiXml."); + throw std::runtime_error("dd4hep: FAILED to parse invalid document string [NULL] with TiXml."); } - catch(exception& e) { + catch(std::exception& e) { printout(ERROR,"DocumentHandler","+++ Exception (TinyXML): parse(string):%s",e.what()); } delete doc; @@ -581,8 +579,8 @@ Document DocumentHandler::parse(const char* bytes, size_t length, const char* /* } /// Write xml document to output file (stdout if file name empty) -int DocumentHandler::output(Document doc, const string& fname) const { - string fn = undressed_file_name(fname); +int DocumentHandler::output(Document doc, const std::string& fname) const { + std::string fn = undressed_file_name(fname); FILE* file = fn.empty() ? stdout : ::fopen(fn.c_str(),"w"); if ( !file ) { printout(ERROR,"DocumentHandler","+++ Failed to open output file: %s",fname.c_str()); @@ -595,7 +593,7 @@ int DocumentHandler::output(Document doc, const string& fname) const { } /// Dump partial or full XML trees -void dd4hep::xml::dump_tree(Handle_t elt, ostream& os) { +void dd4hep::xml::dump_tree(Handle_t elt, std::ostream& os) { TiXmlNode* node = (TiXmlNode*)elt.ptr(); TiXmlPrinter printer; printer.SetStreamPrinting(); @@ -604,7 +602,7 @@ void dd4hep::xml::dump_tree(Handle_t elt, ostream& os) { } /// Dump partial or full XML documents -void dd4hep::xml::dump_tree(Document doc, ostream& os) { +void dd4hep::xml::dump_tree(Document doc, std::ostream& os) { TiXmlDocument* node = (TiXmlDocument*)doc.ptr(); TiXmlPrinter printer; printer.SetStreamPrinting(); @@ -659,29 +657,29 @@ Document DocumentHandler::parse(const char* bytes, size_t length) const { } /// System ID of a given XML entity -string DocumentHandler::system_path(Handle_t base, const XmlChar* fname) { - string fn = _toString(fname); +std::string DocumentHandler::system_path(Handle_t base, const XmlChar* fname) { + std::string fn = _toString(fname); return system_path(base, fn); } /// System directory of a given XML entity -string DocumentHandler::system_directory(Handle_t base, const XmlChar* fname) { - string path = system_path(base,fname); - string dir = ::dirname((char*)path.c_str()); +std::string DocumentHandler::system_directory(Handle_t base, const XmlChar* fname) { + std::string path = system_path(base,fname); + std::string dir = ::dirname((char*)path.c_str()); return dir; } /// System directory of a given XML entity -string DocumentHandler::system_directory(Handle_t base) { - string path = system_path(base); - string dir = ::dirname((char*)path.c_str()); +std::string DocumentHandler::system_directory(Handle_t base) { + std::string path = system_path(base); + std::string dir = ::dirname((char*)path.c_str()); return dir; } /// Create new XML document by parsing empty xml buffer Document DocumentHandler::create(const char* tag, const char* comment) const { - string top(tag); - string empty = "\n"; + std::string top(tag); + std::string empty = "\n"; empty += "<" + top + "/>\0\0"; Document doc = parse(empty.c_str(), empty.length() + 1); if (comment) { @@ -698,10 +696,10 @@ Document DocumentHandler::create(const std::string& tag, const std::string& comm /// Dump partial or full XML trees to stdout void dd4hep::xml::dump_tree(Handle_t elt) { - dump_tree(elt,cout); + dump_tree(elt,std::cout); } /// Dump partial or full XML documents to stdout void dd4hep::xml::dump_tree(Document doc) { - dump_tree(doc,cout); + dump_tree(doc,std::cout); } diff --git a/DDCore/src/XML/Layering.cpp b/DDCore/src/XML/Layering.cpp index a3e6a285e..c1f37895b 100644 --- a/DDCore/src/XML/Layering.cpp +++ b/DDCore/src/XML/Layering.cpp @@ -13,107 +13,92 @@ #ifndef DD4HEP_NONE // Framework include files -#include "DD4hep/Primitives.h" -#include "XML/XMLDetector.h" -#include "XML/Layering.h" -#include "XML/XMLTags.h" +#include +#include +#include +#include -// C/C++ include files -#include -#include -#include -#include - -using namespace std; -using namespace dd4hep; -using namespace dd4hep::xml; - -void Layer::compute() { +void dd4hep::Layer::compute() { _thickness = 0.; - for (vector::const_iterator i = _slices.begin(); i != _slices.end(); ++i) + for (std::vector::const_iterator i = _slices.begin(); i != _slices.end(); ++i) _thickness += (*i)._thickness; } -double LayerStack::sectionThickness(size_t is, size_t ie) const { +double dd4hep::LayerStack::sectionThickness(std::size_t is, std::size_t ie) const { double thick = 0.; if (is > ie) - throw runtime_error( - "LayerStack::sectionThickness: First index (" + _toString(is) + ") " - "must be <= second index (" + _toString(ie) + ")!"); + except("LayerStack", + "sectionThickness: First index (%ld) must be <= second index (%ld)!", is, ie); else if (is > _layers.size()) - throw runtime_error( - "LayerStack::sectionThickness: First index (" + _toString(is) + ") " - "out of range. #layers=" + _toString(_layers.size()) - + ")."); + except("LayerStack", + "sectionThickness: First index (%ld) out of range. #layers=%ld).", is, _layers.size()); else if (ie > _layers.size()) - throw runtime_error( - "LayerStack::sectionThickness: Second index (" + _toString(is) + ") " - "out of range. #layers=" + _toString(_layers.size()) - + ")."); - for (size_t i = is; i <= ie; ++i) + except("LayerStack", + "sectionThickness: Second index (%ld) out of range. #layers=%ld).", is, _layers.size()); + for (std::size_t i = is; i <= ie; ++i) thick += _layers[i]->thicknessWithPreOffset(); return thick; } -Layering::Layering(Element e) { - LayeringCnv(e).fromCompact(*this); -} - -const Layer* Layering::layer(size_t which) const { - return _stack.layers()[which]; -} - -void LayeringCnv::fromCompact(Layering& layering) const { - vector& layers = layering.layers(); +void dd4hep::xml::LayeringCnv::fromCompact(Layering& layering) const { + std::vector& layers = layering.layers(); int count = 0; for_each(layers.begin(), layers.end(), detail::deletePtr); - for (Collection_t c(m_element, _U (layer)); c; ++c) { + for( xml_coll_t c(m_element, _U (layer)); c; ++c ) { Layer lay; - Component layer = c; + xml_comp_t layer = c; int repeat = layer.hasAttr(_U(repeat)) ? layer.repeat() : 1; ++count; - for (Collection_t s(c, _U(slice)); s; ++s) { - Component slice = s; - string mat = slice.materialStr(); - LayerSlice lslice(slice.isSensitive(), slice.thickness(), mat); + for (xml_coll_t s(c, _U(slice)); s; ++s) { + xml_comp_t slice = s; + std::string material = slice.materialStr(); + LayerSlice lslice(slice.isSensitive(), slice.thickness(), material); lay.add(lslice); } lay.compute(); // Add layer to stack once for each repetition - for (int k = 0; k < repeat; ++k) + for( int k = 0; k < repeat; ++k ) layers.emplace_back(new Layer(lay)); } if (0 == count) { - throw runtime_error("LayeringCnv::fromCompact: No layer children to be build!"); + throw std::runtime_error("LayeringCnv::fromCompact: No layer children to be build!"); } } -double Layering::singleLayerThickness(xml::Element e) const { - Component lay = e; +dd4hep::Layering::Layering(xml_elt_t e) { + xml::LayeringCnv(e).fromCompact(*this); +} + +const dd4hep::Layer* dd4hep::Layering::layer(std::size_t which) const { + return _stack.layers()[which]; +} + +double dd4hep::Layering::singleLayerThickness(xml_elt_t e) const { + xml_comp_t lay = e; double thickness = 0e0; - for (Collection_t s(lay, _U(slice)); s; ++s) { - Component slice = s; + for (xml_coll_t s(lay, _U(slice)); s; ++s) { + xml_comp_t slice = s; thickness += slice.thickness(); } return thickness; } -double Layering::absorberThicknessInLayer(xml::Element e) const { - Component lay = e; +double dd4hep::Layering::absorberThicknessInLayer(xml_elt_t e) const { + xml_comp_t lay = e; double thickness = 0e0; - for (Collection_t s(lay, _U(slice)); s; ++s) { - Component slice = s; + for (xml_coll_t s(lay, _U(slice)); s; ++s) { + xml_comp_t slice = s; if (slice.isRadiator()) thickness += slice.thickness(); } return thickness; } -void Layering::sensitivePositionsInLayer(xml::Element e, std::vector& sens_pos) const { - Component lay = e; - double pos=-singleLayerThickness(e)/2.0; - for (Collection_t s(lay, _U(slice)); s; ++s) { - Component slice = s; +void dd4hep::Layering::sensitivePositionsInLayer(xml_elt_t e, std::vector& sens_pos) const { + xml_comp_t lay = e; + double pos =- singleLayerThickness(e)/2.0; + for (xml_coll_t s(lay, _U(slice)); s; ++s) { + xml_comp_t slice = s; pos += slice.thickness(); if (slice.isSensitive()){ //store the position at the center of the slice @@ -123,8 +108,8 @@ void Layering::sensitivePositionsInLayer(xml::Element e, std::vector& se } -Layering::~Layering(){ - vector& layers = this->layers(); +dd4hep::Layering::~Layering(){ + std::vector& layers = this->layers(); for_each(layers.begin(), layers.end(), detail::deletePtr); layers.clear(); } diff --git a/DDCore/src/XML/UriReader.cpp b/DDCore/src/XML/UriReader.cpp index 8efc65272..eaa7cec8a 100644 --- a/DDCore/src/XML/UriReader.cpp +++ b/DDCore/src/XML/UriReader.cpp @@ -12,21 +12,19 @@ //========================================================================== // Framework include files -#include "XML/UriReader.h" - -using namespace std; +#include /// Default destructor dd4hep::xml::UriReader::~UriReader() { } /// Resolve a given URI to a string containing the data -bool dd4hep::xml::UriReader::load(const string& system_id, string& data) { +bool dd4hep::xml::UriReader::load(const std::string& system_id, std::string& data) { return this->load(system_id, context(), data); } /// Inform reader about a locally (e.g. by XercesC) handled source load -void dd4hep::xml::UriReader::parserLoaded(const string& system_id) { +void dd4hep::xml::UriReader::parserLoaded(const std::string& system_id) { this->parserLoaded(system_id, context()); } @@ -57,21 +55,21 @@ bool dd4hep::xml::UriContextReader::isBlocked(const std::string& path) const { } /// Resolve a given URI to a string containing the data -bool dd4hep::xml::UriContextReader::load(const string& system_id, string& data) { +bool dd4hep::xml::UriContextReader::load(const std::string& system_id, std::string& data) { return m_reader->load(system_id, context(), data); } /// Resolve a given URI to a string containing the data -bool dd4hep::xml::UriContextReader::load(const string& system_id, UserContext* ctxt, string& data) { +bool dd4hep::xml::UriContextReader::load(const std::string& system_id, UserContext* ctxt, std::string& data) { return m_reader->load(system_id, ctxt, data); } /// Inform reader about a locally (e.g. by XercesC) handled source load -void dd4hep::xml::UriContextReader::parserLoaded(const string& system_id) { +void dd4hep::xml::UriContextReader::parserLoaded(const std::string& system_id) { m_reader->parserLoaded(system_id, context()); } /// Inform reader about a locally (e.g. by XercesC) handled source load -void dd4hep::xml::UriContextReader::parserLoaded(const string& system_id, UserContext* ctxt) { +void dd4hep::xml::UriContextReader::parserLoaded(const std::string& system_id, UserContext* ctxt) { m_reader->parserLoaded(system_id, ctxt); } diff --git a/DDCore/src/XML/Utilities.cpp b/DDCore/src/XML/Utilities.cpp index 32c6f95f0..f26e7b4b7 100644 --- a/DDCore/src/XML/Utilities.cpp +++ b/DDCore/src/XML/Utilities.cpp @@ -13,19 +13,17 @@ #ifndef DD4HEP_NONE // Framework include files -#include "XML/Utilities.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Plugins.h" -#include "DD4hep/Detector.h" -#include "DD4hep/DetFactoryHelper.h" -#include "Math/Polar2D.h" +#include +#include +#include +#include +#include +#include class TObject; -using namespace std; -using namespace dd4hep; -using namespace dd4hep::detail; using namespace dd4hep::xml::tools; +using dd4hep::printout; namespace { static constexpr const char* TAG_LIMITSETREF = "limitsetref"; @@ -40,11 +38,11 @@ namespace { } /// Create layered transformation from xml information -Transform3D dd4hep::xml::createTransformation(xml::Element e) { +dd4hep::Transform3D dd4hep::xml::createTransformation(xml::Element e) { int flag = 0; Transform3D position, rotation, result; for( xml_coll_t c(e,_U(star)); c; ++c ) { - string tag = c.tag(); + std::string tag = c.tag(); xml_dim_t x_elt = c; if ( tag == "positionRPhiZ" ) { if ( flag == 1 ) result = position * result; @@ -82,56 +80,56 @@ Transform3D dd4hep::xml::createTransformation(xml::Element e) { } /// Create a solid shape using the plugin mechanism from the attributes of the XML element -Solid dd4hep::xml::createShape(Detector& description, - const std::string& shape_type, - xml::Element element) { - string fac = shape_type + "__shape_constructor"; +dd4hep::Solid dd4hep::xml::createShape(Detector& description, + const std::string& shape_type, + xml::Element element) { + std::string fac = shape_type + "__shape_constructor"; xml::Handle_t solid_elt = element; Solid solid = Solid(PluginService::Create(fac, &description, &solid_elt)); if ( !solid.isValid() ) { PluginDebug dbg; PluginService::Create(fac, &description, &solid_elt); - except("xml::createShape","Failed to create solid of type %s [%s]", - shape_type.c_str(),dbg.missingFactory(shape_type).c_str()); + dd4hep::except("xml::createShape","Failed to create solid of type %s [%s]", + shape_type.c_str(),dbg.missingFactory(shape_type).c_str()); } return solid; } /// Create a volume using the plugin mechanism from the attributes of the XML element -Volume dd4hep::xml::createStdVolume(Detector& description, xml::Element element) { +dd4hep::Volume dd4hep::xml::createStdVolume(Detector& description, xml::Element element) { xml_dim_t e(element); if ( e.hasAttr(_U(material)) ) { xml_dim_t x_s = e.child(_U(shape)); - string typ = x_s.typeStr(); - Material mat = description.material(e.attr(_U(material))); + std::string typ = x_s.typeStr(); + Material mat = description.material(e.attr(_U(material))); Solid sol = createShape(description, typ, x_s); Volume vol("volume", sol, mat); - if ( e.hasAttr(_U(name)) ) vol->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) vol->SetName(e.attr(_U(name)).c_str()); vol.setAttributes(description,e.regionStr(),e.limitsStr(),e.visStr()); return vol; } xml_h h = e; xml_attr_t a = h.attr_nothrow(_U(type)); if ( a ) { - string typ = h.attr(a); + std::string typ = h.attr(a); if ( typ.substr(1) == "ssembly" ) { Assembly vol("assembly"); - if ( e.hasAttr(_U(name)) ) vol->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) vol->SetName(e.attr(_U(name)).c_str()); vol.setAttributes(description,e.regionStr(),e.limitsStr(),e.visStr()); return vol; } } - except("xml::createVolume","Failed to create volume. No material specified!"); + dd4hep::except("xml::createVolume","Failed to create volume. No material specified!"); return Volume(); } /// Create a volume using the plugin mechanism from the attributes of the XML element -Volume dd4hep::xml::createVolume(Detector& description, - const std::string& typ, - xml::Element element) { +dd4hep::Volume dd4hep::xml::createVolume(Detector& description, + const std::string& typ, + xml::Element element) { if ( !typ.empty() ) { xml_dim_t e(element); - string fac = typ + "__volume_constructor"; + std::string fac = typ + "__volume_constructor"; xml::Handle_t elt = element; TObject* obj = PluginService::Create(fac, &description, &elt); Volume vol = Volume(dynamic_cast(obj)); @@ -141,20 +139,20 @@ Volume dd4hep::xml::createVolume(Detector& description, except("xml::createShape","Failed to create volume of type %s [%s]", typ.c_str(),dbg.missingFactory(typ).c_str()); } - if ( e.hasAttr(_U(name)) ) vol->SetName(e.attr(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) vol->SetName(e.attr(_U(name)).c_str()); vol.setAttributes(description,e.regionStr(),e.limitsStr(),e.visStr()); return vol; } - except("xml::createVolume","Failed to create volume. No materiaWNo type specified!"); + dd4hep::except("xml::createVolume","Failed to create volume. No materiaWNo type specified!"); return Volume(); } -Volume dd4hep::xml::createPlacedEnvelope( dd4hep::Detector& description, - dd4hep::xml::Handle_t e, - dd4hep::DetElement sdet) +dd4hep::Volume dd4hep::xml::createPlacedEnvelope( dd4hep::Detector& description, + dd4hep::xml::Handle_t e, + dd4hep::DetElement sdet) { xml_det_t x_det = e; - string det_name = x_det.nameStr(); + std::string det_name = x_det.nameStr(); xml_comp_t x_env = x_det.child( dd4hep::xml::Strng_t("envelope") ) ; xml_comp_t x_shape = x_env.child( _U(shape) ); @@ -185,23 +183,14 @@ Volume dd4hep::xml::createPlacedEnvelope( dd4hep::Detector& description, Box env_solid = xml_comp_t( x_shape ).createShape(); if( !env_solid.isValid() ){ - - throw std::runtime_error( std::string(" Cannot create envelope volume : ") + x_shape.typeStr() + - std::string(" for detector " ) + det_name ) ; + dd4hep::except("createPlacedEnvelope","Cannot create envelope volume : %s for detector %s.", + x_shape.typeStr(), det_name.c_str()); } - Material env_mat = description.material( x_shape.materialStr() ); - envelope = Volume( det_name+"_envelope", env_solid, env_mat ); } - - PlacedVolume env_pv ; - - Volume mother = description.pickMotherVolume(sdet); - - // ---- place the envelope into the mother volume // only specify transformations given in xml // to allow for optimization @@ -223,10 +212,9 @@ Volume dd4hep::xml::createPlacedEnvelope( dd4hep::Detector& description, return envelope; } - void dd4hep::xml::setDetectorTypeFlag( dd4hep::xml::Handle_t e, dd4hep::DetElement sdet ) { xml_det_t x_det = e; - string det_name = x_det.nameStr(); + std::string det_name = x_det.nameStr(); try{ xml_comp_t x_dettype = x_det.child( dd4hep::xml::Strng_t("type_flags") ) ; @@ -245,21 +233,21 @@ void dd4hep::xml::setDetectorTypeFlag( dd4hep::xml::Handle_t e, dd4hep::DetElem namespace { template - std::size_t _propagate(bool debug, - bool apply_to_children, - Volume vol, - TYPE item, - const Volume& (Volume::*apply)(const TYPE&) const) { + std::size_t _propagate(bool debug, + bool apply_to_children, + dd4hep::Volume vol, + TYPE item, + const dd4hep::Volume& (dd4hep::Volume::*apply)(const TYPE&) const) { std::size_t count = 0; if ( !vol->IsAssembly() ) { - printout(debug ? ALWAYS : DEBUG,"VolumeConfig", "++ Volume: %s apply setting %s", vol.name(), item.name()); + printout(debug ? dd4hep::ALWAYS : dd4hep::DEBUG,"VolumeConfig", "++ Volume: %s apply setting %s", vol.name(), item.name()); (vol.*apply)(item); ++count; } if ( apply_to_children ) { - std::set handled; + std::set handled; for (Int_t idau = 0, ndau = vol->GetNdaughters(); idau < ndau; ++idau) { - Volume v = vol->GetNode(idau)->GetVolume(); + dd4hep::Volume v = vol->GetNode(idau)->GetVolume(); if ( handled.find(v) == handled.end() ) { handled.insert(v); count += _propagate(debug, apply_to_children, v, item, apply); @@ -268,7 +256,6 @@ namespace { } return count; } - } /// Configure volume properties from XML element diff --git a/DDCore/src/XML/VolumeBuilder.cpp b/DDCore/src/XML/VolumeBuilder.cpp index 67e73543e..b9929e099 100644 --- a/DDCore/src/XML/VolumeBuilder.cpp +++ b/DDCore/src/XML/VolumeBuilder.cpp @@ -13,21 +13,17 @@ #ifndef DD4HEP_NONE // Framework include files -#include "XML/VolumeBuilder.h" -#include "XML/Utilities.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Plugins.h" -#include "DD4hep/Detector.h" -#include "DD4hep/DetFactoryHelper.h" -#include "Math/Polar2D.h" +#include +#include +#include +#include +#include +#include +#include -#include "TClass.h" +#include - -using namespace std; -using namespace dd4hep; -using namespace dd4hep::detail; -using namespace dd4hep::xml::tools; +using dd4hep::xml::tools::VolumeBuilder; /// Initializing constructor VolumeBuilder::VolumeBuilder(Detector& dsc, xml_h x_parent, SensitiveDetector sd) @@ -42,13 +38,13 @@ VolumeBuilder::VolumeBuilder(Detector& dsc, xml_h x_parent, SensitiveDetector sd } /// Collect a set of materials from the leafs of an xml tag -size_t VolumeBuilder::collectMaterials(xml_h element) { - size_t len = materials.size(); +std::size_t VolumeBuilder::collectMaterials(xml_h element) { + std::size_t len = materials.size(); for( xml_coll_t c(element,_U(material)); c; ++c ) { - xml_comp_t x_c = c; - string nam = x_c.nameStr(); - string val = x_c.valueStr(); - Material mat = description.material(val); + xml_comp_t x_c = c; + std::string nam = x_c.nameStr(); + std::string val = x_c.valueStr(); + Material mat = description.material(val); materials[nam] = mat; } return materials.size()-len; @@ -58,7 +54,7 @@ size_t VolumeBuilder::collectMaterials(xml_h element) { void VolumeBuilder::registerShape(const std::string& nam, Solid shape) { auto is = shapes.find(nam); if ( is == shapes.end() ) { - shapes[nam] = make_pair(xml_h(0), shape); + shapes[nam] = std::make_pair(xml_h(0), shape); return; } except("VolumeBuilder","+++ Shape %s is already known to this builder unit. ",nam.c_str()); @@ -74,14 +70,14 @@ void VolumeBuilder::registerVolume(const std::string& nam, Volume volume) { volume.solid()->IsA()->GetName(), volume.visAttributes().name(), yes_no(volume.isSensitive())); - volumes[nam] = make_pair(xml_h(0), volume); + volumes[nam] = std::make_pair(xml_h(0), volume); return; } except("VolumeBuilder","+++ Volume %s is already known to this builder unit. ",nam.c_str()); } /// Access a registered volume by name -Volume VolumeBuilder::volume(const std::string& nam) const { +dd4hep::Volume VolumeBuilder::volume(const std::string& nam) const { auto iv = volumes.find(nam); if ( iv == volumes.end() ) { auto ib = vol_veto.find(nam); @@ -99,7 +95,7 @@ Volume VolumeBuilder::volume(const std::string& nam) const { } /// Access element from shape cache by name. Invalid returns means 'veto'. Otherwise exception -Solid VolumeBuilder::getShape(const string& nam) const { +dd4hep::Solid VolumeBuilder::getShape(const std::string& nam) const { auto is = shapes.find(nam); if ( is == shapes.end() ) { auto ib = shape_veto.find(nam); @@ -117,12 +113,12 @@ Solid VolumeBuilder::getShape(const string& nam) const { } /// Create a new shape from the information given in the xml handle -Solid VolumeBuilder::makeShape(xml_h handle) { - xml_comp_t x = handle; - string nam; - xml_attr_t a = handle.attr_nothrow(_U(name)); +dd4hep::Solid VolumeBuilder::makeShape(xml_h handle) { + xml_comp_t x = handle; + xml_attr_t a = handle.attr_nothrow(_U(name)); + std::string nam; if ( a ) { - nam = handle.attr(a); + nam = handle.attr(a); auto is = shapes.find(nam); if ( is != shapes.end() ) { except("VolumeBuilder","+++ The named shape %s is already known to this builder unit. " @@ -139,7 +135,7 @@ Solid VolumeBuilder::makeShape(xml_h handle) { /// Check if this volume is part of the volumes to be built for this description type a = handle.attr_nothrow(_U(build)); if ( a ) { - string build = handle.attr(a); + std::string build = handle.attr(a); if ( !buildMatch(build,buildType) ) { printout(INFO,"VolumeBuilder", "+++ Shape %s does NOT match build requirements. [Ignored]",nam.c_str()); @@ -148,7 +144,7 @@ Solid VolumeBuilder::makeShape(xml_h handle) { } } /// Now we create the shape.... - string type = x.attr(_U(type)); + std::string type = x.attr(_U(type)); Solid solid = xml::createShape(description, type, x); if ( !solid.isValid() ) { except("VolumeBuilder","+++ Failed to create shape %s of type: %s", @@ -157,7 +153,7 @@ Solid VolumeBuilder::makeShape(xml_h handle) { /// And register it if it is not anonymous if ( !nam.empty() ) { solid.setName(nam); - shapes.emplace(nam,make_pair(handle,solid)); + shapes.emplace(nam,std::make_pair(handle,solid)); } printout(debug ? ALWAYS : DEBUG, "VolumeBuilder", "+++ Created shape of type: %s name: %s",type.c_str(), nam.c_str()); @@ -165,17 +161,17 @@ Solid VolumeBuilder::makeShape(xml_h handle) { } /// Build all identifiers in the passed parent xml element -size_t VolumeBuilder::buildShapes(xml_h handle) { - size_t len = shapes.size(); +std::size_t VolumeBuilder::buildShapes(xml_h handle) { + std::size_t len = shapes.size(); for( xml_coll_t c(handle,_U(shape)); c; ++c ) { xml_elt_t x = c; - string nam = x.attr(_U(name)); + std::string nam = x.attr(_U(name)); auto is = shapes.find(nam); if ( is == shapes.end() ) { /// Check if this volume is part of the volumes to be built for this description type xml_attr_t x_build = c.attr_nothrow(_U(build)); if ( x_build ) { - string build = c.attr(x_build); + std::string build = c.attr(x_build); if ( !buildMatch(build,buildType) ) { printout(INFO,"VolumeBuilder", "+++ Shape %s does NOT match build requirements. [Ignored]",nam.c_str()); @@ -183,7 +179,7 @@ size_t VolumeBuilder::buildShapes(xml_h handle) { continue; } } - string type = x.attr(_U(type)); + std::string type = x.attr(_U(type)); Solid solid = xml::createShape(description, type, c); if ( !solid.isValid() ) { except("VolumeBuilder","+++ Failed to create shape %s of type: %s", @@ -192,7 +188,7 @@ size_t VolumeBuilder::buildShapes(xml_h handle) { printout(debug ? ALWAYS : DEBUG,"VolumeBuilder", "+++ Building shape from XML: %s of type: %s", nam.c_str(), solid->IsA()->GetName()); - shapes.emplace(nam,make_pair(c,solid)); + shapes.emplace(nam,std::make_pair(c,solid)); continue; } except("VolumeBuilder","+++ Shape %s is already known to this builder unit. " @@ -202,17 +198,17 @@ size_t VolumeBuilder::buildShapes(xml_h handle) { } /// Build all identifiers in the passed parent xml element -size_t VolumeBuilder::buildVolumes(xml_h handle) { - size_t len = volumes.size(); +std::size_t VolumeBuilder::buildVolumes(xml_h handle) { + std::size_t len = volumes.size(); xml_elt_t x_comp(0); for( xml_coll_t c(handle,_U(volume)); c; ++c ) { - Solid solid; - xml_comp_t x = c; - string nam = x.attr(_U(name)); + Solid solid; + xml_comp_t x = c; + std::string nam = x.attr(_U(name)); xml_attr_t attr = c.attr_nothrow(_U(build)); /// Check if this volume is part of the volumes to be built for this description type if ( attr ) { - string build = c.attr(attr); + std::string build = c.attr(attr); if ( !buildMatch(build,buildType) ) { printout(INFO,"VolumeBuilder", "+++ Volume %s does NOT match build requirements. [Ignored]",nam.c_str()); @@ -222,10 +218,10 @@ size_t VolumeBuilder::buildVolumes(xml_h handle) { bool is_sensitive = c.attr_nothrow(_U(sensitive)); /// Check if the volume is implemented by a factory if ( (attr=c.attr_nothrow(_U(type))) ) { - string typ = c.attr(attr); + std::string typ = c.attr(attr); Volume vol = xml::createVolume(description, typ, c); vol.setAttributes(description,x.regionStr(),x.limitsStr(),x.visStr()); - volumes.emplace(nam,make_pair(c,vol)); + volumes.emplace(nam,std::make_pair(c,vol)); /// Check if the volume is sensitive if ( is_sensitive ) { vol.setSensitiveDetector(sensitive); @@ -241,7 +237,7 @@ size_t VolumeBuilder::buildVolumes(xml_h handle) { /// Check if the volume has a shape attribute --> shape reference if ( (attr=c.attr_nothrow(_U(shape))) ) { - string ref = c.attr(attr); + std::string ref = c.attr(attr); if ( !(solid=getShape(ref)).isValid() ) continue; } /// Else use anonymous shape embedded in volume @@ -251,11 +247,11 @@ size_t VolumeBuilder::buildVolumes(xml_h handle) { /// We have a real volume here with a concrete shape: if ( solid.isValid() ) { - Material mat = description.material(x.attr(_U(material))); + Material mat = description.material(x.attr(_U(material))); Volume vol(nam, solid, mat); placeDaughters(detector, vol, x); vol.setAttributes(description,x.regionStr(),x.limitsStr(),x.visStr()); - volumes.emplace(nam,make_pair(c,vol)); + volumes.emplace(nam,std::make_pair(c,vol)); /// Check if the volume is sensitive if ( is_sensitive ) { vol.setSensitiveDetector(sensitive); @@ -274,7 +270,7 @@ size_t VolumeBuilder::buildVolumes(xml_h handle) { Assembly vol(nam); placeDaughters(detector, vol, x); vol.setAttributes(description,x.regionStr(),x.limitsStr(),x.visStr()); - volumes.emplace(nam,make_pair(c,vol)); + volumes.emplace(nam,std::make_pair(c,vol)); printout(debug ? ALWAYS : DEBUG,"VolumeBuilder", "+++ Building assembly from XML: %-20s shape:%-24s vis:%s", nam.c_str(), vol->GetShape()->IsA()->GetName(), x.visStr().c_str()); @@ -296,7 +292,7 @@ void VolumeBuilder::_placeSingleVolume(DetElement parent, Volume vol, xml_h c) if ( !attr ) { except("VolumeBuilder","+++ The xml volume element has no 'logvol' or 'volume' attribute!"); } - string nam = c.attr(attr); + std::string nam = c.attr(attr); if ( vol_veto.find(nam) != vol_veto.end() ) { return; } @@ -310,12 +306,11 @@ void VolumeBuilder::_placeSingleVolume(DetElement parent, Volume vol, xml_h c) Volume daughter = (*iv).second.second; attr = c.attr_nothrow(_U(transformation)); if ( attr ) { - string tr_nam = c.attr(attr); + std::string tr_nam = c.attr(attr); auto it = transformations.find(tr_nam); if ( it == transformations.end() ) { except("VolumeBuilder", - "+++ Failed to locate name transformation %s " - "[typo somewhere in the XML?]", + "+++ Failed to locate name transformation %s [typo in the XML?]", nam.c_str()); } const Transform3D& tr = (*it).second.second; @@ -327,7 +322,7 @@ void VolumeBuilder::_placeSingleVolume(DetElement parent, Volume vol, xml_h c) } xml_attr_t attr_nam = c.attr_nothrow(_U(name)); if ( attr_nam ) { - string phys_nam = c.attr(attr_nam); + std::string phys_nam = c.attr(attr_nam); pv->SetName(phys_nam.c_str()); } attr = c.attr_nothrow(_U(element)); @@ -338,11 +333,11 @@ void VolumeBuilder::_placeSingleVolume(DetElement parent, Volume vol, xml_h c) } else if ( attr ) { int elt_id = parent.id(); - string elt = c.attr(attr); + std::string elt = c.attr(attr); attr = c.attr_nothrow(_U(id)); if ( attr ) { elt_id = c.attr(attr); - elt += c.attr(attr); + elt += c.attr(attr); } DetElement de(parent, elt, elt_id); de.setPlacement(pv); @@ -364,7 +359,7 @@ void VolumeBuilder::_placeParamVolumes(DetElement parent, Volume vol, xml_h c) if ( !attr ) { except("VolumeBuilder","+++ The xml volume element has no 'logvol' or 'volume' attribute!"); } - string nam = x_phys.attr(attr); + std::string nam = x_phys.attr(attr); if ( vol_veto.find(nam) != vol_veto.end() ) { return; } @@ -384,7 +379,7 @@ void VolumeBuilder::_placeParamVolumes(DetElement parent, Volume vol, xml_h c) attr_tr = c.attr_nothrow(_U(transformation)); Transform3D tr; if ( attr_tr ) { - string tr_nam = c.attr(attr_tr); + std::string tr_nam = c.attr(attr_tr); auto it = transformations.find(tr_nam); if ( it == transformations.end() ) { except("VolumeBuilder", @@ -399,14 +394,14 @@ void VolumeBuilder::_placeParamVolumes(DetElement parent, Volume vol, xml_h c) } Transform3D transformation(Position(0,0,0)); int elt_id = -1; - string elt, phys_nam; + std::string elt, phys_nam; attr_nam = x_phys.attr_nothrow(_U(name)); if ( attr_nam ) { - phys_nam = x_phys.attr(_U(name))+"_%d"; + phys_nam = x_phys.attr(_U(name))+"_%d"; } if ( attr_elt ) { elt_id = parent.id(); - elt = c.attr(attr_elt); + elt = c.attr(attr_elt); } int number = c.attr(_U(number)); printout(debug ? ALWAYS : DEBUG,"VolumeBuilder","+++ Mother:%s place volume %s %d times.", @@ -414,7 +409,7 @@ void VolumeBuilder::_placeParamVolumes(DetElement parent, Volume vol, xml_h c) for(int i=0; iSetName(_toString(i,phys_nam.c_str()).c_str()); + //pv->SetName(_toStd::String(i,phys_nam.c_str()).c_str()); } if ( attr_elt ) { DetElement de(parent,elt,elt_id); @@ -429,15 +424,15 @@ void VolumeBuilder::_placeParamVolumes(DetElement parent, Volume vol, xml_h c) } /// Load include tags contained in the passed XML handle -size_t VolumeBuilder::load(xml_h element, const string& tag) { - size_t count = 0; +std::size_t VolumeBuilder::load(xml_h element, const std::string& tag) { + std::size_t count = 0; for( xml_coll_t c(element,Unicode(tag)); c; ++c ) { - string ref = c.attr(_U(ref)); - unique_ptr doc(new xml::DocumentHolder(xml::DocumentHandler().load(element, c.attr_value(_U(ref))))); + std::string ref = c.attr(_U(ref)); + std::unique_ptr doc(new xml::DocumentHolder(xml::DocumentHandler().load(element, c.attr_value(_U(ref))))); xml_h vols = doc->root(); printout(debug ? ALWAYS : DEBUG, "VolumeBuilder", "++ Processing xml document %s.", doc->uri().c_str()); - included_docs[ref] = unique_ptr(doc.release()); + included_docs[ref] = std::unique_ptr(doc.release()); buildShapes(vols); buildVolumes(vols); ++count; @@ -461,22 +456,22 @@ VolumeBuilder& VolumeBuilder::placeDaughters(DetElement parent, Volume vol, xml_ } /// Build all identifiers in the passed parent xml element -size_t VolumeBuilder::buildTransformations(Handle_t handle) { - size_t len = transformations.size(); +std::size_t VolumeBuilder::buildTransformations(Handle_t handle) { + std::size_t len = transformations.size(); for( xml_coll_t c(handle,_U(transformation)); c; ++c ) { - string nam = xml_comp_t(c).nameStr(); - transformations.emplace(nam,make_pair(c,xml::createTransformation(c))); + std::string nam = xml_comp_t(c).nameStr(); + transformations.emplace(nam,std::make_pair(c,xml::createTransformation(c))); } return transformations.size() - len; } /// Place the detector object into the mother volume returned by the Detector instance -PlacedVolume VolumeBuilder::placeDetector(Volume vol) { +dd4hep::PlacedVolume VolumeBuilder::placeDetector(Volume vol) { return placeDetector(vol, x_det); } /// Place the detector object into the mother volume returned by the Detector instance -PlacedVolume VolumeBuilder::placeDetector(Volume vol, xml_h handle) { +dd4hep::PlacedVolume VolumeBuilder::placeDetector(Volume vol, xml_h handle) { xml_comp_t x = handle; xml_dim_t x_pos = x_det.child(_U(position),false); xml_dim_t x_rot = x_det.child(_U(rotation),false); diff --git a/DDCore/src/XML/XMLElements.cpp b/DDCore/src/XML/XMLElements.cpp index c392552ab..9d0ec3f8d 100644 --- a/DDCore/src/XML/XMLElements.cpp +++ b/DDCore/src/XML/XMLElements.cpp @@ -34,25 +34,24 @@ #include #include -using namespace std; using namespace dd4hep::xml; static const size_t INVALID_NODE = ~0U; static int s_float_precision = -1; // Forward declarations namespace dd4hep { - std::pair _toInteger(const string& value); - std::pair _toFloatingPoint(const string& value); - void _toDictionary(const string& name, const string& value, const string& typ); - string _getEnviron(const string& env); + std::pair _toInteger(const std::string& value); + std::pair _toFloatingPoint(const std::string& value); + void _toDictionary(const std::string& name, const std::string& value, const std::string& typ); + std::string _getEnviron(const std::string& env); } // Static storage namespace { bool s_resolve_environment = true; - string _checkEnviron(const string& env) { + std::string _checkEnviron(const std::string& env) { if ( s_resolve_environment ) { - string r = dd4hep::_getEnviron(env); + std::string r = dd4hep::_getEnviron(env); return r.empty() ? env : r; } return env; @@ -163,12 +162,12 @@ namespace { size_t node_count(XmlElement* e, const Tag_t& t) { size_t cnt = 0; if ( e ) { - const string& tag = t; + const std::string& tag = t; xercesc::DOMElement *ee = Xml(e).e; if ( ee ) { for(xercesc::DOMElement* elt=ee->getFirstElementChild(); elt; elt=elt->getNextElementSibling()) { if ( elt->getParentNode() == ee ) { - string child_tag = _toString(elt->getTagName()); + std::string child_tag = _toString(elt->getTagName()); if ( tag == "*" || child_tag == tag ) ++cnt; } } @@ -178,13 +177,13 @@ namespace { } XmlElement* node_first(XmlElement* e, const Tag_t& t) { if ( e ) { - const string& tag = t; + const std::string& tag = t; xercesc::DOMElement* ee = Xml(e).e; if ( ee ) { for(xercesc::DOMElement* elt=ee->getFirstElementChild(); elt; elt=elt->getNextElementSibling()) { if ( elt->getParentNode() == ee ) { if ( tag == "*" ) return _XE(elt); - string child_tag = _toString(elt->getTagName()); + std::string child_tag = _toString(elt->getTagName()); if ( child_tag == tag ) return _XE(elt); } } @@ -195,9 +194,9 @@ namespace { } /// Convert XML char to std::string -string dd4hep::xml::_toString(const XmlChar *toTranscode) { +std::string dd4hep::xml::_toString(const XmlChar *toTranscode) { char *buff = XmlString::transcode(toTranscode); - string tmp(buff == 0 ? "" : buff); + std::string tmp(buff == 0 ? "" : buff); XmlString::release(&buff); if ( tmp.length()<3 ) return tmp; if ( !(tmp[0] == '$' && tmp[1] == '{') ) return tmp; @@ -232,54 +231,54 @@ int dd4hep::xml::get_float_precision() { } /// Convert attribute value to string -string dd4hep::xml::_toString(Attribute attr) { +std::string dd4hep::xml::_toString(Attribute attr) { if (attr) return _toString(attribute_value(attr)); return ""; } -template static inline string __to_string(T value, const char* fmt) { +template static inline std::string __to_string(T value, const char* fmt) { char text[128]; ::snprintf(text, sizeof(text), fmt, value); return text; } /// Do-nothing version. Present for completeness and argument interchangeability -string dd4hep::xml::_toString(const char* s) { +std::string dd4hep::xml::_toString(const char* s) { if ( !s || *s == 0 ) return ""; else if ( !(*s == '$' && *(s+1) == '{') ) return s; return _checkEnviron(s); } /// Do-nothing version. Present for completeness and argument interchangeability -string dd4hep::xml::_toString(const string& s) { +std::string dd4hep::xml::_toString(const std::string& s) { if ( s.length() < 3 || s[0] != '$' ) return s; else if ( !(s[0] == '$' && s[1] == '{') ) return s; return _checkEnviron(s); } /// Format unsigned long integer to string with arbitrary format -string dd4hep::xml::_toString(unsigned long v, const char* fmt) { +std::string dd4hep::xml::_toString(unsigned long v, const char* fmt) { return __to_string(v, fmt); } /// Format unsigned integer (32 bits) to string with arbitrary format -string dd4hep::xml::_toString(unsigned int v, const char* fmt) { +std::string dd4hep::xml::_toString(unsigned int v, const char* fmt) { return __to_string(v, fmt); } /// Format signed integer (32 bits) to string with arbitrary format -string dd4hep::xml::_toString(int v, const char* fmt) { +std::string dd4hep::xml::_toString(int v, const char* fmt) { return __to_string(v, fmt); } /// Format signed long integer to string with arbitrary format -string dd4hep::xml::_toString(long v, const char* fmt) { +std::string dd4hep::xml::_toString(long v, const char* fmt) { return __to_string(v, fmt); } /// Format single procision float number (32 bits) to string with arbitrary format -string dd4hep::xml::_toString(float v, const char* fmt) { +std::string dd4hep::xml::_toString(float v, const char* fmt) { if ( s_float_precision >= 0 ) { char format[32]; ::snprintf(format, sizeof(format), "%%.%de", s_float_precision); @@ -289,7 +288,7 @@ string dd4hep::xml::_toString(float v, const char* fmt) { } /// Format double procision float number (64 bits) to string with arbitrary format -string dd4hep::xml::_toString(double v, const char* fmt) { +std::string dd4hep::xml::_toString(double v, const char* fmt) { if ( s_float_precision >= 0 ) { char format[32]; ::snprintf(format, sizeof(format), "%%.%de", s_float_precision); @@ -299,23 +298,23 @@ string dd4hep::xml::_toString(double v, const char* fmt) { } /// Convert Strng_t to std::string -string dd4hep::xml::_toString(const Strng_t& s) { +std::string dd4hep::xml::_toString(const Strng_t& s) { return _toString(Tag_t(s)); } /// Convert Tag_t to std::string -string dd4hep::xml::_toString(const Tag_t& s) { +std::string dd4hep::xml::_toString(const Tag_t& s) { return s.str(); } /// Format pointer to string with arbitrary format -string dd4hep::xml::_ptrToString(const void* v, const char* fmt) { +std::string dd4hep::xml::_ptrToString(const void* v, const char* fmt) { return __to_string(v, fmt); } long dd4hep::xml::_toLong(const XmlChar* value) { if (value) { - string s = _toString(value); + std::string s = _toString(value); return dd4hep::_toInteger(s).second; } return -1; @@ -324,8 +323,8 @@ long dd4hep::xml::_toLong(const XmlChar* value) { unsigned long dd4hep::xml::_toULong(const XmlChar* value) { long val = _toLong(value); if ( val >= 0 ) return (unsigned long) val; - string s = _toString(value); - throw runtime_error("dd4hep: Severe error during expression evaluation of " + s); + std::string s = _toString(value); + throw std::runtime_error("dd4hep: Severe error during expression evaluation of " + s); } int dd4hep::xml::_toInt(const XmlChar* value) { @@ -338,7 +337,7 @@ unsigned int dd4hep::xml::_toUInt(const XmlChar* value) { bool dd4hep::xml::_toBool(const XmlChar* value) { if (value) { - string s = _toString(value); + std::string s = _toString(value); char c = ::toupper(s[0]); if ( c == 'T' || c == '1' ) return true; if ( c == 'F' || c == '0' ) return false; @@ -349,7 +348,7 @@ bool dd4hep::xml::_toBool(const XmlChar* value) { float dd4hep::xml::_toFloat(const XmlChar* value) { if (value) { - string s = _toString(value); + std::string s = _toString(value); return (float) dd4hep::_toFloatingPoint(s).second; } return 0.0; @@ -357,14 +356,14 @@ float dd4hep::xml::_toFloat(const XmlChar* value) { double dd4hep::xml::_toDouble(const XmlChar* value) { if (value) { - string s = _toString(value); + std::string s = _toString(value); return dd4hep::_toFloatingPoint(s).second; } return 0.0; } void dd4hep::xml::_toDictionary(const XmlChar* name, const XmlChar* value) { - string n = _toString(name).c_str(), v = _toString(value); + std::string n = _toString(name).c_str(), v = _toString(value); dd4hep::_toDictionary(n, v, "number"); } @@ -390,7 +389,7 @@ template void dd4hep::xml::_toDictionary(const XmlChar* name, const char* value) #endif template void dd4hep::xml::_toDictionary(const XmlChar* name, const Tag_t& value); template void dd4hep::xml::_toDictionary(const XmlChar* name, const Strng_t& value); -template void dd4hep::xml::_toDictionary(const XmlChar* name, const string& value); +template void dd4hep::xml::_toDictionary(const XmlChar* name, const std::string& value); template void dd4hep::xml::_toDictionary(const XmlChar* name, unsigned long value); template void dd4hep::xml::_toDictionary(const XmlChar* name, unsigned int value); template void dd4hep::xml::_toDictionary(const XmlChar* name, unsigned short value); @@ -401,7 +400,7 @@ template void dd4hep::xml::_toDictionary(const XmlChar* name, float value); template void dd4hep::xml::_toDictionary(const XmlChar* name, double value); /// Evaluate string constant using environment stored in the evaluator -string dd4hep::xml::getEnviron(const string& env) { +std::string dd4hep::xml::getEnviron(const std::string& env) { return dd4hep::_getEnviron(env); } @@ -413,17 +412,17 @@ bool dd4hep::xml::enableEnvironResolution(bool new_value) { } template -static inline string i_add(const string& a, B b) { - string r = a; +static inline std::string i_add(const std::string& a, B b) { + std::string r = a; r += b; return r; } -Strng_t dd4hep::xml::operator+(const Strng_t& a, const string& b) { +Strng_t dd4hep::xml::operator+(const Strng_t& a, const std::string& b) { return _toString(a.ptr()) + b; } -Strng_t dd4hep::xml::operator+(const string& a, const Strng_t& b) { +Strng_t dd4hep::xml::operator+(const std::string& a, const Strng_t& b) { return a + _toString(b.ptr()); } @@ -432,7 +431,7 @@ Strng_t dd4hep::xml::operator+(const Strng_t& a, const char* b) { } Strng_t dd4hep::xml::operator+(const char* a, const Strng_t& b) { - return string(a) + _toString(b.ptr()); + return std::string(a) + _toString(b.ptr()); } Strng_t dd4hep::xml::operator+(const Strng_t& a, const Strng_t& b) { @@ -440,48 +439,48 @@ Strng_t dd4hep::xml::operator+(const Strng_t& a, const Strng_t& b) { } Tag_t dd4hep::xml::operator+(const Tag_t& a, const char* b) { - string res = a.str() + b; + std::string res = a.str() + b; return Tag_t(res); } Tag_t dd4hep::xml::operator+(const char* a, const Tag_t& b) { - string res = a + b.str(); + std::string res = a + b.str(); return Tag_t(res); } Tag_t dd4hep::xml::operator+(const Tag_t& a, const Strng_t& b) { - string res = a.str() + _toString(b); + std::string res = a.str() + _toString(b); return Tag_t(res); } -Tag_t dd4hep::xml::operator+(const Tag_t& a, const string& b) { - string res = a.str() + b; +Tag_t dd4hep::xml::operator+(const Tag_t& a, const std::string& b) { + std::string res = a.str() + b; return Tag_t(res); } #ifndef DD4HEP_USE_TINYXML Strng_t dd4hep::xml::operator+(const Strng_t& a, const XmlChar* b) { - string res = _toString(a.ptr()) + _toString(b); + std::string res = _toString(a.ptr()) + _toString(b); return Tag_t(res); } Strng_t dd4hep::xml::operator+(const XmlChar* a, const Strng_t& b) { - string res = _toString(a) + _toString(b.ptr()); + std::string res = _toString(a) + _toString(b.ptr()); return Tag_t(res); } -Strng_t dd4hep::xml::operator+(const XmlChar* a, const string& b) { - string res = _toString(a) + b; +Strng_t dd4hep::xml::operator+(const XmlChar* a, const std::string& b) { + std::string res = _toString(a) + b; return Tag_t(res); } -Strng_t dd4hep::xml::operator+(const string& a, const XmlChar* b) { - string res = a + _toString(b); +Strng_t dd4hep::xml::operator+(const std::string& a, const XmlChar* b) { + std::string res = a + _toString(b); return Tag_t(res); } Tag_t dd4hep::xml::operator+(const Tag_t& a, const XmlChar* b) { - string res = a.str() + _toString(b); + std::string res = a.str() + _toString(b); return Tag_t(res); } @@ -509,7 +508,7 @@ Strng_t& Strng_t::operator=(const Strng_t& s) { return *this; } -Strng_t& Strng_t::operator=(const string& s) { +Strng_t& Strng_t::operator=(const std::string& s) { if (m_xml) XmlString::release (&m_xml); m_xml = XmlString::transcode(s.c_str()); @@ -553,7 +552,7 @@ Tag_t& Tag_t::operator=(const Strng_t& s) { return *this; } -Tag_t& Tag_t::operator=(const string& s) { +Tag_t& Tag_t::operator=(const std::string& s) { if (m_xml) XmlString::release (&m_xml); m_xml = XmlString::transcode(s.c_str()); @@ -594,7 +593,7 @@ XmlElement* NodeList::next() const { xercesc::DOMElement *elt = Xml(m_ptr).e; for(elt=elt->getNextElementSibling(); elt; elt=elt->getNextElementSibling()) { if ( m_tag.str() == "*" ) return m_ptr=Xml(elt).xe; - string child_tag = _toString(elt->getTagName()); + std::string child_tag = _toString(elt->getTagName()); if ( child_tag == m_tag ) return m_ptr=Xml(elt).xe; } return m_ptr=0; @@ -611,7 +610,7 @@ XmlElement* NodeList::previous() const { xercesc::DOMElement *elt = Xml(m_ptr).e; for(elt=elt->getPreviousElementSibling(); elt; elt=elt->getPreviousElementSibling()) { if ( m_tag.str()=="*" ) return m_ptr=Xml(elt).xe; - string child_tag = _toString(elt->getTagName()); + std::string child_tag = _toString(elt->getTagName()); if ( child_tag == m_tag ) return m_ptr=Xml(elt).xe; } return m_ptr=0; @@ -652,12 +651,12 @@ Handle_t Handle_t::clone(XmlDocument* new_doc) const { XmlElement* e = _XE(_N(m_node)->Clone()->ToElement()); if ( e ) return e; } - throw runtime_error("TiXml: Handle_t::clone: Invalid source handle type [No element type]."); + throw std::runtime_error("TiXml: Handle_t::clone: Invalid source handle type [No element type]."); #else return Elt_t(_D(new_doc)->importNode(_E(m_node), true)); #endif } - throw runtime_error("Xml: Handle_t::clone: Invalid source handle."); + throw std::runtime_error("Xml: Handle_t::clone: Invalid source handle."); } /// Access the element's parent element @@ -676,8 +675,8 @@ bool Handle_t::hasAttr(const XmlChar* tag_value) const { } /// Retrieve a collection of all attributes of this DOM element -vector Handle_t::attributes() const { - vector < Attribute > attrs; +std::vector Handle_t::attributes() const { + std::vector < Attribute > attrs; if (m_node) { #ifdef DD4HEP_USE_TINYXML for(TiXmlAttribute* a=_E(m_node)->FirstAttribute(); a; a=a->Next()) @@ -699,12 +698,12 @@ size_t Handle_t::numChildren(const XmlChar* t, bool throw_exception) const { return 0; else if (n != INVALID_NODE) return n; - string msg = "Handle_t::numChildren: "; + std::string msg = "Handle_t::numChildren: "; if (m_node) msg += "Element [" + tag() + "] has no children of type '" + _toString(t) + "'"; else msg += "Element [INVALID] has no children of type '" + _toString(t) + "'"; - throw runtime_error(msg); + throw std::runtime_error(msg); } /// Remove a single child node identified by its handle from the tree of the element @@ -712,12 +711,12 @@ Handle_t Handle_t::child(const XmlChar* t, bool throw_exception) const { Elt_t e = node_first(m_node, t); if (e || !throw_exception) return e; - string msg = "Handle_t::child: "; + std::string msg = "Handle_t::child: "; if (m_node) msg += "Element [" + tag() + "] has no child of type '" + _toString(t) + "'"; else msg += "Element [INVALID]. Cannot remove child of type: '" + _toString(t) + "'"; - throw runtime_error(msg); + throw std::runtime_error(msg); } NodeList Handle_t::children(const XmlChar* tag_value) const { @@ -738,7 +737,7 @@ Handle_t Handle_t::remove(Handle_t node) const { #endif if (e) return node.ptr(); - string msg = "Handle_t::remove: "; + std::string msg = "Handle_t::remove: "; if (m_node && node.ptr()) msg += "Element [" + tag() + "] has no child of type '" + node.tag() + "'"; else if (node) @@ -746,7 +745,7 @@ Handle_t Handle_t::remove(Handle_t node) const { else if (!node) msg += "Element [INVALID]. Cannot remove [INVALID] child. Big Shit!!!!"; - throw runtime_error(msg); + throw std::runtime_error(msg); } /// Remove children with a given tag name from the DOM node @@ -772,7 +771,7 @@ void Handle_t::setValue(const XmlChar* text_value) const { } /// Set the element's value -void Handle_t::setValue(const string& text_value) const { +void Handle_t::setValue(const std::string& text_value) const { #ifdef DD4HEP_USE_TINYXML _N(m_node)->setNodeValue(text_value.c_str()); #else @@ -790,7 +789,7 @@ void Handle_t::setText(const XmlChar* text_value) const { } /// Set the element's text -void Handle_t::setText(const string& text_value) const { +void Handle_t::setText(const std::string& text_value) const { #ifdef DD4HEP_USE_TINYXML _N(m_node)->LinkEndChild(new TiXmlText(text_value.c_str())); #else @@ -840,12 +839,12 @@ Attribute Handle_t::attr_ptr(const XmlChar* t) const { Attribute a = attribute_node(m_node, t); if (0 != a) return a; - string msg = "Handle_t::attr_ptr: "; + std::string msg = "Handle_t::attr_ptr: "; if (m_node) msg += "Element [" + tag() + "] has no attribute of type '" + _toString(t) + "'"; else msg += "Element [INVALID] has no attribute of type '" + _toString(t) + "'"; - throw runtime_error(msg); + throw std::runtime_error(msg); } /// Access attribute name (throws exception if not present) @@ -853,7 +852,7 @@ const XmlChar* Handle_t::attr_name(const Attribute a) const { if (a) { return Xml(a).a->getName(); } - throw runtime_error("Attempt to access invalid XML attribute object!"); + throw std::runtime_error("Attempt to access invalid XML attribute object!"); } /// Access attribute value by the attribute's unicode name (throws exception if not present) @@ -901,7 +900,7 @@ Attribute Handle_t::setAttr(const XmlChar* name, double val) const { } /// Generic attribute setter with string value -Attribute Handle_t::setAttr(const XmlChar* name, const string& val) const { +Attribute Handle_t::setAttr(const XmlChar* name, const std::string& val) const { return setAttr(name, Strng_t(val.c_str())); } @@ -944,7 +943,7 @@ Handle_t Handle_t::setRef(const XmlChar* tag_value, const XmlChar* ref_name) { } /// Add reference child as a new child node. The obj must have the "name" attribute! -Handle_t Handle_t::setRef(const XmlChar* tag_value, const string& ref_name) { +Handle_t Handle_t::setRef(const XmlChar* tag_value, const std::string& ref_name) { return setRef(tag_value, Strng_t(ref_name).ptr()); } @@ -990,13 +989,13 @@ static unsigned int adler32(unsigned int adler, const XmlChar* xml_buff, size_t typedef unsigned int (fcn_t)(unsigned int, const XmlChar*, size_t); unsigned int Handle_t::checksum(unsigned int param, fcn_t fcn) const { #ifdef DD4HEP_USE_TINYXML - typedef map StringMap; + typedef map StringMap; TiXmlNode* n = Xml(m_node).n; if ( n ) { if ( 0 == fcn ) fcn = adler32; switch (n->Type()) { case TiXmlNode::ELEMENT: { - map m; + map m; TiXmlElement* e = n->ToElement(); TiXmlAttribute* p=e->FirstAttribute(); for(; p; p=p->Next()) m.emplace(p->Name(),p->Value()); @@ -1041,7 +1040,7 @@ Handle_t Document::createElt(const XmlChar* tag_value) const { Handle_t Document::root() const { if (m_doc) return _XE(_D(m_doc)->getDocumentElement()); - throw runtime_error("Document::root: Invalid handle!"); + throw std::runtime_error("Document::root: Invalid handle!"); } /// Acces the document URI @@ -1050,7 +1049,7 @@ std::string Document::uri() const { Tag_t val(_D(m_doc)->getDocumentURI()); return val; } - throw runtime_error("Document::uri: Invalid handle!"); + throw std::runtime_error("Document::uri: Invalid handle!"); } /// Assign new document. Old document is dropped. @@ -1096,7 +1095,7 @@ Handle_t Element::clone(Handle_t h) const { if (m_element && h) { return h.clone(Document::DOC(document())); } - throw runtime_error("Element::clone: Invalid element pointer -- unable to clone node!"); + throw std::runtime_error("Element::clone: Invalid element pointer -- unable to clone node!"); } Attribute Element::getAttr(const XmlChar* name) const { @@ -1109,7 +1108,7 @@ Attribute Element::setRef(const XmlChar* tag_value, const XmlChar* ref_name) con } /// Set the reference attribute to the node (adds attribute ref="ref-name") -Attribute Element::setRef(const XmlChar* tag_value, const string& ref_name) const { +Attribute Element::setRef(const XmlChar* tag_value, const std::string& ref_name) const { return setRef(tag_value, Strng_t(ref_name).ptr()); } @@ -1148,7 +1147,7 @@ void Element::addComment(const char* text_value) const { } /// Add comment node to the element -void Element::addComment(const string& text_value) const { +void Element::addComment(const std::string& text_value) const { addComment(text_value.c_str()); } @@ -1177,13 +1176,13 @@ RefElement& RefElement::operator=(const RefElement& e) { const XmlChar* RefElement::name() const { if (0 == m_name) - cout << "Error:tag=" << m_element.tag() << endl; + std::cout << "Error:tag=" << m_element.tag() << std::endl; return attribute_value(m_name); } const XmlChar* RefElement::refName() const { if (0 == m_name) - cout << "Error:tag=" << m_element.tag() << endl; + std::cout << "Error:tag=" << m_element.tag() << std::endl; return attribute_value(m_name); } @@ -1221,11 +1220,11 @@ size_t Collection_t::size() const { } /// Helper function to throw an exception -void Collection_t::throw_loop_exception(const exception& e) const { +void Collection_t::throw_loop_exception(const std::exception& e) const { if (m_node) { - throw runtime_error(string(e.what()) + "\n" + "dd4hep: Error interpreting XML nodes of type <" + tag() + "/>"); + throw std::runtime_error(std::string(e.what()) + "\n" + "dd4hep: Error interpreting XML nodes of type <" + tag() + "/>"); } - throw runtime_error(string(e.what()) + "\n" + "dd4hep: Error interpreting collections XML nodes."); + throw std::runtime_error(std::string(e.what()) + "\n" + "dd4hep: Error interpreting collections XML nodes."); } void Collection_t::operator++() const { diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp index 8290733a0..90376b959 100644 --- a/DDCore/src/plugins/Compact2Objects.cpp +++ b/DDCore/src/plugins/Compact2Objects.cpp @@ -52,7 +52,6 @@ #include #include -using namespace std; using namespace dd4hep; /// Namespace for the AIDA detector description toolkit @@ -105,9 +104,9 @@ namespace dd4hep { namespace { static UInt_t unique_mat_id = 0xAFFEFEED; - void throw_print(const string& msg) { + void throw_print(const std::string& msg) { printout(ERROR, "Compact", msg.c_str()); - throw runtime_error(msg); + throw std::runtime_error(msg); } class DebugOptions { public: @@ -130,7 +129,7 @@ namespace { static Ref_t create_ConstantField(Detector& /* description */, xml_h e) { CartesianField obj; xml_comp_t field(e), strength(e.child(_U(strength))); - string t = e.attr(_U(field)); + std::string t = e.attr(_U(field)); ConstantField* ptr = new ConstantField(); ptr->field_type = ::toupper(t[0]) == 'E' ? CartesianField::ELECTRIC : CartesianField::MAGNETIC; ptr->direction.SetX(strength.x()); @@ -194,17 +193,17 @@ DECLARE_XMLELEMENT(solenoid,create_SolenoidField) static Ref_t create_DipoleField(Detector& /* description */, xml_h e) { xml_comp_t c(e); CartesianField obj; - DipoleField* ptr = new DipoleField(); - double lunit = c.hasAttr(_U(lunit)) ? c.attr(_U(lunit)) : 1.0; - double funit = c.hasAttr(_U(funit)) ? c.attr(_U(funit)) : 1.0; - double val, mult = funit; + DipoleField* ptr = new DipoleField(); + double lunit = c.hasAttr(_U(lunit)) ? c.attr(_U(lunit)) : 1.0; + double funit = c.hasAttr(_U(funit)) ? c.attr(_U(funit)) : 1.0; + double val, mult = funit; if (c.hasAttr(_U(zmin))) - ptr->zmin = _multiply(c.attr(_U(zmin)), lunit); + ptr->zmin = _multiply(c.attr(_U(zmin)), lunit); if (c.hasAttr(_U(zmax))) - ptr->zmax = _multiply(c.attr(_U(zmax)), lunit); + ptr->zmax = _multiply(c.attr(_U(zmax)), lunit); if (c.hasAttr(_U(rmax))) - ptr->rmax = _multiply(c.attr(_U(rmax)), lunit); + ptr->rmax = _multiply(c.attr(_U(rmax)), lunit); for (xml_coll_t coll(c, _U(dipole_coeff)); coll; ++coll, mult /= lunit) { xml_dim_t coeff = coll; if ( coeff.hasAttr(_U(value)) ) @@ -223,13 +222,13 @@ DECLARE_XMLELEMENT(DipoleMagnet,create_DipoleField) static Ref_t create_MultipoleField(Detector& description, xml_h e) { xml_dim_t c(e), child; - CartesianField obj; + CartesianField obj; MultipoleField* ptr = new MultipoleField(); - double lunit = c.hasAttr(_U(lunit)) ? c.attr(_U(lunit)) : 1.0; - double funit = c.hasAttr(_U(funit)) ? c.attr(_U(funit)) : 1.0; - double val, mult = funit, bz = 0.0; - RotationZYX rot; - Position pos; + double lunit = c.hasAttr(_U(lunit)) ? c.attr(_U(lunit)) : 1.0; + double funit = c.hasAttr(_U(funit)) ? c.attr(_U(funit)) : 1.0; + double val, mult = funit, bz = 0.0; + RotationZYX rot; + Position pos; if (c.hasAttr(_U(Z))) bz = c.Z() * funit; if ((child = c.child(_U(position), false))) { // Position is not mandatory! @@ -239,7 +238,7 @@ static Ref_t create_MultipoleField(Detector& description, xml_h e) { rot.SetComponents(child.z(), child.y(), child.x()); } if ((child = c.child(_U(shape), false))) { // Shape is not mandatory - string type = child.typeStr(); + std::string type = child.typeStr(); ptr->volume = xml::createShape(description, type, child); } ptr->B_z = bz; @@ -296,7 +295,7 @@ bool check_process_file(Detector& description, std::string filename) { template <> void Converter::operator()(xml_h e) const { for (xml_coll_t coll(e, _U(type)); coll; ++coll) { int val = coll.attr(_U(value)); - string nam = coll.attr(_U(name)); + std::string nam = coll.attr(_U(name)); if ( nam.substr(0,6) == "isotop" ) s_debug.isotopes = (0 != val); else if ( nam.substr(0,6) == "elemen" ) s_debug.elements = (0 != val); else if ( nam.substr(0,6) == "materi" ) s_debug.materials = (0 != val); @@ -320,25 +319,25 @@ template <> void Converter::operator()(xml_h e) const { * */ template <> void Converter::operator()(xml_h e) const { - xml_comp_t plugin(e); - string name = plugin.nameStr(); - string type = "default"; + xml_comp_t plugin(e); + std::string name = plugin.nameStr(); + std::string type = "default"; if ( xml_attr_t typ_attr = e.attr_nothrow(_U(type)) ) { - type = e.attr(typ_attr); + type = e.attr(typ_attr); } if ( type == "default" ) { - vector argv; - vector arguments; + std::vector argv; + std::vector arguments; for (xml_coll_t coll(e, _U(arg)); coll; ++coll) { - string val = coll.attr(_U(value)); + std::string val = coll.attr(_U(value)); arguments.emplace_back(val); } for (xml_coll_t coll(e, _U(argument)); coll; ++coll) { - string val = coll.attr(_U(value)); + std::string val = coll.attr(_U(value)); arguments.emplace_back(val); } - for(vector::iterator i=arguments.begin(); i!=arguments.end(); ++i) + for(std::vector::iterator i=arguments.begin(); i!=arguments.end(); ++i) argv.emplace_back(&((*i)[0])); description.apply(name.c_str(),int(argv.size()), &argv[0]); return; @@ -366,9 +365,9 @@ template <> void Converter::operator()(xml_h e) const { template <> void Converter::operator()(xml_h e) const { if ( e.tag() != "include" ) { xml_ref_t constant(e); - string nam = constant.attr(_U(name)); - string val = constant.attr(_U(value)); - string typ = constant.hasAttr(_U(type)) ? constant.attr(_U(type)) : "number"; + std::string nam = constant.attr(_U(name)); + std::string val = constant.attr(_U(value)); + std::string typ = constant.hasAttr(_U(type)) ? constant.attr(_U(type)) : "number"; Constant c(nam, val, typ); _toDictionary(nam, val, typ); description.addConstant(c); @@ -393,11 +392,11 @@ template <> void Converter::operator()(xml_h e) const { */ template <> void Converter
::operator()(xml_h e) const { xml_comp_t c(e); - Header h(e.attr(_U(name)), e.attr(_U(title), "Undefined")); - h.setUrl(e.attr(_U(url), "Undefined")); - h.setAuthor(e.attr(_U(author), "Undefined")); - h.setStatus(e.attr(_U(status), "development")); - h.setVersion(e.attr(_U(version), "Undefined")); + Header h(e.attr(_U(name)), e.attr(_U(title), "Undefined")); + h.setUrl(e.attr(_U(url), "Undefined")); + h.setAuthor(e.attr(_U(author), "Undefined")); + h.setStatus(e.attr(_U(status), "development")); + h.setVersion(e.attr(_U(version), "Undefined")); h.setComment(e.hasChild(_U(comment)) ? e.child(_U(comment)).text() : "No Comment"); description.setHeader(h); } @@ -438,7 +437,7 @@ template <> void Converter::operator()(xml_h e) const { if ( !density.ptr() ) { throw_print("Compact2Objects[ERROR]: material without density tag ( ) provided: " - + string( matname ) ) ; + + std::string( matname ) ) ; } if ( density.hasAttr(_U(unit)) ) { dens_unit = density.attr(_U(unit))/xml::_toDouble(_Unicode(gram/cm3)); @@ -446,15 +445,15 @@ template <> void Converter::operator()(xml_h e) const { if ( dens_unit != 1.0 ) { dens_val *= dens_unit; printout(s_debug.materials ? ALWAYS : DEBUG, "Compact","Density unit: %.3f [%s] raw: %.3f normalized: %.3f ", - dens_unit, density.attr(_U(unit)).c_str(), dens_val, (dens_val*dens_unit)); + dens_unit, density.attr(_U(unit)).c_str(), dens_val, (dens_val*dens_unit)); } mat = mix = new TGeoMixture(matname, composites.size(), dens_val); - size_t ifrac = 0; - vector composite_fractions; - double composite_fractions_total = 0.0; + std::size_t ifrac = 0; + std::vector composite_fractions; + double composite_fractions_total = 0.0; for (composites.reset(); composites; ++composites) { - string nam = composites.attr(_U(ref)); - double fraction = composites.attr(_U(n)); + std::string nam = composites.attr(_U(ref)); + double fraction = composites.attr(_U(n)); if (0 != (comp_mat = mgr.GetMaterial(nam.c_str()))) fraction *= comp_mat->GetA(); else if (0 != (comp_elt = table->FindElement(nam.c_str()))) @@ -465,16 +464,16 @@ template <> void Converter::operator()(xml_h e) const { composite_fractions.emplace_back(fraction); } for (composites.reset(), ifrac=0; composites; ++composites, ++ifrac) { - string nam = composites.attr(_U(ref)); - double fraction = composite_fractions[ifrac]/composite_fractions_total; + std::string nam = composites.attr(_U(ref)); + double fraction = composite_fractions[ifrac]/composite_fractions_total; if (0 != (comp_mat = mgr.GetMaterial(nam.c_str()))) mix->AddElement(comp_mat, fraction); else if (0 != (comp_elt = table->FindElement(nam.c_str()))) mix->AddElement(comp_elt, fraction); } for (fractions.reset(); fractions; ++fractions) { - string nam = fractions.attr(_U(ref)); - double fraction = fractions.attr(_U(n)); + std::string nam = fractions.attr(_U(ref)); + double fraction = fractions.attr(_U(n)); if (0 != (comp_mat = mgr.GetMaterial(nam.c_str()))) mix->AddElement(comp_mat, fraction); else if (0 != (comp_elt = table->FindElement(nam.c_str()))) @@ -490,7 +489,7 @@ template <> void Converter::operator()(xml_h e) const { temp_unit = temperature.attr(_U(unit)); temp_val = temperature.attr(_U(value)) * temp_unit; } - xml_h pressure = x_mat.child(_U(P), false); + xml_h pressure = x_mat.child(_U(P), false); double pressure_val = description.stdConditions().pressure; if ( pressure.ptr() ) { double pressure_unit = _toDouble("pascal"); @@ -516,11 +515,11 @@ template <> void Converter::operator()(xml_h e) const { for(xml_coll_t properties(x_mat, _U(constant)); properties; ++properties) { xml_elt_t p = properties; if ( p.hasAttr(_U(ref)) ) { - bool err = kFALSE; - string ref = p.attr(_U(ref)); + bool err = kFALSE; + std::string ref = p.attr(_U(ref)); mgr.GetProperty(ref.c_str(), &err); /// Check existence if ( err == kFALSE ) { - string prop_nam = p.attr(_U(name)); + std::string prop_nam = p.attr(_U(name)); mat->AddConstProperty(prop_nam.c_str(), ref.c_str()); printout(s_debug.materials ? ALWAYS : DEBUG, "Compact", "++ material %-16s add constant property: %s -> %s.", @@ -531,8 +530,8 @@ template <> void Converter::operator()(xml_h e) const { throw_print("Compact2Objects[ERROR]: Converting material:" + mname + " ConstProperty missing in TGeoManager: " + ref); } else if ( p.hasAttr(_U(value)) ) { - stringstream str; - string ref, prop_nam = p.attr(_U(name)); + std::stringstream str; + std::string ref, prop_nam = p.attr(_U(name)); str << prop_nam << "_" << (void*)mat; ref = str.str(); mgr.AddProperty(ref.c_str(), p.attr(_U(value))); /// Check existence @@ -542,8 +541,8 @@ template <> void Converter::operator()(xml_h e) const { mat->GetName(), prop_nam.c_str(), ref.c_str()); } else if ( p.hasAttr(_U(option)) ) { - string prop_nam = p.attr(_U(name)); - string prop_typ = p.attr(_U(option)); + std::string prop_nam = p.attr(_U(name)); + std::string prop_typ = p.attr(_U(option)); mat->AddConstProperty(prop_nam.c_str(), prop_typ.c_str()); printout(s_debug.materials ? ALWAYS : DEBUG, "Compact", "++ material %-16s add constant property: %s -> %s.", @@ -554,10 +553,10 @@ template <> void Converter::operator()(xml_h e) const { for(xml_coll_t properties(x_mat, _U(property)); properties; ++properties) { xml_elt_t p = properties; if ( p.hasAttr(_U(ref)) ) { - string ref = p.attr(_U(ref)); + std::string ref = p.attr(_U(ref)); TGDMLMatrix* gdmlMat = mgr.GetGDMLMatrix(ref.c_str()); if ( gdmlMat ) { - string prop_nam = p.attr(_U(name)); + std::string prop_nam = p.attr(_U(name)); mat->AddProperty(prop_nam.c_str(), ref.c_str()); printout(s_debug.materials ? ALWAYS : DEBUG, "Compact", "++ material %-16s add property: %s -> %s.", @@ -579,7 +578,7 @@ template <> void Converter::operator()(xml_h e) const { // TGeo has no notion of a material "formula" // Hence, treat the formula the same way as the material itself if (x_mat.hasAttr(_U(formula))) { - string form = x_mat.attr(_U(formula)); + std::string form = x_mat.attr(_U(formula)); if (form != matname) { medium = mgr.GetMedium(form.c_str()); if (0 == medium) { @@ -601,18 +600,18 @@ template <> void Converter::operator()(xml_h e) const { template <> void Converter::operator()(xml_h e) const { xml_dim_t isotope(e); TGeoManager& mgr = description.manager(); - string nam = isotope.nameStr(); + std::string nam = isotope.nameStr(); TGeoElementTable* tab = mgr.GetElementTable(); TGeoIsotope* iso = tab->FindIsotope(nam.c_str()); // Create the isotope object in the event it is not yet present from the XML data if ( !iso ) { - xml_ref_t atom(isotope.child(_U(atom))); - int n = isotope.attr(_U(N)); - int z = isotope.attr(_U(Z)); - double value = atom.attr(_U(value)); - string unit = atom.attr(_U(unit)); - double a = value * _multiply(unit,"mol/g"); + xml_ref_t atom(isotope.child(_U(atom))); + std::string unit = atom.attr(_U(unit)); + double value = atom.attr(_U(value)); + double a = value * _multiply(unit,"mol/g"); + int n = isotope.attr(_U(N)); + int z = isotope.attr(_U(Z)); iso = new TGeoIsotope(nam.c_str(), z, n, a); printout(s_debug.isotopes ? ALWAYS : DEBUG, "Compact", "++ Converting isotope %-16s Z:%3d N:%3d A:%8.4f [g/mol]", @@ -647,12 +646,12 @@ template <> void Converter::operator()(xml_h e) const { TGeoElement* elt = tab->FindElement(name.c_str()); if ( !elt ) { if ( elem.hasChild(_U(atom)) ) { - xml_ref_t atom(elem.child(_U(atom))); - string formula = elem.attr(_U(formula)); - double value = atom.attr(_U(value)); - string unit = atom.attr(_U(unit)); - int z = elem.attr(_U(Z)); - double a = value*_multiply(unit,"mol/g"); + xml_ref_t atom(elem.child(_U(atom))); + std::string formula = elem.attr(_U(formula)); + double value = atom.attr(_U(value)); + std::string unit = atom.attr(_U(unit)); + int z = elem.attr(_U(Z)); + double a = value*_multiply(unit,"mol/g"); printout(s_debug.elements ? ALWAYS : DEBUG, "Compact", "++ Converting element %-16s [%-3s] Z:%3d A:%8.4f [g/mol]", name.c_str(), formula.c_str(), z, a); @@ -660,15 +659,15 @@ template <> void Converter::operator()(xml_h e) const { } else { int num_isotopes = 0; - string formula = elem.hasAttr(_U(formula)) ? elem.attr(_U(formula)) : name.str(); + std::string formula = elem.hasAttr(_U(formula)) ? elem.attr(_U(formula)) : name.str(); for( xml_coll_t i(elem,_U(fraction)); i; ++i) ++num_isotopes; elt = new TGeoElement(name.c_str(), formula.c_str(), num_isotopes); tab->AddElement(elt); for( xml_coll_t i(elem,_U(fraction)); i; ++i) { - double frac = i.attr(_U(n)); - string ref = i.attr(_U(ref)); - TGeoIsotope* iso = tab->FindIsotope(ref.c_str()); + double frac = i.attr(_U(n)); + std::string ref = i.attr(_U(ref)); + TGeoIsotope* iso = tab->FindIsotope(ref.c_str()); if ( !iso ) { except("Compact","Element %s cannot be constructed. Isotope '%s' (fraction: %.3f) missing!", name.c_str(), ref.c_str(), frac); @@ -716,7 +715,7 @@ template <> void Converter::operator()(xml_h e) const { temp_unit = temperature.attr(_U(unit)); temp_val = temperature.attr(_U(value)) * temp_unit; } - xml_h pressure = cond.child(_U(P), false); + xml_h pressure = cond.child(_U(P), false); double pressure_val = description.stdConditions().pressure; if ( pressure.ptr() ) { double pressure_unit = _toDouble("pascal"); @@ -738,17 +737,17 @@ template <> void Converter::operator()(xml_h e) const { template <> void Converter::operator()(xml_h element) const { xml_elt_t e = element; TGeoManager& mgr = description.manager(); - std::string sname = e.attr(_U(name)); - string ref, pname; + std::string sname = e.attr(_U(name)); + std::string ref, pname; // Defaults from Geant4 OpticalSurface::EModel model = OpticalSurface::Model::kMglisur; OpticalSurface::EFinish finish = OpticalSurface::Finish::kFpolished; OpticalSurface::EType type = OpticalSurface::Type::kTdielectric_metal; Double_t value = 1.0; - if ( e.hasAttr(_U(type)) ) type = OpticalSurface::stringToType(e.attr(_U(type))); - if ( e.hasAttr(_U(model)) ) model = OpticalSurface::stringToModel(e.attr(_U(model))); - if ( e.hasAttr(_U(finish)) ) finish = OpticalSurface::stringToFinish(e.attr(_U(finish))); + if ( e.hasAttr(_U(type)) ) type = OpticalSurface::stringToType(e.attr(_U(type))); + if ( e.hasAttr(_U(model)) ) model = OpticalSurface::stringToModel(e.attr(_U(model))); + if ( e.hasAttr(_U(finish)) ) finish = OpticalSurface::stringToFinish(e.attr(_U(finish))); if ( e.hasAttr(_U(value)) ) value = e.attr(_U(value)); OpticalSurface surf(description, sname, model, finish, type, value); if ( s_debug.surface ) { @@ -756,10 +755,10 @@ template <> void Converter::operator()(xml_h element) const { sname.c_str(), int(type), int(model), int(finish), value); } for (xml_coll_t props(e, _U(property)); props; ++props) { - pname = props.attr(_U(name)); + pname = props.attr(_U(name)); if ( props.hasAttr(_U(ref)) ) { bool err = kFALSE; - ref = props.attr(_U(ref)); + ref = props.attr(_U(ref)); mgr.GetProperty(ref.c_str(), &err); /// Check existence surf->AddProperty(pname.c_str(), ref.c_str()); if ( s_debug.surface ) { @@ -767,11 +766,11 @@ template <> void Converter::operator()(xml_h element) const { } continue; } - size_t cols = props.attr(_U(coldim)); - xml_attr_t opt = props.attr_nothrow(_U(option)); - stringstream str(props.attr(_U(values))), str_nam; - string val; - vector values; + std::size_t cols = props.attr(_U(coldim)); + xml_attr_t opt = props.attr_nothrow(_U(option)); + std::stringstream str(props.attr(_U(values))), str_nam; + std::string val; + std::vector values; while ( !str.eof() ) { val = ""; str >> val; @@ -781,13 +780,13 @@ template <> void Converter::operator()(xml_h element) const { /// Create table and register table TGDMLMatrix* table = new TGDMLMatrix("",values.size()/cols, cols); if ( opt ) { - string tit = e.attr(opt); + std::string tit = e.attr(opt); str_nam << tit << "|"; } str_nam << pname << "__" << (void*)table; table->SetName(str_nam.str().c_str()); table->SetTitle(pname.c_str()); - for (size_t i=0, n=values.size(); iSet(i/cols, i%cols, values[i]); surf->AddProperty(pname.c_str(), table->GetName()); description.manager().AddGDMLMatrix(table); @@ -797,10 +796,10 @@ template <> void Converter::operator()(xml_h element) const { // In case there were constant surface properties specified: convert them here for(xml_coll_t properties(e, _U(constant)); properties; ++properties) { xml_elt_t p = properties; - pname = p.attr(_U(name)); + pname = p.attr(_U(name)); if ( p.hasAttr(_U(ref)) ) { bool err = kFALSE; - ref = p.attr(_U(ref)); + ref = p.attr(_U(ref)); mgr.GetProperty(ref.c_str(), &err); /// Check existence if ( err == kFALSE ) { surf->AddConstProperty(pname.c_str(), ref.c_str()); @@ -814,7 +813,7 @@ template <> void Converter::operator()(xml_h element) const { " ConstProperty missing in TGeoManager: " + ref); } else if ( p.hasAttr(_U(value)) ) { - stringstream str; + std::stringstream str; str << pname << "_" << (void*)surf.ptr(); ref = str.str(); mgr.AddProperty(ref.c_str(), p.attr(_U(value))); /// Check existence @@ -824,7 +823,7 @@ template <> void Converter::operator()(xml_h element) const { surf->GetName(), pname.c_str(), ref.c_str()); } else if ( p.hasAttr(_U(option)) ) { - string ptyp = p.attr(_U(option)); + std::string ptyp = p.attr(_U(option)); surf->AddConstProperty(pname.c_str(), ptyp.c_str()); printout(s_debug.surface ? ALWAYS : DEBUG, "Compact", "++ surface %-16s add constant property: %s -> %s.", @@ -840,8 +839,8 @@ template <> void Converter::operator()(xml_h element) const { * */ template <> void Converter::operator()(xml_h e) const { - double value = e.attr(_U(value)); - string name = e.attr(_U(name)); + double value = e.attr(_U(value)); + std::string name = e.attr(_U(name)); description.manager().AddProperty(name.c_str(), value); if ( s_debug.matrix ) { printout(ALWAYS,"Compact","+++ Reading property %s : %f",name.c_str(), value); @@ -849,7 +848,7 @@ template <> void Converter::operator()(xml_h e) const { #if 0 xml_attr_t opt = e.attr_nothrow(_U(title)); if ( opt ) { - string val = e.attr(opt); + std::string val = e.attr(opt); TNamed* nam = description.manager().GetProperty(name.c_str()); if ( !nam ) { except("Compact","Failed to access just added manager property: %s",name.c_str()); @@ -865,35 +864,35 @@ template <> void Converter::operator()(xml_h e) const { * */ template <> void Converter::operator()(xml_h e) const { - vector vals; - size_t cols = e.attr(_U(coldim)); - stringstream str(e.attr(_U(values))); + std::vector vals; + std::size_t cols = e.attr(_U(coldim)); + std::stringstream str(e.attr(_U(values))); if ( s_debug.matrix ) { printout(ALWAYS,"Compact","+++ Reading property table %s with %d columns.", - e.attr(_U(name)).c_str(), cols); + e.attr(_U(name)).c_str(), cols); } vals.reserve(1024); while ( !str.eof() ) { - string item; + std::string item; str >> item; if ( item.empty() && !str.good() ) break; vals.emplace_back(_toDouble(item)); if ( s_debug.matrix ) { - cout << " state:" << (str.good() ? "OK " : "BAD") << " '" << item << "'"; - if ( 0 == (vals.size()%cols) ) cout << endl; + std::cout << " state:" << (str.good() ? "OK " : "BAD") << " '" << item << "'"; + if ( 0 == (vals.size()%cols) ) std::cout << std::endl; } } if ( s_debug.matrix ) { - cout << endl; + std::cout << std::endl; } /// Create table and register table xml_attr_t opt = e.attr_nothrow(_U(option)); PropertyTable tab(description, - e.attr(_U(name)), - opt ? e.attr(opt).c_str() : "", + e.attr(_U(name)), + opt ? e.attr(opt).c_str() : "", vals.size()/cols, cols); - for( size_t i=0, n=vals.size(); i < n; ++i ) + for( std::size_t i=0, n=vals.size(); i < n; ++i ) tab->Set(i/cols, i%cols, vals[i]); //if ( s_debug.matrix ) tab->Print(); } @@ -913,7 +912,7 @@ template <> void Converter::operator()(xml_h e) const { * alpha="0.5"/> */ template <> void Converter::operator()(xml_h e) const { - VisAttr attr(e.attr(_U(name))); + VisAttr attr(e.attr(_U(name))); float alpha = 1.0; float red = 1.0; float green = 1.0; @@ -921,10 +920,10 @@ template <> void Converter::operator()(xml_h e) const { bool use_ref = false; if(e.hasAttr(_U(ref))) { use_ref = true; - auto refName = e.attr(_U(ref)); + auto refName = e.attr(_U(ref)); const auto refAttr = description.visAttributes(refName); if(!refAttr.isValid() ) { - throw runtime_error("reference VisAttr " + refName + " does not exist"); + except("Compact","+++ Reference VisAttr %s does not exist", refName.c_str()); } // Just copying things manually. // I think a handle's copy constructor/assignment would reuse the underlying pointer... maybe? @@ -948,7 +947,7 @@ template <> void Converter::operator()(xml_h e) const { if (e.hasAttr(_U(visible))) attr.setVisible(e.attr(_U(visible))); if (e.hasAttr(_U(lineStyle))) { - string ls = e.attr(_U(lineStyle)); + std::string ls = e.attr(_U(lineStyle)); if (ls == "unbroken") attr.setLineStyle(VisAttr::SOLID); else if (ls == "broken") @@ -959,7 +958,7 @@ template <> void Converter::operator()(xml_h e) const { attr.setLineStyle(VisAttr::SOLID); } if (e.hasAttr(_U(drawingStyle))) { - string ds = e.attr(_U(drawingStyle)); + std::string ds = e.attr(_U(drawingStyle)); if (ds == "wireframe") attr.setDrawingStyle(VisAttr::WIREFRAME); else if (ds == "solid") @@ -984,7 +983,7 @@ template <> void Converter::operator()(xml_h e) const { template <> void Converter::operator()(xml_h elt) const { xml_dim_t e = elt; Region region(e.nameStr()); - vector& limits = region.limits(); + auto& limits = region.limits(); xml_attr_t cut = elt.attr_nothrow(_U(cut)); xml_attr_t threshold = elt.attr_nothrow(_U(threshold)); xml_attr_t store_secondaries = elt.attr_nothrow(_U(store_secondaries)); @@ -1002,7 +1001,7 @@ template <> void Converter::operator()(xml_h elt) const { region.setStoreSecondaries(elt.attr(store_secondaries)); } for (xml_coll_t user_limits(e, _U(limitsetref)); user_limits; ++user_limits) - limits.emplace_back(user_limits.attr(_U(name))); + limits.emplace_back(user_limits.attr(_U(name))); description.addRegion(region); } @@ -1015,9 +1014,9 @@ template <> void Converter::operator()(xml_h elt) const { * */ template <> void Converter::operator()(xml_h seg) const { - string type = seg.attr(_U(type)); - string name = seg.hasAttr(_U(name)) ? seg.attr(_U(name)) : string(); - std::pair* opt = _option >(); + std::string type = seg.attr(_U(type)); + std::string name = seg.hasAttr(_U(name)) ? seg.attr(_U(name)) : std::string(); + std::pair* opt = _option >(); const BitFieldCoder* bitfield = &opt->second->decoder; Segmentation segment(type, name, bitfield); @@ -1028,7 +1027,7 @@ template <> void Converter::operator()(xml_h seg) const { for(const auto p : pars ) { xml::Strng_t pNam(p->name()); if ( seg.hasAttr(pNam) ) { - string pType = p->type(); + std::string pType = p->type(); if ( pType.compare("int") == 0 ) { typedef DDSegmentation::TypedSegmentationParameter ParInt; static_cast(p)->setTypedValue(seg.attr(pNam)); @@ -1036,22 +1035,22 @@ template <> void Converter::operator()(xml_h seg) const { typedef DDSegmentation::TypedSegmentationParameter ParFloat; static_cast(p)->setTypedValue(seg.attr(pNam)); } else if ( pType.compare("doublevec") == 0 ) { - vector valueVector; - string par = seg.attr(pNam); + std::vector valueVector; + std::string par = seg.attr(pNam); printout(s_debug.segmentation ? ALWAYS : DEBUG, "Compact", - "++ Converting this string structure: %s.",par.c_str()); - vector elts = DDSegmentation::splitString(par); - for (const string& spar : elts ) { + "++ Converting this std::string structure: %s.",par.c_str()); + std::vector elts = DDSegmentation::splitString(par); + for (const std::string& spar : elts ) { if ( spar.empty() ) continue; valueVector.emplace_back(_toDouble(spar)); } - typedef DDSegmentation::TypedSegmentationParameter< vector > ParDouVec; + typedef DDSegmentation::TypedSegmentationParameter< std::vector > ParDouVec; static_cast(p)->setTypedValue(valueVector); } else if ( pType.compare("double" ) == 0) { typedef DDSegmentation::TypedSegmentationParameterParDouble; static_cast(p)->setTypedValue(seg.attr(pNam)); } else { - p->setValue(seg.attr(pNam)); + p->setValue(seg.attr(pNam)); } } else if (not p->isOptional()) { throw_print("FAILED to create segmentation: " + type + @@ -1075,7 +1074,7 @@ template <> void Converter::operator()(xml_h seg) const { key_max = x_seg.key_max(); } else { - stringstream tree; + std::stringstream tree; xml::dump_tree(sub,tree); throw_print("Nested segmentations: Invalid key specification:"+tree.str()); } @@ -1102,8 +1101,8 @@ template <> void Converter::operator()(xml_h seg) const { */ template <> void Converter::operator()(xml_h e) const { xml_h seg = e.child(_U(segmentation), false); - xml_h id = e.child(_U(id)); - string name = e.attr(_U(name)); + xml_h id = e.child(_U(id)); + std::string name = e.attr(_U(name)); std::pair opt; Readout ro(name); @@ -1131,16 +1130,16 @@ template <> void Converter::operator()(xml_h e) const { ro.name(), id ? "ID: " : "", id ? id.text().c_str() : ""); for(xml_coll_t colls(e,_U(hits_collections)); colls; ++colls) { - string hits_key; - if ( colls.hasAttr(_U(key)) ) hits_key = colls.attr(_U(key)); + std::string hits_key; + if ( colls.hasAttr(_U(key)) ) hits_key = colls.attr(_U(key)); for(xml_coll_t coll(colls,_U(hits_collection)); coll; ++coll) { xml_dim_t c(coll); - string coll_name = c.nameStr(); - string coll_key = hits_key; + std::string coll_name = c.nameStr(); + std::string coll_key = hits_key; long key_min = 0, key_max = 0; if ( c.hasAttr(_U(key)) ) { - coll_key = c.attr(_U(key)); + coll_key = c.attr(_U(key)); } if ( c.hasAttr(_U(key_value)) ) { key_max = key_min = c.key_value(); @@ -1150,7 +1149,7 @@ template <> void Converter::operator()(xml_h e) const { key_max = c.key_max(); } else { - stringstream tree; + std::stringstream tree; xml::dump_tree(e,tree); throw_print("Readout: Invalid specification for multiple hit collections."+tree.str()); } @@ -1180,14 +1179,14 @@ DECLARE_XML_DOC_READER(readout,load_readout) */ template <> void Converter::operator()(xml_h e) const { Limit limit; - LimitSet ls(e.attr(_U(name))); + LimitSet ls(e.attr(_U(name))); printout(s_debug.limits ? ALWAYS : DEBUG, "Compact", "++ Converting LimitSet structure: %s.",ls.name()); for (xml_coll_t c(e, _U(limit)); c; ++c) { - limit.name = c.attr(_U(name)); - limit.particles = c.attr(_U(particles)); - limit.content = c.attr(_U(value)); - limit.unit = c.attr(_U(unit)); + limit.name = c.attr(_U(name)); + limit.particles = c.attr(_U(particles)); + limit.content = c.attr(_U(value)); + limit.unit = c.attr(_U(unit)); limit.value = _multiply(limit.content, limit.unit); ls.addLimit(limit); printout(s_debug.limits ? ALWAYS : DEBUG, "Compact", @@ -1197,9 +1196,9 @@ template <> void Converter::operator()(xml_h e) const { } limit.name = "cut"; for (xml_coll_t c(e, _U(cut)); c; ++c) { - limit.particles = c.attr(_U(particles)); - limit.content = c.attr(_U(value)); - limit.unit = c.attr(_U(unit)); + limit.particles = c.attr(_U(particles)); + limit.content = c.attr(_U(value)); + limit.unit = c.attr(_U(unit)); limit.value = _multiply(limit.content, limit.unit); ls.addCut(limit); printout(s_debug.limits ? ALWAYS : DEBUG, "Compact", @@ -1217,17 +1216,17 @@ template <> void Converter::operator()(xml_h e) const { * ... */ template <> void Converter::operator()(xml_h e) const { - string name = e.attr(_U(name)); + std::string name = e.attr(_U(name)); Detector::Properties& prp = description.properties(); if ( name.empty() ) throw_print("Failed to convert properties. No name given!"); - vector a = e.attributes(); + std::vector a = e.attributes(); if ( prp.find(name) == prp.end() ) prp.emplace(name, Detector::PropertyValues()); for (xml_attr_t i : a ) - prp[name].emplace(xml_tag_t(e.attr_name(i)).str(),e.attr(i)); + prp[name].emplace(xml_tag_t(e.attr_name(i)).str(),e.attr(i)); } /** Specialized converter for electric and magnetic fields @@ -1239,9 +1238,9 @@ template <> void Converter::operator()(xml_h e) const { * */ template <> void Converter::operator()(xml_h e) const { - string msg = "updated"; - string name = e.attr(_U(name)); - string type = e.attr(_U(type)); + std::string msg = "updated"; + std::string name = e.attr(_U(name)); + std::string type = e.attr(_U(type)); CartesianField field = description.field(name); if ( !field.isValid() ) { // The field is not present: We create it and add it to Detector @@ -1258,13 +1257,13 @@ template <> void Converter::operator()(xml_h e) const { // Now update the field structure with the generic part ie. set its properties CartesianField::Properties& prp = field.properties(); for ( xml_coll_t c(e, _U(properties)); c; ++c ) { - string props_name = c.attr(_U(name)); - vectora = c.attributes(); + std::string props_name = c.attr(_U(name)); + std::vectora = c.attributes(); if ( prp.find(props_name) == prp.end() ) { prp.emplace(props_name, Detector::PropertyValues()); } for ( xml_attr_t i : a ) - prp[props_name].emplace(xml_tag_t(c.attr_name(i)).str(), c.attr(i)); + prp[props_name].emplace(xml_tag_t(c.attr_name(i)).str(), c.attr(i)); if (c.hasAttr(_U(global)) && c.attr(_U(global))) { description.field().properties() = prp; @@ -1287,12 +1286,12 @@ template <> void Converter::operator()(xml_h e) const { * */ template <> void Converter::operator()(xml_h element) const { - string name = element.attr(_U(name)); + std::string name = element.attr(_U(name)); try { SensitiveDetector sd = description.sensitiveDetector(name); xml_attr_t type = element.attr_nothrow(_U(type)); if ( type ) { - sd.setType(element.attr(type)); + sd.setType(element.attr(type)); } xml_attr_t verbose = element.attr_nothrow(_U(verbose)); if ( verbose ) { @@ -1304,7 +1303,7 @@ template <> void Converter::operator()(xml_h element) const { } xml_attr_t limits = element.attr_nothrow(_U(limits)); if ( limits ) { - string l = element.attr(limits); + std::string l = element.attr(limits); LimitSet ls = description.limitSet(l); if (!ls.isValid()) { throw_print("Converter: Request for non-existing limitset:" + l); @@ -1313,7 +1312,7 @@ template <> void Converter::operator()(xml_h element) const { } xml_attr_t region = element.attr_nothrow(_U(region)); if ( region ) { - string r = element.attr(region); + std::string r = element.attr(region); Region reg = description.region(r); if (!reg.isValid()) { throw_print("Converter: Request for non-existing region:" + r); @@ -1322,7 +1321,7 @@ template <> void Converter::operator()(xml_h element) const { } xml_attr_t hits = element.attr_nothrow(_U(hits_collection)); if (hits) { - sd.setHitsCollection(element.attr(hits)); + sd.setHitsCollection(element.attr(hits)); } xml_attr_t ecut = element.attr_nothrow(_U(ecut)); xml_attr_t eunit = element.attr_nothrow(_U(eunit)); @@ -1339,7 +1338,7 @@ template <> void Converter::operator()(xml_h element) const { if (sequence) { } } - catch (const exception& e) { + catch (const std::exception& e) { printout(ERROR, "Compact", "++ FAILED to convert sensitive detector: %s: %s", name.c_str(), e.what()); } catch (...) { @@ -1347,7 +1346,7 @@ template <> void Converter::operator()(xml_h element) const { } } -static void setChildTitles(const pair& e) { +static void setChildTitles(const std::pair& e) { DetElement parent = e.second.parent(); const DetElement::Children& children = e.second.children(); if (::strlen(e.second->GetTitle()) == 0) { @@ -1361,10 +1360,10 @@ template <> void Converter::operator()(xml_h element) const { static const char* req_typs = ::getenv("REQUIRED_DETECTOR_TYPES"); static const char* ign_dets = ::getenv("IGNORED_DETECTORS"); static const char* ign_typs = ::getenv("IGNORED_DETECTOR_TYPES"); - string type = element.attr(_U(type)); - string name = element.attr(_U(name)); - string name_match = ":" + name + ":"; - string type_match = ":" + type + ":"; + std::string type = element.attr(_U(type)); + std::string name = element.attr(_U(name)); + std::string name_match = ":" + name + ":"; + std::string type_match = ":" + type + ":"; if (req_dets && !strstr(req_dets, name_match.c_str())) return; @@ -1385,13 +1384,13 @@ template <> void Converter::operator()(xml_h element) const { } } try { - string par_name; + std::string par_name; xml_attr_t attr_par = element.attr_nothrow(_U(parent)); xml_elt_t elt_par(0); if (attr_par) - par_name = element.attr(attr_par); + par_name = element.attr(attr_par); else if ( (elt_par=element.child(_U(parent),false)) ) - par_name = elt_par.attr(_U(name)); + par_name = elt_par.attr(_U(name)); if ( !par_name.empty() ) { // We have here a nested detector. If the mother volume is not yet registered // it must be done here, so that the detector constructor gets the correct answer from @@ -1407,9 +1406,9 @@ template <> void Converter::operator()(xml_h element) const { SensitiveDetector sd; Segmentation seg; if ( attr_ro ) { - Readout ro = description.readout(element.attr(attr_ro)); + Readout ro = description.readout(element.attr(attr_ro)); if (!ro.isValid()) { - throw runtime_error("No Readout structure present for detector:" + name); + except("Compact","No Readout structure present for detector:" + name); } seg = ro.segmentation(); sd = SensitiveDetector(name, "sensitive"); @@ -1420,7 +1419,7 @@ template <> void Converter::operator()(xml_h element) const { Ref_t sens = sd; DetElement det(Ref_t(PluginService::Create(type, &description, &element, &sens))); if (det.isValid()) { - setChildTitles(make_pair(name, det)); + setChildTitles(std::make_pair(name, det)); if ( sd.isValid() ) { det->flag |= DetElement::Object::HAVE_SENSITIVE_DETECTOR; } @@ -1436,19 +1435,19 @@ template <> void Converter::operator()(xml_h element) const { if (!det.isValid()) { PluginDebug dbg; PluginService::Create(type, &description, &element, &sens); - throw runtime_error("Failed to execute subdetector creation plugin. " + dbg.missingFactory(type)); + except("Compact","Failed to execute subdetector creation plugin. %s", dbg.missingFactory(type).c_str()); } description.addDetector(det); description.surfaceManager().registerSurfaces(det); return; } - catch (const exception& e) { + catch (const std::exception& e) { printout(ERROR, "Compact", "++ FAILED to convert subdetector: %s: %s", name.c_str(), e.what()); - terminate(); + std::terminate(); } catch (...) { printout(ERROR, "Compact", "++ FAILED to convert subdetector: %s: %s", name.c_str(), "UNKNONW Exception"); - terminate(); + std::terminate(); } } @@ -1475,27 +1474,27 @@ template <> void Converter::operator()(xml_h element) const { /// Read material entries from a seperate file in one of the include sections of the geometry template <> void Converter::operator()(xml_h element) const { - string base = xml::DocumentHandler::system_directory(element); - string file = element.attr(_U(ref)); - vector argv{&file[0], &base[0]}; + std::string base = xml::DocumentHandler::system_directory(element); + std::string file = element.attr(_U(ref)); + std::vector argv{&file[0], &base[0]}; description.apply("DD4hep_JsonProcessor",int(argv.size()), &argv[0]); } /// Read alignment entries from a seperate file in one of the include sections of the geometry template <> void Converter::operator()(xml_h element) const { - PrintLevel level = s_debug.includes ? ALWAYS : DEBUG; - string fname = element.attr(_U(ref)); - size_t idx = fname.find("://"); + PrintLevel level = s_debug.includes ? ALWAYS : DEBUG; + std::string fname = element.attr(_U(ref)); + std::size_t idx = fname.find("://"); std::error_code ec; - if ( idx == string::npos && filesystem::exists(fname, ec) ) { + if ( idx == std::string::npos && std::filesystem::exists(fname, ec) ) { // Regular file without protocol specification printout(level, "Compact","++ Processing xml document %s.", fname.c_str()); this->description.fromXML(fname); } - else if ( idx == string::npos ) { + else if ( idx == std::string::npos ) { // File relative to location of xml tag (protocol specification not possible) - string location = xml::DocumentHandler::system_path(element, fname); + std::string location = xml::DocumentHandler::system_path(element, fname); printout(level, "Compact","++ Processing xml document %s.", location.c_str()); this->description.fromXML(location); } @@ -1516,8 +1515,8 @@ template <> void Converter::operator()(xml_h element) const { xml_elt_t x_world(element); xml_comp_t x_shape = x_world.child(_U(shape), false); xml_attr_t att = x_world.getAttr(_U(material)); - Material mat = att ? description.material(x_world.attr(att)) : description.air(); - Volume world_vol; + Material mat = att ? description.material(x_world.attr(att)) : description.air(); + Volume world_vol; /// Create the shape and the corresponding volume if ( x_shape ) { @@ -1562,15 +1561,15 @@ template <> void Converter::operator()(xml_h element) cons xml_comp_t shape = parallel.child(_U(shape)); xml_dim_t pos = element.child(_U(position),false); xml_dim_t rot = element.child(_U(rotation),false); - string name = element.attr(_U(name)); - string path = element.attr(_U(anchor)); + std::string name = element.attr(_U(name)); + std::string path = element.attr(_U(anchor)); bool conn = element.attr(_U(connected),false); DetElement anchor(detail::tools::findElement(description, path)); Position position = pos ? Position(pos.x(), pos.y(), pos.z()) : Position(); RotationZYX rotation = rot ? RotationZYX(rot.z(), rot.y(), rot.x()) : RotationZYX(); Material mat = parallel.hasAttr(_U(material)) - ? description.material(parallel.attr(_U(material))) + ? description.material(parallel.attr(_U(material))) : description.air(); VisAttr vis = parallel.hasAttr(_U(vis)) ? description.invisible() @@ -1610,7 +1609,7 @@ template <> void Converter::operator()(xml_h element) cons /// Read material entries from a seperate file in one of the include sections of the geometry template <> void Converter::operator()(xml_h element) const { - string type = element.hasAttr(_U(type)) ? element.attr(_U(type)) : string("xml"); + std::string type = element.hasAttr(_U(type)) ? element.attr(_U(type)) : std::string("xml"); if ( type == "xml" ) { xml::DocumentHolder doc(xml::DocumentHandler().load(element, element.attr_value(_U(ref)))); if ( s_debug.include_guard ) { @@ -1622,7 +1621,7 @@ template <> void Converter::operator()(xml_h element) const { printout(ALWAYS, "Compact","++ Processing xml document %s.",doc.uri().c_str()); } xml_h node = doc.root(); - string tag = node.tag(); + std::string tag = node.tag(); if ( tag == "lccdd" ) Converter(this->description)(node); else if ( tag == "define" ) @@ -1683,7 +1682,7 @@ template <> void Converter::operator()(xml_h element) const { if ( steer.hasAttr(_U(reflect)) ) build_reflections = steer.attr(_U(reflect)); for (xml_coll_t clr(steer, _U(clear)); clr; ++clr) { - string nam = clr.hasAttr(_U(name)) ? clr.attr(_U(name)) : string(); + std::string nam = clr.hasAttr(_U(name)) ? clr.attr(_U(name)) : std::string(); if ( nam.substr(0,6) == "elemen" ) { TGeoElementTable* table = description.manager().GetElementTable(); table->TGeoElementTable::~TGeoElementTable(); diff --git a/DDCore/src/segmentations/MultiSegmentation.cpp b/DDCore/src/segmentations/MultiSegmentation.cpp index 6dd0c4c00..c00b5ec4e 100644 --- a/DDCore/src/segmentations/MultiSegmentation.cpp +++ b/DDCore/src/segmentations/MultiSegmentation.cpp @@ -11,20 +11,19 @@ #include #include -using namespace std; - namespace dd4hep { + namespace DDSegmentation { /// default constructor using an encoding string - MultiSegmentation::MultiSegmentation(const string& cellEncoding) + MultiSegmentation::MultiSegmentation(const std::string& cellEncoding) : Segmentation(cellEncoding), m_discriminator(0), m_debug(0) { // define type and description _type = "MultiSegmentation"; _description = "Multi-segmenation wrapper segmentation"; //registerParameter("debug", "Debug flag", m_debug, 0); - registerParameter("key", "Diskriminating field", m_discriminatorId, ""); + registerParameter("key", "Diskriminating field", m_discriminatorId, ""); } /// Default constructor used by derived classes passing an existing decoder @@ -35,7 +34,7 @@ namespace dd4hep { _type = "MultiSegmentation"; _description = "Multi-segmenation wrapper segmentation"; //registerParameter("debug", "Debug flag", m_debug, 0); - registerParameter("key", "Diskriminating field", m_discriminatorId, ""); + registerParameter("key", "Diskriminating field", m_discriminatorId, ""); } /// destructor @@ -82,7 +81,8 @@ namespace dd4hep { } } } - throw runtime_error("MultiSegmentation: Invalid sub-segmentation identifier!");; + except("MultiSegmentation", "Invalid sub-segmentation identifier!"); + throw std::string("Invalid sub-segmentation identifier!"); } /// determine the position based on the cell ID @@ -95,13 +95,9 @@ namespace dd4hep { return subsegmentation(vID).cellID(localPosition, globalPosition, vID); } - vector MultiSegmentation::cellDimensions(const CellID& cID) const { + std::vector MultiSegmentation::cellDimensions(const CellID& cID) const { return subsegmentation(cID).cellDimensions(cID); } } /* namespace DDSegmentation */ } /* namespace dd4hep */ - -// This is done DDCore/src/plugins/ReadoutSegmentations.cpp so the plugin is not part of libDDCore -// needs also #include "DD4hep/Factories.h" -// DECLARE_SEGMENTATION(MultiSegmentation,create_segmentation) diff --git a/DDDigi/plugins/DigiRandomNoise.cpp b/DDDigi/plugins/DigiRandomNoise.cpp index 72b435c80..290c2e1d0 100644 --- a/DDDigi/plugins/DigiRandomNoise.cpp +++ b/DDDigi/plugins/DigiRandomNoise.cpp @@ -82,13 +82,12 @@ namespace dd4hep { // C/C++ include files -using namespace std; using namespace dd4hep::digi; DECLARE_DIGIACTION_NS(dd4hep::digi,DigiRandomNoise) /// Standard constructor -DigiRandomNoise::DigiRandomNoise(const DigiKernel& kernel, const string& nam) +DigiRandomNoise::DigiRandomNoise(const DigiKernel& kernel, const std::string& nam) : DigiEventAction(kernel, nam) { declareProperty("Probability", m_probability); diff --git a/DDDigi/src/DigiActionSequence.cpp b/DDDigi/src/DigiActionSequence.cpp index 4815074fb..8596a94a1 100644 --- a/DDDigi/src/DigiActionSequence.cpp +++ b/DDDigi/src/DigiActionSequence.cpp @@ -18,11 +18,10 @@ // C/C++ include files #include -using namespace std; using namespace dd4hep::digi; /// Standard constructor -DigiActionSequence::DigiActionSequence(const DigiKernel& kernel, const string& nam) +DigiActionSequence::DigiActionSequence(const DigiKernel& kernel, const std::string& nam) : DigiSynchronize(kernel, nam) { InstanceCount::increment(this); @@ -50,7 +49,7 @@ void DigiActionSequence::execute(DigiContext& context) const { } /// Standard constructor -DigiSequentialActionSequence::DigiSequentialActionSequence(const DigiKernel& kernel, const string& nam) +DigiSequentialActionSequence::DigiSequentialActionSequence(const DigiKernel& kernel, const std::string& nam) : DigiActionSequence(kernel, nam) { this->m_parallel = false; @@ -63,7 +62,7 @@ DigiSequentialActionSequence::~DigiSequentialActionSequence() { } /// Standard constructor -DigiParallelActionSequence::DigiParallelActionSequence(const DigiKernel& kernel, const string& nam) +DigiParallelActionSequence::DigiParallelActionSequence(const DigiKernel& kernel, const std::string& nam) : DigiActionSequence(kernel, nam) { this->m_parallel = true; diff --git a/DDDigi/src/DigiHandle.cpp b/DDDigi/src/DigiHandle.cpp index f115968ee..dee3922d2 100644 --- a/DDDigi/src/DigiHandle.cpp +++ b/DDDigi/src/DigiHandle.cpp @@ -25,12 +25,11 @@ // C/C++ include files #include -using namespace std; -using namespace dd4hep; using namespace dd4hep::digi; /// Namespace for the AIDA detector description toolkit namespace dd4hep { + /// Namespace for the Digitization part of the AIDA detector description toolkit namespace digi { @@ -75,14 +74,14 @@ namespace dd4hep { template TYPE* _create_object(const DigiKernel& kernel, const TypeName& typ) { TYPE* object = _raw_create(typ.first, kernel, typ.second); if (!object && typ.first == typ.second) { - string _t = typeName(typeid(TYPE)); + std::string _t = typeName(typeid(TYPE)); printout(DEBUG, "DigiHandle", "Object factory for %s not found. Try out %s", typ.second.c_str(), _t.c_str()); object = _raw_create(_t, kernel, typ.second); if (!object) { size_t idx = _t.rfind(':'); - if (idx != string::npos) - _t = string(_t.substr(idx + 1)); + if (idx != std::string::npos) + _t = std::string(_t.substr(idx + 1)); printout(DEBUG, "DigiHandle", "Try out object factory for %s",_t.c_str()); object = _raw_create(_t, kernel, typ.second); } @@ -95,7 +94,7 @@ namespace dd4hep { } template - DigiHandle::DigiHandle(const DigiKernel& kernel, const string& type_name) { + DigiHandle::DigiHandle(const DigiKernel& kernel, const std::string& type_name) { value = _create_object(kernel,TypeName::split(type_name)); } @@ -124,7 +123,7 @@ namespace dd4hep { value->addRef(); } - template Property& DigiHandle::operator[](const string& property_name) const { + template Property& DigiHandle::operator[](const std::string& property_name) const { PropertyManager& pm = checked_value(value)->properties(); return pm[property_name]; } @@ -185,7 +184,7 @@ namespace dd4hep { KernelHandle::KernelHandle(DigiKernel* k) : value(k) { } - Property& KernelHandle::operator[](const string& property_name) const { + Property& KernelHandle::operator[](const std::string& property_name) const { PropertyManager& pm = checked_value(value)->properties(); return pm[property_name]; } @@ -200,6 +199,7 @@ namespace dd4hep { namespace dd4hep { /// Namespace for the Digitization part of the AIDA detector description toolkit namespace digi { + template class DigiHandle; template class DigiHandle; template class DigiHandle; diff --git a/DDDigi/src/DigiLockedAction.cpp b/DDDigi/src/DigiLockedAction.cpp index daa112fd8..6dbf68c2c 100644 --- a/DDDigi/src/DigiLockedAction.cpp +++ b/DDDigi/src/DigiLockedAction.cpp @@ -16,14 +16,11 @@ #include #include -// C/C++ include files - -using namespace std; using namespace dd4hep::digi; /// Standard constructor -DigiLockedAction::DigiLockedAction(const DigiKernel& kernel, const string& nam) +DigiLockedAction::DigiLockedAction(const DigiKernel& kernel, const std::string& nam) : DigiEventAction(kernel, nam) { InstanceCount::increment(this); diff --git a/DDDigi/src/DigiMonitorHandler.cpp b/DDDigi/src/DigiMonitorHandler.cpp index 31abb1180..1d8cf7a59 100644 --- a/DDDigi/src/DigiMonitorHandler.cpp +++ b/DDDigi/src/DigiMonitorHandler.cpp @@ -20,11 +20,10 @@ /// C/C++ include files -using namespace std; using namespace dd4hep::digi; /// Standard constructor -DigiMonitorHandler::DigiMonitorHandler(const DigiKernel& kernel, const string& nam) +DigiMonitorHandler::DigiMonitorHandler(const DigiKernel& kernel, const std::string& nam) : DigiAction(kernel, nam) { declareProperty("MonitorOutput", m_output_file); @@ -52,24 +51,24 @@ void DigiMonitorHandler::adopt(DigiAction* source, TNamed* object) { void DigiMonitorHandler::save() { if ( !m_output_file.empty() ) { TFile* output = TFile::Open(m_output_file.c_str(), - "DD4hep Digitization monitoring information", - "RECREATE"); + "DD4hep Digitization monitoring information", + "RECREATE"); TDirectory::TContext top_context(output); if ( output && !output->IsZombie() ) { for( const auto& m : m_monitors ) { - const auto* act = m.first; - const auto& items = m.second; - const auto& nam = act->name(); - std::string title = "Monitor items of digitization action "+nam; - TDirectory* direc = output->mkdir(nam.c_str(), title.c_str(), kTRUE); - TDirectory::TContext action_context(direc); - for( const auto* itm : items ) { - Int_t nbytes = direc->WriteTObject(itm); - if ( nbytes <= 0 ) { - error("+++ Failed to write object: %s -> %s", nam.c_str(), itm->GetName()); - } - } - direc->Write(); + const auto* act = m.first; + const auto& items = m.second; + const auto& nam = act->name(); + std::string title = "Monitor items of digitization action "+nam; + TDirectory* direc = output->mkdir(nam.c_str(), title.c_str(), kTRUE); + TDirectory::TContext action_context(direc); + for( const auto* itm : items ) { + Int_t nbytes = direc->WriteTObject(itm); + if ( nbytes <= 0 ) { + error("+++ Failed to write object: %s -> %s", nam.c_str(), itm->GetName()); + } + } + direc->Write(); } output->Write(); output->Close(); diff --git a/DDDigi/src/DigiSegmentation.cpp b/DDDigi/src/DigiSegmentation.cpp index cdbedb446..e59fb0af6 100644 --- a/DDDigi/src/DigiSegmentation.cpp +++ b/DDDigi/src/DigiSegmentation.cpp @@ -18,7 +18,6 @@ #include #include - std::shared_ptr dd4hep::digi::create_cell_scanner(Solid solid, Segmentation segment) { std::string typ = "DigiCellScanner" + @@ -29,7 +28,6 @@ dd4hep::digi::create_cell_scanner(Solid solid, Segmentation segment) { std::shared_ptr dd4hep::digi::create_cell_scanner(const std::string& typ, Segmentation segment) { - using namespace dd4hep; SegmentationObject* seg = segment.ptr(); DigiCellScanner* scan = PluginService::Create(typ, seg); if ( !scan ) { diff --git a/DDDigi/src/DigiSegmentationTool.cpp b/DDDigi/src/DigiSegmentationTool.cpp index b71d4ae4f..c0a01a4c6 100644 --- a/DDDigi/src/DigiSegmentationTool.cpp +++ b/DDDigi/src/DigiSegmentationTool.cpp @@ -16,16 +16,16 @@ #include #include +// C/C++ include files #include -using namespace std; using namespace dd4hep::digi; namespace { void scan_detector(const DigiSegmentationTool& tool, - const string& split_by, - map >& splits, - dd4hep::DetElement de, dd4hep::VolumeID vid, dd4hep::VolumeID mask) { + const std::string& split_by, + std::map >& splits, + dd4hep::DetElement de, dd4hep::VolumeID vid, dd4hep::VolumeID mask) { dd4hep::PlacedVolume plc = de.placement(); const auto& new_ids = plc.volIDs(); dd4hep::VolumeID new_vid = vid; @@ -34,10 +34,10 @@ namespace { new_vid |= tool.iddescriptor.encode(new_ids); new_msk |= tool.iddescriptor.get_mask(new_ids); for (const auto& id : new_ids) { - if ( id.first == split_by ) { - splits.emplace(new_vid, make_pair(de, id.second)); - return; - } + if ( id.first == split_by ) { + splits.emplace(new_vid, std::make_pair(de, id.second)); + return; + } } } for ( const auto& c : de.children() ) @@ -46,7 +46,7 @@ namespace { } /// Split field name -const string& DigiSegmentContext::name() const { +const std::string& DigiSegmentContext::name() const { if ( this->field ) { return this->field->name(); } @@ -74,56 +74,56 @@ DigiSegmentationTool::DigiSegmentationTool(Detector& desc) } /// Setup tool to handle a given detector of the geometry -void DigiSegmentationTool::set_detector(const string& det_name) { +void DigiSegmentationTool::set_detector(const std::string& det_name) { const char* det = det_name.c_str(); this->detector = this->description.detector(det_name); if ( !this->detector.isValid() ) { except("DigiSegmentationTool", - "FAILED: Cannot access subdetector %s from the detector description.", det); + "FAILED: Cannot access subdetector %s from the detector description.", det); } this->sensitive = this->description.sensitiveDetector(det_name); if ( !sensitive.isValid() ) { except("DigiSegmentationTool", - "FAILED: Cannot access sensitive detector for %s.", det); + "FAILED: Cannot access sensitive detector for %s.", det); } this->iddescriptor = this->sensitive.idSpec(); if ( !this->iddescriptor.isValid() ) { except("DigiSegmentationTool", - "FAILED: Cannot access ID descriptor for detector %s.", det); + "FAILED: Cannot access ID descriptor for detector %s.", det); } } /// Access the readout collection keys -vector DigiSegmentationTool::collection_names() const { +std::vector DigiSegmentationTool::collection_names() const { if ( this->sensitive.isValid() ) { Readout rd = this->sensitive.readout(); - vector names = rd.collectionNames(); + std::vector names = rd.collectionNames(); if ( names.empty() ) names.emplace_back(rd.name()); return names; } except("DigiSegmentationTool", - "+++ collection_names: Readout not valid. Is the proper detector set ?"); + "+++ collection_names: Readout not valid. Is the proper detector set ?"); return {}; } /// Access the readout collection keys -vector DigiSegmentationTool::collection_keys() const { +std::vector DigiSegmentationTool::collection_keys() const { return collection_keys(0x0); } /// Access the readout collection keys -vector DigiSegmentationTool::collection_keys(Key::mask_type mask) const { - vector keys; - vector names = collection_names(); +std::vector DigiSegmentationTool::collection_keys(Key::mask_type mask) const { + std::vector keys; + std::vector names = collection_names(); for( const auto& collection : names ) keys.emplace_back(Key(collection, mask)); return keys; } /// Access the readout collection keys -vector -DigiSegmentationTool::collection_keys(const vector& detectors) const { - vector keys; +std::vector +DigiSegmentationTool::collection_keys(const std::vector& detectors) const { + std::vector keys; for( const auto& det : detectors ) { DigiSegmentationTool tool(this->description); tool.set_detector(det); @@ -134,11 +134,11 @@ DigiSegmentationTool::collection_keys(const vector& detectors) const { } /// Access the readout collection keys -vector -DigiSegmentationTool::collection_keys(const vector& detectors, - Key::mask_type mask) const +std::vector +DigiSegmentationTool::collection_keys(const std::vector& detectors, + Key::mask_type mask) const { - vector keys; + std::vector keys; for( const auto& det : detectors ) { DigiSegmentationTool tool(this->description); tool.set_detector(det); @@ -150,7 +150,7 @@ DigiSegmentationTool::collection_keys(const vector& detectors, /// Create a split context depending on the segmentation field DigiSegmentContext -DigiSegmentationTool::split_context(const string& split_by) const { +DigiSegmentationTool::split_context(const std::string& split_by) const { DigiSegmentContext splitter; splitter.cell_mask = ~0x0UL; splitter.detector = this->detector; @@ -169,23 +169,23 @@ DigiSegmentationTool::split_context(const string& split_by) const { } splitter.cell_mask = (splitter.cell_mask << e->width()); printout(INFO,"DigiSegmentationTool", - "%-24s %-8s [%3d,%7d] width:%2d offset:%2d mask:%016lX Split:%016lX Det:%016lX Cells:%016lX", - this->iddescriptor.name(), e->name().c_str(), - e->minValue(), e->maxValue(), e->width(), e->offset(), - e->mask(), splitter.split_mask, splitter.det_mask, splitter.cell_mask); + "%-24s %-8s [%3d,%7d] width:%2d offset:%2d mask:%016lX Split:%016lX Det:%016lX Cells:%016lX", + this->iddescriptor.name(), e->name().c_str(), + e->minValue(), e->maxValue(), e->width(), e->offset(), + e->mask(), splitter.split_mask, splitter.det_mask, splitter.cell_mask); if ( splitter.field ) break; } if ( !splitter.field ) { except("DigiSegmentationTool", - "FAILED: The ID descriptor for detector %s has no field %s.", - this->detector.name(), split_by.c_str()); + "FAILED: The ID descriptor for detector %s has no field %s.", + this->detector.name(), split_by.c_str()); } return splitter; } /// Create full set of detector segments which can be split according to the context -set DigiSegmentationTool::split_segmentation(const string& split_by) const { - map > segmentation_splits; +std::set DigiSegmentationTool::split_segmentation(const std::string& split_by) const { + std::map > segmentation_splits; PlacedVolume place = this->detector.placement(); const auto& ids = place.volIDs(); VolumeID vid = this->iddescriptor.encode(ids); @@ -195,22 +195,22 @@ set DigiSegmentationTool::split_segmentation(const string& split_by) if ( !fld ) { except("DigiSegmentationTool","Field discriminator %s does not exist in ID descriptor %s", - split_by.c_str(), this->iddescriptor.name()); + split_by.c_str(), this->iddescriptor.name()); } ::scan_detector(*this, split_by, segmentation_splits, this->detector, vid, msk); - stringstream str; - set splits; + std::stringstream str; + std::set splits; for( const auto& id : segmentation_splits ) { auto val = ((id.first&fld->mask())>>fld->offset()); splits.insert(val); } for( const auto& id : splits ) { - str << setw(16) << hex << setfill(' ') << id << " "; + str << std::setw(16) << std::hex << std::setfill(' ') << id << " "; } printout(INFO,"DigiSegmentationTool", - "%-24s has %ld entries and %ld parallel entries when splitting by \"%s\"", - det, segmentation_splits.size(), splits.size(), split_by.c_str()); + "%-24s has %ld entries and %ld parallel entries when splitting by \"%s\"", + det, segmentation_splits.size(), splits.size(), split_by.c_str()); printout(INFO,"DigiSegmentationTool","%-24s --> %-12s ids: %s", - "", split_by.c_str(), str.str().c_str()); + "", split_by.c_str(), str.str().c_str()); return splits; } diff --git a/DDDigi/src/DigiSynchronize.cpp b/DDDigi/src/DigiSynchronize.cpp index 4729c818e..3c365a3e8 100644 --- a/DDDigi/src/DigiSynchronize.cpp +++ b/DDDigi/src/DigiSynchronize.cpp @@ -20,7 +20,6 @@ // C/C++ include files #include -using namespace std; using namespace dd4hep::digi; @@ -31,7 +30,7 @@ DigiParallelWorker secs = chrono::high_resolution_clock::now() - start; + std::chrono::duration secs = std::chrono::high_resolution_clock::now() - start; const DigiEvent& ev = *context.event; debug("%s+++ Event: %8d (DigiSynchronize) Parallel: %-4s %3ld actions [%8.3g sec]", ev.id(), ev.eventNumber, yes_no(m_parallel), m_actors.size(), diff --git a/DDDigi/src/noise/DigiSubdetectorSequence.cpp b/DDDigi/src/noise/DigiSubdetectorSequence.cpp index 2120f8a62..c21225b50 100644 --- a/DDDigi/src/noise/DigiSubdetectorSequence.cpp +++ b/DDDigi/src/noise/DigiSubdetectorSequence.cpp @@ -27,11 +27,10 @@ // C/C++ include files #include -using namespace std; using namespace dd4hep::digi; /// Standard constructor -DigiSubdetectorSequence::DigiSubdetectorSequence(const DigiKernel& kernel, const string& nam) +DigiSubdetectorSequence::DigiSubdetectorSequence(const DigiKernel& kernel, const std::string& nam) : DigiActionSequence(kernel, nam) { declareProperty("detector",m_detectorName); @@ -69,13 +68,13 @@ void DigiSubdetectorSequence::scan_sensitive(PlacedVolume pv, VolumeID vid, Volu Volume vol = pv.volume(); if ( vol.isSensitive() ) { Solid sol = vol.solid(); - auto key = make_pair(sol->IsA(), m_segmentation); + auto key = std::make_pair(sol->IsA(), m_segmentation); auto is = m_scanners.find(key); if ( is == m_scanners.end() ) { - is = m_scanners.insert(make_pair(key, create_cell_scanner(sol, m_segmentation))).first; + is = m_scanners.insert(std::make_pair(key, create_cell_scanner(sol, m_segmentation))).first; } } - for (int idau = 0, ndau = pv->GetNdaughters(); idau < ndau; ++idau) { + for ( int idau = 0, ndau = pv->GetNdaughters(); idau < ndau; ++idau ) { PlacedVolume p(pv->GetDaughter(idau)); const VolIDs& new_ids = p.volIDs(); if ( !new_ids.empty() ) { @@ -99,8 +98,8 @@ void DigiSubdetectorSequence::scan_detector(DetElement de, VolumeID vid, VolumeI for (const auto& id : new_ids) { if ( id.first == m_segmentName ) { VolumeID rid = detail::reverseBits(new_vid); - m_parallelVid.emplace(make_pair(rid, Context(de, new_vid, rid, new_msk))); - m_parallelDet.emplace(make_pair(de, new_vid)); + m_parallelVid.emplace(std::make_pair(rid, Context(de, new_vid, rid, new_msk))); + m_parallelDet.emplace(std::make_pair(de, new_vid)); scan_sensitive(de.placement(), new_vid, new_msk); return; } @@ -114,12 +113,12 @@ void DigiSubdetectorSequence::scan_detector(DetElement de, VolumeID vid, VolumeI void DigiSubdetectorSequence::process_cell(DigiContext&, const DigiCellScanner& , const DigiCellData& /* data */) const { #if 0 Segmentation seg = m_sensDet.readout().segmentation(); - string desc = m_idDesc.str(data.cell_id); - info("Sensitive: [%s/%s] vid:%s %s", - data.solid->IsA()->GetName(), - seg.type().c_str(), - volumeID(data.cell_id).c_str(), - desc.c_str()); + std::string desc = m_idDesc.str(data.cell_id); + info("Sensitive: [%s/%s] vid:%s %s", + data.solid->IsA()->GetName(), + seg.type().c_str(), + volumeID(data.cell_id).c_str(), + desc.c_str()); if ( data.cell_id ) { } #endif @@ -133,7 +132,7 @@ void DigiSubdetectorSequence::process_context(DigiContext& context, { Volume vol = pv.volume(); if ( vol.isSensitive() ) { - auto key = make_pair(vol->GetShape()->IsA(), m_segmentation); + auto key = std::make_pair(vol->GetShape()->IsA(), m_segmentation); auto is = m_scanners.find(key); if ( is == m_scanners.end() ) { except("Fatal error in process_context: Invalid cell scanner. vid: %016X",vid); @@ -157,7 +156,7 @@ void DigiSubdetectorSequence::execute(DigiContext& context) const { const Context& c = d.second; auto vid = c.detector_id; auto det = c.detector; - string id_desc = m_idDesc.str(vid); + std::string id_desc = m_idDesc.str(vid); info(" Order:%-64s vid:%s %s %s", det.path().c_str(), volumeID(d.first).c_str(), volumeID(vid).c_str(), id_desc.c_str()); process_context(context, c, c.detector.placement(), c.detector_id, c.detector_mask); @@ -168,11 +167,11 @@ void DigiSubdetectorSequence::execute(DigiContext& context) const { } /// Access subdetector from the detector description -dd4hep::DetElement DigiSubdetectorSequence::subdetector(const string& nam) const { +dd4hep::DetElement DigiSubdetectorSequence::subdetector(const std::string& nam) const { return m_kernel.detectorDescription().detector(nam); } /// Access sensitive detector from the detector description -dd4hep::SensitiveDetector DigiSubdetectorSequence::sensitiveDetector(const string& nam) const { +dd4hep::SensitiveDetector DigiSubdetectorSequence::sensitiveDetector(const std::string& nam) const { return m_kernel.detectorDescription().sensitiveDetector(nam); } diff --git a/DDDigi/src/noise/FalphaNoise.cpp b/DDDigi/src/noise/FalphaNoise.cpp index 615557999..01c564e56 100644 --- a/DDDigi/src/noise/FalphaNoise.cpp +++ b/DDDigi/src/noise/FalphaNoise.cpp @@ -19,7 +19,6 @@ #include #include -using namespace std; using namespace dd4hep::detail; #ifdef __GSL_FALPHA_NOISE diff --git a/DDDigi/test_task_queue.cpp b/DDDigi/test_task_queue.cpp index 76ae7e9a1..710ede707 100644 --- a/DDDigi/test_task_queue.cpp +++ b/DDDigi/test_task_queue.cpp @@ -12,8 +12,6 @@ //========================================================================== #include #include -using namespace tbb; -using namespace std; class say_hello { int cnt = 0; @@ -26,10 +24,9 @@ class say_hello { } }; -int main( ) -{ - task_scheduler_init init(2); - task_group tg1, tg2, tg3; +int main() { + tbb::task_scheduler_init init(2); + tbb::task_group tg1, tg2, tg3; for(int i=0; i<200; ++i) { tg1.run(std::move(say_hello("child(1)",i))); tg2.run(std::move(say_hello("child(2)",i))); diff --git a/DDEve/src/Annotation.cpp b/DDEve/src/Annotation.cpp index 2aa6565db..7974ab78c 100644 --- a/DDEve/src/Annotation.cpp +++ b/DDEve/src/Annotation.cpp @@ -12,10 +12,10 @@ //========================================================================== // Framework include files -#include "DDEve/Annotation.h" -#include "DD4hep/InstanceCount.h" -#include "TEveViewer.h" -#include "TGLViewer.h" +#include +#include +#include +#include // C/C++ include files diff --git a/DDG4/plugins/Geant4CaloSmearShowerModel.cpp b/DDG4/plugins/Geant4CaloSmearShowerModel.cpp index fa8405969..56b4415e5 100644 --- a/DDG4/plugins/Geant4CaloSmearShowerModel.cpp +++ b/DDG4/plugins/Geant4CaloSmearShowerModel.cpp @@ -24,8 +24,8 @@ #include // Geant4 include files -#include "G4SystemOfUnits.hh" -#include "G4FastStep.hh" +#include +#include /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -48,38 +48,38 @@ namespace dd4hep { double NoiseEnergyResolution { -1e0 }; double resolution(double momentum) const { - double res = -1e0; - double mom = momentum/CLHEP::GeV; - if ( this->StocasticEnergyResolution > 0 && - this->ConstantEnergyResolution > 0 && - this->NoiseEnergyResolution > 0 ) { - res = std::sqrt(std::pow( this->StocasticEnergyResolution / std::sqrt( mom ), 2 ) + // stochastic - std::pow( this->ConstantEnergyResolution, 2 ) + // constant - std::pow( this->NoiseEnergyResolution / mom, 2 ) ); // noise - } - else if ( this->StocasticEnergyResolution > 0 && - this->ConstantEnergyResolution > 0 ) { - res = std::sqrt(std::pow( this->StocasticEnergyResolution / std::sqrt( mom ), 2 ) + // stochastic - std::pow( this->ConstantEnergyResolution, 2 ) ); // constant - } - else if ( this->StocasticEnergyResolution > 0 ) { - res = this->StocasticEnergyResolution / std::sqrt( mom ); // stochastic - } - else if ( this->ConstantEnergyResolution > 0 ) { - res = this->ConstantEnergyResolution; // constant - } - return res; + double res = -1e0; + double mom = momentum/CLHEP::GeV; + if ( this->StocasticEnergyResolution > 0 && + this->ConstantEnergyResolution > 0 && + this->NoiseEnergyResolution > 0 ) { + res = std::sqrt(std::pow( this->StocasticEnergyResolution / std::sqrt( mom ), 2 ) + // stochastic + std::pow( this->ConstantEnergyResolution, 2 ) + // constant + std::pow( this->NoiseEnergyResolution / mom, 2 ) ); // noise + } + else if ( this->StocasticEnergyResolution > 0 && + this->ConstantEnergyResolution > 0 ) { + res = std::sqrt(std::pow( this->StocasticEnergyResolution / std::sqrt( mom ), 2 ) + // stochastic + std::pow( this->ConstantEnergyResolution, 2 ) ); // constant + } + else if ( this->StocasticEnergyResolution > 0 ) { + res = this->StocasticEnergyResolution / std::sqrt( mom ); // stochastic + } + else if ( this->ConstantEnergyResolution > 0 ) { + res = this->ConstantEnergyResolution; // constant + } + return res; } double smearEnergy(double mom) const { - double resolution = this->resolution(mom); - double smeared = mom; - if ( resolution > 0e0 ) { - for( smeared = -1e0; smeared < 0e0; ) { // Ensure that the resulting value is not negative - smeared = mom * Geant4Random::instance()->gauss(1e0, resolution); - } - } - return smeared; + double resolution = this->resolution(mom); + double smeared = mom; + if ( resolution > 0e0 ) { + for( smeared = -1e0; smeared < 0e0; ) { // Ensure that the resulting value is not negative + smeared = mom * Geant4Random::instance()->gauss(1e0, resolution); + } + } + return smeared; } }; @@ -113,7 +113,7 @@ namespace dd4hep { // Consider only primary tracks and smear according to the parametrized resolution // ELSE: simply set the value of the (initial) energy of the particle is deposited in the step if ( !spot.primary->GetParentID() ) { - deposit = locals.smearEnergy(deposit); + deposit = locals.smearEnergy(deposit); } hit.SetEnergy(deposit); step.ProposeTotalEnergyDeposited(deposit); diff --git a/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp b/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp index e4f870f54..b81de1075 100644 --- a/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp +++ b/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp @@ -126,13 +126,11 @@ namespace dd4hep { #include -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; DECLARE_GEANT4ACTION(Geant4DetectorGeometryConstruction) /// Initializing constructor for other clients -Geant4DetectorGeometryConstruction::Geant4DetectorGeometryConstruction(Geant4Context* ctxt, const string& nam) +Geant4DetectorGeometryConstruction::Geant4DetectorGeometryConstruction(Geant4Context* ctxt, const std::string& nam) : Geant4DetectorConstruction(ctxt,nam) { declareProperty("DebugMaterials", m_debugMaterials); @@ -194,9 +192,9 @@ void Geant4DetectorGeometryConstruction::constructGeo(Geant4DetectorConstruction enableUI(); } -pair +std::pair Geant4DetectorGeometryConstruction::resolve_path(const char* vol_path) const { - string p = vol_path; + std::string p = vol_path; Detector& det = context()->kernel().detectorDescription(); PlacedVolume top = det.world().placement(); PlacedVolume pv = detail::tools::findNode(top, p); @@ -217,19 +215,19 @@ int Geant4DetectorGeometryConstruction::printMaterial(const char* mat_name) { for ( auto it = g4map.begin(); it != g4map.end(); ++it ) { const auto* mat = (*it).second; if ( mat->GetName() == mat_name ) { - stringstream output; + std::stringstream output; const auto* ion = mat->GetIonisation(); printP2("+++ Dump of GEANT4 material: %s", mat_name); output << mat; if ( ion ) { output << " MEE: "; - output << setprecision(12); + output << std::setprecision(12); output << ion->GetMeanExcitationEnergy()/CLHEP::eV; output << " [eV]"; } else output << " MEE: UNKNOWN"; - always("+++ printMaterial: \n%s\n", output.str().c_str()); + always("+++ printMaterial: \n%s\n", output.str().c_str()); return 1; } } @@ -254,51 +252,51 @@ int Geant4DetectorGeometryConstruction::printVolumeObj(const char* vol_path, Pla const auto* ion = mat->GetIonisation(); Solid sh = pv.volume().solid(); if ( flg ) { - printP2("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); - printP2("+++ Dump of GEANT4 solid: %s", vol_path); + printP2("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); + printP2("+++ Dump of GEANT4 solid: %s", vol_path); } - stringstream output; + std::stringstream output; if ( flg ) { - output << mat; - if ( ion ) { - output << " MEE: "; - output << setprecision(12); - output << ion->GetMeanExcitationEnergy()/CLHEP::eV; - output << " [eV]"; - } - else - output << " MEE: UNKNOWN"; + output << mat; + if ( ion ) { + output << " MEE: "; + output << std::setprecision(12); + output << ion->GetMeanExcitationEnergy()/CLHEP::eV; + output << " [eV]"; + } + else + output << " MEE: UNKNOWN"; } if ( flg ) { - output << endl << *sol; - printP2("%s", output.str().c_str()); - printP2("+++ Dump of ROOT solid: %s", vol_path); - sh->InspectShape(); - if ( sh->IsA() == TGeoScaledShape::Class() ) { - TGeoScaledShape* scaled = (TGeoScaledShape*)sh.ptr(); - const Double_t* scale = scaled->GetScale()->GetScale(); - double dot = scale[0]*scale[1]*scale[2]; - printP2("+++ TGeoScaledShape: %8.3g %8.3g %8.3g [%s]", scale[0], scale[1], scale[2], - dot > 0e0 ? "RIGHT handed" : "LEFT handed"); - } - else if ( pit != g4map.g4Placements.end() ) { - const G4VPhysicalVolume* pl = (*pit).second; - const G4RotationMatrix* rot = pl->GetRotation(); - const G4ThreeVector& tr = pl->GetTranslation(); - G4Transform3D transform(rot ? *rot : G4RotationMatrix(), tr); - HepGeom::Scale3D sc; - HepGeom::Rotate3D rr; - G4Translate3D tt; - transform.getDecomposition(sc,rr,tt); - double dot = sc(0,0)*sc(1,1)*sc(2,2); - printP2("+++ TGeoShape: %8.3g %8.3g %8.3g [%s]", sc(0,0), sc(1,1), sc(2,2), - dot > 0e0 ? "RIGHT handed" : "LEFT handed"); - } - const TGeoMatrix* matrix = pv->GetMatrix(); - printP2("+++ TGeoMatrix: %s", - matrix->TestBit(TGeoMatrix::kGeoReflection) ? "LEFT handed" : "RIGHT handed"); - printP2("+++ Shape: %s cubic volume: %8.3g mm^3 area: %8.3g mm^2", - sol->GetName().c_str(), sol->GetCubicVolume(), sol->GetSurfaceArea()); + output << std::endl << *sol; + printP2("%s", output.str().c_str()); + printP2("+++ Dump of ROOT solid: %s", vol_path); + sh->InspectShape(); + if ( sh->IsA() == TGeoScaledShape::Class() ) { + TGeoScaledShape* scaled = (TGeoScaledShape*)sh.ptr(); + const Double_t* scale = scaled->GetScale()->GetScale(); + double dot = scale[0]*scale[1]*scale[2]; + printP2("+++ TGeoScaledShape: %8.3g %8.3g %8.3g [%s]", scale[0], scale[1], scale[2], + dot > 0e0 ? "RIGHT handed" : "LEFT handed"); + } + else if ( pit != g4map.g4Placements.end() ) { + const G4VPhysicalVolume* pl = (*pit).second; + const G4RotationMatrix* rot = pl->GetRotation(); + const G4ThreeVector& tr = pl->GetTranslation(); + G4Transform3D transform(rot ? *rot : G4RotationMatrix(), tr); + HepGeom::Scale3D sc; + HepGeom::Rotate3D rr; + G4Translate3D tt; + transform.getDecomposition(sc,rr,tt); + double dot = sc(0,0)*sc(1,1)*sc(2,2); + printP2("+++ TGeoShape: %8.3g %8.3g %8.3g [%s]", sc(0,0), sc(1,1), sc(2,2), + dot > 0e0 ? "RIGHT handed" : "LEFT handed"); + } + const TGeoMatrix* matrix = pv->GetMatrix(); + printP2("+++ TGeoMatrix: %s", + matrix->TestBit(TGeoMatrix::kGeoReflection) ? "LEFT handed" : "RIGHT handed"); + printP2("+++ Shape: %s cubic volume: %8.3g mm^3 area: %8.3g mm^2", + sol->GetName().c_str(), sol->GetCubicVolume(), sol->GetSurfaceArea()); } return 1; } @@ -309,7 +307,7 @@ int Geant4DetectorGeometryConstruction::printVolumeObj(const char* vol_path, Pla warning("+++ printVolume: volume %s is an assembly...need to resolve imprint",vol_path); for(Int_t i=0; i < v->GetNdaughters(); ++i) { TGeoNode* dau_nod = v->GetNode(i); - string p = vol_path + string("/") + dau_nod->GetName(); + std::string p = vol_path + std::string("/") + dau_nod->GetName(); printVolumeObj(p.c_str(), dau_nod, flg); } return 0; @@ -340,13 +338,13 @@ int Geant4DetectorGeometryConstruction::printVolumeTree(const char* vol_path) { auto [p, pv] = resolve_path(vol_path); if ( pv.isValid() ) { if ( printVolumeObj(p.c_str(), pv, ~0x0) ) { - TGeoVolume* vol = pv->GetVolume(); - for(Int_t i=0; i < vol->GetNdaughters(); ++i) { - PlacedVolume dau_pv(vol->GetNode(i)); - string path = (p + "/") + dau_pv.name(); - if ( printVolumeTree(path.c_str()) ) { - } - } + TGeoVolume* vol = pv->GetVolume(); + for(Int_t i=0; i < vol->GetNdaughters(); ++i) { + PlacedVolume dau_pv(vol->GetNode(i)); + std::string path = (p + "/") + dau_pv.name(); + if ( printVolumeTree(path.c_str()) ) { + } + } } return 1; } @@ -360,13 +358,13 @@ int Geant4DetectorGeometryConstruction::printVolTree(const char* vol_path) { auto [p, pv] = resolve_path(vol_path); if ( pv.isValid() ) { if ( printVolumeObj(p.c_str(), pv, 0) ) { - TGeoVolume* vol = pv->GetVolume(); - for(Int_t i=0; i < vol->GetNdaughters(); ++i) { - PlacedVolume dau_pv(vol->GetNode(i)); - string path = (p + "/") + dau_pv.name(); - if ( printVolTree(path.c_str()) ) { - } - } + TGeoVolume* vol = pv->GetVolume(); + for(Int_t i=0; i < vol->GetNdaughters(); ++i) { + PlacedVolume dau_pv(vol->GetNode(i)); + std::string path = (p + "/") + dau_pv.name(); + if ( printVolTree(path.c_str()) ) { + } + } } return 1; } @@ -437,8 +435,8 @@ int Geant4DetectorGeometryConstruction::writeGDML(const char* output) { return 0; } -void Geant4DetectorGeometryConstruction::printG4(const string& prefix, const G4VPhysicalVolume* g4pv) const { - string path = prefix + "/"; +void Geant4DetectorGeometryConstruction::printG4(const std::string& prefix, const G4VPhysicalVolume* g4pv) const { + std::string path = prefix + "/"; printP2( "+++ GEANT4 volume: %s", prefix.c_str()); auto* g4v = g4pv->GetLogicalVolume(); for(size_t i=0, n=g4v->GetNoDaughters(); i /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -46,31 +46,29 @@ namespace dd4hep { // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Plugins.h" -#include "DD4hep/Detector.h" +#include +#include +#include +#include -#include "DDG4/Geant4Mapping.h" -#include "DDG4/Geant4Kernel.h" -#include "DDG4/Factories.h" +#include +#include +#include // ROOT include files -#include "TGeoManager.h" +#include // Geant4 include files -#include "G4SDManager.hh" -#include "G4PVPlacement.hh" -#include "G4VSensitiveDetector.hh" +#include +#include +#include -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; DECLARE_GEANT4ACTION(Geant4DetectorSensitivesConstruction) /// Initializing constructor for other clients -Geant4DetectorSensitivesConstruction::Geant4DetectorSensitivesConstruction(Geant4Context* ctxt, const string& nam) - : Geant4DetectorConstruction(ctxt,nam) +Geant4DetectorSensitivesConstruction::Geant4DetectorSensitivesConstruction(Geant4Context* ctxt, const std::string& nam) +: Geant4DetectorConstruction(ctxt,nam) { InstanceCount::increment(this); } @@ -84,13 +82,13 @@ Geant4DetectorSensitivesConstruction::~Geant4DetectorSensitivesConstruction() { void Geant4DetectorSensitivesConstruction::constructSensitives(Geant4DetectorConstructionContext* ctxt) { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); const Geant4Kernel& kernel = context()->kernel(); - const auto& types = kernel.sensitiveDetectorTypes(); - const string& dflt = kernel.defaultSensitiveDetectorType(); - for(const auto& iv : p->sensitives ) { + const auto& types = kernel.sensitiveDetectorTypes(); + const std::string& dflt = kernel.defaultSensitiveDetectorType(); + for( const auto& iv : p->sensitives ) { SensitiveDetector sd = iv.first; - string nam = sd.name(); - auto iter = types.find(nam); - string typ = (iter != types.end()) ? (*iter).second : dflt; + std::string nam = sd.name(); + auto iter = types.find(nam); + std::string typ = (iter != types.end()) ? (*iter).second : dflt; G4VSensitiveDetector* g4sd = PluginService::Create(typ, nam, &ctxt->description); if (g4sd) { @@ -101,9 +99,9 @@ void Geant4DetectorSensitivesConstruction::constructSensitives(Geant4DetectorCon PluginDebug dbg; g4sd = PluginService::Create(typ, nam, &ctxt->description); if ( !g4sd ) { - throw runtime_error("ConstructSDandField: FATAL Failed to " - "create Geant4 sensitive detector " + nam + - " (" + sd.type() + ") of type " + typ + "."); + throw std::runtime_error("ConstructSDandField: FATAL Failed to " + "create Geant4 sensitive detector " + nam + + " (" + sd.type() + ") of type " + typ + "."); } print("Geant4SDConstruction", "+++ Subdetector: %-32s type: %-16s factory: %s.", nam.c_str(), sd.type().c_str(), typ.c_str()); @@ -113,8 +111,8 @@ void Geant4DetectorSensitivesConstruction::constructSensitives(Geant4DetectorCon for(const TGeoVolume* vol : iv.second ) { G4LogicalVolume* g4v = p->g4Volumes[vol]; if ( !g4v ) { - throw runtime_error("ConstructSDandField: Failed to access G4LogicalVolume for SD "+ - nam + " of type " + typ + "."); + throw std::runtime_error("ConstructSDandField: Failed to access G4LogicalVolume for SD "+ + nam + " of type " + typ + "."); } ctxt->setSensitiveDetector(g4v,g4sd); } diff --git a/DDG4/plugins/Geant4EscapeCounter.cpp b/DDG4/plugins/Geant4EscapeCounter.cpp index 13b573ac1..283c5c7a0 100644 --- a/DDG4/plugins/Geant4EscapeCounter.cpp +++ b/DDG4/plugins/Geant4EscapeCounter.cpp @@ -14,9 +14,9 @@ #define DD4HEP_DDG4_GEANT4ESCAPECOUNTER_H // Framework include files -#include "DD4hep/DetElement.h" -#include "DDG4/Geant4SensDetAction.h" -#include "DDG4/Geant4SteppingAction.h" +#include +#include +#include /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -63,27 +63,26 @@ namespace dd4hep { // Author : M.Frank // //==================================================================== -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" +// Framework include files +#include +#include -#include "DDG4/Geant4TouchableHandler.h" -#include "DDG4/Geant4TrackHandler.h" -#include "DDG4/Geant4StepHandler.h" -#include "DDG4/Geant4Mapping.h" -#include "DDG4/Geant4Data.h" +#include +#include +#include +#include +#include -#include "CLHEP/Units/SystemOfUnits.h" -#include "G4VProcess.hh" +#include +#include -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; /// Standard constructor -Geant4EscapeCounter::Geant4EscapeCounter(Geant4Context* ctxt, const string& nam, DetElement det, Detector& description_ref) +Geant4EscapeCounter::Geant4EscapeCounter(Geant4Context* ctxt, const std::string& nam, DetElement det, Detector& description_ref) : Geant4Sensitive(ctxt, nam, det, description_ref) { - string coll_name = name()+"Hits"; + std::string coll_name = name()+"Hits"; m_needsControl = true; declareProperty("Shells",m_detectorNames); m_collectionID = defineCollection(coll_name); @@ -100,7 +99,7 @@ bool Geant4EscapeCounter::process(const G4Step* step, G4TouchableHistory* /* his Geant4StepHandler h(step); Geant4TrackHandler th(h.track); Geant4TouchableHandler handler(step); - string hdlr_path = handler.path(); + std::string hdlr_path = handler.path(); Position prePos = h.prePos(); Position postPos = h.postPos(); Geant4HitCollection* coll = collection(m_collectionID); @@ -132,6 +131,6 @@ bool Geant4EscapeCounter::process(const G4Step* step, G4TouchableHistory* /* his return true; } -#include "DDG4/Factories.h" +#include DECLARE_GEANT4SENSITIVE(Geant4EscapeCounter) diff --git a/DDG4/plugins/Geant4EventReaderGuineaPig.cpp b/DDG4/plugins/Geant4EventReaderGuineaPig.cpp index f8ba18c53..548725d20 100644 --- a/DDG4/plugins/Geant4EventReaderGuineaPig.cpp +++ b/DDG4/plugins/Geant4EventReaderGuineaPig.cpp @@ -14,16 +14,16 @@ /** \addtogroup Geant4EventReader * @{ - \package Geant4EventReaderGuineaPig + \package Geant4EventReaderGuineaPig * \brief Reader for ascii files with e+e- pairs created from GuineaPig. * * -@} - */ + @} +*/ // Framework include files -#include "DDG4/Geant4InputAction.h" +#include // C/C++ include files #include @@ -71,15 +71,14 @@ namespace dd4hep { // Framework include files -#include "DDG4/Factories.h" -#include "DD4hep/Printout.h" -#include "CLHEP/Units/SystemOfUnits.h" -#include "CLHEP/Units/PhysicalConstants.h" +#include +#include +#include +#include // C/C++ include files #include -using namespace std; using namespace dd4hep::sim; typedef dd4hep::detail::ReferenceBitMask PropertyMask; @@ -87,15 +86,15 @@ typedef dd4hep::detail::ReferenceBitMask PropertyMask; DECLARE_GEANT4_EVENT_READER(Geant4EventReaderGuineaPig) /// Initializing constructor -Geant4EventReaderGuineaPig::Geant4EventReaderGuineaPig(const string& nam) +Geant4EventReaderGuineaPig::Geant4EventReaderGuineaPig(const std::string& nam) : Geant4EventReader(nam), m_input(), m_part_num(-1) { // Now open the input file: - m_input.open(nam.c_str(),ifstream::in); + m_input.open(nam.c_str(), std::ifstream::in); if ( !m_input.good() ) { - string err = "+++ Geant4EventReaderGuineaPig: Failed to open input stream:"+nam+ - " Error:"+string(strerror(errno)); - throw runtime_error(err); + std::string err = "+++ Geant4EventReaderGuineaPig: Failed to open input stream:"+nam+ + " Error:"+std::string(strerror(errno)); + throw std::runtime_error(err); } } @@ -145,7 +144,7 @@ Geant4EventReaderGuineaPig::moveToEvent(int event_number) { } for (unsigned i = 0; i::max(), m_input.widen('\n'))){ + if (m_input.ignore(std::numeric_limits::max(), m_input.widen('\n'))){ //just skipping the line } else @@ -162,15 +161,13 @@ Geant4EventReaderGuineaPig::moveToEvent(int event_number) { Geant4EventReader::EventReaderStatus Geant4EventReaderGuineaPig::readParticles(int /* event_number */, Vertices& vertices, - vector& particles) { + std::vector& particles) { // if no number of particles per event set, we will read the whole file if ( m_part_num < 0 ) m_part_num = std::numeric_limits::max() ; - - // First check the input file status if ( m_input.eof() ) { return EVENT_READER_EOF; @@ -212,8 +209,8 @@ Geant4EventReaderGuineaPig::readParticles(int /* event_number */, std::stringstream m_input_str( lineStr ) ; m_input_str >> Energy - >> betaX >> betaY >> betaZ - >> posX >> posY >> posZ ; + >> betaX >> betaY >> betaZ + >> posX >> posY >> posZ ; // printf(" ------- %e %e %e %e %e %e %e \n", Energy,betaX, betaY,betaZ,posX,posY,posZ ) ; diff --git a/DDG4/plugins/Geant4EventReaderHepEvt.cpp b/DDG4/plugins/Geant4EventReaderHepEvt.cpp index f1fc11701..0a821a671 100644 --- a/DDG4/plugins/Geant4EventReaderHepEvt.cpp +++ b/DDG4/plugins/Geant4EventReaderHepEvt.cpp @@ -88,9 +88,8 @@ namespace dd4hep { // C/C++ include files #include -using namespace std; using namespace dd4hep::sim; -typedef dd4hep::detail::ReferenceBitMask PropertyMask; +using PropertyMask = dd4hep::detail::ReferenceBitMask; #define HEPEvtShort 1 #define HEPEvtLong 2 @@ -100,14 +99,14 @@ namespace { class Geant4EventReaderHepEvtShort : public Geant4EventReaderHepEvt { public: /// Initializing constructor - explicit Geant4EventReaderHepEvtShort(const string& nam) : Geant4EventReaderHepEvt(nam,HEPEvtShort) {} + explicit Geant4EventReaderHepEvtShort(const std::string& nam) : Geant4EventReaderHepEvt(nam,HEPEvtShort) {} /// Default destructor virtual ~Geant4EventReaderHepEvtShort() {} }; class Geant4EventReaderHepEvtLong : public Geant4EventReaderHepEvt { public: /// Initializing constructor - explicit Geant4EventReaderHepEvtLong(const string& nam) : Geant4EventReaderHepEvt(nam,HEPEvtLong) {} + explicit Geant4EventReaderHepEvtLong(const std::string& nam) : Geant4EventReaderHepEvt(nam,HEPEvtLong) {} /// Default destructor virtual ~Geant4EventReaderHepEvtLong() {} }; @@ -120,15 +119,14 @@ DECLARE_GEANT4_EVENT_READER(Geant4EventReaderHepEvtLong) /// Initializing constructor -Geant4EventReaderHepEvt::Geant4EventReaderHepEvt(const string& nam, int format) +Geant4EventReaderHepEvt::Geant4EventReaderHepEvt(const std::string& nam, int format) : Geant4EventReader(nam), m_input(), m_format(format) { // Now open the input file: - m_input.open(nam.c_str(),ifstream::in); + m_input.open(nam.c_str(), std::ifstream::in); if ( !m_input.good() ) { - string err = "+++ Geant4EventReaderHepEvt: Failed to open input stream:"+nam+ - " Error:"+string(strerror(errno)); - throw runtime_error(err); + except("Geant4EventReaderHepEvt","+++ Failed to open input stream: %s Error:%s", + nam.c_str(), ::strerror(errno)); } } @@ -147,8 +145,8 @@ Geant4EventReaderHepEvt::moveToEvent(int event_number) { std::vector particles; Vertices vertices ; EventReaderStatus sc = readParticles(m_currEvent,vertices,particles); - for_each(vertices.begin(),vertices.end(),detail::deleteObject); - for_each(particles.begin(),particles.end(),detail::deleteObject); + for_each(vertices.begin(), vertices.end(), detail::deleteObject); + for_each(particles.begin(), particles.end(), detail::deleteObject); if ( sc != EVENT_READER_OK ) return sc; //Current event is increased in readParticles already! // ++m_currEvent; @@ -162,7 +160,7 @@ Geant4EventReaderHepEvt::moveToEvent(int event_number) { Geant4EventReader::EventReaderStatus Geant4EventReaderHepEvt::readParticles(int /* event_number */, Vertices& vertices, - vector& particles) { + std::vector& particles) { // First check the input file status @@ -208,8 +206,8 @@ Geant4EventReaderHepEvt::readParticles(int /* event_number */, double VHEP3(0); // z vertex position in mm double VHEP4(0); // production time in mm/c - vector daughter1; - vector daughter2; + std::vector daughter1; + std::vector daughter2; for( unsigned IHEP=0; IHEPparents.size() == 0 ) { Geant4Vertex* vtx = new Geant4Vertex ; diff --git a/DDG4/plugins/Geant4EventReaderHepMC.cpp b/DDG4/plugins/Geant4EventReaderHepMC.cpp index 83ee40ac7..e075df755 100644 --- a/DDG4/plugins/Geant4EventReaderHepMC.cpp +++ b/DDG4/plugins/Geant4EventReaderHepMC.cpp @@ -93,9 +93,8 @@ namespace dd4hep { #include #include -using namespace std; using namespace dd4hep::sim; -typedef dd4hep::detail::ReferenceBitMask PropertyMask; +using PropertyMask = dd4hep::detail::ReferenceBitMask; // Factory entry DECLARE_GEANT4_EVENT_READER(Geant4EventReaderHepMC) @@ -126,8 +125,8 @@ namespace dd4hep { float scale; float alpha_qcd; float alpha_qed; - vector weights; - vector random; + std::vector weights; + std::vector random; /// Default constructor EventHeader() : id(0), num_vertices(0), bp1(0), bp2(0), signal_process_id(0), signal_process_vertex(0), @@ -149,10 +148,10 @@ namespace dd4hep { typedef std::map Vertices; typedef std::map Particles; - istream& instream; + std::istream& instream; // io information - string key; + std::string key; double mom_unit, pos_unit; int io_type; @@ -162,7 +161,7 @@ namespace dd4hep { Particles m_particles; /// Default constructor - EventStream(istream& in) : instream(in), mom_unit(0.0), pos_unit(0.0), + EventStream(std::istream& in) : instream(in), mom_unit(0.0), pos_unit(0.0), io_type(0), xsection(0.0), xsection_err(0.0) { use_default_units(); } /// Check if data stream is in proper state and has data @@ -170,7 +169,7 @@ namespace dd4hep { Geant4Vertex* vertex(int i); Particles& particles() { return m_particles; } Vertices& vertices() { return m_vertices; } - void set_io(int typ, const string& k) + void set_io(int typ, const std::string& k) { io_type = typ; key = k; } void use_default_units() { mom_unit = CLHEP::MeV; pos_unit = CLHEP::mm; } @@ -178,16 +177,16 @@ namespace dd4hep { void clear(); }; - char get_input(istream& is, istringstream& iline); - int read_until_event_end(istream & is); - int read_weight_names(EventStream &, istringstream& iline); - int read_particle(EventStream &info, istringstream& iline, Geant4Particle * p); - int read_vertex(EventStream &info, istream& is, istringstream & iline); - int read_event_header(EventStream &info, istringstream & input, EventHeader& header); - int read_cross_section(EventStream &info, istringstream & input); - int read_units(EventStream &info, istringstream & input); - int read_heavy_ion(EventStream &, istringstream & input); - int read_pdf(EventStream &, istringstream & input); + char get_input(std::istream& is, std::istringstream& iline); + int read_until_event_end(std::istream & is); + int read_weight_names(EventStream &, std::istringstream& iline); + int read_particle(EventStream &info, std::istringstream& iline, Geant4Particle * p); + int read_vertex(EventStream &info, std::istream& is, std::istringstream & iline); + int read_event_header(EventStream &info, std::istringstream & input, EventHeader& header); + int read_cross_section(EventStream &info, std::istringstream & input); + int read_units(EventStream &info, std::istringstream & input); + int read_heavy_ion(EventStream &, std::istringstream & input); + int read_pdf(EventStream &, std::istringstream & input); Geant4Vertex* vertex(EventStream& info, int i); void fix_particles(EventStream &info); } @@ -199,14 +198,13 @@ namespace dd4hep { //#define DD4HEP_DEBUG_HEP_MC_PARTICLE 418 /// Initializing constructor -Geant4EventReaderHepMC::Geant4EventReaderHepMC(const string& nam) +Geant4EventReaderHepMC::Geant4EventReaderHepMC(const std::string& nam) : Geant4EventReader(nam), m_input(), m_events(0) { // Now open the input file: - m_input.open(nam.c_str(),BOOST_IOS::in|BOOST_IOS::binary); + m_input.open(nam.c_str(), BOOST_IOS::in|BOOST_IOS::binary); if ( not m_input.is_open() ) { - except("Geant4EventReaderHepMC","+++ Failed to open input stream: %s Error:%s.", - nam.c_str(), ::strerror(errno)); + except("+++ Failed to open input stream: %s Error:%s.", nam.c_str(), ::strerror(errno)); } m_events = new HepMC::EventStream(m_input); } @@ -260,7 +258,7 @@ Geant4EventReaderHepMC::readParticles(int /* ev_id */, output.reserve(parts.size()); transform(parts.begin(),parts.end(),back_inserter(output),detail::reference2nd(parts)); m_events->clear(); - if (pos.mag2() > numeric_limits::epsilon() ) { + if (pos.mag2() > std::numeric_limits::epsilon() ) { for(Particles::iterator k=output.begin(); k != output.end(); ++k) { Geant4ParticleHandle p(*k); p->vsx += pos.x(); @@ -311,7 +309,7 @@ void HepMC::fix_particles(EventStream& info) { Geant4Vertex* v = vertex(info,end_vtx_id); #if defined(DD4HEP_DEBUG_HEP_MC_VERTEX) if ( end_vtx_id == DD4HEP_DEBUG_HEP_MC_VERTEX ) { - cout << "End-vertex:" << end_vtx_id << endl; + std::cout << "End-vertex:" << end_vtx_id << std::endl; } #endif if ( v ) { @@ -323,7 +321,7 @@ void HepMC::fix_particles(EventStream& info) { EventStream::Particles::iterator ipp = parts.find(*id); Geant4Particle* dau = ipp != parts.end() ? (*ipp).second : 0; if ( !dau ) - cout << "ERROR: Invalid daughter particle: " << *id << endl; + std::cout << "ERROR: Invalid daughter particle: " << *id << std::endl; else dau->parents.insert(p->id); p->daughters.insert(*id); @@ -342,7 +340,7 @@ void HepMC::fix_particles(EventStream& info) { } /// Particles originating from the beam (=no parents) must be /// be stripped off their parents and the status set to G4PARTICLE_GEN_DECAYED! - vector beam; + std::vector beam; for(const auto& ipart : parts) { Geant4ParticleHandle p(ipart.second); if ( p->parents.size() == 0 ) { @@ -353,7 +351,7 @@ void HepMC::fix_particles(EventStream& info) { } } for(auto* ipp : beam) { - //cout << "Clear parents of " << (*ipp)->id << endl; + //std::cout << "Clear parents of " << (*ipp)->id << std::endl; ipp->parents.clear(); ipp->status = G4PARTICLE_GEN_DECAYED; } @@ -364,18 +362,18 @@ Geant4Vertex* HepMC::vertex(EventStream& info, int i) { return (it==info.vertices().end()) ? 0 : (*it).second; } -char HepMC::get_input(istream& is, istringstream& iline) { +char HepMC::get_input(std::istream& is, std::istringstream& iline) { char value = is.peek(); if ( !is ) { // make sure the stream is valid - cerr << "StreamHelpers: setting badbit." << endl; - is.clear(ios::badbit); + std::cerr << "StreamHelpers: setting badbit." << std::endl; + is.clear(std::ios::badbit); return -1; } - string line, firstc; + std::string line, firstc; getline(is,line); if ( !is ) { // make sure the stream is valid - cerr << "StreamHelpers: setting badbit." << endl; - is.clear(ios::badbit); + std::cerr << "StreamHelpers: setting badbit." << std::endl; + is.clear(std::ios::badbit); return -1; } iline.clear(); @@ -384,8 +382,8 @@ char HepMC::get_input(istream& is, istringstream& iline) { return iline ? value : -1; } -int HepMC::read_until_event_end(istream & is) { - string line; +int HepMC::read_until_event_end(std::istream & is) { + std::string line; while ( is ) { char val = is.peek(); if( val == 'E' ) { // next event @@ -397,23 +395,23 @@ int HepMC::read_until_event_end(istream & is) { return 0; } -int HepMC::read_weight_names(EventStream&, istringstream&) { +int HepMC::read_weight_names(EventStream&, std::istringstream&) { #if 0 - int HepMC::read_weight_names(EventStream& info, istringstream& iline) + int HepMC::read_weight_names(EventStream& info, std::istringstream& iline) size_t name_size = 0; iline >> name_size; info.weights.names.clear(); info.weights.weights.clear(); - string name; + std::string name; WeightContainer namedWeight; - string::size_type i1 = line.find("\""), i2, len = line.size(); + std::string::size_type i1 = line.find("\""), i2, len = line.size(); for(size_t ii = 0; ii < name_size; ++ii) { // weight names may contain blanks if(i1 >= len) { - cout << "debug: attempting to read past the end of the named weight line " << endl; - cout << "debug: We should never get here" << endl; - cout << "debug: Looking for the end of this event" << endl; + std::cout << "debug: attempting to read past the end of the named weight line " << std::endl; + std::cout << "debug: We should never get here" << std::endl; + std::cout << "debug: Looking for the end of this event" << std::endl; read_until_event_end(is); } i2 = line.find("\"",i1+1); @@ -430,7 +428,7 @@ int HepMC::read_weight_names(EventStream&, istringstream&) { return 1; } -int HepMC::read_particle(EventStream &info, istringstream& input, Geant4Particle * p) { +int HepMC::read_particle(EventStream &info, std::istringstream& input, Geant4Particle * p) { float ene = 0., theta = 0., phi = 0; int size = 0, stat=0; PropertyMask status(p->status); @@ -440,7 +438,7 @@ int HepMC::read_particle(EventStream &info, istringstream& input, Geant4Particle p->id = info.particles().size(); #if defined(DD4HEP_DEBUG_HEP_MC_PARTICLE) if ( p->id == DD4HEP_DEBUG_HEP_MC_PARTICLE ) { - cout << "Particle id: " << p->id << endl; + std::cout << "Particle id: " << p->id << std::endl; } #endif p->charge = 0; @@ -481,7 +479,7 @@ int HepMC::read_particle(EventStream &info, istringstream& input, Geant4Particle p->genStatus = stat&G4PARTICLE_GEN_STATUS_MASK; // read flow patterns if any exist. Protect against tainted readings. - size = min(size,100); + size = std::min(size,100); for (int i = 0; i < size; ++i ) { input >> p->colorFlow[0] >> p->colorFlow[1]; if(!input) return 0; @@ -489,9 +487,9 @@ int HepMC::read_particle(EventStream &info, istringstream& input, Geant4Particle return 1; } -int HepMC::read_vertex(EventStream &info, istream& is, istringstream & input) { +int HepMC::read_vertex(EventStream &info, std::istream& is, std::istringstream & input) { int id=0, dummy = 0, num_orphans_in=0, num_particles_out=0, weights_size=0; - vector weights; + std::vector weights; Geant4Vertex* v = new Geant4Vertex(); Geant4Particle* p; @@ -561,13 +559,13 @@ int HepMC::read_vertex(EventStream &info, istream& is, istringstream & input) } else { delete p; - throw runtime_error("Invalid number of particles...."); + except("HepMC", "Invalid number of particles...."); } } return 1; } -int HepMC::read_event_header(EventStream &info, istringstream & input, EventHeader& header) { +int HepMC::read_event_header(EventStream &info, std::istringstream & input, EventHeader& header) { // read values into temp variables, then fill GenEvent int random_states_size = 0; input >> header.id; @@ -599,7 +597,7 @@ int HepMC::read_event_header(EventStream &info, istringstream & input, EventHead input >> weights_size; if( input.fail() ) return 0; - vector wgt(weights_size); + std::vector wgt(weights_size); for(size_t ii = 0; ii < weights_size; ++ii ) input >> wgt[ii]; if( input.fail() ) return 0; @@ -609,14 +607,14 @@ int HepMC::read_event_header(EventStream &info, istringstream & input, EventHead return 1; } -int HepMC::read_cross_section(EventStream &info, istringstream & input) { +int HepMC::read_cross_section(EventStream &info, std::istringstream & input) { input >> info.xsection >> info.xsection_err; return input.fail() ? 0 : 1; } -int HepMC::read_units(EventStream &info, istringstream & input) { +int HepMC::read_units(EventStream &info, std::istringstream & input) { if( info.io_type == gen ) { - string mom, pos; + std::string mom, pos; input >> mom >> pos; if ( !input.fail() ) { if ( mom == "KEV" ) info.mom_unit = CLHEP::keV; @@ -632,7 +630,7 @@ int HepMC::read_units(EventStream &info, istringstream & input) { return input.fail() ? 0 : 1; } -int HepMC::read_heavy_ion(EventStream &, istringstream & input) { +int HepMC::read_heavy_ion(EventStream &, std::istringstream & input) { // read values into temp variables, then create a new HeavyIon object int nh =0, np =0, nt =0, nc =0, neut = 0, prot = 0, nw =0, nwn =0, nwnw =0; @@ -640,7 +638,7 @@ int HepMC::read_heavy_ion(EventStream &, istringstream & input) { input >> nh >> np >> nt >> nc >> neut >> prot >> nw >> nwn >> nwnw; input >> impact >> plane >> xcen >> inel; /* - cerr << "Reading heavy ion, but igoring data!" << endl; + std::cerr << "Reading heavy ion, but igoring data!" << std::endl; ion->set_Ncoll_hard(nh); ion->set_Npart_proj(np); ion->set_Npart_targ(nt); @@ -658,7 +656,7 @@ int HepMC::read_heavy_ion(EventStream &, istringstream & input) { return input.fail() ? 0 : 1; } -int HepMC::read_pdf(EventStream &, istringstream & input) { +int HepMC::read_pdf(EventStream &, std::istringstream & input) { // read values into temp variables, then create a new PdfInfo object int id1 =0, id2 =0; double x1 = 0., x2 = 0., scale = 0., pdf1 = 0., pdf2 = 0.; @@ -673,7 +671,7 @@ int HepMC::read_pdf(EventStream &, istringstream & input) { if ( input.fail() ) return 0; /* - cerr << "Reading pdf, but igoring data!" << endl; + std::cerr << "Reading pdf, but igoring data!" << std::endl; pdf->set_id1( id1 ); pdf->set_id2( id2 ); pdf->set_x1( x1 ); @@ -698,7 +696,7 @@ int HepMC::read_pdf(EventStream &, istringstream & input) { bool HepMC::EventStream::ok() const { // make sure the stream is good if ( instream.eof() || instream.fail() ) { - instream.clear(ios::badbit); + instream.clear(std::ios::badbit); return false; } return true; @@ -721,7 +719,7 @@ bool HepMC::EventStream::read() { ++num_evt; while( instream.good() ) { char value = instream.peek(); - istringstream input_line; + std::istringstream input_line; ++num_line; if ( value == 'E' && event_read ) break; @@ -743,7 +741,7 @@ bool HepMC::EventStream::read() { switch( value ) { case 'H': { int iotype = 0; - string key_value; + std::string key_value; input_line >> key_value; // search for event listing key before first event only. key_value = key_value.substr(0,key_value.find('\r')); @@ -773,9 +771,9 @@ bool HepMC::EventStream::read() { iotype = extascii_pdt; if( iotype != 0 && this->io_type != iotype ) { - cerr << "GenEvent::find_end_key: iotype keys have changed. " - << "MALFORMED INPUT" << endl; - instream.clear(ios::badbit); + std::cerr << "GenEvent::find_end_key: iotype keys have changed. " + << "MALFORMED INPUT" << std::endl; + instream.clear(std::ios::badbit); return false; } else if ( iotype != 0 ) { @@ -815,7 +813,7 @@ bool HepMC::EventStream::read() { continue; case 'P': // we should not find this line - cerr << "streaming input: found unexpected Particle line." << endl; + std::cerr << "streaming input: found unexpected Particle line." << std::endl; continue; default: // ignore everything else diff --git a/DDG4/plugins/Geant4FastPhysics.cpp b/DDG4/plugins/Geant4FastPhysics.cpp index 9e59a52e0..e083c5390 100644 --- a/DDG4/plugins/Geant4FastPhysics.cpp +++ b/DDG4/plugins/Geant4FastPhysics.cpp @@ -87,7 +87,6 @@ namespace dd4hep { // Geant4 include files #include -using namespace dd4hep; using namespace dd4hep::sim; /// Standard constructor diff --git a/DDG4/plugins/Geant4FastSimShowerModel.cpp b/DDG4/plugins/Geant4FastSimShowerModel.cpp index d676f63bb..4c74063e5 100644 --- a/DDG4/plugins/Geant4FastSimShowerModel.cpp +++ b/DDG4/plugins/Geant4FastSimShowerModel.cpp @@ -14,8 +14,7 @@ // Framework include files #include -using namespace dd4hep; -using namespace dd4hep::sim; +using dd4hep::sim::Geant4FastSimShowerModel; #include DECLARE_GEANT4ACTION(Geant4FastSimShowerModel) diff --git a/DDG4/plugins/Geant4FieldTrackingSetup.cpp b/DDG4/plugins/Geant4FieldTrackingSetup.cpp index 0c153099a..b43a85bb1 100644 --- a/DDG4/plugins/Geant4FieldTrackingSetup.cpp +++ b/DDG4/plugins/Geant4FieldTrackingSetup.cpp @@ -147,28 +147,26 @@ namespace dd4hep { #include #include -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; /// Local declaration in anonymous namespace namespace { struct Geant4SetupPropertyMap { - const map& vals; - Geant4SetupPropertyMap(const map& v) : vals(v) {} - string value(const string& key) const; - double toDouble(const string& key) const; - bool operator[](const string& key) const { return vals.find(key) != vals.end(); } + const std::map& vals; + Geant4SetupPropertyMap(const std::map& v) : vals(v) {} + std::string value(const std::string& key) const; + double toDouble(const std::string& key) const; + bool operator[](const std::string& key) const { return vals.find(key) != vals.end(); } }; - string Geant4SetupPropertyMap::value(const string& key) const { - Detector::PropertyValues::const_iterator iV = vals.find(key); + std::string Geant4SetupPropertyMap::value(const std::string& key) const { + dd4hep::Detector::PropertyValues::const_iterator iV = vals.find(key); return iV == vals.end() ? "" : (*iV).second; } - double Geant4SetupPropertyMap::toDouble(const string& key) const { - return _toDouble(this->value(key)); + double Geant4SetupPropertyMap::toDouble(const std::string& key) const { + return dd4hep::_toDouble(this->value(key)); } } @@ -238,14 +236,17 @@ int Geant4FieldTrackingSetup::execute(Detector& description) { return 1; } -static long setup_fields(Detector& description, const dd4hep::detail::GeoHandler& /* cnv */, const map& vals) { +static long setup_fields(dd4hep::Detector& description, + const dd4hep::detail::GeoHandler& /* cnv */, + const std::map& vals) +{ struct XMLFieldTrackingSetup : public Geant4FieldTrackingSetup { - XMLFieldTrackingSetup(const map& values) : Geant4FieldTrackingSetup() { + XMLFieldTrackingSetup(const std::map& values) : Geant4FieldTrackingSetup() { Geant4SetupPropertyMap pm(values); - Detector::PropertyValues::const_iterator iV = values.find("min_chord_step"); + dd4hep::Detector::PropertyValues::const_iterator iV = values.find("min_chord_step"); eq_typ = pm.value("equation"); stepper_typ = pm.value("stepper"); - min_chord_step = _toDouble((iV==values.end()) ? string("1e-2 * mm") : (*iV).second); + min_chord_step = dd4hep::_toDouble((iV==values.end()) ? std::string("1e-2 * mm") : (*iV).second); if ( pm["eps_min"] ) eps_min = pm.toDouble("eps_min"); if ( pm["eps_max"] ) eps_max = pm.toDouble("eps_max"); if ( pm["delta_chord"] ) delta_chord = pm.toDouble("delta_chord"); diff --git a/DDG4/plugins/Geant4GDMLWriteAction.cpp b/DDG4/plugins/Geant4GDMLWriteAction.cpp index 0696f24ce..69d2382d5 100644 --- a/DDG4/plugins/Geant4GDMLWriteAction.cpp +++ b/DDG4/plugins/Geant4GDMLWriteAction.cpp @@ -100,12 +100,10 @@ namespace dd4hep { #include #include -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; /// Standard constructor -Geant4GDMLWriteAction::Geant4GDMLWriteAction(Geant4Context* ctxt, const string& nam) +Geant4GDMLWriteAction::Geant4GDMLWriteAction(Geant4Context* ctxt, const std::string& nam) : Geant4Action(ctxt, nam) { m_needsControl = true; @@ -130,7 +128,7 @@ void Geant4GDMLWriteAction::installCommandMessenger() { /// Write geometry to GDML void Geant4GDMLWriteAction::writeGDML() { - string fname = m_output; + std::string fname = m_output; struct stat buff; if ( fname.empty() ) { error("+++ No GDML file name given. Please set the output file (property Output)"); @@ -148,7 +146,7 @@ void Geant4GDMLWriteAction::writeGDML() { #ifdef GEANT4_NO_GDML warning("+++ writeGDML: GDML not found in the present Geant4 build! Output: %s not written", fname.c_str()); #else - unique_ptr parser(new G4GDMLParser()); + std::unique_ptr parser(new G4GDMLParser()); parser->SetRegionExport(m_exportRegions != 0); parser->SetEnergyCutsExport(m_exportEnergyCuts != 0); #if G4VERSION_NUMBER>=1030 diff --git a/DDG4/plugins/Geant4GFlashShowerModel.cpp b/DDG4/plugins/Geant4GFlashShowerModel.cpp index 2ec874852..711be5109 100644 --- a/DDG4/plugins/Geant4GFlashShowerModel.cpp +++ b/DDG4/plugins/Geant4GFlashShowerModel.cpp @@ -123,7 +123,6 @@ namespace dd4hep { // C/C++ include files #include -using namespace dd4hep; using namespace dd4hep::sim; /// Standard constructor diff --git a/DDG4/plugins/Geant4GeometryScanner.cpp b/DDG4/plugins/Geant4GeometryScanner.cpp index 717de5f80..48f1cdb24 100644 --- a/DDG4/plugins/Geant4GeometryScanner.cpp +++ b/DDG4/plugins/Geant4GeometryScanner.cpp @@ -96,7 +96,6 @@ namespace dd4hep { #include #include -using namespace std; using namespace dd4hep::sim; #include @@ -106,7 +105,7 @@ DECLARE_GEANT4ACTION(Geant4GeometryScanner) Geant4GeometryScanner::StepInfo::StepInfo(const Position& prePos, const Position& postPos, const G4LogicalVolume* vol, - const string& p) + const std::string& p) : pre(prePos), post(postPos), path(p), volume(vol) { } @@ -126,7 +125,7 @@ Geant4GeometryScanner::StepInfo& Geant4GeometryScanner::StepInfo::operator=(cons } /// Standard constructor -Geant4GeometryScanner::Geant4GeometryScanner(Geant4Context* ctxt, const string& nam) +Geant4GeometryScanner::Geant4GeometryScanner(Geant4Context* ctxt, const std::string& nam) : Geant4SteppingAction(ctxt,nam) { m_needsControl = true; diff --git a/DDG4/plugins/Geant4HitDumpAction.cpp b/DDG4/plugins/Geant4HitDumpAction.cpp index 507e710ce..4e2621275 100644 --- a/DDG4/plugins/Geant4HitDumpAction.cpp +++ b/DDG4/plugins/Geant4HitDumpAction.cpp @@ -83,12 +83,10 @@ namespace dd4hep { #include #include -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; /// Standard constructor -Geant4HitDumpAction::Geant4HitDumpAction(Geant4Context* ctxt, const string& nam) +Geant4HitDumpAction::Geant4HitDumpAction(Geant4Context* ctxt, const std::string& nam) : Geant4EventAction(ctxt, nam), m_containers{"*"} { m_needsControl = true; @@ -108,7 +106,7 @@ void Geant4HitDumpAction::begin(const G4Event* /* event */) { /// Dump single container of hits void Geant4HitDumpAction::dumpCollection(G4VHitsCollection* collection) { Geant4HitCollection* coll = dynamic_cast(collection); - string nam = collection->GetName(); + std::string nam = collection->GetName(); if ( coll ) { Geant4DataDump::CalorimeterHits cal_hits; Geant4DataDump::TrackerHits trk_hits; diff --git a/DDG4/plugins/Geant4HitExtractor.cpp b/DDG4/plugins/Geant4HitExtractor.cpp index 4bdb77376..2aa069f3b 100644 --- a/DDG4/plugins/Geant4HitExtractor.cpp +++ b/DDG4/plugins/Geant4HitExtractor.cpp @@ -14,7 +14,6 @@ // Framework include files #include "DDG4/Geant4Data.h" -using namespace dd4hep; using namespace dd4hep::sim; /// Namespace for the AIDA detector description toolkit diff --git a/DDG4/plugins/Geant4HitTruthHandler.cpp b/DDG4/plugins/Geant4HitTruthHandler.cpp index f7d51ddec..a246a296f 100644 --- a/DDG4/plugins/Geant4HitTruthHandler.cpp +++ b/DDG4/plugins/Geant4HitTruthHandler.cpp @@ -14,7 +14,7 @@ #define DD4HEP_DDG4_GEANT4HITTRUTHHANDLER_H // Framework include files -#include "DDG4/Geant4EventAction.h" +#include // Forward declarations class G4VHitsCollection; @@ -72,20 +72,18 @@ namespace dd4hep { //==================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4DataDump.h" -#include "DDG4/Geant4HitCollection.h" +#include +#include +#include // Geant 4 includes -#include "G4HCofThisEvent.hh" -#include "G4Event.hh" +#include +#include -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; /// Standard constructor -Geant4HitTruthHandler::Geant4HitTruthHandler(Geant4Context* ctxt, const string& nam) +Geant4HitTruthHandler::Geant4HitTruthHandler(Geant4Context* ctxt, const std::string& nam) : Geant4EventAction(ctxt, nam) { m_needsControl = true; @@ -152,6 +150,6 @@ void Geant4HitTruthHandler::end(const G4Event* event) { event->GetEventID()); } -#include "DDG4/Factories.h" +#include DECLARE_GEANT4ACTION(Geant4HitTruthHandler) diff --git a/DDG4/plugins/Geant4MaterialScanner.cpp b/DDG4/plugins/Geant4MaterialScanner.cpp index 76efe6a9f..56b6859f9 100644 --- a/DDG4/plugins/Geant4MaterialScanner.cpp +++ b/DDG4/plugins/Geant4MaterialScanner.cpp @@ -12,9 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/Objects.h" -#include "DDG4/Defs.h" -#include "DDG4/Geant4SteppingAction.h" +#include +#include +#include // Forward declarations class G4LogicalVolume; @@ -84,20 +84,19 @@ namespace dd4hep { //==================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DD4hep/Printout.h" -#include "DDG4/Geant4TouchableHandler.h" -#include "DDG4/Geant4StepHandler.h" -#include "DDG4/Geant4EventAction.h" -#include "DDG4/Geant4TrackingAction.h" -#include "CLHEP/Units/SystemOfUnits.h" -#include "G4LogicalVolume.hh" -#include "G4Material.hh" - -using namespace std; +#include +#include +#include +#include +#include +#include +#include +#include +#include + using namespace dd4hep::sim; -#include "DDG4/Factories.h" +#include DECLARE_GEANT4ACTION(Geant4MaterialScanner) /// Initializing constructor @@ -108,7 +107,7 @@ Geant4MaterialScanner::StepInfo::StepInfo(const Position& prePos, const Position /// Copy constructor Geant4MaterialScanner::StepInfo::StepInfo(const StepInfo& c) -: pre(c.pre), post(c.post), volume(c.volume) + : pre(c.pre), post(c.post), volume(c.volume) { } @@ -121,7 +120,7 @@ Geant4MaterialScanner::StepInfo& Geant4MaterialScanner::StepInfo::operator=(cons } /// Standard constructor -Geant4MaterialScanner::Geant4MaterialScanner(Geant4Context* ctxt, const string& nam) +Geant4MaterialScanner::Geant4MaterialScanner(Geant4Context* ctxt, const std::string& nam) : Geant4SteppingAction(ctxt,nam) { m_needsControl = true; @@ -141,9 +140,9 @@ void Geant4MaterialScanner::operator()(const G4Step* step, G4SteppingManager*) { Geant4StepHandler h(step); #if 0 Geant4TouchableHandler pre_handler(step); - string prePath = pre_handler.path(); + std::string prePath = pre_handler.path(); Geant4TouchableHandler post_handler(step); - string postPath = post_handler.path(); + std::string postPath = post_handler.path(); #endif G4LogicalVolume* logVol = h.logvol(h.pre); m_steps.emplace_back(new StepInfo(h.prePos(), h.postPos(), logVol)); diff --git a/DDG4/plugins/Geant4ParticleDumpAction.cpp b/DDG4/plugins/Geant4ParticleDumpAction.cpp index 3b9c4b92d..c70f067d1 100644 --- a/DDG4/plugins/Geant4ParticleDumpAction.cpp +++ b/DDG4/plugins/Geant4ParticleDumpAction.cpp @@ -14,7 +14,7 @@ #define DD4HEP_DDG4_GEANT4PARTICLEDUMPACTION_H // Framework include files -#include "DDG4/Geant4EventAction.h" +#include // Forward declarations class G4VHitsCollection; @@ -67,20 +67,18 @@ namespace dd4hep { //==================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4DataDump.h" -#include "DDG4/Geant4HitCollection.h" +#include +#include +#include // Geant 4 includes -#include "G4HCofThisEvent.hh" -#include "G4Event.hh" +#include +#include -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; /// Standard constructor -Geant4ParticleDumpAction::Geant4ParticleDumpAction(Geant4Context* ctxt, const string& nam) +Geant4ParticleDumpAction::Geant4ParticleDumpAction(Geant4Context* ctxt, const std::string& nam) : Geant4EventAction(ctxt, nam) { m_needsControl = true; @@ -107,5 +105,5 @@ void Geant4ParticleDumpAction::end(const G4Event* event) { warning("+++ [Event:%d] No particle map available!",event->GetEventID()); } -#include "DDG4/Factories.h" +#include DECLARE_GEANT4ACTION(Geant4ParticleDumpAction) diff --git a/DDG4/plugins/Geant4ROOTDump.cpp b/DDG4/plugins/Geant4ROOTDump.cpp index d88e81468..eb12b5fb5 100644 --- a/DDG4/plugins/Geant4ROOTDump.cpp +++ b/DDG4/plugins/Geant4ROOTDump.cpp @@ -12,28 +12,21 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/Factories.h" -#include "DD4hep/Primitives.h" -#include "DDG4/Geant4DataDump.h" -#include "DDG4/Geant4Particle.h" +#include +#include +#include +#include +#include // ROOT include files -#include "TInterpreter.h" -#include "TSystem.h" -#include "TFile.h" -#include "TTree.h" -#include "TROOT.h" - -using namespace std; -using namespace dd4hep; -using namespace dd4hep::sim; - -typedef Geant4DataDump::Particles Particles; -typedef Geant4DataDump::TrackerHits TrackerHits; -typedef Geant4DataDump::CalorimeterHits CalorimeterHits; +#include +#include +#include +#include +#include static long usage() { + using namespace dd4hep; printout(FATAL,"Geant4ROOTDump","usage: Geant4ROOTDump -opt (app-opts) --opt=value (plugin-opts)"); printout(FATAL,"Geant4ROOTDump"," app-opts: "); printout(FATAL,"Geant4ROOTDump"," -print INFO Print container summaries only."); @@ -46,10 +39,10 @@ static long usage() { return 'H'; } -static pair load(TBranch* branch, int entry) { +static std::pair load(TBranch* branch, int entry) { TClass* cl = gROOT->GetClass(branch->GetClassName(),kTRUE); if ( !cl ) { - return pair(0,0); + return std::pair(0,0); } void *obj = cl->New(); branch->SetAddress(&obj); @@ -57,12 +50,13 @@ static pair load(TBranch* branch, int entry) { int nb = branch->GetEntry(entry); if ( nb < 0 ) { cl->Destructor(obj); - return pair(0,0); + return std::pair(0,0); } - return pair(cl,obj); + return std::pair(cl,obj); } -static long dump_root(Detector&, int argc, char** argv) { +static long dump_root(dd4hep::Detector&, int argc, char** argv) { + using namespace dd4hep; std::string input = "", tag="Geant4ROOTDump"; int entry = -1; @@ -76,8 +70,8 @@ static long dump_root(Detector&, int argc, char** argv) { return 1; } if ( idx > 0 ) { - string p1 = a.substr(0,idx); - string p2 = a.substr(idx+1); + std::string p1 = a.substr(0,idx); + std::string p2 = a.substr(idx+1); if ( strncmp(p1.c_str(),"input",3)==0 ) { input = p2; } @@ -101,19 +95,18 @@ static long dump_root(Detector&, int argc, char** argv) { return usage(); } - - Geant4DataDump dump("Geant4Data"); + dd4hep::sim::Geant4DataDump dump("Geant4Data"); TFile* f = TFile::Open(input.c_str()); if ( f && !f->IsZombie() ) { TTree* tree = (TTree*)f->Get("EVENT"); - TClass* cl_calo = gROOT->GetClass(typeid(CalorimeterHits)); - TClass* cl_tracker = gROOT->GetClass(typeid(TrackerHits)); - TClass* cl_particles = gROOT->GetClass(typeid(Particles)); + TClass* cl_calo = gROOT->GetClass(typeid(dd4hep::sim::Geant4DataDump::CalorimeterHits)); + TClass* cl_tracker = gROOT->GetClass(typeid(dd4hep::sim::Geant4DataDump::TrackerHits)); + TClass* cl_particles = gROOT->GetClass(typeid(dd4hep::sim::Geant4DataDump::Particles)); TObjArray* branches = tree->GetListOfBranches(); Int_t nbranches = branches->GetEntriesFast(); - typedef pair ENTRY; - typedef map ENTRIES; + typedef std::pair ENTRY; + typedef std::map ENTRIES; for(Int_t ievt=entry<0 ? 0 : entry, nevt=entry<0 ? tree->GetEntries() : entry+1; ievtUncheckedAt(i); - pair data = load(branch,ievt); + std::pair data = load(branch,ievt); if ( data.first ) event[branch->GetName()] = data; } // Now dump the stuff for(ENTRIES::const_iterator i=event.begin(); i!=event.end(); ++i) { - pair data = (*i).second; + std::pair data = (*i).second; if ( data.first == cl_particles ) { - Particles* parts = (Particles*)data.second; + auto* parts = (dd4hep::sim::Geant4DataDump::Particles*)data.second; dump.print(INFO, (*i).first, parts); - for_each(parts->begin(), parts->end(), detail::DestroyObject()); + for_each(parts->begin(), parts->end(), detail::DestroyObject()); } } for(ENTRIES::const_iterator i=event.begin(); i!=event.end(); ++i) { - pair data = (*i).second; + std::pair data = (*i).second; if ( data.first == cl_particles ) { } else if ( data.first == cl_tracker ) { - TrackerHits* hits = (TrackerHits*)data.second; + auto* hits = (dd4hep::sim::Geant4DataDump::TrackerHits*)data.second; dump.print(INFO, (*i).first, hits); - for_each(hits->begin(), hits->end(), detail::DestroyObject()); + for_each(hits->begin(), hits->end(), detail::DestroyObject()); } else if ( data.first == cl_calo ) { - CalorimeterHits* hits = (CalorimeterHits*)data.second; + auto* hits = (dd4hep::sim::Geant4DataDump::CalorimeterHits*)data.second; dump.print(INFO, (*i).first, hits); - for_each(hits->begin(), hits->end(), detail::DestroyObject()); + for_each(hits->begin(), hits->end(), detail::DestroyObject()); } if ( data.first ) data.first->Destructor(data.second); } diff --git a/DDG4/plugins/Geant4SensDetFilters.cpp b/DDG4/plugins/Geant4SensDetFilters.cpp index 9a5d2dedc..2c4e60a5e 100644 --- a/DDG4/plugins/Geant4SensDetFilters.cpp +++ b/DDG4/plugins/Geant4SensDetFilters.cpp @@ -12,8 +12,8 @@ //========================================================================== /// Framework include files -#include "DDG4/Geant4SensDetAction.h" -#include "DDG4/Geant4FastSimSpot.h" +#include +#include /// Geant4 include files @@ -51,15 +51,15 @@ namespace dd4hep { bool isGeantino(const G4Track* track) const; /// Access to the track from step const G4Track* getTrack(const G4Step* step) const { - return step->GetTrack(); + return step->GetTrack(); } /// Access to the track from step const G4Track* getTrack(const Geant4FastSimSpot* spot) const { - return spot->primary; + return spot->primary; } /// Access originator track from G4 fast track const G4Track* getTrack(const G4FastTrack* fast) const { - return fast->GetPrimaryTrack(); + return fast->GetPrimaryTrack(); } }; @@ -76,11 +76,11 @@ namespace dd4hep { virtual ~ParticleRejectFilter(); /// Filter action. Return true if hits should be processed virtual bool operator()(const G4Step* step) const override final { - return !isSameType(getTrack(step)); + return !isSameType(getTrack(step)); } /// GFlash/FastSim interface: Filter action. Return true if hits should be processed virtual bool operator()(const Geant4FastSimSpot* spot) const override final { - return !isSameType(getTrack(spot)); + return !isSameType(getTrack(spot)); } }; @@ -97,11 +97,11 @@ namespace dd4hep { virtual ~ParticleSelectFilter(); /// Filter action. Return true if hits should be processed virtual bool operator()(const G4Step* step) const override final { - return isSameType(getTrack(step)); + return isSameType(getTrack(step)); } /// GFlash/FastSim interface: Filter action. Return true if hits should be processed virtual bool operator()(const Geant4FastSimSpot* spot) const override final { - return isSameType(getTrack(spot)); + return isSameType(getTrack(spot)); } }; @@ -118,11 +118,11 @@ namespace dd4hep { virtual ~GeantinoRejectFilter(); /// Filter action. Return true if hits should be processed virtual bool operator()(const G4Step* step) const override final { - return !isGeantino(getTrack(step)); + return !isGeantino(getTrack(step)); } /// GFlash/FastSim interface: Filter action. Return true if hits should be processed virtual bool operator()(const Geant4FastSimSpot* spot) const override final { - return !isGeantino(getTrack(spot)); + return !isGeantino(getTrack(spot)); } }; @@ -142,30 +142,28 @@ namespace dd4hep { virtual ~EnergyDepositMinimumCut(); /// Filter action. Return true if hits should be processed virtual bool operator()(const G4Step* step) const override final { - return step->GetTotalEnergyDeposit() > m_energyCut; + return step->GetTotalEnergyDeposit() > m_energyCut; } /// GFlash/FastSim interface: Filter action. Return true if hits should be processed virtual bool operator()(const Geant4FastSimSpot* spot) const override final { - return spot->energy() > m_energyCut; + return spot->energy() > m_energyCut; } }; } } /// Framework include files -#include "DD4hep/InstanceCount.h" -#include "DDG4/Factories.h" +#include +#include // Geant4 include files -#include "G4ParticleTable.hh" -#include "G4ChargedGeantino.hh" -#include "G4Geantino.hh" -#include "G4Track.hh" -#include "G4Step.hh" +#include +#include +#include +#include +#include using namespace dd4hep::sim; -using namespace dd4hep; -using namespace std; //DECLARE_GEANT4ACTION() DECLARE_GEANT4ACTION(GeantinoRejectFilter) @@ -191,7 +189,7 @@ const G4ParticleDefinition* ParticleFilter::definition() const { if ( m_definition ) return m_definition; m_definition = G4ParticleTable::GetParticleTable()->FindParticle(m_particle); if ( 0 == m_definition ) { - throw runtime_error("Invalid particle name:'"+m_particle+"' [Not-in-particle-table]"); + throw std::runtime_error("Invalid particle name:'"+m_particle+"' [Not-in-particle-table]"); } return m_definition; } diff --git a/DDG4/plugins/Geant4TrackerWeightedSD.cpp b/DDG4/plugins/Geant4TrackerWeightedSD.cpp index 9f010bfe0..eca4988c3 100644 --- a/DDG4/plugins/Geant4TrackerWeightedSD.cpp +++ b/DDG4/plugins/Geant4TrackerWeightedSD.cpp @@ -12,20 +12,18 @@ //========================================================================== // Framework include files -#include "DD4hep/DD4hepUnits.h" -#include "DDG4/Geant4SensDetAction.inl" -#include "DDG4/Geant4SteppingAction.h" -#include "DDG4/Geant4TrackingAction.h" -#include "DDG4/Geant4EventAction.h" -#include "G4Event.hh" -#include "G4VSolid.hh" +#include +#include +#include +#include +#include +#include +#include #include #include #include -using namespace std; - /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -224,7 +222,7 @@ namespace dd4hep { break; } - if ( ended == kSurface || distance_to_outside < numeric_limits::epsilon() ) + if ( ended == kSurface || distance_to_outside < std::numeric_limits::epsilon() ) hit_flag |= Geant4Tracker::Hit::HIT_ENDED_SURFACE; else if ( ended == kInside ) hit_flag |= Geant4Tracker::Hit::HIT_ENDED_INSIDE; @@ -477,5 +475,5 @@ namespace dd4hep { using namespace dd4hep::sim; -#include "DDG4/Factories.h" +#include DECLARE_GEANT4SENSITIVE(Geant4TrackerWeightedAction) diff --git a/DDG4/plugins/Geant4UserActionInitialization.cpp b/DDG4/plugins/Geant4UserActionInitialization.cpp index ffb7fff1e..a0ebe837e 100644 --- a/DDG4/plugins/Geant4UserActionInitialization.cpp +++ b/DDG4/plugins/Geant4UserActionInitialization.cpp @@ -15,7 +15,7 @@ #define DD4HEP_DDG4_GEANT4USERACTIONINITIALIZATION_H // Framework include files -#include "DDG4/Geant4UserInitialization.h" +#include /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -60,19 +60,16 @@ namespace dd4hep { //========================================================================== // Framework include files -#include "DDG4/Factories.h" -//#include "DDG4/Geant4UserActionInitialization.h" -#include "DDG4/Geant4Context.h" +#include +//#include +#include -// C/C++ include files - -using namespace std; using namespace dd4hep::sim; //DECLARE_GEANT4ACTION(Geant4UserActionInitialization) /// Standard constructor, initializes variables -Geant4UserActionInitialization::Geant4UserActionInitialization(Geant4Context* ctxt, const string& nam) +Geant4UserActionInitialization::Geant4UserActionInitialization(Geant4Context* ctxt, const std::string& nam) : Geant4UserInitialization(ctxt,nam) { } diff --git a/DDG4/plugins/Geant4XMLSetup.cpp b/DDG4/plugins/Geant4XMLSetup.cpp index 9d68abe97..e7227a321 100644 --- a/DDG4/plugins/Geant4XMLSetup.cpp +++ b/DDG4/plugins/Geant4XMLSetup.cpp @@ -12,18 +12,17 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/Printout.h" -#include "DD4hep/DetFactoryHelper.h" -#include "XML/Conversions.h" -#include "DDG4/Geant4Config.h" +#include +#include +#include +#include +#include /// Namespace for the AIDA detector description toolkit namespace dd4hep { // Forward declarations class ActionSequence; - using namespace std; using namespace dd4hep::sim; using namespace dd4hep::sim::Setup; @@ -47,10 +46,10 @@ namespace dd4hep { template static void _setAttributes(const T& handle, xml_h& e) { xml::Handle_t props(e); // Now we set the object properties - vector attrs = props.attributes(); - for(vector::iterator i=attrs.begin(); i!=attrs.end(); ++i) { + std::vector attrs = props.attributes(); + for(std::vector::iterator i=attrs.begin(); i!=attrs.end(); ++i) { xml::Attribute a = *i; - handle[xml::_toString(props.attr_name(a))].str(props.attr(a)); + handle[xml::_toString(props.attr_name(a))].str(props.attr(a)); } } @@ -63,20 +62,20 @@ namespace dd4hep { _setAttributes(handle, props); } if ( action.hasAttr(_Unicode(Control)) ) { - handle["Control"].str(props.attr(_Unicode(Control))); + handle["Control"].str(props.attr(_Unicode(Control))); } } /// Create/Configure Geant4 sensitive action object from XML - static Action _convertSensitive(Detector& description, xml_h e, const string& detector) { + static Action _convertSensitive(Detector& description, xml_h e, const std::string& detector) { xml_comp_t action(e); Kernel& kernel = Kernel::instance(description); - TypeName tn = TypeName::split(action.attr(_U(name))); + TypeName tn = TypeName::split(action.attr(_U(name))); // Create the object using the factory method - Sensitive handle(kernel,action.attr(_U(name)),detector); + Sensitive handle(kernel,action.attr(_U(name)),detector); _setProperties(Action(handle.get()),e); for(xml_coll_t f(e,_Unicode(filter)); f; ++f) { - string nam = f.attr(_U(name)); + std::string nam = f.attr(_U(name)); Filter filter(kernel.globalFilter(nam,false)); handle->adopt(filter); } @@ -90,15 +89,15 @@ namespace dd4hep { static Action _convertAction(Detector& description, xml_h e) { xml_comp_t action(e); Kernel& kernel = Kernel::instance(description); - TypeName tn = TypeName::split(action.attr(_U(name))); + TypeName tn = TypeName::split(action.attr(_U(name))); // Create the object using the factory method - Action handle(kernel,action.attr(_U(name))); + Action handle(kernel,action.attr(_U(name))); _setProperties(handle,e); printout(INFO,"Geant4Setup","+++ Added action %s of type %s",tn.second.c_str(),tn.first.c_str()); installMessenger(handle); if ( action.hasChild(_Unicode(adopt)) ) { - xml_comp_t child = action.child(_Unicode(adopt)); + xml_comp_t child = action.child(_Unicode(adopt)); Geant4Action* user = kernel.globalAction(child.nameStr()); Geant4ParticleHandler* ph = dynamic_cast(handle.get()); if ( ph ) { @@ -110,8 +109,8 @@ namespace dd4hep { enum { SENSITIVE, ACTION, FILTER }; /// Create/Configure Action object from XML - Action _createAction(Detector& description, xml_h a, const string& seqType, int what) { - string nam = a.attr(_U(name)); + Action _createAction(Detector& description, xml_h a, const std::string& seqType, int what) { + std::string nam = a.attr(_U(name)); TypeName typ = TypeName::split(nam); Kernel& kernel = Kernel::instance(description); Action action((what==FILTER) ? (Geant4Action*)kernel.globalFilter(typ.second,false) @@ -125,366 +124,366 @@ namespace dd4hep { : (what==FILTER) ? _convertAction(description, a) : Action(); if ( !action ) { - throw runtime_error(format("Geant4ActionSequence","DDG4: The action '%s'" - " cannot be created. [Action-Missing]",nam.c_str())); - } + except("Geant4ActionSequence", + "DDG4: The action '%s' cannot be created. [Action-Missing]",nam.c_str()); } - return action; } + return action; } +} - /// Convert Geant4Action objects - /** - * - * - * - * - */ - template <> void Converter::operator()(xml_h e) const { - Action a = _convertAction(description, e); - Kernel::instance(description).registerGlobalAction(a); - } +/// Convert Geant4Action objects +/** + * + * + * + * + */ +template <> void Converter::operator()(xml_h e) const { + Action a = _convertAction(description, e); + Kernel::instance(description).registerGlobalAction(a); +} - /// Convert Sensitive detector filters - /** - * Note: Filters are Geant4Actions and - if global - may also receive properties! - * - * - * - * - * - * - * - */ - template <> void Converter::operator()(xml_h e) const { - Action a = _convertAction(description, e); - Kernel::instance(description).registerGlobalFilter(a); - } +/// Convert Sensitive detector filters +/** + * Note: Filters are Geant4Actions and - if global - may also receive properties! + * + * + * + * + * + * + * + */ +template <> void Converter::operator()(xml_h e) const { + Action a = _convertAction(description, e); + Kernel::instance(description).registerGlobalFilter(a); +} - /// Convert Geant4Phase objects - /** - * - * - * - * - */ - template <> void Converter::operator()(xml_h e) const { - xml_comp_t x_phase(e); - Kernel& kernel = Kernel::instance(description); - string nam = x_phase.attr(_U(type)); - typedef Geant4ActionPhase PH; - Phase p; +/// Convert Geant4Phase objects +/** + * + * + * + * + */ +template <> void Converter::operator()(xml_h e) const { + xml_comp_t x_phase(e); + Kernel& kernel = Kernel::instance(description); + std::string nam = x_phase.attr(_U(type)); + typedef Geant4ActionPhase PH; + Phase p; - if ( nam == "RunAction/begin" ) { - void (Geant4ActionPhase::*func)(const G4Run*) = &Geant4ActionPhase::call; - kernel.runAction().callAtBegin((p=kernel.addPhase(nam)).get(),func); - //&Geant4ActionPhase::call); - } - else if ( nam == "RunAction/end" ) { - void (Geant4ActionPhase::*func)(const G4Run*) = &Geant4ActionPhase::call; - kernel.runAction().callAtEnd((p=kernel.addPhase(nam)).get(),func); - //&PH::call); - } - else if ( nam == "EventAction/begin" ) { - void (Geant4ActionPhase::*func)(const G4Event*) = &Geant4ActionPhase::call; - kernel.eventAction().callAtBegin((p=kernel.addPhase(nam)).get(),func); - //&PH::call); - } - else if ( nam == "EventAction/end" ) { - void (Geant4ActionPhase::*func)(const G4Event*) = &Geant4ActionPhase::call; - kernel.eventAction().callAtEnd((p=kernel.addPhase(nam)).get(),func); - //&PH::call); - } - else if ( nam == "TrackingAction/begin" ) { - void (Geant4ActionPhase::*func)(const G4Track*) = &Geant4ActionPhase::call; - kernel.trackingAction().callAtBegin((p=kernel.addPhase(nam)).get(),func); - //&PH::call); - } - else if ( nam == "TrackingAction/end" ) { - void (Geant4ActionPhase::*func)(const G4Track*) = &Geant4ActionPhase::call; - kernel.trackingAction().callAtEnd((p=kernel.addPhase(nam,false)).get(),func); - //&PH::call); - } - else if ( nam == "StackingAction/newStage" ) { - kernel.stackingAction().callAtNewStage((p=kernel.addPhase(nam,false)).get(),&PH::call); - } - else if ( nam == "StackingAction/prepare" ) { - kernel.stackingAction().callAtPrepare((p=kernel.addPhase(nam,false)).get(),&PH::call); - } - else if ( nam == "SteppingAction" ) { - void (Geant4ActionPhase::*func)(const G4Step*,G4SteppingManager*) = &Geant4ActionPhase::call; - kernel.steppingAction().call((p=kernel.addPhase(nam)).get(),func); - //&PH::call); - } - else if ( nam == "GeneratorAction/primaries" ) { - void (Geant4ActionPhase::*func)(G4Event*) = &Geant4ActionPhase::call; - kernel.generatorAction().call((p=kernel.addPhase(nam)).get(),func); - //&PH::call); + if ( nam == "RunAction/begin" ) { + void (Geant4ActionPhase::*func)(const G4Run*) = &Geant4ActionPhase::call; + kernel.runAction().callAtBegin((p=kernel.addPhase(nam)).get(),func); + //&Geant4ActionPhase::call); + } + else if ( nam == "RunAction/end" ) { + void (Geant4ActionPhase::*func)(const G4Run*) = &Geant4ActionPhase::call; + kernel.runAction().callAtEnd((p=kernel.addPhase(nam)).get(),func); + //&PH::call); + } + else if ( nam == "EventAction/begin" ) { + void (Geant4ActionPhase::*func)(const G4Event*) = &Geant4ActionPhase::call; + kernel.eventAction().callAtBegin((p=kernel.addPhase(nam)).get(),func); + //&PH::call); + } + else if ( nam == "EventAction/end" ) { + void (Geant4ActionPhase::*func)(const G4Event*) = &Geant4ActionPhase::call; + kernel.eventAction().callAtEnd((p=kernel.addPhase(nam)).get(),func); + //&PH::call); + } + else if ( nam == "TrackingAction/begin" ) { + void (Geant4ActionPhase::*func)(const G4Track*) = &Geant4ActionPhase::call; + kernel.trackingAction().callAtBegin((p=kernel.addPhase(nam)).get(),func); + //&PH::call); + } + else if ( nam == "TrackingAction/end" ) { + void (Geant4ActionPhase::*func)(const G4Track*) = &Geant4ActionPhase::call; + kernel.trackingAction().callAtEnd((p=kernel.addPhase(nam,false)).get(),func); + //&PH::call); + } + else if ( nam == "StackingAction/newStage" ) { + kernel.stackingAction().callAtNewStage((p=kernel.addPhase(nam,false)).get(),&PH::call); + } + else if ( nam == "StackingAction/prepare" ) { + kernel.stackingAction().callAtPrepare((p=kernel.addPhase(nam,false)).get(),&PH::call); + } + else if ( nam == "SteppingAction" ) { + void (Geant4ActionPhase::*func)(const G4Step*,G4SteppingManager*) = &Geant4ActionPhase::call; + kernel.steppingAction().call((p=kernel.addPhase(nam)).get(),func); + //&PH::call); + } + else if ( nam == "GeneratorAction/primaries" ) { + void (Geant4ActionPhase::*func)(G4Event*) = &Geant4ActionPhase::call; + kernel.generatorAction().call((p=kernel.addPhase(nam)).get(),func); + //&PH::call); + } + else { + TypeName tn = TypeName::split(nam); + DetElement det = description.detector(tn.first); + if ( !det.isValid() ) { + except("Phase","DDG4: The phase '%s' of type SensitiveSeq" + " cannot be attached to a non-existing detector" + " [Detector-Missing]",nam.c_str()); } - else { - TypeName tn = TypeName::split(nam); - DetElement det = description.detector(tn.first); - if ( !det.isValid() ) { - throw runtime_error(format("Phase","DDG4: The phase '%s' of type SensitiveSeq" - " cannot be attached to a non-existing detector" - " [Detector-Missing]",nam.c_str())); - } - SensitiveDetector sd = description.sensitiveDetector(tn.first); - if ( !sd.isValid() ) { - throw runtime_error(format("Phase","DDG4: The phase '%s' of type SensitiveSeq" - " cannot be attached to a non-existing sensitive detector" - " [Sensitive-Missing]",nam.c_str())); - } - SensitiveSeq sdSeq = SensitiveSeq(kernel,tn.first); - if ( tn.second == "begin" ) - sdSeq->callAtBegin((p=kernel.addPhase(tn.second)).get(), - &PH::call); - else if ( tn.second == "end" ) - sdSeq->callAtEnd((p=kernel.addPhase(tn.second)).get(), - &PH::call); - else if ( tn.second == "clear" ) - sdSeq->callAtClear((p=kernel.addPhase(tn.second)).get(), - &PH::call); - else if ( tn.second == "process" ) - sdSeq->callAtProcess((p=kernel.addPhase(tn.second)).get(), - &PH::call); - else - throw runtime_error(format("Phase","DDG4: The phase '%s' of type SensitiveSeq" - " cannot be attached to the call '%s'." - " [Callback-Missing]",tn.first.c_str(), tn.second.c_str())); + SensitiveDetector sd = description.sensitiveDetector(tn.first); + if ( !sd.isValid() ) { + except("Phase","DDG4: The phase '%s' of type SensitiveSeq" + " cannot be attached to a non-existing sensitive detector" + " [Sensitive-Missing]",nam.c_str()); } + SensitiveSeq sdSeq = SensitiveSeq(kernel,tn.first); + if ( tn.second == "begin" ) + sdSeq->callAtBegin((p=kernel.addPhase(tn.second)).get(), + &PH::call); + else if ( tn.second == "end" ) + sdSeq->callAtEnd((p=kernel.addPhase(tn.second)).get(), + &PH::call); + else if ( tn.second == "clear" ) + sdSeq->callAtClear((p=kernel.addPhase(tn.second)).get(), + &PH::call); + else if ( tn.second == "process" ) + sdSeq->callAtProcess((p=kernel.addPhase(tn.second)).get(), + &PH::call); + else + except("Phase","DDG4: The phase '%s' of type SensitiveSeq" + " cannot be attached to the call '%s'." + " [Callback-Missing]",tn.first.c_str(), tn.second.c_str()); } +} - /// Convert Action sequences into objects - /** - * - * - *
- * - * - * - * - * - */ - template <> void Converter::operator()(xml_h e) const { - xml_comp_t seq(e); - SensitiveSeq sdSeq; - string seqNam; - TypeName seqType; - int what = ACTION; - Kernel& kernel = Kernel::instance(description); +/// Convert Action sequences into objects +/** + * + * + * + * + * + * + * + * + */ +template <> void Converter::operator()(xml_h e) const { + xml_comp_t seq(e); + SensitiveSeq sdSeq; + std::string seqNam; + TypeName seqType; + int what = ACTION; + Kernel& kernel = Kernel::instance(description); - if ( seq.hasAttr(_U(sd)) ) { - string sd_nam = seq.attr(_U(sd)); - SensitiveDetector sensitive = description.sensitiveDetector(sd_nam); - seqNam = seq.attr(_U(type))+"/"+sd_nam; - if ( !sensitive.isValid() ) { - printout(ALWAYS,"Geant4Setup","+++ ActionSequence %s is defined, " - "but no sensitive detector present.",seqNam.c_str()); - printout(ALWAYS,"Geant4Setup","+++ ---> Sequence for detector %s IGNORED on popular request!", - sd_nam.c_str()); - return; - } - seqType = TypeName::split(seqNam); - sdSeq = SensitiveSeq(kernel,seqNam); - what = SENSITIVE; - } - else { - seqNam = seq.attr(_U(name)); - seqType = TypeName::split(seqNam); + if ( seq.hasAttr(_U(sd)) ) { + std::string sd_nam = seq.attr(_U(sd)); + SensitiveDetector sensitive = description.sensitiveDetector(sd_nam); + seqNam = seq.attr(_U(type))+"/"+sd_nam; + if ( !sensitive.isValid() ) { + printout(ALWAYS,"Geant4Setup","+++ ActionSequence %s is defined, " + "but no sensitive detector present.",seqNam.c_str()); + printout(ALWAYS,"Geant4Setup","+++ ---> Sequence for detector %s IGNORED on popular request!", + sd_nam.c_str()); + return; } - printout(INFO,"Geant4Setup","+++ ActionSequence %s of type %s added.", - seqType.second.c_str(),seqType.first.c_str()); + seqType = TypeName::split(seqNam); + sdSeq = SensitiveSeq(kernel,seqNam); + what = SENSITIVE; + } + else { + seqNam = seq.attr(_U(name)); + seqType = TypeName::split(seqNam); + } + printout(INFO,"Geant4Setup","+++ ActionSequence %s of type %s added.", + seqType.second.c_str(),seqType.first.c_str()); - if ( seqType.second == "PhysicsList" ) { - PhysicsActionSeq pl(&kernel.physicsList()); - PropertyManager& props = kernel.physicsList().properties(); - props.dump(); - _setAttributes(pl,e); - props.dump(); - } + if ( seqType.second == "PhysicsList" ) { + PhysicsActionSeq pl(&kernel.physicsList()); + PropertyManager& props = kernel.physicsList().properties(); + props.dump(); + _setAttributes(pl,e); + props.dump(); + } - for(xml_coll_t a(seq,_Unicode(action)); a; ++a) { - string nam = a.attr(_U(name)); - Action action(_createAction(description,a,seqType.second,what)); - if ( seqType.second == "RunAction" ) - kernel.runAction().adopt(_action(action.get())); - else if ( seqType.second == "EventAction" ) - kernel.eventAction().adopt(_action(action.get())); - else if ( seqType.second == "GeneratorAction" ) - kernel.generatorAction().adopt(_action(action.get())); - else if ( seqType.second == "TrackingAction" ) - kernel.trackingAction().adopt(_action(action.get())); - else if ( seqType.second == "StackingAction" ) - kernel.stackingAction().adopt(_action(action.get())); - else if ( seqType.second == "SteppingAction" ) - kernel.steppingAction().adopt(_action(action.get())); - else if ( seqType.second == "PhysicsList" ) - kernel.physicsList().adopt(_action(action.get())); - else if ( sdSeq.get() ) - sdSeq->adopt(_action(action.get())); - else { - throw runtime_error(format("ActionSequence","DDG4: The action '%s'" - " cannot be attached to any sequence '%s'." - " [Sequence-Missing]",nam.c_str(), seqNam.c_str())); - } + for(xml_coll_t a(seq,_Unicode(action)); a; ++a) { + std::string nam = a.attr(_U(name)); + Action action(_createAction(description,a,seqType.second,what)); + if ( seqType.second == "RunAction" ) + kernel.runAction().adopt(_action(action.get())); + else if ( seqType.second == "EventAction" ) + kernel.eventAction().adopt(_action(action.get())); + else if ( seqType.second == "GeneratorAction" ) + kernel.generatorAction().adopt(_action(action.get())); + else if ( seqType.second == "TrackingAction" ) + kernel.trackingAction().adopt(_action(action.get())); + else if ( seqType.second == "StackingAction" ) + kernel.stackingAction().adopt(_action(action.get())); + else if ( seqType.second == "SteppingAction" ) + kernel.steppingAction().adopt(_action(action.get())); + else if ( seqType.second == "PhysicsList" ) + kernel.physicsList().adopt(_action(action.get())); + else if ( sdSeq.get() ) + sdSeq->adopt(_action(action.get())); + else { + except("ActionSequence","DDG4: The action '%s'" + " cannot be attached to any sequence '%s'." + " [Sequence-Missing]",nam.c_str(), seqNam.c_str()); + } + printout(INFO,"Geant4Setup","+++ ActionSequence %s added filter object:%s", + seqType.second.c_str(),action->name().c_str()); + } + if ( what == SENSITIVE ) { + for(xml_coll_t a(seq,_Unicode(filter)); a; ++a) { + std::string nam = a.attr(_U(name)); + Action action(_createAction(description,a,"",FILTER)); + installMessenger(action); printout(INFO,"Geant4Setup","+++ ActionSequence %s added filter object:%s", seqType.second.c_str(),action->name().c_str()); - } - if ( what == SENSITIVE ) { - for(xml_coll_t a(seq,_Unicode(filter)); a; ++a) { - string nam = a.attr(_U(name)); - Action action(_createAction(description,a,"",FILTER)); - installMessenger(action); - printout(INFO,"Geant4Setup","+++ ActionSequence %s added filter object:%s", - seqType.second.c_str(),action->name().c_str()); - if ( sdSeq.get() ) - sdSeq->adopt(_action(action.get())); - else { - throw runtime_error(format("ActionSequence","DDG4: The action '%s'" - " cannot be attached to any sequence '%s'." - " [Sequence-Missing]",nam.c_str(), seqNam.c_str())); - } + if ( sdSeq.get() ) + sdSeq->adopt(_action(action.get())); + else { + except("ActionSequence","DDG4: The action '%s'" + " cannot be attached to any sequence '%s'." + " [Sequence-Missing]",nam.c_str(), seqNam.c_str()); } } } +} - /// Create/Configure PhysicsList objects - /** - * - * - * - * - * - * - * - * - */ - template <> void Converter::operator()(xml_h e) const { - xml_comp_t part(e); - string part_name = part.nameStr(); - Geant4PhysicsList::ParticleProcesses& procs = - _object().processes(part_name); - for(xml_coll_t q(part,_Unicode(process)); q; ++q) { - xml_comp_t proc(q); - Geant4PhysicsList::Process p; - p.name = proc.nameStr(); - p.ordAtRestDoIt = proc.attr(_Unicode(ordAtRestDoIt)); - p.ordAlongSteptDoIt = proc.attr(_Unicode(ordAlongSteptDoIt)); - p.ordPostStepDoIt = proc.attr(_Unicode(ordPostStepDoIt)); - procs.emplace_back(p); - printout(INFO,"Geant4Setup","+++ Converter + * + * + * + * + * + * + * + */ +template <> void Converter::operator()(xml_h e) const { + xml_comp_t part(e); + std::string part_name = part.nameStr(); + Geant4PhysicsList::ParticleProcesses& procs = + _object().processes(part_name); + for(xml_coll_t q(part,_Unicode(process)); q; ++q) { + xml_comp_t proc(q); + Geant4PhysicsList::Process p; + p.name = proc.nameStr(); + p.ordAtRestDoIt = proc.attr(_Unicode(ordAtRestDoIt)); + p.ordAlongSteptDoIt = proc.attr(_Unicode(ordAlongSteptDoIt)); + p.ordPostStepDoIt = proc.attr(_Unicode(ordPostStepDoIt)); + procs.emplace_back(p); + printout(INFO,"Geant4Setup","+++ Converter - * - * - * - * - * - * - * - * - */ - template <> void Converter::operator()(xml_h e) const { - Geant4PhysicsList::ParticleConstructors& parts = _object().particles(); - xml_comp_t part(e); - string n = part.nameStr(); - parts.emplace_back(n); - printout(INFO,"Geant4Setup","+++ ParticleConstructor: Add Geant4 particle constructor '%s'",n.c_str()); - } +/// Create/Configure PhysicsList objects: Particle constructors +/** + * + * + * + * + * + * + * + * + * + */ +template <> void Converter::operator()(xml_h e) const { + Geant4PhysicsList::ParticleConstructors& parts = _object().particles(); + xml_comp_t part(e); + std::string n = part.nameStr(); + parts.emplace_back(n); + printout(INFO,"Geant4Setup","+++ ParticleConstructor: Add Geant4 particle constructor '%s'",n.c_str()); +} - /// Create/Configure PhysicsList objects: Physics constructors - /** - * - * - * - * - * - * - */ - template <> void Converter::operator()(xml_h e) const { - Geant4PhysicsList::PhysicsConstructors& parts = _object().physics(); - xml_comp_t part(e); - string n = part.nameStr(); - parts.emplace_back(n); - printout(INFO,"Geant4Setup","+++ PhysicsConstructor: Add Geant4 physics constructor '%s'",n.c_str()); - } +/// Create/Configure PhysicsList objects: Physics constructors +/** + * + * + * + * + * + * + */ +template <> void Converter::operator()(xml_h e) const { + Geant4PhysicsList::PhysicsConstructors& parts = _object().physics(); + xml_comp_t part(e); + std::string n = part.nameStr(); + parts.emplace_back(n); + printout(INFO,"Geant4Setup","+++ PhysicsConstructor: Add Geant4 physics constructor '%s'",n.c_str()); +} - /// Create/Configure PhysicsList extension objects: Predefined Geant4 Physics lists - /** - * - * - * - * Note: list items are Geant4Actions and - if global - may receive properties! - */ - struct PhysicsListExtension; - template <> void Converter::operator()(xml_h e) const { - Kernel& kernel = Kernel::instance(description); - string ext = xml_comp_t(e).nameStr(); - kernel.physicsList().properties()["extends"].str(ext); - printout(INFO,"Geant4Setup","+++ PhysicsListExtension: Set predefined Geant4 physics list to '%s'",ext.c_str()); - } +/// Create/Configure PhysicsList extension objects: Predefined Geant4 Physics lists +/** + * + * + * + * Note: list items are Geant4Actions and - if global - may receive properties! + */ +struct PhysicsListExtension; +template <> void Converter::operator()(xml_h e) const { + Kernel& kernel = Kernel::instance(description); + std::string ext = xml_comp_t(e).nameStr(); + kernel.physicsList().properties()["extends"].str(ext); + printout(INFO,"Geant4Setup","+++ PhysicsListExtension: Set predefined Geant4 physics list to '%s'",ext.c_str()); +} - /// Create/Configure PhysicsList objects: Predefined Geant4 Physics lists - template <> void Converter::operator()(xml_h e) const { - string name = e.attr(_U(name)); - Kernel& kernel = Kernel::instance(description); - PhysicsList handle(kernel,name); - _setAttributes(handle,e); - xml_coll_t(e,_Unicode(particles)).for_each(_Unicode(construct),Converter(description,handle.get())); - xml_coll_t(e,_Unicode(processes)).for_each(_Unicode(particle),Converter(description,handle.get())); - xml_coll_t(e,_Unicode(physics)).for_each(_Unicode(construct),Converter(description,handle.get())); - xml_coll_t(e,_Unicode(extends)).for_each(Converter(description,handle.get())); - kernel.physicsList().adopt(handle); - } +/// Create/Configure PhysicsList objects: Predefined Geant4 Physics lists +template <> void Converter::operator()(xml_h e) const { + std::string name = e.attr(_U(name)); + Kernel& kernel = Kernel::instance(description); + PhysicsList handle(kernel,name); + _setAttributes(handle,e); + xml_coll_t(e,_Unicode(particles)).for_each(_Unicode(construct),Converter(description,handle.get())); + xml_coll_t(e,_Unicode(processes)).for_each(_Unicode(particle),Converter(description,handle.get())); + xml_coll_t(e,_Unicode(physics)).for_each(_Unicode(construct),Converter(description,handle.get())); + xml_coll_t(e,_Unicode(extends)).for_each(Converter(description,handle.get())); + kernel.physicsList().adopt(handle); +} - /// Create/Configure Geant4Kernel objects - template <> void Converter::operator()(xml_h e) const { - Kernel& kernel = Kernel::instance(description); - xml_comp_t k(e); - if ( k.hasAttr(_Unicode(NumEvents)) ) - kernel.property("NumEvents").str(k.attr(_Unicode(NumEvents))); - if ( k.hasAttr(_Unicode(UI)) ) - kernel.property("UI").str(k.attr(_Unicode(UI))); - } +/// Create/Configure Geant4Kernel objects +template <> void Converter::operator()(xml_h e) const { + Kernel& kernel = Kernel::instance(description); + xml_comp_t k(e); + if ( k.hasAttr(_Unicode(NumEvents)) ) + kernel.property("NumEvents").str(k.attr(_Unicode(NumEvents))); + if ( k.hasAttr(_Unicode(UI)) ) + kernel.property("UI").str(k.attr(_Unicode(UI))); +} - /// Main entry point to configure Geant4 with XML - template <> void Converter::operator()(xml_h seq) const { - xml_elt_t compact(seq); - // First execute the basic setup from the plugins module - long result = PluginService::Create("geant4_XML_reader",&description,&seq); - if ( 0 == result ) { - throw runtime_error("dd4hep: Failed to locate plugin to interprete files of type" - " \"" + seq.tag() + "\" - no factory of type geant4_XML_reader."); - } - result = *(long*) result; - if (result != 1) { - throw runtime_error("dd4hep: Failed to parse the XML tag " + seq.tag() + " with the plugin geant4_XML_reader"); - } - xml_coll_t(compact,_Unicode(kernel)).for_each(Converter(description,param)); - // Now deal with the new stuff..... - xml_coll_t(compact,_Unicode(actions) ).for_each(_Unicode(action),Converter(description,param)); - xml_coll_t(compact,_Unicode(filters) ).for_each(_Unicode(filter),Converter(description,param)); - xml_coll_t(compact,_Unicode(sequences) ).for_each(_Unicode(sequence),Converter(description,param)); - xml_coll_t(compact,_Unicode(phases) ).for_each(_Unicode(phase),Converter(description,param)); - xml_coll_t(compact,_Unicode(physicslist)).for_each(Converter(description,param)); +/// Main entry point to configure Geant4 with XML +template <> void Converter::operator()(xml_h seq) const { + xml_elt_t compact(seq); + // First execute the basic setup from the plugins module + long result = PluginService::Create("geant4_XML_reader",&description,&seq); + if ( 0 == result ) { + except("PhysicsList", "dd4hep: Failed to locate plugin to interprete files of type" + " \"" + seq.tag() + "\" - no factory of type geant4_XML_reader."); + } + result = *(long*) result; + if (result != 1) { + except("PhysicsList", "dd4hep: Failed to parse the XML tag %s with the plugin geant4_XML_reader", seq.tag().c_str()); } + xml_coll_t(compact,_Unicode(kernel)).for_each(Converter(description,param)); + // Now deal with the new stuff..... + xml_coll_t(compact,_Unicode(actions) ).for_each(_Unicode(action),Converter(description,param)); + xml_coll_t(compact,_Unicode(filters) ).for_each(_Unicode(filter),Converter(description,param)); + xml_coll_t(compact,_Unicode(sequences) ).for_each(_Unicode(sequence),Converter(description,param)); + xml_coll_t(compact,_Unicode(phases) ).for_each(_Unicode(phase),Converter(description,param)); + xml_coll_t(compact,_Unicode(physicslist)).for_each(Converter(description,param)); +} } /// Factory method diff --git a/DDG4/reco/Geant4SurfaceTest.cpp b/DDG4/reco/Geant4SurfaceTest.cpp index 84b6bb147..a07053a6d 100644 --- a/DDG4/reco/Geant4SurfaceTest.cpp +++ b/DDG4/reco/Geant4SurfaceTest.cpp @@ -15,7 +15,7 @@ // Framework include files //#include "Geant4SurfaceTest.h" -#include "DDG4/Geant4EventAction.h" +#include /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -48,32 +48,31 @@ namespace dd4hep { #endif // DD4HEP_DDG4_GEANT4SURFACETEST_H // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/DD4hepUnits.h" -#include "DD4hep/InstanceCount.h" +#include +#include +#include -#include "DDG4/Factories.h" -#include "DDG4/Geant4Data.h" -#include "DDG4/Geant4Context.h" -#include "DDG4/Geant4SensDetAction.h" -#include "DDG4/Geant4HitCollection.h" +#include +#include +#include +#include +#include -#include "DDRec/Surface.h" -#include "DDRec/DetectorSurfaces.h" -#include "DDRec/SurfaceManager.h" -#include "DDRec/SurfaceHelper.h" +#include +#include +#include +#include // Geant 4 includes -#include "G4VHitsCollection.hh" -#include "G4HCofThisEvent.hh" -#include "G4Event.hh" +#include +#include +#include // C/C++ include files #include #include #include -using namespace std; using namespace dd4hep::DDRec; using namespace dd4hep::detail; using namespace dd4hep::sim; diff --git a/DDG4/src/Geant4Action.cpp b/DDG4/src/Geant4Action.cpp index 9902863e3..c8dbd2327 100644 --- a/DDG4/src/Geant4Action.cpp +++ b/DDG4/src/Geant4Action.cpp @@ -25,7 +25,6 @@ // C/C++ include files #include -using namespace dd4hep; using namespace dd4hep::sim; TypeName TypeName::split(const std::string& type_name, const std::string& delim) { @@ -86,7 +85,7 @@ long Geant4Action::release() { } /// Set the output level; returns previous value -PrintLevel Geant4Action::setOutputLevel(PrintLevel new_level) { +dd4hep::PrintLevel Geant4Action::setOutputLevel(PrintLevel new_level) { int old = m_outputLevel; m_outputLevel = new_level; return (PrintLevel)old; @@ -98,7 +97,7 @@ bool Geant4Action::hasProperty(const std::string& nam) const { } /// Access single property -Property& Geant4Action::property(const std::string& nam) { +dd4hep::Property& Geant4Action::property(const std::string& nam) { return properties()[nam]; } diff --git a/DDG4/src/Geant4Context.cpp b/DDG4/src/Geant4Context.cpp index 95f0f84d4..803d254d8 100644 --- a/DDG4/src/Geant4Context.cpp +++ b/DDG4/src/Geant4Context.cpp @@ -20,7 +20,6 @@ // C/C++ include files #include -using namespace dd4hep; using namespace dd4hep::sim; /// Intializing constructor @@ -89,7 +88,7 @@ Geant4Event& Geant4Context::event() const { } /// Access to detector description -Detector& Geant4Context::detectorDescription() const { +dd4hep::Detector& Geant4Context::detectorDescription() const { return m_kernel->detectorDescription(); } diff --git a/DDG4/src/Geant4Data.cpp b/DDG4/src/Geant4Data.cpp index 4d57b09ca..e4c7efd06 100644 --- a/DDG4/src/Geant4Data.cpp +++ b/DDG4/src/Geant4Data.cpp @@ -24,7 +24,6 @@ #include #include -using namespace dd4hep; using namespace dd4hep::sim; /// Default constructor diff --git a/DDG4/src/Geant4DataDump.cpp b/DDG4/src/Geant4DataDump.cpp index f07fefa7c..21ff02716 100644 --- a/DDG4/src/Geant4DataDump.cpp +++ b/DDG4/src/Geant4DataDump.cpp @@ -15,10 +15,8 @@ #include #include -using namespace dd4hep; using namespace dd4hep::sim; - -typedef detail::ReferenceBitMask PropertyMask; +using PropertyMask = dd4hep::detail::ReferenceBitMask; /// Default constructor Geant4DataDump::Geant4DataDump(const std::string& tag) : m_tag(tag) { diff --git a/DDG4/src/Geant4DetectorConstruction.cpp b/DDG4/src/Geant4DetectorConstruction.cpp index 1eddbf989..2b0efa9ef 100644 --- a/DDG4/src/Geant4DetectorConstruction.cpp +++ b/DDG4/src/Geant4DetectorConstruction.cpp @@ -20,8 +20,6 @@ #include #include -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; /// Helper: Assign sensitive detector to logical volume @@ -81,7 +79,7 @@ void Geant4DetectorConstructionSequence::adopt(Geant4DetectorConstruction* actio m_actors.add(action); return; } - except("Geant4RunActionSequence","++ Attempt to add an invalid actor!"); + except("++ Attempt to add an invalid actor!"); } /// Access an actor by name @@ -91,8 +89,8 @@ Geant4DetectorConstruction* Geant4DetectorConstructionSequence::get(const std::s return i; } } - except("Geant4RunActionSequence","++ Attempt to access invalid actor %s!",nam.c_str()); - return 0; + except("++ Attempt to access invalid actor %s!",nam.c_str()); + return nullptr; } /// Geometry construction callback. Called at "Construct()" @@ -111,49 +109,47 @@ void Geant4DetectorConstructionSequence::constructSensitives(Geant4DetectorConst } /// Access to the converted regions -const map& Geant4DetectorConstructionSequence::regions() const { +const std::map& +Geant4DetectorConstructionSequence::regions() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4Regions; throw std::runtime_error("+++ Geant4DetectorConstructionSequence::regions: Access not possible. Geometry is not yet converted!"); } -#if 0 -/// Access to the converted sensitive detectors -const Geant4GeometryMaps::SensDetMap& Geant4DetectorConstructionSequence::sensitives() const { - Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); - if ( p ) return p->g4SensDets; - throw std::runtime_error("+++ Geant4DetectorConstructionSequence::sensitives: Access not possible. Geometry is not yet converted!"); -} -#endif + /// Access to the converted volumes -const map& Geant4DetectorConstructionSequence::volumes() const { +const std::map& +Geant4DetectorConstructionSequence::volumes() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4Volumes; throw std::runtime_error("+++ Geant4DetectorConstructionSequence::volumes: Access not possible. Geometry is not yet converted!"); } /// Access to the converted shapes -const map& Geant4DetectorConstructionSequence::shapes() const { +const std::map& Geant4DetectorConstructionSequence::shapes() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4Solids; throw std::runtime_error("+++ Geant4DetectorConstructionSequence::shapes: Access not possible. Geometry is not yet converted!"); } /// Access to the converted limit sets -const map& Geant4DetectorConstructionSequence::limits() const { +const std::map& +Geant4DetectorConstructionSequence::limits() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4Limits; throw std::runtime_error("+++ Geant4DetectorConstructionSequence::limits: Access not possible. Geometry is not yet converted!"); } /// Access to the converted assemblies -const map& Geant4DetectorConstructionSequence::assemblies() const { +const std::map& +Geant4DetectorConstructionSequence::assemblies() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4AssemblyVolumes; throw std::runtime_error("+++ Geant4DetectorConstructionSequence::assemblies: Access not possible. Geometry is not yet converted!"); } /// Access to the converted placements -const map& Geant4DetectorConstructionSequence::placements() const { +const std::map& +Geant4DetectorConstructionSequence::placements() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4Placements; throw std::runtime_error("+++ Geant4DetectorConstructionSequence::placements: Access not possible. Geometry is not yet converted!"); diff --git a/DDG4/src/Geant4EventAction.cpp b/DDG4/src/Geant4EventAction.cpp index 5e12acdb0..3974a839b 100644 --- a/DDG4/src/Geant4EventAction.cpp +++ b/DDG4/src/Geant4EventAction.cpp @@ -14,13 +14,11 @@ // Framework include files #include "DD4hep/InstanceCount.h" #include "DDG4/Geant4EventAction.h" + // Geant4 headers #include "G4Threading.hh" #include "G4AutoLock.hh" -// C/C++ include files -#include -using namespace std; using namespace dd4hep::sim; namespace { @@ -28,7 +26,7 @@ namespace { } /// Standard constructor -Geant4EventAction::Geant4EventAction(Geant4Context* ctxt, const string& nam) +Geant4EventAction::Geant4EventAction(Geant4Context* ctxt, const std::string& nam) : Geant4Action(ctxt, nam) { InstanceCount::increment(this); @@ -48,7 +46,7 @@ void Geant4EventAction::end(const G4Event* ) { } /// Standard constructor -Geant4SharedEventAction::Geant4SharedEventAction(Geant4Context* ctxt, const string& nam) +Geant4SharedEventAction::Geant4SharedEventAction(Geant4Context* ctxt, const std::string& nam) : Geant4EventAction(ctxt, nam) { InstanceCount::increment(this); @@ -73,7 +71,7 @@ void Geant4SharedEventAction::use(Geant4EventAction* action) { m_action = action; return; } - throw runtime_error("Geant4SharedEventAction: Attempt to use invalid actor!"); + except("Geant4SharedEventAction: Attempt to use invalid actor!"); } /// Begin-of-event callback @@ -97,7 +95,7 @@ void Geant4SharedEventAction::end(const G4Event* event) { } /// Standard constructor -Geant4EventActionSequence::Geant4EventActionSequence(Geant4Context* ctxt, const string& nam) +Geant4EventActionSequence::Geant4EventActionSequence(Geant4Context* ctxt, const std::string& nam) : Geant4Action(ctxt, nam) { m_needsControl = true; InstanceCount::increment(this); @@ -125,7 +123,7 @@ void Geant4EventActionSequence::configureFiber(Geant4Context* thread_context) } /// Get an action by name -Geant4EventAction* Geant4EventActionSequence::get(const string& nam) const { +Geant4EventAction* Geant4EventActionSequence::get(const std::string& nam) const { return m_actors.get(FindByName(TypeName::split(nam).second)); } @@ -137,7 +135,7 @@ void Geant4EventActionSequence::adopt(Geant4EventAction* action) { m_actors.add(action); return; } - throw runtime_error("Geant4EventActionSequence: Attempt to add invalid actor!"); + except("Geant4EventActionSequence: Attempt to add invalid actor!"); } /// Pre-track action callback diff --git a/DDG4/src/Geant4Exec.cpp b/DDG4/src/Geant4Exec.cpp index 1c7ef0260..e1aa5e6fc 100644 --- a/DDG4/src/Geant4Exec.cpp +++ b/DDG4/src/Geant4Exec.cpp @@ -12,35 +12,35 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/Primitives.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/Handle.h" -#include "DDG4/Geant4RunAction.h" -#include "DDG4/Geant4EventAction.h" -#include "DDG4/Geant4SteppingAction.h" -#include "DDG4/Geant4TrackingAction.h" -#include "DDG4/Geant4StackingAction.h" -#include "DDG4/Geant4GeneratorAction.h" -#include "DDG4/Geant4UserInitialization.h" -#include "DDG4/Geant4DetectorConstruction.h" -#include "DDG4/Geant4PhysicsList.h" -#include "DDG4/Geant4UIManager.h" -#include "DDG4/Geant4Kernel.h" -#include "DDG4/Geant4Random.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // Geant4 include files -#include "G4Version.hh" -#include "G4UserRunAction.hh" -#include "G4UserEventAction.hh" -#include "G4UserTrackingAction.hh" -#include "G4UserStackingAction.hh" -#include "G4UserSteppingAction.hh" -#include "G4VUserPhysicsList.hh" -#include "G4VModularPhysicsList.hh" -#include "G4VUserPrimaryGeneratorAction.hh" -#include "G4VUserActionInitialization.hh" -#include "G4VUserDetectorConstruction.hh" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // C/C++ include files #include @@ -56,6 +56,8 @@ namespace dd4hep { /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit namespace sim { + class Geant4DetectorConstructionSequence; + /// Sequence handler implementing common actions to all sequences. /** @class SequenceHdl * @@ -489,38 +491,36 @@ namespace dd4hep { m_sequence->buildMaster(); } } + + /// Compatibility actions for running Geant4 in single threaded mode + /** @class Geant4Compatibility + * + * @author M.Frank + * @version 1.0 + */ + class Geant4Compatibility { + public: + /// Default constructor + Geant4Compatibility() = default; + /// Default destructor + virtual ~Geant4Compatibility() = default; + /// Detector construction invocation in compatibility mode + Geant4DetectorConstructionSequence* buildDefaultDetectorConstruction(Geant4Kernel& kernel); + }; + } } -#include "DD4hep/Detector.h" -#include "DD4hep/Plugins.h" -#include "DDG4/Geant4DetectorConstruction.h" -#include "DDG4/Geant4Kernel.h" +#include +#include +#include +#include -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; // Geant4 include files -#include "G4RunManager.hh" -#include "G4PhysListFactory.hh" - - -/// Compatibility actions for running Geant4 in single threaded mode -/** @class Geant4Compatibility - * - * @author M.Frank - * @version 1.0 - */ -class Geant4Compatibility { -public: - /// Default constructor - Geant4Compatibility() = default; - /// Default destructor - virtual ~Geant4Compatibility() = default; - /// Detector construction invocation in compatibility mode - Geant4DetectorConstructionSequence* buildDefaultDetectorConstruction(Geant4Kernel& kernel); -}; +#include +#include /// Detector construction invocation in compatibility mode Geant4DetectorConstructionSequence* Geant4Compatibility::buildDefaultDetectorConstruction(Geant4Kernel& kernel) { @@ -531,19 +531,19 @@ Geant4DetectorConstructionSequence* Geant4Compatibility::buildDefaultDetectorCon printout(WARNING, "Geant4Exec", "+++ Building default Geant4DetectorConstruction for single threaded compatibility."); /// Attach first the geometry converter from dd4hep to Geant4 - cr = PluginService::Create("Geant4DetectorGeometryConstruction",ctx,string("ConstructGeometry")); + cr = PluginService::Create("Geant4DetectorGeometryConstruction",ctx,std::string("ConstructGeometry")); det_cr = dynamic_cast(cr); if ( det_cr ) seq->adopt(det_cr); else - throw runtime_error("Panic! Failed to build Geant4DetectorGeometryConstruction."); + throw std::runtime_error("Panic! Failed to build Geant4DetectorGeometryConstruction."); /// Attach the sensitive detector manipulator: - cr = PluginService::Create("Geant4DetectorSensitivesConstruction",ctx,string("ConstructSensitives")); + cr = PluginService::Create("Geant4DetectorSensitivesConstruction",ctx,std::string("ConstructSensitives")); det_cr = dynamic_cast(cr); if ( det_cr ) seq->adopt(det_cr); else - throw runtime_error("Panic! Failed to build Geant4DetectorSensitivesConstruction."); + throw std::runtime_error("Panic! Failed to build Geant4DetectorSensitivesConstruction."); return seq; } @@ -574,7 +574,7 @@ int Geant4Exec::configure(Geant4Kernel& kernel) { /// Get the detector constructed Geant4DetectorConstructionSequence* user_det = kernel.detectorConstruction(false); if ( nullptr == user_det && kernel.isMultiThreaded() ) { - throw runtime_error("Panic! No valid detector construction sequencer present. [Mandatory MT]"); + throw std::runtime_error("Panic! No valid detector construction sequencer present. [Mandatory MT]"); } if ( nullptr == user_det && !kernel.isMultiThreaded() ) { user_det = Geant4Compatibility().buildDefaultDetectorConstruction(kernel); @@ -585,13 +585,13 @@ int Geant4Exec::configure(Geant4Kernel& kernel) { /// Get the physics list constructed Geant4PhysicsListActionSequence* phys_seq = kernel.physicsList(false); if ( nullptr == phys_seq ) { - string phys_model = "QGSP_BERT"; + std::string phys_model = "QGSP_BERT"; phys_seq = kernel.physicsList(true); phys_seq->property("extends").set(phys_model); } G4VUserPhysicsList* physics = phys_seq->extensionList(); if (nullptr == physics) { - throw runtime_error("Panic! No valid user physics list present!"); + throw std::runtime_error("Panic! No valid user physics list present!"); } #if 0 /// Not here: Use seperate object to do this! @@ -606,7 +606,7 @@ int Geant4Exec::configure(Geant4Kernel& kernel) { /// Construct the remaining user initialization in multi-threaded mode Geant4UserInitializationSequence* user_init = kernel.userInitialization(false); if ( nullptr == user_init && kernel.isMultiThreaded() ) { - throw runtime_error("Panic! No valid user initialization sequencer present. [Mandatory MT]"); + throw std::runtime_error("Panic! No valid user initialization sequencer present. [Mandatory MT]"); } else if ( nullptr == user_init && !kernel.isMultiThreaded() ) { /// Use default actions registered to the default kernel. Will do the right thing... @@ -632,7 +632,7 @@ int Geant4Exec::initialize(Geant4Kernel& kernel) { /// Run the simulation int Geant4Exec::run(Geant4Kernel& kernel) { Property& p = kernel.property("UI"); - string value = p.value(); + std::string value = p.value(); kernel.executePhase("start",0); if ( !value.empty() ) { @@ -646,7 +646,7 @@ int Geant4Exec::run(Geant4Kernel& kernel) { } ui->except("++ Geant4Exec: Failed to start UI interface."); } - throw runtime_error(format("Geant4Exec","++ Failed to locate UI interface %s.",value.c_str())); + throw std::runtime_error(format("Geant4Exec","++ Failed to locate UI interface %s.",value.c_str())); } long nevt = kernel.property("NumEvents").value(); kernel.runManager().BeamOn(nevt); diff --git a/DDG4/src/Geant4FastSimShowerModel.cpp b/DDG4/src/Geant4FastSimShowerModel.cpp index de30aa2cd..417bd0ec0 100644 --- a/DDG4/src/Geant4FastSimShowerModel.cpp +++ b/DDG4/src/Geant4FastSimShowerModel.cpp @@ -26,7 +26,6 @@ // C/C++ include files #include -using namespace dd4hep; using namespace dd4hep::sim; /// Namespace for the AIDA detector description toolkit diff --git a/DDG4/src/Geant4GDMLDetector.cpp b/DDG4/src/Geant4GDMLDetector.cpp index a24101659..b7634f2cf 100644 --- a/DDG4/src/Geant4GDMLDetector.cpp +++ b/DDG4/src/Geant4GDMLDetector.cpp @@ -12,7 +12,7 @@ //========================================================================== // Framework include files -#include "DDG4/Geant4GDMLDetector.h" +#include // C/C++ include files #include @@ -23,9 +23,6 @@ #include "G4GDMLParser.hh" #endif -using namespace std; -using namespace dd4hep; - dd4hep::sim::Geant4GDMLDetector::Geant4GDMLDetector(const std::string& gdmlFile) : m_fileName(gdmlFile), m_world(0) { } diff --git a/DDG4/src/Geant4GeneratorAction.cpp b/DDG4/src/Geant4GeneratorAction.cpp index 1d9cfce8c..df31ea3d8 100644 --- a/DDG4/src/Geant4GeneratorAction.cpp +++ b/DDG4/src/Geant4GeneratorAction.cpp @@ -12,16 +12,14 @@ //========================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4GeneratorAction.h" -#include "DDG4/Geant4Kernel.h" +#include +#include +#include + // Geant4 headers -#include "G4Threading.hh" -#include "G4AutoLock.hh" -// C/C++ include files -#include +#include +#include -using namespace std; using namespace dd4hep::sim; namespace { @@ -29,7 +27,7 @@ namespace { } /// Standard constructor -Geant4GeneratorAction::Geant4GeneratorAction(Geant4Context* ctxt, const string& nam) +Geant4GeneratorAction::Geant4GeneratorAction(Geant4Context* ctxt, const std::string& nam) : Geant4Action(ctxt, nam) { InstanceCount::increment(this); } @@ -40,7 +38,7 @@ Geant4GeneratorAction::~Geant4GeneratorAction() { } /// Standard constructor -Geant4SharedGeneratorAction::Geant4SharedGeneratorAction(Geant4Context* ctxt, const string& nam) +Geant4SharedGeneratorAction::Geant4SharedGeneratorAction(Geant4Context* ctxt, const std::string& nam) : Geant4GeneratorAction(ctxt, nam), m_action(0) { InstanceCount::increment(this); @@ -64,7 +62,7 @@ void Geant4SharedGeneratorAction::use(Geant4GeneratorAction* action) { m_action = action; return; } - throw runtime_error("Geant4SharedGeneratorAction: Attempt to use invalid actor!"); + throw std::runtime_error("Geant4SharedGeneratorAction: Attempt to use invalid actor!"); } /// User generator callback @@ -78,7 +76,7 @@ void Geant4SharedGeneratorAction::operator()(G4Event* event) { } /// Standard constructor -Geant4GeneratorActionSequence::Geant4GeneratorActionSequence(Geant4Context* ctxt, const string& nam) +Geant4GeneratorActionSequence::Geant4GeneratorActionSequence(Geant4Context* ctxt, const std::string& nam) : Geant4Action(ctxt, nam) { m_needsControl = true; InstanceCount::increment(this); @@ -104,7 +102,7 @@ void Geant4GeneratorActionSequence::configureFiber(Geant4Context* thread_context } /// Get an action by name -Geant4GeneratorAction* Geant4GeneratorActionSequence::get(const string& nam) const { +Geant4GeneratorAction* Geant4GeneratorActionSequence::get(const std::string& nam) const { return m_actors.get(FindByName(TypeName::split(nam).second)); } @@ -116,7 +114,7 @@ void Geant4GeneratorActionSequence::adopt(Geant4GeneratorAction* action) { m_actors.add(action); return; } - throw runtime_error("Geant4GeneratorActionSequence: Attempt to add invalid actor!"); + except("Attempt to add invalid actor!"); } /// Generator callback diff --git a/DDG4/src/Geant4GeneratorWrapper.cpp b/DDG4/src/Geant4GeneratorWrapper.cpp index 858300e5f..a7ab068e0 100644 --- a/DDG4/src/Geant4GeneratorWrapper.cpp +++ b/DDG4/src/Geant4GeneratorWrapper.cpp @@ -12,30 +12,29 @@ //========================================================================== // Framework include files -#include "DDG4/Geant4GeneratorWrapper.h" +#include -#include "DD4hep/InstanceCount.h" -#include "DD4hep/Plugins.h" -#include "DD4hep/Printout.h" -#include "DDG4/Geant4Context.h" -#include "DDG4/Geant4Primary.h" -#include "DDG4/Geant4InputHandling.h" +#include +#include +#include +#include +#include +#include // Geant4 include files -#include "G4Event.hh" -#include "G4PrimaryVertex.hh" -#include "G4PrimaryParticle.hh" -#include "G4VPrimaryGenerator.hh" +#include +#include +#include +#include // C/C++ include files #include #include using namespace dd4hep::sim; -using namespace std; /// Standard constructor -Geant4GeneratorWrapper::Geant4GeneratorWrapper(Geant4Context* ctxt, const string& nam) +Geant4GeneratorWrapper::Geant4GeneratorWrapper(Geant4Context* ctxt, const std::string& nam) : Geant4GeneratorAction(ctxt,nam), m_generator(0) { declareProperty("Uses", m_generatorType); @@ -56,8 +55,8 @@ G4VPrimaryGenerator* Geant4GeneratorWrapper::generator() { PluginDebug dbg; m_generator = PluginService::Create(m_generatorType); if ( !m_generator ) { - throw runtime_error("Geant4GeneratorWrapper: FATAL Failed to " - "create G4VPrimaryGenerator of type " + m_generatorType + "."); + except("Geant4GeneratorWrapper: FATAL Failed to create G4VPrimaryGenerator of type %s.", + m_generatorType.c_str()); } } } @@ -68,7 +67,7 @@ G4VPrimaryGenerator* Geant4GeneratorWrapper::generator() { void Geant4GeneratorWrapper::operator()(G4Event* event) { Geant4PrimaryEvent* prim = context()->event().extension(); Geant4PrimaryMap* primaryMap = context()->event().extension(); - set primaries; + std::set primaries; // Now generate the new interaction generator()->GeneratePrimaryVertex(event); diff --git a/DDG4/src/Geant4GeometryInfo.cpp b/DDG4/src/Geant4GeometryInfo.cpp index 84639f29e..666df2fa8 100644 --- a/DDG4/src/Geant4GeometryInfo.cpp +++ b/DDG4/src/Geant4GeometryInfo.cpp @@ -12,21 +12,17 @@ //========================================================================== // Framework include files -#include "DDG4/Geant4GeometryInfo.h" -#include "DDG4/Geant4AssemblyVolume.h" +#include +#include +#include // Geant4 include files -#include "G4VPhysicalVolume.hh" +#include -// C/C++ include files -#include - -using namespace std; using namespace dd4hep::sim; - -string Geant4GeometryInfo::placementPath(const Geant4PlacementPath& path, bool reverse) { - string path_name; +std::string Geant4GeometryInfo::placementPath(const Geant4PlacementPath& path, bool reverse) { + std::string path_name; if ( reverse ) { for (Geant4PlacementPath::const_reverse_iterator pIt = path.rbegin(); pIt != path.rend(); ++pIt) { path_name += "/"; path_name += (*pIt)->GetName(); @@ -55,7 +51,8 @@ Geant4GeometryInfo::~Geant4GeometryInfo() { /// The world placement G4VPhysicalVolume* Geant4GeometryInfo::world() const { if ( m_world ) return m_world; - throw runtime_error("Geant4GeometryInfo: Attempt to access invalid world placement"); + except("Geant4GeometryInfo", "Attempt to access invalid world placement"); + return m_world; } /// Set the world placement @@ -63,7 +60,7 @@ void Geant4GeometryInfo::setWorld(const TGeoNode* node) { Geant4GeometryMaps::PlacementMap::const_iterator g4it = g4Placements.find(node); G4VPhysicalVolume* g4 = (g4it == g4Placements.end()) ? 0 : (*g4it).second; if (!g4) { - throw runtime_error("Geant4GeometryInfo: Attempt to SET invalid world placement"); + except("Geant4GeometryInfo", "Attempt to SET invalid world placement"); } m_world = g4; } diff --git a/DDG4/src/Geant4Handle.cpp b/DDG4/src/Geant4Handle.cpp index caaac4956..25a73c67c 100644 --- a/DDG4/src/Geant4Handle.cpp +++ b/DDG4/src/Geant4Handle.cpp @@ -12,33 +12,28 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/Plugins.h" -#include "DD4hep/Printout.h" - -#include "DDG4/Geant4Handle.h" -#include "DDG4/Geant4Kernel.h" -#include "DDG4/Geant4GeneratorAction.h" -#include "DDG4/Geant4RunAction.h" -#include "DDG4/Geant4EventAction.h" -#include "DDG4/Geant4TrackingAction.h" -#include "DDG4/Geant4SteppingAction.h" -#include "DDG4/Geant4StackingAction.h" -#include "DDG4/Geant4SensDetAction.h" -#include "DDG4/Geant4PhysicsList.h" -#include "DDG4/Geant4ActionPhase.h" -#include "DDG4/Geant4UserInitialization.h" -#include "DDG4/Geant4DetectorConstruction.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // Geant4 include files -#include "G4Threading.hh" -#include "G4AutoLock.hh" +#include +#include -// C/C++ include files -#include - -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; namespace { G4Mutex creation_mutex=G4MUTEX_INITIALIZER; @@ -47,7 +42,6 @@ namespace { namespace dd4hep { namespace sim { - template static inline TYPE* checked_value(TYPE* p) { if (p) { return p; @@ -77,14 +71,14 @@ namespace dd4hep { Geant4Context* ctxt = kernel.workerContext(); Geant4Action* object = PluginService::Create(typ.first, ctxt, typ.second); if (!object && typ.first == typ.second) { - string _t = typeName(typeid(TYPE)); + std::string _t = typeName(typeid(TYPE)); printout(DEBUG, "Geant4Handle", "Object factory for %s not found. Try out %s", typ.second.c_str(), _t.c_str()); object = PluginService::Create(_t, ctxt, typ.second); if (!object) { size_t idx = _t.rfind(':'); - if (idx != string::npos) - _t = string(_t.substr(idx + 1)); + if (idx != std::string::npos) + _t = std::string(_t.substr(idx + 1)); printout(DEBUG, "Geant4Handle", "Try out object factory for %s",_t.c_str()); object = PluginService::Create(_t, ctxt, typ.second); } @@ -104,8 +98,8 @@ namespace dd4hep { template TYPE* _create_share(Geant4Kernel& kernel, CONT& (Geant4ActionContainer::*pmf)(), - const string& type_name, - const string& shared_typ, + const std::string& type_name, + const std::string& shared_typ, bool shared, TYPE*) { TypeName typ = TypeName::split(type_name); @@ -135,7 +129,7 @@ namespace dd4hep { } template - Geant4Handle::Geant4Handle(Geant4Kernel& kernel, const string& type_name, bool /* shared */) { + Geant4Handle::Geant4Handle(Geant4Kernel& kernel, const std::string& type_name, bool /* shared */) { value = _create_object(kernel,TypeName::split(type_name)); } @@ -164,7 +158,7 @@ namespace dd4hep { value->addRef(); } - template Property& Geant4Handle::operator[](const string& property_name) const { + template Property& Geant4Handle::operator[](const std::string& property_name) const { PropertyManager& pm = checked_value(value)->properties(); return pm[property_name]; } @@ -238,7 +232,7 @@ namespace dd4hep { } template <> - Geant4Handle::Geant4Handle(Geant4Kernel& kernel, const string& type_name, bool shared) { + Geant4Handle::Geant4Handle(Geant4Kernel& kernel, const std::string& type_name, bool shared) { value = _create_share(kernel,&Geant4ActionContainer::runAction, type_name, "Geant4SharedRunAction", shared, null()); } @@ -249,7 +243,7 @@ namespace dd4hep { } template <> - Geant4Handle::Geant4Handle(Geant4Kernel& kernel, const string& type_name, bool shared) { + Geant4Handle::Geant4Handle(Geant4Kernel& kernel, const std::string& type_name, bool shared) { value = _create_share(kernel,&Geant4ActionContainer::eventAction, type_name, "Geant4SharedEventAction", shared, null()); } @@ -260,7 +254,7 @@ namespace dd4hep { } template <> - Geant4Handle::Geant4Handle(Geant4Kernel& kernel, const string& type_name, bool shared) { + Geant4Handle::Geant4Handle(Geant4Kernel& kernel, const std::string& type_name, bool shared) { value = _create_share(kernel,&Geant4ActionContainer::generatorAction, type_name, "Geant4SharedGeneratorAction", shared, null()); } @@ -271,7 +265,7 @@ namespace dd4hep { } template <> - Geant4Handle::Geant4Handle(Geant4Kernel& kernel, const string& type_name, bool shared) { + Geant4Handle::Geant4Handle(Geant4Kernel& kernel, const std::string& type_name, bool shared) { value = _create_share(kernel,&Geant4ActionContainer::trackingAction, type_name, "Geant4SharedTrackingAction", shared, null()); } @@ -282,7 +276,7 @@ namespace dd4hep { } template <> - Geant4Handle::Geant4Handle(Geant4Kernel& kernel, const string& type_name, bool shared) { + Geant4Handle::Geant4Handle(Geant4Kernel& kernel, const std::string& type_name, bool shared) { value = _create_share(kernel,&Geant4ActionContainer::steppingAction, type_name, "Geant4SharedSteppingAction", shared, null()); } @@ -293,7 +287,7 @@ namespace dd4hep { } template <> - Geant4Handle::Geant4Handle(Geant4Kernel& kernel, const string& type_name, bool shared) { + Geant4Handle::Geant4Handle(Geant4Kernel& kernel, const std::string& type_name, bool shared) { value = _create_share(kernel,&Geant4ActionContainer::stackingAction, type_name, "Geant4SharedStackingAction", shared, null()); } @@ -303,8 +297,8 @@ namespace dd4hep { "Geant4SharedStackingAction", shared, null()); } - template <> Geant4Handle::Geant4Handle(Geant4Kernel& kernel, const string& type_name, - const string& detector, bool /* shared */) { + template <> Geant4Handle::Geant4Handle(Geant4Kernel& kernel, const std::string& type_name, + const std::string& detector, bool /* shared */) { try { Geant4Context* ctxt = kernel.workerContext(); TypeName typ = TypeName::split(type_name); @@ -316,7 +310,7 @@ namespace dd4hep { return; } } - catch (const exception& e) { + catch (const std::exception& e) { printout(ERROR, "Geant4Handle", "Exception: %s", e.what()); } catch (...) { diff --git a/DDG4/src/Geant4HierarchyDump.cpp b/DDG4/src/Geant4HierarchyDump.cpp index 190d3480f..faa790e03 100644 --- a/DDG4/src/Geant4HierarchyDump.cpp +++ b/DDG4/src/Geant4HierarchyDump.cpp @@ -12,47 +12,47 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/Plugins.h" -#include "DD4hep/Volumes.h" -#include "DD4hep/Printout.h" -#include "DDG4/Geant4HierarchyDump.h" +#include +#include +#include +#include +#include // Geant4 include files -#include "G4Version.hh" -#include "G4VisAttributes.hh" -#include "G4ProductionCuts.hh" -#include "G4VUserRegionInformation.hh" -#include "G4Element.hh" -#include "G4SDManager.hh" +#include +#include +#include +#include +#include +#include -#include "G4AssemblyVolume.hh" -#include "G4Box.hh" -#include "G4Trd.hh" -#include "G4Tubs.hh" -#include "G4Cons.hh" -#include "G4Torus.hh" -#include "G4Sphere.hh" -#include "G4Polycone.hh" -#include "G4Polyhedra.hh" -#include "G4UnionSolid.hh" -#include "G4Paraboloid.hh" -#include "G4SubtractionSolid.hh" -#include "G4IntersectionSolid.hh" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "G4Region.hh" -#include "G4UserLimits.hh" -#include "G4VSensitiveDetector.hh" +#include +#include +#include -#include "G4LogicalVolume.hh" -#include "G4Material.hh" -#include "G4Element.hh" -#include "G4Isotope.hh" -#include "G4Transform3D.hh" -#include "G4ThreeVector.hh" -#include "G4PVPlacement.hh" -#include "G4ElectroMagneticField.hh" -#include "G4FieldManager.hh" +#include +#include +#include +#include +#include +#include +#include +#include +#include // C/C++ include files #include @@ -60,8 +60,6 @@ #include using namespace dd4hep::sim; -using namespace dd4hep; -using namespace std; static const char* _T(const std::string& str) { return str.c_str(); @@ -78,7 +76,7 @@ Geant4HierarchyDump::Geant4HierarchyDump(Detector& description, unsigned long fl Geant4HierarchyDump::~Geant4HierarchyDump() { } -void Geant4HierarchyDump::dump(const string& indent, const G4VPhysicalVolume* v) const { +void Geant4HierarchyDump::dump(const std::string& indent, const G4VPhysicalVolume* v) const { G4LogicalVolume* lv = v->GetLogicalVolume(); G4VSensitiveDetector* sd = lv->GetSensitiveDetector(); G4RotationMatrix* rot = v->GetObjectRotation(); @@ -87,7 +85,7 @@ void Geant4HierarchyDump::dump(const string& indent, const G4VPhysicalVolume* v) G4Region* rg = lv->GetRegion(); G4UserLimits* ul = lv->GetUserLimits(); G4int ndau = lv->GetNoDaughters(); - stringstream str; + std::stringstream str; char text[32]; printout(INFO, "Geant4Hierarchy", "%s -> Placement:%s LV:%s Material:%s Solid:%s # of Daughters:%d CopyNo:%d", diff --git a/DDG4/src/Geant4HitCollection.cpp b/DDG4/src/Geant4HitCollection.cpp index 6c18230d0..0f93da6a1 100644 --- a/DDG4/src/Geant4HitCollection.cpp +++ b/DDG4/src/Geant4HitCollection.cpp @@ -12,12 +12,11 @@ //========================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4HitCollection.h" -#include "DDG4/Geant4Data.h" -#include "G4Allocator.hh" +#include +#include +#include +#include -using namespace dd4hep; using namespace dd4hep::sim; G4ThreadLocal G4Allocator* HitWrapperAllocator = 0; @@ -85,12 +84,12 @@ Geant4HitCollection::~Geant4HitCollection() { } /// Type information of the object stored -const ComponentCast& Geant4HitCollection::type() const { +const dd4hep::ComponentCast& Geant4HitCollection::type() const { return m_manipulator->cast; } /// Type information of the vector type for extracting data -const ComponentCast& Geant4HitCollection::vector_type() const { +const dd4hep::ComponentCast& Geant4HitCollection::vector_type() const { return m_manipulator->vec_type; } diff --git a/DDG4/src/Geant4HitHandler.cpp b/DDG4/src/Geant4HitHandler.cpp index 4cac25dd4..456d5bcb6 100644 --- a/DDG4/src/Geant4HitHandler.cpp +++ b/DDG4/src/Geant4HitHandler.cpp @@ -19,44 +19,43 @@ // Geant4 include files #include -using namespace dd4hep; using namespace dd4hep::sim; /// Coordinate transformation to global coordinate. -Position Geant4HitHandler::localToGlobal(const DDSegmentation::Vector3D& local) const { +dd4hep::Position Geant4HitHandler::localToGlobal(const DDSegmentation::Vector3D& local) const { return localToGlobal(G4ThreeVector(local.X / dd4hep::mm,local.Y / dd4hep::mm,local.Z / dd4hep::mm)); } /// Coordinate transformation to global coordinates. -Position Geant4HitHandler::localToGlobal(const Position& local) const { +dd4hep::Position Geant4HitHandler::localToGlobal(const Position& local) const { return localToGlobal(G4ThreeVector(local.X(),local.Y(),local.Z())); } /// Coordinate transformation to global coordinates -Position Geant4HitHandler::localToGlobal(double x, double y, double z) const { +dd4hep::Position Geant4HitHandler::localToGlobal(double x, double y, double z) const { return localToGlobal(G4ThreeVector(x,y,z)); } /// Coordinate transformation to global coordinates -Position Geant4HitHandler::localToGlobal(const G4ThreeVector& loc) const { +dd4hep::Position Geant4HitHandler::localToGlobal(const G4ThreeVector& loc) const { G4ThreeVector p = touchable_ptr->GetHistory()->GetTopTransform().Inverse().TransformPoint(loc); return Position(p.x(),p.y(),p.z()); } /// Coordinate transformation to local coordinates -Position Geant4HitHandler::globalToLocal(double x, double y, double z) const { +dd4hep::Position Geant4HitHandler::globalToLocal(double x, double y, double z) const { G4ThreeVector p = globalToLocalG4(G4ThreeVector(x,y,z)); return Position(p.x(),p.y(),p.z()); } /// Coordinate transformation to local coordinates -Position Geant4HitHandler::globalToLocal(const Position& global) const { +dd4hep::Position Geant4HitHandler::globalToLocal(const Position& global) const { G4ThreeVector p = globalToLocalG4(G4ThreeVector(global.X(),global.Y(),global.Z())); return Position(p.x(),p.y(),p.z()); } /// Coordinate transformation to local coordinates -Position Geant4HitHandler::globalToLocal(const G4ThreeVector& global) const { +dd4hep::Position Geant4HitHandler::globalToLocal(const G4ThreeVector& global) const { G4ThreeVector p = globalToLocalG4(global); return Position(p.x(),p.y(),p.z()); } diff --git a/DDG4/src/Geant4InputAction.cpp b/DDG4/src/Geant4InputAction.cpp index 05dfd7b5d..04917c45c 100644 --- a/DDG4/src/Geant4InputAction.cpp +++ b/DDG4/src/Geant4InputAction.cpp @@ -13,20 +13,19 @@ //==================================================================== // Framework include files -#include "DD4hep/Memory.h" -#include "DD4hep/Plugins.h" -#include "DDG4/Geant4Primary.h" -#include "DDG4/Geant4Context.h" -#include "DDG4/Geant4Kernel.h" -#include "DDG4/Geant4InputAction.h" -#include "DDG4/Geant4RunAction.h" +#include +#include +#include +#include +#include +#include +#include -#include "G4Event.hh" +#include -using namespace std; using namespace dd4hep::sim; -typedef dd4hep::detail::ReferenceBitMask PropertyMask; -typedef Geant4InputAction::Vertices Vertices ; +using Vertices = Geant4InputAction::Vertices; +using PropertyMask = dd4hep::detail::ReferenceBitMask; /// Initializing constructor @@ -118,7 +117,7 @@ Geant4EventReader::moveToEvent(int /* event_number */) { #endif /// Standard constructor -Geant4InputAction::Geant4InputAction(Geant4Context* ctxt, const string& nam) +Geant4InputAction::Geant4InputAction(Geant4Context* ctxt, const std::string& nam) : Geant4GeneratorAction(ctxt,nam), m_reader(0), m_currentEventNumber(0) { declareProperty("Input", m_input); @@ -148,7 +147,7 @@ void Geant4InputAction::createReader() { if ( m_input.empty() ) { except("InputAction: No input file declared!"); } - string err; + std::string err; TypeName tn = TypeName::split(m_input,"|"); try { m_reader = PluginService::Create(tn.first,tn.second); @@ -163,7 +162,7 @@ void Geant4InputAction::createReader() { m_reader->checkParameters( m_parameters ); m_reader->setInputAction( this ); m_reader->registerRunParameters(); - } catch(const exception& e) { + } catch(const std::exception& e) { err = e.what(); } if ( !err.empty() ) { @@ -173,8 +172,8 @@ void Geant4InputAction::createReader() { /// helper to report Geant4 exceptions -string Geant4InputAction::issue(int i) const { - stringstream str; +std::string Geant4InputAction::issue(int i) const { + std::stringstream str; str << "Geant4InputAction[" << name() << "]: Event " << i << " "; return str.str(); } @@ -197,7 +196,7 @@ int Geant4InputAction::readParticles(int evt_number, } if ( Geant4EventReader::EVENT_READER_OK != status ) { - string msg = issue(evid)+"Error when moving to event - "; + std::string msg = issue(evid)+"Error when moving to event - "; if ( status == Geant4EventReader::EVENT_READER_EOF ) msg += " EOF: [end of file]."; else msg += " Unknown error condition"; if ( m_abort ) { @@ -217,9 +216,8 @@ int Geant4InputAction::readParticles(int evt_number, } } - if ( Geant4EventReader::EVENT_READER_OK != status ) { - string msg = issue(evid)+"Error when moving to event - "; + std::string msg = issue(evid)+"Error when moving to event - "; if ( status == Geant4EventReader::EVENT_READER_EOF ) msg += " EOF: [end of file]."; else msg += " Unknown error condition"; if ( m_abort ) { @@ -234,7 +232,7 @@ int Geant4InputAction::readParticles(int evt_number, /// Callback to generate primary particles void Geant4InputAction::operator()(G4Event* event) { - vector primaries; + std::vector primaries; Geant4Event& evt = context()->event(); Geant4PrimaryEvent* prim = evt.extension(); Vertices vertices ; diff --git a/DDG4/src/Geant4InputHandling.cpp b/DDG4/src/Geant4InputHandling.cpp index 84c1a7a81..61d80dfac 100644 --- a/DDG4/src/Geant4InputHandling.cpp +++ b/DDG4/src/Geant4InputHandling.cpp @@ -30,12 +30,8 @@ #include #include -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; - -typedef detail::ReferenceBitMask PropertyMask; - +using PropertyMask = dd4hep::detail::ReferenceBitMask; /// Create a vertex object from the Geant4 primary vertex Geant4Vertex* dd4hep::sim::createPrimary(const G4PrimaryVertex* g4) { @@ -210,8 +206,8 @@ static void rebaseParticles(Geant4PrimaryInteraction::ParticleMap& particles, in static void rebaseVertices(Geant4PrimaryInteraction::VertexMap& vertices, int part_offset) { Geant4PrimaryInteraction::VertexMap::iterator iv, ivend; - set in, out; - set::iterator i; + std::set in, out; + std::set::iterator i; // Now move begin and end-vertex of all primary vertices accordingly for(iv=vertices.begin(), ivend=vertices.end(); iv != ivend; ++iv) { for( Geant4Vertex* v : (*iv).second ){ @@ -229,7 +225,7 @@ int dd4hep::sim::mergeInteractions(const Geant4Action* caller, const Geant4Context* context) { typedef Geant4PrimaryEvent::Interaction Interaction; - typedef vector Interactions; + typedef std::vector Interactions; Geant4Event& event = context->event(); Geant4PrimaryEvent* evt = event.extension(); Interaction* output = event.extension(); @@ -365,14 +361,16 @@ static G4PrimaryParticle* createG4Primary(const Geant4ParticleHandle p) { return g4; } -static vector< pair > -getRelevant(set& visited, - map& prim, +static std::vector< std::pair > +getRelevant(std::set& visited, + std::map& prim, Geant4PrimaryInteraction::ParticleMap& pm, const Geant4PrimaryConfig& primaryConfig, const Geant4ParticleHandle p) { - typedef vector< pair > Primaries; + typedef std::vector< std::pair > Primaries; + using dd4hep::printout; + Primaries res; visited.insert(p->id); PropertyMask status(p->status); @@ -413,13 +411,13 @@ getRelevant(set& visited, // end running simulation if we have a really inconsistent record, that is unrejected stable particle with children bool failStableWithChildren = (not rejectParticle and p.definition()->GetPDGStable()); if (failStableWithChildren) { - printout(FATAL,"Input", + printout(dd4hep::FATAL,"Input", "+++ Stable particle (PDG: %-10d) with daughters! check your MC record, adapt particle.tbl file...", p->pdgID); throw std::runtime_error("Cannot Simmulate this MC Record"); } if (not rejectParticle) { - map::iterator ip4 = prim.find(p->id); + std::map::iterator ip4 = prim.find(p->id); G4PrimaryParticle* p4 = (ip4 == prim.end()) ? 0 : (*ip4).second; if ( !p4 ) { p4 = createG4Primary(p); @@ -454,14 +452,14 @@ int dd4hep::sim::generatePrimaries(const Geant4Action* caller, const Geant4Context* context, G4Event* event) { - typedef vector< pair > Primaries; + typedef std::vector< std::pair > Primaries; typedef Geant4PrimaryInteraction Interaction; Geant4PrimaryMap* primaries = context->event().extension(); Interaction* interaction = context->event().extension(); Interaction::ParticleMap& pm = interaction->particles; Interaction::VertexMap& vm = interaction->vertices; - map prim; - set visited; + std::map prim; + std::set visited; auto const* primHandler = dynamic_cast(caller); auto const& primaryConfig = primHandler ? primHandler->m_primaryConfig : Geant4PrimaryConfig(); @@ -510,9 +508,9 @@ int dd4hep::sim::generatePrimaries(const Geant4Action* caller, } } } - for(map::iterator i=prim.begin(); i!=prim.end(); ++i) { - Geant4ParticleHandle p = pm[(*i).first]; - primaries->insert((*i).second,p); + for( const auto& vtx : prim ) { + Geant4ParticleHandle p = pm[vtx.first]; + primaries->insert(vtx.second, p); } } return 1; diff --git a/DDG4/src/Geant4IsotropeGenerator.cpp b/DDG4/src/Geant4IsotropeGenerator.cpp index b549442f7..84dc9eda9 100644 --- a/DDG4/src/Geant4IsotropeGenerator.cpp +++ b/DDG4/src/Geant4IsotropeGenerator.cpp @@ -12,16 +12,15 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4Random.h" -#include "DDG4/Geant4IsotropeGenerator.h" +#include +#include +#include +#include -using namespace std; using namespace dd4hep::sim; /// Standard constructor -Geant4IsotropeGenerator::Geant4IsotropeGenerator(Geant4Context* ctxt, const string& nam) +Geant4IsotropeGenerator::Geant4IsotropeGenerator(Geant4Context* ctxt, const std::string& nam) : Geant4ParticleGenerator(ctxt, nam) { InstanceCount::increment(this); diff --git a/DDG4/src/Geant4Kernel.cpp b/DDG4/src/Geant4Kernel.cpp index 64c1f2c2b..c2f2e2d09 100644 --- a/DDG4/src/Geant4Kernel.cpp +++ b/DDG4/src/Geant4Kernel.cpp @@ -30,12 +30,10 @@ #include // C/C++ include files -#include #include #include #include -using namespace std; using namespace dd4hep::sim; namespace { @@ -44,16 +42,17 @@ namespace { void description_unexpected() { try { throw; - } catch( exception& e ) { - cout << "\n" + } + catch( std::exception& e ) { + std::cout << "\n" << "**************************************************** \n" << "* A runtime error has occured : \n" - << "* " << e.what() << endl + << "* " << e.what() << std::endl << "* the program will have to be terminated - sorry. \n" << "**************************************************** \n" - << endl ; + << std::endl; // this provokes ROOT seg fault and stack trace (comment out to avoid it) - exit(1) ; + ::exit(1) ; } } } @@ -80,7 +79,7 @@ Geant4Kernel::PhaseSelector& Geant4Kernel::PhaseSelector::operator=(const PhaseS Geant4ActionPhase& Geant4Kernel::PhaseSelector::operator[](const std::string& nam) const { if( Geant4ActionPhase* action_phase = m_kernel->getPhase(nam) ) return *action_phase; - throw runtime_error(format("Geant4Kernel", "Attempt to access the nonexisting phase '%s'", nam.c_str())); + throw except("Geant4Kernel", "Attempt to access the nonexisting phase '%s'", nam.c_str()); } /// Standard constructor @@ -186,7 +185,8 @@ Geant4Kernel& Geant4Kernel::createWorker() { printout(INFO,"Geant4Kernel","+++ Created worker instance id=%ul",identifier); return *w; } - throw runtime_error(format("Geant4Kernel", "DDG4: Only the master instance may create workers.")); + except("Geant4Kernel", "DDG4: Only the master instance may create workers."); + throw std::runtime_error("Geant4Kernel::createWorker"); } /// Access worker instance by its identifier @@ -206,7 +206,8 @@ Geant4Kernel& Geant4Kernel::worker(unsigned long identifier, bool create_if) else if ( create_if ) { return createWorker(); } - throw runtime_error(format("Geant4Kernel", "DDG4: The Kernel object 0x%p does not exists!",(void*)identifier)); + except("Geant4Kernel", "DDG4: The Kernel object 0x%p does not exists!",(void*)identifier); + throw std::runtime_error("Geant4Kernel::worker"); } /// Access number of workers @@ -273,7 +274,7 @@ G4RunManager& Geant4Kernel::runManager() { Geant4Action* mgr = PluginService::Create(m_runManagerType, m_context, - string("Geant4RunManager")); + std::string("Geant4RunManager")); if ( !mgr ) { except("Geant4Kernel", "+++ Invalid Geant4RunManager class: %s. Aborting.", @@ -291,7 +292,7 @@ G4RunManager& Geant4Kernel::runManager() { } except("Geant4Kernel", "+++ Only the master thread may instantiate a G4RunManager object!"); - throw runtime_error("Is never called -- just to satisfy compiler!"); + throw std::runtime_error("Is never called -- just to satisfy compiler!"); } /// Construct detector geometry using description plugin @@ -352,7 +353,7 @@ int Geant4Kernel::run() { G4cout << G4endl; return result; } - catch(const exception& e) { + catch(const std::exception& e) { printout(FATAL,"Geant4Kernel","+++ Exception while simulating:%s",e.what()); } catch(...) { @@ -397,7 +398,7 @@ int Geant4Kernel::terminate() { */ Geant4Kernel& Geant4Kernel::registerGlobalAction(Geant4Action* action) { if( action ) { - const string& nam = action->name(); + const std::string& nam = action->name(); if( auto i=m_globalActions.find(nam); i == m_globalActions.end() ) { action->addRef(); m_globalActions[nam] = action; @@ -419,7 +420,7 @@ Geant4Action* Geant4Kernel::globalAction(const std::string& nam, bool throw_if_n return (*i).second; if( throw_if_not_present ) { except("Geant4Kernel", "DDG4: The action '%s' is not globally " - "registered. [Action-Missing]", nam.c_str()); + "registered. [Action-Missing]", nam.c_str()); } return nullptr; } @@ -431,7 +432,7 @@ Geant4Action* Geant4Kernel::globalAction(const std::string& nam, bool throw_if_n */ Geant4Kernel& Geant4Kernel::registerGlobalFilter(Geant4Action* filter) { if( filter ) { - const string& nam = filter->name(); + const std::string& nam = filter->name(); if( auto i=m_globalFilters.find(nam); i == m_globalFilters.end()) { filter->addRef(); m_globalFilters[nam] = filter; @@ -451,7 +452,7 @@ Geant4Action* Geant4Kernel::globalFilter(const std::string& filter_name, bool th return (*i).second; if (throw_if_not_present) { except("Geant4Kernel", "DDG4: The filter '%s' is not already globally " - "registered. [Filter-Missing]", filter_name.c_str()); + "registered. [Filter-Missing]", filter_name.c_str()); } return nullptr; } @@ -479,8 +480,12 @@ Geant4ActionPhase* Geant4Kernel::addSimplePhase(const std::string& name, bool th } /// Add a new phase -Geant4ActionPhase* Geant4Kernel::addPhase(const std::string& nam, const type_info& arg0, const type_info& arg1, - const type_info& arg2, bool throw_on_exist) { +Geant4ActionPhase* Geant4Kernel::addPhase(const std::string& nam, + const std::type_info& arg0, + const std::type_info& arg1, + const std::type_info& arg2, + bool throw_on_exist) +{ if( auto i=m_phases.find(nam); i == m_phases.end() ) { Geant4ActionPhase* p = new Geant4ActionPhase(workerContext(), nam, arg0, arg1, arg2); m_phases.emplace(nam, p); diff --git a/DDG4/src/Geant4Mapping.cpp b/DDG4/src/Geant4Mapping.cpp index 5582b9b3e..490f8bd71 100644 --- a/DDG4/src/Geant4Mapping.cpp +++ b/DDG4/src/Geant4Mapping.cpp @@ -12,16 +12,12 @@ //========================================================================== // Framework include files -#include "DDG4/Geant4Mapping.h" - -#include "DD4hep/Printout.h" -#include "DD4hep/VolumeManager.h" -#include "G4PVPlacement.hh" -#include +#include +#include +#include +#include using namespace dd4hep::sim; -using namespace dd4hep; -using namespace std; /// Initializing Constructor Geant4Mapping::Geant4Mapping(const Detector& description_ref) @@ -45,7 +41,7 @@ Geant4Mapping& Geant4Mapping::instance() { void Geant4Mapping::checkValidity() const { if (m_dataPtr) return; - throw runtime_error("Geant4Mapping: Attempt to access an invalid data block!"); + except("Geant4Mapping", "Attempt to access an invalid data block!"); } /// Create new data block. Delete old data block if present. @@ -77,11 +73,12 @@ Geant4VolumeManager Geant4Mapping::volumeManager() const { } return Geant4VolumeManager(Handle < Geant4GeometryInfo > (m_dataPtr)); } - throw runtime_error(format("Geant4Mapping", "Cannot create volume manager without Geant4 geometry info [Invalid-Info]")); + except("Geant4Mapping", "Cannot create volume manager without Geant4 geometry info [Invalid-Info]"); + return {}; } /// Accessor to resolve geometry placements -PlacedVolume Geant4Mapping::placement(const G4VPhysicalVolume* node) const { +dd4hep::PlacedVolume Geant4Mapping::placement(const G4VPhysicalVolume* node) const { checkValidity(); const Geant4GeometryMaps::PlacementMap& pm = m_dataPtr->g4Placements; for( const auto& entry : pm ) { diff --git a/DDG4/src/Geant4Output2ROOT.cpp b/DDG4/src/Geant4Output2ROOT.cpp index 9aae89e22..92490ca10 100644 --- a/DDG4/src/Geant4Output2ROOT.cpp +++ b/DDG4/src/Geant4Output2ROOT.cpp @@ -33,11 +33,9 @@ using namespace dd4hep::sim; -using namespace dd4hep; -using namespace std; /// Standard constructor -Geant4Output2ROOT::Geant4Output2ROOT(Geant4Context* ctxt, const string& nam) +Geant4Output2ROOT::Geant4Output2ROOT(Geant4Context* ctxt, const std::string& nam) : Geant4OutputAction(ctxt, nam), m_file(nullptr), m_tree(nullptr) { declareProperty("Section", m_section = "EVENT"); declareProperty("HandleMCTruth", m_handleMCTruth = true); @@ -70,7 +68,7 @@ void Geant4Output2ROOT::closeOutput() { } /// Create/access tree by name -TTree* Geant4Output2ROOT::section(const string& nam) { +TTree* Geant4Output2ROOT::section(const std::string& nam) { Sections::const_iterator i = m_sections.find(nam); if (i == m_sections.end()) { TDirectory::TContext ctxt(m_file); @@ -83,7 +81,7 @@ TTree* Geant4Output2ROOT::section(const string& nam) { /// Callback to store the Geant4 run information void Geant4Output2ROOT::beginRun(const G4Run* run) { - string fname = m_output; + std::string fname = m_output; if ( m_filesByRun ) { size_t idx = m_output.rfind("."); if ( m_file ) { @@ -91,7 +89,7 @@ void Geant4Output2ROOT::beginRun(const G4Run* run) { } fname = m_output.substr(0, idx); fname += _toString(run->GetRunID(), ".run%08d"); - if ( idx != string::npos ) + if ( idx != std::string::npos ) fname += m_output.substr(idx); } if ( !m_file && !fname.empty() ) { @@ -117,7 +115,7 @@ void Geant4Output2ROOT::beginRun(const G4Run* run) { } /// Fill single EVENT branch entry (Geant4 collection data) -int Geant4Output2ROOT::fill(const string& nam, const ComponentCast& type, void* ptr) { +int Geant4Output2ROOT::fill(const std::string& nam, const ComponentCast& type, void* ptr) { if (m_file) { TBranch* b = 0; Branches::const_iterator i = m_branches.find(nam); @@ -130,7 +128,7 @@ int Geant4Output2ROOT::fill(const string& nam, const ComponentCast& type, void* m_branches.emplace(nam, b); } else { - throw runtime_error("No ROOT TClass object availible for object type:" + typeName(typ)); + throw std::runtime_error("No ROOT TClass object availible for object type:" + typeName(typ)); } } else { @@ -147,7 +145,7 @@ int Geant4Output2ROOT::fill(const string& nam, const ComponentCast& type, void* b->SetAddress(&ptr); int nbytes = b->Fill(); if (nbytes < 0) { - throw runtime_error("Failed to write ROOT collection:" + nam + "!"); + throw std::runtime_error("Failed to write ROOT collection:" + nam + "!"); } return nbytes; } @@ -188,12 +186,12 @@ void Geant4Output2ROOT::saveEvent(OutputContext& /* ctxt */) { Manip* manipulator = Geant4HitWrapper::manipulator(); G4ParticleTable* table = G4ParticleTable::GetParticleTable(); const ParticleMap& pm = parts->particles(); - vector particles; + std::vector particles; particles.reserve(pm.size()); for ( const auto& i : pm ) { - auto* p = i.second; - G4ParticleDefinition* def = table->FindParticle(p->pdgID); - p->charge = int(3.0 * (def ? def->GetPDGCharge() : -1.0)); // Assume e-/pi- + auto* p = i.second; + G4ParticleDefinition* def = table->FindParticle(p->pdgID); + p->charge = int(3.0 * (def ? def->GetPDGCharge() : -1.0)); // Assume e-/pi- particles.emplace_back((ParticleMap::mapped_type*)p); } fill("MCParticles",manipulator->vec_type,&particles); @@ -204,14 +202,14 @@ void Geant4Output2ROOT::saveEvent(OutputContext& /* ctxt */) { /// Callback to store each Geant4 hit collection void Geant4Output2ROOT::saveCollection(OutputContext& /* ctxt */, G4VHitsCollection* collection) { Geant4HitCollection* coll = dynamic_cast(collection); - string hc_nam = collection->GetName(); + std::string hc_nam = collection->GetName(); for(const auto& n : m_disabledCollections) { if ( n == hc_nam ) { return; } } if (coll) { - vector hits; + std::vector hits; coll->getHitsUnchecked(hits); size_t nhits = coll->GetSize(); if ( m_handleMCTruth && m_truth && nhits > 0 ) { @@ -237,7 +235,7 @@ void Geant4Output2ROOT::saveCollection(OutputContext& /* ctxt */, G4VHi } } catch(...) { - printout(ERROR,name(),"+++ Exception while saving collection %s.",hc_nam.c_str()); + error("+++ Exception while saving collection %s.",hc_nam.c_str()); } } fill(hc_nam, coll->vector_type(), &hits); diff --git a/DDG4/src/Geant4OutputAction.cpp b/DDG4/src/Geant4OutputAction.cpp index a49bc42f1..12c433a3f 100644 --- a/DDG4/src/Geant4OutputAction.cpp +++ b/DDG4/src/Geant4OutputAction.cpp @@ -12,22 +12,20 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4Particle.h" -#include "DDG4/Geant4RunAction.h" -#include "DDG4/Geant4OutputAction.h" +#include +#include +#include +#include +#include // Geant 4 includes -#include "G4HCofThisEvent.hh" -#include "G4Event.hh" +#include +#include using namespace dd4hep::sim; -using namespace dd4hep; -using namespace std; /// Standard constructor -Geant4OutputAction::Geant4OutputAction(Geant4Context* ctxt, const string& nam) +Geant4OutputAction::Geant4OutputAction(Geant4Context* ctxt, const std::string& nam) : Geant4EventAction(ctxt, nam), m_truth(0) { InstanceCount::increment(this); @@ -73,7 +71,7 @@ void Geant4OutputAction::end(const G4Event* evt) { saveCollection(ctxt, hc); } } - catch(const exception& e) { + catch(const std::exception& e) { printout(ERROR,name(),"+++ [Event:%d] Exception while saving event:%s", evt->GetEventID(),e.what()); if ( m_errorFatal ) throw; @@ -85,7 +83,7 @@ void Geant4OutputAction::end(const G4Event* evt) { } commit(ctxt); } - catch(const exception& e) { + catch(const std::exception& e) { printout(ERROR,name(),"+++ [Event:%d] Exception while saving event:%s", evt->GetEventID(),e.what()); if ( m_errorFatal ) throw; diff --git a/DDG4/src/Geant4Particle.cpp b/DDG4/src/Geant4Particle.cpp index a23810937..10d86ef9f 100644 --- a/DDG4/src/Geant4Particle.cpp +++ b/DDG4/src/Geant4Particle.cpp @@ -27,13 +27,12 @@ #include #include +// C/C++ include files #include #include #include -using namespace dd4hep; using namespace dd4hep::sim; -typedef detail::ReferenceBitMask PropertyMask; /// Default destructor ParticleExtension::~ParticleExtension() { @@ -385,6 +384,7 @@ void Geant4ParticleHandle::header4(int level, const std::string& src, const char } void Geant4ParticleHandle::dump4(int level, const std::string& src, const char* tag) const { + using PropertyMask = dd4hep::detail::ReferenceBitMask; Geant4ParticleHandle p(*this); //char equiv[32]; PropertyMask mask(p->reason); @@ -495,32 +495,31 @@ void Geant4ParticleMap::clear() { void Geant4ParticleMap::dump() const { int cnt; char text[64]; - using namespace std; const Geant4ParticleMap* m = this; cnt = 0; - cout << "Particle map:" << endl; + std::cout << "Particle map:" << std::endl; for( const auto& p : m->particleMap ) { - ::snprintf(text,sizeof(text)," [%-4d:%p]",p.second->id,(void*)p.second); - cout << text; + std::snprintf(text,sizeof(text)," [%-4d:%p]",p.second->id,(void*)p.second); + std::cout << text; if ( ++cnt == 8 ) { - cout << endl; + std::cout << std::endl; cnt = 0; } } - cout << endl; + std::cout << std::endl; cnt = 0; - cout << "Equivalents:" << endl; + std::cout << "Equivalents:" << std::endl; for( const auto& p : m->equivalentTracks ) { - ::snprintf(text,sizeof(text)," [%-5d : %-5d]",p.first,p.second); - cout << text; + std::snprintf(text,sizeof(text)," [%-5d : %-5d]",p.first,p.second); + std::cout << text; if ( ++cnt == 8 ) { - cout << endl; + std::cout << std::endl; cnt = 0; } } - cout << endl; + std::cout << std::endl; } /// Adopt particle maps diff --git a/DDG4/src/Geant4ParticleGenerator.cpp b/DDG4/src/Geant4ParticleGenerator.cpp index f15ecbfed..2ee1619bc 100644 --- a/DDG4/src/Geant4ParticleGenerator.cpp +++ b/DDG4/src/Geant4ParticleGenerator.cpp @@ -12,27 +12,26 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4Context.h" -#include "DDG4/Geant4Primary.h" -#include "DDG4/Geant4ParticleGenerator.h" -#include "DDG4/Geant4Random.h" -#include "CLHEP/Units/SystemOfUnits.h" +#include +#include +#include +#include +#include +#include +#include // Geant4 include files -#include "G4ParticleTable.hh" -#include "G4ParticleDefinition.hh" +#include +#include // C/C++ include files #include #include -using namespace std; using namespace dd4hep::sim; /// Standard constructor -Geant4ParticleGenerator::Geant4ParticleGenerator(Geant4Context* ctxt, const string& nam) +Geant4ParticleGenerator::Geant4ParticleGenerator(Geant4Context* ctxt, const std::string& nam) : Geant4GeneratorAction(ctxt, nam), m_direction(0,1,0), m_position(0,0,0), m_particle(0) { InstanceCount::increment(this); @@ -125,7 +124,7 @@ void Geant4ParticleGenerator::operator()(G4Event*) { G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); m_particle = particleTable->FindParticle(m_particleName); if (0 == m_particle) { - throw runtime_error("Geant4ParticleGenerator: Bad particle type:"+m_particleName+"!"); + except("Geant4ParticleGenerator: Bad particle type: %s!", m_particleName.c_str()); } } Geant4Event& evt = context()->event(); @@ -177,6 +176,5 @@ void Geant4ParticleGenerator::operator()(G4Event*) { p->id, m_particleName.c_str(), momentum/CLHEP::GeV, vtx->x/CLHEP::mm, vtx->y/CLHEP::mm, vtx->z/CLHEP::mm, direction.X(), direction.Y(), direction.Z()); - } } diff --git a/DDG4/src/Geant4ParticleGun.cpp b/DDG4/src/Geant4ParticleGun.cpp index 2718dd950..ee1d1862e 100644 --- a/DDG4/src/Geant4ParticleGun.cpp +++ b/DDG4/src/Geant4ParticleGun.cpp @@ -12,22 +12,21 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4Context.h" -#include "DDG4/Geant4Primary.h" -#include "DDG4/Geant4ParticleGun.h" -#include "DDG4/Geant4InputHandling.h" -#include "CLHEP/Units/SystemOfUnits.h" +#include +#include +#include +#include +#include +#include +#include // C/C++ include files #include -using namespace std; using namespace dd4hep::sim; /// Standard constructor -Geant4ParticleGun::Geant4ParticleGun(Geant4Context* ctxt, const string& nam) +Geant4ParticleGun::Geant4ParticleGun(Geant4Context* ctxt, const std::string& nam) : Geant4IsotropeGenerator(ctxt,nam), m_shotNo(0) { InstanceCount::increment(this); @@ -59,7 +58,7 @@ void Geant4ParticleGun::getParticleDirection(int num, ROOT::Math::XYZVector& dir /// Callback to generate primary particles void Geant4ParticleGun::operator()(G4Event* event) { - double r = m_direction.R(), eps = numeric_limits::epsilon(); + double r = m_direction.R(), eps = std::numeric_limits::epsilon(); if ( r > eps ) { m_direction.SetXYZ(m_direction.X()/r, m_direction.Y()/r, m_direction.Z()/r); } diff --git a/DDG4/src/Geant4ParticleHandler.cpp b/DDG4/src/Geant4ParticleHandler.cpp index 36e686e69..45ca5ff98 100644 --- a/DDG4/src/Geant4ParticleHandler.cpp +++ b/DDG4/src/Geant4ParticleHandler.cpp @@ -40,14 +40,11 @@ #include #include -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; - -typedef detail::ReferenceBitMask PropertyMask; +using PropertyMask = dd4hep::detail::ReferenceBitMask; /// Standard constructor -Geant4ParticleHandler::Geant4ParticleHandler(Geant4Context* ctxt, const string& nam) +Geant4ParticleHandler::Geant4ParticleHandler(Geant4Context* ctxt, const std::string& nam) : Geant4GeneratorAction(ctxt,nam), Geant4MonteCarloTruth(), m_ownsParticles(false), m_userHandler(0), m_primaryMap(0) { @@ -159,7 +156,7 @@ void Geant4ParticleHandler::mark(const G4Track* track) { G4LogicalVolume* vol = track->GetVolume()->GetLogicalVolume(); G4VSensitiveDetector* g4 = vol->GetSensitiveDetector(); Geant4ActionSD* sd = dynamic_cast(g4); - string typ = sd ? sd->sensitiveType() : string(); + std::string typ = sd ? sd->sensitiveType() : std::string(); if ( typ == "calorimeter" ) mask.set(G4PARTICLE_CREATED_CALORIMETER_HIT); else if ( typ == "tracker" ) @@ -184,7 +181,7 @@ void Geant4ParticleHandler::operator()(G4Event* event) { /// User stepping callback void Geant4ParticleHandler::step(const G4Step* step_value, G4SteppingManager* mgr) { - typedef vector _Sec; + typedef std::vector _Sec; ++m_currTrack.steps; if ( (m_currTrack.reason&G4PARTICLE_ABOVE_ENERGY_THRESHOLD) ) { // @@ -428,7 +425,7 @@ void Geant4ParticleHandler::beginEvent(const G4Event* event) { /// Debugging: Dump Geant4 particle map void Geant4ParticleHandler::dumpMap(const char* tag) const { - const string& n = name(); + const std::string& n = name(); Geant4ParticleHandle::header4(INFO,n,tag); for(ParticleMap::const_iterator iend=m_particleMap.end(), i=m_particleMap.begin(); i!=iend; ++i) { Geant4ParticleHandle((*i).second).dump4(INFO,n,tag); @@ -621,7 +618,7 @@ bool Geant4ParticleHandler::defaultKeepParticle(Particle& particle) { /// Clean the monte carlo record. Remove all unwanted stuff. /// This is the core of the object executed at the end of each event action. int Geant4ParticleHandler::recombineParents() { - set remove; + std::set remove; /// Need to start from BACK, to clean first the latest produced stuff. for(ParticleMap::reverse_iterator i=m_particleMap.rbegin(); i!=m_particleMap.rend(); ++i) { @@ -705,7 +702,7 @@ void Geant4ParticleHandler::checkConsistency() const { Geant4ParticleHandle p(particle); PropertyMask mask(p->reason); PropertyMask status(p->status); - set& daughters = p->daughters; + std::set& daughters = p->daughters; ParticleMap::const_iterator j; // For all particles, the set of daughters must be contained in the record. for( int id_dau : daughters ) { diff --git a/DDG4/src/Geant4ParticlePrint.cpp b/DDG4/src/Geant4ParticlePrint.cpp index c7d62afde..ae7a46102 100644 --- a/DDG4/src/Geant4ParticlePrint.cpp +++ b/DDG4/src/Geant4ParticlePrint.cpp @@ -12,24 +12,21 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/Primitives.h" -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4ParticlePrint.h" -#include "DDG4/Geant4Data.h" -#include "DDG4/Geant4HitCollection.h" +#include +#include +#include +#include +#include +#include // Geant4 include files -#include "G4Event.hh" +#include // C/C++ include files #include -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; - -typedef detail::ReferenceBitMask PropertyMask; +using PropertyMask = dd4hep::detail::ReferenceBitMask; /// Standard constructor Geant4ParticlePrint::Geant4ParticlePrint(Geant4Context* ctxt, const std::string& nam) @@ -80,8 +77,8 @@ void Geant4ParticlePrint::printParticle(const std::string& prefix, const G4Event char equiv[32]; PropertyMask mask(p->reason); PropertyMask status(p->status); - string proc_name = p.processName(); - string proc_type = p.processTypeName(); + std::string proc_name = p.processName(); + std::string proc_type = p.processTypeName(); int parent_id = p->parents.empty() ? -1 : *(p->parents.begin()); equiv[0] = 0; @@ -207,10 +204,8 @@ void Geant4ParticlePrint::printParticleTree(const G4Event* e, } printParticle(txt, e, p); - const set& daughters = p->daughters; // For all particles, the set of daughters must be contained in the record. - for(set::const_iterator id=daughters.begin(); id!=daughters.end(); ++id) { - int id_dau = *id; + for( int id_dau : p->daughters ) { Geant4ParticleHandle dau = (*particles.find(id_dau)).second; printParticleTree(e, particles, level+1, dau); } diff --git a/DDG4/src/Geant4PhysicsConstructor.cpp b/DDG4/src/Geant4PhysicsConstructor.cpp index bd4967336..a17179a30 100644 --- a/DDG4/src/Geant4PhysicsConstructor.cpp +++ b/DDG4/src/Geant4PhysicsConstructor.cpp @@ -12,12 +12,12 @@ //========================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4PhysicsConstructor.h" -#include "G4VModularPhysicsList.hh" +#include +#include +#include // Geant4 include files -#include "G4Version.hh" +#include using namespace dd4hep::sim; @@ -60,7 +60,6 @@ namespace { } - /// Standard action constructor Geant4PhysicsConstructor::Constructor::Constructor() : G4VPhysicsConstructor() diff --git a/DDG4/src/Geant4PhysicsList.cpp b/DDG4/src/Geant4PhysicsList.cpp index a67405b8d..cbe2c48a5 100644 --- a/DDG4/src/Geant4PhysicsList.cpp +++ b/DDG4/src/Geant4PhysicsList.cpp @@ -33,8 +33,6 @@ #include #include -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; namespace { @@ -44,15 +42,14 @@ namespace { }; struct EmptyPhysics : public G4VModularPhysicsList { - EmptyPhysics() {} - virtual ~EmptyPhysics() {} + EmptyPhysics() = default; + virtual ~EmptyPhysics() = default; }; struct ParticlePhysics : public G4VPhysicsConstructor { Geant4PhysicsListActionSequence* seq; G4VUserPhysicsList* phys; - ParticlePhysics(Geant4PhysicsListActionSequence* s, G4VUserPhysicsList* p) - : seq(s), phys(p) {} - virtual ~ParticlePhysics() {} + ParticlePhysics(Geant4PhysicsListActionSequence* s, G4VUserPhysicsList* p) : seq(s), phys(p) { } + virtual ~ParticlePhysics() = default; virtual void ConstructProcess() { seq->constructProcesses(phys); if ( seq->transportation() ) { @@ -87,7 +84,7 @@ Geant4PhysicsList::Process& Geant4PhysicsList::Process::operator=(const Process& } /// Standard constructor -Geant4PhysicsList::Geant4PhysicsList(Geant4Context* ctxt, const string& nam) +Geant4PhysicsList::Geant4PhysicsList(Geant4Context* ctxt, const std::string& nam) : Geant4Action(ctxt, nam) { InstanceCount::increment(this); } @@ -168,7 +165,7 @@ void Geant4PhysicsList::addPhysicsConstructor(const std::string& phys_name) { } /// Access processes for one particle type -Geant4PhysicsList::ParticleProcesses& Geant4PhysicsList::processes(const string& nam) { +Geant4PhysicsList::ParticleProcesses& Geant4PhysicsList::processes(const std::string& nam) { if (auto i = m_processes.find(nam); i != m_processes.end()) return (*i).second; auto ret = m_processes.emplace(nam, ParticleProcesses()); @@ -176,27 +173,27 @@ Geant4PhysicsList::ParticleProcesses& Geant4PhysicsList::processes(const string& } /// Access processes for one particle type (CONST) -const Geant4PhysicsList::ParticleProcesses& Geant4PhysicsList::processes(const string& nam) const { +const Geant4PhysicsList::ParticleProcesses& Geant4PhysicsList::processes(const std::string& nam) const { if (auto i = m_processes.find(nam); i != m_processes.end()) return (*i).second; except("Failed to access the physics process '%s' [Unknown-Process]", nam.c_str()); - throw runtime_error("Failed to access the physics process"); // never called anyway + throw std::runtime_error("Failed to access the physics process"); // never called anyway } /// Access discrete processes for one particle type -Geant4PhysicsList::ParticleProcesses& Geant4PhysicsList::discreteProcesses(const string& nam) { +Geant4PhysicsList::ParticleProcesses& Geant4PhysicsList::discreteProcesses(const std::string& nam) { if (auto i = m_discreteProcesses.find(nam); i != m_discreteProcesses.end()) return (*i).second; - pair ret = m_discreteProcesses.emplace(nam, ParticleProcesses()); + auto ret = m_discreteProcesses.emplace(nam, ParticleProcesses()); return (*(ret.first)).second; } /// Access discrete processes for one particle type (CONST) -const Geant4PhysicsList::ParticleProcesses& Geant4PhysicsList::discreteProcesses(const string& nam) const { +const Geant4PhysicsList::ParticleProcesses& Geant4PhysicsList::discreteProcesses(const std::string& nam) const { if (auto i = m_discreteProcesses.find(nam); i != m_discreteProcesses.end()) return (*i).second; except("Failed to access the physics process '%s' [Unknown-Process]", nam.c_str()); - throw runtime_error("Failed to access the physics process"); // never called anyway + throw std::runtime_error("Failed to access the physics process"); // never called anyway } /// Access physics constructor by name (CONST) @@ -204,12 +201,12 @@ Geant4PhysicsList::PhysicsConstructor Geant4PhysicsList::physics(const std::stri for ( const auto& ctor : m_physics ) { if ( ctor == nam ) { if ( nullptr == ctor.pointer ) - except("Failed to instaniate the physics for constructor '%s'", nam.c_str()); + except("Failed to instaniate the physics for constructor '%s'", nam.c_str()); return ctor; } } except("Failed to access the physics for constructor '%s' [Unknown physics]", nam.c_str()); - throw runtime_error("Failed to access the physics process"); // never called anyway + throw std::runtime_error("Failed to access the physics process"); // never called anyway } /// Add PhysicsConstructor by name @@ -233,9 +230,9 @@ void Geant4PhysicsList::constructPhysics(G4VModularPhysicsList* physics_pointer) for ( auto& ctor : m_physics ) { if ( 0 == ctor.pointer ) { if ( G4VPhysicsConstructor* p = PluginService::Create(ctor) ) - ctor.pointer = p; + ctor.pointer = p; else - except("Failed to create the physics for G4VPhysicsConstructor '%s'", ctor.c_str()); + except("Failed to create the physics for G4VPhysicsConstructor '%s'", ctor.c_str()); } physics_pointer->RegisterPhysics(ctor.pointer); info("Registered Geant4 physics constructor %s to physics list", ctor.c_str()); @@ -272,38 +269,38 @@ void Geant4PhysicsList::constructParticles(G4VUserPhysicsList* physics_pointer) void Geant4PhysicsList::constructProcesses(G4VUserPhysicsList* physics_pointer) { debug("constructProcesses %p", physics_pointer); for ( const auto& [part_name, procs] : m_discreteProcesses ) { - vector defs(Geant4ParticleHandle::g4DefinitionsRegEx(part_name)); + std::vector defs(Geant4ParticleHandle::g4DefinitionsRegEx(part_name)); if ( defs.empty() ) { except("Particle:%s Cannot find the corresponding entry in the particle table.", part_name.c_str()); } for ( const Process& p : procs ) { if ( G4VProcess* g4 = PluginService::Create(p.name) ) { - for ( G4ParticleDefinition* particle : defs ) { - G4ProcessManager* mgr = particle->GetProcessManager(); - mgr->AddDiscreteProcess(g4); - info("Particle:%s -> [%s] added discrete process %s", - part_name.c_str(), particle->GetParticleName().c_str(), p.name.c_str()); - } - continue; + for ( G4ParticleDefinition* particle : defs ) { + G4ProcessManager* mgr = particle->GetProcessManager(); + mgr->AddDiscreteProcess(g4); + info("Particle:%s -> [%s] added discrete process %s", + part_name.c_str(), particle->GetParticleName().c_str(), p.name.c_str()); + } + continue; } except("Cannot create discrete physics process %s", p.name.c_str()); } } for ( const auto& [part_name, procs] : m_processes ) { - vector defs(Geant4ParticleHandle::g4DefinitionsRegEx(part_name)); + std::vector defs(Geant4ParticleHandle::g4DefinitionsRegEx(part_name)); if (defs.empty()) { except("Particle:%s Cannot find the corresponding entry in the particle table.", part_name.c_str()); } for ( const Process& p : procs ) { if ( G4VProcess* g4 = PluginService::Create(p.name) ) { - for ( G4ParticleDefinition* particle : defs ) { - G4ProcessManager* mgr = particle->GetProcessManager(); - mgr->AddProcess(g4, p.ordAtRestDoIt, p.ordAlongSteptDoIt, p.ordPostStepDoIt); - info("Particle:%s -> [%s] added process %s with flags (%d,%d,%d)", - part_name.c_str(), particle->GetParticleName().c_str(), p.name.c_str(), - p.ordAtRestDoIt, p.ordAlongSteptDoIt, p.ordPostStepDoIt); - } - continue; + for ( G4ParticleDefinition* particle : defs ) { + G4ProcessManager* mgr = particle->GetProcessManager(); + mgr->AddProcess(g4, p.ordAtRestDoIt, p.ordAlongSteptDoIt, p.ordPostStepDoIt); + info("Particle:%s -> [%s] added process %s with flags (%d,%d,%d)", + part_name.c_str(), particle->GetParticleName().c_str(), p.name.c_str(), + p.ordAtRestDoIt, p.ordAlongSteptDoIt, p.ordPostStepDoIt); + } + continue; } except("Cannot create physics process %s", p.name.c_str()); } @@ -315,7 +312,7 @@ void Geant4PhysicsList::enable(G4VUserPhysicsList* /* physics */) { } /// Standard constructor -Geant4PhysicsListActionSequence::Geant4PhysicsListActionSequence(Geant4Context* ctxt, const string& nam) +Geant4PhysicsListActionSequence::Geant4PhysicsListActionSequence(Geant4Context* ctxt, const std::string& nam) : Geant4Action(ctxt, nam), m_transportation(false), m_decays(false), m_rangecut(0.7*CLHEP::mm) { declareProperty("transportation", m_transportation); declareProperty("extends", m_extends); @@ -335,7 +332,6 @@ Geant4PhysicsListActionSequence::~Geant4PhysicsListActionSequence() { #include - /// Extend physics list from factory: G4VUserPhysicsList* Geant4PhysicsListActionSequence::extensionList() { G4VModularPhysicsList* physics = ( m_extends.empty() ) diff --git a/DDG4/src/Geant4Primary.cpp b/DDG4/src/Geant4Primary.cpp index 50be9eb76..ecaf20772 100644 --- a/DDG4/src/Geant4Primary.cpp +++ b/DDG4/src/Geant4Primary.cpp @@ -12,19 +12,18 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/Primitives.h" -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4Primary.h" +#include +#include +#include +#include // Geant4 include files -#include "G4PrimaryParticle.hh" +#include // C/C++ include files #include #include -using namespace dd4hep; using namespace dd4hep::sim; /// Default destructor diff --git a/DDG4/src/Geant4Random.cpp b/DDG4/src/Geant4Random.cpp index 464ff3c13..e1b382e84 100644 --- a/DDG4/src/Geant4Random.cpp +++ b/DDG4/src/Geant4Random.cpp @@ -12,21 +12,20 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4Random.h" +#include +#include +#include -#include "CLHEP/Random/EngineFactory.h" -#include "CLHEP/Random/RandGamma.h" -#include "CLHEP/Random/Random.h" +#include +#include +#include // ROOT include files -#include "TRandom1.h" +#include // C/C++ include files #include -using namespace std; using namespace dd4hep::sim; namespace CLHEP { @@ -113,7 +112,7 @@ Geant4Random::~Geant4Random() { /// Access the main Geant4 random generator instance. Must be created before used! Geant4Random* Geant4Random::instance(bool throw_exception) { if ( !s_instance && throw_exception ) { - throw runtime_error("No global random number generator defined!"); + dd4hep::except("Geant4Random", "No global random number generator defined!"); } return s_instance; } @@ -125,10 +124,10 @@ Geant4Random* Geant4Random::setMainInstance(Geant4Random* ptr) { } if ( s_instance != ptr ) { if ( !ptr ) { - throw runtime_error("Attempt to declare invalid Geant4Random instance."); + dd4hep::except("Geant4Random","Attempt to declare invalid Geant4Random instance."); } if ( !ptr->m_inited ) { - throw runtime_error("Attempt to declare uninitialized Geant4Random instance."); + dd4hep::except("Geant4Random","Attempt to declare uninitialized Geant4Random instance."); } Geant4Random* old = s_instance; CLHEP::HepRandomEngine* curr = CLHEP::HepRandom::getTheEngine(); @@ -146,19 +145,19 @@ Geant4Random* Geant4Random::setMainInstance(Geant4Random* ptr) { return 0; } -#include "CLHEP/Random/DualRand.h" -#include "CLHEP/Random/JamesRandom.h" -#include "CLHEP/Random/MTwistEngine.h" -#include "CLHEP/Random/RanecuEngine.h" -#include "CLHEP/Random/Ranlux64Engine.h" -#include "CLHEP/Random/RanluxEngine.h" -#include "CLHEP/Random/RanshiEngine.h" -#include "CLHEP/Random/NonRandomEngine.h" +#include +#include +#include +#include +#include +#include +#include +#include /// Initialize the instance. void Geant4Random::initialize() { if ( !m_file.empty() ) { - ifstream in(m_file.c_str(), std::ios::in); + std::ifstream in(m_file.c_str(), std::ios::in); m_engine = CLHEP::EngineFactory::newEngine(in); if ( !m_engine ) { except("Failed to create CLHEP random engine from file:%s.",m_file.c_str()); diff --git a/DDG4/src/Geant4RunAction.cpp b/DDG4/src/Geant4RunAction.cpp index 68169a6b9..6f54ef8e5 100644 --- a/DDG4/src/Geant4RunAction.cpp +++ b/DDG4/src/Geant4RunAction.cpp @@ -12,15 +12,13 @@ //========================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4RunAction.h" +#include +#include + // Geant4 headers -#include "G4Threading.hh" -#include "G4AutoLock.hh" -// C/C++ include files -#include +#include +#include -using namespace std; using namespace dd4hep::sim; namespace { @@ -29,7 +27,7 @@ namespace { } /// Standard constructor -Geant4RunAction::Geant4RunAction(Geant4Context* ctxt, const string& nam) +Geant4RunAction::Geant4RunAction(Geant4Context* ctxt, const std::string& nam) : Geant4Action(ctxt, nam) { InstanceCount::increment(this); } @@ -48,7 +46,7 @@ void Geant4RunAction::end(const G4Run*) { } /// Standard constructor -Geant4SharedRunAction::Geant4SharedRunAction(Geant4Context* ctxt, const string& nam) +Geant4SharedRunAction::Geant4SharedRunAction(Geant4Context* ctxt, const std::string& nam) : Geant4RunAction(ctxt, nam) { InstanceCount::increment(this); @@ -73,7 +71,7 @@ void Geant4SharedRunAction::use(Geant4RunAction* action) { m_action = action; return; } - throw runtime_error("Geant4SharedRunAction: Attempt to use invalid actor!"); + except("Geant4SharedRunAction: Attempt to use invalid actor!"); } /// Begin-of-run callback @@ -97,7 +95,7 @@ void Geant4SharedRunAction::end(const G4Run* run) { } /// Standard constructor -Geant4RunActionSequence::Geant4RunActionSequence(Geant4Context* ctxt, const string& nam) +Geant4RunActionSequence::Geant4RunActionSequence(Geant4Context* ctxt, const std::string& nam) : Geant4Action(ctxt, nam) { m_needsControl = true; InstanceCount::increment(this); @@ -124,7 +122,7 @@ void Geant4RunActionSequence::configureFiber(Geant4Context* thread_context) { } /// Get an action by name -Geant4RunAction* Geant4RunActionSequence::get(const string& nam) const { +Geant4RunAction* Geant4RunActionSequence::get(const std::string& nam) const { return m_actors.get(FindByName(TypeName::split(nam).second)); } @@ -136,7 +134,7 @@ void Geant4RunActionSequence::adopt(Geant4RunAction* action) { m_actors.add(action); return; } - throw runtime_error("Geant4RunActionSequence: Attempt to add invalid actor!"); + except("Geant4RunActionSequence: Attempt to add invalid actor!"); } /// Pre-track action callback diff --git a/DDG4/src/Geant4SensDetAction.cpp b/DDG4/src/Geant4SensDetAction.cpp index 68b1b43dd..a2db05dbd 100644 --- a/DDG4/src/Geant4SensDetAction.cpp +++ b/DDG4/src/Geant4SensDetAction.cpp @@ -15,6 +15,7 @@ #include #include #include + #include #include #include @@ -36,27 +37,24 @@ #define MM_2_CM 0.1 #endif -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; #if 0 namespace { - Geant4ActionSD* _getSensitiveDetector(const string& name) { + Geant4ActionSD* _getSensitiveDetector(const std::string& name) { G4SDManager* mgr = G4SDManager::GetSDMpointer(); G4VSensitiveDetector* sd = mgr->FindSensitiveDetector(name); if (0 == sd) { - throw runtime_error(format("Geant4Sensitive", "DDG4: You requested to configure actions " - "for the sensitive detector %s,\nDDG4: which is not known to Geant4. " - "Are you sure you already converted the geometry?", name.c_str())); + dd4hep::except("Geant4Sensitive", "DDG4: You requested to configure actions " + "for the sensitive detector %s,\nDDG4: which is not known to Geant4. " + "Are you sure you already converted the geometry?", name.c_str()); } Geant4ActionSD* action_sd = dynamic_cast(sd); if (0 == action_sd) { - throw runtime_error( - format("Geant4Sensitive", "DDG4: You may only configure actions " - "for sensitive detectors of type Geant4ActionSD.\n" - "DDG4: The sensitive detector of %s is of type %s, which is incompatible.", name.c_str(), - typeName(typeid(*sd)).c_str())); + throw dd4hep::except("Geant4Sensitive", "DDG4: You may only configure actions " + "for sensitive detectors of type Geant4ActionSD.\n" + "DDG4: The sensitive detector of %s is of type %s, which is incompatible.", name.c_str(), + typeName(typeid(*sd)).c_str()); } return action_sd; } @@ -97,12 +95,12 @@ bool Geant4Filter::operator()(const Geant4FastSimSpot*) const { } /// Constructor. The detector element is identified by the name -Geant4Sensitive::Geant4Sensitive(Geant4Context* ctxt, const string& nam, DetElement det, Detector& det_ref) +Geant4Sensitive::Geant4Sensitive(Geant4Context* ctxt, const std::string& nam, DetElement det, Detector& det_ref) : Geant4Action(ctxt, nam), m_detDesc(det_ref), m_detector(det) { InstanceCount::increment(this); if (!det.isValid()) { - throw runtime_error(format("Geant4Sensitive", "DDG4: Detector elemnt for %s is invalid.", nam.c_str())); + except("DDG4: Detector elemnt for %s is invalid.", nam.c_str()); } declareProperty("HitCreationMode", m_hitCreationMode = SIMPLE_MODE); m_sequence = context()->kernel().sensitiveAction(m_detector.name()); @@ -131,7 +129,7 @@ void Geant4Sensitive::adopt(Geant4Filter* filter) { m_filters.add(filter); return; } - throw runtime_error("Geant4Sensitive: Attempt to add invalid sensitive filter!"); + except("Attempt to add invalid sensitive filter!"); } /// Add an actor responding to all callbacks. Sequence takes ownership. @@ -147,7 +145,7 @@ void Geant4Sensitive::adopt_front(Geant4Filter* filter) { m_filters.add_front(filter); return; } - throw runtime_error("Geant4Sensitive: Attempt to add invalid sensitive filter!"); + except("Attempt to add invalid sensitive filter!"); } /// Callback before hit processing starts. Invoke all filters. @@ -175,8 +173,8 @@ Geant4ActionSD& Geant4Sensitive::detector() const { return *m_sensitiveDetector; //m_sensitiveDetector = _getSensitiveDetector(m_detector.name()); //if ( m_sensitiveDetector ) return *m_sensitiveDetector; - throw runtime_error(format("Geant4Sensitive", "DDG4: The sensitive detector for action %s " - "was not properly configured.", name().c_str())); + except("DDG4: The sensitive detector for action %s was not properly configured.", name().c_str()); + throw std::runtime_error("Geant4Sensitive::detector"); } /// Access to the hosting sequence @@ -185,12 +183,12 @@ Geant4SensDetActionSequence& Geant4Sensitive::sequence() const { } /// Access the detector desciption object -Detector& Geant4Sensitive::detectorDescription() const { +dd4hep::Detector& Geant4Sensitive::detectorDescription() const { return m_detDesc; } /// Access HitCollection container names -const string& Geant4Sensitive::hitCollectionName(std::size_t which) const { +const std::string& Geant4Sensitive::hitCollectionName(std::size_t which) const { return sequence().hitCollectionName(which); } @@ -289,7 +287,7 @@ long long int Geant4Sensitive::cellID(const G4VTouchable* touchable, const G4Thr } /// Standard constructor -Geant4SensDetActionSequence::Geant4SensDetActionSequence(Geant4Context* ctxt, const string& nam) +Geant4SensDetActionSequence::Geant4SensDetActionSequence(Geant4Context* ctxt, const std::string& nam) : Geant4Action(ctxt, nam), m_hce(0), m_detector(0) { m_needsControl = true; @@ -329,7 +327,7 @@ void Geant4SensDetActionSequence::adopt(Geant4Sensitive* sensitive) { m_actors.add(sensitive); return; } - throw runtime_error("Geant4SensDetActionSequence: Attempt to add invalid sensitive actor!"); + except("Attempt to add invalid sensitive actor!"); } /// Add an actor responding to all callbacks. Sequence takes ownership. @@ -339,7 +337,7 @@ void Geant4SensDetActionSequence::adopt(Geant4Filter* filter) { m_filters.add(filter); return; } - throw runtime_error("Geant4SensDetActionSequence: Attempt to add invalid sensitive filter!"); + except("Attempt to add invalid sensitive filter!"); } /// Initialize the usage of a hit collection. Returns the collection identifier @@ -366,7 +364,7 @@ const std::string& Geant4SensDetActionSequence::hitCollectionName(std::size_t wh if (which < m_collections.size()) { return m_collections[which].first; } - static string blank = ""; + static std::string blank = ""; except("The collection name index for subdetector %s is out of range!", c_name()); return blank; } @@ -470,17 +468,18 @@ Geant4SensDetSequences::~Geant4SensDetSequences() { } /// Access sequence member by name -Geant4SensDetActionSequence* Geant4SensDetSequences::operator[](const string& name) const { - string nam = "SD_Seq_" + name; - Members::const_iterator i = m_sequences.find(nam); +Geant4SensDetActionSequence* Geant4SensDetSequences::operator[](const std::string& nam) const { + std::string n = "SD_Seq_" + nam; + Members::const_iterator i = m_sequences.find(n); if (i != m_sequences.end()) return (*i).second; - throw runtime_error("Attempt to access undefined SensDetActionSequence!"); + except("Attempt to access undefined SensDetActionSequence: %s ", nam.c_str()); + return nullptr; } /// Access sequence member by name Geant4SensDetActionSequence* Geant4SensDetSequences::find(const std::string& name) const { - string nam = "SD_Seq_" + name; + std::string nam = "SD_Seq_" + name; Members::const_iterator i = m_sequences.find(nam); if (i != m_sequences.end()) return (*i).second; @@ -488,15 +487,14 @@ Geant4SensDetActionSequence* Geant4SensDetSequences::find(const std::string& nam } /// Insert sequence member -void Geant4SensDetSequences::insert(const string& name, Geant4SensDetActionSequence* seq) { +void Geant4SensDetSequences::insert(const std::string& name, Geant4SensDetActionSequence* seq) { if (seq) { - string nam = "SD_Seq_" + name; + std::string nam = "SD_Seq_" + name; seq->addRef(); m_sequences[nam] = seq; return; } - throw runtime_error(format("Geant4SensDetSequences", "Attempt to add invalid sensitive " - "sequence with name:%s", name.c_str())); + except("Attempt to add invalid sensitive sequence with name:%s", name.c_str()); } /// Clear the sequence list diff --git a/DDG4/src/Geant4StackingAction.cpp b/DDG4/src/Geant4StackingAction.cpp index 985d951cb..e0b771769 100644 --- a/DDG4/src/Geant4StackingAction.cpp +++ b/DDG4/src/Geant4StackingAction.cpp @@ -12,23 +12,20 @@ //========================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4StackingAction.h" -// Geant4 headers -#include "G4Threading.hh" -#include "G4AutoLock.hh" +#include +#include -// C/C++ include files -#include +// Geant4 headers +#include +#include -using namespace std; using namespace dd4hep::sim; namespace { G4Mutex action_mutex=G4MUTEX_INITIALIZER; } /// Standard constructor -Geant4StackingAction::Geant4StackingAction(Geant4Context* ctxt, const string& nam) +Geant4StackingAction::Geant4StackingAction(Geant4Context* ctxt, const std::string& nam) : Geant4Action(ctxt, nam) { InstanceCount::increment(this); } @@ -40,13 +37,12 @@ Geant4StackingAction::~Geant4StackingAction() { /// Classify new track: The first call in the sequence returning non-null pointer wins! TrackClassification -Geant4StackingAction::classifyNewTrack(G4StackManager* /* manager */, - const G4Track* /* track */) { +Geant4StackingAction::classifyNewTrack(G4StackManager* /* manager */, const G4Track* /* track */) { return TrackClassification(); } /// Standard constructor -Geant4SharedStackingAction::Geant4SharedStackingAction(Geant4Context* ctxt, const string& nam) +Geant4SharedStackingAction::Geant4SharedStackingAction(Geant4Context* ctxt, const std::string& nam) : Geant4StackingAction(ctxt, nam), m_action(0) { InstanceCount::increment(this); @@ -71,7 +67,7 @@ void Geant4SharedStackingAction::use(Geant4StackingAction* action) { m_action = action; return; } - throw runtime_error("Geant4SharedStackingAction: Attempt to use invalid actor!"); + except("Attempt to use invalid actor!"); } /// Begin-of-stacking callback @@ -97,7 +93,7 @@ void Geant4SharedStackingAction::prepare(G4StackManager* stackManager) { /// Classify new track with delegation TrackClassification Geant4SharedStackingAction::classifyNewTrack(G4StackManager* stackManager, - const G4Track* track) { + const G4Track* track) { if ( m_action ) { G4AutoLock protection_lock(&action_mutex); { ContextSwap swap(m_action,context()); @@ -108,7 +104,7 @@ Geant4SharedStackingAction::classifyNewTrack(G4StackManager* stackManager, } /// Standard constructor -Geant4StackingActionSequence::Geant4StackingActionSequence(Geant4Context* ctxt, const string& nam) +Geant4StackingActionSequence::Geant4StackingActionSequence(Geant4Context* ctxt, const std::string& nam) : Geant4Action(ctxt, nam) { m_needsControl = true; InstanceCount::increment(this); @@ -130,7 +126,7 @@ void Geant4StackingActionSequence::adopt(Geant4StackingAction* action) { m_actors.add(action); return; } - throw runtime_error("Geant4StackingActionSequence: Attempt to add invalid actor!"); + except("Attempt to add invalid actor!"); } /// Set or update client context @@ -145,7 +141,7 @@ void Geant4StackingActionSequence::configureFiber(Geant4Context* thread_context) } /// Get an action by name -Geant4StackingAction* Geant4StackingActionSequence::get(const string& nam) const { +Geant4StackingAction* Geant4StackingActionSequence::get(const std::string& nam) const { return m_actors.get(FindByName(TypeName::split(nam).second)); } @@ -164,7 +160,7 @@ void Geant4StackingActionSequence::prepare(G4StackManager* stackManager) { /// Classify new track: The first call in the sequence returning non-null pointer wins! TrackClassification Geant4StackingActionSequence::classifyNewTrack(G4StackManager* stackManager, - const G4Track* track) { + const G4Track* track) { for( auto a : m_actors ) { auto ret = a->classifyNewTrack(stackManager, track); if ( ret.type != NoTrackClassification ) { diff --git a/DDG4/src/Geant4StepHandler.cpp b/DDG4/src/Geant4StepHandler.cpp index ad3385e94..ce0bb5715 100644 --- a/DDG4/src/Geant4StepHandler.cpp +++ b/DDG4/src/Geant4StepHandler.cpp @@ -12,16 +12,15 @@ //========================================================================== // Framework include files -#include "DDG4/Geant4StepHandler.h" -#include "DDSegmentation/Segmentation.h" -#include "DD4hep/DD4hepUnits.h" -#include "CLHEP/Units/SystemOfUnits.h" +#include +#include +#include +#include // Geant4 include files -#include "G4Version.hh" +#include namespace units = dd4hep; -using namespace dd4hep; using namespace dd4hep::sim; /// Returns the step status in form of a string diff --git a/DDG4/src/Geant4SteppingAction.cpp b/DDG4/src/Geant4SteppingAction.cpp index 6899711cd..d023a80c6 100644 --- a/DDG4/src/Geant4SteppingAction.cpp +++ b/DDG4/src/Geant4SteppingAction.cpp @@ -12,22 +12,20 @@ //========================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4SteppingAction.h" +#include +#include + // Geant4 headers -#include "G4Threading.hh" -#include "G4AutoLock.hh" -// C/C++ include files -#include +#include +#include -using namespace std; using namespace dd4hep::sim; namespace { G4Mutex action_mutex=G4MUTEX_INITIALIZER; } /// Standard constructor -Geant4SteppingAction::Geant4SteppingAction(Geant4Context* ctxt, const string& nam) +Geant4SteppingAction::Geant4SteppingAction(Geant4Context* ctxt, const std::string& nam) : Geant4Action(ctxt, nam) { InstanceCount::increment(this); } @@ -42,7 +40,7 @@ void Geant4SteppingAction::operator()(const G4Step*, G4SteppingManager*) { } /// Standard constructor -Geant4SharedSteppingAction::Geant4SharedSteppingAction(Geant4Context* ctxt, const string& nam) +Geant4SharedSteppingAction::Geant4SharedSteppingAction(Geant4Context* ctxt, const std::string& nam) : Geant4SteppingAction(ctxt, nam), m_action(0) { InstanceCount::increment(this); @@ -62,7 +60,7 @@ void Geant4SharedSteppingAction::use(Geant4SteppingAction* action) { m_action = action; return; } - throw runtime_error("Geant4SharedSteppingAction: Attempt to use invalid actor!"); + except("Attempt to use invalid actor!"); } /// Set or update client for the use in a new thread fiber @@ -81,7 +79,7 @@ void Geant4SharedSteppingAction::operator()(const G4Step* s, G4SteppingManager* } /// Standard constructor -Geant4SteppingActionSequence::Geant4SteppingActionSequence(Geant4Context* ctxt, const string& nam) +Geant4SteppingActionSequence::Geant4SteppingActionSequence(Geant4Context* ctxt, const std::string& nam) : Geant4Action(ctxt, nam) { m_needsControl = true; InstanceCount::increment(this); @@ -107,7 +105,7 @@ void Geant4SteppingActionSequence::updateContext(Geant4Context* ctxt) { } /// Get an action by name -Geant4SteppingAction* Geant4SteppingActionSequence::get(const string& nam) const { +Geant4SteppingAction* Geant4SteppingActionSequence::get(const std::string& nam) const { return m_actors.get(FindByName(TypeName::split(nam).second)); } @@ -125,5 +123,5 @@ void Geant4SteppingActionSequence::adopt(Geant4SteppingAction* action) { m_actors.add(action); return; } - throw runtime_error("Geant4SteppingActionSequence: Attempt to add invalid actor!"); + except("Attempt to add invalid actor!"); } diff --git a/DDG4/src/Geant4TestActions.cpp b/DDG4/src/Geant4TestActions.cpp index c752033de..3a5b1a73c 100644 --- a/DDG4/src/Geant4TestActions.cpp +++ b/DDG4/src/Geant4TestActions.cpp @@ -12,19 +12,17 @@ //========================================================================= // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4TestActions.h" -#include "G4Run.hh" -#include "G4Event.hh" -#include "G4Step.hh" -#include "G4Track.hh" +#include +#include +#include +#include +#include +#include +#include // C/C++ include files #include -using namespace std; -using namespace dd4hep::sim; using namespace dd4hep::sim::Test; namespace { diff --git a/DDG4/src/Geant4TouchableHandler.cpp b/DDG4/src/Geant4TouchableHandler.cpp index b15d568ad..c18367704 100644 --- a/DDG4/src/Geant4TouchableHandler.cpp +++ b/DDG4/src/Geant4TouchableHandler.cpp @@ -12,14 +12,11 @@ //========================================================================== // Framework include files -#include "DDG4/Geant4TouchableHandler.h" -#include "DDG4/Geant4GeometryInfo.h" +#include +#include -#include "G4Step.hh" -#include "G4VTouchable.hh" - -// C/C++ include files -#include +#include +#include using namespace dd4hep::sim; @@ -52,7 +49,7 @@ Geant4TouchableHandler::Geant4PlacementPath Geant4TouchableHandler::placementPat return path_val; } if ( exception ) { - throw std::runtime_error("Attempt to access invalid G4 touchable object."); + except("Geant4TouchableHandler", "Attempt to access invalid G4 touchable object."); } return path_val; } diff --git a/DDG4/src/Geant4TrackInformation.cpp b/DDG4/src/Geant4TrackInformation.cpp index e5ca3f46e..7020efa73 100644 --- a/DDG4/src/Geant4TrackInformation.cpp +++ b/DDG4/src/Geant4TrackInformation.cpp @@ -12,10 +12,8 @@ //========================================================================== // Framework include files -#include "DDG4/Geant4TrackInformation.h" +#include -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; /// Default constructor diff --git a/DDG4/src/Geant4TrackingAction.cpp b/DDG4/src/Geant4TrackingAction.cpp index 6b778e850..ca307e617 100644 --- a/DDG4/src/Geant4TrackingAction.cpp +++ b/DDG4/src/Geant4TrackingAction.cpp @@ -12,24 +12,20 @@ //========================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4TrackingAction.h" -#include "DDG4/Geant4MonteCarloTruth.h" -#include "DDG4/Geant4TrackInformation.h" +#include +#include +#include +#include // Geant4 include files -#include "G4Track.hh" -#include "G4Threading.hh" -#include "G4AutoLock.hh" -#include "G4TrackingManager.hh" -#include "G4VUserTrackInformation.hh" +#include +#include +#include +#include +#include -// C/C++ include files -#include - -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; + class G4Step; class G4TouchableHistory; namespace { @@ -37,7 +33,7 @@ namespace { } /// Standard constructor -Geant4TrackingActionSequence::Geant4TrackingActionSequence(Geant4Context* ctxt, const string& nam) +Geant4TrackingActionSequence::Geant4TrackingActionSequence(Geant4Context* ctxt, const std::string& nam) : Geant4Action(ctxt, nam) { m_needsControl = true; InstanceCount::increment(this); @@ -66,7 +62,7 @@ void Geant4TrackingActionSequence::configureFiber(Geant4Context* thread_context) } /// Get an action by name -Geant4TrackingAction* Geant4TrackingActionSequence::get(const string& nam) const { +Geant4TrackingAction* Geant4TrackingActionSequence::get(const std::string& nam) const { return m_actors.get(FindByName(TypeName::split(nam).second)); } @@ -78,7 +74,7 @@ void Geant4TrackingActionSequence::adopt(Geant4TrackingAction* action) { m_actors.add(action); return; } - throw runtime_error("Geant4TrackingActionSequence: Attempt to add invalid actor!"); + throw std::runtime_error("Geant4TrackingActionSequence: Attempt to add invalid actor!"); } /// Pre-track action callback @@ -96,7 +92,7 @@ void Geant4TrackingActionSequence::end(const G4Track* track) { } /// Standard constructor -Geant4TrackingAction::Geant4TrackingAction(Geant4Context* ctxt, const string& nam) +Geant4TrackingAction::Geant4TrackingAction(Geant4Context* ctxt, const std::string& nam) : Geant4Action(ctxt, nam) { InstanceCount::increment(this); } @@ -121,7 +117,7 @@ void Geant4TrackingAction::mark(const G4Track* track) const { } /// Standard constructor -Geant4SharedTrackingAction::Geant4SharedTrackingAction(Geant4Context* ctxt, const string& nam) +Geant4SharedTrackingAction::Geant4SharedTrackingAction(Geant4Context* ctxt, const std::string& nam) : Geant4TrackingAction(ctxt, nam), m_action(0) { InstanceCount::increment(this); @@ -146,7 +142,7 @@ void Geant4SharedTrackingAction::use(Geant4TrackingAction* action) { m_action = action; return; } - throw runtime_error("Geant4SharedTrackingAction: Attempt to use invalid actor!"); + except("Attempt to use invalid actor!"); } /// Begin-of-track callback diff --git a/DDG4/src/Geant4TrackingPostAction.cpp b/DDG4/src/Geant4TrackingPostAction.cpp index a19f987ee..196c2ddf0 100644 --- a/DDG4/src/Geant4TrackingPostAction.cpp +++ b/DDG4/src/Geant4TrackingPostAction.cpp @@ -12,17 +12,16 @@ //========================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4TrackingPostAction.h" -#include "DDG4/Geant4TrackHandler.h" +#include +#include +#include // Geant4 include files -#include "G4TrackingManager.hh" +#include // C/C++ include files #include -using namespace std; using namespace dd4hep::sim; /// Helper class to manipulate strings @@ -81,7 +80,7 @@ void Geant4TrackingPostAction::end(const G4Track* tr) { Geant4TrackHandler track(tr); //Geant4TrackInformation* info = track.info(); - const string& proc = track.creatorProcess()->GetProcessName(); + const std::string& proc = track.creatorProcess()->GetProcessName(); StringV::const_iterator trIt = find_if(m_ignoredProcs.begin(), m_ignoredProcs.end(), FindString(proc)); if (trIt != m_ignoredProcs.end()) { warning("Particles created by processes of type %s are not kept!", (*trIt).c_str()); diff --git a/DDG4/src/Geant4TrackingPreAction.cpp b/DDG4/src/Geant4TrackingPreAction.cpp index a75deae26..00b8bd0c0 100644 --- a/DDG4/src/Geant4TrackingPreAction.cpp +++ b/DDG4/src/Geant4TrackingPreAction.cpp @@ -12,11 +12,11 @@ //========================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4TrackingPreAction.h" +#include +#include // Geant4 include files -#include "G4TrackingManager.hh" +#include using namespace dd4hep::sim; diff --git a/DDG4/src/Geant4UIManager.cpp b/DDG4/src/Geant4UIManager.cpp index 763d3877b..b4bb2c3c3 100644 --- a/DDG4/src/Geant4UIManager.cpp +++ b/DDG4/src/Geant4UIManager.cpp @@ -31,16 +31,15 @@ #include using namespace dd4hep::sim; -using namespace std; namespace { - string make_cmd(const string& cmd) { - return string( "/control/execute "+cmd); + std::string make_cmd(const std::string& cmd) { + return std::string( "/control/execute "+cmd); } } /// Initializing constructor -Geant4UIManager::Geant4UIManager(Geant4Context* ctxt, const string& nam) +Geant4UIManager::Geant4UIManager(Geant4Context* ctxt, const std::string& nam) : Geant4Action(ctxt,nam), m_vis(0), m_ui(0) { declareProperty("SetupUI", m_uiSetup=""); @@ -56,9 +55,9 @@ Geant4UIManager::Geant4UIManager(Geant4Context* ctxt, const string& nam) declareProperty("HaveVIS", m_haveVis=false); declareProperty("HaveUI", m_haveUI=true); declareProperty("Prompt", m_prompt); - context()->kernel().register_configure(bind(&Geant4UIManager::configure,this)); - context()->kernel().register_initialize(bind(&Geant4UIManager::initialize,this)); - context()->kernel().register_terminate(bind(&Geant4UIManager::terminate,this)); + context()->kernel().register_configure(std::bind(&Geant4UIManager::configure,this)); + context()->kernel().register_initialize(std::bind(&Geant4UIManager::initialize,this)); + context()->kernel().register_terminate(std::bind(&Geant4UIManager::terminate,this)); enableUI(); } @@ -113,7 +112,7 @@ void Geant4UIManager::terminate() { } /// Apply single command -void Geant4UIManager::applyCommand(const string& command) { +void Geant4UIManager::applyCommand(const std::string& command) { /// Get the pointer to the User Interface manager G4UImanager* mgr = G4UImanager::GetUIpointer(); if ( mgr ) { @@ -248,7 +247,7 @@ void Geant4UIManager::start() { /// No UI. Pure batch mode: Simply execute requested number of events long numEvent = context()->kernel().property("NumEvents").value(); - if(numEvent < 0) numEvent = numeric_limits::max(); + if(numEvent < 0) numEvent = std::numeric_limits::max(); info("++ Start run with %d events.",numEvent); try { context()->kernel().runManager().BeamOn(numEvent); diff --git a/DDG4/src/Geant4UIMessenger.cpp b/DDG4/src/Geant4UIMessenger.cpp index b875f128b..658565d44 100644 --- a/DDG4/src/Geant4UIMessenger.cpp +++ b/DDG4/src/Geant4UIMessenger.cpp @@ -12,19 +12,17 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/Primitives.h" -#include "DDG4/Geant4UIMessenger.h" +#include +#include +#include // Geant4 include files -#include "G4UIcmdWithoutParameter.hh" -#include "G4UIcmdWithAString.hh" +#include +#include // C/C++ include files #include -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; namespace { @@ -35,8 +33,8 @@ namespace { InstallProperties(Geant4UIMessenger::Commands& c, const std::string& p, G4UImessenger* m) : cmds(c), path(p), msg(m) { } - void operator()(const pair& o) { - string n = path + o.first; + void operator()(const std::pair& o) { + std::string n = path + o.first; G4UIcmdWithAString* cmd = new G4UIcmdWithAString(n.c_str(), msg); cmd->SetParameterName(o.first.c_str(), true); cmd->SetGuidance(("Property item of type " + o.second.type()).c_str()); @@ -45,7 +43,7 @@ namespace { }; } -Geant4UIMessenger::Geant4UIMessenger(const string& name, const string& path) +Geant4UIMessenger::Geant4UIMessenger(const std::string& name, const std::string& path) : G4UImessenger(), m_directory(0), m_properties(0), m_name(name), m_path(path) { m_directory = new G4UIdirectory(path.c_str()); printout(INFO, "Geant4UI", "+++ %s> Install Geant4 control directory:%s", name.c_str(), path.c_str()); @@ -89,7 +87,7 @@ void Geant4UIMessenger::exportProperties(PropertyManager& mgr) { G4String Geant4UIMessenger::GetCurrentValue(G4UIcommand * c) { Commands::iterator i = m_propertyCmd.find(c); if (m_properties && i != m_propertyCmd.end()) { - const string& n = (*i).second; + const std::string& n = (*i).second; return (*m_properties)[n].str(); } printout(INFO, "Geant4UI", @@ -101,7 +99,7 @@ G4String Geant4UIMessenger::GetCurrentValue(G4UIcommand * c) { void Geant4UIMessenger::SetNewValue(G4UIcommand *c, G4String v) { Commands::iterator i = m_propertyCmd.find(c); if (m_properties && i != m_propertyCmd.end()) { - const string& n = (*i).second; + const std::string& n = (*i).second; try { if (!v.empty()) { Property& p = (*m_properties)[n]; @@ -111,12 +109,12 @@ void Geant4UIMessenger::SetNewValue(G4UIcommand *c, G4String v) { m_name.c_str(), n.c_str(), v.c_str(), p.str().c_str()); } else { - string value = (*m_properties)[n].str(); + std::string value = (*m_properties)[n].str(); printout(INFO, "Geant4UI", "+++ %s> Unchanged property value %s = %s.", m_name.c_str(), n.c_str(), value.c_str()); } } - catch(const exception& e) { + catch(const std::exception& e) { printout(INFO, "Geant4UI", "+++ %s> Exception: Failed to change property %s = '%s'.", m_name.c_str(), n.c_str(), v.c_str()); printout(INFO, "Geant4UI", "+++ %s> Exception: %s", m_name.c_str(), e.what()); @@ -134,7 +132,7 @@ void Geant4UIMessenger::SetNewValue(G4UIcommand *c, G4String v) { const void* args[] = {v.c_str(), 0}; (*j).second.execute(args); } - catch(const exception& e) { + catch(const std::exception& e) { printout(INFO, "Geant4UI", "+++ %s> Exception: Failed to exec action '%s' [%s].", m_name.c_str(), c->GetCommandName().c_str(), c->GetCommandPath().c_str()); printout(INFO, "Geant4UI", "+++ %s> Exception: %s",e.what()); diff --git a/DDG4/src/Geant4UserInitialization.cpp b/DDG4/src/Geant4UserInitialization.cpp index 69c1357da..73c5920aa 100644 --- a/DDG4/src/Geant4UserInitialization.cpp +++ b/DDG4/src/Geant4UserInitialization.cpp @@ -12,17 +12,13 @@ //========================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4UserInitialization.h" +#include +#include -// C/C++ include files -#include - -using namespace std; using namespace dd4hep::sim; /// Standard constructor -Geant4UserInitialization::Geant4UserInitialization(Geant4Context* ctxt, const string& nam) +Geant4UserInitialization::Geant4UserInitialization(Geant4Context* ctxt, const std::string& nam) : Geant4Action(ctxt, nam) { m_needsControl = false; InstanceCount::increment(this); @@ -42,7 +38,7 @@ void Geant4UserInitialization::buildMaster() const { } /// Standard constructor -Geant4UserInitializationSequence::Geant4UserInitializationSequence(Geant4Context* ctxt, const string& nam) +Geant4UserInitializationSequence::Geant4UserInitializationSequence(Geant4Context* ctxt, const std::string& nam) : Geant4UserInitialization(ctxt, nam) { m_needsControl = false; InstanceCount::increment(this); @@ -64,7 +60,7 @@ void Geant4UserInitializationSequence::adopt(Geant4UserInitialization* action) m_actors.add(action); return; } - throw runtime_error("Geant4UserInitializationSequence: Attempt to add invalid actor!"); + except("Attempt to add invalid actor!"); } /// Callback function to build setup for the MT worker thread diff --git a/DDG4/src/Geant4UserLimits.cpp b/DDG4/src/Geant4UserLimits.cpp index 54e6c0602..b6ba4ecbc 100644 --- a/DDG4/src/Geant4UserLimits.cpp +++ b/DDG4/src/Geant4UserLimits.cpp @@ -12,29 +12,25 @@ //========================================================================== // Framework include files -#include "DDG4/Geant4UserLimits.h" -#include "DDG4/Geant4Particle.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/DD4hepUnits.h" -#include "DD4hep/Primitives.h" -#include "DD4hep/Printout.h" +#include +#include +#include +#include +#include +#include // Geant 4 include files -#include "G4Track.hh" -#include "G4ParticleDefinition.hh" -#include "CLHEP/Units/SystemOfUnits.h" +#include +#include +#include -// C/C++ include files -#include - -using namespace std; using namespace dd4hep::sim; namespace { bool user_limit_debug = false; } - /// Allow for debugging user limits (very verbose) +/// Allow for debugging user limits (very verbose) bool Geant4UserLimits::enable_debug(bool value) { bool tmp = user_limit_debug; user_limit_debug = value; @@ -48,21 +44,21 @@ double Geant4UserLimits::Handler::value(const G4Track& track) const { auto i = particleLimits.find(track.GetDefinition()); if ( i != particleLimits.end() ) { if ( user_limit_debug ) { - dd4hep::printout(dd4hep::INFO,"Geant4UserLimits", "Apply explicit limit %f to track: %s", - def->GetParticleName().c_str()); + dd4hep::printout(dd4hep::INFO,"Geant4UserLimits", "Apply explicit limit %f to track: %s", + def->GetParticleName().c_str()); } return (*i).second; } } if ( user_limit_debug ) { dd4hep::printout(dd4hep::INFO,"Geant4UserLimits", "Apply default limit %f to track: %s", - def->GetParticleName().c_str()); + def->GetParticleName().c_str()); } return defaultValue; } /// Set the handler value(s) -void Geant4UserLimits::Handler::set(const string& particles, double val) { +void Geant4UserLimits::Handler::set(const std::string& particles, double val) { if ( particles == "*" || particles == ".(.*)" ) { defaultValue = val; return; @@ -108,28 +104,28 @@ void Geant4UserLimits::update(LimitSet limitset) { else if (l.name == "range_min") minRange.set(l.particles, l.value); else - throw runtime_error("Unknown Geant4 user limit: " + l.toString()); + except("Geant4UserLimits", "Unknown Geant4 user limit: %s ", l.toString().c_str()); } } /// Setters may not be called! void Geant4UserLimits::SetMaxAllowedStep(G4double /* ustepMax */) { - dd4hep::notImplemented(string(__PRETTY_FUNCTION__)+" May not be called!"); + dd4hep::notImplemented(std::string(__PRETTY_FUNCTION__)+" May not be called!"); } void Geant4UserLimits::SetUserMaxTrackLength(G4double /* utrakMax */) { - dd4hep::notImplemented(string(__PRETTY_FUNCTION__)+" May not be called!"); + dd4hep::notImplemented(std::string(__PRETTY_FUNCTION__)+" May not be called!"); } void Geant4UserLimits::SetUserMaxTime(G4double /* utimeMax */) { - dd4hep::notImplemented(string(__PRETTY_FUNCTION__)+" May not be called!"); + dd4hep::notImplemented(std::string(__PRETTY_FUNCTION__)+" May not be called!"); } void Geant4UserLimits::SetUserMinEkine(G4double /* uekinMin */) { - dd4hep::notImplemented(string(__PRETTY_FUNCTION__)+" May not be called!"); + dd4hep::notImplemented(std::string(__PRETTY_FUNCTION__)+" May not be called!"); } void Geant4UserLimits::SetUserMinRange(G4double /* urangMin */) { - dd4hep::notImplemented(string(__PRETTY_FUNCTION__)+" May not be called!"); + dd4hep::notImplemented(std::string(__PRETTY_FUNCTION__)+" May not be called!"); } diff --git a/DDG4/src/Geant4Vertex.cpp b/DDG4/src/Geant4Vertex.cpp index 5ba2de1b6..ca8f158d0 100644 --- a/DDG4/src/Geant4Vertex.cpp +++ b/DDG4/src/Geant4Vertex.cpp @@ -12,11 +12,10 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4Vertex.h" +#include +#include +#include -using namespace dd4hep; using namespace dd4hep::sim; /// Default destructor diff --git a/DDG4/src/Geant4VolumeManager.cpp b/DDG4/src/Geant4VolumeManager.cpp index 7449c5a13..34a402e81 100644 --- a/DDG4/src/Geant4VolumeManager.cpp +++ b/DDG4/src/Geant4VolumeManager.cpp @@ -29,20 +29,17 @@ #include using namespace dd4hep::sim::Geant4GeometryMaps; -using namespace dd4hep::detail::tools; -using namespace dd4hep::detail; using namespace dd4hep::sim; using namespace dd4hep; -using namespace std; #include -typedef pair > > VolIDDescriptor; +typedef std::pair > > VolIDDescriptor; namespace { /// Helper class to populate the Geant4 volume manager struct Populator { - typedef vector Chain; - typedef map Registries; + typedef std::vector Chain; + typedef std::map Registries; /// Reference to the Detector instance const Detector& m_detDesc; /// Set of already added entries @@ -74,10 +71,10 @@ namespace { } /// Needed to compute the cellID of parameterized volumes for( const auto& pv : m_geo.g4Placements ) { - if ( pv.second->IsParameterised() ) - m_geo.g4Parameterised[pv.second] = pv.first; - if ( pv.second->IsReplicated() ) - m_geo.g4Replicated[pv.second] = pv.first; + if ( pv.second->IsParameterised() ) + m_geo.g4Parameterised[pv.second] = pv.first; + if ( pv.second->IsReplicated() ) + m_geo.g4Replicated[pv.second] = pv.first; } } @@ -133,14 +130,14 @@ namespace { node = *(k); PlacementMap::const_iterator g4pit = m_geo.g4Placements.find(node); if (g4pit != m_geo.g4Placements.end()) { - G4VPhysicalVolume* phys = (*g4pit).second; - if ( phys->IsParameterised() ) { - PlacedVolume pv(n); - PlacedVolumeExtension* ext = pv.data(); - if ( nullptr == ext->params->field ) { - ext->params->field = iddesc.field(ext->volIDs.at(0).first); - } - } + G4VPhysicalVolume* phys = (*g4pit).second; + if ( phys->IsParameterised() ) { + PlacedVolume pv(n); + PlacedVolumeExtension* ext = pv.data(); + if ( nullptr == ext->params->field ) { + ext->params->field = iddesc.field(ext->volIDs.at(0).first); + } + } path.emplace_back(phys); printout(print_chain, "Geant4VolumeManager", "+++ Chain: Node OK: %s [%s]", node->GetName(), phys->GetName().c_str()); @@ -171,21 +168,21 @@ namespace { printout(print_res, "Geant4VolumeManager", "+++ Map %016X to Geant4 Path:%s", (void*)code, Geant4GeometryInfo::placementPath(path).c_str()); if ( m_geo.g4Paths.find(path) == m_geo.g4Paths.end() ) { - Geant4GeometryInfo::PlacementFlags opt; - for(const auto* phys : path) { - opt.flags.path_has_parametrised = phys->IsParameterised() ? 1 : 0; - opt.flags.path_has_replicated = phys->IsReplicated() ? 1 : 0; - } - opt.flags.parametrised = path.front()->IsParameterised() ? 1 : 0; - opt.flags.replicated = path.front()->IsReplicated() ? 1 : 0; + Geant4GeometryInfo::PlacementFlags opt; + for(const auto* phys : path) { + opt.flags.path_has_parametrised = phys->IsParameterised() ? 1 : 0; + opt.flags.path_has_replicated = phys->IsReplicated() ? 1 : 0; + } + opt.flags.parametrised = path.front()->IsParameterised() ? 1 : 0; + opt.flags.replicated = path.front()->IsReplicated() ? 1 : 0; m_geo.g4Paths[path] = { code, opt.value }; m_entries.emplace(code,path); return; } - /// This is a normal case for parametrized volumes and no error - if ( !path.empty() && (path.front()->IsParameterised() || path.front()->IsReplicated()) ) { - return; - } + /// This is a normal case for parametrized volumes and no error + if ( !path.empty() && (path.front()->IsParameterised() || path.front()->IsReplicated()) ) { + return; + } printout(ERROR, "Geant4VolumeManager", "populate: Severe error: Duplicated Geant4 path!!!! %s %s", " [THIS SHOULD NEVER HAPPEN]",Geant4GeometryInfo::placementPath(path).c_str()); goto Err; @@ -195,10 +192,10 @@ namespace { goto Err; } else { - /// This is a normal case for parametrized volumes and no error - if ( !path.empty() && (path.front()->IsParameterised() || path.front()->IsReplicated()) ) { - return; - } + /// This is a normal case for parametrized volumes and no error + if ( !path.empty() && (path.front()->IsParameterised() || path.front()->IsReplicated()) ) { + return; + } } printout(ERROR, "Geant4VolumeManager", "populate: Severe error: Duplicated Volume entry: 0x%X" " [THIS SHOULD NEVER HAPPEN]", code); @@ -211,7 +208,7 @@ namespace { if ( !nodes.empty() ) printout(ERROR,"Geant4VolumeManager"," TGeo path: %s",detail::tools::placementPath(nodes,false).c_str()); printout(ERROR,"Geant4VolumeManager", " Offend.VolIDs: %s",detail::tools::toString(ro.idSpec(),ids,code).c_str()); - throw runtime_error("Failed to populate Geant4 volume manager!"); + throw std::runtime_error("Failed to populate Geant4 volume manager!"); } }; } @@ -224,11 +221,11 @@ Geant4VolumeManager::Geant4VolumeManager(const Detector& description, Geant4Geom p.populate(description.world()); return; } - throw runtime_error(format("Geant4VolumeManager", "Attempt populate from invalid Geant4 geometry info [Invalid-Info]")); + except("Geant4VolumeManager", "Attempt populate from invalid Geant4 geometry info [Invalid-Info]"); } /// Helper: Generate placement path from touchable object -vector +std::vector Geant4VolumeManager::placementPath(const G4VTouchable* touchable, bool exception) const { Geant4TouchableHandler handler(touchable); return handler.placementPath(exception); @@ -237,17 +234,17 @@ Geant4VolumeManager::placementPath(const G4VTouchable* touchable, bool exception /// Check the validity of the information before accessing it. bool Geant4VolumeManager::checkValidity() const { if (!isValid()) { - throw runtime_error(format("Geant4VolumeManager", "Attempt to use invalid Geant4 volume manager [Invalid-Handle]")); + except("Geant4VolumeManager", "Attempt to use invalid Geant4 volume manager [Invalid-Handle]"); } else if (!ptr()->valid) { - throw runtime_error(format("Geant4VolumeManager", "Attempt to use invalid Geant4 geometry info [Invalid-Info]")); + except("Geant4VolumeManager", "Attempt to use invalid Geant4 geometry info [Invalid-Info]"); } return true; } #if 0 /// Access CELLID by placement path -VolumeID Geant4VolumeManager::volumeID(const vector& path) const { +VolumeID Geant4VolumeManager::volumeID(const std::vector& path) const { if (!path.empty() && checkValidity()) { const auto& mapping = ptr()->g4Paths; auto i = mapping.find(path); @@ -268,7 +265,7 @@ VolumeID Geant4VolumeManager::volumeID(const vector& p /// Access CELLID by Geant4 touchable object VolumeID Geant4VolumeManager::volumeID(const G4VTouchable* touchable) const { Geant4TouchableHandler handler(touchable); - vector path = handler.placementPath(); + std::vector path = handler.placementPath(); if (!path.empty() && checkValidity()) { const auto& mapping = ptr()->g4Paths; auto i = mapping.find(path); @@ -276,36 +273,36 @@ VolumeID Geant4VolumeManager::volumeID(const G4VTouchable* touchable) const { const auto& e = (*i).second; /// No parametrization or replication. if ( e.flags == 0 ) { - return e.volumeID; + return e.volumeID; } VolumeID volid = e.volumeID; const auto& paramterised = ptr()->g4Parameterised; const auto& replicated = ptr()->g4Replicated; /// This is incredibly slow .... but what can I do ? Need a better idea. for ( std::size_t j=0; j < path.size(); ++j ) { - const auto* phys = path[j]; - if ( phys->IsParameterised() ) { - int copy_no = touchable->GetCopyNumber(j); - const auto it = paramterised.find(phys); - if ( it != paramterised.end() ) { - //printout(INFO,"Geant4VolumeManager", - // "Copy number: %ld <--> %ld", copy_no, long(phys->GetCopyNo())); - const auto* field = (*it).second.data()->params->field; - volid |= IDDescriptor::encode(field, copy_no); - continue; - } - except("Geant4VolumeManager","Error Geant4VolumeManager::volumeID(const G4VTouchable* touchable)"); - } - else if ( phys->IsReplicated() ) { - int copy_no = touchable->GetCopyNumber(j); - const auto it = replicated.find(phys); - if ( it != replicated.end() ) { - const auto* field = (*it).second.data()->params->field; - volid |= IDDescriptor::encode(field, copy_no); - continue; - } - except("Geant4VolumeManager","Error Geant4VolumeManager::volumeID(const G4VTouchable* touchable)"); - } + const auto* phys = path[j]; + if ( phys->IsParameterised() ) { + int copy_no = touchable->GetCopyNumber(j); + const auto it = paramterised.find(phys); + if ( it != paramterised.end() ) { + //printout(INFO,"Geant4VolumeManager", + // "Copy number: %ld <--> %ld", copy_no, long(phys->GetCopyNo())); + const auto* field = (*it).second.data()->params->field; + volid |= IDDescriptor::encode(field, copy_no); + continue; + } + except("Geant4VolumeManager","Error Geant4VolumeManager::volumeID(const G4VTouchable* touchable)"); + } + else if ( phys->IsReplicated() ) { + int copy_no = touchable->GetCopyNumber(j); + const auto it = replicated.find(phys); + if ( it != replicated.end() ) { + const auto* field = (*it).second.data()->params->field; + volid |= IDDescriptor::encode(field, copy_no); + continue; + } + except("Geant4VolumeManager","Error Geant4VolumeManager::volumeID(const G4VTouchable* touchable)"); + } } return volid; } @@ -320,7 +317,7 @@ VolumeID Geant4VolumeManager::volumeID(const G4VTouchable* touchable) const { } /// Accessfully decoded volume fields by placement path -void Geant4VolumeManager::volumeDescriptor(const vector& path, +void Geant4VolumeManager::volumeDescriptor(const std::vector& path, VolIDDescriptor& vol_desc) const { vol_desc.second.clear(); diff --git a/DDG4/src/IoStreams.cpp b/DDG4/src/IoStreams.cpp index ff9414f1a..a5b41d514 100644 --- a/DDG4/src/IoStreams.cpp +++ b/DDG4/src/IoStreams.cpp @@ -12,7 +12,10 @@ //========================================================================== // Framework includes -#include "DDG4/IoStreams.h" +#include + +// ROOT include files +#include // C/C++ include files #include @@ -20,11 +23,6 @@ #include #include -// ROOT include files -#include "TFile.h" - -using namespace dd4hep; - namespace { /// Anonymous cast class to get access to protected members of TFile ;-) class MyTFile : public TFile { diff --git a/DDG4/src/python/Geant4PythonAction.cpp b/DDG4/src/python/Geant4PythonAction.cpp index 66b7dc803..a130495ab 100644 --- a/DDG4/src/python/Geant4PythonAction.cpp +++ b/DDG4/src/python/Geant4PythonAction.cpp @@ -13,23 +13,17 @@ //========================================================================== // Framework include files -#include "DDG4/Factories.h" -#include "DDG4/Python/Geant4PythonAction.h" -#include "DDG4/Python/Geant4PythonCall.h" -#include "DDG4/Python/DDPython.h" +#include +#include +#include +#include -// C/C++ include files -#include -#include - -using namespace std; -using namespace dd4hep; using namespace dd4hep::sim; DECLARE_GEANT4ACTION(Geant4PythonAction) /// Standard constructor, initializes variables -Geant4PythonAction::Geant4PythonAction(Geant4Context* ctxt, const string& nam) +Geant4PythonAction::Geant4PythonAction(Geant4Context* ctxt, const std::string& nam) : Geant4Action(ctxt,nam) { m_needsControl = true; diff --git a/DDG4/src/python/Geant4PythonCall.cpp b/DDG4/src/python/Geant4PythonCall.cpp index 60f39683e..7a61eaa29 100644 --- a/DDG4/src/python/Geant4PythonCall.cpp +++ b/DDG4/src/python/Geant4PythonCall.cpp @@ -17,10 +17,6 @@ #include #include -// C/C++ include files -#include - -using namespace dd4hep; using namespace dd4hep::sim; /// Standard constructor, initializes variables diff --git a/DDG4/src/python/Geant4PythonDetectorConstruction.cpp b/DDG4/src/python/Geant4PythonDetectorConstruction.cpp index a8213a221..02056085a 100644 --- a/DDG4/src/python/Geant4PythonDetectorConstruction.cpp +++ b/DDG4/src/python/Geant4PythonDetectorConstruction.cpp @@ -12,21 +12,20 @@ // //========================================================================== // Framework include files -#include "DDG4/Geant4Context.h" -#include "DDG4/Geant4Kernel.h" +#include +#include -#include "DDG4/Python/DDPython.h" -#include "DDG4/Python/Geant4PythonAction.h" -#include "DDG4/Python/Geant4PythonDetectorConstruction.h" +#include +#include +#include -using namespace std; using namespace dd4hep::sim; -#include "DDG4/Factories.h" +#include DECLARE_GEANT4ACTION(Geant4PythonDetectorConstruction) /// Standard constructor, initializes variables -Geant4PythonDetectorConstruction::Geant4PythonDetectorConstruction(Geant4Context* ctxt, const string& nam) +Geant4PythonDetectorConstruction::Geant4PythonDetectorConstruction(Geant4Context* ctxt, const std::string& nam) : Geant4DetectorConstruction(ctxt,nam), m_constructSD(), m_constructFLD(), m_constructGEO() { @@ -49,7 +48,7 @@ void Geant4PythonDetectorConstruction::setConstructSensitives(PyObject* callable } /// Execute command in the python interpreter -void Geant4PythonDetectorConstruction::exec(const string& desc, const Geant4PythonCall& cmd) const { +void Geant4PythonDetectorConstruction::exec(const std::string& desc, const Geant4PythonCall& cmd) const { if ( cmd.isValid() ) { int ret = cmd.execute(); if ( ret != 1 ) { diff --git a/DDG4/src/python/Geant4PythonDetectorConstructionLast.cpp b/DDG4/src/python/Geant4PythonDetectorConstructionLast.cpp index caa699248..48eec5eb9 100644 --- a/DDG4/src/python/Geant4PythonDetectorConstructionLast.cpp +++ b/DDG4/src/python/Geant4PythonDetectorConstructionLast.cpp @@ -15,8 +15,8 @@ #define DD4HEP_DDG4_GEANT4PYTHONDETECTORCONSTRUCTIONLAST_H // Framework include files -#include "DDG4/Geant4DetectorConstruction.h" -#include "DDG4/Python/DDPython.h" +#include +#include /// Namespace for the AIDA detector description toolkit namespace dd4hep { diff --git a/DDG4/src/python/Geant4PythonInitialization.cpp b/DDG4/src/python/Geant4PythonInitialization.cpp index bb751becd..3d3151996 100644 --- a/DDG4/src/python/Geant4PythonInitialization.cpp +++ b/DDG4/src/python/Geant4PythonInitialization.cpp @@ -13,18 +13,17 @@ //========================================================================== // Framework include files -#include "DDG4/Factories.h" -#include "DDG4/Geant4Kernel.h" -#include "DDG4/Python/DDPython.h" -#include "DDG4/Python/Geant4PythonInitialization.h" +#include +#include +#include +#include -using namespace std; using namespace dd4hep::sim; DECLARE_GEANT4ACTION(Geant4PythonInitialization) /// Standard constructor, initializes variables -Geant4PythonInitialization::Geant4PythonInitialization(Geant4Context* ctxt, const string& nam) +Geant4PythonInitialization::Geant4PythonInitialization(Geant4Context* ctxt, const std::string& nam) : Geant4UserInitialization(ctxt,nam), m_masterSetup(), m_workerSetup() { m_needsControl = true; @@ -41,7 +40,7 @@ void Geant4PythonInitialization::setWorkerSetup(PyObject* callable, PyObject* ar } /// Execute command in the python interpreter -void Geant4PythonInitialization::exec(const string& desc, const Geant4PythonCall& cmd) const { +void Geant4PythonInitialization::exec(const std::string& desc, const Geant4PythonCall& cmd) const { if ( cmd.isValid() ) { int ret = cmd.execute(); if ( ret != 1 ) { diff --git a/DDG4/tpython/DDPython.cpp b/DDG4/tpython/DDPython.cpp index 7c02786ec..352ef97ad 100644 --- a/DDG4/tpython/DDPython.cpp +++ b/DDG4/tpython/DDPython.cpp @@ -20,8 +20,8 @@ #include // Framework include files -#include "DD4hep/Printout.h" -#include "DDG4/Python/DDPython.h" +#include +#include #if !defined(__MAKECINT__) && !defined(__CINT__) && !defined(G__DICTIONARY) // ----------------------------------------------------------------------------- @@ -38,13 +38,10 @@ #include "Python.h" #endif -using namespace std; -using namespace dd4hep; - namespace { - string loadScript(const string& fname) { - ifstream file(fname.c_str()); - stringstream str; + std::string loadScript(const std::string& fname) { + std::ifstream file(fname.c_str()); + std::stringstream str; if( file ) { char ch; while( file.get(ch) ) str.put(ch); @@ -54,14 +51,14 @@ namespace { return ""; } + static dd4hep::DDPython* _instance = 0; static int _blockers = 0; static pthread_t _mainThread = 0; static int _refCount = 0; - static DDPython* _instance = 0; static PyObject* _main_dict = 0; static PyThreadState *_save_state = 0; int _execPy(const char* cmd) { - DDPython::GILState state(0); + dd4hep::DDPython::GILState state(0); PyObject* ret = ::PyRun_String((char*)cmd, Py_file_input,_main_dict,_main_dict); if ( ::PyErr_Occurred() ) { ::PyErr_Print(); @@ -80,7 +77,7 @@ namespace { return 0; } int _evalPy(const char* cmd) { - DDPython::GILState state(0); + dd4hep::DDPython::GILState state(0); PyObject* ret = ::PyRun_String((char*)cmd, Py_eval_input,_main_dict,_main_dict); if ( ::PyErr_Occurred() ) { ::PyErr_Print(); @@ -100,44 +97,44 @@ namespace { } } -DDPython::GILState::GILState(int) : state(0) { +dd4hep::DDPython::GILState::GILState(int) : state(0) { if ( ::Py_IsInitialized() ) { PyGILState_STATE st = (PyGILState_STATE)::PyGILState_Ensure(); state = (int)st; } } -DDPython::GILState::~GILState() { +dd4hep::DDPython::GILState::~GILState() { if ( ::Py_IsInitialized() ) { PyGILState_STATE st = (PyGILState_STATE)state; ::PyGILState_Release(st); } } -DDPython::BlockThreads::BlockThreads(int) { +dd4hep::DDPython::BlockThreads::BlockThreads(int) { if ( _blockers == 0 ) { DDPython::restoreThread(); } ++_blockers; } -DDPython::BlockThreads::~BlockThreads() { +dd4hep::DDPython::BlockThreads::~BlockThreads() { --_blockers; if ( _blockers == 0 ) { DDPython::allowThreads(); } } -DDPython::AllowThreads::AllowThreads(int) { +dd4hep::DDPython::AllowThreads::AllowThreads(int) { DDPython::allowThreads(); } -DDPython::AllowThreads::~AllowThreads() { +dd4hep::DDPython::AllowThreads::~AllowThreads() { DDPython::restoreThread(); } /// Standard constructor, initializes variables -DDPython::DDPython() : context(0) { +dd4hep::DDPython::DDPython() : context(0) { ++_refCount; bool inited = ::Py_IsInitialized(); if ( !inited ) { @@ -173,7 +170,7 @@ DDPython::DDPython() : context(0) { } /// Default Destructor -DDPython::~DDPython() { +dd4hep::DDPython::~DDPython() { --_refCount; if ( 0 == _refCount && ::Py_IsInitialized() ) { dd4hep::printout(ALWAYS,"DDPython","+++ Shutdown python interpreter......"); @@ -190,32 +187,32 @@ DDPython::~DDPython() { } -DDPython DDPython::instance() { +dd4hep::DDPython dd4hep::DDPython::instance() { if ( 0 == _instance ) _instance = new DDPython(); return DDPython(); } /// Save thread state -void DDPython::allowThreads() { +void dd4hep::DDPython::allowThreads() { if ( !_save_state && ::Py_IsInitialized() ) { _save_state = ::PyEval_SaveThread(); } } -void DDPython::restoreThread() { +void dd4hep::DDPython::restoreThread() { if ( _save_state ) { ::PyEval_RestoreThread(_save_state); _save_state = 0; } } -int DDPython::setArgs(int argc, char** argv) const { +int dd4hep::DDPython::setArgs(int argc, char** argv) const { // Need to protect against API change from Python 2 to Python 3 #if PY_VERSION_HEX < 0x03000000 ::PySys_SetArgv(argc,argv); #else - vector wargs; - vector wargv; + std::vector wargs; + std::vector wargv; for(int i=0; i("\0")); } -void DDPython::afterFork() const { +void dd4hep::DDPython::afterFork() const { if ( ::Py_IsInitialized() ) { - cout << "[INFO] Re-init python after forking....." << endl; + std::cout << "[INFO] Re-init python after forking....." << std::endl; #if PY_VERSION_HEX < 0x03070000 ::PyOS_AfterFork(); #else @@ -319,21 +316,21 @@ void DDPython::afterFork() const { } } -void DDPython::setMainThread() { +void dd4hep::DDPython::setMainThread() { _mainThread = pthread_self(); } -bool DDPython::isMainThread() { +bool dd4hep::DDPython::isMainThread() { return _mainThread == pthread_self(); } /// Start the interpreter in normal mode without hacks like 'pythopn.exe' does. -int DDPython::run_interpreter(int argc, char** argv) { +int dd4hep::DDPython::run_interpreter(int argc, char** argv) { #if PY_VERSION_HEX < 0x03000000 return ::Py_Main(argc, argv); #else - vector wargs; - vector wargv; + std::vector wargs; + std::vector wargv; for(int i=0; i Date: Mon, 12 Feb 2024 09:43:19 +0100 Subject: [PATCH 13/14] Fix compilation error --- DDCore/src/XML/Utilities.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DDCore/src/XML/Utilities.cpp b/DDCore/src/XML/Utilities.cpp index f26e7b4b7..6ffbf2445 100644 --- a/DDCore/src/XML/Utilities.cpp +++ b/DDCore/src/XML/Utilities.cpp @@ -20,6 +20,7 @@ #include #include +// Forward declarations class TObject; using namespace dd4hep::xml::tools; @@ -174,8 +175,7 @@ dd4hep::Volume dd4hep::xml::createPlacedEnvelope( dd4hep::Detector& description, rot = RotationZYX( env_rot.z(),env_rot.y(),env_rot.x() ) ; } - Volume envelope ; - + Volume envelope; if( x_shape.typeStr() == "Assembly" ){ envelope = Assembly( det_name+"_assembly" ) ; } else { @@ -183,8 +183,9 @@ dd4hep::Volume dd4hep::xml::createPlacedEnvelope( dd4hep::Detector& description, Box env_solid = xml_comp_t( x_shape ).createShape(); if( !env_solid.isValid() ){ - dd4hep::except("createPlacedEnvelope","Cannot create envelope volume : %s for detector %s.", - x_shape.typeStr(), det_name.c_str()); + dd4hep::except("createPlacedEnvelope", + "Cannot create envelope volume : %s for detector %s.", + x_shape.typeStr().c_str(), det_name.c_str()); } Material env_mat = description.material( x_shape.materialStr() ); envelope = Volume( det_name+"_envelope", env_solid, env_mat ); From 85935a06b946a32f34b1ffd22f1df8803976673e Mon Sep 17 00:00:00 2001 From: Markus Frank Date: Mon, 12 Feb 2024 11:28:38 +0100 Subject: [PATCH 14/14] Fix compilation error --- DDAlign/src/GlobalAlignmentStack.cpp | 1 + DDCond/src/ConditionsDependencyHandler.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/DDAlign/src/GlobalAlignmentStack.cpp b/DDAlign/src/GlobalAlignmentStack.cpp index 846885e70..d6aaf8f4d 100644 --- a/DDAlign/src/GlobalAlignmentStack.cpp +++ b/DDAlign/src/GlobalAlignmentStack.cpp @@ -95,6 +95,7 @@ GlobalAlignmentStack::~GlobalAlignmentStack() { GlobalAlignmentStack& GlobalAlignmentStack::get() { if ( _stack().get() ) return *_stack(); except("GlobalAlignmentStack", "Stack not allocated -- may not be retrieved!"); + throw std::runtime_error("Stack not allocated"); } /// Create an alignment stack instance. The creation of a second instance will be refused. diff --git a/DDCond/src/ConditionsDependencyHandler.cpp b/DDCond/src/ConditionsDependencyHandler.cpp index 29fd5c2ab..97aee01fe 100644 --- a/DDCond/src/ConditionsDependencyHandler.cpp +++ b/DDCond/src/ConditionsDependencyHandler.cpp @@ -26,7 +26,7 @@ namespace { return d->target.name; #else char text[64]; - ConditionKey::KeyMaker key(d->target.hash); + dd4hep::ConditionKey::KeyMaker key(d->target.hash); ::snprintf(text,sizeof(text),"%08X %08X",key.values.det_key, key.values.item_key); return text; #endif