diff --git a/DDAlign/include/DDAlign/AlignmentCache.h b/DDAlign/include/DDAlign/AlignmentCache.h index a153b129b3fcac98a022d8d34521be98c1aeb6ca..e83bb7490b9dad49af5249652f6c0736137729c6 100644 --- a/DDAlign/include/DDAlign/AlignmentCache.h +++ b/DDAlign/include/DDAlign/AlignmentCache.h @@ -26,7 +26,7 @@ namespace DD4hep { class LCDD; /// Class caching all known alignment operations for one LCDD instance. - /** + /** * Internally the instances are fragmented to subdetectors defined * by the next-to-top level detector elements. * @@ -78,7 +78,7 @@ namespace DD4hep { static void install(LCDD& lcdd); /// Unregister and delete a tree instance static void uninstall(LCDD& lcdd); - + /// Add reference count int addRef(); /// Release object. If reference count goes to NULL, automatic deletion is triggered. diff --git a/DDAlign/include/DDAlign/AlignmentOperators.h b/DDAlign/include/DDAlign/AlignmentOperators.h index b37a9fb3c493fc351e09e51e11948a44135121d2..ff31b8b177a76635539c79730373c3ed732bab4f 100644 --- a/DDAlign/include/DDAlign/AlignmentOperators.h +++ b/DDAlign/include/DDAlign/AlignmentOperators.h @@ -37,9 +37,9 @@ namespace DD4hep { typedef std::map<std::string,std::pair<TGeoPhysicalNode*,Entry*> > Nodes; AlignmentCache& cache; Nodes& nodes; - public: + public: /// Initializing functor constructor - AlignmentOperator(AlignmentCache& c, Nodes& n) : cache(c), nodes(n) {} + AlignmentOperator(AlignmentCache& c, Nodes& n) : cache(c), nodes(n) {} /// Insert alignment entry void insert(Alignment alignment) const; }; @@ -51,10 +51,10 @@ namespace DD4hep { * \ingroup DD4HEP_ALIGN */ class AlignmentSelector : public AlignmentOperator { - public: + public: const Entries& entries; /// Initializing functor constructor - AlignmentSelector(AlignmentCache& c, Nodes& n, const Entries& e) : AlignmentOperator(c,n), entries(e) {} + AlignmentSelector(AlignmentCache& c, Nodes& n, const Entries& e) : AlignmentOperator(c,n), entries(e) {} ~AlignmentSelector() { } const AlignmentSelector& reset() const { nodes.clear(); return *this; } /// Function callback for cache entries @@ -70,9 +70,9 @@ namespace DD4hep { * \ingroup DD4HEP_ALIGN */ template <typename T> class AlignmentActor : public AlignmentOperator { - public: + public: /// Initializing functor constructor - AlignmentActor(AlignmentCache& c, Nodes& n) : AlignmentOperator(c,n) { init(); } + AlignmentActor(AlignmentCache& c, Nodes& n) : AlignmentOperator(c,n) { init(); } void init() {} /// Function callback for entries void operator()(Nodes::value_type& e) const; diff --git a/DDAlign/include/DDAlign/AlignmentStack.h b/DDAlign/include/DDAlign/AlignmentStack.h index af912a3846483a09bee5d3957b3b8ee772527b60..47e48701d463a6af0ade6dfb8ea6fa3d79e630db 100644 --- a/DDAlign/include/DDAlign/AlignmentStack.h +++ b/DDAlign/include/DDAlign/AlignmentStack.h @@ -34,13 +34,13 @@ namespace DD4hep { friend class std::auto_ptr<AlignmentStack>; enum { - OVERLAP_DEFINED = 1<<0, - MATRIX_DEFINED = 1<<1, - CHECKOVL_DEFINED = 1<<2, - CHECKOVL_VALUE = 1<<3, - RESET_VALUE = 1<<4, - RESET_CHILDREN = 1<<5, - ____LLLAST = 1<<31 + OVERLAP_DEFINED = 1<<0, + MATRIX_DEFINED = 1<<1, + CHECKOVL_DEFINED = 1<<2, + CHECKOVL_VALUE = 1<<3, + RESET_VALUE = 1<<4, + RESET_CHILDREN = 1<<5, + ____LLLAST = 1<<31 } Flags; /// Stack entry definition @@ -50,64 +50,64 @@ namespace DD4hep { * \ingroup DD4HEP_ALIGN */ struct StackEntry { - /// Reference to the detector element - DetElement detector; - /// 3-D Transformation matrix for the volume - Transform3D transform; - /// Path to the misaligned volume - std::string path; - /// Parameter for overlap checking - double overlap; - /// Flag containing various encodings - int flag; - - /// Fully initializing constructor + /// Reference to the detector element + DetElement detector; + /// 3-D Transformation matrix for the volume + Transform3D transform; + /// Path to the misaligned volume + std::string path; + /// Parameter for overlap checking + double overlap; + /// Flag containing various encodings + int flag; + + /// Fully initializing constructor StackEntry(const DetElement& p, const std::string& placement, const Transform3D& t, double ov, int flg); - /// Constructor with partial initialization - StackEntry(DetElement element, bool rst=true, bool rst_children=true); - /// Constructor with partial initialization - StackEntry(DetElement element, const Transform3D& trafo, bool rst=true, bool rst_children=true); - /// Constructor with partial initialization - StackEntry(DetElement element, const Position& translation, bool rst=true, bool rst_children=true); - /// Constructor with partial initialization - StackEntry(DetElement element, const RotationZYX& rot, bool rst=true, bool rst_children=true); - /// Constructor with partial initialization - StackEntry(DetElement element, const Position& translation, const RotationZYX& rot, bool rst=true, bool rst_children=true); - /// Copy constructor - StackEntry(const StackEntry& e); - /// Default destructor - virtual ~StackEntry(); - - /// Assignment operator - StackEntry& operator=(const StackEntry& e); - - /// Check a given flag - bool checkFlag(int mask) const { return (flag&mask) == mask; } - /// Check if the overlap flag checking is enabled - bool overlapDefined() const { return checkFlag(OVERLAP_DEFINED); } - /// Check if the overlap flag checking is enabled - bool checkOverlap() const { return checkFlag(CHECKOVL_DEFINED); } - /// Check if the overalp value is present - bool overlapValue() const { return checkFlag(CHECKOVL_VALUE); } - /// Check if this alignment entry has a non unitary transformation matrix - bool hasMatrix() const { return checkFlag(MATRIX_DEFINED); } - /// Check flag if the node location should be reset - bool needsReset() const { return checkFlag(RESET_VALUE); } - /// Check flag if the node location and all children should be reset - bool resetChildren() const { return checkFlag(RESET_CHILDREN); } - - /// Attach transformation object - StackEntry& setTransformation(const Transform3D& trafo); - /// Instruct entry to ignore the transformation - StackEntry& clearTransformation(); - /// Set flag to reset the entry to it's ideal geometrical position - StackEntry& setReset(bool new_value=true); - /// Set flag to reset the entry's children to their ideal geometrical position - StackEntry& setResetChildren(bool new_value=true); - /// Set flag to check overlaps - StackEntry& setOverlapCheck(bool new_value=true); - /// Set the precision for the overlap check (otherwise the default is 0.001 cm) - StackEntry& setOverlapPrecision(double precision=0.001); + /// Constructor with partial initialization + StackEntry(DetElement element, bool rst=true, bool rst_children=true); + /// Constructor with partial initialization + StackEntry(DetElement element, const Transform3D& trafo, bool rst=true, bool rst_children=true); + /// Constructor with partial initialization + StackEntry(DetElement element, const Position& translation, bool rst=true, bool rst_children=true); + /// Constructor with partial initialization + StackEntry(DetElement element, const RotationZYX& rot, bool rst=true, bool rst_children=true); + /// Constructor with partial initialization + StackEntry(DetElement element, const Position& translation, const RotationZYX& rot, bool rst=true, bool rst_children=true); + /// Copy constructor + StackEntry(const StackEntry& e); + /// Default destructor + virtual ~StackEntry(); + + /// Assignment operator + StackEntry& operator=(const StackEntry& e); + + /// Check a given flag + bool checkFlag(int mask) const { return (flag&mask) == mask; } + /// Check if the overlap flag checking is enabled + bool overlapDefined() const { return checkFlag(OVERLAP_DEFINED); } + /// Check if the overlap flag checking is enabled + bool checkOverlap() const { return checkFlag(CHECKOVL_DEFINED); } + /// Check if the overalp value is present + bool overlapValue() const { return checkFlag(CHECKOVL_VALUE); } + /// Check if this alignment entry has a non unitary transformation matrix + bool hasMatrix() const { return checkFlag(MATRIX_DEFINED); } + /// Check flag if the node location should be reset + bool needsReset() const { return checkFlag(RESET_VALUE); } + /// Check flag if the node location and all children should be reset + bool resetChildren() const { return checkFlag(RESET_CHILDREN); } + + /// Attach transformation object + StackEntry& setTransformation(const Transform3D& trafo); + /// Instruct entry to ignore the transformation + StackEntry& clearTransformation(); + /// Set flag to reset the entry to it's ideal geometrical position + StackEntry& setReset(bool new_value=true); + /// Set flag to reset the entry's children to their ideal geometrical position + StackEntry& setResetChildren(bool new_value=true); + /// Set flag to check overlaps + StackEntry& setOverlapCheck(bool new_value=true); + /// Set the precision for the overlap check (otherwise the default is 0.001 cm) + StackEntry& setOverlapPrecision(double precision=0.001); }; typedef std::map<std::string, StackEntry*> Stack; @@ -117,13 +117,13 @@ namespace DD4hep { /// Default constructor AlignmentStack(); - /// Default destructor. Careful with this one: + /// Default destructor. Careful with this one: virtual ~AlignmentStack(); public: /// Static client accessor - static AlignmentStack& get(); + static AlignmentStack& get(); /// Create an alignment stack instance. The creation of a second instance will be refused. static void create(); /// Check existence of alignment stack diff --git a/DDAlign/include/DDAlign/AlignmentTags.h b/DDAlign/include/DDAlign/AlignmentTags.h index 7c6041d17fcf877cd185081d05688d04b1790a56..c93c38535a5f799d55e583fdfc0965f40fb4e9d4 100644 --- a/DDAlign/include/DDAlign/AlignmentTags.h +++ b/DDAlign/include/DDAlign/AlignmentTags.h @@ -11,13 +11,13 @@ // Framework include files #include "XML/XMLElements.h" -#ifndef UNICODE +#ifndef UNICODE #define UNICODE(x) extern const Tag_t Unicode_##x #endif // Unicode tags known to the alignment section namespace DD4hep { - /// Namespace for the AIDA detector description toolkit supporting XML utilities + /// Namespace for the AIDA detector description toolkit supporting XML utilities namespace XML { // Alignment tags diff --git a/DDAlign/include/DDAlign/AlignmentTransaction.h b/DDAlign/include/DDAlign/AlignmentTransaction.h index f77c07bbb08846e71a559ba9de6cd24b6949ecaf..6a18b7e1c8e51188275c852a0ea78c85309dc5dd 100644 --- a/DDAlign/include/DDAlign/AlignmentTransaction.h +++ b/DDAlign/include/DDAlign/AlignmentTransaction.h @@ -38,7 +38,7 @@ namespace DD4hep { LCDD& lcdd; /// Reference to the alignment cache AlignmentCache* m_cache; - + /// Default constructor AlignmentTransaction(LCDD& l, const XML::Handle_t& e); /// Default destructor diff --git a/DDAlign/include/DDAlign/AlignmentWriter.h b/DDAlign/include/DDAlign/AlignmentWriter.h index b6511408c434a26c58ddf7e797724c60c43e0a40..abe2e758d55b2609fbafcdf6f167901ea6e4f379 100644 --- a/DDAlign/include/DDAlign/AlignmentWriter.h +++ b/DDAlign/include/DDAlign/AlignmentWriter.h @@ -57,4 +57,4 @@ namespace DD4hep { } // End namespace XML } // End namespace DD4hep #endif // DD4HEP_DDALIGN_ALIGNMENTWRITER_H - + diff --git a/DDAlign/include/DDAlign/DetectorAlignment.h b/DDAlign/include/DDAlign/DetectorAlignment.h index 642f58c67e01b8e3a9205676ba428bda473f2652..e0ba76a9b02187e313ad66c5885f11164d5b2067 100644 --- a/DDAlign/include/DDAlign/DetectorAlignment.h +++ b/DDAlign/include/DDAlign/DetectorAlignment.h @@ -25,7 +25,7 @@ namespace DD4hep { class DetElement; /// DetectorAlignment. DetElement Handle supporting alignment operations. - /** + /** * \author M.Frank * \version 1.0 * \ingroup DD4HEP_ALIGN diff --git a/DDAlign/src/AlignmentCache.cpp b/DDAlign/src/AlignmentCache.cpp index 7c6933f271ceb2bcdf43fc58b7c84a0e66d115d4..557ff9f2ed2b4dc3f9f1cf9f3f9e289a2d5e868b 100644 --- a/DDAlign/src/AlignmentCache.cpp +++ b/DDAlign/src/AlignmentCache.cpp @@ -49,8 +49,8 @@ AlignmentCache::~AlignmentCache() { releaseObjects(m_detectors)(); m_cache.clear(); printout(INFO,"AlignmentCache", - "Destroy cache for subdetector %s [%d section(s), %d entrie(s)]", - m_sdPath.c_str(),nsect,nentries); + "Destroy cache for subdetector %s [%d section(s), %d entrie(s)]", + m_sdPath.c_str(),nsect,nentries); } /// Add reference count @@ -73,7 +73,7 @@ bool AlignmentCache::insert(Alignment alignment) { unsigned int index = hash32(pn->GetName()+m_sdPathLen); Cache::const_iterator i = m_cache.find(index); printout(ALWAYS,"AlignmentCache","Section: %s adding entry: %s", - name().c_str(),alignment->GetName()); + name().c_str(),alignment->GetName()); if ( i == m_cache.end() ) { m_cache[index] = pn; return true; @@ -124,7 +124,7 @@ Alignment AlignmentCache::get(const string& path_name) const { return Alignment(0); } -/// Return all entries matching a given path. +/// Return all entries matching a given path. vector<Alignment> AlignmentCache::matches(const string& match, bool exclude_exact) const { vector<Alignment> result; AlignmentCache* c = section(match); @@ -135,8 +135,8 @@ vector<Alignment> AlignmentCache::matches(const string& match, bool exclude_exac const Cache::value_type& v = *i; const char* n = v.second->GetName(); if ( 0 == ::strncmp(n,match.c_str(),len) ) { - if ( exclude_exact && len == ::strlen(n) ) continue; - result.push_back(Alignment(v.second)); + if ( exclude_exact && len == ::strlen(n) ) continue; + result.push_back(Alignment(v.second)); } } } @@ -169,7 +169,7 @@ void AlignmentCache::closeTransaction() { return; } printout(WARNING,"Alignment<alignment>", - "Request to close a non-existing alignmant transaction."); + "Request to close a non-existing alignmant transaction."); } /// Create and install a new instance tree diff --git a/DDAlign/src/AlignmentOperators.cpp b/DDAlign/src/AlignmentOperators.cpp index 4c6a818e4f222c20c9c0df4091e3f9934e6a0088..df865b0c8d27cd9be753b8d866cce177a5f4c90c 100644 --- a/DDAlign/src/AlignmentOperators.cpp +++ b/DDAlign/src/AlignmentOperators.cpp @@ -38,15 +38,15 @@ void AlignmentSelector::operator()(const Cache::value_type& e) const { const char* p = pn->GetName(); bool reset_children = e->resetChildren(); if ( reset_children && ::strstr(p,e->path.c_str()) == p ) { - nodes.insert(make_pair(p,make_pair(pn,e))); - break; + nodes.insert(make_pair(p,make_pair(pn,e))); + break; } else if ( e->path == p ) { - nodes.insert(make_pair(p,make_pair(pn,e))); - break; + nodes.insert(make_pair(p,make_pair(pn,e))); + break; } } - } + } } template <> void AlignmentActor<DDAlign_standard_operations::node_print>::init() { @@ -57,7 +57,7 @@ template <> void AlignmentActor<DDAlign_standard_operations::node_print>::operat TGeoPhysicalNode* p = n.second.first; Entry* e = n.second.second; printout(ALWAYS,"AlignmentCache","Need to reset entry:%s - %s [needsReset:%s, hasMatrix:%s]", - p->GetName(),e->path.c_str(),yes_no(e->needsReset()),yes_no(e->hasMatrix())); + p->GetName(),e->path.c_str(),yes_no(e->needsReset()),yes_no(e->hasMatrix())); } template <> void AlignmentActor<DDAlign_standard_operations::node_delete>::operator()(Nodes::value_type& n) const { @@ -75,21 +75,21 @@ template <> void AlignmentActor<DDAlign_standard_operations::node_reset>::operat TGeoMatrix* mm = node->GetMatrix(); // Node's relative matrix np += string("/")+node->GetName(); if ( !mm->IsIdentity() && i > 0 ) { // Ignore the 'world', is identity anyhow - Alignment a = cache.get(np); - if ( a.isValid() ) { - printout(ALWAYS,"AlignmentActor<reset>","Correct path:%s leaf:%s",p->GetName(),np.c_str()); - TGeoHMatrix* glob = p->GetMatrix(i-1); - if ( a.isValid() && i!=nLvl ) { - *mm = *(a->GetOriginalMatrix()); - } - else if ( i==nLvl ) { - TGeoHMatrix* hm = dynamic_cast<TGeoHMatrix*>(mm); - TGeoMatrix* org = p->GetOriginalMatrix(); - hm->SetTranslation(org->GetTranslation()); - hm->SetRotation(org->GetRotationMatrix()); - } - *glob *= *mm; - } + Alignment a = cache.get(np); + if ( a.isValid() ) { + printout(ALWAYS,"AlignmentActor<reset>","Correct path:%s leaf:%s",p->GetName(),np.c_str()); + TGeoHMatrix* glob = p->GetMatrix(i-1); + if ( a.isValid() && i!=nLvl ) { + *mm = *(a->GetOriginalMatrix()); + } + else if ( i==nLvl ) { + TGeoHMatrix* hm = dynamic_cast<TGeoHMatrix*>(mm); + TGeoMatrix* org = p->GetOriginalMatrix(); + hm->SetTranslation(org->GetTranslation()); + hm->SetRotation(org->GetRotationMatrix()); + } + *glob *= *mm; + } } } } @@ -105,17 +105,17 @@ template <> void AlignmentActor<DDAlign_standard_operations::node_align>::operat string det_placement = det.placementPath(); if ( !valid && !has_matrix ) { - cout << "++++ SKIP ALIGNMENT: ++++ " << e.path - << " DE:" << det_placement - << " Valid:" << yes_no(valid) - << " Matrix:" << yes_no(has_matrix) << endl; + cout << "++++ SKIP ALIGNMENT: ++++ " << e.path + << " DE:" << det_placement + << " Valid:" << yes_no(valid) + << " Matrix:" << yes_no(has_matrix) << endl; /* */ return; } - cout << "++++ " << e.path - << " DE:" << det_placement - << " Valid:" << yes_no(valid) + cout << "++++ " << e.path + << " DE:" << det_placement + << " Valid:" << yes_no(valid) << " Matrix:" << yes_no(has_matrix) << endl; /* */ @@ -124,18 +124,18 @@ template <> void AlignmentActor<DDAlign_standard_operations::node_align>::operat Alignment alignment; bool is_not_volume = e.path == det_placement; if ( check && overlap ) { - alignment = is_not_volume + alignment = is_not_volume ? ad.align(e.transform, e.overlapValue(), e.overlap) : ad.align(e.path, e.transform, e.overlapValue(), e.overlap); } else if ( check ) { - alignment = is_not_volume + alignment = is_not_volume ? ad.align(e.transform, e.overlapValue()) : ad.align(e.path, e.transform, e.overlapValue()); } else { alignment = is_not_volume ? ad.align(e.transform) : ad.align(e.path, e.transform); - } + } if ( alignment.isValid() ) { insert(alignment); return; @@ -144,53 +144,53 @@ template <> void AlignmentActor<DDAlign_standard_operations::node_align>::operat } #if 0 - void alignment_reset_dbg(const string& path, const Alignment& a) { - TGeoPhysicalNode* n = a.ptr(); - cout << " +++++++++++++++++++++++++++++++ " << path << endl; - cout << " +++++ Misaligned physical node: " << endl; - n->Print(); - string np; - if ( n->IsAligned() ) { - for (Int_t i=0; i<=n->GetLevel(); i++) { - TGeoMatrix* mm = n->GetNode(i)->GetMatrix(); - np += "/"; - np += n->GetNode(i)->GetName(); - if ( mm->IsIdentity() ) continue; - if ( i == 0 ) continue; +void alignment_reset_dbg(const string& path, const Alignment& a) { + TGeoPhysicalNode* n = a.ptr(); + cout << " +++++++++++++++++++++++++++++++ " << path << endl; + cout << " +++++ Misaligned physical node: " << endl; + n->Print(); + string np; + if ( n->IsAligned() ) { + for (Int_t i=0; i<=n->GetLevel(); i++) { + TGeoMatrix* mm = n->GetNode(i)->GetMatrix(); + np += "/"; + np += n->GetNode(i)->GetName(); + if ( mm->IsIdentity() ) continue; + if ( i == 0 ) continue; - TGeoHMatrix* glob = n->GetMatrix(i-1); - NodeMap::const_iterator j=original_matrices.find(np); - if ( j != original_matrices.end() && i!=n->GetLevel() ) { - cout << " +++++ Patch Level: " << i << np << endl; - *mm = *((*j).second); - } - else { - if ( i==n->GetLevel() ) { - cout << " +++++ Level: " << i << np << " --- Original matrix: " << endl; - n->GetOriginalMatrix()->Print(); - cout << " +++++ Level: " << i << np << " --- Local matrix: " << endl; - mm->Print(); - TGeoHMatrix* hm = dynamic_cast<TGeoHMatrix*>(mm); - hm->SetTranslation(n->GetOriginalMatrix()->GetTranslation()); - hm->SetRotation(n->GetOriginalMatrix()->GetRotationMatrix()); - cout << " +++++ Level: " << i << np << " --- New local matrix" << endl; - mm->Print(); - } - else { - cout << " +++++ Level: " << i << np << " --- Keep matrix " << endl; - mm->Print(); - } - } - cout << " +++++ Level: " << i << np << " --- Global matrix: " << endl; - glob->Print(); - *glob *= *mm; - cout << " +++++ Level: " << i << np << " --- New global matrix: " << endl; - glob->Print(); - } + TGeoHMatrix* glob = n->GetMatrix(i-1); + NodeMap::const_iterator j=original_matrices.find(np); + if ( j != original_matrices.end() && i!=n->GetLevel() ) { + cout << " +++++ Patch Level: " << i << np << endl; + *mm = *((*j).second); } - cout << "\n\n\n +++++ physical node (full): " << np << endl; - n->Print(); - cout << " +++++ physical node (global): " << np << endl; - n->GetMatrix()->Print(); + else { + if ( i==n->GetLevel() ) { + cout << " +++++ Level: " << i << np << " --- Original matrix: " << endl; + n->GetOriginalMatrix()->Print(); + cout << " +++++ Level: " << i << np << " --- Local matrix: " << endl; + mm->Print(); + TGeoHMatrix* hm = dynamic_cast<TGeoHMatrix*>(mm); + hm->SetTranslation(n->GetOriginalMatrix()->GetTranslation()); + hm->SetRotation(n->GetOriginalMatrix()->GetRotationMatrix()); + cout << " +++++ Level: " << i << np << " --- New local matrix" << endl; + mm->Print(); + } + else { + cout << " +++++ Level: " << i << np << " --- Keep matrix " << endl; + mm->Print(); + } + } + cout << " +++++ Level: " << i << np << " --- Global matrix: " << endl; + glob->Print(); + *glob *= *mm; + cout << " +++++ Level: " << i << np << " --- New global matrix: " << endl; + glob->Print(); } + } + cout << "\n\n\n +++++ physical node (full): " << np << endl; + n->Print(); + cout << " +++++ physical node (global): " << np << endl; + n->GetMatrix()->Print(); +} #endif diff --git a/DDAlign/src/AlignmentParser.cpp b/DDAlign/src/AlignmentParser.cpp index c17ab8f5995b29e5150958988dbad457251ed9b2..9a17a2a3f6d2722fc9df7111e0d53667ed7208fd 100644 --- a/DDAlign/src/AlignmentParser.cpp +++ b/DDAlign/src/AlignmentParser.cpp @@ -49,7 +49,7 @@ namespace DD4hep { template <> void Converter<alignment>::operator()(xml_h seq) const; template <> void Converter<detelement>::operator()(xml_h seq) const; template <> void Converter<include_file>::operator()(xml_h seq) const; -} +} using namespace std; using namespace DD4hep; @@ -57,7 +57,7 @@ using namespace DD4hep::Geometry; /** Convert rotation objects * - * <rotation x="0.5" y="0" z="0"/> + * <rotation x="0.5" y="0" z="0"/> * * @author M.Frank * @version 1.0 @@ -68,13 +68,13 @@ template <> void Converter<rotation>::operator()(xml_h e) const { RotationZYX* v = (RotationZYX*)param; v->SetComponents(r.z(), r.y(), r.x()); printout(INFO,"Alignment<rotation>", - " Rotation: x=%9.3f y=%9.3f z=%9.3f phi=%7.4f psi=%7.4f theta=%7.4f", - r.x(), r.y(), r.z(), v->Phi(), v->Psi(), v->Theta()); + " Rotation: x=%9.3f y=%9.3f z=%9.3f phi=%7.4f psi=%7.4f theta=%7.4f", + r.x(), r.y(), r.z(), v->Phi(), v->Psi(), v->Theta()); } /** Convert position objects * - * <position x="0.5" y="0" z="0"/> + * <position x="0.5" y="0" z="0"/> * * @author M.Frank * @version 1.0 @@ -85,12 +85,12 @@ template <> void Converter<position>::operator()(xml_h e) const { Position* v = (Position*)param; v->SetXYZ(p.x(), p.y(), p.z()); printout(INFO,"Alignment<position>"," Position: x=%9.3f y=%9.3f z=%9.3f", - v->X(), v->Y(), v->Z()); + v->X(), v->Y(), v->Z()); } /** Convert pivot objects * - * <pivot x="0.5" y="0" z="0"/> + * <pivot x="0.5" y="0" z="0"/> * * @author M.Frank * @version 1.0 @@ -108,20 +108,20 @@ template <> void Converter<pivot>::operator()(xml_h e) const { * * A generic alignment transformation is defined by * - a translation in 3D space identified in XML as a - * <position/> element - * - a rotation in 3D space around a pivot point specified in XML by - * 2 elements: the <rotation/> and the <pivot/> element. - * The specification of any of the elements is optional: + * <position/> element + * - a rotation in 3D space around a pivot point specified in XML by + * 2 elements: the <rotation/> and the <pivot/> element. + * The specification of any of the elements is optional: * - The absence of a translation implies the origine (0,0,0) * - The absence of a pivot point implies the origine (0,0,0) - * - The absence of a rotation implies the identity rotation. - * Any supplied pivot point in this case is ignored. + * - The absence of a rotation implies the identity rotation. + * Any supplied pivot point in this case is ignored. * - * <xx> - * <position x="0" y="0" z="0.0001*mm"/> - * <rotation x="0" y="0" z="0"/> - * <pivot x="0" y="0" z="100"/> - * </xx> + * <xx> + * <position x="0" y="0" z="0.0001*mm"/> + * <rotation x="0" y="0" z="0"/> + * <pivot x="0" y="0" z="100"/> + * </xx> * * @author M.Frank * @version 1.0 @@ -134,7 +134,7 @@ template <> void Converter<transform3d>::operator()(xml_h e) const { Translation3D piv; xml_h child_rot, child_pos, child_piv; Data* tr = (Data*)param; - + if ( (child_pos=e.child(_U(position),false)) ) Converter<position>(lcdd,&pos)(child_pos); if ( (child_rot=e.child(_U(rotation),false)) ) { @@ -162,14 +162,14 @@ typedef AlignmentStack::StackEntry StackEntry; /** Convert volume objects * - * <volume subpath="layer4_0"> - * <position x="0" y="0" z="0"/> - * <rotation x="0.5" y="0.1" z="0.2"/> - * <pivot x="0" y="0" z="100"/> + * <volume subpath="layer4_0"> + * <position x="0" y="0" z="0"/> + * <rotation x="0.5" y="0.1" z="0.2"/> + * <pivot x="0" y="0" z="100"/> * <volume> * ... * <volume> - * </volume> + * </volume> * * @author M.Frank * @version 1.0 @@ -189,7 +189,7 @@ template <> void Converter<volume>::operator()(xml_h e) const { string placementPath = subpath[0]=='/' ? subpath : eltPlacement + "/" + subpath; printout(INFO,"Alignment<volume>"," path:%s placement:%s reset:%s children:%s", - subpath.c_str(), placementPath.c_str(), yes_no(reset), yes_no(reset_dau)); + subpath.c_str(), placementPath.c_str(), yes_no(reset), yes_no(reset_dau)); Converter<transform3d>(lcdd,&trafo)(e); int flags = 0; @@ -209,13 +209,13 @@ template <> void Converter<volume>::operator()(xml_h e) const { /** Convert detelement objects * * Function entry expects as a parameter a valid DetElement handle - * pointing to the subdetector, which detector elements should be + * pointing to the subdetector, which detector elements should be * realigned. * * <detelement path="/world/TPC/TPC_SideA/TPC_SideA_sector02"> * <position x="0" y="0" z="0"/> - * <rotation x="0.5" y="0" z="0"/> - * <pivot x="0" y="0" z="100"/> + * <rotation x="0.5" y="0" z="0"/> + * <pivot x="0" y="0" z="100"/> * </detelement> * * @author M.Frank @@ -253,10 +253,10 @@ template <> void Converter<detelement>::operator()(xml_h e) const { if ( check_val ) flags |= AlignmentStack::CHECKOVL_VALUE; printout(INFO,"Alignment<detelement>","path:%s [%s] placement:%s matrix:%s reset:%s children:%s", - path.c_str(), - elt.isValid() ? elt.path().c_str() : "-----", - placementPath.c_str(), - yes_no(trafo.first), yes_no(reset), yes_no(reset_dau)); + path.c_str(), + elt.isValid() ? elt.path().c_str() : "-----", + placementPath.c_str(), + yes_no(trafo.first), yes_no(reset), yes_no(reset_dau)); auto_ptr<StackEntry> entry(new StackEntry(elt,placementPath,trafo.second,ovl,flags)); AlignmentStack::insert(entry); @@ -271,7 +271,7 @@ template <> void Converter<detelement>::operator()(xml_h e) const { * * <detelement path="/world/TPC/TPC_SideA/TPC_SideA_sector02"> * <position x="0" y="0" z="0"/> - * <rotation x="0.5" y="0" z="0"/> + * <rotation x="0.5" y="0" z="0"/> * </detelement> * * @author M.Frank @@ -282,7 +282,7 @@ template <> void Converter<include_file>::operator()(xml_h element) const { XML::DocumentHolder doc(XML::DocumentHandler().load(element, element.attr_value(_U(ref)))); xml_h node = doc.root(); string tag = node.tag(); - if ( tag == "alignment" ) + if ( tag == "alignment" ) Converter<alignment>(lcdd,param)(node); else if ( tag == "detelement" ) Converter<detelement>(lcdd,param)(node); diff --git a/DDAlign/src/AlignmentStack.cpp b/DDAlign/src/AlignmentStack.cpp index 8f60b62fea85d3c8aab6a6fa5268cc592feb13ec..e089e6a2a7b05b1595a95c95b5439b51fc23214e 100644 --- a/DDAlign/src/AlignmentStack.cpp +++ b/DDAlign/src/AlignmentStack.cpp @@ -57,7 +57,7 @@ AlignmentStack::StackEntry::StackEntry(DetElement element, const Transform3D& tr /// Constructor with partial initialization AlignmentStack::StackEntry::StackEntry(DetElement element, const Position& translation, bool rst, bool rst_children) -: detector(element), transform(translation), overlap(0.001), flag(0) + : detector(element), transform(translation), overlap(0.001), flag(0) { InstanceCount::increment(this); flag |= MATRIX_DEFINED; @@ -68,7 +68,7 @@ AlignmentStack::StackEntry::StackEntry(DetElement element, const Position& trans /// Constructor with partial initialization AlignmentStack::StackEntry::StackEntry(DetElement element, const RotationZYX& rot, bool rst, bool rst_children) -: detector(element), transform(rot), overlap(0.001), flag(0) + : detector(element), transform(rot), overlap(0.001), flag(0) { InstanceCount::increment(this); flag |= MATRIX_DEFINED; @@ -78,7 +78,7 @@ AlignmentStack::StackEntry::StackEntry(DetElement element, const RotationZYX& ro } /// Constructor with partial initialization -AlignmentStack::StackEntry::StackEntry(DetElement element, const Position& translation, const RotationZYX& rot, bool rst, bool rst_children) +AlignmentStack::StackEntry::StackEntry(DetElement element, const Position& translation, const RotationZYX& rot, bool rst, bool rst_children) : detector(element), transform(rot,translation), overlap(0.001), flag(0) { InstanceCount::increment(this); @@ -90,7 +90,7 @@ AlignmentStack::StackEntry::StackEntry(DetElement element, const Position& trans /// Copy constructor AlignmentStack::StackEntry::StackEntry(const StackEntry& e) -: detector(e.detector), transform(e.transform), path(e.path), overlap(e.overlap), flag(e.flag) + : detector(e.detector), transform(e.transform), path(e.path), overlap(e.overlap), flag(e.flag) { InstanceCount::increment(this); } @@ -217,7 +217,7 @@ bool AlignmentStack::add(auto_ptr<StackEntry>& entry) { // Need to make some checks BEFORE insertion if ( !entry->detector.isValid() ) { - throw runtime_error("AlignmentStack> Invalid alignment entry [No such detector]"); + throw runtime_error("AlignmentStack> Invalid alignment entry [No such detector]"); } printout(INFO,"AlignmentStack","Add node:%s",entry->path.c_str()); m_stack.insert(make_pair(entry->path,entry.get())); @@ -225,7 +225,7 @@ bool AlignmentStack::add(auto_ptr<StackEntry>& entry) { return true; } throw runtime_error("AlignmentStack> The entry with path "+entry->path+ - " cannot be re-aligned twice in one transaction."); + " cannot be re-aligned twice in one transaction."); } throw runtime_error("AlignmentStack> Attempt to apply an invalid alignment entry."); } @@ -239,7 +239,7 @@ auto_ptr<AlignmentStack::StackEntry> AlignmentStack::pop() { return auto_ptr<StackEntry>(e); } throw runtime_error("AlignmentStack> Alignment stack is empty. " - "Cannot pop entries - check size first!"); + "Cannot pop entries - check size first!"); } /// Get all pathes to be aligned diff --git a/DDAlign/src/AlignmentWriter.cpp b/DDAlign/src/AlignmentWriter.cpp index e11cf63db0b8ca5c5d7e4be4139f925a69d9c9e3..85afe6d4522069df9d343bc76c07d6c1a2a14ad8 100644 --- a/DDAlign/src/AlignmentWriter.cpp +++ b/DDAlign/src/AlignmentWriter.cpp @@ -75,7 +75,7 @@ void AlignmentWriter::addNode(XML::Element elt, Alignment a) const { //mat.Print(); if ( fabs(t[0]) > numeric_limits<double>::epsilon() || fabs(t[1]) > numeric_limits<double>::epsilon() || - fabs(t[2]) > numeric_limits<double>::epsilon() ) { + fabs(t[2]) > numeric_limits<double>::epsilon() ) { XML::Element e = XML::Element(elt.document(),_U(position)); e.setAttr(_U(x),t[0]); e.setAttr(_U(y),t[1]); @@ -85,9 +85,9 @@ void AlignmentWriter::addNode(XML::Element elt, Alignment a) const { if ( mat.IsRotation() ) { XYZAngles rot = _XYZangles(&mat); if ( fabs(rot.X()) > numeric_limits<double>::epsilon() || - fabs(rot.Y()) > numeric_limits<double>::epsilon() || - fabs(rot.Z()) > numeric_limits<double>::epsilon() ) { - + fabs(rot.Y()) > numeric_limits<double>::epsilon() || + fabs(rot.Z()) > numeric_limits<double>::epsilon() ) { + XML::Element e = XML::Element(elt.document(),_U(rotation)); // Don't know why the angles have the wrong sign.... rot *= -1; @@ -109,7 +109,7 @@ XML::Element AlignmentWriter::scan(XML::Document doc, DetElement element) const for (DetElement::Children::const_iterator i = c.begin(); i != c.end(); ++i) { XML::Element daughter = scan(doc, (*i).second); if ( daughter ) { - (elt ? (elt) : (elt=createElement(doc,element))).append(daughter); + (elt ? (elt) : (elt=createElement(doc,element))).append(daughter); } } } @@ -159,18 +159,18 @@ static long create_alignment_file(LCDD& lcdd, int argc, char** argv) { else if ( strncmp(argv[i]+1,"-transactions",5)==0 ) enable_transactions = true; else - throw runtime_error("AlignmentWriter: Invalid argument:"+string(argv[i])); + throw runtime_error("AlignmentWriter: Invalid argument:"+string(argv[i])); } } printout(ALWAYS,"AlignmentWriter", - "++++ Writing DD4hep alignment constants of the \"%s\" DetElement tree to file \"%s\"", - path.c_str(), output.c_str()); + "++++ Writing DD4hep alignment constants of the \"%s\" DetElement tree to file \"%s\"", + path.c_str(), output.c_str()); top = DetectorTools::findDaughterElement(lcdd.world(),path); if ( top.isValid() ) { AlignmentWriter wr(lcdd); return wr.write(wr.dump(top,enable_transactions), output); } - throw runtime_error("AlignmentWriter: Invalid top level element name:"+path); + throw runtime_error("AlignmentWriter: Invalid top level element name:"+path); } DECLARE_APPLY(DDAlignmentWriter, create_alignment_file) diff --git a/DDAlign/src/DetectorAlignment.cpp b/DDAlign/src/DetectorAlignment.cpp index bd1d1d0717998ec2d16132971972e160943aea39..1e50e0a4395edad1760e6c2e9917d3f18d4c3561 100644 --- a/DDAlign/src/DetectorAlignment.cpp +++ b/DDAlign/src/DetectorAlignment.cpp @@ -33,24 +33,24 @@ namespace { printout(INFO,"Alignment","DELTA matrix of %s",n->GetName()); transform->Print(); /* - printout(INFO,"Alignment","OLD matrix of %s",n->GetName()); - mm->Print(); + printout(INFO,"Alignment","OLD matrix of %s",n->GetName()); + mm->Print(); */ transform->MultiplyLeft(mm); // orig * delta n->Align(transform, 0, check, overlap); /* - printout(INFO,"Alignment","Apply new relative matrix mother to daughter:"); - transform->Print(); - transform->MultiplyLeft(mm); // orig * delta - printout(INFO,"Alignment","With deltas %s ....",n->GetName()); - transform->Print(); - n->Align(transform, 0, check, overlap); - printout(INFO,"Alignment","NEW matrix of %s",n->GetName()); - n->GetNode()->GetMatrix()->Print(); - - Position local, global = a.toGlobal(local); - cout << "Local:" << local << " Global: " << global - << " and back:" << a.globalToLocal(global) << endl; + printout(INFO,"Alignment","Apply new relative matrix mother to daughter:"); + transform->Print(); + transform->MultiplyLeft(mm); // orig * delta + printout(INFO,"Alignment","With deltas %s ....",n->GetName()); + transform->Print(); + n->Align(transform, 0, check, overlap); + printout(INFO,"Alignment","NEW matrix of %s",n->GetName()); + n->GetNode()->GetMatrix()->Print(); + + Position local, global = a.toGlobal(local); + cout << "Local:" << local << " Global: " << global + << " and back:" << a.globalToLocal(global) << endl; */ return Alignment(n); } @@ -76,15 +76,15 @@ namespace { PlacementPath::const_reverse_iterator j=nodes.rbegin(); ElementPath::const_reverse_iterator k=det_nodes.rbegin(); for(; j!=nodes.rend(); ++j, ++level) { - //cout << "(" << level << ") " << (void*)((*j).ptr()) - // << " " << string((*j)->GetName()) << " "; + //cout << "(" << level << ") " << (void*)((*j).ptr()) + // << " " << string((*j)->GetName()) << " "; if ( ::strcmp((*j).ptr()->GetName(),(*k).placement().ptr()->GetName()) ) { - //cout << "[DE]"; - elements.push_back(make_pair(level,*k)); - ++k; + //cout << "[DE]"; + elements.push_back(make_pair(level,*k)); + ++k; } else { - //elements.push_back(make_pair(level,DetElement())); + //elements.push_back(make_pair(level,DetElement())); } //cout << " "; } diff --git a/DDCore/include/DD4hep/Alignment.h b/DDCore/include/DD4hep/Alignment.h index f1ced06e6f8f5de087eb1ab23df866d837114ed2..1117bfacf0f5b1b2bdc322f5700a41bc206d2594 100644 --- a/DDCore/include/DD4hep/Alignment.h +++ b/DDCore/include/DD4hep/Alignment.h @@ -26,7 +26,7 @@ namespace DD4hep { /// Main handle class to hold a TGeo alignment object of type TGeoPhysicalNode /** * See the ROOT documentation about the TGeoPhysicalNode for further details: - * @see http://root.cern.ch/root/html/TGeoPhysicalNode.html + * @see http://root.cern.ch/root/html/TGeoPhysicalNode.html * * \author M.Frank * \version 1.0 @@ -38,14 +38,14 @@ namespace DD4hep { /// Default constructor Alignment(); /// Default constructor - Alignment(TGeoPhysicalNode* p) - : Handle<TGeoPhysicalNode>(p) { + Alignment(TGeoPhysicalNode* p) + : Handle<TGeoPhysicalNode>(p) { } /// Copy constructor Alignment(const Alignment& c); /// Constructor to be used when reading the already parsed object template <typename Q> Alignment(const Handle<Q>& e) - : Handle<TGeoPhysicalNode>(e) { + : Handle<TGeoPhysicalNode>(e) { } /// Initializing constructor Alignment(const std::string& path); diff --git a/DDCore/include/DD4hep/BasicGrammar.h b/DDCore/include/DD4hep/BasicGrammar.h index d52e1b6c7e4305e54d364e0ea85ec9dad74e7327..3af523591a2167c5bd806fdb5c7cb43f3e375786 100644 --- a/DDCore/include/DD4hep/BasicGrammar.h +++ b/DDCore/include/DD4hep/BasicGrammar.h @@ -17,12 +17,12 @@ namespace DD4hep { /// Base class describing string evaluation to C++ objects using boost::spirit - /** + /** * Grammar object handle the boost::spirit conversion between strings and numeric * values/objects. Numeric objects could be atomic (int, long, float, double, etc) - * or complex (vector<int>, vector<float>...). This way e.g. a vector<int> may + * or complex (vector<int>, vector<float>...). This way e.g. a vector<int> may * be converted into a list<double>. The conversion though requires an intermediate - * string representation. For this reason the conversion mechanism is relatively + * string representation. For this reason the conversion mechanism is relatively * slow and hence should not be used inside number-crunching algorithms. * * \author M.Frank diff --git a/DDCore/include/DD4hep/Callback.h b/DDCore/include/DD4hep/Callback.h index 9c383609dae1136eff6af4c5a30421bd431afdcc..71f55c3ffe4b2e168a70df77be5c8a8bfecb6cd8 100644 --- a/DDCore/include/DD4hep/Callback.h +++ b/DDCore/include/DD4hep/Callback.h @@ -19,13 +19,13 @@ */ namespace DD4hep { - + /// Definition of the generic callback structure for member functions /** - * The callback structure allows to wrap any member function with up to - * 3 arguments into an abstract objects, which could later be called + * The callback structure allows to wrap any member function with up to + * 3 arguments into an abstract objects, which could later be called * using the argument list. The pointer to the hosting objects is stored - * in the callback object. The callback objects in this sense behaves + * in the callback object. The callback objects in this sense behaves * very similar to a static function. * * \author M.Frank @@ -47,18 +47,18 @@ namespace DD4hep { mfunc_t func; /// Default constructor - Callback() - : par(0), call(0) { + Callback() + : par(0), call(0) { func.first = func.second = 0; } /// Constructor with object initialization - Callback(void* p) - : par(p), call(0) { + Callback(void* p) + : par(p), call(0) { func.first = func.second = 0; } /// Initializing constructor - Callback(void* p, void* mf, func_t c) - : par(p), call(c) { + Callback(void* p, void* mf, func_t c) + : par(p), call(c) { func = *(mfunc_t*) mf; } /// Check validity of the callback object @@ -72,7 +72,7 @@ namespace DD4hep { /// Template cast function used internally by the wrapper for type conversion to the object's type template <typename T> static T* cast(void* p) { return (T*) p; - } + } /// Template const cast function used internally by the wrapper for type conversion to the object's type template <typename T> static const T* c_cast(const void* p) { return (const T*) p; @@ -266,7 +266,7 @@ namespace DD4hep { } /// Callback setup function for Callbacks with const member functions with explicit return type taking 3 arguments template <typename R, typename T, typename A0, typename A1, typename A2> const Callback& make( - R (T::*pmf)(A0, A1, A2) const) { + R (T::*pmf)(A0, A1, A2) const) { typedef R (T::*pfunc_t)(A0, A1, A2); typedef Wrapper<pfunc_t> _W; struct _Wrapper : public _W { @@ -338,9 +338,9 @@ namespace DD4hep { CallbackSequence() { } /// Copy constructor - CallbackSequence(const CallbackSequence& c) - : callbacks(c.callbacks) { - } + CallbackSequence(const CallbackSequence& c) + : callbacks(c.callbacks) { + } /// Assignment operator CallbackSequence& operator=(const CallbackSequence& c) { if ( this != & c ) callbacks = c.callbacks; @@ -350,9 +350,9 @@ namespace DD4hep { //template <typename TYPE, typename R, typename OBJECT> // CallbackSequence(const std::vector<TYPE*>& objects, R (TYPE::value_type::*pmf)()) { //} - bool empty() const { - return callbacks.empty(); - } + bool empty() const { + return callbacks.empty(); + } /// Clear the sequence and remove all callbacks void clear() { callbacks.clear(); @@ -360,9 +360,9 @@ namespace DD4hep { /// Generically Add a new callback to the sequence depending on the location arguments void add(const Callback& cb,Location where) { if ( where == CallbackSequence::FRONT ) - callbacks.insert(callbacks.begin(),cb); - else - callbacks.insert(callbacks.end(),cb); + callbacks.insert(callbacks.begin(),cb); + else + callbacks.insert(callbacks.end(),cb); } /// Execution overload for callbacks with no arguments void operator()() const; @@ -404,25 +404,25 @@ namespace DD4hep { /** Callback setup for callbacks with 1 argument */ /// Add a new callback to a member function with explicit return type and 1 argument template <typename TYPE, typename R, typename OBJECT, typename A> - void add(TYPE* pointer, R (OBJECT::*pmf)(A),Location where=CallbackSequence::END) { + void add(TYPE* pointer, R (OBJECT::*pmf)(A),Location where=CallbackSequence::END) { checkTypes(typeid(TYPE), typeid(OBJECT), dynamic_cast<OBJECT*>(pointer)); add(Callback(pointer).make(pmf),where); } /// Add a new callback to a void member function and 1 argument template <typename TYPE, typename OBJECT, typename A> - void add(TYPE* pointer, void (OBJECT::*pmf)(A),Location where=CallbackSequence::END) { + void add(TYPE* pointer, void (OBJECT::*pmf)(A),Location where=CallbackSequence::END) { checkTypes(typeid(TYPE), typeid(OBJECT), dynamic_cast<OBJECT*>(pointer)); add(Callback(pointer).make(pmf),where); } /// Add a new callback to a const member function with explicit return type and 1 argument template <typename TYPE, typename R, typename OBJECT, typename A> - void add(TYPE* pointer, R (OBJECT::*pmf)(A) const,Location where=CallbackSequence::END) { + void add(TYPE* pointer, R (OBJECT::*pmf)(A) const,Location where=CallbackSequence::END) { checkTypes(typeid(TYPE), typeid(OBJECT), dynamic_cast<OBJECT*>(pointer)); add(Callback(pointer).make(pmf),where); } /// Add a new callback to a const void member function and 1 argument template <typename TYPE, typename OBJECT, typename A> - void add(TYPE* pointer, void (OBJECT::*pmf)(A) const,Location where=CallbackSequence::END) { + void add(TYPE* pointer, void (OBJECT::*pmf)(A) const,Location where=CallbackSequence::END) { checkTypes(typeid(TYPE), typeid(OBJECT), dynamic_cast<OBJECT*>(pointer)); add(Callback(pointer).make(pmf),where); } @@ -431,25 +431,25 @@ namespace DD4hep { /** Callback setup for callbacks with 2 arguments */ /// Add a new callback to a member function with explicit return type and 2 arguments template <typename TYPE, typename R, typename OBJECT, typename A1, typename A2> - void add(TYPE* pointer, R (OBJECT::*pmf)(A1, A2),Location where=CallbackSequence::END) { + void add(TYPE* pointer, R (OBJECT::*pmf)(A1, A2),Location where=CallbackSequence::END) { checkTypes(typeid(TYPE), typeid(OBJECT), dynamic_cast<OBJECT*>(pointer)); add(Callback(pointer).make(pmf),where); } /// Add a new callback to a const member function with explicit return type and 2 arguments template <typename TYPE, typename R, typename OBJECT, typename A1, typename A2> - void add(TYPE* pointer, R (OBJECT::*pmf)(A1, A2) const,Location where=CallbackSequence::END) { + void add(TYPE* pointer, R (OBJECT::*pmf)(A1, A2) const,Location where=CallbackSequence::END) { checkTypes(typeid(TYPE), typeid(OBJECT), dynamic_cast<OBJECT*>(pointer)); add(Callback(pointer).make(pmf),where); } /// Add a new callback to a void member function with 2 arguments template <typename TYPE, typename OBJECT, typename A1, typename A2> - void add(TYPE* pointer, void (OBJECT::*pmf)(A1, A2),Location where=CallbackSequence::END) { + void add(TYPE* pointer, void (OBJECT::*pmf)(A1, A2),Location where=CallbackSequence::END) { checkTypes(typeid(TYPE), typeid(OBJECT), dynamic_cast<OBJECT*>(pointer)); add(Callback(pointer).make(pmf),where); } /// Add a new callback to a const void member function with 2 arguments template <typename TYPE, typename OBJECT, typename A1, typename A2> - void add(TYPE* pointer, void (OBJECT::*pmf)(A1, A2) const,Location where=CallbackSequence::END) { + void add(TYPE* pointer, void (OBJECT::*pmf)(A1, A2) const,Location where=CallbackSequence::END) { checkTypes(typeid(TYPE), typeid(OBJECT), dynamic_cast<OBJECT*>(pointer)); add(Callback(pointer).make(pmf),where); } @@ -465,7 +465,7 @@ namespace DD4hep { } /// Execution overload for callbacks with 1 argument template <typename A0> inline - void CallbackSequence::operator()(A0 a0) const { + void CallbackSequence::operator()(A0 a0) const { if (!callbacks.empty()) { const void* args[1] = { a0 }; for (Callbacks::const_iterator i = callbacks.begin(); i != callbacks.end(); ++i) @@ -474,7 +474,7 @@ namespace DD4hep { } /// Execution overload for callbacks with 2 arguments template <typename A0, typename A1> inline - void CallbackSequence::operator()(A0 a0, A1 a1) const { + void CallbackSequence::operator()(A0 a0, A1 a1) const { if (!callbacks.empty()) { const void* args[2] = { a0, a1 }; for (Callbacks::const_iterator i = callbacks.begin(); i != callbacks.end(); ++i) @@ -483,7 +483,7 @@ namespace DD4hep { } /// Execution overload for callbacks with 3 arguments template <typename A0, typename A1, typename A2> inline - void CallbackSequence::operator()(A0 a0, A1 a1, A2 a2) const { + void CallbackSequence::operator()(A0 a0, A1 a1, A2 a2) const { if (!callbacks.empty()) { const void* args[3] = { a0, a1, a2 }; for (Callbacks::const_iterator i = callbacks.begin(); i != callbacks.end(); ++i) diff --git a/DDCore/include/DD4hep/ConditionTypes.h b/DDCore/include/DD4hep/ConditionTypes.h index 3a69de4acfd2ea3883f0e15bc5b67deaab388392..879432e2d48600d2933ebdedbf6d35c8d0c7d766 100644 --- a/DDCore/include/DD4hep/ConditionTypes.h +++ b/DDCore/include/DD4hep/ConditionTypes.h @@ -1,3 +1,3 @@ -#define DD4HEP_INSTANTIATE_GRAMMAR_TYPE(x) namespace DD4hep { \ +#define DD4HEP_INSTANTIATE_GRAMMAR_TYPE(x) namespace DD4hep { \ template<> const BasicGrammar& BasicGrammar::instance<x>() { static Grammar<x> s; return s;}} diff --git a/DDCore/include/DD4hep/Conditions.h b/DDCore/include/DD4hep/Conditions.h index d64f16dd66be6f41e978d6e9db6b717559b72c13..aa3a738d9a33d5984a6caab7b615f15f2e26ae62 100644 --- a/DDCore/include/DD4hep/Conditions.h +++ b/DDCore/include/DD4hep/Conditions.h @@ -33,7 +33,7 @@ namespace DD4hep { } /// Class describing an opaque conditions data block - /** + /** * Access methods are templated. Once the access is fixed * on the first call, the data type may not be changed anymore. * @@ -68,7 +68,7 @@ namespace DD4hep { }; /// Main condition object handle. - /** + /** * This objects allows access to the data block and * the interval of validity for a single condition. * @@ -91,7 +91,7 @@ namespace DD4hep { Condition(Object* p); /// Constructor to be used when reading the already parsed object template <typename Q> Condition(const Handle<Q>& e) - : Handle<Object>(e) { + : Handle<Object>(e) { } /// Initializing constructor Condition(const std::string& name); @@ -139,7 +139,7 @@ namespace DD4hep { /// Re-evaluate the conditions data according to the previous bound type definition Condition& rebind(); - /** Bind the data of the conditions object to a given format. + /** Bind the data of the conditions object to a given format. * * Note: The type definition is possible exactly once. * Any further rebindings MUST match the identical type. @@ -164,7 +164,7 @@ namespace DD4hep { } /// Container class for condition handles aggregated by a detector element - /** + /** * Note: The conditions container is owner by the detector element * On deletion the detector element will destroy the container * and all associated entries. @@ -188,11 +188,11 @@ namespace DD4hep { Conditions(); /// Constructor to be used when reading the already parsed object template <typename Q> Conditions(const Conditions& c) - : Handle<Object>(c) { + : Handle<Object>(c) { } /// Constructor to be used when reading the already parsed object template <typename Q> Conditions(const Handle<Q>& e) - : Handle<Object>(e) { + : Handle<Object>(e) { } /// Access the number of conditons available for this detector element size_t count() const; diff --git a/DDCore/include/DD4hep/DD4hepRootPersistency.h b/DDCore/include/DD4hep/DD4hepRootPersistency.h index edfec68d021711daea5c7a07c98ac985d62025bf..33592496de27509244c8dee2a2fd2c6075abbb53 100644 --- a/DDCore/include/DD4hep/DD4hepRootPersistency.h +++ b/DDCore/include/DD4hep/DD4hepRootPersistency.h @@ -20,7 +20,7 @@ class DD4hepRootPersistency : public TNamed, public DD4hep::Geometry::LCDDData DD4hepRootPersistency() : TNamed() {} /// Default destructor virtual ~DD4hepRootPersistency() {} - + static int save(DD4hep::Geometry::LCDD& lcdd, const char* fname, const char* instance = "Geometry"); static int load(DD4hep::Geometry::LCDD& lcdd, const char* fname, const char* instance = "Geometry"); diff --git a/DDCore/include/DD4hep/DD4hepUnits.h b/DDCore/include/DD4hep/DD4hepUnits.h index ab6bb6996708157d682f24ced81e283b36b9ae87..49dc41cdd369b7bc4b09b2cb9bcc35d7ff8984b8 100644 --- a/DDCore/include/DD4hep/DD4hepUnits.h +++ b/DDCore/include/DD4hep/DD4hepUnits.h @@ -17,9 +17,9 @@ /// Utility namespace to support TGeo units. namespace dd4hep { -// -// Length [L] -// + // + // Length [L] + // static const double millimeter = 0.1; static const double millimeter2 = millimeter * millimeter; static const double millimeter3 = millimeter * millimeter * millimeter; @@ -49,7 +49,7 @@ namespace dd4hep { static const double nanobarn = 1.e-9 * barn; static const double picobarn = 1.e-12 * barn; -// symbols + // symbols static const double nm = nanometer; static const double um = micrometer; @@ -71,30 +71,30 @@ namespace dd4hep { static const double pc = parsec; -// -// Angle -// + // + // Angle + // // static const double radian = 180. / 3.14159265358979323846; // => degree=1 // static const double milliradian = 1.e-3 * radian; // static const double degree = 1.; //= (3.14159265358979323846/180.0)*radian; //fg: use radians as default unit as this is needed for all math functions - // and everywhere else, except in TGeo shapes -> this is taken care of in shape Handles .... - static const double radian = 1. ; + // and everywhere else, except in TGeo shapes -> this is taken care of in shape Handles .... + static const double radian = 1. ; static const double milliradian = 1.e-3 * radian; static const double degree = (3.14159265358979323846/180.0)*radian; static const double steradian = 1.; -// symbols + // symbols static const double rad = radian; static const double mrad = milliradian; static const double sr = steradian; static const double deg = degree; -// -// Time [T] -// + // + // Time [T] + // static const double nanosecond = 1.e-9; static const double second = 1.e+9 * nanosecond; static const double millisecond = 1.e-3 * second; @@ -105,21 +105,21 @@ namespace dd4hep { static const double kilohertz = 1.e+3 * hertz; static const double megahertz = 1.e+6 * hertz; -// symbols + // symbols static const double ns = nanosecond; static const double s = second; static const double ms = millisecond; -// -// Electric charge [Q] -// + // + // Electric charge [Q] + // static const double eplus = 1.; // positron charge static const double e_SI = 1.602176487e-19; // positron charge in coulomb static const double coulomb = eplus / e_SI; // coulomb = 6.24150 e+18 * eplus -// -// Energy [E] -// + // + // Energy [E] + // static const double megaelectronvolt = 1.e-3; static const double electronvolt = 1.e-6 * megaelectronvolt; static const double kiloelectronvolt = 1.e-3 * megaelectronvolt; @@ -129,7 +129,7 @@ namespace dd4hep { static const double joule = electronvolt / e_SI; // joule = 6.24150 e+12 * MeV -// symbols + // symbols static const double MeV = megaelectronvolt; static const double eV = electronvolt; static const double keV = kiloelectronvolt; @@ -137,221 +137,221 @@ namespace dd4hep { static const double TeV = teraelectronvolt; static const double PeV = petaelectronvolt; -// -// Mass [E][T^2][L^-2] -// + // + // Mass [E][T^2][L^-2] + // static const double kilogram = joule * second * second / (meter * meter); static const double gram = 1.e-3 * kilogram; static const double milligram = 1.e-3 * gram; -// symbols + // symbols static const double kg = kilogram; static const double g = gram; static const double mg = milligram; -// -// Power [E][T^-1] -// + // + // Power [E][T^-1] + // static const double watt = joule / second; // watt = 6.24150 e+3 * MeV/ns -// -// Force [E][L^-1] -// + // + // Force [E][L^-1] + // static const double newton = joule / meter; // newton = 6.24150 e+9 * MeV/mm -// -// Pressure [E][L^-3] -// + // + // Pressure [E][L^-3] + // #define pascal hep_pascal // a trick to avoid warnings static const double hep_pascal = newton / m2; // pascal = 6.24150 e+3 * MeV/mm3 static const double bar = 100000 * pascal; // bar = 6.24150 e+8 * MeV/mm3 static const double atmosphere = 101325 * pascal; // atm = 6.32420 e+8 * MeV/mm3 -// -// Electric current [Q][T^-1] -// + // + // Electric current [Q][T^-1] + // static const double ampere = coulomb / second; // ampere = 6.24150 e+9 * eplus/ns static const double milliampere = 1.e-3 * ampere; static const double microampere = 1.e-6 * ampere; static const double nanoampere = 1.e-9 * ampere; -// -// Electric potential [E][Q^-1] -// + // + // Electric potential [E][Q^-1] + // static const double megavolt = megaelectronvolt / eplus; static const double kilovolt = 1.e-3 * megavolt; static const double volt = 1.e-6 * megavolt; -// -// Electric resistance [E][T][Q^-2] -// + // + // Electric resistance [E][T][Q^-2] + // static const double ohm = volt / ampere; // ohm = 1.60217e-16*(MeV/eplus)/(eplus/ns) -// -// Electric capacitance [Q^2][E^-1] -// + // + // Electric capacitance [Q^2][E^-1] + // static const double farad = coulomb / volt; // farad = 6.24150e+24 * eplus/Megavolt static const double millifarad = 1.e-3 * farad; static const double microfarad = 1.e-6 * farad; static const double nanofarad = 1.e-9 * farad; static const double picofarad = 1.e-12 * farad; -// -// Magnetic Flux [T][E][Q^-1] -// + // + // Magnetic Flux [T][E][Q^-1] + // static const double weber = volt * second; // weber = 1000*megavolt*ns -// -// Magnetic Field [T][E][Q^-1][L^-2] -// + // + // Magnetic Field [T][E][Q^-1][L^-2] + // static const double tesla = volt * second / meter2; // tesla =0.001*megavolt*ns/mm2 static const double gauss = 1.e-4 * tesla; static const double kilogauss = 1.e-1 * tesla; -// -// Inductance [T^2][E][Q^-2] -// + // + // Inductance [T^2][E][Q^-2] + // static const double henry = weber / ampere; // henry = 1.60217e-7*MeV*(ns/eplus)**2 -// -// Temperature -// + // + // Temperature + // static const double kelvin = 1.; -// -// Amount of substance -// + // + // Amount of substance + // static const double mole = 1.; -// -// Activity [T^-1] -// + // + // Activity [T^-1] + // static const double becquerel = 1. / second; static const double curie = 3.7e+10 * becquerel; -// -// Absorbed dose [L^2][T^-2] -// + // + // Absorbed dose [L^2][T^-2] + // static const double gray = joule / kilogram; static const double kilogray = 1.e+3 * gray; static const double milligray = 1.e-3 * gray; static const double microgray = 1.e-6 * gray; -// -// Luminous intensity [I] -// + // + // Luminous intensity [I] + // static const double candela = 1.; -// -// Luminous flux [I] -// + // + // Luminous flux [I] + // static const double lumen = candela * steradian; -// -// Illuminance [I][L^-2] -// + // + // Illuminance [I][L^-2] + // static const double lux = lumen / meter2; -// -// Miscellaneous -// + // + // Miscellaneous + // static const double perCent = 0.01; static const double perThousand = 0.001; static const double perMillion = 0.000001; -// -*- C++ -*- -// $Id:$ -// ---------------------------------------------------------------------- -// HEP coherent Physical Constants -// -// This file has been provided by Geant4 (simulation toolkit for HEP). -// -// The basic units are : -// millimeter -// nanosecond -// Mega electron Volt -// positon charge -// degree Kelvin -// amount of substance (mole) -// luminous intensity (candela) -// radian -// steradian -// -// Below is a non exhaustive list of Physical CONSTANTS, -// computed in the Internal HEP System Of Units. -// -// Most of them are extracted from the Particle Data Book : -// Phys. Rev. D volume 50 3-1 (1994) page 1233 -// -// ...with a meaningful (?) name ... -// -// You can add your own constants. -// -// Author: M.Maire -// -// History: -// -// 23.02.96 Created -// 26.03.96 Added constants for standard conditions of temperature -// and pressure; also added Gas threshold. -// 29.04.08 use PDG 2006 values -// 03.11.08 use PDG 2008 values + // -*- C++ -*- + // $Id:$ + // ---------------------------------------------------------------------- + // HEP coherent Physical Constants + // + // This file has been provided by Geant4 (simulation toolkit for HEP). + // + // The basic units are : + // millimeter + // nanosecond + // Mega electron Volt + // positon charge + // degree Kelvin + // amount of substance (mole) + // luminous intensity (candela) + // radian + // steradian + // + // Below is a non exhaustive list of Physical CONSTANTS, + // computed in the Internal HEP System Of Units. + // + // Most of them are extracted from the Particle Data Book : + // Phys. Rev. D volume 50 3-1 (1994) page 1233 + // + // ...with a meaningful (?) name ... + // + // You can add your own constants. + // + // Author: M.Maire + // + // History: + // + // 23.02.96 Created + // 26.03.96 Added constants for standard conditions of temperature + // and pressure; also added Gas threshold. + // 29.04.08 use PDG 2006 values + // 03.11.08 use PDG 2008 values static const double pi = 3.14159265358979323846; static const double twopi = 2 * pi; static const double halfpi = pi / 2; static const double pi2 = pi * pi; -// -// -// + // + // + // static const double Avogadro = 6.02214179e+23 / mole; -// -// c = 299.792458 mm/ns -// c^2 = 898.7404 (mm/ns)^2 -// + // + // c = 299.792458 mm/ns + // c^2 = 898.7404 (mm/ns)^2 + // static const double c_light = 2.99792458e+8 * m / s; static const double c_squared = c_light * c_light; -// -// h = 4.13566e-12 MeV*ns -// hbar = 6.58212e-13 MeV*ns -// hbarc = 197.32705e-12 MeV*mm -// + // + // h = 4.13566e-12 MeV*ns + // hbar = 6.58212e-13 MeV*ns + // hbarc = 197.32705e-12 MeV*mm + // static const double h_Planck = 6.62606896e-34 * joule * s; static const double hbar_Planck = h_Planck / twopi; static const double hbarc = hbar_Planck * c_light; static const double hbarc_squared = hbarc * hbarc; -// -// -// + // + // + // static const double electron_charge = -eplus; // see SystemOfUnits.h static const double e_squared = eplus * eplus; -// -// amu_c2 - atomic equivalent mass unit -// - AKA, unified atomic mass unit (u) -// amu - atomic mass unit -// + // + // amu_c2 - atomic equivalent mass unit + // - AKA, unified atomic mass unit (u) + // amu - atomic mass unit + // static const double electron_mass_c2 = 0.510998910 * MeV; static const double proton_mass_c2 = 938.272013 * MeV; static const double neutron_mass_c2 = 939.56536 * MeV; static const double amu_c2 = 931.494028 * MeV; static const double amu = amu_c2 / c_squared; -// -// permeability of free space mu0 = 2.01334e-16 Mev*(ns*eplus)^2/mm -// permittivity of free space epsil0 = 5.52636e+10 eplus^2/(MeV*mm) -// + // + // permeability of free space mu0 = 2.01334e-16 Mev*(ns*eplus)^2/mm + // permittivity of free space epsil0 = 5.52636e+10 eplus^2/(MeV*mm) + // static const double mu0 = 4 * pi * 1.e-7 * henry / m; static const double epsilon0 = 1. / (c_squared * mu0); -// -// electromagnetic coupling = 1.43996e-12 MeV*mm/(eplus^2) -// + // + // electromagnetic coupling = 1.43996e-12 MeV*mm/(eplus^2) + // static const double elm_coupling = e_squared / (4 * pi * epsilon0); static const double fine_structure_const = elm_coupling / hbarc; static const double classic_electr_radius = elm_coupling / electron_mass_c2; @@ -361,21 +361,21 @@ namespace dd4hep { static const double alpha_rcl2 = fine_structure_const * classic_electr_radius * classic_electr_radius; static const double twopi_mc2_rcl2 = twopi * electron_mass_c2 * classic_electr_radius * classic_electr_radius; -// -// -// + // + // + // static const double k_Boltzmann = 8.617343e-11 * MeV / kelvin; -// -// -// + // + // + // static const double STP_Temperature = 273.15 * kelvin; static const double STP_Pressure = 1. * atmosphere; static const double kGasThreshold = 10. * mg / cm3; -// -// -// + // + // + // static const double universe_mean_density = 1.e-25 * g / cm3; } diff --git a/DDCore/include/DD4hep/DetFactoryHelper.h b/DDCore/include/DD4hep/DetFactoryHelper.h index b552682461589491e27420b23cd0725aff6e590c..bb56089c7116c8e869afc47fc6e8b60c5a777179 100644 --- a/DDCore/include/DD4hep/DetFactoryHelper.h +++ b/DDCore/include/DD4hep/DetFactoryHelper.h @@ -30,13 +30,13 @@ typedef DD4hep::XML::Document xml_doc_t; typedef DD4hep::XML::Strng_t Unicode; typedef DD4hep::Geometry::LCDD lcdd_t; - /// Namespace for the AIDA detector description toolkit +/// Namespace for the AIDA detector description toolkit namespace DD4hep { /// Namespace for the geometry part of the AIDA detector description toolkit namespace Geometry { - /// std::string conversion of XML strings (e.g. Unicode for Xerces-C) + /// std::string conversion of XML strings (e.g. Unicode for Xerces-C) static inline std::string _toString(const DD4hep::XML::XmlChar* value) { return XML::_toString(value); } diff --git a/DDCore/include/DD4hep/Detector.h b/DDCore/include/DD4hep/Detector.h index d959ff76945cc955f8f4fce7ac67914193cc279d..05772ffe13e6d7c03e0c44f3903b4a6250306c4a 100644 --- a/DDCore/include/DD4hep/Detector.h +++ b/DDCore/include/DD4hep/Detector.h @@ -85,8 +85,8 @@ namespace DD4hep { /// Templated constructor for handle conversions template <typename Q> - SensitiveDetector(const Handle<Q>& e) - : RefObject(e) { + SensitiveDetector(const Handle<Q>& e) + : RefObject(e) { } /// Constructor for a new sensitive detector element @@ -159,15 +159,15 @@ namespace DD4hep { /// Handle class describing a detector element /** - * Detector elements (class DetElement are entities which represent + * Detector elements (class DetElement are entities which represent * subdetectors or sizable parts of a subdetector. * A DetElement instance has the means to provide to clients information about * * - the detector hierarchy by exposing its children. - * - its placement within the overall experiment if it represents an + * - its placement within the overall experiment if it represents an * entire subdetector or its placement with respect to its parent * if the \em DetElement represents a part of a subdetector. - * - information about the \em Readout structure if the object is + * - information about the \em Readout structure if the object is * instrumented and read-out. Otherwise this link is empty. * - information about the environmental conditions etc. \em conditons. * - alignment information. @@ -197,14 +197,14 @@ namespace DD4hep { COPY_NONE = 0, COPY_PLACEMENT = 1 << 0, COPY_PARENT = 1 << 1, COPY_ALIGNMENT = 1 << 2, LAST }; - enum UpdateParam { - CONDITIONS_CHANGED = 1<<0, - PLACEMENT_CHANGED = 1<<1, - SOMETHING_CHANGED = 1<<2, - PLACEMENT_ELEMENT = 1<<20, - PLACEMENT_HIGHEST = 1<<21, - PLACEMENT_DETECTOR = 1<<22, - PLACEMENT_NONE + enum UpdateParam { + CONDITIONS_CHANGED = 1<<0, + PLACEMENT_CHANGED = 1<<1, + SOMETHING_CHANGED = 1<<2, + PLACEMENT_ELEMENT = 1<<20, + PLACEMENT_HIGHEST = 1<<21, + PLACEMENT_DETECTOR = 1<<22, + PLACEMENT_NONE }; /// Internal assert function to check conditions @@ -245,7 +245,7 @@ namespace DD4hep { /// Templated constructor for handle conversions template <typename Q> DetElement(const Handle<Q>& e) - : RefObject(e) { + : RefObject(e) { } /// Constructor to copy handle @@ -255,7 +255,7 @@ namespace DD4hep { #ifdef __MAKECINT__ /// Constructor to copy handle - DetElement(const Ref_t& e) + DetElement(const Ref_t& e) : RefObject(e) { } #endif @@ -297,7 +297,7 @@ namespace DD4hep { /// Extend the detector element with an arbitrary structure accessible by the type template <typename IFACE, typename CONCRETE> IFACE* addExtension(CONCRETE* c) const { - CallbackSequence::checkTypes(typeid(IFACE), typeid(CONCRETE), dynamic_cast<IFACE*>(c)); + CallbackSequence::checkTypes(typeid(IFACE), typeid(CONCRETE), dynamic_cast<IFACE*>(c)); return (IFACE*) i_addExtension(dynamic_cast<IFACE*>(c), typeid(IFACE), _copy<CONCRETE>, _delete<IFACE>); } /// Access extension element by the type @@ -305,12 +305,12 @@ namespace DD4hep { return (IFACE*) i_extension(typeid(IFACE)); } /// Extend the detector element with an arbitrary callback - template <typename Q, typename T> - void callAtUpdate(unsigned int type, Q* pointer, - void (T::*pmf)(unsigned long typ, DetElement& det, void* opt_par)) const + template <typename Q, typename T> + void callAtUpdate(unsigned int type, Q* pointer, + void (T::*pmf)(unsigned long typ, DetElement& det, void* opt_par)) const { - CallbackSequence::checkTypes(typeid(T), typeid(Q), dynamic_cast<T*>(pointer)); - i_addUpdateCall(type, Callback(pointer).make(pmf)); + CallbackSequence::checkTypes(typeid(T), typeid(Q), dynamic_cast<T*>(pointer)); + i_addUpdateCall(type, Callback(pointer).make(pmf)); } /// Remove callback from object void removeAtUpdate(unsigned int type, void* pointer) const; @@ -336,7 +336,7 @@ namespace DD4hep { /// Set all attributes in one go DetElement& setAttributes(const LCDD& lcdd, const Volume& volume, const std::string& region, const std::string& limits, - const std::string& vis); + const std::string& vis); /// Set Visualization attributes to the detector element DetElement& setVisAttributes(const LCDD& lcdd, const std::string& name, const Volume& volume); @@ -368,7 +368,7 @@ namespace DD4hep { Alignment alignment() const; /// Access to the survey alignment information Alignment surveyAlignment() const; - /// Access to the conditions information + /// Access to the conditions information Conditions conditions() const; /// Set detector element for reference transformations. Will delete existing reference trafo. @@ -380,7 +380,7 @@ namespace DD4hep { const TGeoHMatrix& parentTransformation() const; /// Create cached matrix to transform to reference coordinates const TGeoHMatrix& referenceTransformation() const; - + /// Transformation from local coordinates of the placed volume to the world system bool localToWorld(const Position& local, Position& global) const; /// Transformation from local coordinates of the placed volume to the parent system diff --git a/DDCore/include/DD4hep/Dictionary.h b/DDCore/include/DD4hep/Dictionary.h index b87d763043799cadbae0f233baab1cc1a03a0d18..b5868c96b264b98152497f162dcdf7f3b9b99941 100644 --- a/DDCore/include/DD4hep/Dictionary.h +++ b/DDCore/include/DD4hep/Dictionary.h @@ -1,6 +1,6 @@ // // LinkDef.h -// +// // // Created by Pere Mato on 22/1/12. // Copyright 2012 __MyCompanyName__. All rights reserved. diff --git a/DDCore/include/DD4hep/Exceptions.h b/DDCore/include/DD4hep/Exceptions.h index 59a59ae38302488733c196fe472571d59f33a4ed..5e9c5389df10551e15bbc85b5c41e6c0e48f1230 100644 --- a/DDCore/include/DD4hep/Exceptions.h +++ b/DDCore/include/DD4hep/Exceptions.h @@ -25,8 +25,8 @@ namespace DD4hep { */ struct unrelated_type_error : public std::runtime_error { static std::string msg(const std::type_info& typ1, const std::type_info& typ2, const std::string& text); - unrelated_type_error(const std::type_info& typ1, const std::type_info& typ2, const std::string& text = "") - : std::runtime_error(msg(typ1, typ2, text)) { + unrelated_type_error(const std::type_info& typ1, const std::type_info& typ2, const std::string& text = "") + : std::runtime_error(msg(typ1, typ2, text)) { } }; @@ -38,8 +38,8 @@ namespace DD4hep { */ struct unrelated_value_error : public std::runtime_error { static std::string msg(const std::type_info& typ, const std::string& text); - unrelated_value_error(const std::type_info& typ, const std::string& text = "") - : std::runtime_error(msg(typ, text)) { + unrelated_value_error(const std::type_info& typ, const std::string& text = "") + : std::runtime_error(msg(typ, text)) { } }; diff --git a/DDCore/include/DD4hep/Factories.h b/DDCore/include/DD4hep/Factories.h index 9a83be1c876e06dbb07f151978b7fb5ae02f4c35..c891f193fbb70c3ec03fb53d9d1f8d6ced9ce3b9 100644 --- a/DDCore/include/DD4hep/Factories.h +++ b/DDCore/include/DD4hep/Factories.h @@ -90,7 +90,7 @@ namespace DD4hep { }; /// Read an arbitrary XML document and analyze it's content - /** + /** * * \author M.Frank * \version 1.0 @@ -103,7 +103,7 @@ namespace DD4hep { }; /// Read an arbitrary XML document and analyze it's content - /** + /** * * \author M.Frank * \version 1.0 @@ -116,7 +116,7 @@ namespace DD4hep { }; /// Standard factory to create Detector elements from the compact XML representation. - /** + /** * * \author M.Frank * \version 1.0 @@ -200,53 +200,53 @@ namespace { }; } -#define DECLARE_DETELEMENT_FACTORY(x) \ +#define DECLARE_DETELEMENT_FACTORY(x) \ PLUGINSVC_FACTORY(x,DD4hep::NamedObject*(DD4hep::Geometry::LCDD*,DD4hep::XML::Handle_t*,DD4hep::Geometry::Ref_t*)) -#define DECLARE_NAMESPACE_DETELEMENT_FACTORY(n,x) using n::x; \ +#define DECLARE_NAMESPACE_DETELEMENT_FACTORY(n,x) using n::x; \ PLUGINSVC_FACTORY(x,DD4hep::NamedObject*(DD4hep::Geometry::LCDD*,DD4hep::XML::Handle_t*,DD4hep::Geometry::Ref_t*)) -#define DECLARE_NAMED_APPLY_FACTORY(n,x) using n::x;\ +#define DECLARE_NAMED_APPLY_FACTORY(n,x) using n::x; \ PLUGINSVC_FACTORY_WITH_ID(x,std::string(#x),long(DD4hep::Geometry::LCDD*,int, char**)) -#define DECLARE_NAMED_TRANSLATION_FACTORY(n,x) using n::x;\ +#define DECLARE_NAMED_TRANSLATION_FACTORY(n,x) using n::x; \ PLUGINSVC_FACTORY_WITH_ID(x,std::string(#x),DD4hep::NamedObject*(DD4hep::Geometry::LCDD*)) -#define DECLARE_NAMED_XMLELEMENT_FACTORY(n,x) using n::x;\ +#define DECLARE_NAMED_XMLELEMENT_FACTORY(n,x) using n::x; \ PLUGINSVC_FACTORY_WITH_ID(x,std::string(#x),DD4hep::NamedObject*(DD4hep::Geometry::LCDD*,DD4hep::XML::Handle_t*)) -#define DECLARE_NAMED_DETELEMENT_FACTORY(n,x) using n::x;\ +#define DECLARE_NAMED_DETELEMENT_FACTORY(n,x) using n::x; \ PLUGINSVC_FACTORY_WITH_ID(x,std::string(#x),DD4hep::NamedObject*(DD4hep::Geometry::LCDD*,DD4hep::XML::Handle_t*,DD4hep::Geometry::Ref_t*)) -#define DECLARE_APPLY(name,func) \ - namespace DD4hep { namespace Geometry { namespace { struct name {}; } \ - template <> long ApplyFactory<name>::create(DD4hep::Geometry::LCDD& l,int n,char** a) {return func(l,n,a);} }} \ - using DD4hep::Geometry::name;\ +#define DECLARE_APPLY(name,func) \ + namespace DD4hep { namespace Geometry { namespace { struct name {}; } \ + template <> long ApplyFactory<name>::create(DD4hep::Geometry::LCDD& l,int n,char** a) {return func(l,n,a);} }} \ + using DD4hep::Geometry::name; \ DECLARE_NAMED_APPLY_FACTORY(DD4hep::Geometry,name) -#define DECLARE_CONSTRUCTOR(name,func) \ +#define DECLARE_CONSTRUCTOR(name,func) \ namespace DD4hep { namespace Geometry { namespace { struct name {}; } \ - template <> void* ConstructionFactory<name>::create(const char* n) { return func(n);}}} \ + template <> void* ConstructionFactory<name>::create(const char* n) { return func(n);}}} \ PLUGINSVC_FACTORY_WITH_ID(name,std::string(#name),void*(const char*)) -#define DECLARE_TRANSLATION(name,func) \ - namespace DD4hep { namespace Geometry { namespace { struct name {}; } \ - template <> DD4hep::Geometry::Ref_t TranslationFactory<name>::create(DD4hep::Geometry::LCDD& l) {return func(l);} }} \ - using DD4hep::Geometry::name;\ +#define DECLARE_TRANSLATION(name,func) \ + namespace DD4hep { namespace Geometry { namespace { struct name {}; } \ + template <> DD4hep::Geometry::Ref_t TranslationFactory<name>::create(DD4hep::Geometry::LCDD& l) {return func(l);} }} \ + using DD4hep::Geometry::name; \ DECLARE_NAMED_TRANSLATION_FACTORY(DD4hep::Geometry,name) -#define DECLARE_XMLELEMENT(name,func) \ - namespace DD4hep { namespace Geometry { namespace { struct xml_element_##name {}; } \ - template <> DD4hep::Geometry::Ref_t XMLElementFactory<DD4hep::Geometry::xml_element_##name>::create(DD4hep::Geometry::LCDD& l,DD4hep::XML::Handle_t e) {return func(l,e);} }}\ - using DD4hep::Geometry::xml_element_##name;\ +#define DECLARE_XMLELEMENT(name,func) \ + namespace DD4hep { namespace Geometry { namespace { struct xml_element_##name {}; } \ + template <> DD4hep::Geometry::Ref_t XMLElementFactory<DD4hep::Geometry::xml_element_##name>::create(DD4hep::Geometry::LCDD& l,DD4hep::XML::Handle_t e) {return func(l,e);} }} \ + using DD4hep::Geometry::xml_element_##name; \ PLUGINSVC_FACTORY_WITH_ID(xml_element_##name,std::string(#name),DD4hep::NamedObject*(DD4hep::Geometry::LCDD*,DD4hep::XML::Handle_t*)) -#define DECLARE_XML_DOC_READER(name,func) \ - namespace DD4hep { namespace Geometry { namespace { struct xml_document_##name {}; } \ - template <> long XMLDocumentReaderFactory<DD4hep::Geometry::xml_document_##name>::create(DD4hep::Geometry::LCDD& l,DD4hep::XML::Handle_t e) {return func(l,e);} }}\ - using DD4hep::Geometry::xml_document_##name;\ +#define DECLARE_XML_DOC_READER(name,func) \ + namespace DD4hep { namespace Geometry { namespace { struct xml_document_##name {}; } \ + template <> long XMLDocumentReaderFactory<DD4hep::Geometry::xml_document_##name>::create(DD4hep::Geometry::LCDD& l,DD4hep::XML::Handle_t e) {return func(l,e);} }} \ + using DD4hep::Geometry::xml_document_##name; \ PLUGINSVC_FACTORY_WITH_ID(xml_document_##name,std::string(#name "_XML_reader"),long(DD4hep::Geometry::LCDD*,DD4hep::XML::Handle_t*)) -#define DECLARE_XML_PROCESSOR_BASIC(name,func,deprecated) \ - namespace DD4hep { namespace Geometry { struct det_element_##name {}; \ +#define DECLARE_XML_PROCESSOR_BASIC(name,func,deprecated) \ + namespace DD4hep { namespace Geometry { struct det_element_##name {}; \ template <> DD4hep::Geometry::Ref_t DetElementFactory< DD4hep::Geometry::det_element_##name >::create(DD4hep::Geometry::LCDD& l,DD4hep::XML::Handle_t e,DD4hep::Geometry::Ref_t h){ if (deprecated) warning_deprecated_xml_factory(#name); return func(l,e,h);}} } \ - using DD4hep::Geometry::det_element_##name; \ + using DD4hep::Geometry::det_element_##name; \ PLUGINSVC_FACTORY_WITH_ID(det_element_##name,std::string(#name),DD4hep::NamedObject*(DD4hep::Geometry::LCDD*,DD4hep::XML::Handle_t*,DD4hep::Geometry::Ref_t*)) #define DECLARE_XML_PROCESSOR(name,func) DECLARE_XML_PROCESSOR_BASIC(name,func,0) diff --git a/DDCore/include/DD4hep/FieldTypes.h b/DDCore/include/DD4hep/FieldTypes.h index 9706f3970b5eaf5dfbaf3665e014506c38086b1c..7934938feb53c576c119c63cfb570132a10c6ca3 100644 --- a/DDCore/include/DD4hep/FieldTypes.h +++ b/DDCore/include/DD4hep/FieldTypes.h @@ -23,7 +23,7 @@ namespace DD4hep { namespace Geometry { /// Implementation object of a field with constant strength - /** + /** * Generic constant uniform field * * \author M.Frank @@ -36,15 +36,15 @@ namespace DD4hep { Direction direction; public: /// Initializing constructor - ConstantField() - : direction() { + ConstantField() + : direction() { } /// Call to access the field components at a given location virtual void fieldComponents(const double* /* pos */, double* field); }; /// Implementation object of a solenoidal magnetic field. - /** + /** * Generic solonoid magnetic field * * \author M.Frank @@ -68,7 +68,7 @@ namespace DD4hep { }; /// Implementation object of a dipole magnetic field. - /** + /** * Generic dipole magnetic field * * \author M.Frank @@ -90,8 +90,8 @@ namespace DD4hep { }; /// Implementation object of a Multipole magnetic field. - /** - * Generic multipole magnetic field using the + /** + * Generic multipole magnetic field using the * Multipole approach. The dipole is assumed to be horizontal * as it is used for bending beams in large colliders * ie. the dipole field lines are vertical. @@ -102,7 +102,7 @@ namespace DD4hep { * B_y + i*B_x &=& C_n * (x + iy)^{n-1} \\ * B_sum = B_y + i B_x &=& Sum_{n=1..4} (b_n + ia_n) (x + iy)^{n-1} \\ * \f} - * With C_n being the complex multipole coefficients and + * With C_n being the complex multipole coefficients and * b_n the "normal multipole coefficients" and a_n the "skew multipole coefficients". * * The maximal momentum used is the octopole momentum. @@ -117,22 +117,22 @@ namespace DD4hep { * \f} * * \li Quadrupole (n=2): - * + * * \f{eqnarray*}{ * B_y &=& b_2 x - a_2 y \\ * B_x &=& b_2 y + a_2 x \\ * \f} - * + * * \li Sextupole (n=3): - * + * * \f{eqnarray*}{ * B_y + i B_x &=& (b_3 +ia_3) (x^2 + 2ixy - y^2) \\ * B_y &=& b_3 x^2 - b_3 y^2 - 2 a_3 xy \\ * B_x &=& a_3 x^2 - a_3 y^2 + 2 b_3 xy \\ * \f} - * + * * \li Octopole (n=4): - * + * * \f{eqnarray*}{ * B_y + i B_x &=& (b_4 +ia_4) (x^3 + 3ix^2y - 3xy^2 -iy^3) \\ * B_y &=& b_4 x^3 - 3 b_4 x y^2 - 3 a_4 x^2 y + a_4 y^3 \\ diff --git a/DDCore/include/DD4hep/Fields.h b/DDCore/include/DD4hep/Fields.h index f101bc0f0137a0b5c9e789ad410cd64002830563..a8a200160f008802cfd4c6718378620edf3aa16b 100644 --- a/DDCore/include/DD4hep/Fields.h +++ b/DDCore/include/DD4hep/Fields.h @@ -39,7 +39,7 @@ namespace DD4hep { * \author M.Frank * \version 1.0 * \ingroup DD4HEP_GEOMETRY - */ + */ class CartesianField: public Ref_t { public: enum FieldType { @@ -69,18 +69,18 @@ namespace DD4hep { }; /// Default constructor - CartesianField() - : Ref_t() { + CartesianField() + : Ref_t() { } /// Constructor to be used when reading the already parsed DOM tree - CartesianField(const CartesianField& e) - : Ref_t(e) { + CartesianField(const CartesianField& e) + : Ref_t(e) { } /// Constructor to be used when reading the already parsed DOM tree template <typename Q> CartesianField(const Handle<Q>& e) - : Ref_t(e) { + : Ref_t(e) { } /// Assignment operator @@ -122,10 +122,10 @@ namespace DD4hep { * with field components in Cartesian coordinates. * * The actual behaviour is solely implemented in the underlying object - * classes. The overlay field is the sum of several magnetic of electric + * classes. The overlay field is the sum of several magnetic of electric * field components. * - * The resulting field vectors are computed by the vector addition + * The resulting field vectors are computed by the vector addition * of the individual components. * * \author M.Frank @@ -149,7 +149,7 @@ namespace DD4hep { class Object: public NamedObject { public: int type; - DD4hep::Geometry::CartesianField electric; + DD4hep::Geometry::CartesianField electric; DD4hep::Geometry::CartesianField magnetic; std::vector<DD4hep::Geometry::CartesianField> electric_components; std::vector<DD4hep::Geometry::CartesianField> magnetic_components; @@ -162,14 +162,14 @@ namespace DD4hep { }; /// Default constructor - OverlayedField() - : Ref_t() { + OverlayedField() + : Ref_t() { } /// Constructor to be used when reading the already parsed DOM tree template <typename Q> - OverlayedField(const Handle<Q>& e) - : Ref_t(e) { + OverlayedField(const Handle<Q>& e) + : Ref_t(e) { } /// Object constructor diff --git a/DDCore/include/DD4hep/GeoHandler.h b/DDCore/include/DD4hep/GeoHandler.h index d930734ce0bcb899a749b43a50b7c068a465d4ba..161e24c72f4129ae318f5455fb7fe6d947d7f074 100644 --- a/DDCore/include/DD4hep/GeoHandler.h +++ b/DDCore/include/DD4hep/GeoHandler.h @@ -88,7 +88,7 @@ namespace DD4hep { * Geometry crawlers are used for multiple purposes, whenever entire * geometries must be traversed like e.g. to create a new geometry * for simulation etc. - * While analysing the geometry, information is collected, which + * While analysing the geometry, information is collected, which * may be later processed. * * \author M.Frank diff --git a/DDCore/include/DD4hep/Handle.h b/DDCore/include/DD4hep/Handle.h index a2354f1428747adb6b1f3421599af932680befb5..22917aa921333392b6a85c8a2203eb8b6e83653b 100644 --- a/DDCore/include/DD4hep/Handle.h +++ b/DDCore/include/DD4hep/Handle.h @@ -57,7 +57,7 @@ namespace DD4hep { /// Pointer to text conversion std::string _ptrToString(const void* p, const char* fmt = "%p"); /// Format any pointer (64 bits) to string \ingroup DD4HEP_XML - template <typename T> std::string _toString(const T* p, const char* fmt = "%p") + template <typename T> std::string _toString(const T* p, const char* fmt = "%p") { return _ptrToString((void*)p, fmt); } /// String conversions: string to boolean value \ingroup DD4HEP_GEOMETRY @@ -160,15 +160,15 @@ namespace DD4hep { } /// Handle: a templated class like a shared pointer, which allows specialized access to tgeometry objects. - /** + /** * The Handle is the base class to access all objects in DD4hep. * Objects, which consist ONLY of data are NEVER passed directly. * They are ALWAYS passed using handles. Such handles are 'handy' ;-). - * Assignment is to and from different handles is possible using concrete + * Assignment is to and from different handles is possible using concrete * type checking. * * Real benefits can result from sophisticated handle subclasses, which can - * implement any desired user functionality with out compromising the + * implement any desired user functionality with out compromising the * object's data content. This leads to very flexible implementations, * where the same data may be shared by many handle implementations * providing different functionality to the clients. @@ -197,25 +197,25 @@ namespace DD4hep { /// Single and only data member: Reference to the actual element. T* m_element; /// Defaulot constructor - Handle() - : m_element(0) { + Handle() + : m_element(0) { } /// Initializing constructor from pointer - Handle(T* e) - : m_element(e) { + Handle(T* e) + : m_element(e) { } /// Copy constructor - Handle(const Handle<T>& e) - : m_element(e.m_element) { + Handle(const Handle<T>& e) + : m_element(e.m_element) { } /// Initializing constructor from unrelated pointer with type checking template <typename Q> Handle(Q* e) - : m_element((T*) e) { + : m_element((T*) e) { verifyObject(); } /// Initializing constructor from unrelated handle with type checking template <typename Q> Handle(const Handle<Q>& e) - : m_element((T*) e.m_element) { + : m_element((T*) e.m_element) { verifyObject(); } /// Assignment operator @@ -246,7 +246,7 @@ namespace DD4hep { /// Release the object held by the handle Handle<T>& clear() { m_element = 0; - return *this; + return *this; } /// Access the held object using the -> operator T* operator->() const { @@ -316,8 +316,8 @@ namespace DD4hep { template <typename M> class DestroyHandles { public: M& object; - DestroyHandles(M& m) - : object(m) { + DestroyHandles(M& m) + : object(m) { } ~DestroyHandles() { object.clear(); diff --git a/DDCore/include/DD4hep/Handle.inl b/DDCore/include/DD4hep/Handle.inl index 61208b4b80b22de4ef7bebac955b407bd1121937..48c328dd248226fa519ebacad13b18efb6085f5f 100644 --- a/DDCore/include/DD4hep/Handle.inl +++ b/DDCore/include/DD4hep/Handle.inl @@ -1,83 +1,83 @@ -// $Id: Handle.h 1059 2014-04-04 20:24:53Z markus.frank@cern.ch $ -//==================================================================== -// AIDA Detector description implementation for LCD -//-------------------------------------------------------------------- -// -// Author : M.Frank -// -//==================================================================== + // $Id: Handle.h 1059 2014-04-04 20:24:53Z markus.frank@cern.ch $ + //==================================================================== + // AIDA Detector description implementation for LCD + //-------------------------------------------------------------------- + // + // Author : M.Frank + // + //==================================================================== -// Framework include files -#include "DD4hep/Handle.h" + // Framework include files + #include "DD4hep/Handle.h" -/* - * DD4hep namespace declaration - */ -namespace DD4hep { + /* + * DD4hep namespace declaration + */ + namespace DD4hep { - /* - * Geometry sub-namespace declaration - */ - namespace Geometry { + /* + * Geometry sub-namespace declaration + */ + namespace Geometry { - template <typename T> void Handle<T>::bad_assignment(const std::type_info& from, const std::type_info& to) { - invalidHandleAssignmentError(from,to); - } - template <typename T> void Handle<T>::assign(T* n, const std::string& nam, const std::string& tit) { - this->m_element = n; - if (!nam.empty()) - n->SetName(nam.c_str()); - if (!tit.empty()) - n->SetTitle(tit.c_str()); - } + template <typename T> void Handle<T>::bad_assignment(const std::type_info& from, const std::type_info& to) { + invalidHandleAssignmentError(from,to); + } + template <typename T> void Handle<T>::assign(T* n, const std::string& nam, const std::string& tit) { + this->m_element = n; + if (!nam.empty()) + n->SetName(nam.c_str()); + if (!tit.empty()) + n->SetTitle(tit.c_str()); + } - template <typename T> const char* Handle<T>::name() const { - return this->m_element ? this->m_element->GetName() : ""; - } + template <typename T> const char* Handle<T>::name() const { + return this->m_element ? this->m_element->GetName() : ""; + } - /// Checked object access. Throws invalid handle runtime exception - template <typename T> T* Handle<T>::access() const { - if ( this->m_element ) return this->m_element; - invalidHandleError(typeid(T)); - return 0; // We have thrown an exception before - does not harm! - } + /// Checked object access. Throws invalid handle runtime exception + template <typename T> T* Handle<T>::access() const { + if ( this->m_element ) return this->m_element; + invalidHandleError(typeid(T)); + return 0; // We have thrown an exception before - does not harm! + } - } /* End namespace Geometry */ -} /* End namespace DD4hep */ + } /* End namespace Geometry */ + } /* End namespace DD4hep */ -#define DD4HEP_INSTANTIATE_HANDLE(X) \ - namespace DD4hep { namespace Geometry { \ - template <> void Handle<X>::verifyObject() const { \ - increment_object_validations(); \ - if (m_element && dynamic_cast<X*>((TObject*)m_element) == 0) { \ - bad_assignment(typeid(*m_element), typeid(X)); \ - } \ - }}} \ - template class DD4hep::Geometry::Handle<X> + #define DD4HEP_INSTANTIATE_HANDLE(X) \ + namespace DD4hep { namespace Geometry { \ + template <> void Handle<X>::verifyObject() const { \ + increment_object_validations(); \ + if (m_element && dynamic_cast<X*>((TObject*)m_element) == 0) { \ + bad_assignment(typeid(*m_element), typeid(X)); \ + } \ + }}} \ + template class DD4hep::Geometry::Handle<X> -#define DD4HEP_INSTANTIATE_HANDLE_NAMED(X) \ - namespace DD4hep { namespace Geometry { \ - template <> const char* Handle<X>::name() const \ - { return this->m_element ? this->m_element->name.c_str() : ""; } \ - template <> void \ - Handle<X>::assign(X* p, const std::string& n, const std::string& t) { \ - this->m_element = p; \ - p->name = n; \ - p->type = t; \ - } \ - template <> void Handle<X>::verifyObject() const { \ - increment_object_validations(); \ - if (m_element && dynamic_cast<X*>((NamedObject*)m_element) == 0) { \ - bad_assignment(typeid(*m_element), typeid(X)); \ - } \ - }}} \ - template class DD4hep::Geometry::Handle<X> + #define DD4HEP_INSTANTIATE_HANDLE_NAMED(X) \ + namespace DD4hep { namespace Geometry { \ + template <> const char* Handle<X>::name() const \ + { return this->m_element ? this->m_element->name.c_str() : ""; } \ + template <> void \ + Handle<X>::assign(X* p, const std::string& n, const std::string& t) { \ + this->m_element = p; \ + p->name = n; \ + p->type = t; \ + } \ + template <> void Handle<X>::verifyObject() const { \ + increment_object_validations(); \ + if (m_element && dynamic_cast<X*>((NamedObject*)m_element) == 0) { \ + bad_assignment(typeid(*m_element), typeid(X)); \ + } \ + }}} \ + template class DD4hep::Geometry::Handle<X> -#define DD4HEP_INSTANTIATE_HANDLE_UNNAMED(X) \ - namespace DD4hep { namespace Geometry { \ - template <> void \ - Handle<X>::assign(X* n, const std::string&, const std::string&) \ - { this->m_element = n;} \ - template <> const char* Handle<X>::name() const { return ""; } \ - }} \ - DD4HEP_INSTANTIATE_HANDLE(X) + #define DD4HEP_INSTANTIATE_HANDLE_UNNAMED(X) \ + namespace DD4hep { namespace Geometry { \ + template <> void \ + Handle<X>::assign(X* n, const std::string&, const std::string&) \ + { this->m_element = n;} \ + template <> const char* Handle<X>::name() const { return ""; } \ + }} \ + DD4HEP_INSTANTIATE_HANDLE(X) diff --git a/DDCore/include/DD4hep/IDDescriptor.h b/DDCore/include/DD4hep/IDDescriptor.h index 6678ab95a68e4b52fdaa53f0da70f8f47ec001a7..9c18c039f718da15c0c9a25380be8c97838b00ff 100644 --- a/DDCore/include/DD4hep/IDDescriptor.h +++ b/DDCore/include/DD4hep/IDDescriptor.h @@ -49,12 +49,12 @@ namespace DD4hep { public: /// Default constructor - IDDescriptor() - : Handle<Object>() { + IDDescriptor() + : Handle<Object>() { } /// Constructor to be used when reading the already parsed object template <typename Q> IDDescriptor(const Handle<Q>& e) - : Handle<Object>(e) { + : Handle<Object>(e) { } /// Initializing constructor IDDescriptor(const std::string& description); diff --git a/DDCore/include/DD4hep/InstanceCount.h b/DDCore/include/DD4hep/InstanceCount.h index 4756236de3d6951dbaf910ecf8cd657d6e5da217..6b200b641a4e5ab04094f3e683fbb25d9bc61051 100644 --- a/DDCore/include/DD4hep/InstanceCount.h +++ b/DDCore/include/DD4hep/InstanceCount.h @@ -50,12 +50,12 @@ namespace DD4hep { counter_t m_max; public: /// Default constructor - Counter() - : m_count(0), m_tot(0), m_max(0) { + Counter() + : m_count(0), m_tot(0), m_max(0) { } /// Copy constructor - Counter(const Counter& c) - : m_count(c.m_count), m_tot(c.m_tot), m_max(c.m_max) { + Counter(const Counter& c) + : m_count(c.m_count), m_tot(c.m_tot), m_max(c.m_max) { } /// Destructor ~Counter() { @@ -64,7 +64,7 @@ namespace DD4hep { void increment() { ++m_count; ++m_tot; - m_max = std::max(m_max,m_count); + m_max = std::max(m_max,m_count); } /// Decrement counter void decrement() { diff --git a/DDCore/include/DD4hep/LCDD.h b/DDCore/include/DD4hep/LCDD.h index 4a0c2a7c0e82c1176eb32990b8f19438c35c89a4..3eaf433ae7bde95519b299a0a97a35247655891e 100644 --- a/DDCore/include/DD4hep/LCDD.h +++ b/DDCore/include/DD4hep/LCDD.h @@ -44,10 +44,10 @@ namespace DD4hep { BUILD_NONE = 0, BUILD_DEFAULT = 1, BUILD_SIMU = BUILD_DEFAULT, BUILD_RECO, BUILD_DISPLAY }; - /// Namespace for the geometry part of the AIDA detector description toolkit + /// Namespace for the geometry part of the AIDA detector description toolkit namespace Geometry { - /// The main interface to the DD4hep detector description package + /// The main interface to the DD4hep detector description package /** * Note: The usage of the factory method: * diff --git a/DDCore/include/DD4hep/LCDDData.h b/DDCore/include/DD4hep/LCDDData.h index 38bd14b3bc57b48b68a730ee408f9fcc9ed806b7..6a36b8de86c4f011918f7aeb6ee68edd7ae18e13 100644 --- a/DDCore/include/DD4hep/LCDDData.h +++ b/DDCore/include/DD4hep/LCDDData.h @@ -42,9 +42,9 @@ namespace DD4hep { * \version 1.0 * \ingroup DD4HEP_GEOMETRY */ - struct InvalidObjectError: public std::runtime_error { + struct InvalidObjectError: public std::runtime_error { InvalidObjectError(const std::string& msg) - : std::runtime_error("DD4hep: " + msg) { + : std::runtime_error("DD4hep: " + msg) { } }; @@ -57,7 +57,7 @@ namespace DD4hep { */ class ObjectHandleMap: public LCDD::HandleMap { public: - /// Default constructor + /// Default constructor ObjectHandleMap() { } void append(const Ref_t& e, bool throw_on_doubles = true) { diff --git a/DDCore/include/DD4hep/NamedObject.h b/DDCore/include/DD4hep/NamedObject.h index 6ed319c8412942bc89d974ac2ae7963539266bb0..c798f76e2d7506cc70df6ce1ea3a322b65661401 100644 --- a/DDCore/include/DD4hep/NamedObject.h +++ b/DDCore/include/DD4hep/NamedObject.h @@ -15,53 +15,53 @@ /// Namespace for the AIDA detector description toolkit namespace DD4hep { - /// Implementation of a named object - /** - * The data class behind named object handles. - * - * \author M.Frank - * \version 1.0 - * \ingroup DD4HEP_GEOMETRY - */ - class NamedObject { - public: - /// The object name - std::string name; - /// The object type - std::string type; + /// Implementation of a named object + /** + * The data class behind named object handles. + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_GEOMETRY + */ + class NamedObject { + public: + /// The object name + std::string name; + /// The object type + std::string type; - /// Standard constructor - NamedObject(); - /// Initializing constructor - NamedObject(const char* nam, const char* typ=""); - /// Initializing constructor - NamedObject(const std::string& nam); - /// Initializing constructor - NamedObject(const std::string& nam, const std::string& typ); - /// Copy constructor - NamedObject(const NamedObject& c); - /// Default destructor - virtual ~NamedObject(); - /// Assignment operator - NamedObject& operator=(const NamedObject& c); + /// Standard constructor + NamedObject(); + /// Initializing constructor + NamedObject(const char* nam, const char* typ=""); + /// Initializing constructor + NamedObject(const std::string& nam); + /// Initializing constructor + NamedObject(const std::string& nam, const std::string& typ); + /// Copy constructor + NamedObject(const NamedObject& c); + /// Default destructor + virtual ~NamedObject(); + /// Assignment operator + NamedObject& operator=(const NamedObject& c); - /// Access name - const char* GetName() const { - return name.c_str(); - } - /// Set name (used by Handle) - void SetName(const char* nam) { - name = nam; - } - /// Set Title (used by Handle) - void SetTitle(const char* tit) { - type = tit; - } - /// Get name (used by Handle) - const char* GetTitle() const { - return type.c_str(); - } - }; + /// Access name + const char* GetName() const { + return name.c_str(); + } + /// Set name (used by Handle) + void SetName(const char* nam) { + name = nam; + } + /// Set Title (used by Handle) + void SetTitle(const char* tit) { + type = tit; + } + /// Get name (used by Handle) + const char* GetTitle() const { + return type.c_str(); + } + }; } /* End namespace DD4hep */ #endif /* DD4HEP_GEOMETRY_INTERNAL_NAMEDOBJECT_H */ diff --git a/DDCore/include/DD4hep/Objects.h b/DDCore/include/DD4hep/Objects.h index b9af4179125fc593d357645c6a9c41cf5aac918f..4643d8aab5fa9bc63504219d9632e794adc89e3c 100644 --- a/DDCore/include/DD4hep/Objects.h +++ b/DDCore/include/DD4hep/Objects.h @@ -68,7 +68,7 @@ namespace DD4hep { TGeoIdentity* identityTransform(); /// Handle class describing an author entity - /** + /** * \author M.Frank * \version 1.0 * \ingroup DD4HEP_GEOMETRY @@ -78,26 +78,26 @@ namespace DD4hep { /// Definition of the implementation type typedef NamedObject Object; /// Default constructor - Author() - : Ref_t() { + Author() + : Ref_t() { } /// Constructorto be used for assignment from a handle - Author(const Author& e) - : Ref_t(e) { + Author(const Author& e) + : Ref_t(e) { } /// Constructor to be used when assigning already valid handle template <typename Q> - Author(const Handle<Q>& e) - : Ref_t(e) { + Author(const Handle<Q>& e) + : Ref_t(e) { } /// Constructor to be used when creating a new object Author(LCDD& doc); /// Assignment operator Author& operator=(const Author& e) { - if ( this != & e ) { - m_element = e.m_element; - } - return *this; + if ( this != & e ) { + m_element = e.m_element; + } + return *this; } /// Access the auhor's name std::string authorName() const; @@ -121,25 +121,25 @@ namespace DD4hep { public: typedef HeaderObject Object; /// Default constructor - Header() - : Handle<HeaderObject>() { + Header() + : Handle<HeaderObject>() { } /// Constructorto be used for assignment from a handle - Header(const Header& e) - : Handle<HeaderObject>(e) { + Header(const Header& e) + : Handle<HeaderObject>(e) { } /// Constructor to be used when reading the already parsed DOM tree template <typename Q> Header(const Handle<Q>& e) - : Handle<HeaderObject>(e) { + : Handle<HeaderObject>(e) { } /// Constructor to be used when creating a new DOM tree Header(const std::string& author, const std::string& url); /// Assignment operator Header& operator=(const Header& e) { - if ( this != & e ) { - m_element = e.m_element; - } - return *this; + if ( this != & e ) { + m_element = e.m_element; + } + return *this; } /// Accessor to object name const std::string name() const; @@ -172,7 +172,7 @@ namespace DD4hep { }; /// Handle class describing a constant (define) object in lcdd - /** + /** * Constant objects are parsed by the expression evaluator and * are subsequently available for expression evaluation. * @@ -185,17 +185,17 @@ namespace DD4hep { /// Definition of the implementation type typedef ConstantObject Object; /// Default constructor - Constant() - : Handle<ConstantObject> () { + Constant() + : Handle<ConstantObject> () { } /// Constructorto be used for assignment from a handle - Constant(const Constant& e) - : Handle<ConstantObject> (e) { + Constant(const Constant& e) + : Handle<ConstantObject> (e) { } /// Constructor to be used when reading the already parsed DOM tree template <typename Q> - Constant(const Handle<Q>& e) - : Handle<ConstantObject> (e) { + Constant(const Handle<Q>& e) + : Handle<ConstantObject> (e) { } /// Constructor to be used when creating a new DOM tree Constant(const std::string& name); @@ -245,7 +245,7 @@ namespace DD4hep { typedef ROOT::Math::Translation3D Translation3D; /// Handle class describing an element in the periodic table - /** + /** * For details please see the ROOT TGeo information: * \see http://root.cern.ch/root/html/TGeoElement.html * @@ -258,19 +258,19 @@ namespace DD4hep { /// Definition of the implementation type typedef TGeoElement Object; /// Default constructor - Atom() - : Handle<Object>() { + Atom() + : Handle<Object>() { } #ifndef __CINT__ /// Constructorto be used for assignment from a handle - Atom(const Handle<Object>& e) - : Handle<Object>(e) { + Atom(const Handle<Object>& e) + : Handle<Object>(e) { } #endif /// Constructor to be used when creating from a object handle template <typename Q> - Atom(const Handle<Q>& e) - : Handle<Object>(e) { + Atom(const Handle<Q>& e) + : Handle<Object>(e) { } /// Constructor to be used when reading the already parsed DOM tree Atom(const std::string& name, const std::string& formula, int Z, int N, double density); @@ -292,19 +292,19 @@ namespace DD4hep { typedef TGeoMedium Object; /// Default constructor - Material() - : Handle<Object>() { + Material() + : Handle<Object>() { } #ifndef __CINT__ /// Constructorto be used for assignment from material handle - Material(const Handle<Object>& e) - : Handle<Object>(e) { + Material(const Handle<Object>& e) + : Handle<Object>(e) { } #endif /// Constructorto be used for assignment from object handle template <typename Q> - Material(const Handle<Q>& e) - : Handle<Object>(e) { + Material(const Handle<Q>& e) + : Handle<Object>(e) { } /// proton number of the underlying material double Z() const ; @@ -334,23 +334,23 @@ namespace DD4hep { }; typedef VisAttrObject Object; /// Default constructor - VisAttr() - : Handle<Object>() { + VisAttr() + : Handle<Object>() { } /// Copy constructor for handle - VisAttr(const VisAttr& e) - : Handle<Object>(e) { + VisAttr(const VisAttr& e) + : Handle<Object>(e) { } #ifndef __CINT__ /// Copy constructor for handle - VisAttr(const Handle<Object>& e) - : Handle<Object>(e) { + VisAttr(const Handle<Object>& e) + : Handle<Object>(e) { } #endif /// Constructor to be used for assignment from object handle template <typename Q> - VisAttr(const Handle<Q>& e) - : Handle<Object>(e) { + VisAttr(const Handle<Q>& e) + : Handle<Object>(e) { } /// Constructor to be used when creating a new registered visualization object VisAttr(const std::string& name); @@ -411,8 +411,8 @@ namespace DD4hep { typedef Handle<TGeoPhysicalNode> Base; /// Constructor to be used when reading the already parsed DOM tree template <typename Q> - AlignmentEntry(const Handle<Q>& h) - : Base(h) { + AlignmentEntry(const Handle<Q>& h) + : Base(h) { } /// Constructor to be used when creating a new aligment entry AlignmentEntry(const std::string& path); @@ -425,7 +425,7 @@ namespace DD4hep { }; /// Small object describing a limit structure acting on a particle type - /** + /** * \author M.Frank * \version 1.0 * \ingroup DD4HEP_GEOMETRY @@ -438,12 +438,12 @@ namespace DD4hep { std::string content; double value; /// Default constructor - Limit() - : particles(), name(), unit(), content(), value(0.0) { + Limit() + : particles(), name(), unit(), content(), value(0.0) { } /// Copy constructor - Limit(const Limit& c) - : particles(c.particles), name(c.name), unit(c.unit), content(c.content), value(c.value) { + Limit(const Limit& c) + : particles(c.particles), name(c.name), unit(c.unit), content(c.content), value(c.value) { } /// Assignment operator Limit& operator=(const Limit& c); @@ -465,23 +465,23 @@ namespace DD4hep { public: typedef LimitSetObject Object; /// Constructor to be used when reading the already parsed DOM tree - LimitSet() - : Handle<LimitSetObject>() { + LimitSet() + : Handle<LimitSetObject>() { } /// Copy constructor for handle - LimitSet(const LimitSet& e) - : Handle<LimitSetObject>(e) { + LimitSet(const LimitSet& e) + : Handle<LimitSetObject>(e) { } #ifndef __CINT__ /// Copy constructor for handle - LimitSet(const Handle<LimitSetObject>& e) - : Handle<LimitSetObject>(e) { + LimitSet(const Handle<LimitSetObject>& e) + : Handle<LimitSetObject>(e) { } #endif /// Constructor to be used when reading the already parsed DOM tree template <typename Q> - LimitSet(const Handle<Q>& e) - : Handle<LimitSetObject>(e) { + LimitSet(const Handle<Q>& e) + : Handle<LimitSetObject>(e) { } /// Constructor to be used when creating a new object LimitSet(const std::string& name); @@ -502,23 +502,23 @@ namespace DD4hep { /// Implemeting class typedef RegionObject Object; /// Default constructor - Region() - : Handle<Object>() { + Region() + : Handle<Object>() { } /// Copy Constructor - Region(const Region& e) - : Handle<Object>(e) { + Region(const Region& e) + : Handle<Object>(e) { } #ifndef __CINT__ /// Copy Constructor - Region(const Handle<RegionObject>& e) - : Handle<Object>(e) { + Region(const Handle<RegionObject>& e) + : Handle<Object>(e) { } #endif /// Constructor to be used when assigning handle template <typename Q> - Region(const Handle<Q>& e) - : Handle<Object>(e) { + Region(const Handle<Q>& e) + : Handle<Object>(e) { } /// Constructor to be used when creating a new object Region(const std::string& name); diff --git a/DDCore/include/DD4hep/Parsers.h b/DDCore/include/DD4hep/Parsers.h index 802c8cf25a39ebfc3c5c26d4aeb537d960f73526..b1f46e5bfdf3db3bcddd4613d57428f572a092db 100644 --- a/DDCore/include/DD4hep/Parsers.h +++ b/DDCore/include/DD4hep/Parsers.h @@ -16,15 +16,15 @@ #include "Math/Vector4D.h" // ============================================================================ -#define PARSERS_DECL_FOR_SINGLE(Type) \ +#define PARSERS_DECL_FOR_SINGLE(Type) \ int parse(Type& result, const std::string& input); -#define PARSERS_DECL_FOR_PAIR(FirstType, SecondType) \ +#define PARSERS_DECL_FOR_PAIR(FirstType, SecondType) \ int parse(std::pair<FirstType, SecondType >& result,const std::string& input); -#define PARSERS_DECL_FOR_LIST(InnerType) \ - int parse(std::vector<InnerType>& result,const std::string& input); \ - int parse(std::list<InnerType>& result,const std::string& input); \ +#define PARSERS_DECL_FOR_LIST(InnerType) \ + int parse(std::vector<InnerType>& result,const std::string& input); \ + int parse(std::list<InnerType>& result,const std::string& input); \ int parse(std::set<InnerType>& result,const std::string& input); // ============================================================================ /** @file @@ -77,147 +77,147 @@ namespace DD4hep { * @date 2006-05-12 */ PARSERS_DECL_FOR_SINGLE(bool) - // ======================================================================== - /// parse the <c>char</c> value - /** - * @see DD4hep::Parsers::CharGrammar - * @param result (output) boolean result - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-12 - */ - PARSERS_DECL_FOR_SINGLE(char) - /// @see DD4hep::Parsers::parser(char&,std::string&) - PARSERS_DECL_FOR_SINGLE(unsigned char) - /// @see DD4hep::Parsers::parser(char&,std::string&) - PARSERS_DECL_FOR_SINGLE(signed char) - // ======================================================================== - /// parse the <c>int</c> value - /** - * @see DD4hep::Parsers::IntGrammar - * @param result (output) integer result - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - PARSERS_DECL_FOR_SINGLE(int) - /// @see DD4hep::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE(short) - /// @see DD4hep::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE(unsigned short) - /// @see DD4hep::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE(unsigned int) - /// @see DD4hep::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE(long) - /// @see DD4hep::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE(unsigned long) - /// @see DD4hep::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE(long long) - /// @see DD4hep::Parsers::parser( int&, const std::string& ) - PARSERS_DECL_FOR_SINGLE(unsigned long long) - // ======================================================================== - /// parse the <c>double</c> value - /** - * @see DD4hep::Parsers::RealGrammar - * @param result (output) double result - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - PARSERS_DECL_FOR_SINGLE(double) - /// @see DD4hep::Parsers::parser( double&, const std::string& ) - PARSERS_DECL_FOR_SINGLE(float) - /// @see DD4hep::Parsers::parser( double&, const std::string& ) - PARSERS_DECL_FOR_SINGLE(long double) - // ======================================================================== - /** parse the <c>std::string</c> value - * - * @see DD4hep::Parsers::StringGrammar - * @param result (output) string result - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - PARSERS_DECL_FOR_SINGLE(std::string) - // ======================================================================== + // ======================================================================== + /// parse the <c>char</c> value + /** + * @see DD4hep::Parsers::CharGrammar + * @param result (output) boolean result + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-12 + */ + PARSERS_DECL_FOR_SINGLE(char) + /// @see DD4hep::Parsers::parser(char&,std::string&) + PARSERS_DECL_FOR_SINGLE(unsigned char) + /// @see DD4hep::Parsers::parser(char&,std::string&) + PARSERS_DECL_FOR_SINGLE(signed char) + // ======================================================================== + /// parse the <c>int</c> value + /** + * @see DD4hep::Parsers::IntGrammar + * @param result (output) integer result + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + PARSERS_DECL_FOR_SINGLE(int) + /// @see DD4hep::Parsers::parser( int&, const std::string& ) + PARSERS_DECL_FOR_SINGLE(short) + /// @see DD4hep::Parsers::parser( int&, const std::string& ) + PARSERS_DECL_FOR_SINGLE(unsigned short) + /// @see DD4hep::Parsers::parser( int&, const std::string& ) + PARSERS_DECL_FOR_SINGLE(unsigned int) + /// @see DD4hep::Parsers::parser( int&, const std::string& ) + PARSERS_DECL_FOR_SINGLE(long) + /// @see DD4hep::Parsers::parser( int&, const std::string& ) + PARSERS_DECL_FOR_SINGLE(unsigned long) + /// @see DD4hep::Parsers::parser( int&, const std::string& ) + PARSERS_DECL_FOR_SINGLE(long long) + /// @see DD4hep::Parsers::parser( int&, const std::string& ) + PARSERS_DECL_FOR_SINGLE(unsigned long long) + // ======================================================================== + /// parse the <c>double</c> value + /** + * @see DD4hep::Parsers::RealGrammar + * @param result (output) double result + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + PARSERS_DECL_FOR_SINGLE(double) + /// @see DD4hep::Parsers::parser( double&, const std::string& ) + PARSERS_DECL_FOR_SINGLE(float) + /// @see DD4hep::Parsers::parser( double&, const std::string& ) + PARSERS_DECL_FOR_SINGLE(long double) + // ======================================================================== + /** parse the <c>std::string</c> value + * + * @see DD4hep::Parsers::StringGrammar + * @param result (output) string result + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + PARSERS_DECL_FOR_SINGLE(std::string) + // ======================================================================== - PARSERS_DECL_FOR_LIST(bool) - PARSERS_DECL_FOR_LIST(char) - PARSERS_DECL_FOR_LIST(unsigned char) - PARSERS_DECL_FOR_LIST(signed char) + PARSERS_DECL_FOR_LIST(bool) + PARSERS_DECL_FOR_LIST(char) + PARSERS_DECL_FOR_LIST(unsigned char) + PARSERS_DECL_FOR_LIST(signed char) - PARSERS_DECL_FOR_LIST(int) - PARSERS_DECL_FOR_LIST(short) - PARSERS_DECL_FOR_LIST(unsigned short) - PARSERS_DECL_FOR_LIST(unsigned int) - PARSERS_DECL_FOR_LIST(long) - PARSERS_DECL_FOR_LIST(unsigned long) - PARSERS_DECL_FOR_LIST(long long) - PARSERS_DECL_FOR_LIST(unsigned long long) + PARSERS_DECL_FOR_LIST(int) + PARSERS_DECL_FOR_LIST(short) + PARSERS_DECL_FOR_LIST(unsigned short) + PARSERS_DECL_FOR_LIST(unsigned int) + PARSERS_DECL_FOR_LIST(long) + PARSERS_DECL_FOR_LIST(unsigned long) + PARSERS_DECL_FOR_LIST(long long) + PARSERS_DECL_FOR_LIST(unsigned long long) - PARSERS_DECL_FOR_LIST(double) - PARSERS_DECL_FOR_LIST(float) - PARSERS_DECL_FOR_LIST(long double) + PARSERS_DECL_FOR_LIST(double) + PARSERS_DECL_FOR_LIST(float) + PARSERS_DECL_FOR_LIST(long double) - PARSERS_DECL_FOR_LIST(std::string) - // ======================================================================== - // Advanced parses - // ======================================================================== - /// parse the <c>std::pair\<double,double\></c> value - /** - * @see DD4hep::Parsers::PairGrammar - * @see DD4hep::Parsers::RealGrammar - * @param result (output) pair of doubles - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - PARSERS_DECL_FOR_PAIR(double, double) - // ======================================================================== - /** parse the <c>std::pair\<int,int\></c> value - * - * @see DD4hep::Parsers::PairGrammar - * @see DD4hep::Parsers::IntGrammar - * @param result (output) pair of integers - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - PARSERS_DECL_FOR_PAIR(int, int) - // ======================================================================== + PARSERS_DECL_FOR_LIST(std::string) + // ======================================================================== + // Advanced parses + // ======================================================================== + /// parse the <c>std::pair\<double,double\></c> value + /** + * @see DD4hep::Parsers::PairGrammar + * @see DD4hep::Parsers::RealGrammar + * @param result (output) pair of doubles + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + PARSERS_DECL_FOR_PAIR(double, double) + // ======================================================================== + /** parse the <c>std::pair\<int,int\></c> value + * + * @see DD4hep::Parsers::PairGrammar + * @see DD4hep::Parsers::IntGrammar + * @param result (output) pair of integers + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + PARSERS_DECL_FOR_PAIR(int, int) + // ======================================================================== - /// parse the <c>std::vector\<std::pair\<double,double\> \></c> value - /** - * @see DD4hep::Parsers::VectorGrammar - * @see DD4hep::Parsers::PairGrammar - * @see DD4hep::Parsers::RealGrammar - * @param result (output) vector with pairs of doubles - * @param input (input) the string to be parsed - * @return status code - * - * @author Alexander MAZUROV Alexander.Mazurov@gmail.com - * @author Vanya BELYAEV ibelyaev@physics.syr.edu - * @date 2006-05-14 - */ - int parse(std::vector<std::pair<double, double> >& result, const std::string& input); + /// parse the <c>std::vector\<std::pair\<double,double\> \></c> value + /** + * @see DD4hep::Parsers::VectorGrammar + * @see DD4hep::Parsers::PairGrammar + * @see DD4hep::Parsers::RealGrammar + * @param result (output) vector with pairs of doubles + * @param input (input) the string to be parsed + * @return status code + * + * @author Alexander MAZUROV Alexander.Mazurov@gmail.com + * @author Vanya BELYAEV ibelyaev@physics.syr.edu + * @date 2006-05-14 + */ + int parse(std::vector<std::pair<double, double> >& result, const std::string& input); // ======================================================================== /// parse the <c>std::vector\<std::pair\<int,int\> \></c> value /** @@ -465,7 +465,7 @@ namespace DD4hep { * @date 2009-09-15 */ template <class T, unsigned int N> - int parse(T (&result)[N], const std::string& input) { + int parse(T (&result)[N], const std::string& input) { typedef std::vector<T> _Vct; // create the temporary vector _Vct tmp; @@ -490,7 +490,7 @@ namespace DD4hep { * @date 2009-09-15 */ template <unsigned int N> - int parse(char (&result)[N], const std::string& input) { + int parse(char (&result)[N], const std::string& input) { // clear the string std::fill_n(result, N, ' '); // create the temporary string @@ -513,22 +513,22 @@ namespace DD4hep { } // ======================================================================== - /// parse 3D-point + /// parse 3D-point /** * Valid representations of 3D-point: * * - a'la python tuple with 3 elements ("canonical") - * - a'la python list with 3 elements - * - tuple or list with named ordered fields + * - a'la python list with 3 elements + * - tuple or list with named ordered fields * * @code * - * " (1,2,3) " - * " [1,2,3] " - * " [ x : 1, 2, Z:3 ] " - * " [ pX : 1 , PY : 2, 3] " - * - * @endcode + * " (1,2,3) " + * " [1,2,3] " + * " [ x : 1, 2, Z:3 ] " + * " [ pX : 1 , PY : 2, 3] " + * + * @endcode * * Valid keys for names fields: * @@ -538,35 +538,35 @@ namespace DD4hep { * "y", "Y" , "pY" , "Py" , "PY " * "z", "Z" , "pZ" , "Pz" , "PZ " * - * @endcode + * @endcode * * @attention Named fields must be ordered <code>(x,y,z)</code> * - * @param result (output) the parsed point - * @param input (input) the input string - * @return status code + * @param result (output) the parsed point + * @param input (input) the input string + * @return status code * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl * @date 2009-09-05 */ int parse(ROOT::Math::XYZPoint& result, const std::string& input); // ======================================================================== - /// parse 3D-vector + /// parse 3D-vector /** * Valid representations of 3D-vector: * * - a'la python tuple with 3 elements ("canonical") - * - a'la python list with 3 elements - * - tuple or list with named ordered fields + * - a'la python list with 3 elements + * - tuple or list with named ordered fields * * @code * - * " (1,2,3) " - * " [1,2,3] " - * " [ x : 1, 2, Z:3 ] " - * " [ pX : 1 , PY : 2, 3] " - * - * @endcode + * " (1,2,3) " + * " [1,2,3] " + * " [ x : 1, 2, Z:3 ] " + * " [ pX : 1 , PY : 2, 3] " + * + * @endcode * * Valid keys for names fields: * @@ -576,13 +576,13 @@ namespace DD4hep { * "y", "Y" , "pY" , "Py" , "PY " * "z", "Z" , "pZ" , "Pz" , "PZ " * - * @endcode + * @endcode * * @attention Named fields must be ordered <code>(x,y,z)</code> * * @param result (output) the parsed vector - * @param input (input) the input string - * @return status code + * @param input (input) the input string + * @return status code * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl * @date 2009-09-05 */ @@ -594,47 +594,47 @@ namespace DD4hep { * Valid representations of Lorenzt vector * * - a'la python tuple with 4 elements ("canonical") - * - a'la python list with 4 elements + * - a'la python list with 4 elements * - python/list with inner representation of 3D-point/vector - * - tuple or list with named ordered fields + * - tuple or list with named ordered fields * * @code * - * " (1,2,3,4) " + * " (1,2,3,4) " * " (1,2,3;4) " * - * " [1,2,3,4] " - * " [1,2,3;4] " + * " [1,2,3,4] " + * " [1,2,3;4] " * - * " [ x:1 ,2,3; e= 4] " - * " [ pX : 1 , PY : 2, 3 , T= 4] " + * " [ x:1 ,2,3; e= 4] " + * " [ pX : 1 , PY : 2, 3 , T= 4] " * - * " [ ( pX : 1 , PY : 2, 3 ) , 4] " - * " [ ( pX : 1 , PY : 2, 3 ) ; 4] " + * " [ ( pX : 1 , PY : 2, 3 ) , 4] " + * " [ ( pX : 1 , PY : 2, 3 ) ; 4] " * - * " [ 4 , ( pX : 1 , PY : 2, 3 ) ] " - * " [ 4 ; ( pX : 1 , PY : 2, 3 ) ] " + * " [ 4 , ( pX : 1 , PY : 2, 3 ) ] " + * " [ 4 ; ( pX : 1 , PY : 2, 3 ) ] " * - * " [ [ pX : 1 , PY : 2, 3 ] , 4] " - * " [ [ pX : 1 , PY : 2, 3 ] ; 4] " + * " [ [ pX : 1 , PY : 2, 3 ] , 4] " + * " [ [ pX : 1 , PY : 2, 3 ] ; 4] " * - * " [ 4 , [ pX : 1 , PY : 2, 3 ] ] " - * " [ 4 ; [ pX : 1 , PY : 2, 3 ] ] " + * " [ 4 , [ pX : 1 , PY : 2, 3 ] ] " + * " [ 4 ; [ pX : 1 , PY : 2, 3 ] ] " * - * " ( ( pX : 1 , PY : 2, 3 ) , 4 )" - * " ( ( pX : 1 , PY : 2, 3 ) ; 4 )" + * " ( ( pX : 1 , PY : 2, 3 ) , 4 )" + * " ( ( pX : 1 , PY : 2, 3 ) ; 4 )" * - * " ( 4 , ( pX : 1 , PY : 2, 3 ) )" - * " ( 4 ; ( pX : 1 , PY : 2, 3 ) )" + * " ( 4 , ( pX : 1 , PY : 2, 3 ) )" + * " ( 4 ; ( pX : 1 , PY : 2, 3 ) )" * - * " ( [ pX : 1 , PY : 2, 3 ] , 4 )" - * " ( [ pX : 1 , PY : 2, 3 ] ; 4 )" + * " ( [ pX : 1 , PY : 2, 3 ] , 4 )" + * " ( [ pX : 1 , PY : 2, 3 ] ; 4 )" * - * " ( 4 , [ pX : 1 , PY : 2, 3 ] )" - * " ( 4 ; [ pX : 1 , PY : 2, 3 ] )" + * " ( 4 , [ pX : 1 , PY : 2, 3 ] )" + * " ( 4 ; [ pX : 1 , PY : 2, 3 ] )" * - * - * @endcode + * + * @endcode * * Note that "eenrgy" element can be separated with semicolumn. * @@ -645,23 +645,23 @@ namespace DD4hep { * "x", "X" , "pX" , "Px" , "PX " * "y", "Y" , "pY" , "Py" , "PY " * "z", "Z" , "pZ" , "Pz" , "PZ " - * "t", "T" , "e" , "E" + * "t", "T" , "e" , "E" * - * @endcode + * @endcode * * @attention Named fields must be ordered <code>(x,y,z)</code> * - * @param result (output) the parsed lorentz vector - * @param input (input) the input string - * @return status code + * @param result (output) the parsed lorentz vector + * @param input (input) the input string + * @return status code * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl * @date 2009-09-05 */ int parse(ROOT::Math::PxPyPzEVector& result, const std::string& input); // ======================================================================== - /// parse the vector of points - /** @param result (OUTPUT) the parser vector - * @param input (INPIUT) the string to be parsed + /// parse the vector of points + /** @param result (OUTPUT) the parser vector + * @param input (INPIUT) the string to be parsed * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl * @date 2009-09-05 */ @@ -669,9 +669,9 @@ namespace DD4hep { int parse( std::list<ROOT::Math::XYZPoint>& result, const std::string& input); int parse( std::set<ROOT::Math::XYZPoint>& result, const std::string& input); // ======================================================================== - /// parse the vector of vectors - /** @param result (OUTPUT) the parser vector - * @param input (INPIUT) the string to be parsed + /// parse the vector of vectors + /** @param result (OUTPUT) the parser vector + * @param input (INPIUT) the string to be parsed * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl * @date 2009-09-05 */ @@ -679,9 +679,9 @@ namespace DD4hep { int parse( std::list<ROOT::Math::XYZVector>& result, const std::string& input); int parse( std::set<ROOT::Math::XYZVector>& result, const std::string& input); // ======================================================================== - /// parse the vector of vectors - /** @param result (OUTPUT) the parser vector - * @param input (INPIUT) the string to be parsed + /// parse the vector of vectors + /** @param result (OUTPUT) the parser vector + * @param input (INPIUT) the string to be parsed * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl * @date 2009-09-05 */ @@ -689,9 +689,9 @@ namespace DD4hep { int parse(std::list<ROOT::Math::PxPyPzEVector>& result, const std::string& input); int parse(std::set<ROOT::Math::PxPyPzEVector>& result, const std::string& input); - // ======================================================================== + // ======================================================================== }// end of namespace Parsers -// ========================================================================== + // ========================================================================== }// end of namespace DD4hep // ============================================================================ // The END diff --git a/DDCore/include/DD4hep/Plugins.h b/DDCore/include/DD4hep/Plugins.h index 72dd8bf20a4700b725fec8433485ed9af4ee8160..b7fcbaa38da742fcfd0ccdd5d56311a5380287ca 100644 --- a/DDCore/include/DD4hep/Plugins.h +++ b/DDCore/include/DD4hep/Plugins.h @@ -20,7 +20,7 @@ namespace DD4hep { typedef ROOT::Reflex::PluginService PluginService; /// Helper to debug plugin manager calls - /** + /** * Small helper class to adjust the plugin service debug level * for a limited code scope. Automatically back-adjusts the debug * level at object destruction. diff --git a/DDCore/include/DD4hep/Primitives.h b/DDCore/include/DD4hep/Primitives.h index 1dbc74efc53eeb0be01ab0c88ceb3712ab70a7b8..8debffde35e767a954dac92d82972b602e057eb1 100644 --- a/DDCore/include/DD4hep/Primitives.h +++ b/DDCore/include/DD4hep/Primitives.h @@ -28,11 +28,11 @@ namespace DD4hep { unsigned int hash = 0; const char* k = key; for (; *k; k++) { - hash += *k; - hash += (hash << 10); + hash += *k; + hash += (hash << 10); hash ^= (hash >> 6); } - hash += (hash << 3); + hash += (hash << 3); hash ^= (hash >> 11); hash += (hash << 15); return hash; } @@ -56,7 +56,7 @@ namespace DD4hep { /** @class ComponentCast Primitives.h DD4hep/Primitives.h * * It is mandatory that the pointers referred do actually - * support the asked functionalty. + * support the asked functionalty. * Miracles also I cannot do..... * * @author M.Frank @@ -84,7 +84,7 @@ namespace DD4hep { public: template <typename TYPE> static void _destroy(void* p) { TYPE* q = (TYPE*)p; - if (q) delete q; + if (q) delete q; } template <typename TYPE> static void* _cast(const void* p) { TYPE* q = (TYPE*)p; @@ -171,7 +171,7 @@ namespace DD4hep { const result_t& operator()(const arg_t &p) const { return p.first; } }; /// Generator to create Operator to select key values of a map - template <typename T> Select1st<typename T::value_type> select1st(const T&) + template <typename T> Select1st<typename T::value_type> select1st(const T&) { return Select1st<typename T::value_type>(); } @@ -179,8 +179,8 @@ namespace DD4hep { template <typename M> class DestroyObjects { public: M& object; - DestroyObjects(M& m) - : object(m) { + DestroyObjects(M& m) + : object(m) { } ~DestroyObjects() { object.clear(); @@ -203,8 +203,8 @@ namespace DD4hep { template <typename M> class DestroyFirst { public: M& object; - DestroyFirst(M& m) - : object(m) { + DestroyFirst(M& m) + : object(m) { } ~DestroyFirst() { object.clear(); @@ -241,8 +241,8 @@ namespace DD4hep { template <typename M> class ReleaseObjects { public: M& object; - ReleaseObjects(M& m) - : object(m) { + ReleaseObjects(M& m) + : object(m) { } ~ReleaseObjects() { object.clear(); @@ -322,8 +322,8 @@ namespace DD4hep { T m = T(1)<<bit; return isSet(m); } - bool isNull() const { - return mask == 0; + bool isNull() const { + return mask == 0; } }; /// Standard constructor @@ -334,7 +334,7 @@ namespace DD4hep { */ namespace Geometry { - // Put here global basic type defintiions derived from primitive types of the Geometry namespace + // Put here global basic type defintiions derived from primitive types of the Geometry namespace }// End namespace Geometry } // End namespace DD4hep diff --git a/DDCore/include/DD4hep/Printout.h b/DDCore/include/DD4hep/Printout.h index 6ba805e3985d8930f1719836d8006a7d60ce2822..c9784bf3d649a7fc2fba245c406788aa3a98fa10 100644 --- a/DDCore/include/DD4hep/Printout.h +++ b/DDCore/include/DD4hep/Printout.h @@ -157,15 +157,15 @@ namespace DD4hep { /// Optional text prefix when formatting the output std::string prefix; /// Initializing constructor of the functor - Printer(const Geometry::LCDD* l, std::ostream& stream, const std::string& p = "") - : lcdd(l), os(stream), prefix(p) { - } + Printer(const Geometry::LCDD* l, std::ostream& stream, const std::string& p = "") + : lcdd(l), os(stream), prefix(p) { + } /// Callback operator to be specialized depending on the element type void operator()(const T& value) const; }; template <typename T> inline std::ostream& print(const T& object, std::ostream& os = std::cout, - const std::string& indent = "") { + const std::string& indent = "") { Printer<T>(0, os, indent)(object); return os; } @@ -191,9 +191,9 @@ namespace DD4hep { /// Reference to the container data of the map. cont_type& cont; /// Initializing constructor of the functor - PrintMap(const Geometry::LCDD* l, std::ostream& stream, cont_type& c, const std::string& t = "") - : lcdd(l), os(stream), text(t), cont(c) { - } + PrintMap(const Geometry::LCDD* l, std::ostream& stream, cont_type& c, const std::string& t = "") + : lcdd(l), os(stream), text(t), cont(c) { + } /// Callback operator to be specialized depending on the element type void operator()() const; }; diff --git a/DDCore/include/DD4hep/Readout.h b/DDCore/include/DD4hep/Readout.h index dc2f183fe27c1604289a8f9da135c37d82d35434..c1353e21adbdf43f1c4f2d3c1523cdb3e1729c80 100644 --- a/DDCore/include/DD4hep/Readout.h +++ b/DDCore/include/DD4hep/Readout.h @@ -41,30 +41,30 @@ namespace DD4hep { typedef ReadoutObject Object; public: /// Default constructor - Readout() - : Handle<Object>() { + Readout() + : Handle<Object>() { } /// Copy Constructor from object - Readout(const Readout& e) - : Handle<Object>(e) { + Readout(const Readout& e) + : Handle<Object>(e) { } #ifndef __CINT__ /// Copy Constructor from handle - Readout(const Handle<ReadoutObject>& e) - : Handle<Object>(e) { + Readout(const Handle<ReadoutObject>& e) + : Handle<Object>(e) { } #endif /// Constructor to be used when reading the already parsed object template <typename Q> Readout(const Handle<Q>& e) - : Handle<Object>(e) { + : Handle<Object>(e) { } /// Initializing constructor Readout(const std::string& name); /// Assignment operator Readout& operator=(const Readout& ro) { - if ( &ro == this ) return *this; - m_element = ro.m_element; - return *this; + if ( &ro == this ) return *this; + m_element = ro.m_element; + return *this; } /// Assign IDDescription to readout structure void setIDDescriptor(const Ref_t& spec) const; diff --git a/DDCore/include/DD4hep/Segmentations.h b/DDCore/include/DD4hep/Segmentations.h index 361cc5516d05c9c593fb21599e8376ff1498b6cb..b43cbe2863ebaf0eec5bd72946f31f4f2a385806 100644 --- a/DDCore/include/DD4hep/Segmentations.h +++ b/DDCore/include/DD4hep/Segmentations.h @@ -27,7 +27,7 @@ namespace DD4hep { namespace Geometry { /// Implementation class supporting generic Segmentation of sensitive detectors - /** + /** * \author M.Frank * \version 1.0 * \ingroup DD4HEP_GEOMETRY @@ -76,7 +76,7 @@ namespace DD4hep { /// Handle class supporting generic Segmentation of sensitive detectors - /** + /** * * \author M.Frank * \version 1.0 @@ -93,28 +93,28 @@ namespace DD4hep { /// Initializing constructor creating a new object of the given DDSegmentation type Segmentation(const std::string& type, const std::string& name); /// Default constructor - Segmentation() - : Handle<Implementation>() { + Segmentation() + : Handle<Implementation>() { } /// Copy Constructor from object - Segmentation(const Segmentation& e) - : Handle<Object>(e) { + Segmentation(const Segmentation& e) + : Handle<Object>(e) { } #ifndef __CINT__ /// Copy Constructor from handle - Segmentation(const Handle<SegmentationObject>& e) - : Handle<Object>(e) { + Segmentation(const Handle<SegmentationObject>& e) + : Handle<Object>(e) { } #endif /// Constructor to be used when reading the already parsed object template <typename Q> Segmentation(const Handle<Q>& e) - : Handle<Implementation>(e) { + : Handle<Implementation>(e) { } /// Assignment operator Segmentation& operator=(const Segmentation& seg) { - if ( &seg == this ) return *this; - m_element = seg.m_element; - return *this; + if ( &seg == this ) return *this; + m_element = seg.m_element; + return *this; } /// Access flag for hit positioning bool useForHitPosition() const; diff --git a/DDCore/include/DD4hep/Shapes.h b/DDCore/include/DD4hep/Shapes.h index 9192acf94d05bb54654d820dd9a31cb604b5d559..0fb475a240b4e6f0b5ff765676c0b3853225e411 100644 --- a/DDCore/include/DD4hep/Shapes.h +++ b/DDCore/include/DD4hep/Shapes.h @@ -45,7 +45,7 @@ namespace DD4hep { * Generic handle holding an object of base TGeoShape. * * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoShape.html + * \see http://root.cern.ch/root/html/TGeoShape.html * * \author M.Frank * \version 1.0 @@ -61,23 +61,23 @@ namespace DD4hep { public: /// Default constructor for uninitialized object - Solid_type() - : Handle<T>() { + Solid_type() + : Handle<T>() { } /// Direct assignment using the implementation pointer - Solid_type(T* p) - : Handle<T>(p) { + Solid_type(T* p) + : Handle<T>(p) { } /// Constructor to be used when passing an already created object - Solid_type(const Handle<T>& e) - : Handle<T>(e) { + Solid_type(const Handle<T>& e) + : Handle<T>(e) { } /// Constructor to be used when passing an already created object: need to check pointers template <typename Q> Solid_type(const Handle<Q>& e) - : Handle<T>(e) { + : Handle<T>(e) { } /// Access to shape name @@ -95,7 +95,7 @@ namespace DD4hep { /// Conversion to string for pretty print std::string toString(int precision=2) const { - return toStringSolid(this->m_element,precision); + return toStringSolid(this->m_element,precision); } }; typedef Solid_type<TGeoShape> Solid; @@ -103,7 +103,7 @@ namespace DD4hep { /// Class describing a box shape /** * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoBBox.html + * \see http://root.cern.ch/root/html/TGeoBBox.html * * * \author M.Frank @@ -118,12 +118,12 @@ namespace DD4hep { public: /// Constructor to be used with an existing object template <typename Q> Box(const Q* p) - : Solid_type<TGeoBBox>(p) { + : Solid_type<TGeoBBox>(p) { } /// Constructor to be used with an existing object template <typename Q> Box(const Handle<Q>& e) - : Solid_type<TGeoBBox>(e) { + : Solid_type<TGeoBBox>(e) { } /// Constructor to create an anonymous new box object (retrieves name from volume) @@ -133,7 +133,7 @@ namespace DD4hep { /// Constructor to create an anonymous new box object (retrieves name from volume) template <typename X, typename Y, typename Z> - Box(const X& x, const Y& y, const Z& z) { + Box(const X& x, const Y& y, const Z& z) { make("", _toDouble(x), _toDouble(y), _toDouble(z)); } @@ -161,7 +161,7 @@ namespace DD4hep { * * * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoPcon.html + * \see http://root.cern.ch/root/html/TGeoPcon.html * * * \author M.Frank @@ -172,12 +172,12 @@ namespace DD4hep { public: /// Constructor to be used with an existing object template <typename Q> Polycone(const Q* p) - : Solid_type<TGeoPcon>(p) { + : Solid_type<TGeoPcon>(p) { } /// Constructor to be used when reading the already parsed polycone object template <typename Q> Polycone(const Handle<Q>& e) - : Solid_type<TGeoPcon>(e) { + : Solid_type<TGeoPcon>(e) { } /// Constructor to create a new polycone object @@ -185,7 +185,7 @@ namespace DD4hep { /// Constructor to create a new polycone object. Add at the same time all Z planes Polycone(double start, double delta, const std::vector<double>& rmin, const std::vector<double>& rmax, - const std::vector<double>& z); + const std::vector<double>& z); /// Add Z-planes to the Polycone void addZPlanes(const std::vector<double>& rmin, const std::vector<double>& rmax, const std::vector<double>& z); @@ -197,7 +197,7 @@ namespace DD4hep { * half-length dz, inner and outer radii specified at -dz and +dz. * * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoConeSeg.html + * \see http://root.cern.ch/root/html/TGeoConeSeg.html * * \author M.Frank * \version 1.0 @@ -207,28 +207,28 @@ namespace DD4hep { public: /// Constructor to be used with an existing object template <typename Q> ConeSegment(const Q* p) - : Solid_type<TGeoConeSeg>(p) { + : Solid_type<TGeoConeSeg>(p) { } /// Constructor to be used when reading the already parsed ConeSegment object template <typename Q> ConeSegment(const Handle<Q>& e) - : Solid_type<TGeoConeSeg>(e) { + : Solid_type<TGeoConeSeg>(e) { } /// Constructor to create a new ConeSegment object ConeSegment(double dz, double rmin1, double rmax1, double rmin2, double rmax2, double phi1 = 0.0, - double phi2 = 2.0 * M_PI); + double phi2 = 2.0 * M_PI); /// Set the cone segment dimensions ConeSegment& setDimensions(double dz, double rmin1, double rmax1, double rmin2, double rmax2, double phi1 = 0.0, - double phi2 = 2.0 * M_PI); + double phi2 = 2.0 * M_PI); }; /// Intermediate class to overcome drawing probles with the TGeoTubeSeg class MyConeSeg: public TGeoConeSeg { public: - MyConeSeg() - : TGeoConeSeg() { + MyConeSeg() + : TGeoConeSeg() { } virtual ~MyConeSeg() { } @@ -246,7 +246,7 @@ namespace DD4hep { * inner radius, outer radius and half-length dz. * * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoConeSeg.html + * \see http://root.cern.ch/root/html/TGeoConeSeg.html * * \author M.Frank * \version 1.0 @@ -264,7 +264,7 @@ namespace DD4hep { /// Constructor to assign an object template <typename Q> Tube(const Handle<Q>& e) - : Solid_type<MyConeSeg>(e) { + : Solid_type<MyConeSeg>(e) { } /// Constructor to create a new anonymous tube object with attribute initialization @@ -294,7 +294,7 @@ namespace DD4hep { /// Constructor to create a new anonymous tube object with attribute initialization template <typename RMIN, typename RMAX, typename Z, typename DELTAPHI> - Tube(const RMIN& rmin, const RMAX& rmax, const Z& z, const DELTAPHI& deltaPhi) { + Tube(const RMIN& rmin, const RMAX& rmax, const Z& z, const DELTAPHI& deltaPhi) { make("", _toDouble(rmin), _toDouble(rmax), _toDouble(z), 0, _toDouble(deltaPhi)); } @@ -305,7 +305,7 @@ namespace DD4hep { /// Class describing a cone shape /** * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoCone.html + * \see http://root.cern.ch/root/html/TGeoCone.html * * \author M.Frank * \version 1.0 @@ -319,12 +319,12 @@ namespace DD4hep { public: /// Constructor to be used with an existing object template <typename Q> Cone(const Q* p) - : Solid_type<TGeoCone>(p) { + : Solid_type<TGeoCone>(p) { } /// Constructor to be used when passing an already created object template <typename Q> Cone(const Handle<Q>& e) - : Solid_type<TGeoCone>(e) { + : Solid_type<TGeoCone>(e) { } /// Constructor to create a new anonymous object with attribute initialization @@ -333,7 +333,7 @@ namespace DD4hep { } template <typename Z, typename RMIN1, typename RMAX1, typename RMIN2, typename RMAX2> - Cone(const Z& z, const RMIN1& rmin1, const RMAX1& rmax1, const RMIN2& rmin2, const RMAX2& rmax2) { + Cone(const Z& z, const RMIN1& rmin1, const RMAX1& rmax1, const RMIN2& rmin2, const RMAX2& rmax2) { make("", _toDouble(z), _toDouble(rmin1), _toDouble(rmax1), _toDouble(rmin2), _toDouble(rmax2)); } @@ -344,7 +344,7 @@ namespace DD4hep { /// Class describing a trap shape /** * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoTrap.html + * \see http://root.cern.ch/root/html/TGeoTrap.html * * \author M.Frank * \version 1.0 @@ -358,38 +358,38 @@ namespace DD4hep { public: /// Constructor to be used with an existing object template <typename Q> Trap(const Q* p) - : Solid_type<TGeoTrap>(p) { + : Solid_type<TGeoTrap>(p) { } /// Constructor to be used when passing an already created object - Trap(const Trap& e) - : Solid_type<TGeoTrap>(e) { + Trap(const Trap& e) + : Solid_type<TGeoTrap>(e) { } /// Constructor to be used when passing an already created object template <typename Q> Trap(const Handle<Q>& e) - : Solid_type<TGeoTrap>(e) { + : Solid_type<TGeoTrap>(e) { } /// Constructor to create a new anonymous object with attribute initialization Trap(double z, double theta, double phi, double y1, double x1, double x2, double alpha1, double y2, double x3, double x4, - double alpha2); + double alpha2); /// Constructor to create a new anonymous object for right angular wedge from STEP (Se G4 manual for details) Trap(double pz, double py, double px, double pLTX) { make(pz,py,px,pLTX); } - + /// Constructor to create a new anonymous object with attribute initialization template <typename PZ,typename PY,typename PX,typename PLTX> Trap(PZ pz, PY py, PX px, PLTX pLTX) - { make(_toDouble(pz),_toDouble(py),_toDouble(px),_toDouble(pLTX)); } - + { make(_toDouble(pz),_toDouble(py),_toDouble(px),_toDouble(pLTX)); } + /// Set the trap dimensions Trap& setDimensions(double z, double theta, double phi, double y1, double x1, double x2, double alpha1, double y2, - double x3, double x4, double alpha2); + double x3, double x4, double alpha2); }; /// Class describing a Trapezoid shape /** * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoTrd2.html + * \see http://root.cern.ch/root/html/TGeoTrd2.html * * * \author M.Frank @@ -404,17 +404,17 @@ namespace DD4hep { public: /// Constructor to be used with an existing object template <typename Q> Trapezoid(const Q* p) - : Solid_type<TGeoTrd2>(p) { + : Solid_type<TGeoTrd2>(p) { } /// Constructor to be used when passing an already created object - Trapezoid(const Trapezoid& e) - : Solid_type<TGeoTrd2>(e) { + Trapezoid(const Trapezoid& e) + : Solid_type<TGeoTrd2>(e) { } /// Constructor to be used when passing an already created object template <typename Q> Trapezoid(const Handle<Q>& e) - : Solid_type<TGeoTrd2>(e) { + : Solid_type<TGeoTrd2>(e) { } /// Constructor to create a new anonymous object with attribute initialization @@ -422,8 +422,8 @@ namespace DD4hep { /// Constructor to create a new anonymous object with attribute initialization template <typename X1,typename X2,typename Y1,typename Y2,typename Z> - Trapezoid(X1 x1, X2 x2, Y1 y1, Y2 y2, Z z) - { make(_toDouble(x1),_toDouble(x2),_toDouble(y1),_toDouble(y2),_toDouble(z)); } + Trapezoid(X1 x1, X2 x2, Y1 y1, Y2 y2, Z z) + { make(_toDouble(x1),_toDouble(x2),_toDouble(y1),_toDouble(y2),_toDouble(z)); } /// Set the Trapezoid dimensions Trapezoid& setDimensions(double x1, double x2, double y1, double y2, double z); @@ -432,7 +432,7 @@ namespace DD4hep { /// Class describing a Torus shape /** * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoTorus.html + * \see http://root.cern.ch/root/html/TGeoTorus.html * * \author M.Frank * \version 1.0 @@ -445,27 +445,27 @@ namespace DD4hep { public: /// Constructor to be used with an existing object template <typename Q> Torus(const Q* p) - : Solid_type<TGeoTorus>(p) { + : Solid_type<TGeoTorus>(p) { } /// Constructor to be used when passing an already created object - Torus(const Torus& e) - : Solid_type<TGeoTorus>(e) { + Torus(const Torus& e) + : Solid_type<TGeoTorus>(e) { } /// Constructor to be used when passing an already created object template <typename Q> Torus(const Handle<Q>& e) - : Solid_type<TGeoTorus>(e) { + : Solid_type<TGeoTorus>(e) { } /// Constructor to create a new anonymous object with attribute initialization template<typename R, typename RMIN, typename RMAX, typename PHI, typename DELTA_PHI> - Torus(R r, RMIN rmin, RMAX rmax, PHI phi=M_PI, DELTA_PHI delta_phi = 2.*M_PI) + Torus(R r, RMIN rmin, RMAX rmax, PHI phi=M_PI, DELTA_PHI delta_phi = 2.*M_PI) { make(_toDouble(r),_toDouble(rmin),_toDouble(rmax),_toDouble(phi),_toDouble(delta_phi)); } /// Constructor to create a new anonymous object with attribute initialization Torus(double r, double rmin, double rmax, double phi=M_PI, double delta_phi = 2.*M_PI) - { make(r,rmin,rmax,phi,delta_phi); } + { make(r,rmin,rmax,phi,delta_phi); } /// Set the Torus dimensions Torus& setDimensions(double r, double rmin, double rmax, double phi, double delta_phi); @@ -474,7 +474,7 @@ namespace DD4hep { /// Class describing a sphere shape /** * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoSphere.html + * \see http://root.cern.ch/root/html/TGeoSphere.html * * * \author M.Frank @@ -485,22 +485,22 @@ namespace DD4hep { public: /// Constructor to be used with an existing object template <typename Q> Sphere(const Q* p) - : Solid_type<TGeoSphere>(p) { + : Solid_type<TGeoSphere>(p) { } /// Constructor to be used when passing an already created object - Sphere(const Sphere& e) - : Solid_type<TGeoSphere>(e) { + Sphere(const Sphere& e) + : Solid_type<TGeoSphere>(e) { } /// Constructor to be used when passing an already created object template <typename Q> Sphere(const Handle<Q>& e) - : Solid_type<TGeoSphere>(e) { + : Solid_type<TGeoSphere>(e) { } /// Constructor to create a new anonymous object with attribute initialization Sphere(double rmin, double rmax, double theta = 0., double delta_theta = M_PI, double phi = 0.0, - double delta_phi = 2. * M_PI); + double delta_phi = 2. * M_PI); /// Set the Sphere dimensions Sphere& setDimensions(double rmin, double rmax, double theta, double delta_theta, double phi, double delta_phi); @@ -509,7 +509,7 @@ namespace DD4hep { /// Class describing a Paraboloid shape /** * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoParaboloid.html + * \see http://root.cern.ch/root/html/TGeoParaboloid.html * * * \author M.Frank @@ -520,17 +520,17 @@ namespace DD4hep { public: /// Constructor to be used with an existing object template <typename Q> Paraboloid(const Q* p) - : Solid_type<TGeoParaboloid>(p) { + : Solid_type<TGeoParaboloid>(p) { } /// Constructor to be used when passing an already created object - Paraboloid(const Paraboloid& e) - : Solid_type<TGeoParaboloid>(e) { + Paraboloid(const Paraboloid& e) + : Solid_type<TGeoParaboloid>(e) { } /// Constructor to be used when passing an already created object template <typename Q> Paraboloid(const Handle<Q>& e) - : Solid_type<TGeoParaboloid>(e) { + : Solid_type<TGeoParaboloid>(e) { } /// Constructor to create a new anonymous object with attribute initialization @@ -543,7 +543,7 @@ namespace DD4hep { /// Class describing a regular polyhedron shape /** * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoPgon.html + * \see http://root.cern.ch/root/html/TGeoPgon.html * * \author M.Frank * \version 1.0 @@ -553,22 +553,22 @@ namespace DD4hep { protected: /// Helper function to create the polyhedron void _create(const std::string& name, int nsides, double rmin, double rmax, double zpos, double zneg, double start, - double delta); + double delta); public: /// Constructor to be used with an existing object template <typename Q> PolyhedraRegular(const Q* p) - : Solid_type<TGeoPgon>(p) { + : Solid_type<TGeoPgon>(p) { } /// Constructor to be used when passing an already created object - PolyhedraRegular(const PolyhedraRegular& e) - : Solid_type<TGeoPgon>(e) { + PolyhedraRegular(const PolyhedraRegular& e) + : Solid_type<TGeoPgon>(e) { } /// Constructor to be used when passing an already created object template <typename Q> - PolyhedraRegular(const Handle<Q>& e) - : Solid_type<TGeoPgon>(e) { + PolyhedraRegular(const Handle<Q>& e) + : Solid_type<TGeoPgon>(e) { } /// Constructor to create a new object. Phi(start)=0, deltaPhi=2PI, Z-planes at -zlen/2 and +zlen/2 @@ -582,31 +582,31 @@ namespace DD4hep { /// Class describing an arbitray solid defined by 8 vertices. /** * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoArb8.html + * \see http://root.cern.ch/root/html/TGeoArb8.html * * \author M.Frank * \version 1.0 * \ingroup DD4HEP_GEOMETRY */ class EightPointSolid: public Solid_type<TGeoArb8> { - private: + private: /// Internal helper method to support object construction void make(double dz, const double* vtx); public: /// Constructor to be used with an existing object template <typename Q> EightPointSolid(const Q* p) - : Solid_type<TGeoArb8>(p) { + : Solid_type<TGeoArb8>(p) { } /// Constructor to be used when passing an already created object - EightPointSolid(const EightPointSolid& e) - : Solid_type<TGeoArb8>(e) { + EightPointSolid(const EightPointSolid& e) + : Solid_type<TGeoArb8>(e) { } /// Constructor to be used when passing an already created object template <typename Q> EightPointSolid(const Handle<Q>& e) - : Solid_type<TGeoArb8>(e) { + : Solid_type<TGeoArb8>(e) { } /// Constructor to create a new anonymous object with attribute initialization @@ -616,7 +616,7 @@ namespace DD4hep { /// Base class describing boolean (=union,intersection,subtraction) solids /** * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoCompositeShape.html + * \see http://root.cern.ch/root/html/TGeoCompositeShape.html * * \author M.Frank * \version 1.0 @@ -625,23 +625,23 @@ namespace DD4hep { class BooleanSolid: public Solid_type<TGeoCompositeShape> { protected: /// Constructor to be used when passing an already created object - BooleanSolid() - : Solid_type<TGeoCompositeShape>() { + BooleanSolid() + : Solid_type<TGeoCompositeShape>() { } public: /// Constructor to be used when passing an already created object template <typename Q> - BooleanSolid(const Handle<Q>& e) - : Solid_type<TGeoCompositeShape>(e) { + BooleanSolid(const Handle<Q>& e) + : Solid_type<TGeoCompositeShape>(e) { } }; /// Class describing boolean subtraction solid /** * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoCompositeShape.html - * \see http://root.cern.ch/root/html/TGeoSubtraction.html + * \see http://root.cern.ch/root/html/TGeoCompositeShape.html + * \see http://root.cern.ch/root/html/TGeoSubtraction.html * * \author M.Frank * \version 1.0 @@ -650,16 +650,16 @@ namespace DD4hep { class SubtractionSolid: public BooleanSolid { public: /// Default constructor - SubtractionSolid() - : BooleanSolid() { + SubtractionSolid() + : BooleanSolid() { } /// Constructor to be used when passing an already created object - SubtractionSolid(const SubtractionSolid& e) - : BooleanSolid(e) { + SubtractionSolid(const SubtractionSolid& e) + : BooleanSolid(e) { } /// Constructor to be used when passing an already created object template <typename Q> SubtractionSolid(const Handle<Q>& e) - : BooleanSolid(e) { + : BooleanSolid(e) { } /// Constructor to create a new object. Position is identity, Rotation is identity-rotation! SubtractionSolid(const Solid& shape1, const Solid& shape2); @@ -676,8 +676,8 @@ namespace DD4hep { /// Class describing boolean union solid /** * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoCompositeShape.html - * \see http://root.cern.ch/root/html/TGeoUnion.html + * \see http://root.cern.ch/root/html/TGeoCompositeShape.html + * \see http://root.cern.ch/root/html/TGeoUnion.html * * \author M.Frank * \version 1.0 @@ -686,16 +686,16 @@ namespace DD4hep { class UnionSolid: public BooleanSolid { public: /// Default constructor - UnionSolid() - : BooleanSolid() { + UnionSolid() + : BooleanSolid() { } /// Constructor to be used when passing an already created object - UnionSolid(const UnionSolid& e) - : BooleanSolid(e) { + UnionSolid(const UnionSolid& e) + : BooleanSolid(e) { } /// Constructor to be used when passing an already created object template <typename Q> UnionSolid(const Handle<Q>& e) - : BooleanSolid(e) { + : BooleanSolid(e) { } /// Constructor to create a new object. Position is identity, Rotation is identity-rotation! UnionSolid(const Solid& shape1, const Solid& shape2); @@ -712,8 +712,8 @@ namespace DD4hep { /// Class describing boolean intersection solid /** * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoCompositeShape.html - * \see http://root.cern.ch/root/html/TGeoIntersection.html + * \see http://root.cern.ch/root/html/TGeoCompositeShape.html + * \see http://root.cern.ch/root/html/TGeoIntersection.html * * \author M.Frank * \version 1.0 @@ -722,16 +722,16 @@ namespace DD4hep { class IntersectionSolid: public BooleanSolid { public: /// Default constructor - IntersectionSolid() - : BooleanSolid() { + IntersectionSolid() + : BooleanSolid() { } /// Constructor to be used when passing an already created object - IntersectionSolid(const IntersectionSolid& e) - : BooleanSolid(e) { + IntersectionSolid(const IntersectionSolid& e) + : BooleanSolid(e) { } /// Constructor to be used when passing an already created object template <typename Q> IntersectionSolid(const Handle<Q>& e) - : BooleanSolid(e) { + : BooleanSolid(e) { } /// Constructor to create a new object. Position is identity, Rotation is identity-rotation! IntersectionSolid(const Solid& shape1, const Solid& shape2); diff --git a/DDCore/include/DD4hep/SurfaceInstaller.h b/DDCore/include/DD4hep/SurfaceInstaller.h index 8ef49c7492caa660423130ad282a1e3e0be9b687..734b50c6698e126bf692496bb7647f3603c0b156 100644 --- a/DDCore/include/DD4hep/SurfaceInstaller.h +++ b/DDCore/include/DD4hep/SurfaceInstaller.h @@ -19,7 +19,7 @@ #include <algorithm> /// Namespace for the tracking surfaces of the AIDA detector description toolkit -namespace DDSurfaces { +namespace DDSurfaces { /// Class describing the surface types class SurfaceType; } @@ -28,7 +28,7 @@ namespace DDSurfaces { namespace DD4hep { /// Namespace for the reconstruction part of the AIDA detector description toolkit - namespace DDRec { + namespace DDRec { /// Class describing surface data class SurfaceData; } @@ -89,19 +89,19 @@ namespace DD4hep { /// Action routine to execute the test template <typename T> inline long SurfaceInstaller::run(Geometry::LCDD& lcdd,int argc,char** argv) - { - for(; argc>0; --argc) { - std::string name = argv[argc-1]; - T installer(lcdd,name); - installer.scan(); + { + for(; argc>0; --argc) { + std::string name = argv[argc-1]; + T installer(lcdd,name); + installer.scan(); + } + return 1; } - return 1; - } -#define DECLARE_SURFACE_INSTALLER(name,class) \ - namespace DD4hep { \ +#define DECLARE_SURFACE_INSTALLER(name,class) \ + namespace DD4hep { \ template long SurfaceInstaller::run< class >(Geometry::LCDD& lcdd,int argc,char** argv); \ - } \ + } \ DECLARE_APPLY(name,SurfaceInstaller::run< class >) } // End namespace DD4hep @@ -112,7 +112,7 @@ namespace DD4hep { #include "DDRec/Surface.h" #include "DDRec/DetectorData.h" -/** If you want to save yourself some typing when creating surface installers, +/** If you want to save yourself some typing when creating surface installers, * set the compile macro DD4HEP_USE_SURFACEINSTALL_HELPER LOCALLY ! * This will then enable the code below and the only thing you will have to * type is the installer member function to create a measurement surface for @@ -141,7 +141,7 @@ namespace { UserData data; public: /// Initializing constructor - Installer(LCDD& lcdd, const std::string& nam) : DD4hep::SurfaceInstaller(lcdd, nam) {} + Installer(LCDD& lcdd, const std::string& nam) : DD4hep::SurfaceInstaller(lcdd, nam) {} /// Default destructor virtual ~Installer() {} /// Install volume information. Default implementation only prints! @@ -153,12 +153,12 @@ namespace { template <typename T> bool checkShape(const T& shape) const { if ( shape.isValid() ) return true; invalidInstaller("Shape is not of the required type:"+DD4hep::typeName(typeid(T))); - return false; + return false; } }; /// Handle surface installation using cached surfaces. - template <typename UserData> + template <typename UserData> bool Installer<UserData>::handleUsingCache(DetElement comp, Volume vol) const { Surfaces::const_iterator is = m_surfaces.find(vol.ptr()); if ( is != m_surfaces.end() ) { @@ -170,7 +170,7 @@ namespace { } /// Add a new surface to the surface manager and the local cache - template <typename UserData> + template <typename UserData> void Installer<UserData>::addSurface(DetElement component, const DD4hep::DDRec::VolSurface& surf) { m_surfaces.insert(std::make_pair(surf.volume().ptr(),surf.ptr())); DD4hep::DDRec::volSurfaceList(component)->push_back(surf); diff --git a/DDCore/include/DD4hep/TGeoUnits.h b/DDCore/include/DD4hep/TGeoUnits.h index 9ea037f390b4588d89258f669978d6077bbaedb1..9719be82cbb0de76cb20d937acdcb419d1b85a6b 100644 --- a/DDCore/include/DD4hep/TGeoUnits.h +++ b/DDCore/include/DD4hep/TGeoUnits.h @@ -1,5 +1,5 @@ // OSOLETE -// use DD4hepUnits and dd4hep:: instead +// use DD4hepUnits and dd4hep:: instead #ifndef DD4HEP_TGEOUNITS_H #define DD4HEP_TGEOUNITS_H diff --git a/DDCore/include/DD4hep/ToStream.h b/DDCore/include/DD4hep/ToStream.h index a584152f58645c8f9d7d685b508085ce9c0827d7..3537cfded0b047c487cbead2da46a3677dd8d298 100644 --- a/DDCore/include/DD4hep/ToStream.h +++ b/DDCore/include/DD4hep/ToStream.h @@ -45,7 +45,7 @@ namespace DD4hep { * @date 2006-05-12 */ template <class TYPE> - std::ostream& toStream(const TYPE& obj, std::ostream& s); + std::ostream& toStream(const TYPE& obj, std::ostream& s); // ======================================================================== /// the helper function to print the sequence /** @param first (INPUT) begin-iterator for the sequence @@ -59,12 +59,12 @@ namespace DD4hep { * @date 2009-09-15 */ template <class ITERATOR> - inline std::ostream& toStream(ITERATOR first, // begin of the sequence - ITERATOR last, // end of the sequence - std::ostream& s, // the stream - const std::string& open, // opening - const std::string& close, // closing - const std::string& delim); // delimiter + inline std::ostream& toStream(ITERATOR first, // begin of the sequence + ITERATOR last, // end of the sequence + std::ostream& s, // the stream + const std::string& open, // opening + const std::string& close, // closing + const std::string& delim); // delimiter // ======================================================================== /// the printtout of the strings. /** the string is printed a'la Python using the quotes @@ -121,7 +121,7 @@ namespace DD4hep { * @date 2006-05-12 */ template <class KTYPE, class VTYPE> - inline std::ostream& toStream(const std::pair<KTYPE, VTYPE>& obj, std::ostream& s) { + inline std::ostream& toStream(const std::pair<KTYPE, VTYPE>& obj, std::ostream& s) { s << "( "; toStream(obj.first, s); s << " , "; @@ -136,7 +136,7 @@ namespace DD4hep { * @date 2006-05-12 */ template <class TYPE, class ALLOCATOR> - inline std::ostream& toStream(const std::vector<TYPE, ALLOCATOR>& obj, std::ostream& s) { + inline std::ostream& toStream(const std::vector<TYPE, ALLOCATOR>& obj, std::ostream& s) { return toStream(obj.begin(), obj.end(), s, "[ ", " ]", " , "); } // ======================================================================== @@ -147,7 +147,7 @@ namespace DD4hep { * @date 2007-04-08 */ template <class TYPE, class ALLOCATOR> - inline std::ostream& toStream(const std::list<TYPE, ALLOCATOR>& obj, std::ostream& s) { + inline std::ostream& toStream(const std::list<TYPE, ALLOCATOR>& obj, std::ostream& s) { return toStream(obj.begin(), obj.end(), s, "[ ", " ]", " , "); } // ======================================================================== @@ -158,7 +158,7 @@ namespace DD4hep { * @date 2006-05-12 */ template <class TYPE, class CMP, class ALLOCATOR> - inline std::ostream& toStream(const std::set<TYPE, CMP, ALLOCATOR>& obj, std::ostream& s) { + inline std::ostream& toStream(const std::set<TYPE, CMP, ALLOCATOR>& obj, std::ostream& s) { return toStream(obj.begin(), obj.end(), s, "[ ", " ]", " , "); } // ======================================================================== @@ -170,7 +170,7 @@ namespace DD4hep { * @date 2006-05-12 */ template <class KTYPE, class VTYPE, class CMP, class ALLOCATOR> - inline std::ostream& toStream(const std::map<KTYPE, VTYPE, CMP, ALLOCATOR>& obj, std::ostream& s) { + inline std::ostream& toStream(const std::map<KTYPE, VTYPE, CMP, ALLOCATOR>& obj, std::ostream& s) { s << "{ "; for (typename std::map<KTYPE, VTYPE, CMP, ALLOCATOR>::const_iterator cur = obj.begin(); obj.end() != cur; ++cur) { if (obj.begin() != cur) { @@ -189,7 +189,7 @@ namespace DD4hep { * @date 2009-10-05 */ template <class TYPE, unsigned int N> - std::ostream& toStream(TYPE (&obj)[N], std::ostream& s) { + std::ostream& toStream(TYPE (&obj)[N], std::ostream& s) { return toStream(obj, obj + N, s, "( ", " )", " , "); } // ======================================================================== @@ -198,7 +198,7 @@ namespace DD4hep { * @date 2009-10-05 */ template <class TYPE, unsigned int N> - std::ostream& toStream(const TYPE (&obj)[N], std::ostream& s) { + std::ostream& toStream(const TYPE (&obj)[N], std::ostream& s) { return toStream(obj, obj + N, s, "( ", " )", " , "); } // ======================================================================== @@ -207,7 +207,7 @@ namespace DD4hep { * @date 2009-10-05 */ template <unsigned int N> - std::ostream& toStream(char (&obj)[N], std::ostream& s) { + std::ostream& toStream(char (&obj)[N], std::ostream& s) { return toStream(std::string(obj, obj + N), s); } // ======================================================================== @@ -216,7 +216,7 @@ namespace DD4hep { * @date 2009-10-05 */ template <unsigned int N> - std::ostream& toStream(const char (&obj)[N], std::ostream& s) { + std::ostream& toStream(const char (&obj)[N], std::ostream& s) { return toStream(std::string(obj, obj + N), s); } // ======================================================================== @@ -234,7 +234,7 @@ namespace DD4hep { * @date 2006-05-12 */ template <class TYPE> - inline std::ostream& toStream(const TYPE& obj, std::ostream& s) { + inline std::ostream& toStream(const TYPE& obj, std::ostream& s) { return s << obj; } // ======================================================================== @@ -250,24 +250,24 @@ namespace DD4hep { * @date 2009-09-15 */ template <class ITERATOR> - inline std::ostream& toStream(ITERATOR first, // begin of the sequence - ITERATOR last, // end of the sequence - std::ostream& s, // the stream - const std::string& open, // opening - const std::string& close, // closing - const std::string& delim) // delimiter - { - s << open; - for (ITERATOR curr = first; curr != last; ++curr) { - if (first != curr) { - s << delim; + inline std::ostream& toStream(ITERATOR first, // begin of the sequence + ITERATOR last, // end of the sequence + std::ostream& s, // the stream + const std::string& open, // opening + const std::string& close, // closing + const std::string& delim) // delimiter + { + s << open; + for (ITERATOR curr = first; curr != last; ++curr) { + if (first != curr) { + s << delim; + } + toStream(*curr, s); } - toStream(*curr, s); + s << close; + // + return s; } - s << close; - // - return s; - } // ======================================================================== /** the generic implementation of the type conversion to the string * @author Alexander MAZUROV Alexander.Mazurov@gmail.com @@ -277,7 +277,7 @@ namespace DD4hep { * @todo need to be compared with boost::lexical_cast */ template <class TYPE> - inline std::string toString(const TYPE& obj) { + inline std::string toString(const TYPE& obj) { std::ostringstream s; std::ios::fmtflags orig_flags = s.flags(); s.setf(std::ios::showpoint); // to display correctly floats @@ -286,16 +286,16 @@ namespace DD4hep { return s.str(); } // ============================================================================ - /// print XYZ point + /// print XYZ point std::ostream& toStream(const ROOT::Math::XYZPoint& obj, std::ostream& s); // print XYZ-vector std::ostream& toStream(const ROOT::Math::XYZVector& obj, std::ostream& s); - /// print Lorentz vector + /// print Lorentz vector std::ostream& toStream(const ROOT::Math::PxPyPzEVector& obj, std::ostream& s); - // ======================================================================== + // ======================================================================== }// end of namespace DD4hep::Utils -// ========================================================================== + // ========================================================================== }// end of namespace DD4hep // ============================================================================ // The END diff --git a/DDCore/include/DD4hep/VolumeManager.h b/DDCore/include/DD4hep/VolumeManager.h index f5c64374555aba1568d001042111093536e30cfc..1e29667c4592a7678ce77abba5daf263ed8bb429 100644 --- a/DDCore/include/DD4hep/VolumeManager.h +++ b/DDCore/include/DD4hep/VolumeManager.h @@ -68,8 +68,8 @@ namespace DD4hep { typedef VolumeID VolIdentifier; // Creation flags enum PopulateFlags { - NONE = 0, - TREE = 1 << 1, // Build 1 level DetElement hierarchy while populating + NONE = 0, + TREE = 1 << 1, // Build 1 level DetElement hierarchy while populating ONE = 1 << 2, // Populate all daughter volumes into one big lookup-container // This flag may be in parallel with 'TREE' LAST @@ -92,37 +92,37 @@ namespace DD4hep { public: /// Default constructor - VolumeManager() - : Handle<VolumeManagerObject>() { + VolumeManager() + : Handle<VolumeManagerObject>() { } /// Constructor to be used when reading the already parsed object - VolumeManager(const VolumeManager& e) - : Handle<VolumeManagerObject>(e) { + VolumeManager(const VolumeManager& e) + : Handle<VolumeManagerObject>(e) { } #ifndef __CINT__ /// Constructor to be used when reading the already parsed object - VolumeManager(const Handle<VolumeManagerObject>& e) - : Handle<VolumeManagerObject>(e) { + VolumeManager(const Handle<VolumeManagerObject>& e) + : Handle<VolumeManagerObject>(e) { } #endif /// Constructor to be used when reading the already parsed object template <typename Q> VolumeManager(const Handle<Q>& e) - : Handle<VolumeManagerObject>(e) { + : Handle<VolumeManagerObject>(e) { } /** Initializing constructor. The tree will automatically be built if the detelement is valid * Please see enum PopulateFlags for further info. * No action whatsoever is performed here, if the detector element is not valid. */ VolumeManager(LCDD& lcdd, const std::string& name, DetElement world = DetElement(), Readout ro = Readout(), int flags = - NONE); + NONE); /// Initializing constructor for subdetector volume managers. VolumeManager(DetElement subdetector, Readout ro); /// Assignment operator VolumeManager& operator=(const VolumeManager& m) { - if ( this != &m ) m_element = m.m_element; - return *this; - } + if ( this != &m ) m_element = m.m_element; + return *this; + } /// Add a new Volume manager section according to a new subdetector VolumeManager addSubdetector(DetElement detector, Readout ro); /// Access the volume manager by cell id diff --git a/DDCore/include/DD4hep/Volumes.h b/DDCore/include/DD4hep/Volumes.h index 3cfe751f18742e2141220590df8657bcf4a68ec9..68cd2c13a428848ac8ab9f67b04707ace28ce306 100644 --- a/DDCore/include/DD4hep/Volumes.h +++ b/DDCore/include/DD4hep/Volumes.h @@ -29,7 +29,7 @@ // Older ROOT version #define DD4HEP_EMULATE_TGEOEXTENSIONS class TGeoExtension : public TObject { - public: + public: virtual ~TGeoExtension() {} /// TGeoExtension overload: Method called whenever requiring a pointer to the extension virtual TGeoExtension *Grab() = 0; @@ -56,9 +56,9 @@ namespace DD4hep { class SensitiveDetector; /// Implementation class extending the ROOT placed volume - /** + /** * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoExtension.html + * \see http://root.cern.ch/root/html/TGeoExtension.html * * \author M.Frank * \version 1.0 @@ -76,7 +76,7 @@ namespace DD4hep { class VolIDs: public std::vector<VolID> { public: typedef std::vector<VolID> Base; - VolIDs() : std::vector<VolID>() { + VolIDs() : std::vector<VolID>() { } ~VolIDs() { } @@ -97,9 +97,9 @@ namespace DD4hep { virtual ~PlacedVolumeExtension(); /// Assignment operator PlacedVolumeExtension& operator=(const PlacedVolumeExtension& c) { - magic = c.magic; - volIDs = c.volIDs; - return *this; + magic = c.magic; + volIDs = c.volIDs; + return *this; } /// TGeoExtension overload: Method called whenever requiring a pointer to the extension virtual TGeoExtension *Grab(); @@ -110,9 +110,9 @@ namespace DD4hep { }; /// Handle class holding a placed volume (also called physical volume) - /** + /** * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoNode.html + * \see http://root.cern.ch/root/html/TGeoNode.html * * \author M.Frank * \version 1.0 @@ -125,20 +125,20 @@ namespace DD4hep { typedef Object::VolID VolID; /// Constructor to be used when reading the already parsed DOM tree - PlacedVolume(const TGeoNode* e) - : Handle<TGeoNode>(e) { + PlacedVolume(const TGeoNode* e) + : Handle<TGeoNode>(e) { } /// Default constructor - PlacedVolume() - : Handle<TGeoNode>() { + PlacedVolume() + : Handle<TGeoNode>() { } /// Copy assignment - PlacedVolume(const PlacedVolume& e) - : Handle<TGeoNode>(e) { + PlacedVolume(const PlacedVolume& e) + : Handle<TGeoNode>(e) { } /// Copy assignment from other handle type template <typename T> PlacedVolume(const Handle<T>& e) - : Handle<TGeoNode>(e) { + : Handle<TGeoNode>(e) { } /// Assignment operator (must match copy constructor) PlacedVolume& operator=(const PlacedVolume& v) { @@ -166,7 +166,7 @@ namespace DD4hep { * Internal data structure optional to TGeo data. * * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoExtension.html + * \see http://root.cern.ch/root/html/TGeoExtension.html * * \author M.Frank * \version 1.0 @@ -189,12 +189,12 @@ namespace DD4hep { virtual ~VolumeExtension(); /// Copy the object void copy(const VolumeExtension& c) { - magic = c.magic; - region = c.region; - limits = c.limits; - vis = c.vis; - sens_det = c.sens_det; - referenced = c.referenced; + magic = c.magic; + region = c.region; + limits = c.limits; + vis = c.vis; + sens_det = c.sens_det; + referenced = c.referenced; } /// TGeoExtension overload: Method called whenever requiring a pointer to the extension virtual TGeoExtension *Grab(); @@ -209,7 +209,7 @@ namespace DD4hep { * Handle describing a Volume * * For any further documentation please see the following ROOT documentation: - * \see http://root.cern.ch/root/html/TGeoVolume.html + * \see http://root.cern.ch/root/html/TGeoVolume.html * * \author M.Frank * \version 1.0 @@ -223,23 +223,23 @@ namespace DD4hep { public: /// Default constructor - Volume() - : Base(0) { + Volume() + : Base(0) { } /// Copy from handle - Volume(const TGeoVolume* v) - : Base(v) { + Volume(const TGeoVolume* v) + : Base(v) { } /// Copy from handle - Volume(const Volume& v) - : Base(v) { + Volume(const Volume& v) + : Base(v) { } /// Copy from arbitrary Element template <typename T> Volume(const Handle<T>& v) - : Base(v) { + : Base(v) { } /// Constructor to be used when creating a new geometry tree. @@ -269,7 +269,7 @@ namespace DD4hep { /// Attach attributes to the volume const Volume& setAttributes(const LCDD& lcdd, const std::string& region, const std::string& limits, - const std::string& vis) const; + const std::string& vis) const; /// Set the regional attributes to the volume. Note: If the name string is empty, the action is ignored. const Volume& setRegion(const LCDD& lcdd, const std::string& name) const; @@ -316,8 +316,8 @@ namespace DD4hep { }; /// Implementation class extending the ROOT assembly volumes (TGeoVolumeAsembly) - /** - * Handle describing a volume assembly. + /** + * Handle describing a volume assembly. * * For any further documentation please see the following ROOT documentation: * \see http://root.cern.ch/root/html/TGeoVolumeAssembly.html @@ -329,18 +329,18 @@ namespace DD4hep { class Assembly: public Volume { public: /// Default constructor - Assembly() - : Volume() { + Assembly() + : Volume() { } /// Copy from handle - Assembly(const Assembly& v) - : Volume(v) { + Assembly(const Assembly& v) + : Volume(v) { } /// Copy from arbitrary Element template <typename T> Assembly(const Handle<T>& v) - : Volume(v) { + : Volume(v) { } /// Constructor to be used when creating a new geometry tree. diff --git a/DDCore/include/DD4hep/config.h b/DDCore/include/DD4hep/config.h index 8fbc91e3d6018669094d5d79aaf55567f47043b3..6ea04ce4ed922d36377bae9370290048d71ad9f3 100644 --- a/DDCore/include/DD4hep/config.h +++ b/DDCore/include/DD4hep/config.h @@ -15,8 +15,8 @@ #define INCREMENT_COUNTER InstanceCount::increment(this) #define DECREMENT_COUNTER InstanceCount::decrement(this) #else -#define INCREMENT_COUNTER -#define DECREMENT_COUNTER +#define INCREMENT_COUNTER +#define DECREMENT_COUNTER #endif /// Namespace for the AIDA detector description toolkit diff --git a/DDCore/include/DD4hep/objects/ConditionsInterna.h b/DDCore/include/DD4hep/objects/ConditionsInterna.h index 32b6eb9d5bfaa87b3fb3f90bdc0ff7d189f9fb12..19c742f982e79faf546eaf5acd98238c65d1cdd6 100644 --- a/DDCore/include/DD4hep/objects/ConditionsInterna.h +++ b/DDCore/include/DD4hep/objects/ConditionsInterna.h @@ -40,31 +40,31 @@ namespace DD4hep { /// Class describing the interval of validty /** - * + * * \author M.Frank * \version 1.0 * \ingroup DD4HEP_GEOMETRY */ class IOV { - friend class Condition; + friend class Condition; public: - enum { - UNKNOWN_IOV = 1<<0 - } _IOVTypes; - /// IOV buffer type: Must be a bitmap! - int type; - int data[4]; - int _spare; - /// Initializing constructor - IOV(int t=UNKNOWN_IOV); - /// Standard Destructor - ~IOV(); - /// Move the data content: 'from' will be reset to NULL - void move(IOV& from); - /// Create IOV data from string representation - void fromString(const std::string& rep); - /// Create string representation of the IOV - std::string str(); + enum { + UNKNOWN_IOV = 1<<0 + } _IOVTypes; + /// IOV buffer type: Must be a bitmap! + int type; + int data[4]; + int _spare; + /// Initializing constructor + IOV(int t=UNKNOWN_IOV); + /// Standard Destructor + ~IOV(); + /// Move the data content: 'from' will be reset to NULL + void move(IOV& from); + /// Create IOV data from string representation + void fromString(const std::string& rep); + /// Create string representation of the IOV + std::string str(); }; /// Class describing an opaque conditions data block @@ -75,38 +75,38 @@ namespace DD4hep { * \ingroup DD4HEP_GEOMETRY */ class BlockData : public Block { - friend class Condition; - friend class Object; + friend class Condition; + friend class Object; private: - enum { - PLAIN_DATA = 1<<0, - ALLOC_DATA = 1<<1, - BOUND_DATA = 1<<2 - } _DataTypes; - /// Data buffer: plain data are allocated directly on this buffer - unsigned int data[16]; - /// Destructor function -- only set if the object is valid - void (*destruct)(void*); - /// Constructor function -- only set if the object is valid - void (*copy)(void*,const void*); + enum { + PLAIN_DATA = 1<<0, + ALLOC_DATA = 1<<1, + BOUND_DATA = 1<<2 + } _DataTypes; + /// Data buffer: plain data are allocated directly on this buffer + unsigned int data[16]; + /// Destructor function -- only set if the object is valid + void (*destruct)(void*); + /// Constructor function -- only set if the object is valid + void (*copy)(void*,const void*); public: - /// Data buffer type: Must be a bitmap! - int type; - - /// Standard initializing constructor - BlockData(); - /// Standard Destructor - ~BlockData(); - /// Move the data content: 'from' will be reset to NULL - void move(BlockData& from); - /// Set data value - void bind(const BasicGrammar* grammar, - void (*ctor)(void*,const void*), - void (*dtor)(void*)); - /// Set data value - void assign(const void* ptr,const std::type_info& typ); + /// Data buffer type: Must be a bitmap! + int type; + + /// Standard initializing constructor + BlockData(); + /// Standard Destructor + ~BlockData(); + /// Move the data content: 'from' will be reset to NULL + void move(BlockData& from); + /// Set data value + void bind(const BasicGrammar* grammar, + void (*ctor)(void*,const void*), + void (*dtor)(void*)); + /// Set data value + void assign(const void* ptr,const std::type_info& typ); }; /// The intermediate conditions data @@ -118,24 +118,24 @@ namespace DD4hep { */ class Entry : public NamedObject { public: - /// Reference to the detector element - DetElement detector; - /// Conditions type (was the tag in the XML) - std::string type; - /// The actual conditions data - std::string value; - /// The validity string to be interpreted by the updating engine - std::string validity; - /// Default constructor - Entry() {} - /// Initializing constructor - Entry(const DetElement& det, const std::string& nam, const std::string& typ, const std::string& valid); - /// Copy constructor - Entry(const Entry& c); - /// Default destructor - virtual ~Entry(); - /// Assignment operator - Entry& operator=(const Entry& c); + /// Reference to the detector element + DetElement detector; + /// Conditions type (was the tag in the XML) + std::string type; + /// The actual conditions data + std::string value; + /// The validity string to be interpreted by the updating engine + std::string validity; + /// Default constructor + Entry() {} + /// Initializing constructor + Entry(const DetElement& det, const std::string& nam, const std::string& typ, const std::string& valid); + /// Copy constructor + Entry(const Entry& c); + /// Default destructor + virtual ~Entry(); + /// Assignment operator + Entry& operator=(const Entry& c); }; /// The data class behind a conditions handle. @@ -147,26 +147,26 @@ namespace DD4hep { */ class ConditionObject : public NamedObject { public: - /// Condition value (in string form) - std::string value; - /// Condition validity (in string form) - std::string validity; - /// Condition address - std::string address; - /// Comment string - std::string comment; - /// The detector element - DetElement detector; - /// Data block - BlockData data; - /// Interval of validity - IOV iov; - /// Standard constructor - ConditionObject(); - /// Standard Destructor - virtual ~ConditionObject(); - /// Move data content: 'from' will be reset to NULL - ConditionObject& move(ConditionObject& from); + /// Condition value (in string form) + std::string value; + /// Condition validity (in string form) + std::string validity; + /// Condition address + std::string address; + /// Comment string + std::string comment; + /// The detector element + DetElement detector; + /// Data block + BlockData data; + /// Interval of validity + IOV iov; + /// Standard constructor + ConditionObject(); + /// Standard Destructor + virtual ~ConditionObject(); + /// Move data content: 'from' will be reset to NULL + ConditionObject& move(ConditionObject& from); }; /// The data class behind a conditions container handle. @@ -179,16 +179,16 @@ namespace DD4hep { class ConditionContainer : public NamedObject { public: #ifndef __CINT__ - /// Container definition - typedef std::map<std::string, DD4hep::Geometry::Condition> Entries; + /// Container definition + typedef std::map<std::string, DD4hep::Geometry::Condition> Entries; #endif - std::map<std::string,DD4hep::Geometry::Condition> entries; + std::map<std::string,DD4hep::Geometry::Condition> entries; /// Standard constructor ConditionContainer(); /// Default destructor virtual ~ConditionContainer(); - /// Clear all conditions. Auto-delete of all existing entries - void removeElements(); + /// Clear all conditions. Auto-delete of all existing entries + void removeElements(); }; } /* End namespace ConditionsInterna */ @@ -210,7 +210,7 @@ namespace DD4hep { if (!grammar || (grammar->type() != typeid(T))) { throw std::bad_cast(); } return *(T*)pointer; } - /// Bind the data of the conditions object to a given format. + /// Bind the data of the conditions object to a given format. template <typename T> Condition& Condition::bind() { Object* o = access(); ConditionsInterna::BlockData& b = o->data; @@ -230,21 +230,21 @@ namespace DD4hep { } /* End namespace Geometry */ } /* End namespace DD4hep */ -#define DD4HEP_DEFINE_CONDITIONS_TYPE(x) \ - namespace DD4hep { namespace Geometry { \ - template Condition& Condition::bind<x>(); \ - template x& Condition::get<x>(); \ - template const x& Condition::get<x>() const; \ +#define DD4HEP_DEFINE_CONDITIONS_TYPE(x) \ + namespace DD4hep { namespace Geometry { \ + template Condition& Condition::bind<x>(); \ + template x& Condition::get<x>(); \ + template const x& Condition::get<x>() const; \ }} -#define DD4HEP_DEFINE_CONDITIONS_CONT(x) \ - DD4HEP_DEFINE_CONDITIONS_TYPE(x) \ +#define DD4HEP_DEFINE_CONDITIONS_CONT(x) \ + DD4HEP_DEFINE_CONDITIONS_TYPE(x) \ DD4HEP_DEFINE_CONDITIONS_TYPE(std::vector<x>) \ - DD4HEP_DEFINE_CONDITIONS_TYPE(std::list<x>) \ + DD4HEP_DEFINE_CONDITIONS_TYPE(std::list<x>) \ DD4HEP_DEFINE_CONDITIONS_TYPE(std::set<x>) -#define DD4HEP_DEFINE_CONDITIONS_U_CONT(x) \ - DD4HEP_DEFINE_CONDITIONS_CONT(x) \ +#define DD4HEP_DEFINE_CONDITIONS_U_CONT(x) \ + DD4HEP_DEFINE_CONDITIONS_CONT(x) \ DD4HEP_DEFINE_CONDITIONS_CONT(unsigned x) diff --git a/DDCore/include/DD4hep/objects/DetectorInterna.h b/DDCore/include/DD4hep/objects/DetectorInterna.h index c49cb5594b7ca625a91a4adeaae6a08d0f0e1865..1864c073b50340e39b0ca9ad606f72c51f548752 100644 --- a/DDCore/include/DD4hep/objects/DetectorInterna.h +++ b/DDCore/include/DD4hep/objects/DetectorInterna.h @@ -76,10 +76,10 @@ namespace DD4hep { typedef std::vector<UpdateCall> UpdateCallbacks; enum DetFlags { - HAVE_WORLD_TRAFO = 1<<0, - HAVE_PARENT_TRAFO = 1<<1, - HAVE_REFERENCE_TRAFO = 1<<2, - HAVE_OTHER = 1<<31 + HAVE_WORLD_TRAFO = 1<<0, + HAVE_PARENT_TRAFO = 1<<1, + HAVE_REFERENCE_TRAFO = 1<<2, + HAVE_OTHER = 1<<31 }; /// Magic number to ensure data integrity diff --git a/DDCore/include/DD4hep/objects/ObjectsInterna.h b/DDCore/include/DD4hep/objects/ObjectsInterna.h index 770952e2b6769bc3a3708684da703cbef187c405..e9bed4f8afef5890bff14e4b721c3afcb54dc418 100644 --- a/DDCore/include/DD4hep/objects/ObjectsInterna.h +++ b/DDCore/include/DD4hep/objects/ObjectsInterna.h @@ -47,7 +47,7 @@ namespace DD4hep { virtual ~HeaderObject(); private: /// Private copy constructor - HeaderObject(const HeaderObject&) : NamedObject() {} + HeaderObject(const HeaderObject&) : NamedObject() {} /// Private assignment operator HeaderObject& operator=(const HeaderObject&) { return *this; } }; @@ -69,7 +69,7 @@ namespace DD4hep { virtual ~ConstantObject(); private: /// Private copy constructor - ConstantObject(const ConstantObject&) : NamedObject() {} + ConstantObject(const ConstantObject&) : NamedObject() {} /// Private assignment operator ConstantObject& operator=(const ConstantObject&) { return *this; } }; @@ -175,7 +175,7 @@ namespace DD4hep { #ifndef __CINT__ /// Access to the field container of the BitField64 const std::vector<BitFieldValue*> fields() const { - return _fields; + return _fields; } #endif }; diff --git a/DDCore/include/DD4hep/objects/VolumeManagerInterna.h b/DDCore/include/DD4hep/objects/VolumeManagerInterna.h index 7bbe77262c769d020840ca421c6a4ea994e3636a..b34425e2f922dd2e3e3f70611b35065c08bf6265 100644 --- a/DDCore/include/DD4hep/objects/VolumeManagerInterna.h +++ b/DDCore/include/DD4hep/objects/VolumeManagerInterna.h @@ -72,7 +72,7 @@ namespace DD4hep { * \author M.Frank * \version 1.0 * \ingroup DD4HEP_GEOMETRY - */ + */ class VolumeManagerObject: public NamedObject { public: typedef IDDescriptor::Field Field; diff --git a/DDCore/include/ROOT/LinkDef.h b/DDCore/include/ROOT/LinkDef.h index 48b800afad4e3d8e3d15d4aab6737817a4bece4c..cf2e5f991620c01ff163ffe3d82a16d529547de6 100644 --- a/DDCore/include/ROOT/LinkDef.h +++ b/DDCore/include/ROOT/LinkDef.h @@ -1,6 +1,6 @@ // // LinkDef.h -// +// // // Created by Pere Mato on 22/1/12. // Copyright 2012 __MyCompanyName__. All rights reserved. diff --git a/DDCore/include/XML/Conversions.h b/DDCore/include/XML/Conversions.h index ecd58b24c41c37871eb22fa91e6d17f669663b84..613db4cc26d81192f946cd078848377ecb6ca603 100644 --- a/DDCore/include/XML/Conversions.h +++ b/DDCore/include/XML/Conversions.h @@ -17,7 +17,7 @@ /// Namespace for the AIDA detector description toolkit namespace DD4hep { - /// Namespace for the AIDA detector description toolkit supporting XML utilities + /// Namespace for the AIDA detector description toolkit supporting XML utilities namespace XML { class Handle_t; } @@ -36,13 +36,13 @@ namespace DD4hep { /// Reference to optional user defined parameter user_param param; /// Initializing constructor of the functor - Converter(Geometry::LCDD& l) - : lcdd(l), param(0) { - } + Converter(Geometry::LCDD& l) + : lcdd(l), param(0) { + } /// Initializing constructor of the functor with initialization of the user parameter - Converter(Geometry::LCDD& l, user_param p) - : lcdd(l), param(p) { - } + Converter(Geometry::LCDD& l, user_param p) + : lcdd(l), param(p) { + } /// Callback operator to be specialized depending on the element type void operator()(XML::Handle_t xml) const; /// Typed access to the user parameter (unchecked) diff --git a/DDCore/include/XML/DocumentHandler.h b/DDCore/include/XML/DocumentHandler.h index f3fbd7ad34c9adcc9b56bc982f0f861d65e1921c..fe3d1d9b8d1c287ad82b8b77b778f7760c2df7d1 100644 --- a/DDCore/include/XML/DocumentHandler.h +++ b/DDCore/include/XML/DocumentHandler.h @@ -25,7 +25,7 @@ namespace DD4hep { class DocumentErrorHandler; /// Class supporting to read and parse XML documents. - /** + /** * Wrapper object around the document parser. * Supports both, XercesC and TiXml. * diff --git a/DDCore/include/XML/Evaluator.h b/DDCore/include/XML/Evaluator.h index 8260759c0ae506e9a6237be7eacaaab24a6ecdf4..677bf1458fdd7d48dc417f442bddf1646842b93e 100644 --- a/DDCore/include/XML/Evaluator.h +++ b/DDCore/include/XML/Evaluator.h @@ -255,7 +255,7 @@ namespace XmlTools { * @endcode */ void setSystemOfUnits(double meter = 1.0, double kilogram = 1.0, double second = 1.0, double ampere = 1.0, double kelvin = - 1.0, double mole = 1.0, double candela = 1.0, double radians = 1.0 ); + 1.0, double mole = 1.0, double candela = 1.0, double radians = 1.0 ); private: void * p; // private data diff --git a/DDCore/include/XML/Layering.h b/DDCore/include/XML/Layering.h index f8a95ef72d2324c5109af178907ec7bc32f7fc1d..544074a386e9c338d784bcfb722498fcb389cdfd 100644 --- a/DDCore/include/XML/Layering.h +++ b/DDCore/include/XML/Layering.h @@ -34,7 +34,7 @@ namespace DD4hep { /// Assignment operator LayerSlice& operator=(const LayerSlice& c); }; - + /// Initializing constructor inline LayerSlice::LayerSlice(bool s, double t, const std::string& m) : _sensitive(s), _thickness(t), _material(m) { @@ -161,15 +161,15 @@ namespace DD4hep { public: /// Initializing constructor LayeringCnv(Element e); - /// Invoke converter + /// Invoke converter void fromCompact(Layering& layering) const; }; - /// Initializing constructor + /// Initializing constructor inline LayeringCnv::LayeringCnv(Element e) : Element(e) { } - + } } /* End namespace DD4hep */ diff --git a/DDCore/include/XML/UnicodeValues.h b/DDCore/include/XML/UnicodeValues.h index 1ba1fa22a90f382cc358071c1df7a8fb7ef91b39..04522776e6547c77cb5d1e3e167df7563f1509a1 100644 --- a/DDCore/include/XML/UnicodeValues.h +++ b/DDCore/include/XML/UnicodeValues.h @@ -1,7 +1,7 @@ /// Namespace for the AIDA detector description toolkit namespace DD4hep { - /// Namespace for the AIDA detector description toolkit supporting XML utilities + /// Namespace for the AIDA detector description toolkit supporting XML utilities namespace XML { extern const Tag_t Unicode_NULL; diff --git a/DDCore/include/XML/XMLChildValue.h b/DDCore/include/XML/XMLChildValue.h index cbbf6c6bf4491fa6b0a963c60b988ca55d64a8f0..40851cf398abfeeeb1ee5b1cf0957440db9bbb84 100644 --- a/DDCore/include/XML/XMLChildValue.h +++ b/DDCore/include/XML/XMLChildValue.h @@ -15,7 +15,7 @@ /// Namespace for the AIDA detector description toolkit namespace DD4hep { - /// Namespace for the AIDA detector description toolkit supporting XML utilities + /// Namespace for the AIDA detector description toolkit supporting XML utilities namespace XML { /// XML Handle to xml elements with predefined child access @@ -53,16 +53,16 @@ namespace DD4hep { */ struct ChildValue: public Element { /// Default constructor - ChildValue() - : Element(Handle_t(0)) { + ChildValue() + : Element(Handle_t(0)) { } /// Constructor from Handle - ChildValue(Handle_t e) - : Element(e) { + ChildValue(Handle_t e) + : Element(e) { } /// Constructor from Element - ChildValue(const Element& e) - : Element(e) { + ChildValue(const Element& e) + : Element(e) { } /// Access parameters: id diff --git a/DDCore/include/XML/XMLDetector.h b/DDCore/include/XML/XMLDetector.h index 2d6057cda01bceace4bd5bac71f53a55494c9bb7..d871acb199f1dd993be73ff33b7da6cfede0df08 100644 --- a/DDCore/include/XML/XMLDetector.h +++ b/DDCore/include/XML/XMLDetector.h @@ -18,7 +18,7 @@ namespace DD4hep { // Forward declarations class NamedObject; - /// Namespace for the AIDA detector description toolkit supporting XML utilities + /// Namespace for the AIDA detector description toolkit supporting XML utilities namespace XML { /// XML Handle class extending the XML handle Dimension @@ -32,12 +32,12 @@ namespace DD4hep { */ struct Component: public Dimension { /// Constructor from Handle - Component(Handle_t e) - : Dimension(e) { + Component(Handle_t e) + : Dimension(e) { } /// Constructor from Element - Component(const Element& e) - : Dimension(e) { + Component(const Element& e) + : Dimension(e) { } /// Access material attribute as STL string std::string materialStr() const; @@ -58,8 +58,8 @@ namespace DD4hep { */ struct DetElement: public Dimension { /// Constructor from Handle - DetElement(Handle_t e) - : Dimension(e) { + DetElement(Handle_t e) + : Dimension(e) { } /// Access underlying XML handle object Handle_t handle() const { diff --git a/DDCore/include/XML/XMLDimension.h b/DDCore/include/XML/XMLDimension.h index 027c2f5c737883a2a98dde52b907e4b757e80f14..1043b923633d7c98c206915246f8bba22ecde544 100644 --- a/DDCore/include/XML/XMLDimension.h +++ b/DDCore/include/XML/XMLDimension.h @@ -15,7 +15,7 @@ /// Namespace for the AIDA detector description toolkit namespace DD4hep { - /// Namespace for the AIDA detector description toolkit supporting XML utilities + /// Namespace for the AIDA detector description toolkit supporting XML utilities namespace XML { /// XML Handle to xml elements with predefined attribute access @@ -45,16 +45,16 @@ namespace DD4hep { */ struct Dimension: public Element { /// Default constructor - Dimension() - : Element(Handle_t(0)) { + Dimension() + : Element(Handle_t(0)) { } /// Constructor from Handle - Dimension(Handle_t e) - : Element(e) { + Dimension(Handle_t e) + : Element(e) { } /// Constructor from Element - Dimension(const Element& e) - : Element(e) { + Dimension(const Element& e) + : Element(e) { } /// Access parameters: id @@ -461,7 +461,7 @@ namespace DD4hep { double lunit() const; /// Access min/max parameters: lunit double lunit(double default_value) const; - + /// Access child element with tag "dimensions" as Dimension object Dimension dimensions(bool throw_if_not_present = true) const; diff --git a/DDCore/include/XML/XMLElements.h b/DDCore/include/XML/XMLElements.h index 34693e07d1475b465a2994ffe7d9a231436dc316..62b3f80dd073202acbdbdf8a85a2b7aedae76a98 100644 --- a/DDCore/include/XML/XMLElements.h +++ b/DDCore/include/XML/XMLElements.h @@ -29,13 +29,13 @@ /// Namespace for the AIDA detector description toolkit namespace DD4hep { - /// Namespace for the AIDA detector description toolkit supporting XML utilities + /// Namespace for the AIDA detector description toolkit supporting XML utilities namespace XML { typedef const XmlAttr* Attribute; /// Definition of the XmlString class. - /** + /** * Definition of the XmlString class. * Unly used to have the same code base as for XercesC, * where this class does the unicode translations and @@ -44,7 +44,7 @@ namespace DD4hep { * \author M.Frank * \version 1.0 * \ingroup DD4HEP_XML - */ + */ class XmlString { public: /// Replicate string: internally allocates new string, which must be free'ed with release @@ -62,7 +62,7 @@ namespace DD4hep { #ifdef __TIXML__ /// Definition of the XmlException class. - /** + /** * Currently no real use. Present to make Xerces happy, * which has such a class. * @@ -73,9 +73,9 @@ namespace DD4hep { class XmlException { public: std::string msg; - XmlException() : msg() {} - XmlException(const std::string& m) : msg(m) {} - XmlException(const XmlException& e) : msg(e.msg) {} + XmlException() : msg() {} + XmlException(const std::string& m) : msg(m) {} + XmlException(const XmlException& e) : msg(e.msg) {} virtual ~XmlException() {} XmlException& operator=(const XmlException& c) { if ( &c != this ) msg = c.msg; @@ -112,7 +112,7 @@ namespace DD4hep { /// Format void pointer (64 bits) to string with atrbitrary format \ingroup DD4HEP_XML std::string _ptrToString(const void* p, const char* fmt = "%p"); /// Format void pointer (64 bits) to string with atrbitrary format \ingroup DD4HEP_XML - template <typename T> std::string _toString(const T* p, const char* fmt = "%p") + template <typename T> std::string _toString(const T* p, const char* fmt = "%p") { return _ptrToString((void*)p,fmt); } /// Helper function to populate the evaluator dictionary \ingroup DD4HEP_XML @@ -139,7 +139,7 @@ namespace DD4hep { double _toDouble(const XmlChar* value); /// Helper class to encapsulate a unicode string. - /** + /** * Simple conversion from ascii strings to unicode strings. * Useful when using XercesC - dummy implementation for TiXml. * @@ -233,21 +233,21 @@ namespace DD4hep { std::string m_str; #ifndef __TIXML__ /// Constructor from normal ASCII string - Tag_t(const char* s) - : Strng_t(s), m_str(s) { + Tag_t(const char* s) + : Strng_t(s), m_str(s) { } #endif /// Constructor from unicode string - Tag_t(const XmlChar* s) - : Strng_t(s), m_str(_toString(s)) { + Tag_t(const XmlChar* s) + : Strng_t(s), m_str(_toString(s)) { } /// Constructor from internal XML string - Tag_t(const Strng_t& s) - : Strng_t(s), m_str(_toString(s)) { + Tag_t(const Strng_t& s) + : Strng_t(s), m_str(_toString(s)) { } /// Constructor from STL string - Tag_t(const std::string& s) - : Strng_t(s), m_str(s) { + Tag_t(const std::string& s) + : Strng_t(s), m_str(s) { } /// Destructor ~Tag_t() { @@ -343,8 +343,8 @@ namespace DD4hep { mutable Elt_t m_node; /// Initializing constructor - Handle_t(Elt_t e = 0) - : m_node(e) { + Handle_t(Elt_t e = 0) + : m_node(e) { } /// Direct access to the XmlElement using the operator-> Elt_t operator->() const { @@ -504,19 +504,19 @@ namespace DD4hep { } #if 0 template<> INLINE bool Handle_t::attr<bool>(const Attribute tag) const - { return _toBool(attr_value(tag));} + { return _toBool(attr_value(tag));} template<> INLINE int Handle_t::attr<int>(const Attribute tag) const - { return _toInt(attr_value(tag));} + { return _toInt(attr_value(tag));} template<> INLINE float Handle_t::attr<float>(const Attribute tag) const - { return _toFloat(attr_value(tag));} + { return _toFloat(attr_value(tag));} template<> INLINE double Handle_t::attr<double>(const Attribute tag) const - { return _toDouble(attr_value(tag));} + { return _toDouble(attr_value(tag));} template<> INLINE std::string Handle_t::attr<std::string>(const Attribute tag) const - { return _toString(attr_value(tag));} + { return _toString(attr_value(tag));} #endif /// Class to support the access to collections of XmlNodes (or XmlElements) @@ -592,8 +592,8 @@ namespace DD4hep { DOC m_doc; /// Constructor - Document(DOC d) - : m_doc(d) { + Document(DOC d) + : m_doc(d) { } /// Auto-conversion to DOM document operator DOC() const { @@ -631,8 +631,8 @@ namespace DD4hep { class DocumentHolder : public Document { public: /// Constructor - DocumentHolder(DOC d) - : Document(d) { + DocumentHolder(DOC d) + : Document(d) { } /// Standard destructor - releases the document virtual ~DocumentHolder(); @@ -659,8 +659,8 @@ namespace DD4hep { Handle_t m_element; /// Constructor from XmlElement handle - Element(const Handle_t& e) - : m_element(e) { + Element(const Handle_t& e) + : m_element(e) { } /// Constructor from DOM document entity Element(const Document& document, const XmlChar* type); @@ -677,13 +677,13 @@ namespace DD4hep { } /// Assignment operator Element& operator=(const Element& c) { - m_element = c.m_element; - return *this; + m_element = c.m_element; + return *this; } /// Assignment operator Element& operator=(Handle_t handle) { - m_element = handle; - return *this; + m_element = handle; + return *this; } /// Automatic conversion to DOM element handle operator Handle_t() const { @@ -755,7 +755,7 @@ namespace DD4hep { Attribute getAttr(const XmlChar* name) const; /// Set single attribute template <class T> - Attribute setAttr(const XmlChar* nam, const T& val) const { + Attribute setAttr(const XmlChar* nam, const T& val) const { return m_element.setAttr(nam, val); } /// Set element value diff --git a/DDCore/include/XML/config.h b/DDCore/include/XML/config.h index 0c17a6c0dca40383432dcbd443ec316a024b0207..e39db645e7a5131b3f618bad2c0d846b56d97192 100644 --- a/DDCore/include/XML/config.h +++ b/DDCore/include/XML/config.h @@ -23,7 +23,7 @@ /// Namespace for the AIDA detector description toolkit namespace DD4hep { - /// Namespace for the AIDA detector description toolkit supporting XML utilities + /// Namespace for the AIDA detector description toolkit supporting XML utilities namespace XML { class XmlElement; class XmlDocument; diff --git a/DDCore/include/XML/tinystr.h b/DDCore/include/XML/tinystr.h index 3c2aa9d54daa7ddafe718a35e54d465479d8caa1..ca177a3f7247cfe03443035270bc26a001cd0a31 100644 --- a/DDCore/include/XML/tinystr.h +++ b/DDCore/include/XML/tinystr.h @@ -1,25 +1,25 @@ /* -www.sourceforge.net/projects/tinyxml -Original file by Yves Berquin. + www.sourceforge.net/projects/tinyxml + Original file by Yves Berquin. -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. + 1. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation + would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. + 2. Altered source versions must be plainly marked as such, and + must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source -distribution. + 3. This notice may not be removed or altered from any source + distribution. */ /* @@ -42,238 +42,238 @@ distribution. #include <assert.h> #include <string.h> -/* The support for explicit isn't that universal, and it isn't really - required - it is used to check that the TiXmlString class isn't incorrectly - used. Be nice to old compilers and macro it here: +/* The support for explicit isn't that universal, and it isn't really + required - it is used to check that the TiXmlString class isn't incorrectly + used. Be nice to old compilers and macro it here: */ #if defined(_MSC_VER) && (_MSC_VER >= 1200 ) - // Microsoft visual studio, version 6 and higher. - #define TIXML_EXPLICIT explicit +// Microsoft visual studio, version 6 and higher. +#define TIXML_EXPLICIT explicit #elif defined(__GNUC__) && (__GNUC__ >= 3 ) - // GCC version 3 and higher.s - #define TIXML_EXPLICIT explicit +// GCC version 3 and higher.s +#define TIXML_EXPLICIT explicit #else - #define TIXML_EXPLICIT +#define TIXML_EXPLICIT #endif /* - TiXmlString is an emulation of a subset of the std::string template. - Its purpose is to allow compiling TinyXML on compilers with no or poor STL support. - Only the member functions relevant to the TinyXML project have been implemented. - The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase - a string and there's no more room, we allocate a buffer twice as big as we need. + TiXmlString is an emulation of a subset of the std::string template. + Its purpose is to allow compiling TinyXML on compilers with no or poor STL support. + Only the member functions relevant to the TinyXML project have been implemented. + The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase + a string and there's no more room, we allocate a buffer twice as big as we need. */ class TiXmlString { - public : - // The size type used - typedef size_t size_type; - - // Error value for find primitive - static const size_type npos; // = -1; - - - // TiXmlString empty constructor - TiXmlString () : rep_(&nullrep_) - { - } - - // TiXmlString copy constructor - TiXmlString ( const TiXmlString & copy) : rep_(0) - { - init(copy.length()); - memcpy(start(), copy.data(), length()); - } - - // TiXmlString constructor, based on a string - TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0) - { - init( static_cast<size_type>( strlen(copy) )); - memcpy(start(), copy, length()); - } - - // TiXmlString constructor, based on a string - TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0) - { - init(len); - memcpy(start(), str, len); - } - - // TiXmlString destructor - ~TiXmlString () - { - quit(); - } - - // = operator - TiXmlString& operator = (const char * copy) - { - return assign( copy, (size_type)strlen(copy)); - } - - // = operator - TiXmlString& operator = (const TiXmlString & copy) - { - return assign(copy.start(), copy.length()); - } - - - // += operator. Maps to append - TiXmlString& operator += (const char * suffix) - { - return append(suffix, static_cast<size_type>( strlen(suffix) )); - } - - // += operator. Maps to append - TiXmlString& operator += (char single) - { - return append(&single, 1); - } - - // += operator. Maps to append - TiXmlString& operator += (const TiXmlString & suffix) - { - return append(suffix.data(), suffix.length()); - } - - - // Convert a TiXmlString into a null-terminated char * - const char * c_str () const { return rep_->str; } - - // Convert a TiXmlString into a char * (need not be null terminated). - const char * data () const { return rep_->str; } - - // Return the length of a TiXmlString - size_type length () const { return rep_->size; } - - // Alias for length() - size_type size () const { return rep_->size; } - - // Checks if a TiXmlString is empty - bool empty () const { return rep_->size == 0; } - - // Return capacity of string - size_type capacity () const { return rep_->capacity; } - - - // single char extraction - const char& at (size_type index) const - { - assert( index < length() ); - return rep_->str[ index ]; - } - - // [] operator - char& operator [] (size_type index) const - { - assert( index < length() ); - return rep_->str[ index ]; - } - - // find a char in a string. Return TiXmlString::npos if not found - size_type find (char lookup) const - { - return find(lookup, 0); - } - - // find a char in a string from an offset. Return TiXmlString::npos if not found - size_type find (char tofind, size_type offset) const - { - if (offset >= length()) return npos; - - for (const char* p = c_str() + offset; *p != '\0'; ++p) - { - if (*p == tofind) return static_cast< size_type >( p - c_str() ); - } - return npos; - } - - void clear () - { - //Lee: - //The original was just too strange, though correct: - // TiXmlString().swap(*this); - //Instead use the quit & re-init: - quit(); - init(0,0); - } - - /* Function to reserve a big amount of data when we know we'll need it. Be aware that this - function DOES NOT clear the content of the TiXmlString if any exists. - */ - void reserve (size_type cap); - - TiXmlString& assign (const char* str, size_type len); - - TiXmlString& append (const char* str, size_type len); - - void swap (TiXmlString& other) - { - Rep* r = rep_; - rep_ = other.rep_; - other.rep_ = r; - } - - private: - - void init(size_type sz) { init(sz, sz); } - void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; } - char* start() const { return rep_->str; } - char* finish() const { return rep_->str + rep_->size; } - - struct Rep - { - size_type size, capacity; - char str[1]; - }; - - void init(size_type sz, size_type cap) - { - if (cap) - { - // Lee: the original form: - // rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap)); - // doesn't work in some cases of new being overloaded. Switching - // to the normal allocation, although use an 'int' for systems - // that are overly picky about structure alignment. - const size_type bytesNeeded = sizeof(Rep) + cap; - const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); - rep_ = reinterpret_cast<Rep*>( new int[ intsNeeded ] ); - - rep_->str[ rep_->size = sz ] = '\0'; - rep_->capacity = cap; - } - else - { - rep_ = &nullrep_; - } - } - - void quit() - { - if (rep_ != &nullrep_) - { - // The rep_ is really an array of ints. (see the allocator, above). - // Cast it back before delete, so the compiler won't incorrectly call destructors. - delete [] ( reinterpret_cast<int*>( rep_ ) ); - } - } - - Rep * rep_; - static Rep nullrep_; + public : + // The size type used + typedef size_t size_type; + + // Error value for find primitive + static const size_type npos; // = -1; + + + // TiXmlString empty constructor + TiXmlString () : rep_(&nullrep_) + { + } + + // TiXmlString copy constructor + TiXmlString ( const TiXmlString & copy) : rep_(0) + { + init(copy.length()); + memcpy(start(), copy.data(), length()); + } + + // TiXmlString constructor, based on a string + TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0) + { + init( static_cast<size_type>( strlen(copy) )); + memcpy(start(), copy, length()); + } + + // TiXmlString constructor, based on a string + TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0) + { + init(len); + memcpy(start(), str, len); + } + + // TiXmlString destructor + ~TiXmlString () + { + quit(); + } + + // = operator + TiXmlString& operator = (const char * copy) + { + return assign( copy, (size_type)strlen(copy)); + } + + // = operator + TiXmlString& operator = (const TiXmlString & copy) + { + return assign(copy.start(), copy.length()); + } + + + // += operator. Maps to append + TiXmlString& operator += (const char * suffix) + { + return append(suffix, static_cast<size_type>( strlen(suffix) )); + } + + // += operator. Maps to append + TiXmlString& operator += (char single) + { + return append(&single, 1); + } + + // += operator. Maps to append + TiXmlString& operator += (const TiXmlString & suffix) + { + return append(suffix.data(), suffix.length()); + } + + + // Convert a TiXmlString into a null-terminated char * + const char * c_str () const { return rep_->str; } + + // Convert a TiXmlString into a char * (need not be null terminated). + const char * data () const { return rep_->str; } + + // Return the length of a TiXmlString + size_type length () const { return rep_->size; } + + // Alias for length() + size_type size () const { return rep_->size; } + + // Checks if a TiXmlString is empty + bool empty () const { return rep_->size == 0; } + + // Return capacity of string + size_type capacity () const { return rep_->capacity; } + + + // single char extraction + const char& at (size_type index) const + { + assert( index < length() ); + return rep_->str[ index ]; + } + + // [] operator + char& operator [] (size_type index) const + { + assert( index < length() ); + return rep_->str[ index ]; + } + + // find a char in a string. Return TiXmlString::npos if not found + size_type find (char lookup) const + { + return find(lookup, 0); + } + + // find a char in a string from an offset. Return TiXmlString::npos if not found + size_type find (char tofind, size_type offset) const + { + if (offset >= length()) return npos; + + for (const char* p = c_str() + offset; *p != '\0'; ++p) + { + if (*p == tofind) return static_cast< size_type >( p - c_str() ); + } + return npos; + } + + void clear () + { + //Lee: + //The original was just too strange, though correct: + // TiXmlString().swap(*this); + //Instead use the quit & re-init: + quit(); + init(0,0); + } + + /* Function to reserve a big amount of data when we know we'll need it. Be aware that this + function DOES NOT clear the content of the TiXmlString if any exists. + */ + void reserve (size_type cap); + + TiXmlString& assign (const char* str, size_type len); + + TiXmlString& append (const char* str, size_type len); + + void swap (TiXmlString& other) + { + Rep* r = rep_; + rep_ = other.rep_; + other.rep_ = r; + } + + private: + + void init(size_type sz) { init(sz, sz); } + void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; } + char* start() const { return rep_->str; } + char* finish() const { return rep_->str + rep_->size; } + + struct Rep + { + size_type size, capacity; + char str[1]; + }; + + void init(size_type sz, size_type cap) + { + if (cap) + { + // Lee: the original form: + // rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap)); + // doesn't work in some cases of new being overloaded. Switching + // to the normal allocation, although use an 'int' for systems + // that are overly picky about structure alignment. + const size_type bytesNeeded = sizeof(Rep) + cap; + const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); + rep_ = reinterpret_cast<Rep*>( new int[ intsNeeded ] ); + + rep_->str[ rep_->size = sz ] = '\0'; + rep_->capacity = cap; + } + else + { + rep_ = &nullrep_; + } + } + + void quit() + { + if (rep_ != &nullrep_) + { + // The rep_ is really an array of ints. (see the allocator, above). + // Cast it back before delete, so the compiler won't incorrectly call destructors. + delete [] ( reinterpret_cast<int*>( rep_ ) ); + } + } + + Rep * rep_; + static Rep nullrep_; } ; inline bool operator == (const TiXmlString & a, const TiXmlString & b) { - return ( a.length() == b.length() ) // optimization on some platforms - && ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare + return ( a.length() == b.length() ) // optimization on some platforms + && ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare } inline bool operator < (const TiXmlString & a, const TiXmlString & b) { - return strcmp(a.c_str(), b.c_str()) < 0; + return strcmp(a.c_str(), b.c_str()) < 0; } inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); } @@ -292,28 +292,28 @@ TiXmlString operator + (const char* a, const TiXmlString & b); /* - TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString. - Only the operators that we need for TinyXML have been developped. + TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString. + Only the operators that we need for TinyXML have been developped. */ class TiXmlOutStream : public TiXmlString { -public : - - // TiXmlOutStream << operator. - TiXmlOutStream & operator << (const TiXmlString & in) - { - *this += in; - return *this; - } - - // TiXmlOutStream << operator. - TiXmlOutStream & operator << (const char * in) - { - *this += in; - return *this; - } + public : + + // TiXmlOutStream << operator. + TiXmlOutStream & operator << (const TiXmlString & in) + { + *this += in; + return *this; + } + + // TiXmlOutStream << operator. + TiXmlOutStream & operator << (const char * in) + { + *this += in; + return *this; + } } ; -#endif // TIXML_STRING_INCLUDED -#endif // TIXML_USE_STL +#endif // TIXML_STRING_INCLUDED +#endif // TIXML_USE_STL diff --git a/DDCore/include/XML/tinyxml.h b/DDCore/include/XML/tinyxml.h index 1b21c402f4ba98e2339065aa56fe3c0e8fff5897..95921278ddb22577bdac2900c5c5c8375f526505 100644 --- a/DDCore/include/XML/tinyxml.h +++ b/DDCore/include/XML/tinyxml.h @@ -1,29 +1,29 @@ /* - www.sourceforge.net/projects/tinyxml - Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) + www.sourceforge.net/projects/tinyxml + Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any - damages arising from the use of this software. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. - Permission is granted to anyone to use this software for any - purpose, including commercial applications, and to alter it and - redistribute it freely, subject to the following restrictions: + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: - 1. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product documentation - would be appreciated but is not required. + 1. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation + would be appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and - must not be misrepresented as being the original software. + 2. Altered source versions must be plainly marked as such, and + must not be misrepresented as being the original software. - 3. This notice may not be removed or altered from any source - distribution. + 3. This notice may not be removed or altered from any source + distribution. - F.Gaede, DESY : added #define TIXML_USE_STL for use with marlin - */ + F.Gaede, DESY : added #define TIXML_USE_STL for use with marlin +*/ #ifndef TIXML_USE_STL #define TIXML_USE_STL @@ -53,10 +53,10 @@ #include <string> #include <iostream> #include <sstream> -#define TIXML_STRING std::string +#define TIXML_STRING std::string #else #include "tinystr.h" -#define TIXML_STRING TiXmlString +#define TIXML_STRING TiXmlString #endif // Deprecated library function hell. Compilers want to use the @@ -96,9 +96,9 @@ const int TIXML_MAJOR_VERSION = 2; const int TIXML_MINOR_VERSION = 5; const int TIXML_PATCH_VERSION = 2; -/* Internal structure for tracking location of items - in the XML file. - */ +/* Internal structure for tracking location of items + in the XML file. +*/ struct TiXmlCursor { TiXmlCursor() { Clear(); @@ -112,25 +112,25 @@ struct TiXmlCursor { }; /** - If you call the Accept() method, it requires being passed a TiXmlVisitor - class to handle callbacks. For nodes that contain other nodes (Document, Element) - you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves - are simple called with Visit(). + If you call the Accept() method, it requires being passed a TiXmlVisitor + class to handle callbacks. For nodes that contain other nodes (Document, Element) + you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves + are simple called with Visit(). - If you return 'true' from a Visit method, recursive parsing will continue. If you return - false, <b>no children of this node or its sibilings</b> will be Visited. + If you return 'true' from a Visit method, recursive parsing will continue. If you return + false, <b>no children of this node or its sibilings</b> will be Visited. - All flavors of Visit methods have a default implementation that returns 'true' (continue - visiting). You need to only override methods that are interesting to you. + All flavors of Visit methods have a default implementation that returns 'true' (continue + visiting). You need to only override methods that are interesting to you. - Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting. + Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting. - You should never change the document from a callback. + You should never change the document from a callback. - @sa TiXmlNode::Accept() - */ + @sa TiXmlNode::Accept() +*/ class TiXmlVisitor { -public: + public: virtual ~TiXmlVisitor() { } @@ -183,56 +183,56 @@ enum TiXmlEncoding { const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN; /** TiXmlBase is a base class for every class in TinyXml. - It does little except to establish that TinyXml classes - can be printed and provide some utility functions. - - In XML, the document and elements can contain - other elements and other types of nodes. - - @verbatim - A Document can contain: Element (container or leaf) - Comment (leaf) - Unknown (leaf) - Declaration( leaf ) - - An Element can contain: Element (container or leaf) - Text (leaf) - Attributes (not on tree) - Comment (leaf) - Unknown (leaf) - - A Decleration contains: Attributes (not on tree) - @endverbatim - */ + It does little except to establish that TinyXml classes + can be printed and provide some utility functions. + + In XML, the document and elements can contain + other elements and other types of nodes. + + @verbatim + A Document can contain: Element (container or leaf) + Comment (leaf) + Unknown (leaf) + Declaration( leaf ) + + An Element can contain: Element (container or leaf) + Text (leaf) + Attributes (not on tree) + Comment (leaf) + Unknown (leaf) + + A Decleration contains: Attributes (not on tree) + @endverbatim +*/ class TiXmlBase { friend class TiXmlNode; friend class TiXmlElement; friend class TiXmlDocument; -public: - TiXmlBase() - : userData(0) { + public: + TiXmlBase() + : userData(0) { } virtual ~TiXmlBase() { } - /** All TinyXml classes can print themselves to a filestream - or the string class (TiXmlString in non-STL mode, std::string - in STL mode.) Either or both cfile and str can be null. + /** All TinyXml classes can print themselves to a filestream + or the string class (TiXmlString in non-STL mode, std::string + in STL mode.) Either or both cfile and str can be null. - This is a formatted print, and will insert - tabs and newlines. + This is a formatted print, and will insert + tabs and newlines. - (For an unformatted stream, use the << operator.) - */ + (For an unformatted stream, use the << operator.) + */ virtual void Print(FILE* cfile, int depth) const = 0; - /** The world does not agree on whether white space should be kept or - not. In order to make everyone happy, these global, static functions - are provided to set whether or not TinyXml will condense all white space - into a single space or not. The default is to condense. Note changing this - value is not thread safe. - */ + /** The world does not agree on whether white space should be kept or + not. In order to make everyone happy, these global, static functions + are provided to set whether or not TinyXml will condense all white space + into a single space or not. The default is to condense. Note changing this + value is not thread safe. + */ static void SetCondenseWhiteSpace(bool condense) { condenseWhiteSpace = condense; } @@ -243,23 +243,23 @@ public: } /** Return the position, in the original source file, of this node or attribute. - The row and column are 1-based. (That is the first row and first column is - 1,1). If the returns values are 0 or less, then the parser does not have - a row and column value. + The row and column are 1-based. (That is the first row and first column is + 1,1). If the returns values are 0 or less, then the parser does not have + a row and column value. - Generally, the row and column value will be set when the TiXmlDocument::Load(), - TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set - when the DOM was created from operator>>. + Generally, the row and column value will be set when the TiXmlDocument::Load(), + TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set + when the DOM was created from operator>>. - The values reflect the initial load. Once the DOM is modified programmatically - (by adding or changing nodes and attributes) the new values will NOT update to - reflect changes in the document. + The values reflect the initial load. Once the DOM is modified programmatically + (by adding or changing nodes and attributes) the new values will NOT update to + reflect changes in the document. - There is a minor performance cost to computing the row and column. Computation - can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value. + There is a minor performance cost to computing the row and column. Computation + can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value. - @sa TiXmlDocument::SetTabSize() - */ + @sa TiXmlDocument::SetTabSize() + */ int Row() const { return location.row + 1; } @@ -305,7 +305,7 @@ public: TIXML_ERROR_STRING_COUNT }; -protected: + protected: static const char* SkipWhiteSpace(const char*, TiXmlEncoding encoding); inline static bool IsWhiteSpace(char c) { @@ -322,21 +322,21 @@ protected: static bool StreamTo(std::istream * in, int character, TIXML_STRING * tag); #endif - /* Reads an XML name into the string provided. Returns - a pointer just past the last character of the name, - or 0 if the function has an error. - */ + /* Reads an XML name into the string provided. Returns + a pointer just past the last character of the name, + or 0 if the function has an error. + */ static const char* ReadName(const char* p, TIXML_STRING* name, TiXmlEncoding encoding); - /* Reads text. Returns a pointer past the given end tag. - Wickedly complex options, but it keeps the (sensitive) code in one place. - */ - static const char* ReadText(const char* in, // where to start - TIXML_STRING* text, // the string read - bool ignoreWhiteSpace, // whether to keep the white space - const char* endTag, // what ends this text - bool ignoreCase, // whether to ignore case in the end tag - TiXmlEncoding encoding); // the current encoding + /* Reads text. Returns a pointer past the given end tag. + Wickedly complex options, but it keeps the (sensitive) code in one place. + */ + static const char* ReadText(const char* in, // where to start + TIXML_STRING* text, // the string read + bool ignoreWhiteSpace, // whether to keep the white space + const char* endTag, // what ends this text + bool ignoreCase, // whether to ignore case in the end tag + TiXmlEncoding encoding); // the current encoding // If an entity has been found, transform it into a character. static const char* GetEntity(const char* in, char* value, int* length, TiXmlEncoding encoding); @@ -360,7 +360,7 @@ protected: return p + 1; } else if (*length) { - //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe), + //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe), // and the null terminator isn't needed for (int i = 0; p[i] && i < *length; ++i) { _value[i] = p[i]; @@ -405,8 +405,8 @@ protected: } static void ConvertUTF32ToUTF8(unsigned long input, char* output, int* length); -private: - TiXmlBase(const TiXmlBase&); // not implemented. + private: + TiXmlBase(const TiXmlBase&); // not implemented. void operator=(const TiXmlBase& base); // not allowed. struct Entity { @@ -423,39 +423,39 @@ private: }; /** The parent class for everything in the Document Object Model. - (Except for attributes). - Nodes have siblings, a parent, and children. A node can be - in a document, or stand on its own. The type of a TiXmlNode - can be queried, and it can be cast to its more defined type. - */ + (Except for attributes). + Nodes have siblings, a parent, and children. A node can be + in a document, or stand on its own. The type of a TiXmlNode + can be queried, and it can be cast to its more defined type. +*/ class TiXmlNode: public TiXmlBase { friend class TiXmlDocument; friend class TiXmlElement; -public: + public: #ifdef TIXML_USE_STL /** An input stream operator, for every class. Tolerant of newlines and - formatting, but doesn't expect them. - */ + formatting, but doesn't expect them. + */ friend std::istream& operator >>(std::istream& in, TiXmlNode& base); /** An output stream operator, for every class. Note that this outputs - without any newlines or formatting, as opposed to Print(), which - includes tabs and new lines. + without any newlines or formatting, as opposed to Print(), which + includes tabs and new lines. - The operator<< and operator>> are not completely symmetric. Writing - a node to a stream is very well defined. You'll get a nice stream - of output, without any extra whitespace or newlines. + The operator<< and operator>> are not completely symmetric. Writing + a node to a stream is very well defined. You'll get a nice stream + of output, without any extra whitespace or newlines. - But reading is not as well defined. (As it always is.) If you create - a TiXmlElement (for example) and read that from an input stream, - the text needs to define an element or junk will result. This is - true of all input streams, but it's worth keeping in mind. + But reading is not as well defined. (As it always is.) If you create + a TiXmlElement (for example) and read that from an input stream, + the text needs to define an element or junk will result. This is + true of all input streams, but it's worth keeping in mind. - A TiXmlDocument will read nodes until it reads a root element, and - all the children of that root element. - */ + A TiXmlDocument will read nodes until it reads a root element, and + all the children of that root element. + */ friend std::ostream& operator<<(std::ostream& out, const TiXmlNode& base); /// Appends the XML node or attribute to a std::string. @@ -464,8 +464,8 @@ public: #endif /** The types of XML nodes supported by TinyXml. (All the - unsupported types are picked up by UNKNOWN.) - */ + unsupported types are picked up by UNKNOWN.) + */ enum NodeType { DOCUMENT, ELEMENT, COMMENT, UNKNOWN, TEXT, DECLARATION, TYPECOUNT }; @@ -473,40 +473,40 @@ public: virtual ~TiXmlNode(); /** The meaning of 'value' changes for the specific type of - TiXmlNode. - @verbatim - Document: filename of the xml file - Element: name of the element - Comment: the comment text - Unknown: the tag contents - Text: the text string - @endverbatim - - The subclasses will wrap this function. - */ + TiXmlNode. + @verbatim + Document: filename of the xml file + Element: name of the element + Comment: the comment text + Unknown: the tag contents + Text: the text string + @endverbatim + + The subclasses will wrap this function. + */ const char *Value() const { return value.c_str(); } #ifdef TIXML_USE_STL /** Return Value() as a std::string. If you only use STL, - this is more efficient than calling Value(). - Only available in STL mode. - */ + this is more efficient than calling Value(). + Only available in STL mode. + */ const std::string& ValueStr() const { return value; } #endif /** Changes the value of the node. Defined as: - @verbatim - Document: filename of the xml file - Element: name of the element - Comment: the comment text - Unknown: the tag contents - Text: the text string - @endverbatim - */ + @verbatim + Document: filename of the xml file + Element: name of the element + Comment: the comment text + Unknown: the tag contents + Text: the text string + @endverbatim + */ void SetValue(const char * _value) { value = _value; } @@ -531,11 +531,11 @@ public: const TiXmlNode* FirstChild() const { return firstChild; - } ///< The first child of this node. Will be null if there are no children. + } ///< The first child of this node. Will be null if there are no children. TiXmlNode* FirstChild() { return firstChild; } - const TiXmlNode* FirstChild(const char * value) const; ///< The first child of this node with the matching 'value'. Will be null if none found. + const TiXmlNode* FirstChild(const char * value) const; ///< The first child of this node with the matching 'value'. Will be null if none found. /// The first child of this node with the matching 'value'. Will be null if none found. TiXmlNode* FirstChild(const char * _value) { // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe) @@ -544,12 +544,12 @@ public: } const TiXmlNode* LastChild() const { return lastChild; - } /// The last child of this node. Will be null if there are no children. + } /// The last child of this node. Will be null if there are no children. TiXmlNode* LastChild() { return lastChild; } - const TiXmlNode* LastChild(const char * value) const; /// The last child of this node matching 'value'. Will be null if there are no children. + const TiXmlNode* LastChild(const char * value) const; /// The last child of this node matching 'value'. Will be null if there are no children. TiXmlNode* LastChild(const char * _value) { return const_cast<TiXmlNode*>((const_cast<const TiXmlNode*>(this))->LastChild(_value)); } @@ -570,21 +570,21 @@ public: #endif /** An alternate way to walk the children of a node. - One way to iterate over nodes is: - @verbatim - for( child = parent->FirstChild(); child; child = child->NextSibling() ) - @endverbatim - - IterateChildren does the same thing with the syntax: - @verbatim - child = 0; - while( child = parent->IterateChildren( child ) ) - @endverbatim - - IterateChildren takes the previous child as input and finds - the next one. If the previous child is null, it returns the - first. IterateChildren will return null when done. - */ + One way to iterate over nodes is: + @verbatim + for( child = parent->FirstChild(); child; child = child->NextSibling() ) + @endverbatim + + IterateChildren does the same thing with the syntax: + @verbatim + child = 0; + while( child = parent->IterateChildren( child ) ) + @endverbatim + + IterateChildren takes the previous child as input and finds + the next one. If the previous child is null, it returns the + first. IterateChildren will return null when done. + */ const TiXmlNode* IterateChildren(const TiXmlNode* previous) const; TiXmlNode* IterateChildren(const TiXmlNode* previous) { return const_cast<TiXmlNode*>((const_cast<const TiXmlNode*>(this))->IterateChildren(previous)); @@ -606,34 +606,34 @@ public: #endif /** Add a new node related to this. Adds a child past the LastChild. - Returns a pointer to the new object or NULL if an error occured. - */ + Returns a pointer to the new object or NULL if an error occured. + */ TiXmlNode* InsertEndChild(const TiXmlNode& addThis); /** Add a new node related to this. Adds a child past the LastChild. - NOTE: the node to be added is passed by pointer, and will be - henceforth owned (and deleted) by tinyXml. This method is efficient - and avoids an extra copy, but should be used with care as it - uses a different memory model than the other insert functions. + NOTE: the node to be added is passed by pointer, and will be + henceforth owned (and deleted) by tinyXml. This method is efficient + and avoids an extra copy, but should be used with care as it + uses a different memory model than the other insert functions. - @sa InsertEndChild - */ + @sa InsertEndChild + */ TiXmlNode* LinkEndChild(TiXmlNode* addThis); /** Add a new node related to this. Adds a child before the specified child. - Returns a pointer to the new object or NULL if an error occured. - */ + Returns a pointer to the new object or NULL if an error occured. + */ TiXmlNode* InsertBeforeChild(TiXmlNode* beforeThis, const TiXmlNode& addThis); /** Add a new node related to this. Adds a child after the specified child. - Returns a pointer to the new object or NULL if an error occured. - */ + Returns a pointer to the new object or NULL if an error occured. + */ TiXmlNode* InsertAfterChild(TiXmlNode* afterThis, const TiXmlNode& addThis); /** Replace a child of this node. - Returns a pointer to the new object or NULL if an error occured. - */ + Returns a pointer to the new object or NULL if an error occured. + */ TiXmlNode* ReplaceChild(TiXmlNode* replaceThis, const TiXmlNode& withThis); /// Delete a child of this node. @@ -683,36 +683,36 @@ public: } /** Convenience function to get through elements. - Calls NextSibling and ToElement. Will skip all non-Element - nodes. Returns 0 if there is not another element. - */ + Calls NextSibling and ToElement. Will skip all non-Element + nodes. Returns 0 if there is not another element. + */ const TiXmlElement* NextSiblingElement() const; TiXmlElement* NextSiblingElement() { return const_cast<TiXmlElement*>((const_cast<const TiXmlNode*>(this))->NextSiblingElement()); } /** Convenience function to get through elements. - Calls NextSibling and ToElement. Will skip all non-Element - nodes. Returns 0 if there is not another element. - */ + Calls NextSibling and ToElement. Will skip all non-Element + nodes. Returns 0 if there is not another element. + */ const TiXmlElement* NextSiblingElement(const char *) const; TiXmlElement* NextSiblingElement(const char *_next) { return const_cast<TiXmlElement*>((const_cast<const TiXmlNode*>(this))->NextSiblingElement(_next)); } /** Convenience function to get through elements. - Calls PreviousSibling and ToElement. Will skip all non-Element - nodes. Returns 0 if there is not another element. - */ + Calls PreviousSibling and ToElement. Will skip all non-Element + nodes. Returns 0 if there is not another element. + */ const TiXmlElement* PreviousSiblingElement() const; TiXmlElement* PreviousSiblingElement() { return const_cast<TiXmlElement*>((const_cast<const TiXmlNode*>(this))->PreviousSiblingElement()); } /** Convenience function to get through elements. - Calls PreviousSibling and ToElement. Will skip all non-Element - nodes. Returns 0 if there is not another element. - */ + Calls PreviousSibling and ToElement. Will skip all non-Element + nodes. Returns 0 if there is not another element. + */ const TiXmlElement* PreviousSiblingElement(const char *) const; TiXmlElement* PreviousSiblingElement(const char *_next) { return const_cast<TiXmlElement*>((const_cast<const TiXmlNode*>(this))->PreviousSiblingElement(_next)); @@ -749,16 +749,16 @@ public: #endif /** Query the type (as an enumerated value, above) of this node. - The possible types are: DOCUMENT, ELEMENT, COMMENT, - UNKNOWN, TEXT, and DECLARATION. - */ + The possible types are: DOCUMENT, ELEMENT, COMMENT, + UNKNOWN, TEXT, and DECLARATION. + */ int Type() const { return type; } /** Return a pointer to the Document this node lives in. - Returns null if not in a document. - */ + Returns null if not in a document. + */ const TiXmlDocument* GetDocument() const; TiXmlDocument* GetDocument() { return const_cast<TiXmlDocument*>((const_cast<const TiXmlNode*>(this))->GetDocument()); @@ -808,35 +808,35 @@ public: } ///< Cast to a more defined type. Will return null if not of the requested type. /** Create an exact duplicate of this node and return it. The memory must be deleted - by the caller. - */ + by the caller. + */ virtual TiXmlNode* Clone() const = 0; /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the - XML tree will be conditionally visited and the host will be called back - via the TiXmlVisitor interface. + XML tree will be conditionally visited and the host will be called back + via the TiXmlVisitor interface. - This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse - the XML for the callbacks, so the performance of TinyXML is unchanged by using this - interface versus any other.) + This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse + the XML for the callbacks, so the performance of TinyXML is unchanged by using this + interface versus any other.) - The interface has been based on ideas from: + The interface has been based on ideas from: - - http://www.saxproject.org/ - - http://c2.com/cgi/wiki?HierarchicalVisitorPattern + - http://www.saxproject.org/ + - http://c2.com/cgi/wiki?HierarchicalVisitorPattern - Which are both good references for "visiting". + Which are both good references for "visiting". - An example of using Accept(): - @verbatim - TiXmlPrinter printer; - tinyxmlDoc.Accept( &printer ); - const char* xmlcstr = printer.CStr(); - @endverbatim - */ + An example of using Accept(): + @verbatim + TiXmlPrinter printer; + tinyxmlDoc.Accept( &printer ); + const char* xmlcstr = printer.CStr(); + @endverbatim + */ virtual bool Accept(TiXmlVisitor* visitor) const = 0; -protected: + protected: TiXmlNode(NodeType _type); // Copy to the allocated object. Shared functionality between Clone, Copy constructor, @@ -862,25 +862,25 @@ protected: TiXmlNode* prev; TiXmlNode* next; -private: - TiXmlNode(const TiXmlNode&); // not implemented. + private: + TiXmlNode(const TiXmlNode&); // not implemented. void operator=(const TiXmlNode& base); // not allowed. }; /** An attribute is a name-value pair. Elements have an arbitrary - number of attributes, each with a unique name. + number of attributes, each with a unique name. - @note The attributes are not TiXmlNodes, since they are not - part of the tinyXML document object model. There are other - suggested ways to look at this problem. - */ + @note The attributes are not TiXmlNodes, since they are not + part of the tinyXML document object model. There are other + suggested ways to look at this problem. +*/ class TiXmlAttribute: public TiXmlBase { friend class TiXmlAttributeSet; -public: + public: /// Construct an empty attribute. - TiXmlAttribute() - : TiXmlBase() { + TiXmlAttribute() + : TiXmlBase() { document = 0; prev = next = 0; } @@ -905,17 +905,17 @@ public: const char* Name() const { return name.c_str(); - } ///< Return the name of this attribute. + } ///< Return the name of this attribute. const char* Value() const { return value.c_str(); - } ///< Return the value of this attribute. + } ///< Return the value of this attribute. #ifdef TIXML_USE_STL const std::string& ValueStr() const { return value; - } ///< Return the value of this attribute. + } ///< Return the value of this attribute. #endif - int IntValue() const; ///< Return the value of this attribute, converted to an integer. - double DoubleValue() const; ///< Return the value of this attribute, converted to a double. + int IntValue() const; ///< Return the value of this attribute, converted to an integer. + double DoubleValue() const; ///< Return the value of this attribute, converted to a double. // Get the tinyxml string representation const TIXML_STRING& NameTStr() const { @@ -923,27 +923,27 @@ public: } /** QueryIntValue examines the value string. It is an alternative to the - IntValue() method with richer error checking. - If the value is an integer, it is stored in 'value' and - the call returns TIXML_SUCCESS. If it is not - an integer, it returns TIXML_WRONG_TYPE. - - A specialized but useful call. Note that for success it returns 0, - which is the opposite of almost all other TinyXml calls. - */ + IntValue() method with richer error checking. + If the value is an integer, it is stored in 'value' and + the call returns TIXML_SUCCESS. If it is not + an integer, it returns TIXML_WRONG_TYPE. + + A specialized but useful call. Note that for success it returns 0, + which is the opposite of almost all other TinyXml calls. + */ int QueryIntValue(int* _value) const; /// QueryDoubleValue examines the value string. See QueryIntValue(). int QueryDoubleValue(double* _value) const; void SetName(const char* _name) { name = _name; - } ///< Set the name of this attribute. + } ///< Set the name of this attribute. void SetValue(const char* _value) { value = _value; - } ///< Set the value. + } ///< Set the value. - void SetIntValue(int _value); ///< Set the value from an integer. - void SetDoubleValue(double _value); ///< Set the value from a double. + void SetIntValue(int _value); ///< Set the value from an integer. + void SetDoubleValue(double _value); ///< Set the value from a double. #ifdef TIXML_USE_STL /// STL std::string form. @@ -978,9 +978,9 @@ public: return name > rhs.name; } - /* Attribute parsing starts: first letter of the name - returns: the next char after the value end quote - */ + /* Attribute parsing starts: first letter of the name + returns: the next char after the value end quote + */ virtual const char* Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding); // Prints this Attribute to a FILE stream. @@ -995,8 +995,8 @@ public: document = doc; } -private: - TiXmlAttribute(const TiXmlAttribute&); // not implemented. + private: + TiXmlAttribute(const TiXmlAttribute&); // not implemented. void operator=(const TiXmlAttribute& base); // not allowed. TiXmlDocument* document; // A pointer back to a document, for error reporting. @@ -1005,20 +1005,20 @@ private: TiXmlAttribute* next; }; -/* A class used to manage a group of attributes. - It is only used internally, both by the ELEMENT and the DECLARATION. +/* A class used to manage a group of attributes. + It is only used internally, both by the ELEMENT and the DECLARATION. - The set can be changed transparent to the Element and Declaration - classes that use it, but NOT transparent to the Attribute - which has to implement a next() and previous() method. Which makes - it a bit problematic and prevents the use of STL. + The set can be changed transparent to the Element and Declaration + classes that use it, but NOT transparent to the Attribute + which has to implement a next() and previous() method. Which makes + it a bit problematic and prevents the use of STL. - This version is implemented with circular lists because: - - I like circular lists - - it demonstrates some independence from the (typical) doubly linked list. - */ + This version is implemented with circular lists because: + - I like circular lists + - it demonstrates some independence from the (typical) doubly linked list. +*/ class TiXmlAttributeSet { -public: + public: TiXmlAttributeSet(); ~TiXmlAttributeSet(); @@ -1050,9 +1050,9 @@ public: #endif -private: - //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element), - //*ME: this class must be also use a hidden/disabled copy-constructor !!! + private: + //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element), + //*ME: this class must be also use a hidden/disabled copy-constructor !!! TiXmlAttributeSet(const TiXmlAttributeSet&); // not allowed void operator=(const TiXmlAttributeSet&); // not allowed (as TiXmlAttribute) @@ -1060,11 +1060,11 @@ private: }; /** The element is a container class. It has a value, the element name, - and can contain other elements, text, comments, and unknowns. - Elements also contain an arbitrary number of attributes. - */ + and can contain other elements, text, comments, and unknowns. + Elements also contain an arbitrary number of attributes. +*/ class TiXmlElement: public TiXmlNode { -public: + public: /// Construct an element. TiXmlElement(const char * in_value); @@ -1080,15 +1080,15 @@ public: virtual ~TiXmlElement(); /** Given an attribute name, Attribute() returns the attribute - with that name, or null if none exists. - */ + with that name, or null if none exists. + */ const TiXmlAttribute* AttributeNode(const char* name) const { return attributeSet.Find(name); } /** Given an attribute name, Attribute() returns the attribute value - with that name, or null if none exists. - */ + with that name, or null if none exists. + */ const char* Attribute(const char* name) const; /** Clear all attribute nodes of this node. @@ -1096,28 +1096,28 @@ public: void ClearAttributes(); /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none exists. - If the attribute exists and can be converted to an integer, - the integer value will be put in the return 'i', if 'i' - is non-null. - */ + for the attribute of that name, or null if none exists. + If the attribute exists and can be converted to an integer, + the integer value will be put in the return 'i', if 'i' + is non-null. + */ const char* Attribute(const char* name, int* i) const; /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none exists. - If the attribute exists and can be converted to an double, - the double value will be put in the return 'd', if 'd' - is non-null. - */ + for the attribute of that name, or null if none exists. + If the attribute exists and can be converted to an double, + the double value will be put in the return 'd', if 'd' + is non-null. + */ const char* Attribute(const char* name, double* d) const; /** QueryIntAttribute examines the attribute - it is an alternative to the - Attribute() method with richer error checking. - If the attribute is an integer, it is stored in 'value' and - the call returns TIXML_SUCCESS. If it is not - an integer, it returns TIXML_WRONG_TYPE. If the attribute - does not exist, then TIXML_NO_ATTRIBUTE is returned. - */ + Attribute() method with richer error checking. + If the attribute is an integer, it is stored in 'value' and + the call returns TIXML_SUCCESS. If it is not + an integer, it returns TIXML_WRONG_TYPE. If the attribute + does not exist, then TIXML_NO_ATTRIBUTE is returned. + */ int QueryIntAttribute(const char* name, int* _value) const; /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). int QueryDoubleAttribute(const char* name, double* _value) const; @@ -1132,11 +1132,11 @@ public: } #ifdef TIXML_USE_STL /** Template form of the attribute query which will try to read the - attribute into the specified type. Very easy, very powerful, but - be careful to make sure to call this with the correct type. + attribute into the specified type. Very easy, very powerful, but + be careful to make sure to call this with the correct type. - @return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE - */ + @return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE + */ template <typename T> int QueryValueAttribute(const std::string& name, T* outValue) const { const TiXmlAttribute* node = attributeSet.Find(name); if (!node) @@ -1151,8 +1151,8 @@ public: #endif /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ + will be created if it does not exist, or changed if it does. + */ void SetAttribute(const char* name, const char * _value); #ifdef TIXML_USE_STL @@ -1169,13 +1169,13 @@ public: #endif /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ + will be created if it does not exist, or changed if it does. + */ void SetAttribute(const char * name, int value); /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ + will be created if it does not exist, or changed if it does. + */ void SetDoubleAttribute(const char * name, double value); /** Deletes an attribute with the given name. @@ -1189,49 +1189,49 @@ public: const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); - } ///< Access the first attribute in this element. + } ///< Access the first attribute in this element. TiXmlAttribute* FirstAttribute() { return attributeSet.First(); } const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); - } ///< Access the last attribute in this element. + } ///< Access the last attribute in this element. TiXmlAttribute* LastAttribute() { return attributeSet.Last(); } /** Convenience function for easy access to the text inside an element. Although easy - and concise, GetText() is limited compared to getting the TiXmlText child - and accessing it directly. - - If the first child of 'this' is a TiXmlText, the GetText() - returns the character string of the Text node, else null is returned. - - This is a convenient method for getting the text of simple contained text: - @verbatim - <foo>This is text</foo> - const char* str = fooElement->GetText(); - @endverbatim - - 'str' will be a pointer to "This is text". - - Note that this function can be misleading. If the element foo was created from - this XML: - @verbatim - <foo><b>This is text</b></foo> - @endverbatim - - then the value of str would be null. The first child node isn't a text node, it is - another element. From this XML: - @verbatim - <foo>This is <b>text</b></foo> - @endverbatim - GetText() will return "This is ". - - WARNING: GetText() accesses a child node - don't become confused with the - similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are - safe type casts on the referenced node. - */ + and concise, GetText() is limited compared to getting the TiXmlText child + and accessing it directly. + + If the first child of 'this' is a TiXmlText, the GetText() + returns the character string of the Text node, else null is returned. + + This is a convenient method for getting the text of simple contained text: + @verbatim + <foo>This is text</foo> + const char* str = fooElement->GetText(); + @endverbatim + + 'str' will be a pointer to "This is text". + + Note that this function can be misleading. If the element foo was created from + this XML: + @verbatim + <foo><b>This is text</b></foo> + @endverbatim + + then the value of str would be null. The first child node isn't a text node, it is + another element. From this XML: + @verbatim + <foo>This is <b>text</b></foo> + @endverbatim + GetText() will return "This is ". + + WARNING: GetText() accesses a child node - don't become confused with the + similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are + safe type casts on the referenced node. + */ const char* GetText() const; /// Creates a new Element and returns it - the returned element is a copy. @@ -1239,9 +1239,9 @@ public: // Print the Element to a FILE stream. virtual void Print(FILE* cfile, int depth) const; - /* Attribtue parsing starts: next char past '<' - returns: next char past '>' - */ + /* Attribtue parsing starts: next char past '<' + returns: next char past '>' + */ virtual const char* Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding); virtual const TiXmlElement* ToElement() const { @@ -1255,7 +1255,7 @@ public: */ virtual bool Accept(TiXmlVisitor* visitor) const; -protected: + protected: void CopyTo(TiXmlElement* target) const; void ClearThis(); // like clear, but initializes 'this' object as well @@ -1264,28 +1264,28 @@ protected: #ifdef TIXML_USE_STL virtual void StreamIn(std::istream * in, TIXML_STRING * tag); #endif - /* [internal use] - Reads the "value" of the element -- another element, or text. - This should terminate with the current end tag. - */ + /* [internal use] + Reads the "value" of the element -- another element, or text. + This should terminate with the current end tag. + */ const char* ReadValue(const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding); -private: + private: TiXmlAttributeSet attributeSet; }; -/** An XML comment. +/** An XML comment. */ class TiXmlComment: public TiXmlNode { -public: + public: /// Constructs an empty comment. - TiXmlComment() - : TiXmlNode(TiXmlNode::COMMENT) { + TiXmlComment() + : TiXmlNode(TiXmlNode::COMMENT) { } /// Construct a comment from text. - TiXmlComment(const char* _value) - : TiXmlNode(TiXmlNode::COMMENT) { + TiXmlComment(const char* _value) + : TiXmlNode(TiXmlNode::COMMENT) { SetValue(_value); } TiXmlComment(const TiXmlComment&); @@ -1299,9 +1299,9 @@ public: // Write this Comment to a FILE stream. virtual void Print(FILE* cfile, int depth) const; - /* Attribtue parsing starts: at the ! of the !-- - returns: next char past '>' - */ + /* Attribtue parsing starts: at the ! of the !-- + returns: next char past '>' + */ virtual const char* Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding); virtual const TiXmlComment* ToComment() const { @@ -1315,33 +1315,33 @@ public: */ virtual bool Accept(TiXmlVisitor* visitor) const; -protected: + protected: void CopyTo(TiXmlComment* target) const; // used to be public #ifdef TIXML_USE_STL virtual void StreamIn(std::istream * in, TIXML_STRING * tag); #endif -// virtual void StreamOut( TIXML_OSTREAM * out ) const; + // virtual void StreamOut( TIXML_OSTREAM * out ) const; -private: + private: }; /** XML text. A text node can have 2 ways to output the next. "normal" output - and CDATA. It will default to the mode it was parsed from the XML file and - you generally want to leave it alone, but you can change the output mode with - SetCDATA() and query it with CDATA(). - */ + and CDATA. It will default to the mode it was parsed from the XML file and + you generally want to leave it alone, but you can change the output mode with + SetCDATA() and query it with CDATA(). +*/ class TiXmlText: public TiXmlNode { friend class TiXmlElement; -public: + public: /** Constructor for text element. By default, it is treated as - normal, encoded text. If you want it be output as a CDATA text - element, set the parameter _cdata to 'true' - */ - TiXmlText(const char * initValue) - : TiXmlNode(TiXmlNode::TEXT) { + normal, encoded text. If you want it be output as a CDATA text + element, set the parameter _cdata to 'true' + */ + TiXmlText(const char * initValue) + : TiXmlNode(TiXmlNode::TEXT) { SetValue(initValue); cdata = false; } @@ -1350,15 +1350,15 @@ public: #ifdef TIXML_USE_STL /// Constructor. - TiXmlText(const std::string& initValue) - : TiXmlNode(TiXmlNode::TEXT) { + TiXmlText(const std::string& initValue) + : TiXmlNode(TiXmlNode::TEXT) { SetValue(initValue); cdata = false; } #endif - TiXmlText(const TiXmlText& copy) - : TiXmlNode(TiXmlNode::TEXT) { + TiXmlText(const TiXmlText& copy) + : TiXmlNode(TiXmlNode::TEXT) { copy.CopyTo(this); } void operator=(const TiXmlText& base) { @@ -1390,7 +1390,7 @@ public: */ virtual bool Accept(TiXmlVisitor* content) const; -protected: + protected: /// [internal use] Creates a new Element and returns it. virtual TiXmlNode* Clone() const; void CopyTo(TiXmlText* target) const; @@ -1401,28 +1401,28 @@ protected: virtual void StreamIn(std::istream * in, TIXML_STRING * tag); #endif -private: - bool cdata; // true if this should be input and output as a CDATA style text element + private: + bool cdata; // true if this should be input and output as a CDATA style text element }; /** In correct XML the declaration is the first entry in the file. - @verbatim - <?xml version="1.0" standalone="yes"?> - @endverbatim - - TinyXml will happily read or write files without a declaration, - however. There are 3 possible attributes to the declaration: - version, encoding, and standalone. - - Note: In this version of the code, the attributes are - handled as special cases, not generic attributes, simply - because there can only be at most 3 and they are always the same. - */ + @verbatim + <?xml version="1.0" standalone="yes"?> + @endverbatim + + TinyXml will happily read or write files without a declaration, + however. There are 3 possible attributes to the declaration: + version, encoding, and standalone. + + Note: In this version of the code, the attributes are + handled as special cases, not generic attributes, simply + because there can only be at most 3 and they are always the same. +*/ class TiXmlDeclaration: public TiXmlNode { -public: + public: /// Construct an empty declaration. - TiXmlDeclaration() - : TiXmlNode(TiXmlNode::DECLARATION) { + TiXmlDeclaration() + : TiXmlNode(TiXmlNode::DECLARATION) { } #ifdef TIXML_USE_STL @@ -1473,35 +1473,35 @@ public: */ virtual bool Accept(TiXmlVisitor* visitor) const; -protected: + protected: void CopyTo(TiXmlDeclaration* target) const; // used to be public #ifdef TIXML_USE_STL virtual void StreamIn(std::istream * in, TIXML_STRING * tag); #endif -private: + private: TIXML_STRING version;TIXML_STRING encoding;TIXML_STRING standalone; }; /** Any tag that tinyXml doesn't recognize is saved as an - unknown. It is a tag of text, but should not be modified. - It will be written back to the XML, unchanged, when the file - is saved. + unknown. It is a tag of text, but should not be modified. + It will be written back to the XML, unchanged, when the file + is saved. - DTD tags get thrown into TiXmlUnknowns. - */ + DTD tags get thrown into TiXmlUnknowns. +*/ class TiXmlUnknown: public TiXmlNode { -public: - TiXmlUnknown() - : TiXmlNode(TiXmlNode::UNKNOWN) { + public: + TiXmlUnknown() + : TiXmlNode(TiXmlNode::UNKNOWN) { } virtual ~TiXmlUnknown() { } - TiXmlUnknown(const TiXmlUnknown& copy) - : TiXmlNode(TiXmlNode::UNKNOWN) { + TiXmlUnknown(const TiXmlUnknown& copy) + : TiXmlNode(TiXmlNode::UNKNOWN) { copy.CopyTo(this); } void operator=(const TiXmlUnknown& copy) { @@ -1526,23 +1526,23 @@ public: */ virtual bool Accept(TiXmlVisitor* content) const; -protected: + protected: void CopyTo(TiXmlUnknown* target) const; #ifdef TIXML_USE_STL virtual void StreamIn(std::istream * in, TIXML_STRING * tag); #endif -private: + private: }; /** Always the top level node. A document binds together all the - XML pieces. It can be saved, loaded, and printed to the screen. - The 'value' of a document node is the xml file name. - */ + XML pieces. It can be saved, loaded, and printed to the screen. + The 'value' of a document node is the xml file name. +*/ class TiXmlDocument: public TiXmlNode { -public: + public: /// Create an empty document, that has no name. TiXmlDocument(); /// Create a document with a name. The name of the document is also the filename of the xml. @@ -1560,9 +1560,9 @@ public: } /** Load a file using the current document value. - Returns true if successful. Will delete any existing - document data before loading. - */ + Returns true if successful. Will delete any existing + document data before loading. + */ bool LoadFile(TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING); /// Save a file using the current document value. Returns true if successful. bool SaveFile() const; @@ -1571,39 +1571,39 @@ public: /// Save a file using the given filename. Returns true if successful. bool SaveFile(const char * filename) const; /** Load a file using the given FILE*. Returns true if successful. Note that this method - doesn't stream - the entire object pointed at by the FILE* - will be interpreted as an XML file. TinyXML doesn't stream in XML from the current - file location. Streaming may be added in the future. - */ + doesn't stream - the entire object pointed at by the FILE* + will be interpreted as an XML file. TinyXML doesn't stream in XML from the current + file location. Streaming may be added in the future. + */ bool LoadFile(FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING); /// Save a file using the given FILE*. Returns true if successful. bool SaveFile(FILE*) const; #ifdef TIXML_USE_STL - bool LoadFile(const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING) ///< STL std::string version. - { -// StringToBuffer f( filename ); -// return ( f.buffer && LoadFile( f.buffer, encoding )); + bool LoadFile(const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING) ///< STL std::string version. + { + // StringToBuffer f( filename ); + // return ( f.buffer && LoadFile( f.buffer, encoding )); return LoadFile(filename.c_str(), encoding); } - bool SaveFile(const std::string& filename) const ///< STL std::string version. - { -// StringToBuffer f( filename ); -// return ( f.buffer && SaveFile( f.buffer )); + bool SaveFile(const std::string& filename) const ///< STL std::string version. + { + // StringToBuffer f( filename ); + // return ( f.buffer && SaveFile( f.buffer )); return SaveFile(filename.c_str()); } #endif /** Parse the given null terminated block of xml data. Passing in an encoding to this - method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml - to use that encoding, regardless of what TinyXml might otherwise try to detect. - */ + method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml + to use that encoding, regardless of what TinyXml might otherwise try to detect. + */ virtual const char* Parse(const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING); /** Get the root element -- the only top level element -- of the document. - In well formed XML, there should only be one. TinyXml is tolerant of - multiple elements at the document level. - */ + In well formed XML, there should only be one. TinyXml is tolerant of + multiple elements at the document level. + */ const TiXmlElement* RootElement() const { return FirstChildElement(); } @@ -1612,10 +1612,10 @@ public: } /** If an error occurs, Error will be set to true. Also, - - The ErrorId() will contain the integer identifier of the error (not generally useful) - - The ErrorDesc() method will return the name of the error. (very useful) - - The ErrorRow() and ErrorCol() will return the location of the error (if known) - */ + - The ErrorId() will contain the integer identifier of the error (not generally useful) + - The ErrorDesc() method will return the name of the error. (very useful) + - The ErrorRow() and ErrorCol() will return the location of the error (if known) + */ bool Error() const { return error; } @@ -1626,19 +1626,19 @@ public: } /** Generally, you probably want the error string ( ErrorDesc() ). But if you - prefer the ErrorId, this function will fetch it. - */ + prefer the ErrorId, this function will fetch it. + */ int ErrorId() const { return errorId; } /** Returns the location (if known) of the error. The first column is column 1, - and the first row is row 1. A value of 0 means the row and column wasn't applicable - (memory errors, for example, have no row/column) or the parser lost the error. (An - error in the error reporting, in that case.) + and the first row is row 1. A value of 0 means the row and column wasn't applicable + (memory errors, for example, have no row/column) or the parser lost the error. (An + error in the error reporting, in that case.) - @sa SetTabSize, Row, Column - */ + @sa SetTabSize, Row, Column + */ int ErrorRow() const { return errorLocation.row + 1; } @@ -1647,29 +1647,29 @@ public: } ///< The column where the error occured. See ErrorRow() /** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) - to report the correct values for row and column. It does not change the output - or input in any way. + to report the correct values for row and column. It does not change the output + or input in any way. - By calling this method, with a tab size - greater than 0, the row and column of each node and attribute is stored - when the file is loaded. Very useful for tracking the DOM back in to - the source file. + By calling this method, with a tab size + greater than 0, the row and column of each node and attribute is stored + when the file is loaded. Very useful for tracking the DOM back in to + the source file. - The tab size is required for calculating the location of nodes. If not - set, the default of 4 is used. The tabsize is set per document. Setting - the tabsize to 0 disables row/column tracking. + The tab size is required for calculating the location of nodes. If not + set, the default of 4 is used. The tabsize is set per document. Setting + the tabsize to 0 disables row/column tracking. - Note that row and column tracking is not supported when using operator>>. + Note that row and column tracking is not supported when using operator>>. - The tab size needs to be enabled before the parse or load. Correct usage: - @verbatim - TiXmlDocument doc; - doc.SetTabSize( 8 ); - doc.Load( "myfile.xml" ); - @endverbatim + The tab size needs to be enabled before the parse or load. Correct usage: + @verbatim + TiXmlDocument doc; + doc.SetTabSize( 8 ); + doc.Load( "myfile.xml" ); + @endverbatim - @sa Row, Column - */ + @sa Row, Column + */ void SetTabSize(int _tabsize) { tabsize = _tabsize; } @@ -1679,8 +1679,8 @@ public: } /** If you have handled the error, it can be reset with this call. The error - state is automatically cleared if you Parse a new XML block. - */ + state is automatically cleared if you Parse a new XML block. + */ void ClearError() { error = false; errorId = 0; @@ -1695,9 +1695,9 @@ public: } /* Write the document to a string using formatted printing ("pretty print"). This - will allocate a character array (new char[]) and return it as a pointer. The - calling code pust call delete[] on the return char* to avoid a memory leak. - */ + will allocate a character array (new char[]) and return it as a pointer. The + calling code pust call delete[] on the return char* to avoid a memory leak. + */ //char* PrintToMemory() const; /// Print this Document to a FILE stream. virtual void Print(FILE* cfile, int depth = 0) const; @@ -1715,105 +1715,105 @@ public: */ virtual bool Accept(TiXmlVisitor* content) const; -protected: + protected: // [internal use] virtual TiXmlNode* Clone() const; #ifdef TIXML_USE_STL virtual void StreamIn(std::istream * in, TIXML_STRING * tag); #endif -private: + private: void CopyTo(TiXmlDocument* target) const; bool error; int errorId;TIXML_STRING errorDesc; int tabsize; TiXmlCursor errorLocation; - bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write. + bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write. }; /** - A TiXmlHandle is a class that wraps a node pointer with null checks; this is - an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml - DOM structure. It is a separate utility class. - - Take an example: - @verbatim - <Document> - <Element attributeA = "valueA"> - <Child attributeB = "value1" /> - <Child attributeB = "value2" /> - </Element> - <Document> - @endverbatim - - Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very - easy to write a *lot* of code that looks like: - - @verbatim - TiXmlElement* root = document.FirstChildElement( "Document" ); - if ( root ) - { - TiXmlElement* element = root->FirstChildElement( "Element" ); - if ( element ) - { - TiXmlElement* child = element->FirstChildElement( "Child" ); - if ( child ) - { - TiXmlElement* child2 = child->NextSiblingElement( "Child" ); - if ( child2 ) - { - // Finally do something useful. - @endverbatim - - And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity - of such code. A TiXmlHandle checks for null pointers so it is perfectly safe - and correct to use: - - @verbatim - TiXmlHandle docHandle( &document ); - TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement(); - if ( child2 ) - { - // do something useful - @endverbatim - - Which is MUCH more concise and useful. - - It is also safe to copy handles - internally they are nothing more than node pointers. - @verbatim - TiXmlHandle handleCopy = handle; - @endverbatim - - What they should not be used for is iteration: - - @verbatim - int i=0; - while ( true ) - { - TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement(); - if ( !child ) - break; - // do something - ++i; - } - @endverbatim - - It seems reasonable, but it is in fact two embedded while loops. The Child method is - a linear walk to find the element, so this code would iterate much more than it needs - to. Instead, prefer: - - @verbatim - TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement(); - - for( child; child; child=child->NextSiblingElement() ) - { - // do something - } - @endverbatim - */ + A TiXmlHandle is a class that wraps a node pointer with null checks; this is + an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml + DOM structure. It is a separate utility class. + + Take an example: + @verbatim + <Document> + <Element attributeA = "valueA"> + <Child attributeB = "value1" /> + <Child attributeB = "value2" /> + </Element> + <Document> + @endverbatim + + Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very + easy to write a *lot* of code that looks like: + + @verbatim + TiXmlElement* root = document.FirstChildElement( "Document" ); + if ( root ) + { + TiXmlElement* element = root->FirstChildElement( "Element" ); + if ( element ) + { + TiXmlElement* child = element->FirstChildElement( "Child" ); + if ( child ) + { + TiXmlElement* child2 = child->NextSiblingElement( "Child" ); + if ( child2 ) + { + // Finally do something useful. + @endverbatim + + And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity + of such code. A TiXmlHandle checks for null pointers so it is perfectly safe + and correct to use: + + @verbatim + TiXmlHandle docHandle( &document ); + TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement(); + if ( child2 ) + { + // do something useful + @endverbatim + + Which is MUCH more concise and useful. + + It is also safe to copy handles - internally they are nothing more than node pointers. + @verbatim + TiXmlHandle handleCopy = handle; + @endverbatim + + What they should not be used for is iteration: + + @verbatim + int i=0; + while ( true ) + { + TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement(); + if ( !child ) + break; + // do something + ++i; + } + @endverbatim + + It seems reasonable, but it is in fact two embedded while loops. The Child method is + a linear walk to find the element, so this code would iterate much more than it needs + to. Instead, prefer: + + @verbatim + TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement(); + + for( child; child; child=child->NextSiblingElement() ) + { + // do something + } + @endverbatim +*/ class TiXmlHandle { -public: + public: /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. TiXmlHandle(TiXmlNode* _node) { this->node = _node; @@ -1837,22 +1837,22 @@ public: TiXmlHandle FirstChildElement(const char * value) const; /** Return a handle to the "index" child with the given name. - The first child is 0, the second 1, etc. - */ + The first child is 0, the second 1, etc. + */ TiXmlHandle Child(const char* value, int index) const; /** Return a handle to the "index" child. - The first child is 0, the second 1, etc. - */ + The first child is 0, the second 1, etc. + */ TiXmlHandle Child(int index) const; /** Return a handle to the "index" child element with the given name. - The first child element is 0, the second 1, etc. Note that only TiXmlElements - are indexed: other types are not counted. - */ + The first child element is 0, the second 1, etc. Note that only TiXmlElements + are indexed: other types are not counted. + */ TiXmlHandle ChildElement(const char* value, int index) const; /** Return a handle to the "index" child element. - The first child element is 0, the second 1, etc. Note that only TiXmlElements - are indexed: other types are not counted. - */ + The first child element is 0, the second 1, etc. Note that only TiXmlElements + are indexed: other types are not counted. + */ TiXmlHandle ChildElement(int index) const; #ifdef TIXML_USE_STL @@ -1881,7 +1881,7 @@ public: TiXmlElement* ToElement() const { return ((node && node->ToElement()) ? node->ToElement() : 0); } - /** Return the handle as a TiXmlText. This may return null. + /** Return the handle as a TiXmlText. This may return null. */ TiXmlText* ToText() const { return ((node && node->ToText()) ? node->ToText() : 0); @@ -1893,57 +1893,57 @@ public: } /** @deprecated use ToNode. - Return the handle as a TiXmlNode. This may return null. - */ + Return the handle as a TiXmlNode. This may return null. + */ TiXmlNode* Node() const { return ToNode(); } /** @deprecated use ToElement. - Return the handle as a TiXmlElement. This may return null. - */ + Return the handle as a TiXmlElement. This may return null. + */ TiXmlElement* Element() const { return ToElement(); } - /** @deprecated use ToText() - Return the handle as a TiXmlText. This may return null. - */ + /** @deprecated use ToText() + Return the handle as a TiXmlText. This may return null. + */ TiXmlText* Text() const { return ToText(); } /** @deprecated use ToUnknown() - Return the handle as a TiXmlUnknown. This may return null. - */ + Return the handle as a TiXmlUnknown. This may return null. + */ TiXmlUnknown* Unknown() const { return ToUnknown(); } -private: + private: TiXmlNode* node; }; /** Print to memory functionality. The TiXmlPrinter is useful when you need to: - -# Print to memory (especially in non-STL mode) - -# Control formatting (line endings, etc.) + -# Print to memory (especially in non-STL mode) + -# Control formatting (line endings, etc.) - When constructed, the TiXmlPrinter is in its default "pretty printing" mode. - Before calling Accept() you can call methods to control the printing - of the XML document. After TiXmlNode::Accept() is called, the printed document can - be accessed via the CStr(), Str(), and Size() methods. + When constructed, the TiXmlPrinter is in its default "pretty printing" mode. + Before calling Accept() you can call methods to control the printing + of the XML document. After TiXmlNode::Accept() is called, the printed document can + be accessed via the CStr(), Str(), and Size() methods. - TiXmlPrinter uses the Visitor API. - @verbatim - TiXmlPrinter printer; - printer.SetIndent( "\t" ); + TiXmlPrinter uses the Visitor API. + @verbatim + TiXmlPrinter printer; + printer.SetIndent( "\t" ); - doc.Accept( &printer ); - fprintf( stdout, "%s", printer.CStr() ); - @endverbatim - */ + doc.Accept( &printer ); + fprintf( stdout, "%s", printer.CStr() ); + @endverbatim +*/ class TiXmlPrinter: public TiXmlVisitor { -public: - TiXmlPrinter() - : depth(0), simpleTextPrint(false), buffer(), indent(" "), lineBreak("\n") { + public: + TiXmlPrinter() + : depth(0), simpleTextPrint(false), buffer(), indent(" "), lineBreak("\n") { } virtual bool VisitEnter(const TiXmlDocument& doc); @@ -1958,8 +1958,8 @@ public: virtual bool Visit(const TiXmlUnknown& unknown); /** Set the indent characters for printing. By default 4 spaces - but tab (\t) is also useful, or null/empty string for no indentation. - */ + but tab (\t) is also useful, or null/empty string for no indentation. + */ void SetIndent(const char* _indent) { indent = _indent ? _indent : ""; } @@ -1968,9 +1968,9 @@ public: return indent.c_str(); } /** Set the line breaking string. By default set to newline (\n). - Some operating systems prefer other characters, or can be - set to the null/empty string for no indenation. - */ + Some operating systems prefer other characters, or can be + set to the null/empty string for no indenation. + */ void SetLineBreak(const char* _lineBreak) { lineBreak = _lineBreak ? _lineBreak : ""; } @@ -1980,8 +1980,8 @@ public: } /** Switch over to "stream printing" which is the most dense formatting without - linebreaks. Common when the XML is needed for network transmission. - */ + linebreaks. Common when the XML is needed for network transmission. + */ void SetStreamPrinting() { indent = ""; lineBreak = ""; @@ -2002,7 +2002,7 @@ public: } #endif -private: + private: void DoIndent() { for (int i = 0; i < depth; ++i) buffer += indent; diff --git a/DDCore/src/Alignment.cpp b/DDCore/src/Alignment.cpp index 70105d90f2342274544d7fdaa181e37989f8e674..5c6f5a6e025a3eef2af21899a3cfe4f217ec5687 100644 --- a/DDCore/src/Alignment.cpp +++ b/DDCore/src/Alignment.cpp @@ -32,24 +32,24 @@ namespace { transform->MultiplyLeft(mm); // orig * delta n->Align(transform, 0, check, overlap); /* - printout(INFO,"Alignment","OLD matrix...."); - mm->Print(); - printout(INFO,"Alignment","Apply new relative matrix mother to daughter:"); - transform->Print(); - transform->MultiplyLeft(mm); // orig * delta - printout(INFO,"Alignment","With deltas...."); - transform->Print(); - n->Align(transform, 0, check, overlap); - printout(INFO,"Alignment","NEW matrix...."); - n->GetNode()->GetMatrix()->Print(); + printout(INFO,"Alignment","OLD matrix...."); + mm->Print(); + printout(INFO,"Alignment","Apply new relative matrix mother to daughter:"); + transform->Print(); + transform->MultiplyLeft(mm); // orig * delta + printout(INFO,"Alignment","With deltas...."); + transform->Print(); + n->Align(transform, 0, check, overlap); + printout(INFO,"Alignment","NEW matrix...."); + n->GetNode()->GetMatrix()->Print(); */ /* */ printout(INFO,"Alignment","NEW matrix...."); n->GetNode()->GetMatrix()->Print(); Position local, global = a.toGlobal(local); - cout << "Local:" << local << " Global: " << global - << " and back:" << a.globalToLocal(global) << endl; + cout << "Local:" << local << " Global: " << global + << " and back:" << a.globalToLocal(global) << endl; return 1; } @@ -105,7 +105,7 @@ PlacedVolume Alignment::nodePlacement(int level) const { PlacedVolume pv = PlacedVolume(ptr()->GetNode(level)); if ( pv.isValid() ) return pv; throw runtime_error("DD4hep: The object chain of "+string(placement().name())+ - " is too short. [Invalid index]"); + " is too short. [Invalid index]"); } /// Access the placement of the mother of this node @@ -118,7 +118,7 @@ PlacedVolume Alignment::motherPlacement(int level_up) const { throw runtime_error("DD4hep: This object "+string(placement().name())+" has not enough mothers. [Invalid index]"); } -/// Access the currently applied alignment/placement matrix +/// Access the currently applied alignment/placement matrix Transform3D Alignment::toGlobal(int level) const { CheckHandle verify_handle(*this); return _transform(ptr()->GetMatrix(level)); @@ -142,13 +142,13 @@ Position Alignment::globalToLocal(const Position& globalPoint, int level) const return result; } -/// Access the currently applied alignment/placement matrix +/// Access the currently applied alignment/placement matrix Transform3D Alignment::toMother(int level) const { CheckHandle verify_handle(*this); return _transform(ptr()->GetNode(level)->GetMatrix()); } -/// Access the currently applied alignment/placement matrix +/// Access the currently applied alignment/placement matrix Transform3D Alignment::nominal() const { CheckHandle verify_handle(*this); return _transform(ptr()->GetOriginalMatrix()); diff --git a/DDCore/src/BasicGrammar.cpp b/DDCore/src/BasicGrammar.cpp index 1ba3a9cec173b421f1c2ab3f343d651637f693dc..a9fd7ef55cb5d99908d9d6d911160ee4cfded049 100644 --- a/DDCore/src/BasicGrammar.cpp +++ b/DDCore/src/BasicGrammar.cpp @@ -27,7 +27,7 @@ DD4hep::BasicGrammar::~BasicGrammar() { void DD4hep::BasicGrammar::invalidConversion(const std::string& value, const std::type_info& to) { std::string to_name = typeName(to); throw unrelated_value_error(to, - "The Property data conversion of '" + value + "' to type " + to_name + " is not defined."); + "The Property data conversion of '" + value + "' to type " + to_name + " is not defined."); } /// Error callback on invalid conversion @@ -35,5 +35,5 @@ void DD4hep::BasicGrammar::invalidConversion(const std::type_info& from, const s std::string to_name = typeName(to); std::string from_name = typeName(from); throw unrelated_type_error(from, to, - "The Property data conversion from type " + from_name + " to " + to_name + " is not implemented."); + "The Property data conversion from type " + from_name + " to " + to_name + " is not implemented."); } diff --git a/DDCore/src/BasicGrammarTypes.cpp b/DDCore/src/BasicGrammarTypes.cpp index 2837f85f49cc30e24dbf73e4dccf0c95d020c318..a43e5f492623ad70cba415f85c8698063e5a9add 100644 --- a/DDCore/src/BasicGrammarTypes.cpp +++ b/DDCore/src/BasicGrammarTypes.cpp @@ -12,24 +12,24 @@ DD4HEP_DEFINE_PARSER_GRAMMAR_U_CONT(char) DD4HEP_DEFINE_PARSER_GRAMMAR_U_CONT(short) -DD4HEP_DEFINE_PARSER_GRAMMAR_U_CONT(int) -DD4HEP_DEFINE_PARSER_GRAMMAR_U_CONT(long) -DD4HEP_DEFINE_PARSER_GRAMMAR_U_CONT(long long) + DD4HEP_DEFINE_PARSER_GRAMMAR_U_CONT(int) + DD4HEP_DEFINE_PARSER_GRAMMAR_U_CONT(long) + DD4HEP_DEFINE_PARSER_GRAMMAR_U_CONT(long long) -DD4HEP_DEFINE_PARSER_GRAMMAR_CONT(bool,eval_item) -DD4HEP_DEFINE_PARSER_GRAMMAR_CONT(float,eval_item) -DD4HEP_DEFINE_PARSER_GRAMMAR_CONT(double,eval_item) + DD4HEP_DEFINE_PARSER_GRAMMAR_CONT(bool,eval_item) + DD4HEP_DEFINE_PARSER_GRAMMAR_CONT(float,eval_item) + DD4HEP_DEFINE_PARSER_GRAMMAR_CONT(double,eval_item) -DD4HEP_DEFINE_PARSER_GRAMMAR_TYPE(std::string) -DD4HEP_DEFINE_PARSER_GRAMMAR_TYPE(std::vector<std::string>) -DD4HEP_DEFINE_PARSER_GRAMMAR_TYPE(std::list<std::string>) -DD4HEP_DEFINE_PARSER_GRAMMAR_TYPE(std::set<std::string>) + DD4HEP_DEFINE_PARSER_GRAMMAR_TYPE(std::string) + DD4HEP_DEFINE_PARSER_GRAMMAR_TYPE(std::vector<std::string>) + DD4HEP_DEFINE_PARSER_GRAMMAR_TYPE(std::list<std::string>) + DD4HEP_DEFINE_PARSER_GRAMMAR_TYPE(std::set<std::string>) // ROOT::Math Object instances -typedef std::map<std::string, int> map_string_int; + typedef std::map<std::string, int> map_string_int; DD4HEP_DEFINE_PARSER_GRAMMAR(map_string_int,eval_obj) -namespace ROOT { +namespace ROOT { namespace Math { static bool operator<(const XYZPoint& a, const XYZPoint& b) { if ( a.X() < b.X() ) return true; diff --git a/DDCore/src/Conditions.cpp b/DDCore/src/Conditions.cpp index ed5f6e42b408559566206494b291b90db532eaa6..169805556eeefda05efcef5cc56c1810d77d62c4 100644 --- a/DDCore/src/Conditions.cpp +++ b/DDCore/src/Conditions.cpp @@ -150,7 +150,7 @@ Condition& Condition::rebind() { o->data.fromString(o->value); o->iov.fromString(o->validity); printout(INFO,"Condition","+++ condition:%s : %s rebinding value:%s", - detector().path().c_str(), name().c_str(), o->value.c_str()); + detector().path().c_str(), name().c_str(), o->value.c_str()); return *this; } @@ -195,9 +195,9 @@ int Conditions::set(Entry* cond) { o = data<Object>(); Entries::iterator i = o->entries.find(cond->name); if ( i != o->entries.end() ) { - (*i).second.replace(cond); - c = (*i).second; - status = 2; + (*i).second.replace(cond); + c = (*i).second; + status = 2; } } else { @@ -210,8 +210,8 @@ int Conditions::set(Entry* cond) { o->entries.insert(make_pair(cond->name,c)); } printout(INFO,"Conditions","+++ %s condition:%s : %s value:%s", - (status==1) ? "Added NEW" : "Replaced existing", - c.detector().path().c_str(), c.name().c_str(), c->value.c_str()); + (status==1) ? "Added NEW" : "Replaced existing", + c.detector().path().c_str(), c.name().c_str(), c->value.c_str()); delete cond; } return status; diff --git a/DDCore/src/ConditionsInterna.cpp b/DDCore/src/ConditionsInterna.cpp index 77e44c992e55d7425f59f4197b00c5fd0a98a552..a5cea74f6c5fbf0f32bbe0ee72a987750c5064a3 100644 --- a/DDCore/src/ConditionsInterna.cpp +++ b/DDCore/src/ConditionsInterna.cpp @@ -86,8 +86,8 @@ void BlockData::bind(const BasicGrammar* g, void (*ctor)(void*,const void*), voi grammar = g; destruct = dtor; copy = ctor; - (len > sizeof(data)) - ? (pointer=::operator new(len),type=ALLOC_DATA) + (len > sizeof(data)) + ? (pointer=::operator new(len),type=ALLOC_DATA) : (pointer=data,type=PLAIN_DATA); return; } @@ -103,7 +103,7 @@ void BlockData::assign(const void* ptr, const type_info& typ) { throw runtime_error("Conditions data block is unbound. Cannot copy data."); } else if ( grammar->type() != typ ) { - throw runtime_error("bad binding"); + throw runtime_error("bad binding"); } (*copy)(pointer,ptr); } @@ -133,8 +133,8 @@ ConditionObject& ConditionObject::move(ConditionObject& c) { } /// Initializing constructor -Entry::Entry(const DetElement& det, const string& nam, - const string& typ, const string& valid) +Entry::Entry(const DetElement& det, const string& nam, + const string& typ, const string& valid) : NamedObject(nam), detector(det), type(typ), value(), validity(valid) { InstanceCount::increment(this); diff --git a/DDCore/src/ConditonsTypes.cpp b/DDCore/src/ConditonsTypes.cpp index eb77f0435e89bbf53c4ce82600c29c458c5e06d2..21462e0116d7163ca21ffaf388b0680c7ee87332 100644 --- a/DDCore/src/ConditonsTypes.cpp +++ b/DDCore/src/ConditonsTypes.cpp @@ -23,22 +23,22 @@ DD4HEP_DEFINE_CONDITIONS_U_CONT(char) DD4HEP_DEFINE_CONDITIONS_U_CONT(short) -DD4HEP_DEFINE_CONDITIONS_U_CONT(int) -DD4HEP_DEFINE_CONDITIONS_U_CONT(long) -DD4HEP_DEFINE_CONDITIONS_U_CONT(long long) + DD4HEP_DEFINE_CONDITIONS_U_CONT(int) + DD4HEP_DEFINE_CONDITIONS_U_CONT(long) + DD4HEP_DEFINE_CONDITIONS_U_CONT(long long) -DD4HEP_DEFINE_CONDITIONS_CONT(bool) -DD4HEP_DEFINE_CONDITIONS_CONT(float) -DD4HEP_DEFINE_CONDITIONS_CONT(double) + DD4HEP_DEFINE_CONDITIONS_CONT(bool) + DD4HEP_DEFINE_CONDITIONS_CONT(float) + DD4HEP_DEFINE_CONDITIONS_CONT(double) -DD4HEP_DEFINE_CONDITIONS_TYPE(std::string) -DD4HEP_DEFINE_CONDITIONS_TYPE(std::vector<std::string>) -DD4HEP_DEFINE_CONDITIONS_TYPE(std::list<std::string>) -DD4HEP_DEFINE_CONDITIONS_TYPE(std::set<std::string>) + DD4HEP_DEFINE_CONDITIONS_TYPE(std::string) + DD4HEP_DEFINE_CONDITIONS_TYPE(std::vector<std::string>) + DD4HEP_DEFINE_CONDITIONS_TYPE(std::list<std::string>) + DD4HEP_DEFINE_CONDITIONS_TYPE(std::set<std::string>) // ROOT::Math Object instances -typedef std::map<std::string, int> map_string_int; + typedef std::map<std::string, int> map_string_int; DD4HEP_DEFINE_CONDITIONS_TYPE(map_string_int) DD4HEP_DEFINE_CONDITIONS_TYPE(ROOT::Math::XYZPoint) -DD4HEP_DEFINE_CONDITIONS_TYPE(ROOT::Math::XYZVector) -DD4HEP_DEFINE_CONDITIONS_TYPE(ROOT::Math::PxPyPzEVector) + DD4HEP_DEFINE_CONDITIONS_TYPE(ROOT::Math::XYZVector) + DD4HEP_DEFINE_CONDITIONS_TYPE(ROOT::Math::PxPyPzEVector) diff --git a/DDCore/src/DD4hepRootPersistency.cpp b/DDCore/src/DD4hepRootPersistency.cpp index e3c684c82ba7b0a636046971ec819b73523fe1f0..2f3cdd2f32b3d267e384d04dfa8b64d1f6365392 100644 --- a/DDCore/src/DD4hepRootPersistency.cpp +++ b/DDCore/src/DD4hepRootPersistency.cpp @@ -27,8 +27,8 @@ int DD4hepRootPersistency::save(DD4hep::Geometry::LCDD& lcdd, const char* fname, int nBytes = persist->Write(instance); f->Close(); DD4hep::printout(DD4hep::ALWAYS,"DD4hepRootPersistency", - "+++ Wrote %d Bytes of geometry data '%s' to '%s'.", - nBytes, instance, fname); + "+++ Wrote %d Bytes of geometry data '%s' to '%s'.", + nBytes, instance, fname); delete f; delete persist; return nBytes; @@ -49,8 +49,8 @@ int DD4hepRootPersistency::load(DD4hep::Geometry::LCDD& lcdd, const char* fname, return 1; } DD4hep::printout(DD4hep::ERROR,"DD4hepRootPersistency", - "+++ Cannot Cannot load instance '%s' from file '%s'.", - instance, fname); + "+++ Cannot Cannot load instance '%s' from file '%s'.", + instance, fname); f->ls(); delete f; return 0; diff --git a/DDCore/src/Detector.cpp b/DDCore/src/Detector.cpp index bcf873abf98070f27413a3af424faa650a8e7ae6..c58fef96505859995f17e72da786fc381f6f6290 100644 --- a/DDCore/src/Detector.cpp +++ b/DDCore/src/Detector.cpp @@ -121,7 +121,7 @@ Alignment DetElement::surveyAlignment() const { return access()->survey; } -/// Access to the conditions information +/// Access to the conditions information Conditions DetElement::conditions() const { return access()->conditions; } @@ -231,7 +231,7 @@ DetElement& DetElement::setLimitSet(const LCDD& lcdd, const string& name, const } DetElement& DetElement::setAttributes(const LCDD& lcdd, const Volume& volume, const string& region, const string& limits, - const string& vis) { + const string& vis) { return setRegion(lcdd, region, volume).setLimitSet(lcdd, limits, volume).setVisAttributes(lcdd, vis, volume); } @@ -318,11 +318,11 @@ bool DetElement::referenceToLocal(const Position& global, Position& local) const /// Constructor SensitiveDetector::SensitiveDetector(const string& name, const string& type) { /* - <calorimeter ecut="0" eunit="MeV" hits_collection="EcalEndcapHits" name="EcalEndcap" verbose="0"> - <global_grid_xy grid_size_x="3.5" grid_size_y="3.5"/> - <idspecref ref="EcalEndcapHits"/> - </calorimeter> - */ + <calorimeter ecut="0" eunit="MeV" hits_collection="EcalEndcapHits" name="EcalEndcap" verbose="0"> + <global_grid_xy grid_size_x="3.5" grid_size_y="3.5"/> + <idspecref ref="EcalEndcapHits"/> + </calorimeter> + */ assign(new Object(name), name, type); object<Object>().ecut = 0e0; object<Object>().verbose = 0; diff --git a/DDCore/src/DetectorInterna.cpp b/DDCore/src/DetectorInterna.cpp index f805f5c7e2857aed4f43066105956c846c1a8ec2..8ae41b54dc753126517729af0c9020c1d3fd3fd3 100644 --- a/DDCore/src/DetectorInterna.cpp +++ b/DDCore/src/DetectorInterna.cpp @@ -29,7 +29,7 @@ DD4HEP_INSTANTIATE_HANDLE_NAMED(SensitiveDetectorObject); /// Default constructor SensitiveDetectorObject::SensitiveDetectorObject() - : NamedObject(), ObjectExtensions(typeid(SensitiveDetectorObject)), magic(magic_word()), + : NamedObject(), ObjectExtensions(typeid(SensitiveDetectorObject)), magic(magic_word()), verbose(0), combineHits(0), ecut(0.0), readout(), region(), limits(), hitsCollection() { printout(VERBOSE,"SensitiveDetectorObject","+++ Created new anonymous SensitiveDetectorObject()"); InstanceCount::increment(this); @@ -37,7 +37,7 @@ SensitiveDetectorObject::SensitiveDetectorObject() /// Initializing constructor SensitiveDetectorObject::SensitiveDetectorObject(const std::string& nam) - : NamedObject(), ObjectExtensions(typeid(SensitiveDetectorObject)), magic(magic_word()), + : NamedObject(), ObjectExtensions(typeid(SensitiveDetectorObject)), magic(magic_word()), verbose(0), combineHits(0), ecut(0.0), readout(), region(), limits(), hitsCollection() { SetName(nam.c_str()); printout(VERBOSE,"SensitiveDetectorObject","+++ Created new SensitiveDetectorObject('%s')",nam.c_str()); @@ -55,10 +55,10 @@ SensitiveDetectorObject::~SensitiveDetectorObject() { /// Default constructor DetElementObject::DetElementObject() - : NamedObject(), ObjectExtensions(typeid(DetElementObject)), magic(magic_word()), + : NamedObject(), ObjectExtensions(typeid(DetElementObject)), magic(magic_word()), flag(0), id(0), combineHits(0), path(), placementPath(), idealPlace(), placement(), volumeID(0), parent(), reference(), children(), - alignment(), volume_alignments(), conditions(), + alignment(), volume_alignments(), conditions(), worldTrafo(), parentTrafo(), referenceTrafo(0) { printout(VERBOSE,"DetElementObject","+++ Created new anonymous DetElementObject()"); InstanceCount::increment(this); @@ -66,10 +66,10 @@ DetElementObject::DetElementObject() /// Initializing constructor DetElementObject::DetElementObject(const std::string& nam, int ident) - : NamedObject(), ObjectExtensions(typeid(DetElementObject)), magic(magic_word()), + : NamedObject(), ObjectExtensions(typeid(DetElementObject)), magic(magic_word()), flag(0), id(ident), combineHits(0), path(), placementPath(), idealPlace(), placement(), volumeID(0), parent(), reference(), children(), - alignment(), volume_alignments(), conditions(), + alignment(), volume_alignments(), conditions(), worldTrafo(), parentTrafo(), referenceTrafo(0) { SetName(nam.c_str()); printout(VERBOSE,"DetElementObject","+++ Created new DetElementObject('%s', %d)",nam.c_str(),id); @@ -118,8 +118,8 @@ DetElementObject* DetElementObject::clone(int new_id, int flag) const { child._data().parent = obj; } else { - throw runtime_error("DD4hep: DetElement::copy: Element " + string(child.name()) + - " is already present [Double-Insert]"); + throw runtime_error("DD4hep: DetElement::copy: Element " + string(child.name()) + + " is already present [Double-Insert]"); } } return obj; @@ -166,8 +166,8 @@ const TGeoHMatrix& DetElementObject::referenceTransformation() { DetectorTools::placementTrafo(nodes,false,referenceTrafo); } else { - throw runtime_error("DD4hep: referenceTransformation: No path from " + string(self.name()) + - " to reference element " + string(ref.name()) + " present!"); + throw runtime_error("DD4hep: referenceTransformation: No path from " + string(self.name()) + + " to reference element " + string(ref.name()) + " present!"); } } return *referenceTrafo; @@ -190,9 +190,9 @@ void DetElementObject::revalidate(TGeoHMatrix* parent_world_trafo) { } //print = (idealPlace.ptr() != node.ptr()); printout((idealPlace.ptr() != node.ptr()) ? INFO : DEBUG, - "DetElement","+++ Invalidate chache of %s -> %s Placement:%p --> %p %s", - det.path().c_str(), DetectorTools::placementPath(par_path).c_str(), - placement.ptr(), node.ptr(), (placement.ptr() == node.ptr()) ? "" : "[UPDATE]"); + "DetElement","+++ Invalidate chache of %s -> %s Placement:%p --> %p %s", + det.path().c_str(), DetectorTools::placementPath(par_path).c_str(), + placement.ptr(), node.ptr(), (placement.ptr() == node.ptr()) ? "" : "[UPDATE]"); placement = node; @@ -244,7 +244,7 @@ void DetElementObject::update(unsigned int tags, void* param) { if ( (tags&DetElement::PLACEMENT_CHANGED)==DetElement::PLACEMENT_CHANGED && (tags&DetElement::PLACEMENT_HIGHEST)==DetElement::PLACEMENT_HIGHEST ) { printout(INFO,"DetElement","+++ Need to update chaches and child caches of %s", - det.path().c_str()); + det.path().c_str()); DetElement par = det.parent(); TGeoHMatrix* parent_world_trafo = 0; if ( par.isValid() && (par->flag&HAVE_PARENT_TRAFO) ) { diff --git a/DDCore/src/DetectorTools.cpp b/DDCore/src/DetectorTools.cpp index e45b4c2ed971c9efbf97acbfe60197fce02f94e6..7add405c14a2848611c62bbc8fb58599fc3d7e22 100644 --- a/DDCore/src/DetectorTools.cpp +++ b/DDCore/src/DetectorTools.cpp @@ -27,7 +27,7 @@ namespace DD4hep { namespace Geometry { /// Helper namespace used to answer detector element specific questons - /** + /** * @author M.Frank * @version 1.0 */ @@ -64,7 +64,7 @@ bool DetectorTools::isParentElement(DetElement parent, DetElement child) { if ( par.ptr() == parent.ptr() ) return true; } } - throw runtime_error("Search for parent detector element with invalid handles not allowed."); + throw runtime_error("Search for parent detector element with invalid handles not allowed."); } /// Find Child of PlacedVolume and assemble on the fly the path of PlacedVolumes @@ -74,7 +74,7 @@ bool DetectorTools::findChild(PlacedVolume parent, PlacedVolume child, Placement if ( parent.ptr() == child.ptr() ) { path.push_back(child); return true; - } + } TIter next(parent->GetVolume()->GetNodes()); // Now check next layer children for (TGeoNode *daughter = (TGeoNode*) next(); daughter; daughter = (TGeoNode*) next()) { @@ -89,7 +89,7 @@ bool DetectorTools::findChild(PlacedVolume parent, PlacedVolume child, Placement PlacementPath sub_path; bool res = findChild(daughter, child, sub_path); if (res) { - path.insert(path.end(), sub_path.begin(), sub_path.end()); + path.insert(path.end(), sub_path.begin(), sub_path.end()); path.push_back(daughter); return res; } @@ -105,7 +105,7 @@ static bool findChildByName(PlacedVolume parent, PlacedVolume child, DetectorToo if ( 0 == ::strcmp(parent.ptr()->GetName(),child.ptr()->GetName()) ) { path.push_back(child); return true; - } + } TIter next(parent->GetVolume()->GetNodes()); // Now check next layer children for (TGeoNode *daughter = (TGeoNode*) next(); daughter; daughter = (TGeoNode*) next()) { @@ -120,7 +120,7 @@ static bool findChildByName(PlacedVolume parent, PlacedVolume child, DetectorToo DetectorTools::PlacementPath sub_path; bool res = findChildByName(daughter, child, sub_path); if (res) { - path.insert(path.end(), sub_path.begin(), sub_path.end()); + path.insert(path.end(), sub_path.begin(), sub_path.end()); path.push_back(daughter); return res; } @@ -147,8 +147,8 @@ void DetectorTools::elementPath(DetElement parent, DetElement child, ElementPath for(DetElement par = child; par.isValid(); par = par.parent()) { elements.push_back(par); if ( par.ptr() == parent.ptr() ) { - detectors = elements; - return; + detectors = elements; + return; } } throw runtime_error(string("The detector element ")+parent.name()+string(" is no parent of ")+child.name()); @@ -182,8 +182,8 @@ void DetectorTools::elementPath(DetElement element, PlacementPath& det_nodes) { std::string DetectorTools::elementPath(const PlacementPath& nodes, bool reverse) { string s = ""; if ( reverse ) { - for(PlacementPath::const_reverse_iterator i=nodes.rbegin();i!=nodes.rend();++i) - s += "/" + string((*i).name()); + for(PlacementPath::const_reverse_iterator i=nodes.rbegin();i!=nodes.rend();++i) + s += "/" + string((*i).name()); } else { for(PlacementPath::const_iterator i=nodes.begin();i!=nodes.end();++i) @@ -196,8 +196,8 @@ std::string DetectorTools::elementPath(const PlacementPath& nodes, bool reverse) std::string DetectorTools::elementPath(const ElementPath& nodes, bool reverse) { string s = ""; if ( reverse ) { - for(ElementPath::const_reverse_iterator i=nodes.rbegin();i!=nodes.rend();++i) - s += "/" + string((*i)->GetName()); + for(ElementPath::const_reverse_iterator i=nodes.rbegin();i!=nodes.rend();++i) + s += "/" + string((*i)->GetName()); } else { for(ElementPath::const_iterator i=nodes.begin();i!=nodes.end();++i) @@ -252,8 +252,8 @@ DetElement DetectorTools::topElement(DetElement child) { static void DetectorTools::makePlacementPath(PlacementPath det_nodes, PlacementPath& all_nodes) { for (size_t i = 0, n = det_nodes.size(); i < n-1; ++i) { if (!findChildByName(det_nodes[i + 1], det_nodes[i], all_nodes)) { - throw runtime_error("DD4hep: DetElement cannot determine placement path of " - + string(det_nodes[i].name()) + " [internal error]"); + throw runtime_error("DD4hep: DetElement cannot determine placement path of " + + string(det_nodes[i].name()) + " [internal error]"); } } if ( det_nodes.size() > 0 ) { @@ -354,7 +354,7 @@ PlacedVolume DetectorTools::findNode(PlacedVolume top_place, const std::string& if ( name == top->GetName() ) { if (ind2>=length-1) return top; ind1 = ind2; - } + } else { return 0; } @@ -369,9 +369,9 @@ PlacedVolume DetectorTools::findNode(PlacedVolume top_place, const std::string& vol = node->GetVolume(); name = spath(ind1+1, ind2-ind1-1); node = vol->GetNode(name.Data()); - if (!node) + if (!node) return 0; - else if (ind2>=length-1) + else if (ind2>=length-1) return node; ind1 = ind2; } diff --git a/DDCore/src/Evaluator/Evaluator.cpp b/DDCore/src/Evaluator/Evaluator.cpp index 6b4cbf29ee9f265bd7e2d4713e47f9ce315d51dd..9252d4a878095aaff138c089286b27de1b83541e 100644 --- a/DDCore/src/Evaluator/Evaluator.cpp +++ b/DDCore/src/Evaluator/Evaluator.cpp @@ -5,14 +5,14 @@ #include "XML/Evaluator.h" #include <iostream> -#include <cmath> // for pow() +#include <cmath> // for pow() #include "stack.src" #include "string.src" #include "hash_map.src" #include <string.h> #include <ctype.h> #include <errno.h> -#include <stdlib.h> // for strtod() +#include <stdlib.h> // for strtod() //--------------------------------------------------------------------------- struct Item { @@ -54,21 +54,21 @@ namespace { FCN(double (*f)(double,double,double)) { f3 = f; } FCN(double (*f)(double,double,double,double)) { f4 = f; } FCN(double (*f)(double,double,double,double,double)) { f5 = f; } - }; + }; } //--------------------------------------------------------------------------- #define EVAL XmlTools::Evaluator -#define REMOVE_BLANKS \ -for(pointer=name;;pointer++) if (!isspace(*pointer)) break; \ -for(n=strlen(pointer);n>0;n--) if (!isspace(*(pointer+n-1))) break +#define REMOVE_BLANKS \ + for(pointer=name;;pointer++) if (!isspace(*pointer)) break; \ + for(n=strlen(pointer);n>0;n--) if (!isspace(*(pointer+n-1))) break -#define SKIP_BLANKS \ -for(;;pointer++) { \ - c = (pointer > end) ? '\0' : *pointer; \ - if (!isspace(c)) break; \ -} +#define SKIP_BLANKS \ + for(;;pointer++) { \ + c = (pointer > end) ? '\0' : *pointer; \ + if (!isspace(c)) break; \ + } #define EVAL_EXIT(STATUS,POSITION) endp = POSITION; return STATUS #define MAX_N_PAR 5 @@ -81,13 +81,13 @@ enum { ENDL, LBRA, OR, AND, EQ, NE, GE, GT, LE, LT, static int engine(pchar, pchar, double &, pchar &, const dic_type &); static int variable(const string & name, double & result, - const dic_type & dictionary) + const dic_type & dictionary) /*********************************************************************** * * * Name: variable Date: 03.10.00 * * Author: Evgeni Chernyaev Revised: * * * - * Function: Finds value of the variable. * + * Function: Finds value of the variable. * * This function is used by operand(). * * * * Parameters: * @@ -118,13 +118,13 @@ static int variable(const string & name, double & result, } static int function(const string & name, stack<double> & par, - double & result, const dic_type & dictionary) + double & result, const dic_type & dictionary) /*********************************************************************** * * * Name: function Date: 03.10.00 * * Author: Evgeni Chernyaev Revised: * * * - * Function: Finds value of the function. * + * Function: Finds value of the function. * * This function is used by operand(). * * * * Parameters: * @@ -150,36 +150,36 @@ static int function(const string & name, stack<double> & par, switch (npar) { case 0: result = (*fcn.f0)(); - break; + break; case 1: result = (*fcn.f1)(pp[0]); - break; + break; case 2: result = (*fcn.f2)(pp[1], pp[0]); - break; + break; case 3: result = (*fcn.f3)(pp[2],pp[1],pp[0]); - break; + break; case 4: result = (*fcn.f4)(pp[3],pp[2],pp[1],pp[0]); - break; + break; case 5: result = (*fcn.f5)(pp[4],pp[3],pp[2],pp[1],pp[0]); - break; + break; } return (errno == 0) ? EVAL::OK : EVAL::ERROR_CALCULATION_ERROR; } static int operand(pchar begin, pchar end, double & result, - pchar & endp, const dic_type & dictionary) + pchar & endp, const dic_type & dictionary) /*********************************************************************** * * * Name: operand Date: 03.10.00 * * Author: Evgeni Chernyaev Revised: * * * - * Function: Finds value of the operand. The operand can be either * - * a number or a variable or a function. * - * This function is used by engine(). * + * Function: Finds value of the operand. The operand can be either * + * a number or a variable or a function. * + * This function is used by engine(). * * * * Parameters: * * begin - pointer to the first character of the operand. * @@ -197,11 +197,11 @@ static int operand(pchar begin, pchar end, double & result, // G E T N U M B E R if (!isalpha(*pointer)) { - errno = 0; + errno = 0; #ifdef _WIN32 - if ( pointer[0] == '0' && pointer < end && (pointer[1] == 'x' || pointer[1] == 'X') ) + if ( pointer[0] == '0' && pointer < end && (pointer[1] == 'x' || pointer[1] == 'X') ) result = strtol(pointer, (char **)(&pointer), 0); - else + else #endif result = strtod(pointer, (char **)(&pointer)); if (errno == 0) { @@ -234,7 +234,7 @@ static int operand(pchar begin, pchar end, double & result, // G E T F U N C T I O N - stack<pchar> pos; // position stack + stack<pchar> pos; // position stack stack<double> par; // parameter stack double value; pchar par_begin = pointer+1, par_end; @@ -242,42 +242,42 @@ static int operand(pchar begin, pchar end, double & result, for(;;pointer++) { c = (pointer > end) ? '\0' : *pointer; switch (c) { - case '\0': - EVAL_EXIT( EVAL::ERROR_UNPAIRED_PARENTHESIS, pos.top() ); + case '\0': + EVAL_EXIT( EVAL::ERROR_UNPAIRED_PARENTHESIS, pos.top() ); case '(': pos.push(pointer); break; case ',': if (pos.size() == 1) { - par_end = pointer-1; - EVAL_STATUS = engine(par_begin, par_end, value, par_end, dictionary); - if (EVAL_STATUS == EVAL::WARNING_BLANK_STRING) - { EVAL_EXIT( EVAL::ERROR_EMPTY_PARAMETER, --par_end ); } - if (EVAL_STATUS != EVAL::OK) - { EVAL_EXIT( EVAL_STATUS, par_end ); } - par.push(value); - par_begin = pointer + 1; + par_end = pointer-1; + EVAL_STATUS = engine(par_begin, par_end, value, par_end, dictionary); + if (EVAL_STATUS == EVAL::WARNING_BLANK_STRING) + { EVAL_EXIT( EVAL::ERROR_EMPTY_PARAMETER, --par_end ); } + if (EVAL_STATUS != EVAL::OK) + { EVAL_EXIT( EVAL_STATUS, par_end ); } + par.push(value); + par_begin = pointer + 1; } break; case ')': if (pos.size() > 1) { - pos.pop(); - break; + pos.pop(); + break; }else{ - par_end = pointer-1; - EVAL_STATUS = engine(par_begin, par_end, value, par_end, dictionary); - switch (EVAL_STATUS) { - case EVAL::OK: - par.push(value); - break; - case EVAL::WARNING_BLANK_STRING: - if (par.size() != 0) - { EVAL_EXIT( EVAL::ERROR_EMPTY_PARAMETER, --par_end ); } - break; - default: - EVAL_EXIT( EVAL_STATUS, par_end ); - } - EVAL_STATUS = function(name, par, result, dictionary); - EVAL_EXIT( EVAL_STATUS, (EVAL_STATUS == EVAL::OK) ? pointer : begin); + par_end = pointer-1; + EVAL_STATUS = engine(par_begin, par_end, value, par_end, dictionary); + switch (EVAL_STATUS) { + case EVAL::OK: + par.push(value); + break; + case EVAL::WARNING_BLANK_STRING: + if (par.size() != 0) + { EVAL_EXIT( EVAL::ERROR_EMPTY_PARAMETER, --par_end ); } + break; + default: + EVAL_EXIT( EVAL_STATUS, par_end ); + } + EVAL_STATUS = function(name, par, result, dictionary); + EVAL_EXIT( EVAL_STATUS, (EVAL_STATUS == EVAL::OK) ? pointer : begin); } } } @@ -290,7 +290,7 @@ static int operand(pchar begin, pchar end, double & result, * * * Function: Executes basic arithmetic operations on values in the top * * of the stack. Result is placed back into the stack. * - * This function is used by engine(). * + * This function is used by engine(). * * * * Parameters: * * op - code of the operation. * @@ -366,7 +366,7 @@ static int maker(int op, stack<double> & val) * * ***********************************************************************/ static int engine(pchar begin, pchar end, double & result, - pchar & endp, const dic_type & dictionary) + pchar & endp, const dic_type & dictionary) { static const int SyntaxTable[17][17] = { //E ( || && == != >= > <= < + - * / ^ ) V - current token @@ -429,25 +429,25 @@ static int engine(pchar begin, pchar end, double & result, case '(': iCur = LBRA; break; case '|': if (*(pointer+1) == '|') { - pointer++; iCur = OR; break; + pointer++; iCur = OR; break; }else{ EVAL_EXIT( EVAL::ERROR_UNEXPECTED_SYMBOL, pointer ); } case '&': if (*(pointer+1) == '&') { - pointer++; iCur = AND; break; + pointer++; iCur = AND; break; }else{ EVAL_EXIT( EVAL::ERROR_UNEXPECTED_SYMBOL, pointer ); } case '=': if (*(pointer+1) == '=') { - pointer++; iCur = EQ; break; + pointer++; iCur = EQ; break; }else{ EVAL_EXIT( EVAL::ERROR_UNEXPECTED_SYMBOL, pointer ); } case '!': if (*(pointer+1) == '=') { - pointer++; iCur = NE; break; + pointer++; iCur = NE; break; }else{ EVAL_EXIT( EVAL::ERROR_UNEXPECTED_SYMBOL, pointer ); } @@ -497,35 +497,35 @@ static int engine(pchar begin, pchar end, double & result, if (op.size() == 0) { EVAL_EXIT( EVAL::ERROR_SYNTAX_ERROR, pointer ); } iTop = op.top(); switch (ActionTable[iTop][iCur]) { - case -1: // syntax error - if (op.size() > 1) pointer = pos.top(); - EVAL_EXIT( EVAL::ERROR_UNPAIRED_PARENTHESIS, pointer ); + case -1: // syntax error + if (op.size() > 1) pointer = pos.top(); + EVAL_EXIT( EVAL::ERROR_UNPAIRED_PARENTHESIS, pointer ); case 0: // last operation (assignment) if (val.size() == 1) { - result = val.top(); - EVAL_EXIT( EVAL::OK, pointer ); - }else{ - EVAL_EXIT( EVAL::ERROR_SYNTAX_ERROR, pointer ); - } + result = val.top(); + EVAL_EXIT( EVAL::OK, pointer ); + }else{ + EVAL_EXIT( EVAL::ERROR_SYNTAX_ERROR, pointer ); + } case 1: // push current operator in stack - op.push(iCur); pos.push(pointer); - break; + op.push(iCur); pos.push(pointer); + break; case 2: // execute top operator EVAL_STATUS = maker(iTop, val); // put current operator in stack if (EVAL_STATUS != EVAL::OK) { - EVAL_EXIT( EVAL_STATUS, pos.top() ); - } - op.top() = iCur; pos.top() = pointer; - break; + EVAL_EXIT( EVAL_STATUS, pos.top() ); + } + op.top() = iCur; pos.top() = pointer; + break; case 3: // delete '(' from stack op.pop(); pos.pop(); - break; - case 4: default: // execute top operator and + break; + case 4: default: // execute top operator and EVAL_STATUS = maker(iTop, val); // delete it from stack - if (EVAL_STATUS != EVAL::OK) { // repete with the same iCur - EVAL_EXIT( EVAL_STATUS, pos.top() ); - } - op.pop(); pos.pop(); + if (EVAL_STATUS != EVAL::OK) { // repete with the same iCur + EVAL_EXIT( EVAL_STATUS, pos.top() ); + } + op.pop(); pos.pop(); continue; } break; @@ -535,7 +535,7 @@ static int engine(pchar begin, pchar end, double & result, //--------------------------------------------------------------------------- static void setItem(const char * prefix, const char * name, - const Item & item, Struct * s) { + const Item & item, Struct * s) { if (name == 0 || *name == '\0') { s->theStatus = EVAL::ERROR_NOT_A_NAME; @@ -546,8 +546,8 @@ static void setItem(const char * prefix, const char * name, const char * pointer; int n; REMOVE_BLANKS; - // C H E C K N A M E - + // C H E C K N A M E + if (n == 0) { s->theStatus = EVAL::ERROR_NOT_A_NAME; return; @@ -575,222 +575,222 @@ static void setItem(const char * prefix, const char * name, (s->theDictionary)[item_name] = item; s->theStatus = EVAL::OK; } -} - -//--------------------------------------------------------------------------- -namespace XmlTools { - -//--------------------------------------------------------------------------- -Evaluator::Evaluator() { - Struct * s = new Struct(); - p = (void *) s; - s->theExpression = 0; - s->thePosition = 0; - s->theStatus = OK; - s->theResult = 0.0; } //--------------------------------------------------------------------------- -Evaluator::~Evaluator() { - Struct * s = (Struct *)(p); - if (s->theExpression != 0) { - delete[] s->theExpression; +namespace XmlTools { + + //--------------------------------------------------------------------------- + Evaluator::Evaluator() { + Struct * s = new Struct(); + p = (void *) s; s->theExpression = 0; + s->thePosition = 0; + s->theStatus = OK; + s->theResult = 0.0; } - delete (Struct *)(p); -} -//--------------------------------------------------------------------------- -double Evaluator::evaluate(const char * expression) { - Struct * s = (Struct *)(p); - if (s->theExpression != 0) { delete[] s->theExpression; } - s->theExpression = 0; - s->thePosition = 0; - s->theStatus = WARNING_BLANK_STRING; - s->theResult = 0.0; - if (expression != 0) { - s->theExpression = new char[strlen(expression)+1]; - strcpy(s->theExpression, expression); - s->theStatus = engine(s->theExpression, - s->theExpression+strlen(expression)-1, - s->theResult, - s->thePosition, - s->theDictionary); - } - return s->theResult; -} + //--------------------------------------------------------------------------- + Evaluator::~Evaluator() { + Struct * s = (Struct *)(p); + if (s->theExpression != 0) { + delete[] s->theExpression; + s->theExpression = 0; + } + delete (Struct *)(p); + } -//--------------------------------------------------------------------------- -int Evaluator::status() const { - return ((Struct *)(p))->theStatus; -} + //--------------------------------------------------------------------------- + double Evaluator::evaluate(const char * expression) { + Struct * s = (Struct *)(p); + if (s->theExpression != 0) { delete[] s->theExpression; } + s->theExpression = 0; + s->thePosition = 0; + s->theStatus = WARNING_BLANK_STRING; + s->theResult = 0.0; + if (expression != 0) { + s->theExpression = new char[strlen(expression)+1]; + strcpy(s->theExpression, expression); + s->theStatus = engine(s->theExpression, + s->theExpression+strlen(expression)-1, + s->theResult, + s->thePosition, + s->theDictionary); + } + return s->theResult; + } -//--------------------------------------------------------------------------- -int Evaluator::error_position() const { - return ((Struct *)(p))->thePosition - ((Struct *)(p))->theExpression; -} + //--------------------------------------------------------------------------- + int Evaluator::status() const { + return ((Struct *)(p))->theStatus; + } -//--------------------------------------------------------------------------- -void Evaluator::print_error() const { - char prefix[] = "Evaluator : "; - Struct * s = (Struct *) p; - switch (s->theStatus) { - case ERROR_NOT_A_NAME: - std::cerr << prefix << "invalid name" << std::endl; - return; - case ERROR_SYNTAX_ERROR: - std::cerr << prefix << "systax error" << std::endl; - return; - case ERROR_UNPAIRED_PARENTHESIS: - std::cerr << prefix << "unpaired parenthesis" << std::endl; - return; - case ERROR_UNEXPECTED_SYMBOL: - std::cerr << prefix << "unexpected symbol" << std::endl; - return; - case ERROR_UNKNOWN_VARIABLE: - std::cerr << prefix << "unknown variable" << std::endl; - return; - case ERROR_UNKNOWN_FUNCTION: - std::cerr << prefix << "unknown function" << std::endl; - return; - case ERROR_EMPTY_PARAMETER: - std::cerr << prefix << "empty parameter in function call" - << std::endl; - return; - case ERROR_CALCULATION_ERROR: - std::cerr << prefix << "calculation error" << std::endl; - return; - default: - return; + //--------------------------------------------------------------------------- + int Evaluator::error_position() const { + return ((Struct *)(p))->thePosition - ((Struct *)(p))->theExpression; } -} -//--------------------------------------------------------------------------- -void Evaluator::setEnviron(const char* name, const char* value) { - Struct* s = (Struct *)p; - string prefix = "${"; - string item_name = prefix + string(name) + string("}"); - dic_type::iterator iter = (s->theDictionary).find(item_name); - Item item; - item.what = Item::STRING; - item.expression = value; - item.function = 0; - item.variable = 0; - //std::cout << " ++++++++++++++++++++++++++++ Saving env:" << name << " = " << value << std::endl; - if (iter != (s->theDictionary).end()) { - iter->second = item; - if (item_name == name) { - s->theStatus = EVAL::WARNING_EXISTING_VARIABLE; + //--------------------------------------------------------------------------- + void Evaluator::print_error() const { + char prefix[] = "Evaluator : "; + Struct * s = (Struct *) p; + switch (s->theStatus) { + case ERROR_NOT_A_NAME: + std::cerr << prefix << "invalid name" << std::endl; + return; + case ERROR_SYNTAX_ERROR: + std::cerr << prefix << "systax error" << std::endl; + return; + case ERROR_UNPAIRED_PARENTHESIS: + std::cerr << prefix << "unpaired parenthesis" << std::endl; + return; + case ERROR_UNEXPECTED_SYMBOL: + std::cerr << prefix << "unexpected symbol" << std::endl; + return; + case ERROR_UNKNOWN_VARIABLE: + std::cerr << prefix << "unknown variable" << std::endl; + return; + case ERROR_UNKNOWN_FUNCTION: + std::cerr << prefix << "unknown function" << std::endl; + return; + case ERROR_EMPTY_PARAMETER: + std::cerr << prefix << "empty parameter in function call" + << std::endl; + return; + case ERROR_CALCULATION_ERROR: + std::cerr << prefix << "calculation error" << std::endl; + return; + default: + return; + } + } + + //--------------------------------------------------------------------------- + void Evaluator::setEnviron(const char* name, const char* value) { + Struct* s = (Struct *)p; + string prefix = "${"; + string item_name = prefix + string(name) + string("}"); + dic_type::iterator iter = (s->theDictionary).find(item_name); + Item item; + item.what = Item::STRING; + item.expression = value; + item.function = 0; + item.variable = 0; + //std::cout << " ++++++++++++++++++++++++++++ Saving env:" << name << " = " << value << std::endl; + if (iter != (s->theDictionary).end()) { + iter->second = item; + if (item_name == name) { + s->theStatus = EVAL::WARNING_EXISTING_VARIABLE; + }else{ + s->theStatus = EVAL::WARNING_EXISTING_FUNCTION; + } }else{ - s->theStatus = EVAL::WARNING_EXISTING_FUNCTION; + (s->theDictionary)[item_name] = item; + s->theStatus = EVAL::OK; } - }else{ - (s->theDictionary)[item_name] = item; - s->theStatus = EVAL::OK; } -} -//--------------------------------------------------------------------------- -const char* Evaluator::getEnviron(const char* name) { - Struct* s = (Struct *)p; - string item_name = name; - //std::cout << " ++++++++++++++++++++++++++++ Try to resolve env:" << name << std::endl; - dic_type::iterator iter = (s->theDictionary).find(item_name); - if (iter == (s->theDictionary).end()) { - s->theStatus = EVAL::ERROR_UNKNOWN_VARIABLE; - return 0; + //--------------------------------------------------------------------------- + const char* Evaluator::getEnviron(const char* name) { + Struct* s = (Struct *)p; + string item_name = name; + //std::cout << " ++++++++++++++++++++++++++++ Try to resolve env:" << name << std::endl; + dic_type::iterator iter = (s->theDictionary).find(item_name); + if (iter == (s->theDictionary).end()) { + s->theStatus = EVAL::ERROR_UNKNOWN_VARIABLE; + return 0; + } + s->theStatus = EVAL::OK; + return iter->second.expression.c_str(); } - s->theStatus = EVAL::OK; - return iter->second.expression.c_str(); -} -//--------------------------------------------------------------------------- -void Evaluator::setVariable(const char * name, double value) -{ setItem("", name, Item(value), (Struct *)p); } + //--------------------------------------------------------------------------- + void Evaluator::setVariable(const char * name, double value) + { setItem("", name, Item(value), (Struct *)p); } -void Evaluator::setVariable(const char * name, const char * expression) -{ setItem("", name, Item(expression), (Struct *)p); } + void Evaluator::setVariable(const char * name, const char * expression) + { setItem("", name, Item(expression), (Struct *)p); } -//--------------------------------------------------------------------------- -void Evaluator::setFunction(const char * name,double (*fun)()) { - FCN fcn(fun); - setItem("0", name, Item(fcn.ptr), (Struct *)p); -} + //--------------------------------------------------------------------------- + void Evaluator::setFunction(const char * name,double (*fun)()) { + FCN fcn(fun); + setItem("0", name, Item(fcn.ptr), (Struct *)p); + } -void Evaluator::setFunction(const char * name,double (*fun)(double)) { - FCN fcn(fun); - setItem("1", name, Item(fcn.ptr), (Struct *)p); -} + void Evaluator::setFunction(const char * name,double (*fun)(double)) { + FCN fcn(fun); + setItem("1", name, Item(fcn.ptr), (Struct *)p); + } -void Evaluator::setFunction(const char * name, double (*fun)(double,double)) { - FCN fcn(fun); - setItem("2", name, Item(fcn.ptr), (Struct *)p); -} + void Evaluator::setFunction(const char * name, double (*fun)(double,double)) { + FCN fcn(fun); + setItem("2", name, Item(fcn.ptr), (Struct *)p); + } -void Evaluator::setFunction(const char * name, double (*fun)(double,double,double)) { - FCN fcn(fun); - setItem("3", name, Item(fcn.ptr), (Struct *)p); -} + void Evaluator::setFunction(const char * name, double (*fun)(double,double,double)) { + FCN fcn(fun); + setItem("3", name, Item(fcn.ptr), (Struct *)p); + } -void Evaluator::setFunction(const char * name, double (*fun)(double,double,double,double)) { - FCN fcn(fun); - setItem("4", name, Item(fcn.ptr), (Struct *)p); -} + void Evaluator::setFunction(const char * name, double (*fun)(double,double,double,double)) { + FCN fcn(fun); + setItem("4", name, Item(fcn.ptr), (Struct *)p); + } -void Evaluator::setFunction(const char * name, double (*fun)(double,double,double,double,double)) { - FCN fcn(fun); - setItem("5", name, Item(fcn.ptr), (Struct *)p); -} + void Evaluator::setFunction(const char * name, double (*fun)(double,double,double,double,double)) { + FCN fcn(fun); + setItem("5", name, Item(fcn.ptr), (Struct *)p); + } -//--------------------------------------------------------------------------- -bool Evaluator::findVariable(const char * name) const { - if (name == 0 || *name == '\0') return false; - const char * pointer; int n; REMOVE_BLANKS; - if (n == 0) return false; - Struct * s = (Struct *)(p); - return - ((s->theDictionary).find(string(pointer,n)) == (s->theDictionary).end()) ? - false : true; -} + //--------------------------------------------------------------------------- + bool Evaluator::findVariable(const char * name) const { + if (name == 0 || *name == '\0') return false; + const char * pointer; int n; REMOVE_BLANKS; + if (n == 0) return false; + Struct * s = (Struct *)(p); + return + ((s->theDictionary).find(string(pointer,n)) == (s->theDictionary).end()) ? + false : true; + } -//--------------------------------------------------------------------------- -bool Evaluator::findFunction(const char * name, int npar) const { - if (name == 0 || *name == '\0') return false; - if (npar < 0 || npar > MAX_N_PAR) return false; - const char * pointer; int n; REMOVE_BLANKS; - if (n == 0) return false; - Struct * s = (Struct *)(p); - return ((s->theDictionary).find(sss[npar]+string(pointer,n)) == - (s->theDictionary).end()) ? false : true; -} + //--------------------------------------------------------------------------- + bool Evaluator::findFunction(const char * name, int npar) const { + if (name == 0 || *name == '\0') return false; + if (npar < 0 || npar > MAX_N_PAR) return false; + const char * pointer; int n; REMOVE_BLANKS; + if (n == 0) return false; + Struct * s = (Struct *)(p); + return ((s->theDictionary).find(sss[npar]+string(pointer,n)) == + (s->theDictionary).end()) ? false : true; + } -//--------------------------------------------------------------------------- -void Evaluator::removeVariable(const char * name) { - if (name == 0 || *name == '\0') return; - const char * pointer; int n; REMOVE_BLANKS; - if (n == 0) return; - Struct * s = (Struct *)(p); - (s->theDictionary).erase(string(pointer,n)); -} + //--------------------------------------------------------------------------- + void Evaluator::removeVariable(const char * name) { + if (name == 0 || *name == '\0') return; + const char * pointer; int n; REMOVE_BLANKS; + if (n == 0) return; + Struct * s = (Struct *)(p); + (s->theDictionary).erase(string(pointer,n)); + } -//--------------------------------------------------------------------------- -void Evaluator::removeFunction(const char * name, int npar) { - if (name == 0 || *name == '\0') return; - if (npar < 0 || npar > MAX_N_PAR) return; - const char * pointer; int n; REMOVE_BLANKS; - if (n == 0) return; - Struct * s = (Struct *)(p); - (s->theDictionary).erase(sss[npar]+string(pointer,n)); -} + //--------------------------------------------------------------------------- + void Evaluator::removeFunction(const char * name, int npar) { + if (name == 0 || *name == '\0') return; + if (npar < 0 || npar > MAX_N_PAR) return; + const char * pointer; int n; REMOVE_BLANKS; + if (n == 0) return; + Struct * s = (Struct *)(p); + (s->theDictionary).erase(sss[npar]+string(pointer,n)); + } -//--------------------------------------------------------------------------- -void Evaluator::clear() { - Struct * s = (Struct *) p; - s->theDictionary.clear(); - s->theExpression = 0; - s->thePosition = 0; - s->theStatus = OK; - s->theResult = 0.0; -} + //--------------------------------------------------------------------------- + void Evaluator::clear() { + Struct * s = (Struct *) p; + s->theDictionary.clear(); + s->theExpression = 0; + s->thePosition = 0; + s->theStatus = OK; + s->theResult = 0.0; + } -//--------------------------------------------------------------------------- + //--------------------------------------------------------------------------- } // namespace XmlTools diff --git a/DDCore/src/Evaluator/setStdMath.cpp b/DDCore/src/Evaluator/setStdMath.cpp index db1857f609a57f301637b34e1451b5b798832b36..fb452c5181dfccf55c382a363c8c09c732032f03 100644 --- a/DDCore/src/Evaluator/setStdMath.cpp +++ b/DDCore/src/Evaluator/setStdMath.cpp @@ -5,77 +5,77 @@ #include "XML/Evaluator.h" #include "DD4hep/DD4hepUnits.h" -#include <cmath> // for sqrt and pow +#include <cmath> // for sqrt and pow using namespace std; -static double eval_abs (double a) { return (a < 0) ? -a : a; } -static double eval_min (double a, double b) { return (a < b) ? a : b; } -static double eval_max (double a, double b) { return (a > b) ? a : b; } -static double eval_sqrt (double a) { return std::sqrt(a); } -static double eval_pow (double a, double b) { return std::pow(a,b); } -static double eval_sin (double a) { return std::sin(a); } -static double eval_cos (double a) { return std::cos(a); } -static double eval_tan (double a) { return std::tan(a); } -static double eval_asin (double a) { return std::asin(a); } -static double eval_acos (double a) { return std::acos(a); } -static double eval_atan (double a) { return std::atan(a); } -static double eval_atan2(double a, double b) { return std::atan2(a,b); } -static double eval_sinh (double a) { return std::sinh(a); } -static double eval_cosh (double a) { return std::cosh(a); } -static double eval_tanh (double a) { return std::tanh(a); } -static double eval_exp (double a) { return std::exp(a); } -static double eval_log (double a) { return std::log(a); } -static double eval_log10(double a) { return std::log10(a); } -static double eval_double(double a) { return a; } -static double eval_int (double a) { return (double)int(a); } -static double eval_nint (double a) { return std::floor(a); } -static double eval_floor(double a) { return std::floor(a); } +static double eval_abs (double a) { return (a < 0) ? -a : a; } +static double eval_min (double a, double b) { return (a < b) ? a : b; } +static double eval_max (double a, double b) { return (a > b) ? a : b; } +static double eval_sqrt (double a) { return std::sqrt(a); } +static double eval_pow (double a, double b) { return std::pow(a,b); } +static double eval_sin (double a) { return std::sin(a); } +static double eval_cos (double a) { return std::cos(a); } +static double eval_tan (double a) { return std::tan(a); } +static double eval_asin (double a) { return std::asin(a); } +static double eval_acos (double a) { return std::acos(a); } +static double eval_atan (double a) { return std::atan(a); } +static double eval_atan2(double a, double b) { return std::atan2(a,b); } +static double eval_sinh (double a) { return std::sinh(a); } +static double eval_cosh (double a) { return std::cosh(a); } +static double eval_tanh (double a) { return std::tanh(a); } +static double eval_exp (double a) { return std::exp(a); } +static double eval_log (double a) { return std::log(a); } +static double eval_log10(double a) { return std::log10(a); } +static double eval_double(double a) { return a; } +static double eval_int (double a) { return (double)int(a); } +static double eval_nint (double a) { return std::floor(a); } +static double eval_floor(double a) { return std::floor(a); } namespace XmlTools { -void Evaluator::setStdMath() { + void Evaluator::setStdMath() { - // S E T S T A N D A R D C O N S T A N T S + // S E T S T A N D A R D C O N S T A N T S - setVariable("pi", 3.14159265358979323846); - setVariable("e", 2.7182818284590452354); - setVariable("gamma", 0.577215664901532861); + setVariable("pi", 3.14159265358979323846); + setVariable("e", 2.7182818284590452354); + setVariable("gamma", 0.577215664901532861); - // setVariable("radian", 1.0); - // setVariable("rad", 1.0); - // setVariable("degree", 3.14159265358979323846/180.); - // setVariable("deg", 3.14159265358979323846/180.); - setVariable("radian", dd4hep::rad ); - setVariable("rad", dd4hep::rad ); - setVariable("degree", dd4hep::deg ); - setVariable("deg", dd4hep::deg ); + // setVariable("radian", 1.0); + // setVariable("rad", 1.0); + // setVariable("degree", 3.14159265358979323846/180.); + // setVariable("deg", 3.14159265358979323846/180.); + setVariable("radian", dd4hep::rad ); + setVariable("rad", dd4hep::rad ); + setVariable("degree", dd4hep::deg ); + setVariable("deg", dd4hep::deg ); - // S E T S T A N D A R D F U N C T I O N S + // S E T S T A N D A R D F U N C T I O N S - setFunction("floor", eval_floor); - setFunction("double",eval_double); - setFunction("int", eval_int); - setFunction("nint", eval_nint); - setFunction("abs", eval_abs); - setFunction("min", eval_min); - setFunction("max", eval_max); - setFunction("sqrt", eval_sqrt); - setFunction("pow", eval_pow); - setFunction("sin", eval_sin); - setFunction("cos", eval_cos); - setFunction("tan", eval_tan); - setFunction("asin", eval_asin); - setFunction("acos", eval_acos); - setFunction("atan", eval_atan); - setFunction("atan2", eval_atan2); - setFunction("sinh", eval_sinh); - setFunction("cosh", eval_cosh); - setFunction("tanh", eval_tanh); - setFunction("exp", eval_exp); - setFunction("log", eval_log); - setFunction("log10", eval_log10); -} + setFunction("floor", eval_floor); + setFunction("double",eval_double); + setFunction("int", eval_int); + setFunction("nint", eval_nint); + setFunction("abs", eval_abs); + setFunction("min", eval_min); + setFunction("max", eval_max); + setFunction("sqrt", eval_sqrt); + setFunction("pow", eval_pow); + setFunction("sin", eval_sin); + setFunction("cos", eval_cos); + setFunction("tan", eval_tan); + setFunction("asin", eval_asin); + setFunction("acos", eval_acos); + setFunction("atan", eval_atan); + setFunction("atan2", eval_atan2); + setFunction("sinh", eval_sinh); + setFunction("cosh", eval_cosh); + setFunction("tanh", eval_tanh); + setFunction("exp", eval_exp); + setFunction("log", eval_log); + setFunction("log10", eval_log10); + } } // namespace XmlTools diff --git a/DDCore/src/Evaluator/setSystemOfUnits.cpp b/DDCore/src/Evaluator/setSystemOfUnits.cpp index e028f470f33aa15425f7be23bd4e45febc0ec5d4..68858c76d68669223ac645534be52fe0961379f6 100644 --- a/DDCore/src/Evaluator/setSystemOfUnits.cpp +++ b/DDCore/src/Evaluator/setSystemOfUnits.cpp @@ -6,397 +6,397 @@ namespace XmlTools { -void Evaluator::setSystemOfUnits(double meter, - double kilogram, - double second, - double ampere, - double kelvin, - double mole, - double candela, - double radians) -{ - const double kilo_ = 1.e+03; // chilioi (Greek) "thousand" - const double mega_ = 1.e+06; // megas (Greek) "large" - const double giga_ = 1.e+09; // gigas (Greek) "giant" - const double tera_ = 1.e+12; // teras (Greek) "monster" - const double peta_ = 1.e+15; // pente (Greek) "five" - - const double deci_ = 1.e-01; // decimus (Latin) "tenth" - const double centi_ = 1.e-02; // centum (Latin) "hundred" - const double milli_ = 1.e-03; // mille (Latin) "thousand" - const double micro_ = 1.e-06; // micro (Latin) or mikros (Greek) "small" - const double nano_ = 1.e-09; // nanus (Latin) or nanos (Greek) "dwarf" - const double pico_ = 1.e-12; // pico (Spanish) "bit" - - // ====================================================================== - // - // Base (default) SI units - // for the basic measurable quantities (dimensions): - // - // ====================================================================== - - // Length - // metrum (Latin) and metron (Greek) "measure" - const double m = meter; - setVariable("meter", m); - setVariable("metre", m); - setVariable("m", m); - - // Mass - const double kg = kilogram; - setVariable("kilogram", kg); - setVariable("kg", kg); - - // Time - // minuta secundam (Latin) "second small one" - const double s = second; - setVariable("second", s); - setVariable("s", s); - - // Current - // --- honors Andre-Marie Ampere (1775-1836) of France - const double A = ampere; - setVariable("ampere", A); - setVariable("amp", A); - setVariable("A", A); - - // Temperature - // --- honors William Thomson, 1st Baron Lord Kelvin (1824-1907) of England - const double K = kelvin; - setVariable("kelvin", K); - setVariable("K", K); - - // Amount of substance - const double mol = mole; - setVariable("mole", mol); - setVariable("mol", mol); - - // Luminous intensity - const double cd = candela; - setVariable("candela", cd); - setVariable("cd", cd); - - // ====================================================================== - // - // Supplementary SI units having special symbols: - // - // ====================================================================== - - const double pi = 3.14159265358979323846; - // Plane angle - // const double rad = 1.; // Geant4 (rad units) - //const double rad = pi; // Degree units - - const double rad = radians ; - - setVariable("radian", rad); - setVariable("rad", rad); - setVariable("milliradian", milli_ * rad); - setVariable("mrad", milli_ * rad); - - const double deg = rad*pi/180.; - - setVariable("degree", deg); - setVariable("deg", deg); - - // Solid angle - const double sr = 1.; - setVariable("steradian", sr); - setVariable("sr", sr); - - // ====================================================================== - // - // Derived SI units having special symbols: - // - // ====================================================================== - - // Frequency - // --- honors Heinrich Rudolf Hertz (1857-1894) of Germany - const double Hz = 1./s; - setVariable("hertz", Hz); - setVariable("Hz", Hz); - - // Force - // --- honors Sir Isaac Newton (1642-1727) of England - const double N = m * kg / (s*s); - setVariable("newton", N); - setVariable("N", N); - - // Pressure - // --- honors Blaise Pascal (1623-1662) of France - const double Pa = N / (m*m); - setVariable("pascal", Pa); - setVariable("Pa", Pa); - setVariable("hPa", 100.0*Pa); - - const double atm = 101325. * Pa; - setVariable("atmosphere", atm); - setVariable("atm", atm); - - const double bar = 100000*Pa; - setVariable("bar", bar); - - // Energy - // --- honors James Prescott Joule (1818-1889) of England - const double J = N * m; - setVariable("joule", J); - setVariable("J", J); - - // Power - // --- honors James Watt (1736-1819) of Scotland - const double W = J / s; - setVariable("watt", W); - setVariable("W", W); - - // Electric charge - // --- honors Charles-Augustin de Coulomb (1736-1806) of France - const double C = A * s; - setVariable("coulomb", C); - setVariable("C", C); - - // Electric potential - // --- honors Count Alessandro Volta (1745-1827) of Italy - const double V = J / C; - setVariable("volt", V); - setVariable("V", V); - - // Electric resistance - // --- honors Georg Simon Ohm (1787-1854) of Germany - const double ohm = V / A; - setVariable("ohm", ohm); - - // Electric conductance - // --- honors Ernst Werner von Siemens (1816-1892) or - // his brother Sir William (Karl Wilhelm von) Siemens (1823-1883) - // of Germany (England) - const double S = 1./ ohm; - setVariable("siemens", S); - setVariable("S", S); - - // Electric capacitance - // --- honors Michael Faraday (1791-1867) of England - const double F = C / V; - setVariable("farad", F); - setVariable("F", F); - - // Magnetic flux density - // --- honors Nikola Tesla (1856-1943) of Croatia (United States) - const double T = V * s / (m*m); - setVariable("tesla", T); - setVariable("T", T); - - // --- honors Karl Friedrich Gauss (1777-1855) of Germany - const double Gs = 1.e-4*T; - setVariable("gauss", Gs); - setVariable("Gs", Gs); - - // Magnetic flux - // --- honors Wilhelm Eduard Weber (1804-1891) of Germany - const double Wb = V * s; - setVariable("weber", Wb); - setVariable("Wb", Wb); - - // Inductance - // --- honors Joseph Henry (1797-1878) of the United States - const double H = Wb / A; - setVariable("henry", H); - setVariable("H", H); - - // Luminous flux - const double lm = cd * sr; - setVariable("lumen", lm); - setVariable("lm", lm); - - // Illuminace - const double lx = lm / (m*m); - setVariable("lux", lx); - setVariable("lx", lx); - - // Radioactivity - // --- honors Antoine-Henri Becquerel (1852-1908) of France - const double Bq = 1./s; - setVariable("becquerel", Bq); - setVariable("Bq", Bq); - - // --- honors Pierre Curie (1859-1906) of France - // and Marie Sklodowska Curie (1867-1934) of Poland - setVariable("curie", 3.7e+10 * Bq); - setVariable("Ci", 3.7e+10 * Bq); - - // Specific energy - // --- honors Louis Harold Gray, F.R.S. (1905-1965) of England - const double Gy = J / kg; - setVariable("gray", Gy); - setVariable("Gy", Gy); - - // Dose equivalent - const double Sv = J / kg; - setVariable("sievert", Sv); - setVariable("Sv", Sv); - - // ====================================================================== - // - // Selected units: - // - // ====================================================================== - - // Length - - const double mm = milli_ * m; - setVariable("millimeter", mm); - setVariable("mm", mm); - - const double cm = centi_ * m; - setVariable("centimeter", cm); - setVariable("cm", cm); - - setVariable("decimeter", deci_ * m); - - const double km = kilo_ * m; - setVariable("kilometer", km); - setVariable("km", km); - - setVariable("micrometer", micro_ * m); - setVariable("micron", micro_ * m); - setVariable("nanometer", nano_ * m); - - // --- honors Anders Jonas Angstrom (1814-1874) of Sweden - setVariable("angstrom", 1.e-10 * m); - - // --- honors Enrico Fermi (1901-1954) of Italy - setVariable("fermi", 1.e-15 * m); - - // Length^2 - - setVariable("m2", m*m); - setVariable("mm2", mm*mm); - setVariable("cm2", cm*cm); - setVariable("km2", km*km); - - const double barn = 1.e-28 * m*m; - setVariable("barn", barn); - setVariable("millibarn", milli_ * barn); - setVariable("mbarn", milli_ * barn); - setVariable("microbarn", micro_ * barn); - setVariable("nanobarn", nano_ * barn); - setVariable("picobarn", pico_ * barn); - - // LengthL^3 - - setVariable("m3", m*m*m); - setVariable("mm3", mm*mm*mm); - setVariable("cm3", cm*cm*cm); - setVariable("cc", cm*cm*cm); - setVariable("km3", km*km*km); - - const double L = 1.e-3*m*m*m; - setVariable("liter", L); - setVariable("litre", L); - setVariable("L", L); - setVariable("centiliter", centi_ * L); - setVariable("cL", centi_ * L); - setVariable("milliliter", milli_ * L); - setVariable("mL", milli_ * L); - - // Length^-1 - - const double dpt = 1./m; - setVariable("diopter", dpt); - setVariable("dioptre", dpt); - setVariable("dpt", dpt); - - // Mass - - const double g = 0.001*kg; - setVariable("gram", g); - setVariable("g", g); - setVariable("milligram", milli_ * g); - setVariable("mg", milli_ * g); - - // Time - - setVariable("millisecond", milli_ * s); - setVariable("ms", milli_ * s); - setVariable("microsecond", micro_ * s); - setVariable("nanosecond", nano_ * s); - setVariable("ns", nano_ * s); - setVariable("picosecond", pico_ * s); - - // Current - - setVariable("milliampere", milli_ * A); - setVariable("mA", milli_ * A); - setVariable("microampere", micro_ * A); - setVariable("nanoampere", nano_ * A); - - // Frequency - - setVariable("kilohertz", kilo_ * Hz); - setVariable("kHz", kilo_ * Hz); - setVariable("megahertz", mega_ * Hz); - setVariable("MHz", mega_ * Hz); - - // Force - setVariable("kilonewton", kilo_ * N); - setVariable("kN", kilo_ * N); - - // Pressure - setVariable("kilobar", kilo_ * bar); - setVariable("kbar", kilo_ * bar); - setVariable("millibar", milli_ * bar); - setVariable("mbar", milli_ * bar); - - // Energy - setVariable("kilojoule", kilo_ * J); - setVariable("kJ", kilo_ * J); - setVariable("megajoule", mega_ * J); - setVariable("MJ", mega_ * J); - setVariable("gigajoule", giga_ * J); - setVariable("GJ", giga_ * J); - - const double e_SI = 1.60217733e-19; // positron charge in coulomb - const double ePlus = e_SI * C; // positron charge - const double eV = ePlus * V; - setVariable("electronvolt", eV); - setVariable("eV", eV); - setVariable("kiloelectronvolt", kilo_ * eV); - setVariable("keV", kilo_ * eV); - setVariable("megaelectronvolt", mega_ * eV); - setVariable("MeV", mega_ * eV); - setVariable("gigaelectronvolt", giga_ * eV); - setVariable("GeV", giga_ * eV); - setVariable("teraelectronvolt", tera_ * eV); - setVariable("TeV", tera_ * eV); - setVariable("petaelectronvolt", peta_ * eV); - setVariable("PeV", peta_ * eV); - - // Power - setVariable("kilowatt", kilo_ * W); - setVariable("kW", kilo_ * W); - setVariable("megawatt", mega_ * W); - setVariable("MW", mega_ * W); - setVariable("gigawatt", giga_ * W); - setVariable("GW", giga_ * W); - - // Electric potential - setVariable("kilovolt", kilo_ * V); - setVariable("kV", kilo_ * V); - setVariable("megavolt", mega_ * V); - setVariable("MV", mega_ * V); - - // Electric capacitance - setVariable("millifarad", milli_ * F); - setVariable("mF", milli_ * F); - setVariable("microfarad", micro_ * F); - setVariable("uF", micro_ * F); - setVariable("nanofarad", nano_ * F); - setVariable("nF", nano_ * F); - setVariable("picofarad", pico_ * F); - setVariable("pF", pico_ * F); - - // Magnetic flux density - setVariable("kilogauss", kilo_ * Gs); - setVariable("kGs", kilo_ * Gs); -} + void Evaluator::setSystemOfUnits(double meter, + double kilogram, + double second, + double ampere, + double kelvin, + double mole, + double candela, + double radians) + { + const double kilo_ = 1.e+03; // chilioi (Greek) "thousand" + const double mega_ = 1.e+06; // megas (Greek) "large" + const double giga_ = 1.e+09; // gigas (Greek) "giant" + const double tera_ = 1.e+12; // teras (Greek) "monster" + const double peta_ = 1.e+15; // pente (Greek) "five" + + const double deci_ = 1.e-01; // decimus (Latin) "tenth" + const double centi_ = 1.e-02; // centum (Latin) "hundred" + const double milli_ = 1.e-03; // mille (Latin) "thousand" + const double micro_ = 1.e-06; // micro (Latin) or mikros (Greek) "small" + const double nano_ = 1.e-09; // nanus (Latin) or nanos (Greek) "dwarf" + const double pico_ = 1.e-12; // pico (Spanish) "bit" + + // ====================================================================== + // + // Base (default) SI units + // for the basic measurable quantities (dimensions): + // + // ====================================================================== + + // Length + // metrum (Latin) and metron (Greek) "measure" + const double m = meter; + setVariable("meter", m); + setVariable("metre", m); + setVariable("m", m); + + // Mass + const double kg = kilogram; + setVariable("kilogram", kg); + setVariable("kg", kg); + + // Time + // minuta secundam (Latin) "second small one" + const double s = second; + setVariable("second", s); + setVariable("s", s); + + // Current + // --- honors Andre-Marie Ampere (1775-1836) of France + const double A = ampere; + setVariable("ampere", A); + setVariable("amp", A); + setVariable("A", A); + + // Temperature + // --- honors William Thomson, 1st Baron Lord Kelvin (1824-1907) of England + const double K = kelvin; + setVariable("kelvin", K); + setVariable("K", K); + + // Amount of substance + const double mol = mole; + setVariable("mole", mol); + setVariable("mol", mol); + + // Luminous intensity + const double cd = candela; + setVariable("candela", cd); + setVariable("cd", cd); + + // ====================================================================== + // + // Supplementary SI units having special symbols: + // + // ====================================================================== + + const double pi = 3.14159265358979323846; + // Plane angle + // const double rad = 1.; // Geant4 (rad units) + //const double rad = pi; // Degree units + + const double rad = radians ; + + setVariable("radian", rad); + setVariable("rad", rad); + setVariable("milliradian", milli_ * rad); + setVariable("mrad", milli_ * rad); + + const double deg = rad*pi/180.; + + setVariable("degree", deg); + setVariable("deg", deg); + + // Solid angle + const double sr = 1.; + setVariable("steradian", sr); + setVariable("sr", sr); + + // ====================================================================== + // + // Derived SI units having special symbols: + // + // ====================================================================== + + // Frequency + // --- honors Heinrich Rudolf Hertz (1857-1894) of Germany + const double Hz = 1./s; + setVariable("hertz", Hz); + setVariable("Hz", Hz); + + // Force + // --- honors Sir Isaac Newton (1642-1727) of England + const double N = m * kg / (s*s); + setVariable("newton", N); + setVariable("N", N); + + // Pressure + // --- honors Blaise Pascal (1623-1662) of France + const double Pa = N / (m*m); + setVariable("pascal", Pa); + setVariable("Pa", Pa); + setVariable("hPa", 100.0*Pa); + + const double atm = 101325. * Pa; + setVariable("atmosphere", atm); + setVariable("atm", atm); + + const double bar = 100000*Pa; + setVariable("bar", bar); + + // Energy + // --- honors James Prescott Joule (1818-1889) of England + const double J = N * m; + setVariable("joule", J); + setVariable("J", J); + + // Power + // --- honors James Watt (1736-1819) of Scotland + const double W = J / s; + setVariable("watt", W); + setVariable("W", W); + + // Electric charge + // --- honors Charles-Augustin de Coulomb (1736-1806) of France + const double C = A * s; + setVariable("coulomb", C); + setVariable("C", C); + + // Electric potential + // --- honors Count Alessandro Volta (1745-1827) of Italy + const double V = J / C; + setVariable("volt", V); + setVariable("V", V); + + // Electric resistance + // --- honors Georg Simon Ohm (1787-1854) of Germany + const double ohm = V / A; + setVariable("ohm", ohm); + + // Electric conductance + // --- honors Ernst Werner von Siemens (1816-1892) or + // his brother Sir William (Karl Wilhelm von) Siemens (1823-1883) + // of Germany (England) + const double S = 1./ ohm; + setVariable("siemens", S); + setVariable("S", S); + + // Electric capacitance + // --- honors Michael Faraday (1791-1867) of England + const double F = C / V; + setVariable("farad", F); + setVariable("F", F); + + // Magnetic flux density + // --- honors Nikola Tesla (1856-1943) of Croatia (United States) + const double T = V * s / (m*m); + setVariable("tesla", T); + setVariable("T", T); + + // --- honors Karl Friedrich Gauss (1777-1855) of Germany + const double Gs = 1.e-4*T; + setVariable("gauss", Gs); + setVariable("Gs", Gs); + + // Magnetic flux + // --- honors Wilhelm Eduard Weber (1804-1891) of Germany + const double Wb = V * s; + setVariable("weber", Wb); + setVariable("Wb", Wb); + + // Inductance + // --- honors Joseph Henry (1797-1878) of the United States + const double H = Wb / A; + setVariable("henry", H); + setVariable("H", H); + + // Luminous flux + const double lm = cd * sr; + setVariable("lumen", lm); + setVariable("lm", lm); + + // Illuminace + const double lx = lm / (m*m); + setVariable("lux", lx); + setVariable("lx", lx); + + // Radioactivity + // --- honors Antoine-Henri Becquerel (1852-1908) of France + const double Bq = 1./s; + setVariable("becquerel", Bq); + setVariable("Bq", Bq); + + // --- honors Pierre Curie (1859-1906) of France + // and Marie Sklodowska Curie (1867-1934) of Poland + setVariable("curie", 3.7e+10 * Bq); + setVariable("Ci", 3.7e+10 * Bq); + + // Specific energy + // --- honors Louis Harold Gray, F.R.S. (1905-1965) of England + const double Gy = J / kg; + setVariable("gray", Gy); + setVariable("Gy", Gy); + + // Dose equivalent + const double Sv = J / kg; + setVariable("sievert", Sv); + setVariable("Sv", Sv); + + // ====================================================================== + // + // Selected units: + // + // ====================================================================== + + // Length + + const double mm = milli_ * m; + setVariable("millimeter", mm); + setVariable("mm", mm); + + const double cm = centi_ * m; + setVariable("centimeter", cm); + setVariable("cm", cm); + + setVariable("decimeter", deci_ * m); + + const double km = kilo_ * m; + setVariable("kilometer", km); + setVariable("km", km); + + setVariable("micrometer", micro_ * m); + setVariable("micron", micro_ * m); + setVariable("nanometer", nano_ * m); + + // --- honors Anders Jonas Angstrom (1814-1874) of Sweden + setVariable("angstrom", 1.e-10 * m); + + // --- honors Enrico Fermi (1901-1954) of Italy + setVariable("fermi", 1.e-15 * m); + + // Length^2 + + setVariable("m2", m*m); + setVariable("mm2", mm*mm); + setVariable("cm2", cm*cm); + setVariable("km2", km*km); + + const double barn = 1.e-28 * m*m; + setVariable("barn", barn); + setVariable("millibarn", milli_ * barn); + setVariable("mbarn", milli_ * barn); + setVariable("microbarn", micro_ * barn); + setVariable("nanobarn", nano_ * barn); + setVariable("picobarn", pico_ * barn); + + // LengthL^3 + + setVariable("m3", m*m*m); + setVariable("mm3", mm*mm*mm); + setVariable("cm3", cm*cm*cm); + setVariable("cc", cm*cm*cm); + setVariable("km3", km*km*km); + + const double L = 1.e-3*m*m*m; + setVariable("liter", L); + setVariable("litre", L); + setVariable("L", L); + setVariable("centiliter", centi_ * L); + setVariable("cL", centi_ * L); + setVariable("milliliter", milli_ * L); + setVariable("mL", milli_ * L); + + // Length^-1 + + const double dpt = 1./m; + setVariable("diopter", dpt); + setVariable("dioptre", dpt); + setVariable("dpt", dpt); + + // Mass + + const double g = 0.001*kg; + setVariable("gram", g); + setVariable("g", g); + setVariable("milligram", milli_ * g); + setVariable("mg", milli_ * g); + + // Time + + setVariable("millisecond", milli_ * s); + setVariable("ms", milli_ * s); + setVariable("microsecond", micro_ * s); + setVariable("nanosecond", nano_ * s); + setVariable("ns", nano_ * s); + setVariable("picosecond", pico_ * s); + + // Current + + setVariable("milliampere", milli_ * A); + setVariable("mA", milli_ * A); + setVariable("microampere", micro_ * A); + setVariable("nanoampere", nano_ * A); + + // Frequency + + setVariable("kilohertz", kilo_ * Hz); + setVariable("kHz", kilo_ * Hz); + setVariable("megahertz", mega_ * Hz); + setVariable("MHz", mega_ * Hz); + + // Force + setVariable("kilonewton", kilo_ * N); + setVariable("kN", kilo_ * N); + + // Pressure + setVariable("kilobar", kilo_ * bar); + setVariable("kbar", kilo_ * bar); + setVariable("millibar", milli_ * bar); + setVariable("mbar", milli_ * bar); + + // Energy + setVariable("kilojoule", kilo_ * J); + setVariable("kJ", kilo_ * J); + setVariable("megajoule", mega_ * J); + setVariable("MJ", mega_ * J); + setVariable("gigajoule", giga_ * J); + setVariable("GJ", giga_ * J); + + const double e_SI = 1.60217733e-19; // positron charge in coulomb + const double ePlus = e_SI * C; // positron charge + const double eV = ePlus * V; + setVariable("electronvolt", eV); + setVariable("eV", eV); + setVariable("kiloelectronvolt", kilo_ * eV); + setVariable("keV", kilo_ * eV); + setVariable("megaelectronvolt", mega_ * eV); + setVariable("MeV", mega_ * eV); + setVariable("gigaelectronvolt", giga_ * eV); + setVariable("GeV", giga_ * eV); + setVariable("teraelectronvolt", tera_ * eV); + setVariable("TeV", tera_ * eV); + setVariable("petaelectronvolt", peta_ * eV); + setVariable("PeV", peta_ * eV); + + // Power + setVariable("kilowatt", kilo_ * W); + setVariable("kW", kilo_ * W); + setVariable("megawatt", mega_ * W); + setVariable("MW", mega_ * W); + setVariable("gigawatt", giga_ * W); + setVariable("GW", giga_ * W); + + // Electric potential + setVariable("kilovolt", kilo_ * V); + setVariable("kV", kilo_ * V); + setVariable("megavolt", mega_ * V); + setVariable("MV", mega_ * V); + + // Electric capacitance + setVariable("millifarad", milli_ * F); + setVariable("mF", milli_ * F); + setVariable("microfarad", micro_ * F); + setVariable("uF", micro_ * F); + setVariable("nanofarad", nano_ * F); + setVariable("nF", nano_ * F); + setVariable("picofarad", pico_ * F); + setVariable("pF", pico_ * F); + + // Magnetic flux density + setVariable("kilogauss", kilo_ * Gs); + setVariable("kGs", kilo_ * Gs); + } } // namespace XmlTools diff --git a/DDCore/src/ExpressionEvaluator.cpp b/DDCore/src/ExpressionEvaluator.cpp index 829a6f3787d79a28f6a33ff4a01382b76c494804..9bc741e94d4dde9be3a35109ed1b576f660e5611 100644 --- a/DDCore/src/ExpressionEvaluator.cpp +++ b/DDCore/src/ExpressionEvaluator.cpp @@ -48,7 +48,7 @@ namespace DD4hep { XmlTools::Evaluator& g4Evaluator() { static XmlTools::Evaluator* e = 0; if ( !e ) { - static XmlTools::Evaluator ev; + static XmlTools::Evaluator ev; _init(ev); _g4Units(ev); e = &ev; diff --git a/DDCore/src/FieldTypes.cpp b/DDCore/src/FieldTypes.cpp index 9e4e16e803244e82496be3a7a6d3390dccb98da0..c10fa1275c8b3b551ecc744e88c32f1285b49300 100644 --- a/DDCore/src/FieldTypes.cpp +++ b/DDCore/src/FieldTypes.cpp @@ -32,15 +32,15 @@ void ConstantField::fieldComponents(const double* /* pos */, double* field) { /// Initializing constructor SolenoidField::SolenoidField() - : innerField(0), outerField(0), minZ(-INFINITY), maxZ(INFINITY), innerRadius(0), outerRadius(INFINITY) { + : innerField(0), outerField(0), minZ(-INFINITY), maxZ(INFINITY), innerRadius(0), outerRadius(INFINITY) { type = CartesianField::MAGNETIC; } /// Call to access the field components at a given location void SolenoidField::fieldComponents(const double* pos, double* field) { double z = pos[2] ; -// std::cout << " field z=" << z << " maxZ=" << maxZ << " minZ = " << minZ << std::endl ; - if( z > minZ && z < maxZ ){ + // std::cout << " field z=" << z << " maxZ=" << maxZ << " minZ = " << minZ << std::endl ; + if( z > minZ && z < maxZ ){ double radius = sqrt(pos[0] * pos[0] + pos[1] * pos[1]); if (radius < innerRadius) field[2] += innerField; @@ -51,7 +51,7 @@ void SolenoidField::fieldComponents(const double* pos, double* field) { /// Initializing constructor DipoleField::DipoleField() - : zmax(INFINITY), zmin(-INFINITY), rmax(INFINITY) { + : zmax(INFINITY), zmin(-INFINITY), rmax(INFINITY) { type = CartesianField::MAGNETIC; } diff --git a/DDCore/src/Fields.cpp b/DDCore/src/Fields.cpp index 034516266edde03838fff10640adc021d4f38750..cfbcf4c123c4de605dd2600a0f05c3bde4eb89e9 100644 --- a/DDCore/src/Fields.cpp +++ b/DDCore/src/Fields.cpp @@ -29,7 +29,7 @@ namespace { /// Default constructor CartesianField::Object::Object() - : NamedObject(), type(UNKNOWN) { + : NamedObject(), type(UNKNOWN) { InstanceCount::increment(this); } @@ -54,8 +54,8 @@ CartesianField::Properties& CartesianField::properties() const { } /// Returns the 3 field components (x, y, z). -void CartesianField::value(const Position& pos, Direction& field) const { - value(pos,(double*)&field); +void CartesianField::value(const Position& pos, Direction& field) const { + value(pos,(double*)&field); } /// Returns the 3 field components (x, y, z). @@ -70,7 +70,7 @@ void CartesianField::value(const double* pos, double* val) const { /// Default constructor OverlayedField::Object::Object() - : type(0), electric(), magnetic() { + : type(0), electric(), magnetic() { InstanceCount::increment(this); } @@ -81,7 +81,7 @@ OverlayedField::Object::~Object() { /// Object constructor OverlayedField::OverlayedField(const string& name) - : Ref_t() { + : Ref_t() { assign(new Object(), name, "overlay_field"); } diff --git a/DDCore/src/GeoHandler.cpp b/DDCore/src/GeoHandler.cpp index 684d98efbb5841f72c7d4a66a3a020d620434a0d..aa63582782287310a7a074983baf005f9bc554c3 100644 --- a/DDCore/src/GeoHandler.cpp +++ b/DDCore/src/GeoHandler.cpp @@ -26,7 +26,7 @@ using namespace std; namespace { void collectSolid(GeoHandler::GeometryInfo& geo, const string& name, const string& node, TGeoShape* shape, - TGeoMatrix* matrix) { + TGeoMatrix* matrix) { if (0 == ::strncmp(shape->GetName(), "TGeo", 4)) { shape->SetName(name.c_str()); } diff --git a/DDCore/src/GeometryTreeDump.cpp b/DDCore/src/GeometryTreeDump.cpp index b88916810dc273ec3fb2be7bb57ada0bb8792e4e..02d4d8976168ab32e0caac89fe1a0ad47cb1778b 100644 --- a/DDCore/src/GeometryTreeDump.cpp +++ b/DDCore/src/GeometryTreeDump.cpp @@ -104,46 +104,46 @@ void* GeometryTreeDump::handleSolid(const string& name, const TGeoShape* shape) if (shape->IsA() == TGeoBBox::Class()) { const TGeoBBox* s = (const TGeoBBox*) shape; m_output << "\t\t<box name=\"" << name << "_shape\" x=\"" << s->GetDX() << "\" y=\"" << s->GetDY() << "\" z=\"" - << s->GetDZ() << "\" lunit=\"cm\"/>" << endl; + << s->GetDZ() << "\" lunit=\"cm\"/>" << endl; } else if (shape->IsA() == TGeoTube::Class()) { const TGeoTube* s = (const TGeoTube*) shape; m_output << "\t\t<tube name=\"" << name << "_shape\" rmin=\"" << s->GetRmin() << "\" rmax=\"" << s->GetRmax() << "\" z=\"" - << s->GetDz() << "\" startphi=\"0.0\" deltaphi=\"360.0\" aunit=\"deg\" lunit=\"cm\"/>" << endl; + << s->GetDz() << "\" startphi=\"0.0\" deltaphi=\"360.0\" aunit=\"deg\" lunit=\"cm\"/>" << endl; } else if (shape->IsA() == TGeoTubeSeg::Class()) { const TGeoTubeSeg* s = (const TGeoTubeSeg*) shape; m_output << "\t\t<tube name=\"" << name << "_shape\" rmin=\"" << s->GetRmin() << "\" rmax=\"" << s->GetRmax() << "\" z=\"" - << s->GetDz() << "\" startphi=\"" << s->GetPhi1() << "\" deltaphi=\"" << s->GetPhi2() - << "\" aunit=\"deg\" lunit=\"cm\"/>" << endl; + << s->GetDz() << "\" startphi=\"" << s->GetPhi1() << "\" deltaphi=\"" << s->GetPhi2() + << "\" aunit=\"deg\" lunit=\"cm\"/>" << endl; } else if (shape->IsA() == TGeoTrd1::Class()) { const TGeoTrd1* s = (const TGeoTrd1*) shape; m_output << "\t\t<tube name=\"" << name << "_shape\" x1=\"" << s->GetDx1() << "\" x2=\"" << s->GetDx2() << "\" y1=\"" - << s->GetDy() << "\" y2=\"" << s->GetDy() << "\" z=\"" << s->GetDz() << "\" lunit=\"cm\"/>" << endl; + << s->GetDy() << "\" y2=\"" << s->GetDy() << "\" z=\"" << s->GetDz() << "\" lunit=\"cm\"/>" << endl; } else if (shape->IsA() == TGeoTrd2::Class()) { const TGeoTrd2* s = (const TGeoTrd2*) shape; m_output << "\t\t<tube name=\"" << name << "_shape\" x1=\"" << s->GetDx1() << "\" x2=\"" << s->GetDx2() << "\" y1=\"" - << s->GetDy1() << "\" y2=\"" << s->GetDy2() << "\" z=\"" << s->GetDz() << "\" lunit=\"cm\"/>" << endl; + << s->GetDy1() << "\" y2=\"" << s->GetDy2() << "\" z=\"" << s->GetDz() << "\" lunit=\"cm\"/>" << endl; } else if (shape->IsA() == TGeoPgon::Class()) { const TGeoPgon* s = (const TGeoPgon*) shape; m_output << "\t\t<polyhedra name=\"" << name << "_shape\" startphi=\"" << s->GetPhi1() << "\" deltaphi=\"" << s->GetDphi() - << "\" numsides=\"" << s->GetNedges() << "\" aunit=\"deg\" lunit=\"cm\">" << endl; + << "\" numsides=\"" << s->GetNedges() << "\" aunit=\"deg\" lunit=\"cm\">" << endl; for (int i = 0; i < s->GetNz(); ++i) { m_output << "\t\t\t<zplane z=\"" << s->GetZ(i) << "\" rmin=\"" << s->GetRmin(i) << "\" rmax=\"" << s->GetRmax(i) - << "\" lunit=\"cm\"/>" << endl; + << "\" lunit=\"cm\"/>" << endl; } m_output << "\t\t</polyhedra>" << endl; } else if (shape->IsA() == TGeoPcon::Class()) { const TGeoPcon* s = (const TGeoPcon*) shape; m_output << "\t\t<polycone name=\"" << name << "_shape\" startphi=\"" << s->GetPhi1() << "\" deltaphi=\"" << s->GetDphi() - << "\" aunit=\"deg\" lunit=\"cm\">" << endl; + << "\" aunit=\"deg\" lunit=\"cm\">" << endl; for (int i = 0; i < s->GetNz(); ++i) { m_output << "\t\t\t<zplane z=\"" << s->GetZ(i) << "\" rmin=\"" << s->GetRmin(i) << "\" rmax=\"" << s->GetRmax(i) - << "\" lunit=\"cm\"/>" << endl; + << "\" lunit=\"cm\"/>" << endl; } m_output << "\t\t</polycone>" << endl; } @@ -235,7 +235,7 @@ void GeometryTreeDump::handleDefines(const LCDD::HandleMap& defs) const { m_output << "\t<define>" << endl; for (LCDD::HandleMap::const_iterator i = defs.begin(); i != defs.end(); ++i) m_output << "\t\t<constant name=\"" << (*i).second->name << "\" value=\"" << (*i).second->type << "\" />" - << endl; + << endl; m_output << "\t</define>" << endl; } diff --git a/DDCore/src/Handle.cpp b/DDCore/src/Handle.cpp index 7b39fa7b7bf5c6efaca251b4339a84ce0d859ce0..9b4de410c2e354f3b1ebf2b104f10d17a155f488 100644 --- a/DDCore/src/Handle.cpp +++ b/DDCore/src/Handle.cpp @@ -173,8 +173,8 @@ namespace DD4hep { const char* edge = "++++++++++++++++++++++++++++++++++++++++++"; size_t len = ::strlen(name); cerr << edge << edge << edge << endl; - cerr << "++ The usage of the factory: \"" << name << "\" is DEPRECATED due to naming conventions." - << setw(53-len) << right << "++" << endl; + cerr << "++ The usage of the factory: \"" << name << "\" is DEPRECATED due to naming conventions." + << setw(53-len) << right << "++" << endl; cerr << "++ Please use \"DD4hep_" << name << "\" instead." << setw(93-len) << right << "++" << endl; cerr << edge << edge << edge << endl; } diff --git a/DDCore/src/InstanceCount.cpp b/DDCore/src/InstanceCount.cpp index 86dd570c371e10a615f41b8608818b078f81f39c..6801fdc01375292ecdfb43b7d869a64e4ef0520d 100644 --- a/DDCore/src/InstanceCount.cpp +++ b/DDCore/src/InstanceCount.cpp @@ -92,33 +92,33 @@ InstanceCount::Counter* InstanceCount::getCounter(const std::string& typ) { /// Increment count according to string information void InstanceCount::increment(const std::string& typ) { - if ( s_global ) + if ( s_global ) getCounter(typ)->increment(); - else + else on_exit_destructors(); } /// Decrement count according to string information void InstanceCount::decrement(const std::string& typ) { - if ( s_global ) + if ( s_global ) getCounter(typ)->decrement(); - else + else on_exit_destructors(); } /// Increment count according to type information void InstanceCount::increment(const std::type_info& typ) { - if ( s_global ) + if ( s_global ) getCounter(typ)->increment(); - else + else on_exit_destructors(); } /// Decrement count according to type information void InstanceCount::decrement(const std::type_info& typ) { - if ( s_global ) + if ( s_global ) getCounter(typ)->decrement(); - else + else on_exit_destructors(); } @@ -134,10 +134,10 @@ void InstanceCount::dump(int typ) { std::cout << "| Total | Max | Leaking | Type identifier |" << std::endl; std::cout << "+----------+------+---------+-------------------------------------------+" << std::endl; for (i = s_strCounts->begin(); i != s_strCounts->end(); ++i) { - std::cout << "|" << std::setw(10) << (*i).second->total() - << "|" << std::setw(6) << (*i).second->maximum() - << "|" << std::setw(9) << (*i).second->value() - << "|" << (*i).first << std::endl; + std::cout << "|" << std::setw(10) << (*i).second->total() + << "|" << std::setw(6) << (*i).second->maximum() + << "|" << std::setw(9) << (*i).second->value() + << "|" << (*i).first << std::endl; } need_footer = true; } @@ -151,10 +151,10 @@ void InstanceCount::dump(int typ) { std::cout << "| Total | Max | Leaking | Type identifier |" << std::endl; std::cout << "+----------+------+---------+-------------------------------------------+" << std::endl; for (i = s_typCounts->begin(); i != s_typCounts->end(); ++i) { - std::cout << "|" << std::setw(10) << (*i).second->total() - << "|" << std::setw(6) << (*i).second->maximum() - << "|" << std::setw(9) << (*i).second->value() - << "|" << typeName(*((*i).first)) << std::endl; + std::cout << "|" << std::setw(10) << (*i).second->total() + << "|" << std::setw(6) << (*i).second->maximum() + << "|" << std::setw(9) << (*i).second->value() + << "|" << typeName(*((*i).first)) << std::endl; } need_footer = true; } diff --git a/DDCore/src/LCDDData.cpp b/DDCore/src/LCDDData.cpp index 8ce88405ba0087c319d2b23030ede95703925366..69841326c93574539e1f3e956e8ea5dedec94703 100644 --- a/DDCore/src/LCDDData.cpp +++ b/DDCore/src/LCDDData.cpp @@ -24,8 +24,8 @@ using namespace std; /// Default constructor LCDDData::LCDDData() - : m_manager(0), m_world(), m_trackers(), m_worldVol(), - m_trackingVol(), m_field("global"), + : m_manager(0), m_world(), m_trackers(), m_worldVol(), + m_trackingVol(), m_field("global"), m_extensions(typeid(LCDDData)), m_volManager() { InstanceCount::increment(this); @@ -62,7 +62,7 @@ void LCDDData::destroyData(bool destroy_mgr) { m_materialVacuum.clear(); m_materialAir.clear(); - if ( destroy_mgr ) + if ( destroy_mgr ) deletePtr(m_manager); else { gGeoManager = m_manager; diff --git a/DDCore/src/LCDDImp.cpp b/DDCore/src/LCDDImp.cpp index 4cbad73a5f30a86d4d4dc6ca055351e15b53feb5..9e34b39bd7b73f4759d6dcb4f35eef34b625ad9a 100644 --- a/DDCore/src/LCDDImp.cpp +++ b/DDCore/src/LCDDImp.cpp @@ -50,7 +50,7 @@ namespace { struct TypePreserve { LCDDBuildType& m_t; TypePreserve(LCDDBuildType& t) - : m_t(t) { + : m_t(t) { } ~TypePreserve() { m_t = BUILD_NONE; @@ -64,17 +64,17 @@ void lcdd_unexpected(){ throw ; }catch( std::exception& e){ std::cout << "\n" - << "**************************************************** \n" + << "**************************************************** \n" << "* A runtime error has occured : \n" << "* " << e.what() << std::endl - << "* the program will have to be terminated - sorry. \n" + << "* the program will have to be terminated - sorry. \n" << "**************************************************** \n" << std::endl ; std::set_unexpected( std::unexpected ) ; std::set_terminate( std::terminate ) ; - // this provokes ROOT seg fault and stack trace (comment out to avoid it) - exit(1) ; + // this provokes ROOT seg fault and stack trace (comment out to avoid it) + exit(1) ; } } @@ -212,7 +212,7 @@ Handle<TObject> LCDDImp::getRefChild(const HandleMap& e, const string& name, boo if (do_throw) { int cnt = 0; cout << "GetRefChild: Failed to find child with name: " << name - << " Map contains " << e.size() << " elements." << endl; + << " Map contains " << e.size() << " elements." << endl; for(i=e.begin(); i!=e.end(); ++i) cout << " " << cnt << " " << (*i).first << endl; throw runtime_error("Cannot find a child with the reference name:" + name); @@ -239,7 +239,7 @@ namespace { TGeoVolume* v = n->GetVolume(); TGeoShape* s = v->GetShape(); const char* sn = s->GetName(); - ::snprintf(text,sizeof(text),"_shape_%p",(void*)s); + ::snprintf(text,sizeof(text),"_shape_%p",(void*)s); if (0 == sn || 0 == ::strlen(sn)) { nam = v->GetName(); nam += text; @@ -310,8 +310,8 @@ void LCDDImp::init() { if (!m_world.isValid()) { TGeoManager* mgr = m_manager; Box worldSolid("world_x", "world_y", "world_z"); - printout(INFO,"LCDD"," *********** created World volume with size : %7.0f %7.0f %7.0f", - worldSolid->GetDX(), worldSolid->GetDY(), worldSolid->GetDZ()); + printout(INFO,"LCDD"," *********** created World volume with size : %7.0f %7.0f %7.0f", + worldSolid->GetDX(), worldSolid->GetDY(), worldSolid->GetDZ()); m_materialAir = material("Air"); m_materialVacuum = material("Vacuum"); @@ -376,8 +376,8 @@ void LCDDImp::apply(const char* factory_type, int argc, char** argv) { PluginDebug dbg; result = PluginService::Create<long>(fac, (LCDD*) this, argc, argv); if ( 0 == result ) { - throw runtime_error("DD4hep: apply-plugin: Failed to locate plugin " + - fac + ". " + dbg.missingFactory(fac)); + throw runtime_error("DD4hep: apply-plugin: Failed to locate plugin " + + fac + ". " + dbg.missingFactory(fac)); } } result = *(long*) result; diff --git a/DDCore/src/LCDDImp.h b/DDCore/src/LCDDImp.h index fd56e8b71265568bddd2241fd0287616e1ee45a5..b77def98e875e397a9aa73046607b3e732f49fa1 100644 --- a/DDCore/src/LCDDImp.h +++ b/DDCore/src/LCDDImp.h @@ -41,7 +41,7 @@ namespace DD4hep { public: - /// Local method (no interface): Load volume manager. + /// Local method (no interface): Load volume manager. void imp_loadVolumeManager(); /// VolumeManager m_volManager; diff --git a/DDCore/src/LCDDLoad.cpp b/DDCore/src/LCDDLoad.cpp index 72da881b197055b875ecc62e18098878bb82aa74..b1ae24fc51c0cef55f6d350580ed28c1562f0eac 100644 --- a/DDCore/src/LCDDLoad.cpp +++ b/DDCore/src/LCDDLoad.cpp @@ -82,7 +82,7 @@ void LCDDLoad::processXMLElement(const std::string& xmlfile, const XML::Handle_t result = PluginService::Create<long>(type, m_lcdd, &xml_root); if ( 0 == result ) { throw runtime_error("DD4hep: Failed to locate plugin to interprete files of type" - " \"" + tag + "\" - no factory:" + type + ". " + dbg.missingFactory(type)); + " \"" + tag + "\" - no factory:" + type + ". " + dbg.missingFactory(type)); } } result = *(long*) result; diff --git a/DDCore/src/MatrixHelpers.cpp b/DDCore/src/MatrixHelpers.cpp index 7ffcea6057e0bdde5e55b36cc626a8edda3139a0..d112c0f16e9a9932a26894c50194833aa5f3c308 100644 --- a/DDCore/src/MatrixHelpers.cpp +++ b/DDCore/src/MatrixHelpers.cpp @@ -77,17 +77,17 @@ DD4hep::Geometry::Transform3D DD4hep::Geometry::_transform(const TGeoMatrix* mat if ( matrix->IsRotation() ) { const Double_t* r = matrix->GetRotationMatrix(); return Transform3D(r[0],r[1],r[2],t[0]*MM_2_CM, - r[3],r[4],r[5],t[1]*MM_2_CM, - r[6],r[7],r[8],t[2]*MM_2_CM); + r[3],r[4],r[5],t[1]*MM_2_CM, + r[6],r[7],r[8],t[2]*MM_2_CM); #if 0 return Transform3D(r[0],r[3],r[6],t[0]*MM_2_CM, - r[1],r[4],r[7],t[1]*MM_2_CM, - r[2],r[5],r[8],t[2]*MM_2_CM); + r[1],r[4],r[7],t[1]*MM_2_CM, + r[2],r[5],r[8],t[2]*MM_2_CM); #endif } return Transform3D(0e0,0e0,0e0,t[0]*MM_2_CM, - 0e0,0e0,0e0,t[1]*MM_2_CM, - 0e0,0e0,0e0,t[2]*MM_2_CM); + 0e0,0e0,0e0,t[1]*MM_2_CM, + 0e0,0e0,0e0,t[2]*MM_2_CM); } DD4hep::Geometry::XYZAngles DD4hep::Geometry::_XYZangles(const TGeoMatrix* m) { diff --git a/DDCore/src/NamedObject.cpp b/DDCore/src/NamedObject.cpp index e32ea82ce69edc9fe5e72d9991079cc7a9dbdc8e..985267cc05e92b6331e3e3c5c8d90b49cfaa9871 100644 --- a/DDCore/src/NamedObject.cpp +++ b/DDCore/src/NamedObject.cpp @@ -23,8 +23,8 @@ NamedObject::NamedObject() { } /// Initializing constructor -NamedObject::NamedObject(const char* nam, const char* typ) - : name(nam ? nam : ""), type(typ ? typ : "") +NamedObject::NamedObject(const char* nam, const char* typ) + : name(nam ? nam : ""), type(typ ? typ : "") { } diff --git a/DDCore/src/ObjectExtensions.cpp b/DDCore/src/ObjectExtensions.cpp index 0eefb3a88d1998940d3836cb7f09552cabf6a253..5b28528c580ace3efb3c922152c00e0c87fe48c2 100644 --- a/DDCore/src/ObjectExtensions.cpp +++ b/DDCore/src/ObjectExtensions.cpp @@ -94,9 +94,9 @@ void* ObjectExtensions::removeExtension(const std::type_info& info, bool destroy if ( destroy ) { ExtensionMap::iterator i = extensionMap->find(&info); if (i != extensionMap->end()) { - Entry& e = (*i).second; - (*e.destruct)((*j).second); - ptr = 0; + Entry& e = (*i).second; + (*e.destruct)((*j).second); + ptr = 0; } } extensions.erase(j); @@ -120,7 +120,7 @@ void* ObjectExtensions::extension(const std::type_info& info, bool alert) const if (j != extensions.end()) { return (*j).second; } - else if ( !alert ) + else if ( !alert ) return 0; throw std::runtime_error("DD4hep: extension: Object has no extension of type:" + typeName(info) + "."); } diff --git a/DDCore/src/Objects.cpp b/DDCore/src/Objects.cpp index b16e8490ca1dfb44d5fa94d41bb5ddc293a550ef..d4f457c1928959aa8170a08b4f36bec689555fcc 100644 --- a/DDCore/src/Objects.cpp +++ b/DDCore/src/Objects.cpp @@ -203,7 +203,7 @@ double Material::density() const { } throw runtime_error("DD4hep: Attempt to access density from invalid material handle!"); } - + /// Access the radiation length of the underlying material double Material::radLength() const { Handle < TGeoMedium > val(*this); @@ -341,8 +341,8 @@ string VisAttr::toString() const { TColor* col = gROOT->GetColor(obj->color); char text[256]; ::snprintf(text, sizeof(text), "%-20s RGB:%-8s [%d] %7.2f Style:%d %d ShowDaughters:%3s Visible:%3s", ptr()->GetName(), - col->AsHexString(), obj->color, col->GetAlpha(), int(obj->drawingStyle), int(obj->lineStyle), - yes_no(obj->showDaughters), yes_no(obj->visible)); + col->AsHexString(), obj->color, col->GetAlpha(), int(obj->drawingStyle), int(obj->lineStyle), + yes_no(obj->showDaughters), yes_no(obj->visible)); return text; } @@ -495,7 +495,7 @@ struct IDSpec : public Ref_t { }; IDSpec::IDSpec(LCDD& lcdd, const string& name, const IDDescriptor& dsc) -: RefElement(doc,Tag_idspec,name) + : RefElement(doc,Tag_idspec,name) { const IDDescriptor::FieldIDs& f = dsc.ids(); const IDDescriptor::FieldMap& m = dsc.fields(); diff --git a/DDCore/src/ObjectsInterna.cpp b/DDCore/src/ObjectsInterna.cpp index f7d0a4a2f1a02015c6278b26e7cad86da4fc9ca9..cad475f004582d18cfb1cb891f5b437b40414ee9 100644 --- a/DDCore/src/ObjectsInterna.cpp +++ b/DDCore/src/ObjectsInterna.cpp @@ -19,7 +19,7 @@ DD4HEP_INSTANTIATE_HANDLE_NAMED(VisAttrObject); /// Standard constructor VisAttrObject::VisAttrObject() -: magic(magic_word()), col(0), color(0), alpha(0), drawingStyle(VisAttr::SOLID), lineStyle(VisAttr::SOLID), showDaughters(true), visible(true) { + : magic(magic_word()), col(0), color(0), alpha(0), drawingStyle(VisAttr::SOLID), lineStyle(VisAttr::SOLID), showDaughters(true), visible(true) { InstanceCount::increment(this); } @@ -32,7 +32,7 @@ DD4HEP_INSTANTIATE_HANDLE_NAMED(HeaderObject); /// Standard constructor HeaderObject::HeaderObject() - : NamedObject() { + : NamedObject() { InstanceCount::increment(this); } @@ -58,7 +58,7 @@ ConstantObject::~ConstantObject() { DD4HEP_INSTANTIATE_HANDLE_NAMED(RegionObject); /// Standard constructor -RegionObject::RegionObject() +RegionObject::RegionObject() : magic(magic_word()), threshold(10.0), cut(10.0), store_secondaries(false) { InstanceCount::increment(this); @@ -102,13 +102,13 @@ DD4HEP_INSTANTIATE_HANDLE_NAMED(IDDescriptorObject); /// Standard constructor IDDescriptorObject::IDDescriptorObject() - : NamedObject(), BitField64() /*, maxBit(0) */{ + : NamedObject(), BitField64() /*, maxBit(0) */{ InstanceCount::increment(this); } /// Standard constructor IDDescriptorObject::IDDescriptorObject(const std::string& desc) - : NamedObject(), BitField64(desc) /*, maxBit(0) */{ + : NamedObject(), BitField64(desc) /*, maxBit(0) */{ InstanceCount::increment(this); } diff --git a/DDCore/src/Plugins.cpp b/DDCore/src/Plugins.cpp index 95a041b2fc7dde4e51278e9e815e0d548c0b6c5e..bb2b494242b2d53be6e5616f21f9a7e598027ec6 100644 --- a/DDCore/src/Plugins.cpp +++ b/DDCore/src/Plugins.cpp @@ -16,7 +16,7 @@ using namespace ROOT::Reflex; /// Default constructor PluginDebug::PluginDebug(int dbg) - : m_debug(0) { + : m_debug(0) { m_debug = PluginService::Debug(); PluginService::SetDebug(dbg); } diff --git a/DDCore/src/Primitives.cpp b/DDCore/src/Primitives.cpp index 7ef516706e4ceb2aa269d9bd7b5f887b8b08cd5b..3b151e4ffcb1a0dcfce70eecc52f21bfb2315559 100644 --- a/DDCore/src/Primitives.cpp +++ b/DDCore/src/Primitives.cpp @@ -174,7 +174,7 @@ void DD4hep::typeinfoCheck(const std::type_info& typ1, const std::type_info& typ /// Initializing Constructor DD4hep::ComponentCast::ComponentCast(const std::type_info& t, destroy_t d, cast_t c) - : type(t), destroy(d), cast(c) { +: type(t), destroy(d), cast(c) { #ifdef __APPLE__ abi_class = 0; #else @@ -199,16 +199,16 @@ DD4hep::ComponentCast::~ComponentCast() { // -3: src_type is a multiple public non-virtual base of dst_type extern "C" void* __dynamic_cast(const void* __src_ptr,// Starting object. - const abi::__class_type_info* __src_type,// Static type of object. - const abi::__class_type_info* __dst_type,// Desired target type. - ptrdiff_t __src2dst);// How src and dst are related. + const abi::__class_type_info* __src_type,// Static type of object. + const abi::__class_type_info* __dst_type,// Desired target type. + ptrdiff_t __src2dst);// How src and dst are related. #endif #ifndef __APPLE__ static inline void* cast_wrap(const void* p, - const abi::__class_type_info* src, - const abi::__class_type_info* dst, - ptrdiff_t src2dst) + const abi::__class_type_info* src, + const abi::__class_type_info* dst, + ptrdiff_t src2dst) { return abi::__dynamic_cast(p,src,dst,src2dst); } @@ -222,67 +222,67 @@ void* DD4hep::ComponentCast::apply_dynCast(const ComponentCast& to, const void* #ifdef __APPLE__ // First try down cast void *r = (*to.cast)(ptr); - if (r) + if (r) return r; { // Now try the up-cast r = (*cast)(ptr); if (r) return r; #else - void* r = (void*)ptr; - if ( to.abi_class ) { - bool cast_worked = type.__do_upcast((const class_t*)to.abi_class,&r); - if ( cast_worked ) return r; - r = (void*)ptr; - cast_worked = to.type.__do_upcast((const class_t*)abi_class,&r); - if ( cast_worked ) return r; + void* r = (void*)ptr; + if ( to.abi_class ) { + bool cast_worked = type.__do_upcast((const class_t*)to.abi_class,&r); + if ( cast_worked ) return r; + r = (void*)ptr; + cast_worked = to.type.__do_upcast((const class_t*)abi_class,&r); + if ( cast_worked ) return r; #if 0 - const class_t* src_type = (const class_t*)to.abi_class; - if (src_type) { - // First try down cast - void *r = cast_wrap(ptr, src_type, (const class_t*) abi_class, -1); - if ( r ) return r; - // Now try the up-cast - r = cast_wrap(ptr, (const class_t*) abi_class, src_type, -1); - if (r) return r; + const class_t* src_type = (const class_t*)to.abi_class; + if (src_type) { + // First try down cast + void *r = cast_wrap(ptr, src_type, (const class_t*) abi_class, -1); + if ( r ) return r; + // Now try the up-cast + r = cast_wrap(ptr, (const class_t*) abi_class, src_type, -1); + if (r) return r; #endif #endif - throw unrelated_type_error(type, to.type, "Failed to apply abi dynamic cast operation!"); - } - throw unrelated_type_error(type, to.type, "Target type is not an abi class type!"); -} + throw unrelated_type_error(type, to.type, "Failed to apply abi dynamic cast operation!"); + } + throw unrelated_type_error(type, to.type, "Target type is not an abi class type!"); + } -/// Apply cast using typeinfo instead of dynamic_cast -void* DD4hep::ComponentCast::apply_upCast(const ComponentCast& to, const void* ptr) const { - if (&to == this) { - return (void*) ptr; - } - return apply_dynCast(to, ptr); -} + /// Apply cast using typeinfo instead of dynamic_cast + void* DD4hep::ComponentCast::apply_upCast(const ComponentCast& to, const void* ptr) const { + if (&to == this) { + return (void*) ptr; + } + return apply_dynCast(to, ptr); + } -/// Apply cast using typeinfo instead of dynamic_cast -void* DD4hep::ComponentCast::apply_downCast(const ComponentCast& to, const void* ptr) const { - if (&to == this) { - return (void*) ptr; - } + /// Apply cast using typeinfo instead of dynamic_cast + void* DD4hep::ComponentCast::apply_downCast(const ComponentCast& to, const void* ptr) const { + if (&to == this) { + return (void*) ptr; + } #ifdef __APPLE__ - void *r = (*to.cast)(ptr); - if (r) return r; - { + void *r = (*to.cast)(ptr); + if (r) return r; + { #else - if ( to.abi_class ) { - // Since we have to cast a 'to' pointer up to the real pointer - // no virtual inheritance can be supported! - void* r = (void*)ptr; - bool cast_worked = type.__do_upcast((const class_t*)to.abi_class,&r); - if ( cast_worked ) return r; + if ( to.abi_class ) { + // Since we have to cast a 'to' pointer up to the real pointer + // no virtual inheritance can be supported! + void* r = (void*)ptr; + bool cast_worked = type.__do_upcast((const class_t*)to.abi_class,&r); + if ( cast_worked ) return r; #if 0 - void *r = cast_wrap(ptr, src_type, (const class_t*)abi_class, -1); - if (r) return r; + void *r = cast_wrap(ptr, src_type, (const class_t*)abi_class, -1); + if (r) return r; #endif #endif - throw unrelated_type_error(type, to.type, "Failed to apply abi dynamic cast operation!"); - } - throw unrelated_type_error(type, to.type, "Target type is not an abi class type!"); -} + throw unrelated_type_error(type, to.type, "Failed to apply abi dynamic cast operation!"); + } + throw unrelated_type_error(type, to.type, "Target type is not an abi class type!"); + } diff --git a/DDCore/src/Printout.cpp b/DDCore/src/Printout.cpp index dbd3bbb8753337b385ddd68c503f70763b885b32..d6de1b0b02b8bbe2c06cde3286cf3b50a7ef476b 100644 --- a/DDCore/src/Printout.cpp +++ b/DDCore/src/Printout.cpp @@ -224,7 +224,7 @@ namespace DD4hep { template <> void Printer<RotationZYX>::operator()(const RotationZYX& val) const { printout(INFO, "Printer", "%s ++ ZYXRotation: phi: %7.3 rad theta: %7.3 rad psi: %7.3 rad", prefix.c_str(), val.Phi(), - val.Theta(), val.Psi()); + val.Theta(), val.Psi()); } template <> void Printer<Position>::operator()(const Position& val) const { @@ -237,7 +237,7 @@ namespace DD4hep { val->TNamed::Print(); for (set<Limit>::const_iterator i = o.begin(); i != o.end(); ++i) { os << "++ Limit:" << (*i).name << " " << (*i).particles << " [" << (*i).unit << "] " << (*i).content << " " - << (*i).value << endl; + << (*i).value << endl; } } @@ -251,8 +251,8 @@ namespace DD4hep { bool env = plc.isValid(); bool mat = plc.isValid(); ::snprintf(text, sizeof(text), "ID:%-3d Combine Hits:%3s Material:%s Envelope:%s VisAttr:%s", sd.id(), - yes_no(sd.combineHits()), mat ? plc.material().name() : yes_no(mat), - env ? plc.motherVol()->GetName() : yes_no(env), yes_no(vis)); + yes_no(sd.combineHits()), mat ? plc.material().name() : yes_no(mat), + env ? plc.motherVol()->GetName() : yes_no(env), yes_no(vis)); os << prefix << "+= DetElement: " << val.name() << " " << val.type() << endl; os << prefix << "| " << text << endl; @@ -262,9 +262,9 @@ namespace DD4hep { TColor* col = gROOT->GetColor(v->color); char text[256]; ::snprintf(text, sizeof(text), " RGB:%-8s [%d] %7.2f Style:%d %d ShowDaughters:%3s Visible:%3s", col->AsHexString(), - v->color, col->GetAlpha(), int(v->drawingStyle), - int(v->lineStyle), yes_no(v->showDaughters), - yes_no(v->visible)); + v->color, col->GetAlpha(), int(v->drawingStyle), + int(v->lineStyle), yes_no(v->showDaughters), + yes_no(v->visible)); os << prefix << "| VisAttr: " << setw(32) << left << attr.name() << text << endl; } if (plc.isValid()) { @@ -272,7 +272,7 @@ namespace DD4hep { Solid s = vol.solid(); Material m = vol.material(); ::snprintf(text, sizeof(text), "Volume:%s Shape:%s Material:%s", vol->GetName(), s.isValid() ? s.name() : "Unknonw", - m.isValid() ? m->GetName() : "Unknown"); + m.isValid() ? m->GetName() : "Unknown"); os << prefix << "+------------- " << text << endl; } const DetElement::Children& ch = sd.children(); diff --git a/DDCore/src/Shapes.cpp b/DDCore/src/Shapes.cpp index 8e480c79dbba94546b6c5d4b26dbf1915638e83b..428b5b268fb2183bdd58cf3f7377f8300520e86c 100644 --- a/DDCore/src/Shapes.cpp +++ b/DDCore/src/Shapes.cpp @@ -50,9 +50,9 @@ std::string DD4hep::Geometry::toStringSolid(const TGeoShape* shape, int precisio log << cl->GetName(); if ( cl == TGeoBBox::Class() ) { TGeoBBox* s = (TGeoBBox*) shape; - log << " x:" << s->GetDX() - << " y:" << s->GetDY() - << " z:" << s->GetDZ(); + log << " x:" << s->GetDX() + << " y:" << s->GetDY() + << " z:" << s->GetDZ(); } else if (cl == TGeoTube::Class()) { const TGeoTube* s = (const TGeoTube*) shape; @@ -60,8 +60,8 @@ std::string DD4hep::Geometry::toStringSolid(const TGeoShape* shape, int precisio } else if (cl == TGeoTubeSeg::Class()) { const TGeoTubeSeg* s = (const TGeoTubeSeg*) shape; - log << " rmin:" << s->GetRmin() << " rmax:" << s->GetRmax() << " dz:" << s->GetDz() - << " Phi1:" << s->GetPhi1() << " Phi2:" << s->GetPhi2(); + log << " rmin:" << s->GetRmin() << " rmax:" << s->GetRmax() << " dz:" << s->GetDz() + << " Phi1:" << s->GetPhi1() << " Phi2:" << s->GetPhi2(); } else if (cl == TGeoTrd1::Class()) { const TGeoTrd1* s = (const TGeoTrd1*) shape; @@ -69,37 +69,37 @@ std::string DD4hep::Geometry::toStringSolid(const TGeoShape* shape, int precisio } else if (cl == TGeoTrd2::Class()) { const TGeoTrd2* s = (const TGeoTrd2*) shape; - log << " x1:" << s->GetDx1() << " x2:" << s->GetDx2() - << " y1:" << s->GetDy1() << " y2:" << s->GetDy2() << " z:" << s->GetDz(); + log << " x1:" << s->GetDx1() << " x2:" << s->GetDx2() + << " y1:" << s->GetDy1() << " y2:" << s->GetDy2() << " z:" << s->GetDz(); } else if (cl == TGeoHype::Class()) { const TGeoHype* s = (const TGeoHype*) shape; - log << " rmin:" << s->GetRmin() << " rmax:" << s->GetRmax() << " dz:" << s->GetDz() - << " StIn:" << s->GetStIn() << " StOut:" << s->GetStOut(); + log << " rmin:" << s->GetRmin() << " rmax:" << s->GetRmax() << " dz:" << s->GetDz() + << " StIn:" << s->GetStIn() << " StOut:" << s->GetStOut(); } else if (cl == TGeoPgon::Class()) { const TGeoPgon* s = (const TGeoPgon*) shape; - log << " Phi1:" << s->GetPhi1() << " dPhi:" << s->GetDphi() - << " NEdges:" << s->GetNedges() << " Nz:" << s->GetNz(); + log << " Phi1:" << s->GetPhi1() << " dPhi:" << s->GetDphi() + << " NEdges:" << s->GetNedges() << " Nz:" << s->GetNz(); for(int i=0, n=s->GetNz(); i<n; ++i) { - log << " i=" << i << " z:" << s->GetZ(i) - << " r:[" << s->GetRmin(i) << "," << s->GetRmax(i) << "]"; + log << " i=" << i << " z:" << s->GetZ(i) + << " r:[" << s->GetRmin(i) << "," << s->GetRmax(i) << "]"; } } else if (cl == TGeoPcon::Class()) { const TGeoPcon* s = (const TGeoPcon*) shape; log << " Phi1:" << s->GetPhi1() << " dPhi:" << s->GetDphi() << " Nz:" << s->GetNz(); for(int i=0, n=s->GetNz(); i<n; ++i) { - log << " i=" << i << " z:" << s->GetZ(i) - << " r:[" << s->GetRmin(i) << "," << s->GetRmax(i) << "]"; + log << " i=" << i << " z:" << s->GetZ(i) + << " r:[" << s->GetRmin(i) << "," << s->GetRmax(i) << "]"; } } else if (cl == TGeoConeSeg::Class()) { const TGeoConeSeg* s = (const TGeoConeSeg*) shape; log << " rmin1:" << s->GetRmin1() << " rmax1:" << s->GetRmax1() - << " rmin2:" << s->GetRmin2() << " rmax2:" << s->GetRmax2() - << " dz:" << s->GetDz() - << " Phi1:" << s->GetPhi1() << " Phi2:" << s->GetPhi2(); + << " rmin2:" << s->GetRmin2() << " rmax2:" << s->GetRmax2() + << " dz:" << s->GetDz() + << " Phi1:" << s->GetPhi1() << " Phi2:" << s->GetPhi2(); } else if (cl == TGeoParaboloid::Class()) { const TGeoParaboloid* s = (const TGeoParaboloid*) shape; @@ -108,19 +108,19 @@ std::string DD4hep::Geometry::toStringSolid(const TGeoShape* shape, int precisio else if (cl == TGeoSphere::Class()) { const TGeoSphere* s = (const TGeoSphere*) shape; log << " rmin:" << s->GetRmin() << " rmax:" << s->GetRmax() - << " Phi1:" << s->GetPhi1() << " Phi2:" << s->GetPhi2() - << " Theta1:" << s->GetTheta1() << " Theta2:" << s->GetTheta2(); + << " Phi1:" << s->GetPhi1() << " Phi2:" << s->GetPhi2() + << " Theta1:" << s->GetTheta1() << " Theta2:" << s->GetTheta2(); } else if (cl == TGeoTorus::Class()) { const TGeoTorus* s = (const TGeoTorus*) shape; log << " rmin:" << s->GetRmin() << " rmax:" << s->GetRmax() << " r:" << s->GetR() - << " Phi1:" << s->GetPhi1() << " dPhi:" << s->GetDphi(); + << " Phi1:" << s->GetPhi1() << " dPhi:" << s->GetDphi(); } else if (cl == TGeoTrap::Class()) { const TGeoTrap* s = (const TGeoTrap*) shape; log << " dz:" << s->GetDz() << " Theta:" << s->GetTheta() << " Phi:" << s->GetPhi() - << " H1:" << s->GetH1() << " Bl1:" << s->GetBl1() << " Tl1:" << s->GetTl1() << " Alpha1:" << s->GetAlpha1() - << " H2:" << s->GetH2() << " Bl2:" << s->GetBl2() << " Tl2:" << s->GetTl2() << " Alpha2:" << s->GetAlpha2(); + << " H1:" << s->GetH1() << " Bl1:" << s->GetBl1() << " Tl1:" << s->GetTl1() << " Alpha1:" << s->GetAlpha1() + << " H2:" << s->GetH2() << " Bl2:" << s->GetBl2() << " Tl2:" << s->GetTl2() << " Alpha2:" << s->GetAlpha2(); } else if (shape->IsA() == TGeoCompositeShape::Class()) { const TGeoCompositeShape* s = (const TGeoCompositeShape*) shape; @@ -191,7 +191,7 @@ Polycone::Polycone(double start, double delta) { /// Constructor to be used when creating a new polycone object. Add at the same time all Z planes Polycone::Polycone(double start, double delta, const vector<double>& rmin, const vector<double>& rmax, - const vector<double>& z) { + const vector<double>& z) { vector<double> params; if (rmin.size() < 2) { throw runtime_error("DD4hep: PolyCone::addZPlanes> Not enough Z planes. minimum is 2!"); @@ -234,12 +234,12 @@ void Polycone::addZPlanes(const vector<double>& rmin, const vector<double>& rmax /// Constructor to be used when creating a new cone segment object ConeSegment::ConeSegment(double dz, double rmin1, double rmax1, double rmin2, double rmax2, double phi1, double phi2) { _assign( - new TGeoConeSeg(dz, rmin1, rmax1, rmin2, rmax2, phi1/dd4hep::deg, phi2/dd4hep::deg), "", "cone_segment", true); + new TGeoConeSeg(dz, rmin1, rmax1, rmin2, rmax2, phi1/dd4hep::deg, phi2/dd4hep::deg), "", "cone_segment", true); } /// Set the cone segment dimensions ConeSegment& ConeSegment::setDimensions(double dz, double rmin1, double rmax1, double rmin2, double rmax2, double phi1, - double phi2) { + double phi2) { double params[] = { dz, rmin1, rmax1, rmin2, rmax2, phi1/dd4hep::deg, phi2/dd4hep::deg }; _setDimensions(params); return *this; @@ -272,8 +272,8 @@ Cone& Cone::setDimensions(double z, double rmin1, double rmax1, double rmin2, do } /// Constructor to create a new anonymous object with attribute initialization -Trapezoid::Trapezoid(double x1, double x2, double y1, double y2, double z) { - make(x1,x2,y1,y2,z); +Trapezoid::Trapezoid(double x1, double x2, double y1, double y2, double z) { + make(x1,x2,y1,y2,z); } /// Constructor to be used when creating a new object with attribute initialization @@ -308,7 +308,7 @@ Sphere::Sphere(double rmin, double rmax, double theta, double delta_theta, doubl /// Set the Sphere dimensions Sphere& Sphere::setDimensions(double rmin, double rmax, double theta, double delta_theta, double phi, double delta_phi) { double params[] = { rmin, rmax, theta, delta_theta/dd4hep::deg, phi/dd4hep::deg, - delta_phi/dd4hep::deg }; + delta_phi/dd4hep::deg }; _setDimensions(params); return *this; } @@ -327,7 +327,7 @@ Torus& Torus::setDimensions(double r, double rmin, double rmax, double phi, doub /// Constructor to be used when creating a new anonymous object with attribute initialization Trap::Trap(double z, double theta, double phi, double y1, double x1, double x2, double alpha1, double y2, double x3, double x4, - double alpha2) { + double alpha2) { _assign(new TGeoTrap(z, theta, phi, y1, x1, x2, alpha1/dd4hep::deg, y2, x3, x4, alpha2/dd4hep::deg), "", "trap", true); } @@ -345,7 +345,7 @@ void Trap::make(double pz, double py, double px, double pLTX) { /// Set the trap dimensions Trap& Trap::setDimensions(double z, double theta, double phi, double y1, double x1, double x2, double alpha1, double y2, - double x3, double x4, double alpha2) { + double x3, double x4, double alpha2) { double params[] = { z, theta, phi, y1, x1, x2, alpha1/dd4hep::deg, y2, x3, x4, alpha2/dd4hep::deg }; _setDimensions(params); return *this; @@ -353,7 +353,7 @@ Trap& Trap::setDimensions(double z, double theta, double phi, double y1, double /// Helper function to create holy hedron void PolyhedraRegular::_create(const string& name, int nsides, double rmin, double rmax, double zpos, double zneg, double start, - double delta) { + double delta) { if (rmin < 0e0 || rmin > rmax) throw runtime_error("DD4hep: PolyhedraRegular: Illegal argument rmin:<" + _toString(rmin) + "> is invalid!"); else if (rmax < 0e0) diff --git a/DDCore/src/SimpleGDMLWriter.cpp b/DDCore/src/SimpleGDMLWriter.cpp index cca0c80e00bd926098bd9c3a8ff4517c032aee7e..dfc849659f02c5e89d18ba5b113b60a1120fb641 100644 --- a/DDCore/src/SimpleGDMLWriter.cpp +++ b/DDCore/src/SimpleGDMLWriter.cpp @@ -68,8 +68,8 @@ void* SimpleGDMLWriter::handleVolume(const string& name, const TGeoVolume* volum m_output << "\t\t<volume name=\"" << name << "\">" << endl; m_output << "\t\t\t<solidref ref=\"" << shape->GetName() << "\"/>" << endl; - m_output << "\t\t\t<materialref ref=\"" - << (medium ? medium->GetName() : "UnknownMaterial") << "\"/>" << endl; + m_output << "\t\t\t<materialref ref=\"" + << (medium ? medium->GetName() : "UnknownMaterial") << "\"/>" << endl; if (vis.isValid()) { m_output << "\t\t\t<visref ref=\"" << vis.name() << "\"/>" << endl; } @@ -102,46 +102,46 @@ void* SimpleGDMLWriter::handleSolid(const string& name, const TGeoShape* shape) if (shape->IsA() == TGeoBBox::Class()) { const TGeoBBox* s = (const TGeoBBox*) shape; m_output << "\t\t<box name=\"" << name << "_shape\" x=\"" << s->GetDX() << "\" y=\"" << s->GetDY() << "\" z=\"" - << s->GetDZ() << "\" lunit=\"cm\"/>" << endl; + << s->GetDZ() << "\" lunit=\"cm\"/>" << endl; } else if (shape->IsA() == TGeoTube::Class()) { const TGeoTube* s = (const TGeoTube*) shape; m_output << "\t\t<tube name=\"" << name << "_shape\" rmin=\"" << s->GetRmin() << "\" rmax=\"" << s->GetRmax() << "\" z=\"" - << s->GetDz() << "\" startphi=\"0.0\" deltaphi=\"360.0\" aunit=\"deg\" lunit=\"cm\"/>" << endl; + << s->GetDz() << "\" startphi=\"0.0\" deltaphi=\"360.0\" aunit=\"deg\" lunit=\"cm\"/>" << endl; } else if (shape->IsA() == TGeoTubeSeg::Class()) { const TGeoTubeSeg* s = (const TGeoTubeSeg*) shape; m_output << "\t\t<tube name=\"" << name << "_shape\" rmin=\"" << s->GetRmin() << "\" rmax=\"" << s->GetRmax() << "\" z=\"" - << s->GetDz() << "\" startphi=\"" << s->GetPhi1() << "\" deltaphi=\"" << s->GetPhi2() - << "\" aunit=\"deg\" lunit=\"cm\"/>" << endl; + << s->GetDz() << "\" startphi=\"" << s->GetPhi1() << "\" deltaphi=\"" << s->GetPhi2() + << "\" aunit=\"deg\" lunit=\"cm\"/>" << endl; } else if (shape->IsA() == TGeoTrd1::Class()) { const TGeoTrd1* s = (const TGeoTrd1*) shape; m_output << "\t\t<tube name=\"" << name << "_shape\" x1=\"" << s->GetDx1() << "\" x2=\"" << s->GetDx2() << "\" y1=\"" - << s->GetDy() << "\" y2=\"" << s->GetDy() << "\" z=\"" << s->GetDz() << "\" lunit=\"cm\"/>" << endl; + << s->GetDy() << "\" y2=\"" << s->GetDy() << "\" z=\"" << s->GetDz() << "\" lunit=\"cm\"/>" << endl; } else if (shape->IsA() == TGeoTrd2::Class()) { const TGeoTrd2* s = (const TGeoTrd2*) shape; m_output << "\t\t<tube name=\"" << name << "_shape\" x1=\"" << s->GetDx1() << "\" x2=\"" << s->GetDx2() << "\" y1=\"" - << s->GetDy1() << "\" y2=\"" << s->GetDy2() << "\" z=\"" << s->GetDz() << "\" lunit=\"cm\"/>" << endl; + << s->GetDy1() << "\" y2=\"" << s->GetDy2() << "\" z=\"" << s->GetDz() << "\" lunit=\"cm\"/>" << endl; } else if (shape->IsA() == TGeoPgon::Class()) { const TGeoPgon* s = (const TGeoPgon*) shape; m_output << "\t\t<polyhedra name=\"" << name << "_shape\" startphi=\"" << s->GetPhi1() << "\" deltaphi=\"" << s->GetDphi() - << "\" numsides=\"" << s->GetNedges() << "\" aunit=\"deg\" lunit=\"cm\">" << endl; + << "\" numsides=\"" << s->GetNedges() << "\" aunit=\"deg\" lunit=\"cm\">" << endl; for (int i = 0; i < s->GetNz(); ++i) { m_output << "\t\t\t<zplane z=\"" << s->GetZ(i) << "\" rmin=\"" << s->GetRmin(i) << "\" rmax=\"" << s->GetRmax(i) - << "\" lunit=\"cm\"/>" << endl; + << "\" lunit=\"cm\"/>" << endl; } m_output << "\t\t</polyhedra>" << endl; } else if (shape->IsA() == TGeoPcon::Class()) { const TGeoPcon* s = (const TGeoPcon*) shape; m_output << "\t\t<polycone name=\"" << name << "_shape\" startphi=\"" << s->GetPhi1() << "\" deltaphi=\"" << s->GetDphi() - << "\" aunit=\"deg\" lunit=\"cm\">" << endl; + << "\" aunit=\"deg\" lunit=\"cm\">" << endl; for (int i = 0; i < s->GetNz(); ++i) { m_output << "\t\t\t<zplane z=\"" << s->GetZ(i) << "\" rmin=\"" << s->GetRmin(i) << "\" rmax=\"" << s->GetRmax(i) - << "\" lunit=\"cm\"/>" << endl; + << "\" lunit=\"cm\"/>" << endl; } m_output << "\t\t</polycone>" << endl; } @@ -233,7 +233,7 @@ void SimpleGDMLWriter::handleDefines(const LCDD::HandleMap& defs) const { m_output << "\t<define>" << endl; for (LCDD::HandleMap::const_iterator i = defs.begin(); i != defs.end(); ++i) m_output << "\t\t<constant name=\"" << (*i).second->GetName() << "\" value=\"" << (*i).second->GetTitle() << "\" />" - << endl; + << endl; m_output << "\t</define>" << endl; } @@ -273,8 +273,8 @@ void SimpleGDMLWriter::handleVisualisation(const VisRefs& vis) const { if (draw_style) m_output << "drawingStyle=\"" << draw_style << "\" "; m_output << "show_daughters=\"" << (const char*) (v.showDaughters() ? "true" : "false") << "\" " << "visible=\"" - << (const char*) (v.visible() ? "true" : "false") << "\" >" << endl << "\t\t\t<color R=\"" << r << "\" G=\"" << g - << "\" B=\"" << b << "\" alpha=\"" << alpha << "\" />" << endl << "\t\t</vis>" << endl; + << (const char*) (v.visible() ? "true" : "false") << "\" >" << endl << "\t\t\t<color R=\"" << r << "\" G=\"" << g + << "\" B=\"" << b << "\" alpha=\"" << alpha << "\" />" << endl << "\t\t</vis>" << endl; } } m_output << "\t</display>" << endl; diff --git a/DDCore/src/SimpleGDMLWriter.h b/DDCore/src/SimpleGDMLWriter.h index 10106331ee557e60c21dd93dc941bfbacdc40148..3b59a7cf7f88409a9b324e7886ec175bcaf4c1a3 100644 --- a/DDCore/src/SimpleGDMLWriter.h +++ b/DDCore/src/SimpleGDMLWriter.h @@ -34,8 +34,8 @@ namespace DD4hep { /// Reference to output stream std::ostream& m_output; - SimpleGDMLWriter(std::ostream& os) - : m_output(os) { + SimpleGDMLWriter(std::ostream& os) + : m_output(os) { } /// Standard destructor virtual ~SimpleGDMLWriter() { diff --git a/DDCore/src/SurfaceInstaller.cpp b/DDCore/src/SurfaceInstaller.cpp index bc13fbb10893d4202b66c372ff7a78752648ab62..c7e8fe9b72612ab31c9ce0e3d246462be25b5444 100644 --- a/DDCore/src/SurfaceInstaller.cpp +++ b/DDCore/src/SurfaceInstaller.cpp @@ -22,7 +22,7 @@ using namespace DD4hep::Geometry; typedef DetElement::Children _C; /// Initializing constructor -SurfaceInstaller::SurfaceInstaller(LCDD& lcdd, const std::string& det_name) +SurfaceInstaller::SurfaceInstaller(LCDD& lcdd, const std::string& det_name) : m_lcdd(lcdd), m_det() { string n = det_name[0] == '-' ? det_name.substr(1) : det_name; @@ -85,10 +85,10 @@ void SurfaceInstaller::install(DetElement component, PlacedVolume pv) { PlacedVolume placed = *i; log << (void*)(placed->GetMatrix()) << " "; if ( placed->GetUserExtension() ) { - const PlacedVolume::VolIDs& vid = placed.volIDs(); - for(PlacedVolume::VolIDs::const_iterator j=vid.begin(); j!=vid.end(); ++j) { - log << (*j).first << ":" << (*j).second << " "; - } + const PlacedVolume::VolIDs& vid = placed.volIDs(); + for(PlacedVolume::VolIDs::const_iterator j=vid.begin(); j!=vid.end(); ++j) { + log << (*j).first << ":" << (*j).second << " "; + } } log << " "; if ( i+1 == all_nodes.rend() ) log << "( -> " << placed->GetName() << ")"; @@ -98,9 +98,9 @@ void SurfaceInstaller::install(DetElement component, PlacedVolume pv) { log.str(""); Volume vol = pv.volume(); log << " " - << " Sensitive: " << (vol.isSensitive() ? "YES" : "NO ") - << " Volume: " << (void*)vol.ptr() << " " - << " Shape: " << vol.solid().toString(); + << " Sensitive: " << (vol.isSensitive() ? "YES" : "NO ") + << " Volume: " << (void*)vol.ptr() << " " + << " Shape: " << vol.solid().toString(); printout(INFO,m_det.name(),log.str()); return; } @@ -109,7 +109,7 @@ void SurfaceInstaller::install(DetElement component, PlacedVolume pv) { /// Scan through tree of volume placements void SurfaceInstaller::scan(DetElement e) { - const _C& children = e.children(); + const _C& children = e.children(); install(e,e.placement()); for (_C::const_iterator i=children.begin(); !m_stopScanning && i!=children.end(); ++i) scan((*i).second); diff --git a/DDCore/src/ToStream.cpp b/DDCore/src/ToStream.cpp index a48fa74955af99a89a6f009845fdbdbb99d65028..c37792078df682e2074e73eefa795080afaddb2f 100644 --- a/DDCore/src/ToStream.cpp +++ b/DDCore/src/ToStream.cpp @@ -30,18 +30,18 @@ namespace DD4hep { namespace Parsers { template <> double evaluate_string<double>(const std::string& value) { double result = eval.evaluate(value.c_str()); if (eval.status() != XmlTools::Evaluator::OK) { - std::cerr << value << ": "; - eval.print_error(); - throw std::runtime_error("DD4hep::Properties: Severe error during expression evaluation of " + value); + std::cerr << value << ": "; + eval.print_error(); + throw std::runtime_error("DD4hep::Properties: Severe error during expression evaluation of " + value); } return result; } template <> float evaluate_string<float>(const std::string& value) { double result = eval.evaluate(value.c_str()); if (eval.status() != XmlTools::Evaluator::OK) { - std::cerr << value << ": "; - eval.print_error(); - throw std::runtime_error("DD4hep::Properties: Severe error during expression evaluation of " + value); + std::cerr << value << ": "; + eval.print_error(); + throw std::runtime_error("DD4hep::Properties: Severe error during expression evaluation of " + value); } return (float) result; } diff --git a/DDCore/src/VolumeManager.cpp b/DDCore/src/VolumeManager.cpp index f2e76519a6277b534fa3e1520011634e24152f17..8bd0bab22fa2a6cb2156630e7e9eb0180c13d36c 100644 --- a/DDCore/src/VolumeManager.cpp +++ b/DDCore/src/VolumeManager.cpp @@ -35,7 +35,7 @@ namespace { set<VolumeID> m_entries; /// Default constructor Populator(LCDD& lcdd, VolumeManager vm) - : m_lcdd(lcdd), m_volManager(vm) { + : m_lcdd(lcdd), m_volManager(vm) { } /// Populate the Volume manager @@ -81,24 +81,24 @@ namespace { chain.push_back(node); VolIDs pv_ids = pv.volIDs(); ids.VolIDs::Base::insert(ids.end(), pv_ids.begin(), pv_ids.end()); - bool got_readout = false; + bool got_readout = false; if (vol.isSensitive()) { sd = vol.sensitiveDetector(); Readout ro = sd.readout(); if (ro.isValid()) { - got_readout = true; + got_readout = true; add_entry(sd, parent, e, node, ids, chain); ++count; } else { - printout(WARNING, "VolumeManager", - "%s: Strange constellation volume %s is sensitive, but has no readout! sd:%p", - parent.name(), pv.volume().name(), sd.ptr()); + printout(WARNING, "VolumeManager", + "%s: Strange constellation volume %s is sensitive, but has no readout! sd:%p", + parent.name(), pv.volume().name(), sd.ptr()); } } for (Int_t idau = 0, ndau = node->GetNdaughters(); idau < ndau; ++idau) { TGeoNode* daughter = node->GetDaughter(idau); - PlacedVolume placement(daughter); + PlacedVolume placement(daughter); if ( placement.data() ) { size_t cnt; PlacedVolume pv_dau = Ref_t(daughter); @@ -115,25 +115,25 @@ namespace { } count += cnt; } - else { - throw runtime_error("Invalid not instrumented placement:"+string(daughter->GetName())+ - " [Internal error -- bad detector constructor]"); - } + else { + throw runtime_error("Invalid not instrumented placement:"+string(daughter->GetName())+ + " [Internal error -- bad detector constructor]"); + } } - if ( sd.isValid() ) { - // We recuperate volumes from lower levels by reusing the subdetector - // This only works if there is exactly one sensitive detector per subdetector! - // I hate this, but I could not talk Frank out of this! M.F. + if ( sd.isValid() ) { + // We recuperate volumes from lower levels by reusing the subdetector + // This only works if there is exactly one sensitive detector per subdetector! + // I hate this, but I could not talk Frank out of this! M.F. Readout ro = sd.readout(); if (ro.isValid()) { - IDDescriptor iddesc = ro.idSpec(); - pair<VolumeID, VolumeID> det_encoding = encoding(iddesc,ids); - printout(VERBOSE,"VolumeManager","++++ %-11s SD:%s VolID=%p Mask=%p",e.path().c_str(), - got_readout ? "RECUPERATED" : "REGULAR", sd.name(), - (void*)det_encoding.first, (void*)det_encoding.second); - e.object<DetElement::Object>().volumeID = det_encoding.first; - } - } + IDDescriptor iddesc = ro.idSpec(); + pair<VolumeID, VolumeID> det_encoding = encoding(iddesc,ids); + printout(VERBOSE,"VolumeManager","++++ %-11s SD:%s VolID=%p Mask=%p",e.path().c_str(), + got_readout ? "RECUPERATED" : "REGULAR", sd.name(), + (void*)det_encoding.first, (void*)det_encoding.second); + e.object<DetElement::Object>().volumeID = det_encoding.first; + } + } chain.pop_back(); } return count; @@ -180,8 +180,8 @@ namespace { } } - void print_node(SensitiveDetector sd, DetElement /* parent */, DetElement e, - const TGeoNode* n, const VolIDs& ids, const Chain& /* nodes */) + void print_node(SensitiveDetector sd, DetElement /* parent */, DetElement e, + const TGeoNode* n, const VolIDs& ids, const Chain& /* nodes */) { static int s_count = 0; Readout ro = sd.readout(); @@ -208,7 +208,7 @@ namespace { log.str(""); log << s_count << ": " << e.name() << " Detector GeoNodes:"; for(vector<const TGeoNode*>::const_iterator j=nodes.begin(); j!=nodes.end();++j) - log << (void*)(*j) << " "; + log << (void*)(*j) << " "; printout(DEBUG,"VolumeManager",log.str().c_str()); #endif } @@ -247,17 +247,17 @@ VolumeManager VolumeManager::addSubdetector(DetElement detector, Readout ro) { // First check all pre-conditions if (!ro.isValid()) { throw runtime_error("DD4hep: VolumeManager::addSubdetector: Only subdetectors with a " - "valid readout descriptor are allowed. [Invalid DetElement:" + det_name + "]"); + "valid readout descriptor are allowed. [Invalid DetElement:" + det_name + "]"); } PlacedVolume pv = detector.placement(); if (!pv.isValid()) { throw runtime_error("DD4hep: VolumeManager::addSubdetector: Only subdetectors with a " - "valid placement are allowed. [Invalid DetElement:" + det_name + "]"); + "valid placement are allowed. [Invalid DetElement:" + det_name + "]"); } VolIDs::Base::const_iterator vit = pv.volIDs().find("system"); if (vit == pv.volIDs().end()) { throw runtime_error("DD4hep: VolumeManager::addSubdetector: Only subdetectors with " - "valid placement VolIDs are allowed. [Invalid DetElement:" + det_name + "]"); + "valid placement VolIDs are allowed. [Invalid DetElement:" + det_name + "]"); } i = o.subdetectors.insert(make_pair(detector, VolumeManager(detector,ro))).first; @@ -266,7 +266,7 @@ VolumeManager VolumeManager::addSubdetector(DetElement detector, Readout ro) { IDDescriptor::Field field = ro.idSpec().field(id.first); if (!field) { throw runtime_error( - "DD4hep: VolumeManager::addSubdetector: IdDescriptor of " + string(detector.name()) + " has no field " + id.first); + "DD4hep: VolumeManager::addSubdetector: IdDescriptor of " + string(detector.name()) + " has no field " + id.first); } Object& mo = m._data(); mo.top = o.top; @@ -276,12 +276,12 @@ VolumeManager VolumeManager::addSubdetector(DetElement detector, Readout ro) { mo.detMask = mo.sysID; o.managers[mo.sysID] = m; detector.callAtUpdate(DetElement::PLACEMENT_CHANGED|DetElement::PLACEMENT_DETECTOR, - &mo,&Object::update); + &mo,&Object::update); } return (*i).second; } throw runtime_error("DD4hep: VolumeManager::addSubdetector: " - "Failed to add subdetector section. [Invalid Manager Handle]"); + "Failed to add subdetector section. [Invalid Manager Handle]"); } /// Access the volume manager by cell id @@ -324,8 +324,8 @@ bool VolumeManager::adoptPlacement(VolumeID /* sys_id */, Context* context) { #if 0 if ( (context->identifier&context->mask) != context->identifier ) { err << "Bad context mask:" << (void*)context->mask << " id:" << (void*)context->identifier - << " pv:" << pv.name() << " Sensitive:" - << yes_no(pv.volume().isSensitive()) << endl; + << " pv:" << pv.name() << " Sensitive:" + << yes_no(pv.volume().isSensitive()) << endl; goto Fail; } #endif @@ -337,11 +337,11 @@ bool VolumeManager::adoptPlacement(VolumeID /* sys_id */, Context* context) { printout(VERBOSE, "VolumeManager", err.str().c_str()); return true; } - err << "+++ Attempt to register duplicate volID " << (void*) context->identifier - << " Mask:" << (void*) context->mask - << " to detector " << o.detector.name() - << " ptr:" << (void*) pv.ptr() - << " Name:" << pv.name() + err << "+++ Attempt to register duplicate volID " << (void*) context->identifier + << " Mask:" << (void*) context->mask + << " to detector " << o.detector.name() + << " ptr:" << (void*) pv.ptr() + << " Name:" << pv.name() << " Sensitive:" << yes_no(pv.volume().isSensitive()) << endl; printout(ERROR, "VolumeManager", "%s", err.str().c_str()); err.str(""); @@ -353,17 +353,17 @@ bool VolumeManager::adoptPlacement(VolumeID /* sys_id */, Context* context) { err.str(""); context = (*i).second; pv = context->placement; - err << " !!!!! +++ Clashing volID " << (void*) context->identifier - << " Mask:" << (void*) context->mask - << " to detector " << o.detector.name() - << " ptr:" << (void*) pv.ptr() - << " Name:" << pv.name() + err << " !!!!! +++ Clashing volID " << (void*) context->identifier + << " Mask:" << (void*) context->mask + << " to detector " << o.detector.name() + << " ptr:" << (void*) pv.ptr() + << " Name:" << pv.name() << " Sensitive:" << yes_no(pv.volume().isSensitive()) << endl; printout(ERROR, "VolumeManager", "%s", err.str().c_str()); err.str(""); goto Fail; - Fail: { + Fail: { err << " !!!!! ++++ VolIDS "; const VolIDs::Base& ids = context->volID; for (VolIDs::Base::const_iterator vit = ids.begin(); vit != ids.end(); ++vit) @@ -409,7 +409,7 @@ bool VolumeManager::adoptPlacement(Context* context) { } err << "Failed to add new physical volume [Invalid Manager Handle]"; goto Fail; - Fail: throw runtime_error("DD4hep: " + err.str()); + Fail: throw runtime_error("DD4hep: " + err.str()); return false; } @@ -475,15 +475,15 @@ std::ostream& DD4hep::Geometry::operator<<(std::ostream& os, const VolumeManager //bool isSdet = (o.flags & VolumeManager::TREE) == VolumeManager::TREE && top != &o; string prefix(isTop ? "" : "++ "); os << prefix << (isTop ? "TOP Level " : "Secondary ") << "Volume manager:" << &o << " " << o.detector.name() << " IDD:" - << o.id.toString() << " SysID:" << (void*) o.sysID << " " << o.managers.size() << " subsections " << o.volumes.size() - << " placements "; + << o.id.toString() << " SysID:" << (void*) o.sysID << " " << o.managers.size() << " subsections " << o.volumes.size() + << " placements "; if (!(o.managers.empty() && o.volumes.empty())) os << endl; for (VolumeManager::Volumes::const_iterator i = o.volumes.begin(); i != o.volumes.end(); ++i) { const VolumeManager::Context* c = (*i).second; PlacedVolume pv = c->placement; os << prefix << "PV:" << setw(32) << left << pv.name() << " id:" << setw(18) << left << (void*) c->identifier << " mask:" - << setw(18) << left << (void*) c->mask << endl; + << setw(18) << left << (void*) c->mask << endl; } for (VolumeManager::Managers::const_iterator i = o.managers.begin(); i != o.managers.end(); ++i) os << prefix << (*i).second << endl; diff --git a/DDCore/src/VolumeManagerInterna.cpp b/DDCore/src/VolumeManagerInterna.cpp index 0657d76d6e370c5b9a4364dde84f7d53d4f6e238..538e162a655831e6b98ba108e72e046b7760bbd5 100644 --- a/DDCore/src/VolumeManagerInterna.cpp +++ b/DDCore/src/VolumeManagerInterna.cpp @@ -18,7 +18,7 @@ DD4HEP_INSTANTIATE_HANDLE_NAMED(VolumeManagerObject); /// Default constructor VolumeManagerContext::VolumeManagerContext() - : identifier(0), mask(~0x0ULL) { + : identifier(0), mask(~0x0ULL) { } /// Default destructor @@ -45,13 +45,13 @@ VolumeManagerObject::~VolumeManagerObject() { void VolumeManagerObject::update(unsigned long tags, DetElement& det, void* param) { if ( DetElement::CONDITIONS_CHANGED == (tags&DetElement::CONDITIONS_CHANGED) ) printout(DEBUG,"VolumeManager","+++ Conditions update %s param:%p",det.path().c_str(),param); - if ( DetElement::PLACEMENT_CHANGED == (tags&DetElement::PLACEMENT_CHANGED) ) + if ( DetElement::PLACEMENT_CHANGED == (tags&DetElement::PLACEMENT_CHANGED) ) printout(DEBUG,"VolumeManager","+++ Alignment update %s param:%p",det.path().c_str(),param); for(Volumes::iterator i=volumes.begin(); i != volumes.end(); ++i) { Context* c = (*i).second; printout(DEBUG,"VolumeManager","+++ Alignment update %s",c->placement.name()); - + } } diff --git a/DDCore/src/Volumes.cpp b/DDCore/src/Volumes.cpp index a34bccdce4ce8b8e09ae034c2c72d5c4c423b4d3..9bb16d7930297b6c595951a9607e6edb457d6d3f 100644 --- a/DDCore/src/Volumes.cpp +++ b/DDCore/src/Volumes.cpp @@ -41,22 +41,22 @@ namespace DD4hep { TGeoExtension* m_extension; DDExtension() : m_extension(0) {} DDExtension(const DDExtension& c) : m_extension(0) { - if ( c.m_extension ) m_extension = c.m_extension->Grab(); + if ( c.m_extension ) m_extension = c.m_extension->Grab(); } virtual ~DDExtension() { - if ( m_extension ) m_extension->Release(); + if ( m_extension ) m_extension->Release(); } DDExtension& operator=(const DDExtension& c) { - if ( this != &c ) SetUserExtension(c.GetUserExtension()); - return *this; + if ( this != &c ) SetUserExtension(c.GetUserExtension()); + return *this; } void SetUserExtension(TGeoExtension *ext) { - if (m_extension) m_extension->Release(); - m_extension = 0; - if (ext) m_extension = ext->Grab(); + if (m_extension) m_extension->Release(); + m_extension = 0; + if (ext) m_extension = ext->Grab(); } TGeoExtension* GetUserExtension() const { - return m_extension; + return m_extension; } }; struct DD_TGeoNodeMatrix : public TGeoNodeMatrix, public DDExtension { @@ -64,11 +64,11 @@ namespace DD4hep { DD_TGeoNodeMatrix& operator=(const DD_TGeoNodeMatrix&) { return *this; } public: DD_TGeoNodeMatrix(const TGeoVolume* v, const TGeoMatrix* m) - : TGeoNodeMatrix(v, m), DDExtension() { + : TGeoNodeMatrix(v, m), DDExtension() { INCREMENT_COUNTER; } DD_TGeoNodeMatrix(const DD_TGeoNodeMatrix& c) - : TGeoNodeMatrix(c.GetVolume(), c.GetMatrix()), DDExtension(c) { + : TGeoNodeMatrix(c.GetVolume(), c.GetMatrix()), DDExtension(c) { INCREMENT_COUNTER; } virtual ~DD_TGeoNodeMatrix() { @@ -128,7 +128,7 @@ namespace DD4hep { if (this->T::fFinder) { // volume already divided. this->T::Error("AddNode", "Cannot add node %s_%i into divided volume %s", vol->GetName(), copy_no, - this->T::GetName()); + this->T::GetName()); return; } @@ -145,18 +145,18 @@ namespace DD4hep { }; template <> _VolWrap<TGeoVolume>::_VolWrap(const char* name) : TGeoVolume(name,0,0), DDExtension() { - INCREMENT_COUNTER; - } + INCREMENT_COUNTER; + } struct TGeoVolumeValue : public _VolWrap<TGeoVolume> { TGeoVolumeValue(const char* name, TGeoShape* s, TGeoMedium* m) : _VolWrap<TGeoVolume>(name) { - SetShape(s); - SetMedium(m); + SetShape(s); + SetMedium(m); } virtual ~TGeoVolumeValue() { } TGeoVolume *_copyVol(TGeoShape *newshape) const { TGeoVolumeValue *vol = new TGeoVolumeValue(this->TGeoVolume::GetName(),newshape,fMedium); - if ( m_extension ) vol->m_extension = m_extension->Grab(); + if ( m_extension ) vol->m_extension = m_extension->Grab(); //vol->copy(*this); return vol; } @@ -224,7 +224,7 @@ namespace DD4hep { } TGeoVolume *CloneVolume() const { TGeoVolumeAssemblyValue *vol = new TGeoVolumeAssemblyValue(this->TGeoVolume::GetName()); - if ( m_extension ) vol->m_extension = m_extension->Grab(); + if ( m_extension ) vol->m_extension = m_extension->Grab(); Int_t i; // copy other attributes Int_t nbits = 8 * sizeof(UInt_t); @@ -308,7 +308,7 @@ PlacedVolumeExtension::PlacedVolumeExtension() /// Copy constructor PlacedVolumeExtension::PlacedVolumeExtension(const PlacedVolumeExtension& c) - : TGeoExtension(), magic(c.magic), refCount(0), volIDs(c.volIDs) { + : TGeoExtension(), magic(c.magic), refCount(0), volIDs(c.volIDs) { INCREMENT_COUNTER; } @@ -334,7 +334,7 @@ void PlacedVolumeExtension::Release() const { } /// Lookup volume ID -vector<PlacedVolumeExtension::VolID>::const_iterator +vector<PlacedVolumeExtension::VolID>::const_iterator PlacedVolumeExtension::VolIDs::find(const string& name) const { for (Base::const_iterator i = this->Base::begin(); i != this->Base::end(); ++i) if (name == (*i).first) @@ -343,7 +343,7 @@ PlacedVolumeExtension::VolIDs::find(const string& name) const { } /// Insert a new value into the volume ID container -std::pair<vector<PlacedVolumeExtension::VolID>::iterator, bool> +std::pair<vector<PlacedVolumeExtension::VolID>::iterator, bool> PlacedVolumeExtension::VolIDs::insert(const string& name, int value) { Base::iterator i = this->Base::begin(); for (; i != this->Base::end(); ++i) @@ -432,7 +432,7 @@ TGeoExtension* VolumeExtension::Grab() { VolumeExtension* ext = const_cast<VolumeExtension*>(this); ++ext->refCount; #ifdef ___print_vols - if ( ext->sens_det.isValid() ) + if ( ext->sens_det.isValid() ) cout << "Volume grabbed with valid sensitive detector....." << endl; else cout << "Volume grabbed....." << endl; @@ -500,8 +500,8 @@ static PlacedVolume _addNode(TGeoVolume* par, TGeoVolume* daughter, TGeoMatrix* if ( shape->IsA() == TGeoShapeAssembly::Class() ) { TGeoShapeAssembly* as = (TGeoShapeAssembly*)shape; if ( std::fabs(as->GetDX()) < numeric_limits<double>::epsilon() && - std::fabs(as->GetDY()) < numeric_limits<double>::epsilon() && - std::fabs(as->GetDZ()) < numeric_limits<double>::epsilon() ) { + std::fabs(as->GetDY()) < numeric_limits<double>::epsilon() && + std::fabs(as->GetDZ()) < numeric_limits<double>::epsilon() ) { as->NeedsBBoxRecompute(); as->ComputeBBox(); } @@ -572,15 +572,15 @@ const Volume& Volume::setVisAttributes(const VisAttr& attr) const { //m_element->SetAttBit(TGeoAtt::kVisContainers, kTRUE); m_element->SetVisDaughters(vis->showDaughters ? kTRUE : kFALSE); printout(DEBUG,"setVisAttributes", - "Set color %3d [%02X,%02X,%02X] DrawingStyle:%9s LineStyle:%6s for volume %s", - int(vis->color), - c ? int(255*c->GetRed()) : 0xFF, - c ? int(255*c->GetGreen()) : 0xFF, - c ? int(255*c->GetBlue()) : 0xFF, - draw_style == VisAttr::SOLID ? "Solid" : "Wireframe", - line_style == VisAttr::SOLID ? "Solid" : "Dashed", - name() - ); + "Set color %3d [%02X,%02X,%02X] DrawingStyle:%9s LineStyle:%6s for volume %s", + int(vis->color), + c ? int(255*c->GetRed()) : 0xFF, + c ? int(255*c->GetGreen()) : 0xFF, + c ? int(255*c->GetBlue()) : 0xFF, + draw_style == VisAttr::SOLID ? "Solid" : "Wireframe", + line_style == VisAttr::SOLID ? "Solid" : "Dashed", + name() + ); m_element->SetLineWidth(10); m_element->SetLineColor(dark); if (draw_style == VisAttr::SOLID) { @@ -604,20 +604,20 @@ const Volume& Volume::setVisAttributes(const VisAttr& attr) const { /* - m_element->SetVisibility(kTRUE); - m_element->SetAttBit(TGeoAtt::kVisContainers, kTRUE); - m_element->SetVisDaughters(kTRUE); - printout(INFO,"setVisAttributes","Set Line color for volume %s",name()); - m_element->SetLineColor(bright); - m_element->SetFillColor(bright); - m_element->SetFillStyle(1001); // Root: solid - if (line_style == VisAttr::SOLID) + m_element->SetVisibility(kTRUE); + m_element->SetAttBit(TGeoAtt::kVisContainers, kTRUE); + m_element->SetVisDaughters(kTRUE); + printout(INFO,"setVisAttributes","Set Line color for volume %s",name()); + m_element->SetLineColor(bright); + m_element->SetFillColor(bright); + m_element->SetFillStyle(1001); // Root: solid + if (line_style == VisAttr::SOLID) m_element->SetFillStyle(1); - else if (line_style == VisAttr::DASHED) + else if (line_style == VisAttr::DASHED) m_element->SetFillStyle(2); - else + else m_element->SetFillStyle(line_style); - m_element->SetLineWidth(10); + m_element->SetLineWidth(10); */ } Volume::Object* o = _userExtension(*this); @@ -633,16 +633,16 @@ const Volume& Volume::setVisAttributes(const LCDD& lcdd, const string& name) con } else { /* - string tag = this->name(); - if ( ::strstr(tag.c_str(),"_slice") ) // Slices turned off by default - setVisAttributes(lcdd.visAttributes("InvisibleNoDaughters")); - else if ( ::strstr(tag.c_str(),"_layer") ) // Layers turned off, but daughters possibly visible - setVisAttributes(lcdd.visAttributes("InvisibleWithDaughters")); - else if ( ::strstr(tag.c_str(),"_module") ) // Tracker modules similar to layers - setVisAttributes(lcdd.visAttributes("InvisibleWithDaughters")); - else if ( ::strstr(tag.c_str(),"_module_component") ) // Tracker modules similar to layers - setVisAttributes(lcdd.visAttributes("InvisibleNoDaughters")); - */ + string tag = this->name(); + if ( ::strstr(tag.c_str(),"_slice") ) // Slices turned off by default + setVisAttributes(lcdd.visAttributes("InvisibleNoDaughters")); + else if ( ::strstr(tag.c_str(),"_layer") ) // Layers turned off, but daughters possibly visible + setVisAttributes(lcdd.visAttributes("InvisibleWithDaughters")); + else if ( ::strstr(tag.c_str(),"_module") ) // Tracker modules similar to layers + setVisAttributes(lcdd.visAttributes("InvisibleWithDaughters")); + else if ( ::strstr(tag.c_str(),"_module_component") ) // Tracker modules similar to layers + setVisAttributes(lcdd.visAttributes("InvisibleNoDaughters")); + */ } return *this; } diff --git a/DDCore/src/XML/DocumentHandler.cpp b/DDCore/src/XML/DocumentHandler.cpp index 59e91bedec65cacdc129f994bff74d59068c4232..7e8c14f660032b0285c26a32251fb8402c03bb08 100644 --- a/DDCore/src/XML/DocumentHandler.cpp +++ b/DDCore/src/XML/DocumentHandler.cpp @@ -76,7 +76,7 @@ namespace DD4hep { } /// Destructor virtual ~DocumentErrorHandler() { - printout(DEBUG,"DocumentErrorHandler","+++ Destructing the XercesC DOM-XML document error handler...."); + printout(DEBUG,"DocumentErrorHandler","+++ Destructing the XercesC DOM-XML document error handler...."); } /// Reset errors (Noop) void resetErrors() { @@ -109,11 +109,11 @@ namespace DD4hep { return false; } printout(FATAL,"DocumentErrorHandler", "+++ %s %s: %s", err.c_str(), - _toString(domError.getType()).c_str(),_toString(domError.getMessage()).c_str()); + _toString(domError.getType()).c_str(),_toString(domError.getMessage()).c_str()); DOMLocator* loc = domError.getLocation(); if (loc) { - printout(FATAL,"DocumentErrorHandler","+++ Location: Line:%d Column: %d", - int(loc->getLineNumber()),int(loc->getColumnNumber())); + printout(FATAL,"DocumentErrorHandler","+++ Location: Line:%d Column: %d", + int(loc->getLineNumber()),int(loc->getColumnNumber())); } return false; } @@ -129,14 +129,14 @@ namespace DD4hep { return; string sys(_toString(e.getSystemId())); printout(ERROR,"XercesC","+++ Error at file \"%s\", Line %d Column: %d Message:%s", - sys.c_str(), int(e.getLineNumber()), int(e.getColumnNumber()), m.c_str()); + sys.c_str(), int(e.getLineNumber()), int(e.getColumnNumber()), m.c_str()); } /// Fatal error handler void DocumentErrorHandler::fatalError(const SAXParseException& e) { string m(_toString(e.getMessage())); string sys(_toString(e.getSystemId())); printout(FATAL,"XercesC","+++ FATAL Error at file \"%s\", Line %d Column: %d Message:%s", - sys.c_str(), int(e.getLineNumber()), int(e.getColumnNumber()), m.c_str()); + sys.c_str(), int(e.getLineNumber()), int(e.getColumnNumber()), m.c_str()); } /// Dump DOM tree using XercesC handles @@ -156,7 +156,7 @@ namespace DD4hep { /// Default constructor of a document handler using XercesC DocumentHandler::DocumentHandler() - : m_errHdlr(new DocumentErrorHandler()) { + : m_errHdlr(new DocumentErrorHandler()) { } /// Default destructor of a document handler using XercesC @@ -302,9 +302,9 @@ Document DocumentHandler::load(Handle_t base, const XmlChar* fname) const { fn += _clean_fname(fname); } if ( ::stat(fn.c_str(),&st)==0 ) - return load(fn); + return load(fn); else if ( ::stat(clean.c_str(),&st)==0 ) - return load(clean); + return load(clean); return load(fname); } @@ -316,9 +316,9 @@ Document DocumentHandler::load(const std::string& fname) const { result = doc->LoadFile(); if ( !result ) { if ( doc->Error() ) { - printout(FATAL,"DocumentHandler","+++ Error (TinyXML) while parsing XML document:%s",doc->ErrorDesc()); - printout(FATAL,"DocumentHandler","+++ Document:%s Location Line:%d Column:%d", - doc->Value(), doc->ErrorRow(), doc->ErrorCol()); + printout(FATAL,"DocumentHandler","+++ Error (TinyXML) while parsing XML document:%s",doc->ErrorDesc()); + printout(FATAL,"DocumentHandler","+++ Document:%s Location Line:%d Column:%d", + doc->Value(), doc->ErrorRow(), doc->ErrorCol()); throw runtime_error(string("DD4hep: ")+doc->ErrorDesc()); } throw runtime_error("DD4hep: Unknown error whaile parsing XML document with TinyXML."); @@ -345,7 +345,7 @@ Document DocumentHandler::parse(const char* doc_string, size_t /* length */) con if ( doc->Error() ) { printout(FATAL,"DocumentHandler","+++ Error (TinyXML) while parsing XML document:%s",doc->ErrorDesc()); printout(FATAL,"DocumentHandler","+++ Document:%s Location Line:%d Column:%d", - doc->Value(), doc->ErrorRow(), doc->ErrorCol()); + doc->Value(), doc->ErrorRow(), doc->ErrorCol()); throw runtime_error(string("DD4hep: ")+doc->ErrorDesc()); } throw runtime_error("DD4hep: Unknown error whaile parsing XML document with TiXml."); diff --git a/DDCore/src/XML/Layering.cpp b/DDCore/src/XML/Layering.cpp index 70e93c9d997a8b227fc518aed64a97fc18f5c070..d00bc50a1f429bb555b6aea1164e7110ee7ffbfd 100644 --- a/DDCore/src/XML/Layering.cpp +++ b/DDCore/src/XML/Layering.cpp @@ -29,7 +29,7 @@ LayerSlice& LayerSlice::operator=(const LayerSlice& c) { } Layer::Layer(const Layer& c) - : _thickness(c._thickness), _preOffset(c._preOffset), _slices(c._slices) { + : _thickness(c._thickness), _preOffset(c._preOffset), _slices(c._slices) { } Layer& Layer::operator=(const Layer& c) { @@ -51,15 +51,15 @@ double LayerStack::sectionThickness(size_t is, size_t ie) const { double thick = 0.; if (is > ie) throw runtime_error( - "LayerStack::sectionThickness: First index (" + _toString(is) + ") must be <= second index (" + _toString(ie) + ")!"); + "LayerStack::sectionThickness: First index (" + _toString(is) + ") must be <= second index (" + _toString(ie) + ")!"); else if (is > _layers.size()) throw runtime_error( - "LayerStack::sectionThickness: First index (" + _toString(is) + ") out of range. #layers=" + _toString(_layers.size()) - + ")."); + "LayerStack::sectionThickness: First index (" + _toString(is) + ") out of range. #layers=" + _toString(_layers.size()) + + ")."); else if (ie > _layers.size()) throw runtime_error( - "LayerStack::sectionThickness: Second index (" + _toString(is) + ") out of range. #layers=" + _toString(_layers.size()) - + ")."); + "LayerStack::sectionThickness: Second index (" + _toString(is) + ") out of range. #layers=" + _toString(_layers.size()) + + ")."); for (size_t i = is; i <= ie; ++i) thick += _layers[i]->thicknessWithPreOffset(); return thick; diff --git a/DDCore/src/XML/XMLChildValue.cpp b/DDCore/src/XML/XMLChildValue.cpp index 3e861531f0fd8500652345ea26ac20e49452d06e..442584aef7defc65656df6264216291077b9b27b 100644 --- a/DDCore/src/XML/XMLChildValue.cpp +++ b/DDCore/src/XML/XMLChildValue.cpp @@ -14,17 +14,17 @@ using namespace DD4hep::XML; #define childValue(name,type) m_element.child(Unicode_##name).attr<type>(Unicode_value) -#define childValueDefault(name,type,def) \ - Handle_t __h = m_element.child(Unicode_##name,false); \ +#define childValueDefault(name,type,def) \ + Handle_t __h = m_element.child(Unicode_##name,false); \ if ( __h.ptr() && __h.hasAttr(Unicode_value) ) return __h.attr < type > (Unicode_value); \ return def; #define XML_ATTR_ACCESSOR(type,name) type ChildValue::name() const { return childValue(name,type); } -#define XML_ATTR_ACCESSOR_DEFAULT(name,type,dressing) \ +#define XML_ATTR_ACCESSOR_DEFAULT(name,type,dressing) \ type ChildValue::name(type default_val) const { \ - Handle_t __h = m_element.child(Unicode_##name,false); \ + Handle_t __h = m_element.child(Unicode_##name,false); \ if ( __h.ptr() ) { \ - const XmlChar* val = __h.attr_value_nothrow(Unicode_value); \ + const XmlChar* val = __h.attr_value_nothrow(Unicode_value); \ return val ? dressing(val) : default_val; } \ return default_val; } diff --git a/DDCore/src/XML/XMLDetector.cpp b/DDCore/src/XML/XMLDetector.cpp index 995e23e6ca2c5389a7dabd8f22db5bd742b6cf2c..3a93cddd16e05eac5806af002265dcae7a16a8b8 100644 --- a/DDCore/src/XML/XMLDetector.cpp +++ b/DDCore/src/XML/XMLDetector.cpp @@ -88,8 +88,8 @@ bool DetElement::isCalorimeter() const { bool DetElement::isInsideTrackingVolume() const { if (m_element && hasAttr(_U(insideTrackingVolume)) ) - return attr<bool>(_U(insideTrackingVolume)); + return attr<bool>(_U(insideTrackingVolume)); else if ( isTracker() ) - return true; + return true; return false; } diff --git a/DDCore/src/XML/XMLDimension.cpp b/DDCore/src/XML/XMLDimension.cpp index 47b057bd33f11a7e799e39a1fbd6d710dc755efd..0a1ed24b8cf204b1b3b113cef7c6eadb0b50cb3a 100644 --- a/DDCore/src/XML/XMLDimension.cpp +++ b/DDCore/src/XML/XMLDimension.cpp @@ -13,19 +13,19 @@ using namespace std; using namespace DD4hep::XML; #define XML_ATTR_ACCESSOR(type,name) type Dimension::name() const { return m_element.attr<type>(Unicode_##name); } -#define XML_ATTR_ACCESSOR_DEFAULT(name,type,dressing) \ - type Dimension::name(type default_val) const { \ - const XmlChar* val = m_element.attr_value_nothrow(Unicode_##name); \ +#define XML_ATTR_ACCESSOR_DEFAULT(name,type,dressing) \ + type Dimension::name(type default_val) const { \ + const XmlChar* val = m_element.attr_value_nothrow(Unicode_##name); \ return val ? dressing(val) : default_val; } -#define XML_ATTR_ACCESSOR_DOUBLE(name) \ - XML_ATTR_ACCESSOR(double,name) \ +#define XML_ATTR_ACCESSOR_DOUBLE(name) \ + XML_ATTR_ACCESSOR(double,name) \ XML_ATTR_ACCESSOR_DEFAULT(name,double,_toDouble) -#define XML_ATTR_ACCESSOR_INT(name) XML_ATTR_ACCESSOR_DEFAULT(name,int,_toInt) -#define XML_ATTR_ACCESSOR_BOOL(name) XML_ATTR_ACCESSOR_DEFAULT(name,bool,_toBool) +#define XML_ATTR_ACCESSOR_INT(name) XML_ATTR_ACCESSOR_DEFAULT(name,int,_toInt) +#define XML_ATTR_ACCESSOR_BOOL(name) XML_ATTR_ACCESSOR_DEFAULT(name,bool,_toBool) -#define XML_CHILD_ACCESSOR_XML_DIM(name) \ +#define XML_CHILD_ACCESSOR_XML_DIM(name) \ Dimension Dimension::name(bool throw_if_not_present) const { \ return m_element.child(Unicode_##name,throw_if_not_present); } diff --git a/DDCore/src/XML/XMLElements.cpp b/DDCore/src/XML/XMLElements.cpp index 00d9da8ef286c157e0055aefe688b20b6e733580..5ceddf6ad228a7e4cf96ee43d48e7e88c03aca33 100644 --- a/DDCore/src/XML/XMLElements.cpp +++ b/DDCore/src/XML/XMLElements.cpp @@ -77,7 +77,7 @@ namespace { size_t node_count(XmlElement* elt, const Tag_t& t) { size_t cnt = 0; TiXmlElement* e = Xml(elt).e; - if ( t.str()=="*" ) + if ( t.str()=="*" ) for(e=e->FirstChildElement();e; e=e->NextSiblingElement()) ++cnt; else for(e=e->FirstChildElement(t.str());e; e=e->NextSiblingElement(t.str())) ++cnt; @@ -99,7 +99,7 @@ void DD4hep::XML::XmlString::release(char** p) {if(p && *p) {::free(*p); *p=0;} /// Union to ease castless object access when using XercesC union Xml { Xml(const void* ptr) - : p(ptr) { + : p(ptr) { } const void* p; xercesc::DOMNode* n; @@ -133,12 +133,12 @@ namespace { const string& tag = t; xercesc::DOMElement *ee = Xml(e).e; if ( ee ) { - for(xercesc::DOMElement* elt=ee->getFirstElementChild(); elt; elt=elt->getNextElementSibling()) { - if ( elt->getParentNode() == ee ) { - string child_tag = _toString(elt->getTagName()); - if ( tag == "*" || child_tag == tag ) ++cnt; - } - } + for(xercesc::DOMElement* elt=ee->getFirstElementChild(); elt; elt=elt->getNextElementSibling()) { + if ( elt->getParentNode() == ee ) { + string child_tag = _toString(elt->getTagName()); + if ( tag == "*" || child_tag == tag ) ++cnt; + } + } } } return cnt; @@ -148,13 +148,13 @@ namespace { const string& tag = t; xercesc::DOMElement* ee = Xml(e).e; if ( ee ) { - for(xercesc::DOMElement* elt=ee->getFirstElementChild(); elt; elt=elt->getNextElementSibling()) { - if ( elt->getParentNode() == ee ) { - if ( tag == "*" ) return _XE(elt); - string child_tag = _toString(elt->getTagName()); - if ( child_tag == tag ) return _XE(elt); - } - } + for(xercesc::DOMElement* elt=ee->getFirstElementChild(); elt; elt=elt->getNextElementSibling()) { + if ( elt->getParentNode() == ee ) { + if ( tag == "*" ) return _XE(elt); + string child_tag = _toString(elt->getTagName()); + if ( child_tag == tag ) return _XE(elt); + } + } } } return 0; @@ -180,8 +180,8 @@ namespace { return Xml(a).a->getValue(); } #if 0 -int node_type(XmlNode* n) {return Xml(n).n->getNodeType();} -int node_type(Handle_t n) {return Xml(n.ptr()).n->getNodeType();} + int node_type(XmlNode* n) {return Xml(n).n->getNodeType();} + int node_type(Handle_t n) {return Xml(n.ptr()).n->getNodeType();} #endif } @@ -318,7 +318,7 @@ void DD4hep::XML::_toDictionary(const XmlChar* name, const XmlChar* value) { eval.setVariable(n.c_str(), result); } -template <typename T> +template <typename T> void DD4hep::XML::_toDictionary(const XmlChar* name, T value) { Strng_t item = _toString(value); const XmlChar* item_value = item; @@ -526,7 +526,7 @@ XmlElement* NodeList::reset() { /// Advance to next element XmlElement* NodeList::next() const { #ifdef DD4HEP_USE_TINYXML - if ( m_tag.str()=="*" ) + if ( m_tag.str()=="*" ) return m_ptr =_XE(m_ptr ? _E(m_ptr)->NextSiblingElement() : 0); return m_ptr = _XE(m_ptr ? _E(m_ptr)->NextSiblingElement(m_tag.str()) : 0); #else @@ -543,7 +543,7 @@ XmlElement* NodeList::next() const { /// Go back to previous element XmlElement* NodeList::previous() const { #ifdef DD4HEP_USE_TINYXML - if ( m_tag.str()=="*" ) + if ( m_tag.str()=="*" ) return m_ptr = _XE(m_ptr ? _E(m_ptr)->PreviousSiblingElement() : 0); return m_ptr = _XE(m_ptr ? _E(m_ptr)->PreviousSiblingElement(m_tag) : 0); #else @@ -620,7 +620,7 @@ vector<Attribute> Handle_t::attributes() const { if (m_node) { #ifdef DD4HEP_USE_TINYXML for(TiXmlAttribute* a=_E(m_node)->FirstAttribute(); a; a=a->Next()) - attrs.push_back(Attribute(a)); + attrs.push_back(Attribute(a)); #else xercesc::DOMNamedNodeMap* l = _E(m_node)->getAttributes(); for (XmlSize_t i = 0, n = l->getLength(); i < n; ++i) { @@ -692,7 +692,7 @@ Handle_t Handle_t::remove(Handle_t node) const { void Handle_t::removeChildren(const XmlChar* tag) const { #ifdef DD4HEP_USE_TINYXML for(TiXmlNode* n=_E(m_node)->FirstChildElement(tag);n;n=_E(m_node)->FirstChildElement(tag)) - n->RemoveChild(n); + n->RemoveChild(n); #else xercesc::DOMElement* e = _E(m_node); xercesc::DOMNodeList* l = e->getElementsByTagName(tag); @@ -757,7 +757,7 @@ void Handle_t::setAttrs(Handle_t elt) const { removeAttrs(); TiXmlElement* e = Xml(elt).e; for(TiXmlAttribute* a=e->FirstAttribute(); a; a=a->Next()) - e->SetAttribute(a->Name(),a->Value()); + e->SetAttribute(a->Name(),a->Value()); } #else void Handle_t::setAttrs(Handle_t /* elt */) const { @@ -935,30 +935,30 @@ unsigned int Handle_t::checksum(unsigned int param, fcn_t fcn) const { if ( n ) { if ( 0 == fcn ) fcn = adler32; switch (n->Type()) { - case TiXmlNode::ELEMENT: { - map<string,string> m; - TiXmlElement* e = n->ToElement(); - TiXmlAttribute* p=e->FirstAttribute(); - for(; p; p=p->Next()) m.insert(make_pair(p->Name(),p->Value())); - param = (*fcn)(param,e->Value(),::strlen(e->Value())); - for(StringMap::const_iterator i=m.begin();i!=m.end();++i) { - param = (*fcn)(param,(*i).first.c_str(),(*i).first.length()); - param = (*fcn)(param,(*i).second.c_str(),(*i).second.length()); - } - break; + case TiXmlNode::ELEMENT: { + map<string,string> m; + TiXmlElement* e = n->ToElement(); + TiXmlAttribute* p=e->FirstAttribute(); + for(; p; p=p->Next()) m.insert(make_pair(p->Name(),p->Value())); + param = (*fcn)(param,e->Value(),::strlen(e->Value())); + for(StringMap::const_iterator i=m.begin();i!=m.end();++i) { + param = (*fcn)(param,(*i).first.c_str(),(*i).first.length()); + param = (*fcn)(param,(*i).second.c_str(),(*i).second.length()); } - case TiXmlNode::TEXT: + break; + } + case TiXmlNode::TEXT: param = (*fcn)(param,n->ToText()->Value(),::strlen(n->ToText()->Value())); break; - case TiXmlNode::UNKNOWN: - case TiXmlNode::COMMENT: - case TiXmlNode::DOCUMENT: - case TiXmlNode::DECLARATION: - default: + case TiXmlNode::UNKNOWN: + case TiXmlNode::COMMENT: + case TiXmlNode::DOCUMENT: + case TiXmlNode::DECLARATION: + default: break; } for(TiXmlNode* c=n->FirstChild(); c; c=c->NextSibling()) - param = Handle_t((XmlElement*)c->ToElement()).checksum(param,fcn); + param = Handle_t((XmlElement*)c->ToElement()).checksum(param,fcn); } #else if ( 0 == fcn ) fcn = adler32; @@ -999,7 +999,7 @@ DocumentHolder::~DocumentHolder() { /// Constructor from DOM document entity Element::Element(const Document& document, const XmlChar* type) - : m_element(Xml(document.createElt(type)).xe) { + : m_element(Xml(document.createElt(type)).xe) { } /// Access the hosting document handle of this DOM element @@ -1058,19 +1058,19 @@ void Element::addComment(const char* text) const { /// Initializing constructor to create a new XMLElement and add it to the document. RefElement::RefElement(const Document& document, const XmlChar* type, const XmlChar* name) - : Element(document, type) { + : Element(document, type) { m_name = name ? setAttr(_U(name), name) : 0; } /// Construction from existing object handle RefElement::RefElement(const Handle_t& e) - : Element(e) { + : Element(e) { m_name = m_element ? getAttr(_U(name)) : 0; } /// Copy constructor RefElement::RefElement(const RefElement& e) - : Element(e), m_name(e.m_name) { + : Element(e), m_name(e.m_name) { } /// Assignment operator @@ -1097,19 +1097,19 @@ void RefElement::setName(const XmlChar* new_name) { #ifndef DD4HEP_USE_TINYXML Collection_t::Collection_t(Handle_t element, const XmlChar* tag) - : m_children(element, tag) { + : m_children(element, tag) { m_node = m_children.reset(); } #endif Collection_t::Collection_t(Handle_t element, const char* tag) - : m_children(element, Strng_t(tag)) { + : m_children(element, Strng_t(tag)) { m_node = m_children.reset(); } /// Constructor over XmlElements in a node list Collection_t::Collection_t(NodeList node_list) - : m_children(node_list) { + : m_children(node_list) { m_node = m_children.reset(); } diff --git a/DDCore/src/XML/tinyxml_inl.h b/DDCore/src/XML/tinyxml_inl.h index b472d2af045ef0152929f0eed6be66dd16d6364c..3c72ed5a6e073623a24a8ab9a74d011d418a31ef 100644 --- a/DDCore/src/XML/tinyxml_inl.h +++ b/DDCore/src/XML/tinyxml_inl.h @@ -1,29 +1,29 @@ /* -www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) + www.sourceforge.net/projects/tinyxml + Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. + 1. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation + would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. + 2. Altered source versions must be plainly marked as such, and + must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source -distribution. + 3. This notice may not be removed or altered from any source + distribution. - F.Gaede, DESY : changed extension to .cc for use with marlin - and include from "marlin/tinyxml.h" + F.Gaede, DESY : changed extension to .cc for use with marlin + and include from "marlin/tinyxml.h" */ @@ -41,1870 +41,1870 @@ bool TiXmlBase::condenseWhiteSpace = true; void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_STRING* outString ) { - int i=0; - - while( i<(int)str.length() ) - { - unsigned char c = (unsigned char) str[i]; - - if ( c == '&' - && i < ( (int)str.length() - 2 ) - && str[i+1] == '#' - && str[i+2] == 'x' ) - { - // Hexadecimal character reference. - // Pass through unchanged. - // © -- copyright symbol, for example. - // - // The -1 is a bug fix from Rob Laveaux. It keeps - // an overflow from happening if there is no ';'. - // There are actually 2 ways to exit this loop - - // while fails (error case) and break (semicolon found). - // However, there is no mechanism (currently) for - // this function to return an error. - while ( i<(int)str.length()-1 ) - { - outString->append( str.c_str() + i, 1 ); - ++i; - if ( str[i] == ';' ) - break; - } - } - else if ( c == '&' ) - { - outString->append( entity[0].str, entity[0].strLength ); - ++i; - } - else if ( c == '<' ) - { - outString->append( entity[1].str, entity[1].strLength ); - ++i; - } - else if ( c == '>' ) - { - outString->append( entity[2].str, entity[2].strLength ); - ++i; - } - else if ( c == '\"' ) - { - outString->append( entity[3].str, entity[3].strLength ); - ++i; - } - else if ( c == '\'' ) - { - outString->append( entity[4].str, entity[4].strLength ); - ++i; - } - else if ( c < 32 ) - { - // Easy pass at non-alpha/numeric/symbol - // Below 32 is symbolic. - char buf[ 32 ]; - - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) ); - #else - sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); - #endif - - //*ME: warning C4267: convert 'size_t' to 'int' - //*ME: Int-Cast to make compiler happy ... - outString->append( buf, (int)strlen( buf ) ); - ++i; - } - else - { - //char realc = (char) c; - //outString->append( &realc, 1 ); - *outString += (char) c; // somewhat more efficient function call. - ++i; - } - } + int i=0; + + while( i<(int)str.length() ) + { + unsigned char c = (unsigned char) str[i]; + + if ( c == '&' + && i < ( (int)str.length() - 2 ) + && str[i+1] == '#' + && str[i+2] == 'x' ) + { + // Hexadecimal character reference. + // Pass through unchanged. + // © -- copyright symbol, for example. + // + // The -1 is a bug fix from Rob Laveaux. It keeps + // an overflow from happening if there is no ';'. + // There are actually 2 ways to exit this loop - + // while fails (error case) and break (semicolon found). + // However, there is no mechanism (currently) for + // this function to return an error. + while ( i<(int)str.length()-1 ) + { + outString->append( str.c_str() + i, 1 ); + ++i; + if ( str[i] == ';' ) + break; + } + } + else if ( c == '&' ) + { + outString->append( entity[0].str, entity[0].strLength ); + ++i; + } + else if ( c == '<' ) + { + outString->append( entity[1].str, entity[1].strLength ); + ++i; + } + else if ( c == '>' ) + { + outString->append( entity[2].str, entity[2].strLength ); + ++i; + } + else if ( c == '\"' ) + { + outString->append( entity[3].str, entity[3].strLength ); + ++i; + } + else if ( c == '\'' ) + { + outString->append( entity[4].str, entity[4].strLength ); + ++i; + } + else if ( c < 32 ) + { + // Easy pass at non-alpha/numeric/symbol + // Below 32 is symbolic. + char buf[ 32 ]; + +#if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) ); +#else + sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); +#endif + + //*ME: warning C4267: convert 'size_t' to 'int' + //*ME: Int-Cast to make compiler happy ... + outString->append( buf, (int)strlen( buf ) ); + ++i; + } + else + { + //char realc = (char) c; + //outString->append( &realc, 1 ); + *outString += (char) c; // somewhat more efficient function call. + ++i; + } + } } TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase() { - parent = 0; - type = _type; - firstChild = 0; - lastChild = 0; - prev = 0; - next = 0; + parent = 0; + type = _type; + firstChild = 0; + lastChild = 0; + prev = 0; + next = 0; } TiXmlNode::~TiXmlNode() { - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; + TiXmlNode* node = firstChild; + TiXmlNode* temp = 0; - while ( node ) - { - temp = node; - node = node->next; - delete temp; - } + while ( node ) + { + temp = node; + node = node->next; + delete temp; + } } void TiXmlNode::CopyTo( TiXmlNode* target ) const { - target->SetValue (value.c_str() ); - target->userData = userData; + target->SetValue (value.c_str() ); + target->userData = userData; } void TiXmlNode::Clear() { - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; + TiXmlNode* node = firstChild; + TiXmlNode* temp = 0; - while ( node ) - { - temp = node; - node = node->next; - delete temp; - } + while ( node ) + { + temp = node; + node = node->next; + delete temp; + } - firstChild = 0; - lastChild = 0; + firstChild = 0; + lastChild = 0; } TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) { - assert( node->parent == 0 || node->parent == this ); - assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); + assert( node->parent == 0 || node->parent == this ); + assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); - if ( node->Type() == TiXmlNode::DOCUMENT ) - { - delete node; - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } + if ( node->Type() == TiXmlNode::DOCUMENT ) + { + delete node; + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } - node->parent = this; + node->parent = this; - node->prev = lastChild; - node->next = 0; + node->prev = lastChild; + node->next = 0; - if ( lastChild ) - lastChild->next = node; - else - firstChild = node; // it was an empty list. + if ( lastChild ) + lastChild->next = node; + else + firstChild = node; // it was an empty list. - lastChild = node; - return node; + lastChild = node; + return node; } TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) { - if ( addThis.Type() == TiXmlNode::DOCUMENT ) - { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; + if ( addThis.Type() == TiXmlNode::DOCUMENT ) + { + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; - return LinkEndChild( node ); + return LinkEndChild( node ); } TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) -{ - if ( !beforeThis || beforeThis->parent != this ) { - return 0; - } - if ( addThis.Type() == TiXmlNode::DOCUMENT ) - { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - node->parent = this; - - node->next = beforeThis; - node->prev = beforeThis->prev; - if ( beforeThis->prev ) - { - beforeThis->prev->next = node; - } - else - { - assert( firstChild == beforeThis ); - firstChild = node; - } - beforeThis->prev = node; - return node; +{ + if ( !beforeThis || beforeThis->parent != this ) { + return 0; + } + if ( addThis.Type() == TiXmlNode::DOCUMENT ) + { + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; + node->parent = this; + + node->next = beforeThis; + node->prev = beforeThis->prev; + if ( beforeThis->prev ) + { + beforeThis->prev->next = node; + } + else + { + assert( firstChild == beforeThis ); + firstChild = node; + } + beforeThis->prev = node; + return node; } TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) { - if ( !afterThis || afterThis->parent != this ) { - return 0; - } - if ( addThis.Type() == TiXmlNode::DOCUMENT ) - { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - node->parent = this; - - node->prev = afterThis; - node->next = afterThis->next; - if ( afterThis->next ) - { - afterThis->next->prev = node; - } - else - { - assert( lastChild == afterThis ); - lastChild = node; - } - afterThis->next = node; - return node; + if ( !afterThis || afterThis->parent != this ) { + return 0; + } + if ( addThis.Type() == TiXmlNode::DOCUMENT ) + { + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; + node->parent = this; + + node->prev = afterThis; + node->next = afterThis->next; + if ( afterThis->next ) + { + afterThis->next->prev = node; + } + else + { + assert( lastChild == afterThis ); + lastChild = node; + } + afterThis->next = node; + return node; } TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) { - if ( replaceThis->parent != this ) - return 0; + if ( replaceThis->parent != this ) + return 0; - TiXmlNode* node = withThis.Clone(); - if ( !node ) - return 0; + TiXmlNode* node = withThis.Clone(); + if ( !node ) + return 0; - node->next = replaceThis->next; - node->prev = replaceThis->prev; + node->next = replaceThis->next; + node->prev = replaceThis->prev; - if ( replaceThis->next ) - replaceThis->next->prev = node; - else - lastChild = node; + if ( replaceThis->next ) + replaceThis->next->prev = node; + else + lastChild = node; - if ( replaceThis->prev ) - replaceThis->prev->next = node; - else - firstChild = node; + if ( replaceThis->prev ) + replaceThis->prev->next = node; + else + firstChild = node; - delete replaceThis; - node->parent = this; - return node; + delete replaceThis; + node->parent = this; + return node; } bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) { - if ( removeThis->parent != this ) - { - assert( 0 ); - return false; - } + if ( removeThis->parent != this ) + { + assert( 0 ); + return false; + } - if ( removeThis->next ) - removeThis->next->prev = removeThis->prev; - else - lastChild = removeThis->prev; + if ( removeThis->next ) + removeThis->next->prev = removeThis->prev; + else + lastChild = removeThis->prev; - if ( removeThis->prev ) - removeThis->prev->next = removeThis->next; - else - firstChild = removeThis->next; + if ( removeThis->prev ) + removeThis->prev->next = removeThis->next; + else + firstChild = removeThis->next; - delete removeThis; - return true; + delete removeThis; + return true; } const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const { - const TiXmlNode* node; - for ( node = firstChild; node; node = node->next ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; + const TiXmlNode* node; + for ( node = firstChild; node; node = node->next ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; } const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const { - const TiXmlNode* node; - for ( node = lastChild; node; node = node->prev ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; + const TiXmlNode* node; + for ( node = lastChild; node; node = node->prev ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; } const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const { - if ( !previous ) - { - return FirstChild(); - } - else - { - assert( previous->parent == this ); - return previous->NextSibling(); - } + if ( !previous ) + { + return FirstChild(); + } + else + { + assert( previous->parent == this ); + return previous->NextSibling(); + } } const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const { - if ( !previous ) - { - return FirstChild( val ); - } - else - { - assert( previous->parent == this ); - return previous->NextSibling( val ); - } + if ( !previous ) + { + return FirstChild( val ); + } + else + { + assert( previous->parent == this ); + return previous->NextSibling( val ); + } } -const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const +const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const { - const TiXmlNode* node; - for ( node = next; node; node = node->next ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; + const TiXmlNode* node; + for ( node = next; node; node = node->next ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; } const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const { - const TiXmlNode* node; - for ( node = prev; node; node = node->prev ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; + const TiXmlNode* node; + for ( node = prev; node; node = node->prev ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; } void TiXmlElement::RemoveAttribute( const char * name ) { - #ifdef TIXML_USE_STL - TIXML_STRING str( name ); - TiXmlAttribute* node = attributeSet.Find( str ); - #else - TiXmlAttribute* node = attributeSet.Find( name ); - #endif - if ( node ) - { - attributeSet.Remove( node ); - delete node; - } +#ifdef TIXML_USE_STL + TIXML_STRING str( name ); + TiXmlAttribute* node = attributeSet.Find( str ); +#else + TiXmlAttribute* node = attributeSet.Find( name ); +#endif + if ( node ) + { + attributeSet.Remove( node ); + delete node; + } } const TiXmlElement* TiXmlNode::FirstChildElement() const { - const TiXmlNode* node; + const TiXmlNode* node; - for ( node = FirstChild(); - node; - node = node->NextSibling() ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; + for ( node = FirstChild(); + node; + node = node->NextSibling() ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; } const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const { - const TiXmlNode* node; + const TiXmlNode* node; - for ( node = FirstChild( _value ); - node; - node = node->NextSibling( _value ) ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; + for ( node = FirstChild( _value ); + node; + node = node->NextSibling( _value ) ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; } const TiXmlElement* TiXmlNode::NextSiblingElement() const { - const TiXmlNode* node; + const TiXmlNode* node; - for ( node = NextSibling(); - node; - node = node->NextSibling() ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; + for ( node = NextSibling(); + node; + node = node->NextSibling() ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; } const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const { - const TiXmlNode* node; + const TiXmlNode* node; - for ( node = NextSibling( _value ); - node; - node = node->NextSibling( _value ) ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; + for ( node = NextSibling( _value ); + node; + node = node->NextSibling( _value ) ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; } const TiXmlElement* TiXmlNode::PreviousSiblingElement() const { - const TiXmlNode* node; + const TiXmlNode* node; - for ( node = PreviousSibling(); - node; - node = node->PreviousSibling() ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; + for ( node = PreviousSibling(); + node; + node = node->PreviousSibling() ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; } const TiXmlElement* TiXmlNode::PreviousSiblingElement( const char * _value ) const { - const TiXmlNode* node; + const TiXmlNode* node; - for ( node = PreviousSibling( _value ); - node; - node = node->PreviousSibling( _value ) ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; + for ( node = PreviousSibling( _value ); + node; + node = node->PreviousSibling( _value ) ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; } const TiXmlDocument* TiXmlNode::GetDocument() const { - const TiXmlNode* node; + const TiXmlNode* node; - for( node = this; node; node = node->parent ) - { - if ( node->ToDocument() ) - return node->ToDocument(); - } - return 0; + for( node = this; node; node = node->parent ) + { + if ( node->ToDocument() ) + return node->ToDocument(); + } + return 0; } TiXmlElement::TiXmlElement (const char * _value) - : TiXmlNode( TiXmlNode::ELEMENT ) +: TiXmlNode( TiXmlNode::ELEMENT ) { - firstChild = lastChild = 0; - value = _value; + firstChild = lastChild = 0; + value = _value; } #ifdef TIXML_USE_STL -TiXmlElement::TiXmlElement( const std::string& _value ) - : TiXmlNode( TiXmlNode::ELEMENT ) +TiXmlElement::TiXmlElement( const std::string& _value ) +: TiXmlNode( TiXmlNode::ELEMENT ) { - firstChild = lastChild = 0; - value = _value; + firstChild = lastChild = 0; + value = _value; } #endif TiXmlElement::TiXmlElement( const TiXmlElement& copy) - : TiXmlNode( TiXmlNode::ELEMENT ) +: TiXmlNode( TiXmlNode::ELEMENT ) { - firstChild = lastChild = 0; - copy.CopyTo( this ); + firstChild = lastChild = 0; + copy.CopyTo( this ); } void TiXmlElement::operator=( const TiXmlElement& base ) { - ClearThis(); - base.CopyTo( this ); + ClearThis(); + base.CopyTo( this ); } -TiXmlElement::~TiXmlElement() -{ - ClearThis(); -} + TiXmlElement::~TiXmlElement() + { + ClearThis(); + } void TiXmlElement::ClearThis() { - Clear(); - while( attributeSet.First() ) - { - TiXmlAttribute* node = attributeSet.First(); - attributeSet.Remove( node ); - delete node; - } + Clear(); + while( attributeSet.First() ) + { + TiXmlAttribute* node = attributeSet.First(); + attributeSet.Remove( node ); + delete node; + } } void TiXmlElement::ClearAttributes() { - while( attributeSet.First() ) - { - TiXmlAttribute* node = attributeSet.First(); - attributeSet.Remove( node ); - delete node; - } + while( attributeSet.First() ) + { + TiXmlAttribute* node = attributeSet.First(); + attributeSet.Remove( node ); + delete node; + } } const char* TiXmlElement::Attribute( const char* name ) const { - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - return node->Value(); - return 0; + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( node ) + return node->Value(); + return 0; } #ifdef TIXML_USE_STL const std::string* TiXmlElement::Attribute( const std::string& name ) const { - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - return &node->ValueStr(); - return 0; + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( node ) + return &node->ValueStr(); + return 0; } #endif const char* TiXmlElement::Attribute( const char* name, int* i ) const { - const char* s = Attribute( name ); - if ( i ) - { - if ( s ) { - *i = atoi( s ); - } - else { - *i = 0; - } - } - return s; + const char* s = Attribute( name ); + if ( i ) + { + if ( s ) { + *i = atoi( s ); + } + else { + *i = 0; + } + } + return s; } #ifdef TIXML_USE_STL const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const { - const std::string* s = Attribute( name ); - if ( i ) - { - if ( s ) { - *i = atoi( s->c_str() ); - } - else { - *i = 0; - } - } - return s; + const std::string* s = Attribute( name ); + if ( i ) + { + if ( s ) { + *i = atoi( s->c_str() ); + } + else { + *i = 0; + } + } + return s; } #endif const char* TiXmlElement::Attribute( const char* name, double* d ) const { - const char* s = Attribute( name ); - if ( d ) - { - if ( s ) { - *d = atof( s ); - } - else { - *d = 0; - } - } - return s; + const char* s = Attribute( name ); + if ( d ) + { + if ( s ) { + *d = atof( s ); + } + else { + *d = 0; + } + } + return s; } #ifdef TIXML_USE_STL const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const { - const std::string* s = Attribute( name ); - if ( d ) - { - if ( s ) { - *d = atof( s->c_str() ); - } - else { - *d = 0; - } - } - return s; + const std::string* s = Attribute( name ); + if ( d ) + { + if ( s ) { + *d = atof( s->c_str() ); + } + else { + *d = 0; + } + } + return s; } #endif int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const { - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryIntValue( ival ); + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + return node->QueryIntValue( ival ); } #ifdef TIXML_USE_STL int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const { - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryIntValue( ival ); + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + return node->QueryIntValue( ival ); } #endif int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const { - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryDoubleValue( dval ); + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + return node->QueryDoubleValue( dval ); } #ifdef TIXML_USE_STL int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const { - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryDoubleValue( dval ); + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + return node->QueryDoubleValue( dval ); } #endif void TiXmlElement::SetAttribute( const char * name, int val ) -{ - char buf[64]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "%d", val ); - #else - sprintf( buf, "%d", val ); - #endif - SetAttribute( name, buf ); +{ + char buf[64]; +#if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "%d", val ); +#else + sprintf( buf, "%d", val ); +#endif + SetAttribute( name, buf ); } #ifdef TIXML_USE_STL void TiXmlElement::SetAttribute( const std::string& name, int val ) -{ - std::ostringstream oss; - oss << val; - SetAttribute( name, oss.str() ); +{ + std::ostringstream oss; + oss << val; + SetAttribute( name, oss.str() ); } #endif void TiXmlElement::SetDoubleAttribute( const char * name, double val ) -{ - char buf[256]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "%f", val ); - #else - sprintf( buf, "%f", val ); - #endif - SetAttribute( name, buf ); +{ + char buf[256]; +#if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "%f", val ); +#else + sprintf( buf, "%f", val ); +#endif + SetAttribute( name, buf ); } void TiXmlElement::SetAttribute( const char * cname, const char * cvalue ) { - #ifdef TIXML_USE_STL - TIXML_STRING _name( cname ); - TIXML_STRING _value( cvalue ); - #else - const char* _name = cname; - const char* _value = cvalue; - #endif - - TiXmlAttribute* node = attributeSet.Find( _name ); - if ( node ) - { - node->SetValue( _value ); - return; - } - - TiXmlAttribute* attrib = new TiXmlAttribute( cname, cvalue ); - if ( attrib ) - { - attributeSet.Add( attrib ); - } - else - { - TiXmlDocument* document = GetDocument(); - if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); - } +#ifdef TIXML_USE_STL + TIXML_STRING _name( cname ); + TIXML_STRING _value( cvalue ); +#else + const char* _name = cname; + const char* _value = cvalue; +#endif + + TiXmlAttribute* node = attributeSet.Find( _name ); + if ( node ) + { + node->SetValue( _value ); + return; + } + + TiXmlAttribute* attrib = new TiXmlAttribute( cname, cvalue ); + if ( attrib ) + { + attributeSet.Add( attrib ); + } + else + { + TiXmlDocument* document = GetDocument(); + if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); + } } #ifdef TIXML_USE_STL void TiXmlElement::SetAttribute( const std::string& name, const std::string& _value ) { - TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - { - node->SetValue( _value ); - return; - } - - TiXmlAttribute* attrib = new TiXmlAttribute( name, _value ); - if ( attrib ) - { - attributeSet.Add( attrib ); - } - else - { - TiXmlDocument* document = GetDocument(); - if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); - } + TiXmlAttribute* node = attributeSet.Find( name ); + if ( node ) + { + node->SetValue( _value ); + return; + } + + TiXmlAttribute* attrib = new TiXmlAttribute( name, _value ); + if ( attrib ) + { + attributeSet.Add( attrib ); + } + else + { + TiXmlDocument* document = GetDocument(); + if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); + } } #endif void TiXmlElement::Print( FILE* cfile, int depth ) const { - int i; - assert( cfile ); - for ( i=0; i<depth; i++ ) { - fprintf( cfile, " " ); - } - - fprintf( cfile, "<%s", value.c_str() ); - - const TiXmlAttribute* attrib; - for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() ) - { - fprintf( cfile, " " ); - attrib->Print( cfile, depth ); - } - - // There are 3 different formatting approaches: - // 1) An element without children is printed as a <foo /> node - // 2) An element with only a text child is printed as <foo> text </foo> - // 3) An element with children is printed on multiple lines. - TiXmlNode* node; - if ( !firstChild ) - { - fprintf( cfile, " />" ); - } - else if ( firstChild == lastChild && firstChild->ToText() ) - { - fprintf( cfile, ">" ); - firstChild->Print( cfile, depth + 1 ); - fprintf( cfile, "</%s>", value.c_str() ); - } - else - { - fprintf( cfile, ">" ); - - for ( node = firstChild; node; node=node->NextSibling() ) - { - if ( !node->ToText() ) - { - fprintf( cfile, "\n" ); - } - node->Print( cfile, depth+1 ); - } - fprintf( cfile, "\n" ); - for( i=0; i<depth; ++i ) { - fprintf( cfile, " " ); - } - fprintf( cfile, "</%s>", value.c_str() ); - } + int i; + assert( cfile ); + for ( i=0; i<depth; i++ ) { + fprintf( cfile, " " ); + } + + fprintf( cfile, "<%s", value.c_str() ); + + const TiXmlAttribute* attrib; + for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() ) + { + fprintf( cfile, " " ); + attrib->Print( cfile, depth ); + } + + // There are 3 different formatting approaches: + // 1) An element without children is printed as a <foo /> node + // 2) An element with only a text child is printed as <foo> text </foo> + // 3) An element with children is printed on multiple lines. + TiXmlNode* node; + if ( !firstChild ) + { + fprintf( cfile, " />" ); + } + else if ( firstChild == lastChild && firstChild->ToText() ) + { + fprintf( cfile, ">" ); + firstChild->Print( cfile, depth + 1 ); + fprintf( cfile, "</%s>", value.c_str() ); + } + else + { + fprintf( cfile, ">" ); + + for ( node = firstChild; node; node=node->NextSibling() ) + { + if ( !node->ToText() ) + { + fprintf( cfile, "\n" ); + } + node->Print( cfile, depth+1 ); + } + fprintf( cfile, "\n" ); + for( i=0; i<depth; ++i ) { + fprintf( cfile, " " ); + } + fprintf( cfile, "</%s>", value.c_str() ); + } } void TiXmlElement::CopyTo( TiXmlElement* target ) const { - // superclass: - TiXmlNode::CopyTo( target ); + // superclass: + TiXmlNode::CopyTo( target ); - // Element class: - // Clone the attributes, then clone the children. - const TiXmlAttribute* attribute = 0; - for( attribute = attributeSet.First(); - attribute; - attribute = attribute->Next() ) - { - target->SetAttribute( attribute->Name(), attribute->Value() ); - } + // Element class: + // Clone the attributes, then clone the children. + const TiXmlAttribute* attribute = 0; + for( attribute = attributeSet.First(); + attribute; + attribute = attribute->Next() ) + { + target->SetAttribute( attribute->Name(), attribute->Value() ); + } - TiXmlNode* node = 0; - for ( node = firstChild; node; node = node->NextSibling() ) - { - target->LinkEndChild( node->Clone() ); - } + TiXmlNode* node = 0; + for ( node = firstChild; node; node = node->NextSibling() ) + { + target->LinkEndChild( node->Clone() ); + } } bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const { - if ( visitor->VisitEnter( *this, attributeSet.First() ) ) - { - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - if ( !node->Accept( visitor ) ) - break; - } - } - return visitor->VisitExit( *this ); + if ( visitor->VisitEnter( *this, attributeSet.First() ) ) + { + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + if ( !node->Accept( visitor ) ) + break; + } + } + return visitor->VisitExit( *this ); } TiXmlNode* TiXmlElement::Clone() const { - TiXmlElement* clone = new TiXmlElement( Value() ); - if ( !clone ) - return 0; + TiXmlElement* clone = new TiXmlElement( Value() ); + if ( !clone ) + return 0; - CopyTo( clone ); - return clone; + CopyTo( clone ); + return clone; } const char* TiXmlElement::GetText() const { - const TiXmlNode* child = this->FirstChild(); - if ( child ) { - const TiXmlText* childText = child->ToText(); - if ( childText ) { - return childText->Value(); - } - } - return 0; + const TiXmlNode* child = this->FirstChild(); + if ( child ) { + const TiXmlText* childText = child->ToText(); + if ( childText ) { + return childText->Value(); + } + } + return 0; } TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT ) { - tabsize = 4; - useMicrosoftBOM = false; - ClearError(); + tabsize = 4; + useMicrosoftBOM = false; + ClearError(); } TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) { - tabsize = 4; - useMicrosoftBOM = false; - value = documentName; - ClearError(); + tabsize = 4; + useMicrosoftBOM = false; + value = documentName; + ClearError(); } #ifdef TIXML_USE_STL TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) { - tabsize = 4; - useMicrosoftBOM = false; - value = documentName; - ClearError(); + tabsize = 4; + useMicrosoftBOM = false; + value = documentName; + ClearError(); } #endif TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::DOCUMENT ) { - copy.CopyTo( this ); + copy.CopyTo( this ); } void TiXmlDocument::operator=( const TiXmlDocument& copy ) { - Clear(); - copy.CopyTo( this ); + Clear(); + copy.CopyTo( this ); } -bool TiXmlDocument::LoadFile( TiXmlEncoding encoding ) -{ - // See STL_STRING_BUG below. - //StringToBuffer buf( value ); + bool TiXmlDocument::LoadFile( TiXmlEncoding encoding ) + { + // See STL_STRING_BUG below. + //StringToBuffer buf( value ); - return LoadFile( Value(), encoding ); -} + return LoadFile( Value(), encoding ); + } bool TiXmlDocument::SaveFile() const { - // See STL_STRING_BUG below. -// StringToBuffer buf( value ); -// -// if ( buf.buffer && SaveFile( buf.buffer ) ) -// return true; -// -// return false; - return SaveFile( Value() ); + // See STL_STRING_BUG below. + // StringToBuffer buf( value ); + // + // if ( buf.buffer && SaveFile( buf.buffer ) ) + // return true; + // + // return false; + return SaveFile( Value() ); } bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding ) { - // There was a really terrifying little bug here. The code: - // value = filename - // in the STL case, cause the assignment method of the std::string to - // be called. What is strange, is that the std::string had the same - // address as it's c_str() method, and so bad things happen. Looks - // like a bug in the Microsoft STL implementation. - // Add an extra string to avoid the crash. - TIXML_STRING filename( _filename ); - value = filename; - - // reading in binary mode so that tinyxml can normalize the EOL - FILE* file = fopen( value.c_str (), "rb" ); - - if ( file ) - { - bool result = LoadFile( file, encoding ); - fclose( file ); - return result; - } - else - { - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } + // There was a really terrifying little bug here. The code: + // value = filename + // in the STL case, cause the assignment method of the std::string to + // be called. What is strange, is that the std::string had the same + // address as it's c_str() method, and so bad things happen. Looks + // like a bug in the Microsoft STL implementation. + // Add an extra string to avoid the crash. + TIXML_STRING filename( _filename ); + value = filename; + + // reading in binary mode so that tinyxml can normalize the EOL + FILE* file = fopen( value.c_str (), "rb" ); + + if ( file ) + { + bool result = LoadFile( file, encoding ); + fclose( file ); + return result; + } + else + { + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } } bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) { - if ( !file ) - { - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - // Delete the existing data: - Clear(); - location.Clear(); - - // Get the file size, so we can pre-allocate the string. HUGE speed impact. - long length = 0; - fseek( file, 0, SEEK_END ); - length = ftell( file ); - fseek( file, 0, SEEK_SET ); - - // Strange case, but good to handle up front. - if ( length == 0 ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - // If we have a file, assume it is all one big XML file, and read it in. - // The document parser may decide the document ends sooner than the entire file, however. - TIXML_STRING data; - data.reserve( length ); - - // Subtle bug here. TinyXml did use fgets. But from the XML spec: - // 2.11 End-of-Line Handling - // <snip> - // <quote> - // ...the XML processor MUST behave as if it normalized all line breaks in external - // parsed entities (including the document entity) on input, before parsing, by translating - // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to - // a single #xA character. - // </quote> - // - // It is not clear fgets does that, and certainly isn't clear it works cross platform. - // Generally, you expect fgets to translate from the convention of the OS to the c/unix - // convention, and not work generally. - - /* - while( fgets( buf, sizeof(buf), file ) ) - { - data += buf; - } - */ - - char* buf = new char[ length+1 ]; - buf[0] = 0; - - if ( fread( buf, length, 1, file ) != 1 ) { - delete [] buf; - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - const char* lastPos = buf; - const char* p = buf; - - buf[length] = 0; - while( *p ) { - assert( p < (buf+length) ); - if ( *p == 0xa ) { - // Newline character. No special rules for this. Append all the characters - // since the last string, and include the newline. - data.append( lastPos, (p-lastPos+1) ); // append, include the newline - ++p; // move past the newline - lastPos = p; // and point to the new buffer (may be 0) - assert( p <= (buf+length) ); - } - else if ( *p == 0xd ) { - // Carriage return. Append what we have so far, then - // handle moving forward in the buffer. - if ( (p-lastPos) > 0 ) { - data.append( lastPos, p-lastPos ); // do not add the CR - } - data += (char)0xa; // a proper newline - - if ( *(p+1) == 0xa ) { - // Carriage return - new line sequence - p += 2; - lastPos = p; - assert( p <= (buf+length) ); - } - else { - // it was followed by something else...that is presumably characters again. - ++p; - lastPos = p; - assert( p <= (buf+length) ); - } - } - else { - ++p; - } - } - // Handle any left over characters. - if ( p-lastPos ) { - data.append( lastPos, p-lastPos ); - } - delete [] buf; - buf = 0; - - Parse( data.c_str(), 0, encoding ); - - if ( Error() ) - return false; - else - return true; + if ( !file ) + { + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + // Delete the existing data: + Clear(); + location.Clear(); + + // Get the file size, so we can pre-allocate the string. HUGE speed impact. + long length = 0; + fseek( file, 0, SEEK_END ); + length = ftell( file ); + fseek( file, 0, SEEK_SET ); + + // Strange case, but good to handle up front. + if ( length == 0 ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + // If we have a file, assume it is all one big XML file, and read it in. + // The document parser may decide the document ends sooner than the entire file, however. + TIXML_STRING data; + data.reserve( length ); + + // Subtle bug here. TinyXml did use fgets. But from the XML spec: + // 2.11 End-of-Line Handling + // <snip> + // <quote> + // ...the XML processor MUST behave as if it normalized all line breaks in external + // parsed entities (including the document entity) on input, before parsing, by translating + // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to + // a single #xA character. + // </quote> + // + // It is not clear fgets does that, and certainly isn't clear it works cross platform. + // Generally, you expect fgets to translate from the convention of the OS to the c/unix + // convention, and not work generally. + + /* + while( fgets( buf, sizeof(buf), file ) ) + { + data += buf; + } + */ + + char* buf = new char[ length+1 ]; + buf[0] = 0; + + if ( fread( buf, length, 1, file ) != 1 ) { + delete [] buf; + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + const char* lastPos = buf; + const char* p = buf; + + buf[length] = 0; + while( *p ) { + assert( p < (buf+length) ); + if ( *p == 0xa ) { + // Newline character. No special rules for this. Append all the characters + // since the last string, and include the newline. + data.append( lastPos, (p-lastPos+1) ); // append, include the newline + ++p; // move past the newline + lastPos = p; // and point to the new buffer (may be 0) + assert( p <= (buf+length) ); + } + else if ( *p == 0xd ) { + // Carriage return. Append what we have so far, then + // handle moving forward in the buffer. + if ( (p-lastPos) > 0 ) { + data.append( lastPos, p-lastPos ); // do not add the CR + } + data += (char)0xa; // a proper newline + + if ( *(p+1) == 0xa ) { + // Carriage return - new line sequence + p += 2; + lastPos = p; + assert( p <= (buf+length) ); + } + else { + // it was followed by something else...that is presumably characters again. + ++p; + lastPos = p; + assert( p <= (buf+length) ); + } + } + else { + ++p; + } + } + // Handle any left over characters. + if ( p-lastPos ) { + data.append( lastPos, p-lastPos ); + } + delete [] buf; + buf = 0; + + Parse( data.c_str(), 0, encoding ); + + if ( Error() ) + return false; + else + return true; } bool TiXmlDocument::SaveFile( const char * filename ) const { - // The old c stuff lives on... - FILE* fp = fopen( filename, "w" ); - if ( fp ) - { - bool result = SaveFile( fp ); - fclose( fp ); - return result; - } - return false; + // The old c stuff lives on... + FILE* fp = fopen( filename, "w" ); + if ( fp ) + { + bool result = SaveFile( fp ); + fclose( fp ); + return result; + } + return false; } bool TiXmlDocument::SaveFile( FILE* fp ) const { - if ( useMicrosoftBOM ) - { - const unsigned char TIXML_UTF_LEAD_0 = 0xefU; - const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; - const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; + if ( useMicrosoftBOM ) + { + const unsigned char TIXML_UTF_LEAD_0 = 0xefU; + const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; + const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; - fputc( TIXML_UTF_LEAD_0, fp ); - fputc( TIXML_UTF_LEAD_1, fp ); - fputc( TIXML_UTF_LEAD_2, fp ); - } - Print( fp, 0 ); - return (ferror(fp) == 0); + fputc( TIXML_UTF_LEAD_0, fp ); + fputc( TIXML_UTF_LEAD_1, fp ); + fputc( TIXML_UTF_LEAD_2, fp ); + } + Print( fp, 0 ); + return (ferror(fp) == 0); } void TiXmlDocument::CopyTo( TiXmlDocument* target ) const { - TiXmlNode::CopyTo( target ); + TiXmlNode::CopyTo( target ); - target->error = error; - target->errorDesc = errorDesc.c_str (); + target->error = error; + target->errorDesc = errorDesc.c_str (); - TiXmlNode* node = 0; - for ( node = firstChild; node; node = node->NextSibling() ) - { - target->LinkEndChild( node->Clone() ); - } + TiXmlNode* node = 0; + for ( node = firstChild; node; node = node->NextSibling() ) + { + target->LinkEndChild( node->Clone() ); + } } TiXmlNode* TiXmlDocument::Clone() const { - TiXmlDocument* clone = new TiXmlDocument(); - if ( !clone ) - return 0; + TiXmlDocument* clone = new TiXmlDocument(); + if ( !clone ) + return 0; - CopyTo( clone ); - return clone; + CopyTo( clone ); + return clone; } void TiXmlDocument::Print( FILE* cfile, int depth ) const { - assert( cfile ); - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - node->Print( cfile, depth ); - fprintf( cfile, "\n" ); - } + assert( cfile ); + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + node->Print( cfile, depth ); + fprintf( cfile, "\n" ); + } } bool TiXmlDocument::Accept( TiXmlVisitor* visitor ) const { - if ( visitor->VisitEnter( *this ) ) - { - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - if ( !node->Accept( visitor ) ) - break; - } - } - return visitor->VisitExit( *this ); + if ( visitor->VisitEnter( *this ) ) + { + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + if ( !node->Accept( visitor ) ) + break; + } + } + return visitor->VisitExit( *this ); } const TiXmlAttribute* TiXmlAttribute::Next() const { - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( next->value.empty() && next->name.empty() ) - return 0; - return next; + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( next->value.empty() && next->name.empty() ) + return 0; + return next; } /* -TiXmlAttribute* TiXmlAttribute::Next() -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( next->value.empty() && next->name.empty() ) - return 0; - return next; -} + TiXmlAttribute* TiXmlAttribute::Next() + { + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( next->value.empty() && next->name.empty() ) + return 0; + return next; + } */ const TiXmlAttribute* TiXmlAttribute::Previous() const { - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( prev->value.empty() && prev->name.empty() ) - return 0; - return prev; + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( prev->value.empty() && prev->name.empty() ) + return 0; + return prev; } /* -TiXmlAttribute* TiXmlAttribute::Previous() -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( prev->value.empty() && prev->name.empty() ) - return 0; - return prev; -} + TiXmlAttribute* TiXmlAttribute::Previous() + { + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( prev->value.empty() && prev->name.empty() ) + return 0; + return prev; + } */ void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const { - TIXML_STRING n, v; + TIXML_STRING n, v; - PutString( name, &n ); - PutString( value, &v ); + PutString( name, &n ); + PutString( value, &v ); - if (value.find ('\"') == TIXML_STRING::npos) { - if ( cfile ) { - fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); - } - if ( str ) { - (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\""; - } - } - else { - if ( cfile ) { - fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); - } - if ( str ) { - (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; - } - } + if (value.find ('\"') == TIXML_STRING::npos) { + if ( cfile ) { + fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); + } + if ( str ) { + (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\""; + } + } + else { + if ( cfile ) { + fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); + } + if ( str ) { + (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; + } + } } int TiXmlAttribute::QueryIntValue( int* ival ) const { - if ( sscanf( value.c_str(), "%d", ival ) == 1 ) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; + if ( sscanf( value.c_str(), "%d", ival ) == 1 ) + return TIXML_SUCCESS; + return TIXML_WRONG_TYPE; } int TiXmlAttribute::QueryDoubleValue( double* dval ) const { - if ( sscanf( value.c_str(), "%lf", dval ) == 1 ) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; + if ( sscanf( value.c_str(), "%lf", dval ) == 1 ) + return TIXML_SUCCESS; + return TIXML_WRONG_TYPE; } void TiXmlAttribute::SetIntValue( int _value ) { - char buf [64]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); - #else - sprintf (buf, "%d", _value); - #endif - SetValue (buf); + char buf [64]; +#if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); +#else + sprintf (buf, "%d", _value); +#endif + SetValue (buf); } void TiXmlAttribute::SetDoubleValue( double _value ) { - char buf [256]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "%f", _value); - #else - sprintf (buf, "%f", _value); - #endif - SetValue (buf); + char buf [256]; +#if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "%f", _value); +#else + sprintf (buf, "%f", _value); +#endif + SetValue (buf); } int TiXmlAttribute::IntValue() const { - return atoi (value.c_str ()); + return atoi (value.c_str ()); } double TiXmlAttribute::DoubleValue() const { - return atof (value.c_str ()); + return atof (value.c_str ()); } TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::COMMENT ) { - copy.CopyTo( this ); + copy.CopyTo( this ); } void TiXmlComment::operator=( const TiXmlComment& base ) { - Clear(); - base.CopyTo( this ); + Clear(); + base.CopyTo( this ); } -void TiXmlComment::Print( FILE* cfile, int depth ) const -{ - assert( cfile ); - for ( int i=0; i<depth; i++ ) - { - fprintf( cfile, " " ); - } - fprintf( cfile, "<!--%s-->", value.c_str() ); -} + void TiXmlComment::Print( FILE* cfile, int depth ) const + { + assert( cfile ); + for ( int i=0; i<depth; i++ ) + { + fprintf( cfile, " " ); + } + fprintf( cfile, "<!--%s-->", value.c_str() ); + } void TiXmlComment::CopyTo( TiXmlComment* target ) const { - TiXmlNode::CopyTo( target ); + TiXmlNode::CopyTo( target ); } bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const { - return visitor->Visit( *this ); + return visitor->Visit( *this ); } TiXmlNode* TiXmlComment::Clone() const { - TiXmlComment* clone = new TiXmlComment(); + TiXmlComment* clone = new TiXmlComment(); - if ( !clone ) - return 0; + if ( !clone ) + return 0; - CopyTo( clone ); - return clone; + CopyTo( clone ); + return clone; } void TiXmlText::Print( FILE* cfile, int depth ) const { - assert( cfile ); - if ( cdata ) - { - int i; - fprintf( cfile, "\n" ); - for ( i=0; i<depth; i++ ) { - fprintf( cfile, " " ); - } - fprintf( cfile, "<![CDATA[%s]]>\n", value.c_str() ); // unformatted output - } - else - { - TIXML_STRING buffer; - PutString( value, &buffer ); - fprintf( cfile, "%s", buffer.c_str() ); - } + assert( cfile ); + if ( cdata ) + { + int i; + fprintf( cfile, "\n" ); + for ( i=0; i<depth; i++ ) { + fprintf( cfile, " " ); + } + fprintf( cfile, "<![CDATA[%s]]>\n", value.c_str() ); // unformatted output + } + else + { + TIXML_STRING buffer; + PutString( value, &buffer ); + fprintf( cfile, "%s", buffer.c_str() ); + } } void TiXmlText::CopyTo( TiXmlText* target ) const { - TiXmlNode::CopyTo( target ); - target->cdata = cdata; + TiXmlNode::CopyTo( target ); + target->cdata = cdata; } bool TiXmlText::Accept( TiXmlVisitor* visitor ) const { - return visitor->Visit( *this ); + return visitor->Visit( *this ); } TiXmlNode* TiXmlText::Clone() const -{ - TiXmlText* clone = 0; - clone = new TiXmlText( "" ); +{ + TiXmlText* clone = 0; + clone = new TiXmlText( "" ); - if ( !clone ) - return 0; + if ( !clone ) + return 0; - CopyTo( clone ); - return clone; + CopyTo( clone ); + return clone; } TiXmlDeclaration::TiXmlDeclaration( const char * _version, - const char * _encoding, - const char * _standalone ) - : TiXmlNode( TiXmlNode::DECLARATION ) + const char * _encoding, + const char * _standalone ) +: TiXmlNode( TiXmlNode::DECLARATION ) { - version = _version; - encoding = _encoding; - standalone = _standalone; + version = _version; + encoding = _encoding; + standalone = _standalone; } #ifdef TIXML_USE_STL -TiXmlDeclaration::TiXmlDeclaration( const std::string& _version, - const std::string& _encoding, - const std::string& _standalone ) - : TiXmlNode( TiXmlNode::DECLARATION ) +TiXmlDeclaration::TiXmlDeclaration( const std::string& _version, + const std::string& _encoding, + const std::string& _standalone ) +: TiXmlNode( TiXmlNode::DECLARATION ) { - version = _version; - encoding = _encoding; - standalone = _standalone; + version = _version; + encoding = _encoding; + standalone = _standalone; } #endif TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy ) - : TiXmlNode( TiXmlNode::DECLARATION ) +: TiXmlNode( TiXmlNode::DECLARATION ) { - copy.CopyTo( this ); + copy.CopyTo( this ); } void TiXmlDeclaration::operator=( const TiXmlDeclaration& copy ) { - Clear(); - copy.CopyTo( this ); + Clear(); + copy.CopyTo( this ); } -void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const -{ - if ( cfile ) fprintf( cfile, "<?xml " ); - if ( str ) (*str) += "<?xml "; + void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const + { + if ( cfile ) fprintf( cfile, "<?xml " ); + if ( str ) (*str) += "<?xml "; - if ( !version.empty() ) { - if ( cfile ) fprintf (cfile, "version=\"%s\" ", version.c_str ()); - if ( str ) { (*str) += "version=\""; (*str) += version; (*str) += "\" "; } - } - if ( !encoding.empty() ) { - if ( cfile ) fprintf (cfile, "encoding=\"%s\" ", encoding.c_str ()); - if ( str ) { (*str) += "encoding=\""; (*str) += encoding; (*str) += "\" "; } - } - if ( !standalone.empty() ) { - if ( cfile ) fprintf (cfile, "standalone=\"%s\" ", standalone.c_str ()); - if ( str ) { (*str) += "standalone=\""; (*str) += standalone; (*str) += "\" "; } - } - if ( cfile ) fprintf( cfile, "?>" ); - if ( str ) (*str) += "?>"; -} + if ( !version.empty() ) { + if ( cfile ) fprintf (cfile, "version=\"%s\" ", version.c_str ()); + if ( str ) { (*str) += "version=\""; (*str) += version; (*str) += "\" "; } + } + if ( !encoding.empty() ) { + if ( cfile ) fprintf (cfile, "encoding=\"%s\" ", encoding.c_str ()); + if ( str ) { (*str) += "encoding=\""; (*str) += encoding; (*str) += "\" "; } + } + if ( !standalone.empty() ) { + if ( cfile ) fprintf (cfile, "standalone=\"%s\" ", standalone.c_str ()); + if ( str ) { (*str) += "standalone=\""; (*str) += standalone; (*str) += "\" "; } + } + if ( cfile ) fprintf( cfile, "?>" ); + if ( str ) (*str) += "?>"; + } void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const { - TiXmlNode::CopyTo( target ); + TiXmlNode::CopyTo( target ); - target->version = version; - target->encoding = encoding; - target->standalone = standalone; + target->version = version; + target->encoding = encoding; + target->standalone = standalone; } bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const { - return visitor->Visit( *this ); + return visitor->Visit( *this ); } TiXmlNode* TiXmlDeclaration::Clone() const -{ - TiXmlDeclaration* clone = new TiXmlDeclaration(); +{ + TiXmlDeclaration* clone = new TiXmlDeclaration(); - if ( !clone ) - return 0; + if ( !clone ) + return 0; - CopyTo( clone ); - return clone; + CopyTo( clone ); + return clone; } void TiXmlUnknown::Print( FILE* cfile, int depth ) const { - for ( int i=0; i<depth; i++ ) - fprintf( cfile, " " ); - fprintf( cfile, "<%s>", value.c_str() ); + for ( int i=0; i<depth; i++ ) + fprintf( cfile, " " ); + fprintf( cfile, "<%s>", value.c_str() ); } void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const { - TiXmlNode::CopyTo( target ); + TiXmlNode::CopyTo( target ); } bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const { - return visitor->Visit( *this ); + return visitor->Visit( *this ); } TiXmlNode* TiXmlUnknown::Clone() const { - TiXmlUnknown* clone = new TiXmlUnknown(); + TiXmlUnknown* clone = new TiXmlUnknown(); - if ( !clone ) - return 0; + if ( !clone ) + return 0; - CopyTo( clone ); - return clone; + CopyTo( clone ); + return clone; } TiXmlAttributeSet::TiXmlAttributeSet() { - sentinel.next = &sentinel; - sentinel.prev = &sentinel; + sentinel.next = &sentinel; + sentinel.prev = &sentinel; } TiXmlAttributeSet::~TiXmlAttributeSet() { - assert( sentinel.next == &sentinel ); - assert( sentinel.prev == &sentinel ); + assert( sentinel.next == &sentinel ); + assert( sentinel.prev == &sentinel ); } void TiXmlAttributeSet::Add( TiXmlAttribute* addMe ) { - #ifdef TIXML_USE_STL - assert( !Find( TIXML_STRING( addMe->Name() ) ) ); // Shouldn't be multiply adding to the set. - #else - assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set. - #endif +#ifdef TIXML_USE_STL + assert( !Find( TIXML_STRING( addMe->Name() ) ) ); // Shouldn't be multiply adding to the set. +#else + assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set. +#endif - addMe->next = &sentinel; - addMe->prev = sentinel.prev; + addMe->next = &sentinel; + addMe->prev = sentinel.prev; - sentinel.prev->next = addMe; - sentinel.prev = addMe; + sentinel.prev->next = addMe; + sentinel.prev = addMe; } void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) { - TiXmlAttribute* node; + TiXmlAttribute* node; - for( node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node == removeMe ) - { - node->prev->next = node->next; - node->next->prev = node->prev; - node->next = 0; - node->prev = 0; - return; - } - } - assert( 0 ); // we tried to remove a non-linked attribute. + for( node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( node == removeMe ) + { + node->prev->next = node->next; + node->next->prev = node->prev; + node->next = 0; + node->prev = 0; + return; + } + } + assert( 0 ); // we tried to remove a non-linked attribute. } #ifdef TIXML_USE_STL const TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const { - for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node->name == name ) - return node; - } - return 0; + for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( node->name == name ) + return node; + } + return 0; } /* -TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) -{ - for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node->name == name ) - return node; - } - return 0; -} + TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) + { + for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( node->name == name ) + return node; + } + return 0; + } */ #endif const TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const { - for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( strcmp( node->name.c_str(), name ) == 0 ) - return node; - } - return 0; + for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( strcmp( node->name.c_str(), name ) == 0 ) + return node; + } + return 0; } /* -TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) -{ - for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( strcmp( node->name.c_str(), name ) == 0 ) - return node; - } - return 0; -} + TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) + { + for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( strcmp( node->name.c_str(), name ) == 0 ) + return node; + } + return 0; + } */ -#ifdef TIXML_USE_STL +#ifdef TIXML_USE_STL std::istream& operator>> (std::istream & in, TiXmlNode & base) { - TIXML_STRING tag; - tag.reserve( 8 * 1000 ); - base.StreamIn( &in, &tag ); + TIXML_STRING tag; + tag.reserve( 8 * 1000 ); + base.StreamIn( &in, &tag ); - base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING ); - return in; + base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING ); + return in; } #endif -#ifdef TIXML_USE_STL +#ifdef TIXML_USE_STL std::ostream& operator<< (std::ostream & out, const TiXmlNode & base) { - TiXmlPrinter printer; - printer.SetStreamPrinting(); - base.Accept( &printer ); - out << printer.Str(); + TiXmlPrinter printer; + printer.SetStreamPrinting(); + base.Accept( &printer ); + out << printer.Str(); - return out; + return out; } std::string& operator<< (std::string& out, const TiXmlNode& base ) { - TiXmlPrinter printer; - printer.SetStreamPrinting(); - base.Accept( &printer ); - out.append( printer.Str() ); + TiXmlPrinter printer; + printer.SetStreamPrinting(); + base.Accept( &printer ); + out.append( printer.Str() ); - return out; + return out; } #endif TiXmlHandle TiXmlHandle::FirstChild() const { - if ( node ) - { - TiXmlNode* child = node->FirstChild(); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); + if ( node ) + { + TiXmlNode* child = node->FirstChild(); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const { - if ( node ) - { - TiXmlNode* child = node->FirstChild( value ); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); + if ( node ) + { + TiXmlNode* child = node->FirstChild( value ); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::FirstChildElement() const { - if ( node ) - { - TiXmlElement* child = node->FirstChildElement(); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); + if ( node ) + { + TiXmlElement* child = node->FirstChildElement(); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const { - if ( node ) - { - TiXmlElement* child = node->FirstChildElement( value ); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); + if ( node ) + { + TiXmlElement* child = node->FirstChildElement( value ); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::Child( int count ) const { - if ( node ) - { - int i; - TiXmlNode* child = node->FirstChild(); - for ( i=0; - child && i<count; - child = child->NextSibling(), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); + if ( node ) + { + int i; + TiXmlNode* child = node->FirstChild(); + for ( i=0; + child && i<count; + child = child->NextSibling(), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const { - if ( node ) - { - int i; - TiXmlNode* child = node->FirstChild( value ); - for ( i=0; - child && i<count; - child = child->NextSibling( value ), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); + if ( node ) + { + int i; + TiXmlNode* child = node->FirstChild( value ); + for ( i=0; + child && i<count; + child = child->NextSibling( value ), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::ChildElement( int count ) const { - if ( node ) - { - int i; - TiXmlElement* child = node->FirstChildElement(); - for ( i=0; - child && i<count; - child = child->NextSiblingElement(), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); + if ( node ) + { + int i; + TiXmlElement* child = node->FirstChildElement(); + for ( i=0; + child && i<count; + child = child->NextSiblingElement(), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const { - if ( node ) - { - int i; - TiXmlElement* child = node->FirstChildElement( value ); - for ( i=0; - child && i<count; - child = child->NextSiblingElement( value ), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); + if ( node ) + { + int i; + TiXmlElement* child = node->FirstChildElement( value ); + for ( i=0; + child && i<count; + child = child->NextSiblingElement( value ), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); } bool TiXmlPrinter::VisitEnter( const TiXmlDocument& ) { - return true; + return true; } bool TiXmlPrinter::VisitExit( const TiXmlDocument& ) { - return true; + return true; } bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) { - DoIndent(); - buffer += "<"; - buffer += element.Value(); - - for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) - { - buffer += " "; - attrib->Print( 0, 0, &buffer ); - } - - if ( !element.FirstChild() ) - { - buffer += " />"; - DoLineBreak(); - } - else - { - buffer += ">"; - if ( element.FirstChild()->ToText() - && element.LastChild() == element.FirstChild() - && element.FirstChild()->ToText()->CDATA() == false ) - { - simpleTextPrint = true; - // no DoLineBreak()! - } - else - { - DoLineBreak(); - } - } - ++depth; - return true; + DoIndent(); + buffer += "<"; + buffer += element.Value(); + + for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) + { + buffer += " "; + attrib->Print( 0, 0, &buffer ); + } + + if ( !element.FirstChild() ) + { + buffer += " />"; + DoLineBreak(); + } + else + { + buffer += ">"; + if ( element.FirstChild()->ToText() + && element.LastChild() == element.FirstChild() + && element.FirstChild()->ToText()->CDATA() == false ) + { + simpleTextPrint = true; + // no DoLineBreak()! + } + else + { + DoLineBreak(); + } + } + ++depth; + return true; } bool TiXmlPrinter::VisitExit( const TiXmlElement& element ) { - --depth; - if ( !element.FirstChild() ) - { - // nothing. - } - else - { - if ( simpleTextPrint ) - { - simpleTextPrint = false; - } - else - { - DoIndent(); - } - buffer += "</"; - buffer += element.Value(); - buffer += ">"; - DoLineBreak(); - } - return true; + --depth; + if ( !element.FirstChild() ) + { + // nothing. + } + else + { + if ( simpleTextPrint ) + { + simpleTextPrint = false; + } + else + { + DoIndent(); + } + buffer += "</"; + buffer += element.Value(); + buffer += ">"; + DoLineBreak(); + } + return true; } bool TiXmlPrinter::Visit( const TiXmlText& text ) { - if ( text.CDATA() ) - { - DoIndent(); - buffer += "<![CDATA["; - buffer += text.Value(); - buffer += "]]>"; - DoLineBreak(); - } - else if ( simpleTextPrint ) - { - buffer += text.Value(); - } - else - { - DoIndent(); - buffer += text.Value(); - DoLineBreak(); - } - return true; + if ( text.CDATA() ) + { + DoIndent(); + buffer += "<![CDATA["; + buffer += text.Value(); + buffer += "]]>"; + DoLineBreak(); + } + else if ( simpleTextPrint ) + { + buffer += text.Value(); + } + else + { + DoIndent(); + buffer += text.Value(); + DoLineBreak(); + } + return true; } bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ) { - DoIndent(); - declaration.Print( 0, 0, &buffer ); - DoLineBreak(); - return true; + DoIndent(); + declaration.Print( 0, 0, &buffer ); + DoLineBreak(); + return true; } bool TiXmlPrinter::Visit( const TiXmlComment& comment ) { - DoIndent(); - buffer += "<!--"; - buffer += comment.Value(); - buffer += "-->"; - DoLineBreak(); - return true; + DoIndent(); + buffer += "<!--"; + buffer += comment.Value(); + buffer += "-->"; + DoLineBreak(); + return true; } bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown ) { - DoIndent(); - buffer += "<"; - buffer += unknown.Value(); - buffer += ">"; - DoLineBreak(); - return true; + DoIndent(); + buffer += "<"; + buffer += unknown.Value(); + buffer += ">"; + DoLineBreak(); + return true; } diff --git a/DDCore/src/XML/tinyxmlerror_inl.h b/DDCore/src/XML/tinyxmlerror_inl.h index 4b5f73317abdbfa287e6367e247116dcc79427d1..7019f8452c60660510ca43991a8442a92232904e 100644 --- a/DDCore/src/XML/tinyxmlerror_inl.h +++ b/DDCore/src/XML/tinyxmlerror_inl.h @@ -1,28 +1,28 @@ /* -www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) + www.sourceforge.net/projects/tinyxml + Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. + 1. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation + would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. + 2. Altered source versions must be plainly marked as such, and + must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source -distribution. + 3. This notice may not be removed or altered from any source + distribution. - F.Gaede, DESY : changed extension to .cc for use with marlin - and include from "marlin/tinyxml.h" + F.Gaede, DESY : changed extension to .cc for use with marlin + and include from "marlin/tinyxml.h" */ #include "XML/tinyxml.h" @@ -36,22 +36,22 @@ distribution. // const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] = -{ - "No error", - "Error", - "Failed to open file", - "Memory allocation failed.", - "Error parsing Element.", - "Failed to read Element name", - "Error reading Element value.", - "Error reading Attributes.", - "Error: empty tag.", - "Error reading end tag.", - "Error parsing Unknown.", - "Error parsing Comment.", - "Error parsing Declaration.", - "Error document empty.", - "Error null (0) or unexpected EOF found in input stream.", - "Error parsing CDATA.", - "Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.", -}; + { + "No error", + "Error", + "Failed to open file", + "Memory allocation failed.", + "Error parsing Element.", + "Failed to read Element name", + "Error reading Element value.", + "Error reading Attributes.", + "Error: empty tag.", + "Error reading end tag.", + "Error parsing Unknown.", + "Error parsing Comment.", + "Error parsing Declaration.", + "Error document empty.", + "Error null (0) or unexpected EOF found in input stream.", + "Error parsing CDATA.", + "Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.", + }; diff --git a/DDCore/src/XML/tinyxmlparser_inl.h b/DDCore/src/XML/tinyxmlparser_inl.h index 30e031effb49df6a3d7379ee14fda1327ef570f7..e6c218fb3e236703a206ec5def1449f267ffa6a3 100644 --- a/DDCore/src/XML/tinyxmlparser_inl.h +++ b/DDCore/src/XML/tinyxmlparser_inl.h @@ -1,28 +1,28 @@ /* -www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com) + www.sourceforge.net/projects/tinyxml + Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com) -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. + 1. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation + would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. + 2. Altered source versions must be plainly marked as such, and + must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source -distribution. + 3. This notice may not be removed or altered from any source + distribution. - F.Gaede, DESY : changed extension to .cc for use with marlin - and include from "marlin/tinyxml.h" + F.Gaede, DESY : changed extension to .cc for use with marlin + and include from "marlin/tinyxml.h" */ @@ -33,373 +33,373 @@ distribution. //#define DEBUG_PARSER #if defined( DEBUG_PARSER ) -# if defined( DEBUG ) && defined( _MSC_VER ) -# include <windows.h> -# define TIXML_LOG OutputDebugString -# else -# define TIXML_LOG printf -# endif +# if defined( DEBUG ) && defined( _MSC_VER ) +# include <windows.h> +# define TIXML_LOG OutputDebugString +# else +# define TIXML_LOG printf +# endif #endif // Note tha "PutString" hardcodes the same list. This // is less flexible than it appears. Changing the entries -// or order will break putstring. -TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] = -{ - //FIXME: workaround for processor conditions of type && - //needs to be tested if there are no adverse effects due to this change!! - { "&", 1, '&' }, - //{ "&", 5, '&' }, - - { "<", 4, '<' }, - { ">", 4, '>' }, - { """, 6, '\"' }, - { "'", 6, '\'' } -}; +// or order will break putstring. +TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] = + { + //FIXME: workaround for processor conditions of type && + //needs to be tested if there are no adverse effects due to this change!! + { "&", 1, '&' }, + //{ "&", 5, '&' }, + + { "<", 4, '<' }, + { ">", 4, '>' }, + { """, 6, '\"' }, + { "'", 6, '\'' } + }; // Bunch of unicode info at: -// http://www.unicode.org/faq/utf_bom.html +// http://www.unicode.org/faq/utf_bom.html // Including the basic of this table, which determines the #bytes in the // sequence from the lead byte. 1 placed for invalid sequences -- // although the result will be junk, pass it through as much as possible. -// Beware of the non-characters in UTF-8: -// ef bb bf (Microsoft "lead bytes") -// ef bf be -// ef bf bf +// Beware of the non-characters in UTF-8: +// ef bb bf (Microsoft "lead bytes") +// ef bf be +// ef bf bf const unsigned char TIXML_UTF_LEAD_0 = 0xefU; const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; -const int TiXmlBase::utf8ByteTable[256] = -{ - // 0 1 2 3 4 5 6 7 8 9 a b c d e f - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x20 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x30 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x50 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 - 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0 - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte - 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid -}; +const int TiXmlBase::utf8ByteTable[256] = + { + // 0 1 2 3 4 5 6 7 8 9 a b c d e f + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x20 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x30 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x50 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 + 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0 + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte + 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid + }; void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) { - const unsigned long BYTE_MASK = 0xBF; - const unsigned long BYTE_MARK = 0x80; - const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; - - if (input < 0x80) - *length = 1; - else if ( input < 0x800 ) - *length = 2; - else if ( input < 0x10000 ) - *length = 3; - else if ( input < 0x200000 ) - *length = 4; - else - { *length = 0; return; } // This code won't covert this correctly anyway. - - output += *length; - - // Scary scary fall throughs. - switch (*length) - { - case 4: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 3: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 2: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 1: - --output; - *output = (char)(input | FIRST_BYTE_MARK[*length]); - } + const unsigned long BYTE_MASK = 0xBF; + const unsigned long BYTE_MARK = 0x80; + const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + + if (input < 0x80) + *length = 1; + else if ( input < 0x800 ) + *length = 2; + else if ( input < 0x10000 ) + *length = 3; + else if ( input < 0x200000 ) + *length = 4; + else + { *length = 0; return; } // This code won't covert this correctly anyway. + + output += *length; + + // Scary scary fall throughs. + switch (*length) + { + case 4: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 3: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 2: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 1: + --output; + *output = (char)(input | FIRST_BYTE_MARK[*length]); + } } /*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) { - // This will only work for low-ascii, everything else is assumed to be a valid - // letter. I'm not sure this is the best approach, but it is quite tricky trying - // to figure out alhabetical vs. not across encoding. So take a very - // conservative approach. - -// if ( encoding == TIXML_ENCODING_UTF8 ) -// { - if ( anyByte < 127 ) - return isalpha( anyByte ); - else - return 1; // What else to do? The unicode set is huge...get the english ones right. -// } -// else -// { -// return isalpha( anyByte ); -// } + // This will only work for low-ascii, everything else is assumed to be a valid + // letter. I'm not sure this is the best approach, but it is quite tricky trying + // to figure out alhabetical vs. not across encoding. So take a very + // conservative approach. + + // if ( encoding == TIXML_ENCODING_UTF8 ) + // { + if ( anyByte < 127 ) + return isalpha( anyByte ); + else + return 1; // What else to do? The unicode set is huge...get the english ones right. + // } + // else + // { + // return isalpha( anyByte ); + // } } /*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) { - // This will only work for low-ascii, everything else is assumed to be a valid - // letter. I'm not sure this is the best approach, but it is quite tricky trying - // to figure out alhabetical vs. not across encoding. So take a very - // conservative approach. - -// if ( encoding == TIXML_ENCODING_UTF8 ) -// { - if ( anyByte < 127 ) - return isalnum( anyByte ); - else - return 1; // What else to do? The unicode set is huge...get the english ones right. -// } -// else -// { -// return isalnum( anyByte ); -// } + // This will only work for low-ascii, everything else is assumed to be a valid + // letter. I'm not sure this is the best approach, but it is quite tricky trying + // to figure out alhabetical vs. not across encoding. So take a very + // conservative approach. + + // if ( encoding == TIXML_ENCODING_UTF8 ) + // { + if ( anyByte < 127 ) + return isalnum( anyByte ); + else + return 1; // What else to do? The unicode set is huge...get the english ones right. + // } + // else + // { + // return isalnum( anyByte ); + // } } class TiXmlParsingData { - friend class TiXmlDocument; - public: - void Stamp( const char* now, TiXmlEncoding encoding ); - - const TiXmlCursor& Cursor() { return cursor; } - - private: - // Only used by the document! - TiXmlParsingData( const char* start, int _tabsize, int row, int col ) - { - assert( start ); - stamp = start; - tabsize = _tabsize; - cursor.row = row; - cursor.col = col; - } - - TiXmlCursor cursor; - const char* stamp; - int tabsize; + friend class TiXmlDocument; + public: + void Stamp( const char* now, TiXmlEncoding encoding ); + + const TiXmlCursor& Cursor() { return cursor; } + + private: + // Only used by the document! + TiXmlParsingData( const char* start, int _tabsize, int row, int col ) + { + assert( start ); + stamp = start; + tabsize = _tabsize; + cursor.row = row; + cursor.col = col; + } + + TiXmlCursor cursor; + const char* stamp; + int tabsize; }; void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding ) { - assert( now ); - - // Do nothing if the tabsize is 0. - if ( tabsize < 1 ) - { - return; - } - - // Get the current row, column. - int row = cursor.row; - int col = cursor.col; - const char* p = stamp; - assert( p ); - - while ( p < now ) - { - // Treat p as unsigned, so we have a happy compiler. - const unsigned char* pU = (const unsigned char*)p; - - // Code contributed by Fletcher Dunn: (modified by lee) - switch (*pU) { - case 0: - // We *should* never get here, but in case we do, don't - // advance past the terminating null character, ever - return; - - case '\r': - // bump down to the next line - ++row; - col = 0; - // Eat the character - ++p; - - // Check for \r\n sequence, and treat this as a single character - if (*p == '\n') { - ++p; - } - break; - - case '\n': - // bump down to the next line - ++row; - col = 0; - - // Eat the character - ++p; - - // Check for \n\r sequence, and treat this as a single - // character. (Yes, this bizarre thing does occur still - // on some arcane platforms...) - if (*p == '\r') { - ++p; - } - break; - - case '\t': - // Eat the character - ++p; - - // Skip to next tab stop - col = (col / tabsize + 1) * tabsize; - break; - - case TIXML_UTF_LEAD_0: - if ( encoding == TIXML_ENCODING_UTF8 ) - { - if ( *(p+1) && *(p+2) ) - { - // In these cases, don't advance the column. These are - // 0-width spaces. - if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) - p += 3; - else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU ) - p += 3; - else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) - p += 3; - else - { p +=3; ++col; } // A normal character. - } - } - else - { - ++p; - ++col; - } - break; - - default: - if ( encoding == TIXML_ENCODING_UTF8 ) - { - // Eat the 1 to 4 byte utf8 character. - int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)]; - if ( step == 0 ) - step = 1; // Error case from bad encoding, but handle gracefully. - p += step; - - // Just advance one column, of course. - ++col; - } - else - { - ++p; - ++col; - } - break; - } - } - cursor.row = row; - cursor.col = col; - assert( cursor.row >= -1 ); - assert( cursor.col >= -1 ); - stamp = p; - assert( stamp ); + assert( now ); + + // Do nothing if the tabsize is 0. + if ( tabsize < 1 ) + { + return; + } + + // Get the current row, column. + int row = cursor.row; + int col = cursor.col; + const char* p = stamp; + assert( p ); + + while ( p < now ) + { + // Treat p as unsigned, so we have a happy compiler. + const unsigned char* pU = (const unsigned char*)p; + + // Code contributed by Fletcher Dunn: (modified by lee) + switch (*pU) { + case 0: + // We *should* never get here, but in case we do, don't + // advance past the terminating null character, ever + return; + + case '\r': + // bump down to the next line + ++row; + col = 0; + // Eat the character + ++p; + + // Check for \r\n sequence, and treat this as a single character + if (*p == '\n') { + ++p; + } + break; + + case '\n': + // bump down to the next line + ++row; + col = 0; + + // Eat the character + ++p; + + // Check for \n\r sequence, and treat this as a single + // character. (Yes, this bizarre thing does occur still + // on some arcane platforms...) + if (*p == '\r') { + ++p; + } + break; + + case '\t': + // Eat the character + ++p; + + // Skip to next tab stop + col = (col / tabsize + 1) * tabsize; + break; + + case TIXML_UTF_LEAD_0: + if ( encoding == TIXML_ENCODING_UTF8 ) + { + if ( *(p+1) && *(p+2) ) + { + // In these cases, don't advance the column. These are + // 0-width spaces. + if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) + p += 3; + else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU ) + p += 3; + else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) + p += 3; + else + { p +=3; ++col; } // A normal character. + } + } + else + { + ++p; + ++col; + } + break; + + default: + if ( encoding == TIXML_ENCODING_UTF8 ) + { + // Eat the 1 to 4 byte utf8 character. + int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)]; + if ( step == 0 ) + step = 1; // Error case from bad encoding, but handle gracefully. + p += step; + + // Just advance one column, of course. + ++col; + } + else + { + ++p; + ++col; + } + break; + } + } + cursor.row = row; + cursor.col = col; + assert( cursor.row >= -1 ); + assert( cursor.col >= -1 ); + stamp = p; + assert( stamp ); } const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding ) { - if ( !p || !*p ) - { - return 0; - } - if ( encoding == TIXML_ENCODING_UTF8 ) - { - while ( *p ) - { - const unsigned char* pU = (const unsigned char*)p; - - // Skip the stupid Microsoft UTF-8 Byte order marks - if ( *(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==TIXML_UTF_LEAD_1 - && *(pU+2)==TIXML_UTF_LEAD_2 ) - { - p += 3; - continue; - } - else if(*(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==0xbfU - && *(pU+2)==0xbeU ) - { - p += 3; - continue; - } - else if(*(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==0xbfU - && *(pU+2)==0xbfU ) - { - p += 3; - continue; - } - - if ( IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) // Still using old rules for white space. - ++p; - else - break; - } - } - else - { - while ( ( *p && IsWhiteSpace( *p ) ) || *p == '\n' || *p =='\r' ) - ++p; - } - - return p; + if ( !p || !*p ) + { + return 0; + } + if ( encoding == TIXML_ENCODING_UTF8 ) + { + while ( *p ) + { + const unsigned char* pU = (const unsigned char*)p; + + // Skip the stupid Microsoft UTF-8 Byte order marks + if ( *(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==TIXML_UTF_LEAD_1 + && *(pU+2)==TIXML_UTF_LEAD_2 ) + { + p += 3; + continue; + } + else if(*(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==0xbfU + && *(pU+2)==0xbeU ) + { + p += 3; + continue; + } + else if(*(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==0xbfU + && *(pU+2)==0xbfU ) + { + p += 3; + continue; + } + + if ( IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) // Still using old rules for white space. + ++p; + else + break; + } + } + else + { + while ( ( *p && IsWhiteSpace( *p ) ) || *p == '\n' || *p =='\r' ) + ++p; + } + + return p; } #ifdef TIXML_USE_STL /*static*/ bool TiXmlBase::StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ) { - for( ;; ) - { - if ( !in->good() ) return false; + for( ;; ) + { + if ( !in->good() ) return false; - int c = in->peek(); - // At this scope, we can't get to a document. So fail silently. - if ( !IsWhiteSpace( c ) || c <= 0 ) - return true; + int c = in->peek(); + // At this scope, we can't get to a document. So fail silently. + if ( !IsWhiteSpace( c ) || c <= 0 ) + return true; - *tag += (char) in->get(); - } + *tag += (char) in->get(); + } } /*static*/ bool TiXmlBase::StreamTo( std::istream * in, int character, TIXML_STRING * tag ) { - //assert( character > 0 && character < 128 ); // else it won't work in utf-8 - while ( in->good() ) - { - int c = in->peek(); - if ( c == character ) - return true; - if ( c <= 0 ) // Silent failure: can't get document at this scope - return false; - - in->get(); - *tag += (char) c; - } - return false; + //assert( character > 0 && character < 128 ); // else it won't work in utf-8 + while ( in->good() ) + { + int c = in->peek(); + if ( c == character ) + return true; + if ( c <= 0 ) // Silent failure: can't get document at this scope + return false; + + in->get(); + *tag += (char) c; + } + return false; } #endif @@ -408,1207 +408,1207 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding ) // const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding ) { - // Oddly, not supported on some comilers, - //name->clear(); - // So use this: - *name = ""; - assert( p ); - - // Names start with letters or underscores. - // Of course, in unicode, tinyxml has no idea what a letter *is*. The - // algorithm is generous. - // - // After that, they can be letters, underscores, numbers, - // hyphens, or colons. (Colons are valid ony for namespaces, - // but tinyxml can't tell namespaces from names.) - if ( p && *p - && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) - { - const char* start = p; - while( p && *p - && ( IsAlphaNum( (unsigned char ) *p, encoding ) - || *p == '_' - || *p == '-' - || *p == '.' - || *p == ':' ) ) - { - //(*name) += *p; // expensive - ++p; - } - if ( p-start > 0 ) { - name->assign( start, p-start ); - } - return p; - } - return 0; + // Oddly, not supported on some comilers, + //name->clear(); + // So use this: + *name = ""; + assert( p ); + + // Names start with letters or underscores. + // Of course, in unicode, tinyxml has no idea what a letter *is*. The + // algorithm is generous. + // + // After that, they can be letters, underscores, numbers, + // hyphens, or colons. (Colons are valid ony for namespaces, + // but tinyxml can't tell namespaces from names.) + if ( p && *p + && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) + { + const char* start = p; + while( p && *p + && ( IsAlphaNum( (unsigned char ) *p, encoding ) + || *p == '_' + || *p == '-' + || *p == '.' + || *p == ':' ) ) + { + //(*name) += *p; // expensive + ++p; + } + if ( p-start > 0 ) { + name->assign( start, p-start ); + } + return p; + } + return 0; } const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding ) { - // Presume an entity, and pull it out. - TIXML_STRING ent; - int i; - *length = 0; - - if ( *(p+1) && *(p+1) == '#' && *(p+2) ) - { - unsigned long ucs = 0; - ptrdiff_t delta = 0; - unsigned mult = 1; - - if ( *(p+2) == 'x' ) - { - // Hexadecimal. - if ( !*(p+3) ) return 0; - - const char* q = p+3; - q = strchr( q, ';' ); - - if ( !q || !*q ) return 0; - - delta = q-p; - --q; - - while ( *q != 'x' ) - { - if ( *q >= '0' && *q <= '9' ) - ucs += mult * (*q - '0'); - else if ( *q >= 'a' && *q <= 'f' ) - ucs += mult * (*q - 'a' + 10); - else if ( *q >= 'A' && *q <= 'F' ) - ucs += mult * (*q - 'A' + 10 ); - else - return 0; - mult *= 16; - --q; - } - } - else - { - // Decimal. - if ( !*(p+2) ) return 0; - - const char* q = p+2; - q = strchr( q, ';' ); - - if ( !q || !*q ) return 0; - - delta = q-p; - --q; - - while ( *q != '#' ) - { - if ( *q >= '0' && *q <= '9' ) - ucs += mult * (*q - '0'); - else - return 0; - mult *= 10; - --q; - } - } - if ( encoding == TIXML_ENCODING_UTF8 ) - { - // convert the UCS to UTF-8 - ConvertUTF32ToUTF8( ucs, value, length ); - } - else - { - *value = (char)ucs; - *length = 1; - } - return p + delta + 1; - } - - // Now try to match it. - for( i=0; i<NUM_ENTITY; ++i ) - { - if ( strncmp( entity[i].str, p, entity[i].strLength ) == 0 ) - { - assert( strlen( entity[i].str ) == entity[i].strLength ); - *value = entity[i].chr; - *length = 1; - return ( p + entity[i].strLength ); - } - } - - // So it wasn't an entity, its unrecognized, or something like that. - *value = *p; // Don't put back the last one, since we return it! - //*length = 1; // Leave unrecognized entities - this doesn't really work. - // Just writes strange XML. - return p+1; + // Presume an entity, and pull it out. + TIXML_STRING ent; + int i; + *length = 0; + + if ( *(p+1) && *(p+1) == '#' && *(p+2) ) + { + unsigned long ucs = 0; + ptrdiff_t delta = 0; + unsigned mult = 1; + + if ( *(p+2) == 'x' ) + { + // Hexadecimal. + if ( !*(p+3) ) return 0; + + const char* q = p+3; + q = strchr( q, ';' ); + + if ( !q || !*q ) return 0; + + delta = q-p; + --q; + + while ( *q != 'x' ) + { + if ( *q >= '0' && *q <= '9' ) + ucs += mult * (*q - '0'); + else if ( *q >= 'a' && *q <= 'f' ) + ucs += mult * (*q - 'a' + 10); + else if ( *q >= 'A' && *q <= 'F' ) + ucs += mult * (*q - 'A' + 10 ); + else + return 0; + mult *= 16; + --q; + } + } + else + { + // Decimal. + if ( !*(p+2) ) return 0; + + const char* q = p+2; + q = strchr( q, ';' ); + + if ( !q || !*q ) return 0; + + delta = q-p; + --q; + + while ( *q != '#' ) + { + if ( *q >= '0' && *q <= '9' ) + ucs += mult * (*q - '0'); + else + return 0; + mult *= 10; + --q; + } + } + if ( encoding == TIXML_ENCODING_UTF8 ) + { + // convert the UCS to UTF-8 + ConvertUTF32ToUTF8( ucs, value, length ); + } + else + { + *value = (char)ucs; + *length = 1; + } + return p + delta + 1; + } + + // Now try to match it. + for( i=0; i<NUM_ENTITY; ++i ) + { + if ( strncmp( entity[i].str, p, entity[i].strLength ) == 0 ) + { + assert( strlen( entity[i].str ) == entity[i].strLength ); + *value = entity[i].chr; + *length = 1; + return ( p + entity[i].strLength ); + } + } + + // So it wasn't an entity, its unrecognized, or something like that. + *value = *p; // Don't put back the last one, since we return it! + //*length = 1; // Leave unrecognized entities - this doesn't really work. + // Just writes strange XML. + return p+1; } bool TiXmlBase::StringEqual( const char* p, - const char* tag, - bool ignoreCase, - TiXmlEncoding encoding ) + const char* tag, + bool ignoreCase, + TiXmlEncoding encoding ) { - assert( p ); - assert( tag ); - if ( !p || !*p ) - { - assert( 0 ); - return false; - } - - const char* q = p; - - if ( ignoreCase ) - { - while ( *q && *tag && ToLower( *q, encoding ) == ToLower( *tag, encoding ) ) - { - ++q; - ++tag; - } - - if ( *tag == 0 ) - return true; - } - else - { - while ( *q && *tag && *q == *tag ) - { - ++q; - ++tag; - } - - if ( *tag == 0 ) // Have we found the end of the tag, and everything equal? - return true; - } - return false; + assert( p ); + assert( tag ); + if ( !p || !*p ) + { + assert( 0 ); + return false; + } + + const char* q = p; + + if ( ignoreCase ) + { + while ( *q && *tag && ToLower( *q, encoding ) == ToLower( *tag, encoding ) ) + { + ++q; + ++tag; + } + + if ( *tag == 0 ) + return true; + } + else + { + while ( *q && *tag && *q == *tag ) + { + ++q; + ++tag; + } + + if ( *tag == 0 ) // Have we found the end of the tag, and everything equal? + return true; + } + return false; } -const char* TiXmlBase::ReadText( const char* p, - TIXML_STRING * text, - bool trimWhiteSpace, - const char* endTag, - bool caseInsensitive, - TiXmlEncoding encoding ) +const char* TiXmlBase::ReadText( const char* p, + TIXML_STRING * text, + bool trimWhiteSpace, + const char* endTag, + bool caseInsensitive, + TiXmlEncoding encoding ) { - *text = ""; - if ( !trimWhiteSpace // certain tags always keep whitespace - || !condenseWhiteSpace ) // if true, whitespace is always kept - { - // Keep all the white space. - while ( p && *p - && !StringEqual( p, endTag, caseInsensitive, encoding ) - ) - { - int len; - char cArr[4] = { 0, 0, 0, 0 }; - p = GetChar( p, cArr, &len, encoding ); - text->append( cArr, len ); - } - } - else - { - bool whitespace = false; - - // Remove leading white space: - p = SkipWhiteSpace( p, encoding ); - while ( p && *p - && !StringEqual( p, endTag, caseInsensitive, encoding ) ) - { - if ( *p == '\r' || *p == '\n' ) - { - whitespace = true; - ++p; - } - else if ( IsWhiteSpace( *p ) ) - { - whitespace = true; - ++p; - } - else - { - // If we've found whitespace, add it before the - // new character. Any whitespace just becomes a space. - if ( whitespace ) - { - (*text) += ' '; - whitespace = false; - } - int len; - char cArr[4] = { 0, 0, 0, 0 }; - p = GetChar( p, cArr, &len, encoding ); - if ( len == 1 ) - (*text) += cArr[0]; // more efficient - else - text->append( cArr, len ); - } - } - } - if ( p ) - p += strlen( endTag ); - return p; + *text = ""; + if ( !trimWhiteSpace // certain tags always keep whitespace + || !condenseWhiteSpace ) // if true, whitespace is always kept + { + // Keep all the white space. + while ( p && *p + && !StringEqual( p, endTag, caseInsensitive, encoding ) + ) + { + int len; + char cArr[4] = { 0, 0, 0, 0 }; + p = GetChar( p, cArr, &len, encoding ); + text->append( cArr, len ); + } + } + else + { + bool whitespace = false; + + // Remove leading white space: + p = SkipWhiteSpace( p, encoding ); + while ( p && *p + && !StringEqual( p, endTag, caseInsensitive, encoding ) ) + { + if ( *p == '\r' || *p == '\n' ) + { + whitespace = true; + ++p; + } + else if ( IsWhiteSpace( *p ) ) + { + whitespace = true; + ++p; + } + else + { + // If we've found whitespace, add it before the + // new character. Any whitespace just becomes a space. + if ( whitespace ) + { + (*text) += ' '; + whitespace = false; + } + int len; + char cArr[4] = { 0, 0, 0, 0 }; + p = GetChar( p, cArr, &len, encoding ); + if ( len == 1 ) + (*text) += cArr[0]; // more efficient + else + text->append( cArr, len ); + } + } + } + if ( p ) + p += strlen( endTag ); + return p; } #ifdef TIXML_USE_STL void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) { - // The basic issue with a document is that we don't know what we're - // streaming. Read something presumed to be a tag (and hope), then - // identify it, and call the appropriate stream method on the tag. - // - // This "pre-streaming" will never read the closing ">" so the - // sub-tag can orient itself. - - if ( !StreamTo( in, '<', tag ) ) - { - SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - - while ( in->good() ) - { - int tagIndex = (int) tag->length(); - while ( in->good() && in->peek() != '>' ) - { - int c = in->get(); - if ( c <= 0 ) - { - SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - break; - } - (*tag) += (char) c; - } - - if ( in->good() ) - { - // We now have something we presume to be a node of - // some sort. Identify it, and call the node to - // continue streaming. - TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING ); - - if ( node ) - { - node->StreamIn( in, tag ); - bool isElement = node->ToElement() != 0; - delete node; - node = 0; - - // If this is the root element, we're done. Parsing will be - // done by the >> operator. - if ( isElement ) - { - return; - } - } - else - { - SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - } - } - // We should have returned sooner. - SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); + // The basic issue with a document is that we don't know what we're + // streaming. Read something presumed to be a tag (and hope), then + // identify it, and call the appropriate stream method on the tag. + // + // This "pre-streaming" will never read the closing ">" so the + // sub-tag can orient itself. + + if ( !StreamTo( in, '<', tag ) ) + { + SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + + while ( in->good() ) + { + int tagIndex = (int) tag->length(); + while ( in->good() && in->peek() != '>' ) + { + int c = in->get(); + if ( c <= 0 ) + { + SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + break; + } + (*tag) += (char) c; + } + + if ( in->good() ) + { + // We now have something we presume to be a node of + // some sort. Identify it, and call the node to + // continue streaming. + TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING ); + + if ( node ) + { + node->StreamIn( in, tag ); + bool isElement = node->ToElement() != 0; + delete node; + node = 0; + + // If this is the root element, we're done. Parsing will be + // done by the >> operator. + if ( isElement ) + { + return; + } + } + else + { + SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + } + } + // We should have returned sooner. + SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); } #endif const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding ) { - ClearError(); - - // Parse away, at the document level. Since a document - // contains nothing but other tags, most of what happens - // here is skipping white space. - if ( !p || !*p ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - // Note that, for a document, this needs to come - // before the while space skip, so that parsing - // starts from the pointer we are given. - location.Clear(); - if ( prevData ) - { - location.row = prevData->cursor.row; - location.col = prevData->cursor.col; - } - else - { - location.row = 0; - location.col = 0; - } - TiXmlParsingData data( p, TabSize(), location.row, location.col ); - location = data.Cursor(); - - if ( encoding == TIXML_ENCODING_UNKNOWN ) - { - // Check for the Microsoft UTF-8 lead bytes. - const unsigned char* pU = (const unsigned char*)p; - if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0 - && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1 - && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 ) - { - encoding = TIXML_ENCODING_UTF8; - useMicrosoftBOM = true; - } - } - - p = SkipWhiteSpace( p, encoding ); - if ( !p ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - while ( p && *p ) - { - TiXmlNode* node = Identify( p, encoding ); - if ( node ) - { - p = node->Parse( p, &data, encoding ); - LinkEndChild( node ); - } - else - { - break; - } - - // Did we get encoding info? - if ( encoding == TIXML_ENCODING_UNKNOWN - && node->ToDeclaration() ) - { - TiXmlDeclaration* dec = node->ToDeclaration(); - const char* enc = dec->Encoding(); - assert( enc ); - - if ( *enc == 0 ) - encoding = TIXML_ENCODING_UTF8; - else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) ) - encoding = TIXML_ENCODING_UTF8; - else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) ) - encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice - else - encoding = TIXML_ENCODING_LEGACY; - } - - p = SkipWhiteSpace( p, encoding ); - } - - // Was this empty? - if ( !firstChild ) { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding ); - return 0; - } - - // All is well. - return p; + ClearError(); + + // Parse away, at the document level. Since a document + // contains nothing but other tags, most of what happens + // here is skipping white space. + if ( !p || !*p ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + // Note that, for a document, this needs to come + // before the while space skip, so that parsing + // starts from the pointer we are given. + location.Clear(); + if ( prevData ) + { + location.row = prevData->cursor.row; + location.col = prevData->cursor.col; + } + else + { + location.row = 0; + location.col = 0; + } + TiXmlParsingData data( p, TabSize(), location.row, location.col ); + location = data.Cursor(); + + if ( encoding == TIXML_ENCODING_UNKNOWN ) + { + // Check for the Microsoft UTF-8 lead bytes. + const unsigned char* pU = (const unsigned char*)p; + if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0 + && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1 + && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 ) + { + encoding = TIXML_ENCODING_UTF8; + useMicrosoftBOM = true; + } + } + + p = SkipWhiteSpace( p, encoding ); + if ( !p ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + while ( p && *p ) + { + TiXmlNode* node = Identify( p, encoding ); + if ( node ) + { + p = node->Parse( p, &data, encoding ); + LinkEndChild( node ); + } + else + { + break; + } + + // Did we get encoding info? + if ( encoding == TIXML_ENCODING_UNKNOWN + && node->ToDeclaration() ) + { + TiXmlDeclaration* dec = node->ToDeclaration(); + const char* enc = dec->Encoding(); + assert( enc ); + + if ( *enc == 0 ) + encoding = TIXML_ENCODING_UTF8; + else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) ) + encoding = TIXML_ENCODING_UTF8; + else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) ) + encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice + else + encoding = TIXML_ENCODING_LEGACY; + } + + p = SkipWhiteSpace( p, encoding ); + } + + // Was this empty? + if ( !firstChild ) { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding ); + return 0; + } + + // All is well. + return p; } void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding ) -{ - // The first error in a chain is more accurate - don't set again! - if ( error ) - return; - - assert( err > 0 && err < TIXML_ERROR_STRING_COUNT ); - error = true; - errorId = err; - errorDesc = errorString[ errorId ]; - - errorLocation.Clear(); - if ( pError && data ) - { - data->Stamp( pError, encoding ); - errorLocation = data->Cursor(); - } +{ + // The first error in a chain is more accurate - don't set again! + if ( error ) + return; + + assert( err > 0 && err < TIXML_ERROR_STRING_COUNT ); + error = true; + errorId = err; + errorDesc = errorString[ errorId ]; + + errorLocation.Clear(); + if ( pError && data ) + { + data->Stamp( pError, encoding ); + errorLocation = data->Cursor(); + } } TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding ) { - TiXmlNode* returnNode = 0; - - p = SkipWhiteSpace( p, encoding ); - if( !p || !*p || *p != '<' ) - { - return 0; - } - - TiXmlDocument* doc = GetDocument(); - p = SkipWhiteSpace( p, encoding ); - - if ( !p || !*p ) - { - return 0; - } - - // What is this thing? - // - Elements start with a letter or underscore, but xml is reserved. - // - Comments: <!-- - // - Decleration: <?xml - // - Everthing else is unknown to tinyxml. - // - - const char* xmlHeader = { "<?xml" }; - const char* commentHeader = { "<!--" }; - const char* dtdHeader = { "<!" }; - const char* cdataHeader = { "<![CDATA[" }; - - if ( StringEqual( p, xmlHeader, true, encoding ) ) - { - #ifdef DEBUG_PARSER - TIXML_LOG( "XML parsing Declaration\n" ); - #endif - returnNode = new TiXmlDeclaration(); - } - else if ( StringEqual( p, commentHeader, false, encoding ) ) - { - #ifdef DEBUG_PARSER - TIXML_LOG( "XML parsing Comment\n" ); - #endif - returnNode = new TiXmlComment(); - } - else if ( StringEqual( p, cdataHeader, false, encoding ) ) - { - #ifdef DEBUG_PARSER - TIXML_LOG( "XML parsing CDATA\n" ); - #endif - TiXmlText* text = new TiXmlText( "" ); - text->SetCDATA( true ); - returnNode = text; - } - else if ( StringEqual( p, dtdHeader, false, encoding ) ) - { - #ifdef DEBUG_PARSER - TIXML_LOG( "XML parsing Unknown(1)\n" ); - #endif - returnNode = new TiXmlUnknown(); - } - else if ( IsAlpha( *(p+1), encoding ) - || *(p+1) == '_' ) - { - #ifdef DEBUG_PARSER - TIXML_LOG( "XML parsing Element\n" ); - #endif - returnNode = new TiXmlElement( "" ); - } - else - { - #ifdef DEBUG_PARSER - TIXML_LOG( "XML parsing Unknown(2)\n" ); - #endif - returnNode = new TiXmlUnknown(); - } - - if ( returnNode ) - { - // Set the parent, so it can report errors - returnNode->parent = this; - } - else - { - if ( doc ) - doc->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); - } - return returnNode; + TiXmlNode* returnNode = 0; + + p = SkipWhiteSpace( p, encoding ); + if( !p || !*p || *p != '<' ) + { + return 0; + } + + TiXmlDocument* doc = GetDocument(); + p = SkipWhiteSpace( p, encoding ); + + if ( !p || !*p ) + { + return 0; + } + + // What is this thing? + // - Elements start with a letter or underscore, but xml is reserved. + // - Comments: <!-- + // - Decleration: <?xml + // - Everthing else is unknown to tinyxml. + // + + const char* xmlHeader = { "<?xml" }; + const char* commentHeader = { "<!--" }; + const char* dtdHeader = { "<!" }; + const char* cdataHeader = { "<![CDATA[" }; + + if ( StringEqual( p, xmlHeader, true, encoding ) ) + { +#ifdef DEBUG_PARSER + TIXML_LOG( "XML parsing Declaration\n" ); +#endif + returnNode = new TiXmlDeclaration(); + } + else if ( StringEqual( p, commentHeader, false, encoding ) ) + { +#ifdef DEBUG_PARSER + TIXML_LOG( "XML parsing Comment\n" ); +#endif + returnNode = new TiXmlComment(); + } + else if ( StringEqual( p, cdataHeader, false, encoding ) ) + { +#ifdef DEBUG_PARSER + TIXML_LOG( "XML parsing CDATA\n" ); +#endif + TiXmlText* text = new TiXmlText( "" ); + text->SetCDATA( true ); + returnNode = text; + } + else if ( StringEqual( p, dtdHeader, false, encoding ) ) + { +#ifdef DEBUG_PARSER + TIXML_LOG( "XML parsing Unknown(1)\n" ); +#endif + returnNode = new TiXmlUnknown(); + } + else if ( IsAlpha( *(p+1), encoding ) + || *(p+1) == '_' ) + { +#ifdef DEBUG_PARSER + TIXML_LOG( "XML parsing Element\n" ); +#endif + returnNode = new TiXmlElement( "" ); + } + else + { +#ifdef DEBUG_PARSER + TIXML_LOG( "XML parsing Unknown(2)\n" ); +#endif + returnNode = new TiXmlUnknown(); + } + + if ( returnNode ) + { + // Set the parent, so it can report errors + returnNode->parent = this; + } + else + { + if ( doc ) + doc->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); + } + return returnNode; } #ifdef TIXML_USE_STL void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag) { - // We're called with some amount of pre-parsing. That is, some of "this" - // element is in "tag". Go ahead and stream to the closing ">" - while( in->good() ) - { - int c = in->get(); - if ( c <= 0 ) - { - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - (*tag) += (char) c ; - - if ( c == '>' ) - break; - } - - if ( tag->length() < 3 ) return; - - // Okay...if we are a "/>" tag, then we're done. We've read a complete tag. - // If not, identify and stream. - - if ( tag->at( tag->length() - 1 ) == '>' - && tag->at( tag->length() - 2 ) == '/' ) - { - // All good! - return; - } - else if ( tag->at( tag->length() - 1 ) == '>' ) - { - // There is more. Could be: - // text - // cdata text (which looks like another node) - // closing tag - // another node. - for ( ;; ) - { - StreamWhiteSpace( in, tag ); - - // Do we have text? - if ( in->good() && in->peek() != '<' ) - { - // Yep, text. - TiXmlText text( "" ); - text.StreamIn( in, tag ); - - // What follows text is a closing tag or another node. - // Go around again and figure it out. - continue; - } - - // We now have either a closing tag...or another node. - // We should be at a "<", regardless. - if ( !in->good() ) return; - assert( in->peek() == '<' ); - int tagIndex = (int) tag->length(); - - bool closingTag = false; - bool firstCharFound = false; - - for( ;; ) - { - if ( !in->good() ) - return; - - int c = in->peek(); - if ( c <= 0 ) - { - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - - if ( c == '>' ) - break; - - *tag += (char) c; - in->get(); - - // Early out if we find the CDATA id. - if ( c == '[' && tag->size() >= 9 ) - { - size_t len = tag->size(); - const char* start = tag->c_str() + len - 9; - if ( strcmp( start, "<![CDATA[" ) == 0 ) { - assert( !closingTag ); - break; - } - } - - if ( !firstCharFound && c != '<' && !IsWhiteSpace( c ) ) - { - firstCharFound = true; - if ( c == '/' ) - closingTag = true; - } - } - // If it was a closing tag, then read in the closing '>' to clean up the input stream. - // If it was not, the streaming will be done by the tag. - if ( closingTag ) - { - if ( !in->good() ) - return; - - int c = in->get(); - if ( c <= 0 ) - { - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - assert( c == '>' ); - *tag += (char) c; - - // We are done, once we've found our closing tag. - return; - } - else - { - // If not a closing tag, id it, and stream. - const char* tagloc = tag->c_str() + tagIndex; - TiXmlNode* node = Identify( tagloc, TIXML_DEFAULT_ENCODING ); - if ( !node ) - return; - node->StreamIn( in, tag ); - delete node; - node = 0; - - // No return: go around from the beginning: text, closing tag, or node. - } - } - } + // We're called with some amount of pre-parsing. That is, some of "this" + // element is in "tag". Go ahead and stream to the closing ">" + while( in->good() ) + { + int c = in->get(); + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + (*tag) += (char) c ; + + if ( c == '>' ) + break; + } + + if ( tag->length() < 3 ) return; + + // Okay...if we are a "/>" tag, then we're done. We've read a complete tag. + // If not, identify and stream. + + if ( tag->at( tag->length() - 1 ) == '>' + && tag->at( tag->length() - 2 ) == '/' ) + { + // All good! + return; + } + else if ( tag->at( tag->length() - 1 ) == '>' ) + { + // There is more. Could be: + // text + // cdata text (which looks like another node) + // closing tag + // another node. + for ( ;; ) + { + StreamWhiteSpace( in, tag ); + + // Do we have text? + if ( in->good() && in->peek() != '<' ) + { + // Yep, text. + TiXmlText text( "" ); + text.StreamIn( in, tag ); + + // What follows text is a closing tag or another node. + // Go around again and figure it out. + continue; + } + + // We now have either a closing tag...or another node. + // We should be at a "<", regardless. + if ( !in->good() ) return; + assert( in->peek() == '<' ); + int tagIndex = (int) tag->length(); + + bool closingTag = false; + bool firstCharFound = false; + + for( ;; ) + { + if ( !in->good() ) + return; + + int c = in->peek(); + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + + if ( c == '>' ) + break; + + *tag += (char) c; + in->get(); + + // Early out if we find the CDATA id. + if ( c == '[' && tag->size() >= 9 ) + { + size_t len = tag->size(); + const char* start = tag->c_str() + len - 9; + if ( strcmp( start, "<![CDATA[" ) == 0 ) { + assert( !closingTag ); + break; + } + } + + if ( !firstCharFound && c != '<' && !IsWhiteSpace( c ) ) + { + firstCharFound = true; + if ( c == '/' ) + closingTag = true; + } + } + // If it was a closing tag, then read in the closing '>' to clean up the input stream. + // If it was not, the streaming will be done by the tag. + if ( closingTag ) + { + if ( !in->good() ) + return; + + int c = in->get(); + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + assert( c == '>' ); + *tag += (char) c; + + // We are done, once we've found our closing tag. + return; + } + else + { + // If not a closing tag, id it, and stream. + const char* tagloc = tag->c_str() + tagIndex; + TiXmlNode* node = Identify( tagloc, TIXML_DEFAULT_ENCODING ); + if ( !node ) + return; + node->StreamIn( in, tag ); + delete node; + node = 0; + + // No return: go around from the beginning: text, closing tag, or node. + } + } + } } #endif const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) { - p = SkipWhiteSpace( p, encoding ); - TiXmlDocument* document = GetDocument(); - - if ( !p || !*p ) - { - if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, 0, 0, encoding ); - return 0; - } - - if ( data ) - { - data->Stamp( p, encoding ); - location = data->Cursor(); - } - - if ( *p != '<' ) - { - if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, p, data, encoding ); - return 0; - } - - p = SkipWhiteSpace( p+1, encoding ); - - // Read the name. - const char* pErr = p; - - p = ReadName( p, &value, encoding ); - if ( !p || !*p ) - { - if ( document ) document->SetError( TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, pErr, data, encoding ); - return 0; - } - - TIXML_STRING endTag ("</"); - endTag += value; - endTag += ">"; - - // Check for and read attributes. Also look for an empty - // tag or an end tag. - while ( p && *p ) - { - pErr = p; - p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); - return 0; - } - if ( *p == '/' ) - { - ++p; - // Empty tag. - if ( *p != '>' ) - { - if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding ); - return 0; - } - return (p+1); - } - else if ( *p == '>' ) - { - // Done with attributes (if there were any.) - // Read the value -- which can include other - // elements -- read the end tag, and return. - ++p; - p = ReadValue( p, data, encoding ); // Note this is an Element method, and will set the error if one happens. - if ( !p || !*p ) - return 0; - - // We should find the end tag now - if ( StringEqual( p, endTag.c_str(), false, encoding ) ) - { - p += endTag.length(); - return p; - } - else - { - if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding ); - return 0; - } - } - else - { - // Try to read an attribute: - TiXmlAttribute* attrib = new TiXmlAttribute(); - if ( !attrib ) - { - if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, pErr, data, encoding ); - return 0; - } - - attrib->SetDocument( document ); - pErr = p; - p = attrib->Parse( p, data, encoding ); - - if ( !p || !*p ) - { - if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding ); - delete attrib; - return 0; - } - - // Handle the strange case of double attributes: - #ifdef TIXML_USE_STL - TiXmlAttribute* node = attributeSet.Find( attrib->NameTStr() ); - #else - TiXmlAttribute* node = attributeSet.Find( attrib->Name() ); - #endif - if ( node ) - { - node->SetValue( attrib->Value() ); - delete attrib; - return 0; - } - - attributeSet.Add( attrib ); - } - } - return p; + p = SkipWhiteSpace( p, encoding ); + TiXmlDocument* document = GetDocument(); + + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, 0, 0, encoding ); + return 0; + } + + if ( data ) + { + data->Stamp( p, encoding ); + location = data->Cursor(); + } + + if ( *p != '<' ) + { + if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, p, data, encoding ); + return 0; + } + + p = SkipWhiteSpace( p+1, encoding ); + + // Read the name. + const char* pErr = p; + + p = ReadName( p, &value, encoding ); + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, pErr, data, encoding ); + return 0; + } + + TIXML_STRING endTag ("</"); + endTag += value; + endTag += ">"; + + // Check for and read attributes. Also look for an empty + // tag or an end tag. + while ( p && *p ) + { + pErr = p; + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); + return 0; + } + if ( *p == '/' ) + { + ++p; + // Empty tag. + if ( *p != '>' ) + { + if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding ); + return 0; + } + return (p+1); + } + else if ( *p == '>' ) + { + // Done with attributes (if there were any.) + // Read the value -- which can include other + // elements -- read the end tag, and return. + ++p; + p = ReadValue( p, data, encoding ); // Note this is an Element method, and will set the error if one happens. + if ( !p || !*p ) + return 0; + + // We should find the end tag now + if ( StringEqual( p, endTag.c_str(), false, encoding ) ) + { + p += endTag.length(); + return p; + } + else + { + if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding ); + return 0; + } + } + else + { + // Try to read an attribute: + TiXmlAttribute* attrib = new TiXmlAttribute(); + if ( !attrib ) + { + if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, pErr, data, encoding ); + return 0; + } + + attrib->SetDocument( document ); + pErr = p; + p = attrib->Parse( p, data, encoding ); + + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding ); + delete attrib; + return 0; + } + + // Handle the strange case of double attributes: +#ifdef TIXML_USE_STL + TiXmlAttribute* node = attributeSet.Find( attrib->NameTStr() ); +#else + TiXmlAttribute* node = attributeSet.Find( attrib->Name() ); +#endif + if ( node ) + { + node->SetValue( attrib->Value() ); + delete attrib; + return 0; + } + + attributeSet.Add( attrib ); + } + } + return p; } const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) { - TiXmlDocument* document = GetDocument(); - - // Read in text and elements in any order. - const char* pWithWhiteSpace = p; - p = SkipWhiteSpace( p, encoding ); - - while ( p && *p ) - { - if ( *p != '<' ) - { - // Take what we have, make a text element. - TiXmlText* textNode = new TiXmlText( "" ); - - if ( !textNode ) - { - if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, encoding ); - return 0; - } - - if ( TiXmlBase::IsWhiteSpaceCondensed() ) - { - p = textNode->Parse( p, data, encoding ); - } - else - { - // Special case: we want to keep the white space - // so that leading spaces aren't removed. - p = textNode->Parse( pWithWhiteSpace, data, encoding ); - } - - if ( !textNode->Blank() ) - LinkEndChild( textNode ); - else - delete textNode; - } - else - { - // We hit a '<' - // Have we hit a new element or an end tag? This could also be - // a TiXmlText in the "CDATA" style. - if ( StringEqual( p, "</", false, encoding ) ) - { - return p; - } - else - { - TiXmlNode* node = Identify( p, encoding ); - if ( node ) - { - p = node->Parse( p, data, encoding ); - LinkEndChild( node ); - } - else - { - return 0; - } - } - } - pWithWhiteSpace = p; - p = SkipWhiteSpace( p, encoding ); - } - - if ( !p ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding ); - } - return p; + TiXmlDocument* document = GetDocument(); + + // Read in text and elements in any order. + const char* pWithWhiteSpace = p; + p = SkipWhiteSpace( p, encoding ); + + while ( p && *p ) + { + if ( *p != '<' ) + { + // Take what we have, make a text element. + TiXmlText* textNode = new TiXmlText( "" ); + + if ( !textNode ) + { + if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, encoding ); + return 0; + } + + if ( TiXmlBase::IsWhiteSpaceCondensed() ) + { + p = textNode->Parse( p, data, encoding ); + } + else + { + // Special case: we want to keep the white space + // so that leading spaces aren't removed. + p = textNode->Parse( pWithWhiteSpace, data, encoding ); + } + + if ( !textNode->Blank() ) + LinkEndChild( textNode ); + else + delete textNode; + } + else + { + // We hit a '<' + // Have we hit a new element or an end tag? This could also be + // a TiXmlText in the "CDATA" style. + if ( StringEqual( p, "</", false, encoding ) ) + { + return p; + } + else + { + TiXmlNode* node = Identify( p, encoding ); + if ( node ) + { + p = node->Parse( p, data, encoding ); + LinkEndChild( node ); + } + else + { + return 0; + } + } + } + pWithWhiteSpace = p; + p = SkipWhiteSpace( p, encoding ); + } + + if ( !p ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding ); + } + return p; } #ifdef TIXML_USE_STL void TiXmlUnknown::StreamIn( std::istream * in, TIXML_STRING * tag ) { - while ( in->good() ) - { - int c = in->get(); - if ( c <= 0 ) - { - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - (*tag) += (char) c; - - if ( c == '>' ) - { - // All is well. - return; - } - } + while ( in->good() ) + { + int c = in->get(); + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + (*tag) += (char) c; + + if ( c == '>' ) + { + // All is well. + return; + } + } } #endif const char* TiXmlUnknown::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) { - TiXmlDocument* document = GetDocument(); - p = SkipWhiteSpace( p, encoding ); - - if ( data ) - { - data->Stamp( p, encoding ); - location = data->Cursor(); - } - if ( !p || !*p || *p != '<' ) - { - if ( document ) document->SetError( TIXML_ERROR_PARSING_UNKNOWN, p, data, encoding ); - return 0; - } - ++p; - value = ""; - - while ( p && *p && *p != '>' ) - { - value += *p; - ++p; - } - - if ( !p ) - { - if ( document ) document->SetError( TIXML_ERROR_PARSING_UNKNOWN, 0, 0, encoding ); - } - if ( *p == '>' ) - return p+1; - return p; + TiXmlDocument* document = GetDocument(); + p = SkipWhiteSpace( p, encoding ); + + if ( data ) + { + data->Stamp( p, encoding ); + location = data->Cursor(); + } + if ( !p || !*p || *p != '<' ) + { + if ( document ) document->SetError( TIXML_ERROR_PARSING_UNKNOWN, p, data, encoding ); + return 0; + } + ++p; + value = ""; + + while ( p && *p && *p != '>' ) + { + value += *p; + ++p; + } + + if ( !p ) + { + if ( document ) document->SetError( TIXML_ERROR_PARSING_UNKNOWN, 0, 0, encoding ); + } + if ( *p == '>' ) + return p+1; + return p; } #ifdef TIXML_USE_STL void TiXmlComment::StreamIn( std::istream * in, TIXML_STRING * tag ) { - while ( in->good() ) - { - int c = in->get(); - if ( c <= 0 ) - { - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - - (*tag) += (char) c; - - if ( c == '>' - && tag->at( tag->length() - 2 ) == '-' - && tag->at( tag->length() - 3 ) == '-' ) - { - // All is well. - return; - } - } + while ( in->good() ) + { + int c = in->get(); + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + + (*tag) += (char) c; + + if ( c == '>' + && tag->at( tag->length() - 2 ) == '-' + && tag->at( tag->length() - 3 ) == '-' ) + { + // All is well. + return; + } + } } #endif const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) { - TiXmlDocument* document = GetDocument(); - value = ""; - - p = SkipWhiteSpace( p, encoding ); - - if ( data ) - { - data->Stamp( p, encoding ); - location = data->Cursor(); - } - const char* startTag = "<!--"; - const char* endTag = "-->"; - - if ( !StringEqual( p, startTag, false, encoding ) ) - { - document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); - return 0; - } - p += strlen( startTag ); - p = ReadText( p, &value, false, endTag, false, encoding ); - return p; + TiXmlDocument* document = GetDocument(); + value = ""; + + p = SkipWhiteSpace( p, encoding ); + + if ( data ) + { + data->Stamp( p, encoding ); + location = data->Cursor(); + } + const char* startTag = "<!--"; + const char* endTag = "-->"; + + if ( !StringEqual( p, startTag, false, encoding ) ) + { + document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); + return 0; + } + p += strlen( startTag ); + p = ReadText( p, &value, false, endTag, false, encoding ); + return p; } const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) { - p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p ) return 0; - -// int tabsize = 4; -// if ( document ) -// tabsize = document->TabSize(); - - if ( data ) - { - data->Stamp( p, encoding ); - location = data->Cursor(); - } - // Read the name, the '=' and the value. - const char* pErr = p; - p = ReadName( p, &name, encoding ); - if ( !p || !*p ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); - return 0; - } - p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p || *p != '=' ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; - } - - ++p; // skip '=' - p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; - } - - const char* end; - const char SINGLE_QUOTE = '\''; - const char DOUBLE_QUOTE = '\"'; - - if ( *p == SINGLE_QUOTE ) - { - ++p; - end = "\'"; // single quote in string - p = ReadText( p, &value, false, end, false, encoding ); - } - else if ( *p == DOUBLE_QUOTE ) - { - ++p; - end = "\""; // double quote in string - p = ReadText( p, &value, false, end, false, encoding ); - } - else - { - // All attribute values should be in single or double quotes. - // But this is such a common error that the parser will try - // its best, even without them. - value = ""; - while ( p && *p // existence - && !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r' // whitespace - && *p != '/' && *p != '>' ) // tag end - { - if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) { - // [ 1451649 ] Attribute values with trailing quotes not handled correctly - // We did not have an opening quote but seem to have a - // closing one. Give up and throw an error. - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; - } - value += *p; - ++p; - } - } - return p; + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p ) return 0; + + // int tabsize = 4; + // if ( document ) + // tabsize = document->TabSize(); + + if ( data ) + { + data->Stamp( p, encoding ); + location = data->Cursor(); + } + // Read the name, the '=' and the value. + const char* pErr = p; + p = ReadName( p, &name, encoding ); + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); + return 0; + } + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p || *p != '=' ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); + return 0; + } + + ++p; // skip '=' + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); + return 0; + } + + const char* end; + const char SINGLE_QUOTE = '\''; + const char DOUBLE_QUOTE = '\"'; + + if ( *p == SINGLE_QUOTE ) + { + ++p; + end = "\'"; // single quote in string + p = ReadText( p, &value, false, end, false, encoding ); + } + else if ( *p == DOUBLE_QUOTE ) + { + ++p; + end = "\""; // double quote in string + p = ReadText( p, &value, false, end, false, encoding ); + } + else + { + // All attribute values should be in single or double quotes. + // But this is such a common error that the parser will try + // its best, even without them. + value = ""; + while ( p && *p // existence + && !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r' // whitespace + && *p != '/' && *p != '>' ) // tag end + { + if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) { + // [ 1451649 ] Attribute values with trailing quotes not handled correctly + // We did not have an opening quote but seem to have a + // closing one. Give up and throw an error. + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); + return 0; + } + value += *p; + ++p; + } + } + return p; } #ifdef TIXML_USE_STL void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag ) { - while ( in->good() ) - { - int c = in->peek(); - if ( !cdata && (c == '<' ) ) - { - return; - } - if ( c <= 0 ) - { - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - - (*tag) += (char) c; - in->get(); // "commits" the peek made above - - if ( cdata && c == '>' && tag->size() >= 3 ) { - size_t len = tag->size(); - if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) { - // terminator of cdata. - return; - } - } - } + while ( in->good() ) + { + int c = in->peek(); + if ( !cdata && (c == '<' ) ) + { + return; + } + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + + (*tag) += (char) c; + in->get(); // "commits" the peek made above + + if ( cdata && c == '>' && tag->size() >= 3 ) { + size_t len = tag->size(); + if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) { + // terminator of cdata. + return; + } + } + } } #endif const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) { - value = ""; - TiXmlDocument* document = GetDocument(); - - if ( data ) - { - data->Stamp( p, encoding ); - location = data->Cursor(); - } - - const char* const startTag = "<![CDATA["; - const char* const endTag = "]]>"; - - if ( cdata || StringEqual( p, startTag, false, encoding ) ) - { - cdata = true; - - if ( !StringEqual( p, startTag, false, encoding ) ) - { - document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); - return 0; - } - p += strlen( startTag ); - - // Keep all the white space, ignore the encoding, etc. - while ( p && *p - && !StringEqual( p, endTag, false, encoding ) - ) - { - value += *p; - ++p; - } - - TIXML_STRING dummy; - p = ReadText( p, &dummy, false, endTag, false, encoding ); - return p; - } - else - { - bool ignoreWhite = true; - - const char* end = "<"; - p = ReadText( p, &value, ignoreWhite, end, false, encoding ); - if ( p ) - return p-1; // don't truncate the '<' - return 0; - } + value = ""; + TiXmlDocument* document = GetDocument(); + + if ( data ) + { + data->Stamp( p, encoding ); + location = data->Cursor(); + } + + const char* const startTag = "<![CDATA["; + const char* const endTag = "]]>"; + + if ( cdata || StringEqual( p, startTag, false, encoding ) ) + { + cdata = true; + + if ( !StringEqual( p, startTag, false, encoding ) ) + { + document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); + return 0; + } + p += strlen( startTag ); + + // Keep all the white space, ignore the encoding, etc. + while ( p && *p + && !StringEqual( p, endTag, false, encoding ) + ) + { + value += *p; + ++p; + } + + TIXML_STRING dummy; + p = ReadText( p, &dummy, false, endTag, false, encoding ); + return p; + } + else + { + bool ignoreWhite = true; + + const char* end = "<"; + p = ReadText( p, &value, ignoreWhite, end, false, encoding ); + if ( p ) + return p-1; // don't truncate the '<' + return 0; + } } #ifdef TIXML_USE_STL void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag ) { - while ( in->good() ) - { - int c = in->get(); - if ( c <= 0 ) - { - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - (*tag) += (char) c; - - if ( c == '>' ) - { - // All is well. - return; - } - } + while ( in->good() ) + { + int c = in->get(); + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + (*tag) += (char) c; + + if ( c == '>' ) + { + // All is well. + return; + } + } } #endif const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding ) { - p = SkipWhiteSpace( p, _encoding ); - // Find the beginning, find the end, and look for - // the stuff in-between. - TiXmlDocument* document = GetDocument(); - if ( !p || !*p || !StringEqual( p, "<?xml", true, _encoding ) ) - { - if ( document ) document->SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding ); - return 0; - } - if ( data ) - { - data->Stamp( p, _encoding ); - location = data->Cursor(); - } - p += 5; - - version = ""; - encoding = ""; - standalone = ""; - - while ( p && *p ) - { - if ( *p == '>' ) - { - ++p; - return p; - } - - p = SkipWhiteSpace( p, _encoding ); - if ( StringEqual( p, "version", true, _encoding ) ) - { - TiXmlAttribute attrib; - p = attrib.Parse( p, data, _encoding ); - version = attrib.Value(); - } - else if ( StringEqual( p, "encoding", true, _encoding ) ) - { - TiXmlAttribute attrib; - p = attrib.Parse( p, data, _encoding ); - encoding = attrib.Value(); - } - else if ( StringEqual( p, "standalone", true, _encoding ) ) - { - TiXmlAttribute attrib; - p = attrib.Parse( p, data, _encoding ); - standalone = attrib.Value(); - } - else - { - // Read over whatever it is. - while( p && *p && *p != '>' && !IsWhiteSpace( *p ) ) - ++p; - } - } - return 0; + p = SkipWhiteSpace( p, _encoding ); + // Find the beginning, find the end, and look for + // the stuff in-between. + TiXmlDocument* document = GetDocument(); + if ( !p || !*p || !StringEqual( p, "<?xml", true, _encoding ) ) + { + if ( document ) document->SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding ); + return 0; + } + if ( data ) + { + data->Stamp( p, _encoding ); + location = data->Cursor(); + } + p += 5; + + version = ""; + encoding = ""; + standalone = ""; + + while ( p && *p ) + { + if ( *p == '>' ) + { + ++p; + return p; + } + + p = SkipWhiteSpace( p, _encoding ); + if ( StringEqual( p, "version", true, _encoding ) ) + { + TiXmlAttribute attrib; + p = attrib.Parse( p, data, _encoding ); + version = attrib.Value(); + } + else if ( StringEqual( p, "encoding", true, _encoding ) ) + { + TiXmlAttribute attrib; + p = attrib.Parse( p, data, _encoding ); + encoding = attrib.Value(); + } + else if ( StringEqual( p, "standalone", true, _encoding ) ) + { + TiXmlAttribute attrib; + p = attrib.Parse( p, data, _encoding ); + standalone = attrib.Value(); + } + else + { + // Read over whatever it is. + while( p && *p && *p != '>' && !IsWhiteSpace( *p ) ) + ++p; + } + } + return 0; } bool TiXmlText::Blank() const { - for ( unsigned i=0; i<value.length(); i++ ) - if ( !IsWhiteSpace( value[i] ) ) - return false; - return true; + for ( unsigned i=0; i<value.length(); i++ ) + if ( !IsWhiteSpace( value[i] ) ) + return false; + return true; } diff --git a/DDCore/src/parsers/Grammars.h b/DDCore/src/parsers/Grammars.h index 37513082bd99b064d956551a603c01800441436b..b67a7d21351dad70c4211d6545177726305e933d 100644 --- a/DDCore/src/parsers/Grammars.h +++ b/DDCore/src/parsers/Grammars.h @@ -2,8 +2,8 @@ #ifndef DD4HEPKERNEL_GRAMMARS_H #define DD4HEPKERNEL_GRAMMARS_H 1 #ifdef __GNUC__ -#warning \ - The headers Grammars.h and Parsers.icpp are deprecated \ +#warning \ + The headers Grammars.h and Parsers.icpp are deprecated \ and will be removed from the next release of Gaudi. You should migrate your \ code the new pasers based on Boost.Spirit 2. #endif @@ -59,12 +59,12 @@ namespace DD4hep * @author Vanya BELYAEV ibelyaev@physics.syr.edu * @date 2006-05-14 */ - template <typename T> - struct ClosureGrammar : public boost::spirit::closure < ClosureGrammar<T>,T > - { - typedef boost::spirit::closure<ClosureGrammar, T> closure; - typename closure::member1 val; - }; + template <typename T> + struct ClosureGrammar : public boost::spirit::closure < ClosureGrammar<T>,T > + { + typedef boost::spirit::closure<ClosureGrammar, T> closure; + typename closure::member1 val; + }; // ======================================================================== /** @struct AttributesClosureGrammar * @@ -77,13 +77,13 @@ namespace DD4hep * @date 2006-05-14 */ template <typename T1,typename T2> - struct AttributesClosureGrammar + struct AttributesClosureGrammar : public boost::spirit::closure<AttributesClosureGrammar<T1,T2>,T1,T2> - { - typedef boost::spirit::closure<AttributesClosureGrammar, T1,T2> closure; - typename closure::member1 val; - typename closure::member2 attrs; - }; + { + typedef boost::spirit::closure<AttributesClosureGrammar, T1,T2> closure; + typename closure::member1 val; + typename closure::member2 attrs; + }; // ======================================================================== /** @class BoolGrammar * @@ -97,31 +97,31 @@ namespace DD4hep * @date 2006-05-14 */ class BoolGrammar : public grammar - < + < BoolGrammar, ClosureGrammar<bool>::context_t - > - { - public: - typedef bool ResultT; - public: - template <typename ScannerT> - struct definition - { - definition( BoolGrammar const &self) + > { - boolean_literal - = true_literal[self.val = true] | false_literal[self.val = false]; - true_literal - = str_p("true" ) | str_p("True" ) | str_p("TRUE" ) | str_p("1"); - false_literal - = str_p("false") | str_p("False") | str_p("FALSE") | str_p("0"); - } - rule<ScannerT> const& start() const - { return boolean_literal;} - rule<ScannerT> boolean_literal,true_literal,false_literal; - }; - }; + public: + typedef bool ResultT; + public: + template <typename ScannerT> + struct definition + { + definition( BoolGrammar const &self) + { + boolean_literal + = true_literal[self.val = true] | false_literal[self.val = false]; + true_literal + = str_p("true" ) | str_p("True" ) | str_p("TRUE" ) | str_p("1"); + false_literal + = str_p("false") | str_p("False") | str_p("FALSE") | str_p("0"); + } + rule<ScannerT> const& start() const + { return boolean_literal;} + rule<ScannerT> boolean_literal,true_literal,false_literal; + }; + }; // ======================================================================== /** @class CharGrammar * @@ -134,14 +134,14 @@ namespace DD4hep * @date 2006-05-14 */ template<typename RT=char> - class CharGrammar : public grammar - < + class CharGrammar : public grammar + < CharGrammar<RT> , typename ClosureGrammar<RT>::context_t - > - { - public: + > + { + public: typedef RT ResultT; - public: + public: template <typename ScannerT> struct definition { @@ -157,7 +157,7 @@ namespace DD4hep { return char_literal; } rule<ScannerT> char_literal; }; - }; + }; // ======================================================================== /** @class IntGrammar * @@ -171,27 +171,27 @@ namespace DD4hep * @date 2006-05-14 */ template<typename RT=int> - class IntGrammar : public grammar - < + class IntGrammar : public grammar + < IntGrammar<RT>, typename ClosureGrammar<RT>::context_t - > - { - public: + > + { + public: typedef RT ResultT; - public: + public: template <typename ScannerT> struct definition { definition( IntGrammar<RT> const &self) { int_literal = lexeme_d[int_parser<RT>()[self.val=arg1] - >> !(ch_p('u') | ch_p('U') | ch_p('l') | ch_p('L'))]; + >> !(ch_p('u') | ch_p('U') | ch_p('l') | ch_p('L'))]; } rule<ScannerT> const& start() const { return int_literal; } rule<ScannerT> int_literal; }; - }; + }; // ======================================================================== /** @class RealGrammar * @@ -205,14 +205,14 @@ namespace DD4hep * @date 2006-05-14 */ template<typename RT=double> - class RealGrammar : public grammar - < + class RealGrammar : public grammar + < RealGrammar<RT>,typename ClosureGrammar<RT>::context_t - > - { - public: + > + { + public: typedef RT ResultT; - public: + public: template <typename ScannerT> struct definition { @@ -220,14 +220,14 @@ namespace DD4hep { real_literal = lexeme_d[real_parser<RT, - real_parser_policies<RT> >()[self.val = arg1] - >> !(ch_p('f') | ch_p('F') | ch_p('l') | ch_p('L'))]; + real_parser_policies<RT> >()[self.val = arg1] + >> !(ch_p('f') | ch_p('F') | ch_p('l') | ch_p('L'))]; } rule<ScannerT> const& start() const { return real_literal; } rule<ScannerT> real_literal; }; - }; + }; // ======================================================================== /** @class StringGrammar * @@ -244,51 +244,51 @@ namespace DD4hep */ class StringGrammar : public grammar - < + < StringGrammar, ClosureGrammar<std::string>::context_t - > - { - public: - typedef std::string ResultT; - /** remove CR/LF symbols form the parsed strings - * @attention it is a bit dangerous operation - * The operation allows to write "very long" input strings - * for opts-files (it is actual e.g. for DataOnDemandSvc configuration) - * by splitting the strings into few lines - * All new-line symbols (as well as '\n', '\t', CR/LF etc - * are substituted by ordinary blanks. - */ - void matchString() const + > { - for ( std::string::iterator cur=this->val().begin(); - cur!=this->val().end();cur++) - { if(std::isspace(*cur) ) { *cur = ' '; } } - } - public: - template <typename ScannerT> - struct definition + public: + typedef std::string ResultT; + /** remove CR/LF symbols form the parsed strings + * @attention it is a bit dangerous operation + * The operation allows to write "very long" input strings + * for opts-files (it is actual e.g. for DataOnDemandSvc configuration) + * by splitting the strings into few lines + * All new-line symbols (as well as '\n', '\t', CR/LF etc + * are substituted by ordinary blanks. + */ + void matchString() const { - definition( StringGrammar const &self ) + for ( std::string::iterator cur=this->val().begin(); + cur!=this->val().end();cur++) + { if(std::isspace(*cur) ) { *cur = ' '; } } + } + public: + template <typename ScannerT> + struct definition { - string_literal = (lexeme_d - [ - ('"' >> (*( str_p("\\\"") - | - (anychar_p-'"') )) - [self.val = construct_<std::string> - (arg1,arg2)] >> - '"') - | - ('\'' >> (*( str_p("\\'") - | - (anychar_p-'\'') )) - [self.val = construct_<std::string> - (arg1,arg2)]>> - '\'')])[boost::bind(&StringGrammar::matchString,&self)]; - } - rule<ScannerT> const& start() const { return string_literal; } - rule<ScannerT> string_literal; - }; + definition( StringGrammar const &self ) + { + string_literal = (lexeme_d + [ + ('"' >> (*( str_p("\\\"") + | + (anychar_p-'"') )) + [self.val = construct_<std::string> + (arg1,arg2)] >> + '"') + | + ('\'' >> (*( str_p("\\'") + | + (anychar_p-'\'') )) + [self.val = construct_<std::string> + (arg1,arg2)]>> + '\'')])[boost::bind(&StringGrammar::matchString,&self)]; + } + rule<ScannerT> const& start() const { return string_literal; } + rule<ScannerT> string_literal; + }; }; // ======================================================================== /** @class SkipperGrammar @@ -316,30 +316,30 @@ namespace DD4hep bool skipnewline() const{return m_skipnewline;} public: template <typename ScannerT> - struct definition - { - definition( SkipperGrammar const& self) + struct definition { - if ( self.skipnewline() ) - { - skip - = space_p - | comment_p("//") // C++ comment - | comment_p("/*", "*/") // C comment - ; - } - else + definition( SkipperGrammar const& self) { - skip - = (space_p-eol_p) - | comment_p("//") // C++ comment - | comment_p("/*", "*/") // C comment - ; + if ( self.skipnewline() ) + { + skip + = space_p + | comment_p("//") // C++ comment + | comment_p("/*", "*/") // C comment + ; + } + else + { + skip + = (space_p-eol_p) + | comment_p("//") // C++ comment + | comment_p("/*", "*/") // C comment + ; + } } - } - rule<ScannerT> skip; - rule<ScannerT> const& start() const { return skip; } - }; + rule<ScannerT> skip; + rule<ScannerT> const& start() const { return skip; } + }; private: bool m_skipnewline; }; @@ -355,59 +355,59 @@ namespace DD4hep * @date 2006-05-14 */ template <typename KeyGrammarT, typename ValueGrammarT> - class PairGrammar : public grammar - < + class PairGrammar : public grammar + < PairGrammar<KeyGrammarT,ValueGrammarT>, typename ClosureGrammar< std::pair<typename KeyGrammarT::ResultT, - typename ValueGrammarT::ResultT> >::context_t - > - { - public: - typedef typename KeyGrammarT::ResultT KeyT; - typedef typename ValueGrammarT::ResultT ValueT; - typedef std::pair<KeyT,ValueT> ResultT; - public: - /** Constructor - * @param delim Delimiter for pair values - */ - PairGrammar ( const std::string& delim = "," ) - : m_delim(delim) {} - public: - /// callback. Action when we match first value - void matchFirst ( const KeyT& first ) const { this->val().first = first; } - /// callback. Action when we match second value - void matchSecond ( const ValueT& second ) const { this->val().second = second; } - public: - template <typename ScannerT> - struct definition - { - definition( PairGrammar const &self) + typename ValueGrammarT::ResultT> >::context_t + > { - para - = ( - str_p("(") - >> (grkey[boost::bind(&PairGrammar::matchFirst,&self,_1)]) - >> self.delim().c_str() - >> (grvalue[boost::bind(&PairGrammar::matchSecond,&self,_1)]) - >> str_p(")") - ) ; - } - rule<ScannerT> const& start() const { return para; } - rule<ScannerT> para; - KeyGrammarT grkey; - ValueGrammarT grvalue; - }; - public: - /// @return Delimiter for pair values - const std::string& delim() const { return m_delim ; } - /** Set delimiters for pair values - * @param delim Delimiter - */ - void setDelim ( const std::string& delim ) { m_delim = delim;} - private: - std::string m_delim; - }; + public: + typedef typename KeyGrammarT::ResultT KeyT; + typedef typename ValueGrammarT::ResultT ValueT; + typedef std::pair<KeyT,ValueT> ResultT; + public: + /** Constructor + * @param delim Delimiter for pair values + */ + PairGrammar ( const std::string& delim = "," ) + : m_delim(delim) {} + public: + /// callback. Action when we match first value + void matchFirst ( const KeyT& first ) const { this->val().first = first; } + /// callback. Action when we match second value + void matchSecond ( const ValueT& second ) const { this->val().second = second; } + public: + template <typename ScannerT> + struct definition + { + definition( PairGrammar const &self) + { + para + = ( + str_p("(") + >> (grkey[boost::bind(&PairGrammar::matchFirst,&self,_1)]) + >> self.delim().c_str() + >> (grvalue[boost::bind(&PairGrammar::matchSecond,&self,_1)]) + >> str_p(")") + ) ; + } + rule<ScannerT> const& start() const { return para; } + rule<ScannerT> para; + KeyGrammarT grkey; + ValueGrammarT grvalue; + }; + public: + /// @return Delimiter for pair values + const std::string& delim() const { return m_delim ; } + /** Set delimiters for pair values + * @param delim Delimiter + */ + void setDelim ( const std::string& delim ) { m_delim = delim;} + private: + std::string m_delim; + }; // ======================================================================== /** @class VectorGrammar * @@ -421,38 +421,38 @@ namespace DD4hep * @date 2006-05-14 */ template <typename GrammarT> - class VectorGrammar : public grammar - < + class VectorGrammar : public grammar + < VectorGrammar<GrammarT> , typename ClosureGrammar<std::vector<typename GrammarT::ResultT> >::context_t - > - { - public: - typedef typename GrammarT::ResultT ValueT; - typedef std::vector<ValueT> ResultT; - typedef VectorGrammar<GrammarT> SelfT; - public: - /// callback. Action when we match inner value - void matchItem(const ValueT& value) const { this->val().push_back(value); } - public: - template <typename ScannerT> - struct definition + > { - definition(SelfT const &self) - { - inner = - !(gr[boost::bind(&VectorGrammar::matchItem,&self,_1)] - >> *(','>>gr[boost::bind(&VectorGrammar::matchItem,&self,_1)])); - vec = - '[' >> inner >> ']' | // a'la python list - '(' >> inner >> ')' | // a'la python tuple - '{' >> inner >> '}' ; // like obsolete list from opts-grammar - } - rule<ScannerT> const& start() const { return vec; } - rule<ScannerT> vec,inner; - GrammarT gr; + public: + typedef typename GrammarT::ResultT ValueT; + typedef std::vector<ValueT> ResultT; + typedef VectorGrammar<GrammarT> SelfT; + public: + /// callback. Action when we match inner value + void matchItem(const ValueT& value) const { this->val().push_back(value); } + public: + template <typename ScannerT> + struct definition + { + definition(SelfT const &self) + { + inner = + !(gr[boost::bind(&VectorGrammar::matchItem,&self,_1)] + >> *(','>>gr[boost::bind(&VectorGrammar::matchItem,&self,_1)])); + vec = + '[' >> inner >> ']' | // a'la python list + '(' >> inner >> ')' | // a'la python tuple + '{' >> inner >> '}' ; // like obsolete list from opts-grammar + } + rule<ScannerT> const& start() const { return vec; } + rule<ScannerT> vec,inner; + GrammarT gr; + }; }; - }; // ======================================================================== /** @class MapGrammar * @@ -469,57 +469,57 @@ namespace DD4hep * @date 2006-05-14 */ template <typename KeyGrammarT, typename ValueGrammarT> - class MapGrammar : public grammar - < + class MapGrammar : public grammar + < MapGrammar<KeyGrammarT,ValueGrammarT>, typename AttributesClosureGrammar < std::map<typename KeyGrammarT::ResultT, - typename ValueGrammarT::ResultT>, - std::pair<typename KeyGrammarT::ResultT, - typename ValueGrammarT::ResultT> >::context_t - > - { - public: - typedef typename KeyGrammarT::ResultT KeyT; - typedef typename ValueGrammarT::ResultT ValueT; - typedef std::map<KeyT,ValueT> ResultT; - public: - /// call backs. Action when we match pair in map - void matchItem () const - { - //this->val().insert(this->attrs()); - this->val()[this->attrs().first] = this->attrs().second ; - } - /// call backs. Action when we match key of pair - void matchFirst ( const KeyT& value ) const { this->attrs().first = value ; } - /// call backs. Action when we match value pf pair - void matchSecond( const ValueT& value ) const { this->attrs().second = value ; } - public: - template <typename ScannerT> - struct definition - { - definition( MapGrammar const &self) + typename ValueGrammarT::ResultT>, + std::pair<typename KeyGrammarT::ResultT, + typename ValueGrammarT::ResultT> >::context_t + > { - vec - = ('{'>> inner_list >> '}') | ('['>>inner_list>>']'); - inner_list - = - !( inner[boost::bind(&MapGrammar::matchItem,&self)] - >> *( ch_p(',') >> - inner[boost::bind(&MapGrammar::matchItem,&self)] ) - ); - inner - = - grKey[boost ::bind(&MapGrammar::matchFirst,&self,_1)] - >> ( ch_p('=') | ch_p(':')) - >> grValue[boost::bind(&MapGrammar::matchSecond,&self,_1)] ; - } - KeyGrammarT grKey; - ValueGrammarT grValue; - rule<ScannerT> const& start() const { return vec; } - rule<ScannerT> vec,inner, inner_list ; - }; - }; + public: + typedef typename KeyGrammarT::ResultT KeyT; + typedef typename ValueGrammarT::ResultT ValueT; + typedef std::map<KeyT,ValueT> ResultT; + public: + /// call backs. Action when we match pair in map + void matchItem () const + { + //this->val().insert(this->attrs()); + this->val()[this->attrs().first] = this->attrs().second ; + } + /// call backs. Action when we match key of pair + void matchFirst ( const KeyT& value ) const { this->attrs().first = value ; } + /// call backs. Action when we match value pf pair + void matchSecond( const ValueT& value ) const { this->attrs().second = value ; } + public: + template <typename ScannerT> + struct definition + { + definition( MapGrammar const &self) + { + vec + = ('{'>> inner_list >> '}') | ('['>>inner_list>>']'); + inner_list + = + !( inner[boost::bind(&MapGrammar::matchItem,&self)] + >> *( ch_p(',') >> + inner[boost::bind(&MapGrammar::matchItem,&self)] ) + ); + inner + = + grKey[boost ::bind(&MapGrammar::matchFirst,&self,_1)] + >> ( ch_p('=') | ch_p(':')) + >> grValue[boost::bind(&MapGrammar::matchSecond,&self,_1)] ; + } + KeyGrammarT grKey; + ValueGrammarT grValue; + rule<ScannerT> const& start() const { return vec; } + rule<ScannerT> vec,inner, inner_list ; + }; + }; // ======================================================================== } // end of namespace Dd4hep::Parsers } // end of namespace Dd4hep diff --git a/DDCore/src/parsers/GrammarsV2.h b/DDCore/src/parsers/GrammarsV2.h index d9b3f3c48fac3b47797f32f3b18a5ad75afe9142..45b5e9100c22659cd0d76094f020f55cb178e2b9 100644 --- a/DDCore/src/parsers/GrammarsV2.h +++ b/DDCore/src/parsers/GrammarsV2.h @@ -54,53 +54,53 @@ namespace DD4hep { namespace Parsers { //============================================================================== template <typename Iterator, typename T, typename Skipper, class Enable=void> struct Grammar_ { - /* READ THIS IF YOUR COMPILE BREAKS ON THE FOLLOWING LINE - * - * To users: You have to ask developers to implement parser for your type T - * To developer: You have to implement and register Grammar for type T - * - */ - BOOST_MPL_ASSERT_MSG(false, GRAMMAR_FOR_TYPE_DOES_NOT_EXISTS, (T)); + /* READ THIS IF YOUR COMPILE BREAKS ON THE FOLLOWING LINE + * + * To users: You have to ask developers to implement parser for your type T + * To developer: You have to implement and register Grammar for type T + * + */ + BOOST_MPL_ASSERT_MSG(false, GRAMMAR_FOR_TYPE_DOES_NOT_EXISTS, (T)); }; -#define REGISTER_GRAMMAR(ResultType, GrammarName) \ - template <typename Iterator, typename Skipper> \ - struct Grammar_<Iterator, ResultType, Skipper> \ - { \ - typedef GrammarName<Iterator, Skipper> Grammar; \ +#define REGISTER_GRAMMAR(ResultType, GrammarName) \ + template <typename Iterator, typename Skipper> \ + struct Grammar_<Iterator, ResultType, Skipper> \ + { \ + typedef GrammarName<Iterator, Skipper> Grammar; \ } //============================================================================== template< typename Iterator> struct SkipperGrammar : qi::grammar<Iterator> { SkipperGrammar() : SkipperGrammar::base_type(comments) { - comments = enc::space | rep::confix("/*", "*/")[*(qi::char_ - "*/")] - | - rep::confix("//", (sp::eol | sp::eoi))[*(qi::char_ - (sp::eol|sp::eoi))]; - } - qi::rule<Iterator> comments; + comments = enc::space | rep::confix("/*", "*/")[*(qi::char_ - "*/")] + | + rep::confix("//", (sp::eol | sp::eoi))[*(qi::char_ - (sp::eol|sp::eoi))]; + } + qi::rule<Iterator> comments; }; //============================================================================== template< typename Iterator, typename Skipper> struct StringGrammar : qi::grammar<Iterator, std::string(), qi::locals<char>,Skipper> { - //------------------------------------------------------------------------------ - typedef std::string ResultT; - //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ + typedef std::string ResultT; + //------------------------------------------------------------------------------ StringGrammar() : StringGrammar::base_type( str ) { - begin_quote = enc::char_("\"'"); - quote = enc::char_(qi::_r1); + begin_quote = enc::char_("\"'"); + quote = enc::char_(qi::_r1); - str = qi::lexeme[begin_quote[qi::_a = qi::_1] - > *( (enc::char_('\\') >> quote(qi::_a))[qi::_val += qi::_a] - | (enc::char_[qi::_val += qi::_1] - quote(qi::_a))) > - quote(qi::_a)] - ; - } - //------------------------------------------------------------------------------ - qi::rule<Iterator, std::string(), qi::locals<char>, Skipper> str; - qi::rule<Iterator, char()> begin_quote; - qi::rule<Iterator, void(char)> quote; - //------------------------------------------------------------------------------ + str = qi::lexeme[begin_quote[qi::_a = qi::_1] + > *( (enc::char_('\\') >> quote(qi::_a))[qi::_val += qi::_a] + | (enc::char_[qi::_val += qi::_1] - quote(qi::_a))) > + quote(qi::_a)] + ; + } + //------------------------------------------------------------------------------ + qi::rule<Iterator, std::string(), qi::locals<char>, Skipper> str; + qi::rule<Iterator, char()> begin_quote; + qi::rule<Iterator, void(char)> quote; + //------------------------------------------------------------------------------ }; REGISTER_GRAMMAR(std::string, StringGrammar); //============================================================================== @@ -108,9 +108,9 @@ namespace DD4hep { namespace Parsers { struct CharGrammar : qi::grammar<Iterator, char(), Skipper> { typedef char ResultT; CharGrammar() : CharGrammar::base_type( ch ) { - ch = qi::int_parser<char>() - | - '\'' >> (qi::char_-'\'') >> '\''; + ch = qi::int_parser<char>() + | + '\'' >> (qi::char_-'\'') >> '\''; } qi::rule<Iterator, char(), Skipper> ch; }; @@ -119,76 +119,76 @@ namespace DD4hep { namespace Parsers { template< typename Iterator, typename Skipper> struct BoolGrammar : qi::grammar<Iterator, bool(), Skipper> { - typedef bool ResultT; + typedef bool ResultT; BoolGrammar() : BoolGrammar::base_type( boolean_literal ) { - boolean_literal = + boolean_literal = (qi::lit("true") | "True" | "TRUE" | "1")[qi::_val=true] | (qi::lit("false") | "False" | "FALSE" | "0")[qi::_val=false]; - } - qi::rule<Iterator, bool(), Skipper> boolean_literal; + } + qi::rule<Iterator, bool(), Skipper> boolean_literal; }; REGISTER_GRAMMAR(bool, BoolGrammar); //============================================================================== template< typename Iterator, typename RT , typename Skipper> struct IntGrammar : qi::grammar<Iterator, RT(), Skipper> { - typedef RT ResultT; - IntGrammar() : IntGrammar::base_type( integer ) { - integer = qi::int_parser<RT>()[qi::_val = qi::_1] - >> -qi::no_case[qi::char_('L')]; - } - qi::rule<Iterator, RT(), Skipper> integer; - }; + typedef RT ResultT; + IntGrammar() : IntGrammar::base_type( integer ) { + integer = qi::int_parser<RT>()[qi::_val = qi::_1] + >> -qi::no_case[qi::char_('L')]; + } + qi::rule<Iterator, RT(), Skipper> integer; + }; // ---------------------------------------------------------------------------- // Register IntGrammar: // ---------------------------------------------------------------------------- template <typename Iterator, typename T, typename Skipper> struct Grammar_<Iterator, T, Skipper, typename boost::enable_if<boost::is_integral<T> >::type> - { - typedef IntGrammar<Iterator, T, Skipper> Grammar; - }; + { + typedef IntGrammar<Iterator, T, Skipper> Grammar; + }; //============================================================================== template< typename Iterator, typename RT, typename Skipper> struct RealGrammar : qi::grammar<Iterator, RT(), Skipper> { - typedef RT ResultT; - RealGrammar() : RealGrammar::base_type(real) { - real = qi::real_parser<RT>(); - } - qi::rule<Iterator, RT(), Skipper> real; - }; + typedef RT ResultT; + RealGrammar() : RealGrammar::base_type(real) { + real = qi::real_parser<RT>(); + } + qi::rule<Iterator, RT(), Skipper> real; + }; // ---------------------------------------------------------------------------- // Register RealGrammar: // ---------------------------------------------------------------------------- template <typename Iterator, typename T, typename Skipper > struct Grammar_<Iterator, T, Skipper, - typename boost::enable_if<boost::is_floating_point<T> >::type > { - typedef RealGrammar<Iterator, T, Skipper> Grammar; - }; + typename boost::enable_if<boost::is_floating_point<T> >::type > { + typedef RealGrammar<Iterator, T, Skipper> Grammar; + }; //============================================================================== template< typename Iterator, typename VectorT, typename Skipper> struct VectorGrammar : qi::grammar<Iterator, VectorT(), qi::locals<char>,Skipper> { - //------------------------------------------------------------------------------ - typedef VectorT ResultT; - //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ + typedef VectorT ResultT; + //------------------------------------------------------------------------------ VectorGrammar() : VectorGrammar::base_type(vec) { - begin = enc::char_('[')[qi::_val=']'] | enc::char_('{')[qi::_val='}'] - | enc::char_('(')[qi::_val=')']; - end = enc::char_(qi::_r1); - list = elementGrammar % ','; - vec = begin[qi::_a = qi::_1] >> -list[qi::_val=qi::_1] >> end(qi::_a); - } - // ---------------------------------------------------------------------------- - typename - Grammar_<Iterator, typename VectorT::value_type, Skipper>::Grammar - elementGrammar; - qi::rule<Iterator, char()> begin; - qi::rule<Iterator, void(char)> end; + begin = enc::char_('[')[qi::_val=']'] | enc::char_('{')[qi::_val='}'] + | enc::char_('(')[qi::_val=')']; + end = enc::char_(qi::_r1); + list = elementGrammar % ','; + vec = begin[qi::_a = qi::_1] >> -list[qi::_val=qi::_1] >> end(qi::_a); + } + // ---------------------------------------------------------------------------- + typename + Grammar_<Iterator, typename VectorT::value_type, Skipper>::Grammar + elementGrammar; + qi::rule<Iterator, char()> begin; + qi::rule<Iterator, void(char)> end; - qi::rule<Iterator, ResultT(), qi::locals<char>,Skipper> vec; - qi::rule<Iterator, ResultT(), Skipper> list; - // ---------------------------------------------------------------------------- + qi::rule<Iterator, ResultT(), qi::locals<char>,Skipper> vec; + qi::rule<Iterator, ResultT(), Skipper> list; + // ---------------------------------------------------------------------------- }; // ---------------------------------------------------------------------------- // Register VectorGrammar for std::vector: @@ -196,8 +196,8 @@ namespace DD4hep { namespace Parsers { template <typename Iterator,typename InnerT,typename AllocatorT,typename Skipper> struct Grammar_<Iterator, std::vector<InnerT, AllocatorT>, Skipper > { typedef - VectorGrammar<Iterator, std::vector<InnerT, AllocatorT>,Skipper> - Grammar; + VectorGrammar<Iterator, std::vector<InnerT, AllocatorT>,Skipper> + Grammar; }; // ---------------------------------------------------------------------------- // Register VectorGrammar for std::list: @@ -205,8 +205,8 @@ namespace DD4hep { namespace Parsers { template <typename Iterator, typename InnerT, typename AllocatorT,typename Skipper> struct Grammar_<Iterator, std::list<InnerT, AllocatorT>, Skipper > { typedef - VectorGrammar<Iterator, std::list<InnerT, AllocatorT>,Skipper> - Grammar; + VectorGrammar<Iterator, std::list<InnerT, AllocatorT>,Skipper> + Grammar; }; // ---------------------------------------------------------------------------- // Register VectorGrammar for std::set: @@ -214,8 +214,8 @@ namespace DD4hep { namespace Parsers { template <typename Iterator, typename InnerT, typename CompareT,typename AllocatorT, typename Skipper> struct Grammar_<Iterator, std::set<InnerT, CompareT, AllocatorT>, Skipper > { typedef - VectorGrammar<Iterator, std::set<InnerT, CompareT, AllocatorT>,Skipper> - Grammar; + VectorGrammar<Iterator, std::set<InnerT, CompareT, AllocatorT>,Skipper> + Grammar; }; //============================================================================== @@ -238,19 +238,19 @@ namespace DD4hep { namespace Parsers { struct first {}; struct second {}; void init(const std::string& delimeter) { - begin = enc::char_('(')[qi::_val=')'] - | - enc::char_('[')[qi::_val=']']; - end = qi::char_(qi::_r1); - pair = begin[qi::_a = qi::_1] >> pair_in[qi::_val = qi::_1] >> end(qi::_a); - pair_in = key >> qi::lit(delimeter) >> value; + begin = enc::char_('(')[qi::_val=')'] + | + enc::char_('[')[qi::_val=']']; + end = qi::char_(qi::_r1); + pair = begin[qi::_a = qi::_1] >> pair_in[qi::_val = qi::_1] >> end(qi::_a); + pair_in = key >> qi::lit(delimeter) >> value; } // ---------------------------------------------------------------------------- typename - Grammar_<Iterator, typename PairT::first_type, Skipper>::Grammar key; + Grammar_<Iterator, typename PairT::first_type, Skipper>::Grammar key; typename - Grammar_<Iterator, typename PairT::second_type, Skipper>::Grammar - value; + Grammar_<Iterator, typename PairT::second_type, Skipper>::Grammar + value; qi::rule<Iterator, char()> begin; qi::rule<Iterator, void(char)> end; qi::rule<Iterator, ResultT(), qi::locals<char>, Skipper> pair; @@ -265,7 +265,7 @@ namespace DD4hep { namespace Parsers { typename Skipper> struct Grammar_<Iterator, std::pair<KeyT, ValueT>, Skipper > { - typedef PairGrammar<Iterator, std::pair<KeyT, ValueT>, Skipper> Grammar; + typedef PairGrammar<Iterator, std::pair<KeyT, ValueT>, Skipper> Grammar; }; // ============================================================================ template< typename Iterator, typename MapT, typename Skipper> @@ -281,38 +281,38 @@ namespace DD4hep { namespace Parsers { struct tag_key{}; struct tag_mapped{}; struct Operations { - template <typename A, typename B = boost::fusion::unused_type, - typename C = boost::fusion::unused_type, - typename D = boost::fusion::unused_type> - struct result { typedef void type; }; - //---------------------------------------------------------------------- - void operator()(ResultT& res, const VectorPairT& vec) const{ - for(typename VectorPairT::const_iterator cur = vec.begin(); - cur != vec.end(); cur++){ - res.insert(*cur); - } - } - void operator()(PairT& res, const KeyT& key, tag_key) const{ - res.first = key; - } - void operator()(PairT& res, const MappedT& value, tag_mapped) const{ - res.second = value; - } - //---------------------------------------------------------------------- + template <typename A, typename B = boost::fusion::unused_type, + typename C = boost::fusion::unused_type, + typename D = boost::fusion::unused_type> + struct result { typedef void type; }; + //---------------------------------------------------------------------- + void operator()(ResultT& res, const VectorPairT& vec) const{ + for(typename VectorPairT::const_iterator cur = vec.begin(); + cur != vec.end(); cur++){ + res.insert(*cur); + } + } + void operator()(PairT& res, const KeyT& key, tag_key) const{ + res.first = key; + } + void operator()(PairT& res, const MappedT& value, tag_mapped) const{ + res.second = value; + } + //---------------------------------------------------------------------- }; //------------------------------------------------------------------------------ MapGrammar() : MapGrammar::base_type(map) { - pair = key[op(qi::_val,qi::_1, tag_key())] > (qi::lit(':') | '=') > - value[op(qi::_val,qi::_1, tag_mapped())]; - list = -(pair % enc::char_(',')); - map = (('[' >> list >> ']') - | ('{' >> list >> '}'))[op(qi::_val,qi::_1)]; + pair = key[op(qi::_val,qi::_1, tag_key())] > (qi::lit(':') | '=') > + value[op(qi::_val,qi::_1, tag_mapped())]; + list = -(pair % enc::char_(',')); + map = (('[' >> list >> ']') + | ('{' >> list >> '}'))[op(qi::_val,qi::_1)]; } // ---------------------------------------------------------------------------- typename - Grammar_<Iterator, typename MapT::key_type, Skipper>::Grammar key; + Grammar_<Iterator, typename MapT::key_type, Skipper>::Grammar key; typename - Grammar_<Iterator, typename MapT::mapped_type, Skipper>::Grammar value; + Grammar_<Iterator, typename MapT::mapped_type, Skipper>::Grammar value; qi::rule<Iterator, PairT(), Skipper> pair; qi::rule<Iterator, VectorPairT(), Skipper> list; qi::rule<Iterator, ResultT(), Skipper> map; @@ -341,8 +341,8 @@ namespace DD4hep { namespace Parsers { struct second {}; KeyValueGrammar() : KeyValueGrammar::base_type(pair) { - //------------------------------------------------------------------------------ - pair = gstring >> ":" >> +enc::char_; + //------------------------------------------------------------------------------ + pair = gstring >> ":" >> +enc::char_; } // ---------------------------------------------------------------------------- StringGrammar<Iterator, Skipper> gstring; @@ -360,28 +360,28 @@ namespace DD4hep { namespace Parsers { // ---------------------------------------------------------------------------- struct Operations { template <typename A, typename B = boost::fusion::unused_type, - typename C = boost::fusion::unused_type, - typename D = boost::fusion::unused_type> - struct result { typedef void type; }; + typename C = boost::fusion::unused_type, + typename D = boost::fusion::unused_type> + struct result { typedef void type; }; void operator()(ResultT& res, const Scalar& value,const char xyz) const{ - typename PointT::Scalar val = evaluate_string<typename PointT::Scalar>(value); - switch(xyz) { - case 'x': res.SetX(val); break; - case 'y': res.SetY(val); break; - case 'z': res.SetZ(val); break; - default: break; - } + typename PointT::Scalar val = evaluate_string<typename PointT::Scalar>(value); + switch(xyz) { + case 'x': res.SetX(val); break; + case 'y': res.SetY(val); break; + case 'z': res.SetZ(val); break; + default: break; + } } }; // Operations // ---------------------------------------------------------------------------- Pnt3DGrammar() : Pnt3DGrammar::base_type(point) { point = list | ('(' >> list >> ')') | ('[' >> list >> ']'); list = -(enc::no_case[qi::lit("x") | qi::lit("px")] >> ':') - >> scalar[op(qi::_val,qi::_1,'x')] >> - ',' >> -(enc::no_case[qi::lit("y") | qi::lit("py")] >> ':') - >> scalar[op(qi::_val,qi::_1,'y')] >> - ',' >> -(enc::no_case[qi::lit("z") | qi::lit("pz")] >> ':') - >> scalar[op(qi::_val,qi::_1,'z')]; + >> scalar[op(qi::_val,qi::_1,'x')] >> + ',' >> -(enc::no_case[qi::lit("y") | qi::lit("py")] >> ':') + >> scalar[op(qi::_val,qi::_1,'y')] >> + ',' >> -(enc::no_case[qi::lit("z") | qi::lit("pz")] >> ':') + >> scalar[op(qi::_val,qi::_1,'z')]; } // ---------------------------------------------------------------------------- qi::rule<Iterator, ResultT(), Skipper> point, list; @@ -410,49 +410,49 @@ namespace DD4hep { namespace Parsers { typedef std::string ScalarT; //----------------------------------------------------------------------------- struct Operations { - template <typename A, typename B = boost::fusion::unused_type, - typename C = boost::fusion::unused_type, - typename D = boost::fusion::unused_type> - struct result { typedef void type; }; + template <typename A, typename B = boost::fusion::unused_type, + typename C = boost::fusion::unused_type, + typename D = boost::fusion::unused_type> + struct result { typedef void type; }; - void operator()(ResultT& res, const ScalarT& value,const char xyz) const{ - typename PointT::Scalar val = evaluate_string<typename PointT::Scalar>(value); - switch(xyz){ - case 'x': res.SetPx(val); break; - case 'y': res.SetPy(val); break; - case 'z': res.SetPz(val); break; - case 'e': res.SetE(val); break; - default: break; - } - } - void operator()(ResultT& res, const ResultT& xyz) const{ - res.SetPx(xyz.Px()); - res.SetPy(xyz.Py()); - res.SetPz(xyz.Pz()); - } + void operator()(ResultT& res, const ScalarT& value,const char xyz) const{ + typename PointT::Scalar val = evaluate_string<typename PointT::Scalar>(value); + switch(xyz){ + case 'x': res.SetPx(val); break; + case 'y': res.SetPy(val); break; + case 'z': res.SetPz(val); break; + case 'e': res.SetE(val); break; + default: break; + } + } + void operator()(ResultT& res, const ResultT& xyz) const{ + res.SetPx(xyz.Px()); + res.SetPy(xyz.Py()); + res.SetPz(xyz.Pz()); + } }; // Operations // ---------------------------------------------------------------------------- Pnt4DGrammar() : Pnt4DGrammar::base_type(point4d) { - point4d = list4d | ('(' >> list4d >> ')') | ('[' >> list4d >> ']'); - list4d = (point3d[op(qi::_val,qi::_1)] >> enc::char_(";,") - >> e[op(qi::_val, qi::_1, 'e')]) - | - (e[op(qi::_val,qi::_1, 'e')] >> enc::char_(";,") - >> point3d[op(qi::_val, qi::_1)]); - e = -(enc::no_case[enc::char_("te")] >> ':') - >> scalar[qi::_val = qi::_1]; + point4d = list4d | ('(' >> list4d >> ')') | ('[' >> list4d >> ']'); + list4d = (point3d[op(qi::_val,qi::_1)] >> enc::char_(";,") + >> e[op(qi::_val, qi::_1, 'e')]) + | + (e[op(qi::_val,qi::_1, 'e')] >> enc::char_(";,") + >> point3d[op(qi::_val, qi::_1)]); + e = -(enc::no_case[enc::char_("te")] >> ':') + >> scalar[qi::_val = qi::_1]; - point3d = list3d | ('(' >> list3d >> ')') | ('[' >> list3d >> ']'); - list3d = -(enc::no_case[qi::lit("x") | qi::lit("px")] >> ':') - >> scalar[op(qi::_val, qi::_1,'x')] >> - ',' >> -(enc::no_case[qi::lit("y") | qi::lit("py")] >> ':') - >> scalar[op(qi::_val, qi::_1,'y')] >> - ',' >> -(enc::no_case[qi::lit("z") | qi::lit("pz")] >> ':') - >> scalar[op(qi::_val, qi::_1,'z')]; + point3d = list3d | ('(' >> list3d >> ')') | ('[' >> list3d >> ']'); + list3d = -(enc::no_case[qi::lit("x") | qi::lit("px")] >> ':') + >> scalar[op(qi::_val, qi::_1,'x')] >> + ',' >> -(enc::no_case[qi::lit("y") | qi::lit("py")] >> ':') + >> scalar[op(qi::_val, qi::_1,'y')] >> + ',' >> -(enc::no_case[qi::lit("z") | qi::lit("pz")] >> ':') + >> scalar[op(qi::_val, qi::_1,'z')]; } // ---------------------------------------------------------------------------- qi::rule<Iterator, ResultT(), Skipper> point3d, point4d, list3d, - list4d; + list4d; qi::rule<Iterator, ScalarT(), Skipper> e; typename Grammar_<Iterator, ScalarT, Skipper>::Grammar scalar; ph::function<Operations> op; @@ -463,8 +463,8 @@ namespace DD4hep { namespace Parsers { // ---------------------------------------------------------------------------- template <typename Iterator, typename T1, typename Skipper> struct Grammar_<Iterator, ROOT::Math::LorentzVector<T1>, Skipper > { - typedef Pnt4DGrammar<Iterator, ROOT::Math::LorentzVector<T1>, Skipper> Grammar; - }; + typedef Pnt4DGrammar<Iterator, ROOT::Math::LorentzVector<T1>, Skipper> Grammar; + }; // ============================================================================ }} // DD4hep::Parsers //============================================================================ diff --git a/DDCore/src/parsers/ParsersFactory.h b/DDCore/src/parsers/ParsersFactory.h index b0b936b0b1bf322dabef638864b8609f81318f4c..b618661d11a4d3d6dd648ec1e7571a9f26361d5e 100644 --- a/DDCore/src/parsers/ParsersFactory.h +++ b/DDCore/src/parsers/ParsersFactory.h @@ -27,7 +27,7 @@ namespace DD4hep { typedef SkipperGrammar<IteratorT> Skipper; // ======================================================================== template<typename ResultT> inline int - parse_(ResultT& result, const std::string& input){ + parse_(ResultT& result, const std::string& input){ Skipper skipper; typename Grammar_<IteratorT, ResultT, Skipper>::Grammar g; IteratorT iter = input.begin(), end = input.end(); @@ -35,7 +35,7 @@ namespace DD4hep { } //========================================================================= template<> inline int - parse_(std::string& result, const std::string& input){ + parse_(std::string& result, const std::string& input){ Skipper skipper; Grammar_<IteratorT, std::string, Skipper>::Grammar g; IteratorT iter = input.begin(), end = input.end(); diff --git a/DDCore/src/parsers/ParsersObjects.cpp b/DDCore/src/parsers/ParsersObjects.cpp index 850585c1cbe0a9e0418339d9209b0607b8b536b8..23465f6e20d427be4585b7f20f6ab80899a050e3 100644 --- a/DDCore/src/parsers/ParsersObjects.cpp +++ b/DDCore/src/parsers/ParsersObjects.cpp @@ -5,7 +5,7 @@ #include "DD4hep/ToStream.h" using namespace std; -namespace ROOT { +namespace ROOT { namespace Math { static bool operator<(const XYZPoint& a, const XYZPoint& b) { if ( a.X() < b.X() ) return true; @@ -29,7 +29,7 @@ namespace ROOT { } } // ============================================================================ -namespace DD4hep { +namespace DD4hep { namespace Parsers { // ========================================================================== template<typename T1, typename T2> inline int @@ -38,7 +38,7 @@ namespace DD4hep { typename Grammar_<IteratorT,ROOT::Math::PositionVector3D<T1,T2>,Skipper>::Grammar g; IteratorT iter = input.begin(), end = input.end(); if (qi::phrase_parse( iter, end, g, skipper, result)){ - return 1; + return 1; } return 0; } diff --git a/DDCore/src/parsers/ParsersStandardList1.cpp b/DDCore/src/parsers/ParsersStandardList1.cpp index ad28873f7132249f02c247b9797fc6d6c3b1d193..4a76b514f85f5d92ddbb68261a66ad77b0c36330 100644 --- a/DDCore/src/parsers/ParsersStandardList1.cpp +++ b/DDCore/src/parsers/ParsersStandardList1.cpp @@ -1,5 +1,5 @@ #include "ParsersStandardListCommon.h" PARSERS_DEF_FOR_LIST(bool) PARSERS_DEF_FOR_LIST(char) -PARSERS_DEF_FOR_LIST(unsigned char) -PARSERS_DEF_FOR_LIST(signed char) + PARSERS_DEF_FOR_LIST(unsigned char) + PARSERS_DEF_FOR_LIST(signed char) diff --git a/DDCore/src/parsers/ParsersStandardList2.cpp b/DDCore/src/parsers/ParsersStandardList2.cpp index f32362c9b1caaec0fb66ead59a0c53384a779d96..f3040a991cd5762f56677b4d8586c8b3ea2ad0ef 100644 --- a/DDCore/src/parsers/ParsersStandardList2.cpp +++ b/DDCore/src/parsers/ParsersStandardList2.cpp @@ -1,5 +1,5 @@ #include "ParsersStandardListCommon.h" PARSERS_DEF_FOR_LIST(int) PARSERS_DEF_FOR_LIST(short) -PARSERS_DEF_FOR_LIST(unsigned short) -PARSERS_DEF_FOR_LIST(unsigned int) + PARSERS_DEF_FOR_LIST(unsigned short) + PARSERS_DEF_FOR_LIST(unsigned int) diff --git a/DDCore/src/parsers/ParsersStandardList3.cpp b/DDCore/src/parsers/ParsersStandardList3.cpp index f7e32e55d37973fecb5f74d570df4c121d0fc9c8..d610cfc7cc70a15ed7ebd3a713cf3bddcb36233d 100644 --- a/DDCore/src/parsers/ParsersStandardList3.cpp +++ b/DDCore/src/parsers/ParsersStandardList3.cpp @@ -1,5 +1,5 @@ #include "ParsersStandardListCommon.h" PARSERS_DEF_FOR_LIST(long) PARSERS_DEF_FOR_LIST(unsigned long) -PARSERS_DEF_FOR_LIST(long long) -PARSERS_DEF_FOR_LIST(unsigned long long) + PARSERS_DEF_FOR_LIST(long long) + PARSERS_DEF_FOR_LIST(unsigned long long) diff --git a/DDCore/src/parsers/ParsersStandardList4.cpp b/DDCore/src/parsers/ParsersStandardList4.cpp index 04d9c51502b8effae50f8a01316266aa4e60f393..5db505633b78f40b8358e4e434de6f60625b387f 100644 --- a/DDCore/src/parsers/ParsersStandardList4.cpp +++ b/DDCore/src/parsers/ParsersStandardList4.cpp @@ -1,5 +1,5 @@ #include "ParsersStandardListCommon.h" PARSERS_DEF_FOR_LIST(double) PARSERS_DEF_FOR_LIST(float) -PARSERS_DEF_FOR_LIST(long double) -PARSERS_DEF_FOR_LIST(std::string) + PARSERS_DEF_FOR_LIST(long double) + PARSERS_DEF_FOR_LIST(std::string) diff --git a/DDCore/src/parsers/ParsersStandardListCommon.h b/DDCore/src/parsers/ParsersStandardListCommon.h index e7533c82888057f1db5337b32983eeafe004cc0d..d6987868d6ea2865777c6977a35140760331c0ab 100644 --- a/DDCore/src/parsers/ParsersStandardListCommon.h +++ b/DDCore/src/parsers/ParsersStandardListCommon.h @@ -6,13 +6,13 @@ #include "DD4hep/Parsers.h" #include "ParsersFactory.h" // ============================================================================ -#define PARSERS_DEF_FOR_LIST(InnerType)\ - int DD4hep::Parsers::parse(std::vector<InnerType>& result,const std::string& input)\ - { return DD4hep::Parsers::parse_(result, input); } \ - int DD4hep::Parsers::parse(std::list<InnerType>& result,const std::string& input)\ - { return DD4hep::Parsers::parse_(result, input); } \ - int DD4hep::Parsers::parse(std::set<InnerType>& result,const std::string& input)\ - { return DD4hep::Parsers::parse_(result, input); } \ +#define PARSERS_DEF_FOR_LIST(InnerType) \ + int DD4hep::Parsers::parse(std::vector<InnerType>& result,const std::string& input) \ + { return DD4hep::Parsers::parse_(result, input); } \ + int DD4hep::Parsers::parse(std::list<InnerType>& result,const std::string& input) \ + { return DD4hep::Parsers::parse_(result, input); } \ + int DD4hep::Parsers::parse(std::set<InnerType>& result,const std::string& input) \ + { return DD4hep::Parsers::parse_(result, input); } \ // ============================================================================ #endif /* PARSERS_STANDARD_LIST_COMMON_H */ diff --git a/DDCore/src/parsers/ParsersStandardMisc1.cpp b/DDCore/src/parsers/ParsersStandardMisc1.cpp index 8ae34a8c2283fbe1f7fbd30af96b9365de9b8941..a653ba631eef0cc5027cfc3c23b4944d9fa213e3 100644 --- a/DDCore/src/parsers/ParsersStandardMisc1.cpp +++ b/DDCore/src/parsers/ParsersStandardMisc1.cpp @@ -1,21 +1,21 @@ #include "ParsersStandardMiscCommon.h" int DD4hep::Parsers::parse(std::pair<double,double>& result, const std::string& input) { - return DD4hep::Parsers::parse_(result, input); + return DD4hep::Parsers::parse_(result, input); } int DD4hep::Parsers::parse(std::pair<int, int>& result, const std::string& input) { - return DD4hep::Parsers::parse_(result, input); + return DD4hep::Parsers::parse_(result, input); } int DD4hep::Parsers::parse(std::vector<std::pair<double, double> >& result, const std::string& input) { - return DD4hep::Parsers::parse_(result, input); + return DD4hep::Parsers::parse_(result, input); } int DD4hep::Parsers::parse(std::vector<std::pair<int, int> >& result, const std::string& input) { - return DD4hep::Parsers::parse_(result, input); + return DD4hep::Parsers::parse_(result, input); } int DD4hep::Parsers::parse(std::vector<std::vector<std::string> >& result, const std::string& input) { - return DD4hep::Parsers::parse_(result, input); + return DD4hep::Parsers::parse_(result, input); } diff --git a/DDCore/src/parsers/ParsersStandardMisc2.cpp b/DDCore/src/parsers/ParsersStandardMisc2.cpp index bb4ed696a6d7cc85ed181ca8ce146116337d0123..04cd39710c35913d30cf0f44550751a2e837fe37 100644 --- a/DDCore/src/parsers/ParsersStandardMisc2.cpp +++ b/DDCore/src/parsers/ParsersStandardMisc2.cpp @@ -1,17 +1,17 @@ #include "ParsersStandardMiscCommon.h" int DD4hep::Parsers::parse(std::vector<std::vector<double> >& result, const std::string& input) { - return DD4hep::Parsers::parse_(result, input); + return DD4hep::Parsers::parse_(result, input); } int DD4hep::Parsers::parse(std::map<int, int>& result, const std::string& input) { - return DD4hep::Parsers::parse_(result, input); + return DD4hep::Parsers::parse_(result, input); } int DD4hep::Parsers::parse(std::map<int, double>& result, const std::string& input) { - return DD4hep::Parsers::parse_(result, input); + return DD4hep::Parsers::parse_(result, input); } int DD4hep::Parsers::parse(std::map<std::string, std::string>& result, const std::string& input) { - return DD4hep::Parsers::parse_(result, input); + return DD4hep::Parsers::parse_(result, input); } diff --git a/DDCore/src/parsers/ParsersStandardMisc3.cpp b/DDCore/src/parsers/ParsersStandardMisc3.cpp index 9cc2a0348a745e8173285d56658c45aece719682..5da3432ca06f0b39ac91bb068fdf8f0fcebbac98 100644 --- a/DDCore/src/parsers/ParsersStandardMisc3.cpp +++ b/DDCore/src/parsers/ParsersStandardMisc3.cpp @@ -1,17 +1,17 @@ #include "ParsersStandardMiscCommon.h" int DD4hep::Parsers::parse(std::map<std::string, int>& result, const std::string& input) { - return DD4hep::Parsers::parse_(result, input); + return DD4hep::Parsers::parse_(result, input); } int DD4hep::Parsers::parse(std::map<std::string, unsigned int>& result, const std::string& input) { - return DD4hep::Parsers::parse_(result, input); + return DD4hep::Parsers::parse_(result, input); } int DD4hep::Parsers::parse(std::map<std::string, double>& result, const std::string& input) { - return DD4hep::Parsers::parse_(result, input); + return DD4hep::Parsers::parse_(result, input); } int DD4hep::Parsers::parse(std::map<std::string, std::vector<std::string> >& result, const std::string& input) { - return DD4hep::Parsers::parse_(result, input); + return DD4hep::Parsers::parse_(result, input); } diff --git a/DDCore/src/parsers/ParsersStandardMisc4.cpp b/DDCore/src/parsers/ParsersStandardMisc4.cpp index 5867cd25e3a0090f627666468dbc5f5b9c016d62..6baab15b04daee2cff91fb1b2e4008460694f16b 100644 --- a/DDCore/src/parsers/ParsersStandardMisc4.cpp +++ b/DDCore/src/parsers/ParsersStandardMisc4.cpp @@ -1,13 +1,13 @@ #include "ParsersStandardMiscCommon.h" int DD4hep::Parsers::parse(std::map<std::string, std::vector<int> >& result, const std::string& input) { - return DD4hep::Parsers::parse_(result, input); + return DD4hep::Parsers::parse_(result, input); } int DD4hep::Parsers::parse(std::map<std::string, std::vector<double> >& result, const std::string& input) { - return DD4hep::Parsers::parse_(result, input); + return DD4hep::Parsers::parse_(result, input); } int DD4hep::Parsers::parse(std::map<int, std::string>& result, const std::string& input) { - return DD4hep::Parsers::parse_(result, input); + return DD4hep::Parsers::parse_(result, input); } diff --git a/DDCore/src/parsers/ParsersStandardMisc5.cpp b/DDCore/src/parsers/ParsersStandardMisc5.cpp index 5984100beba3ab1901e939c0979b7dcadcb37a67..12ea5ec5f8bd8ed49db80061e97052423ef9946b 100644 --- a/DDCore/src/parsers/ParsersStandardMisc5.cpp +++ b/DDCore/src/parsers/ParsersStandardMisc5.cpp @@ -1,17 +1,17 @@ #include "ParsersStandardMiscCommon.h" int DD4hep::Parsers::parse(std::map<unsigned int, std::string>& result, const std::string& input) { - return DD4hep::Parsers::parse_(result, input); + return DD4hep::Parsers::parse_(result, input); } int DD4hep::Parsers::parse(std::string& name, std::string& value , - const std::string& input ) { + const std::string& input ) { Skipper skipper; KeyValueGrammar<IteratorT, Skipper> g; KeyValueGrammar<IteratorT, Skipper>::ResultT result; std::string::const_iterator iter = input.begin(); bool parse_result = qi::phrase_parse(iter, input.end(), g, skipper, - result) && (iter==input.end()); + result) && (iter==input.end()); if (parse_result) { name = result.first; value = result.second; @@ -20,5 +20,5 @@ int DD4hep::Parsers::parse(std::string& name, std::string& value , } int DD4hep::Parsers::parse(std::map<std::string, std::pair<double, double> >& result, const std::string& input) { - return DD4hep::Parsers::parse_(result, input); + return DD4hep::Parsers::parse_(result, input); } diff --git a/DDCore/src/parsers/ParsersStandardSingle.cpp b/DDCore/src/parsers/ParsersStandardSingle.cpp index a5428f120e80542868a75a3e47eac793a9765517..64ef13e38a0d974fa164aaa00bac143a9533c680 100644 --- a/DDCore/src/parsers/ParsersStandardSingle.cpp +++ b/DDCore/src/parsers/ParsersStandardSingle.cpp @@ -4,23 +4,23 @@ #include "DD4hep/Parsers.h" #include "ParsersFactory.h" // ============================================================================ -#define PARSERS_DEF_FOR_SINGLE(Type)\ - int DD4hep::Parsers::parse(Type& result, const std::string& input) \ - { return DD4hep::Parsers::parse_(result, input); } +#define PARSERS_DEF_FOR_SINGLE(Type) \ + int DD4hep::Parsers::parse(Type& result, const std::string& input) \ + { return DD4hep::Parsers::parse_(result, input); } // ============================================================================ PARSERS_DEF_FOR_SINGLE(bool) PARSERS_DEF_FOR_SINGLE(char) -PARSERS_DEF_FOR_SINGLE(unsigned char) -PARSERS_DEF_FOR_SINGLE(signed char) -PARSERS_DEF_FOR_SINGLE(int) -PARSERS_DEF_FOR_SINGLE(short) -PARSERS_DEF_FOR_SINGLE(unsigned short) -PARSERS_DEF_FOR_SINGLE(unsigned int) -PARSERS_DEF_FOR_SINGLE(long) -PARSERS_DEF_FOR_SINGLE(unsigned long) -PARSERS_DEF_FOR_SINGLE(long long) -PARSERS_DEF_FOR_SINGLE(unsigned long long) -PARSERS_DEF_FOR_SINGLE(double) -PARSERS_DEF_FOR_SINGLE(float) -PARSERS_DEF_FOR_SINGLE(long double) -PARSERS_DEF_FOR_SINGLE(std::string) + PARSERS_DEF_FOR_SINGLE(unsigned char) + PARSERS_DEF_FOR_SINGLE(signed char) + PARSERS_DEF_FOR_SINGLE(int) + PARSERS_DEF_FOR_SINGLE(short) + PARSERS_DEF_FOR_SINGLE(unsigned short) + PARSERS_DEF_FOR_SINGLE(unsigned int) + PARSERS_DEF_FOR_SINGLE(long) + PARSERS_DEF_FOR_SINGLE(unsigned long) + PARSERS_DEF_FOR_SINGLE(long long) + PARSERS_DEF_FOR_SINGLE(unsigned long long) + PARSERS_DEF_FOR_SINGLE(double) + PARSERS_DEF_FOR_SINGLE(float) + PARSERS_DEF_FOR_SINGLE(long double) + PARSERS_DEF_FOR_SINGLE(std::string) diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp index 95e63a2df14b08e4c8363e1f11aee7586bf42730..7a0198d6dc3963001f2ae8e95386c47d140d17e9 100644 --- a/DDCore/src/plugins/Compact2Objects.cpp +++ b/DDCore/src/plugins/Compact2Objects.cpp @@ -95,7 +95,7 @@ static Ref_t create_SolenoidField(lcdd_t& lcdd, xml_h e) { if (!has_inner_radius && !has_outer_radius) { throw_print("Compact2Objects[ERROR]: For a solenoidal field at least one of the " - " xml attributes inner_radius of outer_radius MUST be set."); + " xml attributes inner_radius of outer_radius MUST be set."); } CartesianField obj; SolenoidField* ptr = new SolenoidField(); @@ -340,9 +340,9 @@ template <> void Converter<Material>::operator()(xml_h e) const { std::string nam = composites.attr<string>(_U(ref)); double fraction = composites.attr<double>(_U(n)); if (0 != (comp_mat = mgr.GetMaterial(nam.c_str()))) - fraction *= comp_mat->GetA(); + fraction *= comp_mat->GetA(); else if (0 != (comp_elt = table->FindElement(nam.c_str()))) - fraction *= comp_elt->A(); + fraction *= comp_elt->A(); else throw_print("Compact2Objects[ERROR]: Converting material:" + mname + " Element missing: " + nam); composite_fractions_total += fraction; @@ -383,7 +383,7 @@ template <> void Converter<Material>::operator()(xml_h e) const { dens += composites.attr<double>(_U(n)) * comp_mat->GetDensity(); } printout(WARNING, "Compact", "++ Material: %s with NO density. " - "Set density to %7.3 g/cm**3", matname, dens); + "Set density to %7.3 g/cm**3", matname, dens); mix->SetDensity(dens); } } @@ -423,7 +423,7 @@ template <> void Converter<Atom>::operator()(xml_h e) const { if (!element) { xml_ref_t atom(elem.child(_U(atom))); tab->AddElement(elem.attr<string>(_U(name)).c_str(), elem.attr<string>(_U(formula)).c_str(), elem.attr<int>(_U(Z)), - atom.attr<int>(_U(value))); + atom.attr<int>(_U(value))); element = tab->FindElement(eltname.c_str()); if (!element) { throw_print("Failed to properly insert the Element:" + eltname + " into the element table!"); @@ -558,20 +558,20 @@ template <> void Converter<Readout>::operator()(xml_h e) const { Segmentation::Parameters::iterator it; for (it = parameters.begin(); it != parameters.end(); ++it) { Segmentation::Parameter p = *it; - if (seg.hasAttr(Unicode(p->name()))) { - string pType = p->type(); - if (pType.compare("int") == 0) { - p->setValue(_toString(seg.attr<int>(Unicode(p->name())))); - } else if (pType.compare("float") == 0) { - p->setValue(_toString(seg.attr<float>(Unicode(p->name())))); - } else if (pType.compare("double") == 0) { - p->setValue(_toString(seg.attr<double>(Unicode(p->name())))); - } else { - p->setValue(seg.attr<string>(Unicode(p->name()))); - } + if (seg.hasAttr(Unicode(p->name()))) { + string pType = p->type(); + if (pType.compare("int") == 0) { + p->setValue(_toString(seg.attr<int>(Unicode(p->name())))); + } else if (pType.compare("float") == 0) { + p->setValue(_toString(seg.attr<float>(Unicode(p->name())))); + } else if (pType.compare("double") == 0) { + p->setValue(_toString(seg.attr<double>(Unicode(p->name())))); + } else { + p->setValue(seg.attr<string>(Unicode(p->name()))); + } } else if (not p->isOptional()) { - throw_print("FAILED to create segmentation: " + type + ". Missing mandatory parameter: " + p->name() + "!"); - } + throw_print("FAILED to create segmentation: " + type + ". Missing mandatory parameter: " + p->name() + "!"); + } } } ro.setSegmentation(segment); @@ -736,7 +736,7 @@ template <> void Converter<SensitiveDetector>::operator()(xml_h element) const { sd.setEnergyCutoff(element.attr<double>(ecut)); } printout(DEBUG, "Compact", "SensitiveDetector-update: %-18s %-24s Hits:%-24s Cutoff:%f7.3f", sd.name(), - (" [" + sd.type() + "]").c_str(), sd.hitsCollection().c_str(), sd.energyCutoff()); + (" [" + sd.type() + "]").c_str(), sd.hitsCollection().c_str(), sd.energyCutoff()); xml_attr_t sequence = element.attr_nothrow(_U(sequence)); if (sequence) { } @@ -795,8 +795,8 @@ template <> void Converter<DetElement>::operator()(xml_h element) const { setChildTitles(make_pair(name, det)); } printout(det.isValid() ? INFO : ERROR, "Compact", "%s subdetector:%s of type %s %s", - (det.isValid() ? "++ Converted" : "FAILED "), name.c_str(), type.c_str(), - (sd.isValid() ? ("[" + sd.type() + "]").c_str() : "")); + (det.isValid() ? "++ Converted" : "FAILED "), name.c_str(), type.c_str(), + (sd.isValid() ? ("[" + sd.type() + "]").c_str() : "")); if (!det.isValid()) { PluginDebug dbg; @@ -842,7 +842,7 @@ template <> void Converter<DetElementInclude>::operator()(xml_h element) const { XML::DocumentHolder doc(XML::DocumentHandler().load(element, element.attr_value(_U(ref)))); xml_h node = doc.root(); string tag = node.tag(); - if ( tag == "lccdd" ) + if ( tag == "lccdd" ) Converter < Compact > (this->lcdd)(node); else if ( tag == "define" ) xml_coll_t(node, _U(constant)).for_each(Converter < Constant > (this->lcdd)); @@ -854,7 +854,7 @@ template <> void Converter<DetElementInclude>::operator()(xml_h element) const { xml_coll_t(node, _U(limitset)).for_each(Converter < LimitSet > (this->lcdd)); else if ( tag == "display" ) xml_coll_t(node,_U(vis)).for_each(Converter < VisAttr > (this->lcdd)); - else if ( tag == "detector" ) + else if ( tag == "detector" ) Converter < DetElement > (this->lcdd)(node); else if ( tag == "detectors" ) xml_coll_t(node,_U(detector)).for_each(Converter < DetElement > (this->lcdd)); diff --git a/DDCore/src/plugins/GeometryWalk.cpp b/DDCore/src/plugins/GeometryWalk.cpp index 2db01ff64df802e72a8859e41bf0ce4692e79bbb..57d502927735d23a965333c99b32c28be9263cde 100644 --- a/DDCore/src/plugins/GeometryWalk.cpp +++ b/DDCore/src/plugins/GeometryWalk.cpp @@ -30,7 +30,7 @@ typedef DetectorTools::PlacementPath PlacementPath; namespace { /** @class GeometryWalk * - * Test the volume manager by scanning the sensitive + * Test the volume manager by scanning the sensitive * volumes of one or several subdetectors. * * @author M.Frank @@ -99,7 +99,7 @@ void GeometryWalk::print(DetElement e, PlacedVolume pv, const VolIDs& /* child_i /// Walk through tree of volume placements void GeometryWalk::walk(DetElement e, VolIDs ids) const { - const _C& children = e.children(); + const _C& children = e.children(); PlacedVolume pv = e.placement(); VolIDs child_ids(ids); print(e,pv,ids); @@ -115,11 +115,11 @@ long GeometryWalk::run(LCDD& lcdd,int argc,char** argv) { for(int i=1; i<argc;++i) { string name = argv[i]+1; if ( name == "all" || name == "All" || name == "ALL" ) { - const _C& children = lcdd.world().children(); + const _C& children = lcdd.world().children(); for (_C::const_iterator i=children.begin(); i!=children.end(); ++i) { - DetElement sdet = (*i).second; - cout << "++ Processing subdetector: " << sdet.name() << endl; - GeometryWalk test(lcdd,sdet); + DetElement sdet = (*i).second; + cout << "++ Processing subdetector: " << sdet.name() << endl; + GeometryWalk test(lcdd,sdet); } return 1; } diff --git a/DDCore/src/plugins/LCDD2Output.cpp b/DDCore/src/plugins/LCDD2Output.cpp index 8923ba19edf7165b8616dae833c0769ea65ddba7..9b1028d4a7f0ca539be70d4d83f39325b8621f2d 100644 --- a/DDCore/src/plugins/LCDD2Output.cpp +++ b/DDCore/src/plugins/LCDD2Output.cpp @@ -39,7 +39,7 @@ namespace DD4hep { cout << " "; const Double_t* tr = mat->GetTranslation(); cout << " matrix:|" << mat->GetName() << "|" << mat->IsTranslation() << mat->IsRotation() << mat->IsScale() - << " tr:x=" << tr[0] << " y=" << tr[1] << " z=" << tr[2]; + << " tr:x=" << tr[0] << " y=" << tr[1] << " z=" << tr[2]; if (mat->IsRotation()) { Double_t theta, phi, psi; TGeoRotation rot(*mat); diff --git a/DDCore/src/plugins/LCDDConverter.cpp b/DDCore/src/plugins/LCDDConverter.cpp index 6bf092795019499c0acd8b9c8c221fd0def0bd68..6a1457f23fc770be459f0ec9db1fe863ec536fb1 100644 --- a/DDCore/src/plugins/LCDDConverter.cpp +++ b/DDCore/src/plugins/LCDDConverter.cpp @@ -78,8 +78,8 @@ namespace { c = 0; } XYZRotation rr(a, b, c); - cout << " X:" << a << " " << rr.X() << " Y:" << b << " " << rr.Y() << " Z:" << c << " " << rr.Z() - << " lx:" << r[0] << " ly:" << r[4] << " lz:" << r[8] << endl; + cout << " X:" << a << " " << rr.X() << " Y:" << b << " " << rr.Y() << " Z:" << c << " " << rr.Z() + << " lx:" << r[0] << " ly:" << r[4] << " lz:" << r[8] << endl; return XYZRotation(a, b, c); } #endif @@ -105,7 +105,7 @@ void LCDDConverter::GeometryInfo::check(const string& name, const TNamed* n, map /// Initializing Constructor LCDDConverter::LCDDConverter(LCDD& lcdd) - : m_lcdd(lcdd), m_dataPtr(0) { + : m_lcdd(lcdd), m_dataPtr(0) { } LCDDConverter::~LCDDConverter() { @@ -475,11 +475,11 @@ xml_h LCDDConverter::handleSolid(const string& name, const TGeoShape* shape) con } if ( oper == TGeoBoolNode::kGeoSubtraction ) - solid = xml_elt_t(geo.doc,_U(subtraction)); + solid = xml_elt_t(geo.doc,_U(subtraction)); else if ( oper == TGeoBoolNode::kGeoUnion ) - solid = xml_elt_t(geo.doc,_U(union)); + solid = xml_elt_t(geo.doc,_U(union)); else if ( oper == TGeoBoolNode::kGeoIntersection ) - solid = xml_elt_t(geo.doc,_U(intersection)); + solid = xml_elt_t(geo.doc,_U(intersection)); xml_h obj; geo.doc_solids.append(solid); @@ -750,8 +750,8 @@ xml_h LCDDConverter::handlePlacement(const string& name,PlacedVolume node) const ::snprintf(text, sizeof(text), "_%p_rot", (void*)node.ptr()); place.setRef(_U(positionref), pos.name()); if ( m->IsRotation() ) { - xml_ref_t rot = handleRotation(name + text, m); - place.setRef(_U(rotationref), rot.name()); + xml_ref_t rot = handleRotation(name + text, m); + place.setRef(_U(rotationref), rot.name()); } } if (geo.doc_root.tag() != "gdml") { @@ -823,20 +823,20 @@ xml_h LCDDConverter::handleSegmentation(Segmentation seg) const { const _P::value_type& v = *i; if (v->name() == "lunit") { string val = v->value() == _toDouble("mm") ? "mm" : v->value() == _toDouble("cm") ? "cm" : - v->value() == _toDouble("m") ? "m" : v->value() == _toDouble("micron") ? "micron" : - v->value() == _toDouble("nanometer") ? "namometer" : "??"; + v->value() == _toDouble("m") ? "m" : v->value() == _toDouble("micron") ? "micron" : + v->value() == _toDouble("nanometer") ? "namometer" : "??"; xml.setAttr(Unicode(v->name()), Unicode(val)); continue; } // translate from TGeo units to Geant4 units if necessary if (v->unitType() == DDSegmentation::SegmentationParameter::LengthUnit) { - double value = _toDouble(v->value()) * CM_2_MM; - xml.setAttr(Unicode(v->name()), value); + double value = _toDouble(v->value()) * CM_2_MM; + xml.setAttr(Unicode(v->name()), value); } else if (v->unitType() == DDSegmentation::SegmentationParameter::AngleUnit) { - double value = _toDouble(v->value()) * DEGREE_2_RAD; - xml.setAttr(Unicode(v->name()), value); + double value = _toDouble(v->value()) * DEGREE_2_RAD; + xml.setAttr(Unicode(v->name()), value); } else { - xml.setAttr(Unicode(v->name()), v->value()); + xml.setAttr(Unicode(v->name()), v->value()); } } } @@ -949,13 +949,13 @@ xml_h LCDDConverter::handleField(const std::string& /* name */, OverlayedField f field.setAttr(_U(name), f->GetName()); fld = PluginService::Create<NamedObject*>(type + "_Convert2LCDD", &m_lcdd, &field, &fld); cout << "++ " << (fld.isValid() ? "Converted" : "FAILED to convert ") << " electromagnetic field:" << f->GetName() - << " of type " << type << endl; + << " of type " << type << endl; if (!fld.isValid()) { PluginDebug dbg; PluginService::Create<NamedObject*>(type + "_Convert2LCDD", &m_lcdd, &field, &fld); throw runtime_error( - "Failed to locate plugin to convert electromagnetic field:" + string(f->GetName()) + " of type " + type + ". " - + dbg.missingFactory(type)); + "Failed to locate plugin to convert electromagnetic field:" + string(f->GetName()) + " of type " + type + ". " + + dbg.missingFactory(type)); } geo.doc_fields.append(field); } @@ -994,9 +994,9 @@ void LCDDConverter::handleProperties(LCDD::Properties& prp) const { PluginDebug dbg; result = PluginService::Create<long>(tag, &m_lcdd, ptr, &vals); if (0 == result) { - throw runtime_error("Failed to locate plugin to interprete files of type" - " \"" + tag + "\" - no factory:" + type + ". " + - dbg.missingFactory(tag)); + throw runtime_error("Failed to locate plugin to interprete files of type" + " \"" + tag + "\" - no factory:" + type + ". " + + dbg.missingFactory(tag)); } } result = *(long*) result; @@ -1054,22 +1054,22 @@ xml_doc_t LCDDConverter::createGDML(DetElement top) { cout << "++ ==> Converting in memory detector description to GDML format..." << endl; const char* comment = "\n" - " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" - " ++++ Linear collider detector description GDML in C++ ++++\n" - " ++++ DD4hep Detector description generator. ++++\n" - " ++++ ++++\n" - " ++++ Parser:" - XML_IMPLEMENTATION_TYPE - " ++++\n" - " ++++ ++++\n" - " ++++ M.Frank CERN/LHCb ++++\n" - " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n "; + " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" + " ++++ Linear collider detector description GDML in C++ ++++\n" + " ++++ DD4hep Detector description generator. ++++\n" + " ++++ ++++\n" + " ++++ Parser:" + XML_IMPLEMENTATION_TYPE + " ++++\n" + " ++++ ++++\n" + " ++++ M.Frank CERN/LHCb ++++\n" + " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n "; XML::DocumentHandler docH; geo.doc = docH.create("gdml", comment); geo.doc_root = geo.doc.root(); geo.doc_root.setAttr(Unicode("xmlns:xs"), "http://www.w3.org/2001/XMLSchema-instance"); geo.doc_root.setAttr(Unicode("xs:noNamespaceSchemaLocation"), - "http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd"); + "http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd"); // geo.doc = docH.create("gdml_simple_extension",comment); // geo.doc_root.setAttr(Unicode("xmlns:gdml_simple_extension"),"http://www.example.org"); // geo.doc_root.setAttr(Unicode("xs:noNamespaceSchemaLocation"), @@ -1087,7 +1087,7 @@ xml_doc_t LCDDConverter::createGDML(DetElement top) { #if 0 const LCDD::HandleMap& mat = lcdd.materials(); for(LCDD::HandleMap::const_iterator i=mat.begin(); i!=mat.end(); ++i) - geo.materials.insert(dynamic_cast<TGeoMedium*>((*i).second.ptr())); + geo.materials.insert(dynamic_cast<TGeoMedium*>((*i).second.ptr())); #endif // Start creating the objects for materials, solids and log volumes. @@ -1119,16 +1119,16 @@ xml_doc_t LCDDConverter::createVis(DetElement top) { collect(top, geo); cout << "++ ==> Dump visualisation attributes from in memory detector description..." << endl; const char comment[] = "\n" - " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" - " ++++ Linear collider detector description LCDD in C++ ++++\n" - " ++++ DD4hep Detector description generator. ++++\n" - " ++++ ++++\n" - " ++++ Parser:" - XML_IMPLEMENTATION_TYPE - " ++++\n" - " ++++ ++++\n" - " ++++ M.Frank CERN/LHCb ++++\n" - " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n "; + " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" + " ++++ Linear collider detector description LCDD in C++ ++++\n" + " ++++ DD4hep Detector description generator. ++++\n" + " ++++ ++++\n" + " ++++ Parser:" + XML_IMPLEMENTATION_TYPE + " ++++\n" + " ++++ ++++\n" + " ++++ M.Frank CERN/LHCb ++++\n" + " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n "; XML::DocumentHandler docH; xml_elt_t elt(0); geo.doc = docH.create("visualization", comment); @@ -1153,16 +1153,16 @@ xml_doc_t LCDDConverter::createLCDD(DetElement top) { m_data->clear(); collect(top, geo); const char comment[] = "\n" - " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" - " ++++ Linear collider detector description LCDD in C++ ++++\n" - " ++++ DD4hep Detector description generator. ++++\n" - " ++++ ++++\n" - " ++++ Parser:" - XML_IMPLEMENTATION_TYPE - " ++++\n" - " ++++ ++++\n" - " ++++ M.Frank CERN/LHCb ++++\n" - " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n "; + " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" + " ++++ Linear collider detector description LCDD in C++ ++++\n" + " ++++ DD4hep Detector description generator. ++++\n" + " ++++ ++++\n" + " ++++ Parser:" + XML_IMPLEMENTATION_TYPE + " ++++\n" + " ++++ ++++\n" + " ++++ M.Frank CERN/LHCb ++++\n" + " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n "; XML::DocumentHandler docH; xml_elt_t elt(0); geo.doc = docH.create("lcdd", comment); @@ -1235,8 +1235,8 @@ xml_doc_t LCDDConverter::createLCDD(DetElement top) { /// Helper constructor LCDDConverter::GeometryInfo::GeometryInfo() - : doc(0), doc_root(0), doc_header(0), doc_idDict(0), doc_detectors(0), doc_limits(0), doc_regions(0), doc_display(0), doc_gdml( - 0), doc_fields(0), doc_define(0), doc_materials(0), doc_solids(0), doc_structure(0), doc_setup(0) { + : doc(0), doc_root(0), doc_header(0), doc_idDict(0), doc_detectors(0), doc_limits(0), doc_regions(0), doc_display(0), doc_gdml( + 0), doc_fields(0), doc_define(0), doc_materials(0), doc_solids(0), doc_structure(0), doc_setup(0) { } static long dump_output(xml_doc_t doc, int argc, char** argv) { @@ -1275,9 +1275,9 @@ static long create_visASCII(LCDD& lcdd, int /* argc */, char** argv) { xml_comp_t vis = (*vis_map.find(ref.refStr())).second; xml_comp_t col = vis.child(_U(color)); os << "vol:" << vol.nameStr() << sep << "vis:" << vis.nameStr() << sep << "visible:" << vis.visible() << sep << "r:" - << col.R() << sep << "g:" << col.G() << sep << "b:" << col.B() << sep << "alpha:" << col.alpha() << sep << "line_style:" - << vis.attr < string > (_U(line_style)) << sep << "drawing_style:" << vis.attr < string - > (_U(drawing_style)) << sep << "show_daughters:" << vis.show_daughters() << sep << endl; + << col.R() << sep << "g:" << col.G() << sep << "b:" << col.B() << sep << "alpha:" << col.alpha() << sep << "line_style:" + << vis.attr < string > (_U(line_style)) << sep << "drawing_style:" << vis.attr < string + > (_U(drawing_style)) << sep << "show_daughters:" << vis.show_daughters() << sep << endl; } os.close(); return 1; diff --git a/DDCore/src/plugins/LCDDConverter.h b/DDCore/src/plugins/LCDDConverter.h index fdf96d5cee97012083f191cab3087af652386aba..7c5ca04599c555c6ef89a58da1eab10255268d61 100644 --- a/DDCore/src/plugins/LCDDConverter.h +++ b/DDCore/src/plugins/LCDDConverter.h @@ -107,7 +107,7 @@ namespace DD4hep { xml_doc_t doc; xml_h identity_rot, identity_pos; xml_elt_t doc_root, doc_header, doc_idDict, doc_detectors, doc_limits, doc_regions, doc_display, doc_gdml, doc_fields, - doc_define, doc_materials, doc_solids, doc_structure, doc_setup; + doc_define, doc_materials, doc_solids, doc_structure, doc_setup; GeometryInfo(); }; typedef std::set<std::string> NameSet; diff --git a/DDCore/src/plugins/PandoraConverter.cpp b/DDCore/src/plugins/PandoraConverter.cpp index d32daa0c1f22ef7b5613da424c555c7a8ddce4ec..4011ddb17ec6b2bf1b852107bbf0a33b284674d9 100644 --- a/DDCore/src/plugins/PandoraConverter.cpp +++ b/DDCore/src/plugins/PandoraConverter.cpp @@ -85,12 +85,12 @@ using namespace std; /// Helper constructor PandoraConverter::GeometryInfo::GeometryInfo() - : doc(0), doc_root(0), doc_calorimeters(0), doc_detector(0), doc_coil(0), doc_tracking(0) { + : doc(0), doc_root(0), doc_calorimeters(0), doc_detector(0), doc_coil(0), doc_tracking(0) { } /// Initializing Constructor PandoraConverter::PandoraConverter(LCDD& lcdd) - : m_lcdd(lcdd), m_dataPtr(0) { + : m_lcdd(lcdd), m_dataPtr(0) { } /// Standard destructor @@ -103,15 +103,15 @@ PandoraConverter::~PandoraConverter() { /// Create geometry conversion in Pandora XML format xml_doc_t PandoraConverter::create(DetElement /* top */) { const char empty_xml[] = "<?xml version=\"1.0\" encoding=\"UTF-8\">\n" - "<!-- \n" - " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" - " ++++ Linear collider detector description in C++ ++++\n" - " ++++ DD4hep Detector description generator. ++++\n" - " ++++ ++++\n" - " ++++ M.Frank CERN/LHCb ++++\n" - " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" - "-->\n" - "<pandoraSetup>\n\0\0"; + "<!-- \n" + " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" + " ++++ Linear collider detector description in C++ ++++\n" + " ++++ DD4hep Detector description generator. ++++\n" + " ++++ ++++\n" + " ++++ M.Frank CERN/LHCb ++++\n" + " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" + "-->\n" + "<pandoraSetup>\n\0\0"; XML::DocumentHandler docH; GeometryInfo& geo = *(m_dataPtr = new GeometryInfo); @@ -193,81 +193,81 @@ static long create_lcdd(LCDD& /* lcdd */, int /* argc */, char** /* argv */) { * @author Jeremy McCormick <jeremym@slac.stanford.edu> * @version $Id$ */ -public class Main implements Converter - { + public class Main implements Converter + { private final static boolean DEBUG = false; - // ConditionsManager instance. - private ConditionsManager conditionsManager = ConditionsManager.defaultInstance(); - - // Numerical formatting. - static final DecimalFormat xlen = new DecimalFormat("#.########"); - static final DecimalFormat xfrac = new DecimalFormat("#.########"); - static final DecimalFormat xthick = new DecimalFormat("#.######"); - - /** - * A range of layers with associated EM and HAD sampling fractions. - * - * @author Jeremy McCormick <jeremym@slac.stanford.edu> - */ - static class SamplingLayerRange - { - int lowerLayer; - int upperLayer; - double em; - double had; - - SamplingLayerRange(int lowerLayer, int upperLayer, double em, double had) - { - this.lowerLayer = lowerLayer; - this.upperLayer = upperLayer; - this.em = em; - this.had = had; - } + // ConditionsManager instance. + private ConditionsManager conditionsManager = ConditionsManager.defaultInstance(); + + // Numerical formatting. + static final DecimalFormat xlen = new DecimalFormat("#.########"); + static final DecimalFormat xfrac = new DecimalFormat("#.########"); + static final DecimalFormat xthick = new DecimalFormat("#.######"); + + /** + * A range of layers with associated EM and HAD sampling fractions. + * + * @author Jeremy McCormick <jeremym@slac.stanford.edu> + */ + static class SamplingLayerRange + { + int lowerLayer; + int upperLayer; + double em; + double had; + + SamplingLayerRange(int lowerLayer, int upperLayer, double em, double had) + { + this.lowerLayer = lowerLayer; + this.upperLayer = upperLayer; + this.em = em; + this.had = had; + } public boolean inRange(int layerNumber) - { - return layerNumber >= lowerLayer && layerNumber <= upperLayer; - } + { + return layerNumber >= lowerLayer && layerNumber <= upperLayer; + } public int getLowerLayer() - { - return lowerLayer; - } + { + return lowerLayer; + } public int getUpperLayer() - { - return upperLayer; - } + { + return upperLayer; + } public double getEMSampling() - { - return em; - } + { + return em; + } public double getHADSampling() - { - return had; - } - } - - /** - * A list of SamplingLayerRange objects to represent the sampling for a - * subdetector. - * - * @author Jeremy McCormick <jeremym@slac.stanford.edu> - * - */ - static class SamplingLayers extends ArrayList<SamplingLayerRange> - { + { + return had; + } + } + + /** + * A list of SamplingLayerRange objects to represent the sampling for a + * subdetector. + * + * @author Jeremy McCormick <jeremym@slac.stanford.edu> + * + */ + static class SamplingLayers extends ArrayList<SamplingLayerRange> + { public SamplingLayers() - { - } + { + } public SamplingLayers(SamplingLayerRange range) - { - this.add(range); - } + { + this.add(range); + } public SamplingLayers(List<SamplingLayerRange> ranges) { @@ -275,153 +275,153 @@ public class Main implements Converter } public SamplingLayerRange getSamplingLayerRange(int layern) - { - for (SamplingLayerRange range : this) + { + for (SamplingLayerRange range : this) { if (range.inRange(layern)) - return range; + return range; } - return null; - } + return null; } + } - /** - * Represents CalorimeterConditions for a single subdetector. - * - * @author Jeremy McCormick <jeremym@slac.stanford.edu> - */ + /** + * Represents CalorimeterConditions for a single subdetector. + * + * @author Jeremy McCormick <jeremym@slac.stanford.edu> + */ private static class CalorimeterConditions + { + SamplingLayers samplingLayers; + String name; + double mipEnergy; + double mipSigma; + double mipCut; + double timeCut; + + public String toString() { - SamplingLayers samplingLayers; - String name; - double mipEnergy; - double mipSigma; - double mipCut; - double timeCut; - - public String toString() - { - StringBuffer buff = new StringBuffer(); - buff.append(name + '\n'); - for (SamplingLayerRange range : samplingLayers) + StringBuffer buff = new StringBuffer(); + buff.append(name + '\n'); + for (SamplingLayerRange range : samplingLayers) { buff.append("[" + range.getLowerLayer() + " - " + range.getUpperLayer() + "]" + '\n'); buff.append(" em = " + range.getEMSampling() + '\n'); buff.append(" had = " + range.getHADSampling() + '\n'); } - return buff.toString(); - } + return buff.toString(); + } public SamplingLayers getSamplingLayers() - { - return samplingLayers; - } + { + return samplingLayers; + } - /** - * Constructor that parses raw CalorimeterCalibration conditions for a - * single subdetector. - * - * @param calorimeter - * @param conditions - */ + /** + * Constructor that parses raw CalorimeterCalibration conditions for a + * single subdetector. + * + * @param calorimeter + * @param conditions + */ protected CalorimeterConditions(Calorimeter calorimeter, ConditionsSet conditions) - { - //System.out.println("conditions: " + calorimeter.getName()); - this.name = calorimeter.getName(); + { + //System.out.println("conditions: " + calorimeter.getName()); + this.name = calorimeter.getName(); - // Figure out which layering conditions to use based on the - // CalorimeterType. - String layeringName = null; - if (calorimeter.getCalorimeterType() == CalorimeterType.EM_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.EM_ENDCAP) + // Figure out which layering conditions to use based on the + // CalorimeterType. + String layeringName = null; + if (calorimeter.getCalorimeterType() == CalorimeterType.EM_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.EM_ENDCAP) { layeringName = "ECalLayering"; } - else if (calorimeter.getCalorimeterType() == CalorimeterType.HAD_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.HAD_ENDCAP) + else if (calorimeter.getCalorimeterType() == CalorimeterType.HAD_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.HAD_ENDCAP) { layeringName = "HCalLayering"; } - else if (calorimeter.getCalorimeterType() == CalorimeterType.MUON_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.MUON_ENDCAP) + else if (calorimeter.getCalorimeterType() == CalorimeterType.MUON_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.MUON_ENDCAP) { layeringName = "MuonLayering"; } - else + else { throw new RuntimeException("Don't know how to handle CalorimeterConditions for " + calorimeter.getName() + "."); } - String emName = null; - String hadName = null; - if (calorimeter.getCalorimeterType() == CalorimeterType.EM_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.HAD_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.MUON_BARREL) + String emName = null; + String hadName = null; + if (calorimeter.getCalorimeterType() == CalorimeterType.EM_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.HAD_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.MUON_BARREL) { emName = "EMBarrel_SF"; hadName = "HadBarrel_SF"; } - else if (calorimeter.getCalorimeterType() == CalorimeterType.EM_ENDCAP || calorimeter.getCalorimeterType() == CalorimeterType.HAD_ENDCAP || calorimeter.getCalorimeterType() == CalorimeterType.MUON_ENDCAP) + else if (calorimeter.getCalorimeterType() == CalorimeterType.EM_ENDCAP || calorimeter.getCalorimeterType() == CalorimeterType.HAD_ENDCAP || calorimeter.getCalorimeterType() == CalorimeterType.MUON_ENDCAP) { emName = "EMEndcap_SF"; hadName = "HadEndcap_SF"; } - if (emName == null || hadName == null) + if (emName == null || hadName == null) { throw new RuntimeException("Sampling fractions not found for " + calorimeter.getName() + "."); } - String emSampling = conditions.getString(emName); - String hadSampling = conditions.getString(hadName); - List<Double> emSamplingFractions = new ArrayList<Double>(); - List<Double> hadSamplingFractions = new ArrayList<Double>(); - StringTokenizer tok = new StringTokenizer(emSampling, ","); - while (tok.hasMoreTokens()) + String emSampling = conditions.getString(emName); + String hadSampling = conditions.getString(hadName); + List<Double> emSamplingFractions = new ArrayList<Double>(); + List<Double> hadSamplingFractions = new ArrayList<Double>(); + StringTokenizer tok = new StringTokenizer(emSampling, ","); + while (tok.hasMoreTokens()) { Double emSamplingFraction = Double.valueOf(tok.nextToken().trim()); emSamplingFractions.add(emSamplingFraction); } - tok = new StringTokenizer(hadSampling, ","); - while (tok.hasMoreTokens()) + tok = new StringTokenizer(hadSampling, ","); + while (tok.hasMoreTokens()) { Double hadSamplingFraction = Double.valueOf(tok.nextToken().trim()); hadSamplingFractions.add(hadSamplingFraction); } - String layering = conditions.getString(layeringName); - tok = new StringTokenizer(layering, ","); - List<Integer> layers = new ArrayList<Integer>(); - int maxLayer = calorimeter.getLayering().getLayerCount() - 1; - while (tok.hasMoreTokens()) + String layering = conditions.getString(layeringName); + tok = new StringTokenizer(layering, ","); + List<Integer> layers = new ArrayList<Integer>(); + int maxLayer = calorimeter.getLayering().getLayerCount() - 1; + while (tok.hasMoreTokens()) { String nextToken = tok.nextToken().trim(); int nextLayer = Integer.valueOf(nextToken); layers.add(nextLayer); } - // FIXME Hack to get the correct starting index for the sampling - // fractions. Ideally, the sampling fractions should be separated by subdetector name. - int samplingIndex = 0; - if (calorimeter.getCalorimeterType() == HAD_BARREL || calorimeter.getCalorimeterType() == HAD_ENDCAP) + // FIXME Hack to get the correct starting index for the sampling + // fractions. Ideally, the sampling fractions should be separated by subdetector name. + int samplingIndex = 0; + if (calorimeter.getCalorimeterType() == HAD_BARREL || calorimeter.getCalorimeterType() == HAD_ENDCAP) { samplingIndex = (new StringTokenizer(conditions.getString("ECalLayering"), ",").countTokens()); } - if (calorimeter.getCalorimeterType() == MUON_BARREL || calorimeter.getCalorimeterType() == MUON_ENDCAP) + if (calorimeter.getCalorimeterType() == MUON_BARREL || calorimeter.getCalorimeterType() == MUON_ENDCAP) { samplingIndex = (new StringTokenizer(conditions.getString("ECalLayering"), ",").countTokens()); samplingIndex += (new StringTokenizer(conditions.getString("HCalLayering"), ",").countTokens()); } - // System.out.println(" samplingIndex: " + samplingIndex); + // System.out.println(" samplingIndex: " + samplingIndex); - // Create the SamplingLayerRange list. - samplingLayers = new SamplingLayers(); - for (int i = 0; i < layers.size(); i++) + // Create the SamplingLayerRange list. + samplingLayers = new SamplingLayers(); + for (int i = 0; i < layers.size(); i++) { // Figure out the layer range. int lowerLayer = layers.get(i); int upperLayer = 0; if (i + 1 > layers.size() - 1) - upperLayer = maxLayer; + upperLayer = maxLayer; else - upperLayer = layers.get(i + 1) - 1; + upperLayer = layers.get(i + 1) - 1; // Create the sampling layer range. double emSamplingFraction = emSamplingFractions.get(samplingIndex); @@ -435,73 +435,73 @@ public class Main implements Converter ++samplingIndex; } - // MIP energy. - String mipCondition = null; - String mipSigmaCondition = null; - String mipCutCondition = null; + // MIP energy. + String mipCondition = null; + String mipSigmaCondition = null; + String mipCutCondition = null; - // FIXME: Cleanup this ugliness. - if (calorimeter.getCalorimeterType() == CalorimeterType.EM_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.EM_ENDCAP) + // FIXME: Cleanup this ugliness. + if (calorimeter.getCalorimeterType() == CalorimeterType.EM_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.EM_ENDCAP) { mipCondition = "ECalMip_MPV"; mipSigmaCondition = "ECalMip_sig"; mipCutCondition = "ECalMip_Cut"; } - else if (calorimeter.getCalorimeterType() == CalorimeterType.HAD_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.HAD_ENDCAP) + else if (calorimeter.getCalorimeterType() == CalorimeterType.HAD_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.HAD_ENDCAP) { mipCondition = "HCalMip_MPV"; mipSigmaCondition = "HCalMip_sig"; mipCutCondition = "HCalMip_Cut"; } - else if (calorimeter.getCalorimeterType() == CalorimeterType.MUON_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.MUON_ENDCAP) + else if (calorimeter.getCalorimeterType() == CalorimeterType.MUON_BARREL || calorimeter.getCalorimeterType() == CalorimeterType.MUON_ENDCAP) { mipCondition = "MuonMip_MPV"; mipSigmaCondition = "MuonMip_sig"; mipCutCondition = "MuonMip_Cut"; } - mipEnergy = conditions.getDouble(mipCondition); - mipSigma = conditions.getDouble(mipSigmaCondition); - mipCut = conditions.getDouble(mipCutCondition); - timeCut = conditions.getDouble("timeCut"); - - /* - * System.out.println(" mipEnergy: " + mipEnergy); - * System.out.println(" mipSigma: " + mipSigma); - * System.out.println(" mipCut: " + mipCut); - * System.out.println(" timeCut: " + timeCut); - */ - } + mipEnergy = conditions.getDouble(mipCondition); + mipSigma = conditions.getDouble(mipSigmaCondition); + mipCut = conditions.getDouble(mipCutCondition); + timeCut = conditions.getDouble("timeCut"); + + /* + * System.out.println(" mipEnergy: " + mipEnergy); + * System.out.println(" mipSigma: " + mipSigma); + * System.out.println(" mipCut: " + mipCut); + * System.out.println(" timeCut: " + timeCut); + */ + } public SamplingLayerRange getSamplingLayerRange(int layer) - { - for (SamplingLayerRange layers : this.samplingLayers) + { + for (SamplingLayerRange layers : this.samplingLayers) { if (layers.inRange(layer)) - return layers; + return layers; } - return null; - } + return null; + } public double getMipEnergy() - { - return mipEnergy; - } + { + return mipEnergy; + } public double getMipSigma() - { - return mipSigma; - } + { + return mipSigma; + } public double getMipCut() - { - return mipCut; - } + { + return mipCut; + } public double getTimeCut() - { - return timeCut; - } + { + return timeCut; } + } public void convert(String inputFileName, InputStream in, OutputStream out) throws Exception { @@ -509,323 +509,323 @@ public class Main implements Converter Detector det = reader.read(in); String detectorName = det.getDetectorName(); try - { - conditionsManager.setDetector(detectorName, 0); - } + { + conditionsManager.setDetector(detectorName, 0); + } catch (ConditionsNotFoundException x) - { - throw new RuntimeException("Failed to setup conditions system for detector: " + detectorName, x); - } + { + throw new RuntimeException("Failed to setup conditions system for detector: " + detectorName, x); + } Document doc = convertDetectorToPandora(det); XMLOutputter outputter = new XMLOutputter(); if (out != null) - { - outputter.setFormat(Format.getPrettyFormat()); - outputter.output(doc, out); - out.close(); - } + { + outputter.setFormat(Format.getPrettyFormat()); + outputter.output(doc, out); + out.close(); + } } public Document convertDetectorToPandora(Detector detector) - { - // Setup XML output document. - Document outputDoc = new Document(); - Element root = new Element("pandoraSetup"); - outputDoc.setRootElement(root); - Element calorimeters = new Element("calorimeters"); - root.addContent(calorimeters); - - // Add basic detector data element. - Element detectorTag = new Element("detector"); - detectorTag.setAttribute("name", detector.getDetectorName()); - root.addContent(detectorTag); - - // Setup CalorimeterCalibration conditions. - ConditionsSet calorimeterCalibration = null; - try + { + // Setup XML output document. + Document outputDoc = new Document(); + Element root = new Element("pandoraSetup"); + outputDoc.setRootElement(root); + Element calorimeters = new Element("calorimeters"); + root.addContent(calorimeters); + + // Add basic detector data element. + Element detectorTag = new Element("detector"); + detectorTag.setAttribute("name", detector.getDetectorName()); + root.addContent(detectorTag); + + // Setup CalorimeterCalibration conditions. + ConditionsSet calorimeterCalibration = null; + try { calorimeterCalibration = conditionsManager.getConditions("CalorimeterCalibration"); } - catch (Exception x) + catch (Exception x) { } - boolean haveCalCalib = (calorimeterCalibration == null) ? false : true; + boolean haveCalCalib = (calorimeterCalibration == null) ? false : true; - // Process the subdetectors. - for (Subdetector subdetector : detector.getSubdetectors().values()) + // Process the subdetectors. + for (Subdetector subdetector : detector.getSubdetectors().values()) { //System.out.println(subdetector.getName()); // Only handle calorimeters that are planar. if (subdetector instanceof AbstractPolyhedraCalorimeter) - { - Element calorimeter = new Element("calorimeter"); - AbstractPolyhedraCalorimeter polycal = (AbstractPolyhedraCalorimeter) subdetector; - - // Look for specific calorimeter types in the compact - // description. - Calorimeter.CalorimeterType calType = polycal.getCalorimeterType(); - if (calType.equals(HAD_BARREL) || calType.equals(HAD_ENDCAP) || calType.equals(EM_ENDCAP) || calType.equals(EM_BARREL) || calType.equals(MUON_BARREL) || calType.equals(MUON_ENDCAP)) { - // Set basic parameters in pandora calorimeter. - calorimeter.setAttribute("type", Calorimeter.CalorimeterType.toString(calType)); - calorimeter.setAttribute("innerR", Double.toString(polycal.getInnerRadius())); - calorimeter.setAttribute("innerZ", Double.toString(polycal.getInnerZ())); - calorimeter.setAttribute("innerPhi", Double.toString(polycal.getSectionPhi())); - calorimeter.setAttribute("innerSymmetryOrder", Double.toString(polycal.getNumberOfSides())); - calorimeter.setAttribute("outerR", Double.toString(polycal.getOuterRadius())); - calorimeter.setAttribute("outerZ", Double.toString(polycal.getOuterZ())); - calorimeter.setAttribute("outerPhi", Double.toString(polycal.getSectionPhi())); - calorimeter.setAttribute("outerSymmetryOrder", Double.toString(polycal.getNumberOfSides())); - calorimeter.setAttribute("collection", subdetector.getReadout().getName()); - - // Get the cell sizes from the segmentation. - List<Double> cellSizes = getCellSizes(subdetector); - - // For endcaps, X is U, and Y is V. - if (subdetector.isEndcap()) - { - calorimeter.setAttribute("cellSizeU", Double.toString(cellSizes.get(0))); - calorimeter.setAttribute("cellSizeV", Double.toString(cellSizes.get(1))); - } - // The UV mapping is flipped around for barrel. X is V, and Y is U. - else if (subdetector.isBarrel()) - { - calorimeter.setAttribute("cellSizeU", Double.toString(cellSizes.get(1))); - calorimeter.setAttribute("cellSizeV", Double.toString(cellSizes.get(0))); - } - - // Create identifier description and add to subdet. - calorimeter.addContent(makeIdentifierDescription(polycal)); - - // Add the calorimeter. - calorimeters.addContent(calorimeter); - - LayerStack layers = polycal.getLayering().getLayerStack(); - - Element layersElem = new Element("layers"); - layersElem.setAttribute("nlayers", Integer.toString(layers.getNumberOfLayers())); - - calorimeter.addContent(layersElem); - - double layerD = 0.; - - if (polycal.isBarrel()) - { - layerD = polycal.getInnerRadius(); - } - else if (polycal.isEndcap()) - { - layerD = polycal.getInnerZ(); - } - - CalorimeterConditions subdetectorCalorimeterConditions = null; - - if (haveCalCalib) - { - subdetectorCalorimeterConditions = new CalorimeterConditions((Calorimeter) subdetector, calorimeterCalibration); - } - - // Set MIP energy from calibration. - if (haveCalCalib) - { - calorimeter.setAttribute("mipEnergy", xfrac.format(subdetectorCalorimeterConditions.getMipEnergy())); - calorimeter.setAttribute("mipSigma", xfrac.format(subdetectorCalorimeterConditions.getMipSigma())); - calorimeter.setAttribute("mipCut", xfrac.format(subdetectorCalorimeterConditions.getMipCut())); - calorimeter.setAttribute("timeCut", xfrac.format(subdetectorCalorimeterConditions.getTimeCut())); - } - // Set MIP energy from Bethe-Bloche calculation. - // TODO Check accuracy of this algorithm. - else - { - List<LayerSlice> sensors = subdetector.getLayering().getLayerStack().getLayer(0).getSensors(); - LayerSlice sensor = sensors.get(0); - IMaterial sensorMaterial = MaterialStore.getInstance().get(sensor.getMaterial().getName()); + Element calorimeter = new Element("calorimeter"); + AbstractPolyhedraCalorimeter polycal = (AbstractPolyhedraCalorimeter) subdetector; - ParticleType particleType = ParticlePropertyManager.getParticlePropertyProvider().get(13); - - Hep3Vector p = new BasicHep3Vector(-6.8641, -7.2721, 1.2168e-7); - - double emip = BetheBlochCalculator.computeBetheBloch(sensorMaterial, p, particleType.getMass(), particleType.getCharge(), sensor.getThickness()); - - // Set MIP Energy from Bethe Bloche. - calorimeter.setAttribute("mipEnergy", xfrac.format(emip)); - - // Set defaults for CalCalib parameters. - calorimeter.setAttribute("mipSigma", "0"); - calorimeter.setAttribute("mipCut", "0"); - calorimeter.setAttribute("timeCut", xfrac.format(Double.MAX_VALUE)); - } - - double totalX0 = 0; - - for (int i = 0; i < layers.getNumberOfLayers(); i++) - { - //System.out.println(" layer " + i); - Layer layer = layers.getLayer(i); - - Element layerElem = new Element("layer"); - layersElem.addContent(layerElem); - - // Set radiation and interaction lengths. - double intLen = 0; - double radLen = 0; - for (int j = 0; j < layer.getNumberOfSlices(); j++) + // Look for specific calorimeter types in the compact + // description. + Calorimeter.CalorimeterType calType = polycal.getCalorimeterType(); + if (calType.equals(HAD_BARREL) || calType.equals(HAD_ENDCAP) || calType.equals(EM_ENDCAP) || calType.equals(EM_BARREL) || calType.equals(MUON_BARREL) || calType.equals(MUON_ENDCAP)) { - LayerSlice slice = layer.getSlice(j); - //System.out.println(" slice " + j + " " + slice.getMaterial().getName()); - double x0 = slice.getMaterial().getRadiationLength(); - //System.out.println(" x0_mat_D="+x0); - //System.out.println(" x0_mat="+slice.getMaterial().getRadiationLength()); - radLen += slice.getThickness() / (x0*10); - //System.out.println(" radLen="+radLen); - - double lambda = slice.getMaterial().getNuclearInteractionLength(); - intLen += slice.getThickness() / (lambda*10); + // Set basic parameters in pandora calorimeter. + calorimeter.setAttribute("type", Calorimeter.CalorimeterType.toString(calType)); + calorimeter.setAttribute("innerR", Double.toString(polycal.getInnerRadius())); + calorimeter.setAttribute("innerZ", Double.toString(polycal.getInnerZ())); + calorimeter.setAttribute("innerPhi", Double.toString(polycal.getSectionPhi())); + calorimeter.setAttribute("innerSymmetryOrder", Double.toString(polycal.getNumberOfSides())); + calorimeter.setAttribute("outerR", Double.toString(polycal.getOuterRadius())); + calorimeter.setAttribute("outerZ", Double.toString(polycal.getOuterZ())); + calorimeter.setAttribute("outerPhi", Double.toString(polycal.getSectionPhi())); + calorimeter.setAttribute("outerSymmetryOrder", Double.toString(polycal.getNumberOfSides())); + calorimeter.setAttribute("collection", subdetector.getReadout().getName()); + + // Get the cell sizes from the segmentation. + List<Double> cellSizes = getCellSizes(subdetector); + + // For endcaps, X is U, and Y is V. + if (subdetector.isEndcap()) + { + calorimeter.setAttribute("cellSizeU", Double.toString(cellSizes.get(0))); + calorimeter.setAttribute("cellSizeV", Double.toString(cellSizes.get(1))); + } + // The UV mapping is flipped around for barrel. X is V, and Y is U. + else if (subdetector.isBarrel()) + { + calorimeter.setAttribute("cellSizeU", Double.toString(cellSizes.get(1))); + calorimeter.setAttribute("cellSizeV", Double.toString(cellSizes.get(0))); + } + + // Create identifier description and add to subdet. + calorimeter.addContent(makeIdentifierDescription(polycal)); + + // Add the calorimeter. + calorimeters.addContent(calorimeter); + + LayerStack layers = polycal.getLayering().getLayerStack(); + + Element layersElem = new Element("layers"); + layersElem.setAttribute("nlayers", Integer.toString(layers.getNumberOfLayers())); + + calorimeter.addContent(layersElem); + + double layerD = 0.; + + if (polycal.isBarrel()) + { + layerD = polycal.getInnerRadius(); + } + else if (polycal.isEndcap()) + { + layerD = polycal.getInnerZ(); + } + + CalorimeterConditions subdetectorCalorimeterConditions = null; + + if (haveCalCalib) + { + subdetectorCalorimeterConditions = new CalorimeterConditions((Calorimeter) subdetector, calorimeterCalibration); + } + + // Set MIP energy from calibration. + if (haveCalCalib) + { + calorimeter.setAttribute("mipEnergy", xfrac.format(subdetectorCalorimeterConditions.getMipEnergy())); + calorimeter.setAttribute("mipSigma", xfrac.format(subdetectorCalorimeterConditions.getMipSigma())); + calorimeter.setAttribute("mipCut", xfrac.format(subdetectorCalorimeterConditions.getMipCut())); + calorimeter.setAttribute("timeCut", xfrac.format(subdetectorCalorimeterConditions.getTimeCut())); + } + // Set MIP energy from Bethe-Bloche calculation. + // TODO Check accuracy of this algorithm. + else + { + List<LayerSlice> sensors = subdetector.getLayering().getLayerStack().getLayer(0).getSensors(); + LayerSlice sensor = sensors.get(0); + IMaterial sensorMaterial = MaterialStore.getInstance().get(sensor.getMaterial().getName()); + + ParticleType particleType = ParticlePropertyManager.getParticlePropertyProvider().get(13); + + Hep3Vector p = new BasicHep3Vector(-6.8641, -7.2721, 1.2168e-7); + + double emip = BetheBlochCalculator.computeBetheBloch(sensorMaterial, p, particleType.getMass(), particleType.getCharge(), sensor.getThickness()); + + // Set MIP Energy from Bethe Bloche. + calorimeter.setAttribute("mipEnergy", xfrac.format(emip)); + + // Set defaults for CalCalib parameters. + calorimeter.setAttribute("mipSigma", "0"); + calorimeter.setAttribute("mipCut", "0"); + calorimeter.setAttribute("timeCut", xfrac.format(Double.MAX_VALUE)); + } + + double totalX0 = 0; + + for (int i = 0; i < layers.getNumberOfLayers(); i++) + { + //System.out.println(" layer " + i); + Layer layer = layers.getLayer(i); + + Element layerElem = new Element("layer"); + layersElem.addContent(layerElem); + + // Set radiation and interaction lengths. + double intLen = 0; + double radLen = 0; + for (int j = 0; j < layer.getNumberOfSlices(); j++) + { + LayerSlice slice = layer.getSlice(j); + //System.out.println(" slice " + j + " " + slice.getMaterial().getName()); + double x0 = slice.getMaterial().getRadiationLength(); + //System.out.println(" x0_mat_D="+x0); + //System.out.println(" x0_mat="+slice.getMaterial().getRadiationLength()); + radLen += slice.getThickness() / (x0*10); + //System.out.println(" radLen="+radLen); + + double lambda = slice.getMaterial().getNuclearInteractionLength(); + intLen += slice.getThickness() / (lambda*10); + } + //System.out.println(" x0_lyr_tot=" + radLen); + + totalX0 += radLen; + + //System.out.println(" layer " + i + " " + radLen); + + layerElem.setAttribute("radLen", xlen.format(radLen)); + layerElem.setAttribute("intLen", xlen.format(intLen)); + + // Set distance to IP. + double layerD2 = layerD + layer.getThicknessToSensitiveMid(); + layerElem.setAttribute("distanceToIp", xthick.format(layerD2)); + + // Set cell thickness. + layerElem.setAttribute("cellThickness", xthick.format(layer.getThickness())); + + // Set EM and HAD sampling fractions from + // CalorimeterCalibration conditions, if present. + if (haveCalCalib) + { + SamplingLayerRange layerRange = subdetectorCalorimeterConditions.getSamplingLayerRange(i); + if (calType == EM_BARREL || calType == EM_ENDCAP) + { + layerElem.setAttribute("samplingFraction", xfrac.format(layerRange.getEMSampling())); + } + if (calType == HAD_BARREL || calType == HAD_ENDCAP) + { + layerElem.setAttribute("samplingFraction", xfrac.format(layerRange.getHADSampling())); + } + if (calType == MUON_BARREL || calType == MUON_ENDCAP) + { + layerElem.setAttribute("samplingFraction", xfrac.format(layerRange.getHADSampling())); + } + layerElem.setAttribute("emSamplingFraction", xfrac.format(layerRange.getEMSampling())); + layerElem.setAttribute("hadSamplingFraction", xfrac.format(layerRange.getHADSampling())); + } + // Set from base SamplingFraction conditions. May throw + // an exception if neither CalorimeterCalibration + // or SamplingFractions conditions exists. + else + { + double samplingFraction = SamplingFractionManager.defaultInstance().getSamplingFraction(subdetector, i); + layerElem.setAttribute("emSamplingFraction", xfrac.format(samplingFraction)); + layerElem.setAttribute("hadSamplingFraction", xfrac.format(samplingFraction)); + } + + // Increment layer distance by thickness of layer. + layerD += layer.getThickness(); + } + + //System.out.println(" X0 Sum = " + totalX0); } - //System.out.println(" x0_lyr_tot=" + radLen); - - totalX0 += radLen; - - //System.out.println(" layer " + i + " " + radLen); - layerElem.setAttribute("radLen", xlen.format(radLen)); - layerElem.setAttribute("intLen", xlen.format(intLen)); - - // Set distance to IP. - double layerD2 = layerD + layer.getThicknessToSensitiveMid(); - layerElem.setAttribute("distanceToIp", xthick.format(layerD2)); - - // Set cell thickness. - layerElem.setAttribute("cellThickness", xthick.format(layer.getThickness())); - - // Set EM and HAD sampling fractions from - // CalorimeterCalibration conditions, if present. - if (haveCalCalib) + // Set digital flag. + try { - SamplingLayerRange layerRange = subdetectorCalorimeterConditions.getSamplingLayerRange(i); - if (calType == EM_BARREL || calType == EM_ENDCAP) - { - layerElem.setAttribute("samplingFraction", xfrac.format(layerRange.getEMSampling())); - } - if (calType == HAD_BARREL || calType == HAD_ENDCAP) - { - layerElem.setAttribute("samplingFraction", xfrac.format(layerRange.getHADSampling())); - } - if (calType == MUON_BARREL || calType == MUON_ENDCAP) - { - layerElem.setAttribute("samplingFraction", xfrac.format(layerRange.getHADSampling())); - } - layerElem.setAttribute("emSamplingFraction", xfrac.format(layerRange.getEMSampling())); - layerElem.setAttribute("hadSamplingFraction", xfrac.format(layerRange.getHADSampling())); + // Set digital attribute from conditions, if present. + ConditionsSet conditions = conditionsManager.getConditions("SamplingFractions/" + subdetector.getName()); + boolean isDigital = conditions.getBoolean("digital"); + calorimeter.setAttribute("digital", String.valueOf(isDigital)); } - // Set from base SamplingFraction conditions. May throw - // an exception if neither CalorimeterCalibration - // or SamplingFractions conditions exists. - else + catch (Exception x) { - double samplingFraction = SamplingFractionManager.defaultInstance().getSamplingFraction(subdetector, i); - layerElem.setAttribute("emSamplingFraction", xfrac.format(samplingFraction)); - layerElem.setAttribute("hadSamplingFraction", xfrac.format(samplingFraction)); + calorimeter.setAttribute("digital", "false"); } - - // Increment layer distance by thickness of layer. - layerD += layer.getThickness(); - } - - //System.out.println(" X0 Sum = " + totalX0); - } - - // Set digital flag. - try - { - // Set digital attribute from conditions, if present. - ConditionsSet conditions = conditionsManager.getConditions("SamplingFractions/" + subdetector.getName()); - boolean isDigital = conditions.getBoolean("digital"); - calorimeter.setAttribute("digital", String.valueOf(isDigital)); - } - catch (Exception x) - { - calorimeter.setAttribute("digital", "false"); } - } } - // TODO clean up the hard coded assumptions on coil geometry - double coilRadLen = 0; - double coilIntLen = 0; - int coilLayers = 0; - double coilInnerR = 0; - double coilOuterR = 0; - double bfield = 0; - double coilMaxZ = 0; - try + // TODO clean up the hard coded assumptions on coil geometry + double coilRadLen = 0; + double coilIntLen = 0; + int coilLayers = 0; + double coilInnerR = 0; + double coilOuterR = 0; + double bfield = 0; + double coilMaxZ = 0; + try { MultiLayerTracker c = (MultiLayerTracker) detector.getSubdetector("SolenoidCoilBarrel"); if (c != null) - { - coilLayers = c.getNumberOfLayers(); - coilInnerR = c.getInnerR()[0]; - coilOuterR = c.getInnerR()[coilLayers-1] + c.getLayerThickness(coilLayers-1); - for (int layern = 0; layern != c.getNumberOfLayers(); layern++) { - for (LayerSlice slice : c.getLayer(layern).getSlices()) - { - double x0 = slice.getMaterial().getRadiationLength(); - double sliceRadLen = slice.getThickness() / (x0*10); - double lambda = slice.getMaterial().getNuclearInteractionLength(); - double sliceIntLen = slice.getThickness() / (lambda*10); - - coilRadLen += sliceRadLen; - coilIntLen += sliceIntLen; - } + coilLayers = c.getNumberOfLayers(); + coilInnerR = c.getInnerR()[0]; + coilOuterR = c.getInnerR()[coilLayers-1] + c.getLayerThickness(coilLayers-1); + for (int layern = 0; layern != c.getNumberOfLayers(); layern++) + { + for (LayerSlice slice : c.getLayer(layern).getSlices()) + { + double x0 = slice.getMaterial().getRadiationLength(); + double sliceRadLen = slice.getThickness() / (x0*10); + double lambda = slice.getMaterial().getNuclearInteractionLength(); + double sliceIntLen = slice.getThickness() / (lambda*10); + + coilRadLen += sliceRadLen; + coilIntLen += sliceIntLen; + } + } + //calculate average interaction/radiation length in coil material + coilRadLen = coilRadLen/(coilOuterR-coilInnerR); + coilIntLen = coilIntLen/(coilOuterR-coilInnerR); } - //calculate average interaction/radiation length in coil material - coilRadLen = coilRadLen/(coilOuterR-coilInnerR); - coilIntLen = coilIntLen/(coilOuterR-coilInnerR); - } } - catch (ClassCastException e) + catch (ClassCastException e) { throw new RuntimeException(e); } - try + try { Solenoid s = (Solenoid) detector.getFields().get("GlobalSolenoid"); if (s != null) - { - bfield = s.getField(new BasicHep3Vector(0, 0, 0)).z(); - coilMaxZ = s.getZMax(); - } + { + bfield = s.getField(new BasicHep3Vector(0, 0, 0)).z(); + coilMaxZ = s.getZMax(); + } } - catch (ClassCastException e) + catch (ClassCastException e) { throw new RuntimeException(e); } - Element coil = new Element("coil"); - coil.setAttribute("radLen", xlen.format(coilRadLen)); - coil.setAttribute("intLen", xlen.format(coilIntLen)); - coil.setAttribute("innerR", Double.toString(coilInnerR)); - coil.setAttribute("outerR", Double.toString(coilOuterR)); - coil.setAttribute("z", Double.toString(coilMaxZ)); - coil.setAttribute("bfield", Double.toString(bfield)); - root.addContent(coil); - - Tube tube = (Tube) detector.getTrackingVolume().getLogicalVolume().getSolid(); - Element tracking = new Element("tracking"); - tracking.setAttribute("innerR", Double.toString(tube.getInnerRadius())); - tracking.setAttribute("outerR", Double.toString(tube.getOuterRadius())); - tracking.setAttribute("z", Double.toString(tube.getZHalfLength())); - root.addContent(tracking); - - return outputDoc; - } + Element coil = new Element("coil"); + coil.setAttribute("radLen", xlen.format(coilRadLen)); + coil.setAttribute("intLen", xlen.format(coilIntLen)); + coil.setAttribute("innerR", Double.toString(coilInnerR)); + coil.setAttribute("outerR", Double.toString(coilOuterR)); + coil.setAttribute("z", Double.toString(coilMaxZ)); + coil.setAttribute("bfield", Double.toString(bfield)); + root.addContent(coil); - Element makeIdentifierDescription(Subdetector subdet) - { - IDDescriptor descr = subdet.getIDDecoder().getIDDescription(); - Element id = new Element("id"); - for (int i = 0, j = descr.fieldCount(); i < j; i++) + Tube tube = (Tube) detector.getTrackingVolume().getLogicalVolume().getSolid(); + Element tracking = new Element("tracking"); + tracking.setAttribute("innerR", Double.toString(tube.getInnerRadius())); + tracking.setAttribute("outerR", Double.toString(tube.getOuterRadius())); + tracking.setAttribute("z", Double.toString(tube.getZHalfLength())); + root.addContent(tracking); + + return outputDoc; + } + + Element makeIdentifierDescription(Subdetector subdet) + { + IDDescriptor descr = subdet.getIDDecoder().getIDDescription(); + Element id = new Element("id"); + for (int i = 0, j = descr.fieldCount(); i < j; i++) { Element field = new Element("field"); field.setAttribute("name", descr.fieldName(i)); @@ -835,43 +835,43 @@ public class Main implements Converter id.addContent(field); } - return id; - } + return id; + } private List<Double> getCellSizes(Subdetector subdetector) { List<Double> cellSizes = new ArrayList<Double>(); BaseIDDecoder dec = (BaseIDDecoder) subdetector.getReadout().getIDDecoder(); if (dec instanceof AbstractCartesianGrid) - { - AbstractCartesianGrid cgrid = (AbstractCartesianGrid) dec; - if (cgrid.getGridSizeX() != 0) { - cellSizes.add(cgrid.getGridSizeX()); - } - if (cgrid.getGridSizeY() != 0) - { - cellSizes.add(cgrid.getGridSizeY()); - } - if (cgrid.getGridSizeZ() != 0) - { - cellSizes.add(cgrid.getGridSizeZ()); + AbstractCartesianGrid cgrid = (AbstractCartesianGrid) dec; + if (cgrid.getGridSizeX() != 0) + { + cellSizes.add(cgrid.getGridSizeX()); + } + if (cgrid.getGridSizeY() != 0) + { + cellSizes.add(cgrid.getGridSizeY()); + } + if (cgrid.getGridSizeZ() != 0) + { + cellSizes.add(cgrid.getGridSizeZ()); + } } - } if (cellSizes.size() != 2) - throw new RuntimeException("Only 2 cell dimensions are allowed."); + throw new RuntimeException("Only 2 cell dimensions are allowed."); return cellSizes; } public String getOutputFormat() - { - return "pandora"; - } + { + return "pandora"; + } public FileFilter getFileFilter() - { - return new PandoraFileFilter(); - } + { + return new PandoraFileFilter(); + } private static class PandoraFileFilter extends FileFilter { @@ -882,11 +882,11 @@ public class Main implements Converter } public String getDescription() - { - return "Pandora Geometry file (*.xml)"; - } + { + return "Pandora Geometry file (*.xml)"; } - } + } + } #endif } DECLARE_APPLY(DD4hepGeometry2PANDORA,create_lcdd) diff --git a/DDCore/src/plugins/PluginInvoker.cpp b/DDCore/src/plugins/PluginInvoker.cpp index 1470d2875097709d8eaf53041f83f14eb38e8a9a..d0b7636f07d258585e016a53d13550741fd1549b 100644 --- a/DDCore/src/plugins/PluginInvoker.cpp +++ b/DDCore/src/plugins/PluginInvoker.cpp @@ -83,7 +83,7 @@ template <> void Converter<include_file>::operator()(xml_h element) const { XML::DocumentHolder doc(XML::DocumentHandler().load(element, element.attr_value(_U(ref)))); xml_h node = doc.root(); string tag = node.tag(); - if ( tag == "plugin" ) + if ( tag == "plugin" ) Converter<plugin>(lcdd,param)(node); else if ( tag == "plugins" ) Converter<plugins>(lcdd,param)(node); diff --git a/DDCore/src/plugins/ShapePlugins.cpp b/DDCore/src/plugins/ShapePlugins.cpp index b16f2c4c1e9c12ff774b4a6039a88a6b5693d1c1..0892299b0c4f570c3f782b14c364102de8d5b546 100644 --- a/DDCore/src/plugins/ShapePlugins.cpp +++ b/DDCore/src/plugins/ShapePlugins.cpp @@ -61,7 +61,7 @@ DECLARE_XMLELEMENT(Cone__shape_constructor,create_Cone) static Ref_t create_Trap(lcdd_t&, xml_h element) { xml_dim_t e(element); - if ( e.hasAttr(_U(dz)) ) + if ( e.hasAttr(_U(dz)) ) return Trap(e.dz(),e.dy(),e.dx(),_toDouble(_Unicode(pLTX))); return Trap(e.z(0.0),e.theta(),e.phi(0),e.y1(),e.x1(),e.x2(),e.alpha(),e.y2(),e.x3(),e.x4(),e.alpha2()); } diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp index 8217c9c9eb0c5488ac2a3a991c107b1d7d6e79d3..1007bbb05800d2488242c3f68e485f9548c673b3 100644 --- a/DDCore/src/plugins/StandardPlugins.cpp +++ b/DDCore/src/plugins/StandardPlugins.cpp @@ -44,7 +44,7 @@ static LCDDBuildType build_type(const char* value) { return BUILD_DISPLAY; throw runtime_error(string("Invalid build type value: ")+value); } - + static void* create_lcdd_instance(const char* /* name */) { return &LCDD::getInstance(); } @@ -74,7 +74,7 @@ static long load_compact(LCDD& lcdd, int argc, char** argv) { if ( argc > 1 ) { type = build_type(argv[1]); printout(INFO,"CompactLoader","+++ Processing compact file: %s with flag %s", - input.c_str(), argv[1]); + input.c_str(), argv[1]); lcdd.fromCompact(input,type); return 1; } @@ -93,7 +93,7 @@ static long load_xml(LCDD& lcdd, int argc, char** argv) { if ( argc > 1 ) { type = build_type(argv[1]); printout(INFO,"XMLLoader","+++ Processing XML file: %s with flag %s", - input.c_str(), argv[1]); + input.c_str(), argv[1]); lcdd.fromXML(input,type); return 1; } @@ -116,7 +116,7 @@ static long load_volmgr(LCDD& lcdd, int, char**) { } catch (const exception& e) { throw runtime_error(string(e.what()) + "\n" - "DD4hep: while programming VolumeManager. Are your volIDs correct?"); + "DD4hep: while programming VolumeManager. Are your volIDs correct?"); } catch (...) { throw runtime_error("UNKNOWN exception while programming VolumeManager. Are your volIDs correct?"); @@ -166,7 +166,7 @@ static long dump_volume_tree(LCDD& lcdd, int , char** ) { } else { ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%s Ideal node:%p Aligned node:%p", - level+1,2*level+1,(void*)ideal,(void*)aligned); + level+1,2*level+1,(void*)ideal,(void*)aligned); } printout(INFO,"+++",fmt,"",aligned->GetName()); TGeoVolume* volume = ideal->GetVolume(); diff --git a/DDCore/src/plugins/VolumeMgrTest.cpp b/DDCore/src/plugins/VolumeMgrTest.cpp index 13701ecf0f752f32b068a0320833ad629533a41f..ed5e1f11ed74e472f8b92eafdaffe177ed5db93e 100644 --- a/DDCore/src/plugins/VolumeMgrTest.cpp +++ b/DDCore/src/plugins/VolumeMgrTest.cpp @@ -26,7 +26,7 @@ using namespace DD4hep::Geometry; namespace { /** @class VolIDTest * - * Test the volume manager by scanning the sensitive + * Test the volume manager by scanning the sensitive * volumes of one or several subdetectors. * * @author M.Frank @@ -71,8 +71,8 @@ VolIDTest::VolIDTest(LCDD& lcdd, DetElement sdet, size_t depth) : m_det(sdet) { } if ( !lcdd.sensitiveDetector(m_det.name()).isValid() ) { stringstream err; - err << "The sensitive detector of subdetector " << m_det.name() - << " is not known to the geometry."; + err << "The sensitive detector of subdetector " << m_det.name() + << " is not known to the geometry."; printout(INFO,"VolIDTest",err.str().c_str()); throw runtime_error(err.str()); } @@ -92,19 +92,19 @@ void VolIDTest::checkVolume(DetElement e, PlacedVolume pv, const VolIDs& child_i PlacedVolume det_place = m_mgr.lookupPlacement(vid); if ( pv.ptr() != det_place.ptr() ) { err << "Wrong placement " - << " got " << det_place.name() << " (" << (void*)det_place.ptr() << ")" - << " instead of " << pv.name() << " (" << (void*)pv.ptr() << ") " - << " vid:" << (void*)vid; + << " got " << det_place.name() << " (" << (void*)det_place.ptr() << ")" + << " instead of " << pv.name() << " (" << (void*)pv.ptr() << ") " + << " vid:" << (void*)vid; } else if ( det_elem.ptr() != e.ptr() ) { - err << "Wrong associated detector element vid=" << (void*)vid - << " got " << det_elem.path() << " (" << (void*)det_elem.ptr() << ") " - << " instead of " << e.path() << " (" << (void*)e.ptr() << ")" - << " vid:" << (void*)vid; + err << "Wrong associated detector element vid=" << (void*)vid + << " got " << det_elem.path() << " (" << (void*)det_elem.ptr() << ") " + << " instead of " << e.path() << " (" << (void*)e.ptr() << ")" + << " vid:" << (void*)vid; } else if ( det.ptr() != m_det.ptr() ) { err << "Wrong associated detector " - << " vid:" << (void*)vid; + << " vid:" << (void*)vid; } } catch(const exception& ex) { @@ -140,7 +140,7 @@ void VolIDTest::walkVolume(DetElement e, PlacedVolume pv, VolIDs ids, size_t dep child_ids.insert(child_ids.end(),place.volIDs().begin(),place.volIDs().end()); bool is_sensitive = place.volume().isSensitive(); if ( is_sensitive ) { - checkVolume(e,place,child_ids); + checkVolume(e,place,child_ids); } walkVolume(e,place,child_ids,depth+1,mx_depth); } @@ -151,7 +151,7 @@ void VolIDTest::walkVolume(DetElement e, PlacedVolume pv, VolIDs ids, size_t dep void VolIDTest::walk(DetElement e, VolIDs ids, size_t depth, size_t mx_depth) const { if ( depth <= mx_depth ) { DetElement::Children::const_iterator i; - const DetElement::Children& children = e.children(); + const DetElement::Children& children = e.children(); PlacedVolume pv = e.placement(); VolIDs child_ids(ids); bool is_sensitive = pv.volume().isSensitive(); @@ -174,11 +174,11 @@ long VolIDTest::run(LCDD& lcdd,int argc,char** argv) { for(int i=1; i<argc;++i) { string name = argv[i]+1; if ( name == "all" || name == "All" || name == "ALL" ) { - const DetElement::Children& children = lcdd.world().children(); + const DetElement::Children& children = lcdd.world().children(); for (DetElement::Children::const_iterator i=children.begin(); i!=children.end(); ++i) { - DetElement sdet = (*i).second; - cout << "++ Processing subdetector: " << sdet.name() << endl; - VolIDTest test(lcdd,sdet,99); + DetElement sdet = (*i).second; + cout << "++ Processing subdetector: " << sdet.name() << endl; + VolIDTest test(lcdd,sdet,99); } return 1; } diff --git a/DDG4/ddsim.cpp b/DDG4/ddsim.cpp index a1ef98b6e7ec09dc52d4be660b75ee2f615d605e..3658dea8ab89067bab89b733453fe3b4d598148d 100644 --- a/DDG4/ddsim.cpp +++ b/DDG4/ddsim.cpp @@ -1,5 +1,5 @@ //==================================================================== -// DDSim - LC simulation based on DD4hep +// DDSim - LC simulation based on DD4hep //-------------------------------------------------------------------- // F.Gaede, DESY // $Id:$ @@ -15,32 +15,32 @@ using namespace DD4hep::Simulation::Setup; * Loops over all xml files given on command line: * - first file defines geometry * - subsequent files configure the application - */ + */ int main(int argc, char** argv) { if( argc < 2 ){ - std::cout << " --- Usage example: \n " - << " dd_sim ../ILD/compact/ILD_o1_v05.xml [sensitive_detectors.xml] sequences.xml physics.xml " - << std::endl ; + std::cout << " --- Usage example: \n " + << " dd_sim ../ILD/compact/ILD_o1_v05.xml [sensitive_detectors.xml] sequences.xml physics.xml " + << std::endl ; exit( 0 ) ; } - - + + DD4hep::Geometry::LCDD& lcdd = DD4hep::Geometry::LCDD::getInstance(); - + Kernel& kernel = Kernel::instance(lcdd); - + // first argument: geometry file - + std::string geoFile = "file:" ; geoFile += argv[1] ; - kernel.loadGeometry( geoFile ) ; + kernel.loadGeometry( geoFile ) ; for( int i=2 ; i < argc ; ++i ) { - + std::cout << " will open xml file " << argv[i] << " and load to kernel ..." << std::endl ; kernel.loadXML( argv[i] ) ; diff --git a/DDG4/g4gdmlDisplay.cpp b/DDG4/g4gdmlDisplay.cpp index ea97f3615b49f144a8e0b4fcfabe14d360b5599a..0d7808ff6ad76b54482096e625e73ef8bfeac227 100644 --- a/DDG4/g4gdmlDisplay.cpp +++ b/DDG4/g4gdmlDisplay.cpp @@ -55,9 +55,9 @@ int main(int argc, char** argv) { if ( argv[i][0]=='-' ) { string nam = argv[i]+1; if ( strncmp(nam.c_str(),"gdml",4) == 0 ) - gdml = get_arg(argc,argv,++i); - else if ( strncmp(nam.c_str(),"guisetup",3) == 0 ) - setup = get_arg(argc,argv,++i); + gdml = get_arg(argc,argv,++i); + else if ( strncmp(nam.c_str(),"guisetup",3) == 0 ) + setup = get_arg(argc,argv,++i); } } if ( gdml.empty() || setup.empty() ) { @@ -78,7 +78,7 @@ int main(int argc, char** argv) { // // Get the pointer to the User Interface manager G4UImanager* uiman = G4UImanager::GetUIpointer(); - G4UIExecutive* ui = new G4UIExecutive(1,(char**)args); + G4UIExecutive* ui = new G4UIExecutive(1,(char**)args); uiman->ApplyCommand("/control/execute "+setup); ui->SessionStart(); // end ... diff --git a/DDG4/include/DDG4/ComponentProperties.h b/DDG4/include/DDG4/ComponentProperties.h index 122acf054a0a22f0d027237d67425854dabe04fc..1a9116bc5f000d2206007d9fdad20706c8cd01d4 100644 --- a/DDG4/include/DDG4/ComponentProperties.h +++ b/DDG4/include/DDG4/ComponentProperties.h @@ -94,7 +94,7 @@ namespace DD4hep { Property(const Property& p); /// User constructor template <typename TYPE> Property(TYPE& val) - : m_par(0), m_hdl(0) { + : m_par(0), m_hdl(0) { make(val); } /// Property type name @@ -138,8 +138,8 @@ namespace DD4hep { template <class TYPE> class PropertyValue : private Property { public: TYPE data; - PropertyValue() - : Property(data) { + PropertyValue() + : Property(data) { } /// Assignment operator PropertyValue& operator=(const TYPE& val) { diff --git a/DDG4/include/DDG4/ComponentProperties_inl.h b/DDG4/include/DDG4/ComponentProperties_inl.h index 850abf8a949f9966af76f898803e89795690e21e..3eacb522811ebe0857c420f7a5c6372dd8385543 100644 --- a/DDG4/include/DDG4/ComponentProperties_inl.h +++ b/DDG4/include/DDG4/ComponentProperties_inl.h @@ -67,23 +67,23 @@ namespace DD4hep { } // End namespace DD4hep // Instantiate single property -#define DD4HEP_DEFINE_PROPERTY_TYPE(x) \ - template x Property::value() const; \ - template void Property::value(x& value) const; \ - template void Property::set(const x& value); \ - template Property& Property::operator=(const x& value); \ +#define DD4HEP_DEFINE_PROPERTY_TYPE(x) \ + template x Property::value() const; \ + template void Property::value(x& value) const; \ + template void Property::set(const x& value); \ + template Property& Property::operator=(const x& value); \ template void Property::make(x& value) // Instantiate single property with support for STL containers -#define DD4HEP_DEFINE_PROPERTY_CONT(x) \ - DD4HEP_DEFINE_PROPERTY_TYPE(x); \ - DD4HEP_DEFINE_PROPERTY_TYPE(std::vector<x>); \ - DD4HEP_DEFINE_PROPERTY_TYPE(std::list<x>); \ +#define DD4HEP_DEFINE_PROPERTY_CONT(x) \ + DD4HEP_DEFINE_PROPERTY_TYPE(x); \ + DD4HEP_DEFINE_PROPERTY_TYPE(std::vector<x>); \ + DD4HEP_DEFINE_PROPERTY_TYPE(std::list<x>); \ DD4HEP_DEFINE_PROPERTY_TYPE(std::set<x>) // Instantiate single property with support for STL containers + same for unsigned -#define DD4HEP_DEFINE_PROPERTY_U_CONT(x) \ - DD4HEP_DEFINE_PROPERTY_CONT(x); \ +#define DD4HEP_DEFINE_PROPERTY_U_CONT(x) \ + DD4HEP_DEFINE_PROPERTY_CONT(x); \ DD4HEP_DEFINE_PROPERTY_CONT(unsigned x) #endif // DD4HEP_DDG4_COMPONENTPROPERTIES_INL_H diff --git a/DDG4/include/DDG4/DDG4Dict.h b/DDG4/include/DDG4/DDG4Dict.h index 67fed961a33062b24828ab6b050d62d5360b49df..af88076721e355ff900e69cc53e01559732f104f 100644 --- a/DDG4/include/DDG4/DDG4Dict.h +++ b/DDG4/include/DDG4/DDG4Dict.h @@ -3,7 +3,7 @@ // AIDA Detector description implementation //-------------------------------------------------------------------- // -// Define the ROOT dictionaries for all data classes to be saved +// Define the ROOT dictionaries for all data classes to be saved // which are created by the DDG4 examples. // // Author : M.Frank @@ -15,7 +15,7 @@ // FRamework include files #include "DDG4/Geant4Data.h" #include "DDG4/Geant4Particle.h" -namespace DD4hep { +namespace DD4hep { namespace DDSegmentation { } namespace Simulation { } namespace Geometry { } diff --git a/DDG4/include/DDG4/Factories.h b/DDG4/include/DDG4/Factories.h index 200d7e501f4df924016b26daec3a109aaee75681..86d8f125ea1024eae598d52593bcb9ea04be6594 100644 --- a/DDG4/include/DDG4/Factories.h +++ b/DDG4/include/DDG4/Factories.h @@ -121,11 +121,11 @@ namespace { /// Factory to create Geant4 steppers template <typename P> class Factory<P, G4MagIntegratorStepper*(G4EquationOfMotion*)> : public FF1<P, G4MagIntegratorStepper*, - G4EquationOfMotion*> { + G4EquationOfMotion*> { }; /// Factory to create Geant4 steppers template <typename P> class Factory<P, G4MagIntegratorStepper*(G4Mag_EqRhs*)> : public FF1<P, G4MagIntegratorStepper*, - G4Mag_EqRhs*> { + G4Mag_EqRhs*> { }; /// Factory to create Geant4 equations of motion for magnetic fields template <typename P> class Factory<P, G4Mag_EqRhs*(G4MagneticField*)> : public FF1<P, G4Mag_EqRhs*, G4MagneticField*> { @@ -156,42 +156,42 @@ namespace { public: static void Func(void *ret, void*, ARGS a, void*) { DD4hep::printout(DD4hep::INFO,"PhysicsList","+++ Create physics list of type:%s", - DD4hep::typeName(typeid(P)).c_str()); + DD4hep::typeName(typeid(P)).c_str()); *(G4VUserPhysicsList**) ret = (G4VUserPhysicsList*) new P((DS::Geant4PhysicsListActionSequence*) a[0], *(int*) a[1]); } }; /// Factory template to create Geant4 event reader objects template <typename P> class Factory<P, DD4hep::Simulation::Geant4EventReader*(std::string)> { public: - static void Func(void *ret, void*, const std::vector<void*>& a, void*) + static void Func(void *ret, void*, const std::vector<void*>& a, void*) { *(DD4hep::Simulation::Geant4EventReader**)ret = (DD4hep::Simulation::Geant4EventReader*)new P(*(std::string*)a[0]);} }; } -#define DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(name,func) \ +#define DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(name,func) \ namespace DD4hep { namespace Simulation { struct external_geant4_sd_##name {}; \ template <> G4VSensitiveDetector* Geant4SensitiveDetectorFactory< external_geant4_sd_##name >::create(const std::string& n,DD4hep::Geometry::LCDD& l) { return func(n,l); } \ - }} using DD4hep::Simulation::external_geant4_sd_##name; \ + }} using DD4hep::Simulation::external_geant4_sd_##name; \ PLUGINSVC_FACTORY_WITH_ID(external_geant4_sd_##name,std::string(#name),G4VSensitiveDetector*(std::string,DD4hep::Geometry::LCDD*)) /// Plugin definition to create Geant4 sensitive detectors #define DECLARE_GEANT4SENSITIVEDETECTOR(name) namespace DD4hep { namespace Simulation { struct geant4_sd_##name {}; \ template <> G4VSensitiveDetector* Geant4SensitiveDetectorFactory< geant4_sd_##name >::create(const std::string& n,DD4hep::Geometry::LCDD& l) { return new name(n,l); } \ - }} using DD4hep::Simulation::geant4_sd_##name; \ + }} using DD4hep::Simulation::geant4_sd_##name; \ PLUGINSVC_FACTORY_WITH_ID(geant4_sd_##name,std::string(#name),G4VSensitiveDetector*(std::string,DD4hep::Geometry::LCDD*)) #if 0 /* Equivalent: */ -#define DECLARE_GEANT4SENSITIVEDETECTOR(name) \ +#define DECLARE_GEANT4SENSITIVEDETECTOR(name) \ namespace DD4hep { namespace Simulation { static G4VSensitiveDetector* __sd_create__##name(const std::string& n,DD4hep::Geometry::LCDD& p) { return new name(n,p); } }} \ DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(name,DD4hep::Simulation::__sd_create__##name) #endif -#define DECLARE_GEANT4SENSITIVE_NS(ns,name) using ns::name; \ +#define DECLARE_GEANT4SENSITIVE_NS(ns,name) using ns::name; \ PLUGINSVC_FACTORY_WITH_ID(name,std::string(#name),DD4hep::Simulation::Geant4Sensitive*(DD4hep::Simulation::Geant4Context*,std::string,DD4hep::Geometry::DetElement*,DD4hep::Geometry::LCDD*)) #define DECLARE_GEANT4SENSITIVE(name) DECLARE_GEANT4SENSITIVE_NS(DD4hep::Simulation,name) /// Plugin defintion to create Geant4Action objects -#define DECLARE_GEANT4ACTION_NS(ns,name) using ns::name; \ +#define DECLARE_GEANT4ACTION_NS(ns,name) using ns::name; \ PLUGINSVC_FACTORY_WITH_ID(name,std::string(#name),DD4hep::Simulation::Geant4Action*(DD4hep::Simulation::Geant4Context*,std::string)) /// Plugin defintion to create Geant4Action objects #define DECLARE_GEANT4ACTION(name) DECLARE_GEANT4ACTION_NS(DD4hep::Simulation,name) @@ -213,13 +213,13 @@ namespace { #define DECLARE_GEANT4_PHYSICS_LIST(name) typedef DD4hep::Simulation::Geant4UserPhysicsList< name > G4_physics_list_##name; \ PLUGINSVC_FACTORY_WITH_ID(G4_physics_list_##name,std::string(#name),G4VUserPhysicsList*(DD4hep::Simulation::Geant4PhysicsListActionSequence*,int)) -#define DECLARE_GEANT4_SETUP(name,func) \ - namespace DD4hep { namespace Simulation { struct xml_g4_setup_##name {}; \ - template <> long Geant4SetupAction<DD4hep::Simulation::xml_g4_setup_##name>::create(LCDD& l,const DD4hep::Simulation::Geant4Converter& e, const std::map<std::string,std::string>& a) {return func(l,e,a);} }} \ +#define DECLARE_GEANT4_SETUP(name,func) \ + namespace DD4hep { namespace Simulation { struct xml_g4_setup_##name {}; \ + template <> long Geant4SetupAction<DD4hep::Simulation::xml_g4_setup_##name>::create(LCDD& l,const DD4hep::Simulation::Geant4Converter& e, const std::map<std::string,std::string>& a) {return func(l,e,a);} }} \ PLUGINSVC_FACTORY_WITH_ID(xml_g4_setup_##name,std::string(#name "_Geant4_action"),long(DD4hep::Geometry::LCDD*,const DD4hep::Simulation::Geant4Converter*,const std::map<std::string,std::string>*)) /// Plugin defintion to create event reader objects -#define DECLARE_GEANT4_EVENT_READER(name) \ +#define DECLARE_GEANT4_EVENT_READER(name) \ PLUGINSVC_FACTORY_WITH_ID(name,std::string(#name),DD4hep::Simulation::Geant4EventReader*(std::string)) /// Plugin defintion to create event reader objects diff --git a/DDG4/include/DDG4/Geant4Action.h b/DDG4/include/DDG4/Geant4Action.h index 45fe180608776feea5cd9f629dfb836c724c75ae..c5c671616e4782938559e9c2b5759b9ad4747d53 100644 --- a/DDG4/include/DDG4/Geant4Action.h +++ b/DDG4/include/DDG4/Geant4Action.h @@ -57,14 +57,14 @@ namespace DD4hep { class TypeName : public std::pair<std::string, std::string> { public: /// Default constructor - TypeName() - : std::pair<std::string, std::string>() { + TypeName() + : std::pair<std::string, std::string>() { } - TypeName(const std::pair<std::string, std::string>& c) - : std::pair<std::string, std::string>(c) { + TypeName(const std::pair<std::string, std::string>& c) + : std::pair<std::string, std::string>(c) { } - TypeName(const std::string& typ, const std::string& nam) - : std::pair<std::string, std::string>(typ, nam) { + TypeName(const std::string& typ, const std::string& nam) + : std::pair<std::string, std::string>(typ, nam) { } /// Split string pair according to default delimiter ('/') static TypeName split(const std::string& type_name); @@ -74,7 +74,7 @@ namespace DD4hep { /// Default base class for all Geant 4 actions and derivates thereof. /** - * This is a utility class supporting properties, output and access to + * This is a utility class supporting properties, output and access to * event and run objects through the context. * * \author M.Frank @@ -100,28 +100,28 @@ namespace DD4hep { long m_refCount; //fg: ContextUpdate needs to be public for the clang compiler - // as it is used in SequenceHdl::setContextToClients() + // as it is used in SequenceHdl::setContextToClients() public: /// Functor to update the context of a Geant4Action object - /** + /** * \author M.Frank * \version 1.0 * \ingroup DD4HEP_SIMULATION */ class ContextUpdate { public: - /// reference to the context; - const Geant4Context* context; - /// Constructor - ContextUpdate(const Geant4Context* c=0) : context(c) {} - /// Callback - void operator()(Geant4Action* action) const; + /// reference to the context; + const Geant4Context* context; + /// Constructor + ContextUpdate(const Geant4Context* c=0) : context(c) {} + /// Callback + void operator()(Geant4Action* action) const; }; friend class ContextUpdate; protected: /// Actor class to manipulate action groups - /** + /** * \author M.Frank * \version 1.0 * \ingroup DD4HEP_SIMULATION @@ -152,16 +152,16 @@ namespace DD4hep { _V* operator->() { return &m_v; } - typename _V::iterator begin() { return m_v.begin(); } - typename _V::iterator end() { return m_v.end(); } - typename _V::const_iterator begin() const { return m_v.begin(); } - typename _V::const_iterator end() const { return m_v.end(); } + typename _V::iterator begin() { return m_v.begin(); } + typename _V::iterator end() { return m_v.end(); } + typename _V::const_iterator begin() const { return m_v.begin(); } + typename _V::const_iterator end() const { return m_v.end(); } /// Context updates void operator()(const ContextUpdate& context) { if (m_v.empty()) return; for (typename _V::iterator i = m_v.begin(); i != m_v.end(); ++i) - context(*i); + context(*i); } /// NON-CONST actions template <typename R, typename Q> void operator()(R (Q::*pmf)()) { @@ -196,7 +196,7 @@ namespace DD4hep { ((*i)->*pmf)(a0); } template <typename R, typename Q, typename A0, typename A1> void operator()(R (Q::*pmf)(A0, A1) const, A0 a0, - A1 a1) const { + A1 a1) const { if (m_v.empty()) return; for (typename _V::const_iterator i = m_v.begin(); i != m_v.end(); ++i) @@ -261,7 +261,7 @@ namespace DD4hep { } /// Access the output level PrintLevel outputLevel() const { - return (PrintLevel)m_outputLevel; + return (PrintLevel)m_outputLevel; } /// Set the output level; returns previous value PrintLevel setOutputLevel(PrintLevel new_level); diff --git a/DDG4/include/DDG4/Geant4ActionPhase.h b/DDG4/include/DDG4/Geant4ActionPhase.h index 517ef4e17e0de643e50534b1527f751e494c3036..959b47b9f169f34b43ca15267e83c7e4a4705258 100644 --- a/DDG4/include/DDG4/Geant4ActionPhase.h +++ b/DDG4/include/DDG4/Geant4ActionPhase.h @@ -23,21 +23,21 @@ namespace DD4hep { /* - Geant4Phase, G4EventGenerator --> G4VUserPrimaryGeneratorAction::GeneratePrimaries - Geant4Begin, G4Run --> G4UserRunAction::BeginOfRunAction - Geant4End, G4Run --> G4UserRunAction::EndOfRunAction - Geant4Begin, G4Event --> G4UserEventAction::BeginOfEventAction - Geant4End, G4Event --> G4UserEventAction::EndOfEventAction - Geant4Begin, G4Track --> G4UserTrackingAction::PreUserTrackingAction - Geant4End, G4Track --> G4UserTrackingAction::PostUserTrackingAction - Geant4Phase, G4Step --> G4UserSteppingAction::UserSteppingAction - Geant4Begin, G4TrackStack --> G4UserStackingAction::NewStage - Geant4End, G4TrackStack --> G4UserStackingAction::PrepareNewEvent + Geant4Phase, G4EventGenerator --> G4VUserPrimaryGeneratorAction::GeneratePrimaries + Geant4Begin, G4Run --> G4UserRunAction::BeginOfRunAction + Geant4End, G4Run --> G4UserRunAction::EndOfRunAction + Geant4Begin, G4Event --> G4UserEventAction::BeginOfEventAction + Geant4End, G4Event --> G4UserEventAction::EndOfEventAction + Geant4Begin, G4Track --> G4UserTrackingAction::PreUserTrackingAction + Geant4End, G4Track --> G4UserTrackingAction::PostUserTrackingAction + Geant4Phase, G4Step --> G4UserSteppingAction::UserSteppingAction + Geant4Begin, G4TrackStack --> G4UserStackingAction::NewStage + Geant4End, G4TrackStack --> G4UserStackingAction::PrepareNewEvent - */ + */ /// Action phase definition. Client callback at various stage of the simulation processing - /** + /** * \author M.Frank * \version 1.0 * \ingroup DD4HEP_SIMULATION @@ -54,7 +54,7 @@ namespace DD4hep { public: /// Standard constructor Geant4ActionPhase(Geant4Context* context, const std::string& name, const std::type_info& arg_type0, - const std::type_info& arg_type1, const std::type_info& arg_type2); + const std::type_info& arg_type1, const std::type_info& arg_type2); /// Default destructor virtual ~Geant4ActionPhase(); /// Access phase members @@ -73,7 +73,7 @@ namespace DD4hep { virtual bool remove(Callback callback); /// Add a new member to the phase template <typename TYPE, typename IF_TYPE, typename A0, typename R> - bool add(TYPE* member, R (IF_TYPE::*callback)(A0 arg)) { + bool add(TYPE* member, R (IF_TYPE::*callback)(A0 arg)) { typeinfoCheck(typeid(A0), *m_argTypes[0], "Invalid ARG0 type. Failed to add phase callback."); if (dynamic_cast<IF_TYPE*>(member)) { //member->addRef(); @@ -83,7 +83,7 @@ namespace DD4hep { } /// Add a new member to the phase template <typename TYPE, typename IF_TYPE, typename A0, typename A1, typename R> - bool add(TYPE* member, R (IF_TYPE::*callback)(A0 arg0, A1 arg1)) { + bool add(TYPE* member, R (IF_TYPE::*callback)(A0 arg0, A1 arg1)) { typeinfoCheck(typeid(A0), *m_argTypes[0], "Invalid ARG0 type. Failed to add phase callback."); typeinfoCheck(typeid(A1), *m_argTypes[1], "Invalid ARG1 type. Failed to add phase callback."); if (dynamic_cast<IF_TYPE*>(member)) { @@ -94,7 +94,7 @@ namespace DD4hep { } /// Add a new member to the phase template <typename TYPE, typename IF_TYPE, typename A0, typename A1, typename A2, typename R> - bool add(TYPE* member, R (IF_TYPE::*callback)(A0 arg0, A1 arg1)) { + bool add(TYPE* member, R (IF_TYPE::*callback)(A0 arg0, A1 arg1)) { typeinfoCheck(typeid(A0), *m_argTypes[0], "Invalid ARG0 type. Failed to add phase callback."); typeinfoCheck(typeid(A1), *m_argTypes[1], "Invalid ARG1 type. Failed to add phase callback."); typeinfoCheck(typeid(A2), *m_argTypes[2], "Invalid ARG2 type. Failed to add phase callback."); diff --git a/DDG4/include/DDG4/Geant4AssemblyVolume.h b/DDG4/include/DDG4/Geant4AssemblyVolume.h index 5a90e07181deff1fd602e8bd7d8d075998ac977c..469802957dab5d2958a193700c69d7126599f99b 100644 --- a/DDG4/include/DDG4/Geant4AssemblyVolume.h +++ b/DDG4/include/DDG4/Geant4AssemblyVolume.h @@ -9,7 +9,7 @@ namespace DD4hep { namespace Simulation { /// Hack! Wrapper around G4AssemblyVolume to access protected members. - /** + /** * \author M.Frank * \version 1.0 * \ingroup DD4HEP_SIMULATION @@ -26,25 +26,25 @@ namespace DD4hep { } //std::vector<G4AssemblyTriplet>& triplets() { return fTriplets; } long placeVolume(const TGeoNode* n, G4LogicalVolume* pPlacedVolume, G4Transform3D& transformation) { - size_t id = fTriplets.size(); - m_entries.push_back(n); - this->AddPlacedVolume(pPlacedVolume, transformation); - return (long)id; + size_t id = fTriplets.size(); + m_entries.push_back(n); + this->AddPlacedVolume(pPlacedVolume, transformation); + return (long)id; } long placeAssembly(const TGeoNode* n, Geant4AssemblyVolume* pPlacedVolume, G4Transform3D& transformation) { - size_t id = fTriplets.size(); - m_entries.push_back(n); - this->AddPlacedAssembly(pPlacedVolume, transformation); - return (long)id; + size_t id = fTriplets.size(); + m_entries.push_back(n); + this->AddPlacedAssembly(pPlacedVolume, transformation); + return (long)id; } void imprint(Geant4GeometryInfo& info, - const TGeoNode* n, - Chain chain, - Geant4AssemblyVolume* pAssembly, - G4LogicalVolume* pMotherLV, - G4Transform3D& transformation, - G4int copyNumBase, - G4bool surfCheck ); + const TGeoNode* n, + Chain chain, + Geant4AssemblyVolume* pAssembly, + G4LogicalVolume* pMotherLV, + G4Transform3D& transformation, + G4int copyNumBase, + G4bool surfCheck ); }; } } diff --git a/DDG4/include/DDG4/Geant4Call.h b/DDG4/include/DDG4/Geant4Call.h index 9dcb2ce19d29e87a29d76b3272cf869c92dd2def..31aa6f2a0b75dc82bc51d2fbb6be72cdb471f494 100644 --- a/DDG4/include/DDG4/Geant4Call.h +++ b/DDG4/include/DDG4/Geant4Call.h @@ -16,7 +16,7 @@ namespace DD4hep { namespace Simulation { /// Callback interface class with argument - /** + /** * \author M.Frank * \version 1.0 * \ingroup DD4HEP_SIMULATION diff --git a/DDG4/include/DDG4/Geant4Context.h b/DDG4/include/DDG4/Geant4Context.h index e722e19a0bfd0cabe4365a93741fafe25fdc8221..bd7b46a9b3c07c7b636edd4e9a5946e447d5df09 100644 --- a/DDG4/include/DDG4/Geant4Context.h +++ b/DDG4/include/DDG4/Geant4Context.h @@ -45,8 +45,8 @@ namespace DD4hep { class Geant4GeneratorActionSequence; class Geant4SensDetSequences; - /// User run context for DDG4 - /** + /// User run context for DDG4 + /** * The context is accessible from the Geant4Context pointer, * which is present in every Geant4Action. * The run context is only valid however, if there is actually @@ -82,20 +82,20 @@ namespace DD4hep { * set 'dtor' to ObjectExtensions::_noDelete or 0. */ void* addExtension(void* ptr, const std::type_info& info, destruct_t dtor) { - return ObjectExtensions::addExtension(ptr,info,dtor); + return ObjectExtensions::addExtension(ptr,info,dtor); } /// Add user extension object. Ownership is transferred! - template <typename T> T* addExtension(T* ptr, bool take_ownership=true) { - destruct_t dt = ObjectExtensions::_delete<T>; - return (T*)ObjectExtensions::addExtension(ptr,typeid(T),take_ownership ? dt : 0); + template <typename T> T* addExtension(T* ptr, bool take_ownership=true) { + destruct_t dt = ObjectExtensions::_delete<T>; + return (T*)ObjectExtensions::addExtension(ptr,typeid(T),take_ownership ? dt : 0); } /// Access to type safe extension object. Exception is thrown if the object is invalid - template <typename T> T* extension(bool alert=true) { - return (T*)ObjectExtensions::extension(typeid(T),alert); + template <typename T> T* extension(bool alert=true) { + return (T*)ObjectExtensions::extension(typeid(T),alert); } }; - /// User event context for DDG4 + /// User event context for DDG4 /** * The context is accessible from the Geant4Context pointer, * which is present in every Geant4Action. @@ -109,7 +109,7 @@ namespace DD4hep { * Hence: They are only useful to extend data of an event. * * Any random numbers used to process one event should be accessed - * from this location. The framework ensures that the same seeded + * from this location. The framework ensures that the same seeded * sequence is used throughout the processing of one single event. * * \author M.Frank @@ -140,16 +140,16 @@ namespace DD4hep { * set 'dtor' to ObjectExtensions::_noDelete or 0. */ void* addExtension(void* ptr, const std::type_info& info, destruct_t dtor) { - return ObjectExtensions::addExtension(ptr,info,dtor); + return ObjectExtensions::addExtension(ptr,info,dtor); } /// Add user extension object. Ownership is transferred and object deleted at the end of the event. - template <typename T> T* addExtension(T* ptr, bool take_ownership=true) { - destruct_t dt = ObjectExtensions::_delete<T>; - return (T*)ObjectExtensions::addExtension(ptr,typeid(T),take_ownership ? dt : 0); + template <typename T> T* addExtension(T* ptr, bool take_ownership=true) { + destruct_t dt = ObjectExtensions::_delete<T>; + return (T*)ObjectExtensions::addExtension(ptr,typeid(T),take_ownership ? dt : 0); } /// Access to type safe extension object. Exception is thrown if the object is invalid - template <typename T> T* extension(bool alert=true) { - return (T*)ObjectExtensions::extension(typeid(T),alert); + template <typename T> T* extension(bool alert=true) { + return (T*)ObjectExtensions::extension(typeid(T),alert); } }; @@ -176,7 +176,7 @@ namespace DD4hep { /// Default destructor virtual ~Geant4Context(); /// Set the geant4 run reference - void setRun(Geant4Run* new_run); + void setRun(Geant4Run* new_run); /// Access the geant4 run -- valid only between BeginRun() and EndRun()! Geant4Run& run() const; /// Access the geant4 run by ptr. Must be checked by clients! diff --git a/DDG4/include/DDG4/Geant4Converter.h b/DDG4/include/DDG4/Geant4Converter.h index 0ce5cc8f3f8a2bf854eab4e8bb9e35867d942ade..6d05fe964211b02904ad7e643c5f075e2997c2d0 100644 --- a/DDG4/include/DDG4/Geant4Converter.h +++ b/DDG4/include/DDG4/Geant4Converter.h @@ -20,7 +20,7 @@ namespace DD4hep { namespace Simulation { /// Geometry converter from DD4hep to Geant 4. - /** + /** * \author M.Frank * \version 1.0 * \ingroup DD4HEP_SIMULATION diff --git a/DDG4/include/DDG4/Geant4Data.h b/DDG4/include/DDG4/Geant4Data.h index 0abc1b2da933fcaf9b9e6e67eaa4049f02ecbfd9..e3bb3969030fa63a1896fc72185867c558e51c8a 100644 --- a/DDG4/include/DDG4/Geant4Data.h +++ b/DDG4/include/DDG4/Geant4Data.h @@ -40,7 +40,7 @@ namespace DD4hep { * \ingroup DD4HEP_SIMULATION */ class SimpleRun { - public: + public: /// Run identifiers int runID; /// Number of events in this run @@ -60,7 +60,7 @@ namespace DD4hep { * \ingroup DD4HEP_SIMULATION */ class SimpleEvent { - public: + public: typedef std::vector<long> Seeds; /// Run identifiers int runID; @@ -85,14 +85,14 @@ namespace DD4hep { /// Default constructor DataExtension() {} /// Default destructor - virtual ~DataExtension(); + virtual ~DataExtension(); }; /// Base class for geant4 hit structures used by the default DDG4 sensitive detector implementations /* * Base class for geant4 hit structures created by the * example sensitive detectors. This is a generic class - * only dealing with the cellID. Users may add an extension + * only dealing with the cellID. Users may add an extension * object, which normally should not be necessary. * * \author M.Frank @@ -100,11 +100,11 @@ namespace DD4hep { * \ingroup DD4HEP_SIMULATION */ class Geant4HitData { - public: + public: /// cellID long long int cellID; /// User data extension if required - std::auto_ptr<DataExtension> extension; + std::auto_ptr<DataExtension> extension; /// Utility class describing the monte carlo contribution of a given particle to a hit. /** @@ -122,50 +122,50 @@ namespace DD4hep { double deposit; /// Timestamp when this energy was deposited double time; - /// Proper position of the hit contribution - float x,y,z; + /// Proper position of the hit contribution + float x,y,z; /// Default constructor - MonteCarloContrib() - : trackID(-1), pdgID(-1), deposit(0.0), time(0.0), x(0), y(0), z(0) { + MonteCarloContrib() + : trackID(-1), pdgID(-1), deposit(0.0), time(0.0), x(0), y(0), z(0) { } /// Initializing constructor - MonteCarloContrib(int track_id, int pdg, double dep, double time_stamp) - : trackID(track_id), pdgID(pdg), deposit(dep), time(time_stamp), x(0), y(0), z(0) { + MonteCarloContrib(int track_id, int pdg, double dep, double time_stamp) + : trackID(track_id), pdgID(pdg), deposit(dep), time(time_stamp), x(0), y(0), z(0) { } /// Initializing constructor - MonteCarloContrib(int track_id, int pdg, double dep, double time_stamp, float* pos) - : trackID(track_id), pdgID(pdg), deposit(dep), time(time_stamp), - x(pos[0]), y(pos[1]), z(pos[2]) - { - } + MonteCarloContrib(int track_id, int pdg, double dep, double time_stamp, float* pos) + : trackID(track_id), pdgID(pdg), deposit(dep), time(time_stamp), + x(pos[0]), y(pos[1]), z(pos[2]) + { + } /// Initializing constructor - MonteCarloContrib(int track_id, int pdg, double dep, double time_stamp, double* pos) - : trackID(track_id), pdgID(pdg), deposit(dep), time(time_stamp), - x(pos[0]), y(pos[1]), z(pos[2]) - { - } + MonteCarloContrib(int track_id, int pdg, double dep, double time_stamp, double* pos) + : trackID(track_id), pdgID(pdg), deposit(dep), time(time_stamp), + x(pos[0]), y(pos[1]), z(pos[2]) + { + } /// Copy constructor - MonteCarloContrib(const MonteCarloContrib& c) - : trackID(c.trackID), pdgID(c.pdgID), deposit(c.deposit), time(c.time), - x(c.x), y(c.y), z(c.z) { + MonteCarloContrib(const MonteCarloContrib& c) + : trackID(c.trackID), pdgID(c.pdgID), deposit(c.deposit), time(c.time), + x(c.x), y(c.y), z(c.z) { + } + /// Assignment operator + MonteCarloContrib& operator=(const MonteCarloContrib& c) { + if ( this != &c ) { + trackID = c.trackID; + pdgID = c.pdgID; + deposit = c.deposit; + time = c.time; + x = c.x; + y = c.y; + z = c.z; + } + return *this; } - /// Assignment operator - MonteCarloContrib& operator=(const MonteCarloContrib& c) { - if ( this != &c ) { - trackID = c.trackID; - pdgID = c.pdgID; - deposit = c.deposit; - time = c.time; - x = c.x; - y = c.y; - z = c.z; - } - return *this; - } /// Clear data content void clear() { - x = y = z = 0.0; + x = y = z = 0.0; time = deposit = 0.0; pdgID = trackID = -1; } diff --git a/DDG4/include/DDG4/Geant4DataConversion.h b/DDG4/include/DDG4/Geant4DataConversion.h index c80d6ed8a2270995680ac4ffc7475239d3b02bc6..758c26b47bd856bac97da650787fa966958574e9 100644 --- a/DDG4/include/DDG4/Geant4DataConversion.h +++ b/DDG4/include/DDG4/Geant4DataConversion.h @@ -41,7 +41,7 @@ namespace DD4hep { }; /// Data conversion class - /** + /** * \author M.Frank * \version 1.0 * \ingroup DD4HEP_SIMULATION @@ -77,37 +77,37 @@ namespace DD4hep { namespace Simulation { template <typename OUTPUT,typename ARGS> - Geant4Conversion<OUTPUT,ARGS>::Geant4Conversion() - : Geant4ConversionHelper() - { - } + Geant4Conversion<OUTPUT,ARGS>::Geant4Conversion() + : Geant4ConversionHelper() + { + } template <typename OUTPUT,typename ARGS> - Geant4Conversion<OUTPUT,ARGS>::~Geant4Conversion() - { - } + Geant4Conversion<OUTPUT,ARGS>::~Geant4Conversion() + { + } template <typename OUTPUT,typename ARGS> - typename Geant4Conversion<OUTPUT,ARGS>::Converters& - Geant4Conversion<OUTPUT,ARGS>::conversions() - { - static Converters m; - return m; - } + typename Geant4Conversion<OUTPUT,ARGS>::Converters& + Geant4Conversion<OUTPUT,ARGS>::conversions() + { + static Converters m; + return m; + } template <typename OUTPUT, typename ARGS> - const Geant4Conversion<OUTPUT,ARGS>& - Geant4Conversion<OUTPUT,ARGS>::converter(const std::type_info& typ) - { - typename Converters::const_iterator i = conversions().find(&typ); - if ( i != conversions().end() ) { - return *((*i).second); + const Geant4Conversion<OUTPUT,ARGS>& + Geant4Conversion<OUTPUT,ARGS>::converter(const std::type_info& typ) + { + typename Converters::const_iterator i = conversions().find(&typ); + if ( i != conversions().end() ) { + return *((*i).second); + } + throw std::runtime_error(typeName(typeid(self_t))+ + ": No appropriate LCIO_OUTPUT conversion " + "mechanism known for tag:"+ + typeName(typ)); } - throw std::runtime_error(typeName(typeid(self_t))+ - ": No appropriate LCIO_OUTPUT conversion " - "mechanism known for tag:"+ - typeName(typ)); - } /// Template class for data conversion. To be specialized by the client. /** @@ -116,17 +116,17 @@ namespace DD4hep { * \ingroup DD4HEP_SIMULATION */ template <typename OUTPUT, typename ARGS, typename TAG> - class Geant4DataConversion : public Geant4Conversion<OUTPUT,ARGS> { + class Geant4DataConversion : public Geant4Conversion<OUTPUT,ARGS> { public: typedef TAG tag_t; typedef ARGS arg_t; typedef OUTPUT output_t; typedef Geant4Conversion<output_t,arg_t> self_t; - Geant4DataConversion(void*) : Geant4Conversion<OUTPUT,ARGS>() - { - this->self_t::conversions().insert(make_pair(&typeid(TAG),this)); - //std::cout << "Registered " << typeName(typeid(*this)) << std::endl; - } + Geant4DataConversion(void*) : Geant4Conversion<OUTPUT,ARGS>() + { + this->self_t::conversions().insert(make_pair(&typeid(TAG),this)); + //std::cout << "Registered " << typeName(typeid(*this)) << std::endl; + } virtual OUTPUT* operator()(const ARGS& args) const; }; @@ -134,7 +134,7 @@ namespace DD4hep { } // End namespace DD4hep #define GEANT4_CNAME(a,b) a ## _instance_ ## b -#define DECLARE_GEANT4_DATACONVERTER(output_type,args_type,tag,serial) \ +#define DECLARE_GEANT4_DATACONVERTER(output_type,args_type,tag,serial) \ DD4hep::Simulation::Geant4DataConversion<output_type,args_type,tag> GEANT4_CNAME(s_g4_data_cnv,serial) (0); #define DECLARE_GEANT4_HITCONVERTER(output_type,args_type,tag) DECLARE_GEANT4_DATACONVERTER(output_type,args_type,tag,__LINE__) diff --git a/DDG4/include/DDG4/Geant4DetectorConstruction.h b/DDG4/include/DDG4/Geant4DetectorConstruction.h index 61ada9413b5e739c5269c8b0c825430ee59053da..62500f157ef85ac69a2be9e55281d0deb3ca16e4 100644 --- a/DDG4/include/DDG4/Geant4DetectorConstruction.h +++ b/DDG4/include/DDG4/Geant4DetectorConstruction.h @@ -33,7 +33,7 @@ namespace DD4hep { /// Class to create Geant4 detector geometry from TGeo representation in memory /** * On demand (ie. when calling "Construct") the DD4hep geometry is converted - * to Geant4 with all volumes, assemblies, shapes, materials etc. + * to Geant4 with all volumes, assemblies, shapes, materials etc. * The actuak work is performed by the Geant4Converter class called by this method. * * \author M.Frank diff --git a/DDG4/include/DDG4/Geant4EventAction.h b/DDG4/include/DDG4/Geant4EventAction.h index f9866c3d797a465ea8203895ad3bdb08cca0a2f5..beff038651aa0df4d8395da5362c352ffaa1c7a3 100644 --- a/DDG4/include/DDG4/Geant4EventAction.h +++ b/DDG4/include/DDG4/Geant4EventAction.h @@ -53,9 +53,9 @@ namespace DD4hep { }; /// Concrete implementation of the Geant4 event action sequence - /** + /** * The sequence dispatches the callbacks at the beginning and the and - * of an event to all registered Geant4EventAction members and all + * of an event to all registered Geant4EventAction members and all * registered callbacks. * * \author M.Frank @@ -79,17 +79,17 @@ namespace DD4hep { virtual ~Geant4EventActionSequence(); /// Register begin-of-event callback template <typename Q, typename T> - void callAtBegin(Q* p, void (T::*f)(const G4Event*)) { + void callAtBegin(Q* p, void (T::*f)(const G4Event*)) { m_begin.add(p, f); } /// Register end-of-event callback template <typename Q, typename T> - void callAtEnd(Q* p, void (T::*f)(const G4Event*)) { + void callAtEnd(Q* p, void (T::*f)(const G4Event*)) { m_end.add(p, f); } /// Register event-cleanup callback (after end-of-event callback -- unordered) template <typename Q, typename T> - void callAtFinal(Q* p, void (T::*f)(const G4Event*)) { + void callAtFinal(Q* p, void (T::*f)(const G4Event*)) { m_final.add(p, f); } /// Add an actor responding to all callbacks. Sequence takes ownership. diff --git a/DDG4/include/DDG4/Geant4Field.h b/DDG4/include/DDG4/Geant4Field.h index 8ccca0149a9d3bd13f2288e629b77f50e8697962..62f220ea374f79bc390750c3776ecc145e5d5600 100644 --- a/DDG4/include/DDG4/Geant4Field.h +++ b/DDG4/include/DDG4/Geant4Field.h @@ -38,8 +38,8 @@ namespace DD4hep { public: /// Constructor. The sensitive detector element is identified by the detector name - Geant4Field(Geometry::OverlayedField field) - : m_field(field) { + Geant4Field(Geometry::OverlayedField field) + : m_field(field) { } /// Standard destructor virtual ~Geant4Field() { diff --git a/DDG4/include/DDG4/Geant4GeneratorAction.h b/DDG4/include/DDG4/Geant4GeneratorAction.h index b1fd2f9fe342d16ec5a6ec1f810649e63a2f1433..badff9f15f583e60ba1b8281a75ddf3437c80457 100644 --- a/DDG4/include/DDG4/Geant4GeneratorAction.h +++ b/DDG4/include/DDG4/Geant4GeneratorAction.h @@ -22,9 +22,9 @@ namespace DD4hep { namespace Simulation { /// Concrete implementation of the Geant4 generator action base class - /** + /** * The Geant4GeneratorAction is called for every event. - * During the callback all particles are created which form the + * During the callback all particles are created which form the * microscopic kinematic action of the particle collision. * This input may either origin directly from an event generator program * or come from file. @@ -49,9 +49,9 @@ namespace DD4hep { }; /// Concrete implementation of the Geant4 generator action sequence - /** - * The sequence dispatches the callbacks at the beginning - * of an event to all registered Geant4GeneratorAction members and all + /** + * The sequence dispatches the callbacks at the beginning + * of an event to all registered Geant4GeneratorAction members and all * registered callbacks. * * The callback signature is: void operator()(G4Event* event) @@ -73,7 +73,7 @@ namespace DD4hep { virtual ~Geant4GeneratorActionSequence(); /// Register primary particle generation callback. Types Q and T must be polymorph! template <typename Q, typename T> - void call(Q* p, void (T::*f)(G4Event*)) { + void call(Q* p, void (T::*f)(G4Event*)) { m_calls.add(p, f); } /// Add an actor responding to all callbacks. Sequence takes ownership. diff --git a/DDG4/include/DDG4/Geant4GeneratorActionInit.h b/DDG4/include/DDG4/Geant4GeneratorActionInit.h index 706c6b42b449d05c8f22451dfc69ffefb3895654..391460c9af3ebdc980ece4bde9b6f43f94dd5d21 100644 --- a/DDG4/include/DDG4/Geant4GeneratorActionInit.h +++ b/DDG4/include/DDG4/Geant4GeneratorActionInit.h @@ -25,15 +25,15 @@ namespace DD4hep { /// Initialize the Geant4Event objects to host generator and MC truth related information /** Geant4 actions to collect the MC particle information. * - * This action should register all event extension required for the further - * processing. We want to avoid that every client has to check if a given + * This action should register all event extension required for the further + * processing. We want to avoid that every client has to check if a given * object is present or not and than later install the required data structures. - * + * * These by default are extensions of type: * -- Geant4PrimaryEvent with multiple interaction sections, one for each interaction * This is the MAIN and ONLY information to feed Geant4 * - * -- Geant4PrimaryInteraction containing the track/vertex information to create + * -- Geant4PrimaryInteraction containing the track/vertex information to create * the primary particles for Geant4. This record is build from the Geant4PrimaryEvent * information. * -- Geant4PrimaryMap a map of the Geant4Particles converted to G4PrimaryParticles @@ -41,7 +41,7 @@ namespace DD4hep { * -- Geant4ParticleMap the map of particles created during the event simulation. * This map has directly the correct particle offsets, so that the merging of * Geant4PrimaryInteraction particles and the simulation particles is easy.... - * + * * \author M.Frank * \version 1.0 * \ingroup DD4HEP_SIMULATION diff --git a/DDG4/include/DDG4/Geant4Handle.h b/DDG4/include/DDG4/Geant4Handle.h index 513a8ee9e5e0b1ebf56dae5bd12ba40ce2773b05..df3693c142e3381dfbdce2b84a2f18a7b0bdf9f8 100644 --- a/DDG4/include/DDG4/Geant4Handle.h +++ b/DDG4/include/DDG4/Geant4Handle.h @@ -32,7 +32,7 @@ namespace DD4hep { * \author M.Frank * \version 1.0 * \ingroup DD4HEP_SIMULATION - */ + */ template <typename TYPE> class Geant4Handle { protected: void checked_assign(TYPE* p); @@ -42,7 +42,7 @@ namespace DD4hep { explicit Geant4Handle(); Geant4Handle(handled_type* typ); template <typename T> Geant4Handle(T* typ) - : value(0) { + : value(0) { checked_assign(dynamic_cast<handled_type*>(typ)); } Geant4Handle(const Geant4Handle& handle); @@ -63,7 +63,7 @@ namespace DD4hep { }; /// Handle to Geant4 actions with built-in creation mechanism - /** + /** * \author M.Frank * \version 1.0 * \ingroup DD4HEP_SIMULATION diff --git a/DDG4/include/DDG4/Geant4HitCollection.h b/DDG4/include/DDG4/Geant4HitCollection.h index c7fdb6a930fb16b797ac12c8261a985b3097576a..8672a718d0ecf80f545b8d60239958e662327641 100644 --- a/DDG4/include/DDG4/Geant4HitCollection.h +++ b/DDG4/include/DDG4/Geant4HitCollection.h @@ -105,18 +105,18 @@ namespace DD4hep { public: /// Default constructor - Geant4HitWrapper() : G4VHit() { + Geant4HitWrapper() : G4VHit() { m_data.second = manipulator<InvalidHit>(); m_data.first = 0; } /// Copy constructor - Geant4HitWrapper(const Geant4HitWrapper& v) : G4VHit() { + Geant4HitWrapper(const Geant4HitWrapper& v) : G4VHit() { m_data = v.m_data; v.m_data.first = 0; //v.release(); } /// Copy constructor - Geant4HitWrapper(const Wrapper& v) : G4VHit() { + Geant4HitWrapper(const Wrapper& v) : G4VHit() { m_data = v; } /// Default destructor @@ -147,18 +147,18 @@ namespace DD4hep { } /// Assignment transfers the pointer ownership Geant4HitWrapper& operator=(const Geant4HitWrapper& v) { - if ( this != & v ) { - m_data = v.m_data; - v.m_data.first = 0; - //v.release(); - } + if ( this != & v ) { + m_data = v.m_data; + v.m_data.first = 0; + //v.release(); + } return *this; } /// Automatic conversion to the desired type template <typename TYPE> operator TYPE*() const { return (TYPE*) m_data.second-> - cast.apply_dynCast(ComponentCast::instance<TYPE>(),m_data.first); - //cast.apply_downCast(ComponentCast::instance<TYPE>(),m_data.first); + cast.apply_dynCast(ComponentCast::instance<TYPE>(),m_data.first); + //cast.apply_downCast(ComponentCast::instance<TYPE>(),m_data.first); } }; @@ -192,8 +192,8 @@ namespace DD4hep { */ class Compare { public: - /// Default destructor - virtual ~Compare(); + /// Default destructor + virtual ~Compare(); /// Comparison function virtual void* operator()(const Geant4HitWrapper& w) const = 0; }; @@ -219,17 +219,17 @@ namespace DD4hep { public: /// Initializing constructor (C++ version) template <typename TYPE> - Geant4HitCollection(const std::string& det, const std::string& coll, Geant4Sensitive* sd) - : G4VHitsCollection(det, coll), m_detector(sd), - m_manipulator(Geant4HitWrapper::manipulator<TYPE>()) { + Geant4HitCollection(const std::string& det, const std::string& coll, Geant4Sensitive* sd) + : G4VHitsCollection(det, coll), m_detector(sd), + m_manipulator(Geant4HitWrapper::manipulator<TYPE>()) { newInstance(); m_hits.reserve(200); } /// Initializing constructor template <typename TYPE> - Geant4HitCollection(const std::string& det, const std::string& coll, Geant4Sensitive* sd, const TYPE*) - : G4VHitsCollection(det, coll), m_detector(sd), - m_manipulator(Geant4HitWrapper::manipulator<TYPE>()) { + Geant4HitCollection(const std::string& det, const std::string& coll, Geant4Sensitive* sd, const TYPE*) + : G4VHitsCollection(det, coll), m_detector(sd), + m_manipulator(Geant4HitWrapper::manipulator<TYPE>()) { newInstance(); m_hits.reserve(200); } @@ -243,11 +243,11 @@ namespace DD4hep { virtual void clear(); /// Set the sensitive detector void setSensitive(Geant4Sensitive* detector) { - m_detector = detector; + m_detector = detector; } /// Access the sensitive detector Geant4Sensitive* sensitive() const { - return m_detector; + return m_detector; } /// Access individual hits virtual G4VHit* GetHit(size_t which) const { @@ -310,12 +310,12 @@ namespace DD4hep { public: const POS& pos; /// Constructor - PositionCompare(const POS& p) : pos(p) { } + PositionCompare(const POS& p) : pos(p) { } /// Comparison function virtual void* operator()(const Geant4HitWrapper& w) const; }; - template <typename TYPE, typename POS> + template <typename TYPE, typename POS> void* PositionCompare<TYPE,POS>::operator()(const Geant4HitWrapper& w) const { TYPE* h = w; return pos == h->position ? h : 0; @@ -333,16 +333,16 @@ namespace DD4hep { public: long long int id; /// Constructor - CellIDCompare(long long int i) : id(i) { } + CellIDCompare(long long int i) : id(i) { } /// Comparison function. virtual void* operator()(const Geant4HitWrapper& w) const; }; - template <typename TYPE> + template <typename TYPE> void* CellIDCompare<TYPE>::operator()(const Geant4HitWrapper& w) const { TYPE* h = w; if ( id == h->cellID ) - return h; + return h; return 0; } diff --git a/DDG4/include/DDG4/Geant4Hits.h b/DDG4/include/DDG4/Geant4Hits.h index 451fd62269fecb50b124ee2ce2b01f270f153dc1..0e7449218d447c8d51fce4a3c675dd6387fa8c0c 100644 --- a/DDG4/include/DDG4/Geant4Hits.h +++ b/DDG4/include/DDG4/Geant4Hits.h @@ -52,8 +52,8 @@ namespace DD4hep { template <class HIT> struct HitPositionCompare: public HitCompare<HIT> { const Position& pos; /// Constructor - HitPositionCompare(const Position& p) - : pos(p) { + HitPositionCompare(const Position& p) + : pos(p) { } /// Default destructor virtual ~HitPositionCompare() {} @@ -89,39 +89,39 @@ namespace DD4hep { double deposit; /// Timestamp when this energy was deposited double time; - MonteCarloContrib() - : trackID(-1), pdgID(-1), deposit(0.0), time(0.0) { - } - MonteCarloContrib(int track_id, double dep, double time_stamp) - : trackID(track_id), pdgID(-1), deposit(dep), time(time_stamp) { - } - MonteCarloContrib(int track_id, int pdg, double dep, double time_stamp) - : trackID(track_id), pdgID(pdg), deposit(dep), time(time_stamp) { - } - MonteCarloContrib(const MonteCarloContrib& c) - : trackID(c.trackID), pdgID(c.pdgID), deposit(c.deposit), time(c.time) { - } - /// Assignment operator - MonteCarloContrib& operator=(const MonteCarloContrib& c) { - if ( this != &c ) { - trackID = c.trackID; - pdgID = c.pdgID; - deposit = c.deposit; - time = c.time; - } - return *this; - } - void clear() { - time = deposit = 0.0; - pdgID = trackID = -1; + MonteCarloContrib() + : trackID(-1), pdgID(-1), deposit(0.0), time(0.0) { + } + MonteCarloContrib(int track_id, double dep, double time_stamp) + : trackID(track_id), pdgID(-1), deposit(dep), time(time_stamp) { + } + MonteCarloContrib(int track_id, int pdg, double dep, double time_stamp) + : trackID(track_id), pdgID(pdg), deposit(dep), time(time_stamp) { + } + MonteCarloContrib(const MonteCarloContrib& c) + : trackID(c.trackID), pdgID(c.pdgID), deposit(c.deposit), time(c.time) { + } + /// Assignment operator + MonteCarloContrib& operator=(const MonteCarloContrib& c) { + if ( this != &c ) { + trackID = c.trackID; + pdgID = c.pdgID; + deposit = c.deposit; + time = c.time; + } + return *this; } + void clear() { + time = deposit = 0.0; + pdgID = trackID = -1; + } }; typedef MonteCarloContrib Contribution; typedef std::vector<MonteCarloContrib> Contributions; public: /// Standard constructor - Geant4Hit() : cellID(0) { + Geant4Hit() : cellID(0) { } /// Default destructor virtual ~Geant4Hit() { diff --git a/DDG4/include/DDG4/Geant4InputAction.h b/DDG4/include/DDG4/Geant4InputAction.h index ba4912828478ceb2d91ed835a9541a984a9f788a..a9f3c551c361216ff2ac7c78865fcdddb30274f9 100644 --- a/DDG4/include/DDG4/Geant4InputAction.h +++ b/DDG4/include/DDG4/Geant4InputAction.h @@ -25,7 +25,7 @@ namespace DD4hep { namespace Simulation { /// Basic geant4 event reader class. This interface/base-class must be implemented by concrete readers. - /** + /** * Base class to read input files containing simulation data. * * \author P.Kostka (main author) @@ -39,13 +39,13 @@ namespace DD4hep { typedef Geant4Particle Particle; typedef std::vector<Particle*> Particles; /// Status codes of the event reader object. Anything with NOT low-bit set is an error. - enum EventReaderStatus { - EVENT_READER_ERROR=0, - EVENT_READER_OK=1, - EVENT_READER_NO_DIRECT=2, - EVENT_READER_NO_PRIMARIES=4, - EVENT_READER_NO_FACTORY=6, - EVENT_READER_IO_ERROR=8 + enum EventReaderStatus { + EVENT_READER_ERROR=0, + EVENT_READER_OK=1, + EVENT_READER_NO_DIRECT=2, + EVENT_READER_NO_PRIMARIES=4, + EVENT_READER_NO_FACTORY=6, + EVENT_READER_IO_ERROR=8 }; protected: /// File name to be opened and read @@ -64,24 +64,24 @@ namespace DD4hep { /// Flag if direct event access (by event sequence number) is supported (Default: false) bool hasDirectAccess() const { return m_directAccess; } /// Move to the indicated event number. - /** For pure sequential access, the default implementation + /** For pure sequential access, the default implementation * will skip events one by one. * For technologies supporting direct event access the default * implementation will be empty. * - * @return + * @return */ virtual EventReaderStatus moveToEvent(int event_number); /// Skip event. To be implemented for sequential sources virtual EventReaderStatus skipEvent(); /// Read an event and fill a vector of MCParticles. - /** The additional argument + /** The additional argument */ virtual EventReaderStatus readParticles(int event_number, Particles& particles) = 0; }; /// Generic input action capable of using the Geant4EventReader class. - /** + /** * Concrete implementation of the Geant4 generator action base class * populating Geant4 primaries from Geant4 and HepStd files. * diff --git a/DDG4/include/DDG4/Geant4InputHandling.h b/DDG4/include/DDG4/Geant4InputHandling.h index 570b4688e3635848616190584050986d65c74dca..ba0e2019c848d249b87b33b3ea6e9d9ec9b13a70 100644 --- a/DDG4/include/DDG4/Geant4InputHandling.h +++ b/DDG4/include/DDG4/Geant4InputHandling.h @@ -32,19 +32,19 @@ namespace DD4hep { /// Boost particles of one interaction identified by its mask int boostInteraction(const Geant4Action* caller, - Geant4PrimaryEvent::Interaction* inter, - double alpha); + Geant4PrimaryEvent::Interaction* inter, + double alpha); /// Smear the primary vertex of an interaction int smearInteraction(const Geant4Action* caller, - Geant4PrimaryEvent::Interaction* inter, - double dx, double dy, double dz, double dt); + Geant4PrimaryEvent::Interaction* inter, + double dx, double dy, double dz, double dt); /// Generate all primary vertices corresponding to the merged interaction int generatePrimaries(const Geant4Action* caller, - const Geant4Context* context, - G4Event* event); + const Geant4Context* context, + G4Event* event); } // End namespace Simulation } // End namespace DD4hep diff --git a/DDG4/include/DDG4/Geant4InteractionVertexSmear.h b/DDG4/include/DDG4/Geant4InteractionVertexSmear.h index c95940db2f9e446fb080dfad57a650159b328170..ed61f8938581ce1394d324ea68e6ac7126fe7f5c 100644 --- a/DDG4/include/DDG4/Geant4InteractionVertexSmear.h +++ b/DDG4/include/DDG4/Geant4InteractionVertexSmear.h @@ -36,7 +36,7 @@ namespace DD4hep { /// Property: The constant smearing offset ROOT::Math::PxPyPzEVector m_offset; /// Property: The gaussian sigmas to the offset - ROOT::Math::PxPyPzEVector m_sigma; + ROOT::Math::PxPyPzEVector m_sigma; /// Property: Unique identifier of the interaction created int m_mask; public: diff --git a/DDG4/include/DDG4/Geant4Output2ROOT.h b/DDG4/include/DDG4/Geant4Output2ROOT.h index e233f7aa87f3d373edb5a5d3a77f0426dfd4af0c..a901d0a0859b186ffd0ebc54f33e659fefac4da3 100644 --- a/DDG4/include/DDG4/Geant4Output2ROOT.h +++ b/DDG4/include/DDG4/Geant4Output2ROOT.h @@ -23,7 +23,7 @@ namespace DD4hep { /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit namespace Simulation { - + /// Class to output Geant4 event data to ROOT files /** * \author M.Frank diff --git a/DDG4/include/DDG4/Geant4OutputAction.h b/DDG4/include/DDG4/Geant4OutputAction.h index 394a194345f4fa41e35b4d253d09cb6bb0207d9e..82f20d5892f42746642a72e4a6e5656a3985d2f7 100644 --- a/DDG4/include/DDG4/Geant4OutputAction.h +++ b/DDG4/include/DDG4/Geant4OutputAction.h @@ -37,8 +37,8 @@ namespace DD4hep { public: const T* context; void* userData; - OutputContext(const T* c) - : context(c), userData(0) { + OutputContext(const T* c) + : context(c), userData(0) { } template <typename U> U* data() const { return (U*) userData; diff --git a/DDG4/include/DDG4/Geant4Particle.h b/DDG4/include/DDG4/Geant4Particle.h index 7511a3d8c54e58b6efde4a3349ae43d8e9ac0e34..bf4c030fbb7d744385aebea77cd757eabf8845b9 100644 --- a/DDG4/include/DDG4/Geant4Particle.h +++ b/DDG4/include/DDG4/Geant4Particle.h @@ -43,12 +43,12 @@ namespace DD4hep { /// Default constructor ParticleExtension() {} /// Default destructor - virtual ~ParticleExtension(); + virtual ~ParticleExtension(); }; /// Track properties enum Geant4ParticleProperties { - G4PARTICLE_CREATED_HIT = 1<<1, + G4PARTICLE_CREATED_HIT = 1<<1, G4PARTICLE_PRIMARY = 1<<2, G4PARTICLE_HAS_SECONDARIES = 1<<3, G4PARTICLE_ABOVE_ENERGY_THRESHOLD = 1<<4, @@ -68,7 +68,7 @@ namespace DD4hep { G4PARTICLE_GEN_GENERATOR = // Particle comes from generator ( G4PARTICLE_GEN_EMPTY+G4PARTICLE_GEN_STABLE+ - G4PARTICLE_GEN_DECAYED+G4PARTICLE_GEN_DOCUMENTATION ), + G4PARTICLE_GEN_DECAYED+G4PARTICLE_GEN_DOCUMENTATION ), G4PARTICLE_GEN_STATUS = 0x3FF, // Mask for generator status (bit 0...9) // Simulation status of a given particle @@ -86,7 +86,7 @@ namespace DD4hep { - /// Data structure to store the MC particle information + /// Data structure to store the MC particle information /** * \author M.Frank * \version 1.0 @@ -116,7 +116,7 @@ namespace DD4hep { Particles daughters; /// User data extension if required - std::auto_ptr<ParticleExtension> extension; + std::auto_ptr<ParticleExtension> extension; const G4VProcess *process; //! not persistent //const G4ParticleDefinition *definition; //! not persistent /// Default constructor @@ -127,8 +127,8 @@ namespace DD4hep { virtual ~Geant4Particle(); /// Increase reference count Geant4Particle* addRef() { - ++ref; - return this; + ++ref; + return this; } /// Decrease reference count. Deletes object if NULL void release(); @@ -140,7 +140,7 @@ namespace DD4hep { #ifndef __DDG4_STANDALONE_DICTIONARIES__ - /// Data structure to access derived MC particle information + /// Data structure to access derived MC particle information /** * \author M.Frank * \version 1.0 @@ -152,7 +152,7 @@ namespace DD4hep { typedef ROOT::Math::Cartesian3D<double> ThreeVector; protected: /// Particle pointer - Geant4Particle* particle; + Geant4Particle* particle; public: /// Default constructor Geant4ParticleHandle(Geant4Particle* part); @@ -230,7 +230,7 @@ namespace DD4hep { return particle; } /// Assignment operator - inline Geant4ParticleHandle& Geant4ParticleHandle::operator=(Geant4Particle* part) { + inline Geant4ParticleHandle& Geant4ParticleHandle::operator=(Geant4Particle* part) { particle = part; return *this; } @@ -270,7 +270,7 @@ namespace DD4hep { ROOT::Math::PxPyPzM4D<double> v(p->psx,p->psy,p->psz,p->mass); return v.E(); } - + /// Scalar particle momentum squared inline double Geant4ParticleHandle::momentum2() const { const Geant4Particle* p = particle; @@ -286,7 +286,7 @@ namespace DD4hep { * - At the end of the handling of the MC truth are particles to be kept * are inserted if the required modules are activated such as the * Geant4ParticleHandler. - * + * * Note: This object takes OWNERSHIP of the inserted particles! * beware of double deletion of objects! * diff --git a/DDG4/include/DDG4/Geant4ParticleGun.h b/DDG4/include/DDG4/Geant4ParticleGun.h index 0e620e86c7281cdfb71d02582bcc12ecf25469dc..f051c0fb0f8555b28ca89a21f273900a62c2b769 100644 --- a/DDG4/include/DDG4/Geant4ParticleGun.h +++ b/DDG4/include/DDG4/Geant4ParticleGun.h @@ -22,26 +22,26 @@ namespace DD4hep { namespace Simulation { /// Implementation of a particle gun using Geant4Particles. - /** + /** * The {\tt{Geant4ParticleGun}} is a tool to shoot a number of * particles with identical properties into a given region of the * detector to be simulated. * - * The particle gun is a input source like any other and participates - * in the general input stage merging process like any other input + * The particle gun is a input source like any other and participates + * in the general input stage merging process like any other input * e.g. from file. Hence, there may be several particle guns present * each generating it's own primary vertex. Use the mask property to * ensure each gun generates it's own, well identified primary vertex. * * There is one 'user lazyness' support though: - * If there is only one particle gun in use, the property 'Standalone', - * which by default is set to true invokes the interaction merging and he + * If there is only one particle gun in use, the property 'Standalone', + * which by default is set to true invokes the interaction merging and he * Geant4 primary generation directly. * * \author M.Frank * \version 1.0 * \ingroup DD4HEP_SIMULATION - */ + */ class Geant4ParticleGun: public Geant4GeneratorAction { protected: /// Property: Position and shooting direction of the gun diff --git a/DDG4/include/DDG4/Geant4ParticleHandler.h b/DDG4/include/DDG4/Geant4ParticleHandler.h index 9844eb836a1229992cdf6a80b5f3de066e767281..63ab9eb3f17004fd2b87af396278e60d84b85341 100644 --- a/DDG4/include/DDG4/Geant4ParticleHandler.h +++ b/DDG4/include/DDG4/Geant4ParticleHandler.h @@ -34,16 +34,16 @@ namespace DD4hep { * Extract the relevant particle information during the simulation step. * * This procedure works as follows: - * -- At the beginning of the event generation the object registers itself as + * -- At the beginning of the event generation the object registers itself as * Monte-Carlo truth handler to the event context. * -- At the begin of each track action a particle candidate is created and filled * with all properties known at this time. * -- At each stepping action a flag is set if the step produced secondaries. * -- Sensitive detectors call the MC truth handler if a hit was created. * This fact is remembered. - * -- At the end of the tracking action a first decision is taken if the candidate is to be + * -- At the end of the tracking action a first decision is taken if the candidate is to be * kept for the final record. - * -- At the end of the event action finally all particles are reduced to the + * -- At the end of the event action finally all particles are reduced to the * final record. This logic can be overridden by a user handler to be attached. * . * Any of these actions may be intercepted by a {\tt{Geant4UserParticleHandler}} @@ -73,7 +73,7 @@ namespace DD4hep { typedef std::vector<std::string> Processes; protected: - + /// Property: Steer printout at tracking action begin bool m_printStartTracking; /// Property: Steer printout at tracking action end @@ -91,7 +91,7 @@ namespace DD4hep { Geant4UserParticleHandler* m_userHandler; /// Primary map Geant4PrimaryMap* m_primaryMap; - /// Local buffer about the 'current' G4Track + /// Local buffer about the 'current' G4Track Particle m_currTrack; /// Map with stored MC Particles ParticleMap m_particleMap; @@ -131,7 +131,7 @@ namespace DD4hep { virtual void begin(const G4Track* track); /// Post-track action callback virtual void end(const G4Track* track); - + /// Mark a Geant4 track to be kept for later MC truth analysis. Default flag: CREATED_HIT virtual void mark(const G4Track* track); /// Store a track diff --git a/DDG4/include/DDG4/Geant4ParticlePrint.h b/DDG4/include/DDG4/Geant4ParticlePrint.h index c4df649cdf7c8d4f7bab031598704905f8587be7..7cdc2ea3f7ae6709c82df8b5f3add2bda874302b 100644 --- a/DDG4/include/DDG4/Geant4ParticlePrint.h +++ b/DDG4/include/DDG4/Geant4ParticlePrint.h @@ -30,7 +30,7 @@ namespace DD4hep { * \version 1.0 * \ingroup DD4HEP_SIMULATION */ - class Geant4ParticlePrint : public Geant4EventAction { + class Geant4ParticlePrint : public Geant4EventAction { public: typedef Geant4ParticleMap::Particle Particle; typedef Geant4ParticleMap::ParticleMap ParticleMap; @@ -69,7 +69,7 @@ namespace DD4hep { virtual void end(const G4Event* event); /// Generation action callback virtual void operator()(G4Event* event); - + }; } // End namespace Simulation } // End namespace DD4hep diff --git a/DDG4/include/DDG4/Geant4PhysicsList.h b/DDG4/include/DDG4/Geant4PhysicsList.h index 7bc408f9b5adeb85dd66f1fa707d2a2678143b52..66f7df440c956ace104c834b61880e4b66ab834d 100644 --- a/DDG4/include/DDG4/Geant4PhysicsList.h +++ b/DDG4/include/DDG4/Geant4PhysicsList.h @@ -80,14 +80,14 @@ namespace DD4hep { class ParticleConstructor: public std::string { public: /// Default constructor - ParticleConstructor() - : std::string() { + ParticleConstructor() + : std::string() { } - /// Initalizing constructor - ParticleConstructor(const std::string& s) - : std::string(s) { + /// Initalizing constructor + ParticleConstructor(const std::string& s) + : std::string(s) { } - /// Default destructor + /// Default destructor ~ParticleConstructor() { } }; @@ -99,17 +99,17 @@ namespace DD4hep { * \version 1.0 * \ingroup DD4HEP_SIMULATION */ - class PhysicsConstructor: public std::string { + class PhysicsConstructor: public std::string { public: /// Default constructor - PhysicsConstructor() - : std::string() { + PhysicsConstructor() + : std::string() { } - /// Initalizing constructor - PhysicsConstructor(const std::string& s) - : std::string(s) { + /// Initalizing constructor + PhysicsConstructor(const std::string& s) + : std::string(s) { } - /// Default destructor + /// Default destructor ~PhysicsConstructor() { } }; @@ -161,7 +161,7 @@ namespace DD4hep { void addParticleConstructor(const std::string& part_name); /// Add particle process by name with arguments void addParticleProcess(const std::string& part_name, const std::string& proc_name, - int ordAtRestDoIt,int ordAlongSteptDoIt,int ordPostStepDoIt); + int ordAtRestDoIt,int ordAlongSteptDoIt,int ordPostStepDoIt); /// Add PhysicsConstructor by name void addPhysicsConstructor(const std::string& physics_name); @@ -177,7 +177,7 @@ namespace DD4hep { }; /// The implementation of the single Geant4 physics list action sequence - /** + /** * Concrete implementation of the Geant4 physics list sequence. * A list to setup the physics content in a modular form * @@ -225,12 +225,12 @@ namespace DD4hep { } /// Register process construction callback template <typename Q, typename T> - void constructProcess(Q* p, void (T::*f)(Geant4UserPhysics*)) { + void constructProcess(Q* p, void (T::*f)(Geant4UserPhysics*)) { m_process.add(p, f); } /// Register particle construction callback template <typename Q, typename T> - void constructParticle(Q* p, void (T::*f)(Geant4UserPhysics*)) { + void constructParticle(Q* p, void (T::*f)(Geant4UserPhysics*)) { m_particle.add(p, f); } /// Add an actor responding to all callbacks. Sequence takes ownership. diff --git a/DDG4/include/DDG4/Geant4Primary.h b/DDG4/include/DDG4/Geant4Primary.h index 56d7f3ca6e4de5e12845b87232b4a36dc62bde6d..416aa453942d7c7105706db945032366bd7fb900 100644 --- a/DDG4/include/DDG4/Geant4Primary.h +++ b/DDG4/include/DDG4/Geant4Primary.h @@ -31,7 +31,7 @@ namespace DD4hep { // Forward declarations class Geant4Particle; class Geant4Vertex; - + /// Base structure to extend primary information with user data /** * \author M.Frank @@ -43,7 +43,7 @@ namespace DD4hep { /// Default constructor PrimaryExtension() {} /// Default destructor - virtual ~PrimaryExtension(); + virtual ~PrimaryExtension(); }; /// Data structure to map primaries to particles. @@ -65,7 +65,7 @@ namespace DD4hep { /// Default destructor virtual ~Geant4PrimaryMap(); }; - + /// Class modelling a single interaction with multiple primary vertices and particles /* diff --git a/DDG4/include/DDG4/Geant4PrimaryHandler.h b/DDG4/include/DDG4/Geant4PrimaryHandler.h index 202e12327903c150903d39a78a9aef8587672354..1e6f325eb34ecbf69f42d5caee1796964a191275 100644 --- a/DDG4/include/DDG4/Geant4PrimaryHandler.h +++ b/DDG4/include/DDG4/Geant4PrimaryHandler.h @@ -19,7 +19,7 @@ namespace DD4hep { namespace Simulation { /// Geant4Action to convert the particle information to Geant4 - /** Convert the primary interaction (object \tt{Geant4PrimaryInteraction} object + /** Convert the primary interaction (object \tt{Geant4PrimaryInteraction} object * attached to the \tt{Geant4Event} event context) and pass the result * to Geant4 for simulation. * diff --git a/DDG4/include/DDG4/Geant4Random.h b/DDG4/include/DDG4/Geant4Random.h index 027458bb9e885c0888eb22f8a35ab11fb33e9ab6..d449bd0849adb7d72665916c5bffb0e88500cd3c 100644 --- a/DDG4/include/DDG4/Geant4Random.h +++ b/DDG4/include/DDG4/Geant4Random.h @@ -29,10 +29,10 @@ namespace DD4hep { * the main instance avaible throu the Geant4Context. * * This is mandatory to ensure reproducability of the event generation - * process. Particular objects may use a dependent generator from + * process. Particular objects may use a dependent generator from * an experiment framework like GAUDI. * - * This main interface is supposed to be stable. Unclear however is + * This main interface is supposed to be stable. Unclear however is * if the generation functions will have to become virtual.... * Future will tell us. * @@ -60,7 +60,7 @@ namespace DD4hep { double uniform(double x1=1); double uniform(double x1, double x2); }; - + } // End namespace Simulation } // End namespace DD4hep #endif // DD4HEP_GEANT4RANDOM_H diff --git a/DDG4/include/DDG4/Geant4RunAction.h b/DDG4/include/DDG4/Geant4RunAction.h index d7a624b87e27a89482660ccec5c8964602d245d7..35e3b50214ee6f48c9397223ae1bc319465d10c2 100644 --- a/DDG4/include/DDG4/Geant4RunAction.h +++ b/DDG4/include/DDG4/Geant4RunAction.h @@ -23,7 +23,7 @@ namespace DD4hep { /// Concrete basic implementation of the Geant4 run action base class. /** - * The Run Action is called once per start and end of a run. + * The Run Action is called once per start and end of a run. * i.e. a series of generated events. These two callbacks * allow clients to define run-dependent actions such as statistics * summaries etc. @@ -48,7 +48,7 @@ namespace DD4hep { /** * Concrete implementation of the Geant4 run action sequence. * The sequence dispatches the callbacks at the beginning and the and - * of a run to all registered Geant4RunAction members and all + * of a run to all registered Geant4RunAction members and all * registered callbacks. * * \author M.Frank @@ -70,12 +70,12 @@ namespace DD4hep { virtual ~Geant4RunActionSequence(); /// Register begin-of-run callback. Types Q and T must be polymorph! template <typename Q, typename T> - void callAtBegin(Q* p, void (T::*f)(const G4Run*)) { + void callAtBegin(Q* p, void (T::*f)(const G4Run*)) { m_begin.add(p, f); } /// Register end-of-run callback. Types Q and T must be polymorph! template <typename Q, typename T> - void callAtEnd(Q* p, void (T::*f)(const G4Run*)) { + void callAtEnd(Q* p, void (T::*f)(const G4Run*)) { m_end.add(p, f); } /// Add an actor responding to all callbacks. Sequence takes ownership. diff --git a/DDG4/include/DDG4/Geant4SensDetAction.h b/DDG4/include/DDG4/Geant4SensDetAction.h index 829896e5371e8f4dc17b2145580ff40d7a3d6105..2f26b4be6c8554f227650a71393bb48cbc515e2e 100644 --- a/DDG4/include/DDG4/Geant4SensDetAction.h +++ b/DDG4/include/DDG4/Geant4SensDetAction.h @@ -46,7 +46,7 @@ namespace DD4hep { class Geant4SensDetSequences; /// Interface class to access properties of the underlying Geant4 sensitive detector structure - /** + /** * \author M.Frank * \version 1.0 * \ingroup DD4HEP_SIMULATION @@ -113,11 +113,11 @@ namespace DD4hep { typedef Geant4StepHandler StepHandler; typedef Geant4HitCollection HitCollection; - enum HitCreationFlags { - SIMPLE_MODE = 0, - MEDIUM_MODE = 1<<0, - DETAILED_MODE = 1<<1 - }; + enum HitCreationFlags { + SIMPLE_MODE = 0, + MEDIUM_MODE = 1<<0, + DETAILED_MODE = 1<<1 + }; private: /// Reference to G4 sensitive detector @@ -156,7 +156,7 @@ namespace DD4hep { /// Property access to the hit creation mode int hitCreationMode() const { - return m_hitCreationMode; + return m_hitCreationMode; } /// G4VSensitiveDetector internals: Access to the detector name @@ -181,7 +181,7 @@ namespace DD4hep { /// Access the DD4hep sensitive detector SensitiveDetector sensitiveDetector() const { - return m_sensitive; + return m_sensitive; } /// Access to the readout geometry of the sensitive detector @@ -266,7 +266,7 @@ namespace DD4hep { */ class Geant4SensDetActionSequence: public Geant4Action { public: - + typedef Geometry::SensitiveDetector SensitiveDetector; typedef Geant4HitCollection* (*create_t)(const std::string&, const std::string&, Geant4Sensitive*); typedef std::pair<std::string, std::pair<Geant4Sensitive*,create_t> > HitCollection; @@ -310,7 +310,7 @@ namespace DD4hep { /// Access to the sensitive type of the detector virtual const std::string& sensitiveType() const { - return m_sensitiveType; + return m_sensitiveType; } /// Called at construction time of the sensitive detector to declare all hit collections @@ -452,10 +452,10 @@ namespace DD4hep { UserData m_userData; public: /// Standard , initializing constructor - Geant4SensitiveAction(Geant4Context* context, - const std::string& name, - Geometry::DetElement det, - Geometry::LCDD& lcdd); + Geant4SensitiveAction(Geant4Context* context, + const std::string& name, + Geometry::DetElement det, + Geometry::LCDD& lcdd); /// Default destructor virtual ~Geant4SensitiveAction(); /// Initialization overload for specialization @@ -464,9 +464,9 @@ namespace DD4hep { void finalize(); /// Define collections created by this sensitivie action object virtual void defineCollections() {} - /// G4VSensitiveDetector interface: Method invoked at the begining of each event. + /// G4VSensitiveDetector interface: Method invoked at the begining of each event. virtual void begin(G4HCofThisEvent* hce); - /// G4VSensitiveDetector interface: Method invoked at the end of each event. + /// G4VSensitiveDetector interface: Method invoked at the end of each event. virtual void end(G4HCofThisEvent* hce); /// G4VSensitiveDetector interface: Method for generating hit(s) using the G4Step object. virtual bool process(G4Step* step,G4TouchableHistory* history); diff --git a/DDG4/include/DDG4/Geant4SensDetAction.inl b/DDG4/include/DDG4/Geant4SensDetAction.inl index 16a8798c395be98a3c4e0b4146cea95304dd907d..ae979100cbb7d79e8c71072488dd2c57007eac14 100644 --- a/DDG4/include/DDG4/Geant4SensDetAction.inl +++ b/DDG4/include/DDG4/Geant4SensDetAction.inl @@ -1,76 +1,76 @@ -// $Id: $ -//==================================================================== -// AIDA Detector description implementation for LCD -//-------------------------------------------------------------------- -// -// Author : M.Frank -// -//==================================================================== + // $Id: $ + //==================================================================== + // AIDA Detector description implementation for LCD + //-------------------------------------------------------------------- + // + // Author : M.Frank + // + //==================================================================== -// Framework include files -#ifndef DD4HEP_DDG4_GEANT4SENSDETACTION_H -#include "DDG4/Geant4SensDetAction.h" -#endif -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4Data.h" + // Framework include files + #ifndef DD4HEP_DDG4_GEANT4SENSDETACTION_H + #include "DDG4/Geant4SensDetAction.h" + #endif + #include "DD4hep/InstanceCount.h" + #include "DDG4/Geant4Data.h" -namespace DD4hep { - namespace Simulation { + namespace DD4hep { + namespace Simulation { - /// Standard , initializing constructor - template <typename T> - Geant4SensitiveAction<T>::Geant4SensitiveAction(Geant4Context* context, - const std::string& name, - Geometry::DetElement det, - Geometry::LCDD& lcdd) - : Geant4Sensitive(context,name,det,lcdd), m_collectionID(0) - { - initialize(); - defineCollections(); - InstanceCount::increment(this); - } + /// Standard , initializing constructor + template <typename T> + Geant4SensitiveAction<T>::Geant4SensitiveAction(Geant4Context* context, + const std::string& name, + Geometry::DetElement det, + Geometry::LCDD& lcdd) + : Geant4Sensitive(context,name,det,lcdd), m_collectionID(0) + { + initialize(); + defineCollections(); + InstanceCount::increment(this); + } - /// Default destructor - template <typename T> Geant4SensitiveAction<T>::~Geant4SensitiveAction() { - finalize(); - InstanceCount::decrement(this); - } + /// Default destructor + template <typename T> Geant4SensitiveAction<T>::~Geant4SensitiveAction() { + finalize(); + InstanceCount::decrement(this); + } - /// Initialization overload for specialization - template <typename T> void Geant4SensitiveAction<T>::initialize() { - } + /// Initialization overload for specialization + template <typename T> void Geant4SensitiveAction<T>::initialize() { + } - /// Finalization overload for specialization - template <typename T> void Geant4SensitiveAction<T>::finalize() { - } + /// Finalization overload for specialization + template <typename T> void Geant4SensitiveAction<T>::finalize() { + } - /// G4VSensitiveDetector interface: Method invoked at the begining of each event. - template <typename T> void Geant4SensitiveAction<T>::begin(G4HCofThisEvent* hce) { - Geant4Sensitive::begin(hce); - } + /// G4VSensitiveDetector interface: Method invoked at the begining of each event. + template <typename T> void Geant4SensitiveAction<T>::begin(G4HCofThisEvent* hce) { + Geant4Sensitive::begin(hce); + } - /// G4VSensitiveDetector interface: Method invoked at the end of each event. - template <typename T> void Geant4SensitiveAction<T>::end(G4HCofThisEvent* hce) { - Geant4Sensitive::end(hce); - } + /// G4VSensitiveDetector interface: Method invoked at the end of each event. + template <typename T> void Geant4SensitiveAction<T>::end(G4HCofThisEvent* hce) { + Geant4Sensitive::end(hce); + } - /// G4VSensitiveDetector interface: Method for generating hit(s) using the G4Step object. - template <typename T> bool Geant4SensitiveAction<T>::process(G4Step* step,G4TouchableHistory* history) { - return Geant4Sensitive::process(step,history); - } + /// G4VSensitiveDetector interface: Method for generating hit(s) using the G4Step object. + template <typename T> bool Geant4SensitiveAction<T>::process(G4Step* step,G4TouchableHistory* history) { + return Geant4Sensitive::process(step,history); + } - /// G4VSensitiveDetector interface: Method invoked if the event was aborted. - template <typename T> void Geant4SensitiveAction<T>::clear(G4HCofThisEvent* hce) { - Geant4Sensitive::clear(hce); - } + /// G4VSensitiveDetector interface: Method invoked if the event was aborted. + template <typename T> void Geant4SensitiveAction<T>::clear(G4HCofThisEvent* hce) { + Geant4Sensitive::clear(hce); + } - // Forward declarations - typedef Geant4HitData::Contribution HitContribution; - } -} + // Forward declarations + typedef Geant4HitData::Contribution HitContribution; + } + } -#include "DD4hep/Printout.h" -#include "DDG4/Geant4TouchableHandler.h" -#include "DDG4/Geant4StepHandler.h" -#include "DDG4/Geant4VolumeManager.h" + #include "DD4hep/Printout.h" + #include "DDG4/Geant4TouchableHandler.h" + #include "DDG4/Geant4StepHandler.h" + #include "DDG4/Geant4VolumeManager.h" diff --git a/DDG4/include/DDG4/Geant4SensitiveDetector.h b/DDG4/include/DDG4/Geant4SensitiveDetector.h index dc475ae915d6fb03e4cdf22b249ddb42f3caaef1..04d1825f260299663ee094a949cf90b66ebbd7b8 100644 --- a/DDG4/include/DDG4/Geant4SensitiveDetector.h +++ b/DDG4/include/DDG4/Geant4SensitiveDetector.h @@ -35,12 +35,12 @@ namespace DD4hep { /// Deprecated: Example G4VSensitiveDetector implementation. /** \deprecated * Deprecated class. Not supported by the DDG4 kernel. - * + * * @author M.Frank * @version 1.0 */ class Geant4SensitiveDetector : public G4VSensitiveDetector { - public: + public: typedef Geometry::SensitiveDetector SensitiveDetector; typedef G4THitsCollection<Geant4Hit> HitCollection; typedef Geant4Hit::Contribution HitContribution; @@ -101,13 +101,13 @@ namespace DD4hep { // from the current sensitive volume to the world volume long long getVolumeID(G4Step* step ) ; - /** G4VSensitiveDetector interface: Method invoked at the begining of each event. + /** G4VSensitiveDetector interface: Method invoked at the begining of each event. * The hits collection(s) created by this sensitive detector must * be set to the G4HCofThisEvent object at one of these two methods. */ virtual void Initialize(G4HCofThisEvent* HCE); - /// G4VSensitiveDetector interface: Method invoked at the end of each event. + /// G4VSensitiveDetector interface: Method invoked at the end of each event. virtual void EndOfEvent(G4HCofThisEvent* HCE); /// G4VSensitiveDetector interface: Method for generating hit(s) using the information of G4Step object. @@ -117,9 +117,9 @@ namespace DD4hep { virtual G4bool process(G4Step* step,G4TouchableHistory* history); /// G4VSensitiveDetector interface: Method invoked if the event was aborted. - /** Hits collections created but not beibg set to G4HCofThisEvent + /** Hits collections created but not beibg set to G4HCofThisEvent * at the event should be deleted. - * Collection(s) which have already set to G4HCofThisEvent + * Collection(s) which have already set to G4HCofThisEvent * will be deleted automatically. */ virtual void clear(); @@ -135,26 +135,26 @@ namespace DD4hep { public: /// Constructor. The sensitive detector element is identified by the detector name Geant4GenericSD(const std::string& name, LCDD& lcdd); - + /// Initialize the sensitive detector for the usage of a single hit collection virtual bool defineCollection(const std::string& coll_name); /// Method for generating hit(s) using the information of G4Step object. virtual G4bool ProcessHits(G4Step* step,G4TouchableHistory* history); - /** Method invoked at the begining of each event. + /** Method invoked at the begining of each event. * The hits collection(s) created by this sensitive detector must * be set to the G4HCofThisEvent object at one of these two methods. */ virtual void Initialize(G4HCofThisEvent* HCE); - /// Method invoked at the end of each event. + /// Method invoked at the end of each event. virtual void EndOfEvent(G4HCofThisEvent* HCE); /// This method is invoked if the event abortion is occured. - /** Hits collections created but not beibg set to G4HCofThisEvent + /** Hits collections created but not beibg set to G4HCofThisEvent * at the event should be deleted. - * Collection(s) which have already set to G4HCofThisEvent + * Collection(s) which have already set to G4HCofThisEvent * will be deleted automatically. */ virtual void clear(); diff --git a/DDG4/include/DDG4/Geant4SensitiveDetector_inline.h b/DDG4/include/DDG4/Geant4SensitiveDetector_inline.h index 9a5940eefc2a4dfb1513743d7ca747fb4905c1a2..a8bbf2141e65257e7ef9f77d34dccb0c7e883598 100644 --- a/DDG4/include/DDG4/Geant4SensitiveDetector_inline.h +++ b/DDG4/include/DDG4/Geant4SensitiveDetector_inline.h @@ -14,7 +14,7 @@ /// Constructor. The sensitive detector element is identified by the detector name template <class SD> DD4hep::Simulation::Geant4GenericSD<SD>::Geant4GenericSD(const std::string& name, LCDD& lcdd) - : Geant4SensitiveDetector(name, lcdd) { +: Geant4SensitiveDetector(name, lcdd) { defineCollection(m_sensitive.hitsCollection()); } diff --git a/DDG4/include/DDG4/Geant4StackingAction.h b/DDG4/include/DDG4/Geant4StackingAction.h index b08bad4ba400a2a439a5d4f34fb80e0270373be1..5066c4f217741040159fffbaf414f9a3484e5d7a 100644 --- a/DDG4/include/DDG4/Geant4StackingAction.h +++ b/DDG4/include/DDG4/Geant4StackingAction.h @@ -41,7 +41,7 @@ namespace DD4hep { /// Concrete implementation of the Geant4 stacking action sequence /** * The sequence dispatches the callbacks for each stepping action - * to all registered Geant4StackingAction members and all + * to all registered Geant4StackingAction members and all * registered callbacks. * * \author M.Frank diff --git a/DDG4/include/DDG4/Geant4StepHandler.h b/DDG4/include/DDG4/Geant4StepHandler.h index 85ad64586db475091c83fb1cf5ed799620833f29..6d47a0f8b1c91b97945a9c621a0790ee7e48ab1d 100644 --- a/DDG4/include/DDG4/Geant4StepHandler.h +++ b/DDG4/include/DDG4/Geant4StepHandler.h @@ -44,8 +44,8 @@ namespace DD4hep { G4StepPoint* pre; G4StepPoint* post; G4Track* track; - Geant4StepHandler(const G4Step* s) - : step(s) { + Geant4StepHandler(const G4Step* s) + : step(s) { pre = s->GetPreStepPoint(); post = s->GetPostStepPoint(); track = s->GetTrack(); @@ -64,7 +64,7 @@ namespace DD4hep { const char* postStepStatus() const; /// Returns total energy deposit double totalEnergy() const { - return step->GetTotalEnergyDeposit(); + return step->GetTotalEnergyDeposit(); } /// Returns the pre-step position Position prePos() const { @@ -87,21 +87,21 @@ namespace DD4hep { /// Average position vector of the step. Position avgPosition() const { const G4ThreeVector& p1 = pre->GetPosition(); - const G4ThreeVector& p2 = post->GetPosition(); - G4ThreeVector r = 0.5*(p2+p1); - return Position(r.x(),r.y(),r.z()); + const G4ThreeVector& p2 = post->GetPosition(); + G4ThreeVector r = 0.5*(p2+p1); + return Position(r.x(),r.y(),r.z()); } /// Direction calculated from the post- and pre-position ofthe step Position direction() const { const G4ThreeVector& p1 = pre->GetPosition(); - const G4ThreeVector& p2 = post->GetPosition(); - G4ThreeVector r = (p2-p1); - double len = r.r(); - if ( len > 1e-15 ) { - r /= len; - return Position(r.x(),r.y(),r.z()); - } - return Position(); + const G4ThreeVector& p2 = post->GetPosition(); + G4ThreeVector r = (p2-p1); + double len = r.r(); + if ( len > 1e-15 ) { + r /= len; + return Position(r.x(),r.y(),r.z()); + } + return Position(); } Momentum preMom() const { const G4ThreeVector& p = pre->GetMomentum(); @@ -116,19 +116,19 @@ namespace DD4hep { return Momentum(p.x(), p.y(), p.z()); } double deposit() const { - return step->GetTotalEnergyDeposit(); + return step->GetTotalEnergyDeposit(); } int trkID() const { - return track->GetTrackID(); + return track->GetTrackID(); } double trkTime() const { - return track->GetGlobalTime(); + return track->GetGlobalTime(); } double trkEnergy() const { - return track->GetTotalEnergy(); + return track->GetTotalEnergy(); } double trkKineEnergy() const { - return track->GetKineticEnergy(); + return track->GetKineticEnergy(); } const G4VTouchable* preTouchable() const { return pre->GetTouchable(); @@ -180,15 +180,15 @@ namespace DD4hep { return sd(post); } bool firstInVolume() const { - return step->IsFirstStepInVolume(); + return step->IsFirstStepInVolume(); } bool lastInVolume() const { - return step->IsLastStepInVolume(); + return step->IsLastStepInVolume(); } - /// Coordinate transformation to global coordinates. + /// Coordinate transformation to global coordinates. /** Note: Positions are in units of MM! */ Position localToGlobal(const Position& local) const; - /// Coordinate transformation to global coordinates. + /// Coordinate transformation to global coordinates. /** Note: DDSegmentation points are units in CM! Conversion done inside! */ Position localToGlobal(const DDSegmentation::Vector3D& local) const; /// Coordinate transformation to global coordinates in MM diff --git a/DDG4/include/DDG4/Geant4SteppingAction.h b/DDG4/include/DDG4/Geant4SteppingAction.h index c5de1bd20eab394d997b5976d2058ea9814b9eef..cde38d1603aed1659b65388a44fd6a652ff30b7a 100644 --- a/DDG4/include/DDG4/Geant4SteppingAction.h +++ b/DDG4/include/DDG4/Geant4SteppingAction.h @@ -41,7 +41,7 @@ namespace DD4hep { /// Concrete implementation of the Geant4 stepping action sequence /** * The sequence dispatches the callbacks for each stepping action - * to all registered Geant4SteppingAction members and all + * to all registered Geant4SteppingAction members and all * registered callbacks. * * \author M.Frank @@ -62,7 +62,7 @@ namespace DD4hep { virtual ~Geant4SteppingActionSequence(); /// Register stepping action callback. Types Q and T must be polymorph! template <typename Q, typename T> - void call(Q* p, void (T::*f)(const G4Step*, G4SteppingManager*)) { + void call(Q* p, void (T::*f)(const G4Step*, G4SteppingManager*)) { m_calls.add(p, f); } /// Add an actor responding to all callbacks. Sequence takes ownership. diff --git a/DDG4/include/DDG4/Geant4TestActions.h b/DDG4/include/DDG4/Geant4TestActions.h index e5b86d959d73394969b49fcdc1dc3ab264e3d21d..aaf7cfbcde21cc661625f98fb02da6debf0bef89 100644 --- a/DDG4/include/DDG4/Geant4TestActions.h +++ b/DDG4/include/DDG4/Geant4TestActions.h @@ -31,7 +31,7 @@ namespace DD4hep { namespace Test { /// Common base class for test action - /** + /** * \author M.Frank * \version 1.0 * \ingroup DD4HEP_SIMULATION @@ -61,8 +61,8 @@ namespace DD4hep { Geant4TestGeneratorAction(Geant4Context* c, const std::string& n); /// Default destructor virtual ~Geant4TestGeneratorAction(); - /// Callback to generate primary particles - virtual void operator()(G4Event*); + /// Callback to generate primary particles + virtual void operator()(G4Event*); }; /// Example run action doing nothing, but print diff --git a/DDG4/include/DDG4/Geant4TouchableHandler.h b/DDG4/include/DDG4/Geant4TouchableHandler.h index d67d128621b2ad401fe7191eec92e5185e62ebde..ebd77051a26b72323ae7ff06ee95b370abe55c23 100644 --- a/DDG4/include/DDG4/Geant4TouchableHandler.h +++ b/DDG4/include/DDG4/Geant4TouchableHandler.h @@ -38,13 +38,13 @@ namespace DD4hep { */ class Geant4TouchableHandler { public: - + typedef std::vector<const G4VPhysicalVolume*> Geant4PlacementPath; /// Data member of the helper objects const G4VTouchable* touchable; /// Default constructor. - Geant4TouchableHandler(const G4VTouchable* t) : touchable(t) {} + Geant4TouchableHandler(const G4VTouchable* t) : touchable(t) {} /// Default constructor. Takes the step's pre-touchable Geant4TouchableHandler(const G4Step* step); /// Default constructor. Takes the step's pre-touchable diff --git a/DDG4/include/DDG4/Geant4TrackHandler.h b/DDG4/include/DDG4/Geant4TrackHandler.h index 768a413aaa3d875b7feb97b6114cb144be61395c..9b6edbdfb934e778e69c7b82e3638da529313134 100644 --- a/DDG4/include/DDG4/Geant4TrackHandler.h +++ b/DDG4/include/DDG4/Geant4TrackHandler.h @@ -51,23 +51,23 @@ namespace DD4hep { /// Reference to the track object const G4Track* track; /// Initializing constructor - Geant4TrackHandler(const G4Track* t) - : track(t) { - /// Should test here if the track pointer is valid to avoind any later trouble - if ( 0 == t ) { - throw std::runtime_error("Geant4TrackHandler: NULL pointer passed to constructor!"); - } + Geant4TrackHandler(const G4Track* t) + : track(t) { + /// Should test here if the track pointer is valid to avoind any later trouble + if ( 0 == t ) { + throw std::runtime_error("Geant4TrackHandler: NULL pointer passed to constructor!"); + } } const char* statusName() const { - switch( track->GetTrackStatus() ) { - case fAlive: return "Alive"; - case fStopButAlive: return "StopButAlive"; - case fStopAndKill: return "StopAndKill"; - case fKillTrackAndSecondaries: return "KillTrackAndSecondaries"; - case fSuspend: return "Suspend"; - case fPostponeToNextEvent: return "PostponeToNextEvent"; - default: return "UNKNOWN"; - } + switch( track->GetTrackStatus() ) { + case fAlive: return "Alive"; + case fStopButAlive: return "StopButAlive"; + case fStopAndKill: return "StopAndKill"; + case fKillTrackAndSecondaries: return "KillTrackAndSecondaries"; + case fSuspend: return "Suspend"; + case fPostponeToNextEvent: return "PostponeToNextEvent"; + default: return "UNKNOWN"; + } } /// Conversion to G4Track @@ -76,11 +76,11 @@ namespace DD4hep { } /// Track's identifier int id() const { - return track->GetTrackID(); + return track->GetTrackID(); } /// Track's parent identifier int parent() const { - return track->GetParentID(); + return track->GetParentID(); } /// Track's particle definition G4ParticleDefinition* trackDef() const { @@ -88,11 +88,11 @@ namespace DD4hep { } /// Track's particle name const std::string& name() const { - return trackDef()->GetParticleName(); + return trackDef()->GetParticleName(); } /// Track's particle type const std::string& type() const { - return trackDef()->GetParticleType(); + return trackDef()->GetParticleType(); } /// Track's position const G4ThreeVector& position() const { @@ -102,13 +102,13 @@ namespace DD4hep { const G4ThreeVector& vertex() const { return track->GetVertexPosition(); } - /// Track global time + /// Track global time double globalTime() const { - return track->GetGlobalTime(); + return track->GetGlobalTime(); } - /// Track proper time + /// Track proper time double properTime() const { - return track->GetProperTime(); + return track->GetProperTime(); } /// Track's energy double energy() const { @@ -135,7 +135,7 @@ namespace DD4hep { return track->GetVolume(); } G4ThreeVector momentum() const { - return track->GetMomentum(); + return track->GetMomentum(); } /// Next physical volume of the track G4VPhysicalVolume* nextVol() const { @@ -159,9 +159,9 @@ namespace DD4hep { } /// Physical process of the track generation const std::string creatorName() const { - const G4VProcess* p = creatorProcess(); + const G4VProcess* p = creatorProcess(); if ( p ) return p->GetProcessName(); - return ""; + return ""; } /// User information block Info* userInfo() const { diff --git a/DDG4/include/DDG4/Geant4TrackInformation.h b/DDG4/include/DDG4/Geant4TrackInformation.h index c3324b146367d604c1db7630f820d1d404c44669..fa36d08ff0f8a35cae8d7f27061e7d8b73b1a551 100644 --- a/DDG4/include/DDG4/Geant4TrackInformation.h +++ b/DDG4/include/DDG4/Geant4TrackInformation.h @@ -19,7 +19,7 @@ namespace DD4hep { namespace Simulation { /// Unused. - /** + /** * * @author M.Frank * @version 1.0 diff --git a/DDG4/include/DDG4/Geant4TrackingAction.h b/DDG4/include/DDG4/Geant4TrackingAction.h index d9d29e4d16051715590a01643bcb0174bdabb0b2..67e04f16e133845b2f252f0a159c7071c630b18d 100644 --- a/DDG4/include/DDG4/Geant4TrackingAction.h +++ b/DDG4/include/DDG4/Geant4TrackingAction.h @@ -58,7 +58,7 @@ namespace DD4hep { /// Concrete implementation of the Geant4 tracking action sequence /** * The sequence dispatches the callbacks for each tracking action - * to all registered Geant4SteppingAction members and all + * to all registered Geant4SteppingAction members and all * registered callbacks. * * \author M.Frank @@ -83,27 +83,27 @@ namespace DD4hep { /// Default destructor virtual ~Geant4TrackingActionSequence(); /// Register Pre-track action callback before anything else - template <typename Q, typename T> - void callUpFront(Q* p, void (T::*f)(const G4Track*), - CallbackSequence::Location where=CallbackSequence::END) { + template <typename Q, typename T> + void callUpFront(Q* p, void (T::*f)(const G4Track*), + CallbackSequence::Location where=CallbackSequence::END) { m_front.add(p, f, where); } /// Register Pre-track action callback - template <typename Q, typename T> - void callAtBegin(Q* p, void (T::*f)(const G4Track*), - CallbackSequence::Location where=CallbackSequence::END) { + template <typename Q, typename T> + void callAtBegin(Q* p, void (T::*f)(const G4Track*), + CallbackSequence::Location where=CallbackSequence::END) { m_begin.add(p, f, where); } /// Register Post-track action callback - template <typename Q, typename T> - void callAtEnd(Q* p, void (T::*f)(const G4Track*), - CallbackSequence::Location where=CallbackSequence::END) { + template <typename Q, typename T> + void callAtEnd(Q* p, void (T::*f)(const G4Track*), + CallbackSequence::Location where=CallbackSequence::END) { m_end.add(p, f, where); } /// Register Post-track action callback - template <typename Q, typename T> - void callAtFinal(Q* p, void (T::*f)(const G4Track*), - CallbackSequence::Location where=CallbackSequence::END) { + template <typename Q, typename T> + void callAtFinal(Q* p, void (T::*f)(const G4Track*), + CallbackSequence::Location where=CallbackSequence::END) { m_final.add(p, f, where); } /// Add an actor responding to all callbacks. Sequence takes ownership. diff --git a/DDG4/include/DDG4/Geant4UIManager.h b/DDG4/include/DDG4/Geant4UIManager.h index e9e417a13d6353a9b393c98350f7ade90474eeeb..6f088e48be984538c4e47b10ce4068097a82589c 100644 --- a/DDG4/include/DDG4/Geant4UIManager.h +++ b/DDG4/include/DDG4/Geant4UIManager.h @@ -26,10 +26,10 @@ namespace DD4hep { namespace Simulation { /// Standard UI interface implementation with configuration using property options - /** The {\tt{Geant4UIManager}} is a component attached to the {\tt{Geant4Kernel}} object. + /** The {\tt{Geant4UIManager}} is a component attached to the {\tt{Geant4Kernel}} object. * - * All properties of all {\tt{Geant4Action}} instances may be exported to - * Geant4 messengers and {\em{may}} hence be accessible directly from the Geant4 + * All properties of all {\tt{Geant4Action}} instances may be exported to + * Geant4 messengers and {\em{may}} hence be accessible directly from the Geant4 * prompt. To export properties from any action, call the {\tt{enableUI()}} * method of the action. * diff --git a/DDG4/include/DDG4/Geant4UIMessenger.h b/DDG4/include/DDG4/Geant4UIMessenger.h index cdb67d57e72cccf191cfe17dfffee0dc318f96b3..75d0a064bbf4f9b4860572090533c6847073c0a8 100644 --- a/DDG4/include/DDG4/Geant4UIMessenger.h +++ b/DDG4/include/DDG4/Geant4UIMessenger.h @@ -54,7 +54,7 @@ namespace DD4hep { void addCall(const std::string& name, const std::string& description, const Callback& cb); /// Add any callback (without parameters to the messenger template <typename Q, typename R, typename T> - void addCall(const std::string& name, const std::string& description, Q* p, R (T::*f)()) { + void addCall(const std::string& name, const std::string& description, Q* p, R (T::*f)()) { CallbackSequence::checkTypes(typeid(Q), typeid(T), dynamic_cast<T*>(p)); addCall(name, description, Callback(p).make(f)); } diff --git a/DDG4/include/DDG4/Geant4UserParticleHandler.h b/DDG4/include/DDG4/Geant4UserParticleHandler.h index 57d60c5ad080363bdbf91f11b91564f1cd924783..f7adc0cfe74e92f7e423fe4db3187ceafa224927 100644 --- a/DDG4/include/DDG4/Geant4UserParticleHandler.h +++ b/DDG4/include/DDG4/Geant4UserParticleHandler.h @@ -104,7 +104,7 @@ namespace DD4hep { * * Note: This may override all other decisions! * Default implementation is empty. - * + * */ virtual bool keepParticle(Particle& particle); diff --git a/DDG4/include/DDG4/Geant4UserPhysicsList.h b/DDG4/include/DDG4/Geant4UserPhysicsList.h index d4f14c7feb0704fbf15447b26f145de5db760eb0..f8d4468d50d3a8f851e0703ddab2b04d974fc932 100644 --- a/DDG4/include/DDG4/Geant4UserPhysicsList.h +++ b/DDG4/include/DDG4/Geant4UserPhysicsList.h @@ -34,8 +34,8 @@ namespace DD4hep { Geant4PhysicsListActionSequence* m_sequence; public: /// Standard constructor - Geant4UserPhysicsList(Geant4PhysicsListActionSequence* seq, int verbose) - : Geant4UserPhysics(), BASE_IMP(verbose), m_sequence(seq) { + Geant4UserPhysicsList(Geant4PhysicsListActionSequence* seq, int verbose) + : Geant4UserPhysics(), BASE_IMP(verbose), m_sequence(seq) { if (m_sequence) m_sequence->addRef(); InstanceCount::increment(this); diff --git a/DDG4/include/DDG4/Geant4Vertex.h b/DDG4/include/DDG4/Geant4Vertex.h index fc28e58d9122ece1ac24b96a4fffc1eb63667c38..c705dffe4ae2e0e8bbc011bb4226b3a0de3e05a8 100644 --- a/DDG4/include/DDG4/Geant4Vertex.h +++ b/DDG4/include/DDG4/Geant4Vertex.h @@ -28,10 +28,10 @@ namespace DD4hep { /// Default constructor VertexExtension() {} /// Default destructor - virtual ~VertexExtension(); + virtual ~VertexExtension(); }; - /// Data structure to store the MC vertex information + /// Data structure to store the MC vertex information /** * @author M.Frank * @version 1.0 @@ -50,7 +50,7 @@ namespace DD4hep { /// The list of incoming particles Particles in; /// User data extension if required - std::auto_ptr<VertexExtension> extension; + std::auto_ptr<VertexExtension> extension; /// Default constructor Geant4Vertex(); diff --git a/DDG4/include/DDG4/Geant4VolumeManager.h b/DDG4/include/DDG4/Geant4VolumeManager.h index 5361332d32162a6f65510fbbf53c545f105a3ac1..2fc471d4807ef6643be25565fafbeda5c57a0e15 100644 --- a/DDG4/include/DDG4/Geant4VolumeManager.h +++ b/DDG4/include/DDG4/Geant4VolumeManager.h @@ -60,30 +60,30 @@ namespace DD4hep { /// Initializing constructor. The tree will automatically be built if possible Geant4VolumeManager(Geometry::LCDD& lcdd, Geant4GeometryInfo* info); /// Default constructor - Geant4VolumeManager() - : Base(), m_isValid(false) { + Geant4VolumeManager() + : Base(), m_isValid(false) { } /// Constructor to be used when reading the already parsed object - Geant4VolumeManager(const Base& e) - : Base(e), m_isValid(false) { + Geant4VolumeManager(const Base& e) + : Base(e), m_isValid(false) { } /// Constructor to be used when reading the already parsed object - Geant4VolumeManager(const Geant4VolumeManager& e) - : Base(e), m_isValid(false) { + Geant4VolumeManager(const Geant4VolumeManager& e) + : Base(e), m_isValid(false) { } /// Constructor to be used when reading the already parsed object template <typename Q> Geant4VolumeManager(const Geometry::Handle<Q>& e) - : Base(e), m_isValid(false) { + : Base(e), m_isValid(false) { } /// Assignment operator Geant4VolumeManager& operator=(const Geant4VolumeManager& c) { - if ( this != &c ) { - m_element = c.m_element; - m_isValid = c.m_isValid; - } - return *this; + if ( this != &c ) { + m_element = c.m_element; + m_isValid = c.m_isValid; + } + return *this; } - + /// Helper: Generate placement path from touchable object PlacementPath placementPath(const G4VTouchable* touchable, bool exception = true) const; /// Access CELLID by placement path diff --git a/DDG4/include/DDG4/IoStreams.h b/DDG4/include/DDG4/IoStreams.h index c5bd612d3a9648763f4350211289cd69e301a8b2..799d12750d739939f8a0ff457b334384e1a0087a 100644 --- a/DDG4/include/DDG4/IoStreams.h +++ b/DDG4/include/DDG4/IoStreams.h @@ -40,7 +40,7 @@ namespace DD4hep { * The final aim is to hide all this behind a TFile object, * so that we get the entire network file handling for free! * - * Note: + * Note: * Credits go to a large extend to the authors of boost::iostreams. * Without their work I could not have done this! * @@ -60,7 +60,7 @@ namespace DD4hep { struct category : boost::iostreams::seekable_device_tag, boost::iostreams::closable_tag { }; // Default constructor - dd4hep_file() : m_handle(0) { } + dd4hep_file() : m_handle(0) { } // Constructors taking file desciptors dd4hep_file(handle_type fd, dd4hep_file_flags); // Constructors taking file desciptors @@ -93,7 +93,7 @@ namespace DD4hep { * The final aim is to hide all this behind a TFile object, * so that we get the entire network file handling for free! * - * Note: + * Note: * Credits go to a large extend to the authors of boost::iostreams. * Without their work I could not have done this! * @@ -104,48 +104,48 @@ namespace DD4hep { */ template <typename T=int> class dd4hep_file_source : private dd4hep_file<T> { public: - typedef dd4hep_file<T> descriptor; - struct category : boost::iostreams::input_seekable, - boost::iostreams::device_tag, - boost::iostreams::closable_tag { }; - typedef typename descriptor::handle_type handle_type; - typedef typename descriptor::char_type char_type; - using descriptor::is_open; - using descriptor::close; - using descriptor::read; - using descriptor::seek; - using descriptor::handle; - - /// Default Constructor - dd4hep_file_source() : descriptor() { } - - /// Copy constructor - dd4hep_file_source(const dd4hep_file_source<T>& other) - : descriptor(other) { } - - /// Constructors taking file desciptors - explicit dd4hep_file_source(handle_type h, dd4hep_file_flags flags) - : descriptor(h,flags) { } - - /// Constructors taking file desciptors - explicit dd4hep_file_source(const char* name, BOOST_IOS::openmode mode = BOOST_IOS::in) - : descriptor(name,mode) { } - - /// open overload taking file desciptors - void open(handle_type h, dd4hep_file_flags flags) - { this->descriptor::open(h, flags); } - - /// open overload taking C-style string - void open(const char* path, BOOST_IOS::openmode mode = BOOST_IOS::in) - { this->descriptor::open(path,mode); } - - /// open overload taking a std::string - void open(const std::string& path, BOOST_IOS::openmode mode = BOOST_IOS::in) - { open(path.c_str(), mode); } - - /// open overload taking a Boost.Filesystem path - template<typename Path> void open(const Path& path, BOOST_IOS::openmode mode = BOOST_IOS::in) - { open(detail_path(path), mode); } + typedef dd4hep_file<T> descriptor; + struct category : boost::iostreams::input_seekable, + boost::iostreams::device_tag, + boost::iostreams::closable_tag { }; + typedef typename descriptor::handle_type handle_type; + typedef typename descriptor::char_type char_type; + using descriptor::is_open; + using descriptor::close; + using descriptor::read; + using descriptor::seek; + using descriptor::handle; + + /// Default Constructor + dd4hep_file_source() : descriptor() { } + + /// Copy constructor + dd4hep_file_source(const dd4hep_file_source<T>& other) + : descriptor(other) { } + + /// Constructors taking file desciptors + explicit dd4hep_file_source(handle_type h, dd4hep_file_flags flags) + : descriptor(h,flags) { } + + /// Constructors taking file desciptors + explicit dd4hep_file_source(const char* name, BOOST_IOS::openmode mode = BOOST_IOS::in) + : descriptor(name,mode) { } + + /// open overload taking file desciptors + void open(handle_type h, dd4hep_file_flags flags) + { this->descriptor::open(h, flags); } + + /// open overload taking C-style string + void open(const char* path, BOOST_IOS::openmode mode = BOOST_IOS::in) + { this->descriptor::open(path,mode); } + + /// open overload taking a std::string + void open(const std::string& path, BOOST_IOS::openmode mode = BOOST_IOS::in) + { open(path.c_str(), mode); } + + /// open overload taking a Boost.Filesystem path + template<typename Path> void open(const Path& path, BOOST_IOS::openmode mode = BOOST_IOS::in) + { open(detail_path(path), mode); } }; /// DD4hep file sink extension to boost::iostreams @@ -157,7 +157,7 @@ namespace DD4hep { * The final aim is to hide all this behind a TFile object, * so that we get the entire network file handling for free! * - * Note: + * Note: * Credits go to a large extend to the authors of boost::iostreams. * Without their work I could not have done this! * @@ -167,11 +167,11 @@ namespace DD4hep { * \see http://www.boost.org/libs/iostreams for further documentation. */ template <typename T> - class dd4hep_file_sink : private dd4hep_file<T> { + class dd4hep_file_sink : private dd4hep_file<T> { public: typedef dd4hep_file<T> descriptor; - struct category : boost::iostreams::output_seekable, - boost::iostreams::device_tag, + struct category : boost::iostreams::output_seekable, + boost::iostreams::device_tag, boost::iostreams::closable_tag { }; typedef typename descriptor::handle_type handle_type; typedef typename descriptor::char_type char_type; @@ -185,11 +185,11 @@ namespace DD4hep { dd4hep_file_sink() { } /// Copy constructor - dd4hep_file_sink(const dd4hep_file_sink<T>& other) - : descriptor(other) { } + dd4hep_file_sink(const dd4hep_file_sink<T>& other) + : descriptor(other) { } /// Constructors taking file desciptors - explicit dd4hep_file_sink(handle_type fd, dd4hep_file_flags flags) + explicit dd4hep_file_sink(handle_type fd, dd4hep_file_flags flags) : descriptor(fd, flags) { } /// Constructor taking a std::string @@ -202,15 +202,15 @@ namespace DD4hep { /// Constructor taking a Boost.Filesystem path template<typename Path> - explicit dd4hep_file_sink(const Path& path, BOOST_IOS::openmode mode = BOOST_IOS::out ) + explicit dd4hep_file_sink(const Path& path, BOOST_IOS::openmode mode = BOOST_IOS::out ) : descriptor(detail_path(path), mode) { } /// open overloads taking file descriptors void open(handle_type fd, dd4hep_file_flags flags) - { this->descriptor::open(fd,flags); } + { this->descriptor::open(fd,flags); } /// open overload taking a std::string - void open(const std::string& path, BOOST_IOS::openmode mode = BOOST_IOS::out ) + void open(const std::string& path, BOOST_IOS::openmode mode = BOOST_IOS::out ) { open(path.c_str(),mode); } /// open overload taking C-style string @@ -219,7 +219,7 @@ namespace DD4hep { /// open overload taking a Boost.Filesystem path template<typename Path> void open(const Path& path, BOOST_IOS::openmode mode = BOOST_IOS::out ) - { open(detail_path(path), mode); } + { open(detail_path(path), mode); } }; } // End namespace boost #endif // DD4HEP_DD4HEP_IOSTREAMs_H diff --git a/DDG4/lcio/Geant4Output2LCIO.cpp b/DDG4/lcio/Geant4Output2LCIO.cpp index a2093c5fe4eae90eb8e9b1bcf33d2ff152bfc4ac..d5adee47045faa3436e6f9da5fed22c26c08bc4c 100644 --- a/DDG4/lcio/Geant4Output2LCIO.cpp +++ b/DDG4/lcio/Geant4Output2LCIO.cpp @@ -28,7 +28,7 @@ namespace DD4hep { namespace Simulation { class Geant4ParticleMap; - + /// Base class to output Geant4 event data to media /** * \author M.Frank @@ -39,7 +39,7 @@ namespace DD4hep { protected: lcio::LCWriter* m_file; int m_runNo; - + /// Data conversion interface for MC particles to LCIO format lcio::LCCollectionVec* saveParticles(Geant4ParticleMap* particles); public: @@ -157,7 +157,7 @@ void Geant4Output2LCIO::saveRun(const G4Run* run) { void Geant4Output2LCIO::begin(const G4Event* /* event */) { lcio::LCEventImpl* e = new lcio::LCEventImpl; //fg: here the event context takes ownership and - // deletes the event in the end + // deletes the event in the end context()->event().addExtension<lcio::LCEventImpl>( e ); } @@ -186,10 +186,10 @@ lcio::LCCollectionVec* Geant4Output2LCIO::saveParticles(Geant4ParticleMap* parti float ps_fa[3] = {float(p->psx/GeV),float(p->psy/GeV),float(p->psz/GeV)}; q->setMomentum( ps_fa ); - double vs_fa[3] = { p->vsx/mm, p->vsy/mm, p->vsz/mm } ; + double vs_fa[3] = { p->vsx/mm, p->vsy/mm, p->vsz/mm } ; q->setVertex( vs_fa ); - double ve_fa[3] = { p->vex/mm, p->vey/mm, p->vez/mm } ; + double ve_fa[3] = { p->vex/mm, p->vey/mm, p->vez/mm } ; q->setEndpoint( ve_fa ); q->setTime(p->time/ns); @@ -203,7 +203,7 @@ lcio::LCCollectionVec* Geant4Output2LCIO::saveParticles(Geant4ParticleMap* parti else if ( mask.isSet(G4PARTICLE_GEN_DOCUMENTATION) ) q->setGeneratorStatus(3); // Set simulation status - q->setSimulatorStatus( 0 ) ; + q->setSimulatorStatus( 0 ) ; q->setCreatedInSimulation( mask.isSet(G4PARTICLE_SIM_CREATED) ); q->setBackscatter( mask.isSet(G4PARTICLE_SIM_BACKSCATTER) ); q->setVertexIsNotEndpointOfParent( mask.isSet(G4PARTICLE_SIM_PARENT_RADIATED) ); @@ -214,8 +214,8 @@ lcio::LCCollectionVec* Geant4Output2LCIO::saveParticles(Geant4ParticleMap* parti q->setOverlay( false ); //fg: if simstatus !=0 we have to set the generator status to 0: - if( q->getSimulatorStatus() != 0 ) - q->setGeneratorStatus( 0 ) ; + if( q->getSimulatorStatus() != 0 ) + q->setGeneratorStatus( 0 ) ; q->setSpin(p->spin); q->setColorFlow(p->colorFlow); @@ -233,25 +233,25 @@ lcio::LCCollectionVec* Geant4Output2LCIO::saveParticles(Geant4ParticleMap* parti MCParticleImpl* q = p_lcio[i]; const Geant4Particle::Particles& dau = p->daughters; for(Geant4Particle::Particles::const_iterator j=dau.begin(); j!=dau.end(); ++j) { - int idau = *j; - if ( (k=p_ids.find(idau)) == p_ids.end() ) { // Error!!! - printout(FATAL,"Geant4Conversion","+++ Particle %d: FAILED to find daughter with ID:%d",p->id,idau); - continue; - } - int iqdau = (*k).second; - MCParticleImpl* qdau = p_lcio[iqdau]; - qdau->addParent(q); + int idau = *j; + if ( (k=p_ids.find(idau)) == p_ids.end() ) { // Error!!! + printout(FATAL,"Geant4Conversion","+++ Particle %d: FAILED to find daughter with ID:%d",p->id,idau); + continue; + } + int iqdau = (*k).second; + MCParticleImpl* qdau = p_lcio[iqdau]; + qdau->addParent(q); } const Geant4Particle::Particles& par = p->parents; for(Geant4Particle::Particles::const_iterator j=par.begin(); j!=par.end(); ++j) { - int ipar = *j; // A parent ID iof -1 means NO parent, because a base of 0 is perfectly leagal! - if ( ipar>=0 && (k=p_ids.find(ipar)) == p_ids.end() ) { // Error!!! - printout(FATAL,"Geant4Conversion","+++ Particle %d: FAILED to find parent with ID:%d",p->id,ipar); - continue; - } - int iqpar = (*k).second; - MCParticleImpl* qpar = p_lcio[iqpar]; - q->addParent(qpar); + int ipar = *j; // A parent ID iof -1 means NO parent, because a base of 0 is perfectly leagal! + if ( ipar>=0 && (k=p_ids.find(ipar)) == p_ids.end() ) { // Error!!! + printout(FATAL,"Geant4Conversion","+++ Particle %d: FAILED to find parent with ID:%d",p->id,ipar); + continue; + } + int iqpar = (*k).second; + MCParticleImpl* qpar = p_lcio[iqpar]; + q->addParent(qpar); } } } diff --git a/DDG4/lcio/LCIOConversions.cpp b/DDG4/lcio/LCIOConversions.cpp index 1cd94877dbc126ae56a03e971fb9b2cef7f5edc1..77edb08762c90cd4dc2b200c5bd48fc3a51a7178 100644 --- a/DDG4/lcio/LCIOConversions.cpp +++ b/DDG4/lcio/LCIOConversions.cpp @@ -68,18 +68,18 @@ namespace DD4hep { */ template <> lcio::LCCollectionVec* Geant4DataConversion<lcio::LCCollectionVec, - pair<const Geant4Context*,G4VHitsCollection*>, - Geant4HitCollection>::operator()(const arg_t& args) const { + pair<const Geant4Context*,G4VHitsCollection*>, + Geant4HitCollection>::operator()(const arg_t& args) const { G4VHitsCollection* c = args.second; Geant4HitCollection* coll = dynamic_cast<Geant4HitCollection*>(c); if ( coll ) { - typedef pair<arg_t::first_type,Geant4HitCollection*> _A; - typedef Geant4Conversion<output_t,_A> _C; - const _C& cnv= _C::converter(coll->type().type); - return cnv(_A(args.first,coll)); + typedef pair<arg_t::first_type,Geant4HitCollection*> _A; + typedef Geant4Conversion<output_t,_A> _C; + const _C& cnv= _C::converter(coll->type().type); + return cnv(_A(args.first,coll)); } throw unrelated_type_error(typeid(Geant4HitCollection),typeid(*c), - "Cannot save the collection entries of:"+c->GetName()); + "Cannot save the collection entries of:"+c->GetName()); } /// Data conversion interface creating lcio::SimTrackerHitImpl from Geant4Tracker::Hit structures @@ -92,10 +92,10 @@ namespace DD4hep { * @author M.Frank * @version 1.0 */ - template <> lcio::LCCollectionVec* + template <> lcio::LCCollectionVec* Geant4DataConversion<lcio::LCCollectionVec, - pair<const Geant4Context*,Geant4HitCollection*>, - Geant4Tracker::Hit>::operator()(const arg_t& args) const { + pair<const Geant4Context*,Geant4HitCollection*>, + Geant4Tracker::Hit>::operator()(const arg_t& args) const { Geant4HitCollection* coll = args.second; Geant4Sensitive* sd = coll->sensitive(); @@ -109,27 +109,27 @@ namespace DD4hep { int hit_creation_mode = sd->hitCreationMode(); if ( hit_creation_mode == Geant4Sensitive::DETAILED_MODE ) - lc_coll->setFlag(UTIL::make_bitset32(LCIO::THBIT_MOMENTUM,LCIO::THBIT_ID1)); + lc_coll->setFlag(UTIL::make_bitset32(LCIO::THBIT_MOMENTUM,LCIO::THBIT_ID1)); else - lc_coll->setFlag(LCIO::THBIT_ID1); + lc_coll->setFlag(LCIO::THBIT_ID1); lc_coll->reserve(nhits); for(size_t i=0; i<nhits; ++i) { - const Geant4Tracker::Hit* hit = coll->hit(i); - const Geant4Tracker::Hit::Contribution& t = hit->truth; - int trackID = pm->particleID(t.trackID); - EVENT::MCParticle* lc_mcp = (EVENT::MCParticle*)lc_part->getElementAt(trackID); - double pos[3] = {hit->position.x()/mm, hit->position.y()/mm, hit->position.z()/mm}; - lcio::SimTrackerHitImpl* lc_hit = new lcio::SimTrackerHitImpl; - lc_hit->setCellID0((hit->cellID >> 0 ) & 0xFFFFFFFF); - lc_hit->setCellID1((hit->cellID >> sizeof(int)) & 0xFFFFFFFF); - lc_hit->setEDep(hit->energyDeposit/GeV); - lc_hit->setPathLength(hit->length/mm); - lc_hit->setTime(hit->truth.time/ns); - lc_hit->setMCParticle(lc_mcp); - lc_hit->setPosition(pos); - lc_hit->setMomentum(hit->momentum.x()/GeV,hit->momentum.y()/GeV,hit->momentum.z()/GeV); - lc_coll->addElement(lc_hit); + const Geant4Tracker::Hit* hit = coll->hit(i); + const Geant4Tracker::Hit::Contribution& t = hit->truth; + int trackID = pm->particleID(t.trackID); + EVENT::MCParticle* lc_mcp = (EVENT::MCParticle*)lc_part->getElementAt(trackID); + double pos[3] = {hit->position.x()/mm, hit->position.y()/mm, hit->position.z()/mm}; + lcio::SimTrackerHitImpl* lc_hit = new lcio::SimTrackerHitImpl; + lc_hit->setCellID0((hit->cellID >> 0 ) & 0xFFFFFFFF); + lc_hit->setCellID1((hit->cellID >> sizeof(int)) & 0xFFFFFFFF); + lc_hit->setEDep(hit->energyDeposit/GeV); + lc_hit->setPathLength(hit->length/mm); + lc_hit->setTime(hit->truth.time/ns); + lc_hit->setMCParticle(lc_mcp); + lc_hit->setPosition(pos); + lc_hit->setMomentum(hit->momentum.x()/GeV,hit->momentum.y()/GeV,hit->momentum.z()/GeV); + lc_coll->addElement(lc_hit); } return lc_coll; } @@ -144,10 +144,10 @@ namespace DD4hep { * @author M.Frank * @version 1.0 */ - template <> lcio::LCCollectionVec* + template <> lcio::LCCollectionVec* Geant4DataConversion<lcio::LCCollectionVec, - pair<const Geant4Context*,Geant4HitCollection*>, - Geant4Calorimeter::Hit>::operator()(const arg_t& args) const { + pair<const Geant4Context*,Geant4HitCollection*>, + Geant4Calorimeter::Hit>::operator()(const arg_t& args) const { typedef Geant4HitData::Contributions Contributions; Geant4HitCollection* coll = args.second; Geant4Sensitive* sd = coll->sensitive(); @@ -161,49 +161,49 @@ namespace DD4hep { int hit_creation_mode = sd->hitCreationMode(); if ( hit_creation_mode == Geant4Sensitive::DETAILED_MODE ) - lc_coll->setFlag(UTIL::make_bitset32(LCIO::CHBIT_LONG,LCIO::CHBIT_STEP,LCIO::CHBIT_ID1)); + lc_coll->setFlag(UTIL::make_bitset32(LCIO::CHBIT_LONG,LCIO::CHBIT_STEP,LCIO::CHBIT_ID1)); else - lc_coll->setFlag(UTIL::make_bitset32(LCIO::CHBIT_LONG,LCIO::CHBIT_ID1)); + lc_coll->setFlag(UTIL::make_bitset32(LCIO::CHBIT_LONG,LCIO::CHBIT_ID1)); lc_coll->reserve(nhits); if ( sd->hasProperty("HitCreationMode") ) { - hit_creation_mode = sd->property("HitCreationMode").value<int>(); + hit_creation_mode = sd->property("HitCreationMode").value<int>(); } for(size_t i=0; i<nhits; ++i) { - const Geant4Calorimeter::Hit* hit = coll->hit(i); - float pos[3] = {float(hit->position.x()/mm), float(hit->position.y()/mm), float(hit->position.z()/mm)}; - lcio::SimCalorimeterHitImpl* lc_hit = new lcio::SimCalorimeterHitImpl; - lc_hit->setCellID0((hit->cellID >> 0 ) & 0xFFFFFFFF); - lc_hit->setCellID1((hit->cellID >> sizeof(int)) & 0xFFFFFFFF); // ???? - lc_hit->setPosition(pos); - ///No! Done when adding particle contrbutions: lc_hit->setEnergy( hit->energyDeposit ); - lc_coll->addElement(lc_hit); - /// Now add the individual track contributions to the LCIO hit structure - for(Contributions::const_iterator j=hit->truth.begin(); j!=hit->truth.end(); ++j) { - const Geant4HitData::Contribution& c = *j; - int trackID = pm->particleID(c.trackID); - float pos[] = {float(c.x/mm), float(c.y/mm), float(c.z/mm)}; - EVENT::MCParticle* lc_mcp = (EVENT::MCParticle*)lc_parts->getElementAt(trackID); - if ( hit_creation_mode == Geant4Sensitive::DETAILED_MODE ) - lc_hit->addMCParticleContribution(lc_mcp, c.deposit/GeV, c.time/ns, lc_mcp->getPDG(), pos); - else - lc_hit->addMCParticleContribution(lc_mcp, c.deposit/GeV, c.time/ns); - } + const Geant4Calorimeter::Hit* hit = coll->hit(i); + float pos[3] = {float(hit->position.x()/mm), float(hit->position.y()/mm), float(hit->position.z()/mm)}; + lcio::SimCalorimeterHitImpl* lc_hit = new lcio::SimCalorimeterHitImpl; + lc_hit->setCellID0((hit->cellID >> 0 ) & 0xFFFFFFFF); + lc_hit->setCellID1((hit->cellID >> sizeof(int)) & 0xFFFFFFFF); // ???? + lc_hit->setPosition(pos); + ///No! Done when adding particle contrbutions: lc_hit->setEnergy( hit->energyDeposit ); + lc_coll->addElement(lc_hit); + /// Now add the individual track contributions to the LCIO hit structure + for(Contributions::const_iterator j=hit->truth.begin(); j!=hit->truth.end(); ++j) { + const Geant4HitData::Contribution& c = *j; + int trackID = pm->particleID(c.trackID); + float pos[] = {float(c.x/mm), float(c.y/mm), float(c.z/mm)}; + EVENT::MCParticle* lc_mcp = (EVENT::MCParticle*)lc_parts->getElementAt(trackID); + if ( hit_creation_mode == Geant4Sensitive::DETAILED_MODE ) + lc_hit->addMCParticleContribution(lc_mcp, c.deposit/GeV, c.time/ns, lc_mcp->getPDG(), pos); + else + lc_hit->addMCParticleContribution(lc_mcp, c.deposit/GeV, c.time/ns); + } } return lc_coll; } - template <typename T> + template <typename T> lcio::LCCollectionVec* moveEntries(Geant4HitCollection* coll, - lcio::LCCollectionVec* lc_coll) + lcio::LCCollectionVec* lc_coll) { size_t nhits = coll->GetSize(); lc_coll->reserve(nhits); for(size_t i=0; i<nhits; ++i) { - Geant4HitWrapper& wrap = coll->hit(i); + Geant4HitWrapper& wrap = coll->hit(i); T* lc_hit = wrap; - wrap.release(); // Now we have ownership! - lc_coll->addElement(lc_hit); + wrap.release(); // Now we have ownership! + lc_coll->addElement(lc_hit); } coll->clear(); // Since the collection now only contains NULL pointers, better clear it! return lc_coll; @@ -222,10 +222,10 @@ namespace DD4hep { * @author M.Frank * @version 1.0 */ - template <> lcio::LCCollectionVec* + template <> lcio::LCCollectionVec* Geant4DataConversion<lcio::LCCollectionVec, - pair<const Geant4Context*,Geant4HitCollection*>, - lcio::SimTrackerHitImpl>::operator()(const arg_t& args) const + pair<const Geant4Context*,Geant4HitCollection*>, + lcio::SimTrackerHitImpl>::operator()(const arg_t& args) const { Geant4Sensitive* sd = args.second->sensitive(); string dsc = encoding(sd->sensitiveDetector()); @@ -233,9 +233,9 @@ namespace DD4hep { int hit_creation_mode = sd->hitCreationMode(); if ( hit_creation_mode == Geant4Sensitive::DETAILED_MODE ) - lc->setFlag(UTIL::make_bitset32(LCIO::CHBIT_LONG,LCIO::CHBIT_STEP,LCIO::CHBIT_ID1)); + lc->setFlag(UTIL::make_bitset32(LCIO::CHBIT_LONG,LCIO::CHBIT_STEP,LCIO::CHBIT_ID1)); else - lc->setFlag(UTIL::make_bitset32(LCIO::CHBIT_LONG,LCIO::CHBIT_ID1)); + lc->setFlag(UTIL::make_bitset32(LCIO::CHBIT_LONG,LCIO::CHBIT_ID1)); UTIL::CellIDEncoder<SimTrackerHit> decoder(dsc,lc); return moveEntries<lcio::SimTrackerHitImpl>(args.second,lc); } @@ -253,10 +253,10 @@ namespace DD4hep { * @author M.Frank * @version 1.0 */ - template <> lcio::LCCollectionVec* + template <> lcio::LCCollectionVec* Geant4DataConversion<lcio::LCCollectionVec, - pair<const Geant4Context*,Geant4HitCollection*>, - lcio::SimCalorimeterHitImpl>::operator()(const arg_t& args) const + pair<const Geant4Context*,Geant4HitCollection*>, + lcio::SimCalorimeterHitImpl>::operator()(const arg_t& args) const { Geant4Sensitive* sd = args.second->sensitive(); string dsc = encoding(args.second->sensitive()->sensitiveDetector()); @@ -264,9 +264,9 @@ namespace DD4hep { int hit_creation_mode = sd->hitCreationMode(); if ( hit_creation_mode == Geant4Sensitive::DETAILED_MODE ) - lc->setFlag(UTIL::make_bitset32(LCIO::CHBIT_LONG,LCIO::CHBIT_STEP,LCIO::CHBIT_ID1)); + lc->setFlag(UTIL::make_bitset32(LCIO::CHBIT_LONG,LCIO::CHBIT_STEP,LCIO::CHBIT_ID1)); else - lc->setFlag(UTIL::make_bitset32(LCIO::CHBIT_LONG,LCIO::CHBIT_ID1)); + lc->setFlag(UTIL::make_bitset32(LCIO::CHBIT_LONG,LCIO::CHBIT_ID1)); return moveEntries<tag_t>(args.second,lc); } @@ -276,10 +276,10 @@ namespace DD4hep { * @author M.Frank * @version 1.0 */ - template <> lcio::LCCollectionVec* + template <> lcio::LCCollectionVec* Geant4DataConversion<lcio::LCCollectionVec, - pair<const Geant4Context*,Geant4HitCollection*>, - lcio::ClusterImpl>::operator()(const arg_t& args) const + pair<const Geant4Context*,Geant4HitCollection*>, + lcio::ClusterImpl>::operator()(const arg_t& args) const { output_t* lc = new lcio::LCCollectionVec(lcio::LCIO::CLUSTER); return moveEntries<tag_t>(args.second,lc); diff --git a/DDG4/lcio/LCIOEventReader.cpp b/DDG4/lcio/LCIOEventReader.cpp index a6a94eaa6f61be7b104849f79da349cf45e95245..1a0cf097b1c039882db48f84ee4adfe3748972b0 100644 --- a/DDG4/lcio/LCIOEventReader.cpp +++ b/DDG4/lcio/LCIOEventReader.cpp @@ -60,13 +60,13 @@ LCIOEventReader::readParticles(int event_number, vector<Particle*>& particles) vector<EVENT::MCParticle*> mcpcoll; EventReaderStatus ret = EVENT_READER_OK; - if ( hasDirectAccess() ) + if ( hasDirectAccess() ) ret = readParticles(event_number,&primaries); else if ( m_numEvent == event_number ) ret = readParticles(event_number,&primaries); else ret = readParticles(event_number,&primaries); - //ret = EVENT_READER_NO_DIRECT; + //ret = EVENT_READER_NO_DIRECT; ++m_numEvent; if ( ret != EVENT_READER_OK ) return ret; @@ -121,12 +121,12 @@ LCIOEventReader::readParticles(int event_number, vector<Particle*>& particles) int genStatus = mcp->getGeneratorStatus(); if ( genStatus == 0 ) status.set(G4PARTICLE_GEN_EMPTY); - else if ( genStatus == 1 ) status.set(G4PARTICLE_GEN_STABLE); + else if ( genStatus == 1 ) status.set(G4PARTICLE_GEN_STABLE); else if ( genStatus == 2 ) status.set(G4PARTICLE_GEN_DECAYED); else if ( genStatus == 3 ) status.set(G4PARTICLE_GEN_DOCUMENTATION); - else { - cout << " #### WARNING - LCIOInputAction : unknown generator status : " - << genStatus << " -> ignored ! " << endl; + else { + cout << " #### WARNING - LCIOInputAction : unknown generator status : " + << genStatus << " -> ignored ! " << endl; } if ( mcp->isCreatedInSimulation() ) status.set(G4PARTICLE_SIM_CREATED); if ( mcp->isBackscatter() ) status.set(G4PARTICLE_SIM_BACKSCATTER); diff --git a/DDG4/lcio/LCIOEventReader.h b/DDG4/lcio/LCIOEventReader.h index 5d2e67626e296c9c40f3d4815b11a973bbfcce3d..fa9f0e8199032b3546607fc254260eb6830eb9ef 100644 --- a/DDG4/lcio/LCIOEventReader.h +++ b/DDG4/lcio/LCIOEventReader.h @@ -20,7 +20,7 @@ namespace DD4hep { namespace Simulation { /// Base class to read lcio files. - /** + /** * \author P.Kostka (main author) * \author M.Frank (code reshuffeling into new DDG4 scheme) * \version 1.0 diff --git a/DDG4/lcio/LCIOFileReader.cpp b/DDG4/lcio/LCIOFileReader.cpp index 307b877fee2805344231317ebef3fa004e51a64a..a5a2914ca251dfd7d0083f7e92936f55eaceaf16 100644 --- a/DDG4/lcio/LCIOFileReader.cpp +++ b/DDG4/lcio/LCIOFileReader.cpp @@ -52,7 +52,7 @@ using namespace DD4hep::Simulation; DECLARE_GEANT4_EVENT_READER_NS(DD4hep::Simulation,LCIOFileReader) /// Initializing constructor -DD4hep::Simulation::LCIOFileReader::LCIOFileReader(const std::string& nam) +DD4hep::Simulation::LCIOFileReader::LCIOFileReader(const std::string& nam) : LCIOEventReader(nam) { m_reader = ::lcio::LCFactory::getInstance()->createLCReader(); diff --git a/DDG4/lcio/LCIOSDTestActions.cpp b/DDG4/lcio/LCIOSDTestActions.cpp index 171003684675f81f0e392c1cf2575c553b2342c7..e30c5dd3280997bb0fd489dd7d0a99b9142b1d34 100644 --- a/DDG4/lcio/LCIOSDTestActions.cpp +++ b/DDG4/lcio/LCIOSDTestActions.cpp @@ -1,5 +1,5 @@ //==================================================================== -// DDSim - LC simulation based on DD4hep +// DDSim - LC simulation based on DD4hep //-------------------------------------------------------------------- // F.Gaede, DESY //==================================================================== @@ -26,7 +26,7 @@ using namespace DD4hep; namespace Tests { // copied from Geant4SDActions.cpp (why is this not a public class ??????) - + /// Deprecated: Simple SensitiveAction class ... /** * \deprecated @@ -40,7 +40,7 @@ namespace Tests { size_t m_collectionID; // properties: - bool _detailedHitsStoring ; + bool _detailedHitsStoring ; public: // typedef SimpleHit::Contribution HitContribution; @@ -74,7 +74,7 @@ namespace Tests { Base::clear(hce); } }; - + // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Geant4SensitiveAction<SimpleTracker> @@ -92,17 +92,17 @@ namespace Tests { template <> void Geant4SensitiveAction<LcioTestTracker>::defineCollections() { m_collectionID = Base::defineCollection<lcio::SimTrackerHitImpl>(m_sensitive.readout().name()); } - + /// Method for generating hit(s) using the information of G4Step object. template <> bool Geant4SensitiveAction<LcioTestTracker>::process(G4Step* step,G4TouchableHistory* /*hist*/ ) { StepHandler h(step); - + Position prePos = h.prePos(); Position postPos = h.postPos(); Position direction = postPos - prePos; Position position = mean_direction(prePos,postPos); double hit_len = direction.R(); - + if (hit_len > 0) { double new_len = mean_length(h.preMom(),h.postMom())/hit_len; direction *= new_len/hit_len; @@ -110,10 +110,10 @@ namespace Tests { lcio::SimTrackerHitImpl* hit = new lcio::SimTrackerHitImpl; // (h.track->GetTrackID(), - // h.track->GetDefinition()->GetPDGEncoding(), - // step->GetTotalEnergyDeposit(), - // h.track->GetGlobalTime()); - + // h.track->GetDefinition()->GetPDGEncoding(), + // step->GetTotalEnergyDeposit(), + // h.track->GetGlobalTime()); + // HitContribution contrib = Hit::extractContribution(step); VolumeID cellID = volumeID( step ) ; @@ -121,7 +121,7 @@ namespace Tests { hit->setCellID1( ( cellID >> 32 ) & 0xffffffff ) ; printout(INFO,"LcioTestTracker","%s> Add hit with deposit:%f Pos:%f %f %f - cellID0: 0x%x cellID1: 0x%x", - c_name(),step->GetTotalEnergyDeposit(),position.X(),position.Y(),position.Z() , hit->getCellID0() ,hit->getCellID1() ); + c_name(),step->GetTotalEnergyDeposit(),position.X(),position.Y(),position.Z() , hit->getCellID0() ,hit->getCellID1() ); double pos[3] = {position.x(), position.y(), position.z()}; hit->setPosition( pos ) ; @@ -134,7 +134,7 @@ namespace Tests { return hit != 0; } - typedef Geant4SensitiveAction<LcioTestTracker> LcioTestTrackerAction; + typedef Geant4SensitiveAction<LcioTestTracker> LcioTestTrackerAction; } // namespace #include "DDG4/Factories.h" diff --git a/DDG4/lcio/LCIOStdHepReader.cpp b/DDG4/lcio/LCIOStdHepReader.cpp index 626b8838b893c16ff8552ad309e346e7b215f4d0..b1b61598c3055e154297ba5d76557cfd26f96120 100644 --- a/DDG4/lcio/LCIOStdHepReader.cpp +++ b/DDG4/lcio/LCIOStdHepReader.cpp @@ -48,7 +48,7 @@ DECLARE_GEANT4_EVENT_READER_NS(DD4hep::Simulation,LCIOStdHepReader) using namespace DD4hep::Simulation; /// Initializing constructor -LCIOStdHepReader::LCIOStdHepReader(const std::string& nam) +LCIOStdHepReader::LCIOStdHepReader(const std::string& nam) : LCIOEventReader(nam) { m_reader = new UTIL::LCStdHepRdr(m_name.c_str()); diff --git a/DDG4/legacy/Geant4CalorimeterSD.cpp b/DDG4/legacy/Geant4CalorimeterSD.cpp index 5d38f53f34c37e261152f253facc8f4bb259905c..c65857d99843197ecb84f0c3dbfc1cd4e1d2b09b 100644 --- a/DDG4/legacy/Geant4CalorimeterSD.cpp +++ b/DDG4/legacy/Geant4CalorimeterSD.cpp @@ -23,34 +23,34 @@ using namespace DD4hep::Geometry; */ namespace DD4hep { namespace Simulation { - /// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - /// Geant4GenericSD<Calorimeter> - /// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - struct Calorimeter {}; - /// Method for generating hit(s) using the information of G4Step object. - template <> bool Geant4GenericSD<Calorimeter>::buildHits(G4Step* step,G4TouchableHistory*) { - StepHandler h(step); - Position pos = 0.5 * (h.prePos() + h.postPos()); - HitContribution contrib = Geant4Hit::extractContribution(step); - Geant4CalorimeterHit* hit=find(collection(0),HitPositionCompare<Geant4CalorimeterHit>(pos)); + /// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + /// Geant4GenericSD<Calorimeter> + /// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + struct Calorimeter {}; + /// Method for generating hit(s) using the information of G4Step object. + template <> bool Geant4GenericSD<Calorimeter>::buildHits(G4Step* step,G4TouchableHistory*) { + StepHandler h(step); + Position pos = 0.5 * (h.prePos() + h.postPos()); + HitContribution contrib = Geant4Hit::extractContribution(step); + Geant4CalorimeterHit* hit=find(collection(0),HitPositionCompare<Geant4CalorimeterHit>(pos)); + + // G4cout << "----------- Geant4GenericSD<Calorimeter>::buildHits : position : " << pos << G4endl ; - // G4cout << "----------- Geant4GenericSD<Calorimeter>::buildHits : position : " << pos << G4endl ; + if ( !hit ) { - if ( !hit ) { + hit = new Geant4CalorimeterHit(pos) ; - hit = new Geant4CalorimeterHit(pos) ; + hit->cellID = getVolumeID( step ) ; - hit->cellID = getVolumeID( step ) ; + collection(0)->insert(hit) ; + } + hit->truth.push_back(contrib); + hit->energyDeposit += contrib.deposit; - collection(0)->insert(hit) ; + return true; } - hit->truth.push_back(contrib); - hit->energyDeposit += contrib.deposit; - - return true; - } typedef Geant4GenericSD<Calorimeter> Geant4Calorimeter; -}} // End namespace DD4hep::Simulation + }} // End namespace DD4hep::Simulation DECLARE_GEANT4SENSITIVEDETECTOR(Geant4Calorimeter) @@ -59,52 +59,52 @@ DECLARE_GEANT4SENSITIVEDETECTOR(Geant4Calorimeter) */ namespace DD4hep { namespace Simulation { - /// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - /// Geant4GenericSD<OpticalCalorimeter> - /// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - enum { Edep_type=0, Cerenkov_type=1 }; - struct OpticalCalorimeter {}; - template <> class Geant4GenericSD<OpticalCalorimeter> : public Geant4GenericSD<Calorimeter> { - public: - /// Constructor. The sensitive detector element is identified by the detector name - Geant4GenericSD(const string& name, LCDD& lcdd) - : Geant4GenericSD<Calorimeter>(name,lcdd) { } - - /// Initialize the sensitive detector for the usage of a single hit collection - bool defineCollection(const string& coll_name) { - Geant4SensitiveDetector::defineCollection("Edep_" + coll_name); - Geant4SensitiveDetector::defineCollection("Ceren_" + coll_name); - return true; - } - - /// Method for generating hit(s) using the information of G4Step object. - virtual G4bool ProcessHits(G4Step* step,G4TouchableHistory* history) { - G4Track * track = step->GetTrack(); - - // check that particle is optical photon: - if( track->GetDefinition() != G4OpticalPhoton::OpticalPhotonDefinition() ) { - return this->Geant4GenericSD<Calorimeter>::ProcessHits(step,history); + /// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + /// Geant4GenericSD<OpticalCalorimeter> + /// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + enum { Edep_type=0, Cerenkov_type=1 }; + struct OpticalCalorimeter {}; + template <> class Geant4GenericSD<OpticalCalorimeter> : public Geant4GenericSD<Calorimeter> { + public: + /// Constructor. The sensitive detector element is identified by the detector name + Geant4GenericSD(const string& name, LCDD& lcdd) + : Geant4GenericSD<Calorimeter>(name,lcdd) { } + + /// Initialize the sensitive detector for the usage of a single hit collection + bool defineCollection(const string& coll_name) { + Geant4SensitiveDetector::defineCollection("Edep_" + coll_name); + Geant4SensitiveDetector::defineCollection("Ceren_" + coll_name); + return true; } - else if ( track->GetCreatorProcess()->G4VProcess::GetProcessName() != "Cerenkov") { - track->SetTrackStatus(fStopAndKill); - return false; - } - else { - StepHandler h(step); - HitContribution contrib = Geant4Hit::extractContribution(step); - Position pos = h.prePos(); - Geant4CalorimeterHit* hit=find(collection(Cerenkov_type),HitPositionCompare<Geant4CalorimeterHit>(pos)); - if ( !hit ) { - collection(Cerenkov_type)->insert(hit=new Geant4CalorimeterHit(pos)); - } - hit->energyDeposit += contrib.deposit; - hit->truth.push_back(contrib); - track->SetTrackStatus(fStopAndKill); // don't step photon any further - return true; + + /// Method for generating hit(s) using the information of G4Step object. + virtual G4bool ProcessHits(G4Step* step,G4TouchableHistory* history) { + G4Track * track = step->GetTrack(); + + // check that particle is optical photon: + if( track->GetDefinition() != G4OpticalPhoton::OpticalPhotonDefinition() ) { + return this->Geant4GenericSD<Calorimeter>::ProcessHits(step,history); + } + else if ( track->GetCreatorProcess()->G4VProcess::GetProcessName() != "Cerenkov") { + track->SetTrackStatus(fStopAndKill); + return false; + } + else { + StepHandler h(step); + HitContribution contrib = Geant4Hit::extractContribution(step); + Position pos = h.prePos(); + Geant4CalorimeterHit* hit=find(collection(Cerenkov_type),HitPositionCompare<Geant4CalorimeterHit>(pos)); + if ( !hit ) { + collection(Cerenkov_type)->insert(hit=new Geant4CalorimeterHit(pos)); + } + hit->energyDeposit += contrib.deposit; + hit->truth.push_back(contrib); + track->SetTrackStatus(fStopAndKill); // don't step photon any further + return true; + } } - } - }; + }; typedef Geant4GenericSD<OpticalCalorimeter> Geant4OpticalCalorimeter; -}} // End namespace DD4hep::Simulation + }} // End namespace DD4hep::Simulation DECLARE_GEANT4SENSITIVEDETECTOR(Geant4OpticalCalorimeter) diff --git a/DDG4/legacy/Geant4TrackerCombineSD.cpp b/DDG4/legacy/Geant4TrackerCombineSD.cpp index 38405a6bb227c2f63d6a7d286af2d0b8509c14be..b6772fcf8a46d87ecf7a81b9021fcbdc01f893f2 100644 --- a/DDG4/legacy/Geant4TrackerCombineSD.cpp +++ b/DDG4/legacy/Geant4TrackerCombineSD.cpp @@ -28,45 +28,45 @@ namespace DD4hep { namespace Simulation { TrackerCombine() : pre(), post(), track(0), e_cut(0.0), current(-1) { } void start(G4Step* step, G4StepPoint* point) { - pre.storePoint(step,point); - current = pre.truth.trackID; - track = step->GetTrack(); - post = pre; + pre.storePoint(step,point); + current = pre.truth.trackID; + track = step->GetTrack(); + post = pre; } void update(G4Step* step) { - post.storePoint(step,step->GetPostStepPoint()); - pre.truth.deposit += post.truth.deposit; + post.storePoint(step,step->GetPostStepPoint()); + pre.truth.deposit += post.truth.deposit; } void clear() { - pre.truth.clear(); - current = -1; - track = 0; + pre.truth.clear(); + current = -1; + track = 0; } Geant4TrackerHit* extractHit(Geant4SensitiveDetector::HitCollection* c) { - if ( current == -1 || !track ) { - return 0; - } - else if ( pre.truth.deposit <= e_cut && !Geant4Hit::isGeantino(track) ) { - clear(); - return 0; - } - Position pos = 0.5 * (pre.position + post.position); - Momentum mom = 0.5 * (pre.momentum + post.momentum); - double path_len = (post.position - pre.position).R(); - Geant4TrackerHit* hit = new Geant4TrackerHit(pre.truth.trackID, - pre.truth.pdgID, - pre.truth.deposit, - pre.truth.time); - hit->position = pos; - hit->momentum = mom; - hit->length = path_len; - clear(); - c->insert(hit); - return hit; + if ( current == -1 || !track ) { + return 0; + } + else if ( pre.truth.deposit <= e_cut && !Geant4Hit::isGeantino(track) ) { + clear(); + return 0; + } + Position pos = 0.5 * (pre.position + post.position); + Momentum mom = 0.5 * (pre.momentum + post.momentum); + double path_len = (post.position - pre.position).R(); + Geant4TrackerHit* hit = new Geant4TrackerHit(pre.truth.trackID, + pre.truth.pdgID, + pre.truth.deposit, + pre.truth.time); + hit->position = pos; + hit->momentum = mom; + hit->length = path_len; + clear(); + c->insert(hit); + return hit; } }; - /// Method invoked at the begining of each event. + /// Method invoked at the begining of each event. template <> void Geant4GenericSD<TrackerCombine>::Initialize(G4HCofThisEvent* HCE) { userData.e_cut = m_sensitive.energyCutoff(); this->Geant4SensitiveDetector::Initialize(HCE); @@ -84,8 +84,8 @@ namespace DD4hep { namespace Simulation { bool return_code = false; if ( !userData.track || userData.current != h.track->GetTrackID() ) { - return_code = userData.extractHit(collection(0)) != 0; - userData.start(step, h.pre); + return_code = userData.extractHit(collection(0)) != 0; + userData.start(step, h.pre); } // ....update ..... @@ -93,21 +93,21 @@ namespace DD4hep { namespace Simulation { void *prePV = h.volume(h.pre), *postPV = h.volume(h.post); if ( prePV != postPV ) { - void* postSD = h.sd(h.post); - return_code = userData.extractHit(collection(0)) != 0; - if ( 0 != postSD ) { - void* preSD = h.sd(h.pre); - if ( preSD == postSD ) { - userData.start(step,h.post); - } - } + void* postSD = h.sd(h.post); + return_code = userData.extractHit(collection(0)) != 0; + if ( 0 != postSD ) { + void* preSD = h.sd(h.pre); + if ( preSD == postSD ) { + userData.start(step,h.post); + } + } } else if ( userData.track->GetTrackStatus() == fStopAndKill ) { - return_code = userData.extractHit(collection(0)) != 0; + return_code = userData.extractHit(collection(0)) != 0; } return return_code; } typedef Geant4GenericSD<TrackerCombine> Geant4TrackerCombine; -}} // End namespace DD4hep::Simulation + }} // End namespace DD4hep::Simulation DECLARE_GEANT4SENSITIVEDETECTOR(Geant4TrackerCombine) diff --git a/DDG4/legacy/Geant4TrackerSD.cpp b/DDG4/legacy/Geant4TrackerSD.cpp index 1617cecb02dc07fd3cc42a309beea215b4544434..c096d85b070f7ff354cbf6de4d59af4604d54c88 100644 --- a/DDG4/legacy/Geant4TrackerSD.cpp +++ b/DDG4/legacy/Geant4TrackerSD.cpp @@ -14,18 +14,18 @@ //#include "DDSegmentation/BitField64.h" // C include files -#include <stdexcept> +#include <stdexcept> /* * DD4hep::Simulation namespace declaration */ namespace DD4hep { namespace Simulation { - /// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - /// Geant4GenericSD<Tracker> - /// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - struct Tracker {}; - /// Method for generating hit(s) using the information of G4Step object. + /// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + /// Geant4GenericSD<Tracker> + /// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + struct Tracker {}; + /// Method for generating hit(s) using the information of G4Step object. template <> bool Geant4GenericSD<Tracker>::buildHits(G4Step* step,G4TouchableHistory* /*hist*/ ) { StepHandler h(step); @@ -35,27 +35,27 @@ namespace DD4hep { namespace Simulation { Position position = mean_direction(prePos,postPos); double hit_len = direction.R(); if (hit_len > 0) { - double new_len = mean_length(h.preMom(),h.postMom())/hit_len; - direction *= new_len/hit_len; + double new_len = mean_length(h.preMom(),h.postMom())/hit_len; + direction *= new_len/hit_len; } - + // G4cout << "----------- Geant4GenericSD<Tracker>::buildHits : position : " << prePos << G4endl ; - - Geant4TrackerHit* hit = - new Geant4TrackerHit(h.track->GetTrackID(), - h.track->GetDefinition()->GetPDGEncoding(), - step->GetTotalEnergyDeposit(), - h.track->GetGlobalTime()); + + Geant4TrackerHit* hit = + new Geant4TrackerHit(h.track->GetTrackID(), + h.track->GetDefinition()->GetPDGEncoding(), + step->GetTotalEnergyDeposit(), + h.track->GetGlobalTime()); if ( hit ) { - HitContribution contrib = Geant4Hit::extractContribution(step); - hit->cellID = getVolumeID( step ) ; - hit->energyDeposit = contrib.deposit ; - hit->position = position; - hit->momentum = direction; - hit->length = hit_len; - collection(0)->insert(hit); - return 1; + HitContribution contrib = Geant4Hit::extractContribution(step); + hit->cellID = getVolumeID( step ) ; + hit->energyDeposit = contrib.deposit ; + hit->position = position; + hit->momentum = direction; + hit->length = hit_len; + collection(0)->insert(hit); + return 1; } throw std::runtime_error("new() failed: Cannot allocate hit object"); } diff --git a/DDG4/plugins/Geant4EscapeCounter.cpp b/DDG4/plugins/Geant4EscapeCounter.cpp index 0cb563facd3324db413e30894594dcd359ea1c85..3800729e715a95cd7491d25aff7efa635760697d 100644 --- a/DDG4/plugins/Geant4EscapeCounter.cpp +++ b/DDG4/plugins/Geant4EscapeCounter.cpp @@ -72,7 +72,7 @@ using namespace DD4hep::Simulation; /// Standard constructor Geant4EscapeCounter::Geant4EscapeCounter(Geant4Context* context, const string& nam, DetElement det, LCDD& lcdd) -: Geant4Sensitive(context, nam, det, lcdd) +: Geant4Sensitive(context, nam, det, lcdd) { string coll_name = name()+"Hits"; m_needsControl = true; @@ -102,10 +102,10 @@ bool Geant4EscapeCounter::process(G4Step* step, G4TouchableHistory* /* history * hit->length = 0; coll->add(hit); mark(h.track); - + print("+++ Track:%4d %8.2f MeV [%s] %s Geant4 path:%s", - h.trkID(),h.trkEnergy()/CLHEP::MeV,th.name().c_str(), - th.creatorName().c_str(),path.c_str()); + h.trkID(),h.trkEnergy()/CLHEP::MeV,th.name().c_str(), + th.creatorName().c_str(),path.c_str()); // Kill track, so that it does no longer participate in the propagation h.track->SetTrackStatus(fStopAndKill); return true; diff --git a/DDG4/plugins/Geant4EventReaderHepEvt.cpp b/DDG4/plugins/Geant4EventReaderHepEvt.cpp index 0a7e288b3c8506bfd5683e1b43edd0d84aad488e..ce559443d31c17a38f11c2bab455542b50874d49 100644 --- a/DDG4/plugins/Geant4EventReaderHepEvt.cpp +++ b/DDG4/plugins/Geant4EventReaderHepEvt.cpp @@ -18,8 +18,8 @@ namespace DD4hep { namespace Simulation { /// Class to populate Geant4 primaries from StdHep files. - /** - * Class to populate Geant4 primary particles and vertices from a + /** + * Class to populate Geant4 primary particles and vertices from a * file in HEPEvt format (ASCII) * * \author P.Kostka (main author) @@ -112,7 +112,7 @@ Geant4EventReaderHepEvt::~Geant4EventReaderHepEvt() { } /// Read an event and fill a vector of MCParticles. -Geant4EventReader::EventReaderStatus +Geant4EventReader::EventReaderStatus Geant4EventReaderHepEvt::readParticles(int /* event_number */, vector<Particle*>& particles) { // First check the input file status @@ -149,23 +149,23 @@ Geant4EventReaderHepEvt::readParticles(int /* event_number */, vector<Particle*> double VHEP2; // y vertex position in mm double VHEP3; // z vertex position in mm double VHEP4; // production time in mm/c - + vector<int> daughter1; vector<int> daughter2; - + for( int IHEP=0; IHEP<NHEP; IHEP++ ) { if ( m_format == HEPEvtShort ) m_input >> ISTHEP >> IDHEP >> JDAHEP1 >> JDAHEP2 - >> PHEP1 >> PHEP2 >> PHEP3 >> PHEP5; + >> PHEP1 >> PHEP2 >> PHEP3 >> PHEP5; else - m_input >> ISTHEP >> IDHEP - >> JMOHEP1 >> JMOHEP2 - >> JDAHEP1 >> JDAHEP2 - >> PHEP1 >> PHEP2 >> PHEP3 - >> PHEP4 >> PHEP5 - >> VHEP1 >> VHEP2 >> VHEP3 - >> VHEP4; - + m_input >> ISTHEP >> IDHEP + >> JMOHEP1 >> JMOHEP2 + >> JDAHEP1 >> JDAHEP2 + >> PHEP1 >> PHEP2 >> PHEP3 + >> PHEP4 >> PHEP5 + >> VHEP1 >> VHEP2 >> VHEP3 + >> VHEP4; + if(m_input.eof()) return EVENT_READER_IO_ERROR; // @@ -184,7 +184,7 @@ Geant4EventReaderHepEvt::readParticles(int /* event_number */, vector<Particle*> // Mass p->mass = PHEP5*GeV; // - // Vertex + // Vertex // (missing information in HEPEvt files) p->vsx = 0.0; p->vsy = 0.0; @@ -197,7 +197,7 @@ Geant4EventReaderHepEvt::readParticles(int /* event_number */, vector<Particle*> // Simulator status 0 until simulator acts on it p->status = 0; if ( ISTHEP == 0 ) status.set(G4PARTICLE_GEN_EMPTY); - else if ( ISTHEP == 1 ) status.set(G4PARTICLE_GEN_STABLE); + else if ( ISTHEP == 1 ) status.set(G4PARTICLE_GEN_STABLE); else if ( ISTHEP == 2 ) status.set(G4PARTICLE_GEN_DECAYED); else if ( ISTHEP == 3 ) status.set(G4PARTICLE_GEN_DOCUMENTATION); else status.set(G4PARTICLE_GEN_DOCUMENTATION); @@ -218,7 +218,7 @@ Geant4EventReaderHepEvt::readParticles(int /* event_number */, vector<Particle*> // // Now make a second loop over the particles, checking the daughter - // information. This is not always consistent with parent + // information. This is not always consistent with parent // information, and this utility assumes all parents listed are // parents and all daughters listed are daughters // @@ -227,10 +227,10 @@ Geant4EventReaderHepEvt::readParticles(int /* event_number */, vector<Particle*> Particle* m_part; ParticleHandler(Particle* p) : m_part(p) {} void addParent(const Particle* p) { - m_part->parents.insert(p->id); + m_part->parents.insert(p->id); } Particle* findParent(const Particle* p) { - return m_part->parents.find(p->id)==m_part->parents.end() ? 0 : m_part; + return m_part->parents.find(p->id)==m_part->parents.end() ? 0 : m_part; } }; @@ -241,30 +241,30 @@ Geant4EventReaderHepEvt::readParticles(int /* event_number */, vector<Particle*> // // Get the daughter information, discarding extra information // sometimes stored in daughter variables. - // + // int fd = daughter1[IHEP] - 1; int ld = daughter2[IHEP] - 1; - + // - // As with the parents, look for range, 2 discreet or 1 discreet + // As with the parents, look for range, 2 discreet or 1 discreet // daughter. if( (fd > -1) && (ld > -1) ) { if(ld >= fd) { - for(int id=fd;id<ld+1;id++) { - // - // Get the daughter, and see if it already lists this particle as - // a parent. If not, add this particle as a parent - // - ParticleHandler part(particles[id]); - if ( !part.findParent(mcp) ) part.addParent(mcp); - } + for(int id=fd;id<ld+1;id++) { + // + // Get the daughter, and see if it already lists this particle as + // a parent. If not, add this particle as a parent + // + ParticleHandler part(particles[id]); + if ( !part.findParent(mcp) ) part.addParent(mcp); + } } else { // Same logic, discrete cases - ParticleHandler part_fd(particles[fd]); - if ( !part_fd.findParent(mcp) ) part_fd.addParent(mcp); + ParticleHandler part_fd(particles[fd]); + if ( !part_fd.findParent(mcp) ) part_fd.addParent(mcp); - ParticleHandler part_ld(particles[ld]); - if ( !part_ld.findParent(mcp) ) part_ld.addParent(mcp); + ParticleHandler part_ld(particles[ld]); + if ( !part_ld.findParent(mcp) ) part_ld.addParent(mcp); } } else if(fd > -1) { diff --git a/DDG4/plugins/Geant4EventReaderHepMC.cpp b/DDG4/plugins/Geant4EventReaderHepMC.cpp index 7bef3d9818d9bf1fdb0c82a4b39673ee3ec19943..6051f82c2e7324075e446ab2b3b8f707fc8dbc26 100644 --- a/DDG4/plugins/Geant4EventReaderHepMC.cpp +++ b/DDG4/plugins/Geant4EventReaderHepMC.cpp @@ -21,8 +21,8 @@ namespace DD4hep { namespace HepMC { class EventStream; } /// Class to populate Geant4 primaries from StdHep files. - /** - * Class to populate Geant4 primary particles and vertices from a + /** + * Class to populate Geant4 primary particles and vertices from a * file in HEPEvt format (ASCII) * * \author P.Kostka (main author) @@ -85,17 +85,17 @@ namespace DD4hep { class EventHeader { public: - int id; - int num_vertices; - int bp1, bp2; - int signal_process_id; - int signal_process_vertex; - float scale; - float alpha_qcd; - float alpha_qed; - vector<float> weights; - vector<long> random; - EventHeader() {} + int id; + int num_vertices; + int bp1, bp2; + int signal_process_id; + int signal_process_vertex; + float scale; + float alpha_qcd; + float alpha_qed; + vector<float> weights; + vector<long> random; + EventHeader() {} }; /// The known_io enum is used to track which type of input is being read @@ -103,35 +103,35 @@ namespace DD4hep { class EventStream { public: - typedef std::map<int,Geant4Vertex*> Vertices; - typedef std::map<int,Geant4Particle*> Particles; - - istream& instream; - - // io information - string key; - double mom_unit, pos_unit; - int io_type; - - float xsection, xsection_err; - EventHeader header; - Vertices m_vertices; - Particles m_particles; - - - EventStream(istream& in) : instream(in), io_type(0) - { use_default_units(); } - /// Check if data stream is in proper state and has data - bool ok() const; - Geant4Vertex* vertex(int i); - Particles& particles() { return m_particles; } - Vertices& vertices() { return m_vertices; } - void set_io(int typ, const string& k) - { io_type = typ; key = k; } - void use_default_units() - { mom_unit = MeV; pos_unit = mm; } - bool read(); - void clear(); + typedef std::map<int,Geant4Vertex*> Vertices; + typedef std::map<int,Geant4Particle*> Particles; + + istream& instream; + + // io information + string key; + double mom_unit, pos_unit; + int io_type; + + float xsection, xsection_err; + EventHeader header; + Vertices m_vertices; + Particles m_particles; + + + EventStream(istream& in) : instream(in), io_type(0) + { use_default_units(); } + /// Check if data stream is in proper state and has data + bool ok() const; + Geant4Vertex* vertex(int i); + Particles& particles() { return m_particles; } + Vertices& vertices() { return m_vertices; } + void set_io(int typ, const string& k) + { io_type = typ; key = k; } + void use_default_units() + { mom_unit = MeV; pos_unit = mm; } + bool read(); + void clear(); }; char get_input(istream& is, istringstream& iline); @@ -185,12 +185,12 @@ Geant4EventReaderHepMC::readParticles(int /* ev_id */, Particles& output) { for(Particles::const_iterator k=output.begin(); k != output.end(); ++k) { Geant4ParticleHandle p(*k); printout(INFO,m_name, - "+++ %s ID:%3d status:%08X typ:%9d Mom:(%+.2e,%+.2e,%+.2e)[MeV] " - "time: %+.2e [ns] #Dau:%3d #Par:%1d", - "",p->id,p->status,p->pdgID, - p->psx/MeV,p->psy/MeV,p->psz/MeV,p->time/ns, - p->daughters.size(), - p->parents.size()); + "+++ %s ID:%3d status:%08X typ:%9d Mom:(%+.2e,%+.2e,%+.2e)[MeV] " + "time: %+.2e [ns] #Dau:%3d #Par:%1d", + "",p->id,p->status,p->pdgID, + p->psx/MeV,p->psy/MeV,p->psz/MeV,p->time/ns, + p->daughters.size(), + p->parents.size()); //output.push_back(p); } return EVENT_READER_OK; @@ -214,7 +214,7 @@ void HepMC::fix_particles(EventStream& info) { p->vez = v->z; v->in.insert(p->id); for(id=v->out.begin(); id!=v->out.end();++id) - p->daughters.insert(*id); + p->daughters.insert(*id); } } EventStream::Vertices::iterator j; @@ -224,7 +224,7 @@ void HepMC::fix_particles(EventStream& info) { EventStream::Particles::iterator ipp = parts.find(*ip); Geant4Particle* p = (*ipp).second; for (id=v->in.begin(); id!=v->in.end();++id) { - p->parents.insert(*id); + p->parents.insert(*id); } } } @@ -235,8 +235,8 @@ void HepMC::fix_particles(EventStream& info) { Geant4ParticleHandle p((*i).second); if ( p->parents.size() == 0 ) { for(id=p->daughters.begin(); id!=p->daughters.end();++id) { - Geant4Particle *pp = parts[*id]; - beam.push_back(pp); + Geant4Particle *pp = parts[*id]; + beam.push_back(pp); } } } @@ -256,14 +256,14 @@ char HepMC::get_input(istream& is, istringstream& iline) { char value = is.peek(); if ( !is ) { // make sure the stream is valid cerr << "StreamHelpers: setting badbit." << endl; - is.clear(ios::badbit); + is.clear(ios::badbit); return -1; } string line, firstc; getline(is,line); if ( !is ) { // make sure the stream is valid cerr << "StreamHelpers: setting badbit." << endl; - is.clear(ios::badbit); + is.clear(ios::badbit); return -1; } iline.clear(); @@ -274,9 +274,9 @@ char HepMC::get_input(istream& is, istringstream& iline) { int HepMC::read_until_event_end(istream & is) { string line; - while ( is ) { + while ( is ) { char val = is.peek(); - if( val == 'E' ) { // next event + if( val == 'E' ) { // next event return 1; } getline(is,line); @@ -330,7 +330,7 @@ int HepMC::read_particle(EventStream &info, istringstream& input, Geant4Particle p->psy *= info.mom_unit; p->psz *= info.mom_unit; ene *= info.mom_unit; - if ( !input ) + if ( !input ) return 0; else if ( info.io_type != ascii ) { input >> p->mass; @@ -341,7 +341,7 @@ int HepMC::read_particle(EventStream &info, istringstream& input, Geant4Particle } // Reuse here the secondaries to store the end-vertex ID input >> stat >> theta >> phi >> p->secondaries >> size; - if(!input) + if(!input) return 0; // @@ -349,7 +349,7 @@ int HepMC::read_particle(EventStream &info, istringstream& input, Geant4Particle // Simulator status 0 until simulator acts on it status.clear(); if ( stat == 0 ) status.set(G4PARTICLE_GEN_EMPTY); - else if ( stat == 0x1 ) status.set(G4PARTICLE_GEN_STABLE); + else if ( stat == 0x1 ) status.set(G4PARTICLE_GEN_STABLE); else if ( stat == 0x2 ) status.set(G4PARTICLE_GEN_DECAYED); else if ( stat == 0x3 ) status.set(G4PARTICLE_GEN_DOCUMENTATION); else if ( stat == 0x4 ) status.set(G4PARTICLE_GEN_DOCUMENTATION); @@ -369,9 +369,9 @@ int HepMC::read_vertex(EventStream &info, istream& is, istringstream & input) Geant4Vertex* v = new Geant4Vertex(); Geant4Particle* p; - input >> id >> dummy >> v->x >> v->y >> v->z >> v->time - >> num_orphans_in >> num_particles_out >> weights_size; - if(!input) + input >> id >> dummy >> v->x >> v->y >> v->z >> v->time + >> num_orphans_in >> num_particles_out >> weights_size; + if(!input) return 0; v->x *= info.pos_unit; v->y *= info.pos_unit; @@ -421,7 +421,7 @@ int HepMC::read_vertex(EventStream &info, istream& is, istringstream & input) } return 1; } - + int HepMC::read_event_header(EventStream &info, istringstream & input, EventHeader& header) { // read values into temp variables, then fill GenEvent int random_states_size = 0, nmpi = -1; @@ -477,7 +477,7 @@ int HepMC::read_units(EventStream &info, istringstream & input) { else if ( mom == "MEV" ) info.mom_unit = MeV; else if ( mom == "GEV" ) info.mom_unit = GeV; else if ( mom == "TEV" ) info.mom_unit = TeV; - + if ( pos == "MM" ) info.pos_unit = mm; else if ( pos == "CM" ) info.pos_unit = cm; else if ( pos == "M" ) info.pos_unit = m; @@ -488,9 +488,9 @@ int HepMC::read_units(EventStream &info, istringstream & input) { int HepMC::read_heavy_ion(EventStream &, istringstream & input) { // read values into temp variables, then create a new HeavyIon object - int nh =0, np =0, nt =0, nc =0, + int nh =0, np =0, nt =0, nc =0, neut = 0, prot = 0, nw =0, nwn =0, nwnw =0; - float impact = 0., plane = 0., xcen = 0., inel = 0.; + float impact = 0., plane = 0., xcen = 0., inel = 0.; input >> nh >> np >> nt >> nc >> neut >> prot >> nw >> nwn >> nwnw; input >> impact >> plane >> xcen >> inel; /* @@ -515,7 +515,7 @@ int HepMC::read_heavy_ion(EventStream &, istringstream & input) { int HepMC::read_pdf(EventStream &, istringstream & input) { // read values into temp variables, then create a new PdfInfo object int id1 =0, id2 =0, pdf_id1=0, pdf_id2=0; - double x1 = 0., x2 = 0., scale = 0., pdf1 = 0., pdf2 = 0.; + double x1 = 0., x2 = 0., scale = 0., pdf1 = 0., pdf2 = 0.; input >> id1 ; if ( input.fail() ) return 0; @@ -531,7 +531,7 @@ int HepMC::read_pdf(EventStream &, istringstream & input) { input >> pdf_id1 >> pdf_id2; } /* - cerr << "Reading pdf, but igoring data!" << endl; + cerr << "Reading pdf, but igoring data!" << endl; pdf->set_id1( id1 ); pdf->set_id2( id2 ); pdf->set_pdf_id1( pdf_id1 ); @@ -602,73 +602,73 @@ bool HepMC::EventStream::read() { // search for event listing key before first event only. key = key.substr(0,key.find('\r')); if ( key == "H" && (this->io_type == gen || this->io_type == extascii) ) { - read_heavy_ion(info, input_line); - break; + read_heavy_ion(info, input_line); + break; } else if( key == "HepMC::IO_GenEvent-START_EVENT_LISTING" ) - this->set_io(gen,key); + this->set_io(gen,key); else if( key == "HepMC::IO_Ascii-START_EVENT_LISTING" ) - this->set_io(ascii,key); + this->set_io(ascii,key); else if( key == "HepMC::IO_ExtendedAscii-START_EVENT_LISTING" ) - this->set_io(extascii,key); + this->set_io(extascii,key); else if( key == "HepMC::IO_Ascii-START_PARTICLE_DATA" ) - this->set_io(ascii_pdt,key); + this->set_io(ascii_pdt,key); else if( key == "HepMC::IO_ExtendedAscii-START_PARTICLE_DATA" ) - this->set_io(extascii_pdt,key); + this->set_io(extascii_pdt,key); else if( key == "HepMC::IO_GenEvent-END_EVENT_LISTING" ) - iotype = gen; - else if( key == "HepMC::IO_Ascii-END_EVENT_LISTING" ) - iotype = ascii; - else if( key == "HepMC::IO_ExtendedAscii-END_EVENT_LISTING" ) - iotype = extascii; - else if( key == "HepMC::IO_Ascii-END_PARTICLE_DATA" ) - iotype = ascii_pdt; - else if( key == "HepMC::IO_ExtendedAscii-END_PARTICLE_DATA" ) - iotype = extascii_pdt; + iotype = gen; + else if( key == "HepMC::IO_Ascii-END_EVENT_LISTING" ) + iotype = ascii; + else if( key == "HepMC::IO_ExtendedAscii-END_EVENT_LISTING" ) + iotype = extascii; + else if( key == "HepMC::IO_Ascii-END_PARTICLE_DATA" ) + iotype = ascii_pdt; + else if( key == "HepMC::IO_ExtendedAscii-END_PARTICLE_DATA" ) + iotype = extascii_pdt; if( iotype != 0 && this->io_type != iotype ) { - cerr << "GenEvent::find_end_key: iotype keys have changed. " - << "MALFORMED INPUT" << endl; - instream.clear(ios::badbit); - return false; + cerr << "GenEvent::find_end_key: iotype keys have changed. " + << "MALFORMED INPUT" << endl; + instream.clear(ios::badbit); + return false; } else if ( iotype != 0 ) { - break; + break; } continue; - } - case 'E': // deal with the event line + } + case 'E': // deal with the event line if ( !read_event_header(info, input_line, this->header) ) - goto Skip; + goto Skip; event_read = true; continue; - case 'N': // get weight names + case 'N': // get weight names if ( !read_weight_names(info, input_line) ) - goto Skip; + goto Skip; continue; - case 'U': // get unit information if it exists + case 'U': // get unit information if it exists if ( !read_units(info, input_line) ) - goto Skip; + goto Skip; continue; - case 'C': // we have a GenCrossSection line + case 'C': // we have a GenCrossSection line if ( !read_cross_section(info, input_line) ) - goto Skip; + goto Skip; continue; case 'V': // Read vertex with particles if ( !read_vertex(info, instream, input_line) ) - goto Skip; + goto Skip; continue; case 'F': // Read PDF if ( !read_pdf(info, input_line) ) - goto Skip; + goto Skip; continue; - case 'P': // we should not find this line + case 'P': // we should not find this line cerr << "streaming input: found unexpected Particle line." << endl; continue; diff --git a/DDG4/plugins/Geant4FieldSetup.cpp b/DDG4/plugins/Geant4FieldSetup.cpp index 749e37207e091ff55ddacd0552b95c27d44b1963..fd275aacca5ec2b6f12725383bf74a614845a9cd 100644 --- a/DDG4/plugins/Geant4FieldSetup.cpp +++ b/DDG4/plugins/Geant4FieldSetup.cpp @@ -54,7 +54,7 @@ static long setup_fields(lcdd_t& lcdd, const DD4hep::Simulation::Geant4Converter G4FieldManager* fieldMgr = 0; G4TransportationManager* tr = 0; G4PropagatorInField* propagator = 0; - G4ChordFinder* chordFinder = 0; + G4ChordFinder* chordFinder = 0; lcdd_t::PropertyValues::const_iterator iV; diff --git a/DDG4/plugins/Geant4HitExtractor.cpp b/DDG4/plugins/Geant4HitExtractor.cpp index efeace86c8d66e7e340dea7a347204623d5729c8..9b4bcc4f4017cbd9bdf8c15f00272e32d5734322 100644 --- a/DDG4/plugins/Geant4HitExtractor.cpp +++ b/DDG4/plugins/Geant4HitExtractor.cpp @@ -30,11 +30,11 @@ namespace DD4hep { ~SimulationHit() {} /// Assignment operator SimulationHit& operator=(const SimulationHit& c) { - if ( this != &c ) { - position = c.position; - deposit = c.deposit; - } - return *this; + if ( this != &c ) { + position = c.position; + deposit = c.deposit; + } + return *this; } }; } @@ -49,13 +49,13 @@ static void* _convertHitCollection(const char* source) { for(std::vector<SimpleHit*>::const_iterator k=c->begin(); k!=c->end(); ++k) { SimpleTracker::Hit* trh = dynamic_cast<SimpleTracker::Hit*>(*k); if ( trh ) { - pv->push_back(SimulationHit(trh->position, trh->energyDeposit)); - continue; + pv->push_back(SimulationHit(trh->position, trh->energyDeposit)); + continue; } SimpleCalorimeter::Hit* cah = dynamic_cast<SimpleCalorimeter::Hit*>(*k); if ( cah ) { - pv->push_back(SimulationHit(cah->position, cah->energyDeposit)); - continue; + pv->push_back(SimulationHit(cah->position, cah->energyDeposit)); + continue; } } } diff --git a/DDG4/plugins/Geant4MaterialScanner.cpp b/DDG4/plugins/Geant4MaterialScanner.cpp index 379bf106b7aa3df97007ff9cfc22a8ae777bb810..59614677f46182214bdeaace2b84139529e7f1ac 100644 --- a/DDG4/plugins/Geant4MaterialScanner.cpp +++ b/DDG4/plugins/Geant4MaterialScanner.cpp @@ -32,19 +32,19 @@ namespace DD4hep { /// Structure to hold the information of one simulation step. class StepInfo { public: - /// Pre-step and Post-step position - Position pre, post; - /// Reference to the logical volue - const G4LogicalVolume* volume; - - /// Initializing constructor - StepInfo(const Position& pre, const Position& post, const G4LogicalVolume* volume); - /// Copy constructor - StepInfo(const StepInfo& c); - /// Default destructor - ~StepInfo() {} - /// Assignment operator - StepInfo& operator=(const StepInfo& c); + /// Pre-step and Post-step position + Position pre, post; + /// Reference to the logical volue + const G4LogicalVolume* volume; + + /// Initializing constructor + StepInfo(const Position& pre, const Position& post, const G4LogicalVolume* volume); + /// Copy constructor + StepInfo(const StepInfo& c); + /// Default destructor + ~StepInfo() {} + /// Assignment operator + StepInfo& operator=(const StepInfo& c); }; typedef std::vector<StepInfo*> Steps; @@ -119,7 +119,7 @@ Geant4MaterialScanner::StepInfo& Geant4MaterialScanner::StepInfo::operator=(cons /// Standard constructor Geant4MaterialScanner::Geant4MaterialScanner(Geant4Context* context, const string& name) -: Geant4SteppingAction(context,name) +: Geant4SteppingAction(context,name) { m_needsControl = true; eventAction().callAtBegin(this,&Geant4MaterialScanner::beginEvent); @@ -175,7 +175,7 @@ void Geant4MaterialScanner::end(const G4Track* track) { const Position& post = m_steps[m_steps.size()-1]->post; ::printf("%s + Material scan between: x_0 = (%7.2f,%7.2f,%7.2f) [cm] and x_1 = (%7.2f,%7.2f,%7.2f) [cm] TrackID:%d: \n%s", - line,pre.X()/cm,pre.Y()/cm,pre.Z()/cm,post.X()/cm,post.Y()/cm,post.Z()/cm,track->GetTrackID(),line); + line,pre.X()/cm,pre.Y()/cm,pre.Z()/cm,post.X()/cm,post.Y()/cm,post.Z()/cm,track->GetTrackID(),line); ::printf(" | \\ %-11s Atomic Radiation Interaction Path Integrated Integrated Material\n","Material"); ::printf(" | Num. \\ %-11s Number/Z Mass/A Density Length Length Thickness Length X0 Lambda Endpoint \n","Name"); ::printf(" | Layer \\ %-11s [g/mole] [g/cm3] [cm] [cm] [cm] [cm] [cm] [cm] ( cm, cm, cm)\n",""); @@ -198,16 +198,16 @@ void Geant4MaterialScanner::end(const G4Track* track) { const char* fmt = radLen >= 1e5 ? fmt2 : fmt1; const double* fractions = m->GetFractionVector(); for(size_t i=0; i<m->GetNumberOfElements(); ++i) { - Zeff += fractions[i]*(m->GetElement(i)->GetZ()); - Aeff += fractions[i]*(m->GetElement(i)->GetA())/gram; + Zeff += fractions[i]*(m->GetElement(i)->GetZ()); + Aeff += fractions[i]*(m->GetElement(i)->GetA())/gram; } m_sumX0 += nx0; m_sumLambda += nLambda; m_sumPath += length; ::printf(fmt,count,m->GetName().c_str(), - Zeff, Aeff, density, radLen, intLen, length, - m_sumPath,m_sumX0,m_sumLambda, - postPos.X()/cm,postPos.Y()/cm,postPos.Z()/cm); + Zeff, Aeff, density, radLen, intLen, length, + m_sumPath,m_sumX0,m_sumLambda, + postPos.X()/cm,postPos.Y()/cm,postPos.Z()/cm); //cout << *m << endl; } for_each(m_steps.begin(),m_steps.end(),DestroyObject<StepInfo*>()); diff --git a/DDG4/plugins/Geant4PhysicsConstructors.cpp b/DDG4/plugins/Geant4PhysicsConstructors.cpp index 916ed759d7b9137b9c7e5ffa3a6e4f4ba77d9160..1905201ce262e2a348006fd6faaffffab159da7d 100644 --- a/DDG4/plugins/Geant4PhysicsConstructors.cpp +++ b/DDG4/plugins/Geant4PhysicsConstructors.cpp @@ -32,7 +32,7 @@ // // ====================================================================== -// EM physics +// EM physics #include "G4EmStandardPhysics_option1.hh" DECLARE_GEANT4_PHYSICS(G4EmStandardPhysics_option1) #include "G4EmStandardPhysics_option2.hh" @@ -51,10 +51,10 @@ DECLARE_GEANT4_PHYSICS(G4EmLivermorePhysics) DECLARE_GEANT4_PHYSICS(G4IonBinaryCascadePhysics) #ifdef GEANT4_9_6 - #include "G4IonINCLXXPhysics.hh" - DECLARE_GEANT4_PHYSICS(G4IonINCLXXPhysics) - #include "G4IonLHEPPhysics.hh" - DECLARE_GEANT4_PHYSICS(G4IonLHEPPhysics) +#include "G4IonINCLXXPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4IonINCLXXPhysics) +#include "G4IonLHEPPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4IonLHEPPhysics) #endif #include "G4IonPhysics.hh" diff --git a/DDG4/plugins/Geant4PhysicsLists.cpp b/DDG4/plugins/Geant4PhysicsLists.cpp index 10435691ea272a341b5a8a3f0ac81378fe8ecd9a..4d04f3263edeca6bc708c037bbdc3e9100ff1411 100644 --- a/DDG4/plugins/Geant4PhysicsLists.cpp +++ b/DDG4/plugins/Geant4PhysicsLists.cpp @@ -46,71 +46,71 @@ DECLARE_GEANT4_PHYSICS_LIST(CHIPS) #ifdef GEANT4_9_6 #include "CHIPS_HP.hh" -DECLARE_GEANT4_PHYSICS_LIST(CHIPS_HP) + DECLARE_GEANT4_PHYSICS_LIST(CHIPS_HP) #include "FTFP_BERT.hh" -DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT) + DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT) #include "FTFP_BERT_HP.hh" -DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT_HP) + DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT_HP) #include "QGSP_BERT_95.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_95) + DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_95) #include "QGSP_BERT_95XS.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_95XS) + DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_95XS) #include "QGSP_INCLXX.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_INCLXX) + DECLARE_GEANT4_PHYSICS_LIST(QGSP_INCLXX) #endif #include "FTF_BIC.hh" -DECLARE_GEANT4_PHYSICS_LIST(FTF_BIC) + DECLARE_GEANT4_PHYSICS_LIST(FTF_BIC) #include "FTFP_BERT_EMV.hh" -DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT_EMV) + DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT_EMV) #include "FTFP_BERT_EMX.hh" -DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT_EMX) + DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT_EMX) #include "FTFP_BERT.hh" -DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT) + DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT) #include "FTFP_BERT_TRV.hh" -DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT_TRV) + DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT_TRV) #include "LBE.hh" //DECLARE_GEANT4_PHYSICS_LIST(LBE) takes no verbosity arg! #include "LHEP_EMV.hh" -DECLARE_GEANT4_PHYSICS_LIST(LHEP_EMV) + DECLARE_GEANT4_PHYSICS_LIST(LHEP_EMV) #include "LHEP.hh" -DECLARE_GEANT4_PHYSICS_LIST(LHEP) + DECLARE_GEANT4_PHYSICS_LIST(LHEP) #include "QBBC.hh" -DECLARE_GEANT4_PHYSICS_LIST(QBBC) + DECLARE_GEANT4_PHYSICS_LIST(QBBC) #include "QGS_BIC.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGS_BIC) + DECLARE_GEANT4_PHYSICS_LIST(QGS_BIC) #include "QGSC_BERT.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSC_BERT) + DECLARE_GEANT4_PHYSICS_LIST(QGSC_BERT) #include "QGSC_CHIPS.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSC_CHIPS) + DECLARE_GEANT4_PHYSICS_LIST(QGSC_CHIPS) #include "QGSP_BERT_CHIPS.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_CHIPS) + DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_CHIPS) #include "QGSP_BERT_EMV.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_EMV) + DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_EMV) #include "QGSP_BERT_EMX.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_EMX) + DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_EMX) #include "QGSP_BERT.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT) + DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT) #include "QGSP_BERT_NOLEP.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_NOLEP) + DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_NOLEP) #include "QGSP_BERT_TRV.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_TRV) + DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_TRV) #include "QGSP_BIC_EMY.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BIC_EMY) + DECLARE_GEANT4_PHYSICS_LIST(QGSP_BIC_EMY) #include "QGSP_BIC_HP.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BIC_HP) + DECLARE_GEANT4_PHYSICS_LIST(QGSP_BIC_HP) #include "QGSP_BIC.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BIC) + DECLARE_GEANT4_PHYSICS_LIST(QGSP_BIC) #include "QGSP_FTFP_BERT.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_FTFP_BERT) + DECLARE_GEANT4_PHYSICS_LIST(QGSP_FTFP_BERT) #include "QGSP.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP) + DECLARE_GEANT4_PHYSICS_LIST(QGSP) #include "QGSP_QEL.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_QEL) + DECLARE_GEANT4_PHYSICS_LIST(QGSP_QEL) #include "HadronPhysicsCHIPS.hh" #if 0 #include ".hh" -DECLARE_GEANT4_PHYSICS_LIST() + DECLARE_GEANT4_PHYSICS_LIST() #endif diff --git a/DDG4/plugins/Geant4Processes.cpp b/DDG4/plugins/Geant4Processes.cpp index c0b408e7aaea9c2178d907bcb5a4f95c2b8c66c6..5938bea205f205768c2f52c2602480c500fe28db 100644 --- a/DDG4/plugins/Geant4Processes.cpp +++ b/DDG4/plugins/Geant4Processes.cpp @@ -24,8 +24,8 @@ // <physicslist name="Geant4PhysicsList/MyPhysics.0"> // <processes> // <particle name="e[+-]" cut="1*mm"> -// <process name="G4eMultipleScattering" ordAtRestDoIt="-1" ordAlongSteptDoIt="1" ordPostStepDoIt="1"/> -// <process name="G4eIonisation" ordAtRestDoIt="-1" ordAlongSteptDoIt="2" ordPostStepDoIt="2"/> +// <process name="G4eMultipleScattering" ordAtRestDoIt="-1" ordAlongSteptDoIt="1" ordPostStepDoIt="1"/> +// <process name="G4eIonisation" ordAtRestDoIt="-1" ordAlongSteptDoIt="2" ordPostStepDoIt="2"/> // </particle> // </processes> // </physicslist> @@ -45,7 +45,7 @@ DECLARE_GEANT4_PROCESS(G4RayleighScattering) #include "G4GammaConversionToMuons.hh" DECLARE_GEANT4_PROCESS(G4GammaConversionToMuons) -// Electron/positron processes +// Electron/positron processes #include "G4eIonisation.hh" DECLARE_GEANT4_PROCESS(G4eIonisation) #include "G4eBremsstrahlung.hh" @@ -59,7 +59,7 @@ DECLARE_GEANT4_PROCESS(G4AnnihiToMuPair) #include "G4eeToHadrons.hh" DECLARE_GEANT4_PROCESS(G4eeToHadrons) -// Muon processes +// Muon processes #include "G4MuIonisation.hh" DECLARE_GEANT4_PROCESS(G4MuIonisation) #include "G4MuBremsstrahlung.hh" @@ -69,7 +69,7 @@ DECLARE_GEANT4_PROCESS(G4MuPairProduction) #include "G4MuMultipleScattering.hh" DECLARE_GEANT4_PROCESS(G4MuMultipleScattering) -// Hadron/ion processes +// Hadron/ion processes #include "G4hIonisation.hh" DECLARE_GEANT4_PROCESS(G4hIonisation) #include "G4ionIonisation.hh" @@ -89,7 +89,7 @@ DECLARE_GEANT4_PROCESS(G4hPairProduction) #include "G4CoulombScattering.hh" DECLARE_GEANT4_PROCESS(G4CoulombScattering) -// Processes for simulation of polarized electron and gamma beams +// Processes for simulation of polarized electron and gamma beams #include "G4PolarizedCompton.hh" DECLARE_GEANT4_PROCESS(G4PolarizedCompton) #include "G4PolarizedGammaConversion.hh" @@ -103,7 +103,7 @@ DECLARE_GEANT4_PROCESS(G4ePolarizedIonisation) #include "G4eplusPolarizedAnnihilation.hh" DECLARE_GEANT4_PROCESS(G4eplusPolarizedAnnihilation) -// Processes for simulation of X-rays and optical protons production by charged particles +// Processes for simulation of X-rays and optical protons production by charged particles #include "G4SynchrotronRadiation.hh" DECLARE_GEANT4_PROCESS(G4SynchrotronRadiation) #include "G4TransitionRadiation.hh" diff --git a/DDG4/plugins/Geant4SDActions.cpp b/DDG4/plugins/Geant4SDActions.cpp index 54a0704c5d700a534b01cf905fd38f1e1e13e957..31b37fcb74af78af504e6cf8bfe2124f71de7702 100644 --- a/DDG4/plugins/Geant4SDActions.cpp +++ b/DDG4/plugins/Geant4SDActions.cpp @@ -194,8 +194,8 @@ namespace DD4hep { pre.truth.deposit = 0.0; current = pre.truth.trackID; sensitive->mark(step->GetTrack()); - mean_pos.SetXYZ(0,0,0); - mean_time = 0; + mean_pos.SetXYZ(0,0,0); + mean_time = 0; post = pre; combined = 0; cell = 0; @@ -205,10 +205,10 @@ namespace DD4hep { void update(G4Step* step) { post.storePoint(step,step->GetPostStepPoint()); pre.truth.deposit += post.truth.deposit; - mean_pos.SetX(mean_pos.x()+post.position.x()*post.truth.deposit); - mean_pos.SetY(mean_pos.y()+post.position.y()*post.truth.deposit); - mean_pos.SetZ(mean_pos.z()+post.position.z()*post.truth.deposit); - mean_time += post.truth.time*post.truth.deposit; + mean_pos.SetX(mean_pos.x()+post.position.x()*post.truth.deposit); + mean_pos.SetY(mean_pos.y()+post.position.y()*post.truth.deposit); + mean_pos.SetZ(mean_pos.z()+post.position.z()*post.truth.deposit); + mean_time += post.truth.time*post.truth.deposit; if ( 0 == cell ) { cell = sensitive->cellID(step); if ( 0 == cell ) { @@ -221,8 +221,8 @@ namespace DD4hep { /// Clear collected information and restart for new hit void clear() { - mean_pos.SetXYZ(0,0,0); - mean_time = 0; + mean_pos.SetXYZ(0,0,0); + mean_time = 0; post.clear(); pre.clear(); current = -1; @@ -300,7 +300,7 @@ namespace DD4hep { /// Post-event action callback void endEvent(const G4Event* /* event */) { // We need to add the possibly last added hit to the collection here. - // otherwise the last hit would be assigned to the next event and the + // otherwise the last hit would be assigned to the next event and the // MC truth would be screwed. // // Alternatively the 'update' method would become rather CPU consuming, @@ -330,7 +330,7 @@ namespace DD4hep { } /// Method for generating hit(s) using the information of G4Step object. - template <> G4bool + template <> G4bool Geant4SensitiveAction<TrackerCombine>::process(G4Step* step, G4TouchableHistory* history) { return m_userData.process(step, history); } diff --git a/DDG4/plugins/Geant4SensDet.cpp b/DDG4/plugins/Geant4SensDet.cpp index b91f0de30e689cfac331d078ce639c3929ced7f4..7684fa625df3a11631889df9870a3a8a60835a18 100644 --- a/DDG4/plugins/Geant4SensDet.cpp +++ b/DDG4/plugins/Geant4SensDet.cpp @@ -43,13 +43,13 @@ namespace DD4hep { /// Default destructor virtual ~RefCountedSequence() { _release(); } void _aquire(T* s) { - InstanceCount::increment(this); - m_sequence = s; - m_sequence->addRef(); + InstanceCount::increment(this); + m_sequence = s; + m_sequence->addRef(); } void _release() { - releasePtr(m_sequence); - InstanceCount::decrement(this); + releasePtr(m_sequence); + InstanceCount::decrement(this); } }; @@ -59,10 +59,10 @@ namespace DD4hep { * \version 1.0 * \ingroup DD4HEP_SIMULATION */ - class Geant4SensDet : virtual public G4VSensitiveDetector, - virtual public G4VSDFilter, - virtual public Geant4ActionSD, - virtual public RefCountedSequence<Geant4SensDetActionSequence> + class Geant4SensDet : virtual public G4VSensitiveDetector, + virtual public G4VSDFilter, + virtual public Geant4ActionSD, + virtual public RefCountedSequence<Geant4SensDetActionSequence> { protected: /// Access to the geant4 sensitive detector handle @@ -70,16 +70,16 @@ namespace DD4hep { public: /// Constructor. The detector element is identified by the name Geant4SensDet(const std::string& nam, Geometry::LCDD& lcdd) - : G4VSensitiveDetector(nam), G4VSDFilter(nam), - Geant4Action(0,nam), Geant4ActionSD(nam), Base() + : G4VSensitiveDetector(nam), G4VSDFilter(nam), + Geant4Action(0,nam), Geant4ActionSD(nam), Base() { - Geant4Kernel& kernel = Geant4Kernel::access(lcdd); - m_sensitive = lcdd.sensitiveDetector(nam); - m_context = Geant4Context(&kernel); - m_outputLevel = kernel.getOutputLevel(nam); - _aquire(kernel.sensitiveAction(nam)); - m_sequence->defineCollections(this); - this->G4VSensitiveDetector::SetFilter(this); + Geant4Kernel& kernel = Geant4Kernel::access(lcdd); + m_sensitive = lcdd.sensitiveDetector(nam); + m_context = Geant4Context(&kernel); + m_outputLevel = kernel.getOutputLevel(nam); + _aquire(kernel.sensitiveAction(nam)); + m_sequence->defineCollections(this); + this->G4VSensitiveDetector::SetFilter(this); } /// Destructor @@ -96,7 +96,7 @@ namespace DD4hep { /// Is the detector active? virtual bool isActive() const { return this->G4VSensitiveDetector::isActive(); } - /// This is a utility method which returns the hits collection ID + /// This is a utility method which returns the hits collection ID virtual G4int GetCollectionID(G4int i) { return this->G4VSensitiveDetector::GetCollectionID(i); } /// Access to the readout geometry of the sensitive detector @@ -111,25 +111,25 @@ namespace DD4hep { /// Callback if the sequence should be accepted or filtered off virtual G4bool Accept(const G4Step* step) const { return m_sequence->accept(step); } - /// Method invoked at the begining of each event. + /// Method invoked at the begining of each event. virtual void Initialize(G4HCofThisEvent* hce) { - m_context.setRun(&ddg4_globalContext()->run()); - m_context.setEvent(&ddg4_globalContext()->event()); - (Geant4Action::ContextUpdate(&m_context))(m_sequence); - m_sequence->begin(hce); + m_context.setRun(&ddg4_globalContext()->run()); + m_context.setEvent(&ddg4_globalContext()->event()); + (Geant4Action::ContextUpdate(&m_context))(m_sequence); + m_sequence->begin(hce); #if 0 - const G4Event& evt = context()->event(); - error(name(), "%s> calling Initialize(event_id=%d Context: run=%p (%d) evt=%p (%d))", - GetName().c_str(), evt.GetEventID(), - &context()->run(), context()->run().run().GetRunID(), - &context()->event(), context()->event().event().GetEventID()); + const G4Event& evt = context()->event(); + error(name(), "%s> calling Initialize(event_id=%d Context: run=%p (%d) evt=%p (%d))", + GetName().c_str(), evt.GetEventID(), + &context()->run(), context()->run().run().GetRunID(), + &context()->event(), context()->event().event().GetEventID()); #endif } - /// Method invoked at the end of each event. + /// Method invoked at the end of each event. virtual void EndOfEvent(G4HCofThisEvent* hce) { - m_sequence->end(hce); - m_context.setEvent(0); - (Geant4Action::ContextUpdate(&m_context))(m_sequence); + m_sequence->end(hce); + m_context.setEvent(0); + (Geant4Action::ContextUpdate(&m_context))(m_sequence); } /// Method for generating hit(s) using the information of G4Step object. virtual G4bool ProcessHits(G4Step* step,G4TouchableHistory* hist) @@ -139,11 +139,11 @@ namespace DD4hep { { m_sequence->clear(); } /// Initialize the usage of a hit collection. Returns the collection identifier virtual size_t defineCollection(const std::string& coll) { - if ( coll.empty() ) { - except("Geant4Sensitive: No collection defined for %s [Invalid name]",c_name()); - } - collectionName.push_back(coll); - return collectionName.size()-1; + if ( coll.empty() ) { + except("Geant4Sensitive: No collection defined for %s [Invalid name]",c_name()); + } + collectionName.push_back(coll); + return collectionName.size()-1; } }; diff --git a/DDG4/plugins/Geant4SensDetFilters.cpp b/DDG4/plugins/Geant4SensDetFilters.cpp index 76e8d1b2eedf590a1d442f8e7c93187acfb8006b..2f4c46f040c0bc888b1c5a4bf90ee34b4703a1ce 100644 --- a/DDG4/plugins/Geant4SensDetFilters.cpp +++ b/DDG4/plugins/Geant4SensDetFilters.cpp @@ -31,7 +31,7 @@ namespace DD4hep { /// Corresponding geant4 particle definiton mutable G4ParticleDefinition* m_definition; public: - /// Constructor. + /// Constructor. ParticleFilter(Geant4Context* context, const std::string& name); /// Standard destructor virtual ~ParticleFilter(); @@ -50,7 +50,7 @@ namespace DD4hep { * @version 1.0 */ struct ParticleRejectFilter : public ParticleFilter { - /// Constructor. + /// Constructor. ParticleRejectFilter(Geant4Context* c, const std::string& n); /// Standard destructor virtual ~ParticleRejectFilter(); @@ -59,13 +59,13 @@ namespace DD4hep { }; /// Geant4 sensitive detector filter implementing a particle selector - /** + /** * * @author M.Frank * @version 1.0 */ struct ParticleSelectFilter : public ParticleFilter { - /// Constructor. + /// Constructor. ParticleSelectFilter(Geant4Context* c, const std::string& n); /// Standard destructor virtual ~ParticleSelectFilter(); @@ -74,13 +74,13 @@ namespace DD4hep { }; /// Geant4 sensitive detector filter implementing a Geantino rejector - /** + /** * * @author M.Frank * @version 1.0 */ struct GeantinoRejectFilter : public ParticleFilter { - /// Constructor. + /// Constructor. GeantinoRejectFilter(Geant4Context* c, const std::string& n); /// Standard destructor virtual ~GeantinoRejectFilter(); @@ -89,7 +89,7 @@ namespace DD4hep { }; /// Geant4 sensitive detector filter implementing an energy cut. - /** + /** * * @author M.Frank * @version 1.0 @@ -98,7 +98,7 @@ namespace DD4hep { /// Energy cut value double m_energyCut; public: - /// Constructor. + /// Constructor. EnergyDepositMinimumCut(Geant4Context* c, const std::string& n); /// Standard destructor virtual ~EnergyDepositMinimumCut(); @@ -113,7 +113,7 @@ namespace DD4hep { #include "DDG4/Factories.h" // Geant4 include files -#include "G4ParticleTable.hh" +#include "G4ParticleTable.hh" #include "G4ChargedGeantino.hh" #include "G4Geantino.hh" #include "G4Track.hh" @@ -126,12 +126,12 @@ using namespace std; //DECLARE_GEANT4ACTION() DECLARE_GEANT4ACTION(GeantinoRejectFilter) DECLARE_GEANT4ACTION(ParticleRejectFilter) -DECLARE_GEANT4ACTION(ParticleSelectFilter) -DECLARE_GEANT4ACTION(EnergyDepositMinimumCut) + DECLARE_GEANT4ACTION(ParticleSelectFilter) + DECLARE_GEANT4ACTION(EnergyDepositMinimumCut) -/// Constructor. -ParticleFilter::ParticleFilter(Geant4Context* context, const std::string& name) -: Geant4Filter(context,name), m_definition(0) +/// Constructor. + ParticleFilter::ParticleFilter(Geant4Context* context, const std::string& name) + : Geant4Filter(context,name), m_definition(0) { declareProperty("particle",m_particle); InstanceCount::increment(this); @@ -171,9 +171,9 @@ bool ParticleFilter::isGeantino(const G4Track* track) const { return false; } -/// Constructor. +/// Constructor. GeantinoRejectFilter::GeantinoRejectFilter(Geant4Context* c, const std::string& n) -: ParticleFilter(c,n) { + : ParticleFilter(c,n) { InstanceCount::increment(this); } @@ -187,9 +187,9 @@ bool GeantinoRejectFilter::operator()(const G4Step* step) const { return !isGeantino(step->GetTrack()); } -/// Constructor. +/// Constructor. ParticleRejectFilter::ParticleRejectFilter(Geant4Context* c, const std::string& n) -: ParticleFilter(c,n) { + : ParticleFilter(c,n) { InstanceCount::increment(this); } @@ -203,8 +203,8 @@ bool ParticleRejectFilter::operator()(const G4Step* step) const { return isSameType(step->GetTrack()); } -/// Constructor. -ParticleSelectFilter::ParticleSelectFilter(Geant4Context* c, const std::string& n) +/// Constructor. +ParticleSelectFilter::ParticleSelectFilter(Geant4Context* c, const std::string& n) : ParticleFilter(c,n) { InstanceCount::increment(this); } @@ -219,8 +219,8 @@ bool ParticleSelectFilter::operator()(const G4Step* step) const { return !isSameType(step->GetTrack()); } -/// Constructor. -EnergyDepositMinimumCut::EnergyDepositMinimumCut(Geant4Context* c, const std::string& n) +/// Constructor. +EnergyDepositMinimumCut::EnergyDepositMinimumCut(Geant4Context* c, const std::string& n) : Geant4Filter(c,n) { InstanceCount::increment(this); declareProperty("Cut",m_energyCut=0.0); diff --git a/DDG4/plugins/Geant4Steppers.cpp b/DDG4/plugins/Geant4Steppers.cpp index 2c7161847f860a23a9e0ee96c05f3e97340320ac..f353770cdfa3ec63dcf60f51b1f8c2fbb3be5e5f 100644 --- a/DDG4/plugins/Geant4Steppers.cpp +++ b/DDG4/plugins/Geant4Steppers.cpp @@ -19,10 +19,10 @@ DECLARE_GEANT4_STEPPER(ImplicitEuler) DECLARE_GEANT4_STEPPER(ExplicitEuler) -DECLARE_GEANT4_STEPPER(SimpleRunge) -DECLARE_GEANT4_STEPPER(SimpleHeum) -DECLARE_GEANT4_MAGSTEPPER(ConstRK4) -DECLARE_GEANT4_STEPPER(ClassicalRK4) + DECLARE_GEANT4_STEPPER(SimpleRunge) + DECLARE_GEANT4_STEPPER(SimpleHeum) + DECLARE_GEANT4_MAGSTEPPER(ConstRK4) + DECLARE_GEANT4_STEPPER(ClassicalRK4) // Geant 4 include files @@ -32,11 +32,11 @@ DECLARE_GEANT4_STEPPER(ClassicalRK4) #include "G4HelixSimpleRunge.hh" #include "G4HelixHeum.hh" -DECLARE_GEANT4_MAGSTEPPER(HelixImplicitEuler) -DECLARE_GEANT4_MAGSTEPPER(HelixExplicitEuler) -DECLARE_GEANT4_MAGSTEPPER(HelixMixedStepper) -DECLARE_GEANT4_MAGSTEPPER(HelixSimpleRunge) -DECLARE_GEANT4_MAGSTEPPER(HelixHeum) + DECLARE_GEANT4_MAGSTEPPER(HelixImplicitEuler) + DECLARE_GEANT4_MAGSTEPPER(HelixExplicitEuler) + DECLARE_GEANT4_MAGSTEPPER(HelixMixedStepper) + DECLARE_GEANT4_MAGSTEPPER(HelixSimpleRunge) + DECLARE_GEANT4_MAGSTEPPER(HelixHeum) // Geant 4 include files @@ -46,7 +46,7 @@ DECLARE_GEANT4_MAGSTEPPER(HelixHeum) #include "G4KM_OpticalEqRhs.hh" #include "G4KM_NucleonEqRhs.hh" //Virtual: DECLARE_GEANT4_MAGMOTION(Mag_EqRhs); -DECLARE_GEANT4_MAGMOTION(Mag_SpinEqRhs) -DECLARE_GEANT4_MAGMOTION(Mag_UsualEqRhs) + DECLARE_GEANT4_MAGMOTION(Mag_SpinEqRhs) + DECLARE_GEANT4_MAGMOTION(Mag_UsualEqRhs) //DECLARE_GEANT4_MAGMOTION(KM_OpticalEqRhs); //DECLARE_GEANT4_MAGMOTION(KM_NucleonEqRhs); diff --git a/DDG4/plugins/Geant4TCUserParticleHandler.cpp b/DDG4/plugins/Geant4TCUserParticleHandler.cpp index 28216b48643cafe22f004b7a2b0ffd670d5487f5..389136d74f620f535277c6598e8c7d6f4a9ee15c 100644 --- a/DDG4/plugins/Geant4TCUserParticleHandler.cpp +++ b/DDG4/plugins/Geant4TCUserParticleHandler.cpp @@ -71,7 +71,7 @@ DECLARE_GEANT4ACTION(Geant4TCUserParticleHandler) /// Standard constructor Geant4TCUserParticleHandler::Geant4TCUserParticleHandler(Geant4Context* context, const std::string& nam) -: Geant4UserParticleHandler(context,nam) +: Geant4UserParticleHandler(context,nam) { declareProperty("TrackingVolume_Zmax",m_zTracker=1e100); declareProperty("TrackingVolume_Rmax",m_rTracker=1e100); @@ -98,7 +98,7 @@ void Geant4TCUserParticleHandler::end(const G4Track* /* track */, Particle& p) p.reason = 0; return ; } - + //fg: backscatter ?? - // if( !starts_in_trk_vol && ends_in_trk_vol ){ keep ? } + // if( !starts_in_trk_vol && ends_in_trk_vol ){ keep ? } } diff --git a/DDG4/plugins/Geant4XMLSetup.cpp b/DDG4/plugins/Geant4XMLSetup.cpp index dd95a2262955a9b72de16958cd0476cf49630c91..524e6b57e83284ca3b77f7dfc8d66711e80e8197 100644 --- a/DDG4/plugins/Geant4XMLSetup.cpp +++ b/DDG4/plugins/Geant4XMLSetup.cpp @@ -48,8 +48,8 @@ namespace DD4hep { // Now we set the object properties vector<XML::Attribute> attrs = props.attributes(); for(vector<XML::Attribute>::iterator i=attrs.begin(); i!=attrs.end(); ++i) { - XML::Attribute a = *i; - handle[XML::_toString(props.attr_name(a))].str(props.attr<string>(a)); + XML::Attribute a = *i; + handle[XML::_toString(props.attr_name(a))].str(props.attr<string>(a)); } } @@ -59,10 +59,10 @@ namespace DD4hep { // Now we set the object properties XML::Handle_t props = action.child(_Unicode(properties),false); if ( props ) { - _setAttributes(handle, props); + _setAttributes(handle, props); } if ( action.hasAttr(_Unicode(Control)) ) { - handle["Control"].str(props.attr<string>(_Unicode(Control))); + handle["Control"].str(props.attr<string>(_Unicode(Control))); } } @@ -75,13 +75,13 @@ namespace DD4hep { Sensitive handle(kernel,action.attr<string>(_U(name)),detector); _setProperties(Action(handle.get()),e); for(xml_coll_t f(e,_Unicode(filter)); f; ++f) { - string nam = f.attr<string>(_U(name)); - Filter filter(kernel.globalFilter(nam,false)); - handle->adopt(filter); + string nam = f.attr<string>(_U(name)); + Filter filter(kernel.globalFilter(nam,false)); + handle->adopt(filter); } installMessenger(handle); printout(INFO,"Geant4Setup","+++ Added sensitive element %s of type %s", - tn.second.c_str(),tn.first.c_str()); + tn.second.c_str(),tn.first.c_str()); return Action(handle); } @@ -97,12 +97,12 @@ namespace DD4hep { installMessenger(handle); if ( action.hasChild(_Unicode(adopt)) ) { - xml_comp_t child = action.child(_Unicode(adopt)); - Geant4Action* user = kernel.globalAction(child.nameStr()); - Geant4ParticleHandler* ph = dynamic_cast<Geant4ParticleHandler*>(handle.get()); - if ( ph ) { - ph->adopt(user); - } + xml_comp_t child = action.child(_Unicode(adopt)); + Geant4Action* user = kernel.globalAction(child.nameStr()); + Geant4ParticleHandler* ph = dynamic_cast<Geant4ParticleHandler*>(handle.get()); + if ( ph ) { + ph->adopt(user); + } } return handle; } @@ -114,19 +114,19 @@ namespace DD4hep { TypeName typ = TypeName::split(nam); Kernel& kernel = Kernel::access(lcdd); Action action((what==FILTER) ? (Geant4Action*)kernel.globalFilter(typ.second,false) - : (what==ACTION) ? kernel.globalAction(typ.second,false) - /// : (what==FILTER) ? kernel.globalAction(typ.second,false) - : 0); + : (what==ACTION) ? kernel.globalAction(typ.second,false) + /// : (what==FILTER) ? kernel.globalAction(typ.second,false) + : 0); // Create the object using the factory method if ( !action ) { - action = (what == SENSITIVE) ? Action(_convertSensitive(lcdd, a, seqType)) - : (what==ACTION) ? _convertAction(lcdd, a) - : (what==FILTER) ? _convertAction(lcdd, a) - : Action(); - if ( !action ) { - throw runtime_error(format("Geant4ActionSequence","DDG4: The action '%s'" - " cannot be created. [Action-Missing]",nam.c_str())); - } + action = (what == SENSITIVE) ? Action(_convertSensitive(lcdd, a, seqType)) + : (what==ACTION) ? _convertAction(lcdd, a) + : (what==FILTER) ? _convertAction(lcdd, a) + : Action(); + if ( !action ) { + throw runtime_error(format("Geant4ActionSequence","DDG4: The action '%s'" + " cannot be created. [Action-Missing]",nam.c_str())); + } } return action; } @@ -136,7 +136,7 @@ namespace DD4hep { /** * <actions> * <action name="Geant4PostTrackingAction/PostTrackAction" - * <properties + * <properties * NAME1="Value1" * NAME2="Value2" /> * </action> @@ -167,7 +167,7 @@ namespace DD4hep { /** * <phases> * <phase name="Geant4PostTrackingPhase/PostTrackPhase" - * <properties + * <properties * NAME1="Value1" * NAME2="Value2" /> * </phase> @@ -230,34 +230,34 @@ namespace DD4hep { TypeName tn = TypeName::split(nam); DetElement det = lcdd.detector(tn.first); if ( !det.isValid() ) { - throw runtime_error(format("Phase","DDG4: The phase '%s' of type SensitiveSeq" - " cannot be attached to a non-existing detector" - " [Detector-Missing]",nam.c_str())); + throw runtime_error(format("Phase","DDG4: The phase '%s' of type SensitiveSeq" + " cannot be attached to a non-existing detector" + " [Detector-Missing]",nam.c_str())); } Geometry::SensitiveDetector sd = lcdd.sensitiveDetector(tn.first); if ( !sd.isValid() ) { - throw runtime_error(format("Phase","DDG4: The phase '%s' of type SensitiveSeq" - " cannot be attached to a non-existing sensitive detector" - " [Sensitive-Missing]",nam.c_str())); + throw runtime_error(format("Phase","DDG4: The phase '%s' of type SensitiveSeq" + " cannot be attached to a non-existing sensitive detector" + " [Sensitive-Missing]",nam.c_str())); } SensitiveSeq sdSeq = SensitiveSeq(kernel,tn.first); if ( tn.second == "begin" ) - sdSeq->callAtBegin((p=kernel.addPhase<G4HCofThisEvent*>(tn.second)).get(), - &PH::call<G4HCofThisEvent*>); + sdSeq->callAtBegin((p=kernel.addPhase<G4HCofThisEvent*>(tn.second)).get(), + &PH::call<G4HCofThisEvent*>); else if ( tn.second == "end" ) - sdSeq->callAtEnd((p=kernel.addPhase<G4HCofThisEvent*>(tn.second)).get(), - &PH::call<G4HCofThisEvent*>); + sdSeq->callAtEnd((p=kernel.addPhase<G4HCofThisEvent*>(tn.second)).get(), + &PH::call<G4HCofThisEvent*>); else if ( tn.second == "clear" ) - sdSeq->callAtClear((p=kernel.addPhase<G4HCofThisEvent*>(tn.second)).get(), - &PH::call<G4HCofThisEvent*>); + sdSeq->callAtClear((p=kernel.addPhase<G4HCofThisEvent*>(tn.second)).get(), + &PH::call<G4HCofThisEvent*>); else if ( tn.second == "process" ) - sdSeq->callAtProcess((p=kernel.addPhase<G4Step*>(tn.second)).get(), - &PH::call<G4Step*,G4TouchableHistory*>); - else - throw runtime_error(format("Phase","DDG4: The phase '%s' of type SensitiveSeq" - " cannot be attached to the call '%s'." - " [Callback-Missing]",tn.first.c_str(), tn.second.c_str())); + sdSeq->callAtProcess((p=kernel.addPhase<G4Step*>(tn.second)).get(), + &PH::call<G4Step*,G4TouchableHistory*>); + else + throw runtime_error(format("Phase","DDG4: The phase '%s' of type SensitiveSeq" + " cannot be attached to the call '%s'." + " [Callback-Missing]",tn.first.c_str(), tn.second.c_str())); } } @@ -269,7 +269,7 @@ namespace DD4hep { * </sequence> * <sequence name="Geant4SensdetActionSequence/SiVertexBarrel" * <member type="Geant4TrackerSensitiveMonitor/TrackerHitMonitor"> - * <properties + * <properties * NAME1="Value1" * NAME2="Value2" /> * </member> @@ -289,11 +289,11 @@ namespace DD4hep { SensitiveDetector sensitive = lcdd.sensitiveDetector(sd_nam); seqNam = seq.attr<string>(_U(type))+"/"+sd_nam; if ( !sensitive.isValid() ) { - printout(ALWAYS,"Geant4Setup","+++ ActionSequence %s is defined, " - "but no sensitive detector present.",seqNam.c_str()); - printout(ALWAYS,"Geant4Setup","+++ ---> Sequence for detector %s IGNORED on popular request!", - sd_nam.c_str()); - return; + printout(ALWAYS,"Geant4Setup","+++ ActionSequence %s is defined, " + "but no sensitive detector present.",seqNam.c_str()); + printout(ALWAYS,"Geant4Setup","+++ ---> Sequence for detector %s IGNORED on popular request!", + sd_nam.c_str()); + return; } seqType = TypeName::split(seqNam); sdSeq = SensitiveSeq(kernel,seqNam); @@ -304,7 +304,7 @@ namespace DD4hep { seqType = TypeName::split(seqNam); } printout(INFO,"Geant4Setup","+++ ActionSequence %s of type %s added.", - seqType.second.c_str(),seqType.first.c_str()); + seqType.second.c_str(),seqType.first.c_str()); if ( seqType.second == "PhysicsList" ) { PhysicsActionSeq pl(&kernel.physicsList()); @@ -318,43 +318,43 @@ namespace DD4hep { string nam = a.attr<string>(_U(name)); Action action(_createAction(lcdd,a,seqType.second,what)); if ( seqType.second == "RunAction" ) - kernel.runAction().adopt(_action<RunAction::handled_type>(action.get())); + kernel.runAction().adopt(_action<RunAction::handled_type>(action.get())); else if ( seqType.second == "EventAction" ) - kernel.eventAction().adopt(_action<EventAction::handled_type>(action.get())); + kernel.eventAction().adopt(_action<EventAction::handled_type>(action.get())); else if ( seqType.second == "GeneratorAction" ) - kernel.generatorAction().adopt(_action<GenAction::handled_type>(action.get())); + kernel.generatorAction().adopt(_action<GenAction::handled_type>(action.get())); else if ( seqType.second == "TrackingAction" ) - kernel.trackingAction().adopt(_action<TrackAction::handled_type>(action.get())); + kernel.trackingAction().adopt(_action<TrackAction::handled_type>(action.get())); else if ( seqType.second == "StackingAction" ) - kernel.stackingAction().adopt(_action<StackAction::handled_type>(action.get())); + kernel.stackingAction().adopt(_action<StackAction::handled_type>(action.get())); else if ( seqType.second == "SteppingAction" ) - kernel.steppingAction().adopt(_action<StepAction::handled_type>(action.get())); + kernel.steppingAction().adopt(_action<StepAction::handled_type>(action.get())); else if ( seqType.second == "PhysicsList" ) - kernel.physicsList().adopt(_action<PhysicsList::handled_type>(action.get())); + kernel.physicsList().adopt(_action<PhysicsList::handled_type>(action.get())); else if ( sdSeq.get() ) - sdSeq->adopt(_action<Sensitive::handled_type>(action.get())); + sdSeq->adopt(_action<Sensitive::handled_type>(action.get())); else { - throw runtime_error(format("ActionSequence","DDG4: The action '%s'" - " cannot be attached to any sequence '%s'." - " [Sequence-Missing]",nam.c_str(), seqNam.c_str())); + throw runtime_error(format("ActionSequence","DDG4: The action '%s'" + " cannot be attached to any sequence '%s'." + " [Sequence-Missing]",nam.c_str(), seqNam.c_str())); } printout(INFO,"Geant4Setup","+++ ActionSequence %s added filter object:%s", - seqType.second.c_str(),action->name().c_str()); + seqType.second.c_str(),action->name().c_str()); } if ( what == SENSITIVE ) { for(xml_coll_t a(seq,_Unicode(filter)); a; ++a) { - string nam = a.attr<string>(_U(name)); - Action action(_createAction(lcdd,a,"",FILTER)); - installMessenger(action); - printout(INFO,"Geant4Setup","+++ ActionSequence %s added filter object:%s", - seqType.second.c_str(),action->name().c_str()); - if ( sdSeq.get() ) - sdSeq->adopt(_action<Filter::handled_type>(action.get())); - else { - throw runtime_error(format("ActionSequence","DDG4: The action '%s'" - " cannot be attached to any sequence '%s'." - " [Sequence-Missing]",nam.c_str(), seqNam.c_str())); - } + string nam = a.attr<string>(_U(name)); + Action action(_createAction(lcdd,a,"",FILTER)); + installMessenger(action); + printout(INFO,"Geant4Setup","+++ ActionSequence %s added filter object:%s", + seqType.second.c_str(),action->name().c_str()); + if ( sdSeq.get() ) + sdSeq->adopt(_action<Filter::handled_type>(action.get())); + else { + throw runtime_error(format("ActionSequence","DDG4: The action '%s'" + " cannot be attached to any sequence '%s'." + " [Sequence-Missing]",nam.c_str(), seqNam.c_str())); + } } } } @@ -364,7 +364,7 @@ namespace DD4hep { * <physicslist> * <processes> * <particle name="'e-'"> - * <process name="G4eMultipleScattering" ordAtRestDoIt="-1" ordAlongSteptDoIt="1" ordPostStepDoIt="1"/> + * <process name="G4eMultipleScattering" ordAtRestDoIt="-1" ordAlongSteptDoIt="1" ordPostStepDoIt="1"/> * <process name="G4eIonisation" ordAtRestDoIt="-1" ordAlongSteptDoIt="2" ordPostStepDoIt="2"/> * </particle> * </processes> @@ -373,7 +373,7 @@ namespace DD4hep { template <> void Converter<Geant4PhysicsList::ParticleProcesses>::operator()(xml_h e) const { xml_comp_t part(e); string part_name = part.nameStr(); - Geant4PhysicsList::ParticleProcesses& procs = + Geant4PhysicsList::ParticleProcesses& procs = _object<Geant4PhysicsList>().processes(part_name); for(xml_coll_t q(part,_Unicode(process)); q; ++q) { xml_comp_t proc(q); @@ -384,7 +384,7 @@ namespace DD4hep { p.ordPostStepDoIt = proc.attr<int>(_Unicode(ordPostStepDoIt)); procs.push_back(p); printout(INFO,"Geant4Setup","+++ Converter<ParticleProcesses: Particle:%s add process %s %d %d %d", - part_name.c_str(),p.name.c_str(),p.ordAtRestDoIt,p.ordAlongSteptDoIt,p.ordPostStepDoIt); + part_name.c_str(),p.name.c_str(),p.ordAtRestDoIt,p.ordAlongSteptDoIt,p.ordPostStepDoIt); } } @@ -457,9 +457,9 @@ namespace DD4hep { template <> void Converter<Kernel>::operator()(xml_h e) const { Kernel& kernel = Kernel::access(lcdd); xml_comp_t k(e); - if ( k.hasAttr(_Unicode(NumEvents)) ) + if ( k.hasAttr(_Unicode(NumEvents)) ) kernel.property("NumEvents").str(k.attr<string>(_Unicode(NumEvents))); - if ( k.hasAttr(_Unicode(UI)) ) + if ( k.hasAttr(_Unicode(UI)) ) kernel.property("UI").str(k.attr<string>(_Unicode(UI))); } @@ -470,7 +470,7 @@ namespace DD4hep { long result = ROOT::Reflex::PluginService::Create<long>("geant4_XML_reader",&lcdd,&seq); if ( 0 == result ) { throw runtime_error("DD4hep: Failed to locate plugin to interprete files of type" - " \"" + seq.tag() + "\" - no factory of type geant4_XML_reader."); + " \"" + seq.tag() + "\" - no factory of type geant4_XML_reader."); } result = *(long*) result; if (result != 1) { diff --git a/DDG4/src/ComponentProperties.cpp b/DDG4/src/ComponentProperties.cpp index 01fa9bb4ad41a1a5524e389e06a1ab3c1cb64f4a..42a4f3edafcbb1b21d830068587ac09ac5126d4e 100644 --- a/DDG4/src/ComponentProperties.cpp +++ b/DDG4/src/ComponentProperties.cpp @@ -59,7 +59,7 @@ Property::Property() /// Copy constructor Property::Property(const Property& property) - : m_par(property.m_par), m_hdl(property.m_hdl) { + : m_par(property.m_par), m_hdl(property.m_hdl) { } /// Assignment operator diff --git a/DDG4/src/Geant4Action.cpp b/DDG4/src/Geant4Action.cpp index 4b5136e968192600f69a85508ba20fc82a08ed07..46deeba78900405e9c6d374bcc8653cf0cec7f99 100644 --- a/DDG4/src/Geant4Action.cpp +++ b/DDG4/src/Geant4Action.cpp @@ -50,8 +50,8 @@ void Geant4Action::ContextUpdate::operator()(Geant4Action* action) const { /// Standard constructor Geant4Action::Geant4Action(Geant4Context* context, const string& nam) - : m_context(0), - m_control(0), m_outputLevel(INFO), m_needsControl(false), m_name(nam), m_refCount(1) { +: m_context(0), + m_control(0), m_outputLevel(INFO), m_needsControl(false), m_name(nam), m_refCount(1) { InstanceCount::increment(this); if ( context ) m_context = *context; m_outputLevel = context ? context->kernel().getOutputLevel(nam) : (printLevel()-1); @@ -76,7 +76,7 @@ long Geant4Action::release() { long count = --m_refCount; if (m_refCount <= 0) { print("Geant4Action: Deleting object %s of type %s Pointer:%p", - m_name.c_str(),typeName(typeid(*this)).c_str(),(void*)this); + m_name.c_str(),typeName(typeid(*this)).c_str(),(void*)this); delete this; } return count; @@ -266,7 +266,7 @@ void Geant4Action::abortRun(const string& exception, const char* fmt, ...) const desc = DD4hep::format("*** Geant4Action:", fmt, args); va_end(args); G4Exception(issuer.c_str(),exception.c_str(),RunMustBeAborted,desc.c_str()); - //throw runtime_error(issuer+"> "+desc); + //throw runtime_error(issuer+"> "+desc); } /// Access to the main run action sequence from the kernel object diff --git a/DDG4/src/Geant4ActionPhase.cpp b/DDG4/src/Geant4ActionPhase.cpp index 6a10160a61a27a249e203179f7eac9eec271dc70..9efcf941cb3cc343c4bd9ec3be2c1616c02238c0 100644 --- a/DDG4/src/Geant4ActionPhase.cpp +++ b/DDG4/src/Geant4ActionPhase.cpp @@ -16,8 +16,8 @@ using namespace DD4hep::Simulation; /// Standard constructor Geant4ActionPhase::Geant4ActionPhase(Geant4Context* context, const string& nam, const type_info& arg_type0, - const type_info& arg_type1, const type_info& arg_type2) - : Geant4Action(context, nam) { + const type_info& arg_type1, const type_info& arg_type2) +: Geant4Action(context, nam) { m_argTypes[0] = &arg_type0; m_argTypes[1] = &arg_type1; m_argTypes[2] = &arg_type2; diff --git a/DDG4/src/Geant4Context.cpp b/DDG4/src/Geant4Context.cpp index a3dc1a65237d257a4568b76f9911b538a96a85f2..96e01b16d7b3d28e44b242d2cac382df03fbeaf4 100644 --- a/DDG4/src/Geant4Context.cpp +++ b/DDG4/src/Geant4Context.cpp @@ -29,8 +29,8 @@ Geant4Run::~Geant4Run() { } /// Intializing constructor -Geant4Event::Geant4Event(const G4Event* evt, Geant4Random* rnd) - : ObjectExtensions(typeid(Geant4Event)), m_event(evt), m_random(rnd) +Geant4Event::Geant4Event(const G4Event* evt, Geant4Random* rnd) +: ObjectExtensions(typeid(Geant4Event)), m_event(evt), m_random(rnd) { InstanceCount::increment(this); } @@ -42,7 +42,7 @@ Geant4Event::~Geant4Event() { /// Default constructor Geant4Context::Geant4Context(Geant4Kernel* kernel) - : m_kernel(kernel), m_run(0), m_event(0) { +: m_kernel(kernel), m_run(0), m_event(0) { InstanceCount::increment(this); } diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp index 2b81f0ffe650581f249e48d262c4389649a1dc69..c48cfc3dc5dcd5151b6992a7e9cdfd9db7b0c517 100644 --- a/DDG4/src/Geant4Converter.cpp +++ b/DDG4/src/Geant4Converter.cpp @@ -99,36 +99,36 @@ using namespace std; #include "G4ReflectionFactory.hh" void Geant4AssemblyVolume::imprint(Geant4GeometryInfo& info, - const TGeoNode* parent, - Chain chain, - Geant4AssemblyVolume* pAssembly, - G4LogicalVolume* pMotherLV, - G4Transform3D& transformation, - G4int copyNumBase, - G4bool surfCheck ) + const TGeoNode* parent, + Chain chain, + Geant4AssemblyVolume* pAssembly, + G4LogicalVolume* pMotherLV, + G4Transform3D& transformation, + G4int copyNumBase, + G4bool surfCheck ) { TGeoVolume* vol = parent->GetVolume(); static int level=0; ++level; - + unsigned int numberOfDaughters; if( copyNumBase == 0 ) - { - numberOfDaughters = pMotherLV->GetNoDaughters(); - } + { + numberOfDaughters = pMotherLV->GetNoDaughters(); + } else - { - numberOfDaughters = copyNumBase; - } + { + numberOfDaughters = copyNumBase; + } // We start from the first available index // numberOfDaughters++; ImprintsCountPlus(); - + std::vector<G4AssemblyTriplet> triplets = pAssembly->fTriplets; //cout << " Assembly:" << DetectorTools::placementPath(chain) << endl; @@ -143,63 +143,63 @@ void Geant4AssemblyVolume::imprint(Geant4GeometryInfo& info, if ( triplets[i].IsReflection() ) { Ta = Ta * G4ReflectZ3D(); } G4Transform3D Tfinal = transformation * Ta; - + if ( triplets[i].GetVolume() ) - { - // Generate the unique name for the next PV instance - // The name has format: - // - // av_WWW_impr_XXX_YYY_ZZZ - // where the fields mean: - // WWW - assembly volume instance number - // XXX - assembly volume imprint number - // YYY - the name of a log. volume we want to make a placement of - // ZZZ - the log. volume index inside the assembly volume - // - std::stringstream pvName; - pvName << "av_" - << GetAssemblyID() - << "_impr_" - << GetImprintsCount() - << "_" - << triplets[i].GetVolume()->GetName().c_str() - << "_pv_" - << i - << std::ends; - - // Generate a new physical volume instance inside a mother - // (as we allow 3D transformation use G4ReflectionFactory to - // take into account eventual reflection) - // - G4PhysicalVolumesPair pvPlaced - = G4ReflectionFactory::Instance()->Place( Tfinal, - pvName.str().c_str(), - triplets[i].GetVolume(), - pMotherLV, - false, - numberOfDaughters + i, - surfCheck ); - - // Register the physical volume created by us so we can delete it later - // - fPVStore.push_back( pvPlaced.first ); - info.g4VolumeImprints[vol].push_back(make_pair(new_chain,pvPlaced.first)); + { + // Generate the unique name for the next PV instance + // The name has format: + // + // av_WWW_impr_XXX_YYY_ZZZ + // where the fields mean: + // WWW - assembly volume instance number + // XXX - assembly volume imprint number + // YYY - the name of a log. volume we want to make a placement of + // ZZZ - the log. volume index inside the assembly volume + // + std::stringstream pvName; + pvName << "av_" + << GetAssemblyID() + << "_impr_" + << GetImprintsCount() + << "_" + << triplets[i].GetVolume()->GetName().c_str() + << "_pv_" + << i + << std::ends; + + // Generate a new physical volume instance inside a mother + // (as we allow 3D transformation use G4ReflectionFactory to + // take into account eventual reflection) + // + G4PhysicalVolumesPair pvPlaced + = G4ReflectionFactory::Instance()->Place( Tfinal, + pvName.str().c_str(), + triplets[i].GetVolume(), + pMotherLV, + false, + numberOfDaughters + i, + surfCheck ); + + // Register the physical volume created by us so we can delete it later + // + fPVStore.push_back( pvPlaced.first ); + info.g4VolumeImprints[vol].push_back(make_pair(new_chain,pvPlaced.first)); #if 0 - cout << " Assembly:Parent:" << parent->GetName() << " " << node->GetName() - << " " << (void*)node << " G4:" << pvName.str() << " Daughter:" - << DetectorTools::placementPath(new_chain) << endl; - cout << endl; + cout << " Assembly:Parent:" << parent->GetName() << " " << node->GetName() + << " " << (void*)node << " G4:" << pvName.str() << " Daughter:" + << DetectorTools::placementPath(new_chain) << endl; + cout << endl; #endif - if ( pvPlaced.second ) { - G4Exception("G4AssemblyVolume::MakeImprint(..)", "GeomVol0003", FatalException, - "Fancy construct popping new mother from the stack!"); - //fPVStore.push_back( pvPlaced.second ); + if ( pvPlaced.second ) { + G4Exception("G4AssemblyVolume::MakeImprint(..)", "GeomVol0003", FatalException, + "Fancy construct popping new mother from the stack!"); + //fPVStore.push_back( pvPlaced.second ); + } } - } else if ( triplets[i].GetAssembly() ) { // Place volumes in this assembly with composed transformation - imprint(info, parent, new_chain, (Geant4AssemblyVolume*)triplets[i].GetAssembly(), pMotherLV, Tfinal, i*100+copyNumBase, surfCheck ); + imprint(info, parent, new_chain, (Geant4AssemblyVolume*)triplets[i].GetAssembly(), pMotherLV, Tfinal, i*100+copyNumBase, surfCheck ); } else { --level; @@ -207,20 +207,20 @@ void Geant4AssemblyVolume::imprint(Geant4GeometryInfo& info, "GeomVol0003", FatalException, "Triplet has no volume and no assembly"); } - } + } //cout << "Imprinted assembly level:" << level << " in mother:" << pMotherLV->GetName() << endl; --level; -} +} namespace { static string indent = ""; static Double_t s_identity_rot[] = { 1., 0., 0., 0., 1., 0., 0., 0., 1. }; struct MyTransform3D : public G4Transform3D { MyTransform3D(double XX, double XY, double XZ, double DX, double YX, double YY, double YZ, double DY, double ZX, double ZY, - double ZZ, double DZ) - : G4Transform3D(XX, XY, XZ, DX, YX, YY, YZ, DY, ZX, ZY, ZZ, DZ) { + double ZZ, double DZ) + : G4Transform3D(XX, XY, XZ, DX, YX, YY, YZ, DY, ZX, ZY, ZZ, DZ) { } - MyTransform3D(const double* t, const double* r = s_identity_rot) + MyTransform3D(const double* t, const double* r = s_identity_rot) : G4Transform3D(r[0],r[1],r[2],t[0]*CM_2_MM,r[3],r[4],r[5],t[1]*CM_2_MM,r[6],r[7],r[8],t[2]*CM_2_MM) { } }; @@ -232,9 +232,9 @@ namespace { TGeoShape* s = v->GetShape(); string nam; printout(DEBUG, "G4", "TGeoNode:'%s' Vol:'%s' Shape:'%s' Medium:'%s'", n->GetName(), v->GetName(), s->GetName(), - m->GetName()); + m->GetName()); } - #endif +#endif class G4UserRegionInformation : public G4VUserRegionInformation { public: @@ -242,7 +242,7 @@ namespace { double threshold; bool storeSecondaries; G4UserRegionInformation() - : threshold(0.0), storeSecondaries(false) { + : threshold(0.0), storeSecondaries(false) { } virtual ~G4UserRegionInformation() { } @@ -255,7 +255,7 @@ namespace { /// Initializing Constructor Geant4Converter::Geant4Converter(LCDD& lcdd) - : Geant4Mapping(lcdd), m_checkOverlaps(true) { +: Geant4Mapping(lcdd), m_checkOverlaps(true) { this->Geant4Mapping::init(); m_propagateRegions = true; m_outputLevel = PrintLevel(printLevel() - 1); @@ -263,7 +263,7 @@ Geant4Converter::Geant4Converter(LCDD& lcdd) /// Initializing Constructor Geant4Converter::Geant4Converter(LCDD& lcdd, PrintLevel level) - : Geant4Mapping(lcdd), m_checkOverlaps(true) { +: Geant4Mapping(lcdd), m_checkOverlaps(true) { this->Geant4Mapping::init(); m_propagateRegions = true; m_outputLevel = level; @@ -337,7 +337,7 @@ void* Geant4Converter::handleMaterial(const string& name, Material medium) const for (int i = 0; i < nElements; ++i) { A_total += (mix->GetAmixt())[i]; W_total += (mix->GetWmixt())[i]; - } + } for (int i = 0; i < nElements; ++i) { TGeoElement* e = mix->GetElement(i); G4Element* g4e = (G4Element*) handleElement(e->GetName(), Atom(e)); @@ -349,9 +349,9 @@ void* Geant4Converter::handleMaterial(const string& name, Material medium) const } } else { - double z = m->GetZ(), a = m->GetA(); - if ( z < 1.0000001 ) z = 1.0; - if ( a < 0.5000001 ) a = 1.0; + double z = m->GetZ(), a = m->GetA(); + if ( z < 1.0000001 ) z = 1.0; + if ( a < 0.5000001 ) a = 1.0; mat = new G4Material(name, z, a, density, state, m->GetTemperature(), m->GetPressure()); } stringstream str; @@ -387,23 +387,23 @@ void* Geant4Converter::handleSolid(const string& name, const TGeoShape* shape) c else if (shape->IsA() == TGeoTubeSeg::Class()) { const TGeoTubeSeg* s = (const TGeoTubeSeg*) shape; solid = new G4Tubs(name, s->GetRmin() * CM_2_MM, s->GetRmax() * CM_2_MM, s->GetDz() * CM_2_MM, - s->GetPhi1() * DEGREE_2_RAD, (s->GetPhi2()-s->GetPhi1()) * DEGREE_2_RAD); + s->GetPhi1() * DEGREE_2_RAD, (s->GetPhi2()-s->GetPhi1()) * DEGREE_2_RAD); } else if (shape->IsA() == TGeoTrd1::Class()) { const TGeoTrd1* s = (const TGeoTrd1*) shape; solid = new G4Trd(name, s->GetDx1() * CM_2_MM, s->GetDx2() * CM_2_MM, s->GetDy() * CM_2_MM, s->GetDy() * CM_2_MM, - s->GetDz() * CM_2_MM); + s->GetDz() * CM_2_MM); } else if (shape->IsA() == TGeoTrd2::Class()) { const TGeoTrd2* s = (const TGeoTrd2*) shape; solid = new G4Trd(name, s->GetDx1() * CM_2_MM, s->GetDx2() * CM_2_MM, s->GetDy1() * CM_2_MM, s->GetDy2() * CM_2_MM, - s->GetDz() * CM_2_MM); + s->GetDz() * CM_2_MM); } else if (shape->IsA() == TGeoHype::Class()) { const TGeoHype* s = (const TGeoHype*) shape; - solid = new G4Hype(name, s->GetRmin() * CM_2_MM, s->GetRmax() * CM_2_MM, - s->GetStIn() * DEGREE_2_RAD, s->GetStOut() * DEGREE_2_RAD, - s->GetDz() * CM_2_MM); + solid = new G4Hype(name, s->GetRmin() * CM_2_MM, s->GetRmax() * CM_2_MM, + s->GetStIn() * DEGREE_2_RAD, s->GetStOut() * DEGREE_2_RAD, + s->GetDz() * CM_2_MM); } else if (shape->IsA() == TGeoPgon::Class()) { const TGeoPgon* s = (const TGeoPgon*) shape; @@ -432,7 +432,7 @@ void* Geant4Converter::handleSolid(const string& name, const TGeoShape* shape) c else if (shape->IsA() == TGeoConeSeg::Class()) { const TGeoConeSeg* s = (const TGeoConeSeg*) shape; solid = new G4Cons(name, s->GetRmin1() * CM_2_MM, s->GetRmax1() * CM_2_MM, s->GetRmin2() * CM_2_MM, - s->GetRmax2() * CM_2_MM, s->GetDz() * CM_2_MM, s->GetPhi1() * DEGREE_2_RAD, (s->GetPhi2()-s->GetPhi1()) * DEGREE_2_RAD); + s->GetRmax2() * CM_2_MM, s->GetDz() * CM_2_MM, s->GetPhi1() * DEGREE_2_RAD, (s->GetPhi2()-s->GetPhi1()) * DEGREE_2_RAD); } else if (shape->IsA() == TGeoParaboloid::Class()) { const TGeoParaboloid* s = (const TGeoParaboloid*) shape; @@ -441,18 +441,18 @@ void* Geant4Converter::handleSolid(const string& name, const TGeoShape* shape) c else if (shape->IsA() == TGeoSphere::Class()) { const TGeoSphere* s = (const TGeoSphere*) shape; solid = new G4Sphere(name, s->GetRmin() * CM_2_MM, s->GetRmax() * CM_2_MM, s->GetPhi1() * DEGREE_2_RAD, - s->GetPhi2() * DEGREE_2_RAD, s->GetTheta1() * DEGREE_2_RAD, s->GetTheta2() * DEGREE_2_RAD); + s->GetPhi2() * DEGREE_2_RAD, s->GetTheta1() * DEGREE_2_RAD, s->GetTheta2() * DEGREE_2_RAD); } else if (shape->IsA() == TGeoTorus::Class()) { const TGeoTorus* s = (const TGeoTorus*) shape; solid = new G4Torus(name, s->GetRmin() * CM_2_MM, s->GetRmax() * CM_2_MM, s->GetR() * CM_2_MM, - s->GetPhi1() * DEGREE_2_RAD, s->GetDphi() * DEGREE_2_RAD); + s->GetPhi1() * DEGREE_2_RAD, s->GetDphi() * DEGREE_2_RAD); } else if (shape->IsA() == TGeoTrap::Class()) { const TGeoTrap* s = (const TGeoTrap*) shape; - solid = new G4Trap(name, s->GetDz() * CM_2_MM, s->GetTheta(), s->GetPhi(), - s->GetH1() * CM_2_MM, s->GetBl1() * CM_2_MM, s->GetTl1() * CM_2_MM, s->GetAlpha1() * DEGREE_2_RAD, - s->GetH2() * CM_2_MM, s->GetBl2() * CM_2_MM, s->GetTl2() * CM_2_MM, s->GetAlpha2() * DEGREE_2_RAD); + solid = new G4Trap(name, s->GetDz() * CM_2_MM, s->GetTheta(), s->GetPhi(), + s->GetH1() * CM_2_MM, s->GetBl1() * CM_2_MM, s->GetTl1() * CM_2_MM, s->GetAlpha1() * DEGREE_2_RAD, + s->GetH2() * CM_2_MM, s->GetBl2() * CM_2_MM, s->GetTl2() * CM_2_MM, s->GetAlpha2() * DEGREE_2_RAD); } else if (shape->IsA() == TGeoCompositeShape::Class()) { const TGeoCompositeShape* s = (const TGeoCompositeShape*) shape; @@ -479,7 +479,7 @@ void* Geant4Converter::handleSolid(const string& name, const TGeoShape* shape) c solid = new G4IntersectionSolid(name, left, right, transform); } else { - const Double_t *t = m->GetTranslation(); + const Double_t *t = m->GetTranslation(); G4ThreeVector transform(t[0] * CM_2_MM, t[1] * CM_2_MM, t[2] * CM_2_MM); if (oper == TGeoBoolNode::kGeoSubtraction) solid = new G4SubtractionSolid(name, left, right, 0, transform); @@ -520,7 +520,7 @@ void* Geant4Converter::handleVolume(const string& name, const TGeoVolume* volume sd = info.g4SensDets[det.ptr()]; if (!sd) { throw runtime_error("G4Cnv::volume[" + name + "]: + FATAL Failed to " - "access Geant4 sensitive detector."); + "access Geant4 sensitive detector."); } sd->Activate(true); } @@ -530,7 +530,7 @@ void* Geant4Converter::handleVolume(const string& name, const TGeoVolume* volume user_limits = info.g4Limits[lim]; if (!user_limits) { throw runtime_error("G4Cnv::volume[" + name + "]: + FATAL Failed to " - "access Geant4 user limits."); + "access Geant4 user limits."); } } VisAttr vis = _v.visAttributes(); @@ -544,12 +544,12 @@ void* Geant4Converter::handleVolume(const string& name, const TGeoVolume* volume region = info.g4Regions[reg]; if (!region) { throw runtime_error("G4Cnv::volume[" + name + "]: + FATAL Failed to " - "access Geant4 region."); + "access Geant4 region."); } } PrintLevel lvl = m_outputLevel; //string(det.name())=="SiTrackerBarrel" ? WARNING : m_outputLevel; printout(lvl, "Geant4Converter", "++ Convert Volume %-32s: %p %s/%s assembly:%s sensitive:%s", n.c_str(), v, - s->IsA()->GetName(), v->IsA()->GetName(), yes_no(assembly), yes_no(det.isValid())); + s->IsA()->GetName(), v->IsA()->GetName(), yes_no(assembly), yes_no(det.isValid())); if (assembly) { //info.g4AssemblyVolumes[v] = new Geant4AssemblyVolume(); @@ -576,7 +576,7 @@ void* Geant4Converter::handleVolume(const string& name, const TGeoVolume* volume } if (sd) { printout(m_outputLevel, "Geant4Converter", "++ Volume: + %s <> %s Solid:%s Mat:%s SD:%s", name.c_str(), vol->GetName().c_str(), - solid->GetName().c_str(), medium->GetName().c_str(), sd->GetName().c_str()); + solid->GetName().c_str(), medium->GetName().c_str(), sd->GetName().c_str()); } info.g4Volumes[v] = vol; printout(m_outputLevel, "Geant4Converter", "++ Volume + %s converted: %p ---> G4: %p", n.c_str(), v, vol); @@ -619,28 +619,28 @@ void* Geant4Converter::handleAssembly(const std::string& name, const TGeoNode* n TGeoMatrix* tr = d->GetMatrix(); MyTransform3D transform(tr->GetTranslation(),tr->IsRotation() ? tr->GetRotationMatrix() : s_identity_rot); if ( dau_vol->IsA() == TGeoVolumeAssembly::Class() ) { - AssemblyMap::iterator assIt = info.g4AssemblyVolumes.find(d); - if ( assIt == info.g4AssemblyVolumes.end() ) { - printout(FATAL, "Geant4Converter", "+++ Invalid child assembly at %s : %d parent: %s child:%s", - __FILE__, __LINE__, name.c_str(), d->GetName()); - } - g4->placeAssembly(d,(*assIt).second,transform); + AssemblyMap::iterator assIt = info.g4AssemblyVolumes.find(d); + if ( assIt == info.g4AssemblyVolumes.end() ) { + printout(FATAL, "Geant4Converter", "+++ Invalid child assembly at %s : %d parent: %s child:%s", + __FILE__, __LINE__, name.c_str(), d->GetName()); + } + g4->placeAssembly(d,(*assIt).second,transform); printout(m_outputLevel, "Geant4Converter", "+++ Assembly: AddPlacedAssembly : dau:%s " - "to mother %s Tr:x=%8.3f y=%8.3f z=%8.3f", - dau_vol->GetName(), mot_vol->GetName(), - transform.dx(), transform.dy(), transform.dz()); + "to mother %s Tr:x=%8.3f y=%8.3f z=%8.3f", + dau_vol->GetName(), mot_vol->GetName(), + transform.dx(), transform.dy(), transform.dz()); } else { - VolumeMap::iterator volIt = info.g4Volumes.find(dau_vol); - if ( volIt == info.g4Volumes.end() ) { - printout(FATAL, "Geant4Converter", "+++ Invalid child volume at %s : %d parent: %s child:%s", - __FILE__, __LINE__, name.c_str(), d->GetName()); - } - g4->placeVolume(d,(*volIt).second, transform); + VolumeMap::iterator volIt = info.g4Volumes.find(dau_vol); + if ( volIt == info.g4Volumes.end() ) { + printout(FATAL, "Geant4Converter", "+++ Invalid child volume at %s : %d parent: %s child:%s", + __FILE__, __LINE__, name.c_str(), d->GetName()); + } + g4->placeVolume(d,(*volIt).second, transform); printout(m_outputLevel, "Geant4Converter", "+++ Assembly: AddPlacedVolume : dau:%s " - "to mother %s Tr:x=%8.3f y=%8.3f z=%8.3f", - dau_vol->GetName(), mot_vol->GetName(), - transform.dx(), transform.dy(), transform.dz()); + "to mother %s Tr:x=%8.3f y=%8.3f z=%8.3f", + dau_vol->GetName(), mot_vol->GetName(), + transform.dx(), transform.dy(), transform.dz()); } } info.g4AssemblyVolumes[node] = g4; @@ -659,11 +659,11 @@ void* Geant4Converter::handlePlacement(const string& name, const TGeoNode* node) TGeoMatrix* tr = node->GetMatrix(); if (!tr) { printout(FATAL, "Geant4Converter", "++ Attempt to handle placement without transformation:%p %s of type %s vol:%p", node, - node->GetName(), node->IsA()->GetName(), vol); + node->GetName(), node->IsA()->GetName(), vol); } else if (0 == vol) { printout(FATAL, "Geant4Converter", "++ Unknown G4 volume:%p %s of type %s ptr:%p", node, node->GetName(), - node->IsA()->GetName(), vol); + node->IsA()->GetName(), vol); } else { int copy = node->GetNumber(); @@ -673,48 +673,48 @@ void* Geant4Converter::handlePlacement(const string& name, const TGeoNode* node) VolumeMap::const_iterator volIt = info.g4Volumes.find(mot_vol); if ( mother_is_assembly ) { - // - // Mother is an assembly: - // Nothing to do here, because: - // -- placed volumes were already added before in "handleAssembly" - // -- imprint cannot be made, because this requires a logical volume as a mother - // + // + // Mother is an assembly: + // Nothing to do here, because: + // -- placed volumes were already added before in "handleAssembly" + // -- imprint cannot be made, because this requires a logical volume as a mother + // printout(m_outputLevel, "Geant4Converter", "+++ Assembly: **** : dau:%s " - "to mother %s Tr:x=%8.3f y=%8.3f z=%8.3f", - vol->GetName(), mot_vol->GetName(), - transform.dx(), transform.dy(), transform.dz()); + "to mother %s Tr:x=%8.3f y=%8.3f z=%8.3f", + vol->GetName(), mot_vol->GetName(), + transform.dx(), transform.dy(), transform.dz()); return 0; } else if ( node_is_assembly ) { - // - // Node is an assembly: - // Imprint the assembly. The mother MUST already be transformed. - // + // + // Node is an assembly: + // Imprint the assembly. The mother MUST already be transformed. + // printout(m_outputLevel, "Geant4Converter", "+++ Assembly: makeImprint: dau:%s in mother %s " - "Tr:x=%8.3f y=%8.3f z=%8.3f", - node->GetName(), mot_vol->GetName(), - transform.dx(), transform.dy(), transform.dz()); - Geant4AssemblyVolume* ass = (Geant4AssemblyVolume*)info.g4AssemblyVolumes[node]; - Geant4AssemblyVolume::Chain chain; - chain.push_back(node); - ass->imprint(info,node,chain,ass,(*volIt).second, transform, copy, m_checkOverlaps); - return 0; + "Tr:x=%8.3f y=%8.3f z=%8.3f", + node->GetName(), mot_vol->GetName(), + transform.dx(), transform.dy(), transform.dz()); + Geant4AssemblyVolume* ass = (Geant4AssemblyVolume*)info.g4AssemblyVolumes[node]; + Geant4AssemblyVolume::Chain chain; + chain.push_back(node); + ass->imprint(info,node,chain,ass,(*volIt).second, transform, copy, m_checkOverlaps); + return 0; } else if ( node != gGeoManager->GetTopNode() && volIt == info.g4Volumes.end() ) { - throw logic_error("Geant4Converter: Invalid mother volume found!"); + throw logic_error("Geant4Converter: Invalid mother volume found!"); } else if ( node_is_assembly ) { // g4mot is NULL ! - throw logic_error("Geant4Converter: Invalid mother - daughter relationship in assembly! ["+name+"]"); + throw logic_error("Geant4Converter: Invalid mother - daughter relationship in assembly! ["+name+"]"); } G4LogicalVolume* g4vol = info.g4Volumes[vol]; G4LogicalVolume* g4mot = info.g4Volumes[mot_vol]; g4 = new G4PVPlacement(transform, // no rotation - g4vol, // its logical volume - name, // its name - g4mot, // its mother (logical) volume - false, // no boolean operations - copy, // its copy number - m_checkOverlaps); + g4vol, // its logical volume + name, // its name + g4mot, // its mother (logical) volume + false, // no boolean operations + copy, // its copy number + m_checkOverlaps); } info.g4Placements[node] = g4; } @@ -810,10 +810,10 @@ void* Geant4Converter::handleSensitive(SensitiveDetector sens_det, const set<con if (!g4) { PluginDebug dbg; g4 = ROOT::Reflex::PluginService::Create<G4VSensitiveDetector*>(type, name, &m_lcdd); - if ( !g4 ) { - throw runtime_error("Geant4Converter<SensitiveDetector>: FATAL Failed to " - "create Geant4 sensitive detector factory " + name + " of type " + type + "."); - } + if ( !g4 ) { + throw runtime_error("Geant4Converter<SensitiveDetector>: FATAL Failed to " + "create Geant4 sensitive detector factory " + name + " of type " + type + "."); + } } } g4->Activate(true); @@ -879,7 +879,7 @@ void Geant4Converter::handleProperties(LCDD::Properties& prp) const { long result = ROOT::Reflex::PluginService::Create<long>(tag, &m_lcdd, ptr, &vals); if (0 == result) { throw runtime_error("Failed to locate plugin to interprete files of type" - " \"" + tag + "\" - no factory:" + type); + " \"" + tag + "\" - no factory:" + type); } result = *(long*) result; if (result != 1) { @@ -898,7 +898,7 @@ void* Geant4Converter::printSensitive(SensitiveDetector sens_det, const set<cons stringstream str; printout(INFO, "Geant4Converter", "++ SensitiveDetector: %-18s %-20s Hits:%-16s", sd.name(), ("[" + sd.type() + "]").c_str(), - sd.hitsCollection().c_str()); + sd.hitsCollection().c_str()); str << " | " << "Cutoff:" << setw(6) << left << sd.energyCutoff() << setw(5) << right << volset.size() << " volumes "; if (sd.region().isValid()) diff --git a/DDG4/src/Geant4Data.cpp b/DDG4/src/Geant4Data.cpp index 3c81189d0c12560323dc8769c4a1a33d70a83f2d..408c64fd066bbf294af62dd094442e6298ce19bf 100644 --- a/DDG4/src/Geant4Data.cpp +++ b/DDG4/src/Geant4Data.cpp @@ -24,7 +24,7 @@ using namespace DD4hep::Simulation; /// Default constructor SimpleRun::SimpleRun() - : runID(-1), numEvents(0) { + : runID(-1), numEvents(0) { InstanceCount::increment(this); } @@ -35,7 +35,7 @@ SimpleRun::~SimpleRun() { /// Default constructor SimpleEvent::SimpleEvent() - : runID(-1), eventID(-1) { + : runID(-1), eventID(-1) { InstanceCount::increment(this); } @@ -50,7 +50,7 @@ DataExtension::~DataExtension() { /// Default constructor Geant4HitData::Geant4HitData() - : cellID(0), extension() { +: cellID(0), extension() { InstanceCount::increment(this); } @@ -73,13 +73,13 @@ Geant4HitData::Contribution Geant4HitData::extractContribution(const G4Step* ste /// Default constructor Geant4Tracker::Hit::Hit() - : Geant4HitData(), position(), momentum(), length(0.0), truth(), energyDeposit(0.0) { +: Geant4HitData(), position(), momentum(), length(0.0), truth(), energyDeposit(0.0) { InstanceCount::increment(this); } /// Standard initializing constructor Geant4Tracker::Hit::Hit(int track_id, int pdg_id, double deposit, double time_stamp) - : Geant4HitData(), position(), momentum(), length(0.0), truth(track_id, pdg_id, deposit, time_stamp), energyDeposit(deposit) { +: Geant4HitData(), position(), momentum(), length(0.0), truth(track_id, pdg_id, deposit, time_stamp), energyDeposit(deposit) { InstanceCount::increment(this); } @@ -126,13 +126,13 @@ Geant4Tracker::Hit& Geant4Tracker::Hit::storePoint(const G4Step* step, const G4S /// Default constructor (for ROOT) Geant4Calorimeter::Hit::Hit() - : Geant4HitData(), position(), truth(), energyDeposit(0) { +: Geant4HitData(), position(), truth(), energyDeposit(0) { InstanceCount::increment(this); } /// Standard constructor Geant4Calorimeter::Hit::Hit(const Position& pos) - : Geant4HitData(), position(pos), truth(), energyDeposit(0) { +: Geant4HitData(), position(pos), truth(), energyDeposit(0) { InstanceCount::increment(this); } diff --git a/DDG4/src/Geant4DataDump.cpp b/DDG4/src/Geant4DataDump.cpp index ad55dfd1c814ad00b7af360103623e696cea183e..5193613cebb5d5c3e678b3a917eaeabc5297493c 100644 --- a/DDG4/src/Geant4DataDump.cpp +++ b/DDG4/src/Geant4DataDump.cpp @@ -30,19 +30,19 @@ void Geant4DataDump::print(PrintLevel level, Geant4ParticleHandle p) const { PropertyMask mask(p->reason); int parent = p->parents.empty() ? -1 : *p->parents.begin(); printout(level, m_tag, " +++ TrackID: %6d %12d %6d %-7s %3s %5d %6s %8.3g %-4s %-7s %-7s %-3s", - p->id, - p->pdgID, - parent, - yes_no(mask.isSet(G4PARTICLE_PRIMARY)), - yes_no(mask.isSet(G4PARTICLE_HAS_SECONDARIES)), - int(p->daughters.size()), - yes_no(mask.isSet(G4PARTICLE_ABOVE_ENERGY_THRESHOLD)), - p.energy(), - yes_no(mask.isSet(G4PARTICLE_CREATED_CALORIMETER_HIT)), - yes_no(mask.isSet(G4PARTICLE_CREATED_TRACKER_HIT)), - yes_no(mask.isSet(G4PARTICLE_KEEP_PROCESS)), - mask.isSet(G4PARTICLE_KEEP_PARENT) ? "YES" : "" - ); + p->id, + p->pdgID, + parent, + yes_no(mask.isSet(G4PARTICLE_PRIMARY)), + yes_no(mask.isSet(G4PARTICLE_HAS_SECONDARIES)), + int(p->daughters.size()), + yes_no(mask.isSet(G4PARTICLE_ABOVE_ENERGY_THRESHOLD)), + p.energy(), + yes_no(mask.isSet(G4PARTICLE_CREATED_CALORIMETER_HIT)), + yes_no(mask.isSet(G4PARTICLE_CREATED_TRACKER_HIT)), + yes_no(mask.isSet(G4PARTICLE_KEEP_PROCESS)), + mask.isSet(G4PARTICLE_KEEP_PARENT) ? "YES" : "" + ); } /// Print the particle container to the output logging using the specified print level @@ -50,7 +50,7 @@ void Geant4DataDump::print(PrintLevel level, const std::string& container, const if ( parts ) { printout(level,m_tag,"+++ Track container: %-21s --------------- Track KEEP reasoning ---------------",container.c_str()); printout(level,m_tag,"+++ # of Tracks:%6d PDG Parent Primary Secondary Energy %-8s Calo Tracker Process/Par", - int(parts->size()),"in [MeV]"); + int(parts->size()),"in [MeV]"); for(Particles::const_iterator i=parts->begin(); i!= parts->end(); ++i) print(PrintLevel(level-1), *i); return; @@ -61,7 +61,7 @@ void Geant4DataDump::print(PrintLevel level, const std::string& container, const void Geant4DataDump::print(PrintLevel level, const TrackerHit* h) { const SimpleHit::Contribution& t = h->truth; printout(level,m_tag," +++ Hit: Cell: %016llX Pos:(%9.3g,%9.3g,%9.3g) Len:%9.3g [mm] E:%9.3g MeV TrackID:%6d PDG:%12d dep:%9.3g time:%9.3g [ns]", - h->cellID,h->position.x(),h->position.y(),h->position.z(),h->length,h->energyDeposit,t.trackID,t.pdgID,t.deposit,t.time); + h->cellID,h->position.x(),h->position.y(),h->position.z(),h->length,h->energyDeposit,t.trackID,t.pdgID,t.deposit,t.time); } /// Print the tracker hits container to the output logging using the specified print level @@ -77,13 +77,13 @@ void Geant4DataDump::print(PrintLevel level, const std::string& container, const /// Print a calorimeter tracker hit to the output logging using the specified print level void Geant4DataDump::print(PrintLevel level, const CalorimeterHit* h) { printout(level,m_tag," +++ Hit: Cell: %016llX Pos:(%9.3g,%9.3g,%9.3g) [mm] E:%9.3g MeV #Contributions:%3d", - h->cellID,h->position.x(),h->position.y(),h->position.z(),h->energyDeposit,h->truth.size()); + h->cellID,h->position.x(),h->position.y(),h->position.z(),h->energyDeposit,h->truth.size()); const SimpleHit::Contributions& t = h->truth; int cnt=0; for(SimpleHit::Contributions::const_iterator i=t.begin(); i!=t.end(); ++i,++cnt) { const SimpleHit::Contribution& c = *i; printout(PrintLevel(level-1),m_tag," Contribution #%3d TrackID:%6d PDG:%12d %9.3g MeV %9.3g ns", - cnt,c.trackID,c.pdgID,c.deposit,c.time); + cnt,c.trackID,c.pdgID,c.deposit,c.time); } } diff --git a/DDG4/src/Geant4DetectorConstruction.cpp b/DDG4/src/Geant4DetectorConstruction.cpp index 15ee8bfdb43ac3083f5463ed67fd729171ab4ac1..6cc4a6a656940824fcc7eef4df1480c5868b1745 100644 --- a/DDG4/src/Geant4DetectorConstruction.cpp +++ b/DDG4/src/Geant4DetectorConstruction.cpp @@ -35,7 +35,7 @@ Geant4DetectorConstruction* Geant4DetectorConstruction::instance(Geant4Kernel& k /// Initializing constructor for other clients Geant4DetectorConstruction::Geant4DetectorConstruction(Geometry::LCDD& lcdd) - : Geant4Action(0,"DetectorConstruction"), m_lcdd(lcdd), m_world(0) +: Geant4Action(0,"DetectorConstruction"), m_lcdd(lcdd), m_world(0) { m_outputLevel = PrintLevel(printLevel()-1); s_instance = this; @@ -43,7 +43,7 @@ Geant4DetectorConstruction::Geant4DetectorConstruction(Geometry::LCDD& lcdd) /// Initializing constructor for DDG4 Geant4DetectorConstruction::Geant4DetectorConstruction(Geant4Kernel& kernel) - : Geant4Action(0,"DetectorConstruction"), m_lcdd(kernel.lcdd()), m_world(0) +: Geant4Action(0,"DetectorConstruction"), m_lcdd(kernel.lcdd()), m_world(0) { m_outputLevel = kernel.getOutputLevel("Geant4Converter"); s_instance = this; diff --git a/DDG4/src/Geant4EventAction.cpp b/DDG4/src/Geant4EventAction.cpp index bc9a7ce1d3201e4c883c4dafc3c90279ac275982..c249521c26ba511f46deb666cedcc74ddbfa093f 100644 --- a/DDG4/src/Geant4EventAction.cpp +++ b/DDG4/src/Geant4EventAction.cpp @@ -18,7 +18,7 @@ using namespace DD4hep::Simulation; /// Standard constructor Geant4EventAction::Geant4EventAction(Geant4Context* context, const string& nam) - : Geant4Action(context, nam) { +: Geant4Action(context, nam) { InstanceCount::increment(this); } @@ -37,7 +37,7 @@ void Geant4EventAction::end(const G4Event*) { /// Standard constructor Geant4EventActionSequence::Geant4EventActionSequence(Geant4Context* context, const string& name) - : Geant4Action(context, name) { +: Geant4Action(context, name) { m_needsControl = true; InstanceCount::increment(this); } diff --git a/DDG4/src/Geant4Exec.cpp b/DDG4/src/Geant4Exec.cpp index c6d3321af3fcb2cdfa572ef7bf38ae64b45d8c3b..040c8386f0a3ecb358b0b3beb4ec4c377b85f865 100644 --- a/DDG4/src/Geant4Exec.cpp +++ b/DDG4/src/Geant4Exec.cpp @@ -58,54 +58,54 @@ namespace DD4hep { Geant4Context* m_activeContext; /// Default constructor SequenceHdl() - : m_sequence(0), m_activeContext(0) { + : m_sequence(0), m_activeContext(0) { } SequenceHdl(Geant4Context* context, T* seq) : m_sequence(0), m_activeContext(context) { - _aquire(seq); + _aquire(seq); } virtual ~SequenceHdl() { - _release(); + _release(); } void _aquire(T* s) { - InstanceCount::increment(this); - m_sequence = s; - m_sequence->addRef(); + InstanceCount::increment(this); + m_sequence = s; + m_sequence->addRef(); } void _release() { - releasePtr(m_sequence); - InstanceCount::decrement(this); + releasePtr(m_sequence); + InstanceCount::decrement(this); } void setContextToClients() { - (Geant4Action::ContextUpdate(m_activeContext))(m_sequence); + (Geant4Action::ContextUpdate(m_activeContext))(m_sequence); } void releaseContextFromClients() { - Geant4Action::ContextUpdate(0)(m_sequence); + Geant4Action::ContextUpdate(0)(m_sequence); } void createClientContext(const G4Run* run) { - Geant4Run* r = new Geant4Run(run); - m_activeContext->setRun(r); - setContextToClients(); + Geant4Run* r = new Geant4Run(run); + m_activeContext->setRun(r); + setContextToClients(); } void destroyClientContext(const G4Run*) { - Geant4Run* r = m_activeContext->runPtr(); - releaseContextFromClients(); - if ( r ) { - m_activeContext->setRun(0); - deletePtr(r); - } + Geant4Run* r = m_activeContext->runPtr(); + releaseContextFromClients(); + if ( r ) { + m_activeContext->setRun(0); + deletePtr(r); + } } void createClientContext(const G4Event* evt) { - Geant4Event* e = new Geant4Event(evt,s_globalRandom); - m_activeContext->setEvent(e); - setContextToClients(); + Geant4Event* e = new Geant4Event(evt,s_globalRandom); + m_activeContext->setEvent(e); + setContextToClients(); } void destroyClientContext(const G4Event*) { - Geant4Event* e = m_activeContext->eventPtr(); - releaseContextFromClients(); - if ( e ) { - m_activeContext->setEvent(0); - deletePtr(e); - } + Geant4Event* e = m_activeContext->eventPtr(); + releaseContextFromClients(); + if ( e ) { + m_activeContext->setEvent(0); + deletePtr(e); + } } }; @@ -123,7 +123,7 @@ namespace DD4hep { Geant4UserEventAction* eventAction; /// Standard constructor Geant4UserRunAction(Geant4Context* context, Geant4RunActionSequence* seq) - : Base(context, seq), eventAction(0) { + : Base(context, seq), eventAction(0) { } /// Default destructor virtual ~Geant4UserRunAction() { @@ -145,7 +145,7 @@ namespace DD4hep { Geant4UserRunAction* runAction; /// Standard constructor Geant4UserEventAction(Geant4Context* context, Geant4EventActionSequence* seq) - : Base(context, seq), runAction(0) { + : Base(context, seq), runAction(0) { } /// Default destructor virtual ~Geant4UserEventAction() { @@ -166,22 +166,22 @@ namespace DD4hep { public: /// Standard constructor Geant4UserTrackingAction(Geant4Context* context, Geant4TrackingActionSequence* seq) - : Base(context, seq) { + : Base(context, seq) { } /// Default destructor virtual ~Geant4UserTrackingAction() { } /// Pre-track action callback virtual void PreUserTrackingAction(const G4Track* trk) { - setContextToClients(); - m_sequence->context()->kernel().setTrackMgr(fpTrackingManager); + setContextToClients(); + m_sequence->context()->kernel().setTrackMgr(fpTrackingManager); m_sequence->begin(trk); } /// Post-track action callback virtual void PostUserTrackingAction(const G4Track* trk) { m_sequence->end(trk); - m_sequence->context()->kernel().setTrackMgr(0); - releaseContextFromClients(); //Let's leave this out for now...Frank has dirty tricks. + m_sequence->context()->kernel().setTrackMgr(0); + releaseContextFromClients(); //Let's leave this out for now...Frank has dirty tricks. } }; @@ -195,22 +195,22 @@ namespace DD4hep { public: /// Standard constructor Geant4UserStackingAction(Geant4Context* context, Geant4StackingActionSequence* seq) - : Base(context, seq) { + : Base(context, seq) { } /// Default destructor virtual ~Geant4UserStackingAction() { } /// New-stage callback virtual void NewStage() { - setContextToClients(); + setContextToClients(); m_sequence->newStage(); - releaseContextFromClients(); //Let's leave this out for now...Frank has dirty tricks. + releaseContextFromClients(); //Let's leave this out for now...Frank has dirty tricks. } /// Preparation callback virtual void PrepareNewEvent() { - setContextToClients(); + setContextToClients(); m_sequence->prepare(); - releaseContextFromClients(); //Let's leave this out for now...Frank has dirty tricks. + releaseContextFromClients(); //Let's leave this out for now...Frank has dirty tricks. } }; @@ -224,16 +224,16 @@ namespace DD4hep { public: /// Standard constructor Geant4UserGeneratorAction(Geant4Context* context, Geant4GeneratorActionSequence* seq) - : G4VUserPrimaryGeneratorAction(), Base(context, seq) { + : G4VUserPrimaryGeneratorAction(), Base(context, seq) { } /// Default destructor virtual ~Geant4UserGeneratorAction() { } /// Generate primary particles virtual void GeneratePrimaries(G4Event* event) { - createClientContext(event); + createClientContext(event); (*m_sequence)(event); - releaseContextFromClients(); //Let's leave this out for now...Frank has dirty tricks. + releaseContextFromClients(); //Let's leave this out for now...Frank has dirty tricks. } }; @@ -247,16 +247,16 @@ namespace DD4hep { public: /// Standard constructor Geant4UserSteppingAction(Geant4Context* context, Geant4SteppingActionSequence* seq) - : Base(context, seq) { + : Base(context, seq) { } /// Default destructor virtual ~Geant4UserSteppingAction() { } /// User stepping callback virtual void UserSteppingAction(const G4Step* s) { - setContextToClients(); + setContextToClients(); (*m_sequence)(s, fpSteppingManager); - releaseContextFromClients(); //Let's leave this out for now...Frank has dirty tricks. + releaseContextFromClients(); //Let's leave this out for now...Frank has dirty tricks. } }; @@ -317,7 +317,7 @@ int Geant4Exec::configure(Geant4Kernel& kernel) { // Check if the geometry was loaded if (lcdd.detectors().size() <= 1) { printout(WARNING, "Geant4Exec", "+++ Only %d subdetectors present. " - "You sure you loaded the geometry properly?",int(lcdd.detectors().size())); + "You sure you loaded the geometry properly?",int(lcdd.detectors().size())); } // Get the detector constructed Geant4DetectorConstruction* detector = Geant4DetectorConstruction::instance(kernel); @@ -340,7 +340,7 @@ int Geant4Exec::configure(Geant4Kernel& kernel) { } runManager.SetUserInitialization(physics); // Set user generator action sequence. Not optional, since event context is defined inside - Geant4UserGeneratorAction* gen_action = + Geant4UserGeneratorAction* gen_action = new Geant4UserGeneratorAction(ctx,kernel.generatorAction(false)); runManager.SetUserAction(gen_action); @@ -392,8 +392,8 @@ int Geant4Exec::run(Geant4Kernel& kernel) { if ( ui ) { Geant4Call* c = dynamic_cast<Geant4Call*>(ui); if ( c ) { - (*c)(0); - return 1; + (*c)(0); + return 1; } ui->except("++ Geant4Exec: Failed to start UI interface."); } diff --git a/DDG4/src/Geant4GDMLDetector.cpp b/DDG4/src/Geant4GDMLDetector.cpp index fca6718b31c5461511cca74cfa67e79fd2d95a7b..766b051f2bc95752ac9f337b1fbc81a1660b58f8 100644 --- a/DDG4/src/Geant4GDMLDetector.cpp +++ b/DDG4/src/Geant4GDMLDetector.cpp @@ -11,7 +11,7 @@ using namespace std; using namespace DD4hep; DD4hep::Simulation::Geant4GDMLDetector::Geant4GDMLDetector(const std::string& gdmlFile) - : m_fileName(gdmlFile), m_world(0) { +: m_fileName(gdmlFile), m_world(0) { } G4VPhysicalVolume* DD4hep::Simulation::Geant4GDMLDetector::Construct() { diff --git a/DDG4/src/Geant4GeneratorAction.cpp b/DDG4/src/Geant4GeneratorAction.cpp index e7bf8534447c43d0a4a2b4efd10a4f1a5e496156..3bf2c24f75503dcf293619f40e527e947cfefa36 100644 --- a/DDG4/src/Geant4GeneratorAction.cpp +++ b/DDG4/src/Geant4GeneratorAction.cpp @@ -17,7 +17,7 @@ using namespace DD4hep::Simulation; /// Standard constructor Geant4GeneratorAction::Geant4GeneratorAction(Geant4Context* context, const std::string& name) - : Geant4Action(context, name) { +: Geant4Action(context, name) { InstanceCount::increment(this); } @@ -28,7 +28,7 @@ Geant4GeneratorAction::~Geant4GeneratorAction() { /// Standard constructor Geant4GeneratorActionSequence::Geant4GeneratorActionSequence(Geant4Context* context, const std::string& name) - : Geant4Action(context, name) { +: Geant4Action(context, name) { m_needsControl = true; InstanceCount::increment(this); } diff --git a/DDG4/src/Geant4GeneratorActionInit.cpp b/DDG4/src/Geant4GeneratorActionInit.cpp index 09ee12e1d1c837a34eba79ee74f1775686994f5e..2671ac7329a88ac054c24b5d73d7f78dc888aef0 100644 --- a/DDG4/src/Geant4GeneratorActionInit.cpp +++ b/DDG4/src/Geant4GeneratorActionInit.cpp @@ -20,7 +20,7 @@ using namespace DD4hep::Simulation; /// Standard constructor Geant4GeneratorActionInit::Geant4GeneratorActionInit(Geant4Context* context, const std::string& nam) - : Geant4GeneratorAction(context,nam), m_run(0), m_evtTotal(0), m_evtRun(0) +: Geant4GeneratorAction(context,nam), m_run(0), m_evtTotal(0), m_evtRun(0) { InstanceCount::increment(this); context->kernel().runAction().callAtEnd(this,&Geant4GeneratorActionInit::end); diff --git a/DDG4/src/Geant4GeometryInfo.cpp b/DDG4/src/Geant4GeometryInfo.cpp index 17f4bea5c8dc43c0d7186399ebffc8fd024d2174..2c346fda650c09771a0c18210b504624fcf7a14e 100644 --- a/DDG4/src/Geant4GeometryInfo.cpp +++ b/DDG4/src/Geant4GeometryInfo.cpp @@ -35,7 +35,7 @@ string Geant4GeometryMaps::placementPath(const Geant4PlacementPath& path, bool r /// Default constructor Geant4GeometryInfo::Geant4GeometryInfo() - : TNamed("Geant4GeometryInfo", "Geant4GeometryInfo"), m_world(0), valid(false) { +: TNamed("Geant4GeometryInfo", "Geant4GeometryInfo"), m_world(0), valid(false) { } /// Default destructor diff --git a/DDG4/src/Geant4Handle.cpp b/DDG4/src/Geant4Handle.cpp index 771e55a80553c72049fe962d5694be0e719b4d07..f69bcc6843021d0e4f4891c7602a2724f3cae849 100644 --- a/DDG4/src/Geant4Handle.cpp +++ b/DDG4/src/Geant4Handle.cpp @@ -36,35 +36,35 @@ template <typename TYPE> static inline TYPE* checked_value(TYPE* p) { return p; } throw runtime_error( - format("Geant4Handle", "Attempt to access an invalid object of type:%s!", typeName(typeid(TYPE)).c_str())); + format("Geant4Handle", "Attempt to access an invalid object of type:%s!", typeName(typeid(TYPE)).c_str())); } template <typename TYPE> Geant4Handle<TYPE>::Geant4Handle() - : value(0) { + : value(0) { } template <typename TYPE> Geant4Handle<TYPE>::Geant4Handle(TYPE* typ) - : value(typ) { +: value(typ) { if (value) value->addRef(); } template <typename TYPE> Geant4Handle<TYPE>::Geant4Handle(const Geant4Handle<TYPE>& handle) - : value(0) { + : value(0) { value = handle.get(); if (value) value->addRef(); } template <typename TYPE> Geant4Handle<TYPE>::Geant4Handle(Geant4Kernel& kernel, const string& type_name) - : value(0) { + : value(0) { TypeName typ = TypeName::split(type_name); Geant4Context ctxt(&kernel); Geant4Action* object = PluginService::Create<Geant4Action*>(typ.first, &ctxt, typ.second); if (!object && typ.first == typ.second) { typ.first = typeName(typeid(TYPE)); printout(DEBUG, "Geant4Handle<Geant4Sensitive>", "Object factory for %s not found. Try out %s", typ.second.c_str(), - typ.first.c_str()); + typ.first.c_str()); object = PluginService::Create<Geant4Action*>(typ.first, &ctxt, typ.second); if (!object) { size_t idx = typ.first.rfind(':'); @@ -81,14 +81,14 @@ template <typename TYPE> Geant4Handle<TYPE>::Geant4Handle(Geant4Kernel& kernel, return; } throw runtime_error( - format("Geant4Handle", "Failed to convert object of type %s to handle of type %s!", type_name.c_str(), - typeName(typeid(TYPE)).c_str())); + format("Geant4Handle", "Failed to convert object of type %s to handle of type %s!", type_name.c_str(), + typeName(typeid(TYPE)).c_str())); } throw runtime_error(format("Geant4Handle", "Failed to create object of type %s!", type_name.c_str())); } template <typename TYPE> Geant4Handle<TYPE>::Geant4Handle(Geant4Kernel& kernel, const char* type_name_char) - : value(0) { + : value(0) { string type_name = type_name_char; TypeName typ = TypeName::split(type_name); Geant4Context ctxt(&kernel); @@ -96,7 +96,7 @@ template <typename TYPE> Geant4Handle<TYPE>::Geant4Handle(Geant4Kernel& kernel, if (!object && typ.first == typ.second) { typ.first = typeName(typeid(TYPE)); printout(DEBUG, "Geant4Handle<Geant4Sensitive>", "Object factory for %s not found. Try out %s", typ.second.c_str(), - typ.first.c_str()); + typ.first.c_str()); object = PluginService::Create<Geant4Action*>(typ.first, &ctxt, typ.second); if (!object) { size_t idx = typ.first.rfind(':'); @@ -113,8 +113,8 @@ template <typename TYPE> Geant4Handle<TYPE>::Geant4Handle(Geant4Kernel& kernel, return; } throw runtime_error( - format("Geant4Handle", "Failed to convert object of type %s to handle of type %s!", type_name.c_str(), - typeName(typeid(TYPE)).c_str())); + format("Geant4Handle", "Failed to convert object of type %s to handle of type %s!", type_name.c_str(), + typeName(typeid(TYPE)).c_str())); } throw runtime_error(format("Geant4Handle", "Failed to create object of type %s!", type_name.c_str())); } @@ -194,7 +194,7 @@ namespace DD4hep { } template <> Geant4Handle<Geant4Sensitive>::Geant4Handle(Geant4Kernel& kernel, const string& type_name, - const string& detector) { + const string& detector) { try { Geant4Context ctxt(&kernel); TypeName typ = TypeName::split(type_name); @@ -213,8 +213,8 @@ namespace DD4hep { printout(ERROR, "Geant4Handle<Geant4Sensitive>", "Exception: Unknown exception"); } throw runtime_error( - format("Geant4Handle<Geant4Sensitive>", "Failed to create sensitive object of type %s for detector %s!", - type_name.c_str(), detector.c_str())); + format("Geant4Handle<Geant4Sensitive>", "Failed to create sensitive object of type %s for detector %s!", + type_name.c_str(), detector.c_str())); } } } diff --git a/DDG4/src/Geant4HierarchyDump.cpp b/DDG4/src/Geant4HierarchyDump.cpp index 6e212f8b0e51103a220817c45c6a54e7aa341229..2e6b463f96246271141d838e56aa5a88f4749dcb 100644 --- a/DDG4/src/Geant4HierarchyDump.cpp +++ b/DDG4/src/Geant4HierarchyDump.cpp @@ -76,7 +76,7 @@ static unsigned long m_flags = ~0x0UL; /// Initializing Constructor Geant4HierarchyDump::Geant4HierarchyDump(LCDD& lcdd) - : m_lcdd(lcdd) { +: m_lcdd(lcdd) { } /// Standard destructor @@ -96,7 +96,7 @@ void Geant4HierarchyDump::dump(const string& indent, const G4VPhysicalVolume* v) m_flags &= ~G4DUMP_SOLID; printout(INFO, "Geant4Hierarchy", "%s -> Placement:%s LV:%s Material:%s Solid:%s # of Daughters:%d", indent.c_str(), - _T(v->GetName()), _T(lv->GetName()), _T(mat->GetName()), _T(sol->GetName()), ndau); + _T(v->GetName()), _T(lv->GetName()), _T(mat->GetName()), _T(sol->GetName()), ndau); if (sd && (m_flags & G4DUMP_SOLID)) { str.str(""); @@ -114,7 +114,7 @@ void Geant4HierarchyDump::dump(const string& indent, const G4VPhysicalVolume* v) } if (sd && (m_flags & G4DUMP_SENSDET)) { printout(INFO, "Geant4Hierarchy", "%s Sens.det:%p %s path:%s Active:%-3s #Coll:%d", indent.c_str(), sd, - _T(sd->GetName()), _T(sd->GetFullPathName()), yes_no(sd->isActive()), sd->GetNumberOfCollections()); + _T(sd->GetName()), _T(sd->GetFullPathName()), yes_no(sd->isActive()), sd->GetNumberOfCollections()); } if (ul && (m_flags & G4DUMP_LIMITS)) { printout(INFO, "Geant4Hierarchy", "%s Limits:%s ", indent.c_str(), _T(ul->GetType())); diff --git a/DDG4/src/Geant4HitCollection.cpp b/DDG4/src/Geant4HitCollection.cpp index f6b9c94c5019eb9fca50e7b8ce5430469a207475..0117b8cbf7be6c2f41c4e3415023b5a9e63b59d0 100644 --- a/DDG4/src/Geant4HitCollection.cpp +++ b/DDG4/src/Geant4HitCollection.cpp @@ -23,7 +23,7 @@ Geant4HitWrapper::InvalidHit::~InvalidHit() { /// Initializing Constructor Geant4HitWrapper::HitManipulator::HitManipulator(const ComponentCast& c, const ComponentCast& v) - : cast(c), vec_type(v) { +: cast(c), vec_type(v) { InstanceCount::increment(this); } diff --git a/DDG4/src/Geant4Hits.cpp b/DDG4/src/Geant4Hits.cpp index 8c50f3a243824bc93211fc335b8380312d03c2ca..4f42f5c4e9d520615a56e6112abc9dfeb64b0c9f 100644 --- a/DDG4/src/Geant4Hits.cpp +++ b/DDG4/src/Geant4Hits.cpp @@ -39,8 +39,8 @@ bool Geant4Hit::isGeantino(G4Track* track) { Geant4Hit::Contribution Geant4Hit::extractContribution(G4Step* step) { G4Track* trk = step->GetTrack(); double energy_deposit = - (trk->GetDefinition() == G4OpticalPhoton::OpticalPhotonDefinition()) ? - trk->GetTotalEnergy() : step->GetTotalEnergyDeposit(); + (trk->GetDefinition() == G4OpticalPhoton::OpticalPhotonDefinition()) ? + trk->GetTotalEnergy() : step->GetTotalEnergyDeposit(); Contribution contrib(trk->GetTrackID(), trk->GetDefinition()->GetPDGEncoding(), energy_deposit, trk->GetGlobalTime()); return contrib; } @@ -49,12 +49,12 @@ static G4Allocator<Geant4TrackerHit> TrackerHitAllocator; /// Default constructor Geant4TrackerHit::Geant4TrackerHit() - : Geant4Hit(), position(), momentum(), length(0.0), truth(), energyDeposit(0.0) { +: Geant4Hit(), position(), momentum(), length(0.0), truth(), energyDeposit(0.0) { } /// Standard initializing constructor Geant4TrackerHit::Geant4TrackerHit(int track_id, int pdg_id, double deposit, double time_stamp) - : Geant4Hit(), position(), momentum(), length(0.0), truth(track_id, pdg_id, deposit, time_stamp), energyDeposit(deposit) { +: Geant4Hit(), position(), momentum(), length(0.0), truth(track_id, pdg_id, deposit, time_stamp), energyDeposit(deposit) { } /// Assignment operator @@ -110,7 +110,7 @@ static G4Allocator<Geant4CalorimeterHit> CalorimeterHitAllocator; /// Standard constructor Geant4CalorimeterHit::Geant4CalorimeterHit(const Position& pos) - : Geant4Hit(), position(pos), truth(), energyDeposit(0) { +: Geant4Hit(), position(pos), truth(), energyDeposit(0) { } /// Geant4 required object allocator diff --git a/DDG4/src/Geant4InputAction.cpp b/DDG4/src/Geant4InputAction.cpp index f4f059fe4a61868ab4591b3589fe7316be0322ca..74d0042976421c52e0bfcff9b74d1f21db74a2d2 100644 --- a/DDG4/src/Geant4InputAction.cpp +++ b/DDG4/src/Geant4InputAction.cpp @@ -21,7 +21,7 @@ using namespace DD4hep::Simulation; typedef DD4hep::ReferenceBitMask<int> PropertyMask; /// Initializing constructor -Geant4EventReader::Geant4EventReader(const std::string& nam) +Geant4EventReader::Geant4EventReader(const std::string& nam) : m_name(nam), m_directAccess(false), m_currEvent(0) { } @@ -31,7 +31,7 @@ Geant4EventReader::~Geant4EventReader() { } /// Skip event. To be implemented for sequential sources -Geant4EventReader::EventReaderStatus Geant4EventReader::skipEvent() { +Geant4EventReader::EventReaderStatus Geant4EventReader::skipEvent() { if ( hasDirectAccess() ) { ++m_currEvent; return EVENT_READER_OK; @@ -44,7 +44,7 @@ Geant4EventReader::EventReaderStatus Geant4EventReader::skipEvent() { } /// Move to the indicated event number. -Geant4EventReader::EventReaderStatus +Geant4EventReader::EventReaderStatus Geant4EventReader::moveToEvent(int event_number) { if ( event_number >= INT_MIN ) { return EVENT_READER_OK; // Logic below does not work as expected. @@ -70,7 +70,7 @@ Geant4EventReader::moveToEvent(int event_number) { /// Standard constructor Geant4InputAction::Geant4InputAction(Geant4Context* context, const string& name) - : Geant4GeneratorAction(context,name), m_reader(0) +: Geant4GeneratorAction(context,name), m_reader(0) { declareProperty("Input", m_input); declareProperty("Sync", m_firstEvent=0); @@ -102,12 +102,12 @@ int Geant4InputAction::readParticles(int evt_number, std::vector<Particle*>& par try { m_reader = PluginService::Create<Geant4EventReader*>(tn.first,tn.second); if ( 0 == m_reader ) { - PluginDebug dbg; - m_reader = PluginService::Create<Geant4EventReader*>(tn.first,tn.second); - abortRun(issue(evid)+"Error creating reader plugin.", - "Failed to create file reader of type %s. Cannot open dataset %s", - tn.first.c_str(),tn.second.c_str()); - return Geant4EventReader::EVENT_READER_NO_FACTORY; + PluginDebug dbg; + m_reader = PluginService::Create<Geant4EventReader*>(tn.first,tn.second); + abortRun(issue(evid)+"Error creating reader plugin.", + "Failed to create file reader of type %s. Cannot open dataset %s", + tn.first.c_str(),tn.second.c_str()); + return Geant4EventReader::EVENT_READER_NO_FACTORY; } } catch(const exception& e) { @@ -121,12 +121,12 @@ int Geant4InputAction::readParticles(int evt_number, std::vector<Particle*>& par int status = m_reader->moveToEvent(evid); if ( Geant4EventReader::EVENT_READER_OK != status ) { abortRun(issue(evid)+"Error when moving to event - may be end of file.", - "Error when reading file %s",m_input.c_str()); - } + "Error when reading file %s",m_input.c_str()); + } status = m_reader->readParticles(evid,particles); if ( Geant4EventReader::EVENT_READER_OK != status ) { abortRun(issue(evid)+"Error when reading file - may be end of file.", - "Error when reading file %s",m_input.c_str()); + "Error when reading file %s",m_input.c_str()); } return status; } @@ -147,7 +147,7 @@ void Geant4InputAction::operator()(G4Event* event) { if ( primaries.empty() ) return; print("+++ Particle interaction with %d generator particles ++++++++++++++++++++++++", - int(primaries.size())); + int(primaries.size())); Geant4Vertex* vtx = new Geant4Vertex(); vtx->x = 0; vtx->y = 0; @@ -165,9 +165,9 @@ void Geant4InputAction::operator()(G4Event* event) { if ( p->parents.size() == 0 ) { if ( status.isSet(G4PARTICLE_GEN_EMPTY) || status.isSet(G4PARTICLE_GEN_DOCUMENTATION) ) - vtx->in.insert(p->id); // Beam particles and primary quarks etc. + vtx->in.insert(p->id); // Beam particles and primary quarks etc. else - vtx->out.insert(p->id); // Stuff, to be given to Geant4 together with daughters + vtx->out.insert(p->id); // Stuff, to be given to Geant4 together with daughters } inter->particles.insert(make_pair(p->id,p)); p.dumpWithMomentumAndVertex(outputLevel()-1,name(),"->"); diff --git a/DDG4/src/Geant4InputHandling.cpp b/DDG4/src/Geant4InputHandling.cpp index 887609a7ba0f8d2347d304b9de86e2732ddacec5..fb34c11eeecea1a15c368e22e19aa8ffbeffbb09 100644 --- a/DDG4/src/Geant4InputHandling.cpp +++ b/DDG4/src/Geant4InputHandling.cpp @@ -31,11 +31,11 @@ typedef ReferenceBitMask<int> PropertyMask; /// Initialize the generation of one event int DD4hep::Simulation::generationInitialization(const Geant4Action* /* caller */, - const Geant4Context* context) + const Geant4Context* context) { /** - * This action should register all event extension required for the further - * processing. We want to avoid that every client has to check if a given + * This action should register all event extension required for the further + * processing. We want to avoid that every client has to check if a given * object is present or not and than later install the required data structures. */ context->event().addExtension(new Geant4PrimaryMap()); @@ -44,10 +44,10 @@ int DD4hep::Simulation::generationInitialization(const Geant4Action* /* caller * context->event().addExtension(new Geant4ParticleMap()); // - // The Geant4PrimaryEvent extension contains a whole set of + // The Geant4PrimaryEvent extension contains a whole set of // Geant4PrimaryInteraction objects each may represent a complete // interaction. Particles and vertices may be unbiased. - // This is the input to the translator forming the final + // This is the input to the translator forming the final // Geant4PrimaryInteraction (see below) containing rebiased particle // and vertex maps. Geant4PrimaryEvent* evt = new Geant4PrimaryEvent(); @@ -63,8 +63,8 @@ int DD4hep::Simulation::generationInitialization(const Geant4Action* /* caller * /// Append input interaction to global output static void appendInteraction(const Geant4Action* caller, - Geant4PrimaryInteraction* output, - Geant4PrimaryInteraction* input) + Geant4PrimaryInteraction* output, + Geant4PrimaryInteraction* input) { Geant4PrimaryInteraction::ParticleMap::iterator ip, ipend; for( ip=input->particles.begin(), ipend=input->particles.end(); ip != ipend; ++ip ) { @@ -76,7 +76,7 @@ static void appendInteraction(const Geant4Action* caller, ivfnd = output->vertices.find((*iv).second->mask); if ( ivfnd != output->vertices.end() ) { caller->abortRun("Duplicate primary interaction identifier!", - "Cannot handle 2 interactions with identical identifiers!"); + "Cannot handle 2 interactions with identical identifiers!"); } output->vertices.insert(make_pair((*iv).second->mask,(*iv).second->addRef())); } @@ -95,7 +95,7 @@ static void rebaseParticles(Geant4PrimaryInteraction::ParticleMap& particles, in } static void rebaseVertices(Geant4PrimaryInteraction::VertexMap& vertices, int part_offset) { - Geant4PrimaryInteraction::VertexMap::iterator iv, ivend; + Geant4PrimaryInteraction::VertexMap::iterator iv, ivend; set<int> in, out; set<int>::iterator i; // Now move begin and end-vertex of all primary vertices accordingly @@ -112,7 +112,7 @@ static void rebaseVertices(Geant4PrimaryInteraction::VertexMap& vertices, int pa /// Merge all interactions present in the context int DD4hep::Simulation::mergeInteractions(const Geant4Action* caller, - const Geant4Context* context) + const Geant4Context* context) { typedef Geant4PrimaryEvent::Interaction Interaction; typedef vector<Interaction*> Interactions; @@ -127,7 +127,7 @@ int DD4hep::Simulation::mergeInteractions(const Geant4Action* caller, int vertex_offset = particle_offset; if ( !interaction->applyMask() ) { caller->abortRun("Found single interaction with multiple primary vertices!", - "Cannot merge individual interactions with more than one primary!"); + "Cannot merge individual interactions with more than one primary!"); } rebaseParticles(interaction->particles,particle_offset); rebaseVertices(interaction->vertices,vertex_offset); @@ -143,11 +143,11 @@ int DD4hep::Simulation::mergeInteractions(const Geant4Action* caller, /// Boost particles of one interaction identified by its mask int DD4hep::Simulation::boostInteraction(const Geant4Action* /* caller */, - Geant4PrimaryEvent::Interaction* inter, - double alpha) + Geant4PrimaryEvent::Interaction* inter, + double alpha) { #define SQR(x) (x*x) - Geant4PrimaryEvent::Interaction::VertexMap::iterator iv; + Geant4PrimaryEvent::Interaction::VertexMap::iterator iv; Geant4PrimaryEvent::Interaction::ParticleMap::iterator ip; double gamma = std::sqrt(1 + SQR(tan(alpha))); double betagamma = std::tan(alpha); @@ -195,10 +195,10 @@ int DD4hep::Simulation::boostInteraction(const Geant4Action* /* caller */, /// Smear the primary vertex of an interaction int DD4hep::Simulation::smearInteraction(const Geant4Action* /* caller */, - Geant4PrimaryEvent::Interaction* inter, - double dx, double dy, double dz, double dt) + Geant4PrimaryEvent::Interaction* inter, + double dx, double dy, double dz, double dt) { - Geant4PrimaryEvent::Interaction::VertexMap::iterator iv; + Geant4PrimaryEvent::Interaction::VertexMap::iterator iv; Geant4PrimaryEvent::Interaction::ParticleMap::iterator ip; // Now move begin and end-vertex of all primary vertices accordingly @@ -239,9 +239,9 @@ static G4PrimaryParticle* createG4Primary(const Geant4ParticleHandle p) { static map<Geant4Particle*,G4PrimaryParticle*> getRelevant(set<int>& visited, - map<int,G4PrimaryParticle*>& prim, - Geant4PrimaryInteraction::ParticleMap& pm, - const Geant4ParticleHandle p) + map<int,G4PrimaryParticle*>& prim, + Geant4PrimaryInteraction::ParticleMap& pm, + const Geant4ParticleHandle p) { typedef map<Geant4Particle*,G4PrimaryParticle*> Primaries; Primaries res; @@ -269,27 +269,27 @@ getRelevant(set<int>& visited, map<int,G4PrimaryParticle*>::iterator ip4 = prim.find(p->id); G4PrimaryParticle* p4 = (ip4 == prim.end()) ? 0 : (*ip4).second; if ( !p4 ) { - p4 = createG4Primary(p); - p4->SetProperTime(proper_time); - prim[p->id] = p4; - Primaries daughters; - for(Geant4Particle::Particles::const_iterator i=dau.begin(); i!=dau.end(); ++i) { - if ( visited.find(*i) == visited.end() ) { - Primaries tmp = getRelevant(visited,prim,pm,pm[*i]); - daughters.insert(tmp.begin(),tmp.end()); - } - } - for(Primaries::iterator i=daughters.begin(); i!=daughters.end(); ++i) - p4->SetDaughter((*i).second); + p4 = createG4Primary(p); + p4->SetProperTime(proper_time); + prim[p->id] = p4; + Primaries daughters; + for(Geant4Particle::Particles::const_iterator i=dau.begin(); i!=dau.end(); ++i) { + if ( visited.find(*i) == visited.end() ) { + Primaries tmp = getRelevant(visited,prim,pm,pm[*i]); + daughters.insert(tmp.begin(),tmp.end()); + } + } + for(Primaries::iterator i=daughters.begin(); i!=daughters.end(); ++i) + p4->SetDaughter((*i).second); } res.insert(make_pair(p,p4)); } else { for(Geant4Particle::Particles::const_iterator i=dau.begin(); i!=dau.end(); ++i) { - if ( visited.find(*i) == visited.end() ) { - Primaries tmp = getRelevant(visited,prim,pm,pm[*i]); - res.insert(tmp.begin(),tmp.end()); - } + if ( visited.find(*i) == visited.end() ) { + Primaries tmp = getRelevant(visited,prim,pm,pm[*i]); + res.insert(tmp.begin(),tmp.end()); + } } } } @@ -298,8 +298,8 @@ getRelevant(set<int>& visited, /// Generate all primary vertices corresponding to the merged interaction int DD4hep::Simulation::generatePrimaries(const Geant4Action* caller, - const Geant4Context* context, - G4Event* event) + const Geant4Context* context, + G4Event* event) { typedef map<Geant4Particle*,G4PrimaryParticle*> Primaries; typedef Geant4PrimaryInteraction Interaction; @@ -318,25 +318,25 @@ int DD4hep::Simulation::generatePrimaries(const Geant4Action* caller, G4PrimaryVertex* v4 = new G4PrimaryVertex(v->x,v->y,v->z,v->time); event->AddPrimaryVertex(v4); caller->print("+++++ G4PrimaryVertex at (%+.2e,%+.2e,%+.2e) [mm] %+.2e [ns]", - v->x/mm,v->y/mm,v->z/mm,v->time/ns); + v->x/mm,v->y/mm,v->z/mm,v->time/ns); for(Geant4Vertex::Particles::const_iterator ip=v->out.begin(); ip!=v->out.end(); ++ip) { Geant4ParticleHandle p = pm[*ip]; if ( p->daughters.size() > 0 ) { - PropertyMask mask(p->reason); - mask.set(G4PARTICLE_HAS_SECONDARIES); + PropertyMask mask(p->reason); + mask.set(G4PARTICLE_HAS_SECONDARIES); } if ( p->parents.size() == 0 ) { - Primaries relevant = getRelevant(visited,prim,pm,p); - for(Primaries::const_iterator j=relevant.begin(); j!= relevant.end(); ++j) { - Geant4ParticleHandle r = (*j).first; - G4PrimaryParticle* p4 = (*j).second; - PropertyMask reason(r->reason); - reason.set(G4PARTICLE_PRIMARY); - v4->SetPrimary(p4); - ::snprintf(text,sizeof(text),"-> G4Primary[%3d]",num_part); - r.dumpWithMomentum(caller->outputLevel()-1,caller->name(),text); - ++num_part; - } + Primaries relevant = getRelevant(visited,prim,pm,p); + for(Primaries::const_iterator j=relevant.begin(); j!= relevant.end(); ++j) { + Geant4ParticleHandle r = (*j).first; + G4PrimaryParticle* p4 = (*j).second; + PropertyMask reason(r->reason); + reason.set(G4PARTICLE_PRIMARY); + v4->SetPrimary(p4); + ::snprintf(text,sizeof(text),"-> G4Primary[%3d]",num_part); + r.dumpWithMomentum(caller->outputLevel()-1,caller->name(),text); + ++num_part; + } } } } diff --git a/DDG4/src/Geant4InteractionMerger.cpp b/DDG4/src/Geant4InteractionMerger.cpp index 7423bca01b612e88d85ce1abc0eb7914d656aa3a..bcc22fba8251d0460875dd29c1ba7d923ced2d92 100644 --- a/DDG4/src/Geant4InteractionMerger.cpp +++ b/DDG4/src/Geant4InteractionMerger.cpp @@ -16,7 +16,7 @@ using namespace DD4hep::Simulation; /// Standard constructor Geant4InteractionMerger::Geant4InteractionMerger(Geant4Context* context, const std::string& nam) - : Geant4GeneratorAction(context,nam) +: Geant4GeneratorAction(context,nam) { InstanceCount::increment(this); } diff --git a/DDG4/src/Geant4InteractionVertexBoost.cpp b/DDG4/src/Geant4InteractionVertexBoost.cpp index 1960fd9d1822ecbaa225c323504ef1e0d37d887b..a1b3addc79f2327bbf39113c6d65202fe082e54c 100644 --- a/DDG4/src/Geant4InteractionVertexBoost.cpp +++ b/DDG4/src/Geant4InteractionVertexBoost.cpp @@ -17,7 +17,7 @@ using namespace DD4hep::Simulation; /// Standard constructor Geant4InteractionVertexBoost::Geant4InteractionVertexBoost(Geant4Context* context, const std::string& name) - : Geant4GeneratorAction(context, name) +: Geant4GeneratorAction(context, name) { InstanceCount::increment(this); declareProperty("Angle", m_angle = 0); @@ -32,7 +32,7 @@ Geant4InteractionVertexBoost::~Geant4InteractionVertexBoost() { /// Callback to generate primary particles void Geant4InteractionVertexBoost::operator()(G4Event*) { - Geant4PrimaryEvent::Interaction* inter = + Geant4PrimaryEvent::Interaction* inter = context()->event().extension<Geant4PrimaryEvent>()->get(m_mask); if ( inter ) { boostInteraction(this, inter, m_angle); diff --git a/DDG4/src/Geant4InteractionVertexSmear.cpp b/DDG4/src/Geant4InteractionVertexSmear.cpp index 5e33448d1b2ef2dced38c925f9db8fafc23b18a5..856a34d987b12d647473da67e661dd800e65d2ef 100644 --- a/DDG4/src/Geant4InteractionVertexSmear.cpp +++ b/DDG4/src/Geant4InteractionVertexSmear.cpp @@ -22,7 +22,7 @@ using namespace DD4hep::Simulation; /// Standard constructor Geant4InteractionVertexSmear::Geant4InteractionVertexSmear(Geant4Context* context, const std::string& name) - : Geant4GeneratorAction(context, name) +: Geant4GeneratorAction(context, name) { InstanceCount::increment(this); declareProperty("Offset", m_offset); @@ -49,8 +49,8 @@ void Geant4InteractionVertexSmear::operator()(G4Event*) { double dz = rndm.gauss(m_offset.z(),m_sigma.z()); double dt = rndm.gauss(m_offset.t(),m_sigma.t()); print("+++ Smearing primary vertex for interaction type %d (%d Vertices, %d particles) " - "by (%+.2e mm, %+.2e mm, %+.2e mm, %+.2e ns)", - m_mask,int(inter->vertices.size()),int(inter->particles.size()),dx,dy,dz,dt); + "by (%+.2e mm, %+.2e mm, %+.2e mm, %+.2e ns)", + m_mask,int(inter->vertices.size()),int(inter->particles.size()),dx,dy,dz,dt); smearInteraction(this,inter,dx,dy,dz,dt); } else { diff --git a/DDG4/src/Geant4IsotropeGenerator.cpp b/DDG4/src/Geant4IsotropeGenerator.cpp index 56894a4c7f0b831fe03dba8a6ee0ea77c5465175..b0b83b06e7866c77920766ae83857c5b8bfd07b0 100644 --- a/DDG4/src/Geant4IsotropeGenerator.cpp +++ b/DDG4/src/Geant4IsotropeGenerator.cpp @@ -28,7 +28,7 @@ using namespace DD4hep::Simulation; /// Standard constructor Geant4IsotropeGenerator::Geant4IsotropeGenerator(Geant4Context* context, const string& name) - : Geant4GeneratorAction(context, name), m_position(0,0,0), m_particle(0) +: Geant4GeneratorAction(context, name), m_position(0,0,0), m_particle(0) { InstanceCount::increment(this); m_needsControl = true; @@ -94,7 +94,7 @@ void Geant4IsotropeGenerator::operator()(G4Event*) { inter->particles.insert(make_pair(p->id,p)); vtx->out.insert(p->id); printout(INFO,name(),"Particle [%d] %s %.3f GeV direction:(%6.3f %6.3f %6.3f)", - p->id, m_particleName.c_str(), momentum/GeV, x1, x2, x3); + p->id, m_particleName.c_str(), momentum/GeV, x1, x2, x3); } } diff --git a/DDG4/src/Geant4Kernel.cpp b/DDG4/src/Geant4Kernel.cpp index df65d48c2a98b3da64a03c80352892ca3706b1a9..6736095f85f95eead39a5887c153ba923d6d84d3 100644 --- a/DDG4/src/Geant4Kernel.cpp +++ b/DDG4/src/Geant4Kernel.cpp @@ -38,12 +38,12 @@ using namespace DD4hep::Simulation; /// Standard constructor Geant4Kernel::PhaseSelector::PhaseSelector(Geant4Kernel* kernel) - : m_kernel(kernel) { +: m_kernel(kernel) { } /// Copy constructor Geant4Kernel::PhaseSelector::PhaseSelector(const PhaseSelector& c) - : m_kernel(c.m_kernel) { +: m_kernel(c.m_kernel) { } /// Assignment operator @@ -65,9 +65,9 @@ Geant4ActionPhase& Geant4Kernel::PhaseSelector::operator[](const std::string& na /// Standard constructor Geant4Kernel::Geant4Kernel(LCDD& lcdd) - : m_runManager(0), m_generatorAction(0), m_runAction(0), m_eventAction(0), - m_trackingAction(0), m_steppingAction(0), m_stackingAction(0), m_sensDetActions(0), - m_physicsList(0), m_lcdd(lcdd), phase(this) { +: m_runManager(0), m_generatorAction(0), m_runAction(0), m_eventAction(0), + m_trackingAction(0), m_steppingAction(0), m_stackingAction(0), m_sensDetActions(0), + m_physicsList(0), m_lcdd(lcdd), phase(this) { #if 0 registerSequence(m_runAction, "RunAction"); registerSequence(m_eventAction, "EventAction"); @@ -137,7 +137,7 @@ Geant4Kernel& Geant4Kernel::access(LCDD& lcdd) { Geant4Kernel* kernel = lcdd.extension<Geant4Kernel>(); if (!kernel) { throw runtime_error(format("Geant4Kernel", "DDG4: The LCDD object has no registered " - "extension of type Geant4Kernel [No-Extension]")); + "extension of type Geant4Kernel [No-Extension]")); } return *kernel; } @@ -238,14 +238,14 @@ Geant4Kernel& Geant4Kernel::registerGlobalAction(Geant4Action* action) { action->addRef(); m_globalActions[nam] = action; printout(INFO,"Geant4Kernel","++ Registered global action %s of type %s", - nam.c_str(),typeName(typeid(*action)).c_str()); + nam.c_str(),typeName(typeid(*action)).c_str()); return *this; } throw runtime_error(format("Geant4Kernel", "DDG4: The action '%s' is already globally " - "registered. [Action-Already-Registered]", nam.c_str())); + "registered. [Action-Already-Registered]", nam.c_str())); } throw runtime_error(format("Geant4Kernel", "DDG4: Attempt to globally register an invalid " - "action. [Action-Invalid]")); + "action. [Action-Invalid]")); } /// Retrieve action from repository @@ -254,7 +254,7 @@ Geant4Action* Geant4Kernel::globalAction(const std::string& action_name, bool th if (i == m_globalActions.end()) { if (throw_if_not_present) { throw runtime_error(format("Geant4Kernel", "DDG4: The action '%s' is not globally " - "registered. [Action-Missing]", action_name.c_str())); + "registered. [Action-Missing]", action_name.c_str())); } return 0; } @@ -276,10 +276,10 @@ Geant4Kernel& Geant4Kernel::registerGlobalFilter(Geant4Action* filter) { return *this; } throw runtime_error(format("Geant4Kernel", "DDG4: The filter '%s' is already globally " - "registered. [Filter-Already-Registered]", nam.c_str())); + "registered. [Filter-Already-Registered]", nam.c_str())); } throw runtime_error(format("Geant4Kernel", "DDG4: Attempt to globally register an invalid " - "filter. [Filter-Invalid]")); + "filter. [Filter-Invalid]")); } /// Retrieve filter from repository @@ -288,7 +288,7 @@ Geant4Action* Geant4Kernel::globalFilter(const std::string& filter_name, bool th if (i == m_globalFilters.end()) { if (throw_if_not_present) { throw runtime_error(format("Geant4Kernel", "DDG4: The filter '%s' is not already globally " - "registered. [Filter-Missing]", filter_name.c_str())); + "registered. [Filter-Missing]", filter_name.c_str())); } return 0; } @@ -302,12 +302,12 @@ Geant4ActionPhase* Geant4Kernel::getPhase(const std::string& nam) { return (*i).second; } throw runtime_error(format("Geant4Kernel", "DDG4: The Geant4 action phase '%s' " - "does not exist. [No-Entry]", nam.c_str())); + "does not exist. [No-Entry]", nam.c_str())); } /// Add a new phase Geant4ActionPhase* Geant4Kernel::addPhase(const std::string& nam, const type_info& arg0, const type_info& arg1, - const type_info& arg2, bool throw_on_exist) { + const type_info& arg2, bool throw_on_exist) { Phases::const_iterator i = m_phases.find(nam); if (i == m_phases.end()) { Geant4Context ctxt(this); @@ -317,7 +317,7 @@ Geant4ActionPhase* Geant4Kernel::addPhase(const std::string& nam, const type_inf } else if (throw_on_exist) { throw runtime_error(format("Geant4Kernel", "DDG4: The Geant4 action phase %s " - "already exists. [Already-Exists]", nam.c_str())); + "already exists. [Already-Exists]", nam.c_str())); } return (*i).second; } diff --git a/DDG4/src/Geant4Mapping.cpp b/DDG4/src/Geant4Mapping.cpp index 02aa98d96547dc175c9268bc2421a0c59d06073c..6a82361824fe8ce3cbcea58a9c0400ee4d7be893 100644 --- a/DDG4/src/Geant4Mapping.cpp +++ b/DDG4/src/Geant4Mapping.cpp @@ -18,7 +18,7 @@ using namespace std; /// Initializing Constructor Geant4Mapping::Geant4Mapping(LCDD& lcdd) - : m_lcdd(lcdd), m_dataPtr(0) { +: m_lcdd(lcdd), m_dataPtr(0) { } /// Standard destructor diff --git a/DDG4/src/Geant4Output2ROOT.cpp b/DDG4/src/Geant4Output2ROOT.cpp index 5bcc98f0bd1dcda228880144231a0548c5fb2e74..b4c247be7af41ee1e9918079ec59dbe0a907ba59 100644 --- a/DDG4/src/Geant4Output2ROOT.cpp +++ b/DDG4/src/Geant4Output2ROOT.cpp @@ -29,7 +29,7 @@ using namespace std; /// Standard constructor Geant4Output2ROOT::Geant4Output2ROOT(Geant4Context* context, const string& nam) - : Geant4OutputAction(context, nam), m_file(0), m_tree(0) { +: Geant4OutputAction(context, nam), m_file(0), m_tree(0) { declareProperty("Section", m_section = "EVENT"); declareProperty("HandleMCTruth", m_handleMCTruth = true); InstanceCount::increment(this); @@ -161,27 +161,27 @@ void Geant4Output2ROOT::saveCollection(OutputContext<G4Event>& /* ctxt */, G4VHi Geant4ParticleMap* truth = context()->event().extension<Geant4ParticleMap>(); if ( m_handleMCTruth && truth && nhits > 0 ) { try { - for(size_t i=0; i<nhits; ++i) { - Geant4HitData* h = coll->hit(i); - Geant4Tracker::Hit* trk_hit = dynamic_cast<Geant4Tracker::Hit*>(h); - if ( 0 != trk_hit ) { - Geant4HitData::Contribution& t = trk_hit->truth; - int trackID = t.trackID; - t.trackID = truth->particleID(trackID); - } - Geant4Calorimeter::Hit* cal_hit = dynamic_cast<Geant4Calorimeter::Hit*>(h); - if ( 0 != cal_hit ) { - Geant4HitData::Contributions& c = cal_hit->truth; - for(Geant4HitData::Contributions::iterator j=c.begin(); j!=c.end(); ++j) { - Geant4HitData::Contribution& t = *j; - int trackID = t.trackID; - t.trackID = truth->particleID(trackID); - } - } - } + for(size_t i=0; i<nhits; ++i) { + Geant4HitData* h = coll->hit(i); + Geant4Tracker::Hit* trk_hit = dynamic_cast<Geant4Tracker::Hit*>(h); + if ( 0 != trk_hit ) { + Geant4HitData::Contribution& t = trk_hit->truth; + int trackID = t.trackID; + t.trackID = truth->particleID(trackID); + } + Geant4Calorimeter::Hit* cal_hit = dynamic_cast<Geant4Calorimeter::Hit*>(h); + if ( 0 != cal_hit ) { + Geant4HitData::Contributions& c = cal_hit->truth; + for(Geant4HitData::Contributions::iterator j=c.begin(); j!=c.end(); ++j) { + Geant4HitData::Contribution& t = *j; + int trackID = t.trackID; + t.trackID = truth->particleID(trackID); + } + } + } } catch(...) { - printout(ERROR,name(),"+++ Exception while saving collection %s.",hc_nam.c_str()); + printout(ERROR,name(),"+++ Exception while saving collection %s.",hc_nam.c_str()); } } fill(hc_nam, coll->vector_type(), &hits); diff --git a/DDG4/src/Geant4OutputAction.cpp b/DDG4/src/Geant4OutputAction.cpp index e0c2d1accdffcf80f9d36f7d9b256e65be9de54e..0a0f91c5b400e47383f2a7ac2b0e16287b345ce4 100644 --- a/DDG4/src/Geant4OutputAction.cpp +++ b/DDG4/src/Geant4OutputAction.cpp @@ -23,7 +23,7 @@ using namespace std; /// Standard constructor Geant4OutputAction::Geant4OutputAction(Geant4Context* ctxt, const string& nam) - : Geant4EventAction(ctxt, nam) +: Geant4EventAction(ctxt, nam) { InstanceCount::increment(this); declareProperty("Output", m_output); @@ -55,7 +55,7 @@ void Geant4OutputAction::end(const G4Event* evt) { return; } printout(WARNING,"Geant4OutputAction", - "+++ The value of G4HCofThisEvent is NULL. No collections saved!"); + "+++ The value of G4HCofThisEvent is NULL. No collections saved!"); } /// Commit data at end of filling procedure diff --git a/DDG4/src/Geant4Particle.cpp b/DDG4/src/Geant4Particle.cpp index 4d9fe1abd9611fef72eb4a914b710f74ad63b6cf..7ba98359b5adec8988686fed4ee6a9be5faac82a 100644 --- a/DDG4/src/Geant4Particle.cpp +++ b/DDG4/src/Geant4Particle.cpp @@ -35,10 +35,10 @@ Geant4Particle::Geant4Particle(const Geant4Particle& c) : ref(1), id(c.id), 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), + 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) @@ -53,14 +53,14 @@ Geant4Particle::Geant4Particle(const Geant4Particle& c) /// Default constructor Geant4Particle::Geant4Particle() - : ref(1), id(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), +: ref(1), id(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) { InstanceCount::increment(this); @@ -70,14 +70,14 @@ Geant4Particle::Geant4Particle() /// Constructor with ID initialization Geant4Particle::Geant4Particle(int part_id) - : ref(1), id(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), +: ref(1), id(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) { InstanceCount::increment(this); @@ -101,31 +101,31 @@ void Geant4Particle::release() { /// Assignment operator Geant4Particle& Geant4Particle::get_data(Geant4Particle& c) { if ( this != &c ) { - id = c.id; + id = c.id; g4Parent = c.g4Parent; - reason = c.reason; + reason = c.reason; mask = c.mask; status = c.status; charge = c.charge; - steps = c.steps; + steps = c.steps; secondaries = c.secondaries; pdgID = c.pdgID; vsx = c.vsx; vsy = c.vsy; - vsz = c.vsz; + vsz = c.vsz; vex = c.vex; vey = c.vey; - vez = c.vez; + vez = c.vez; psx = c.psx; psy = c.psy; - psz = c.psz; + psz = c.psz; pex = c.pex; pey = c.pey; - pez = c.pez; + pez = c.pez; mass = c.mass; time = c.time; properTime = c.properTime; - process = c.process; + process = c.process; //definition = c.definition; daughters = c.daughters; parents = c.parents; @@ -146,7 +146,7 @@ const G4ParticleDefinition* Geant4ParticleHandle::definition() const { G4ParticleTable* tab = G4ParticleTable::GetParticleTable(); G4ParticleDefinition* def = tab->FindParticle(particle->pdgID); if ( 0 == def && 0 == particle->pdgID ) { - if ( fabs(particle->charge) < 0.001 ) + if ( fabs(particle->charge) < 0.001 ) return G4Geantino::Definition(); return G4ChargedGeantino::Definition(); } @@ -228,7 +228,7 @@ void Geant4ParticleHandle::dump1(int level, const std::string& src, const char* char text[256]; Geant4ParticleHandle p(*this); text[0]=0; - if ( p->parents.size() == 1 ) + if ( p->parents.size() == 1 ) ::snprintf(text,sizeof(text),"/%d",*(p->parents.begin())); else if ( p->parents.size() > 1 ) { text[0]='/';text[1]=0; @@ -236,15 +236,15 @@ void Geant4ParticleHandle::dump1(int level, const std::string& src, const char* ::snprintf(text+strlen(text),sizeof(text)-strlen(text),"%d ",*i); } printout((DD4hep::PrintLevel)level,src, - "+++ %s %4d def [%-11s,%8s] reason:%8d E:%+.2e %3s #Dau:%3d #Par:%3d%-5s", - tag, p->id, - p.particleName().c_str(), - p.particleType().c_str(), - p->reason, - p.energy(), - p->g4Parent>0 ? "Sim" : "Gen", - int(p->daughters.size()), - int(p->parents.size()),text); + "+++ %s %4d def [%-11s,%8s] reason:%8d E:%+.2e %3s #Dau:%3d #Par:%3d%-5s", + tag, p->id, + p.particleName().c_str(), + p.particleType().c_str(), + p->reason, + p.energy(), + p->g4Parent>0 ? "Sim" : "Gen", + int(p->daughters.size()), + int(p->parents.size()),text); } /// Output type 2:+++ <tag> 20 G4: 7 def:0xde4eaa8 [gamma , gamma] reason: 20 E:+3.304035e+01 in record:YES \#Par: 1/18 \#Dau: 0 @@ -255,16 +255,16 @@ void Geant4ParticleHandle::dump2(int level, const std::string& src, const char* else if ( p->parents.size() == 1 ) ::snprintf(text,sizeof(text),"/%d",*(p->parents.begin())); else if ( p->parents.size() > 1 ) ::snprintf(text,sizeof(text),"/%d..",*(p->parents.begin())); printout((DD4hep::PrintLevel)level,src, - "+++ %s %4d G4:%4d [%-12s,%8s] reason:%8d " - "E:%+.2e in record:%s #Par:%3d%-5s #Dau:%3d", - tag, p->id, g4id, - p.particleName().c_str(), - p.particleType().c_str(), - p->reason, - p.energy(), - yes_no(inrec), - int(p->parents.size()),text, - int(p->daughters.size())); + "+++ %s %4d G4:%4d [%-12s,%8s] reason:%8d " + "E:%+.2e in record:%s #Par:%3d%-5s #Dau:%3d", + tag, p->id, g4id, + p.particleName().c_str(), + p.particleType().c_str(), + p->reason, + p.energy(), + yes_no(inrec), + int(p->parents.size()),text, + int(p->daughters.size())); } /// Output type 3:+++ <tag> ID: 0 e- status:00000014 type: 11 Vertex:(+0.00e+00,+0.00e+00,+0.00e+00) [mm] time: +0.00e+00 [ns] \#Par: 0 \#Dau: 4 @@ -272,7 +272,7 @@ void Geant4ParticleHandle::dumpWithVertex(int level, const std::string& src, con char text[256]; Geant4ParticleHandle p(*this); text[0]=0; - if ( p->parents.size() == 1 ) + if ( p->parents.size() == 1 ) ::snprintf(text,sizeof(text),"/%d",*(p->parents.begin())); else if ( p->parents.size() > 1 ) { text[0]='/';text[1]=0; @@ -280,13 +280,13 @@ void Geant4ParticleHandle::dumpWithVertex(int level, const std::string& src, con ::snprintf(text+strlen(text),sizeof(text)-strlen(text),"%d ",*i); } printout((DD4hep::PrintLevel)level,src, - "+++ %s ID:%3d %-12s status:%08X PDG:%6d Vtx:(%+.2e,%+.2e,%+.2e)[mm] " - "time: %+.2e [ns] #Dau:%3d #Par:%1d%-6s", - tag,p->id,p.particleName().c_str(),p->status,p->pdgID, - p->vsx/mm,p->vsy/mm,p->vsz/mm,p->time/ns, - p->daughters.size(), - p->parents.size(), - text); + "+++ %s ID:%3d %-12s status:%08X PDG:%6d Vtx:(%+.2e,%+.2e,%+.2e)[mm] " + "time: %+.2e [ns] #Dau:%3d #Par:%1d%-6s", + tag,p->id,p.particleName().c_str(),p->status,p->pdgID, + p->vsx/mm,p->vsy/mm,p->vsz/mm,p->time/ns, + p->daughters.size(), + p->parents.size(), + text); } @@ -295,7 +295,7 @@ void Geant4ParticleHandle::dumpWithMomentum(int level, const std::string& src, c char text[256]; Geant4ParticleHandle p(*this); text[0]=0; - if ( p->parents.size() == 1 ) + if ( p->parents.size() == 1 ) ::snprintf(text,sizeof(text),"/%d",*(p->parents.begin())); else if ( p->parents.size() > 1 ) { text[0]='/';text[1]=0; @@ -303,13 +303,13 @@ void Geant4ParticleHandle::dumpWithMomentum(int level, const std::string& src, c ::snprintf(text+strlen(text),sizeof(text)-strlen(text),"%d ",*i); } printout((DD4hep::PrintLevel)level,src, - "+++%s ID:%3d %-12s stat:%08X PDG:%6d Mom:(%+.2e,%+.2e,%+.2e)[MeV] " - "time: %+.2e [ns] #Dau:%3d #Par:%1d%-6s", - tag,p->id,p.particleName().c_str(),p->status,p->pdgID, - p->psx/MeV,p->psy/MeV,p->psz/MeV,p->time/ns, - int(p->daughters.size()), - int(p->parents.size()), - text); + "+++%s ID:%3d %-12s stat:%08X PDG:%6d Mom:(%+.2e,%+.2e,%+.2e)[MeV] " + "time: %+.2e [ns] #Dau:%3d #Par:%1d%-6s", + tag,p->id,p.particleName().c_str(),p->status,p->pdgID, + p->psx/MeV,p->psy/MeV,p->psz/MeV,p->time/ns, + int(p->daughters.size()), + int(p->parents.size()), + text); } /// Output type 3:+++ <tag> ID: 0 e- status:00000014 type: 11 Vertex:(+0.00e+00,+0.00e+00,+0.00e+00) [mm] time: +0.00e+00 [ns] \#Par: 0 \#Dau: 4 @@ -317,7 +317,7 @@ void Geant4ParticleHandle::dumpWithMomentumAndVertex(int level, const std::strin char text[256]; Geant4ParticleHandle p(*this); text[0]=0; - if ( p->parents.size() == 1 ) + if ( p->parents.size() == 1 ) ::snprintf(text,sizeof(text),"/%d",*(p->parents.begin())); else if ( p->parents.size() > 1 ) { text[0]='/';text[1]=0; @@ -325,14 +325,14 @@ void Geant4ParticleHandle::dumpWithMomentumAndVertex(int level, const std::strin ::snprintf(text+strlen(text),sizeof(text)-strlen(text),"%d ",*i); } printout((DD4hep::PrintLevel)level,src, - "+++%s %3d %-12s stat:%08X PDG:%6d Mom:(%+.2e,%+.2e,%+.2e)[MeV] " - "Vtx:(%+.2e,%+.2e,%+.2e)[mm] #Dau:%3d #Par:%1d%-6s", - tag,p->id,p.particleName().c_str(),p->status,p->pdgID, - p->psx/MeV,p->psy/MeV,p->psz/MeV, - p->vsx/mm,p->vsy/mm,p->vsz/mm, - int(p->daughters.size()), - int(p->parents.size()), - text); + "+++%s %3d %-12s stat:%08X PDG:%6d Mom:(%+.2e,%+.2e,%+.2e)[MeV] " + "Vtx:(%+.2e,%+.2e,%+.2e)[mm] #Dau:%3d #Par:%1d%-6s", + tag,p->id,p.particleName().c_str(),p->status,p->pdgID, + p->psx/MeV,p->psy/MeV,p->psz/MeV, + p->vsx/mm,p->vsy/mm,p->vsz/mm, + int(p->daughters.size()), + int(p->parents.size()), + text); } void Geant4ParticleHandle::dump4(int level, const std::string& src, const char* tag) const { @@ -349,29 +349,29 @@ void Geant4ParticleHandle::dump4(int level, const std::string& src, const char* ::snprintf(equiv,sizeof(equiv),"/%d",p->g4Parent); } printout((DD4hep::PrintLevel)level,src, - "+++ %s ID:%7d %12s %6d%-7s %7s %3s %5d %3s %+.3e %-4s %-7s %-3s %-3s %2d [%s%s%s] %c%c%c%c", - tag, - p->id, - p.particleName().c_str(), - parent_id,equiv, - yes_no(mask.isSet(G4PARTICLE_PRIMARY)), - yes_no(mask.isSet(G4PARTICLE_HAS_SECONDARIES)), - int(p->daughters.size()), - yes_no(mask.isSet(G4PARTICLE_ABOVE_ENERGY_THRESHOLD)), - p.energy(), - yes_no(mask.isSet(G4PARTICLE_CREATED_CALORIMETER_HIT)), - yes_no(mask.isSet(G4PARTICLE_CREATED_TRACKER_HIT)), - yes_no(mask.isSet(G4PARTICLE_KEEP_PROCESS)), - mask.isSet(G4PARTICLE_KEEP_PARENT) ? "YES" : "", - p.numParent(), - proc_name.c_str(), - p->process ? "/" : "", - proc_type.c_str(), - status.isSet(G4PARTICLE_GEN_EMPTY) ? 'E' : '.', - status.isSet(G4PARTICLE_GEN_STABLE) ? 'S' : '.', - status.isSet(G4PARTICLE_GEN_DECAYED) ? 'D' : '.', - status.isSet(G4PARTICLE_GEN_DOCUMENTATION) ? 'd' : '.' - ); + "+++ %s ID:%7d %12s %6d%-7s %7s %3s %5d %3s %+.3e %-4s %-7s %-3s %-3s %2d [%s%s%s] %c%c%c%c", + tag, + p->id, + p.particleName().c_str(), + parent_id,equiv, + yes_no(mask.isSet(G4PARTICLE_PRIMARY)), + yes_no(mask.isSet(G4PARTICLE_HAS_SECONDARIES)), + int(p->daughters.size()), + yes_no(mask.isSet(G4PARTICLE_ABOVE_ENERGY_THRESHOLD)), + p.energy(), + yes_no(mask.isSet(G4PARTICLE_CREATED_CALORIMETER_HIT)), + yes_no(mask.isSet(G4PARTICLE_CREATED_TRACKER_HIT)), + yes_no(mask.isSet(G4PARTICLE_KEEP_PROCESS)), + mask.isSet(G4PARTICLE_KEEP_PARENT) ? "YES" : "", + p.numParent(), + proc_name.c_str(), + p->process ? "/" : "", + proc_type.c_str(), + status.isSet(G4PARTICLE_GEN_EMPTY) ? 'E' : '.', + status.isSet(G4PARTICLE_GEN_STABLE) ? 'S' : '.', + status.isSet(G4PARTICLE_GEN_DECAYED) ? 'D' : '.', + status.isSet(G4PARTICLE_GEN_DOCUMENTATION) ? 'd' : '.' + ); } /// Default destructor @@ -433,7 +433,7 @@ int Geant4ParticleMap::particleID(int g4_id, bool) const { TrackEquivalents::const_iterator iequiv = equivalentTracks.find(g4_id); if ( iequiv != equivalentTracks.end() ) return (*iequiv).second; printout(ERROR,"Geant4ParticleMap","+++ No Equivalent particle for track:%d." - " Monte Carlo truth record looks broken!",g4_id); + " Monte Carlo truth record looks broken!",g4_id); dump(); return -1; } diff --git a/DDG4/src/Geant4ParticleGun.cpp b/DDG4/src/Geant4ParticleGun.cpp index f10ed36ab431b9e7a61a5d77307e537b82c07f72..7a0705a5f669f84069ef8213c058002f8114e401 100644 --- a/DDG4/src/Geant4ParticleGun.cpp +++ b/DDG4/src/Geant4ParticleGun.cpp @@ -30,8 +30,8 @@ using namespace DD4hep::Simulation; /// Standard constructor Geant4ParticleGun::Geant4ParticleGun(Geant4Context* context, const string& name) - : Geant4GeneratorAction(context, name), m_position(0,0,0), m_direction(1,1,0.3), - m_particle(0), m_shotNo(0) +: Geant4GeneratorAction(context, name), m_position(0,0,0), m_direction(1,1,0.3), + m_particle(0), m_shotNo(0) { InstanceCount::increment(this); m_needsControl = true; @@ -82,9 +82,9 @@ void Geant4ParticleGun::operator()(G4Event* event) { } } print("Shoot [%d] %.3f GeV %s pos:(%.3f %.3f %.3f)[mm] dir:(%6.3f %6.3f %6.3f)", - m_shotNo, m_energy/GeV, m_particleName.c_str(), - m_position.X(), m_position.Y(), m_position.Z(), - m_direction.X(),m_direction.Y(), m_direction.Z()); + m_shotNo, m_energy/GeV, m_particleName.c_str(), + m_position.X(), m_position.Y(), m_position.Z(), + m_direction.X(),m_direction.Y(), m_direction.Z()); Geant4PrimaryInteraction* inter = new Geant4PrimaryInteraction(); Geant4Vertex* vtx = new Geant4Vertex(); diff --git a/DDG4/src/Geant4ParticleHandler.cpp b/DDG4/src/Geant4ParticleHandler.cpp index f0a1ce3aaffa6c3cb797c820550f9a5b238b1532..050a546f821c1658323ed65f74e15683d8d1cd5d 100644 --- a/DDG4/src/Geant4ParticleHandler.cpp +++ b/DDG4/src/Geant4ParticleHandler.cpp @@ -44,10 +44,10 @@ namespace { for(int i=0, ni=evt.GetNumberOfPrimaryVertex(); i<ni; ++i) { G4PrimaryVertex* v = evt.GetPrimaryVertex(i); for(int j=0, nj=v->GetNumberOfParticle(); j<nj; ++j) { - G4PrimaryParticle* p = v->GetPrimary(j); - if ( id == p->GetTrackID() ) { - return p; - } + G4PrimaryParticle* p = v->GetPrimary(j); + if ( id == p->GetTrackID() ) { + return p; + } } } return 0; @@ -56,7 +56,7 @@ namespace { /// Standard constructor Geant4ParticleHandler::Geant4ParticleHandler(Geant4Context* context, const string& nam) - : Geant4GeneratorAction(context,nam), Geant4MonteCarloTruth(), m_userHandler(0), m_primaryMap(0) +: Geant4GeneratorAction(context,nam), Geant4MonteCarloTruth(), m_userHandler(0), m_primaryMap(0) { InstanceCount::increment(this); //generatorAction().adopt(this); @@ -86,8 +86,8 @@ Geant4ParticleHandler::~Geant4ParticleHandler() { } /// No assignment operator -Geant4ParticleHandler& Geant4ParticleHandler::operator=(const Geant4ParticleHandler&) { - return *this; +Geant4ParticleHandler& Geant4ParticleHandler::operator=(const Geant4ParticleHandler&) { + return *this; } /// Adopt the user particle handler @@ -96,9 +96,9 @@ bool Geant4ParticleHandler::adopt(Geant4Action* action) { if ( !m_userHandler ) { Geant4UserParticleHandler* h = dynamic_cast<Geant4UserParticleHandler*>(action); if ( h ) { - m_userHandler = h; - m_userHandler->addRef(); - return true; + m_userHandler = h; + m_userHandler->addRef(); + return true; } except("Cannot add an invalid user particle handler object [Invalid-object-type].", c_name()); } @@ -148,7 +148,7 @@ void Geant4ParticleHandler::mark(const G4Step* step) { void Geant4ParticleHandler::mark(const G4Track* track) { PropertyMask mask(m_currTrack.reason); mask.set(G4PARTICLE_CREATED_HIT); - /// Check if the track origines from the calorimeter. + /// Check if the track origines from the calorimeter. // If yes, flag it, because it is a candidate for removal. G4LogicalVolume* vol = track->GetVolume()->GetLogicalVolume(); G4VSensitiveDetector* g4 = vol->GetSensitiveDetector(); @@ -183,7 +183,7 @@ void Geant4ParticleHandler::step(const G4Step* step, G4SteppingManager* mgr) { if ( (m_currTrack.reason&G4PARTICLE_ABOVE_ENERGY_THRESHOLD) ) { // // Tracks below the energy threshold are NOT stored. - // If these tracks produce hits or are selected due to another signature, + // If these tracks produce hits or are selected due to another signature, // this criterium will anyhow take precedence. // const _Sec* sec=step->GetSecondaryInCurrentStep(); @@ -243,7 +243,7 @@ void Geant4ParticleHandler::begin(const G4Track* track) { m_currTrack.colorFlow[0] = 0; m_currTrack.colorFlow[1] = 0; m_currTrack.parents.clear(); - m_currTrack.daughters.clear(); + m_currTrack.daughters.clear(); m_currTrack.pdgID = h.trackDef()->GetPDGEncoding(); m_currTrack.mass = h.trackDef()->GetPDGMass(); ++m_globalParticleID; @@ -273,7 +273,7 @@ void Geant4ParticleHandler::begin(const G4Track* track) { } } if ( m_keepAll ) { - PropertyMask(m_currTrack.reason).set(G4PARTICLE_KEEP_ALWAYS); + PropertyMask(m_currTrack.reason).set(G4PARTICLE_KEEP_ALWAYS); } /// Initial update of the particle using the user handler @@ -309,7 +309,7 @@ void Geant4ParticleHandler::end(const G4Track* track) { // - hits created // - secondaries // - above energy threshold - // - to be kept due to creator process + // - to be kept due to creator process // if ( !mask.isNull() ) { m_equivalentTracks[g4_id] = g4_id; @@ -326,11 +326,11 @@ void Geant4ParticleHandler::end(const G4Track* track) { else { // These are tracks without any special properties. // - // We will not store them on the record, but have to memorise the + // We will not store them on the record, but have to memorise the // track identifier in order to restore the history for the created hits. int pid = m_currTrack.g4Parent; m_equivalentTracks[g4_id] = pid; - // Need to find the last stored particle and OR this particle's mask + // Need to find the last stored particle and OR this particle's mask // with the mask of the last stored particle TrackEquivalents::const_iterator iequiv, iend = m_equivalentTracks.end(); ParticleMap::iterator ip; @@ -432,7 +432,7 @@ void Geant4ParticleHandler::rebaseSimulatedTracks(int ) { while( (ipar=m_particleMap.find(g4_equiv)) == m_particleMap.end() ) { TrackEquivalents::const_iterator iequiv = m_equivalentTracks.find(g4_equiv); if ( iequiv == iend ) { - break; // ERROR !! Will be handled by printout below because ipar==end() + break; // ERROR !! Will be handled by printout below because ipar==end() } g4_equiv = (*iequiv).second; } @@ -442,11 +442,11 @@ void Geant4ParticleHandler::rebaseSimulatedTracks(int ) { const G4ParticleDefinition* def = p.definition(); int pdg = int(fabs(def->GetPDGEncoding())+0.1); if ( pdg != 0 && pdg<36 && !(pdg > 10 && pdg < 17) && pdg != 22 ) { - error("+++ ERROR: Geant4 particle for track:%d last known is:%d -- is gluon or quark!",(*i).second,g4_equiv); + error("+++ ERROR: Geant4 particle for track:%d last known is:%d -- is gluon or quark!",(*i).second,g4_equiv); } pdg = int(fabs(p->pdgID)+0.1); if ( pdg != 0 && pdg<36 && !(pdg > 10 && pdg < 17) && pdg != 22 ) { - error("+++ ERROR(2): Geant4 particle for track:%d last known is:%d -- is gluon or quark!",(*i).second,g4_equiv); + error("+++ ERROR(2): Geant4 particle for track:%d last known is:%d -- is gluon or quark!",(*i).second,g4_equiv); } } else { @@ -454,7 +454,7 @@ void Geant4ParticleHandler::rebaseSimulatedTracks(int ) { } } - // (3) Compute the particle's parents and daughters. + // (3) Compute the particle's parents and daughters. // Replace the original Geant4 track with the // equivalent particle still present in the record. for(ParticleMap::const_iterator ipar, iend=m_particleMap.end(), i=m_particleMap.begin(); i!=iend; ++i) { @@ -462,14 +462,14 @@ void Geant4ParticleHandler::rebaseSimulatedTracks(int ) { if ( p->g4Parent > 0 ) { int equiv_id = equivalents[p->g4Parent]; if ( (ipar=finalParticles.find(equiv_id)) != finalParticles.end() ) { - Particle* q = (*ipar).second; - q->daughters.insert(p->id); - p->parents.insert(q->id); + Particle* q = (*ipar).second; + q->daughters.insert(p->id); + p->parents.insert(q->id); } else { - error("+++ Inconsistency in particle record: Geant4 parent %d " - "of particle %d (equiv:%d) not in record!", - p->g4Parent,p->id,equiv_id); + error("+++ Inconsistency in particle record: Geant4 parent %d " + "of particle %d (equiv:%d) not in record!", + p->g4Parent,p->id,equiv_id); } } } @@ -510,7 +510,7 @@ int Geant4ParticleHandler::recombineParents() { set<int> remove; /// Need to start from BACK, to clean first the latest produced stuff. - for(ParticleMap::reverse_iterator i=m_particleMap.rbegin(); i!=m_particleMap.rend(); ++i) { + for(ParticleMap::reverse_iterator i=m_particleMap.rbegin(); i!=m_particleMap.rend(); ++i) { Particle* p = (*i).second; PropertyMask mask(p->reason); bool remove_me = false; @@ -547,12 +547,12 @@ int Geant4ParticleHandler::recombineParents() { else if ( mask.isSet(G4PARTICLE_KEEP_PROCESS) ) { ParticleMap::iterator ip = m_particleMap.find(p->g4Parent); if ( ip != m_particleMap.end() ) { - Particle* parent_part = (*ip).second; - PropertyMask parent_mask(parent_part->reason); - if ( parent_mask.isSet(G4PARTICLE_ABOVE_ENERGY_THRESHOLD) ) { - parent_mask.set(G4PARTICLE_KEEP_PARENT); - continue; - } + Particle* parent_part = (*ip).second; + PropertyMask parent_mask(parent_part->reason); + if ( parent_mask.isSet(G4PARTICLE_ABOVE_ENERGY_THRESHOLD) ) { + parent_mask.set(G4PARTICLE_KEEP_PARENT); + continue; + } } // Low energy stuff. Remove it. Reassign to parent. //remove_me = true; @@ -565,14 +565,14 @@ int Geant4ParticleHandler::recombineParents() { remove.insert(g4_id); m_equivalentTracks[g4_id] = p->g4Parent; if ( ip != m_particleMap.end() ) { - Particle* parent_part = (*ip).second; - PropertyMask(parent_part->reason).set(mask.value()); - parent_part->steps += p->steps; - parent_part->secondaries += p->secondaries; - /// Update of the particle using the user handler - if ( m_userHandler ) { - m_userHandler->combine(*p, *parent_part); - } + Particle* parent_part = (*ip).second; + PropertyMask(parent_part->reason).set(mask.value()); + parent_part->steps += p->steps; + parent_part->secondaries += p->secondaries; + /// Update of the particle using the user handler + if ( m_userHandler ) { + m_userHandler->combine(*p, *parent_part); + } } } } @@ -600,8 +600,8 @@ void Geant4ParticleHandler::checkConsistency() const { for(set<int>::const_iterator id=daughters.begin(); id!=daughters.end(); ++id) { int id_dau = *id; if ( (j=m_particleMap.find(id_dau)) == m_particleMap.end() ) { - ++num_errors; - error("+++ Particle:%d Daughter %d is not in particle map!",p->id,id_dau); + ++num_errors; + error("+++ Particle:%d Daughter %d is not in particle map!",p->id,id_dau); } } // We assume that particles from the generator have consistent parents @@ -611,19 +611,19 @@ void Geant4ParticleHandler::checkConsistency() const { bool in_map = false, in_parent_list = false; int parent_id = -1; if ( eq_it != m_equivalentTracks.end() ) { - parent_id = (*eq_it).second; - in_map = (j=m_particleMap.find(parent_id)) != m_particleMap.end(); - in_parent_list = p->parents.find(parent_id) != p->parents.end(); + parent_id = (*eq_it).second; + in_map = (j=m_particleMap.find(parent_id)) != m_particleMap.end(); + in_parent_list = p->parents.find(parent_id) != p->parents.end(); } if ( !in_map || !in_parent_list ) { - char parent_list[1024]; - parent_list[0] = 0; - ++num_errors; - p.dumpWithMomentum(ERROR,name(),"INCONSISTENCY"); - for(set<int>::const_iterator ip=p->parents.begin(); ip!=p->parents.end();++ip) - ::snprintf(parent_list+strlen(parent_list),sizeof(parent_list)-strlen(parent_list),"%d ",*ip); - error("+++ Particle:%d Parent %d (G4id:%d) In record:%s In parent list:%s [%s]", - p->id,parent_id,p->g4Parent,yes_no(in_map),yes_no(in_parent_list),parent_list); + char parent_list[1024]; + parent_list[0] = 0; + ++num_errors; + p.dumpWithMomentum(ERROR,name(),"INCONSISTENCY"); + for(set<int>::const_iterator ip=p->parents.begin(); ip!=p->parents.end();++ip) + ::snprintf(parent_list+strlen(parent_list),sizeof(parent_list)-strlen(parent_list),"%d ",*ip); + error("+++ Particle:%d Parent %d (G4id:%d) In record:%s In parent list:%s [%s]", + p->id,parent_id,p->g4Parent,yes_no(in_map),yes_no(in_parent_list),parent_list); } } } diff --git a/DDG4/src/Geant4ParticlePrint.cpp b/DDG4/src/Geant4ParticlePrint.cpp index 27e082177162c85bcdf306b7de8d580e69aa58a2..31002bb66a38e5af9395be10fa433ca1d3a154ac 100644 --- a/DDG4/src/Geant4ParticlePrint.cpp +++ b/DDG4/src/Geant4ParticlePrint.cpp @@ -25,7 +25,7 @@ typedef ReferenceBitMask<const int> PropertyMask; /// Standard constructor Geant4ParticlePrint::Geant4ParticlePrint(Geant4Context* context, const std::string& nam) - : Geant4EventAction(context,nam) +: Geant4EventAction(context,nam) { declareProperty("OutputType",m_outputType=3); declareProperty("PrintBegin",m_printBegin=false); @@ -81,28 +81,28 @@ void Geant4ParticlePrint::printParticle(const std::string& prefix, const G4Event ::snprintf(equiv,sizeof(equiv),"/%d",p->g4Parent); } print("+++ %s ID:%7d %12s %6d%-7s %7s %3s %5d %3s %+.3e %-4s %-7s %-3s %-3s %2d [%s%s%s] %c%c%c%c", - prefix.c_str(), - p->id, - p.particleName().c_str(), - parent_id,equiv, - yes_no(mask.isSet(G4PARTICLE_PRIMARY)), - yes_no(mask.isSet(G4PARTICLE_HAS_SECONDARIES)), - int(p->daughters.size()), - yes_no(mask.isSet(G4PARTICLE_ABOVE_ENERGY_THRESHOLD)), - p.energy(), - yes_no(mask.isSet(G4PARTICLE_CREATED_CALORIMETER_HIT)), - yes_no(mask.isSet(G4PARTICLE_CREATED_TRACKER_HIT)), - yes_no(mask.isSet(G4PARTICLE_KEEP_PROCESS)), - mask.isSet(G4PARTICLE_KEEP_PARENT) ? "YES" : "", - p.numParent(), - proc_name.c_str(), - p->process ? "/" : "", - proc_type.c_str(), - status.isSet(G4PARTICLE_GEN_EMPTY) ? 'E' : '.', - status.isSet(G4PARTICLE_GEN_STABLE) ? 'S' : '.', - status.isSet(G4PARTICLE_GEN_DECAYED) ? 'D' : '.', - status.isSet(G4PARTICLE_GEN_DOCUMENTATION) ? 'd' : '.' - ); + prefix.c_str(), + p->id, + p.particleName().c_str(), + parent_id,equiv, + yes_no(mask.isSet(G4PARTICLE_PRIMARY)), + yes_no(mask.isSet(G4PARTICLE_HAS_SECONDARIES)), + int(p->daughters.size()), + yes_no(mask.isSet(G4PARTICLE_ABOVE_ENERGY_THRESHOLD)), + p.energy(), + yes_no(mask.isSet(G4PARTICLE_CREATED_CALORIMETER_HIT)), + yes_no(mask.isSet(G4PARTICLE_CREATED_TRACKER_HIT)), + yes_no(mask.isSet(G4PARTICLE_KEEP_PROCESS)), + mask.isSet(G4PARTICLE_KEEP_PARENT) ? "YES" : "", + p.numParent(), + proc_name.c_str(), + p->process ? "/" : "", + proc_type.c_str(), + status.isSet(G4PARTICLE_GEN_EMPTY) ? 'E' : '.', + status.isSet(G4PARTICLE_GEN_STABLE) ? 'S' : '.', + status.isSet(G4PARTICLE_GEN_DECAYED) ? 'D' : '.', + status.isSet(G4PARTICLE_GEN_DOCUMENTATION) ? 'd' : '.' + ); if ( e && m_printHits ) { Geant4ParticleMap* truth = context()->event().extension<Geant4ParticleMap>(); G4HCofThisEvent* hc = e->GetHCofThisEvent(); @@ -111,30 +111,30 @@ void Geant4ParticlePrint::printParticle(const std::string& prefix, const G4Event Geant4HitCollection* coll = dynamic_cast<Geant4HitCollection*>(c); size_t nhits = coll->GetSize(); for(size_t i=0; i<nhits; ++i) { - Geant4HitData* h = coll->hit(i); - Geant4Tracker::Hit* trk_hit = dynamic_cast<Geant4Tracker::Hit*>(h); - if ( 0 != trk_hit ) { - Geant4HitData::Contribution& t = trk_hit->truth; - int trackID = t.trackID; - int trueID = truth->particleID(trackID); - if ( trueID == p->id ) { - print("+++ %20s %s[%d] (%+.2e,%+.2e,%+.2e)[mm]","",c->GetName().c_str(),i, - trk_hit->position.x(),trk_hit->position.y(),trk_hit->position.z()); - } - } - Geant4Calorimeter::Hit* cal_hit = dynamic_cast<Geant4Calorimeter::Hit*>(h); - if ( 0 != cal_hit ) { - Geant4HitData::Contributions& contrib = cal_hit->truth; - for(Geant4HitData::Contributions::iterator j=contrib.begin(); j!=contrib.end(); ++j) { - Geant4HitData::Contribution& t = *j; - int trackID = t.trackID; - int trueID = truth->particleID(trackID); - if ( trueID == p->id ) { - print("+++ %20s %s[%d] (%+.2e,%+.2e,%+.2e)[mm]","",c->GetName().c_str(),i, - cal_hit->position.x(),cal_hit->position.y(),cal_hit->position.z()); - } - } - } + Geant4HitData* h = coll->hit(i); + Geant4Tracker::Hit* trk_hit = dynamic_cast<Geant4Tracker::Hit*>(h); + if ( 0 != trk_hit ) { + Geant4HitData::Contribution& t = trk_hit->truth; + int trackID = t.trackID; + int trueID = truth->particleID(trackID); + if ( trueID == p->id ) { + print("+++ %20s %s[%d] (%+.2e,%+.2e,%+.2e)[mm]","",c->GetName().c_str(),i, + trk_hit->position.x(),trk_hit->position.y(),trk_hit->position.z()); + } + } + Geant4Calorimeter::Hit* cal_hit = dynamic_cast<Geant4Calorimeter::Hit*>(h); + if ( 0 != cal_hit ) { + Geant4HitData::Contributions& contrib = cal_hit->truth; + for(Geant4HitData::Contributions::iterator j=contrib.begin(); j!=contrib.end(); ++j) { + Geant4HitData::Contribution& t = *j; + int trackID = t.trackID; + int trueID = truth->particleID(trackID); + if ( trueID == p->id ) { + print("+++ %20s %s[%d] (%+.2e,%+.2e,%+.2e)[mm]","",c->GetName().c_str(),i, + cal_hit->position.x(),cal_hit->position.y(),cal_hit->position.z()); + } + } + } } } } @@ -151,8 +151,8 @@ void Geant4ParticlePrint::printParticles(const G4Event* e, const ParticleMap& pa int num_tracker_hits = 0; print("+++ MC Particles #Tracks:%7d ParticleType Parent/Geant4 " - "Primary Secondary Energy in [MeV] Calo Tracker Process/Par Details", - int(particles.size())); + "Primary Secondary Energy in [MeV] Calo Tracker Process/Par Details", + int(particles.size())); for(ParticleMap::const_iterator i=particles.begin(); i!=particles.end(); ++i) { Geant4ParticleHandle p = (*i).second; PropertyMask mask(p->reason); @@ -166,11 +166,11 @@ void Geant4ParticlePrint::printParticles(const G4Event* e, const ParticleMap& pa else if ( mask.isSet(G4PARTICLE_KEEP_PROCESS) ) ++num_process; } print("+++ MC Particles #Tracks:%7d ParticleType Parent/Geant4 " - "Primary Secondary Energy Calo Tracker Process/Par", - int(particles.size())); + "Primary Secondary Energy Calo Tracker Process/Par", + int(particles.size())); print("+++ MC Particle Summary: %7d %10d %7d %7d %9d %5d %6d", - num_primary, num_secondaries, num_energy, - num_calo_hits,num_tracker_hits,num_process,num_parent); + num_primary, num_secondaries, num_energy, + num_calo_hits,num_tracker_hits,num_process,num_parent); } void Geant4ParticlePrint::printParticleTree(const G4Event* e, const ParticleMap& particles, int level, Geant4ParticleHandle p) const { @@ -178,7 +178,7 @@ void Geant4ParticlePrint::printParticleTree(const G4Event* e, const ParticleMap& size_t len = sizeof(txt)-1; // Ensure we do not overwrite the array if ( level>int(len)-3 ) level=len-3; - + ::snprintf(txt,sizeof(txt),"%5d ",level); ::memset(txt+6,' ',len-6); txt[len-1] = 0; @@ -200,8 +200,8 @@ void Geant4ParticlePrint::printParticleTree(const G4Event* e, const ParticleMap& void Geant4ParticlePrint::printParticleTree(const G4Event* e, const ParticleMap& particles) const { print("+++ MC Particle Parent daughter relationships. [%d particles]",int(particles.size())); print("+++ MC Particles %12s #Tracks:%7d %-12s Parent%-7s " - "Primary Secondary Energy %-8s Calo Tracker Process/Par Details", - "",int(particles.size()),"ParticleType","","in [MeV]"); + "Primary Secondary Energy %-8s Calo Tracker Process/Par Details", + "",int(particles.size()),"ParticleType","","in [MeV]"); for(ParticleMap::const_iterator i=particles.begin(); i!=particles.end(); ++i) { Geant4ParticleHandle p = (*i).second; PropertyMask mask(p->reason); diff --git a/DDG4/src/Geant4PhysicsList.cpp b/DDG4/src/Geant4PhysicsList.cpp index be1c0dbaea7ed5ca85080ead84478f3535e5957a..278ef825fda5b03df60c2d52359f23b853a0bce6 100644 --- a/DDG4/src/Geant4PhysicsList.cpp +++ b/DDG4/src/Geant4PhysicsList.cpp @@ -70,11 +70,11 @@ Geant4UserPhysics::~Geant4UserPhysics() { /// Default constructor Geant4PhysicsList::Process::Process() - : ordAtRestDoIt(-1), ordAlongSteptDoIt(-1), ordPostStepDoIt(-1) { +: ordAtRestDoIt(-1), ordAlongSteptDoIt(-1), ordPostStepDoIt(-1) { } /// Copy constructor Geant4PhysicsList::Process::Process(const Process& p) - : name(p.name), ordAtRestDoIt(p.ordAtRestDoIt), ordAlongSteptDoIt(p.ordAlongSteptDoIt), ordPostStepDoIt(p.ordPostStepDoIt) { +: name(p.name), ordAtRestDoIt(p.ordAtRestDoIt), ordAlongSteptDoIt(p.ordAlongSteptDoIt), ordPostStepDoIt(p.ordPostStepDoIt) { } /// Assignment operator @@ -90,7 +90,7 @@ Geant4PhysicsList::Process& Geant4PhysicsList::Process::operator=(const Process& /// Standard constructor Geant4PhysicsList::Geant4PhysicsList(Geant4Context* context, const string& nam) - : Geant4Action(context, nam) { +: Geant4Action(context, nam) { InstanceCount::increment(this); } @@ -118,7 +118,7 @@ void Geant4PhysicsList::dump() { for (ParticleProcesses::const_iterator ip = procs.begin(); ip != procs.end(); ++ip) { const Process& p = (*ip); printout(ALWAYS,name(),"+++ Process %s ordAtRestDoIt=%d ordAlongSteptDoIt=%d ordPostStepDoIt=%d", - p.name.c_str(),p.ordAtRestDoIt,p.ordAlongSteptDoIt,p.ordPostStepDoIt); + p.name.c_str(),p.ordAtRestDoIt,p.ordAlongSteptDoIt,p.ordPostStepDoIt); } } } @@ -129,11 +129,11 @@ void Geant4PhysicsList::addParticleConstructor(const std::string& part_name) { } /// Add particle process by name with arguments -void Geant4PhysicsList::addParticleProcess(const std::string& part_name, - const std::string& proc_name, - int ordAtRestDoIt, - int ordAlongSteptDoIt, - int ordPostStepDoIt) +void Geant4PhysicsList::addParticleProcess(const std::string& part_name, + const std::string& proc_name, + int ordAtRestDoIt, + int ordAlongSteptDoIt, + int ordPostStepDoIt) { Process p; p.name = proc_name; @@ -181,7 +181,7 @@ void Geant4PhysicsList::constructPhysics(Geant4UserPhysics* physics) { G4VPhysicsConstructor* p = PluginService::Create<G4VPhysicsConstructor*>(ctor); if (!p) { throw runtime_error(format("Geant4PhysicsList", "Failed to create the physics entities " - "for the G4VPhysicsConstructor '%s'", ctor.c_str())); + "for the G4VPhysicsConstructor '%s'", ctor.c_str())); } physics->RegisterPhysics(p); printout(INFO, "Geant4PhysicsList", "%s> registered Geant4 physics %s", name().c_str(), ctor.c_str()); @@ -216,7 +216,7 @@ void Geant4PhysicsList::constructProcesses(Geant4UserPhysics* physics) { _findDef(part_name, defs); if (defs.empty()) { throw runtime_error(format("Geant4PhysicsList", "Particle:%s " - "Cannot find the corresponding entry in the particle table.", part_name.c_str())); + "Cannot find the corresponding entry in the particle table.", part_name.c_str())); } for (vector<G4ParticleDefinition*>::const_iterator id = defs.begin(); id != defs.end(); ++id) { G4ParticleDefinition* particle = *id; @@ -226,12 +226,12 @@ void Geant4PhysicsList::constructProcesses(Geant4UserPhysics* physics) { G4VProcess* g4 = PluginService::Create<G4VProcess*>(p.name); if (!g4) { // Error no factory for this process throw runtime_error(format("Geant4PhysicsList", "Particle:%s -> [%s] " - "Cannot create physics process %s", part_name.c_str(), particle->GetParticleName().c_str(), p.name.c_str())); + "Cannot create physics process %s", part_name.c_str(), particle->GetParticleName().c_str(), p.name.c_str())); } mgr->AddProcess(g4, p.ordAtRestDoIt, p.ordAlongSteptDoIt, p.ordPostStepDoIt); printout(INFO, "Geant4PhysicsList", "Particle:%s -> [%s] " - "added process %s with flags (%d,%d,%d)", part_name.c_str(), particle->GetParticleName().c_str(), p.name.c_str(), - p.ordAtRestDoIt, p.ordAlongSteptDoIt, p.ordPostStepDoIt); + "added process %s with flags (%d,%d,%d)", part_name.c_str(), particle->GetParticleName().c_str(), p.name.c_str(), + p.ordAtRestDoIt, p.ordAlongSteptDoIt, p.ordPostStepDoIt); } } } @@ -239,7 +239,7 @@ void Geant4PhysicsList::constructProcesses(Geant4UserPhysics* physics) { /// Standard constructor Geant4PhysicsListActionSequence::Geant4PhysicsListActionSequence(Geant4Context* context, const string& nam) - : Geant4Action(context, nam), m_transportation(false), m_decays(false) { +: Geant4Action(context, nam), m_transportation(false), m_decays(false) { declareProperty("transportation", m_transportation); declareProperty("extends", m_extends); declareProperty("decays", m_decays); diff --git a/DDG4/src/Geant4Primary.cpp b/DDG4/src/Geant4Primary.cpp index 38e8dbf0fca38fe23f30a3cd70302083ae416d19..1924f9bed262bc72a166870d25655ddd5d54eddb 100644 --- a/DDG4/src/Geant4Primary.cpp +++ b/DDG4/src/Geant4Primary.cpp @@ -25,18 +25,18 @@ PrimaryExtension::~PrimaryExtension() { /// Default destructor Geant4PrimaryMap::~Geant4PrimaryMap() { - releaseObjects(primaryMap)(); + releaseObjects(primaryMap)(); } /// Default constructor Geant4PrimaryInteraction::Geant4PrimaryInteraction() - : mask(0), next_particle_identifier(-1) +: mask(0), next_particle_identifier(-1) { } /// Copy constructor Geant4PrimaryInteraction::Geant4PrimaryInteraction(const Geant4PrimaryInteraction&) - : mask(0), next_particle_identifier(-1) +: mask(0), next_particle_identifier(-1) { } @@ -68,7 +68,7 @@ bool Geant4PrimaryInteraction::applyMask() { Geant4PrimaryInteraction::ParticleMap::iterator ip, ipend; for( ip=particles.begin(), ipend=particles.end(); ip != ipend; ++ip ) (*ip).second->mask = mask; - + Geant4PrimaryInteraction::VertexMap::iterator iv, ivend; for( iv=vertices.begin(), ivend=vertices.end(); iv != ivend; ++iv ) (*iv).second->mask = mask; @@ -78,7 +78,7 @@ bool Geant4PrimaryInteraction::applyMask() { } /// Default constructor -Geant4PrimaryEvent::Geant4PrimaryEvent() +Geant4PrimaryEvent::Geant4PrimaryEvent() { } @@ -109,7 +109,7 @@ void Geant4PrimaryEvent::add(int id, Geant4PrimaryInteraction* interaction) { } char text[132]; ::snprintf(text,sizeof(text),"Geant4PrimaryEvent: Interaction with ID '%d' " - "exists and cannot be added twice!",id); + "exists and cannot be added twice!",id); throw std::runtime_error(text); } throw std::runtime_error("Geant4PrimaryEvent: CANNOT add invalid Interaction!"); diff --git a/DDG4/src/Geant4PrimaryHandler.cpp b/DDG4/src/Geant4PrimaryHandler.cpp index 687aed5d7e58635d6d715d2c0e105c457dc9b9d8..49bfdde1cd7f78173abc4e6bd297b80bcc16fb55 100644 --- a/DDG4/src/Geant4PrimaryHandler.cpp +++ b/DDG4/src/Geant4PrimaryHandler.cpp @@ -16,7 +16,7 @@ using namespace DD4hep::Simulation; /// Standard constructor Geant4PrimaryHandler::Geant4PrimaryHandler(Geant4Context* context, const std::string& nam) - : Geant4GeneratorAction(context,nam) +: Geant4GeneratorAction(context,nam) { InstanceCount::increment(this); } diff --git a/DDG4/src/Geant4ROOTDump.cpp b/DDG4/src/Geant4ROOTDump.cpp index 457b0c7dbe6ff835b6746ed29f640755756d4aaf..4f9cf0ed733fd18aafb5bdc2457a33624c21776a 100644 --- a/DDG4/src/Geant4ROOTDump.cpp +++ b/DDG4/src/Geant4ROOTDump.cpp @@ -28,7 +28,7 @@ typedef Geant4DataDump::Particles Particles; typedef Geant4DataDump::TrackerHits TrackerHits; typedef Geant4DataDump::CalorimeterHits CalorimeterHits; -static long usage() { +static long usage() { printout(FATAL,"Geant4ROOTDump","usage: Geant4ROOTDump -opt (app-opts) --opt=value (plugin-opts)"); printout(FATAL,"Geant4ROOTDump"," app-opts: "); printout(FATAL,"Geant4ROOTDump"," -print INFO Print container summaries only."); @@ -42,7 +42,7 @@ static long usage() { } static pair<TClass*,void*> load(TBranch* branch, int entry) { - TClass* cl = gROOT->GetClass(branch->GetClassName(),kTRUE); + TClass* cl = gROOT->GetClass(branch->GetClassName(),kTRUE); if ( !cl ) { return pair<TClass*,void*>(0,0); } @@ -74,13 +74,13 @@ static long dump_root(DD4hep::Geometry::LCDD&, int argc, char** argv) { string p1 = a.substr(0,idx); string p2 = a.substr(idx+1); if ( strncmp(p1.c_str(),"input",3)==0 ) { - input = p2; + input = p2; } if ( strncmp(p1.c_str(),"entry",5)==0 ) { - if ( 1 != ::sscanf(p2.c_str(),"%d",&entry) ) { - printout(FATAL,tag,"+++ Argument %s is not properly formatted. must be --entry=<number>.",argv[j]); - return usage(); - } + if ( 1 != ::sscanf(p2.c_str(),"%d",&entry) ) { + printout(FATAL,tag,"+++ Argument %s is not properly formatted. must be --entry=<number>.",argv[j]); + return usage(); + } } continue; } @@ -118,40 +118,40 @@ static long dump_root(DD4hep::Geometry::LCDD&, int argc, char** argv) { // First suck in all data for (Int_t i=0;i<nbranches;i++) { - TBranch* branch = (TBranch*)branches->UncheckedAt(i); - pair<TClass*,void*> data = load(branch,ievt); - if ( data.first ) event[branch->GetName()] = data; + TBranch* branch = (TBranch*)branches->UncheckedAt(i); + pair<TClass*,void*> data = load(branch,ievt); + if ( data.first ) event[branch->GetName()] = data; } // Now dump the stuff for(ENTRIES::const_iterator i=event.begin(); i!=event.end(); ++i) { - pair<TClass*,void*> data = (*i).second; - if ( data.first == cl_particles ) { - Particles* parts = (Particles*)data.second; - dump.print(INFO, (*i).first, parts); - for_each(parts->begin(), parts->end(), DestroyObject<Geant4Particle*>()); - } + pair<TClass*,void*> data = (*i).second; + if ( data.first == cl_particles ) { + Particles* parts = (Particles*)data.second; + dump.print(INFO, (*i).first, parts); + for_each(parts->begin(), parts->end(), DestroyObject<Geant4Particle*>()); + } } for(ENTRIES::const_iterator i=event.begin(); i!=event.end(); ++i) { - pair<TClass*,void*> data = (*i).second; - if ( data.first == cl_particles ) { - } - else if ( data.first == cl_tracker ) { - TrackerHits* hits = (TrackerHits*)data.second; - dump.print(INFO, (*i).first, hits); - for_each(hits->begin(), hits->end(), DestroyObject<Geant4Tracker::Hit*>()); - } - else if ( data.first == cl_calo ) { - CalorimeterHits* hits = (CalorimeterHits*)data.second; - dump.print(INFO, (*i).first, hits); - for_each(hits->begin(), hits->end(), DestroyObject<Geant4Calorimeter::Hit*>()); - } - if ( data.first ) data.first->Destructor(data.second); + pair<TClass*,void*> data = (*i).second; + if ( data.first == cl_particles ) { + } + else if ( data.first == cl_tracker ) { + TrackerHits* hits = (TrackerHits*)data.second; + dump.print(INFO, (*i).first, hits); + for_each(hits->begin(), hits->end(), DestroyObject<Geant4Tracker::Hit*>()); + } + else if ( data.first == cl_calo ) { + CalorimeterHits* hits = (CalorimeterHits*)data.second; + dump.print(INFO, (*i).first, hits); + for_each(hits->begin(), hits->end(), DestroyObject<Geant4Calorimeter::Hit*>()); + } + if ( data.first ) data.first->Destructor(data.second); } } delete f; } else { - printout(FATAL,tag,"+++ FAILED to open input file:%s",input.c_str()); + printout(FATAL,tag,"+++ FAILED to open input file:%s",input.c_str()); return usage(); } return 1; diff --git a/DDG4/src/Geant4RunAction.cpp b/DDG4/src/Geant4RunAction.cpp index 304ad9791ccb9306e10b5f9457063697c2da7d25..e7cd40ce0dd4d8861ecde33507107c595ea17785 100644 --- a/DDG4/src/Geant4RunAction.cpp +++ b/DDG4/src/Geant4RunAction.cpp @@ -17,7 +17,7 @@ using namespace DD4hep::Simulation; /// Standard constructor Geant4RunAction::Geant4RunAction(Geant4Context* context, const std::string& nam) - : Geant4Action(context, nam) { +: Geant4Action(context, nam) { InstanceCount::increment(this); } @@ -36,7 +36,7 @@ void Geant4RunAction::end(const G4Run*) { /// Standard constructor Geant4RunActionSequence::Geant4RunActionSequence(Geant4Context* context, const std::string& name) - : Geant4Action(context, name) { +: Geant4Action(context, name) { m_needsControl = true; InstanceCount::increment(this); } diff --git a/DDG4/src/Geant4SensDetAction.cpp b/DDG4/src/Geant4SensDetAction.cpp index 2221f04a1dd4dc662e14f86233b1fa4dfdb8f180..0914ded1e32c48c6dd89fe6d92599269c2ff49ec 100644 --- a/DDG4/src/Geant4SensDetAction.cpp +++ b/DDG4/src/Geant4SensDetAction.cpp @@ -35,16 +35,16 @@ namespace { G4VSensitiveDetector* sd = mgr->FindSensitiveDetector(name); if (0 == sd) { throw runtime_error(format("Geant4Sensitive", "DDG4: You requested to configure actions " - "for the sensitive detector %s,\nDDG4: which is not known to Geant4. " - "Are you sure you already converted the geometry?", name.c_str())); + "for the sensitive detector %s,\nDDG4: which is not known to Geant4. " + "Are you sure you already converted the geometry?", name.c_str())); } Geant4ActionSD* action_sd = dynamic_cast<Geant4ActionSD*>(sd); if (0 == action_sd) { throw runtime_error( - format("Geant4Sensitive", "DDG4: You may only configure actions " - "for sensitive detectors of type Geant4ActionSD.\n" - "DDG4: The sensitive detector of %s is of type %s, which is incompatible.", name.c_str(), - typeName(typeid(*sd)).c_str())); + format("Geant4Sensitive", "DDG4: You may only configure actions " + "for sensitive detectors of type Geant4ActionSD.\n" + "DDG4: The sensitive detector of %s is of type %s, which is incompatible.", name.c_str(), + typeName(typeid(*sd)).c_str())); } return action_sd; } @@ -52,7 +52,7 @@ namespace { /// Standard action constructor Geant4ActionSD::Geant4ActionSD(const std::string& name) - : Geant4Action(0, name) { +: Geant4Action(0, name) { InstanceCount::increment(this); } @@ -63,7 +63,7 @@ Geant4ActionSD::~Geant4ActionSD() { /// Standard constructor Geant4Filter::Geant4Filter(Geant4Context* context, const std::string& name) - : Geant4Action(context, name) { +: Geant4Action(context, name) { InstanceCount::increment(this); } @@ -79,8 +79,8 @@ bool Geant4Filter::operator()(const G4Step*) const { /// Constructor. The detector element is identified by the name Geant4Sensitive::Geant4Sensitive(Geant4Context* ctxt, const string& name, DetElement det, LCDD& lcdd) - : Geant4Action(ctxt, name), m_sensitiveDetector(0), m_sequence(0), - m_lcdd(lcdd), m_detector(det), m_sensitive(), m_readout(), m_segmentation() +: Geant4Action(ctxt, name), m_sensitiveDetector(0), m_sequence(0), + m_lcdd(lcdd), m_detector(det), m_sensitive(), m_readout(), m_segmentation() { InstanceCount::increment(this); if (!det.isValid()) { @@ -134,7 +134,7 @@ Geant4ActionSD& Geant4Sensitive::detector() const { //m_sensitiveDetector = _getSensitiveDetector(m_detector.name()); //if ( m_sensitiveDetector ) return *m_sensitiveDetector; throw runtime_error(format("Geant4Sensitive", "DDG4: The sensitive detector for action %s " - "was not properly configured.", name().c_str())); + "was not properly configured.", name().c_str())); } /// Access to the hosting sequence @@ -212,7 +212,7 @@ long long int Geant4Sensitive::cellID(G4Step* s) { /// Standard constructor Geant4SensDetActionSequence::Geant4SensDetActionSequence(Geant4Context* context, const string& nam) - : Geant4Action(context, nam), m_hce(0) +: Geant4Action(context, nam), m_hce(0) { m_needsControl = true; context->sensitiveActions().insert(name(), this); @@ -399,7 +399,7 @@ void Geant4SensDetSequences::insert(const string& name, Geant4SensDetActionSeque return; } throw runtime_error(format("Geant4SensDetSequences", "Attempt to add invalid sensitive " - "sequence with name:%s", name.c_str())); + "sequence with name:%s", name.c_str())); } /// Clear the sequence list diff --git a/DDG4/src/Geant4SensitiveDetector.cpp b/DDG4/src/Geant4SensitiveDetector.cpp index 1ef838978c7957f977150866ab5e25b40823d89e..32f3dc2933104840dd21d3301a5115efd0ebcc1a 100644 --- a/DDG4/src/Geant4SensitiveDetector.cpp +++ b/DDG4/src/Geant4SensitiveDetector.cpp @@ -31,7 +31,7 @@ using namespace DD4hep::Simulation; /// Constructor. The detector element is identified by the name Geant4SensitiveDetector::Geant4SensitiveDetector(const string& name, LCDD& lcdd) - : G4VSensitiveDetector(name), m_lcdd(lcdd), m_detector(), m_sensitive(), m_readout(), m_hce(0) { +: G4VSensitiveDetector(name), m_lcdd(lcdd), m_detector(), m_sensitive(), m_readout(), m_hce(0) { m_sensitive = lcdd.sensitiveDetector(name); m_detector = lcdd.detector(name); m_readout = m_sensitive.readout(); @@ -45,7 +45,7 @@ Geant4SensitiveDetector::~Geant4SensitiveDetector() { bool Geant4SensitiveDetector::defineCollection(const string& coll_name) { if (coll_name.empty()) { throw runtime_error( - "Geant4SensitiveDetector: No collection defined for " + name() + " of type " + string(m_sensitive.type())); + "Geant4SensitiveDetector: No collection defined for " + name() + " of type " + string(m_sensitive.type())); } collectionName.insert(coll_name); return true; @@ -151,10 +151,10 @@ void Geant4SensitiveDetector::dumpStep(G4Step* st, G4TouchableHistory* /* histor Momentum mom = step.postMom(); printout(INFO, "G4Step", " Track:%08ld Pos:(%8f %8f %8f) -> (%f %f %f) Mom:%7.0f %7.0f %7.0f", long(step.track), pos1.X(), - pos1.Y(), pos1.Z(), pos2.X(), pos2.Y(), pos2.Z(), mom.X(), mom.Y(), mom.Z()); + pos1.Y(), pos1.Z(), pos2.X(), pos2.Y(), pos2.Z(), mom.X(), mom.Y(), mom.Z()); printout(INFO, "G4Step", " pre-Vol: %s Status:%s", step.preVolume()->GetName().c_str(), step.preStepStatus()); printout(INFO, "G4Step", " post-Vol:%s Status:%s", step.postVolume()->GetName().c_str(), - step.postStepStatus()); + step.postStepStatus()); const G4VPhysicalVolume* pv = step.volume(step.post); diff --git a/DDG4/src/Geant4StackingAction.cpp b/DDG4/src/Geant4StackingAction.cpp index a4a840747fe6913d1fe96e95e3ade800fce3f5f9..b08d34cf4a5bff6c41f8439c447d12f3175c9480 100644 --- a/DDG4/src/Geant4StackingAction.cpp +++ b/DDG4/src/Geant4StackingAction.cpp @@ -18,7 +18,7 @@ using namespace DD4hep::Simulation; /// Standard constructor Geant4StackingAction::Geant4StackingAction(Geant4Context* context, const std::string& name) - : Geant4Action(context, name) { +: Geant4Action(context, name) { InstanceCount::increment(this); } @@ -29,7 +29,7 @@ Geant4StackingAction::~Geant4StackingAction() { /// Standard constructor Geant4StackingActionSequence::Geant4StackingActionSequence(Geant4Context* context, const std::string& name) - : Geant4Action(context, name) { +: Geant4Action(context, name) { m_needsControl = true; InstanceCount::increment(this); } diff --git a/DDG4/src/Geant4StepHandler.cpp b/DDG4/src/Geant4StepHandler.cpp index 3fe9cdd5e72e74a4b3e112637a695623097359fe..21275671164098c2540deb6ef78678103582ec05 100644 --- a/DDG4/src/Geant4StepHandler.cpp +++ b/DDG4/src/Geant4StepHandler.cpp @@ -17,7 +17,7 @@ using namespace DD4hep::Simulation; /// Returns the step status in form of a string const char* Geant4StepHandler::stepStatus(G4StepStatus status) { switch (status) { - // Step reached the world boundary + // Step reached the world boundary case fWorldBoundary: return "WorldBoundary"; // Step defined by a geometry boundary diff --git a/DDG4/src/Geant4SteppingAction.cpp b/DDG4/src/Geant4SteppingAction.cpp index 3fa5128b016cd6840efd27420c09c77d7fc303da..49856b7e0db5e2afb4591df11794027ae138ed5e 100644 --- a/DDG4/src/Geant4SteppingAction.cpp +++ b/DDG4/src/Geant4SteppingAction.cpp @@ -14,7 +14,7 @@ using namespace DD4hep::Simulation; /// Standard constructor Geant4SteppingAction::Geant4SteppingAction(Geant4Context* context, const std::string& name) - : Geant4Action(context, name) { +: Geant4Action(context, name) { InstanceCount::increment(this); } @@ -29,7 +29,7 @@ void Geant4SteppingAction::operator()(const G4Step*, G4SteppingManager*) { /// Standard constructor Geant4SteppingActionSequence::Geant4SteppingActionSequence(Geant4Context* context, const std::string& name) - : Geant4Action(context, name) { +: Geant4Action(context, name) { m_needsControl = true; InstanceCount::increment(this); } diff --git a/DDG4/src/Geant4TestActions.cpp b/DDG4/src/Geant4TestActions.cpp index ee5ad871d863ff37627ed5037fb615ffa3ada901..6cb4051b4f7bc2a69afe85da7a58d9b08bc94a7a 100644 --- a/DDG4/src/Geant4TestActions.cpp +++ b/DDG4/src/Geant4TestActions.cpp @@ -37,7 +37,7 @@ namespace { /// Standard constructor Geant4TestBase::Geant4TestBase(Geant4Action* a, const std::string& typ) - : m_type(typ) { +: m_type(typ) { a->declareProperty("Property_int", m_value1 = 0); a->declareProperty("Property_double", m_value2 = 0e0); a->declareProperty("Property_string", m_value3); @@ -50,7 +50,7 @@ Geant4TestBase::~Geant4TestBase() { /// Standard constructor with initializing arguments Geant4TestGeneratorAction::Geant4TestGeneratorAction(Geant4Context* c, const std::string& n) - : Geant4GeneratorAction(c, n), Geant4TestBase(this, "Geant4TestGeneratorAction") { +: Geant4GeneratorAction(c, n), Geant4TestBase(this, "Geant4TestGeneratorAction") { InstanceCount::increment(this); } @@ -61,13 +61,13 @@ Geant4TestGeneratorAction::~Geant4TestGeneratorAction() { /// Callback to generate primary particles void Geant4TestGeneratorAction::operator()(G4Event* evt) { - PRINT("%s> calling Geant4TestGeneratorAction(event_id=%d Context: run=%p evt=%p)", - m_type.c_str(), evt->GetEventID(), context()->runPtr(), context()->eventPtr()); + PRINT("%s> calling Geant4TestGeneratorAction(event_id=%d Context: run=%p evt=%p)", + m_type.c_str(), evt->GetEventID(), context()->runPtr(), context()->eventPtr()); } /// Standard constructor with initializing arguments Geant4TestRunAction::Geant4TestRunAction(Geant4Context* c, const std::string& n) - : Geant4RunAction(c, n), Geant4TestBase(this, "Geant4TestRunAction") { +: Geant4RunAction(c, n), Geant4TestBase(this, "Geant4TestRunAction") { InstanceCount::increment(this); } @@ -79,30 +79,30 @@ Geant4TestRunAction::~Geant4TestRunAction() { /// begin-of-run callback void Geant4TestRunAction::begin(const G4Run* run) { PRINT("%s> calling begin(run_id=%d,num_event=%d Context:%p)", m_type.c_str(), run->GetRunID(), - run->GetNumberOfEventToBeProcessed(), &context()->run()); + run->GetNumberOfEventToBeProcessed(), &context()->run()); } /// End-of-run callback void Geant4TestRunAction::end(const G4Run* run) { - PRINT("%s> calling end(run_id=%d, num_event=%d Context:%p)", - m_type.c_str(), run->GetRunID(), run->GetNumberOfEvent(), &context()->run()); + PRINT("%s> calling end(run_id=%d, num_event=%d Context:%p)", + m_type.c_str(), run->GetRunID(), run->GetNumberOfEvent(), &context()->run()); } /// begin-of-event callback void Geant4TestRunAction::beginEvent(const G4Event* evt) { - PRINT("%s> calling beginEvent(event_id=%d Context: run=%p evt=%p)", - m_type.c_str(), evt->GetEventID(), context()->runPtr(), context()->eventPtr()); + PRINT("%s> calling beginEvent(event_id=%d Context: run=%p evt=%p)", + m_type.c_str(), evt->GetEventID(), context()->runPtr(), context()->eventPtr()); } /// End-of-event callback void Geant4TestRunAction::endEvent(const G4Event* evt) { - PRINT("%s> calling endEvent(event_id=%d Context: run=%p evt=%p)", - m_type.c_str(), evt->GetEventID(), context()->runPtr(), context()->eventPtr()); + PRINT("%s> calling endEvent(event_id=%d Context: run=%p evt=%p)", + m_type.c_str(), evt->GetEventID(), context()->runPtr(), context()->eventPtr()); } /// Standard constructor with initializing arguments Geant4TestEventAction::Geant4TestEventAction(Geant4Context* c, const std::string& n) - : Geant4EventAction(c, n), Geant4TestBase(this, "Geant4TestEventAction") { +: Geant4EventAction(c, n), Geant4TestBase(this, "Geant4TestEventAction") { InstanceCount::increment(this); } @@ -112,37 +112,37 @@ Geant4TestEventAction::~Geant4TestEventAction() { } /// begin-of-event callback void Geant4TestEventAction::begin(const G4Event* evt) { - PRINT("%s> calling begin(event_id=%d Context: run=%p (%d) evt=%p (%d))", - m_type.c_str(), evt->GetEventID(), - &context()->run(), context()->run().run().GetRunID(), - &context()->event(), context()->event().event().GetEventID()); + PRINT("%s> calling begin(event_id=%d Context: run=%p (%d) evt=%p (%d))", + m_type.c_str(), evt->GetEventID(), + &context()->run(), context()->run().run().GetRunID(), + &context()->event(), context()->event().event().GetEventID()); } /// End-of-event callback void Geant4TestEventAction::end(const G4Event* evt) { - PRINT("%s> calling end(event_id=%d Context: run=%p (%d) evt=%p (%d))", - m_type.c_str(), evt->GetEventID(), &context()->run(), &context()->event(), - &context()->run(), context()->run().run().GetRunID(), - &context()->event(), context()->event().event().GetEventID()); + PRINT("%s> calling end(event_id=%d Context: run=%p (%d) evt=%p (%d))", + m_type.c_str(), evt->GetEventID(), &context()->run(), &context()->event(), + &context()->run(), context()->run().run().GetRunID(), + &context()->event(), context()->event().event().GetEventID()); } /// begin-of-run callback void Geant4TestEventAction::beginRun(const G4Run* run) { PRINT("%s> calling beginRun(run_id=%d,num_event=%d Context:%p)", - m_type.c_str(), run->GetRunID(), - run->GetNumberOfEventToBeProcessed(), context()->runPtr()); + m_type.c_str(), run->GetRunID(), + run->GetNumberOfEventToBeProcessed(), context()->runPtr()); } /// End-of-run callback void Geant4TestEventAction::endRun(const G4Run* run) { - PRINT("%s> calling endRun(run_id=%d, num_event=%d Context:%p)", - m_type.c_str(), run->GetRunID(), - run->GetNumberOfEvent(), context()->runPtr()); + PRINT("%s> calling endRun(run_id=%d, num_event=%d Context:%p)", + m_type.c_str(), run->GetRunID(), + run->GetNumberOfEvent(), context()->runPtr()); } /// Standard constructor with initializing arguments Geant4TestTrackAction::Geant4TestTrackAction(Geant4Context* c, const std::string& n) - : Geant4TrackingAction(c, n), Geant4TestBase(this, "Geant4TestTrackAction") { +: Geant4TrackingAction(c, n), Geant4TestBase(this, "Geant4TestTrackAction") { InstanceCount::increment(this); } @@ -152,23 +152,23 @@ Geant4TestTrackAction::~Geant4TestTrackAction() { } /// Begin-of-tracking callback void Geant4TestTrackAction::begin(const G4Track* trk) { - PRINT("%s> calling begin(track=%d, parent=%d, position=(%f,%f,%f) Context: run=%p evt=%p)", - m_type.c_str(), trk->GetTrackID(), - trk->GetParentID(), trk->GetPosition().x(), trk->GetPosition().y(), trk->GetPosition().z(), - &context()->run(), &context()->event()); + PRINT("%s> calling begin(track=%d, parent=%d, position=(%f,%f,%f) Context: run=%p evt=%p)", + m_type.c_str(), trk->GetTrackID(), + trk->GetParentID(), trk->GetPosition().x(), trk->GetPosition().y(), trk->GetPosition().z(), + &context()->run(), &context()->event()); } /// End-of-tracking callback void Geant4TestTrackAction::end(const G4Track* trk) { - PRINT("%s> calling end(track=%d, parent=%d, position=(%f,%f,%f) Context: run=%p evt=%p)", - m_type.c_str(), trk->GetTrackID(), - trk->GetParentID(), trk->GetPosition().x(), trk->GetPosition().y(), trk->GetPosition().z(), - &context()->run(), &context()->event()); + PRINT("%s> calling end(track=%d, parent=%d, position=(%f,%f,%f) Context: run=%p evt=%p)", + m_type.c_str(), trk->GetTrackID(), + trk->GetParentID(), trk->GetPosition().x(), trk->GetPosition().y(), trk->GetPosition().z(), + &context()->run(), &context()->event()); } /// Standard constructor with initializing arguments Geant4TestStepAction::Geant4TestStepAction(Geant4Context* c, const std::string& n) - : Geant4SteppingAction(c, n), Geant4TestBase(this, "Geant4TestStepAction") { +: Geant4SteppingAction(c, n), Geant4TestBase(this, "Geant4TestStepAction") { InstanceCount::increment(this); } @@ -183,7 +183,7 @@ void Geant4TestStepAction::operator()(const G4Step*, G4SteppingManager*) { /// Standard constructor with initializing arguments Geant4TestSensitive::Geant4TestSensitive(Geant4Context* c, const std::string& n, DetElement det, LCDD& lcdd) - : Geant4Sensitive(c, n, det, lcdd), Geant4TestBase(this, "Geant4TestSensitive") { +: Geant4Sensitive(c, n, det, lcdd), Geant4TestBase(this, "Geant4TestSensitive") { InstanceCount::increment(this); m_collectionID = defineCollection < TestHit > (n); PRINT("%s> Collection ID is %d", m_type.c_str(), int(m_collectionID)); @@ -197,27 +197,27 @@ Geant4TestSensitive::~Geant4TestSensitive() { /// Begin-of-tracking callback void Geant4TestSensitive::begin(G4HCofThisEvent* hce) { Geant4HitCollection* c = collectionByID(m_collectionID); - PRINT("%s> calling begin(num_coll=%d, coll=%s Context: run=%p evt=%p)", - m_type.c_str(), hce->GetNumberOfCollections(), - c ? c->GetName().c_str() : "None", &context()->run(), &context()->event()); + PRINT("%s> calling begin(num_coll=%d, coll=%s Context: run=%p evt=%p)", + m_type.c_str(), hce->GetNumberOfCollections(), + c ? c->GetName().c_str() : "None", &context()->run(), &context()->event()); } /// End-of-tracking callback void Geant4TestSensitive::end(G4HCofThisEvent* hce) { Geant4HitCollection* c = collection(m_collectionID); - PRINT("%s> calling end(num_coll=%d, coll=%s Context: run=%p evt=%p)", - m_type.c_str(), hce->GetNumberOfCollections(), - c ? c->GetName().c_str() : "None", &context()->run(), &context()->event()); + PRINT("%s> calling end(num_coll=%d, coll=%s Context: run=%p evt=%p)", + m_type.c_str(), hce->GetNumberOfCollections(), + c ? c->GetName().c_str() : "None", &context()->run(), &context()->event()); } /// Method for generating hit(s) using the information of G4Step object. bool Geant4TestSensitive::process(G4Step* step, G4TouchableHistory*) { Geant4HitCollection* c = collection(m_collectionID); PRINT("%s> calling process(track=%d, dE=%f, dT=%f len=%f, First,last in Vol=(%c,%c), coll=%s Context: run=%p evt=%p)", - m_type.c_str(), step->GetTrack()->GetTrackID(), - step->GetTotalEnergyDeposit(), step->GetDeltaTime(), - step->GetStepLength(), step->IsFirstStepInVolume() ? 'Y' : 'N', - step->IsLastStepInVolume() ? 'Y' : 'N', - c ? c->GetName().c_str() : "None", &context()->run(), &context()->event()); + m_type.c_str(), step->GetTrack()->GetTrackID(), + step->GetTotalEnergyDeposit(), step->GetDeltaTime(), + step->GetStepLength(), step->IsFirstStepInVolume() ? 'Y' : 'N', + step->IsLastStepInVolume() ? 'Y' : 'N', + c ? c->GetName().c_str() : "None", &context()->run(), &context()->event()); return true; } diff --git a/DDG4/src/Geant4TrackInformation.cpp b/DDG4/src/Geant4TrackInformation.cpp index 449dcaf5a696d19b464242b47d7cf4cc1ed1a59d..4c40ca6bba8d4367349ffcfe4ea165880cc4ebdd 100644 --- a/DDG4/src/Geant4TrackInformation.cpp +++ b/DDG4/src/Geant4TrackInformation.cpp @@ -14,7 +14,7 @@ using namespace DD4hep::Simulation; /// Default constructor Geant4TrackInformation::Geant4TrackInformation() - : G4VUserTrackInformation(), m_flags(0) { +: G4VUserTrackInformation(), m_flags(0) { } /// Standard destructor diff --git a/DDG4/src/Geant4TrackingAction.cpp b/DDG4/src/Geant4TrackingAction.cpp index 7baa9852711f2f8c7a111d7291e3374b1de0242d..87082f99d41e5dda2e90690d9d7e3957c8eb9a5f 100644 --- a/DDG4/src/Geant4TrackingAction.cpp +++ b/DDG4/src/Geant4TrackingAction.cpp @@ -29,7 +29,7 @@ class G4TouchableHistory; /// Standard constructor Geant4TrackingActionSequence::Geant4TrackingActionSequence(Geant4Context* context, const std::string& name) - : Geant4Action(context, name) { +: Geant4Action(context, name) { m_needsControl = true; InstanceCount::increment(this); } @@ -73,7 +73,7 @@ void Geant4TrackingActionSequence::end(const G4Track* track) { /// Standard constructor Geant4TrackingAction::Geant4TrackingAction(Geant4Context* context, const std::string& name) - : Geant4Action(context, name) { +: Geant4Action(context, name) { InstanceCount::increment(this); } diff --git a/DDG4/src/Geant4TrackingPostAction.cpp b/DDG4/src/Geant4TrackingPostAction.cpp index 9498cb32e0b4fc32558c380cbc0cbad29ea446c3..daab5c3f5b215fe23ee91d71415f9e7621d2838a 100644 --- a/DDG4/src/Geant4TrackingPostAction.cpp +++ b/DDG4/src/Geant4TrackingPostAction.cpp @@ -21,7 +21,7 @@ using namespace std; using namespace DD4hep::Simulation; /// Helper class to manipulate strings -/** +/** * \author M.Frank * \version 1.0 * \ingroup DD4HEP_SIMULATION @@ -29,7 +29,7 @@ using namespace DD4hep::Simulation; struct FindString { const std::string& m_name; FindString(const std::string& n) - : m_name(n) { + : m_name(n) { } bool operator()(const std::string& n) const { return m_name == n; @@ -42,7 +42,7 @@ struct FindString { /// Standard constructor Geant4TrackingPostAction::Geant4TrackingPostAction(Geant4Context* context, const std::string& name) - : Geant4TrackingAction(context, name) { +: Geant4TrackingAction(context, name) { InstanceCount::increment(this); declareProperty("IgnoredProcesses", m_ignoredProcs); declareProperty("RequiredProcesses", m_requiredProcs); diff --git a/DDG4/src/Geant4TrackingPreAction.cpp b/DDG4/src/Geant4TrackingPreAction.cpp index 799b4cba4da6cba32291a66e40c1d8bfcfbf3c79..b87b6243c36a4cde4eb38f6066e4163fe5befbc9 100644 --- a/DDG4/src/Geant4TrackingPreAction.cpp +++ b/DDG4/src/Geant4TrackingPreAction.cpp @@ -17,7 +17,7 @@ using namespace DD4hep::Simulation; /// Standard constructor Geant4TrackingPreAction::Geant4TrackingPreAction(Geant4Context* context, const std::string& name) - : Geant4TrackingAction(context, name) { +: Geant4TrackingAction(context, name) { InstanceCount::increment(this); } diff --git a/DDG4/src/Geant4UIManager.cpp b/DDG4/src/Geant4UIManager.cpp index 97ebd1d9b0900587de40a854cac3cef4754f87a4..a09725d5a6242dcfc38ac5ec7d83b6147b7a8aa7 100644 --- a/DDG4/src/Geant4UIManager.cpp +++ b/DDG4/src/Geant4UIManager.cpp @@ -24,7 +24,7 @@ using namespace std; /// Initializing constructor Geant4UIManager::Geant4UIManager(Geant4Context* context, const std::string& name) - : Geant4Action(context,name), m_vis(0), m_ui(0) +: Geant4Action(context,name), m_vis(0), m_ui(0) { declareProperty("SetupUI", m_uiSetup=""); declareProperty("SetupVIS", m_visSetup=""); @@ -51,7 +51,7 @@ G4UIExecutive* Geant4UIManager::startUI() { G4UIExecutive* ui = 0; const char* args[] = {"DDG4","",""}; printout(INFO,"Geant4UIManager","+++ Starting G4UIExecutive '%s' of type %s....", - args[0], m_sessionType.c_str()); + args[0], m_sessionType.c_str()); #if (G4VERSION_NUMBER >= 960) ui = new G4UIExecutive(1,(char**)args,m_sessionType.c_str()); diff --git a/DDG4/src/Geant4UIMessenger.cpp b/DDG4/src/Geant4UIMessenger.cpp index 555f9d1be4c2bce46a062f22522d0b0a635d9208..a38593e892cc4e5a6c3a18a976e70d3b78e23066 100644 --- a/DDG4/src/Geant4UIMessenger.cpp +++ b/DDG4/src/Geant4UIMessenger.cpp @@ -29,7 +29,7 @@ namespace { const std::string& path; G4UImessenger* msg; InstallProperties(Geant4UIMessenger::Commands& c, const std::string& p, G4UImessenger* m) - : cmds(c), path(p), msg(m) { + : cmds(c), path(p), msg(m) { } void operator()(const pair<string, Property>& o) { string n = path + o.first; @@ -42,7 +42,7 @@ namespace { } Geant4UIMessenger::Geant4UIMessenger(const string& name, const string& path) - : G4UImessenger(), m_directory(0), m_properties(0), m_name(name), m_path(path) { +: G4UImessenger(), m_directory(0), m_properties(0), m_name(name), m_path(path) { m_directory = new G4UIdirectory(path.c_str()); printout(INFO, "Geant4UIMessenger", "+++ %s> Install Geant4 control directory:%s", name.c_str(), path.c_str()); m_directory->SetGuidance(("Control hierarchy for Geant4 action:" + name).c_str()); @@ -65,8 +65,8 @@ void Geant4UIMessenger::addCall(const std::string& name, const std::string& desc void Geant4UIMessenger::exportProperties(PropertyManager& mgr) { InstallProperties installer(m_propertyCmd, m_path, this); m_properties = &mgr; - addCall("show", "Show all properties of Geant4 component:" + m_name, - Callback(m_properties).make(&PropertyManager::dump)); + addCall("show", "Show all properties of Geant4 component:" + m_name, + Callback(m_properties).make(&PropertyManager::dump)); m_properties->for_each(installer); } @@ -77,8 +77,8 @@ G4String Geant4UIMessenger::GetCurrentValue(G4UIcommand * c) { const string& n = (*i).second; return (*m_properties)[n].str(); } - printout(INFO, "Geant4UIMessenger", - "+++ %s> Failed to access property value.", m_name.c_str()); + printout(INFO, "Geant4UIMessenger", + "+++ %s> Failed to access property value.", m_name.c_str()); return ""; } @@ -90,14 +90,14 @@ void Geant4UIMessenger::SetNewValue(G4UIcommand *c, G4String v) { if (!v.empty()) { Property& p = (*m_properties)[n]; p.str(v); - printout(INFO, "Geant4UIMessenger", - "+++ %s> Setting property value %s = %s native:%s.", - m_name.c_str(), n.c_str(), v.c_str(), p.str().c_str()); + printout(INFO, "Geant4UIMessenger", + "+++ %s> Setting property value %s = %s native:%s.", + m_name.c_str(), n.c_str(), v.c_str(), p.str().c_str()); } else { string value = (*m_properties)[n].str(); printout(INFO, "Geant4UIMessenger", "+++ %s> Unchanged property value %s = %s.", - m_name.c_str(), n.c_str(), value.c_str()); + m_name.c_str(), n.c_str(), value.c_str()); } return; } diff --git a/DDG4/src/Geant4UserParticleHandler.cpp b/DDG4/src/Geant4UserParticleHandler.cpp index 539242a4816fc520ae2b70f0427533bda5461a71..65120b52f6df98cb6754888de53d243e9458e566 100644 --- a/DDG4/src/Geant4UserParticleHandler.cpp +++ b/DDG4/src/Geant4UserParticleHandler.cpp @@ -17,7 +17,7 @@ using namespace DD4hep::Simulation; /// Standard constructor Geant4UserParticleHandler::Geant4UserParticleHandler(Geant4Context* context, const std::string& nam) - : Geant4Action(context,nam) +: Geant4Action(context,nam) { InstanceCount::increment(this); declareProperty("MinimalKineticEnergy",m_kinEnergyCut = 100e0*CLHEP::MeV); diff --git a/DDG4/src/Geant4Vertex.cpp b/DDG4/src/Geant4Vertex.cpp index d1dc57ef90358760fc813929a8fefb13e6bd06c8..e5c1ae725ca57fbfe3af1b2f3ec0adf5709da27f 100644 --- a/DDG4/src/Geant4Vertex.cpp +++ b/DDG4/src/Geant4Vertex.cpp @@ -21,14 +21,14 @@ VertexExtension::~VertexExtension() { /// Copy constructor Geant4Vertex::Geant4Vertex(const Geant4Vertex& c) - : ref(1), mask(c.mask), x(c.x), y(c.y), z(c.z), time(c.time), out(c.out), in(c.in) +: ref(1), mask(c.mask), x(c.x), y(c.y), z(c.z), time(c.time), out(c.out), in(c.in) { InstanceCount::increment(this); } /// Default constructor Geant4Vertex::Geant4Vertex() - : ref(1), mask(0), x(0), y(0), z(0), time(0) +: ref(1), mask(0), x(0), y(0), z(0), time(0) { InstanceCount::increment(this); } diff --git a/DDG4/src/Geant4VolumeManager.cpp b/DDG4/src/Geant4VolumeManager.cpp index 4eeba01dde921a52499bc73e5c454322d9181d7b..bc242e1780f0298278602f09aa4b955f175e6046 100644 --- a/DDG4/src/Geant4VolumeManager.cpp +++ b/DDG4/src/Geant4VolumeManager.cpp @@ -50,7 +50,7 @@ namespace { /// Default constructor Populator(LCDD& lcdd, Geant4GeometryInfo& g) - : m_lcdd(lcdd), m_geo(g) { + : m_lcdd(lcdd), m_geo(g) { } /// Populate the Volume manager @@ -64,7 +64,7 @@ namespace { SensitiveDetector sd; PlacedVolume::VolIDs ids; m_entries.clear(); - chain.push_back(m_lcdd.world().placement().ptr()); + chain.push_back(m_lcdd.world().placement().ptr()); scanPhysicalVolume(pv.ptr(), ids, sd, chain); continue; } @@ -87,14 +87,14 @@ namespace { } else { printout(WARNING, "Geant4VolumeManager", - "populate: Strange constellation volume %s is sensitive, but has no readout! sd:%p", pv.volume().name(), - sd.ptr()); + "populate: Strange constellation volume %s is sensitive, but has no readout! sd:%p", pv.volume().name(), + sd.ptr()); } } for (Int_t idau = 0, ndau = node->GetNdaughters(); idau < ndau; ++idau) { TGeoNode* daughter = node->GetDaughter(idau); - PlacedVolume placement(daughter); - if ( placement.data() ) { + PlacedVolume placement(daughter); + if ( placement.data() ) { scanPhysicalVolume(daughter, ids, sd, chain); } } @@ -113,69 +113,69 @@ namespace { PrintLevel print_action = VERBOSE; PrintLevel print_chain = VERBOSE; PrintLevel print_res = VERBOSE; - + printout(print_action,"Geant4VolumeManager","+++ Add path:%s vid:%016X", - DetectorTools::placementPath(nodes,false).c_str(),code); + DetectorTools::placementPath(nodes,false).c_str(),code); if (i == m_entries.end()) { path.reserve(nodes.size()); for (Chain::const_reverse_iterator k = nodes.rbegin(), kend=nodes.rend(); k != kend; ++k) { node = *(k); PlacementMap::const_iterator g4pit = m_geo.g4Placements.find(node); - if (g4pit != m_geo.g4Placements.end()) { + if (g4pit != m_geo.g4Placements.end()) { path.push_back((*g4pit).second); - printout(print_chain, "Geant4VolumeManager", "+++ Chain: Node OK: %s [%s]", - node->GetName(), (*g4pit).second->GetName().c_str()); - continue; + printout(print_chain, "Geant4VolumeManager", "+++ Chain: Node OK: %s [%s]", + node->GetName(), (*g4pit).second->GetName().c_str()); + continue; + } + control.insert(control.begin(),node); + vol = Volume(node->GetVolume()); + VolumeImprintMap::const_iterator iVolImp = m_geo.g4VolumeImprints.find(vol); + if ( iVolImp != m_geo.g4VolumeImprints.end() ) { + const Imprints& imprints = (*iVolImp).second; + //size_t len = kend-k; + for(Imprints::const_iterator iImp=imprints.begin(); iImp != imprints.end(); ++iImp) { + const VolumeChain& c = (*iImp).first; + if ( c.size() <= control.size() && control == c ) { + path.push_back((*iImp).second); + printout(print_chain, "Geant4VolumeManager", "+++ Chain: Node OK: %s %s -> %s", + node->GetName(), DetectorTools::placementPath(c,false).c_str(), + (*iImp).second->GetName().c_str()); + control.clear(); + break; + } + } + } + } + if ( control.empty() ) { + printout(print_res, "Geant4VolumeManager", "+++ Volume IDs:%s", + DetectorTools::toString(ro.idSpec(),ids,code).c_str()); + path.erase(path.begin()+path.size()-1); + printout(print_res, "Geant4VolumeManager", "+++ Map %016X to Geant4 Path:%s", + (void*)code, placementPath(path).c_str()); + if (m_geo.g4Paths.find(path) == m_geo.g4Paths.end()) { + m_geo.g4Paths[path] = code; + m_entries.insert(make_pair(code,path)); + return; } - control.insert(control.begin(),node); - vol = Volume(node->GetVolume()); - VolumeImprintMap::const_iterator iVolImp = m_geo.g4VolumeImprints.find(vol); - if ( iVolImp != m_geo.g4VolumeImprints.end() ) { - const Imprints& imprints = (*iVolImp).second; - //size_t len = kend-k; - for(Imprints::const_iterator iImp=imprints.begin(); iImp != imprints.end(); ++iImp) { - const VolumeChain& c = (*iImp).first; - if ( c.size() <= control.size() && control == c ) { - path.push_back((*iImp).second); - printout(print_chain, "Geant4VolumeManager", "+++ Chain: Node OK: %s %s -> %s", - node->GetName(), DetectorTools::placementPath(c,false).c_str(), - (*iImp).second->GetName().c_str()); - control.clear(); - break; - } - } - } - } - if ( control.empty() ) { - printout(print_res, "Geant4VolumeManager", "+++ Volume IDs:%s", - DetectorTools::toString(ro.idSpec(),ids,code).c_str()); - path.erase(path.begin()+path.size()-1); - printout(print_res, "Geant4VolumeManager", "+++ Map %016X to Geant4 Path:%s", - (void*)code, placementPath(path).c_str()); - if (m_geo.g4Paths.find(path) == m_geo.g4Paths.end()) { - m_geo.g4Paths[path] = code; - m_entries.insert(make_pair(code,path)); - return; - } - printout(ERROR, "Geant4VolumeManager", "populate: Severe error: Duplicated Geant4 path!!!! %s %s", - " [THIS SHOULD NEVER HAPPEN]",placementPath(path).c_str()); - goto Err; - } - printout(INFO, "Geant4VolumeManager", "Control block has still %d entries:%s", - int(control.size()),DetectorTools::placementPath(control,true).c_str()); - goto Err; + printout(ERROR, "Geant4VolumeManager", "populate: Severe error: Duplicated Geant4 path!!!! %s %s", + " [THIS SHOULD NEVER HAPPEN]",placementPath(path).c_str()); + goto Err; + } + printout(INFO, "Geant4VolumeManager", "Control block has still %d entries:%s", + int(control.size()),DetectorTools::placementPath(control,true).c_str()); + goto Err; } printout(ERROR, "Geant4VolumeManager", "populate: Severe error: Duplicated Volume entry: %X" - " [THIS SHOULD NEVER HAPPEN]", code); + " [THIS SHOULD NEVER HAPPEN]", code); Err: - if ( i != m_entries.end() ) - printout(ERROR,"Geant4VolumeManager"," Known G4 path: %s",placementPath((*i).second).c_str()); + if ( i != m_entries.end() ) + printout(ERROR,"Geant4VolumeManager"," Known G4 path: %s",placementPath((*i).second).c_str()); if ( !path.empty() ) - printout(ERROR,"Geant4VolumeManager"," New G4 path: %s",placementPath(path).c_str()); + printout(ERROR,"Geant4VolumeManager"," New G4 path: %s",placementPath(path).c_str()); if ( !nodes.empty() ) - printout(ERROR,"Geant4VolumeManager"," TGeo path: %s",DetectorTools::placementPath(nodes,false).c_str()); + printout(ERROR,"Geant4VolumeManager"," TGeo path: %s",DetectorTools::placementPath(nodes,false).c_str()); printout(ERROR,"Geant4VolumeManager", " Offend.VolIDs: %s",DetectorTools::toString(ro.idSpec(),ids,code).c_str()); throw runtime_error("Failed to populate Geant4 volume manager!"); } @@ -184,7 +184,7 @@ namespace { /// Initializing constructor. The tree will automatically be built if possible Geant4VolumeManager::Geant4VolumeManager(LCDD& lcdd, Geant4GeometryInfo* info) - : Base(info), m_isValid(false) { +: Base(info), m_isValid(false) { if (info && info->valid && info->g4Paths.empty()) { Populator p(lcdd, *info); p.populate(lcdd.world()); @@ -226,8 +226,8 @@ VolumeID Geant4VolumeManager::volumeID(const PlacementPath& path) const { else if (!path[0]->GetLogicalVolume()->GetSensitiveDetector()) return Insensitive; } - printout(INFO, "Geant4VolumeManager","+++ Bad volume Geant4 Path: %s", - Geant4GeometryMaps::placementPath(path).c_str()); + printout(INFO, "Geant4VolumeManager","+++ Bad volume Geant4 Path: %s", + Geant4GeometryMaps::placementPath(path).c_str()); return NonExisting; } @@ -248,18 +248,18 @@ void Geant4VolumeManager::volumeDescriptor(const PlacementPath& path, VolIDDescr VolumeID vid = (*i).second; G4LogicalVolume* lvol = path[0]->GetLogicalVolume(); if (lvol->GetSensitiveDetector()) { - const G4VPhysicalVolume* node = path[0]; - const PlacementMap& m = ptr()->g4Placements; - for (PlacementMap::const_iterator i = m.begin(); i != m.end(); ++i) { - if ((*i).second == node) { - PlacedVolume pv = (*i).first; - Geometry::SensitiveDetector sd = pv.volume().sensitiveDetector(); - Geometry::IDDescriptor dsc = sd.readout().idSpec(); - vol_desc.first = vid; - dsc.decodeFields(vid, vol_desc.second); - return; - } - } + const G4VPhysicalVolume* node = path[0]; + const PlacementMap& m = ptr()->g4Placements; + for (PlacementMap::const_iterator i = m.begin(); i != m.end(); ++i) { + if ((*i).second == node) { + PlacedVolume pv = (*i).first; + Geometry::SensitiveDetector sd = pv.volume().sensitiveDetector(); + Geometry::IDDescriptor dsc = sd.readout().idSpec(); + vol_desc.first = vid; + dsc.decodeFields(vid, vol_desc.second); + return; + } + } } vol_desc.first = Insensitive; return; diff --git a/DDG4/src/IoStreams.cpp b/DDG4/src/IoStreams.cpp index c18cff50e699fec3d23bfb43e4cc17504bfbc949..614a81be256eead2a7f76761298c051d46ea38ab 100644 --- a/DDG4/src/IoStreams.cpp +++ b/DDG4/src/IoStreams.cpp @@ -51,15 +51,15 @@ namespace DD4hep { : m_handle(0), m_flag(close_handle) {open(fn,mode); } /// Specialization for standard file descriptor files according to the posix standard - template<> std::streamsize dd4hep_file<int>::read(char_type* s, std::streamsize n) + template<> std::streamsize dd4hep_file<int>::read(char_type* s, std::streamsize n) { return ::read(m_handle,s,n); } /// Specialization for standard file descriptor files according to the posix standard - template<> std::streamsize dd4hep_file<int>::write(const char_type* s, std::streamsize n) + template<> std::streamsize dd4hep_file<int>::write(const char_type* s, std::streamsize n) { return ::write(m_handle,s,n); } /// Specialization for standard file descriptor files according to the posix standard - template<> std::streampos dd4hep_file<int>::seek(stream_offset off, BOOST_IOS::seekdir way) + template<> std::streampos dd4hep_file<int>::seek(stream_offset off, BOOST_IOS::seekdir way) { return ::lseek(m_handle,off,way); } /// Specialization for standard file descriptor files according to the posix standard @@ -89,11 +89,11 @@ namespace DD4hep { #define _p(x) ((MyTFile*)x) /// Specialization for the usage of TFile structures - template<> dd4hep_file<TFile*>::dd4hep_file(handle_type fd, dd4hep_file_flags flags) + template<> dd4hep_file<TFile*>::dd4hep_file(handle_type fd, dd4hep_file_flags flags) : m_handle(fd), m_flag(flags) { } /// Specialization for the usage of TFile structures - template<> dd4hep_file<TFile*>::dd4hep_file(const char* fname, BOOST_IOS::openmode mode) + template<> dd4hep_file<TFile*>::dd4hep_file(const char* fname, BOOST_IOS::openmode mode) : m_handle(0), m_flag(close_handle) { open(fname,mode); } /// Specialization for the usage of TFile structures @@ -102,23 +102,23 @@ namespace DD4hep { Long64_t nb1 = m_handle->GetBytesRead(); Bool_t res = _p(m_handle)->ReadBuffer(s,nb1,n); if ( res ) { - Long64_t nb2 = m_handle->GetBytesRead(); - return nb2-nb1; + Long64_t nb2 = m_handle->GetBytesRead(); + return nb2-nb1; } } return -1; } /// Specialization for the usage of TFile structures - template<> std::streamsize dd4hep_file<TFile*>::write(const char_type* s, std::streamsize n) + template<> std::streamsize dd4hep_file<TFile*>::write(const char_type* s, std::streamsize n) { return m_handle ? _p(m_handle)->SysWrite(m_handle->GetFd(),s,n) : -1; } /// Specialization for the usage of TFile structures - template<> std::streampos dd4hep_file<TFile*>::seek(stream_offset off, BOOST_IOS::seekdir way) + template<> std::streampos dd4hep_file<TFile*>::seek(stream_offset off, BOOST_IOS::seekdir way) { return m_handle ? _p(m_handle)->SysSeek(m_handle->GetFd(),off,way) : -1; } /// Specialization for the usage of TFile structures - template<> void dd4hep_file<TFile*>::close() + template<> void dd4hep_file<TFile*>::close() { if ( m_handle ) { m_handle->Close(); delete m_handle; m_handle=0; } } }