11 #include <analysis/utility/PCmsLabTransform.h>
13 #include <analysis/modules/EventShapeCalculator/EventShapeCalculatorModule.h>
15 #include <analysis/dataobjects/ParticleList.h>
16 #include <analysis/dataobjects/Particle.h>
17 #include <analysis/dataobjects/EventShapeContainer.h>
19 #include <framework/datastore/StoreObjPtr.h>
21 #include <framework/logging/Logger.h>
25 #include <analysis/ContinuumSuppression/Thrust.h>
26 #include <analysis/ContinuumSuppression/HarmonicMoments.h>
27 #include <analysis/ContinuumSuppression/CleoCones.h>
28 #include <analysis/ContinuumSuppression/FoxWolfram.h>
29 #include <analysis/ContinuumSuppression/SphericityEigenvalues.h>
32 #include <TLorentzVector.h>
50 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 setPropertyFlags(c_ParallelProcessingCertified);
53 addParam(
"particleListNames", m_particleListNames,
"List of the ParticleLists to be used for the calculation of the EventShapes.",
55 addParam(
"enableThrust", m_enableThrust,
"Enables the calculation of thust-related quantities.",
true);
56 addParam(
"enableCollisionAxis", m_enableCollisionAxis,
"Enables the calculation of the quantities related to the collision axis.",
58 addParam(
"enableFoxWolfram", m_enableFW,
"Enables the calculation of the Fox-Wolfram moments.",
true);
59 addParam(
"enableHarmonicMoments", m_enableHarmonicMoments,
"Enables the calculation of the Harmonic moments.",
true);
60 addParam(
"enableJets", m_enableJets,
"Enables the calculation of jet-related quantities.",
true);
61 addParam(
"enableSphericity", m_enableSphericity,
"Enables the calculation of the sphericity-related quantities.",
true);
62 addParam(
"enableCleoCones", m_enableCleoCones,
"Enables the calculation of the CLEO cones.",
true);
63 addParam(
"enableAllMoments", m_enableAllMoments,
"Enables the calculation of FW and harmonic moments from 5 to 8",
false);
64 addParam(
"checkForDuplicates", m_checkForDuplicates,
65 "Enables the check for duplicates in the input list. If a duplicate entry is found, the first one is kept.",
false);
69 void EventShapeCalculatorModule::initialize()
72 evtShapeContainer.registerInDataStore();
76 void EventShapeCalculatorModule::event()
83 if (!eventShapeContainer) eventShapeContainer.create();
85 parseParticleLists(m_particleListNames);
93 if (m_enableAllMoments) {
95 for (
short i = 0; i < 9; i++) {
96 eventShapeContainer->setFWMoment(i, fw.
getH(i));
100 for (
short i = 0; i < 5; i++) {
101 eventShapeContainer->setFWMoment(i, fw.
getH(i));
109 if (m_enableSphericity) {
114 B2WARNING(
"Eigenvalues not ordered!!!!!!!!!!");
116 for (
short i = 0; i < 3; i++) {
117 eventShapeContainer->setSphericityEigenvalue(i, Sph.
getEigenvalue(i));
118 eventShapeContainer->setSphericityEigenvector(i, Sph.
getEigenvector(i));
126 if (m_enableThrust) {
127 TVector3 thrust = Thrust::calculateThrust(m_p3List);
128 float thrustVal = thrust.Mag();
129 thrust = (1. / thrustVal) * thrust;
130 eventShapeContainer->setThrustAxis(thrust);
131 eventShapeContainer->setThrust(thrustVal);
134 if (m_enableHarmonicMoments) {
136 if (m_enableAllMoments) {
137 MM.calculateAllMoments();
138 for (
short i = 0; i < 9; i++) {
139 auto moment = MM.getMoment(i, sqrtS);
140 eventShapeContainer->setHarmonicMomentThrust(i, moment);
143 MM.calculateBasicMoments();
144 for (
short i = 0; i < 5; i++) {
145 auto moment = MM.getMoment(i, sqrtS);
146 eventShapeContainer->setHarmonicMomentThrust(i, moment);
152 if (m_enableCleoCones) {
159 CleoCones cleoCones(m_p3List, m_p3List, thrust,
true,
false);
160 std::vector<float> cones;
161 cones = cleoCones.cleo_cone_with_all();
162 for (
short i = 0; i < 10; i++) {
163 eventShapeContainer->setCleoConeThrust(i, cones[i]);
170 TLorentzVector p4FWD(0., 0., 0., 0.);
171 TLorentzVector p4BKW(0., 0., 0., 0.);
172 for (
const auto& p4 : m_p4List) {
173 if (p4.Vect().Dot(thrust) > 0)
178 eventShapeContainer->setForwardHemisphere4Momentum(p4FWD);
179 eventShapeContainer->setBackwardHemisphere4Momentum(p4BKW);
188 if (m_enableCollisionAxis) {
190 TVector3 collisionAxis(0., 0., 1.);
193 if (m_enableCleoCones) {
194 CleoCones cleoCones(m_p3List, m_p3List, collisionAxis,
true,
false);
195 std::vector<float> cones;
196 cones = cleoCones.cleo_cone_with_all();
197 for (
short i = 0; i < 10; i++) {
198 eventShapeContainer->setCleoConeCollision(i, cones[i]);
203 if (m_enableHarmonicMoments) {
205 if (m_enableAllMoments) {
206 MM.calculateAllMoments();
207 for (
short i = 0; i < 9; i++) {
208 auto moment = MM.getMoment(i, sqrtS);
209 eventShapeContainer->setHarmonicMomentCollision(i, moment);
212 MM.calculateBasicMoments();
213 for (
short i = 0; i < 5; i++) {
214 auto moment = MM.getMoment(i, sqrtS);
215 eventShapeContainer->setHarmonicMomentCollision(i, moment);
224 int EventShapeCalculatorModule::parseParticleLists(vector<string> particleListNames)
232 unsigned short nParticleLists = particleListNames.size();
233 if (nParticleLists == 0)
234 B2ERROR(
"No particle lists found. EventShape calculation not performed.");
240 std::vector<Particle> tmpParticles;
243 for (
unsigned short iList = 0; iList < nParticleLists; iList++) {
244 string particleListName = particleListNames[iList];
248 for (
unsigned int iPart = 0; iPart < particleList->getListSize(); iPart++) {
249 const Particle* part = particleList->getParticle(iPart);
253 bool isDuplicate =
false;
255 if (m_checkForDuplicates) {
257 for (
const auto& testPart : tmpParticles) {
258 if (testPart.isCopyOf(part)) {
259 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.");
264 tmpParticles.push_back(*part);
271 m_p4List.push_back(p4CMS);
272 m_p3List.push_back(p4CMS.Vect());