test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTLocalTriggerTest.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author C. Battilana S. Marcellini - INFN Bologna
5  */
6 
7 
8 // This class header
10 
11 // Framework headers
16 
17 // Geometry
20 
21 // Root
22 #include "TF1.h"
23 #include "TProfile.h"
24 
25 
26 //C++ headers
27 #include <iostream>
28 #include <sstream>
29 
30 using namespace edm;
31 using namespace std;
32 
33 
35 
36  setConfig(ps,"DTLocalTrigger");
37  baseFolderDCC = "DT/03-LocalTrigger-DCC/";
38  baseFolderDDU = "DT/04-LocalTrigger-DDU/";
39  nMinEvts = ps.getUntrackedParameter<int>("nEventsCert", 5000);
40 
41 }
42 
43 
45 
46 }
47 
49 
51 
52 
53  vector<string>::const_iterator iTr = trigSources.begin();
54  vector<string>::const_iterator trEnd = trigSources.end();
55  vector<string>::const_iterator iHw = hwSources.begin();
56  vector<string>::const_iterator hwEnd = hwSources.end();
57 
58 
59  //Booking
60  if(parameters.getUntrackedParameter<bool>("staticBooking", true)){
61  for (; iTr != trEnd; ++iTr){
62  trigSource = (*iTr);
63  for (; iHw != hwEnd; ++iHw){
64  hwSource = (*iHw);
65  // Loop over the TriggerUnits
66  for (int wh=-2; wh<=2; ++wh){
67  if (hwSource=="COM") {
68  bookWheelHistos(wh,"MatchingPhi");
69  }
70  else {
71  for (int sect=1; sect<=12; ++sect){
72  bookSectorHistos(wh,sect,"BXDistribPhi");
73  bookSectorHistos(wh,sect,"QualDistribPhi");
74  }
75  bookWheelHistos(wh,"CorrectBXPhi");
76  bookWheelHistos(wh,"ResidualBXPhi");
77  bookWheelHistos(wh,"CorrFractionPhi");
78  bookWheelHistos(wh,"2ndFractionPhi");
79  bookWheelHistos(wh,"TriggerInclusivePhi");
80  bookWheelHistos(wh,"CorrectBXTheta");
81  if (hwSource=="DDU") {
82  bookWheelHistos(wh,"HFractionTheta");
83  }
84  }
85  }
86  }
87  }
88  }
89  // Summary test histo booking (only static)
90  for (iTr = trigSources.begin(); iTr != trEnd; ++iTr){
91  trigSource = (*iTr);
92  for (iHw = hwSources.begin(); iHw != hwSources.end(); ++iHw){
93  hwSource = (*iHw);
94  // Loop over the TriggerUnits
95  for (int wh=-2; wh<=2; ++wh){
96  if (hwSource=="COM") {
97  bookWheelHistos(wh,"MatchingSummary","Summaries");
98  }
99  else {
100  bookWheelHistos(wh,"CorrFractionSummary","Summaries");
101  bookWheelHistos(wh,"2ndFractionSummary","Summaries");
102  }
103  }
104  if (hwSource=="COM") {
105  bookCmsHistos("MatchingSummary","Summaries");
106  }
107  else {
108  bookCmsHistos("CorrFractionSummary");
109  bookCmsHistos("2ndFractionSummary");
110  }
111  if (hwSource=="DCC") {
112  bookCmsHistos("TrigGlbSummary","",true);
113  }
114 
115  }
116  }
117 
118 }
119 
120 
122 
124 
125 }
126 
127 
129 
130  // Loop over Trig & Hw sources
131  for (vector<string>::const_iterator iTr = trigSources.begin(); iTr != trigSources.end(); ++iTr){
132  trigSource = (*iTr);
133  for (vector<string>::const_iterator iHw = hwSources.begin(); iHw != hwSources.end(); ++iHw){
134  hwSource = (*iHw);
135  // Loop over the TriggerUnits
136  for (int stat=1; stat<=4; ++stat){
137  for (int wh=-2; wh<=2; ++wh){
138  for (int sect=1; sect<=12; ++sect){
139  DTChamberId chId(wh,stat,sect);
140  int sector_id = (wh+3)+(sect-1)*5;
141  // uint32_t indexCh = chId.rawId();
142 
143  if (hwSource=="COM") {
144  // Perform DCC-DDU matching test and generates summaries (Phi view)
145  TH2F * DDUvsDCC = getHisto<TH2F>(dbe->get(getMEName("QualDDUvsQualDCC","LocalTriggerPhi", chId)));
146  if (DDUvsDCC) {
147 
148  int matchSummary = 1;
149 
150  if (DDUvsDCC->GetEntries()>1) {
151 
152  double entries = DDUvsDCC->GetEntries();
153  double corrEntries = 0;
154  for (int ibin=2; ibin<=8; ++ibin) {
155  corrEntries += DDUvsDCC->GetBinContent(ibin,ibin);
156  }
157  double corrRatio = corrEntries/entries;
158 
159  if (corrRatio < parameters.getUntrackedParameter<double>("matchingFracError",.65)){
160  matchSummary = 2;
161  }
162  else if (corrRatio < parameters.getUntrackedParameter<double>("matchingFracWarning",.85)){
163  matchSummary = 3;
164  }
165  else {
166  matchSummary = 0;
167  }
168 
169  if( whME[wh].find(fullName("MatchingPhi")) == whME[wh].end() ){
170  bookWheelHistos(wh,"MatchingPhi");
171  }
172 
173  whME[wh].find(fullName("MatchingPhi"))->second->setBinContent(sect,stat,corrRatio);
174 
175  }
176 
177  whME[wh].find(fullName("MatchingSummary"))->second->setBinContent(sect,stat,matchSummary);
178 
179  }
180  }
181  else {
182  // Perform DCC/DDU common plot analysis (Phi ones)
183  TH2F * BXvsQual = getHisto<TH2F>(dbe->get(getMEName("BXvsQual","LocalTriggerPhi", chId)));
184  TH1F * BestQual = getHisto<TH1F>(dbe->get(getMEName("BestQual","LocalTriggerPhi", chId)));
185  TH2F * Flag1stvsQual = getHisto<TH2F>(dbe->get(getMEName("Flag1stvsQual","LocalTriggerPhi", chId)));
186  if (BXvsQual && Flag1stvsQual && BestQual) {
187 
188  int corrSummary = 1;
189  int secondSummary = 1;
190 
191  if (BestQual->GetEntries()>1) {
192 
193  TH1D* BXHH = BXvsQual->ProjectionY("",6,7,"");
194  TH1D* Flag1st = Flag1stvsQual->ProjectionY();
195  int BXOK_bin = BXHH->GetEntries()>=1 ? BXHH->GetMaximumBin() : 51;
196  double BXMean = BXHH->GetEntries()>=1 ? BXHH->GetMean() : 51;
197  double BX_OK = BXvsQual->GetYaxis()->GetBinCenter(BXOK_bin);
198  double trigsFlag2nd = Flag1st->GetBinContent(2);
199  double trigs = Flag1st->GetEntries();
200  double besttrigs = BestQual->GetEntries();
201  double besttrigsCorr = BestQual->Integral(5,7,"");
202  delete BXHH;
203  delete Flag1st;
204 
205  double corrFrac = besttrigsCorr/besttrigs;
206  double secondFrac = trigsFlag2nd/trigs;
207  if (corrFrac < parameters.getUntrackedParameter<double>("corrFracError",.5)){
208  corrSummary = 2;
209  }
210  else if (corrFrac < parameters.getUntrackedParameter<double>("corrFracWarning",.6)){
211  corrSummary = 3;
212  }
213  else {
214  corrSummary = 0;
215  }
216  if (secondFrac > parameters.getUntrackedParameter<double>("secondFracError",.2)){
217  secondSummary = 2;
218  }
219  else if (secondFrac > parameters.getUntrackedParameter<double>("secondFracWarning",.1)){
220  secondSummary = 3;
221  }
222  else {
223  secondSummary = 0;
224  }
225 
226  if( secME[sector_id].find(fullName("BXDistribPhi")) == secME[sector_id].end() ){
227  bookSectorHistos(wh,sect,"QualDistribPhi");
228  bookSectorHistos(wh,sect,"BXDistribPhi");
229  }
230 
231  TH1D* BXDistr = BXvsQual->ProjectionY();
232  TH1D* QualDistr = BXvsQual->ProjectionX();
233  std::map<std::string,MonitorElement*> *innerME = &(secME[sector_id]);
234 
235  int nbinsBX = BXDistr->GetNbinsX();
236  int firstBinCenter = static_cast<int>(BXDistr->GetBinCenter(1));
237  int lastBinCenter = static_cast<int>(BXDistr->GetBinCenter(nbinsBX));
238  int iMin = firstBinCenter>-4 ? firstBinCenter : -4;
239  int iMax = lastBinCenter<20 ? lastBinCenter : 20;
240  for (int ibin=iMin+5;ibin<=iMax+5; ++ibin) {
241  innerME->find(fullName("BXDistribPhi"))->second->setBinContent(ibin,stat,BXDistr->GetBinContent(ibin-5-firstBinCenter+1));
242  }
243  for (int ibin=1;ibin<=7;++ibin) {
244  innerME->find(fullName("QualDistribPhi"))->second->setBinContent(ibin,stat,QualDistr->GetBinContent(ibin));
245  }
246 
247  delete BXDistr;
248  delete QualDistr;
249 
250  if( whME[wh].find(fullName("CorrectBXPhi")) == whME[wh].end() ){
251  bookWheelHistos(wh,"ResidualBXPhi");
252  bookWheelHistos(wh,"CorrectBXPhi");
253  bookWheelHistos(wh,"CorrFractionPhi");
254  bookWheelHistos(wh,"2ndFractionPhi");
255  bookWheelHistos(wh,"TriggerInclusivePhi");
256  }
257 
258  innerME = &(whME[wh]);
259  innerME->find(fullName("CorrectBXPhi"))->second->setBinContent(sect,stat,BX_OK+0.00001);
260  innerME->find(fullName("ResidualBXPhi"))->second->setBinContent(sect,stat,round(25.*(BXMean-BX_OK))+0.00001);
261  innerME->find(fullName("CorrFractionPhi"))->second->setBinContent(sect,stat,corrFrac);
262  innerME->find(fullName("TriggerInclusivePhi"))->second->setBinContent(sect,stat,besttrigs);
263  innerME->find(fullName("2ndFractionPhi"))->second->setBinContent(sect,stat,secondFrac);
264 
265  }
266 
267  whME[wh].find(fullName("CorrFractionSummary"))->second->setBinContent(sect,stat,corrSummary);
268  whME[wh].find(fullName("2ndFractionSummary"))->second->setBinContent(sect,stat,secondSummary);
269 
270  }
271 
272  if (hwSource=="DDU") {
273  // Perform DDU plot analysis (Theta ones)
274  TH2F * ThetaBXvsQual = getHisto<TH2F>(dbe->get(getMEName("ThetaBXvsQual","LocalTriggerTheta", chId)));
275  TH1F * ThetaBestQual = getHisto<TH1F>(dbe->get(getMEName("ThetaBestQual","LocalTriggerTheta", chId)));
276 
277  // no theta triggers in stat 4!
278  if (ThetaBXvsQual && ThetaBestQual && stat<4 && ThetaBestQual->GetEntries()>1) {
279  TH1D* BXH = ThetaBXvsQual->ProjectionY("",4,4,"");
280  int BXOK_bin = BXH->GetEffectiveEntries()>=1 ? BXH->GetMaximumBin(): 10;
281  double BX_OK = ThetaBXvsQual->GetYaxis()->GetBinCenter(BXOK_bin);
282  double trigs = ThetaBestQual->GetEntries();
283  double trigsH = ThetaBestQual->GetBinContent(4);
284  delete BXH;
285 
286  // if( secME[sector_id].find(fullName("HFractionTheta")) == secME[sector_id].end() ){
287  // // bookSectorHistos(wh,sect,"CorrectBXTheta");
288  // bookSectorHistos(wh,sect,"HFractionTheta");
289  // }
290  //std::map<std::string,MonitorElement*> *innerME = &(secME.find(sector_id)->second);
291  // innerME->find(fullName("CorrectBXTheta"))->second->setBinContent(stat,BX_OK);
292  //innerME->find(fullName("HFractionTheta"))->second->setBinContent(stat,trigsH/trigs);
293 
294  if( whME[wh].find(fullName("HFractionTheta")) == whME[wh].end() ){
295  bookWheelHistos(wh,"CorrectBXTheta");
296  bookWheelHistos(wh,"HFractionTheta");
297  }
298  std::map<std::string,MonitorElement*> *innerME = &(whME.find(wh)->second);
299  innerME->find(fullName("CorrectBXTheta"))->second->setBinContent(sect,stat,BX_OK+0.00001);
300  innerME->find(fullName("HFractionTheta"))->second->setBinContent(sect,stat,trigsH/trigs);
301 
302  }
303  }
304  else if (hwSource=="DCC") {
305  // Perform DCC plot analysis (Theta ones)
306  TH2F * ThetaPosvsBX = getHisto<TH2F>(dbe->get(getMEName("PositionvsBX","LocalTriggerTheta", chId)));
307 
308  // no theta triggers in stat 4!
309  if (ThetaPosvsBX && stat<4 && ThetaPosvsBX->GetEntries()>1) {
310  TH1D* BX = ThetaPosvsBX->ProjectionX();
311  int BXOK_bin = BX->GetEffectiveEntries()>=1 ? BX->GetMaximumBin(): 10;
312  double BX_OK = ThetaPosvsBX->GetXaxis()->GetBinCenter(BXOK_bin);
313  delete BX;
314 
315  if( whME[wh].find(fullName("CorrectBXTheta")) == whME[wh].end() ){
316  bookWheelHistos(wh,"CorrectBXTheta");
317  }
318  std::map<std::string,MonitorElement*> *innerME = &(whME.find(wh)->second);
319  innerME->find(fullName("CorrectBXTheta"))->second->setBinContent(sect,stat,BX_OK+0.00001);
320 
321  }
322  }
323  }
324 
325  }
326  }
327  }
328  }
329  }
330 
331  for (vector<string>::const_iterator iTr = trigSources.begin(); iTr != trigSources.end(); ++iTr){
332  trigSource = (*iTr);
333  for (vector<string>::const_iterator iHw = hwSources.begin(); iHw != hwSources.end(); ++iHw){
334  hwSource = (*iHw);
335  for (int wh=-2; wh<=2; ++wh){
336  std::map<std::string,MonitorElement*> *innerME = &(whME[wh]);
337  if(hwSource=="COM") {
338  TH2F* matchWhSummary = getHisto<TH2F>(innerME->find(fullName("MatchingSummary"))->second);
339  for (int sect=1; sect<=12; ++sect){
340  int matchErr = 0;
341  int matchNoData = 0;
342  for (int stat=1; stat<=4; ++stat){
343  switch (static_cast<int>(matchWhSummary->GetBinContent(sect,stat))) {
344  case 1:
345  matchNoData++;
346  case 2:
347  matchErr++;
348  }
349  }
350  if (matchNoData == 4) matchErr = 5;
351  cmsME.find(fullName("MatchingSummary"))->second->setBinContent(sect,wh+3,matchErr);
352  }
353  }
354  else {
355  TH2F* corrWhSummary = getHisto<TH2F>(innerME->find(fullName("CorrFractionSummary"))->second);
356  TH2F* secondWhSummary = getHisto<TH2F>(innerME->find(fullName("2ndFractionSummary"))->second);
357  for (int sect=1; sect<=12; ++sect){
358  int corrErr = 0;
359  int secondErr = 0;
360  int corrNoData = 0;
361  int secondNoData = 0;
362  for (int stat=1; stat<=4; ++stat){
363  switch (static_cast<int>(corrWhSummary->GetBinContent(sect,stat))) {
364  case 1:
365  corrNoData++;
366  case 2:
367  corrErr++;
368  }
369  switch (static_cast<int>(secondWhSummary->GetBinContent(sect,stat))) {
370  case 1:
371  secondNoData++;
372  case 2:
373  secondErr++;
374  }
375  }
376  if (corrNoData == 4) corrErr = 5;
377  if (secondNoData == 4) secondErr = 5;
378  cmsME.find(fullName("CorrFractionSummary"))->second->setBinContent(sect,wh+3,corrErr);
379  cmsME.find(fullName("2ndFractionSummary"))->second->setBinContent(sect,wh+3,secondErr);
380  }
381  }
382  }
383  }
384  }
385 
386  fillGlobalSummary();
387 
388 }
389 
391 
392  float glbPerc[5] = { 1., 0.9, 0.6, 0.3, 0.01 };
393  trigSource = "";
394  hwSource = "DCC";
395 
396  int nSecReadout = 0;
397 
398  for (int wh=-2; wh<=2; ++wh) {
399  for (int sect=1; sect<=12; ++sect) {
400 
401  float maxErr = 8.;
402  int corr = cmsME.find(fullName("CorrFractionSummary"))->second->getBinContent(sect,wh+3);
403  int second = cmsME.find(fullName("2ndFractionSummary"))->second->getBinContent(sect,wh+3);
404  int lut=0;
405  MonitorElement * lutsME = dbe->get(topFolder(hwSource=="DCC") + "Summaries/TrigLutSummary");
406  if (lutsME) {
407  lut = lutsME->getBinContent(sect,wh+3);
408  maxErr+=4;
409  } else {
410  LogTrace(category()) << "[" << testName
411  << "Test]: DCC Lut test Summary histo not found." << endl;
412  }
413  (corr <5 || second<5) && nSecReadout++;
414  int errcode = ((corr<5 ? corr : 4) + (second<5 ? second : 4) + (lut<5 ? lut : 4) );
415  errcode = min(int((errcode/maxErr + 0.01)*5),5);
416  cmsME.find("TrigGlbSummary")->second->setBinContent(sect,wh+3,glbPerc[errcode]);
417 
418  }
419  }
420 
421  if (!nSecReadout)
422  cmsME.find("TrigGlbSummary")->second->Reset(); // white histo id DCC is not RO
423 
424  string nEvtsName = "DT/EventInfo/Counters/nProcessedEventsTrigger";
425  MonitorElement * meProcEvts = dbe->get(nEvtsName);
426 
427  if (meProcEvts) {
428  int nProcEvts = meProcEvts->getFloatValue();
429  cmsME.find("TrigGlbSummary")->second->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
430  } else {
431  cmsME.find("TrigGlbSummary")->second->setEntries(nMinEvts + 1);
432  LogVerbatim (category()) << "[" << testName
433  << "Test]: ME: " << nEvtsName << " not found!" << endl;
434  }
435 
436 }
T getUntrackedParameter(std::string const &, T const &) const
dictionary parameters
Definition: Parameters.py:2
void beginJob()
BeginJob.
void beginRun(edm::Run const &run, edm::EventSetup const &context)
BeginRun.
virtual ~DTLocalTriggerTest()
Destructor.
void runClientDiagnostic()
Run client analysis.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
U second(std::pair< T, U > const &p)
double getFloatValue(void) const
EventID const & min(EventID const &lh, EventID const &rh)
Definition: EventID.h:132
tuple lut
Definition: lumiPlot.py:244
#define end
Definition: vmac.h:37
#define LogTrace(id)
JetCorrectorParameters corr
Definition: classes.h:5
string fullName
DTLocalTriggerTest(const edm::ParameterSet &ps)
Constructor.
double getBinContent(int binx) const
get content of bin (1-D)
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
Definition: Run.h:41