CMS 3D CMS Logo

GEMSimHitValidation.cc
Go to the documentation of this file.
4 
6  : GEMBaseValidation(pset, "GEMSimHitValidation") {
7  const auto& simhit_pset = pset.getParameterSet("gemSimHit");
8  const auto& simhit_tag = simhit_pset.getParameter<edm::InputTag>("inputTag");
9  simhit_token_ = consumes<edm::PSimHitContainer>(simhit_tag);
10 
11  tof_range_ = pset.getUntrackedParameter<std::vector<Double_t> >("TOFRange");
12  geomToken_ = esConsumes<GEMGeometry, MuonGeometryRecord>();
13  geomTokenBeginRun_ = esConsumes<GEMGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
14 }
15 
17 
19  const GEMGeometry* gem = &setup.getData(geomTokenBeginRun_);
20 
21  // NOTE Time of flight
22  booker.setCurrentFolder("MuonGEMHitsV/GEMHitsTask/TimeOfFlight");
23 
24  TString tof_xtitle = "Time of flight [ns]";
25  TString tof_ytitle = "Entries";
26 
27  for (const auto& region : gem->regions()) {
28  Int_t region_id = region->region();
29 
30  for (const auto& station : region->stations()) {
31  Int_t station_id = station->station();
32 
33  const auto [tof_min, tof_max] = getTOFRange(station_id);
34  ME2IdsKey key2{region_id, station_id};
35 
36  me_tof_mu_[key2] =
37  bookHist1D(booker, key2, "tof_muon", "SimHit TOF (Muon only)", 20, tof_min, tof_max, tof_xtitle, tof_ytitle);
38 
39  me_tof_others_[key2] = bookHist1D(
40  booker, key2, "tof_others", "SimHit TOF (Other Particles)", 20, tof_min, tof_max, tof_xtitle, tof_ytitle);
41  } // station loop
42  } // region loop
43 
44  if (detail_plot_) {
45  for (const auto& region : gem->regions()) {
46  Int_t region_id = region->region();
47 
48  for (const auto& station : region->stations()) {
49  Int_t station_id = station->station();
50 
51  const auto [tof_min, tof_max] = getTOFRange(station_id);
52  const auto& superChamberVec = station->superChambers();
53  if (superChamberVec.empty() || superChamberVec.front() == nullptr) {
54  edm::LogError(kLogCategory_) << "Super chambers missing or null for region = " << region_id
55  << " and station = " << station_id;
56  } else {
57  const GEMSuperChamber* super_chamber = superChamberVec.front();
58 
59  for (const auto& chamber : super_chamber->chambers()) {
60  Int_t layer_id = chamber->id().layer();
61  ME3IdsKey key3{region_id, station_id, layer_id};
62 
63  me_detail_tof_[key3] = bookHist1D(
64  booker, key3, "tof", "Time of Flight of Muon SimHits", 40, tof_min, tof_max, tof_xtitle, tof_ytitle);
65 
67  booker, key3, "tof_muon", "SimHit TOF (Muon only)", 40, tof_min, tof_max, tof_xtitle, tof_ytitle);
68  } // chamber loop
69  } // end else
70  } // station loop
71  } // region loop
72  } // detail plot
73 
74  // NOTE Energy Loss
75  booker.setCurrentFolder("MuonGEMHitsV/GEMHitsTask/EnergyLoss");
76 
77  TString eloss_xtitle = "Energy loss [eV]";
78  TString eloss_ytitle = "Entries / 0.5 keV";
79 
80  for (const auto& station : gem->regions()[0]->stations()) {
81  Int_t station_id = station->station();
82 
83  auto eloss_mu_name = TString::Format("eloss_muon_st%d", station_id);
84  auto eloss_mu_title = TString::Format("SimHit Energy Loss (Muon only) : Station %d", station_id);
85 
86  me_eloss_mu_[station_id] =
87  booker.book1D(eloss_mu_name, eloss_mu_title + ";" + eloss_xtitle + ";" + eloss_ytitle, 20, 0.0, 10.0);
88 
89  auto eloss_others_name = TString::Format("eloss_others_st%d", station_id);
90  auto eloss_others_title = TString::Format("SimHit Energy Loss (Other Particles) : Station %d", station_id);
91 
92  me_eloss_others_[station_id] =
93  booker.book1D(eloss_others_name, eloss_others_title + ";" + eloss_xtitle + ";" + eloss_ytitle, 20, 0.0, 10.0);
94  } // station loop
95 
96  if (detail_plot_) {
97  for (const auto& region : gem->regions()) {
98  Int_t region_id = region->region();
99  for (const auto& station : region->stations()) {
100  Int_t station_id = station->station();
101  const auto& superChamberVec = station->superChambers();
102  if (superChamberVec.empty() || superChamberVec.front() == nullptr) {
103  edm::LogError(kLogCategory_) << "Super chambers missing or null for region = " << region_id
104  << " and station = " << station_id;
105  } else {
106  for (const auto& chamber : superChamberVec.front()->chambers()) {
107  Int_t layer_id = chamber->id().layer();
108  ME3IdsKey key3{region_id, station_id, layer_id};
109 
110  me_detail_eloss_[key3] =
111  bookHist1D(booker, key3, "eloss", "SimHit Energy Loss", 60, 0.0, 6000.0, eloss_xtitle, eloss_ytitle);
112 
113  me_detail_eloss_mu_[key3] = bookHist1D(booker,
114  key3,
115  "eloss_muon",
116  "SimHit Energy Loss (Muon Only)",
117  60,
118  0.0,
119  6000.0,
120  eloss_xtitle,
121  eloss_ytitle);
122 
123  } // chamber loop
124  } // end else
125  } // station loop
126  } // region loop
127  } // detail plot
128 
129  // NOTE Occupancy
130  booker.setCurrentFolder("MuonGEMHitsV/GEMHitsTask/Occupancy");
131 
132  for (const auto& region : gem->regions()) {
133  Int_t region_id = region->region();
134 
135  if (detail_plot_)
136  me_detail_occ_zr_[region_id] = bookZROccupancy(booker, region_id, "simhit", "SimHit");
137 
138  for (const auto& station : region->stations()) {
139  Int_t station_id = station->station();
140  ME2IdsKey key2{region_id, station_id};
141 
142  if (detail_plot_) {
143  me_detail_occ_det_[key2] = bookDetectorOccupancy(booker, key2, station, "simhit", "SimHit");
144  me_detail_occ_det_mu_[key2] = bookDetectorOccupancy(booker, key2, station, "muon_simhit", "Muon SimHit");
145  }
146 
147  const auto& superChamberVec = station->superChambers();
148  if (superChamberVec.empty() || superChamberVec.front() == nullptr) {
149  edm::LogError(kLogCategory_) << "Super chambers missing or null for region = " << region_id
150  << " and station = " << station_id;
151  } else {
152  const GEMSuperChamber* super_chamber = superChamberVec.front();
153  for (const auto& chamber : super_chamber->chambers()) {
154  Int_t layer_id = chamber->id().layer();
155  ME3IdsKey key3{region_id, station_id, layer_id};
156 
157  me_occ_eta_mu_[key3] = bookHist1D(booker,
158  key3,
159  "muon_simhit_occ_eta",
160  "Muon SimHit Eta Occupancy",
161  16,
162  eta_range_[station_id * 2 + 0],
163  eta_range_[station_id * 2 + 1],
164  "#eta");
165 
166  me_occ_phi_mu_[key3] = bookHist1D(
167  booker, key3, "muon_simhit_occ_phi", "Muon SimHit Phi Occupancy", 36, -5, 355, "#phi [degrees]");
168 
169  me_occ_pid_[key3] = bookPIDHist(booker, key3, "simhit_occ_pid", "Number of entries for each paritcle");
170 
171  if (detail_plot_)
172  me_detail_occ_xy_[key3] = bookXYOccupancy(booker, key3, "simhit", "SimHit");
173  } // layer loop
174  } // end else
175  } // station loop
176  } // region loop
177 }
178 
179 std::tuple<Double_t, Double_t> GEMSimHitValidation::getTOFRange(Int_t station_id) {
180  UInt_t start_index = station_id * 2;
181  Double_t tof_min = tof_range_[start_index];
182  Double_t tof_max = tof_range_[start_index + 1];
183  return std::make_tuple(tof_min, tof_max);
184 }
185 
187  const GEMGeometry* gem = &setup.getData(geomToken_);
188 
189  edm::Handle<edm::PSimHitContainer> simhit_container;
190  event.getByToken(simhit_token_, simhit_container);
191  if (not simhit_container.isValid()) {
192  edm::LogError(kLogCategory_) << "Cannot get GEMHits by Token simhitLabel" << std::endl;
193  return;
194  }
195 
196  for (const auto& simhit : *simhit_container.product()) {
197  const GEMDetId gemid(simhit.detUnitId());
198 
199  if (gem->idToDet(gemid) == nullptr) {
200  edm::LogError(kLogCategory_) << "SimHit did not matched with GEM Geometry." << std::endl;
201  continue;
202  }
203 
204  Int_t region_id = gemid.region();
205  Int_t station_id = gemid.station();
206  Int_t layer_id = gemid.layer();
207  Int_t chamber_id = gemid.chamber();
208  Int_t ieta = gemid.ieta();
209  Int_t num_layers = gemid.nlayers();
210 
211  ME2IdsKey key2{region_id, station_id};
212  ME3IdsKey key3{region_id, station_id, layer_id};
213 
214  GlobalPoint&& simhit_global_pos = gem->idToDet(gemid)->surface().toGlobal(simhit.localPosition());
215 
216  Float_t simhit_g_r = simhit_global_pos.perp();
217  Float_t simhit_g_x = simhit_global_pos.x();
218  Float_t simhit_g_y = simhit_global_pos.y();
219  Float_t simhit_g_abs_z = std::fabs(simhit_global_pos.z());
220  Float_t simhit_g_eta = std::fabs(simhit_global_pos.eta());
221  Float_t simhit_g_phi = toDegree(simhit_global_pos.phi());
222 
223  Float_t energy_loss = kEnergyCF_ * simhit.energyLoss();
224  energy_loss = energy_loss > 10 ? 9.9 : energy_loss;
225  Float_t tof = simhit.timeOfFlight();
226  Int_t pid = simhit.particleType();
227  Int_t pid_idx = getPidIdx(pid);
228 
229  // NOTE Fill MonitorElement
230  Int_t bin_x = getDetOccBinX(num_layers, chamber_id, layer_id);
231 
232  bool is_muon_simhit = isMuonSimHit(simhit);
233  if (is_muon_simhit) {
234  me_tof_mu_[key2]->Fill(tof);
235  me_eloss_mu_[station_id]->Fill(energy_loss);
236  me_occ_eta_mu_[key3]->Fill(simhit_g_eta);
237  me_occ_phi_mu_[key3]->Fill(simhit_g_phi);
238  } else {
239  me_tof_others_[key2]->Fill(tof);
240  me_eloss_others_[station_id]->Fill(energy_loss);
241  }
242 
243  me_occ_pid_[key3]->Fill(pid_idx);
244 
245  if (detail_plot_) {
246  me_detail_tof_[key3]->Fill(tof);
247  me_detail_eloss_[key3]->Fill(energy_loss);
248 
249  me_detail_occ_zr_[region_id]->Fill(simhit_g_abs_z, simhit_g_r);
250  me_detail_occ_det_[key2]->Fill(bin_x, ieta);
251  me_detail_occ_xy_[key3]->Fill(simhit_g_x, simhit_g_y);
252 
253  if (is_muon_simhit) {
254  me_detail_tof_mu_[key3]->Fill(tof);
255  me_detail_eloss_mu_[key3]->Fill(energy_loss);
256  me_detail_occ_det_mu_[key2]->Fill(bin_x, ieta);
257  }
258 
259  } // detail_plot
260  } // simhit loop
261 }
ME2IdsKey
std::tuple< Int_t, Int_t > ME2IdsKey
Definition: GEMValidationUtils.h:16
GEMSimHitValidation::tof_range_
std::vector< Double_t > tof_range_
Definition: GEMSimHitValidation.h:25
GEMSimHitValidation::me_tof_others_
MEMap2Ids me_tof_others_
Definition: GEMSimHitValidation.h:29
Handle.h
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
edm::Handle::product
T const * product() const
Definition: Handle.h:70
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
GEMSimHitValidation::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: GEMSimHitValidation.cc:18
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
GEMSimHitValidation::geomToken_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geomToken_
Definition: GEMSimHitValidation.h:23
PSimHitContainer.h
GEMSimHitValidation::me_detail_occ_xy_
MEMap3Ids me_detail_occ_xy_
Definition: GEMSimHitValidation.h:44
GEMSimHitValidation::me_occ_phi_mu_
MEMap3Ids me_occ_phi_mu_
Definition: GEMSimHitValidation.h:39
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
GEMSimHitValidation::me_detail_eloss_
MEMap3Ids me_detail_eloss_
Definition: GEMSimHitValidation.h:35
GEMSimHitValidation::me_detail_tof_mu_
MEMap3Ids me_detail_tof_mu_
Definition: GEMSimHitValidation.h:31
edm::Handle< edm::PSimHitContainer >
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
GEMSimHitValidation::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: GEMSimHitValidation.cc:186
GEMSimHitValidation::me_eloss_others_
MEMap1Ids me_eloss_others_
Definition: GEMSimHitValidation.h:34
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
GEMSimHitValidation::me_tof_mu_
MEMap2Ids me_tof_mu_
Definition: GEMSimHitValidation.h:28
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
GEMSimHitValidation::me_detail_occ_det_mu_
MEMap2Ids me_detail_occ_det_mu_
Definition: GEMSimHitValidation.h:43
GEMSimHitValidation::me_detail_occ_det_
MEMap2Ids me_detail_occ_det_
Definition: GEMSimHitValidation.h:42
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 >
GEMSimHitValidation::geomTokenBeginRun_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geomTokenBeginRun_
Definition: GEMSimHitValidation.h:24
GEMSimHitValidation::me_detail_eloss_mu_
MEMap3Ids me_detail_eloss_mu_
Definition: GEMSimHitValidation.h:36
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
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::eta
T eta() const
Definition: PV3DBase.h:73
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88286
GEMSimHitValidation::me_occ_pid_
MEMap3Ids me_occ_pid_
Definition: GEMSimHitValidation.h:40
GEMBaseValidation
Definition: GEMBaseValidation.h:19
GEMBaseValidation::getPidIdx
Int_t getPidIdx(Int_t pid)
Definition: GEMBaseValidation.cc:38
GEMSimHitValidation::me_occ_eta_mu_
MEMap3Ids me_occ_eta_mu_
Definition: GEMSimHitValidation.h:38
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
gem
Definition: AMC13Event.h:6
GEMSimHitValidation::GEMSimHitValidation
GEMSimHitValidation(const edm::ParameterSet &)
Definition: GEMSimHitValidation.cc:5
GEMSimHitValidation::getTOFRange
std::tuple< Double_t, Double_t > getTOFRange(Int_t station_id)
Definition: GEMSimHitValidation.cc:179
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
GEMSimHitValidation::me_detail_occ_zr_
MEMap1Ids me_detail_occ_zr_
Definition: GEMSimHitValidation.h:41
GEMBaseValidation::toDegree
Float_t toDegree(Float_t radian)
Definition: GEMBaseValidation.cc:30
GEMSimHitValidation::me_detail_tof_
MEMap3Ids me_detail_tof_
Definition: GEMSimHitValidation.h:30
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
ME3IdsKey
std::tuple< Int_t, Int_t, Int_t > ME3IdsKey
Definition: GEMValidationUtils.h:19
GEMSimHitValidation::simhit_token_
edm::EDGetTokenT< edm::PSimHitContainer > simhit_token_
Definition: GEMSimHitValidation.h:22
dqm::implementation::IBooker
Definition: DQMStore.h:43
GEMGeometry
Definition: GEMGeometry.h:24
GEMSimHitValidation.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
GEMSimHitValidation::~GEMSimHitValidation
~GEMSimHitValidation() override
Definition: GEMSimHitValidation.cc:16
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
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
GEMSimHitValidation::kEnergyCF_
const Float_t kEnergyCF_
Definition: GEMSimHitValidation.h:47
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
GEMSimHitValidation::me_eloss_mu_
MEMap1Ids me_eloss_mu_
Definition: GEMSimHitValidation.h:33