Helper Functions¶
-
namespace HelperFunctions¶
Enums
-
enum ShowerType¶
The different supported shower types.
Values:
-
enumerator Unknown¶
-
enumerator Pythia8¶
-
enumerator Herwig7p1¶
-
enumerator Herwig7p2¶
-
enumerator Sherpa221¶
-
enumerator Sherpa2210¶
-
enumerator Sherpa2212¶
-
enumerator AmcPy8¶
-
enumerator AmcH7¶
-
enumerator Pythia8_517¶
-
enumerator Sherpa2214¶
-
enumerator Sherpa_Unknown¶
-
enumerator Unknown¶
Functions
-
MsgStream &msg(MSG::Level lvl = MSG::INFO)¶
Static object that provides athena-based message logging functionality
-
bool passPrimaryVertexSelection(const xAOD::VertexContainer *vertexContainer, int Ntracks = 2)¶
-
int countPrimaryVertices(const xAOD::VertexContainer *vertexContainer, int Ntracks = 2)¶
-
const xAOD::Vertex *getPrimaryVertex(const xAOD::VertexContainer *vertexContainer, MsgStream &msg)¶
-
inline const xAOD::Vertex *getPrimaryVertex(const xAOD::VertexContainer *vertexContainer)¶
-
float getPrimaryVertexZ(const xAOD::Vertex *pvx)¶
-
int getPrimaryVertexLocation(const xAOD::VertexContainer *vertexContainer, MsgStream &msg)¶
-
inline int getPrimaryVertexLocation(const xAOD::VertexContainer *vertexContainer)¶
-
bool applyPrimaryVertexSelection(const xAOD::JetContainer *jets, const xAOD::VertexContainer *vertices)¶
-
std::string replaceString(std::string subjet, const std::string &search, const std::string &replace)¶
-
std::vector<TString> SplitString(TString &orig, const char separator)¶
-
float dPhi(float phi1, float phi2)¶
-
bool has_exact(const std::string input, const std::string flag)¶
-
std::size_t string_pos(const std::string &haystack, const std::string &needle, unsigned int N)¶
Function which returns the position of the n-th occurence of a character in a string searching backwards. Returns -1 if no occurencies are found.
Source: http://stackoverflow.com/questions/18972258/index-of-nth-occurrence-of-the-string
-
StatusCode isAvailableMetaData(TTree *metaData)¶
-
bool isFilePrimaryxAOD(TFile *inputFile)¶
-
std::vector<TLorentzVector> jetReclustering(const xAOD::JetContainer *jets, double radius = 1.0, double fcut = 0.05, fastjet::JetAlgorithm rc_alg = fastjet::antikt_algorithm)¶
-
std::vector<TLorentzVector> jetTrimming(const xAOD::JetContainer *jets, double radius = 0.3, double fcut = 0.05, fastjet::JetAlgorithm s_alg = fastjet::kt_algorithm)¶
-
TLorentzVector jetTrimming(const xAOD::Jet *jet, double radius = 0.3, double fcut = 0.05, fastjet::JetAlgorithm s_alg = fastjet::kt_algorithm)¶
-
bool sort_pt(const xAOD::IParticle *partA, const xAOD::IParticle *partB)¶
-
std::vector<CP::SystematicSet> getListofSystematics(const CP::SystematicSet inSysts, std::string systNames, float systVal, MsgStream &msg)¶
Get a list of systematics.
- Parameters
inSysts – systematics set retrieved from the tool
systNames – comma separated list of wanted systematics names, use “Nominal” for nominal and “All” for all systematics
systVal – continuous systematics sigma value
msg – the MsgStream object with appropriate level for debugging
-
void writeSystematicsListHist(const std::vector<CP::SystematicSet> &systs, std::string histName, TFile *file)¶
-
template<typename T>
std::string type_name(bool useXAOD = true)¶
-
template<typename T1, typename T2>
StatusCode makeSubsetCont(T1 *&intCont, T2 *&outCont, MsgStream &msg, const std::string &flagSelect = "", HelperClasses::ToolName tool_name = HelperClasses::ToolName::DEFAULT)¶ Function to copy a subset of a generic input xAOD container into a generic output xAOD container.
If the optional parameters aren’t specified, the function will just make a full copy of the input container into the output one.
- Author
Marco Milesi (marco.milesi@cern.ch)
- Parameters
intCont – [in] input container
outCont – [inout] output container
flagSelect – [in] (optional) the name of the decoration for objects passing a certain selection (e.g. “passSel”, “overlaps” …). When explicitly specified, it must not be empty.
tool_name – [in] (optional) an enum specifying the tool type which is calling this function (definition in
HelperClasses::ToolName
)
-
template<typename T1, typename T2>
StatusCode makeSubsetCont(T1 *&intCont, T2 *&outCont, const std::string &flagSelect = "", HelperClasses::ToolName tool_name = HelperClasses::ToolName::DEFAULT)¶
-
template<typename T>
StatusCode retrieve(T *&cont, std::string name, xAOD::TEvent *event, xAOD::TStore *store, MsgStream &msg)¶ Retrieve an arbitrary object from TStore / TEvent.
This tries to make your life simple by providing a one-stop container retrieval shop for all types.
Example Usage:
const xAOD::JetContainer jets(0); // look for "AntiKt10LCTopoJets" in both TEvent and TStore ANA_CHECK( HelperFunctions::retrieve(jets, "AntiKt10LCTopoJets", m_event, m_store) ); // look for "AntiKt10LCTopoJets" in only TStore ANA_CHECK( HelperFunctions::retrieve(jets, "AntiKt10LCTopoJets", 0, m_store) ); // look for "AntiKt10LCTopoJets" in only TEvent, enable verbose output ANA_CHECK( HelperFunctions::retrieve(jets, "AntiKt10LCTopoJets", m_event, 0, msg()) );
Checking Order:
start by checking TStore
check if store contains ‘xAOD::JetContainer’ named ‘name’
attempt to retrieve from store
return if failure
next check TEvent
check if event contains ‘xAOD::JetContainer’ named ‘name’
attempt to retrieve from event
return if failure
return FAILURE
return SUCCESS (should never reach this last line)
- Parameters
cont – pass in a pointer to the object to store the retrieved container in
name – the name of the object to look up
event – the TEvent, usually wk()->xaodEvent(). Set to 0 to not search TEvent.
store – the TStore, usually wk()->xaodStore(). Set to 0 to not search TStore.
msg – the MsgStream object with appropriate level for debugging
-
template<typename T>
StatusCode retrieve(T *&cont, std::string name, xAOD::TEvent *event, xAOD::TStore *store)¶
- template<typename T> StatusCode __attribute__ ((deprecated("retrieve<T>(..., bool) is deprecated. See https://github.com/UCATLAS/xAODAnaHelpers/pull/882"))) retrieve(T *&cont
-
template<typename T>
bool isAvailable(std::string name, xAOD::TEvent *event, xAOD::TStore *store, MsgStream &msg)¶ Return true if an arbitrary object from TStore / TEvent is available.
This tries to make your life simple by providing a one-stop container check shop for all types
Example Usage:
const xAOD::JetContainer jets(0); // look for "AntiKt10LCTopoJets" in both TEvent and TStore HelperFunctions::isAvailable<xAOD::JetContainer>("AntiKt10LCTopoJets", m_event, m_store) // look for "AntiKt10LCTopoJets" in only TStore HelperFunctions::isAvailable<xAOD::JetContainer>("AntiKt10LCTopoJets", 0, m_store) // look for "AntiKt10LCTopoJets" in only TEvent, enable verbose output HelperFunctions::isAvailable<xAOD::JetContainer>("AntiKt10LCTopoJets", m_event, 0, MSG::VERBOSE)
- Parameters
name – the name of the object to look up
event – the TEvent, usually wk()->xaodEvent(). Set to 0 to not search TEvent.
store – the TStore, usually wk()->xaodStore(). Set to 0 to not search TStore.
msg – the MsgStream object with appropriate level for debugging
-
template<typename T>
bool isAvailable(std::string name, xAOD::TEvent *event, xAOD::TStore *store)¶
-
template<class T>
const T *getLink(const xAOD::IParticle *particle, std::string name)¶ Access to element link to object of type T stored in auxdata.
-
inline bool found_non_dummy_sys(std::vector<std::string> *sys_list)¶
-
template<typename T1, typename T2, typename T3>
StatusCode makeDeepCopy(xAOD::TStore *m_store, std::string containerName, const T1 *cont)¶ Make a deep copy of a container and put it in the TStore.
This is a very powerful templating function. The point is to remove the triviality of making deep copies by specifying all that is needed. The best way is to demonstrate via example:
const xAOD::JetContainer selected_jets(nullptr); ANA_CHECK( m_event->retrieve( selected_jets, "SelectedJets" )); ANA_CHECK( (HelperFunctions::makeDeepCopy<xAOD::JetContainer, xAOD::JetAuxContainer, xAOD::Jet>(m_store, "BaselineJets", selected_jets)));
- Template Parameters
T1 – The type of the container you’re going to deep copy into
T2 – The type of the aux container you’re going to deep copy into
T3 – The type of the object inside the container you’re going to deep copy
- Parameters
m_store – A pointer to the TStore object
containerName – The name of the container to create as output in the TStore
cont – The container to deep copy, it should be a container of pointers (IParticleContainer or ConstDataVector)
-
template<typename T1, typename T2>
StatusCode recordOutput(xAOD::TEvent *m_event, xAOD::TStore *m_store, std::string containerName)¶ Copy a container from the TStore to be recorded in the TEvent (eg: to an output)
If you have a container in the TStore, this function will record it into the output for you without an issue. As an example:
ANA_CHECK( HelperFunctions::recordOutput<xAOD::JetContainer, xAOD::JetAuxContainer>(m_event, m_store, "BaselineJets"));
where we build off the previous example of making a deep copy (see
HelperFunctions::makeDeepCopy()
).- Template Parameters
T1 – The type of the container you’re going to record
T2 – The type of the aux container you’re going to record
- Parameters
m_event – A pointer to the TEvent object
m_store – A pointer to the TStore object
containerName – The name of the container in the TStore to record to TEvent
-
template<typename T_BR>
void connectBranch(std::string name, TTree *tree, const std::string &branch, std::vector<T_BR> **variable)¶
-
ShowerType getMCShowerType(const std::string &sample_name, const std::string &m_taggerName)¶
Determines the type of generator used for the shower from the sample name.
The name of the generator is determined using some common definitions in the ATLAS MC dataset naming scheme. The case independent strings that are searched for are:
PYTHIA8EVTGEN or Py8EG or PYTHIA : Pythia8 HERWIG : Herwig7 SHERPA_CT : Sherpa21 SHERPA : Sherpa22 (if not Sherpa 21)
- Parameters
sample_name – The name of the sample, usualy the dataset name
Variables
- StatusCode std::string name
- StatusCode std::string xAOD::TEvent * event
- StatusCode std::string xAOD::TEvent xAOD::TStore * store
- StatusCode std::string xAOD::TEvent xAOD::TStore bool debug = { return retrieve<T>(cont, name, event, store, msg())
-
struct pt_sort¶
Public Functions
-
inline bool operator()(const TLorentzVector &lhs, const TLorentzVector &rhs)¶
-
inline bool operator()(const TLorentzVector *lhs, const TLorentzVector *rhs)¶
-
inline bool operator()(const xAOD::IParticle &lhs, const xAOD::IParticle &rhs)¶
-
inline bool operator()(const xAOD::IParticle *lhs, const xAOD::IParticle *rhs)¶
-
inline bool operator()(const TLorentzVector &lhs, const TLorentzVector &rhs)¶
-
enum ShowerType¶