CMS 3D CMS Logo

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