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 
11 
13 {
14 
15  outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile", "myfile.root");
16 
18  if (!dbe_) {
19  edm::LogError("CaloTowersClient") << "unable to get DQMStore service, upshot is no client histograms will be made";
20  }
21  if(iConfig.getUntrackedParameter<bool>("DQMStore", false)) {
22  if(dbe_) dbe_->setVerbose(0);
23  }
24 
25  debug_ = false;
26  verbose_ = false;
27 
28  dirName_=iConfig.getParameter<std::string>("DQMDirName");
29  if(dbe_) dbe_->setCurrentFolder(dirName_);
30 
31 }
32 
33 
35 {
36 
37 }
38 
40 {
41 
42 
43 }
44 
46 {
47  if ( outputFile_.size() != 0 && dbe_ ) dbe_->save(outputFile_);
48 }
49 
51 {
52 
53 }
54 
55 
57 {
58  runClient_();
59 }
60 
61 //dummy analysis function
63 {
64 
65 }
66 
68 {
69 // runClient_();
70 }
71 
73 {
74  if(!dbe_) return; //we dont have the DQMStore so we cant do anything
76 
77  if (verbose_) std::cout << "\nrunClient" << std::endl;
78 
79  std::vector<MonitorElement*> hcalMEs;
80 
81  // Since out folders are fixed to three, we can just go over these three folders
82  // i.e., CaloTowersV/CaloTowersTask, HcalRecHitsV/HcalRecHitTask, NoiseRatesV/NoiseRatesTask.
83  std::vector<std::string> fullPathHLTFolders = dbe_->getSubdirs();
84  for(unsigned int i=0;i<fullPathHLTFolders.size();i++) {
85 
86  if (verbose_) std::cout <<"\nfullPath: "<< fullPathHLTFolders[i] << std::endl;
87  dbe_->setCurrentFolder(fullPathHLTFolders[i]);
88 
89  std::vector<std::string> fullSubPathHLTFolders = dbe_->getSubdirs();
90  for(unsigned int j=0;j<fullSubPathHLTFolders.size();j++) {
91 
92  if (verbose_) std::cout <<"fullSub: "<<fullSubPathHLTFolders[j] << std::endl;
93 
94  if( strcmp(fullSubPathHLTFolders[j].c_str(), "CaloTowersV/CaloTowersTask") ==0 ){
95  hcalMEs = dbe_->getContents(fullSubPathHLTFolders[j]);
96  if (verbose_) std::cout <<"hltMES size : "<<hcalMEs.size()<<std::endl;
97  if( !CaloTowersEndjob(hcalMEs) ) std::cout<<"\nError in CaloTowersEndjob!"<<std::endl<<std::endl;
98  }
99 
100  }
101 
102  }
103 
104 }
105 
106 // called after entering the CaloTowersV/CaloTowersTask directory
107 // hcalMEs are within that directory
108 int CaloTowersClient::CaloTowersEndjob(const std::vector<MonitorElement*> &hcalMEs){
109 
110  int useAllHistos = 0;
111  MonitorElement* Ntowers_vs_ieta =0;
112  MonitorElement* mapEnergy_N =0, *mapEnergy_E =0, *mapEnergy_H =0, *mapEnergy_EH =0;
113  MonitorElement* occupancy_map =0, *occupancy_vs_ieta =0;
114  for(unsigned int ih=0; ih<hcalMEs.size(); ih++){
115  if( strcmp(hcalMEs[ih]->getName().c_str(), "Ntowers_per_event_vs_ieta") ==0 ){
116  Ntowers_vs_ieta = hcalMEs[ih];
117  }
118  if( strcmp(hcalMEs[ih]->getName().c_str(), "CaloTowersTask_map_Nentries") ==0 ){
119  mapEnergy_N = hcalMEs[ih];
120  }
121  if( strcmp(hcalMEs[ih]->getName().c_str(), "CaloTowersTask_map_energy_H") ==0 ){
122  useAllHistos++; mapEnergy_H = hcalMEs[ih];
123  }
124  if( strcmp(hcalMEs[ih]->getName().c_str(), "CaloTowersTask_map_energy_E") ==0 ){
125  useAllHistos++; mapEnergy_E = hcalMEs[ih];
126  }
127  if( strcmp(hcalMEs[ih]->getName().c_str(), "CaloTowersTask_map_energy_EH") ==0 ){
128  useAllHistos++; mapEnergy_EH = hcalMEs[ih];
129  }
130  if( strcmp(hcalMEs[ih]->getName().c_str(), "CaloTowersTask_map_occupancy") ==0 ){
131  occupancy_map = hcalMEs[ih];
132  }
133  if( strcmp(hcalMEs[ih]->getName().c_str(), "CaloTowersTask_occupancy_vs_ieta") ==0 ){
134  occupancy_vs_ieta = hcalMEs[ih];
135  }
136 
137  }
138  if( useAllHistos !=0 && useAllHistos !=3 ) return 0;
139 
140  double nevent = mapEnergy_N->getEntries();
141  if(verbose_) std::cout<<"nevent : "<<nevent<<std::endl;
142 
143  // mean number of towers per ieta
144  int nx = Ntowers_vs_ieta->getNbinsX();
145  float cont;
146  float fev = float(nevent);
147 
148  for (int i = 1; i <= nx; i++) {
149  cont = Ntowers_vs_ieta -> getBinContent(i) / fev ;
150  Ntowers_vs_ieta -> setBinContent(i,cont);
151  }
152 
153  // mean energies & occupancies evaluation
154 
155  nx = mapEnergy_N->getNbinsX();
156  int ny = mapEnergy_N->getNbinsY();
157  float cnorm;
158  float phi_factor;
159 
160  for (int i = 1; i <= nx; i++) {
161  float sumphi = 0.;
162 
163  for (int j = 1; j <= ny; j++) {
164 
165  // Emean
166  cnorm = mapEnergy_N -> getBinContent(i,j);
167  //Phi histos are not used in the macros
168  if(cnorm > 0.000001 && useAllHistos) {
169 
170  cont = mapEnergy_E -> getBinContent(i,j) / cnorm ;
171  mapEnergy_E -> setBinContent(i,j,cont);
172 
173  cont = mapEnergy_H -> getBinContent(i,j) / cnorm ;
174  mapEnergy_H -> setBinContent(i,j,cont);
175 
176  cont = mapEnergy_EH -> getBinContent(i,j) / cnorm ;
177  mapEnergy_EH -> setBinContent(i,j,cont);
178  }
179 
180  // Occupancy (needed for occupancy vs ieta)
181  cnorm = occupancy_map -> getBinContent(i,j) / fev;
182  if(cnorm > 1.e-30) occupancy_map -> setBinContent(i,j,cnorm);
183 
184  sumphi += cnorm;
185 
186  } // end of iphy cycle (j)
187 
188  //Occupancy vs ieta histo is drawn
189  // phi-factor evaluation for occupancy_vs_ieta calculation
190  int ieta = i - 42; // -41 -1, 0 40
191  if(ieta >=0 ) ieta +=1; // -41 -1, 1 41 - to make it detector-like
192 
193  if(ieta >= -20 && ieta <= 20 )
194  {phi_factor = 72.;}
195  else {
196  if(ieta >= 40 || ieta <= -40 ) {phi_factor = 18.;}
197  else
198  phi_factor = 36.;
199  }
200  if(ieta >= 0) ieta -= 1; // -41 -1, 0 40 - to bring back to histo num
201 
202  cnorm = sumphi / phi_factor;
203  occupancy_vs_ieta->Fill(double(ieta), cnorm);
204 
205  } // end of ieta cycle (i)
206 
207  return 1;
208 
209 }
210 
virtual void runClient_()
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_
virtual void endRun(const edm::Run &run, const edm::EventSetup &c)
virtual void beginRun(const edm::Run &run, const edm::EventSetup &c)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1647
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
double getEntries(void) const
get # of entries
int getNbinsY(void) const
get # of bins in Y-axis
int nevent
Definition: AMPTWrapper.h:74
int iEvent
Definition: GenABIO.cc:230
int CaloTowersEndjob(const std::vector< MonitorElement * > &hcalMEs)
int j
Definition: DBlmapReader.cc:9
std::vector< MonitorElement * > getContents(const std::string &path) const
Definition: DQMStore.cc:1725
virtual void endJob()
std::string dirName_
virtual ~CaloTowersClient()
int cont
CaloTowersClient(const edm::ParameterSet &)
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, const uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE", const bool resetMEsAfterWriting=false)
Definition: DQMStore.cc:2490
int getNbinsX(void) const
get # of bins in X-axis
tuple cout
Definition: gather_cfg.py:121
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655
Definition: Run.h:41