Skip to content

Commit

Permalink
Added monitor elements and methods to analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
samhiggie committed Apr 5, 2018
1 parent 7420370 commit 5af58c6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 18 deletions.
2 changes: 2 additions & 0 deletions Calibration/LumiAlCaRecoProducers/plugins/BuildFile.xml
@@ -1,6 +1,8 @@
<use name="FWCore/MessageLogger"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="DQMServices/Core"/>
<use name="DQMServices/Components"/>

<use name="CondCore/Utilities"/>
<use name="FWCore/ServiceRegistry"/>
Expand Down
50 changes: 36 additions & 14 deletions Calibration/LumiAlCaRecoProducers/plugins/CorrPCCProducer.cc
Expand Up @@ -45,20 +45,26 @@ ________________________________________________________________**/
#include "TGraphErrors.h"
#include "TFile.h"

class CorrPCCProducer : public edm::one::EDProducer<edm::EndRunProducer,edm::one::WatchRuns,edm::EndLuminosityBlockProducer,edm::one::WatchLuminosityBlocks> {
#include "DQMServices/Core/interface/DQMStore.h"
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/MonitorElement.h"

class DQMStore;
class MonitorElement;

class CorrPCCProducer : public DQMEDAnalyzer {
public:
explicit CorrPCCProducer(const edm::ParameterSet&);
~CorrPCCProducer() override;

private:
void beginRun(edm::Run const& runSeg, const edm::EventSetup& iSetup) final;
void beginLuminosityBlock(edm::LuminosityBlock const& lumiSeg, const edm::EventSetup& iSetup) final;
void endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, const edm::EventSetup& iSetup) final;
void endRun(edm::Run const& runSeg, const edm::EventSetup& iSetup) final;
void endLuminosityBlockProduce(edm::LuminosityBlock& lumiSeg, const edm::EventSetup& iSetup) final;
void endRunProduce(edm::Run& runSeg, const edm::EventSetup& iSetup) final;
void endJob() final;
void produce (edm::Event& iEvent, const edm::EventSetup& iSetup) final;

void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;


void makeCorrectionTemplate ();
Expand Down Expand Up @@ -96,6 +102,12 @@ class CorrPCCProducer : public edm::one::EDProducer<edm::EndRunProducer,edm::one
TH1F *type1FracHist;
TH1F *type1resHist;
TH1F *type2resHist;

unsigned int maxLS=3500;
MonitorElement* Type1FracMon;
MonitorElement* Type1ResMon;
MonitorElement* Type2ResMon;

TGraphErrors *type1FracGraph;
TGraphErrors *type1resGraph;
TGraphErrors *type2resGraph;
Expand Down Expand Up @@ -341,12 +353,6 @@ void CorrPCCProducer::calculateCorrections (std::vector<float> uncorrected, std:
overallCorrection_ = integral_corr_clusters/integral_uncorr_clusters;
}

//--------------------------------------------------------------------------------------------------
void CorrPCCProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup){
}
//--------------------------------------------------------------------------------------------------
void CorrPCCProducer::beginRun(edm::Run const& runSeg, const edm::EventSetup& iSetup){
}
//--------------------------------------------------------------------------------------------------
void CorrPCCProducer::beginLuminosityBlock(edm::LuminosityBlock const& lumiSeg, const edm::EventSetup& iSetup){
countLumi_++;
Expand Down Expand Up @@ -391,10 +397,6 @@ void CorrPCCProducer::endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, co
void CorrPCCProducer::endRun(edm::Run const& runSeg, const edm::EventSetup& iSetup){
}

//--------------------------------------------------------------------------------------------------
void CorrPCCProducer::endLuminosityBlockProduce(edm::LuminosityBlock& lumiSeg, const edm::EventSetup& iSetup){
}

//--------------------------------------------------------------------------------------------------
void CorrPCCProducer::endRunProduce(edm::Run& runSeg, const edm::EventSetup& iSetup){
if(lumiSections.empty()){
Expand Down Expand Up @@ -562,6 +564,19 @@ void CorrPCCProducer::endRunProduce(edm::Run& runSeg, const edm::EventSetup& iSe
type1resHist->Fill(mean_type1_residual);
type2resHist->Fill(mean_type2_residual);

for(unsigned int ils=lumiInfoMapIterator->first.first;ils<lumiInfoMapIterator->first.second+1;ils++){
if(ils>maxLS){
std::cout<<"ils out of maxLS range!!"<<std::endl;
break;
}
Type1FracMon->setBinContent(ils,type1Frac);
Type1FracMon->setBinError(ils,mean_type1_residual_unc);
Type1ResMon->setBinContent(ils,mean_type1_residual);
Type1ResMon->setBinError(ils,mean_type1_residual_unc);
Type2ResMon->setBinContent(ils,mean_type2_residual);
Type2ResMon->setBinError(ils,mean_type2_residual_unc);
}


type1FracGraph->SetPoint(iBlock,thisIOV+approxLumiBlockSize_/2.0,type1Frac);
type1resGraph->SetPoint(iBlock,thisIOV+approxLumiBlockSize_/2.0,mean_type1_residual);
Expand Down Expand Up @@ -618,6 +633,13 @@ void CorrPCCProducer::resetBlock(){
}
}
//--------------------------------------------------------------------------------------------------
void CorrPCCProducer::bookHistograms(DQMStore::IBooker & ibooker, edm::Run const & iRun, edm::EventSetup const & context){

Type1FracMon = ibooker.book1D("type1Fraction","Type1Fraction;Lumisection;Type 1 Fraction",maxLS,0,maxLS);
Type1ResMon = ibooker.book1D("type1Residual","Type1Residual;Lumisection;Type 1 Residual",maxLS,0,maxLS);
Type2ResMon = ibooker.book1D("type2Residual","Type2Residual;Lumisection;Type 2 Residual",maxLS,0,maxLS);
}
//--------------------------------------------------------------------------------------------------
void CorrPCCProducer::endJob(){
histoFile->cd();
type1FracGraph->Write();
Expand Down

0 comments on commit 5af58c6

Please sign in to comment.