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")) {
70 vector<string> cellsWithHisto =
pset.getParameter<vector<string> >(
"cellsWithHisto");
71 for (vector<string>::const_iterator cell = cellsWithHisto.begin(); cell != cellsWithHisto.end(); ++cell) {
73 if ((!cell->empty()) && (*cell) !=
"None") {
84 string rootFileName =
pset.getUntrackedParameter<
string>(
"rootFileName",
"noise.root");
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) {
135 float upperLimit = 0.;
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;
188 TH1F* hOccupancyHisto =
new TH1F(
histoName.c_str(),
histoName.c_str(), nWires, firstWire, lastWire + 1);
189 LogTrace(
"Calibration") <<
" Created occupancy Histo: " << hOccupancyHisto->GetName();
200 LogTrace(
"Calibration") <<
" Created occupancy histo: " << hOccupancyVsLumiHisto->GetName();
205 const DTWireId wireId(dtLId, (*digiIt).wire());
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_;
341 (*wHisto).second->Write();
348 (*chHisto).second->Write();
355 (*chHisto).second->Write();
383 if ((*lHisto).second) {
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);
444 return superLayerName;
Log< level::Info, true > LogVerbatim
int station() const
Return the station number.
constexpr char const * layerName[numberOfLayers]
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_
std::string to_string(const V &value)
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.
constexpr std::array< uint8_t, layerIndexSize > layer
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)
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
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.
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