CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Attributes
DTNoiseTest Class Reference

#include <DTNoiseTest.h>

Inheritance diagram for DTNoiseTest:
edm::EDAnalyzer

Public Member Functions

 DTNoiseTest (const edm::ParameterSet &ps)
 Constructor. More...
 
virtual ~DTNoiseTest ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
 Analyze. More...
 
void beginJob ()
 BeginJob. More...
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
 
void beginRun (const edm::Run &r, const edm::EventSetup &c)
 BeginRun. More...
 
void bookHistos (const DTChamberId &ch, std::string folder, std::string histoTag)
 book the new ME More...
 
void bookHistos (const DTLayerId &ch, int nWire, std::string folder, std::string histoTag)
 
void endJob ()
 Endjob. More...
 
void endLuminosityBlock (edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c)
 DQM Client Diagnostic. More...
 
std::string getMEName (const DTChamberId &ch)
 Get the ME name. More...
 
std::string getMEName (const DTLayerId &ly)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Private Attributes

DQMStoredbe
 
bool debug
 
std::map< std::string,
std::map< uint32_t,
MonitorElement * > > 
histos
 
edm::ESHandle< DTGeometrymuonGeom
 
unsigned int nLumiSegs
 
edm::ParameterSet parameters
 
int prescaleFactor
 
int run
 
std::vector< DTWireIdtheNoisyChannels
 
edm::ESHandle< DTTtrigtTrigMap
 
int updates
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Detailed Description

Definition at line 52 of file DTNoiseTest.h.

Constructor & Destructor Documentation

DTNoiseTest::DTNoiseTest ( const edm::ParameterSet ps)

Constructor.

Definition at line 38 of file DTNoiseTest.cc.

References cppFunctionSkipper::operator, Parameters::parameters, and dtDQMClient_cfg::prescaleFactor.

38  {
39 
40  edm::LogVerbatim ("noise") <<"[DTNoiseTest]: Constructor";
41 
42  parameters = ps;
43 
45  dbe->setCurrentFolder("DT/Tests/Noise");
46 
47  prescaleFactor = parameters.getUntrackedParameter<int>("diagnosticPrescale", 1);
48 
49 }
T getUntrackedParameter(std::string const &, T const &) const
int prescaleFactor
Definition: DTNoiseTest.h:99
edm::ParameterSet parameters
Definition: DTNoiseTest.h:104
DQMStore * dbe
Definition: DTNoiseTest.h:102
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
DTNoiseTest::~DTNoiseTest ( )
virtual

Destructor.

Definition at line 53 of file DTNoiseTest.cc.

53  {
54 
55  edm::LogVerbatim ("noise") <<"DTNoiseTest: analyzed " << updates << " events";
56 
57 }

Member Function Documentation

void DTNoiseTest::analyze ( const edm::Event e,
const edm::EventSetup c 
)
protectedvirtual

Analyze.

Implements edm::EDAnalyzer.

Definition at line 91 of file DTNoiseTest.cc.

91  {
92 
93  updates++;
94  edm::LogVerbatim ("noise") << "[DTNoiseTest]: "<<updates<<" events";
95 
96 }
void DTNoiseTest::beginJob ( void  )
protectedvirtual

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 61 of file DTNoiseTest.cc.

