8 const auto& rechit_pset =
pset.getParameterSet(
"gemRecHit");
9 const auto& rechit_tag = rechit_pset.getParameter<
edm::InputTag>(
"inputTag");
12 const auto& simhit_pset =
pset.getParameterSet(
"gemSimHit");
13 const auto& simhit_tag = simhit_pset.getParameter<
edm::InputTag>(
"inputTag");
19 geomToken_ = esConsumes<GEMGeometry, MuonGeometryRecord>();
20 geomTokenBeginRun_ = esConsumes<GEMGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
31 TString cls_title =
"Cluster Size Distribution";
32 TString cls_x_title =
"Cluster size";
37 for (
const auto&
station :
gem->regions()[0]->stations()) {
38 Int_t station_id =
station->station();
39 for (
const auto& roll :
station->superChambers()[0]->chambers()[0]->etaPartitions()) {
40 Int_t
ieta = roll->id().ieta();
43 Form(
"Cluster Size Distribution : GE%d1-E%d", station_id,
ieta),
50 for (
const auto&
region :
gem->regions()) {
51 Int_t region_id =
region->region();
54 Int_t station_id =
station->station();
56 const auto& superChamberVec =
station->superChambers();
57 if (superChamberVec.empty() || superChamberVec[0] ==
nullptr) {
59 <<
" and station = " << station_id;
62 Int_t layer_id =
chamber->id().layer();
64 for (
const auto& roll :
chamber->etaPartitions()) {
65 Int_t
ieta = roll->id().ieta();
77 for (
const auto&
station :
gem->regions()[0]->stations()) {
78 Int_t station_id =
station->station();
79 for (
const auto& roll :
station->superChambers()[0]->chambers()[0]->etaPartitions()) {
80 Int_t
ieta = roll->id().ieta();
84 Form(
"Residual in Y : GE%d1-E%d; Residual in Y [cm]", station_id,
ieta),
90 booker.
book1D(Form(
"residual_rphi_GE%d1-E%d", station_id,
ieta),
91 Form(
"Residual in R #times #phi : GE%d1-E%d; Residual in r #times #phi [cm]", station_id,
ieta),
99 for (
const auto&
region :
gem->regions()) {
100 Int_t region_id =
region->region();
103 Int_t station_id =
station->station();
105 const auto& superChamberVec =
station->superChambers();
106 if (!superChamberVec.empty() && superChamberVec[0] !=
nullptr) {
108 Int_t layer_id =
chamber->id().layer();
110 for (
const auto& roll :
chamber->etaPartitions()) {
111 Int_t
ieta = roll->id().ieta();
115 bookHist1D(booker, key4,
"residual_y",
"Residual in y", 60, -15, 15,
"Residual in y [cm]");
120 "Residual in r #times #phi",
124 "Residual in r #times #phi [cm]");
134 for (
const auto&
station :
gem->regions()[0]->stations()) {
135 Int_t station_id =
station->station();
136 for (
const auto& roll :
station->superChambers()[0]->chambers()[0]->etaPartitions()) {
137 Int_t
ieta = roll->id().ieta();
141 Form(
"pull_x_GE%d1-E%d", station_id,
ieta), Form(
"Pull in X : GE%d1-E%d", station_id,
ieta), 60, -3, 3);
144 Form(
"pull_y_GE%d1-E%d", station_id,
ieta), Form(
"Pull in Y : GE%d1-E%d", station_id,
ieta), 60, -3, 3);
148 for (
const auto&
region :
gem->regions()) {
149 Int_t region_id =
region->region();
152 Int_t station_id =
station->station();
154 const auto& superChamberVec =
station->superChambers();
155 if (!superChamberVec.empty() && superChamberVec[0] !=
nullptr) {
157 Int_t layer_id =
chamber->id().layer();
159 for (
const auto& roll :
chamber->etaPartitions()) {
160 Int_t
ieta = roll->id().ieta();
174 for (
const auto&
region :
gem->regions()) {
175 Int_t region_id =
region->region();
181 Int_t station_id =
station->station();
187 const auto& superChamberVec =
station->superChambers();
188 if (!superChamberVec.empty() && superChamberVec[0] !=
nullptr) {
190 Int_t layer_id =
chamber->id().layer();
191 ME3IdsKey key3{region_id, station_id, layer_id};
193 Int_t num_eta_partitions =
chamber->nEtaPartitions();
197 "sim_matched_occ_eta",
198 "Matched RecHit Eta Occupancy",
205 bookHist1D(booker, key3,
"sim_matched_occ_phi",
"Matched RecHit Phi Occupancy", 36, -5, 355,
"#phi");
209 bookHist1D(booker, key3,
"total_rechit",
"Number of rec hits per event", 25, -0.5, 24.5);
216 "Rechit Occupancy per eta partition",
219 num_eta_partitions + 0.5);
234 Int_t cls = rechit->clusterSize();
235 Int_t rechit_first_strip = rechit->firstClusterStrip();
238 return simhit_strip == rechit_first_strip;
240 Int_t rechit_last_strip = rechit_first_strip + cls - 1;
241 return (simhit_strip >= rechit_first_strip) and (simhit_strip <= rechit_last_strip);
250 if (not digiSimLink.
isValid()) {
257 if (not simhit_container.
isValid()) {
264 if (not rechit_collection.
isValid()) {
269 std::map<ME3IdsKey, Int_t> total_rechit;
270 for (
const auto& rechit : *rechit_collection) {
272 Int_t region_id = gem_id.
region();
273 Int_t station_id = gem_id.station();
274 Int_t layer_id = gem_id.layer();
275 Int_t
ieta = gem_id.ieta();
280 ME3IdsKey key3{region_id, station_id, layer_id};
283 GlobalPoint&& rechit_global_pos = surface.toGlobal(rechit.localPosition());
285 Float_t rechit_g_x = rechit_global_pos.
x();
286 Float_t rechit_g_y = rechit_global_pos.
y();
287 Float_t rechit_g_abs_z = std::fabs(rechit_global_pos.
z());
288 Float_t rechit_g_r = rechit_global_pos.
perp();
289 Float_t rechit_g_phi =
toDegree(rechit_global_pos.
phi());
291 Int_t first_strip = rechit.firstClusterStrip();
292 Int_t cls = rechit.clusterSize();
293 cls = cls > 10 ? 10 : cls;
295 total_rechit[key3]++;
308 auto links = digiSimLink->find(gem_id);
310 if (
links == digiSimLink->end())
312 std::map<Int_t, Int_t> pid_count;
316 Int_t link_strip =
link.getStrip();
317 if (link_strip ==
strip) {
318 Int_t pid =
link.getParticleType();
327 for (
auto& [pid,
count] : pid_count) {
328 if (max_count <
count) {
339 for (
auto [
key, num_total_rechit] : total_rechit) {
345 for (
const auto& simhit : *simhit_container.
product()) {
346 if (
gem->idToDet(simhit.detUnitId()) ==
nullptr) {
351 GEMDetId simhit_gemid{simhit.detUnitId()};
352 const BoundPlane& surface =
gem->idToDet(simhit_gemid)->surface();
354 Int_t region_id = simhit_gemid.region();
355 Int_t station_id = simhit_gemid.station();
356 Int_t layer_id = simhit_gemid.layer();
357 Int_t chamber_id = simhit_gemid.chamber();
358 Int_t
ieta = simhit_gemid.ieta();
359 Int_t num_layers = simhit_gemid.nlayers();
363 ME3IdsKey key3{region_id, station_id, layer_id};
366 const LocalPoint& simhit_local_pos = simhit.localPosition();
367 const GlobalPoint& simhit_global_pos = surface.toGlobal(simhit_local_pos);
369 Float_t simhit_g_abs_eta = std::fabs(simhit_global_pos.
eta());
370 Float_t simhit_g_phi =
toDegree(simhit_global_pos.
phi());
372 Int_t det_occ_bin_x =
getDetOccBinX(num_layers, chamber_id, layer_id);
374 auto simhit_trackId = simhit.trackId();
376 auto links = digiSimLink->find(simhit_gemid);
377 if (
links == digiSimLink->end())
380 Int_t simhit_strip = -1;
382 if (simhit_trackId ==
link.getTrackId()) {
383 simhit_strip =
link.getStrip();
389 for (
auto rechit =
range.first; rechit !=
range.second; ++rechit) {
390 if (
gem->idToDet(rechit->gemId()) ==
nullptr) {
399 const LocalPoint& rechit_local_pos = rechit->localPosition();
401 Float_t resolution_x =
std::sqrt(rechit->localPositionError().xx());
402 Float_t resolution_y =
std::sqrt(rechit->localPositionError().yy());
404 Float_t residual_x = rechit_local_pos.
x() - simhit_local_pos.
x();
405 Float_t residual_y = rechit_local_pos.
y() - simhit_local_pos.
y();
406 Float_t residual_r =
sqrt(
pow(residual_x, 2) +
pow(residual_y, 2));
407 Float_t residual_phi = rechit_local_pos.
phi() - simhit_local_pos.
phi();
408 Float_t residual_rphi = residual_r * residual_phi;
410 Float_t pull_x = residual_x / resolution_x;
411 Float_t pull_y = residual_y / resolution_y;
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")
Bool_t matchRecHitAgainstSimHit(GEMRecHitCollection::const_iterator, Int_t)
MEMap3Ids me_detail_occ_phi_
std::pair< const_iterator, const_iterator > range
iterator range
constexpr int region() const
MEMap2Ids me_detail_rechit_occ_det_
MEMap2Ids me_detail_pull_y_
MEMap2Ids me_residual_rphi_
MEMap2Ids me_detail_cls_roll_
virtual void setCurrentFolder(std::string const &fullpath)
~GEMRecHitValidation() override
Geom::Phi< T > phi() const
MEMap3Ids me_detail_occ_xy_
Bool_t isMuonSimHit(const PSimHit &)
std::tuple< Int_t, Int_t, Int_t, Int_t > ME4IdsKey
T const * product() const
MonitorElement * me_detail_cls_total_
Log< level::Error, false > LogError
dqm::impl::MonitorElement * bookZROccupancy(DQMStore::IBooker &booker, Int_t region_id, const char *name_prfix, const char *title_prefix)
MEMap3Ids me_detail_total_rechit_
C::const_iterator const_iterator
constant access iterator type
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geomTokenBeginRun_
MEMap3Ids me_rechit_occ_phi_
dqm::impl::MonitorElement * bookXYOccupancy(DQMStore::IBooker &booker, const T &key, const char *name_prefix, const char *title_prefix)
MEMap4Ids me_detail_pull_x_la_
MEMap2Ids me_detail_pull_x_
Int_t getPidIdx(Int_t pid)
std::vector< Double_t > eta_range_
edm::EDGetTokenT< edm::PSimHitContainer > simhit_token_
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< edm::DetSetVector< GEMDigiSimLink > > digisimlink_token_
MEMap1Ids me_detail_occ_zr_
edm::EDGetTokenT< GEMRecHitCollection > rechit_token_
MEMap4Ids me_detail_residual_rphi_
MEMap4Ids me_detail_pull_y_la_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MEMap3Ids me_detail_occ_ieta_
MEMap3Ids me_detail_occ_pid_
GEMRecHitValidation(const edm::ParameterSet &)
std::tuple< Int_t, Int_t > ME2IdsKey
Float_t toDegree(Float_t radian)
std::tuple< Int_t, Int_t, Int_t > ME3IdsKey
MEMap4Ids me_detail_residual_y_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
static char chambers[264][20]
Int_t getDetOccBinX(Int_t num_layers, Int_t chamber_id, Int_t layer_id)
MEMap3Ids me_rechit_occ_eta_
MEMap3Ids me_detail_occ_polar_
dqm::impl::MonitorElement * bookPIDHist(DQMStore::IBooker &booker, const T &key, const char *name, const char *title)
const std::string kLogCategory_
dqm::impl::MonitorElement * bookPolarOccupancy(DQMStore::IBooker &booker, const T &key, const char *name_prefix, const char *title_prefix)
Power< A, B >::type pow(const A &a, const B &b)
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geomToken_
dqm::impl::MonitorElement * bookDetectorOccupancy(DQMStore::IBooker &booker, const T &key, const GEMStation *station, const char *name_prfix, const char *title_prefix)