1 #include "TEveBoxSet.h"
3 #include "TEveTrackPropagator.h"
4 #include "TEveCompound.h"
5 #include "TEveStraightLineSet.h"
6 #include "TEveProjectionBases.h"
24 const std::string cname(
"particleFlowRecHitHCALUpgrade");
26 void addLineToLineSet(TEveStraightLineSet*
ls,
const float*
p,
int i1,
int i2) {
32 void addBoxAsLines(TEveStraightLineSet* lineset,
const float*
p) {
33 for (
int l = 0;
l < 5;
l += 4) {
34 addLineToLineSet(lineset,
p, 0 +
l, 1 +
l);
35 addLineToLineSet(lineset,
p, 1 +
l, 2 +
l);
36 addLineToLineSet(lineset,
p, 2 +
l, 3 +
l);
37 addLineToLineSet(lineset,
p, 3 +
l, 0 +
l);
39 for (
int l = 0;
l < 4; ++
l)
40 addLineToLineSet(lineset,
p, 0 +
l, 4 +
l);
43 void editLineInLineSet(TEveChunkManager::iterator& li,
const float*
p,
int i1,
int i2) {
44 TEveStraightLineSet::Line_t&
line = *(TEveStraightLineSet::Line_t*)li();
47 for (
int i = 0;
i < 3; ++
i) {
55 void editBoxInLineSet(TEveChunkManager::iterator& li,
const float*
p) {
56 for (
int i = 0;
i < 5;
i += 4) {
57 editLineInLineSet(li,
p, 0 +
i, 1 +
i);
59 editLineInLineSet(li,
p, 1 +
i, 2 +
i);
60 editLineInLineSet(li,
p, 2 +
i, 3 +
i);
61 editLineInLineSet(li,
p, 3 +
i, 0 +
i);
63 for (
int i = 0;
i < 4; ++
i)
64 editLineInLineSet(li,
p, 0 +
i, 4 +
i);
70 TEveElementList* product,
80 for (reco::PFCandidateCollection::const_iterator it =
candidates->begin(), itEnd =
candidates->end(); it != itEnd;
93 t.fV = TEveVector(
cand.vertex().x(),
cand.vertex().y(),
cand.vertex().z());
94 t.fSign =
cand.charge();
95 TEveTrack* trk =
new TEveTrack(&
t,
context().getTrackPropagator());
122 <<
": Failed to access collection with name " << cname <<
"." << std::endl;
126 <<
": Failed to access collection with name " << cname <<
"." << std::endl;
132 const float* corners,
float scale,
bool plotEt, std::vector<float>& scaledCorners,
const reco::PFRecHit*) {
133 static TEveVector vtmp;
134 vtmp.Set(0.
f, 0.
f, 0.
f);
135 for (
unsigned int i = 0;
i < 24;
i += 3) {
136 vtmp[0] += corners[
i];
137 vtmp[1] += corners[
i + 1];
138 vtmp[2] += corners[
i + 2];
143 scale *= vtmp.Perp() / vtmp.Mag();
147 for (
unsigned int i = 0;
i < 24;
i += 3) {
148 scaledCorners[
i] = vtmp[0] + (corners[
i] - vtmp[0]) *
scale;
149 scaledCorners[
i + 1] = vtmp[1] + (corners[
i + 1] - vtmp[1]) *
scale;
150 scaledCorners[
i + 2] = vtmp[2] + (corners[
i + 2] - vtmp[2]) *
scale;
157 if (it->detId() == candIdx) {
168 std::vector<float> scaledCorners(24);
171 for (TEveElement::List_i
i =
parent->BeginChildren();
i !=
parent->EndChildren(); ++
i) {
172 if ((*i)->NumChildren() > 1) {
173 TEveElement::List_i
xx = (*i)->BeginChildren();
175 TEveBoxSet* boxset = dynamic_cast<TEveBoxSet*>(*
xx);
177 TEveStraightLineSet* lineset = dynamic_cast<TEveStraightLineSet*>(*
xx);
178 TEveChunkManager::iterator li(lineset->GetLinePlex());
181 TEveChunkManager* plex = boxset->GetPlex();
183 for (
int atomIdx = 0; atomIdx < plex->Size(); ++atomIdx) {
184 TEveBoxSet::BFreeBox_t* atom = (TEveBoxSet::BFreeBox_t*)boxset->GetPlex()->Atom(atomIdx);
188 memcpy(atom->fVertices, &scaledCorners[0],
sizeof(atom->fVertices));
190 editBoxInLineSet(li, &scaledCorners[0]);
193 for (TEveProjectable::ProjList_i
p = lineset->BeginProjecteds();
p != lineset->EndProjecteds(); ++
p) {
194 TEveStraightLineSetProjected* projLineSet = (TEveStraightLineSetProjected*)(*
p);
195 projLineSet->UpdateProjection();
203 TString boxset_tooltip_callback(TEveDigitSet* ds, Int_t
idx) {
204 void* ud = ds->GetUserData(
idx);
209 return TString::Format(
"RecHit %d energy '%f'",
idx,
hit->energy());
222 TEveBoxSet* boxset =
nullptr;
223 TEveStraightLineSet* lineset =
nullptr;
225 for (
unsigned elIdx = 0; elIdx < eleInBlocks.size(); elIdx++) {
231 unsigned indexInBlock = eleInBlocks[elIdx].second;
239 if (myBlock->elements()[indexInBlock].type() == 5)
240 ieHCAL = indexInBlock;
242 std::vector<float> scaledCorners(24);
247 if (myCluster.get()) {
248 const std::vector<std::pair<DetId, float> >& hitsandfracs = myCluster->
hitsAndFractions();
251 boxset =
new TEveBoxSet();
252 boxset->Reset(TEveBoxSet::kBT_FreeBox,
true, hitsandfracs.size());
253 boxset->SetAntiFlick(
true);
254 boxset->SetAlwaysSecSelect(
true);
255 boxset->SetPickable(
true);
256 boxset->SetTooltipCBFoo(boxset_tooltip_callback);
260 lineset =
new TEveStraightLineSet();
263 bool hitsFound =
false;
264 for (
int ihandf = 0, lastIdx = (
int)(hitsandfracs.size()); ihandf < lastIdx; ihandf++) {
265 unsigned int hitDetId = hitsandfracs[ihandf].first;
270 boxset->AddBox(&scaledCorners[0]);
272 boxset->DigitColor(holder->GetMainColor());
273 boxset->DigitUserData((
void*)
hit);
274 addBoxAsLines(lineset, &scaledCorners[0]);
287 "Can't find matching hits with for HCAL block %d in %s collection. Number of hits %d.\n",
290 (
int)hitsandfracs.size());
310 "PFCandidatesWithHits",