// $Id$ // // File: DParticle_factory.cc // Created: Thu Sep 4 14:02:44 EDT 2008 // Creator: davidl (on Darwin harriet.jlab.org 8.11.1 i386) // #include #include using namespace std; #include "DParticle_factory.h" #include #include using namespace jana; //------------------ // init //------------------ jerror_t DParticle_factory::init(void) { fitter = NULL; return NOERROR; } //------------------ // brun //------------------ jerror_t DParticle_factory::brun(jana::JEventLoop *loop, int runnumber) { // Get pointer to TrackFitter object that actually fits a track vector fitters; loop->Get(fitters); if(fitters.size()<1){ _DBG_<<"Unable to get a DTrackFitter object! NO Charged track fitting will be done!"<(fitters[0]); // Warn user if something happened that caused us NOT to get a fitter object pointer if(!fitter){ _DBG_<<"Unable to get a DTrackFitter object! NO Charged track fitting will be done!"< tracks; loop->Get(tracks); // Loop over candidates for(unsigned int i=0; i cdchits; vector fdchits; track->Get(cdchits); track->Get(fdchits); // Setup fitter to do fit fitter->Reset(); fitter->AddHits(cdchits); fitter->AddHits(fdchits); fitter->SetFitType(DTrackFitter::kTimeBased); // We need to create our own DKinematicData object so we can set the mass DKinematicData input_params(*track); input_params.setMass(0.13957018); // Use only pion assumption for now // Do the fit DTrackFitter::fit_status_t status = fitter->FitTrack(input_params); switch(status){ case DTrackFitter::kFitNotDone: _DBG_<<"Fitter returned kFitNotDone. This should never happen!!"<GetDMagneticFieldMap())); DReferenceTrajectory *rt = rtv[_data.size()]; DParticle *particle = new DParticle; // Copy over DKinematicData part DKinematicData *track_kd = particle; *track_kd = fitter->GetFitParameters(); rt->Swim(particle->position(), particle->momentum(), particle->charge()); particle->rt = rt; particle->chisq = fitter->GetChisq(); particle->Ndof = fitter->GetNdof(); particle->trackid = track->id; // Add hits used as associated objects const vector &cdchits = fitter->GetCDCFitHits(); const vector &fdchits = fitter->GetFDCFitHits(); for(unsigned int i=0; iAddAssociatedObject(cdchits[i]); for(unsigned int i=0; iAddAssociatedObject(fdchits[i]); // Add DTrack object as associate object particle->AddAssociatedObject(track); _data.push_back(particle); }