43 : digiLabel_(pset.getParameter<
InputTag>(
"digiLabel")),
44 useTimeWindow_(pset.getParameter<bool>(
"useTimeWindow")),
45 triggerWidth_(pset.getParameter<double>(
"triggerWidth")),
46 timeWindowOffset_(pset.getParameter<int>(
"timeWindowOffset")),
47 maximumNoiseRate_(pset.getParameter<double>(
"maximumNoiseRate")),
48 useAbsoluteRate_(pset.getParameter<bool>(
"useAbsoluteRate")),
64 if (pset.
exists(
"defaultTtrig")) {
69 if (pset.
exists(
"cellsWithHisto")) {
71 for (vector<string>::const_iterator cell = cellsWithHisto.begin(); cell != cellsWithHisto.end(); ++cell) {
73 if ((!cell->empty()) && (*cell) !=
"None") {
77 linestr >> wheel >> station >> sector >> sl >> layer >> wire;
85 rootFile_ =
new TFile(rootFileName.c_str(),
"RECREATE");
90 LogVerbatim(
"Calibration") <<
"[DTNoiseCalibration]: Begin job";
94 TH1::SetDefaultSumw2(
true);
128 time_t eventTime = time_t(event.
time().
value() >> 32);
129 unsigned int lumiSection =
event.luminosityBlock();
133 for (dtLayerId_It = dtdigis->begin(); dtLayerId_It != dtdigis->end(); ++dtLayerId_It) {
138 float tTrig, tTrigRMS, kFactor;
142 throw cms::Exception(
"DTNoiseCalibration") <<
"Could not find tTrig entry in DB for" << slId << endl;
149 double triggerWidth_s = 0.;
151 triggerWidth_s = ((upperLimit * 25) / 32) / 1e9;
154 LogTrace(
"Calibration") << ((*dtLayerId_It).first).superlayerId() <<
" Trigger width (s): " << triggerWidth_s;
157 digiIt != ((*dtLayerId_It).second).
second;
160 int tdcTime = (*digiIt).countsTDC();
163 LogError(
"Calibration") <<
"Digi has a TDC time (ns) higher than the pre-defined TDC trigger width: "
164 << ((float)tdcTime * 25) / 32;
177 const DTLayerId dtLId = (*dtLayerId_It).first;
182 const int nWires = lastWire - firstWire + 1;
186 string histoName =
"DigiOccupancy_" +
getLayerName(dtLId);
188 TH1F* hOccupancyHisto =
new TH1F(histoName.c_str(), histoName.c_str(), nWires, firstWire, lastWire + 1);
189 LogTrace(
"Calibration") <<
" Created occupancy Histo: " << hOccupancyHisto->GetName();
199 TH1F* hOccupancyVsLumiHisto =
new TH1F(histoName.c_str(), histoName.c_str(),
lumiMax_, 0,
lumiMax_);
200 LogTrace(
"Calibration") <<
" Created occupancy histo: " << hOccupancyVsLumiHisto->GetName();
205 const DTWireId wireId(dtLId, (*digiIt).wire());
210 TH1F* hOccupancyVsLumiHisto =
new TH1F(histoName.c_str(), histoName.c_str(),
lumiMax_, 0,
lumiMax_);
211 LogTrace(
"Calibration") <<
" Created occupancy histo: " << hOccupancyVsLumiHisto->GetName();
220 float secPerBin = 20.0;
223 TH1F* hOccupancyVsTimeHisto =
new TH1F(
225 for (
int k = 0;
k < hOccupancyVsTimeHisto->GetNbinsX(); ++
k) {
227 unsigned int binLowEdge = hOccupancyVsTimeHisto->GetBinLowEdge(
k + 1);
228 time_t timeValue = time_t(binLowEdge);
229 hOccupancyVsTimeHisto->GetXaxis()->SetBinLabel((
k + 1), ctime(&timeValue));
232 size_t lastBin = hOccupancyVsTimeHisto->GetNbinsX();
233 unsigned int binUpperEdge =
234 hOccupancyVsTimeHisto->GetBinLowEdge(lastBin) + hOccupancyVsTimeHisto->GetBinWidth(lastBin);
235 time_t timeValue = time_t(binUpperEdge);
236 hOccupancyVsTimeHisto->GetXaxis()->SetBinLabel((lastBin), ctime(&timeValue));
238 LogTrace(
"Calibration") <<
" Created occupancy histo: " << hOccupancyVsTimeHisto->GetName();
329 LogVerbatim(
"Calibration") <<
"[DTNoiseCalibration] Total number of events analyzed: " <<
nevents_;
335 double normalization = 1. / double(
nevents_);
340 (*wHisto).second->Scale(normalization);
341 (*wHisto).second->Write();
347 (*chHisto).second->Scale(normalization);
348 (*chHisto).second->Write();
354 (*chHisto).second->Scale(normalization);
355 (*chHisto).second->Write();
383 if ((*lHisto).second) {
384 (*lHisto).second->Scale(normalization);
386 (*lHisto).second->Write();
391 const int nWires = lastWire - firstWire + 1;
393 double averageRate = 0.;
394 for (
int bin = 1;
bin <= (*lHisto).second->GetNbinsX(); ++
bin)
395 averageRate += (*lHisto).second->GetBinContent(
bin);
398 averageRate /= nWires;
399 LogTrace(
"Calibration") <<
" Average rate = " << averageRate;
401 for (
int i_wire = firstWire; i_wire <= lastWire; ++i_wire) {
403 int bin = i_wire - firstWire + 1;
404 double channelRate = (*lHisto).second->GetBinContent(bin);
407 DTWireId wireID((*lHisto).first, i_wire);
409 LogVerbatim(
"Calibration") <<
">>> Channel noisy: " << wireID;
414 LogVerbatim(
"Calibration") <<
"Writing noise map object to DB";
415 string record =
"DTStatusFlagRcd";
416 DTCalibDBUtils::writeToDB<DTStatusFlag>(
record, statusMap);
423 std::to_string(wId.
sector()) +
"_SL" + std::to_string(wId.
superlayer()) +
"_L" +
424 std::to_string(wId.
layer()) +
"_W" + std::to_string(wId.
wire());
431 string layerName =
"W" + std::to_string(dtChId.
wheel()) +
"_St" + std::to_string(dtChId.
station()) +
"_Sec" +
432 std::to_string(dtChId.
sector()) +
"_SL" + std::to_string(dtSLId.
superlayer()) +
"_L" +
433 std::to_string(lId.
layer());
441 string superLayerName =
"W" + std::to_string(dtChId.
wheel()) +
"_St" + std::to_string(dtChId.
station()) +
"_Sec" +
442 std::to_string(dtChId.
sector()) +
"_SL" + std::to_string(dtSLId.
superlayer());
444 return superLayerName;
448 string chamberName =
"W" + std::to_string(dtChId.
wheel()) +
"_St" + std::to_string(dtChId.
station()) +
"_Sec" +
449 std::to_string(dtChId.
sector());
Log< level::Info, true > LogVerbatim
T getUntrackedParameter(std::string const &, T const &) const
Timestamp const & endTime() const
constexpr char const * layerName[numberOfLayers]
void analyze(const edm::Event &e, const edm::EventSetup &c) override
edm::ESHandle< DTGeometry > dtGeom_
DTChamberId chamberId() const
Return the corresponding ChamberId.
std::vector< DTWireId > wireIdWithHisto_
std::map< DTLayerId, TH1F * > theHistoOccupancyMap_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::string getChannelName(const DTWireId &) const
void beginRun(const edm::Run &run, const edm::EventSetup &setup) override
int layer() const
Return the layer number.
Log< level::Error, false > LogError
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::map< DTChamberId, TH1F * > chamberOccupancyVsTimeMap_
std::string getChamberName(const DTChamberId &) const
std::map< DTChamberId, TH1F * > chamberOccupancyVsLumiMap_
~DTNoiseCalibration() override
Destructor.
constexpr std::array< uint8_t, layerIndexSize > layer
int firstChannel() const
Returns the wire number of the first wire.
std::string getLayerName(const DTLayerId &) const
std::map< DTWireId, TH1F * > theHistoOccupancyVsLumiMap_
DTNoiseCalibration(const edm::ParameterSet &ps)
Constructor.
bool getData(T &iHolder) const
U second(std::pair< T, U > const &p)
int lastChannel() const
Returns the wire number of the last wire.
int setCellNoise(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool flag)
int wire() const
Return the wire number.
int superlayer() const
Return the superlayer number (deprecated method name)
const edm::ESGetToken< DTTtrig, DTTtrigRcd > ttrigToken_
T getParameter(std::string const &) const
std::vector< DigiType >::const_iterator const_iterator
Timestamp const & beginTime() const
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
std::string channelName(EcalElectronicsMapping const *, uint32_t, BinningType _btype=kDCC)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
int station() const
Return the station number.
int wheel() const
Return the wheel number.
TimeValue_t value() const
std::string getSuperLayerName(const DTSuperLayerId &) const
edm::Timestamp time() const
edm::ESHandle< DTTtrig > tTrigMap_