Skip to content

Commit

Permalink
Merge pull request #46575 from CMSTrackerDPG/mm_dev_improvePhase2Trac…
Browse files Browse the repository at this point in the history
…kerMonitorDigi

Improve `Phase2TrackerMonitorDigi`
  • Loading branch information
cmsbuild authored Nov 5, 2024
2 parents 60ae807 + 76205cb commit 9776ebc
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 113 deletions.
126 changes: 97 additions & 29 deletions DQM/SiTrackerPhase2/plugins/Phase2TrackerMonitorDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,103 @@
// Date: January 29, 2016
// Date: November 8, 2019 (Modified for adding in phase2 DQM Offline)
//
// system include files

// system include files
#include <memory>

#include "DQM/SiTrackerPhase2/plugins/Phase2TrackerMonitorDigi.h"

#include "FWCore/Framework/interface/MakerMacros.h"
// user includes
#include "DQM/SiTrackerPhase2/interface/TrackerPhase2DQMUtil.h"
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/MonitorElement.h"
#include "DataFormats/Common/interface/DetSetVector.h"
#include "DataFormats/Common/interface/Handle.h"

#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h"
#include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
#include "DataFormats/SiPixelDigi/interface/PixelDigiCollection.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ESWatcher.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Framework/interface/ESWatcher.h"

#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "Geometry/CommonDetUnit/interface/GeomDet.h"
#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
#include "Geometry/CommonDetUnit/interface/PixelGeomDetType.h"
#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"

#include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h"
#include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
#include "DataFormats/SiPixelDigi/interface/PixelDigiCollection.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
using Phase2TrackerGeomDetUnit = PixelGeomDetUnit;

// DQM Histograming
#include "DQMServices/Core/interface/MonitorElement.h"
#include "DQM/SiTrackerPhase2/interface/TrackerPhase2DQMUtil.h"
class Phase2TrackerMonitorDigi : public DQMEDAnalyzer {
public:
explicit Phase2TrackerMonitorDigi(const edm::ParameterSet&);
~Phase2TrackerMonitorDigi() override;
void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) override;
void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
void dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) override;
std::string getHistoId(uint32_t det_id, bool flag);

struct DigiMEs {
MonitorElement* NumberOfDigisPerDet;
MonitorElement* DigiOccupancyP;
MonitorElement* DigiOccupancyS;
MonitorElement* ChargeXYMap;
MonitorElement* PositionOfDigisP;
MonitorElement* PositionOfDigisS;
MonitorElement* ChargeOfDigis;
MonitorElement* ChargeOfDigisVsWidth;
MonitorElement* TotalNumberOfDigisPerLayer;
MonitorElement* NumberOfHitDetectorsPerLayer;
MonitorElement* NumberOfClustersPerDet;
MonitorElement* ClusterWidth;
MonitorElement* ClusterPositionP;
MonitorElement* ClusterPositionS;
MonitorElement* FractionOfOvTBits;
MonitorElement* FractionOfOvTBitsVsEta;
MonitorElement* EtaOccupancyProfP;
MonitorElement* EtaOccupancyProfS;
unsigned int nDigiPerLayer;
unsigned int nHitDetsPerLayer;
};

struct Ph2DigiCluster {
int charge;
int position;
int width;
int column;
};

MonitorElement* XYPositionMap;
MonitorElement* RZPositionMap;
MonitorElement* XYOccupancyMap;
MonitorElement* RZOccupancyMap;

private:
void bookLayerHistos(DQMStore::IBooker& ibooker, unsigned int det_id);
void fillITPixelDigiHistos(const edm::Handle<edm::DetSetVector<PixelDigi>> handle);
void fillOTDigiHistos(const edm::Handle<edm::DetSetVector<Phase2TrackerDigi>> handle);
void fillDigiClusters(DigiMEs& mes, std::vector<Ph2DigiCluster>& digi_clusters);

const edm::ParameterSet config_;
std::map<std::string, DigiMEs> layerMEs;
const bool pixelFlag_;
const bool clsFlag_;
const std::string geomType_;
const edm::InputTag otDigiSrc_;
const edm::InputTag itPixelDigiSrc_;
const edm::EDGetTokenT<edm::DetSetVector<Phase2TrackerDigi>> otDigiToken_;
const edm::EDGetTokenT<edm::DetSetVector<PixelDigi>> itPixelDigiToken_;
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomToken_;
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> topoToken_;
const TrackerGeometry* tkGeom_ = nullptr;
const TrackerTopology* tTopo_ = nullptr;
};

