From 464d5aaa8d833e9a95b9ad042348a5ed75e7477f Mon Sep 17 00:00:00 2001 From: Alex Mourtziapis Date: Tue, 12 Mar 2019 14:26:36 +0100 Subject: [PATCH 1/4] Added time window selection for LayerClusters --- .../Calo/plugins/FWCaloClusterProxyBuilder.cc | 111 +++++++++++++----- 1 file changed, 82 insertions(+), 29 deletions(-) diff --git a/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc b/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc index 27859a719793e..ff1deb682b7d1 100644 --- a/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc +++ b/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc @@ -2,7 +2,8 @@ #include "Fireworks/Core/interface/FWEventItem.h" #include "Fireworks/Core/interface/FWGeometry.h" #include "Fireworks/Core/interface/BuilderUtils.h" -#include "DataFormats/CaloRecHit/interface/CaloCluster.h" +#include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h" +#include "DataFormats/Common/interface/ValueMap.h" #include "TEveBoxSet.h" #include "TEveStraightLineSet.h" @@ -16,25 +17,75 @@ class FWCaloClusterProxyBuilder : public FWHeatmapProxyBuilderTemplate> CaloToParticleBasedIsoMapHandle; + double timeLowerBound, timeUpperBound; + long layer; + double saturation_energy; + bool heatmap; + bool z_plus; + bool z_minus; + bool p_showClusterWithoutTimeInfo; + FWCaloClusterProxyBuilder(const FWCaloClusterProxyBuilder &) = delete; // stop default const FWCaloClusterProxyBuilder &operator=(const FWCaloClusterProxyBuilder &) = delete; // stop default - + + void setItem(const FWEventItem *iItem) override; + + void build(const FWEventItem *iItem, TEveElementList *product, const FWViewContext *vc) override; void build(const reco::CaloCluster &iData, unsigned int iIndex, TEveElement &oItemHolder, const FWViewContext *) override; }; +void FWCaloClusterProxyBuilder::setItem(const FWEventItem *iItem) +{ + FWProxyBuilderBase::setItem(iItem); + if (iItem) + { + // const reco::CaloCluster &iData = modelData(0); + // isHGCal = (iData.algo() >= 6 && iData.algo() <= 8); + + iItem->getConfig()->keepEntries(true); + iItem->getConfig()->assertParam("TimeLowerBound", 0.2, 0.01, 1.0); + iItem->getConfig()->assertParam("TimeUpperBound", 0.3, 0.01, 1.0); + iItem->getConfig()->assertParam("ShowClusterWithoutTimeInfo", false); + + iItem->getConfig()->assertParam("Layer", 0L, 0L, 52L); + iItem->getConfig()->assertParam("EnergyCutOff", 0.5, 0.2, 5.0); + iItem->getConfig()->assertParam("Heatmap", true); + iItem->getConfig()->assertParam("Z+", true); + iItem->getConfig()->assertParam("Z-", true); + } +} + +void FWCaloClusterProxyBuilder::build(const FWEventItem *iItem, TEveElementList *product, const FWViewContext *vc) +{ + iItem->getEvent()->getByLabel(edm::InputTag("hgcalLayerClusters", "timeLayerCluster"), CaloToParticleBasedIsoMapHandle); + timeLowerBound = std::min(item()->getConfig()->value("TimeLowerBound"), item()->getConfig()->value("TimeUpperBound")); + timeUpperBound = std::max(item()->getConfig()->value("TimeLowerBound"), item()->getConfig()->value("TimeUpperBound")); + + layer = item()->getConfig()->value("Layer"); + saturation_energy = item()->getConfig()->value("EnergyCutOff"); + heatmap = item()->getConfig()->value("Heatmap"); + z_plus = item()->getConfig()->value("Z+"); + z_minus = item()->getConfig()->value("Z-"); + p_showClusterWithoutTimeInfo = item()->getConfig()->value("ShowClusterWithoutTimeInfo"); + + FWHeatmapProxyBuilderTemplate::build(iItem, product, vc); +} + void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned int iIndex, TEveElement &oItemHolder, const FWViewContext *) { - const long layer = item()->getConfig()->value("Layer"); - const double saturation_energy = item()->getConfig()->value("EnergyCutOff"); - const bool heatmap = item()->getConfig()->value("Heatmap"); - const bool z_plus = item()->getConfig()->value("Z+"); - const bool z_minus = item()->getConfig()->value("Z-"); + if (!p_showClusterWithoutTimeInfo && CaloToParticleBasedIsoMapHandle.isValid()) + { + const float time = CaloToParticleBasedIsoMapHandle->get(iIndex); + if (time < timeLowerBound || time > timeUpperBound) + return; + } std::vector> clusterDetIds = iData.hitsAndFractions(); bool h_hex(false); TEveBoxSet *hex_boxset = new TEveBoxSet(); - if(!heatmap) + if (!heatmap) hex_boxset->UseSingleColor(); hex_boxset->SetPickable(true); hex_boxset->Reset(TEveBoxSet::kBT_Hex, true, 64); @@ -42,7 +93,7 @@ void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned i bool h_box(false); TEveBoxSet *boxset = new TEveBoxSet(); - if(!heatmap) + if (!heatmap) boxset->UseSingleColor(); boxset->SetPickable(true); boxset->Reset(TEveBoxSet::kBT_FreeBox, true, 64); @@ -61,7 +112,7 @@ void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned i if (iData.algo() == 8 || (type >= 8 && type <= 10)) { - if(heatmap && hitmap.find(it->first) == hitmap.end()) + if (heatmap && hitmap.find(it->first) == hitmap.end()) continue; const bool z = (it->first >> 25) & 0x1; @@ -105,21 +156,24 @@ void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned i } // seed - if(iData.seed().rawId() == it->first.rawId()){ + if (iData.seed().rawId() == it->first.rawId()) + { TEveStraightLineSet *marker = new TEveStraightLineSet; - marker->SetLineWidth( 1 ); + marker->SetLineWidth(1); // center of RecHit float center[3] = { - corners[0], corners[1], corners[2]+shapes[3]*0.5f - }; + corners[0], corners[1], corners[2] + shapes[3] * 0.5f}; - if (isScintillator){ + if (isScintillator) + { constexpr int offset = 9; center[0] = (corners[6] + corners[6 + offset]) / 2; center[1] = (corners[7] + corners[7 + offset]) / 2; - } else { + } + else + { float min[2] = {1e3f, 1e3f}; float max[2] = {-1e3f, -1e3f}; @@ -139,17 +193,14 @@ void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned i // draw 3D cross const float crossScale = 1.0f + fmin(iData.energy(), 5.0f); marker->AddLine( - center[0]-crossScale, center[1], center[2], - center[0]+crossScale, center[1], center[2] - ); + center[0] - crossScale, center[1], center[2], + center[0] + crossScale, center[1], center[2]); marker->AddLine( - center[0], center[1]-crossScale, center[2], - center[0], center[1]+crossScale, center[2] - ); + center[0], center[1] - crossScale, center[2], + center[0], center[1] + crossScale, center[2]); marker->AddLine( - center[0], center[1], center[2]-crossScale, - center[0], center[1], center[2]+crossScale - ); + center[0], center[1], center[2] - crossScale, + center[0], center[1], center[2] + crossScale); oItemHolder.AddElement(marker); } @@ -171,8 +222,9 @@ void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned i pnts[(i * 3 + 2) + total_vertices] = corners[i * 3 + 2] + shapes[3]; } boxset->AddBox(&pnts[0]); - if(heatmap) { - const uint8_t colorFactor = gradient_steps*(fmin(hitmap[it->first]->energy()/saturation_energy, 1.0f)); + if (heatmap) + { + const uint8_t colorFactor = gradient_steps * (fmin(hitmap[it->first]->energy() / saturation_energy, 1.0f)); boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor]); } @@ -188,8 +240,9 @@ void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned i float radius = fabs(corners[6] - corners[6 + offset]) / 2; hex_boxset->AddHex(TEveVector(centerX, centerY, corners[2]), radius, 90.0, shapes[3]); - if(heatmap) { - const uint8_t colorFactor = gradient_steps*(fmin(hitmap[it->first]->energy()/saturation_energy, 1.0f)); + if (heatmap) + { + const uint8_t colorFactor = gradient_steps * (fmin(hitmap[it->first]->energy() / saturation_energy, 1.0f)); hex_boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor]); } From 14d7ad617504d56d24687052a6a817324d1b6831 Mon Sep 17 00:00:00 2001 From: Alex Mourtziapis Date: Tue, 12 Mar 2019 18:11:05 +0100 Subject: [PATCH 2/4] Implemented time window selection for HGCalLayerCluster --- .../interface/FWHeatmapProxyBuilderTemplate.h | 4 +- .../Calo/plugins/FWCaloClusterProxyBuilder.cc | 47 ++++++++++--------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/Fireworks/Calo/interface/FWHeatmapProxyBuilderTemplate.h b/Fireworks/Calo/interface/FWHeatmapProxyBuilderTemplate.h index 7544a5c48da5d..6a4861f7ac270 100644 --- a/Fireworks/Calo/interface/FWHeatmapProxyBuilderTemplate.h +++ b/Fireworks/Calo/interface/FWHeatmapProxyBuilderTemplate.h @@ -48,8 +48,8 @@ class FWHeatmapProxyBuilderTemplate : public FWSimpleProxyBuilder { protected: std::map hitmap; - static const uint8_t gradient_steps = 9; - const float gradient[3][gradient_steps] = { + static constexpr uint8_t gradient_steps = 9; + static constexpr uint8_t gradient[3][gradient_steps] = { {0.2082*255, 0.0592*255, 0.0780*255, 0.0232*255, 0.1802*255, 0.5301*255, 0.8186*255, 0.9956*255, 0.9764*255}, {0.1664*255, 0.3599*255, 0.5041*255, 0.6419*255, 0.7178*255, 0.7492*255, 0.7328*255, 0.7862*255, 0.9832*255}, {0.5293*255, 0.8684*255, 0.8385*255, 0.7914*255, 0.6425*255, 0.4662*255, 0.3499*255, 0.1968*255, 0.0539*255} diff --git a/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc b/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc index ff1deb682b7d1..3331d05c7a4e1 100644 --- a/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc +++ b/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc @@ -24,7 +24,7 @@ class FWCaloClusterProxyBuilder : public FWHeatmapProxyBuilderTemplate= 6 && iData.algo() <= 8); - - iItem->getConfig()->keepEntries(true); - iItem->getConfig()->assertParam("TimeLowerBound", 0.2, 0.01, 1.0); - iItem->getConfig()->assertParam("TimeUpperBound", 0.3, 0.01, 1.0); - iItem->getConfig()->assertParam("ShowClusterWithoutTimeInfo", false); - - iItem->getConfig()->assertParam("Layer", 0L, 0L, 52L); - iItem->getConfig()->assertParam("EnergyCutOff", 0.5, 0.2, 5.0); - iItem->getConfig()->assertParam("Heatmap", true); - iItem->getConfig()->assertParam("Z+", true); - iItem->getConfig()->assertParam("Z-", true); + iItem->getConfig()->assertParam("Cluster(0)/RecHit(1)", false); + iItem->getConfig()->assertParam("EnableTimeFilter", false); + iItem->getConfig()->assertParam("TimeLowerBound(ns)", 0.01, 0.0, 75.0); + iItem->getConfig()->assertParam("TimeUpperBound(ns)", 0.01, 0.0, 75.0); } } void FWCaloClusterProxyBuilder::build(const FWEventItem *iItem, TEveElementList *product, const FWViewContext *vc) { iItem->getEvent()->getByLabel(edm::InputTag("hgcalLayerClusters", "timeLayerCluster"), CaloToParticleBasedIsoMapHandle); - timeLowerBound = std::min(item()->getConfig()->value("TimeLowerBound"), item()->getConfig()->value("TimeUpperBound")); - timeUpperBound = std::max(item()->getConfig()->value("TimeLowerBound"), item()->getConfig()->value("TimeUpperBound")); + if(CaloToParticleBasedIsoMapHandle.isValid()){ + timeLowerBound = std::min(item()->getConfig()->value("TimeLowerBound(ns)"), item()->getConfig()->value("TimeUpperBound(ns)")); + timeUpperBound = std::max(item()->getConfig()->value("TimeLowerBound(ns)"), item()->getConfig()->value("TimeUpperBound(ns)")); + } + else { + std::cerr << "Warning: couldn't locate 'timeLayerCluster' ValueMap in root file." << std::endl; + } layer = item()->getConfig()->value("Layer"); saturation_energy = item()->getConfig()->value("EnergyCutOff"); heatmap = item()->getConfig()->value("Heatmap"); z_plus = item()->getConfig()->value("Z+"); z_minus = item()->getConfig()->value("Z-"); - p_showClusterWithoutTimeInfo = item()->getConfig()->value("ShowClusterWithoutTimeInfo"); + enableTimeFilter = item()->getConfig()->value("EnableTimeFilter"); FWHeatmapProxyBuilderTemplate::build(iItem, product, vc); } void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned int iIndex, TEveElement &oItemHolder, const FWViewContext *) { - if (!p_showClusterWithoutTimeInfo && CaloToParticleBasedIsoMapHandle.isValid()) + if (enableTimeFilter && CaloToParticleBasedIsoMapHandle.isValid()) { const float time = CaloToParticleBasedIsoMapHandle->get(iIndex); if (time < timeLowerBound || time > timeUpperBound) @@ -205,6 +201,9 @@ void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned i oItemHolder.AddElement(marker); } + const float energy = fmin((item()->getConfig()->value("Cluster(0)/RecHit(1)") ? hitmap[it->first]->energy() : iData.energy()) / saturation_energy, 1.0f); + const uint8_t colorFactor = gradient_steps*energy; + // Scintillator if (isScintillator) { @@ -224,8 +223,9 @@ void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned i boxset->AddBox(&pnts[0]); if (heatmap) { - const uint8_t colorFactor = gradient_steps * (fmin(hitmap[it->first]->energy() / saturation_energy, 1.0f)); - boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor]); + energy ? + boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor]) : + boxset->DigitColor(0.7f, 0.7f, 0.7f); } h_box = true; @@ -242,8 +242,9 @@ void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned i radius, 90.0, shapes[3]); if (heatmap) { - const uint8_t colorFactor = gradient_steps * (fmin(hitmap[it->first]->energy() / saturation_energy, 1.0f)); - hex_boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor]); + energy ? + hex_boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor]) : + hex_boxset->DigitColor(0.7f, 0.7f, 0.7f); } h_hex = true; From 48fac277d819b6b3c79a5f1e04beb8af31fb57e8 Mon Sep 17 00:00:00 2001 From: Alex Mourtziapis Date: Wed, 13 Mar 2019 11:06:04 +0100 Subject: [PATCH 3/4] Change Handle name --- Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc b/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc index 3331d05c7a4e1..ae3dca1f7f268 100644 --- a/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc +++ b/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc @@ -17,7 +17,7 @@ class FWCaloClusterProxyBuilder : public FWHeatmapProxyBuilderTemplate> CaloToParticleBasedIsoMapHandle; + edm::Handle> TimeValueMapHandle; double timeLowerBound, timeUpperBound; long layer; double saturation_energy; @@ -49,8 +49,8 @@ void FWCaloClusterProxyBuilder::setItem(const FWEventItem *iItem) void FWCaloClusterProxyBuilder::build(const FWEventItem *iItem, TEveElementList *product, const FWViewContext *vc) { - iItem->getEvent()->getByLabel(edm::InputTag("hgcalLayerClusters", "timeLayerCluster"), CaloToParticleBasedIsoMapHandle); - if(CaloToParticleBasedIsoMapHandle.isValid()){ + iItem->getEvent()->getByLabel(edm::InputTag("hgcalLayerClusters", "timeLayerCluster"), TimeValueMapHandle); + if(TimeValueMapHandle.isValid()){ timeLowerBound = std::min(item()->getConfig()->value("TimeLowerBound(ns)"), item()->getConfig()->value("TimeUpperBound(ns)")); timeUpperBound = std::max(item()->getConfig()->value("TimeLowerBound(ns)"), item()->getConfig()->value("TimeUpperBound(ns)")); } @@ -70,9 +70,9 @@ void FWCaloClusterProxyBuilder::build(const FWEventItem *iItem, TEveElementList void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned int iIndex, TEveElement &oItemHolder, const FWViewContext *) { - if (enableTimeFilter && CaloToParticleBasedIsoMapHandle.isValid()) + if (enableTimeFilter && TimeValueMapHandle.isValid()) { - const float time = CaloToParticleBasedIsoMapHandle->get(iIndex); + const float time = TimeValueMapHandle->get(iIndex); if (time < timeLowerBound || time > timeUpperBound) return; } From 2611f2367600e3ae9579d6f98f08dfd566e2f3f0 Mon Sep 17 00:00:00 2001 From: Alex Mourtziapis Date: Fri, 15 Mar 2019 10:42:56 +0100 Subject: [PATCH 4/4] Update FWCaloClusterProxyBuilder.cc --- Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc b/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc index ae3dca1f7f268..17ccb78e8671f 100644 --- a/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc +++ b/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc @@ -225,7 +225,7 @@ void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned i { energy ? boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor]) : - boxset->DigitColor(0.7f, 0.7f, 0.7f); + boxset->DigitColor(64, 64, 64); } h_box = true; @@ -244,7 +244,7 @@ void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned i { energy ? hex_boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor]) : - hex_boxset->DigitColor(0.7f, 0.7f, 0.7f); + hex_boxset->DigitColor(64, 64, 64); } h_hex = true;