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
CaloTowersClient Class Reference

#include <CaloTowersClient.h>

Inheritance diagram for CaloTowersClient:
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)
 
 CaloTowersClient (const edm::ParameterSet &)
 
int CaloTowersEndjob (const std::vector< MonitorElement * > &hcalMEs)
 
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)
 
virtual void runClient_ ()
 
virtual ~CaloTowersClient ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- 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 CaloTowersClient.h.

Constructor & Destructor Documentation

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

Definition at line 12 of file CaloTowersClient.cc.

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

12  :conf_(iConfig)
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");
30 
31 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::string outputFile_
void setVerbose(unsigned level)
Definition: DQMStore.cc:398
edm::ParameterSet conf_
std::string dirName_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
CaloTowersClient::~CaloTowersClient ( )
virtual

Definition at line 34 of file CaloTowersClient.cc.

35 {
36 
37 }

Member Function Documentation

void CaloTowersClient::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 62 of file CaloTowersClient.cc.

63 {
64 
65 }
void CaloTowersClient::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 39 of file CaloTowersClient.cc.

40 {
41 
42 
43 }
void CaloTowersClient::beginRun ( const edm::Run run,
const edm::EventSetup c 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 50 of file CaloTowersClient.cc.

51 {
52 
53 }
int CaloTowersClient::CaloTowersEndjob ( const std::vector< MonitorElement * > &  hcalMEs)

Definition at line 108 of file CaloTowersClient.cc.

References cont, gather_cfg::cout, alignCSCRings::e, MonitorElement::getEntries(), MonitorElement::getNbinsX(), MonitorElement::getNbinsY(), i, j, nevent, and verbose_.

Referenced by runClient_().

108  {
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 }
int i
Definition: DBlmapReader.cc:9
double getEntries(void) const
get # of entries
int getNbinsY(void) const
get # of bins in Y-axis
int nevent
Definition: AMPTWrapper.h:74
int j
Definition: DBlmapReader.cc:9
int cont
int getNbinsX(void) const
get # of bins in X-axis
tuple cout
Definition: gather_cfg.py:121
void CaloTowersClient::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 45 of file CaloTowersClient.cc.

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

46 {
47  if ( outputFile_.size() != 0 && dbe_ ) dbe_->save(outputFile_);
48 }
std::string outputFile_
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2118
void CaloTowersClient::endLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 67 of file CaloTowersClient.cc.

68 {
69 // runClient_();
70 }
void CaloTowersClient::endRun ( const edm::Run run,
const edm::EventSetup c 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 56 of file CaloTowersClient.cc.

References runClient_().

57 {
58  runClient_();
59 }
virtual void runClient_()
void CaloTowersClient::runClient_ ( )
virtual

Definition at line 72 of file CaloTowersClient.cc.

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

Referenced by endRun().

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 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1424
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:1502
std::string dirName_
tuple cout
Definition: gather_cfg.py:121
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434

Member Data Documentation

edm::ParameterSet CaloTowersClient::conf_
private

Definition at line 42 of file CaloTowersClient.h.

DQMStore* CaloTowersClient::dbe_
private

Definition at line 39 of file CaloTowersClient.h.

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

bool CaloTowersClient::debug_
private

Definition at line 45 of file CaloTowersClient.h.

Referenced by CaloTowersClient().

std::string CaloTowersClient::dirName_
private

Definition at line 47 of file CaloTowersClient.h.

Referenced by CaloTowersClient(), and runClient_().

std::string CaloTowersClient::dirNameJet_
private

Definition at line 48 of file CaloTowersClient.h.

std::string CaloTowersClient::dirNameMET_
private

Definition at line 49 of file CaloTowersClient.h.

std::string CaloTowersClient::outputFile_
private

Definition at line 40 of file CaloTowersClient.h.

Referenced by CaloTowersClient(), and endJob().

bool CaloTowersClient::verbose_
private

Definition at line 44 of file CaloTowersClient.h.

Referenced by CaloTowersClient(), CaloTowersEndjob(), and runClient_().