9#include <svd/modules/svdPerformance/SVDPerformanceTTreeModule.h>
10#include <framework/datastore/StoreArray.h>
11#include <framework/gearbox/Unit.h>
12#include <framework/core/Environment.h>
13#include <svd/dataobjects/SVDCluster.h>
14#include <svd/dataobjects/SVDRecoDigit.h>
15#include <svd/dataobjects/SVDShaperDigit.h>
16#include <svd/dataobjects/SVDTrueHit.h>
17#include <svd/dataobjects/SVDEventInfo.h>
18#include <vxd/dataobjects/VxdID.h>
19#include <vxd/geometry/GeoCache.h>
20#include <vxd/geometry/SensorInfoBase.h>
21#include <tracking/dataobjects/RecoTrack.h>
22#include <tracking/dataobjects/RecoHitInformation.h>
23#include <genfit/TrackPoint.h>
24#include <Math/Boost.h>
28#include <mdst/dataobjects/Track.h>
29#include <mdst/dataobjects/TrackFitResult.h>
48 setDescription(
"The module is used to create a TTree to study SVD clusters, genfit unbiased residuals and many other properties related to the track they belong to.");
50 addParam(
"outputFileName",
m_rootFileName,
"Name of output root file.", std::string(
"SVDPerformanceTTree.root"));
64 m_t_U =
new TTree(
"t_U",
"Tree for SVD u-clusters");
115 m_t_V =
new TTree(
"t_V",
"Tree for SVD v-clusters");
183 if (
m_EventT0->hasTemporaryEventT0(Const::EDetector::CDC)) {
184 const auto bestCDCEvtT0 =
m_EventT0->getBestCDCTemporaryEventT0();
192 std::string m_svdEventInfoName =
"SVDEventInfo";
194 m_svdEventInfoName =
"SVDEventInfoSim";
196 if (!eventinfo) B2ERROR(
"No SVDEventInfo!");
197 m_svdTB = eventinfo->getModeByte().getTriggerBin();
203 for (
const auto& trk : recoTracks) {
204 if (! trk.wasFitSuccessful()) {
211 if (theTK.
size() == 0) {
223 ROOT::Math::BoostZ boost(3. / 11);
224 pStar = boost(pStar);
229 const vector<SVDCluster* > svdClusters = trk.getSVDHitList();
230 B2DEBUG(40,
"FITTED TRACK: NUMBER OF SVD HITS = " << svdClusters.size());
236 for (
unsigned int i = 0; i < svdClusters.size(); i++) {
247 const auto* hitTrackPoint_1 = trk.getCreatedTrackPoint(infoSVD_1);
248 const auto* fittedResult_1 = hitTrackPoint_1->getFitterInfo();
249 if (!fittedResult_1) {
258 const TVectorD resUnBias_1 = fittedResult_1->getResidual(0,
false).getState();
259 genfit::MeasuredStateOnPlane state_unbiased = fittedResult_1->getFittedState(
false);
260 const TVectorD& svd_predIntersect_unbiased = state_unbiased.getState();
261 const TMatrixDSym& covMatrix_unbiased = state_unbiased.getCov();
262 genfit::MeasuredStateOnPlane state_1 = trk.getMeasuredStateOnPlaneFromRecoHit(infoSVD_1);
263 const TVectorD& svd_predIntersect_1 = state_1.getState();
264 const TMatrixDSym& covMatrix_1 = state_1.getCov();
268 const int strips_1 = svd_1->
getSize();
271 const ROOT::Math::XYZVector svdLocal_1(svd_1->
getPosition(), svd_predIntersect_1[4], 0.);
273 const ROOT::Math::XYZVector& svdGlobal_1 = svdSensor_1.
pointToGlobal(svdLocal_1);
274 double svdPhi_1 = svdGlobal_1.Phi();
275 double svdZ_1 = svdGlobal_1.Z();
285 if (isMC && trueHit_1.
size() > 0)
322 B2ERROR(
" Inconsistency with cluster size! # recoDigits = " << theRecoDigits.
size() <<
" != " <<
m_svdSize <<
" cluster size");
326 for (
unsigned int d = 0; d <
m_svdSize; d++) {
329 array<float, 6> Samples = ShaperDigit->
getSamples();
332 std::copy(std::begin(Samples), std::end(Samples), std::back_inserter(
m_svdStrip6Samples));
334 double misalignedStripPos = svdSensor_1.
getUCellPosition(theRecoDigits[d]->getCellID());
347 const int strips_1 = svd_1->
getSize();
349 const ROOT::Math::XYZVector svdLocal_1(svd_predIntersect_1[3], svd_1->
getPosition(), 0.);
351 const ROOT::Math::XYZVector& svdGlobal_1 = svdSensor_1.
pointToGlobal(svdLocal_1);
352 double svdPhi_1 = svdGlobal_1.Phi();
353 double svdZ_1 = svdGlobal_1.Z();
363 if (isMC && trueHit_1.
size() > 0)
400 B2ERROR(
" Inconsistency with cluster size! # recoDigits = " << theRecoDigits.
size() <<
" != " <<
m_svdSize <<
" cluster size");
404 for (
unsigned int d = 0; d <
m_svdSize; d++) {
406 array<float, 6> Samples = ShaperDigit->
getSamples();
408 std::copy(std::begin(Samples), std::end(Samples), std::back_inserter(
m_svdStrip6Samples));
410 double misalignedStripPos = svdSensor_1.
getVCellPosition(theRecoDigits[d]->getCellID());
424 B2INFO(
"oops...something went wrong in getting the unbiased state, skipping this cluster.");
static const ChargedStable pion
charged pion particle
bool isMC() const
Do we have generated, not real data?
static Environment & Instance()
Static method to get a reference to the Environment instance.
void setDescription(const std::string &description)
Sets the description of the module.
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
float getClsTime() const
Get average of waveform maximum times of cluster strip signals.
float getSNR() const
Get cluster SNR.
unsigned short getSize() const
Get cluster size.
float getCharge() const
Get collected charge.
VxdID getSensorID() const
Get the sensor ID.
bool isUCluster() const
Get the direction of strips.
float getPosition(double v=0) const
Get the coordinate of reconstructed hit.
float getClsTimeSigma() const
Get the error of the reconstructed hit time.
float getPositionSigma() const
Get the error of the reconstructed hit coordinate.
int getFirstFrame() const
Get firstFrame of the MaxSum algorithm.
The SVD ShaperDigit class.
APVFloatSamples getSamples() const
Get array of samples.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
Accessor to arrays stored in the data store.
Type-safe access to single objects in the data store.
bool isValid() const
Check whether the object was created.
Values of the result of a track fit with a given particle hypothesis.
ROOT::Math::PxPyPzEVector get4Momentum() const
Getter for the 4Momentum at the closest approach of the track in the r/phi projection.
double getD0() const
Getter for d0.
double getZ0() const
Getter for z0.
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
static GeoCache & getInstance()
Return a reference to the singleton instance.
Base class to provide Sensor Information for PXD and SVD.
double getVCellPosition(int vID) const
Return the position of a specific strip/pixel in v direction.
double getUPitch(double v=0) const
Return the pitch of the sensor.
double getVSize() const
Return the length of the sensor.
double getUCellPosition(int uID, int vID=-1) const
Return the position of a specific strip/pixel in u direction.
ROOT::Math::XYZVector pointToGlobal(const ROOT::Math::XYZVector &local, bool reco=false) const
Convert a point from local to global coordinates.
double getVPitch(double v=0) const
Return the pitch of the sensor.
double getThickness() const
Return the thickness of the sensor.
double getUSize(double v=0) const
Return the width of the sensor.
Class to uniquely identify a any structure of the PXD and SVD.
baseType getSensorNumber() const
Get the sensor id.
baseType getLadderNumber() const
Get the ladder id.
baseType getLayerNumber() const
Get the layer id.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
static double convertValueToUnit(double value, const std::string &unitString)
Converts a floating point value from the standard framework unit to the given unit.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.