2 #define protected public
3 #include "TEveBoxSet.h"
6 #include "TEveTrackPropagator.h"
7 #include "TEveCompound.h"
8 #include "TEveStraightLineSet.h"
9 #include "TEveProjectionBases.h"
28 const static std::string cname(
"particleFlowRecHitHCALUpgrade");
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);
86 iItem->
get( candidates );
87 if( candidates == 0 )
return;
92 for( reco::PFCandidateCollection::const_iterator it = candidates->begin(), itEnd = candidates->end(); it != itEnd; ++it, ++
idx)
104 t.fP = TEveVector( cand.
px(), cand.
py(), cand.
pz() );
107 TEveTrack* trk =
new TEveTrack(&t,
context().getTrackPropagator() );
140 fwLog(
fwlog::kError) <<
"FWPFCandidateWithHitsProxyBuilder, item " <<
item()->
name() <<
": Failed to access collection with name " << cname <<
"." << std::endl;
145 fwLog(
fwlog::kError) <<
"FWPFCandidateWithHitsProxyBuilder, item " <<
item()->
name() <<
": Failed to access collection with name " << cname <<
"." << std::endl;
152 static TEveVector vtmp;
153 vtmp.Set(0.
f, 0.
f, 0.
f);
154 for(
unsigned int i = 0;
i < 24;
i += 3 )
156 vtmp[0] += corners[
i];
157 vtmp[1] += corners[
i + 1];
158 vtmp[2] += corners[
i + 2];
164 scale *= vtmp.Perp()/vtmp.Mag();
168 for(
unsigned int i = 0;
i < 24;
i += 3 )
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;
183 if ( it->detId() == candIdx)
194 std::vector<float> scaledCorners(24);
197 for (TEveElement::List_i
i=parent->BeginChildren();
i!=parent->EndChildren(); ++
i)
199 if ((*i)->NumChildren() > 1)
201 TEveElement::List_i xx = (*i)->BeginChildren(); ++xx;
202 TEveBoxSet* boxset =
dynamic_cast<TEveBoxSet*
>(*xx);
204 TEveStraightLineSet* lineset =
dynamic_cast<TEveStraightLineSet*
>(*xx);
205 TEveChunkManager::iterator li(lineset->GetLinePlex());
209 TEveChunkManager* plex = boxset->GetPlex();
212 for (
int atomIdx=0; atomIdx < plex->Size(); ++atomIdx)
215 TEveBoxSet::BFreeBox_t* atom = (TEveBoxSet::BFreeBox_t*)boxset->GetPlex()->Atom(atomIdx);
219 memcpy(atom->fVertices, &scaledCorners[0],
sizeof(atom->fVertices));
221 editBoxInLineSet(li, &scaledCorners[0]);
224 for (TEveProjectable::ProjList_i
p = lineset->BeginProjecteds();
p != lineset->EndProjecteds(); ++
p)
226 TEveStraightLineSetProjected* projLineSet = (TEveStraightLineSetProjected*)(*
p);
227 projLineSet->UpdateProjection();
235 TString boxset_tooltip_callback(TEveDigitSet* ds, Int_t
idx)
237 void* ud = ds->GetUserData(idx);
243 return TString::Format(
"RecHit %d energy '%f'", idx, hit->
energy());
253 TEveBoxSet* boxset = 0;
254 TEveStraightLineSet* lineset = 0;
256 for(
unsigned elIdx=0; elIdx<eleInBlocks.size(); elIdx++)
263 unsigned indexInBlock = eleInBlocks[elIdx].second;
271 if (myBlock->elements()[indexInBlock].type() == 5)
272 ieHCAL = indexInBlock;
275 std::vector<float> scaledCorners(24);
282 const std::vector< std::pair<DetId, float> > & hitsandfracs = myCluster->hitsAndFractions();
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);
296 lineset =
new TEveStraightLineSet();
299 bool hitsFound =
false;
300 for (
int ihandf=0, lastIdx=(
int)(hitsandfracs.size()); ihandf<lastIdx; ihandf++)
302 unsigned int hitDetId = hitsandfracs[ihandf].first;
308 boxset->AddBox( &scaledCorners[0]);
310 boxset->DigitColor(holder->GetMainColor());
311 boxset->DigitUserData((
void*)hit);
312 addBoxAsLines(lineset, &scaledCorners[0]);
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());
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
std::vector< ElementInBlock > ElementsInBlocks
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
electric charge
virtual const Point & vertex() const
vertex position (overwritten by PF...)
const edm::EventBase * getEvent() const
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
const float * getCorners(unsigned int id) const
virtual double px() const
x coordinate of momentum vector
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 *)
virtual double pz() const
z coordinate of momentum vector
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)
ProductID id() const
Accessor for product ID.
T const * get() const
Returns C++ pointer to the item.
const ElementsInBlocks & elementsInBlocks() const
virtual double py() const
y coordinate of momentum vector
const FWGeometry * getGeom() const