CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
FWPFCandidateWithHitsProxyBuilder Class Reference

#include <FWPFCandidateWithHitsProxyBuilder.h>

Inheritance diagram for FWPFCandidateWithHitsProxyBuilder:
FWProxyBuilderBase

Public Member Functions

void build (const FWEventItem *iItem, TEveElementList *product, const FWViewContext *) override
 
 FWPFCandidateWithHitsProxyBuilder ()
 
 FWPFCandidateWithHitsProxyBuilder (const FWPFCandidateWithHitsProxyBuilder &)=delete
 
bool havePerViewProduct (FWViewType::EType) const override
 
const
FWPFCandidateWithHitsProxyBuilder
operator= (const FWPFCandidateWithHitsProxyBuilder &)=delete
 
const std::string & purpose () const
 
void scaleProduct (TEveElementList *parent, FWViewType::EType type, const FWViewContext *vc) override
 
const std::string & typeName () const
 
const std::string & view () const
 
 ~FWPFCandidateWithHitsProxyBuilder () override
 
- Public Member Functions inherited from FWProxyBuilderBase
void build ()
 
virtual bool canHandle (const FWEventItem &)
 
const fireworks::Contextcontext () const
 
TEveElementList * createProduct (FWViewType::EType, const FWViewContext *)
 
 FWProxyBuilderBase ()
 
bool getHaveWindow () const
 
virtual bool haveSingleProduct () const
 
const FWEventItemitem () const
 
virtual void itemBeingDestroyed (const FWEventItem *)
 
void itemChanged (const FWEventItem *)
 
int layer () const
 
void modelChanges (const FWModelIds &)
 
void removePerViewProduct (FWViewType::EType, const FWViewContext *vc)
 
void scaleChanged (const FWViewContext *)
 
void setHaveWindow (bool iFlag)
 
virtual void setInteractionList (FWInteractionList *, const std::string &)
 
virtual void setItem (const FWEventItem *iItem)
 
void setupAddElement (TEveElement *el, TEveElement *parent, bool set_color=true) const
 
void setupElement (TEveElement *el, bool color=true) const
 
virtual bool willHandleInteraction () const
 
virtual ~FWProxyBuilderBase ()
 

Static Public Member Functions

static const std::string & classPurpose ()
 
static const std::string & classRegisterTypeName ()
 
static const std::string & classTypeName ()
 
static const std::string & classView ()
 
- Static Public Member Functions inherited from FWProxyBuilderBase
static bool representsSubPart ()
 
static std::string typeOfBuilder ()
 Used by the plugin system to determine how the proxy uses the data from FWEventItem. More...
 

Private Member Functions

void addHitsForCandidate (const reco::PFCandidate &c, TEveElement *holder, const FWViewContext *vc)
 
const reco::PFRecHitgetHitForDetId (unsigned detId)
 
void initPFRecHitsCollections ()
 
void viewContextBoxScale (const float *corners, float scale, bool plotEt, std::vector< float > &scaledCorners, const reco::PFRecHit *)
 

Private Attributes

const reco::PFRecHitCollectionm_collectionHCAL
 

Additional Inherited Members

- Protected Types inherited from FWProxyBuilderBase
typedef std::vector< Product * >
::iterator 
Product_it
 
- Protected Member Functions inherited from FWProxyBuilderBase
virtual void buildViewType (const FWEventItem *iItem, TEveElementList *, FWViewType::EType, const FWViewContext *)
 
virtual void clean ()
 
virtual void cleanLocal ()
 
TEveCompound * createCompound (bool set_color=true, bool propagate_color_to_all_children=false) const
 
 FWProxyBuilderBase (const FWProxyBuilderBase &)
 
void increaseComponentTransparency (unsigned int index, TEveElement *holder, const std::string &name, Char_t transpOffset)
 
virtual void localModelChanges (const FWModelId &iId, TEveElement *iCompound, FWViewType::EType viewType, const FWViewContext *vc)
 
