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