CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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

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

- 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 249 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().

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

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

Definition at line 346 of file FWPFCandidateWithHitsProxyBuilder.cc.

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

Definition at line 346 of file FWPFCandidateWithHitsProxyBuilder.cc.

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

Definition at line 346 of file FWPFCandidateWithHitsProxyBuilder.cc.

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

Definition at line 346 of file FWPFCandidateWithHitsProxyBuilder.cc.

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

Definition at line 177 of file FWPFCandidateWithHitsProxyBuilder.cc.

References m_collectionHCAL.

Referenced by addHitsForCandidate().

178 {
179 
180  for (reco::PFRecHitCollection::const_iterator it = m_collectionHCAL->begin(); it != m_collectionHCAL->end(); ++it)
181  {
182 
183  if ( it->detId() == candIdx)
184  {
185  return &(*it);
186  }
187  }
188  return 0;
189 }
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 122 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().

123 {
124  // ref hcal collections
126 
127 
128  m_collectionHCAL =0;
129  try
130  {
131  // edm::InputTag tag("particleFlowRecHitHCAL");
132  edm::InputTag tag(cname);
133  item()->getEvent()->getByLabel(tag, handle_hits);
134  if (handle_hits.isValid())
135  {
136  m_collectionHCAL = &*handle_hits;
137  }
138  else
139  {
140  fwLog(fwlog::kError) <<"FWPFCandidateWithHitsProxyBuilder, item " << item()->name() <<": Failed to access collection with name " << cname << "." << std::endl;
141  }
142  }
143  catch (...)
144  {
145  fwLog(fwlog::kError) <<"FWPFCandidateWithHitsProxyBuilder, item " << item()->name() <<": Failed to access collection with name " << cname << "." << std::endl;
146  }
147 }
const std::string & name() const
Definition: FWEventItem.cc:500
const FWEventItem * item() const
bool isValid() const
Definition: HandleBase.h:76
const edm::EventBase * getEvent() const
Definition: FWEventItem.h:146
#define fwLog(_level_)
Definition: fwLog.h:50
const reco::PFRecHitCollection * m_collectionHCAL
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:87
const FWPFCandidateWithHitsProxyBuilder& FWPFCandidateWithHitsProxyBuilder::operator= ( const FWPFCandidateWithHitsProxyBuilder )
private
const std::string& FWPFCandidateWithHitsProxyBuilder::purpose ( ) const
inline
void FWPFCandidateWithHitsProxyBuilder::scaleProduct ( TEveElementList *  parent,
FWViewType::EType  type,
const FWViewContext vc 
)
virtual

Reimplemented from FWProxyBuilderBase.

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

193 {
194  std::vector<float> scaledCorners(24);
195 
196  float scale = vc->getEnergyScale()->getScaleFactor3D()/50;
197  for (TEveElement::List_i i=parent->BeginChildren(); i!=parent->EndChildren(); ++i)
198  {
199  if ((*i)->NumChildren() > 1)
200  {
201  TEveElement::List_i xx = (*i)->BeginChildren(); ++xx;
202  TEveBoxSet* boxset = dynamic_cast<TEveBoxSet*>(*xx);
203  ++xx;
204  TEveStraightLineSet* lineset = dynamic_cast<TEveStraightLineSet*>(*xx);
205  TEveChunkManager::iterator li(lineset->GetLinePlex());
206  li.next();
207 
208 
209  TEveChunkManager* plex = boxset->GetPlex();
210  if (plex->N())
211  {
212  for (int atomIdx=0; atomIdx < plex->Size(); ++atomIdx)
213  {
214 
215  TEveBoxSet::BFreeBox_t* atom = (TEveBoxSet::BFreeBox_t*)boxset->GetPlex()->Atom(atomIdx);
216  reco::PFRecHit* hit = (reco::PFRecHit*)boxset->GetUserData(atomIdx);
217  const float* corners = item()->getGeom()->getCorners(hit->detId());
218  viewContextBoxScale(corners, hit->energy()*scale, vc->getEnergyScale()->getPlotEt(), scaledCorners, hit);
219  memcpy(atom->fVertices, &scaledCorners[0], sizeof(atom->fVertices));
220 
221  editBoxInLineSet(li, &scaledCorners[0]);
222  }
223 
224  for (TEveProjectable::ProjList_i p = lineset->BeginProjecteds(); p != lineset->EndProjecteds(); ++p)
225  {
226  TEveStraightLineSetProjected* projLineSet = (TEveStraightLineSetProjected*)(*p);
227  projLineSet->UpdateProjection();
228  }
229  }
230  }
231  }
232 }
float getScaleFactor3D() const
int i
Definition: DBlmapReader.cc:9
list parent
Definition: dbtoconf.py:74
unsigned detId() const
rechit detId
Definition: PFRecHit.h:101
FWViewEnergyScale * getEnergyScale() const
const FWEventItem * item() const
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:35
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:107
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:681
bool getPlotEt() const
const std::string& FWPFCandidateWithHitsProxyBuilder::typeName ( ) const
inline
const std::string& FWPFCandidateWithHitsProxyBuilder::view ( ) const
inline
void FWPFCandidateWithHitsProxyBuilder::viewContextBoxScale ( const float *  corners,
float  scale,
bool  plotEt,
std::vector< float > &  scaledCorners,
const reco::PFRecHit  
)
private

Definition at line 150 of file FWPFCandidateWithHitsProxyBuilder.cc.

References f, and i.

Referenced by addHitsForCandidate(), and scaleProduct().

151 {
152  static TEveVector vtmp;
153  vtmp.Set(0.f, 0.f, 0.f);
154  for( unsigned int i = 0; i < 24; i += 3 )
155  {
156  vtmp[0] += corners[i];
157  vtmp[1] += corners[i + 1];
158  vtmp[2] += corners[i + 2];
159  }
160  vtmp *= 1.f/8.f;
161 
162  if (plotEt)
163  {
164  scale *= vtmp.Perp()/vtmp.Mag();
165  }
166 
167  // Coordinates for a scaled version of the original box
168  for( unsigned int i = 0; i < 24; i += 3 )
169  {
170  scaledCorners[i] = vtmp[0] + ( corners[i] - vtmp[0] ) * scale;
171  scaledCorners[i + 1] = vtmp[1] + ( corners[i + 1] - vtmp[1] ) * scale;
172  scaledCorners[i + 2] = vtmp[2] + ( corners[i + 2] - vtmp[2] ) * scale;
173  }
174 }
int i
Definition: DBlmapReader.cc:9
double f[11][100]

Member Data Documentation

const reco::PFRecHitCollection* FWPFCandidateWithHitsProxyBuilder::m_collectionHCAL
private