ATLAS Offline Software
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Analysis::MultiSVTag Class Reference

#include <MultiSVTag.h>

Inheritance diagram for Analysis::MultiSVTag:
Collaboration diagram for Analysis::MultiSVTag:

Classes

struct  Vars
 

Public Member Functions

 MultiSVTag (const std::string &, const std::string &, const IInterface *)
 
virtual ~MultiSVTag ()=default
 
virtual StatusCode initialize () override
 
virtual StatusCode tagJet (const xAOD::Vertex &priVtx, const xAOD::Jet &jetToTag, xAOD::BTagging &BTag, const std::string &jetName) const override
 
virtual void finalizeHistos () override
 

Private Member Functions

double GetClassResponse (MVAUtils::BDT *bdt) const
 

Private Attributes

std::string m_taggerNameBase
 
std::string m_varStrName
 
SG::ReadCondHandleKey< JetTagCalibCondDatam_readKey {this, "HistosKey", "JetTagCalibHistosKey", "Key of input (derived) JetTag calibration data"}
 Key of calibration data: More...
 
std::string m_runModus
 
bool m_doForcedCalib
 
std::string m_ForcedCalibName
 
std::string m_secVxFinderName
 
std::string m_sv1_infosource
 

Detailed Description

Definition at line 27 of file MultiSVTag.h.

Constructor & Destructor Documentation

◆ MultiSVTag()

Analysis::MultiSVTag::MultiSVTag ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Definition at line 32 of file MultiSVTag.cxx.

33  : base_class(t,n,p),
34  m_runModus("analysis")
35  {
36  declareProperty("Runmodus", m_runModus= "analysis");
37  declareProperty("useForcedCalibration", m_doForcedCalib = false);
38  declareProperty("ForcedCalibrationName", m_ForcedCalibName = "AntiKt4TopoEM");//Cone4H1Tower
39  declareProperty("SecVxFinderName",m_secVxFinderName);
40  declareProperty("taggerNameBase",m_taggerNameBase = "MultiSVbb1");
41  declareProperty("inputSV1SourceName", m_sv1_infosource = "SV1");
42  }

◆ ~MultiSVTag()

virtual Analysis::MultiSVTag::~MultiSVTag ( )
virtualdefault

Member Function Documentation

◆ finalizeHistos()

void Analysis::MultiSVTag::finalizeHistos ( )
overridevirtual

implementation for Analysis::ITagTool::finalizeHistos

Definition at line 278 of file MultiSVTag.cxx.

278  {
280  }

◆ GetClassResponse()

double Analysis::MultiSVTag::GetClassResponse ( MVAUtils::BDT bdt) const
inlineprivate

Definition at line 94 of file MultiSVTag.h.

◆ initialize()

StatusCode Analysis::MultiSVTag::initialize ( )
overridevirtual

Definition at line 44 of file MultiSVTag.cxx.

44  {
45  m_varStrName = "variables";
46 
47  // prepare readKey for calibration data:
48  ATH_CHECK(m_readKey.initialize());
49  return StatusCode::SUCCESS;
50  }

◆ tagJet()

StatusCode Analysis::MultiSVTag::tagJet ( const xAOD::Vertex priVtx,
const xAOD::Jet jetToTag,
xAOD::BTagging BTag,
const std::string &  jetName 
) const
overridevirtual

author to know which jet algorithm:

Definition at line 52 of file MultiSVTag.cxx.

