ATLAS Offline Software
Loading...
Searching...
No Matches
AcceptInfo.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6/******************************************************************************
7Name: AcceptInfo
8
9Author: Karsten Koeneke (CERN)
10Author: Nils Krumnack (Iowa State University)
11Created: April 2011
12Created: September 2017
13
14Description: Object to encode the result of several cuts
15******************************************************************************/
16
17// This class' header
18#include "PATCore/AcceptInfo.h"
19
20
21// include math
22#include <math.h>
23#include <utility>
24#include <map>
25#include <iostream>
26
27// ROOT includes
28#include <TString.h>
29
30
31
32
33//=============================================================================
34// Get the description of a cut based on the cut position
35//=============================================================================
36const std::string& asg::AcceptInfo::getCutName( unsigned int cutPosition ) const
37{
38 static const std::string emptyString;
39
40 // Make sure that this cut doesn't exceed the number of defined cuts
41 if ( cutPosition >= m_cutMap.size() )
42 {
43 return emptyString;
44 }
45
46 // iterate over the map and find the right position
47 auto it = m_cutMap.begin();
48 auto itEnd = m_cutMap.end();
49 for ( ; it != itEnd; ++it )
50 {
51 if ( (it->second).second == cutPosition )
52 {
53 return (it->first);
54 }
55 }
56
57 return emptyString;
58}
59
60
61
62
63//=============================================================================
64// Get the description of a cut based on the cut position
65//=============================================================================
66const std::string& asg::AcceptInfo::getCutDescription( unsigned int cutPosition ) const
67{
68 static const std::string emptyString;
69
70 // Make sure that this cut doesn't exceed the number of defined cuts
71 if ( cutPosition >= m_cutMap.size() )
72 {
73 return emptyString;
74 }
75
76 // iterate over the map and find the right position
77 auto it = m_cutMap.begin();
78 auto itEnd = m_cutMap.end();
79 for ( ; it != itEnd; ++it )
80 {
81 if ( (it->second).second == cutPosition )
82 {
83 return (it->second).first;
84 }
85 }
86
87 return emptyString;
88}
89
90
91
92
93
94//=============================================================================
95// Set the description of a cut based on the cut position
96//=============================================================================
97void asg::AcceptInfo::setCutDescription( const unsigned int cutPosition, const std::string& cutDescription )
98{
99 // iterate over the map and find the right position
100 auto it = m_cutMap.begin();
101 auto itEnd = m_cutMap.end();
102 for ( ; it != itEnd; ++it )
103 {
104 if ( (it->second).second == cutPosition )
105 {
106 ((it->second).first) = cutDescription;
107 return;
108 }
109 }
110
111 return;
112}
113
114
115
116
117
119const std::string& asg::AcceptInfo :: getCutDescription( const std::string& cutName ) const
120{
121 static const std::string emptyString;
122 auto it = m_cutMap.find(cutName);
123 return (it != m_cutMap.end()) ? (it->second).first : emptyString;
124}
std::map< std::string, std::pair< std::string, unsigned int > > m_cutMap
The map for mapping cut names to their description and position.
Definition AcceptInfo.h:109
const std::string & getCutName(unsigned int cutPosition) const
Get the name of a cut, based on the cut position (slow, avoid usage)
void setCutDescription(const std::string &cutName, const std::string &cutDescription)
Set the result of a cut, based on the cut name (safer)
Definition AcceptInfo.h:92
const std::string & getCutDescription(const std::string &cutName) const
Get the description of a cut, based on the cut name.