61  {
62 
63  edm::LogVerbatim ("noise") <<"[DTNoiseTest]: BeginJob";
64 
65  updates = 0;
66 
67 }
void DTNoiseTest::beginLuminosityBlock ( edm::LuminosityBlock const &  lumiSeg,
edm::EventSetup const &  context 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 81 of file DTNoiseTest.cc.

References edm::LuminosityBlockBase::run(), and DTTTrigCorrFirst::run.

81  {
82 
83  edm::LogVerbatim ("noise") <<"[DTNoiseTest]: Begin of LS transition";
84 
85  // Get the run number
86  run = lumiSeg.run();
87 
88 }
void DTNoiseTest::beginRun ( const edm::Run r,
const edm::EventSetup c 
)
protectedvirtual

BeginRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 70 of file DTNoiseTest.cc.

References edm::EventSetup::get().

70  {
71 
72  edm::LogVerbatim ("noise") <<"[DTNoiseTest]: BeginRun";
73 
74  // Get the geometry
75  context.get<MuonGeometryRecord>().get(muonGeom);
76 
77 }
edm::ESHandle< DTGeometry > muonGeom
Definition: DTNoiseTest.h:105
void DTNoiseTest::bookHistos ( const DTChamberId ch,
std::string  folder,
std::string  histoTag 
)
protected

book the new ME

void DTNoiseTest::bookHistos ( const DTLayerId ch,
int  nWire,
std::string  folder,
std::string  histoTag 
)
protected
void DTNoiseTest::endJob ( void  )
protectedvirtual

Endjob.

Reimplemented from edm::EDAnalyzer.

Definition at line 262 of file DTNoiseTest.cc.

262  {
263 
264  edm::LogVerbatim ("noise") <<"[DTNoiseTest] endjob called!";
265 
266  //if ( parameters.getUntrackedParameter<bool>("writeHisto", true) )
267  // dbe->save(parameters.getUntrackedParameter<string>("outputFile", "DTNoiseTest.root"));
268 
269  dbe->rmdir("DT/Tests/Noise");
270 }
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2530
DQMStore * dbe
Definition: DTNoiseTest.h:102
void DTNoiseTest::endLuminosityBlock ( edm::LuminosityBlock const &  lumiSeg,
edm::EventSetup const &  c 
)
protectedvirtual

DQM Client Diagnostic.

Reimplemented from edm::EDAnalyzer.

Definition at line 99 of file DTNoiseTest.cc.

References PDRates::average, begin, bookHistos(), DTTimeUnits::counts, end, spr::find(), edm::EventSetup::get(), QReport::getBadChannels(), MonitorElement::getTH2F(), mergeVDriftHistosByStation::histos, edm::LuminosityBlockBase::id(), edm::LuminosityBlockID::luminosityBlock(), Mean, nevents, Parameters::parameters, dtDQMClient_cfg::prescaleFactor, edm::second(), crabStatusFromReport::statusMap, DTSuperLayerId::superLayer(), and w().

99  {
100 
101  // counts number of updats (online mode) or number of events (standalone mode)
102  //updates++;
103  // if running in standalone perform diagnostic only after a reasonalbe amount of events
104  //if ( parameters.getUntrackedParameter<bool>("runningStandalone", false) &&
105  // updates%parameters.getUntrackedParameter<int>("diagnosticPrescale", 1000) != 0 ) return;
106 
107  //edm::LogVerbatim ("noise") <<"[DTNoiseTest]: "<<updates<<" updates";
108 
109 
110  edm::LogVerbatim ("noise") <<"[DTNoiseTest]: End of LS transition, performing the DQM client operation";
111 
112  // counts number of lumiSegs
113  nLumiSegs = lumiSeg.id().luminosityBlock();
114 
115  // prescale factor
116  if ( nLumiSegs%prescaleFactor != 0 ) return;
117 
118  edm::LogVerbatim ("noise") <<"[DTNoiseTest]: "<<nLumiSegs<<" updates";
119 
121  context.get<DTStatusFlagRcd>().get(statusMap);
122 
123  context.get<DTTtrigRcd>().get(tTrigMap);
124  float tTrig, tTrigRMS, kFactor;
125 
126  string histoTag;
127  // loop over chambers
128  vector<DTChamber*>::const_iterator ch_it = muonGeom->chambers().begin();
129  vector<DTChamber*>::const_iterator ch_end = muonGeom->chambers().end();
130 
131  for (; ch_it != ch_end; ++ch_it) {
132  DTChamberId ch = (*ch_it)->id();
133  vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
134  vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
135 
136  MonitorElement * noiseME = dbe->get(getMEName(ch));
137  if (noiseME) {
138  TH2F * noiseHisto = noiseME->getTH2F();
139 
140  // WARNING uncorrect normalization!! TO BE PROVIDED CENTRALLY
141  double nevents = (int) noiseHisto->GetEntries();
142 
143  double normalization =0;
144 
145  float average=0;
146  float nOfChannels=0;
147  float noiseStatistics=0;
148  int newNoiseChannels=0;
149 
150  for(; sl_it != sl_end; ++sl_it) {
151  const DTSuperLayerId & slID = (*sl_it)->id();
152 
153  // ttrig and rms are counts
154  tTrigMap->get(slID, tTrig, tTrigRMS, kFactor, DTTimeUnits::counts);
155  if (tTrig==0) tTrig=1;
156  const double ns_s = 1e9*(32/25);
157  normalization = ns_s/float(tTrig*nevents);
158 
159  noiseHisto->Scale(normalization);
160 
161  // loop over layers
162 
163  for (int binY=(slID.superLayer()-1)*4+1 ; binY <= (slID.superLayer()-1)*4+4; binY++) {
164 
165  int Y = binY - 4*(slID.superLayer()-1);
166 
167  // the layer
168 
169  const DTLayerId theLayer(slID,Y);
170 
171  // loop over channels
172  for (int binX=1; binX <= noiseHisto->GetNbinsX(); binX++) {
173 
174  if (noiseHisto->GetBinContent(binX,binY) > parameters.getUntrackedParameter<int>("HzThreshold", 300))
175  theNoisyChannels.push_back(DTWireId(theLayer, binX));
176 
177  // get rid of the dead channels
178  else {
179  average += noiseHisto->GetBinContent(binX,binY);
180  nOfChannels++;
181  }
182  }
183  }
184 
185  if (nOfChannels) noiseStatistics = average/nOfChannels;
186  histoTag = "NoiseAverage";
187 
188  if (histos[histoTag].find((*ch_it)->id().rawId()) == histos[histoTag].end()) bookHistos((*ch_it)->id(),string("NoiseAverage"), histoTag );
189  histos[histoTag].find((*ch_it)->id().rawId())->second->setBinContent(slID.superLayer(),noiseStatistics);
190 
191  for ( vector<DTWireId>::const_iterator nb_it = theNoisyChannels.begin();
192  nb_it != theNoisyChannels.end(); ++nb_it) {
193 
194  bool isNoisy = false;
195  bool isFEMasked = false;
196  bool isTDCMasked = false;
197  bool isTrigMask = false;
198  bool isDead = false;
199  bool isNohv = false;
200  statusMap->cellStatus((*nb_it), isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
201 
202  if (!isNoisy) newNoiseChannels++;
203  }
204  theNoisyChannels.clear();
205  histoTag = "NewNoisyChannels";
206  if (histos[histoTag].find((*ch_it)->id().rawId()) == histos[histoTag].end()) bookHistos((*ch_it)->id(),string("NewNoisyChannels"), histoTag );
207  histos[histoTag].find((*ch_it)->id().rawId())->second->setBinContent(slID.superLayer(), newNoiseChannels);
208  }
209  }
210  //To compute the Noise Mean test
211  vector<const DTSuperLayer*>::const_iterator sl2_it = (*ch_it)->superLayers().begin();
212  vector<const DTSuperLayer*>::const_iterator sl2_end = (*ch_it)->superLayers().end();
213  for(; sl2_it != sl2_end; ++sl2_it) {
214  vector<const DTLayer*>::const_iterator l_it = (*sl2_it)->layers().begin();
215  vector<const DTLayer*>::const_iterator l_end = (*sl2_it)->layers().end();
216  for(; l_it != l_end; ++l_it) {
217 
218  DTLayerId lID = (*l_it)->id();
219  MonitorElement * noisePerEventME = dbe->get(getMEName(lID));
220 
221  if (noisePerEventME) {
222  TH2F * noiseHistoPerEvent = noisePerEventME->getTH2F();
223  int nWires = muonGeom->layer(lID)->specificTopology().channels();
224  double MeanNumerator=0, MeanDenominator=0;
225  histoTag = "MeanDigiPerEvent";
226  for (int w=1; w<=nWires; w++){
227  for(int numDigi=1; numDigi<=10; numDigi++){
228  MeanNumerator+=(noiseHistoPerEvent->GetBinContent(w,numDigi)*(numDigi-1));
229  MeanDenominator+=noiseHistoPerEvent->GetBinContent(w,numDigi);
230  }
231  double Mean=MeanNumerator/MeanDenominator;
232  if (histos[histoTag].find((*l_it)->id().rawId()) == histos[histoTag].end()) bookHistos((*l_it)->id(),nWires, string("MeanDigiPerEvent"), histoTag );
233  histos[histoTag].find((*l_it)->id().rawId())->second->setBinContent(w, Mean);
234  }
235  }
236  }
237  }
238  }
239 
240  // Noise Mean test
241  histoTag = "MeanDigiPerEvent";
242  string MeanCriterionName = parameters.getUntrackedParameter<string>("meanTestName","NoiseMeanInRange");
243  for(map<uint32_t, MonitorElement*>::const_iterator hMean = histos[histoTag].begin();
244  hMean != histos[histoTag].end();
245  hMean++) {
246  const QReport * theMeanQReport = (*hMean).second->getQReport(MeanCriterionName);
247  if(theMeanQReport) {
248  vector<dqm::me_util::Channel> badChannels = theMeanQReport->getBadChannels();
249  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin();
250  channel != badChannels.end(); channel++) {
251  LogVerbatim ("tTrigCalibration")<<"LayerId : "<<(*hMean).first<<" Bad mean channels: "<<(*channel).getBin()<<" Contents : "<<(*channel).getContents();
252  // FIXME: getMessage() sometimes returns and invalid string (null pointer inside QReport data member)
253  // LogVerbatim ("tTrigCalibration") << "-------- LayerId : "<<(*hMean).first<<" "<<theMeanQReport->getMessage()<<" ------- "<<theMeanQReport->getStatus();
254  }
255  }
256  }
257 
258 }
T getUntrackedParameter(std::string const &, T const &) const
edm::ESHandle< DTGeometry > muonGeom
Definition: DTNoiseTest.h:105
std::vector< DTWireId > theNoisyChannels
Definition: DTNoiseTest.h:111
unsigned int nLumiSegs
Definition: DTNoiseTest.h:98
edm::ESHandle< DTTtrig > tTrigMap
Definition: DTNoiseTest.h:106
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)
int prescaleFactor
Definition: DTNoiseTest.h:99
int superLayer() const
Return the superlayer number.
int nevents
#define end
Definition: vmac.h:38
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1468
const std::vector< DQMChannel > & getBadChannels(void) const
Definition: QReport.h:33
edm::ParameterSet parameters
Definition: DTNoiseTest.h:104
void bookHistos(const DTChamberId &ch, std::string folder, std::string histoTag)
book the new ME
DQMStore * dbe
Definition: DTNoiseTest.h:102
int average
Definition: PDRates.py:137
#define begin
Definition: vmac.h:31
std::string getMEName(const DTChamberId &ch)
Get the ME name.
Definition: DTNoiseTest.cc:273
std::map< std::string, std::map< uint32_t, MonitorElement * > > histos
Definition: DTNoiseTest.h:115
TH2F * getTH2F(void) const
T w() const
string DTNoiseTest::getMEName ( const DTChamberId ch)
protected

