47 fPixelClusterLabel(consumes<edmNew::DetSetVector<
SiPixelCluster> >(iConfig.getUntrackedParameter<edm::
InputTag>(
"pixelClusterLabel",
49 fIncludePixelClusterInfo(iConfig.getUntrackedParameter<bool>(
"includePixelClusterInfo",
true)),
50 fIncludePixelQualCheckHistos(iConfig.getUntrackedParameter<bool>(
"includePixelQualCheckHistos",
true)),
51 fResetIntervalInLumiSections(iConfig.getUntrackedParameter<int>(
"resetEveryNLumiSections", 1)),
52 fDeadModules(iConfig.getUntrackedParameter<std::vector<uint32_t> >(
"deadModules", std::vector<uint32_t>())),
53 fMinPixelsPerCluster(iConfig.getUntrackedParameter<int>(
"minNumPixelsPerCluster", 0)),
54 fMinClusterCharge(iConfig.getUntrackedParameter<double>(
"minChargePerCluster", 0)),
55 bunchTriggerMask(lastBunchCrossing+1,
false),
56 filledAndUnmaskedBunches(0),
57 useInnerBarrelLayer(iConfig.getUntrackedParameter<bool>(
"useInnerBarrelLayer",
false)),
58 fLogFileName_(iConfig.getUntrackedParameter<std::
string>(
"logFileName",
"/tmp/pixel_lumi.txt"))
61 <<
"PixelLumiDQM looking for pixel clusters in '"
65 <<
"PixelLumiDQM storing pixel cluster info? "
68 <<
"PixelLumiDQM storing pixel cluster quality check histograms? "
73 <<
"No pixel modules specified to be ignored";
76 <<
fDeadModules.size() <<
" pixel modules specified to be ignored:";
77 for (std::vector<uint32_t>::const_iterator it =
fDeadModules.begin();
84 <<
"Ignoring pixel clusters with less than "
87 <<
"Ignoring pixel clusters with charge less than "
131 for (TrackerGeometry::DetContainer::const_iterator
132 i = trackerGeo->dets().begin();
133 i != trackerGeo->dets().end(); ++
i) {
137 DetId detId = (*i)->geographicalId();
140 pixelClusters->find(detId);
141 if (iSearch != pixelClusters->end()) {
145 size_t numClusters = 0;
147 itClus = iSearch->
begin();
148 itClus != iSearch->
end(); ++itClus) {
171 int disk = detName.diskName();
172 switch (halfCylinder) {
206 std::vector<uint32_t>::const_iterator deadModulesBegin =
fDeadModules.begin();
207 std::vector<uint32_t>::const_iterator deadModulesEnd =
fDeadModules.end();
210 for (TrackerGeometry::DetContainer::const_iterator
211 i = trackerGeo->dets().begin();
212 i != trackerGeo->dets().end(); ++
i) {
216 DetId detId = (*i)->geographicalId();
219 if (filterDeadModules &&
220 find(deadModulesBegin, deadModulesEnd, detId()) != deadModulesEnd) {
226 pixelClusters->find(detId);
229 if (iSearch != pixelClusters->end()) {
231 clus != iSearch->
end(); ++clus) {
239 double x = clus->x();
240 double y = clus->y();
243 double charge = clus->charge() / 1.e3;
244 int size = clus->size();
277 int disk = detName.diskName();
278 switch (halfCylinder) {
348 subfolder = folder+
"ClusterCountingDetails/";
351 fHistnBClusVsLS[0] = ibooker.
book1D(
"nBClusVsLS_0",
"Fraction of Clusters vs LS Barrel layer 0",8000,0.5,8000.5);
352 fHistnBClusVsLS[1] = ibooker.
book1D(
"nBClusVsLS_1",
"Fraction of Clusters vs LS Barrel layer 1",8000,0.5,8000.5);
353 fHistnBClusVsLS[2] = ibooker.
book1D(
"nBClusVsLS_2",
"Fraction of Clusters vs LS Barrel layer 2",8000,0.5,8000.5);
354 fHistnFPClusVsLS[0] = ibooker.
book1D(
"nFPClusVsLS_0",
"Fraction of Clusters vs LS Barrel layer 0",8000,0.5,8000.5);
355 fHistnFPClusVsLS[1] = ibooker.
book1D(
"nFPClusVsLS_1",
"Fraction of Clusters vs LS Barrel layer 1",8000,0.5,8000.5);
356 fHistnFMClusVsLS[0] = ibooker.
book1D(
"nFMClusVsLS_0",
"Fraction of Clusters vs LS Barrel layer 0",8000,0.5,8000.5);
357 fHistnFMClusVsLS[1] = ibooker.
book1D(
"nFMClusVsLS_1",
"Fraction of Clusters vs LS Barrel layer 1",8000,0.5,8000.5);
366 fHistClusByLS = ibooker.
book1D(
"totalClusByLS",
"Number of Clusters all dets vs LS",8000,0.5,8000.5);
369 subfolder = folder+
"qualityChecks/";
378 std::stringstream
key;
379 key <<
"clusPosBarrel" <<
i;
380 std::stringstream
name;
381 name << key.str() <<
"_" << run.
run();
382 std::stringstream
title;
383 title <<
"Pixel cluster position - barrel layer " <<
i;
391 std::vector<std::string> sides;
392 sides.push_back(
"M");
393 sides.push_back(
"P");
394 for (std::vector<std::string>::const_iterator side = sides.begin();
395 side != sides.end(); ++side) {
397 std::stringstream
key;
398 key <<
"clusPosEndCap" << *side <<
i;
399 std::stringstream
name;
400 name << key.str() <<
"_" << run.
run();
401 std::stringstream
title;
402 title <<
"Pixel cluster position - endcap disk " <<
i;
412 std::stringstream
key;
413 key <<
"clusChargeBarrel" <<
i;
414 std::stringstream
name;
415 name << key.str() <<
"_" << run.
run();
416 std::stringstream
title;
417 title <<
"Pixel cluster charge - barrel layer " <<
i;
425 for (std::vector<std::string>::const_iterator side = sides.begin();
426 side != sides.end(); ++side) {
428 std::stringstream
key;
429 key <<
"clusChargeEndCap" << *side <<
i;
430 std::stringstream
name;
431 name << key.str() <<
"_" << run.
run();
432 std::stringstream
title;
433 title <<
"Pixel cluster charge - endcap disk " <<
i;
443 std::stringstream
key;
444 key <<
"clusSizeBarrel" <<
i;
445 std::stringstream
name;
446 name << key.str() <<
"_" << run.
run();
447 std::stringstream
title;
448 title <<
"Pixel cluster size - barrel layer " <<
i;
456 for (std::vector<std::string>::const_iterator side = sides.begin();
457 side != sides.end(); ++side) {
459 std::stringstream
key;
460 key <<
"clusSizeEndCap" << *side <<
i;
461 std::stringstream
name;
462 name << key.str() <<
"_" << run.
run();
463 std::stringstream
title;
464 title <<
"Pixel cluster size - endcap disk " <<
i;
519 printf(
"Lumi Block = %d\n",ls);
524 unsigned int nBClus[3] = {0,0,0};
525 unsigned int nFPClus[2] = {0, 0};
526 unsigned int nFMClus[2] = {0, 0};
528 double total_recorded = 0.;
529 double total_recorded_unc_square = 0.;
532 double totalcounts = 0.0;
533 double etotalcounts = 0.0;
534 double totalevents = 0.0;
535 double lumi_factor_per_bx = 0.0;
545 unsigned int total = (*it).second.numB.at(1)+
546 (*it).second.numB.at(2)+(*it).second.numFP.at(0)+(*it).second.numFP.at(1)+
547 (*it).second.numFM.at(0)+(*it).second.numFM.at(1);
549 totalcounts +=
total;
550 double etotal = (*it).second.dnumB.at(1)+
551 (*it).second.dnumB.at(2)+(*it).second.dnumFP.at(0)+(*it).second.dnumFP.at(1)+
552 (*it).second.dnumFM.at(0)+(*it).second.dnumFM.at(1);
554 etotalcounts += etotal;
555 etotal =
sqrt(etotal);
562 totalevents += events_per_bx;
563 double average_cluster_count = events_per_bx !=0 ? double(total)/events_per_bx : 0.;
564 double average_cluster_count_unc = events_per_bx!=0 ? etotal/events_per_bx : 0.;
565 double pixel_bx_lumi_per_ls = lumi_factor_per_bx * average_cluster_count /
CM2_TO_NANOBARN ;
566 double pixel_bx_lumi_per_ls_unc = 0.0;
568 pixel_bx_lumi_per_ls_unc =
sqrt(lumi_factor_per_bx*lumi_factor_per_bx *
569 (average_cluster_count_unc*average_cluster_count_unc +
576 pixel_bx_lumi_per_ls_unc =
sqrt(lumi_factor_per_bx*lumi_factor_per_bx *
577 (average_cluster_count_unc*average_cluster_count_unc +
589 pixel_bx_lumi_per_ls);
598 nBClus[0] +=(*it).second.numB.at(0);
599 nBClus[1] +=(*it).second.numB.at(1);
600 nBClus[2] +=(*it).second.numB.at(2);
601 nFPClus[0] +=(*it).second.numFP.at(0);
602 nFPClus[1] +=(*it).second.numFP.at(1);
603 nFMClus[0] +=(*it).second.numFM.at(0);
604 nFMClus[1] +=(*it).second.numFM.at(1);
607 (*it).second.Reset();
617 total_recorded_unc_square += err*err;
623 if(totalevents > 10){
624 total_recorded = lumi_factor_per_bx * totalcounts / totalevents /
CM2_TO_NANOBARN ;
626 else total_recorded = 0.0;
628 std::cout <<
" Total recorded " << total_recorded << std::endl;
631 sqrt(total_recorded_unc_square));
634 unsigned int all_detectors_counts = 0;
635 for(
unsigned int i = 0;
i < 3;
i++){
636 all_detectors_counts+=nBClus[
i];
638 for(
unsigned int i = 0;
i < 2;
i++){
639 all_detectors_counts+=nFPClus[
i];
641 for(
unsigned int i = 0;
i < 2;
i++){
642 all_detectors_counts+=nFMClus[
i];
647 for(
unsigned int i = 0;
i < 3;
i++){
649 float(nBClus[
i])/
float(all_detectors_counts));
651 for(
unsigned int i = 0;
i < 2;
i++){
653 float(nFPClus[
i])/
float(all_detectors_counts));
655 for(
unsigned int i = 0;
i < 2;
i++){
657 float(nFMClus[
i])/
float(all_detectors_counts));
664 tm *ts = gmtime(&tv.tv_sec);
665 char datestring[256];
666 strftime(datestring,
sizeof(datestring),
"%Y.%m.%d %T GMT %s",ts);
668 logFile_ <<
"EndTimeOfFit " << datestring << std::endl;
674 std::vector<float> ar(nbins,0.);
675 for(
unsigned int i = 1;
i<=
nbins;
i++){
682 unsigned int active_count = 0;
685 unsigned int non_empty_bins = 0;
687 for(
unsigned int i = 1;
i<=
nbins;
i++){
690 if(maxc<bin) maxc =
bin;
696 ave /= non_empty_bins;
697 std::cout <<
"Bunch mask finder - non empty bins " << non_empty_bins
698 <<
" average of non empty bins " << ave
699 <<
" max content of one bin " << maxc << std::endl;
702 if(non_empty_bins < 50){
707 TH1F dist(
"dist",
"dist",500,0.,maxc+(maxc/500.)*20.);
708 for(
unsigned int i = 1;
i<=
nbins;
i++){
712 dist.Fit(
"gaus",
"",
"",fmax(0.,ave-(maxc-ave)/5.),maxc);
713 TF1 *fit = dist.GetFunction(
"gaus");
714 mean = fit->GetParameter(
"Mean");
715 sigma = fit->GetParameter(
"Sigma");
717 std::cout <<
"Bunch mask will use mean" << mean <<
" sigma " << sigma << std::endl;
719 for(
unsigned int i = 1;
i<=
nbins;
i++){
721 if(bin>0. &&
abs(bin-mean)<5.*(sigma)){ mask[
i]=
true; active_count++;}
723 std::cout <<
"Bunch mask finds " << active_count <<
" active bunch crossings " << std::endl;
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
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
static const unsigned int lastBunchCrossing
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::vector< uint32_t > fDeadModules
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
Geom::Phi< T > phi() const
int bunchCrossing() const
int fResetIntervalInLumiSections
data_type const * const_iterator
virtual void endRun(edm::Run const &, edm::EventSetup const &)
MonitorElement * fHistRecordedByBxCumulative
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const Plane & surface() const
The nominal surface of the GeomDet.
LuminosityBlockNumber_t luminosityBlock() const
MonitorElement * fHistClusByLS
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
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
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.
virtual 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
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
std::vector< bool > bunchTriggerMask
static double CM2_TO_NANOBARN
void setCurrentFolder(const std::string &fullpath)
LuminosityBlockAuxiliary const & luminosityBlockAuxiliary() const
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.
int layerName() const
layer id
bool isTrackerPixel(const GeomDetEnumerators::SubDetector m)
std::string fLogFileName_
PixelLumiDQM(const edm::ParameterSet &)
static double rXSEC_PIXEL_CLUSTER_UNC
virtual void dqmBeginRun(edm::Run const &, edm::EventSetup const &)
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
int getNbinsX(void) const
get # of bins in X-axis
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
volatile std::atomic< bool > shutdown_flag false
static size_t const kNumDisks
void Reset(void)
reset ME (ie. contents, errors, etc)
MonitorElement * fHistnFPClusVsLS[2]
tuple size
Write out results.
edm::Timestamp time() const
const_iterator begin(bool update=false) const
static size_t const kNumLayers