diff --git a/DDCMS/include/DDCMS/DDCMS.h b/DDCMS/include/DDCMS/DDCMS.h index 7d15a05a794c0698d7f864e28cc5ff1f9162e7f5..9eafbf207e1e6f0c62b1c94a386d6b6db963a194 100644 --- a/DDCMS/include/DDCMS/DDCMS.h +++ b/DDCMS/include/DDCMS/DDCMS.h @@ -24,6 +24,7 @@ // C/C++ include files #include <map> +#include <sstream> /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -77,27 +78,27 @@ namespace dd4hep { return elt.attr<T>(n); } /// Add a new constant to the namespace - void addConstant(const std::string& name, const std::string& value, const std::string& type) const; + void addConstant(const std::string& name, const std::string& value, const std::string& type) const; /// Add a new constant to the namespace as fully indicated by the name - void addConstantNS(const std::string& name, const std::string& value, const std::string& type) const; + void addConstantNS(const std::string& name, const std::string& value, const std::string& type) const; /// Access material by its namespace dressed name Material material(const std::string& name) const; - Solid solid(const std::string& name) const; + Solid solid(const std::string& name) const; /// Add solid to current namespace - void addSolid(const std::string& name,Solid solid) const; + Solid addSolid(const std::string& name,Solid solid) const; /// Add solid to current namespace as fully indicated by the name - void addSolidNS(const std::string& name,Solid solid) const; + Solid addSolidNS(const std::string& name,Solid solid) const; - Volume volume(const std::string& name, bool exc=true) const; + Volume volume(const std::string& name, bool exc=true) const; /// Add volume to current namespace - void addVolume(Volume vol) const; + Volume addVolume(Volume vol) const; /// Add volume to current namespace as fully indicated by the name - void addVolumeNS(Volume vol) const; + Volume addVolumeNS(Volume vol) const; const Rotation3D& rotation(const std::string& name) const; /// Add rotation matrix to current namespace - void addRotation(const std::string& name,const Rotation3D& rot) const; + void addRotation(const std::string& name,const Rotation3D& rot) const; }; /// XML parser context to store intermediate stuff @@ -113,6 +114,8 @@ namespace dd4hep { std::map<std::string, Rotation3D> rotations; std::map<std::string, Solid> shapes; std::map<std::string, Volume> volumes; + std::map<std::string, std::string> vismaterial; + std::set<std::string> disabledAlgs; std::vector<std::string> namespaces; bool geo_inited = false; @@ -172,8 +175,33 @@ namespace dd4hep { bool find(const std::string& name) const; /// Access typed argument by name template<typename T> T value(const std::string& name) const; + /// Shortcut to access string arguments + std::string str(const std::string& nam) const; + /// Shortcut to access double arguments + double dble(const std::string& nam) const; + /// Shortcut to access integer arguments + int integer(const std::string& nam) const; + /// Shortcut to access vector<double> arguments + std::vector<double> vecDble(const std::string& nam) const; + /// Shortcut to access vector<int> arguments + std::vector<int> vecInt(const std::string& nam) const; + /// Shortcut to access vector<int> arguments + std::vector<std::string> vecStr(const std::string& nam) const; }; + class LogDebug : public std::stringstream { + std::string tag; + bool pop = false; + public: + LogDebug() = delete; + LogDebug(const LogDebug& copy) = delete; + LogDebug& operator=(const LogDebug& copy) = delete; + LogDebug(const std::string& tag_value, bool /* set_context */); + LogDebug(const std::string& tag_value); + ~LogDebug(); + static void setDebugAlgorithms(bool value); + }; + /// Create 3D rotation matrix from angles. Rotation3D make_rotation3D(double thetaX, double phiX, double thetaY, double phiY, diff --git a/DDCMS/include/DDCMS/DDCMSTags.h b/DDCMS/include/DDCMS/DDCMSTags.h index 4fadc4414ea99091d6a12d1be4ba1cef7d46a459..f7415c2bdad9a5ae2c20079f41d3544a05e5acad 100644 --- a/DDCMS/include/DDCMS/DDCMSTags.h +++ b/DDCMS/include/DDCMS/DDCMSTags.h @@ -114,7 +114,9 @@ namespace dd4hep { UNICODE(nEntries); UNICODE(VisSection); + UNICODE(vismaterial); UNICODE(vis); + /// Debug flags UNICODE(debug_constants); @@ -133,6 +135,7 @@ namespace dd4hep { UNICODE(close_geometry); UNICODE(IncludeSection); UNICODE(Include); + UNICODE(DisabledAlgo); } /* End namespace DDCMS */ } /* End namespace dd4hep */ diff --git a/DDCMS/src/DDCMS.cpp b/DDCMS/src/DDCMS.cpp index a1dd309290dc4ca8bc8f8da07261b5de4537a293..35f9f5109de9c73465c638db18775e18f620a46d 100644 --- a/DDCMS/src/DDCMS.cpp +++ b/DDCMS/src/DDCMS.cpp @@ -207,7 +207,7 @@ const Rotation3D& Namespace::rotation(const string& nam) const { } /// Add rotation matrix to current namespace -void Namespace::addVolumeNS(Volume vol) const { +Volume Namespace::addVolumeNS(Volume vol) const { string n = vol.name(); Solid s = vol.solid(); Material m = vol.material(); @@ -216,10 +216,11 @@ void Namespace::addVolumeNS(Volume vol) const { printout(context->debug_volumes ? ALWAYS : DEBUG, "DDCMS", "+++ Add volume:%-38s Solid:%-26s[%-16s] Material:%s", vol.name(), s.name(), s.type(), m.name()); + return vol; } /// Add rotation matrix to current namespace -void Namespace::addVolume(Volume vol) const { +Volume Namespace::addVolume(Volume vol) const { string n = prepend(vol.name()); Solid s = vol.solid(); Material m = vol.material(); @@ -228,6 +229,7 @@ void Namespace::addVolume(Volume vol) const { printout(context->debug_volumes ? ALWAYS : DEBUG, "DDCMS", "+++ Add volume:%-38s Solid:%-26s[%-16s] Material:%s", vol.name(), s.name(), s.type(), m.name()); + return vol; } Volume Namespace::volume(const string& nam, bool exc) const { @@ -250,15 +252,16 @@ Volume Namespace::volume(const string& nam, bool exc) const { } /// Add solid to current namespace as fully indicated by the name -void Namespace::addSolidNS(const std::string& nam,Solid sol) const { +Solid Namespace::addSolidNS(const string& nam,Solid sol) const { printout(context->debug_shapes ? ALWAYS : DEBUG, "DDCMS", "+++ Add shape of type %s : %s",sol->IsA()->GetName(), nam.c_str()); context->shapes[nam] = sol.setName(nam); + return sol; } /// Add solid to current namespace -void Namespace::addSolid(const string& nam, Solid sol) const { - addSolidNS(prepend(nam), sol); +Solid Namespace::addSolid(const string& nam, Solid sol) const { + return addSolidNS(prepend(nam), sol); } Solid Namespace::solid(const string& nam) const { @@ -415,29 +418,79 @@ namespace dd4hep { template string AlgoArguments::value<string>(const string& nam) const; /// Access typed vector<string> argument by name - template<> vector<string> AlgoArguments::value<vector<string> >(const string& nam) const { - xml_h xp = raw_arg(nam); - return raw_vector(this,xp); - } + template<> vector<string> AlgoArguments::value<vector<string> >(const string& nam) const + { return raw_vector(this,raw_arg(nam)); } /// Access typed vector<double> argument by name - template<> vector<double> AlgoArguments::value<vector<double> >(const string& nam) const { - return __cnvVect<double>(this,"numeric",raw_arg(nam)); - } + template<> vector<double> AlgoArguments::value<vector<double> >(const string& nam) const + { return __cnvVect<double>(this,"numeric",raw_arg(nam)); } /// Access typed vector<float> argument by name - template<> vector<float> AlgoArguments::value<vector<float> >(const string& nam) const { - return __cnvVect<float>(this,"numeric",raw_arg(nam)); - } + template<> vector<float> AlgoArguments::value<vector<float> >(const string& nam) const + { return __cnvVect<float>(this,"numeric",raw_arg(nam)); } /// Access typed vector<long> argument by name - template<> vector<long> AlgoArguments::value<vector<long> >(const string& nam) const { - return __cnvVect<long>(this,"numeric",raw_arg(nam)); - } + template<> vector<long> AlgoArguments::value<vector<long> >(const string& nam) const + { return __cnvVect<long>(this,"numeric",raw_arg(nam)); } /// Access typed vector<int> argument by name - template<> vector<int> AlgoArguments::value<vector<int> >(const string& nam) const { - return __cnvVect<int>(this,"numeric",raw_arg(nam)); - } + template<> vector<int> AlgoArguments::value<vector<int> >(const string& nam) const + { return __cnvVect<int>(this,"numeric",raw_arg(nam)); } } } + +/// Shortcut to access string arguments +string AlgoArguments::str(const string& nam) const +{ return this->value<string>(nam); } + +/// Shortcut to access double arguments +double AlgoArguments::dble(const string& nam) const +{ return this->value<double>(nam); } + +/// Shortcut to access integer arguments +int AlgoArguments::integer(const string& nam) const +{ return this->value<int>(nam); } + +/// Shortcut to access vector<double> arguments +vector<double> AlgoArguments::vecDble(const string& nam) const +{ return this->value<vector<double> >(nam); } + +/// Shortcut to access vector<int> arguments +vector<int> AlgoArguments::vecInt(const string& nam) const +{ return this->value<vector<int> >(nam); } + +/// Shortcut to access vector<string> arguments +vector<string> AlgoArguments::vecStr(const string& nam) const +{ return this->value<vector<string> >(nam); } + +namespace { + bool s_debug_algorithms = false; + vector<string> s_algorithms; + const std::string currentAlg() { + static std::string s_none = "??????"; + if ( !s_algorithms.empty() ) return s_algorithms.back(); + return s_none; + } +} + +LogDebug::LogDebug(const std::string& tag_value, bool /* set_context */) { + s_algorithms.push_back(tag_value); + pop = true; +} + +LogDebug::LogDebug(const std::string& t) : stringstream(), tag(t) { + if ( pop ) s_algorithms.pop_back(); +} + +LogDebug::~LogDebug() { + if ( pop ) return; + if ( this->str().empty() ) return; + printout(s_debug_algorithms ? ALWAYS : DEBUG, + currentAlg(),"%s: %s", + tag.c_str(),this->str().c_str()); +} + +void LogDebug::setDebugAlgorithms(bool value) { + s_debug_algorithms = value; +} + diff --git a/DDCMS/src/plugins/DDCMSDetElementCreator.cpp b/DDCMS/src/plugins/DDCMSDetElementCreator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..972b29df9a7c802b2f79272165a5879c72c86863 --- /dev/null +++ b/DDCMS/src/plugins/DDCMSDetElementCreator.cpp @@ -0,0 +1,88 @@ +//========================================================================== +// 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 +// +//========================================================================== +// +// Specialized generic detector constructor +// +//========================================================================== + +// Framework include files +#include "DD4hep/VolumeProcessor.h" +#include "DD4hep/DetFactoryHelper.h" + +using namespace std; +using namespace dd4hep; + + +namespace { + + + class DDCMSDetElementCreator : public PlacedVolumeProcessor { + struct Data { + bool sensitive = false; + Data() = default; + Data(const Data& d) = default; + Data& operator=(const Data& d) = default; + }; + typedef std::vector<std::pair<PlacedVolume,Data> > VolumeStack; + VolumeStack* stack; + + public: + /// Initializing constructor + DDCMSDetElementCreator(); + /// Default destructor + virtual ~DDCMSDetElementCreator(); + /// Callback to output PlacedVolume information of an single Placement + virtual int operator()(PlacedVolume pv, int level) const; + /// Callback to output PlacedVolume information of an entire Placement + virtual int process(PlacedVolume pv, int level, bool recursive) const; + }; +} + + +#include "DD4hep/Printout.h" + +/// Initializing constructor +DDCMSDetElementCreator::DDCMSDetElementCreator() { + stack = new VolumeStack(); +} + +/// Default destructor +DDCMSDetElementCreator::~DDCMSDetElementCreator() { + detail::deletePtr(stack); +} + +/// Callback to output PlacedVolume information of an single Placement +int DDCMSDetElementCreator::operator()(PlacedVolume pv, int level) const { + Volume vol = pv.volume(); + char sens = vol.isSensitive() ? 'S' : ' '; + printout(INFO,"DDCMSDetElementCreator", + "++ %3d %s [%s] %c", level, pv.name(), vol.name(), sens); + return 1; +} + +/// Callback to output PlacedVolume information of an entire Placement +int DDCMSDetElementCreator::process(PlacedVolume pv, int level, bool recursive) const { + stack->push_back(make_pair(pv,Data())); + int ret = PlacedVolumeProcessor::process(pv,level,recursive); + stack->pop_back(); + return ret; +} + +static void* create_object(Detector& /* description */, int /* argc */, char** /* argv */) { + PlacedVolumeProcessor* proc = new DDCMSDetElementCreator(); + return proc; +} + +// first argument is the type from the xml file +DECLARE_DD4HEP_CONSTRUCTOR(DDCMS_DetElementCreator,create_object) + diff --git a/DDCMS/src/plugins/DDDefinitions2Objects.cpp b/DDCMS/src/plugins/DDDefinitions2Objects.cpp index 2940001a067a82da2d8806c1e95352fa9ffee8ff..83f7c63176c225ba5c548db81d611854cc140354 100644 --- a/DDCMS/src/plugins/DDDefinitions2Objects.cpp +++ b/DDCMS/src/plugins/DDDefinitions2Objects.cpp @@ -50,6 +50,8 @@ namespace dd4hep { static UInt_t unique_mat_id = 0xAFFEFEED; + + class disabled_algo; class include_constants; class include_load; class include_unload; @@ -90,6 +92,7 @@ namespace dd4hep { class vissection; class vis_apply; + class vismaterial; class vis; class debug; } @@ -97,7 +100,8 @@ namespace dd4hep { /// Converter instances implemented in this compilation unit template <> void Converter<debug>::operator()(xml_h element) const; template <> void Converter<print_xml_doc>::operator()(xml_h element) const; - + template <> void Converter<disabled_algo>::operator()(xml_h element) const; + /// Converter for <ConstantsSection/> tags template <> void Converter<constantssection>::operator()(xml_h element) const; template <> void Converter<constant>::operator()(xml_h element) const; @@ -105,7 +109,11 @@ namespace dd4hep { /// Converter for <VisSection/> tags template <> void Converter<vissection>::operator()(xml_h element) const; + /// Convert to apply visualization attributes template <> void Converter<vis_apply>::operator()(xml_h element) const; + /// Convert material visualization attributes + template <> void Converter<vismaterial>::operator()(xml_h element) const; + /// Convert compact visualization attributes template <> void Converter<vis>::operator()(xml_h element) const; /// Converter for <MaterialSection/> tags @@ -166,6 +174,7 @@ template <> void Converter<constantssection>::operator()(xml_h element) const { /// Converter for <VisSection/> tags template <> void Converter<vissection>::operator()(xml_h element) const { Namespace _ns(_param<ParsingContext>(), element); + xml_coll_t(element, _CMU(vismaterial)).for_each(Converter<vismaterial>(description,_ns.context,optional)); xml_coll_t(element, _CMU(vis)).for_each(Converter<vis>(description,_ns.context,optional)); } @@ -192,6 +201,11 @@ template <> void Converter<logicalpartsection>::operator()(xml_h element) const xml_coll_t(element, _CMU(LogicalPart)).for_each(Converter<logicalpart>(description,_ns.context,optional)); } +template <> void Converter<disabled_algo>::operator()(xml_h element) const { + ParsingContext* c = _param<ParsingContext>(); + c->disabledAlgs.insert(element.attr<string>(_U(name))); +} + /// Generic converter for <SolidSection/> tags template <> void Converter<solidsection>::operator()(xml_h element) const { Namespace _ns(_param<ParsingContext>(), element); @@ -268,6 +282,13 @@ template <> void Converter<constant>::operator()(xml_h element) const { res->unresolvedConst[real] = val; } +/// Convert material visualization attributes +template <> void Converter<vismaterial>::operator()(xml_h e) const { + ParsingContext* c = _param<ParsingContext>(); + xml_dim_t xvis(e); + c->vismaterial[xvis.nameStr()] = xvis.typeStr(); +} + /** Convert compact visualization attribute to Detector visualization attribute * * <vis name="SiVertexBarrelModuleVis" @@ -405,6 +426,7 @@ template <> void Converter<compositematerial>::operator()(xml_h element) const medium->SetTitle("material"); medium->SetUniqueID(unique_mat_id); } + } } @@ -652,15 +674,20 @@ template <> void Converter<algorithm>::operator()(xml_h element) const { Namespace _ns(_param<ParsingContext>()); xml_dim_t e(element); string name = e.nameStr(); + if ( _ns.context->disabledAlgs.find(name) != _ns.context->disabledAlgs.end() ) { + printout(INFO,"DDCMS","+++ Skip disabled algorithms: %s",name.c_str()); + return; + } try { SensitiveDetector sd; Segmentation seg; - string type = _ns.real_name(e.nameStr()); + string type = "DDCMS_"+_ns.real_name(name); // SensitiveDetector and Segmentation currently are undefined. Let's keep it like this // until we found something better..... printout(_ns.context->debug_algorithms ? ALWAYS : DEBUG, "DDCMS","+++ Start executing algorithm %s....",type.c_str()); + LogDebug context(e.nameStr(),true); long ret = PluginService::Create<long>(type, &description, _ns.context, &element, &sd); if ( ret == 1 ) { printout(_ns.context->debug_algorithms ? ALWAYS : DEBUG, @@ -711,25 +738,58 @@ template <> void Converter<debug>::operator()(xml_h dbg) const { if ( dbg.hasChild(_CMU(debug_namespaces)) ) _ns.context->debug_namespaces = true; if ( dbg.hasChild(_CMU(debug_includes)) ) _ns.context->debug_includes = true; if ( dbg.hasChild(_CMU(debug_algorithms)) ) _ns.context->debug_algorithms = true; + LogDebug::setDebugAlgorithms(_ns.context->debug_algorithms); } template <> void Converter<vis_apply>::operator()(xml_h /* dddefinition */) const { struct VisPatcher: public detail::GeoScan { - Detector& detector; - VisPatcher(Detector& d) : detail::GeoScan(d.world()), detector(d) { } + const Namespace& n_s; + VisPatcher(const Namespace& n) + : detail::GeoScan(n.context->description->world()), n_s(n) + { } void patch() const { + Detector* detector = n_s.context->description; printout(INFO,"Detector","+++ Applying DD4hep visualization attributes...."); + VisAttr invisible = detector->visAttributes("invisible"); for (auto i = m_data->rbegin(); i != m_data->rend(); ++i) { for( const TGeoNode* n : (*i).second ) { - Volume vol(n->GetVolume()); - VisAttr vis = detector.visAttributes(vol.name()); - printout(DEBUG,"Vis","+++ %s vis-attrs:%s",vol.name(), yes_no(vis.isValid())); + Volume vol = n->GetVolume(); + Material mat = vol.material(); + VisAttr vis = detector->visAttributes(vol.name()); + if ( !vis.isValid() ) { + auto iv = n_s.context->vismaterial.find(mat.name()); + if ( iv != n_s.context->vismaterial.end() ) { + vis = detector->visAttributes((*iv).second); + } + } + if ( !vis.isValid() && mat.density() < 5e0 ) { + vis = invisible; + } + /* + if ( !vis ) { + TGeoMaterial* m = mat->GetMaterial(); + int ne = m->GetNelements(); + for(int k=0; ne==1 && k<ne; ++k) { + TGeoElement* e = m->GetElement(k); + auto iv = n_s.context->vismaterial.find(e->GetName()); + if ( iv != n_s.context->vismaterial.end() ) { + vis = detector->visAttributes((*iv).second); + printout(INFO,"Vis","Set visattr according to element: %s -> %s", + mat.name(), e->GetName()); + break; + } + } + } + */ + printout(INFO,"Vis","+++ %-40s Material:%s Dens:%6.1f vis-attrs:%s [%s]", + vol.name(), mat.name(), mat.density(), yes_no(vis.isValid()), + vis.name()); vol.setVisAttributes(vis); } } } }; - VisPatcher(description).patch(); + VisPatcher(Namespace(_param<ParsingContext>())).patch(); } template <> void Converter<resolve>::operator()(xml_h /* element */) const { @@ -785,7 +845,7 @@ template <> void Converter<resolve>::operator()(xml_h /* element */) const { template <> void Converter<print_xml_doc>::operator()(xml_h element) const { string fname = xml::DocumentHandler::system_path(element); printout(_param<ParsingContext>()->debug_includes ? ALWAYS : DEBUG, - "DDCMS","+++ Processing data from file:%s",fname.c_str()); + "DDCMS","+++ Processing data from: %s",fname.c_str()); } /// Converter for <DDDefinition/> tags @@ -809,6 +869,7 @@ static long load_dddefinition(Detector& det, xml_h element) { try { resolve res; print_doc((doc=dddef.document()).root()); + xml_coll_t(dddef, _CMU(DisabledAlgo)).for_each(Converter<disabled_algo>(det,&ctxt,&res)); xml_coll_t(dddef, _CMU(ConstantsSection)).for_each(Converter<constantssection>(det,&ctxt,&res)); xml_coll_t(dddef, _CMU(VisSection)).for_each(Converter<vissection>(det,&ctxt)); xml_coll_t(dddef, _CMU(RotationSection)).for_each(Converter<rotationsection>(det,&ctxt)); @@ -816,7 +877,10 @@ static long load_dddefinition(Detector& det, xml_h element) { xml_coll_t(dddef, _CMU(IncludeSection)).for_each(_CMU(Include), Converter<include_load>(det,&ctxt,&res)); - for(xml::Document d : res.includes ) Converter<include_constants>(det,&ctxt,&res)((doc=d).root()); + for(xml::Document d : res.includes ) { + print_doc((doc=d).root()); + Converter<include_constants>(det,&ctxt,&res)((doc=d).root()); + } // Before we continue, we have to resolve all constants NOW! Converter<resolve>(det,&ctxt,&res)(dddef); // Now we can process the include files one by one..... diff --git a/DDCMS/src/plugins/DDPixBarLayerAlgo.cpp b/DDCMS/src/plugins/DDPixBarLayerAlgo.cpp index 44437faab4930c5ab81f232c7af260e03a54a7a4..198a97b76320c0fe99440bb91609514cfece57d9 100644 --- a/DDCMS/src/plugins/DDPixBarLayerAlgo.cpp +++ b/DDCMS/src/plugins/DDPixBarLayerAlgo.cpp @@ -17,27 +17,20 @@ // Framework include files #include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/Printout.h" #include "DDCMS/DDCMSPlugins.h" -// C/C++ include files -#include <sstream> - using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; using namespace dd4hep::cms; -static long create_element(Detector& description, ParsingContext& ctxt, xml_h e, SensitiveDetector& /* sens */) { - stringstream str; +static long algorithm(Detector& description, ParsingContext& ctxt, xml_h e, SensitiveDetector& /* sens */) { PlacedVolume pv; Namespace ns(ctxt, e, true); AlgoArguments args(ctxt, e); string parentName = args.parentName(); - printout(INFO,"DDCMS","+++ Parsing arguments for Algorithm:%-24s rParent:%s", - args.name.c_str(), parentName.c_str()); - + LogDebug("PixelGeom") << "+++ Parsing arguments for Algorithm:" << args.name + << " rParent:" << parentName; string genMat = args.value<string>("GeneralMaterial"); int number = args.value<int>("Ladders"); double layerDz = args.value<double>("LayerDz"); @@ -49,8 +42,7 @@ static long create_element(Detector& description, ParsingContext& ctxt, xml_h e, double coolDist = args.value<double>("CoolDist"); string coolMat = args.value<string>("CoolMaterial"); string tubeMat = args.value<string>("CoolTubeMaterial"); - - str << "Parent " << parentName << " NameSpace " << ns.name << "\n" + LogDebug("PixelGeom") << "Parent " << parentName << " NameSpace " << ns.name << "\n" << "\tLadders " << number << "\tGeneral Material " << genMat << "\tLength " << layerDz << "\tSensorEdge " << sensorEdge << "\tSpecification of Cooling Pieces:\n" @@ -58,21 +50,15 @@ static long create_element(Detector& description, ParsingContext& ctxt, xml_h e, << " Side " << coolSide << " Thickness of Shell " << coolThick << " Radial distance " << coolDist << " Materials " << coolMat << ", " << tubeMat; - printout(INFO,"DDPixBarLayerAlgo",str); - vector<string> ladder = args.value<vector<string> >("LadderName"); vector<double> ladderWidth = args.value<vector<double> >("LadderWidth"); vector<double> ladderThick = args.value<vector<double> >("LadderThick"); - - str << "Full Ladder " << ladder[0] << " width/thickness " << ladderWidth[0] + LogDebug("PixelGeom") << "Full Ladder " << ladder[0] << " width/thickness " << ladderWidth[0] << ", " << ladderThick[0] << "\tHalf Ladder " << ladder[1] << " width/thickness " << ladderWidth[1] << ", " << ladderThick[1]; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDPixBarLayerAlgo",str); - - string mother = parentName; - const std::string &idName = mother; + const std::string idName = ns.obj_name(parentName); double dphi = CLHEP::twopi/number; double d2 = 0.5*coolWidth; double d1 = d2 - coolSide*sin(0.5*dphi); @@ -81,58 +67,47 @@ static long create_element(Detector& description, ParsingContext& ctxt, xml_h e, double rmin = (coolDist-0.5*(d1+d2))*cos(0.5*dphi)-0.5*ladderThick[0]; double rmax = (coolDist+0.5*(d1+d2))*cos(0.5*dphi)+0.5*ladderThick[0]; double rmxh = rmax - 0.5*ladderThick[0] + ladderThick[1]; - str << "Rmin/Rmax " << rmin + LogDebug("PixelGeom") << "Rmin/Rmax " << rmin << ", " << rmax << " d1/d2 " << d1 << ", " << d2 << " x1/x2 " << x1 << ", " << x2; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDPixBarLayerAlgo",str); double rtmi = rmin + 0.5*ladderThick[0] - ladderThick[1]; double rtmx = sqrt(rmxh*rmxh+ladderWidth[1]*ladderWidth[1]); - Solid solid = Tube(rtmi, rtmx, 0.5*layerDz, 0, CLHEP::twopi); - solid.setName(idName); - str.str(""); - str << "IDname "<< idName << " Tubs made of " + Solid solid = ns.addSolid(idName,Tube(rtmi, rtmx, 0.5*layerDz, 0, CLHEP::twopi)); + LogDebug("PixelGeom") << "IDname "<< idName << " Tubs made of " << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg << " with Rin " << rtmi << " Rout " << rtmx << " ZHalf " << 0.5*layerDz; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDPixBarLayerAlgo",str); - - Volume layer(solid.name(), solid, ns.material(genMat)); - + + Volume layer = ns.addVolume(Volume(idName, solid, ns.material(genMat))); double rr = 0.5*(rmax+rmin); double dr = 0.5*(rmax-rmin); double h1 = 0.5*coolSide*cos(0.5*dphi); std::string name = idName + "CoolTube"; - solid = Trap(0.5*coolDz, 0, 0, h1, d2, d1, 0, h1, d2, d1, 0); - solid.setName(idName+"CoolTube"); - str << "Solid " << solid.name() + solid = ns.addSolid(name,Trap(0.5*coolDz, 0, 0, h1, d2, d1, 0, h1, d2, d1, 0)); + LogDebug("PixelGeom") << "Solid " << solid.name() << " Trap made of " << tubeMat << " of dimensions " << 0.5*coolDz << ", 0, 0, " << h1 << ", " << d2 << ", " << d1 << ", 0, " << h1 << ", " << d2 << ", " << d1 << ", 0"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDPixBarLayerAlgo",str); - Volume coolTube(solid.name(), solid, description.material(tubeMat)); - + + Volume coolTube = ns.addVolume(Volume(name, solid, description.material(tubeMat))); h1 -= coolThick; d1 -= coolThick; d2 -= coolThick; - solid = Trap(0.5*coolDz, 0, 0, h1, d2, d1, 0, h1, d2, d1, 0); - solid.setName(idName + "Coolant"); - - str << "Solid " << solid.name() + name = idName + "Coolant"; + solid = ns.addSolid(name, Trap(0.5*coolDz, 0, 0, h1, d2, d1, 0, h1, d2, d1, 0)); + LogDebug("PixelGeom") << "Solid " << solid.name() << " Trap made of " << coolMat << " of dimensions " << 0.5*coolDz << ", 0, 0, " << h1 << ", " << d2 << ", " << d1 << ", 0, " << h1 << ", " << d2 << ", " << d1 << ", 0"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDPixBarLayerAlgo",str); - Volume cool(solid.name(), solid, description.material(coolMat)); - //cpv.position(cool, coolTube, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation()); + Volume cool = ns.addVolume(Volume(name, solid, description.material(coolMat))); pv = coolTube.placeVolume(cool); - str << "Cool " << cool.name() + LogDebug("PixelGeom") << "Cool " << cool.name() << " number 1 positioned in " << coolTube.name() << " at (0,0,0) with no rotation"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDPixBarLayerAlgo",str); string ladderFull = ladder[0]; string ladderHalf = ladder[1]; @@ -154,22 +129,19 @@ static long create_element(Detector& description, ParsingContext& ctxt, xml_h e, rots = idName + std::to_string(copy); phix = phi-90*CLHEP::deg; phiy = 90*CLHEP::deg+phix; - str << "Creating a new " + LogDebug("PixelGeom") << "Creating a new " << "rotation: " << rots << "\t90., " << phix/CLHEP::deg << ", 90.," << phiy/CLHEP::deg << ", 0, 0"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDPixBarLayerAlgo",str); rot = make_rotation3D(90*CLHEP::deg, phix, 90*CLHEP::deg, phiy, 0.,0.); //cpv.position(ladderHalf, layer, copy, tran, rot); pv = layer.placeVolume(ladderHalfVol, Transform3D(rot,tran)); if ( !pv.isValid() ) { } - str << "ladderHalfVol: " << ladderHalfVol.name() + LogDebug("PixelGeom") << "ladderHalfVol: " << ladderHalfVol.name() << " number " << copy << " positioned in " << layer.name() << " at " << tran << " with " << rot; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDPixBarLayerAlgo",str); - copy++; iup = -1; rrr = rr - dr - 0.5*(ladderThick[1]-ladderThick[0]); @@ -177,20 +149,17 @@ static long create_element(Detector& description, ParsingContext& ctxt, xml_h e, rots = idName + std::to_string(copy); phix = phi+90*CLHEP::deg; phiy = 90*CLHEP::deg+phix; - str << "Creating a new rotation: " << rots << "\t90., " + LogDebug("PixelGeom") << "Creating a new rotation: " << rots << "\t90., " << phix/CLHEP::deg << ", 90.," << phiy/CLHEP::deg << ", 0, 0"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDPixBarLayerAlgo",str); - rot = make_rotation3D(90*CLHEP::deg, phix, 90*CLHEP::deg, phiy, 0.,0.); //cpv.position(ladderHalf, layer, copy, tran, rot); pv = layer.placeVolume(ladderHalfVol, Transform3D(rot,tran)); if ( !pv.isValid() ) { } - str << "ladderHalfVol: " << ladderHalfVol.name() + LogDebug("PixelGeom") << "ladderHalfVol: " << ladderHalfVol.name() << " number " << copy << " positioned in " << layer.name() << " at " << tran << " with " << rot; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDPixBarLayerAlgo",str); copy++; } else { iup =-iup; @@ -200,22 +169,19 @@ static long create_element(Detector& description, ParsingContext& ctxt, xml_h e, if (iup > 0) phix = phi-90*CLHEP::deg; else phix = phi+90*CLHEP::deg; phiy = phix+90.*CLHEP::deg; - str << "DDPixBarLayerAlgo test: Creating a new " + LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: Creating a new " << "rotation: " << rots << "\t90., " << phix/CLHEP::deg << ", 90.," << phiy/CLHEP::deg << ", 0, 0"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDPixBarLayerAlgo",str); - rot = make_rotation3D(90*CLHEP::deg, phix, 90*CLHEP::deg, phiy, 0.,0.); //cpv.position(ladderFull, layer, copy, tran, rot); pv = layer.placeVolume(ladderFullVol, Transform3D(rot,tran)); if ( !pv.isValid() ) { } - str << "test: " << ladderFullVol.name() + LogDebug("PixelGeom") << "test: " << ladderFullVol.name() << " number " << copy << " positioned in " << layer.name() << " at " << tran << " with " << rot; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDPixBarLayerAlgo",str); copy++; } rrr = coolDist*cos(0.5*dphi); @@ -224,38 +190,21 @@ static long create_element(Detector& description, ParsingContext& ctxt, xml_h e, phix = phi+0.5*dphi; if (iup > 0) phix += 180*CLHEP::deg; phiy = phix+90.*CLHEP::deg; - str << "Creating a new rotation: " << rots << "\t90., " + LogDebug("PixelGeom") << "Creating a new rotation: " << rots << "\t90., " << phix/CLHEP::deg << ", 90.," << phiy/CLHEP::deg << ", 0, 0"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDPixBarLayerAlgo",str); + rot = make_rotation3D(90*CLHEP::deg, phix, 90*CLHEP::deg, phiy, 0.,0.); - //cpv.position(coolTube, layer, i+1, tran, rot); - pv = layer.placeVolume(coolTube,Transform3D(rot,tran)); + pv = layer.placeVolume(coolTube,Transform3D(rot,tran)); if ( !pv.isValid() ) { } - str << "coolTube: " << coolTube.name() + LogDebug("PixelGeom") << "coolTube: " << coolTube.name() << " number " << i+1 << " positioned in " << layer.name() << " at " << tran << " with "<< rot; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDPixBarLayerAlgo",str); } - - ns.addVolumeNS(layer); - //nn.addVolume(assembly); - printout(INFO,"DDPixBarLayerAlgo","Layer: %s assembly:%s",layer.name(),"---"); -#if 0 - string det_name = idName; - Assembly assembly(det_name); - // Now we have built the layer.....create the DetElement object - DetElement det_elt(det_name,0); - pv = assembly.placeVolume(layer); - - det_elt.setPlacement(pv); - description.addDetector(det_elt); - Volume motherVol = description.pickMotherVolume(det_elt); - pv = motherVol.placeVolume(assembly); -#endif + LogDebug("PixelGeom") << "Layer: " << layer.name(); return 1; } // first argument is the type from the xml file -DECLARE_DDCMS_DETELEMENT(track_DDPixBarLayerAlgo,create_element) +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDPixBarLayerAlgo,algorithm) diff --git a/DDCMS/src/plugins/DDTECCoolAlgo.cpp b/DDCMS/src/plugins/DDTECCoolAlgo.cpp index 6dd9a87fac72a9aa1cd93290c21a436c7dd2066c..061e2079388adc54d2757e05dd9ddf7d9c0cd7dd 100644 --- a/DDCMS/src/plugins/DDTECCoolAlgo.cpp +++ b/DDCMS/src/plugins/DDTECCoolAlgo.cpp @@ -32,7 +32,6 @@ static long algorithm(Detector& /* description */, xml_h e, SensitiveDetector& /* sens */) { - stringstream str; Namespace ns(ctxt,e,true); AlgoArguments args(ctxt, e); int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1; @@ -41,19 +40,17 @@ static long algorithm(Detector& /* description */, vector<string> coolInsert = args.value<vector<string> >("CoolInsert"); Volume mother = ns.volume(args.parentName()); - str << "debug: Parent " << mother.name() - <<" NameSpace " << ns.name << " at radial Position " << rPosition; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECCoolAlgo",str); + LogDebug("TECGeom") << "debug: Parent " << mother.name() + <<" NameSpace " << ns.name << " at radial Position " << rPosition; if (phiPosition.size() == coolInsert.size()) { for (int i=0; i<(int)(phiPosition.size()); i++) { - str << "debug: Insert[" << i << "]: " + LogDebug("TECGeom") << "debug: Insert[" << i << "]: " << coolInsert.at(i) << " at Phi " << phiPosition.at(i)/CLHEP::deg; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECCoolAlgo",str); } - } else { - str << "ERROR: Number of inserts does not match the numer of PhiPositions!"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECCoolAlgo",str); + } + else { + LogDebug("TECGeom") << "ERROR: Number of inserts does not match the numer of PhiPositions!"; } int copyNo = startCopyNo; @@ -66,18 +63,17 @@ static long algorithm(Detector& /* description */, // place inserts Position tran(xpos, ypos, 0.0); mother.placeVolume(child,tran); - str << "test " << child.name() << "[" - << copyNo << "] positioned in " << mother.name() - << " at " << tran - << " phi " << phiPosition.at(i)/CLHEP::deg << " r " - << rPosition; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECCoolAlgo",str); + LogDebug("TECGeom") << "test " << child.name() << "[" + << copyNo << "] positioned in " << mother.name() + << " at " << tran + << " phi " << phiPosition.at(i)/CLHEP::deg << " r " + << rPosition; copyNo++; } - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECCoolAlgo","Finished...."); + LogDebug("TECGeom") << "Finished...."; return 1; } // first argument is the type from the xml file -DECLARE_DDCMS_DETELEMENT(track_DDTECCoolAlgo,algorithm) +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTECCoolAlgo,algorithm) diff --git a/DDCMS/src/plugins/DDTECModuleAlgo.cpp b/DDCMS/src/plugins/DDTECModuleAlgo.cpp index 4192461ffb48bd9298af53dd0bab048fc20628a6..c9eabf69d1cc29090a2a2f062f3ce830ce5e4037 100644 --- a/DDCMS/src/plugins/DDTECModuleAlgo.cpp +++ b/DDCMS/src/plugins/DDTECModuleAlgo.cpp @@ -17,12 +17,8 @@ // Framework include files #include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/Printout.h" #include "DDCMS/DDCMSPlugins.h" -// C/C++ include files -#include <sstream> - using namespace std; using namespace dd4hep; using namespace dd4hep::cms; @@ -31,11 +27,9 @@ static void doPos(ParsingContext& ctxt, Volume toPos, Volume mother, int /* copyNr */, double x, double y, double z, const string& rotName) { - stringstream str; Namespace ns(ctxt); mother.placeVolume(toPos,Transform3D(ns.rotation(rotName),Position(x,y,z))); - str << "Volume: " << mother.name() << " positioned daughter "<< mother.name(); - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); + LogDebug("TECGeom") << "Volume: " << mother.name() << " positioned daughter "<< mother.name(); } static void doPos(ParsingContext& ctxt, Volume toPos, Volume mother, @@ -63,7 +57,6 @@ static long algorithm(Detector& /* description */, xml_h e, SensitiveDetector& /* sens */) { - stringstream str; Namespace ns(ctxt, e, true); AlgoArguments args(ctxt, e); Volume mother = ns.volume(args.parentName()); @@ -147,25 +140,22 @@ static long algorithm(Detector& /* description */, double siReenforceThick = args.value<double>("SiReenforcementThick");// Thick string siReenforceMat = args.value<string>("SiReenforcementMaterial"); // Materieal - str << "debug: ModuleThick " << moduleThick + LogDebug("TECGeom") << "debug: ModuleThick " << moduleThick << " Detector Tilt " << detTilt/CLHEP::deg << " Height " << fullHeight << " dl(Top) " << dlTop << " dl(Bottom) " << dlBottom << " dl(Hybrid) " << dlHybrid << " rPos " << rPos << " standrad rotation " << standardRot; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); - str << "debug: Frame Width " << frameWidth + LogDebug("TECGeom") << "debug: Frame Width " << frameWidth << " Thickness " << frameThick << " Overlap " << frameOver; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); - str << "debug: Top Frame Material " + LogDebug("TECGeom") << "debug: Top Frame Material " << topFrameMat << " Height " << topFrameHeight << " Top Width " << topFrameTopWidth << " Bottom Width " << topFrameTopWidth << " Thickness " << topFrameThick <<" positioned at" << topFrameZ; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); - str << "debug : Side Frame Material " + LogDebug("TECGeom") << "debug : Side Frame Material " << sideFrameMat << " Thickness " << sideFrameThick << " left Leg's Width: " << sideFrameLWidth << " left Leg's Height: " << sideFrameLHeight @@ -175,74 +165,61 @@ static long algorithm(Detector& /* description */, << " right Leg's tilt(theta): " << sideFrameRtheta << "Supplies Box's Material: " << siFrSuppBoxMat << " positioned at" << sideFrameZ; - for (int i= 0; i < (int)(siFrSuppBoxWidth.size());i++){ - str << " Supplies Box" << i << "'s Width: " + for (int i= 0; i < (int)(siFrSuppBoxWidth.size());i++) + LogDebug("TECGeom") << " Supplies Box" << i << "'s Width: " << siFrSuppBoxWidth[i] << " Supplies Box" << i <<"'s Height: " << siFrSuppBoxHeight[i] << " Supplies Box" << i << "'s y Position: " << siFrSuppBoxYPos[i]; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); - } - str << "debug: Wafer Material " + LogDebug("TECGeom") << "debug: Wafer Material " << waferMat << " Side Width Top" << sideWidthTop << " Side Width Bottom" << sideWidthBottom << " and positioned at "<<waferPosition << " positioned with rotation" << " matrix:" << waferRot; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); - str << "debug: Active Material " + LogDebug("TECGeom") << "debug: Active Material " << activeMat << " Height " << activeHeight << " rotated by " << activeRot << " translated by (0,0," << -0.5 * backplaneThick << ")" << " Thickness/Z" << waferThick-backplaneThick << "/" << activeZ; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); - str << "debug: Hybrid Material " + LogDebug("TECGeom") << "debug: Hybrid Material " << hybridMat << " Height " << hybridHeight << " Width " << hybridWidth << " Thickness " << hybridThick << " Z" << hybridZ; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); - str << "debug: Pitch Adapter Material " + LogDebug("TECGeom") << "debug: Pitch Adapter Material " << pitchMat << " Height " << pitchHeight << " Thickness " << pitchThick << " position with " << " rotation " << pitchRot << " at Z" << pitchZ; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); - str << "debug: Bridge Material " + LogDebug("TECGeom") << "debug: Bridge Material " << bridgeMat << " Width " << bridgeWidth << " Thickness " << bridgeThick << " Height " << bridgeHeight << " Separation "<< bridgeSep; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); - str << "FALTBOOT DDTECModuleAlgo debug : Si-Reenforcement Material " + LogDebug("TECGeom") << "FALTBOOT DDTECModuleAlgo debug : Si-Reenforcement Material " << sideFrameMat << " Thickness " << siReenforceThick; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); - for (int i= 0; i < (int)(siReenforceWidth.size());i++){ - str << " SiReenforcement" << i << "'s Width: " + for (int i= 0; i < (int)(siReenforceWidth.size());i++) + LogDebug("TECGeom") << " SiReenforcement" << i << "'s Width: " << siReenforceWidth[i] << " SiReenforcement" << i << "'s Height: " << siReenforceHeight[i] << " SiReenforcement" << i << "'s y Position: " <<siReenforceYPos[i]; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); - } + if(!isStereo){ - str << "This is a normal module, in ring "<<ringNo<<"!"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); - } else { - str << "This is a stereo module, in ring "<<ringNo<<"!"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); - str << "Phi Position corrected by " << posCorrectionPhi << "*rad"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); - str << "debug: stereo Top Frame 2nd Part left Heigt " + LogDebug("TECGeom") << "This is a normal module, in ring "<<ringNo<<"!"; + } + else { + LogDebug("TECGeom") << "This is a stereo module, in ring "<<ringNo<<"!"; + LogDebug("TECGeom") << "Phi Position corrected by " << posCorrectionPhi << "*rad"; + LogDebug("TECGeom") << "debug: stereo Top Frame 2nd Part left Heigt " << topFrame2LHeight << " right Height " << topFrame2RHeight << " Width " << topFrame2Width ; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); - str << " left Leg's lower Width: " << sideFrameLWidthLow + LogDebug("TECGeom") << " left Leg's lower Width: " << sideFrameLWidthLow << " right Leg's lower Width: " << sideFrameRWidthLow; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); } // Execution part: - str << "==>> Constructing DDTECModuleAlgo: "; + LogDebug("TECGeom") << "==>> Constructing DDTECModuleAlgo: "; //declarations double tmp; //names @@ -252,8 +229,7 @@ static long algorithm(Detector& /* description */, //usefull constants const double topFrameEndZ = 0.5 * (-waferPosition + fullHeight) + pitchHeight + hybridHeight - topFrameHeight; string idName = ns.prepend(ns.obj_name(mother.name())); - str << "idName: " << idName << " parent " << mother.name() << " namespace " << ns.name; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); + LogDebug("TECGeom") << "idName: " << idName << " parent " << mother.name() << " namespace " << ns.name; Solid solid; //set global parameters @@ -283,12 +259,11 @@ static long algorithm(Detector& /* description */, if(isStereo) bl1 = 0.5 * sideFrameLWidthLow; solid = Trap(dz, thet, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0); ns.addSolidNS(name,solid); - str << "Solid: " << solid.name() + LogDebug("TECGeom") << "Solid: " << solid.name() << " Trap made of " << sideFrameMat << " of dimensions " << dz << ", "<<thet<<", 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl2 << ", 0"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); Volume sideFrameLeft(name, solid, ns.material(sideFrameMat)); ns.addVolumeNS(sideFrameLeft); //translate @@ -320,12 +295,11 @@ static long algorithm(Detector& /* description */, if(isStereo) bl1 = 0.5 * sideFrameRWidthLow; solid = Trap(dz, thet, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0); ns.addSolidNS(name,solid); - str << "Solid:\t" << solid.name() + LogDebug("TECGeom") << "Solid:\t" << solid.name() << " Trap made of " << sideFrameMat << " of dimensions " << dz << ", "<<thet<<", 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl2 << ", 0"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); Volume sideFrameRight(name, solid, ns.material(sideFrameMat)); ns.addVolumeNS(sideFrameRight); //translate @@ -360,12 +334,11 @@ static long algorithm(Detector& /* description */, // ^-- this calculates the lower left angel of the tipped trapezoid, which is the SideFframe... solid = Trap(dz, thet,0, h1, bl1, bl1, 0, h1, bl2, bl2, 0); - str << "Solid:\t" << solid.name() + LogDebug("TECGeom") << "Solid:\t" << solid.name() << " Trap made of " << siFrSuppBoxMat << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl2 << ", 0"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); Volume siFrSuppBox(name, solid, matter); ns.addVolumeNS(siFrSuppBox); //translate @@ -394,10 +367,9 @@ static long algorithm(Detector& /* description */, dz = 0.5 * hybridHeight; solid = Box(dx, dy, dz); ns.addSolidNS(name, solid); - str << "Solid:\t" << solid.name() + LogDebug("TECGeom") << "Solid:\t" << solid.name() << " Box made of " << hybridMat << " of dimensions " << dx << ", " << dy << ", " << dz; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); Volume hybrid(name, solid, ns.material(hybridMat)); ns.addVolumeNS(hybrid); @@ -415,12 +387,11 @@ static long algorithm(Detector& /* description */, dz = 0.5 * fullHeight; solid = Trap(dz, 0, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0); ns.addSolidNS(name,solid); - str << "Solid:\t" << solid.name() + LogDebug("TECGeom") << "Solid:\t" << solid.name() << " Trap made of " << waferMat << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl2 << ", 0"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); Volume wafer(name, solid, ns.material(waferMat)); ypos = activeZ; @@ -440,12 +411,11 @@ static long algorithm(Detector& /* description */, } solid = Trap(dz, 0, 0, h1, bl2, bl1, 0, h1, bl2, bl1, 0); ns.addSolidNS(name,solid); - str << "Solid:\t" << solid.name() + LogDebug("TECGeom") << "Solid:\t" << solid.name() << " Trap made of " << activeMat << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bl2 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl1 << ", 0"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); Volume active(name, solid, ns.material(activeMat)); ns.addVolumeNS(active); doPos(ctxt, active, wafer, 1, -0.5 * backplaneThick,0,0, activeRot); // from the definition of the wafer local axes and doPos() routine @@ -467,12 +437,11 @@ static long algorithm(Detector& /* description */, } solid = Trap(dz, 0, 0, h1, bl2, bl1, 0, h1, bl2, bl1, 0); ns.addSolidNS(name,solid); - str << "Solid:\t" << solid.name() + LogDebug("TECGeom") << "Solid:\t" << solid.name() << " Trap made of " << inactiveMat << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bl2 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl1 << ", 0"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); Volume inactive(name, solid, ns.material(inactiveMat)); ns.addVolumeNS(inactive); ypos = inactivePos - 0.5*activeHeight; @@ -486,10 +455,9 @@ static long algorithm(Detector& /* description */, dz = 0.5 * pitchHeight; solid = Box(dx, dy, dz); ns.addSolidNS(name,solid); - str << "Solid:\t" << solid.name() + LogDebug("TECGeom") << "Solid:\t" << solid.name() << " Box made of " << pitchMat <<" of dimensions " << dx << ", " << dy << ", " << dz; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); } else { dz = 0.5 * pitchWidth; h1 = 0.5 * pitchThick; @@ -498,13 +466,12 @@ static long algorithm(Detector& /* description */, thet = atan((bl1-bl2)/(2.*dz)); solid = Trap(dz, thet, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0); ns.addSolidNS(name,solid); - str << "Solid:\t" << solid.name() + LogDebug("TECGeom") << "Solid:\t" << solid.name() << " Trap made of " << pitchMat << " of dimensions " << dz << ", " << thet/CLHEP::deg << ", 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl2 << ", 0"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); } xpos = 0; ypos = pitchZ; @@ -529,12 +496,11 @@ static long algorithm(Detector& /* description */, solid = Trap(dz, 0, 0, h1, bl1, bl1,0, h1, bl2, bl2, 0); ns.addSolid(name,solid); - str << "Solid:\t" << solid.name() + LogDebug("TECGeom") << "Solid:\t" << solid.name() << " Trap made of " << topFrameMat << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl2 << ", 0"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); Volume topFrame(name, solid, ns.material(topFrameMat)); ns.addVolumeNS(topFrame); @@ -549,12 +515,11 @@ static long algorithm(Detector& /* description */, solid = Trap(dz, thet, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0); ns.addSolid(name,solid); - str << "Solid:\t" << solid.name() + LogDebug("TECGeom") << "Solid:\t" << solid.name() << " Trap made of " << topFrameMat << " of dimensions " << dz << ", " << thet/CLHEP::deg << ", 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl2 << ", 0"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); } // Position the topframe @@ -580,12 +545,11 @@ static long algorithm(Detector& /* description */, dz = 0.5 * siReenforceHeight[i]; bl1 = bl2 = 0.5 * siReenforceWidth[i]; solid = Trap(dz, 0, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0); - str << "Solid:\t" << solid.name() + LogDebug("TECGeom") << "Solid:\t" << solid.name() << " Trap made of " << matter.name() << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl2 << ", 0"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); Volume siReenforce(name, solid, matter); ns.addVolumeNS(siReenforce); //translate @@ -612,34 +576,30 @@ static long algorithm(Detector& /* description */, h1 = 0.5 * bridgeThick; dz = 0.5 * bridgeHeight; solid = Trap(dz, 0, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0); - str << "Solid:\t" << solid.name() + LogDebug("TECGeom") << "Solid:\t" << solid.name() << " Trap made of " << bridgeMat << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl2 << ", 0"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); Volume bridge(name, solid, ns.material(bridgeMat)); ns.addVolumeNS(bridge); name = idName + "BridgeGap"; bl1 = 0.5*bridgeSep; solid = Box(bl1, h1, dz); - str << "Solid:\t" << solid.name() + LogDebug("TECGeom") << "Solid:\t" << solid.name() << " Box made of " << genMat << " of dimensions " << bl1 << ", " << h1 << ", " << dz; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); Volume bridgeGap(name, solid, ns.material(genMat)); ns.addVolumeNS(bridgeGap); /* PlacedVolume pv = */ bridge.placeVolume(bridgeGap); - str << "Solid: " << bridgeGap.name() + LogDebug("TECGeom") << "Solid: " << bridgeGap.name() << " number 1 positioned in " << bridge.name() << " at (0,0,0) with no rotation"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); } - str << "<<== End of DDTECModuleAlgo construction ..."; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECModuleAlgo",str); + LogDebug("TECGeom") << "<<== End of DDTECModuleAlgo construction ..."; return 1; } // first argument is the type from the xml file -DECLARE_DDCMS_DETELEMENT(track_DDTECModuleAlgo,algorithm) +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTECModuleAlgo,algorithm) diff --git a/DDCMS/src/plugins/DDTECOptoHybAlgo.cpp b/DDCMS/src/plugins/DDTECOptoHybAlgo.cpp index 76e99613f77298b04cd0381d882898adc309a4af..803790537c2d3b68ee9fcda6855d83786da76ab7 100644 --- a/DDCMS/src/plugins/DDTECOptoHybAlgo.cpp +++ b/DDCMS/src/plugins/DDTECOptoHybAlgo.cpp @@ -17,12 +17,8 @@ // Framework include files #include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/Printout.h" #include "DDCMS/DDCMSPlugins.h" -// C/C++ include files -#include <sstream> - using namespace std; using namespace dd4hep; using namespace dd4hep::cms; @@ -32,7 +28,6 @@ static long algorithm(Detector& /* description */, xml_h e, SensitiveDetector& /* sens */) { - stringstream str; Namespace ns(ctxt,e,true); AlgoArguments args(ctxt, e); int startCopyNo = args.value<int>("StartCopyNo"); @@ -44,15 +39,13 @@ static long algorithm(Detector& /* description */, Volume child = ns.volume(args.value<string>("ChildName")); Volume mother = ns.volume(args.parentName()); - str << "Parent " << mother.name() << " Child " << child.name() << " NameSpace " << ns.name; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECOptoHybAlgo",str); - - str << "Height of the Hybrid " - << optoHeight << " and Width " << optoWidth - <<"Rpos " << rpos << " Zpos " << zpos - << " StartCopyNo " << startCopyNo << " Number " - << angles.size(); - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECOptoHybAlgo",str); + LogDebug("TECGeom") << "Parent " << mother.name() + << " Child " << child.name() << " NameSpace " << ns.name; + LogDebug("TECGeom") << "Height of the Hybrid " + << optoHeight << " and Width " << optoWidth + <<"Rpos " << rpos << " Zpos " << zpos + << " StartCopyNo " << startCopyNo << " Number " + << angles.size(); // given r positions are for the lower left corner rpos += optoHeight/2; @@ -76,25 +69,22 @@ static long algorithm(Detector& /* description */, } else { double theta = 90.*CLHEP::deg; - str << "test: Creating a new " - << "rotation: " << rotstr << "\t90., " - << phix/CLHEP::deg << ", 90.," << phiy/CLHEP::deg - << ", 0, 0"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECOptoHybAlgo",str); + LogDebug("TECGeom") << "test: Creating a new " + << "rotation: " << rotstr << "\t90., " + << phix/CLHEP::deg << ", 90.," << phiy/CLHEP::deg + << ", 0, 0"; rotation = make_rotation3D(theta, phix, theta, phiy, 0., 0.); } } mother.placeVolume(child, Transform3D(rotation,tran)); - str << "test " << child.name() << " number " - << copyNo << " positioned in " << mother.name() << " at " - << tran << " with " << rotation; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECOptoHybAlgo",str); + LogDebug("TECGeom") << "test " << child.name() << " number " + << copyNo << " positioned in " << mother.name() << " at " + << tran << " with " << rotation; copyNo++; } - str << "<<== End of DDTECOptoHybAlgo construction ..."; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECOptoHybAlgo",str); + LogDebug("TECGeom") << "<<== End of DDTECOptoHybAlgo construction ..."; return 1; } // first argument is the type from the xml file -DECLARE_DDCMS_DETELEMENT(track_DDTECOptoHybAlgo,algorithm) +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTECOptoHybAlgo,algorithm) diff --git a/DDCMS/src/plugins/DDTECPhiAlgo.cpp b/DDCMS/src/plugins/DDTECPhiAlgo.cpp index 85c04c917579291f0dc987062b92d310bd88e44e..e14311814e72f57b5c2f827602734ba88c6489b5 100644 --- a/DDCMS/src/plugins/DDTECPhiAlgo.cpp +++ b/DDCMS/src/plugins/DDTECPhiAlgo.cpp @@ -17,12 +17,8 @@ // Framework include files #include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/Printout.h" #include "DDCMS/DDCMSPlugins.h" -// C/C++ include files -#include <sstream> - using namespace std; using namespace dd4hep; using namespace dd4hep::cms; @@ -32,7 +28,6 @@ static long algorithm(Detector& /* description */, xml_h e, SensitiveDetector& /* sens */) { - stringstream str; Namespace ns(ctxt, e, true); AlgoArguments args(ctxt, e); Volume mother = ns.volume(args.parentName()); @@ -45,18 +40,16 @@ static long algorithm(Detector& /* description */, int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1; //Start copy number int incrCopyNo = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1; //Increment in copy number - str << "debug: Parameters for " + LogDebug("TECGeom") << "debug: Parameters for " << "positioning--" << "\tStartAngle " << startAngle/CLHEP::deg << "\tIncrAngle " << incrAngle/CLHEP::deg << "\tZ in/out " << zIn << ", " << zOut << "\tCopy Numbers " << number << " Start/Increment " << startCopyNo << ", " << incrCopyNo; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECPhiAlgo",str); - str << "debug: Parent " << mother.name() + LogDebug("TECGeom") << "debug: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace " << ns.name; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECPhiAlgo",str); if (number > 0) { double theta = 90.*CLHEP::deg; @@ -67,10 +60,9 @@ static long algorithm(Detector& /* description */, Rotation3D rotation = make_rotation3D(theta, phix, theta, phiy, 0, 0); Position tran(0., 0., (i%2 == 0) ? zIn : zOut); /* PlacedVolume pv = */ mother.placeVolume(child,Transform3D(rotation,tran)); - str << "test: " << child.name() <<" number " + LogDebug("TECGeom") << "test: " << child.name() <<" number " << copyNo << " positioned in " << mother.name() <<" at " << tran << " with " << rotation; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECPhiAlgo",str); copyNo += incrCopyNo; } } @@ -78,4 +70,4 @@ static long algorithm(Detector& /* description */, } // first argument is the type from the xml file -DECLARE_DDCMS_DETELEMENT(track_DDTECPhiAlgo,algorithm) +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTECPhiAlgo,algorithm) diff --git a/DDCMS/src/plugins/DDTECPhiAltAlgo.cpp b/DDCMS/src/plugins/DDTECPhiAltAlgo.cpp index b14a52d28a1861172b612a463dd913201bcec2e7..3d355a498d58303119f768b106ca5919e27002a0 100644 --- a/DDCMS/src/plugins/DDTECPhiAltAlgo.cpp +++ b/DDCMS/src/plugins/DDTECPhiAltAlgo.cpp @@ -17,12 +17,8 @@ // Framework include files #include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/Printout.h" #include "DDCMS/DDCMSPlugins.h" -// C/C++ include files -#include <sstream> - using namespace std; using namespace dd4hep; using namespace dd4hep::cms; @@ -32,7 +28,6 @@ static long algorithm(Detector& /* description */, xml_h e, SensitiveDetector& /* sens */) { - stringstream str; Namespace ns(ctxt, e, true); AlgoArguments args(ctxt, e); Volume mother = ns.volume(args.parentName()); @@ -45,18 +40,16 @@ static long algorithm(Detector& /* description */, int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1; //Start copy number int incrCopyNo = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1; //Increment in copy number - str << "debug: Parameters for " + LogDebug("TECGeom") << "debug: Parameters for " << "positioning--" << "\tStartAngle " << startAngle/CLHEP::deg << "\tIncrAngle " << incrAngle/CLHEP::deg << "\tZ in/out " << zIn << ", " << zOut << "\tCopy Numbers " << number << " Start/Increment " << startCopyNo << ", " << incrCopyNo; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECPhiAltAlgo",str); - str << "debug: Parent " << mother.name() + LogDebug("TECGeom") << "debug: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace " << ns.name; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECPhiAltAlgo",str); if (number > 0) { double theta = 90.*CLHEP::deg; @@ -67,10 +60,9 @@ static long algorithm(Detector& /* description */, Rotation3D rotation = make_rotation3D(theta, phix, 0e0, 0e0, theta, phiz); Position tran(0., 0., (i%2 == 0) ? zIn : zOut); /* PlacedVolume pv = */ mother.placeVolume(child,Transform3D(rotation,tran)); - str << "test: " << child.name() <<" number " + LogDebug("TECGeom") << "test: " << child.name() <<" number " << copyNo << " positioned in " << mother.name() <<" at " << tran << " with " << rotation; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTECPhiAltAlgo",str); copyNo += incrCopyNo; } } @@ -78,5 +70,5 @@ static long algorithm(Detector& /* description */, } // first argument is the type from the xml file -DECLARE_DDCMS_DETELEMENT(track_DDTECPhiAltAlgo,algorithm) +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTECPhiAltAlgo,algorithm) diff --git a/DDCMS/src/plugins/DDTIBLayerAlgo.cpp b/DDCMS/src/plugins/DDTIBLayerAlgo.cpp index ccc991dfffe5e030ecc555049fd5ee39b3d051e3..75eb159f45a10ab477b472ebb5408cd7ead9e4b6 100644 --- a/DDCMS/src/plugins/DDTIBLayerAlgo.cpp +++ b/DDCMS/src/plugins/DDTIBLayerAlgo.cpp @@ -17,12 +17,8 @@ // Framework include files #include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/Printout.h" #include "DDCMS/DDCMSPlugins.h" -// C/C++ include files -#include <sstream> - using namespace std; using namespace dd4hep; using namespace dd4hep::cms; @@ -32,15 +28,542 @@ static long algorithm(Detector& /* description */, xml_h e, SensitiveDetector& /* sens */) { - stringstream str; + typedef vector<double> vecdouble; Namespace ns(ctxt, e, true); AlgoArguments args(ctxt, e); - //Volume mother = ns.volume(args.parentName()); + string mother = args.parentName(); + string genMat = args.str("GeneralMaterial"); //General material name + double detectorTilt = args.dble("DetectorTilt"); //Detector Tilt + double layerL = args.dble("LayerL"); //Length of the layer + + double radiusLo = args.dble("RadiusLo"); //Radius for detector at lower level + int stringsLo = args.integer("StringsLo"); //Number of strings ...... + string detectorLo = args.str("StringDetLoName"); //Detector string name ...... + + double radiusUp = args.dble("RadiusUp"); //Radius for detector at upper level + int stringsUp = args.integer("StringsUp"); //Number of strings ...... + string detectorUp = args.str("StringDetUpName"); //Detector string name ...... + + double cylinderT = args.dble("CylinderThickness"); //Cylinder thickness + double cylinderInR = args.dble("CylinderInnerRadius"); //Cylinder inner radius + string cylinderMat = args.str("CylinderMaterial"); //Cylinder material + double MFRingInR = args.dble("MFRingInnerRadius"); //Inner Manifold Ring Inner Radius + double MFRingOutR = args.dble("MFRingOuterRadius"); //Outer Manifold Ring Outer Radius + double MFRingT = args.dble("MFRingThickness"); //Manifold Ring Thickness + double MFRingDz = args.dble("MFRingDeltaz"); //Manifold Ring Half Lenght + string MFIntRingMat = args.str("MFIntRingMaterial"); //Manifold Ring Material + string MFExtRingMat = args.str("MFExtRingMaterial"); //Manifold Ring Material + + double supportT = args.dble("SupportThickness"); //Cylinder barrel CF skin thickness + + string centMat = args.str("CentRingMaterial"); //Central rings material + vecdouble centRing1par = args.vecDble("CentRing1"); //Central rings parameters + vecdouble centRing2par = args.vecDble("CentRing2"); //Central rings parameters + + string fillerMat = args.str("FillerMaterial"); //Filler material + double fillerDz = args.dble("FillerDeltaz"); //Filler Half Length + + string ribMat = args.str("RibMaterial"); //Rib material + vecdouble ribW = args.vecDble("RibWidth"); //Rib width + vecdouble ribPhi = args.vecDble("RibPhi"); //Rib Phi position + + vecdouble dohmListFW = args.vecDble("DOHMListFW"); //DOHM/AUX positions in #strings FW + vecdouble dohmListBW = args.vecDble("DOHMListBW"); //DOHM/AUX positions in #strings BW + + double dohmtoMF = args.dble("DOHMtoMFDist"); //DOHM Distance to MF + double dohmCarrierPhiOff = args.dble("DOHMCarrierPhiOffset"); //DOHM Carrier Phi offset wrt horizontal + string dohmPrimName = args.str("StringDOHMPrimName"); //DOHM Primary Logical Volume name + string dohmAuxName = args.str("StringDOHMAuxName"); //DOHM Auxiliary Logical Volume name + + string dohmCarrierMaterial = args.str("DOHMCarrierMaterial");//DOHM Carrier Material + string dohmCableMaterial = args.str("DOHMCableMaterial"); //DOHM Cable Material + double dohmPrimL = args.dble("DOHMPRIMLength"); //DOHM PRIMary Length + string dohmPrimMaterial = args.str("DOHMPRIMMaterial"); //DOHM PRIMary Material + double dohmAuxL = args.dble("DOHMAUXLength"); //DOHM AUXiliary Length + string dohmAuxMaterial = args.str("DOHMAUXMaterial"); //DOHM AUXiliary Material + + string pillarMaterial = args.str("PillarMaterial"); //Pillar Material + + double fwIntPillarDz = args.dble("FWIntPillarDz"); //Internal pillar parameters + double fwIntPillarDPhi = args.dble("FWIntPillarDPhi"); + vecdouble fwIntPillarZ = args.vecDble("FWIntPillarZ"); + vecdouble fwIntPillarPhi = args.vecDble("FWIntPillarPhi"); + double bwIntPillarDz = args.dble("BWIntPillarDz"); + double bwIntPillarDPhi = args.dble("BWIntPillarDPhi"); + vecdouble bwIntPillarZ = args.vecDble("BWIntPillarZ"); + vecdouble bwIntPillarPhi = args.vecDble("BWIntPillarPhi"); + + double fwExtPillarDz = args.dble("FWExtPillarDz"); //External pillar parameters + double fwExtPillarDPhi = args.dble("FWExtPillarDPhi"); + vecdouble fwExtPillarZ = args.vecDble("FWExtPillarZ"); + vecdouble fwExtPillarPhi = args.vecDble("FWExtPillarPhi"); + double bwExtPillarDz = args.dble("BWExtPillarDz"); + double bwExtPillarDPhi = args.dble("BWExtPillarDPhi"); + vecdouble bwExtPillarZ = args.vecDble("BWExtPillarZ"); + vecdouble bwExtPillarPhi = args.vecDble("BWExtPillarPhi"); + + LogDebug("TIBGeom") << "Parent " << mother + << " NameSpace " << ns.name + << " General Material " << genMat; + LogDebug("TIBGeom") << "Lower layer Radius " << radiusLo + << " Number " << stringsLo << " String " << detectorLo; + LogDebug("TIBGeom") << "Upper layer Radius "<< radiusUp + << " Number " << stringsUp << " String " << detectorUp; + LogDebug("TIBGeom") << "Cylinder Material/thickness " << cylinderMat << " " << cylinderT + << " Rib Material " << ribMat << " at " << ribW.size() << " positions with width/phi"; + for (unsigned int i = 0; i < ribW.size(); i++) { + LogDebug("TIBGeom") << "\tribW[" << i << "] = " << ribW[i] + << "\tribPhi[" << i << "] = " << ribPhi[i]/CLHEP::deg; + } + LogDebug("TIBGeom") << "DOHM Primary " << " Material " << dohmPrimMaterial << " Length " << dohmPrimL; + LogDebug("TIBGeom") << "DOHM Aux " << " Material " << dohmAuxMaterial << " Length " << dohmAuxL; + for (double i : dohmListFW) { + if (i>0.) LogDebug("TIBGeom") << "DOHM Primary at FW Position " << i; + if (i<0.) LogDebug("TIBGeom") << "DOHM Aux at FW Position " << -i; + } + for (double i : dohmListBW) { + if (i>0.) LogDebug("TIBGeom") << "DOHM Primary at BW Position " << i; + if (i<0.) LogDebug("TIBGeom") << "DOHM Aux at BW Position " << -i; + } + LogDebug("TIBGeom") << "FW Internal Pillar [Dz, DPhi] " << fwIntPillarDz << ", " << fwIntPillarDPhi; + for (unsigned int i=0; i<fwIntPillarZ.size(); i++) { + if( fwIntPillarPhi[i]>0. ) { + LogDebug("TIBGeom") << " at positions [z, phi] " << fwIntPillarZ[i] << " " << fwIntPillarPhi[i]; + } + } + LogDebug("TIBGeom") << "BW Internal Pillar [Dz, DPhi] " << bwIntPillarDz << ", " << bwIntPillarDPhi; + for (unsigned int i=0; i<bwIntPillarZ.size(); i++) { + if( bwIntPillarPhi[i]>0. ) { + LogDebug("TIBGeom") << " at positions [z, phi] " << bwIntPillarZ[i] << " " << bwIntPillarPhi[i]; + } + } + LogDebug("TIBGeom") << "FW External Pillar [Dz, DPhi] " << fwExtPillarDz << ", " << fwExtPillarDPhi; + for (unsigned int i=0; i<fwExtPillarZ.size(); i++) { + if( fwExtPillarPhi[i]>0. ) { + LogDebug("TIBGeom") << " at positions [z, phi] " << fwExtPillarZ[i] << " " << fwExtPillarPhi[i]; + } + } + LogDebug("TIBGeom") << "BW External Pillar [Dz, DPhi] " << bwExtPillarDz << ", " << bwExtPillarDPhi; + for (unsigned int i=0; i<bwExtPillarZ.size(); i++) { + if( bwExtPillarPhi[i]>0. ) { + LogDebug("TIBGeom") << " at positions [z, phi] " << bwExtPillarZ[i] << " " << bwExtPillarPhi[i]; + } + } + + string idName = mother; + double rmin = MFRingInR; + double rmax = MFRingOutR; + Solid solid = ns.addSolidNS(idName,Tube(rmin, rmax, 0.5*layerL)); + LogDebug("TIBGeom") << solid.name() << " Tubs made of " + << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg + << " with Rin " << rmin << " Rout " << rmax << " ZHalf " << 0.5*layerL; + Volume layer = ns.addVolumeNS(Volume(idName, solid, ns.material(genMat))); + + //Internal layer first + double rin = rmin+MFRingT; + // double rout = 0.5*(radiusLo+radiusUp-cylinderT); + double rout = cylinderInR; + string name = idName + "Down"; + solid = ns.addSolidNS(name,Tube(rin, rout, 0.5*layerL)); + LogDebug("TIBGeom") << solid.name() << " Tubs made of " + << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg + << " with Rin " << rin << " Rout " << rout + << " ZHalf " << 0.5*layerL; + Volume layerIn = ns.addVolumeNS(Volume(name, solid, ns.material(genMat))); + layer.placeVolume(layerIn); // copyNr=1 ! + LogDebug("TIBGeom") << layerIn.name() + << " number 1 positioned in " << layer.name() + << " at (0,0,0) with no rotation"; + + double rposdet = radiusLo; + double dphi = CLHEP::twopi/stringsLo; + Volume detIn = ns.volume(detectorLo); + for (int n = 0; n < stringsLo; n++) { + double phi = (n+0.5)*dphi; + double phix = phi - detectorTilt + 90*CLHEP::deg; + double theta = 90*CLHEP::deg; + double phiy = phix + 90.*CLHEP::deg; + Rotation3D rotation = make_rotation3D(theta, phix, theta, phiy, 0., 0.); + Position trdet(rposdet*cos(phi), rposdet*sin(phi), 0); + layerIn.placeVolume(detIn, Transform3D(rotation,trdet)); // copyNr=n+1 + LogDebug("TIBGeom") << detIn.name() << " number " << n+1 << " positioned in " + << layerIn.name() << " at " << trdet << " with " + << rotation; + } + + //Now the external layer + rin = cylinderInR + cylinderT; + rout = rmax-MFRingT; + name = idName + "Up"; + solid = ns.addSolidNS(name,Tube(rin, rout, 0.5*layerL)); + LogDebug("TIBGeom") << solid.name() << " Tubs made of " + << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg + << " with Rin " << rin << " Rout " << rout + << " ZHalf " << 0.5*layerL; + Volume layerOut = ns.addVolumeNS(Volume(name, solid, ns.material(genMat))); + layer.placeVolume(layerOut); // CopyNr again 1 ?? + LogDebug("TIBGeom") << layerOut.name() + << " number 1 positioned in " << layer.name() + << " at (0,0,0) with no rotation"; + + rposdet = radiusUp; + dphi = CLHEP::twopi/stringsUp; + Volume detOut = ns.volume(detectorUp); + for (int n = 0; n < stringsUp; n++) { + double phi = (n+0.5)*dphi; + double phix = phi - detectorTilt - 90*CLHEP::deg; + double theta = 90*CLHEP::deg; + double phiy = phix + 90.*CLHEP::deg; + Rotation3D rotation = make_rotation3D(theta, phix, theta, phiy, 0., 0.); + Position trdet(rposdet*cos(phi), rposdet*sin(phi), 0); + layerOut.placeVolume(detOut,Transform3D(rotation,trdet)); + LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << detectorUp + << " number " << n+1 << " positioned in " + << layerOut.name() << " at " << trdet << " with " + << rotation; + } + + // + // Inner cylinder, support wall and ribs + // + // External skins + rin = cylinderInR; + rout = cylinderInR+cylinderT; + name = idName + "Cylinder"; + solid = ns.addSolidNS(name, Tube(rin, rout, 0.5*layerL)); + LogDebug("TIBGeom") << solid.name() << " Tubs made of " + << cylinderMat << " from 0 to " + << CLHEP::twopi/CLHEP::deg << " with Rin " << rin + << " Rout " << rout << " ZHalf " << 0.5*layerL; + Volume cylinder = ns.addVolumeNS(Volume(name, solid, ns.material(cylinderMat))); + layer.placeVolume(cylinder); // CopyNr = 1 + LogDebug("TIBGeom") << cylinder.name() + << " number 1 positioned in " << layer.name() + << " at (0,0,0) with no rotation"; + // + // inner part of the cylinder + // + rin += supportT; + rout -= supportT; + name = idName + "CylinderIn"; + solid = ns.addSolidNS(name, Tube(rin, rout, 0.5*layerL)); + LogDebug("TIBGeom") << solid.name() << " Tubs made of " + << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg + << " with Rin " << rin << " Rout " << rout + << " ZHalf " << 0.5*layerL; + Volume cylinderIn = ns.addVolumeNS(Volume(name, solid, ns.material(genMat))); + cylinder.placeVolume(cylinderIn); + LogDebug("TIBGeom") << cylinderIn.name() + << " number 1 positioned in " << cylinder.name() + << " at (0,0,0) with no rotation"; + // + // Filler Rings + // + name = idName + "Filler"; + solid = ns.addSolidNS(name,Tube(rin, rout, fillerDz)); + LogDebug("TIBGeom") << solid.name() << " Tubs made of " + << fillerMat << " from " << 0. << " to " + << CLHEP::twopi/CLHEP::deg << " with Rin " << rin + << " Rout " << rout << " ZHalf " << fillerDz; + Volume cylinderFiller = ns.addVolumeNS(Volume(name,solid,ns.material(fillerMat))); + cylinderIn.placeVolume(cylinderFiller,Position(0.0, 0.0, 0.5*layerL-fillerDz)); // copyNr 1 + cylinderIn.placeVolume(cylinderFiller,Position(0.0, 0.0,-0.5*layerL+fillerDz)); // copyNr 2 + LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << cylinderFiller.name() + << " number 1" << " positioned in " + << cylinderIn.name() << " at " << Position(0.0, 0.0, 0.5*layerL-fillerDz) + << " number 2" << " positioned in " + << cylinderIn.name() << " at " << Position(0.0, 0.0,-0.5*layerL+fillerDz); + // + // Ribs + // + Material matrib = ns.material(ribMat); + for (int i = 0; i < (int)(ribW.size()); i++) { + name = idName + "Rib" + std::to_string(i); + double width = 2.*ribW[i]/(rin+rout); + double dz = 0.5*layerL-2.*fillerDz; + double _rmi = std::min(rin+0.5*CLHEP::mm,rout-0.5*CLHEP::mm); + double _rma = std::max(rin+0.5*CLHEP::mm,rout-0.5*CLHEP::mm); + solid = ns.addSolidNS(name,Tube(_rmi,_rma,dz,-0.5*width, width)); + LogDebug("TIBGeom") << solid.name() << " Tubs made of " + << ribMat << " from " << -0.5*width/CLHEP::deg <<" to " + << 0.5*width/CLHEP::deg << " with Rin " + << rin+0.5*CLHEP::mm << " Rout " + << rout-0.5*CLHEP::mm << " ZHalf " << dz; + Volume cylinderRib = ns.addVolumeNS(Volume(name, solid, matrib)); + double phix = ribPhi[i]; + double theta = 90*CLHEP::deg; + double phiy = phix + 90.*CLHEP::deg; + Rotation3D rotation = make_rotation3D(theta, phix, theta, phiy, 0., 0.); + Position tran(0, 0, 0); + cylinderIn.placeVolume(cylinderRib,Transform3D(rotation,tran));// copyNr=1 + LogDebug("TIBGeom") << cylinderRib.name() + << " number 1" << " positioned in " + << cylinderIn.name() << " at " << tran << " with " + << rotation; + } + + //Manifold rings + // + // Inner ones first + rin = MFRingInR; + rout = rin + MFRingT; + name = idName + "InnerMFRing"; + solid = ns.addSolidNS(name,Tube(rin, rout, MFRingDz)); + LogDebug("TIBGeom") << solid.name() << " Tubs made of " + << MFIntRingMat << " from 0 to " + << CLHEP::twopi/CLHEP::deg << " with Rin " << rin + << " Rout " << rout << " ZHalf " << MFRingDz; + Volume inmfr = ns.addVolumeNS(Volume(name, solid, ns.material(MFIntRingMat))); + layer.placeVolume(inmfr, Position(0.0, 0.0, -0.5*layerL+MFRingDz)); // Copy Nr=1 + layer.placeVolume(inmfr, Position(0.0, 0.0, +0.5*layerL+MFRingDz)); // Copy Nr=2 + LogDebug("TIBGeom") << inmfr.name() + << " number 1 and 2 positioned in " << layer.name() + << " at (0,0,+-" << 0.5*layerL-MFRingDz << ") with no rotation"; + + // Outer ones + rout = MFRingOutR; + rin = rout - MFRingT; + name = idName + "OuterMFRing"; + solid= ns.addSolidNS(name,Tube(rin, rout, MFRingDz)); + LogDebug("TIBGeom") << solid.name() << " Tubs made of " + << MFExtRingMat << " from 0 to " + << CLHEP::twopi/CLHEP::deg << " with Rin " << rin + << " Rout " << rout << " ZHalf " << MFRingDz; + + Volume outmfr = ns.addVolumeNS(Volume(name, solid, ns.material(MFExtRingMat))); + layer.placeVolume(outmfr,Position(0.0, 0.0, -0.5*layerL+MFRingDz)); // CopyNr=1 + layer.placeVolume(outmfr,Position(0.0, 0.0, +0.5*layerL+MFRingDz)); // CopyNr=2 + LogDebug("TIBGeom") << outmfr.name() + << " number 1 and 2 positioned in " << layer.name() + << " at (0,0,+-" << 0.5*layerL-MFRingDz + << ") with no rotation"; + + //Central Support rings + // + // Ring 1 + double centZ = centRing1par[0]; + double centDz = 0.5*centRing1par[1]; + rin = centRing1par[2]; + rout = centRing1par[3]; + name = idName + "CentRing1"; + solid = ns.addSolidNS(name,Tube(rin, rout, centDz)); + + LogDebug("TIBGeom") << solid.name() << " Tubs made of " + << centMat << " from 0 to " << CLHEP::twopi/CLHEP::deg + << " with Rin " << rin << " Rout " << rout + << " ZHalf " << centDz; + + Volume cent1 = ns.addVolumeNS(Volume(name, solid, ns.material(centMat))); + layer.placeVolume(cent1,Position(0.0, 0.0, centZ)); // Copy Nr = 1 + LogDebug("TIBGeom") << cent1.name() << " positioned in " << layer.name() + << " at (0,0," << centZ << ") with no rotation"; + // Ring 2 + centZ = centRing2par[0]; + centDz = 0.5*centRing2par[1]; + rin = centRing2par[2]; + rout = centRing2par[3]; + name = idName + "CentRing2"; + solid = ns.addSolidNS(name, Tube(rin, rout, centDz)); + LogDebug("TIBGeom") << solid.name() << " Tubs made of " + << centMat << " from 0 to " << CLHEP::twopi/CLHEP::deg + << " with Rin " << rin << " Rout " << rout + << " ZHalf " << centDz; + + Volume cent2 = ns.addVolumeNS(Volume(name, solid, ns.material(centMat))); + layer.placeVolume(cent2, Position(0e0,0e0,centZ)); // copyNr=1 + LogDebug("TIBGeom") << cent2.name() + << " positioned in " << layer.name() + << " at (0,0," << centZ << ") with no rotation"; + + ////// DOHM + // + // Preparing DOHM Carrier solid + + name = idName + "DOHMCarrier"; + double dohmCarrierRin = MFRingOutR - MFRingT; + double dohmCarrierRout = MFRingOutR; + double dohmCarrierDz = 0.5*(dohmPrimL+dohmtoMF); + double dohmCarrierZ = 0.5*layerL-2.*MFRingDz-dohmCarrierDz; + + solid = ns.addSolidNS(name,Tube(dohmCarrierRin, dohmCarrierRout, + dohmCarrierPhiOff, dohmCarrierDz, + 180.*CLHEP::deg-2.*dohmCarrierPhiOff)); + LogDebug("TIBGeom") << solid.name() << " Tubs made of " + << dohmCarrierMaterial << " from " + << dohmCarrierPhiOff << " to " + << 180.*CLHEP::deg-dohmCarrierPhiOff << " with Rin " + << dohmCarrierRin << " Rout " << MFRingOutR << " ZHalf " + << dohmCarrierDz; + + // Define FW and BW carrier logical volume and + // place DOHM Primary and auxiliary modules inside it + dphi = CLHEP::twopi/stringsUp; + + Rotation3D dohmRotation; + double dohmR = 0.5*(dohmCarrierRin+dohmCarrierRout); + + for (int j = 0; j<4; j++) { + vector<double> dohmList; + Position tran; + string rotstr; + Rotation3D rotation; + int dohmCarrierReplica=0; + int placeDohm = 0; + + switch (j){ + case 0: + name = idName + "DOHMCarrierFW"; + dohmList = dohmListFW; + tran = Position(0., 0., dohmCarrierZ); + rotstr = idName + "FwUp"; + rotation = Rotation3D(); + dohmCarrierReplica = 1; + placeDohm=1; + break; + case 1: + name = idName + "DOHMCarrierFW"; + dohmList = dohmListFW; + tran = Position(0., 0., dohmCarrierZ); + rotstr = idName + "FwDown"; + rotation = make_rotation3D(90.*CLHEP::deg, 180.*CLHEP::deg, 90.*CLHEP::deg,270.*CLHEP::deg, 0.,0.); + dohmCarrierReplica = 2; + placeDohm=0; + break; + case 2: + name = idName + "DOHMCarrierBW"; + dohmList = dohmListBW; + tran = Position(0., 0., -dohmCarrierZ); + rotstr = idName + "BwUp"; + rotation = make_rotation3D(90.*CLHEP::deg, 180.*CLHEP::deg, 90.*CLHEP::deg, 90.*CLHEP::deg, 180.*CLHEP::deg, 0.); + dohmCarrierReplica = 1; + placeDohm=1; + break; + case 3: + name = idName + "DOHMCarrierBW"; + dohmList = dohmListBW; + tran = Position(0., 0., -dohmCarrierZ); + rotstr = idName + "BwDown"; + rotation = make_rotation3D(90.*CLHEP::deg, 0., 90.*CLHEP::deg, 270.*CLHEP::deg, 180.*CLHEP::deg, 0.); + dohmCarrierReplica = 2; + placeDohm=0; + break; + } + + Volume dohmCarrier = ns.addVolumeNS(Volume(name,solid,ns.material(dohmCarrierMaterial))); + int primReplica = 0; + int auxReplica = 0; + + for (int i = 0; i < placeDohm*((int)(dohmList.size())); i++) { + double phi = (std::abs(dohmList[i])+0.5-1.)*dphi; + double phix = phi + 90*CLHEP::deg; + double theta = 90*CLHEP::deg; + double phiy = phix + 90.*CLHEP::deg; + dohmRotation = make_rotation3D(theta, phix, theta, phiy, 0., 0.); + + string dohmName; + int dohmReplica = 0; + double dohmZ = 0.; + Volume dohm; + + if(dohmList[i]<0.) { + // Place a Auxiliary DOHM + dohm = ns.volume(dohmAuxName); + dohmZ = dohmCarrierDz - 0.5*dohmAuxL - dohmtoMF; + primReplica++; + dohmReplica = primReplica; + + } else { + // Place a Primary DOHM + dohm = ns.volume(dohmPrimName); + dohmZ = dohmCarrierDz - 0.5*dohmPrimL - dohmtoMF; + auxReplica++; + dohmReplica = auxReplica; + } + + Position dohmTrasl(dohmR*cos(phi), dohmR*sin(phi), dohmZ); + dohmCarrier.placeVolume(dohm,Transform3D(dohmRotation,dohmTrasl)); + LogDebug("TIBGeom") << dohm.name() + << " replica " << dohmReplica << " positioned in " + << dohmCarrier.name() << " at " << dohmTrasl << " with " + << dohmRotation; + } + + layer.placeVolume(dohmCarrier, Transform3D(rotation,tran));// copyNr = dohmCarrierReplica + LogDebug("TIBGeom") << "DDTIBLayerAlgo test " + << dohmCarrier.name() << " positioned in " << mother + << " replica " << dohmCarrierReplica << " at " + << tran << " with " << rotation; + } - str << "Not implemented. To be done.... ";// << mother.name(); - printout(WARNING,"DDTIBLayerAlgo",str); + ////// PILLARS + for (int j = 0; j<4; j++) { + vector<double> pillarZ; + vector<double> pillarPhi; + double pillarDz=0, pillarDPhi=0, pillarRin=0, pillarRout=0; + + switch (j){ + case 0: + name = idName + "FWIntPillar"; + pillarZ = fwIntPillarZ; + pillarPhi = fwIntPillarPhi; + pillarRin = MFRingInR; + pillarRout = MFRingInR + MFRingT; + pillarDz = fwIntPillarDz; + pillarDPhi = fwIntPillarDPhi; + break; + case 1: + name = idName + "BWIntPillar"; + pillarZ = bwIntPillarZ; + pillarPhi = bwIntPillarPhi; + pillarRin = MFRingInR; + pillarRout = MFRingInR + MFRingT; + pillarDz = bwIntPillarDz; + pillarDPhi = bwIntPillarDPhi; + break; + case 2: + name = idName + "FWExtPillar"; + pillarZ = fwExtPillarZ; + pillarPhi = fwExtPillarPhi; + pillarRin = MFRingOutR - MFRingT; + pillarRout = MFRingOutR; + pillarDz = fwExtPillarDz; + pillarDPhi = fwExtPillarDPhi; + break; + case 3: + name = idName + "BWExtPillar"; + pillarZ = bwExtPillarZ; + pillarPhi = bwExtPillarPhi; + pillarRin = MFRingOutR - MFRingT; + pillarRout = MFRingOutR; + pillarDz = bwExtPillarDz; + pillarDPhi = bwExtPillarDPhi; + break; + } + + solid = ns.addSolidNS(name,Tube(pillarRin, pillarRout, pillarDz, -pillarDPhi, 2.*pillarDPhi)); + Volume Pillar = ns.addVolumeNS(Volume(name,solid,ns.material(pillarMaterial))); + LogDebug("TIBGeom") << solid.name() << " Tubs made of " << pillarMaterial << " from " + << -pillarDPhi << " to " << pillarDPhi << " with Rin " + << pillarRin << " Rout " << pillarRout << " ZHalf " + << pillarDz; + Position pillarTran; + Rotation3D pillarRota; + int pillarReplica = 0; + for (unsigned int i=0; i<pillarZ.size(); i++) { + if( pillarPhi[i]>0. ) { + pillarTran = Position(0., 0., pillarZ[i]); + pillarRota = make_rotation3D(90.*CLHEP::deg, pillarPhi[i], 90.*CLHEP::deg, 90.*CLHEP::deg+pillarPhi[i], 0., 0.); + layer.placeVolume(Pillar,Transform3D(pillarRota,pillarTran)); // copyNr i + LogDebug("TIBGeom") << Pillar.name() << " positioned in " + << mother << " at " + << pillarTran << " with " << pillarRota + << " copy number " << pillarReplica; + pillarReplica++; + } + } + } return 1; } // first argument is the type from the xml file -DECLARE_DDCMS_DETELEMENT(track_DDTIBLayerAlgo,algorithm) +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTIBLayerAlgo,algorithm) diff --git a/DDCMS/src/plugins/DDTIDModuleAlgo.cpp b/DDCMS/src/plugins/DDTIDModuleAlgo.cpp index a820afd62aeb2f2b4615e1236b45bbbb719a15b7..b762fe977a5021d2066f50400a76f89a2c9cc7d7 100644 --- a/DDCMS/src/plugins/DDTIDModuleAlgo.cpp +++ b/DDCMS/src/plugins/DDTIDModuleAlgo.cpp @@ -17,12 +17,8 @@ // Framework include files #include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/Printout.h" #include "DDCMS/DDCMSPlugins.h" -// C/C++ include files -#include <sstream> - using namespace std; using namespace dd4hep; using namespace dd4hep::cms; @@ -32,15 +28,441 @@ static long algorithm(Detector& /* description */, xml_h e, SensitiveDetector& /* sens */) { - stringstream str; Namespace ns(ctxt, e, true); AlgoArguments args(ctxt, e); - //Volume mother = ns.volume(args.parentName()); - - str << "Not implemented. To be done.... ";// << mother.name(); - printout(WARNING,"DDTIDModuleAlgo",str); + string mother = args.parentName(); + string genMat = args.str("GeneralMaterial"); //General material name + int detectorN = args.integer("DetectorNumber"); //Detector planes + double moduleThick = args.dble("ModuleThick"); //Module thickness + double detTilt = args.dble("DetTilt"); //Tilt of stereo detector + double fullHeight = args.dble("FullHeight"); //Height + double dlTop = args.dble("DlTop"); //Width at top of wafer + double dlBottom = args.dble("DlBottom"); //Width at bottom of wafer + double dlHybrid = args.dble("DlHybrid"); //Width at the hybrid end + bool doComponents = ::toupper(args.str("DoComponents")[0]) != 'N'; //Components to be made + + string boxFrameName = args.str("BoxFrameName"); //Top frame name + string boxFrameMat = args.str("BoxFrameMaterial"); // material + double boxFrameHeight = args.dble("BoxFrameHeight"); // height + double boxFrameThick = args.dble("BoxFrameThick"); // thickness + double boxFrameWidth = args.dble("BoxFrameWidth"); // extra width + double bottomFrameHeight = args.dble("BottomFrameHeight"); //Bottom of the frame + double bottomFrameOver = args.dble("BottomFrameOver"); // overlap + double topFrameHeight = args.dble("TopFrameHeight"); //Top of the frame + double topFrameOver = args.dble("TopFrameOver"); // overlap + vector<string> sideFrameName = args.vecStr("SideFrameName"); //Side frame name + string sideFrameMat = args.str("SideFrameMaterial"); // material + double sideFrameWidth = args.dble("SideFrameWidth"); // width + double sideFrameThick = args.dble("SideFrameThick"); // thickness + double sideFrameOver = args.dble("SideFrameOver"); // overlap (wrt wafer) + vector<string> holeFrameName = args.vecStr("HoleFrameName"); //Hole in the frame name + vector<string> holeFrameRot = args.vecStr("HoleFrameRotation"); // Rotation matrix + + vector<string> kaptonName = args.vecStr("KaptonName"); //Kapton circuit name + string kaptonMat = args.str("KaptonMaterial"); // material + double kaptonThick = args.dble("KaptonThick"); // thickness + double kaptonOver = args.dble("KaptonOver"); // overlap (wrt Wafer) + vector<string> holeKaptonName = args.vecStr("HoleKaptonName"); //Hole in the kapton circuit name + vector<string> holeKaptonRot = args.vecStr("HoleKaptonRotation"); // Rotation matrix + + vector<string> waferName = args.vecStr("WaferName"); //Wafer name + string waferMat = args.str("WaferMaterial"); // material + double sideWidthTop = args.dble("SideWidthTop"); // width on the side Top + double sideWidthBottom = args.dble("SideWidthBottom"); // Bottom + vector<string> activeName = args.vecStr("ActiveName"); //Sensitive name + string activeMat = args.str("ActiveMaterial"); // material + double activeHeight = args.dble("ActiveHeight"); // height + vector<double> waferThick = args.vecDble("WaferThick"); // wafer thickness (active = wafer - backplane) + string activeRot = args.str("ActiveRotation"); // Rotation matrix + vector<double> backplaneThick = args.vecDble("BackPlaneThick"); // thickness + string hybridName = args.str("HybridName"); //Hybrid name + string hybridMat = args.str("HybridMaterial"); // material + double hybridHeight = args.dble("HybridHeight"); // height + double hybridWidth = args.dble("HybridWidth"); // width + double hybridThick = args.dble("HybridThick"); // thickness + vector<string> pitchName = args.vecStr("PitchName"); //Pitch adapter name + string pitchMat = args.str("PitchMaterial"); // material + double pitchHeight = args.dble("PitchHeight"); // height + double pitchThick = args.dble("PitchThick"); // thickness + double pitchStereoTol = args.dble("PitchStereoTolerance"); // tolerance in dimensions of the stereo + string coolName = args.str("CoolInsertName"); // Cool insert name + string coolMat = args.str("CoolInsertMaterial"); // material + double coolHeight = args.dble("CoolInsertHeight"); // height + double coolThick = args.dble("CoolInsertThick"); // thickness + double coolWidth = args.dble("CoolInsertWidth"); // width + + LogDebug("TIDGeom") << "Parent " << mother + << " General Material " << genMat + << " Detector Planes " << detectorN; + + LogDebug("TIDGeom") << "ModuleThick " + << moduleThick << " Detector Tilt " << detTilt/CLHEP::deg + << " Height " << fullHeight << " dl(Top) " << dlTop + << " dl(Bottom) " << dlBottom << " dl(Hybrid) " + << dlHybrid << " doComponents " << doComponents; + LogDebug("TIDGeom") << "" << boxFrameName + << " Material " << boxFrameMat << " Thickness " + << boxFrameThick << " width " << boxFrameWidth + << " height " << boxFrameHeight + << " Extra Height at Bottom " << bottomFrameHeight + << " Overlap " << bottomFrameOver; + + for (int i = 0; i < detectorN; i++) + LogDebug("TIDGeom") << sideFrameName[i] + << " Material " << sideFrameMat << " Width " + << sideFrameWidth << " Thickness " << sideFrameThick + << " Overlap " << sideFrameOver << " Hole " + << holeFrameName[i]; + + for (int i = 0; i < detectorN; i++) + LogDebug("TIDGeom") << kaptonName[i] + << " Material " << kaptonMat + << " Thickness " << kaptonThick + << " Overlap " << kaptonOver << " Hole " + << holeKaptonName[i]; + + LogDebug("TIDGeom") << "Wafer Material " + << waferMat << " Side Width Top " << sideWidthTop + << " Side Width Bottom " << sideWidthBottom; + for (int i = 0; i < detectorN; i++) + LogDebug("TIDGeom") << "\twaferName[" << i << "] = " << waferName[i]; + + LogDebug("TIDGeom") << "Active Material " + << activeMat << " Height " << activeHeight + << " rotated by " << activeRot; + for (int i = 0; i < detectorN; i++) + LogDebug("TIDGeom") << " translated by (0," << -0.5*backplaneThick[i] + << ",0)\tactiveName[" << i << "] = " << activeName[i] + << " of thickness " << waferThick[i]-backplaneThick[i]; + + LogDebug("TIDGeom") << "" << hybridName + << " Material " << hybridMat << " Height " + << hybridHeight << " Width " << hybridWidth + << " Thickness " << hybridThick; + LogDebug("TIDGeom") << "Pitch Adapter Material " + << pitchMat << " Height " << pitchHeight + << " Thickness " << pitchThick; + for (int i = 0; i < detectorN; i++) + LogDebug("TIDGeom") << "\tpitchName[" << i << "] = " << pitchName[i]; + LogDebug("TIDGeom") << "Cool Element Material " + << coolMat << " Height " << coolHeight + << " Thickness " << coolThick << " Width " << coolWidth; + + string name = mother; + double sidfr = sideFrameWidth - sideFrameOver; // width of side frame on the sides of module + double botfr; // width of side frame at the the bottom of the modules + double topfr; // width of side frame at the the top of the modules + double kaptonHeight; + if (dlHybrid > dlTop) { + // ring 1, ring 2 + topfr = topFrameHeight - pitchHeight - topFrameOver; + botfr = bottomFrameHeight - bottomFrameOver; + kaptonHeight = fullHeight + botfr; + } else { + // ring 3 + topfr = topFrameHeight - topFrameOver; + botfr = bottomFrameHeight - bottomFrameOver - pitchHeight; + kaptonHeight = fullHeight + topfr; + } + + double sideFrameHeight = fullHeight + pitchHeight + botfr + topfr; + double kaptonWidth = sidfr + kaptonOver; + + double dxbot = 0.5*dlBottom + sidfr; + double dxtop = 0.5*dlTop + sidfr; + double dxtopenv, dxbotenv; // top/bot width of the module envelope trap + + // Envelope + if (dlHybrid > dlTop) { + // ring 1, ring 2 + dxtopenv = dxbot + (dxtop-dxbot)*(fullHeight+pitchHeight+topfr+hybridHeight)/fullHeight; + dxbotenv = dxtop - (dxtop-dxbot)*(fullHeight+botfr)/fullHeight; + } else { + // ring 3 + dxtopenv = dxbot + (dxtop-dxbot)*(fullHeight+topfr)/fullHeight; + dxbotenv = dxbot; + } + double bl1 = dxbotenv; + double bl2 = dxtopenv; + double h1 = 0.5 * moduleThick; + double dx, dy; + double dz = 0.5 * (boxFrameHeight + sideFrameHeight); + + Solid solid = ns.addSolidNS(name,Trap(dz, 0, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0)); + /* Volume module = */ ns.addVolumeNS(Volume(name, solid, ns.material(genMat))); + LogDebug("TIDGeom") << solid.name() + << " Trap made of " << genMat << " of dimensions " << dz + << ", 0, 0, " << h1 << ", " << bl1 << ", " << bl1 + << ", 0, " << h1 << ", " << bl2 << ", " << bl2 + << ", 0"; + + if (doComponents) { + + //Box frame + name = boxFrameName; + dx = 0.5 * boxFrameWidth; + dy = 0.5 * boxFrameThick; + dz = 0.5 * boxFrameHeight; + solid = ns.addSolidNS(name,Box(dx, dy, dz)); + LogDebug("TIDGeom") << solid.name() + << " Box made of " << boxFrameMat << " of dimensions " + << dx << ", " << dy << ", " << dz; + /* Volume boxFrame = */ ns.addVolumeNS(Volume(name, solid, ns.material(boxFrameMat))); + + + // Hybrid + name = hybridName; + dx = 0.5 * hybridWidth; + dy = 0.5 * hybridThick; + dz = 0.5 * hybridHeight; + solid = ns.addSolidNS(name,Box(dx, dy, dz)); + LogDebug("TIDGeom") << solid.name() + << " Box made of " << hybridMat << " of dimensions " + << dx << ", " << dy << ", " << dz; + /* Volume hybrid = */ ns.addVolumeNS(Volume(name, solid, ns.material(hybridMat))); + + // Cool Insert + name = coolName; + dx = 0.5 * coolWidth; + dy = 0.5 * coolThick; + dz = 0.5 * coolHeight; + solid = ns.addSolidNS(name,Box(dx, dy, dz)); + LogDebug("TIDGeom") << solid.name() + << " Box made of " << coolMat << " of dimensions " + << dx << ", " << dy << ", " << dz; + /* Volume cool = */ ns.addVolumeNS(Volume(name, solid, ns.material(coolMat))); + + // Loop over detectors to be placed + for (int k = 0; k < detectorN; k++) { + double bbl1, bbl2; // perhaps useless (bl1 enough) + // Frame Sides + name = sideFrameName[k]; + if (dlHybrid > dlTop) { + // ring 1, ring 2 + bbl1 = dxtop - (dxtop-dxbot)*(fullHeight+botfr)/fullHeight; + bbl2 = dxbot + (dxtop-dxbot)*(fullHeight+pitchHeight+topfr)/fullHeight; + } else { + // ring 3 + bbl1 = dxtop - (dxtop-dxbot)*(fullHeight+pitchHeight+botfr)/fullHeight; + bbl2 = dxbot + (dxtop-dxbot)*(fullHeight+topfr)/fullHeight; + } + h1 = 0.5 * sideFrameThick; + dz = 0.5 * sideFrameHeight; + solid = ns.addSolidNS(name,Trap(dz, 0., 0., h1, bbl1, bbl1, 0., h1, bbl2, bbl2, 0.)); + LogDebug("TIDGeom") << solid.name() + << " Trap made of " << sideFrameMat << " of dimensions " + << dz << ", 0, 0, " << h1 << ", " << bbl1 << ", " + << bbl1 << ", 0, " << h1 << ", " << bbl2 << ", " + << bbl2 << ", 0"; + Volume sideFrame = ns.addVolumeNS(Volume(name, solid, ns.material(sideFrameMat))); + + std::string rotstr, rotns; + Rotation3D rot; + + // Hole in the frame below the wafer + name = holeFrameName[k]; + double xpos, zpos; + dz = fullHeight - bottomFrameOver - topFrameOver; + bbl1 = dxbot - sideFrameWidth + bottomFrameOver*(dxtop-dxbot)/fullHeight; + bbl2 = dxtop - sideFrameWidth - topFrameOver*(dxtop-dxbot)/fullHeight; + if (dlHybrid > dlTop) { + // ring 1, ring 2 + zpos = -(topFrameHeight+0.5*dz-0.5*sideFrameHeight); + } else { + // ring 3 + zpos = bottomFrameHeight+0.5*dz-0.5*sideFrameHeight; + } + dz /= 2.; + solid = ns.addSolidNS(name,Trap(dz, 0,0, h1,bbl1,bbl1, 0, h1,bbl2,bbl2, 0)); + LogDebug("TIDGeom") << solid.name() + << " Trap made of " << genMat << " of dimensions " + << dz << ", 0, 0, " << h1 << ", " << bbl1 << ", " + << bbl1 << ", 0, " << h1 << ", " << bbl2 << ", " + << bbl2 << ", 0"; + Volume holeFrame = ns.addVolumeNS(Volume(name, solid, ns.material(genMat))); + + rot = ns.rotation(holeFrameRot[k]); + sideFrame.placeVolume(holeFrame,Transform3D(rot,Position(0e0,0e0,zpos)));// copyNr=1 + LogDebug("TIDGeom") << holeFrame.name() + << " number 1 positioned in " << sideFrame.name() + << " at (0,0," << zpos << ") with no rotation"; + + // Kapton circuit + double kaptonExtraHeight=0; // kapton extra height in the stereo + if (dlHybrid > dlTop) { + // ring 1, ring 2 + bbl1 = dxtop - (dxtop-dxbot)*(fullHeight+botfr)/fullHeight; + if ( k == 1 ) { + kaptonExtraHeight = dlTop*sin(detTilt)-fullHeight*(1-cos(detTilt)); + kaptonExtraHeight = 0.5*fabs(kaptonExtraHeight); + bbl2 = dxbot + (dxtop-dxbot)*(fullHeight+kaptonExtraHeight)/fullHeight; + } + else { + bbl2 = dxtop; + } + } else { + // ring 3 + bbl2 = dxbot + (dxtop-dxbot)*(fullHeight+topfr)/fullHeight; + if ( k == 1) { + kaptonExtraHeight = dlBottom*sin(detTilt)-fullHeight*(1-cos(detTilt)); + kaptonExtraHeight = 0.5*fabs(kaptonExtraHeight); + bbl1 = dxtop - (dxtop-dxbot)*(fullHeight+kaptonExtraHeight)/fullHeight; + } else { + bbl1 = dxbot; + } + } + h1 = 0.5 * kaptonThick; + dz = 0.5 * (kaptonHeight+kaptonExtraHeight); + + // For the stereo create the uncut solid, the solid to be removed and then the subtraction solid + if ( k == 1 ) { + // Uncut solid + Solid solidUncut = ns.addSolidNS(kaptonName[k]+"Uncut",Trap(dz, 0., 0., h1, bbl1, bbl1, 0., h1, bbl2, bbl2, 0)); + + // Piece to be cut + dz = (dlHybrid > dlTop) ? 0.5 * dlTop : 0.5 * dlBottom; + h1 = 0.5 * kaptonThick; + bbl1 = fabs(dz*sin(detTilt)); + bbl2 = bbl1*0.000001; + double thet = atan((bbl1-bbl2)/(2*dz)); + Solid solidCut = ns.addSolidNS(kaptonName[k]+"Cut",Trap(dz, thet, 0., h1, bbl1, bbl1, 0., h1, bbl2, bbl2, 0)); + + // Subtraction Solid + name = kaptonName[k]; + rot = ns.rotation("tidmodpar:9PYX"); + xpos = -0.5 * fullHeight * sin(detTilt); + zpos = 0.5 * kaptonHeight - bbl2; + solid = ns.addSolidNS(name,SubtractionSolid(solidUncut, solidCut, Transform3D(rot,Position(xpos,0.0,zpos)))); + } else { + name = kaptonName[k]; + solid = ns.addSolidNS(name,Trap(dz, 0., 0., h1, bbl1, bbl1, 0., h1, bbl2, bbl2, 0.)); + } + + Volume kapton = ns.addVolumeNS(Volume(name, solid, ns.material(kaptonMat))); + LogDebug("TIDGeom") << solid.name() + << " SUBTRACTION SOLID Trap made of " << kaptonMat + << " of dimensions " << dz << ", 0, 0, " << h1 + << ", " << bbl1 << ", " << bbl1 << ", 0, " << h1 + << ", " << bbl2 << ", " << bbl2 << ", 0"; + + // Hole in the kapton below the wafer + name = holeKaptonName[k]; + dz = fullHeight - kaptonOver; + xpos = 0; + if (dlHybrid > dlTop) { + // ring 1, ring 2 + bbl1 = dxbot - kaptonWidth + kaptonOver*(dxtop-dxbot)/fullHeight; + bbl2 = dxtop - kaptonWidth; + zpos = 0.5*(kaptonHeight-kaptonExtraHeight-dz); + if ( k == 1 ) { + zpos -= 0.5*kaptonOver*(1-cos(detTilt)); + xpos = -0.5*kaptonOver*sin(detTilt); + } + } else { + // ring 3 + bbl1 = dxbot - kaptonWidth; + bbl2 = dxtop - kaptonWidth - kaptonOver*(dxtop-dxbot)/fullHeight; + zpos = -0.5*(kaptonHeight-kaptonExtraHeight-dz); + } + dz /= 2.; + solid = ns.addSolidNS(name,Trap(dz,0.,0., h1,bbl1,bbl1, 0., h1,bbl2,bbl2, 0.)); + LogDebug("TIDGeom") << solid.name() + << " Trap made of " << genMat << " of dimensions " + << dz << ", 0, 0, " << h1 << ", " << bbl1 << ", " + << bbl1 << ", 0, " << h1 << ", " << bbl2 << ", " + << bbl2 << ", 0"; + Volume holeKapton = ns.addVolumeNS(Volume(name, solid, ns.material(genMat))); + + rot = ns.rotation(holeKaptonRot[k]); + kapton.placeVolume(holeKapton, Transform3D(rot,Position(xpos, 0.0, zpos))); + LogDebug("TIDGeom") << holeKapton.name() + << " number 1 positioned in " << kapton.name() + << " at (0,0," << zpos << ") with no rotation"; + + // Wafer + name = waferName[k]; + if (k == 0 && dlHybrid < dlTop) { + bl1 = 0.5 * dlTop; + bl2 = 0.5 * dlBottom; + } else { + bl1 = 0.5 * dlBottom; + bl2 = 0.5 * dlTop; + } + h1 = 0.5 * waferThick[k]; + dz = 0.5 * fullHeight; + solid = ns.addSolidNS(name,Trap(dz, 0,0, h1,bl1,bl1,0, h1,bl2,bl2,0)); + LogDebug("TIDGeom") << solid.name() + << " Trap made of " << waferMat << " of dimensions " + << dz << ", 0, 0, " << h1 << ", " << bl1 << ", " + << bl1 << ", 0, " << h1 << ", " << bl2 << ", " + << bl2 << ", 0"; + Volume wafer = ns.addVolumeNS(Volume(name, solid, ns.material(waferMat))); + + // Active + name = activeName[k]; + if (k == 0 && dlHybrid < dlTop) { + bl1 -= sideWidthTop; + bl2 -= sideWidthBottom; + } + else { + bl1 -= sideWidthBottom; + bl2 -= sideWidthTop; + } + dz = 0.5 * (waferThick[k] - backplaneThick[k]); // inactive backplane + h1 = 0.5 * activeHeight; + solid = ns.addSolidNS(name,Trap(dz, 0,0, h1,bl2,bl1,0, h1,bl2,bl1,0)); + LogDebug("TIDGeom") << solid.name() + << " Trap made of " << activeMat << " of dimensions " + << dz << ", 0, 0, " << h1 << ", " << bl2 << ", " + << bl1 << ", 0, " << h1 << ", " << bl2 << ", " + << bl1 << ", 0"; + Volume active = ns.addVolumeNS(Volume(name, solid, ns.material(activeMat))); + rot = ns.rotation(activeRot); + Position tran(0.0,-0.5 * backplaneThick[k],0.0); // from the definition of the wafer local axes + wafer.placeVolume(active, Transform3D(rot,tran)); // inactive backplane copyNr=1 + LogDebug("TIDGeom") << "DDTIDModuleAlgo test: " << active.name() + << " number 1 positioned in " << wafer.name() + << " at " << tran << " with " << rot; + + //Pitch Adapter + name = pitchName[k]; + if (dlHybrid > dlTop) { + dz = 0.5 * dlTop; + } else { + dz = 0.5 * dlBottom; + } + if (k == 0) { + dx = dz; + dy = 0.5 * pitchThick; + dz = 0.5 * pitchHeight; + solid = ns.addSolidNS(name,Box(dx, dy, dz)); + LogDebug("TIDGeom") << solid.name() + << " Box made of " << pitchMat << " of dimensions" + << " " << dx << ", " << dy << ", " << dz; + } else { + h1 = 0.5 * pitchThick; + bl1 = 0.5 * pitchHeight + 0.5 * dz * sin(detTilt); + bl2 = 0.5 * pitchHeight - 0.5 * dz * sin(detTilt); + + dz -=0.5*pitchStereoTol; + bl1-=pitchStereoTol; + bl2-=pitchStereoTol; + + double thet = atan((bl1-bl2)/(2.*dz)); + solid = ns.addSolidNS(name,Trap(dz, thet, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0)); + LogDebug("TIDGeom") << solid.name() + << " Trap made of " << pitchMat << " of " + << "dimensions " << dz << ", " << thet/CLHEP::deg + << ", 0, " << h1 << ", " << bl1 << ", " << bl1 + << ", 0, " << h1 << ", " << bl2 << ", " << bl2 + << ", 0"; + } + /* Volume pa = */ ns.addVolumeNS(Volume(name, solid, ns.material(pitchMat))); + } + } + LogDebug("TIDGeom") << "<<== End of DDTIDModuleAlgo construction ..."; return 1; } // first argument is the type from the xml file -DECLARE_DDCMS_DETELEMENT(track_DDTIDModuleAlgo,algorithm) +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTIDModuleAlgo,algorithm) diff --git a/DDCMS/src/plugins/DDTIDModulePosAlgo.cpp b/DDCMS/src/plugins/DDTIDModulePosAlgo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d9e1bfdbdaa3e39cb4910e2eb9181cb16327906e --- /dev/null +++ b/DDCMS/src/plugins/DDTIDModulePosAlgo.cpp @@ -0,0 +1,356 @@ +//========================================================================== +// 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 +// +//========================================================================== +// +// Specialized generic detector constructor +// +//========================================================================== + +// Framework include files +#include "DD4hep/DetFactoryHelper.h" +#include "DDCMS/DDCMSPlugins.h" + +using namespace std; +using namespace dd4hep; +using namespace dd4hep::cms; + +static long algorithm(Detector& /* description */, + ParsingContext& ctxt, + xml_h e, + SensitiveDetector& /* sens */) +{ + Namespace ns(ctxt, e, true); + AlgoArguments args(ctxt, e); + string parentName = args.parentName(); + int detectorN = args.integer("DetectorNumber"); //Number of detectors + double detTilt = args.dble("DetTilt"); //Tilt of stereo detector + double fullHeight = args.dble("FullHeight"); //Height + string boxFrameName = args.str("BoxFrameName"); //Top frame Name + double boxFrameHeight = args.dble("BoxFrameHeight"); // height + double boxFrameWidth = args.dble("BoxFrameWidth"); // width + double dlTop = args.dble("DlTop"); //Width at top of wafer + double dlBottom = args.dble("DlBottom"); //Width at bottom of wafer + double dlHybrid = args.dble("DlHybrid"); //Width at the hybrid end + vector<double> boxFrameZ = args.vecDble("BoxFrameZ"); // z-positions + double bottomFrameHeight = args.dble("BottomFrameHeight"); //Bottom of the frame + double bottomFrameOver = args.dble("BottomFrameOver"); // overlap + double topFrameHeight = args.dble("TopFrameHeight"); //Top of the frame + double topFrameOver = args.dble("TopFrameOver"); // overlap + + vector<string> sideFrameName = args.vecStr("SideFrameName"); //Side Frame name + vector<double> sideFrameZ = args.vecDble("SideFrameZ"); // z-positions + vector<string> sideFrameRot = args.vecStr("SideFrameRotation"); // rotation matrix (required for correct positiong of the hole in the StereoR) + double sideFrameWidth = args.dble("SideFrameWidth"); // width + double sideFrameOver = args.dble("SideFrameOver"); // overlap (wrt wafer) + + vector<string> kaptonName = args.vecStr("KaptonName"); //Kapton Circuit name + vector<double> kaptonZ = args.vecDble("KaptonZ"); // z-positions + vector<string> kaptonRot = args.vecStr("KaptonRotation"); // rotation matrix (required for correct positiong of the hole in the StereoR) + vector<string> waferName = args.vecStr("WaferName"); //Wafer name + vector<double> waferZ = args.vecDble("WaferZ"); // z-positions + vector<string> waferRot = args.vecStr("WaferRotation"); // rotation matrix + string hybridName = args.str("HybridName"); //Hybrid name + double hybridHeight = args.dble("HybridHeight"); // height + vector<double> hybridZ = args.vecDble("HybridZ"); // z-positions + vector<string> pitchName = args.vecStr("PitchName"); //Pitch adapter rotation matrix + double pitchHeight = args.dble("PitchHeight"); // height + vector<double> pitchZ = args.vecDble("PitchZ"); // z-positions + vector<string> pitchRot = args.vecStr("PitchRotation"); // rotation matrix + string coolName = args.str("CoolInsertName"); //Cool Insert name + double coolHeight = args.dble("CoolInsertHeight"); // height + double coolZ = args.dble("CoolInsertZ"); // z-position + double coolWidth = args.dble("CoolInsertWidth"); // width + vector<double> coolRadShift = args.vecDble("CoolInsertShift"); // + + + bool doSpacers = ::toupper(args.str("DoSpacers")[0])!='N'; //Spacers (alumina) to be made (Should be "Yes" for DS modules only) + string botSpacersName = args.str("BottomSpacersName"); // Spacers at the "bottom" of the module + double botSpacersHeight = args.dble("BottomSpacersHeight"); // + double botSpacersZ = args.dble("BottomSpacersZ"); // z-position + string sidSpacersName = args.str("SideSpacersName"); //Spacers at the "sides" of the module + double sidSpacersHeight = args.dble("SideSpacersHeight"); + double sidSpacersZ = args.dble("SideSpacersZ"); // z-position + double sidSpacersWidth = args.dble("SideSpacersWidth"); // width + double sidSpacersRadShift = args.dble("SideSpacersShift"); // + + LogDebug("TIDGeom") << "Parent " << parentName + << " Detector Planes " << detectorN; + LogDebug("TIDGeom") << "Detector Tilt " + << detTilt/CLHEP::deg << " Height " << fullHeight + << " dl(Top) " << dlTop << " dl(Bottom) " << dlBottom + << " dl(Hybrid) " << dlHybrid; + LogDebug("TIDGeom") << boxFrameName << " positioned at Z"; + for (int i = 0; i < detectorN; i++) + LogDebug("TIDGeom") << "\tboxFrameZ[" << i << "] = " << boxFrameZ[i]; + LogDebug("TIDGeom") << "\t Extra Height at Bottom " << bottomFrameHeight + << " Overlap " <<bottomFrameOver; + for (int i = 0; i < detectorN; i++) + LogDebug("TIDGeom") << "\tsideFrame[" << i << "] = " << sideFrameName[i] + << " positioned at Z "<< sideFrameZ[i] + << " with rotation " << sideFrameRot[i]; + for (int i = 0; i < detectorN; i++) + LogDebug("TIDGeom") << "\tkapton[" << i << "] = " << kaptonName[i] + << " positioned at Z "<< kaptonZ[i] + << " with rotation " << kaptonRot[i]; + for (int i = 0; i < detectorN; i++) + LogDebug("TIDGeom") << waferName[i] + << " positioned at Z " << waferZ[i] + << " with rotation " << waferRot[i]; + LogDebug("TIDGeom") << hybridName + << " Height " << hybridHeight << " Z"; + for (int i = 0; i < detectorN; i++) + LogDebug("TIDGeom") << "\thybridZ[" << i <<"] = " << hybridZ[i]; + LogDebug("TIDGeom") << "Pitch Adapter Height " << pitchHeight; + for (int i = 0; i < detectorN; i++) + LogDebug("TIDGeom") << pitchName[i] << " position at Z " << pitchZ[i] + << " with rotation " << pitchRot[i]; + + string name; + double botfr; // width of side frame at the the bottom of the modules + double topfr; // width of side frame at the the top of the modules + double kaptonHeight; + if (dlHybrid > dlTop) { + // ring 1, ring 2 + topfr = topFrameHeight - pitchHeight - topFrameOver; + botfr = bottomFrameHeight - bottomFrameOver; + kaptonHeight = fullHeight + botfr; + } else { + // ring 3 + topfr = topFrameHeight - topFrameOver; + botfr = bottomFrameHeight - bottomFrameOver - pitchHeight; + kaptonHeight = fullHeight + topfr; + } + + double sideFrameHeight = fullHeight + pitchHeight + botfr + topfr; + double zCenter = 0.5 * (sideFrameHeight+boxFrameHeight); + + // (Re) Compute the envelope for positioning Cool Inserts and Side Spacers (Alumina). + double sidfr = sideFrameWidth - sideFrameOver; // width of side frame on the sides of module + double dxbot = 0.5*dlBottom + sidfr; + double dxtop = 0.5*dlTop + sidfr; + double dxtopenv, dxbotenv; // top/bot width of the module envelope trap + + double tanWafer=(dxtop-dxbot)/fullHeight; // + double thetaWafer = atan(tanWafer); // 1/2 of the wafer wedge angle + + if (dlHybrid > dlTop) { + // ring 1, ring 2 + dxtopenv = dxbot + (dxtop-dxbot)*(fullHeight+pitchHeight+topfr+hybridHeight)/fullHeight; + dxbotenv = dxtop - (dxtop-dxbot)*(fullHeight+botfr)/fullHeight; + } else { + // ring 3 + dxtopenv = dxbot + (dxtop-dxbot)*(fullHeight+topfr)/fullHeight; + dxbotenv = dxbot; + } + + double tanEnv=(dxtopenv-dxbotenv)/(sideFrameHeight+boxFrameHeight); // 1/2 of the envelope wedge angle + + double xpos=0; double ypos=0; double zpos=0; + + // Cool Inserts + name = coolName; + ypos = coolZ; + + double zCool; + int copy=0; + Rotation3D rot; // should be different for different elements + Volume parentVol = ns.volume(parentName); + + for (int j1=0; j1<2; j1++){ // j1: 0 inserts below the hybrid + // 1 inserts below the wafer + if (dlHybrid > dlTop) { + zCool = sideFrameHeight+boxFrameHeight-coolRadShift[j1]; + if ( j1==0 ) zCool -= 0.5*coolHeight; + } else { + zCool = coolRadShift[j1]; + if ( j1==0 ) zCool += 0.5*coolHeight; + } + + if ( j1==0 ) { + xpos = -0.5*(boxFrameWidth-coolWidth); + } else { + xpos = -(dxbotenv+(zCool-0.5*coolHeight)*tanEnv-0.5*coolWidth); + } + + zpos = zCool-zCenter; + for ( int j2=0; j2<2; j2++) { + copy++; + parentVol.placeVolume(ns.volume(name),Position(xpos,ypos,zpos)); + LogDebug("TIDGeom") << name <<" number " + << copy << " positioned in " << parentName << " at " + << Position(xpos,ypos,zpos) << " with " << rot; + xpos = -xpos; + } + } + + if ( doSpacers ) { + // Bottom Spacers (Alumina) + name = botSpacersName; + ypos = botSpacersZ; + double zBotSpacers; + if (dlHybrid > dlTop) { + zBotSpacers = sideFrameHeight+boxFrameHeight-0.5*botSpacersHeight; + } else { + zBotSpacers = 0.5*botSpacersHeight; + } + zpos = zBotSpacers - zCenter; + parentVol.placeVolume(ns.volume(name),Position(0.0,ypos,zpos)); + LogDebug("TIDGeom") << name <<" number " + << 1 << " positioned in " << parentName << " at " + << Position(0.0,ypos,zpos) << " with no rotation"; + // Side Spacers (Alumina) + name = sidSpacersName; + ypos = sidSpacersZ; + double zSideSpacers; + if (dlHybrid > dlTop) { + zSideSpacers = sideFrameHeight+boxFrameHeight-sidSpacersRadShift; + } else { + zSideSpacers = sidSpacersRadShift; + } + zpos = zSideSpacers - zCenter; + + copy=0; + xpos = dxbotenv+(zSideSpacers-0.5*sidSpacersHeight)*tanEnv-0.5*sidSpacersWidth+sideFrameOver; + + double phiy = 0e0, phiz = 0e0; + double phix=0.*CLHEP::deg; phiy=90.*CLHEP::deg; phiz=0.*CLHEP::deg; + + double thetax = 0e0; + double thetay = 90.*CLHEP::deg; + double thetaz = thetaWafer; + + for (int j1=0; j1<2; j1++){ + copy++; + // tilt Side Spacers (parallel to Side Frame) + thetax = 90.*CLHEP::deg+thetaz; + rot = make_rotation3D(thetax, phix, thetay, phiy, thetaz, phiz); + parentVol.placeVolume(ns.volume(name),Transform3D(rot,Position(xpos,ypos,zpos))); + LogDebug("TIDGeom") << name <<" number " << copy << " positioned in " << parentName << " at " + << Position(xpos,ypos,zpos) << " with " << rot; + xpos = -xpos; + thetaz = -thetaz; + } + } + + // Loop over detectors to be placed + for (int k = 0; k < detectorN; k++) { + // Wafer + name = waferName[k]; + xpos=0; + ypos = waferZ[k]; + double zWafer; + if (dlHybrid > dlTop) { + zWafer = botfr+0.5*fullHeight; + } else { + zWafer = boxFrameHeight+botfr+pitchHeight+0.5*fullHeight; + } + zpos = zWafer - zCenter; + Position tran(xpos, ypos, zpos); + rot = ns.rotation(waferRot[k]); + + parentVol.placeVolume(ns.volume(name),Transform3D(rot,tran)); // copyNr=k+1 + LogDebug("TIDGeom") << name <<" number " << k+1 << " positioned in " << parentName << " at " + << tran << " with " << rot; + + //Pitch Adapter + name = pitchName[k]; + if (k == 0) { + xpos = 0; + } else { + xpos = 0.5 * fullHeight * sin(detTilt); + } + ypos = pitchZ[k]; + double zPitch; + if (dlHybrid > dlTop) { + zPitch = botfr+fullHeight+0.5*pitchHeight; + } else { + zPitch = boxFrameHeight+botfr+0.5*pitchHeight; + } + zpos = zPitch - zCenter; + rot = ns.rotation(pitchRot[k]); + tran = Position(xpos,ypos,zpos); + parentVol.placeVolume(ns.volume(name),Transform3D(rot,tran)); // copyNr=k+1 + LogDebug("TIDGeom") << name <<" number " << k+1 << " positioned in " << parentName << " at " + << tran << " with " << rot; + + // Hybrid + name = hybridName; + ypos = hybridZ[k]; + double zHybrid; + if (dlHybrid > dlTop) { + zHybrid = botfr+fullHeight+pitchHeight+0.5*hybridHeight; + } else { + zHybrid = 0.5*hybridHeight; + } + zpos = zHybrid - zCenter; + tran = Position(0,ypos,zpos); + parentVol.placeVolume(ns.volume(name),tran); // copyNr=k+1 + LogDebug("TIDGeom") << name <<" number " << k+1 << " positioned in " << parentName << " at " << tran; + + // Box frame + name = boxFrameName; + ypos = boxFrameZ[k]; + double zBoxFrame; + if (dlHybrid > dlTop) { + zBoxFrame = sideFrameHeight+0.5*boxFrameHeight; + } else { + zBoxFrame = 0.5*boxFrameHeight; + } + zpos = zBoxFrame - zCenter; + tran = Position(0,ypos,zpos); + parentVol.placeVolume(ns.volume(name),tran); // copyNr=k+1 + LogDebug("TIDGeom") << name <<" number " << k+1 << " positioned in " << parentName << " at " << tran; + + // Side frame + name = sideFrameName[k]; + ypos = sideFrameZ[k]; + double zSideFrame; + if (dlHybrid > dlTop) { + zSideFrame = 0.5*sideFrameHeight; + } else { + zSideFrame = boxFrameHeight+0.5*sideFrameHeight; + } + zpos = zSideFrame-zCenter; + rot = ns.rotation(sideFrameRot[k]); + tran = Position(0,ypos,zpos); + parentVol.placeVolume(ns.volume(name),Transform3D(rot,tran)); + LogDebug("TIDGeom") << name <<" number " + << k+1 << " positioned in " << parentName << " at " + << tran << " with " << rot; + // Kapton circuit + name = kaptonName[k]; + ypos = kaptonZ[k]; + double zKapton; + double kaptonExtraHeight=0; + if (dlHybrid > dlTop) { + if ( k == 1 ) kaptonExtraHeight = dlTop*sin(detTilt)-fullHeight*(1-cos(detTilt)); + kaptonExtraHeight = 0.5*fabs(kaptonExtraHeight); + zKapton = 0.5*(kaptonHeight+kaptonExtraHeight); + } else { + if ( k == 1 ) kaptonExtraHeight = dlBottom*sin(detTilt)-fullHeight*(1-cos(detTilt)); + kaptonExtraHeight = 0.5*fabs(kaptonExtraHeight); + zKapton = boxFrameHeight+sideFrameHeight-0.5*(kaptonHeight+kaptonExtraHeight); + } + zpos = zKapton-zCenter; + rot = ns.rotation(kaptonRot[k]); + tran = Position(0,ypos,zpos); + parentVol.placeVolume(ns.volume(name),Transform3D(rot,tran)); + LogDebug("TIDGeom") << name <<" number " + << k+1 << " positioned in " << parentName << " at " + << tran << " with " << rot; + } + LogDebug("TIDGeom") << "<<== End of DDTIDModulePosAlgo positioning ..."; + return 1; +} + +// first argument is the type from the xml file +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTIDModulePosAlgo,algorithm) diff --git a/DDCMS/src/plugins/DDTIDRingAlgo.cpp b/DDCMS/src/plugins/DDTIDRingAlgo.cpp index 3437688a8d76b965f898afc49fc592b57c8818a3..d646bd04d558bd93443c2872b57bb0660bd7189d 100644 --- a/DDCMS/src/plugins/DDTIDRingAlgo.cpp +++ b/DDCMS/src/plugins/DDTIDRingAlgo.cpp @@ -17,12 +17,8 @@ // Framework include files #include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/Printout.h" #include "DDCMS/DDCMSPlugins.h" -// C/C++ include files -#include <sstream> - using namespace std; using namespace dd4hep; using namespace dd4hep::cms; @@ -32,7 +28,6 @@ static long algorithm(Detector& /* description */, xml_h e, SensitiveDetector& /* sens */) { - stringstream str; Namespace ns(ctxt, e, true); AlgoArguments args(ctxt, e); Volume mother = ns.volume(args.parentName()); @@ -46,20 +41,16 @@ static long algorithm(Detector& /* description */, double sICC = args.value<double>("ICCShift"); //Shift of ICC per to R vector<double> zICC = args.value<vector<double> >("ICCZ"); // in Z - str << "Parent " << mother.name() - << "\tModule " << moduleName[0] << ", " - << moduleName[1] << "\tICC " << iccName - << "\tNameSpace " << ns.name; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTIDRingAlgo",str); - - str << "Parameters for positioning--" - << " StartAngle " << startAngle/CLHEP::deg - << " Copy Numbers " << number << " Modules at R " - << rModule << " Z " << zModule[0] << ", " << zModule[1] - << " ICCs at R " << rICC << " Z " << zICC[0] << ", " - << zICC[1]; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTIDRingAlgo",str); - + LogDebug("TIDGeom") << "Parent " << mother.name() + << "\tModule " << moduleName[0] << ", " + << moduleName[1] << "\tICC " << iccName + << "\tNameSpace " << ns.name; + LogDebug("TIDGeom") << "Parameters for positioning--" + << " StartAngle " << startAngle/CLHEP::deg + << " Copy Numbers " << number << " Modules at R " + << rModule << " Z " << zModule[0] << ", " << zModule[1] + << " ICCs at R " << rICC << " Z " << zICC[0] << ", " + << zICC[1]; double theta = 90.*CLHEP::deg; double phiy = 0.*CLHEP::deg; double dphi = CLHEP::twopi/number; @@ -95,11 +86,9 @@ static long algorithm(Detector& /* description */, Rotation3D rotation = make_rotation3D(theta, phix, thetay, phiy, theta, phiz); // int copyNr = i+1; /* PlacedVolume pv = */ mother.placeVolume(module, Transform3D(rotation,trmod)); - str << module.name() << " number " - << i+1 << " positioned in " << mother.name() << " at " - << trmod << " with " << rotation; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTIDRingAlgo",str); - + LogDebug("TIDGeom") << module.name() << " number " + << i+1 << " positioned in " << mother.name() << " at " + << trmod << " with " << rotation; //Now the ICC if (i%2 == 0 ) { zpos = zICC[0]; @@ -113,13 +102,12 @@ static long algorithm(Detector& /* description */, // int copyNr = i+1; Position tricc(xpos, ypos, zpos); /* PlacedVolume pv = */ mother.placeVolume(icc, Transform3D(rotation,tricc)); - str << iccName << " number " - << i+1 << " positioned in " << mother.name() << " at " - << tricc << " with " << rotation; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTIDRingAlgo",str); + LogDebug("TIDGeom") << iccName << " number " + << i+1 << " positioned in " << mother.name() << " at " + << tricc << " with " << rotation; } return 1; } // first argument is the type from the xml file -DECLARE_DDCMS_DETELEMENT(track_DDTIDRingAlgo___DISABLED,algorithm) +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTIDRingAlgo,algorithm) diff --git a/DDCMS/src/plugins/DDTOBAxCableAlgo.cpp b/DDCMS/src/plugins/DDTOBAxCableAlgo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ed8042acb0794a799004e12615c86eba16a103e8 --- /dev/null +++ b/DDCMS/src/plugins/DDTOBAxCableAlgo.cpp @@ -0,0 +1,139 @@ +//========================================================================== +// 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 +// +//========================================================================== +// +// Specialized generic detector constructor +// +//========================================================================== + +// Framework include files +#include "DD4hep/DetFactoryHelper.h" +#include "DDCMS/DDCMSPlugins.h" + +using namespace std; +using namespace dd4hep; +using namespace dd4hep::cms; + +static long algorithm(Detector& /* description */, + ParsingContext& ctxt, + xml_h e, + SensitiveDetector& /* sens */) +{ + Namespace ns(ctxt, e, true); + AlgoArguments args(ctxt, e); + vector<string> sectorNumber = args.vecStr("SectorNumber"); // Id. Number of the sectors + double sectorRin = args.dble("SectorRin"); // Inner radius of service sectors + double sectorRout = args.dble("SectorRout"); // Outer radius of service sectors + double sectorDz = args.dble("SectorDz"); // Sector half-length + double sectorDeltaPhi_B = args.dble("SectorDeltaPhi_B"); // Sector B phi width [A=C=0.5*(360/sectors)] + vector<double> sectorStartPhi = args.vecDble("SectorStartPhi"); // Starting phi for the service sectors + vector<string> sectorMaterial_A = args.vecStr("SectorMaterial_A"); // Material for the A sectors + vector<string> sectorMaterial_B = args.vecStr("SectorMaterial_B"); // Material for the B sectors + vector<string> sectorMaterial_C = args.vecStr("SectorMaterial_C"); // Material for the C sectors + + + for (int i=0; i<(int)(sectorNumber.size()); i++) + LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: sectorNumber[" << i + << "] = " << sectorNumber[i]; + + LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Axial Service Sectors half-length " << sectorDz + << "\tRin " << sectorRin << "\tRout = " << sectorRout + << "\tPhi of sectors position:"; + for (int i=0; i<(int)(sectorNumber.size()); i++) + LogDebug("TOBGeom") << "\t[" << i << "]\tPhi = " << sectorStartPhi[i]; + LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: List of materials for the sectors/3 parts"; + // + LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 A"; + for (int i=0; i<(int)(sectorNumber.size()); i++) + LogDebug("TOBGeom") << "\t[" << i << "]\tsectorMaterial_A = " << sectorMaterial_A[i]; + // + LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 B"; + for (int i=0; i<(int)(sectorNumber.size()); i++) + LogDebug("TOBGeom") << "\t[" << i << "]\tsectorMaterial_B = " << sectorMaterial_B[i]; + // + LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 C"; + for (int i=0; i<(int)(sectorNumber.size()); i++) + LogDebug("TOBGeom") << "\t[" << i << "]\tsectorMaterial_C = " << sectorMaterial_C[i]; + + string tubsName = args.parentName(); + Volume tubsVol = ns.volume(tubsName); + // Loop over sectors (sectorNumber vector) + for (int i=0; i<(int)(sectorNumber.size()); i++) { + Solid solid; + string name; + double dz, rin, rout, startphi, widthphi, deltaphi; + + // Axial Services + // Each sector is divided in 3 parts from phi[i] to phi[i+1] + + widthphi = ( (i+1 == (int)(sectorStartPhi.size())) ? + (sectorStartPhi[0]+CLHEP::twopi)-sectorStartPhi[i] : + (sectorStartPhi[i+1]-sectorStartPhi[i]) ); + // First Part: A + name = "TOBAxService_" + sectorNumber[i] + "A"; + dz = sectorDz; + rin = sectorRin; + rout = sectorRout; + startphi = sectorStartPhi[i]; + deltaphi = 0.5 * (widthphi - sectorDeltaPhi_B); + solid = ns.addSolid(name,Tube(rin, rout, dz, startphi, deltaphi)); + LogDebug("TOBGeom") << solid.name() << " Tubs made of " + << sectorMaterial_A[i] << " from " + << startphi/CLHEP::deg << " to " + << (startphi+deltaphi)/CLHEP::deg << " with Rin " + << rin << " Rout " << rout << " ZHalf " << dz; + Volume sectorLogic = ns.addVolume(Volume(name,solid, ns.material(sectorMaterial_A[i]))); + tubsVol.placeVolume(sectorLogic); // copyNr: i+1 + LogDebug("TOBGeom") << sectorLogic.name() << " number " << i+1 + << " positioned in " << tubsName + << " with no translation and no rotation"; + + // Second Part: B + name = "TOBAxService_" + sectorNumber[i] + "B"; + startphi += deltaphi; + deltaphi = sectorDeltaPhi_B; + solid = ns.addSolid(name, Tube(rin, rout, dz, startphi, deltaphi)); + LogDebug("TOBGeom") << solid.name() << " Tubs made of " + << sectorMaterial_B[i] << " from " << startphi/CLHEP::deg + << " to " << (startphi+deltaphi)/CLHEP::deg + << " with Rin " << rin << " Rout " << rout + << " ZHalf " << dz; + + sectorLogic = ns.addVolume(Volume(name, solid, ns.material(sectorMaterial_B[i]))); + tubsVol.placeVolume(sectorLogic); // copyNr: i+1 + LogDebug("TOBGeom") << sectorLogic.name() << " number " << i+1 + << " positioned in " << tubsName + << " with no translation and no rotation"; + + // Third Part: C + name = "TOBAxService_" + sectorNumber[i] + "C"; + startphi += deltaphi; + deltaphi = 0.5 * (widthphi - sectorDeltaPhi_B); + solid = ns.addSolid(name,Tube(rin, rout, dz, startphi, deltaphi)); + LogDebug("TOBGeom") << solid.name() << " Tubs made of " + << sectorMaterial_C[i] << " from " + << startphi/CLHEP::deg << " to " + << (startphi+deltaphi)/CLHEP::deg << " with Rin " + << rin << " Rout " << rout << " ZHalf " << dz; + sectorLogic = ns.addVolume(Volume(name, solid, ns.material(sectorMaterial_C[i]))); + tubsVol.placeVolume(sectorLogic); // copyNr: i+1 + LogDebug("TOBGeom") << sectorLogic.name() << " number " << i+1 + << " positioned in " << tubsName + << " with no translation and no rotation"; + } + LogDebug("TOBGeom") << "<<== End of DDTOBAxCableAlgo construction ..."; + return 1; +} + +// first argument is the type from the xml file +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTOBAxCableAlgo,algorithm) + diff --git a/DDCMS/src/plugins/DDTOBRadCableAlgo.cpp b/DDCMS/src/plugins/DDTOBRadCableAlgo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..96ed78ab947b62c107c5900dc9da73da8b914c16 --- /dev/null +++ b/DDCMS/src/plugins/DDTOBRadCableAlgo.cpp @@ -0,0 +1,209 @@ +//========================================================================== +// 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 +// +//========================================================================== +// +// Specialized generic detector constructor +// +//========================================================================== + +// Framework include files +#include "DD4hep/DetFactoryHelper.h" +#include "DDCMS/DDCMSPlugins.h" + +using namespace std; +using namespace dd4hep; +using namespace dd4hep::cms; + +static long algorithm(Detector& /* description */, + ParsingContext& ctxt, + xml_h e, + SensitiveDetector& /* sens */) +{ + Namespace ns(ctxt, e, true); + AlgoArguments args(ctxt, e); + double diskDz = args.dble("DiskDz"); // Disk thickness + double rMax = args.dble("RMax"); // Maximum radius + double cableT = args.dble("CableT"); // Cable thickness + vector<double> rodRin = args.vecDble("RodRin"); // Radii for inner rods + vector<double> rodRout = args.vecDble("RodRout"); // Radii for outer rods + vector<string> cableM = args.vecStr("CableMaterial"); // Materials for cables + double connW = args.dble("ConnW"); // Connector width + double connT = args.dble("ConnT"); // Connector thickness + vector<string> connM = args.vecStr("ConnMaterial"); // Materials for connectors + vector<double> coolR1 = args.vecDble("CoolR1"); // Radii for cooling manifold + vector<double> coolR2 = args.vecDble("CoolR2"); // Radii for return cooling manifold + double coolRin = args.dble("CoolRin"); // Inner radius of cooling manifold + double coolRout1 = args.dble("CoolRout1"); // Outer radius of cooling manifold + double coolRout2 = args.dble("CoolRout2"); // Outer radius of cooling fluid in cooling manifold + double coolStartPhi1 = args.dble("CoolStartPhi1"); // Starting Phi of cooling manifold + double coolDeltaPhi1 = args.dble("CoolDeltaPhi1"); // Phi Range of cooling manifold + double coolStartPhi2 = args.dble("CoolStartPhi2"); // Starting Phi of cooling fluid in of cooling manifold + double coolDeltaPhi2 = args.dble("CoolDeltaPhi2"); // Phi Range of of cooling fluid in cooling manifold + string coolM1 = args.str("CoolMaterial1"); // Material for cooling manifold + string coolM2 = args.str("CoolMaterial2"); // Material for cooling fluid + vector<string> names = args.vecStr("RingName"); // Names of layers + + string parentName = args.parentName(); + LogDebug("TOBGeom") << "DDTOBRadCableAlgo debug: Parent " << parentName << " NameSpace " << ns.name; + LogDebug("TOBGeom") << "DDTOBRadCableAlgo debug: Disk Half width " << diskDz + << "\tRMax " << rMax << "\tCable Thickness " << cableT + << "\tRadii of disk position and cable materials:"; + for (int i=0; i<(int)(rodRin.size()); i++) + LogDebug("TOBGeom") << "\t[" << i << "]\tRin = " << rodRin[i] + << "\tRout = " << rodRout[i] << " " << cableM[i]; + LogDebug("TOBGeom") << "DDTOBRadCableAlgo debug: Connector Width = " + << connW << "\tThickness = " << connT + << "\tMaterials: "; + for (int i=0; i<(int)(connM.size()); i++) + LogDebug("TOBGeom") << "\tconnM[" << i << "] = " << connM[i]; + LogDebug("TOBGeom") << "DDTOBRadCableAlgo debug: Cool Manifold Torus Rin = " << coolRin + << " Rout = " << coolRout1 + << "\t Phi start = " << coolStartPhi1 << " Phi Range = " << coolDeltaPhi1 + << "\t Material = " << coolM1 + << "\t Radial positions:"; + for (int i=0; i<(int)(coolR1.size()); i++) + LogDebug("TOBGeom") << "\t[" << i <<"]\tR = " << coolR1[i]; + for (int i=0; i<(int)(coolR2.size()); i++) + LogDebug("TOBGeom") << "\t[" << i <<"]\tR = " << coolR2[i]; + LogDebug("TOBGeom") << "DDTOBRadCableAlgo debug: Cooling Fluid Torus Rin = " << coolRin + << " Rout = " << coolRout2 + << "\t Phi start = " << coolStartPhi2 << " Phi Range = " << coolDeltaPhi2 + << "\t Material = " << coolM2 + << "\t Radial positions:"; + for (int i=0; i<(int)(coolR1.size()); i++) + LogDebug("TOBGeom") << "\t[" << i <<"]\tR = " << coolR1[i]; + for (int i=0; i<(int)(coolR2.size()); i++) + LogDebug("TOBGeom") << "\t[" << i <<"]\tR = " << coolR2[i]; + for (int i=0; i<(int)(names.size()); i++) + LogDebug("TOBGeom") << "DDTOBRadCableAlgo debug: names[" << i << "] = " << names[i]; + + Volume disk = ns.volume(parentName); + // Loop over sub disks + for (int i=0; i<(int)(names.size()); i++) { + Solid solid; + string name; + double dz, rin, rout; + + // Cooling Manifolds + name = "TOBCoolingManifold" + names[i] + "a"; + dz = coolRout1; + solid = ns.addSolid(name,Torus(coolRin,coolRout1,coolR1[i],coolStartPhi1,coolDeltaPhi1)); + LogDebug("TOBGeom") << name << " Torus made of " + << coolM1 << " from " << coolStartPhi1/CLHEP::deg + << " to " << (coolStartPhi1+coolDeltaPhi1)/CLHEP::deg + << " with Rin " << coolRin << " Rout " << coolRout1 + << " R torus " << coolR1[i]; + Volume coolManifoldLogic_a = ns.addVolume(Volume(name,solid,ns.material(coolM1))); + Position r1(0, 0, (dz-diskDz)); + disk.placeVolume(coolManifoldLogic_a,r1); // i+1 + LogDebug("TOBGeom") << name << " number " << i+1 + << " positioned in " << disk.name() << " at " << r1 + << " with no rotation"; + + // Cooling Fluid (in Cooling Manifold) + name = "TOBCoolingManifoldFluid" + names[i] + "a"; + solid = ns.addSolid(name,Torus(coolRin,coolRout2,coolR1[i],coolStartPhi2,coolDeltaPhi2)); + LogDebug("TOBGeom") << name << " Torus made of " + << coolM2 << " from " << coolStartPhi2/CLHEP::deg + << " to " << (coolStartPhi2+coolDeltaPhi2)/CLHEP::deg + << " with Rin " << coolRin << " Rout " << coolRout2 + << " R torus " << coolR1[i]; + Volume coolManifoldFluidLogic_a = ns.addVolume(Volume(name,solid,ns.material(coolM2))); + disk.placeVolume(coolManifoldFluidLogic_a); // i+1 + LogDebug("TOBGeom") << name << " number " << i+1 + << " positioned in " << coolM2 + << " with no translation and no rotation"; + + name = "TOBCoolingManifold" + names[i] + "r"; + dz = coolRout1; + solid = ns.addSolid(name,Torus(coolRin,coolRout1,coolR2[i],coolStartPhi1,coolDeltaPhi1)); + LogDebug("TOBGeom") << name << " Torus made of " + << coolM1 << " from " << coolStartPhi1/CLHEP::deg + << " to " << (coolStartPhi1+coolDeltaPhi1)/CLHEP::deg + << " with Rin " << coolRin << " Rout " << coolRout1 + << " R torus " << coolR2[i]; + Volume coolManifoldLogic_r = ns.addVolume(Volume(name,solid,ns.material(coolM1))); + r1 = Position(0, 0, (dz-diskDz)); + disk.placeVolume(coolManifoldLogic_r, r1); // i+1 + LogDebug("TOBGeom") << name << " number " << i+1 + << " positioned in " << disk.name() << " at " << r1 + << " with no rotation"; + + // Cooling Fluid (in Cooling Manifold) + name = "TOBCoolingManifoldFluid" + names[i] + "r"; + solid = ns.addSolid(name,Torus(coolRin,coolRout2,coolR2[i],coolStartPhi2,coolDeltaPhi2)); + LogDebug("TOBGeom") << name << " Torus made of " + << coolM2 << " from " << coolStartPhi2/CLHEP::deg + << " to " << (coolStartPhi2+coolDeltaPhi2)/CLHEP::deg + << " with Rin " << coolRin << " Rout " << coolRout2 + << " R torus " << coolR2[i]; + Volume coolManifoldFluidLogic_r = ns.addVolume(Volume(name, solid, ns.material(coolM2))); + disk.placeVolume(coolManifoldFluidLogic_r); // i+1 + LogDebug("TOBGeom") << name << " number " << i+1 + << " positioned in " << coolM2 + << " with no translation and no rotation"; + + // Connectors + name = "TOBConn" + names[i]; + dz = 0.5*connT; + rin = 0.5*(rodRin[i]+rodRout[i])-0.5*connW; + rout = 0.5*(rodRin[i]+rodRout[i])+0.5*connW; + solid = ns.addSolid(name,Tube(rin, rout, dz)); + LogDebug("TOBGeom") << name << " Tubs made of " + << connM[i] << " from 0 to " << CLHEP::twopi/CLHEP::deg + << " with Rin " << rin << " Rout " << rout + << " ZHalf " << dz; + Volume connLogic = ns.addVolume(Volume(name, solid, ns.material(connM[i]))); + Position r2(0, 0, (dz-diskDz)); + disk.placeVolume(connLogic,r2); // i+1 + LogDebug("TOBGeom") << name << " number " << i+1 + << " positioned in " << disk.name() << " at " << r2 + << " with no rotation"; + + // Now the radial cable + name = "TOBRadServices" + names[i]; + rin = 0.5*(rodRin[i]+rodRout[i]); + rout = ( i+1 == (int)(names.size()) ? rMax : 0.5*(rodRin[i+1]+rodRout[i+1])); + vector<double> pgonZ; + pgonZ.emplace_back(-0.5*cableT); + pgonZ.emplace_back(cableT*(rin/rMax-0.5)); + pgonZ.emplace_back(0.5*cableT); + vector<double> pgonRmin; + pgonRmin.emplace_back(rin); + pgonRmin.emplace_back(rin); + pgonRmin.emplace_back(rin); + vector<double> pgonRmax; + pgonRmax.emplace_back(rout); + pgonRmax.emplace_back(rout); + pgonRmax.emplace_back(rout); + solid = ns.addSolid(name,Polycone(0, CLHEP::twopi, pgonRmin, pgonRmax, pgonZ)); + LogDebug("TOBGeom") << name <<" Polycone made of " + << cableM[i] << " from 0 to " + << CLHEP::twopi/CLHEP::deg << " and with " + << pgonZ.size() << " sections"; + for (int ii = 0; ii < (int)(pgonZ.size()); ii++) + LogDebug("TOBGeom") << "\t[" << ii << "]\tZ = " << pgonZ[ii] + << "\tRmin = " << pgonRmin[ii] << "\tRmax = " << pgonRmax[ii]; + Volume cableLogic = ns.addVolume(Volume(name, solid, ns.material(cableM[i]))); + Position r3(0, 0, (diskDz-(i+0.5)*cableT)); + disk.placeVolume(cableLogic, r3); // i+1 + LogDebug("TOBGeom") << name << " number " <<i+1 + << " positioned in " << disk.name() << " at " << r3 + << " with no rotation"; + } + LogDebug("TOBGeom") << "<<== End of DDTOBRadCableAlgo construction ..."; + return 1; +} + +// first argument is the type from the xml file +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTOBRadCableAlgo,algorithm) + diff --git a/DDCMS/src/plugins/DDTOBRodAlgo.cpp b/DDCMS/src/plugins/DDTOBRodAlgo.cpp index 94642942e79fe51a47ce224b10e9f484c0a05f7e..50d52780f87e2c82b8e374ce23c1c84e53b78245 100644 --- a/DDCMS/src/plugins/DDTOBRodAlgo.cpp +++ b/DDCMS/src/plugins/DDTOBRodAlgo.cpp @@ -17,12 +17,8 @@ // Framework include files #include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/Printout.h" #include "DDCMS/DDCMSPlugins.h" -// C/C++ include files -#include <sstream> - using namespace std; using namespace dd4hep; using namespace dd4hep::cms; @@ -32,15 +28,282 @@ static long algorithm(Detector& /* description */, xml_h e, SensitiveDetector& /* sens */) { - stringstream str; Namespace ns(ctxt, e, true); AlgoArguments args(ctxt, e); - Volume mother = ns.volume(args.parentName()); + string parentName = args.parentName(); + string central = args.str("CentralName"); // Name of the central piece + + double shift = args.dble("Shift"); // Shift in z + vector<string> sideRod = args.vecStr("SideRodName"); // Name of the Side Rod + vector<double> sideRodX = args.vecDble("SideRodX"); // x-positions + vector<double> sideRodY = args.vecDble("SideRodY"); // y-positions + vector<double> sideRodZ = args.vecDble("SideRodZ"); // z-positions + string endRod1 = args.str("EndRod1Name"); // Name of the End Rod of type 1 + vector<double> endRod1Y = args.vecDble("EndRod1Y"); // y-positions + vector<double> endRod1Z = args.vecDble("EndRod1Z"); // z-positions + string endRod2 = args.str("EndRod2Name"); // Name of the End Rod of type 2 + double endRod2Y = args.dble("EndRod2Y"); // y-position + double endRod2Z = args.dble("EndRod2Z"); // z-position + + string cable = args.str("CableName"); // Name of the Mother cable + double cableZ = args.dble("CableZ"); // z-position + + string clamp = args.str("ClampName"); // Name of the clamp + vector<double> clampX = args.vecDble("ClampX"); // x-positions + vector<double> clampZ = args.vecDble("ClampZ"); // z-positions + string sideCool = args.str("SideCoolName"); // Name of the Side Cooling Tube + vector<double> sideCoolX = args.vecDble("SideCoolX"); // x-positions + vector<double> sideCoolY = args.vecDble("SideCoolY"); // y-positions to avoid overlap with the module (be at the same level of EndCool) + vector<double> sideCoolZ = args.vecDble("SideCoolZ"); // z-positions + string endCool = args.str("EndCoolName"); // Name of the End Cooling Tube + string endCoolRot = args.str("EndCoolRot"); // Rotation matrix name for end cool + double endCoolY = args.dble("EndCoolY"); // y-position to avoid overlap with the module + double endCoolZ = args.dble("EndCoolZ"); // z-position + + string optFibre = args.str("OptFibreName"); // Name of the Optical Fibre + vector<double> optFibreX = args.vecDble("optFibreX"); // x-positions + vector<double> optFibreZ = args.vecDble("optFibreZ"); // z-positions + + string sideClamp1 = args.str("SideClamp1Name"); // Name of the side clamp of type 1 + vector<double> sideClampX = args.vecDble("SideClampX"); // x-positions + vector<double> sideClamp1DZ = args.vecDble("SideClamp1DZ"); // Delta(z)-positions + string sideClamp2 = args.str("SideClamp2Name"); // Name of the side clamp of type 2 + vector<double> sideClamp2DZ = args.vecDble("SideClamp2DZ"); // Delta(z)-positions + + string module = args.str("ModuleName"); // Name of the detector modules + vector<string> moduleRot = args.vecStr("ModuleRot"); // Rotation matrix name for module + vector<double> moduleY = args.vecDble("ModuleY"); // y-positions + vector<double> moduleZ = args.vecDble("ModuleZ"); // z-positions + vector<string> connect = args.vecStr("ICCName");; // Name of the connectors + vector<double> connectY = args.vecDble("ICCY"); // y-positions + vector<double> connectZ = args.vecDble("ICCZ"); // z-positions + + string aohName = args.str("AOHName"); // AOH name + vector<double> aohCopies = args.vecDble("AOHCopies"); // AOH copies to be positioned on each ICC + vector<double> aohX = args.vecDble("AOHx"); // AOH translation with respect small-ICC center (X) + vector<double> aohY = args.vecDble("AOHy"); // AOH translation with respect small-ICC center (Y) + vector<double> aohZ = args.vecDble("AOHz"); // AOH translation with respect small-ICC center (Z) + + LogDebug("TOBGeom") << "Parent " << parentName << " Central " << central << " NameSpace " + << ns.name << "\tShift " << shift; + for (int i=0; i<(int)(sideRod.size()); i++) { + LogDebug("TOBGeom") << sideRod[i] << " to be positioned " << sideRodX.size() + <<" times at y = " << sideRodY[i] << " z = " << sideRodZ[i] << " and x"; + for (double j : sideRodX) + LogDebug("TOBGeom") << "\tsideRodX[" << i << "] = " << j; + } + LogDebug("TOBGeom") << endRod1 << " to be " + << "positioned " << endRod1Y.size() << " times at"; + for (int i=0; i<(int)(endRod1Y.size()); i++) + LogDebug("TOBGeom") << "\t[" << i << "]\ty = " << endRod1Y[i] + << "\tz = " << endRod1Z[i]; + LogDebug("TOBGeom") << endRod2 << " to be " + << "positioned at y = " << endRod2Y << " z = " + << endRod2Z; + LogDebug("TOBGeom") << cable << " to be " + << "positioned at z = " << cableZ; + LogDebug("TOBGeom") << clamp << " to be " + << "positioned " << clampX.size() << " times at"; + for (int i=0; i<(int)(clampX.size()); i++) + LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << clampX[i] << "\tz = " + << clampZ[i]; + LogDebug("TOBGeom") << sideCool << " to be " + << "positioned " << sideCoolX.size() << " times at"; + for (int i=0; i<(int)(sideCoolX.size()); i++) + LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << sideCoolX[i] + << "\ty = " << sideCoolY[i] + << "\tz = " << sideCoolZ[i]; + LogDebug("TOBGeom") << endCool <<" to be " + << "positioned with " << endCoolRot << " rotation at" + << " y = " << endCoolY + << " z = " << endCoolZ; + LogDebug("TOBGeom") << optFibre << " to be " + << "positioned " << optFibreX.size() << " times at"; + for (int i=0; i<(int)(optFibreX.size()); i++) + LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << optFibreX[i] + << "\tz = " << optFibreZ[i]; + LogDebug("TOBGeom") << sideClamp1 << " to be " + << "positioned " << sideClampX.size() << " times at"; + for (int i=0; i<(int)(sideClampX.size()); i++) + LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << sideClampX[i] + << "\tdz = " << sideClamp1DZ[i]; + LogDebug("TOBGeom") << sideClamp2 << " to be " + << "positioned " << sideClampX.size() << " times at"; + for (int i=0; i<(int)(sideClampX.size()); i++) + LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << sideClampX[i] + << "\tdz = " << sideClamp2DZ[i]; + LogDebug("TOBGeom") << "DDTOBRodAlgo debug:\t" << module <<" positioned " + << moduleRot.size() << " times"; + for (int i=0; i<(int)(moduleRot.size()); i++) + LogDebug("TOBGeom") << "\tRotation " << moduleRot[i] << "\ty = " + << moduleY[i] << "\tz = " << moduleZ[i]; + LogDebug("TOBGeom") << "DDTOBRodAlgo debug:\t" << connect.size() + << " ICC positioned with no rotation"; + for (int i=0; i<(int)(connect.size()); i++) + LogDebug("TOBGeom") << "\t" << connect[i] << "\ty = " << connectY[i] + << "\tz = " << connectZ[i]; + LogDebug("TOBGeom") << "DDTOBRodAlgo debug:\t" << aohName <<" AOH will be positioned on ICC's"; + for (int i=0; i<(int)(aohCopies.size()); i++) + LogDebug("TOBGeom") << " copies " << aohCopies[i] << "\tx = " << aohX[i] + << "\ty = " << aohY[i] << "\tz = " << aohZ[i]; + + string centName = central; + string child; + string rodName = parentName; + Volume rod = ns.volume(rodName); + + // Side Rods + for (int i=0; i<(int)(sideRod.size()); i++) { + for (int j=0; j<(int)(sideRodX.size()); j++) { + Position r(sideRodX[j], sideRodY[i], sideRodZ[i]); + child = sideRod[i]; + rod.placeVolume(ns.volume(child), /* j+1, */ r); + LogDebug("TOBGeom") << child << " number " << j+1 << " positioned in " + << rodName << " at " << r << " with no rotation"; + } + } + // Clamps + for (int i=0; i<(int)(clampX.size()); i++) { + Position r(clampX[i], 0, shift+clampZ[i]); + child = clamp; + rod.placeVolume(ns.volume(child), /* i+1, */ r); + LogDebug("TOBGeom") << child << " number " << i+1 << " positioned in " + << rodName << " at " << r << " with no rotation"; + } + // Side Cooling tubes + for (int i=0; i<(int)(sideCoolX.size()); i++) { + Position r(sideCoolX[i], sideCoolY[i], shift+sideCoolZ[i]); + child = sideCool; + rod.placeVolume(ns.volume(child), /* i+1, */ r); + LogDebug("TOBGeom") << child << " number " << i+1 << " positioned in " + << rodName << " at " << r << " with no rotation"; + } + // Optical Fibres + for (int i=0; i<(int)(optFibreX.size()); i++) { + Position r(optFibreX[i], 0, shift+optFibreZ[i]); + child = optFibre; + rod.placeVolume(ns.volume(child), /* i+1, */ r); + LogDebug("TOBGeom") << child << " number " << i+1 << " positioned in " + << rodName << " at " << r << " with no rotation"; + } + + // Side Clamps + for (int i=0; i<(int)(sideClamp1DZ.size()); i++) { + int j = i/2; + Position r(sideClampX[i],moduleY[j],shift+moduleZ[j]+sideClamp1DZ[i]); + child = sideClamp1; + rod.placeVolume(ns.volume(child), /* i+1, */ r); + LogDebug("TOBGeom") << child << " number " << i+1 << " positioned in " << rodName << " at " + << r << " with no rotation"; + } + for (int i=0; i<(int)(sideClamp2DZ.size()); i++) { + int j = i/2; + Position r(sideClampX[i],moduleY[j],shift+moduleZ[j]+sideClamp2DZ[i]); + child = sideClamp2; + rod.placeVolume(ns.volume(child), /* i+1, */ r); + LogDebug("TOBGeom") << child << " number " << i+1 << " positioned in " << rodName << " at " + << r << " with no rotation"; + } + + Volume cent = ns.volume(centName); + // End Rods + for (int i=0; i<(int)(endRod1Y.size()); i++) { + Position r(0, endRod1Y[i], shift+endRod1Z[i]); + child = endRod1; + cent.placeVolume(ns.volume(child), /* i+1, */ r); + LogDebug("TOBGeom") << child << " number " << i+1 << " positioned in " << centName << " at " + << r << " with no rotation"; + } + Position r1(0, endRod2Y, shift+endRod2Z); + child = endRod2; + cent.placeVolume(ns.volume(child), /* 1, */ r1); + LogDebug("TOBGeom") << child << " number 1 " << "positioned in " << centName << " at " << r1 + << " with no rotation"; + + // End cooling tubes + Position r2(0, endCoolY, shift+endCoolZ); + Rotation3D rot2 = ns.rotation(endCoolRot); + child = endCool; + cent.placeVolume(ns.volume(child), /* 1, */ Transform3D(rot2,r2)); + LogDebug("TOBGeom") << child << " number 1 " << "positioned in " << centName << " at " << r2 + << " with " << rot2; + + //Mother cable + Position r3(0, 0, shift+cableZ); + child = cable; + cent.placeVolume(ns.volume(child), /* 1, */ r3); + LogDebug("TOBGeom") << child << " number 1 " << "positioned in " << centName << " at " << r3 + << " with no rotation"; + + //Modules + for (int i=0; i<(int)(moduleRot.size()); i++) { + Position r(0, moduleY[i], shift+moduleZ[i]); + Rotation3D rot = ns.rotation(moduleRot[i]); + child = module; + cent.placeVolume(ns.volume(child), /* i+1, */ Transform3D(rot,r)); + LogDebug("TOBGeom") << child << " number " + << i+1 << " positioned in " << centName << " at " + << r << " with " << rot; + } + + //Connectors (ICC, CCUM, ...) + for (int i=0; i<(int)(connect.size()); i++) { + Position r(0, connectY[i], shift+connectZ[i]); + child = connect[i]; + cent.placeVolume(ns.volume(child), /* i+1, */ r); + LogDebug("TOBGeom") << child << " number " << i+1 << " positioned in " << centName << " at " + << r << " with no rotation"; + } - str << "Not implemented. To be done.... " << mother.name(); - printout(WARNING,"DDTOBRodAlgo",str); + //AOH (only on ICCs) + int copyNumber = 0; + for (int i=0; i<(int)(aohCopies.size()); i++) { + if(aohCopies[i] != 0) { + // first copy with (+aohX,+aohZ) translation + copyNumber++; + Position r(aohX[i] + 0, aohY[i] + connectY[i], aohZ[i] + shift+connectZ[i]); + child = aohName; + cent.placeVolume(ns.volume(child), r); // copyNumber + LogDebug("TOBGeom") << child << " number " << copyNumber << " positioned in " << centName << " at " + << r << " with no rotation"; + // if two copies add a copy with (-aohX,-aohZ) translation + if(aohCopies[i] == 2) { + copyNumber++; + r = Position(-aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift+connectZ[i]); + child = aohName; + cent.placeVolume(ns.volume(child), r); // copyNumber + LogDebug("TOBGeom") << child << " number " << copyNumber << " positioned in " << centName << " at " + << r << " with no rotation"; + } + // if four copies add 3 copies with (-aohX,+aohZ) (-aohX,-aohZ) (+aohX,+aohZ) and translations + if(aohCopies[i] == 4) { + Position rr; + for (unsigned int j = 1; j<4; j++ ) { + copyNumber++; + child = aohName; + switch(j) { + case 1: + rr = Position(-aohX[i] + 0, aohY[i] + connectY[i], +aohZ[i] + shift+connectZ[i]); + cent.placeVolume(ns.volume(child), rr); // copyNumber + break; + case 2: + rr = Position(-aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift+connectZ[i]); + cent.placeVolume(ns.volume(child), rr); // copyNumber + break; + case 3: + rr = Position(+aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift+connectZ[i]); + cent.placeVolume(ns.volume(child), rr); // copyNumber + break; + } + LogDebug("TOBGeom") << child << " number " << copyNumber << " positioned in " << centName << " at " + << rr << " with no rotation"; + } + } + } + } + LogDebug("TOBGeom") << "<<== End of DDTOBRodAlgo construction ..."; return 1; } // first argument is the type from the xml file -DECLARE_DDCMS_DETELEMENT(track_DDTOBRodAlgo,algorithm) +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTOBRodAlgo,algorithm) diff --git a/DDCMS/src/plugins/DDTrackerAngular.cpp b/DDCMS/src/plugins/DDTrackerAngular.cpp index bf6e48c6151450ee78bf4c05dff96abd878e1a4b..7611265dca02e9dca0bbb6d8b64b3b4589c5055d 100644 --- a/DDCMS/src/plugins/DDTrackerAngular.cpp +++ b/DDCMS/src/plugins/DDTrackerAngular.cpp @@ -17,12 +17,8 @@ // Framework include files #include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/Printout.h" #include "DDCMS/DDCMSPlugins.h" -// C/C++ include files -#include <sstream> - using namespace std; using namespace dd4hep; using namespace dd4hep::cms; @@ -32,7 +28,6 @@ static long algorithm(Detector& /* description */, xml_h e, SensitiveDetector& /* sens */) { - stringstream str; Namespace ns(ctxt,e,true); AlgoArguments args(ctxt, e); // Header section of original DDTrackerAngular.h @@ -43,33 +38,26 @@ static long algorithm(Detector& /* description */, double startAngle = args.value<double>("StartAngle"); //Start anle double radius = args.value<double>("Radius"); //Radius vector<double> center = args.value<vector<double> >("Center"); //Phi values - double delta; //Increment in phi Volume mother = ns.volume(args.parentName()); Volume child = ns.volume(args.value<string>("ChildName")); + double delta = 0e0; //Increment in phi // Code section of original DDTrackerAngular.cc if (fabs(rangeAngle-360.0*CLHEP::deg)<0.001*CLHEP::deg) { delta = rangeAngle/double(n); - } else { - if (n > 1) { - delta = rangeAngle/double(n-1); - } else { - delta = 0.; - } + } else if (n > 1) { + delta = rangeAngle/double(n-1); } - str << "debug: Parameters for positioning:: n " + LogDebug("TrackerGeom") << "debug: Parameters for positioning:: n " << n << " Start, Range, Delta " << startAngle/CLHEP::deg << " " << rangeAngle/CLHEP::deg << " " << delta/CLHEP::deg << " Radius " << radius << " Centre " << center[0] << ", " << center[1] << ", "<<center[2]; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerAngular",str); - - str << "debug: Parent " << mother.name() + LogDebug("TrackerGeom") << "debug: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace " << ns.name; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerAngular",str); double theta = 90.*CLHEP::deg; int copy = startCopyNo; @@ -87,11 +75,10 @@ static long algorithm(Detector& /* description */, rotation = ns.rotation(ns.prepend(rotstr)); } else { - str << "Creating a new " + LogDebug("TrackerGeom") << "Creating a new " << "rotation: " << rotstr << "\t90., " << phix/CLHEP::deg << ", 90.," << phiy/CLHEP::deg <<", 0, 0"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerAngular",str); RotationZYX rot; rotation = make_rotation3D(theta, phix, theta, phiy, 0., 0.); } @@ -102,10 +89,9 @@ static long algorithm(Detector& /* description */, double zpos = center[2]; Position tran(xpos, ypos, zpos); mother.placeVolume(child, Transform3D(rotation,tran)); - str << "test " << child.name() << " number " - << copy << " positioned in " << mother.name() << " at " - << tran << " with " << rotation; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerAngular",str); + LogDebug("TrackerGeom") << "test " << child.name() << " number " + << copy << " positioned in " << mother.name() << " at " + << tran << " with " << rotation; copy += incrCopyNo; phi += delta; } @@ -113,4 +99,4 @@ static long algorithm(Detector& /* description */, } // first argument is the type from the xml file -DECLARE_DDCMS_DETELEMENT(track_DDTrackerAngular,algorithm) +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerAngular,algorithm) diff --git a/DDCMS/src/plugins/DDTrackerLinear.cpp b/DDCMS/src/plugins/DDTrackerLinear.cpp index 92b5cef54d4a18884393c3fcaf4a54961c7b3185..2d95337847ac8452498c82fd764eb1956d9a003c 100644 --- a/DDCMS/src/plugins/DDTrackerLinear.cpp +++ b/DDCMS/src/plugins/DDTrackerLinear.cpp @@ -17,23 +17,17 @@ // Framework include files #include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/Printout.h" #include "DDCMS/DDCMSPlugins.h" -// C/C++ include files -#include <sstream> - using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; using namespace dd4hep::cms; -static long create_element(Detector& /* description */, - ParsingContext& ctxt, - xml_h e, - SensitiveDetector& /* sens */) +static long algorithm(Detector& /* description */, + ParsingContext& ctxt, + xml_h e, + SensitiveDetector& /* sens */) { - stringstream str; Namespace ns(ctxt, e, true); AlgoArguments args(ctxt, e); int startcn = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1; @@ -48,8 +42,8 @@ static long create_element(Detector& /* description */, Volume mother = ns.volume(args.parentName()); Volume child = ns.volume(args.value<string>("ChildName")); - printout(INFO,"DDTrackerLinear","+++ Executing Algorithm. rParent:%s",mother.name()); - str << "debug: Parent " << mother.name() + LogDebug("TrackerGeom") << "+++ Executing Algorithm. rParent:" << mother.name(); + LogDebug("TrackerGeom") << "debug: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace " << ns.name << "\tNumber " << number << "\tAxis (theta/phi) " << theta/dd4hep::deg << ", " @@ -57,7 +51,6 @@ static long create_element(Detector& /* description */, << ", " << delta << "\tCentre " << centre[0] << ", " << centre[1] << ", " << centre[2] << "\tRotation " << rotMat; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerLinear",str); Position direction(sin(theta)*cos(phi),sin(theta)*sin(phi),cos(theta)); Position base(centre[0],centre[1],centre[2]); @@ -71,14 +64,13 @@ static long create_element(Detector& /* description */, /* PlacedVolume pv = */ rotMat.empty() ? mother.placeVolume(child,Transform3D(rot,tran)) : mother.placeVolume(child,tran); - str << child.name() << " number " - << ci << " positioned in " << mother.name() << " at " - << tran << " with " << rot; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerLinear",str); + LogDebug("TrackerGeom") << child.name() << " number " + << ci << " positioned in " << mother.name() << " at " + << tran << " with " << rot; } return 1; } // first argument is the type from the xml file -DECLARE_DDCMS_DETELEMENT(track_DDTrackerLinear,create_element) +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerLinear,algorithm) diff --git a/DDCMS/src/plugins/DDTrackerPhiAlgo.cpp b/DDCMS/src/plugins/DDTrackerPhiAlgo.cpp index 9e231d4e085d0367b86ec36c2fa9a8c587ff1bb0..29119f4d387fdb762e10a3e17f27aecc8e15d865 100644 --- a/DDCMS/src/plugins/DDTrackerPhiAlgo.cpp +++ b/DDCMS/src/plugins/DDTrackerPhiAlgo.cpp @@ -17,12 +17,8 @@ // Framework include files #include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/Printout.h" #include "DDCMS/DDCMSPlugins.h" -// C/C++ include files -#include <sstream> - using namespace std; using namespace dd4hep; using namespace dd4hep::cms; @@ -32,13 +28,12 @@ static long algorithm(Detector& /* description */, xml_h e, SensitiveDetector& /* sens */) { - stringstream str; Namespace ns(ctxt, e, true); AlgoArguments args(ctxt, e); Volume mother = ns.volume(args.parentName()); Volume child = ns.volume(args.childName()); int startcn = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1; - int incrcn = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1; + int incrcn = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1; vector<double> phi = args.value<vector<double> >("Phi"); // Phi values vector<double> zpos = args.value<vector<double> >("ZPos"); // Z positions int numcopies = args.find("NumCopies") ? args.value<int>("NumCopies") : int(phi.size()); @@ -46,27 +41,21 @@ static long algorithm(Detector& /* description */, double tilt = args.value<double>("Tilt"); if ( numcopies != int(phi.size()) ) { - str << "error: Parameter " + LogDebug("TrackerGeom") << "error: Parameter " << "NumCopies does not agree with the size " << "of the Phi vector. It was adjusted to " << "be the size of the Phi vector and may " << "lead to crashes or errors."; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerPhiAlgo",str); } - - str << "debug: Parameters for position" + LogDebug("TrackerGeom") << "debug: Parameters for position" << "ing:: " << " Radius " << radius << " Tilt " << tilt/CLHEP::deg << " Copies " << phi.size() << " at"; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerPhiAlgo",str); - for (int i=0; i<(int)(phi.size()); i++) { - str << "\t[" << i << "] phi = " << phi[i]/CLHEP::deg + for (int i=0; i<(int)(phi.size()); i++) + LogDebug("TrackerGeom") << "\t[" << i << "] phi = " << phi[i]/CLHEP::deg << " z = " << zpos[i]; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerPhiAlgo",str); - } - str << "debug: Parent " << mother.name() + LogDebug("TrackerGeom") << "debug: Parent " << mother.name() <<"\tChild " << child.name() << " NameSpace " << ns.name; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerPhiAlgo",str); double theta = 90.*CLHEP::deg; int ci = startcn; @@ -78,15 +67,14 @@ static long algorithm(Detector& /* description */, Rotation3D rot = make_rotation3D(theta, phix, theta, phiy, 0., 0.); Position tran(xpos, ypos, zpos[i]); /* PlacedVolume pv = */ mother.placeVolume(child,Transform3D(rot,tran)); - str << "test: " << child.name() << " number " + LogDebug("TrackerGeom") << "test: " << child.name() << " number " << ci << " positioned in " << mother.name() << " at " << tran << " with " << rot; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerPhiAlgo",str); ci = ci+incrcn; } return 1; } // first argument is the type from the xml file -DECLARE_DDCMS_DETELEMENT(track_DDTrackerPhiAlgo,algorithm) +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerPhiAlgo,algorithm) diff --git a/DDCMS/src/plugins/DDTrackerPhiAltAlgo.cpp b/DDCMS/src/plugins/DDTrackerPhiAltAlgo.cpp index b56945947ea769df4d2f087c412f060b163efef3..5ad9bdaa6d1e47520025b52c39d7f8d608ab5c7d 100644 --- a/DDCMS/src/plugins/DDTrackerPhiAltAlgo.cpp +++ b/DDCMS/src/plugins/DDTrackerPhiAltAlgo.cpp @@ -17,12 +17,8 @@ // Framework include files #include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/Printout.h" #include "DDCMS/DDCMSPlugins.h" -// C/C++ include files -#include <sstream> - using namespace std; using namespace dd4hep; using namespace dd4hep::cms; @@ -32,7 +28,6 @@ static long algorithm(Detector& /* description */, xml_h e, SensitiveDetector& /* sens */) { - stringstream str; Namespace ns(ctxt, e, true); AlgoArguments args(ctxt, e); Volume mother = ns.volume(args.parentName()); @@ -47,16 +42,14 @@ static long algorithm(Detector& /* description */, int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1; //Start copy number int incrCopyNo = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1; //Increment in copy number - str << "Parameters for positioning-- Tilt " << tilt - << "\tStartAngle " << startAngle/CLHEP::deg - << "\tRangeAngle " << rangeAngle/CLHEP::deg - << "\tRin " << radiusIn << "\tRout " << radiusOut - << "\t ZPos " << zpos << "\tCopy Numbers " << number - << " Start/Increment " << startCopyNo << ", " - << incrCopyNo; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerPhiAltAlgo",str); - str << "Parent " << mother.name() << "\tChild " << child.name() << " NameSpace " << ns.name; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerPhiAltAlgo",str); + LogDebug("TrackerGeom") << "Parent " << mother.name() << "\tChild " << child.name() << " NameSpace " << ns.name; + LogDebug("TrackerGeom") << "Parameters for positioning-- Tilt " << tilt + << "\tStartAngle " << startAngle/CLHEP::deg + << "\tRangeAngle " << rangeAngle/CLHEP::deg + << "\tRin " << radiusIn << "\tRout " << radiusOut + << "\t ZPos " << zpos << "\tCopy Numbers " << number + << " Start/Increment " << startCopyNo << ", " + << incrCopyNo; if (number > 0) { double theta = 90.*CLHEP::deg; @@ -88,11 +81,10 @@ static long algorithm(Detector& /* description */, } Position tran(xpos, ypos, zpos); /* PlacedVolume pv = */ mother.placeVolume(child,Transform3D(rotation,tran)); - str << "" << child.name() - << " number " << copyNo << " positioned in " - << mother.name() << " at " << tran << " with " - << rotation; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerPhiAltAlgo",str); + LogDebug("TrackerGeom") << "" << child.name() + << " number " << copyNo << " positioned in " + << mother.name() << " at " << tran << " with " + << rotation; copyNo += incrCopyNo; } } @@ -100,5 +92,5 @@ static long algorithm(Detector& /* description */, } // first argument is the type from the xml file -DECLARE_DDCMS_DETELEMENT(track_DDTrackerPhiAltAlgo,algorithm) +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerPhiAltAlgo,algorithm) diff --git a/DDCMS/src/plugins/DDTrackerXYZPosAlgo.cpp b/DDCMS/src/plugins/DDTrackerXYZPosAlgo.cpp index 57faf42ec79d569221af8afedd7eb05a0c7003c2..d2d9c8a889325b931f786eb746c1ad5c17e07cd3 100644 --- a/DDCMS/src/plugins/DDTrackerXYZPosAlgo.cpp +++ b/DDCMS/src/plugins/DDTrackerXYZPosAlgo.cpp @@ -17,12 +17,8 @@ // Framework include files #include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/Printout.h" #include "DDCMS/DDCMSPlugins.h" -// C/C++ include files -#include <sstream> - using namespace std; using namespace dd4hep; using namespace dd4hep::cms; @@ -32,7 +28,6 @@ static long algorithm(Detector& /* description */, xml_h e, SensitiveDetector& /* sens */) { - stringstream str; Namespace ns(ctxt, e, true); AlgoArguments args(ctxt, e); int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1; @@ -44,18 +39,16 @@ static long algorithm(Detector& /* description */, vector<double> zvec = args.value<vector<double> >("ZPositions"); // Z positions vector<string> rotMat = args.value<vector<string> >("Rotations"); // Names of rotation matrices - str << "debug: Parent " << mother.name() - << "\tChild " << child.name() << " NameSpace " - << ns.name << "\tCopyNo (Start/Increment) " - << startCopyNo << ", " << incrCopyNo << "\tNumber " - << xvec.size() << ", " << yvec.size() << ", " << zvec.size(); - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerXYZPosAlgo",str); + LogDebug("TrackerGeom") << "debug: Parent " << mother.name() + << "\tChild " << child.name() << " NameSpace " + << ns.name << "\tCopyNo (Start/Increment) " + << startCopyNo << ", " << incrCopyNo << "\tNumber " + << xvec.size() << ", " << yvec.size() << ", " << zvec.size(); for (int i = 0; i < (int)(zvec.size()); i++) { - str << "\t[" << i << "]\tX = " << xvec[i] - << "\t[" << i << "]\tY = " << yvec[i] - << "\t[" << i << "]\tZ = " << zvec[i] - << ", Rot.Matrix = " << rotMat[i]; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerXYZPosAlgo",str); + LogDebug("TrackerGeom") << "\t[" << i << "]\tX = " << xvec[i] + << "\t[" << i << "]\tY = " << yvec[i] + << "\t[" << i << "]\tZ = " << zvec[i] + << ", Rot.Matrix = " << rotMat[i]; } for (int i=0, copy = startCopyNo; i<(int)(zvec.size()); i++) { @@ -64,15 +57,13 @@ static long algorithm(Detector& /* description */, /* PlacedVolume pv = */ rotMat[i] != "NULL" ? mother.placeVolume(child,Transform3D(ns.rotation(rotMat[i]),tran)) : mother.placeVolume(child,tran); - str << "test: " << child.name() - <<" number " << copy << " positioned in " - << mother.name() << " at " << tran << " with " << rot; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerXYZPosAlgo",str); + LogDebug("TrackerGeom") << "test: " << child.name() + <<" number " << copy << " positioned in " + << mother.name() << " at " << tran << " with " << rot; copy += incrCopyNo; } return 1; } // first argument is the type from the xml file -DECLARE_DDCMS_DETELEMENT(track_DDTrackerXYZPosAlgo,algorithm) - +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerXYZPosAlgo,algorithm) diff --git a/DDCMS/src/plugins/DDTrackerZPosAlgo.cpp b/DDCMS/src/plugins/DDTrackerZPosAlgo.cpp index e375c43dd022991a39f3232a1374ae83880bee47..c7e97b94bcb9350aa2ffb75cb19ff202cba4c415 100644 --- a/DDCMS/src/plugins/DDTrackerZPosAlgo.cpp +++ b/DDCMS/src/plugins/DDTrackerZPosAlgo.cpp @@ -17,12 +17,8 @@ // Framework include files #include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/Printout.h" #include "DDCMS/DDCMSPlugins.h" -// C/C++ include files -#include <sstream> - using namespace std; using namespace dd4hep; using namespace dd4hep::cms; @@ -32,7 +28,6 @@ static long algorithm(Detector& /* description */, xml_h e, SensitiveDetector& /* sens */) { - stringstream str; Namespace ns(ctxt, e, true); AlgoArguments args(ctxt, e); int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1; @@ -42,16 +37,13 @@ static long algorithm(Detector& /* description */, vector<double> zvec = args.value<vector<double> >("ZPositions"); // Z positions vector<string> rotMat = args.value<vector<string> >("Rotations"); // Names of rotation matrices - str << "debug: Parent " << mother.name() - << "\tChild " << child.name() << " NameSpace " - << ns.name << "\tCopyNo (Start/Increment) " - << startCopyNo << ", " << incrCopyNo << "\tNumber " << zvec.size(); - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerZPosAlgo",str); - for (int i = 0; i < (int)(zvec.size()); i++) { - str << "\t[" << i << "]\tZ = " << zvec[i] - << ", Rot.Matrix = " << rotMat[i]; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerZPosAlgo",str); - } + LogDebug("TrackerGeom") << "debug: Parent " << mother.name() + << "\tChild " << child.name() << " NameSpace " + << ns.name << "\tCopyNo (Start/Increment) " + << startCopyNo << ", " << incrCopyNo << "\tNumber " << zvec.size(); + for (int i = 0; i < (int)(zvec.size()); i++) + LogDebug("TrackerGeom") << "\t[" << i << "]\tZ = " << zvec[i] + << ", Rot.Matrix = " << rotMat[i]; for (int i=0, copy = startCopyNo; i<(int)(zvec.size()); i++) { Position tran(0, 0, zvec[i]); @@ -59,15 +51,14 @@ static long algorithm(Detector& /* description */, /* PlacedVolume pv = */ rotMat[i] != "NULL" ? mother.placeVolume(child,Transform3D(ns.rotation(rotMat[i]),tran)) : mother.placeVolume(child,tran); - str << "test: " << child.name() - <<" number " << copy << " positioned in " - << mother.name() << " at " << tran << " with " << rot; - printout(ctxt.debug_algorithms ? ALWAYS : DEBUG,"DDTrackerZPosAlgo",str); + LogDebug("TrackerGeom") << "test: " << child.name() + <<" number " << copy << " positioned in " + << mother.name() << " at " << tran << " with " << rot; copy += incrCopyNo; } return 1; } // first argument is the type from the xml file -DECLARE_DDCMS_DETELEMENT(track_DDTrackerZPosAlgo,algorithm) +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerZPosAlgo,algorithm) diff --git a/DDCond/src/Type1/Manager_Type1.cpp b/DDCond/src/Type1/Manager_Type1.cpp index 5a0a3d28778b86f2094ae204b51ae6aaebc2fcb7..d05fa62586dcb701abb8a970be4e0bea7f89b54e 100644 --- a/DDCond/src/Type1/Manager_Type1.cpp +++ b/DDCond/src/Type1/Manager_Type1.cpp @@ -81,13 +81,14 @@ namespace { 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<Range>(const Manager_Type1* o, const IOV* iov) { const IOVType* typ = check_iov_type<void>(o,iov); if ( typ && iov->has_range() ) return typ; return 0; } - +#endif /// Helper: Check conditions result for consistency template <typename T> void __check_values__(const Manager_Type1* o, Condition::key_type key, const IOV* iov) { diff --git a/DDCore/include/DD4hep/VolumeProcessor.h b/DDCore/include/DD4hep/VolumeProcessor.h new file mode 100644 index 0000000000000000000000000000000000000000..f1bedab307bfbd7d0476da97741f35a271a4d5e2 --- /dev/null +++ b/DDCore/include/DD4hep/VolumeProcessor.h @@ -0,0 +1,179 @@ +//========================================================================== +// 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 +// +//========================================================================== +#ifndef DD4HEP_DDCORE_VOLUMEPROCESSOR_H +#define DD4HEP_DDCORE_VOLUMEPROCESSOR_H + +// Framework includes +#include "DD4hep/DetElement.h" +#include "DD4hep/Volumes.h" + +// C/C++ include files +#include <memory> + +/// Namespace for the AIDA detector description toolkit +namespace dd4hep { + + /// Generic PlacedVolume processor + /** + * Please note that the principle of locality applies: + * The object is designed for stack allocation and configuration. + * It may NOT be shared across threads! + * + * \author M.Frank + * \version 1.0 + * \date 31/05/2017 + * \ingroup DD4HEP_CORE + */ + class PlacedVolumeProcessor { + public: + /// Initializing constructor + PlacedVolumeProcessor() = default; + /// R-value copy from a temporary (Since processor is reference) + PlacedVolumeProcessor(PlacedVolumeProcessor&& copy) = default; + /// Default copy constructor + PlacedVolumeProcessor(const PlacedVolumeProcessor& copy) = default; + /// Default destructor + virtual ~PlacedVolumeProcessor(); + /// Default assignment + PlacedVolumeProcessor& operator=(const PlacedVolumeProcessor& copy) = default; + /// Callback to output PlacedVolume information of an single Placement + virtual int operator()(PlacedVolume pv, int level) const = 0; + /// Callback to output PlacedVolume information of an entire Placement + virtual int process(PlacedVolume pv, int level, bool recursive) const; + }; + + /// PlacedVolume scanner using a Processor object + /** + * Please see the documentation of the + * PlacedVolumeProcessor base class for further information. + * The only requirement to the object is to fullfill the callback signature. + * + * \author M.Frank + * \version 1.0 + * \date 31/05/2017 + * \ingroup DD4HEP_CORE + */ + template <typename T> class PlacementProcessor : virtual public PlacedVolumeProcessor { + public: + /// Reference to execution object implementing operator()(PlacedVolume pv, int level) + T& processor; + public: + /// Default constructor + PlacementProcessor() = delete; + /// Default constructor + PlacementProcessor(T& p) : processor(p) {} + /// Default move constructor is disabled + PlacementProcessor(T&& p) = delete; + /// R-value copy from a temporary (Since processor is reference) + PlacementProcessor(PlacementProcessor&& copy) = default; + /// Default copy constructor + PlacementProcessor(const PlacementProcessor& copy) = default; + /// Default destructor + virtual ~PlacementProcessor() = default; + /// Default assignment + PlacementProcessor& operator=(const PlacementProcessor& copy) = default; + /// Callback to output detector information of an single placement + virtual int operator()(PlacedVolume pv, int level) const final + { return (processor)(pv, level); } + }; + + /// Instantiation helper + template <typename T> inline + PlacementProcessor<typename std::remove_reference<T>::type> placementProcessor(T&& proc) + { return PlacementProcessor<typename std::remove_reference<T>::type>(std::forward<T>(proc)); } + + /// Wrapper to call objects in the form of a PlacedVolume processor. + /** + * \author M.Frank + * \version 1.0 + * \date 31/05/2017 + * \ingroup DD4HEP_CORE + */ + template <typename T> class PlacementProcessorShared : public PlacedVolumeProcessor { + public: + /// Reference to execution object implementing operator()(PlacedVolume pv, int level) + std::shared_ptr<T> processor; + public: + /// Default constructor + PlacementProcessorShared() = delete; + /// Default constructor + PlacementProcessorShared(std::shared_ptr<T>& p) : processor(p) {} + /// Default copy constructor + PlacementProcessorShared(const PlacementProcessorShared& copy) = default; + /// Default destructor + virtual ~PlacementProcessorShared() = default; + /// Default assignment + PlacementProcessorShared& operator=(const PlacementProcessorShared& copy) = default; + /// Callback to output detector information of an single DetElement + virtual int operator()(PlacedVolume pv, int level) const final + { return (*processor)(pv, level); } + }; + + /// Helper to run placement scan through volume hierarchies scans + /** + * This wrapper converts any object, which has the signature + * int operator()(DetElement de, int level) const + * The object is automatically wrapped to a PlacedVolumeProcessor + * and the PlacedVolume tree is scanned depending on the scanning + * arguments. + * + * \author M.Frank + * \version 1.0 + * \date 01/04/2016 + * \ingroup DD4HEP_CORE + */ + class PlacedVolumeScanner { + public: + /// Default constructor + PlacedVolumeScanner() = default; + /// Copy constructor + PlacedVolumeScanner(const PlacedVolumeScanner& copy) = default; + /// Assignment operator + PlacedVolumeScanner& operator=(const PlacedVolumeScanner& copy) = default; + + /// Constructor performing the scan internally + template <typename Q> + PlacedVolumeScanner(Q& proc, DetElement start, int level=0, bool recursive=true) + { scan(proc, start.placement(), level, recursive); } + + /// Constructor performing the scan internally + template <typename Q> + PlacedVolumeScanner(const Q& proc, DetElement start, int level=0, bool recursive=true) + { scan(proc, start.placement(), level, recursive); } + + /// Constructor performing the scan internally + template <typename Q> + PlacedVolumeScanner(Q& proc, PlacedVolume start, int level=0, bool recursive=true) + { scan(proc, start, level, recursive); } + + /// Constructor performing the scan internally + template <typename Q> + PlacedVolumeScanner(const Q& proc, PlacedVolume start, int level=0, bool recursive=true) + { scan(proc, start, level, recursive); } + + /// PlacedVolume element tree scanner using wrapped PlacedVolumeProcessor objects + template <typename Q> + int scan(Q& p, PlacedVolume start, int level=0, bool recursive=true) const { + auto proc = placementProcessor(p); + return proc.process(start, level, recursive); + } + + /// PlacedVolume element tree scanner using wrapped PlacedVolumeProcessor objects + template <typename Q> + int scan(const Q& p, PlacedVolume start, int level=0, bool recursive=true) const { + auto proc = placementProcessor(p); + return proc.process(start, level, recursive); + } + }; +} /* End namespace dd4hep */ +#endif /* DD4HEP_DDCORE_VOLUMEPROCESSOR_H */ diff --git a/DDCore/include/DD4hep/Volumes.h b/DDCore/include/DD4hep/Volumes.h index 05fcea4647829ae10d6f1636dfbf6a15739fb180..3f340579740277be1103dd6651cd8db262165448 100644 --- a/DDCore/include/DD4hep/Volumes.h +++ b/DDCore/include/DD4hep/Volumes.h @@ -141,6 +141,24 @@ namespace dd4hep { typedef PlacedVolumeExtension Object; typedef PlacedVolumeExtension::VolIDs VolIDs; + /// Abstract base for processing callbacks to PlacedVolume objects + /** Helper to facilitate building plugins, which instrument + * placements and volumes e.g. during geometry scans. + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_CORE + */ + class Processor { + public: + /// Default constructor + Processor(); + /// Default destructor + virtual ~Processor(); + /// Container callback for object processing + virtual int processPlacement(PlacedVolume pv) = 0; + }; + /// Default constructor PlacedVolume() = default; /// Copy assignment diff --git a/DDCore/src/GeoDictionary.h b/DDCore/src/GeoDictionary.h index aa3d3d8ff3c0e6a241b13806b40fe276c8ecc621..7900069a015f7aa863065e4b88a471f216aab06c 100644 --- a/DDCore/src/GeoDictionary.h +++ b/DDCore/src/GeoDictionary.h @@ -19,6 +19,7 @@ // Framework include files #include "DD4hep/Volumes.h" #include "DD4hep/Shapes.h" +#include "DD4hep/VolumeProcessor.h" // C/C++ include files #include <vector> @@ -44,6 +45,8 @@ using namespace std; #pragma link C++ class dd4hep::Handle<TGeoVolume>+; #pragma link C++ class dd4hep::PlacedVolume+; +#pragma link C++ class dd4hep::PlacedVolume::Processor+; + #ifndef __ROOTCLING__ template vector<pair<string, int> >; template vector<pair<string, int> >::iterator; @@ -122,5 +125,8 @@ template vector<pair<string, int> >::iterator; #pragma link C++ class dd4hep::UnionSolid+; #pragma link C++ class dd4hep::IntersectionSolid+; +#pragma link C++ class dd4hep::PlacedVolumeProcessor+; +#pragma link C++ class dd4hep::PlacedVolumeScanner+; + #endif // __CINT__ #endif /* DD4HEP_DDCORE_ROOTDICTIONARY_H */ diff --git a/DDCore/src/RootDictionary.h b/DDCore/src/RootDictionary.h index 8009d57e0e926bb2fac34df263aa043166ad4666..8f2fcc9e5c54409095e82c52fae488af660d53ba 100644 --- a/DDCore/src/RootDictionary.h +++ b/DDCore/src/RootDictionary.h @@ -29,10 +29,11 @@ #include "DD4hep/World.h" #include "DD4hep/DD4hepUI.h" #include "DD4hep/Callback.h" -#include "DD4hep/DetectorData.h" #include "DD4hep/Conditions.h" #include "DD4hep/Alignments.h" #include "DD4hep/FieldTypes.h" +#include "DD4hep/DetectorData.h" +#include "DD4hep/DetectorProcessor.h" #include "DD4hep/ComponentProperties.h" // C/C++ include files @@ -98,7 +99,7 @@ template class pair<dd4hep::Callback,unsigned long>; #pragma link C++ class map<string, dd4hep::Handle<dd4hep::NamedObject> >+; #pragma link C++ class map<string, dd4hep::Handle<dd4hep::NamedObject> >::iterator; #pragma link C++ class map<string, dd4hep::Handle<dd4hep::NamedObject> >::const_iterator; -#pragma link C++ class dd4hep::dd4hepUI; +#pragma link C++ class dd4hep::detail::DD4hepUI; #ifdef R__MACOSX // We only need these declarations for the clang compiler @@ -245,6 +246,7 @@ template class dd4hep::Handle<TNamed>; #pragma link C++ class dd4hep::WorldObject+; #pragma link C++ class dd4hep::Handle<dd4hep::WorldObject>+; #pragma link C++ class dd4hep::DetElement+; +#pragma link C++ class dd4hep::DetElement::Processor+; #pragma link C++ class dd4hep::DetElementObject+; #pragma link C++ class dd4hep::Handle<dd4hep::DetElementObject>+; #pragma link C++ class vector<dd4hep::DetElement>+; @@ -253,6 +255,9 @@ template class dd4hep::Handle<TNamed>; #pragma link C++ class map<string,dd4hep::DetElement>::iterator; #pragma link C++ class map<string,dd4hep::DetElement>::const_iterator; +#pragma link C++ class dd4hep::DetectorProcessor+; +#pragma link C++ class dd4hep::DetectorScanner+; + #ifdef R__MACOSX // We only need these declarations for the clang compiler #pragma link C++ function operator==( const map<string, dd4hep::DetElement >::iterator&,const map<string, dd4hep::DetElement >::iterator& ); diff --git a/DDCore/src/VolumeManager.cpp b/DDCore/src/VolumeManager.cpp index 2d6bc5cf777220072f914444336c9ae36d7f3674..231947ee314a59eaacdf63abe2c387934d9aae29 100644 --- a/DDCore/src/VolumeManager.cpp +++ b/DDCore/src/VolumeManager.cpp @@ -194,14 +194,13 @@ namespace dd4hep { /// Populate the Volume manager void populate(DetElement e) { //const char* typ = 0;//::getenv("VOLMGR_NEW"); - const DetElement::Children& c = e.children(); SensitiveDetector parent_sd; if ( e->flag&DetElement::Object::HAVE_SENSITIVE_DETECTOR ) { parent_sd = m_detDesc.sensitiveDetector(e.name()); } //printout(INFO, "VolumeManager", "++ Executing %s plugin manager version",typ ? "***NEW***" : "***OLD***"); - for (const auto& i : c ) { - DetElement de = i.second; + //for (const auto& i : c ) { + DetElement de = e;//i.second; PlacedVolume pv = de.placement(); if (pv.isValid()) { Chain chain; @@ -209,11 +208,12 @@ namespace dd4hep { SensitiveDetector sd = parent_sd; m_entries.clear(); scanPhysicalVolume(de, de, pv, coding, sd, chain); - continue; + //continue; + return; } printout(WARNING, "VolumeManager", "++ Detector element %s of type %s has no placement.", de.name(), de.type().c_str()); - } + //} } /// Scan a single physical volume and look for sensitive elements below size_t scanPhysicalVolume(DetElement& parent, DetElement e, PlacedVolume pv, diff --git a/DDCore/src/VolumeProcessor.cpp b/DDCore/src/VolumeProcessor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..84444e0850a887163e6b2eee6ef170bd3b57ad77 --- /dev/null +++ b/DDCore/src/VolumeProcessor.cpp @@ -0,0 +1,41 @@ +//========================================================================== +// 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 "DD4hep/Printout.h" +#include "DD4hep/VolumeProcessor.h" + +using namespace dd4hep; + +/// Default destructor +PlacedVolumeProcessor::~PlacedVolumeProcessor() { +} + +/// Callback to output PlacedVolume information of an entire DetElement +int PlacedVolumeProcessor::process(PlacedVolume pv, int level, bool recursive) const { + if ( pv.isValid() ) { + int ret = (*this)(pv, level); + TGeoNode* node = pv.ptr(); + if ( recursive ) { + for (Int_t idau = 0, ndau = node->GetNdaughters(); idau < ndau; ++idau) { + PlacedVolume placement(node->GetDaughter(idau)); + if ( placement.data() ) { + ret += process(placement,level+1,recursive); + } + } + } + return ret; + } + except("PlacedVolume","Cannot process an invalid PlacedVolume element"); + return 0; +} diff --git a/DDCore/src/Volumes.cpp b/DDCore/src/Volumes.cpp index 348715d5d2f5b9d580dfeb3ee14a1aa6bed06904..185f07faea6ce7567f24ac04e20fe0459b291eca 100644 --- a/DDCore/src/Volumes.cpp +++ b/DDCore/src/Volumes.cpp @@ -303,6 +303,14 @@ static TGeoVolume* _createTGeoVolumeAssembly(const string& name) { return e; } +/// Default constructor +PlacedVolume::Processor::Processor() { +} + +/// Default destructor +PlacedVolume::Processor::~Processor() { +} + /// Default constructor PlacedVolumeExtension::PlacedVolumeExtension() : TGeoExtension(), magic(0), refCount(0), volIDs() { @@ -504,7 +512,7 @@ static PlacedVolume _addNode(TGeoVolume* par, TGeoVolume* daughter, TGeoMatrix* } TGeoVolume* parent = par; TObjArray* a = parent->GetNodes(); - Int_t id = a ? a->GetEntries() : 0; + Int_t id = 5*(a ? a->GetEntries() : 0); if (transform && transform != detail::matrix::_identity()) { string nam = string(daughter->GetName()) + "_placement"; transform->SetName(nam.c_str()); @@ -521,7 +529,9 @@ static PlacedVolume _addNode(TGeoVolume* par, TGeoVolume* daughter, TGeoMatrix* } } parent->AddNode(daughter, id, transform); - geo_node_t* n = static_cast<geo_node_t*>(parent->GetNode(id)); + //geo_node_t* n = static_cast<geo_node_t*>(parent->GetNode(id)); + TString nam_id = TString::Format("%s_%d", daughter->GetName(), id); + geo_node_t* n = static_cast<geo_node_t*>(parent->GetNode(nam_id)); n->geo_node_t::SetUserExtension(new PlacedVolume::Object()); return PlacedVolume(n); } diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp index 4345a1ceaeb92070ad80a27fc08315168e02493f..5574a27a67baee1dc6594028f72d9e7938359be1 100644 --- a/DDCore/src/plugins/StandardPlugins.cpp +++ b/DDCore/src/plugins/StandardPlugins.cpp @@ -20,6 +20,7 @@ #include "DD4hep/DD4hepUnits.h" #include "DD4hep/DetectorTools.h" #include "DD4hep/PluginCreators.h" +#include "DD4hep/VolumeProcessor.h" #include "DD4hep/DetectorProcessor.h" #include "DD4hep/DD4hepRootPersistency.h" #include "XML/DocumentHandler.h" @@ -68,12 +69,27 @@ DECLARE_CONSTRUCTOR(Detector_constructor,create_description_instance) */ static long display(Detector& description, int argc, char** argv) { TGeoManager& mgr = description.manager(); + int vislevel = 4, visopt = 1; const char* opt = "ogl"; - if (argc > 0) { - opt = argv[0]; + for(int i = 0; i < argc && argv[i]; ++i) { + if ( 0 == ::strncmp("-option",argv[i],4) ) + opt = argv[++i]; + else if ( 0 == ::strncmp("-level",argv[i],4) ) + vislevel = ::atol(argv[++i]); + else if ( 0 == ::strncmp("-visopt",argv[i],4) ) + visopt = ::atol(argv[++i]); + else { + cout << + "Usage: -plugin <name> -arg [-arg] \n" + " -option <string> ROOT Draw option. Default: 'ogl' \n" + " -level <number> Visualization level [TGeoManager::SetVisLevel] Default: 4 \n" + " -visopt <number> Visualization option [TGeoManager::SetVisOption] Default: 1 \n" + "\tArguments given: " << arguments(argc,argv) << endl << flush; + ::exit(EINVAL); + } } - mgr.SetVisLevel(4); - mgr.SetVisOption(1); + mgr.SetVisLevel(vislevel); + mgr.SetVisOption(visopt); TGeoVolume* vol = mgr.GetTopVolume(); if (vol) { vol->Draw(opt); @@ -644,6 +660,7 @@ DECLARE_APPLY(DD4hepCheckNominals,check_nominals) */ static long dump_volume_tree(Detector& description, int argc, char** argv) { struct Actor { + bool m_printPathes = false; bool m_printVolIDs = false; bool m_printPointers = false; bool m_printPositions = false; @@ -659,11 +676,12 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { char c = ::tolower(av[i][0]); char* p = av[i]; if ( c == '-' ) { ++p; c = ::tolower(av[i][1]); } - if ( ::strncmp(p,"volume_ids",3) == 0 ) m_printVolIDs = true; - else if ( ::strncmp(p,"positions",3) == 0 ) m_printPositions = true; - else if ( ::strncmp(p,"materials",3) == 0 ) m_printMaterials = true; - else if ( ::strncmp(p,"pointers",3) == 0 ) m_printPointers = true; - else if ( ::strncmp(p,"sensitive",3) == 0 ) m_printSensitivesOnly = true; + if ( ::strncmp(p,"volume_ids",3) == 0 ) m_printVolIDs = true; + else if ( ::strncmp(p,"pathes",3) == 0 ) m_printPathes = true; + else if ( ::strncmp(p,"positions",3) == 0 ) m_printPositions = true; + else if ( ::strncmp(p,"materials",3) == 0 ) m_printMaterials = true; + else if ( ::strncmp(p,"pointers",3) == 0 ) m_printPointers = true; + else if ( ::strncmp(p,"sensitive",3) == 0 ) m_printSensitivesOnly = true; } } ~Actor() { @@ -675,13 +693,17 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { } } - long dump(TGeoNode* ideal, TGeoNode* aligned,int level, PlacedVolume::VolIDs volids) { + long dump(string prefix, TGeoNode* ideal, TGeoNode* aligned, int level, PlacedVolume::VolIDs volids) { char fmt[128]; - string opt_info; PlacedVolume pv(ideal); bool sensitive = false; + string opt_info, pref = prefix; ++m_numNodes; + if ( m_printPathes ) { + pref += "/"; + pref += aligned->GetName(); + } if ( m_printPositions || m_printVolIDs ) { stringstream log; if ( m_printPointers ) { @@ -732,25 +754,25 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { char sens = pv.volume().isSensitive() ? 'S' : ' '; if ( m_printPointers ) { if ( ideal == aligned ) { - ::snprintf(fmt,sizeof(fmt),"%03d [Ideal:%p] %%-%ds %%-16s (%%s) \t %c %%s", + ::snprintf(fmt,sizeof(fmt),"%03d %%s [Ideal:%p] %%-%ds %%-16s (%%s) \t %c %%s", level+1,(void*)ideal,2*level+1,sens); } else { - ::snprintf(fmt,sizeof(fmt),"%03d Ideal:%p Aligned:%p %%-%ds %%-16s (%%s) %c %%s", + ::snprintf(fmt,sizeof(fmt),"%03d %%s Ideal:%p Aligned:%p %%-%ds %%-16s (%%s) %c %%s", level+1,(void*)ideal,(void*)aligned,2*level+1,sens); } } else { if ( ideal == aligned ) { - ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%-16s (%%s) \t %c %%s", + ::snprintf(fmt,sizeof(fmt),"%03d %%s %%-%ds %%-16s (%%s) \t %c %%s", level+1,2*level+1,sens); } else { - ::snprintf(fmt,sizeof(fmt),"%03d Ideal:%p Aligned:%p %%-%ds %%-16s (%%s) %c %%s", + ::snprintf(fmt,sizeof(fmt),"%03d %%s Ideal:%p Aligned:%p %%-%ds %%-16s (%%s) %c %%s", level+1,(void*)ideal,(void*)aligned,2*level+1,sens); } } - printout(INFO,"VolumeDump",fmt,"", + printout(INFO,"VolumeDump",fmt,pref.c_str(),"", aligned->GetName(), volume ? volume->GetShape()->IsA()->GetName() : "[Invalid Volume]", opt_info.c_str()); @@ -761,19 +783,19 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { Material mat = vol.material(); TGeoMaterial* mptr = mat->GetMaterial(); bool ok = mat.A() == mptr->GetA() && mat.Z() == mptr->GetZ(); - ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds Material: %%-16s A:%%f %%f Z:%%f %%f", + ::snprintf(fmt,sizeof(fmt),"%03d %%s %%-%ds Material: %%-16s A:%%f %%f Z:%%f %%f", level+1,2*level+1); ++m_numMaterial; if ( !ok ) ++m_numMaterialERR; printout(ok ? INFO : ERROR, - "VolumeDump", fmt, "", mat.name(), mat.A(), mptr->GetA(), mat.Z(), mptr->GetZ()); + "VolumeDump", fmt, pref.c_str(), "", mat.name(), mat.A(), mptr->GetA(), mat.Z(), mptr->GetZ()); } for (Int_t idau = 0, ndau = aligned->GetNdaughters(); idau < ndau; ++idau) { if ( ideal ) { TGeoNode* ideal_daughter = ideal->GetDaughter(idau); const char* daughter_name = ideal_daughter->GetName(); TGeoNode* aligned_daughter = volume->GetNode(daughter_name); - dump(ideal_daughter, aligned_daughter, level+1, volids); + dump(pref, ideal_daughter, aligned_daughter, level+1, volids); } else { printout(ERROR,"VolumeDump"," <ERROR: INVALID IDEAL Translation matrix>: %s",aligned->GetName()); @@ -787,7 +809,7 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { detail::tools::placementPath(description.world(), path); PlacedVolume pv = detail::tools::findNode(description.world().placement(),place); Actor actor(argc,argv); - return actor.dump(description.world().placement().ptr(),pv.ptr(),0,PlacedVolume::VolIDs()); + return actor.dump("",description.world().placement().ptr(),pv.ptr(),0,PlacedVolume::VolIDs()); } DECLARE_APPLY(DD4hepVolumeDump,dump_volume_tree) @@ -805,18 +827,79 @@ DECLARE_APPLY(DD4hepVolumeDump,dump_volume_tree) * \date 18/11/2016 */ static int detelement_processor(Detector& description, int argc, char** argv) { + bool recursive = true; DetElement det = description.world(); unique_ptr<DetectorProcessor> proc(dd4hep::createProcessor<DetectorProcessor>(description, argc, argv)); for(int i=0, num=std::min(argc,3); i<num; ++i) { - if ( 0 == ::strncmp(argv[i],"-detector",4) ) { - det = detail::tools::findElement(description, argv[++i]); - break; + if ( 0 == ::strncmp(argv[i],"-recursive",4) ) + recursive = true; + else if ( 0 == ::strncmp(argv[i],"-no-recursive",7) ) + recursive = false; + else if ( 0 == ::strncmp(argv[i],"-detector",4) ) { + string path = argv[++i]; + det = detail::tools::findElement(description, path); + if ( det.isValid() ) { + continue; + } + except("DetElementProcessor", + "++ The detector element path:%s is not part of this description!", + path.c_str()); + } + else { + except("DetElementProcessor","++ Unknown plugin argument: %s",argv[i]); } } - return DetectorScanner().scan(*proc,det); + return DetectorScanner().scan(*proc, det, 0, recursive); } DECLARE_APPLY(DD4hep_DetElementProcessor,detelement_processor) +// ====================================================================================== +/// Plugin function: Apply arbitrary functor callback on the tree of detector elements +/** + * Factory: dd4hep_DetElementProcessor + * + * Invokation: -plugin dd4hep_DetElementProcessor + * -detector /path/to/detElement (default: /world) + * -processor <factory-name> <processor-args> + * + * \author M.Frank + * \version 1.0 + * \date 18/11/2016 + */ +static int placed_volume_processor(Detector& description, int argc, char** argv) { + bool recursive = true; + PlacedVolume pv = description.world().placement(); + unique_ptr<PlacedVolumeProcessor> proc(dd4hep::createProcessor<PlacedVolumeProcessor>(description, argc, argv)); + + for(int i=0, num=std::min(argc,3); i<num; ++i) { + if ( 0 == ::strncmp(argv[i],"-recursive",4) ) + recursive = true; + else if ( 0 == ::strncmp(argv[i],"-no-recursive",7) ) + recursive = false; + else if ( 0 == ::strncmp(argv[i],"-detector",4) ) { + string path = argv[++i]; + DetElement det = detail::tools::findElement(description, path); + if ( det.isValid() ) { + pv = det.placement(); + if ( pv.isValid() ) { + continue; + } + except("PlacedVolumeProcessor", + "++ 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()); + } + else { + except("PlacedVolumeProcessor","++ Unknown plugin argument: %s",argv[i]); + } + } + return PlacedVolumeScanner().scan(*proc, pv, 0, recursive); +} +DECLARE_APPLY(DD4hep_PlacedVolumeProcessor,placed_volume_processor) + /// Basic entry point to print out the detector element hierarchy /** * Factory: DD4hepDetectorDump, DD4hepDetectorVolumeDump diff --git a/DDDB/src/plugins/CondDB2DDDB.cpp b/DDDB/src/plugins/CondDB2DDDB.cpp index 33b0a6fc00debb8cdfb791b31f2364e46873911a..bac677d9563909c8be30555f9e102ac6266b5553 100644 --- a/DDDB/src/plugins/CondDB2DDDB.cpp +++ b/DDDB/src/plugins/CondDB2DDDB.cpp @@ -25,6 +25,7 @@ #include "DDDB/DDDBDimension.h" #include "DDDB/DDDBHelper.h" #include "DDDB/DDDBConversion.h" +#include "Math/Polar2D.h" // C/C++ include files @@ -45,7 +46,7 @@ namespace dd4hep { using cond::AbstractMap; typedef AbstractMap::Params ConditionParams; - + struct PositionRPhiZ {}; struct DDDBLogVolRef {}; struct DDDBElementRef {}; struct DDDBMaterialRef {}; @@ -310,6 +311,11 @@ namespace dd4hep { template <> void Conv<DDDBConditionParam>::convert(xml_h element) const; template <> void Conv<Delta>::convert(xml_h element) const; + template <> void Conv<Position>::convert(xml_h element) const; + template <> void Conv<PositionRPhiZ>::convert(xml_h element) const; + template <> void Conv<RotationZYX>::convert(xml_h element) const; + template <> void Conv<Transform3D>::convert(xml_h element) const; + void extract_transformation(Detector& description, void* context, xml_coll_t& collection, Transform3D& tr, int which=-1); void build_transformation(Detector& description, void* context, xml_h element, Transform3D& tr, int which=-1) { xml_coll_t p(element,_U(star)); @@ -883,6 +889,15 @@ namespace dd4hep { //dddb_print(p); } + /// Specialized conversion of <posRPhiZ/> entities + template <> void Conv<PositionRPhiZ>::convert(xml_h element) const { + dddb_dim_t dim = element; + ROOT::Math::Polar2D<double> dim2(dim.r(0.0), dim.phi(0.0)); + Position* pos = _option<Position>(); + pos->SetXYZ(dim2.X(), dim2.Y(), dim.z(0.0)); + //dddb_print(p); + } + /// Specialized conversion of <rotXYZ/> entities template <> void Conv<RotationZYX>::convert(xml_h element) const { dddb_dim_t dim = element; @@ -1620,6 +1635,13 @@ namespace dd4hep { apply = 1; ++count; } + else if ( tag == "posRPhiZ" && (which<0 || count == which) ) { + ROOT::Math::Polar2D<double> dim2(dim.r(0.0), dim.phi(0.0)); + apply_trafo(apply, pos, rot, trafo, tr); + pos.SetXYZ(dim2.X(), dim2.Y(), dim.z(0.0)); + apply = 1; + ++count; + } else if ( tag == "rotXYZ" && (which<0 || count == (which+1)) ) { rot.SetComponents(dim.rotZ(0.0), dim.rotY(0.0), dim.rotX(0.0)); apply = 2; diff --git a/DDG4/include/DDG4/DDG4Dict.h b/DDG4/include/DDG4/DDG4Dict.h index 78fe3e90fa8e71891d44e092ecdf9808bbdada8b..b08c80f8c51e66d1cf07643cf18f94bad98756f7 100644 --- a/DDG4/include/DDG4/DDG4Dict.h +++ b/DDG4/include/DDG4/DDG4Dict.h @@ -131,8 +131,6 @@ namespace dd4hep { inline ParticleExtension::~ParticleExtension() { } /// Default constructor inline Geant4Particle::Geant4Particle() { } - /// Copy constructor - inline Geant4Particle::Geant4Particle(const Geant4Particle&) { NO_CALL } /// Default destructor inline Geant4Particle::~Geant4Particle() { } /// Remove daughter from set diff --git a/DDG4/include/DDG4/Geant4InputAction.h b/DDG4/include/DDG4/Geant4InputAction.h index 1125ed15025b3bb7bb68d3124f0373231a3a52b7..7c4be855a74995b1f5f0613a7043c31ed6589c33 100644 --- a/DDG4/include/DDG4/Geant4InputAction.h +++ b/DDG4/include/DDG4/Geant4InputAction.h @@ -56,7 +56,8 @@ namespace dd4hep { EVENT_READER_NO_DIRECT=2, EVENT_READER_NO_PRIMARIES=4, EVENT_READER_NO_FACTORY=6, - EVENT_READER_IO_ERROR=8 + EVENT_READER_IO_ERROR=8, + EVENT_READER_EOF=10 }; protected: /// File name to be opened and read diff --git a/DDG4/include/DDG4/Geant4Particle.h b/DDG4/include/DDG4/Geant4Particle.h index 7b3fc57644ddf8959037a757641c33ef8497d6d2..9cce168b61e9dfe4b8618794c6adce8198e604bd 100644 --- a/DDG4/include/DDG4/Geant4Particle.h +++ b/DDG4/include/DDG4/Geant4Particle.h @@ -79,7 +79,7 @@ namespace dd4hep { G4PARTICLE_GEN_DECAYED+G4PARTICLE_GEN_DOCUMENTATION+ G4PARTICLE_GEN_BEAM+G4PARTICLE_GEN_OTHER), G4PARTICLE_GEN_STATUS = 0x3FF, // Mask for generator status (bit 0...9) - + G4PARTICLE_GEN_STATUS_MASK = 0xFFFF,// Mask for the raw generator status (max 65k values) // Simulation status of a given particle G4PARTICLE_SIM_CREATED = 1<<10, // True if the particle has been created by the simulation program (rather than the generator) G4PARTICLE_SIM_BACKSCATTER = 1<<11, // True if the particle is the result of a backscatter from a calorimeter shower. @@ -102,9 +102,6 @@ namespace dd4hep { * \ingroup DD4HEP_SIMULATION */ class Geant4Particle { - private: - /// Copy constructor - Geant4Particle(const Geant4Particle& c); public: typedef std::set<int> Particles; /// Reference counter @@ -114,13 +111,15 @@ namespace dd4hep { int g4Parent = 0, reason = 0, mask = 0; int steps = 0, secondaries = 0, pdgID = 0; int status = 0, colorFlow[2] {0,0}; - char charge = 0, _spare[3] {0,0,0}; + unsigned short genStatus= 0; + char charge = 0; + char _spare[1] {0}; float spin[3] {0E0,0E0,0E0}; - // 12 ints + 4 floats should be aligned to 8 bytes.... - double vsx = 0E0, vsy = 0E0, vsz = 0E0; - double vex = 0E0, vey = 0E0, vez = 0E0; - double psx = 0E0, psy = 0E0, psz = 0E0; - double pex = 0E0, pey = 0E0, pez = 0E0; + // 12 ints + 4 bytes + 3 floats should be aligned to 8 bytes.... + double vsx = 0E0, vsy = 0E0, vsz = 0E0; + double vex = 0E0, vey = 0E0, vez = 0E0; + double psx = 0E0, psy = 0E0, psz = 0E0; + double pex = 0E0, pey = 0E0, pez = 0E0; double mass = 0E0, time = 0E0, properTime = 0E0; /// The list of daughters of this MC particle Particles parents; @@ -137,8 +136,12 @@ namespace dd4hep { Geant4Particle(); /// Constructor with ID initialization Geant4Particle(int part_id); + /// NO copy constructor + Geant4Particle(const Geant4Particle& copy) = delete; /// Default destructor virtual ~Geant4Particle(); + /// NO assignment operation + Geant4Particle& operator=(const Geant4Particle& copy) = delete; /// Increase reference count Geant4Particle* addRef() { ++ref; diff --git a/DDG4/lcio/Geant4Output2LCIO.cpp b/DDG4/lcio/Geant4Output2LCIO.cpp index b88373eb0acb9ffc1ddf07ff3a06d84f3b4e0f6e..d49b99665d4bc8e3ad2c3502109d6385658cd15f 100644 --- a/DDG4/lcio/Geant4Output2LCIO.cpp +++ b/DDG4/lcio/Geant4Output2LCIO.cpp @@ -21,7 +21,6 @@ #include "G4Threading.hh" #include "G4AutoLock.hh" -#include "LCIOParticleExtension.h" #include "DD4hep/Detector.h" #include <G4Version.hh> @@ -241,14 +240,8 @@ lcio::LCCollectionVec* Geant4Output2LCIO::saveParticles(Geant4ParticleMap* parti // Set generator status q->setGeneratorStatus(0); - - // see if we have preserved the original generator code in the stdhep or LCIO reader - const LCIOParticleExtension* p_ext = dynamic_cast< LCIOParticleExtension*>( p->extension.get() ) ; - - if( p_ext ) { - - q->setGeneratorStatus( p_ext->generatorStatus ) ; - + if( p->genStatus ) { + q->setGeneratorStatus( p->genStatus ) ; } else { if ( mask.isSet(G4PARTICLE_GEN_STABLE) ) q->setGeneratorStatus(1); diff --git a/DDG4/lcio/LCIOEventReader.cpp b/DDG4/lcio/LCIOEventReader.cpp index b403aaf85e98f2c75e55b393d8760425d176e389..64aedadaad1ef23ea6869b4ba640e85892355ceb 100644 --- a/DDG4/lcio/LCIOEventReader.cpp +++ b/DDG4/lcio/LCIOEventReader.cpp @@ -14,7 +14,6 @@ // Framework include files #include "LCIOEventReader.h" -#include "LCIOParticleExtension.h" #include "DD4hep/Printout.h" #include "DDG4/Geant4Primary.h" #include "DDG4/Geant4Context.h" @@ -127,12 +126,8 @@ LCIOEventReader::readParticles(int event_number, else if ( genStatus == 4 ) status.set(G4PARTICLE_GEN_BEAM); else status.set(G4PARTICLE_GEN_OTHER); - - // store the original generator status in case it is not in [0,4] - LCIOParticleExtension* p_ext = new LCIOParticleExtension ; - p_ext->generatorStatus = mcp->getGeneratorStatus(); - p->extension.adopt( p_ext ) ; - + // Copy raw generator status + p->genStatus = genStatus&G4PARTICLE_GEN_STATUS_MASK; //fg: we simply add all particles without parents as with their own vertex. // This might include the incoming beam particles, e.g. in diff --git a/DDG4/lcio/LCIOFileReader.cpp b/DDG4/lcio/LCIOFileReader.cpp index 69fd8c7ec63ef968496218fada7f2f7b8c7afa33..9a4c96aca0f4a112606cd102857269d4df1731e3 100644 --- a/DDG4/lcio/LCIOFileReader.cpp +++ b/DDG4/lcio/LCIOFileReader.cpp @@ -124,7 +124,7 @@ dd4hep::sim::LCIOFileReader::readParticleCollection(int /*event_number*/, EVENT: return EVENT_READER_OK; } } - return EVENT_READER_ERROR; + return EVENT_READER_EOF; } /// Set the parameters for the class, in particular the name of the MCParticle diff --git a/DDG4/lcio/LCIOParticleExtension.h b/DDG4/lcio/LCIOParticleExtension.h deleted file mode 100644 index 3519c3cd7ea8a5535ce4fc9836fc07466211798a..0000000000000000000000000000000000000000 --- a/DDG4/lcio/LCIOParticleExtension.h +++ /dev/null @@ -1,50 +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 -// -//========================================================================== - -#ifndef DD4HEP_LCIOParticleExtension_H -#define DD4HEP_LCIOParticleExtension_H - -#include "DDG4/Geant4Particle.h" - -/// Namespace for the AIDA detector description toolkit -namespace dd4hep { - - /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit - namespace sim { - - - /** Simple helper class for additional MCParticle information - * used with LCIO readers and writers. - * - * @author F.Gaede, DESY - * @version 1.0 - * @ingroup DD4HEP_SIMULATION - */ - class LCIOParticleExtension : public ParticleExtension{ - - public: - - /// original generator status - int generatorStatus ; - - /// Default constructor - LCIOParticleExtension() {} - - /// Default destructor - virtual ~LCIOParticleExtension() {} ; - - }; - } -} - -#endif diff --git a/DDG4/lcio/LCIOStdHepReader.cpp b/DDG4/lcio/LCIOStdHepReader.cpp index 8351577ba73e51497c04717d8767b1acd3ab7818..9acf2bef692e0592edc8a50432fa0d585767c760 100644 --- a/DDG4/lcio/LCIOStdHepReader.cpp +++ b/DDG4/lcio/LCIOStdHepReader.cpp @@ -92,7 +92,7 @@ LCIOStdHepReader::moveToEvent(int event_number) { printout(INFO,"LCIOStdHepReader::moveToEvent","Event number before skipping: %d", m_currEvent ); while ( m_currEvent < event_number ) { EVENT::LCCollection* particles = m_reader->readEvent(); - if ( 0 == particles ) return EVENT_READER_ERROR; + if ( 0 == particles ) return EVENT_READER_EOF; delete particles; ++m_currEvent; } @@ -108,6 +108,6 @@ LCIOStdHepReader::readParticleCollection(int /*event_number*/, EVENT::LCCollecti *particles = m_reader->readEvent(); ++m_currEvent; - if ( 0 == *particles ) return EVENT_READER_ERROR; + if ( 0 == *particles ) return EVENT_READER_EOF; return EVENT_READER_OK; } diff --git a/DDG4/plugins/Geant4EventReaderHepEvt.cpp b/DDG4/plugins/Geant4EventReaderHepEvt.cpp index 02bf25b1b89dd9057f3fc63cb157905efeead718..1cac6db735f91127b12a4257eb2afbe84711b46f 100644 --- a/DDG4/plugins/Geant4EventReaderHepEvt.cpp +++ b/DDG4/plugins/Geant4EventReaderHepEvt.cpp @@ -156,10 +156,12 @@ Geant4EventReaderHepEvt::readParticles(int /* event_number */, // First check the input file status - if ( !m_input.good() || m_input.eof() ) { + if ( m_input.eof() ) { + return EVENT_READER_EOF; + } + else if ( !m_input.good() ) { return EVENT_READER_IO_ERROR; } - //static const double c_light = 299.792;// mm/ns // // Read the event, check for errors @@ -167,7 +169,7 @@ Geant4EventReaderHepEvt::readParticles(int /* event_number */, unsigned NHEP(0); // number of entries m_input >> NHEP; - if( m_input.eof() ){ return EVENT_READER_IO_ERROR; } + if( m_input.eof() ) { return EVENT_READER_EOF; } //check loop variable read from input file and chack that is reasonable @@ -175,7 +177,7 @@ Geant4EventReaderHepEvt::readParticles(int /* event_number */, if( NHEP > 1e6 ){ printout(ERROR,"EventReaderHepEvt::readParticles","Cannot read in more than million particles, but %d requested", NHEP ); - return EVENT_READER_IO_ERROR; + return EVENT_READER_EOF; } @@ -223,7 +225,7 @@ Geant4EventReaderHepEvt::readParticles(int /* event_number */, >> VHEP4; if(m_input.eof()) - return EVENT_READER_IO_ERROR; + return EVENT_READER_EOF; // // create a MCParticle and fill it from stdhep info @@ -262,6 +264,8 @@ Geant4EventReaderHepEvt::readParticles(int /* event_number */, else if ( ISTHEP == 2 ) status.set(G4PARTICLE_GEN_DECAYED); else if ( ISTHEP == 3 ) status.set(G4PARTICLE_GEN_DOCUMENTATION); else status.set(G4PARTICLE_GEN_DOCUMENTATION); + // RAW Generator status + p->genStatus = ISTHEP&G4PARTICLE_GEN_STATUS_MASK; //fixme: need to define the correct logic for selecting the particle to use // for the _one_ event vertex diff --git a/DDG4/plugins/Geant4EventReaderHepMC.cpp b/DDG4/plugins/Geant4EventReaderHepMC.cpp index 47dfbeb5ac598ec03392540aecd98049c6ed42c2..af680ba419d409d800866fec659fa2c1df6c0037 100644 --- a/DDG4/plugins/Geant4EventReaderHepMC.cpp +++ b/DDG4/plugins/Geant4EventReaderHepMC.cpp @@ -232,7 +232,7 @@ Geant4EventReaderHepMC::readParticles(int /* ev_id */, primary_vertex->z = 0; if ( !m_events->ok() ) { - return EVENT_READER_IO_ERROR; + return EVENT_READER_EOF; } else if ( m_events->read() ) { EventStream::Particles& parts = m_events->particles(); @@ -266,18 +266,18 @@ Geant4EventReaderHepMC::readParticles(int /* ev_id */, //ad particles to the 'primary vertex' if ( p->parents.size() == 0 ) { - PropertyMask status(p->status); - if ( status.isSet(G4PARTICLE_GEN_EMPTY) || status.isSet(G4PARTICLE_GEN_DOCUMENTATION) ) - primary_vertex->in.insert(p->id); // Beam particles and primary quarks etc. - else - primary_vertex->out.insert(p->id); // Stuff, to be given to Geant4 together with daughters + PropertyMask status(p->status); + if ( status.isSet(G4PARTICLE_GEN_EMPTY) || status.isSet(G4PARTICLE_GEN_DOCUMENTATION) ) + primary_vertex->in.insert(p->id); // Beam particles and primary quarks etc. + else + primary_vertex->out.insert(p->id); // Stuff, to be given to Geant4 together with daughters } } ++m_currEvent; return EVENT_READER_OK; } - return EVENT_READER_IO_ERROR; + return EVENT_READER_EOF; } void HepMC::fix_particles(EventStream& info) { @@ -436,7 +436,8 @@ int HepMC::read_particle(EventStream &info, istringstream& input, Geant4Particle else if ( stat == 0x3 ) status.set(G4PARTICLE_GEN_DOCUMENTATION); else if ( stat == 0x4 ) status.set(G4PARTICLE_GEN_DOCUMENTATION); else if ( stat == 0xB ) status.set(G4PARTICLE_GEN_DOCUMENTATION); - + p->genStatus = stat&G4PARTICLE_GEN_STATUS_MASK; + // read flow patterns if any exist for (int i = 0; i < size; ++i ) { input >> p->colorFlow[0] >> p->colorFlow[1]; @@ -629,8 +630,8 @@ int HepMC::read_pdf(EventStream &, istringstream & input) { int pdf_id1=0, pdf_id2=0; input >> pdf_id1 >> pdf_id2; /* - pdf->set_pdf_id1( pdf_id1 ); - pdf->set_pdf_id2( pdf_id2 ); + pdf->set_pdf_id1( pdf_id1 ); + pdf->set_pdf_id2( pdf_id2 ); */ } return input.fail() ? 0 : 1; diff --git a/DDG4/src/Geant4InputAction.cpp b/DDG4/src/Geant4InputAction.cpp index cbba3e42288ec2649453c47c75a764203bc517b9..f07a39010bcb26e42449efc9d4ed0eae4aa6fdcd 100644 --- a/DDG4/src/Geant4InputAction.cpp +++ b/DDG4/src/Geant4InputAction.cpp @@ -95,7 +95,7 @@ Geant4EventReader::moveToEvent(int event_number) { #else /// Move to the indicated event number. Geant4EventReader::EventReaderStatus -Geant4EventReader::moveToEvent(int event_number) { +Geant4EventReader::moveToEvent(int /* event_number */) { return EVENT_READER_OK; } #endif @@ -159,7 +159,9 @@ int Geant4InputAction::readParticles(int evt_number, } int status = m_reader->moveToEvent(evid); if ( Geant4EventReader::EVENT_READER_OK != status ) { - string msg = issue(evid)+"Error when moving to event - may be end of file."; + 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 ) { abortRun(msg,"Error when reading file %s",m_input.c_str()); return status; @@ -172,7 +174,9 @@ int Geant4InputAction::readParticles(int evt_number, if ( Geant4EventReader::EVENT_READER_OK != status ) { - string msg = issue(evid)+"Error when moving to event - may be end of file."; + 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 ) { abortRun(msg,"Error when reading file %s",m_input.c_str()); return status; diff --git a/DDG4/src/Geant4Particle.cpp b/DDG4/src/Geant4Particle.cpp index 0a7071e10de9eff5334a3e8d9136affa591ef4b2..89aa18c131cb5b01259f007dda8bc84c6142d91c 100644 --- a/DDG4/src/Geant4Particle.cpp +++ b/DDG4/src/Geant4Particle.cpp @@ -34,59 +34,16 @@ typedef detail::ReferenceBitMask<int> PropertyMask; ParticleExtension::~ParticleExtension() { } -/// Copy constructor -Geant4Particle::Geant4Particle(const Geant4Particle& c) -: ref(1), id(c.id), originalG4ID(c.originalG4ID), g4Parent(c.g4Parent), reason(c.reason), mask(c.mask), - steps(c.steps), secondaries(c.secondaries), pdgID(c.pdgID), - status(c.status), charge(0), - vsx(c.vsx), vsy(c.vsy), vsz(c.vsz), - vex(c.vex), vey(c.vey), vez(c.vez), - psx(c.psx), psy(c.psy), psz(c.psz), - pex(c.pex), pey(c.pey), pez(c.pez), - mass(c.mass), time(c.time), properTime(c.properTime), - parents(c.parents), daughters(c.daughters), extension(), - process(c.process)//, definition(c.definition) -{ - InstanceCount::increment(this); - spin[0] = c.spin[0]; - spin[1] = c.spin[1]; - spin[2] = c.spin[2]; - colorFlow[0] = c.colorFlow[0]; - colorFlow[1] = c.colorFlow[1]; -} - /// Default constructor -Geant4Particle::Geant4Particle() -: ref(1), id(0), originalG4ID(0), g4Parent(0), reason(0), mask(0), - steps(0), secondaries(0), pdgID(0), - status(0), charge(0), - vsx(0.0), vsy(0.0), vsz(0.0), - vex(0.0), vey(0.0), vez(0.0), - psx(0.0), psy(0.0), psz(0.0), - pex(0.0), pey(0.0), pez(0.0), - mass(0.0), time(0.0), properTime(0.0), - daughters(), extension(), process(0)//, definition(0) +Geant4Particle::Geant4Particle() : ref(1) { InstanceCount::increment(this); - spin[0] = spin[1] = spin[2] = 0; - colorFlow[0] = colorFlow[1] = 0; } /// Constructor with ID initialization -Geant4Particle::Geant4Particle(int part_id) -: ref(1), id(part_id), originalG4ID(part_id), g4Parent(0), reason(0), mask(0), - steps(0), secondaries(0), pdgID(0), - status(0), charge(0), - vsx(0.0), vsy(0.0), vsz(0.0), - vex(0.0), vey(0.0), vez(0.0), - psx(0.0), psy(0.0), psz(0.0), - pex(0.0), pey(0.0), pez(0.0), - mass(0.0), time(0.0), properTime(0.0), - daughters(), extension(), process(0)//, definition(0) +Geant4Particle::Geant4Particle(int part_id) : ref(1), id(part_id), originalG4ID(part_id) { InstanceCount::increment(this); - spin[0] = spin[1] = spin[2] = 0; - colorFlow[0] = colorFlow[1] = 0; } /// Default destructor @@ -111,6 +68,7 @@ Geant4Particle& Geant4Particle::get_data(Geant4Particle& c) { reason = c.reason; mask = c.mask; status = c.status; + genStatus = c.genStatus; charge = c.charge; steps = c.steps; secondaries = c.secondaries; diff --git a/DDG4/src/Geant4ParticleHandler.cpp b/DDG4/src/Geant4ParticleHandler.cpp index c13fbbd09ac9f46a437ab007024299ae5d5adf38..6cad82846719d292eae5b45bd5d8ab7cc0493373 100644 --- a/DDG4/src/Geant4ParticleHandler.cpp +++ b/DDG4/src/Geant4ParticleHandler.cpp @@ -226,6 +226,7 @@ void Geant4ParticleHandler::begin(const G4Track* track) { m_currTrack.reason = prim_part->reason|reason; m_currTrack.mask = prim_part->mask; m_currTrack.status = prim_part->status; + m_currTrack.genStatus = prim_part->genStatus; m_currTrack.spin[0] = prim_part->spin[0]; m_currTrack.spin[1] = prim_part->spin[1]; m_currTrack.spin[2] = prim_part->spin[2]; @@ -241,6 +242,7 @@ void Geant4ParticleHandler::begin(const G4Track* track) { m_currTrack.reason = reason; m_currTrack.mask = 0; m_currTrack.status = G4PARTICLE_SIM_CREATED; + m_currTrack.genStatus = 0; m_currTrack.spin[0] = 0; m_currTrack.spin[1] = 0; m_currTrack.spin[2] = 0; diff --git a/UtilityApps/src/run_plugin.h b/UtilityApps/src/run_plugin.h index 295a521eb0e0926e8439e7ad1f8a526a60702369..0c0d88cb383a7e07cf429a0f93f9abe9fcc40359 100644 --- a/UtilityApps/src/run_plugin.h +++ b/UtilityApps/src/run_plugin.h @@ -71,22 +71,28 @@ namespace { std::ostream& print_default_args() { std::cout << " -build_type <number/string> Specify the build type \n" - " [OPTIONAL] MUST come immediately after the -compact input.\n" + " [OPTIONAL] MUST come immediately after the -compact input.\n" " Default for each file is: BUILD_DEFAULT [=1] \n" " Allowed: BUILD_SIMU [=1], BUILD_RECO [=2], \n" " BUILD_DISPLAY [=3] or BUILD_ENVELOPE [=4] \n" - " -destroy [OPTIONAL] Force destruction of the Detector instance \n" + " -destroy [OPTIONAL] Force destruction of the Detector instance \n" " before exiting the application \n" - " -volmgr [OPTIONAL] Load and populate phys.volume manager to \n" + " -no-destroy [OPTIONAL] Inhibit destruction of the Detector instance \n" + " -volmgr [OPTIONAL] Load and populate phys.volume manager to \n" " check the volume ids for duplicates etc. \n" + " -no-volmgr [OPTIONAL] Inhibit loading phys.volume manager \n" + " -interpreter [OPTIONAL] Start ROOT C++ interpreter after execution. \n" + " -no-interpreter [OPTIONAL] Inhibit ROOT C++ interpreter. \n" " -print <number/string> Specify output level. Default: INFO(=3) \n" - " [OPTIONAL] Allowed values: VERBOSE(=1), DEBUG(=2), \n" + " [OPTIONAL] Allowed values: VERBOSE(=1), DEBUG(=2), \n" " INFO(=3), WARNING(=4), ERROR(=5), FATAL(=6) \n" " The lower the level, the more printout... \n" + " -dry-run [OPTIONAL] Only load description. No execution. \n" " -plugin <name> <args> Execute plugin <name> after loading geometry. \n" - " All arguments following until the next '-' \n" - " are considered as arguments to the plugin. \n" - " -ui Install ROOT interpreter UI for dd4hep \n" + " All arguments following until the next \n" + " '-plugin' tag are considered as arguments \n" + " to the current plugin. \n" + " -ui [OPTIONAL] Install ROOT interpreter UI for dd4hep \n" " Will show up in the global interpreter variable\n" " 'dd4hep::ROOTUI* gdd4hepUI' and allows the user\n" " to interact with the the Detector instance from the\n" diff --git a/examples/DDCMS/CMS-tracker2.png b/examples/DDCMS/CMS-tracker2.png new file mode 100644 index 0000000000000000000000000000000000000000..55f737849000c897e2a9d37c104a5db9eb4b1758 Binary files /dev/null and b/examples/DDCMS/CMS-tracker2.png differ diff --git a/examples/DDCMS/data/cms_tracker.xml b/examples/DDCMS/data/cms_tracker.xml index c353d197cc6b80cc28cc414c15165cfd015dd2ad..66da5a09de1461852b333d3f26c1353a57ad770b 100644 --- a/examples/DDCMS/data/cms_tracker.xml +++ b/examples/DDCMS/data/cms_tracker.xml @@ -1,16 +1,16 @@ <?xml version="1.0"?> <DDDefinition> <debug> + <debug_rotations/> + <debug_materials/> <!-- <debug_shapes/> <debug_volumes/> <debug_constants/> - <debug_rotations/> - <debug_materials/> <debug_includes/> <debug_namespaces/> - <debug_algorithms/> <debug_placements/> + <debug_algorithms/> --> </debug> <open_geometry/> @@ -62,29 +62,46 @@ <vis name="pixbarladderhalf_PixelBarrelCFStripHalf" alpha="1" r="1" g="0.1" b="0.1" showDaughters="true" visible="true"/> <vis name="pixbarladderhalf_PixelBarrelLadderHalf" alpha="0.8" r="0.6" g="0.6" b="0.0" showDaughters="true" visible="true"/> - <vis name="pixbarladderfull_PixelBarrelCable1Full" alpha="1.0" r="0" g="1" b="1" showDaughters="true" visible="true"/> - <vis name="pixbarladderfull_PixelBarrelCable2Full" alpha="1.0" r="0" g="1" b="1" showDaughters="true" visible="true"/> - <vis name="pixbarladderfull_PixelBarrelCable3Full" alpha="1.0" r="0" g="1" b="1" showDaughters="true" visible="true"/> - <vis name="pixbarladderfull_PixelBarrelCable4Full" alpha="1.0" r="0" g="1" b="1" showDaughters="true" visible="true"/> - <vis name="pixbarladderfull_PixelBarrelCableBoxFull" alpha="0.4" r="0.4" g="0.2" b="0.2" showDaughters="true" visible="true"/> - <vis name="pixbarladderfull_PixelBarrelModuleBoxFull" alpha="0.6" r="0.2" g="0.2" b="0.2" showDaughters="true" visible="true"/> - <vis name="pixbarladderfull_PixelBarrelCFStripFull" alpha="1" r="1" g="0.1" b="0.1" showDaughters="true" visible="true"/> - <vis name="pixbarladderfull_PixelBarrelLadderFull" alpha="0.8" r="0.6" g="0.6" b="0.0" showDaughters="true" visible="true"/> - - <vis name="pixbarlayer0_PixelBarrelLayer0Coolant" alpha="0.5" r="0" g="0.4" b="0.6" showDaughters="true" visible="false"/> - <vis name="pixbarlayer0_PixelBarrelLayer0CoolTube" alpha="1.0" r="0" g="0.2" b="0.8" showDaughters="true" visible="true"/> - <vis name="pixbarlayer0_PixelBarrelLayer0" alpha="0.5" r="0.6" g="0.6" b="0.6" showDaughters="true" visible="true"/> - - <vis name="pixbarlayer1_PixelBarrelLayer1Coolant" alpha="0.5" r="0" g="0.4" b="0.6" showDaughters="true" visible="false"/> - <vis name="pixbarlayer1_PixelBarrelLayer1CoolTube" alpha="1.0" r="0" g="0.2" b="0.8" showDaughters="true" visible="true"/> - <vis name="pixbarlayer1_PixelBarrelLayer1" alpha="0.5" r="0.6" g="0.6" b="0.6" showDaughters="true" visible="true"/> - - <vis name="pixbarlayer2_PixelBarrelLayer2Coolant" alpha="0.5" r="0" g="0.4" b="0.6" showDaughters="true" visible="false"/> - <vis name="pixbarlayer2_PixelBarrelLayer2CoolTube" alpha="1.0" r="0" g="0.2" b="0.8" showDaughters="true" visible="true"/> - <vis name="pixbarlayer2_PixelBarrelLayer2" alpha="0.5" r="0.6" g="0.6" b="0.6" showDaughters="true" visible="true"/> - + <vis name="pixbarladderfull_PixelBarrelCable1Full" alpha="1.0" r="0" g="1" b="1" showDaughters="true" visible="true"/> + <vis name="pixbarladderfull_PixelBarrelCable2Full" alpha="1.0" r="0" g="1" b="1" showDaughters="true" visible="true"/> + <vis name="pixbarladderfull_PixelBarrelCable3Full" alpha="1.0" r="0" g="1" b="1" showDaughters="true" visible="true"/> + <vis name="pixbarladderfull_PixelBarrelCable4Full" alpha="1.0" r="0" g="1" b="1" showDaughters="true" visible="true"/> + <vis name="pixbarladderfull_PixelBarrelCableBoxFull" alpha="0.4" r="0.4" g="0.2" b="0.2" showDaughters="true" visible="true"/> + <vis name="pixbarladderfull_PixelBarrelModuleBoxFull" alpha="0.6" r="0.2" g="0.2" b="0.2" showDaughters="true" visible="true"/> + <vis name="pixbarladderfull_PixelBarrelCFStripFull" alpha="1" r="1" g="0.1" b="0.1" showDaughters="true" visible="true"/> + <vis name="pixbarladderfull_PixelBarrelLadderFull" alpha="0.8" r="0.6" g="0.6" b="0.0" showDaughters="true" visible="true"/> + + <vis name="pixbarlayer0_PixelBarrelLayer0Coolant" alpha="0.5" r="0" g="0.4" b="0.6" showDaughters="true" visible="false"/> + <vis name="pixbarlayer0_PixelBarrelLayer0CoolTube" alpha="1.0" r="0" g="0.2" b="0.8" showDaughters="true" visible="true"/> + <vis name="pixbarlayer0_PixelBarrelLayer0" alpha="0.5" r="0.6" g="0.6" b="0.6" showDaughters="true" visible="true"/> + + <vis name="pixbarlayer1_PixelBarrelLayer1Coolant" alpha="0.5" r="0" g="0.4" b="0.6" showDaughters="true" visible="false"/> + <vis name="pixbarlayer1_PixelBarrelLayer1CoolTube" alpha="1.0" r="0" g="0.2" b="0.8" showDaughters="true" visible="true"/> + <vis name="pixbarlayer1_PixelBarrelLayer1" alpha="0.5" r="0.6" g="0.6" b="0.6" showDaughters="true" visible="true"/> + + <vis name="pixbarlayer2_PixelBarrelLayer2Coolant" alpha="0.5" r="0" g="0.4" b="0.6" showDaughters="true" visible="false"/> + <vis name="pixbarlayer2_PixelBarrelLayer2CoolTube" alpha="1.0" r="0" g="0.2" b="0.8" showDaughters="true" visible="true"/> + <vis name="pixbarlayer2_PixelBarrelLayer2" alpha="0.5" r="0.6" g="0.6" b="0.6" showDaughters="true" visible="true"/>f + <vis name="solid-light-grey" alpha="0.5" r="0.5" g="0.5" b="0.5" showDaughters="true" visible="true"/> + <vis name="solid-red" alpha="1.0" r="1.0" g="0.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="solid-green" alpha="1.0" r="0.0" g="1.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="solid-blue" alpha="1.0" r="0.0" g="0.0" b="1.0" showDaughters="true" visible="true"/> + <vis name="CMS_Invisible" alpha="1" r="0.0" g="0.0" b="1" showDaughters="true" visible="false"/> + + <vismaterial name="AL" type="solid-light-grey"/> + <vismaterial name="SI" type="solid-red"/> + <vismaterial name="materials_Air" type="CMS_Invisible"/> + <vismaterial name="materials_E_Air" type="CMS_Invisible"/> + <vismaterial name="materials_H_Air" type="CMS_Invisible"/> + <vismaterial name="materials_M_B_Air" type="CMS_Invisible"/> + <vismaterial name="materials_M_F_Air" type="CMS_Invisible"/> + <vismaterial name="materials_T_Air" type="CMS_Invisible"/> + <vismaterial name="materials_V_Air" type="CMS_Invisible"/> + <vismaterial name="trackermaterial_T_Aluminium" type="solid-light-grey"/> + <vismaterial name="tecmaterial_TEC_petalinsert" type="solid-blue"/> </VisSection> + <DisabledAlgo name="track:DDTOBRadCableAlgo"/> <ConstantsSection label="pixfwd" eval="true"> <Constant name="AnchorZ" value="0.*mm"/> <Constant name="ZPixelForward" value="325.*mm"/> @@ -97,15 +114,12 @@ <Include ref="materials.xml"/> <Include ref="trackermaterial.xml"/> <Include ref="tibtidcommonmaterial.xml"/> - <Include ref="pixfwdMaterials.xml"/> <Include ref="vacuum.xml"/> <Include ref="cmsextent.xml"/> <Include ref="cms.xml"/> -<!-- ---> - + <Include ref="pixfwdMaterials.xml"/> <Include ref="pixbarmaterial.xml"/> <Include ref="pixbarladder.xml"/> <Include ref="pixbarladderfull.xml"/> @@ -116,9 +130,6 @@ <Include ref="pixbarlayer2.xml"/> <Include ref="pixbar.xml"/> -<!-- ---> - <Include ref="tecmaterial.xml"/> <Include ref="tecpetpar.xml"/> @@ -183,8 +194,6 @@ <Include ref="tec.xml"/> <Include ref="tecservices.xml"/> -<!-- ---> <Include ref="tibmaterial.xml"/> <Include ref="tibmodpar.xml"/> @@ -223,8 +232,6 @@ <Include ref="tib.xml"/> -<!-- ---> <Include ref="tidmaterial.xml"/> <Include ref="tidmodpar.xml"/> <Include ref="tidringpar.xml"/> @@ -250,18 +257,14 @@ <Include ref="tibtidservices.xml"/> <Include ref="tibtidservicesb.xml"/> <Include ref="tibtidservicesf.xml"/> -<!-- ---> <Include ref="tobmaterial.xml"/> <Include ref="tobmodpar.xml"/> - + <Include ref="tobrodpar.xml"/> <Include ref="tobmodule0.xml"/> <Include ref="tobmodule2.xml"/> <Include ref="tobmodule4.xml"/> - <Include ref="tobrodpar.xml"/> - <Include ref="tobrod0.xml"/> <Include ref="tobrod0c.xml"/> <Include ref="tobrod0h.xml"/> @@ -288,14 +291,14 @@ <Include ref="tobrod5.xml"/> <Include ref="tobrod5h.xml"/> <Include ref="tobrod5l.xml"/> - <Include ref="tob.xml"/> + <Include ref="pixfwdCommon.xml"/> <!-- - <Include ref="pixfwdCommon.xml"/> - <Include ref="pixfwdPanelBase.xml"/> + <Include ref="pixfwdBlade.xml"/> <Include ref="pixfwdPanel.xml"/> + <Include ref="pixfwdPanelBase.xml"/> <Include ref="pixfwdDisk.xml"/> <Include ref="pixfwdCylinder.xml"/> <Include ref="pixfwdNipple.xml"/> @@ -308,27 +311,23 @@ <Include ref="pixfwdPlaq2x5.xml"/> <Include ref="pixfwd.xml"/> - --> + <Include ref="trackerbulkhead.xml"/> + <Include ref="trackertib.xml"/> <Include ref="trackertid.xml"/> <Include ref="trackertec.xml"/> - <Include ref="trackertob.xml"/> - <Include ref="trackerbulkhead.xml"/> + <Include ref="trackerother.xml"/> <Include ref="trackerpixbar.xml"/> + <Include ref="tracker.xml"/> + <Include ref="trackertob.xml"/> </IncludeSection> <PosPartSection label=""> -<!-- - <PosPart copyNumber="1"> - <rParent name="world_volume"/> - <rChild name="tec:TEC"/> - </PosPart> ---> <PosPart copyNumber="2"> <rParent name="world_volume"/> <rChild name="tracker:Tracker"/> diff --git a/examples/DDCMS/data/pixfwdBlade.xml b/examples/DDCMS/data/pixfwdBlade.xml index 6588cc68bf00ebe63c42e99c5a249f0415894147..b8b8c04509084378b454459b9556fa9ccc8edee3 100644 --- a/examples/DDCMS/data/pixfwdBlade.xml +++ b/examples/DDCMS/data/pixfwdBlade.xml @@ -45,7 +45,7 @@ --> <!-- Blade geometry parameters: Input from drawings --> - <ConstantsSection label="Input" eval="true"> + <ConstantsSection label="Common" eval="true"> <Constant name="T01" value="0.5*mm"/> <!-- Blade01.gif --> <Constant name="T02" value="3.0*mm"/> diff --git a/examples/DDDB/CMakeLists.txt b/examples/DDDB/CMakeLists.txt index 01c92760a123af0018e38929c7ab69537e57c2c4..a805bcb8c1980e9fe0b85d934648e69d41663a76 100644 --- a/examples/DDDB/CMakeLists.txt +++ b/examples/DDDB/CMakeLists.txt @@ -31,6 +31,7 @@ if (DD4HEP_USE_XERCESC) ) #---Package installation procedure(s) ----------------------------------------- install ( PROGRAMS scripts/run_dddb.sh DESTINATION bin) + install ( PROGRAMS scripts/display_dddb.sh DESTINATION bin) install ( PROGRAMS scripts/extract_dddb.sh DESTINATION bin) install ( FILES data/DDDB.tar.gz DESTINATION examples/DDDB) #---Testing-------------------------------------------------------------------- diff --git a/examples/DDDB/scripts/display_dddb.sh b/examples/DDDB/scripts/display_dddb.sh new file mode 100755 index 0000000000000000000000000000000000000000..fdb7390eae1b5d400adc920c86d3fb1204aadf93 --- /dev/null +++ b/examples/DDDB/scripts/display_dddb.sh @@ -0,0 +1,28 @@ +#!/bin/bash +#========================================================================== +# 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 +# +#========================================================================== +if test -z "${DDDB_DIR}"; then + target=/tmp; + if test -n "$USER"; then + target=/tmp/$USER; + fi; + DDDB_DIR=${target}/DDDB; +fi; +export DDDB_DIR; +. ${DD4hepINSTALL}/bin/run_test_DDDB.sh \ + ${DD4hepINSTALL}/bin/run_dddb.sh \ + -config DD4hep_ConditionsManagerInstaller \ + -visualize \ + -attr file:${DDDB_DIR}/Visattrs.xml $* diff --git a/examples/DDDB/scripts/run_dddb.sh b/examples/DDDB/scripts/run_dddb.sh index 9911c2e16ab9333c7e8bff7f73706ef1a0d03f5c..1ed14f98fc212f0a3d0a1abe0c1204ae57678d5c 100755 --- a/examples/DDDB/scripts/run_dddb.sh +++ b/examples/DDDB/scripts/run_dddb.sh @@ -27,6 +27,7 @@ if test -z "${DDDB_DIR}"; then fi; DDDB_DIR=${target}/DDDB; fi; +export DDDB_DIR; loader="-loader DDDB_FileReader"; params="-params file:${DDDB_DIR}/Parameters.xml"; input="-input file:${DDDB_DIR}/DDDB/lhcb.xml";