CMS 3D CMS Logo

SiPixelBarycenter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiPixelPhase1Summary
4 // Class: SiPixelBarycenter
5 //
13 //
14 // Original Author: Danilo Meuser
15 // Created: 26th May 2021
16 //
17 //
21 
22 #include <string>
23 #include <iostream>
24 
25 using namespace std;
26 using namespace edm;
27 
29  : DQMEDHarvester(iConfig),
30  alignmentToken_(esConsumes<edm::Transition::EndRun>()),
31  gprToken_(esConsumes<edm::Transition::EndRun>()),
32  trackerTopologyToken_(esConsumes<edm::Transition::EndRun>()) {
33  LogInfo("PixelDQM") << "SiPixelBarycenter::SiPixelBarycenter: Got DQM BackEnd interface" << endl;
34 }
35 
37 
39 
41  DQMStore::IGetter& iGetter,
42  const edm::Run& iRun,
43  edm::EventSetup const& c) {
44  bookBarycenterHistograms(iBooker);
45 
46  const Alignments* alignments = &c.getData(alignmentToken_);
47  const Alignments* gpr = &c.getData(gprToken_);
48  const TrackerTopology* tTopo = &c.getData(trackerTopologyToken_);
49 
50  fillBarycenterHistograms(iBooker, iGetter, alignments->m_align, gpr->m_align, *tTopo);
51 }
52 //------------------------------------------------------------------
53 // Used to book the barycenter histograms
54 //------------------------------------------------------------------
56  iBooker.cd();
57 
58  iBooker.setCurrentFolder("PixelPhase1/Barycenter");
59  //Book one histogram for each subdetector
60  for (const std::string& subdetector : subdetectors_) {
62  iBooker.book1D("barycenters_" + subdetector,
63  "Position of the barycenter for " + subdetector + ";Coordinate;Position [mm]",
64  3,
65  0.5,
66  3.5);
67  barycenters_[subdetector]->setBinLabel(1, "x");
68  barycenters_[subdetector]->setBinLabel(2, "y");
69  barycenters_[subdetector]->setBinLabel(3, "z");
70  }
71 
72  //Reset the iBooker
73  iBooker.setCurrentFolder("PixelPhase1/");
74 }
75 
76 //------------------------------------------------------------------
77 // Fill the Barycenter histograms
78 //------------------------------------------------------------------
80  DQMStore::IGetter& iGetter,
81  const std::vector<AlignTransform>& input,
82  const std::vector<AlignTransform>& GPR,
83  const TrackerTopology& tTopo) {
84  const auto GPR_translation_pixel = GPR[0].translation();
85  const std::map<DQMBarycenter::coordinate, float> GPR_pixel = {{DQMBarycenter::t_x, GPR_translation_pixel.x()},
86  {DQMBarycenter::t_y, GPR_translation_pixel.y()},
87  {DQMBarycenter::t_z, GPR_translation_pixel.z()}};
88 
90  barycenters.computeBarycenters(input, tTopo, GPR_pixel);
91 
92  auto Xbarycenters = barycenters.getX();
93  auto Ybarycenters = barycenters.getY();
94  auto Zbarycenters = barycenters.getZ();
95 
96  //Fill histogram for each subdetector
97  for (std::size_t i = 0; i < subdetectors_.size(); ++i) {
98  barycenters_[subdetectors_[i]]->setBinContent(1, Xbarycenters[i]);
99  barycenters_[subdetectors_[i]]->setBinContent(2, Ybarycenters[i]);
100  barycenters_[subdetectors_[i]]->setBinContent(3, Zbarycenters[i]);
101 
102  // zero the errors for better comparison display
103  barycenters_[subdetectors_[i]]->setBinError(1, 0.);
104  barycenters_[subdetectors_[i]]->setBinError(2, 0.);
105  barycenters_[subdetectors_[i]]->setBinError(3, 0.);
106  }
107 }
108 
109 //define this as a plug-in
const edm::ESGetToken< Alignments, GlobalPositionRcd > gprToken_
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
TString subdetector
void fillBarycenterHistograms(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, const std::vector< AlignTransform > &input, const std::vector< AlignTransform > &GPR, const TrackerTopology &tTopo)
const std::array< double, 9 > getY()
std::vector< AlignTransform > m_align
Definition: Alignments.h:19
void dqmEndRun(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, edm::Run const &iRun, edm::EventSetup const &c) override
static std::string const input
Definition: EdmProvDump.cc:50
const std::array< std::string, 9 > subdetectors_
void dqmEndJob(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter) override
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopologyToken_
SiPixelBarycenter(const edm::ParameterSet &conf)
Transition
Definition: Transition.h:12
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Log< level::Info, false > LogInfo
void computeBarycenters(const std::vector< AlignTransform > &input, const TrackerTopology &tTopo, const std::map< DQMBarycenter::coordinate, float > &GPR)
std::map< std::string, MonitorElement * > barycenters_
const edm::ESGetToken< Alignments, TrackerAlignmentRcd > alignmentToken_
HLT enums.
const std::array< double, 9 > getZ()
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
const std::array< double, 9 > getX()
Definition: Run.h:45
void bookBarycenterHistograms(DQMStore::IBooker &iBooker)
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup) override