CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes | Static Private Attributes
HcalSimHitsClient Class Reference

#include <HcalSimHitsClient.h>

Inheritance diagram for HcalSimHitsClient:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob (void)
 
virtual void beginRun (const edm::Run &run, const edm::EventSetup &c)
 
virtual void endJob ()
 
virtual void endLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
 
virtual void endRun (const edm::Run &run, const edm::EventSetup &c)
 
 HcalSimHitsClient (const edm::ParameterSet &)
 
virtual void runClient_ ()
 
int SimHitsEndjob (const std::vector< MonitorElement * > &hcalMEs)
 
virtual ~HcalSimHitsClient ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

edm::ParameterSet conf_
 
DQMStoredbe_
 
bool debug_
 
std::string dirName_
 
std::string outputFile_
 
bool verbose_
 

Static Private Attributes

static const int nTime = 4
 
static const int nType = 25
 
static const int nType1 = 4
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 36 of file HcalSimHitsClient.h.

Constructor & Destructor Documentation

HcalSimHitsClient::HcalSimHitsClient ( const edm::ParameterSet iConfig)
explicit

Definition at line 12 of file HcalSimHitsClient.cc.

References dbe_, debug_, dirName_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), cppFunctionSkipper::operator, outputFile_, AlCaHLTBitMon_QueryRunRegistry::string, and verbose_.

