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>
16 #include <framework/logging/Logger.h>
20 #include <analysis/ContinuumSuppression/Thrust.h>
21 #include <analysis/ContinuumSuppression/HarmonicMoments.h>
22 #include <analysis/ContinuumSuppression/CleoCones.h>
23 #include <analysis/ContinuumSuppression/FoxWolfram.h>
24 #include <analysis/ContinuumSuppression/SphericityEigenvalues.h>
27 #include <TLorentzVector.h>
45 setDescription(
"Module to compute event shape attributes starting from particlelists. The core algorithms are not implemented in this module, but in dedicated basf2 classes.");
46 setPropertyFlags(c_ParallelProcessingCertified);
48 addParam(
"particleListNames", m_particleListNames,
"List of the ParticleLists to be used for the calculation of the EventShapes.",
50 addParam(
"enableThrust", m_enableThrust,
"Enables the calculation of thust-related quantities.",
true);
51 addParam(
"enableCollisionAxis", m_enableCollisionAxis,
"Enables the calculation of the quantities related to the collision axis.",
53 addParam(
"enableFoxWolfram", m_enableFW,
"Enables the calculation of the Fox-Wolfram moments.",
true);
54 addParam(
"enableHarmonicMoments", m_enableHarmonicMoments,
"Enables the calculation of the Harmonic moments.",
true);
55 addParam(
"enableJets", m_enableJets,
"Enables the calculation of jet-related quantities.",
true);
56 addParam(
"enableSphericity", m_enableSphericity,
"Enables the calculation of the sphericity-related quantities.",
true);
57 addParam(
"enableCleoCones", m_enableCleoCones,
"Enables the calculation of the CLEO cones.",
true);
58 addParam(
"enableAllMoments", m_enableAllMoments,
"Enables the calculation of FW and harmonic moments from 5 to 8",
false);
59 addParam(
"checkForDuplicates", m_checkForDuplicates,
60 "Enables the check for duplicates in the input list. If a duplicate entry is found, the first one is kept.",
false);
64 void EventShapeCalculatorModule::initialize()
66 m_eventShapeContainer.registerInDataStore();
70 void EventShapeCalculatorModule::event()
76 if (!m_eventShapeContainer) m_eventShapeContainer.create();
78 parseParticleLists(m_particleListNames);
86 if (m_enableAllMoments) {
88 for (
short i = 0; i < 9; i++) {
89 m_eventShapeContainer->setFWMoment(i, fw.
getH(i));
93 for (
short i = 0; i < 5; i++) {
94 m_eventShapeContainer->setFWMoment(i, fw.
getH(i));
102 if (m_enableSphericity) {
107 B2WARNING(
"Eigenvalues not ordered!!!!!!!!!!");
109 for (
short i = 0; i < 3; i++) {
110 m_eventShapeContainer->setSphericityEigenvalue(i, Sph.
getEigenvalue(i));
111 m_eventShapeContainer->setSphericityEigenvector(i, Sph.
getEigenvector(i));
119 if (m_enableThrust) {
120 TVector3 thrust = Thrust::calculateThrust(m_p3List);
121 float thrustVal = thrust.Mag();
122 thrust = (1. / thrustVal) * thrust;
123 m_eventShapeContainer->setThrustAxis(thrust);
124 m_eventShapeContainer->setThrust(thrustVal);
127 if (m_enableHarmonicMoments) {
129 if (m_enableAllMoments) {
130 MM.calculateAllMoments();
131 for (
short i = 0; i < 9; i++) {
132 auto moment = MM.getMoment(i, sqrtS);
133 m_eventShapeContainer->setHarmonicMomentThrust(i, moment);
136 MM.calculateBasicMoments();
137 for (
short i = 0; i < 5; i++) {
138 auto moment = MM.getMoment(i, sqrtS);
139 m_eventShapeContainer->setHarmonicMomentThrust(i, moment);
145 if (m_enableCleoCones) {
152 CleoCones cleoCones(m_p3List, m_p3List, thrust,
true,
false);
153 std::vector<float> cones;
154 cones = cleoCones.cleo_cone_with_all();
155 for (
short i = 0; i < 10; i++) {
156 m_eventShapeContainer->setCleoConeThrust(i, cones[i]);
163 TLorentzVector p4FWD(0., 0., 0., 0.);
164 TLorentzVector p4BKW(0., 0., 0., 0.);
165 for (
const auto& p4 : m_p4List) {
166 if (p4.Vect().Dot(thrust) > 0)
171 m_eventShapeContainer->setForwardHemisphere4Momentum(p4FWD);
172 m_eventShapeContainer->setBackwardHemisphere4Momentum(p4BKW);
181 if (m_enableCollisionAxis) {
183 TVector3 collisionAxis(0., 0., 1.);
186 if (m_enableCleoCones) {
187 CleoCones cleoCones(m_p3List, m_p3List, collisionAxis,
true,
false);
188 std::vector<float> cones;
189 cones = cleoCones.cleo_cone_with_all();
190 for (
short i = 0; i < 10; i++) {
191 m_eventShapeContainer->setCleoConeCollision(i, cones[i]);
196 if (m_enableHarmonicMoments) {
198 if (m_enableAllMoments) {
199 MM.calculateAllMoments();
200 for (
short i = 0; i < 9; i++) {
201 auto moment = MM.getMoment(i, sqrtS);
202 m_eventShapeContainer->setHarmonicMomentCollision(i, moment);
205 MM.calculateBasicMoments();
206 for (
short i = 0; i < 5; i++) {
207 auto moment = MM.getMoment(i, sqrtS);
208 m_eventShapeContainer->setHarmonicMomentCollision(i, moment);
217 int EventShapeCalculatorModule::parseParticleLists(vector<string> particleListNames)
225 unsigned short nParticleLists = particleListNames.size();
226 if (nParticleLists == 0)
227 B2ERROR(
"No particle lists found. EventShape calculation not performed.");
233 std::vector<Particle> tmpParticles;
236 for (
unsigned short iList = 0; iList < nParticleLists; iList++) {
237 string particleListName = particleListNames[iList];
241 for (
unsigned int iPart = 0; iPart < particleList->getListSize(); iPart++) {
242 const Particle* part = particleList->getParticle(iPart);
246 bool isDuplicate =
false;
248 if (m_checkForDuplicates) {
250 for (
const auto& testPart : tmpParticles) {
251 if (testPart.isCopyOf(part)) {
252 B2WARNING(
"Duplicate particle found. The new one won't be used for the calculation of the event shape variables. Please, double check your input lists and try to make them mutually exclusive.");
257 tmpParticles.push_back(*part);
264 m_p4List.push_back(p4CMS);
265 m_p3List.push_back(p4CMS.Vect());
Class to calculate the Cleo clone variables.
Module to compute event shape variables starting from three lists of particle objects (tracks,...
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.
Class to store reconstructed particles.
Class to calculate the Sphericity tensor eigenvalues and eigenvectors starting from an array of 3-mom...
TVector3 getEigenvector(short i) const
Returns the i-th Eigenvector.
void calculateEigenvalues()
Calculates eigenvalues and eigenvectors.
double getEigenvalue(short i) const
Returns the i-th Eigenvalue.
Type-safe access to single objects in the data store.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.