CMS 3D CMS Logo

CaloTowersDQMClient.cc
Go to the documentation of this file.
3 
7 
9 
11  outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile", "myfile.root");
12  debug_ = false;
13  verbose_ = false;
14  dirName_ = iConfig.getParameter<std::string>("DQMDirName");
15 }
16 
18 
20 
22 
23 // called after entering the CaloTowersD/CaloTowersTask directory
24 // hcalMEs are within that directory
25 int CaloTowersDQMClient::CaloTowersEndjob(const std::vector<MonitorElement *> &hcalMEs) {
26  int useAllHistos = 0;
27  MonitorElement *Ntowers_vs_ieta = nullptr;
28  MonitorElement *mapEnergy_N = nullptr, *mapEnergy_E = nullptr, *mapEnergy_H = nullptr, *mapEnergy_EH = nullptr;
29  MonitorElement *occupancy_map = nullptr, *occupancy_vs_ieta = nullptr;
30  for (unsigned int ih = 0; ih < hcalMEs.size(); ih++) {
31  if (strcmp(hcalMEs[ih]->getName().c_str(), "Ntowers_per_event_vs_ieta") == 0) {
32  Ntowers_vs_ieta = hcalMEs[ih];
33  }
34  if (strcmp(hcalMEs[ih]->getName().c_str(), "CaloTowersTask_map_Nentries") == 0) {
35  mapEnergy_N = hcalMEs[ih];
36  }
37  if (strcmp(hcalMEs[ih]->getName().c_str(), "CaloTowersTask_map_energy_H") == 0) {
38  useAllHistos++;
39  mapEnergy_H = hcalMEs[ih];
40  }
41  if (strcmp(hcalMEs[ih]->getName().c_str(), "CaloTowersTask_map_energy_E") == 0) {
42  useAllHistos++;
43  mapEnergy_E = hcalMEs[ih];
44  }
45  if (strcmp(hcalMEs[ih]->getName().c_str(), "CaloTowersTask_map_energy_EH") == 0) {
46  useAllHistos++;
47  mapEnergy_EH = hcalMEs[ih];
48  }
49  if (strcmp(hcalMEs[ih]->getName().c_str(), "CaloTowersTask_map_occupancy") == 0) {
50  occupancy_map = hcalMEs[ih];
51  }
52  if (strcmp(hcalMEs[ih]->getName().c_str(), "CaloTowersTask_occupancy_vs_ieta") == 0) {
53  occupancy_vs_ieta = hcalMEs[ih];
54  }
55  }
56  if (useAllHistos != 0 && useAllHistos != 3)
57  return 0;
58 
59  double nevent = mapEnergy_N->getEntries();
60  if (verbose_)
61  std::cout << "nevent : " << nevent << std::endl;
62 
63  // mean number of towers per ieta
64  int nx = Ntowers_vs_ieta->getNbinsX();
65  float cont;
66  float conte;
67  float fev = float(nevent);
68 
69  for (int i = 1; i <= nx; i++) {
70  cont = Ntowers_vs_ieta->getBinContent(i) / fev;
71  conte = pow(Ntowers_vs_ieta->getBinContent(i), 0.5) / fev;
72  Ntowers_vs_ieta->setBinContent(i, cont);
73  Ntowers_vs_ieta->setBinError(i, conte);
74  }
75 
76  // mean energies & occupancies evaluation
77 
78  nx = mapEnergy_N->getNbinsX();
79  int ny = mapEnergy_N->getNbinsY();
80  float cnorm;
81  float cnorme;
82  float phi_factor;
83 
84  for (int i = 1; i <= nx; i++) {
85  float sumphi = 0.;
86 
87  for (int j = 1; j <= ny; j++) {
88  // Emean
89  cnorm = mapEnergy_N->getBinContent(i, j);
90  // Phi histos are not used in the macros
91  if (cnorm > 0.000001 && useAllHistos) {
92  cont = mapEnergy_E->getBinContent(i, j) / cnorm;
93  conte = mapEnergy_E->getBinError(i, j) / cnorm;
94  mapEnergy_E->setBinContent(i, j, cont);
95  mapEnergy_E->setBinError(i, j, conte);
96 
97  cont = mapEnergy_H->getBinContent(i, j) / cnorm;
98  conte = mapEnergy_H->getBinError(i, j) / cnorm;
99  mapEnergy_H->setBinContent(i, j, cont);
100  mapEnergy_H->setBinError(i, j, conte);
101 
102  cont = mapEnergy_EH->getBinContent(i, j) / cnorm;
103  conte = mapEnergy_EH->getBinError(i, j) / cnorm;
104  mapEnergy_EH->setBinContent(i, j, cont);
105  mapEnergy_EH->setBinError(i, j, conte);
106  }
107 
108  // Occupancy (needed for occupancy vs ieta)
109  cont = occupancy_map->getBinContent(i, j);
110  conte = occupancy_map->getBinError(i, j);
111  if (fev > 0. && cnorm > 1.e-30) {
112  occupancy_map->setBinContent(i, j, cont / fev);
113  occupancy_map->setBinError(i, j, conte / fev);
114  }
115 
116  sumphi += cont;
117 
118  } // end of iphy cycle (j)
119 
120  // Occupancy vs ieta histo is drawn
121  // phi-factor evaluation for occupancy_vs_ieta calculation
122  int ieta = i - 43; // should be the same as int ieta =
123  // int(occupancy_vs_ieta->getBinCenter(i));
124 
125  if (ieta >= -20 && ieta <= 20) {
126  phi_factor = 72.;
127  } else {
128  if (ieta >= 40 || ieta <= -40) {
129  phi_factor = 18.;
130  } else
131  phi_factor = 36.;
132  }
133 
134  cnorm = sumphi / phi_factor;
135  cnorme = pow(sumphi, 0.5) / phi_factor;
136  if (fev > 0. && cnorm > 1.e-30) {
137  occupancy_vs_ieta->setBinContent(i, cnorm / fev);
138  occupancy_vs_ieta->setBinError(i, cnorme / fev);
139  }
140 
141  } // end of ieta cycle (i)
142 
143  return 1;
144 }
145 
147  igetter.setCurrentFolder(dirName_);
148  if (verbose_)
149  std::cout << "\nrunClient" << std::endl;
150 
151  std::vector<MonitorElement *> hcalMEs;
152 
153  // Since out folders are fixed to three, we can just go over these three
154  // folders i.e., CaloTowersD/CaloTowersTask, HcalRecHitsD/HcalRecHitTask,
155  // NoiseRatesV/NoiseRatesTask.
156  std::vector<std::string> fullPathHLTFolders = igetter.getSubdirs();
157  for (unsigned int i = 0; i < fullPathHLTFolders.size(); i++) {
158  if (verbose_)
159  std::cout << "\nfullPath: " << fullPathHLTFolders[i] << std::endl;
160  igetter.setCurrentFolder(fullPathHLTFolders[i]);
161 
162  std::vector<std::string> fullSubPathHLTFolders = igetter.getSubdirs();
163  for (unsigned int j = 0; j < fullSubPathHLTFolders.size(); j++) {
164  if (verbose_)
165  std::cout << "fullSub: " << fullSubPathHLTFolders[j] << std::endl;
166 
167  if (strcmp(fullSubPathHLTFolders[j].c_str(), "CaloTowersD/CaloTowersTask") == 0) {
168  hcalMEs = igetter.getContents(fullSubPathHLTFolders[j]);
169  if (verbose_)
170  std::cout << "hltMES size : " << hcalMEs.size() << std::endl;
171  if (!CaloTowersEndjob(hcalMEs))
172  std::cout << "\nError in CaloTowersEndjob!" << std::endl << std::endl;
173  }
174  }
175  }
176 }
177 
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
constexpr int pow(int x)
Definition: conifer.h:24
int CaloTowersEndjob(const std::vector< MonitorElement *> &hcalMEs)
T getUntrackedParameter(std::string const &, T const &) const
int nevent
Definition: AMPTWrapper.h:84
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
virtual double getEntries() const
get # of entries
virtual int getNbinsY() const
get # of bins in Y-axis
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
void beginRun(const edm::Run &run, const edm::EventSetup &c) override
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
std::string getName(const G4String &)
Definition: ForwardName.cc:3
virtual int getNbinsX() const
get # of bins in X-axis
virtual double getBinError(int binx) const
get uncertainty on content of bin (1-D) - See TH1::GetBinError for details
void beginJob(void) override
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
CaloTowersDQMClient(const edm::ParameterSet &)
cont
load Luminosity info ##
Definition: generateEDF.py:620
Definition: Run.h:45
virtual std::vector< dqm::harvesting::MonitorElement * > getContents(std::string const &path) const
Definition: DQMStore.cc:625
virtual double getBinContent(int binx) const
get content of bin (1-D)
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:739