ATLAS Offline Software
Loading...
Searching...
No Matches
EventHashBranch.cxx
Go to the documentation of this file.
1
2/*
3 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4*/
7namespace MuonVal {
8
9EventHashBranch::EventHashBranch(TTree* tree, const std::string& evtKey):
10 m_cache{tree, "CommonEventHash", 2},
11 m_evtKey{evtKey} {}
12bool EventHashBranch::init() {return m_cache.init() && m_evtKey.initialize();}
13std::string EventHashBranch::name() const {return m_cache.name();}
14std::vector<EventHashBranch::DataDependency> EventHashBranch::data_dependencies() {
15 return {&m_evtKey};
16}
17TTree* EventHashBranch::tree() {return m_cache.tree();}
18const TTree*EventHashBranch::tree() const {return m_cache.tree();}
19bool EventHashBranch::fill(const EventContext& ctx) {
21 if (!evtInfo.isValid()){
22 MsgStream log(Athena::getMessageSvc(), name());
23 log << MSG::ERROR << "Could not retrieve the EventInfo " << m_evtKey.fullKey() << endmsg;
24 return false;
25 }
26 m_cache[0] = evtInfo->eventNumber();
27 if (evtInfo->eventType(xAOD::EventInfo::IS_SIMULATION)) {
28 ULong64_t dsid = evtInfo->mcChannelNumber();
29 dsid = ( (dsid<<32) | evtInfo->runNumber());
30 m_cache[1] = dsid;
31 } else m_cache[1] = evtInfo->runNumber();
32 m_last_dump = &ctx;
33 return m_cache.fill(ctx);
34}
35bool EventHashBranch::is_dumped(const EventContext& ctx ) const{
36 return &ctx == m_last_dump;
37}
38}
#define endmsg
Handle class for reading from StoreGate.
ArrayBranch< ULong64_t > m_cache
TTree * tree() override final
Returns the pointer to the underlying TTree object.
std::string name() const override final
Returns the name of the branch.
bool fill(const EventContext &ctx) override final
The fill method checks if enough information is provided such that the branch is cleared from the inf...
EventHashBranch(TTree *tree, const std::string &evtKey="EventInfo")
bool is_dumped(const EventContext &ctx) const
Returns true whether the current event is dumped to the N-tuple or not.
const EventContext * m_last_dump
bool init() override final
The init method checks whether the branch name has already registered to the MuonTree and tries then ...
std::vector< DataDependency > data_dependencies() override final
Returns a vector of all Event data dependencies needed by the Branch to work.
SG::ReadHandleKey< xAOD::EventInfo > m_evtKey
virtual bool isValid() override final
Can the handle be successfully dereferenced?
@ IS_SIMULATION
true: simulation, false: data
IMessageSvc * getMessageSvc(bool quiet=false)
Class to store array like branches into the n-tuples.
Definition HitValAlg.cxx:19