103 std::map<std::string, edm::ESGetToken<Alignments, TrackerAlignmentRcd>>
tkAlignTokens_;
104 std::map<std::string, edm::ESGetToken<BeamSpotObjects, BeamSpotObjectsRcd>>
bsTokens_;
147 : usePixelQuality_(iConfig.getUntrackedParameter<
bool>(
"usePixelQuality")),
164 usesResource(
"TFileService");
172 double dummy_float = 999999.0;
180 double dummy_float = 999999.0;
231 bool prepareTkAlign =
false;
232 bool prepareBS =
false;
237 prepareTkAlign =
true;
241 if (!prepareTkAlign && !prepareBS)
247 if (prepareTkAlign) {
276 std::vector<AlignTransform> tkAlignments =
alignments.m_align;
282 float nmodules_BPIX(0.);
285 float nmodules_FPIX(0.);
288 std::map<int, std::map<int, float>> nmodules_bpix;
289 std::map<int, std::map<int, GlobalVector>> barycentre_bpix;
292 std::map<int, std::map<int, float>> nmodules_fpix;
293 std::map<int, std::map<int, GlobalVector>> barycentre_fpix;
296 for (
const auto& ali : tkAlignments) {
304 GlobalVector ali_translation(ali.translation().x(), ali.translation().y(), ali.translation().z());
310 barycentre_BPIX += ali_translation;
311 barycentre_PIX += ali_translation;
323 barycentre_FPIX += ali_translation;
324 barycentre_PIX += ali_translation;
338 nmodules_fpix[disk][
ring] += 1;
339 barycentre_fpix[disk][
ring] += ali_translation;
346 float nmodules_PIX = nmodules_BPIX + nmodules_FPIX;
347 barycentre_PIX *= (1.0 / nmodules_PIX);
348 barycentre_PIX += globalTkPosition;
353 barycentre_BPIX *= (1.0 / nmodules_BPIX);
354 barycentre_BPIX += globalTkPosition;
358 barycentre_FPIX *= (1.0 / nmodules_FPIX);
359 barycentre_FPIX += globalTkPosition;
372 int nmodules_BPIX_Flipped = 0;
373 int nmodules_BPIX_NonFlipped = 0;
378 for (
const auto& il : barycentre_bpix) {
379 int layer = il.first;
381 int nmodulesLayer = 0;
382 int nmodulesLayer_Flipped = 0;
383 int nmodulesLayer_NonFlipped = 0;
389 std::map<int, GlobalVector> barycentreLayer = barycentre_bpix[
layer];
390 for (
const auto&
it : barycentreLayer) {
395 BPIXLayer += barycentreLayer[
ladder];
404 nmodulesLayer_NonFlipped += nmodules_bpix[
layer][
ladder];
405 BPIXLayer_NonFlipped += barycentreLayer[
ladder];
407 nmodulesLayer_Flipped += nmodules_bpix[
layer][
ladder];
408 BPIXLayer_Flipped += barycentreLayer[
ladder];
413 nmodulesLayer_Flipped += nmodules_bpix[
layer][
ladder];
414 BPIXLayer_Flipped += barycentreLayer[
ladder];
416 nmodulesLayer_NonFlipped += nmodules_bpix[
layer][
ladder];
417 BPIXLayer_NonFlipped += barycentreLayer[
ladder];
430 nmodulesLayer_Flipped += nmodules_bpix[
layer][
ladder];
431 BPIXLayer_Flipped += barycentreLayer[
ladder];
433 nmodulesLayer_NonFlipped += nmodules_bpix[
layer][
ladder];
434 BPIXLayer_NonFlipped += barycentreLayer[
ladder];
439 nmodulesLayer_Flipped += nmodules_bpix[
layer][
ladder];
440 BPIXLayer_Flipped += barycentreLayer[
ladder];
442 nmodulesLayer_NonFlipped += nmodules_bpix[
layer][
ladder];
443 BPIXLayer_NonFlipped += barycentreLayer[
ladder];
452 BPIX_Flipped += BPIXLayer_Flipped;
453 BPIX_NonFlipped += BPIXLayer_NonFlipped;
454 nmodules_BPIX_Flipped += nmodulesLayer_Flipped;
455 nmodules_BPIX_NonFlipped += nmodulesLayer_NonFlipped;
458 BPIXLayer *= (1.0 / nmodulesLayer);
459 BPIXLayer += globalTkPosition;
460 BPIXLayer_Flipped *= (1.0 / nmodulesLayer_Flipped);
461 BPIXLayer_Flipped += globalTkPosition;
462 BPIXLayer_NonFlipped *= (1.0 / nmodulesLayer_NonFlipped);
463 BPIXLayer_NonFlipped += globalTkPosition;
468 GlobalPoint(BPIXLayer_Flipped.
x(), BPIXLayer_Flipped.
y(), BPIXLayer_Flipped.
z());
471 GlobalPoint(BPIXLayer_NonFlipped.
x(), BPIXLayer_NonFlipped.
y(), BPIXLayer_NonFlipped.
z());
474 BPIXLayer_Flipped.
y() - BPIXLayer_NonFlipped.
y(),
475 BPIXLayer_Flipped.
z() - BPIXLayer_NonFlipped.
z());
480 BPIX_Flipped *= (1.0 / nmodules_BPIX_Flipped);
481 BPIX_Flipped += globalTkPosition;
484 BPIX_NonFlipped *= (1.0 / nmodules_BPIX_NonFlipped);
485 BPIX_NonFlipped += globalTkPosition;
489 BPIX_Flipped.
y() - BPIX_NonFlipped.
y(),
490 BPIX_Flipped.
z() - BPIX_NonFlipped.
z());
494 int nmodules_FPIX_plus = 0;
495 int nmodules_FPIX_minus = 0;
500 for (
const auto&
id : barycentre_fpix) {
503 int nmodulesDisk = 0;
506 std::map<int, GlobalVector> baryCentreDisk =
id.second;
507 for (
const auto& ir : baryCentreDisk) {
509 nmodulesDisk += nmodules_fpix[disk][
ring];
510 FPIXDisk += ir.second;
512 nmodules_FPIX_plus += nmodules_fpix[disk][
ring];
513 FPIX_plus += ir.second;
516 nmodules_FPIX_minus += nmodules_fpix[disk][
ring];
517 FPIX_minus += ir.second;
522 FPIXDisk *= (1.0 / nmodulesDisk);
523 FPIXDisk += globalTkPosition;
535 FPIX_plus *= (1.0 / nmodules_FPIX_plus);
536 FPIX_plus += globalTkPosition;
539 FPIX_minus *= (1.0 / nmodules_FPIX_minus);
540 FPIX_minus += globalTkPosition;
610 TString structure =
"BPIXLYR";
623 TString structure =
"FPIXDisk_plus";
628 structure =
"FPIXDisk_minus";
648 desc.setComment(
"Validates alignment payloads by providing the position of the pixel barycenter positions");
649 desc.addUntracked<
bool>(
"usePixelQuality",
false);
650 desc.addUntracked<std::vector<std::string>>(
"tkAlignLabels", {});
651 desc.addUntracked<std::vector<std::string>>(
"beamSpotLabels", {});
SimplePoint(const GlobalPoint &p)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
GlobalPoint BPIXLayer_Flipped_[nPixelLayers]
SimplePoint vFPIXDisks_minus_[nPixelDiscs]
unsigned int pxbLayer(const DetId &id) const
void analyze(const edm::Event &, const edm::EventSetup &) override
double z() const
get Z beam position
static const unsigned int nPixelDiscs
bcLabels_
Load and configure analyzer.
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
int ringName() const
ring Id
edm::ESWatcher< BeamSpotObjectsRcd > watcherBS_
SimplePoint vBPIXLayer_NonFlipped_[nPixelLayers]
PixelBaryCentreAnalyzer(const edm::ParameterSet &)
SimplePoint vBPIXLayer_DiffFlippedNonFlipped_[nPixelLayers]
SimplePoint vBPIX_DiffFlippedNonFlipped_
GlobalPoint BPIXLayer_DiffFlippedNonFlipped_[nPixelLayers]
unsigned int pxfModule(const DetId &id) const
GlobalPoint FPIXDisks_plus_[nPixelDiscs]
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryToken_
int quadrant(const DetId &detid, const TrackerTopology *tTopo_, bool phase_)
Global3DPoint GlobalPoint
bool IsModuleBad(const uint32_t &detid) const
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopologyToken_
unsigned int pxbLadder(const DetId &id) const
SimplePoint vBPIX_Flipped_
SimplePoint vBPIXLayer_Flipped_[nPixelLayers]
edm::Service< TFileService > tFileService
GlobalPoint BPIX_NonFlipped_
GlobalPoint BPIXLayer_[nPixelLayers]
GlobalPoint FPIXDisks_minus_[nPixelDiscs]
edm::ESWatcher< TrackerAlignmentRcd > watcherTkAlign_
bool isThere(GeomDetEnumerators::SubDetector subdet) const
HalfCylinder halfCylinder() const
unsigned int pxfDisk(const DetId &id) const
double x() const
get X beam position
const bool usePixelQuality_
#define DEFINE_FWK_MODULE(type)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
SimplePoint vFPIXDisks_plus_[nPixelDiscs]
const edm::ESGetToken< Alignments, GlobalPositionRcd > gprToken_
~PixelBaryCentreAnalyzer() override=default
std::vector< std::string > bsLabels_
unsigned int pxfPanel(const DetId &id) const
double y() const
get Y beam position
std::vector< std::string > bcLabels_
SimplePoint vBPIXLayer_[nPixelLayers]
GlobalPoint BPIX_Flipped_
std::map< std::string, TTree * > bsTrees_
bool check(const edm::EventSetup &iSetup)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static const unsigned int nPixelLayers
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
T * make(const Args &...args) const
make new ROOT object
SimplePoint vBPIX_NonFlipped_
const edm::ESGetToken< SiPixelQuality, SiPixelQualityFromDbRcd > siPixelQualityToken_
std::map< std::string, edm::ESGetToken< Alignments, TrackerAlignmentRcd > > tkAlignTokens_
std::map< std::string, TTree * > bcTrees_
GlobalPoint BPIXLayer_NonFlipped_[nPixelLayers]
std::map< std::string, edm::ESGetToken< BeamSpotObjects, BeamSpotObjectsRcd > > bsTokens_
GlobalPoint BPIX_DiffFlippedNonFlipped_