12  :conf_(iConfig) {
13 
14  outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile", "myfile.root");
15 
17  if (!dbe_) {
18  edm::LogError("HcalSimHitsClient") << "unable to get DQMStore service, upshot is no client histograms will be made";
19  }
20  if (iConfig.getUntrackedParameter<bool>("DQMStore", false)) {
21  if (dbe_) dbe_->setVerbose(0);
22  }
23 
24  debug_ = false;
25  verbose_ = false;
26 
27  dirName_= iConfig.getParameter<std::string>("DQMDirName");
29 
30 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::ParameterSet conf_
std::string outputFile_
void setVerbose(unsigned level)
Definition: DQMStore.cc:619
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655
HcalSimHitsClient::~HcalSimHitsClient ( )
virtual

Definition at line 33 of file HcalSimHitsClient.cc.

33 { }

Member Function Documentation

void HcalSimHitsClient::analyze ( const edm::Event ,
const edm::EventSetup  
)
virtual

Implements edm::EDAnalyzer.

Definition at line 48 of file HcalSimHitsClient.cc.

48 { }
void HcalSimHitsClient::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 35 of file HcalSimHitsClient.cc.

35 { }
void HcalSimHitsClient::beginRun ( const edm::Run run,
const edm::EventSetup c 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 41 of file HcalSimHitsClient.cc.

41 { }
void HcalSimHitsClient::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 37 of file HcalSimHitsClient.cc.

References dbe_, outputFile_, and DQMStore::save().

37  {
38  if ( outputFile_.size() != 0 && dbe_ ) dbe_->save(outputFile_);
39 }
std::string outputFile_
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
void HcalSimHitsClient::endLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 50 of file HcalSimHitsClient.cc.

50 { }
void HcalSimHitsClient::endRun ( const edm::Run run,
const edm::EventSetup c 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 44 of file HcalSimHitsClient.cc.

References runClient_().

44  {
45  runClient_();
46 }
virtual void runClient_()
void HcalSimHitsClient::runClient_ ( )
virtual

Definition at line 52 of file HcalSimHitsClient.cc.

References gather_cfg::cout, dbe_, dirName_, DQMStore::getContents(), DQMStore::getSubdirs(), i, j, DQMStore::setCurrentFolder(), SimHitsEndjob(), and verbose_.

Referenced by endRun().

52  {
53 
54  if (!dbe_) return; //we dont have the DQMStore so we cant do anything
56 
57  if (verbose_) std::cout << "\nrunClient" << std::endl;
58 
59  std::vector<MonitorElement*> hcalMEs;
60 
61  std::vector<std::string> fullPathHLTFolders = dbe_->getSubdirs();
62  for (unsigned int i=0;i<fullPathHLTFolders.size();i++) {
63  if (verbose_) std::cout <<"\nfullPath: "<< fullPathHLTFolders[i] << std::endl;
64  dbe_->setCurrentFolder(fullPathHLTFolders[i]);
65 
66  std::vector<std::string> fullSubPathHLTFolders = dbe_->getSubdirs();
67  for (unsigned int j=0;j<fullSubPathHLTFolders.size();j++) {
68 
69  if (verbose_) std::cout <<"fullSub: "<<fullSubPathHLTFolders[j] << std::endl;
70 
71  if (strcmp(fullSubPathHLTFolders[j].c_str(), "HcalHitsV/SimHitsValidationHcal") == 0) {
72  hcalMEs = dbe_->getContents(fullSubPathHLTFolders[j]);
73  if (verbose_) std::cout <<"hltMES size : "<<hcalMEs.size()<<std::endl;
74  if( !SimHitsEndjob(hcalMEs) ) std::cout<<"\nError in SimhitEndjob!"<<std::endl<<std::endl;
75  }
76 
77  }
78 
79  }
80 
81 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1647
int SimHitsEndjob(const std::vector< MonitorElement * > &hcalMEs)
int j
Definition: DBlmapReader.cc:9
std::vector< MonitorElement * > getContents(const std::string &path) const
Definition: DQMStore.cc:1725
tuple cout
Definition: gather_cfg.py:121
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655
int HcalSimHitsClient::SimHitsEndjob ( const std::vector< MonitorElement * > &  hcalMEs)

Definition at line 85 of file HcalSimHitsClient.cc.

References cont, gather_cfg::cout, MonitorElement::getBinContent(), MonitorElement::getEntries(), MonitorElement::getNbinsX(), MonitorElement::getNbinsY(), i, j, gen::k, mergeVDriftHistosByStation::name, nevent, nTime, nType, nType1, MonitorElement::setBinContent(), AlCaHLTBitMon_QueryRunRegistry::string, cond::rpcobgas::time, and verbose_.

Referenced by runClient_().

85  {
86 
87  MonitorElement *Occupancy_map[nTime][nType];
88  MonitorElement *Energy[nType1], *Time_weighteden[nType1];
89  MonitorElement *HitEnergyvsieta[nType], *HitTimevsieta[nType];
90  std::string divisions[nType]={"HB0","HB1","HE0+z","HE1+z","HE2+z","HE0-z","HE1-z",
91  "HE2-z","HO0","HFL0+z","HFS0+z","HFL1+z","HFS1+z",
92  "HFL2+z","HFS2+z","HFL3+z","HFS3+z","HFL0-z","HFS0-z",
93  "HFL1-z","HFS1-z","HFL2-z","HFS2-z","HFL3-z","HFS3-z"};
94 
95  std::string time[nTime]={"25","50","100","250"};
96  std::string detdivision[nType1]={"HB","HE","HF","HO"};
97  char name[40], name1[40], name2[40], name3[40], name4[40];
98 
99  for (int k=0; k<nType1;k++) {
100  Energy[k] = 0;
101  Time_weighteden[k] = 0;
102  for (unsigned int ih=0; ih<hcalMEs.size(); ih++) {
103  sprintf (name1, "Energy_%s", detdivision[k].c_str());
104  sprintf (name2, "Time_Enweighted_%s", detdivision[k].c_str());
105  if (strcmp(hcalMEs[ih]->getName().c_str(), name1) == 0) {
106  Energy[k] = hcalMEs[ih];
107  }
108  if (strcmp(hcalMEs[ih]->getName().c_str(), name2) == 0) {
109  Time_weighteden[k] = hcalMEs[ih];
110  }
111  }
112  }
113 
114  for (int i=0; i<nTime; i++) {
115  for (int j=0; j<nType;j++) {
116  Occupancy_map[i][j]= 0;
117  for (unsigned int ih=0; ih<hcalMEs.size(); ih++) {
118  sprintf (name, "HcalHitE%s%s", time[i].c_str(),divisions[j].c_str());
119  if (strcmp(hcalMEs[ih]->getName().c_str(), name) == 0) {
120  Occupancy_map[i][j]= hcalMEs[ih];
121  }
122  }
123  }
124  }
125 
126  for (int k=0; k<nType;k++) {
127  HitEnergyvsieta[k]= 0;
128  HitTimevsieta[k]= 0;
129  for (unsigned int ih=0; ih<hcalMEs.size(); ih++) {
130  sprintf (name3, "HcalHitEta%s",divisions[k].c_str());
131  sprintf (name4, "HcalHitTimeAEta%s",divisions[k].c_str());
132  if (strcmp(hcalMEs[ih]->getName().c_str(), name3) == 0) {
133  HitEnergyvsieta[k]= hcalMEs[ih];
134  }
135  if (strcmp(hcalMEs[ih]->getName().c_str(), name4) == 0) {
136  HitTimevsieta[k]= hcalMEs[ih];
137  }
138  }
139  }
140 
141  //mean energy
142 
143  double nevent = Energy[0]->getEntries();
144  if (verbose_) std::cout<<"nevent : "<<nevent<<std::endl;
145 
146  float cont[nTime][nType];
147  float en[nType1], tme[nType1];
148  float hitenergy[nType], hittime[nType];
149  float fev = float(nevent);
150 
151  for (int dettype=0; dettype<nType1; dettype++) {
152  int nx1=Energy[dettype]->getNbinsX();
153  for (int i=0; i<=nx1; i++) {
154  en[dettype]= Energy[dettype]->getBinContent(i)/fev;
155  Energy[dettype]->setBinContent(i,en[dettype]);
156  }
157  int nx2= Time_weighteden[dettype]->getNbinsX();
158  for (int i=0; i<=nx2; i++) {
159  //std::cout<<" time_eneweighted for bin: "<< i<<"is:"<<Time_weighteden[dettype]->getBinContent(i)<<std::endl;
160  tme[dettype]= Time_weighteden[dettype]->getBinContent(i)/fev;
161  //std::cout<<" averagetime for bin : "<<i<<"is:"<<tme[dettype]<<std::endl;
162  Time_weighteden[dettype]->setBinContent(i,tme[dettype]);
163  }
164  }
165 
166  for (int dettype=0; dettype<nType; dettype++) {
167  if (HitEnergyvsieta[dettype] != 0) {
168  int nx1=HitEnergyvsieta[dettype]->getNbinsX();
169  for (int i=0; i<=nx1; i++) {
170  hitenergy[dettype]= HitEnergyvsieta[dettype]->getBinContent(i)/fev;
171  HitEnergyvsieta[dettype]->setBinContent(i,hitenergy[dettype]);
172  }
173  int nx2= HitTimevsieta[dettype]->getNbinsX();
174  for (int i=0; i<=nx2; i++) {
175  hittime[dettype]= HitTimevsieta[dettype]->getBinContent(i)/fev;
176  HitTimevsieta[dettype]->setBinContent(i,hittime[dettype]);
177  }
178  }
179  }
180 
181  for (int itime=0; itime<nTime; itime++) {
182  for (int det=0; det<nType;det++) {
183  if (Occupancy_map[itime][det] != 0) {
184  int ny= Occupancy_map[itime][det]->getNbinsY();
185  int nx= Occupancy_map[itime][det]->getNbinsX();
186  for (int i=1; i<nx+1; i++) {
187  for (int j=1; j<ny+1; j++) {
188  cont[itime][det] = Occupancy_map[itime][det]->getBinContent(i,j)/fev;
189  Occupancy_map[itime][det]->setBinContent(i,j,cont[itime][det]);
190  }
191  }
192  }
193  }
194  }
195 
196  return 1;
197 }
int i
Definition: DBlmapReader.cc:9
void setBinContent(int binx, double content)
set content of bin (1-D)
static const int nType1
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
int j
Definition: DBlmapReader.cc:9
int k[5][pyjets_maxn]
static const int nTime
int cont
double getBinContent(int binx) const
get content of bin (1-D)
int getNbinsX(void) const
get # of bins in X-axis
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

edm::ParameterSet HcalSimHitsClient::conf_
private

Definition at line 42 of file HcalSimHitsClient.h.

DQMStore* HcalSimHitsClient::dbe_
private

Definition at line 39 of file HcalSimHitsClient.h.

Referenced by endJob(), HcalSimHitsClient(), and runClient_().

bool HcalSimHitsClient::debug_
private

Definition at line 45 of file HcalSimHitsClient.h.

Referenced by HcalSimHitsClient().

std::string HcalSimHitsClient::dirName_
private

Definition at line 50 of file HcalSimHitsClient.h.

Referenced by HcalSimHitsClient(), and runClient_().

const int HcalSimHitsClient::nTime = 4
staticprivate

Definition at line 47 of file HcalSimHitsClient.h.

Referenced by SimHitsEndjob().

const int HcalSimHitsClient::nType = 25
staticprivate

Definition at line 46 of file HcalSimHitsClient.h.

Referenced by SimHitsEndjob().

const int HcalSimHitsClient::nType1 = 4
staticprivate

Definition at line 48 of file HcalSimHitsClient.h.

Referenced by SimHitsEndjob().

std::string HcalSimHitsClient::outputFile_
private

Definition at line 40 of file HcalSimHitsClient.h.

Referenced by endJob(), and HcalSimHitsClient().

bool HcalSimHitsClient::verbose_
private

Definition at line 44 of file HcalSimHitsClient.h.

Referenced by HcalSimHitsClient(), runClient_(), and SimHitsEndjob().