Skip to content

Commit

Permalink
refs #4201 Different small bugfixes
Browse files Browse the repository at this point in the history
1) Kind of crude spectra-detector map selects valid spectra.
2) mixed numbers for direct and indirect modes.
3) Dangling pointer to the unit conversion in one of the coordinate transformation macro
  • Loading branch information
abuts committed Dec 9, 2011
1 parent 5092f0a commit 7c30cb5
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ namespace MDAlgorithms
*/
enum AnalMode{
Elastic = 0, //< int emode = 0; Elastic analysis
Indir = 1, //< emode=1; InDirect inelastic analysis mode
Direct = 2, //< emode=2; Direct inelastic analysis mode
Direct = 1, //< emode=1; Direct inelastic analysis mode
Indir = 2, //< emode=2; InDirect inelastic analysis mode
ANY_Mode //< couples with NoQ, means just copying existing data (may be douing units conversion)
};
/// enum describes if there is need to convert workspace units and different units conversion modes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,22 @@ ConvertToMDEvents::processQND(API::IMDEventWorkspace *const piWS)

const size_t specSize = inWS2D->blocksize();
std::vector<coord_t> Coord(nd);
size_t nValidSpectra = det_loc.det_id.size();


if(!trn.calcGenericVariables(Coord,nd))return; // if any property dimension is outside of the data range requested
//External loop over the spectra:
for (int64_t i = 0; i < int64_t(numSpec); ++i)
for (int64_t i = 0; i < int64_t(nValidSpectra); ++i)
{

const MantidVec& X = inWS2D->readX(i);
const MantidVec& Signal = inWS2D->readY(i);
const MantidVec& Error = inWS2D->readE(i);
size_t ic = det_loc.detIDMap[i];
int32_t det_id = det_loc.det_id[i];

if(!trn.calcYDepCoordinates(Coord,i))continue; // skip y outsize of the range;
const MantidVec& X = inWS2D->readX(ic);
const MantidVec& Signal = inWS2D->readY(ic);
const MantidVec& Error = inWS2D->readE(ic);


if(!trn.calcYDepCoordinates(Coord,ic))continue; // skip y outsize of the range;

//=> START INTERNAL LOOP OVER THE "TIME"
for (size_t j = 0; j < specSize; ++j)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct UNITS_CONVERSION<ConvFromTOF>
}
// get units class, requested by subalgorithm
std::string native_units = ConvertToMDEvents::getNativeUnitsID(pHost);
Kernel::Unit_sptr pWSUnit = Kernel::UnitFactory::Instance().create(native_units);
pWSUnit = Kernel::UnitFactory::Instance().create(native_units);
if(!pWSUnit){
throw(std::logic_error(" can not retrieve workspace unit from the units factory"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ namespace MDAlgorithms
std::vector<double> L2;
std::vector<double> TwoTheta;
std::vector<int32_t> det_id; // the detector ID;
std::vector<size_t> detIDMap;
//
bool is_defined(void)const{return det_dir.size()>0;}
bool is_defined(size_t new_size)const{return det_dir.size()==new_size;}
double * pL2(){return &L2[0];}
double * pTwoTheta(){return &TwoTheta[0];}
size_t * iDetIDMap(){return &detIDMap[0];}
Kernel::V3D * pDetDir(){return &det_dir[0];}
};
class DLLExport ConvertToQ3DdE : public API::Algorithm
Expand Down
8 changes: 6 additions & 2 deletions Code/Mantid/Framework/MDAlgorithms/src/ConvertToMDEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ ConvertToMDEvents::process_detectors_positions(const DataObjects::Workspace2D_co
det_loc.det_id.resize(nHist);
det_loc.L2.resize(nHist);
det_loc.TwoTheta.resize(nHist);
det_loc.detIDMap.resize(nHist);
// Loop over the spectra
size_t ic(0);
for (size_t i = 0; i < nHist; i++){
Expand All @@ -302,8 +303,10 @@ ConvertToMDEvents::process_detectors_positions(const DataObjects::Workspace2D_co
// Check that we aren't dealing with monitor...
if (spDet->isMonitor())continue;

det_loc.det_id[ic] = spDet->getID();
det_loc.L2[ic] = spDet->getDistance(*sample);
det_loc.det_id[ic] = spDet->getID();
det_loc.detIDMap[ic]= i;
det_loc.L2[ic] = spDet->getDistance(*sample);


double polar = inputWS->detectorTwoTheta(spDet);
det_loc.TwoTheta[ic]= polar;
Expand All @@ -326,6 +329,7 @@ ConvertToMDEvents::process_detectors_positions(const DataObjects::Workspace2D_co
det_loc.det_id.resize(ic);
det_loc.L2.resize(ic);
det_loc.TwoTheta.resize(ic);
det_loc.detIDMap.resize(ic);
}

}
Expand Down
6 changes: 5 additions & 1 deletion Code/Mantid/Framework/MDAlgorithms/src/ConvertToQ3DdE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ ConvertToQ3DdE::process_detectors_positions(const DataObjects::Workspace2D_const

det_loc.det_dir.resize(nHist);
det_loc.det_id.resize(nHist);
det_loc.detIDMap.resize(nHist);
// Loop over the spectra
const Geometry::ISpectraDetectorMap & spm = inputWS->spectraMap();
size_t ic(0);
Expand All @@ -121,7 +122,9 @@ ConvertToQ3DdE::process_detectors_positions(const DataObjects::Workspace2D_const
// Check that we aren't dealing with monitor...
if (spDet->isMonitor())continue;

det_loc.det_id[ic] = spDet->getID();
det_loc.det_id[ic] = spDet->getID();
det_loc.detIDMap[ic]= i;

// dist = spDet->getDistance(*sample);
double polar = inputWS->detectorTwoTheta(spDet);
double azim = spDet->getPhi();
Expand All @@ -141,6 +144,7 @@ ConvertToQ3DdE::process_detectors_positions(const DataObjects::Workspace2D_const
if(ic<nHist){
det_loc.det_dir.resize(ic);
det_loc.det_id.resize(ic);
det_loc.detIDMap.resize(ic);
}
}
//----------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 7c30cb5

Please sign in to comment.