virtual void modelChanges (const FWModelIds &, Product *)
 
const FWProxyBuilderBaseoperator= (const FWProxyBuilderBase &)
 
virtual bool visibilityModelChanges (const FWModelId &, TEveElement *, FWViewType::EType, const FWViewContext *)
 
- Protected Attributes inherited from FWProxyBuilderBase
std::vector< Product * > m_products
 

Detailed Description

Definition at line 11 of file FWPFCandidateWithHitsProxyBuilder.h.

Constructor & Destructor Documentation

FWPFCandidateWithHitsProxyBuilder::FWPFCandidateWithHitsProxyBuilder ( )
inline

Definition at line 13 of file FWPFCandidateWithHitsProxyBuilder.h.

13 {}
FWPFCandidateWithHitsProxyBuilder::~FWPFCandidateWithHitsProxyBuilder ( )
inlineoverride

Definition at line 14 of file FWPFCandidateWithHitsProxyBuilder.h.

14 {}
FWPFCandidateWithHitsProxyBuilder::FWPFCandidateWithHitsProxyBuilder ( const FWPFCandidateWithHitsProxyBuilder )
delete

Member Function Documentation

void FWPFCandidateWithHitsProxyBuilder::addHitsForCandidate ( const reco::PFCandidate c,
TEveElement *  holder,
const FWViewContext vc 
)
private

Definition at line 217 of file FWPFCandidateWithHitsProxyBuilder.cc.

References FWProxyBuilderBase::context(), reco::PFCandidate::elementsInBlocks(), reco::PFRecHit::energy(), fwLog, edm::Ref< C, T, F >::get(), FWGeometry::getCorners(), FWViewContext::getEnergyScale(), fireworks::Context::getGeom(), getHitForDetId(), FWViewEnergyScale::getPlotEt(), FWViewEnergyScale::getScaleFactor3D(), edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::key(), fwlog::kInfo, fwlog::kWarning, m_collectionHCAL, pileupReCalc_HLTpaths::scale, FWProxyBuilderBase::setupAddElement(), and viewContextBoxScale().

Referenced by build().

