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
mps_fire.i
i
Definition: mps_fire.py:428
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
FWGeometry::getCorners
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:467
edm::Ref::isAvailable
bool isAvailable() const
Definition: Ref.h:537
FWProxyBuilderBase.h
BuilderUtils.h
FWDisplayProperties::color
Color_t color() const
Definition: FWDisplayProperties.h:47
edm::Ref< SuperClusterCollection >
fireworks::getShape
TEveGeoShape * getShape(const char *name, TGeoBBox *shape, Color_t color)
Definition: BuilderUtils.cc:44
FWEventItem::defaultDisplayProperties
const FWDisplayProperties & defaultDisplayProperties() const
Definition: FWEventItem.cc:403
fireworks::Context::caloZ2
static float caloZ2(bool offset=true)
Definition: Context.cc:185
mps_fire.end
end
Definition: mps_fire.py:242
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
VtxSmearedParameters_cfi.Phi
Phi
Definition: VtxSmearedParameters_cfi.py:112
fireworks::addRhoZEnergyProjection
void addRhoZEnergyProjection(FWProxyBuilderBase *, TEveElement *, double r_ecal, double z_ecal, double theta_min, double theta_max, double phi)
Definition: BuilderUtils.cc:58
FWGeometry.h
fireworks::Context::caloR2
static float caloR2(bool offset=true)
Definition: Context.cc:182
fireworks::makeRhoZSuperCluster
bool makeRhoZSuperCluster(FWProxyBuilderBase *, const reco::SuperClusterRef &iCluster, float iPhi, TEveElement &oItemHolder)
Definition: makeSuperCluster.cc:69
fireworks::Context::getGeom
FWGeometry * getGeom() const
Definition: Context.h:72
FWProxyBuilderBase::setupAddElement
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Definition: FWProxyBuilderBase.cc:350
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
FWEventItem.h
fireworks::Context::caloTransAngle
static float caloTransAngle()
Definition: Context.cc:189
fireworks::makeRhoPhiSuperCluster
bool makeRhoPhiSuperCluster(FWProxyBuilderBase *, const reco::SuperClusterRef &iCluster, float iPhi, TEveElement &oItemHolder)
Definition: makeSuperCluster.cc:29
alignCSCRings.r
r
Definition: alignCSCRings.py:93
FWProxyBuilderBase::item
const FWEventItem * item() const
Definition: FWProxyBuilderBase.h:64
makeSuperCluster.h
fireworks::Context::caloZ1
static float caloZ1(bool offset=true)
Definition: Context.cc:183
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
FWProxyBuilderBase
Definition: FWProxyBuilderBase.h:46
FWProxyBuilderBase::context
const fireworks::Context & context() const
Definition: FWProxyBuilderBase.cc:412
Pi
const double Pi
Definition: CosmicMuonParameters.h:18
fireworks
Definition: FWTauProxyBuilderBase.h:35
fireworks::Context::caloR1
static float caloR1(bool offset=true)
Definition: Context.cc:180
Context.h
fireworks::getPhiRange
std::pair< double, double > getPhiRange(const std::vector< double > &phis, double phi)
Definition: BuilderUtils.cc:21