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 }
13 
15 
18 
19  // NOTE Time of flight
20  booker.setCurrentFolder("MuonGEMHitsV/GEMHitsTask/TimeOfFlight");
21 
22  TString tof_xtitle = "Time of flight [ns]";
23  TString tof_ytitle = "Entries";
24 
25  const auto& regionsVec = gem->regions();
26  if (regionsVec.empty() || regionsVec[0] == nullptr) {
27  edm::LogError(kLogCategory_) << "Regions missing or null.";
28  return;
29  } else {
30  for (const auto& station : regionsVec[0]->stations()) {
31  Int_t station_id = station->station();
32  const auto [tof_min, tof_max] = getTOFRange(station_id);
33  auto tof_name = TString::Format("tof_muon_st%d", station_id);
34  auto tof_title = TString::Format("SimHit Time Of Flight (Muon only) : Station %d", station_id);
35 
36  me_tof_mu_[station_id] = booker.book1D(tof_name, tof_title, 40, tof_min, tof_max);
37  } // end for
38  } // end else
39 
40  if (detail_plot_) {
41  for (const auto& region : gem->regions()) {
42  Int_t region_id = region->region();
43 
44  for (const auto& station : region->stations()) {
45  Int_t station_id = station->station();
46 
47  const auto [tof_min, tof_max] = getTOFRange(station_id);
48  const auto& superChamberVec = station->superChambers();
49  if (superChamberVec.empty() || superChamberVec.front() == nullptr) {
50  edm::LogError(kLogCategory_) << "Super chambers missing or null for region = " << region_id
51  << " and station = " << station_id;
52  } else {
53  const GEMSuperChamber* super_chamber = superChamberVec.front();
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_tof_[key3] = bookHist1D(
60  booker, key3, "tof", "Time of Flight of Muon SimHits", 40, tof_min, tof_max, tof_xtitle, tof_ytitle);
61 
63  booker, key3, "tof_muon", "SimHit TOF (Muon only)", 40, tof_min, tof_max, tof_xtitle, tof_ytitle);
64  } // chamber loop
65  } // end else
66  } // station loop
67  } // region loop
68  } // detail plot
69 
70  // NOTE Energy Loss
71  booker.setCurrentFolder("MuonGEMHitsV/GEMHitsTask/EnergyLoss");
72 
73  TString eloss_xtitle = "Energy loss [eV]";
74  TString eloss_ytitle = "Entries / 100 eV";
75 
76  for (const auto& station : gem->regions()[0]->stations()) {
77  Int_t station_id = station->station();
78 
79  auto eloss_name = TString::Format("eloss_muon_st%d", station_id);
80  auto eloss_title = TString::Format("SimHit Energy Loss (Muon only) : Station %d", station_id);
81 
82  me_eloss_mu_[station_id] =
83  booker.book1D(eloss_name, eloss_title + ";" + eloss_xtitle + ";" + eloss_ytitle, 60, 0.0, 6000.0);
84  } // station loop
85 
86  if (detail_plot_) {
87  for (const auto& region : gem->regions()) {
88  Int_t region_id = region->region();
89  for (const auto& station : region->stations()) {
90  Int_t station_id = station->station();
91  const auto& superChamberVec = station->superChambers();
92  if (superChamberVec.empty() || superChamberVec.front() == nullptr) {
93  edm::LogError(kLogCategory_) << "Super chambers missing or null for region = " << region_id
94  << " and station = " << station_id;
95  } else {
96  for (const auto& chamber : superChamberVec.front()->chambers()) {
97  Int_t layer_id = chamber->id().layer();
98  ME3IdsKey key3{region_id, station_id, layer_id};
99 
100  me_detail_eloss_[key3] =
101  bookHist1D(booker, key3, "eloss", "SimHit Energy Loss", 60, 0.0, 6000.0, eloss_xtitle, eloss_ytitle);
102 
103  me_detail_eloss_mu_[key3] = bookHist1D(booker,
104  key3,
105  "eloss_muon",
106  "SimHit Energy Loss (Muon Only)",
107  60,
108  0.0,
109  6000.0,
110  eloss_xtitle,
111  eloss_ytitle);
112 
113  } // chamber loop
114  } // end else
115  } // station loop
116  } // region loop
117  } // detail plot
118 
119  // NOTE Occupancy
120  booker.setCurrentFolder("MuonGEMHitsV/GEMHitsTask/Occupancy");
121 
122  for (const auto& region : gem->regions()) {
123  Int_t region_id = region->region();
124 
125  me_occ_zr_[region_id] = bookZROccupancy(booker, region_id, "simhit", "SimHit");
126 
127  for (const auto& station : region->stations()) {
128  Int_t station_id = station->station();
129  ME2IdsKey key2{region_id, station_id};
130 
131  me_occ_det_[key2] = bookDetectorOccupancy(booker, key2, station, "simhit", "SimHit");
132 
133  const auto& superChamberVec = station->superChambers();
134  if (superChamberVec.empty() || superChamberVec.front() == nullptr) {
135  edm::LogError(kLogCategory_) << "Super chambers missing or null for region = " << region_id
136  << " and station = " << station_id;
137  } else {
138  const GEMSuperChamber* super_chamber = superChamberVec.front();
139  for (const auto& chamber : super_chamber->chambers()) {
140  Int_t layer_id = chamber->id().layer();
141  ME3IdsKey key3{region_id, station_id, layer_id};
142 
143  me_occ_xy_[key3] = bookXYOccupancy(booker, key3, "simhit", "SimHit");
144  } // layer loop
145  } // end else
146  } // station loop
147  } // region loop
148 }
149 
150 std::tuple<Double_t, Double_t> GEMSimHitValidation::getTOFRange(Int_t station_id) {
151  UInt_t start_index = station_id == 1 ? 0 : 2;
152  Double_t tof_min = tof_range_[start_index];
153  Double_t tof_max = tof_range_[start_index + 1];
154  return std::make_tuple(tof_min, tof_max);
155 }
156 
158  const GEMGeometry* gem = initGeometry(setup);
159 
160  edm::Handle<edm::PSimHitContainer> simhit_container;
161  event.getByToken(simhit_token_, simhit_container);
162  if (not simhit_container.isValid()) {
163  edm::LogError(kLogCategory_) << "Cannot get GEMHits by Token simhitLabel" << std::endl;
164  return;
165  }
166 
167  for (const auto& simhit : *simhit_container.product()) {
168  const GEMDetId gemid(simhit.detUnitId());
169 
170  if (gem->idToDet(gemid) == nullptr) {
171  edm::LogError(kLogCategory_) << "SimHit did not matched with GEM Geometry." << std::endl;
172  continue;
173  }
174 
175  Int_t region_id = gemid.region();
176  Int_t station_id = gemid.station();
177  Int_t layer_id = gemid.layer();
178  Int_t chamber_id = gemid.chamber();
179  Int_t roll_id = gemid.roll();
180 
181  ME2IdsKey key2{region_id, station_id};
182  ME3IdsKey key3{region_id, station_id, layer_id};
183 
184  GlobalPoint&& simhit_global_pos = gem->idToDet(gemid)->surface().toGlobal(simhit.localPosition());
185 
186  Float_t simhit_g_r = simhit_global_pos.perp();
187  Float_t simhit_g_x = simhit_global_pos.x();
188  Float_t simhit_g_y = simhit_global_pos.y();
189  Float_t simhit_g_abs_z = std::fabs(simhit_global_pos.z());
190 
191  Float_t energy_loss = kEnergyCF_ * simhit.energyLoss();
192  Float_t tof = simhit.timeOfFlight();
193 
194  // NOTE Fill MonitorElement
195  Int_t bin_x = getDetOccBinX(chamber_id, layer_id);
196 
197  me_occ_zr_[region_id]->Fill(simhit_g_abs_z, simhit_g_r);
198  me_occ_det_[key2]->Fill(bin_x, roll_id);
199  me_occ_xy_[key3]->Fill(simhit_g_x, simhit_g_y);
200 
201  bool is_muon_simhit = isMuonSimHit(simhit);
202  if (is_muon_simhit) {
203  me_tof_mu_[station_id]->Fill(tof);
204  me_eloss_mu_[station_id]->Fill(energy_loss);
205  }
206 
207  if (detail_plot_) {
208  me_detail_tof_[key3]->Fill(tof);
209  me_detail_eloss_[key3]->Fill(energy_loss);
210 
211  if (is_muon_simhit) {
212  me_detail_tof_mu_[key3]->Fill(tof);
213  me_detail_eloss_mu_[key3]->Fill(energy_loss);
214  }
215 
216  } // detail_plot
217  } // simhit loop
218 }
ME2IdsKey
std::tuple< Int_t, Int_t > ME2IdsKey
Definition: GEMValidationUtils.h:16
GEMSimHitValidation::tof_range_
std::vector< Double_t > tof_range_
Definition: GEMSimHitValidation.h:23
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:210
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
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:16
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
PSimHitContainer.h
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:30
GEMSimHitValidation::me_detail_tof_mu_
MEMap3Ids me_detail_tof_mu_
Definition: GEMSimHitValidation.h:28
GEMSimHitValidation::me_occ_zr_
MEMap1Ids me_occ_zr_
Definition: GEMSimHitValidation.h:32
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:157
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
GEMBaseValidation::initGeometry
const GEMGeometry * initGeometry(const edm::EventSetup &)
Definition: GEMBaseValidation.cc:23
GEMSimHitValidation::me_occ_det_
MEMap2Ids me_occ_det_
Definition: GEMSimHitValidation.h:33
GEMBaseValidation::bookXYOccupancy
dqm::impl::MonitorElement * bookXYOccupancy(DQMStore::IBooker &booker, const T &key, const char *name_prefix, const char *title_prefix)
Definition: GEMBaseValidation.h:134
Point3DBase< float, GlobalTag >
GEMSimHitValidation::me_detail_eloss_mu_
MEMap3Ids me_detail_eloss_mu_
Definition: GEMSimHitValidation.h:31
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
GEMDetId
Definition: GEMDetId.h:17
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
GEMBaseValidation
Definition: GEMBaseValidation.h:19
GEMSimHitValidation::me_occ_xy_
MEMap3Ids me_occ_xy_
Definition: GEMSimHitValidation.h:34
edm::EventSetup
Definition: EventSetup.h:57
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:150
writedatasetfile.run
run
Definition: writedatasetfile.py:27
GEMSimHitValidation::me_detail_tof_
MEMap3Ids me_detail_tof_
Definition: GEMSimHitValidation.h:27
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
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
GEMSimHitValidation::me_tof_mu_
std::map< Int_t, MonitorElement * > me_tof_mu_
Definition: GEMSimHitValidation.h:26
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:14
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
edm::InputTag
Definition: InputTag.h:15
GEMSimHitValidation::kEnergyCF_
const Float_t kEnergyCF_
Definition: GEMSimHitValidation.h:37
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
GEMSimHitValidation::me_eloss_mu_
MEMap1Ids me_eloss_mu_
Definition: GEMSimHitValidation.h:29