Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to more easily use the UniqueIDGenSvc with Functional algorithms #268

Open
tmadlener opened this issue Dec 18, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@tmadlener
Copy link
Contributor

Currently our UniqueIDGenSvc is already working with the Functional algorithms, but it requires a bit of setup to get there. I think in some cases this also makes it necessary to change the flavor of the functional, e.g. (as will become apparent soon), it's not possible to have a Producer, instead one would need a Transformer.

What is possible at the moment is this

class UniqueIDGenSvcTransfomer final
    : k4FWCore::Transformer<podio::UserDataCollection<int64_t>(const edm4hep::EventHeaderCollection&)> {
public:
  UniqueIDGenSvcTransfomer(const std::string& name, ISvcLocator* svcLoc)
      : Transformer(name, svcLoc, {KeyValues("EventHeaderCollection", {"EventHeader"})},
                    {KeyValues("OutputCollection", {"seeds"})}) {}

  StatusCode initialize() final {
    m_uniqueIDSvc = serviceLocator()->service("UniqueIDGenSvc");
    return StatusCode::SUCCESS;
  }

  podio::UserDataCollection<int64_t> operator()(const edm4hep::EventHeaderCollection& evtHeader) const final {
    // we need the event header here to get to the event and run number.
    const auto evt = evtHeader[0];
    auto       uid = m_uniqueIDSvc->getUniqueID(evt.getEventNumber(), evt.getRunNumber(), name());

    auto coll = podio::UserDataCollection<int64_t>();
    coll.push_back(uid);
    return coll;
  }

private:
  SmartIF<IUniqueIDGenSvc> m_uniqueIDSvc{nullptr};
};

I am wondering if it's possible to make this a bit cleaner, i.e. such that getUniqueID() could be done without arguments in which case it would just get the event and run number from somewhere (potentially another service?).

@tmadlener tmadlener added the enhancement New feature or request label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant