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 
25 private:
28  delete; // stop default
29 
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",
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:29
mps_fire.i
i
Definition: mps_fire.py:428
FWL1THGCalProxyTemplate
Definition: FWL1THGCalProxyTemplate.cc:12
FWGeometry::getCorners
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:467
HGCScintillatorDetId.h
FWHGCalTriggerClusterProxyBuilder::~FWHGCalTriggerClusterProxyBuilder
~FWHGCalTriggerClusterProxyBuilder(void) override
Definition: FWHGCalTriggerClusterProxyBuilder.cc:21
FWEventItem::getConfig
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:150
FWL1THGCalProxyTemplate.cc
REGISTER_FWPROXYBUILDER
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
Definition: FWProxyBuilderFactory.h:33
REGISTER_PROXYBUILDER_METHODS
#define REGISTER_PROXYBUILDER_METHODS()
Definition: register_dataproxybuilder_macro.h:28
FWL1THGCalProxyTemplate< l1t::HGCalMulticluster >::getCellsFromTriggerCell
std::unordered_set< unsigned > getCellsFromTriggerCell(const unsigned trigger_cell_id) const
Definition: FWL1THGCalProxyTemplate.cc:26
FWGeometry::getShapePars
const float * getShapePars(unsigned int id) const
Definition: FWGeometry.cc:489
BuilderUtils.h
FWViewType::kAll3DBits
static const int kAll3DBits
Definition: FWViewType.h:68
HGCalClusterT.h
FWGeometry::getParameters
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:478
l1t::HGCalMulticluster
Definition: HGCalMulticluster.h:13
FWProxyBuilderBase::layer
int layer() const
Definition: FWProxyBuilderBase.cc:414
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
HGCalMulticluster.h
FWHGCalTriggerClusterProxyBuilder::operator=
const FWHGCalTriggerClusterProxyBuilder & operator=(const FWHGCalTriggerClusterProxyBuilder &)=delete
DDAxes::z
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
l1t::HGCalClusterT::constituents
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:50
FWGeometry.h
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
HcalDetId.h
FWHGCalTriggerClusterProxyBuilder
Definition: FWHGCalTriggerClusterProxyBuilder.cc:18
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
FWProxyBuilderConfiguration::value
T value(const std::string &name)
Definition: FWProxyBuilderConfiguration.cc:123
postprocess-scan-build.cells
cells
Definition: postprocess-scan-build.py:13
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
reco::LeafCandidate::energy
double energy() const final
energy
Definition: LeafCandidate.h:125
FWHGCalTriggerClusterProxyBuilder::FWHGCalTriggerClusterProxyBuilder
FWHGCalTriggerClusterProxyBuilder(void)
Definition: FWHGCalTriggerClusterProxyBuilder.cc:20
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
HGCalTriggerDetId.h