diff --git a/DDAlign/src/AlignmentsCalib.cpp b/DDAlign/src/AlignmentsCalib.cpp index 3ce1c5617edb237b7febd9bbe88d59d9d70a837a..60a6fa36b31785bf5564f929ae17f380f7a8502c 100644 --- a/DDAlign/src/AlignmentsCalib.cpp +++ b/DDAlign/src/AlignmentsCalib.cpp @@ -98,7 +98,7 @@ AlignmentsCalib::_set(DetElement detector, const Delta& delta) { entry->source = src_cond; entry->target = tar_key.hash; entry->dirty = 1; - return *(used.insert(make_pair(tar_key,entry.release())).first); + return *(used.emplace(tar_key,entry.release()).first); } /// (1) Add a new entry to an existing DetElement structure. diff --git a/DDAlign/src/GlobalAlignmentCache.cpp b/DDAlign/src/GlobalAlignmentCache.cpp index c177f8c0f757e031966e19452c285e2423b85665..28b4a423537d6d89354edfbc565d735f53080d52 100644 --- a/DDAlign/src/GlobalAlignmentCache.cpp +++ b/DDAlign/src/GlobalAlignmentCache.cpp @@ -177,7 +177,7 @@ GlobalAlignmentCache* GlobalAlignmentCache::subdetectorAlignments(const string& SubdetectorAlignments::const_iterator i = m_detectors.find(nam); if ( i == m_detectors.end() ) { GlobalAlignmentCache* ptr = new GlobalAlignmentCache(m_detDesc,nam,false); - m_detectors.insert(make_pair(nam,ptr)); + m_detectors.emplace(nam,ptr); return ptr; } return (*i).second; @@ -196,7 +196,7 @@ void GlobalAlignmentCache::apply(GlobalAlignmentStack& stack) { DetElement det = _detector(e->detector); all[det].emplace_back(e); if ( stack.hasMatrix(*e) || stack.needsReset(*e) || stack.resetChildren(*e) ) { - detelt_updates.insert(make_pair(e->detector.path(),e->detector)); + detelt_updates.emplace(e->detector.path(),e->detector); } } for(sd_entries_t::iterator i=all.begin(); i!=all.end(); ++i) { diff --git a/DDAlign/src/GlobalAlignmentOperators.cpp b/DDAlign/src/GlobalAlignmentOperators.cpp index 5d3fff15ac07a4caef1e4647ca3e715b6f3e472c..5e64fcd6e5328eb31eb1e64983e66ef9090d3de5 100644 --- a/DDAlign/src/GlobalAlignmentOperators.cpp +++ b/DDAlign/src/GlobalAlignmentOperators.cpp @@ -33,7 +33,7 @@ void GlobalAlignmentOperator::insert(GlobalAlignment alignment) const { void GlobalAlignmentSelector::operator()(Entries::value_type e) const { TGeoPhysicalNode* pn = 0; - nodes.insert(make_pair(e->path,make_pair(pn,e))); + nodes.emplace(e->path,make_pair(pn,e)); } void GlobalAlignmentSelector::operator()(const Cache::value_type& entry) const { @@ -44,11 +44,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.insert(make_pair(p,make_pair(pn,e))); + nodes.emplace(p,make_pair(pn,e)); break; } else if ( e->path == p ) { - nodes.insert(make_pair(p,make_pair(pn,e))); + nodes.emplace(p,make_pair(pn,e)); break; } } diff --git a/DDAlign/src/GlobalAlignmentStack.cpp b/DDAlign/src/GlobalAlignmentStack.cpp index 1a87663a759c0f4a8c96387cdec8de200d9fe2ef..292594bf5a8eee8485a20498431c9db18a326c4b 100644 --- a/DDAlign/src/GlobalAlignmentStack.cpp +++ b/DDAlign/src/GlobalAlignmentStack.cpp @@ -146,7 +146,7 @@ bool GlobalAlignmentStack::add(dd4hep_ptr<StackEntry>& entry) { throw runtime_error("GlobalAlignmentStack> Invalid alignment entry [No such detector]"); } printout(INFO,"GlobalAlignmentStack","Add node:%s",e->path.c_str()); - m_stack.insert(make_pair(e->path,entry.release())); + m_stack.emplace(e->path,entry.release()); return true; } throw runtime_error("GlobalAlignmentStack> The entry with path "+entry->path+ diff --git a/DDAlign/src/GlobalDetectorAlignment.cpp b/DDAlign/src/GlobalDetectorAlignment.cpp index 35b26fb4e69ea01fa705c328922fc00512241427..57fcecc4dfd02a22a3e83614621d8e2f1889528e 100644 --- a/DDAlign/src/GlobalDetectorAlignment.cpp +++ b/DDAlign/src/GlobalDetectorAlignment.cpp @@ -130,11 +130,11 @@ namespace { // << " " << string((*j)->GetName()) << " "; if ( ::strcmp((*j).ptr()->GetName(),(*k).placement().ptr()->GetName()) ) { //cout << "[DE]"; - elements.emplace_back(make_pair(level,*k)); + elements.emplace_back(level,*k); ++k; } else { - //elements.emplace_back(make_pair(level,DetElement())); + //elements.emplace_back(level,DetElement()); } //cout << " "; } diff --git a/DDCond/src/ConditionsContent.cpp b/DDCond/src/ConditionsContent.cpp index 27c9e6df3c17c065c55b1a8d0aa5f38023763a7f..d66ada4ae4c8ed5d78a43aead66b2a1c8d33f312 100644 --- a/DDCond/src/ConditionsContent.cpp +++ b/DDCond/src/ConditionsContent.cpp @@ -54,7 +54,7 @@ void ConditionsContent::merge(const ConditionsContent& to_add) { auto& cond = to_add.conditions(); auto& deriv = to_add.derived(); for( const auto& c : cond ) { - auto ret = m_conditions.insert(c); + auto ret = m_conditions.emplace(c); if ( ret.second ) { c.second->addRef(); continue; @@ -66,7 +66,7 @@ void ConditionsContent::merge(const ConditionsContent& to_add) { } for( const auto& d : deriv ) { - auto ret = m_derived.insert(d); + auto ret = m_derived.emplace(d); if ( ret.second ) { d.second->addRef(); continue; @@ -97,7 +97,7 @@ bool ConditionsContent::remove(Condition::key_type hash) { pair<Condition::key_type, ConditionsLoadInfo*> ConditionsContent::insertKey(Condition::key_type hash) { - auto ret = m_conditions.insert(make_pair(hash,(ConditionsLoadInfo*)0)); + auto ret = m_conditions.emplace(hash,(ConditionsLoadInfo*)0); if ( ret.second ) return pair<Condition::key_type, ConditionsLoadInfo*>(hash,0); return pair<Condition::key_type, ConditionsLoadInfo*>(0,0); } @@ -106,7 +106,7 @@ ConditionsContent::insertKey(Condition::key_type hash) { pair<Condition::key_type, ConditionsLoadInfo*> ConditionsContent::addLocationInfo(Condition::key_type hash, ConditionsLoadInfo* info) { if ( info ) { - auto ret = m_conditions.insert(make_pair(hash,info)); + auto ret = m_conditions.emplace(hash,info); if ( ret.second ) { info->addRef(); return *(ret.first); @@ -120,7 +120,7 @@ ConditionsContent::addLocationInfo(Condition::key_type hash, ConditionsLoadInfo* pair<Condition::key_type, ConditionDependency*> ConditionsContent::addDependency(ConditionDependency* dep) { - auto ret = m_derived.insert(make_pair(dep->key(),dep)); + auto ret = m_derived.emplace(dep->key(),dep); if ( ret.second ) { dep->addRef(); return *(ret.first); diff --git a/DDCond/src/Type1/Manager_Type1.cpp b/DDCond/src/Type1/Manager_Type1.cpp index ef655e8e137aa4c30ee8655854580aa4013b61e9..c3ae16fe86d860a370af8deec2b23134d6e16a90 100644 --- a/DDCond/src/Type1/Manager_Type1.cpp +++ b/DDCond/src/Type1/Manager_Type1.cpp @@ -230,7 +230,7 @@ ConditionsPool* Manager_Type1::registerIOV(const IOVType& typ, IOV::Key key) { iov->keyData = key; const void* argv_pool[] = {this, iov, 0}; shared_ptr<ConditionsPool> cond_pool(createPlugin<ConditionsPool>(m_poolType,m_detDesc,2,argv_pool)); - pool->elements.insert(make_pair(key,cond_pool)); + pool->elements.emplace(key,cond_pool); printout(INFO,"ConditionsMgr","Created IOV Pool for:%s",iov->str().c_str()); return cond_pool.get(); } diff --git a/DDCond/src/plugins/ConditionsUserPool.cpp b/DDCond/src/plugins/ConditionsUserPool.cpp index 878cbb111d3b9aa3ff2f18a167f78a46358a23dd..68e20619847136b1fac0ac15538165c2cdbde20f 100644 --- a/DDCond/src/plugins/ConditionsUserPool.cpp +++ b/DDCond/src/plugins/ConditionsUserPool.cpp @@ -186,10 +186,10 @@ namespace { T& m; MapSelector(T& o) : m(o) {} bool operator()(Condition::Object* o) const - { return m.insert(make_pair(o->hash,o)).second; } + { return m.emplace(o->hash,o).second; } }; template <typename T> MapSelector<T> mapSelector(T& container) - { return MapSelector<T>(container); } + { return MapSelector<T>(container); } template <typename T> struct Inserter { T& m; @@ -197,7 +197,7 @@ namespace { Inserter(T& o, IOV* i=0) : m(o), iov(i) {} void operator()(const Condition& c) { Condition::Object* o = c.ptr(); - m.insert(make_pair(o->hash,o)); + m.emplace(o->hash,o); if ( iov ) iov->iov_intersection(o->iov->key()); } void operator()(const pair<Condition::key_type,Condition>& e) { (*this)(e.second); } @@ -242,7 +242,7 @@ ConditionsMappedUserPool<MAPPING>::i_findCondition(Condition::key_type key) con template<typename MAPPING> inline bool ConditionsMappedUserPool<MAPPING>::i_insert(Condition::Object* o) { - int ret = m_conditions.insert(make_pair(o->hash,o)).second; + int ret = m_conditions.emplace(o->hash,o).second; if ( flags&PRINT_INSERT ) { printout(INFO,"UserPool","++ %s condition [%016llX]: %s.", ret ? "Successfully inserted" : "FAILED to insert", o->hash, @@ -461,7 +461,7 @@ size_t ConditionsMappedUserPool<MAPPING>::compute(const Dependencies& deps, /// This condition is no longer valid. remove it! /// It will be added again by the handler. m_conditions.erase(j); - missing.insert(i); + missing.emplace(i); } continue; } @@ -469,7 +469,7 @@ size_t ConditionsMappedUserPool<MAPPING>::compute(const Dependencies& deps, m_conditions.erase(j); } } - missing.insert(i); + missing.emplace(i); } if ( !missing.empty() ) { ConditionsManagerObject* m(m_manager.access()); @@ -615,7 +615,7 @@ ConditionsMappedUserPool<MAPPING>::prepare(const IOV& required, for( auto i = calc_missing.begin(); i != last_calc; ++i ) { typename MAPPING::iterator j = m_conditions.find((*i).first); if ( j == m_conditions.end() ) - slice_miss_calc.insert(*i); + slice_miss_calc.emplace(*i); } } } @@ -758,7 +758,7 @@ ConditionsMappedUserPool<MAPPING>::compute(const IOV& required, for(auto i=calc_missing.begin(); i != last_calc; ++i) { typename MAPPING::iterator j = m_conditions.find((*i).first); if ( j == m_conditions.end() ) - slice_miss_calc.insert(*i); + slice_miss_calc.emplace(*i); } } } diff --git a/DDCore/include/DD4hep/DetectorData.h b/DDCore/include/DD4hep/DetectorData.h index 976ba15b649230d3273414a7210e6072bd205466..5208a2c7be2361c1148791f47a09843624ec681e 100644 --- a/DDCore/include/DD4hep/DetectorData.h +++ b/DDCore/include/DD4hep/DetectorData.h @@ -64,7 +64,7 @@ namespace dd4hep { void append(const Handle<NamedObject>& e, bool throw_on_doubles = true) { if (e.isValid()) { std::string n = e.name(); - std::pair<iterator, bool> r = this->insert(std::make_pair(n, e.ptr())); + std::pair<iterator, bool> r = this->emplace(n, e.ptr()); if (!throw_on_doubles || r.second) { if (not r.second) { printout(WARNING,"Detector","+++ Object '%s' is already defined and new one will be ignored", n.c_str()); diff --git a/DDCore/include/DD4hep/detail/ContainerHelpers.h b/DDCore/include/DD4hep/detail/ContainerHelpers.h index 2f3de195c40c81444b82799ee4d6a67e10b39521..9ba202369c31cf3b064337ff56dc3eaefb66d2ee 100644 --- a/DDCore/include/DD4hep/detail/ContainerHelpers.h +++ b/DDCore/include/DD4hep/detail/ContainerHelpers.h @@ -62,51 +62,51 @@ namespace dd4hep { template <typename Q, typename T> void insert_item(std::map<Q,T>& c, Q de, const T& d) { - c.insert(std::make_pair(de,d)); + c.emplace(de,d); } template <typename Q, typename T> void insert_item(std::map<T,Q>& c, Q de, const T& d) { - c.insert(std::make_pair(d,de)); + c.emplace(d,de); } template <typename Q, typename T> void insert_item(std::vector<std::pair<Q,T> >& c, Q de, const T& d) { - c.emplace_back(std::make_pair(de,d)); + c.emplace_back(de,d); } template <typename Q, typename T> void insert_item(std::vector<std::pair<std::string,T> >& c, Q de, const T& d) { - c.emplace_back(std::make_pair(de.path(),d)); + c.emplace_back(de.path(),d); } template <typename Q, typename T> void insert_item(std::list<std::pair<Q,T> >& c, Q de, const T& d) { - c.emplace_back(std::make_pair(de,d)); + c.emplace_back(de,d); } template <typename Q, typename T> void insert_item(std::list<std::pair<std::string,T> >& c, Q de, const T& d) { - c.emplace_back(std::make_pair(de.path(),d)); + c.emplace_back(de.path(),d); } template <typename Q, typename T> void insert_item(std::set<std::pair<Q,T> >& c, Q de, const T& d) { - c.insert(std::make_pair(de,d)); + c.emplace(de,d); } template <typename Q, typename T> void insert_item(std::set<std::pair<std::string,T> >& c, Q de, const T& d) { - c.insert(std::make_pair(de.path(),d)); + c.emplace(de.path(),d); } template <typename Q, typename T> void insert_item(std::multimap<Q,T>& c, Q de, const T& d) { - c.insert(std::make_pair(de,d)); + c.emplace(de,d); } template <typename Q, typename T> void insert_item(std::map<std::string,T>& c, Q de, const T& d) { - c.insert(std::make_pair(de.path(),d)); + c.emplace(de.path(),d); } template <typename Q, typename T> void insert_item(std::multimap<std::string,T>& c, Q de, const T& d) { - c.insert(std::make_pair(de.path(),d)); + c.emplace(de.path(),d); } } // End namespace dd4hep #endif // DD4HEP_DD4HEP_CONTAINERHELPERS_H diff --git a/DDCore/src/AlignmentNominalMap.cpp b/DDCore/src/AlignmentNominalMap.cpp index 46b055f43c2243925494b487fd5682faedb01f0e..547ebb5acfc7f0796968c45a35acf872a19bd931 100644 --- a/DDCore/src/AlignmentNominalMap.cpp +++ b/DDCore/src/AlignmentNominalMap.cpp @@ -29,7 +29,7 @@ AlignmentsNominalMap::AlignmentsNominalMap(DetElement wrld) : world(wrld) { bool AlignmentsNominalMap::insert(DetElement detector, Condition::itemkey_type key, Condition condition) { - auto res = data.insert(std::make_pair(ConditionKey(detector,key).hash,condition)); + auto res = data.emplace(ConditionKey(detector,key).hash,condition); return res.second; } diff --git a/DDCore/src/AlignmentsCalculator.cpp b/DDCore/src/AlignmentsCalculator.cpp index 491dfb92214306f082ebda339b87229f222ecad7..b186591ea1415cc58bdcaef1fe677101a45a1618 100644 --- a/DDCore/src/AlignmentsCalculator.cpp +++ b/DDCore/src/AlignmentsCalculator.cpp @@ -89,9 +89,9 @@ namespace dd4hep { void insert(DetElement det, const Delta* delta) { if ( det.isValid() ) { Entry entry(det,delta); - detectors.insert(std::make_pair(det, entries.size())); - keys.insert(std::make_pair(entry.key, entries.size())); - entries.insert(entries.end(), entry); + detectors.emplace(det, entries.size()); + keys.emplace(entry.key, entries.size()); + entries.emplace_back(entry); return; } except("AlignContext","Failed to add entry: invalid detector handle!"); @@ -112,7 +112,7 @@ int AlignmentsCalculator::Scanner::operator()(DetElement de, int) const { Condition c = context.condition(key, false); if ( c.isValid() ) { const Delta& d = c.get<Delta>(); - deltas.insert(std::make_pair(de,&d)); + deltas.emplace(de,&d); if ( iov ) iov->iov_intersection(c->iov->key()); } return 1; @@ -229,7 +229,7 @@ Result AlignmentsCalculator::compute(const std::map<DetElement, Delta>& deltas, // OrderedDeltas ordered_deltas; for( const auto& i : deltas ) - ordered_deltas.insert(std::make_pair(i.first, &i.second)); + ordered_deltas.emplace(i.first, &i.second); return compute(ordered_deltas, alignments); } @@ -285,7 +285,7 @@ size_t AlignmentsCalculator::extract_deltas(DetElement start, if ( idd != extract_context.end() ) { const Delta& d = c.get<Delta>(); DetElement de = idd->second; - delta_conditions.insert(std::make_pair(de,&d)); + delta_conditions.emplace(de,&d); if (effective_iov) effective_iov->iov_intersection(c->iov->key()); return 1; } @@ -300,7 +300,7 @@ size_t AlignmentsCalculator::extract_deltas(DetElement start, return deltas.size(); } DetectorScanner().scan(AlignmentsCalculator::Scanner(ctxt,deltas,effective_iov),start); - for( const auto& d : deltas ) extract_context.insert(std::make_pair(d.first.key(), d.first)); + for( const auto& d : deltas ) extract_context.emplace(d.first.key(), d.first); return deltas.size(); } diff --git a/DDCore/src/BasicGrammar.cpp b/DDCore/src/BasicGrammar.cpp index bca5abee26a4af6e022330522dae66337896160e..431aa0565633f8de4fc3b88a0b66f64c8837e940 100644 --- a/DDCore/src/BasicGrammar.cpp +++ b/DDCore/src/BasicGrammar.cpp @@ -42,7 +42,7 @@ namespace { dd4hep::BasicGrammar::BasicGrammar(const std::string& typ) : name(typ), hash_value(dd4hep::detail::hash64(typ)) { - if ( !registry().insert(std::make_pair(hash_value,this)).second ) { + if ( !registry().emplace(hash_value,this).second ) { // Error: Already existing grammar. dd4hep::except("BasicGrammar","FAILED to add existent registry: %s [%016llX]",name.c_str(), hash_value); } diff --git a/DDCore/src/ComponentProperties.cpp b/DDCore/src/ComponentProperties.cpp index 6befee4c0f9bf92362a8f5077e78caed715dea45..f3662acad47a86e8523c6dca599e26debd09b10c 100644 --- a/DDCore/src/ComponentProperties.cpp +++ b/DDCore/src/ComponentProperties.cpp @@ -201,7 +201,7 @@ const Property& PropertyManager::operator[](const string& name) const { /// Add a new property void PropertyManager::add(const string& name, const Property& prop) { verifyNonExistence(name); - m_properties.insert(make_pair(name, prop)); + m_properties.emplace(name, prop); } /// Bulk set of all properties diff --git a/DDCore/src/ConditionsMap.cpp b/DDCore/src/ConditionsMap.cpp index fe2942ba0dad0072e85fde8e11d60d9959abf396..c9f496a11bb1fafa704c684e9a38d3750bcce426 100644 --- a/DDCore/src/ConditionsMap.cpp +++ b/DDCore/src/ConditionsMap.cpp @@ -96,7 +96,7 @@ std::vector<Condition> ConditionsMap::get(DetElement detector, /// Insert a new entry to the map template <typename T> bool ConditionsMapping<T>::insert(DetElement detector, Condition::itemkey_type key, Condition condition) { - auto res = data.insert(std::make_pair(ConditionKey(detector,key).hash,condition)); + auto res = data.emplace(ConditionKey(detector,key).hash,condition); return res.second; } @@ -140,7 +140,7 @@ namespace dd4hep { template <> bool ConditionsMapping<std::multimap<Condition::key_type,Condition> > ::insert(DetElement detector, Condition::itemkey_type key, Condition condition) { - data.insert(std::make_pair(ConditionKey(detector,key).hash,condition)); + data.emplace(ConditionKey(detector,key).hash,condition); return true; } diff --git a/DDCore/src/DetectorImp.cpp b/DDCore/src/DetectorImp.cpp index 14b28c64f7c1ee615ef356381565f5b49d4d5d75..6b9f98b57c7094215bc8995559e23f1f174ffa04 100644 --- a/DDCore/src/DetectorImp.cpp +++ b/DDCore/src/DetectorImp.cpp @@ -82,7 +82,7 @@ namespace { void insert(const string& name, Detector* detector) { auto i = detectors.find(name); if ( i==detectors.end() ) { - detectors.insert(make_pair(name,detector)); + detectors.emplace(name,detector); return; } except("DD4hep","Cannot insert detector instance %s [Already present]",name.c_str()); @@ -261,7 +261,7 @@ void DetectorImp::declareParent(const string& detector_name, const DetElement& p if (i == m_detectorParents.end()) { Volume parent_volume = parent.placement().volume(); if ( parent_volume.isValid() ) { - m_detectorParents.insert(make_pair(detector_name,parent)); + m_detectorParents.emplace(detector_name,parent); return; } except("DD4hep","+++ Failed to access valid parent volume of %s from %s", diff --git a/DDCore/src/DetectorInterna.cpp b/DDCore/src/DetectorInterna.cpp index 9fad854e422bbc37febd5867b6ee3c7323da9ad6..e7f89d39e133ed41c92fc34b78f00aa8158ee1c0 100644 --- a/DDCore/src/DetectorInterna.cpp +++ b/DDCore/src/DetectorInterna.cpp @@ -121,8 +121,8 @@ DetElementObject* DetElementObject::clone(int new_id, int flg) const { DetElement c = d.clone(d.id, DetElement::COPY_PLACEMENT); c->SetName(d.GetName()); c->SetTitle(d.GetTitle()); - pair<DetElement::Children::iterator, bool> r = obj->children.insert(make_pair(c.name(), c)); - if (r.second) { + bool r = obj->children.emplace(c.name(), c).second; + if ( r ) { c._data().parent = obj; } else { diff --git a/DDCore/src/GeoHandler.cpp b/DDCore/src/GeoHandler.cpp index faea76e28d3bb2ba6c341cb8fcafd1ff59895eab..d5785b506f4a0ad83439457aecbf0ed9278e6113 100644 --- a/DDCore/src/GeoHandler.cpp +++ b/DDCore/src/GeoHandler.cpp @@ -93,11 +93,11 @@ GeoHandler& GeoHandler::collect(DetElement element, GeometryInfo& info) { Volume vol(v); // Note : assemblies and the world do not have a real volume nor a material if (info.volumeSet.find(vol) == info.volumeSet.end()) { - info.volumeSet.insert(vol); + info.volumeSet.emplace(vol); info.volumes.emplace_back(vol); } if (m.isValid()) - info.materials.insert(m); + info.materials.emplace(m); if (dynamic_cast<Volume::Object*>(v)) { VisAttr vis = vol.visAttributes(); //Region reg = vol.region(); @@ -105,10 +105,10 @@ GeoHandler& GeoHandler::collect(DetElement element, GeometryInfo& info) { //SensitiveDetector det = vol.sensitiveDetector(); if (vis.isValid()) - info.vis.insert(vis); - //if ( lim.isValid() ) info.limits[lim.ptr()].insert(v); - //if ( reg.isValid() ) info.regions[reg.ptr()].insert(v); - //if ( det.isValid() ) info.sensitives[det.ptr()].insert(v); + info.vis.emplace(vis); + //if ( lim.isValid() ) info.limits[lim.ptr()].emplace(v); + //if ( reg.isValid() ) info.regions[reg.ptr()].emplace(v); + //if ( det.isValid() ) info.sensitives[det.ptr()].emplace(v); } collectSolid(info, v->GetName(), n->GetName(), v->GetShape(), n->GetMatrix()); } @@ -135,7 +135,7 @@ GeoHandler& GeoHandler::i_collect(const TGeoNode* current, int level, Region rg, vol.setLimitSet(limits); } } - (*m_data)[level].insert(current); + (*m_data)[level].emplace(current); //printf("GeoHandler: collect level:%d %s\n",level,current->GetName()); if (num_children > 0) { for (int i = 0; i < num_children; ++i) { diff --git a/DDCore/src/OpaqueDataBinder.cpp b/DDCore/src/OpaqueDataBinder.cpp index 554e1a23008c47eaa576c24023c57bc01b0c4158..7d30173f5688f9740e4104b75cec9a74127eedb4 100644 --- a/DDCore/src/OpaqueDataBinder.cpp +++ b/DDCore/src/OpaqueDataBinder.cpp @@ -136,11 +136,11 @@ namespace dd4hep { } template<typename BINDER, typename OBJECT, typename KEY, typename VAL> - static void insert_map_item(const BINDER&, - OBJECT& object, - const KEY& k, - const string& val, - const VAL*) + static void emplace_map_item(const BINDER&, + OBJECT& object, + const KEY& k, + const string& val, + const VAL*) { typedef map<KEY,VAL> map_t; map_t& m = object.template get<map_t>(); @@ -148,49 +148,49 @@ namespace dd4hep { if ( !BasicGrammar::instance<VAL>().fromString(&v, val) ) { except("OpaqueDataBinder","++ Failed to convert conditions map entry."); } - m.insert(make_pair(k,v)); + m.emplace(k,v); } template<typename BINDER, typename OBJECT, typename KEY> - static void insert_map_key(const BINDER& b, - OBJECT& object, - const string& key_val, - const string& val_type, - const string& val, - const KEY*) + static void emplace_map_key(const BINDER& b, + OBJECT& object, + const string& key_val, + const string& val_type, + const string& val, + const KEY*) { KEY key; BasicGrammar::instance<KEY>().fromString(&key, key_val); // Short and char is not part of the standard dictionaries. Fall back to 'int'. if ( val_type.substr(0,4) == "char" ) - insert_map_item(b, object, key, val, (int*)0); + emplace_map_item(b, object, key, val, (int*)0); else if ( val_type.substr(0,5) == "short" ) - insert_map_item(b, object, key, val, (int*)0); + emplace_map_item(b, object, key, val, (int*)0); else if ( val_type.substr(0,3) == "int" ) - insert_map_item(b, object, key, val, (int*)0); + emplace_map_item(b, object, key, val, (int*)0); else if ( val_type.substr(0,4) == "long" ) - insert_map_item(b, object, key, val, (long*)0); + emplace_map_item(b, object, key, val, (long*)0); else if ( val_type.substr(0,5) == "float" ) - insert_map_item(b, object, key, val, (float*)0); + emplace_map_item(b, object, key, val, (float*)0); else if ( val_type.substr(0,6) == "double" ) - insert_map_item(b, object, key, val, (double*)0); + emplace_map_item(b, object, key, val, (double*)0); else if ( val_type.substr(0,6) == "string" ) - insert_map_item(b, object, key, val, (string*)0); + emplace_map_item(b, object, key, val, (string*)0); else if ( val_type == "std::string" ) - insert_map_item(b, object, key, val, (string*)0); + emplace_map_item(b, object, key, val, (string*)0); else { printout(INFO,"Param","++ Unknown conditions parameter type:%s data:%s", val_type.c_str(),val.c_str()); - insert_map_item(b, object, key, val, (string*)0); + emplace_map_item(b, object, key, val, (string*)0); } } template<typename BINDER, typename OBJECT, typename KEY, typename VAL> - static void insert_map_pair(const BINDER&, - OBJECT& object, - const string& data, - const KEY*, - const VAL*) + static void emplace_map_pair(const BINDER&, + OBJECT& object, + const string& data, + const KEY*, + const VAL*) { typedef map<KEY,VAL> map_t; pair<KEY,VAL> entry; @@ -198,37 +198,37 @@ namespace dd4hep { if ( !BasicGrammar::instance<pair<KEY,VAL> >().fromString(&entry,data) ) { except("OpaqueDataBinder","++ Failed to convert conditions map entry."); } - m.insert(entry); + m.emplace(entry); } template<typename BINDER, typename OBJECT, typename KEY> - static void insert_map_data(const BINDER& b, - OBJECT& object, - const string& val_type, - const string& pair_data, - const KEY*) + static void emplace_map_data(const BINDER& b, + OBJECT& object, + const string& val_type, + const string& pair_data, + const KEY*) { // Short and char is not part of the standard dictionaries. Fall back to 'int'. if ( val_type.substr(0,4) == "char" ) - insert_map_pair(b, object, pair_data, (KEY*)0, (int*)0); + emplace_map_pair(b, object, pair_data, (KEY*)0, (int*)0); else if ( val_type.substr(0,5) == "short" ) - insert_map_pair(b, object, pair_data, (KEY*)0, (int*)0); + emplace_map_pair(b, object, pair_data, (KEY*)0, (int*)0); else if ( val_type.substr(0,3) == "int" ) - insert_map_pair(b, object, pair_data, (KEY*)0, (int*)0); + emplace_map_pair(b, object, pair_data, (KEY*)0, (int*)0); else if ( val_type.substr(0,4) == "long" ) - insert_map_pair(b, object, pair_data, (KEY*)0, (long*)0); + emplace_map_pair(b, object, pair_data, (KEY*)0, (long*)0); else if ( val_type.substr(0,5) == "float" ) - insert_map_pair(b, object, pair_data, (KEY*)0, (float*)0); + emplace_map_pair(b, object, pair_data, (KEY*)0, (float*)0); else if ( val_type.substr(0,6) == "double" ) - insert_map_pair(b, object, pair_data, (KEY*)0, (double*)0); + emplace_map_pair(b, object, pair_data, (KEY*)0, (double*)0); else if ( val_type.substr(0,6) == "string" ) - insert_map_pair(b, object, pair_data, (KEY*)0, (string*)0); + emplace_map_pair(b, object, pair_data, (KEY*)0, (string*)0); else if ( val_type == "std::string" ) - insert_map_pair(b, object, pair_data, (KEY*)0, (string*)0); + emplace_map_pair(b, object, pair_data, (KEY*)0, (string*)0); else { printout(INFO,"Param","++ Unknown conditions parameter type:%s data:%s", val_type.c_str(),pair_data.c_str()); - insert_map_pair(b, object, pair_data, (KEY*)0, (string*)0); + emplace_map_pair(b, object, pair_data, (KEY*)0, (string*)0); } } @@ -308,27 +308,27 @@ namespace dd4hep { const string& val_type, const string& val) { if ( key_type.substr(0,3) == "int" ) - insert_map_key(b, object, key, val_type, val, Primitive<int>::null_pointer()); + emplace_map_key(b, object, key, val_type, val, Primitive<int>::null_pointer()); #if defined(DD4HEP_HAVE_ALL_PARSERS) // Short and char is not part of the standard dictionaries. Fall back to 'int'. else if ( key_type.substr(0,4) == "char" ) - insert_map_key(b, object, key, val_type, val, Primitive<int>::null_pointer()); + emplace_map_key(b, object, key, val_type, val, Primitive<int>::null_pointer()); else if ( key_type.substr(0,5) == "short" ) - insert_map_key(b, object, key, val_type, val, Primitive<int>::null_pointer()); + emplace_map_key(b, object, key, val_type, val, Primitive<int>::null_pointer()); else if ( key_type.substr(0,4) == "long" ) - insert_map_key(b, object, key, val_type, val, Primitive<long>::null_pointer()); + emplace_map_key(b, object, key, val_type, val, Primitive<long>::null_pointer()); else if ( key_type.substr(0,5) == "float" ) - insert_map_key(b, object, key, val_type, val, Primitive<float>::null_pointer()); + emplace_map_key(b, object, key, val_type, val, Primitive<float>::null_pointer()); else if ( key_type.substr(0,6) == "double" ) - insert_map_key(b, object, key, val_type, val, Primitive<double>::null_pointer()); + emplace_map_key(b, object, key, val_type, val, Primitive<double>::null_pointer()); #endif else if ( key_type.substr(0,6) == "string" ) - insert_map_key(b, object, key, val_type, val, Primitive<string>::null_pointer()); + emplace_map_key(b, object, key, val_type, val, Primitive<string>::null_pointer()); else if ( key_type == "std::string" ) - insert_map_key(b, object, key, val_type, val, Primitive<string>::null_pointer()); + emplace_map_key(b, object, key, val_type, val, Primitive<string>::null_pointer()); else { printout(INFO,"OpaqueDataBinder","++ Unknown MAP-conditions key-type:%s",key_type.c_str()); - insert_map_key(b, object, key, val_type, val, Primitive<string>::null_pointer()); + emplace_map_key(b, object, key, val_type, val, Primitive<string>::null_pointer()); } return true; } @@ -340,27 +340,27 @@ namespace dd4hep { const std::string& pair_data) { if ( key_type.substr(0,3) == "int" ) - insert_map_data(b, object, val_type, pair_data, Primitive<int>::null_pointer()); + emplace_map_data(b, object, val_type, pair_data, Primitive<int>::null_pointer()); #if defined(DD4HEP_HAVE_ALL_PARSERS) // Short and char is not part of the standard dictionaries. Fall back to 'int'. else if ( key_type.substr(0,4) == "char" ) - insert_map_data(b, object, val_type, pair_data, Primitive<int>::null_pointer()); + emplace_map_data(b, object, val_type, pair_data, Primitive<int>::null_pointer()); else if ( key_type.substr(0,5) == "short" ) - insert_map_data(b, object, val_type, pair_data, Primitive<int>::null_pointer()); + emplace_map_data(b, object, val_type, pair_data, Primitive<int>::null_pointer()); else if ( key_type.substr(0,4) == "long" ) - insert_map_data(b, object, val_type, pair_data, Primitive<long>::null_pointer()); + emplace_map_data(b, object, val_type, pair_data, Primitive<long>::null_pointer()); else if ( key_type.substr(0,5) == "float" ) - insert_map_data(b, object, val_type, pair_data, Primitive<float>::null_pointer()); + emplace_map_data(b, object, val_type, pair_data, Primitive<float>::null_pointer()); else if ( key_type.substr(0,6) == "double" ) - insert_map_data(b, object, val_type, pair_data, Primitive<double>::null_pointer()); + emplace_map_data(b, object, val_type, pair_data, Primitive<double>::null_pointer()); #endif else if ( key_type.substr(0,6) == "string" ) - insert_map_data(b, object, val_type, pair_data, Primitive<string>::null_pointer()); + emplace_map_data(b, object, val_type, pair_data, Primitive<string>::null_pointer()); else if ( key_type == "std::string" ) - insert_map_data(b, object, val_type, pair_data, Primitive<string>::null_pointer()); + emplace_map_data(b, object, val_type, pair_data, Primitive<string>::null_pointer()); else { printout(INFO,"OpaqueDataBinder","++ Unknown MAP-conditions key-type:%s",key_type.c_str()); - insert_map_data(b, object, val_type, pair_data, Primitive<string>::null_pointer()); + emplace_map_data(b, object, val_type, pair_data, Primitive<string>::null_pointer()); } return true; } diff --git a/DDCore/src/OpticalSurfaceManager.cpp b/DDCore/src/OpticalSurfaceManager.cpp index 1e43b414494e0e1cc8b684ea35bd197d1f056c3e..e7844687772ee95b6e86dff4bb25532bc2955352 100644 --- a/DDCore/src/OpticalSurfaceManager.cpp +++ b/DDCore/src/OpticalSurfaceManager.cpp @@ -97,7 +97,7 @@ OpticalSurface OpticalSurfaceManager::opticalSurface(const string& full_nam) co /// Add skin surface to manager void OpticalSurfaceManager::addSkinSurface(DetElement de, SkinSurface surf) const { - if ( access()->skinSurfaces.insert(make_pair(make_pair(de,surf->GetName()), surf)).second ) + if ( access()->skinSurfaces.emplace(make_pair(de,surf->GetName()), surf).second ) return; except("OpticalSurfaceManager","++ Skin surface %s already present for DE:%s.", surf->GetName(), de.name()); @@ -105,7 +105,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.insert(make_pair(make_pair(de,surf->GetName()), surf)).second ) + if ( access()->borderSurfaces.emplace(make_pair(de,surf->GetName()), surf).second ) return; except("OpticalSurfaceManager","++ Border surface %s already present for DE:%s.", surf->GetName(), de.name()); @@ -113,7 +113,7 @@ void OpticalSurfaceManager::addBorderSurface(DetElement de, BorderSurface surf) /// Add optical surface data to manager void OpticalSurfaceManager::addOpticalSurface(OpticalSurface surf) const { - if ( access()->opticalSurfaces.insert(make_pair(surf->GetName(), surf)).second ) + if ( access()->opticalSurfaces.emplace(surf->GetName(), surf).second ) return; except("OpticalSurfaceManager","++ Optical surface %s already present.", surf->GetName()); diff --git a/DDCore/src/PluginTester.cpp b/DDCore/src/PluginTester.cpp index 951cc12b3fc719ba004be02de9bb6a7fd2a64743..8607486f5112f62179b892784ffd58bb1842e5c8 100644 --- a/DDCore/src/PluginTester.cpp +++ b/DDCore/src/PluginTester.cpp @@ -67,7 +67,7 @@ void* PluginTester::addExtension(void* ptr, const std::string& name, const std:: Entry entry; entry.destruct = dtor; entry.id = ++s_extensionID; - extensionMap->insert(make_pair(&info, entry)); + extensionMap->emplace(&info, entry); } return extensions[key] = ptr; } diff --git a/DDCore/src/VolumeManager.cpp b/DDCore/src/VolumeManager.cpp index d30073f250e4ffb9affc78c995a5493b4e5691f2..19a5b510502a5d421d6a628feac11f93067bb005 100644 --- a/DDCore/src/VolumeManager.cpp +++ b/DDCore/src/VolumeManager.cpp @@ -402,7 +402,7 @@ VolumeManager VolumeManager::addSubdetector(DetElement det, Readout ro) { "valid placement VolIDs are allowed. [Invalid DetElement:" + det_name + "]"); } - i = o.subdetectors.insert(make_pair(det, VolumeManager(det,ro))).first; + i = o.subdetectors.emplace(det, VolumeManager(det,ro)).first; const auto& id = (*vit); VolumeManager m = (*i).second; const BitFieldElement* field = ro.idSpec().field(id.first); diff --git a/DDCore/src/Volumes.cpp b/DDCore/src/Volumes.cpp index 5e0502d50a077a5256656f2ec0fe17ff8b741655..492bb47dc9ed0b293e3b2403c30d0bfda2ced186 100644 --- a/DDCore/src/Volumes.cpp +++ b/DDCore/src/Volumes.cpp @@ -407,7 +407,7 @@ PlacedVolumeExtension::VolIDs::insert(const string& name, int value) { if (i != this->Base::end()) { return make_pair(i, false); } - i = this->Base::insert(this->Base::end(), make_pair(name, value)); + i = this->Base::emplace(this->Base::end(), name, value); return make_pair(i, true); } diff --git a/DDCore/src/XML/VolumeBuilder.cpp b/DDCore/src/XML/VolumeBuilder.cpp index add297ba70ff0048d2be1b97af8bc1a536fc719a..bf24c8620a57bd4e04065541dcee2ffc1c155a8d 100644 --- a/DDCore/src/XML/VolumeBuilder.cpp +++ b/DDCore/src/XML/VolumeBuilder.cpp @@ -143,7 +143,7 @@ Solid VolumeBuilder::makeShape(xml_h handle) { if ( !buildMatch(build,buildType) ) { printout(INFO,"VolumeBuilder", "+++ Shape %s does NOT match build requirements. [Ignored]",nam.c_str()); - if ( !nam.empty() ) shape_veto.insert(nam); + if ( !nam.empty() ) shape_veto.emplace(nam); return Solid(); } } @@ -157,7 +157,7 @@ Solid VolumeBuilder::makeShape(xml_h handle) { /// And register it if it is not anonymous if ( !nam.empty() ) { solid.setName(nam); - shapes.insert(make_pair(nam,make_pair(handle,solid))); + shapes.emplace(nam,make_pair(handle,solid)); } printout(debug ? ALWAYS : DEBUG, "VolumeBuilder", "+++ Created shape of type: %s name: %s",type.c_str(), nam.c_str()); @@ -179,7 +179,7 @@ size_t VolumeBuilder::buildShapes(xml_h handle) { if ( !buildMatch(build,buildType) ) { printout(INFO,"VolumeBuilder", "+++ Shape %s does NOT match build requirements. [Ignored]",nam.c_str()); - shape_veto.insert(nam); + shape_veto.emplace(nam); continue; } } @@ -192,7 +192,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.insert(make_pair(nam,make_pair(c,solid))); + shapes.emplace(nam,make_pair(c,solid)); continue; } except("VolumeBuilder","+++ Shape %s is already known to this builder unit. " @@ -225,7 +225,7 @@ size_t VolumeBuilder::buildVolumes(xml_h handle) { string typ = c.attr<string>(attr); Volume vol = xml::createVolume(description, typ, c); vol.setAttributes(description,x.regionStr(),x.limitsStr(),x.visStr()); - volumes.insert(make_pair(nam,make_pair(c,vol))); + volumes.emplace(nam,make_pair(c,vol)); /// Check if the volume is sensitive if ( is_sensitive ) { vol.setSensitiveDetector(sensitive); @@ -255,7 +255,7 @@ size_t VolumeBuilder::buildVolumes(xml_h handle) { Volume vol(nam, solid, mat); placeDaughters(detector, vol, x); vol.setAttributes(description,x.regionStr(),x.limitsStr(),x.visStr()); - volumes.insert(make_pair(nam,make_pair(c,vol))); + volumes.emplace(nam,make_pair(c,vol)); /// Check if the volume is sensitive if ( is_sensitive ) { vol.setSensitiveDetector(sensitive); @@ -274,7 +274,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.insert(make_pair(nam,make_pair(c,vol))); + volumes.emplace(nam,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()); @@ -465,7 +465,7 @@ size_t VolumeBuilder::buildTransformations(Handle_t handle) { size_t len = transformations.size(); for( xml_coll_t c(handle,_U(transformation)); c; ++c ) { string nam = xml_comp_t(c).nameStr(); - transformations.insert(make_pair(nam,make_pair(c,xml::createTransformation(c)))); + transformations.emplace(nam,make_pair(c,xml::createTransformation(c))); } return transformations.size() - len; } diff --git a/DDCore/src/XML/XMLElements.cpp b/DDCore/src/XML/XMLElements.cpp index 8b4f2b4ed9aa2ce63770f53aa9be873d7dcd746c..f9b996140c04b4de186e2928b00ea72c7c6cedc2 100644 --- a/DDCore/src/XML/XMLElements.cpp +++ b/DDCore/src/XML/XMLElements.cpp @@ -1032,7 +1032,7 @@ unsigned int Handle_t::checksum(unsigned int param, fcn_t fcn) const { map<string,string> m; TiXmlElement* e = n->ToElement(); TiXmlAttribute* p=e->FirstAttribute(); - for(; p; p=p->Next()) m.insert(make_pair(p->Name(),p->Value())); + for(; p; p=p->Next()) m.emplace(p->Name(),p->Value()); param = (*fcn)(param,e->Value(),::strlen(e->Value())); for(StringMap::const_iterator i=m.begin();i!=m.end();++i) { param = (*fcn)(param,(*i).first.c_str(),(*i).first.length()); diff --git a/DDCore/src/gdml/DetElementCreator.cpp b/DDCore/src/gdml/DetElementCreator.cpp index 392b3c2b2017b4448934241552824e308a28c6dd..8223c2079bf5b024d18a8d4cd23564daf3705bdd 100644 --- a/DDCore/src/gdml/DetElementCreator.cpp +++ b/DDCore/src/gdml/DetElementCreator.cpp @@ -271,7 +271,7 @@ DetElement DetElementCreator::addSubdetector(const std::string& nam, PlacedVolum if ( volid ) { det.placement().addPhysVolID("system",det.id()); } - idet = subdetectors.insert(make_pair(nam,det)).first; + idet = subdetectors.emplace(nam,det).first; description.add(det); printout(printLevel,"DetElementCreator","++ Added sub-detector element: %s",det.path().c_str()); } diff --git a/DDCore/src/plugins/CodeGenerator.cpp b/DDCore/src/plugins/CodeGenerator.cpp index 68378147c8428652579bdeaf34841047c253f145..adb222d07bf6fedd7ea4caf842ef10897a726286 100644 --- a/DDCore/src/plugins/CodeGenerator.cpp +++ b/DDCore/src/plugins/CodeGenerator.cpp @@ -280,7 +280,7 @@ namespace { ostream& Actor::handleStructure(ostream& log, DetElement parent, DetElement de) { if ( de.isValid() && detelements.find(de) == detelements.end() ) { string name = obj_name("de", de.ptr()); - detelements.insert(make_pair(de,name)); + detelements.emplace(de,name); if ( !parent.isValid() ) { cout << "No parent: " << de.path() << " " << pointer(de) << " " << pointer(detector.world()) << endl; log << endl @@ -320,12 +320,12 @@ namespace { TGeoMatrix* mat = node->GetMatrix(); string name = obj_name("vol", vol); - placements.insert(make_pair(node,name)); + placements.emplace(node,name); handleMatrix(log, mat); if ( vol && volumes.find(vol) == volumes.end() ) { - volumes.insert(make_pair(vol,name)); + volumes.emplace(vol,name); if ( vol->IsA() == TGeoVolumeAssembly::Class() ) { log << "{" << newline; log << "\t Assembly vol(\"" << vol->GetName() << "\");" << newline; @@ -384,7 +384,7 @@ namespace { ostream& Actor::handleMaterial(ostream& log, TGeoMedium* medium) { if ( medium && materials.find(medium) == materials.end() ) { string name = obj_name("material",medium); - materials.insert(make_pair(medium,name)); + materials.emplace(medium,name); TGeoMaterial* material = medium->GetMaterial(); log << "{" << newline << "\t TGeoManager& mgr = detector.manager();" << newline @@ -456,7 +456,7 @@ namespace { return log; } - shapes.insert(make_pair(shape,name)); + shapes.emplace(shape,name); TClass* cl = shape->IsA(); log << "{" << newline; diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp index 80858ded86aae3c3c6b699fdc6710f8e45e024b9..5793f0eed67f4e6840fd615450d04a26ea6a8adc 100644 --- a/DDCore/src/plugins/Compact2Objects.cpp +++ b/DDCore/src/plugins/Compact2Objects.cpp @@ -1032,10 +1032,10 @@ template <> void Converter<Property>::operator()(xml_h e) const { vector<xml_attr_t> a = e.attributes(); if ( prp.find(name) == prp.end() ) - prp.insert(make_pair(name, Detector::PropertyValues())); + prp.emplace(name, Detector::PropertyValues()); for (xml_attr_t i : a ) - prp[name].insert(make_pair(xml_tag_t(e.attr_name(i)).str(),e.attr<string>(i))); + prp[name].emplace(xml_tag_t(e.attr_name(i)).str(),e.attr<string>(i)); } /** Specialized converter for electric and magnetic fields @@ -1069,10 +1069,10 @@ template <> void Converter<CartesianField>::operator()(xml_h e) const { string props_name = c.attr<string>(_U(name)); vector<xml_attr_t>a = c.attributes(); if ( prp.find(props_name) == prp.end() ) { - prp.insert(make_pair(props_name, Detector::PropertyValues())); + prp.emplace(props_name, Detector::PropertyValues()); } for ( xml_attr_t i : a ) - prp[props_name].insert(make_pair(xml_tag_t(c.attr_name(i)).str(), c.attr<string>(i))); + prp[props_name].emplace(xml_tag_t(c.attr_name(i)).str(), c.attr<string>(i)); if (c.hasAttr(_U(global)) && c.attr<bool>(_U(global))) { description.field().properties() = prp; diff --git a/DDCore/src/python/PythonPlugin.cpp b/DDCore/src/python/PythonPlugin.cpp index 1a0e2beae87079b3e9719debea21c02c1f3c34d5..70ecfe17d12631386c519e62b80992528e5cb637 100644 --- a/DDCore/src/python/PythonPlugin.cpp +++ b/DDCore/src/python/PythonPlugin.cpp @@ -56,17 +56,17 @@ namespace { vector<pair<string, string> > commands; for(int i = 0; i < argc && argv[i]; ++i) { if ( 0 == ::strncmp("-import",argv[i],2) ) - commands.emplace_back(make_pair("import",argv[++i])); + commands.emplace_back("import",argv[++i]); else if ( 0 == ::strncmp("-dd4hep", argv[i],2) ) - commands.emplace_back(make_pair("exec","import dd4hep")); + commands.emplace_back("exec","import dd4hep"); else if ( 0 == ::strncmp("-macro", argv[i],2) ) - commands.emplace_back(make_pair("macro",argv[++i])); + commands.emplace_back("macro",argv[++i]); else if ( 0 == ::strncmp("-exec", argv[i],2) ) - commands.emplace_back(make_pair("exec",argv[++i])); + commands.emplace_back("exec",argv[++i]); else if ( 0 == ::strncmp("-eval", argv[i],2) ) - commands.emplace_back(make_pair("calc",argv[++i])); + commands.emplace_back("calc",argv[++i]); else if ( 0 == ::strncmp("-prompt", argv[i],2) ) - commands.emplace_back(make_pair("prompt","")); + commands.emplace_back("prompt",""); else usage(argc, argv); } diff --git a/DDEve/src/ContextMenu.cpp b/DDEve/src/ContextMenu.cpp index 1089a96c55bc59fc35d231862138a5f93d0dac4d..c7744e5ec97e065ef8eec247776ad58879b6c124 100644 --- a/DDEve/src/ContextMenu.cpp +++ b/DDEve/src/ContextMenu.cpp @@ -68,7 +68,7 @@ ContextMenu& ContextMenu::instance(TClass* cl) { Contexts::const_iterator i = mapped_entries().find(cl->GetName()); if ( i != mapped_entries().end() ) return *((*i).second); ContextMenu* m = new ContextMenu(cl); - mapped_entries().insert(make_pair(cl->GetName(),m)); + mapped_entries().emplace(cl->GetName(),m); return *m; } diff --git a/DDEve/src/DDG4EventHandler.cpp b/DDEve/src/DDG4EventHandler.cpp index 69b51e11bf40d546b43311b96565e21e0db95ebb..e5ba92b914ef271855b5c8bfdf0807cbb6c7b1cd 100644 --- a/DDEve/src/DDG4EventHandler.cpp +++ b/DDEve/src/DDG4EventHandler.cpp @@ -175,7 +175,7 @@ Int_t DDG4EventHandler::ReadEvent(Long64_t event_number) { for(Branches::const_iterator i=m_branches.begin(); i != m_branches.end(); ++i) { TBranch* b = (*i).second.first; std::vector<void*>* ptr_data = *(std::vector<void*>**)b->GetAddress(); - m_data[b->GetClassName()].push_back(make_pair(b->GetName(),ptr_data->size())); + m_data[b->GetClassName()].emplace_back(b->GetName(),ptr_data->size()); } m_hasEvent = true; return nbytes; diff --git a/DDEve/src/Display.cpp b/DDEve/src/Display.cpp index c56b594c92a4b5edc0f6aca4fd90bd12d0718fd0..d68d1dd9561f05a8c67fd6dbaffee99d46a24101 100644 --- a/DDEve/src/Display.cpp +++ b/DDEve/src/Display.cpp @@ -232,7 +232,7 @@ Display::CalodataContext& Display::GetCaloHistogram(const string& nam) { ctx.config.hits = hits; ctx.config.name = nam; } - i = m_calodata.insert(make_pair(nam,ctx)).first; + i = m_calodata.emplace(nam,ctx).first; return (*i).second; } throw runtime_error("Cannot access calodata configuration "+nam); diff --git a/DDEve/src/ParticleActors.cpp b/DDEve/src/ParticleActors.cpp index cd9b63176f405d7a90f51348b2c3a1bcc1008dc5..56aaea7d771b9ba8a70487850be61d5a453c1931 100644 --- a/DDEve/src/ParticleActors.cpp +++ b/DDEve/src/ParticleActors.cpp @@ -67,7 +67,7 @@ void MCParticleCreator::addCompound(const std::string& name, TEveLine* e) { static int icol = 0; TEveCompound* o = new TEveCompound(name.c_str(),name.c_str()); particles->AddElement(o); - i = types.insert(make_pair(name,o)).first; + i = types.emplace(name,o).first; Color_t col = Colors[icol%(sizeof(Colors)/sizeof(Colors[0]))]; col += icol/sizeof(Colors)/sizeof(Colors[0]); o->SetMainColor(col); @@ -86,7 +86,7 @@ void MCParticleCreator::addCompoundLight(const std::string& name, TEveLine* e) static int icol = 0; TEveCompound* o = new TEveCompound(name.c_str(),name.c_str()); particles->AddElement(o); - i = types.insert(make_pair(name,o)).first; + i = types.emplace(name,o).first; o->SetMainColor(kBlack); o->CSCApplyMainColorToAllChildren(); ++icol; diff --git a/DDG4/include/DDG4/Geant4DataConversion.h b/DDG4/include/DDG4/Geant4DataConversion.h index 4d683466e9870c0be002a407e8c39eaae8e71135..189b38d4d407f3ffade6c8b8042b3502c0c13c21 100644 --- a/DDG4/include/DDG4/Geant4DataConversion.h +++ b/DDG4/include/DDG4/Geant4DataConversion.h @@ -129,7 +129,7 @@ namespace dd4hep { typedef Geant4Conversion<output_t,arg_t> self_t; Geant4DataConversion(void*) : Geant4Conversion<OUTPUT,ARGS>() { - this->self_t::conversions().insert(make_pair(&typeid(TAG),this)); + this->self_t::conversions().emplace(&typeid(TAG),this); //std::cout << "Registered " << typeName(typeid(*this)) << std::endl; } virtual OUTPUT* operator()(const ARGS& args) const; diff --git a/DDG4/include/DDG4/Geant4HitCollection.h b/DDG4/include/DDG4/Geant4HitCollection.h index dde711f127178fc3983c615540e698a1e24357b4..9e25b178c6ed33bbb90d1698f6c642f2fbf2fe88 100644 --- a/DDG4/include/DDG4/Geant4HitCollection.h +++ b/DDG4/include/DDG4/Geant4HitCollection.h @@ -338,7 +338,7 @@ namespace dd4hep { /// Add a new hit with a check, that the hit is of the same type template <typename TYPE> void add(VolumeID key, TYPE* hit_pointer) { m_lastHit = m_hits.size(); - std::pair<Keys::iterator,bool> ret = m_keys.insert(std::make_pair(key,m_lastHit)); + std::pair<Keys::iterator,bool> ret = m_keys.emplace(key,m_lastHit); if ( ret.second ) { Geant4HitWrapper w(m_manipulator->castHit(hit_pointer)); m_hits.emplace_back(w); diff --git a/DDG4/lcio/LCIOEventReader.cpp b/DDG4/lcio/LCIOEventReader.cpp index 64aedadaad1ef23ea6869b4ba640e85892355ceb..ae0a8a9c4b4669f937f0f7c2a8de0f68fa8dbf08 100644 --- a/DDG4/lcio/LCIOEventReader.cpp +++ b/DDG4/lcio/LCIOEventReader.cpp @@ -140,7 +140,7 @@ LCIOEventReader::readParticles(int event_number, if ( p->parents.size() == 0 ) { Geant4Vertex* vtx = new Geant4Vertex ; - vertices.push_back( vtx ); + vertices.emplace_back( vtx ); vtx->x = p->vsx; vtx->y = p->vsy; vtx->z = p->vsz; @@ -157,7 +157,7 @@ LCIOEventReader::readParticles(int event_number, if ( mcp->hasLeftDetector() ) status.set(G4PARTICLE_SIM_LEFT_DETECTOR); if ( mcp->isStopped() ) status.set(G4PARTICLE_SIM_STOPPED); if ( mcp->isOverlay() ) status.set(G4PARTICLE_SIM_OVERLAY); - particles.push_back(p); + particles.emplace_back(p); } return EVENT_READER_OK; } diff --git a/DDG4/plugins/Geant4EventReaderGuineaPig.cpp b/DDG4/plugins/Geant4EventReaderGuineaPig.cpp index c7b4c4ef8e490a058f7f277bcf9db26974a3828d..61087b8405aea6cfe1f31973528e540b4cdfa3f6 100644 --- a/DDG4/plugins/Geant4EventReaderGuineaPig.cpp +++ b/DDG4/plugins/Geant4EventReaderGuineaPig.cpp @@ -258,10 +258,10 @@ Geant4EventReaderGuineaPig::readParticles(int /* event_number */, // Add the particle to the collection vector - particles.push_back(p); + particles.emplace_back(p); // create a new vertex for this particle - vertices.push_back( vtx) ; + vertices.emplace_back(vtx); } // End loop over particles diff --git a/DDG4/plugins/Geant4EventReaderHepEvt.cpp b/DDG4/plugins/Geant4EventReaderHepEvt.cpp index 1cac6db735f91127b12a4257eb2afbe84711b46f..68395917bd303613da238ddb90a2fa20db1e7541 100644 --- a/DDG4/plugins/Geant4EventReaderHepEvt.cpp +++ b/DDG4/plugins/Geant4EventReaderHepEvt.cpp @@ -183,7 +183,7 @@ Geant4EventReaderHepEvt::readParticles(int /* event_number */, //fg: for now we create exactly one event vertex here ( as before ) Geant4Vertex* vtx = new Geant4Vertex ; - vertices.push_back( vtx ); + vertices.emplace_back( vtx ); vtx->x = 0; vtx->y = 0; vtx->z = 0; @@ -280,11 +280,11 @@ Geant4EventReaderHepEvt::readParticles(int /* event_number */, // // Keep daughters information for later - daughter1.push_back(JDAHEP1); - daughter2.push_back(JDAHEP2); + daughter1.emplace_back(JDAHEP1); + daughter2.emplace_back(JDAHEP2); // // Add the particle to the collection vector - particles.push_back(p); + particles.emplace_back(p); // }// End loop over particles diff --git a/DDG4/plugins/Geant4EventReaderHepMC.cpp b/DDG4/plugins/Geant4EventReaderHepMC.cpp index 40101c561b73849faca1ade32619c7187a382045..e1d0c75607e365d9b23383ee82ebfdcc828ef551 100644 --- a/DDG4/plugins/Geant4EventReaderHepMC.cpp +++ b/DDG4/plugins/Geant4EventReaderHepMC.cpp @@ -502,7 +502,7 @@ int HepMC::read_vertex(EventStream &info, istream& is, istringstream & input) return 0; } } - info.vertices().insert(make_pair(id,v)); + info.vertices().emplace(id,v); for(char value = is.peek(); value=='P'; value=is.peek()) { value = get_input(is,input); if( !input || value < 0 ) @@ -514,7 +514,7 @@ int HepMC::read_vertex(EventStream &info, istream& is, istringstream & input) delete p; return 0; } - info.particles().insert(make_pair(p->id,p)); + info.particles().emplace(p->id,p); p->pex = p->psx; p->pey = p->psy; p->pez = p->psz; diff --git a/DDG4/plugins/Geant4HitDumpAction.cpp b/DDG4/plugins/Geant4HitDumpAction.cpp index f9e75bd1befa5d3bf04ba3fab16fb8065c064681..e5889ed7e44590629a2ada429351850e8132875e 100644 --- a/DDG4/plugins/Geant4HitDumpAction.cpp +++ b/DDG4/plugins/Geant4HitDumpAction.cpp @@ -118,11 +118,11 @@ void Geant4HitDumpAction::dumpCollection(G4VHitsCollection* collection) { Geant4HitData* h = coll->hit(i); Geant4Tracker::Hit* trk_hit = dynamic_cast<Geant4Tracker::Hit*>(h); if ( 0 != trk_hit ) { - trk_hits.push_back(trk_hit); + trk_hits.emplace_back(trk_hit); } Geant4Calorimeter::Hit* cal_hit = dynamic_cast<Geant4Calorimeter::Hit*>(h); if ( 0 != cal_hit ) { - cal_hits.push_back(cal_hit); + cal_hits.emplace_back(cal_hit); } } if ( !trk_hits.empty() ) diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp index 384573d1f96efa83f8f4f471b922e192a33d76e6..22721f2857c0f00919ccebf21f3c9d2a94f9e945 100644 --- a/DDG4/src/Geant4Converter.cpp +++ b/DDG4/src/Geant4Converter.cpp @@ -203,7 +203,7 @@ void Geant4AssemblyVolume::imprint(Geant4GeometryInfo& info, // Register the physical volume created by us so we can delete it later // //fPVStore.emplace_back( pvPlaced.first ); - info.g4VolumeImprints[vol].emplace_back(make_pair(new_chain,pvPlaced.first)); + info.g4VolumeImprints[vol].emplace_back(new_chain,pvPlaced.first); #if 0 cout << " Assembly:Parent:" << parent->GetName() << " " << node->GetName() << " " << (void*)node << " G4:" << pvName.str() << " Daughter:" @@ -1167,7 +1167,7 @@ void Geant4Converter::handleProperties(Detector::Properties& prp) const { ::snprintf(txt, sizeof(txt), "%d", ++s_idd); id = txt; } - processors.insert(make_pair(id, nam)); + processors.emplace(id, nam); } } for (map<string, string>::const_iterator i = processors.begin(); i != processors.end(); ++i) { diff --git a/DDG4/src/Geant4InputAction.cpp b/DDG4/src/Geant4InputAction.cpp index d2c061a6a0a8b3a3ea8226d43d88a5d3e2835cf6..9999625185fb967d6e3de812e87a3523548a246b 100644 --- a/DDG4/src/Geant4InputAction.cpp +++ b/DDG4/src/Geant4InputAction.cpp @@ -270,7 +270,7 @@ void Geant4InputAction::operator()(G4Event* event) { // // vtx->out.insert(p->id); // Stuff, to be given to Geant4 together with daughters // // } - inter->particles.insert(make_pair(p->id,p)); + inter->particles.emplace(p->id,p); p.dumpWithMomentumAndVertex(outputLevel()-1,name(),"->"); } } diff --git a/DDG4/src/Geant4InputHandling.cpp b/DDG4/src/Geant4InputHandling.cpp index e1cc9fb19b87f4c4646a27ffb6e7ebfca31305fe..902a43f5f4e75aec56361637d1ca605ddb8e16fc 100644 --- a/DDG4/src/Geant4InputHandling.cpp +++ b/DDG4/src/Geant4InputHandling.cpp @@ -94,7 +94,7 @@ static void collectPrimaries(Geant4PrimaryMap* pm, PropertyMask status(p->status); int mask = interaction->mask; - interaction->particles.insert(make_pair(p->id,p)); + interaction->particles.emplace(p->id,p); status.set(G4PARTICLE_PRIMARY); p->mask = mask; particle_origine->out.insert(p->id); @@ -176,7 +176,7 @@ static void appendInteraction(const Geant4Action* caller, Geant4PrimaryInteraction::ParticleMap::iterator ip, ipend; for( ip=input->particles.begin(), ipend=input->particles.end(); ip != ipend; ++ip ) { Geant4Particle* p = (*ip).second; - output->particles.insert(make_pair(p->id,p->addRef())); + output->particles.emplace(p->id,p->addRef()); } Geant4PrimaryInteraction::VertexMap::iterator ivfnd, iv, ivend; for( iv=input->vertices.begin(), ivend=input->vertices.end(); iv != ivend; ++iv ) { diff --git a/DDG4/src/Geant4Kernel.cpp b/DDG4/src/Geant4Kernel.cpp index 46e9cf5f8e842469c9ce7b0ad983436038e792e0..0d3b89abb6495bd051a6b58ec9f63e1386fb5e1f 100644 --- a/DDG4/src/Geant4Kernel.cpp +++ b/DDG4/src/Geant4Kernel.cpp @@ -444,7 +444,7 @@ Geant4ActionPhase* Geant4Kernel::addPhase(const std::string& nam, const type_inf Phases::const_iterator i = m_phases.find(nam); if (i == m_phases.end()) { Geant4ActionPhase* p = new Geant4ActionPhase(workerContext(), nam, arg0, arg1, arg2); - m_phases.insert(make_pair(nam, p)); + m_phases.emplace(nam, p); return p; } else if (throw_on_exist) { diff --git a/DDG4/src/Geant4Output2ROOT.cpp b/DDG4/src/Geant4Output2ROOT.cpp index 03b05dcacf71ccd54bcbd283094dde4b80c93e28..db3b74adfc7e0ccfe8d4b4bada2a2b9f675fd130 100644 --- a/DDG4/src/Geant4Output2ROOT.cpp +++ b/DDG4/src/Geant4Output2ROOT.cpp @@ -59,7 +59,7 @@ TTree* Geant4Output2ROOT::section(const string& nam) { if (i == m_sections.end()) { TDirectory::TContext ctxt(m_file); TTree* t = new TTree(nam.c_str(), ("Geant4 " + nam + " information").c_str()); - m_sections.insert(make_pair(nam, t)); + m_sections.emplace(nam, t); return t; } return (*i).second; @@ -89,7 +89,7 @@ int Geant4Output2ROOT::fill(const string& nam, const ComponentCast& type, void* if (cl) { b = m_tree->Branch(nam.c_str(), cl->GetName(), (void*) 0); b->SetAutoDelete(false); - m_branches.insert(make_pair(nam, b)); + m_branches.emplace(nam, b); } else { throw runtime_error("No ROOT TClass object availible for object type:" + typeName(type.type)); diff --git a/DDG4/src/Geant4PhysicsList.cpp b/DDG4/src/Geant4PhysicsList.cpp index 3b84e549f469ec3fd395b4d758c15f909ca9def9..0ebc668a74fc7ab593a6ec9e805a9889b669ddd9 100644 --- a/DDG4/src/Geant4PhysicsList.cpp +++ b/DDG4/src/Geant4PhysicsList.cpp @@ -178,7 +178,7 @@ Geant4PhysicsList::ParticleProcesses& Geant4PhysicsList::processes(const string& if (i != m_processes.end()) { return (*i).second; } - pair<PhysicsProcesses::iterator, bool> ret = m_processes.insert(make_pair(nam, ParticleProcesses())); + auto ret = m_processes.emplace(nam, ParticleProcesses()); return (*(ret.first)).second; } @@ -198,7 +198,7 @@ Geant4PhysicsList::ParticleProcesses& Geant4PhysicsList::discreteProcesses(const if (i != m_discreteProcesses.end()) { return (*i).second; } - pair<PhysicsProcesses::iterator, bool> ret = m_discreteProcesses.insert(make_pair(nam, ParticleProcesses())); + pair<PhysicsProcesses::iterator, bool> ret = m_discreteProcesses.emplace(nam, ParticleProcesses()); return (*(ret.first)).second; } diff --git a/DDG4/src/Geant4Primary.cpp b/DDG4/src/Geant4Primary.cpp index 0682ab7e589093fac6453cf4e14fd9f4eb9a7060..f18280377ea801ca258faa5d43f9feeccf56dc7f 100644 --- a/DDG4/src/Geant4Primary.cpp +++ b/DDG4/src/Geant4Primary.cpp @@ -38,7 +38,7 @@ Geant4PrimaryMap::~Geant4PrimaryMap() { /// Add a new object pair (G4 primary particle, DDG4 particle) into the maps void Geant4PrimaryMap::insert(G4PrimaryParticle* g4,Geant4Particle* p) { - m_primaryMap.insert(std::make_pair(g4,p->addRef())); + m_primaryMap.emplace(g4,p->addRef()); } /// Access DDG4 particle by G4 primary particle diff --git a/DDG4/src/Geant4VolumeManager.cpp b/DDG4/src/Geant4VolumeManager.cpp index 00f6bcca70315269bbf190568eb4d58142ca72d2..7d1a6ec4603eecf97e7e7ca8d6e8a3b056010b32 100644 --- a/DDG4/src/Geant4VolumeManager.cpp +++ b/DDG4/src/Geant4VolumeManager.cpp @@ -157,7 +157,7 @@ namespace { (void*)code, Geant4GeometryInfo::placementPath(path).c_str()); if (m_geo.g4Paths.find(path) == m_geo.g4Paths.end()) { m_geo.g4Paths[path] = code; - m_entries.insert(make_pair(code,path)); + m_entries.emplace(code,path); return; } printout(ERROR, "Geant4VolumeManager", "populate: Severe error: Duplicated Geant4 path!!!! %s %s", diff --git a/DDRec/src/MaterialManager.cpp b/DDRec/src/MaterialManager.cpp index 7d73acdee728326fb370e557d8b9041f55f04cb6..70e825cab73af5adf203ec7b2f64ab2cd3a51549 100644 --- a/DDRec/src/MaterialManager.cpp +++ b/DDRec/src/MaterialManager.cpp @@ -24,12 +24,9 @@ namespace dd4hep { namespace rec { - MaterialManager::MaterialManager(Volume world) : _mV(0), _m( Material() ), _p0(),_p1(),_pos() { _tgeoMgr = world->GetGeoManager(); } - - MaterialManager::~MaterialManager(){ @@ -129,8 +126,8 @@ namespace dd4hep { if( length > epsilon ) { - _mV.push_back( std::make_pair( Material( node1->GetMedium() ) , length ) ) ; - _placeV.push_back(std::make_pair(node1,length)); + _mV.emplace_back(node1->GetMedium(), length ); + _placeV.emplace_back(node1,length); } break; } @@ -138,8 +135,8 @@ namespace dd4hep { track->AddPoint( position[0], position[1], position[2], 0.); if( length > epsilon ) { - _mV.push_back( std::make_pair( Material( node1->GetMedium() ), length ) ) ; - _placeV.push_back(std::make_pair(node1,length)); + _mV.emplace_back(node1->GetMedium(), length); + _placeV.emplace_back(node1,length); } node1 = node2; } @@ -147,7 +144,8 @@ namespace dd4hep { //fg: protect against empty list: if( _mV.empty() ){ - _mV.push_back( std::make_pair( Material( node1->GetMedium() ), totDist ) ) ; + _mV.emplace_back(node1->GetMedium(), totDist); + _placeV.emplace_back(node1,totDist); } diff --git a/DDRec/src/MaterialScan.cpp b/DDRec/src/MaterialScan.cpp index 5a4130e74820c24f6f8fa2a6c8eab2c6071af4fa..d2969755c43e7598a7167d0889e055f535028fd4 100644 --- a/DDRec/src/MaterialScan.cpp +++ b/DDRec/src/MaterialScan.cpp @@ -213,7 +213,7 @@ void MaterialScan::print(const Vector3D& p0, const Vector3D& p1, double epsilon) sum_x0 += nx0; sum_lambda += nLambda; path_length += length; - materials.push_back(std::make_pair(placements[i].first->GetMedium(),length)); + materials.emplace_back(placements[i].first->GetMedium(),length); const char* fmt = mat->GetRadLen() >= 1e5 ? fmt2 : fmt1; ::printf(fmt, i+1, mat->GetName(), mat->GetZ(), mat->GetA(), mat->GetDensity(), mat->GetRadLen(), mat->GetIntLen(), diff --git a/DDRec/src/Surface.cpp b/DDRec/src/Surface.cpp index fcc9872275a929d9201f0eefe5ba411774f2f88b..144e2b09a7cc149d2846d476c5c336438a8702e9 100644 --- a/DDRec/src/Surface.cpp +++ b/DDRec/src/Surface.cpp @@ -497,10 +497,10 @@ namespace dd4hep { Vector3D pl2 = -zv + r0v1 ; Vector3D pl3 = -zv + r0v0 ; - lines.push_back( std::make_pair( pl0, pl1 ) ) ; - lines.push_back( std::make_pair( pl1, pl2 ) ) ; - lines.push_back( std::make_pair( pl2, pl3 ) ) ; - lines.push_back( std::make_pair( pl3, pl0 ) ) ; + lines.emplace_back( pl0, pl1 ); + lines.emplace_back( pl1, pl2 ); + lines.emplace_back( pl2, pl3 ); + lines.emplace_back( pl3, pl0 ); } return lines; } @@ -542,7 +542,7 @@ namespace dd4hep { bool findVolume( PlacedVolume pv, Volume theVol, std::list< PlacedVolume >& volList ) { - volList.push_back( pv ) ; + volList.emplace_back( pv ) ; // unsigned count = volList.size() ; // for(unsigned i=0 ; i < count ; ++i) { @@ -854,7 +854,7 @@ namespace dd4hep { _wtM->LocalToMaster( local_lines[i].first , av.array() ) ; _wtM->LocalToMaster( local_lines[i].second , bv.array() ) ; - lines.push_back( std::make_pair( av, bv ) ); + lines.emplace_back( av, bv ); } return lines ; @@ -917,10 +917,10 @@ namespace dd4hep { lines.reserve(4) ; - lines.push_back( std::make_pair( _o + boxDim[ uidx ] * ub + boxDim[ vidx ] * vb , _o - boxDim[ uidx ] * ub + boxDim[ vidx ] * vb ) ) ; - lines.push_back( std::make_pair( _o - boxDim[ uidx ] * ub + boxDim[ vidx ] * vb , _o - boxDim[ uidx ] * ub - boxDim[ vidx ] * vb ) ) ; - lines.push_back( std::make_pair( _o - boxDim[ uidx ] * ub - boxDim[ vidx ] * vb , _o + boxDim[ uidx ] * ub - boxDim[ vidx ] * vb ) ) ; - lines.push_back( std::make_pair( _o + boxDim[ uidx ] * ub - boxDim[ vidx ] * vb , _o + boxDim[ uidx ] * ub + boxDim[ vidx ] * vb ) ) ; + lines.emplace_back(_o + boxDim[ uidx ] * ub + boxDim[ vidx ] * vb , _o - boxDim[ uidx ] * ub + boxDim[ vidx ] * vb ); + lines.emplace_back(_o - boxDim[ uidx ] * ub + boxDim[ vidx ] * vb , _o - boxDim[ uidx ] * ub - boxDim[ vidx ] * vb ); + lines.emplace_back(_o - boxDim[ uidx ] * ub - boxDim[ vidx ] * vb , _o + boxDim[ uidx ] * ub - boxDim[ vidx ] * vb ); + lines.emplace_back(_o + boxDim[ uidx ] * ub - boxDim[ vidx ] * vb , _o + boxDim[ uidx ] * ub + boxDim[ vidx ] * vb ); return lines ; } @@ -990,8 +990,8 @@ namespace dd4hep { _wtM->LocalToMaster( pl2, pg2.array() ) ; _wtM->LocalToMaster( pl3, pg3.array() ) ; - lines.push_back( std::make_pair( pg0, pg1 ) ) ; - lines.push_back( std::make_pair( pg2, pg3 ) ) ; + lines.emplace_back( pg0, pg1 ); + lines.emplace_back( pg2, pg3 ); } //add some vertical and horizontal lines so that the disc is seen in the rho-z projection @@ -1011,7 +1011,7 @@ namespace dd4hep { _wtM->LocalToMaster( pl0, pg0.array() ) ; _wtM->LocalToMaster( pl1, pg1.array() ) ; - lines.push_back( std::make_pair( pg0, pg1 ) ) ; + lines.emplace_back(pg0, pg1); } } @@ -1040,10 +1040,10 @@ namespace dd4hep { //the trapezoid is drawn as a set of four lines connecting its four corners lines.reserve(4) ; //_o is vector to the origin - lines.push_back( std::make_pair( _o + dx1 * ub - dz * vb , _o + dx2 * ub + dz * vb ) ) ; - lines.push_back( std::make_pair( _o + dx2 * ub + dz * vb , _o - dx2 * ub + dz * vb ) ) ; - lines.push_back( std::make_pair( _o - dx2 * ub + dz * vb , _o - dx1 * ub - dz * vb) ) ; - lines.push_back( std::make_pair( _o - dx1 * ub - dz * vb , _o + dx1 * ub - dz * vb) ) ; + lines.emplace_back( _o + dx1 * ub - dz * vb , _o + dx2 * ub + dz * vb); + lines.emplace_back( _o + dx2 * ub + dz * vb , _o - dx2 * ub + dz * vb); + lines.emplace_back( _o - dx2 * ub + dz * vb , _o - dx1 * ub - dz * vb); + lines.emplace_back( _o - dx1 * ub - dz * vb , _o + dx1 * ub - dz * vb); return lines; } @@ -1071,10 +1071,10 @@ namespace dd4hep { //the trapezoid is drawn as a set of four lines connecting its four corners lines.reserve(4) ; //_o is vector to the origin - lines.push_back( std::make_pair( _o + dx1 * ub - dz * vb , _o + dx2 * ub + dz * vb ) ) ; - lines.push_back( std::make_pair( _o + dx2 * ub + dz * vb , _o - dx2 * ub + dz * vb ) ) ; - lines.push_back( std::make_pair( _o - dx2 * ub + dz * vb , _o - dx1 * ub - dz * vb) ) ; - lines.push_back( std::make_pair( _o - dx1 * ub - dz * vb , _o + dx1 * ub - dz * vb) ) ; + lines.emplace_back( _o + dx1 * ub - dz * vb , _o + dx2 * ub + dz * vb); + lines.emplace_back( _o + dx2 * ub + dz * vb , _o - dx2 * ub + dz * vb); + lines.emplace_back( _o - dx2 * ub + dz * vb , _o - dx1 * ub - dz * vb); + lines.emplace_back( _o - dx1 * ub - dz * vb , _o + dx1 * ub - dz * vb); return lines; } @@ -1103,10 +1103,10 @@ namespace dd4hep { //the trapezoid is drawn as a set of four lines connecting its four corners lines.reserve(4) ; //_o is vector to the origin - lines.push_back( std::make_pair( _o + dx1 * ub - dz * vb , _o + dx2 * ub + dz * vb ) ) ; - lines.push_back( std::make_pair( _o + dx2 * ub + dz * vb , _o - dx2 * ub + dz * vb ) ) ; - lines.push_back( std::make_pair( _o - dx2 * ub + dz * vb , _o - dx1 * ub - dz * vb) ) ; - lines.push_back( std::make_pair( _o - dx1 * ub - dz * vb , _o + dx1 * ub - dz * vb) ) ; + lines.emplace_back( _o + dx1 * ub - dz * vb , _o + dx2 * ub + dz * vb); + lines.emplace_back( _o + dx2 * ub + dz * vb , _o - dx2 * ub + dz * vb); + lines.emplace_back( _o - dx2 * ub + dz * vb , _o - dx1 * ub - dz * vb); + lines.emplace_back( _o - dx1 * ub - dz * vb , _o + dx1 * ub - dz * vb); return lines; } @@ -1160,13 +1160,13 @@ namespace dd4hep { if( i > 0 ) - lines.push_back( std::make_pair( previous, gp ) ) ; + lines.emplace_back(previous, gp); else first = gp ; previous = gp ; } - lines.push_back( std::make_pair( previous, first ) ) ; + lines.emplace_back(previous, first); } else if( type().isCylinder() ) { @@ -1206,10 +1206,10 @@ namespace dd4hep { _wtM->LocalToMaster( pl2, pg2.array() ) ; _wtM->LocalToMaster( pl3, pg3.array() ) ; - lines.push_back( std::make_pair( pg0, pg1 ) ) ; - lines.push_back( std::make_pair( pg1, pg2 ) ) ; - lines.push_back( std::make_pair( pg2, pg3 ) ) ; - lines.push_back( std::make_pair( pg3, pg0 ) ) ; + lines.emplace_back( pg0, pg1 ); + lines.emplace_back( pg1, pg2 ); + lines.emplace_back( pg2, pg3 ); + lines.emplace_back( pg3, pg0 ); } } } diff --git a/DDRec/src/SurfaceManager.cpp b/DDRec/src/SurfaceManager.cpp index 1fe1d2e4809e1d6c127f4d2eb4f8dfd365a9221f..fd83a4d0825205f875227a28a029f31dd56660d0 100644 --- a/DDRec/src/SurfaceManager.cpp +++ b/DDRec/src/SurfaceManager.cpp @@ -46,7 +46,7 @@ namespace dd4hep { if( it != _map.end() ){ - return & it->second ; + return & it->second ; } return 0 ; @@ -58,33 +58,33 @@ namespace dd4hep { for(unsigned i=0,N=types.size();i<N;++i){ - const std::vector<DetElement>& dets = description.detectors( types[i] ) ; + const std::vector<DetElement>& dets = description.detectors( types[i] ) ; - for(unsigned j=0,M=dets.size();j<M;++j){ + for(unsigned j=0,M=dets.size();j<M;++j){ - std::string name = dets[j].name() ; + std::string name = dets[j].name() ; - SurfaceHelper surfH( dets[j] ) ; + SurfaceHelper surfH( dets[j] ) ; - const SurfaceList& detSL = surfH.surfaceList() ; + const SurfaceList& detSL = surfH.surfaceList() ; - // add an empty map for this detector in case there are no surfaces attached - _map.insert( std::make_pair( name , SurfaceMap() ) ) ; + // add an empty map for this detector in case there are no surfaces attached + _map.emplace(name , SurfaceMap()); - for( SurfaceList::const_iterator it = detSL.begin() ; it != detSL.end() ; ++it ){ - ISurface* surf = *it ; + for( SurfaceList::const_iterator it = detSL.begin() ; it != detSL.end() ; ++it ){ + ISurface* surf = *it ; - // enter surface into map for this detector - _map[ name ].insert( std::make_pair( surf->id(), surf ) ) ; + // enter surface into map for this detector + _map[ name ].emplace(surf->id(), surf ); - // enter surface into map for detector type - _map[ types[i] ].insert( std::make_pair( surf->id(), surf ) ) ; + // enter surface into map for detector type + _map[ types[i] ].emplace(surf->id(), surf ); - // enter surface into world map - _map[ "world" ].insert( std::make_pair( surf->id(), surf ) ) ; + // enter surface into world map + _map[ "world" ].emplace(surf->id(), surf ); - } - } + } + } } } @@ -97,7 +97,7 @@ namespace dd4hep { for( SurfaceMapsMap::const_iterator mi = _map.begin() ; mi != _map.end() ; ++mi ) { - sstr << " key: " << mi->first << " \t number of surfaces : " << mi->second.size() << std::endl ; + sstr << " key: " << mi->first << " \t number of surfaces : " << mi->second.size() << std::endl ; } sstr << "---------------------------------------------------------------- " << std::endl ;