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") ),
49 readDB_(
true), defaultTtrig_(0),
50 dbLabel_( pset.getUntrackedParameter<
string>(
"dbLabel",
"") ),
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) !=
"" && (*cell) !=
"None"){
76 linestr >> wheel >> station >> sector >> sl >> layer >> wire;
84 rootFile_ =
new TFile(rootFileName.c_str(),
"RECREATE");
89 LogVerbatim(
"Calibration") <<
"[DTNoiseCalibration]: Begin job";
93 TH1::SetDefaultSumw2(
true);
130 time_t eventTime = time_t(event.
time().
value()>>32);
131 unsigned int lumiSection =
event.luminosityBlock();
135 for (dtLayerId_It=dtdigis->begin(); dtLayerId_It!=dtdigis->end(); ++dtLayerId_It){
137 float upperLimit = 0.;
143 if(status != 0)
throw cms::Exception(
"DTNoiseCalibration") <<
"Could not find tTrig entry in DB for" << slId << endl;
150 double triggerWidth_s = 0.;
153 LogTrace(
"Calibration") << ((*dtLayerId_It).first).superlayerId() <<
" Trigger width (s): " << triggerWidth_s;
156 digiIt!=((*dtLayerId_It).second).
second; ++digiIt){
159 int tdcTime = (*digiIt).countsTDC();
162 LogError(
"Calibration") <<
"Digi has a TDC time (ns) higher than the pre-defined TDC trigger width: " << ((
float)tdcTime*25)/32;
174 const DTLayerId dtLId = (*dtLayerId_It).first;
179 const int nWires = lastWire - firstWire + 1;
183 string histoName =
"DigiOccupancy_" +
getLayerName(dtLId);
185 TH1F* hOccupancyHisto =
new TH1F(histoName.c_str(), histoName.c_str(), nWires, firstWire, lastWire+1);
186 LogTrace(
"Calibration") <<
" Created occupancy Histo: " << hOccupancyHisto->GetName();
196 TH1F* hOccupancyVsLumiHisto =
new TH1F(histoName.c_str(), histoName.c_str(),
lumiMax_, 0,
lumiMax_);
197 LogTrace(
"Calibration") <<
" Created occupancy histo: " << hOccupancyVsLumiHisto->GetName();
202 const DTWireId wireId(dtLId, (*digiIt).wire());
207 TH1F* hOccupancyVsLumiHisto =
new TH1F(histoName.c_str(), histoName.c_str(),
lumiMax_, 0,
lumiMax_);
208 LogTrace(
"Calibration") <<
" Created occupancy histo: " << hOccupancyVsLumiHisto->GetName();
217 float secPerBin = 20.0;
220 TH1F* hOccupancyVsTimeHisto =
new TH1F(histoName.c_str(), histoName.c_str(),
223 for(
int k = 0;
k < hOccupancyVsTimeHisto->GetNbinsX(); ++
k){
225 unsigned int binLowEdge = hOccupancyVsTimeHisto->GetBinLowEdge(
k+1);
226 time_t timeValue = time_t(binLowEdge);
227 hOccupancyVsTimeHisto->GetXaxis()->SetBinLabel( (
k+1),ctime(&timeValue) );
230 size_t lastBin = hOccupancyVsTimeHisto->GetNbinsX();
231 unsigned int binUpperEdge = hOccupancyVsTimeHisto->GetBinLowEdge(lastBin) +
232 hOccupancyVsTimeHisto->GetBinWidth(lastBin);
233 time_t timeValue = time_t(binUpperEdge);
234 hOccupancyVsTimeHisto->GetXaxis()->SetBinLabel( (lastBin),ctime(&timeValue) );
236 LogTrace(
"Calibration") <<
" Created occupancy histo: " << hOccupancyVsTimeHisto->GetName();
329 LogVerbatim(
"Calibration") <<
"[DTNoiseCalibration] Total number of events analyzed: " <<
nevents_;
339 (*wHisto).second->Scale(normalization);
340 (*wHisto).second->Write();
345 (*chHisto).second->Scale(normalization);
346 (*chHisto).second->Write();
351 (*chHisto).second->Scale(normalization);
352 (*chHisto).second->Write();
380 if((*lHisto).second){
381 (*lHisto).second->Scale(normalization);
383 (*lHisto).second->Write();
388 const int nWires = lastWire - firstWire + 1;
390 double averageRate = 0.;
391 for(
int bin = 1;
bin <= (*lHisto).second->GetNbinsX(); ++
bin)
392 averageRate += (*lHisto).second->GetBinContent(
bin);
394 if(nWires) averageRate /= nWires;
395 LogTrace(
"Calibration") <<
" Average rate = " << averageRate;
397 for(
int i_wire = firstWire; i_wire <= lastWire; ++i_wire){
399 int bin = i_wire - firstWire + 1;
400 double channelRate = (*lHisto).second->GetBinContent(bin);
403 DTWireId wireID((*lHisto).first, i_wire);
405 LogVerbatim(
"Calibration") <<
">>> Channel noisy: " << wireID;
410 LogVerbatim(
"Calibration") <<
"Writing noise map object to DB";
411 string record =
"DTStatusFlagRcd";
412 DTCalibDBUtils::writeToDB<DTStatusFlag>(
record, statusMap);
421 +
"_Sec" + std::to_string(wId.
sector()) +
"_SL" + std::to_string(wId.
superlayer())
422 +
"_L" + std::to_string(wId.
layer()) +
"_W" + std::to_string(wId.
wire());
431 "W" + std::to_string(dtChId.
wheel())
432 +
"_St" + std::to_string(dtChId.
station())
433 +
"_Sec" + std::to_string(dtChId.
sector())
435 +
"_L" + std::to_string(lId.
layer());
444 string superLayerName =
445 "W" + std::to_string(dtChId.
wheel())
446 +
"_St" + std::to_string(dtChId.
station())
447 +
"_Sec" + std::to_string(dtChId.
sector())
448 +
"_SL" + std::to_string(dtSLId.
superlayer());
450 return superLayerName;
456 "W" + std::to_string(dtChId.
wheel())
457 +
"_St" + std::to_string(dtChId.
station())
458 +
"_Sec" + std::to_string(dtChId.
sector());
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
Timestamp const & endTime() const
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
def setup(process, global_tag, zero_tesla=False)
std::string getChannelName(const DTWireId &) const
void beginRun(const edm::Run &run, const edm::EventSetup &setup) override
int layer() const
Return the layer number.
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.
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.
U second(std::pair< T, U > const &p)
int lastChannel() const
Returns the wire number of the last wire.
const DTTopology & specificTopology() const
int setCellNoise(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool flag)
std::string channelName(uint32_t, BinningType _btype=kDCC)
bin
set the eta bin as selection string.
int wire() const
Return the wire number.
int superlayer() const
Return the superlayer number (deprecated method name)
int get(int wheelId, int stationId, int sectorId, int slId, float &tTrig, float &tTrms, float &kFact, DTTimeUnits::type unit) const
get content
std::vector< DTDigi >::const_iterator const_iterator
Timestamp const & beginTime() const
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
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_