CMS 3D CMS Logo

ME0DigisValidation.cc
Go to the documentation of this file.
2 #include <TMath.h>
3 
5  InputTagToken_ = consumes<edm::PSimHitContainer>(cfg.getParameter<edm::InputTag>("simInputLabel"));
6  InputTagToken_Digi = consumes<ME0DigiPreRecoCollection>(cfg.getParameter<edm::InputTag>("digiInputLabel"));
7  sigma_x_ = cfg.getParameter<double>("sigma_x");
8  sigma_y_ = cfg.getParameter<double>("sigma_y");
9 }
10 
12  edm::Run const &Run,
13  edm::EventSetup const &iSetup) {
14  LogDebug("MuonME0DigisValidation") << "Info: Loading Geometry information\n";
15  ibooker.setCurrentFolder("MuonME0DigisV/ME0DigisTask");
16 
17  unsigned int nregion = 2;
18 
19  edm::LogInfo("MuonME0DigisValidation") << "+++ Info : # of region: " << nregion << std::endl;
20 
21  LogDebug("MuonME0DigisValidation") << "+++ Info : finish to get geometry information from ES.\n";
22 
23  num_evts = ibooker.book1D("num_evts", "Number of events; ; Number of events", 1, 0, 2);
24 
26  ibooker.book1D("me0_strip_dg_x_local_tot", "Local X; X_{local} [cm]; Entries", 60, -30.0, +30.0);
28  ibooker.book1D("me0_strip_dg_y_local_tot", "Local Y; Y_{local} [cm]; Entries", 100, -50.0, +50.0);
29  me0_strip_dg_time_tot = ibooker.book1D("me0_strip_dg_time_tot", "ToF; ToF [ns]; Entries", 400, -200, +200);
30 
32  ibooker.book1D("me0_strip_dg_dx_local_tot", "Local DeltaX; #Delta X_{local} [cm]; Entries", 50, -0.1, +0.1);
34  ibooker.book1D("me0_strip_dg_dy_local_tot", "Local DeltaY; #Delta Y_{local} [cm]; Entries", 500, -10.0, +10.0);
36  "me0_strip_dg_dphi_global_tot", "Global DeltaPhi; #Delta #phi_{global} [rad]; Entries", 50, -0.01, +0.01);
38  ibooker.book1D("me0_strip_dg_dtime_tot", "DeltaToF; #Delta ToF [ns]; Entries", 50, -5, +5);
39 
40  me0_strip_dg_dphi_vs_phi_global_tot_Muon = ibooker.book2D("me0_strip_dg_dphi_vs_phi_global_tot",
41  "Global DeltaPhi vs. Phi; #phi_{global} [rad]; #Delta "
42  "#phi_{global} [rad]",
43  72,
44  -M_PI,
45  +M_PI,
46  50,
47  -0.01,
48  +0.01);
49 
50  me0_strip_dg_den_eta_tot = ibooker.book1D("me0_strip_dg_den_eta_tot", "Denominator; #eta; Entries", 12, 1.8, 3.0);
51  me0_strip_dg_num_eta_tot = ibooker.book1D("me0_strip_dg_num_eta_tot", "Numerator; #eta; Entries", 12, 1.8, 3.0);
52 
53  float bins[] = {62.3, 70.0, 77.7, 87.1, 96.4, 108.2, 119.9, 134.7, 149.5};
54  int binnum = sizeof(bins) / sizeof(float) - 1;
55 
57  ibooker.book1D("me0_strip_dg_bkg_radius_tot", "Total neutron background; Radius [cm]; Entries", binnum, bins);
59  "me0_strip_dg_bkgElePos_radius", "Neutron background: electrons+positrons; Radius [cm]; Entries", binnum, bins);
61  "me0_strip_dg_bkgNeutral_radius", "Neutron background: gammas+neutrons; Radius [cm]; Entries", binnum, bins);
62 
63  me0_strip_exp_bkg_rad_tot = ibooker.book1D("me0_strip_exp_bkg_radius_tot",
64  "Total expected neutron background; Radius [cm]; Hit Rate [Hz/cm^{2}]",
65  binnum,
66  bins);
67  me0_strip_exp_bkgElePos_rad = ibooker.book1D("me0_strip_exp_bkgElePos_radius",
68  "Expected neutron background: electrons+positrons; Radius "
69  "[cm]; Hit Rate [Hz/cm^{2}]",
70  binnum,
71  bins);
72  me0_strip_exp_bkgNeutral_rad = ibooker.book1D("me0_strip_exp_bkgNeutral_radius",
73  "Expected neutron background: gammas+neutrons; Radius "
74  "[cm]; Hit Rate [Hz/cm^{2}]",
75  binnum,
76  bins);
77 
78  std::vector<double> neuBkg, eleBkg;
79  neuBkg.push_back(899644.0);
80  neuBkg.push_back(-30841.0);
81  neuBkg.push_back(441.28);
82  neuBkg.push_back(-3.3405);
83  neuBkg.push_back(0.0140588);
84  neuBkg.push_back(-3.11473e-05);
85  neuBkg.push_back(2.83736e-08);
86  eleBkg.push_back(4.68590e+05);
87  eleBkg.push_back(-1.63834e+04);
88  eleBkg.push_back(2.35700e+02);
89  eleBkg.push_back(-1.77706e+00);
90  eleBkg.push_back(7.39960e-03);
91  eleBkg.push_back(-1.61448e-05);
92  eleBkg.push_back(1.44368e-08);
93 
94  for (int i = 1; i < me0_strip_exp_bkgNeutral_rad->getTH1F()->GetSize(); i++) {
95  double pos = me0_strip_exp_bkgNeutral_rad->getTH1F()->GetBinCenter(i);
96  double neutral = 0;
97  double charged = 0;
98 
99  double pos_helper = 1.0;
100  for (int j = 0; j < 7; ++j) {
101  neutral += neuBkg[j] * pos_helper;
102  charged += eleBkg[j] * pos_helper;
103  pos_helper *= pos;
104  }
105 
108  me0_strip_exp_bkg_rad_tot->setBinContent(i, neutral + charged);
109  }
110 
111  for (unsigned int region_num = 0; region_num < nregion; region_num++) {
112  me0_strip_dg_zr_tot[region_num] = BookHistZR(ibooker, "me0_strip_dg_tot", "Digi", region_num);
113  me0_strip_dg_zr_tot_Muon[region_num] = BookHistZR(ibooker, "me0_strip_dg_tot_Muon", "Digi Muon", region_num);
114  for (unsigned int layer_num = 0; layer_num < 6; layer_num++) {
115  std::string hist_name_for_dx_local =
116  std::string("me0_strip_dg_dx_local") + regionLabel[region_num] + "_l" + layerLabel[layer_num];
117  std::string hist_name_for_dy_local =
118  std::string("me0_strip_dg_dy_local") + regionLabel[region_num] + "_l" + layerLabel[layer_num];
119  std::string hist_name_for_dphi_global =
120  std::string("me0_strip_dg_dphi_global") + regionLabel[region_num] + "_l" + layerLabel[layer_num];
121 
122  std::string hist_name_for_den_eta =
123  std::string("me0_strip_dg_den_eta") + regionLabel[region_num] + "_l" + layerLabel[layer_num];
124  std::string hist_name_for_num_eta =
125  std::string("me0_strip_dg_num_eta") + regionLabel[region_num] + "_l" + layerLabel[layer_num];
126 
127  std::string hist_label_for_dx_local = "Local DeltaX: region" + regionLabel[region_num] + " layer " +
128  layerLabel[layer_num] + " ; #Delta X_{local} [cm]; Entries";
129  std::string hist_label_for_dy_local = "Local DeltaY: region" + regionLabel[region_num] + " layer " +
130  layerLabel[layer_num] + " ; #Delta Y_{local} [cm]; Entries";
131  std::string hist_label_for_dphi_global = "Global DeltaPhi: region" + regionLabel[region_num] + " layer " +
132  layerLabel[layer_num] + " ; #Delta #phi_{global} [rad]; Entries";
133 
134  std::string hist_label_for_den_eta =
135  "Denominator: region" + regionLabel[region_num] + " layer " + layerLabel[layer_num] + " ; #eta; Entries";
136  std::string hist_label_for_num_eta =
137  "Numerator: region" + regionLabel[region_num] + " layer " + layerLabel[layer_num] + " ; #eta; Entries";
138 
139  me0_strip_dg_xy[region_num][layer_num] = BookHistXY(ibooker, "me0_strip_dg", "Digi", region_num, layer_num);
140  me0_strip_dg_xy_Muon[region_num][layer_num] =
141  BookHistXY(ibooker, "me0_strip_dg_Muon", "Digi Muon", region_num, layer_num);
142 
143  me0_strip_dg_dx_local_Muon[region_num][layer_num] =
144  ibooker.book1D(hist_name_for_dx_local.c_str(), hist_label_for_dx_local.c_str(), 50, -0.1, +0.1);
145  me0_strip_dg_dy_local_Muon[region_num][layer_num] =
146  ibooker.book1D(hist_name_for_dy_local.c_str(), hist_label_for_dy_local.c_str(), 500, -10.0, +10.0);
147  me0_strip_dg_dphi_global_Muon[region_num][layer_num] =
148  ibooker.book1D(hist_name_for_dphi_global.c_str(), hist_label_for_dphi_global.c_str(), 50, -0.01, +0.01);
149 
150  me0_strip_dg_den_eta[region_num][layer_num] =
151  ibooker.book1D(hist_name_for_den_eta, hist_label_for_den_eta, 12, 1.8, 3.0);
152  me0_strip_dg_num_eta[region_num][layer_num] =
153  ibooker.book1D(hist_name_for_num_eta, hist_label_for_num_eta, 12, 1.8, 3.0);
154  }
155  }
156 }
157 
159 
161  const ME0Geometry *ME0Geometry_ = &iSetup.getData(geomToken_);
162 
164  e.getByToken(InputTagToken_, ME0Hits);
165 
167  e.getByToken(InputTagToken_Digi, ME0Digis);
168 
169  if (!ME0Hits.isValid() | !ME0Digis.isValid()) {
170  edm::LogError("ME0DigisValidation") << "Cannot get ME0Hits/ME0Digis by Token simInputTagToken";
171  return;
172  }
173 
174  num_evts->Fill(1);
175  bool toBeCounted1 = true;
176 
177  for (ME0DigiPreRecoCollection::DigiRangeIterator cItr = ME0Digis->begin(); cItr != ME0Digis->end(); cItr++) {
178  ME0DetId id = (*cItr).first;
179 
180  const GeomDet *gdet = ME0Geometry_->idToDet(id);
181  if (gdet == nullptr) {
182  edm::LogWarning("ME0DigisValidation") << "Getting DetId failed. Discard this gem strip hit. Maybe it comes "
183  "from unmatched geometry.";
184  continue;
185  }
186  const BoundPlane &surface = gdet->surface();
187 
188  int region = (int)id.region();
189  int layer = (int)id.layer();
190  int chamber = (int)id.chamber();
191  int roll = (int)id.roll();
192 
194  for (digiItr = (*cItr).second.first; digiItr != (*cItr).second.second; ++digiItr) {
195  LocalPoint lp(digiItr->x(), digiItr->y(), 0);
196 
197  GlobalPoint gp = surface.toGlobal(lp);
198 
199  float g_r = (float)gp.perp();
200  float g_x = (float)gp.x();
201  float g_y = (float)gp.y();
202  float g_z = (float)gp.z();
203 
204  int particleType = digiItr->pdgid();
205  int isPrompt = digiItr->prompt();
206 
207  float timeOfFlight = digiItr->tof();
208 
212 
213  // fill hist
214  int region_num = 0;
215  if (region == -1)
216  region_num = 0;
217  else if (region == 1)
218  region_num = 1;
219  int layer_num = layer - 1;
220 
221  bool toBeCounted2 = true;
222 
223  if (isPrompt == 1 && abs(particleType) == 13) {
224  me0_strip_dg_zr_tot_Muon[region_num]->Fill(g_z, g_r);
225  me0_strip_dg_xy_Muon[region_num][layer_num]->Fill(g_x, g_y);
226 
227  for (auto hits = ME0Hits->begin(); hits != ME0Hits->end(); hits++) {
228  int particleType_sh = hits->particleType();
229  int evtId_sh = hits->eventId().event();
230  int bx_sh = hits->eventId().bunchCrossing();
231  int procType_sh = hits->processType();
232 
233  if (!(abs(particleType_sh) == 13 && evtId_sh == 0 && bx_sh == 0 && procType_sh == 0))
234  continue;
235 
236  const ME0DetId id(hits->detUnitId());
237  int region_sh = id.region();
238  int layer_sh = id.layer();
239  int chamber_sh = id.chamber();
240  int roll_sh = id.roll();
241 
242  int region_sh_num = 0;
243  if (region_sh == -1)
244  region_sh_num = 0;
245  else if (region_sh == 1)
246  region_sh_num = 1;
247  int layer_sh_num = layer_sh - 1;
248 
249  LocalPoint lp_sh = hits->localPosition();
250  GlobalPoint gp_sh = ME0Geometry_->idToDet(id)->surface().toGlobal(lp_sh);
251 
252  if (toBeCounted1) {
253  me0_strip_dg_den_eta[region_sh_num][layer_sh_num]->Fill(fabs(gp_sh.eta()));
254  me0_strip_dg_den_eta_tot->Fill(fabs(gp_sh.eta()));
255  }
256 
257  if (!(region == region_sh && layer == layer_sh && chamber == chamber_sh && roll == roll_sh))
258  continue;
259 
260  float dx_loc = lp_sh.x() - lp.x();
261  float dy_loc = lp_sh.y() - lp.y();
262  float dphi_glob = gp_sh.phi() - gp.phi();
263  float deta_glob = gp_sh.eta() - gp.eta();
264 
265  if (!(fabs(dphi_glob) < 3 * sigma_x_ && fabs(deta_glob) < 3 * sigma_y_))
266  continue;
267 
268  float timeOfFlight_sh = hits->tof();
269  const LocalPoint centralLP(0., 0., 0.);
270  const GlobalPoint centralGP(ME0Geometry_->idToDet(id)->surface().toGlobal(centralLP));
271  float centralTOF(centralGP.mag() / 29.98); // speed of light
272  float timeOfFlight_sh_corr = timeOfFlight_sh - centralTOF;
273 
274  me0_strip_dg_dx_local_Muon[region_num][layer_num]->Fill(dx_loc);
275  me0_strip_dg_dy_local_Muon[region_num][layer_num]->Fill(dy_loc);
276  me0_strip_dg_dphi_global_Muon[region_num][layer_num]->Fill(dphi_glob);
277 
281 
283  me0_strip_dg_dtime_tot_Muon->Fill(timeOfFlight - timeOfFlight_sh_corr);
284 
285  if (toBeCounted2) {
286  me0_strip_dg_num_eta[region_num][layer_num]->Fill(fabs(gp_sh.eta()));
287  me0_strip_dg_num_eta_tot->Fill(fabs(gp_sh.eta()));
288  }
289  toBeCounted2 = false;
290 
291  } // loop SH
292 
293  toBeCounted1 = false;
294 
295  } else {
296  me0_strip_dg_zr_tot[region_num]->Fill(g_z, g_r);
297  me0_strip_dg_xy[region_num][layer_num]->Fill(g_x, g_y);
298  }
299 
300  if ((abs(particleType) == 11 || abs(particleType) == 22 || abs(particleType) == 2112) && isPrompt == 0)
301  me0_strip_dg_bkg_rad_tot->Fill(fabs(gp.perp()));
302  if ((abs(particleType) == 11) && isPrompt == 0)
303  me0_strip_dg_bkgElePos_rad->Fill(fabs(gp.perp()));
304  if ((abs(particleType) == 22 || abs(particleType) == 2112) && isPrompt == 0)
305  me0_strip_dg_bkgNeutral_rad->Fill(fabs(gp.perp()));
306 
307  } // loop DG
308  }
309 }
MonitorElement * me0_strip_dg_num_eta[2][6]
MonitorElement * me0_strip_dg_den_eta_tot
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
MonitorElement * me0_strip_exp_bkgElePos_rad
edm::ESGetToken< ME0Geometry, MuonGeometryRecord > geomToken_
std::vector< std::string > regionLabel
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T eta() const
Definition: PV3DBase.h:73
MonitorElement * me0_strip_dg_num_eta_tot
Log< level::Error, false > LogError
MonitorElement * me0_strip_dg_x_local_tot
MonitorElement * me0_strip_dg_dphi_global_Muon[2][6]
MonitorElement * me0_strip_dg_y_local_tot
MonitorElement * BookHistZR(DQMStore::IBooker &, const char *name, const char *label, unsigned int region_num, unsigned int layer_num=99)
const GeomDet * idToDet(DetId) const override
Definition: ME0Geometry.cc:24
constexpr std::array< uint8_t, layerIndexSize > layer
void Fill(long long x)
MonitorElement * BookHistXY(DQMStore::IBooker &, const char *name, const char *label, unsigned int region_num, unsigned int layer_num=99)
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
MonitorElement * num_evts
MonitorElement * me0_strip_dg_zr_tot_Muon[2]
MonitorElement * me0_strip_dg_dtime_tot_Muon
MonitorElement * me0_strip_dg_xy[2][6]
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MonitorElement * me0_strip_dg_dphi_global_tot_Muon
MonitorElement * me0_strip_dg_xy_Muon[2][6]
bool getData(T &iHolder) const
Definition: EventSetup.h:122
MonitorElement * me0_strip_dg_dy_local_tot_Muon
ME0DigisValidation(const edm::ParameterSet &)
MonitorElement * me0_strip_dg_dy_local_Muon[2][6]
#define M_PI
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
MonitorElement * me0_strip_dg_bkgNeutral_rad
Log< level::Info, false > LogInfo
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
MonitorElement * me0_strip_exp_bkgNeutral_rad
MonitorElement * me0_strip_dg_dx_local_tot_Muon
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
edm::EDGetToken InputTagToken_Digi
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
std::vector< DigiType >::const_iterator const_iterator
MonitorElement * me0_strip_dg_time_tot
edm::EDGetToken InputTagToken_
bool isValid() const
Definition: HandleBase.h:70
MonitorElement * me0_strip_dg_bkg_rad_tot
MonitorElement * me0_strip_dg_den_eta[2][6]
std::vector< std::string > layerLabel
MonitorElement * me0_strip_dg_bkgElePos_rad
MonitorElement * me0_strip_exp_bkg_rad_tot
MonitorElement * me0_strip_dg_dphi_vs_phi_global_tot_Muon
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
void analyze(const edm::Event &e, const edm::EventSetup &) override
Log< level::Warning, false > LogWarning
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 * me0_strip_dg_zr_tot[2]
double timeOfFlight(DetId id, const CaloGeometry *geo, bool debug=false)
Definition: CaloSimInfo.cc:15
Definition: Run.h:45
#define LogDebug(id)
MonitorElement * me0_strip_dg_dx_local_Muon[2][6]