Belle II Software  release-06-02-00
BeamSpotCollectorModule.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 #include <tracking/modules/BeamSpotCollector/BeamSpotCollectorModule.h>
9 
10 #include <analysis/dataobjects/ParticleList.h>
11 #include <analysis/utility/ReferenceFrame.h>
12 #include <mdst/dataobjects/TrackFitResult.h>
13 
14 using namespace Belle2;
15 using namespace std;
16 
17 #include <iostream>
18 
19 //-----------------------------------------------------------------
20 // Register the Module
21 //-----------------------------------------------------------------
22 REG_MODULE(BeamSpotCollector)
23 
24 //-----------------------------------------------------------------
25 // Implementation
26 //-----------------------------------------------------------------
27 
29  m_evt(-99), m_exp(-99), m_run(-99),
30  m_time(-99),
31  m_mu0_d0(-99), m_mu0_z0(-99), m_mu0_phi0(-99), m_mu0_tanlambda(-99), m_mu0_omega(-99),
32  m_mu1_d0(-99), m_mu1_z0(-99), m_mu1_phi0(-99), m_mu1_tanlambda(-99), m_mu1_omega(-99)
33 {
34  //Set module properties
35 
36  setDescription("Collect data for BeamSpot calibration algorithm using the position of mu+mu- events");
37  setPropertyFlags(c_ParallelProcessingCertified);
38 
39  addParam("Y4SPListName", m_Y4SPListName, "Name of the Y4S particle list", std::string("Upsilon(4S):IPDQM"));
40 }
41 
43 {
44  B2INFO("Init of the trees");
45  std::string objectName = "events";
46  //Data object creation --------------------------------------------------
47  TTree* tree = new TTree(objectName.c_str(), "");
48 
49  tree->Branch<int>("event", &m_evt);
50  tree->Branch<int>("exp", &m_exp);
51  tree->Branch<int>("run", &m_run);
52  tree->Branch<double>("time", &m_time);
53 
54  tree->Branch<double>("mu0_d0", &m_mu0_d0);
55  tree->Branch<double>("mu0_z0", &m_mu0_z0);
56  tree->Branch<double>("mu0_phi0", &m_mu0_phi0);
57  tree->Branch<double>("mu0_tanlambda", &m_mu0_tanlambda);
58 
59  tree->Branch<double>("mu1_d0", &m_mu1_d0);
60  tree->Branch<double>("mu1_z0", &m_mu1_z0);
61  tree->Branch<double>("mu1_phi0", &m_mu1_phi0);
62  tree->Branch<double>("mu1_tanlambda", &m_mu1_tanlambda);
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, 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 
90  std::vector<int> indxes = Y4SParticles->getParticle(0)->getDaughterIndices();
91  if (indxes.size() != 2) return;
92 
93  const Particle* part0 = Y4SParticles->getParticle(0)->getDaughter(0);
94  const Particle* part1 = Y4SParticles->getParticle(0)->getDaughter(1);
95  const TrackFitResult* tr0 = part0->getTrackFitResult();
96  const TrackFitResult* tr1 = part1->getTrackFitResult();
97 
98  m_mu0_d0 = tr0->getD0();
99  m_mu0_z0 = tr0->getZ0();
100  m_mu0_phi0 = tr0->getPhi0();
101  m_mu0_tanlambda = tr0->getTanLambda();
102  m_mu0_omega = tr0->getOmega();
103 
104 
105  m_mu1_d0 = tr1->getD0();
106  m_mu1_z0 = tr1->getZ0();
107  m_mu1_phi0 = tr1->getPhi0();
108  m_mu1_tanlambda = tr1->getTanLambda();
109  m_mu1_omega = tr1->getOmega();
110 
111 
112  getObjectPtr<TTree>("events")->Fill();
113 
114 }
This collects the track parameters of the mu+mu- events for calibration of the BeamSpot using CAF and...
void prepare() override final
Initialize the module.
void collect() override final
Event processor The filling of the tree.
Calibration collector module base class.
Class to store reconstructed particles.
Definition: Particle.h:74
const TrackFitResult * getTrackFitResult() const
Returns the pointer to the TrackFitResult that was used to create this Particle (ParticleType == c_Tr...
Definition: Particle.cc:823
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:95
bool isValid() const
Check whether the object was created.
Definition: StoreObjPtr.h:110
Values of the result of a track fit with a given particle hypothesis.
double getOmega() const
Getter for omega.
double getD0() const
Getter for d0.
double getTanLambda() const
Getter for tanLambda.
double getZ0() const
Getter for z0.
double getPhi0() const
Getter for phi0.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.