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 public:
39  ~BtlDigiHitsValidation() override;
40 
41  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
42 
43 private:
44  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
45 
46  void analyze(const edm::Event&, const edm::EventSetup&) override;
47 
48  // ------------ member data ------------
49 
51 
53 
54  // --- histograms declaration
55 
57 
60 
62 
68 
76 };
77 
78 // ------------ constructor and destructor --------------
80  : folder_(iConfig.getParameter<std::string>("folder")) {
81  btlDigiHitsToken_ = consumes<BTLDigiCollection>(iConfig.getParameter<edm::InputTag>("inputTag"));
82 }
83 
85 
86 // ------------ method called for each event ------------
88  using namespace edm;
89 
90  edm::ESHandle<MTDGeometry> geometryHandle;
91  iSetup.get<MTDDigiGeometryRecord>().get(geometryHandle);
92  const MTDGeometry* geom = geometryHandle.product();
93 
94  edm::ESHandle<MTDTopology> topologyHandle;
95  iSetup.get<MTDTopologyRcd>().get(topologyHandle);
96  const MTDTopology* topology = topologyHandle.product();
97 
98  auto btlDigiHitsHandle = makeValid(iEvent.getHandle(btlDigiHitsToken_));
99 
100  // --- Loop over the BLT DIGI hits
101 
102  unsigned int n_digi_btl[2] = {0, 0};
103 
104  for (const auto& dataFrame : *btlDigiHitsHandle) {
105  BTLDetId detId = dataFrame.id();
106  DetId geoId = detId.geographicalId(static_cast<BTLDetId::CrysLayout>(topology->getMTDTopologyMode()));
107  const MTDGeomDet* thedet = geom->idToDet(geoId);
108  if (thedet == nullptr)
109  throw cms::Exception("BtlDigiHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " ("
110  << detId.rawId() << ") is invalid!" << std::dec << std::endl;
111  const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(thedet->topology());
112  const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology());
113 
114  Local3DPoint local_point(0., 0., 0.);
115  local_point = topo.pixelToModuleLocalPoint(local_point, detId.row(topo.nrows()), detId.column(topo.nrows()));
116  const auto& global_point = thedet->toGlobal(local_point);
117 
118  const auto& sample_L = dataFrame.sample(0);
119  const auto& sample_R = dataFrame.sample(1);
120 
121  uint32_t adc[2] = {sample_L.data(), sample_R.data()};
122  uint32_t tdc[2] = {sample_L.toa(), sample_R.toa()};
123 
124  for (int iside = 0; iside < 2; ++iside) {
125  if (adc[iside] == 0)
126  continue;
127 
128  meHitCharge_[iside]->Fill(adc[iside]);
129  meHitTime_[iside]->Fill(tdc[iside]);
130 
131  meOccupancy_[iside]->Fill(global_point.z(), global_point.phi());
132 
133  meHitX_[iside]->Fill(global_point.x());
134  meHitY_[iside]->Fill(global_point.y());
135  meHitZ_[iside]->Fill(global_point.z());
136  meHitPhi_[iside]->Fill(global_point.phi());
137  meHitEta_[iside]->Fill(global_point.eta());
138 
139  meHitTvsQ_[iside]->Fill(adc[iside], tdc[iside]);
140  meHitQvsPhi_[iside]->Fill(global_point.phi(), adc[iside]);
141  meHitQvsEta_[iside]->Fill(global_point.eta(), adc[iside]);
142  meHitQvsZ_[iside]->Fill(global_point.z(), adc[iside]);
143  meHitTvsPhi_[iside]->Fill(global_point.phi(), tdc[iside]);
144  meHitTvsEta_[iside]->Fill(global_point.eta(), tdc[iside]);
145  meHitTvsZ_[iside]->Fill(global_point.z(), tdc[iside]);
146 
147  n_digi_btl[iside]++;
148 
149  } // iside loop
150 
151  } // dataFrame loop
152 
153  if (n_digi_btl[0] > 0)
154  meNhits_[0]->Fill(log10(n_digi_btl[0]));
155  if (n_digi_btl[1] > 0)
156  meNhits_[1]->Fill(log10(n_digi_btl[1]));
157 }
158 
159 // ------------ method for histogram booking ------------
161  edm::Run const& run,
162  edm::EventSetup const& iSetup) {
163  ibook.setCurrentFolder(folder_);
164 
165  // --- histograms booking
166 
167  meNhits_[0] = ibook.book1D("BtlNhitsL", "Number of BTL DIGI hits (L);log_{10}(N_{DIGI})", 100, 0., 5.25);
168  meNhits_[1] = ibook.book1D("BtlNhitsR", "Number of BTL DIGI hits (R);log_{10}(N_{DIGI})", 100, 0., 5.25);
169 
170  meHitCharge_[0] = ibook.book1D("BtlHitChargeL", "BTL DIGI hits charge (L);Q_{DIGI} [ADC counts]", 100, 0., 1024.);
171  meHitCharge_[1] = ibook.book1D("BtlHitChargeR", "BTL DIGI hits charge (R);Q_{DIGI} [ADC counts]", 100, 0., 1024.);
172  meHitTime_[0] = ibook.book1D("BtlHitTimeL", "BTL DIGI hits ToA (L);ToA_{DIGI} [TDC counts]", 100, 0., 1024.);
173  meHitTime_[1] = ibook.book1D("BtlHitTimeR", "BTL DIGI hits ToA (R);ToA_{DIGI} [TDC counts]", 100, 0., 1024.);
174 
175  meOccupancy_[0] = ibook.book2D("BtlOccupancyL",
176  "BTL DIGI hits occupancy (L);Z_{DIGI} [cm]; #phi_{DIGI} [rad]",
177  65,
178  -260.,
179  260.,
180  126,
181  -3.15,
182  3.15);
183  meOccupancy_[1] = ibook.book2D("BtlOccupancyR",
184  "BTL DIGI hits occupancy (R);Z_{DIGI} [cm]; #phi_{DIGI} [rad]",
185  65,
186  -260.,
187  260.,
188  126,
189  -3.15,
190  3.15);
191 
192  meHitX_[0] = ibook.book1D("BtlHitXL", "BTL DIGI hits X (L);X_{DIGI} [cm]", 60, -120., 120.);
193  meHitX_[1] = ibook.book1D("BtlHitXR", "BTL DIGI hits X (R);X_{DIGI} [cm]", 60, -120., 120.);
194  meHitY_[0] = ibook.book1D("BtlHitYL", "BTL DIGI hits Y (L);Y_{DIGI} [cm]", 60, -120., 120.);
195  meHitY_[1] = ibook.book1D("BtlHitYR", "BTL DIGI hits Y (R);Y_{DIGI} [cm]", 60, -120., 120.);
196  meHitZ_[0] = ibook.book1D("BtlHitZL", "BTL DIGI hits Z (L);Z_{DIGI} [cm]", 100, -260., 260.);
197  meHitZ_[1] = ibook.book1D("BtlHitZR", "BTL DIGI hits Z (R);Z_{DIGI} [cm]", 100, -260., 260.);
198  meHitPhi_[0] = ibook.book1D("BtlHitPhiL", "BTL DIGI hits #phi (L);#phi_{DIGI} [rad]", 126, -3.15, 3.15);
199  meHitPhi_[1] = ibook.book1D("BtlHitPhiR", "BTL DIGI hits #phi (R);#phi_{DIGI} [rad]", 126, -3.15, 3.15);
200  meHitEta_[0] = ibook.book1D("BtlHitEtaL", "BTL DIGI hits #eta (L);#eta_{DIGI}", 100, -1.55, 1.55);
201  meHitEta_[1] = ibook.book1D("BtlHitEtaR", "BTL DIGI hits #eta (R);#eta_{DIGI}", 100, -1.55, 1.55);
202 
203  meHitTvsQ_[0] = ibook.bookProfile("BtlHitTvsQL",
204  "BTL DIGI ToA vs charge (L);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]",
205  50,
206  0.,
207  1024.,
208  0.,
209  1024.);
210  meHitTvsQ_[1] = ibook.bookProfile("BtlHitTvsQR",
211  "BTL DIGI ToA vs charge (R);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]",
212  50,
213  0.,
214  1024.,
215  0.,
216  1024.);
217  meHitQvsPhi_[0] = ibook.bookProfile("BtlHitQvsPhiL",
218  "BTL DIGI charge vs #phi (L);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]",
219  50,
220  -3.15,
221  3.15,
222  0.,
223  1024.);
224  meHitQvsPhi_[1] = ibook.bookProfile("BtlHitQvsPhiR",
225  "BTL DIGI charge vs #phi (R);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]",
226  50,
227  -3.15,
228  3.15,
229  0.,
230  1024.);
231  meHitQvsEta_[0] = ibook.bookProfile(
232  "BtlHitQvsEtaL", "BTL DIGI charge vs #eta (L);#eta_{DIGI};Q_{DIGI} [ADC counts]", 50, -1.55, 1.55, 0., 1024.);
233  meHitQvsEta_[1] = ibook.bookProfile(
234  "BtlHitQvsEtaR", "BTL DIGI charge vs #eta (R);#eta_{DIGI};Q_{DIGI} [ADC counts]", 50, -1.55, 1.55, 0., 1024.);
235  meHitQvsZ_[0] = ibook.bookProfile(
236  "BtlHitQvsZL", "BTL DIGI charge vs Z (L);Z_{DIGI} [cm];Q_{DIGI} [ADC counts]", 50, -260., 260., 0., 1024.);
237  meHitQvsZ_[1] = ibook.bookProfile(
238  "BtlHitQvsZR", "BTL DIGI charge vs Z (R);Z_{DIGI} [cm];Q_{DIGI} [ADC counts]", 50, -260., 260., 0., 1024.);
239  meHitTvsPhi_[0] = ibook.bookProfile(
240  "BtlHitTvsPhiL", "BTL DIGI ToA vs #phi (L);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", 50, -3.15, 3.15, 0., 1024.);
241  meHitTvsPhi_[1] = ibook.bookProfile(
242  "BtlHitTvsPhiR", "BTL DIGI ToA vs #phi (R);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", 50, -3.15, 3.15, 0., 1024.);
243  meHitTvsEta_[0] = ibook.bookProfile(
244  "BtlHitTvsEtaL", "BTL DIGI ToA vs #eta (L);#eta_{DIGI};ToA_{DIGI} [TDC counts]", 50, -1.55, 1.55, 0., 1024.);
245  meHitTvsEta_[1] = ibook.bookProfile(
246  "BtlHitTvsEtaR", "BTL DIGI ToA vs #eta (R);#eta_{DIGI};ToA_{DIGI} [TDC counts]", 50, -1.55, 1.55, 0., 1024.);
247  meHitTvsZ_[0] = ibook.bookProfile(
248  "BtlHitTvsZL", "BTL DIGI ToA vs Z (L);Z_{DIGI} [cm];ToA_{DIGI} [TDC counts]", 50, -260., 260., 0., 1024.);
249  meHitTvsZ_[1] = ibook.bookProfile(
250  "BtlHitTvsZR", "BTL DIGI ToA vs Z (R);Z_{DIGI} [cm];ToA_{DIGI} [TDC counts]", 50, -260., 260., 0., 1024.);
251 }
252 
253 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
256 
257  desc.add<std::string>("folder", "MTD/BTL/DigiHits");
258  desc.add<edm::InputTag>("inputTag", edm::InputTag("mix", "FTLBarrel"));
259 
260  descriptions.add("btlDigiHitsDefault", desc);
261 }
262 
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
Definition: DQMStore.cc:239
T getParameter(std::string const &) const
BtlDigiHitsValidation(const edm::ParameterSet &)
MonitorElement * meHitZ_[2]
CaloTopology const * topology(0)
virtual const Topology & topology() const
Definition: GeomDet.cc:67
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:418
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
int getMTDTopologyMode() const
Definition: MTDTopology.h:73
MonitorElement * meHitQvsEta_[2]
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
MonitorElement * meHitTvsZ_[2]
MonitorElement * meHitY_[2]
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
MonitorElement * meHitX_[2]
edm::EDGetTokenT< BTLDigiCollection > btlDigiHitsToken_
int nrows() const override
void Fill(long long x)
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:547
const MTDGeomDet * idToDet(DetId) const override
Definition: MTDGeometry.cc:160
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BTLDetId geographicalId(CrysLayout lay) const
Definition: BTLDetId.cc:163
MonitorElement * meHitTvsEta_[2]
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, char const *option="s")
Definition: DQMStore.cc:333
virtual const PixelTopology & specificTopology() const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
LocalPoint pixelToModuleLocalPoint(const LocalPoint &plp, int row, int col) const
MonitorElement * meNhits_[2]
MonitorElement * meOccupancy_[2]
Definition: DetId.h:17
MonitorElement * meHitTvsQ_[2]
void add(std::string const &label, ParameterSetDescription const &psetDescription)
MonitorElement * meHitQvsZ_[2]
MonitorElement * meHitEta_[2]
MonitorElement * meHitPhi_[2]
HLT enums.
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Definition: DQMStore.cc:266
T get() const
Definition: EventSetup.h:73
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0...
Definition: BTLDetId.h:18
MonitorElement * meHitTime_[2]
MonitorElement * meHitTvsPhi_[2]
int column(unsigned nrows=16) const
Definition: BTLDetId.h:110
MonitorElement * meHitCharge_[2]
auto makeValid(const U &iOtherHandleType) noexcept(false)
Definition: ValidHandle.h:52
T const * product() const
Definition: ESHandle.h:86
Definition: Run.h:45
void analyze(const edm::Event &, const edm::EventSetup &) override
MonitorElement * meHitQvsPhi_[2]
int row(unsigned nrows=16) const
Definition: BTLDetId.h:105