Skip to content

Commit

Permalink
Merge pull request #20418 from argiro/ecalPedestalPCLfixes_92x_v2
Browse files Browse the repository at this point in the history
Ecal pedestal pcl fixes 92x v2
  • Loading branch information
cmsbuild committed Sep 11, 2017
2 parents 7c7cf4a + 2139936 commit cd78fdb
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 58 deletions.
13 changes: 10 additions & 3 deletions Calibration/EcalCalibAlgos/interface/ECALpedestalPCLHarvester.h
Expand Up @@ -27,19 +27,21 @@

#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "DataFormats/EcalDetId/interface/EBDetId.h"
#include "DataFormats/EcalDetId/interface/EEDetId.h"
#include "CondFormats/EcalObjects/interface/EcalPedestals.h"
#include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"

class ECALpedestalPCLHarvester : public DQMEDHarvester {
public:
explicit ECALpedestalPCLHarvester(const edm::ParameterSet& ps);
virtual void endRun(edm::Run const& run, edm::EventSetup const & isetup);
void endRun(edm::Run const& run, edm::EventSetup const & isetup) override;
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);


private:

virtual void dqmEndJob(DQMStore::IBooker& ibooker_, DQMStore::IGetter& igetter_) ;
void dqmEndJob(DQMStore::IBooker& ibooker_, DQMStore::IGetter& igetter_) override ;

void dqmPlots(const EcalPedestals& newpeds, DQMStore::IBooker& ibooker);

Expand All @@ -52,11 +54,16 @@ class ECALpedestalPCLHarvester : public DQMEDHarvester {
bool checkVariation(const EcalPedestalsMap& oldPedestals, const EcalPedestalsMap& newPedestals);
std::vector<int> chStatusToExclude_;
int minEntries_;



int entriesEB_[EBDetId::kSizeForDenseIndexing];
int entriesEE_[EEDetId::kSizeForDenseIndexing];
bool checkAnomalies_ ; // whether or not to avoid creating sqlite file in case of many changed pedestals
double nSigma_; // threshold in sigmas to define a pedestal as changed
double thresholdAnomalies_; // threshold (fraction of changed pedestals) to avoid creation of sqlite file
std::string dqmDir_; // DQM directory where histograms are stored
std::string labelG6G1_; // DB label from which pedestals for G6 and G1 are to be copied
float threshDiffEB_; // if the new pedestals differs more than this from old, keep old
float threshDiffEE_; // same as above for EE. Stray channel protection

};
11 changes: 6 additions & 5 deletions Calibration/EcalCalibAlgos/interface/ECALpedestalPCLworker.h
Expand Up @@ -26,7 +26,7 @@

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"

#include <DataFormats/Scalers/interface/BSTRecord.h>
//
// class declaration
//
Expand All @@ -41,14 +41,14 @@ class ECALpedestalPCLworker : public DQMEDAnalyzer {

private:
virtual void beginJob() ;
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &);
virtual void analyze(const edm::Event&, const edm::EventSetup&) ;
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
void analyze(const edm::Event&, const edm::EventSetup&) override ;
virtual void endJob() ;

edm::InputTag digiTagEB_;
edm::InputTag digiTagEE_;

edm::EDGetTokenT<EBDigiCollection> digiTokenEB_;
edm::EDGetTokenT<EEDigiCollection> digiTokenEE_;
edm::EDGetTokenT<BSTRecord> bstToken_;

