CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
dqmoffline::l1t::L1TDiffHarvesting::L1TDiffPlotHandler Class Reference

Public Member Functions

void bookDiff (DQMStore::IBooker &ibooker)
 
void computeDiff (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
 
bool isValid () const
 
 L1TDiffPlotHandler (const edm::ParameterSet &ps, std::string plotName)
 
 L1TDiffPlotHandler (const L1TDiffPlotHandler &handler)
 
void loadHistograms (DQMStore::IGetter &igetter)
 

Public Attributes

std::string dir1_
 
std::string dir2_
 
MonitorElementh1_
 
MonitorElementh2_
 
MonitorElementh_diff_
 
MonitorElement::Kind histType1_
 
MonitorElement::Kind histType2_
 
std::string outputDir_
 
std::string plotName_
 

Detailed Description

Definition at line 29 of file L1TDiffHarvesting.h.

Constructor & Destructor Documentation

dqmoffline::l1t::L1TDiffHarvesting::L1TDiffPlotHandler::L1TDiffPlotHandler ( const edm::ParameterSet ps,
std::string  plotName 
)

Definition at line 9 of file L1TDiffHarvesting.cc.

9  :
10  dir1_(ps.getUntrackedParameter < std::string > ("dir1")),
11  dir2_(ps.getUntrackedParameter < std::string > ("dir2")),
12  outputDir_(ps.getUntrackedParameter < std::string > ("outputDir", dir1_)),
13  plotName_(plotName),
14  h1_(),
15  h2_(),
16  h_diff_(),
17  histType1_(),
18  histType2_()
19 {
20 
21 }
T getUntrackedParameter(std::string const &, T const &) const
dqmoffline::l1t::L1TDiffHarvesting::L1TDiffPlotHandler::L1TDiffPlotHandler ( const L1TDiffPlotHandler handler)

Member Function Documentation

void dqmoffline::l1t::L1TDiffHarvesting::L1TDiffPlotHandler::bookDiff ( DQMStore::IBooker ibooker)

Definition at line 114 of file L1TDiffHarvesting.cc.

References DQMStore::IBooker::book1D(), DQMStore::IBooker::book2D(), DQMStore::IBooker::bookProfile(), MonitorElement::DQM_KIND_TH1D, MonitorElement::DQM_KIND_TH1F, MonitorElement::DQM_KIND_TH2D, MonitorElement::DQM_KIND_TH2F, MonitorElement::DQM_KIND_TPROFILE, MonitorElement::getTH1F(), MonitorElement::getTH2F(), MonitorElement::getTProfile(), h1_, h_diff_, histType1_, fastTrackerRecHitType::is2D(), SiStripPI::max, min(), outputDir_, plotName_, and DQMStore::IBooker::setCurrentFolder().

Referenced by computeDiff().

115 {
116  ibooker.setCurrentFolder(outputDir_);
117 
121 
122  if (is1D) {
123  TH1F* h1 = h1_->getTH1F();
124  double min = h1->GetXaxis()->GetXmin();
125  double max = h1->GetXaxis()->GetXmax();
126  int nBins = h1->GetNbinsX();
127  h_diff_ = ibooker.book1D(plotName_, plotName_, nBins, min, max);
128  } else if (is2D) {
129  TH2F* h1 = h1_->getTH2F();
130  double minX = h1->GetXaxis()->GetXmin();
131  double maxX = h1->GetXaxis()->GetXmax();
132  double minY = h1->GetYaxis()->GetXmin();
133  double maxY = h1->GetYaxis()->GetXmax();
134  int nBinsX = h1->GetNbinsX();
135  int nBinsY = h1->GetNbinsY();
136 
137  h_diff_ = ibooker.book2D(plotName_, plotName_, nBinsX, minX, maxX, nBinsY, minY, maxY);
138  } else if (isProfile) {
139  TProfile* h1 = h1_->getTProfile();
140  double minX = h1->GetXaxis()->GetXmin();
141  double maxX = h1->GetXaxis()->GetXmax();
142  double minY = h1->GetYaxis()->GetXmin();
143  double maxY = h1->GetYaxis()->GetXmax();
144  int nBins = h1->GetNbinsX();
145  h_diff_ = ibooker.bookProfile(plotName_, plotName_, nBins, minX, maxX, minY, maxY);
146  } else {
147  edm::LogWarning("L1TDiffHarvesting::L1TDiffPlotHandler::bookDiff")
148  << "Unknown histogram type. Quitting booking"
149  << std::endl;
150 
151  return;
152  }
153 
154 }
TProfile * getTProfile() const
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:113
TH1F * getTH1F() const
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
bool is2D(HitType hitType)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
T min(T a, T b)
Definition: MathUtil.h:58
TH2F * getTH2F() const
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
void dqmoffline::l1t::L1TDiffHarvesting::L1TDiffPlotHandler::computeDiff ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter 
)

Definition at line 37 of file L1TDiffHarvesting.cc.

References bookDiff(), MonitorElement::DQM_KIND_TH1D, MonitorElement::DQM_KIND_TH1F, MonitorElement::DQM_KIND_TH2D, MonitorElement::DQM_KIND_TH2F, MonitorElement::DQM_KIND_TPROFILE, MonitorElement::getTH1F(), MonitorElement::getTH2F(), MonitorElement::getTProfile(), h1_, h2_, h_diff_, histType1_, fastTrackerRecHitType::is2D(), isValid(), and loadHistograms().

