CMS 3D CMS Logo

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

#include <FWPFCandidateWithHitsProxyBuilder.h>

Inheritance diagram for FWPFCandidateWithHitsProxyBuilder:
FWProxyBuilderBase

Public Member Functions

virtual void build (const FWEventItem *iItem, TEveElementList *product, const FWViewContext *)
 
 FWPFCandidateWithHitsProxyBuilder ()
 
virtual bool havePerViewProduct (FWViewType::EType) const
 
 REGISTER_PROXYBUILDER_METHODS ()
 
virtual void scaleProduct (TEveElementList *parent, FWViewType::EType type, const FWViewContext *vc)
 
virtual void setItem (const FWEventItem *iItem)
 
virtual ~FWPFCandidateWithHitsProxyBuilder ()
 
- 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 &)
 
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 ()
 

Private Member Functions

void addHitsForCandidate (const reco::PFCandidate &c, TEveElement *holder, const FWViewContext *vc)
 
 FWPFCandidateWithHitsProxyBuilder (const FWPFCandidateWithHitsProxyBuilder &)
 
const reco::PFRecHitgetHitForDetId (unsigned detId)
 
void initPFRecHitsCollections ()
 
const
FWPFCandidateWithHitsProxyBuilder
operator= (const FWPFCandidateWithHitsProxyBuilder &)
 
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

- 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...
 
- 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 12 of file FWPFCandidateWithHitsProxyBuilder.h.

Constructor & Destructor Documentation

FWPFCandidateWithHitsProxyBuilder::FWPFCandidateWithHitsProxyBuilder ( )
inline

Definition at line 15 of file FWPFCandidateWithHitsProxyBuilder.h.

15 {}
virtual FWPFCandidateWithHitsProxyBuilder::~FWPFCandidateWithHitsProxyBuilder ( )
inlinevirtual

Definition at line 16 of file FWPFCandidateWithHitsProxyBuilder.h.

16 {}
FWPFCandidateWithHitsProxyBuilder::FWPFCandidateWithHitsProxyBuilder ( const FWPFCandidateWithHitsProxyBuilder )
private

Member Function Documentation

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

Definition at line 262 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().

