63 #include "CLHEP/Vector/RotationInterfaces.h" 77 static std::vector<GeomDetEnumerators::SubDetector>
toSubDetectors(
const std::vector<std::string>& subs);
103 std::vector<GeomDetEnumerators::SubDetector>
subDets_;
116 skipSubDetectors_(toSubDetectors(iConfig.getUntrackedParameter<
std::
vector<
std::
string> >(
"skipSubDetectors"))),
117 alignToGlobalTag_(iConfig.getUntrackedParameter<
bool>(
"alignToGlobalTag")),
118 createReferenceRcd_(iConfig.getUntrackedParameter<
bool>(
"createReferenceRcd")),
134 std::sort(dets.begin(), dets.end(), [](
const auto&
a,
const auto&
b) {
135 return a->geographicalId().rawId() <
b->geographicalId().rawId();
138 for (
const auto& det : dets)
150 return "PixelBarrel";
152 return "PixelEndcap";
193 if (sub ==
"PixelBarrel")
195 else if (sub ==
"PixelEndcap")
197 else if (sub ==
"TIB")
199 else if (sub ==
"TOB")
201 else if (sub ==
"TID")
203 else if (sub ==
"TEC")
205 else if (sub ==
"CSC")
207 else if (sub ==
"DT")
209 else if (sub ==
"RPCBarrel")
211 else if (sub ==
"RPCEndcap")
213 else if (sub ==
"GEM")
215 else if (sub ==
"ME0")
217 else if (sub ==
"P2OTB")
219 else if (sub ==
"P2OTEC")
221 else if (sub ==
"P1PXB")
223 else if (sub ==
"P1PXEC")
225 else if (sub ==
"P2PXB")
227 else if (sub ==
"P2PXEC")
229 else if (sub ==
"invalidDet")
236 const std::vector<std::string>& subs) {
237 std::vector<GeomDetEnumerators::SubDetector>
result;
238 result.reserve(subs.size());
239 for (
const auto& sub : subs)
258 return std::unique_ptr<TrackerGeometry>{trackerBuilder.
build(geometricDet, ptp, tTopo)};
276 const auto& eulerAngles =
rotation.eulerAngles();
277 LogDebug(
"Alignment") <<
"============================================================\n" 278 <<
"subdetector: " << subDetector <<
"\n" 279 <<
"detId: " << detId <<
"\n" 280 <<
"------------------------------------------------------------\n" 281 <<
" x: " <<
pos.x() <<
"\n" 282 <<
" y: " <<
pos.y() <<
"\n" 283 <<
" z: " <<
pos.z() <<
"\n" 284 <<
" phi: " << eulerAngles.phi() <<
"\n" 285 <<
" theta: " << eulerAngles.theta() <<
"\n" 286 <<
" psi: " << eulerAngles.psi() <<
"\n" 287 <<
"============================================================\n";
297 LogDebug(
"Alignment") <<
"Aligning to global tag\n";
305 <<
"Size mismatch between alignments (size=" << alignments->
m_align.size()
306 <<
") and alignment errors (size=" << alignmentErrors->
m_alignError.size() <<
")";
308 std::vector<uint32_t> commonIDs;
309 auto itAlignErr = alignmentErrors->
m_alignError.cbegin();
310 for (
auto itAlign = alignments->
m_align.cbegin(); itAlign != alignments->
m_align.cend(); ++itAlign, ++itAlignErr) {
311 const auto id = itAlign->rawId();
314 if (
id != itAlignErr->rawId())
315 throw cms::Exception(
"GeometryMismatch") <<
"DetId mismatch between alignments (rawId=" <<
id 316 <<
") and alignment errors (rawId=" << itAlignErr->rawId() <<
")";
327 LogDebug(
"Alignment") <<
"============================================================\n" 336 <<
"============================================================\n";
339 commonIDs.push_back(
id);
340 LogDebug(
"Alignment") <<
"============================================================\n" 349 <<
"============================================================\n";
359 for (
const auto&
id : commonIDs) {
361 auto item = std::find_if(surfaceDeformations->
items().cbegin(),
362 surfaceDeformations->
items().cend(),
363 [&
id](
const auto&
i) {
return i.m_rawId ==
id; });
364 if (
item == surfaceDeformations->
items().cend())
370 std::vector<align::Scalar>
params(beginEndPair.first, beginEndPair.second);
380 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
383 edm::LogInfo(
"Alignment") <<
"Writing ideal tracker-alignment records.";
393 "Creates ideal TrackerAlignmentRcd and TrackerAlignmentErrorExtendedRcd " 394 "from the loaded tracker geometry. " 395 "PoolDBOutputService must be set up for these records.");
396 desc.addUntracked<
bool>(
"alignToGlobalTag",
false);
397 desc.addUntracked<std::vector<std::string> >(
"skipSubDetectors", std::vector<std::string>{});
398 desc.addUntracked<
bool>(
"createReferenceRcd",
false);
399 descriptions.
add(
"createIdealTkAlRecords",
desc);
std::unique_ptr< TrackerGeometry > retrieveGeometry(const edm::EventSetup &)
const TimeTypeSpecs timeTypeSpecs[]
std::vector< uint32_t > rawIDs_
void addAlignmentInfo(const GeomDet &)
static std::string toString(const GeomDetEnumerators::SubDetector &)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
const edm::ESGetToken< GeometricDet, IdealGeometryRecord > geomDetToken_
AlignmentErrorsExtended alignmentErrors_
AlignmentSurfaceDeformations alignmentSurfaceDeformations_
std::vector< GeomDetEnumerators::SubDetector > subDets_
void analyze(const edm::Event &, const edm::EventSetup &) override
void clear()
Clear vector without having to look into internals:
const bool createReferenceRcd_
CreateIdealTkAlRecords(const edm::ParameterSet &)
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
static std::vector< GeomDetEnumerators::SubDetector > toSubDetectors(const std::vector< std::string > &subs)
void alignToGT(const edm::EventSetup &)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< AlignTransform > m_align
const std::vector< GeomDetEnumerators::SubDetector > skipSubDetectors_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
const Surface::RotationType & rotation() const
The rotation defining the local R.F.
const edm::ESGetToken< Alignments, TrackerAlignmentRcd > aliToken_
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
~CreateIdealTkAlRecords() override
#define DEFINE_FWK_MODULE(type)
DetId geographicalId() const
The label of this GeomDet.
Log< level::Info, false > LogInfo
void clearAlignmentInfos()
static GeomDetEnumerators::SubDetector toSubDetector(const std::string &sub)
std::vector< AlignTransformErrorExtended > m_alignError
constexpr uint32_t rawId() const
get the raw id
const edm::ESGetToken< AlignmentErrorsExtended, TrackerAlignmentErrorExtendedRcd > aliErrorToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual SubDetector subDetector() const
Which subdetector.
const bool alignToGlobalTag_
const Surface::PositionType & position() const
The position (origin of the R.F.)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::ESGetToken< AlignmentSurfaceDeformations, TrackerSurfaceDeformationRcd > aliSurfaceToken_
const edm::ESGetToken< PTrackerParameters, PTrackerParametersRcd > ptpToken_
void clear()
Clear vector without having to look into internals: