14 #include <boost/bind.hpp>
22 #include <TEveManager.h>
23 #include <TEveTrackPropagator.h>
24 #include <TEveTrack.h>
25 #include <TEvePointSet.h>
26 #include <TEveElement.h>
27 #include <TEveCaloData.h>
29 #include <TEveQuadSet.h>
30 #include <TEveTrans.h>
36 #include <ktracker/SRecEvent.h>
39 #include <pheve_display/PHEveDisplay.h>
56 _reco_tracks =
new TEveTrackList(
"Svtx Tracks");
59 TEveRGBAPalette *pal =
new TEveRGBAPalette(0, 100,
true,
true,
true);
61 _hit_wires[i] =
new TEveQuadSet(std::to_string(i).c_str());
62 _hit_wires[i]->SetOwnIds(kTRUE);
64 _hit_wires[i]->Reset(TEveQuadSet::kQT_LineXYFixedZ,
true, 32);
65 _hit_wires[i]->RefitPlex();
66 _hit_wires[i]->SetPickable(
true);
67 TEveTrans& t = _hit_wires[i]->RefMainTrans();
100 std::cout <<
"mTrkEveDisplay - event() begins." << std::endl;
105 if(verbosity > 0)
LogInfo(
"draw_hits()");
108 if(verbosity > 0)
LogInfo(
"draw_tracks()");
110 }
catch (std::exception& e) {
111 static bool first(
true);
113 std::cout <<
"mTrkEveDisplay::event Exception: " << e.what() << std::endl;
129 _sqhit_col = findNode::getClass<SQHitVector>(topNode,
"SQHitVector");
130 if(!_sqhit_col) std::cout<<
"SQHitVector node not found!!"<<std::endl;
131 if(verbosity) std::cout<<
"mTrkEveDisplay - SQHitVector nodes found."<<std::endl;
133 _recEvent = findNode::getClass<SRecEvent>(topNode,
"SRecEvent");
134 if(!_recEvent) std::cout<<
"SRecEvent node not found!!"<<std::endl;
135 if(verbosity) std::cout<<
"mTrkEveDisplay - SRecEvent nodes found."<<std::endl;
140 if (!_geom_svc)
return -1;
147 double n[2] = {cos_theta, sin_theta};
152 double vc[2] = {xc, yc};
161 if(fabs(n[0])<0.01) {
162 y1 = (pos + xc*n[0] + yc*n[1] - x1*n[0])/n[1];
163 y2 = (pos + xc*n[0] + yc*n[1] - x2*n[0])/n[1];
165 x1 = (pos + xc*n[0] + yc*n[1] - y1*n[1])/n[0];
166 x2 = (pos + xc*n[0] + yc*n[1] - y2*n[1])/n[0];
191 if(verbosity > 1)
LogInfo(
"!hit");
201 <<
"mTrkEveDisplay::draw_hits: {"
202 << det_id <<
", " << elm_id <<
"} "
207 if(verbosity > 2)
LogInfo(det_id);
211 int ret_code =
hit_to_wire(det_id, elm_id, x, y, dx, dy);
213 if(verbosity > 1)
LogInfo(
"hit_to_wire failed");
217 const float geom_limit = 1000;
219 !(fabs(x) < geom_limit) or
220 !(fabs(y) < geom_limit) or
221 !(fabs(dx) < geom_limit) or
222 !(fabs(dy) < geom_limit)
224 if(verbosity > 2)
LogInfo(
" {" << x <<
", " << y <<
", " << dx <<
", " << dy <<
"}");
230 <<
"mTrkEveDisplay::draw_hits: {"
231 << det_id <<
", " << elm_id <<
"} => "
232 <<
" {" << x <<
", " << y <<
", " << dx <<
", " << dy <<
"}"
236 _hit_wires[det_id]->AddLine(x, y, dx, dy);
238 _hit_wires[det_id]->QuadId(
new TNamed(Form(
"%d",elm_id),
"element id"));
240 if(det_id<31) _hit_wires[det_id]->DigitColor(kBlue);
241 else if(det_id<47) _hit_wires[det_id]->DigitColor(kGreen);
242 else if(det_id<55) _hit_wires[det_id]->DigitColor(kRed);
243 else if(det_id<63) _hit_wires[det_id]->DigitColor(kMagenta);
244 }
catch (std::exception &e ) {
245 std::cout <<
"Exception caught mTrkEveDisplay::draw_hits " << e.what() << std::endl;
265 std::map<int, int> hitID_ihit;
267 for(
int ihit=0; ihit<_sqhit_col->
size(); ++ihit) {
268 SQHit *hit = _sqhit_col->
at(ihit);
270 hitID_ihit[hitID] = ihit;
273 for(
int itrack=0; itrack<_recEvent->
getNTracks(); ++itrack){
276 TEveRecTrackT<double>* eve_rec_trk =
new TEveRecTrackT<double>();
286 eve_rec_trk->fV.Set(vx, vy, vz);
287 eve_rec_trk->fP.Set(px, py, pz);
290 std::cout <<
"--------- itrack: " << itrack <<
" ---------"<< std::endl;
292 <<
" { " << vx <<
"," << vy <<
"," << vz <<
" } "
293 <<
" { " << px <<
"," << py <<
"," << pz <<
" } "
300 eve_rec_trk->fV.Set(rec_vtx.x(), rec_vtx.y(), rec_vtx.z());
301 eve_rec_trk->fP.Set(rec_mom.x(), rec_mom.y(), rec_mom.z());
303 eve_rec_trk->fSign = charge;
304 TEveTrack* trk =
new TEveTrack(eve_rec_trk, _prop);
305 trk->SetSmooth(kTRUE);
308 trk->SetLineColor(kYellow);
312 trk->SetLineColor(kCyan);
314 trk->SetLineWidth(1);
316 for (
int iz = -1; iz<26; ++iz) {
321 trk->AddPathMark(TEvePathMarkD(
322 TEvePathMarkD::kDaughter,
355 trk->SetRnrPoints(kTRUE);
356 trk->SetMarkerStyle(1);
357 trk->SetMarkerSize(1);
359 trk->SetMarkerColor(kYellow);
361 trk->SetMarkerColor(kCyan);
365 std::cout <<
"mTrkEveDisplay - track made. " << std::endl;
366 _reco_tracks->AddElement(trk);
373 if(fabs(pid)==211 || fabs(pid)==321 || fabs(pid)==11 || fabs(pid)==13 || fabs(pid)==15 || fabs(pid)==17)
return true;
375 if (pid == 0)
return true;
383 _prop->IncDenyDestroy();
387 _hit_wires[i]->Reset(TEveQuadSet::kQT_LineXYFixedZ,
true, 32);
388 _hit_wires[i]->RefitPlex();
389 TEveTrans& t = _hit_wires[i]->RefMainTrans();
392 _reco_tracks->DestroyElements();
Int_t getNTracks()
Get tracks.
void get_nodes(PHCompositeNode *topNode)
double getSintheta(int detectorID) const
std::vector< SQHit * >::const_iterator ConstIter
TEveElementList * get_dc_list() const
void getExpPositionFast(Double_t z, Double_t &x, Double_t &y, Int_t iNode=-1)
bool event(PHCompositeNode *topNode)
An SQ interface class to hold one detector hit.
virtual ConstIter end() const
mTrkEveDisplay(boost::shared_ptr< PHEveDisplay >)
TEveElementList * get_top_list() const
void end(PHCompositeNode *topNode)
void init(PHCompositeNode *topNode)
int get_verbosity() const
int hit_to_wire(const int det, const int elm, double &x, double &y, double &dx, double &dy)
TEveTrackPropagator * get_cnt_prop() const
virtual const SQHit * at(const size_t idkey) const
Double_t getPositionSt1(Double_t &x, Double_t &y) const
virtual short get_detector_id() const
Return the detector ID of this hit.
TEveManager * _evemanager
TEveElementList * get_hodo_list() const
SRecTrack & getTrack(Int_t i)
TEveElementList * get_prop_list() const
double getCostheta(int detectorID) const
static GeomSvc * instance()
singlton instance
virtual size_t size() const
void init_run(PHCompositeNode *topNode)
virtual int get_hit_id() const
Return the ID of this hit.
int getDetectorID(const std::string &detectorName) const
Get the plane position.
double getPlaneCenterZ(int detectorID)
Plane getPlane(int detectorID) const
void getMeasurement(int detectorID, int elementID, double &measurement, double &dmeasurement)
Convert the detectorID and elementID to the actual hit position.
Int_t getCharge() const
Gets.
virtual short get_element_id() const
Return the element ID of this hit.
virtual ConstIter begin() const
TEveManager * get_eve_manager() const
Return a pointer to the underlying TEveManager.
Double_t getMomentumSt1(Double_t &px, Double_t &py, Double_t &pz) const
TEveElementList * get_dp_list() const