50 iConfig.getUntrackedParameter<
edm::InputTag>(
"pixelClusterLabel",
edm::InputTag(
"siPixelClusters")))),
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";
113 for (TrackerGeometry::DetContainer::const_iterator
i = trackerGeo->
dets().begin();
i != trackerGeo->
dets().end();
118 DetId detId = (*i)->geographicalId();
121 if (iSearch != pixelClusters->end()) {
124 size_t numClusters = 0;
132 assert(numClusters <= iSearch->
size());
150 switch (halfCylinder) {
183 std::vector<uint32_t>::const_iterator deadModulesBegin =
fDeadModules.begin();
184 std::vector<uint32_t>::const_iterator deadModulesEnd =
fDeadModules.end();
187 for (TrackerGeometry::DetContainer::const_iterator
i = trackerGeo->
dets().begin();
i != trackerGeo->
dets().end();
191 DetId detId = (*i)->geographicalId();
194 if (filterDeadModules &&
find(deadModulesBegin, deadModulesEnd, detId()) != deadModulesEnd) {
202 if (iSearch != pixelClusters->end()) {
207 double x = clus->x();
208 double y = clus->y();
211 double charge = clus->charge() / 1.e3;
212 int size = clus->size();
219 histName =
"clusPosBarrel" + std::to_string(layer);
221 histName =
"clusChargeBarrel" + std::to_string(layer);
223 histName =
"clusSizeBarrel" + std::to_string(layer);
226 edm::LogWarning(
"pixelLumi") <<
"higher layer number, " << layer <<
", than layers";
237 histName =
"clusPosEndCap" + std::to_string(disk);
239 histName =
"clusChargeEndCap" + std::to_string(disk);
241 histName =
"clusSizeEndCap" + std::to_string(disk);
245 <<
"higher disk number, " << disk <<
", than disks," <<
kNumDisks << std::endl;
267 "Pixel Lumi in nb by BX Cumulative vs LS",
277 subfolder = folder +
"ClusterCountingDetails/";
280 fHistnBClusVsLS[0] = ibooker.
book1D(
"nBClusVsLS_0",
"Fraction of Clusters vs LS Barrel layer 0", 8000, 0.5, 8000.5);
281 fHistnBClusVsLS[1] = ibooker.
book1D(
"nBClusVsLS_1",
"Fraction of Clusters vs LS Barrel layer 1", 8000, 0.5, 8000.5);
282 fHistnBClusVsLS[2] = ibooker.
book1D(
"nBClusVsLS_2",
"Fraction of Clusters vs LS Barrel layer 2", 8000, 0.5, 8000.5);
283 fHistnFPClusVsLS[0] = ibooker.
book1D(
"nFPClusVsLS_0",
"Fraction of Clusters vs LS Barrel layer 0", 8000, 0.5, 8000.5);
284 fHistnFPClusVsLS[1] = ibooker.
book1D(
"nFPClusVsLS_1",
"Fraction of Clusters vs LS Barrel layer 1", 8000, 0.5, 8000.5);
285 fHistnFMClusVsLS[0] = ibooker.
book1D(
"nFMClusVsLS_0",
"Fraction of Clusters vs LS Barrel layer 0", 8000, 0.5, 8000.5);
286 fHistnFMClusVsLS[1] = ibooker.
book1D(
"nFMClusVsLS_1",
"Fraction of Clusters vs LS Barrel layer 1", 8000, 0.5, 8000.5);
295 fHistClusByLS = ibooker.
book1D(
"totalClusByLS",
"Number of Clusters all dets vs LS", 8000, 0.5, 8000.5);
298 subfolder = folder +
"qualityChecks/";
307 std::stringstream
key;
308 key <<
"clusPosBarrel" <<
i;
309 std::stringstream
name;
310 name << key.str() <<
"_" << run.
run();
311 std::stringstream
title;
312 title <<
"Pixel cluster position - barrel layer " <<
i;
319 std::stringstream
key;
320 key <<
"clusPosEndCap" <<
i;
321 std::stringstream
name;
322 name << key.str() <<
"_" << run.
run();
323 std::stringstream
title;
324 title <<
"Pixel cluster position - endcap disk " <<
i;
326 ibooker.
book2D(name.str().c_str(), title.str().c_str(), 100, -20., 20., 100, -20., 20.);
331 std::stringstream
key;
332 key <<
"clusChargeBarrel" <<
i;
333 std::stringstream
name;
334 name << key.str() <<
"_" << run.
run();
335 std::stringstream
title;
336 title <<
"Pixel cluster charge - barrel layer " <<
i;
338 ibooker.
book2D(name.str().c_str(), title.str().c_str(), 3564, .5, 3564.5, 100, 0., 100.);
343 std::stringstream
key;
344 key <<
"clusChargeEndCap" <<
i;
345 std::stringstream
name;
346 name << key.str() <<
"_" << run.
run();
347 std::stringstream
title;
348 title <<
"Pixel cluster charge - endcap disk " <<
i;
350 ibooker.
book2D(name.str().c_str(), title.str().c_str(), 3564, .5, 3564.5, 100, 0., 100.);
355 std::stringstream
key;
356 key <<
"clusSizeBarrel" <<
i;
357 std::stringstream
name;
358 name << key.str() <<
"_" << run.
run();
359 std::stringstream
title;
360 title <<
"Pixel cluster size - barrel layer " <<
i;
362 ibooker.
book2D(name.str().c_str(), title.str().c_str(), 3564, .5, 3564.5, 100, 0., 100.);
367 std::stringstream
key;
368 key <<
"clusSizeEndCap" <<
i;
369 std::stringstream
name;
370 name << key.str() <<
"_" << run.
run();
371 std::stringstream
title;
372 title <<
"Pixel cluster size - endcap disk " <<
i;
374 ibooker.
book2D(name.str().c_str(), title.str().c_str(), 3564, .5, 3564.5, 100, 0., 100.);
412 printf(
"Lumi Block = %d\n", ls);
417 unsigned int nBClus[3] = {0, 0, 0};
418 unsigned int nFPClus[2] = {0, 0};
419 unsigned int nFMClus[2] = {0, 0};
421 double total_recorded = 0.;
422 double total_recorded_unc_square = 0.;
426 double totalcounts = 0.0;
427 double etotalcounts = 0.0;
428 double totalevents = 0.0;
429 double lumi_factor_per_bx = 0.0;
437 unsigned int total = (*it).second.numB.at(1) + (*it).second.numB.at(2) + (*it).second.numFP.at(0) +
438 (*it).second.numFP.at(1) + (*it).second.numFM.at(0) + (*it).second.numFM.at(1);
440 total += (*it).second.numB.at(0);
441 totalcounts +=
total;
442 double etotal = (*it).second.dnumB.at(1) + (*it).second.dnumB.at(2) + (*it).second.dnumFP.at(0) +
443 (*it).second.dnumFP.at(1) + (*it).second.dnumFM.at(0) + (*it).second.dnumFM.at(1);
445 etotal = (*it).second.dnumB.at(0);
446 etotalcounts += etotal;
447 etotal =
sqrt(etotal);
455 totalevents += events_per_bx;
456 double average_cluster_count = events_per_bx != 0 ? double(total) / events_per_bx : 0.;
457 double average_cluster_count_unc = events_per_bx != 0 ? etotal / events_per_bx : 0.;
458 double pixel_bx_lumi_per_ls = lumi_factor_per_bx * average_cluster_count /
CM2_TO_NANOBARN;
459 double pixel_bx_lumi_per_ls_unc = 0.0;
461 pixel_bx_lumi_per_ls_unc =
sqrt(lumi_factor_per_bx * lumi_factor_per_bx *
462 (average_cluster_count_unc * average_cluster_count_unc +
467 pixel_bx_lumi_per_ls_unc =
sqrt(lumi_factor_per_bx * lumi_factor_per_bx *
468 (average_cluster_count_unc * average_cluster_count_unc +
486 nBClus[0] += (*it).second.numB.at(0);
487 nBClus[1] += (*it).second.numB.at(1);
488 nBClus[2] += (*it).second.numB.at(2);
489 nFPClus[0] += (*it).second.numFP.at(0);
490 nFPClus[1] += (*it).second.numFP.at(1);
491 nFMClus[0] += (*it).second.numFM.at(0);
492 nFMClus[1] += (*it).second.numFM.at(1);
495 (*it).second.Reset();
506 total_recorded_unc_square += err * err;
513 if (totalevents > 10) {
514 total_recorded = lumi_factor_per_bx * totalcounts / totalevents /
CM2_TO_NANOBARN;
516 total_recorded = 0.0;
523 unsigned int all_detectors_counts = 0;
524 for (
unsigned int i = 0;
i < 3;
i++) {
525 all_detectors_counts += nBClus[
i];
527 for (
unsigned int i = 0;
i < 2;
i++) {
528 all_detectors_counts += nFPClus[
i];
530 for (
unsigned int i = 0;
i < 2;
i++) {
531 all_detectors_counts += nFMClus[
i];
536 for (
unsigned int i = 0;
i < 3;
i++) {
539 for (
unsigned int i = 0;
i < 2;
i++) {
542 for (
unsigned int i = 0;
i < 2;
i++) {
549 gettimeofday(&tv,
nullptr);
550 tm *ts = gmtime(&tv.tv_sec);
551 char datestring[256];
552 strftime(datestring,
sizeof(datestring),
"%Y.%m.%d %T GMT %s", ts);
554 logFile_ <<
"EndTimeOfFit " << datestring << std::endl;
555 logFile_ <<
"LumiRange " << ls <<
"-" << ls << std::endl;
556 logFile_ <<
"Fill " << -99 << std::endl;
559 logFile_ <<
"HFLumi " << -99 << std::endl;
560 logFile_ <<
"Ratio " << -99 << std::endl;
566 std::vector<float> ar(nbins, 0.);
567 for (
unsigned int i = 1;
i <=
nbins;
i++) {
575 unsigned int active_count = 0;
578 unsigned int non_empty_bins = 0;
580 for (
unsigned int i = 1;
i <=
nbins;
i++) {
590 ave /= non_empty_bins;
591 edm::LogWarning(
"pixelLumi") <<
"Bunch mask finder - non empty bins " << non_empty_bins
592 <<
" average of non empty bins " << ave <<
" max content of one bin " << maxc;
595 if (non_empty_bins < 50) {
599 TH1F dist(
"dist",
"dist", 500, 0., maxc + (maxc / 500.) * 20.);
600 for (
unsigned int i = 1;
i <=
nbins;
i++) {
604 TF1
fit(
"plgaus",
"gaus");
605 dist.Fit(&fit,
"",
"", fmax(0., ave - (maxc - ave) / 5.), maxc);
606 mean = fit.GetParameter(
"Mean");
607 sigma = fit.GetParameter(
"Sigma");
609 edm::LogWarning(
"pixelLumi") <<
"Bunch mask will use mean" << mean <<
" sigma " << sigma;
612 for (
unsigned int i = 1;
i <=
nbins;
i++) {
614 if (bin > 0. &&
std::abs(bin - mean) < 5. * (sigma)) {
619 edm::LogWarning(
"pixelLumi") <<
"Bunch mask finds " << active_count <<
" active bunch crossings ";
bool fIncludePixelQualCheckHistos
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
static double SECONDS_PER_LS
unsigned int filledAndUnmaskedBunches
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
void setBinContent(int binx, double content)
set content of bin (1-D)
const_iterator end(bool update=false) const
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
static const unsigned int lastBunchCrossing
void endRun(edm::Run const &, edm::EventSetup const &) override
std::vector< uint32_t > fDeadModules
bool getByToken(EDGetToken token, Handle< PROD > &result) const
static size_t kOffsetDisks
Geom::Phi< T > phi() const
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.
LuminosityBlockNumber_t luminosityBlock() const
MonitorElement * fHistClusByLS
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)
void setCurrentFolder(std::string const &fullpath)
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 * book1D(Args &&...args)
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
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
MonitorElement * fHistClusterCountByBxCumulative
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
MonitorElement * fHistnBClusVsLS[3]
void Reset()
reset ME (ie. contents, errors, etc)
LuminosityBlockNumber_t luminosityBlock() const
std::map< std::string, MonitorElement * > fHistContainerThisRun
bin
set the eta bin as selection string.
std::vector< bool > bunchTriggerMask
static double CM2_TO_NANOBARN
bool fIncludePixelClusterInfo
static double XSEC_PIXEL_CLUSTER
MonitorElement * book2D(Args &&...args)
MonitorElement * fHistBunchCrossings
double getBinError(int binx) const
get uncertainty on content of bin (1-D) - See TH1::GetBinError for details
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
double getBinContent(int binx) const
get content of bin (1-D)
Pixel cluster – collection of neighboring pixels above threshold.
std::map< int, PixelClusterCount > fNumPixelClusters
MonitorElement * fHistRecordedByBxLastLumi
const TrackerGeomDet * idToDet(DetId) const override
static size_t kOffsetLayers
int getNbinsX() const
get # of bins in X-axis
MonitorElement * fHistnFPClusVsLS[2]
int layerName() const
layer id
edm::Timestamp time() const
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
const_iterator begin(bool update=false) const