263 {
264  reco::PFCandidate::ElementsInBlocks eleInBlocks = cand.elementsInBlocks();
265 
266  TEveBoxSet* boxset = 0;
267  TEveStraightLineSet* lineset = 0;
268 
269  for(unsigned elIdx=0; elIdx<eleInBlocks.size(); elIdx++)
270  {
271  // unsigned ieTrack = 0;
272  // unsigned ieECAL = 0;
273  unsigned ieHCAL = 0;
274 
275  reco::PFBlockRef blockRef = eleInBlocks[elIdx].first;
276  unsigned indexInBlock = eleInBlocks[elIdx].second;
277  edm::Ptr<reco::PFBlock> myBlock(blockRef.id(),blockRef.get(), blockRef.key());
278  /*
279  if (myBlock->elements()[indexInBlock].type() == 1)
280  ieTrack = indexInBlock;
281  if (myBlock->elements()[indexInBlock].type() == 4)
282  ieECAL = indexInBlock;
283  */
284  if (myBlock->elements()[indexInBlock].type() == 5)
285  ieHCAL = indexInBlock;
286 
287 
288  std::vector<float> scaledCorners(24);
289  float scale = vc->getEnergyScale()->getScaleFactor3D()/50;
290  if (ieHCAL && m_collectionHCAL) {
291  reco::PFClusterRef hcalclusterRef=myBlock->elements()[ieHCAL].clusterRef();
292  edm::Ptr<reco::PFCluster> myCluster(hcalclusterRef.id(),hcalclusterRef.get(), hcalclusterRef.key());
293  if (myCluster.get())
294  {
295  const std::vector< std::pair<DetId, float> > & hitsandfracs = myCluster->hitsAndFractions();
296 
297  if (!boxset)
298  {
299  boxset = new TEveBoxSet();
300  boxset->Reset(TEveBoxSet::kBT_FreeBox, true, hitsandfracs.size());
301  boxset->SetAntiFlick(true);
302  boxset->SetAlwaysSecSelect(1);
303  boxset->SetPickable(1);
304  boxset->SetTooltipCBFoo(boxset_tooltip_callback);
305  }
306 
307  if (!lineset)
308  {
309  lineset = new TEveStraightLineSet();
310  }
311 
312  bool hitsFound = false;
313  for ( int ihandf=0, lastIdx=(int)(hitsandfracs.size()); ihandf<lastIdx; ihandf++)
314  {
315  unsigned int hitDetId = hitsandfracs[ihandf].first;
316  const float* corners = context().getGeom()->getCorners(hitDetId);
317  const reco::PFRecHit* hit = getHitForDetId(hitDetId);
318  if (hit)
319  {
320  viewContextBoxScale( corners, hit->energy()*scale, vc->getEnergyScale()->getPlotEt(), scaledCorners, hit);
321  boxset->AddBox( &scaledCorners[0]);
322  // setup last box
323  boxset->DigitColor(holder->GetMainColor());
324  boxset->DigitUserData((void*)hit);
325  addBoxAsLines(lineset, &scaledCorners[0]);
326  hitsFound = true;
327  }
328  /*
329  // AMT: don't add lines if hit is not found becuse of unconsistency of scaling.
330  else
331  {
332  addBoxAsLines(lineset, corners);
333  }
334  */
335  }
336  if (!hitsFound)
337  fwLog(fwlog::kWarning) << Form("Can't find matching hits with for HCAL block %d in RecHit collection. Number of hits %d.\n", elIdx, (int)hitsandfracs.size());
338 
339 
340  }
341  else
342  {
343  fwLog(fwlog::kInfo) << "empty cluster \n";
344  }
345  }
346  } // endloop cand.elementsInBlocks();
347 
348 
349  if (boxset) {
350  boxset->RefitPlex();
351  setupAddElement(boxset, holder);
352  }
353 
354  if (lineset) {
355  setupAddElement(lineset, holder);
356  }
357 }
const fireworks::Context & context() const
float getScaleFactor3D() const
const FWGeometry * getGeom() const
Definition: Context.h:84
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
FWViewEnergyScale * getEnergyScale() const
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:360
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:277
#define fwLog(_level_)
Definition: fwLog.h:51
key_type key() const
Accessor for product key.
Definition: Ref.h:266
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)
double energy() const
rechit energy
Definition: PFRecHit.h:111
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242
bool getPlotEt() const
void FWPFCandidateWithHitsProxyBuilder::build ( const FWEventItem iItem,
TEveElementList *  product,
const FWViewContext vc 
)
virtual

Reimplemented from FWProxyBuilderBase.

Definition at line 94 of file FWPFCandidateWithHitsProxyBuilder.cc.

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

95 {
96  // init PFCandiate collection
97  reco::PFCandidateCollection const * candidates = 0;
98  iItem->get( candidates );
99  if( candidates == 0 ) return;
100 
101  Int_t idx = 0;
103  for( reco::PFCandidateCollection::const_iterator it = candidates->begin(), itEnd = candidates->end(); it != itEnd; ++it, ++idx)
104  {
105  TEveCompound* comp = createCompound();
106  setupAddElement( comp, product );
107  // printf("products size %d/%d \n", (int)iItem->size(), product->NumChildren());
108 
109  const reco::PFCandidate& cand = *it;
110 
111  // track
112  {
113  TEveRecTrack t;
114  t.fBeta = 1.;
115  t.fP = TEveVector( cand.px(), cand.py(), cand.pz() );
116  t.fV = TEveVector( cand.vertex().x(), cand.vertex().y(), cand.vertex().z() );
117  t.fSign = cand.charge();
118  TEveTrack* trk = new TEveTrack(&t, context().getTrackPropagator() );
119  trk->MakeTrack();
120  fireworks::setTrackTypePF( cand, trk );
121  setupAddElement( trk, comp);
122  }
123  // hits
124  {
125  comp->SetMainColor(iItem->defaultDisplayProperties().color());
126  addHitsForCandidate(cand, comp, vc);
127  }
128 
129  }
130 }
const fireworks::Context & context() const
const FWDisplayProperties & defaultDisplayProperties() const
Definition: FWEventItem.cc:452
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
void get(const T *&oData) const
Definition: FWEventItem.h:85
virtual double pz() const GCC11_FINAL
z coordinate of momentum vector
virtual double py() const GCC11_FINAL
y coordinate of momentum vector
Color_t color() const
virtual double px() const GCC11_FINAL
x coordinate of momentum vector
virtual const Point & vertex() const
vertex position (overwritten by PF...)
Definition: PFCandidate.cc:563
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
virtual int charge() const GCC11_FINAL
electric charge
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
void setTrackTypePF(const reco::PFCandidate &pfCand, TAttLine *track)
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:35
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)
const reco::PFRecHit * FWPFCandidateWithHitsProxyBuilder::getHitForDetId ( unsigned  detId)
private

