Skip to content

Commit

Permalink
Merge pull request #34301 from jfernan2/makeNanoDQMIOwork
Browse files Browse the repository at this point in the history
[DQM] Make nanoDQMIO work
  • Loading branch information
cmsbuild authored Jul 13, 2021
2 parents 964d203 + cf44883 commit b5a6b22
Show file tree
Hide file tree
Showing 29 changed files with 237 additions and 141 deletions.
38 changes: 21 additions & 17 deletions DQM/BeamMonitor/plugins/AlcaBeamMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ AlcaBeamMonitor::AlcaBeamMonitor(const ParameterSet& ps)
trackLabel_(consumes<reco::TrackCollection>(ps.getUntrackedParameter<InputTag>("TrackLabel"))),
scalerLabel_(consumes<BeamSpot>(ps.getUntrackedParameter<InputTag>("ScalerLabel"))),
beamSpotToken_(esConsumes<edm::Transition::BeginLuminosityBlock>()),
perLSsaving_(ps.getUntrackedParameter<bool>("perLSsaving", false)),
numberOfValuesToSave_(0) {
if (!monitorName_.empty())
monitorName_ = monitorName_ + "/";
Expand All @@ -55,23 +56,25 @@ AlcaBeamMonitor::AlcaBeamMonitor(const ParameterSet& ps)
varNamesV_.push_back("sigmaY");
varNamesV_.push_back("sigmaZ");

histoByCategoryNames_.insert(pair<string, string>("run", "Coordinate"));
histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex fit-DataBase"));
histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex fit-BeamFit"));
histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex fit-Scalers"));
histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex-DataBase"));
histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex-BeamFit"));
histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex-Scalers"));

histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased BeamSpotFit"));
histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased PrimaryVertex"));
histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased DataBase"));
histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased Scalers"));
histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased PrimaryVertex-DataBase fit"));
histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased PrimaryVertex-Scalers fit"));
histoByCategoryNames_.insert(pair<string, string>("validation", "Lumibased Scalers-DataBase fit"));
histoByCategoryNames_.insert(pair<string, string>("validation", "Lumibased PrimaryVertex-DataBase"));
histoByCategoryNames_.insert(pair<string, string>("validation", "Lumibased PrimaryVertex-Scalers"));
if (!perLSsaving_) {
histoByCategoryNames_.insert(pair<string, string>("run", "Coordinate"));
histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex fit-DataBase"));
histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex fit-BeamFit"));
histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex fit-Scalers"));
histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex-DataBase"));
histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex-BeamFit"));
histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex-Scalers"));

histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased BeamSpotFit"));
histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased PrimaryVertex"));
histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased DataBase"));
histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased Scalers"));
histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased PrimaryVertex-DataBase fit"));
histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased PrimaryVertex-Scalers fit"));
histoByCategoryNames_.insert(pair<string, string>("validation", "Lumibased Scalers-DataBase fit"));
histoByCategoryNames_.insert(pair<string, string>("validation", "Lumibased PrimaryVertex-DataBase"));
histoByCategoryNames_.insert(pair<string, string>("validation", "Lumibased PrimaryVertex-Scalers"));
}

for (vector<string>::iterator itV = varNamesV_.begin(); itV != varNamesV_.end(); itV++) {
for (multimap<string, string>::iterator itM = histoByCategoryNames_.begin(); itM != histoByCategoryNames_.end();
Expand All @@ -88,6 +91,7 @@ void AlcaBeamMonitor::fillDescriptions(edm::ConfigurationDescriptions& iDesc) {
ps.addUntracked<edm::InputTag>("PrimaryVertexLabel");
ps.addUntracked<edm::InputTag>("TrackLabel");
ps.addUntracked<edm::InputTag>("ScalerLabel");
ps.addUntracked<bool>("perLSsaving");

BeamFitter::fillDescription(ps);
PVFitter::fillDescription(ps);
Expand Down
1 change: 1 addition & 0 deletions DQM/BeamMonitor/plugins/AlcaBeamMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class AlcaBeamMonitor : public DQMOneEDAnalyzer<edm::LuminosityBlockCache<alcabe
const edm::EDGetTokenT<reco::TrackCollection> trackLabel_;
const edm::EDGetTokenT<reco::BeamSpot> scalerLabel_;
const edm::ESGetToken<BeamSpotObjects, BeamSpotObjectsRcd> beamSpotToken_;
bool perLSsaving_; //to avoid nanoDQMIO crashing, driven by DQMServices/Core/python/DQMStore_cfi.py

//Service variables
int numberOfValuesToSave_;
Expand Down
5 changes: 4 additions & 1 deletion DQM/BeamMonitor/python/AlcaBeamMonitorHeavyIons_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
AlcaBeamMonitor.BeamFitter.TrackCollection = 'hiGeneralTracks'
AlcaBeamMonitor.BeamFitter.TrackQuality = ['highPurity']
AlcaBeamMonitor.PVFitter.VertexCollection = 'hiSelectedVertex'

#Check if perLSsaving is enabled to mask MEs vs LS
from DQMServices.Core.DQMStore_cfi import DQMStore
if(DQMStore.saveByLumi):
AlcaBeamMonitor.perLSsaving=True
import RecoVertex.BeamSpotProducer.BeamSpotOnline_cfi
scalerBeamSpot = RecoVertex.BeamSpotProducer.BeamSpotOnline_cfi.onlineBeamSpotProducer.clone()
alcaBeamMonitor = cms.Sequence( scalerBeamSpot*AlcaBeamMonitor )
Expand Down
7 changes: 7 additions & 0 deletions DQM/BeamMonitor/python/AlcaBeamMonitor_cff.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import FWCore.ParameterSet.Config as cms

from DQM.BeamMonitor.AlcaBeamMonitor_cfi import *
#Check if perLSsaving is enabled to mask MEs vs LS
from DQMServices.Core.DQMStore_cfi import DQMStore
if(DQMStore.saveByLumi):
AlcaBeamMonitor.perLSsaving=True

import RecoVertex.BeamSpotProducer.BeamSpotOnline_cfi
scalerBeamSpot = RecoVertex.BeamSpotProducer.BeamSpotOnline_cfi.onlineBeamSpotProducer.clone()

alcaBeamMonitor = cms.Sequence( scalerBeamSpot*AlcaBeamMonitor )


1 change: 1 addition & 0 deletions DQM/BeamMonitor/python/AlcaBeamMonitor_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
AlcaBeamMonitor = DQMEDAnalyzer('AlcaBeamMonitor',
MonitorName = cms.untracked.string('AlcaBeamMonitor'),
PrimaryVertexLabel = cms.untracked.InputTag('offlinePrimaryVertices'),
perLSsaving = cms.untracked.bool(False), #driven by DQMServices/Core/python/DQMStore_cfi.py
#TrackLabel = cms.untracked.InputTag('ALCARECOTkAlMinBias'),
TrackLabel = cms.untracked.InputTag('generalTracks'),
ScalerLabel = cms.untracked.InputTag('scalerBeamSpot'),
Expand Down
10 changes: 7 additions & 3 deletions DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class CTPPSCommonDQMSource : public DQMOneEDAnalyzer<edm::LuminosityBlockCache<s
const edm::EDGetTokenT<std::vector<reco::ForwardProton>> tokenRecoProtons;

bool makeProtonRecoPlots_;
bool perLSsaving_; //to avoid nanoDQMIO crashing, driven by DQMServices/Core/python/DQMStore_cfi.py

int currentLS;
int endLS;
Expand Down Expand Up @@ -287,7 +288,8 @@ CTPPSCommonDQMSource::CTPPSCommonDQMSource(const edm::ParameterSet &ps)
ctppsRecordToken(consumes<CTPPSRecord>(ps.getUntrackedParameter<edm::InputTag>("ctppsmetadata"))),
tokenLocalTrackLite(consumes<vector<CTPPSLocalTrackLite>>(ps.getParameter<edm::InputTag>("tagLocalTrackLite"))),
tokenRecoProtons(consumes<std::vector<reco::ForwardProton>>(ps.getParameter<InputTag>("tagRecoProtons"))),
makeProtonRecoPlots_(ps.getParameter<bool>("makeProtonRecoPlots")) {
makeProtonRecoPlots_(ps.getParameter<bool>("makeProtonRecoPlots")),
perLSsaving_(ps.getUntrackedParameter<bool>("perLSsaving", false)) {
currentLS = 0;
endLS = 0;
rpstate.clear();
Expand Down Expand Up @@ -545,8 +547,10 @@ std::shared_ptr<std::vector<int>> CTPPSCommonDQMSource::globalBeginLuminosityBlo
void CTPPSCommonDQMSource::globalEndLuminosityBlock(const edm::LuminosityBlock &iLumi, const edm::EventSetup &c) {
auto const &rpstate = *luminosityBlockCache(iLumi.index());
auto currentLS = iLumi.id().luminosityBlock();
for (std::vector<int>::size_type i = 0; i < rpstate.size(); i++)
globalPlots.RPState->setBinContent(currentLS, i + 1, rpstate[i]);
if (!perLSsaving_) {
for (std::vector<int>::size_type i = 0; i < rpstate.size(); i++)
globalPlots.RPState->setBinContent(currentLS, i + 1, rpstate[i]);
}
}

//----------------------------------------------------------------------------------------------------
Expand Down
137 changes: 73 additions & 64 deletions DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class CTPPSDiamondDQMSource : public DQMOneEDAnalyzer<edm::LuminosityBlockCache<
edm::ESGetToken<CTPPSGeometry, VeryForwardRealGeometryRecord> ctppsGeometryEventToken_;

bool excludeMultipleHits_;
bool perLSsaving_; //to avoid nanoDQMIO crashing, driven by DQMServices/Core/python/DQMStore_cfi.py
double horizontalShiftBwDiamondPixels_;
double horizontalShiftOfDiamond_;
std::vector<std::pair<edm::EventRange, int>> runParameters_;
Expand Down Expand Up @@ -486,6 +487,7 @@ CTPPSDiamondDQMSource::CTPPSDiamondDQMSource(const edm::ParameterSet& ps)
ctppsGeometryRunToken_(esConsumes<CTPPSGeometry, VeryForwardRealGeometryRecord, edm::Transition::BeginRun>()),
ctppsGeometryEventToken_(esConsumes<CTPPSGeometry, VeryForwardRealGeometryRecord>()),
excludeMultipleHits_(ps.getParameter<bool>("excludeMultipleHits")),
perLSsaving_(ps.getUntrackedParameter<bool>("perLSsaving", false)),
centralOOT_(-999),
verbosity_(ps.getUntrackedParameter<unsigned int>("verbosity", 0)),
EC_difference_56_(-500),
Expand Down Expand Up @@ -554,9 +556,11 @@ std::shared_ptr<dds::Cache> CTPPSDiamondDQMSource::globalBeginLuminosityBlock(co
const edm::EventSetup&) const {
auto d = std::make_shared<dds::Cache>();
d->hitDistribution2dMap.reserve(potPlots_.size());
for (auto& plot : potPlots_)
d->hitDistribution2dMap[plot.first] =
std::unique_ptr<TH2F>(static_cast<TH2F*>(plot.second.hitDistribution2d_lumisection->getTH2F()->Clone()));
if (!perLSsaving_) {
for (auto& plot : potPlots_)
d->hitDistribution2dMap[plot.first] =
std::unique_ptr<TH2F>(static_cast<TH2F*>(plot.second.hitDistribution2d_lumisection->getTH2F()->Clone()));
}
return d;
}

Expand Down Expand Up @@ -747,12 +751,14 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet
hitHistoTmp->Fill(detId.plane() + UFSDShift, hitHistoTmpYAxis->GetBinCenter(startBin + i));
}

hitHistoTmp = lumiCache->hitDistribution2dMap[detId_pot].get();
hitHistoTmpYAxis = hitHistoTmp->GetYaxis();
startBin = hitHistoTmpYAxis->FindBin(rechit.x() - horizontalShiftOfDiamond_ - 0.5 * rechit.xWidth());
numOfBins = rechit.xWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
for (int i = 0; i < numOfBins; ++i) {
hitHistoTmp->Fill(detId.plane() + UFSDShift, hitHistoTmpYAxis->GetBinCenter(startBin + i));
if (!perLSsaving_) {
hitHistoTmp = lumiCache->hitDistribution2dMap[detId_pot].get();
hitHistoTmpYAxis = hitHistoTmp->GetYaxis();
startBin = hitHistoTmpYAxis->FindBin(rechit.x() - horizontalShiftOfDiamond_ - 0.5 * rechit.xWidth());
numOfBins = rechit.xWidth() * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
for (int i = 0; i < numOfBins; ++i) {
hitHistoTmp->Fill(detId.plane() + UFSDShift, hitHistoTmpYAxis->GetBinCenter(startBin + i));
}
}
}

Expand Down Expand Up @@ -1129,71 +1135,74 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet

void CTPPSDiamondDQMSource::globalEndLuminosityBlock(const edm::LuminosityBlock& iLumi, const edm::EventSetup&) {
auto lumiCache = luminosityBlockCache(iLumi.index());
for (auto& plot : potPlots_) {
*(plot.second.hitDistribution2d_lumisection->getTH2F()) = *(lumiCache->hitDistribution2dMap[plot.first]);
}
for (auto& plot : channelPlots_) {
auto hitsCounterPerLumisection = lumiCache->hitsCounterMap[plot.first];
if (hitsCounterPerLumisection != 0) {
plot.second.hit_rate->Fill((double)hitsCounterPerLumisection / SEC_PER_LUMI_SECTION);
if (!perLSsaving_) {
for (auto& plot : potPlots_) {
*(plot.second.hitDistribution2d_lumisection->getTH2F()) = *(lumiCache->hitDistribution2dMap[plot.first]);
}

double HundredOverHitCounter = .0;
if (plot.second.HitCounter != 0)
HundredOverHitCounter = 100. / plot.second.HitCounter;
plot.second.HPTDCErrorFlags->setBinContent(16, HundredOverHitCounter * plot.second.MHCounter);
plot.second.leadingWithoutTrailing->setBinContent(1, HundredOverHitCounter * plot.second.LeadingOnlyCounter);
plot.second.leadingWithoutTrailing->setBinContent(2, HundredOverHitCounter * plot.second.TrailingOnlyCounter);
plot.second.leadingWithoutTrailing->setBinContent(3, HundredOverHitCounter * plot.second.CompleteCounter);
}

for (auto& plot : potPlots_) {
double HundredOverHitCounterPot = 0.;
if (plot.second.HitCounter != 0)
HundredOverHitCounterPot = 100. / plot.second.HitCounter;
plot.second.leadingWithoutTrailingCumulativePot->setBinContent(
1, HundredOverHitCounterPot * plot.second.LeadingOnlyCounter);
plot.second.leadingWithoutTrailingCumulativePot->setBinContent(
2, HundredOverHitCounterPot * plot.second.TrailingOnlyCounter);
plot.second.leadingWithoutTrailingCumulativePot->setBinContent(
3, HundredOverHitCounterPot * plot.second.CompleteCounter);

plot.second.MHComprensive->Reset();
CTPPSDiamondDetId rpId(plot.first);
for (auto& chPlot : channelPlots_) {
CTPPSDiamondDetId chId(chPlot.first);
if (chId.arm() == rpId.arm() && chId.rp() == rpId.rp()) {
plot.second.MHComprensive->Fill(chId.plane(), chId.channel(), chPlot.second.HPTDCErrorFlags->getBinContent(16));
for (auto& plot : channelPlots_) {
auto hitsCounterPerLumisection = lumiCache->hitsCounterMap[plot.first];
if (hitsCounterPerLumisection != 0) {
plot.second.hit_rate->Fill((double)hitsCounterPerLumisection / SEC_PER_LUMI_SECTION);
}

double HundredOverHitCounter = .0;
if (plot.second.HitCounter != 0)
HundredOverHitCounter = 100. / plot.second.HitCounter;
plot.second.HPTDCErrorFlags->setBinContent(16, HundredOverHitCounter * plot.second.MHCounter);
plot.second.leadingWithoutTrailing->setBinContent(1, HundredOverHitCounter * plot.second.LeadingOnlyCounter);
plot.second.leadingWithoutTrailing->setBinContent(2, HundredOverHitCounter * plot.second.TrailingOnlyCounter);
plot.second.leadingWithoutTrailing->setBinContent(3, HundredOverHitCounter * plot.second.CompleteCounter);
}
}

// Efficiencies of single channels
for (auto& plot : potPlots_) {
plot.second.EfficiencyOfChannelsInPot->Reset();
for (auto& element : plot.second.effTriplecountingChMap) {
if (plot.second.effDoublecountingChMap[element.first] > 0) {
int plane = element.first / 100;
int channel = element.first % 100;
double counted = element.second;
double total = plot.second.effDoublecountingChMap[element.first];
double efficiency = counted / total;
// double error = std::sqrt( efficiency * ( 1 - efficiency ) / total );

plot.second.EfficiencyOfChannelsInPot->Fill(plane, channel, 100 * efficiency);
for (auto& plot : potPlots_) {
double HundredOverHitCounterPot = 0.;
if (plot.second.HitCounter != 0)
HundredOverHitCounterPot = 100. / plot.second.HitCounter;
plot.second.leadingWithoutTrailingCumulativePot->setBinContent(
1, HundredOverHitCounterPot * plot.second.LeadingOnlyCounter);
plot.second.leadingWithoutTrailingCumulativePot->setBinContent(
2, HundredOverHitCounterPot * plot.second.TrailingOnlyCounter);
plot.second.leadingWithoutTrailingCumulativePot->setBinContent(
3, HundredOverHitCounterPot * plot.second.CompleteCounter);

plot.second.MHComprensive->Reset();
CTPPSDiamondDetId rpId(plot.first);
for (auto& chPlot : channelPlots_) {
CTPPSDiamondDetId chId(chPlot.first);
if (chId.arm() == rpId.arm() && chId.rp() == rpId.rp()) {
plot.second.MHComprensive->Fill(
chId.plane(), chId.channel(), chPlot.second.HPTDCErrorFlags->getBinContent(16));
}
}
}
// Efficiencies of single channels
for (auto& plot : potPlots_) {
plot.second.EfficiencyOfChannelsInPot->Reset();
for (auto& element : plot.second.effTriplecountingChMap) {
if (plot.second.effDoublecountingChMap[element.first] > 0) {
int plane = element.first / 100;
int channel = element.first % 100;
double counted = element.second;
double total = plot.second.effDoublecountingChMap[element.first];
double efficiency = counted / total;
// double error = std::sqrt( efficiency * ( 1 - efficiency ) / total );

plot.second.EfficiencyOfChannelsInPot->Fill(plane, channel, 100 * efficiency);
}
}
}
}

// Efficeincy wrt pixels //TODO
for (auto& plot : planePlots_) {
TH2F* hitHistoTmp = plot.second.EfficiencyWRTPixelsInPlane->getTH2F();
// Efficeincy wrt pixels //TODO
for (auto& plot : planePlots_) {
TH2F* hitHistoTmp = plot.second.EfficiencyWRTPixelsInPlane->getTH2F();

CTPPSDiamondDetId detId_pot(plot.first);
detId_pot.setPlane(0);
CTPPSDiamondDetId detId_pot(plot.first);
detId_pot.setPlane(0);

hitHistoTmp->Divide(&(plot.second.pixelTracksMapWithDiamonds), &(potPlots_[detId_pot].pixelTracksMap));
}
hitHistoTmp->Divide(&(plot.second.pixelTracksMapWithDiamonds), &(potPlots_[detId_pot].pixelTracksMap));
}
} //perLSsaving
}

//----------------------------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit b5a6b22

Please sign in to comment.