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  * $Date: 2010/01/05 10:15:46 $
6  * $Revision: 1.15 $
7  * \author G. Mila - INFN Torino
8  */
9 
10 
12 
13 // Framework
15 
16 
17 // Geometry
22 
25 
29 
30 #include <stdio.h>
31 #include <sstream>
32 #include <math.h>
33 
34 
35 using namespace edm;
36 using namespace std;
37 
38 
40 
41  edm::LogVerbatim ("deadChannel") << "[DTDeadChannelTest]: Constructor";
42 
43  parameters = ps;
44 
45  dbe = edm::Service<DQMStore>().operator->();
46 
47  prescaleFactor = parameters.getUntrackedParameter<int>("diagnosticPrescale", 1);
48 
49 }
50 
52 
53  edm::LogVerbatim ("deadChannel") << "DTDeadChannelTest: analyzed " << nevents << " events";
54 
55 }
56 
57 
59 
60  edm::LogVerbatim ("deadChannel") << "[DTDeadChannelTest]: BeginJob";
61 
62  nevents = 0;
63 
64 }
65 
66 void DTDeadChannelTest::beginRun(Run const& run, EventSetup const& context) {
67 
68  edm::LogVerbatim ("deadChannel") << "[DTDeadChannelTest]: BeginRun";
69 
70  // Get the geometry
71  context.get<MuonGeometryRecord>().get(muonGeom);
72 
73 }
74 
75 
77 
78  edm::LogVerbatim ("deadChannel") <<"[DTDeadChannelTest]: Begin of LS transition";
79 
80  // Get the run number
81  run = lumiSeg.run();
82 
83 }
84 
85 
86 
88 
89  nevents++;
90  edm::LogVerbatim ("deadChannel") << "[DTDeadChannelTest]: "<<nevents<<" events";
91 
92 }
93 
94 
95 
97 
98  // counts number of updats (online mode) or number of events (standalone mode)
99  //nevents++;
100  // if running in standalone perform diagnostic only after a reasonalbe amount of events
101  //if ( parameters.getUntrackedParameter<bool>("runningStandalone", false) &&
102  // nevents%parameters.getUntrackedParameter<int>("diagnosticPrescale", 1000) != 0 ) return;
103  //edm::LogVerbatim ("deadChannel") << "[DTDeadChannelTest]: "<<nevents<<" updates";
104 
105 
106  edm::LogVerbatim ("deadChannel") <<"[DTDeadChannelTest]: End of LS transition, performing the DQM client operation";
107 
108  // counts number of lumiSegs
109  nLumiSegs = lumiSeg.id().luminosityBlock();
110 
111  // prescale factor
112  if ( nLumiSegs%prescaleFactor != 0 ) return;
113 
114  edm::LogVerbatim ("deadChannel") <<"[DTDeadChannelTest]: "<<nLumiSegs<<" updates";
115 
116 
117  vector<DTChamber*>::const_iterator ch_it = muonGeom->chambers().begin();
118  vector<DTChamber*>::const_iterator ch_end = muonGeom->chambers().end();
119 
120  edm::LogVerbatim ("deadChannel") << "[DTDeadChannelTest]: Occupancy tests results";
121 
122  // Loop over the chambers
123  for (; ch_it != ch_end; ++ch_it) {
124  DTChamberId chID = (*ch_it)->id();
125  vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
126  vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
127 
128  stringstream wheel; wheel << chID.wheel();
129  stringstream station; station << chID.station();
130  stringstream sector; sector << chID.sector();
131 
132  context.get<DTTtrigRcd>().get(tTrigMap);
133 
134  string HistoName = "W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str();
135 
136  // Get the ME produced by DigiTask Source
137  MonitorElement * noise_histo = dbe->get(getMEName("OccupancyNoise_perCh", chID));
138  MonitorElement * hitInTime_histo = dbe->get(getMEName("OccupancyInTimeHits_perCh", chID));
139 
140  // ME -> TH2F
141  if(noise_histo && hitInTime_histo) {
142  TH2F * noise_histo_root = noise_histo->getTH2F();
143  TH2F * hitInTime_histo_root = hitInTime_histo->getTH2F();
144 
145  // Loop over the SuperLayers
146  for(; sl_it != sl_end; ++sl_it) {
147  DTSuperLayerId slID = (*sl_it)->id();
148  vector<const DTLayer*>::const_iterator l_it = (*sl_it)->layers().begin();
149  vector<const DTLayer*>::const_iterator l_end = (*sl_it)->layers().end();
150 
151  // ttrig and rms are counts
152  float tTrig, tTrigRMS, kFactor;
153  tTrigMap->get(slID, tTrig, tTrigRMS, kFactor, DTTimeUnits::counts);
154 
155  // Loop over the layers
156  for(; l_it != l_end; ++l_it) {
157  DTLayerId lID = (*l_it)->id();
158 
159  //Parameters to fill histos
160  stringstream superLayer; superLayer << slID.superlayer();
161  stringstream layer; layer << lID.layer();
162  string HistoNameTest = "W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str() + "_SL" + superLayer.str() + "_L" + layer.str();
163 
164  const int firstWire = muonGeom->layer(lID)->specificTopology().firstChannel();
165  const int lastWire = muonGeom->layer(lID)->specificTopology().lastChannel();
166 
167  int entry=-1;
168  if(slID.superlayer() == 1) entry=0;
169  if(slID.superlayer() == 2) entry=4;
170  if(slID.superlayer() == 3) entry=8;
171  int YBinNumber = entry+lID.layer();
172 
173 
174  // Loop over the TH2F bin and fill the ME to be used for the Quality Test
175  for(int bin=firstWire; bin <= lastWire; bin++) {
176  if (OccupancyDiffHistos.find(HistoNameTest) == OccupancyDiffHistos.end()) bookHistos(lID, firstWire, lastWire);
177  // tMax default value
178  float tMax = 450.0;
179 
180  float difference = (hitInTime_histo_root->GetBinContent(bin, YBinNumber) / tMax)
181  - (noise_histo_root->GetBinContent(bin, YBinNumber) / tTrig);
182  OccupancyDiffHistos.find(HistoNameTest)->second->setBinContent(bin, difference);
183  }
184  } // loop on layers
185  } // loop on superlayers
186  }
187  } // loop on chambers
188 
189  // Occupancy Difference test
190  string OccupancyDiffCriterionName = parameters.getUntrackedParameter<string>("OccupancyDiffTestName","OccupancyDiffInRange");
191  for(map<string, MonitorElement*>::const_iterator hOccDiff = OccupancyDiffHistos.begin();
192  hOccDiff != OccupancyDiffHistos.end();
193  hOccDiff++) {
194  const QReport * theOccupancyDiffQReport = (*hOccDiff).second->getQReport(OccupancyDiffCriterionName);
195  if(theOccupancyDiffQReport) {
196  vector<dqm::me_util::Channel> badChannels = theOccupancyDiffQReport->getBadChannels();
197  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin();
198  channel != badChannels.end(); channel++) {
199  edm::LogError ("deadChannel") << "Layer : "<<(*hOccDiff).first<<" Bad occupancy difference channels: "<<(*channel).getBin()<<" Contents : "<<(*channel).getContents();
200  }
201  // FIXME: getMessage() sometimes returns and invalid string (null pointer inside QReport data member)
202  // edm::LogWarning("deadChannel")<< "-------- Layer : "<<(*hOccDiff).first<<" "<<theOccupancyDiffQReport->getMessage()<<" ------- "<<theOccupancyDiffQReport->getStatus();
203  }
204  }
205 
206 }
207 
208 
210 
211  edm::LogVerbatim ("deadChannel") << "[DTDeadChannelTest] endjob called!";
212 
213  dbe->rmdir("DT/Tests/DTDeadChannel");
214 
215 }
216 
217 string DTDeadChannelTest::getMEName(string histoTag, const DTChamberId & chId) {
218 
219  stringstream wheel; wheel << chId.wheel();
220  stringstream station; station << chId.station();
221  stringstream sector; sector << chId.sector();
222 
223  string folderRoot = parameters.getUntrackedParameter<string>("folderRoot", "Collector/FU0/");
224  string folderName =
225  folderRoot + "DT/DTDigiTask/Wheel" + wheel.str() +
226  "/Station" + station.str() +
227  "/Sector" + sector.str() +
228  "/Occupancies" + "/";
229 
230  string histoname = folderName + histoTag
231  + "_W" + wheel.str()
232  + "_St" + station.str()
233  + "_Sec" + sector.str();
234 
235  return histoname;
236 
237 }
238 
239 
240 void DTDeadChannelTest::bookHistos(const DTLayerId & lId, int firstWire, int lastWire) {
241 
242  stringstream wheel; wheel << lId.superlayerId().wheel();
243  stringstream station; station << lId.superlayerId().station();
244  stringstream sector; sector << lId.superlayerId().sector();
245  stringstream superLayer; superLayer << lId.superlayerId().superlayer();
246  stringstream layer; layer << lId.layer();
247 
248  string HistoName = "W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str() + "_SL" + superLayer.str() + "_L" + layer.str();
249  string OccupancyDiffHistoName = "OccupancyDiff_" + HistoName;
250 
251  dbe->setCurrentFolder("DT/Tests/DTDeadChannel/Wheel" + wheel.str() +
252  "/Station" + station.str() +
253  "/Sector" + sector.str());
254 
255  OccupancyDiffHistos[HistoName] = dbe->book1D(OccupancyDiffHistoName.c_str(),OccupancyDiffHistoName.c_str(),lastWire-firstWire+1, firstWire-0.5, lastWire+0.5);
256 
257 }
LuminosityBlockID id() const
dictionary parameters
Definition: Parameters.py:2
std::string getMEName(std::string histoTag, const DTChamberId &chId)
Get the ME name.
void endJob()
Endjob.
int layer() const
Return the layer number.
Definition: DTLayerId.h:55
DTDeadChannelTest(const edm::ParameterSet &ps)
Constructor.
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:61
void bookHistos()
Definition: Histogram.h:33
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
RunNumber_t run() const
int nevents
void beginJob()
BeginJob.
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)
const T & get() const
Definition: EventSetup.h:55
LuminosityBlockNumber_t luminosityBlock() const
std::string HistoName
void bookHistos(const DTLayerId &ch, int firstWire, int lastWire)
book the new ME
int sector() const
Definition: DTChamberId.h:63
int station() const
Return the station number.
Definition: DTChamberId.h:53
TH2F * getTH2F(void) const
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:47
virtual ~DTDeadChannelTest()
Destructor.
Definition: Run.h:36
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c)
DQM Client Diagnostic.
void beginRun(edm::Run const &run, edm::EventSetup const &context)
BeginRun.