CMS 3D CMS Logo

GEMRecHitValidation.cc
Go to the documentation of this file.
5 
7  : GEMBaseValidation(pset, "GEMRecHitsValidation") {
8  const auto& rechit_pset = pset.getParameterSet("gemRecHit");
9  const auto& rechit_tag = rechit_pset.getParameter<edm::InputTag>("inputTag");
10  rechit_token_ = consumes<GEMRecHitCollection>(rechit_tag);
11 
12  const auto& simhit_pset = pset.getParameterSet("gemSimHit");
13  const auto& simhit_tag = simhit_pset.getParameter<edm::InputTag>("inputTag");
14  simhit_token_ = consumes<edm::PSimHitContainer>(simhit_tag);
15  geomToken_ = esConsumes<GEMGeometry, MuonGeometryRecord>();
16  geomTokenBeginRun_ = esConsumes<GEMGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
17 }
18 
20 
22  const GEMGeometry* gem = &setup.getData(geomTokenBeginRun_);
23 
24  // NOTE Cluster Size
25  booker.setCurrentFolder("MuonGEMRecHitsV/GEMRecHitsTask/ClusterSize");
26 
27  TString cls_title = "Cluster Size Distribution";
28  TString cls_x_title = "Cluster size";
29 
30  me_cls_ = booker.book1D("cls", cls_title + ";" + cls_x_title + ";" + "Entries", 11, -0.5, 10.5);
31 
32  if (detail_plot_) {
33  for (const auto& region : gem->regions()) {
34  Int_t region_id = region->region();
35 
36  for (const auto& station : region->stations()) {
37  Int_t station_id = station->station();
38 
39  const auto& superChamberVec = station->superChambers();
40  if (superChamberVec.empty() || superChamberVec[0] == nullptr) {
41  edm::LogError(kLogCategory_) << "Super chambers missing or null for region = " << region_id
42  << " and station = " << station_id;
43  } else {
44  for (const auto& chamber : superChamberVec[0]->chambers()) {
45  Int_t layer_id = chamber->id().layer();
46  ME3IdsKey key3{region_id, station_id, layer_id};
47 
48  me_detail_cls_[key3] = bookHist1D(booker, key3, "cls", cls_title, 11, -0.5, 10.5, cls_x_title);
49  } // chamber loop
50  } // end else
51  } // station loop
52  } // region loop
53  } // detail plot
54 
55  // NOTE Residual
56  booker.setCurrentFolder("MuonGEMRecHitsV/GEMRecHitsTask/Residual");
57 
58  for (const auto& region : gem->regions()) {
59  Int_t region_id = region->region();
60 
61  me_residual_x_[region_id] =
62  bookHist1D(booker, region_id, "residual_x", "Residual in X", 120, -3, 3, "Residual in X [cm]");
63 
64  me_residual_y_[region_id] =
65  bookHist1D(booker, region_id, "residual_y", "Residual in Y", 600, -15, 15, "Residual in Y [cm]");
66 
67  if (detail_plot_) {
68  for (const auto& station : region->stations()) {
69  Int_t station_id = station->station();
70 
71  const auto& superChamberVec = station->superChambers();
72  if (!superChamberVec.empty() && superChamberVec[0] != nullptr) {
73  for (const auto& chamber : superChamberVec[0]->chambers()) {
74  Int_t layer_id = chamber->id().layer();
75  ME3IdsKey key3{region_id, station_id, layer_id};
76 
77  // Occupancy histograms of SimHits and RecHits for Efficiency
78  me_detail_residual_x_[key3] =
79  bookHist1D(booker, key3, "residual_x", "Residual in X", 120, -3, 3, "Residual in X [cm]");
80 
81  me_detail_residual_y_[key3] =
82  bookHist1D(booker, key3, "residual_y", "Residual in Y", 600, -15, 15, "Residual in Y [cm]");
83 
84  } // chamber loop
85  } // end if
86  } // station loop
87  } // detail_plot
88  } // region loop
89 
90  // NOTE Pull
91  booker.setCurrentFolder("MuonGEMRecHitsV/GEMRecHitsTask/Pull");
92 
93  for (const auto& region : gem->regions()) {
94  Int_t region_id = region->region();
95 
96  me_pull_x_[region_id] = bookHist1D(booker, region_id, "pull_x", "Pull in X", 100, -3, 3);
97 
98  me_pull_y_[region_id] = bookHist1D(booker, region_id, "pull_y", "Pull in Y", 100, -3, 3);
99 
100  if (detail_plot_) {
101  for (const auto& station : region->stations()) {
102  Int_t station_id = station->station();
103 
104  const auto& superChamberVec = station->superChambers();
105  if (!superChamberVec.empty() && superChamberVec[0] != nullptr) {
106  for (const auto& chamber : superChamberVec[0]->chambers()) {
107  Int_t layer_id = chamber->id().layer();
108  ME3IdsKey key3{region_id, station_id, layer_id};
109 
110  me_detail_pull_x_[key3] = bookHist1D(booker, key3, "pull_x", "Pull in X", 100, -3, 3);
111 
112  me_detail_pull_y_[key3] = bookHist1D(booker, key3, "pull_y", "Pull in Y", 100, -3, 3);
113 
114  } // chamber loop
115  } // end if
116  } // station loop
117  } // detail plot
118  } // region loop
119 
120  // NOTE Occupancy
121  booker.setCurrentFolder("MuonGEMRecHitsV/GEMRecHitsTask/Occupancy");
122  for (const auto& region : gem->regions()) {
123  Int_t region_id = region->region();
124 
125  me_occ_zr_[region_id] = bookZROccupancy(booker, region_id, "rechit", "RecHit");
126 
127  me_simhit_occ_eta_[region_id] = bookHist1D(booker,
128  region_id,
129  "muon_simhit_occ_eta",
130  "Muon SimHit Eta Occupancy",
131  50,
132  eta_range_[0],
133  eta_range_[1],
134  "|#eta|");
135 
136  me_rechit_occ_eta_[region_id] = bookHist1D(booker,
137  region_id,
138  "matched_rechit_occ_eta",
139  "Matched RecHit Eta Occupancy",
140  50,
141  eta_range_[0],
142  eta_range_[1],
143  "|#eta|");
144 
145  for (const auto& station : region->stations()) {
146  Int_t station_id = station->station();
147  ME2IdsKey key2{region_id, station_id};
148 
149  me_simhit_occ_phi_[key2] =
150  bookHist1D(booker, key2, "muon_simhit_occ_phi", "Muon SimHit Phi Occupancy", 51, -M_PI, M_PI, "#phi");
151 
152  me_rechit_occ_phi_[key2] =
153  bookHist1D(booker, key2, "matched_rechit_occ_phi", "Matched RecHit Phi Occupancy", 51, -M_PI, M_PI, "#phi");
154 
155  me_simhit_occ_det_[key2] = bookDetectorOccupancy(booker, key2, station, "muon_simhit", "Muon SimHit");
156 
157  me_rechit_occ_det_[key2] = bookDetectorOccupancy(booker, key2, station, "matched_rechit", "Matched RecHit");
158 
159  if (detail_plot_) {
160  const auto& superChamberVec = station->superChambers();
161  if (!superChamberVec.empty() && superChamberVec[0] != nullptr) {
162  for (const auto& chamber : superChamberVec[0]->chambers()) {
163  Int_t layer_id = chamber->id().layer();
164  ME3IdsKey key3{region_id, station_id, layer_id};
165 
166  me_detail_occ_xy_[key3] = bookXYOccupancy(booker, key3, "rechit", "RecHit");
167 
168  me_detail_occ_polar_[key3] = bookPolarOccupancy(booker, key3, "rechit", "RecHit");
169 
170  } // chamber loop
171  } // end if
172  } // detail plot
173  } // station loop
174  } // region_loop
175 }
176 
178  Bool_t matched = false;
179 
180  Int_t cls = rechit->clusterSize();
181  Int_t rechit_first_strip = rechit->firstClusterStrip();
182 
183  if (cls == 1) {
184  matched = simhit_strip == rechit_first_strip;
185  } else {
186  Int_t rechit_last_strip = rechit_first_strip + cls - 1;
187  matched = (simhit_strip >= rechit_first_strip) and (simhit_strip <= rechit_last_strip);
188  }
189 
190  return matched;
191 }
192 
194  const GEMGeometry* gem = &setup.getData(geomToken_);
195 
196  edm::Handle<edm::PSimHitContainer> simhit_container;
197  event.getByToken(simhit_token_, simhit_container);
198  if (not simhit_container.isValid()) {
199  edm::LogError(kLogCategory_) << "Failed to get PSimHitContainer." << std::endl;
200  return;
201  }
202 
203  edm::Handle<GEMRecHitCollection> rechit_collection;
204  event.getByToken(rechit_token_, rechit_collection);
205  if (not rechit_collection.isValid()) {
206  edm::LogError(kLogCategory_) << "Failed to get GEMRecHitCollection" << std::endl;
207  return;
208  }
209 
210  for (auto rechit = rechit_collection->begin(); rechit != rechit_collection->end(); rechit++) {
211  GEMDetId gem_id{rechit->gemId()};
212  Int_t region_id = gem_id.region();
213  Int_t station_id = gem_id.station();
214  Int_t layer_id = gem_id.layer();
215 
216  ME2IdsKey key2{region_id, station_id};
217  ME3IdsKey key3{region_id, station_id, layer_id};
218 
219  const BoundPlane& surface = gem->idToDet(gem_id)->surface();
220  GlobalPoint&& rechit_global_pos = surface.toGlobal(rechit->localPosition());
221 
222  Float_t rechit_g_x = rechit_global_pos.x();
223  Float_t rechit_g_y = rechit_global_pos.y();
224  Float_t rechit_g_abs_z = std::fabs(rechit_global_pos.z());
225  Float_t rechit_g_r = rechit_global_pos.perp();
226  Float_t rechit_g_phi = rechit_global_pos.phi();
227 
228  Int_t cls = rechit->clusterSize();
229 
230  me_cls_->Fill(cls);
231  me_occ_zr_[region_id]->Fill(rechit_g_abs_z, rechit_g_r);
232 
233  if (detail_plot_) {
234  me_detail_cls_[key3]->Fill(cls);
235  me_detail_occ_xy_[key3]->Fill(rechit_g_x, rechit_g_y);
236  me_detail_occ_polar_[key3]->Fill(rechit_g_phi, rechit_g_r);
237  } // detail plot
238  }
239 
240  // NOTE
241  for (const auto& simhit : *simhit_container.product()) {
242  if (gem->idToDet(simhit.detUnitId()) == nullptr) {
243  edm::LogError(kLogCategory_) << "MuonGEMHit didn't matched with GEMGeometry." << std::endl;
244  continue;
245  }
246 
247  if (not isMuonSimHit(simhit))
248  continue;
249 
250  GEMDetId simhit_gemid{simhit.detUnitId()};
251  const BoundPlane& surface = gem->idToDet(simhit_gemid)->surface();
252 
253  Int_t region_id = simhit_gemid.region();
254  Int_t station_id = simhit_gemid.station();
255  Int_t layer_id = simhit_gemid.layer();
256  Int_t chamber_id = simhit_gemid.chamber();
257  Int_t roll_id = simhit_gemid.roll();
258 
259  ME2IdsKey key2{region_id, station_id};
260  ME3IdsKey key3{region_id, station_id, layer_id};
261 
262  const LocalPoint& simhit_local_pos = simhit.localPosition();
263  const GlobalPoint& simhit_global_pos = surface.toGlobal(simhit_local_pos);
264 
265  Float_t simhit_g_abs_eta = std::fabs(simhit_global_pos.eta());
266  Float_t simhit_g_phi = simhit_global_pos.phi();
267 
268  Int_t simhit_strip = gem->etaPartition(simhit_gemid)->strip(simhit_local_pos);
269  Int_t det_occ_bin_x = getDetOccBinX(chamber_id, layer_id);
270 
271  me_simhit_occ_eta_[region_id]->Fill(simhit_g_abs_eta);
272  me_simhit_occ_phi_[key2]->Fill(simhit_g_phi);
273  me_simhit_occ_det_[key2]->Fill(det_occ_bin_x, roll_id);
274 
275  GEMRecHitCollection::range range = rechit_collection->get(simhit_gemid);
276  for (auto rechit = range.first; rechit != range.second; ++rechit) {
277  if (gem->idToDet(rechit->gemId()) == nullptr) {
278  edm::LogError(kLogCategory_) << "GEMRecHit didn't matched with GEMGeometry." << std::endl;
279  continue;
280  }
281 
282  if (matchRecHitAgainstSimHit(rechit, simhit_strip)) {
283  const LocalPoint& rechit_local_pos = rechit->localPosition();
284 
285  Float_t resolution_x = std::sqrt(rechit->localPositionError().xx());
286  Float_t resolution_y = std::sqrt(rechit->localPositionError().yy());
287 
288  Float_t residual_x = rechit_local_pos.x() - simhit_local_pos.x();
289  Float_t residual_y = rechit_local_pos.y() - simhit_local_pos.y();
290 
291  Float_t pull_x = residual_x / resolution_x;
292  Float_t pull_y = residual_y / resolution_y;
293 
294  me_residual_x_[region_id]->Fill(residual_x);
295  me_residual_y_[region_id]->Fill(residual_y);
296  me_pull_x_[region_id]->Fill(pull_x);
297  me_pull_y_[region_id]->Fill(pull_y);
298 
299  me_rechit_occ_eta_[region_id]->Fill(simhit_g_abs_eta);
300  me_rechit_occ_phi_[key2]->Fill(simhit_g_phi);
301  me_rechit_occ_det_[key2]->Fill(det_occ_bin_x, roll_id);
302 
303  if (detail_plot_) {
304  me_detail_residual_x_[key3]->Fill(residual_x);
305  me_detail_residual_y_[key3]->Fill(residual_y);
306 
307  me_detail_pull_x_[key3]->Fill(pull_x);
308  me_detail_pull_y_[key3]->Fill(pull_y);
309  } // detail_plot
310 
311  // If we find GEMRecHit that matches PSimHit, then exit
312  // GEMRecHitCollection loop.
313  break;
314 
315  } // if rechit matches against simhit
316  } // rechit loop
317  } // simhit loop
318 }
muonTagProbeFilters_cff.matched
matched
Definition: muonTagProbeFilters_cff.py:62
GEMRecHitValidation::me_detail_pull_y_
MEMap3Ids me_detail_pull_y_
Definition: GEMRecHitValidation.h:35
ME2IdsKey
std::tuple< Int_t, Int_t > ME2IdsKey
Definition: GEMValidationUtils.h:16
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
GEMRecHitValidation::rechit_token_
edm::EDGetTokenT< GEMRecHitCollection > rechit_token_
Definition: GEMRecHitValidation.h:18
Handle.h
GEMBaseValidation::bookHist1D
dqm::impl::MonitorElement * bookHist1D(DQMStore::IBooker &booker, const T &key, const char *name, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup, const char *x_title="", const char *y_title="Entries")
Definition: GEMBaseValidation.h:210
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
GEMBaseValidation::detail_plot_
Bool_t detail_plot_
Definition: GEMBaseValidation.h:88
GEMRecHitValidation::me_detail_occ_polar_
MEMap3Ids me_detail_occ_polar_
Definition: GEMRecHitValidation.h:40
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
edm::Run
Definition: Run.h:45
GEMDetId::region
constexpr int region() const
Definition: GEMDetId.h:168
GEMBaseValidation::bookDetectorOccupancy
dqm::impl::MonitorElement * bookDetectorOccupancy(DQMStore::IBooker &booker, const T &key, const GEMStation *station, const char *name_prfix, const char *title_prefix)
Definition: GEMBaseValidation.h:161
relativeConstraints.station
station
Definition: relativeConstraints.py:67
PSimHitContainer.h
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
edm::Handle< edm::PSimHitContainer >
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
GEMRecHitValidation::me_detail_residual_x_
MEMap3Ids me_detail_residual_x_
Definition: GEMRecHitValidation.h:29
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
GEMRecHitValidation::me_detail_pull_x_
MEMap3Ids me_detail_pull_x_
Definition: GEMRecHitValidation.h:34
GEMBaseValidation::isMuonSimHit
Bool_t isMuonSimHit(const PSimHit &)
Definition: GEMBaseValidation.cc:25
GEMBaseValidation::bookZROccupancy
dqm::impl::MonitorElement * bookZROccupancy(DQMStore::IBooker &booker, Int_t region_id, const char *name_prfix, const char *title_prefix)
Definition: GEMBaseValidation.cc:27
GEMRecHitValidation::me_pull_x_
MEMap1Ids me_pull_x_
Definition: GEMRecHitValidation.h:32
GEMRecHitValidation::me_detail_occ_xy_
MEMap3Ids me_detail_occ_xy_
Definition: GEMRecHitValidation.h:39
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
GEMBaseValidation::bookXYOccupancy
dqm::impl::MonitorElement * bookXYOccupancy(DQMStore::IBooker &booker, const T &key, const char *name_prefix, const char *title_prefix)
Definition: GEMBaseValidation.h:134
Point3DBase< float, GlobalTag >
GEMRecHitValidation::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: GEMRecHitValidation.cc:193
GEMRecHitValidation::me_detail_cls_
MEMap3Ids me_detail_cls_
Definition: GEMRecHitValidation.h:25
GEMRecHitValidation::me_rechit_occ_det_
MEMap2Ids me_rechit_occ_det_
Definition: GEMRecHitValidation.h:48
edm::ParameterSet
Definition: ParameterSet.h:47
GEMRecHitValidation::matchRecHitAgainstSimHit
Bool_t matchRecHitAgainstSimHit(GEMRecHitCollection::const_iterator, Int_t)
Definition: GEMRecHitValidation.cc:177
GEMBaseValidation::eta_range_
std::vector< Double_t > eta_range_
Definition: GEMBaseValidation.h:87
GEMDetId
Definition: GEMDetId.h:18
edm::RangeMap::const_iterator
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88272
GEMRecHitValidation::me_simhit_occ_eta_
MEMap1Ids me_simhit_occ_eta_
Definition: GEMRecHitValidation.h:42
GEMRecHitValidation::simhit_token_
edm::EDGetTokenT< edm::PSimHitContainer > simhit_token_
Definition: GEMRecHitValidation.h:19
GEMRecHitValidation::me_residual_y_
MEMap1Ids me_residual_y_
Definition: GEMRecHitValidation.h:28
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
GEMRecHitValidation::me_rechit_occ_phi_
MEMap2Ids me_rechit_occ_phi_
Definition: GEMRecHitValidation.h:47
chambers
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
GEMRecHitValidation::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: GEMRecHitValidation.cc:21
GEMBaseValidation
Definition: GEMBaseValidation.h:18
GEMRecHitValidation::me_residual_x_
MEMap1Ids me_residual_x_
Definition: GEMRecHitValidation.h:27
GEMRecHitValidation::GEMRecHitValidation
GEMRecHitValidation(const edm::ParameterSet &)
Definition: GEMRecHitValidation.cc:6
edm::EventSetup
Definition: EventSetup.h:57
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
GEMRecHitValidation::me_rechit_occ_eta_
MEMap1Ids me_rechit_occ_eta_
Definition: GEMRecHitValidation.h:46
gem
Definition: AMC13Event.h:6
GEMRecHitValidation::me_detail_residual_y_
MEMap3Ids me_detail_residual_y_
Definition: GEMRecHitValidation.h:30
GEMRecHitValidation::me_cls_
MonitorElement * me_cls_
Definition: GEMRecHitValidation.h:24
edm::RangeMap::range
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
writedatasetfile.run
run
Definition: writedatasetfile.py:27
GEMRecHitValidation::geomTokenBeginRun_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geomTokenBeginRun_
Definition: GEMRecHitValidation.h:21
GEMRecHitValidation::geomToken_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geomToken_
Definition: GEMRecHitValidation.h:20
GEMRecHitValidation::me_occ_zr_
MEMap1Ids me_occ_zr_
Definition: GEMRecHitValidation.h:38
GEMBaseValidation::bookPolarOccupancy
dqm::impl::MonitorElement * bookPolarOccupancy(DQMStore::IBooker &booker, const T &key, const char *name_prefix, const char *title_prefix)
Definition: GEMBaseValidation.h:146
BoundPlane
GEMRecHitValidation::me_pull_y_
MEMap1Ids me_pull_y_
Definition: GEMRecHitValidation.h:33
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
ME3IdsKey
std::tuple< Int_t, Int_t, Int_t > ME3IdsKey
Definition: GEMValidationUtils.h:19
dqm::implementation::IBooker
Definition: DQMStore.h:43
GEMGeometry
Definition: GEMGeometry.h:24
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
GEMRecHitValidation::me_simhit_occ_det_
MEMap2Ids me_simhit_occ_det_
Definition: GEMRecHitValidation.h:44
GEMRecHitValidation::me_simhit_occ_phi_
MEMap2Ids me_simhit_occ_phi_
Definition: GEMRecHitValidation.h:43
GEMRecHitValidation::~GEMRecHitValidation
~GEMRecHitValidation() override
Definition: GEMRecHitValidation.cc:19
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
edm::InputTag
Definition: InputTag.h:15
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
GEMBaseValidation::getDetOccBinX
Int_t getDetOccBinX(Int_t chamber_id, Int_t layer_id)
Definition: GEMBaseValidation.cc:23
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
GEMBaseValidation::kLogCategory_
const std::string kLogCategory_
Definition: GEMBaseValidation.h:92
GEMRecHitValidation.h