CMS 3D CMS Logo

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 //
12 
13 // system include files
14 
15 // user include files
16 #include "TGeoTube.h"
17 #include "TEveJetCone.h"
18 #include "TEveGeoNode.h"
19 #include "TEveScalableStraightLineSet.h"
20 #include "TEveTrack.h"
21 
32 
34 
37 
38 
39 static const std::string kTauApexBeamSpot("Place Apex In BeamSpot");
41  m_minTheta(0),
42  m_maxTheta(0)
43 {
44 }
45 
47 {
48 }
49 
50 
53  if (iItem) {
54  iItem->getConfig()->assertParam(kTauApexBeamSpot, false);
55  }
56 
57 }
58 
59 void
61 {
62  // track
63  addLeadTrack( iTau, comp );
64  addConstituentTracks( iTau, comp );
65 
66  // projected markers
67  if (FWViewType::isProjected(type))
68  {
69  double phi = iTau.phi();
70  double theta = iTau.theta();
71  double size = 1;
72 
73  bool barrel = (theta< context().caloTransAngle() || theta > (TMath::Pi() - context().caloTransAngle()));
74  float ecalR = barrel ? context().caloR1() : context().caloR2();
75  float ecalZ = barrel ? context().caloZ1() : context().caloZ2();
76 
77  TEveScalableStraightLineSet* marker = new TEveScalableStraightLineSet( "energy" );
78 
79  if( type == FWViewType::kRhoZ )
80  {
81  double r(0);
82  ( theta < context().caloTransAngle() || M_PI-theta < context().caloTransAngle()) ?
83  r = ecalZ/fabs(cos(theta)) :
84  r = ecalR/sin(theta);
85 
86  fireworks::addRhoZEnergyProjection( this, comp, ecalR, ecalZ, m_minTheta-0.003, m_maxTheta+0.003, phi);
87 
88  marker->SetScaleCenter( 0., (phi>0 ? r*fabs(sin(theta)) : -r*fabs(sin(theta))), r*cos(theta) );
89  marker->AddLine(0., (phi>0 ? r*fabs(sin(theta)) : -r*fabs(sin(theta))), r*cos(theta),
90  0., (phi>0 ? (r+size)*fabs(sin(theta)) : -(r+size)*fabs(sin(theta))), (r+size)*cos(theta) );
91 
92  }
93  else
94  {
95  std::pair<double,double> phiRange = fireworks::getPhiRange( m_phis, phi );
96  double min_phi = phiRange.first-M_PI/36/2;
97  double max_phi = phiRange.second+M_PI/36/2;
98  if( fabs(phiRange.first-phiRange.first)<1e-3 ) {
99  min_phi = phi-M_PI/36/2;
100  max_phi = phi+M_PI/36/2;
101  }
102  TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
103  TGeoBBox *sc_box = new TGeoTubeSeg(ecalR - 1, ecalR + 1, 1, min_phi * 180 / M_PI, max_phi * 180 / M_PI);
104  TEveGeoShape *shape = fireworks::getShape( "spread", sc_box, item()->defaultDisplayProperties().color() );
105  shape->SetPickable(kTRUE);
106  setupAddElement( shape, comp );
107 
108  marker->SetScaleCenter(ecalR*cos(phi), ecalR*sin(phi), 0);
109  marker->AddLine( ecalR*cos( phi ), ecalR*sin( phi ), 0,
110  ( ecalR+size )*cos( phi ), ( ecalR+size )*sin( phi ), 0);
111  }
112  marker->SetLineWidth(4);
113  FWViewEnergyScale* caloScale = vc->getEnergyScale();
114  marker->SetScale(caloScale->getScaleFactor3D()*(caloScale->getPlotEt() ? iTau.et() : iTau.energy()));
115  setupAddElement( marker, comp );
116  m_lines.push_back(fireworks::scaleMarker(marker, iTau.et(), iTau.energy(), vc));
117 
118  context().voteMaxEtAndEnergy( iTau.et(), iTau.energy());
119  }
120  else if (iJet)
121  {
122  // jet
123  TEveJetCone* cone = fireworks::makeEveJetCone(*iJet, context());
124  if (item()->getConfig()->value<bool>(kTauApexBeamSpot))
125  {
126  FWBeamSpot* bs = context().getBeamSpot();
127  cone->SetApex(TEveVector(bs->x0(), bs->y0(), bs->z0()));
128  }
130  cone->SetFillColor(dp.color());
131  cone->SetLineColor(dp.color());
132  setupAddElement( cone, comp );
133  cone->SetMainTransparency(TMath::Min(100, 80 + dp.transparency() / 5));
134  }
135 }
136 
137 // Tracks which passed quality cuts and are inside a tracker signal cone around leading Track
138 void
139 FWTauProxyBuilderBase::addConstituentTracks( const reco::BaseTau &tau, class TEveElement* product )
140 {
141  for( reco::TrackRefVector::iterator i = tau.signalTracks().begin(), iEnd = tau.signalTracks().end();
142  i != iEnd; ++i ) {
143  TEveTrack* track( 0 );
144  if( i->isAvailable() ) {
145  track = fireworks::prepareTrack( **i, context().getTrackPropagator() );
146  track->MakeTrack();
147  setupAddElement( track, product );
148  }
149  }
150 }
151 
152 // Leading Track
153 void
154 FWTauProxyBuilderBase::addLeadTrack( const reco::BaseTau &tau, class TEveElement *product )
155 {
156  const reco::TrackRef leadTrack = tau.leadTrack();
157  if( !leadTrack ) return;
158 
159  TEveTrack* track = fireworks::prepareTrack( *leadTrack, context().getTrackPropagator() );
160  if( track )
161  {
162  track->MakeTrack();
163  setupAddElement( track, product );
164  }
165 }
166 
167 void
168 FWTauProxyBuilderBase::localModelChanges(const FWModelId& iId, TEveElement* iCompound,
169  FWViewType::EType viewType, const FWViewContext* vc)
170 {
171  if (FWViewType::isProjected(viewType))
172  increaseComponentTransparency(iId.index(), iCompound, "TEveJetCone", 80);
173 }
174 
175 void
177 {
178  if (FWViewType::isProjected(viewType))
179  {
180  typedef std::vector<fireworks::scaleMarker> Lines_t;
181  FWViewEnergyScale* caloScale = vc->getEnergyScale();
182  // printf("%p -> %f\n", this,caloScale->getValToHeight() );
183  for (Lines_t::iterator i = m_lines.begin(); i!= m_lines.end(); ++ i)
184  {
185  if (vc == (*i).m_vc)
186  {
187  float value = caloScale->getPlotEt() ? (*i).m_et : (*i).m_energy;
188  (*i).m_ls->SetScale(caloScale->getScaleFactor3D()*value);
189  TEveProjected* proj = *(*i).m_ls->BeginProjecteds();
190  proj->UpdateProjection();
191  }
192  }
193  }
194 }
195 
196 void
198 {
199  m_lines.clear();
200 }
size
Write out results.
const double Pi
type
Definition: HCALResponse.h:21
const fireworks::Context & context() const
virtual reco::TrackRef leadTrack() const
Definition: BaseTau.cc:26
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:169
float getScaleFactor3D() const
const FWDisplayProperties & defaultDisplayProperties() const
Definition: FWEventItem.cc:453
std::pair< double, double > getPhiRange(const std::vector< double > &phis, double phi)
Definition: BuilderUtils.cc:21
double x0() const
Definition: FWBeamSpot.cc:30
static float caloTransAngle()
Definition: Context.cc:233
TEveTrack * prepareTrack(const reco::Track &track, TEveTrackPropagator *propagator, const std::vector< TEveVector > &extraRefPoints=std::vector< TEveVector >())
Definition: TrackUtils.cc:69
double z0() const
Definition: FWBeamSpot.cc:40
void addLeadTrack(const reco::BaseTau &tau, class TEveElement *product)
double y0() const
Definition: FWBeamSpot.cc:35
Base class for all types of Jets.
Definition: Jet.h:20
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:183
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:223
T Min(T a, T b)
Definition: MathUtil.h:39
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:253
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:248
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)
virtual double phi() const final
momentum azimuthal angle
static bool isProjected(int)
Definition: FWViewType.cc:128
virtual double et() const final
transverse energy
virtual void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc)
virtual double theta() const final
momentum polar angle
Char_t transparency() const
FWBeamSpot * getBeamSpot() const
Definition: Context.h:78
static float caloR2(bool offset=true)
Definition: Context.cc:213
int index() const
Definition: FWModelId.h:49
static const std::string kTauApexBeamSpot("Place Apex In BeamSpot")
virtual void setItem(const FWEventItem *iItem)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
virtual double energy() const final
energy
static float caloR1(bool offset=true)
Definition: Context.cc:208
Definition: value.py:1
virtual const reco::TrackRefVector & signalTracks() const
Definition: BaseTau.cc:28
#define M_PI
FWGenericParameter< T > * assertParam(const std::string &name, T def)
void addRhoZEnergyProjection(FWProxyBuilderBase *, TEveElement *, double r_ecal, double z_ecal, double theta_min, double theta_max, double phi)
Definition: BuilderUtils.cc:60
auto dp
Definition: deltaR.h:22
static float caloZ1(bool offset=true)
Definition: Context.cc:218
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
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
virtual void setItem(const FWEventItem *iItem)