51 fIncludePixelClusterInfo(iConfig.getUntrackedParameter<
bool>(
"includePixelClusterInfo",
true)),
52 fIncludePixelQualCheckHistos(iConfig.getUntrackedParameter<
bool>(
"includePixelQualCheckHistos",
true)),
53 fResetIntervalInLumiSections(iConfig.getUntrackedParameter<
int>(
"resetEveryNLumiSections", 1)),
54 fDeadModules(iConfig.getUntrackedParameter<
std::
vector<uint32_t>>(
"deadModules",
std::
vector<uint32_t>())),
55 fMinPixelsPerCluster(iConfig.getUntrackedParameter<
int>(
"minNumPixelsPerCluster", 0)),
56 fMinClusterCharge(iConfig.getUntrackedParameter<double>(
"minChargePerCluster", 0)),
57 bunchTriggerMask(lastBunchCrossing + 1,
false),
58 filledAndUnmaskedBunches(0),
59 useInnerBarrelLayer(iConfig.getUntrackedParameter<
bool>(
"useInnerBarrelLayer",
false)),
60 fLogFileName_(iConfig.getUntrackedParameter<
std::
string>(
"logFileName",
"/tmp/pixel_lumi.txt")) {
61 edm::LogInfo(
"Configuration") <<
"PixelLumiDQM looking for pixel clusters in '"
66 edm::LogInfo(
"Configuration") <<
"PixelLumiDQM storing pixel cluster quality check histograms? "
70 edm::LogInfo(
"Configuration") <<
"No pixel modules specified to be ignored";
93 fLSNo =
iEvent.getLuminosityBlock().luminosityBlock();
110 for (TrackerGeometry::DetContainer::const_iterator
i = trackerGeo->
dets().begin();
i != trackerGeo->
dets().end();
115 DetId detId = (*i)->geographicalId();
121 size_t numClusters = 0;
147 switch (halfCylinder) {
176 std::vector<uint32_t>::const_iterator deadModulesBegin =
fDeadModules.begin();
177 std::vector<uint32_t>::const_iterator deadModulesEnd =
fDeadModules.end();
180 for (TrackerGeometry::DetContainer::const_iterator
i = trackerGeo->
dets().begin();
i != trackerGeo->
dets().end();
184 DetId detId = (*i)->geographicalId();
187 if (filterDeadModules &&
find(deadModulesBegin, deadModulesEnd, detId()) != deadModulesEnd) {
200 double x = clus->x();
201 double y = clus->y();
204 double charge = clus->charge() / 1.e3;
205 int size = clus->size();
212 histName =
"clusPosBarrel" + std::to_string(
layer);
214 histName =
"clusChargeBarrel" + std::to_string(
layer);
216 histName =
"clusSizeBarrel" + std::to_string(
layer);
230 histName =
"clusPosEndCap" + std::to_string(disk);
232 histName =
"clusChargeEndCap" + std::to_string(disk);
234 histName =
"clusSizeEndCap" + std::to_string(disk);
238 <<
"higher disk number, " << disk <<
", than disks," <<
kNumDisks << std::endl;
252 edm::LogInfo(
"Status") <<
"Starting processing of run #" <<
run.id().run();
260 "Pixel Lumi in nb by BX Cumulative vs LS",
270 subfolder =
folder +
"ClusterCountingDetails/";
273 fHistnBClusVsLS[0] = ibooker.
book1D(
"nBClusVsLS_0",
"Fraction of Clusters vs LS Barrel layer 0", 8000, 0.5, 8000.5);
274 fHistnBClusVsLS[1] = ibooker.
book1D(
"nBClusVsLS_1",
"Fraction of Clusters vs LS Barrel layer 1", 8000, 0.5, 8000.5);
275 fHistnBClusVsLS[2] = ibooker.
book1D(
"nBClusVsLS_2",
"Fraction of Clusters vs LS Barrel layer 2", 8000, 0.5, 8000.5);
276 fHistnFPClusVsLS[0] = ibooker.
book1D(
"nFPClusVsLS_0",
"Fraction of Clusters vs LS Barrel layer 0", 8000, 0.5, 8000.5);
277 fHistnFPClusVsLS[1] = ibooker.
book1D(
"nFPClusVsLS_1",
"Fraction of Clusters vs LS Barrel layer 1", 8000, 0.5, 8000.5);
278 fHistnFMClusVsLS[0] = ibooker.
book1D(
"nFMClusVsLS_0",
"Fraction of Clusters vs LS Barrel layer 0", 8000, 0.5, 8000.5);
279 fHistnFMClusVsLS[1] = ibooker.
book1D(
"nFMClusVsLS_1",
"Fraction of Clusters vs LS Barrel layer 1", 8000, 0.5, 8000.5);
288 fHistClusByLS = ibooker.
book1D(
"totalClusByLS",
"Number of Clusters all dets vs LS", 8000, 0.5, 8000.5);
291 subfolder =
folder +
"qualityChecks/";
296 edm::LogInfo(
"Status") <<
"Creating histograms for run #" <<
run.id().run();
300 std::stringstream
key;
301 key <<
"clusPosBarrel" <<
i;
302 std::stringstream
name;
304 std::stringstream
title;
305 title <<
"Pixel cluster position - barrel layer " <<
i;
312 std::stringstream
key;
313 key <<
"clusPosEndCap" <<
i;
314 std::stringstream
name;
316 std::stringstream
title;
317 title <<
"Pixel cluster position - endcap disk " <<
i;
319 ibooker.
book2D(
name.str().c_str(),
title.str().c_str(), 100, -20., 20., 100, -20., 20.);
324 std::stringstream
key;
325 key <<
"clusChargeBarrel" <<
i;
326 std::stringstream
name;
328 std::stringstream
title;
329 title <<
"Pixel cluster charge - barrel layer " <<
i;
331 ibooker.
book2D(
name.str().c_str(),
title.str().c_str(), 3564, .5, 3564.5, 100, 0., 100.);
336 std::stringstream
key;
337 key <<
"clusChargeEndCap" <<
i;
338 std::stringstream
name;
340 std::stringstream
title;
341 title <<
"Pixel cluster charge - endcap disk " <<
i;
343 ibooker.
book2D(
name.str().c_str(),
title.str().c_str(), 3564, .5, 3564.5, 100, 0., 100.);
348 std::stringstream
key;
349 key <<
"clusSizeBarrel" <<
i;
350 std::stringstream
name;
352 std::stringstream
title;
353 title <<
"Pixel cluster size - barrel layer " <<
i;
355 ibooker.
book2D(
name.str().c_str(),
title.str().c_str(), 3564, .5, 3564.5, 100, 0., 100.);
360 std::stringstream
key;
361 key <<
"clusSizeEndCap" <<
i;
362 std::stringstream
name;
364 std::stringstream
title;
365 title <<
"Pixel cluster size - endcap disk " <<
i;
367 ibooker.
book2D(
name.str().c_str(),
title.str().c_str(), 3564, .5, 3564.5, 100, 0., 100.);
399 printf(
"Lumi Block = %d\n",
ls);
404 unsigned int nBClus[3] = {0, 0, 0};
405 unsigned int nFPClus[2] = {0, 0};
406 unsigned int nFMClus[2] = {0, 0};
408 double total_recorded = 0.;
409 double total_recorded_unc_square = 0.;
413 double totalcounts = 0.0;
414 double etotalcounts = 0.0;
415 double totalevents = 0.0;
416 double lumi_factor_per_bx = 0.0;
424 unsigned int total = (*it).second.numB.at(1) + (*it).second.numB.at(2) + (*it).second.numFP.at(0) +
425 (*it).second.numFP.at(1) + (*it).second.numFM.at(0) + (*it).second.numFM.at(1);
427 total += (*it).second.numB.at(0);
428 totalcounts +=
total;
429 double etotal = (*it).second.dnumB.at(1) + (*it).second.dnumB.at(2) + (*it).second.dnumFP.at(0) +
430 (*it).second.dnumFP.at(1) + (*it).second.dnumFM.at(0) + (*it).second.dnumFM.at(1);
432 etotal = (*it).second.dnumB.at(0);
433 etotalcounts += etotal;
434 etotal =
sqrt(etotal);
442 totalevents += events_per_bx;
443 double average_cluster_count = events_per_bx != 0 ? double(
total) / events_per_bx : 0.;
444 double average_cluster_count_unc = events_per_bx != 0 ? etotal / events_per_bx : 0.;
445 double pixel_bx_lumi_per_ls = lumi_factor_per_bx * average_cluster_count /
CM2_TO_NANOBARN;
446 double pixel_bx_lumi_per_ls_unc = 0.0;
448 pixel_bx_lumi_per_ls_unc =
sqrt(lumi_factor_per_bx * lumi_factor_per_bx *
449 (average_cluster_count_unc * average_cluster_count_unc +
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 +
473 nBClus[0] += (*it).second.numB.at(0);
474 nBClus[1] += (*it).second.numB.at(1);
475 nBClus[2] += (*it).second.numB.at(2);
476 nFPClus[0] += (*it).second.numFP.at(0);
477 nFPClus[1] += (*it).second.numFP.at(1);
478 nFMClus[0] += (*it).second.numFM.at(0);
479 nFMClus[1] += (*it).second.numFM.at(1);
482 (*it).second.Reset();
493 total_recorded_unc_square +=
err *
err;
500 if (totalevents > 10) {
501 total_recorded = lumi_factor_per_bx * totalcounts / totalevents /
CM2_TO_NANOBARN;
503 total_recorded = 0.0;
510 unsigned int all_detectors_counts = 0;
511 for (
unsigned int i = 0;
i < 3;
i++) {
512 all_detectors_counts += nBClus[
i];
514 for (
unsigned int i = 0;
i < 2;
i++) {
515 all_detectors_counts += nFPClus[
i];
517 for (
unsigned int i = 0;
i < 2;
i++) {
518 all_detectors_counts += nFMClus[
i];
523 for (
unsigned int i = 0;
i < 3;
i++) {
526 for (
unsigned int i = 0;
i < 2;
i++) {
529 for (
unsigned int i = 0;
i < 2;
i++) {
536 gettimeofday(&tv,
nullptr);
537 tm *ts = gmtime(&tv.tv_sec);
538 char datestring[256];
539 strftime(datestring,
sizeof(datestring),
"%Y.%m.%d %T GMT %s", ts);
541 logFile_ <<
"EndTimeOfFit " << datestring << std::endl;
542 logFile_ <<
"LumiRange " <<
ls <<
"-" <<
ls << std::endl;
543 logFile_ <<
"Fill " << -99 << std::endl;
546 logFile_ <<
"HFLumi " << -99 << std::endl;
547 logFile_ <<
"Ratio " << -99 << std::endl;
552 unsigned int nbins =
e->getNbinsX();
553 std::vector<float> ar(
nbins, 0.);
554 for (
unsigned int i = 1;
i <=
nbins;
i++) {
555 ar[
i] =
e->getBinContent(
i);
562 unsigned int active_count = 0;
565 unsigned int non_empty_bins = 0;
567 for (
unsigned int i = 1;
i <=
nbins;
i++) {
577 ave /= non_empty_bins;
578 edm::LogWarning(
"pixelLumi") <<
"Bunch mask finder - non empty bins " << non_empty_bins
579 <<
" average of non empty bins " << ave <<
" max content of one bin " << maxc;
582 if (non_empty_bins < 50) {
586 TH1F dist(
"dist",
"dist", 500, 0., maxc + (maxc / 500.) * 20.);
587 for (
unsigned int i = 1;
i <=
nbins;
i++) {
591 TF1
fit(
"plgaus",
"gaus");
592 dist.Fit(&
fit,
"",
"", fmax(0., ave - (maxc - ave) / 5.), maxc);
593 mean =
fit.GetParameter(
"Mean");
594 sigma =
fit.GetParameter(
"Sigma");
599 for (
unsigned int i = 1;
i <=
nbins;
i++) {
606 edm::LogWarning(
"pixelLumi") <<
"Bunch mask finds " << active_count <<
" active bunch crossings ";