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 "TEveGeoShape.h"
20 #include "TEveScalableStraightLineSet.h"
21 #include "TEveTrack.h"
22 
33 
35 
38 
39 static const std::string kTauApexBeamSpot("Place Apex In BeamSpot");
40 FWTauProxyBuilderBase::FWTauProxyBuilderBase() : m_minTheta(0), m_maxTheta(0) {}
41 
43 
46  if (iItem) {
47  iItem->getConfig()->assertParam(kTauApexBeamSpot, false);
48  }
49 }
50 
52  const reco::Jet* iJet,
53  TEveElement* comp,
55  const FWViewContext* vc) {
56  // track
57  addLeadTrack(iTau, comp);
59 
60  // projected markers
62  double phi = iTau.phi();
63  double theta = iTau.theta();
64  double size = 1;
65 
67  float ecalR = barrel ? context().caloR1() : context().caloR2();
68  float ecalZ = barrel ? context().caloZ1() : context().caloZ2();
69 
70  TEveScalableStraightLineSet* marker = new TEveScalableStraightLineSet("energy");
71 
72  if (type == FWViewType::kRhoZ) {
73  double r(0);
74  (theta < context().caloTransAngle() || M_PI - theta < context().caloTransAngle()) ? r = ecalZ / fabs(cos(theta))
75  : r = ecalR / sin(theta);
76 
77  fireworks::addRhoZEnergyProjection(this, comp, ecalR, ecalZ, m_minTheta - 0.003, m_maxTheta + 0.003, phi);
78 
79  marker->SetScaleCenter(0., (phi > 0 ? r * fabs(sin(theta)) : -r * fabs(sin(theta))), r * cos(theta));
80  marker->AddLine(0.,
81  (phi > 0 ? r * fabs(sin(theta)) : -r * fabs(sin(theta))),
82  r * cos(theta),
83  0.,
84  (phi > 0 ? (r + size) * fabs(sin(theta)) : -(r + size) * fabs(sin(theta))),
85  (r + size) * cos(theta));
86 
87  } else {
88  std::pair<double, double> phiRange = fireworks::getPhiRange(m_phis, phi);
89  double min_phi = phiRange.first - M_PI / 36 / 2;
90  double max_phi = phiRange.second + M_PI / 36 / 2;
91  TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
92  TGeoBBox* sc_box = new TGeoTubeSeg(ecalR - 1, ecalR + 1, 1, min_phi * 180 / M_PI, max_phi * 180 / M_PI);
93  TEveGeoShape* shape = fireworks::getShape("spread", sc_box, item()->defaultDisplayProperties().color());
94  shape->SetPickable(kTRUE);
96 
97  marker->SetScaleCenter(ecalR * cos(phi), ecalR * sin(phi), 0);
98  marker->AddLine(ecalR * cos(phi), ecalR * sin(phi), 0, (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 
105  context().voteMaxEtAndEnergy(iTau.et(), iTau.energy());
106  } else if (iJet) {
107  // jet
108  TEveJetCone* cone = fireworks::makeEveJetCone(*iJet, context());
109  if (item()->getConfig()->value<bool>(kTauApexBeamSpot)) {
111  cone->SetApex(TEveVector(bs->x0(), bs->y0(), bs->z0()));
112  }
114  cone->SetFillColor(dp.color());
115  cone->SetLineColor(dp.color());
117  cone->SetMainTransparency(TMath::Min(100, 80 + dp.transparency() / 5));
118  }
119 }
120 
121 // Tracks which passed quality cuts and are inside a tracker signal cone around leading Track
122 void FWTauProxyBuilderBase::addConstituentTracks(const reco::BaseTau& tau, class TEveElement* product) {
123  for (reco::TrackRefVector::iterator i = tau.signalTracks().begin(), iEnd = tau.signalTracks().end(); i != iEnd; ++i) {
124  TEveTrack* track(nullptr);
125  if (i->isAvailable()) {
126  track = fireworks::prepareTrack(**i, context().getTrackPropagator());
127  track->MakeTrack();
128  setupAddElement(track, product);
129  }
130  }
131 }
132 
133 // Leading Track
134 void FWTauProxyBuilderBase::addLeadTrack(const reco::BaseTau& tau, class TEveElement* product) {
135  const reco::TrackRef leadTrack = tau.leadTrack();
136  if (!leadTrack)
137  return;
138 
139  TEveTrack* track = fireworks::prepareTrack(*leadTrack, context().getTrackPropagator());
140  if (track) {
141  track->MakeTrack();
142  setupAddElement(track, product);
143  }
144 }
145 
147  TEveElement* iCompound,
148  FWViewType::EType viewType,
149  const FWViewContext* vc) {
150  if (FWViewType::isProjected(viewType))
151  increaseComponentTransparency(iId.index(), iCompound, "TEveJetCone", 80);
152 }
153 
154 void FWTauProxyBuilderBase::scaleProduct(TEveElementList* product,
155  FWViewType::EType viewType,
156  const FWViewContext* vc) {
157  int idx = 0;
158  for (auto& c : product->RefChildren()) {
159  // check the compound has more than one element (the first one is jet)
160  for (auto& compChld : c->RefChildren()) {
161  TEveScalableStraightLineSet* lineSet = dynamic_cast<TEveScalableStraightLineSet*>(compChld);
162  if (lineSet) {
163  // compund index in the product is an index of model data in the collection
164  const void* modelData = item()->modelData(idx);
165  const reco::BaseTau* ptr = (const reco::BaseTau*)(modelData);
166  float value = vc->getEnergyScale()->getPlotEt() ? ptr->et() : ptr->energy();
167  lineSet->SetScale(vc->getEnergyScale()->getScaleFactor3D() * value);
168  for (TEveProjectable::ProjList_i j = lineSet->BeginProjecteds(); j != lineSet->EndProjecteds(); ++j) {
169  (*j)->UpdateProjection();
170  }
171  }
172  }
173  idx++;
174  }
175 }
176 
size
Write out results.
const double Pi
void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc) override
const void * modelData(int iIndex) const
Definition: FWEventItem.cc:466
std::pair< double, double > getPhiRange(const std::vector< double > &phis, double phi)
Definition: BuilderUtils.cc:21
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
static float caloTransAngle()
Definition: Context.cc:196
TEveTrack * prepareTrack(const reco::Track &track, TEveTrackPropagator *propagator, const std::vector< TEveVector > &extraRefPoints=std::vector< TEveVector >())
Definition: TrackUtils.cc:62
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:150
void addLeadTrack(const reco::BaseTau &tau, class TEveElement *product)
Base class for all types of Jets.
Definition: Jet.h:20
FWBeamSpot * getBeamSpot() const
Definition: Context.h:67
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
void setItem(const FWEventItem *iItem) override
static float caloZ2(bool offset=true)
Definition: Context.cc:192
int index() const
Definition: FWModelId.h:41
const fireworks::Context & context() const
bool getPlotEt() 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)
FWViewEnergyScale * getEnergyScale() const
static bool isProjected(int)
Definition: FWViewType.cc:100
double theta() const final
momentum polar angle
static float caloR2(bool offset=true)
Definition: Context.cc:189
void localModelChanges(const FWModelId &iId, TEveElement *iCompound, FWViewType::EType viewType, const FWViewContext *vc) override
static const std::string kTauApexBeamSpot("Place Apex In BeamSpot")
const FWDisplayProperties & defaultDisplayProperties() const
Definition: FWEventItem.cc:403
virtual void setItem(const FWEventItem *iItem)
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:169
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static float caloR1(bool offset=true)
Definition: Context.cc:187
Definition: value.py:1
#define M_PI
FWGenericParameter< T > * assertParam(const std::string &name, T def)
float getScaleFactor3D() const
void addRhoZEnergyProjection(FWProxyBuilderBase *, TEveElement *, double r_ecal, double z_ecal, double theta_min, double theta_max, double phi)
Definition: BuilderUtils.cc:58
double et() const final
transverse energy
static float caloZ1(bool offset=true)
Definition: Context.cc:190
std::vector< double > m_phis
TEveGeoShape * getShape(const char *name, TGeoBBox *shape, Color_t color)
Definition: BuilderUtils.cc:44
double phi() const final
momentum azimuthal angle
const FWEventItem * item() const
void increaseComponentTransparency(unsigned int index, TEveElement *holder, const std::string &name, Char_t transpOffset)
TEveJetCone * makeEveJetCone(const reco::Jet &iData, const fireworks::Context &context)
double energy() const final
energy