CMS 3D CMS Logo

GEMStripDigiValidation.cc
Go to the documentation of this file.
3 
5  : GEMBaseValidation(pset, "GEMStripDigiValidation") {
6  const auto& strip_pset = pset.getParameterSet("gemStripDigi");
7  const auto& strip_tag = strip_pset.getParameter<edm::InputTag>("inputTag");
8  strip_token_ = consumes<GEMDigiCollection>(strip_tag);
9 
10  const auto& simhit_pset = pset.getParameterSet("gemSimHit");
11  const auto& simhit_tag = simhit_pset.getParameter<edm::InputTag>("inputTag");
12  simhit_token_ = consumes<edm::PSimHitContainer>(simhit_tag);
13 
14  const auto& digisimlink_tag = pset.getParameter<edm::InputTag>("gemDigiSimLink");
15  digisimlink_token_ = consumes<edm::DetSetVector<GEMDigiSimLink>>(digisimlink_tag);
16 
17  geomToken_ = esConsumes<GEMGeometry, MuonGeometryRecord>();
18  geomTokenBeginRun_ = esConsumes<GEMGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
19 }
20 
22  edm::Run const& run,
23  edm::EventSetup const& setup) {
24  const GEMGeometry* gem = &setup.getData(geomTokenBeginRun_);
25  if (gem == nullptr) {
26  edm::LogError(kLogCategory_) << "Failed to initialize GEM geometry.";
27  return;
28  }
29 
30  // NOTE Bunch Crossing
31  booker.setCurrentFolder("MuonGEMDigisV/GEMDigisTask/Strip/BunchCrossing");
32 
33  me_bx_ = booker.book1D("strip_bx", "Strip Digi Bunch Crossing", 5, -2.5, 2.5);
34 
35  for (const auto& region : gem->regions()) {
36  if (region == nullptr) {
37  edm::LogError(kLogCategory_) << "Null region";
38  continue;
39  }
40  Int_t region_id = region->region();
41  for (const auto& station : region->stations()) {
42  if (station == nullptr) {
43  edm::LogError(kLogCategory_) << "Null station for region = " << region_id;
44  continue;
45  }
46  Int_t station_id = station->station();
47 
48  const auto& superChamberVec = station->superChambers();
49  if (superChamberVec.empty()) {
50  edm::LogError(kLogCategory_) << "Super chambers missing for region = " << region_id
51  << " and station = " << station_id;
52  continue;
53  }
54  const GEMSuperChamber* super_chamber = superChamberVec.front();
55  if (super_chamber == nullptr) {
56  edm::LogError(kLogCategory_) << "Failed to find super chamber for region = " << region_id
57  << " and station = " << station_id;
58  continue;
59  }
60  for (const auto& chamber : super_chamber->chambers()) {
61  Int_t layer_id = chamber->id().layer();
62  ME3IdsKey key3(region_id, station_id, layer_id);
63 
64  me_bx_layer_[key3] =
65  bookHist1D(booker, key3, "strip_bx", "Strip Digi Bunch Crossing", 5, -2.5, 2.5, "Bunch crossing");
66  } // chamber loop
67  } // station loop
68  } // region loop
69 
70  // NOTE Occupancy
71  booker.setCurrentFolder("MuonGEMDigisV/GEMDigisTask/Strip/Occupancy");
72 
73  me_total_strip_ = booker.book1D("total_strips_per_event", "Number of strip digi per event", 50, -0.5, 395.5);
74 
75  for (const auto& region : gem->regions()) {
76  Int_t region_id = region->region();
77 
78  if (detail_plot_)
79  me_detail_occ_zr_[region_id] = bookZROccupancy(booker, region_id, "strip", "Strip Digi");
80 
81  for (const auto& station : region->stations()) {
82  Int_t station_id = station->station();
83  ME2IdsKey key2{region_id, station_id};
84 
85  if (detail_plot_) {
87  bookHist1D(booker, key2, "total_strips_per_event", "Number of strip digs per event", 50, -0.5, 99.5);
88 
89  me_detail_occ_det_[key2] = bookDetectorOccupancy(booker, key2, station, "strip", "Strip Digi");
90 
92  bookDetectorOccupancy(booker, key2, station, "matched_strip", "Matched Strip Digi");
93  }
94 
95  const auto& superChamberVec = station->superChambers();
96  if (superChamberVec.empty() || superChamberVec[0] == nullptr) {
97  edm::LogError(kLogCategory_) << "Super chambers missing or null for region = " << region_id
98  << " and station = " << station_id;
99  } else {
100  for (const auto& chamber : superChamberVec[0]->chambers()) {
101  if (chamber == nullptr) {
102  edm::LogError(kLogCategory_) << "Null chamber for region, station, super chamber = (" << region_id << ", "
103  << station_id << ", " << superChamberVec[0]->id() << ")";
104  continue;
105  }
106  Int_t layer_id = chamber->id().layer();
107  ME3IdsKey key3{region_id, station_id, layer_id};
108 
109  const auto& etaPartitionsVec = chamber->etaPartitions();
110  if (etaPartitionsVec.empty() || etaPartitionsVec.front() == nullptr) {
112  << "Eta partition missing or null for region, station, super chamber, chamber = (" << region_id << ", "
113  << station_id << ", " << superChamberVec[0]->id() << ", " << chamber->id() << ")";
114  continue;
115  }
116 
117  me_occ_pid_[key3] = bookPIDHist(booker, key3, "strip_occ_pid", "Number of entreis for each particle");
118 
119  if (detail_plot_) {
120  Int_t num_strips = etaPartitionsVec.front()->nstrips();
121 
122  me_detail_strip_occ_eta_[key3] = bookHist1D(booker,
123  key3,
124  "matched_strip_occ_eta",
125  "Matched Strip Eta Occupancy",
126  16,
127  eta_range_[station_id * 2 + 0],
128  eta_range_[station_id * 2 + 1],
129  "#eta");
130 
132  booker, key3, "matched_strip_occ_phi", "Matched Strip Phi Occupancy", 36, -5, 355, "#phi [degrees]");
133 
134  me_detail_occ_xy_[key3] = bookXYOccupancy(booker, key3, "strip", "Strip Digi");
135 
136  me_detail_occ_strip_[key3] = bookHist1D(booker,
137  key3,
138  "strip_occ_strip",
139  "Strip Digi Occupancy per strip number",
140  num_strips,
141  0.5,
142  num_strips + 0.5,
143  "strip number");
144  }
145  } // chamber
146  } // end else
147  } // station looop
148  } // region loop
149 }
150 
152 
154  const GEMGeometry* gem = &setup.getData(geomToken_);
155  if (gem == nullptr) {
156  edm::LogError(kLogCategory_) << "Failed to initialize GEM geometry.";
157  return;
158  }
159 
161  event.getByToken(digisimlink_token_, digiSimLink);
162  if (not digiSimLink.isValid()) {
163  edm::LogError(kLogCategory_) << "Failed to get GEMDigiSimLink." << std::endl;
164  return;
165  }
166 
167  edm::Handle<edm::PSimHitContainer> simhit_container;
168  event.getByToken(simhit_token_, simhit_container);
169  if (not simhit_container.isValid()) {
170  edm::LogError(kLogCategory_) << "Failed to get PSimHitContainer." << std::endl;
171  return;
172  }
173 
174  edm::Handle<GEMDigiCollection> digi_collection;
175  event.getByToken(strip_token_, digi_collection);
176  if (not digi_collection.isValid()) {
177  edm::LogError(kLogCategory_) << "Cannot get strips by Token stripToken." << std::endl;
178  return;
179  }
180 
181  // NOTE
182  Int_t total_strip = 0;
183  std::map<ME2IdsKey, Int_t> total_strip_2IdsMap;
184  for (const auto digi_pair : *digi_collection) {
185  GEMDetId id = digi_pair.first;
186  if (gem->idToDet(id) == nullptr) {
187  edm::LogError(kLogCategory_) << "Getting DetId failed. Discard this gem strip hit. Maybe it comes "
188  << "from unmatched geometry." << std::endl;
189  continue;
190  }
191 
192  Int_t region_id = id.region();
193  Int_t layer_id = id.layer();
194  Int_t station_id = id.station();
195  Int_t chamber_id = id.chamber();
196  Int_t ieta = id.ieta();
197  Int_t num_layers = id.nlayers();
198 
199  ME2IdsKey key2{region_id, station_id};
200  ME3IdsKey key3{region_id, station_id, layer_id};
201  Int_t bin_x = getDetOccBinX(num_layers, chamber_id, layer_id);
202 
203  const BoundPlane& surface = gem->idToDet(id)->surface();
204  const GEMEtaPartition* roll = gem->etaPartition(id);
205 
206  const GEMDigiCollection::Range& range = digi_pair.second;
207  auto links = digiSimLink->find(id);
208  if (links == digiSimLink->end())
209  continue;
210 
211  for (auto digi = range.first; digi != range.second; ++digi) {
212  total_strip++;
213  total_strip_2IdsMap[key2]++;
214  Int_t strip = digi->strip();
215  Int_t bx = digi->bx();
216  bx = bx < -10 ? -10 : bx;
217  bx = bx > 10 ? 10 : bx;
218 
219  GlobalPoint strip_global_pos = surface.toGlobal(roll->centreOfStrip(strip));
220 
221  Float_t digi_g_x = strip_global_pos.x();
222  Float_t digi_g_y = strip_global_pos.y();
223  Float_t digi_g_r = strip_global_pos.perp();
224  Float_t digi_g_abs_z = std::abs(strip_global_pos.z());
225 
226  me_bx_->Fill(bx);
227  me_bx_layer_[key3]->Fill(bx);
228 
229  if (detail_plot_) {
230  me_detail_occ_zr_[region_id]->Fill(digi_g_abs_z, digi_g_r);
231  me_detail_occ_det_[key2]->Fill(bin_x, ieta);
232  me_detail_occ_xy_[key3]->Fill(digi_g_x, digi_g_y);
233  me_detail_occ_strip_[key3]->Fill(strip);
234  }
235  }
236  } // range loop
237  me_total_strip_->Fill(total_strip);
238  if (detail_plot_) {
239  for (const auto& region : gem->regions()) {
240  Int_t region_id = region->region();
241  for (const auto& station : region->stations()) {
242  Int_t station_id = station->station();
243  ME2IdsKey key2{region_id, station_id};
244  me_detail_total_strip_[key2]->Fill(total_strip_2IdsMap[key2]);
245  }
246  }
247  }
248 
249  // NOTE
250  for (const auto& simhit : *simhit_container.product()) {
251  if (gem->idToDet(simhit.detUnitId()) == nullptr) {
252  edm::LogError(kLogCategory_) << "SimHit did not match with GEMGeometry." << std::endl;
253  continue;
254  }
255 
256  GEMDetId simhit_gemid(simhit.detUnitId());
257 
258  Int_t region_id = simhit_gemid.region();
259  Int_t station_id = simhit_gemid.station();
260  Int_t layer_id = simhit_gemid.layer();
261  Int_t chamber_id = simhit_gemid.chamber();
262  Int_t ieta = simhit_gemid.ieta();
263  Int_t num_layers = simhit_gemid.nlayers();
264 
265  ME2IdsKey key2{region_id, station_id};
266  ME3IdsKey key3{region_id, station_id, layer_id};
267 
268  const GEMEtaPartition* roll = gem->etaPartition(simhit_gemid);
269 
270  const auto& simhit_local_pos = simhit.localPosition();
271  const auto& simhit_global_pos = roll->surface().toGlobal(simhit_local_pos);
272 
273  Float_t simhit_g_eta = std::abs(simhit_global_pos.eta());
274  Float_t simhit_g_phi = toDegree(simhit_global_pos.phi());
275 
276  auto simhit_trackId = simhit.trackId();
277 
278  Int_t bin_x = getDetOccBinX(num_layers, chamber_id, layer_id);
279 
280  auto links = digiSimLink->find(simhit_gemid);
281  if (links == digiSimLink->end())
282  continue;
283 
284  for (const auto& link : *links) {
285  if (simhit_trackId == link.getTrackId()) {
286  Int_t pid = simhit.particleType();
287  Int_t pid_idx = getPidIdx(pid);
288 
289  me_occ_pid_[key3]->Fill(pid_idx);
290 
291  if (detail_plot_) {
292  if (isMuonSimHit(simhit)) {
293  me_detail_strip_occ_eta_[key3]->Fill(simhit_g_eta);
294  me_detail_strip_occ_phi_[key3]->Fill(simhit_g_phi);
295  me_detail_strip_occ_det_[key2]->Fill(bin_x, ieta);
296  }
297  }
298  break;
299  }
300  }
301  } // simhit_container loop
302 }
GEMStripDigiValidation::strip_token_
edm::EDGetTokenT< GEMDigiCollection > strip_token_
Definition: GEMStripDigiValidation.h:19
GEMStripDigiValidation::me_detail_strip_occ_eta_
MEMap3Ids me_detail_strip_occ_eta_
Definition: GEMStripDigiValidation.h:41
ME2IdsKey
std::tuple< Int_t, Int_t > ME2IdsKey
Definition: GEMValidationUtils.h:16
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
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
GEMStripDigiValidation::me_detail_occ_xy_
MEMap3Ids me_detail_occ_xy_
Definition: GEMStripDigiValidation.h:32
GEMSuperChamber::chambers
const std::vector< const GEMChamber * > & chambers() const
Return the chambers in the super chamber.
Definition: GEMSuperChamber.cc:23
edm::Handle::product
T const * product() const
Definition: Handle.h:70
MainPageGenerator.link
link
Definition: MainPageGenerator.py:271
GEMBaseValidation::detail_plot_
Bool_t detail_plot_
Definition: GEMBaseValidation.h:95
GEMSuperChamber
Definition: GEMSuperChamber.h:19
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
GEMStripDigiValidation::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: GEMStripDigiValidation.cc:153
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
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
StripTopology.h
edm::Handle
Definition: AssociativeIterator.h:50
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
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
GEMStripDigiValidation.h
GEMStripDigiValidation::~GEMStripDigiValidation
~GEMStripDigiValidation() override
Definition: GEMStripDigiValidation.cc:151
GEMStripDigiValidation::me_detail_total_strip_
MEMap2Ids me_detail_total_strip_
Definition: GEMStripDigiValidation.h:29
GEMStripDigiValidation::me_total_strip_
MonitorElement * me_total_strip_
Definition: GEMStripDigiValidation.h:28
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
GEMStripDigiValidation::me_detail_strip_occ_det_
MEMap2Ids me_detail_strip_occ_det_
Definition: GEMStripDigiValidation.h:43
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, GlobalTag >
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
GEMStripDigiValidation::simhit_token_
edm::EDGetTokenT< edm::PSimHitContainer > simhit_token_
Definition: GEMStripDigiValidation.h:20
edm::ParameterSet
Definition: ParameterSet.h:47
GEMBaseValidation::eta_range_
std::vector< Double_t > eta_range_
Definition: GEMBaseValidation.h:94
GEMDetId
Definition: GEMDetId.h:18
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88271
GEMStripDigiValidation::geomTokenBeginRun_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geomTokenBeginRun_
Definition: GEMStripDigiValidation.h:23
chambers
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
GEMBaseValidation
Definition: GEMBaseValidation.h:19
GEMBaseValidation::getPidIdx
Int_t getPidIdx(Int_t pid)
Definition: GEMBaseValidation.cc:38
GEMStripDigiValidation::me_bx_
MonitorElement * me_bx_
Definition: GEMStripDigiValidation.h:36
edm::EventSetup
Definition: EventSetup.h:58
GEMStripDigiValidation::geomToken_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geomToken_
Definition: GEMStripDigiValidation.h:22
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
GEMEtaPartition::centreOfStrip
LocalPoint centreOfStrip(int strip) const
Definition: GEMEtaPartition.cc:26
gem
Definition: AMC13Event.h:6
GEMStripDigiValidation::GEMStripDigiValidation
GEMStripDigiValidation(const edm::ParameterSet &)
Definition: GEMStripDigiValidation.cc:4
GEMStripDigiValidation::me_detail_occ_strip_
MEMap3Ids me_detail_occ_strip_
Definition: GEMStripDigiValidation.h:33
GEMStripDigiValidation::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: GEMStripDigiValidation.cc:21
writedatasetfile.run
run
Definition: writedatasetfile.py:27
GEMBaseValidation::bookPIDHist
dqm::impl::MonitorElement * bookPIDHist(DQMStore::IBooker &booker, const T &key, const char *name, const char *title)
Definition: GEMBaseValidation.h:217
GEMStripDigiValidation::digisimlink_token_
edm::EDGetTokenT< edm::DetSetVector< GEMDigiSimLink > > digisimlink_token_
Definition: GEMStripDigiValidation.h:21
GEMBaseValidation::toDegree
Float_t toDegree(Float_t radian)
Definition: GEMBaseValidation.cc:30
BoundPlane
electronStore.links
links
Definition: electronStore.py:149
GEMStripDigiValidation::me_occ_pid_
MEMap3Ids me_occ_pid_
Definition: GEMStripDigiValidation.h:40
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
ME3IdsKey
std::tuple< Int_t, Int_t, Int_t > ME3IdsKey
Definition: GEMValidationUtils.h:19
MuonDigiCollection::Range
std::pair< const_iterator, const_iterator > Range
Definition: MuonDigiCollection.h:95
dqm::implementation::IBooker
Definition: DQMStore.h:43
GEMStripDigiValidation::me_detail_occ_det_
MEMap2Ids me_detail_occ_det_
Definition: GEMStripDigiValidation.h:31
GEMGeometry
Definition: GEMGeometry.h:24
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
GEMStripDigiValidation::me_detail_occ_zr_
MEMap1Ids me_detail_occ_zr_
Definition: GEMStripDigiValidation.h:30
GEMStripDigiValidation::me_detail_strip_occ_phi_
MEMap3Ids me_detail_strip_occ_phi_
Definition: GEMStripDigiValidation.h:42
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
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
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:99
GEMStripDigiValidation::me_bx_layer_
MEMap3Ids me_bx_layer_
Definition: GEMStripDigiValidation.h:37