219  {
220  reco::PFCandidate::ElementsInBlocks eleInBlocks = cand.elementsInBlocks();
221 
222  TEveBoxSet* boxset = nullptr;
223  TEveStraightLineSet* lineset = nullptr;
224 
225  for (unsigned elIdx = 0; elIdx < eleInBlocks.size(); elIdx++) {
226  // unsigned ieTrack = 0;
227  // unsigned ieECAL = 0;
228  unsigned ieHCAL = 0;
229 
230  reco::PFBlockRef blockRef = eleInBlocks[elIdx].first;
231  unsigned indexInBlock = eleInBlocks[elIdx].second;
232  edm::Ptr<reco::PFBlock> myBlock(blockRef.id(), blockRef.get(), blockRef.key());
233  /*
234  if (myBlock->elements()[indexInBlock].type() == 1)
235  ieTrack = indexInBlock;
236  if (myBlock->elements()[indexInBlock].type() == 4)
237  ieECAL = indexInBlock;
238  */
239  if (myBlock->elements()[indexInBlock].type() == 5)
240  ieHCAL = indexInBlock;
241 
242  std::vector<float> scaledCorners(24);
243  float scale = vc->getEnergyScale()->getScaleFactor3D() / 50;
244  if (ieHCAL && m_collectionHCAL) {
245  reco::PFClusterRef hcalclusterRef = myBlock->elements()[ieHCAL].clusterRef();
246  edm::Ptr<reco::PFCluster> myCluster(hcalclusterRef.id(), hcalclusterRef.get(), hcalclusterRef.key());
247  if (myCluster.get()) {
248  const std::vector<std::pair<DetId, float> >& hitsandfracs = myCluster->hitsAndFractions();
249 
250  if (!boxset) {
251  boxset = new TEveBoxSet();
252  boxset->Reset(TEveBoxSet::kBT_FreeBox, true, hitsandfracs.size());
253  boxset->SetAntiFlick(true);
254  boxset->SetAlwaysSecSelect(true);
255  boxset->SetPickable(true);
256  boxset->SetTooltipCBFoo(boxset_tooltip_callback);
257  }
258 
259  if (!lineset) {
260  lineset = new TEveStraightLineSet();
261  }
262 
263  bool hitsFound = false;
264  for (int ihandf = 0, lastIdx = (int)(hitsandfracs.size()); ihandf < lastIdx; ihandf++) {
265  unsigned int hitDetId = hitsandfracs[ihandf].first;
266  const float* corners = context().getGeom()->getCorners(hitDetId);
267  const reco::PFRecHit* hit = getHitForDetId(hitDetId);
268  if (hit) {
269  viewContextBoxScale(corners, hit->energy() * scale, vc->getEnergyScale()->getPlotEt(), scaledCorners, hit);
270  boxset->AddBox(&scaledCorners[0]);
271  // setup last box
272  boxset->DigitColor(holder->GetMainColor());
273  boxset->DigitUserData((void*)hit);
274  addBoxAsLines(lineset, &scaledCorners[0]);
275  hitsFound = true;
276  }
277  /*
278  // AMT: don't add lines if hit is not found becuse of unconsistency of scaling.
279  else
280  {
281  addBoxAsLines(lineset, corners);
282  }
283  */
284  }
285  if (!hitsFound)
286  fwLog(fwlog::kWarning) << Form(
287  "Can't find matching hits with for HCAL block %d in %s collection. Number of hits %d.\n",
288  elIdx,
289  cname.c_str(),
290  (int)hitsandfracs.size());
291 
292  } else {
293  fwLog(fwlog::kInfo) << "empty cluster \n";
294  }
295  }
296  } // endloop cand.elementsInBlocks();
297 
298  if (boxset) {
299  boxset->RefitPlex();
300  setupAddElement(boxset, holder);
301  }
302 
303  if (lineset) {
304  setupAddElement(lineset, holder);
305  }
306 }
const fireworks::Context & context() const
float getScaleFactor3D() const
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
FWViewEnergyScale * getEnergyScale() const
key_type key() const
Accessor for product key.
Definition: Ref.h:250
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:404
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
float energy() const
rechit energy
Definition: PFRecHit.h:99
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:461
#define fwLog(_level_)
Definition: fwLog.h:45
void viewContextBoxScale(const float *corners, float scale, bool plotEt, std::vector< float > &scaledCorners, const reco::PFRecHit *)
const reco::PFRecHitCollection * m_collectionHCAL
const reco::PFRecHit * getHitForDetId(unsigned detId)
FWGeometry * getGeom() const
Definition: Context.h:72
bool getPlotEt() const
void FWPFCandidateWithHitsProxyBuilder::build ( const FWEventItem iItem,
TEveElementList *  product,
const FWViewContext vc 
)
overridevirtual

Reimplemented from FWProxyBuilderBase.

Definition at line 69 of file FWPFCandidateWithHitsProxyBuilder.cc.

References addHitsForCandidate(), HLT_FULL_cff::candidates, reco::LeafCandidate::charge(), FWDisplayProperties::color(), AlCaHLTBitMon_QueryRunRegistry::comp, FWProxyBuilderBase::context(), FWProxyBuilderBase::createCompound(), FWEventItem::defaultDisplayProperties(), FWEventItem::get(), initPFRecHitsCollections(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), reco::LeafCandidate::pz(), fireworks::setTrackTypePF(), FWProxyBuilderBase::setupAddElement(), submitPVValidationJobs::t, and reco::PFCandidate::vertex().

