DenseIntVectSet& DenseIntVectSet::operator&=(const ProblemDomain& domain) { if (domain.domainBox().contains(m_domain)) { return *this; } IntVect chopSml = domain.domainBox().smallEnd(); IntVect chopBig = domain.domainBox().bigEnd(); if (domain.isPeriodic()) { for (int dir = 0; dir != SpaceDim; ++dir) { if (domain.isPeriodic(dir)) { chopSml[dir] = m_domain.smallEnd(dir); chopBig[dir] = m_domain.bigEnd(dir); } } } Box chopper(chopSml, chopBig); *this &= chopper; return *this; }
static char *guessMarkerType(struct slName *lineList, Chopper chopper, struct sqlConnection *conn, int colCount) /* Guess which type of marker type is being used. */ { struct markerTypeRecognizer *mtrList = getMarkerRecognizers(conn, colCount); struct markerTypeRecognizer *mtr, *bestMtr = NULL; int lineCount = 0, bestCount = 0; struct slName *el; char *type = NULL; /* Loop through sample lines keeping track of who recognizes markers. */ for (el = lineList; el != NULL; el = el->next) { char *s = cloneString(el->name); char *row[1]; chopper(s, row, ArraySize(row)); for (mtr = mtrList; mtr != NULL; mtr = mtr->next) { char query[512]; sqlSafef(query, sizeof(query), mtr->query, mtr->table, row[0]); if (sqlQuickNum(conn, query) > 0) mtr->matches += 1; } freeMem(s); ++lineCount; } /* Figure out who recognizes the most markers. */ for (mtr = mtrList; mtr != NULL; mtr = mtr->next) { if (mtr->matches > bestCount) { bestCount = mtr->matches; bestMtr = mtr; } } /* Return best type, so long as at least half are recognized */ if (bestCount > lineCount/2) type = bestMtr->type; slFreeList(&mtrList); return type; }
/** Executes the algorithm. Reading in the file and creating and populating * the output workspace * * @throw Exception::NotFoundError Error when saving the PoldiDeadWires Results data to Workspace * @throw std::runtime_error Error when saving the PoldiDeadWires Results data to Workspace */ void PoldiAutoCorrelation5::exec() { g_log.information() << "_Poldi start conf -------------- " << std::endl; /* From localWorkspace three things are used: * - Count data from POLDI experiment * - POLDI instrument definition * - Some data from the "Log" (for example chopper-speed) */ DataObjects::Workspace2D_sptr localWorkspace = this->getProperty("InputWorkspace"); g_log.information() << "_Poldi ws loaded -------------- " << std::endl; double wlen_min = this->getProperty("wlenmin"); double wlen_max = this->getProperty("wlenmax"); double chopperSpeed = 0.0; try { chopperSpeed = localWorkspace->run().getPropertyValueAsType<std::vector<double> >("chopperspeed").front(); } catch(std::invalid_argument&) { throw(std::runtime_error("Chopper speed could not be extracted from Workspace '" + localWorkspace->name() + "'. Aborting.")); } // Instrument definition Instrument_const_sptr poldiInstrument = localWorkspace->getInstrument(); // Chopper configuration PoldiChopperFactory chopperFactory; boost::shared_ptr<PoldiAbstractChopper> chopper(chopperFactory.createChopper(std::string("default-chopper"))); chopper->loadConfiguration(poldiInstrument); chopper->setRotationSpeed(chopperSpeed); g_log.information() << "____________________________________________________ " << std::endl; g_log.information() << "_Poldi chopper conf ------------------------------ " << std::endl; g_log.information() << "_Poldi - Chopper speed: " << chopper->rotationSpeed() << " rpm" << std::endl; g_log.information() << "_Poldi - Number of slits: " << chopper->slitPositions().size() << std::endl; g_log.information() << "_Poldi - Cycle time: " << chopper->cycleTime() << " µs" << std::endl; g_log.information() << "_Poldi - Zero offset: " << chopper->zeroOffset() << " µs" << std::endl; g_log.information() << "_Poldi - Distance: " << chopper->distanceFromSample() << " mm" << std::endl; if(g_log.is(Poco::Message::PRIO_DEBUG)) { for(size_t i = 0; i < chopper->slitPositions().size(); ++i) { g_log.information() << "_Poldi - Slits: " << i << ": Position = " << chopper->slitPositions()[i] << "\t Time = " << chopper->slitTimes()[i] << " µs" << std::endl; } } // Detector configuration PoldiDetectorFactory detectorFactory; boost::shared_ptr<PoldiAbstractDetector> detector(detectorFactory.createDetector(std::string("helium3-detector"))); detector->loadConfiguration(poldiInstrument); g_log.information() << "_Poldi detector conf ------------------------------ " << std::endl; g_log.information() << "_Poldi - Element count: " << detector->elementCount() << std::endl; g_log.information() << "_Poldi - Central element: " << detector->centralElement() << std::endl; g_log.information() << "_Poldi - 2Theta(central): " << detector->twoTheta(199) / M_PI * 180.0 << "°" << std::endl; g_log.information() << "_Poldi - Distance(central): " << detector->distanceFromSample(199) << " mm" << std::endl; boost::shared_ptr<PoldiDeadWireDecorator> cleanDetector(new PoldiDeadWireDecorator(poldiInstrument, detector)); std::set<int> deadWires = cleanDetector->deadWires(); g_log.information() << "_Poldi - Number of dead wires: " << deadWires.size() << std::endl; g_log.information() << "_Poldi - Wire indices: "; for(std::set<int>::const_iterator dw = deadWires.begin(); dw != deadWires.end(); ++dw) { g_log.information() << *dw << " "; } g_log.information() << std::endl; // putting together POLDI instrument for calculations m_core->setInstrument(cleanDetector, chopper); m_core->setWavelengthRange(wlen_min, wlen_max); try { Mantid::DataObjects::Workspace2D_sptr outputws = m_core->calculate(localWorkspace); setProperty("OutputWorkspace",boost::dynamic_pointer_cast<Workspace>(outputws)); } catch(Mantid::Kernel::Exception::NotFoundError& ) { throw std::runtime_error("Error when saving the PoldiIPP Results data to Workspace : NotFoundError"); } catch(std::runtime_error &) { throw std::runtime_error("Error when saving the PoldiIPP Results data to Workspace : runtime_error"); } }