CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTDeadChannelTest.cc
Go to the documentation of this file.
1 
2 /*
3  * See header file for a description of this class.
4  *
5  * \author G. Mila - INFN Torino
6  */
7 
8 
10 
11 // Framework
13 
14 
15 // Geometry
20 
23 
27 
28 #include <stdio.h>
29 #include <sstream>
30 #include <math.h>
31 
32 
33 using namespace edm;
34 using namespace std;
35 
36 
38 
39  edm::LogVerbatim ("deadChannel") << "[DTDeadChannelTest]: Constructor";
40 
41  parameters = ps;
42 
43  prescaleFactor = parameters.getUntrackedParameter<int>("diagnosticPrescale", 1);
44  nevents = 0;
45 
46 }
47 
49 
50  edm::LogVerbatim ("deadChannel") << "DTDeadChannelTest: analyzed " << nevents << " events";
51 
52 }
53 
54 void DTDeadChannelTest::beginRun(Run const& run, EventSetup const& context) {
55 
56  edm::LogVerbatim ("deadChannel") << "[DTDeadChannelTest]: BeginRun";
57 
58  // Get the geometry
59  context.get<MuonGeometryRecord>().get(muonGeom);
60 
61 }
62 
63 
65 
66  edm::LogVerbatim ("deadChannel") <<"[DTDeadChannelTest]: Begin of LS transition";
67 
68  // Get the run number
69  run = lumiSeg.run();
70 
71 }
72 
73 
75 
76  nevents++;
77  edm::LogVerbatim ("deadChannel") << "[DTDeadChannelTest]: "<<nevents<<" events";
78 
79 }
80 
81 
83  LuminosityBlock const& lumiSeg, EventSetup const& context) {
84 
85  edm::LogVerbatim ("deadChannel") <<"[DTDeadChannelTest]: End of LS transition, performing the DQM client operation";
86 
87  // counts number of lumiSegs
88  nLumiSegs = lumiSeg.id().luminosityBlock();
89 
90  // prescale factor
91  if ( nLumiSegs%prescaleFactor != 0 ) return;
92 
93  edm::LogVerbatim ("deadChannel") <<"[DTDeadChannelTest]: "<<nLumiSegs<<" updates";
94 
95 
96  vector<const DTChamber*>::const_iterator ch_it = muonGeom->chambers().begin();
97  vector<const DTChamber*>::const_iterator ch_end = muonGeom->chambers().end();
98 
99  edm::LogVerbatim ("deadChannel") << "[DTDeadChannelTest]: Occupancy tests results";
100 
101  // Loop over the chambers
102  for (; ch_it != ch_end; ++ch_it) {
103  DTChamberId chID = (*ch_it)->id();
104  vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
105  vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
106 
107  stringstream wheel; wheel << chID.wheel();
108  stringstream station; station << chID.station();
109  stringstream sector; sector << chID.sector();
110 
111  context.get<DTTtrigRcd>().get(tTrigMap);
112 
113  string HistoName = "W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str();
114 
115  // Get the ME produced by DigiTask Source
116  MonitorElement * noise_histo = igetter.get(getMEName("OccupancyNoise_perCh", chID));
117  MonitorElement * hitInTime_histo = igetter.get(getMEName("OccupancyInTimeHits_perCh", chID));
118 
119  // ME -> TH2F
120  if(noise_histo && hitInTime_histo) {
121  TH2F * noise_histo_root = noise_histo->getTH2F();
122  TH2F * hitInTime_histo_root = hitInTime_histo->getTH2F();
123 
124  // Loop over the SuperLayers
125  for(; sl_it != sl_end; ++sl_it) {
126  DTSuperLayerId slID = (*sl_it)->id();
127  vector<const DTLayer*>::const_iterator l_it = (*sl_it)->layers().begin();
128  vector<const DTLayer*>::const_iterator l_end = (*sl_it)->layers().end();
129 
130  // ttrig and rms are counts
131  float tTrig, tTrigRMS, kFactor;
132  tTrigMap->get(slID, tTrig, tTrigRMS, kFactor, DTTimeUnits::counts);
133 
134  // Loop over the layers
135  for(; l_it != l_end; ++l_it) {
136  DTLayerId lID = (*l_it)->id();
137 
138  //Parameters to fill histos
139  stringstream superLayer; superLayer << slID.superlayer();
140  stringstream layer; layer << lID.layer();
141  string HistoNameTest = "W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str() + "_SL" + superLayer.str()
142  + "_L" + layer.str();
143 
144  const int firstWire = muonGeom->layer(lID)->specificTopology().firstChannel();
145  const int lastWire = muonGeom->layer(lID)->specificTopology().lastChannel();
146 
147  int entry=-1;
148  if(slID.superlayer() == 1) entry=0;
149  if(slID.superlayer() == 2) entry=4;
150  if(slID.superlayer() == 3) entry=8;
151  int YBinNumber = entry+lID.layer();
152 
153 
154  // Loop over the TH2F bin and fill the ME to be used for the Quality Test
155  for(int bin=firstWire; bin <= lastWire; bin++) {
156  if (OccupancyDiffHistos.find(HistoNameTest) == OccupancyDiffHistos.end()) bookHistos(ibooker,lID, firstWire, lastWire);
157  // tMax default value
158  float tMax = 450.0;
159 
160  float difference = (hitInTime_histo_root->GetBinContent(bin, YBinNumber) / tMax)
161  - (noise_histo_root->GetBinContent(bin, YBinNumber) / tTrig);
162  OccupancyDiffHistos.find(HistoNameTest)->second->setBinContent(bin, difference);
163  }
164  } // loop on layers
165  } // loop on superlayers
166  }
167  } // loop on chambers
168 
169  // Occupancy Difference test
170  string OccupancyDiffCriterionName = parameters.getUntrackedParameter<string>("OccupancyDiffTestName","OccupancyDiffInRange");
171  for(map<string, MonitorElement*>::const_iterator hOccDiff = OccupancyDiffHistos.begin();
172  hOccDiff != OccupancyDiffHistos.end();
173  hOccDiff++) {
174  const QReport * theOccupancyDiffQReport = (*hOccDiff).second->getQReport(OccupancyDiffCriterionName);
175  if(theOccupancyDiffQReport) {
176  vector<dqm::me_util::Channel> badChannels = theOccupancyDiffQReport->getBadChannels();
177  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin();
178  channel != badChannels.end(); channel++) {
179  edm::LogError ("deadChannel") << "Layer : "<<(*hOccDiff).first<<" Bad occupancy difference channels: "<<(*channel).getBin()<<" Contents : "<<(*channel).getContents();
180  }
181  }
182  }
183 
184 }
185 
186 string DTDeadChannelTest::getMEName(string histoTag, const DTChamberId & chId) {
187 
188  stringstream wheel; wheel << chId.wheel();
189  stringstream station; station << chId.station();
190  stringstream sector; sector << chId.sector();
191 
192  string folderRoot = parameters.getUntrackedParameter<string>("folderRoot", "Collector/FU0/");
193  string folderName =
194  folderRoot + "DT/DTDigiTask/Wheel" + wheel.str() +
195  "/Station" + station.str() +
196  "/Sector" + sector.str() +
197  "/Occupancies" + "/";
198 
199  string histoname = folderName + histoTag
200  + "_W" + wheel.str()
201  + "_St" + station.str()
202  + "_Sec" + sector.str();
203 
204  return histoname;
205 
206 }
207 
208 
209 void DTDeadChannelTest::bookHistos(DQMStore::IBooker & ibooker, const DTLayerId & lId, int firstWire, int lastWire) {
210 
211  stringstream wheel; wheel << lId.superlayerId().wheel();
212  stringstream station; station << lId.superlayerId().station();
213  stringstream sector; sector << lId.superlayerId().sector();
214  stringstream superLayer; superLayer << lId.superlayerId().superlayer();
215  stringstream layer; layer << lId.layer();
216 
217  string HistoName = "W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str() + "_SL" + superLayer.str() + "_L" + layer.str();
218  string OccupancyDiffHistoName = "OccupancyDiff_" + HistoName;
219 
220  ibooker.setCurrentFolder("DT/Tests/DTDeadChannel/Wheel" + wheel.str() +
221  "/Station" + station.str() +
222  "/Sector" + sector.str());
223 
224  OccupancyDiffHistos[HistoName] = ibooker.book1D(OccupancyDiffHistoName.c_str(),OccupancyDiffHistoName.c_str(),lastWire-firstWire+1, firstWire-0.5, lastWire+0.5);
225 
226 }
LuminosityBlockID id() const
dictionary parameters
Definition: Parameters.py:2
std::string getMEName(std::string histoTag, const DTChamberId &chId)
Get the ME name.
void bookHistos(DQMStore::IBooker &, const DTLayerId &ch, int firstWire, int lastWire)
book the new ME
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:302
int layer() const
Return the layer number.
Definition: DTLayerId.h:53
DTDeadChannelTest(const edm::ParameterSet &ps)
Constructor.
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:59
void bookHistos()
Definition: Histogram.h:33
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
RunNumber_t run() const
const std::vector< DQMChannel > & getBadChannels(void) const
Definition: QReport.h:33
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
int superlayer() const
Return the superlayer number (deprecated method name)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
const T & get() const
Definition: EventSetup.h:55
LuminosityBlockNumber_t luminosityBlock() const
std::string HistoName
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
DQM Client Diagnostic.
int sector() const
Definition: DTChamberId.h:61
int station() const
Return the station number.
Definition: DTChamberId.h:51
TH2F * getTH2F(void) const
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
virtual ~DTDeadChannelTest()
Destructor.
Definition: Run.h:41
void beginRun(edm::Run const &run, edm::EventSetup const &context)
BeginRun.