CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/Fireworks/Electrons/src/makeSuperCluster.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Electrons
00004 // Class  :     makeSuperCluster
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Fri Dec  5 15:32:33 EST 2008
00011 // $Id: makeSuperCluster.cc,v 1.13 2010/09/16 15:42:21 yana Exp $
00012 //
00013 
00014 // system include files
00015 #include "TEveGeoNode.h"
00016 #include "TGeoBBox.h"
00017 #include "TGeoTube.h"
00018 
00019 // user include files
00020 #include "Fireworks/Electrons/interface/makeSuperCluster.h"
00021 
00022 #include "Fireworks/Core/interface/BuilderUtils.h"
00023 #include "Fireworks/Core/interface/FWEventItem.h"
00024 #include "Fireworks/Core/interface/FWGeometry.h"
00025 #include "Fireworks/Core/interface/Context.h"
00026 #include "Fireworks/Core/interface/FWProxyBuilderBase.h" 
00027 
00028 namespace fireworks {
00029 bool makeRhoPhiSuperCluster( FWProxyBuilderBase* pb,
00030                              const reco::SuperClusterRef& iCluster,
00031                              float iPhi,
00032                              TEveElement& oItemHolder )
00033 {
00034    if( !iCluster.isAvailable()) return false;
00035    TEveGeoManagerHolder gmgr( TEveGeoShape::GetGeoMangeur());
00036 
00037    std::vector< std::pair<DetId, float> > detids = iCluster->hitsAndFractions();
00038    std::vector<double> phis;
00039    for( std::vector<std::pair<DetId, float> >::const_iterator id = detids.begin(), end = detids.end(); id != end; ++id )
00040    {
00041       const float* corners = pb->context().getGeom()->getCorners( id->first.rawId());
00042       if( corners != 0 )
00043       {
00044          std::vector<float> centre( 3, 0 );
00045 
00046          for( unsigned int i = 0; i < 24; i += 3 )
00047          {       
00048             centre[0] += corners[i];
00049             centre[1] += corners[i + 1];
00050             centre[2] += corners[i + 2];
00051          }
00052        
00053          phis.push_back( TEveVector( centre[0], centre[1], centre[2] ).Phi());
00054       }
00055    }
00056    std::pair<double,double> phiRange = fireworks::getPhiRange( phis, iPhi );
00057    const double r = pb->context().caloR1();
00058    TGeoBBox *sc_box = new TGeoTubeSeg( r - 2, r , 1,
00059                                        phiRange.first * 180 / M_PI - 0.5,
00060                                        phiRange.second * 180 / M_PI + 0.5 ); // 0.5 is roughly half size of a crystal
00061    TEveGeoShape *sc = fireworks::getShape( "supercluster", sc_box, pb->item()->defaultDisplayProperties().color());
00062    sc->SetPickable( kTRUE );
00063    pb->setupAddElement( sc, &oItemHolder );
00064    return true;
00065 }
00066 
00067 bool makeRhoZSuperCluster( FWProxyBuilderBase* pb,
00068                            const reco::SuperClusterRef& iCluster,
00069                            float iPhi,
00070                            TEveElement& oItemHolder )
00071 {
00072    if( !iCluster.isAvailable()) return false;
00073    TEveGeoManagerHolder gmgr( TEveGeoShape::GetGeoMangeur());
00074    double theta_max = 0;
00075    double theta_min = 10;
00076    std::vector<std::pair<DetId, float> > detids = iCluster->hitsAndFractions();
00077    for( std::vector<std::pair<DetId, float> >::const_iterator id = detids.begin(), end = detids.end(); id != end; ++id )
00078    {
00079       const float* corners = pb->context().getGeom()->getCorners( id->first.rawId());
00080       if( corners != 0 )
00081       {
00082          std::vector<float> centre( 3, 0 );
00083 
00084          for( unsigned int i = 0; i < 24; i += 3 )
00085          {       
00086             centre[0] += corners[i];
00087             centre[1] += corners[i + 1];
00088             centre[2] += corners[i + 2];
00089          }
00090 
00091          double theta = TEveVector( centre[0], centre[1], centre[2] ).Theta();
00092          if( theta > theta_max ) theta_max = theta;
00093          if( theta < theta_min ) theta_min = theta;
00094       }
00095    }
00096    // expand theta range by the size of a crystal to avoid segments of zero length
00097    bool barrel = true; 
00098    if ((theta_max > 0 && theta_max <  pb->context().caloTransAngle()) || 
00099        ( theta_min > (TMath::Pi() -pb->context().caloTransAngle())) )
00100    {
00101         barrel = false; 
00102    }
00103  
00104    double z_ecal = barrel ? pb->context().caloZ1() : pb->context().caloZ2();
00105    double r_ecal = barrel ? pb->context().caloR1() : pb->context().caloR2();
00106 
00107    fireworks::addRhoZEnergyProjection( pb, &oItemHolder, r_ecal-1, z_ecal-1,
00108                                        theta_min - 0.003, theta_max + 0.003,
00109                                        iPhi );
00110 
00111    return true;
00112 }
00113 
00114 }