50 fIncludePixelClusterInfo(iConfig.getUntrackedParameter<
bool>(
"includePixelClusterInfo",
true)),
51 fIncludePixelQualCheckHistos(iConfig.getUntrackedParameter<
bool>(
"includePixelQualCheckHistos",
true)),
52 fResetIntervalInLumiSections(iConfig.getUntrackedParameter<
int>(
"resetEveryNLumiSections", 1)),
53 fDeadModules(iConfig.getUntrackedParameter<
std::
vector<uint32_t>>(
"deadModules",
std::
vector<uint32_t>())),
54 fMinPixelsPerCluster(iConfig.getUntrackedParameter<
int>(
"minNumPixelsPerCluster", 0)),
55 fMinClusterCharge(iConfig.getUntrackedParameter<double>(
"minChargePerCluster", 0)),
56 bunchTriggerMask(lastBunchCrossing + 1,
false),
57 filledAndUnmaskedBunches(0),
58 useInnerBarrelLayer(iConfig.getUntrackedParameter<
bool>(
"useInnerBarrelLayer",
false)),
59 fLogFileName_(iConfig.getUntrackedParameter<
std::
string>(
"logFileName",
"/tmp/pixel_lumi.txt")) {
60 edm::LogInfo(
"Configuration") <<
"PixelLumiDQM looking for pixel clusters in '"
65 edm::LogInfo(
"Configuration") <<
"PixelLumiDQM storing pixel cluster quality check histograms? "
69 edm::LogInfo(
"Configuration") <<
"No pixel modules specified to be ignored";
92 fLSNo =
iEvent.getLuminosityBlock().luminosityBlock();
112 for (TrackerGeometry::DetContainer::const_iterator
i = trackerGeo->
dets().begin();
i != trackerGeo->
dets().end();
117 DetId detId = (*i)->geographicalId();
123 size_t numClusters = 0;
149 switch (halfCylinder) {
182 std::vector<uint32_t>::const_iterator deadModulesBegin =
fDeadModules.begin();
183 std::vector<uint32_t>::const_iterator deadModulesEnd =
fDeadModules.end();
186 for (TrackerGeometry::DetContainer::const_iterator
i = trackerGeo->
dets().begin();
i != trackerGeo->
dets().end();
190 DetId detId = (*i)->geographicalId();
193 if (filterDeadModules &&
find(deadModulesBegin, deadModulesEnd, detId()) != deadModulesEnd) {
206 double x = clus->x();
207 double y = clus->y();
210 double charge = clus->charge() / 1.e3;
211 int size = clus->size();
218 histName =
"clusPosBarrel" + std::to_string(layer);
220 histName =
"clusChargeBarrel" + std::to_string(layer);
222 histName =
"clusSizeBarrel" + std::to_string(layer);
225 edm::LogWarning(
"pixelLumi") <<
"higher layer number, " << layer <<
", than layers";
236 histName =
"clusPosEndCap" + std::to_string(disk);
238 histName =
"clusChargeEndCap" + std::to_string(disk);
240 histName =
"clusSizeEndCap" + std::to_string(disk);
244 <<
"higher disk number, " << disk <<
", than disks," <<
kNumDisks << std::endl;
258 edm::LogInfo(
"Status") <<
"Starting processing of run #" <<
run.id().run();
266 "Pixel Lumi in nb by BX Cumulative vs LS",
276 subfolder =
folder +
"ClusterCountingDetails/";
279 fHistnBClusVsLS[0] = ibooker.
book1D(
"nBClusVsLS_0",
"Fraction of Clusters vs LS Barrel layer 0", 8000, 0.5, 8000.5);
280 fHistnBClusVsLS[1] = ibooker.
book1D(
"nBClusVsLS_1",
"Fraction of Clusters vs LS Barrel layer 1", 8000, 0.5, 8000.5);
281 fHistnBClusVsLS[2] = ibooker.
book1D(
"nBClusVsLS_2",
"Fraction of Clusters vs LS Barrel layer 2", 8000, 0.5, 8000.5);
282 fHistnFPClusVsLS[0] = ibooker.
book1D(
"nFPClusVsLS_0",
"Fraction of Clusters vs LS Barrel layer 0", 8000, 0.5, 8000.5);
283 fHistnFPClusVsLS[1] = ibooker.
book1D(
"nFPClusVsLS_1",
"Fraction of Clusters vs LS Barrel layer 1", 8000, 0.5, 8000.5);
284 fHistnFMClusVsLS[0] = ibooker.
book1D(
"nFMClusVsLS_0",
"Fraction of Clusters vs LS Barrel layer 0", 8000, 0.5, 8000.5);
285 fHistnFMClusVsLS[1] = ibooker.
book1D(
"nFMClusVsLS_1",
"Fraction of Clusters vs LS Barrel layer 1", 8000, 0.5, 8000.5);
294 fHistClusByLS = ibooker.
book1D(
"totalClusByLS",
"Number of Clusters all dets vs LS", 8000, 0.5, 8000.5);
297 subfolder =
folder +
"qualityChecks/";
302 edm::LogInfo(
"Status") <<
"Creating histograms for run #" <<
run.id().run();
306 std::stringstream
key;
307 key <<
"clusPosBarrel" <<
i;
308 std::stringstream
name;
310 std::stringstream
title;
311 title <<
"Pixel cluster position - barrel layer " <<
i;
318 std::stringstream
key;
319 key <<
"clusPosEndCap" <<
i;
320 std::stringstream
name;
322 std::stringstream
title;
323 title <<
"Pixel cluster position - endcap disk " <<
i;
325 ibooker.
book2D(
name.str().c_str(),
title.str().c_str(), 100, -20., 20., 100, -20., 20.);
330 std::stringstream
key;
331 key <<
"clusChargeBarrel" <<
i;
332 std::stringstream
name;
334 std::stringstream
title;
335 title <<
"Pixel cluster charge - barrel layer " <<
i;
337 ibooker.
book2D(
name.str().c_str(),
title.str().c_str(), 3564, .5, 3564.5, 100, 0., 100.);
342 std::stringstream
key;
343 key <<
"clusChargeEndCap" <<
i;
344 std::stringstream
name;
346 std::stringstream
title;
347 title <<
"Pixel cluster charge - endcap disk " <<
i;
349 ibooker.
book2D(
name.str().c_str(),
title.str().c_str(), 3564, .5, 3564.5, 100, 0., 100.);
354 std::stringstream
key;
355 key <<
"clusSizeBarrel" <<
i;
356 std::stringstream
name;
358 std::stringstream
title;
359 title <<
"Pixel cluster size - barrel layer " <<
i;
361 ibooker.
book2D(
name.str().c_str(),
title.str().c_str(), 3564, .5, 3564.5, 100, 0., 100.);
366 std::stringstream
key;
367 key <<
"clusSizeEndCap" <<
i;
368 std::stringstream
name;
370 std::stringstream
title;
371 title <<
"Pixel cluster size - endcap disk " <<
i;
373 ibooker.
book2D(
name.str().c_str(),
title.str().c_str(), 3564, .5, 3564.5, 100, 0., 100.);
405 printf(
"Lumi Block = %d\n",
ls);
410 unsigned int nBClus[3] = {0, 0, 0};
411 unsigned int nFPClus[2] = {0, 0};
412 unsigned int nFMClus[2] = {0, 0};
414 double total_recorded = 0.;
415 double total_recorded_unc_square = 0.;
419 double totalcounts = 0.0;
420 double etotalcounts = 0.0;
421 double totalevents = 0.0;
422 double lumi_factor_per_bx = 0.0;
430 unsigned int total = (*it).second.numB.at(1) + (*it).second.numB.at(2) + (*it).second.numFP.at(0) +
431 (*it).second.numFP.at(1) + (*it).second.numFM.at(0) + (*it).second.numFM.at(1);
433 total += (*it).second.numB.at(0);
434 totalcounts +=
total;
435 double etotal = (*it).second.dnumB.at(1) + (*it).second.dnumB.at(2) + (*it).second.dnumFP.at(0) +
436 (*it).second.dnumFP.at(1) + (*it).second.dnumFM.at(0) + (*it).second.dnumFM.at(1);
438 etotal = (*it).second.dnumB.at(0);
439 etotalcounts += etotal;
440 etotal =
sqrt(etotal);
448 totalevents += events_per_bx;
449 double average_cluster_count = events_per_bx != 0 ? double(
total) / events_per_bx : 0.;
450 double average_cluster_count_unc = events_per_bx != 0 ? etotal / events_per_bx : 0.;
451 double pixel_bx_lumi_per_ls = lumi_factor_per_bx * average_cluster_count /
CM2_TO_NANOBARN;
452 double pixel_bx_lumi_per_ls_unc = 0.0;
454 pixel_bx_lumi_per_ls_unc =
sqrt(lumi_factor_per_bx * lumi_factor_per_bx *
455 (average_cluster_count_unc * average_cluster_count_unc +
460 pixel_bx_lumi_per_ls_unc =
sqrt(lumi_factor_per_bx * lumi_factor_per_bx *
461 (average_cluster_count_unc * average_cluster_count_unc +
479 nBClus[0] += (*it).second.numB.at(0);
480 nBClus[1] += (*it).second.numB.at(1);
481 nBClus[2] += (*it).second.numB.at(2);
482 nFPClus[0] += (*it).second.numFP.at(0);
483 nFPClus[1] += (*it).second.numFP.at(1);
484 nFMClus[0] += (*it).second.numFM.at(0);
485 nFMClus[1] += (*it).second.numFM.at(1);
488 (*it).second.Reset();
499 total_recorded_unc_square +=
err *
err;
506 if (totalevents > 10) {
507 total_recorded = lumi_factor_per_bx * totalcounts / totalevents /
CM2_TO_NANOBARN;
509 total_recorded = 0.0;
516 unsigned int all_detectors_counts = 0;
517 for (
unsigned int i = 0;
i < 3;
i++) {
518 all_detectors_counts += nBClus[
i];
520 for (
unsigned int i = 0;
i < 2;
i++) {
521 all_detectors_counts += nFPClus[
i];
523 for (
unsigned int i = 0;
i < 2;
i++) {
524 all_detectors_counts += nFMClus[
i];
529 for (
unsigned int i = 0;
i < 3;
i++) {
532 for (
unsigned int i = 0;
i < 2;
i++) {
535 for (
unsigned int i = 0;
i < 2;
i++) {
542 gettimeofday(&tv,
nullptr);
543 tm *ts = gmtime(&tv.tv_sec);
544 char datestring[256];
545 strftime(datestring,
sizeof(datestring),
"%Y.%m.%d %T GMT %s", ts);
547 logFile_ <<
"EndTimeOfFit " << datestring << std::endl;
548 logFile_ <<
"LumiRange " <<
ls <<
"-" <<
ls << std::endl;
549 logFile_ <<
"Fill " << -99 << std::endl;
552 logFile_ <<
"HFLumi " << -99 << std::endl;
553 logFile_ <<
"Ratio " << -99 << std::endl;
558 unsigned int nbins =
e->getNbinsX();
559 std::vector<float> ar(
nbins, 0.);
560 for (
unsigned int i = 1;
i <=
nbins;
i++) {
561 ar[
i] =
e->getBinContent(
i);
568 unsigned int active_count = 0;
571 unsigned int non_empty_bins = 0;
573 for (
unsigned int i = 1;
i <=
nbins;
i++) {
583 ave /= non_empty_bins;
584 edm::LogWarning(
"pixelLumi") <<
"Bunch mask finder - non empty bins " << non_empty_bins
585 <<
" average of non empty bins " << ave <<
" max content of one bin " << maxc;
588 if (non_empty_bins < 50) {
592 TH1F dist(
"dist",
"dist", 500, 0., maxc + (maxc / 500.) * 20.);
593 for (
unsigned int i = 1;
i <=
nbins;
i++) {
597 TF1 fit(
"plgaus",
"gaus");
598 dist.Fit(&
fit,
"",
"", fmax(0., ave - (maxc - ave) / 5.), maxc);
599 mean =
fit.GetParameter(
"Mean");
600 sigma =
fit.GetParameter(
"Sigma");
605 for (
unsigned int i = 1;
i <=
nbins;
i++) {
612 edm::LogWarning(
"pixelLumi") <<
"Bunch mask finds " << active_count <<
" active bunch crossings ";