CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWPFBlockProxyBuilder.cc
Go to the documentation of this file.
2 
3 //______________________________________________________________________________
4 float
5 FWPFBlockProxyBuilder::calculateEt( const TEveVector &centre, float e )
6 {
7  TEveVector vec = centre;
8  float et;
9 
10  vec.Normalize();
11  vec *= e;
12  et = vec.Perp();
13 
14  return et;
15 }
16 
17 //______________________________________________________________________________
18 void
20 {
21  typedef std::vector<ScalableLines> Lines_t;
22  FWViewEnergyScale *caloScale = vc->getEnergyScale();
23 
24  if( viewType == FWViewType::kRhoPhiPF || viewType == FWViewType::kRhoZ )
25  { /* Handle the rhophi and rhoz cluster scaling */
26  for( Lines_t::iterator i = m_clusters.begin(); i != m_clusters.end(); ++i )
27  {
28  if( vc == (*i).m_vc )
29  {
30  float value = caloScale->getPlotEt() ? (*i).m_et : (*i).m_energy;
31  (*i).m_ls->SetScale( caloScale->getScaleFactor3D() * value );
32  TEveProjected *proj = *(*i).m_ls->BeginProjecteds();
33  proj->UpdateProjection();
34  }
35  }
36  }
37 }
38 
39 //______________________________________________________________________________
40 void
42  TEveElement &oItemHolder, const FWViewContext *vc, FWViewType::EType viewType )
43 {
44  if( blockElement.trackType( reco::PFBlockElement::DEFAULT ) )
45  {
46  reco::Track track = *blockElement.trackRef();
47  FWPFTrackUtils *trackUtils = new FWPFTrackUtils();
48 
49  if( viewType == FWViewType::kLego || viewType == FWViewType::kLegoPFECAL ) // Lego views
50  {
51  TEveStraightLineSet *legoTrack = trackUtils->setupLegoTrack( track );
52  legoTrack->SetRnrMarkers( true );
53  setupAddElement( legoTrack, &oItemHolder );
54  }
55  else if( viewType == FWViewType::kRhoPhiPF || viewType == FWViewType::kRhoZ ) // Projected views
56  {
57  TEveTrack *trk = trackUtils->setupRPZTrack( track );
58  TEvePointSet *ps = trackUtils->getCollisionMarkers( trk );
59  setupAddElement( trk, &oItemHolder );
60  if( ps->GetN() != 0 )
61  setupAddElement( ps, &oItemHolder );
62  else
63  delete ps;
64  }
65  }
66 }
67 
68 //______________________________________________________________________________
69 void
70 FWPFBlockProxyBuilder::setupClusterElement( const reco::PFBlockElement &blockElement, TEveElement &oItemHolder,
71  const FWViewContext *vc, FWViewType::EType viewType, float r )
72 {
73  // Get reference to PFCluster
74  reco::PFCluster cluster = *blockElement.clusterRef();
75  TEveVector centre = TEveVector( cluster.x(), cluster.y(), cluster.z() );
76  float energy = cluster.energy();
77  float et = calculateEt( centre, energy );
78  float pt = et;
79  float eta = cluster.eta();
80  float phi = cluster.phi();
81 
83 
84  if( viewType == FWViewType::kLego || viewType == FWViewType::kLegoPFECAL )
85  {
86  FWPFLegoCandidate *legoCluster = new FWPFLegoCandidate( vc, FWProxyBuilderBase::context(), energy, et, pt, eta, phi );
87  legoCluster->SetMarkerColor( FWProxyBuilderBase::item()->defaultDisplayProperties().color() );
88  setupAddElement( legoCluster, &oItemHolder );
89  }
90  if( viewType == FWViewType::kRhoPhiPF )
91  {
93  FWPFClusterRPZUtils *clusterUtils = new FWPFClusterRPZUtils();
94  TEveScalableStraightLineSet *rpCluster = clusterUtils->buildRhoPhiClusterLineSet( cluster, vc, energy, et, r );
95  rpCluster->SetLineColor( dp.color() );
96  m_clusters.push_back( ScalableLines( rpCluster, et, energy, vc ) );
97  setupAddElement( rpCluster, &oItemHolder );
98  delete clusterUtils;
99  }
100  else if( viewType == FWViewType::kRhoZ )
101  {
103  FWPFClusterRPZUtils *clusterUtils = new FWPFClusterRPZUtils();
104  TEveScalableStraightLineSet *rzCluster = clusterUtils->buildRhoZClusterLineSet( cluster, vc, context().caloTransAngle(),
105  energy, et, r, context().caloZ1() );
106  rzCluster->SetLineColor( dp.color() );
107  m_clusters.push_back( ScalableLines( rzCluster, et, energy, vc ) );
108  setupAddElement( rzCluster, &oItemHolder );
109  delete clusterUtils;
110  }
111 }
112 
113 //______________________________________________________________________________
114 void
115 FWPFBlockProxyBuilder::buildViewType( const reco::PFBlock &iData, unsigned int iIndex, TEveElement &oItemHolder,
116  FWViewType::EType viewType, const FWViewContext *vc )
117 {
119 
120  for( unsigned int i = 0; i < elements.size(); ++i )
121  {
122  reco::PFBlockElement::Type type = elements[i].type();
123  switch( type )
124  {
125  case 1: // TRACK
126  if( e_builderType == BASE )
127  setupTrackElement( elements[i], oItemHolder, vc, viewType );
128  break;
129 
130  case 4: // ECAL
131  if( e_builderType == ECAL )
132  setupClusterElement( elements[i], oItemHolder, vc, viewType, context().caloR1() );
133  break;
134 
135  case 5: // HCAL
136  if( e_builderType == HCAL )
137  {
138  if( viewType == FWViewType::kRhoPhiPF )
139  setupClusterElement( elements[i], oItemHolder, vc, viewType, 177.7 );
140  else // RhoZ
141  setupClusterElement( elements[i], oItemHolder, vc, viewType, context().caloR1() );
142  }
143  break;
144 
145  default: // Ignore anything that isn't wanted
146  break;
147  }
148  }
149 }
150 
151 //______________________________________________________________________________
type
Definition: HCALResponse.h:22
const fireworks::Context & context() const
Abstract base class for a PFBlock element (track, cluster...)
float getScaleFactor3D() const
int i
Definition: DBlmapReader.cc:9
const FWDisplayProperties & defaultDisplayProperties() const
Definition: FWEventItem.cc:452
void setupTrackElement(const reco::PFBlockElement &, TEveElement &, const FWViewContext *, FWViewType::EType)
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
void setupClusterElement(const reco::PFBlockElement &, TEveElement &, const FWViewContext *, FWViewType::EType, float r)
list parent
Definition: dbtoconf.py:74
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:42
TEvePointSet * getCollisionMarkers(const TEveTrack *)
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:185
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
size_type size() const
Definition: OwnVector.h:260
FWViewEnergyScale * getEnergyScale() const
list elements
Definition: asciidump.py:414
const edm::OwnVector< reco::PFBlockElement > & elements() const
Definition: PFBlock.h:107
std::vector< ScalableLines > m_clusters
TEveScalableStraightLineSet * buildRhoPhiClusterLineSet(const reco::PFCluster &, const FWViewContext *, float r)
T eta() const
double z() const
z coordinate of cluster centroid
Definition: CaloCluster.h:146
const FWEventItem * item() const
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:149
Color_t color() const
virtual void buildViewType(const reco::PFBlock &, unsigned int, TEveElement &, FWViewType::EType, const FWViewContext *)
virtual reco::TrackRef trackRef() const
virtual PFClusterRef clusterRef() const
TEveScalableStraightLineSet * buildRhoZClusterLineSet(const reco::PFCluster &, const FWViewContext *, float caloTransAngle, float r, float z)
double x() const
x coordinate of cluster centroid
Definition: CaloCluster.h:140
TEveStraightLineSet * setupLegoTrack(const reco::Track &)
double energy() const
cluster energy
Definition: PFCluster.h:73
virtual void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc)
float calculateEt(const TEveVector &cluster, float e)
virtual bool trackType(TrackType trType) const
double y() const
y coordinate of cluster centroid
Definition: CaloCluster.h:143
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:152
TEveTrack * setupRPZTrack(const reco::Track &)
bool getPlotEt() const
Definition: DDAxes.h:10
Block of elements.
Definition: PFBlock.h:30