CMS 3D CMS Logo

BtlSimHitsValidation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Validation/MtdValidation
4 // Class: BtlSimHitsValidation
5 //
14 #include <string>
15 
20 
23 
27 
31 
36 
39 
41 
42 struct MTDHit {
43  float energy;
44  float time;
45  float x;
46  float y;
47  float z;
48 };
49 
51 public:
52  explicit BtlSimHitsValidation(const edm::ParameterSet&);
53  ~BtlSimHitsValidation() override;
54 
55  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
56 
57 private:
58  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
59 
60  void analyze(const edm::Event&, const edm::EventSetup&) override;
61 
62  // ------------ member data ------------
63 
65  const float hitMinEnergy_;
66 
68 
69  // --- histograms declaration
70 
72 
75 
79 
83 
85 
91 
99 };
100 
101 // ------------ constructor and destructor --------------
103  : folder_(iConfig.getParameter<std::string>("folder")),
104  hitMinEnergy_(iConfig.getParameter<double>("hitMinimumEnergy")) {
105  btlSimHitsToken_ = consumes<CrossingFrame<PSimHit> >(iConfig.getParameter<edm::InputTag>("inputTag"));
106 }
107 
109 
110 // ------------ method called for each event ------------
112  using namespace edm;
113  using namespace geant_units::operators;
114 
115  edm::ESHandle<MTDGeometry> geometryHandle;
116  iSetup.get<MTDDigiGeometryRecord>().get(geometryHandle);
117  const MTDGeometry* geom = geometryHandle.product();
118 
119  edm::ESHandle<MTDTopology> topologyHandle;
120  iSetup.get<MTDTopologyRcd>().get(topologyHandle);
121  const MTDTopology* topology = topologyHandle.product();
122 
123  auto btlSimHitsHandle = makeValid(iEvent.getHandle(btlSimHitsToken_));
124  MixCollection<PSimHit> btlSimHits(btlSimHitsHandle.product());
125 
126  std::unordered_map<uint32_t, MTDHit> m_btlHits;
127  std::unordered_map<uint32_t, std::set<int> > m_btlTrkPerCell;
128 
129  // --- Loop over the BLT SIM hits
130  for (auto const& simHit : btlSimHits) {
131  // --- Use only hits compatible with the in-time bunch-crossing
132  if (simHit.tof() < 0 || simHit.tof() > 25.)
133  continue;
134 
135  DetId id = simHit.detUnitId();
136 
137  m_btlTrkPerCell[id.rawId()].insert(simHit.trackId());
138 
139  auto simHitIt = m_btlHits.emplace(id.rawId(), MTDHit()).first;
140 
141  // --- Accumulate the energy (in MeV) of SIM hits in the same detector cell
142  (simHitIt->second).energy += convertUnitsTo(0.001_MeV, simHit.energyLoss());
143 
144  // --- Get the time of the first SIM hit in the cell
145  if ((simHitIt->second).time == 0 || simHit.tof() < (simHitIt->second).time) {
146  (simHitIt->second).time = simHit.tof();
147 
148  auto hit_pos = simHit.entryPoint();
149  (simHitIt->second).x = hit_pos.x();
150  (simHitIt->second).y = hit_pos.y();
151  (simHitIt->second).z = hit_pos.z();
152  }
153 
154  } // simHit loop
155 
156  // ==============================================================================
157  // Histogram filling
158  // ==============================================================================
159 
160  if (!m_btlHits.empty())
161  meNhits_->Fill(log10(m_btlHits.size()));
162 
163  for (auto const& hit : m_btlTrkPerCell)
164  meNtrkPerCell_->Fill((hit.second).size());
165 
166  for (auto const& hit : m_btlHits) {
167  meHitLogEnergy_->Fill(log10((hit.second).energy));
168 
169  if ((hit.second).energy < hitMinEnergy_)
170  continue;
171 
172  // --- Get the SIM hit global position
173  BTLDetId detId(hit.first);
174  DetId geoId = detId.geographicalId(MTDTopologyMode::crysLayoutFromTopoMode(topology->getMTDTopologyMode()));
175  const MTDGeomDet* thedet = geom->idToDet(geoId);
176  if (thedet == nullptr)
177  throw cms::Exception("BtlSimHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " ("
178  << detId.rawId() << ") is invalid!" << std::dec << std::endl;
179  const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(thedet->topology());
180  const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology());
181 
182  Local3DPoint local_point(
183  convertMmToCm((hit.second).x), convertMmToCm((hit.second).y), convertMmToCm((hit.second).z));
184 
185  local_point = topo.pixelToModuleLocalPoint(local_point, detId.row(topo.nrows()), detId.column(topo.nrows()));
186  const auto& global_point = thedet->toGlobal(local_point);
187 
188  // --- Fill the histograms
189  meHitEnergy_->Fill((hit.second).energy);
190  meHitTime_->Fill((hit.second).time);
191 
192  meHitXlocal_->Fill((hit.second).x);
193  meHitYlocal_->Fill((hit.second).y);
194  meHitZlocal_->Fill((hit.second).z);
195 
196  meOccupancy_->Fill(global_point.z(), global_point.phi());
197 
198  meHitX_->Fill(global_point.x());
199  meHitY_->Fill(global_point.y());
200  meHitZ_->Fill(global_point.z());
201  meHitPhi_->Fill(global_point.phi());
202  meHitEta_->Fill(global_point.eta());
203 
204  meHitTvsE_->Fill((hit.second).energy, (hit.second).time);
205  meHitEvsPhi_->Fill(global_point.phi(), (hit.second).energy);
206  meHitEvsEta_->Fill(global_point.eta(), (hit.second).energy);
207  meHitEvsZ_->Fill(global_point.z(), (hit.second).energy);
208  meHitTvsPhi_->Fill(global_point.phi(), (hit.second).time);
209  meHitTvsEta_->Fill(global_point.eta(), (hit.second).time);
210  meHitTvsZ_->Fill(global_point.z(), (hit.second).time);
211 
212  } // hit loop
213 
214  // --- This is to count the number of processed events, needed in the harvesting step
215  meNevents_->Fill(0.5);
216 }
217 
218 // ------------ method for histogram booking ------------
220  edm::Run const& run,
221  edm::EventSetup const& iSetup) {
222  ibook.setCurrentFolder(folder_);
223 
224  // --- histograms booking
225 
226  meNevents_ = ibook.book1D("BtlNevents", "Number of events", 1, 0., 1.);
227 
228  meNhits_ = ibook.book1D("BtlNhits", "Number of BTL cells with SIM hits;log_{10}(N_{BTL cells})", 100, 0., 5.25);
229  meNtrkPerCell_ = ibook.book1D("BtlNtrkPerCell", "Number of tracks per BTL cell;N_{trk}", 10, 0., 10.);
230 
231  meHitEnergy_ = ibook.book1D("BtlHitEnergy", "BTL SIM hits energy;E_{SIM} [MeV]", 100, 0., 20.);
232  meHitLogEnergy_ = ibook.book1D("BtlHitLogEnergy", "BTL SIM hits energy;log_{10}(E_{SIM} [MeV])", 200, -6., 3.);
233  meHitTime_ = ibook.book1D("BtlHitTime", "BTL SIM hits ToA;ToA_{SIM} [ns]", 100, 0., 25.);
234 
235  meHitXlocal_ = ibook.book1D("BtlHitXlocal", "BTL SIM local X;X_{SIM}^{LOC} [mm]", 100, -30., 30.);
236  meHitYlocal_ = ibook.book1D("BtlHitYlocal", "BTL SIM local Y;Y_{SIM}^{LOC} [mm]", 100, -1.65, 1.65);
237  meHitZlocal_ = ibook.book1D("BtlHitZlocal", "BTL SIM local z;z_{SIM}^{LOC} [mm]", 100, -2., 2.);
238 
239  meOccupancy_ = ibook.book2D(
240  "BtlOccupancy", "BTL SIM hits occupancy;z_{SIM} [cm];#phi_{SIM} [rad]", 130, -260., 260., 200, -3.15, 3.15);
241 
242  meHitX_ = ibook.book1D("BtlHitX", "BTL SIM hits X;X_{SIM} [cm]", 100, -120., 120.);
243  meHitY_ = ibook.book1D("BtlHitY", "BTL SIM hits Y;Y_{SIM} [cm]", 100, -120., 120.);
244  meHitZ_ = ibook.book1D("BtlHitZ", "BTL SIM hits Z;Z_{SIM} [cm]", 100, -260., 260.);
245  meHitPhi_ = ibook.book1D("BtlHitPhi", "BTL SIM hits #phi;#phi_{SIM} [rad]", 200, -3.15, 3.15);
246  meHitEta_ = ibook.book1D("BtlHitEta", "BTL SIM hits #eta;#eta_{SIM}", 100, -1.55, 1.55);
247 
248  meHitTvsE_ =
249  ibook.bookProfile("BtlHitTvsE", "BTL SIM time vs energy;E_{SIM} [MeV];T_{SIM} [ns]", 50, 0., 20., 0., 100.);
250  meHitEvsPhi_ = ibook.bookProfile(
251  "BtlHitEvsPhi", "BTL SIM energy vs #phi;#phi_{SIM} [rad];E_{SIM} [MeV]", 50, -3.15, 3.15, 0., 100.);
252  meHitEvsEta_ =
253  ibook.bookProfile("BtlHitEvsEta", "BTL SIM energy vs #eta;#eta_{SIM};E_{SIM} [MeV]", 50, -1.55, 1.55, 0., 100.);
254  meHitEvsZ_ =
255  ibook.bookProfile("BtlHitEvsZ", "BTL SIM energy vs Z;Z_{SIM} [cm];E_{SIM} [MeV]", 50, -260., 260., 0., 100.);
256  meHitTvsPhi_ = ibook.bookProfile(
257  "BtlHitTvsPhi", "BTL SIM time vs #phi;#phi_{SIM} [rad];T_{SIM} [ns]", 50, -3.15, 3.15, 0., 100.);
258  meHitTvsEta_ =
259  ibook.bookProfile("BtlHitTvsEta", "BTL SIM time vs #eta;#eta_{SIM};T_{SIM} [ns]", 50, -1.55, 1.55, 0., 100.);
260  meHitTvsZ_ =
261  ibook.bookProfile("BtlHitTvsZ", "BTL SIM time vs Z;Z_{SIM} [cm];T_{SIM} [ns]", 50, -260., 260., 0., 100.);
262 }
263 
264 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
267 
268  desc.add<std::string>("folder", "MTD/BTL/SimHits");
269  desc.add<edm::InputTag>("inputTag", edm::InputTag("mix", "g4SimHitsFastTimerHitsBarrel"));
270  desc.add<double>("hitMinimumEnergy", 1.); // [MeV]
271 
272  descriptions.add("btlSimHits", desc);
273 }
274 
BtlSimHitsValidation::meHitTvsE_
MonitorElement * meHitTvsE_
Definition: BtlSimHitsValidation.cc:92
MTDDigiGeometryRecord
Definition: MTDDigiGeometryRecord.h:15
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
dqm::impl::MonitorElement
Definition: MonitorElement.h:98
DDAxes::y
BTLDetId.h
BtlSimHitsValidation::meHitEvsZ_
MonitorElement * meHitEvsZ_
Definition: BtlSimHitsValidation.cc:95
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
BtlSimHitsValidation::meHitZ_
MonitorElement * meHitZ_
Definition: BtlSimHitsValidation.cc:88
BtlSimHitsValidation::meHitYlocal_
MonitorElement * meHitYlocal_
Definition: BtlSimHitsValidation.cc:81
BtlSimHitsValidation::meHitLogEnergy_
MonitorElement * meHitLogEnergy_
Definition: BtlSimHitsValidation.cc:77
BtlSimHitsValidation::btlSimHitsToken_
edm::EDGetTokenT< CrossingFrame< PSimHit > > btlSimHitsToken_
Definition: BtlSimHitsValidation.cc:67
edm::Run
Definition: Run.h:45
BtlSimHitsValidation::meHitEta_
MonitorElement * meHitEta_
Definition: BtlSimHitsValidation.cc:90
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
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
ProxyMTDTopology::specificTopology
virtual const PixelTopology & specificTopology() const
Definition: ProxyMTDTopology.h:89
DQMStore.h
GeomDet::topology
virtual const Topology & topology() const
Definition: GeomDet.cc:67
DDAxes::x
geant_units::operators
Definition: GeantUnits.h:18
MTDTopologyMode.h
BtlSimHitsValidation::meHitXlocal_
MonitorElement * meHitXlocal_
Definition: BtlSimHitsValidation.cc:80
BtlSimHitsValidation::BtlSimHitsValidation
BtlSimHitsValidation(const edm::ParameterSet &)
Definition: BtlSimHitsValidation.cc:102
BtlSimHitsValidation::folder_
const std::string folder_
Definition: BtlSimHitsValidation.cc:64
BtlSimHitsValidation::meHitTvsZ_
MonitorElement * meHitTvsZ_
Definition: BtlSimHitsValidation.cc:98
DetId
Definition: DetId.h:17
MakerMacros.h
BTLDetId
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0,...
Definition: BTLDetId.h:18
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
ecaldqm::topology
const CaloTopology * topology(nullptr)
rpcPointValidation_cfi.simHit
simHit
Definition: rpcPointValidation_cfi.py:24
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
BTLDetId::row
int row(unsigned nrows=16) const
Definition: BTLDetId.h:105
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
RectangularMTDTopology.h
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
BtlSimHitsValidation::hitMinEnergy_
const float hitMinEnergy_
Definition: BtlSimHitsValidation.cc:65
BtlSimHitsValidation::meHitPhi_
MonitorElement * meHitPhi_
Definition: BtlSimHitsValidation.cc:89
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
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
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
BtlSimHitsValidation::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: BtlSimHitsValidation.cc:219
folder_
std::string folder_
Definition: DQMEDAnalyzer.cc:60
DQMEDAnalyzer
Definition: DQMEDAnalyzer.py:1
MTDTopology
Definition: MTDTopology.h:16
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
MTDTopologyRcd
Definition: MTDTopologyRcd.h:10
Event.h
MTDTopologyMode::crysLayoutFromTopoMode
BTLDetId::CrysLayout crysLayoutFromTopoMode(const int &topoMode)
Definition: MTDTopologyMode.h:19
MTDHit::energy
float energy
Definition: BtlLocalRecoValidation.cc:45
GeantUnits.h
BtlSimHitsValidation::meNevents_
MonitorElement * meNevents_
Definition: BtlSimHitsValidation.cc:71
BtlSimHitsValidation::meHitTime_
MonitorElement * meHitTime_
Definition: BtlSimHitsValidation.cc:78
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
BtlSimHitsValidation::meHitTvsEta_
MonitorElement * meHitTvsEta_
Definition: BtlSimHitsValidation.cc:97
edm::makeValid
auto makeValid(const U &iOtherHandleType) noexcept(false)
Definition: ValidHandle.h:52
get
#define get
BtlSimHitsValidation::meNhits_
MonitorElement * meNhits_
Definition: BtlSimHitsValidation.cc:73
BtlSimHitsValidation
Definition: BtlSimHitsValidation.cc:50
BtlSimHitsValidation::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: BtlSimHitsValidation.cc:111
RectangularMTDTopology
Definition: RectangularMTDTopology.h:39
BtlSimHitsValidation::meHitZlocal_
MonitorElement * meHitZlocal_
Definition: BtlSimHitsValidation.cc:82
ProxyMTDTopology
Definition: ProxyMTDTopology.h:28
ProxyMTDTopology.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
MTDGeometry
Definition: MTDGeometry.h:14
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
MTDTopologyRcd.h
Frameworkfwd.h
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
Exception
Definition: hltDiff.cc:246
MTDHit::z
float z
Definition: BtlSimHitsValidation.cc:47
BtlSimHitsValidation::meHitEnergy_
MonitorElement * meHitEnergy_
Definition: BtlSimHitsValidation.cc:76
dqm::implementation::IBooker
Definition: DQMStore.h:43
geant_units::operators::convertMmToCm
constexpr NumType convertMmToCm(NumType millimeters)
Definition: GeantUnits.h:62
BtlSimHitsValidation::meNtrkPerCell_
MonitorElement * meNtrkPerCell_
Definition: BtlSimHitsValidation.cc:74
ParameterSet.h
BTLDetId::geographicalId
BTLDetId geographicalId(CrysLayout lay) const
Definition: BTLDetId.cc:171
ntuplemaker.time
time
Definition: ntuplemaker.py:310
edm::Event
Definition: Event.h:73
BtlSimHitsValidation::meHitTvsPhi_
MonitorElement * meHitTvsPhi_
Definition: BtlSimHitsValidation.cc:96
BtlSimHitsValidation::meHitEvsEta_
MonitorElement * meHitEvsEta_
Definition: BtlSimHitsValidation.cc:94
BtlSimHitsValidation::~BtlSimHitsValidation
~BtlSimHitsValidation() override
Definition: BtlSimHitsValidation.cc:108
BtlSimHitsValidation::meHitY_
MonitorElement * meHitY_
Definition: BtlSimHitsValidation.cc:87
BtlSimHitsValidation::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: BtlSimHitsValidation.cc:265
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
edm::InputTag
Definition: InputTag.h:15
BtlSimHitsValidation::meHitX_
MonitorElement * meHitX_
Definition: BtlSimHitsValidation.cc:86
MTDTopology.h
hit
Definition: SiStripHitEffFromCalibTree.cc:88
BtlSimHitsValidation::meOccupancy_
MonitorElement * meOccupancy_
Definition: BtlSimHitsValidation.cc:84
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
BtlSimHitsValidation::meHitEvsPhi_
MonitorElement * meHitEvsPhi_
Definition: BtlSimHitsValidation.cc:93
BTLDetId::column
int column(unsigned nrows=16) const
Definition: BTLDetId.h:110
MTDHit
Definition: BtlLocalRecoValidation.cc:44