CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
DTNoiseCalibration Class Reference

#include <DTNoiseCalibration.h>

Inheritance diagram for DTNoiseCalibration:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
void beginJob () override
 
void beginRun (const edm::Run &run, const edm::EventSetup &setup) override
 
 DTNoiseCalibration (const edm::ParameterSet &ps)
 Constructor. More...
 
void endJob () override
 
 ~DTNoiseCalibration () override
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

std::string getChamberName (const DTChamberId &) const
 
std::string getChannelName (const DTWireId &) const
 
std::string getLayerName (const DTLayerId &) const
 
std::string getSuperLayerName (const DTSuperLayerId &) const
 

Private Attributes

std::map< DTChamberId, TH1F * > chamberOccupancyVsLumiMap_
 
std::map< DTChamberId, TH1F * > chamberOccupancyVsTimeMap_
 
std::string dbLabel_
 
int defaultTtrig_
 
edm::InputTag digiLabel_
 
edm::ESHandle< DTGeometrydtGeom_
 
TH1F * hTDCTriggerWidth_
 
unsigned int lumiMax_
 
double maximumNoiseRate_
 
int nevents_
 
bool readDB_
 
TFile * rootFile_
 
time_t runBeginTime_
 
time_t runEndTime_
 
std::map< DTLayerId, TH1F * > theHistoOccupancyMap_
 
std::map< DTWireId, TH1F * > theHistoOccupancyVsLumiMap_
 
int timeWindowOffset_
 
double triggerWidth_
 
edm::ESHandle< DTTtrigtTrigMap_
 
bool useAbsoluteRate_
 
bool useTimeWindow_
 
std::vector< DTWireIdwireIdWithHisto_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 31 of file DTNoiseCalibration.h.

Constructor & Destructor Documentation

DTNoiseCalibration::DTNoiseCalibration ( const edm::ParameterSet ps)

Constructor.

Definition at line 42 of file DTNoiseCalibration.cc.

References defaultTtrig_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), readDB_, rootFile_, DTAnalyzerDetailed_cfi::rootFileName, relativeConstraints::station, makeMuonMisalignmentScenario::wheel, mixOne_premix_on_sim_cfi::wire, and wireIdWithHisto_.

42  :
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", "") ),
51  //fastAnalysis_( pset.getParameter<bool>("fastAnalysis", true) ),
52  wireIdWithHisto_( std::vector<DTWireId>() ),
53  lumiMax_(3000)
54  {
55 
56  // Get the debug parameter for verbose output
57  //debug = ps.getUntrackedParameter<bool>("debug");
58  /*// The analysis type
59  // The wheel & sector interested for the time-dependent analysis
60  wh = ps.getUntrackedParameter<int>("wheel", 0);
61  sect = ps.getUntrackedParameter<int>("sector", 6);*/
62 
63  if( pset.exists("defaultTtrig") ){
64  readDB_ = false;
65  defaultTtrig_ = pset.getParameter<int>("defaultTtrig");
66  }
67 
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){
71  //FIXME: Use regex to check whether format is right
72  if( (*cell) != "" && (*cell) != "None"){
73  stringstream linestr;
74  int wheel,station,sector,sl,layer,wire;
75  linestr << (*cell);
76  linestr >> wheel >> station >> sector >> sl >> layer >> wire;
77  wireIdWithHisto_.push_back(DTWireId(wheel,station,sector,sl,layer,wire));
78  }
79  }
80  }
81 
82  // The root file which will contain the histos
83  string rootFileName = pset.getUntrackedParameter<string>("rootFileName","noise.root");
84  rootFile_ = new TFile(rootFileName.c_str(), "RECREATE");
85  rootFile_->cd();
86 }
edm::InputTag digiLabel_
std::vector< DTWireId > wireIdWithHisto_
DTNoiseCalibration::~DTNoiseCalibration ( )
override

Destructor.

Definition at line 415 of file DTNoiseCalibration.cc.

References rootFile_.

415  {
416  rootFile_->Close();
417 }

Member Function Documentation

