Belle II Software  release-05-02-19
BoostVectorCollectorModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2020 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Radek Zlebcik
7  * *
8  * *
9  * This software is provided "as is" without any warranty. *
10  **************************************************************************/
11 #include <tracking/modules/BoostVectorCollector/BoostVectorCollectorModule.h>
12 
13 #include <analysis/dataobjects/ParticleList.h>
14 #include <analysis/utility/ReferenceFrame.h>
15 #include <mdst/dataobjects/TrackFitResult.h>
16 
17 #include <mdst/dataobjects/PIDLikelihood.h>
18 
19 #include <limits>
20 
21 using namespace Belle2;
22 using namespace std;
23 
24 //-----------------------------------------------------------------
25 // Register the Module
26 //-----------------------------------------------------------------
27 REG_MODULE(BoostVectorCollector)
28 
29 //-----------------------------------------------------------------
30 // Implementation
31 //-----------------------------------------------------------------
32 
34  m_exp(-99), m_run(-99), m_evt(-99),
35  m_time(-99),
36  m_mu0_pid(-99), m_mu1_pid(-99)
37 {
38  //Set module properties
39 
40  setDescription("Collect data for BoostVector calibration algorithm using the momenta of the mu+mu- events");
41  setPropertyFlags(c_ParallelProcessingCertified);
42 
43  addParam("Y4SPListName", m_Y4SPListName, "Name of the Y4S particle list", std::string("Upsilon(4S):IPDQM"));
44 }
45 
47 {
48  B2INFO("Init of the trees");
49  TString objectName = "events";
50  //Data object creation --------------------------------------------------
51  TTree* tree = new TTree(objectName, "");
52 
53  tree->Branch<int>("event", &m_evt);
54  tree->Branch<int>("exp", &m_exp);
55  tree->Branch<int>("run", &m_run);
56  tree->Branch<double>("time", &m_time);
57 
58  tree->Branch<double>("mu0_pid", &m_mu0_pid);
59  tree->Branch<double>("mu1_pid", &m_mu1_pid);
60 
61  tree->Branch<TVector3>("mu0_p", &m_mu0_p);
62  tree->Branch<TVector3>("mu1_p", &m_mu1_p);
63 
64 
65  // We register the objects so that our framework knows about them.
66  // Don't try and hold onto the pointers or fill these objects directly
67  // Use the getObjectPtr functions to access collector objects
68  registerObject<TTree>(objectName.Data(), tree);
69 }
70 
71 
73 {
74  m_evt = m_emd->getEvent();
75  m_run = m_emd->getRun();
76  m_exp = m_emd->getExperiment();
77  m_time = m_emd->getTime() / 1e9 / 3600.; //from ns to hours
78 
79 
80  StoreObjPtr<ParticleList> Y4SParticles(m_Y4SPListName);
81 
82 
83  if (!Y4SParticles.isValid() || abs(Y4SParticles->getPDGCode()) != 300553)
84  return;
85 
86  if (Y4SParticles->getListSize() != 1)
87  return;
88 
89  std::vector<int> indxes = Y4SParticles->getParticle(0)->getDaughterIndices();
90  if (indxes.size() != 2) return;
91 
92  const Particle* part0 = Y4SParticles->getParticle(0)->getDaughter(0);
93  const Particle* part1 = Y4SParticles->getParticle(0)->getDaughter(1);
94 
95  // Get the mu/e PID
96  auto* pidObj0 = part0->getPIDLikelihood();
97  auto* pidObj1 = part1->getPIDLikelihood();
98 
99  // if PID not available init to NaN
100  m_mu0_pid = std::numeric_limits<double>::quiet_NaN();
101  m_mu1_pid = std::numeric_limits<double>::quiet_NaN();
102 
103  if (pidObj0) m_mu0_pid = pidObj0->getProbability(Const::ChargedStable(13), Const::ChargedStable(11));
104  if (pidObj1) m_mu1_pid = pidObj1->getProbability(Const::ChargedStable(13), Const::ChargedStable(11));
105 
106  // get 3-vectors of the mu/e momenta
107  m_mu0_p = part0->getMomentum();
108  m_mu1_p = part1->getMomentum();
109 
110 
111  getObjectPtr<TTree>("events")->Fill();
112 
113 }
Belle2::CalibrationCollectorModule
Calibration collector module base class.
Definition: CalibrationCollectorModule.h:44
Belle2::BoostVectorCollectorModule::collect
void collect() override final
Event processor The filling of the tree.
Definition: BoostVectorCollectorModule.cc:72
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Particle::getPIDLikelihood
const PIDLikelihood * getPIDLikelihood() const
Returns the pointer to the PIDLikelihood object that is related to the Track, which was used to creat...
Definition: Particle.cc:796
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::BoostVectorCollectorModule::prepare
void prepare() override final
Initialize the module.
Definition: BoostVectorCollectorModule.cc:46
Belle2::Particle::getMomentum
TVector3 getMomentum() const
Returns momentum vector.
Definition: Particle.h:475
Belle2::BoostVectorCollectorModule
This collects the track parameters and momenta of the mu+mu- events for calibration of the BoostVecto...
Definition: BoostVectorCollectorModule.h:35
Belle2::Particle
Class to store reconstructed particles.
Definition: Particle.h:77
Belle2::Const::ChargedStable
Provides a type-safe way to pass members of the chargedStableSet set.
Definition: Const.h:465
Belle2::StoreObjPtr::isValid
bool isValid() const
Check whether the object was created.
Definition: StoreObjPtr.h:120