Definition at line 189 of file FWPFCandidateWithHitsProxyBuilder.cc.

References m_collectionHCAL.

Referenced by addHitsForCandidate().

190 {
191 
192  for (reco::PFRecHitCollection::const_iterator it = m_collectionHCAL->begin(); it != m_collectionHCAL->end(); ++it)
193  {
194 
195  if ( it->detId() == candIdx)
196  {
197  return &(*it);
198  }
199  }
200  return 0;
201 }
const reco::PFRecHitCollection * m_collectionHCAL
virtual bool FWPFCandidateWithHitsProxyBuilder::havePerViewProduct ( FWViewType::EType  ) const
inlinevirtual

Reimplemented from FWProxyBuilderBase.

Definition at line 20 of file FWPFCandidateWithHitsProxyBuilder.h.

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

Definition at line 133 of file FWPFCandidateWithHitsProxyBuilder.cc.

References fwLog, edm::EventBase::getByLabel(), FWEventItem::getConfig(), FWEventItem::getEvent(), edm::HandleBase::isValid(), FWProxyBuilderBase::item(), fwlog::kError, fwlog::kInfo, m_collectionHCAL, FWEventItem::name(), AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, and FWProxyBuilderConfiguration::value().

Referenced by build().

134 {
135  // ref hcal collections
137 
138 
139  m_collectionHCAL =0;
140  try
141  {
142  std::string scc = item()->getConfig()->value<std::string>(kRecHitCollectionName);
143  edm::InputTag tag(scc);
144  item()->getEvent()->getByLabel(tag, handle_hits);
145  if (handle_hits.isValid())
146  {
147  m_collectionHCAL = &*handle_hits;
148  fwLog(fwlog::kInfo) <<"FWPFCandidateWithHitsProxyBuilder, item " << item()->name() <<": Accessed collection with name " << scc << "." << std::endl;
149  }
150  else
151  {
152  fwLog(fwlog::kError) <<"FWPFCandidateWithHitsProxyBuilder, item " << item()->name() <<": Failed to access collection with name " << scc << "." << std::endl;
153  }
154  }
155  catch (...)
156  {
157  fwLog(fwlog::kError) <<"FWPFCandidateWithHitsProxyBuilder, item " << item()->name() <<": Failed to access rechit collection \n";
158  }
159 }
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:166
const std::string & name() const
Definition: FWEventItem.cc:501
const FWEventItem * item() const
bool isValid() const
Definition: HandleBase.h:76
const edm::EventBase * getEvent() const
Definition: FWEventItem.h:147
#define fwLog(_level_)
Definition: fwLog.h:51
const reco::PFRecHitCollection * m_collectionHCAL
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:86
const FWPFCandidateWithHitsProxyBuilder& FWPFCandidateWithHitsProxyBuilder::operator= ( const FWPFCandidateWithHitsProxyBuilder )
private
FWPFCandidateWithHitsProxyBuilder::REGISTER_PROXYBUILDER_METHODS ( )
void FWPFCandidateWithHitsProxyBuilder::scaleProduct ( TEveElementList *  parent,
FWViewType::EType  type,
const FWViewContext vc 
)
virtual

Reimplemented from FWProxyBuilderBase.

Definition at line 204 of file FWPFCandidateWithHitsProxyBuilder.cc.

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

