-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migration to DD4Hep for RPC db Loader #32102
Merged
cmsbuild
merged 6 commits into
cms-sw:master
from
slomeo:MigrationToDD4hepForRPCdbLoader
Dec 9, 2020
+155
−25
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d48b46e
Migration to DD4Hep of the RPCGeometryParsFromDD and RPCRecoIdealDBLo…
slomeo 99a6992
added "Log" printouts
slomeo 277c279
deleted #include "DataFormats/Math/interface/CMSUnits.h" and added my…
slomeo 5b455b6
code check performed
slomeo 7d4826e
restored DDD units
slomeo 831685d
cosmetics
slomeo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,34 @@ | ||
/** Implementation of the RPC Geometry Builder from DDD | ||
/* Implementation of the RPCGeometryParsFromDD Class | ||
* Build the RPCGeometry from the DDD and DD4Hep description | ||
* | ||
* DD4hep part added to the original old file (DD version) made by M. Maggi (INFN Bari) | ||
* Author: Sergio Lo Meo ([email protected]) | ||
* Created: Mon, 09 Nov 2020 | ||
* | ||
* \author Port of: MuDDDRPCBuilder (ORCA) | ||
* \author M. Maggi - INFN Bari | ||
*/ | ||
#include "Geometry/RPCGeometryBuilder/src/RPCGeometryParsFromDD.h" | ||
#include "DataFormats/MuonDetId/interface/RPCDetId.h" | ||
|
||
#include <CondFormats/GeometryObjects/interface/RecoIdealGeometry.h> | ||
#include <DetectorDescription/Core/interface/DDFilter.h> | ||
#include <DetectorDescription/Core/interface/DDFilteredView.h> | ||
#include <DetectorDescription/Core/interface/DDSolid.h> | ||
|
||
#include "Geometry/MuonNumbering/interface/MuonGeometryNumbering.h" | ||
#include "Geometry/MuonNumbering/interface/MuonBaseNumber.h" | ||
#include "Geometry/MuonNumbering/interface/RPCNumberingScheme.h" | ||
|
||
#include "DataFormats/GeometryVector/interface/Basic3DVector.h" | ||
|
||
#include "CLHEP/Units/GlobalSystemOfUnits.h" | ||
|
||
#include <iostream> | ||
#include <algorithm> | ||
#include <DetectorDescription/DDCMS/interface/DDFilteredView.h> | ||
#include <DetectorDescription/DDCMS/interface/DDCompactView.h> | ||
#include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" | ||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
|
||
RPCGeometryParsFromDD::RPCGeometryParsFromDD() {} | ||
|
||
RPCGeometryParsFromDD::~RPCGeometryParsFromDD() {} | ||
|
||
// DD | ||
void RPCGeometryParsFromDD::build(const DDCompactView* cview, | ||
const MuonGeometryConstants& muonConstants, | ||
RecoIdealGeometry& rgeo) { | ||
|
@@ -39,6 +42,20 @@ void RPCGeometryParsFromDD::build(const DDCompactView* cview, | |
this->buildGeometry(fview, muonConstants, rgeo); | ||
} | ||
|
||
// DD4Hep | ||
|
||
void RPCGeometryParsFromDD::build(const cms::DDCompactView* cview, | ||
const MuonGeometryConstants& muonConstants, | ||
RecoIdealGeometry& rgeo) { | ||
const std::string attribute = "ReadOutName"; | ||
const std::string value = "MuonRPCHits"; | ||
const cms::DDFilter filter(attribute, value); | ||
cms::DDFilteredView fview(*cview, filter); | ||
this->buildGeometry(fview, muonConstants, rgeo); | ||
} | ||
|
||
// DD | ||
|
||
void RPCGeometryParsFromDD::buildGeometry(DDFilteredView& fview, | ||
const MuonGeometryConstants& muonConstants, | ||
RecoIdealGeometry& rgeo) { | ||
|
@@ -50,6 +67,7 @@ void RPCGeometryParsFromDD::buildGeometry(DDFilteredView& fview, | |
// Get the The Rpc det Id | ||
RPCNumberingScheme rpcnum(muonConstants); | ||
const int detid = rpcnum.baseNumberToUnitNumber(mbn); | ||
|
||
RPCDetId rpcid(detid); | ||
|
||
DDValue numbOfStrips("nStrips"); | ||
|
@@ -67,6 +85,11 @@ void RPCGeometryParsFromDD::buildGeometry(DDFilteredView& fview, | |
const std::vector<double> dpar = fview.logicalPart().solid().parameters(); | ||
|
||
const std::string name = fview.logicalPart().name().name(); | ||
|
||
edm::LogVerbatim("RPCGeometryParsFromDD") | ||
<< " (1) " | ||
<< "detid: " << detid << " name: " << name << " number of Strips: " << nStrips; | ||
|
||
const std::vector<std::string> strpars = {name}; | ||
const DDTranslation& tran = fview.translation(); | ||
|
||
|
@@ -78,15 +101,84 @@ void RPCGeometryParsFromDD::buildGeometry(DDFilteredView& fview, | |
const double width = dpar[0]; | ||
const double length = dpar[1]; | ||
const double thickness = dpar[2]; | ||
edm::LogVerbatim("RPCGeometryParsFromDD") | ||
<< " (2) dpar.size() == 3, width: " << width << " length: " << length << " thickness: " << thickness; | ||
pars = {width, length, thickness, numbOfStrips.doubles()[0]}; | ||
} else { | ||
pars = { | ||
dpar[4] /*b/2*/, dpar[8] /*B/2*/, dpar[0] /*h/2*/, 0.4, numbOfStrips.doubles()[0] /*h/2*/ | ||
}; | ||
const double dpar4 = dpar[4]; | ||
const double dpar8 = dpar[8]; | ||
const double dpar0 = dpar[0]; | ||
pars = {dpar4, dpar8, dpar0, 0.4, numbOfStrips.doubles()[0]}; | ||
edm::LogVerbatim("RPCGeometryParsFromDD") | ||
<< " (3), else, dpar[4]: " << dpar4 << " dpar[8]: " << dpar8 << " dpar[0]: " << dpar0; | ||
} | ||
|
||
const std::vector<double> vtra = {tran.x(), tran.y(), tran.z()}; | ||
|
||
edm::LogVerbatim("RPCGeometryParsFromDD") | ||
<< " (4), tran.x() " << tran.x() << " tran.y(): " << tran.y() << " tran.z(): " << tran.z(); | ||
|
||
const std::vector<double> vrot = {x.X(), x.Y(), x.Z(), y.X(), y.Y(), y.Z(), z.X(), z.Y(), z.Z()}; | ||
edm::LogVerbatim("RPCGeometryParsFromDD") | ||
<< " (5), x.X(), x.Y(), x.Z(), y.X(), y.Y(), y.Z(), z.X(), z.Y(), z.Z() " << x.X() << ", " << x.Y() << ", " | ||
<< x.Z() << ", " << y.X() << ", " << y.Y() << ", " << y.Z() << ", " << z.X() << ", " << z.Y() << ", " << z.Z(); | ||
rgeo.insert(rpcid.rawId(), vtra, vrot, pars, strpars); | ||
} | ||
} | ||
|
||
// DD4Hep | ||
|
||
void RPCGeometryParsFromDD::buildGeometry(cms::DDFilteredView& fview, | ||
const MuonGeometryConstants& muonConstants, | ||
RecoIdealGeometry& rgeo) { | ||
while (fview.firstChild()) { | ||
MuonGeometryNumbering mdddnum(muonConstants); | ||
RPCNumberingScheme rpcnum(muonConstants); | ||
int rawidCh = rpcnum.baseNumberToUnitNumber(mdddnum.geoHistoryToBaseNumber(fview.history())); | ||
RPCDetId rpcid = RPCDetId(rawidCh); | ||
|
||
auto nStrips = fview.get<double>("nStrips"); | ||
|
||
std::vector<double> dpar = fview.parameters(); | ||
|
||
std::string_view name = fview.name(); | ||
|
||
edm::LogVerbatim("RPCGeometryParsFromDD") | ||
<< " (1), detid: " << rawidCh << " name: " << std::string(name) << " number of Strips: " << nStrips; | ||
|
||
const std::vector<std::string> strpars = {std::string(name)}; | ||
|
||
std::vector<double> tran(3); | ||
tran[0] = static_cast<double>(fview.translation().X()) / dd4hep::mm; | ||
tran[1] = static_cast<double>(fview.translation().Y()) / dd4hep::mm; | ||
tran[2] = static_cast<double>(fview.translation().Z()) / dd4hep::mm; | ||
|
||
DDRotationMatrix rota; | ||
fview.rot(rota); | ||
DD3Vector x, y, z; | ||
rota.GetComponents(x, y, z); | ||
const std::vector<double> rot = {x.X(), x.Y(), x.Z(), y.X(), y.Y(), y.Z(), z.X(), z.Y(), z.Z()}; | ||
|
||
if (dd4hep::isA<dd4hep::Box>(fview.solid())) { | ||
const std::vector<double> pars = { | ||
dpar[0] / dd4hep::mm, dpar[1] / dd4hep::mm, dpar[2] / dd4hep::mm, double(nStrips)}; | ||
edm::LogVerbatim("RPCGeometryParsFromDD") | ||
<< " (2), dd4hep::Box, width: " << dpar[0] / dd4hep::mm << " length: " << dpar[1] / dd4hep::mm | ||
<< " thickness: " << dpar[2] / dd4hep::mm; | ||
rgeo.insert(rpcid, tran, rot, pars, strpars); | ||
} else { | ||
const double ti = 0.4; | ||
const std::vector<double> pars = { | ||
dpar[0] / dd4hep::mm, dpar[1] / dd4hep::mm, dpar[3] / dd4hep::mm, ti, double(nStrips)}; | ||
edm::LogVerbatim("RPCGeometryParsFromDD") << " (3), else, dpar[0] (i.e. dpar[4] for DD): " << dpar[0] / dd4hep::mm | ||
<< " dpar[1] (i.e. dpar[8] for DD): " << dpar[1] / dd4hep::mm | ||
<< " dpar[3] (i.e. dpar[0] for DD): " << dpar[3] / dd4hep::mm; | ||
rgeo.insert(rpcid, tran, rot, pars, strpars); | ||
} | ||
edm::LogVerbatim("RPCGeometryParsFromDD") | ||
<< " (4), tran.x(): " << tran[0] << " tran.y(): " << tran[1] << " tran.z(): " << tran[2]; | ||
edm::LogVerbatim("RPCGeometryParsFromDD") | ||
<< " (5), x.X(), x.Y(), x.Z(), y.X(), y.Y(), y.Z(), z.X(), z.Y(), z.Z(): " << x.X() << ", " << x.Y() << ", " | ||
<< x.Z() << ", " << y.X() << ", " << y.Y() << ", " << y.Z() << ", " << z.X() << ", " << z.Y() << ", " << z.Z(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
#ifndef RPCGeometry_RPCGeometryParsFromDD_H | ||
#define RPCGeometry_RPCGeometryParsFromDD_H | ||
|
||
/** \class RPCGeometryParsFromDD | ||
* Build the RPCGeometry ftom the DDD description | ||
* | ||
* \author Port of: MuDDDRPCBuilder, MuonRPCGeometryBuilder (ORCA) | ||
* \author M. Maggi - INFN Bari | ||
/* \class RPCGeometryParsFromDD | ||
* Build the RPCGeometry from the DDD and DD4Hep description | ||
* | ||
* DD4hep part added to the original old file (DD version) made by M. Maggi (INFN Bari) | ||
* Author: Sergio Lo Meo ([email protected]) | ||
* Created: Mon, 09 Nov 2020 | ||
* | ||
*/ | ||
|
||
|
@@ -15,6 +16,10 @@ | |
|
||
class DDCompactView; | ||
class DDFilteredView; | ||
namespace cms { // DD4Hep | ||
class DDFilteredView; | ||
class DDCompactView; | ||
} // namespace cms | ||
class RPCDetId; | ||
class RPCRoll; | ||
class MuonGeometryConstants; | ||
|
@@ -25,10 +30,16 @@ class RPCGeometryParsFromDD { | |
|
||
~RPCGeometryParsFromDD(); | ||
|
||
// DD | ||
void build(const DDCompactView* cview, const MuonGeometryConstants& muonConstants, RecoIdealGeometry& rgeo); | ||
// DD4Hep | ||
void build(const cms::DDCompactView* cview, const MuonGeometryConstants& muonConstants, RecoIdealGeometry& rgeo); | ||
|
||
private: | ||
// DD | ||
void buildGeometry(DDFilteredView& fview, const MuonGeometryConstants& muonConstants, RecoIdealGeometry& rgeo); | ||
// DD4Hep | ||
void buildGeometry(cms::DDFilteredView& fview, const MuonGeometryConstants& muonConstants, RecoIdealGeometry& rgeo); | ||
}; | ||
|
||
#endif |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is right to include this DD4hep geometry. This file needs to work with both old DD and DD4hep.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cvuosalo : I added the same line for PR #32001 (for CSC). Without it an error appears:
----- Begin Fatal Exception 12-Nov-2020 09:04:49 CET-----------------------
An exception of category 'NoProxyException' occurred while
[0] Processing global begin Run run: 1
[1] Calling method for module RPCRecoIdealDBLoader/'RPCGeometryWriter'
Exception Message:
No data of type "DDCompactView" with label "" in record "IdealGeometryRecord"
Please add an ESSource or ESProducer to your job which can deliver this data.
----- End Fatal Exception -------------------------------------------------
%MSG-i DDCompactViewImpl: 12-Nov-2020 09:04:49 CET EndJob
DDD transient representation has been destructed.
%MSG