2 #include <unordered_map> 47 std::unordered_map<unsigned int, Histogram_TICLTrackstersEdgesValidation>;
82 trackstersCollectionsNames_.emplace_back(tag.label());
83 return consumes<std::vector<Trackster>>(tag);
111 iEvent.getByToken(trackster_token, trackster_h);
112 auto numberOfTracksters = trackster_h->size();
114 const auto&
histo =
histos.at(trackster_token.index());
115 histo.number_->Fill(numberOfTracksters);
116 for (
unsigned int i = 0;
i < numberOfTracksters; ++
i) {
117 const auto& thisTrackster = trackster_h->at(
i);
121 histo.raw_energy_->Fill(thisTrackster.raw_energy());
122 histo.regr_energy_->Fill(thisTrackster.regressed_energy());
123 histo.raw_energy_vs_regr_energy_->Fill(thisTrackster.regressed_energy(), thisTrackster.raw_energy());
124 const auto& probs = thisTrackster.id_probabilities();
125 std::vector<int> sorted_probs_idx(probs.size());
126 std::iota(begin(sorted_probs_idx),
end(sorted_probs_idx), 0);
127 std::sort(begin(sorted_probs_idx),
end(sorted_probs_idx), [&probs](
int i,
int j) {
return probs[
i] > probs[
j]; });
128 histo.id_prob_->Fill(sorted_probs_idx[0]);
129 if (!thisTrackster.vertices().empty()) {
130 histo.raw_energy_1plusLC_->Fill(thisTrackster.raw_energy());
131 histo.regr_energy_1plusLC_->Fill(thisTrackster.regressed_energy());
132 histo.raw_energy_vs_regr_energy_1plusLC_->Fill(thisTrackster.regressed_energy(), thisTrackster.raw_energy());
133 histo.id_prob_1plusLC_->Fill(sorted_probs_idx[0]);
137 for (
const auto& edge : thisTrackster.edges()) {
140 auto const& cl_in = ic.hitsAndFractions()[0].first;
141 auto const& cl_out = oc.hitsAndFractions()[0].first;
144 histo.delta_energy_->Fill(oc.energy() - ic.energy());
145 histo.delta_energy_relative_->Fill((oc.energy() - ic.energy()) / ic.energy());
146 histo.delta_energy_vs_energy_->Fill(oc.energy() - ic.energy(), ic.energy());
147 histo.delta_energy_vs_layer_->Fill(layer_in, oc.energy() - ic.energy());
148 histo.delta_energy_relative_vs_layer_->Fill(layer_in, (oc.energy() - ic.energy()) / ic.energy());
149 histo.delta_layer_->Fill(layer_out - layer_in);
152 const auto& outer_outer_pos = oc.position();
153 const auto& outer_inner_pos = ic.position();
154 const auto&
seed = thisTrackster.seedIndex();
157 auto seedDirectionPos = outer_inner_pos;
158 if (thisTrackster.seedID().id() != 0) {
161 if (
s.index ==
seed) {
164 math::XYZPoint(
s.directionAtOrigin.x(),
s.directionAtOrigin.y(),
s.directionAtOrigin.z());
170 auto alpha = (outer_inner_pos - seedGlobalPos).Dot(outer_outer_pos - outer_inner_pos) /
171 sqrt((outer_inner_pos - seedGlobalPos).Mag2() * (outer_outer_pos - outer_inner_pos).Mag2());
172 auto alpha_alternative = (outer_outer_pos - seedGlobalPos).Dot(seedDirectionPos) /
173 sqrt((outer_outer_pos - seedGlobalPos).Mag2() * seedDirectionPos.Mag2());
175 histo.angle_alpha_alternative_->Fill(alpha_alternative);
179 std::vector<std::array<unsigned int, 2>> innerDoublets;
180 std::vector<std::array<unsigned int, 2>> outerDoublets;
181 for (
const auto& otherEdge : thisTrackster.edges()) {
182 if (otherEdge[1] == edge[0]) {
183 innerDoublets.push_back(otherEdge);
185 if (edge[1] == otherEdge[0]) {
186 outerDoublets.push_back(otherEdge);
190 histo.ingoing_links_vs_layer_->Fill(layer_in, innerDoublets.size());
191 histo.outgoing_links_vs_layer_->Fill(layer_out, outerDoublets.size());
192 for (
const auto&
inner : innerDoublets) {
194 const auto& inner_inner_pos = inner_ic.position();
195 auto beta = (outer_inner_pos - inner_inner_pos).Dot(outer_outer_pos - inner_inner_pos) /
196 sqrt((outer_inner_pos - inner_inner_pos).Mag2() * (outer_outer_pos - inner_inner_pos).Mag2());
198 histo.angle_beta_byLayer_[layer_in]->Fill(
beta);
199 histo.angle_beta_w_byLayer_[layer_in]->Fill(
beta, ic.energy());
210 float eMin = 0., eThresh = 70.,
eMax = 500;
211 float eWidth[] = {0.5, 2.};
212 std::vector<float> eBins;
214 while (eVal <= eThresh) {
215 eBins.push_back(eVal);
218 while (eVal <
eMax) {
220 eBins.push_back(eVal);
222 int eNBins = eBins.size() - 1;
224 TString onePlusLC[] = {
"1plus LC",
"for tracksters with at least one LC"};
225 TString trkers =
"Tracksters";
226 static const char* particle_kind[] = {
227 "photon",
"electron",
"muon",
"neutral_pion",
"charged_hadron",
"neutral_hadron",
"ambiguous",
"unknown"};
228 auto nCategory =
sizeof(particle_kind) /
sizeof(*particle_kind);
234 "Number of Tracksters per Event",
"Number of Tracksters per Event;# Tracksters;Events", 250, 0., 250.);
237 histo.raw_energy_ = ibook.
book1D(
"Raw Energy",
"Raw Energy;Raw Energy [GeV];" + trkers, eNBins, &eBins[0]);
239 ibook.
book1D(
"Regressed Energy",
"Regressed Energy;Regressed Energy [GeV];" + trkers, eNBins, &eBins[0]);
240 histo.raw_energy_vs_regr_energy_ = ibook.
book2D(
"Raw Energy vs Regressed Energy",
241 "Raw vs Regressed Energy;Regressed Energy [GeV];Raw Energy [GeV]",
247 ibook.
book1D(
"ID probability",
"ID probability;category;Max ID probability", nCategory, 0, nCategory);
249 "Raw Energy " + onePlusLC[0],
"Raw Energy " + onePlusLC[1] +
";Raw Energy [GeV];" + trkers, eNBins, &eBins[0]);
250 histo.regr_energy_1plusLC_ = ibook.
book1D(
"Regressed Energy " + onePlusLC[0],
251 "Regressed Energy " + onePlusLC[1] +
";Regressed Energy [GeV];" + trkers,
254 histo.raw_energy_vs_regr_energy_1plusLC_ =
255 ibook.
book2D(
"Raw Energy vs Regressed Energy " + onePlusLC[0],
256 "Raw vs Regressed Energy " + onePlusLC[1] +
";Regressed Energy [GeV];Raw Energy [GeV]",
261 histo.id_prob_1plusLC_ = ibook.
book1D(
"ID probability " + onePlusLC[0],
262 "ID probability " + onePlusLC[1] +
";category;Max ID probability",
266 for (
int iBin = 0; iBin <
histo.id_prob_->getNbinsX(); iBin++) {
267 histo.id_prob_->setBinLabel(iBin + 1, particle_kind[iBin]);
268 histo.id_prob_1plusLC_->setBinLabel(iBin + 1, particle_kind[iBin]);
271 histo.delta_energy_ = ibook.
book1D(
"Delta energy",
"Delta Energy (O-I)", 800, -20., 20.);
272 histo.delta_energy_relative_ =
273 ibook.
book1D(
"Relative Delta energy",
"Relative Delta Energy (O-I)/I", 200, -10., 10.);
274 histo.delta_energy_vs_energy_ =
275 ibook.
book2D(
"Energy vs Delta Energy",
"Energy (I) vs Delta Energy (O-I)", 800, -20., 20., 200, 0., 20.);
277 "Delta Energy (O-I) vs Layer Number (I)",
"Delta Energy (O-I) vs Layer Number (I)", 50, 0., 50., 800, -20., 20.);
278 histo.delta_energy_relative_vs_layer_ = ibook.
book2D(
"Relative Delta Energy (O-I)_I vs Layer Number (I)",
279 "Relative Delta Energy (O-I)_I vs Layer Number (I)",
286 histo.ingoing_links_vs_layer_ =
287 ibook.
book2D(
"Ingoing links Layer Number",
"Ingoing links vs Layer Number", 50, 0., 50., 40, 0., 40.);
288 histo.outgoing_links_vs_layer_ =
289 ibook.
book2D(
"Outgoing links vs Layer Number",
"Outgoing links vs Layer Number", 50, 0., 50., 40, 0., 40.);
290 histo.delta_layer_ = ibook.
book1D(
"Delta Layer",
"Delta Layer", 10, 0., 10.);
291 histo.angle_alpha_ = ibook.
book1D(
"cosAngle Alpha",
"cosAngle Alpha", 200, -1., 1.);
292 histo.angle_beta_ = ibook.
book1D(
"cosAngle Beta",
"cosAngle Beta", 200, -1., 1.);
293 histo.angle_alpha_alternative_ = ibook.
book1D(
"cosAngle Alpha Alternative",
"Angle Alpha Alternative", 200, 0., 1.);
296 if (layerstr.length() < 2)
297 layerstr.insert(0, 2 - layerstr.length(),
'0');
298 histo.angle_beta_byLayer_.push_back(
299 ibook.
book1D(
"cosAngle Beta on Layer " + layerstr,
"cosAngle Beta on Layer " + layerstr, 200, -1., 1.));
300 histo.angle_beta_w_byLayer_.push_back(ibook.
book1D(
301 "cosAngle Beta Weighted on Layer " + layerstr,
"cosAngle Beta Weighted on Layer " + layerstr, 200, -1., 1.));
316 std::vector<edm::InputTag> source_vector{
edm::InputTag(
"ticlTrackstersTrk"),
321 desc.add<std::vector<edm::InputTag>>(
"tracksterCollections", source_vector);
326 descriptions.
add(
"ticlTrackstersEdgesValidationDefault",
desc);
edm::EDGetTokenT< std::vector< reco::CaloCluster > > layerClustersToken_
dqm::reco::MonitorElement * angle_alpha_alternative_
T getParameter(std::string const &) const
dqm::reco::MonitorElement * delta_energy_
virtual void setCurrentFolder(std::string const &fullpath)
dqm::reco::MonitorElement * raw_energy_vs_regr_energy_1plusLC_
hgcal::RecHitTools rhtools_
dqm::reco::MonitorElement * delta_energy_relative_vs_layer_
dqm::reco::MonitorElement * delta_energy_relative_
dqm::reco::MonitorElement * ingoing_links_vs_layer_
T const * product() const
dqm::reco::MonitorElement * delta_layer_
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, Histograms_TICLTrackstersEdgesValidation const &) const override
dqm::reco::MonitorElement * angle_beta_
std::string to_string(const V &value)
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, Histograms_TICLTrackstersEdgesValidation &) const override
example_stream void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
~TICLTrackstersEdgesValidation() override
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
dqm::reco::MonitorElement * regr_energy_1plusLC_
std::vector< dqm::reco::MonitorElement * > angle_beta_w_byLayer_
TICLTrackstersEdgesValidation(const edm::ParameterSet &)
dqm::reco::MonitorElement * angle_alpha_
dqm::reco::MonitorElement * id_prob_1plusLC_
#define DEFINE_FWK_MODULE(type)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
void dqmBeginRun(edm::Run const &, edm::EventSetup const &, Histograms_TICLTrackstersEdgesValidation &) const override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
example_global void dqmAnalyze(edm::Event const &, edm::EventSetup const &, Histograms___class__ const &) const override
XYZPointD XYZPoint
point in space with cartesian internal representation
std::vector< dqm::reco::MonitorElement * > angle_beta_byLayer_
dqm::reco::MonitorElement * outgoing_links_vs_layer_
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
edm::EDGetTokenT< std::vector< TICLSeedingRegion > > ticlSeedingGlobalToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
dqm::reco::MonitorElement * raw_energy_1plusLC_
dqm::reco::MonitorElement * delta_energy_vs_layer_
std::vector< edm::EDGetTokenT< std::vector< Trackster > > > tracksterTokens_
dqm::reco::MonitorElement * number_
std::unordered_map< unsigned int, Histogram_TICLTrackstersEdgesValidation > Histograms_TICLTrackstersEdgesValidation
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
edm::EDGetTokenT< std::vector< TICLSeedingRegion > > ticlSeedingTrkToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
dqm::reco::MonitorElement * delta_energy_vs_energy_
std::vector< std::string > trackstersCollectionsNames_