94 std::map<std::string, edm::ESGetToken<Alignments, TrackerAlignmentRcd>>
tkAlignTokens_;
95 std::map<std::string, edm::ESGetToken<BeamSpotObjects, BeamSpotObjectsRcd>>
bsTokens_;
124 : usePixelQuality_(iConfig.getUntrackedParameter<
bool>(
"usePixelQuality")),
141 usesResource(
"TFileService");
154 double dummy_float = 999999.0;
161 double dummy_float = 999999.0;
174 for (
unsigned int i = 0;
i < 4;
i++) {
181 for (
unsigned int i = 0;
i < 3;
i++) {
189 bool prepareTkAlign =
false;
190 bool prepareBS =
false;
195 prepareTkAlign =
true;
199 if (!prepareTkAlign && !prepareBS)
205 if (prepareTkAlign) {
222 std::unique_ptr<const Alignments> globalPositions = std::make_unique<Alignments>(*globalAlignments);
234 std::vector<AlignTransform> tkAlignments = alignments->
m_align;
240 float nmodules_BPIX(0.);
243 float nmodules_FPIX(0.);
246 std::map<int, std::map<int, float>> nmodules_bpix;
247 std::map<int, std::map<int, GlobalVector>> barycentre_bpix;
250 std::map<int, std::map<int, float>> nmodules_fpix;
251 std::map<int, std::map<int, GlobalVector>> barycentre_fpix;
254 for (
const auto& ali : tkAlignments) {
262 GlobalVector ali_translation(ali.translation().x(), ali.translation().y(), ali.translation().z());
268 barycentre_BPIX += ali_translation;
269 barycentre_PIX += ali_translation;
281 barycentre_FPIX += ali_translation;
282 barycentre_PIX += ali_translation;
284 int disk = tkTopo->
pxfDisk(detId);
296 nmodules_fpix[disk][
ring] += 1;
297 barycentre_fpix[disk][
ring] += ali_translation;
304 float nmodules_PIX = nmodules_BPIX + nmodules_FPIX;
305 barycentre_PIX *= (1.0 / nmodules_PIX);
306 barycentre_PIX += globalTkPosition;
310 barycentre_BPIX *= (1.0 / nmodules_BPIX);
311 barycentre_BPIX += globalTkPosition;
314 barycentre_FPIX *= (1.0 / nmodules_FPIX);
315 barycentre_FPIX += globalTkPosition;
328 int nmodules_BPIX_Flipped = 0;
329 int nmodules_BPIX_NonFlipped = 0;
334 for (
std::map<
int, std::map<int, GlobalVector>>::iterator il = barycentre_bpix.begin();
335 il != barycentre_bpix.end();
337 int layer = il->first;
339 int nmodulesLayer = 0;
340 int nmodulesLayer_Flipped = 0;
341 int nmodulesLayer_NonFlipped = 0;
347 std::map<int, GlobalVector> barycentreLayer = barycentre_bpix[
layer];
348 for (std::map<int, GlobalVector>::iterator it = barycentreLayer.begin(); it != barycentreLayer.end(); ++it) {
353 BPIXLayer += barycentreLayer[
ladder];
362 nmodulesLayer_Flipped += nmodules_bpix[
layer][
ladder];
363 BPIXLayer_Flipped += barycentreLayer[
ladder];
365 nmodulesLayer_NonFlipped += nmodules_bpix[
layer][
ladder];
366 BPIXLayer_NonFlipped += barycentreLayer[
ladder];
371 nmodulesLayer_Flipped += nmodules_bpix[
layer][
ladder];
372 BPIXLayer_Flipped += barycentreLayer[
ladder];
374 nmodulesLayer_NonFlipped += nmodules_bpix[
layer][
ladder];
375 BPIXLayer_NonFlipped += barycentreLayer[
ladder];
388 nmodulesLayer_Flipped += nmodules_bpix[
layer][
ladder];
389 BPIXLayer_Flipped += barycentreLayer[
ladder];
391 nmodulesLayer_NonFlipped += nmodules_bpix[
layer][
ladder];
392 BPIXLayer_NonFlipped += barycentreLayer[
ladder];
397 nmodulesLayer_Flipped += nmodules_bpix[
layer][
ladder];
398 BPIXLayer_Flipped += barycentreLayer[
ladder];
400 nmodulesLayer_NonFlipped += nmodules_bpix[
layer][
ladder];
401 BPIXLayer_NonFlipped += barycentreLayer[
ladder];
410 BPIX_Flipped += BPIXLayer_Flipped;
411 BPIX_NonFlipped += BPIXLayer_NonFlipped;
412 nmodules_BPIX_Flipped += nmodulesLayer_Flipped;
413 nmodules_BPIX_NonFlipped += nmodulesLayer_NonFlipped;
416 BPIXLayer *= (1.0 / nmodulesLayer);
417 BPIXLayer += globalTkPosition;
418 BPIXLayer_Flipped *= (1.0 / nmodulesLayer_Flipped);
419 BPIXLayer_Flipped += globalTkPosition;
420 BPIXLayer_NonFlipped *= (1.0 / nmodulesLayer_NonFlipped);
421 BPIXLayer_NonFlipped += globalTkPosition;
425 GlobalPoint(BPIXLayer_Flipped.
x(), BPIXLayer_Flipped.
y(), BPIXLayer_Flipped.
z());
427 GlobalPoint(BPIXLayer_NonFlipped.
x(), BPIXLayer_NonFlipped.
y(), BPIXLayer_NonFlipped.
z());
430 BPIXLayer_Flipped.
y() - BPIXLayer_NonFlipped.
y(),
431 BPIXLayer_Flipped.
z() - BPIXLayer_NonFlipped.
z());
435 BPIX_Flipped *= (1.0 / nmodules_BPIX_Flipped);
436 BPIX_Flipped += globalTkPosition;
438 BPIX_NonFlipped *= (1.0 / nmodules_BPIX_NonFlipped);
439 BPIX_NonFlipped += globalTkPosition;
442 BPIX_Flipped.
y() - BPIX_NonFlipped.
y(),
443 BPIX_Flipped.
z() - BPIX_NonFlipped.
z());
446 int nmodules_FPIX_plus = 0;
447 int nmodules_FPIX_minus = 0;
451 for (
std::map<
int, std::map<int, GlobalVector>>::iterator
id = barycentre_fpix.begin();
452 id != barycentre_fpix.end();
454 int disk =
id->first;
456 int nmodulesDisk = 0;
459 std::map<int, GlobalVector> baryCentreDisk =
id->second;
460 for (std::map<int, GlobalVector>::iterator ir = baryCentreDisk.begin(); ir != baryCentreDisk.end();
462 int ring = ir->first;
463 nmodulesDisk += nmodules_fpix[disk][
ring];
464 FPIXDisk += ir->second;
466 nmodules_FPIX_plus += nmodules_fpix[disk][
ring];
467 FPIX_plus += ir->second;
470 nmodules_FPIX_minus += nmodules_fpix[disk][
ring];
471 FPIX_minus += ir->second;
476 FPIXDisk *= (1.0 / nmodulesDisk);
477 FPIXDisk += globalTkPosition;
485 FPIX_plus *= (1.0 / nmodules_FPIX_plus);
486 FPIX_plus += globalTkPosition;
488 FPIX_minus *= (1.0 / nmodules_FPIX_minus);
489 FPIX_minus += globalTkPosition;
522 treeName =
"BeamSpot_";
537 treeName =
"PixelBarycentre_";
556 for (
unsigned int i = 0;
i < 4;
i++) {
557 TString structure =
"BPIXLYR";
568 for (
unsigned int i = 0;
i < 3;
i++) {
569 TString structure =
"FPIXDisk+";
574 structure =
"FPIXDisk-";