24 #include <unordered_map>
74 using ScalerMap = std::unordered_map<unsigned int, std::unordered_map<int, double> >;
97 pullBadModulesToIdeal_{iConfig.getUntrackedParameter<
bool>(
"pullBadModulesToIdeal")},
98 outlierPullToIdealCut_{iConfig.getUntrackedParameter<
double>(
"outlierPullToIdealCut")} {}
120 auto tracker = std::unique_ptr<TrackerGeometry>{trackerBuilder.
build(geometricDet, ptp, topology)};
123 std::sort(dets.begin(), dets.end(), [](
const auto&
a,
const auto&
b) {
124 return a->geographicalId().rawId() <
b->geographicalId().rawId();
130 if (dets.size() != alignments->m_align.size()) {
131 throw cms::Exception(
"GeometryMismatch") <<
"Size mismatch between alignments (size=" << alignments->m_align.size()
132 <<
") and ideal geometry (size=" << dets.size() <<
")";
137 auto outlierCounter{0};
138 auto ideal = dets.cbegin();
139 const auto& ideal_end = dets.cend();
140 auto misaligned = alignments->
m_align.cbegin();
141 for (; ideal != ideal_end; ++ideal, ++misaligned) {
142 if ((*ideal)->geographicalId().rawId() != misaligned->rawId()) {
143 throw cms::Exception(
"GeometryMismatch") <<
"Order differs between Dets in alignments ideal geometry.";
147 const auto&
subDetId = (*ideal)->geographicalId().subdetId();
148 auto side = topology->
side((*ideal)->geographicalId());
155 side = topology->
tibSide((*ideal)->geographicalId());
158 side = topology->
tobSide((*ideal)->geographicalId());
171 auto x_diff = misaligned->translation().x() - (*ideal)->position().x();
172 auto y_diff = misaligned->translation().y() - (*ideal)->position().y();
173 auto z_diff = misaligned->translation().z() - (*ideal)->position().z();
175 auto xx_diff = misaligned->rotation().xx() - (*ideal)->rotation().xx();
176 auto xy_diff = misaligned->rotation().xy() - (*ideal)->rotation().xy();
177 auto xz_diff = misaligned->rotation().xz() - (*ideal)->rotation().xz();
178 auto yx_diff = misaligned->rotation().yx() - (*ideal)->rotation().yx();
179 auto yy_diff = misaligned->rotation().yy() - (*ideal)->rotation().yy();
180 auto yz_diff = misaligned->rotation().yz() - (*ideal)->rotation().yz();
181 auto zx_diff = misaligned->rotation().zx() - (*ideal)->rotation().zx();
182 auto zy_diff = misaligned->rotation().zy() - (*ideal)->rotation().zy();
183 auto zz_diff = misaligned->rotation().zz() - (*ideal)->rotation().zz();
189 <<
": delta x: " << x_diff <<
", delta y: " << y_diff <<
", delta z: " << z_diff
190 <<
", delta xx: " << xx_diff <<
", delta xy: " << xy_diff
191 <<
", delta xz: " << xz_diff <<
", delta yx: " << yx_diff
192 <<
", delta yx: " << yy_diff <<
", delta yy: " << yz_diff
193 <<
", delta zz: " << zx_diff <<
", delta zy: " << zy_diff
194 <<
", delta zz: " << zz_diff <<
"\n";
203 CLHEP::HepRep3x3{(*ideal)->rotation().xx() +
scaleFactor * xx_diff,
211 (*ideal)->rotation().zz() +
scaleFactor * zz_diff}};
213 const AlignTransform rescaledTransform{rescaledTranslation, rescaledRotation, misaligned->
rawId()};
214 rescaledAlignments.m_align.emplace_back(rescaledTransform);
220 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
222 edm::LogInfo(
"Alignment") <<
"Writing rescaled tracker-alignment record.";
224 poolDb->
writeOne(&rescaledAlignments,
since,
"TrackerAlignmentRcd");
236 for (
const auto&
pset : psets) {
238 const auto&
factor =
pset.getUntrackedParameter<
double>(
"factor");
240 std::vector<int> sides;
241 if (
name.find(
'-') != std::string::npos)
243 if (
name.find(
'+') != std::string::npos)
250 if (
name.find(
"Tracker") != std::string::npos) {
252 for (
const auto& side : sides)
255 if (sides.size() == 1) {
260 }
else if (
name.find(
"PXB") != std::string::npos) {
264 }
else if (
name.find(
"PXF") != std::string::npos) {
265 for (
const auto& side : sides)
267 }
else if (
name.find(
"TIB") != std::string::npos) {
268 for (
const auto& side : sides)
270 }
else if (
name.find(
"TOB") != std::string::npos) {
271 for (
const auto& side : sides)
273 }
else if (
name.find(
"TID") != std::string::npos) {
274 for (
const auto& side : sides)
276 }
else if (
name.find(
"TEC") != std::string::npos) {
277 for (
const auto& side : sides)
280 throw cms::Exception(
"BadConfig") <<
"@SUB=MCMisalignmentScaler::decodeSubDetectors\n"
281 <<
"Unknown tracker subdetector: " <<
name
282 <<
"\nSupported options: Tracker, PXB, PXF, TIB, TOB, TID, TEC "
283 <<
"(possibly decorated with '+' or '-')";
287 std::stringstream logInfo;
288 logInfo <<
"MC misalignment scale factors:\n";
289 for (
const auto& subdet : subDetMap) {
290 logInfo <<
" Subdet " << subdet.first <<
"\n";
291 for (
const auto& side : subdet.second) {
292 logInfo <<
" side " << side.first <<
": " << side.second <<
"\n";
305 "Creates rescaled MC misalignment scenario. "
306 "PoolDBOutputService must be set up for 'TrackerAlignmentRcd'.");
309 "ParameterSet specifying the tracker part to be scaled "
310 "by a given factor.");
313 desc.addVPSet(
"scalers", descScaler, std::vector<edm::ParameterSet>(1));
314 desc.addUntracked<
bool>(
"pullBadModulesToIdeal",
false);
315 desc.addUntracked<
double>(
"outlierPullToIdealCut", -1.0);
316 descriptions.
add(
"mcMisalignmentScaler",
desc);