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 "TGeoBBox.h"
16 #include "TGeoTube.h"
17 
18 // user include files
20 
26 
27 namespace fireworks {
29  const reco::SuperClusterRef& iCluster,
30  float iPhi,
31  TEveElement& oItemHolder) {
32  if (!iCluster.isAvailable())
33  return false;
34  TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
35 
36  std::vector<std::pair<DetId, float> > detids = iCluster->hitsAndFractions();
37  if (detids.empty())
38  return false;
39  std::vector<double> phis;
40  for (std::vector<std::pair<DetId, float> >::const_iterator id = detids.begin(), end = detids.end(); id != end;
41  ++id) {
42  const float* corners = pb->context().getGeom()->getCorners(id->first.rawId());
43  if (corners != nullptr) {
44  std::vector<float> centre(3, 0);
45 
46  for (unsigned int i = 0; i < 24; i += 3) {
47  centre[0] += corners[i];
48  centre[1] += corners[i + 1];
49  centre[2] += corners[i + 2];
50  }
51 
52  phis.push_back(TEveVector(centre[0], centre[1], centre[2]).Phi());
53  }
54  }
55  std::pair<double, double> phiRange = fireworks::getPhiRange(phis, iPhi);
56  const double r = pb->context().caloR1();
57  TGeoBBox* sc_box = new TGeoTubeSeg(r - 2,
58  r,
59  1,
60  phiRange.first * 180 / M_PI - 0.5,
61  phiRange.second * 180 / M_PI + 0.5); // 0.5 is roughly half size of a crystal
62  TEveGeoShape* sc = fireworks::getShape("supercluster", sc_box, pb->item()->defaultDisplayProperties().color());
63  sc->SetPickable(kTRUE);
64  pb->setupAddElement(sc, &oItemHolder);
65  return true;
66  }
67 
69  const reco::SuperClusterRef& iCluster,
70  float iPhi,
71  TEveElement& oItemHolder) {
72  if (!iCluster.isAvailable())
73  return false;
74  TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
75  double theta_max = 0;
76  double theta_min = 10;
77  std::vector<std::pair<DetId, float> > detids = iCluster->hitsAndFractions();
78  if (detids.empty())
79  return false;
80  for (std::vector<std::pair<DetId, float> >::const_iterator id = detids.begin(), end = detids.end(); id != end;
81  ++id) {
82  const float* corners = pb->context().getGeom()->getCorners(id->first.rawId());
83  if (corners != nullptr) {
84  std::vector<float> centre(3, 0);
85 
86  for (unsigned int i = 0; i < 24; i += 3) {
87  centre[0] += corners[i];
88  centre[1] += corners[i + 1];
89  centre[2] += corners[i + 2];
90  }
91 
92  double theta = TEveVector(centre[0], centre[1], centre[2]).Theta();
93  if (theta > theta_max)
94  theta_max = theta;
95  if (theta < theta_min)
96  theta_min = theta;
97  }
98  }
99  // expand theta range by the size of a crystal to avoid segments of zero length
100  bool barrel = true;
101  if ((theta_max > 0 && theta_max < pb->context().caloTransAngle()) ||
102  (theta_min > (TMath::Pi() - pb->context().caloTransAngle()))) {
103  barrel = false;
104  }
105 
106  double z_ecal = barrel ? pb->context().caloZ1() : pb->context().caloZ2();
107  double r_ecal = barrel ? pb->context().caloR1() : pb->context().caloR2();
108 
110  pb, &oItemHolder, r_ecal - 1, z_ecal - 1, theta_min - 0.003, theta_max + 0.003, iPhi);
111 
112  return true;
113  }
114 
115 } // namespace fireworks
mps_fire.i
i
Definition: mps_fire.py:355
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
FWGeometry::getCorners
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:464
edm::Ref::isAvailable
bool isAvailable() const
Definition: Ref.h:537
FWProxyBuilderBase.h
BuilderUtils.h
FWDisplayProperties::color
Color_t color() const
Definition: FWDisplayProperties.h:47
end
#define end
Definition: vmac.h:39
edm::Ref< SuperClusterCollection >
fireworks::getShape
TEveGeoShape * getShape(const char *name, TGeoBBox *shape, Color_t color)
Definition: BuilderUtils.cc:43
FWEventItem::defaultDisplayProperties
const FWDisplayProperties & defaultDisplayProperties() const
Definition: FWEventItem.cc:403
fireworks::Context::caloZ2
static float caloZ2(bool offset=true)
Definition: Context.cc:185
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:57
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:68
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:50
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:28
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:20