49 fPixelClusterLabel(consumes<
edmNew::DetSetVector<
SiPixelCluster> >(iConfig.getUntrackedParameter<
edm::InputTag>(
"pixelClusterLabel",
50 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"))
63 <<
"PixelLumiDQM looking for pixel clusters in '" 67 <<
"PixelLumiDQM storing pixel cluster info? " 70 <<
"PixelLumiDQM storing pixel cluster quality check histograms? " 75 <<
"No pixel modules specified to be ignored";
78 <<
fDeadModules.size() <<
" pixel modules specified to be ignored:";
79 for (std::vector<uint32_t>::const_iterator it =
fDeadModules.begin();
86 <<
"Ignoring pixel clusters with less than " 89 <<
"Ignoring pixel clusters with charge less than " 133 for (TrackerGeometry::DetContainer::const_iterator
134 i = trackerGeo->
dets().begin();
135 i != trackerGeo->
dets().end(); ++
i) {
139 DetId detId = (*i)->geographicalId();
142 pixelClusters->find(detId);
143 if (iSearch != pixelClusters->end()) {
147 size_t numClusters = 0;
149 itClus = iSearch->
begin();
150 itClus != iSearch->
end(); ++itClus) {
157 assert(numClusters <= iSearch->
size());
174 switch (halfCylinder) {
208 std::vector<uint32_t>::const_iterator deadModulesBegin =
fDeadModules.begin();
209 std::vector<uint32_t>::const_iterator deadModulesEnd =
fDeadModules.end();
212 for (TrackerGeometry::DetContainer::const_iterator
213 i = trackerGeo->
dets().begin();
214 i != trackerGeo->
dets().end(); ++
i) {
218 DetId detId = (*i)->geographicalId();
221 if (filterDeadModules &&
222 find(deadModulesBegin, deadModulesEnd, detId()) != deadModulesEnd) {
228 pixelClusters->find(detId);
231 if (iSearch != pixelClusters->end()) {
233 clus != iSearch->
end(); ++clus) {
241 double x = clus->x();
242 double y = clus->y();
245 double charge = clus->charge() / 1.e3;
246 int size = clus->size();
253 histName=
"clusPosBarrel"+std::to_string(layer);
255 histName=
"clusChargeBarrel"+std::to_string(layer);
257 histName=
"clusSizeBarrel"+std::to_string(layer);
260 edm::LogWarning(
"pixelLumi")<<
"higher layer number, "<<layer<<
", than layers";
272 histName=
"clusPosEndCap"+std::to_string(disk);
274 histName=
"clusChargeEndCap"+std::to_string(disk);
276 histName=
"clusSizeEndCap"+std::to_string(disk);
310 subfolder = folder+
"ClusterCountingDetails/";
313 fHistnBClusVsLS[0] = ibooker.
book1D(
"nBClusVsLS_0",
"Fraction of Clusters vs LS Barrel layer 0",8000,0.5,8000.5);
314 fHistnBClusVsLS[1] = ibooker.
book1D(
"nBClusVsLS_1",
"Fraction of Clusters vs LS Barrel layer 1",8000,0.5,8000.5);
315 fHistnBClusVsLS[2] = ibooker.
book1D(
"nBClusVsLS_2",
"Fraction of Clusters vs LS Barrel layer 2",8000,0.5,8000.5);
316 fHistnFPClusVsLS[0] = ibooker.
book1D(
"nFPClusVsLS_0",
"Fraction of Clusters vs LS Barrel layer 0",8000,0.5,8000.5);
317 fHistnFPClusVsLS[1] = ibooker.
book1D(
"nFPClusVsLS_1",
"Fraction of Clusters vs LS Barrel layer 1",8000,0.5,8000.5);
318 fHistnFMClusVsLS[0] = ibooker.
book1D(
"nFMClusVsLS_0",
"Fraction of Clusters vs LS Barrel layer 0",8000,0.5,8000.5);
319 fHistnFMClusVsLS[1] = ibooker.
book1D(
"nFMClusVsLS_1",
"Fraction of Clusters vs LS Barrel layer 1",8000,0.5,8000.5);
328 fHistClusByLS = ibooker.
book1D(
"totalClusByLS",
"Number of Clusters all dets vs LS",8000,0.5,8000.5);
331 subfolder = folder+
"qualityChecks/";
340 std::stringstream
key;
341 key <<
"clusPosBarrel" <<
i;
342 std::stringstream
name;
343 name << key.str() <<
"_" << run.
run();
344 std::stringstream
title;
345 title <<
"Pixel cluster position - barrel layer " <<
i;
354 std::stringstream
key;
355 key <<
"clusPosEndCap" <<
i;
356 std::stringstream
name;
357 name << key.str() <<
"_" << run.
run();
358 std::stringstream
title;
359 title <<
"Pixel cluster position - endcap disk " <<
i;
368 std::stringstream
key;
369 key <<
"clusChargeBarrel" <<
i;
370 std::stringstream
name;
371 name << key.str() <<
"_" << run.
run();
372 std::stringstream
title;
373 title <<
"Pixel cluster charge - barrel layer " <<
i;
382 std::stringstream
key;
383 key <<
"clusChargeEndCap" <<
i;
384 std::stringstream
name;
385 name << key.str() <<
"_" << run.
run();
386 std::stringstream
title;
387 title <<
"Pixel cluster charge - endcap disk " <<
i;
397 std::stringstream
key;
398 key <<
"clusSizeBarrel" <<
i;
399 std::stringstream
name;
400 name << key.str() <<
"_" << run.
run();
401 std::stringstream
title;
402 title <<
"Pixel cluster size - barrel layer " <<
i;
411 std::stringstream
key;
412 key <<
"clusSizeEndCap" <<
i;
413 std::stringstream
name;
414 name << key.str() <<
"_" << run.
run();
415 std::stringstream
title;
416 title <<
"Pixel cluster size - endcap disk " <<
i;
470 printf(
"Lumi Block = %d\n",ls);
475 unsigned int nBClus[3] = {0,0,0};
476 unsigned int nFPClus[2] = {0, 0};
477 unsigned int nFMClus[2] = {0, 0};
479 double total_recorded = 0.;
480 double total_recorded_unc_square = 0.;
483 double totalcounts = 0.0;
484 double etotalcounts = 0.0;
485 double totalevents = 0.0;
486 double lumi_factor_per_bx = 0.0;
496 unsigned int total = (*it).second.numB.at(1)+
497 (*it).second.numB.at(2)+(*it).second.numFP.at(0)+(*it).second.numFP.at(1)+
498 (*it).second.numFM.at(0)+(*it).second.numFM.at(1);
500 totalcounts +=
total;
501 double etotal = (*it).second.dnumB.at(1)+
502 (*it).second.dnumB.at(2)+(*it).second.dnumFP.at(0)+(*it).second.dnumFP.at(1)+
503 (*it).second.dnumFM.at(0)+(*it).second.dnumFM.at(1);
505 etotalcounts += etotal;
506 etotal =
sqrt(etotal);
513 totalevents += events_per_bx;
514 double average_cluster_count = events_per_bx !=0 ? double(total)/events_per_bx : 0.;
515 double average_cluster_count_unc = events_per_bx!=0 ? etotal/events_per_bx : 0.;
516 double pixel_bx_lumi_per_ls = lumi_factor_per_bx * average_cluster_count /
CM2_TO_NANOBARN ;
517 double pixel_bx_lumi_per_ls_unc = 0.0;
519 pixel_bx_lumi_per_ls_unc =
sqrt(lumi_factor_per_bx*lumi_factor_per_bx *
520 (average_cluster_count_unc*average_cluster_count_unc +
527 pixel_bx_lumi_per_ls_unc =
sqrt(lumi_factor_per_bx*lumi_factor_per_bx *
528 (average_cluster_count_unc*average_cluster_count_unc +
540 pixel_bx_lumi_per_ls);
549 nBClus[0] +=(*it).second.numB.at(0);
550 nBClus[1] +=(*it).second.numB.at(1);
551 nBClus[2] +=(*it).second.numB.at(2);
552 nFPClus[0] +=(*it).second.numFP.at(0);
553 nFPClus[1] +=(*it).second.numFP.at(1);
554 nFMClus[0] +=(*it).second.numFM.at(0);
555 nFMClus[1] +=(*it).second.numFM.at(1);
558 (*it).second.Reset();
568 total_recorded_unc_square += err*err;
574 if(totalevents > 10){
575 total_recorded = lumi_factor_per_bx * totalcounts / totalevents /
CM2_TO_NANOBARN ;
577 else total_recorded = 0.0;
582 sqrt(total_recorded_unc_square));
585 unsigned int all_detectors_counts = 0;
586 for(
unsigned int i = 0;
i < 3;
i++){
587 all_detectors_counts+=nBClus[
i];
589 for(
unsigned int i = 0;
i < 2;
i++){
590 all_detectors_counts+=nFPClus[
i];
592 for(
unsigned int i = 0;
i < 2;
i++){
593 all_detectors_counts+=nFMClus[
i];
598 for(
unsigned int i = 0;
i < 3;
i++){
600 float(nBClus[
i])/
float(all_detectors_counts));
602 for(
unsigned int i = 0;
i < 2;
i++){
604 float(nFPClus[
i])/
float(all_detectors_counts));
606 for(
unsigned int i = 0;
i < 2;
i++){
608 float(nFMClus[
i])/
float(all_detectors_counts));
614 gettimeofday(&tv,
nullptr);
615 tm *ts = gmtime(&tv.tv_sec);
616 char datestring[256];
617 strftime(datestring,
sizeof(datestring),
"%Y.%m.%d %T GMT %s",ts);
619 logFile_ <<
"EndTimeOfFit " << datestring << std::endl;
620 logFile_ <<
"LumiRange "<< ls <<
"-" << ls << std::endl;
621 logFile_ <<
"Fill "<< -99 << std::endl;
624 logFile_ <<
"HFLumi "<< -99 << std::endl;
625 logFile_ <<
"Ratio " << -99 << std::endl;
631 std::vector<float> ar(nbins,0.);
632 for(
unsigned int i = 1;
i<=
nbins;
i++){
639 unsigned int active_count = 0;
642 unsigned int non_empty_bins = 0;
644 for(
unsigned int i = 1;
i<=
nbins;
i++){
647 if(maxc<bin) maxc =
bin;
653 ave /= non_empty_bins;
654 edm::LogWarning(
"pixelLumi") <<
"Bunch mask finder - non empty bins " << non_empty_bins
655 <<
" average of non empty bins " << ave
656 <<
" max content of one bin " << maxc;
659 if(non_empty_bins < 50){
664 TH1F dist(
"dist",
"dist",500,0.,maxc+(maxc/500.)*20.);
665 for(
unsigned int i = 1;
i<=
nbins;
i++){
669 TF1
fit(
"plgaus",
"gaus");
670 dist.Fit(&fit,
"",
"",fmax(0.,ave-(maxc-ave)/5.),maxc);
671 mean = fit.GetParameter(
"Mean");
672 sigma = fit.GetParameter(
"Sigma");
674 edm::LogWarning(
"pixelLumi") <<
"Bunch mask will use mean" << mean <<
" sigma " << sigma;
676 for(
unsigned int i = 1;
i<=
nbins;
i++){
678 if(bin>0. &&
std::abs(bin-mean)<5.*(sigma)){ mask[
i]=
true; active_count++;}
680 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
#define DEFINE_FWK_MODULE(type)
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.
void addDefault(ParameterSetDescription const &psetDescription)
MonitorElement * fHistnFMClusVsLS[2]
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > fPixelClusterLabel
unsigned int calculateBunchMask(MonitorElement *, std::vector< bool > &)
static double rXSEC_PIXEL_CLUSTER
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]
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
LuminosityBlockNumber_t luminosityBlock() const
bin
set the eta bin as selection string.
std::vector< bool > bunchTriggerMask
static double CM2_TO_NANOBARN
void setCurrentFolder(const std::string &fullpath)
bool fIncludePixelClusterInfo
static double XSEC_PIXEL_CLUSTER
MonitorElement * book2D(Args &&...args)
MonitorElement * fHistBunchCrossings
std::map< std::string, MonitorElement * > fHistContainerThisRun
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
int getNbinsX(void) const
get # of bins in X-axis
static size_t kOffsetLayers
void Reset(void)
reset ME (ie. contents, errors, etc)
MonitorElement * fHistnFPClusVsLS[2]
int layerName() const
layer id
edm::Timestamp time() const
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
const_iterator begin(bool update=false) const