CMS 3D CMS Logo

GEMPadDigiValidation.cc
Go to the documentation of this file.
2 
4  : GEMBaseValidation(pset, "GEMPadDigiValidation") {
5  const auto& pad_pset = pset.getParameterSet("gemPadDigi");
6  const auto& pad_tag = pad_pset.getParameter<edm::InputTag>("inputTag");
7  pad_token_ = consumes<GEMPadDigiCollection>(pad_tag);
8 
9  const auto& simhit_pset = pset.getParameterSet("gemSimHit");
10  const auto& simhit_tag = simhit_pset.getParameter<edm::InputTag>("inputTag");
11  simhit_token_ = consumes<edm::PSimHitContainer>(simhit_tag);
12 
13  const auto& digisimlink_tag = pset.getParameter<edm::InputTag>("gemDigiSimLink");
14  digisimlink_token_ = consumes<edm::DetSetVector<GEMDigiSimLink>>(digisimlink_tag);
15 
16  geomToken_ = esConsumes<GEMGeometry, MuonGeometryRecord>();
17  geomTokenBeginRun_ = esConsumes<GEMGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
18 }
19 
21  edm::Run const& Run,
22  edm::EventSetup const& setup) {
23  const GEMGeometry* gem = &setup.getData(geomTokenBeginRun_);
24 
25  // NOTE Occupancy
26  booker.setCurrentFolder("MuonGEMDigisV/GEMDigisTask/Pad/Occupancy");
27 
28  for (const auto& region : gem->regions()) {
29  Int_t region_id = region->region();
30 
31  if (detail_plot_)
32  me_detail_occ_zr_[region_id] = bookZROccupancy(booker, region_id, "pad", "Pad");
33 
34  for (const auto& station : region->stations()) {
35  Int_t station_id = station->station();
36  ME2IdsKey key2(region_id, station_id);
37 
38  if (detail_plot_) {
39  me_detail_occ_det_[key2] = bookDetectorOccupancy(booker, key2, station, "pad", "Pad");
40  me_detail_pad_occ_det_[key2] = bookDetectorOccupancy(booker, key2, station, "matched_pad", "Matched Pad");
41  }
42 
43  const auto& superChamberVec = station->superChambers();
44  if (superChamberVec.empty()) {
45  edm::LogError(kLogCategory_) << "Super chambers missing for region = " << region_id
46  << " and station = " << station_id;
47  continue;
48  }
49  const GEMSuperChamber* super_chamber = superChamberVec.front();
50  if (super_chamber == nullptr) {
51  edm::LogError(kLogCategory_) << "Failed to find super chamber for region = " << region_id
52  << " and station = " << station_id;
53  continue;
54  }
55  for (const auto& chamber : super_chamber->chambers()) {
56  Int_t layer_id = chamber->id().layer();
57  ME3IdsKey key3(region_id, station_id, layer_id);
58 
59  const auto& etaPartitionVec = chamber->etaPartitions();
60  if (etaPartitionVec.empty() || etaPartitionVec.front() == nullptr) {
62  << "Eta partition missing or null for region, station, super chamber, chamber = (" << region_id << ", "
63  << station_id << ", " << super_chamber->id() << ", " << chamber->id() << ")";
64  continue;
65  }
66  Int_t num_pads = etaPartitionVec.front()->npads();
67 
68  me_occ_total_pad_[key3] =
69  bookHist1D(booker, key3, "total_pads_per_event", "Number of pad digis per event", 51, -0.5, 50);
70 
71  me_pad_occ_eta_[key3] = bookHist1D(booker,
72  key3,
73  "matched_pad_occ_eta",
74  "Matched Pad Eta Occupancy",
75  16,
76  eta_range_[station_id * 2 + 0],
77  eta_range_[station_id * 2 + 1],
78  "#eta");
79 
80  me_pad_occ_phi_[key3] =
81  bookHist1D(booker, key3, "matched_pad_occ_phi", "Matched Pad Phi Occupancy", 36, -5, 355, "#phi [degrees]");
82 
83  if (detail_plot_) {
84  me_detail_occ_xy_[key3] = bookXYOccupancy(booker, key3, "pad", "Pad");
85 
86  me_detail_occ_phi_pad_[key3] = bookHist2D(booker,
87  key3,
88  "occ_phi_pad",
89  "Pad Occupancy",
90  280,
91  -M_PI,
92  M_PI,
93  num_pads / 2,
94  0,
95  num_pads,
96  "#phi [rad]",
97  "Pad number");
98 
99  me_detail_occ_pad_[key3] =
100  bookHist1D(booker, key3, "occ_pad", "Pad Occupancy", num_pads, 0.5, num_pads + 0.5, "Pad number");
101  }
102  } // layer loop
103  } // station loop
104  } // region loop
105 
106  // NOTE Bunch Crossing
107  if (detail_plot_) {
108  booker.setCurrentFolder("MuonGEMDigisV/GEMDigisTask/Pad/BunchCrossing");
109 
110  for (const auto& region : gem->regions()) {
111  Int_t region_id = region->region();
112  for (const auto& station : region->stations()) {
113  Int_t station_id = station->station();
114 
115  const auto& superChamberVec = station->superChambers();
116  if (superChamberVec.empty()) {
117  edm::LogError(kLogCategory_) << "Super chambers missing for region = " << region_id
118  << " and station = " << station_id;
119  continue;
120  }
121  const GEMSuperChamber* super_chamber = superChamberVec.front();
122  if (super_chamber == nullptr) {
123  edm::LogError(kLogCategory_) << "Failed to find super chamber for region = " << region_id
124  << " and station = " << station_id;
125  continue;
126  }
127  for (const auto& chamber : super_chamber->chambers()) {
128  Int_t layer_id = chamber->id().layer();
129  ME3IdsKey key3(region_id, station_id, layer_id);
130 
131  me_detail_bx_[key3] = bookHist1D(booker, key3, "bx", "Pad Bunch Crossing", 5, -2.5, 2.5, "Bunch crossing");
132  } // chamber loop
133  } // station loop
134  } // region loop
135  } // detail plot
136 }
137 
139 
141  const GEMGeometry* gem = &setup.getData(geomToken_);
142 
144  event.getByToken(pad_token_, collection);
145  if (not collection.isValid()) {
146  edm::LogError(kLogCategory_) << "Cannot get pads by label GEMPadToken.";
147  return;
148  }
149 
151  event.getByToken(digisimlink_token_, digiSimLink);
152  if (not digiSimLink.isValid()) {
153  edm::LogError(kLogCategory_) << "Failed to get GEMDigiSimLink." << std::endl;
154  return;
155  }
156 
157  edm::Handle<edm::PSimHitContainer> simhit_container;
158  event.getByToken(simhit_token_, simhit_container);
159  if (not simhit_container.isValid()) {
160  edm::LogError(kLogCategory_) << "Failed to get PSimHitContainer." << std::endl;
161  return;
162  }
163 
164  std::map<ME3IdsKey, Int_t> total_pad;
165  for (const auto& pad_pair : *collection) {
166  GEMDetId gemid = pad_pair.first;
167  const auto& range = pad_pair.second;
168 
169  if (gem->idToDet(gemid) == nullptr) {
170  edm::LogError(kLogCategory_) << "Getting DetId failed. Discard this gem pad hit. "
171  << "Maybe it comes from unmatched geometry." << std::endl;
172  continue;
173  }
174 
175  const GEMEtaPartition* roll = gem->etaPartition(gemid);
176  const BoundPlane& surface = roll->surface();
177 
178  Int_t region_id = gemid.region();
179  Int_t station_id = gemid.station();
180  Int_t layer_id = gemid.layer();
181  Int_t chamber_id = gemid.chamber();
182  Int_t ieta = gemid.ieta();
183  Int_t num_layers = gemid.nlayers();
184 
185  ME2IdsKey key2(region_id, station_id);
186  ME3IdsKey key3(region_id, station_id, layer_id);
187 
188  for (auto digi = range.first; digi != range.second; ++digi) {
189  // ignore 16-partition GE2/1 pads
190  if (gemid.isGE21() and digi->nPartitions() == GEMPadDigi::GE21SplitStrip)
191  continue;
192 
193  total_pad[key3]++;
194 
195  Int_t pad = digi->pad();
196  Int_t bx = digi->bx();
197 
198  const LocalPoint& local_pos = roll->centreOfPad(pad);
199  const GlobalPoint& global_pos = surface.toGlobal(local_pos);
200 
201  Float_t g_r = global_pos.perp();
202  Float_t g_phi = global_pos.phi();
203  Float_t g_x = global_pos.x();
204  Float_t g_y = global_pos.y();
205  Float_t g_abs_z = std::fabs(global_pos.z());
206 
207  Int_t bin_x = getDetOccBinX(num_layers, chamber_id, layer_id);
208 
209  if (detail_plot_) {
210  me_detail_occ_zr_[region_id]->Fill(g_abs_z, g_r);
211  me_detail_occ_xy_[key3]->Fill(g_x, g_y);
212  me_detail_occ_phi_pad_[key3]->Fill(g_phi, pad);
213  me_detail_occ_pad_[key3]->Fill(pad);
214  me_detail_occ_det_[key2]->Fill(bin_x, ieta);
215  me_detail_bx_[key3]->Fill(bx);
216  } // if detail_plot
217  } // digi loop
218  } // range loop
219 
220  for (const auto& region : gem->regions()) {
221  Int_t region_id = region->region();
222  for (const auto& station : region->stations()) {
223  Int_t station_id = station->station();
224  const auto& superChamberVec = station->superChambers();
225  if (superChamberVec.empty()) {
226  edm::LogError(kLogCategory_) << "Super chambers missing for region = " << region_id
227  << " and station = " << station_id;
228  continue;
229  }
230  const GEMSuperChamber* super_chamber = superChamberVec.front();
231  if (super_chamber == nullptr) {
232  edm::LogError(kLogCategory_) << "Failed to find super chamber for region = " << region_id
233  << " and station = " << station_id;
234  continue;
235  }
236  for (const auto& chamber : super_chamber->chambers()) {
237  Int_t layer_id = chamber->id().layer();
238  ME3IdsKey key3{region_id, station_id, layer_id};
239  me_occ_total_pad_[key3]->Fill(total_pad[key3]);
240  }
241  }
242  }
243 
244  // NOTE
245  for (const auto& simhit : *simhit_container.product()) {
246  if (not isMuonSimHit(simhit))
247  continue;
248  if (gem->idToDet(simhit.detUnitId()) == nullptr) {
249  edm::LogError(kLogCategory_) << "SimHit did not match with GEMGeometry." << std::endl;
250  continue;
251  }
252 
253  GEMDetId simhit_gemid(simhit.detUnitId());
254 
255  Int_t region_id = simhit_gemid.region();
256  Int_t station_id = simhit_gemid.station();
257  Int_t layer_id = simhit_gemid.layer();
258  Int_t chamber_id = simhit_gemid.chamber();
259  Int_t ieta = simhit_gemid.ieta();
260  Int_t num_layers = simhit_gemid.nlayers();
261 
262  ME2IdsKey key2{region_id, station_id};
263  ME3IdsKey key3{region_id, station_id, layer_id};
264 
265  const GEMEtaPartition* roll = gem->etaPartition(simhit_gemid);
266 
267  const auto& simhit_local_pos = simhit.localPosition();
268  const auto& simhit_global_pos = roll->surface().toGlobal(simhit_local_pos);
269 
270  Float_t simhit_g_eta = std::abs(simhit_global_pos.eta());
271  Float_t simhit_g_phi = toDegree(simhit_global_pos.phi());
272 
273  auto simhit_trackId = simhit.trackId();
274 
275  Int_t bin_x = getDetOccBinX(num_layers, chamber_id, layer_id);
276 
277  auto links = digiSimLink->find(simhit_gemid);
278  if (links == digiSimLink->end())
279  continue;
280 
281  Int_t simhit_strip = -1;
282  for (const auto& link : *links) {
283  if (simhit_trackId == link.getTrackId()) {
284  simhit_strip = link.getStrip();
285  break;
286  }
287  }
288  Int_t simhit_pad = roll->padOfStrip(simhit_strip);
289  auto range = collection->get(simhit_gemid);
290  for (auto pad = range.first; pad != range.second; ++pad) {
291  if (pad->pad() == simhit_pad) {
292  me_pad_occ_eta_[key3]->Fill(simhit_g_eta);
293  me_pad_occ_phi_[key3]->Fill(simhit_g_phi);
294  if (detail_plot_) {
295  me_detail_pad_occ_det_[key2]->Fill(bin_x, ieta);
296  }
297  break;
298  }
299  }
300  } // simhit_container loop
301 }
ME2IdsKey
std::tuple< Int_t, Int_t > ME2IdsKey
Definition: GEMValidationUtils.h:16
GEMPadDigiValidation::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: GEMPadDigiValidation.cc:20
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
GEMDetId::isGE21
bool isGE21() const
Definition: GEMDetId.cc:11
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:240
GEMSuperChamber::chambers
const std::vector< const GEMChamber * > & chambers() const
Return the chambers in the super chamber.
Definition: GEMSuperChamber.cc:23
GEMPadDigiValidation::me_pad_occ_phi_
MEMap3Ids me_pad_occ_phi_
Definition: GEMPadDigiValidation.h:28
edm::Handle::product
T const * product() const
Definition: Handle.h:70
MainPageGenerator.link
link
Definition: MainPageGenerator.py:271
GEMPadDigiValidation::geomTokenBeginRun_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geomTokenBeginRun_
Definition: GEMPadDigiValidation.h:23
GEMBaseValidation::detail_plot_
Bool_t detail_plot_
Definition: GEMBaseValidation.h:95
GEMSuperChamber
Definition: GEMSuperChamber.h:19
GEMDetId::layer
constexpr int layer() const
Definition: GEMDetId.h:190
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
edm::Run
Definition: Run.h:45
GEMDetId::region
constexpr int region() const
Definition: GEMDetId.h:171
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:168
relativeConstraints.station
station
Definition: relativeConstraints.py:67
GEMEtaPartition
Definition: GEMEtaPartition.h:12
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
GEMPadDigiValidation::geomToken_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geomToken_
Definition: GEMPadDigiValidation.h:22
GEMPadDigiValidation::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: GEMPadDigiValidation.cc:140
edm::Handle< GEMPadDigiCollection >
GEMDetId::nlayers
constexpr int nlayers() const
Definition: GEMDetId.h:213
GEMPadDigi::GE21SplitStrip
Definition: GEMPadDigi.h:22
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
GEMPadDigiValidation::me_occ_total_pad_
MEMap3Ids me_occ_total_pad_
Definition: GEMPadDigiValidation.h:26
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
GEMBaseValidation::isMuonSimHit
Bool_t isMuonSimHit(const PSimHit &)
Definition: GEMBaseValidation.cc:28
GEMBaseValidation::bookZROccupancy
dqm::impl::MonitorElement * bookZROccupancy(DQMStore::IBooker &booker, Int_t region_id, const char *name_prfix, const char *title_prefix)
Definition: GEMBaseValidation.cc:42
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
GEMPadDigiValidation::me_detail_occ_xy_
MEMap3Ids me_detail_occ_xy_
Definition: GEMPadDigiValidation.h:31
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
GEMPadDigiValidation::me_detail_occ_pad_
MEMap3Ids me_detail_occ_pad_
Definition: GEMPadDigiValidation.h:34
GEMBaseValidation::bookXYOccupancy
dqm::impl::MonitorElement * bookXYOccupancy(DQMStore::IBooker &booker, const T &key, const char *name_prefix, const char *title_prefix)
Definition: GEMBaseValidation.h:141
Point3DBase< float, LocalTag >
GEMPadDigiValidation::simhit_token_
edm::EDGetTokenT< edm::PSimHitContainer > simhit_token_
Definition: GEMPadDigiValidation.h:20
GEMPadDigiValidation::~GEMPadDigiValidation
~GEMPadDigiValidation() override
Definition: GEMPadDigiValidation.cc:138
GEMBaseValidation::bookHist2D
dqm::impl::MonitorElement * bookHist2D(DQMStore::IBooker &booker, const T &key, const char *name, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, const char *x_title="", const char *y_title="")
Definition: GEMBaseValidation.h:257
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
GEMDetId::chamber
constexpr int chamber() const
Definition: GEMDetId.h:183
GEMPadDigiValidation::GEMPadDigiValidation
GEMPadDigiValidation(const edm::ParameterSet &)
Definition: GEMPadDigiValidation.cc:3
edm::ParameterSet
Definition: ParameterSet.h:47
GEMBaseValidation::eta_range_
std::vector< Double_t > eta_range_
Definition: GEMBaseValidation.h:94
GEMDetId
Definition: GEMDetId.h:18
GEMPadDigiValidation::pad_token_
edm::EDGetTokenT< GEMPadDigiCollection > pad_token_
Definition: GEMPadDigiValidation.h:19
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
GEMPadDigiValidation.h
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88271
GEMPadDigiValidation::me_pad_occ_eta_
MEMap3Ids me_pad_occ_eta_
Definition: GEMPadDigiValidation.h:27
universalConfigTemplate.collection
collection
Definition: universalConfigTemplate.py:81
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
GEMBaseValidation
Definition: GEMBaseValidation.h:19
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
GEMPadDigiValidation::me_detail_occ_phi_pad_
MEMap3Ids me_detail_occ_phi_pad_
Definition: GEMPadDigiValidation.h:33
gem
Definition: AMC13Event.h:6
GEMEtaPartition::centreOfPad
LocalPoint centreOfPad(int pad) const
Definition: GEMEtaPartition.cc:45
GEMPadDigiValidation::me_detail_pad_occ_det_
MEMap2Ids me_detail_pad_occ_det_
Definition: GEMPadDigiValidation.h:30
GEMBaseValidation::toDegree
Float_t toDegree(Float_t radian)
Definition: GEMBaseValidation.cc:30
BoundPlane
electronStore.links
links
Definition: electronStore.py:149
GEMPadDigiValidation::digisimlink_token_
edm::EDGetTokenT< edm::DetSetVector< GEMDigiSimLink > > digisimlink_token_
Definition: GEMPadDigiValidation.h:21
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
GEMDetId::station
constexpr int station() const
Definition: GEMDetId.h:179
GEMPadDigiValidation::me_detail_bx_
MEMap3Ids me_detail_bx_
Definition: GEMPadDigiValidation.h:35
GEMGeometry
Definition: GEMGeometry.h:24
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
GEMEtaPartition::padOfStrip
float padOfStrip(int strip) const
returns FRACTIONAL pad number [0.,npads) for an integer strip [0,nstrip-1]
Definition: GEMEtaPartition.cc:58
GEMDetId::ieta
constexpr int ieta() const
Definition: GEMDetId.h:199
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
GEMPadDigiValidation::me_detail_occ_det_
MEMap2Ids me_detail_occ_det_
Definition: GEMPadDigiValidation.h:29
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
edm::InputTag
Definition: InputTag.h:15
GEMBaseValidation::getDetOccBinX
Int_t getDetOccBinX(Int_t num_layers, Int_t chamber_id, Int_t layer_id)
Definition: GEMBaseValidation.cc:24
GEMSuperChamber::id
GEMDetId id() const
Return the GEMDetId of this super chamber.
Definition: GEMSuperChamber.cc:11
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
GEMBaseValidation::kLogCategory_
const std::string kLogCategory_
Definition: GEMBaseValidation.h:99
GEMPadDigiValidation::me_detail_occ_zr_
MEMap1Ids me_detail_occ_zr_
Definition: GEMPadDigiValidation.h:32
Run