9#include <tracking/modules/eventTimeExtractor/SVDEventT0EstimatorModule.h>
10#include <framework/datastore/RelationArray.h>
11#include <framework/geometry/B2Vector3.h>
12#include <framework/dataobjects/EventT0.h>
13#include <tracking/dataobjects/RecoTrack.h>
14#include <tracking/dbobjects/SVDEventT0Configuration.h>
32 setDescription(
"This module estimates the EventT0 as the average of cluster time of SVD clusters associated to tracks. The EventT0 is set to NaN if there are not RecoTracks or there are not SVD clusters associated to tracks or RecoTrack pt < ptMin OR RecoTrack pz < pzMin. The EventT0 estimated is added to the temporaryEventT0s to the StoreObjPtr as EventT0Component that contains: eventT0, eventT0_error, detector=SVD, algorithm, quality.");
37 addParam(
"EventT0",
m_eventT0Name,
"Name of the StoreObjPtr with the input EventT0", std::string(
""));
40 "Cut on minimum absolute value of the longitudinal momentum, abs(pz), for RecoTrack selection",
43 "Cut on maximum absolute value of the d0 for RecoTrack selection",
m_absD0Selection);
45 "Cut on maximum absolute value of the z0 for RecoTrack selection",
m_absZ0Selection);
47 "Apply the selection based on the absolute values of d0 and z0 to select tracks from the IP to compute SVDEventT0",
49 addParam(
"useDB",
m_useDB,
"To compute EvetT0, use configuration of selections stored in the DB",
m_useDB);
72 B2FATAL(
"no valid configuration found for SVD EventT0 computation");
74 B2DEBUG(20,
"SVDEventT0Configuration: from now on we are using " <<
m_svdEventT0Config->get_uniqueID());
88 double evtT0 = std::numeric_limits<double>::quiet_NaN();
89 double evtT0Err = std::numeric_limits<double>::quiet_NaN();
90 double armTimeSum = 0;
91 double armTimeErrSum = 0;
92 double quality = std::numeric_limits<double>::quiet_NaN();
93 int numberOfSVDClusters = 0;
94 int numberOfRecoTracksUsed = 0;
95 float outgoingArmTime = 0;
96 float ingoingArmTime = 0;
97 float outgoingArmTimeError = 0;
98 float ingoingArmTimeError = 0;
102 const B2Vector3D& p = recoTrack.getMomentumSeed();
104 double d0 = uncertainHelix.getD0();
105 double z0 = uncertainHelix.getZ0();
118 outgoingArmTime = recoTrack.getOutgoingArmTime();
119 ingoingArmTime = recoTrack.getIngoingArmTime();
120 outgoingArmTimeError = recoTrack.getOutgoingArmTimeError();
121 ingoingArmTimeError = recoTrack.getIngoingArmTimeError();
122 bool hasOutgoingArm = recoTrack.hasOutgoingArmTime();
123 bool hasIngoingArm = recoTrack.hasIngoingArmTime();
126 if (hasOutgoingArm && hasIngoingArm) {
128 if (outgoingArmTime <= ingoingArmTime) {
129 armTimeSum += outgoingArmTime * recoTrack.getNSVDHitsOfOutgoingArm();
130 armTimeErrSum += outgoingArmTimeError * outgoingArmTimeError * recoTrack.getNSVDHitsOfOutgoingArm() *
131 (recoTrack.getNSVDHitsOfOutgoingArm() - 1);
132 numberOfSVDClusters += recoTrack.getNSVDHitsOfOutgoingArm();
134 armTimeSum += ingoingArmTime * recoTrack.getNSVDHitsOfIngoingArm();
135 armTimeErrSum += ingoingArmTimeError * ingoingArmTimeError * recoTrack.getNSVDHitsOfIngoingArm() *
136 (recoTrack.getNSVDHitsOfIngoingArm() - 1);
137 numberOfSVDClusters += recoTrack.getNSVDHitsOfIngoingArm();
139 numberOfRecoTracksUsed += 1;
140 }
else if (hasOutgoingArm && !hasIngoingArm) {
141 armTimeSum += outgoingArmTime * recoTrack.getNSVDHitsOfOutgoingArm();
142 armTimeErrSum += outgoingArmTimeError * outgoingArmTimeError * recoTrack.getNSVDHitsOfOutgoingArm() *
143 (recoTrack.getNSVDHitsOfOutgoingArm() - 1);
144 numberOfSVDClusters += recoTrack.getNSVDHitsOfOutgoingArm();
145 numberOfRecoTracksUsed += 1;
146 }
else if (!hasOutgoingArm && hasIngoingArm) {
147 armTimeSum += ingoingArmTime * recoTrack.getNSVDHitsOfIngoingArm();
148 armTimeErrSum += ingoingArmTimeError * ingoingArmTimeError * recoTrack.getNSVDHitsOfIngoingArm() *
149 (recoTrack.getNSVDHitsOfIngoingArm() - 1);
150 numberOfSVDClusters += recoTrack.getNSVDHitsOfIngoingArm();
151 numberOfRecoTracksUsed += 1;
157 if ((numberOfRecoTracksUsed == 0) || !(
m_eventT0.isValid()))
return;
161 evtT0 = armTimeSum / numberOfSVDClusters;
162 quality = numberOfSVDClusters;
165 if (numberOfSVDClusters > 1)
166 evtT0Err = std::sqrt(armTimeErrSum / (numberOfSVDClusters * (numberOfSVDClusters - 1)));
168 evtT0Err = std::sqrt(armTimeErrSum);
172 m_eventT0->addTemporaryEventT0(evtT0Component);
184 if (charge < 0) charge = -1;
186 const float pValue = float(std::numeric_limits<double>::quiet_NaN());
189 const UncertainHelix uncertainHelix(position, momentum, charge, bField, covariance, pValue);
191 return uncertainHelix;
static ROOT::Math::XYZVector getFieldInTesla(const ROOT::Math::XYZVector &pos)
return the magnetic field at a given position in Tesla.
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...
This is the Reconstruction Event-Data Model Track.
const TMatrixDSym & getSeedCovariance() const
Return the covariance matrix of the seed. ATTENTION: This is not the fitted covariance.
ROOT::Math::XYZVector getPositionSeed() const
Return the position seed stored in the reco track. ATTENTION: This is not the fitted position.
short int getChargeSeed() const
Return the charge seed stored in the reco track. ATTENTION: This is not the fitted charge.
ROOT::Math::XYZVector getMomentumSeed() const
Return the momentum seed stored in the reco track. ATTENTION: This is not the fitted momentum.
double m_absPzSelection
Cut on abs(pz) for RecoTrack selection.
StoreObjPtr< EventT0 > m_eventT0
EventT0 StoreObjPtr.
bool m_selectTracksFromIP
Apply the selection based on the absolute values of d0 and z0 to select tracks from the IP to compute...
double m_absD0Selection
Cut on abs(d0), in cm, for RecoTrack selection.
virtual void initialize() override
Initialize the SVDEventT0Estimator.
std::string m_algorithm
name of the algorithm used to evaluate SVD-eventT0
virtual void event() override
This method is the core of the SVDEventT0Estimator.
double m_absZ0Selection
Cut on abs(z0), in cm, for RecoTrack selection.
void beginRun() override
Configure.
std::string m_recoTracksName
name of RecoTracks StoreArray
double m_ptSelection
Cut on pt for RecoTrack selection.
DBObjPtr< SVDEventT0Configuration > m_svdEventT0Config
SVD EventT0 Reconstruction Configuration payload.
const UncertainHelix constructUncertainHelix(const RecoTrack &recoTrack)
return the UncertainHelix from the seed quantities of the RecoTrack
std::string m_eventT0Name
name of StoreObj EventT0
StoreArray< RecoTrack > m_recoTracks
RecoTracks StoreArray.
virtual ~SVDEventT0EstimatorModule()
default destructor
bool m_useDB
To compute EvetT0, use configuration of selections stored in the DB.
SVDEventT0EstimatorModule()
Constructor defining the parameters.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
This class represents an ideal helix in perigee parameterization including the covariance matrix of t...
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.
Abstract base class for different kinds of events.
Structure for storing the extracted event t0s together with its detector and its uncertainty.