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;
67 return StatusCode::FAILURE;
74 m_MVreader = std::make_unique< TMVA::Reader > (
"Silent" );
75 float fjvt,
width,time,cllambda2,cletawidth,cle,cliso,clemprob;
79 m_MVreader->AddVariable(
"jet_LeadingClusterSecondLambda", &cllambda2 );
80 m_MVreader->AddVariable(
"cl_etaWidthLead", &cletawidth );
82 m_MVreader->AddVariable(
"cl_ISOLATIONsumE", &cliso );
83 m_MVreader->AddVariable(
"cl_EM_PROBABILITYsumE", &clemprob );
132 return StatusCode::SUCCESS;
141 if(pvind == -1) pvind =
getPV();
143 ATH_MSG_DEBUG(
"In JetForwardJvtToolBDT::modify: PV index = " << pvind);
145 ATH_MSG_WARNING(
"Something went wrong with the HS primary vertex identification." );
146 return StatusCode::FAILURE;
157 std::vector<TVector2> pileupMomenta;
161 outMVHandle(*jetF) = 1;
162 cllambda2Handle(*jetF) = 0;
163 clwidthHandle(*jetF) = 0;
164 cleHandle(*jetF) = 0;
165 clisoHandle(*jetF) = 0;
166 clemprobHandle(*jetF) = 0;
170 if( pileupMomenta.empty() ) {
172 if( pileupMomenta.empty() ) {
173 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." );
174 mvfjvtHandle(*jetF) = 0;
178 mvfjvt =
getMVfJVT(jetF, pvind, pileupMomenta);
180 mvfjvtHandle(*jetF) = mvfjvt;
183 return StatusCode::SUCCESS;
190 TVector2 fjet(-
jet->pt()*cos(
jet->phi()),-
jet->pt()*sin(
jet->phi()));
192 ATH_MSG_DEBUG(
"In JetForwardJvtToolBDT::getFJVT -----> Starting looping on vertices (pileupMomenta.size() = "<<pileupMomenta.size());
193 for (
size_t pui = 0; pui < pileupMomenta.size(); pui++) {
194 if (pui!=(
size_t)pvind){
195 double projection = pileupMomenta[pui]*fjet/fjet.Mod();
196 if (projection>fjvt) fjvt = projection;
209 if(
sc.isFailure() ) {
215 if ( !eventInfoHandle.
isValid() ) {
219 float mu = eventInfoHandle->actualInteractionsPerCrossing();
229 std::vector<float> MVinputs;
230 MVinputs.push_back(
getFJVT(
jet, pvind, pileupMomenta)/
jet->pt() );
231 MVinputs.push_back(
jet->getAttribute<
float>(
"Width") );
232 MVinputs.push_back(
jet->getAttribute<
float>(
"Timing") );
233 MVinputs.push_back( cllambda2Handle(*
jet) );
234 MVinputs.push_back( clwidthHandle(*
jet) );
235 MVinputs.push_back( cleHandle(*
jet) );
236 MVinputs.push_back( clisoHandle(*
jet) );
237 MVinputs.push_back( clemprobHandle(*
jet) );
239 float pt =
jet->pt()/(
GeV);
240 float eta = fabs(
jet->eta());
245 static std::mutex
mutex;
247 if ( pt < 30. && pt >= 20. &&
eta >= 3.2 && mu>=50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_1" ,1.);
248 else if ( pt < 30. && pt >= 20. &&
eta < 3.2 && mu>=50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_2" ,1.);
249 else if ( pt < 40. && pt >= 30. &&
eta >= 3.2 && mu>=50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_3" ,1.);
250 else if ( pt < 40. && pt >= 30. &&
eta < 3.2 && mu>=50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_4" ,1.);
251 else if ( pt < 50. && pt >= 40. &&
eta >= 3.2 && mu>=50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_5" ,1.);
252 else if ( pt < 50. && pt >= 40. &&
eta < 3.2 && mu>=50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_6" ,1.);
253 else if ( pt < 120. && pt >= 50. &&
eta >= 3.2 && mu>=50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_7" ,1.);
254 else if ( pt < 120. && pt >= 50. &&
eta < 3.2 && mu>=50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_8" ,1.);
255 else if ( pt < 30. && pt >= 20. &&
eta >= 3.2 && mu<50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_9" ,1.);
256 else if ( pt < 30. && pt >= 20. &&
eta < 3.2 && mu<50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_10" ,1.);
257 else if ( pt < 40. && pt >= 30. &&
eta >= 3.2 && mu<50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_11" ,1.);
258 else if ( pt < 40. && pt >= 30. &&
eta < 3.2 && mu<50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_12" ,1.);
259 else if ( pt < 50. && pt >= 40. &&
eta >= 3.2 && mu<50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_13" ,1.);
260 else if ( pt < 50. && pt >= 40. &&
eta < 3.2 && mu<50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_14" ,1.);
261 else if ( pt < 120. && pt >= 50. &&
eta >= 3.2 && mu<50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_15" ,1.);
262 else if ( pt < 120. && pt >= 50. &&
eta < 3.2 && mu<50. ) score = reader.EvaluateMVA( MVinputs,
"BDT_16" ,1.);
264 ATH_MSG_DEBUG(
"pt = " << pt <<
" | eta = " <<
eta <<
" | mu = " << mu <<
" || MVfJVT = " << score );
271 double mvfjvtThresh = -999.;
274 if ( !eventInfoHandle.
isValid() ) {
279 float mu = eventInfoHandle->actualInteractionsPerCrossing();
286 return mvfjvt==-2 || mvfjvt>mvfjvtThresh;
299 cllambda2Handle(*
jet) = lcllambda2NTHandle(*
jet);
303 if( !clustersHandle.
isValid() ) {
305 return StatusCode::FAILURE;
319 if(cl->p4().DeltaR(
jet->p4())>0.6)
continue;
321 cle2 += cl->e()*cl->e();
322 cliso1 += ISOLATIONAcc(*cl)*cl->e()*cl->e();
323 clemprob1 += EM_PROBABILITYAcc(*cl)*cl->e()*cl->e();
324 if(cl->rawE()/cosh(cl->rawEta()) > maxpt){
325 maxpt = cl->rawE()/cosh(cl->rawEta());
332 clwidthHandle(*
jet) = TMath::CosH(cl->rawEta()) * TMath::ATan2( TMath::Sqrt(SECOND_RAcc(*cl)),
335 cleHandle(*
jet) = cle1;
337 ATH_MSG_ERROR(
"JetForwardJvtToolBDT::getMVfJVT: divide by zero.");
338 return StatusCode::FAILURE;
340 clisoHandle(*
jet)= cliso1/cle2;
341 clemprobHandle(*
jet) =clemprob1/cle2;
350 cllambda2Handle(*
jet) = lcllambda2Handle(*
jet);
351 clwidthHandle(*
jet) = lclwidthHandle(*
jet);
352 clisoHandle(*
jet) = lclisoHandle(*
jet);
353 clemprobHandle(*
jet) = lclemprobHandle(*
jet);
354 cleHandle(*
jet) = lcleHandle(*
jet);
356 return StatusCode::SUCCESS;
361 std::vector<TVector2> pileupMomenta;
364 if( !trkMetHandle.
isValid() ) {
366 return pileupMomenta;
369 if( !vxContHandle.
isValid() ) {
371 return pileupMomenta;
373 ATH_MSG_DEBUG(
"In JetForwardJvtToolBDT::calculateVertexMomenta : Starting vertex loop ");
377 TString vname =
"PVTrack_vx";
378 vname += vx->index();
379 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()));
384 if (jetvert>=0) pileupMomenta[jetvert] += TVector2(0.5*
jet->pt()*cos(
jet->phi()),0.5*
jet->pt()*sin(
jet->phi()));
387 return pileupMomenta;
410 std::vector<float> sumpts;
411 jet->getAttribute<std::vector<float> >(
"SumPtTrkPt500",sumpts);
414 for (
size_t i = 0; i < sumpts.size(); i++) {
415 if (sumpts[i]>firstVal) {
417 firstVal = sumpts[i];
425 std::vector<float> sumpts;
426 jet->getAttribute<std::vector<float> >(
"SumPtTrkPt500",sumpts);
427 if (sumpts.size()<2)
return 0;
429 std::nth_element(sumpts.begin(),sumpts.begin()+sumpts.size()/2,sumpts.end(),std::greater<int>());
430 double median = sumpts[sumpts.size()/2];
431 std::nth_element(sumpts.begin(),sumpts.begin(),sumpts.end(),std::greater<int>());
432 double max = sumpts[0];
433 return (
max-median)/
jet->pt();
439 if( !vxContHandle.
isValid() ) {
443 ATH_MSG_DEBUG(
"Successfully retrieved primary vertex container");
448 ATH_MSG_DEBUG(
"Couldn't identify the hard-scatter primary vertex (no vertex with \"vx->vertexType()==xAOD::VxType::PriVtx\" in the container)!");
459 for(
const xAOD::Jet *tjet : *truthJets) {
460 if (tjet->p4().DeltaR(
jet->p4())<0.3 && tjet->pt()>10e3) ishs =
true;
461 if (tjet->p4().DeltaR(
jet->p4())<0.6) ispu =
false;
463 isHSHandle(*
jet)=ishs;
464 isPUHandle(*
jet)=ispu;
466 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.
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
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".