void DTNoiseCalibration::analyze ( const edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 118 of file DTNoiseCalibration.cc.

References DTSuperLayerId::chamberId(), chamberOccupancyVsLumiMap_, chamberOccupancyVsTimeMap_, DTTimeUnits::counts, defaultTtrig_, digiLabel_, dtGeom_, Exception, spr::find(), DTTopology::firstChannel(), objects.autophobj::float, DTTtrig::get(), getChamberName(), getChannelName(), getLayerName(), hTDCTriggerWidth_, createfilelist::int, gen::k, DTAnalyzerDetailed_cfi::kFactor, DTTopology::lastChannel(), DTGeometry::layer(), LogTrace, lumiMax_, nevents_, readDB_, rootFile_, runBeginTime_, runEndTime_, edm::second(), DTLayer::specificTopology(), mps_update::status, theHistoOccupancyMap_, theHistoOccupancyVsLumiMap_, edm::EventBase::time(), timeWindowOffset_, triggerWidth_, tTrigMap_, useTimeWindow_, edm::Timestamp::value(), and wireIdWithHisto_.

118  {
119  ++nevents_;
120 
121  // Get the digis from the event
122  Handle<DTDigiCollection> dtdigis;
123  event.getByLabel(digiLabel_, dtdigis);
124 
125  /*TH1F *hOccupancyHisto;
126  TH2F *hEvtPerWireH;
127  string Histo2Name;*/
128 
129  //RunNumber_t runNumber = event.id().run();
130  time_t eventTime = time_t(event.time().value()>>32);
131  unsigned int lumiSection = event.luminosityBlock();
132 
133  // Loop over digis
135  for (dtLayerId_It=dtdigis->begin(); dtLayerId_It!=dtdigis->end(); ++dtLayerId_It){
136  // Define time window
137  float upperLimit = 0.;
138  if(useTimeWindow_){
139  if( readDB_ ){
140  float tTrig,tTrigRMS,kFactor;
141  DTSuperLayerId slId = ((*dtLayerId_It).first).superlayerId();
142  int status = tTrigMap_->get( slId, tTrig, tTrigRMS, kFactor, DTTimeUnits::counts );
143  if(status != 0) throw cms::Exception("DTNoiseCalibration") << "Could not find tTrig entry in DB for" << slId << endl;
144  upperLimit = tTrig - timeWindowOffset_;
145  } else {
146  upperLimit = defaultTtrig_ - timeWindowOffset_;
147  }
148  }
149 
150  double triggerWidth_s = 0.;
151  if(useTimeWindow_) triggerWidth_s = ( (upperLimit*25)/32 )/1e9;
152  else triggerWidth_s = double(triggerWidth_/1e9);
153  LogTrace("Calibration") << ((*dtLayerId_It).first).superlayerId() << " Trigger width (s): " << triggerWidth_s;
154 
155  for (DTDigiCollection::const_iterator digiIt = ((*dtLayerId_It).second).first;
156  digiIt!=((*dtLayerId_It).second).second; ++digiIt){
157 
158  //Check the TDC trigger width
159  int tdcTime = (*digiIt).countsTDC();
160  if( !useTimeWindow_ ){
161  if( ( ((float)tdcTime*25)/32 ) > triggerWidth_ ){
162  LogError("Calibration") << "Digi has a TDC time (ns) higher than the pre-defined TDC trigger width: " << ((float)tdcTime*25)/32;
163  continue;
164  }
165  }
166 
167  hTDCTriggerWidth_->Fill(tdcTime);
168 
169  if( useTimeWindow_ && tdcTime > upperLimit) continue;
170 
171  /*LogTrace("Calibration") << "TDC time (ns): " << ((float)tdcTime*25)/32
172  <<" --- trigger width (ns): " << ((float)upperLimit*25)/32;*/
173 
174  const DTLayerId dtLId = (*dtLayerId_It).first;
175  const DTTopology& dtTopo = dtGeom_->layer(dtLId)->specificTopology();
176  const int firstWire = dtTopo.firstChannel();
177  const int lastWire = dtTopo.lastChannel();
178  //const int nWires = dtTopo.channels();
179  const int nWires = lastWire - firstWire + 1;
180 
181  // Book the occupancy histos
182  if( theHistoOccupancyMap_.find(dtLId) == theHistoOccupancyMap_.end() ){
183  string histoName = "DigiOccupancy_" + getLayerName(dtLId);
184  rootFile_->cd();
185  TH1F* hOccupancyHisto = new TH1F(histoName.c_str(), histoName.c_str(), nWires, firstWire, lastWire+1);
186  LogTrace("Calibration") << " Created occupancy Histo: " << hOccupancyHisto->GetName();
187  theHistoOccupancyMap_[dtLId] = hOccupancyHisto;
188  }
189  theHistoOccupancyMap_[dtLId]->Fill( (*digiIt).wire(), 1./triggerWidth_s );
190 
191  // Histos vs lumi section
192  const DTChamberId dtChId = dtLId.chamberId();
193  if( chamberOccupancyVsLumiMap_.find(dtChId) == chamberOccupancyVsLumiMap_.end() ){
194  string histoName = "OccupancyVsLumi_" + getChamberName(dtChId);
195  rootFile_->cd();
196  TH1F* hOccupancyVsLumiHisto = new TH1F(histoName.c_str(), histoName.c_str(), lumiMax_, 0, lumiMax_);
197  LogTrace("Calibration") << " Created occupancy histo: " << hOccupancyVsLumiHisto->GetName();
198  chamberOccupancyVsLumiMap_[dtChId] = hOccupancyVsLumiHisto;
199  }
200  chamberOccupancyVsLumiMap_[dtChId]->Fill( lumiSection, 1./triggerWidth_s );
201 
202  const DTWireId wireId(dtLId, (*digiIt).wire());
203  if( find(wireIdWithHisto_.begin(),wireIdWithHisto_.end(),wireId) != wireIdWithHisto_.end() ){
204  if( theHistoOccupancyVsLumiMap_.find(wireId) == theHistoOccupancyVsLumiMap_.end() ){
205  string histoName = "OccupancyVsLumi_" + getChannelName(wireId);
206  rootFile_->cd();
207  TH1F* hOccupancyVsLumiHisto = new TH1F(histoName.c_str(), histoName.c_str(), lumiMax_, 0, lumiMax_);
208  LogTrace("Calibration") << " Created occupancy histo: " << hOccupancyVsLumiHisto->GetName();
209  theHistoOccupancyVsLumiMap_[wireId] = hOccupancyVsLumiHisto;
210  }
211  theHistoOccupancyVsLumiMap_[wireId]->Fill( lumiSection, 1./triggerWidth_s );
212  }
213 
214  // Histos vs time
215  if( chamberOccupancyVsTimeMap_.find(dtChId) == chamberOccupancyVsTimeMap_.end() ){
216  string histoName = "OccupancyVsTime_" + getChamberName(dtChId);
217  float secPerBin = 20.0;
218  unsigned int nBins = ( (unsigned int)(runEndTime_ - runBeginTime_) )/secPerBin;
219  rootFile_->cd();
220  TH1F* hOccupancyVsTimeHisto = new TH1F(histoName.c_str(), histoName.c_str(),
221  nBins, (unsigned int)runBeginTime_,
222  (unsigned int)runEndTime_);
223  for(int k = 0; k < hOccupancyVsTimeHisto->GetNbinsX(); ++k){
224  if( k%10 == 0 ){
225  unsigned int binLowEdge = hOccupancyVsTimeHisto->GetBinLowEdge(k+1);
226  time_t timeValue = time_t(binLowEdge);
227  hOccupancyVsTimeHisto->GetXaxis()->SetBinLabel( (k+1),ctime(&timeValue) );
228  }
229  }
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) );
235 
236  LogTrace("Calibration") << " Created occupancy histo: " << hOccupancyVsTimeHisto->GetName();
237  chamberOccupancyVsTimeMap_[dtChId] = hOccupancyVsTimeHisto;
238  }
239  chamberOccupancyVsTimeMap_[dtChId]->Fill( (unsigned int)eventTime, 1./triggerWidth_s );
240 
241  /*// Book the digi event plot every 1000 events if the analysis is not "fast" and if is the correct sector
242  if(!fastAnalysis &&
243  dtLId.superlayerId().chamberId().wheel()==wh &&
244  dtLId.superlayerId().chamberId().sector()==sect) {
245  if(theHistoEvtPerWireMap.find(dtLId) == theHistoEvtPerWireMap.end() ||
246  (theHistoEvtPerWireMap.find(dtLId) != theHistoEvtPerWireMap.end() &&
247  skippedPlot[dtLId] != counter)){
248  skippedPlot[dtLId] = counter;
249  Histo2Name = "DigiPerWirePerEvent_" + getLayerName(dtLId) + "_" + std::to_string(counter);
250  theFile->cd();
251  hEvtPerWireH = new TH2F(Histo2Name.c_str(), Histo2Name.c_str(), 1000,0.5,1000.5,nWires, firstWire, lastWire+1);
252  if(hEvtPerWireH){
253  if(debug)
254  cout << " New Histo with the number of digi per evt per wire: " << hEvtPerWireH->GetName() << endl;
255  theHistoEvtPerWireMap[dtLId]=hEvtPerWireH;
256  }
257  }
258  }*/
259  }
260  }
261 
262  /*//Fill the plot of the number of digi per event per wire
263  std::map<int,int > DigiPerWirePerEvent;
264  // LOOP OVER ALL THE CHAMBERS
265  vector<DTChamber*>::const_iterator ch_it = dtGeom->chambers().begin();
266  vector<DTChamber*>::const_iterator ch_end = dtGeom->chambers().end();
267  for (; ch_it != ch_end; ++ch_it) {
268  DTChamberId ch = (*ch_it)->id();
269  vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
270  vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
271  // Loop over the SLs
272  for(; sl_it != sl_end; ++sl_it) {
273  DTSuperLayerId sl = (*sl_it)->id();
274  vector<const DTLayer*>::const_iterator l_it = (*sl_it)->layers().begin();
275  vector<const DTLayer*>::const_iterator l_end = (*sl_it)->layers().end();
276  // Loop over the Ls
277  for(; l_it != l_end; ++l_it) {
278  DTLayerId layerId = (*l_it)->id();
279 
280  // Get the number of wires
281  const DTTopology& dtTopo = dtGeom->layer(layerId)->specificTopology();
282  const int firstWire = dtTopo.firstChannel();
283  const int lastWire = dtTopo.lastChannel();
284 
285  if (theHistoEvtPerWireMap.find(layerId) != theHistoEvtPerWireMap.end() &&
286  skippedPlot[layerId] == counter) {
287 
288  for (int wire=firstWire; wire<=lastWire; wire++) {
289  DigiPerWirePerEvent[wire]= 0;
290  }
291  // loop over all the digis of the event
292  DTDigiCollection::Range layerDigi= dtdigis->get(layerId);
293  for (DTDigiCollection::const_iterator digi = layerDigi.first;
294  digi!=layerDigi.second;
295  ++digi){
296  if((cosmicRun && (*digi).countsTDC()<upperLimit) || (!cosmicRun))
297  DigiPerWirePerEvent[(*digi).wire()]+=1;
298  }
299  // fill the digi event histo
300  for (int wire=firstWire; wire<=lastWire; wire++) {
301  theFile->cd();
302  int histoEvents = nevents - (counter*1000);
303  theHistoEvtPerWireMap[layerId]->Fill(histoEvents,wire,DigiPerWirePerEvent[wire]);
304  }
305  }
306  } //Loop Ls
307  } //Loop SLs
308  } //Loop chambers
309 
310 
311  if(nevents % 1000 == 0) {
312  counter++;
313  // save the digis event plot on file
314  for(map<DTLayerId, TH2F* >::const_iterator lHisto = theHistoEvtPerWireMap.begin();
315  lHisto != theHistoEvtPerWireMap.end();
316  lHisto++) {
317  theFile->cd();
318  if((*lHisto).second)
319  (*lHisto).second->Write();
320  }
321  theHistoEvtPerWireMap.clear();
322  }*/
323 
324 }
edm::ESHandle< DTGeometry > dtGeom_
DTChamberId chamberId() const
Return the corresponding ChamberId.
edm::InputTag digiLabel_
std::vector< DTWireId > wireIdWithHisto_
std::map< DTLayerId, TH1F * > theHistoOccupancyMap_
std::string getChannelName(const DTWireId &) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
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.
Definition: DTTopology.h:78
std::string getLayerName(const DTLayerId &) const
std::map< DTWireId, TH1F * > theHistoOccupancyVsLumiMap_
U second(std::pair< T, U > const &p)
int lastChannel() const
Returns the wire number of the last wire.
Definition: DTTopology.h:80
const DTTopology & specificTopology() const
Definition: DTLayer.cc:42
#define LogTrace(id)
int k[5][pyjets_maxn]
int get(int wheelId, int stationId, int sectorId, int slId, float &tTrig, float &tTrms, float &kFact, DTTimeUnits::type unit) const
get content
Definition: DTTtrig.cc:85
std::vector< DTDigi >::const_iterator const_iterator
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:127
edm::ESHandle< DTTtrig > tTrigMap_
Definition: event.py:1
void DTNoiseCalibration::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 88 of file DTNoiseCalibration.cc.

