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";
112 for (TrackerGeometry::DetContainer::const_iterator
i = trackerGeo->
dets().begin();
i != trackerGeo->
dets().end();
117 DetId detId = (*i)->geographicalId();
120 if (iSearch != pixelClusters->end()) {
123 size_t numClusters = 0;
131 assert(numClusters <= iSearch->
size());
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) {
201 if (iSearch != pixelClusters->end()) {
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;
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/";
306 std::stringstream
key;
307 key <<
"clusPosBarrel" <<
i;
308 std::stringstream
name;
309 name << key.str() <<
"_" << run.
run();
310 std::stringstream
title;
311 title <<
"Pixel cluster position - barrel layer " <<
i;
318 std::stringstream
key;
319 key <<
"clusPosEndCap" <<
i;
320 std::stringstream
name;
321 name << key.str() <<
"_" << run.
run();
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;
333 name << key.str() <<
"_" << run.
run();
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;
345 name << key.str() <<
"_" << run.
run();
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;
357 name << key.str() <<
"_" << run.
run();
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;
369 name << key.str() <<
"_" << run.
run();
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.);
411 printf(
"Lumi Block = %d\n", ls);
416 unsigned int nBClus[3] = {0, 0, 0};
417 unsigned int nFPClus[2] = {0, 0};
418 unsigned int nFMClus[2] = {0, 0};
420 double total_recorded = 0.;
421 double total_recorded_unc_square = 0.;
425 double totalcounts = 0.0;
426 double etotalcounts = 0.0;
427 double totalevents = 0.0;
428 double lumi_factor_per_bx = 0.0;
436 unsigned int total = (*it).second.numB.at(1) + (*it).second.numB.at(2) + (*it).second.numFP.at(0) +
437 (*it).second.numFP.at(1) + (*it).second.numFM.at(0) + (*it).second.numFM.at(1);
439 total += (*it).second.numB.at(0);
440 totalcounts +=
total;
441 double etotal = (*it).second.dnumB.at(1) + (*it).second.dnumB.at(2) + (*it).second.dnumFP.at(0) +
442 (*it).second.dnumFP.at(1) + (*it).second.dnumFM.at(0) + (*it).second.dnumFM.at(1);
444 etotal = (*it).second.dnumB.at(0);
445 etotalcounts += etotal;
446 etotal =
sqrt(etotal);
454 totalevents += events_per_bx;
455 double average_cluster_count = events_per_bx != 0 ? double(total) / events_per_bx : 0.;
456 double average_cluster_count_unc = events_per_bx != 0 ? etotal / events_per_bx : 0.;
457 double pixel_bx_lumi_per_ls = lumi_factor_per_bx * average_cluster_count /
CM2_TO_NANOBARN;
458 double pixel_bx_lumi_per_ls_unc = 0.0;
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 +
466 pixel_bx_lumi_per_ls_unc =
sqrt(lumi_factor_per_bx * lumi_factor_per_bx *
467 (average_cluster_count_unc * average_cluster_count_unc +
485 nBClus[0] += (*it).second.numB.at(0);
486 nBClus[1] += (*it).second.numB.at(1);
487 nBClus[2] += (*it).second.numB.at(2);
488 nFPClus[0] += (*it).second.numFP.at(0);
489 nFPClus[1] += (*it).second.numFP.at(1);
490 nFMClus[0] += (*it).second.numFM.at(0);
491 nFMClus[1] += (*it).second.numFM.at(1);
494 (*it).second.Reset();
505 total_recorded_unc_square += err *
err;
512 if (totalevents > 10) {
513 total_recorded = lumi_factor_per_bx * totalcounts / totalevents /
CM2_TO_NANOBARN;
515 total_recorded = 0.0;
522 unsigned int all_detectors_counts = 0;
523 for (
unsigned int i = 0;
i < 3;
i++) {
524 all_detectors_counts += nBClus[
i];
526 for (
unsigned int i = 0;
i < 2;
i++) {
527 all_detectors_counts += nFPClus[
i];
529 for (
unsigned int i = 0;
i < 2;
i++) {
530 all_detectors_counts += nFMClus[
i];
535 for (
unsigned int i = 0;
i < 3;
i++) {
538 for (
unsigned int i = 0;
i < 2;
i++) {
541 for (
unsigned int i = 0;
i < 2;
i++) {
548 gettimeofday(&tv,
nullptr);
549 tm *ts = gmtime(&tv.tv_sec);
550 char datestring[256];
551 strftime(datestring,
sizeof(datestring),
"%Y.%m.%d %T GMT %s", ts);
553 logFile_ <<
"EndTimeOfFit " << datestring << std::endl;
554 logFile_ <<
"LumiRange " << ls <<
"-" << ls << std::endl;
555 logFile_ <<
"Fill " << -99 << std::endl;
558 logFile_ <<
"HFLumi " << -99 << std::endl;
559 logFile_ <<
"Ratio " << -99 << std::endl;
565 std::vector<float> ar(nbins, 0.);
566 for (
unsigned int i = 1;
i <=
nbins;
i++) {
574 unsigned int active_count = 0;
577 unsigned int non_empty_bins = 0;
579 for (
unsigned int i = 1;
i <=
nbins;
i++) {
589 ave /= non_empty_bins;
590 edm::LogWarning(
"pixelLumi") <<
"Bunch mask finder - non empty bins " << non_empty_bins
591 <<
" average of non empty bins " << ave <<
" max content of one bin " << maxc;
594 if (non_empty_bins < 50) {
598 TH1F dist(
"dist",
"dist", 500, 0., maxc + (maxc / 500.) * 20.);
599 for (
unsigned int i = 1;
i <=
nbins;
i++) {
603 TF1
fit(
"plgaus",
"gaus");
604 dist.Fit(&fit,
"",
"", fmax(0., ave - (maxc - ave) / 5.), maxc);
605 mean = fit.GetParameter(
"Mean");
606 sigma = fit.GetParameter(
"Sigma");
608 edm::LogWarning(
"pixelLumi") <<
"Bunch mask will use mean" << mean <<
" sigma " << sigma;
611 for (
unsigned int i = 1;
i <=
nbins;
i++) {
613 if (bin > 0. &&
std::abs(bin - mean) < 5. * (sigma)) {
618 edm::LogWarning(
"pixelLumi") <<
"Bunch mask finds " << active_count <<
" active bunch crossings ";
bool fIncludePixelQualCheckHistos
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
static double SECONDS_PER_LS
unsigned int filledAndUnmaskedBunches
const_iterator end(bool update=false) const
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
static const unsigned int lastBunchCrossing
std::vector< uint32_t > fDeadModules
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void setCurrentFolder(std::string const &fullpath)
static size_t kOffsetDisks
Geom::Phi< T > phi() const
virtual double getBinError(int binx) const
get uncertainty on content of bin (1-D) - See TH1::GetBinError for details
int bunchCrossing() const
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
const Plane & surface() const
The nominal surface of the GeomDet.
void dqmEndRun(edm::Run const &, edm::EventSetup const &) override
LuminosityBlockNumber_t luminosityBlock() const
MonitorElement * fHistClusByLS
virtual void Reset()
reset ME (ie. contents, errors, etc)
LuminosityBlockAuxiliary const & luminosityBlockAuxiliary() const override
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
#define DEFINE_FWK_MODULE(type)
void addDefault(ParameterSetDescription const &psetDescription)
virtual int getNbinsX() const
get # of bins in X-axis
MonitorElement * fHistnFMClusVsLS[2]
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > fPixelClusterLabel
unsigned int calculateBunchMask(MonitorElement *, std::vector< bool > &)
static double rXSEC_PIXEL_CLUSTER
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
MonitorElement * fHistClusterCountByBxLastLumi
Abs< T >::type abs(const T &t)
MonitorElement * fHistTotalRecordedLumiByLS
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
unsigned int unixTime() const
Time in seconds since January 1, 1970.
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
static double XSEC_PIXEL_CLUSTER_UNC
LuminosityBlock const & getLuminosityBlock() const
MonitorElement * fHistClusterCountByBxCumulative
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
MonitorElement * fHistnBClusVsLS[3]
virtual double getBinContent(int binx) const
get content of bin (1-D)
LuminosityBlockNumber_t luminosityBlock() const
std::map< std::string, MonitorElement * > fHistContainerThisRun
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
std::vector< bool > bunchTriggerMask
static double CM2_TO_NANOBARN
bool fIncludePixelClusterInfo
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
static double XSEC_PIXEL_CLUSTER
MonitorElement * fHistBunchCrossings
MonitorElement * fHistBunchCrossingsLastLumi
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
std::string fLogFileName_
PixelLumiDQM(const edm::ParameterSet &)
static double rXSEC_PIXEL_CLUSTER_UNC
void analyze(const edm::Event &, const edm::EventSetup &) override
Pixel cluster – collection of neighboring pixels above threshold.
std::map< int, PixelClusterCount > fNumPixelClusters
MonitorElement * fHistRecordedByBxLastLumi
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
const TrackerGeomDet * idToDet(DetId) const override
static size_t kOffsetLayers
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
MonitorElement * fHistnFPClusVsLS[2]
int layerName() const
layer id
edm::Timestamp time() const
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
const_iterator begin(bool update=false) const