43 useTimeWindow_(
pset.getParameter<
bool>(
"useTimeWindow")),
44 triggerWidth_(
pset.getParameter<double>(
"triggerWidth")),
45 timeWindowOffset_(
pset.getParameter<
int>(
"timeWindowOffset")),
46 maximumNoiseRate_(
pset.getParameter<double>(
"maximumNoiseRate")),
47 useAbsoluteRate_(
pset.getParameter<
bool>(
"useAbsoluteRate")),
63 if (
pset.exists(
"defaultTtrig")) {
68 if (
pset.exists(
"cellsWithHisto")) {
69 vector<string> cellsWithHisto =
pset.getParameter<vector<string> >(
"cellsWithHisto");
70 for (vector<string>::const_iterator cell = cellsWithHisto.begin(); cell != cellsWithHisto.end(); ++cell) {
72 if ((!cell->empty()) && (*cell) !=
"None") {
83 string rootFileName =
pset.getUntrackedParameter<
string>(
"rootFileName",
"noise.root");
89 LogVerbatim(
"Calibration") <<
"[DTNoiseCalibration]: Begin job";
93 TH1::SetDefaultSumw2(
true);
114 time_t eventTime = time_t(
event.time().value() >> 32);
115 unsigned int lumiSection =
event.luminosityBlock();
119 for (dtLayerId_It = dtdigis->begin(); dtLayerId_It != dtdigis->end(); ++dtLayerId_It) {
121 float upperLimit = 0.;
128 throw cms::Exception(
"DTNoiseCalibration") <<
"Could not find tTrig entry in DB for" << slId << endl;
135 double triggerWidth_s = 0.;
137 triggerWidth_s = ((upperLimit * 25) / 32) / 1e9;
140 LogTrace(
"Calibration") << ((*dtLayerId_It).first).superlayerId() <<
" Trigger width (s): " << triggerWidth_s;
143 digiIt != ((*dtLayerId_It).second).
second;
146 int tdcTime = (*digiIt).countsTDC();
149 LogError(
"Calibration") <<
"Digi has a TDC time (ns) higher than the pre-defined TDC trigger width: " 150 << ((
float)tdcTime * 25) / 32;
160 const DTLayerId dtLId = (*dtLayerId_It).first;
164 const int nWires = lastWire - firstWire + 1;
170 TH1F* hOccupancyHisto =
new TH1F(
histoName.c_str(),
histoName.c_str(), nWires, firstWire, lastWire + 1);
171 LogTrace(
"Calibration") <<
" Created occupancy Histo: " << hOccupancyHisto->GetName();
182 LogTrace(
"Calibration") <<
" Created occupancy histo: " << hOccupancyVsLumiHisto->GetName();
187 const DTWireId wireId(dtLId, (*digiIt).wire());
193 LogTrace(
"Calibration") <<
" Created occupancy histo: " << hOccupancyVsLumiHisto->GetName();
202 float secPerBin = 20.0;
205 TH1F* hOccupancyVsTimeHisto =
new TH1F(
207 for (
int k = 0;
k < hOccupancyVsTimeHisto->GetNbinsX(); ++
k) {
209 unsigned int binLowEdge = hOccupancyVsTimeHisto->GetBinLowEdge(
k + 1);
210 time_t timeValue = time_t(binLowEdge);
211 hOccupancyVsTimeHisto->GetXaxis()->SetBinLabel((
k + 1), ctime(&timeValue));
214 size_t lastBin = hOccupancyVsTimeHisto->GetNbinsX();
215 unsigned int binUpperEdge =
216 hOccupancyVsTimeHisto->GetBinLowEdge(lastBin) + hOccupancyVsTimeHisto->GetBinWidth(lastBin);
217 time_t timeValue = time_t(binUpperEdge);
218 hOccupancyVsTimeHisto->GetXaxis()->SetBinLabel((lastBin), ctime(&timeValue));
220 LogTrace(
"Calibration") <<
" Created occupancy histo: " << hOccupancyVsTimeHisto->GetName();
229 LogVerbatim(
"Calibration") <<
"[DTNoiseCalibration] Total number of events analyzed: " <<
nevents_;
241 (*wHisto).second->Write();
248 (*chHisto).second->Write();
255 (*chHisto).second->Write();
263 if ((*lHisto).second) {
266 (*lHisto).second->Write();
270 const int nWires = lastWire - firstWire + 1;
272 double averageRate = 0.;
273 for (
int bin = 1;
bin <= (*lHisto).second->GetNbinsX(); ++
bin)
274 averageRate += (*lHisto).second->GetBinContent(
bin);
277 averageRate /= nWires;
278 LogTrace(
"Calibration") <<
" Average rate = " << averageRate;
280 for (
int i_wire = firstWire; i_wire <= lastWire; ++i_wire) {
282 int bin = i_wire - firstWire + 1;
283 double channelRate = (*lHisto).second->GetBinContent(
bin);
286 DTWireId wireID((*lHisto).first, i_wire);
288 LogVerbatim(
"Calibration") <<
">>> Channel noisy: " << wireID;
293 LogVerbatim(
"Calibration") <<
"Writing noise map object to DB";
294 string record =
"DTStatusFlagRcd";
295 DTCalibDBUtils::writeToDB<DTStatusFlag>(
record, statusMap);
323 return superLayerName;
Log< level::Info, true > LogVerbatim
int station() const
Return the station number.
const bool useAbsoluteRate_
const double triggerWidth_
int wire() const
Return the wire number.
void analyze(const edm::Event &e, const edm::EventSetup &c) override
edm::ESHandle< DTGeometry > dtGeom_
std::vector< DTWireId > wireIdWithHisto_
std::map< DTLayerId, TH1F * > theHistoOccupancyMap_
void beginRun(const edm::Run &run, const edm::EventSetup &setup) override
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::map< DTChamberId, TH1F * > chamberOccupancyVsTimeMap_
std::map< DTChamberId, TH1F * > chamberOccupancyVsLumiMap_
~DTNoiseCalibration() override
Destructor.
static std::string to_string(const XMLCh *ch)
std::string getChamberName(const DTChamberId &) const
std::map< DTWireId, TH1F * > theHistoOccupancyVsLumiMap_
DTNoiseCalibration(const edm::ParameterSet &ps)
Constructor.
int firstChannel() const
Returns the wire number of the first wire.
std::string getSuperLayerName(const DTSuperLayerId &) const
U second(std::pair< T, U > const &p)
const double maximumNoiseRate_
DTChamberId chamberId() const
Return the corresponding ChamberId.
int setCellNoise(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool flag)
const DTTopology & specificTopology() const
const int timeWindowOffset_
int superlayer() const
Return the superlayer number (deprecated method name)
const edm::ESGetToken< DTTtrig, DTTtrigRcd > ttrigToken_
std::vector< DigiType >::const_iterator const_iterator
int layer() const
Return the layer number.
int get(int wheelId, int stationId, int sectorId, int slId, float &tTrig, float &tTrms, float &kFact, DTTimeUnits::type unit) const
get content
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
int wheel() const
Return the wheel number.
int lastChannel() const
Returns the wire number of the last wire.
std::string channelName(EcalElectronicsMapping const *, uint32_t, BinningType _btype=kDCC)
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
const edm::EDGetTokenT< DTDigiCollection > digiToken_
const bool useTimeWindow_
edm::ESHandle< DTTtrig > tTrigMap_
std::string getChannelName(const DTWireId &) const
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
std::string getLayerName(const DTLayerId &) const