CMS 3D CMS Logo

FWGeometry.h
Go to the documentation of this file.
1 #ifndef Fireworks_Core_FWGeometry_h
2 #define Fireworks_Core_FWGeometry_h
3 //
4 // Description: service class that implements access to geometry of a given DetId
5 //
6 // Primary usage: raw detector id to full transformation matrix mapping
7 //
8 // Original Author: D.Kovalskyi
9 //
10 class TEveGeoShape;
11 class TGeoVolume;
12 class TGeoShape;
13 class TFile;
14 class TObjArray;
15 
16 #include <map>
17 #include <vector>
18 #include <memory>
19 
20 #include "TEveVSDStructs.h"
21 #include "TGeoMatrix.h"
22 #include "TGeoXtru.h"
23 
25 
27 class FWGeometry {
28 public:
29  static const int kDetOffset = 28;
30  static const int kSubdetOffset = 25;
31 
32  enum Detector {
33  Tracker = 1,
34  Muon = 2,
35  Ecal = 3,
36  Hcal = 4,
37  Calo = 5,
38  HGCalEE = 8,
39  HGCalHSi = 9,
40  HGCalHSc = 10,
42  };
43  enum SubDetector {
46  TIB = 3,
47  TID = 4,
48  TOB = 5,
49  TEC = 6,
50  CSC = 7,
51  DT = 8,
52  RPCBarrel = 9,
53  RPCEndcap = 10,
54  GEM = 11,
55  ME0 = 12
56  };
57 
58  struct Range {
59  double min1;
60  double max1;
61  double min2;
62  double max2;
63  Range(void) : min1(9999), max1(-9999), min2(9999), max2(-9999) {}
64  };
65 
66  class VersionInfo {
67  public:
68  TNamed* productionTag;
69  TNamed* cmsswVersion;
70  TObjArray* extraDetectors;
71 
72  VersionInfo() : productionTag(nullptr), cmsswVersion(nullptr), extraDetectors(nullptr) {}
73  bool haveExtraDet(const char*) const;
74  };
75 
76  FWGeometry(void);
77 
78  ~FWGeometry(void);
79 
80  // load DetId to RecoGeomInfo map
81  void loadMap(const char* fileName);
82 
83  void initMap(const FWRecoGeom::InfoMap& map);
84 
85  // get matrix for full local to global transformation
86  const TGeoMatrix* getMatrix(unsigned int id) const;
87 
88  static TFile* findFile(const char* fileName);
89 
90  // extract locally positioned shape for stand alone use
91  TGeoShape* getShape(unsigned int id) const;
92 
93  // extract globally positioned shape for stand alone use
94  TEveGeoShape* getEveShape(unsigned int id) const;
95  TEveGeoShape* getHGCSiliconEveShape(unsigned int id) const;
96  TEveGeoShape* getHGCScintillatorEveShape(unsigned int id) const;
97 
98  // get shape description parameters
99  const float* getShapePars(unsigned int id) const;
100 
101  // get all known detector ids with id matching mask
102  std::vector<unsigned int> getMatchedIds(Detector det, SubDetector subdet) const;
103  std::vector<unsigned int> getMatchedIds(Detector det) const;
104 
105  // get reco geometry
106  const float* getCorners(unsigned int id) const;
107 
108  // get reco topology/parameters
109  const float* getParameters(unsigned int id) const;
110 
111  void localToGlobal(unsigned int id, const float* local, float* global, bool translatep = true) const;
112  void localToGlobal(unsigned int id,
113  const float* local1,
114  float* global1,
115  const float* local2,
116  float* global2,
117  bool translatep = true) const;
118 
119  struct GeomDetInfo {
120  unsigned int id; // DetId
121  float points[24]; // 3*8 x,y,z points defining its shape (can be undefined, e.g. 0s)
122  float parameters[9]; // specific DetId dependent parameters, e.g. topology (can be undefined, e.g. 0s)
123  float shape
124  [5]; // shape description: 0 - shape type, For Trap: 1 - dx1, 2 - dx2, 3 - dz, 4 - dy1; for Box: dx, dy, dz (can be undefined, e.g. 0s)
125  float translation[3]; // translation x, y, z (can be undefined, e.g. 0s)
126  float matrix[9]; // transformation matrix xx, yx, zx, xy, yy, zy, xz, yz, zz (can be undefined, e.g. 0s)
127 
128  bool operator<(unsigned int id) const { return (this->id < id); }
129  };
130 
131  bool match_id(const GeomDetInfo& o, unsigned int mask) const {
132  unsigned int id = o.id;
133  return (((((id >> kDetOffset) & 0xF) << 4) | ((id >> kSubdetOffset) & 0x7)) == mask);
134  }
135 
136  typedef std::vector<FWGeometry::GeomDetInfo> IdToInfo;
137  typedef std::vector<FWGeometry::GeomDetInfo>::const_iterator IdToInfoItr;
138 
139  bool contains(unsigned int id) const { return FWGeometry::find(id) != m_idToInfo.end(); }
140 
141  IdToInfoItr mapEnd() const { return m_idToInfo.end(); }
142 
143  void clear(void) {
144  m_idToInfo.clear();
145  m_idToMatrix.clear();
146  }
147  IdToInfoItr find(unsigned int) const;
148  void localToGlobal(const GeomDetInfo& info, const float* local, float* global, bool translatep = true) const;
149 
150  const VersionInfo& versionInfo() const { return m_versionInfo; }
151 
152  int getProducerVersion() const { return m_producerVersion; }
153 
154  TGeoShape* getShape(const GeomDetInfo& info) const;
155 
156  const TrackerTopology* getTrackerTopology() const { return m_trackerTopology.get(); }
157 
158  void applyGlobalTag(const std::string& gt);
159 
160  bool isEmpty() const;
161 
162 private:
163  mutable std::map<unsigned int, TGeoMatrix*> m_idToMatrix;
164 
166 
168 
170 
172 
174 
175  std::unique_ptr<TrackerTopology> m_trackerTopology;
176 };
177 
178 #endif
FWGeometry::getProducerVersion
int getProducerVersion() const
Definition: FWGeometry.h:152
FWGeometry::getHGCScintillatorEveShape
TEveGeoShape * getHGCScintillatorEveShape(unsigned int id) const
Definition: FWGeometry.cc:420
FWGeometry::GeomDetInfo
Definition: FWGeometry.h:119
FWGeometry
Definition: FWGeometry.h:27
FWGeometry::getCorners
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:464
FWGeometry::match_id
bool match_id(const GeomDetInfo &o, unsigned int mask) const
Definition: FWGeometry.h:131
FWGeometry::loadMap
void loadMap(const char *fileName)
Definition: FWGeometry.cc:100
FWGeometry::versionInfo
const VersionInfo & versionInfo() const
Definition: FWGeometry.h:150
FWGeometry::TID
Definition: FWGeometry.h:47
FWGeometry::VersionInfo::productionTag
TNamed * productionTag
Definition: FWGeometry.h:68
TrackerTopology
Definition: TrackerTopology.h:16
FWGeometry::RPCBarrel
Definition: FWGeometry.h:52
FWGeometry::getTrackerTopology
const TrackerTopology * getTrackerTopology() const
Definition: FWGeometry.h:156
FWGeometry::localToGlobal
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:497
FWGeometry::GeomDetInfo::shape
float shape[5]
Definition: FWGeometry.h:124
FWGeometry::VersionInfo
Definition: FWGeometry.h:66
FWGeometry::Range::max1
double max1
Definition: FWGeometry.h:60
FWGeometry::GeomDetInfo::points
float points[24]
Definition: FWGeometry.h:121
FWGeometry::IdToInfoItr
std::vector< FWGeometry::GeomDetInfo >::const_iterator IdToInfoItr
Definition: FWGeometry.h:137
FWGeometry::getShapePars
const float * getShapePars(unsigned int id) const
Definition: FWGeometry.cc:486
FWGeometry::applyGlobalTag
void applyGlobalTag(const std::string &gt)
Definition: FWGeometry.cc:56
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:152
FWGeometry::DT
Definition: FWGeometry.h:51
FWGeometry::RPCEndcap
Definition: FWGeometry.h:53
FWGeometry::VersionInfo::VersionInfo
VersionInfo()
Definition: FWGeometry.h:72
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
FWGeometry::GeomDetInfo::matrix
float matrix[9]
Definition: FWGeometry.h:126
FWGeometry::getHGCSiliconEveShape
TEveGeoShape * getHGCSiliconEveShape(unsigned int id) const
Definition: FWGeometry.cc:354
FWGeometry::m_versionInfo
VersionInfo m_versionInfo
Definition: FWGeometry.h:169
Muon
Definition: Muon.py:1
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:36
parameters
parameters
Definition: BeamSpot_PayloadInspector.cc:14
FWGeometry::kDetOffset
static const int kDetOffset
Definition: FWGeometry.h:29
FWGeometry::getParameters
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:475
TrackerTopology.h
FWGeometry::getMatrix
const TGeoMatrix * getMatrix(unsigned int id) const
Definition: FWGeometry.cc:222
FWGeometry::Tracker
Definition: FWGeometry.h:33
FWGeometry::FWGeometry
FWGeometry(void)
Definition: FWGeometry.cc:24
FWGeometry::VersionInfo::haveExtraDet
bool haveExtraDet(const char *) const
Definition: FWGeometry.cc:532
FWGeometry::mapEnd
IdToInfoItr mapEnd() const
Definition: FWGeometry.h:141
FWGeometry::Hcal
Definition: FWGeometry.h:36
FWRecoGeom.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FWGeometry::isEmpty
bool isEmpty() const
Definition: FWGeometry.cc:28
FWGeometry::Range::max2
double max2
Definition: FWGeometry.h:62
FWGeometry::TOB
Definition: FWGeometry.h:48
FWGeometry::m_prodTag
std::string m_prodTag
Definition: FWGeometry.h:167
FWGeometry::GeomDetInfo::id
unsigned int id
Definition: FWGeometry.h:120
FWGeometry::GeomDetInfo::translation
float translation[3]
Definition: FWGeometry.h:125
FWGeometry::VersionInfo::extraDetectors
TObjArray * extraDetectors
Definition: FWGeometry.h:70
FWGeometry::CSC
Definition: FWGeometry.h:50
FWGeometry::m_idToInfo
IdToInfo m_idToInfo
Definition: FWGeometry.h:165
FWGeometry::Ecal
Definition: FWGeometry.h:35
FWGeometry::m_producerVersion
int m_producerVersion
Definition: FWGeometry.h:171
FWGeometry::GeomDetInfo::operator<
bool operator<(unsigned int id) const
Definition: FWGeometry.h:128
FWGeometry::IdToInfo
std::vector< FWGeometry::GeomDetInfo > IdToInfo
Definition: FWGeometry.h:136
FWGeometry::Detector
Detector
Definition: FWGeometry.h:32
FWGeometry::initMap
void initMap(const FWRecoGeom::InfoMap &map)
Definition: FWGeometry.cc:200
FWGeometry::m_trackerTopology
std::unique_ptr< TrackerTopology > m_trackerTopology
Definition: FWGeometry.h:175
FWGeometry::TIB
Definition: FWGeometry.h:46
FWGeometry::HGCalHSi
Definition: FWGeometry.h:39
FWGeometry::HGCalHSc
Definition: FWGeometry.h:40
FWGeometry::TEC
Definition: FWGeometry.h:49
FWGeometry::m_idToMatrix
std::map< unsigned int, TGeoMatrix * > m_idToMatrix
Definition: FWGeometry.h:163
FWGeometry::PixelBarrel
Definition: FWGeometry.h:44
FWGeometry::ME0
Definition: FWGeometry.h:55
FWGeometry::VersionInfo::cmsswVersion
TNamed * cmsswVersion
Definition: FWGeometry.h:69
FWGeometry::HGCalTrigger
Definition: FWGeometry.h:41
FWGeometry::~FWGeometry
~FWGeometry(void)
Definition: FWGeometry.cc:26
FWGeometry::findFile
static TFile * findFile(const char *fileName)
Definition: FWGeometry.cc:35
FWGeometry::Range::min2
double min2
Definition: FWGeometry.h:61
FWGeometry::getMatchedIds
std::vector< unsigned int > getMatchedIds(Detector det, SubDetector subdet) const
Definition: FWGeometry.cc:251
FWGeometry::contains
bool contains(unsigned int id) const
Definition: FWGeometry.h:139
FWGeometry::Calo
Definition: FWGeometry.h:37
FWGeometry::SubDetector
SubDetector
Definition: FWGeometry.h:43
FWGeometry::clear
void clear(void)
Definition: FWGeometry.h:143
FWGeometry::Range::min1
double min1
Definition: FWGeometry.h:59
FWGeometry::GEM
Definition: FWGeometry.h:54
FWGeometry::getShape
TGeoShape * getShape(unsigned int id) const
Definition: FWGeometry.cc:290
FWGeometry::kSubdetOffset
static const int kSubdetOffset
Definition: FWGeometry.h:30
DTRecHitClients_cfi.local
local
Definition: DTRecHitClients_cfi.py:10
FWGeometry::m_fileName
std::string m_fileName
Definition: FWGeometry.h:173
genParticles_cff.map
map
Definition: genParticles_cff.py:11
FWGeometry::PixelEndcap
Definition: FWGeometry.h:45
FWGeometry::Range
Definition: FWGeometry.h:58
FWGeometry::Range::Range
Range(void)
Definition: FWGeometry.h:63
FWGeometry::getEveShape
TEveGeoShape * getEveShape(unsigned int id) const
Definition: FWGeometry.cc:321
FWRecoGeom::InfoMap
std::vector< FWRecoGeom::Info > InfoMap
Definition: FWRecoGeom.h:23
FWGeometry::HGCalEE
Definition: FWGeometry.h:38
FWGeometry::find
IdToInfoItr find(unsigned int) const
Definition: FWGeometry.cc:517