References hTDCTriggerWidth_, nevents_, and triggerWidth_.

88  {
89  LogVerbatim("Calibration") << "[DTNoiseCalibration]: Begin job";
90 
91  nevents_ = 0;
92 
93  TH1::SetDefaultSumw2(true);
94  int numBin = (triggerWidth_*32/25)/50;
95  hTDCTriggerWidth_ = new TH1F("TDC_Time_Distribution", "TDC_Time_Distribution", numBin, 0, triggerWidth_*32/25);
96 }
void DTNoiseCalibration::beginRun ( const edm::Run run,
const edm::EventSetup setup 
)
override

Definition at line 98 of file DTNoiseCalibration.cc.

References edm::RunBase::beginTime(), dbLabel_, dtGeom_, edm::RunBase::endTime(), edm::EventSetup::get(), readDB_, runBeginTime_, runEndTime_, tTrigMap_, and edm::Timestamp::value().

98  {
99 
100  // Get the DT Geometry
101  setup.get<MuonGeometryRecord>().get(dtGeom_);
102 
103  // tTrig
104  if( readDB_ ) setup.get<DTTtrigRcd>().get(dbLabel_,tTrigMap_);
105 
106  runBeginTime_ = time_t(run.beginTime().value()>>32);
107  runEndTime_ = time_t(run.endTime().value()>>32);
108  /*
109  nevents = 0;
110  counter = 0;
111 
112  // TDC time distribution
113  int numBin = (triggerWidth_*(32/25))/50;
114  hTDCTriggerWidth = new TH1F("TDC_Time_Distribution", "TDC_Time_Distribution", numBin, 0, triggerWidth_*(32/25));*/
115 
116 }
Timestamp const & endTime() const
Definition: RunBase.h:42
edm::ESHandle< DTGeometry > dtGeom_
Timestamp const & beginTime() const
Definition: RunBase.h:41
T get() const
Definition: EventSetup.h:62
TimeValue_t value() const
Definition: Timestamp.h:56
edm::ESHandle< DTTtrig > tTrigMap_
void DTNoiseCalibration::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 326 of file DTNoiseCalibration.cc.

