CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JetTagComputer.h
Go to the documentation of this file.
1 #ifndef RecoBTau_JetTagComputer_h
2 #define RecoBTau_JetTagComputer_h
3 
4 #include <vector>
5 #include <string>
6 
11 
13 
15  public:
16  class TagInfoHelper {
17  public:
18  TagInfoHelper(const std::vector<const reco::BaseTagInfo*> &infos, std::vector<std::string> &labels) :
19  m_tagInfos(infos),
20  m_labels(labels) {}
21 
22  TagInfoHelper(const std::vector<const reco::BaseTagInfo*> &infos):
23  m_tagInfos(infos),
24  m_labels()
25  {}
26 
27 
29 
30  const reco::BaseTagInfo &getBase(unsigned int index) const
31  {
32  if (index >= m_tagInfos.size())
33  throw cms::Exception("InvalidIndex")
34  << "Invalid index " << index << " "
35  "in call to JetTagComputer::get."
36  << std::endl;
37 
39  if (!info)
40  throw cms::Exception("ProductMissing")
41  << "Missing TagInfo "
42  "in call to JetTagComputer::get."
43  << std::endl;
44 
45  return *info;
46  }
47 
48  template<class T>
49  const T &get(unsigned int index = 0) const
50  {
52  const T *castInfo = dynamic_cast<const T*>(info);
53  if (!castInfo)
54  throw cms::Exception("InvalidCast")
55  << "Invalid TagInfo cast "
56  "in call to JetTagComputer::get( index="<< index <<" )."
57  << std::endl;
58 
59  return *castInfo;
60  }
61 
62  template<class T>
63  const T &get(std::string label) const
64  {
65  size_t idx=0;
66  for(; idx <= m_labels.size(); idx++){
67  if(idx < m_labels.size() && m_labels[idx] == label) break;
68  }
69 
70  if(idx == m_labels.size()) {
71  throw cms::Exception("ProductMissing")
72  << "Missing TagInfo with label: " << label <<
73  " in call to JetTagComputer::get." << std::endl;
74  }
75  return get<T>(idx);
76  }
77 
78  private:
79  const std::vector<const reco::BaseTagInfo*> &m_tagInfos;
80  std::vector<std::string> m_labels;
81  };
82 
83  // default constructor
85  virtual ~JetTagComputer() {}
86 
87  // explicit constructor accepting a ParameterSet for configuration
89  m_setupDone(false) {}
90 
91  virtual void initialize(const JetTagComputerRecord &) {}
92 
93  float operator () (const reco::BaseTagInfo& info) const;
94  inline float operator () (const TagInfoHelper &helper) const
95  { return discriminator(helper); }
96 
97  inline const std::vector<std::string> &getInputLabels() const
98  { return m_inputLabels; }
99 
100  void setupDone() { m_setupDone = true; }
101 
102  protected:
103  void uses(unsigned int id, const std::string &label);
104  void uses(const std::string &label) { uses(0, label); }
105 
106  virtual float discriminator(const reco::BaseTagInfo&) const;
107  virtual float discriminator(const TagInfoHelper&) const;
108 
109  private:
110  std::vector<std::string> m_inputLabels;
112 };
113 
114 #endif // RecoBTau_JetTagComputer_h
std::vector< std::string > m_inputLabels
static const TGPicture * info(bool iBackgroundIsBlack)
virtual ~JetTagComputer()
JetTagComputer(const edm::ParameterSet &configuration)
virtual float discriminator(const reco::BaseTagInfo &) const
std::vector< std::string > m_labels
TagInfoHelper(const std::vector< const reco::BaseTagInfo * > &infos)
TagInfoHelper(const std::vector< const reco::BaseTagInfo * > &infos, std::vector< std::string > &labels)
const std::vector< const reco::BaseTagInfo * > & m_tagInfos
const std::vector< std::string > & getInputLabels() const
float operator()(const reco::BaseTagInfo &info) const
void uses(unsigned int id, const std::string &label)
const reco::BaseTagInfo & getBase(unsigned int index) const
void uses(const std::string &label)
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
volatile std::atomic< bool > shutdown_flag false
long double T
virtual void initialize(const JetTagComputerRecord &)