@@ -94,6 +94,7 @@ struct JetTaggerHFTask {
9494 Configurable<LabeledArray<double >> cutsMl{" cutsMl" , {DefaultCutsMl[0 ], 1 , 2 , {" pT bin 0" }, {" score for default b-jet tagging" , " uncer 1" }}, " ML selections per pT bin" };
9595 Configurable<int > nClassesMl{" nClassesMl" , 2 , " Number of classes in ML model" };
9696 Configurable<std::vector<std::string>> namesInputFeatures{" namesInputFeatures" , std::vector<std::string>{" feature1" , " feature2" }, " Names of ML model input features" };
97+ Configurable<bool > useDb{" useDb" , false , " Flag to use DB for ML model instead of the score" };
9798
9899 Configurable<std::string> ccdbUrl{" ccdbUrl" , " http://alice-ccdb.cern.ch" , " url of the ccdb repository" };
99100 Configurable<std::vector<std::string>> modelPathsCCDB{" modelPathsCCDB" , std::vector<std::string>{" Users/h/hahassan" }, " Paths of models on CCDB" };
@@ -297,16 +298,16 @@ struct JetTaggerHFTask {
297298 std::map<std::string, std::string> metadata;
298299 resoFuncMatch = resoFuncMatching;
299300
300- const int IPmethodResolutionFunctionSize = 7 ;
301+ const int mIPmethodResolutionFunctionSize = 7 ;
301302
302303 auto loadCCDBforIP = [&](const std::vector<std::string>& paths, std::vector<TF1*>& targetVec, const std::string& name) {
303- if (paths.size () != IPmethodResolutionFunctionSize ) {
304+ if (paths.size () != mIPmethodResolutionFunctionSize ) {
304305 usepTcategorize.value = false ;
305306 LOG (info) << name << " does not have 7 entries. Disabling pT categorization (usepTcategorize = false)." ;
306307 resoFuncMatch = 0 ;
307308 return ;
308309 }
309- for (int i = 0 ; i < IPmethodResolutionFunctionSize ; i++) {
310+ for (int i = 0 ; i < mIPmethodResolutionFunctionSize ; i++) {
310311 targetVec.push_back (ccdbApi.retrieveFromTFileAny <TF1>(paths[i], metadata, -1 ));
311312 }
312313 };
@@ -335,7 +336,7 @@ struct JetTaggerHFTask {
335336 }
336337
337338 maxOrder = numCount + 1 ; // 0: untagged, >1 : N ordering
338- const int IPmethodNumOfParameters = 9 ;
339+ const int mIPmethodNumOfParameters = 9 ;
339340
340341 // Set up the resolution function
341342 switch (resoFuncMatch) {
@@ -383,7 +384,7 @@ struct JetTaggerHFTask {
383384 for (size_t j = 0 ; j < resoFuncIncCCDB.size (); j++) {
384385 std::vector<float > params;
385386 if (resoFuncIncCCDB[j]) {
386- for (int i = 0 ; i < IPmethodNumOfParameters ; i++) {
387+ for (int i = 0 ; i < mIPmethodNumOfParameters ; i++) {
387388 params.emplace_back (resoFuncIncCCDB[j]->GetParameter (i));
388389 }
389390 }
@@ -397,7 +398,7 @@ struct JetTaggerHFTask {
397398 for (size_t j = 0 ; j < resoFuncBeautyCCDB.size (); j++) {
398399 std::vector<float > params;
399400 if (resoFuncBeautyCCDB[j]) {
400- for (int i = 0 ; i < IPmethodNumOfParameters ; i++) {
401+ for (int i = 0 ; i < mIPmethodNumOfParameters ; i++) {
401402 params.emplace_back (resoFuncBeautyCCDB[j]->GetParameter (i));
402403 }
403404 }
@@ -406,7 +407,7 @@ struct JetTaggerHFTask {
406407 for (size_t j = 0 ; j < resoFuncCharmCCDB.size (); j++) {
407408 std::vector<float > params;
408409 if (resoFuncCharmCCDB[j]) {
409- for (int i = 0 ; i < IPmethodNumOfParameters ; i++) {
410+ for (int i = 0 ; i < mIPmethodNumOfParameters ; i++) {
410411 params.emplace_back (resoFuncCharmCCDB[j]->GetParameter (i));
411412 }
412413 }
@@ -415,7 +416,7 @@ struct JetTaggerHFTask {
415416 for (size_t j = 0 ; j < resoFuncLfCCDB.size (); j++) {
416417 std::vector<float > params;
417418 if (resoFuncLfCCDB[j]) {
418- for (int i = 0 ; i < IPmethodNumOfParameters ; i++) {
419+ for (int i = 0 ; i < mIPmethodNumOfParameters ; i++) {
419420 params.emplace_back (resoFuncLfCCDB[j]->GetParameter (i));
420421 }
421422 }
@@ -427,7 +428,7 @@ struct JetTaggerHFTask {
427428 for (size_t j = 0 ; j < resoFuncDataCCDB.size (); j++) {
428429 std::vector<float > params;
429430 if (resoFuncDataCCDB[j]) {
430- for (int i = 0 ; i < IPmethodNumOfParameters ; i++) {
431+ for (int i = 0 ; i < mIPmethodNumOfParameters ; i++) {
431432 params.emplace_back (resoFuncDataCCDB[j]->GetParameter (i));
432433 }
433434 }
@@ -507,7 +508,7 @@ struct JetTaggerHFTask {
507508 std::vector<jettaggingutilities::BJetSVParams> svsParams;
508509
509510 jettaggingutilities::analyzeJetSVInfo4ML (analysisJet, allTracks, allSVs, svsParams, svPtMin, svReductionFactor);
510- jettaggingutilities::analyzeJetTrackInfo4ML (analysisJet, allTracks, allSVs, tracksParams, trackPtMin);
511+ jettaggingutilities::analyzeJetTrackInfo4ML (analysisJet, allTracks, allSVs, tracksParams, trackPtMin, trackDcaXYMax, trackDcaZMax );
511512
512513 int nSVs = analysisJet.template secondaryVertices_as <SecondaryVertices>().size ();
513514
@@ -525,7 +526,15 @@ struct JetTaggerHFTask {
525526 bMlResponse.isSelectedMl (inputML, analysisJet.pt (), output);
526527 }
527528
528- scoreML[analysisJet.globalIndex ()] = output[0 ];
529+ if (bMlResponse.getOutputNodes () > 1 ) {
530+ auto mDb = [](std::vector<float > scores, float fC ) {
531+ return std::log (scores[2 ] / (fC * scores[1 ] + (1 - fC ) * scores[0 ]));
532+ };
533+
534+ scoreML[analysisJet.globalIndex ()] = useDb ? mDb (output, fC ) : output[2 ]; // 2 is the b-jet index
535+ } else {
536+ scoreML[analysisJet.globalIndex ()] = output[0 ];
537+ }
529538 }
530539 }
531540
@@ -537,7 +546,7 @@ struct JetTaggerHFTask {
537546 std::vector<jettaggingutilities::BJetTrackParams> tracksParams;
538547 std::vector<jettaggingutilities::BJetSVParams> svsParams;
539548
540- jettaggingutilities::analyzeJetTrackInfo4MLnoSV (analysisJet, allTracks, tracksParams, trackPtMin);
549+ jettaggingutilities::analyzeJetTrackInfo4MLnoSV (analysisJet, allTracks, tracksParams, trackPtMin, trackDcaXYMax, trackDcaZMax );
541550
542551 jettaggingutilities::BJetParams jetparam = {analysisJet.pt (), analysisJet.eta (), analysisJet.phi (), static_cast <int >(tracksParams.size ()), 0 , analysisJet.mass ()};
543552 tracksParams.resize (nJetConst); // resize to the number of inputs of the ML
0 commit comments