File indexing completed on 2024-04-06 12:09:08
0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002 #include "FWCore/ServiceRegistry/interface/Service.h"
0003 #include "FWCore/ParameterSet/interface/FileInPath.h"
0004 #include "DQM/TrackingMonitor/interface/TrackFoldedOccupancyClient.h"
0005
0006 TrackFoldedOccupancyClient::TrackFoldedOccupancyClient(edm::ParameterSet const& iConfig)
0007
0008 {
0009 edm::LogInfo("TrackFoldedOccupancyClient") << "TrackFoldedOccupancyClient::Deleting TrackFoldedOccupancyClient ";
0010 TopFolder_ = iConfig.getParameter<std::string>("FolderName");
0011 quality_ = iConfig.getParameter<std::string>("TrackQuality");
0012 algoName_ = iConfig.getParameter<std::string>("AlgoName");
0013 state_ = iConfig.getParameter<std::string>("MeasurementState");
0014 histTag_ = (state_ == "default") ? algoName_ : state_ + "_" + algoName_;
0015 conf_ = iConfig;
0016 }
0017
0018
0019 TrackFoldedOccupancyClient::~TrackFoldedOccupancyClient()
0020
0021 {
0022 edm::LogInfo("TrackFoldedOccupancyClient") << "TrackFoldedOccupancyClient::Deleting TrackFoldedOccupancyClient ";
0023 }
0024
0025
0026 void TrackFoldedOccupancyClient::beginJob(void)
0027
0028 {
0029 edm::LogInfo("TrackFoldedOccupancyClient") << "TrackFoldedOccupancyClient::beginJob done";
0030 }
0031
0032
0033 void TrackFoldedOccupancyClient::beginRun(edm::Run const& run, edm::EventSetup const& eSetup)
0034
0035 {
0036 edm::LogInfo("TrackFoldedOccupancyClient") << "TrackFoldedOccupancyClient:: Begining of Run";
0037 }
0038
0039
0040 void TrackFoldedOccupancyClient::bookMEs(DQMStore::IBooker& ibooker)
0041
0042 {
0043 ibooker.setCurrentFolder(TopFolder_ + "/" + quality_ + "/GeneralProperties/");
0044 int Phi2DBin = conf_.getParameter<int>("Phi2DBin");
0045 int Eta2DBin = conf_.getParameter<int>("Eta2DBin");
0046 double EtaMin = conf_.getParameter<double>("EtaMin");
0047 double EtaMax = conf_.getParameter<double>("EtaMax");
0048 double PhiMin = conf_.getParameter<double>("PhiMin");
0049 double PhiMax = conf_.getParameter<double>("PhiMax");
0050
0051
0052 std::string histname = "TkEtaPhi_RelativeDifference_byFoldingmap_" + histTag_;
0053 TkEtaPhi_RelativeDifference_byFoldingmap =
0054 ibooker.book2D(histname, histname, Eta2DBin, EtaMin, EtaMax, Phi2DBin, PhiMin, PhiMax);
0055 TkEtaPhi_RelativeDifference_byFoldingmap->setAxisTitle("Track #eta", 1);
0056 TkEtaPhi_RelativeDifference_byFoldingmap->setAxisTitle("Track #phi", 2);
0057
0058 histname = "TkEtaPhi_RelativeDifference_byFoldingmap_op_" + histTag_;
0059 TkEtaPhi_RelativeDifference_byFoldingmap_op =
0060 ibooker.book2D(histname, histname, Eta2DBin, EtaMin, EtaMax, Phi2DBin, PhiMin, PhiMax);
0061 TkEtaPhi_RelativeDifference_byFoldingmap_op->setAxisTitle("Track #eta", 1);
0062 TkEtaPhi_RelativeDifference_byFoldingmap_op->setAxisTitle("Track #phi", 2);
0063
0064 histname = "TkEtaPhi_Ratio_byFoldingmap_" + histTag_;
0065 TkEtaPhi_Ratio_byFoldingmap = ibooker.book2D(histname, histname, Eta2DBin, EtaMin, EtaMax, Phi2DBin, PhiMin, PhiMax);
0066 TkEtaPhi_Ratio_byFoldingmap->setAxisTitle("Track #eta", 1);
0067 TkEtaPhi_Ratio_byFoldingmap->setAxisTitle("Track #phi", 2);
0068
0069 histname = "TkEtaPhi_Ratio_byFoldingmap_op_" + histTag_;
0070 TkEtaPhi_Ratio_byFoldingmap_op =
0071 ibooker.book2D(histname, histname, Eta2DBin, EtaMin, EtaMax, Phi2DBin, PhiMin, PhiMax);
0072 TkEtaPhi_Ratio_byFoldingmap_op->setAxisTitle("Track #eta", 1);
0073 TkEtaPhi_Ratio_byFoldingmap_op->setAxisTitle("Track #phi", 2);
0074 }
0075
0076
0077 void TrackFoldedOccupancyClient::dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter)
0078
0079 {
0080 edm::LogInfo("TrackFoldedOccupancyClient") << "TrackFoldedOccupancyClient::endLuminosityBlock";
0081
0082 bookMEs(ibooker);
0083 std::string inFolder = TopFolder_ + "/" + quality_ + "/GeneralProperties/";
0084
0085 std::string hname;
0086 hname = "TrackEtaPhi_";
0087 MonitorElement* TrackEtaPhi = igetter.get(inFolder + hname + histTag_);
0088
0089 hname = "TrackEtaPhiInverted_";
0090 MonitorElement* TrackEtaPhiInverted = igetter.get(inFolder + hname + histTag_);
0091
0092 hname = "TrackEtaPhiInvertedoutofphase_";
0093 MonitorElement* TrackEtaPhiInvertedoutofphase = igetter.get(inFolder + hname + histTag_);
0094
0095 if (TrackEtaPhi == nullptr || TrackEtaPhiInverted == nullptr || TrackEtaPhiInvertedoutofphase == nullptr) {
0096 edm::LogWarning("TrackFoldedOccupancyClient") << "MEs needed for this module not found. Skipping.";
0097 return;
0098 }
0099
0100 TkEtaPhi_Ratio_byFoldingmap->divide(TrackEtaPhi, TrackEtaPhiInverted, 1., 1., "");
0101 TkEtaPhi_Ratio_byFoldingmap_op->divide(TrackEtaPhi, TrackEtaPhiInvertedoutofphase, 1., 1., "");
0102
0103 int nx = TrackEtaPhi->getNbinsX();
0104 int ny = TrackEtaPhi->getNbinsY();
0105
0106 for (int ii = 1; ii <= nx; ii++) {
0107 for (int jj = 1; jj <= ny; jj++) {
0108 double Sum1 = TrackEtaPhi->getBinContent(ii, jj) + TrackEtaPhiInverted->getBinContent(ii, jj);
0109 double Sum2 = TrackEtaPhi->getBinContent(ii, jj) + TrackEtaPhiInvertedoutofphase->getBinContent(ii, jj);
0110
0111 double Sub1 = TrackEtaPhi->getBinContent(ii, jj) - TrackEtaPhiInverted->getBinContent(ii, jj);
0112 double Sub2 = TrackEtaPhi->getBinContent(ii, jj) - TrackEtaPhiInvertedoutofphase->getBinContent(ii, jj);
0113
0114 if (Sum1 == 0 || Sum2 == 0) {
0115 TkEtaPhi_RelativeDifference_byFoldingmap->setBinContent(ii, jj, 1);
0116 TkEtaPhi_RelativeDifference_byFoldingmap_op->setBinContent(ii, jj, 1);
0117 } else {
0118 double ratio1 = Sub1 / Sum1;
0119 double ratio2 = Sub2 / Sum2;
0120 TkEtaPhi_RelativeDifference_byFoldingmap->setBinContent(ii, jj, ratio1);
0121 TkEtaPhi_RelativeDifference_byFoldingmap_op->setBinContent(ii, jj, ratio2);
0122 }
0123 }
0124 }
0125 }
0126
0127 DEFINE_FWK_MODULE(TrackFoldedOccupancyClient);