CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWTauProxyBuilderBase.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Calo
4 // Class : FWTauProxyBuilderBase
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Alja Mrak-Tadel
10 // Created: Thu Oct 21 20:40:28 CEST 2010
11 // $Id: FWTauProxyBuilderBase.cc,v 1.5 2012/03/23 00:08:29 amraktad Exp $
12 //
13 
14 // system include files
15 
16 // user include files
17 #include "TGeoTube.h"
18 #include "TEveJetCone.h"
19 #include "TEveGeoNode.h"
20 #include "TEveScalableStraightLineSet.h"
21 #include "TEveTrack.h"
22 
30 
32 
35 
36 
38  m_minTheta(0),
39  m_maxTheta(0)
40 {
41 }
42 
44 {
45 }
46 
47 void
48 FWTauProxyBuilderBase::buildBaseTau( const reco::BaseTau& iTau, const reco::Jet* iJet, TEveElement* comp, FWViewType::EType type, const FWViewContext* vc)
49 {
50  // track
51  addLeadTrack( iTau, comp );
52  addConstituentTracks( iTau, comp );
53 
54  // projected markers
55  if (FWViewType::isProjected(type))
56  {
57  double phi = iTau.phi();
58  double theta = iTau.theta();
59  double size = 1;
60 
61  bool barrel = (theta< context().caloTransAngle() || theta > (TMath::Pi() - context().caloTransAngle()));
62  float ecalR = barrel ? context().caloR1() : context().caloR2();
63  float ecalZ = barrel ? context().caloZ1() : context().caloZ2();
64 
65  TEveScalableStraightLineSet* marker = new TEveScalableStraightLineSet( "energy" );
66 
67  if( type == FWViewType::kRhoZ )
68  {
69  double r(0);
70  ( theta < context().caloTransAngle() || M_PI-theta < context().caloTransAngle()) ?
71  r = ecalZ/fabs(cos(theta)) :
72  r = ecalR/sin(theta);
73 
74  fireworks::addRhoZEnergyProjection( this, comp, ecalR, ecalZ, m_minTheta-0.003, m_maxTheta+0.003, phi);
75 
76  marker->SetScaleCenter( 0., (phi>0 ? r*fabs(sin(theta)) : -r*fabs(sin(theta))), r*cos(theta) );
77  marker->AddLine(0., (phi>0 ? r*fabs(sin(theta)) : -r*fabs(sin(theta))), r*cos(theta),
78  0., (phi>0 ? (r+size)*fabs(sin(theta)) : -(r+size)*fabs(sin(theta))), (r+size)*cos(theta) );
79 
80  }
81  else
82  {
83  std::pair<double,double> phiRange = fireworks::getPhiRange( m_phis, phi );
84  double min_phi = phiRange.first-M_PI/36/2;
85  double max_phi = phiRange.second+M_PI/36/2;
86  if( fabs(phiRange.first-phiRange.first)<1e-3 ) {
87  min_phi = phi-M_PI/36/2;
88  max_phi = phi+M_PI/36/2;
89  }
90  TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
91  TGeoBBox *sc_box = new TGeoTubeSeg(ecalR - 1, ecalR + 1, 1, min_phi * 180 / M_PI, max_phi * 180 / M_PI);
92  TEveGeoShape *shape = fireworks::getShape( "spread", sc_box, item()->defaultDisplayProperties().color() );
93  shape->SetPickable(kTRUE);
94  setupAddElement( shape, comp );
95 
96  marker->SetScaleCenter(ecalR*cos(phi), ecalR*sin(phi), 0);
97  marker->AddLine( ecalR*cos( phi ), ecalR*sin( phi ), 0,
98  ( ecalR+size )*cos( phi ), ( ecalR+size )*sin( phi ), 0);
99  }
100  marker->SetLineWidth(4);
101  FWViewEnergyScale* caloScale = vc->getEnergyScale();
102  marker->SetScale(caloScale->getScaleFactor3D()*(caloScale->getPlotEt() ? iTau.et() : iTau.energy()));
103  setupAddElement( marker, comp );
104  m_lines.push_back(fireworks::scaleMarker(marker, iTau.et(), iTau.energy(), vc));
105 
106  context().voteMaxEtAndEnergy( iTau.et(), iTau.energy());
107  }
108  else if (iJet)
109  {
110  // jet
111  TEveJetCone* cone = fireworks::makeEveJetCone(*iJet, context());
113  cone->SetFillColor(dp.color());
114  cone->SetLineColor(dp.color());
115  setupAddElement( cone, comp );
116  cone->SetMainTransparency(TMath::Min(100, 80 + dp.transparency() / 5));
117  }
118 }
119 
120 // Tracks which passed quality cuts and are inside a tracker signal cone around leading Track
121 void
122 FWTauProxyBuilderBase::addConstituentTracks( const reco::BaseTau &tau, class TEveElement* product )
123 {
124  for( reco::TrackRefVector::iterator i = tau.signalTracks().begin(), iEnd = tau.signalTracks().end();
125  i != iEnd; ++i ) {
126  TEveTrack* track( 0 );
127  if( i->isAvailable() ) {
128  track = fireworks::prepareTrack( **i, context().getTrackPropagator() );
129  track->MakeTrack();
130  setupAddElement( track, product );
131  }
132  }
133 }
134 
135 // Leading Track
136 void
137 FWTauProxyBuilderBase::addLeadTrack( const reco::BaseTau &tau, class TEveElement *product )
138 {
139  const reco::TrackRef leadTrack = tau.leadTrack();
140  if( !leadTrack ) return;
141 
142  TEveTrack* track = fireworks::prepareTrack( *leadTrack, context().getTrackPropagator() );
143  if( track )
144  {
145  track->MakeTrack();
146  setupAddElement( track, product );
147  }
148 }
149 
150 void
151 FWTauProxyBuilderBase::localModelChanges(const FWModelId& iId, TEveElement* iCompound,
152  FWViewType::EType viewType, const FWViewContext* vc)
153 {
154  if (FWViewType::isProjected(viewType))
155  increaseComponentTransparency(iId.index(), iCompound, "TEveJetCone", 80);
156 }
157 
158 void
160 {
161  if (FWViewType::isProjected(viewType))
162  {
163  typedef std::vector<fireworks::scaleMarker> Lines_t;
164  FWViewEnergyScale* caloScale = vc->getEnergyScale();
165  // printf("%p -> %f\n", this,caloScale->getValToHeight() );
166  for (Lines_t::iterator i = m_lines.begin(); i!= m_lines.end(); ++ i)
167  {
168  if (vc == (*i).m_vc)
169  {
170  float value = caloScale->getPlotEt() ? (*i).m_et : (*i).m_energy;
171  (*i).m_ls->SetScale(caloScale->getScaleFactor3D()*value);
172  TEveProjected* proj = *(*i).m_ls->BeginProjecteds();
173  proj->UpdateProjection();
174  }
175  }
176  }
177 }
178 
179 void
181 {
182  m_lines.clear();
183 }
const double Pi
type
Definition: HCALResponse.h:22
const fireworks::Context & context() const
virtual reco::TrackRef leadTrack() const
Definition: BaseTau.cc:26
float getScaleFactor3D() const
int i
Definition: DBlmapReader.cc:9
const FWDisplayProperties & defaultDisplayProperties() const
Definition: FWEventItem.cc:451
std::pair< double, double > getPhiRange(const std::vector< double > &phis, double phi)
Definition: BuilderUtils.cc:21
list parent
Definition: dbtoconf.py:74
virtual double et() const
transverse energy
static float caloTransAngle()
Definition: Context.cc:235
TEveTrack * prepareTrack(const reco::Track &track, TEveTrackPropagator *propagator, const std::vector< TEveVector > &extraRefPoints=std::vector< TEveVector >())
Definition: TrackUtils.cc:70
void addLeadTrack(const reco::BaseTau &tau, class TEveElement *product)
Base class for all types of Jets.
Definition: Jet.h:21
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:185
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
FWViewEnergyScale * getEnergyScale() const
virtual void localModelChanges(const FWModelId &iId, TEveElement *iCompound, FWViewType::EType viewType, const FWViewContext *vc)
Geom::Theta< T > theta() const
static float caloZ2(bool offset=true)
Definition: Context.cc:225
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
const FWEventItem * item() const
Color_t color() const
void addConstituentTracks(const reco::BaseTau &tau, class TEveElement *product)
void buildBaseTau(const reco::BaseTau &iTau, const reco::Jet *iJet, TEveElement *comp, FWViewType::EType type, const FWViewContext *vc)
static bool isProjected(int)
Definition: FWViewType.cc:129
virtual void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc)
virtual double energy() const
energy
Char_t transparency() const
static float caloR2(bool offset=true)
Definition: Context.cc:215
int index() const
Definition: FWModelId.h:50
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static float caloR1(bool offset=true)
Definition: Context.cc:210
virtual const reco::TrackRefVector & signalTracks() const
Definition: BaseTau.cc:28
virtual double theta() const
momentum polar angle
void addRhoZEnergyProjection(FWProxyBuilderBase *, TEveElement *, double r_ecal, double z_ecal, double theta_min, double theta_max, double phi)
Definition: BuilderUtils.cc:60
#define M_PI
Definition: BFit3D.cc:3
static float caloZ1(bool offset=true)
Definition: Context.cc:220
std::vector< double > m_phis
TEveGeoShape * getShape(const char *name, TGeoBBox *shape, Color_t color)
Definition: BuilderUtils.cc:42
std::vector< fireworks::scaleMarker > m_lines
virtual double phi() const
momentum azimuthal angle
tuple size
Write out results.
void increaseComponentTransparency(unsigned int index, TEveElement *holder, const std::string &name, Char_t transpOffset)
TEveJetCone * makeEveJetCone(const reco::Jet &iData, const fireworks::Context &context)
bool getPlotEt() const
Definition: DDAxes.h:10