CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DQWorker.cc
Go to the documentation of this file.
2 
4 
13 
14 namespace ecaldqm{
15 
16  std::map<std::string, std::vector<MEData> > DQWorker::meData;
17 
18  DQWorker::DQWorker(const edm::ParameterSet &, const edm::ParameterSet& _paths, std::string const& _name) :
19  name_(_name),
20  MEs_(0),
21  initialized_(false),
22  verbosity_(0)
23  {
24  using namespace std;
25 
26  map<string, vector<MEData> >::iterator dItr(meData.find(name_));
27  if(dItr == meData.end())
28  throw cms::Exception("InvalidCall") << "MonitorElement setup data not found for " << name_ << std::endl;
29 
30  vector<MEData> const& vData(dItr->second);
31  MEs_.resize(vData.size());
32 
33  for(unsigned iME(0); iME < MEs_.size(); iME++){
34  MEData& data(meData[name_].at(iME));
35  string fullpath(_paths.getUntrackedParameter<string>(data.pathName));
36 
37  MEs_.at(iME) = createMESet_(fullpath, data);
38  }
39  }
40 
42  {
43  for(unsigned iME(0); iME < MEs_.size(); iME++)
44  delete MEs_[iME];
45  }
46 
47  void
49  {
50  for(unsigned iME(0); iME < MEs_.size(); iME++)
51  if(MEs_[iME]) MEs_[iME]->book();
52  }
53 
54  void
56  {
57  for(unsigned iME(0); iME < MEs_.size(); iME++)
58  if(MEs_[iME]) MEs_[iME]->clear();
59 
60  initialized_ = false;
61  }
62 
63  /*static*/
64  void
65  DQWorker::setMEData(std::vector<MEData>&)
66  {
67  }
68 
69  MESet*
70  DQWorker::createMESet_(std::string const& _fullpath, MEData const& _data, bool _readOnly/* = false*/) const
71  {
72  BinService::ObjectType otype(_data.otype);
73  BinService::BinningType btype(_data.btype);
74  MonitorElement::Kind kind(_data.kind);
75 
76  if(otype == BinService::nObjType)
77  return new MESetNonObject(_fullpath, _data, _readOnly);
78 
79  if(otype == BinService::kChannel)
80  return new MESetChannel(_fullpath, _data, _readOnly);
81 
82  if(btype == BinService::kTrend)
83  return new MESetTrend(_fullpath, _data, _readOnly);
84 
85  unsigned logicalDimensions;
86  switch(kind){
88  logicalDimensions = 0;
89  break;
92  logicalDimensions = 1;
93  break;
96  logicalDimensions = 2;
97  break;
98  default:
99  throw cms::Exception("InvalidCall") << "Histogram type " << kind << " not supported" << std::endl;
100  }
101 
102  // example case: Ecal/TriggerPrimitives/EmulMatching/TrigPrimTask matching index
103  if(logicalDimensions == 2 && _data.yaxis && btype != BinService::kUser) logicalDimensions = 1;
104 
105  // for EventInfo summary contents
106  if(btype == BinService::kReport){
107  if(logicalDimensions != 0)
108  throw cms::Exception("InvalidCall") << "Report can only be a DQM_KIND_REAL" << std::endl;
109  }
110 
111  if(btype == BinService::kUser)
112  return new MESetEcal(_fullpath, _data, logicalDimensions, _readOnly);
113 
114  if(logicalDimensions == 0)
115  return new MESetDet0D(_fullpath, _data, _readOnly);
116 
117  if(logicalDimensions == 1)
118  return new MESetDet1D(_fullpath, _data, _readOnly);
119 
120  if(logicalDimensions == 2)
121  return new MESetDet2D(_fullpath, _data, _readOnly);
122 
123  return 0;
124  }
125 
126 
127 
128  std::map<std::string, WorkerFactory> SetWorker::workerFactories_;
129 
132  {
133  if(workerFactories_.find(_name) != workerFactories_.end()) return workerFactories_[_name];
134  return NULL;
135  }
136 
137 }
138 
T getUntrackedParameter(std::string const &, T const &) const
BinService::ObjectType otype
Definition: MESet.h:22
std::string pathName
Definition: MESet.h:21
BinService::AxisSpecs * yaxis
Definition: MESet.h:26
MonitorElement::Kind kind
Definition: MESet.h:24
#define NULL
Definition: scimark2.h:8
static void setMEData(std::vector< MEData > &)
Definition: DQWorker.cc:65
static std::map< std::string, WorkerFactory > workerFactories_
Definition: DQWorker.h:88
virtual void reset()
Definition: DQWorker.cc:55
BinService::BinningType btype
Definition: MESet.h:23
DQWorker(const edm::ParameterSet &, const edm::ParameterSet &, std::string const &)
Definition: DQWorker.cc:18
DQWorker *(* WorkerFactory)(const edm::ParameterSet &, const edm::ParameterSet &)
Definition: DQWorker.h:64
static WorkerFactory findFactory(const std::string &)
Definition: DQWorker.cc:131
virtual void bookMEs()
Definition: DQWorker.cc:48
std::vector< MESet * > MEs_
Definition: DQWorker.h:56
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
MESet * createMESet_(std::string const &, MEData const &, bool _readOnly=false) const
Definition: DQWorker.cc:70
volatile std::atomic< bool > shutdown_flag false
virtual ~DQWorker()
Definition: DQWorker.cc:41
std::string name_
Definition: DQWorker.h:55
list at
Definition: asciidump.py:428
static std::map< std::string, std::vector< MEData > > meData
Definition: DQWorker.h:47