ATLAS Offline Software
Loading...
Searching...
No Matches
GradedTrack.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include "GaudiKernel/MsgStream.h"
8#include <iostream>
9#include <sys/types.h>
10
13
14namespace Analysis {
15
16 // GradedTrack::GradedTrack(const xAOD::TrackParticle* trk, TrackGrade grd) {
18 track(trk), grade(grd) {
19 // this->track = trk;
20 // this->grade = grd;
21 }
22
25
26 TrackGradePartition::TrackGradePartition(const std::string& definition,
27 const ITrackGradeFactory& trackGradeFactory) {
28
29 const TrackGradesDefinition & myTrackGradesDefinition = trackGradeFactory.getTrackGradesDefinition();
30
31 // parse definition to extract grades separated by + sign:
32 const std::string delim("+");
33 std::string::size_type sPos, sEnd, sLen;
34 sPos = definition.find_first_not_of(delim);
35 while ( sPos != std::string::npos ) {
36 sEnd = definition.find_first_of(delim, sPos);
37 if(sEnd==std::string::npos) sEnd = definition.length();
38 sLen = sEnd - sPos;
39 std::string grade = definition.substr(sPos,sLen);
40 // add new grade to this partition:
41 const TrackGrade* tgrade(myTrackGradesDefinition.getGrade(grade));
42 if (tgrade==0)
43 {
44 throw std::string("#BTAG# Error: the following grade ") + grade + std::string(" could not be found in the list from TrackGradeFactory ");
45 }
46 m_grades.push_back(TrackGrade(*tgrade));
47 sPos = definition.find_first_not_of(delim, sEnd);
48 }
49 }
50
53
55 m_grades.push_back(grade);
56 }
57
58 const std::vector<TrackGrade>& TrackGradePartition::grades() const {
59 return m_grades;
60 }
61
62 const std::string TrackGradePartition::suffix() const {
63 std::string suf("");
64 for(uint i=0;i<m_grades.size();i++) {
65 if(0==i) {
66 suf += m_grades[i].gradeString();
67 } else {
68 suf += ("_" + m_grades[i].gradeString());
69 }
70 }
71 return suf;
72 }
73
75 return m_grades.size();
76 }
77
78 MsgStream& operator<<( MsgStream& out, const TrackGradePartition& part) {
79 out << "#BTAG# GradePartition: [ ";
80 for(int i=0;i<part.size();i++) out<<" "<<part.grades()[i].gradeString();
81 out << " ]";
82 return out;
83 }
84 std::ostream& operator<<( std::ostream& out, const TrackGradePartition& part) {
85 out << "#BTAG# GradePartition: [ ";
86 for(int i=0;i<part.size();i++) out<<" "<<part.grades()[i].gradeString();
87 out << " ]";
88 return out;
89 }
90}
unsigned int uint
GradedTrack(const tracklink_t &, const TrackGrade &)
const tracklink_t & track
Definition GradedTrack.h:36
Interface class for the CombinerTool AlgTool, it inherits from IAlgTool Detailed information about pr...
virtual const TrackGradesDefinition & getTrackGradesDefinition() const =0
const std::string suffix() const
const std::vector< TrackGrade > & grades() const
std::vector< TrackGrade > m_grades
Definition GradedTrack.h:53
void add(const TrackGrade &)
const TrackGrade * getGrade(const std::string &) const
The namespace of all packages in PhysicsAnalysis/JetTagging.
MsgStream & operator<<(MsgStream &out, const IPInfoBase &)
output.
ElementLink< xAOD::TrackParticleContainer > tracklink_t
Definition GradedTrack.h:28