References stringResolutionProvider_cfi::bin, chamberOccupancyVsLumiMap_, chamberOccupancyVsTimeMap_, dtGeom_, DTTopology::firstChannel(), hTDCTriggerWidth_, DTTopology::lastChannel(), DTGeometry::layer(), LogTrace, maximumNoiseRate_, nevents_, PostProcessor_cff::normalization, record, rootFile_, DTStatusFlag::setCellNoise(), DTLayer::specificTopology(), theHistoOccupancyMap_, theHistoOccupancyVsLumiMap_, and useAbsoluteRate_.

Referenced by o2olib.O2ORunMgr::executeJob().

326  {
327 
328  //LogVerbatim("Calibration") << "[DTNoiseCalibration] endjob called!";
329  LogVerbatim("Calibration") << "[DTNoiseCalibration] Total number of events analyzed: " << nevents_;
330 
331  // Save the TDC digi plot
332  rootFile_->cd();
333  hTDCTriggerWidth_->Write();
334 
335  double normalization = 1./double(nevents_);
336 
337  for(map<DTWireId, TH1F*>::const_iterator wHisto = theHistoOccupancyVsLumiMap_.begin();
338  wHisto != theHistoOccupancyVsLumiMap_.end(); ++wHisto){
339  (*wHisto).second->Scale(normalization);
340  (*wHisto).second->Write();
341  }
342 
343  for(map<DTChamberId, TH1F*>::const_iterator chHisto = chamberOccupancyVsLumiMap_.begin();
344  chHisto != chamberOccupancyVsLumiMap_.end(); ++chHisto){
345  (*chHisto).second->Scale(normalization);
346  (*chHisto).second->Write();
347  }
348 
349  for(map<DTChamberId, TH1F*>::const_iterator chHisto = chamberOccupancyVsTimeMap_.begin();
350  chHisto != chamberOccupancyVsTimeMap_.end(); ++chHisto){
351  (*chHisto).second->Scale(normalization);
352  (*chHisto).second->Write();
353  }
354 
355  // Save on file the occupancy histos and write the list of noisy cells
356  DTStatusFlag *statusMap = new DTStatusFlag();
357  for(map<DTLayerId, TH1F*>::const_iterator lHisto = theHistoOccupancyMap_.begin();
358  lHisto != theHistoOccupancyMap_.end();
359  ++lHisto){
360  /*double triggerWidth_s = 0.;
361  if( useTimeWindow_ ){
362  double triggerWidth_ns = 0.;
363  if( readDB_ ){
364  float tTrig, tTrigRMS, kFactor;
365  DTSuperLayerId slId = ((*lHisto).first).superlayerId();
366  int status = tTrigMap_->get( slId, tTrig, tTrigRMS, kFactor, DTTimeUnits::counts );
367  if(status != 0) throw cms::Exception("DTNoiseCalibration") << "Could not find tTrig entry in DB for" << slId << endl;
368  triggerWidth_ns = tTrig - timeWindowOffset_;
369  } else{
370  triggerWidth_ns = defaultTtrig_ - timeWindowOffset_;
371  }
372  triggerWidth_ns = (triggerWidth_ns*25)/32;
373  triggerWidth_s = triggerWidth_ns/1e9;
374  } else{
375  triggerWidth_s = double(triggerWidth_/1e9);
376  }
377  LogTrace("Calibration") << (*lHisto).second->GetName() << " trigger width (s): " << triggerWidth_s;*/
378 
379  //double normalization = 1./(nevents_*triggerWidth_s);
380  if((*lHisto).second){
381  (*lHisto).second->Scale(normalization);
382  rootFile_->cd();
383  (*lHisto).second->Write();
384  const DTTopology& dtTopo = dtGeom_->layer((*lHisto).first)->specificTopology();
385  const int firstWire = dtTopo.firstChannel();
386  const int lastWire = dtTopo.lastChannel();
387  //const int nWires = dtTopo.channels();
388  const int nWires = lastWire - firstWire + 1;
389  // Find average in layer
390  double averageRate = 0.;
391  for(int bin = 1; bin <= (*lHisto).second->GetNbinsX(); ++bin)
392  averageRate += (*lHisto).second->GetBinContent(bin);
393 
394  if(nWires) averageRate /= nWires;
395  LogTrace("Calibration") << " Average rate = " << averageRate;
396 
397  for(int i_wire = firstWire; i_wire <= lastWire; ++i_wire){
398  // From definition of "noisy cell"
399  int bin = i_wire - firstWire + 1;
400  double channelRate = (*lHisto).second->GetBinContent(bin);
401  double rateOffset = (useAbsoluteRate_) ? 0. : averageRate;
402  if( (channelRate - rateOffset) > maximumNoiseRate_ ){
403  DTWireId wireID((*lHisto).first, i_wire);
404  statusMap->setCellNoise(wireID,true);
405  LogVerbatim("Calibration") << ">>> Channel noisy: " << wireID;
406  }
407  }
408  }
409  }
410  LogVerbatim("Calibration") << "Writing noise map object to DB";
411  string record = "DTStatusFlagRcd";
412  DTCalibDBUtils::writeToDB<DTStatusFlag>(record, statusMap);
413 }
JetCorrectorParameters::Record record
Definition: classes.h:7
edm::ESHandle< DTGeometry > dtGeom_
std::map< DTLayerId, TH1F * > theHistoOccupancyMap_
std::map< DTChamberId, TH1F * > chamberOccupancyVsTimeMap_
std::map< DTChamberId, TH1F * > chamberOccupancyVsLumiMap_
int firstChannel() const
Returns the wire number of the first wire.
Definition: DTTopology.h:78
std::map< DTWireId, TH1F * > theHistoOccupancyVsLumiMap_
int lastChannel() const
Returns the wire number of the last wire.
Definition: DTTopology.h:80
const DTTopology & specificTopology() const
Definition: DTLayer.cc:42
int setCellNoise(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool flag)
#define LogTrace(id)
bin
set the eta bin as selection string.
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:127
string DTNoiseCalibration::getChamberName ( const DTChamberId dtChId) const
private

