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 edm::EDConsumerBase

Public Member Functions

 DTNoiseTest (const edm::ParameterSet &ps)
 Constructor. More...
 
virtual ~DTNoiseTest ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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
 
- 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 50 of file DTNoiseTest.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 36 of file DTNoiseTest.cc.

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

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

Destructor.

Definition at line 51 of file DTNoiseTest.cc.

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

Member Function Documentation

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

Analyze.

Implements edm::EDAnalyzer.

Definition at line 89 of file DTNoiseTest.cc.

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

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 59 of file DTNoiseTest.cc.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 79 of file DTNoiseTest.cc.

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

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

BeginRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 68 of file DTNoiseTest.cc.

References edm::EventSetup::get().

68  {
69 
70  edm::LogVerbatim ("noise") <<"[DTNoiseTest]: BeginRun";
71 
72  // Get the geometry
73  context.get<MuonGeometryRecord>().get(muonGeom);
74 
75 }
edm::ESHandle< DTGeometry > muonGeom
Definition: DTNoiseTest.h:103
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 260 of file DTNoiseTest.cc.

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

DQM Client Diagnostic.

Reimplemented from edm::EDAnalyzer.

Definition at line 97 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, AlCaHLTBitMon_QueryRunRegistry::string, DTSuperLayerId::superLayer(), and w().

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

Get the ME name.

Definition at line 271 of file DTNoiseTest.cc.

References dt-layouts::histoname, Parameters::parameters, DTChamberId::sector(), DTChamberId::station(), relativeConstraints::station, and DTChamberId::wheel().

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

Definition at line 295 of file DTNoiseTest.cc.

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

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

Member Data Documentation

DQMStore* DTNoiseTest::dbe
private

Definition at line 100 of file DTNoiseTest.h.

bool DTNoiseTest::debug
private
std::map<std::string, std::map<uint32_t, MonitorElement*> > DTNoiseTest::histos
private
edm::ESHandle<DTGeometry> DTNoiseTest::muonGeom
private

Definition at line 103 of file DTNoiseTest.h.

unsigned int DTNoiseTest::nLumiSegs
private

Definition at line 96 of file DTNoiseTest.h.

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

Definition at line 97 of file DTNoiseTest.h.

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

Definition at line 109 of file DTNoiseTest.h.

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

Definition at line 104 of file DTNoiseTest.h.

int DTNoiseTest::updates
private

Definition at line 95 of file DTNoiseTest.h.