66 using fitParams = std::pair<Measurement1D, Measurement1D>;
89 template <std::
size_t SIZE>
92 unsigned int theNOfBins,
247 std::array<float, nPtBins_ + 1>
mypT_bins_ = PVValHelper::makeLogBins<float, nPtBins_>(1., 1
e3);
259 : storeNtuple_(iConfig.getParameter<
bool>(
"storeNtuple")),
260 intLumi_(iConfig.getUntrackedParameter<double>(
"intLumi", 0.)),
261 debug_(iConfig.getUntrackedParameter<
bool>(
"Debug",
false)),
262 pvsTag_(iConfig.getParameter<
edm::
InputTag>(
"vtxCollection")),
264 tracksTag_(iConfig.getParameter<
edm::
InputTag>(
"trackCollection")),
267 transientTrackBuilderToken_(
270 minVtxNdf_(iConfig.getUntrackedParameter<double>(
"minVertexNdf")),
271 minVtxWgt_(iConfig.getUntrackedParameter<double>(
"minVertexMeanWeight")),
272 runControl_(iConfig.getUntrackedParameter<
bool>(
"runControl",
false)) {
275 std::vector<unsigned int> defaultRuns;
276 defaultRuns.push_back(0);
301 bool passesRunControl =
false;
305 if (
iEvent.eventAuxiliary().run() == runControlNumber) {
308 <<
" run number: " <<
iEvent.eventAuxiliary().run() <<
" keeping run:" << runControlNumber;
310 passesRunControl =
true;
314 if (!passesRunControl)
340 int nOfflineVtx = pvtx.size();
347 for (
int itrig = 0; itrig != ntrigs; ++itrig) {
358 int noFakecounter = 0;
361 for (
auto pvIt = pvtx.cbegin(); pvIt != pvtx.cend(); ++pvIt) {
376 if (trki->isNonnull()) {
393 ntrks % 2 == 0 ? even_ntrks = ntrks : even_ntrks = ntrks - 1;
396 for (
uint tracksIt = 0; tracksIt < even_ntrks; tracksIt = tracksIt + 2) {
399 auto dis = std::uniform_int_distribution<>(0, 1);
402 groupOne.push_back(firstTrk);
403 groupTwo.push_back(secondTrk);
405 groupOne.push_back(secondTrk);
406 groupTwo.push_back(firstTrk);
410 if (!(groupOne.size() >= 2 && groupTwo.size() >= 2))
417 float sumPt = 0, sumPt1 = 0, sumPt2 = 0, avgSumPt = 0;
420 std::vector<reco::TransientTrack> groupOne_ttks;
421 groupOne_ttks.clear();
422 for (
auto itrk = groupOne.cbegin(); itrk != groupOne.cend(); itrk++) {
424 groupOne_ttks.push_back(tmpTransientTrack);
425 sumPt1 += itrk->pt();
436 std::vector<reco::TransientTrack> groupTwo_ttks;
437 groupTwo_ttks.clear();
438 for (
auto itrk = groupTwo.cbegin(); itrk != groupTwo.cend(); itrk++) {
440 groupTwo_ttks.push_back(tmpTransientTrack);
441 sumPt2 += itrk->pt();
446 avgSumPt = (sumPt1 + sumPt2) / 2.;
472 int half_trks = twoPV.
nTracks();
474 const double invSqrt2 = 1. /
std::sqrt(2.);
476 double deltaX = (twoPV.
x() - onePV.
x());
477 double deltaY = (twoPV.
y() - onePV.
y());
478 double deltaZ = (twoPV.
z() - onePV.
z());
480 double resX = deltaX * invSqrt2;
481 double resY = deltaY * invSqrt2;
482 double resZ = deltaZ * invSqrt2;
502 for (
int ipTBin = 0; ipTBin <
nPtBins_; ipTBin++) {
506 if (avgSumPt >= pTF && avgSumPt < pTL) {
519 for (
int inTrackBin = 0; inTrackBin <
nTrackBins_; inTrackBin++) {
523 if (ntrks >= nTrackF && ntrks < nTrackL) {
536 for (
int inVtxBin = 0; inVtxBin <
nVtxBins_; inVtxBin++) {
543 if (nOfflineVtx == inVtxBin) {
560 h_PVCL_subVtx1->Fill(TMath::Prob(pvOne.totalChiSquared(), (
int)(pvOne.degreesOfFreedom())));
561 h_PVCL_subVtx2->Fill(TMath::Prob(pvTwo.totalChiSquared(), (
int)(pvTwo.degreesOfFreedom())));
596 thePV.
CL_subVtx1 = TMath::Prob(pvOne.totalChiSquared(), (
int)(pvOne.degreesOfFreedom()));
597 thePV.
CL_subVtx2 = TMath::Prob(pvTwo.totalChiSquared(), (
int)(pvTwo.degreesOfFreedom()));
622 unsigned int RunNumber_ =
run.run();
628 const time_t start_time = times.first / 1000000;
630 << RunNumber_ <<
" has start time: " << times.first <<
" - " << times.second << std::endl;
632 <<
"human readable time: " << std::asctime(std::gmtime(&start_time)) << std::endl;
646 EventFeatures.
make<TH1F>(
"h_lumiFromConfig",
"luminosity from config;;luminosity of present run", 1, -0.5, 0.5);
650 "run number from config;;run number (from configuration)",
661 edm::LogError(
"SplitVertexResolution") <<
" Warning - the vector of pT bins is not ordered " << std::endl;
665 edm::LogError(
"SplitVertexResolution") <<
" Warning -the vector of n. tracks bins is not ordered " << std::endl;
669 edm::LogError(
"SplitVertexResolution") <<
" Warning -the vector of n. vertices bins is not ordered " << std::endl;
729 h_runNumber =
outfile_->
make<TH1F>(
"h_runNumber",
"run number;run number;n_{events}", 100000, 250000., 350000.);
734 outfile_->
make<TH1I>(
"h_nRealVertices",
"n. of non-fake vertices;n. vertices; events", 100, 0, 100);
736 outfile_->
make<TH1I>(
"h_nSelectedVertices",
"n. of selected vertices vertices;n. vertices; events", 100, 0, 100);
739 "h_diffX",
"x-coordinate vertex resolution;vertex resolution (x) [#mum];vertices", 100, -300, 300.);
741 "h_diffY",
"y-coordinate vertex resolution;vertex resolution (y) [#mum];vertices", 100, -300, 300.);
743 "h_diffZ",
"z-coordinate vertex resolution;vertex resolution (z) [#mum];vertices", 100, -500, 500.);
746 "h_OrigVertexErrX",
"x-coordinate vertex error;vertex error (x) [#mum];vertices", 300, 0., 300.);
748 "h_OrigVertexErrY",
"y-coordinate vertex error;vertex error (y) [#mum];vertices", 300, 0., 300.);
750 "h_OrigVertexErrZ",
"z-coordinate vertex error;vertex error (z) [#mum];vertices", 500, 0., 500.);
753 "h_errX",
"x-coordinate vertex resolution error;vertex resoltuion error (x) [#mum];vertices", 300, 0., 300.);
755 "h_errY",
"y-coordinate vertex resolution error;vertex resolution error (y) [#mum];vertices", 300, 0., 300.);
757 "h_errZ",
"z-coordinate vertex resolution error;vertex resolution error (z) [#mum];vertices", 500, 0., 500.);
759 h_pullX =
outfile_->
make<TH1F>(
"h_pullX",
"x-coordinate vertex pull;vertex pull (x);vertices", 500, -10, 10.);
760 h_pullY =
outfile_->
make<TH1F>(
"h_pullY",
"y-coordinate vertex pull;vertex pull (y);vertices", 500, -10, 10.);
761 h_pullZ =
outfile_->
make<TH1F>(
"h_pullZ",
"z-coordinate vertex pull;vertex pull (z);vertices", 500, -10, 10.);
764 "number of tracks in vertex;vertex multeplicity;vertices",
772 "h_avgSumPt",
"#LT #Sigma p_{T} #GT;#LT #sum p_{T} #GT [GeV];vertices",
mypT_bins_.size() - 1,
mypT_bins_.data());
775 "#Sigma p_{T} sub-vertex 1;#sum p_{T} sub-vertex 1 [GeV];subvertices",
779 "#Sigma p_{T} sub-vertex 2;#sum p_{T} sub-vertex 2 [GeV];subvertices",
783 h_wTrks1 =
outfile_->
make<TH1F>(
"h_wTrks1",
"weight of track for sub-vertex 1;track weight;subvertices", 500, 0., 1.);
784 h_wTrks2 =
outfile_->
make<TH1F>(
"h_wTrks2",
"weithg of track for sub-vertex 2;track weight;subvertices", 500, 0., 1.);
787 "h_minWTrks1",
"minimum weight of track for sub-vertex 1;minimum track weight;subvertices", 500, 0., 1.);
789 "h_minWTrks2",
"minimum weithg of track for sub-vertex 2;minimum track weight;subvertices", 500, 0., 1.);
793 "#chi^{2} probability for sub-vertex 1;Prob(#chi^{2},ndof) for sub-vertex 1;subvertices",
799 "#chi^{2} probability for sub-vertex 2;Prob(#chi^{2},ndof) for sub-vertex 2;subvertices",
807 "x-resolution vs #Sigma p_{T};#sum p_{T}; x vertex resolution [#mum]",
811 "y-resolution vs #Sigma p_{T};#sum p_{T}; y vertex resolution [#mum]",
815 "z-resolution vs #Sigma p_{T};#sum p_{T}; z vertex resolution [#mum]",
820 "x-resolution vs n_{tracks};n_{tracks}; x vertex resolution [#mum]",
824 "y-resolution vs n_{tracks};n_{tracks}; y vertex resolution [#mum]",
828 "z-resolution vs n_{tracks};n_{tracks}; z vertex resolution [#mum]",
833 "x-resolution vs n_{vertices};n_{vertices}; x vertex resolution [#mum]",
837 "y-resolution vs n_{vertices};n_{vertices}; y vertex resolution [#mum]",
841 "z-resolution vs n_{vertices};n_{vertices}; z vertex resolution [#mum]",
848 "p_pullX_vsSumPt",
"x-pull vs #Sigma p_{T};#sum p_{T}; x vertex pull",
mypT_bins_.size() - 1,
mypT_bins_.data());
850 "p_pullY_vsSumPt",
"y-pull vs #Sigma p_{T};#sum p_{T}; y vertex pull",
mypT_bins_.size() - 1,
mypT_bins_.data());
852 "p_pullZ_vsSumPt",
"z-pull vs #Sigma p_{T};#sum p_{T}; z vertex pull",
mypT_bins_.size() - 1,
mypT_bins_.data());
855 "x-pull vs n_{tracks};n_{tracks}; x vertex pull",
859 "y-pull vs n_{tracks};n_{tracks}; y vertex pull",
863 "z-pull vs n_{tracks};n_{tracks}; z vertex pull",
868 "x-pull vs n_{vertices};n_{vertices}; x vertex pull",
872 "y-pull vs n_{vertices};n_{vertices}; y vertex pull",
876 "z-pull vs n_{vertices};n_{vertices}; z vertex pull",
888 unsigned int theNOfBins,
891 TH1F::SetDefaultSumw2(kTRUE);
896 if (resType.Contains(
"pull")) {
901 std::vector<TH1F*>
h;
902 h.reserve(theNOfBins);
904 const char* auxResType = (resType.ReplaceAll(
"_",
"")).Data();
906 for (
unsigned int i = 0;
i < theNOfBins;
i++) {
907 TH1F* htemp =
dir.make<TH1F>(Form(
"histo_%s_%s_plot%i", resType.Data(),
varType.Data(),
i),
908 Form(
"%s vs %s - bin %i;%s;vertices", auxResType,
varType.Data(),
i, auxResType),
920 edm::LogVerbatim(
"SplitVertexResolution") <<
"*******************************" << std::endl;
923 edm::LogVerbatim(
"SplitVertexResolution") <<
"*******************************" << std::endl;
926 edm::LogVerbatim(
"SplitVertexResolution") <<
"firing triggers: " << nFiringTriggers << std::endl;
927 edm::LogVerbatim(
"SplitVertexResolution") <<
"*******************************" << std::endl;
930 "tksByTrigger",
"tracks by HLT path;;% of # traks", nFiringTriggers, -0.5, nFiringTriggers - 0.5);
932 "evtsByTrigger",
"events by HLT path;;% of # events", nFiringTriggers, -0.5, nFiringTriggers - 0.5);
938 double trkpercent = ((it->second).
second) * 100. / double(
itrks);
939 double evtpercent = ((it->second).
first) * 100. / double(
ievt);
942 <<
"HLT path: " << std::setw(60) << std::left << it->first <<
" | events firing: " << std::right << std::setw(8)
943 << (it->second).
first <<
" (" << std::setw(8) <<
std::fixed << std::setprecision(4) << evtpercent <<
"%)"
944 <<
" | tracks collected: " << std::setw(8) << (it->second).
second <<
" (" << std::setw(8) <<
std::fixed
945 << std::setprecision(4) << trkpercent <<
"%)";
960 unsigned int count = 1;
1016 edm::LogInfo(
"SplitVertexResolution") << runInfo.m_start_time_str <<
" " << runInfo.m_stop_time_str << std::endl;
1018 return std::make_pair(runInfo.m_start_time_ll, runInfo.m_stop_time_ll);
1025 for (
auto iterator =
h.begin(); iterator !=
h.end(); iterator++) {
1031 float mean_ = myFit.first.value();
1032 float meanErr_ = myFit.first.error();
1033 trendPlot->SetBinContent(
bin, mean_);
1034 trendPlot->SetBinError(
bin, meanErr_);
1038 float width_ = myFit.second.value();
1039 float widthErr_ = myFit.second.error();
1040 trendPlot->SetBinContent(
bin, width_);
1041 trendPlot->SetBinError(
bin, widthErr_);
1047 trendPlot->SetBinContent(
bin, median_);
1048 trendPlot->SetBinError(
bin, medianErr_);
1054 trendPlot->SetBinContent(
bin, mad_);
1055 trendPlot->SetBinError(
bin, madErr_);
1060 <<
"fillTrendPlotByIndex() " << fitPar_ <<
" unknown estimator!" << std::endl;
1070 if (
hist->GetEntries() < 10) {
1071 LogDebug(
"SplitVertexResolution") <<
"hist name: " <<
hist->GetName() <<
" has less than 10 entries" << std::endl;
1075 float maxHist =
hist->GetXaxis()->GetXmax();
1076 float minHist =
hist->GetXaxis()->GetXmin();
1078 float sigma =
hist->GetRMS();
1080 if (TMath::IsNaN(
mean) || TMath::IsNaN(sigma)) {
1083 sigma = -minHist + maxHist;
1085 <<
"FitPVResiduals::fitResiduals(): histogram" <<
hist->GetName() <<
" mean or sigma are NaN!!" << std::endl;
1089 if (0 ==
hist->Fit(&
func,
"QNR")) {
1091 sigma =
func.GetParameter(2);
1098 if (0 ==
hist->Fit(&
func,
"Q0LR")) {
1099 if (
hist->GetFunction(
func.GetName())) {
1100 hist->GetFunction(
func.GetName())->ResetBit(TF1::kNotDraw);
1106 float res_mean =
func.GetParameter(1);
1107 float res_width =
func.GetParameter(2);
1109 float res_mean_err =
func.GetParError(1);
1110 float res_width_err =
func.GetParError(2);
1124 float sigma =
hist->GetRMS();
1127 if (0 ==
hist->Fit(&
func,
"QNR")) {
1129 sigma =
func.GetParameter(2);
1134 if (0 ==
hist->Fit(&
func,
"Q0LR")) {
1135 if (
hist->GetFunction(
func.GetName())) {
1136 hist->GetFunction(
func.GetName())->ResetBit(TF1::kNotDraw);
1141 float res_mean =
func.GetParameter(1);
1142 float res_width =
func.GetParameter(2);
1144 float res_mean_err =
func.GetParError(1);
1145 float res_width_err =
func.GetParError(2);
1155 template <std::
size_t SIZE>
1161 if (std::is_sorted(
bins.begin(),
bins.end())) {
1164 for (
const auto&
bin :
bins) {
1165 edm::LogInfo(
"SplitVertexResolution") <<
"bin: " <<
i <<
" : " <<
bin << std::endl;
1168 edm::LogInfo(
"SplitVertexResolution") <<
"--------------------------------" << std::endl;