CMS 3D CMS Logo

DQMHcalIsoTrackPostProcessor.cc
Go to the documentation of this file.
7 
10 
11 #include <cmath>
12 #include <cstring>
13 #include <fstream>
14 #include <iomanip>
15 #include <iostream>
16 
17 #define DebugLog
18 
20 public:
23 
24  // void analyze(const edm::Event& event, const edm::EventSetup& eventSetup)
25  // override {};
27  DQMStore::IGetter &) override; // performed in the endJob
28 
29 private:
31 };
32 
34  subDir_ = pset.getUntrackedParameter<std::string>("subDir");
35 }
36 
38  if (igetter.dirExists(subDir_)) {
39  igetter.cd(subDir_);
40  } else {
41  edm::LogWarning("DQMHcalIsoTrackPostProcessor") << "cannot find directory: " << subDir_ << " , skipping";
42  return;
43  }
44 
45  MonitorElement *hSumEta[4], *hSumPhi[4], *hPurityEta[3], *hPurityPhi[3];
46  std::string types[4] = {"L2", "L2x", "L3", "Off"};
47  char name[100], title[200];
48  for (int i = 0; i < 4; ++i) {
49  sprintf(name, "/heta%s", types[i].c_str());
50  std::string hname1 = ibooker.pwd() + std::string(name);
51  int nbinEta = igetter.get(hname1)->getTH1F()->GetNbinsX();
52  double xminEta = igetter.get(hname1)->getTH1F()->GetBinLowEdge(1);
53  double xmaxEta =
54  igetter.get(hname1)->getTH1F()->GetBinLowEdge(nbinEta) + igetter.get(hname1)->getTH1F()->GetBinWidth(nbinEta);
55  sprintf(name, "/hphi%s", types[i].c_str());
56  std::string hname2 = ibooker.pwd() + std::string(name);
57  int nbinPhi = igetter.get(hname2)->getTH1F()->GetNbinsX();
58  double xminPhi = igetter.get(hname2)->getTH1F()->GetBinLowEdge(1);
59  double xmaxPhi =
60  igetter.get(hname2)->getTH1F()->GetBinLowEdge(nbinEta) + igetter.get(hname2)->getTH1F()->GetBinWidth(nbinEta);
61  sprintf(name, "hSum%sEta", types[i].c_str());
62  hSumEta[i] = ibooker.book1D(name, name, nbinEta, xminEta, xmaxEta);
63  sprintf(name, "hSum%sPhi", types[i].c_str());
64  hSumPhi[i] = ibooker.book1D(name, name, nbinPhi, xminPhi, xmaxPhi);
65  if (i < 3) {
66  sprintf(name, "hPurity%sEta", types[i].c_str());
67  sprintf(title, "Purity of %s sample vs #eta", types[i].c_str());
68  hPurityEta[i] = ibooker.book1D(name, title, nbinEta, xminEta, xmaxEta);
69  sprintf(name, "hPurity%sPhi", types[i].c_str());
70  sprintf(title, "Purity of %s sample vs #phi", types[i].c_str());
71  hPurityPhi[i] = ibooker.book1D(name, title, nbinPhi, xminPhi, xmaxPhi);
72  }
73  }
74 
75  for (int i = 0; i < 4; ++i) {
76  sprintf(name, "/heta%s", types[i].c_str());
77  std::string hname1 = ibooker.pwd() + std::string(name);
78 #ifdef DebugLog
79  std::cout << "PostProcesor " << hname1 << " " << igetter.get(hname1) << std::endl;
80 #endif
81  hSumEta[i]->getTH1F()->Add(igetter.get(hname1)->getTH1F(), 1);
82  sprintf(name, "/hphi%s", types[i].c_str());
83  std::string hname2 = ibooker.pwd() + std::string(name);
84 #ifdef DebugLog
85  std::cout << "PostProcesor " << hname2 << " " << igetter.get(hname2) << std::endl;
86 #endif
87  hSumPhi[i]->getTH1F()->Add(igetter.get(hname2)->getTH1F(), 1);
88  }
89 
90  for (int i = 0; i < 3; ++i) {
91  hPurityEta[i]->getTH1F()->Divide(hSumEta[i + 1]->getTH1F(), hSumEta[i]->getTH1F(), 1, 1);
92  hPurityPhi[i]->getTH1F()->Divide(hSumPhi[i + 1]->getTH1F(), hSumPhi[i]->getTH1F(), 1, 1);
93  }
94 }
95 
T getUntrackedParameter(std::string const &, T const &) const
TH1F * getTH1F() const
DQMHcalIsoTrackPostProcessor(const edm::ParameterSet &pset)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
MonitorElement * get(std::string const &path)
Definition: DQMStore.cc:303
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
std::string const & pwd()
Definition: DQMStore.cc:278
bool dirExists(std::string const &path)
Definition: DQMStore.cc:343