diff --git a/DDCore/include/Parsers/Printout.h b/DDCore/include/Parsers/Printout.h index 6a96d5a98f21131f11ee2a89fcf098877fb75c72..c48acd14b3faadf31076466949704db3258aaa49 100644 --- a/DDCore/include/Parsers/Printout.h +++ b/DDCore/include/Parsers/Printout.h @@ -20,10 +20,9 @@ #include <cstdio> #include <cstdlib> #include <cstdarg> -#include <map> #include <string> #include <sstream> -#include <iostream> +//#include <iostream> /// Forward declarations class TNamed; @@ -268,63 +267,6 @@ namespace dd4hep { /// Check if this print level would result in some output bool isActivePrintLevel(int severity); - /// Helper class template to implement ASCII object dumps - /** @class Printer Conversions.h dd4hep/compact/Conversions.h - * - * Small helper class to print objects - * - * @author M.Frank - * @version 1.0 - */ - template <typename T> struct Printer { - /// Reference to the detector description object - const Detector* description; - /// Reference to the output stream object, the Printer object should write - std::ostream& os; - /// Optional text prefix when formatting the output - std::string prefix; - /// Initializing constructor of the functor - Printer(const Detector* l, std::ostream& stream, const std::string& p = "") - : description(l), os(stream), prefix(p) { - } - /// Callback operator to be specialized depending on the element type - void operator()(const T& value) const; - }; - - template <typename T> inline std::ostream& print(const T& object, std::ostream& os = std::cout, - const std::string& indent = "") { - Printer<T>(0, os, indent)(object); - return os; - } - - /// Helper class template to implement ASCII dumps of named objects maps - /** @class PrintMap Conversions.h dd4hep/compact/Conversions.h - * - * Small helper class to print maps of objects - * - * @author M.Frank - * @version 1.0 - */ - template <typename T> struct PrintMap { - typedef T item_type; - typedef const std::map<std::string, Handle<NamedObject> > cont_type; - - /// Reference to the detector description object - const Detector* description; - /// Reference to the output stream object, the Printer object should write - std::ostream& os; - /// Optional text prefix when formatting the output - std::string text; - /// Reference to the container data of the map. - cont_type& cont; - /// Initializing constructor of the functor - PrintMap(const Detector* l, std::ostream& stream, cont_type& c, const std::string& t = "") - : description(l), os(stream), text(t), cont(c) { - } - /// Callback operator to be specialized depending on the element type - void operator()() const; - }; - /// Helper function to print booleans in format YES/NO inline const char* yes_no(bool value) { return value ? "YES" : "NO "; diff --git a/DDCore/src/ObjectPrintout.cpp b/DDCore/src/ObjectPrintout.cpp deleted file mode 100644 index 5c28f778c2aadd60087d5c7e39fd1baa054b80b9..0000000000000000000000000000000000000000 --- a/DDCore/src/ObjectPrintout.cpp +++ /dev/null @@ -1,140 +0,0 @@ -//========================================================================== -// 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 include files -#include "DD4hep/Detector.h" -#include "DD4hep/Objects.h" -#include "DD4hep/Conditions.h" -#include "DD4hep/detail/ObjectsInterna.h" -#include "DD4hep/Printout.h" - -// C/C++ include files -#include <cstdarg> -#include <stdexcept> - -using namespace std; - -#include "TMap.h" -#include "TROOT.h" -#include "TColor.h" -using namespace std; -namespace dd4hep { - using namespace detail; - - template <typename T> void PrintMap<T>::operator()() const { - Printer < T > p(description, os); - os << "++" << endl << "++ " << text << endl << "++" << endl; - for (Detector::HandleMap::const_iterator i = cont.begin(); i != cont.end(); ++i) - p((*i).second); - } - - template <> void Printer<Handle<NamedObject> >::operator()(const Handle<NamedObject>& val) const { - printout(INFO, "Printer", "++ %s Handle:%s %s", prefix.c_str(), val->GetName(), val->GetTitle()); - } - template <> void Printer<Handle<TNamed> >::operator()(const Handle<TNamed>& val) const { - printout(INFO, "Printer", "++ %s Handle:%s %s", prefix.c_str(), val->GetName(), val->GetTitle()); - } - - template <> void Printer<Constant>::operator()(const Constant& val) const { - printout(INFO, "Printer", "++ %s Constant:%s %s", prefix.c_str(), val->GetName(), val.toString().c_str()); - } - - template <> void Printer<Material>::operator()(const Material& val) const { - printout(INFO, "Printer", "++ %s Material:%s %s", prefix.c_str(), val->GetName(), val.toString().c_str()); - } - - template <> void Printer<VisAttr>::operator()(const VisAttr& val) const { - printout(INFO, "Printer", "++ %s VisAttr: %s", prefix.c_str(), val.toString().c_str()); - } - - template <> void Printer<Readout>::operator()(const Readout& val) const { - printout(INFO, "Printer", "++ %s Readout: %s of type %s", prefix.c_str(), val->GetName(), val->GetTitle()); - } - - template <> void Printer<Region>::operator()(const Region& val) const { - printout(INFO, "Printer", "++ %s Region: %s of type %s", prefix.c_str(), val->GetName(), val->GetTitle()); - } - - template <> void Printer<RotationZYX>::operator()(const RotationZYX& val) const { - printout(INFO, "Printer", "++ %s ZYXRotation: phi: %7.3 rad theta: %7.3 rad psi: %7.3 rad", prefix.c_str(), val.Phi(), - val.Theta(), val.Psi()); - } - - template <> void Printer<Position>::operator()(const Position& val) const { - printout(INFO, "Printer", "++ %s Position: x: %9.3 mm y: %9.3 mm z: %9.3 mm", prefix.c_str(), val.X(), val.Y(), val.Z()); - } - template <> void Printer<Condition>::operator()(const Condition& val) const { - int flg = Condition::WITH_IOV|Condition::WITH_ADDRESS; - printout(INFO, "Printer", "++ %s %s", prefix.c_str(), val.str(flg).c_str()); - } -#if 0 - template <> void Printer<LimitSet>::operator()(const LimitSet& val) const { - const set<Limit>& o = val.limits(); - printout(INFO, "Printer", "++ %s LimitSet: %s", prefix.c_str(), val.name()); - val->TNamed::Print(); - for (set<Limit>::const_iterator i = o.begin(); i != o.end(); ++i) { - os << "++ Limit:" << (*i).name << " " << (*i).particles << " [" << (*i).unit << "] " << (*i).content << " " - << (*i).value << endl; - } - } - - template <> void Printer<DetElement>::operator()(const DetElement& val) const { - DetElement::Object* obj = val.data<DetElement::Object>(); - if (obj) { - char text[256]; - const DetElement& sd = val; - PlacedVolume plc = sd.placement(); - bool vis = plc.isValid(); - bool env = plc.isValid(); - bool mat = plc.isValid(); - ::snprintf(text, sizeof(text), "ID:%-3d Combine Hits:%3s Material:%s Envelope:%s VisAttr:%s", sd.id(), - yes_no(sd.combineHits()), mat ? plc.material().name() : yes_no(mat), - env ? plc.motherVol()->GetName() : yes_no(env), yes_no(vis)); - os << prefix << "+= DetElement: " << val.name() << " " << val.type() << endl; - os << prefix << "| " << text << endl; - - if (vis) { - VisAttr attr = plc.volume().visAttributes(); - VisAttr::Object* v = attr.data<VisAttr::Object>(); - TColor* col = gROOT->GetColor(v->color); - char text[256]; - ::snprintf(text, sizeof(text), " RGB:%-8s [%d] %7.2f Style:%d %d ShowDaughters:%3s Visible:%3s", col->AsHexString(), - v->color, col->GetAlpha(), int(v->drawingStyle), - int(v->lineStyle), yes_no(v->showDaughters), - yes_no(v->visible)); - os << prefix << "| VisAttr: " << setw(32) << left << attr.name() << text << endl; - } - if (plc.isValid()) { - Volume vol = plc.volume(); - Solid s = vol.solid(); - Material m = vol.material(); - ::snprintf(text, sizeof(text), "Volume:%s Shape:%s Material:%s", vol->GetName(), s.isValid() ? s.name() : "Unknonw", - m.isValid() ? m->GetName() : "Unknown"); - os << prefix << "+------------- " << text << endl; - } - const DetElement::Children& ch = sd.children(); - for (DetElement::Children::const_iterator i = ch.begin(); i != ch.end(); ++i) - Printer < DetElement > (description, os, prefix + "| ")((*i).second); - return; - } - } -#endif - template <> void Printer<const Detector*>::operator()(const Detector* const &) const { - //Header(description.header()).fromCompact(doc,compact.child(Tag_info),Strng_t("In memory")); - PrintMap < Constant > (description, os, description->constants(), "List of Constants")(); - //PrintMap < VisAttr > (description, os, description->visAttributes(), "List of Visualization attributes")(); - //PrintMap < LimitSet > (description, os, description->readouts(), "List of Readouts")(); - //PrintMap < Region > (description, os, description->regions(), "List of Regions")(); - //PrintMap < DetElement > (description, os, description->detectors(), "List of DetElements")(); - } -} diff --git a/DDCore/src/Primitives.cpp b/DDCore/src/Primitives.cpp index 91ff59e0ae0edca5cc440dca6f90fe51cb38a2b9..9b794f3f24e397d89b9711729b878f0649421199 100644 --- a/DDCore/src/Primitives.cpp +++ b/DDCore/src/Primitives.cpp @@ -17,13 +17,7 @@ #include "DD4hep/Printout.h" // C/C++ include files -#include <algorithm> -#include <functional> -#include <numeric> -#include <stdexcept> -#include <cstdint> #include <cstring> -#include <map> #if defined(__linux) || defined(__APPLE__) || defined(__powerpc64__) #include <cxxabi.h> @@ -188,6 +182,11 @@ unsigned long long int dd4hep::detail::hash64(const char* key) { return update_hash64(FNV1a_64::hashinit, key); } +/// 64 bit hash function +unsigned long long int dd4hep::detail::hash64(const std::string& key) { + return update_hash64(FNV1a_64::hashinit, key.c_str(), key.length()); +} + /// 64 bit hash function unsigned long long int dd4hep::detail::hash64(const void* key, std::size_t len) { return update_hash64(FNV1a_64::hashinit, key, len); @@ -214,11 +213,6 @@ unsigned long long int dd4hep::detail::update_hash64(unsigned long long int hash return hash; } -/// 64 bit hash function -unsigned long long int dd4hep::detail::hash64(const std::string& key) { - return std::accumulate(begin(key), end(key), FNV1a_64::hashinit, FNV1a_64::doByte); -} - /// 16 bit hash function unsigned short dd4hep::detail::hash16(const void* key, std::size_t len) { unsigned short value = (unsigned short)hash32(key, len); diff --git a/DDCore/src/Printout.cpp b/DDCore/src/Printout.cpp index 79b49f467ba7d0f15c9ee3d8d4b57e0d130fbe17..2c570f51731455496ad65a20a76840998b14b869 100644 --- a/DDCore/src/Printout.cpp +++ b/DDCore/src/Printout.cpp @@ -19,6 +19,7 @@ #include <cstring> #include <cstdarg> #include <sstream> +#include <iostream> #include <stdexcept> // Disable some diagnostics for ROOT dictionaries #ifdef __GNUC__ diff --git a/DDCore/src/plugins/DetectorChecksum.cpp b/DDCore/src/plugins/DetectorChecksum.cpp index c5fcfd411b00202990f6c6e20157a67d35cd0298..bc86efea7bb59c77a75f1674d70ef4ea8a394685 100644 --- a/DDCore/src/plugins/DetectorChecksum.cpp +++ b/DDCore/src/plugins/DetectorChecksum.cpp @@ -1179,9 +1179,9 @@ void DetectorChecksum::dump_volumes() const { void DetectorChecksum::dump_placements() const { const auto& geo = data().mapOfPlacements; for(const auto& e : geo) { - PlacedVolume v = e.first; + PlacedVolume pv = e.first; printout(ALWAYS, "DetectorChecksum", "+++ Placement %-32s 0x%016lx%s", - v.name(), e.second.hash, debug > 2 ? ("\n"+e.second.data).c_str() : ""); + pv.name(), e.second.hash, debug > 2 ? ("\n"+e.second.data).c_str() : ""); } } @@ -1192,6 +1192,14 @@ void DetectorChecksum::dump_detelements() const { DetElement de = e.first; printout(ALWAYS, "DetectorChecksum", "+++ Detelement %-32s 0x%016lx%s", de.name(), e.second.hash, debug > 2 ? ("\n"+e.second.data).c_str() : ""); + if ( de.path() == "/world" ) { + PlacedVolume pv = de.placement(); + printout(ALWAYS, "DetectorChecksum", " Placement %-32s 0x%016lx%s", + pv.name(), e.second.hash, debug > 2 ? ("\n"+e.second.data).c_str() : ""); + Volume v = pv.volume(); + printout(ALWAYS, "DetectorChecksum", " Volume %-32s 0x%016lx%s", + v.name(), e.second.hash, debug > 2 ? ("\n"+e.second.data).c_str() : ""); + } } }