Definition at line 453 of file DTNoiseCalibration.cc.

References DTChamberId::sector(), DTChamberId::station(), and DTChamberId::wheel().

Referenced by analyze().

453  {
454 
455  string chamberName =
456  "W" + std::to_string(dtChId.wheel())
457  + "_St" + std::to_string(dtChId.station())
458  + "_Sec" + std::to_string(dtChId.sector());
459 
460  return chamberName;
461 }
int sector() const
Definition: DTChamberId.h:61
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
string DTNoiseCalibration::getChannelName ( const DTWireId wId) const
private

Definition at line 419 of file DTNoiseCalibration.cc.

References ecaldqm::binning::channelName(), DTLayerId::layer(), DTChamberId::sector(), DTChamberId::station(), DTSuperLayerId::superlayer(), DTChamberId::wheel(), and DTWireId::wire().

Referenced by analyze().

419  {
420  string channelName = "Wh" + std::to_string(wId.wheel()) + "_St" + std::to_string(wId.station())
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());
423  return channelName;
424 }
int layer() const
Return the layer number.
Definition: DTLayerId.h:53
std::string channelName(uint32_t, BinningType _btype=kDCC)
int wire() const
Return the wire number.
Definition: DTWireId.h:56
int superlayer() const
Return the superlayer number (deprecated method name)
int sector() const
Definition: DTChamberId.h:61
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
string DTNoiseCalibration::getLayerName ( const DTLayerId lId) const
private

