48 : fPixelClusterLabel(consumes<edmNew::DetSetVector<
SiPixelCluster>>(
49 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";
110 for (TrackerGeometry::DetContainer::const_iterator
i = trackerGeo->
dets().begin();
i != trackerGeo->
dets().end();
115 DetId detId = (*i)->geographicalId();
118 if (iSearch != pixelClusters->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();
184 DetId detId = (*i)->geographicalId();
187 if (filterDeadModules &&
find(deadModulesBegin, deadModulesEnd, detId()) != deadModulesEnd) {
195 if (iSearch != pixelClusters->end()) {
200 double x = clus->x();
201 double y = clus->y();
204 double charge = clus->charge() / 1.e3;
205 int size = clus->size();
219 edm::LogWarning(
"pixelLumi") <<
"higher layer number, " << layer <<
", than layers";
238 <<
"higher disk number, " << disk <<
", than disks," <<
kNumDisks << std::endl;
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/";
300 std::stringstream
key;
301 key <<
"clusPosBarrel" <<
i;
302 std::stringstream
name;
303 name << key.str() <<
"_" << run.
run();
304 std::stringstream
title;
305 title <<
"Pixel cluster position - barrel layer " <<
i;
312 std::stringstream
key;
313 key <<
"clusPosEndCap" <<
i;
314 std::stringstream
name;
315 name << key.str() <<
"_" << run.
run();
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;
327 name << key.str() <<
"_" << run.
run();
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;
339 name << key.str() <<
"_" << run.
run();
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;
351 name << key.str() <<
"_" << run.
run();
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;
363 name << key.str() <<
"_" << run.
run();
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;
553 std::vector<float> ar(nbins + 1, 0.);
554 for (
unsigned int i = 1;
i <=
nbins;
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");
596 edm::LogWarning(
"pixelLumi") <<
"Bunch mask will use mean" << mean <<
" sigma " << sigma;
599 for (
unsigned int i = 1;
i <=
nbins;
i++) {
601 if (bin > 0. &&
std::abs(bin - mean) < 5. * (sigma)) {
606 edm::LogWarning(
"pixelLumi") <<
"Bunch mask finds " << active_count <<
" active bunch crossings ";
bool fIncludePixelQualCheckHistos
static constexpr double XSEC_PIXEL_CLUSTER
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
static constexpr double XSEC_PIXEL_CLUSTER_UNC
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
unsigned int filledAndUnmaskedBunches
const_iterator end(bool update=false) const
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
static const unsigned int lastBunchCrossing
virtual void setCurrentFolder(std::string const &fullpath)
std::vector< uint32_t > fDeadModules
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
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
static constexpr size_t kOffsetDisks
std::string to_string(const V &value)
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
const Plane & surface() const
The nominal surface of the GeomDet.
constexpr std::array< uint8_t, layerIndexSize > layer
LuminosityBlockNumber_t luminosityBlock() const
MonitorElement * fHistClusByLS
bool getData(T &iHolder) const
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
LuminosityBlockAuxiliary const & luminosityBlockAuxiliary() const override
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)
virtual int getNbinsX() const
get # of bins in X-axis
MonitorElement * fHistnFMClusVsLS[2]
static constexpr double SECONDS_PER_LS
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > fPixelClusterLabel
unsigned int calculateBunchMask(MonitorElement *, std::vector< bool > &)
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
tuple key
prepare the HTCondor submission files and eventually submit them
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
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
const TrackerGeomDet * idToDet(DetId) const override
std::map< std::string, MonitorElement * > fHistContainerThisRun
Log< level::Info, false > LogInfo
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
std::vector< bool > bunchTriggerMask
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())
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
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 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]
int layerName() const
layer id
tuple size
Write out results.
edm::Timestamp time() const
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
const_iterator begin(bool update=false) const
static constexpr double FREQ_ORBIT
static constexpr double CM2_TO_NANOBARN
static constexpr size_t kNumLayers