9#include <analysis/modules/PostMergeUpdate/PostMergeUpdaterModule.h>
10#include <mdst/dbobjects/BeamSpot.h>
11#include <framework/logging/Logger.h>
12#include <analysis/utility/RotationTools.h>
13#include <analysis/utility/PCmsLabTransform.h>
14#include <TDatabasePDG.h>
15#include <Math/Vector3D.h>
27 setDescription(
"Synchronize parts of the events post merge/embedding. Used in the signal embedding pipeline. Uses kinematic information for the tag / simulated decay stored in eventExtraInfo.");
28 addParam(
"Mixing",
m_mixing,
"Mixing (true) or embedding (false) corrections",
false);
71 const double mB = TDatabasePDG::Instance()->GetParticle(iPDG)->Mass();
72 double E = sqrt(mB * mB + sec3v.
Mag2());
73 ROOT::Math::PxPyPzEVector sec4v(sec3v.
X(), sec3v.
Y(), sec3v.
Z(), E);
74 ROOT::Math::PxPyPzEVector secCMS = T.
labToCms(sec4v);
77 ROOT::Math::PxPyPzEVector secRoeCMS(-secCMS.X(), -secCMS.Y(), -secCMS.Z(), secCMS.E());
78 ROOT::Math::PxPyPzEVector sec4roe = T.
cmsToLab(secRoeCMS);
81 sec3v.
SetXYZ(sec4roe.X(), sec4roe.Y(), sec4roe.Z());
89 rot.Rotate(-acos(dot), cros);
93 double smallValue = 1e-12;
94 if ((abs(sin(test.Phi() - tag3v.
Phi())) > smallValue) or (abs(test.Theta() - tag3v.
Theta()) > smallValue)) {
95 B2ERROR(
"Loss of accuracy during rotation" <<
LogVar(
"Delta phi", abs(sin(test.Phi() - tag3v.
Phi())))
96 <<
LogVar(
"Delta Theta", abs(test.Theta() - tag3v.
Theta())));
99 B2ERROR(
"No momentum information provided for the tag/simulated particle list, can not update tracks");
118 const B2Vector3D beamSpot = beamSpotDB->getIPPosition();
126 for (
short int i :
m_tracks[idxTr]->getValidIndices()) {
127 auto t_idx =
m_tracks[idxTr]->m_trackFitIndices[i];
129 short charge =
m_trackFits[t_idx]->getChargeSign();
132 helixO.passiveMoveBy(origSpot - beamSpot);
140 Helix helix(ROOT::Math::XYZVector(position.
X(), position.
Y(), position.
Z()),
141 ROOT::Math::XYZVector(momentum.
X(), momentum.
Y(), momentum.
Z()), charge, bz);
156 B2ERROR(
"No vertex info, can not update tracks");
182 for (
short int i :
m_tracks[idxTr]->getValidIndices()) {
183 auto t_idx =
m_tracks[idxTr]->m_trackFitIndices[i];
187 helix.passiveMoveBy(vertexEmb);
190 short charge =
m_trackFits[t_idx]->getChargeSign();
200 Helix h(vertexTag, momTag, charge, bz);
214 B2ERROR(
"No track parameters info, can not update tracks");
DataType Phi() const
The azimuth angle.
DataType Z() const
access variable Z (= .at(2) without boundary check)
DataType Theta() const
The polar angle.
B2Vector3< DataType > Cross(const B2Vector3< DataType > &p) const
Cross product.
DataType X() const
access variable X (= .at(0) without boundary check)
DataType Y() const
access variable Y (= .at(1) without boundary check)
DataType Mag2() const
The magnitude squared (rho^2 in spherical coordinate system).
DataType Dot(const B2Vector3< DataType > &p) const
Scalar product.
B2Vector3< DataType > Unit() const
Unit vector parallel to this.
void SetXYZ(DataType x, DataType y, DataType z)
set all coordinates using data type
static ROOT::Math::XYZVector getFieldInTesla(const ROOT::Math::XYZVector &pos)
return the magnetic field at a given position in Tesla.
Class for accessing objects in the database.
This class represents an ideal helix in perigee parameterization.
double getOmega() const
Getter for omega, which is a signed curvature measure of the track.
double getD0() const
Getter for d0, which is the signed distance to the perigee in the r-phi plane.
double getTanLambda() const
Getter for tan lambda, which is the z over two dimensional arc length slope of the track.
double getZ0() const
Getter for z0, which is the z coordinate of the perigee.
double getPhi0() const
Getter for phi0, which is the azimuth angle of the transverse momentum at the perigee.
void setDescription(const std::string &description)
Sets the description of the module.
StoreObjPtr< EventExtraInfo > m_eventExtraInfo_orig
Event extra info original.
TRotation tag_vertex_rotation()
Helper function to determine rotation matrix.
bool m_isCharged
B+ or B0.
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
StoreArray< Track > m_tracks
tracks
void cluster_rotation(const TRotation &rot)
Rotate clusters.
StoreArray< TrackFitResult > m_trackFits
track fits
PostMergeUpdaterModule()
Constructor.
StoreObjPtr< EventExtraInfo > m_mergedArrayIndices
indices where the StoreArrays were merged
StoreObjPtr< EventExtraInfo > m_eventExtraInfo
Event extra info.
StoreArray< ECLCluster > m_eclclusters
StoreArray of ECLCluster.
bool m_mixing
Fix to common vertex.
static const unsigned int iZ0
Index for z0.
static const unsigned int iTanLambda
Index tan lambda.
static const unsigned int iD0
Index for d0.
static const unsigned int iOmega
Index for omega.
static const unsigned int iPhi0
Index for phi0.
Class to store variables with their name which were sent to the logging service.
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.
B2Vector3< double > B2Vector3D
typedef for common usage with double
Abstract base class for different kinds of events.