Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
  shared_ptr<Psana::Acqiris::ConfigV1> acqConfig = env.configStore().get("DetInfo(AmoITof:Acqiris)");
");

Matching Event Data to Configuration

In many cases user code is written to use source address match (or approximate address like "AmoITof.:Acqiris."). When it is necessary to find matching configuration object for an event object the approximate addresses (matches) cannot be used because approximate source match can find different devices in event and configuration store. In this case one has to use exact source address (Pds::Src or fully-specified Source) for either both or one of the objects. If exact source address is used for both types of objects one has to pass this address to both get() methods:

Code Block

// ==== ExampleModule.h ====
class ExampleModule: public Module {
public:
  .....
private:
  Source m_src;
};

// ==== ExampleModule.cpp ====
ExampleModule::ExampleModule(const std::string& name)
  : Module(name)
  , m_src("AmoITof.0:Acqiris.0") // fully-specified source
{
}

void ExampleModule::beginJob(Env& env) {
  shared_ptr<Psana::Acqiris::ConfigV1> acqConfig = env.configStore().get(m_src);
  ......
}

void ExampleModule::event(Event& evt, Env& env) {
  shared_ptr<Psana::Acqiris::DataDescV1> acqData = evt.get(m_src);
  ......
}

If exact source address is not known then one can still use matches for one get() but obtain exact address from the first get() and use it for the second one. There are two possible options here, first is to get exact address from configuration store:

Code Block

// ==== ExampleModule.h ====
class ExampleModule: public Module {
public:
  .....
private:
  Source m_srcMatch;
  Pds::Src m_src;
};

// ==== ExampleModule.cpp ====
ExampleModule::ExampleModule(const std::string& name)
  : Module(name)
  , m_srcMatch("AmoITof.*:Acqiris.*")  // matching address
  , m_src()
{
}

void ExampleModule::beginJob(Env& env) {
  // use match but obtain exact address
  shared_ptr<Psana::Acqiris::ConfigV1> acqConfig = env.configStore().get(m_srcMatch, &m_src);
  ......
}

void ExampleModule::event(Event& evt, Env& env) {
  // use exact address here
  shared_ptr<Psana::Acqiris::DataDescV1> acqData = evt.get(m_src);
  ......
}

Second option is to use match for getting event object and obtain exact address at the same time, then use exact address to get configuration object:

Code Block

// ==== ExampleModule.h ====
class ExampleModule: public Module {
public:
  .....
private:
  Source m_srcMatch;
};

// ==== ExampleModule.cpp ====
ExampleModule::ExampleModule(const std::string& name)
  : Module(name)
  , m_srcMatch("AmoITof.*:Acqiris.*")  // matching address
{
}

void ExampleModule::beginJob(Env& env) {
  ......
}

void ExampleModule::event(Event& evt, Env& env) {
  // use match but obtain exact address
  Pds::Src src;
  shared_ptr<Psana::Acqiris::DataDescV1> acqData = evt.get(m_srcMatch, "", &src);
  if (acqData.get()) {
    // use exact address here
    shared_ptr<Psana::Acqiris::ConfigV1> acqConfig = env.configStore().get(src);
  }
  ......
}

Latter code is less efficient because it searches for configuration object on every event which can be avoided if one uses first option.