Get the ME name.

Definition at line 273 of file DTNoiseTest.cc.

References Parameters::parameters, DTChamberId::sector(), DTChamberId::station(), relativeConstraints::station, and DTChamberId::wheel().

273  {
274 
275  stringstream wheel; wheel << ch.wheel();
276  stringstream station; station << ch.station();
277  stringstream sector; sector << ch.sector();
278 
279  string folderRoot = parameters.getUntrackedParameter<string>("folderRoot", "Collector/FU0/");
280  string folderTag = parameters.getUntrackedParameter<string>("folderTag", "Occupancies");
281  string folderName =
282  folderRoot + "DT/DTDigiTask/Wheel" + wheel.str() +
283  "/Station" + station.str() +
284  "/Sector" + sector.str() + "/" + folderTag + "/";
285 
286  string histoTag = parameters.getUntrackedParameter<string>("histoTag", "OccupancyNoise_perCh");
287  string histoname = folderName + histoTag
288  + "_W" + wheel.str()
289  + "_St" + station.str()
290  + "_Sec" + sector.str();
291 
292 
293  return histoname;
294 
295 }
T getUntrackedParameter(std::string const &, T const &) const
edm::ParameterSet parameters
Definition: DTNoiseTest.h:104
int sector() const
Definition: DTChamberId.h:63
int station() const
Return the station number.
Definition: DTChamberId.h:53
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:47
string DTNoiseTest::getMEName ( const DTLayerId ly)
protected

