1 #include "TEveBoxSet.h"
3 #include "TEveTrackPropagator.h"
4 #include "TEveCompound.h"
5 #include "TEveStraightLineSet.h"
6 #include "TEveProjectionBases.h"
25 const static std::string cname(
"particleFlowRecHitHCALUpgrade");
27 void addLineToLineSet(TEveStraightLineSet*
ls,
const float*
p,
int i1,
int i2)
31 ls->AddLine(p[i1], p[i1+1], p[i1+2], p[i2], p[i2+1], p[i2+2]);
35 void addBoxAsLines(TEveStraightLineSet* lineset,
const float* p)
37 for (
int l = 0;
l < 5;
l+=4)
39 addLineToLineSet(lineset, p, 0+
l, 1+
l);
40 addLineToLineSet(lineset, p, 1+
l, 2+
l);
41 addLineToLineSet(lineset, p, 2+
l, 3+
l);
42 addLineToLineSet(lineset, p, 3+
l, 0+
l);
44 for (
int l = 0;
l < 4; ++
l)
45 addLineToLineSet(lineset, p, 0+
l, 4+
l);
48 void editLineInLineSet(TEveChunkManager::iterator& li,
const float* p,
int i1,
int i2)
50 TEveStraightLineSet::Line_t&
line = * (TEveStraightLineSet::Line_t*) li();
53 for (
int i = 0;
i < 3 ; ++
i) {
54 line.fV1[0+
i] = p[i1+
i];
55 line.fV2[0+
i] = p[i2+
i];
61 void editBoxInLineSet(TEveChunkManager::iterator& li,
const float* p)
64 for (
int i = 0;
i < 5;
i+=4)
66 editLineInLineSet(li, p, 0+
i, 1+
i);
68 editLineInLineSet(li, p, 1+
i, 2+
i);
69 editLineInLineSet(li, p, 2+
i, 3+
i);
70 editLineInLineSet(li, p, 3+
i, 0+
i);
72 for (
int i = 0;
i < 4; ++
i)
73 editLineInLineSet(li, p, 0+
i, 4+
i);
83 iItem->
get( candidates );
84 if( candidates == 0 )
return;
89 for( reco::PFCandidateCollection::const_iterator it = candidates->begin(), itEnd = candidates->end(); it != itEnd; ++it, ++
idx)
101 t.fP = TEveVector( cand.
px(), cand.
py(), cand.
pz() );
104 TEveTrack* trk =
new TEveTrack(&t,
context().getTrackPropagator() );
137 fwLog(
fwlog::kError) <<
"FWPFCandidateWithHitsProxyBuilder, item " <<
item()->
name() <<
": Failed to access collection with name " << cname <<
"." << std::endl;
142 fwLog(
fwlog::kError) <<
"FWPFCandidateWithHitsProxyBuilder, item " <<
item()->
name() <<
": Failed to access collection with name " << cname <<
"." << std::endl;
149 static TEveVector vtmp;
150 vtmp.Set(0.
f, 0.
f, 0.
f);
151 for(
unsigned int i = 0;
i < 24;
i += 3 )
153 vtmp[0] += corners[
i];
154 vtmp[1] += corners[
i + 1];
155 vtmp[2] += corners[
i + 2];
161 scale *= vtmp.Perp()/vtmp.Mag();
165 for(
unsigned int i = 0;
i < 24;
i += 3 )
167 scaledCorners[
i] = vtmp[0] + ( corners[
i] - vtmp[0] ) * scale;
168 scaledCorners[
i + 1] = vtmp[1] + ( corners[
i + 1] - vtmp[1] ) * scale;
169 scaledCorners[
i + 2] = vtmp[2] + ( corners[
i + 2] - vtmp[2] ) * scale;
180 if ( it->detId() == candIdx)
191 std::vector<float> scaledCorners(24);
194 for (TEveElement::List_i
i=parent->BeginChildren();
i!=parent->EndChildren(); ++
i)
196 if ((*i)->NumChildren() > 1)
198 TEveElement::List_i xx = (*i)->BeginChildren(); ++xx;
199 TEveBoxSet* boxset =
dynamic_cast<TEveBoxSet*
>(*xx);
201 TEveStraightLineSet* lineset =
dynamic_cast<TEveStraightLineSet*
>(*xx);
202 TEveChunkManager::iterator li(lineset->GetLinePlex());
206 TEveChunkManager* plex = boxset->GetPlex();
209 for (
int atomIdx=0; atomIdx < plex->Size(); ++atomIdx)
212 TEveBoxSet::BFreeBox_t* atom = (TEveBoxSet::BFreeBox_t*)boxset->GetPlex()->Atom(atomIdx);
216 memcpy(atom->fVertices, &scaledCorners[0],
sizeof(atom->fVertices));
218 editBoxInLineSet(li, &scaledCorners[0]);
221 for (TEveProjectable::ProjList_i p = lineset->BeginProjecteds(); p != lineset->EndProjecteds(); ++
p)
223 TEveStraightLineSetProjected* projLineSet = (TEveStraightLineSetProjected*)(*p);
224 projLineSet->UpdateProjection();
232 TString boxset_tooltip_callback(TEveDigitSet* ds, Int_t
idx)
234 void* ud = ds->GetUserData(idx);
240 return TString::Format(
"RecHit %d energy '%f'", idx, hit->
energy());
251 TEveBoxSet* boxset = 0;
252 TEveStraightLineSet* lineset = 0;
254 for(
unsigned elIdx=0; elIdx<eleInBlocks.size(); elIdx++)
261 unsigned indexInBlock = eleInBlocks[elIdx].second;
269 if (myBlock->elements()[indexInBlock].type() == 5)
270 ieHCAL = indexInBlock;
273 std::vector<float> scaledCorners(24);
280 const std::vector< std::pair<DetId, float> > & hitsandfracs = myCluster->hitsAndFractions();
284 boxset =
new TEveBoxSet();
285 boxset->Reset(TEveBoxSet::kBT_FreeBox,
true, hitsandfracs.size());
286 boxset->SetAntiFlick(
true);
287 boxset->SetAlwaysSecSelect(1);
288 boxset->SetPickable(1);
289 boxset->SetTooltipCBFoo(boxset_tooltip_callback);
294 lineset =
new TEveStraightLineSet();
297 bool hitsFound =
false;
298 for (
int ihandf=0,
lastIdx=(
int)(hitsandfracs.size()); ihandf<
lastIdx; ihandf++)
300 unsigned int hitDetId = hitsandfracs[ihandf].first;
306 boxset->AddBox( &scaledCorners[0]);
308 boxset->DigitColor(holder->GetMainColor());
309 boxset->DigitUserData((
void*)hit);
310 addBoxAsLines(lineset, &scaledCorners[0]);
322 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());
const fireworks::Context & context() 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
key_type key() const
Accessor for product key.
std::vector< ElementInBlock > ElementsInBlocks
ProductID id() const
Accessor for product ID.
const FWEventItem * item() const
static const int kAll3DBits
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
virtual int charge() const final
electric charge
virtual const Point & vertex() const
vertex position (overwritten by PF...)
virtual double py() const final
y coordinate of momentum vector
T const * get() const
Returns C++ pointer to the item.
float energy() const
rechit energy
virtual double pz() const final
z coordinate of momentum vector
const edm::EventBase * getEvent() const
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
const float * getCorners(unsigned int id) const
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
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
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)
virtual double px() const final
x coordinate of momentum vector
const ElementsInBlocks & elementsInBlocks() const
const FWGeometry * getGeom() const