CMS 3D CMS Logo

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