diff --git a/Code/Mantid/Framework/DataObjects/src/Peak.cpp b/Code/Mantid/Framework/DataObjects/src/Peak.cpp index cbafd4067c4530a6d6d96cb754fe2f4ac875fd9d..5cf0ed7394e91ad609176f87b24a0000663921c1 100644 --- a/Code/Mantid/Framework/DataObjects/src/Peak.cpp +++ b/Code/Mantid/Framework/DataObjects/src/Peak.cpp @@ -528,69 +528,72 @@ namespace DataObjects */ bool Peak::findDetector() { - // Scattered beam direction - V3D oldDetPos = detPos; - V3D beam = detPos - samplePos; - beam.normalize(); - - // Create a ray tracer - InstrumentRayTracer tracker( m_inst ); - tracker.traceFromSample(beam); - IDetector_const_sptr det = tracker.getDetectorResult(); - if (det) - { - // Set the detector ID, the row, col, etc. - this->setDetectorID(det->getID()); - // The old detector position is not more precise if it comes from FindPeaksMD - detPos = det->getPos(); - return true; - } - else //fix for gaps between tubes - { - double gap = 0.00065; - V3D beam1 = beam + V3D(gap,0.,0.); - tracker.traceFromSample(beam1); - IDetector_const_sptr det1 = tracker.getDetectorResult(); - V3D beam2 = beam + V3D(-gap,0.,0.); - tracker.traceFromSample(beam2); - IDetector_const_sptr det2 = tracker.getDetectorResult(); - if (det1 && det2) - { - // Set the detector ID, the row, col, etc. - this->setDetectorID(static_cast<int>((det1->getID()+det2->getID())*0.5));; - detPos = (det1->getPos() + det2->getPos())*0.5; - std::cout <<static_cast<int>((det1->getID()+det2->getID())*0.5) << " x gap\n"; - return true; - } - beam1 = beam + V3D(0.,gap,0.); - tracker.traceFromSample(beam1); - det1 = tracker.getDetectorResult(); - beam2 = beam + V3D(0.,-gap,0.); - tracker.traceFromSample(beam2); - det2 = tracker.getDetectorResult(); - if (det1 && det2) - { - // Set the detector ID, the row, col, etc. - this->setDetectorID(static_cast<int>((det1->getID()+det2->getID())*0.5));; - detPos = (det1->getPos() + det2->getPos())*0.5; - std::cout <<static_cast<int>((det1->getID()+det2->getID())*0.5) << " y gap\n"; - return true; - } - beam1 = beam + V3D(0.,0.,gap); - tracker.traceFromSample(beam1); - det1 = tracker.getDetectorResult(); - beam2 = beam + V3D(0.,0.,-gap); - tracker.traceFromSample(beam2); - det2 = tracker.getDetectorResult(); - if (det1 && det2) - { - // Set the detector ID, the row, col, etc. - this->setDetectorID(static_cast<int>((det1->getID()+det2->getID())*0.5));; - detPos = (det1->getPos() + det2->getPos())*0.5; - std::cout <<static_cast<int>((det1->getID()+det2->getID())*0.5) << " z gap\n"; - return true; - } - } + // Scattered beam direction + V3D oldDetPos = detPos; + V3D beam = detPos - samplePos; + beam.normalize(); + + // Create a ray tracer + InstrumentRayTracer tracker( m_inst ); + tracker.traceFromSample(beam); + IDetector_const_sptr det = tracker.getDetectorResult(); + if (det) + { + // Set the detector ID, the row, col, etc. + this->setDetectorID(det->getID()); + // The old detector position is not more precise if it comes from FindPeaksMD + detPos = det->getPos(); + return true; + } + //fix for gaps between tubes + else if (m_inst->hasParameter("tube-gap")) + { + std::vector<double> gaps = m_inst->getNumberParameter("tube-gap", true); + if (gaps.empty()) return false; + const double gap = static_cast<double>(gaps.front()); + V3D beam1 = beam + V3D(0.,0.,gap); + tracker.traceFromSample(beam1); + IDetector_const_sptr det1 = tracker.getDetectorResult(); + V3D beam2 = beam + V3D(0.,0.,-gap); + tracker.traceFromSample(beam2); + IDetector_const_sptr det2 = tracker.getDetectorResult(); + if (det1 && det2) + { + // Set the detector ID, the row, col, etc. + this->setDetectorID(static_cast<int>((det1->getID()+det2->getID())*0.5));; + detPos = (det1->getPos() + det2->getPos())*0.5; + std::cout <<gap<<" "<<static_cast<int>((det1->getID()+det2->getID())*0.5) << " z gap\n"; + return true; + } + beam1 = beam + V3D(gap,0.,0.); + tracker.traceFromSample(beam1); + det1 = tracker.getDetectorResult(); + beam2 = beam + V3D(-gap,0.,0.); + tracker.traceFromSample(beam2); + det2 = tracker.getDetectorResult(); + if (det1 && det2) + { + // Set the detector ID, the row, col, etc. + this->setDetectorID(static_cast<int>((det1->getID()+det2->getID())*0.5));; + detPos = (det1->getPos() + det2->getPos())*0.5; + std::cout <<gap<<" "<<static_cast<int>((det1->getID()+det2->getID())*0.5) << " x gap\n"; + return true; + } + beam1 = beam + V3D(0.,gap,0.); + tracker.traceFromSample(beam1); + det1 = tracker.getDetectorResult(); + beam2 = beam + V3D(0.,-gap,0.); + tracker.traceFromSample(beam2); + det2 = tracker.getDetectorResult(); + if (det1 && det2) + { + // Set the detector ID, the row, col, etc. + this->setDetectorID(static_cast<int>((det1->getID()+det2->getID())*0.5));; + detPos = (det1->getPos() + det2->getPos())*0.5; + std::cout <<gap<<" "<<static_cast<int>((det1->getID()+det2->getID())*0.5) << " y gap\n"; + return true; + } + } return false; } diff --git a/Code/Mantid/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp b/Code/Mantid/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp index 11bee7adaf1fdbc86a22229150975ecf086aab1f..e778e8ab44d341d4d3f14282cad952070be96222 100644 --- a/Code/Mantid/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp +++ b/Code/Mantid/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp @@ -587,7 +587,6 @@ namespace MDAlgorithms */ bool IntegratePeaksMD2::detectorQ(Mantid::Kernel::V3D QLabFrame, double r) { - double kmax=100.; std::vector<detid_t> detectorIDs = inst->getDetectorIDs(); for (auto detID = detectorIDs.begin(); detID != detectorIDs.end(); ++detID) @@ -597,7 +596,7 @@ namespace MDAlgorithms if( !det->isMasked() ) continue;// edge is masked so don't check if not masked double tt1=det->getTwoTheta(V3D(0,0,0),V3D(0,0,1)); //two theta double ph1=det->getPhi(); //phi - V3D E1=V3D(-kmax*std::sin(tt1)*std::cos(ph1),-kmax*std::sin(tt1)*std::sin(ph1),kmax-kmax*std::cos(tt1)); //end of trajectory + V3D E1=V3D(-std::sin(tt1)*std::cos(ph1),-std::sin(tt1)*std::sin(ph1),1.-std::cos(tt1)); //end of trajectory E1=E1*(1./E1.norm()); //normalize V3D distv=QLabFrame-E1*(QLabFrame.scalar_prod(E1)); //distance to the trajectory as a vector if(distv.norm()<r) diff --git a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/MaskBTP.py b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/MaskBTP.py index 8dea47ab8c63b152e86c85c1131b4b55fff71444..17921a342437992be1e4d82cc5b1eaef54db56b5 100644 --- a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/MaskBTP.py +++ b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/MaskBTP.py @@ -49,7 +49,7 @@ class MaskBTP(mantid.api.PythonAlgorithm): instrumentList=["ARCS","CNCS","CORELLI","HYSPEC","NOMAD","POWGEN","SEQUOIA","SNAP","TOPAZ","WISH"] self.bankmin={"ARCS":1,"CNCS":1,"CORELLI":1,"HYSPEC":1,"NOMAD":1,"POWGEN":1,"SEQUOIA":38,"SNAP":1,"TOPAZ":10,"WISH":1} - self.bankmax={"ARCS":115,"CNCS":50,"CORELLI":91,"HYSPEC":20,"NOMAD":99,"POWGEN":300,"SEQUOIA":150,"SNAP":18,"TOPAZ":59,"WISH":5} + self.bankmax={"ARCS":115,"CNCS":50,"CORELLI":91,"HYSPEC":20,"NOMAD":99,"POWGEN":300,"SEQUOIA":150,"SNAP":18,"TOPAZ":59,"WISH":10} tubemin={"ARCS":1,"CNCS":1,"CORELLI":1,"HYSPEC":1,"NOMAD":1,"POWGEN":0,"SEQUOIA":1,"SNAP":0,"TOPAZ":0,"WISH":1} tubemax={"ARCS":8,"CNCS":8,"CORELLI":16,"HYSPEC":8,"NOMAD":8,"POWGEN":153,"SEQUOIA":8,"SNAP":255,"TOPAZ":255,"WISH":152} pixmin={"ARCS":1,"CNCS":1,"CORELLI":1,"HYSPEC":1,"NOMAD":1,"POWGEN":0,"SEQUOIA":1,"SNAP":0,"TOPAZ":0,"WISH":1} @@ -175,8 +175,10 @@ class MaskBTP(mantid.api.PythonAlgorithm): raise ValueError("Out of range index for "+str(self.instname)+" instrument bank numbers") elif self.instname=="WISH": if (self.bankmin[self.instname]<=banknum<= self.bankmax[self.instname]): - print "panel"+"%02d" % banknum - return self.instrument.getComponentByName("panel"+"%02d" % banknum)[0] + try: + return self.instrument.getComponentByName("panel"+"%02d" % banknum)[0] + except: + return None else: raise ValueError("Out of range index for "+str(self.instname)+" instrument bank numbers") else: diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp b/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp index 3c89ed9415b559cf8d0d26c7235433690184810f..e648af6e75dc3f6678ef711212da1b604adb90bd 100644 --- a/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp +++ b/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp @@ -481,7 +481,8 @@ namespace WorkflowAlgorithms maskAlg->setProperty("Workspace", m_outputW); maskAlg->setProperty("MaskedWorkspace", m_maskWS); maskAlg->executeAsChildAlg(); - m_outputW = maskAlg->getProperty("Workspace"); + Workspace_sptr tmpW = maskAlg->getProperty("Workspace"); + m_outputW =boost::dynamic_pointer_cast<MatrixWorkspace>(tmpW); } m_progress->report(); diff --git a/Code/Mantid/instrument/CORELLI_Parameters.xml b/Code/Mantid/instrument/CORELLI_Parameters.xml new file mode 100644 index 0000000000000000000000000000000000000000..ddf9701b1f49270092ba3d2890ed8d8832822335 --- /dev/null +++ b/Code/Mantid/instrument/CORELLI_Parameters.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<parameter-file instrument = "CORELLI" valid-from = "2014-02-25 00:00:00"> + + <component-link name = "CORELLI"> + + <!-- Specify the gap between the tubes for Peak::findDetector --> + <parameter name="tube-gap"> + <value val="0.00065"/> + </parameter> + + </component-link> + +</parameter-file> + diff --git a/Code/Mantid/instrument/WISH_Parameters.xml b/Code/Mantid/instrument/WISH_Parameters.xml index 09c45dbaae21347dca31254a89122318df3a64ca..b14a5057845ecf15df2caf6bffc4ea6ef6ef1fc9 100644 --- a/Code/Mantid/instrument/WISH_Parameters.xml +++ b/Code/Mantid/instrument/WISH_Parameters.xml @@ -23,5 +23,10 @@ <value val="Always" /> </parameter> + <!-- Specify the gap between the tubes for Peak::findDetector --> + <parameter name="tube-gap"> + <value val="0.0003"/> + </parameter> + </component-link> </parameter-file>