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.
3 
4 //______________________________________________________________________________
5 void
7 {
8  typedef std::vector<ScalableLines> Lines_t;
9  FWViewEnergyScale *caloScale = vc->getEnergyScale();
10 
11  if( viewType == FWViewType::kRhoPhiPF || viewType == FWViewType::kRhoZ )
12  { /* Handle the rhophi and rhoz cluster scaling */
13  for( Lines_t::iterator i = m_clusters.begin(); i != m_clusters.end(); ++i )
14  {
15  if( vc == (*i).m_vc )
16  {
17  float value = caloScale->getPlotEt() ? (*i).m_et : (*i).m_energy;
18  (*i).m_ls->SetScale( caloScale->getScaleFactor3D() * value );
19  TEveProjected *proj = *(*i).m_ls->BeginProjecteds();
20  proj->UpdateProjection();
21  }
22  }
23  } /* Handle cluster scaling in lego view(s) */
24  else if( viewType == FWViewType::kLego || viewType == FWViewType::kLegoPFECAL )
25  { // Loop products
26  for( TEveElement::List_i i = parent->BeginChildren(); i != parent->EndChildren(); ++i )
27  {
28  if( (*i)->HasChildren() )
29  { // Loop elements of block
30  for( TEveElement::List_i j = (*i)->BeginChildren(); j != (*i)->EndChildren(); ++j )
31  {
32  if( strcmp( (*j)->GetElementName(), "BlockCluster" ) == 0 )
33  {
34  FWLegoCandidate *cluster = dynamic_cast<FWLegoCandidate*>( *j );
35  cluster->updateScale( vc, context() );
36  }
37  }
38  }
39  }
40  }
41 }
42 
43 //______________________________________________________________________________
44 void
46  TEveElement &oItemHolder, const FWViewContext *vc, FWViewType::EType viewType )
47 {
48  if( blockElement.trackType( reco::PFBlockElement::DEFAULT ) )
49  {
50  reco::Track track = *blockElement.trackRef();
51  FWPFTrackUtils *trackUtils = new FWPFTrackUtils();
52 
53  if( viewType == FWViewType::kLego || viewType == FWViewType::kLegoPFECAL ) // Lego views
54  {
55  TEveStraightLineSet *legoTrack = trackUtils->setupLegoTrack( track );
56  setupAddElement( legoTrack, &oItemHolder );
57  }
58  else if( viewType == FWViewType::kRhoPhiPF ) // RhoPhi view
59  {
60  TEveTrack *trk = trackUtils->setupTrack( track );
61  TEvePointSet *ps = trackUtils->getCollisionMarkers( trk );
62  setupAddElement( trk, &oItemHolder );
63  if( ps->GetN() != 0 )
64  setupAddElement( ps, &oItemHolder );
65  else
66  delete ps;
67  }
68  else if ( viewType == FWViewType::kRhoZ ) // RhoZ view
69  {
70  TEveTrack *trk = trackUtils->setupTrack( track );
71  TEvePointSet *markers = trackUtils->getCollisionMarkers( trk );
72  TEvePointSet *ps = new TEvePointSet();
73  setupAddElement( trk, &oItemHolder );
74 
75  Float_t *trackPoints = trk->GetP();
76  unsigned int last = ( trk->GetN() - 1 ) * 3;
77  float y = trackPoints[last+1];
78  float z = trackPoints[last+2];
79 
80  // Reposition any points that have been translated in RhoZ
81  for( signed int i = 0; i < markers->GetN(); ++i )
82  {
83  Float_t a,b,c;
84  markers->GetPoint( i, a, b, c );
85 
86  if( y < 0 && b > 0 )
87  b *= -1;
88  else if( y > 0 && b < 0 )
89  b *= -1;
90 
91  if( z < 0 && c > 0 )
92  c *= -1;
93  else if( z > 0 && c < 0 )
94  c *= -1;
95 
96  ps->SetNextPoint( a, b, c );
97  }
98 
99  if( ps->GetN() != 0 )
100  setupAddElement( ps, &oItemHolder );
101  else
102  delete ps;
103  delete markers;
104  }
105 
106  delete trackUtils;
107  }
108 }
109 
110 //______________________________________________________________________________
111 void
112 FWPFBlockProxyBuilder::setupClusterElement( const reco::PFBlockElement &blockElement, TEveElement &oItemHolder,
113  const FWViewContext *vc, FWViewType::EType viewType, float r )
114 {
115  // Get reference to PFCluster
116  reco::PFCluster cluster = *blockElement.clusterRef();
117  TEveVector centre = TEveVector( cluster.x(), cluster.y(), cluster.z() );
118  float energy = cluster.energy();
119  float et = FWPFMaths::calculateEt( centre, energy );
120  float pt = et;
121  float eta = cluster.eta();
122  float phi = cluster.phi();
123 
125 
126  if( viewType == FWViewType::kLego || viewType == FWViewType::kLegoPFECAL )
127  {
128  FWLegoCandidate *legoCluster = new FWLegoCandidate( vc, FWProxyBuilderBase::context(), energy, et, pt, eta, phi );
129  legoCluster->SetMarkerColor( FWProxyBuilderBase::item()->defaultDisplayProperties().color() );
130  legoCluster->SetElementName( "BlockCluster" );
131  setupAddElement( legoCluster, &oItemHolder );
132  }
133  if( viewType == FWViewType::kRhoPhiPF )
134  {
136  FWPFClusterRPZUtils *clusterUtils = new FWPFClusterRPZUtils();
137  TEveScalableStraightLineSet *rpCluster = clusterUtils->buildRhoPhiClusterLineSet( cluster, vc, energy, et, r );
138  rpCluster->SetLineColor( dp.color() );
139  m_clusters.push_back( ScalableLines( rpCluster, et, energy, vc ) );
140  setupAddElement( rpCluster, &oItemHolder );
141  delete clusterUtils;
142  }
143  else if( viewType == FWViewType::kRhoZ )
144  {
146  FWPFClusterRPZUtils *clusterUtils = new FWPFClusterRPZUtils();
147  TEveScalableStraightLineSet *rzCluster = clusterUtils->buildRhoZClusterLineSet( cluster, vc, context().caloTransAngle(),
148  energy, et, r, context().caloZ1() );
149  rzCluster->SetLineColor( dp.color() );
150  m_clusters.push_back( ScalableLines( rzCluster, et, energy, vc ) );
151  setupAddElement( rzCluster, &oItemHolder );
152  delete clusterUtils;
153  }
154 }
155 
156 //______________________________________________________________________________
157 void
158 FWPFBlockProxyBuilder::buildViewType( const reco::PFBlock &iData, unsigned int iIndex, TEveElement &oItemHolder,
159  FWViewType::EType viewType, const FWViewContext *vc )
160 {
162 
163  for( unsigned int i = 0; i < elements.size(); ++i )
164  {
165  reco::PFBlockElement::Type type = elements[i].type();
166  switch( type )
167  {
168  case 1: // TRACK
169  if( e_builderType == BASE )
170  setupTrackElement( elements[i], oItemHolder, vc, viewType );
171  break;
172 
173  case 4: // ECAL
174  if( e_builderType == ECAL )
175  setupClusterElement( elements[i], oItemHolder, vc, viewType, FWPFGeom::caloR1() );
176  break;
177 
178  case 5: // HCAL
179  if( e_builderType == HCAL )
180  {
181  if( viewType == FWViewType::kRhoPhiPF )
182  setupClusterElement( elements[i], oItemHolder, vc, viewType, FWPFGeom::caloR2() );
183  else // RhoZ
184  setupClusterElement( elements[i], oItemHolder, vc, viewType, context().caloR1() );
185  }
186  break;
187 
188  default: // Ignore anything that isn't wanted
189  break;
190  }
191  }
192 }
193 
194 //______________________________________________________________________________
type
Definition: HCALResponse.h:21
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:451
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:47
TEvePointSet * getCollisionMarkers(const TEveTrack *)
TEveTrack * setupTrack(const reco::Track &)
virtual const PFClusterRef & clusterRef() const
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:184
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
size_type size() const
Definition: OwnVector.h:254
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
T eta() const
TEveScalableStraightLineSet * buildRhoPhiClusterLineSet(const reco::PFCluster &, const FWViewContext *, float r)
double z() const
z coordinate of cluster centroid
Definition: CaloCluster.h:160
float float float z
const FWEventItem * item() const
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:163
Color_t color() const
float caloR1()
Definition: FWPFGeom.h:21
virtual void buildViewType(const reco::PFBlock &, unsigned int, TEveElement &, FWViewType::EType, const FWViewContext *)
int j
Definition: DBlmapReader.cc:9
TEveScalableStraightLineSet * buildRhoZClusterLineSet(const reco::PFCluster &, const FWViewContext *, float caloTransAngle, float r, float z)
double x() const
x coordinate of cluster centroid
Definition: CaloCluster.h:154
float caloR2()
Definition: FWPFGeom.h:25
TEveStraightLineSet * setupLegoTrack(const reco::Track &)
float calculateEt(const TEveVector &centre, float e)
Definition: FWPFMaths.cc:115
double energy() const
cluster energy
Definition: PFCluster.h:82
virtual void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc)
float caloZ1()
Definition: FWPFGeom.h:22
void updateScale(const FWViewContext *vc, const fireworks::Context &)
double b
Definition: hdecay.h:120
virtual bool trackType(TrackType trType) const
double a
Definition: hdecay.h:121
double y() const
y coordinate of cluster centroid
Definition: CaloCluster.h:157
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:166
virtual const reco::TrackRef & trackRef() const
bool getPlotEt() const
Definition: DDAxes.h:10
Block of elements.
Definition: PFBlock.h:30