71  {
72  // init PFCandiate collection
73  reco::PFCandidateCollection const* candidates = nullptr;
74  iItem->get(candidates);
75  if (candidates == nullptr)
76  return;
77 
78  Int_t idx = 0;
80  for (reco::PFCandidateCollection::const_iterator it = candidates->begin(), itEnd = candidates->end(); it != itEnd;
81  ++it, ++idx) {
82  TEveCompound* comp = createCompound();
83  setupAddElement(comp, product);
84  // printf("products size %d/%d \n", (int)iItem->size(), product->NumChildren());
85 
86  const reco::PFCandidate& cand = *it;
87 
88  // track
89  {
90  TEveRecTrack t;
91  t.fBeta = 1.;
92  t.fP = TEveVector(cand.px(), cand.py(), cand.pz());
93  t.fV = TEveVector(cand.vertex().x(), cand.vertex().y(), cand.vertex().z());
94  t.fSign = cand.charge();
95  TEveTrack* trk = new TEveTrack(&t, context().getTrackPropagator());
96  trk->MakeTrack();
97  fireworks::setTrackTypePF(cand, trk);
98  setupAddElement(trk, comp);
99  }
100  // hits
101  {
102  comp->SetMainColor(iItem->defaultDisplayProperties().color());
103  addHitsForCandidate(cand, comp, vc);
104  }
105  }
106 }
const fireworks::Context & context() const
const FWDisplayProperties & defaultDisplayProperties() const
Definition: FWEventItem.cc:403
double pz() const final
z coordinate of momentum vector
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
void get(const T *&oData) const
Definition: FWEventItem.h:78
Color_t color() const
double px() const final
x coordinate of momentum vector
double py() const final
y coordinate of momentum vector
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
const Point & vertex() const override
vertex position (overwritten by PF...)
Definition: PFCandidate.cc:60
void setTrackTypePF(const reco::PFCandidate &pfCand, TAttLine *track)
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
void addHitsForCandidate(const reco::PFCandidate &c, TEveElement *holder, const FWViewContext *vc)
int charge() const final
electric charge
const std::string & FWPFCandidateWithHitsProxyBuilder::classPurpose ( )
static

Definition at line 311 of file FWPFCandidateWithHitsProxyBuilder.cc.

const std::string & FWPFCandidateWithHitsProxyBuilder::classRegisterTypeName ( )
static

Definition at line 311 of file FWPFCandidateWithHitsProxyBuilder.cc.

const std::string & FWPFCandidateWithHitsProxyBuilder::classTypeName ( )
static

Definition at line 311 of file FWPFCandidateWithHitsProxyBuilder.cc.

const std::string & FWPFCandidateWithHitsProxyBuilder::classView ( )
static

Definition at line 311 of file FWPFCandidateWithHitsProxyBuilder.cc.

const reco::PFRecHit * FWPFCandidateWithHitsProxyBuilder::getHitForDetId ( unsigned  detId)
private

Definition at line 155 of file FWPFCandidateWithHitsProxyBuilder.cc.

References m_collectionHCAL.

Referenced by addHitsForCandidate().

155  {
156  for (reco::PFRecHitCollection::const_iterator it = m_collectionHCAL->begin(); it != m_collectionHCAL->end(); ++it) {
157  if (it->detId() == candIdx) {
158  return &(*it);
159  }
160  }
161  return nullptr;
162 }
const reco::PFRecHitCollection * m_collectionHCAL
bool FWPFCandidateWithHitsProxyBuilder::havePerViewProduct ( FWViewType::EType  ) const
inlineoverridevirtual

Reimplemented from FWProxyBuilderBase.

Definition at line 18 of file FWPFCandidateWithHitsProxyBuilder.h.

18 { return true; }
void FWPFCandidateWithHitsProxyBuilder::initPFRecHitsCollections ( )
private

Definition at line 109 of file FWPFCandidateWithHitsProxyBuilder.cc.

