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