CMS 3D CMS Logo

FWHGCalMultiClusterProxyBuilder.cc
Go to the documentation of this file.
1 #include "TEveBoxSet.h"
7 
9 
10 class FWHGCalMultiClusterProxyBuilder : public FWHeatmapProxyBuilderTemplate<reco::HGCalMultiCluster>
11 {
12 public:
15 
17 
18 private:
19  FWHGCalMultiClusterProxyBuilder( const FWHGCalMultiClusterProxyBuilder& ) = delete; // stop default
20  const FWHGCalMultiClusterProxyBuilder& operator=( const FWHGCalMultiClusterProxyBuilder& ) = delete; // stop default
21 
22  void build( const reco::HGCalMultiCluster& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* ) override;
23 };
24 
25 void
26 FWHGCalMultiClusterProxyBuilder::build(const reco::HGCalMultiCluster &iData, unsigned int iIndex, TEveElement &oItemHolder, const FWViewContext *)
27 {
28  const long layer = item()->getConfig()->value<long>("Layer");
29  const double saturation_energy = item()->getConfig()->value<double>("EnergyCutOff");
30  const bool heatmap = item()->getConfig()->value<bool>("Heatmap");
31  const bool z_plus = item()->getConfig()->value<bool>("Z+");
32  const bool z_minus = item()->getConfig()->value<bool>("Z-");
33 
34  const auto &clusters = iData.clusters();
35 
36  bool h_hex(false);
37  TEveBoxSet *hex_boxset = new TEveBoxSet("Silicon");
38  if(!heatmap)
39  hex_boxset->UseSingleColor();
40  hex_boxset->SetPickable(true);
41  hex_boxset->Reset(TEveBoxSet::kBT_Hex, true, 64);
42  hex_boxset->SetAntiFlick(kTRUE);
43 
44  bool h_box(false);
45  TEveBoxSet *boxset = new TEveBoxSet("Scintillator");
46  if(!heatmap)
47  boxset->UseSingleColor();
48  boxset->SetPickable(true);
49  boxset->Reset(TEveBoxSet::kBT_FreeBox, true, 64);
50  boxset->SetAntiFlick(kTRUE);
51 
52  for (const auto &c : clusters)
53  {
54  std::vector<std::pair<DetId, float>> clusterDetIds = c->hitsAndFractions();
55 
56  for (std::vector<std::pair<DetId, float>>::iterator it = clusterDetIds.begin(), itEnd = clusterDetIds.end();
57  it != itEnd; ++it)
58  {
59  if(heatmap && hitmap.find(it->first) == hitmap.end())
60  continue;
61 
62  const bool z = (it->first >> 25) & 0x1;
63 
64  // discard everything thats not at the side that we are intersted in
65  if (
66  ((z_plus & z_minus) != 1) &&
67  (((z_plus | z_minus) == 0) || !(z == z_minus || z == !z_plus)))
68  continue;
69 
70  const float *corners = item()->getGeom()->getCorners(it->first);
71  const float *parameters = item()->getGeom()->getParameters(it->first);
72  const float *shapes = item()->getGeom()->getShapePars(it->first);
73 
74  if (corners == nullptr || parameters == nullptr || shapes == nullptr)
75  {
76  continue;
77  }
78 
79  const int total_points = parameters[0];
80  const bool isScintillator = (total_points == 4);
81  const uint8_t type = ((it->first >> 28) & 0xF);
82 
83  uint8_t ll = layer;
84  if (layer > 0)
85  {
86  if (layer > 28)
87  {
88  if (type == 8)
89  {
90  continue;
91  }
92  ll -= 28;
93  }
94  else
95  {
96  if (type != 8)
97  {
98  continue;
99  }
100  }
101 
102  if (ll != ((it->first >> (isScintillator ? 17 : 20)) & 0x1F))
103  continue;
104  }
105 
106  // Scintillator
107  if (isScintillator)
108  {
109  const int total_vertices = 3 * total_points;
110 
111  std::vector<float> pnts(24);
112  for (int i = 0; i < total_points; ++i)
113  {
114  pnts[i * 3 + 0] = corners[i * 3];
115  pnts[i * 3 + 1] = corners[i * 3 + 1];
116  pnts[i * 3 + 2] = corners[i * 3 + 2];
117 
118  pnts[(i * 3 + 0) + total_vertices] = corners[i * 3];
119  pnts[(i * 3 + 1) + total_vertices] = corners[i * 3 + 1];
120  pnts[(i * 3 + 2) + total_vertices] = corners[i * 3 + 2] + shapes[3];
121  }
122  boxset->AddBox(&pnts[0]);
123  if(heatmap) {
124  const uint8_t colorFactor = gradient_steps*(fmin(hitmap[it->first]->energy()/saturation_energy, 1.0f));
125  boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor]);
126  }
127 
128  h_box = true;
129  }
130  // Silicon
131  else
132  {
133  const int offset = 9;
134 
135  float centerX = (corners[6] + corners[6 + offset]) / 2;
136  float centerY = (corners[7] + corners[7 + offset]) / 2;
137  float radius = fabs(corners[6] - corners[6 + offset]) / 2;
138  hex_boxset->AddHex(TEveVector(centerX, centerY, corners[2]),
139  radius, 90.0, shapes[3]);
140  if(heatmap) {
141  const uint8_t colorFactor = gradient_steps*(fmin(hitmap[it->first]->energy()/saturation_energy, 1.0f));
142  hex_boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor]);
143  }
144 
145  h_hex = true;
146  }
147  }
148  }
149 
150  if (h_hex)
151  {
152  hex_boxset->RefitPlex();
153 
154  hex_boxset->CSCTakeAnyParentAsMaster();
155  if (!heatmap)
156  {
157  hex_boxset->CSCApplyMainColorToMatchingChildren();
158  hex_boxset->CSCApplyMainTransparencyToMatchingChildren();
159  hex_boxset->SetMainColor(item()->modelInfo(iIndex).displayProperties().color());
160  hex_boxset->SetMainTransparency(item()->defaultDisplayProperties().transparency());
161  }
162  oItemHolder.AddElement(hex_boxset);
163  }
164 
165  if (h_box)
166  {
167  boxset->RefitPlex();
168 
169  boxset->CSCTakeAnyParentAsMaster();
170  if (!heatmap)
171  {
172  boxset->CSCApplyMainColorToMatchingChildren();
173  boxset->CSCApplyMainTransparencyToMatchingChildren();
174  boxset->SetMainColor(item()->modelInfo(iIndex).displayProperties().color());
175  boxset->SetMainTransparency(item()->defaultDisplayProperties().transparency());
176  }
177  oItemHolder.AddElement(boxset);
178  }
179 }
180 
type
Definition: HCALResponse.h:21
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:169
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:446
const FWEventItem * item() const
const float * getShapePars(unsigned int id) const
Definition: FWGeometry.cc:462
const edm::PtrVector< reco::BasicCluster > & clusters() const
const FWHGCalMultiClusterProxyBuilder & operator=(const FWHGCalMultiClusterProxyBuilder &)=delete
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:430
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:686