Measurement* getMeasurement(bhep::hit& hit) { EVector hit_pos(2,0); EVector meas_pos(3,0); meas_pos[0] = hit.x()[0]; meas_pos[1] = hit.x()[1]; meas_pos[2] = hit.x()[2]; hit_pos[0] = meas_pos[0]; hit_pos[1] = meas_pos[1]; //covariance and meastype hardwired for now. EMatrix cov(2,2,0); cov[0][0] = 1.; cov[1][1] = 1.; string meastype = "xy"; Measurement* me = new Measurement(); me->set_name(meastype); me->set_hv(HyperVector(hit_pos,cov)); me->set_name("volume", "Detector"); me->set_position( meas_pos ); //Add the hit energy deposit as a key to the Measurement. const dict::Key Edep = "E_dep"; const dict::Key EdepVal = hit.data("E_dep"); me->set_name(Edep, EdepVal); return me; }
//-------------------------------------------------------------------- RP::State* KFSvcManager::SeedState(std::vector<double> v0, std::vector<double> p0) //-------------------------------------------------------------------- { State* state = new State(); // v0 is a guess of the position //p0 is a guess of the momentum log4cpp::Category& klog = log4cpp::Category::getRoot(); EVector v(fDim,0); EMatrix C(fDim,fDim,0); v[0] = v0[0]; // a guess of the x position v[1] = v0[1]; // a guess of the y position v[2] = v0[2]; // a guess of the z position v[3] = p0[0]/p0[2]; // a guess of dx/dz v[4] = p0[1]/p0[2]; // a guess of dy/dz klog << log4cpp::Priority::INFO << " Initial state --> " << v; double pmag = sqrt(p0[0]*p0[0] + p0[1]*p0[1] + p0[2]*p0[2]); double qoverp = -1./pmag; if (KFSetup::Instance().Model() =="helix" && KFSetup::Instance().FitMomentum()) { v[5]=qoverp; // assume forward fit! C[5][5]= 0.1; // not a large error like the others, momentum "known" // Set a qoverp HyperVector for use only in multiple scattering calculations. klog << log4cpp::Priority::INFO << " Helix model, set qoverp --> " << qoverp ; state->set_hv("MSqoverp",HyperVector(qoverp,0)); state->set_hv("MSdeltaqoverp",HyperVector(0.,0)); } else { // For the Straight line model q/p is a fix parameter use for MS computation klog << log4cpp::Priority::INFO << " Sline model, set qoverp --> " << qoverp ; state->set_hv(RP::qoverp,HyperVector(qoverp,0)); std::cout << "qoverp hypervector is " << state->hv(RP::qoverp).vector()[0] << std::endl; } // diagonal covariance matrix C[0][0] = C[1][1] = 0.1*cm; C[2][2] = EGeo::zero_cov()/2.; // no error on Z since planes are perpendicular to z //C[0][0] = C[1][1] = C[2][2] = 100.*cm; C[3][3] = C[4][4] = 1.; klog << log4cpp::Priority::INFO << " Cov matrix --> " << C ; // Set the main HyperVector klog << log4cpp::Priority::INFO << " Set the main HyperVector --> " ; state->set_hv(HyperVector(v,C)); // Set the sense HyperVector (1=increasing z) double sense=p0[2]/fabs(p0[2]); klog << log4cpp::Priority::INFO << " Set the sense HyperVector --> " << sense ; state->set_hv(RP::sense,HyperVector(sense,0)); // Set the model name klog << log4cpp::Priority::INFO << " Set the model name --> " << fModel ; state->set_name(fModel); // Set the representation (x,y,z dx/dz, dy/dz, q/p) klog << log4cpp::Priority::INFO << " Set the representation --> " ; if (KFSetup::Instance().Model() =="helix" && KFSetup::Instance().FitMomentum()) state->set_name(RP::representation,RP::slopes_curv_z); else state->set_name(RP::representation,RP::slopes_z); // Set the particle type to electron. state->set_name(RP::PID, "Electron"); return state; }
//-------------------------------------------------------------------- RP::Trajectory* KFSvcManager::CreateTrajectory(std::vector<const Hit* > hits, std::vector<double> hitErrors) //-------------------------------------------------------------------- { log4cpp::Category& klog = log4cpp::Category::getRoot(); klog << log4cpp::Priority::DEBUG << " In CreateTrajectory --> " ; klog << log4cpp::Priority::DEBUG << "Cov Matrix --> " ; EVector m(3,0); fCov = EMatrix(3,3,0); for (size_t i=0; i<3; ++i) { fCov[i][i] = hitErrors[i]; } klog << log4cpp::Priority::DEBUG << "Cov Matrix --> " << fCov; // destroy measurements in fMeas container //stc_tools::destroy(fMeas); RP::measurement_vector fMeas; auto size = hits.size(); klog << log4cpp::Priority::DEBUG << " size of hits --> " << size; klog << log4cpp::Priority::DEBUG << " fill measurement vector --> " << size; for(auto hit : hits) { m[0]=hit->XYZ().X(); m[1]=hit->XYZ().Y(); m[2]=hit->XYZ().Z(); klog << log4cpp::Priority::DEBUG << "+++hit x = " << m[0] << " y = " << m[1] << " z = " << m[2]; klog << log4cpp::Priority::DEBUG << "Create a measurement " ; Measurement* meas = new Measurement(); string type=RP::xyz; meas->set_name(type); // the measurement type meas->set_hv(HyperVector(m,fCov,type)); // the HyperVector meas->set_deposited_energy(hit->Edep()); // the deposited energy meas->set_name(RP::setup_volume,"mother"); // the volume // the position of the measurement klog << log4cpp::Priority::DEBUG << "Create measurement plane " ; meas->set_position_hv(HyperVector(m,EMatrix(3,3,0),RP::xyz)); // Add the measurement to the vector fMeas.push_back(meas); } // add the measurements to the trajectory klog << log4cpp::Priority::INFO << " Measurement vector created " ; Trajectory* trj = new Trajectory(); trj->add_constituents(fMeas); klog << log4cpp::Priority::INFO << " Trajectory --> " << *trj ; return trj; }