56  {
57  //Retrieval of Calibration Condition Data objects
59 
61  std::string author = jetName;
63  ATH_MSG_DEBUG("#BTAG# MSV Using jet type " << author << " for calibrations.");
64  //....
65  std::string alias = readCdo->getChannelAlias(author);
66  ATH_MSG_DEBUG("#BTAG# Jet author for MultiSVTag: " << author << ", alias: " << alias );
67 
68  //Retrieve BDT from cond object
69  MVAUtils::BDT *bdt(nullptr);
70  ATH_MSG_DEBUG("#BTAG# Getting MVAUtils::BDT for "<<m_taggerNameBase);
71  bdt = readCdo->retrieveBdt(m_taggerNameBase,author);
72  if (!bdt) {
73  ATH_MSG_WARNING("#BTAG# No BDT for " << m_taggerNameBase<<" exists in the condition object.. Disabling algorithm.");
74  return StatusCode::SUCCESS;
75  }
76 
77  //Retrieve input variables for BDT in cond store
78  std::vector<float*> inputPointers; inputPointers.clear();
79  std::vector<std::string> inputVars = readCdo->retrieveInputVars(m_taggerNameBase,author, m_taggerNameBase+"Calib/"+m_varStrName);
80  unsigned nConfgVar=0; bool badVariableFound=false;
81 
82  Vars vars;
83  vars.SetVariableRefs(msg(),inputVars,nConfgVar,badVariableFound,inputPointers);
84  ATH_MSG_DEBUG("#BTAG# nConfgVar"<<nConfgVar
85  <<", badVariableFound= "<<badVariableFound <<", inputPointers.size()= "<<inputPointers.size() );
86 
87  if ( inputVars.size()!=nConfgVar or badVariableFound ) {
88  ATH_MSG_WARNING("#BTAG# Number of expected variables for MVA: "<< nConfgVar << " does not match the number of variables found in the calibration file: " << inputVars.size() << " ... the algorithm will be 'disabled' "<<alias<<" "<<author);
89  return StatusCode::SUCCESS;
90  }
91 
92  bdt->SetPointers(inputPointers);
93 
94  //the jet
95  double jeteta = jetToTag.eta(), jetphi = jetToTag.phi();
96  vars.m_jetpt = jetToTag.pt();
97  ATH_MSG_DEBUG("#BTAG# Jet properties : eta = " << jeteta
98  << " phi = " << jetphi << " pT = " <<vars.m_jetpt/GeV);
99 
100  TLorentzVector jp4; jp4.SetPtEtaPhiM(jetToTag.pt(), jetToTag.eta(), jetToTag.phi(), jetToTag.m());
101 
102  int msv_n = 0;
103  int all_trks = 0;
104  int nvtx2trk = 0;
105  int nsv = 0;
106 
107  bool status = true;
108 
109  status &= BTag.variable<float>(m_secVxFinderName, "normdist", vars.m_normDist);
110  status &= BTag.variable<int>(m_secVxFinderName, "nvsec", msv_n);
111  std::vector< ElementLink< xAOD::VertexContainer > > msvVertices;
112  status &= BTag.variable<std::vector<ElementLink<xAOD::VertexContainer> > >(m_secVxFinderName, "vertices", msvVertices);
113  ATH_MSG_DEBUG("#BTAG# MSV_vertices: " <<msvVertices.size());
114  std::vector<float> v_vtxmass = std::vector<float>(10,0);
115  std::vector<float> v_vtxefrc = std::vector<float>(10,0);
116  std::vector<float> v_vtxntrk = std::vector<float>(10,0);
117  std::vector<float> v_vtxDRj = std::vector<float>(10,0);
118  std::vector<float> v_vtxdls = std::vector<float>(10,0);
119  std::vector<float> v_vtxpt = std::vector<float>(10,0);
120  std::vector<float> v_vtxeta = std::vector<float>(10,0);
121  std::vector<float> v_vtxphi = std::vector<float>(10,0);
122  std::vector<float> v_vtxx = std::vector<float>(10,0);
123  std::vector<float> v_vtxy = std::vector<float>(10,0);
124  std::vector<float> v_vtxz = std::vector<float>(10,0);
125  // loop in msv vertices
126  if(!msvVertices.empty()){
127  for(const auto& vtx : msvVertices){
128  if(msvVertices.size()>=10) continue;
129  float mass = xAOD::SecVtxHelper::VertexMass(*vtx);
130  float efrc = xAOD::SecVtxHelper::EnergyFraction(*vtx);
131  int ntrk = xAOD::SecVtxHelper::VtxNtrk(*vtx);
132  float pt = xAOD::SecVtxHelper::Vtxpt(*vtx);
133  float eta = xAOD::SecVtxHelper::Vtxeta(*vtx);
134  float phi = xAOD::SecVtxHelper::Vtxphi(*vtx);
135  float dls = xAOD::SecVtxHelper::VtxnormDist(*vtx);
136  float x = (*vtx)->x();
137  float y = (*vtx)->y();
138  float z = (*vtx)->z();
139  TLorentzVector svp4; svp4.SetPtEtaPhiM(pt,eta,phi,mass);
140  //if(jp4.DeltaR(svp4)>0.4) continue;
141  vars.m_summass += mass;
142  const std::vector<ElementLink<xAOD::TrackParticleContainer> > svTrackLinks = (*vtx)->trackParticleLinks();
143  if(svTrackLinks.size()>1){
144  nvtx2trk++;
145  }
146  all_trks += svTrackLinks.size();
147 
148  ATH_MSG_DEBUG("#BTAG# MSV_vtx mass: " <<mass<<", efrc: "<<efrc<<", ntrk: "<<ntrk );
149  ATH_MSG_DEBUG("#BTAG# MSV_vtx pt: " <<pt<<", eta: "<<eta<<", phi: "<<phi );
150  ATH_MSG_DEBUG("#BTAG# MSV_vtx DRj: " <<jp4.DeltaR(svp4));
151  v_vtxmass[nsv] = mass;
152  v_vtxefrc[nsv] = efrc;
153  v_vtxntrk[nsv] = ntrk;
154  v_vtxDRj[nsv] = jp4.DeltaR(svp4);
155  v_vtxdls[nsv] = dls;
156  v_vtxpt[nsv] = pt;
157  v_vtxeta[nsv] = eta;
158  v_vtxphi[nsv] = phi;
159  v_vtxx[nsv] = x;
160  v_vtxy[nsv] = y;
161  v_vtxz[nsv] = z;
162  nsv++;
163 
164  }//loop in vertices
165  vars.m_nvtx = nsv;
166  vars.m_totalntrk = all_trks;
167 
168  int SV1ntrk = 0;
169  std::vector< ElementLink< xAOD::VertexContainer > > SV1Vertice;
170  status &= BTag.variable<std::vector<ElementLink<xAOD::VertexContainer> > >(m_sv1_infosource, "vertices", SV1Vertice);
171  if (!SV1Vertice.empty() && SV1Vertice[0].isValid()){
172  status &= BTag.taggerInfo(SV1ntrk, xAOD::BTagInfo::SV1_NGTinSvx);
173  vars.m_diffntrkSV1 = all_trks - SV1ntrk;
174  }else{
175  vars.m_diffntrkSV1 = all_trks;
176  }
177 
178  vars.m_diffntrkSV0 = vars.m_diffntrkSV1;
179 
180  if (!status) {
181  ATH_MSG_WARNING("Error retrieving input values; results will be incorrect!");
182  }
183 
184  for(int i=0; i<nsv; i++) {
185  if(v_vtxntrk[i]!=1){
186  if(v_vtxefrc[i] > vars.m_maxefrc ) vars.m_maxefrc = v_vtxefrc[i];
187  }
188  }
189 
190  int ivm1 = -1; int ivm2 = -1;
191  float vm1 = 0.; float vm2 = 0.;
192  TLorentzVector pvtx1; TLorentzVector pvtx2;
193  TVector3 sv1p3; TVector3 sv2p3;
194  for(int i=0; i<nsv; i++) {
195  if( v_vtxntrk[i]!=1) {
196  if( v_vtxmass[i] > vm1 ) {
197  vm1 = v_vtxmass[i];
198  ivm1 = i;
199  }
200  }
201  }
202  for(int i=0; i<nsv; i++) {
203  if( v_vtxntrk[i]!=1) {
204  if( v_vtxmass[i] > vm2 && v_vtxmass[i] < vm1 ) {
205  vm2 = v_vtxmass[i];
206  ivm2 = i;
207  }
208  }
209  }
210  if(ivm1>=0) {
211  pvtx1.SetPtEtaPhiM(v_vtxpt[ivm1], v_vtxeta[ivm1], v_vtxphi[ivm1], v_vtxmass[ivm1]);
212  TVector3 p1 = pvtx1.Vect();
213  sv1p3.SetX(v_vtxx[ivm1] - priVtx.x());
214  sv1p3.SetY(v_vtxy[ivm1] - priVtx.y());
215  sv1p3.SetZ(v_vtxz[ivm1] - priVtx.z());
216  vars.m_mmax_mass = v_vtxmass[ivm1];
217  vars.m_mmax_efrc = v_vtxefrc[ivm1];
218 
219  vars.m_mmax_DRjet = v_vtxDRj[ivm1];
220  vars.m_mmax_dist = v_vtxdls[ivm1];
221  }
222  if(ivm2>=0) {
223  pvtx2.SetPtEtaPhiM(v_vtxpt[ivm2], v_vtxeta[ivm2], v_vtxphi[ivm2], v_vtxmass[ivm2]);
224  TVector3 p2 = pvtx2.Vect();
225  sv2p3.SetX(v_vtxx[ivm2] - priVtx.x());
226  sv2p3.SetY(v_vtxy[ivm2] - priVtx.y());
227  sv2p3.SetZ(v_vtxz[ivm2] - priVtx.z());
228  vars.m_mmx2_mass = v_vtxmass[ivm2];
229  vars.m_mmx2_efrc = v_vtxefrc[ivm2];
230 
231  vars.m_mmx2_DRjet = v_vtxDRj[ivm2];
232  vars.m_mmx2_dist = v_vtxdls[ivm2];
233  }
234  // distances: max mass vertex to PV, and mx2 to max vertex:
235  if(ivm1>=0&&ivm2>=0) {
236 
237  vars.m_mx12_2d12 = std::hypot( v_vtxx[ivm2] - v_vtxx[ivm1], v_vtxy[ivm2] - v_vtxy[ivm1] );
238  vars.m_mx12_DR = sv1p3.DeltaR(sv2p3);
239 
240  vars.m_mx12_Angle = sv1p3.Angle(sv2p3);
241 
242  }
243  //end of inputs
244  ATH_MSG_DEBUG("#BTAG# MSV inputs: " <<
245  "nvtx= " << vars.m_nvtx <<
246  ", maxefrc= " << vars.m_maxefrc <<
247  ", summass= " << vars.m_summass <<
248  ", totalntrk= " << vars.m_totalntrk <<
249  ", diffntrkSV0= " << vars.m_diffntrkSV0 <<
250  ", diffntrkSV1= " << vars.m_diffntrkSV1 <<
251  ", normDist= " << vars.m_normDist <<
252  ", mmax_mass= " << vars.m_mmax_mass <<
253  ", mmax_efrc= " << vars.m_mmax_efrc <<
254  ", mmax_DRjet= " << vars.m_mmax_DRjet <<
255  ", mmax_dist= " << vars.m_mmax_dist <<
256  ", mmx2_mass= " << vars.m_mmx2_mass <<
257  ", mmx2_efrc= " << vars.m_mmx2_efrc <<
258  ", mmx2_DRjet= " << vars.m_mmx2_DRjet <<
259  ", mmx2_dist= " << vars.m_mmx2_dist <<
260  ", mx12_2d12= " << vars.m_mx12_2d12 <<
261  ", mx12_DR= " << vars.m_mx12_DR <<
262  ", mx12_Angle=" << vars.m_mx12_Angle
263  );
264  }
265  //...
266  //compute BDT weight
267  float msvW = -9.;
268  if( nvtx2trk>1 ){
269  msvW = GetClassResponse(bdt);
270  }
271 
272  if(m_runModus=="analysis") {
273  BTag.setVariable<float>(m_taggerNameBase, "discriminant", msvW);
274  }
275  return StatusCode::SUCCESS;
276  }

