Belle II Software development
ContinuumSuppression.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 <analysis/ContinuumSuppression/ContinuumSuppression.h>
10#include <analysis/ContinuumSuppression/Thrust.h>
11#include <analysis/ContinuumSuppression/KsfwMoments.h>
12#include <analysis/ContinuumSuppression/FoxWolfram.h>
13#include <analysis/ContinuumSuppression/CleoCones.h>
14#include <analysis/dataobjects/RestOfEvent.h>
15#include <analysis/dataobjects/ContinuumSuppression.h>
16#include <analysis/utility/PCmsLabTransform.h>
17#include <framework/datastore/StoreArray.h>
18
19#include <vector>
20#include <Math/Vector3D.h>
21
22namespace Belle2 {
28 void addContinuumSuppression(const Particle* particle, const std::string& maskName)
29 {
30 // Output
31 StoreArray<ContinuumSuppression> qqArray(maskName);
32 // Create ContinuumSuppression object
33 ContinuumSuppression* qqVars = qqArray.appendNew();
34
35 // Create relation: Particle <-> ContinuumSuppression
36 particle->addRelationTo(qqVars);
37
38 std::vector<ROOT::Math::PxPyPzEVector> p_cms_sigB, p_cms_roe, p_cms_all;
39
40 std::vector<std::pair<ROOT::Math::PxPyPzEVector, int>> p_cms_q_sigA;
41 std::vector<std::pair<ROOT::Math::PxPyPzEVector, int>> p_cms_q_sigB;
42 std::vector<std::pair<ROOT::Math::PxPyPzEVector, int>> p_cms_q_roe;
43
44 std::vector<float> ksfwFS0;
45 std::vector<float> ksfwFS1;
46
47 std::vector<float> cleoConesAll;
48 std::vector<float> cleoConesROE;
49
50 double et[2];
51
52 ROOT::Math::XYZVector thrustB;
53 ROOT::Math::XYZVector thrustO;
54
55 float thrustBm = -1;
56 float thrustOm = -1;
57 float cosTBTO = -1;
58 float cosTBz = -1;
59 float R2 = -1;
60
61
62 // -- B Cand --------------------------------------------------------------------------
64 double BeamEnergy = T.getCMSEnergy() / 2;
65
66 ROOT::Math::PxPyPzEVector p_cms_missA(0, 0, 0, 2 * BeamEnergy);
67 ROOT::Math::PxPyPzEVector p_cms_missB(0, 0, 0, 2 * BeamEnergy);
68 et[0] = et[1] = 0;
69
70 // -- SIG A --- Use B primary daughters - (Belle: use_finalstate_for_sig == 0) --------
71 std::vector<Belle2::Particle*> signalDaughters = particle->getDaughters();
72
73 for (const Belle2::Particle* sigFS0 : signalDaughters) {
74 ROOT::Math::PxPyPzEVector p_cms = T.rotateLabToCms() * sigFS0->get4Vector();
75
76 p_cms_q_sigA.emplace_back(p_cms, sigFS0->getCharge());
77
78 p_cms_missA -= p_cms;
79 et[0] += p_cms.Pt();
80 }
81
82 // -- SIG B --- Use B final-state daughters - (Belle: use_finalstate_for_sig == 1) ----
83 std::vector<const Belle2::Particle*> signalFSParticles = particle->getFinalStateDaughters();
84
85 for (const Belle2::Particle* sigFS1 : signalFSParticles) {
86 ROOT::Math::PxPyPzEVector p_cms = T.rotateLabToCms() * sigFS1->get4Vector();
87
88 p_cms_all.push_back(p_cms);
89 p_cms_sigB.push_back(p_cms);
90
91 p_cms_q_sigB.emplace_back(p_cms, sigFS1->getCharge());
92
93 p_cms_missB -= p_cms;
94 et[1] += p_cms.Pt();
95 }
96
97 // -- ROE -----------------------------------------------------------------------------
98 const RestOfEvent* roe = particle->getRelated<RestOfEvent>();
99
100 if (roe) {
101
102 // Charged tracks
103 //
104 std::vector<const Particle*> chargedROEParticles = roe->getChargedParticles(maskName);
105
106 for (const Particle* chargedROEParticle : chargedROEParticles) {
107
108 // TODO: Add helix and KVF with IpProfile once available. Port from L163-199 of:
109 // /belle/b20090127_0910/src/anal/ekpcontsuppress/src/ksfwmoments.cc
110
111 ROOT::Math::PxPyPzEVector p_cms = T.rotateLabToCms() * chargedROEParticle->get4Vector();
112
113 p_cms_all.push_back(p_cms);
114 p_cms_roe.push_back(p_cms);
115
116 p_cms_q_roe.emplace_back(p_cms, chargedROEParticle->getCharge());
117
118 p_cms_missA -= p_cms;
119 p_cms_missB -= p_cms;
120 et[0] += p_cms.Pt();
121 et[1] += p_cms.Pt();
122 }
123
124 // ECLCluster
125 //
126 std::vector<const Particle*> roePhotons = roe->getPhotons(maskName);
127
128 for (const Particle* photon : roePhotons) {
129
130 if (photon->getECLClusterEHypothesisBit() == ECLCluster::EHypothesisBit::c_nPhotons) {
131
132 ROOT::Math::PxPyPzEVector p_cms = T.rotateLabToCms() * photon->get4Vector();
133 p_cms_all.push_back(p_cms);
134 p_cms_roe.push_back(p_cms);
135
136 p_cms_q_roe.emplace_back(p_cms, photon->getCharge());
137
138 p_cms_missA -= p_cms;
139 p_cms_missB -= p_cms;
140 et[0] += p_cms.Pt();
141 et[1] += p_cms.Pt();
142 }
143 }
144
145 // Thrust variables
146 thrustB = Thrust::calculateThrust(p_cms_sigB);
147 thrustO = Thrust::calculateThrust(p_cms_roe);
148 thrustBm = thrustB.R();
149 thrustOm = thrustO.R();
150 cosTBTO = fabs(thrustB.Unit().Dot(thrustO.Unit()));
151 cosTBz = fabs(cos(thrustB.Theta()));
152
153 // Cleo Cones
154 CleoCones cc(p_cms_all, p_cms_roe, thrustB, true, true);
155 cleoConesAll = cc.cleo_cone_with_all();
156 cleoConesROE = cc.cleo_cone_with_roe();
157
158 // Fox-Wolfram Moments: Uses all final-state tracks (= sigB + ROE)
159 FoxWolfram FW(p_cms_all);
161 R2 = FW.getR(2);
162
163 // KSFW moments
164 ROOT::Math::PxPyPzEVector p_cms_B = T.rotateLabToCms() * particle->get4Vector();
165 double Hso0_max(2 * (2 * BeamEnergy - p_cms_B.E()));
166 KsfwMoments KsfwM(Hso0_max,
167 p_cms_q_sigA,
168 p_cms_q_sigB,
169 p_cms_q_roe,
170 p_cms_missA,
171 p_cms_missB,
172 et);
173 // use_finalstate_for_sig == 0
174 KsfwM.usefinal(0);
175 ksfwFS0.push_back(KsfwM.mm2());
176 ksfwFS0.push_back(KsfwM.et());
177 ksfwFS0.push_back(KsfwM.Hso(0, 0));
178 ksfwFS0.push_back(KsfwM.Hso(0, 1));
179 ksfwFS0.push_back(KsfwM.Hso(0, 2));
180 ksfwFS0.push_back(KsfwM.Hso(0, 3));
181 ksfwFS0.push_back(KsfwM.Hso(0, 4));
182 ksfwFS0.push_back(KsfwM.Hso(1, 0));
183 ksfwFS0.push_back(KsfwM.Hso(1, 2));
184 ksfwFS0.push_back(KsfwM.Hso(1, 4));
185 ksfwFS0.push_back(KsfwM.Hso(2, 0));
186 ksfwFS0.push_back(KsfwM.Hso(2, 2));
187 ksfwFS0.push_back(KsfwM.Hso(2, 4));
188 ksfwFS0.push_back(KsfwM.Hoo(0));
189 ksfwFS0.push_back(KsfwM.Hoo(1));
190 ksfwFS0.push_back(KsfwM.Hoo(2));
191 ksfwFS0.push_back(KsfwM.Hoo(3));
192 ksfwFS0.push_back(KsfwM.Hoo(4));
193 // use_finalstate_for_sig == 1
194 KsfwM.usefinal(1);
195 ksfwFS1.push_back(KsfwM.mm2());
196 ksfwFS1.push_back(KsfwM.et());
197 ksfwFS1.push_back(KsfwM.Hso(0, 0));
198 ksfwFS1.push_back(KsfwM.Hso(0, 1));
199 ksfwFS1.push_back(KsfwM.Hso(0, 2));
200 ksfwFS1.push_back(KsfwM.Hso(0, 3));
201 ksfwFS1.push_back(KsfwM.Hso(0, 4));
202 ksfwFS1.push_back(KsfwM.Hso(1, 0));
203 ksfwFS1.push_back(KsfwM.Hso(1, 2));
204 ksfwFS1.push_back(KsfwM.Hso(1, 4));
205 ksfwFS1.push_back(KsfwM.Hso(2, 0));
206 ksfwFS1.push_back(KsfwM.Hso(2, 2));
207 ksfwFS1.push_back(KsfwM.Hso(2, 4));
208 ksfwFS1.push_back(KsfwM.Hoo(0));
209 ksfwFS1.push_back(KsfwM.Hoo(1));
210 ksfwFS1.push_back(KsfwM.Hoo(2));
211 ksfwFS1.push_back(KsfwM.Hoo(3));
212 ksfwFS1.push_back(KsfwM.Hoo(4));
213
214 // TODO: The following is from the original belle ksfwmoments.cc module.
215 // Not sure if necessary here (i.e., will we be using rooksfw in belle II in the same way?).
216 // printf("rooksfw::rooksfw: mm2=%f et=%f hoo2=%f hso02=%f\n",
217 // m_mm2[0], et[0], m_Hoo[0][2], m_Hso[0][0][2]);
218 }
219
220 // Fill ContinuumSuppression with content
221 qqVars->addThrustB(thrustB);
222 qqVars->addThrustO(thrustO);
223 qqVars->addThrustBm(thrustBm);
224 qqVars->addThrustOm(thrustOm);
225 qqVars->addCosTBTO(cosTBTO);
226 qqVars->addCosTBz(cosTBz);
227 qqVars->addR2(R2);
228 qqVars->addKsfwFS0(ksfwFS0);
229 qqVars->addKsfwFS1(ksfwFS1);
230 qqVars->addCleoConesALL(cleoConesAll);
231 qqVars->addCleoConesROE(cleoConesROE);
232 }
234}
Class to calculate the Cleo clone variables.
Definition: CleoCones.h:23
This is a class for collecting variables used in continuum suppression.
void addR2(float R2)
Add reduced Fox-Wolfram moment R2.
void addThrustBm(float thrustBm)
Add magnitude of B thrust axis.
void addCleoConesALL(const std::vector< float > &cleoConesALL)
Add vector of Cleo Cones constructed of all final state particles.
void addCleoConesROE(const std::vector< float > &cleoConesROE)
Add vector of Cleo Cones constructed of only ROE particles.
void addThrustB(const ROOT::Math::XYZVector &thrustB)
Add ROE thrust axis.
void addCosTBz(float cosTBz)
Add cosine of the angle between the thrust axis of the B and the z-axis.
void addThrustOm(float thrustOm)
Add magnitude of ROE thrust axis.
void addKsfwFS0(const std::vector< float > &ksfwFS0)
Add vector of KSFW moments, Et, and mm2 for final state = 0.
void addThrustO(const ROOT::Math::XYZVector &thrustO)
Add ROE thrust axis.
void addKsfwFS1(const std::vector< float > &ksfwFS1)
Add vector of KSFW moments, Et, and mm2 for final state = 1.
void addCosTBTO(float cosTBTO)
Add cosine of the angle between the thrust axis of the B and the thrust axis of the ROE.
@ c_nPhotons
CR is split into n photons (N1)
Class to calculate the Fox-Wolfram moments up to order 8.
Definition: FoxWolfram.h:28
double getR(int i) const
Returns the i-th moment normalized to the 0th-order moment.
Definition: FoxWolfram.h:89
void calculateBasicMoments()
Method to perform the calculation of the moments up to order 4, which are the most relevant ones.
Definition: FoxWolfram.cc:14
Moment-calculation of the k_sfw improved Super-Fox-Wolfram moments.
Definition: KsfwMoments.h:34
int usefinal(int uf)
Sets the flag that specifiies we are using the finalstate for signal.
Definition: KsfwMoments.h:77
double et(int uf=-1) const
Returns calculated transverse energy.
Definition: KsfwMoments.h:92
double Hso(int i, int j, int uf=-1) const
Returns calculated KSFW Moments.
Definition: KsfwMoments.h:102
double mm2(int uf=-1) const
Returns calculated missing mass squared.
Definition: KsfwMoments.h:87
double Hoo(int i, int uf=-1) const
Returns calculated KSFW Moments.
Definition: KsfwMoments.h:97
Class to hold Lorentz transformations from/to CMS and boost vector.
double getCMSEnergy() const
Returns CMS energy of e+e- (aka.
const ROOT::Math::LorentzRotation rotateLabToCms() const
Returns Lorentz transformation from Lab to CMS.
Class to store reconstructed particles.
Definition: Particle.h:76
This is a general purpose class for collecting reconstructed MDST data objects that are not used in r...
Definition: RestOfEvent.h:57
std::vector< const Particle * > getChargedParticles(const std::string &maskName=c_defaultMaskName, unsigned int pdg=0, bool unpackComposite=true) const
Get charged particles from ROE mask.
Definition: RestOfEvent.cc:103
std::vector< const Particle * > getPhotons(const std::string &maskName=c_defaultMaskName, bool unpackComposite=true) const
Get photons from ROE mask.
Definition: RestOfEvent.cc:79
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246
static ROOT::Math::XYZVector calculateThrust(const std::vector< ROOT::Math::PxPyPzEVector > &momenta)
calculates the thrust axis
Definition: Thrust.cc:71
void addContinuumSuppression(const Particle *particle, const std::string &maskName)
Adds continuum suppression variables.
Abstract base class for different kinds of events.