CMS 3D CMS Logo

EtlSimHitsValidation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Validation/MtdValidation
4 // Class: EtlSimHitsValidation
5 //
14 #include <string>
15 
20 
23 
27 
31 
34 
35 struct MTDHit {
36  float energy;
37  float time;
38  float x;
39  float y;
40  float z;
41 };
42 
44 public:
45  explicit EtlSimHitsValidation(const edm::ParameterSet&);
46  ~EtlSimHitsValidation() override;
47 
48  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
49 
50 private:
51  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
52 
53  void analyze(const edm::Event&, const edm::EventSetup&) override;
54 
55  // ------------ member data ------------
56 
58  const float hitMinEnergy_;
59 
61 
62  // --- histograms declaration
63 
66 
69 
73 
75 
81 
87 };
88 
89 // ------------ constructor and destructor --------------
91  : folder_(iConfig.getParameter<std::string>("folder")),
92  hitMinEnergy_(iConfig.getParameter<double>("hitMinimumEnergy")) {
93  etlSimHitsToken_ = consumes<CrossingFrame<PSimHit> >(iConfig.getParameter<edm::InputTag>("inputTag"));
94 }
95 
97 
98 // ------------ method called for each event ------------
100  using namespace edm;
101  using namespace geant_units::operators;
102 
103  edm::ESHandle<MTDGeometry> geometryHandle;
104  iSetup.get<MTDDigiGeometryRecord>().get(geometryHandle);
105  const MTDGeometry* geom = geometryHandle.product();
106 
107  auto etlSimHitsHandle = makeValid(iEvent.getHandle(etlSimHitsToken_));
108  MixCollection<PSimHit> etlSimHits(etlSimHitsHandle.product());
109 
110  std::unordered_map<uint32_t, MTDHit> m_etlHits[2];
111  std::unordered_map<uint32_t, std::set<int> > m_etlTrkPerCell[2];
112 
113  // --- Loop over the BLT SIM hits
114  for (auto const& simHit : etlSimHits) {
115  // --- Use only hits compatible with the in-time bunch-crossing
116  if (simHit.tof() < 0 || simHit.tof() > 25.)
117  continue;
118 
119  ETLDetId id = simHit.detUnitId();
120 
121  int idet = (id.zside() + 1) / 2;
122 
123  m_etlTrkPerCell[idet][id.rawId()].insert(simHit.trackId());
124 
125  auto simHitIt = m_etlHits[idet].emplace(id.rawId(), MTDHit()).first;
126 
127  // --- Accumulate the energy (in MeV) of SIM hits in the same detector cell
128  (simHitIt->second).energy += convertUnitsTo(0.001_MeV, simHit.energyLoss());
129 
130  // --- Get the time of the first SIM hit in the cell
131  if ((simHitIt->second).time == 0 || simHit.tof() < (simHitIt->second).time) {
132  (simHitIt->second).time = simHit.tof();
133 
134  auto hit_pos = simHit.entryPoint();
135  (simHitIt->second).x = hit_pos.x();
136  (simHitIt->second).y = hit_pos.y();
137  (simHitIt->second).z = hit_pos.z();
138  }
139 
140  } // simHit loop
141 
142  // ==============================================================================
143  // Histogram filling
144  // ==============================================================================
145 
146  for (int idet = 0; idet < 2; ++idet) {
147  meNhits_[idet]->Fill(m_etlHits[idet].size());
148 
149  for (auto const& hit : m_etlTrkPerCell[idet])
150  meNtrkPerCell_[idet]->Fill((hit.second).size());
151 
152  for (auto const& hit : m_etlHits[idet]) {
153  if ((hit.second).energy < hitMinEnergy_)
154  continue;
155 
156  // --- Get the SIM hit global position
157  ETLDetId detId(hit.first);
158 
159  DetId geoId = detId.geographicalId();
160  const MTDGeomDet* thedet = geom->idToDet(geoId);
161  if (thedet == nullptr)
162  throw cms::Exception("EtlSimHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " ("
163  << detId.rawId() << ") is invalid!" << std::dec << std::endl;
164 
165  Local3DPoint local_point(
166  convertMmToCm((hit.second).x), convertMmToCm((hit.second).y), convertMmToCm((hit.second).z));
167  const auto& global_point = thedet->toGlobal(local_point);
168 
169  // --- Fill the histograms
170 
171  meHitEnergy_[idet]->Fill((hit.second).energy);
172  meHitTime_[idet]->Fill((hit.second).time);
173 
174  meHitXlocal_[idet]->Fill((hit.second).x);
175  meHitYlocal_[idet]->Fill((hit.second).y);
176  meHitZlocal_[idet]->Fill((hit.second).z);
177 
178  meOccupancy_[idet]->Fill(global_point.x(), global_point.y());
179 
180  meHitX_[idet]->Fill(global_point.x());
181  meHitY_[idet]->Fill(global_point.y());
182  meHitZ_[idet]->Fill(global_point.z());
183  meHitPhi_[idet]->Fill(global_point.phi());
184  meHitEta_[idet]->Fill(global_point.eta());
185 
186  meHitTvsE_[idet]->Fill((hit.second).energy, (hit.second).time);
187  meHitEvsPhi_[idet]->Fill(global_point.phi(), (hit.second).energy);
188  meHitEvsEta_[idet]->Fill(global_point.eta(), (hit.second).energy);
189  meHitTvsPhi_[idet]->Fill(global_point.phi(), (hit.second).time);
190  meHitTvsEta_[idet]->Fill(global_point.eta(), (hit.second).time);
191 
192  } // hit loop
193 
194  } // idet loop
195 }
196 
197 // ------------ method for histogram booking ------------
199  edm::Run const& run,
200  edm::EventSetup const& iSetup) {
201  ibook.setCurrentFolder(folder_);
202 
203  // --- histograms booking
204 
205  meNhits_[1] = ibook.book1D("EtlNhitsZpos", "Number of ETL cells with SIM hits (+Z);N_{ETL cells}", 100, 0., 5000.);
206  meNhits_[0] = ibook.book1D("EtlNhitsZneg", "Number of ETL cells with SIM hits (-Z);N_{ETL cells}", 100, 0., 5000.);
207  meNtrkPerCell_[1] = ibook.book1D("EtlNtrkPerCellZpos", "Number of tracks per ETL sensor (+Z);N_{trk}", 10, 0., 10.);
208  meNtrkPerCell_[0] = ibook.book1D("EtlNtrkPerCellZneg", "Number of tracks per ETL sensor (-Z);N_{trk}", 10, 0., 10.);
209 
210  meHitEnergy_[1] = ibook.book1D("EtlHitEnergyZpos", "ETL SIM hits energy (+Z);E_{SIM} [MeV]", 100, 0., 3.);
211  meHitEnergy_[0] = ibook.book1D("EtlHitEnergyZneg", "ETL SIM hits energy (-Z);E_{SIM} [MeV]", 100, 0., 3.);
212  meHitTime_[1] = ibook.book1D("EtlHitTimeZpos", "ETL SIM hits ToA (+Z);ToA_{SIM} [ns]", 100, 0., 25.);
213  meHitTime_[0] = ibook.book1D("EtlHitTimeZneg", "ETL SIM hits ToA (-Z);ToA_{SIM} [ns]", 100, 0., 25.);
214 
215  meHitXlocal_[1] = ibook.book1D("EtlHitXlocalZpos", "ETL SIM local X (+Z);X_{SIM}^{LOC} [mm]", 100, -25., 25.);
216  meHitXlocal_[0] = ibook.book1D("EtlHitXlocalZneg", "ETL SIM local X (-Z);X_{SIM}^{LOC} [mm]", 100, -25., 25.);
217  meHitYlocal_[1] = ibook.book1D("EtlHitYlocalZpos", "ETL SIM local Y (+Z);Y_{SIM}^{LOC} [mm]", 100, -48., 48.);
218  meHitYlocal_[0] = ibook.book1D("EtlHitYlocalZneg", "ETL SIM local Y (-Z);Y_{SIM}^{LOC} [mm]", 100, -48., 48.);
219  meHitZlocal_[1] = ibook.book1D("EtlHitZlocalZpos", "ETL SIM local Z (+Z);Z_{SIM}^{LOC} [mm]", 80, -0.16, 0.16);
220  meHitZlocal_[0] = ibook.book1D("EtlHitZlocalZneg", "ETL SIM local Z (-Z);Z_{SIM}^{LOC} [mm]", 80, -0.16, 0.16);
221 
222  meOccupancy_[1] = ibook.book2D(
223  "EtlOccupancyZpos", "ETL SIM hits occupancy (+Z);X_{SIM} [cm];Y_{SIM} [cm]", 135, -135., 135., 135, -135., 135.);
224  meOccupancy_[0] = ibook.book2D(
225  "EtlOccupancyZneg", "ETL SIM hits occupancy (-Z);X_{SIM} [cm];Y_{SIM} [cm]", 135, -135., 135., 135, -135., 135.);
226 
227  meHitX_[1] = ibook.book1D("EtlHitXZpos", "ETL SIM hits X (+Z);X_{SIM} [cm]", 100, -130., 130.);
228  meHitX_[0] = ibook.book1D("EtlHitXZneg", "ETL SIM hits X (-Z);X_{SIM} [cm]", 100, -130., 130.);
229  meHitY_[1] = ibook.book1D("EtlHitYZpos", "ETL SIM hits Y (+Z);Y_{SIM} [cm]", 100, -130., 130.);
230  meHitY_[0] = ibook.book1D("EtlHitYZneg", "ETL SIM hits Y (-Z);Y_{SIM} [cm]", 100, -130., 130.);
231  meHitZ_[1] = ibook.book1D("EtlHitZZpos", "ETL SIM hits Z (+Z);Z_{SIM} [cm]", 100, 303.4, 304.2);
232  meHitZ_[0] = ibook.book1D("EtlHitZZneg", "ETL SIM hits Z (-Z);Z_{SIM} [cm]", 100, -304.2, -303.4);
233 
234  meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL SIM hits #phi (+Z);#phi_{SIM} [rad]", 100, -3.15, 3.15);
235  meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL SIM hits #phi (-Z);#phi_{SIM} [rad]", 100, -3.15, 3.15);
236  meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL SIM hits #eta (+Z);#eta_{SIM}", 100, 1.56, 3.2);
237  meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL SIM hits #eta (-Z);#eta_{SIM}", 100, -3.2, -1.56);
238 
239  meHitTvsE_[1] = ibook.bookProfile(
240  "EtlHitTvsEZpos", "ETL SIM time vs energy (+Z);E_{SIM} [MeV];T_{SIM} [ns]", 50, 0., 2., 0., 100.);
241  meHitTvsE_[0] = ibook.bookProfile(
242  "EtlHitTvsEZneg", "ETL SIM time vs energy (-Z);E_{SIM} [MeV];T_{SIM} [ns]", 50, 0., 2., 0., 100.);
243  meHitEvsPhi_[1] = ibook.bookProfile(
244  "EtlHitEvsPhiZpos", "ETL SIM energy vs #phi (+Z);#phi_{SIM} [rad];E_{SIM} [MeV]", 50, -3.15, 3.15, 0., 100.);
245  meHitEvsPhi_[0] = ibook.bookProfile(
246  "EtlHitEvsPhiZneg", "ETL SIM energy vs #phi (-Z);#phi_{SIM} [rad];E_{SIM} [MeV]", 50, -3.15, 3.15, 0., 100.);
247  meHitEvsEta_[1] = ibook.bookProfile(
248  "EtlHitEvsEtaZpos", "ETL SIM energy vs #eta (+Z);#eta_{SIM};E_{SIM} [MeV]", 50, 1.56, 3.2, 0., 100.);
249  meHitEvsEta_[0] = ibook.bookProfile(
250  "EtlHitEvsEtaZneg", "ETL SIM energy vs #eta (-Z);#eta_{SIM};E_{SIM} [MeV]", 50, -3.2, -1.56, 0., 100.);
251  meHitTvsPhi_[1] = ibook.bookProfile(
252  "EtlHitTvsPhiZpos", "ETL SIM time vs #phi (+Z);#phi_{SIM} [rad];T_{SIM} [ns]", 50, -3.15, 3.15, 0., 100.);
253  meHitTvsPhi_[0] = ibook.bookProfile(
254  "EtlHitTvsPhiZneg", "ETL SIM time vs #phi (-Z);#phi_{SIM} [rad];T_{SIM} [ns]", 50, -3.15, 3.15, 0., 100.);
255  meHitTvsEta_[1] = ibook.bookProfile(
256  "EtlHitTvsEtaZpos", "ETL SIM time vs #eta (+Z);#eta_{SIM};T_{SIM} [ns]", 50, 1.56, 3.2, 0., 100.);
257  meHitTvsEta_[0] = ibook.bookProfile(
258  "EtlHitTvsEtaZneg", "ETL SIM time vs #eta (-Z);#eta_{SIM};T_{SIM} [ns]", 50, -3.2, -1.56, 0., 100.);
259 }
260 
261 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
264 
265  desc.add<std::string>("folder", "MTD/ETL/SimHits");
266  desc.add<edm::InputTag>("inputTag", edm::InputTag("mix", "g4SimHitsFastTimerHitsEndcap"));
267  desc.add<double>("hitMinimumEnergy", 0.1); // [MeV]
268 
269  descriptions.add("etlSimHits", desc);
270 }
271 
MTDDigiGeometryRecord
Definition: MTDDigiGeometryRecord.h:15
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EtlSimHitsValidation::meHitTime_
MonitorElement * meHitTime_[2]
Definition: EtlSimHitsValidation.cc:68
dqm::impl::MonitorElement
Definition: MonitorElement.h:98
DDAxes::y
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
EtlSimHitsValidation::etlSimHitsToken_
edm::EDGetTokenT< CrossingFrame< PSimHit > > etlSimHitsToken_
Definition: EtlSimHitsValidation.cc:60
EtlSimHitsValidation::folder_
const std::string folder_
Definition: EtlSimHitsValidation.cc:57
edm::Run
Definition: Run.h:45
edm::EDGetTokenT
Definition: EDGetToken.h:33
geant_units::operators::convertUnitsTo
constexpr NumType convertUnitsTo(long double desiredUnits, NumType val)
Definition: GeantUnits.h:87
edm
HLT enums.
Definition: AlignableModifier.h:19
EtlSimHitsValidation::meHitTvsEta_
MonitorElement * meHitTvsEta_[2]
Definition: EtlSimHitsValidation.cc:86
CrossingFrame.h
MTDGeometry.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
TrackerGeomDet
Definition: TrackerGeomDet.h:6
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
MTDDigiGeometryRecord.h
DQMStore.h
EtlSimHitsValidation::~EtlSimHitsValidation
~EtlSimHitsValidation() override
Definition: EtlSimHitsValidation.cc:96
ETLDetId
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:15
DDAxes::x
EtlSimHitsValidation::meHitTvsPhi_
MonitorElement * meHitTvsPhi_[2]
Definition: EtlSimHitsValidation.cc:85
geant_units::operators
Definition: GeantUnits.h:18
ETLDetId.h
EtlSimHitsValidation::meHitZ_
MonitorElement * meHitZ_[2]
Definition: EtlSimHitsValidation.cc:78
EtlSimHitsValidation::meHitYlocal_
MonitorElement * meHitYlocal_[2]
Definition: EtlSimHitsValidation.cc:71
EtlSimHitsValidation::meHitEvsPhi_
MonitorElement * meHitEvsPhi_[2]
Definition: EtlSimHitsValidation.cc:83
EtlSimHitsValidation::meHitXlocal_
MonitorElement * meHitXlocal_[2]
Definition: EtlSimHitsValidation.cc:70
DetId
Definition: DetId.h:17
MakerMacros.h
EtlSimHitsValidation::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: EtlSimHitsValidation.cc:198
PSimHit.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
MixCollection.h
MixCollection
Definition: MixCollection.h:11
rpcPointValidation_cfi.simHit
simHit
Definition: rpcPointValidation_cfi.py:24
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
DDAxes::z
edm::ESHandle
Definition: DTSurvey.h:22
MTDHit::time
float time
Definition: BtlLocalRecoValidation.cc:46
dqm::implementation::IBooker::bookProfile
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:322
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
EtlSimHitsValidation::meHitZlocal_
MonitorElement * meHitZlocal_[2]
Definition: EtlSimHitsValidation.cc:72
ETLDetId::geographicalId
ETLDetId geographicalId() const
Definition: ETLDetId.h:81
Point3DBase< float, LocalTag >
MTDHit::x
float x
Definition: BtlSimHitsValidation.cc:45
MTDHit::y
float y
Definition: BtlSimHitsValidation.cc:46
DQMEDAnalyzer.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
ValidHandle.h
EtlSimHitsValidation::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: EtlSimHitsValidation.cc:262
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
folder_
std::string folder_
Definition: DQMEDAnalyzer.cc:60
DQMEDAnalyzer
Definition: DQMEDAnalyzer.py:1
GeomDet::toGlobal
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
MTDHit::energy
float energy
Definition: BtlLocalRecoValidation.cc:45
EtlSimHitsValidation::meHitEnergy_
MonitorElement * meHitEnergy_[2]
Definition: EtlSimHitsValidation.cc:67
GeantUnits.h
iEvent
int iEvent
Definition: GenABIO.cc:224
EtlSimHitsValidation::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: EtlSimHitsValidation.cc:99
EtlSimHitsValidation::meHitEta_
MonitorElement * meHitEta_[2]
Definition: EtlSimHitsValidation.cc:80
edm::EventSetup
Definition: EventSetup.h:57
edm::makeValid
auto makeValid(const U &iOtherHandleType) noexcept(false)
Definition: ValidHandle.h:52
get
#define get
EtlSimHitsValidation::hitMinEnergy_
const float hitMinEnergy_
Definition: EtlSimHitsValidation.cc:58
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
MTDGeometry
Definition: MTDGeometry.h:14
EtlSimHitsValidation::meHitX_
MonitorElement * meHitX_[2]
Definition: EtlSimHitsValidation.cc:76
EtlSimHitsValidation::meNhits_
MonitorElement * meNhits_[2]
Definition: EtlSimHitsValidation.cc:64
EtlSimHitsValidation::meOccupancy_
MonitorElement * meOccupancy_[2]
Definition: EtlSimHitsValidation.cc:74
std
Definition: JetResolutionObject.h:76
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
writedatasetfile.run
run
Definition: writedatasetfile.py:27
Frameworkfwd.h
EtlSimHitsValidation::meHitEvsEta_
MonitorElement * meHitEvsEta_[2]
Definition: EtlSimHitsValidation.cc:84
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
EtlSimHitsValidation::meHitTvsE_
MonitorElement * meHitTvsE_[2]
Definition: EtlSimHitsValidation.cc:82
Exception
Definition: hltDiff.cc:246
MTDHit::z
float z
Definition: BtlSimHitsValidation.cc:47
EtlSimHitsValidation::meHitPhi_
MonitorElement * meHitPhi_[2]
Definition: EtlSimHitsValidation.cc:79
dqm::implementation::IBooker
Definition: DQMStore.h:43
geant_units::operators::convertMmToCm
constexpr NumType convertMmToCm(NumType millimeters)
Definition: GeantUnits.h:62
EtlSimHitsValidation::meHitY_
MonitorElement * meHitY_[2]
Definition: EtlSimHitsValidation.cc:77
ParameterSet.h
EtlSimHitsValidation::meNtrkPerCell_
MonitorElement * meNtrkPerCell_[2]
Definition: EtlSimHitsValidation.cc:65
ntuplemaker.time
time
Definition: ntuplemaker.py:310
edm::Event
Definition: Event.h:73
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
EtlSimHitsValidation
Definition: EtlSimHitsValidation.cc:43
edm::InputTag
Definition: InputTag.h:15
hit
Definition: SiStripHitEffFromCalibTree.cc:88
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
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
EtlSimHitsValidation::EtlSimHitsValidation
EtlSimHitsValidation(const edm::ParameterSet &)
Definition: EtlSimHitsValidation.cc:90
MTDHit
Definition: BtlLocalRecoValidation.cc:44