References fwLog, edm::EventBase::getByLabel(), FWEventItem::getEvent(), edm::HandleBase::isValid(), FWProxyBuilderBase::item(), fwlog::kError, m_collectionHCAL, FWEventItem::name(), and GlobalPosition_Frontier_DevDB_cff::tag.

Referenced by build().

109  {
110  // ref hcal collections
112 
113  m_collectionHCAL = nullptr;
114  try {
115  // edm::InputTag tag("particleFlowRecHitHCAL");
116  edm::InputTag tag(cname);
117  item()->getEvent()->getByLabel(tag, handle_hits);
118  if (handle_hits.isValid()) {
119  m_collectionHCAL = &*handle_hits;
120  } else {
121  fwLog(fwlog::kError) << "FWPFCandidateWithHitsProxyBuilder, item " << item()->name()
122  << ": Failed to access collection with name " << cname << "." << std::endl;
123  }
124  } catch (...) {
125  fwLog(fwlog::kError) << "FWPFCandidateWithHitsProxyBuilder, item " << item()->name()
126  << ": Failed to access collection with name " << cname << "." << std::endl;
127  }
128 }
const std::string & name() const
Definition: FWEventItem.cc:435
const FWEventItem * item() const
bool isValid() const
Definition: HandleBase.h:70
const edm::EventBase * getEvent() const
Definition: FWEventItem.h:131
#define fwLog(_level_)
Definition: fwLog.h:45
const reco::PFRecHitCollection * m_collectionHCAL
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:92
const FWPFCandidateWithHitsProxyBuilder& FWPFCandidateWithHitsProxyBuilder::operator= ( const FWPFCandidateWithHitsProxyBuilder )
delete
const std::string& FWPFCandidateWithHitsProxyBuilder::purpose ( ) const
inline

Definition at line 22 of file FWPFCandidateWithHitsProxyBuilder.h.

27 :
28  void addHitsForCandidate(const reco::PFCandidate& c, TEveElement* holder, const FWViewContext* vc);
const edm::EventSetup & c
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
void addHitsForCandidate(const reco::PFCandidate &c, TEveElement *holder, const FWViewContext *vc)
void FWPFCandidateWithHitsProxyBuilder::scaleProduct ( TEveElementList *  parent,
FWViewType::EType  type,
const FWViewContext vc 
)
overridevirtual

Reimplemented from FWProxyBuilderBase.

Definition at line 165 of file FWPFCandidateWithHitsProxyBuilder.cc.

References reco::PFRecHit::detId(), reco::PFRecHit::energy(), FWGeometry::getCorners(), FWViewContext::getEnergyScale(), FWEventItem::getGeom(), FWViewEnergyScale::getPlotEt(), FWViewEnergyScale::getScaleFactor3D(), mps_fire::i, FWProxyBuilderBase::item(), AlCaHLTBitMon_ParallelJobs::p, pileupReCalc_HLTpaths::scale, and viewContextBoxScale().

