CMS 3D CMS Logo

FWCaloParticleProxyBuilder.cc
Go to the documentation of this file.
1 /*
2  * FWCaloParticleProxyBuilder.cc
3  * FWorks
4  *
5  * Created by Marco Rovere 13/09/2018
6  *
7  */
8 
15 
16 #include "TEveBoxSet.h"
17 
19 public:
21  ~FWCaloParticleProxyBuilder(void) override {}
22 
24 
25 private:
26  // Disable default copy constructor
28  // Disable default assignment operator
30 
31  void build(const CaloParticle &iData, unsigned int iIndex, TEveElement &oItemHolder, const FWViewContext *) override;
32 };
33 
35  unsigned int iIndex,
36  TEveElement &oItemHolder,
37  const FWViewContext *) {
38  const long layer = item()->getConfig()->value<long>("Layer");
39  const double saturation_energy = item()->getConfig()->value<double>("EnergyCutOff");
40  const bool heatmap = item()->getConfig()->value<bool>("Heatmap");
41  const bool z_plus = item()->getConfig()->value<bool>("Z+");
42  const bool z_minus = item()->getConfig()->value<bool>("Z-");
43 
44  bool h_hex(false);
45  TEveBoxSet *hex_boxset = new TEveBoxSet();
46  if (!heatmap)
47  hex_boxset->UseSingleColor();
48  hex_boxset->SetPickable(true);
49  hex_boxset->Reset(TEveBoxSet::kBT_Hex, true, 64);
50  hex_boxset->SetAntiFlick(true);
51 
52  bool h_box(false);
53  TEveBoxSet *boxset = new TEveBoxSet();
54  if (!heatmap)
55  boxset->UseSingleColor();
56  boxset->SetPickable(true);
57  boxset->Reset(TEveBoxSet::kBT_FreeBox, true, 64);
58  boxset->SetAntiFlick(true);
59 
60  for (const auto &c : iData.simClusters()) {
61  for (const auto &it : (*c).hits_and_fractions()) {
62  if (heatmap && hitmap->find(it.first) == hitmap->end())
63  continue;
64 
65  const bool z = (it.first >> 25) & 0x1;
66 
67  // discard everything thats not at the side that we are intersted in
68  if (((z_plus & z_minus) != 1) && (((z_plus | z_minus) == 0) || !(z == z_minus || z == !z_plus)))
69  continue;
70 
71  const float *corners = item()->getGeom()->getCorners(it.first);
72  const float *parameters = item()->getGeom()->getParameters(it.first);
73  const float *shapes = item()->getGeom()->getShapePars(it.first);
74 
75  if (corners == nullptr || parameters == nullptr || shapes == nullptr) {
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  if (layer > 28) {
86  if (type == 8) {
87  continue;
88  }
89  ll -= 28;
90  } else {
91  if (type != 8) {
92  continue;
93  }
94  }
95 
96  if (ll != ((it.first >> (isScintillator ? 17 : 20)) & 0x1F))
97  continue;
98  }
99 
100  // Scintillator
101  if (isScintillator) {
102  const int total_vertices = 3 * total_points;
103 
104  std::vector<float> pnts(24);
105  for (int i = 0; i < total_points; ++i) {
106  pnts[i * 3 + 0] = corners[i * 3];
107  pnts[i * 3 + 1] = corners[i * 3 + 1];
108  pnts[i * 3 + 2] = corners[i * 3 + 2];
109 
110  pnts[(i * 3 + 0) + total_vertices] = corners[i * 3];
111  pnts[(i * 3 + 1) + total_vertices] = corners[i * 3 + 1];
112  pnts[(i * 3 + 2) + total_vertices] = corners[i * 3 + 2] + shapes[3];
113  }
114  boxset->AddBox(&pnts[0]);
115  if (heatmap) {
116  const uint8_t colorFactor = gradient_steps * (fmin(hitmap->at(it.first)->energy() / saturation_energy, 1.0f));
117  boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor]);
118  }
119 
120  h_box = true;
121  }
122  // Silicon
123  else {
124  const int offset = 9;
125 
126  float centerX = (corners[6] + corners[6 + offset]) / 2;
127  float centerY = (corners[7] + corners[7 + offset]) / 2;
128  float radius = fabs(corners[6] - corners[6 + offset]) / 2;
129  hex_boxset->AddHex(TEveVector(centerX, centerY, corners[2]), radius, 90.0, shapes[3]);
130  if (heatmap) {
131  const uint8_t colorFactor = gradient_steps * (fmin(hitmap->at(it.first)->energy() / saturation_energy, 1.0f));
132  hex_boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor]);
133  }
134 
135  h_hex = true;
136  }
137  }
138  }
139 
140  if (h_hex) {
141  hex_boxset->RefitPlex();
142 
143  hex_boxset->CSCTakeAnyParentAsMaster();
144  if (!heatmap) {
145  hex_boxset->CSCApplyMainColorToMatchingChildren();
146  hex_boxset->CSCApplyMainTransparencyToMatchingChildren();
147  hex_boxset->SetMainColor(item()->modelInfo(iIndex).displayProperties().color());
148  hex_boxset->SetMainTransparency(item()->defaultDisplayProperties().transparency());
149  }
150  oItemHolder.AddElement(hex_boxset);
151  }
152 
153  if (h_box) {
154  boxset->RefitPlex();
155 
156  boxset->CSCTakeAnyParentAsMaster();
157  if (!heatmap) {
158  boxset->CSCApplyMainColorToMatchingChildren();
159  boxset->CSCApplyMainTransparencyToMatchingChildren();
160  boxset->SetMainColor(item()->modelInfo(iIndex).displayProperties().color());
161  boxset->SetMainTransparency(item()->defaultDisplayProperties().transparency());
162  }
163  oItemHolder.AddElement(boxset);
164  }
165 }
166 
168  CaloParticle,
169  "CaloParticle",
FWCaloParticleProxyBuilder::operator=
const FWCaloParticleProxyBuilder & operator=(const FWCaloParticleProxyBuilder &)=delete
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:30
mps_fire.i
i
Definition: mps_fire.py:428
FWGeometry::getCorners
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:467
FWEventItem::getConfig
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:150
FWHeatmapProxyBuilderTemplate< CaloParticle >::gradient_steps
static constexpr uint8_t gradient_steps
Definition: FWHeatmapProxyBuilderTemplate.h:49
FWViewType::kAllRPZBits
static const int kAllRPZBits
Definition: FWViewType.h:67
REGISTER_FWPROXYBUILDER
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
Definition: FWProxyBuilderFactory.h:33
CaloParticleFwd.h
REGISTER_PROXYBUILDER_METHODS
#define REGISTER_PROXYBUILDER_METHODS()
Definition: register_dataproxybuilder_macro.h:28
FWCaloParticleProxyBuilder::~FWCaloParticleProxyBuilder
~FWCaloParticleProxyBuilder(void) override
Definition: FWCaloParticleProxyBuilder.cc:21
FWGeometry::getShapePars
const float * getShapePars(unsigned int id) const
Definition: FWGeometry.cc:489
FWViewType::kAll3DBits
static const int kAll3DBits
Definition: FWViewType.h:68
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
SimCluster.h
DDAxes::z
FWHeatmapProxyBuilderTemplate< CaloParticle >::gradient
static constexpr uint8_t gradient[3][gradient_steps]
Definition: FWHeatmapProxyBuilderTemplate.h:50
FWGeometry.h
CaloParticle
Definition: CaloParticle.h:16
FWCaloParticleProxyBuilder
Definition: FWCaloParticleProxyBuilder.cc:18
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
CaloParticle.h
FWProxyBuilderBase::build
void build()
Definition: FWProxyBuilderBase.cc:110
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
FWHeatmapProxyBuilderTemplate
Definition: FWHeatmapProxyBuilderTemplate.h:34
FWProxyBuilderConfiguration::value
T value(const std::string &name)
Definition: FWProxyBuilderConfiguration.cc:123
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
FWHeatmapProxyBuilderTemplate.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
FWHeatmapProxyBuilderTemplate< CaloParticle >::hitmap
std::unordered_map< DetId, const HGCRecHit * > * hitmap
Definition: FWHeatmapProxyBuilderTemplate.h:47
CaloParticle::simClusters
const SimClusterRefVector & simClusters() const
Definition: CaloParticle.h:72
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
FWCaloParticleProxyBuilder::FWCaloParticleProxyBuilder
FWCaloParticleProxyBuilder(void)
Definition: FWCaloParticleProxyBuilder.cc:20
Context.h