CMS 3D CMS Logo

TrigPrimClient.cc
Go to the documentation of this file.
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& meTTF4vMaskByLumi(MEs_.at("TTF4vMaskByLumi"));
97  MESet const& sTTFlags4(sources_.at("TTFlags4"));
98  MESet const& sTTFlags4ByLumi(sources_.at("TTFlags4ByLumi"));
99  MESet const& sTTMaskMapAll(sources_.at("TTMaskMapAll"));
100 
101  std::vector<float> nWithTTF4(nDCC, 0.); // counters to keep track of number of towers in a DCC that have TTF4 flag set
102  int nWithTTF4_EE = 0; // total number of towers in EE with TTF4
103  int nWithTTF4_EB = 0; // total number of towers in EB with TTF4
104  // Loop over all TTs
105  for(unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++) {
107  unsigned iDCC( dccId(ttid)-1 );
108  bool isMasked( sTTMaskMapAll.getBinContent(ttid) > 0. );
109  bool hasTTF4( sTTFlags4.getBinContent(ttid) > 0. );
110  bool hasTTF4InThisLumiSection( sTTFlags4ByLumi.getBinContent(ttid) > 0. );
111  if (hasTTF4InThisLumiSection) {
112  nWithTTF4[iDCC]++;
113  if (ttid.subDet() == EcalBarrel) nWithTTF4_EB++;
114  else if (ttid.subDet() == EcalEndcap) nWithTTF4_EE++;
115  }
116  if ( isMasked ) {
117  if ( hasTTF4 ) {
118  meTTF4vMask.setBinContent( ttid,12 ); // Masked, has TTF4
119  }
120  else {
121  meTTF4vMask.setBinContent( ttid,11 ); // Masked, no TTF4
122  }
123  if ( hasTTF4InThisLumiSection ) {
124  meTTF4vMaskByLumi.setBinContent( ttid,12 ); // Masked, has TTF4
125  }
126  else {
127  meTTF4vMaskByLumi.setBinContent( ttid,11 ); // Masked, no TTF4
128  }
129  } else {
130  if ( hasTTF4 ) meTTF4vMask.setBinContent( ttid,13 ); // not Masked, has TTF4
131  if ( hasTTF4InThisLumiSection ) meTTF4vMaskByLumi.setBinContent( ttid,13 ); // not Masked, has TTF4
132  }
133  } // TT loop
134 
135  // Fill trend plots for number of TTs with TTF4 flag set
136  meTrendTTF4Flags.fill(EcalBarrel, double(timestamp_.iLumi), nWithTTF4_EB);
137  meTrendTTF4Flags.fill(EcalEndcap, double(timestamp_.iLumi), nWithTTF4_EE);
138 
139  // 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
140  // Fill flag mismatch statistics
141  std::vector<float> nTTs(nDCC,0.);
142  std::vector<float> nTTFMismath(nDCC,0.);
143  MESet const& sTTFMismatch(sources_.at("TTFMismatch"));
144  for ( unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++ ) {
146  unsigned iDCC( dccId(ttid)-1 );
147  if ( sTTFMismatch.getBinContent(ttid) > 0. )
148  nTTFMismath[iDCC]++;
149  nTTs[iDCC]++;
150  }
151  // Analyze flag mismatch statistics and TTF4 fraction statistics
152  for ( unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++ ) {
154  unsigned iDCC( dccId(ttid)-1 );
155  if ( nTTFMismath[iDCC] > 0.8*nTTs[iDCC] || nWithTTF4[iDCC] > TTF4MaskingAlarmThreshold_*nTTs[iDCC]) {
156  meEmulQualitySummary.setBinContent( ttid, meEmulQualitySummary.maskMatches(ttid, mask, statusManager_) ? kMBad : kBad );
157  }
158  }
159 
160  // Quality check: set entire FED to BAD if its occupancy begins to vanish
161  // Fill FED statistics from TP digi occupancy
162  float meanFEDEB(0.), meanFEDEE(0.), rmsFEDEB(0.), rmsFEDEE(0.);
163  unsigned int nFEDEB(0), nFEDEE(0);
164  for ( unsigned iDCC(0); iDCC < nDCC; iDCC++ ) {
165  if ( iDCC >=kEBmLow && iDCC <= kEBpHigh) {
166  meanFEDEB += Nentries[iDCC];
167  rmsFEDEB += Nentries[iDCC]*Nentries[iDCC];
168  nFEDEB++;
169  }
170  else {
171  meanFEDEE += Nentries[iDCC];
172  rmsFEDEE += Nentries[iDCC]*Nentries[iDCC];
173  nFEDEE++;
174  }
175  }
176  meanFEDEB /= float( nFEDEB ); rmsFEDEB /= float( nFEDEB );
177  meanFEDEE /= float( nFEDEE ); rmsFEDEE /= float( nFEDEE );
178  rmsFEDEB = sqrt( std::abs(rmsFEDEB - meanFEDEB*meanFEDEB) );
179  rmsFEDEE = sqrt( std::abs(rmsFEDEE - meanFEDEE*meanFEDEE) );
180  // Analyze FED statistics
181  float meanFED(0.), rmsFED(0.), nRMS(5.);
182  for(unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++){
184  unsigned iDCC( dccId(ttid)-1 );
185  if ( iDCC >= kEBmLow && iDCC <= kEBpHigh ) {
186  meanFED = meanFEDEB;
187  rmsFED = rmsFEDEB;
188  }
189  else {
190  meanFED = meanFEDEE;
191  rmsFED = rmsFEDEE;
192  }
193  float threshold( meanFED < nRMS*rmsFED ? minEntries_ : meanFED - nRMS*rmsFED );
194  if ( (meanFED > 100. && Nentries[iDCC] < threshold) && statsCheckEnabled )
195  meEmulQualitySummary.setBinContent( ttid, meEmulQualitySummary.maskMatches(ttid, mask, statusManager_) ? kMBad : kBad );
196  }
197 
198  } // producePlots()
199 
201 }
T getUntrackedParameter(std::string const &, T const &) const
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:109
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 &)