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 
8 
9 #include <cmath>
10 
11 namespace ecaldqm
12 {
15  toleranceMean_(0.),
16  toleranceMeanFwd_(0.),
17  toleranceRMS_(0.),
18  toleranceRMSFwd_(0.),
19  minChannelEntries_(0),
20  minChannelEntriesFwd_(0),
21  minTowerEntries_(0),
22  minTowerEntriesFwd_(0),
23  tailPopulThreshold_(0.)
24  {
25  qualitySummaries_.insert("Quality");
26  qualitySummaries_.insert("QualitySummary");
27  }
28 
29  void
31  {
32  toleranceMean_ = _params.getUntrackedParameter<double>("toleranceMean");
33  toleranceMeanFwd_ = _params.getUntrackedParameter<double>("toleranceMeanFwd");
34  toleranceRMS_ = _params.getUntrackedParameter<double>("toleranceRMS");
35  toleranceRMSFwd_ = _params.getUntrackedParameter<double>("toleranceRMSFwd");
36  minChannelEntries_ = _params.getUntrackedParameter<int>("minChannelEntries");
37  minChannelEntriesFwd_ = _params.getUntrackedParameter<int>("minChannelEntriesFwd");
38  minTowerEntries_ = _params.getUntrackedParameter<int>("minTowerEntries");
39  minTowerEntriesFwd_ = _params.getUntrackedParameter<int>("minChannelEntriesFwd");
40  tailPopulThreshold_ = _params.getUntrackedParameter<double>("tailPopulThreshold");
41  }
42 
43  void
45  {
46  MESet& meQuality(MEs_.at("Quality"));
47  MESet& meMeanSM(MEs_.at("MeanSM"));
48  MESet& meMeanAll(MEs_.at("MeanAll"));
49  MESet& meFwdBkwdDiff(MEs_.at("FwdBkwdDiff"));
50  MESet& meFwdvBkwd(MEs_.at("FwdvBkwd"));
51  MESet& meRMSMap(MEs_.at("RMSMap"));
52  MESet& meRMSAll(MEs_.at("RMSAll"));
53  MESet& meProjEta(MEs_.at("ProjEta"));
54  MESet& meProjPhi(MEs_.at("ProjPhi"));
55  MESet& meQualitySummary(MEs_.at("QualitySummary"));
56 
57  MESet const& sTimeAllMap(sources_.at("TimeAllMap"));
58  MESet const& sTimeMap(sources_.at("TimeMap"));
59 
61 
62  MESet::iterator qEnd(meQuality.end());
63 
64  MESet::iterator rItr(meRMSMap);
65  MESet::const_iterator tItr(sTimeMap);
66 
67  for(MESet::iterator qItr(meQuality.beginChannel()); qItr != qEnd; qItr.toNextChannel()){
68 
69  tItr = qItr;
70  rItr = qItr;
71 
72  DetId id(qItr->getId());
73 
75  float meanThresh(toleranceMean_);
76  float rmsThresh(toleranceRMS_);
77 
78  if(isForward(id)){
79  minChannelEntries = minChannelEntriesFwd_;
80  meanThresh = toleranceMeanFwd_;
81  rmsThresh = toleranceRMSFwd_;
82  }
83 
84  bool doMask(meQuality.maskMatches(id, mask, statusManager_));
85 
86  float entries(tItr->getBinEntries());
87 
88  if(entries < minChannelEntries){
89  qItr->setBinContent(doMask ? kMUnknown : kUnknown);
90  rItr->setBinContent(-1.);
91  continue;
92  }
93 
94  float mean(tItr->getBinContent());
95  float rms(tItr->getBinError() * sqrt(entries));
96 
97  meMeanSM.fill(id, mean);
98  meMeanAll.fill(id, mean);
99  meProjEta.fill(id, mean);
100  meProjPhi.fill(id, mean);
101  meRMSAll.fill(id, rms);
102  rItr->setBinContent(rms);
103 
104  bool negative(false);
105  float posTime(0.);
106 
107  if(id.subdetId() == EcalBarrel){
108  EBDetId ebid(id);
109  if(ebid.zside() < 0){
110  negative = true;
111  EBDetId posId(EBDetId::switchZSide(ebid));
112  posTime = sTimeMap.getBinContent(posId);
113  }
114  }
115  else{
116  EEDetId eeid(id);
117  if(eeid.zside() < 0){
118  negative = true;
119  EEDetId posId(EEDetId::switchZSide(eeid));
120  posTime = sTimeMap.getBinContent(posId);
121  }
122  }
123  if(negative){
124  meFwdBkwdDiff.fill(id, posTime - mean);
125  meFwdvBkwd.fill(id, mean, posTime);
126  }
127 
128  if(abs(mean) > meanThresh || rms > rmsThresh)
129  qItr->setBinContent(doMask ? kMBad : kBad);
130  else
131  qItr->setBinContent(doMask ? kMGood : kGood);
132  }
133 
134  MESet::iterator qsEnd(meQualitySummary.end());
135 
136  for(MESet::iterator qsItr(meQualitySummary.beginChannel()); qsItr != qsEnd; qsItr.toNextChannel()){
137 
138  DetId tId(qsItr->getId());
139 
140  std::vector<DetId> ids;
141 
142  if(tId.subdetId() == EcalTriggerTower)
144  else
145  ids = scConstituents(EcalScDetId(tId));
146 
148  float meanThresh(toleranceMean_);
149  float rmsThresh(toleranceRMS_);
150 
151  if(isForward(tId)){
152  minTowerEntries = minTowerEntriesFwd_;
153  meanThresh = toleranceMeanFwd_;
154  rmsThresh = toleranceRMSFwd_;
155  }
156 
157  // tower entries != sum(channel entries) because of the difference in timing cut at the source
158  float summaryEntries(sTimeAllMap.getBinEntries(tId));
159 
160  float towerEntries(0.);
161  float towerMean(0.);
162  float towerMean2(0.);
163 
164  bool doMask(false);
165 
166  for(std::vector<DetId>::iterator idItr(ids.begin()); idItr != ids.end(); ++idItr){
167  DetId& id(*idItr);
168 
169  doMask |= meQuality.maskMatches(id, mask, statusManager_);
170 
171  MESet::const_iterator tmItr(sTimeMap, id);
172 
173  float entries(tmItr->getBinEntries());
174  if(entries < 0.) continue;
175  towerEntries += entries;
176  float mean(tmItr->getBinContent());
177  towerMean += mean * entries;
178  float rms(tmItr->getBinError() * sqrt(entries));
179  towerMean2 += (rms * rms + mean * mean) * entries;
180  }
181 
182  double quality(doMask ? kMUnknown : kUnknown);
183  if(towerEntries / ids.size() > minTowerEntries / 25.){
184  if(summaryEntries < towerEntries * (1. - tailPopulThreshold_)) // large timing deviation
185  quality = doMask ? kMBad : kBad;
186  else{
187  towerMean /= towerEntries;
188  towerMean2 /= towerEntries;
189 
190  float towerRMS(sqrt(towerMean2 - towerMean * towerMean));
191 
192  if(abs(towerMean) > meanThresh || towerRMS > rmsThresh)
193  quality = doMask ? kMBad : kBad;
194  else
195  quality = doMask ? kMGood : kGood;
196  }
197  }
198 
199  qsItr->setBinContent(quality);
200  }
201  }
202 
204 }
205 
T getUntrackedParameter(std::string const &, T const &) const
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:108
static const int PHYSICS_BAD_CHANNEL_WARNING
double getBinEntries() const
Definition: MESet.h:179
bool isForward(DetId const &)
EBDetId switchZSide() const
Definition: EBDetId.cc:82
const_iterator & toNextChannel()
Definition: MESet.h:271
std::set< std::string > qualitySummaries_
void setParams(edm::ParameterSet const &) override
Definition: TimingClient.cc:30
T sqrt(T t)
Definition: SSEVec.h:48
EcalTrigTowerConstituentsMap const * getTrigTowerMap()
StatusManager const * statusManager_
double getBinError() const
Definition: MESet.h:174
int zside() const
Definition: EEDetId.h:70
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< DetId > constituentsOf(const EcalTrigTowerDetId &id) const
Get the constituent detids for this tower id.
MESetCollection sources_
EEDetId switchZSide() const
Definition: EEDetId.cc:487
Definition: DetId.h:18
MESetCollection MEs_
Definition: DQWorker.h:75
double getBinContent() const
Definition: MESet.h:169
std::vector< DetId > scConstituents(EcalScDetId const &)
void producePlots(ProcessType) override
Definition: TimingClient.cc:44
int zside() const
get the z-side of the crystal (1/-1)
Definition: EBDetId.h:47