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  geomToken_ = esConsumes<GEMGeometry, MuonGeometryRecord>();
14  geomTokenBeginRun_ = esConsumes<GEMGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
15 }
16 
18  edm::Run const& run,
19  edm::EventSetup const& setup) {
20  const GEMGeometry* gem = &setup.getData(geomTokenBeginRun_);
21  if (gem == nullptr) {
22  edm::LogError(kLogCategory_) << "Failed to initialize GEM geometry.";
23  return;
24  }
25 
26  // NOTE Bunch Crossing
27  booker.setCurrentFolder("MuonGEMDigisV/GEMDigisTask/Strip/BunchCrossing");
28 
29  me_bx_ = booker.book1D("strip_bx", "Strip Digi Bunch Crossing", 5, -2.5, 2.5);
30 
31  if (detail_plot_) {
32  for (const auto& region : gem->regions()) {
33  if (region == nullptr) {
34  edm::LogError(kLogCategory_) << "Null region";
35  continue;
36  }
37  Int_t region_id = region->region();
38  for (const auto& station : region->stations()) {
39  if (station == nullptr) {
40  edm::LogError(kLogCategory_) << "Null station for region = " << region_id;
41  continue;
42  }
43  Int_t station_id = station->station();
44 
45  const auto& superChamberVec = station->superChambers();
46  if (superChamberVec.empty()) {
47  edm::LogError(kLogCategory_) << "Super chambers missing for region = " << region_id
48  << " and station = " << station_id;
49  continue;
50  }
51  const GEMSuperChamber* super_chamber = superChamberVec.front();
52  if (super_chamber == nullptr) {
53  edm::LogError(kLogCategory_) << "Failed to find super chamber for region = " << region_id
54  << " and station = " << station_id;
55  continue;
56  }
57  for (const auto& chamber : super_chamber->chambers()) {
58  Int_t layer_id = chamber->id().layer();
59  ME3IdsKey key3(region_id, station_id, layer_id);
60 
61  me_detail_bx_[key3] =
62  bookHist1D(booker, key3, "strip_bx", "Strip Digi Bunch Crossing", 5, -2.5, 2.5, "Bunch crossing");
63  } // chamber loop
64  } // station loop
65  } // region loop
66  } // detail plot
67 
68  // NOTE Occupancy
69  booker.setCurrentFolder("MuonGEMDigisV/GEMDigisTask/Strip/Occupancy");
70 
71  for (const auto& region : gem->regions()) {
72  Int_t region_id = region->region();
73 
74  me_occ_zr_[region_id] = bookZROccupancy(booker, region_id, "strip", "Strip Digi");
75 
76  // occupancy plots for eta efficiency
77  me_simhit_occ_eta_[region_id] = bookHist1D(booker,
78  region_id,
79  "muon_simhit_occ_eta",
80  "Muon SimHit Eta Occupancy",
81  50,
82  eta_range_[0],
83  eta_range_[1],
84  "|#eta|");
85 
86  me_strip_occ_eta_[region_id] = bookHist1D(booker,
87  region_id,
88  "matched_strip_occ_eta",
89  "Matched Strip Digi Eta Occupancy",
90  50,
91  eta_range_[0],
92  eta_range_[1],
93  "|#eta|");
94  for (const auto& station : region->stations()) {
95  Int_t station_id = station->station();
96  ME2IdsKey key2{region_id, station_id};
97 
98  me_occ_det_[key2] = bookDetectorOccupancy(booker, key2, station, "strip", "Strip Digi");
99 
100  me_simhit_occ_phi_[key2] =
101  bookHist1D(booker, key2, "muon_simhit_occ_phi", "Muon SimHit Phi Occupancy", 51, -M_PI, M_PI, "#phi");
102 
104  booker, key2, "matched_strip_occ_phi", "Matched Strip Digi Phi Occupancy", 51, -M_PI, M_PI, "#phi");
105 
106  me_simhit_occ_det_[key2] = bookDetectorOccupancy(booker, key2, station, "muon_simhit", "Muon SimHit");
107 
108  me_strip_occ_det_[key2] = bookDetectorOccupancy(booker, key2, station, "matched_strip", "Matched Strip Digi");
109 
110  const auto& superChamberVec = station->superChambers();
111  if (superChamberVec.empty() || superChamberVec[0] == nullptr) {
112  edm::LogError(kLogCategory_) << "Super chambers missing or null for region = " << region_id
113  << " and station = " << station_id;
114  } else {
115  for (const auto& chamber : superChamberVec[0]->chambers()) {
116  if (chamber == nullptr) {
117  edm::LogError(kLogCategory_) << "Null chamber for region, station, super chamber = (" << region_id << ", "
118  << station_id << ", " << superChamberVec[0]->id() << ")";
119  continue;
120  }
121  Int_t layer_id = chamber->id().layer();
122  ME3IdsKey key3{region_id, station_id, layer_id};
123 
124  if (detail_plot_) {
125  const auto& etaPartitionsVec = chamber->etaPartitions();
126  if (etaPartitionsVec.empty() || etaPartitionsVec.front() == nullptr) {
128  << "Eta partition missing or null for region, station, super chamber, chamber = (" << region_id
129  << ", " << station_id << ", " << superChamberVec[0]->id() << ", " << chamber->id() << ")";
130  continue;
131  }
132  Int_t num_strips = etaPartitionsVec.front()->nstrips();
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  me_detail_occ_phi_strip_[key3] = bookHist2D(booker,
146  key3,
147  "strip_occ_phi_strip",
148  "Strip Digi Occupancy",
149  280,
150  -M_PI,
151  M_PI,
152  num_strips / 2,
153  0,
154  num_strips,
155  "#phi [rad]",
156  "strip number");
157  } // detail plot
158  } // chamber
159  } // end else
160  } // station looop
161  } // region loop
162 }
163 
165 
167  const GEMGeometry* gem = &setup.getData(geomToken_);
168  if (gem == nullptr) {
169  edm::LogError(kLogCategory_) << "Failed to initialize GEM geometry.";
170  return;
171  }
172  edm::Handle<edm::PSimHitContainer> simhit_container;
173  event.getByToken(simhit_token_, simhit_container);
174  if (not simhit_container.isValid()) {
175  edm::LogError(kLogCategory_) << "Failed to get PSimHitContainer." << std::endl;
176  return;
177  }
178 
179  edm::Handle<GEMDigiCollection> digi_collection;
180  event.getByToken(strip_token_, digi_collection);
181  if (not digi_collection.isValid()) {
182  edm::LogError(kLogCategory_) << "Cannot get strips by Token stripToken." << std::endl;
183  return;
184  }
185 
186  // NOTE
187  for (auto range_iter = digi_collection->begin(); range_iter != digi_collection->end(); range_iter++) {
188  GEMDetId id = (*range_iter).first;
189  if (gem->idToDet(id) == nullptr) {
190  edm::LogError(kLogCategory_) << "Getting DetId failed. Discard this gem strip hit. Maybe it comes "
191  << "from unmatched geometry." << std::endl;
192  continue;
193  }
194 
195  Int_t region_id = id.region();
196  Int_t layer_id = id.layer();
197  Int_t station_id = id.station();
198  Int_t chamber_id = id.chamber();
199  Int_t roll_id = id.roll();
200 
201  ME2IdsKey key2{region_id, station_id};
202  ME3IdsKey key3{region_id, station_id, layer_id};
203  Int_t bin_x = getDetOccBinX(chamber_id, layer_id);
204 
205  const BoundPlane& surface = gem->idToDet(id)->surface();
206  const GEMEtaPartition* roll = gem->etaPartition(id);
207 
208  const GEMDigiCollection::Range& range = (*range_iter).second;
209  for (auto digi = range.first; digi != range.second; ++digi) {
210  Int_t strip = digi->strip();
211  Int_t bx = digi->bx();
212 
213  GlobalPoint strip_global_pos = surface.toGlobal(roll->centreOfStrip(digi->strip()));
214 
215  Float_t digi_g_r = strip_global_pos.perp();
216  Float_t digi_g_abs_z = std::abs(strip_global_pos.z());
217 
218  me_bx_->Fill(bx);
219  me_occ_zr_[region_id]->Fill(digi_g_abs_z, digi_g_r), me_occ_det_[key2]->Fill(bin_x, roll_id);
220 
221  if (detail_plot_) {
222  Float_t digi_g_x = strip_global_pos.x();
223  Float_t digi_g_y = strip_global_pos.y();
224  Float_t digi_g_phi = strip_global_pos.phi();
225 
226  me_detail_bx_[key3]->Fill(bx);
227  me_detail_occ_xy_[key3]->Fill(digi_g_x, digi_g_y);
228  me_detail_occ_strip_[key3]->Fill(strip);
229  me_detail_occ_phi_strip_[key3]->Fill(digi_g_phi, strip);
230  }
231  }
232  } // range loop
233 
234  // NOTE
235  for (const auto& simhit : *simhit_container.product()) {
236  if (not isMuonSimHit(simhit))
237  continue;
238 
239  if (gem->idToDet(simhit.detUnitId()) == nullptr) {
240  edm::LogError(kLogCategory_) << "SimHit did not match with GEMGeometry." << std::endl;
241  continue;
242  }
243 
244  GEMDetId simhit_gemid(simhit.detUnitId());
245 
246  Int_t region_id = simhit_gemid.region();
247  Int_t station_id = simhit_gemid.station();
248  Int_t layer_id = simhit_gemid.layer();
249  Int_t chamber_id = simhit_gemid.chamber();
250  Int_t roll_id = simhit_gemid.roll();
251 
252  ME2IdsKey key2{region_id, station_id};
253  ME3IdsKey key3{region_id, station_id, layer_id};
254 
255  const GEMEtaPartition* roll = gem->etaPartition(simhit_gemid);
256 
257  const auto& simhit_local_pos = simhit.localPosition();
258  const auto& simhit_global_pos = roll->surface().toGlobal(simhit_local_pos);
259 
260  Float_t simhit_g_eta = std::abs(simhit_global_pos.eta());
261  Float_t simhit_g_phi = simhit_global_pos.phi();
262 
263  Int_t simhit_strip = roll->strip(simhit_local_pos);
264 
265  Int_t bin_x = getDetOccBinX(chamber_id, layer_id);
266  me_simhit_occ_eta_[region_id]->Fill(simhit_g_eta);
267  me_simhit_occ_phi_[key2]->Fill(simhit_g_phi);
268  me_simhit_occ_det_[key2]->Fill(bin_x, roll_id);
269 
270  auto range = digi_collection->get(simhit_gemid);
271  for (auto digi = range.first; digi != range.second; ++digi) {
272  if (simhit_strip == digi->strip()) {
273  me_strip_occ_eta_[region_id]->Fill(simhit_g_eta);
274  me_strip_occ_phi_[key2]->Fill(simhit_g_phi);
275  me_strip_occ_det_[key2]->Fill(bin_x, roll_id);
276  break;
277  }
278  }
279  } // simhit_container loop
280 }
GEMStripDigiValidation::strip_token_
edm::EDGetTokenT< GEMDigiCollection > strip_token_
Definition: GEMStripDigiValidation.h:16
ME2IdsKey
std::tuple< Int_t, Int_t > ME2IdsKey
Definition: GEMValidationUtils.h:16
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
GEMStripDigiValidation::me_occ_det_
MEMap2Ids me_occ_det_
Definition: GEMStripDigiValidation.h:25
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
GEMStripDigiValidation::me_detail_occ_xy_
MEMap3Ids me_detail_occ_xy_
Definition: GEMStripDigiValidation.h:26
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
GEMBaseValidation::detail_plot_
Bool_t detail_plot_
Definition: GEMBaseValidation.h:88
GEMStripDigiValidation::me_strip_occ_det_
MEMap2Ids me_strip_occ_det_
Definition: GEMStripDigiValidation.h:41
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: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
GEMStripDigiValidation::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: GEMStripDigiValidation.cc:166
GEMStripDigiValidation::me_occ_zr_
MEMap1Ids me_occ_zr_
Definition: GEMStripDigiValidation.h:24
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
GEMStripDigiValidation::me_detail_occ_phi_strip_
MEMap3Ids me_detail_occ_phi_strip_
Definition: GEMStripDigiValidation.h:28
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
GEMStripDigiValidation::me_simhit_occ_det_
MEMap2Ids me_simhit_occ_det_
Definition: GEMStripDigiValidation.h:37
StripTopology.h
GEMStripDigiValidation::me_detail_bx_
MEMap3Ids me_detail_bx_
Definition: GEMStripDigiValidation.h:32
edm::Handle< edm::PSimHitContainer >
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
GEMStripDigiValidation::me_simhit_occ_phi_
MEMap2Ids me_simhit_occ_phi_
Definition: GEMStripDigiValidation.h:36
GEMStripDigiValidation::me_strip_occ_eta_
MEMap1Ids me_strip_occ_eta_
Definition: GEMStripDigiValidation.h:39
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
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
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:164
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
GEMBaseValidation::bookXYOccupancy
dqm::impl::MonitorElement * bookXYOccupancy(DQMStore::IBooker &booker, const T &key, const char *name_prefix, const char *title_prefix)
Definition: GEMBaseValidation.h:134
GEMStripDigiValidation::me_simhit_occ_eta_
MEMap1Ids me_simhit_occ_eta_
Definition: GEMStripDigiValidation.h:35
Point3DBase< float, GlobalTag >
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:227
GEMStripDigiValidation::simhit_token_
edm::EDGetTokenT< edm::PSimHitContainer > simhit_token_
Definition: GEMStripDigiValidation.h:17
edm::ParameterSet
Definition: ParameterSet.h:47
GEMBaseValidation::eta_range_
std::vector< Double_t > eta_range_
Definition: GEMBaseValidation.h:87
GEMDetId
Definition: GEMDetId.h:18
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88272
GEMStripDigiValidation::geomTokenBeginRun_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geomTokenBeginRun_
Definition: GEMStripDigiValidation.h:19
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
chambers
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
GEMBaseValidation
Definition: GEMBaseValidation.h:18
GEMStripDigiValidation::me_bx_
MonitorElement * me_bx_
Definition: GEMStripDigiValidation.h:31
edm::EventSetup
Definition: EventSetup.h:57
GEMStripDigiValidation::geomToken_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geomToken_
Definition: GEMStripDigiValidation.h:18
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
GEMEtaPartition::strip
float strip(const LocalPoint &lp) const
Definition: GEMEtaPartition.cc:37
GEMStripDigiValidation::me_detail_occ_strip_
MEMap3Ids me_detail_occ_strip_
Definition: GEMStripDigiValidation.h:27
GEMStripDigiValidation::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: GEMStripDigiValidation.cc:17
writedatasetfile.run
run
Definition: writedatasetfile.py:27
BoundPlane
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
GEMGeometry
Definition: GEMGeometry.h:24
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
GEMStripDigiValidation::me_strip_occ_phi_
MEMap2Ids me_strip_occ_phi_
Definition: GEMStripDigiValidation.h:40
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
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