24 #include <unordered_map>
68 using ScalerMap = std::unordered_map<unsigned int, std::unordered_map<int, double> >;
85 pullBadModulesToIdeal_{iConfig.getUntrackedParameter<
bool>(
"pullBadModulesToIdeal")},
86 outlierPullToIdealCut_{iConfig.getUntrackedParameter<
double>(
"outlierPullToIdealCut")} {}
113 auto tracker = std::unique_ptr<TrackerGeometry>{trackerBuilder.
build(&(*geometricDet), *ptp,
topology)};
116 std::sort(dets.begin(), dets.end(), [](
const auto&
a,
const auto&
b) {
117 return a->geographicalId().rawId() <
b->geographicalId().rawId();
124 if (dets.size() != alignments->m_align.size()) {
125 throw cms::Exception(
"GeometryMismatch") <<
"Size mismatch between alignments (size=" << alignments->m_align.size()
126 <<
") and ideal geometry (size=" << dets.size() <<
")";
131 auto outlierCounter{0};
132 auto ideal = dets.cbegin();
133 const auto& ideal_end = dets.cend();
134 auto misaligned = alignments->
m_align.cbegin();
135 for (; ideal != ideal_end; ++ideal, ++misaligned) {
136 if ((*ideal)->geographicalId().rawId() != misaligned->rawId()) {
137 throw cms::Exception(
"GeometryMismatch") <<
"Order differs between Dets in alignments ideal geometry.";
141 const auto&
subDetId = (*ideal)->geographicalId().subdetId();
142 auto side =
topology->side((*ideal)->geographicalId());
149 side =
topology->tibSide((*ideal)->geographicalId());
152 side =
topology->tobSide((*ideal)->geographicalId());
165 auto x_diff = misaligned->translation().x() - (*ideal)->position().x();
166 auto y_diff = misaligned->translation().y() - (*ideal)->position().y();
167 auto z_diff = misaligned->translation().z() - (*ideal)->position().z();
169 auto xx_diff = misaligned->rotation().xx() - (*ideal)->rotation().xx();
170 auto xy_diff = misaligned->rotation().xy() - (*ideal)->rotation().xy();
171 auto xz_diff = misaligned->rotation().xz() - (*ideal)->rotation().xz();
172 auto yx_diff = misaligned->rotation().yx() - (*ideal)->rotation().yx();
173 auto yy_diff = misaligned->rotation().yy() - (*ideal)->rotation().yy();
174 auto yz_diff = misaligned->rotation().yz() - (*ideal)->rotation().yz();
175 auto zx_diff = misaligned->rotation().zx() - (*ideal)->rotation().zx();
176 auto zy_diff = misaligned->rotation().zy() - (*ideal)->rotation().zy();
177 auto zz_diff = misaligned->rotation().zz() - (*ideal)->rotation().zz();
183 <<
": delta x: " << x_diff <<
", delta y: " << y_diff <<
", delta z: " << z_diff
184 <<
", delta xx: " << xx_diff <<
", delta xy: " << xy_diff
185 <<
", delta xz: " << xz_diff <<
", delta yx: " << yx_diff
186 <<
", delta yx: " << yy_diff <<
", delta yy: " << yz_diff
187 <<
", delta zz: " << zx_diff <<
", delta zy: " << zy_diff
188 <<
", delta zz: " << zz_diff <<
"\n";
197 CLHEP::HepRep3x3{(*ideal)->rotation().xx() +
scaleFactor * xx_diff,
205 (*ideal)->rotation().zz() +
scaleFactor * zz_diff}};
207 const AlignTransform rescaledTransform{rescaledTranslation, rescaledRotation, misaligned->
rawId()};
208 rescaledAlignments.m_align.emplace_back(rescaledTransform);
214 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
216 edm::LogInfo(
"Alignment") <<
"Writing rescaled tracker-alignment record.";
218 poolDb->
writeOne(&rescaledAlignments,
since,
"TrackerAlignmentRcd");
230 for (
const auto&
pset : psets) {
232 const auto&
factor =
pset.getUntrackedParameter<
double>(
"factor");
234 std::vector<int> sides;
235 if (
name.find(
'-') != std::string::npos)
237 if (
name.find(
'+') != std::string::npos)
244 if (
name.find(
"Tracker") != std::string::npos) {
246 for (
const auto& side : sides)
249 if (sides.size() == 1) {
254 }
else if (
name.find(
"PXB") != std::string::npos) {
258 }
else if (
name.find(
"PXF") != std::string::npos) {
259 for (
const auto& side : sides)
261 }
else if (
name.find(
"TIB") != std::string::npos) {
262 for (
const auto& side : sides)
264 }
else if (
name.find(
"TOB") != std::string::npos) {
265 for (
const auto& side : sides)
267 }
else if (
name.find(
"TID") != std::string::npos) {
268 for (
const auto& side : sides)
270 }
else if (
name.find(
"TEC") != std::string::npos) {
271 for (
const auto& side : sides)
274 throw cms::Exception(
"BadConfig") <<
"@SUB=MCMisalignmentScaler::decodeSubDetectors\n"
275 <<
"Unknown tracker subdetector: " <<
name
276 <<
"\nSupported options: Tracker, PXB, PXF, TIB, TOB, TID, TEC "
277 <<
"(possibly decorated with '+' or '-')";
281 std::stringstream logInfo;
282 logInfo <<
"MC misalignment scale factors:\n";
283 for (
const auto& subdet : subDetMap) {
284 logInfo <<
" Subdet " << subdet.first <<
"\n";
285 for (
const auto& side : subdet.second) {
286 logInfo <<
" side " << side.first <<
": " << side.second <<
"\n";
299 "Creates rescaled MC misalignment scenario. "
300 "PoolDBOutputService must be set up for 'TrackerAlignmentRcd'.");
303 "ParameterSet specifying the tracker part to be scaled "
304 "by a given factor.");
307 desc.addVPSet(
"scalers", descScaler, std::vector<edm::ParameterSet>(1));
308 desc.addUntracked<
bool>(
"pullBadModulesToIdeal",
false);
309 desc.addUntracked<
double>(
"outlierPullToIdealCut", -1.0);
310 descriptions.
add(
"mcMisalignmentScaler",
desc);