167  {
168  std::vector<float> scaledCorners(24);
169 
170  float scale = vc->getEnergyScale()->getScaleFactor3D() / 50;
171  for (TEveElement::List_i i = parent->BeginChildren(); i != parent->EndChildren(); ++i) {
172  if ((*i)->NumChildren() > 1) {
173  TEveElement::List_i xx = (*i)->BeginChildren();
174  ++xx;
175  TEveBoxSet* boxset = dynamic_cast<TEveBoxSet*>(*xx);
176  ++xx;
177  TEveStraightLineSet* lineset = dynamic_cast<TEveStraightLineSet*>(*xx);
178  TEveChunkManager::iterator li(lineset->GetLinePlex());
179  li.next();
180 
181  TEveChunkManager* plex = boxset->GetPlex();
182  if (plex->N()) {
183  for (int atomIdx = 0; atomIdx < plex->Size(); ++atomIdx) {
184  TEveBoxSet::BFreeBox_t* atom = (TEveBoxSet::BFreeBox_t*)boxset->GetPlex()->Atom(atomIdx);
185  reco::PFRecHit* hit = (reco::PFRecHit*)boxset->GetUserData(atomIdx);
186  const float* corners = item()->getGeom()->getCorners(hit->detId());
187  viewContextBoxScale(corners, hit->energy() * scale, vc->getEnergyScale()->getPlotEt(), scaledCorners, hit);
188  memcpy(atom->fVertices, &scaledCorners[0], sizeof(atom->fVertices));
189 
190  editBoxInLineSet(li, &scaledCorners[0]);
191  }
192 
193  for (TEveProjectable::ProjList_i p = lineset->BeginProjecteds(); p != lineset->EndProjecteds(); ++p) {
194  TEveStraightLineSetProjected* projLineSet = (TEveStraightLineSetProjected*)(*p);
195  projLineSet->UpdateProjection();
196  }
197  }
198  }
199  }
200 }
float getScaleFactor3D() const
unsigned detId() const
rechit detId
Definition: PFRecHit.h:93
FWViewEnergyScale * getEnergyScale() const
const FWEventItem * item() const
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
float energy() const
rechit energy
Definition: PFRecHit.h:99
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:461
void viewContextBoxScale(const float *corners, float scale, bool plotEt, std::vector< float > &scaledCorners, const reco::PFRecHit *)
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
bool getPlotEt() const
const std::string& FWPFCandidateWithHitsProxyBuilder::typeName ( ) const
inline

Definition at line 22 of file FWPFCandidateWithHitsProxyBuilder.h.

27 :
28  void addHitsForCandidate(const reco::PFCandidate& c, TEveElement* holder, const FWViewContext* vc);
const edm::EventSetup & c
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
void addHitsForCandidate(const reco::PFCandidate &c, TEveElement *holder, const FWViewContext *vc)
const std::string& FWPFCandidateWithHitsProxyBuilder::view ( ) const
inline

Definition at line 22 of file FWPFCandidateWithHitsProxyBuilder.h.

27 :
28  void addHitsForCandidate(const reco::PFCandidate& c, TEveElement* holder, const FWViewContext* vc);
const edm::EventSetup & c
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
void addHitsForCandidate(const reco::PFCandidate &c, TEveElement *holder, const FWViewContext *vc)
void FWPFCandidateWithHitsProxyBuilder::viewContextBoxScale ( const float *  corners,
float  scale,
bool  plotEt,
std::vector< float > &  scaledCorners,
const reco::PFRecHit  
)
private

Definition at line 131 of file FWPFCandidateWithHitsProxyBuilder.cc.

References validate-o2o-wbm::f, and mps_fire::i.

Referenced by addHitsForCandidate(), and scaleProduct().

132  {
133  static TEveVector vtmp;
134  vtmp.Set(0.f, 0.f, 0.f);
135  for (unsigned int i = 0; i < 24; i += 3) {
136  vtmp[0] += corners[i];
137  vtmp[1] += corners[i + 1];
138  vtmp[2] += corners[i + 2];
139  }
140  vtmp *= 1.f / 8.f;
141 
142  if (plotEt) {
143  scale *= vtmp.Perp() / vtmp.Mag();
144  }
145 
146  // Coordinates for a scaled version of the original box
147  for (unsigned int i = 0; i < 24; i += 3) {
148  scaledCorners[i] = vtmp[0] + (corners[i] - vtmp[0]) * scale;
149  scaledCorners[i + 1] = vtmp[1] + (corners[i + 1] - vtmp[1]) * scale;
150  scaledCorners[i + 2] = vtmp[2] + (corners[i + 2] - vtmp[2]) * scale;
151  }
152 }

Member Data Documentation

const reco::PFRecHitCollection* FWPFCandidateWithHitsProxyBuilder::m_collectionHCAL
private