205 {
206  std::vector<float> scaledCorners(24);
207 
208  float scale = vc->getEnergyScale()->getScaleFactor3D()/50;
209  for (TEveElement::List_i i=parent->BeginChildren(); i!=parent->EndChildren(); ++i)
210  {
211  if ((*i)->NumChildren() > 1)
212  {
213  TEveElement::List_i xx = (*i)->BeginChildren(); ++xx;
214  TEveBoxSet* boxset = dynamic_cast<TEveBoxSet*>(*xx);
215  ++xx;
216  TEveStraightLineSet* lineset = dynamic_cast<TEveStraightLineSet*>(*xx);
217  TEveChunkManager::iterator li(lineset->GetLinePlex());
218  li.next();
219 
220 
221  TEveChunkManager* plex = boxset->GetPlex();
222  if (plex->N())
223  {
224  for (int atomIdx=0; atomIdx < plex->Size(); ++atomIdx)
225  {
226 
227  TEveBoxSet::BFreeBox_t* atom = (TEveBoxSet::BFreeBox_t*)boxset->GetPlex()->Atom(atomIdx);
228  reco::PFRecHit* hit = (reco::PFRecHit*)boxset->GetUserData(atomIdx);
229  const float* corners = item()->getGeom()->getCorners(hit->detId());
230  viewContextBoxScale(corners, hit->energy()*scale, vc->getEnergyScale()->getPlotEt(), scaledCorners, hit);
231  memcpy(atom->fVertices, &scaledCorners[0], sizeof(atom->fVertices));
232 
233  editBoxInLineSet(li, &scaledCorners[0]);
234  }
235 
236  for (TEveProjectable::ProjList_i p = lineset->BeginProjecteds(); p != lineset->EndProjecteds(); ++p)
237  {
238  TEveStraightLineSetProjected* projLineSet = (TEveStraightLineSetProjected*)(*p);
239  projLineSet->UpdateProjection();
240  }
241  }
242  }
243  }
244 }
float getScaleFactor3D() const
int i
Definition: DBlmapReader.cc:9
list parent
Definition: dbtoconf.py:74
unsigned detId() const
rechit detId
Definition: PFRecHit.h:105
FWViewEnergyScale * getEnergyScale() const
const FWEventItem * item() const
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:277
void viewContextBoxScale(const float *corners, float scale, bool plotEt, std::vector< float > &scaledCorners, const reco::PFRecHit *)
double energy() const
rechit energy
Definition: PFRecHit.h:111
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:682
bool getPlotEt() const
void FWPFCandidateWithHitsProxyBuilder::setItem ( const FWEventItem iItem)
virtual

Reimplemented from FWProxyBuilderBase.

Definition at line 82 of file FWPFCandidateWithHitsProxyBuilder.cc.

References FWProxyBuilderConfiguration::assertParam(), FWEventItem::getConfig(), FWProxyBuilderBase::setItem(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by Vispa.Plugins.EdmBrowser.EventContentView.EventContentView::_addRow(), Vispa.Views.TableView.TableView::_createItem(), Vispa.Views.PropertyView.PropertyView::addCategory(), and Vispa.Views.PropertyView.PropertyView::append().

83 {
84 
86  if (iItem) {
87  std::string defn = "particleFlowRecHitHCAL";
88  iItem->getConfig()->assertParam(kRecHitCollectionName, defn);
89  }
90 }
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:166
virtual void setItem(const FWEventItem *iItem)
FWGenericParameter< T > * assertParam(const std::string &name, T def)
void FWPFCandidateWithHitsProxyBuilder::viewContextBoxScale ( const float *  corners,
float  scale,
bool  plotEt,
std::vector< float > &  scaledCorners,
const reco::PFRecHit  
)
private

Definition at line 162 of file FWPFCandidateWithHitsProxyBuilder.cc.

References f, and i.

Referenced by addHitsForCandidate(), and scaleProduct().

163 {
164  static TEveVector vtmp;
165  vtmp.Set(0.f, 0.f, 0.f);
166  for( unsigned int i = 0; i < 24; i += 3 )
167  {
168  vtmp[0] += corners[i];
169  vtmp[1] += corners[i + 1];
170  vtmp[2] += corners[i + 2];
171  }
172  vtmp *= 1.f/8.f;
173 
174  if (plotEt)
175  {
176  scale *= vtmp.Perp()/vtmp.Mag();
177  }
178 
179  // Coordinates for a scaled version of the original box
180  for( unsigned int i = 0; i < 24; i += 3 )
181  {
182  scaledCorners[i] = vtmp[0] + ( corners[i] - vtmp[0] ) * scale;
183  scaledCorners[i + 1] = vtmp[1] + ( corners[i + 1] - vtmp[1] ) * scale;
184  scaledCorners[i + 2] = vtmp[2] + ( corners[i + 2] - vtmp[2] ) * scale;
185  }
186 }
int i
Definition: DBlmapReader.cc:9
double f[11][100]

Member Data Documentation

const reco::PFRecHitCollection* FWPFCandidateWithHitsProxyBuilder::m_collectionHCAL
private