std::vector<MonitorElement *> meEB_;
std::vector<MonitorElement *> meEE_;
Expand All @@ -65,6 +65,7 @@ class ECALpedestalPCLworker : public DQMEDAnalyzer {
int nBins_ ; // number of bins per histogram
std::string dqmDir_; // DQM directory where histograms are stored

bool requireStableBeam_;

// compare ADC values
static bool adc_compare(uint16_t a, uint16_t b) { return ( a&0xFFF ) < (b&0xFFF);}
Expand Down
Expand Up @@ -16,6 +16,7 @@
ALCARECOEcalPedestals = ecalpedestalPCL.clone()
ALCARECOEcalPedestals.BarrelDigis = cms.InputTag('ALCARECOEcalPedestalsDigis', 'ebDigis')
ALCARECOEcalPedestals.EndcapDigis = cms.InputTag('ALCARECOEcalPedestalsDigis', 'eeDigis')
ALCARECOEcalPedestals.bstRecord = cms.InputTag('ALCALRECOEcalTCDSDigis', 'bstRecord')


MEtoEDMConvertEcalPedestals = cms.EDProducer("MEtoEDMConverter",
Expand All @@ -29,8 +30,12 @@
deleteAfterCopy=cms.untracked.bool(True)
)

ALCALRECOEcalTCDSDigis = cms.EDProducer('TcdsRawToDigi')
ALCALRECOEcalTCDSDigis.InputLabel = cms.InputTag('hltEcalCalibrationRaw')

# The actual sequence
seqALCARECOPromptCalibProdEcalPedestals = cms.Sequence(ALCARECOEcalTestPulsesRaw *
seqALCARECOPromptCalibProdEcalPedestals = cms.Sequence(ALCALRECOEcalTCDSDigis *
ALCARECOEcalTestPulsesRaw *
ALCARECOEcalPedestalsDigis *
ALCARECOEcalPedestals *
MEtoEDMConvertEcalPedestals)
Expand Up @@ -9,4 +9,7 @@
thresholdAnomalies = cms.double(0.1),# threshold (fraction of changed pedestals) to avoid creation of sqlite file
dqmDir = cms.string('AlCaReco/EcalPedestalsPCL'),
labelG6G1 = cms.string('HLT'), #use the HLT tag as source for G6 and G1 pedestals
threshDiffEB= cms.double(5.0), # if pedestal has changed more then this wrt old value, keep old value. Unit = ADC count
threshDiffEE= cms.double(8.0),

)
Expand Up @@ -3,6 +3,8 @@
ecalpedestalPCL =cms.EDAnalyzer('ECALpedestalPCLworker',
BarrelDigis=cms.InputTag('ecalDigis','ebDigis'),
EndcapDigis=cms.InputTag('ecalDigis','eeDigis'),
bstRecord =cms.InputTag('tcdsDigis','bstRecord'),
requireStableBeam = cms.bool(True),
pedestalSamples=cms.uint32(2), # number of presamples to be used for pedestal determination
checkSignal = cms.bool(False), # whether or not to exclude digis containing a signal
sThresholdEB = cms.uint32(10), # threshold to define a digi as containing signal
Expand Down
72 changes: 45 additions & 27 deletions Calibration/EcalCalibAlgos/src/ECALpedestalPCLHarvester.cc
Expand Up @@ -4,8 +4,6 @@

// user include files
#include "Calibration/EcalCalibAlgos/interface/ECALpedestalPCLHarvester.h"
#include "DataFormats/EcalDetId/interface/EBDetId.h"
#include "DataFormats/EcalDetId/interface/EEDetId.h"
#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
Expand All @@ -18,7 +16,7 @@
#include <string>

ECALpedestalPCLHarvester::ECALpedestalPCLHarvester(const edm::ParameterSet& ps):
currentPedestals_(0),channelStatus_(0){
currentPedestals_(nullptr),channelStatus_(nullptr){

chStatusToExclude_= StringToEnumValue<EcalChannelStatusCode::Code>(ps.getParameter<std::vector<std::string> >("ChannelStatusToExclude"));
minEntries_=ps.getParameter<int>("MinEntries");
Expand All @@ -27,6 +25,8 @@ ECALpedestalPCLHarvester::ECALpedestalPCLHarvester(const edm::ParameterSet& ps):
thresholdAnomalies_ = ps.getParameter<double>("thresholdAnomalies");
dqmDir_ = ps.getParameter<std::string>("dqmDir");
labelG6G1_ = ps.getParameter<std::string>("labelG6G1");
threshDiffEB_ = ps.getParameter<double>("threshDiffEB");
threshDiffEE_ = ps.getParameter<double>("threshDiffEE");
}

void ECALpedestalPCLHarvester::dqmEndJob(DQMStore::IBooker& ibooker_, DQMStore::IGetter& igetter_) {
Expand All @@ -41,6 +41,7 @@ void ECALpedestalPCLHarvester::dqmEndJob(DQMStore::IBooker& ibooker_, DQMStore::
MonitorElement* ch= igetter_.get(hname);
double mean = ch->getMean();
double rms = ch->getRMS();
entriesEB_[i] = ch->getEntries();

DetId id = EBDetId::detIdFromDenseIndex(i);
EcalPedestal ped;
Expand All @@ -50,8 +51,10 @@ void ECALpedestalPCLHarvester::dqmEndJob(DQMStore::IBooker& ibooker_, DQMStore::
ped.mean_x12=mean;
ped.rms_x12=rms;

// if bad channel or low stat skip
if(ch->getEntries()< minEntries_ || !checkStatusCode(id)){
float diff = std::abs(mean-oldped.mean_x12);

// if bad channel or low stat skip or the difference is too large wrt to previous record
if(ch->getEntries()< minEntries_ || !checkStatusCode(id) || diff>threshDiffEB_){

ped.mean_x12=oldped.mean_x12;
ped.rms_x12=oldped.rms_x12;
Expand All @@ -75,7 +78,8 @@ void ECALpedestalPCLHarvester::dqmEndJob(DQMStore::IBooker& ibooker_, DQMStore::
MonitorElement* ch= igetter_.get(hname);
double mean = ch->getMean();
double rms = ch->getRMS();

entriesEE_[i] = ch->getEntries();

DetId id = EEDetId::detIdFromDenseIndex(i);
EcalPedestal ped;
EcalPedestal oldped = *currentPedestals_->find(id.rawId());
Expand All @@ -84,8 +88,10 @@ void ECALpedestalPCLHarvester::dqmEndJob(DQMStore::IBooker& ibooker_, DQMStore::
ped.mean_x12=mean;
ped.rms_x12=rms;

// if bad channel or low stat skip
if(ch->getEntries()< minEntries_ || !checkStatusCode(id)){
float diff = std::abs(mean-oldped.mean_x12);

// if bad channel or low stat skip or the difference is too large wrt to previous record
if(ch->getEntries()< minEntries_ || !checkStatusCode(id)|| diff>threshDiffEE_){
ped.mean_x12=oldped.mean_x12;
ped.rms_x12=oldped.rms_x12;
}
Expand Down Expand Up @@ -220,23 +226,31 @@ void ECALpedestalPCLHarvester::dqmPlots(const EcalPedestals& newpeds, DQMStore:
ibooker.cd();
ibooker.setCurrentFolder(dqmDir_+"/Summary");

MonitorElement * pmeb = ibooker.book2D("meaneb","Pedestal Means",360, 1., 361., 171, -85., 86.);
MonitorElement * preb = ibooker.book2D("rmseb","Pedestal RMS",360, 1., 361., 171, -85., 86.);
MonitorElement * pmeb = ibooker.book2D("meaneb","Pedestal Means EB",360, 1., 361., 171, -85., 86.);
MonitorElement * preb = ibooker.book2D("rmseb","Pedestal RMS EB ",360, 1., 361., 171, -85., 86.);

MonitorElement * pmeep = ibooker.book2D("meaneep","Pedestal Means",100,1,101,100,1,101);
MonitorElement * preep = ibooker.book2D("rmseep","Pedestal RMS",100,1,101,100,1,101);
MonitorElement * pmeep = ibooker.book2D("meaneep","Pedestal Means EEP",100,1,101,100,1,101);
MonitorElement * preep = ibooker.book2D("rmseep","Pedestal RMS EEP",100,1,101,100,1,101);

MonitorElement * pmeem = ibooker.book2D("meaneem","Pedestal Means",100,1,101,100,1,101);
MonitorElement * preem = ibooker.book2D("rmseem","Pedestal RMS",100,1,101,100,1,101);
MonitorElement * pmeem = ibooker.book2D("meaneem","Pedestal Means EEM",100,1,101,100,1,101);
MonitorElement * preem = ibooker.book2D("rmseem","Pedestal RMS EEM",100,1,101,100,1,101);

MonitorElement * pmebd = ibooker.book2D("meanebdiff","Pedestal Means Diff",360, 1., 361., 171, -85., 86.);
MonitorElement * prebd = ibooker.book2D("rmsebdiff","Pedestal RMS Diff",360, 1., 361., 171, -85., 86.);
MonitorElement * pmebd = ibooker.book2D("meanebdiff","Abs Rel Pedestal Means Diff EB",360,1., 361., 171, -85., 86.);
MonitorElement * prebd = ibooker.book2D("rmsebdiff","Abs Rel Pedestal RMS Diff E ",360, 1., 361., 171, -85., 86.);

MonitorElement * pmeepd = ibooker.book2D("meaneepdiff","Pedestal Means Diff",100,1,101,100,1,101);
MonitorElement * preepd = ibooker.book2D("rmseepdiff","Pedestal RMS Diff",100,1,101,100,1,101);
MonitorElement * pmeepd = ibooker.book2D("meaneepdiff","Abs Rel Pedestal Means Diff EEP",100,1,101,100,1,101);
MonitorElement * preepd = ibooker.book2D("rmseepdiff","Abs Rel Pedestal RMS Diff EEP",100,1,101,100,1,101);

MonitorElement * pmeemd = ibooker.book2D("meaneemdiff","Pedestal Means Diff",100,1,101,100,1,101);
MonitorElement * preemd = ibooker.book2D("rmseemdiff","Pedestal RMS Diff",100,1,101,100,1,101);
MonitorElement * pmeemd = ibooker.book2D("meaneemdiff","Abs Rel Pedestal Means Diff EEM",100,1,101,100,1,101);
MonitorElement * preemd = ibooker.book2D("rmseemdiff","Abs RelPedestal RMS Diff EEM",100,1,101,100,1,101);

MonitorElement * poeb = ibooker.book2D("occeb","Occupancy EB",360, 1., 361., 171, -85., 86.);
MonitorElement * poeep = ibooker.book2D("occeep","Occupancy EEP",100,1,101,100,1,101);
MonitorElement * poeem = ibooker.book2D("occeem","Occupancy EEM",100,1,101,100,1,101);


MonitorElement * hdiffeb = ibooker.book1D("diffeb","Pedestal Differences EB",100,-2.5,2.5);
MonitorElement * hdiffee = ibooker.book1D("diffee","Pedestal Differences EE",100,-2.5,2.5);

for (int hash =0; hash<EBDetId::kSizeForDenseIndexing;++hash){

Expand All @@ -251,9 +265,10 @@ void ECALpedestalPCLHarvester::dqmPlots(const EcalPedestals& newpeds, DQMStore:

pmeb->Fill(di.iphi(),di.ieta(),mean);
preb->Fill(di.iphi(),di.ieta(),rms);
pmebd->Fill(di.iphi(),di.ieta(),std::abs(mean-cmean)/cmean);
prebd->Fill(di.iphi(),di.ieta(),std::abs(rms-crms)/crms);

if (cmean) pmebd->Fill(di.iphi(),di.ieta(),std::abs(mean-cmean)/cmean);
if (crms) prebd->Fill(di.iphi(),di.ieta(),std::abs(rms-crms)/crms);
poeb->Fill(di.iphi(),di.ieta(),entriesEB_[hash]);
hdiffeb->Fill(mean-cmean);
}


Expand All @@ -270,14 +285,17 @@ void ECALpedestalPCLHarvester::dqmPlots(const EcalPedestals& newpeds, DQMStore:
if (di.zside() >0){
pmeep->Fill(di.ix(),di.iy(),mean);
preep->Fill(di.ix(),di.iy(),rms);
pmeepd->Fill(di.ix(),di.iy(),std::abs(mean-cmean)/cmean);
preepd->Fill(di.ix(),di.iy(),std::abs(rms-crms)/crms);
poeep->Fill(di.ix(),di.iy(),entriesEE_[hash]);
if (cmean) pmeepd->Fill(di.ix(),di.iy(),std::abs(mean-cmean)/cmean);
if (crms) preepd->Fill(di.ix(),di.iy(),std::abs(rms-crms)/crms);
} else{
pmeem->Fill(di.ix(),di.iy(),mean);
preem->Fill(di.ix(),di.iy(),rms);
pmeemd->Fill(di.ix(),di.iy(),std::abs(mean-cmean)/cmean);
preemd->Fill(di.ix(),di.iy(),std::abs(rms-crms)/crms);
if (cmean) pmeemd->Fill(di.ix(),di.iy(),std::abs(mean-cmean)/cmean);
poeem->Fill(di.ix(),di.iy(),entriesEE_[hash]);
if (crms)preemd->Fill(di.ix(),di.iy(),std::abs(rms-crms)/crms);
}
hdiffee->Fill(mean-cmean);

}

Expand Down
24 changes: 18 additions & 6 deletions Calibration/EcalCalibAlgos/src/ECALpedestalPCLworker.cc
Expand Up @@ -14,11 +14,11 @@
ECALpedestalPCLworker::ECALpedestalPCLworker(const edm::ParameterSet& iConfig)

{
digiTagEB_= iConfig.getParameter<edm::InputTag>("BarrelDigis");
digiTagEE_= iConfig.getParameter<edm::InputTag>("EndcapDigis");
edm::InputTag digiTagEB= iConfig.getParameter<edm::InputTag>("BarrelDigis");
edm::InputTag digiTagEE= iConfig.getParameter<edm::InputTag>("EndcapDigis");

digiTokenEB_ = consumes<EBDigiCollection>(digiTagEB_);
digiTokenEE_ = consumes<EEDigiCollection>(digiTagEE_);
digiTokenEB_ = consumes<EBDigiCollection>(digiTagEB);
digiTokenEE_ = consumes<EEDigiCollection>(digiTagEE);

pedestalSamples_ = iConfig.getParameter<uint32_t>("pedestalSamples");
checkSignal_ = iConfig.getParameter<bool>("checkSignal");
Expand All @@ -29,6 +29,10 @@ ECALpedestalPCLworker::ECALpedestalPCLworker(const edm::ParameterSet& iConfig)
fixedBookingCenterBin_ = iConfig.getParameter<int>("fixedBookingCenterBin");
nBins_ = iConfig.getParameter<int>("nBins");
dqmDir_ = iConfig.getParameter<std::string>("dqmDir");

edm::InputTag bstRecord= iConfig.getParameter<edm::InputTag>("bstRecord");
bstToken_ = consumes<BSTRecord>(bstRecord);
requireStableBeam_ = iConfig.getParameter<bool>("requireStableBeam");
}


Expand All @@ -40,12 +44,20 @@ ECALpedestalPCLworker::analyze(const edm::Event& iEvent, const edm::EventSetup&
using namespace edm;

Handle<EBDigiCollection> pDigiEB;
iEvent.getByLabel(digiTagEB_,pDigiEB);
iEvent.getByToken(digiTokenEB_,pDigiEB);

Handle<EEDigiCollection> pDigiEE;
iEvent.getByLabel(digiTagEE_,pDigiEE);
iEvent.getByToken(digiTokenEE_,pDigiEE);


// Only Events with stable beam

if (requireStableBeam_){
edm::Handle<BSTRecord> bstData;
iEvent.getByToken(bstToken_,bstData);
int beamMode = static_cast<int>( bstData->beamMode() );
if (beamMode != 11 ) return;
}

for (EBDigiCollection::const_iterator pDigi=pDigiEB->begin(); pDigi!=pDigiEB->end(); ++pDigi){

Expand Down
22 changes: 9 additions & 13 deletions Calibration/EcalCalibAlgos/test/ecalPedestalPCL_step1_cfg.py
Expand Up @@ -26,14 +26,11 @@

# Input source
process.source = cms.Source("PoolSource",

#fileNames = cms.untracked.vstring('/store/data/Run2016D/TestEnablesEcalHcal/RAW/v2/000/276/315/00000/92AB6184-FD41-E611-A550-02163E01464C.root'),
#fileNames = cms.untracked.vstring('/store/data/Run2016D/TestEnablesEcalHcal/RAW/v2/000/276/318/00000/8487C425-1242-E611-81E6-02163E0146AF.root'),
fileNames = cms.untracked.vstring(
#'file://store_data_Run2016D_TestEnablesEcalHcal_RAW_v2_000_276_315_00000_92AB6184-FD41-E611-A550-02163E01464C.root',
#'file://store_data_Run2016D_TestEnablesEcalHcal_RAW_v2_000_276_318_00000_8487C425-1242-E611-81E6-02163E0146AF.root',
'file:///afs/cern.ch/work/a/argiro/ecalpedPCL/data/store_data_Run2016D_TestEnablesEcalHcal_RAW_v2_000_276_318_00000_5A25B228-1242-E611-BA75-02163E0120B0.root',
),
fileNames = cms.untracked.vstring(
'/store/data/Run2017B/TestEnablesEcalHcal/RAW/v1/000/299/149/00000/24768806-E869-E711-A7F2-02163E019BBE.root',
'/store/data/Run2017B/TestEnablesEcalHcal/RAW/v1/000/299/149/00000/26D7BF02-E869-E711-842E-02163E01A1CE.root',
'/store/data/Run2017B/TestEnablesEcalHcal/RAW/v1/000/299/149/00000/2AED4B13-EB69-E711-A167-02163E01A5B3.root',
),
secondaryFileNames = cms.untracked.vstring(),
#duplicateCheckMode = cms.untracked.string('noDuplicateCheck')
)
Expand All @@ -58,13 +55,12 @@


# Path and EndPath definitions
#process.ecalpedstalPCL = cms.EDAnalyzer('ECALpedestalPCLworker',
# BarrelDigis=cms.InputTag('ecalDigis','ebDigis'),
# EndcapDigis=cms.InputTag('ecalDigis','eeDigis'))

process.load('Calibration.EcalCalibAlgos.ecalPedestalPCLworker_cfi')

process.raw2digi_step = cms.Path(process.ecalDigis*process.ecalpedestalPCL)

process.tcdsDigis = cms.EDProducer('TcdsRawToDigi', InputLabel=cms.InputTag('hltEcalCalibrationRaw'))
process.raw2digi_step = cms.Path(process.tcdsDigis*process.ecalDigis*process.ecalpedestalPCL)

process.DQMoutput = cms.OutputModule("DQMRootOutputModule",
fileName = cms.untracked.string("OUT_step1.root"))
Expand All @@ -75,5 +71,5 @@
process.schedule = cms.Schedule(process.raw2digi_step,process.DQMoutput_step)



process.ecalDigis.InputLabel = cms.InputTag('hltEcalCalibrationRaw')

Expand Up @@ -16,7 +16,7 @@
workflows[1003]=['', ['RunMinBias2012A','RECODDQM','HARVESTDDQM']]
workflows[1004] = [ '',['RunHI2011','TIER0EXPHI','ALCAEXPHI','ALCAHARVD1HI','ALCAHARVD2HI','ALCAHARVD3HI','ALCAHARVD5HI']]

workflows[1010] = ['',['TestEnableEcalHCAL2016H','TIER0EXPTE', 'ALCAEXPTE', 'ALCAHARVDTE']]
workflows[1010] = ['',['TestEnableEcalHCAL2017B','TIER0EXPTE', 'ALCAEXPTE', 'ALCAHARVDTE']]
workflows[1020] = ['',['AlCaLumiPixels2016H','TIER0PROMPTLP']]
workflows[1030] = ['',['RunHLTPhy2017B','TIER0EXPHPBS','ALCASPLITHPBS','ALCAHARVDHPBS']]

Expand Down

0 comments on commit cd78fdb

Please sign in to comment.