Definition at line 426 of file DTNoiseCalibration.cc.

References DTSuperLayerId::chamberId(), DTLayerId::layer(), DTChamberId::sector(), DTChamberId::station(), DTSuperLayerId::superlayer(), DTLayerId::superlayerId(), and DTChamberId::wheel().

Referenced by analyze().

426  {
427 
428  const DTSuperLayerId dtSLId = lId.superlayerId();
429  const DTChamberId dtChId = dtSLId.chamberId();
430  string layerName =
431  "W" + std::to_string(dtChId.wheel())
432  + "_St" + std::to_string(dtChId.station())
433  + "_Sec" + std::to_string(dtChId.sector())
434  + "_SL" + std::to_string(dtSLId.superlayer())
435  + "_L" + std::to_string(lId.layer());
436 
437  return layerName;
438 }
DTChamberId chamberId() const
Return the corresponding ChamberId.
int layer() const
Return the layer number.
Definition: DTLayerId.h:53
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:59
int superlayer() const
Return the superlayer number (deprecated method name)
int sector() const
Definition: DTChamberId.h:61
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
string DTNoiseCalibration::getSuperLayerName ( const DTSuperLayerId dtSLId) const
private

Definition at line 440 of file DTNoiseCalibration.cc.

References DTSuperLayerId::chamberId(), DTChamberId::sector(), DTChamberId::station(), DTSuperLayerId::superlayer(), and DTChamberId::wheel().

