CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalSimHitsClient.cc
Go to the documentation of this file.
3 
8 
11 
13 
14  outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile", "myfile.root");
15 
16 
17  debug_ = false;
18  verbose_ = false;
19 
20  dirName_= iConfig.getParameter<std::string>("DQMDirName");
21 
22 }
23 
24 
26 
27 // let's see if this breaks anything
28 /*void HcalSimHitsClient::endJob() {
29  if ( outputFile_.size() != 0 && dbe_ ) dbe_->save(outputFile_);
30 }*/
31 
32 
33 
35 {
36  runClient_(ib,ig);
37 }
38 
39 
40 
41 
43 
45 
46  if (verbose_) std::cout << "\nrunClient" << std::endl;
47 
48  std::vector<MonitorElement*> hcalMEs;
49 
50  std::vector<std::string> fullPathHLTFolders = ig.getSubdirs();
51  for (unsigned int i=0;i<fullPathHLTFolders.size();i++) {
52  if (verbose_) std::cout <<"\nfullPath: "<< fullPathHLTFolders[i] << std::endl;
53  ig.setCurrentFolder(fullPathHLTFolders[i]);
54 
55  std::vector<std::string> fullSubPathHLTFolders = ig.getSubdirs();
56  for (unsigned int j=0;j<fullSubPathHLTFolders.size();j++) {
57 
58  if (verbose_) std::cout <<"fullSub: "<<fullSubPathHLTFolders[j] << std::endl;
59 
60  if (strcmp(fullSubPathHLTFolders[j].c_str(), "HcalHitsV/SimHitsValidationHcal") == 0) {
61  hcalMEs = ig.getContents(fullSubPathHLTFolders[j]);
62  if (verbose_) std::cout <<"hltMES size : "<<hcalMEs.size()<<std::endl;
63  if( !SimHitsEndjob(hcalMEs) ) std::cout<<"\nError in SimhitEndjob!"<<std::endl<<std::endl;
64  }
65 
66  }
67 
68  }
69 
70 }
71 
72 // called after entering the directory
73 // hcalMEs are within that directory
74 int HcalSimHitsClient::SimHitsEndjob(const std::vector<MonitorElement*> &hcalMEs) {
75 
76  MonitorElement *Occupancy_map[nTime][nType];
77  MonitorElement *Energy[nType1], *Time_weighteden[nType1];
78  MonitorElement *HitEnergyvsieta[nType], *HitTimevsieta[nType];
79  std::string divisions[nType]={"HB0","HB1","HE0+z","HE1+z","HE2+z","HE0-z","HE1-z",
80  "HE2-z","HO0","HFL0+z","HFS0+z","HFL1+z","HFS1+z",
81  "HFL2+z","HFS2+z","HFL3+z","HFS3+z","HFL0-z","HFS0-z",
82  "HFL1-z","HFS1-z","HFL2-z","HFS2-z","HFL3-z","HFS3-z"};
83 
84  std::string time[nTime]={"25","50","100","250"};
85  std::string detdivision[nType1]={"HB","HE","HF","HO"};
86  char name[40], name1[40], name2[40], name3[40], name4[40];
87 
88  for (int k=0; k<nType1;k++) {
89  Energy[k] = 0;
90  Time_weighteden[k] = 0;
91  for (unsigned int ih=0; ih<hcalMEs.size(); ih++) {
92  sprintf (name1, "Energy_%s", detdivision[k].c_str());
93  sprintf (name2, "Time_Enweighted_%s", detdivision[k].c_str());
94  if (strcmp(hcalMEs[ih]->getName().c_str(), name1) == 0) {
95  Energy[k] = hcalMEs[ih];
96  }
97  if (strcmp(hcalMEs[ih]->getName().c_str(), name2) == 0) {
98  Time_weighteden[k] = hcalMEs[ih];
99  }
100  }
101  }
102 
103  for (int i=0; i<nTime; i++) {
104  for (int j=0; j<nType;j++) {
105  Occupancy_map[i][j]= 0;
106  for (unsigned int ih=0; ih<hcalMEs.size(); ih++) {
107  sprintf (name, "HcalHitE%s%s", time[i].c_str(),divisions[j].c_str());
108  if (strcmp(hcalMEs[ih]->getName().c_str(), name) == 0) {
109  Occupancy_map[i][j]= hcalMEs[ih];
110  }
111  }
112  }
113  }
114 
115  for (int k=0; k<nType;k++) {
116  HitEnergyvsieta[k]= 0;
117  HitTimevsieta[k]= 0;
118  for (unsigned int ih=0; ih<hcalMEs.size(); ih++) {
119  sprintf (name3, "HcalHitEta%s",divisions[k].c_str());
120  sprintf (name4, "HcalHitTimeAEta%s",divisions[k].c_str());
121  if (strcmp(hcalMEs[ih]->getName().c_str(), name3) == 0) {
122  HitEnergyvsieta[k]= hcalMEs[ih];
123  }
124  if (strcmp(hcalMEs[ih]->getName().c_str(), name4) == 0) {
125  HitTimevsieta[k]= hcalMEs[ih];
126  }
127  }
128  }
129 
130  //mean energy
131 
132  double nevent = Energy[0]->getEntries();
133  if (verbose_) std::cout<<"nevent : "<<nevent<<std::endl;
134 
135  float cont[nTime][nType];
136  float en[nType1], tme[nType1];
137  float hitenergy[nType], hittime[nType];
138  float fev = float(nevent);
139 
140  for (int dettype=0; dettype<nType1; dettype++) {
141  int nx1=Energy[dettype]->getNbinsX();
142  for (int i=0; i<=nx1; i++) {
143  en[dettype]= Energy[dettype]->getBinContent(i)/fev;
144  Energy[dettype]->setBinContent(i,en[dettype]);
145  }
146  int nx2= Time_weighteden[dettype]->getNbinsX();
147  for (int i=0; i<=nx2; i++) {
148  //std::cout<<" time_eneweighted for bin: "<< i<<"is:"<<Time_weighteden[dettype]->getBinContent(i)<<std::endl;
149  tme[dettype]= Time_weighteden[dettype]->getBinContent(i)/fev;
150  //std::cout<<" averagetime for bin : "<<i<<"is:"<<tme[dettype]<<std::endl;
151  Time_weighteden[dettype]->setBinContent(i,tme[dettype]);
152  }
153  }
154 
155  for (int dettype=0; dettype<nType; dettype++) {
156  if (HitEnergyvsieta[dettype] != 0) {
157  int nx1=HitEnergyvsieta[dettype]->getNbinsX();
158  for (int i=0; i<=nx1; i++) {
159  hitenergy[dettype]= HitEnergyvsieta[dettype]->getBinContent(i)/fev;
160  HitEnergyvsieta[dettype]->setBinContent(i,hitenergy[dettype]);
161  }
162  int nx2= HitTimevsieta[dettype]->getNbinsX();
163  for (int i=0; i<=nx2; i++) {
164  hittime[dettype]= HitTimevsieta[dettype]->getBinContent(i)/fev;
165  HitTimevsieta[dettype]->setBinContent(i,hittime[dettype]);
166  }
167  }
168  }
169 
170  for (int itime=0; itime<nTime; itime++) {
171  for (int det=0; det<nType;det++) {
172  if (Occupancy_map[itime][det] != 0) {
173  int ny= Occupancy_map[itime][det]->getNbinsY();
174  int nx= Occupancy_map[itime][det]->getNbinsX();
175  for (int i=1; i<nx+1; i++) {
176  for (int j=1; j<ny+1; j++) {
177  cont[itime][det] = Occupancy_map[itime][det]->getBinContent(i,j)/fev;
178  Occupancy_map[itime][det]->setBinContent(i,j,cont[itime][det]);
179  }
180  }
181  }
182  }
183  }
184 
185  return 1;
186 }
187 
std::vector< MonitorElement * > getContents(Args &&...args)
Definition: DQMStore.h:196
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void setBinContent(int binx, double content)
set content of bin (1-D)
int ib
Definition: cuy.py:660
static const int nType1
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int SimHitsEndjob(const std::vector< MonitorElement * > &hcalMEs)
virtual void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &)
double getEntries(void) const
get # of entries
int getNbinsY(void) const
get # of bins in Y-axis
int nevent
Definition: AMPTWrapper.h:74
static const int nType
std::string outputFile_
int j
Definition: DBlmapReader.cc:9
virtual void runClient_(DQMStore::IBooker &, DQMStore::IGetter &)
int k[5][pyjets_maxn]
virtual ~HcalSimHitsClient()
static const int nTime
int cont
std::vector< std::string > getSubdirs(void)
Definition: DQMStore.cc:295
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:319
double getBinContent(int binx) const
get content of bin (1-D)
HcalSimHitsClient(const edm::ParameterSet &)
int getNbinsX(void) const
get # of bins in X-axis
tuple cout
Definition: gather_cfg.py:121