Belle II Software development
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
14using namespace Belle2;
15
16#include <iostream>
17
18//-----------------------------------------------------------------
19// Register the Module
20//-----------------------------------------------------------------
21REG_MODULE(BeamSpotCollector);
22
23//-----------------------------------------------------------------
24// Implementation
25//-----------------------------------------------------------------
26
28 m_evt(-99), m_exp(-99), m_run(-99),
29 m_time(-99),
30 m_mu0_d0(-99), m_mu0_z0(-99), m_mu0_phi0(-99), m_mu0_tanlambda(-99), m_mu0_omega(-99),
31 m_mu1_d0(-99), m_mu1_z0(-99), m_mu1_phi0(-99), m_mu1_tanlambda(-99), m_mu1_omega(-99)
32{
33 //Set module properties
34
35 setDescription("Collect data for BeamSpot calibration algorithm using the position of mu+mu- events");
37
38 addParam("Y4SPListName", m_Y4SPListName, "Name of the Y4S particle list", std::string("Upsilon(4S):IPDQM"));
39}
40
42{
43 B2INFO("Init of the trees");
44 std::string objectName = "events";
45 //Data object creation --------------------------------------------------
46 TTree* tree = new TTree(objectName.c_str(), "");
47
48 tree->Branch<int>("event", &m_evt);
49 tree->Branch<int>("exp", &m_exp);
50 tree->Branch<int>("run", &m_run);
51 tree->Branch<double>("time", &m_time);
52
53 tree->Branch<double>("mu0_d0", &m_mu0_d0);
54 tree->Branch<double>("mu0_z0", &m_mu0_z0);
55 tree->Branch<double>("mu0_phi0", &m_mu0_phi0);
56 tree->Branch<double>("mu0_tanlambda", &m_mu0_tanlambda);
57
58 tree->Branch<double>("mu1_d0", &m_mu1_d0);
59 tree->Branch<double>("mu1_z0", &m_mu1_z0);
60 tree->Branch<double>("mu1_phi0", &m_mu1_phi0);
61 tree->Branch<double>("mu1_tanlambda", &m_mu1_tanlambda);
62
63
64 // We register the objects so that our framework knows about them.
65 // Don't try and hold onto the pointers or fill these objects directly
66 // Use the getObjectPtr functions to access collector objects
67 registerObject<TTree>(objectName, tree);
68}
69
70
72{
73 m_evt = m_emd->getEvent();
74 m_run = m_emd->getRun();
75 m_exp = m_emd->getExperiment();
76 m_time = m_emd->getTime() / 1e9 / 3600.; //from ns to hours
77
78
80
81
82 if (!Y4SParticles.isValid() || abs(Y4SParticles->getPDGCode()) != 300553)
83 return;
84
85 if (Y4SParticles->getListSize() != 1)
86 return;
87
88 if (Y4SParticles->getParticle(0)->getDaughterIndices().size() != 2)
89 return;
90
91 const Particle* part0 = Y4SParticles->getParticle(0)->getDaughter(0);
92 const Particle* part1 = Y4SParticles->getParticle(0)->getDaughter(1);
93 const TrackFitResult* tr0 = part0->getTrackFitResult();
94 const TrackFitResult* tr1 = part1->getTrackFitResult();
95
96 m_mu0_d0 = tr0->getD0();
97 m_mu0_z0 = tr0->getZ0();
98 m_mu0_phi0 = tr0->getPhi0();
100 m_mu0_omega = tr0->getOmega();
101
102
103 m_mu1_d0 = tr1->getD0();
104 m_mu1_z0 = tr1->getZ0();
105 m_mu1_phi0 = tr1->getPhi0();
107 m_mu1_omega = tr1->getOmega();
108
109
110 getObjectPtr<TTree>("events")->Fill();
111
112}
void prepare() override final
Initialize the module.
double m_mu1_tanlambda
tanlambda track parameter of the second muon in the event
double m_mu1_omega
omega track parameter of the second muon in the event
double m_mu1_z0
z0 track parameter of the second muon in the event
double m_mu0_tanlambda
tanlambda track parameter of the first muon in the event
std::string m_Y4SPListName
Name of the Y4S particle list.
double m_mu1_d0
d0 track parameter of the second muon in the event
void collect() override final
Event processor The filling of the tree.
double m_mu0_z0
z0 track parameter of the first muon in the event
double m_mu1_phi0
phi0 track parameter of the second muon in the event
double m_mu0_omega
omega track parameter of the first muon in the event
double m_mu0_d0
d0 track parameter of the first muon in the event
double m_mu0_phi0
phi0 track parameter of the first muon in the event
Calibration collector module base class.
StoreObjPtr< EventMetaData > m_emd
Current EventMetaData.
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
Class to store reconstructed particles.
Definition: Particle.h:75
const TrackFitResult * getTrackFitResult() const
Returns the pointer to the TrackFitResult that was used to create this Particle (ParticleType == c_Tr...
Definition: Particle.cc:854
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
bool isValid() const
Check whether the object was created.
Definition: StoreObjPtr.h:111
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.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#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.