440  {
441 
442  const DTChamberId dtChId = dtSLId.chamberId();
443 
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());
449 
450  return superLayerName;
451 }
DTChamberId chamberId() const
Return the corresponding ChamberId.
int superlayer() const
Return the superlayer number (deprecated method name)
int sector() const
Definition: DTChamberId.h:61
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45

Member Data Documentation

std::map<DTChamberId, TH1F*> DTNoiseCalibration::chamberOccupancyVsLumiMap_
private

Definition at line 89 of file DTNoiseCalibration.h.

Referenced by analyze(), and endJob().

std::map<DTChamberId, TH1F*> DTNoiseCalibration::chamberOccupancyVsTimeMap_
private

Definition at line 91 of file DTNoiseCalibration.h.

Referenced by analyze(), and endJob().

std::string DTNoiseCalibration::dbLabel_
private

Definition at line 66 of file DTNoiseCalibration.h.

Referenced by beginRun().

int DTNoiseCalibration::defaultTtrig_
private

Definition at line 65 of file DTNoiseCalibration.h.

Referenced by analyze(), and DTNoiseCalibration().

edm::InputTag DTNoiseCalibration::digiLabel_
private

Definition at line 53 of file DTNoiseCalibration.h.

Referenced by analyze().

edm::ESHandle<DTGeometry> DTNoiseCalibration::dtGeom_
private