Definition at line 297 of file DTNoiseTest.cc.

References DTLayerId::layer(), Parameters::parameters, DTChamberId::sector(), DTChamberId::station(), relativeConstraints::station, DTSuperLayerId::superlayer(), and DTChamberId::wheel().

297  {
298 
299  stringstream wheel; wheel << ly.wheel();
300  stringstream station; station << ly.station();
301  stringstream sector; sector << ly.sector();
302  stringstream superLayer; superLayer << ly.superlayer();
303  stringstream layer; layer << ly.layer();
304 
305  string folderRoot = parameters.getUntrackedParameter<string>("folderRoot", "Collector/FU0/");
306  string folderTag = parameters.getUntrackedParameter<string>("folderTagForDigiPerEventTest", "DigiPerEvent");
307  string folderName =
308  folderRoot + "DT/DTDigiForNoiseTask/Wheel" + wheel.str() +
309  "/Station" + station.str() +
310  "/Sector" + sector.str() + "/" + folderTag + "/";
311 
312  string histoTag = parameters.getUntrackedParameter<string>("histoTagForDigiPerEventTest", "DigiPerEvent");
313  string histoname = folderName + histoTag
314  + "_W" + wheel.str()
315  + "_St" + station.str()
316  + "_Sec" + sector.str()
317  + "_SL" + superLayer.str()
318  + "_L" + layer.str();
319 
320 
321  return histoname;
322 
323 }
T getUntrackedParameter(std::string const &, T const &) const
int layer() const
Return the layer number.
Definition: DTLayerId.h:55
edm::ParameterSet parameters
Definition: DTNoiseTest.h:104
int superlayer() const
Return the superlayer number (deprecated method name)
int sector() const
Definition: DTChamberId.h:63
int station() const
Return the station number.
Definition: DTChamberId.h:53
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:47

Member Data Documentation

DQMStore* DTNoiseTest::dbe
private

Definition at line 102 of file DTNoiseTest.h.

bool DTNoiseTest::debug
private

Definition at line 96 of file DTNoiseTest.h.

std::map<std::string, std::map<uint32_t, MonitorElement*> > DTNoiseTest::histos
private

Definition at line 115 of file DTNoiseTest.h.

edm::ESHandle<DTGeometry> DTNoiseTest::muonGeom
private

Definition at line 105 of file DTNoiseTest.h.

unsigned int DTNoiseTest::nLumiSegs
private

Definition at line 98 of file DTNoiseTest.h.

edm::ParameterSet DTNoiseTest::parameters
private
int DTNoiseTest::prescaleFactor
private

Definition at line 99 of file DTNoiseTest.h.

int DTNoiseTest::run
private
std::vector<DTWireId> DTNoiseTest::theNoisyChannels
private

Definition at line 111 of file DTNoiseTest.h.

edm::ESHandle<DTTtrig> DTNoiseTest::tTrigMap
private

Definition at line 106 of file DTNoiseTest.h.

int DTNoiseTest::updates
private

Definition at line 97 of file DTNoiseTest.h.