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 ...@@ -105,7 +105,7 @@ namespace DataObjects
Peak & getPeak(int peakNum); Peak & getPeak(int peakNum);
const Peak & getPeak(int peakNum) const; const Peak & getPeak(int peakNum) const;
API::IPeak* createPeak(Kernel::V3D QLabFrame, double detectorDistance=1.0) 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(); std::vector<Peak> & getPeaks();
const std::vector<Peak> & getPeaks() const; const std::vector<Peak> & getPeaks() const;
virtual bool hasIntegratedPeaks() const; virtual bool hasIntegratedPeaks() const;
......
...@@ -238,141 +238,166 @@ namespace Mantid ...@@ -238,141 +238,166 @@ namespace Mantid
* Returns selected information for a "peak" at QLabFrame. * 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 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. * @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 * each element is a pair of description of information and the string form for the corresponding
* value. * 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())); std::pair<std::string, std::string> QMag("|Q|", boost::lexical_cast<std::string>(QFrame.norm()));
Result.push_back( QMag ); Result.push_back(QMag);
std::pair< std::string,std::string > dspc( "d-spacing", boost::lexical_cast<std::string>(2.0*M_PI/QLabFrame.norm())); std::pair<std::string, std::string> dspc("d-spacing",
Result.push_back( dspc); boost::lexical_cast<std::string>(2.0 * M_PI / QFrame.norm()));
Result.push_back(dspc);
int seqNum = -1;
bool hasOneRunNumber = true;
int runNum = -1;
double minDist = 10000000;
std::pair< std::string,std::string > Qlab("Qlab",boost::lexical_cast<std::string>(QLabFrame)); for (int i = 0; i < getNumberPeaks(); i++)
Result.push_back(Qlab); {
Peak pk = getPeak(i);
try{ V3D Q = pk.getQLabFrame();
API::IPeak* peak = createPeak( QLabFrame); if (!lab_coords)
int seqNum=-1; Q = pk.getQSampleFrame();
bool hasOneRunNumber = true; double D = QFrame.distance(Q);
int runNum = -1; if (D < minDist)
double minDist= 10000000;
for( int i = 0; i < getNumberPeaks() ; i++ )
{ {
Peak pk = getPeak(i); minDist = D;
double D = QLabFrame.distance(pk.getQLabFrame() ); seqNum = i + 1;
if( D < minDist)
{
minDist = D;
seqNum = i+1;
}
int run= pk.getRunNumber();
if( runNum <0)
runNum =run;
else if( runNum != run)
hasOneRunNumber = false;
} }
if( hasOneRunNumber) int run = pk.getRunNumber();
{ if (runNum < 0)
std::pair< std::string,std::string > runn( "RunNumber", boost::lexical_cast<std::string>(runNum)); runNum = run;
Result.push_back(runn); else if (runNum != run)
const Kernel::DblMatrix GonRconst= run().getGoniometerMatrix(); hasOneRunNumber = false;
Kernel::Matrix<double> GonR(GonRconst); }
Kernel::Matrix<double>ident(3,3);
ident.identityMatrix();
V3D QSamp;
if( !(GonR ==ident))
{
Kernel::Matrix<double> InvGon( GonR); V3D Qlab = QFrame;
InvGon.Invert(); V3D Qsamp;
QSamp = InvGon *QLabFrame; Kernel::Matrix<double> Gon(3, 3, true);
if (seqNum >= 0)
Gon = getPeak(seqNum).getGoniometerMatrix();
if (lab_coords)
{
std::pair< std::string,std::string > Qsamp("QSample",boost::lexical_cast<std::string>(QSamp)); Kernel::Matrix<double> InvGon(Gon);
Result.push_back(Qsamp); InvGon.Invert();
Qsamp = InvGon * Qlab;
}else }
QSamp = QLabFrame; else
{
Qsamp = QFrame;
Qlab = Gon * Qsamp;
}
if( sample().hasOrientedLattice()) if (lab_coords || seqNum >= 0)
{
const Geometry::OrientedLattice & lat =(sample().getOrientedLattice()); {
std::pair<std::string, std::string> QlabStr("Qlab", boost::lexical_cast<std::string>(Qlab));
Result.push_back(QlabStr);
}
const Kernel::Matrix<double> &UB0 = lat.getUB(); if (!lab_coords || seqNum >= 0)
Kernel::Matrix<double> UB ( UB0); {
UB.Invert();
V3D hkl = UB*QSamp/2/M_PI;
std::pair< std::string,std::string > HKL("HKL", boost::lexical_cast<std::string>(hkl)); std::pair<std::string, std::string> QsampStr("QSample", boost::lexical_cast<std::string>(Qsamp));
Result.push_back( HKL ); Result.push_back(QsampStr);
}
} try
{
API::IPeak* peak = createPeak(Qlab);
//------- Now get phi, chi and omega ---------------- if (sample().hasOrientedLattice())
Geometry::Goniometer Gon( GonR); {
std::vector<double>OmegaChiPhi= Gon.getEulerAngles("YZY");
Kernel::V3D PhiChiOmega( OmegaChiPhi[2],OmegaChiPhi[1],OmegaChiPhi[0]);
std::pair< std::string,std::string > GRead( "Goniometer Angles",boost::lexical_cast<std::string>(PhiChiOmega)); peak->setGoniometerMatrix(Gon);
Result.push_back( GRead ); const Geometry::OrientedLattice & lat = (sample().getOrientedLattice());
} 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 > SeqNum( "Sequence Num",boost::lexical_cast<std::string>(seqNum)); std::pair<std::string, std::string> HKL("HKL", boost::lexical_cast<std::string>(hkl));
Result.push_back( SeqNum ); Result.push_back(HKL);
std::pair< std::string,std::string > wl( "Wavelength", boost::lexical_cast<std::string>(peak->getWavelength())); }
Result.push_back( wl );
if( peak->findDetector()) if (hasOneRunNumber)
{ {
V3D detPos = peak->getDetPos(); std::pair<std::string, std::string> runn("RunNumber",
std::pair< std::string,std::string > detpos( "Position(x,y,z)", boost::lexical_cast<std::string>(peak->getDetPos())); boost::lexical_cast<std::string>(runNum));
Result.push_back( detpos ); Result.push_back(runn);
}
std::pair< std::string,std::string > tof( "TOF", boost::lexical_cast<std::string>(peak->getTOF())); //------- Now get phi, chi and omega ----------------
Result.push_back( tof ); 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())); std::pair<std::string, std::string> GRead("Goniometer Angles",
Result.push_back( Energy ); 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())); std::pair<std::string, std::string> SeqNum("Sequence Num",
Result.push_back( row ); 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())); if (peak->findDetector())
Result.push_back( col ); {
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() ); std::pair<std::string, std::string> Energy("Energy",
Result.push_back( bank ); 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() )); std::pair<std::string, std::string> row("Row",
Result.push_back( scat ); 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 Result;
} }
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
/** Return a reference to the Peaks vector */ /** Return a reference to the Peaks vector */
std::vector<Peak> & PeaksWorkspace::getPeaks() std::vector<Peak> & PeaksWorkspace::getPeaks()
......
...@@ -875,7 +875,7 @@ std::vector< std::pair<std::string,std::string> >MantidEVWorker::PointInfo( cons ...@@ -875,7 +875,7 @@ std::vector< std::pair<std::string,std::string> >MantidEVWorker::PointInfo( cons
const auto& ADS = AnalysisDataService::Instance(); const auto& ADS = AnalysisDataService::Instance();
Mantid::DataObjects::PeaksWorkspace_sptr peaks_ws = ADS.retrieveWS<Mantid::DataObjects::PeaksWorkspace>(peaks_ws_name); 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 } // 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