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();
330 LogVerbatim(
"Calibration") <<
"[DTNoiseCalibration] Total number of events analyzed: " <<
nevents_;
340 (*wHisto).second->Scale(normalization);
341 (*wHisto).second->Write();
346 (*chHisto).second->Scale(normalization);
347 (*chHisto).second->Write();
352 (*chHisto).second->Scale(normalization);
353 (*chHisto).second->Write();
381 if((*lHisto).second){
382 (*lHisto).second->Scale(normalization);
384 (*lHisto).second->Write();
389 const int nWires = lastWire - firstWire + 1;
391 double averageRate = 0.;
392 for(
int bin = 1;
bin <= (*lHisto).second->GetNbinsX(); ++
bin)
393 averageRate += (*lHisto).second->GetBinContent(
bin);
395 if(nWires) averageRate /= nWires;
396 LogTrace(
"Calibration") <<
" Average rate = " << averageRate;
398 for(
int i_wire = firstWire; i_wire <= lastWire; ++i_wire){
400 int bin = i_wire - firstWire + 1;
401 double channelRate = (*lHisto).second->GetBinContent(bin);
404 DTWireId wireID((*lHisto).first, i_wire);
406 LogVerbatim(
"Calibration") <<
">>> Channel noisy: " << wireID;
411 LogVerbatim(
"Calibration") <<
"Writing noise map object to DB";
412 string record =
"DTStatusFlagRcd";
413 DTCalibDBUtils::writeToDB<DTStatusFlag>(
record, statusMap);
422 channelName <<
"Wh" << wId.
wheel() <<
"_St" << wId.
station() <<
"_Sec" << wId.
sector()
425 return channelName.str();
433 stringstream superLayer; superLayer << dtSLId.
superlayer();
436 stringstream sector; sector << dtChId.
sector();
440 +
"_St" + station.str()
441 +
"_Sec" + sector.str()
442 +
"_SL" + superLayer.str()
443 +
"_L" + Layer.str();
451 stringstream superLayer; superLayer << dtSLId.
superlayer();
454 stringstream sector; sector << dtChId.
sector();
456 string superLayerName =
458 +
"_St" + station.str()
459 +
"_Sec" + sector.str()
460 +
"_SL" + superLayer.str();
462 return superLayerName;
469 stringstream sector; sector << dtChId.
sector();
473 +
"_St" + station.str()
474 +
"_Sec" + sector.str();
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
Timestamp const & endTime() const
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
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_
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.
SeedingLayerSetsHits::SeedingLayer Layer
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)
void beginRun(const edm::Run &run, const edm::EventSetup &setup)
std::string channelName(uint32_t, BinningType _btype=kDCC)
virtual ~DTNoiseCalibration()
Destructor.
void analyze(const edm::Event &e, const edm::EventSetup &c)
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_