9#include <analysis/utility/PCmsLabTransform.h>
11#include <analysis/modules/EventShapeCalculator/EventShapeCalculatorModule.h>
13#include <analysis/dataobjects/ParticleList.h>
14#include <analysis/dataobjects/Particle.h>
15#include <mdst/dataobjects/MCParticle.h>
17#include <framework/logging/Logger.h>
19#include <analysis/ContinuumSuppression/Thrust.h>
20#include <analysis/ContinuumSuppression/HarmonicMoments.h>
21#include <analysis/ContinuumSuppression/CleoCones.h>
22#include <analysis/ContinuumSuppression/FoxWolfram.h>
23#include <analysis/ContinuumSuppression/SphericityEigenvalues.h>
25#include <Math/Vector4D.h>
43 setDescription(
"Module to compute event shape attributes starting from particlelists. The core algorithms are not implemented in this module, but in dedicated basf2 classes.");
51 addParam(
"enableFoxWolfram",
m_enableFW,
"Enables the calculation of the Fox-Wolfram moments.",
true);
53 addParam(
"enableJets",
m_enableJets,
"Enables the calculation of jet-related quantities.",
true);
58 "Enables the check for duplicates in the input list. If a duplicate entry is found, the first one is kept.",
false);
66 B2WARNING(
"The jet-related quantities can only be calculated if the thrust calculation is activated as well.");
70 B2WARNING(
"The CLEO cones can only be calculated if either the thrust or the collision axis calculation are activated as well.");
72 B2WARNING(
"The harmonic moments can only be calculated if either the thrust or the collision axis calculation are activated as well.");
85 if (nPart == 0)
return;
94 for (
short i = 0; i < 9; i++) {
99 for (
short i = 0; i < 5; i++) {
113 B2WARNING(
"Eigenvalues not ordered!!!!!!!!!!");
115 for (
short i = 0; i < 3; i++) {
127 float thrustVal = thrust.R();
128 thrust = thrust.Unit();
137 for (
short i = 0; i < 9; i++) {
143 for (
short i = 0; i < 5; i++) {
159 std::vector<float> cones;
160 cones = cleoCones.cleo_cone_with_all();
161 for (
short i = 0; i < 10; i++) {
169 ROOT::Math::PxPyPzEVector p4FWD;
170 ROOT::Math::PxPyPzEVector p4BKW;
172 if (p4.Vect().Dot(thrust) > 0)
189 ROOT::Math::XYZVector collisionAxis(0., 0., 1.);
194 std::vector<float> cones;
195 cones = cleoCones.cleo_cone_with_all();
196 for (
short i = 0; i < 10; i++) {
206 for (
short i = 0; i < 9; i++) {
212 for (
short i = 0; i < 5; i++) {
228 unsigned int nParticlesInAllLists = 0;
229 unsigned short nParticleLists = particleListNames.size();
230 if (nParticleLists == 0)
231 B2WARNING(
"No particle lists found. EventShape calculation not performed.");
237 std::vector<int> usedMdstSources;
240 for (
unsigned short iList = 0; iList < nParticleLists; iList++) {
241 string particleListName = particleListNames[iList];
245 nParticlesInAllLists += particleList->getListSize();
247 for (
unsigned int iPart = 0; iPart < particleList->getListSize(); iPart++) {
248 const Particle* part = particleList->getParticle(iPart);
250 if (mcParticle and mcParticle->
isInitial())
continue;
256 for (
const auto fsp : finalStateDaughters) {
257 int mdstSource = fsp->getMdstSource();
258 auto result = std::find(usedMdstSources.begin(), usedMdstSources.end(), mdstSource);
259 if (result == usedMdstSources.end()) {
260 usedMdstSources.push_back(mdstSource);
261 ROOT::Math::PxPyPzEVector p4CMS = T.
rotateLabToCms() * fsp->get4Vector();
263 B2DEBUG(19,
"non-duplicate has pdgCode " << fsp->getPDGCode() <<
" and mdstSource " << mdstSource);
265 B2DEBUG(19,
"duplicate has pdgCode " << fsp->getPDGCode() <<
" and mdstSource " << mdstSource);
266 B2DEBUG(19,
"Duplicate particle found. The new one won't be used for the calculation of the event shape variables. "
267 "Please, double check your input lists and try to make them mutually exclusive.");
277 return nParticlesInAllLists;
Class to calculate the Cleo clone variables.
int parseParticleLists(std::vector< std::string >)
Turns the ParticleLists provided as inputs into std::vector of PxPyPzEVector, after boosting them int...
bool m_enableCollisionAxis
Enables the calculation of the quantities related to the collision axis.
virtual void initialize() override
Define the physical parameters.
virtual void event() override
Main method, called for each events.
bool m_enableHarmonicMoments
Enables the calculation of the Harmonic moments.
std::vector< std::string > m_particleListNames
Names of the ParticleLists (inputs).
bool m_enableAllMoments
Enables the calculation of the FW moments from 5 to 8.
bool m_enableThrust
Enables the calculation of thrust-related quantities.
bool m_enableCleoCones
Enables the calculation of the Cleo Cones.
bool m_enableJets
Enables the calculation of the Jet-related quantities.
std::vector< ROOT::Math::PxPyPzEVector > m_p4List
vector containing all the 4-momenta of the particles contained in the input lists.
bool m_enableFW
Enables the calculation of the FW moments.
bool m_checkForDuplicates
Enables the check for the duplicates in the input list.
EventShapeCalculatorModule()
Constructor: Sets the description, the properties and the parameters of the module.
StoreObjPtr< EventShapeContainer > m_eventShapeContainer
event shape container object pointer
bool m_enableSphericity
Enables the calculation of the Sphericity matrix.
Class to calculate the Fox-Wolfram moments up to order 8.
void calculateAllMoments()
Method to perform the calculation of the moments up to order 8.
void calculateBasicMoments()
Method to perform the calculation of the moments up to order 4, which are the most relevant ones.
double getH(int i) const
Returns the i-th moment.
Class to calculate the Harmonic moments up to order 8 with respect to a given axis.
void calculateAllMoments()
Calculates the moments up to order 8.
double getMoment(short i, double sqrts) const
Returns the moment of order i.
void calculateBasicMoments()
Calculates the moments up to order 4.
A Class to store the Monte Carlo particle information.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Class to store reconstructed particles.
std::vector< const Belle2::Particle * > getFinalStateDaughters() const
Returns a vector of pointers to Final State daughter particles.
const MCParticle * getMCParticle() const
Returns the pointer to the MCParticle object that was used to create this Particle (ParticleType == c...
ROOT::Math::PxPyPzEVector get4Vector() const
Returns Lorentz vector.
Class to calculate the Sphericity tensor eigenvalues and eigenvectors starting from an array of 3-mom...
void calculateEigenvalues()
Calculates eigenvalues and eigenvectors.
ROOT::Math::XYZVector getEigenvector(short i) const
Returns the i-th Eigenvector.
double getEigenvalue(short i) const
Returns the i-th Eigenvalue.
Type-safe access to single objects in the data store.
static ROOT::Math::XYZVector calculateThrust(const std::vector< ROOT::Math::PxPyPzEVector > &momenta)
calculates the thrust axis
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
bool isInitial() const
Check if particle is an initial particle such as ISR.
Abstract base class for different kinds of events.