Member Data Documentation

◆ m_doForcedCalib

bool Analysis::MultiSVTag::m_doForcedCalib
private

Definition at line 53 of file MultiSVTag.h.

◆ m_ForcedCalibName

std::string Analysis::MultiSVTag::m_ForcedCalibName
private

Definition at line 54 of file MultiSVTag.h.

◆ m_readKey

SG::ReadCondHandleKey<JetTagCalibCondData> Analysis::MultiSVTag::m_readKey {this, "HistosKey", "JetTagCalibHistosKey", "Key of input (derived) JetTag calibration data"}
private

Key of calibration data:

Definition at line 49 of file MultiSVTag.h.

◆ m_runModus

std::string Analysis::MultiSVTag::m_runModus
private

Definition at line 51 of file MultiSVTag.h.

◆ m_secVxFinderName

std::string Analysis::MultiSVTag::m_secVxFinderName
private

Definition at line 55 of file MultiSVTag.h.

◆ m_sv1_infosource

std::string Analysis::MultiSVTag::m_sv1_infosource
private

Definition at line 57 of file MultiSVTag.h.

◆ m_taggerNameBase

std::string Analysis::MultiSVTag::m_taggerNameBase
private

Definition at line 44 of file MultiSVTag.h.

◆ m_varStrName

