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();
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();
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();
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 totalevents = 0.0;
415 double lumi_factor_per_bx = 0.0;
423 unsigned int total = (*it).second.numB.at(1) + (*it).second.numB.at(2) + (*it).second.numFP.at(0) +
424 (*it).second.numFP.at(1) + (*it).second.numFM.at(0) + (*it).second.numFM.at(1);
426 total += (*it).second.numB.at(0);
427 totalcounts +=
total;
429 ? (*it).second.dnumB.at(0)
430 : (*it).second.dnumB.at(1) + (*it).second.dnumB.at(2) + (*it).second.dnumFP.at(0) +
431 (*it).second.dnumFP.at(1) + (*it).second.dnumFM.at(0) + (*it).second.dnumFM.at(1);
432 etotal =
sqrt(etotal);
440 totalevents += events_per_bx;
441 double average_cluster_count = events_per_bx != 0 ? double(
total) / events_per_bx : 0.;
442 double average_cluster_count_unc = events_per_bx != 0 ? etotal / events_per_bx : 0.;
443 double pixel_bx_lumi_per_ls = lumi_factor_per_bx * average_cluster_count /
CM2_TO_NANOBARN;
444 double pixel_bx_lumi_per_ls_unc = 0.0;
446 pixel_bx_lumi_per_ls_unc =
sqrt(lumi_factor_per_bx * lumi_factor_per_bx *
447 (average_cluster_count_unc * average_cluster_count_unc +
452 pixel_bx_lumi_per_ls_unc =
sqrt(lumi_factor_per_bx * lumi_factor_per_bx *
453 (average_cluster_count_unc * average_cluster_count_unc +
471 nBClus[0] += (*it).second.numB.at(0);
472 nBClus[1] += (*it).second.numB.at(1);
473 nBClus[2] += (*it).second.numB.at(2);
474 nFPClus[0] += (*it).second.numFP.at(0);
475 nFPClus[1] += (*it).second.numFP.at(1);
476 nFMClus[0] += (*it).second.numFM.at(0);
477 nFMClus[1] += (*it).second.numFM.at(1);
480 (*it).second.Reset();
491 total_recorded_unc_square +=
err *
err;
498 if (totalevents > 10) {
499 total_recorded = lumi_factor_per_bx * totalcounts / totalevents /
CM2_TO_NANOBARN;
501 total_recorded = 0.0;
508 unsigned int all_detectors_counts = 0;
509 for (
unsigned int i = 0;
i < 3;
i++) {
510 all_detectors_counts += nBClus[
i];
512 for (
unsigned int i = 0;
i < 2;
i++) {
513 all_detectors_counts += nFPClus[
i];
515 for (
unsigned int i = 0;
i < 2;
i++) {
516 all_detectors_counts += nFMClus[
i];
521 for (
unsigned int i = 0;
i < 3;
i++) {
524 for (
unsigned int i = 0;
i < 2;
i++) {
527 for (
unsigned int i = 0;
i < 2;
i++) {
534 gettimeofday(&tv,
nullptr);
535 tm *ts = gmtime(&tv.tv_sec);
536 char datestring[256];
537 strftime(datestring,
sizeof(datestring),
"%Y.%m.%d %T GMT %s", ts);
539 logFile_ <<
"EndTimeOfFit " << datestring << std::endl;
540 logFile_ <<
"LumiRange " <<
ls <<
"-" <<
ls << std::endl;
541 logFile_ <<
"Fill " << -99 << std::endl;
544 logFile_ <<
"HFLumi " << -99 << std::endl;
545 logFile_ <<
"Ratio " << -99 << std::endl;
550 unsigned int nbins =
e->getNbinsX();
551 std::vector<float> ar(
nbins + 1, 0.);
552 for (
unsigned int i = 1;
i <=
nbins;
i++) {
553 ar[
i] =
e->getBinContent(
i);
560 unsigned int active_count = 0;
563 unsigned int non_empty_bins = 0;
565 for (
unsigned int i = 1;
i <=
nbins;
i++) {
575 ave /= non_empty_bins;
576 edm::LogWarning(
"pixelLumi") <<
"Bunch mask finder - non empty bins " << non_empty_bins
577 <<
" average of non empty bins " << ave <<
" max content of one bin " << maxc;
580 if (non_empty_bins < 50) {
584 TH1F dist(
"dist",
"dist", 500, 0., maxc + (maxc / 500.) * 20.);
585 for (
unsigned int i = 1;
i <=
nbins;
i++) {
589 TF1
fit(
"plgaus",
"gaus");
590 dist.Fit(&
fit,
"",
"", fmax(0., ave - (maxc - ave) / 5.), maxc);
591 mean =
fit.GetParameter(
"Mean");
592 sigma =
fit.GetParameter(
"Sigma");
597 for (
unsigned int i = 1;
i <=
nbins;
i++) {
604 edm::LogWarning(
"pixelLumi") <<
"Bunch mask finds " << active_count <<
" active bunch crossings ";
bool fIncludePixelQualCheckHistos
static constexpr double XSEC_PIXEL_CLUSTER
static constexpr double XSEC_PIXEL_CLUSTER_UNC
LuminosityBlockAuxiliary const & luminosityBlockAuxiliary() const final
unsigned int filledAndUnmaskedBunches
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
static const unsigned int lastBunchCrossing
virtual void setCurrentFolder(std::string const &fullpath)
std::vector< uint32_t > fDeadModules
int layerName() const
layer id
Geom::Phi< T > phi() const
static constexpr size_t kOffsetDisks
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
int fResetIntervalInLumiSections
data_type const * const_iterator
MonitorElement * fHistRecordedByBxCumulative
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
static std::string to_string(const XMLCh *ch)
const_iterator end(bool update=false) const
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * fHistClusByLS
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
static constexpr size_t kNumDisks
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
static constexpr double rXSEC_PIXEL_CLUSTER_UNC
void addDefault(ParameterSetDescription const &psetDescription)
MonitorElement * fHistnFMClusVsLS[2]
static constexpr double SECONDS_PER_LS
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > fPixelClusterLabel
unsigned int calculateBunchMask(MonitorElement *, std::vector< bool > &)
LuminosityBlockNumber_t luminosityBlock() const
MonitorElement * fHistClusterCountByBxLastLumi
Abs< T >::type abs(const T &t)
MonitorElement * fHistTotalRecordedLumiByLS
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
key
prepare the HTCondor submission files and eventually submit them
#define DEFINE_FWK_MODULE(type)
MonitorElement * fHistClusterCountByBxCumulative
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
MonitorElement * fHistnBClusVsLS[3]
const TrackerGeomDet * idToDet(DetId) const override
std::map< std::string, MonitorElement * > fHistContainerThisRun
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Log< level::Info, false > LogInfo
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
std::vector< bool > bunchTriggerMask
const_iterator begin(bool update=false) const
const Plane & surface() const
The nominal surface of the GeomDet.
bool fIncludePixelClusterInfo
static constexpr double rXSEC_PIXEL_CLUSTER
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * fHistBunchCrossings
MonitorElement * fHistBunchCrossingsLastLumi
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
std::string fLogFileName_
PixelLumiDQM(const edm::ParameterSet &)
static constexpr size_t kOffsetLayers
void analyze(const edm::Event &, const edm::EventSetup &) override
Pixel cluster – collection of neighboring pixels above threshold.
std::map< int, PixelClusterCount > fNumPixelClusters
MonitorElement * fHistRecordedByBxLastLumi
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
virtual double getBinError(int binx) const
get uncertainty on content of bin (1-D) - See TH1::GetBinError for details
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
MonitorElement * fHistnFPClusVsLS[2]
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
static constexpr double FREQ_ORBIT
static constexpr double CM2_TO_NANOBARN
virtual double getBinContent(int binx) const
get content of bin (1-D)
static constexpr size_t kNumLayers