CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TimingClient.cc
Go to the documentation of this file.
1 #include "../interface/TimingClient.h"
2 
4 
6 
7 #include <cmath>
8 
9 namespace ecaldqm {
10 
12  DQWorkerClient(_params, _paths, "TimingClient"),
13  expectedMean_(0.),
14  meanThreshold_(0.),
15  rmsThreshold_(0.),
16  minChannelEntries_(0),
17  minTowerEntries_(0),
18  tailPopulThreshold_(0.)
19  {
20  edm::ParameterSet const& taskParams(_params.getUntrackedParameterSet(name_));
21  expectedMean_ = taskParams.getUntrackedParameter<double>("expectedMean");
22  meanThreshold_ = taskParams.getUntrackedParameter<double>("meanThreshold");
23  rmsThreshold_ = taskParams.getUntrackedParameter<double>("rmsThreshold");
24  minChannelEntries_ = taskParams.getUntrackedParameter<int>("minChannelEntries");
25  minTowerEntries_ = taskParams.getUntrackedParameter<int>("minTowerEntries");
26  tailPopulThreshold_ = taskParams.getUntrackedParameter<double>("tailPopulThreshold");
27 
28  edm::ParameterSet const& sources(_params.getUntrackedParameterSet("sources"));
29  source_(sTimeAllMap, "TimingTask", TimingTask::kTimeAllMap, sources);
30  source_(sTimeMap, "TimingTask", TimingTask::kTimeMap, sources);
31  }
32 
33  void
35  {
37 
38  MEs_[kQuality]->resetAll(-1.);
39  MEs_[kRMS]->resetAll(-1.);
40  MEs_[kQualitySummary]->resetAll(-1.);
41  }
42 
43  void
45  {
46  using namespace std;
47 
48  MEs_[kMeanSM]->reset();
49  MEs_[kMeanAll]->reset();
50  MEs_[kRMS]->reset(-1.);
51  MEs_[kRMSAll]->reset();
52  MEs_[kProjEta]->reset();
53  MEs_[kProjPhi]->reset();
54  MEs_[kFwdBkwdDiff]->reset();
55  MEs_[kFwdvBkwd]->reset();
56 
58 
59  for(unsigned dccid(1); dccid <= 54; dccid++){
60 
61  for(unsigned tower(1); tower <= getNSuperCrystals(dccid); tower++){
62  vector<DetId> ids(getElectronicsMap()->dccTowerConstituents(dccid, tower));
63 
64  if(ids.size() == 0) continue;
65 
66  // tower entries != sum(channel entries) because of the difference in timing cut at the source
67  float summaryEntries(0.);
68  if(dccid <= 9 || dccid >= 46){
69  vector<EcalScDetId> scids(getElectronicsMap()->getEcalScDetId(dccid, tower));
70  for(vector<EcalScDetId>::iterator scItr(scids.begin()); scItr != scids.end(); ++scItr)
71  summaryEntries += sources_[sTimeAllMap]->getBinEntries(*scItr);
72  }
73  else
74  summaryEntries = sources_[sTimeAllMap]->getBinEntries(ids[0]);
75 
76  float towerEntries(0.);
77  float towerMean(0.);
78  float towerMean2(0.);
79 
80  for(vector<DetId>::iterator idItr(ids.begin()); idItr != ids.end(); ++idItr){
81  float entries(sources_[sTimeMap]->getBinEntries(*idItr));
82  float mean(sources_[sTimeMap]->getBinContent(*idItr));
83  float rms(sources_[sTimeMap]->getBinError(*idItr) * sqrt(entries));
84 
85  towerEntries += entries;
86  towerMean += mean;
87  towerMean2 += mean * mean;
88 
89  if(entries < minChannelEntries_){
90  fillQuality_(kQuality, *idItr, mask, 2.);
91  continue;
92  }
93 
94  MEs_[kMeanSM]->fill(*idItr, mean);
95  MEs_[kMeanAll]->fill(*idItr, mean);
96  MEs_[kProjEta]->fill(*idItr, mean);
97  MEs_[kProjPhi]->fill(*idItr, mean);
98  MEs_[kRMS]->fill(*idItr, rms);
99  MEs_[kRMSAll]->fill(*idItr, rms);
100 
101  if(dccid <= 27){
102  DetId posId(0);
103  if(idItr->subdetId() == EcalEndcap){
104  posId = EEDetId::switchZSide(*idItr);
105  }
106  else{
107  posId = EBDetId::switchZSide(*idItr);
108  }
109  float posTime(sources_[sTimeMap]->getBinContent(posId));
110  MEs_[kFwdBkwdDiff]->fill(*idItr, posTime - mean);
111  MEs_[kFwdvBkwd]->fill(*idItr, mean, posTime);
112  }
113 
114  float quality(abs(mean - expectedMean_) > meanThreshold_ || rms > rmsThreshold_ ? 0. : 1.);
115  fillQuality_(kQuality, *idItr, mask, quality);
116  }
117 
118  float quality(1.);
119  if(towerEntries > minTowerEntries_){
120  if(summaryEntries < towerEntries * (1. - tailPopulThreshold_)) // large timing deviation
121  quality = 0.;
122 
123  towerMean /= ids.size();
124  towerMean2 /= ids.size();
125 
126  float towerRMS(0.);
127  float variance(towerMean2 - towerMean * towerMean);
128  if(variance > 0.) towerRMS = sqrt(variance);
129 
130  if(abs(towerMean - expectedMean_) > meanThreshold_ || towerRMS > rmsThreshold_)
131  quality = 0.;
132  }
133  else
134  quality = 2.;
135 
136  if(dccid <= 9 || dccid >= 46){
137  vector<EcalScDetId> scs(getElectronicsMap()->getEcalScDetId(dccid, tower));
138  for(vector<EcalScDetId>::iterator scItr(scs.begin()); scItr != scs.end(); ++scItr)
139  fillQuality_(kQualitySummary, *scItr, mask, quality);
140  }
141  else
142  fillQuality_(kQualitySummary, ids[0], mask, quality);
143  }
144  }
145  }
146 
147  /*static*/
148  void
149  TimingClient::setMEData(std::vector<MEData>& _data)
150  {
152 
154 
155  axis.nbins = 100;
156  axis.low = -25.;
157  axis.high = 25.;
160 
161  axis.nbins = 50;
163 
164  axis.low = -5.;
165  axis.high = 5.;
167 
169 
170  axis.nbins = 100;
171  axis.low = 0.;
172  axis.high = 10.;
177  }
178 
180 }
TimingClient(const edm::ParameterSet &, const edm::ParameterSet &)
Definition: TimingClient.cc:11
const EcalElectronicsMapping * getElectronicsMap()
static const int PHYSICS_BAD_CHANNEL_WARNING
EBDetId switchZSide() const
Definition: EBDetId.cc:82
#define abs(x)
Definition: mlp_lapack.h:159
void source_(unsigned, std::string const &, unsigned, edm::ParameterSet const &)
ParameterSet const & getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
T sqrt(T t)
Definition: SSEVec.h:48
EEDetId switchZSide() const
Definition: EEDetId.cc:487
Definition: DetId.h:20
virtual void bookMEs()
Definition: DQWorker.cc:48
std::vector< MESet * > MEs_
Definition: DQWorker.h:56
unsigned getNSuperCrystals(unsigned)
static void setMEData(std::vector< MEData > &)
std::vector< MESet const * > sources_
DEFINE_ECALDQM_WORKER(CertificationClient)
void fillQuality_(unsigned, DetId const &, uint32_t, float)
std::string name_
Definition: DQWorker.h:55