File indexing completed on 2022-06-24 22:51:52
0001 #include "DQM/GEM/interface/GEMDigiSource.h"
0002
0003 using namespace std;
0004 using namespace edm;
0005
0006 GEMDigiSource::GEMDigiSource(const edm::ParameterSet& cfg) : GEMDQMBase(cfg) {
0007 tagDigi_ = consumes<GEMDigiCollection>(cfg.getParameter<edm::InputTag>("digisInputLabel"));
0008 lumiScalers_ = consumes<LumiScalersCollection>(
0009 cfg.getUntrackedParameter<edm::InputTag>("lumiCollection", edm::InputTag("scalersRawToDigi")));
0010 nBXMin_ = cfg.getParameter<int>("bxMin");
0011 nBXMax_ = cfg.getParameter<int>("bxMax");
0012 }
0013
0014 void GEMDigiSource::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0015 edm::ParameterSetDescription desc;
0016 desc.add<edm::InputTag>("digisInputLabel", edm::InputTag("muonGEMDigis", ""));
0017 desc.addUntracked<std::string>("runType", "online");
0018 desc.addUntracked<std::string>("logCategory", "GEMDigiSource");
0019 desc.add<int>("bxMin", -10);
0020 desc.add<int>("bxMax", 10);
0021 descriptions.add("GEMDigiSource", desc);
0022 }
0023
0024 void GEMDigiSource::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const& iSetup) {
0025 initGeometry(iSetup);
0026 if (GEMGeometry_ == nullptr)
0027 return;
0028 loadChambers();
0029
0030 strFolderMain_ = "GEM/Digis";
0031
0032 fRadiusMin_ = 120.0;
0033 fRadiusMax_ = 250.0;
0034 float radS = -5.0 / 180 * M_PI;
0035 float radL = 355.0 / 180 * M_PI;
0036
0037 mapTotalDigi_layer_ = MEMap3Inf(this, "occ", "Digi Occupancy", 36, 0.5, 36.5, 24, -0.5, 24 - 0.5, "Chamber", "VFAT");
0038 mapDigiWheel_layer_ = MEMap3Inf(
0039 this, "occ_rphi", "Digi R-Phi Occupancy", 360, radS, radL, 8, fRadiusMin_, fRadiusMax_, "#phi (rad)", "R [cm]");
0040 mapDigiOcc_ieta_ = MEMap3Inf(this, "occ_ieta", "Digi iEta Occupancy", 8, 0.5, 8.5, "iEta", "Number of fired digis");
0041 mapDigiOcc_phi_ =
0042 MEMap3Inf(this, "occ_phi", "Digi Phi Occupancy", 72, -5, 355, "#phi (degree)", "Number of fired digis");
0043 mapTotalDigiPerEvtLayer_ = MEMap3Inf(this,
0044 "digis_per_layer",
0045 "Total number of digis per event for each layers",
0046 50,
0047 -0.5,
0048 99.5,
0049 "Number of fired digis",
0050 "Events");
0051 mapTotalDigiPerEvtLayer_.SetNoUnderOverflowBin();
0052 mapTotalDigiPerEvtIEta_ = MEMap3Inf(this,
0053 "digis_per_ieta",
0054 "Total number of digis per event for each eta partitions",
0055 50,
0056 -0.5,
0057 99.5,
0058 "Number of fired digis",
0059 "Events");
0060 mapTotalDigiPerEvtIEta_.SetNoUnderOverflowBin();
0061
0062 mapBX_ = MEMap2Inf(this, "bx", "Digi Bunch Crossing", 21, nBXMin_ - 0.5, nBXMax_ + 0.5, "Bunch crossing");
0063
0064 mapDigiOccPerCh_ = MEMap4Inf(this, "occ", "Digi Occupancy", 1, -0.5, 1.5, 1, 0.5, 1.5, "Digi", "iEta");
0065
0066 if (nRunType_ == GEMDQM_RUNTYPE_OFFLINE) {
0067 mapDigiWheel_layer_.TurnOff();
0068 mapBX_.TurnOff();
0069 }
0070
0071 if (nRunType_ == GEMDQM_RUNTYPE_RELVAL) {
0072 mapDigiWheel_layer_.TurnOff();
0073 mapDigiOccPerCh_.TurnOff();
0074 mapTotalDigi_layer_.TurnOff();
0075 }
0076
0077 if (nRunType_ != GEMDQM_RUNTYPE_ALLPLOTS && nRunType_ != GEMDQM_RUNTYPE_RELVAL) {
0078 mapDigiOcc_ieta_.TurnOff();
0079 mapDigiOcc_phi_.TurnOff();
0080 }
0081
0082 if (nRunType_ != GEMDQM_RUNTYPE_ALLPLOTS) {
0083 mapTotalDigiPerEvtLayer_.TurnOff();
0084 mapTotalDigiPerEvtIEta_.TurnOff();
0085 }
0086
0087 ibooker.cd();
0088 ibooker.setCurrentFolder(strFolderMain_);
0089 GenerateMEPerChamber(ibooker);
0090 }
0091
0092 int GEMDigiSource::ProcessWithMEMap2(BookingHelper& bh, ME2IdsKey key) {
0093 mapBX_.bookND(bh, key);
0094
0095 return 0;
0096 }
0097
0098 int GEMDigiSource::ProcessWithMEMap2WithEta(BookingHelper& bh, ME3IdsKey key) {
0099 mapTotalDigiPerEvtIEta_.bookND(bh, key);
0100
0101 return 0;
0102 }
0103
0104 int GEMDigiSource::ProcessWithMEMap3(BookingHelper& bh, ME3IdsKey key) {
0105 MEStationInfo& stationInfo = mapStationInfo_[key];
0106
0107 int nNumVFATPerEta = stationInfo.nMaxVFAT_ / stationInfo.nNumEtaPartitions_;
0108
0109 mapTotalDigi_layer_.SetBinConfX(stationInfo.nNumChambers_);
0110 mapTotalDigi_layer_.SetBinConfY(stationInfo.nMaxVFAT_, -0.5);
0111 mapTotalDigi_layer_.bookND(bh, key);
0112 mapTotalDigi_layer_.SetLabelForChambers(key, 1, -1, stationInfo.nMinIdxChamber_);
0113 mapTotalDigi_layer_.SetLabelForVFATs(key, stationInfo.nNumEtaPartitions_, 2);
0114
0115 mapDigiWheel_layer_.SetBinLowEdgeX(stationInfo.fMinPhi_);
0116 mapDigiWheel_layer_.SetBinHighEdgeX(stationInfo.fMinPhi_ + 2 * M_PI);
0117 mapDigiWheel_layer_.SetNbinsX(nNumVFATPerEta * stationInfo.nNumChambers_);
0118 mapDigiWheel_layer_.SetNbinsY(stationInfo.nNumEtaPartitions_);
0119 mapDigiWheel_layer_.bookND(bh, key);
0120
0121 mapDigiOcc_ieta_.SetBinConfX(stationInfo.nNumEtaPartitions_);
0122 mapDigiOcc_ieta_.bookND(bh, key);
0123 mapDigiOcc_ieta_.SetLabelForIEta(key, 1);
0124
0125 mapDigiOcc_phi_.SetBinLowEdgeX(stationInfo.fMinPhi_ * 180 / M_PI);
0126 mapDigiOcc_phi_.SetBinHighEdgeX(stationInfo.fMinPhi_ * 180 / M_PI + 360);
0127 mapDigiOcc_phi_.bookND(bh, key);
0128 mapTotalDigiPerEvtLayer_.bookND(bh, key);
0129
0130 return 0;
0131 }
0132
0133 int GEMDigiSource::ProcessWithMEMap3WithChamber(BookingHelper& bh, ME4IdsKey key) {
0134 ME3IdsKey key3 = key4Tokey3(key);
0135 MEStationInfo& stationInfo = mapStationInfo_[key3];
0136
0137 bh.getBooker()->setCurrentFolder(strFolderMain_ + "/occupancy_" + getNameDirLayer(key3));
0138
0139 int nNumVFATPerEta = stationInfo.nMaxVFAT_ / stationInfo.nNumEtaPartitions_;
0140 int nNumCh = stationInfo.nNumDigi_;
0141
0142 mapDigiOccPerCh_.SetBinConfX(nNumCh * nNumVFATPerEta, -0.5);
0143 mapDigiOccPerCh_.SetBinConfY(stationInfo.nNumEtaPartitions_);
0144 mapDigiOccPerCh_.bookND(bh, key);
0145 mapDigiOccPerCh_.SetLabelForIEta(key, 2);
0146
0147 bh.getBooker()->setCurrentFolder(strFolderMain_);
0148
0149 return 0;
0150 }
0151
0152 void GEMDigiSource::analyze(edm::Event const& event, edm::EventSetup const& eventSetup) {
0153 edm::Handle<GEMDigiCollection> gemDigis;
0154 event.getByToken(this->tagDigi_, gemDigis);
0155 edm::Handle<LumiScalersCollection> lumiScalers;
0156 event.getByToken(lumiScalers_, lumiScalers);
0157
0158 std::map<ME3IdsKey, Int_t> total_digi_layer;
0159 std::map<ME3IdsKey, Int_t> total_digi_eta;
0160 for (const auto& ch : gemChambers_) {
0161 GEMDetId gid = ch.id();
0162 ME2IdsKey key2{gid.region(), gid.station()};
0163 ME3IdsKey key3{gid.region(), gid.station(), gid.layer()};
0164 ME4IdsKey key4Ch{gid.region(), gid.station(), gid.layer(), gid.chamber()};
0165 std::map<Int_t, bool> bTagVFAT;
0166 bTagVFAT.clear();
0167 MEStationInfo& stationInfo = mapStationInfo_[key3];
0168 const BoundPlane& surface = GEMGeometry_->idToDet(gid)->surface();
0169 if (total_digi_layer.find(key3) == total_digi_layer.end())
0170 total_digi_layer[key3] = 0;
0171 for (auto iEta : ch.etaPartitions()) {
0172 GEMDetId eId = iEta->id();
0173 ME3IdsKey key3IEta{gid.region(), gid.station(), eId.ieta()};
0174 if (total_digi_eta.find(key3IEta) == total_digi_eta.end())
0175 total_digi_eta[key3IEta] = 0;
0176 const auto& digis_in_det = gemDigis->get(eId);
0177 for (auto d = digis_in_det.first; d != digis_in_det.second; ++d) {
0178
0179 Int_t nIdxVFAT = getVFATNumberByDigi(gid.station(), eId.ieta(), d->strip());
0180 mapTotalDigi_layer_.Fill(key3, gid.chamber(), nIdxVFAT);
0181
0182
0183 mapDigiOcc_ieta_.Fill(key3, eId.ieta());
0184
0185 GlobalPoint digi_global_pos = surface.toGlobal(iEta->centreOfStrip(d->strip()));
0186 Float_t fPhi = (Float_t)digi_global_pos.phi();
0187 Float_t fPhiShift = restrictAngle(fPhi, stationInfo.fMinPhi_);
0188 Float_t fPhiDeg = fPhiShift * 180.0 / M_PI;
0189 mapDigiOcc_phi_.Fill(key3, fPhiDeg);
0190
0191
0192 Float_t fR = fRadiusMin_ + (fRadiusMax_ - fRadiusMin_) * (eId.ieta() - 0.5) / stationInfo.nNumEtaPartitions_;
0193 mapDigiWheel_layer_.Fill(key3, fPhiShift, fR);
0194
0195 mapDigiOccPerCh_.Fill(key4Ch, d->strip(), eId.ieta());
0196
0197
0198 total_digi_layer[key3]++;
0199 total_digi_eta[key3IEta]++;
0200
0201
0202 Int_t nBX = std::min(std::max((Int_t)d->bx(), nBXMin_), nBXMax_);
0203 if (bTagVFAT.find(nIdxVFAT) == bTagVFAT.end()) {
0204 mapBX_.Fill(key2, nBX);
0205 }
0206
0207 bTagVFAT[nIdxVFAT] = true;
0208 }
0209 }
0210 }
0211 for (auto [key, num_total_digi] : total_digi_layer)
0212 mapTotalDigiPerEvtLayer_.Fill(key, num_total_digi);
0213 for (auto [key, num_total_digi] : total_digi_eta)
0214 mapTotalDigiPerEvtIEta_.Fill(key, num_total_digi);
0215 }
0216
0217 DEFINE_FWK_MODULE(GEMDigiSource);