/** * Return the confidence with with this algorithm can load the file * @param descriptor A descriptor for the file * @returns An integer specifying the confidence level. 0 indicates it will not * be used */ int LoadSassena::confidence(Kernel::NexusDescriptor &descriptor) const { if (descriptor.hasRootAttr("sassena_version") || descriptor.pathExists("/qvectors")) { return 99; } return 0; }
/** * Return the confidence with with this algorithm can load the file * @param descriptor A descriptor for the file * @returns An integer specifying the confidence level. 0 indicates it will not be used */ int LoadMcStas::confidence(Kernel::NexusDescriptor & descriptor) const { using namespace ::NeXus; // We will look at the first entry and check for a // simulation class that contains a name attribute with the value=mcstas int confidence(0); try { ::NeXus::File file = ::NeXus::File(descriptor.filename()); auto entries = file.getEntries(); if(!entries.empty()) { auto firstIt = entries.begin(); file.openGroup(firstIt->first,firstIt->second); file.openGroup("simulation", "NXnote"); std::string nameAttrValue; file.readData("name", nameAttrValue); if(boost::iequals(nameAttrValue, "mccode")) confidence = 98; file.closeGroup(); file.closeGroup(); } } catch(::NeXus::Exception&) { } return confidence; }
/** * Return the confidence with with this algorithm can load the file * @param descriptor A descriptor for the file * @returns An integer specifying the confidence level. 0 indicates it will not be used */ int LoadSINQFocus::confidence(Kernel::NexusDescriptor & descriptor) const { // fields existent only at the SINQ (to date Loader only valid for focus) if (descriptor.pathExists("/entry1/FOCUS/SINQ") ){ return 80; } else { return 0; } }
/** * Return the confidence with with this algorithm can load the file * @param descriptor A descriptor for the file * @returns An integer specifying the confidence level. 0 indicates it will not * be used */ int LoadMuonNexus2::confidence(Kernel::NexusDescriptor &descriptor) const { const auto &firstEntryNameType = descriptor.firstEntryNameType(); const std::string root = "/" + firstEntryNameType.first; if (!descriptor.pathExists(root + "/definition")) return 0; bool upperIDF(true); if (descriptor.pathExists(root + "/IDF_version")) upperIDF = true; else { if (descriptor.pathExists(root + "/idf_version")) upperIDF = false; else return 0; } try { std::string versionField = "idf_version"; if (upperIDF) versionField = "IDF_version"; auto &file = descriptor.data(); file.openPath(root + "/" + versionField); int32_t version = 0; file.getData(&version); if (version != 2) return 0; file.openPath(root + "/definition"); std::string def = file.getStrData(); if (def == "muonTD" || def == "pulsedTD") { // If all this succeeded then we'll assume this is an ISIS Muon NeXus file // version 2 return 81; } } catch (...) { } return 0; }
/** * Return the confidence with with this algorithm can load the file * @param descriptor A descriptor for the file * @returns An integer specifying the confidence level. 0 indicates it will not * be used */ int LoadMcStas::confidence(Kernel::NexusDescriptor &descriptor) const { using namespace ::NeXus; // look at to see if entry1/simulation/name exist first and then // if its value = mccode int confidence(0); if(descriptor.pathExists("/entry1/simulation/name")) { try { // need to look inside file to check value of entry1/simulation/name ::NeXus::File file = ::NeXus::File(descriptor.filename()); file.openGroup( descriptor.firstEntryNameType().first, descriptor.firstEntryNameType().second); file.openGroup("simulation", "NXnote"); std::string value; // check if entry1/simulation/name equals mccode file.readData("name", value); if (boost::iequals(value, "mccode")) confidence = 98; file.closeGroup(); file.closeGroup(); } catch (::NeXus::Exception &) { } } return confidence; }
/** * Return the confidence with with this algorithm can load the file * @param descriptor A descriptor for the file * @returns An integer specifying the confidence level. 0 indicates it will not be used */ int LoadNXSPE::confidence(Kernel::NexusDescriptor & descriptor) const { int confidence(0); typedef std::map<std::string,std::string> string_map_t; try { ::NeXus::File file = ::NeXus::File(descriptor.filename()); string_map_t entries = file.getEntries(); for(string_map_t::const_iterator it = entries.begin(); it != entries.end(); ++it) { if (it->second == "NXentry") { file.openGroup(it->first, it->second); file.openData("definition"); if (file.getStrData().compare("NXSPE")==0) confidence =99; } } } catch(::NeXus::Exception&) { } return confidence; }