CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // $Id: makeSuperCluster.cc,v 1.13 2010/09/16 15:42:21 yana Exp $
12 //
13 
14 // system include files
15 #include "TEveGeoNode.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 {
34  if( !iCluster.isAvailable()) return false;
35  TEveGeoManagerHolder gmgr( TEveGeoShape::GetGeoMangeur());
36 
37  std::vector< std::pair<DetId, float> > detids = iCluster->hitsAndFractions();
38  std::vector<double> phis;
39  for( std::vector<std::pair<DetId, float> >::const_iterator id = detids.begin(), end = detids.end(); id != end; ++id )
40  {
41  const float* corners = pb->context().getGeom()->getCorners( id->first.rawId());
42  if( corners != 0 )
43  {
44  std::vector<float> centre( 3, 0 );
45 
46  for( unsigned int i = 0; i < 24; i += 3 )
47  {
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, r , 1,
59  phiRange.first * 180 / M_PI - 0.5,
60  phiRange.second * 180 / M_PI + 0.5 ); // 0.5 is roughly half size of a crystal
61  TEveGeoShape *sc = fireworks::getShape( "supercluster", sc_box, pb->item()->defaultDisplayProperties().color());
62  sc->SetPickable( kTRUE );
63  pb->setupAddElement( sc, &oItemHolder );
64  return true;
65 }
66 
68  const reco::SuperClusterRef& iCluster,
69  float iPhi,
70  TEveElement& oItemHolder )
71 {
72  if( !iCluster.isAvailable()) return false;
73  TEveGeoManagerHolder gmgr( TEveGeoShape::GetGeoMangeur());
74  double theta_max = 0;
75  double theta_min = 10;
76  std::vector<std::pair<DetId, float> > detids = iCluster->hitsAndFractions();
77  for( std::vector<std::pair<DetId, float> >::const_iterator id = detids.begin(), end = detids.end(); id != end; ++id )
78  {
79  const float* corners = pb->context().getGeom()->getCorners( id->first.rawId());
80  if( corners != 0 )
81  {
82  std::vector<float> centre( 3, 0 );
83 
84  for( unsigned int i = 0; i < 24; i += 3 )
85  {
86  centre[0] += corners[i];
87  centre[1] += corners[i + 1];
88  centre[2] += corners[i + 2];
89  }
90 
91  double theta = TEveVector( centre[0], centre[1], centre[2] ).Theta();
92  if( theta > theta_max ) theta_max = theta;
93  if( theta < theta_min ) theta_min = theta;
94  }
95  }
96  // expand theta range by the size of a crystal to avoid segments of zero length
97  bool barrel = true;
98  if ((theta_max > 0 && theta_max < pb->context().caloTransAngle()) ||
99  ( theta_min > (TMath::Pi() -pb->context().caloTransAngle())) )
100  {
101  barrel = false;
102  }
103 
104  double z_ecal = barrel ? pb->context().caloZ1() : pb->context().caloZ2();
105  double r_ecal = barrel ? pb->context().caloR1() : pb->context().caloR2();
106 
107  fireworks::addRhoZEnergyProjection( pb, &oItemHolder, r_ecal-1, z_ecal-1,
108  theta_min - 0.003, theta_max + 0.003,
109  iPhi );
110 
111  return true;
112 }
113 
114 }
const double Pi
const fireworks::Context & context() const
int i
Definition: DBlmapReader.cc:9
const FWDisplayProperties & defaultDisplayProperties() const
Definition: FWEventItem.cc:452
std::pair< double, double > getPhiRange(const std::vector< double > &phis, double phi)
Definition: BuilderUtils.cc:21
static float caloTransAngle()
Definition: Context.cc:235
const FWGeometry * getGeom() const
Definition: Context.h:84
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Geom::Theta< T > theta() const
static float caloZ2(bool offset=true)
Definition: Context.cc:225
bool isAvailable() const
Definition: Ref.h:276
const FWEventItem * item() const
Color_t color() const
static float caloR2(bool offset=true)
Definition: Context.cc:215
static float caloR1(bool offset=true)
Definition: Context.cc:210
#define end
Definition: vmac.h:38
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:60
#define M_PI
Definition: BFit3D.cc:3
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:277
bool makeRhoPhiSuperCluster(FWProxyBuilderBase *, const reco::SuperClusterRef &iCluster, float iPhi, TEveElement &oItemHolder)
static float caloZ1(bool offset=true)
Definition: Context.cc:220
TEveGeoShape * getShape(const char *name, TGeoBBox *shape, Color_t color)
Definition: BuilderUtils.cc:42