CMS 3D CMS Logo

BtlDigiHitsValidation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Validation/MtdValidation
4 // Class: BtlDigiHitsValidation
5 //
14 #include <string>
15 
20 
23 
27 
32 
35 
37 
39 public:
41  ~BtlDigiHitsValidation() override;
42 
43  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
44 
45 private:
46  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
47 
48  void analyze(const edm::Event&, const edm::EventSetup&) override;
49 
50  // ------------ member data ------------
51 
53  const bool optionalPlots_;
54 
56 
59 
60  // --- histograms declaration
61 
63 
66 
68 
69  //local position monitoring
74 
80 
88 };
89 
90 // ------------ constructor and destructor --------------
92  : folder_(iConfig.getParameter<std::string>("folder")),
93  optionalPlots_(iConfig.getParameter<bool>("optionalPlots")) {
94  btlDigiHitsToken_ = consumes<BTLDigiCollection>(iConfig.getParameter<edm::InputTag>("inputTag"));
95  mtdgeoToken_ = esConsumes<MTDGeometry, MTDDigiGeometryRecord>();
96  mtdtopoToken_ = esConsumes<MTDTopology, MTDTopologyRcd>();
97 }
98 
100 
101 // ------------ method called for each event ------------
103  using namespace edm;
104 
105  auto geometryHandle = iSetup.getTransientHandle(mtdgeoToken_);
106  const MTDGeometry* geom = geometryHandle.product();
107 
108  auto topologyHandle = iSetup.getTransientHandle(mtdtopoToken_);
109  const MTDTopology* topology = topologyHandle.product();
110 
111  auto btlDigiHitsHandle = makeValid(iEvent.getHandle(btlDigiHitsToken_));
112 
113  // --- Loop over the BLT DIGI hits
114 
115  unsigned int n_digi_btl[2] = {0, 0};
116 
117  for (const auto& dataFrame : *btlDigiHitsHandle) {
118  BTLDetId detId = dataFrame.id();
119  DetId geoId = detId.geographicalId(MTDTopologyMode::crysLayoutFromTopoMode(topology->getMTDTopologyMode()));
120  const MTDGeomDet* thedet = geom->idToDet(geoId);
121  if (thedet == nullptr)
122  throw cms::Exception("BtlDigiHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " ("
123  << detId.rawId() << ") is invalid!" << std::dec << std::endl;
124  const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(thedet->topology());
125  const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology());
126 
127  Local3DPoint local_point(0., 0., 0.);
128  local_point = topo.pixelToModuleLocalPoint(local_point, detId.row(topo.nrows()), detId.column(topo.nrows()));
129  const auto& global_point = thedet->toGlobal(local_point);
130 
131  const auto& sample_L = dataFrame.sample(0);
132  const auto& sample_R = dataFrame.sample(1);
133 
134  uint32_t adc[2] = {sample_L.data(), sample_R.data()};
135  uint32_t tdc[2] = {sample_L.toa(), sample_R.toa()};
136 
137  for (int iside = 0; iside < 2; ++iside) {
138  if (adc[iside] == 0)
139  continue;
140 
141  meHitCharge_[iside]->Fill(adc[iside]);
142  meHitTime_[iside]->Fill(tdc[iside]);
143 
144  meOccupancy_[iside]->Fill(global_point.z(), global_point.phi());
145 
146  if (optionalPlots_) {
147  meLocalOccupancy_[iside]->Fill(local_point.x(), local_point.y());
148  meHitXlocal_[iside]->Fill(local_point.x());
149  meHitYlocal_[iside]->Fill(local_point.y());
150  meHitZlocal_[iside]->Fill(local_point.z());
151  }
152 
153  meHitX_[iside]->Fill(global_point.x());
154  meHitY_[iside]->Fill(global_point.y());
155  meHitZ_[iside]->Fill(global_point.z());
156  meHitPhi_[iside]->Fill(global_point.phi());
157  meHitEta_[iside]->Fill(global_point.eta());
158 
159  meHitTvsQ_[iside]->Fill(adc[iside], tdc[iside]);
160  meHitQvsPhi_[iside]->Fill(global_point.phi(), adc[iside]);
161  meHitQvsEta_[iside]->Fill(global_point.eta(), adc[iside]);
162  meHitQvsZ_[iside]->Fill(global_point.z(), adc[iside]);
163  meHitTvsPhi_[iside]->Fill(global_point.phi(), tdc[iside]);
164  meHitTvsEta_[iside]->Fill(global_point.eta(), tdc[iside]);
165  meHitTvsZ_[iside]->Fill(global_point.z(), tdc[iside]);
166 
167  n_digi_btl[iside]++;
168 
169  } // iside loop
170 
171  } // dataFrame loop
172 
173  if (n_digi_btl[0] > 0)
174  meNhits_[0]->Fill(log10(n_digi_btl[0]));
175  if (n_digi_btl[1] > 0)
176  meNhits_[1]->Fill(log10(n_digi_btl[1]));
177 }
178 
179 // ------------ method for histogram booking ------------
181  edm::Run const& run,
182  edm::EventSetup const& iSetup) {
183  ibook.setCurrentFolder(folder_);
184  // --- histograms booking
185 
186  meNhits_[0] = ibook.book1D("BtlNhitsL", "Number of BTL DIGI hits (L);log_{10}(N_{DIGI})", 100, 0., 5.25);
187  meNhits_[1] = ibook.book1D("BtlNhitsR", "Number of BTL DIGI hits (R);log_{10}(N_{DIGI})", 100, 0., 5.25);
188 
189  meHitCharge_[0] = ibook.book1D("BtlHitChargeL", "BTL DIGI hits charge (L);Q_{DIGI} [ADC counts]", 100, 0., 1024.);
190  meHitCharge_[1] = ibook.book1D("BtlHitChargeR", "BTL DIGI hits charge (R);Q_{DIGI} [ADC counts]", 100, 0., 1024.);
191  meHitTime_[0] = ibook.book1D("BtlHitTimeL", "BTL DIGI hits ToA (L);ToA_{DIGI} [TDC counts]", 100, 0., 1024.);
192  meHitTime_[1] = ibook.book1D("BtlHitTimeR", "BTL DIGI hits ToA (R);ToA_{DIGI} [TDC counts]", 100, 0., 1024.);
193  meOccupancy_[0] = ibook.book2D("BtlOccupancyL",
194  "BTL DIGI hits occupancy (L);Z_{DIGI} [cm]; #phi_{DIGI} [rad]",
195  65,
196  -260.,
197  260.,
198  126,
199  -3.15,
200  3.15);
201  meOccupancy_[1] = ibook.book2D("BtlOccupancyR",
202  "BTL DIGI hits occupancy (R);Z_{DIGI} [cm]; #phi_{DIGI} [rad]",
203  65,
204  -260.,
205  260.,
206  126,
207  -3.15,
208  3.15);
209  if (optionalPlots_) {
210  meLocalOccupancy_[0] = ibook.book2D("BtlLocalOccupancyL",
211  "BTL DIGI hits local occupancy (L);X_{DIGI} [cm]; Y_{DIGI} [cm]",
212  100,
213  -10.,
214  10,
215  60,
216  -3.,
217  3.);
218  meLocalOccupancy_[1] = ibook.book2D(
219  "BtlLocalOccupancyR", "BTL DIGI hits occupancy (R);X_{DIGI} [cm]; Y_{DIGI} [cm]", 100, -10., 10., 60, -3., 3.);
220  meHitXlocal_[0] = ibook.book1D("BtlHitXlocalL", "BTL DIGI local X (L);X_{DIGI}^{LOC} [cm]", 100, -10., 10.);
221  meHitXlocal_[1] = ibook.book1D("BtlHitXlocalR", "BTL DIGI local X (R);X_{DIGI}^{LOC} [cm]", 100, -10., 10.);
222  meHitYlocal_[0] = ibook.book1D("BtlHitYlocalL", "BTL DIGI local Y (L);Y_{DIGI}^{LOC} [cm]", 60, -3., 3.);
223  meHitYlocal_[1] = ibook.book1D("BtlHitYlocalR", "BTL DIGI local Y (R);Y_{DIGI}^{LOC} [cm]", 60, -3., 3.);
224  meHitZlocal_[0] = ibook.book1D("BtlHitZlocalL", "BTL DIGI local z (L);z_{DIGI}^{LOC} [cm]", 10, -1, 1);
225  meHitZlocal_[1] = ibook.book1D("BtlHitZlocalR", "BTL DIGI local z (R);z_{DIGI}^{LOC} [cm]", 10, -1, 1);
226  }
227 
228  meHitX_[0] = ibook.book1D("BtlHitXL", "BTL DIGI hits X (L);X_{DIGI} [cm]", 60, -120., 120.);
229  meHitX_[1] = ibook.book1D("BtlHitXR", "BTL DIGI hits X (R);X_{DIGI} [cm]", 60, -120., 120.);
230  meHitY_[0] = ibook.book1D("BtlHitYL", "BTL DIGI hits Y (L);Y_{DIGI} [cm]", 60, -120., 120.);
231  meHitY_[1] = ibook.book1D("BtlHitYR", "BTL DIGI hits Y (R);Y_{DIGI} [cm]", 60, -120., 120.);
232  meHitZ_[0] = ibook.book1D("BtlHitZL", "BTL DIGI hits Z (L);Z_{DIGI} [cm]", 100, -260., 260.);
233  meHitZ_[1] = ibook.book1D("BtlHitZR", "BTL DIGI hits Z (R);Z_{DIGI} [cm]", 100, -260., 260.);
234  meHitPhi_[0] = ibook.book1D("BtlHitPhiL", "BTL DIGI hits #phi (L);#phi_{DIGI} [rad]", 126, -3.15, 3.15);
235  meHitPhi_[1] = ibook.book1D("BtlHitPhiR", "BTL DIGI hits #phi (R);#phi_{DIGI} [rad]", 126, -3.15, 3.15);
236  meHitEta_[0] = ibook.book1D("BtlHitEtaL", "BTL DIGI hits #eta (L);#eta_{DIGI}", 100, -1.55, 1.55);
237  meHitEta_[1] = ibook.book1D("BtlHitEtaR", "BTL DIGI hits #eta (R);#eta_{DIGI}", 100, -1.55, 1.55);
238 
239  meHitTvsQ_[0] = ibook.bookProfile("BtlHitTvsQL",
240  "BTL DIGI ToA vs charge (L);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]",
241  50,
242  0.,
243  1024.,
244  0.,
245  1024.);
246  meHitTvsQ_[1] = ibook.bookProfile("BtlHitTvsQR",
247  "BTL DIGI ToA vs charge (R);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]",
248  50,
249  0.,
250  1024.,
251  0.,
252  1024.);
253  meHitQvsPhi_[0] = ibook.bookProfile("BtlHitQvsPhiL",
254  "BTL DIGI charge vs #phi (L);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]",
255  50,
256  -3.15,
257  3.15,
258  0.,
259  1024.);
260  meHitQvsPhi_[1] = ibook.bookProfile("BtlHitQvsPhiR",
261  "BTL DIGI charge vs #phi (R);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]",
262  50,
263  -3.15,
264  3.15,
265  0.,
266  1024.);
267  meHitQvsEta_[0] = ibook.bookProfile(
268  "BtlHitQvsEtaL", "BTL DIGI charge vs #eta (L);#eta_{DIGI};Q_{DIGI} [ADC counts]", 50, -1.55, 1.55, 0., 1024.);
269  meHitQvsEta_[1] = ibook.bookProfile(
270  "BtlHitQvsEtaR", "BTL DIGI charge vs #eta (R);#eta_{DIGI};Q_{DIGI} [ADC counts]", 50, -1.55, 1.55, 0., 1024.);
271  meHitQvsZ_[0] = ibook.bookProfile(
272  "BtlHitQvsZL", "BTL DIGI charge vs Z (L);Z_{DIGI} [cm];Q_{DIGI} [ADC counts]", 50, -260., 260., 0., 1024.);
273  meHitQvsZ_[1] = ibook.bookProfile(
274  "BtlHitQvsZR", "BTL DIGI charge vs Z (R);Z_{DIGI} [cm];Q_{DIGI} [ADC counts]", 50, -260., 260., 0., 1024.);
275  meHitTvsPhi_[0] = ibook.bookProfile(
276  "BtlHitTvsPhiL", "BTL DIGI ToA vs #phi (L);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", 50, -3.15, 3.15, 0., 1024.);
277  meHitTvsPhi_[1] = ibook.bookProfile(
278  "BtlHitTvsPhiR", "BTL DIGI ToA vs #phi (R);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", 50, -3.15, 3.15, 0., 1024.);
279  meHitTvsEta_[0] = ibook.bookProfile(
280  "BtlHitTvsEtaL", "BTL DIGI ToA vs #eta (L);#eta_{DIGI};ToA_{DIGI} [TDC counts]", 50, -1.55, 1.55, 0., 1024.);
281  meHitTvsEta_[1] = ibook.bookProfile(
282  "BtlHitTvsEtaR", "BTL DIGI ToA vs #eta (R);#eta_{DIGI};ToA_{DIGI} [TDC counts]", 50, -1.55, 1.55, 0., 1024.);
283  meHitTvsZ_[0] = ibook.bookProfile(
284  "BtlHitTvsZL", "BTL DIGI ToA vs Z (L);Z_{DIGI} [cm];ToA_{DIGI} [TDC counts]", 50, -260., 260., 0., 1024.);
285  meHitTvsZ_[1] = ibook.bookProfile(
286  "BtlHitTvsZR", "BTL DIGI ToA vs Z (R);Z_{DIGI} [cm];ToA_{DIGI} [TDC counts]", 50, -260., 260., 0., 1024.);
287 }
288 
289 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
292 
293  desc.add<std::string>("folder", "MTD/BTL/DigiHits");
294  desc.add<edm::InputTag>("inputTag", edm::InputTag("mix", "FTLBarrel"));
295  desc.add<bool>("optionalPlots", false);
296 
297  descriptions.add("btlDigiHitsDefaultValid", desc);
298 }
299 
int getMTDTopologyMode() const
Definition: MTDTopology.h:27
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MonitorElement * meHitYlocal_[2]
BtlDigiHitsValidation(const edm::ParameterSet &)
std::string folder_
MonitorElement * meHitZ_[2]
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
T z() const
Definition: PV3DBase.h:61
virtual const Topology & topology() const
Definition: GeomDet.cc:67
virtual const PixelTopology & specificTopology() const
MonitorElement * meHitQvsEta_[2]
MonitorElement * meHitTvsZ_[2]
MonitorElement * meHitZlocal_[2]
MonitorElement * meHitY_[2]
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
MonitorElement * meHitX_[2]
LocalPoint pixelToModuleLocalPoint(const LocalPoint &plp, int row, int col) const
edm::EDGetTokenT< BTLDigiCollection > btlDigiHitsToken_
MonitorElement * meLocalOccupancy_[2]
void Fill(long long x)
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
int iEvent
Definition: GenABIO.cc:224
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:399
MonitorElement * meHitTvsEta_[2]
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
int nrows() const override
edm::ESGetToken< MTDTopology, MTDTopologyRcd > mtdtopoToken_
MonitorElement * meNhits_[2]
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
MonitorElement * meOccupancy_[2]
Definition: DetId.h:17
edm::ESGetToken< MTDGeometry, MTDDigiGeometryRecord > mtdgeoToken_
MonitorElement * meHitTvsQ_[2]
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
void add(std::string const &label, ParameterSetDescription const &psetDescription)
MonitorElement * meHitQvsZ_[2]
MonitorElement * meHitEta_[2]
MonitorElement * meHitPhi_[2]
HLT enums.
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0...
Definition: BTLDetId.h:19
MonitorElement * meHitTime_[2]
MonitorElement * meHitTvsPhi_[2]
ESTransientHandle< T > getTransientHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:141
MonitorElement * meHitCharge_[2]
BTLDetId::CrysLayout crysLayoutFromTopoMode(const int &topoMode)
auto makeValid(const U &iOtherHandleType) noexcept(false)
Definition: ValidHandle.h:52
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
MonitorElement * meHitXlocal_[2]
Definition: Run.h:45
uint16_t *__restrict__ uint16_t const *__restrict__ adc
void analyze(const edm::Event &, const edm::EventSetup &) override
MonitorElement * meHitQvsPhi_[2]