// Author: David Lawrence June 25, 2004 // // // MyProcessor.cc // #include #include #include using namespace std; #include #include #include #include #include #include #include #include #include #include "hdview2.h" #include "hdv_mainframe.h" #include "MyProcessor.h" #include "TRACKING/DTrackHit_factory.h" #include "TRACKING/DQuickFit.h" #include "TRACKING/DMagneticFieldStepper.h" #include "TRACKING/DTrackCandidate_factory.h" #include "TRACKING/DMCTrackHit.h" #include "TRACKING/DMCThrown.h" #include "TRACKING/DTrack.h" #include "TRACKING/DReferenceTrajectory.h" #include "JANA/JGeometry.h" #include "TRACKING/DMCTrajectoryPoint.h" #include "FCAL/DFCALHit.h" #include "FDC/DFDCGeometry.h" #include "CDC/DCDCTrackHit.h" #include "FDC/DFDCPseudo.h" extern hdv_mainframe *hdvmf; MyProcessor *gMYPROC=NULL; //------------------------------------------------------------------ // MyProcessor //------------------------------------------------------------------ MyProcessor::MyProcessor() { Bfield = NULL; loop = NULL; // Tell factory to keep around a few density histos //gPARMS->SetParameter("TRKFIND:MAX_DEBUG_BUFFERS", 16); gMYPROC = this; } //------------------------------------------------------------------ // ~MyProcessor //------------------------------------------------------------------ MyProcessor::~MyProcessor() { } //------------------------------------------------------------------ // init //------------------------------------------------------------------ jerror_t MyProcessor::init(void) { // Make sure detectors have been drawn //if(!drew_detectors)DrawDetectors(); vector loops = app->GetJEventLoops(); if(loops.size()>0){ vector facnames; loops[0]->GetFactoryNames(facnames); hdvmf = new hdv_mainframe(gClient->GetRoot(), 1000, 600); hdvmf->SetTrackFactories(facnames); hdvmf->SetCandidateFactories(facnames); hdvmf->SetReconstructedFactories(facnames); } return NOERROR; } //------------------------------------------------------------------ // brun //------------------------------------------------------------------ jerror_t MyProcessor::brun(JEventLoop *eventloop, int runnumber) { // Read in Magnetic field map DApplication* dapp = dynamic_cast(eventloop->GetJApplication()); Bfield = dapp->GetBfield(); return NOERROR; } //------------------------------------------------------------------ // evnt //------------------------------------------------------------------ jerror_t MyProcessor::evnt(JEventLoop *eventLoop, int eventnumber) { if(!eventLoop)return NOERROR; loop = eventLoop; last_jevent.FreeEvent(); last_jevent = loop->GetJEvent(); cout<<"----------- New Event "<SetEvent(eventnumber); hdvmf->DoRedraw(); return NOERROR; } //------------------------------------------------------------------ // FillGraphics //------------------------------------------------------------------ void MyProcessor::FillGraphics(void) { /// Create "graphics" objects for this event given the current GUI settings. /// /// This method will create DGraphicSet objects that represent tracks, hits, /// and showers for the event. It creates objects for both hits and /// reconstructed entities. The "graphics" objects created here are /// really just collections of 3D space points with flags indicating /// whether they should be drawn as markers or lines and with what /// color and size. The actual graphics objects are created for the /// various views of the detector in hdv_mainframe. graphics.clear(); if(!loop)return; // FCAL hits if(hdvmf->GetCheckButton("fcal")){ vector fcalhits; loop->Get(fcalhits); for(unsigned int i=0; iGetFCALPolyLine(hit->x, hit->y); if(!poly)continue; double a = hit->E/0.25; double f = sqrt(a>1.0 ? 1.0:a<0.0 ? 0.0:a); double grey = 0.8; double s = 1.0 - f; float r = s*grey; float g = s*grey; float b = f*(1.0-grey) + grey; poly->SetFillColor(TColor::GetColor(r,g,b)); } } // CDC hits if(hdvmf->GetCheckButton("cdc")){ vector cdctrackhits; loop->Get(cdctrackhits); for(unsigned int i=0; iwire; DGraphicSet gset(kCyan, kLine, 1.0); gset.points.push_back(wire->origin-(wire->L/2.0)*wire->udir); gset.points.push_back(wire->origin+(wire->L/2.0)*wire->udir); graphics.push_back(gset); } } // FDC wire if(hdvmf->GetCheckButton("fdcwire")){ vector fdcpseudos; loop->Get(fdcpseudos); for(unsigned int i=0; iwire; // Wire DGraphicSet gset(kCyan, kLine, 1.0); gset.points.push_back(wire->origin-(wire->L/2.0)*wire->udir); gset.points.push_back(wire->origin+(wire->L/2.0)*wire->udir); graphics.push_back(gset); } } // FDC psuedo hits if(hdvmf->GetCheckButton("fdcpseudo")){ vector fdcpseudos; loop->Get(fdcpseudos); DGraphicSet gsetp(38, kMarker, 0.5); for(unsigned int i=0; iwire; // Pseudo point TVector3 pos(fdcpseudos[i]->x, fdcpseudos[i]->y, wire->origin.Z()); gsetp.points.push_back(pos); } graphics.push_back(gsetp); } // DMCThrown if(hdvmf->GetCheckButton("thrown")){ vector mcthrown; loop->Get(mcthrown); for(unsigned int i=0; iGetCheckButton("cdctruth")){ vector mctrackhits; loop->Get(mctrackhits); DGraphicSet gset(12, kMarker, 0.5); for(unsigned int i=0; isystem != SYS_CDC)continue; TVector3 pos(hit->r*cos(hit->phi), hit->r*sin(hit->phi), hit->z); gset.points.push_back(pos); } graphics.push_back(gset); } // FDC Truth points if(hdvmf->GetCheckButton("fdctruth")){ vector mctrackhits; loop->Get(mctrackhits); DGraphicSet gset(12, kMarker, 0.5); for(unsigned int i=0; isystem != SYS_FDC)continue; TVector3 pos(hit->r*cos(hit->phi), hit->r*sin(hit->phi), hit->z); gset.points.push_back(pos); } graphics.push_back(gset); } // TOF Truth points if(hdvmf->GetCheckButton("toftruth")){ vector mctrackhits; loop->Get(mctrackhits); DGraphicSet gset(kBlack, kMarker, 0.5); for(unsigned int i=0; isystem != SYS_TOF)continue; TVector3 pos(hit->r*cos(hit->phi), hit->r*sin(hit->phi), hit->z); gset.points.push_back(pos); } graphics.push_back(gset); } // BCAL Truth points if(hdvmf->GetCheckButton("bcaltruth")){ vector mctrackhits; loop->Get(mctrackhits); DGraphicSet gset(kBlack, kMarker, 1.0); for(unsigned int i=0; isystem != SYS_BCAL)continue; TVector3 pos(hit->r*cos(hit->phi), hit->r*sin(hit->phi), hit->z); gset.points.push_back(pos); } graphics.push_back(gset); } // FCAL Truth points if(hdvmf->GetCheckButton("fcaltruth")){ vector mctrackhits; loop->Get(mctrackhits); DGraphicSet gset(kBlack, kMarker, 1.0); for(unsigned int i=0; isystem != SYS_FCAL)continue; TVector3 pos(hit->r*cos(hit->phi), hit->r*sin(hit->phi), hit->z); gset.points.push_back(pos); } graphics.push_back(gset); } // DMCTrajectoryPoints if(hdvmf->GetCheckButton("trajectories")){ vector mctrajectorypoints; loop->Get(mctrajectorypoints); DGraphicSet gset(kBlack, kLine, 1.5); for(unsigned int i=0; ix, pt->y, pt->z); gset.points.push_back(v); } graphics.push_back(gset); } // DTrackCandidate if(hdvmf->GetCheckButton("candidates")){ vector trackcandidates; loop->Get(trackcandidates, hdvmf->GetFactoryTag("DTrackCandidate")); for(unsigned int i=0; iGetCheckButton("tracks")){ vector tracks; loop->Get(tracks, hdvmf->GetFactoryTag("DTrack")); for(unsigned int i=0; iposition(), kd->momentum(), kd->charge()); // Create a new graphics set and fill it with all of the trajectory points DGraphicSet gset(color, kLine, size); DReferenceTrajectory::swim_step_t *step = rt.swim_steps; for(int i=0; iorigin); } // Push the graphics set onto the stack graphics.push_back(gset); }