CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DQWorkerClient.cc
Go to the documentation of this file.
3 
5 
7 
8 namespace ecaldqm {
9 
12 
13  DQWorkerClient::DQWorkerClient(const edm::ParameterSet &_params, const edm::ParameterSet& _paths, std::string const& _name) :
14  DQWorker(_params, _paths, _name),
15  sources_(0)
16  {
17  }
18 
19  void
21  {
22  for(std::vector<MESet const*>::iterator sItr(sources_.begin()); sItr != sources_.end(); ++sItr){
23  MESetChannel const* meset(dynamic_cast<MESetChannel const*>(*sItr));
24  if(meset) meset->checkDirectory();
25  }
26  }
27 
28  void
30  {
32  for(std::vector<MESet const*>::iterator sItr(sources_.begin()); sItr != sources_.end(); ++sItr)
33  (*sItr)->clear();
34  }
35 
36  void
38  {
39  initialized_ = true;
40  for(std::vector<MESet const*>::iterator sItr(sources_.begin()); sItr != sources_.end(); ++sItr)
41  initialized_ &= (*sItr)->retrieve();
42  }
43 
44  void
45  DQWorkerClient::source_(unsigned _iS, std::string const& _worker, unsigned _iW, edm::ParameterSet const& _sources)
46  {
47  if(_iS >= sources_.size()) sources_.resize(_iS + 1, 0);
48 
49  std::map<std::string, std::vector<MEData> >::const_iterator dataItr(meData.find(_worker));
50  if(dataItr == meData.end())
51  throw cms::Exception("InvalidCall") << "DQWorker " << _worker << " is not defined";
52 
53  MEData const& data(dataItr->second.at(_iW));
54 
55  edm::ParameterSet const& workerPaths(_sources.getUntrackedParameterSet(_worker));
56 
57  std::string fullpath(workerPaths.getUntrackedParameter<std::string>(data.pathName));
58 
59  sources_.at(_iS) = createMESet_(fullpath, data, true);
60  }
61 
62  void
63  DQWorkerClient::fillQuality_(unsigned _iME, DetId const& _id, uint32_t _mask, float _quality)
64  {
65  using namespace std;
66 
67  bool doMask(false);
68 
69  // turn off masking for good channel for the time being
70  // update the RP then enable again
71  if(_quality != 1. && channelStatus && towerStatus){
72  BinService::BinningType btype(MEs_[_iME]->getBinType());
73  bool searchTower(btype == BinService::kTriggerTower || btype == BinService::kSuperCrystal);
74 
75  switch(_id.subdetId()){
76  case EcalBarrel:
77  if(searchTower){
78  EcalTrigTowerDetId ttid(EBDetId(_id).tower());
79  int tccid(getElectronicsMap()->TCCid(ttid));
80  int itt(getElectronicsMap()->iTT(ttid));
81  vector<DetId> ids(getElectronicsMap()->ttConstituents(tccid, itt));
82  for(vector<DetId>::iterator idItr(ids.begin()); idItr != ids.end(); ++idItr){
83  if(doMask) break;
85  if(cItr != channelStatus->end()) doMask |= cItr->getStatusCode() & _mask;
86  }
87  }
88  else{
90  if(cItr != channelStatus->end()) doMask |= cItr->getStatusCode() & _mask;
91  }
92 
93  if(!doMask){
94  EcalDQMTowerStatus::const_iterator tItr(towerStatus->find(EBDetId(_id).tower().rawId()));
95  if(tItr != towerStatus->end()) doMask |= tItr->getStatusCode() & _mask;
96  }
97 
98  break;
99 
100  case EcalEndcap:
101  if(isEcalScDetId(_id)){
102  EcalScDetId scid(_id);
103  for(int ix(1); ix <= 5; ix++){
104  for(int iy(1); iy <= 5; iy++){
105  if(doMask) break;
106  int iix((scid.ix() - 1) * 5 + ix);
107  int iiy((scid.iy() - 1) * 5 + iy);
108  if(!EEDetId::validDetId(iix, iiy, scid.zside())) continue;
109  EcalDQMChannelStatus::const_iterator cItr(channelStatus->find(EEDetId(iix, iiy, scid.zside()).rawId()));
110  if(cItr != channelStatus->end()) doMask |= cItr->getStatusCode() & _mask;
111  }
112  }
113 
114  if(!doMask){
116  if(tItr != towerStatus->end()) doMask |= tItr->getStatusCode() & _mask;
117  }
118  }
119  else{
120  if(searchTower){
121  EcalScDetId scid(EEDetId(_id).sc());
122  for(int ix(1); ix <= 5; ix++){
123  for(int iy(1); iy <= 5; iy++){
124  if(doMask) break;
125  int iix((scid.ix() - 1) * 5 + ix);
126  int iiy((scid.iy() - 1) * 5 + iy);
127  if(!EEDetId::validDetId(iix, iiy, scid.zside())) continue;
128  EcalDQMChannelStatus::const_iterator cItr(channelStatus->find(EEDetId(iix, iiy, scid.zside()).rawId()));
129  if(cItr != channelStatus->end()) doMask |= cItr->getStatusCode() & _mask;
130  }
131  }
132  }
133  else{
135  if(cItr != channelStatus->end()) doMask |= cItr->getStatusCode() & _mask;
136  }
137 
138  if(!doMask){
140  if(tItr != towerStatus->end()) doMask |= tItr->getStatusCode() & _mask;
141  }
142  }
143 
144  break;
145 
146  case EcalTriggerTower:
147  {
148  EcalTrigTowerDetId ttid(_id);
149  vector<DetId> ids(getTrigTowerMap()->constituentsOf(ttid));
150  for(vector<DetId>::iterator idItr(ids.begin()); idItr != ids.end(); ++idItr){
151  if(doMask) break;
153  if(cItr != channelStatus->end()) doMask |= cItr->getStatusCode() & _mask;
154 
155  if(doMask) break;
156  if(idItr->subdetId() == EcalBarrel){
157  if(idItr != ids.begin()) continue;
159  if(tItr != towerStatus->end()) doMask |= tItr->getStatusCode() & _mask;
160  }
161  else{
163  if(tItr != towerStatus->end()) doMask |= tItr->getStatusCode() & _mask;
164  }
165  }
166  }
167 
168  break;
169 
170  default:
171  break;
172  }
173  }
174 
175  float quality(doMask ? _quality + 3. : _quality);
176 
177  MEs_[_iME]->setBinContent(_id, quality);
178  }
179 
180 }
const EcalElectronicsMapping * getElectronicsMap()
void source_(unsigned, std::string const &, unsigned, edm::ParameterSet const &)
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.cc:562
const_iterator find(uint32_t rawId) const
virtual void initialize()
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
static EcalDQMChannelStatus const * channelStatus
virtual void reset()
Definition: DQWorker.cc:55
int ix() const
Definition: EcalScDetId.h:72
ParameterSet const & getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
EcalTrigTowerDetId tower() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.h:52
DQWorkerClient(const edm::ParameterSet &, const edm::ParameterSet &, std::string const &)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
bool isEcalScDetId(const DetId &_id)
int iy() const
Definition: EcalScDetId.h:78
void checkDirectory() const
Definition: DetId.h:20
std::vector< MESet * > MEs_
Definition: DQWorker.h:56
std::vector< Item >::const_iterator const_iterator
EcalScDetId sc() const
Definition: EEDetId.h:83
int zside() const
Definition: EcalScDetId.h:66
const EcalTrigTowerConstituentsMap * getTrigTowerMap()
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::vector< MESet const * > sources_
MESet * createMESet_(std::string const &, MEData const &, bool _readOnly=false) const
Definition: DQWorker.cc:70
const_iterator find(uint32_t rawId) const
const_iterator end() const
std::vector< Item >::const_iterator const_iterator
void fillQuality_(unsigned, DetId const &, uint32_t, float)
virtual void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
static EcalDQMTowerStatus const * towerStatus
static std::map< std::string, std::vector< MEData > > meData
Definition: DQWorker.h:47