Skip to content

Commit bc18fda

Browse files
authored
Merge pull request cms-sw#44819 from mmusich/mm_dev_cleanup_PixelBaryCentreAnalyzer
miscellaneaous improvements to `PixelBaryCentreAnalyzer`
2 parents 7a1f4df + bcdc402 commit bc18fda

File tree

1 file changed

+25
-29
lines changed

1 file changed

+25
-29
lines changed

Alignment/OfflineValidation/plugins/PixelBaryCentreAnalyzer.cc

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class PixelBaryCentreAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedReso
8181
void initBC();
8282
void initBS();
8383

84-
bool usePixelQuality_;
84+
const bool usePixelQuality_;
8585
int phase_;
8686

8787
// ----------member data ---------------------------
@@ -93,11 +93,11 @@ class PixelBaryCentreAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedReso
9393
// labels of beamspot tags
9494
std::vector<std::string> bsLabels_;
9595

96-
edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerGeometryToken_;
97-
edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> trackerTopologyToken_;
98-
edm::ESGetToken<SiPixelQuality, SiPixelQualityFromDbRcd> siPixelQualityToken_;
96+
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerGeometryToken_;
97+
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> trackerTopologyToken_;
98+
const edm::ESGetToken<SiPixelQuality, SiPixelQualityFromDbRcd> siPixelQualityToken_;
9999

100-
edm::ESGetToken<Alignments, GlobalPositionRcd> gprToken_;
100+
const edm::ESGetToken<Alignments, GlobalPositionRcd> gprToken_;
101101
std::map<std::string, edm::ESGetToken<Alignments, TrackerAlignmentRcd>> tkAlignTokens_;
102102
std::map<std::string, edm::ESGetToken<BeamSpotObjects, BeamSpotObjectsRcd>> bsTokens_;
103103

@@ -249,20 +249,20 @@ void PixelBaryCentreAnalyzer::analyze(const edm::Event& iEvent, const edm::Event
249249
const TrackerGeometry* tkGeo = &iSetup.getData(trackerGeometryToken_);
250250
const TrackerTopology* tkTopo = &iSetup.getData(trackerTopologyToken_);
251251

252-
if (tkGeo->isThere(GeomDetEnumerators::PixelBarrel) && tkGeo->isThere(GeomDetEnumerators::PixelEndcap))
252+
if (tkGeo->isThere(GeomDetEnumerators::PixelBarrel) && tkGeo->isThere(GeomDetEnumerators::PixelEndcap)) {
253253
phase_ = 0;
254-
else if (tkGeo->isThere(GeomDetEnumerators::P1PXB) && tkGeo->isThere(GeomDetEnumerators::P1PXEC))
254+
} else if (tkGeo->isThere(GeomDetEnumerators::P1PXB) && tkGeo->isThere(GeomDetEnumerators::P1PXEC)) {
255255
phase_ = 1;
256+
}
256257

257258
// pixel quality
258259
const SiPixelQuality* badPixelInfo = &iSetup.getData(siPixelQualityToken_);
259260

260261
// Tracker global position
261-
const Alignments* globalAlignments = &iSetup.getData(gprToken_);
262-
std::unique_ptr<const Alignments> globalPositions = std::make_unique<Alignments>(*globalAlignments);
263-
const AlignTransform& globalCoordinates = align::DetectorGlobalPosition(*globalPositions, DetId(DetId::Tracker));
264-
GlobalVector globalTkPosition(
265-
globalCoordinates.translation().x(), globalCoordinates.translation().y(), globalCoordinates.translation().z());
262+
const AlignTransform& glbCoord = align::DetectorGlobalPosition(iSetup.getData(gprToken_), DetId(DetId::Tracker));
263+
264+
// Convert AlignTransform::Translation to GlobalVector using the appropriate constructor
265+
GlobalVector globalTkPosition(glbCoord.translation().x(), glbCoord.translation().y(), glbCoord.translation().z());
266266

267267
// loop over bclabels
268268
for (const auto& label : bcLabels_) {
@@ -373,10 +373,8 @@ void PixelBaryCentreAnalyzer::analyze(const edm::Event& iEvent, const edm::Event
373373
GlobalVector BPIX_NonFlipped(0.0, 0.0, 0.0);
374374

375375
// loop over layers
376-
for (std::map<int, std::map<int, GlobalVector>>::iterator il = barycentre_bpix.begin();
377-
il != barycentre_bpix.end();
378-
++il) {
379-
int layer = il->first;
376+
for (const auto& il : barycentre_bpix) {
377+
int layer = il.first;
380378

381379
int nmodulesLayer = 0;
382380
int nmodulesLayer_Flipped = 0;
@@ -387,8 +385,8 @@ void PixelBaryCentreAnalyzer::analyze(const edm::Event& iEvent, const edm::Event
387385

388386
// loop over ladder
389387
std::map<int, GlobalVector> barycentreLayer = barycentre_bpix[layer];
390-
for (std::map<int, GlobalVector>::iterator it = barycentreLayer.begin(); it != barycentreLayer.end(); ++it) {
391-
int ladder = it->first;
388+
for (const auto& it : barycentreLayer) {
389+
int ladder = it.first;
392390
//BPIXLayerLadder_[layer][ladder] = (1.0/nmodules[layer][ladder])*barycentreLayer[ladder] + globalTkPosition;
393391

394392
nmodulesLayer += nmodules_bpix[layer][ladder];
@@ -496,27 +494,25 @@ void PixelBaryCentreAnalyzer::analyze(const edm::Event& iEvent, const edm::Event
496494
GlobalVector FPIX_plus(0.0, 0.0, 0.0);
497495
GlobalVector FPIX_minus(0.0, 0.0, 0.0);
498496
// loop over disks
499-
for (std::map<int, std::map<int, GlobalVector>>::iterator id = barycentre_fpix.begin();
500-
id != barycentre_fpix.end();
501-
++id) {
502-
int disk = id->first;
497+
498+
for (const auto& id : barycentre_fpix) {
499+
int disk = id.first;
503500

504501
int nmodulesDisk = 0;
505502
GlobalVector FPIXDisk(0.0, 0.0, 0.0);
506503

507-
std::map<int, GlobalVector> baryCentreDisk = id->second;
508-
for (std::map<int, GlobalVector>::iterator ir = baryCentreDisk.begin(); ir != baryCentreDisk.end();
509-
++ir) { // loop over rings
510-
int ring = ir->first;
504+
std::map<int, GlobalVector> baryCentreDisk = id.second;
505+
for (const auto& ir : baryCentreDisk) {
506+
int ring = ir.first;
511507
nmodulesDisk += nmodules_fpix[disk][ring];
512-
FPIXDisk += ir->second;
508+
FPIXDisk += ir.second;
513509
if (disk > 0) {
514510
nmodules_FPIX_plus += nmodules_fpix[disk][ring];
515-
FPIX_plus += ir->second;
511+
FPIX_plus += ir.second;
516512
}
517513
if (disk < 0) {
518514
nmodules_FPIX_minus += nmodules_fpix[disk][ring];
519-
FPIX_minus += ir->second;
515+
FPIX_minus += ir.second;
520516
}
521517

522518
} // loop over rings

0 commit comments

Comments
 (0)