CMS 3D CMS Logo

FWJetProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Calo
4 // Class : FWJetProxyBuilder
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Tue Dec 2 14:17:03 EST 2008
11 //
12 
13 #include "TEveJetCone.h"
14 #include "TEveScalableStraightLineSet.h"
15 
21 // user include files
29 
31 
32 namespace fireworks {
33 
34  struct jetScaleMarker : public scaleMarker {
35  jetScaleMarker(TEveScalableStraightLineSet* ls, float et, float e, const FWViewContext* vc)
36  : scaleMarker(ls, et, e, vc), m_text(nullptr) {}
37 
39  };
40 } // namespace fireworks
41 
42 static const std::string kJetLabelsRhoPhiOn("Draw Labels in RhoPhi View");
43 static const std::string kJetLabelsRhoZOn("Draw Labels in RhoZ View");
44 static const std::string kJetOffset("Label Offset");
45 static const std::string kJetApexBeamSpot("Place Apex In BeamSpot");
46 
48 public:
50  ~FWJetProxyBuilder() override;
51 
52  bool havePerViewProduct(FWViewType::EType) const override { return true; }
53  bool haveSingleProduct() const override { return false; } // different view types
54  void cleanLocal() override;
55 
56  void setItem(const FWEventItem* iItem) override {
58  if (iItem) {
59  iItem->getConfig()->assertParam(kJetLabelsRhoPhiOn, false);
60  iItem->getConfig()->assertParam(kJetLabelsRhoZOn, false);
61  iItem->getConfig()->assertParam(kJetOffset, 2.1, 1.0, 5.0);
62  }
63  }
64 
66 
67 protected:
69  void buildViewType(const reco::Jet& iData,
70  unsigned int iIndex,
71  TEveElement& oItemHolder,
73  const FWViewContext*) override;
74 
75  void localModelChanges(const FWModelId& iId,
76  TEveElement* iCompound,
77  FWViewType::EType viewType,
78  const FWViewContext* vc) override;
79 
80  void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc) override;
81 
82 private:
83  typedef std::vector<fireworks::jetScaleMarker> Lines_t;
84 
85  FWJetProxyBuilder(const FWJetProxyBuilder&) = delete; // stop default
86  const FWJetProxyBuilder& operator=(const FWJetProxyBuilder&) = delete; // stop default
87 
88  TEveElementList* requestCommon();
90 
91  TEveElementList* m_common;
92 };
93 
94 //______________________________________________________________________________
95 FWJetProxyBuilder::FWJetProxyBuilder() : m_common(nullptr) {
96  m_common = new TEveElementList("common electron scene");
97  m_common->IncDenyDestroy();
98 }
99 
101 
103  if (m_common->HasChildren() == false) {
104  for (int i = 0; i < static_cast<int>(item()->size()); ++i) {
105  TEveJetCone* cone = fireworks::makeEveJetCone(modelData(i), context());
106 
107  cone->SetFillColor(item()->defaultDisplayProperties().color());
108  cone->SetLineColor(item()->defaultDisplayProperties().color());
109 
110  m_common->AddElement(cone);
111  }
112  }
113  return m_common;
114 }
115 
117  unsigned int iIndex,
118  TEveElement& oItemHolder,
120  const FWViewContext* vc) {
121  // add cone from shared pool
122  TEveElementList* cones = requestCommon();
123  TEveElement::List_i coneIt = cones->BeginChildren();
124  std::advance(coneIt, iIndex);
125 
127  setupAddElement(*coneIt, &oItemHolder);
128  (*coneIt)->SetMainTransparency(TMath::Min(100, 80 + dp.transparency() / 5));
129 
130  TEveVector p1;
131  TEveVector p2;
132 
133  // scale markers in projected views
135  fireworks::jetScaleMarker markers(new TEveScalableStraightLineSet("jetline"), iData.et(), iData.energy(), vc);
136 
137  float size = 1.f; // values are saved in scale
138  double theta = iData.theta();
139  double phi = iData.phi();
140 
141  if (type == FWViewType::kRhoZ) {
142  static const float_t offr = 4;
143  float r_ecal = context().caloR1() + offr;
144  float z_ecal = context().caloZ1() + offr / tan(context().caloTransAngle());
145  double r(0);
146  if (theta < context().caloTransAngle() || M_PI - theta < context().caloTransAngle()) {
147  z_ecal = context().caloZ2() + offr / tan(context().caloTransAngle());
148  r = z_ecal / fabs(cos(theta));
149  } else {
150  r = r_ecal / sin(theta);
151  }
152 
153  p1.Set(0., (phi > 0 ? r * fabs(sin(theta)) : -r * fabs(sin(theta))), r * cos(theta));
154  p2.Set(0., (phi > 0 ? (r + size) * fabs(sin(theta)) : -(r + size) * fabs(sin(theta))), (r + size) * cos(theta));
155  } else {
156  float ecalR = context().caloR1() + 4;
157  p1.Set(ecalR * cos(phi), ecalR * sin(phi), 0);
158  p2.Set((ecalR + size) * cos(phi), (ecalR + size) * sin(phi), 0);
159  }
160 
161  markers.m_ls->SetScaleCenter(p1.fX, p1.fY, p1.fZ);
162  markers.m_ls->AddLine(p1, p2);
163 
164  markers.m_ls->SetLineWidth(4);
165  markers.m_ls->SetLineColor(dp.color());
166  FWViewEnergyScale* caloScale = vc->getEnergyScale();
167  markers.m_ls->SetScale(caloScale->getScaleFactor3D() * (caloScale->getPlotEt() ? iData.et() : iData.energy()));
168 
169  if ((type == FWViewType::kRhoZ && item()->getConfig()->value<bool>(kJetLabelsRhoZOn)) ||
171  markers.m_text = new FWEveText(Form("%.1f", vc->getEnergyScale()->getPlotEt() ? iData.et() : iData.energy()));
172  markers.m_text->SetMainColor(item()->defaultDisplayProperties().color());
173  setTextPos(markers, vc, type);
174  }
175 
176  markers.m_ls->SetMarkerColor(markers.m_ls->GetMainColor());
177  setupAddElement(markers.m_ls, &oItemHolder);
178  if (markers.m_text)
179  setupAddElement(markers.m_text, &oItemHolder, false);
180  }
181  context().voteMaxEtAndEnergy(iData.et(), iData.energy());
182 }
183 
185  TEveElement* iCompound,
186  FWViewType::EType viewType,
187  const FWViewContext* vc) {
188  increaseComponentTransparency(iId.index(), iCompound, "TEveJetCone", 80);
189 }
190 
191 void FWJetProxyBuilder::cleanLocal() { m_common->DestroyElements(); }
192 
193 void FWJetProxyBuilder::scaleProduct(TEveElementList* product, FWViewType::EType viewType, const FWViewContext* vc) {
194  // move jets to eventCenter
196  TEveVector cv;
197  contextGl->commonPrefs()->getEventCenter(cv.Arr());
198  for (TEveElement::List_i i = m_common->BeginChildren(); i != m_common->EndChildren(); ++i) {
199  TEveJetCone* cone = dynamic_cast<TEveJetCone*>(*i);
200  if (cone) {
201  cone->SetApex(cv);
202  }
203  }
204 
205  // loop compounds in projected product
206  int idx = 0;
207  for (auto& c : product->RefChildren()) {
208  TEveElement* parent = c;
209  // check the compound has more than one element (the first one is jet)
210  if (parent->NumChildren() > 1) {
211  auto compIt = parent->BeginChildren();
212  compIt++;
213  TEveScalableStraightLineSet* lineSet = dynamic_cast<TEveScalableStraightLineSet*>(*compIt);
214  if (lineSet) {
215  // compund index in the product is an index of model data in the collection
216  const void* modelData = item()->modelData(idx);
217  const reco::Jet* jet = (const reco::Jet*)(modelData);
218  float value = vc->getEnergyScale()->getPlotEt() ? jet->et() : jet->energy();
219  lineSet->SetScale(vc->getEnergyScale()->getScaleFactor3D() * value);
220  for (TEveProjectable::ProjList_i j = lineSet->BeginProjecteds(); j != lineSet->EndProjecteds(); ++j) {
221  (*j)->UpdateProjection();
222  }
223  }
224  }
225  idx++;
226  }
227 }
228 
230  TEveChunkManager::iterator li(s.m_ls->GetLinePlex());
231  li.next();
232  TEveStraightLineSet::Line_t& l = *(TEveStraightLineSet::Line_t*)li();
233  TEveVector v(l.fV2[0] - l.fV1[0], l.fV2[1] - l.fV1[1], l.fV2[2] - l.fV1[2]);
234  v.Normalize();
235 
236  double off = item()->getConfig()->value<double>(kJetOffset) - 1;
237  float value = vc->getEnergyScale()->getPlotEt() ? s.m_et : s.m_energy;
238  double trs = off * 130 * value / context().getMaxEnergyInEvent(vc->getEnergyScale()->getPlotEt());
239  v *= trs;
240 
241  float x = l.fV1[0] + v[0];
242  float y = l.fV1[1] + v[1];
243  float z = l.fV1[2] + v[2];
244 
245  s.m_text->m_offsetZ = value / context().getMaxEnergyInEvent(vc->getEnergyScale()->getPlotEt());
246  s.m_text->RefMainTrans().SetPos(x, y, z);
247  if ((s.m_text)->BeginProjecteds() != (s.m_text)->EndProjecteds()) {
248  FWEveTextProjected* textProjected = (FWEveTextProjected*)(*(s.m_text)->BeginProjecteds());
249  textProjected->UpdateProjection();
250  }
251 }
252 
254  reco::Jet,
255  "Jets",
FWJetProxyBuilder::setTextPos
void setTextPos(fireworks::jetScaleMarker &s, const FWViewContext *vc, FWViewType::EType)
Definition: FWJetProxyBuilder.cc:229
eostools.ls
def ls(path, rec=False)
Definition: eostools.py:349
DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:428
reco::Jet
Base class for all types of Jets.
Definition: Jet.h:20
fireworks::Context
Definition: Context.h:41
FWSimpleProxyBuilderTemplate.h
FWJetProxyBuilder
Definition: FWJetProxyBuilder.cc:47
FWViewType::EType
EType
Definition: FWViewType.h:31
FWEventItem::getConfig
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:150
FWJetProxyBuilder::localModelChanges
void localModelChanges(const FWModelId &iId, TEveElement *iCompound, FWViewType::EType viewType, const FWViewContext *vc) override
Definition: FWJetProxyBuilder.cc:184
cuy.cv
cv
Definition: cuy.py:363
FWViewType::kAllRPZBits
static const int kAllRPZBits
Definition: FWViewType.h:67
REGISTER_FWPROXYBUILDER
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
Definition: FWProxyBuilderFactory.h:33
FWModelId
Definition: FWModelId.h:28
kJetLabelsRhoZOn
static const std::string kJetLabelsRhoZOn("Draw Labels in RhoZ View")
FWViewType::kRhoZ
Definition: FWViewType.h:33
makeEveJetCone.h
REGISTER_PROXYBUILDER_METHODS
#define REGISTER_PROXYBUILDER_METHODS()
Definition: register_dataproxybuilder_macro.h:27
FWSimpleProxyBuilderTemplate< reco::Jet >::modelData
const reco::Jet & modelData(int index)
Definition: FWSimpleProxyBuilderTemplate.h:43
FWEventItem::modelData
const void * modelData(int iIndex) const
Definition: FWEventItem.cc:466
FWViewEnergyScale::getPlotEt
bool getPlotEt() const
Definition: FWViewEnergyScale.h:47
Jet.h
FWJetProxyBuilder::Lines_t
std::vector< fireworks::jetScaleMarker > Lines_t
Definition: FWJetProxyBuilder.cc:83
DDAxes::x
findQualityFiles.v
v
Definition: findQualityFiles.py:179
FWViewType::isProjected
static bool isProjected(int)
Definition: FWViewType.cc:100
fireworks::jetScaleMarker::m_text
FWEveText * m_text
Definition: FWJetProxyBuilder.cc:38
FWJetProxyBuilder::operator=
const FWJetProxyBuilder & operator=(const FWJetProxyBuilder &)=delete
FWViewType::kAll3DBits
static const int kAll3DBits
Definition: FWViewType.h:68
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
FWEventItem::defaultDisplayProperties
const FWDisplayProperties & defaultDisplayProperties() const
Definition: FWEventItem.cc:403
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
FWViewType::kGlimpseBit
Definition: FWViewType.h:58
FWViewContext.h
alignCSCRings.s
s
Definition: alignCSCRings.py:92
fireworks::jetScaleMarker
Definition: FWJetProxyBuilder.cc:34
fireworks::Context::caloZ2
static float caloZ2(bool offset=true)
Definition: Context.cc:185
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Calorimetry_cff.dp
dp
Definition: Calorimetry_cff.py:158
fireworks::Context::voteMaxEtAndEnergy
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:162
kJetApexBeamSpot
static const std::string kJetApexBeamSpot("Place Apex In BeamSpot")
DDAxes::z
p2
double p2[4]
Definition: TauolaWrapper.h:90
FWProxyBuilderBase::increaseComponentTransparency
void increaseComponentTransparency(unsigned int index, TEveElement *holder, const std::string &name, Char_t transpOffset)
Definition: FWProxyBuilderBase.cc:393
reco::LeafCandidate::theta
double theta() const final
momentum polar angle
Definition: LeafCandidate.h:150
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
fireworks::jetScaleMarker::jetScaleMarker
jetScaleMarker(TEveScalableStraightLineSet *ls, float et, float e, const FWViewContext *vc)
Definition: FWJetProxyBuilder.cc:35
FWEveTextProjected::UpdateProjection
void UpdateProjection() override
Definition: FWTextProjected.cc:36
FWJetProxyBuilder::m_common
TEveElementList * m_common
Definition: FWJetProxyBuilder.cc:91
FWModelId::index
int index() const
Definition: FWModelId.h:41
fireworks::Context::commonPrefs
CmsShowCommon * commonPrefs() const
Definition: Context.cc:160
FWTextProjected.h
FWProxyBuilderConfiguration::assertParam
FWGenericParameter< T > * assertParam(const std::string &name, T def)
Definition: FWProxyBuilderConfiguration.cc:83
fireworks::makeEveJetCone
TEveJetCone * makeEveJetCone(const reco::Jet &iData, const fireworks::Context &context)
Definition: makeEveJetCone.cc:6
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
FWJetProxyBuilder::haveSingleProduct
bool haveSingleProduct() const override
Definition: FWJetProxyBuilder.cc:53
FWProxyBuilderConfiguration.h
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
FWProxyBuilderBase::setupAddElement
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Definition: FWProxyBuilderBase.cc:350
value
Definition: value.py:1
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
p1
double p1[4]
Definition: TauolaWrapper.h:89
FWEveTextProjected
Definition: FWTextProjected.h:47
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
FWJetProxyBuilder::setItem
void setItem(const FWEventItem *iItem) override
Definition: FWJetProxyBuilder.cc:56
kJetLabelsRhoPhiOn
static const std::string kJetLabelsRhoPhiOn("Draw Labels in RhoPhi View")
fireworks::Context::getMaxEnergyInEvent
float getMaxEnergyInEvent(bool isEt) const
Definition: Context.cc:174
scaleMarker.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FWEventItem.h
FWEveText
Definition: FWTextProjected.h:29
FWViewContext
Definition: FWViewContext.h:32
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
FWJetProxyBuilder::FWJetProxyBuilder
FWJetProxyBuilder()
Definition: FWJetProxyBuilder.cc:95
FWDisplayProperties
Definition: FWDisplayProperties.h:28
alignCSCRings.r
r
Definition: alignCSCRings.py:93
DDAxes::phi
FWProxyBuilderBase::item
const FWEventItem * item() const
Definition: FWProxyBuilderBase.h:64
FWViewEnergyScale::getScaleFactor3D
float getScaleFactor3D() const
Definition: FWViewEnergyScale.h:44
reco::LeafCandidate::et
double et() const final
transverse energy
Definition: LeafCandidate.h:127
CmsShowCommon.h
FWEventItem
Definition: FWEventItem.h:56
fireworks::Context::caloZ1
static float caloZ1(bool offset=true)
Definition: Context.cc:183
reco::LeafCandidate::phi
double phi() const final
momentum azimuthal angle
Definition: LeafCandidate.h:148
FWProxyBuilderConfiguration::value
T value(const std::string &name)
Definition: FWProxyBuilderConfiguration.cc:123
metsig::jet
Definition: SignAlgoResolutions.h:47
relativeConstraints.value
value
Definition: relativeConstraints.py:53
FWJetProxyBuilder::requestCommon
TEveElementList * requestCommon()
Definition: FWJetProxyBuilder.cc:102
FWViewEnergyScale
Definition: FWViewEnergyScale.h:34
fireworks::scaleMarker
Definition: scaleMarker.h:25
fireworks::Context::getInstance
static Context * getInstance()
Definition: Context.cc:193
FWJetProxyBuilder::buildViewType
void buildViewType(const reco::Jet &iData, unsigned int iIndex, TEveElement &oItemHolder, FWViewType::EType type, const FWViewContext *) override
Definition: FWJetProxyBuilder.cc:116
FWJetProxyBuilder::~FWJetProxyBuilder
~FWJetProxyBuilder() override
Definition: FWJetProxyBuilder.cc:100
kJetOffset
static const std::string kJetOffset("Label Offset")
reco::LeafCandidate::energy
double energy() const final
energy
Definition: LeafCandidate.h:125
FWProxyBuilderBase::context
const fireworks::Context & context() const
Definition: FWProxyBuilderBase.cc:412
FWViewEnergyScale.h
FWSimpleProxyBuilderTemplate
Definition: FWSimpleProxyBuilderTemplate.h:30
fireworks
Definition: FWTauProxyBuilderBase.h:35
Min
T Min(T a, T b)
Definition: MathUtil.h:39
FWProxyBuilderBase::setItem
virtual void setItem(const FWEventItem *iItem)
Definition: FWProxyBuilderBase.cc:83
FWJetProxyBuilder::cleanLocal
void cleanLocal() override
Definition: FWJetProxyBuilder.cc:191
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
FWViewContext::getEnergyScale
FWViewEnergyScale * getEnergyScale() const
Definition: FWViewContext.cc:25
class-composition.parent
parent
Definition: class-composition.py:98
CmsShowCommon::getEventCenter
void getEventCenter(float *inC) const
Definition: CmsShowCommon.cc:294
FWViewType::kRhoPhi
Definition: FWViewType.h:32
fireworks::Context::caloR1
static float caloR1(bool offset=true)
Definition: Context.cc:180
FWJetProxyBuilder::scaleProduct
void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc) override
Definition: FWJetProxyBuilder.cc:193
Context.h
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
FWJetProxyBuilder::havePerViewProduct
bool havePerViewProduct(FWViewType::EType) const override
Definition: FWJetProxyBuilder.cc:52