CMS 3D CMS Logo

FWHGCalTriggerClusterProxyBuilder.cc
Go to the documentation of this file.
2 
6 
9 
13 
14 #include "TEveBoxSet.h"
15 #include "TColor.h"
16 #include "TROOT.h"
17 
18 class FWHGCalTriggerClusterProxyBuilder : public FWL1THGCalProxyTemplate<l1t::HGCalMulticluster> {
19 public:
22 
24 
27  delete; // stop default
28 
29 private:
30  void build(const l1t::HGCalMulticluster &iData,
31  unsigned int iIndex,
32  TEveElement &oItemHolder,
33  const FWViewContext *) override;
34 };
35 
37  unsigned int iIndex,
38  TEveElement &oItemHolder,
39  const FWViewContext *) {
40  const long layer = item()->getConfig()->value<long>("Layer");
41  const double saturation_energy = item()->getConfig()->value<double>("EnergyCutOff");
42  const bool heatmap = item()->getConfig()->value<bool>("Heatmap");
43 
44  const bool z_plus = item()->getConfig()->value<bool>("Z+");
45  const bool z_minus = item()->getConfig()->value<bool>("Z-");
46 
47  bool h_hex(false);
48  TEveBoxSet *hex_boxset = new TEveBoxSet();
49  if (!heatmap)
50  hex_boxset->UseSingleColor();
51  hex_boxset->SetPickable(true);
52  hex_boxset->Reset(TEveBoxSet::kBT_Hex, true, 64);
53  hex_boxset->SetAntiFlick(true);
54 
55  bool h_box(false);
56  TEveBoxSet *boxset = new TEveBoxSet();
57  if (!heatmap)
58  boxset->UseSingleColor();
59  boxset->SetPickable(true);
60  boxset->Reset(TEveBoxSet::kBT_FreeBox, true, 64);
61  boxset->SetAntiFlick(true);
62 
63  const float energy = fmin(iData.energy() / (saturation_energy * 100), 1.0);
64 
65  for (const auto &t_detid : iData.constituents()) {
66  std::unordered_set<unsigned> cells = getCellsFromTriggerCell(t_detid.first);
67 
68  for (auto &it : cells) {
69  const bool z = (it >> 25) & 0x1;
70 
71  // discard everything thats not at the side that we are intersted in
72  if (((z_plus & z_minus) != 1) && (((z_plus | z_minus) == 0) || !(z == z_minus || z == !z_plus)))
73  continue;
74 
75  const float *corners = item()->getGeom()->getCorners(it);
76  const float *parameters = item()->getGeom()->getParameters(it);
77  const float *shapes = item()->getGeom()->getShapePars(it);
78 
79  if (corners == nullptr || parameters == nullptr || shapes == nullptr) {
80  continue;
81  }
82 
83  const int total_points = parameters[0];
84  const bool isScintillator = (total_points == 4);
85  const uint8_t type = ((it >> 28) & 0xF);
86 
87  uint8_t ll = layer;
88  if (layer > 0) {
89  if (layer > 28) {
90  if (type == 8) {
91  continue;
92  }
93  ll -= 28;
94  } else {
95  if (type != 8) {
96  continue;
97  }
98  }
99 
100  if (ll != ((it >> (isScintillator ? 17 : 20)) & 0x1F))
101  continue;
102  }
103 
104  // Scintillator
105  if (isScintillator) {
106  const int total_vertices = 3 * total_points;
107 
108  std::vector<float> pnts(24);
109  for (int i = 0; i < total_points; ++i) {
110  pnts[i * 3 + 0] = corners[i * 3];
111  pnts[i * 3 + 1] = corners[i * 3 + 1];
112  pnts[i * 3 + 2] = corners[i * 3 + 2];
113 
114  pnts[(i * 3 + 0) + total_vertices] = corners[i * 3];
115  pnts[(i * 3 + 1) + total_vertices] = corners[i * 3 + 1];
116  pnts[(i * 3 + 2) + total_vertices] = corners[i * 3 + 2] + shapes[3];
117  }
118  boxset->AddBox(&pnts[0]);
119  boxset->DigitColor(energy * 255, 0, 255 - energy * 255);
120 
121  h_box = true;
122  }
123  // Silicon
124  else {
125  const int offset = 9;
126 
127  float centerX = (corners[6] + corners[6 + offset]) / 2;
128  float centerY = (corners[7] + corners[7 + offset]) / 2;
129  float radius = fabs(corners[6] - corners[6 + offset]) / 2;
130  hex_boxset->AddHex(TEveVector(centerX, centerY, corners[2]), radius, 90.0, shapes[3]);
131  hex_boxset->DigitColor(energy * 255, 0, 255 - energy * 255);
132 
133  h_hex = true;
134  }
135  }
136  }
137 
138  if (h_hex) {
139  hex_boxset->RefitPlex();
140 
141  hex_boxset->CSCTakeAnyParentAsMaster();
142  if (!heatmap) {
143  hex_boxset->CSCApplyMainColorToMatchingChildren();
144  hex_boxset->CSCApplyMainTransparencyToMatchingChildren();
145  hex_boxset->SetMainColor(item()->modelInfo(iIndex).displayProperties().color());
146  hex_boxset->SetMainTransparency(item()->defaultDisplayProperties().transparency());
147  }
148  oItemHolder.AddElement(hex_boxset);
149  }
150 
151  if (h_box) {
152  boxset->RefitPlex();
153 
154  boxset->CSCTakeAnyParentAsMaster();
155  if (!heatmap) {
156  boxset->CSCApplyMainColorToMatchingChildren();
157  boxset->CSCApplyMainTransparencyToMatchingChildren();
158  boxset->SetMainColor(item()->modelInfo(iIndex).displayProperties().color());
159  boxset->SetMainTransparency(item()->defaultDisplayProperties().transparency());
160  }
161  oItemHolder.AddElement(boxset);
162  }
163 }
164 
167  "HGCal Trigger Cluster",
const FWHGCalTriggerClusterProxyBuilder & operator=(const FWHGCalTriggerClusterProxyBuilder &)=delete
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:150
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
std::unordered_set< unsigned > getCellsFromTriggerCell(const unsigned trigger_cell_id) const
static const int kAll3DBits
Definition: FWViewType.h:68
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:461
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ cells
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
const float * getShapePars(unsigned int id) const
Definition: FWGeometry.cc:483
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:472
const FWEventItem * item() const
double energy() const final
energy