24 #include <unordered_map>
77 using ScalerMap = std::unordered_map<unsigned int, std::unordered_map<int, double> >;
101 pullBadModulesToIdeal_{iConfig.getUntrackedParameter<
bool>(
"pullBadModulesToIdeal")},
102 outlierPullToIdealCut_{iConfig.getUntrackedParameter<
double>(
"outlierPullToIdealCut")} {}
125 auto tracker = std::unique_ptr<TrackerGeometry>{trackerBuilder.
build(geometricDet, ptitp, ptp, topology)};
128 std::sort(dets.begin(), dets.end(), [](
const auto&
a,
const auto&
b) {
129 return a->geographicalId().rawId() <
b->geographicalId().rawId();
135 if (dets.size() != alignments->m_align.size()) {
136 throw cms::Exception(
"GeometryMismatch") <<
"Size mismatch between alignments (size=" << alignments->m_align.size()
137 <<
") and ideal geometry (size=" << dets.size() <<
")";
142 auto outlierCounter{0};
143 auto ideal = dets.cbegin();
144 const auto& ideal_end = dets.cend();
145 auto misaligned = alignments->
m_align.cbegin();
146 for (; ideal != ideal_end; ++ideal, ++misaligned) {
147 if ((*ideal)->geographicalId().rawId() != misaligned->rawId()) {
148 throw cms::Exception(
"GeometryMismatch") <<
"Order differs between Dets in alignments ideal geometry.";
152 const auto&
subDetId = (*ideal)->geographicalId().subdetId();
153 auto side = topology->
side((*ideal)->geographicalId());
160 side = topology->
tibSide((*ideal)->geographicalId());
163 side = topology->
tobSide((*ideal)->geographicalId());
176 auto x_diff = misaligned->translation().x() - (*ideal)->position().x();
177 auto y_diff = misaligned->translation().y() - (*ideal)->position().y();
178 auto z_diff = misaligned->translation().z() - (*ideal)->position().z();
180 auto xx_diff = misaligned->rotation().xx() - (*ideal)->rotation().xx();
181 auto xy_diff = misaligned->rotation().xy() - (*ideal)->rotation().xy();
182 auto xz_diff = misaligned->rotation().xz() - (*ideal)->rotation().xz();
183 auto yx_diff = misaligned->rotation().yx() - (*ideal)->rotation().yx();
184 auto yy_diff = misaligned->rotation().yy() - (*ideal)->rotation().yy();
185 auto yz_diff = misaligned->rotation().yz() - (*ideal)->rotation().yz();
186 auto zx_diff = misaligned->rotation().zx() - (*ideal)->rotation().zx();
187 auto zy_diff = misaligned->rotation().zy() - (*ideal)->rotation().zy();
188 auto zz_diff = misaligned->rotation().zz() - (*ideal)->rotation().zz();
194 <<
": delta x: " << x_diff <<
", delta y: " << y_diff <<
", delta z: " << z_diff
195 <<
", delta xx: " << xx_diff <<
", delta xy: " << xy_diff
196 <<
", delta xz: " << xz_diff <<
", delta yx: " << yx_diff
197 <<
", delta yx: " << yy_diff <<
", delta yy: " << yz_diff
198 <<
", delta zz: " << zx_diff <<
", delta zy: " << zy_diff
199 <<
", delta zz: " << zz_diff <<
"\n";
208 CLHEP::HepRep3x3{(*ideal)->rotation().xx() +
scaleFactor * xx_diff,
216 (*ideal)->rotation().zz() +
scaleFactor * zz_diff}};
218 const AlignTransform rescaledTransform{rescaledTranslation, rescaledRotation, misaligned->
rawId()};
219 rescaledAlignments.m_align.emplace_back(rescaledTransform);
225 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
227 edm::LogInfo(
"Alignment") <<
"Writing rescaled tracker-alignment record.";
229 poolDb->
writeOne(&rescaledAlignments,
since,
"TrackerAlignmentRcd");
241 for (
const auto&
pset : psets) {
243 const auto&
factor =
pset.getUntrackedParameter<
double>(
"factor");
245 std::vector<int> sides;
246 if (
name.find(
'-') != std::string::npos)
248 if (
name.find(
'+') != std::string::npos)
255 if (
name.find(
"Tracker") != std::string::npos) {
257 for (
const auto& side : sides)
260 if (sides.size() == 1) {
265 }
else if (
name.find(
"PXB") != std::string::npos) {
269 }
else if (
name.find(
"PXF") != std::string::npos) {
270 for (
const auto& side : sides)
272 }
else if (
name.find(
"TIB") != std::string::npos) {
273 for (
const auto& side : sides)
275 }
else if (
name.find(
"TOB") != std::string::npos) {
276 for (
const auto& side : sides)
278 }
else if (
name.find(
"TID") != std::string::npos) {
279 for (
const auto& side : sides)
281 }
else if (
name.find(
"TEC") != std::string::npos) {
282 for (
const auto& side : sides)
285 throw cms::Exception(
"BadConfig") <<
"@SUB=MCMisalignmentScaler::decodeSubDetectors\n"
286 <<
"Unknown tracker subdetector: " <<
name
287 <<
"\nSupported options: Tracker, PXB, PXF, TIB, TOB, TID, TEC "
288 <<
"(possibly decorated with '+' or '-')";
292 std::stringstream logInfo;
293 logInfo <<
"MC misalignment scale factors:\n";
294 for (
const auto& subdet : subDetMap) {
295 logInfo <<
" Subdet " << subdet.first <<
"\n";
296 for (
const auto& side : subdet.second) {
297 logInfo <<
" side " << side.first <<
": " << side.second <<
"\n";
310 "Creates rescaled MC misalignment scenario. "
311 "PoolDBOutputService must be set up for 'TrackerAlignmentRcd'.");
314 "ParameterSet specifying the tracker part to be scaled "
315 "by a given factor.");
318 desc.addVPSet(
"scalers", descScaler, std::vector<edm::ParameterSet>(1));
319 desc.addUntracked<
bool>(
"pullBadModulesToIdeal",
false);
320 desc.addUntracked<
double>(
"outlierPullToIdealCut", -1.0);
321 descriptions.
add(
"mcMisalignmentScaler",
desc);