Skip to content

Commit

Permalink
Fix accessing data from ES
Browse files Browse the repository at this point in the history
  • Loading branch information
abhih1 committed Jul 6, 2021
1 parent 7c10d4b commit ba94b0e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 66 deletions.
5 changes: 4 additions & 1 deletion DQM/EcalMonitorTasks/interface/OccupancyTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbRecord.h"
#include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbService.h"
#include "DataFormats/Provenance/interface/Timestamp.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

namespace ecaldqm {
class OccupancyTask : public DQWorkerTask {
Expand All @@ -29,9 +30,11 @@ namespace ecaldqm {
void runOnTPDigis(EcalTrigPrimDigiCollection const&);
void runOnRecHits(EcalRecHitCollection const&, Collections);
void setEventTime(const edm::TimeValue_t& iTime);
void setTokens(edm::ConsumesCollector&) override;

private:
void setParams(edm::ParameterSet const&) override;
edm::ESHandle<EcalLaserDbService> laser;
edm::ESGetToken<EcalLaserDbService, EcalLaserDbRecord> lasertoken_;
bool FillLaser = false;
float recHitThreshold_;
float tpThreshold_;
Expand Down
6 changes: 3 additions & 3 deletions DQM/EcalMonitorTasks/interface/PresampleTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "FWCore/Framework/interface/ESHandle.h"
#include "CondFormats/EcalObjects/interface/EcalPedestals.h"
#include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

namespace ecaldqm {
class PresampleTask : public DQWorkerTask {
Expand All @@ -23,17 +24,16 @@ namespace ecaldqm {

template <typename DigiCollection>
void runOnDigis(DigiCollection const&);
void setTokens(edm::ConsumesCollector&) override;

private:
void setParams(edm::ParameterSet const&) override;

edm::ESGetToken<EcalPedestals, EcalPedestalsRcd> Pedtoken_;
bool doPulseMaxCheck_;
int pulseMaxPosition_;
int nSamples_;
MESet* mePedestalByLS;
bool FillPedestal = false;
edm::ESHandle<EcalPedestals> pPeds;

};

inline bool PresampleTask::analyze(void const* _p, Collections _collection) {
Expand Down
60 changes: 25 additions & 35 deletions DQM/EcalMonitorTasks/src/OccupancyTask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace ecaldqm {
tpThreshold_ = _params.getUntrackedParameter<double>("tpThreshold");
}

void OccupancyTask::setTokens(edm::ConsumesCollector& _collector) { lasertoken_ = _collector.esConsumes(); }

bool OccupancyTask::filterRunType(short const* _runType) {
for (int iFED(0); iFED < 54; iFED++) {
if (_runType[iFED] == EcalDCCHeaderBlock::COSMIC || _runType[iFED] == EcalDCCHeaderBlock::MTCC ||
Expand All @@ -23,54 +25,42 @@ namespace ecaldqm {

return false;
}

void OccupancyTask::beginRun(edm::Run const&, edm::EventSetup const& _es)
{

_es.get<EcalLaserDbRecord>().get(laser);
FillLaser = true;

}
void OccupancyTask::setEventTime(const edm::TimeValue_t& iTime) {
m_iTime = iTime;
}

void OccupancyTask::beginRun(edm::Run const&, edm::EventSetup const& _es) { FillLaser = true; }
void OccupancyTask::setEventTime(const edm::TimeValue_t& iTime) { m_iTime = iTime; }
void OccupancyTask::beginEvent(edm::Event const& _evt,
edm::EventSetup const& _es,
bool const& ByLumiResetSwitch,
bool&) {
bool&) {
if (ByLumiResetSwitch) {
MEs_.at("DigiAllByLumi").reset(GetElectronicsMap());
MEs_.at("TPDigiThrAllByLumi").reset(GetElectronicsMap());
MEs_.at("RecHitThrAllByLumi").reset(GetElectronicsMap());
}
MESet& meLaserCorrProjEta(MEs_.at("LaserCorrProjEta"));
if (FillLaser){
for ( int i = 0; i < EBDetId::kSizeForDenseIndexing; i++ ) {
if ( !EBDetId::validDenseIndex(i) ) continue;
EBDetId ebid( EBDetId::unhashIndex(i) );

const edm::Timestamp& evtTimeStamp = edm::Timestamp(m_iTime);

float lasercalib = 1.;
lasercalib = laser->getLaserCorrection( ebid, evtTimeStamp);
if (FillLaser) {
float lasercalib = 1.;
auto const& laser = &_es.getData(lasertoken_);
const edm::Timestamp& evtTimeStamp = edm::Timestamp(m_iTime);

for (int i = 0; i < EBDetId::kSizeForDenseIndexing; i++) {
if (!EBDetId::validDenseIndex(i))
continue;
EBDetId ebid(EBDetId::unhashIndex(i));
lasercalib = laser->getLaserCorrection(ebid, evtTimeStamp);
meLaserCorrProjEta.fill(getEcalDQMSetupObjects(), ebid, lasercalib);
}

}

for ( int i = 0; i < EEDetId::kSizeForDenseIndexing; i++ ) {
if ( !EEDetId::validDenseIndex(i) ) continue;
EEDetId eeid( EEDetId::unhashIndex(i) );

const edm::Timestamp& evtTimeStamp = edm::Timestamp(m_iTime);

float lasercalib = 1.;
lasercalib = laser->getLaserCorrection( eeid, evtTimeStamp);
for (int i = 0; i < EEDetId::kSizeForDenseIndexing; i++) {
if (!EEDetId::validDenseIndex(i))
continue;
EEDetId eeid(EEDetId::unhashIndex(i));
lasercalib = laser->getLaserCorrection(eeid, evtTimeStamp);
meLaserCorrProjEta.fill(getEcalDQMSetupObjects(), eeid, lasercalib);

}
FillLaser = false;
}
FillLaser = false;
}
}
}

void OccupancyTask::runOnRawData(EcalRawDataCollection const& _dcchs) {
MESet& meDCC(MEs_.at("DCC"));
Expand Down
51 changes: 24 additions & 27 deletions DQM/EcalMonitorTasks/src/PresampleTask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace ecaldqm {
pulseMaxPosition_ = _params.getUntrackedParameter<int>("pulseMaxPosition");
nSamples_ = _params.getUntrackedParameter<int>("nSamples");
}
void PresampleTask::setTokens(edm::ConsumesCollector& _collector) { Pedtoken_ = _collector.esConsumes(); }

bool PresampleTask::filterRunType(short const* _runType) {
for (int iFED(0); iFED < nDCC; iFED++) {
Expand All @@ -29,12 +30,7 @@ namespace ecaldqm {
return false;
}

void PresampleTask::beginRun(edm::Run const&, edm::EventSetup const& _es)
{
_es.get<EcalPedestalsRcd>().get(pPeds);
FillPedestal = true;
}

void PresampleTask::beginRun(edm::Run const&, edm::EventSetup const& _es) { FillPedestal = true; }

void PresampleTask::beginEvent(edm::Event const& _evt,
edm::EventSetup const& _es,
Expand All @@ -53,33 +49,34 @@ void PresampleTask::beginRun(edm::Run const&, edm::EventSetup const& _es)
MESet& mePedestalProjEtaG6(MEs_.at("PedestalProjEtaG6"));
MESet& mePedestalProjEtaG12(MEs_.at("PedestalProjEtaG12"));

if (FillPedestal){
const EcalPedestals* myped = pPeds.product();
if (FillPedestal) {
const EcalPedestals* myped = &_es.getData(Pedtoken_);

for ( int i = 0; i < EBDetId::kSizeForDenseIndexing; i++ ) {
if ( !EBDetId::validDenseIndex(i) ) continue;
EBDetId ebid( EBDetId::unhashIndex(i) );
for (int i = 0; i < EBDetId::kSizeForDenseIndexing; i++) {
if (!EBDetId::validDenseIndex(i))
continue;
EBDetId ebid(EBDetId::unhashIndex(i));
EcalPedestals::const_iterator it = myped->find(ebid.rawId());
if (it != myped->end()) {
mePedestalProjEtaG1.fill(getEcalDQMSetupObjects(), ebid, (*it).rms_x1);
mePedestalProjEtaG6.fill(getEcalDQMSetupObjects(), ebid, (*it).rms_x6);
mePedestalProjEtaG12.fill(getEcalDQMSetupObjects(), ebid, (*it).rms_x12);
}
}
for ( int i = 0; i < EEDetId::kSizeForDenseIndexing; i++ ) {
if ( !EEDetId::validDenseIndex(i) ) continue;
EEDetId eeid( EEDetId::unhashIndex(i) );
mePedestalProjEtaG1.fill(getEcalDQMSetupObjects(), ebid, (*it).rms_x1);
mePedestalProjEtaG6.fill(getEcalDQMSetupObjects(), ebid, (*it).rms_x6);
mePedestalProjEtaG12.fill(getEcalDQMSetupObjects(), ebid, (*it).rms_x12);
}
}
for (int i = 0; i < EEDetId::kSizeForDenseIndexing; i++) {
if (!EEDetId::validDenseIndex(i))
continue;
EEDetId eeid(EEDetId::unhashIndex(i));
EcalPedestals::const_iterator it = myped->find(eeid.rawId());
if (it != myped->end()) {
mePedestalProjEtaG1.fill(getEcalDQMSetupObjects(), eeid, (*it).rms_x1);
mePedestalProjEtaG6.fill(getEcalDQMSetupObjects(), eeid, (*it).rms_x6);
mePedestalProjEtaG12.fill(getEcalDQMSetupObjects(), eeid, (*it).rms_x12);
}
}

FillPedestal = false;
}
mePedestalProjEtaG1.fill(getEcalDQMSetupObjects(), eeid, (*it).rms_x1);
mePedestalProjEtaG6.fill(getEcalDQMSetupObjects(), eeid, (*it).rms_x6);
mePedestalProjEtaG12.fill(getEcalDQMSetupObjects(), eeid, (*it).rms_x12);
}
}

FillPedestal = false;
}
}

template <typename DigiCollection>
Expand Down

0 comments on commit ba94b0e

Please sign in to comment.