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());
173 int disk = detName.diskName();
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();
279 int disk = detName.diskName();
280 switch (halfCylinder) {
350 subfolder = folder+
"ClusterCountingDetails/";
353 fHistnBClusVsLS[0] = ibooker.
book1D(
"nBClusVsLS_0",
"Fraction of Clusters vs LS Barrel layer 0",8000,0.5,8000.5);
354 fHistnBClusVsLS[1] = ibooker.
book1D(
"nBClusVsLS_1",
"Fraction of Clusters vs LS Barrel layer 1",8000,0.5,8000.5);
355 fHistnBClusVsLS[2] = ibooker.
book1D(
"nBClusVsLS_2",
"Fraction of Clusters vs LS Barrel layer 2",8000,0.5,8000.5);
356 fHistnFPClusVsLS[0] = ibooker.
book1D(
"nFPClusVsLS_0",
"Fraction of Clusters vs LS Barrel layer 0",8000,0.5,8000.5);
357 fHistnFPClusVsLS[1] = ibooker.
book1D(
"nFPClusVsLS_1",
"Fraction of Clusters vs LS Barrel layer 1",8000,0.5,8000.5);
358 fHistnFMClusVsLS[0] = ibooker.
book1D(
"nFMClusVsLS_0",
"Fraction of Clusters vs LS Barrel layer 0",8000,0.5,8000.5);
359 fHistnFMClusVsLS[1] = ibooker.
book1D(
"nFMClusVsLS_1",
"Fraction of Clusters vs LS Barrel layer 1",8000,0.5,8000.5);
368 fHistClusByLS = ibooker.
book1D(
"totalClusByLS",
"Number of Clusters all dets vs LS",8000,0.5,8000.5);
371 subfolder = folder+
"qualityChecks/";
380 std::stringstream
key;
381 key <<
"clusPosBarrel" <<
i;
382 std::stringstream
name;
383 name << key.str() <<
"_" << run.
run();
384 std::stringstream
title;
385 title <<
"Pixel cluster position - barrel layer " <<
i;
393 std::vector<std::string> sides;
394 sides.push_back(
"M");
395 sides.push_back(
"P");
396 for (std::vector<std::string>::const_iterator side = sides.begin();
397 side != sides.end(); ++side) {
399 std::stringstream
key;
400 key <<
"clusPosEndCap" << *side <<
i;
401 std::stringstream
name;
402 name << key.str() <<
"_" << run.
run();
403 std::stringstream
title;
404 title <<
"Pixel cluster position - endcap disk " <<
i;
414 std::stringstream
key;
415 key <<
"clusChargeBarrel" <<
i;
416 std::stringstream
name;
417 name << key.str() <<
"_" << run.
run();
418 std::stringstream
title;
419 title <<
"Pixel cluster charge - barrel layer " <<
i;
427 for (std::vector<std::string>::const_iterator side = sides.begin();
428 side != sides.end(); ++side) {
430 std::stringstream
key;
431 key <<
"clusChargeEndCap" << *side <<
i;
432 std::stringstream
name;
433 name << key.str() <<
"_" << run.
run();
434 std::stringstream
title;
435 title <<
"Pixel cluster charge - endcap disk " <<
i;
445 std::stringstream
key;
446 key <<
"clusSizeBarrel" <<
i;
447 std::stringstream
name;
448 name << key.str() <<
"_" << run.
run();
449 std::stringstream
title;
450 title <<
"Pixel cluster size - barrel layer " <<
i;
458 for (std::vector<std::string>::const_iterator side = sides.begin();
459 side != sides.end(); ++side) {
461 std::stringstream
key;
462 key <<
"clusSizeEndCap" << *side <<
i;
463 std::stringstream
name;
464 name << key.str() <<
"_" << run.
run();
465 std::stringstream
title;
466 title <<
"Pixel cluster size - endcap disk " <<
i;
521 printf(
"Lumi Block = %d\n",ls);
526 unsigned int nBClus[3] = {0,0,0};
527 unsigned int nFPClus[2] = {0, 0};
528 unsigned int nFMClus[2] = {0, 0};
530 double total_recorded = 0.;
531 double total_recorded_unc_square = 0.;
534 double totalcounts = 0.0;
535 double etotalcounts = 0.0;
536 double totalevents = 0.0;
537 double lumi_factor_per_bx = 0.0;
547 unsigned int total = (*it).second.numB.at(1)+
548 (*it).second.numB.at(2)+(*it).second.numFP.at(0)+(*it).second.numFP.at(1)+
549 (*it).second.numFM.at(0)+(*it).second.numFM.at(1);
551 totalcounts +=
total;
552 double etotal = (*it).second.dnumB.at(1)+
553 (*it).second.dnumB.at(2)+(*it).second.dnumFP.at(0)+(*it).second.dnumFP.at(1)+
554 (*it).second.dnumFM.at(0)+(*it).second.dnumFM.at(1);
556 etotalcounts += etotal;
557 etotal =
sqrt(etotal);
564 totalevents += events_per_bx;
565 double average_cluster_count = events_per_bx !=0 ? double(total)/events_per_bx : 0.;
566 double average_cluster_count_unc = events_per_bx!=0 ? etotal/events_per_bx : 0.;
567 double pixel_bx_lumi_per_ls = lumi_factor_per_bx * average_cluster_count /
CM2_TO_NANOBARN ;
568 double pixel_bx_lumi_per_ls_unc = 0.0;
570 pixel_bx_lumi_per_ls_unc =
sqrt(lumi_factor_per_bx*lumi_factor_per_bx *
571 (average_cluster_count_unc*average_cluster_count_unc +
578 pixel_bx_lumi_per_ls_unc =
sqrt(lumi_factor_per_bx*lumi_factor_per_bx *
579 (average_cluster_count_unc*average_cluster_count_unc +
591 pixel_bx_lumi_per_ls);
600 nBClus[0] +=(*it).second.numB.at(0);
601 nBClus[1] +=(*it).second.numB.at(1);
602 nBClus[2] +=(*it).second.numB.at(2);
603 nFPClus[0] +=(*it).second.numFP.at(0);
604 nFPClus[1] +=(*it).second.numFP.at(1);
605 nFMClus[0] +=(*it).second.numFM.at(0);
606 nFMClus[1] +=(*it).second.numFM.at(1);
609 (*it).second.Reset();
619 total_recorded_unc_square += err*err;
625 if(totalevents > 10){
626 total_recorded = lumi_factor_per_bx * totalcounts / totalevents /
CM2_TO_NANOBARN ;
628 else total_recorded = 0.0;
630 std::cout <<
" Total recorded " << total_recorded << std::endl;
633 sqrt(total_recorded_unc_square));
636 unsigned int all_detectors_counts = 0;
637 for(
unsigned int i = 0;
i < 3;
i++){
638 all_detectors_counts+=nBClus[
i];
640 for(
unsigned int i = 0;
i < 2;
i++){
641 all_detectors_counts+=nFPClus[
i];
643 for(
unsigned int i = 0;
i < 2;
i++){
644 all_detectors_counts+=nFMClus[
i];
649 for(
unsigned int i = 0;
i < 3;
i++){
651 float(nBClus[
i])/
float(all_detectors_counts));
653 for(
unsigned int i = 0;
i < 2;
i++){
655 float(nFPClus[
i])/
float(all_detectors_counts));
657 for(
unsigned int i = 0;
i < 2;
i++){
659 float(nFMClus[
i])/
float(all_detectors_counts));
666 tm *ts = gmtime(&tv.tv_sec);
667 char datestring[256];
668 strftime(datestring,
sizeof(datestring),
"%Y.%m.%d %T GMT %s",ts);
670 logFile_ <<
"EndTimeOfFit " << datestring << std::endl;
671 logFile_ <<
"LumiRange "<< ls <<
"-" << ls << std::endl;
672 logFile_ <<
"Fill "<< -99 << std::endl;
675 logFile_ <<
"HFLumi "<< -99 << std::endl;
676 logFile_ <<
"Ratio " << -99 << std::endl;
682 std::vector<float> ar(nbins,0.);
683 for(
unsigned int i = 1;
i<=
nbins;
i++){
690 unsigned int active_count = 0;
693 unsigned int non_empty_bins = 0;
695 for(
unsigned int i = 1;
i<=
nbins;
i++){
698 if(maxc<bin) maxc =
bin;
704 ave /= non_empty_bins;
705 std::cout <<
"Bunch mask finder - non empty bins " << non_empty_bins
706 <<
" average of non empty bins " << ave
707 <<
" max content of one bin " << maxc << std::endl;
710 if(non_empty_bins < 50){
715 TH1F dist(
"dist",
"dist",500,0.,maxc+(maxc/500.)*20.);
716 for(
unsigned int i = 1;
i<=
nbins;
i++){
720 dist.Fit(
"gaus",
"",
"",fmax(0.,ave-(maxc-ave)/5.),maxc);
721 TF1 *
fit = dist.GetFunction(
"gaus");
722 mean = fit->GetParameter(
"Mean");
723 sigma = fit->GetParameter(
"Sigma");
725 std::cout <<
"Bunch mask will use mean" << mean <<
" sigma " << sigma << std::endl;
727 for(
unsigned int i = 1;
i<=
nbins;
i++){
729 if(bin>0. &&
std::abs(bin-mean)<5.*(sigma)){ mask[
i]=
true; active_count++;}
731 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 void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
static const unsigned int lastBunchCrossing
virtual void endRun(edm::Run const &, edm::EventSetup const &) override
std::vector< uint32_t > fDeadModules
const DetContainer & dets() const
Returm a vector of all GeomDet (including all GeomDetUnits)
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
MonitorElement * fHistRecordedByBxCumulative
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
virtual 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
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.
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
virtual 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)
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
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
bool isTrackerPixel(const GeomDetEnumerators::SubDetector m)
std::string fLogFileName_
PixelLumiDQM(const edm::ParameterSet &)
static double rXSEC_PIXEL_CLUSTER_UNC
virtual 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
int getNbinsX(void) const
get # of bins in X-axis
static size_t const kNumDisks
void Reset(void)
reset ME (ie. contents, errors, etc)
MonitorElement * fHistnFPClusVsLS[2]
edm::Timestamp time() const
const_iterator begin(bool update=false) const
const TrackerGeomDet * idToDet(DetId) const
static size_t const kNumLayers