test
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 //
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 {
33  if( !iCluster.isAvailable()) return false;
34  TEveGeoManagerHolder gmgr( TEveGeoShape::GetGeoMangeur());
35 
36  std::vector< std::pair<DetId, float> > detids = iCluster->hitsAndFractions();
37  std::vector<double> phis;
38  for( std::vector<std::pair<DetId, float> >::const_iterator id = detids.begin(), end = detids.end(); id != end; ++id )
39  {
40  const float* corners = pb->context().getGeom()->getCorners( id->first.rawId());
41  if( corners != 0 )
42  {
43  std::vector<float> centre( 3, 0 );
44 
45  for( unsigned int i = 0; i < 24; i += 3 )
46  {
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, r , 1,
58  phiRange.first * 180 / M_PI - 0.5,
59  phiRange.second * 180 / M_PI + 0.5 ); // 0.5 is roughly half size of a crystal
60  TEveGeoShape *sc = fireworks::getShape( "supercluster", sc_box, pb->item()->defaultDisplayProperties().color());
61  sc->SetPickable( kTRUE );
62  pb->setupAddElement( sc, &oItemHolder );
63  return true;
64 }
65 
67  const reco::SuperClusterRef& iCluster,
68  float iPhi,
69  TEveElement& oItemHolder )
70 {
71  if( !iCluster.isAvailable()) return false;
72  TEveGeoManagerHolder gmgr( TEveGeoShape::GetGeoMangeur());
73  double theta_max = 0;
74  double theta_min = 10;
75  std::vector<std::pair<DetId, float> > detids = iCluster->hitsAndFractions();
76  for( std::vector<std::pair<DetId, float> >::const_iterator id = detids.begin(), end = detids.end(); id != end; ++id )
77  {
78  const float* corners = pb->context().getGeom()->getCorners( id->first.rawId());
79  if( corners != 0 )
80  {
81  std::vector<float> centre( 3, 0 );
82 
83  for( unsigned int i = 0; i < 24; i += 3 )
84  {
85  centre[0] += corners[i];
86  centre[1] += corners[i + 1];
87  centre[2] += corners[i + 2];
88  }
89 
90  double theta = TEveVector( centre[0], centre[1], centre[2] ).Theta();
91  if( theta > theta_max ) theta_max = theta;
92  if( theta < theta_min ) theta_min = theta;
93  }
94  }
95  // expand theta range by the size of a crystal to avoid segments of zero length
96  bool barrel = true;
97  if ((theta_max > 0 && theta_max < pb->context().caloTransAngle()) ||
98  ( theta_min > (TMath::Pi() -pb->context().caloTransAngle())) )
99  {
100  barrel = false;
101  }
102 
103  double z_ecal = barrel ? pb->context().caloZ1() : pb->context().caloZ2();
104  double r_ecal = barrel ? pb->context().caloR1() : pb->context().caloR2();
105 
106  fireworks::addRhoZEnergyProjection( pb, &oItemHolder, r_ecal-1, z_ecal-1,
107  theta_min - 0.003, theta_max + 0.003,
108  iPhi );
109 
110  return true;
111 }
112 
113 }
const double Pi
const fireworks::Context & context() const
int i
Definition: DBlmapReader.cc:9
const FWDisplayProperties & defaultDisplayProperties() const
Definition: FWEventItem.cc:451
std::pair< double, double > getPhiRange(const std::vector< double > &phis, double phi)
Definition: BuilderUtils.cc:21
static float caloTransAngle()
Definition: Context.cc:234
const FWGeometry * getGeom() const
Definition: Context.h:83
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:224
bool isAvailable() const
Definition: Ref.h:276
const FWEventItem * item() const
Color_t color() const
static float caloR2(bool offset=true)
Definition: Context.cc:214
static float caloR1(bool offset=true)
Definition: Context.cc:209
#define end
Definition: vmac.h:37
#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:60
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:219
TEveGeoShape * getShape(const char *name, TGeoBBox *shape, Color_t color)
Definition: BuilderUtils.cc:42