CMS 3D CMS Logo

makeSuperCluster.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Electrons
4 // Class : makeSuperCluster
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Fri Dec 5 15:32:33 EST 2008
11 //
12 
13 // system include files
14 #include "TEveGeoNode.h"
15 #include "TEveGeoShape.h"
16 #include "TGeoBBox.h"
17 #include "TGeoTube.h"
18 
19 // user include files
21 
27 
28 namespace fireworks {
30  const reco::SuperClusterRef& iCluster,
31  float iPhi,
32  TEveElement& oItemHolder) {
33  if (!iCluster.isAvailable())
34  return false;
35  TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
36 
37  std::vector<std::pair<DetId, float> > detids = iCluster->hitsAndFractions();
38  if (detids.empty())
39  return false;
40  std::vector<double> phis;
41  for (std::vector<std::pair<DetId, float> >::const_iterator id = detids.begin(), end = detids.end(); id != end;
42  ++id) {
43  const float* corners = pb->context().getGeom()->getCorners(id->first.rawId());
44  if (corners != nullptr) {
45  std::vector<float> centre(3, 0);
46 
47  for (unsigned int i = 0; i < 24; i += 3) {
48  centre[0] += corners[i];
49  centre[1] += corners[i + 1];
50  centre[2] += corners[i + 2];
51  }
52 
53  phis.push_back(TEveVector(centre[0], centre[1], centre[2]).Phi());
54  }
55  }
56  std::pair<double, double> phiRange = fireworks::getPhiRange(phis, iPhi);
57  const double r = pb->context().caloR1();
58  TGeoBBox* sc_box = new TGeoTubeSeg(r - 2,
59  r,
60  1,
61  phiRange.first * 180 / M_PI - 0.5,
62  phiRange.second * 180 / M_PI + 0.5); // 0.5 is roughly half size of a crystal
63  TEveGeoShape* sc = fireworks::getShape("supercluster", sc_box, pb->item()->defaultDisplayProperties().color());
64  sc->SetPickable(kTRUE);
65  pb->setupAddElement(sc, &oItemHolder);
66  return true;
67  }
68 
70  const reco::SuperClusterRef& iCluster,
71  float iPhi,
72  TEveElement& oItemHolder) {
73  if (!iCluster.isAvailable())
74  return false;
75  TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
76  double theta_max = 0;
77  double theta_min = 10;
78  std::vector<std::pair<DetId, float> > detids = iCluster->hitsAndFractions();
79  if (detids.empty())
80  return false;
81  for (std::vector<std::pair<DetId, float> >::const_iterator id = detids.begin(), end = detids.end(); id != end;
82  ++id) {
83  const float* corners = pb->context().getGeom()->getCorners(id->first.rawId());
84  if (corners != nullptr) {
85  std::vector<float> centre(3, 0);
86 
87  for (unsigned int i = 0; i < 24; i += 3) {
88  centre[0] += corners[i];
89  centre[1] += corners[i + 1];
90  centre[2] += corners[i + 2];
91  }
92 
93  double theta = TEveVector(centre[0], centre[1], centre[2]).Theta();
94  if (theta > theta_max)
95  theta_max = theta;
96  if (theta < theta_min)
97  theta_min = theta;
98  }
99  }
100  // expand theta range by the size of a crystal to avoid segments of zero length
101  bool barrel = true;
102  if ((theta_max > 0 && theta_max < pb->context().caloTransAngle()) ||
103  (theta_min > (TMath::Pi() - pb->context().caloTransAngle()))) {
104  barrel = false;
105  }
106 
107  double z_ecal = barrel ? pb->context().caloZ1() : pb->context().caloZ2();
108  double r_ecal = barrel ? pb->context().caloR1() : pb->context().caloR2();
109 
111  pb, &oItemHolder, r_ecal - 1, z_ecal - 1, theta_min - 0.003, theta_max + 0.003, iPhi);
112 
113  return true;
114  }
115 
116 } // namespace fireworks
const double Pi
std::pair< double, double > getPhiRange(const std::vector< double > &phis, double phi)
Definition: BuilderUtils.cc:21
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
static float caloTransAngle()
Definition: Context.cc:196
static float caloZ2(bool offset=true)
Definition: Context.cc:192
const fireworks::Context & context() const
static float caloR2(bool offset=true)
Definition: Context.cc:189
FWGeometry * getGeom() const
Definition: Context.h:72
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:439
const FWDisplayProperties & defaultDisplayProperties() const
Definition: FWEventItem.cc:403
bool isAvailable() const
Definition: Ref.h:537
static float caloR1(bool offset=true)
Definition: Context.cc:187
#define M_PI
bool makeRhoZSuperCluster(FWProxyBuilderBase *, const reco::SuperClusterRef &iCluster, float iPhi, TEveElement &oItemHolder)
void addRhoZEnergyProjection(FWProxyBuilderBase *, TEveElement *, double r_ecal, double z_ecal, double theta_min, double theta_max, double phi)
Definition: BuilderUtils.cc:58
bool makeRhoPhiSuperCluster(FWProxyBuilderBase *, const reco::SuperClusterRef &iCluster, float iPhi, TEveElement &oItemHolder)
static float caloZ1(bool offset=true)
Definition: Context.cc:190
TEveGeoShape * getShape(const char *name, TGeoBBox *shape, Color_t color)
Definition: BuilderUtils.cc:44
Geom::Theta< T > theta() const
const FWEventItem * item() const