CMS 3D CMS Logo

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