Belle II Software  release-08-01-10
ECLCNNPIDVariables.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #include <ecl/variables/ECLCNNPIDVariables.h>
10 #include <ecl/dataobjects/ECLCNNPid.h>
11 
12 #include <analysis/VariableManager/Manager.h>
13 #include <analysis/dataobjects/Particle.h>
14 
15 #include <mdst/dataobjects/Track.h>
16 
17 #include <framework/logging/Logger.h>
18 
19 using namespace std;
20 
21 namespace Belle2 {
27  namespace Variable {
28 
29  // CNNPIDECLPion -------------------------------------------
30  double CNNPIDECLMuon(const Particle* part)
31  {
32  auto track = part->getTrack();
33  if (!track) return std::numeric_limits<double>::quiet_NaN();
34 
35  const auto eclCnnMuonRelationVector = track->getRelationsWith<ECLCNNPid>();
36  if (eclCnnMuonRelationVector.size() == 0) return std::numeric_limits<double>::quiet_NaN();
37 
38  if (eclCnnMuonRelationVector.size() == 1) {
39  return eclCnnMuonRelationVector.object(0)->getEclCnnMuon();
40  } else {
41  B2FATAL("Somehow found more than 1 ECL CNN muon probabilities matched to the extrapolated track. This should not be possible!");
42  return std::numeric_limits<double>::quiet_NaN();
43  }
44  }
45 
46  VARIABLE_GROUP("CNN PID ECL variable (cDST)");
47 
48  REGISTER_VARIABLE("cnn_pid_ecl_muon", CNNPIDECLMuon,
49  R"DOC(CNN runs over extrapolated tracks and output probabilities of pion or muon like. The variable here is muon-like probablity.
50 Returns NaN if CNN was not run or if the ``cnn_pid_ecl_muon`` parameter was not set.)DOC");
51 
52  }
54 }
Abstract base class for different kinds of events.