Пример #1
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;
 }
Пример #2
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 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;
 }
Пример #3
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;
}