CMS 3D CMS Logo

RPCGeometryParsFromDD.cc
Go to the documentation of this file.
1 /* Implementation of the RPCGeometryParsFromDD Class
2  * Build the RPCGeometry from the DDD and DD4Hep description
3  *
4  * DD4hep part added to the original old file (DD version) made by M. Maggi (INFN Bari)
5  * Author: Sergio Lo Meo (sergio.lo.meo@cern.ch)
6  * Created: Mon, 09 Nov 2020
7  *
8  */
19 #include "CLHEP/Units/GlobalSystemOfUnits.h"
20 #include <iostream>
21 #include <algorithm>
26 
28 
30 
31 // DD
33  const MuonGeometryConstants& muonConstants,
34  RecoIdealGeometry& rgeo) {
35  const std::string attribute = "ReadOutName";
36  const std::string value = "MuonRPCHits";
37 
38  // Asking only for the MuonRPC's
40  DDFilteredView fview(*cview, filter);
41 
42  this->buildGeometry(fview, muonConstants, rgeo);
43 }
44 
45 // DD4Hep
46 
48  const MuonGeometryConstants& muonConstants,
49  RecoIdealGeometry& rgeo) {
50  const std::string attribute = "ReadOutName";
51  const std::string value = "MuonRPCHits";
52  const cms::DDFilter filter(attribute, value);
53  cms::DDFilteredView fview(*cview, filter);
54  this->buildGeometry(fview, muonConstants, rgeo);
55 }
56 
57 // DD
58 
60  const MuonGeometryConstants& muonConstants,
61  RecoIdealGeometry& rgeo) {
62  for (bool doSubDets = fview.firstChild(); doSubDets == true; doSubDets = fview.nextSibling()) {
63  // Get the Base Muon Number
64  MuonGeometryNumbering mdddnum(muonConstants);
65  MuonBaseNumber mbn = mdddnum.geoHistoryToBaseNumber(fview.geoHistory());
66 
67  // Get the The Rpc det Id
68  RPCNumberingScheme rpcnum(muonConstants);
69  const int detid = rpcnum.baseNumberToUnitNumber(mbn);
70 
71  RPCDetId rpcid(detid);
72 
73  DDValue numbOfStrips("nStrips");
74 
75  std::vector<const DDsvalues_type*> specs(fview.specifics());
76  int nStrips = 0;
77  for (auto& spec : specs) {
78  if (DDfetch(spec, numbOfStrips)) {
79  nStrips = int(numbOfStrips.doubles()[0]);
80  }
81  }
82  if (nStrips == 0)
83  std::cout << "No strip found!!" << std::endl;
84 
85  const std::vector<double> dpar = fview.logicalPart().solid().parameters();
86 
87  const std::string name = fview.logicalPart().name().name();
88 
89  edm::LogVerbatim("RPCGeometryParsFromDD")
90  << " (1) "
91  << "detid: " << detid << " name: " << name << " number of Strips: " << nStrips;
92 
93  const std::vector<std::string> strpars = {name};
94  const DDTranslation& tran = fview.translation();
95 
96  const DDRotationMatrix& rota = fview.rotation(); //.Inverse();
97  DD3Vector x, y, z;
98  rota.GetComponents(x, y, z);
99  std::vector<double> pars;
100  if (dpar.size() == 3) {
101  const double width = dpar[0];
102  const double length = dpar[1];
103  const double thickness = dpar[2];
104  edm::LogVerbatim("RPCGeometryParsFromDD")
105  << " (2) dpar.size() == 3, width: " << width << " length: " << length << " thickness: " << thickness;
106  pars = {width, length, thickness, numbOfStrips.doubles()[0]};
107  } else {
108  const double dpar4 = dpar[4];
109  const double dpar8 = dpar[8];
110  const double dpar0 = dpar[0];
111  pars = {dpar4, dpar8, dpar0, 0.4, numbOfStrips.doubles()[0]};
112  edm::LogVerbatim("RPCGeometryParsFromDD")
113  << " (3), else, dpar[4]: " << dpar4 << " dpar[8]: " << dpar8 << " dpar[0]: " << dpar0;
114  }
115 
116  const std::vector<double> vtra = {tran.x(), tran.y(), tran.z()};
117 
118  edm::LogVerbatim("RPCGeometryParsFromDD")
119  << " (4), tran.x() " << tran.x() << " tran.y(): " << tran.y() << " tran.z(): " << tran.z();
120 
121  const std::vector<double> vrot = {x.X(), x.Y(), x.Z(), y.X(), y.Y(), y.Z(), z.X(), z.Y(), z.Z()};
122  edm::LogVerbatim("RPCGeometryParsFromDD")
123  << " (5), x.X(), x.Y(), x.Z(), y.X(), y.Y(), y.Z(), z.X(), z.Y(), z.Z() " << x.X() << ", " << x.Y() << ", "
124  << x.Z() << ", " << y.X() << ", " << y.Y() << ", " << y.Z() << ", " << z.X() << ", " << z.Y() << ", " << z.Z();
125  rgeo.insert(rpcid.rawId(), vtra, vrot, pars, strpars);
126  }
127 }
128 
129 // DD4Hep
130 
132  const MuonGeometryConstants& muonConstants,
133  RecoIdealGeometry& rgeo) {
134  while (fview.firstChild()) {
135  MuonGeometryNumbering mdddnum(muonConstants);
136  RPCNumberingScheme rpcnum(muonConstants);
137  int rawidCh = rpcnum.baseNumberToUnitNumber(mdddnum.geoHistoryToBaseNumber(fview.history()));
138  RPCDetId rpcid = RPCDetId(rawidCh);
139 
140  auto nStrips = fview.get<double>("nStrips");
141 
142  std::vector<double> dpar = fview.parameters();
143 
144  std::string_view name = fview.name();
145 
146  edm::LogVerbatim("RPCGeometryParsFromDD")
147  << " (1), detid: " << rawidCh << " name: " << std::string(name) << " number of Strips: " << nStrips;
148 
149  const std::vector<std::string> strpars = {std::string(name)};
150 
151  std::vector<double> tran(3);
152  tran[0] = static_cast<double>(fview.translation().X()) / dd4hep::mm;
153  tran[1] = static_cast<double>(fview.translation().Y()) / dd4hep::mm;
154  tran[2] = static_cast<double>(fview.translation().Z()) / dd4hep::mm;
155 
156  DDRotationMatrix rota;
157  fview.rot(rota);
158  DD3Vector x, y, z;
159  rota.GetComponents(x, y, z);
160  const std::vector<double> rot = {x.X(), x.Y(), x.Z(), y.X(), y.Y(), y.Z(), z.X(), z.Y(), z.Z()};
161 
162  if (dd4hep::isA<dd4hep::Box>(fview.solid())) {
163  const std::vector<double> pars = {
164  dpar[0] / dd4hep::mm, dpar[1] / dd4hep::mm, dpar[2] / dd4hep::mm, double(nStrips)};
165  edm::LogVerbatim("RPCGeometryParsFromDD")
166  << " (2), dd4hep::Box, width: " << dpar[0] / dd4hep::mm << " length: " << dpar[1] / dd4hep::mm
167  << " thickness: " << dpar[2] / dd4hep::mm;
168  rgeo.insert(rpcid, tran, rot, pars, strpars);
169  } else {
170  const double ti = 0.4;
171  const std::vector<double> pars = {
172  dpar[0] / dd4hep::mm, dpar[1] / dd4hep::mm, dpar[3] / dd4hep::mm, ti, double(nStrips)};
173  edm::LogVerbatim("RPCGeometryParsFromDD") << " (3), else, dpar[0] (i.e. dpar[4] for DD): " << dpar[0] / dd4hep::mm
174  << " dpar[1] (i.e. dpar[8] for DD): " << dpar[1] / dd4hep::mm
175  << " dpar[3] (i.e. dpar[0] for DD): " << dpar[3] / dd4hep::mm;
176  rgeo.insert(rpcid, tran, rot, pars, strpars);
177  }
178  edm::LogVerbatim("RPCGeometryParsFromDD")
179  << " (4), tran.x(): " << tran[0] << " tran.y(): " << tran[1] << " tran.z(): " << tran[2];
180  edm::LogVerbatim("RPCGeometryParsFromDD")
181  << " (5), x.X(), x.Y(), x.Z(), y.X(), y.Y(), y.Z(), z.X(), z.Y(), z.Z(): " << x.X() << ", " << x.Y() << ", "
182  << x.Z() << ", " << y.X() << ", " << y.Y() << ", " << y.Z() << ", " << z.X() << ", " << z.Y() << ", " << z.Z();
183  }
184 }
cms::DDFilteredView::rot
const Double_t * rot() const
The absolute rotation of the current node.
Definition: DDFilteredView.cc:120
MuonGeometryConstants
Definition: MuonGeometryConstants.h:20
DDAxes::y
RPCGeometryParsFromDD::build
void build(const DDCompactView *cview, const MuonGeometryConstants &muonConstants, RecoIdealGeometry &rgeo)
Definition: RPCGeometryParsFromDD.cc:32
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
cms::DDFilteredView::parameters
const std::vector< double > parameters() const
extract shape parameters
Definition: DDFilteredView.cc:536
MessageLogger.h
MuonGeometryNumbering::geoHistoryToBaseNumber
MuonBaseNumber geoHistoryToBaseNumber(const DDGeoHistory &history) const
Definition: MuonGeometryNumbering.cc:38
DDFilteredView::logicalPart
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
Definition: DDFilteredView.cc:16
RPCDetId
Definition: RPCDetId.h:16
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HistogramManager_cfi.specs
specs
Definition: HistogramManager_cfi.py:83
Basic3DVector.h
MuonGeometryNumbering.h
DDAxes::x
cms::DDFilteredView
Definition: DDFilteredView.h:70
RPCNumberingScheme
Definition: RPCNumberingScheme.h:18
cms::DDFilteredView::name
std::string_view name() const
Definition: DDFilteredView.cc:857
cms::DDFilteredView::translation
const Translation translation() const
Definition: DDFilteredView.cc:103
RPCNumberingScheme::baseNumberToUnitNumber
int baseNumberToUnitNumber(const MuonBaseNumber &) const override
Definition: RPCNumberingScheme.cc:30
cms::DDFilteredView::get
T get(const std::string &)
extract attribute value
cms::DDFilteredView::solid
dd4hep::Solid solid() const
Definition: DDFilteredView.cc:865
RPCGeometryParsFromDD::buildGeometry
void buildGeometry(DDFilteredView &fview, const MuonGeometryConstants &muonConstants, RecoIdealGeometry &rgeo)
Definition: RPCGeometryParsFromDD.cc:59
DDFilteredView::firstChild
bool firstChild()
set the current node to the first child ...
Definition: DDFilteredView.cc:86
DDFilteredView.h
cms::DDFilter
Definition: DDFilteredView.h:59
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Calorimetry_cff.thickness
thickness
Definition: Calorimetry_cff.py:115
RPCNumberingScheme.h
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDBase::name
const N & name() const
Definition: DDBase.h:59
DDAxes::z
cms::DDFilteredView::firstChild
bool firstChild()
set the current node to the first child
Definition: DDFilteredView.cc:268
DDSolid.h
DDFilteredView::nextSibling
bool nextSibling()
set the current node to the next sibling ...
Definition: DDFilteredView.cc:124
DDfetch
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79
DDFilteredView.h
DDCompactView.h
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
RecoIdealGeometry.h
RPCDetId.h
DD3Vector
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
Definition: PGeometricDetBuilder.cc:20
DDSpecParRegistry.h
MuonBaseNumber.h
RPCGeometryParsFromDD::~RPCGeometryParsFromDD
~RPCGeometryParsFromDD()
Definition: RPCGeometryParsFromDD.cc:29
cms::DDFilteredView::history
const ExpandedNodes & history()
The numbering history of the current node.
Definition: DDFilteredView.cc:686
createfilelist.int
int
Definition: createfilelist.py:10
DDFilter.h
value
Definition: value.py:1
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
DDFilteredView::geoHistory
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
Definition: DDFilteredView.cc:30
RPCGeometryParsFromDD.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDFilteredView::specifics
std::vector< const DDsvalues_type * > specifics() const
Definition: DDFilteredView.cc:32
me0TriggerPseudoDigis_cff.nStrips
nStrips
1.2 is to make the matching window safely the two nearest strips 0.35 is the size of an ME0 chamber i...
Definition: me0TriggerPseudoDigis_cff.py:26
MuonBaseNumber
Definition: MuonBaseNumber.h:21
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
DDRotationMatrix
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
Definition: DDRotationMatrix.h:8
RPCGeometryParsFromDD::RPCGeometryParsFromDD
RPCGeometryParsFromDD()
Definition: RPCGeometryParsFromDD.cc:27
DDValue
Definition: DDValue.h:22
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DDFilteredView::translation
const DDTranslation & translation() const
The absolute translation of the current node.
Definition: DDFilteredView.cc:26
cms::DDCompactView
Definition: DDCompactView.h:31
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
DDSolid::parameters
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:125
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDSpecificsMatchesValueFilter
Definition: DDFilter.h:70
DDFilteredView::rotation
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
Definition: DDFilteredView.cc:28
MuonGeometryNumbering
Definition: MuonGeometryNumbering.h:24
DDValue::doubles
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
Definition: DDValue.cc:111
DDFilteredView
Definition: DDFilteredView.h:20
RecoIdealGeometry::insert
bool insert(DetId id, const std::vector< double > &trans, const std::vector< double > &rot, const std::vector< double > &pars)
Definition: RecoIdealGeometry.h:33
DDLogicalPart::solid
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
Definition: DDLogicalPart.cc:120
RecoIdealGeometry
Definition: RecoIdealGeometry.h:28