9#include "cdc/modules/cdcCalibrationCollector/CDCT0CalibrationCollector.h"
11#include <framework/datastore/RelationArray.h>
13#include <genfit/TrackPoint.h>
14#include <genfit/KalmanFitterInfo.h>
15#include <genfit/MeasuredStateOnPlane.h>
16#include <Math/ProbFuncMathCore.h>
18#include <cdc/dataobjects/WireID.h>
19#include <cdc/geometry/CDCGeometryPar.h>
24using namespace genfit;
33 addParam(
"BField",
m_BField,
"If true -> #Params ==5 else #params ==4 for calculate P-Val",
false);
35 addParam(
"MinimumPt",
m_MinimumPt,
"Tracks whose Pt lower than this value will not be recoreded", 0.);
36 addParam(
"PvalCut",
m_PvalCut,
"Tracks which Pval small than this will not be recoreded", 0.);
37 addParam(
"NDFCut",
m_ndfCut,
"Tracks which NDF small than this will not be recoreded", 0.);
55 auto m_hNDF =
new TH1D(
"hNDF",
"NDF of fitted track;NDF;Tracks", 71, -1, 70);
56 auto m_hPval =
new TH1D(
"hPval",
"p-values of tracks;pVal;Tracks", 1000, 0, 1);
58 registerObject<TH1D>(
"hNDF", m_hNDF);
59 registerObject<TH1D>(
"hPval", m_hPval);
62 for (
int i = 0; i < 56; ++i) {
68 auto m_hTotal =
new TH1F(
"hTotal",
"hTotal", 30, -15, 15);
69 registerObject<TH1F>(
"hTotal", m_hTotal);
73 for (
int il = 0; il < 56; il++) {
75 for (
int ic = 0; ic < nW; ++ic) {
76 m_h1[il][ic] =
new TH1F(Form(
"hdT_lay%d_cell%d", il, ic), Form(
"Lay%d_cell%d", il, ic), 30, -15, 15);
77 registerObject<TH1F>(Form(
"hdT_lay%d_cell%d", il, ic), m_h1[il][ic]);
81 for (
int ib = 0; ib < 300; ++ib) {
82 m_hT0b[ib] =
new TH1F(Form(
"hT0b%d", ib), Form(
"boardID_%d", ib), 100, -20, 20);
83 registerObject<TH1F>(Form(
"hT0b%d", ib), m_hT0b[ib]);
97 for (
int i = 0; i < nTr; ++i) {
99 if (track->getDirtyFlag())
continue;
100 const genfit::FitStatus* fs = track->getTrackFitStatus();
101 if (!fs || !fs->isFitted())
continue;
102 if (!fs->isFitConverged())
continue;
106 B2DEBUG(99,
"No relation found");
113 B2WARNING(
"track was fitted but Relation not found");
121 Pval = fs->getPVal();
123 ndf = fs->getNdf() + 1;
124 double Chi2 = fs->getChi2();
125 Pval = std::max(0., ROOT::Math::chisquared_cdf_c(Chi2, ndf));
128 getObjectPtr<TH1D>(
"hPval")->Fill(Pval);
129 getObjectPtr<TH1D>(
"hNDF")->Fill(ndf);
144 B2DEBUG(99,
"start collect hit");
148 const genfit::TrackPoint* tp = track->getCreatedTrackPoint(track->getRecoHitInformation(hit));
149 int lay = hit->getICLayer();
150 int IWire = hit->getIWire();
151 unsigned short tdc = hit->getTDCCount();
152 unsigned short adc = hit->getADCCount();
153 WireID wireid(lay, IWire);
154 const genfit::KalmanFitterInfo* kfi = tp->getKalmanFitterInfo();
155 if (!kfi) {B2DEBUG(199,
"No Fitter Info: Layer " << hit->getICLayer());
continue;}
156 for (
unsigned int iMeas = 0; iMeas < kfi->getNumMeasurements(); ++iMeas) {
157 if ((kfi->getWeights().at(iMeas)) > 0.5) {
159 const genfit::MeasuredStateOnPlane& mop = kfi->getFittedState();
160 const B2Vector3D pocaOnWire = mop.getPlane()->getO();
163 double alpha = cdcgeo.
getAlpha(pocaOnWire, pocaMom) ;
164 double theta = cdcgeo.
getTheta(pocaMom);
165 double x_u = kfi->getFittedState(
false).getState()(3);
169 if ((fabs(x_u) <
m_xmin) || (fabs(x_u) > xmax))
continue;
176 if (fabs(alpha) > M_PI / 2) {
184 double t_fit = cdcgeo.
getDriftTime(std::abs(x_u), lay, lr, alpha, theta);
189 dt_flight = mop.getTime();
190 if (dt_flight < 50) {
196 double z = pocaOnWire.
Z();
198 double z_prop = z - m_backWirePos.
Z();
199 B2DEBUG(99,
"z_prop = " << z_prop <<
" |z " << z <<
" |back wire poss: " << m_backWirePos.
Z());
211 getObjectPtr<TH1F>(Form(
"hdT_lay%d_cell%d", lay, IWire))->Fill(t - t_fit);
212 getObjectPtr<TH1F>(Form(
"hT0b%d", boardID))->Fill(t - t_fit);
213 getObjectPtr<TH1F>(
"hTotal")->Fill(t - t_fit);
DataType Z() const
access variable Z (= .at(2) without boundary check)
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
The Class for CDC Geometry Parameters.
double getTimeWalk(const WireID &wID, unsigned short adcCount) const
Returns time-walk.
double getTheta(const B2Vector3D &momentum) const
Returns track incident angle (theta in rad.).
unsigned short getBoardID(const WireID &wID) const
Returns frontend board id. corresponding to the wire id.
double getAlpha(const B2Vector3D &posOnWire, const B2Vector3D &momentum) const
Returns track incident angle in rphi plane (alpha in rad.).
const B2Vector3D wireBackwardPosition(uint layerId, int cellId, EWirePosition set=c_Base) const
Returns the backward position of the input sense wire.
double getTdcBinWidth() const
Return TDC bin width (nsec).
double getOutgoingAlpha(const double alpha) const
Converts incoming- to outgoing-alpha.
float getT0(const WireID &wireID) const
Returns t0 parameter of the specified sense wire.
unsigned short getOutgoingLR(const unsigned short lr, const double alpha) const
Converts incoming-lr to outgoing-lr.
double getOutgoingTheta(const double alpha, const double theta) const
Converts incoming- to outgoing-theta.
unsigned nWiresInLayer(int layerId) const
Returns wire numbers in a layer.
double getPropSpeedInv(const unsigned int layerID) const
Get the inversel of propagation speed in the sense wire.
double getDriftTime(double dist, unsigned short layer, unsigned short lr, double alpha, double theta) const
Return the drift time to the sense wire.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
double senseWireR(int layerId) const
Returns radius of sense wire in each layer.
bool m_BField
fit in case no magnetic field or not, if false, NDF=4 in cal P-value
StoreObjPtr< EventT0 > m_eventTimeStoreObject
Event t0 object.
std::string m_recoTrackArrayName
Belle2::RecoTrack StoreArray nam.e.
double m_MinimumPt
minimum pt required for track
double m_xmin
Min drift length.
double m_PvalCut
minimum pt required for track
StoreArray< TrackFitResult > m_TrackFitResults
Track fit results.
std::string m_cdcHitArrayName
Belle2::CDCHit StoreArray name.
CDCT0CalibrationCollectorModule()
Constructor.
std::string m_relRecoTrackTrackName
Relation between RecoTrack and Belle2:Track.
void collect() override
Event action, collect information for calibration.
virtual ~CDCT0CalibrationCollectorModule()
Destructor.
std::string m_trackArrayName
Belle2::Track StoreArray name.
void prepare() override
Initializes the Module.
void finish() override
Termination action.
std::string m_trackFitResultArrayName
Belle2::TrackFitResult StoreArray name.
double halfCSize[56]
Half cell size.
StoreArray< RecoTrack > m_RecoTracks
Tracks.
StoreArray< Track > m_Tracks
Tracks.
double m_ndfCut
minimum pt required for track
bool m_EventT0Extraction
use Event T0 extraction or not.
StoreArray< CDCHit > m_CDCHits
CDC hits.
Calibration collector module base class.
static const ChargedStable muon
muon particle
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.
Low-level class to create/modify relations between StoreArrays.
const std::string & getName() const
Return name under which the object is saved in the DataStore.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
int getEntries() const
Get the number of objects in the array.
Values of the result of a track fit with a given particle hypothesis.
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
Class that bundles various TrackFitResults.
const TrackFitResult * getTrackFitResult(const Const::ChargedStable &chargedStable) const
Default Access to TrackFitResults.
Class to identify a wire inside the CDC.
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.