11 #include "cdc/modules/cdcCalibrationCollector/CDCT0CalibrationCollector.h"
13 #include <framework/datastore/StoreObjPtr.h>
14 #include <framework/datastore/StoreArray.h>
15 #include <framework/datastore/RelationArray.h>
17 #include <mdst/dataobjects/TrackFitResult.h>
18 #include <mdst/dataobjects/Track.h>
19 #include <tracking/dataobjects/RecoTrack.h>
20 #include <genfit/TrackPoint.h>
21 #include <genfit/KalmanFitterInfo.h>
22 #include <genfit/MeasuredStateOnPlane.h>
23 #include <Math/ProbFuncMathCore.h>
25 #include <cdc/dataobjects/WireID.h>
26 #include <cdc/geometry/CDCGeometryPar.h>
37 setDescription(
"Collector module for cdc T0 calibration");
38 setPropertyFlags(c_ParallelProcessingCertified);
39 addParam(
"RecoTracksColName", m_recoTrackArrayName,
"Name of collection hold genfit::Track", std::string(
""));
40 addParam(
"BField", m_BField,
"If true -> #Params ==5 else #params ==4 for calculate P-Val",
false);
41 addParam(
"EventT0Extraction", m_EventT0Extraction,
"use event t0 extract t0 or not",
false);
42 addParam(
"MinimumPt", m_MinimumPt,
"Tracks whose Pt lower than this value will not be recoreded", 0.);
43 addParam(
"PvalCut", m_PvalCut,
"Tracks which Pval small than this will not be recoreded", 0.);
44 addParam(
"NDFCut", m_ndfCut,
"Tracks which NDF small than this will not be recoreded", 0.);
45 addParam(
"Xmin", m_xmin,
"minimum dift length", 0.1);
48 CDCT0CalibrationCollectorModule::~CDCT0CalibrationCollectorModule()
52 void CDCT0CalibrationCollectorModule::prepare()
58 RelationArray relRecoTrackTrack(recoTracks, storeTrack, m_relRecoTrackTrackName);
60 m_recoTrackArrayName = recoTracks.getName();
61 m_trackFitResultArrayName = storeTrackFitResults.getName();
62 m_relRecoTrackTrackName = relRecoTrackTrack.
getName();
64 auto m_hNDF =
new TH1D(
"hNDF",
"NDF of fitted track;NDF;Tracks", 71, -1, 70);
65 auto m_hPval =
new TH1D(
"hPval",
"p-values of tracks;pVal;Tracks", 1000, 0, 1);
67 registerObject<TH1D>(
"hNDF", m_hNDF);
68 registerObject<TH1D>(
"hPval", m_hPval);
71 for (
int i = 0; i < 56; ++i) {
74 halfCSize[i] = M_PI * R / nW;
77 auto m_hTotal =
new TH1F(
"hTotal",
"hTotal", 30, -15, 15);
78 registerObject<TH1F>(
"hTotal", m_hTotal);
82 for (
int il = 0; il < 56; il++) {
84 for (
int ic = 0; ic < nW; ++ic) {
85 m_h1[il][ic] =
new TH1F(Form(
"hdT_lay%d_cell%d", il, ic), Form(
"Lay%d_cell%d", il, ic), 30, -15, 15);
86 registerObject<TH1F>(Form(
"hdT_lay%d_cell%d", il, ic), m_h1[il][ic]);
90 for (
int ib = 0; ib < 300; ++ib) {
91 m_hT0b[ib] =
new TH1F(Form(
"hT0b%d", ib), Form(
"boardID_%d", ib), 100, -20, 20);
92 registerObject<TH1F>(Form(
"hT0b%d", ib), m_hT0b[ib]);
97 void CDCT0CalibrationCollectorModule::collect()
103 const RelationArray relTrackTrack(recoTracks, storeTrack, m_relRecoTrackTrackName);
110 for (
int i = 0; i < nTr; ++i) {
112 if (track->getDirtyFlag())
continue;
113 if (!track->getTrackFitStatus()->isFitted())
continue;
119 B2DEBUG(99,
"No relation found");
126 B2WARNING(
"track was fitted but Relation not found");
138 Pval = std::max(0., ROOT::Math::chisquared_cdf_c(Chi2, ndf));
141 getObjectPtr<TH1D>(
"hPval")->Fill(Pval);
142 getObjectPtr<TH1D>(
"hNDF")->Fill(ndf);
144 if (Pval < m_PvalCut || ndf < m_ndfCut)
continue;
146 if (fitresult->
getMomentum().Perp() < m_MinimumPt)
continue;
148 if (m_EventT0Extraction) {
150 if (m_eventTimeStoreObject.isValid() && m_eventTimeStoreObject->hasEventT0()) {
151 evtT0 = m_eventTimeStoreObject->getEventT0();
157 B2DEBUG(99,
"start collect hit");
161 const genfit::TrackPoint* tp = track->getCreatedTrackPoint(track->getRecoHitInformation(hit));
162 int lay = hit->getICLayer();
163 int IWire = hit->getIWire();
164 unsigned short tdc = hit->getTDCCount();
165 unsigned short adc = hit->getADCCount();
166 WireID wireid(lay, IWire);
168 if (!kfi) {B2DEBUG(199,
"No Fitter Info: Layer " << hit->getICLayer());
continue;}
169 for (
unsigned int iMeas = 0; iMeas < kfi->getNumMeasurements(); ++iMeas) {
173 const TVector3 pocaOnWire = mop.getPlane()->getO();
175 const TVector3 pocaMom = mop.getMom();
176 double alpha = cdcgeo.
getAlpha(pocaOnWire, pocaMom) ;
177 double theta = cdcgeo.
getTheta(pocaMom);
181 double xmax = halfCSize[lay] - 0.1;
182 if ((fabs(x_u) < m_xmin) || (fabs(x_u) > xmax))
continue;
189 if (fabs(alpha) > M_PI / 2) {
197 double t_fit = cdcgeo.
getDriftTime(std::abs(x_u), lay, lr, alpha , theta);
202 dt_flight = mop.getTime();
203 if (dt_flight < 50) {
209 double z = pocaOnWire.Z();
211 double z_prop = z - m_backWirePos.Z();
212 B2DEBUG(99,
"z_prop = " << z_prop <<
" |z " << z <<
" |back wire poss: " << m_backWirePos.Z());
224 getObjectPtr<TH1F>(Form(
"hdT_lay%d_cell%d", lay, IWire))->Fill(t - t_fit);
225 getObjectPtr<TH1F>(Form(
"hT0b%d", boardID))->Fill(t - t_fit);
226 getObjectPtr<TH1F>(
"hTotal")->Fill(t - t_fit);
234 void CDCT0CalibrationCollectorModule::finish()