Belle II Software  release-05-01-25
InvariantMassStandAlone.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2021 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Radek Zlebcik *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <iostream>
12 #include <vector>
13 #include <tuple>
14 #include <TTree.h>
15 #include <TVector3.h>
16 #include <Eigen/Dense>
17 
18 //if compiled within BASF2
19 #ifdef _PACKAGE_
20 #include <tracking/calibration/InvariantMassStandAlone.h>
21 #include <tracking/calibration/Splitter.h>
22 #include <tracking/calibration/tools.h>
23 #else
24 #include <InvariantMassStandAlone.h>
25 #include <Splitter.h>
26 #include <tools.h>
27 #endif
28 
29 using Eigen::MatrixXd;
30 using Eigen::VectorXd;
31 
32 using namespace std;
33 
34 namespace Belle2 {
40  namespace InvariantMassCalib {
41 
42 
43 
45  vector<Event> getEvents(TTree* tr)
46  {
47 
48  vector<Event> events;
49  events.reserve(tr->GetEntries());
50 
51  Event evt;
52 
53  tr->SetBranchAddress("run", &evt.run);
54  tr->SetBranchAddress("exp", &evt.exp);
55  tr->SetBranchAddress("event", &evt.evtNo);
56 
57  TVector3* p0 = nullptr;
58  TVector3* p1 = nullptr;
59 
60  tr->SetBranchAddress("mu0_p", &p0);
61  tr->SetBranchAddress("mu1_p", &p1);
62 
63  tr->SetBranchAddress("mu0_pid", &evt.mu0.pid);
64  tr->SetBranchAddress("mu1_pid", &evt.mu1.pid);
65 
66 
67  tr->SetBranchAddress("time", &evt.t); //time in hours
68 
69 
70  for (int i = 0; i < tr->GetEntries(); ++i) {
71  tr->GetEntry(i);
72 
73  evt.mu0.p = *p0;
74  evt.mu1.p = *p1;
75 
76  evt.nBootStrap = 1;
77  evt.isSig = true;
78  events.push_back(evt);
79  }
80 
81  //sort by time
82  sort(events.begin(), events.end(), [](Event e1, Event e2) {return e1.t < e2.t;});
83 
84 
85  return events;
86  }
87 
88 
90  vector<double> getInvMassPars(const vector<Event>& /*evts*/)
91  {
92  return { -1, -1, -1}; //dummy values
93  }
94 
95 
96 
97  // Returns tuple with the invariant mass parameters
98  // cppcheck-suppress passedByValue
99  tuple<vector<VectorXd>, vector<MatrixXd>, MatrixXd> runInvariantMassAnalysis(vector<Event> evts,
100  const vector<double>& splitPoints)
101  {
102  int n = splitPoints.size() + 1;
103  //no split points, i.e. the spead interval identical to the center interval
104  B2ASSERT("No split points for InvariantMass calibration", n == 1);
105  vector<VectorXd> invMassVec(n);
106  vector<MatrixXd> invMassVecUnc(n);
107  MatrixXd invMassVecSpred;
108 
109  invMassVec[0].resize(1); //1D vector for center of the 1D Gauss
110  invMassVecUnc[0].resize(1, 1); //1x1 matrix covariance mat of the center
111  invMassVecSpred.resize(1, 1); //1x1 matrix for spread of the 1D Gauss
112 
113  auto res = getInvMassPars(evts);
114  invMassVec[0](0) = res[0];
115  invMassVecUnc[0](0, 0) = res[1];
116  invMassVecSpred(0, 0) = res[2];
117 
118 
119  return make_tuple(invMassVec, invMassVecUnc, invMassVecSpred);
120  }
121 
122  }
124 }
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19