CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrigPrimClient.cc
Go to the documentation of this file.
1 #include "../interface/TrigPrimClient.h"
2 
4 
6 
8 
9 #include <cmath>
10 
11 namespace ecaldqm
12 {
15  minEntries_(0),
16  errorFractionThreshold_(0.)
17  {
18  qualitySummaries_.insert("EmulQualitySummary");
19  }
20 
21  void
23  {
24  minEntries_ = _params.getUntrackedParameter<int>("minEntries");
25  errorFractionThreshold_ = _params.getUntrackedParameter<double>("errorFractionThreshold");
26  }
27 
28  void
30  {
31  MESet& meTimingSummary(MEs_.at("TimingSummary"));
32  MESet& meNonSingleSummary(MEs_.at("NonSingleSummary"));
33  MESet& meEmulQualitySummary(MEs_.at("EmulQualitySummary"));
34 
35  MESet const& sEtEmulError(sources_.at("EtEmulError"));
36  MESet const& sMatchedIndex(sources_.at("MatchedIndex"));
37  MESet const& sTPDigiThrAll(sources_.at("TPDigiThrAll"));
38 
40 
41  // Store # of entries for Occupancy analysis
42  std::vector<float> Nentries(nDCC,0.);
43 
44  for(unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++){
46 
47  bool doMask(meEmulQualitySummary.maskMatches(ttid, mask, statusManager_));
48 
49  float towerEntries(0.);
50  float tMax(0.5);
51  float nMax(0.);
52  for(int iBin(0); iBin < 6; iBin++){
53  float entries(sMatchedIndex.getBinContent(ttid, iBin + 1));
54  towerEntries += entries;
55 
56  if(entries > nMax){
57  nMax = entries;
58  tMax = iBin == 0 ? -0.5 : iBin + 0.5; // historical reasons.. much clearer to say "no entry = -0.5"
59  }
60  }
61 
62  meTimingSummary.setBinContent(ttid, tMax);
63 
64  if(towerEntries < minEntries_){
65  meEmulQualitySummary.setBinContent(ttid, doMask ? kMUnknown : kUnknown);
66  continue;
67  }
68 
69  float nonsingleFraction(1. - nMax / towerEntries);
70 
71  if(nonsingleFraction > 0.)
72  meNonSingleSummary.setBinContent(ttid, nonsingleFraction);
73 
74  if(sEtEmulError.getBinContent(ttid) / towerEntries > errorFractionThreshold_)
75  meEmulQualitySummary.setBinContent(ttid, doMask ? kMBad : kBad);
76  else
77  meEmulQualitySummary.setBinContent(ttid, doMask ? kMGood : kGood);
78 
79  // Keep count for Occupancy analysis
80  unsigned iDCC( dccId(ttid)-1 );
81  Nentries[iDCC] += sTPDigiThrAll.getBinContent(ttid);
82  }
83 
84  // Fill TTF4 v Masking ME
85  // NOT an occupancy plot: only tells you if non-zero TTF4 occupancy was seen
86  // without giving info about how many were seen
87  MESet& meTTF4vMask(MEs_.at("TTF4vMask"));
88  MESet const& sTTFlags4(sources_.at("TTFlags4"));
89  MESet const& sTTMaskMapAll(sources_.at("TTMaskMapAll"));
90 
91  // Loop over all TTs
92  for(unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++) {
94  bool isMasked( sTTMaskMapAll.getBinContent(ttid) > 0. );
95  bool hasTTF4( sTTFlags4.getBinContent(ttid) > 0. );
96  if ( isMasked ) {
97  if ( hasTTF4 )
98  meTTF4vMask.setBinContent( ttid,12 ); // Masked, has TTF4
99  else
100  meTTF4vMask.setBinContent( ttid,11 ); // Masked, no TTF4
101  } else {
102  if ( hasTTF4 )
103  meTTF4vMask.setBinContent( ttid,13 ); // not Masked, has TTF4
104  }
105  } // TT loop
106 
107  // Quality check: set an entire FED to BAD if an "entire" FED shows any DCC-SRP flag mismatch errors
108  // Fill flag mismatch statistics
109  std::vector<float> nTTs(nDCC,0.);
110  std::vector<float> nTTFMismath(nDCC,0.);
111  MESet const& sTTFMismatch(sources_.at("TTFMismatch"));
112  for ( unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++ ) {
114  unsigned iDCC( dccId(ttid)-1 );
115  if ( sTTFMismatch.getBinContent(ttid) > 0. )
116  nTTFMismath[iDCC]++;
117  nTTs[iDCC]++;
118  }
119  // Analyze flag mismatch statistics
120  for ( unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++ ) {
122  unsigned iDCC( dccId(ttid)-1 );
123  if ( nTTFMismath[iDCC] > 0.8*nTTs[iDCC] ) // "entire" => 80%
124  meEmulQualitySummary.setBinContent( ttid, meEmulQualitySummary.maskMatches(ttid, mask, statusManager_) ? kMBad : kBad );
125  }
126 
127  // Quality check: set entire FED to BAD if its occupancy begins to vanish
128  // Fill FED statistics from TP digi occupancy
129  float meanFEDEB(0.), meanFEDEE(0.), rmsFEDEB(0.), rmsFEDEE(0.);
130  unsigned int nFEDEB(0), nFEDEE(0);
131  for ( unsigned iDCC(0); iDCC < nDCC; iDCC++ ) {
132  if ( iDCC >=kEBmLow && iDCC <= kEBpHigh) {
133  meanFEDEB += Nentries[iDCC];
134  rmsFEDEB += Nentries[iDCC]*Nentries[iDCC];
135  nFEDEB++;
136  }
137  else {
138  meanFEDEE += Nentries[iDCC];
139  rmsFEDEE += Nentries[iDCC]*Nentries[iDCC];
140  nFEDEE++;
141  }
142  }
143  meanFEDEB /= float( nFEDEB ); rmsFEDEB /= float( nFEDEB );
144  meanFEDEE /= float( nFEDEE ); rmsFEDEE /= float( nFEDEE );
145  rmsFEDEB = sqrt( abs(rmsFEDEB - meanFEDEB*meanFEDEB) );
146  rmsFEDEE = sqrt( abs(rmsFEDEE - meanFEDEE*meanFEDEE) );
147  // Analyze FED statistics
148  float meanFED(0.), rmsFED(0.), nRMS(5.);
149  for(unsigned iTT(0); iTT < EcalTrigTowerDetId::kSizeForDenseIndexing; iTT++){
151  unsigned iDCC( dccId(ttid)-1 );
152  if ( iDCC >= kEBmLow && iDCC <= kEBpHigh ) {
153  meanFED = meanFEDEB;
154  rmsFED = rmsFEDEB;
155  }
156  else {
157  meanFED = meanFEDEE;
158  rmsFED = rmsFEDEE;
159  }
160  float threshold( meanFED < nRMS*rmsFED ? minEntries_ : meanFED - nRMS*rmsFED );
161  if ( meanFED > 100. && Nentries[iDCC] < threshold )
162  meEmulQualitySummary.setBinContent( ttid, meEmulQualitySummary.maskMatches(ttid, mask, statusManager_) ? kMBad : kBad );
163  }
164 
165  } // producePlots()
166 
168 }
T getUntrackedParameter(std::string const &, T const &) const
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:108
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_
MESetCollection MEs_
Definition: DQWorker.h:75
unsigned dccId(DetId const &)