CMS 3D CMS Logo

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