CMS 3D CMS Logo

FWHGCRecHitProxyBuilder.cc
Go to the documentation of this file.
6 
7 #include "TEveBoxSet.h"
8 
10 public:
12  ~FWHGCRecHitProxyBuilder(void) override {}
13 
15 
16 private:
19 
20  static constexpr uint8_t gradient_steps = 9;
21  static constexpr float gradient[3][gradient_steps] = {{0.2082 * 255,
22  0.0592 * 255,
23  0.0780 * 255,
24  0.0232 * 255,
25  0.1802 * 255,
26  0.5301 * 255,
27  0.8186 * 255,
28  0.9956 * 255,
29  0.9764 * 255},
30  {0.1664 * 255,
31  0.3599 * 255,
32  0.5041 * 255,
33  0.6419 * 255,
34  0.7178 * 255,
35  0.7492 * 255,
36  0.7328 * 255,
37  0.7862 * 255,
38  0.9832 * 255},
39  {0.5293 * 255,
40  0.8684 * 255,
41  0.8385 * 255,
42  0.7914 * 255,
43  0.6425 * 255,
44  0.4662 * 255,
45  0.3499 * 255,
46  0.1968 * 255,
47  0.0539 * 255}};
48 
49  void setItem(const FWEventItem *iItem) override;
50  void build(const HGCRecHit &iData, unsigned int iIndex, TEveElement &oItemHolder, const FWViewContext *) override;
51 };
52 
55  if (iItem) {
56  iItem->getConfig()->keepEntries(true);
57  iItem->getConfig()->assertParam("Layer", 0L, 0L, 52L);
58  iItem->getConfig()->assertParam("EnergyCutOff", 0.5, 0.2, 5.0);
59  iItem->getConfig()->assertParam("Heatmap", true);
60  iItem->getConfig()->assertParam("Z+", true);
61  iItem->getConfig()->assertParam("Z-", true);
62  }
63 }
64 
66  unsigned int iIndex,
67  TEveElement &oItemHolder,
68  const FWViewContext *) {
69  const long layer = item()->getConfig()->value<long>("Layer");
70  const double saturation_energy = item()->getConfig()->value<double>("EnergyCutOff");
71  const bool heatmap = item()->getConfig()->value<bool>("Heatmap");
72  const bool z_plus = item()->getConfig()->value<bool>("Z+");
73  const bool z_minus = item()->getConfig()->value<bool>("Z-");
74 
75  TEveBoxSet *boxset = new TEveBoxSet();
76  if (!heatmap)
77  boxset->UseSingleColor();
78  boxset->SetPickable(true);
79  boxset->SetAntiFlick(true);
80 
81  unsigned int ID = iData.id();
82 
83  const bool z = (ID >> 25) & 0x1;
84 
85  // discard everything thats not at the side that we are intersted in
86  if (((z_plus & z_minus) != 1) && (((z_plus | z_minus) == 0) || !(z == z_minus || z == !z_plus)))
87  return;
88 
89  const float *corners = item()->getGeom()->getCorners(ID);
90  const float *parameters = item()->getGeom()->getParameters(ID);
91  const float *shapes = item()->getGeom()->getShapePars(ID);
92 
93  if (corners == nullptr || parameters == nullptr || shapes == nullptr)
94  return;
95 
96  const int total_points = parameters[0];
97  const bool isScintillator = (total_points == 4);
98  const uint8_t type = ((ID >> 28) & 0xF);
99 
100  uint8_t ll = layer;
101  if (layer > 0) {
102  if (layer > 28) {
103  if (type == 8) {
104  return;
105  }
106  ll -= 28;
107  } else {
108  if (type != 8) {
109  return;
110  }
111  }
112 
113  if (ll != ((ID >> (isScintillator ? 17 : 20)) & 0x1F))
114  return;
115  }
116 
117  boxset->Reset(isScintillator ? TEveBoxSet::kBT_FreeBox : TEveBoxSet::kBT_Hex, true, 64);
118 
119  // Scintillator
120  if (isScintillator) {
121  const int total_vertices = 3 * total_points;
122 
123  std::vector<float> pnts(24);
124  for (int i = 0; i < total_points; ++i) {
125  pnts[i * 3 + 0] = corners[i * 3];
126  pnts[i * 3 + 1] = corners[i * 3 + 1];
127  pnts[i * 3 + 2] = corners[i * 3 + 2];
128 
129  pnts[(i * 3 + 0) + total_vertices] = corners[i * 3];
130  pnts[(i * 3 + 1) + total_vertices] = corners[i * 3 + 1];
131  pnts[(i * 3 + 2) + total_vertices] = corners[i * 3 + 2] + shapes[3];
132  }
133  boxset->AddBox(&pnts[0]);
134  }
135  // Silicon
136  else {
137  const int offset = 9;
138 
139  float centerX = (corners[6] + corners[6 + offset]) / 2;
140  float centerY = (corners[7] + corners[7 + offset]) / 2;
141  float radius = fabs(corners[6] - corners[6 + offset]) / 2;
142  boxset->AddHex(TEveVector(centerX, centerY, corners[2]), radius, 90.0, shapes[3]);
143  }
144 
145  if (heatmap) {
146  const uint8_t colorFactor = gradient_steps * (fmin(iData.energy() / saturation_energy, 1.0f));
147  boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor]);
148  }
149 
150  boxset->RefitPlex();
151 
152  boxset->CSCTakeAnyParentAsMaster();
153  if (!heatmap) {
154  boxset->CSCApplyMainColorToMatchingChildren();
155  boxset->CSCApplyMainTransparencyToMatchingChildren();
156  boxset->SetMainColor(item()->defaultDisplayProperties().color());
157  boxset->SetMainTransparency(item()->defaultDisplayProperties().transparency());
158  }
159  oItemHolder.AddElement(boxset);
160 }
161 
dttmaxenums::L
Definition: DTTMax.h:29
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:30
mps_fire.i
i
Definition: mps_fire.py:428
FWHGCRecHitProxyBuilder::gradient
static constexpr float gradient[3][gradient_steps]
Definition: FWHGCRecHitProxyBuilder.cc:21
FWSimpleProxyBuilderTemplate.h
CaloRecHit::energy
constexpr float energy() const
Definition: CaloRecHit.h:29
FWGeometry::getCorners
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:467
FWEventItem::getConfig
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:150
REGISTER_FWPROXYBUILDER
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
Definition: FWProxyBuilderFactory.h:33
FWHGCRecHitProxyBuilder
Definition: FWHGCRecHitProxyBuilder.cc:9
REGISTER_PROXYBUILDER_METHODS
#define REGISTER_PROXYBUILDER_METHODS()
Definition: register_dataproxybuilder_macro.h:27
FWGeometry::getShapePars
const float * getShapePars(unsigned int id) const
Definition: FWGeometry.cc:489
FWHGCRecHitProxyBuilder::FWHGCRecHitProxyBuilder
FWHGCRecHitProxyBuilder()
Definition: FWHGCRecHitProxyBuilder.cc:11
HGCRecHit::id
DetId id() const
get the id
Definition: HGCRecHit.h:79
FWGeometry::getParameters
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:478
FWProxyBuilderBase::layer
int layer() const
Definition: FWProxyBuilderBase.cc:414
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
DDAxes::z
FWProxyBuilderConfiguration::keepEntries
void keepEntries(bool b)
Definition: FWProxyBuilderConfiguration.cc:78
FWHGCRecHitProxyBuilder::operator=
const FWHGCRecHitProxyBuilder & operator=(const FWHGCRecHitProxyBuilder &)=delete
HGCRecHit
Definition: HGCRecHit.h:14
FWProxyBuilderConfiguration::assertParam
FWGenericParameter< T > * assertParam(const std::string &name, T def)
Definition: FWProxyBuilderConfiguration.cc:83
FWGeometry.h
HGCRecHitCollections.h
align::ID
uint32_t ID
Definition: Definitions.h:24
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
FWProxyBuilderConfiguration.h
FWHGCRecHitProxyBuilder::~FWHGCRecHitProxyBuilder
~FWHGCRecHitProxyBuilder(void) override
Definition: FWHGCRecHitProxyBuilder.cc:12
FWProxyBuilderBase::build
void build()
Definition: FWProxyBuilderBase.cc:110
FWEventItem.h
FWViewContext
Definition: FWViewContext.h:32
FWEventItem::getGeom
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
FWProxyBuilderBase::item
const FWEventItem * item() const
Definition: FWProxyBuilderBase.h:64
FWEventItem
Definition: FWEventItem.h:56
FWViewType::kISpyBit
Definition: FWViewType.h:54
FWProxyBuilderConfiguration::value
T value(const std::string &name)
Definition: FWProxyBuilderConfiguration.cc:123
FWHGCRecHitProxyBuilder::gradient_steps
static constexpr uint8_t gradient_steps
Definition: FWHGCRecHitProxyBuilder.cc:20
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
FWHGCRecHitProxyBuilder::setItem
void setItem(const FWEventItem *iItem) override
Definition: FWHGCRecHitProxyBuilder.cc:53
FWSimpleProxyBuilderTemplate
Definition: FWSimpleProxyBuilderTemplate.h:30
FWProxyBuilderBase::setItem
virtual void setItem(const FWEventItem *iItem)
Definition: FWProxyBuilderBase.cc:83
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82