23 cout <<
" First loop over reco. tracks:" << endl;
26 uint64_t nBytesTrk = 0;
27 for (uint64_t iTrk = 0; iTrk < nTrks; iTrk++) {
30 const uint64_t bytesTrk = ntTrack ->
GetEntry(iTrk);
32 cerr <<
"WARNING: something wrong with track #" << iTrk <<
"! Aborting loop!" << endl;
35 nBytesTrk += bytesTrk;
38 const uint64_t iProgTrk = iTrk + 1;
39 if (iProgTrk == nTrks) {
40 cout <<
" Processing track " << iProgTrk <<
"/" << nTrks <<
"..." << endl;
42 cout <<
" Processing track " << iProgTrk <<
"/" << nTrks <<
"...\r" <<
flush;
46 const double ptFrac = trk_pt / trk_gpt;
47 const double ptDelta = trk_deltapt / trk_pt;
50 const bool isInZVtxCut = (abs(trk_vz) < vzTrkMax);
51 const bool isInInttCut = (trk_nintt >= nInttTrkMin);
52 const bool isInMVtxCut = (trk_nlmaps > nMVtxTrkMin);
53 const bool isInTpcCut = (trk_ntpc > nTpcTrkMin);
54 const bool isInPtCut = (trk_pt > ptTrkMin);
55 const bool isInQualCut = (trk_quality < qualTrkMax);
56 const bool isGoodTrk = (isInZVtxCut && isInInttCut && isInMVtxCut && isInTpcCut && isInPtCut && isInQualCut);
57 if (!isGoodTrk)
continue;
60 hPtDelta ->
Fill(ptDelta);
61 hPtTrack ->
Fill(trk_pt);
62 hPtFrac ->
Fill(ptFrac);
63 hPtTrkTru ->
Fill(trk_gpt);
64 hPtDeltaVsFrac ->
Fill(ptFrac, ptDelta);
65 hPtDeltaVsTrue ->
Fill(trk_gpt, ptDelta);
66 hPtDeltaVsTrack ->
Fill(trk_pt, ptDelta);
67 hPtTrueVsTrack ->
Fill(trk_pt, trk_gpt);
70 const bool isNormalTrk = ((ptFrac > normRange[0]) && (ptFrac < normRange[1]));
71 for (
size_t iCut = 0; iCut < nDPtCuts; iCut++) {
72 const bool isInDeltaPtCut = (ptDelta < ptDeltaMax[iCut]);
76 hPtDeltaCut[iCut] ->
Fill(ptDelta);
77 hPtTrackCut[iCut] ->
Fill(trk_pt);
78 hPtFracCut[iCut] ->
Fill(ptFrac);
79 hPtTrkTruCut[iCut] ->
Fill(trk_gpt);
80 hPtDeltaVsFracCut[iCut] ->
Fill(ptFrac, ptDelta);
81 hPtDeltaVsTrueCut[iCut] ->
Fill(trk_gpt, ptDelta);
82 hPtDeltaVsTrackCut[iCut] ->
Fill(trk_pt, ptDelta);
83 hPtTrueVsTrackCut[iCut] ->
Fill(trk_pt, trk_gpt);
95 cout <<
" First loop over reco. tracks finished!" << endl;
105 cout <<
" Second loop over reco. tracks:" << endl;
108 uint64_t nBytesTrk = 0;
109 for (uint64_t iTrk = 0; iTrk < nTrks; iTrk++) {
112 const uint64_t bytesTrk = ntTrack ->
GetEntry(iTrk);
114 cerr <<
"WARNING: something wrong with track #" << iTrk <<
"! Aborting loop!" << endl;
117 nBytesTrk += bytesTrk;
120 const uint64_t iProgTrk = iTrk + 1;
121 if (iProgTrk == nTrks) {
122 cout <<
" Processing track " << iProgTrk <<
"/" << nTrks <<
"..." << endl;
124 cout <<
" Processing track " << iProgTrk <<
"/" << nTrks <<
"...\r" <<
flush;
128 const double ptFrac = trk_pt / trk_gpt;
129 const double ptDelta = trk_deltapt / trk_pt;
132 const bool isInZVtxCut = (abs(trk_vz) < vzTrkMax);
133 const bool isInInttCut = (trk_nintt >= nInttTrkMin);
134 const bool isInMVtxCut = (trk_nlmaps > nMVtxTrkMin);
135 const bool isInTpcCut = (trk_ntpc > nTpcTrkMin);
136 const bool isInPtCut = (trk_pt > ptTrkMin);
137 const bool isInQualCut = (trk_quality < qualTrkMax);
138 const bool isGoodTrk = (isInZVtxCut && isInInttCut && isInMVtxCut && isInTpcCut && isInPtCut && isInQualCut);
139 if (!isGoodTrk)
continue;
142 const bool isNormalTrk = ((ptFrac > normRange[0]) && (ptFrac < normRange[1]));
143 for (
size_t iSig = 0; iSig < nSigCuts; iSig++) {
146 const float ptDeltaMin = fMuLoProj[iSig] -> Eval(trk_pt);
147 const float ptDeltaMax = fMuHiProj[iSig] -> Eval(trk_pt);
149 const bool isInDeltaPtSigma = ((ptDelta >= ptDeltaMin) && (ptDelta <= ptDeltaMax));
150 if (isInDeltaPtSigma) {
153 hPtDeltaSig[iSig] ->
Fill(ptDelta);
154 hPtTrackSig[iSig] ->
Fill(trk_pt);
155 hPtFracSig[iSig] ->
Fill(ptFrac);
156 hPtTrkTruSig[iSig] ->
Fill(trk_gpt);
157 hPtDeltaVsFracSig[iSig] ->
Fill(ptFrac, ptDelta);
158 hPtDeltaVsTrueSig[iSig] ->
Fill(trk_gpt, ptDelta);
159 hPtDeltaVsTrackSig[iSig] ->
Fill(trk_pt, ptDelta);
160 hPtTrueVsTrackSig[iSig] ->
Fill(trk_pt, trk_gpt);
172 cout <<
" Second loop over reco. tracks finished!" << endl;
182 cout <<
" Loop over particles:" << endl;
185 uint64_t nBytesTru = 0;
186 for (uint64_t iTru = 0; iTru < nTrus; iTru++) {
189 const uint64_t bytesTru = ntTruth ->
GetEntry(iTru);
191 cerr <<
"WARNING: something wrong with particle #" << iTru <<
"! Aborting loop!" << endl;
194 nBytesTru += bytesTru;
197 const uint64_t iProgTru = iTru + 1;
198 if (iProgTru == nTrus) {
199 cout <<
" Processing particle " << iProgTru <<
"/" << nTrus <<
"..." << endl;
201 cout <<
" Processing particle " << iProgTru <<
"/" << nTrus <<
"...\r" <<
flush;
205 const bool isPrimary = (tru_gprimary == 1);
207 hPtTruth ->
Fill(tru_gpt);
210 cout <<
" Loop over particles finished!" << endl;
219 const TString sMuHiBase =
"MeanPlusSigma";
220 const TString sMuLoBase =
"MeanMinusSigma";
221 const TString sSigBase =
"ProjectionSigma";
222 const TString sMuBase =
"ProjectionMean";
225 vector<TString> sFitProj(nProj);
226 for (
size_t iProj = 0; iProj < nProj; iProj++) {
227 sFitProj[iProj] =
"f";
228 sFitProj[iProj].Append(sPtProjBase.Data());
229 sFitProj[iProj].Append(sProjSuffix[iProj].
Data());
233 const uint32_t fWidFit = 2;
234 const uint32_t fLinFit = 1;
235 for (
size_t iProj = 0; iProj < nProj; iProj++) {
238 const uint32_t iBinProj = hPtDeltaVsTrack ->
GetXaxis() -> FindBin(ptProj[iProj]);
239 hPtDeltaProj[iProj] = hPtDeltaVsTrack ->
ProjectionY(sPtProj[iProj], iBinProj, iBinProj,
"");
242 const float ampGuess = hPtDeltaProj[iProj] -> GetMaximum();
243 const float muGuess = hPtDeltaProj[iProj] -> GetMean();
244 const float sigGuess = hPtDeltaProj[iProj] -> GetRMS();
247 fPtDeltaProj[iProj] =
new TF1(sFitProj[iProj].
Data(),
"gaus", deltaFitRange[0], deltaFitRange[1]);
254 hPtDeltaProj[iProj] -> Fit(sFitProj[iProj].
Data(),
"R");
258 sigProj[iProj] = fPtDeltaProj[iProj] ->
GetParameter(2);
259 for (
size_t iSig = 0; iSig < nSigCuts; iSig++) {
260 muHiProj[iSig][iProj] = muProj[iProj] + (ptDeltaSig[iSig] * sigProj[iProj]);
261 muLoProj[iSig][iProj] = muProj[iProj] - (ptDeltaSig[iSig] * sigProj[iProj]);
264 cout <<
" Obtained delta-pt projections, fits, and sigmas." << endl;
267 TString sMuProj(
"gr");
268 TString sSigProj(
"gr");
269 sMuProj.Append(sMuBase.Data());
270 sSigProj.Append(sSigBase.Data());
272 vector<TString> sGrMuHiProj(nSigCuts);
273 vector<TString> sGrMuLoProj(nSigCuts);
274 vector<TString> sFnMuHiProj(nSigCuts);
275 vector<TString> sFnMuLoProj(nSigCuts);
276 for (
size_t iSig = 0; iSig < nSigCuts; iSig++) {
277 sGrMuHiProj[iSig] =
"gr";
278 sGrMuLoProj[iSig] =
"gr";
279 sFnMuHiProj[iSig] =
"f";
280 sFnMuLoProj[iSig] =
"f";
281 sGrMuHiProj[iSig].Append(sMuHiBase.Data());
282 sGrMuLoProj[iSig].Append(sMuLoBase.Data());
283 sFnMuHiProj[iSig].Append(sMuHiBase.Data());
284 sFnMuLoProj[iSig].Append(sMuLoBase.Data());
285 sGrMuHiProj[iSig].Append(sSigSuffix[iSig].
Data());
286 sGrMuLoProj[iSig].Append(sSigSuffix[iSig].
Data());
287 sFnMuHiProj[iSig].Append(sSigSuffix[iSig].
Data());
288 sFnMuLoProj[iSig].Append(sSigSuffix[iSig].
Data());
292 TVectorD tvecPtProj(ptProj.size(), ptProj.data());
293 TVectorD tvecMuProj(muProj.size(), muProj.data());
294 TVectorD tvecSigProj(sigProj.size(), sigProj.data());
296 vector<TVectorD> tvecMuHiProj;
297 vector<TVectorD> tvecMuLoProj;
298 for (
size_t iSig = 0; iSig < nSigCuts; iSig++) {
299 tvecMuHiProj.push_back(TVectorD(muHiProj[iSig].
size(), muHiProj[iSig].
data()));
300 tvecMuLoProj.push_back(TVectorD(muLoProj[iSig].
size(), muLoProj[iSig].
data()));
304 grMuProj =
new TGraph(tvecPtProj, tvecMuProj);
305 grSigProj =
new TGraph(tvecPtProj, tvecSigProj);
307 grSigProj ->
SetName(sSigProj);
310 for (
size_t iSig = 0; iSig < nSigCuts; iSig++) {
313 grMuHiProj[iSig] =
new TGraph(tvecPtProj, tvecMuHiProj[iSig]);
314 grMuLoProj[iSig] =
new TGraph(tvecPtProj, tvecMuLoProj[iSig]);
315 grMuHiProj[iSig] ->
SetName(sGrMuHiProj[iSig].
Data());
316 grMuLoProj[iSig] ->
SetName(sGrMuLoProj[iSig].
Data());
319 fMuHiProj[iSig] =
new TF1(sFnMuHiProj[iSig].
Data(),
"pol2", rPtRange[0], rPtRange[1]);
320 fMuLoProj[iSig] =
new TF1(sFnMuLoProj[iSig].
Data(),
"pol2", rPtRange[0], rPtRange[1]);
335 grMuHiProj[iSig] -> Fit(sFnMuHiProj[iSig].
Data(),
"",
"", ptFitRange[0], ptFitRange[1]);
336 grMuLoProj[iSig] -> Fit(sFnMuLoProj[iSig].
Data(),
"",
"", ptFitRange[0], ptFitRange[1]);
339 cout <<
" Created and fit sigma graphs." << endl;
349 const TString sRejCutBase =
"Reject_flatDPtCut";
350 const TString sRejSigBase =
"Reject_sigmaCut";
353 for (
size_t iCut = 0; iCut < nDPtCuts; iCut++) {
354 rejCut[iCut] = (
double) nNormCut[iCut] / (
double) nWeirdCut[iCut];
356 cout <<
" Calculated flat delta-pt rejection factors." << endl;
359 for (
size_t iSig = 0; iSig < nSigCuts; iSig++) {
360 rejSig[iSig] = (
double) nNormSig[iSig] / (
double) nWeirdSig[iSig];
362 cout <<
" Calculated pt-depdendent delta-pt rejection factors\n"
363 <<
" Rejection factors:\n"
364 <<
" Flat delta-pt cuts"
368 for (
size_t iCut = 0; iCut < nDPtCuts; iCut++) {
369 cout <<
" n(Norm, Weird) = (" << nNormCut[iCut] <<
", " << nWeirdCut[iCut] <<
"), rejection = " << rejCut[iCut] << endl;
373 cout <<
" Pt-dependent delta-pt cuts" << endl;
374 for (
size_t iSig = 0; iSig < nSigCuts; iSig++) {
375 cout <<
" n(Norm, Weird) = (" << nNormSig[iSig] <<
", " << nWeirdSig[iSig] <<
"), rejection = " << rejSig[iSig] << endl;
379 TString sRejCut(
"gr");
380 TString sRejSig(
"gr");
381 sRejCut.Append(sRejCutBase.Data());
382 sRejSig.Append(sRejSigBase.Data());
385 TVectorD tvecPtDeltaMax(ptDeltaMax.size(), ptDeltaMax.data());
386 TVectorD tvecPtDeltaSig(ptDeltaSig.size(), ptDeltaSig.data());
387 TVectorD tvecRejCut(rejCut.size(), rejCut.data());
388 TVectorD tvecRejSig(rejSig.size(), rejSig.data());
391 grRejCut =
new TGraph(tvecPtDeltaMax, tvecRejCut);
392 grRejSig =
new TGraph(tvecPtDeltaSig, tvecRejSig);
393 grRejCut ->
SetName(sRejCut.Data());
394 grRejSig ->
SetName(sRejSig.Data());
396 cout <<
" Made rejection factor graph." << endl;
406 const TString sEffBase =
"Efficiency";
410 hPtTruth -> Rebin(nEffRebin);
411 hPtTrkTru -> Rebin(nEffRebin);
412 for (
size_t iCut = 0; iCut < nDPtCuts; iCut++) {
413 hPtTrkTruCut[iCut] -> Rebin(nEffRebin);
415 for (
size_t iSig = 0; iSig < nSigCuts; iSig++) {
416 hPtTrkTruSig[iSig] -> Rebin(nEffRebin);
418 cout <<
" Rebinned efficiency histograms." << endl;
422 sEff.Append(sEffBase.Data());
425 vector<TString> sEffCut(nDPtCuts);
426 for (
size_t iCut = 0; iCut < nDPtCuts; iCut++) {
428 sEffCut[iCut].Append(sEffBase.Data());
429 sEffCut[iCut].Append(sDPtSuffix[iCut].
Data());
433 vector<TString> sEffSig(nSigCuts);
434 for (
size_t iSig = 0; iSig < nSigCuts; iSig++) {
436 sEffSig[iSig].Append(sEffBase.Data());
437 sEffSig[iSig].Append(sSigSuffix[iSig].
Data());
440 hEff = (TH1D*) hPtTruth -> Clone();
442 hEff ->
Reset(
"ICES");
443 hEff -> Divide(hPtTrkTru, hPtTruth, 1., 1.);
446 for (
size_t iCut = 0; iCut < nDPtCuts; iCut++) {
447 hEffCut[iCut] = (TH1D*) hPtTruth -> Clone();
449 hEffCut[iCut] ->
Reset(
"ICES");
450 hEffCut[iCut] -> Divide(hPtTrkTruCut[iCut], hPtTruth, 1., 1.);
454 for (
size_t iSig = 0; iSig < nSigCuts; iSig++) {
455 hEffSig[iSig] = (TH1D*) hPtTruth -> Clone();
457 hEffSig[iSig] ->
Reset(
"ICES");
458 hEffSig[iSig] -> Divide(hPtTrkTruSig[iSig], hPtTruth, 1., 1.);
461 cout <<
" Calculated efficiencies." << endl;