20const double GeV = 1000.;
45 if (filename.empty()){
47 return StatusCode::FAILURE;
53 m_wpFileIn = std::make_unique<TFile> (filename.c_str(),
"read");
55 if (
m_OP==
"TIGHTER") {
57 }
else if (
m_OP==
"TIGHT" ) {
59 }
else if (
m_OP==
"DEFAULT" ||
m_OP==
"LOOSE" ) {
63 return StatusCode::FAILURE;
70 m_MVreader = std::make_unique< TMVA::Reader > (
"Silent" );
71 float fjvt,
width,time,cllambda2,cletawidth,cle,cliso,clemprob;
75 m_MVreader->AddVariable(
"jet_LeadingClusterSecondLambda", &cllambda2 );
76 m_MVreader->AddVariable(
"cl_etaWidthLead", &cletawidth );
78 m_MVreader->AddVariable(
"cl_ISOLATIONsumE", &cliso );
79 m_MVreader->AddVariable(
"cl_EM_PROBABILITYsumE", &clemprob );
128 return StatusCode::SUCCESS;
137 if(pvind == -1) pvind =
getPV();
139 ATH_MSG_DEBUG(
"In JetForwardJvtToolBDT::modify: PV index = " << pvind);
141 ATH_MSG_WARNING(
"Something went wrong with the HS primary vertex identification." );
142 return StatusCode::FAILURE;
153 std::vector<TVector2> pileupMomenta;
157 outMVHandle(*jetF) = 1;
158 cllambda2Handle(*jetF) = 0;
159 clwidthHandle(*jetF) = 0;
160 cleHandle(*jetF) = 0;
161 clisoHandle(*jetF) = 0;
162 clemprobHandle(*jetF) = 0;
166 if( pileupMomenta.empty() ) {
168 if( pileupMomenta.empty() ) {
169 ATH_MSG_DEBUG(
"pileupMomenta is empty, this can happen for events with no PU vertices. fJVT won't be computed for this event and will be set to 0 instead." );
170 mvfjvtHandle(*jetF) = 0;
174 mvfjvt =
getMVfJVT(jetF, pvind, pileupMomenta);
176 mvfjvtHandle(*jetF) = mvfjvt;
179 return StatusCode::SUCCESS;
186 TVector2 fjet(-
jet->pt()*cos(
jet->phi()),-
jet->pt()*sin(
jet->phi()));
188 ATH_MSG_DEBUG(
"In JetForwardJvtToolBDT::getFJVT -----> Starting looping on vertices (pileupMomenta.size() = "<<pileupMomenta.size());
189 for (
size_t pui = 0; pui < pileupMomenta.size(); pui++) {
190 if (pui!=(
size_t)pvind){
191 double projection = pileupMomenta[pui]*fjet/fjet.Mod();
192 if (projection>fjvt) fjvt = projection;
205 if(
sc.isFailure() ) {
211 if ( !eventInfoHandle.
isValid() ) {
215 float mu = eventInfoHandle->actualInteractionsPerCrossing();
225 std::vector<float> MVinputs;
226 MVinputs.push_back(
getFJVT(
jet, pvind, pileupMomenta)/
jet->pt() );
227 MVinputs.push_back(
jet->getAttribute<
float>(
"Width") );
228 MVinputs.push_back(
jet->getAttribute<
float>(
"Timing") );
229 MVinputs.push_back( cllambda2Handle(*
jet) );
230 MVinputs.push_back( clwidthHandle(*
jet) );
231 MVinputs.push_back( cleHandle(*
jet) );
232 MVinputs.push_back( clisoHandle(*
jet) );
233 MVinputs.push_back( clemprobHandle(*
jet) );
235 float pt =
jet->pt()/(
GeV);
236 float eta = fabs(
jet->eta());
241 static std::mutex
mutex;
242 std::lock_guard lock (
mutex);
243 if ( pt < 30. && pt >= 20. &&
eta >= 3.2 && mu>=50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_1" ,1.);
244 else if ( pt < 30. && pt >= 20. &&
eta < 3.2 && mu>=50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_2" ,1.);
245 else if ( pt < 40. && pt >= 30. &&
eta >= 3.2 && mu>=50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_3" ,1.);
246 else if ( pt < 40. && pt >= 30. &&
eta < 3.2 && mu>=50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_4" ,1.);
247 else if ( pt < 50. && pt >= 40. &&
eta >= 3.2 && mu>=50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_5" ,1.);
248 else if ( pt < 50. && pt >= 40. &&
eta < 3.2 && mu>=50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_6" ,1.);
249 else if ( pt < 120. && pt >= 50. &&
eta >= 3.2 && mu>=50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_7" ,1.);
250 else if ( pt < 120. && pt >= 50. &&
eta < 3.2 && mu>=50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_8" ,1.);
251 else if ( pt < 30. && pt >= 20. &&
eta >= 3.2 && mu<50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_9" ,1.);
252 else if ( pt < 30. && pt >= 20. &&
eta < 3.2 && mu<50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_10" ,1.);
253 else if ( pt < 40. && pt >= 30. &&
eta >= 3.2 && mu<50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_11" ,1.);
254 else if ( pt < 40. && pt >= 30. &&
eta < 3.2 && mu<50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_12" ,1.);
255 else if ( pt < 50. && pt >= 40. &&
eta >= 3.2 && mu<50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_13" ,1.);
256 else if ( pt < 50. && pt >= 40. &&
eta < 3.2 && mu<50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_14" ,1.);
257 else if ( pt < 120. && pt >= 50. &&
eta >= 3.2 && mu<50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_15" ,1.);
258 else if ( pt < 120. && pt >= 50. &&
eta < 3.2 && mu<50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_16" ,1.);
260 ATH_MSG_DEBUG(
"pt = " << pt <<
" | eta = " <<
eta <<
" | mu = " << mu <<
" || MVfJVT = " << score );
267 double mvfjvtThresh = -999.;
270 if ( !eventInfoHandle.
isValid() ) {
275 float mu = eventInfoHandle->actualInteractionsPerCrossing();
282 return mvfjvt==-2 || mvfjvt>mvfjvtThresh;
295 cllambda2Handle(*
jet) = lcllambda2NTHandle(*
jet);
299 if( !clustersHandle.
isValid() ) {
301 return StatusCode::FAILURE;
315 if(cl->p4().DeltaR(
jet->p4())>0.6)
continue;
317 cle2 += cl->e()*cl->e();
318 cliso1 += ISOLATIONAcc(*cl)*cl->e()*cl->e();
319 clemprob1 += EM_PROBABILITYAcc(*cl)*cl->e()*cl->e();
320 if(cl->rawE()/cosh(cl->rawEta()) > maxpt){
321 maxpt = cl->rawE()/cosh(cl->rawEta());
328 clwidthHandle(*
jet) = TMath::CosH(cl->rawEta()) * TMath::ATan2( TMath::Sqrt(SECOND_RAcc(*cl)),
331 cleHandle(*
jet) = cle1;
332 clisoHandle(*
jet)= cliso1/cle2;
333 clemprobHandle(*
jet) =clemprob1/cle2;
342 cllambda2Handle(*
jet) = lcllambda2Handle(*
jet);
343 clwidthHandle(*
jet) = lclwidthHandle(*
jet);
344 clisoHandle(*
jet) = lclisoHandle(*
jet);
345 clemprobHandle(*
jet) = lclemprobHandle(*
jet);
346 cleHandle(*
jet) = lcleHandle(*
jet);
348 return StatusCode::SUCCESS;
353 std::vector<TVector2> pileupMomenta;
356 if( !trkMetHandle.
isValid() ) {
358 return pileupMomenta;
361 if( !vxContHandle.
isValid() ) {
363 return pileupMomenta;
365 ATH_MSG_DEBUG(
"In JetForwardJvtToolBDT::calculateVertexMomenta : Starting vertex loop ");
369 TString vname =
"PVTrack_vx";
370 vname += vx->index();
371 pileupMomenta.push_back((vx->index()==(
size_t)pvind?0:-(1./
m_jetScaleFactor))*TVector2(0.5*(*trkMetHandle)[vname.Data()]->mpx(),0.5*(*trkMetHandle)[vname.Data()]->mpy()));
376 if (jetvert>=0) pileupMomenta[jetvert] += TVector2(0.5*
jet->pt()*cos(
jet->phi()),0.5*
jet->pt()*sin(
jet->phi()));
379 return pileupMomenta;
402 std::vector<float> sumpts;
403 jet->getAttribute<std::vector<float> >(
"SumPtTrkPt500",sumpts);
406 for (
size_t i = 0; i < sumpts.size(); i++) {
407 if (sumpts[i]>firstVal) {
409 firstVal = sumpts[i];
417 std::vector<float> sumpts;
418 jet->getAttribute<std::vector<float> >(
"SumPtTrkPt500",sumpts);
419 if (sumpts.size()<2)
return 0;
421 std::nth_element(sumpts.begin(),sumpts.begin()+sumpts.size()/2,sumpts.end(),std::greater<int>());
422 double median = sumpts[sumpts.size()/2];
423 std::nth_element(sumpts.begin(),sumpts.begin(),sumpts.end(),std::greater<int>());
424 double max = sumpts[0];
425 return (
max-median)/
jet->pt();
431 if( !vxContHandle.
isValid() ) {
435 ATH_MSG_DEBUG(
"Successfully retrieved primary vertex container");
440 ATH_MSG_DEBUG(
"Couldn't identify the hard-scatter primary vertex (no vertex with \"vx->vertexType()==xAOD::VxType::PriVtx\" in the container)!");
451 for(
const xAOD::Jet *tjet : *truthJets) {
452 if (tjet->p4().DeltaR(
jet->p4())<0.3 && tjet->pt()>10e3) ishs =
true;
453 if (tjet->p4().DeltaR(
jet->p4())<0.6) ispu =
false;
455 isHSHandle(*
jet)=ishs;
456 isPUHandle(*
jet)=ispu;
458 return StatusCode::SUCCESS;
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Helper class to provide constant type-safe access to aux data.
Defines enum to access jet attribute and associated particles/objects.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
Helper class to provide constant type-safe access to aux data.
Handle class for reading a decoration on an object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.
Jet_v1 Jet
Definition of the current "jet version".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Vertex_v1 Vertex
Define the latest version of the vertex class.
JetContainer_v1 JetContainer
Definition of the current "jet container version".