CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 =0;
73  MonitorElement* mapEnergy_N =0, *mapEnergy_E =0, *mapEnergy_H =0, *mapEnergy_EH =0;
74  MonitorElement* occupancy_map =0, *occupancy_vs_ieta =0;
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 fev = float(nevent);
108 
109  for (int i = 1; i <= nx; i++) {
110  cont = Ntowers_vs_ieta -> getBinContent(i) / fev ;
111  Ntowers_vs_ieta -> setBinContent(i,cont);
112  }
113 
114  // mean energies & occupancies evaluation
115 
116  nx = mapEnergy_N->getNbinsX();
117  int ny = mapEnergy_N->getNbinsY();
118  float cnorm;
119  float phi_factor;
120 
121  for (int i = 1; i <= nx; i++) {
122  float sumphi = 0.;
123 
124  for (int j = 1; j <= ny; j++) {
125 
126  // Emean
127  cnorm = mapEnergy_N -> getBinContent(i,j);
128  //Phi histos are not used in the macros
129  if(cnorm > 0.000001 && useAllHistos) {
130 
131  cont = mapEnergy_E -> getBinContent(i,j) / cnorm ;
132  mapEnergy_E -> setBinContent(i,j,cont);
133 
134  cont = mapEnergy_H -> getBinContent(i,j) / cnorm ;
135  mapEnergy_H -> setBinContent(i,j,cont);
136 
137  cont = mapEnergy_EH -> getBinContent(i,j) / cnorm ;
138  mapEnergy_EH -> setBinContent(i,j,cont);
139  }
140 
141  // Occupancy (needed for occupancy vs ieta)
142  cnorm = occupancy_map -> getBinContent(i,j) / fev;
143  if(cnorm > 1.e-30) occupancy_map -> setBinContent(i,j,cnorm);
144 
145  sumphi += cnorm;
146 
147  } // end of iphy cycle (j)
148 
149  //Occupancy vs ieta histo is drawn
150  // phi-factor evaluation for occupancy_vs_ieta calculation
151  int ieta = i - 42; // -41 -1, 0 40
152  if(ieta >=0 ) ieta +=1; // -41 -1, 1 41 - to make it detector-like
153 
154  if(ieta >= -20 && ieta <= 20 )
155  {phi_factor = 72.;}
156  else {
157  if(ieta >= 40 || ieta <= -40 ) {phi_factor = 18.;}
158  else
159  phi_factor = 36.;
160  }
161  if(ieta >= 0) ieta -= 1; // -41 -1, 0 40 - to bring back to histo num
162 
163  cnorm = sumphi / phi_factor;
164  occupancy_vs_ieta->Fill(double(ieta), cnorm);
165 
166  } // end of ieta cycle (i)
167 
168  return 1;
169 
170 }
171 
std::vector< MonitorElement * > getContents(Args &&...args)
Definition: DQMStore.h:197
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
virtual void beginJob(void)
std::string outputFile_
tuple cont
load Luminosity info ##
Definition: generateEDF.py:622
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
double getEntries(void) const
get # of entries
int getNbinsY(void) const
get # of bins in Y-axis
int nevent
Definition: AMPTWrapper.h:74
virtual void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
int CaloTowersEndjob(const std::vector< MonitorElement * > &hcalMEs)
int j
Definition: DBlmapReader.cc:9
std::string dirName_
virtual ~CaloTowersClient()
std::vector< std::string > getSubdirs(void)
Definition: DQMStore.cc:305
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:329
CaloTowersClient(const edm::ParameterSet &)
int getNbinsX(void) const
get # of bins in X-axis
tuple cout
Definition: gather_cfg.py:145