std::string Analysis::MultiSVTag::m_varStrName
private

Definition at line 46 of file MultiSVTag.h.


The documentation for this class was generated from the following files:
Analysis::MultiSVTag::m_taggerNameBase
std::string m_taggerNameBase
Definition: MultiSVTag.h:44
xAOD::Vertex_v1::x
float x() const
Returns the x position.
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
test_pyathena.pt
pt
Definition: test_pyathena.py:11
MVAUtils::BDT
Simplified Boosted Regression Tree, support TMVA, lgbm, and xgboost.
Definition: BDT.h:34
xAOD::SecVtxHelper::VtxNtrk
int VtxNtrk(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:39
xAOD::Jet_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: Jet_v1.cxx:54
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
x
#define x
xAOD::SecVtxHelper::VertexMass
float VertexMass(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:9
dqt_zlumi_pandas.mass
mass
Definition: dqt_zlumi_pandas.py:170
Analysis::MultiSVTag::m_runModus
std::string m_runModus
Definition: MultiSVTag.h:51
xAOD::SecVtxHelper::VtxnormDist
float VtxnormDist(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:95
lumiFormat.i
int i
Definition: lumiFormat.py:92
z
#define z
beamspotman.n
n
Definition: beamspotman.py:731
xAOD::SecVtxHelper::Vtxphi
float Vtxphi(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:81
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
python.xAODClusterD3PDObject.Vars
Vars
Definition: xAODClusterD3PDObject.py:29
COOLRates.alias
alias
Definition: COOLRates.py:1172
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::Vertex_v1::z
float z() const
Returns the z position.
xAOD::Jet_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: Jet_v1.cxx:49
xAOD::SV1_NGTinSvx
@ SV1_NGTinSvx
SV1 : Number of good tracks in vertex.
Definition: BTaggingEnums.h:33
Analysis::MultiSVTag::m_varStrName
std::string m_varStrName
Definition: MultiSVTag.h:46
xAOD::Jet_v1::m
virtual double m() const
The invariant mass of the particle.
Definition: Jet_v1.cxx:59
y
#define y
Analysis::MultiSVTag::m_secVxFinderName
std::string m_secVxFinderName
Definition: MultiSVTag.h:55
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CaloCondBlobAlgs_fillNoiseFromASCII.author
string author
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:26
xAOD::Vertex_v1::y
float y() const
Returns the y position.
Analysis::MultiSVTag::m_doForcedCalib
bool m_doForcedCalib
Definition: MultiSVTag.h:53
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
xAOD::SecVtxHelper::EnergyFraction
float EnergyFraction(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:24
merge.status
status
Definition: merge.py:17
Analysis::MultiSVTag::m_ForcedCalibName
std::string m_ForcedCalibName
Definition: MultiSVTag.h:54
Analysis::MultiSVTag::GetClassResponse
double GetClassResponse(MVAUtils::BDT *bdt) const
Definition: MultiSVTag.h:94
xAODType::BTag
@ BTag
The object is a b-tagging object.
Definition: ObjectType.h:60
xAOD::SecVtxHelper::Vtxpt
float Vtxpt(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:53
xAOD::SecVtxHelper::Vtxeta
float Vtxeta(const xAOD::Vertex *)
Definition: SecVtxHelper.cxx:67
xAOD::Jet_v1::pt
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition: Jet_v1.cxx:44
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
Analysis::MultiSVTag::m_readKey
SG::ReadCondHandleKey< JetTagCalibCondData > m_readKey
Key of calibration data:
Definition: MultiSVTag.h:49
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
Analysis::MultiSVTag::m_sv1_infosource
std::string m_sv1_infosource
Definition: MultiSVTag.h:57