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  // do anything here that needs to be done at desctruction time
38  // (e.g. close files, deallocate resources etc.)
39  LogInfo("PixelDQM") << "SiPixelBarycenter::~SiPixelBarycenter: Destructor" << endl;
40 }
41 
43 
45 
47  DQMStore::IGetter& iGetter,
48  const edm::Run& iRun,
49  edm::EventSetup const& c) {
50  bookBarycenterHistograms(iBooker);
51 
52  const Alignments* alignments = &c.getData(alignmentToken_);
53  const Alignments* gpr = &c.getData(gprToken_);
54  const TrackerTopology* tTopo = &c.getData(trackerTopologyToken_);
55 
56  fillBarycenterHistograms(iBooker, iGetter, alignments->m_align, gpr->m_align, *tTopo);
57 }
58 //------------------------------------------------------------------
59 // Used to book the barycenter histograms
60 //------------------------------------------------------------------
62  iBooker.cd();
63 
64  iBooker.setCurrentFolder("PixelPhase1/Barycenter");
65  //Book one histogram for each subdetector
67  {"BPIX", "FPIX_zm", "FPIX_zp", "BPIX_xp", "BPIX_xm", "FPIX_zp_xp", "FPIX_zm_xp", "FPIX_zp_xm", "FPIX_zm_xm"}) {
69  iBooker.book1D("barycenters_" + subdetector,
70  "Position of the barycenter for " + subdetector + ";Coordinate;Position [mm]",
71  3,
72  0.5,
73  3.5);
74  barycenters_[subdetector]->setBinLabel(1, "x");
75  barycenters_[subdetector]->setBinLabel(2, "y");
76  barycenters_[subdetector]->setBinLabel(3, "z");
77  }
78 
79  //Reset the iBooker
80  iBooker.setCurrentFolder("PixelPhase1/");
81 }
82 
83 //------------------------------------------------------------------
84 // Fill the Barycenter histograms
85 //------------------------------------------------------------------
87  DQMStore::IGetter& iGetter,
88  const std::vector<AlignTransform>& input,
89  const std::vector<AlignTransform>& GPR,
90  const TrackerTopology& tTopo) {
91  const auto GPR_translation_pixel = GPR[0].translation();
92  const std::map<DQMBarycenter::coordinate, float> GPR_pixel = {{DQMBarycenter::t_x, GPR_translation_pixel.x()},
93  {DQMBarycenter::t_y, GPR_translation_pixel.y()},
94  {DQMBarycenter::t_z, GPR_translation_pixel.z()}};
95 
97  barycenters.computeBarycenters(input, tTopo, GPR_pixel);
98 
99  auto Xbarycenters = barycenters.getX();
100  auto Ybarycenters = barycenters.getY();
101  auto Zbarycenters = barycenters.getZ();
102 
103  //Fill histogram for each subdetector
104  std::vector<std::string> subdetectors = {
105  "BPIX", "FPIX_zm", "FPIX_zp", "BPIX_xp", "BPIX_xm", "FPIX_zp_xp", "FPIX_zm_xp", "FPIX_zp_xm", "FPIX_zm_xm"};
106  for (std::size_t i = 0; i < subdetectors.size(); ++i) {
107  barycenters_[subdetectors[i]]->setBinContent(1, Xbarycenters[i]);
108  barycenters_[subdetectors[i]]->setBinContent(2, Ybarycenters[i]);
109  barycenters_[subdetectors[i]]->setBinContent(3, Zbarycenters[i]);
110  }
111 }
112 
113 //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:32
TString subdetector
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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:47
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
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
~SiPixelBarycenter() override
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