CMS 3D CMS Logo

FWTracksterLayersProxyBuilder.cc
Go to the documentation of this file.
12 
13 #include "TEveBoxSet.h"
14 #include "TGeoSphere.h"
15 #include "TGeoTube.h"
16 #include "TEveGeoShape.h"
17 #include "TEveStraightLineSet.h"
18 
19 #include <cmath>
20 
22 public:
25 
27 
28 private:
32  long layer;
33  bool z_plus;
34  bool z_minus;
38  double displayMode;
40 
41  FWTracksterLayersProxyBuilder(const FWTracksterLayersProxyBuilder &) = delete; // stop default
42  const FWTracksterLayersProxyBuilder &operator=(const FWTracksterLayersProxyBuilder &) = delete; // stop default
43 
44  void setItem(const FWEventItem *iItem) override;
45 
46  void build(const FWEventItem *iItem, TEveElementList *product, const FWViewContext *vc) override;
47  void build(const ticl::Trackster &iData,
48  unsigned int iIndex,
49  TEveElement &oItemHolder,
50  const FWViewContext *) override;
51 };
52 
55  if (iItem) {
56  iItem->getConfig()->assertParam("EnablePositionLines", false);
57  iItem->getConfig()->assertParam("EnableEdges", false);
58  iItem->getConfig()->assertParam("EnableTimeFilter", false);
59  iItem->getConfig()->assertParam("TimeLowerBound(ns)", 0.01, 0.0, 75.0);
60  iItem->getConfig()->assertParam("TimeUpperBound(ns)", 0.01, 0.0, 75.0);
61  iItem->getConfig()->assertParam("DisplayMode", 0.0, 0.0, 5.0);
62  iItem->getConfig()->assertParam("ProportionalityFactor", 1.0, 0.0, 1.0);
63  }
64 }
65 
66 void FWTracksterLayersProxyBuilder::build(const FWEventItem *iItem, TEveElementList *product, const FWViewContext *vc) {
67  iItem->getEvent()->getByLabel(edm::InputTag("hgcalLayerClusters", "timeLayerCluster"), TimeValueMapHandle);
68  iItem->getEvent()->getByLabel(edm::InputTag("hgcalLayerClusters"), layerClustersHandle);
70  timeLowerBound = item()->getConfig()->value<double>("TimeLowerBound(ns)");
71  timeUpperBound = item()->getConfig()->value<double>("TimeUpperBound(ns)");
73  edm::LogWarning("InvalidParameters")
74  << "lower time bound is larger than upper time bound. Maybe opposite is desired?";
75  }
76  } else {
77  edm::LogWarning("DataNotFound|InvalidData") << "couldn't locate 'timeLayerCluster' ValueMap in root file.";
78  }
79 
81  edm::LogWarning("DataNotFound|InvalidData") << "couldn't locate 'timeLayerCluster' ValueMap in root file.";
82  }
83 
84  layer = item()->getConfig()->value<long>("Layer");
85  z_plus = item()->getConfig()->value<bool>("Z+");
86  z_minus = item()->getConfig()->value<bool>("Z-");
87  enableTimeFilter = item()->getConfig()->value<bool>("EnableTimeFilter");
88  enablePositionLines = item()->getConfig()->value<bool>("EnablePositionLines");
89  enableEdges = item()->getConfig()->value<bool>("EnableEdges");
90  displayMode = item()->getConfig()->value<double>("DisplayMode");
91  proportionalityFactor = item()->getConfig()->value<double>("ProportionalityFactor");
92 
93  FWHeatmapProxyBuilderTemplate::build(iItem, product, vc);
94 }
95 
97  unsigned int iIndex,
98  TEveElement &oItemHolder,
99  const FWViewContext *) {
101  const float time = TimeValueMapHandle->get(iIndex).first;
102  if (time < timeLowerBound || time > timeUpperBound)
103  return;
104  }
105 
106  const ticl::Trackster &trackster = iData;
107  const size_t N = trackster.vertices().size();
108  const std::vector<reco::CaloCluster> &layerClusters = *layerClustersHandle;
109 
110  for (size_t i = 0; i < N; ++i) {
111  const reco::CaloCluster layerCluster = layerClusters[trackster.vertices(i)];
112  const math::XYZPoint &position = layerCluster.position();
113  const size_t nHits = layerCluster.size();
114  const double energy = layerCluster.correctedEnergy();
115  float radius = 0;
116 
117  // discard everything thats not at the side that we are intersted in
118  const bool z = (layerCluster.seed() >> 25) & 0x1;
119  if (((z_plus & z_minus) != 1) && (((z_plus | z_minus) == 0) || !(z == z_minus || z == !z_plus)))
120  continue;
121 
122  if (displayMode == 0) {
123  radius = sqrt(nHits);
124  } else if (displayMode == 1) {
125  radius = nHits;
126  } else if (displayMode == 2) {
127  radius = energy;
128  } else if (displayMode == 3) {
129  radius = energy / nHits;
130  } else if (displayMode == 4) {
131  const bool isScintillator = layerCluster.seed().det() == DetId::HGCalHSc;
132  float area = 0;
133  if (isScintillator) {
134  const bool isFine = (HGCScintillatorDetId(layerCluster.seed()).type() == 0);
135  float dphi = (isFine) ? 1.0 * M_PI / 180. : 1.25 * M_PI / 180.;
136  int ir = HGCScintillatorDetId(layerCluster.seed()).iradiusAbs();
137  float dr = (isFine) ? (0.0484 * static_cast<float>(ir) + 2.1) : (0.075 * static_cast<float>(ir) + 2.0);
138  float r = (isFine) ? (0.0239 * static_cast<float>(pow(ir, 2)) + 2.02 * static_cast<float>(ir) + 119.6)
139  : (0.0367 * static_cast<float>(pow(ir, 2)) + 1.7 * static_cast<float>(ir) + 90.7);
140  area = r * dr * dphi;
141  } else {
142  const bool isFine = (HGCSiliconDetId(layerCluster.seed()).type() == 0);
143  float side = (isFine) ? 0.465 : 0.698;
144  area = pow(side, 2) * 3 * sqrt(3) / 2;
145  }
146  radius = sqrt(nHits * area) / M_PI;
147  }
148 
149  auto eveCircle = new TEveGeoShape("Circle");
150  auto tube = new TGeoTube(0., proportionalityFactor * radius, 0.1);
151  eveCircle->SetShape(tube);
152  eveCircle->InitMainTrans();
153  eveCircle->RefMainTrans().Move3PF(position.x(), position.y(), position.z());
154  setupAddElement(eveCircle, &oItemHolder);
155 
156  // seed and cluster position
157  const float crossScale = 1.0f + fmin(energy, 5.0f);
158  if (enablePositionLines) {
159  TEveStraightLineSet *position_marker = new TEveStraightLineSet;
160  position_marker->SetLineWidth(2);
161  position_marker->SetLineColor(kOrange);
162  auto const &pos = layerCluster.position();
163  const float position_crossScale = crossScale * 0.5;
164  position_marker->AddLine(
165  pos.x() - position_crossScale, pos.y(), pos.z(), pos.x() + position_crossScale, pos.y(), pos.z());
166  position_marker->AddLine(
167  pos.x(), pos.y() - position_crossScale, pos.z(), pos.x(), pos.y() + position_crossScale, pos.z());
168 
169  oItemHolder.AddElement(position_marker);
170  }
171  }
172 
173  if (enableEdges) {
174  auto &edges = trackster.edges();
175 
176  for (auto edge : edges) {
177  auto doublet = std::make_pair(layerClusters[edge[0]], layerClusters[edge[1]]);
178 
179  const bool isScintillatorIn = doublet.first.seed().det() == DetId::HGCalHSc;
180  const bool isScintillatorOut = doublet.second.seed().det() == DetId::HGCalHSc;
181  int layerIn = (isScintillatorIn) ? (HGCScintillatorDetId(doublet.first.seed()).layer())
182  : (HGCSiliconDetId(doublet.first.seed()).layer());
183  int layerOut = (isScintillatorOut) ? (HGCScintillatorDetId(doublet.second.seed()).layer())
184  : (HGCSiliconDetId(doublet.second.seed()).layer());
185 
186  // Check if offset is needed
187  const int offset = 28;
188  const int offsetIn = offset * (doublet.first.seed().det() != DetId::HGCalEE);
189  const int offsetOut = offset * (doublet.second.seed().det() != DetId::HGCalEE);
190  layerIn += offsetIn;
191  layerOut += offsetOut;
192 
193  const bool isAdjacent = (layerOut - layerIn) == 1;
194 
195  TEveStraightLineSet *marker = new TEveStraightLineSet;
196  marker->SetLineWidth(2);
197  if (isAdjacent) {
198  marker->SetLineColor(kYellow);
199  } else {
200  marker->SetLineColor(kRed);
201  }
202 
203  // draw 3D cross
204  if (layer == 0 || fabs(layerIn - layer) == 0 || fabs(layerOut - layer) == 0) {
205  marker->AddLine(doublet.first.x(),
206  doublet.first.y(),
207  doublet.first.z(),
208  doublet.second.x(),
209  doublet.second.y(),
210  doublet.second.z());
211  }
212 
213  oItemHolder.AddElement(marker);
214  }
215  }
216 }
217 
FWTracksterLayersProxyBuilder
Definition: FWTracksterLayersProxyBuilder.cc:21
reco::CaloCluster::size
size_t size() const
size in number of hits (e.g. in crystals for ECAL)
Definition: CaloCluster.h:187
mps_fire.i
i
Definition: mps_fire.py:428
FWHeatmapProxyBuilderTemplate::setItem
void setItem(const FWEventItem *iItem) override
Definition: FWHeatmapProxyBuilderTemplate.h:82
FWTracksterLayersProxyBuilder::layer
long layer
Definition: FWTracksterLayersProxyBuilder.cc:32
MessageLogger.h
Trackster.h
HGCScintillatorDetId.h
edm::EventBase::getByLabel
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:92
FWEventItem::getConfig
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:150
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
REGISTER_FWPROXYBUILDER
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
Definition: FWProxyBuilderFactory.h:33
FWTracksterLayersProxyBuilder::FWTracksterLayersProxyBuilder
FWTracksterLayersProxyBuilder(void)
Definition: FWTracksterLayersProxyBuilder.cc:23
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
FWTracksterLayersProxyBuilder::setItem
void setItem(const FWEventItem *iItem) override
Definition: FWTracksterLayersProxyBuilder.cc:53
pos
Definition: PixelAliasList.h:18
FWTracksterLayersProxyBuilder::enableTimeFilter
bool enableTimeFilter
Definition: FWTracksterLayersProxyBuilder.cc:35
HGCSiliconDetId.h
FWTracksterLayersProxyBuilder::enablePositionLines
bool enablePositionLines
Definition: FWTracksterLayersProxyBuilder.cc:36
REGISTER_PROXYBUILDER_METHODS
#define REGISTER_PROXYBUILDER_METHODS()
Definition: register_dataproxybuilder_macro.h:28
protons_cff.time
time
Definition: protons_cff.py:39
FWTracksterLayersProxyBuilder::timeUpperBound
double timeUpperBound
Definition: FWTracksterLayersProxyBuilder.cc:31
BuilderUtils.h
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
HGCSiliconDetId
Definition: HGCSiliconDetId.h:22
FWTracksterLayersProxyBuilder::layerClustersHandle
edm::Handle< std::vector< reco::CaloCluster > > layerClustersHandle
Definition: FWTracksterLayersProxyBuilder.cc:30
DetId::HGCalEE
Definition: DetId.h:32
FWProxyBuilderBase::layer
int layer() const
Definition: FWProxyBuilderBase.cc:414
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
nHits
const caConstants::TupleMultiplicity *__restrict__ const HitsOnGPU *__restrict__ double *__restrict__ float *__restrict__ double *__restrict__ uint32_t nHits
Definition: BrokenLineFitOnGPU.h:27
reco::CaloCluster
Definition: CaloCluster.h:31
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DDAxes::z
N
#define N
Definition: blowfish.cc:9
ticl::Trackster::edges
std::vector< std::array< unsigned int, 2 > > & edges()
Definition: Trackster.h:58
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
HLTEgPhaseIITestSequence_cff.layerClusters
layerClusters
Definition: HLTEgPhaseIITestSequence_cff.py:2506
FWProxyBuilderConfiguration::assertParam
FWGenericParameter< T > * assertParam(const std::string &name, T def)
Definition: FWProxyBuilderConfiguration.cc:83
FWEventItem::getEvent
const edm::EventBase * getEvent() const
Definition: FWEventItem.h:131
FWGeometry.h
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
FWTracksterLayersProxyBuilder::TimeValueMapHandle
edm::Handle< edm::ValueMap< std::pair< float, float > > > TimeValueMapHandle
Definition: FWTracksterLayersProxyBuilder.cc:29
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
FWTracksterLayersProxyBuilder::z_minus
bool z_minus
Definition: FWTracksterLayersProxyBuilder.cc:34
FWTracksterLayersProxyBuilder::~FWTracksterLayersProxyBuilder
~FWTracksterLayersProxyBuilder(void) override
Definition: FWTracksterLayersProxyBuilder.cc:24
FWTracksterLayersProxyBuilder::operator=
const FWTracksterLayersProxyBuilder & operator=(const FWTracksterLayersProxyBuilder &)=delete
FWProxyBuilderBase::setupAddElement
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Definition: FWProxyBuilderBase.cc:350
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
FWProxyBuilderBase::build
void build()
Definition: FWProxyBuilderBase.cc:110
SelectiveReadoutTask_cfi.edges
edges
Definition: SelectiveReadoutTask_cfi.py:107
reco::CaloCluster::seed
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:219
FWEventItem.h
FWViewContext
Definition: FWViewContext.h:32
FWTracksterLayersProxyBuilder::enableEdges
bool enableEdges
Definition: FWTracksterLayersProxyBuilder.cc:37
reco::CaloCluster::position
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:154
alignCSCRings.r
r
Definition: alignCSCRings.py:93
ValueMap.h
FWProxyBuilderBase::item
const FWEventItem * item() const
Definition: FWProxyBuilderBase.h:64
edm::ValueMap::get
const_reference_type get(ProductID id, size_t idx) const
Definition: ValueMap.h:144
FWHeatmapProxyBuilderTemplate
Definition: FWHeatmapProxyBuilderTemplate.h:34
FWTracksterLayersProxyBuilder::proportionalityFactor
double proportionalityFactor
Definition: FWTracksterLayersProxyBuilder.cc:39
FWEventItem
Definition: FWEventItem.h:56
FWViewType::kISpyBit
Definition: FWViewType.h:54
FWProxyBuilderConfiguration::value
T value(const std::string &name)
Definition: FWProxyBuilderConfiguration.cc:123
DetId.h
HGCScintillatorDetId
Definition: HGCScintillatorDetId.h:23
DetId::HGCalHSc
Definition: DetId.h:34
ticl::Trackster::vertices
std::vector< unsigned int > & vertices()
Definition: Trackster.h:56
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
reco::CaloCluster::correctedEnergy
double correctedEnergy() const
Definition: CaloCluster.h:150
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
FWTracksterLayersProxyBuilder::z_plus
bool z_plus
Definition: FWTracksterLayersProxyBuilder.cc:33
FWHeatmapProxyBuilderTemplate.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
FWTracksterLayersProxyBuilder::timeLowerBound
double timeLowerBound
Definition: FWTracksterLayersProxyBuilder.cc:31
custom_jme_cff.area
area
Definition: custom_jme_cff.py:140
edm::InputTag
Definition: InputTag.h:15
FWTracksterLayersProxyBuilder::displayMode
double displayMode
Definition: FWTracksterLayersProxyBuilder.cc:38
ticl::Trackster
Definition: Trackster.h:19
CaloCluster.h