Commit 9753283a authored by Ruth Mikkelson's avatar Ruth Mikkelson
Browse files

Refs #6805 Incorporated boolean for selected Q type(lab/sample)

Also, more info will now be given based on peak in workspace closes to given peak.
parent 7e66cbc6
......@@ -105,7 +105,7 @@ namespace DataObjects
Peak & getPeak(int peakNum);
const Peak & getPeak(int peakNum) const;
API::IPeak* createPeak(Kernel::V3D QLabFrame, double detectorDistance=1.0) const;
std::vector<std::pair<std::string,std::string> > PeakInfo(Kernel::V3D QLabFrame ) const;
std::vector<std::pair<std::string,std::string> > PeakInfo(Kernel::V3D QLabFrame , bool lab_coords) const;
std::vector<Peak> & getPeaks();
const std::vector<Peak> & getPeaks() const;
virtual bool hasIntegratedPeaks() const;
......
......@@ -238,141 +238,166 @@ namespace Mantid
* Returns selected information for a "peak" at QLabFrame.
*
* @param QLabFrame a postion in Q-space. A peak does not have to be at that position
* @param lab_coords
* @return a vector whose elements contain different information about the "peak" at that position.
* each element is a pair of description of information and the string form for the corresponding
* value.
*/
std::vector<std::pair<std::string,std::string> >PeaksWorkspace::PeakInfo(Kernel::V3D QLabFrame ) const
std::vector<std::pair<std::string, std::string> > PeaksWorkspace::PeakInfo(Kernel::V3D QFrame,
bool lab_coords) const
{
std::vector<std::pair< std::string,std::string > > Result;
std::vector<std::pair<std::string, std::string> > Result;
std::pair< std::string,std::string > QMag( "|Q|", boost::lexical_cast<std::string>(QLabFrame.norm()));
Result.push_back( QMag );
std::pair<std::string, std::string> QMag("|Q|", boost::lexical_cast<std::string>(QFrame.norm()));
Result.push_back(QMag);
std::pair< std::string,std::string > dspc( "d-spacing", boost::lexical_cast<std::string>(2.0*M_PI/QLabFrame.norm()));
Result.push_back( dspc);
std::pair<std::string, std::string> dspc("d-spacing",
boost::lexical_cast<std::string>(2.0 * M_PI / QFrame.norm()));
Result.push_back(dspc);
std::pair< std::string,std::string > Qlab("Qlab",boost::lexical_cast<std::string>(QLabFrame));
Result.push_back(Qlab);
try{
API::IPeak* peak = createPeak( QLabFrame);
int seqNum=-1;
int seqNum = -1;
bool hasOneRunNumber = true;
int runNum = -1;
double minDist= 10000000;
double minDist = 10000000;
for( int i = 0; i < getNumberPeaks() ; i++ )
for (int i = 0; i < getNumberPeaks(); i++)
{
Peak pk = getPeak(i);
double D = QLabFrame.distance(pk.getQLabFrame() );
if( D < minDist)
V3D Q = pk.getQLabFrame();
if (!lab_coords)
Q = pk.getQSampleFrame();
double D = QFrame.distance(Q);
if (D < minDist)
{
minDist = D;
seqNum = i+1;
seqNum = i + 1;
}
int run= pk.getRunNumber();
if( runNum <0)
runNum =run;
else if( runNum != run)
int run = pk.getRunNumber();
if (runNum < 0)
runNum = run;
else if (runNum != run)
hasOneRunNumber = false;
}
if( hasOneRunNumber)
{
std::pair< std::string,std::string > runn( "RunNumber", boost::lexical_cast<std::string>(runNum));
Result.push_back(runn);
const Kernel::DblMatrix GonRconst= run().getGoniometerMatrix();
Kernel::Matrix<double> GonR(GonRconst);
Kernel::Matrix<double>ident(3,3);
ident.identityMatrix();
V3D QSamp;
if( !(GonR ==ident))
V3D Qlab = QFrame;
V3D Qsamp;
Kernel::Matrix<double> Gon(3, 3, true);
if (seqNum >= 0)
Gon = getPeak(seqNum).getGoniometerMatrix();
if (lab_coords)
{
Kernel::Matrix<double> InvGon( GonR);
Kernel::Matrix<double> InvGon(Gon);
InvGon.Invert();
QSamp = InvGon *QLabFrame;
Qsamp = InvGon * Qlab;
std::pair< std::string,std::string > Qsamp("QSample",boost::lexical_cast<std::string>(QSamp));
Result.push_back(Qsamp);
}else
QSamp = QLabFrame;
if( sample().hasOrientedLattice())
}
else
{
Qsamp = QFrame;
Qlab = Gon * Qsamp;
}
const Geometry::OrientedLattice & lat =(sample().getOrientedLattice());
if (lab_coords || seqNum >= 0)
const Kernel::Matrix<double> &UB0 = lat.getUB();
Kernel::Matrix<double> UB ( UB0);
UB.Invert();
V3D hkl = UB*QSamp/2/M_PI;
{
std::pair<std::string, std::string> QlabStr("Qlab", boost::lexical_cast<std::string>(Qlab));
Result.push_back(QlabStr);
}
std::pair< std::string,std::string > HKL("HKL", boost::lexical_cast<std::string>(hkl));
Result.push_back( HKL );
if (!lab_coords || seqNum >= 0)
{
std::pair<std::string, std::string> QsampStr("QSample", boost::lexical_cast<std::string>(Qsamp));
Result.push_back(QsampStr);
}
//------- Now get phi, chi and omega ----------------
Geometry::Goniometer Gon( GonR);
std::vector<double>OmegaChiPhi= Gon.getEulerAngles("YZY");
Kernel::V3D PhiChiOmega( OmegaChiPhi[2],OmegaChiPhi[1],OmegaChiPhi[0]);
try
{
API::IPeak* peak = createPeak(Qlab);
std::pair< std::string,std::string > GRead( "Goniometer Angles",boost::lexical_cast<std::string>(PhiChiOmega));
Result.push_back( GRead );
if (sample().hasOrientedLattice())
{
}
peak->setGoniometerMatrix(Gon);
const Geometry::OrientedLattice & lat = (sample().getOrientedLattice());
std::pair< std::string,std::string > SeqNum( "Sequence Num",boost::lexical_cast<std::string>(seqNum));
Result.push_back( SeqNum );
const Kernel::Matrix<double> &UB0 = lat.getUB();
Kernel::Matrix<double> UB(UB0);
UB.Invert();
V3D hkl = UB * Qsamp / 2 / M_PI;
std::pair< std::string,std::string > wl( "Wavelength", boost::lexical_cast<std::string>(peak->getWavelength()));
Result.push_back( wl );
std::pair<std::string, std::string> HKL("HKL", boost::lexical_cast<std::string>(hkl));
Result.push_back(HKL);
if( peak->findDetector())
}
if (hasOneRunNumber)
{
V3D detPos = peak->getDetPos();
std::pair< std::string,std::string > detpos( "Position(x,y,z)", boost::lexical_cast<std::string>(peak->getDetPos()));
Result.push_back( detpos );
std::pair<std::string, std::string> runn("RunNumber",
boost::lexical_cast<std::string>(runNum));
Result.push_back(runn);
}
std::pair< std::string,std::string > tof( "TOF", boost::lexical_cast<std::string>(peak->getTOF()));
Result.push_back( tof );
//------- Now get phi, chi and omega ----------------
Geometry::Goniometer GonG(Gon);
std::vector<double> OmegaChiPhi = GonG.getEulerAngles("YZY");
Kernel::V3D PhiChiOmega(OmegaChiPhi[2], OmegaChiPhi[1], OmegaChiPhi[0]);
std::pair< std::string,std::string > Energy( "Energy", boost::lexical_cast<std::string>(peak->getFinalEnergy()));
Result.push_back( Energy );
std::pair<std::string, std::string> GRead("Goniometer Angles",
boost::lexical_cast<std::string>(PhiChiOmega));
Result.push_back(GRead);
std::pair< std::string,std::string > row( "Row", boost::lexical_cast<std::string>(peak->getRow()));
Result.push_back( row );
std::pair<std::string, std::string> SeqNum("Sequence Num",
boost::lexical_cast<std::string>(seqNum));
Result.push_back(SeqNum);
std::pair<std::string, std::string> wl("Wavelength",
boost::lexical_cast<std::string>(peak->getWavelength()));
Result.push_back(wl);
std::pair< std::string,std::string > col( "Col", boost::lexical_cast<std::string>(peak->getCol()));
Result.push_back( col );
if (peak->findDetector())
{
V3D detPos = peak->getDetPos();
std::pair<std::string, std::string> detpos("Position(x,y,z)",
boost::lexical_cast<std::string>(peak->getDetPos()));
Result.push_back(detpos);
std::pair<std::string, std::string> tof("TOF",
boost::lexical_cast<std::string>(peak->getTOF()));
Result.push_back(tof);
std::pair< std::string,std::string > bank( "Bank",peak->getBankName() );
Result.push_back( bank );
std::pair<std::string, std::string> Energy("Energy",
boost::lexical_cast<std::string>(peak->getFinalEnergy()));
Result.push_back(Energy);
std::pair< std::string,std::string > scat( "Scattering Angle",boost::lexical_cast<std::string>(peak->getScattering() ));
Result.push_back( scat );
std::pair<std::string, std::string> row("Row",
boost::lexical_cast<std::string>(peak->getRow()));
Result.push_back(row);
std::pair<std::string, std::string> col("Col",
boost::lexical_cast<std::string>(peak->getCol()));
Result.push_back(col);
std::pair<std::string, std::string> bank("Bank", peak->getBankName());
Result.push_back(bank);
std::pair<std::string, std::string> scat("Scattering Angle",
boost::lexical_cast<std::string>(peak->getScattering()));
Result.push_back(scat);
}
}catch(...)//Impossible position
} catch (...) //Impossible position
{
}
return Result;
}
//---------------------------------------------------------------------------------------------
/** Return a reference to the Peaks vector */
std::vector<Peak> & PeaksWorkspace::getPeaks()
......
......@@ -875,7 +875,7 @@ std::vector< std::pair<std::string,std::string> >MantidEVWorker::PointInfo( cons
const auto& ADS = AnalysisDataService::Instance();
Mantid::DataObjects::PeaksWorkspace_sptr peaks_ws = ADS.retrieveWS<Mantid::DataObjects::PeaksWorkspace>(peaks_ws_name);
return peaks_ws->PeakInfo( Q );
return peaks_ws->PeakInfo( Q , lab_coords);
}
} // namespace CustomInterfaces
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment