CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTDCSByLumiSummary.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author C. Battilana - CIEMAT
5  * \author P. Bellan - INFN PD
6  * \author A. Branca = INFN PD
7  */
8 
9 
12 
17 
20 
21 #include<string>
22 
23 
24 using namespace std;
25 using namespace edm;
26 
27 
29 
30  bookingdone = 0;
31 
32 }
33 
34 
36 
37 
39 
40 }
41 
43  edm::EventSetup const & setup) {
44 
45  if (!bookingdone) {
46 
47 
48  ibooker.setCurrentFolder("DT/EventInfo/DCSContents");
49 
50  totalDCSFraction = ibooker.bookFloat("DTDCSSummary");
51  totalDCSFraction->setLumiFlag(); // set LumiFlag to DCS content value (save it by lumi)
52 
53  globalHVSummary = ibooker.book2D("HVGlbSummary","HV Status Summary",1,1,13,5,-2,3);
54  globalHVSummary->setAxisTitle("Sectors",1);
55  globalHVSummary->setAxisTitle("Wheel",2);
56 
57  for(int wh=-2;wh<=2;wh++){
58 
59  stringstream wheel_str; wheel_str << wh;
60 
61  MonitorElement* FractionWh = ibooker.bookFloat("DT_Wheel"+wheel_str.str());
62  FractionWh->setLumiFlag(); // set LumiFlag to DCS content value (save it by lumi)
63 
64  totalDCSFractionWh.push_back(FractionWh);
65  }
66 
67  globalHVSummary->Reset();
68 
69  // CB LumiFlag marked products are reset on LS boundaries
70  totalDCSFraction->Reset();
71 
72  for(int wh=-2;wh<=2;wh++){
73  totalDCSFractionWh[wh+2]->Reset();
74  }
75 
76  }
77  bookingdone = 1;
78 
79  // Get the by lumi product plot from the task
80  int lumiNumber = lumi.id().luminosityBlock();
81 
82  bool null_pointer_histo(0);
83 
84  std::vector<float> wh_activeFrac;
85 
86  for(int wh=-2;wh<=2;wh++){
87 
88  stringstream wheel_str; wheel_str << wh;
89 
90  string hActiveUnitsPath = "DT/EventInfo/DCSContents/hActiveUnits"+wheel_str.str();
91 
92  MonitorElement *hActiveUnits = igetter.get(hActiveUnitsPath);
93 
94  if (hActiveUnits) {
95  float activeFrac = static_cast<float>(hActiveUnits->getBinContent(2)) / // CB 2nd bin is # of active channels
96  hActiveUnits->getBinContent(1); // first bin is overall number of channels
97 
98  if(activeFrac < 0.) activeFrac=-1;
99 
100  wh_activeFrac.push_back(activeFrac);
101 
102  // Fill by lumi Certification ME
103  totalDCSFraction->Fill(activeFrac);
104  totalDCSFractionWh[wh+2]->Fill(activeFrac);
105 
106  } else {
107  LogTrace("DTDQM|DTMonitorClient|DTDCSByLumiSummary")
108  << "[DTDCSByLumiSummary]: got null pointer retrieving histo at :"
109  << hActiveUnitsPath << " for lumi # " << lumiNumber
110  << "client operation not performed." << endl;
111 
112  null_pointer_histo=true;
113  }
114 
115  } // end loop on wheels
116 
117  if(!null_pointer_histo) dcsFracPerLumi[lumiNumber] = wh_activeFrac; // Fill map to be used to compute trend plots
118 
119 
120  // CB LumiFlag marked products are reset on LS boundaries
121  totalDCSFraction->Reset();
122 
123  for(int wh=-2;wh<=2;wh++){
124  totalDCSFractionWh[wh+2]->Reset();
125  }
126 
127 }
128 
130 
131  // Book trend plots ME & loop on map to fill it with by lumi info
132  map<int,std::vector<float> >::const_iterator fracPerLumiIt = dcsFracPerLumi.begin();
133  map<int,std::vector<float> >::const_iterator fracPerLumiEnd = dcsFracPerLumi.end();
134 
135  if (fracPerLumiIt != fracPerLumiEnd ) {
136  int fLumi = dcsFracPerLumi.begin()->first;
137  int lLumi = dcsFracPerLumi.rbegin()->first;
138 
139  ibooker.setCurrentFolder("DT/EventInfo/DCSContents");
140 
141  int nLumis = lLumi-fLumi + 1.;
142 
143  // trend plots
144  for(int wh=-2; wh<=2; wh++) {
145 
146  stringstream wheel_str; wheel_str << wh;
147 
148  DTTimeEvolutionHisto* trend;
149 
150  trend = new DTTimeEvolutionHisto(ibooker, "hDCSFracTrendWh" + wheel_str.str(), "Fraction of DT-HV ON Wh" + wheel_str.str(),
151  nLumis, fLumi, 1, false, 2);
152 
153  hDCSFracTrend.push_back(trend);
154 
155  }
156  }
157 
158  float goodLSperWh[5] = {0,0,0,0,0};
159  float badLSperWh[5] = {0,0,0,0,0};
160 
161  // fill trend plots and save infos for summaryPlot
162  for(;fracPerLumiIt!=fracPerLumiEnd;++fracPerLumiIt) {
163 
164  for(int wh=-2; wh<=2; wh++) {
165 
166  std::vector<float> activeFracPerWh;
167  activeFracPerWh = fracPerLumiIt->second;
168 
169  hDCSFracTrend[wh+2]->setTimeSlotValue(activeFracPerWh[wh+2],fracPerLumiIt->first);
170 
171  if( activeFracPerWh[wh+2] > 0 ) { // we do not count the lumi were the DTs are off (no real problem),
172  // even if this can happen in the middle of a run (real problem: to be fixed)
173  if( activeFracPerWh[wh+2] > 0.9 ) goodLSperWh[wh+2]++;
174  else {
175  badLSperWh[wh+2]++;
176  }
177  } else { // there is no HV value OR all channels OFF
178  if( activeFracPerWh[wh+2] < 0 ) badLSperWh[wh+2]=-1; // if there were no HV values, activeFrac returning -1
179  }
180 
181  }
182 
183  }
184 
185  // fill summaryPlot
186  for(int wh=-2; wh<=2; wh++) {
187 
188  if( goodLSperWh[wh+2] != 0 || badLSperWh[wh+2] == -1 ) {
189 
190  float r = badLSperWh[wh+2]/fabs(goodLSperWh[wh+2] + badLSperWh[wh+2]);
191  if( r > 0.5 ) globalHVSummary->Fill(1,wh,0);
192  else globalHVSummary->Fill(1,wh,1);
193  if( r == -1 ) globalHVSummary->Fill(1,wh,-1);
194 
195  } else {
196 
197  globalHVSummary->Fill(1,wh,0);
198 
199  }
200 
201  }
202 
203 }
204 
LuminosityBlockID id() const
void dqmEndLuminosityBlock(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, edm::LuminosityBlock const &lumi, edm::EventSetup const &setup)
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:302
tuple lumi
Definition: fjr2json.py:35
void setTimeSlotValue(float value, int timeSlot)
void dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
DTDCSByLumiSummary(const edm::ParameterSet &pset)
Constructor.
#define LogTrace(id)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
LuminosityBlockNumber_t luminosityBlock() const
virtual ~DTDCSByLumiSummary()
Destructor.
double getBinContent(int binx) const
get content of bin (1-D)
void beginRun(const edm::Run &r, const edm::EventSetup &c)
MonitorElement * bookFloat(Args &&...args)
Definition: DQMStore.h:109
void setLumiFlag(void)
this ME is meant to be stored for each luminosity section
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
Definition: Run.h:41