CMS 3D CMS Logo

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