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";
34 me_cls_ = booker.
book1D(
"cls", cls_title +
";" + cls_x_title +
";" +
"Entries", 10, 0.5, 10.5);
36 for (
const auto&
station :
gem->regions()[0]->stations()) {
37 Int_t station_id =
station->station();
38 for (
const auto& roll :
station->superChambers()[0]->chambers()[0]->etaPartitions()) {
39 Int_t
ieta = roll->id().ieta();
42 Form(
"Cluster Size Distribution : GE%d1 iEta %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();
79 for (
const auto&
station :
gem->regions()[0]->stations()) {
80 Int_t station_id =
station->station();
81 for (
const auto& roll :
station->superChambers()[0]->chambers()[0]->etaPartitions()) {
82 Int_t
ieta = roll->id().ieta();
86 Form(
"Residual in X : GE%d1 iEta %d; Residual in X [cm]", station_id,
ieta),
92 Form(
"Residual in Y : GE%d1 iEta %d; Residual in Y [cm]", station_id,
ieta),
98 Form(
"residual_rphi_GE%d1_iEta%d", station_id,
ieta),
99 Form(
"Residual in R #times #phi : GE%d1 iEta %d; Residual in r #times #phi [cm]", station_id,
ieta),
107 for (
const auto&
region :
gem->regions()) {
108 Int_t region_id =
region->region();
111 Int_t station_id =
station->station();
113 const auto& superChamberVec =
station->superChambers();
114 if (!superChamberVec.empty() && superChamberVec[0] !=
nullptr) {
116 Int_t layer_id =
chamber->id().layer();
118 for (
const auto& roll :
chamber->etaPartitions()) {
119 Int_t
ieta = roll->id().ieta();
123 bookHist1D(booker, key4,
"residual_x",
"Residual in x", 60, -2, 2,
"Residual in x [cm]");
126 bookHist1D(booker, key4,
"residual_y",
"Residual in y", 60, -15, 15,
"Residual in y [cm]");
131 "Residual in r #times #phi",
135 "Residual in r #times #phi [cm]");
147 for (
const auto&
station :
gem->regions()[0]->stations()) {
148 Int_t station_id =
station->station();
149 for (
const auto& roll :
station->superChambers()[0]->chambers()[0]->etaPartitions()) {
150 Int_t
ieta = roll->id().ieta();
154 Form(
"Pull in X : GE%d1 iEta %d", station_id,
ieta),
160 Form(
"Pull in Y : GE%d1 iEta %d", station_id,
ieta),
167 for (
const auto&
region :
gem->regions()) {
168 Int_t region_id =
region->region();
171 Int_t station_id =
station->station();
173 const auto& superChamberVec =
station->superChambers();
174 if (!superChamberVec.empty() && superChamberVec[0] !=
nullptr) {
176 Int_t layer_id =
chamber->id().layer();
178 for (
const auto& roll :
chamber->etaPartitions()) {
179 Int_t
ieta = roll->id().ieta();
194 for (
const auto&
region :
gem->regions()) {
195 Int_t region_id =
region->region();
201 Int_t station_id =
station->station();
208 const auto& superChamberVec =
station->superChambers();
209 if (!superChamberVec.empty() && superChamberVec[0] !=
nullptr) {
211 Int_t layer_id =
chamber->id().layer();
212 ME3IdsKey key3{region_id, station_id, layer_id};
214 Int_t num_eta_partitions =
chamber->nEtaPartitions();
217 bookHist1D(booker, key3,
"total_rechit",
"Number of rec hits per event", 25, -0.5, 24.5);
224 "Rechit Occupancy per eta partition",
227 num_eta_partitions + 0.5);
229 me_occ_phi_[key3] =
bookHist1D(booker, key3,
"rechit_occ_phi",
"Rechit Phi Occupancy", 108, -5, 355);
233 "matched_rechit_occ_eta",
234 "Matched RecHit Eta Occupancy",
241 bookHist1D(booker, key3,
"matched_rechit_occ_phi",
"Matched RecHit Phi Occupancy", 36, -5, 355,
"#phi");
255 Int_t cls = rechit->clusterSize();
256 Int_t rechit_first_strip = rechit->firstClusterStrip();
259 return simhit_strip == rechit_first_strip;
261 Int_t rechit_last_strip = rechit_first_strip + cls - 1;
262 return (simhit_strip >= rechit_first_strip) and (simhit_strip <= rechit_last_strip);
271 if (not digiSimLink.
isValid()) {
278 if (not simhit_container.
isValid()) {
285 if (not rechit_collection.
isValid()) {
290 std::map<ME3IdsKey, Int_t> total_rechit;
291 for (
const auto& rechit : *rechit_collection) {
293 Int_t region_id = gem_id.
region();
294 Int_t station_id = gem_id.station();
295 Int_t layer_id = gem_id.layer();
296 Int_t
ieta = gem_id.ieta();
301 ME3IdsKey key3{region_id, station_id, layer_id};
304 GlobalPoint&& rechit_global_pos = surface.toGlobal(rechit.localPosition());
306 Float_t rechit_g_x = rechit_global_pos.
x();
307 Float_t rechit_g_y = rechit_global_pos.
y();
308 Float_t rechit_g_abs_z = std::fabs(rechit_global_pos.
z());
309 Float_t rechit_g_r = rechit_global_pos.
perp();
310 Float_t rechit_g_phi =
toDegree(rechit_global_pos.
phi());
312 Int_t first_strip = rechit.firstClusterStrip();
313 Int_t cls = rechit.clusterSize();
314 cls = cls > 10 ? 10 : cls;
319 total_rechit[key3]++;
330 auto links = digiSimLink->find(gem_id);
332 if (
links == digiSimLink->end())
334 std::map<Int_t, Int_t> pid_count;
338 Int_t link_strip =
link.getStrip();
339 if (link_strip ==
strip) {
340 Int_t pid =
link.getParticleType();
348 for (
auto& [pid,
count] : pid_count) {
349 if (max_count <
count) {
358 for (
auto [
key, num_total_rechit] : total_rechit) {
363 for (
const auto& simhit : *simhit_container.
product()) {
364 if (
gem->idToDet(simhit.detUnitId()) ==
nullptr) {
369 GEMDetId simhit_gemid{simhit.detUnitId()};
370 const BoundPlane& surface =
gem->idToDet(simhit_gemid)->surface();
372 Int_t region_id = simhit_gemid.region();
373 Int_t station_id = simhit_gemid.station();
374 Int_t layer_id = simhit_gemid.layer();
375 Int_t chamber_id = simhit_gemid.chamber();
376 Int_t
ieta = simhit_gemid.ieta();
377 Int_t num_layers = simhit_gemid.nlayers();
381 ME3IdsKey key3{region_id, station_id, layer_id};
384 const LocalPoint& simhit_local_pos = simhit.localPosition();
385 const GlobalPoint& simhit_global_pos = surface.toGlobal(simhit_local_pos);
387 Float_t simhit_g_abs_eta = std::fabs(simhit_global_pos.
eta());
388 Float_t simhit_g_phi =
toDegree(simhit_global_pos.
phi());
390 Int_t det_occ_bin_x =
getDetOccBinX(num_layers, chamber_id, layer_id);
392 auto simhit_trackId = simhit.trackId();
394 auto links = digiSimLink->find(simhit_gemid);
395 if (
links == digiSimLink->end())
398 Int_t simhit_strip = -1;
400 if (simhit_trackId ==
link.getTrackId()) {
401 simhit_strip =
link.getStrip();
407 for (
auto rechit =
range.first; rechit !=
range.second; ++rechit) {
408 if (
gem->idToDet(rechit->gemId()) ==
nullptr) {
417 const LocalPoint& rechit_local_pos = rechit->localPosition();
419 Float_t resolution_x =
std::sqrt(rechit->localPositionError().xx());
420 Float_t resolution_y =
std::sqrt(rechit->localPositionError().yy());
422 Float_t residual_x = rechit_local_pos.
x() - simhit_local_pos.
x();
423 Float_t residual_y = rechit_local_pos.
y() - simhit_local_pos.
y();
424 Float_t residual_r =
sqrt(
pow(residual_x, 2) +
pow(residual_y, 2));
425 Float_t residual_phi = rechit_local_pos.
phi() - simhit_local_pos.
phi();
426 Float_t residual_rphi = residual_r * residual_phi;
428 Float_t pull_x = residual_x / resolution_x;
429 Float_t pull_y = residual_y / resolution_y;