38 {
39  loadHistograms(igetter);
40  if (!isValid()) {
41  return;
42  }
43  bookDiff(ibooker);
44 
45  TH1* h_diff;
46  TH1* h1;
47  TH1* h2;
51 
52  if (is1D) {
53  h_diff = h_diff_->getTH1F();
54  h1 = h1_->getTH1F();
55  h2 = h2_->getTH1F();
56  } else if (is2D) {
57  h_diff = h_diff_->getTH2F();
58  h1 = h1_->getTH2F();
59  h2 = h2_->getTH2F();
60  }
61  else if (isProfile){
62  h_diff = h_diff_->getTProfile();
63  h1 = h1_->getTProfile();
64  h2 = h2_->getTProfile();
65  } else {
66  edm::LogWarning("L1TDiffHarvesting::L1TDiffPlotHandler::computeDiff")
67  << "Unknown histogram type. Quitting booking"
68  << std::endl;
69 
70  return;
71  }
72  h_diff->Add(h1);
73  h_diff->Add(h2, -1);
74  // if histograms are identical h_diff will have 0 entries -> not good to check if anything happened
75  // let's fix it
76  h_diff->SetEntries(h1->GetEntries() + h2->GetEntries());
77 }
TProfile * getTProfile() const
TH1F * getTH1F() const
bool is2D(HitType hitType)
TH2F * getTH2F() const
bool dqmoffline::l1t::L1TDiffHarvesting::L1TDiffPlotHandler::isValid ( void  ) const

Definition at line 99 of file L1TDiffHarvesting.cc.

References MonitorElement::DQM_KIND_INVALID, histType1_, and histType2_.

Referenced by ntupleDataFormat._Object::_checkIsValid(), computeDiff(), and core.AutoHandle.AutoHandle::ReallyLoad().

100 {
102  edm::LogWarning("L1TDiffHarvesting::L1TDiffPlotHandler::isValid") << " Could not find a supported histogram type"
103  << std::endl;
104  return false;
105  }
106  if (histType1_ != histType2_) {
107  edm::LogWarning("L1TDiffHarvesting::L1TDiffPlotHandler::isValid")
108  << " Histogram 1 and 2 have different histogram types" << std::endl;
109  return false;
110  }
111  return true;
112 }
void dqmoffline::l1t::L1TDiffHarvesting::L1TDiffPlotHandler::loadHistograms ( DQMStore::IGetter igetter)

Definition at line 79 of file L1TDiffHarvesting.cc.

References dir1_, dir2_, DQMStore::IGetter::get(), h1_, h2_, histType1_, histType2_, MonitorElement::kind(), plotName_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by computeDiff().

80 {
81  std::string h1Name = dir1_ + "/" + plotName_;
82  std::string h2Name = dir2_ + "/" + plotName_;
83  h1_ = igetter.get(h1Name);
84  h2_ = igetter.get(h2Name);
85 
86  if (!h1_ || !h2_) {
87  edm::LogWarning("L1TDiffHarvesting::L1TDiffPlotHandler::loadHistograms")
88  << (!h1_ && !h2_ ? h1Name + " && " + h2Name : !h1_ ? h1Name : h2Name) << " not gettable. Quitting booking"
89  << std::endl;
90 
91  return;
92  }
93 
94  histType1_ = h1_->kind();
95  histType2_ = h2_->kind();
96 
97 }
MonitorElement * get(std::string const &path)
Definition: DQMStore.cc:303
Kind kind() const
Get the type of the monitor element.

Member Data Documentation

std::string dqmoffline::l1t::L1TDiffHarvesting::L1TDiffPlotHandler::dir1_

Definition at line 36 of file L1TDiffHarvesting.h.

Referenced by loadHistograms().

std::string dqmoffline::l1t::L1TDiffHarvesting::L1TDiffPlotHandler::dir2_

Definition at line 37 of file L1TDiffHarvesting.h.

Referenced by loadHistograms().

MonitorElement* dqmoffline::l1t::L1TDiffHarvesting::L1TDiffPlotHandler::h1_

Definition at line 41 of file L1TDiffHarvesting.h.

Referenced by bookDiff(), computeDiff(), and loadHistograms().

MonitorElement* dqmoffline::l1t::L1TDiffHarvesting::L1TDiffPlotHandler::h2_

Definition at line 42 of file L1TDiffHarvesting.h.

Referenced by computeDiff(), and loadHistograms().

MonitorElement* dqmoffline::l1t::L1TDiffHarvesting::L1TDiffPlotHandler::h_diff_

Definition at line 43 of file L1TDiffHarvesting.h.

Referenced by bookDiff(), and computeDiff().

MonitorElement::Kind dqmoffline::l1t::L1TDiffHarvesting::L1TDiffPlotHandler::histType1_

Definition at line 44 of file L1TDiffHarvesting.h.

Referenced by bookDiff(), computeDiff(), isValid(), and loadHistograms().

MonitorElement::Kind dqmoffline::l1t::L1TDiffHarvesting::L1TDiffPlotHandler::histType2_

Definition at line 44 of file L1TDiffHarvesting.h.

Referenced by isValid(), and loadHistograms().

std::string dqmoffline::l1t::L1TDiffHarvesting::L1TDiffPlotHandler::outputDir_
std::string dqmoffline::l1t::L1TDiffHarvesting::L1TDiffPlotHandler::plotName_

Definition at line 39 of file L1TDiffHarvesting.h.

Referenced by bookDiff(), and loadHistograms().