CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
OccupancyClient.cc
Go to the documentation of this file.
1 #include "../interface/OccupancyClient.h"
2 
8 
10 
12 
13 namespace ecaldqm {
14 
16  DQWorkerClient(_params, _paths, "OccupancyClient"),
17  geometry_(0),
18  minHits_(0),
19  deviationThreshold_(0.)
20  {
21  edm::ParameterSet const& taskParams(_params.getUntrackedParameterSet(name_));
22  minHits_ = taskParams.getUntrackedParameter<int>("minHits");
23  deviationThreshold_ = taskParams.getUntrackedParameter<double>("deviationThreshold");
24 
25  edm::ParameterSet const& sources(_params.getUntrackedParameterSet("sources"));
26  source_(sDigi, "OccupancyTask", OccupancyTask::kDigi, sources);
27  source_(sRecHitThr, "OccupancyTask", OccupancyTask::kRecHitThr, sources);
28  source_(sTPDigiThr, "OccupancyTask", OccupancyTask::kTPDigiThr, sources);
29  }
30 
31  void
33  {
35  _es.get<CaloGeometryRecord>().get(geomHndl);
36  geometry_ = geomHndl.product();
37  if(!geometry_)
38  throw cms::Exception("EventSetup") << "CaloGeometry invalid";
39  }
40 
41  void
43  {
45 
46  MEs_[kQualitySummary]->resetAll(-1.);
47  }
48 
49  void
51  {
52  using namespace std;
53 
54  MEs_[kHotDigi]->reset();
55  MEs_[kHotRecHitThr]->reset();
56  MEs_[kHotTPDigiThr]->reset();
57 
59 
60  vector<double> digiPhiRingMean(28, 0.);
61  vector<double> rechitPhiRingMean(28, 0.);
62  vector<int> numCrystals(28, 0); // this is static, but is easier to count now
63 
64  for(unsigned dccid(1); dccid <= 54; dccid++){
65  for(unsigned tower(1); tower <= getNSuperCrystals(dccid); tower++){
66  vector<DetId> ids(getElectronicsMap()->dccTowerConstituents(dccid, tower));
67 
68  if(ids.size() == 0) continue;
69 
70  for(vector<DetId>::iterator idItr(ids.begin()); idItr != ids.end(); ++idItr){
71  float entries(sources_[sDigi]->getBinContent(*idItr));
72  float rhentries(sources_[sRecHitThr]->getBinContent(*idItr));
73 
74  int ieta(getTrigTowerMap()->towerOf(*idItr).ietaAbs());
75  digiPhiRingMean.at(ieta - 1) += entries;
76  rechitPhiRingMean.at(ieta - 1) += rhentries;
77 
78  numCrystals.at(ieta - 1) += 1;
79  }
80  }
81  }
82 
83  for(int ie(0); ie < 28; ie++){
84  digiPhiRingMean[ie] /= numCrystals[ie];
85  rechitPhiRingMean[ie] /= numCrystals[ie];
86  }
87 
88  // second round to find hot towers
89  for(unsigned dccid(1); dccid <= 54; dccid++){
90  for(unsigned tower(1); tower <= getNSuperCrystals(dccid); tower++){
91  vector<DetId> ids(getElectronicsMap()->dccTowerConstituents(dccid, tower));
92 
93  if(ids.size() == 0) continue;
94 
95  float quality(1.);
96  for(vector<DetId>::iterator idItr(ids.begin()); idItr != ids.end(); ++idItr){
97  float entries(sources_[sDigi]->getBinContent(*idItr));
98  float rhentries(sources_[sRecHitThr]->getBinContent(*idItr));
99 
100  int ieta(getTrigTowerMap()->towerOf(*idItr).ietaAbs());
101 
102  if(entries > minHits_ && entries > digiPhiRingMean.at(ieta - 1) * deviationThreshold_){
103  MEs_[kHotDigi]->fill(*idItr);
104  quality = 0.;
105  }
106  if(rhentries > minHits_ && rhentries > rechitPhiRingMean.at(ieta - 1) * deviationThreshold_){
107  MEs_[kHotRecHitThr]->fill(*idItr);
108  quality = 0.;
109  }
110  }
111  if(dccid <= 9 || dccid >= 46){
112  vector<EcalScDetId> scs(getElectronicsMap()->getEcalScDetId(dccid, tower));
113  for(vector<EcalScDetId>::iterator scItr(scs.begin()); scItr != scs.end(); ++scItr)
114  fillQuality_(kQualitySummary, *scItr, mask, quality);
115  }
116  else
117  fillQuality_(kQualitySummary, ids[0], mask, quality);
118  }
119  }
120 
121  vector<double> tpdigiPhiRingMean(28, 0.);
122 
123  for(unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++){
125  float entries(sources_[sTPDigiThr]->getBinContent(ttid));
126 
127  tpdigiPhiRingMean.at(ttid.ietaAbs() - 1) += entries;
128  }
129 
130  for(int ie(0); ie < 28; ie++){
131  float denom(-1.);
132  if(ie < 27) denom = 72.;
133  else denom = 36.;
134  tpdigiPhiRingMean[ie] /= denom;
135  }
136 
137  for(unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++){
139  float entries(sources_[sTPDigiThr]->getBinContent(ttid));
140 
141  if(entries > minHits_ && entries > tpdigiPhiRingMean.at(ttid.ietaAbs() - 1) * deviationThreshold_){
142  MEs_[kHotTPDigiThr]->fill(ttid);
143  vector<DetId> ids(getTrigTowerMap()->constituentsOf(ttid));
144  for(vector<DetId>::iterator idItr(ids.begin()); idItr != ids.end(); ++idItr){
145  if(MEs_[kQualitySummary]->getBinContent(*idItr) > 0.)
146  fillQuality_(kQualitySummary, *idItr, mask, 0.);
147  }
148  }
149  }
150 
151  }
152 
153  /*static*/
154  void
155  OccupancyClient::setMEData(std::vector<MEData>& _data)
156  {
161  }
162 
164 }
165 
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
const EcalElectronicsMapping * getElectronicsMap()
const CaloGeometry * geometry_
static const int PEDESTAL_ONLINE_HIGH_GAIN_RMS_ERROR
void source_(unsigned, std::string const &, unsigned, edm::ParameterSet const &)
static void setMEData(std::vector< MEData > &)
int ietaAbs() const
get the absolute value of the tower ieta
ParameterSet const & getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
OccupancyClient(const edm::ParameterSet &, const edm::ParameterSet &)
virtual void bookMEs()
Definition: DQWorker.cc:48
std::vector< MESet * > MEs_
Definition: DQWorker.h:56
unsigned getNSuperCrystals(unsigned)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
const EcalTrigTowerConstituentsMap * getTrigTowerMap()
std::vector< MESet const * > sources_
DEFINE_ECALDQM_WORKER(CertificationClient)
void fillQuality_(unsigned, DetId const &, uint32_t, float)
std::string name_
Definition: DQWorker.h:55
Definition: Run.h:33
void beginRun(const edm::Run &, const edm::EventSetup &)