Definition at line 77 of file DTNoiseCalibration.h.

Referenced by analyze(), beginRun(), and endJob().

TH1F* DTNoiseCalibration::hTDCTriggerWidth_
private

Definition at line 83 of file DTNoiseCalibration.h.

Referenced by analyze(), beginJob(), and endJob().

unsigned int DTNoiseCalibration::lumiMax_
private

Definition at line 69 of file DTNoiseCalibration.h.

Referenced by analyze().

double DTNoiseCalibration::maximumNoiseRate_
private

Definition at line 57 of file DTNoiseCalibration.h.

Referenced by endJob().

int DTNoiseCalibration::nevents_
private

Definition at line 71 of file DTNoiseCalibration.h.

Referenced by analyze(), beginJob(), and endJob().

bool DTNoiseCalibration::readDB_
private

Definition at line 64 of file DTNoiseCalibration.h.

Referenced by analyze(), beginRun(), and DTNoiseCalibration().

TFile* DTNoiseCalibration::rootFile_
private

Definition at line 81 of file DTNoiseCalibration.h.

Referenced by analyze(), DTNoiseCalibration(), endJob(), and ~DTNoiseCalibration().

time_t DTNoiseCalibration::runBeginTime_
private

Definition at line 73 of file DTNoiseCalibration.h.

Referenced by analyze(), and beginRun().

time_t DTNoiseCalibration::runEndTime_
private

Definition at line 74 of file DTNoiseCalibration.h.

Referenced by analyze(), and beginRun().

std::map<DTLayerId, TH1F*> DTNoiseCalibration::theHistoOccupancyMap_
private

Definition at line 85 of file DTNoiseCalibration.h.

Referenced by analyze(), and endJob().

std::map<DTWireId, TH1F*> DTNoiseCalibration::theHistoOccupancyVsLumiMap_
private

Definition at line 87 of file DTNoiseCalibration.h.

Referenced by analyze(), and endJob().

int DTNoiseCalibration::timeWindowOffset_
private

Definition at line 56 of file DTNoiseCalibration.h.

Referenced by analyze().

double DTNoiseCalibration::triggerWidth_
private

Definition at line 55 of file DTNoiseCalibration.h.

Referenced by analyze(), and beginJob().

edm::ESHandle<DTTtrig> DTNoiseCalibration::tTrigMap_
private

Definition at line 79 of file DTNoiseCalibration.h.

Referenced by analyze(), and beginRun().

bool DTNoiseCalibration::useAbsoluteRate_
private

Definition at line 58 of file DTNoiseCalibration.h.

Referenced by endJob().

bool DTNoiseCalibration::useTimeWindow_
private

Definition at line 54 of file DTNoiseCalibration.h.

Referenced by analyze().

std::vector<DTWireId> DTNoiseCalibration::wireIdWithHisto_
private

Definition at line 68 of file DTNoiseCalibration.h.

Referenced by analyze(), and DTNoiseCalibration().