11 #include <tracking/modules/svdROIFinder/SVDROIFinderAnalysisDataModule.h>
12 #include <framework/datastore/StoreArray.h>
13 #include <framework/logging/Logger.h>
15 #include <svd/dataobjects/SVDShaperDigit.h>
32 , m_recoTrackListName()
33 , m_SVDInterceptListName()
35 , m_rootFilePtr(
nullptr)
37 , m_writeToRoot(false)
41 , m_h1Track_pt(
nullptr)
42 , m_h1Track_phi(
nullptr)
43 , m_h1Track_lambda(
nullptr)
44 , m_h1Track_cosTheta(
nullptr)
45 , m_h1Track_pVal(
nullptr)
47 , m_h1ROItrack(
nullptr)
48 , m_h1ROItrack_pt(
nullptr)
49 , m_h1ROItrack_phi(
nullptr)
50 , m_h1ROItrack_lambda(
nullptr)
51 , m_h1ROItrack_cosTheta(
nullptr)
52 , m_h1ROItrack_pVal(
nullptr)
54 , m_h1GoodROItrack(
nullptr)
55 , m_h1GoodROItrack_pt(
nullptr)
56 , m_h1GoodROItrack_phi(
nullptr)
57 , m_h1GoodROItrack_lambda(
nullptr)
58 , m_h1GoodROItrack_cosTheta(
nullptr)
59 , m_h1GoodROItrack_pVal(
nullptr)
61 , m_h1FullROItrack(
nullptr)
62 , m_h1FullROItrack_pt(
nullptr)
63 , m_h1FullROItrack_phi(
nullptr)
64 , m_h1FullROItrack_lambda(
nullptr)
65 , m_h1FullROItrack_cosTheta(
nullptr)
66 , m_h1FullROItrack_pVal(
nullptr)
70 , m_h2sigmaUphi(
nullptr)
71 , m_h2sigmaVphi(
nullptr)
76 , m_h1GlobalTime(
nullptr)
78 , m_h2ROIuMinMax(
nullptr)
79 , m_h2ROIvMinMax(
nullptr)
80 , m_h2ROIcenters(
nullptr)
81 , m_h2GoodROIcenters(
nullptr)
82 , m_h2FullROIcenters(
nullptr)
83 , m_h1totROIs(
nullptr)
84 , m_h1goodROIs(
nullptr)
86 , m_h1effROIs(
nullptr)
97 setDescription(
"This module performs the analysis of the SVDROIFinder module output ON DATA");
99 addParam(
"writeToRoot", m_writeToRoot,
100 "set true if you want to save the informations in a root file named by parameter 'rootFileName'",
bool(
true));
102 addParam(
"rootFileName", m_rootFileName,
103 "fileName used for . Will be ignored if parameter 'writeToRoot' is false (standard)",
104 string(
"svdDataRedAnalysisData"));
106 addParam(
"recoTrackListName", m_recoTrackListName,
107 "name of the input collection of RecoTracks", std::string(
""));
109 addParam(
"shapers", m_shapersName,
110 "name of the input collection of SVDShaperDigits", std::string(
""));
112 addParam(
"SVDInterceptListName", m_SVDInterceptListName,
113 "name of the list of interceptions", std::string(
""));
115 addParam(
"ROIListName", m_ROIListName,
116 "name of the list of ROIs", std::string(
""));
118 addParam(
"edgeU", m_edgeU,
"fiducial region: edge U [mm]",
float(10));
119 addParam(
"edgeV", m_edgeV,
"fiducial region: edge V [mm]",
float(10));
120 addParam(
"minPVal", m_minPVal,
"fiducial region: minimum track P-Value",
float(0.001));
124 SVDROIFinderAnalysisDataModule::~SVDROIFinderAnalysisDataModule()
129 void SVDROIFinderAnalysisDataModule::initialize()
132 m_shapers.isRequired(m_shapersName);
133 m_recoTracks.isRequired(m_recoTrackListName);
134 m_tracks.isRequired();
135 m_ROIs.isRequired(m_ROIListName);
136 m_SVDIntercepts.isRequired(m_SVDInterceptListName);
144 if (m_writeToRoot ==
true) {
145 m_rootFileName +=
".root";
146 m_rootFilePtr =
new TFile(m_rootFileName.c_str(),
"RECREATE");
148 m_rootFilePtr =
nullptr;
151 m_h1GlobalTime =
new TH1F(
"hGlobalTime",
"global time for SVDShaperDigits contained in ROI", 200, -100, 100);
152 m_h1PullU =
new TH1F(
"hPullU",
"U pulls for SVDShaperDigits contained in ROI", 100, -6, 6);
153 m_h1PullV =
new TH1F(
"hPullV",
"V pulls for SVDShaperDigits contained in ROI", 100, -6, 6);
154 m_h2sigmaUphi =
new TH2F(
"hsigmaUvsPhi",
"sigmaU vs phi digits in ROI", 100, -180, 180, 100, 0, 0.35);
155 m_h2sigmaVphi =
new TH2F(
"hsigmaVvsPhi",
"sigmaU vs phi digits in ROI", 100, -180, 180, 100, 0, 0.4);
156 m_h1ResidU =
new TH1F(
"hResidU",
"U resid for SVDShaperDigits contained in ROI", 100, -0.5, 0.5);
157 m_h1ResidV =
new TH1F(
"hResidV",
"V resid for SVDShaperDigits contained in ROI", 100, -0.5, 0.5);
158 m_h1SigmaU =
new TH1F(
"hSigmaU",
"sigmaU for SVDShaperDigits contained in ROI", 100, 0, 0.35);
159 m_h1SigmaV =
new TH1F(
"hSigmaV",
"sigmaV for SVDShaperDigits contained in ROI", 100, 0, 0.35);
171 m_h1totROIs =
new TH1F(
"h1TotNROIs",
"number of all ROIs", 110, 0, 110);
172 m_h1goodROIs =
new TH1F(
"h1GoodNROIs",
"number of ROIs from Good Track", 110, 0, 110);
173 m_h1okROIs =
new TH1F(
"h1OkNROIs",
"number of Good ROIs containing a SVDShaperDigit", 110, 0, 110);
174 m_h1effROIs =
new TH1F(
"h1EffSVD",
"fraction of Good ROIs containing a SVDShaperDigit", 100, 0, 1.1);
180 m_h2ROIuMinMax =
new TH2F(
"h2ROIuMinMax",
"u Min vs Max (all ROIs)", 960, -100, 860, 960, -100, 860);
181 m_h2ROIvMinMax =
new TH2F(
"h2ROIvMinMax",
"v Min vs Max (all ROIs)", 960, -100, 860, 960, -100, 860);
182 m_h2ROIcenters =
new TH2F(
"h2ROIcenters",
"ROI Centers", 768, 0, 768, 512, 0, 512);
183 m_h2GoodROIcenters =
new TH2F(
"h2GoodROIcenters",
"Good ROI Centers", 768, 0, 768, 512, 0, 512);
184 m_h2FullROIcenters =
new TH2F(
"h2FullROIcenters",
"Full ROI Centers", 768, 0, 768, 512, 0, 512);
193 m_h1ROItrack =
new TH1F(
"hROITrack",
"track with an attached Good ROI", 2, 0, 2);
194 m_h1ROItrack_pt =
new TH1F(
"hROITrack_pT",
"Track with an attached Good ROI, Transverse Momentum", 100, 0, 8);
195 m_h1ROItrack_phi =
new TH1F(
"h1ROITrack_phi",
"Track with an attached Good ROI, Momentum Phi", 200, -TMath::Pi() - 0.01,
197 m_h1ROItrack_lambda =
new TH1F(
"h1ROITrack_lambda",
"Track with an attached Good ROI, Lambda", 100, -TMath::Pi() - 0.01,
199 m_h1ROItrack_cosTheta =
new TH1F(
"h1ROITrack_cosTheta",
"Track with an attached Good ROI, Momentum CosTheta", 100, -1 - 0.01, 1.01);
200 m_h1ROItrack_pVal =
new TH1F(
"h1ROITrack_pVal",
"Track with an attached Good ROI, P-Value", 1000, 0, 1 + 0.01);
202 m_h1FullROItrack =
new TH1F(
"hFullROITrack",
"track with an attached Full ROI", 20, 0, 20);
203 m_h1FullROItrack_pt =
new TH1F(
"hFullROITrack_pT",
"Track with an attached Full ROI, Transverse Momentum", 100, 0, 8);
204 m_h1FullROItrack_phi =
new TH1F(
"h1FullROITrack_phi",
"Track with an attached Full ROI, Momentum Phi", 200, -TMath::Pi() - 0.01,
206 m_h1FullROItrack_lambda =
new TH1F(
"h1FullROITrack_lambda",
"Track with an attached Full ROI, Lambda", 100, -TMath::Pi() - 0.01,
208 m_h1FullROItrack_cosTheta =
new TH1F(
"h1FullROITrack_cosTheta",
"Track with an attached Full ROI, Momentum CosTheta", 100,
210 m_h1FullROItrack_pVal =
new TH1F(
"h1FullROITrack_pVal",
"Track with an attached Full ROI, P-Value", 1000, 0, 1 + 0.01);
212 m_h1GoodROItrack =
new TH1F(
"hGoodROITrack",
"track with an attached Good ROI", 20, 0, 20);
213 m_h1GoodROItrack_pt =
new TH1F(
"hGoodROITrack_pT",
"Track with an attached Good ROI, Transverse Momentum", 100, 0, 8);
214 m_h1GoodROItrack_phi =
new TH1F(
"h1GoodROITrack_phi",
"Track with an attached Good ROI, Momentum Phi", 200, -TMath::Pi() - 0.01,
216 m_h1GoodROItrack_lambda =
new TH1F(
"h1GoodROITrack_lambda",
"Track with an attached Good ROI, Lambda", 100, -TMath::Pi() - 0.01,
218 m_h1GoodROItrack_cosTheta =
new TH1F(
"h1GoodROITrack_cosTheta",
"Track with an attached Good ROI, Momentum CosTheta", 100,
220 m_h1GoodROItrack_pVal =
new TH1F(
"h1GoodROITrack_pVal",
"Track with an attached Good ROI, P-Value", 1000, 0, 1 + 0.01);
222 m_h1Track =
new TH1F(
"hTrack",
"Number of Tracks per Event", 20, 0, 20);
223 m_h1Track_pt =
new TH1F(
"hTrack_pT",
"Track Transverse Momentum", 100, 0, 8);
224 m_h1Track_lambda =
new TH1F(
"h1Track_lambda",
"Track Momentum Lambda", 100, -TMath::Pi() + 0.01, TMath::Pi() + 0.01);
225 m_h1Track_phi =
new TH1F(
"h1Track_phi",
"Track momentum Phi", 200, -TMath::Pi() - 0.01, TMath::Pi() + 0.01);
226 m_h1Track_cosTheta =
new TH1F(
"h1Track_cosTheta",
"Track Momentum CosTheta", 100, -1 - 0.01, 1 + 0.01);
227 m_h1Track_pVal =
new TH1F(
"h1Track_pVal",
"Track P-Value", 1000, 0, 1 + 0.01);
232 void SVDROIFinderAnalysisDataModule::event()
235 B2DEBUG(1,
" ++++++++++++++ SVDROIFinderAnalysisDataModule");
242 for (
int i = 0; i < (int)m_tracks.getEntries(); i++) {
244 const TrackFitResult* tfr = m_tracks[i]->getTrackFitResultWithClosestMass(Const::pion);
247 m_h1Track_pt->Fill(mom.Perp());
248 m_h1Track_phi->Fill(mom.Phi());
249 m_h1Track_cosTheta->Fill(mom.CosTheta());
250 m_h1Track_lambda->Fill(TMath::Pi() / 2 - mom.Theta());
254 m_h1Track->Fill(m_tracks.getEntries());
257 for (
int i = 0; i < (int)m_ROIs.getEntries(); i++) {
259 float centerROIU = (m_ROIs[i]->getMaxUid() + m_ROIs[i]->getMinUid()) / 2;
260 float centerROIV = (m_ROIs[i]->getMaxVid() + m_ROIs[i]->getMinVid()) / 2;
262 m_h2ROIuMinMax->Fill(m_ROIs[i]->getMinUid(), m_ROIs[i]->getMaxUid());
263 m_h2ROIvMinMax->Fill(m_ROIs[i]->getMinVid(), m_ROIs[i]->getMaxVid());
264 m_h2ROIcenters->Fill(centerROIU, centerROIV);
269 if (!theRC[0]->wasFitSuccessful()) {
270 m_h1ROItrack->Fill(0);
276 const TrackFitResult* tfr = theTrack[0]->getTrackFitResultWithClosestMass(Const::pion);
279 m_h1ROItrack->Fill(0);
284 m_h1ROItrack->Fill(1);
285 m_h1ROItrack_pt->Fill(mom.Perp());
286 m_h1ROItrack_phi->Fill(mom.Phi());
287 m_h1ROItrack_cosTheta->Fill(mom.CosTheta());
288 m_h1ROItrack_lambda->Fill(TMath::Pi() / 2 - mom.Theta());
289 m_h1ROItrack_pVal->Fill(tfr->
getPValue());
292 VxdID sensorID = m_ROIs[i]->getSensorID();
294 float nStripsU = 768;
295 float nStripsV = 512;
296 float centerSensorU = nStripsU / 2;
297 float centerSensorV = nStripsV / 2;
298 float pitchU = 0.075;
299 float pitchV = 0.240;
307 float edgeStripsU = m_edgeU / pitchU;
308 float edgeStripsV = m_edgeV / pitchV;
309 B2DEBUG(10,
"good U in range " << edgeStripsU <<
", " << nStripsU - edgeStripsU);
310 B2DEBUG(10,
"good V in range " << edgeStripsV <<
", " << nStripsV - edgeStripsV);
312 B2DEBUG(10,
"U check: " << abs(centerROIU - centerSensorU) <<
" < (good) " << centerSensorU - edgeStripsU);
313 B2DEBUG(10,
"V check: " << abs(centerROIV - centerSensorV) <<
" < (good) " << centerSensorV - edgeStripsV);
315 if ((abs(centerROIU - centerSensorU) > centerSensorU - edgeStripsU)
316 || (abs(centerROIV - centerSensorV) > centerSensorV - edgeStripsV))
320 m_h2GoodROIcenters->Fill(centerROIU, centerROIV);
324 ": U side " << m_ROIs[i]->getMinUid() <<
"->" << m_ROIs[i]->getMaxUid() <<
", V side " << m_ROIs[i]->getMinVid() <<
"->" <<
325 m_ROIs[i]->getMaxVid());
327 m_h1GoodROItrack_pt->Fill(mom.Perp());
328 m_h1GoodROItrack_phi->Fill(mom.Phi());
329 m_h1GoodROItrack_cosTheta->Fill(mom.CosTheta());
330 m_h1GoodROItrack_lambda->Fill(TMath::Pi() / 2 - mom.Theta());
331 m_h1GoodROItrack_pVal->Fill(tfr->
getPValue());
333 for (
int s = 0; s < m_shapers.getEntries(); s++) {
334 if (m_ROIs[i]->Contains(*(m_shapers[s]))) {
337 m_h2FullROIcenters->Fill(centerROIU, centerROIV);
338 m_h1FullROItrack->Fill(1);
339 m_h1FullROItrack_pt->Fill(mom.Perp());
340 m_h1FullROItrack_phi->Fill(mom.Phi());
341 m_h1FullROItrack_cosTheta->Fill(mom.CosTheta());
342 m_h1FullROItrack_lambda->Fill(TMath::Pi() / 2 - mom.Theta());
343 m_h1FullROItrack_pVal->Fill(tfr->
getPValue());
345 B2RESULT(
" --> is Full");
352 m_nGoodROIs += nGoodROIs;
353 m_h1goodROIs->Fill(nGoodROIs);
354 m_nOkROIs += nOkROIs;
355 m_h1okROIs->Fill(nOkROIs);
357 m_h1totROIs->Fill(m_ROIs.getEntries());
359 m_h1effROIs->Fill((
float) nOkROIs / nGoodROIs);
360 n_rois += m_ROIs.getEntries();
363 n_tracks += m_tracks.getEntries();
366 n_intercepts += m_SVDIntercepts.getEntries();
371 B2RESULT(
" o Good ROIs = " << nGoodROIs <<
", of which Full = " << nOkROIs
372 <<
" --> efficiency = " << (
float)nOkROIs / nGoodROIs);
374 if (nGoodROIs > m_ROIs.getEntries()) B2RESULT(
" HOUSTON WE HAVE A PROBLEM!");
379 void SVDROIFinderAnalysisDataModule::terminate()
382 B2RESULT(
" ROI AnalysisData Summary ");
383 B2RESULT(
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
385 B2RESULT(
" number of events = " << m_rootEvent);
386 B2RESULT(
" number of tracks = " << n_tracks);
387 B2RESULT(
" number of Intercepts = " << n_intercepts);
388 B2RESULT(
" number of ROIs = " << n_rois);
389 B2RESULT(
" number of Good ROIs = " << m_nGoodROIs);
390 if (m_nGoodROIs > 0) {
391 B2RESULT(
" number of Good ROIs with SVDShaperDigit= " << m_nOkROIs);
392 B2RESULT(
" SVD INefficiency = " << 1 - (
float)m_nOkROIs / m_nGoodROIs);
393 B2RESULT(
" average SVD INefficiency = " << 1 - m_h1effROIs->GetMean());
394 B2RESULT(
" number of EMPTY ROIs = " << m_nGoodROIs - m_nOkROIs);
399 if (m_rootFilePtr !=
nullptr) {
402 TDirectory* oldDir = gDirectory;
404 TDirectory* m_alltracks = oldDir->mkdir(
"ALLtracks");
405 TDirectory* m_roitracks = oldDir->mkdir(
"ROItracks");
406 TDirectory* m_goodroitracks = oldDir->mkdir(
"GoodROItracks");
407 TDirectory* m_fullroitracks = oldDir->mkdir(
"FullROItracks");
410 TDirectory* m_ROIDir = oldDir->mkdir(
"roi");
419 m_h1Track_pt->Write();
420 m_h1Track_phi->Write();
421 m_h1Track_lambda->Write();
422 m_h1Track_cosTheta->Write();
423 m_h1Track_pVal->Write();
426 m_h1ROItrack->Write();
427 m_h1ROItrack_pt->Write();
428 m_h1ROItrack_phi->Write();
429 m_h1ROItrack_lambda->Write();
430 m_h1ROItrack_cosTheta->Write();
432 m_goodroitracks->cd();
433 m_h1GoodROItrack->Write();
434 m_h1GoodROItrack_pt->Write();
435 m_h1GoodROItrack_phi->Write();
436 m_h1GoodROItrack_lambda->Write();
437 m_h1GoodROItrack_cosTheta->Write();
439 m_fullroitracks->cd();
440 m_h1FullROItrack->Write();
441 m_h1FullROItrack_pt->Write();
442 m_h1FullROItrack_phi->Write();
443 m_h1FullROItrack_lambda->Write();
444 m_h1FullROItrack_cosTheta->Write();
447 m_h1effROIs->Write();
448 m_h1totROIs->Write();
449 m_h1goodROIs->Write();
451 m_h2ROIuMinMax->Write();
452 m_h2ROIvMinMax->Write();
453 m_h2ROIcenters->Write();
454 m_h2GoodROIcenters->Write();
455 m_h2FullROIcenters->Write();
457 m_rootFilePtr->Close();