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 
162  iSetup.get<MuonGeometryRecord>().get(hGeom);
163  const ME0Geometry *ME0Geometry_ = (&*hGeom);
164 
166  e.getByToken(InputTagToken_, ME0Hits);
167 
169  e.getByToken(InputTagToken_Digi, ME0Digis);
170 
171  if (!ME0Hits.isValid() | !ME0Digis.isValid()) {
172  edm::LogError("ME0DigisValidation") << "Cannot get ME0Hits/ME0Digis by Token simInputTagToken";
173  return;
174  }
175 
176  num_evts->Fill(1);
177  bool toBeCounted1 = true;
178 
179  for (ME0DigiPreRecoCollection::DigiRangeIterator cItr = ME0Digis->begin(); cItr != ME0Digis->end(); cItr++) {
180  ME0DetId id = (*cItr).first;
181 
182  const GeomDet *gdet = ME0Geometry_->idToDet(id);
183  if (gdet == nullptr) {
184  edm::LogWarning("ME0DigisValidation") << "Getting DetId failed. Discard this gem strip hit. Maybe it comes "
185  "from unmatched geometry.";
186  continue;
187  }
188  const BoundPlane &surface = gdet->surface();
189 
190  int region = (int)id.region();
191  int layer = (int)id.layer();
192  int chamber = (int)id.chamber();
193  int roll = (int)id.roll();
194 
196  for (digiItr = (*cItr).second.first; digiItr != (*cItr).second.second; ++digiItr) {
197  LocalPoint lp(digiItr->x(), digiItr->y(), 0);
198 
199  GlobalPoint gp = surface.toGlobal(lp);
200 
201  float g_r = (float)gp.perp();
202  float g_x = (float)gp.x();
203  float g_y = (float)gp.y();
204  float g_z = (float)gp.z();
205 
206  int particleType = digiItr->pdgid();
207  int isPrompt = digiItr->prompt();
208 
209  float timeOfFlight = digiItr->tof();
210 
213  me0_strip_dg_time_tot->Fill(timeOfFlight);
214 
215  // fill hist
216  int region_num = 0;
217  if (region == -1)
218  region_num = 0;
219  else if (region == 1)
220  region_num = 1;
221  int layer_num = layer - 1;
222 
223  bool toBeCounted2 = true;
224 
225  if (isPrompt == 1 && abs(particleType) == 13) {
226  me0_strip_dg_zr_tot_Muon[region_num]->Fill(g_z, g_r);
227  me0_strip_dg_xy_Muon[region_num][layer_num]->Fill(g_x, g_y);
228 
229  for (auto hits = ME0Hits->begin(); hits != ME0Hits->end(); hits++) {
230  int particleType_sh = hits->particleType();
231  int evtId_sh = hits->eventId().event();
232  int bx_sh = hits->eventId().bunchCrossing();
233  int procType_sh = hits->processType();
234 
235  if (!(abs(particleType_sh) == 13 && evtId_sh == 0 && bx_sh == 0 && procType_sh == 0))
236  continue;
237 
238  const ME0DetId id(hits->detUnitId());
239  int region_sh = id.region();
240  int layer_sh = id.layer();
241  int chamber_sh = id.chamber();
242  int roll_sh = id.roll();
243 
244  int region_sh_num = 0;
245  if (region_sh == -1)
246  region_sh_num = 0;
247  else if (region_sh == 1)
248  region_sh_num = 1;
249  int layer_sh_num = layer_sh - 1;
250 
251  LocalPoint lp_sh = hits->localPosition();
252  GlobalPoint gp_sh = ME0Geometry_->idToDet(id)->surface().toGlobal(lp_sh);
253 
254  if (toBeCounted1) {
255  me0_strip_dg_den_eta[region_sh_num][layer_sh_num]->Fill(fabs(gp_sh.eta()));
256  me0_strip_dg_den_eta_tot->Fill(fabs(gp_sh.eta()));
257  }
258 
259  if (!(region == region_sh && layer == layer_sh && chamber == chamber_sh && roll == roll_sh))
260  continue;
261 
262  float dx_loc = lp_sh.x() - lp.x();
263  float dy_loc = lp_sh.y() - lp.y();
264  float dphi_glob = gp_sh.phi() - gp.phi();
265  float deta_glob = gp_sh.eta() - gp.eta();
266 
267  if (!(fabs(dphi_glob) < 3 * sigma_x_ && fabs(deta_glob) < 3 * sigma_y_))
268  continue;
269 
270  float timeOfFlight_sh = hits->tof();
271  const LocalPoint centralLP(0., 0., 0.);
272  const GlobalPoint centralGP(ME0Geometry_->idToDet(id)->surface().toGlobal(centralLP));
273  float centralTOF(centralGP.mag() / 29.98); // speed of light
274  float timeOfFlight_sh_corr = timeOfFlight_sh - centralTOF;
275 
276  me0_strip_dg_dx_local_Muon[region_num][layer_num]->Fill(dx_loc);
277  me0_strip_dg_dy_local_Muon[region_num][layer_num]->Fill(dy_loc);
278  me0_strip_dg_dphi_global_Muon[region_num][layer_num]->Fill(dphi_glob);
279 
283 
285  me0_strip_dg_dtime_tot_Muon->Fill(timeOfFlight - timeOfFlight_sh_corr);
286 
287  if (toBeCounted2) {
288  me0_strip_dg_num_eta[region_num][layer_num]->Fill(fabs(gp_sh.eta()));
289  me0_strip_dg_num_eta_tot->Fill(fabs(gp_sh.eta()));
290  }
291  toBeCounted2 = false;
292 
293  } // loop SH
294 
295  toBeCounted1 = false;
296 
297  } else {
298  me0_strip_dg_zr_tot[region_num]->Fill(g_z, g_r);
299  me0_strip_dg_xy[region_num][layer_num]->Fill(g_x, g_y);
300  }
301 
302  if ((abs(particleType) == 11 || abs(particleType) == 22 || abs(particleType) == 2112) && isPrompt == 0)
303  me0_strip_dg_bkg_rad_tot->Fill(fabs(gp.perp()));
304  if ((abs(particleType) == 11) && isPrompt == 0)
305  me0_strip_dg_bkgElePos_rad->Fill(fabs(gp.perp()));
306  if ((abs(particleType) == 22 || abs(particleType) == 2112) && isPrompt == 0)
307  me0_strip_dg_bkgNeutral_rad->Fill(fabs(gp.perp()));
308 
309  } // loop DG
310  }
311 }
#define LogDebug(id)
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
MonitorElement * BookHistZR(DQMStore::IBooker &, const char *name, const char *label, unsigned int region_num, unsigned int layer_num=99)
T getParameter(std::string const &) const
MonitorElement * me0_strip_dg_num_eta[2][6]
void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * me0_strip_dg_den_eta_tot
MonitorElement * me0_strip_exp_bkgElePos_rad
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
TH1F * getTH1F() const
std::vector< std::string > regionLabel
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
MonitorElement * me0_strip_dg_num_eta_tot
MonitorElement * me0_strip_dg_x_local_tot
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
MonitorElement * me0_strip_dg_dphi_global_Muon[2][6]
MonitorElement * me0_strip_dg_y_local_tot
void Fill(long long x)
MonitorElement * BookHistXY(DQMStore::IBooker &, const char *name, const char *label, unsigned int region_num, unsigned int layer_num=99)
MonitorElement * num_evts
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
MonitorElement * me0_strip_dg_zr_tot_Muon[2]
MonitorElement * me0_strip_dg_dtime_tot_Muon
MonitorElement * me0_strip_dg_xy[2][6]
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
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]
MonitorElement * me0_strip_dg_dy_local_tot_Muon
ME0DigisValidation(const edm::ParameterSet &)
bool isValid() const
Definition: HandleBase.h:74
MonitorElement * me0_strip_dg_dy_local_Muon[2][6]
#define M_PI
MonitorElement * me0_strip_dg_bkgNeutral_rad
MonitorElement * me0_strip_exp_bkgNeutral_rad
MonitorElement * me0_strip_dg_dx_local_tot_Muon
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
edm::EDGetToken InputTagToken_Digi
std::vector< DigiType >::const_iterator const_iterator
const GeomDet * idToDet(DetId) const override
Definition: ME0Geometry.cc:42
MonitorElement * me0_strip_dg_time_tot
edm::EDGetToken InputTagToken_
T eta() const
Definition: PV3DBase.h:76
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
T get() const
Definition: EventSetup.h:71
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
T x() const
Definition: PV3DBase.h:62
MonitorElement * me0_strip_dg_zr_tot[2]
double timeOfFlight(DetId id, const CaloGeometry *geo, bool debug=false)
Definition: CaloSimInfo.cc:17
Definition: Run.h:45
MonitorElement * me0_strip_dg_dx_local_Muon[2][6]