CMS 3D CMS Logo

TrigPrimClient.cc
Go to the documentation of this file.
1 #include "../interface/TrigPrimClient.h"
2 
5 
7 
9 
10 #include <cmath>
11 
12 namespace ecaldqm
13 {
16  minEntries_(0),
17  errorFractionThreshold_(0.),
18  TTF4MaskingAlarmThreshold_(0.)
19  {
20  qualitySummaries_.insert("EmulQualitySummary");
21  }
22 
23  void
25  {
26  minEntries_ = _params.getUntrackedParameter<int>("minEntries");
27  errorFractionThreshold_ = _params.getUntrackedParameter<double>("errorFractionThreshold");
28  TTF4MaskingAlarmThreshold_ = _params.getUntrackedParameter<double>("TTF4MaskingAlarmThreshold");
29  }
30 
31  void
33  {
34  MESet& meTimingSummary(MEs_.at("TimingSummary"));
35  MESet& meNonSingleSummary(MEs_.at("NonSingleSummary"));
36  MESet& meEmulQualitySummary(MEs_.at("EmulQualitySummary"));
37  MESet& meTrendTTF4Flags(MEs_.at("TrendTTF4Flags"));
38 
39  MESet const& sEtEmulError(sources_.at("EtEmulError"));
40  MESet const& sMatchedIndex(sources_.at("MatchedIndex"));
41  MESet const& sTPDigiThrAll(sources_.at("TPDigiThrAll"));
42  MESetNonObject const& sLHCStatusByLumi(static_cast<MESetNonObject&>(sources_.at("LHCStatusByLumi")));
43 
45 
46  // Store # of entries for Occupancy analysis
47  std::vector<float> Nentries(nDCC,0.);
48 
49  double currentLHCStatus = sLHCStatusByLumi.getFloatValue();
50  bool statsCheckEnabled = ((currentLHCStatus > 10.5 && currentLHCStatus < 11.5) || currentLHCStatus < 0); // currentLHCStatus = -1 is the default when no beam info is available
51 
52  for(unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++){
54 
55  bool doMask(meEmulQualitySummary.maskMatches(ttid, mask, statusManager_));
56 
57  float towerEntries(0.);
58  float tMax(0.5);
59  float nMax(0.);
60  for(int iBin(0); iBin < 6; iBin++){
61  float entries(sMatchedIndex.getBinContent(ttid, iBin + 1));
62  towerEntries += entries;
63 
64  if(entries > nMax){
65  nMax = entries;
66  tMax = iBin == 0 ? -0.5 : iBin + 0.5; // historical reasons.. much clearer to say "no entry = -0.5"
67  }
68  }
69 
70  meTimingSummary.setBinContent(ttid, tMax);
71 
72  if(towerEntries < minEntries_){
73  meEmulQualitySummary.setBinContent(ttid, doMask ? kMUnknown : kUnknown);
74  continue;
75  }
76 
77  float nonsingleFraction(1. - nMax / towerEntries);
78 
79  if(nonsingleFraction > 0.)
80  meNonSingleSummary.setBinContent(ttid, nonsingleFraction);
81 
82  if(sEtEmulError.getBinContent(ttid) / towerEntries > errorFractionThreshold_)
83  meEmulQualitySummary.setBinContent(ttid, doMask ? kMBad : kBad);
84  else
85  meEmulQualitySummary.setBinContent(ttid, doMask ? kMGood : kGood);
86 
87  // Keep count for Occupancy analysis
88  unsigned iDCC( dccId(ttid)-1 );
89  Nentries[iDCC] += sTPDigiThrAll.getBinContent(ttid);
90  }
91 
92  // Fill TTF4 v Masking ME
93  // NOT an occupancy plot: only tells you if non-zero TTF4 occupancy was seen
94  // without giving info about how many were seen
95  MESet& meTTF4vMask(MEs_.at("TTF4vMask"));
96  MESet const& sTTFlags4(sources_.at("TTFlags4"));
97  MESet const& sTTMaskMapAll(sources_.at("TTMaskMapAll"));
98 
99  std::vector<float> nWithTTF4(nDCC, 0.); // counters to keep track of number of towers in a DCC that have TTF4 flag set
100  int nWithTTF4_EE = 0; // total number of towers in EE with TTF4
101  int nWithTTF4_EB = 0; // total number of towers in EB with TTF4
102  // Loop over all TTs
103  for(unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++) {
105  unsigned iDCC( dccId(ttid)-1 );
106  bool isMasked( sTTMaskMapAll.getBinContent(ttid) > 0. );
107  bool hasTTF4( sTTFlags4.getBinContent(ttid) > 0. );
108  if (hasTTF4) {
109  nWithTTF4[iDCC]++;
110  if (ttid.subDet() == EcalBarrel) nWithTTF4_EB++;
111  else if (ttid.subDet() == EcalEndcap) nWithTTF4_EE++;
112  }
113  if ( isMasked ) {
114  if ( hasTTF4 )
115  meTTF4vMask.setBinContent( ttid,12 ); // Masked, has TTF4
116  else
117  meTTF4vMask.setBinContent( ttid,11 ); // Masked, no TTF4
118  } else {
119  if ( hasTTF4 )
120  meTTF4vMask.setBinContent( ttid,13 ); // not Masked, has TTF4
121  }
122  } // TT loop
123 
124  // Fill trend plots for number of TTs with TTF4 flag set
125  meTrendTTF4Flags.fill(EcalBarrel, double(timestamp_.iLumi), nWithTTF4_EB);
126  meTrendTTF4Flags.fill(EcalEndcap, double(timestamp_.iLumi), nWithTTF4_EE);
127 
128  // Quality check: set an entire FED to BAD if a more than 80% of the TTs in that FED show any DCC-SRP flag mismatch errors
129  // Fill flag mismatch statistics
130  std::vector<float> nTTs(nDCC,0.);
131  std::vector<float> nTTFMismath(nDCC,0.);
132  MESet const& sTTFMismatch(sources_.at("TTFMismatch"));
133  for ( unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++ ) {
135  unsigned iDCC( dccId(ttid)-1 );
136  if ( sTTFMismatch.getBinContent(ttid) > 0. )
137  nTTFMismath[iDCC]++;
138  nTTs[iDCC]++;
139  }
140  // Analyze flag mismatch statistics and TTF4 fraction statistics
141  for ( unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++ ) {
143  unsigned iDCC( dccId(ttid)-1 );
144  if ( nTTFMismath[iDCC] > 0.8*nTTs[iDCC] || nWithTTF4[iDCC] > TTF4MaskingAlarmThreshold_*nTTs[iDCC]) {
145  meEmulQualitySummary.setBinContent( ttid, meEmulQualitySummary.maskMatches(ttid, mask, statusManager_) ? kMBad : kBad );
146  }
147  }
148 
149  // Quality check: set entire FED to BAD if its occupancy begins to vanish
150  // Fill FED statistics from TP digi occupancy
151  float meanFEDEB(0.), meanFEDEE(0.), rmsFEDEB(0.), rmsFEDEE(0.);
152  unsigned int nFEDEB(0), nFEDEE(0);
153  for ( unsigned iDCC(0); iDCC < nDCC; iDCC++ ) {
154  if ( iDCC >=kEBmLow && iDCC <= kEBpHigh) {
155  meanFEDEB += Nentries[iDCC];
156  rmsFEDEB += Nentries[iDCC]*Nentries[iDCC];
157  nFEDEB++;
158  }
159  else {
160  meanFEDEE += Nentries[iDCC];
161  rmsFEDEE += Nentries[iDCC]*Nentries[iDCC];
162  nFEDEE++;
163  }
164  }
165  meanFEDEB /= float( nFEDEB ); rmsFEDEB /= float( nFEDEB );
166  meanFEDEE /= float( nFEDEE ); rmsFEDEE /= float( nFEDEE );
167  rmsFEDEB = sqrt( std::abs(rmsFEDEB - meanFEDEB*meanFEDEB) );
168  rmsFEDEE = sqrt( std::abs(rmsFEDEE - meanFEDEE*meanFEDEE) );
169  // Analyze FED statistics
170  float meanFED(0.), rmsFED(0.), nRMS(5.);
171  for(unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++){
173  unsigned iDCC( dccId(ttid)-1 );
174  if ( iDCC >= kEBmLow && iDCC <= kEBpHigh ) {
175  meanFED = meanFEDEB;
176  rmsFED = rmsFEDEB;
177  }
178  else {
179  meanFED = meanFEDEE;
180  rmsFED = rmsFEDEE;
181  }
182  float threshold( meanFED < nRMS*rmsFED ? minEntries_ : meanFED - nRMS*rmsFED );
183  if ( (meanFED > 100. && Nentries[iDCC] < threshold) && statsCheckEnabled )
184  meEmulQualitySummary.setBinContent( ttid, meEmulQualitySummary.maskMatches(ttid, mask, statusManager_) ? kMBad : kBad );
185  }
186 
187  } // producePlots()
188 
190 }
T getUntrackedParameter(std::string const &, T const &) const
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:108
edm::LuminosityBlockNumber_t iLumi
Definition: DQWorker.h:35
static const int PHYSICS_BAD_CHANNEL_WARNING
void producePlots(ProcessType) override
void setParams(edm::ParameterSet const &) override
std::set< std::string > qualitySummaries_
T sqrt(T t)
Definition: SSEVec.h:18
StatusManager const * statusManager_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MESetCollection sources_
Timestamp timestamp_
Definition: DQWorker.h:78
MESetCollection MEs_
Definition: DQWorker.h:75
EcalSubdetector subDet() const
get the subDetector associated to the Trigger Tower
unsigned dccId(DetId const &)