using Phase2TrackerGeomDetUnit = PixelGeomDetUnit;
//
// constructors
//
Expand All @@ -56,7 +124,7 @@ Phase2TrackerMonitorDigi::Phase2TrackerMonitorDigi(const edm::ParameterSet& iCon
itPixelDigiToken_(consumes<edm::DetSetVector<PixelDigi>>(itPixelDigiSrc_)),
geomToken_(esConsumes<TrackerGeometry, TrackerDigiGeometryRecord, edm::Transition::BeginRun>()),
topoToken_(esConsumes<TrackerTopology, TrackerTopologyRcd, edm::Transition::BeginRun>()) {
edm::LogInfo("Phase2TrackerMonitorDigi") << ">>> Construct Phase2TrackerMonitorDigi ";
LogDebug("Phase2TrackerMonitorDigi") << ">>> Construct Phase2TrackerMonitorDigi ";
}

//
Expand All @@ -65,7 +133,7 @@ Phase2TrackerMonitorDigi::Phase2TrackerMonitorDigi(const edm::ParameterSet& iCon
Phase2TrackerMonitorDigi::~Phase2TrackerMonitorDigi() {
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
edm::LogInfo("Phase2TrackerMonitorDigi") << ">>> Destroy Phase2TrackerMonitorDigi ";
LogDebug("Phase2TrackerMonitorDigi") << ">>> Destroy Phase2TrackerMonitorDigi ";
}

void Phase2TrackerMonitorDigi::dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
Expand Down Expand Up @@ -97,7 +165,7 @@ void Phase2TrackerMonitorDigi::fillITPixelDigiHistos(const edm::Handle<edm::DetS
for (typename edm::DetSetVector<PixelDigi>::const_iterator DSViter = digis->begin(); DSViter != digis->end();
DSViter++) {
unsigned int rawid = DSViter->id;
edm::LogInfo("Phase2TrackerMonitorDigi") << " Det Id = " << rawid;
LogDebug("Phase2TrackerMonitorDigi") << " Det Id = " << rawid;

int layer = tTopo_->getITPixelLayerNumber(rawid);

Expand Down Expand Up @@ -144,7 +212,7 @@ void Phase2TrackerMonitorDigi::fillITPixelDigiHistos(const edm::Handle<edm::DetS
RZPositionMap->Fill(pdPos.z() * 10., std::hypot(pdPos.x(), pdPos.y()) * 10.);
}
nDigi++;
edm::LogInfo("Phase2TrackerMonitorDigi") << " column " << col << " row " << row << std::dec << std::endl;
LogDebug("Phase2TrackerMonitorDigi") << " column " << col << " row " << row << std::dec << std::endl;
if (local_mes.ChargeXYMap)
local_mes.ChargeXYMap->Fill(col, row, adc);
if (local_mes.PositionOfDigisP)
Expand All @@ -167,8 +235,8 @@ void Phase2TrackerMonitorDigi::fillITPixelDigiHistos(const edm::Handle<edm::DetS
digiClusters.back().position = pos;
digiClusters.back().width += 1;
}
edm::LogInfo("Phase2TrackerMonitorDigi") << " row " << row << " col " << col << " row_last " << row_last
<< " col_last " << col_last << " width " << digiClusters.back().width;
LogDebug("Phase2TrackerMonitorDigi") << " row " << row << " col " << col << " row_last " << row_last
<< " col_last " << col_last << " width " << digiClusters.back().width;
row_last = row;
col_last = col;
}
Expand Down Expand Up @@ -213,7 +281,7 @@ void Phase2TrackerMonitorDigi::fillOTDigiHistos(const edm::Handle<edm::DetSetVec
DSViter++) {
unsigned int rawid = DSViter->id;
DetId detId(rawid);
edm::LogInfo("Phase2TrackerMonitorDigi") << " Det Id = " << rawid;
LogDebug("Phase2TrackerMonitorDigi") << " Det Id = " << rawid;
int layer = tTopo_->getOTLayerNumber(rawid);
if (layer < 0)
continue;
Expand Down Expand Up @@ -257,7 +325,7 @@ void Phase2TrackerMonitorDigi::fillOTDigiHistos(const edm::Handle<edm::DetSetVec
nDigi++;
if (di->overThreshold())
frac_ot++;
edm::LogInfo("Phase2TrackerMonitorDigi") << " column " << col << " row " << row << std::dec << std::endl;
LogDebug("Phase2TrackerMonitorDigi") << " column " << col << " row " << row << std::dec << std::endl;
if (nColumns > 2 && local_mes.PositionOfDigisP)
local_mes.PositionOfDigisP->Fill(row + 1, col + 1);
if (nColumns <= 2 && local_mes.PositionOfDigisS)
Expand All @@ -281,8 +349,8 @@ void Phase2TrackerMonitorDigi::fillOTDigiHistos(const edm::Handle<edm::DetSetVec
}
row_last = row;
col_last = col;
edm::LogInfo("Phase2TrackerMonitorDigi") << " row " << row << " col " << col << " row_last " << row_last
<< " col_last " << col_last << " width " << digiClusters.back().width;
LogDebug("Phase2TrackerMonitorDigi") << " row " << row << " col " << col << " row_last " << row_last
<< " col_last " << col_last << " width " << digiClusters.back().width;
}
}
if (local_mes.NumberOfDigisPerDet)
Expand Down Expand Up @@ -436,7 +504,7 @@ void Phase2TrackerMonitorDigi::bookLayerHistos(DQMStore::IBooker& ibooker, unsig

ibooker.cd();
ibooker.setCurrentFolder(top_folder + "/DigiMonitor/" + key);
edm::LogInfo("Phase2TrackerMonitorDigi") << " Booking Histograms in : " << key;
LogDebug("Phase2TrackerMonitorDigi") << " Booking Histograms in : " << key;

std::ostringstream HistoName;
DigiMEs local_mes;
Expand Down
84 changes: 0 additions & 84 deletions DQM/SiTrackerPhase2/plugins/Phase2TrackerMonitorDigi.h

This file was deleted.

0 comments on commit 9776ebc

Please sign in to comment.