9 #include "cdc/modules/cdcCRTest/CDCCRTestModule.h"
11 #include <framework/gearbox/Const.h>
12 #include <framework/core/HistoModule.h>
13 #include <framework/datastore/StoreObjPtr.h>
14 #include <framework/datastore/RelationArray.h>
16 #include <genfit/TrackPoint.h>
17 #include <genfit/KalmanFitterInfo.h>
18 #include <genfit/MeasurementOnPlane.h>
19 #include <genfit/MeasuredStateOnPlane.h>
20 #include <genfit/StateOnPlane.h>
21 #include <boost/foreach.hpp>
23 #include <cdc/translators/RealisticCDCGeometryTranslator.h>
24 #include <cdc/translators/RealisticTDCCountTranslator.h>
25 #include <cdc/dataobjects/CDCRecoHit.h>
26 #include <cdc/dataobjects/CDCSimHit.h>
27 #include "TDirectory.h"
28 #include <Math/ProbFuncMathCore.h>
42 setDescription(
"CDC Cosmic ray test module");
43 setPropertyFlags(c_ParallelProcessingCertified);
44 addParam(
"CorrectToF", m_ToF,
"if true, time of flight will take account in t",
true);
45 addParam(
"CorrectToP", m_ToP,
"if true, time of Propagation will take account in t",
true);
46 addParam(
"RecoTracksColName", m_recoTrackArrayName,
"Name of collection hold genfit::Track", std::string(
""));
47 addParam(
"histogramDirectoryName", m_histogramDirectoryName,
48 "Track fit results histograms will be put into this directory", std::string(
"trackfit"));
49 addParam(
"NameOfTree", m_treeName,
"name of tree in output file",
string(
"tree"));
50 addParam(
"fillExpertHistograms", m_fillExpertHistos,
"Fill additional histograms",
true);
51 addParam(
"noBFit", m_noBFit,
"If true -> #Params ==4, #params ==5 for calculate P-Val",
false);
52 addParam(
"plotResidual", m_plotResidual,
"plot biased residual, normalized res and xtplot for all layer",
false);
53 addParam(
"calExpectedDriftTime", m_calExpectedDriftTime,
"if true module will calculate expected drift time, it take a time",
55 addParam(
"hitEfficiency", m_hitEfficiency,
"calculate hit efficiency(Not work now) true:yes false:No",
false);
56 addParam(
"TriggerPos", m_TriggerPos,
"Trigger position use for cut and reconstruct Trigger image", std::vector<double> { -0.6, -13.25, 17.3});
57 addParam(
"NormTriggerPlaneDirection", m_TriggerPlaneDirection,
"Normal trigger plane direction and reconstruct Trigger image",
58 std::vector<double> { 0, 1, 0});
59 addParam(
"TriggerSize", m_TriggerSize,
"Trigger Size, (Width x length)", std::vector<double> {100, 50});
60 addParam(
"IwireLow", m_low,
"Lower boundary of hit dist. Histogram", std::vector<int> {0, 0, 0, 0, 0, 0, 0, 0, 0});
61 addParam(
"IwireUpper", m_up,
"Upper boundary of hit dist. Histogram", std::vector<int> {161, 161, 193, 225, 257, 289, 321, 355, 385});
62 addParam(
"StoreCDCSimHitInfo", m_StoreCDCSimHitInfo,
"Store simulation info related to hit, driftLeng, flight time,z_onwire",
64 addParam(
"EstimateResultForUnFittedLayer", m_EstimateResultForUnFittedLayer,
65 "Calculate residual for Layer that is set unUseInFit",
true);
66 addParam(
"SmallerOutput", m_SmallerOutput,
"If true, trigghit position, residual cov,absRes, will not be stored",
false);
67 addParam(
"StoreTrackParams", m_StoreTrackParams,
"Store Track Parameter or not, it will be multicount for each hit",
true);
68 addParam(
"StoreHitDistribution", m_MakeHitDist,
"Make hit distribution or not",
true);
69 addParam(
"EventT0Extraction", m_EventT0Extraction,
"use event t0 extract t0 or not",
true);
70 addParam(
"MinimumPt", m_MinimumPt,
"Tracks with tranverse momentum small than this will not recored", 0.);
73 CDCCRTestModule::~CDCCRTestModule()
80 void CDCCRTestModule::defineHisto()
82 m_tree =
new TTree(m_treeName.c_str(),
"tree");
83 m_tree->Branch(
"x_mea", &x_mea,
"x_mea/D");
84 m_tree->Branch(
"x_u", &x_u,
"x_u/D");
85 m_tree->Branch(
"x_b", &x_b,
"x_b/D");
86 m_tree->Branch(
"z", &z,
"z/D");
87 m_tree->Branch(
"alpha", &alpha,
"alpha/D");
88 m_tree->Branch(
"theta", &theta,
"theta/D");
89 m_tree->Branch(
"t", &t,
"t/D");
90 m_tree->Branch(
"evtT0", &evtT0,
"evtT0/D");
91 m_tree->Branch(
"adc", &adc,
"adc/s");
92 m_tree->Branch(
"boardID", &boardID,
"boardID/I");
93 m_tree->Branch(
"lay", &lay,
"lay/I");
94 m_tree->Branch(
"weight", &weight,
"weight/D");
95 m_tree->Branch(
"IWire", &IWire,
"IWire/I");
96 m_tree->Branch(
"Pval", &Pval,
"Pval/D");
97 m_tree->Branch(
"ndf", &ndf,
"ndf/D");
99 if (m_StoreTrackParams) {
100 m_tree->Branch(
"d0", &d0,
"d0/D");
101 m_tree->Branch(
"z0", &z0,
"z0/D");
102 m_tree->Branch(
"phi0", &phi0,
"phi0/D");
103 m_tree->Branch(
"tanL", &tanL,
"tanL/D");
104 m_tree->Branch(
"omega", &omega,
"omega/D");
105 m_tree->Branch(
"Pt", &Pt,
"Pt/D");
107 if (m_StoreCDCSimHitInfo) {
108 m_tree->Branch(
"z_sim", &z_sim,
"z_sim/D");
109 m_tree->Branch(
"x_sim", &x_sim,
"x_sim/D");
110 m_tree->Branch(
"dt_flight_sim", &dt_flight_sim,
"dt_flight_sim/D");
112 if (m_calExpectedDriftTime) {
113 m_tree->Branch(
"t_fit", &t_fit,
"t_fit/D");
115 if (!m_SmallerOutput) {
116 m_tree->Branch(
"tdc", &tdc,
"tdc/I");
117 m_tree->Branch(
"z_prop", &z_prop,
"z_prop/D");
118 m_tree->Branch(
"res_b", &res_b,
"res_b/D");
119 m_tree->Branch(
"res_u", &res_u,
"res_u/D");
120 m_tree->Branch(
"lr", &lr,
"lr/I");
121 m_tree->Branch(
"trigHitPos_x", &trigHitPos_x,
"trigHitPos_x/D");
122 m_tree->Branch(
"trigHitPos_z", &trigHitPos_z,
"trigHitPos_z/D");
123 m_tree->Branch(
"numhits", &numhits,
"numhits/I");
124 m_tree->Branch(
"res_b_err", &res_b_err,
"res_b_err/D");
125 m_tree->Branch(
"res_u_err", &res_u_err,
"res_u_err/D");
126 m_tree->Branch(
"absRes_u", &absRes_u,
"absRes_u/D");
127 m_tree->Branch(
"absRes_b", &absRes_b,
"absRes_b/D");
128 m_tree->Branch(
"dt_prop", &dt_prop,
"dt_prop/D");
129 m_tree->Branch(
"dt_flight", &dt_flight,
"dt_flight/D");
133 TDirectory* oldDir = gDirectory;
134 TDirectory* histDir = oldDir->mkdir(m_histogramDirectoryName.c_str());
136 m_hNTracks = getHist(
"hNTracks",
"number of tracks", 3, 0, 3);
137 m_hNTracks->GetXaxis()->SetBinLabel(1,
"fitted, converged");
138 m_hNTracks->GetXaxis()->SetBinLabel(2,
"fitted, not converged");
139 m_hNTracks->GetXaxis()->SetBinLabel(3,
"TrackCand, but no Track");
141 m_hNDF = getHist(
"hNDF",
"NDF of fitted track;NDF;Tracks", 71, -1, 150);
142 m_hNHits = getHist(
"hNHits",
"#hit of fitted track;#hit;Tracks", 61, -1, 150);
143 m_hNHits_trackcand = getHist(
"hNHits_trackcand",
"#hit of track candidate;#hit;Tracks", 71, -1, 150);
144 m_hNTracksPerEvent = getHist(
"hNTracksPerEvent",
"#tracks/Event;#Tracks;Event", 20, 0, 20);
145 m_hNTracksPerEventFitted = getHist(
"hNTracksPerEventFitted",
"#tracks/Event After Fit;#Tracks;Event", 20, 0, 20);
146 m_hChi2 = getHist(
"hChi2",
"#chi^{2} of tracks;#chi^{2};Tracks", 400, 0, 400);
147 m_hPhi0 = getHist(
"hPhi0",
"#Phi_{0} of tracks;#phi_{0} (Degree);Tracks", 400, -190, 190);
148 m_hAlpha = getHist(
"hAlpha",
"#alpha Dist.;#alpha (Degree);Hits", 360, -90, 90);
149 m_hTheta = getHist(
"hTheta",
"#theta Dist.;#theta (Degree);Hits", 360, 0, 180);
150 m_hPval = getHist(
"hPval",
"p-values of tracks;pVal;Tracks", 1000, 0, 1);
151 m_hEvtT0 = getHist(
"hEvtT0",
"Event T0; EvtT0 (ns); #event", 200, -100, 100);
153 m_hTriggerHitZX = getHist(
"TriggerHitZX",
"Hit Position on trigger counter;z(cm);x(cm)", 300, -100, 100, 120, -15, 15);
155 m_h2DHitDistInCDCHit = getHist(
"2DHitDistInCDCHit",
" CDCHit;WireID;LayerID",
156 m_up[8] - m_low[0], m_low[0], m_up[8], 56, 0, 56);
157 m_h2DHitDistInTrCand = getHist(
"2DHitDistInTrCand",
"Track Cand ;WireID;LayerID",
158 m_up[8] - m_low[0], m_low[0], m_up[8], 56, 0, 56);
159 m_h2DHitDistInTrack = getHist(
"2DHitDistInTrack",
"Fitted Track ;WireID;LayerID",
160 m_up[8] - m_low[0], m_low[0], m_up[8], 56, 0, 56);
162 if (m_fillExpertHistos) {
163 m_hNDFChi2 = getHist(
"hNDFChi2",
"#chi^{2} of tracks;NDF;#chi^{2};Tracks", 8, 0, 8, 800, 0, 200);
164 m_hNDFPval = getHist(
"hNDFPval",
"p-values of tracks;NDF;pVal;Tracks", 8, 0, 8, 100, 0, 1);
167 for (
int i = 0; i < 56; ++i) {
168 if (m_hitEfficiency) {
169 m_hHitEff_soft[i] = getHistProfile(Form(
"hHitEff_soft_L%d", i),
170 Form(
"hit efficiency(soft) of Layer %d ;Drift distance;Software Efficiency", i), 200, -1, 1);
173 if (i < 8) {sl = 0;}
else { sl = floor((i - 8) / 6) + 1;}
174 m_hHitDistInCDCHit[i] = getHist(Form(
"hHitDistInCDCHit_layer%d", i), Form(
"Hit Dist. ICLayer_%d;WireID;#Hits", i),
175 m_up.at(sl) - m_low.at(sl), m_low.at(sl), m_up.at(sl));
176 m_hHitDistInCDCHit[i]->SetLineColor(kGreen);
177 m_hHitDistInTrCand[i] = getHist(Form(
"hHitDistInTrCand_layer%d", i), Form(
"Hit Dist. ICLayer_%d;WireID;#Hits", i),
178 m_up.at(sl) - m_low.at(sl), m_low.at(sl), m_up.at(sl));
179 m_hHitDistInTrCand[i]->SetLineColor(kRed);
180 m_hHitDistInTrack[i] = getHist(Form(
"hHitDistInTrack_layer%d", i), Form(
"Hit Dist. ICLayer_%d;WireID;#Hits", i),
181 m_up.at(sl) - m_low.at(sl), m_low.at(sl), m_up.at(sl));
183 const double normResRange = 20;
184 const double residualRange = 0.3;
185 std::string title, name;
186 if (m_plotResidual) {
187 name = (boost::format(
"hist_ResidualsU%1%") % i).str();
188 title = (boost::format(
"unnormalized, unbiased residuals in layer %1%;cm;Tracks") % i).str();
189 m_hResidualU[i] = getHist(name, title, 500, -residualRange, residualRange);
191 name = (boost::format(
"hNormalizedResidualsU%1%") % i).str();
192 title = (boost::format(
"normalized, unbiased residuals in layer %1%;NDF;#sigma (cm);Tracks") % i).str();
193 m_hNormalizedResidualU[i] = getHist(name, title, 500, -normResRange, normResRange);
195 name = (boost::format(
"DxDt%1%") % i).str();
196 title = (boost::format(
"Drift Length vs Drift time at Layer_%1%;Drift Length (cm);Drift time (ns)") % i).str();
197 m_hDxDt[i] = getHist(name, title, 200, -1, 1, 450, -50, 400);
199 if (m_fillExpertHistos) {
200 name = (boost::format(
"hNDFResidualsU%1%") % i).str();
201 title = (boost::format(
"unnormalized, unbiased residuals along U in layer %1%;NDF;cm;Tracks") % i).str();
202 m_hNDFResidualU[i] = getHist(name, title, 8, 0, 8, 1000, -residualRange, residualRange);
204 name = (boost::format(
"hNDFNormalizedResidualsU%1%") % i).str();
205 title = (boost::format(
"normalized, unbiased residuals in layer %1%;NDF;#sigma (cm);Tracks") % i).str();
206 m_hNDFNormalizedResidualU[i] = getHist(name, title, 8, 0, 8, 1000, -normResRange, normResRange);
212 void CDCCRTestModule::initialize()
215 m_Tracks.isRequired(m_trackArrayName);
216 m_RecoTracks.isRequired(m_recoTrackArrayName);
217 m_TrackFitResults.isRequired(m_trackFitResultArrayName);
218 m_CDCHits.isRequired(m_cdcHitArrayName);
219 RelationArray relRecoTrackTrack(m_RecoTracks, m_Tracks, m_relRecoTrackTrackName);
221 m_relRecoTrackTrackName = relRecoTrackTrack.
getName();
223 for (
size_t i = 0; i < m_allHistos.size(); ++i) {
224 m_allHistos[i]->Reset();
226 B2ASSERT(
"Trigger Position (TriggerPos) must be 3 components.", m_TriggerPos.size() == 3);
227 B2ASSERT(
"Normal vector of Trigger Plane (NormTriggerPlaneDirection) must be 3 components.", m_TriggerPlaneDirection.size() == 3);
228 B2ASSERT(
"Trigger size (TriggerSize) must be 2 component width and length(z direction)", m_TriggerSize.size() == 2);
229 B2ASSERT(
"List of Lower boundary (IWireLow) ( for histo must be 9 components, equivalent 9 supper layers", m_low.size() == 9);
230 B2ASSERT(
"List of Upper boundary (IWireUp) for histo must be 9 components, equivalent 9 supper layers", m_low.size() == 9);
231 B2INFO(
"Trigger Position (" << m_TriggerPos.at(0) <<
" ," << m_TriggerPos.at(1) <<
" ," << m_TriggerPos.at(2) <<
")");
234 void CDCCRTestModule::beginRun()
238 void CDCCRTestModule::event()
241 const RelationArray relTrackTrack(m_RecoTracks, m_Tracks, m_relRecoTrackTrackName);
245 for (
int i = 0; i < m_CDCHits.getEntries(); ++i) {
247 m_hHitDistInCDCHit[getICLayer(hit->getISuperLayer(), hit->getILayer())]->Fill(hit->getIWire());
248 m_h2DHitDistInCDCHit->Fill(hit->getIWire(), getICLayer(hit->getISuperLayer(), hit->getILayer()));
252 int nTr = m_RecoTracks.getEntries();
253 m_hNTracksPerEvent->Fill(nTr);
257 for (
int i = 0; i < nTr; ++i) {
259 if (track->getDirtyFlag()) {B2INFO(
"Dirty flag was set for track: " << track->getPositionSeed().Y());
continue;}
260 m_hNHits_trackcand->Fill(track->getNumberOfCDCHits());
262 getHitDistInTrackCand(track);
264 if (!track->hasTrackFitStatus()) {
265 m_hNTracks->Fill(
"Track not fitted", 1.0);
270 m_hNTracks->Fill(
"Track not fitted", 1.0);
274 m_hNTracks->Fill(
"fitted, not converged", 1.0);
275 B2DEBUG(99,
"------Fitted but not converged");
279 m_hNTracks->Fill(
"fitted, converged", 1.0);
280 B2DEBUG(99,
"-------Fittted and Conveged");
282 nfitted = nfitted + 1;
285 if (!b2track) {B2DEBUG(99,
"No relation found");
continue;}
289 B2WARNING(
"track was fitted but Relation not found");
293 if (m_noBFit) {ndf = fs->
getNdf() + 1;}
294 else {ndf = fs->
getNdf();}
296 TrPval = std::max(0., ROOT::Math::chisquared_cdf_c(Chi2, ndf));
297 m_hPval->Fill(TrPval);
299 if (ndf < 15)
continue;
300 if (m_EventT0Extraction) {
302 if (m_eventTimeStoreObject.isValid() && m_eventTimeStoreObject->hasEventT0()) {
303 evtT0 = m_eventTimeStoreObject->getEventT0();
304 m_hEvtT0->Fill(evtT0);
308 d0 = fitresult->getD0();
309 z0 = fitresult->getZ0();
310 tanL = fitresult->getTanLambda();
311 omega = fitresult->getOmega();
312 phi0 = fitresult->getPhi0() * 180 / M_PI;
313 Pt = fitresult->getMomentum().Perp();
316 if (Pt < m_MinimumPt)
continue;
317 if (m_hitEfficiency && track->getNumberOfCDCHits() > 30 && TrPval > 0.001) {
318 HitEfficiency(track);
320 if (m_fillExpertHistos) {
321 m_hNDFChi2->Fill(ndf, fs->
getChi2());
322 m_hNDFPval->Fill(ndf, TrPval);
328 B2ERROR(
"Exception when calling the plotResults method" << e.what());
331 if (m_EstimateResultForUnFittedLayer) {
334 getResidualOfUnFittedLayer(track);
343 m_hNTracksPerEventFitted->Fill(nfitted);
346 void CDCCRTestModule::endRun()
350 void CDCCRTestModule::terminate()
356 m_trigHitPos = getTriggerHitPosition(track);
357 trigHitPos_x = m_trigHitPos.X();
358 trigHitPos_z = m_trigHitPos.Z();
359 m_hTriggerHitZX->Fill(m_trigHitPos.Z(), m_trigHitPos.X());
360 bool hittrig = (sqrt((m_trigHitPos.X() - m_TriggerPos[0]) * (m_trigHitPos.X() - m_TriggerPos[0]) +
361 (m_trigHitPos.Y() - m_TriggerPos[1]) * (m_trigHitPos.Y() - m_TriggerPos[1])) < m_TriggerSize[0] / 2
362 && fabs(m_trigHitPos.Z() - m_TriggerPos[2]) < m_TriggerSize[1] / 2) ?
true :
false;
363 if (hittrig) {trighit = 1;}
367 m_hNHits->Fill(track->getNumberOfCDCHits());
369 std::vector<genfit::TrackPoint*> tps = track->getHitPointsWithMeasurement();
370 numhits = tps.size();
372 if (!tp->hasRawMeasurements())
380 if (!kfi) {B2DEBUG(199,
"No Fitter Info: Layer " << wireid.getICLayer());
continue;}
382 for (
unsigned int iMeas = 0; iMeas < kfi->getNumMeasurements(); ++iMeas) {
386 lay = wireid.getICLayer();
387 IWire = wireid.getIWire();
389 m_hHitDistInTrack[lay]->Fill(IWire);
390 m_h2DHitDistInTrack->Fill(IWire, lay);
398 const TVector3 pocaOnWire = mop.getPlane()->getO();
399 const TVector3 pocaOnTrack = mop.getPlane()->getU();
400 const TVector3 pocaMom = mop.getMom();
401 alpha = cdcgeo.
getAlpha(pocaOnWire, pocaMom) ;
404 x_mea = kfi->getMeasurementOnPlane(iMeas)->getState()(0);
406 res_b = residual_b.getState()(0);
408 res_u = residual_u.getState()(0);
411 if (fabs(alpha) > M_PI / 2) {
417 x_mea = copysign(x_mea, x_u);
421 B2DEBUG(199,
"x_unbiased " << x_u <<
" |left_right " << lr);
422 if (m_calExpectedDriftTime) { t_fit = cdcgeo.
getDriftTime(std::abs(x_u), lay, lr, alpha , theta);}
425 m_hAlpha->Fill(alpha);
426 m_hTheta->Fill(theta);
430 absRes_b = std::abs(x_b + res_b) - std::abs(x_b);
431 absRes_u = std::abs(x_u + res_u) - std::abs(x_u);
432 weight = residual_u.getWeight();
433 res_b_err = std::sqrt(residual_b.getCov()(0, 0));
434 res_u_err = std::sqrt(residual_u.getCov()(0, 0));
436 t = tdcTrans->
getDriftTime(tdc, wireid, mop.getTime(), pocaOnWire.Z(), adc);
440 if (m_StoreCDCSimHitInfo) {
449 if (m_plotResidual) {
450 m_hDxDt[lay]->Fill(x_u, t);
451 m_hResidualU[lay]->Fill(res_b, weight);
452 m_hNormalizedResidualU[lay]->Fill(res_b / sqrt(residual_b.getCov()(0, 0)), weight);
454 if (m_fillExpertHistos) {
455 m_hNDFResidualU[lay]->Fill(ndf, res_b, weight);
456 m_hNDFResidualU[lay]->Fill(ndf, res_b);
457 m_hNDFNormalizedResidualU[lay]->Fill(ndf, res_b / std::sqrt(residual_b.getCov()(0, 0)), weight);
466 void CDCCRTestModule::getHitDistInTrackCand(
const RecoTrack* track)
470 B2DEBUG(99,
"In TrackCand: ICLayer: " << iclay <<
"IWire: " << cdchit->
getIWire());
471 m_hHitDistInTrCand[iclay]->Fill(cdchit->
getIWire());
472 m_h2DHitDistInTrCand->Fill(cdchit->
getIWire(), iclay);
476 TVector3 CDCCRTestModule::getTriggerHitPosition(
RecoTrack* track)
478 TVector3 trigpos(m_TriggerPos.at(0), m_TriggerPos.at(1), m_TriggerPos.at(2));
479 TVector3 trigDir(m_TriggerPlaneDirection.at(0), m_TriggerPlaneDirection.at(1), m_TriggerPlaneDirection.at(2));
482 TVector3 pos(-200, 200, 200);
485 if (fabs(l) < 1000) pos = mop.getPos();
487 B2WARNING(
"extrapolate to Trigger counter failure" << er.
what());
505 const genfit::TrackPoint* tp = track->getCreatedTrackPoint(track->getRecoHitInformation(cdchit));
509 if (rightLeftHitInformation == RecoHitInformation::RightLeftInformation::c_left) {
511 }
else if (rightLeftHitInformation == RecoHitInformation::RightLeftInformation::c_right) {
515 if (!tp->hasRawMeasurements())
522 unsigned short imea = 0;
523 for (
unsigned int iMeas = 0; iMeas < kfi->getNumMeasurements(); ++iMeas) {
525 if (ww > max) {max = ww; imea = iMeas;}
527 double xx = kfi->getMeasurementOnPlane(imea)->getState()(0);
528 m_hHitEff_soft[Wid.
getICLayer()]->Fill(std::copysign(xx, RLInfo), max);
535 B2INFO(
"Start estimate residual for un-fitted layer");
536 B2INFO(
"position seed" << track->getPositionSeed().Y());
540 x_b = 0; res_b = 0; res_b_err = 0;
541 x_u = 0; res_u = 0; res_u_err = 0;
542 z = 0; dt_flight_sim = 0; z_prop = 0; t = 0;
543 dt_prop = 0; dt_flight = 0; alpha = 0; theta = 0;
544 tdc = 0; adc = 0; lay = 0; IWire = 0;
547 B2INFO(
"number of cdchit" << track->getCDCHitList().size());
548 B2INFO(
"number of point use int fit" << ndf + 4);
550 typedef std::pair<double, const RecoHitInformation*> SortingRecoHitPair;
554 if (track->getRecoHitInformation(cdchit)->useInFit())
continue;
558 int hitSortingParameter = track->getRecoHitInformation(cdchit)->getSortingParameter();
560 SortingRecoHitPair frontSideHit = std::make_pair(0,
nullptr);;
561 SortingRecoHitPair backsideSideHit = std::make_pair(0,
nullptr);;
562 SortingRecoHitPair hit4extraction;
575 auto hitListReverse = track->getCDCHitList();
576 std::reverse(hitListReverse.begin() , hitListReverse.end());
585 B2DEBUG(99,
"forward sorting parameter: " << frontSideHit.first <<
" |backward sorting parameter = " << backsideSideHit.first);
586 if (std::fabs(frontSideHit.first - hitSortingParameter) < std::fabs(backsideSideHit.first - hitSortingParameter)) {
587 hit4extraction = frontSideHit;
589 hit4extraction = backsideSideHit;
593 if (hit4extraction.second ==
nullptr)
596 auto closestHitTrackPoint = track->getCreatedTrackPoint(hit4extraction.second);
608 plane = constructPlane(meaOnPlane, wireid);
610 B2WARNING(
"Error happen, can not reconstruct plan for extrapolating" << e.what());
613 double segmentLength;
615 segmentLength = meaOnPlane.extrapolateToPlane(plane);
617 B2WARNING(
"Could not extrapolate the fit" << e.what());
620 IWire = wireid.getIWire();
621 lay = wireid.getICLayer();
622 const TVector3 pocaOnWire = meaOnPlane.getPlane()->getO();
623 const TVector3 pocaMom = meaOnPlane.getMom();
624 x_u = meaOnPlane.getState()(3);
625 alpha = cdcgeo.
getAlpha(pocaOnWire, pocaMom) ;
629 dt_prop = z_prop / 27.25;
633 if (fabs(alpha) > M_PI / 2) {
639 dt_flight = meaOnPlane.getTime();
640 x_mea = tdcTrans->
getDriftLength(cdchit->getTDCCount(), wireid, dt_flight, lr, pocaOnWire.Z(), alpha, theta, cdchit->getADCCount());
641 x_mea = std::copysign(x_mea, x_u);
643 absRes_u = fabs(x_mea) - fabs(x_u);
646 m_hAlpha->Fill(alpha);
647 m_hTheta->Fill(theta);
648 if (m_StoreCDCSimHitInfo) {
656 B2DEBUG(199,
"we calculate residua for lay - IWire: " << lay <<
" - " << IWire);
657 B2DEBUG(199,
"distance between two hit" << segmentLength);
658 B2DEBUG(199,
"Flight Time (extra | sim)" << dt_flight <<
" - " << dt_flight_sim);
659 B2DEBUG(199,
"DriftLength (cal | sim)" << x_mea <<
" - " << x_sim);
678 TVector3 WireDirectionIdeal = Wire2PosIdeal - Wire1PosIdeal;
679 WireDirectionIdeal.SetMag(1.);
684 const TVector3& PocaIdeal = rep->
getPos(st);
686 double zPOCA = (Wire1PosIdeal.Z()
687 + WireDirectionIdeal.Dot(PocaIdeal - Wire1PosIdeal) * WireDirectionIdeal.Z());
694 TVector3 wireDirection = wire2 - wire1;
695 wireDirection.SetMag(1.);
699 const TVector3& poca = rep->
getPos(st);
700 TVector3 dirInPoca = rep->
getMom(st);
701 dirInPoca.SetMag(1.);
702 const TVector3& pocaOnWire = wire1 + wireDirection.Dot(poca - wire1) * wireDirection;
703 if (fabs(wireDirection.Angle(dirInPoca)) < 0.01) {
704 B2WARNING(
"cannot construct det plane, track parallel with wire");
707 const TVector3& U = wireDirection.Cross(dirInPoca);
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
unsigned short getIWire() const
Getter for iWire.
short getTDCCount() const
Getter for TDC count.
unsigned short getID() const
Getter for encoded wire number.
unsigned short getADCCount() const
Getter for integrated charge.
unsigned short getISuperLayer() const
Getter for iSuperLayer.
unsigned short getILayer() const
Getter for iLayer.
This class is used to transfer CDC information to the track fit.
const CDCHit * getCDCHit() const
get the pointer to the CDCHit object that was used to create this CDCRecoHit object.
WireID getWireID() const
Getter for WireID object.
TVector3 getPosWire() const
The method to get position on wire.
double getFlightTime() const
The method to get flight time.
double getDriftLength() const
The method to get drift length.
CDC Cosmic test calibration module.
The Class for CDC Geometry Parameters.
unsigned short getBoardID(const WireID &wID) const
Returns frontend board id. corresponding to the wire id.
const TVector3 wireBackwardPosition(int layerId, int cellId, EWirePosition set=c_Base) const
Returns the backward position of the input sense wire.
double getAlpha(const TVector3 &posOnWire, const TVector3 &momentum) const
Returns track incident angle in rphi plane (alpha in rad.).
double getOutgoingAlpha(const double alpha) const
Converts incoming- to outgoing-alpha.
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.
double getTheta(const TVector3 &momentum) const
Returns track incident angle (theta in rad.).
double getDriftTime(double dist, unsigned short layer, unsigned short lr, double alpha, double theta) const
Return the drift time to the sense wire.
This class uses the realistic detector geometry (the one after alignment procedure) for the translati...
const TVector3 getWireBackwardPosition(const WireID &wireID) override
Get wire position at backward end.
const TVector3 getWireForwardPosition(const WireID &wireID) override
Get wire position at forward end.
Translator mirroring the realistic Digitization.
double getDriftLength(unsigned short tdcCount, const WireID &wireID=WireID(), double timeOfFlightEstimator=0, bool leftRight=false, double z=0, double alpha=0, double theta=static_cast< double >(TMath::Pi()/2.), unsigned short adcCount=0) override
Get Drift length.
double getDriftTime(unsigned short tdcCount, const WireID &wireID, double timeOfFlightEstimator, double z, unsigned short adcCount) override
Get Drift time.
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
This is the Reconstruction Event-Data Model Track.
Low-level class to create/modify relations between StoreArrays.
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
const std::string & getName() const
Return name under which the object is saved in the DataStore.
Class that bundles various TrackFitResults.
const TrackFitResult * getTrackFitResult(const Const::ChargedStable &chargedStable) const
Access to TrackFitResults.
Class to identify a wire inside the CDC.
unsigned short getICLayer() const
Getter for continuous layer numbering.
Contains the measurement and covariance in raw detector coordinates.
Abstract base class for a track representation.
virtual double extrapolateToLine(StateOnPlane &state, const TVector3 &linePoint, const TVector3 &lineDirection, bool stopAtBoundary=false, bool calcJacobianNoise=false) const =0
Extrapolates the state to the POCA to a line, and returns the extrapolation length and,...
virtual TVector3 getMom(const StateOnPlane &state) const =0
Get the cartesian momentum vector of a state.
virtual TVector3 getPos(const StateOnPlane &state) const =0
Get the cartesian position of a state.
Exception class for error handling in GENFIT (provides storage for diagnostic information)
virtual const char * what() const noexcept
Standard error message handling for exceptions. use like "std::cerr << e.what();".
Class where important numbers and properties of a fit can be stored.
bool isFitConverged(bool inAllPoints=true) const
Did the fit converge (in all Points or only partially)?
double getChi2() const
Get chi^2 of the fit.
bool isFitted() const
Has the track been fitted?
double getNdf() const
Get the degrees of freedom of the fit.
Collects information needed and produced by a AbsKalmanFitter implementations and is specific to one ...
MeasurementOnPlane getResidual(unsigned int iMeasurement=0, bool biased=false, bool onlyMeasurementErrors=true) const override
Get unbiased (default) or biased residual from ith measurement.
const MeasuredStateOnPlane & getFittedState(bool biased=true) const override
Get unbiased or biased (default) smoothed state.
std::vector< double > getWeights() const
Get weights of measurements.
#StateOnPlane with additional covariance matrix.
Measured coordinates on a plane.
A state with arbitrary dimension defined in a DetPlane.
Object containing AbsMeasurement and AbsFitterInfo objects.
KalmanFitterInfo * getKalmanFitterInfo(const AbsTrackRep *rep=nullptr) const
Helper to avoid casting.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.
Defines for I/O streams used for error and debug printing.
std::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.