DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LayeringExtensionPlugin.cpp
Go to the documentation of this file.
1 // $Id: $
2 //==========================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------------
5 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6 // All rights reserved.
7 //
8 // For the licensing terms see $DD4hepINSTALL/LICENSE.
9 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10 //
11 // Author : M.Frank
12 //
13 //==========================================================================
14 //
15 // Specialized generic detector plugin
16 //
17 //==========================================================================
18 
19 #include <map>
21 using namespace DD4hep::DDRec;
22 using namespace DD4hep::Geometry;
23 
24 namespace {
25  struct LayeringContext {
26  public:
27  DetElement det, parent;
28  std::map<int,DetElement> layers;
29  LayeringContext() {}
30  ~LayeringContext() {
32  det.addExtension<LayeringExtension>(e);
33  for(std::map<int,DetElement>::const_iterator i=layers.begin(); i!=layers.end();++i) {
34  DetElement de = (*i).second;
35  e->setLayer(de.id(), de, Position(0,0,1));
36  std::cout << " Add layer:" << de.name()
37  << " ID: " << de.id()
38  << " Parent:" << de.parent().name() << std::endl;
39  }
40  }
41  };
42 }
43 #define SURFACEINSTALLER_DATA LayeringContext
44 #define DD4HEP_USE_SURFACEINSTALL_HELPER LayeringExtensionPlugin
46 
47 
49 template <typename T> void Installer<T>::install(DetElement de, PlacedVolume /* pv */) {
50  if ( ::strstr(de.name(),"layer") != 0 ) {
51  if ( !data.parent.isValid() ) {
52  data.det = m_det;
53  data.parent = de.parent();
54  }
55  if ( data.parent == de.parent() && data.layers.find(de.id()) == data.layers.end() ) {
56  data.layers[de.id()] = de;
57  }
58  }
59 }
60 
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:135
const char * name() const
Access the object name (or "" if not supported by the object)
Definition: Handle.inl:36
return e
Definition: Volumes.cpp:297
ROOT::Math::XYZVector Position
Definition: Objects.h:75
int id() const
Get the detector identifier.
Definition: Detector.cpp:171
DetElement parent() const
Access to the detector elements's parent.
Definition: Detector.cpp:222
Handle class describing a detector element.
Definition: Detector.h:172
void setLayer(int layerIndex, Geometry::DetElement layer, const Position &normal)
Stores the layer information for the given layer index.