2 #define protected public
3 #include "TEveBoxSet.h"
6 #include "TEveTrackPropagator.h"
7 #include "TEveCompound.h"
8 #include "TEveStraightLineSet.h"
9 #include "TEveProjectionBases.h"
29 static std::string kRecHitCollectionName =
"RecHitCollection";
30 void addLineToLineSet(TEveStraightLineSet*
ls,
const float*
p,
int i1,
int i2)
34 ls->AddLine(p[i1], p[i1+1], p[i1+2], p[i2], p[i2+1], p[i2+2]);
38 void addBoxAsLines(TEveStraightLineSet* lineset,
const float* p)
40 for (
int l = 0;
l < 5;
l+=4)
42 addLineToLineSet(lineset, p, 0+
l, 1+
l);
43 addLineToLineSet(lineset, p, 1+
l, 2+
l);
44 addLineToLineSet(lineset, p, 2+
l, 3+
l);
45 addLineToLineSet(lineset, p, 3+
l, 0+
l);
47 for (
int l = 0;
l < 4; ++
l)
48 addLineToLineSet(lineset, p, 0+
l, 4+
l);
51 void editLineInLineSet(TEveChunkManager::iterator& li,
const float* p,
int i1,
int i2)
53 TEveStraightLineSet::Line_t&
line = * (TEveStraightLineSet::Line_t*) li();
56 for (
int i = 0;
i < 3 ; ++
i) {
57 line.fV1[0+
i] = p[i1+
i];
58 line.fV2[0+
i] = p[i2+
i];
64 void editBoxInLineSet(TEveChunkManager::iterator& li,
const float* p)
67 for (
int i = 0;
i < 5;
i+=4)
69 editLineInLineSet(li, p, 0+
i, 1+
i);
71 editLineInLineSet(li, p, 1+
i, 2+
i);
72 editLineInLineSet(li, p, 2+
i, 3+
i);
73 editLineInLineSet(li, p, 3+
i, 0+
i);
75 for (
int i = 0;
i < 4; ++
i)
76 editLineInLineSet(li, p, 0+
i, 4+
i);
98 iItem->
get( candidates );
99 if( candidates == 0 )
return;
103 for( reco::PFCandidateCollection::const_iterator it = candidates->begin(), itEnd = candidates->end(); it != itEnd; ++it, ++
idx)
115 t.fP = TEveVector( cand.
px(), cand.
py(), cand.
pz() );
118 TEveTrack* trk =
new TEveTrack(&t,
context().getTrackPropagator() );
148 fwLog(
fwlog::kInfo) <<
"FWPFCandidateWithHitsProxyBuilder, item " <<
item()->
name() <<
": Accessed collection with name " << scc <<
"." << std::endl;
152 fwLog(
fwlog::kError) <<
"FWPFCandidateWithHitsProxyBuilder, item " <<
item()->
name() <<
": Failed to access collection with name " << scc <<
"." << std::endl;
157 fwLog(
fwlog::kError) <<
"FWPFCandidateWithHitsProxyBuilder, item " <<
item()->
name() <<
": Failed to access rechit collection \n";
164 static TEveVector vtmp;
165 vtmp.Set(0.
f, 0.
f, 0.
f);
166 for(
unsigned int i = 0;
i < 24;
i += 3 )
168 vtmp[0] += corners[
i];
169 vtmp[1] += corners[
i + 1];
170 vtmp[2] += corners[
i + 2];
176 scale *= vtmp.Perp()/vtmp.Mag();
180 for(
unsigned int i = 0;
i < 24;
i += 3 )
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;
195 if ( it->detId() == candIdx)
206 std::vector<float> scaledCorners(24);
209 for (TEveElement::List_i
i=parent->BeginChildren();
i!=parent->EndChildren(); ++
i)
211 if ((*i)->NumChildren() > 1)
213 TEveElement::List_i xx = (*i)->BeginChildren(); ++xx;
214 TEveBoxSet* boxset =
dynamic_cast<TEveBoxSet*
>(*xx);
216 TEveStraightLineSet* lineset =
dynamic_cast<TEveStraightLineSet*
>(*xx);
217 TEveChunkManager::iterator li(lineset->GetLinePlex());
221 TEveChunkManager* plex = boxset->GetPlex();
224 for (
int atomIdx=0; atomIdx < plex->Size(); ++atomIdx)
227 TEveBoxSet::BFreeBox_t* atom = (TEveBoxSet::BFreeBox_t*)boxset->GetPlex()->Atom(atomIdx);
231 memcpy(atom->fVertices, &scaledCorners[0],
sizeof(atom->fVertices));
233 editBoxInLineSet(li, &scaledCorners[0]);
236 for (TEveProjectable::ProjList_i
p = lineset->BeginProjecteds();
p != lineset->EndProjecteds(); ++
p)
238 TEveStraightLineSetProjected* projLineSet = (TEveStraightLineSetProjected*)(*
p);
239 projLineSet->UpdateProjection();
247 TString boxset_tooltip_callback(TEveDigitSet* ds, Int_t
idx)
249 void* ud = ds->GetUserData(idx);
255 return TString::Format(
"RecHit %d energy '%f'", idx, hit->
energy());
266 TEveBoxSet* boxset = 0;
267 TEveStraightLineSet* lineset = 0;
269 for(
unsigned elIdx=0; elIdx<eleInBlocks.size(); elIdx++)
276 unsigned indexInBlock = eleInBlocks[elIdx].second;
284 if (myBlock->elements()[indexInBlock].type() == 5)
285 ieHCAL = indexInBlock;
288 std::vector<float> scaledCorners(24);
295 const std::vector< std::pair<DetId, float> > & hitsandfracs = myCluster->hitsAndFractions();
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);
309 lineset =
new TEveStraightLineSet();
312 bool hitsFound =
false;
313 for (
int ihandf=0, lastIdx=(
int)(hitsandfracs.size()); ihandf<lastIdx; ihandf++)
315 unsigned int hitDetId = hitsandfracs[ihandf].first;
321 boxset->AddBox( &scaledCorners[0]);
323 boxset->DigitColor(holder->GetMainColor());
324 boxset->DigitUserData((
void*)hit);
325 addBoxAsLines(lineset, &scaledCorners[0]);
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());
const fireworks::Context & context() const
FWProxyBuilderConfiguration * getConfig() const
float getScaleFactor3D() const
const FWDisplayProperties & defaultDisplayProperties() const
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
unsigned detId() const
rechit detId
const std::string & name() const
const FWGeometry * getGeom() const
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
void get(const T *&oData) const
FWViewEnergyScale * getEnergyScale() const
virtual double pz() const GCC11_FINAL
z coordinate of momentum vector
virtual double py() const GCC11_FINAL
y coordinate of momentum vector
std::vector< ElementInBlock > ElementsInBlocks
const FWEventItem * item() const
static const int kAll3DBits
const ElementsInBlocks & elementsInBlocks() const
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
virtual void setItem(const FWEventItem *iItem)
virtual double px() const GCC11_FINAL
x coordinate of momentum vector
virtual const Point & vertex() const
vertex position (overwritten by PF...)
FWGenericParameter< T > * assertParam(const std::string &name, T def)
virtual void setItem(const FWEventItem *iItem)
const edm::EventBase * getEvent() const
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
const float * getCorners(unsigned int id) const
virtual int charge() const GCC11_FINAL
electric charge
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
key_type key() const
Accessor for product key.
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)
void setTrackTypePF(const reco::PFCandidate &pfCand, TAttLine *track)
Particle reconstructed by the particle flow algorithm.
bool getByLabel(InputTag const &, Handle< T > &) const
double energy() const
rechit energy
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
virtual void scaleProduct(TEveElementList *parent, FWViewType::EType type, const FWViewContext *vc)
void initPFRecHitsCollections()
void addHitsForCandidate(const reco::PFCandidate &c, TEveElement *holder, const FWViewContext *vc)
T value(const std::string &name)
ProductID id() const
Accessor for product ID.
T const * get() const
Returns C++ pointer to the item.
const FWGeometry * getGeom() const