CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
DTNoiseTask Class Reference

#include <DTNoiseTask.h>

Inheritance diagram for DTNoiseTask:
edm::EDAnalyzer

Public Member Functions

 DTNoiseTask (const edm::ParameterSet &ps)
 Constructor. More...
 
virtual ~DTNoiseTask ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
 Analyze. More...
 
void beginJob ()
 BeginJob. More...
 
void beginLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
 To reset the MEs. More...
 
void beginRun (const edm::Run &, const edm::EventSetup &)
 
void endJob ()
 Endjob. More...
 
void endLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &setup)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Private Member Functions

void bookHistos (DTChamberId chId)
 
void bookHistos (DTSuperLayerId slId)
 

Private Attributes

DQMStoredbe
 
bool doSegmentVeto
 
bool doTimeBoxHistos
 
edm::InputTag dtDigiLabel
 
edm::ESHandle< DTGeometrydtGeom
 
int evtNumber
 
std::map< DTChamberId, int > mapEvt
 
MonitorElementnEventMonitor
 
std::map< DTChamberId,
MonitorElement * > 
noiseHistos
 
double safeMargin
 
std::map< DTSuperLayerId,
MonitorElement * > 
tbHistos
 
std::string theRecHits4DLabel
 
std::map< DTChamberId, double > tTrigStMap
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Detailed Description

No description available.

Date:
2011/06/10 13:23:26
Revision:
1.9
Authors
G. Mila , G. Cerminara - INFN Torino

Definition at line 32 of file DTNoiseTask.h.

Constructor & Destructor Documentation

DTNoiseTask::DTNoiseTask ( const edm::ParameterSet ps)

Constructor.

Definition at line 48 of file DTNoiseTask.cc.

References dbe, doSegmentVeto, doTimeBoxHistos, dtDigiLabel, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), cppFunctionSkipper::operator, safeMargin, and theRecHits4DLabel.

48  : evtNumber(0) {
49 
50  LogVerbatim("DTNoiseTask") << "[DTNoiseTask]: Constructor"<<endl;
51 
53 
54  //switch for timeBox booking
55  doTimeBoxHistos = ps.getUntrackedParameter<bool>("doTbHistos", false);
56 
57  // The label to retrieve the digis
58  dtDigiLabel = ps.getParameter<InputTag>("dtDigiLabel");
59 
60  // the name of the 4D rec hits collection
61  theRecHits4DLabel = ps.getParameter<string>("recHits4DLabel");
62 
63  // switch for segment veto
64  doSegmentVeto = ps.getUntrackedParameter<bool>("doSegmentVeto", false);
65 
66  // safe margin (ns) between ttrig and beginning of counting area
67  safeMargin = ps.getUntrackedParameter<double>("safeMargin", 200.);
68 
69 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag dtDigiLabel
Definition: DTNoiseTask.h:64
bool doSegmentVeto
Definition: DTNoiseTask.h:72
double safeMargin
Definition: DTNoiseTask.h:92
bool doTimeBoxHistos
Definition: DTNoiseTask.h:68
DQMStore * dbe
Definition: DTNoiseTask.h:74
std::string theRecHits4DLabel
Definition: DTNoiseTask.h:70
DTNoiseTask::~DTNoiseTask ( )
virtual

Destructor.

Definition at line 74 of file DTNoiseTask.cc.

74 {}

Member Function Documentation

void DTNoiseTask::analyze ( const edm::Event e,
const edm::EventSetup c 
)
protectedvirtual

Analyze.

Implements edm::EDAnalyzer.

Definition at line 98 of file DTNoiseTask.cc.

References doSegmentVeto, doTimeBoxHistos, dtDigiLabel, evtNumber, MonitorElement::Fill(), edm::Event::getByLabel(), mapEvt, nEventMonitor, noiseHistos, safeMargin, edm::second(), tbHistos, theRecHits4DLabel, and tTrigStMap.

98  {
99 
100  evtNumber++;
102 
103  if(evtNumber%1000==0)
104  LogVerbatim("DTNoiseTask") <<"[DTNoiseTask]: Analyzing evt number :"<<evtNumber<<endl;
105 
106  // map of the chambers with at least 1 segment
107  std::map<DTChamberId, int> segmentsChId;
108 
109  // Get the 4D segment collection from the event
111  if(doSegmentVeto) {
112  e.getByLabel(theRecHits4DLabel, all4DSegments);
113 
114  // Loop over all chambers containing a segment and look for the number of segments
116  for (chamberId = all4DSegments->id_begin();
117  chamberId != all4DSegments->id_end();
118  ++chamberId){
119  segmentsChId[*chamberId]=1;
120  }
121  }
122 
123  // Get the digis from the event
125  e.getByLabel(dtDigiLabel, dtdigis);
126 
127  // LOOP OVER ALL THE DIGIS OF THE EVENT
129  for (dtLayerId_It=dtdigis->begin(); dtLayerId_It!=dtdigis->end(); ++dtLayerId_It){
130  for (DTDigiCollection::const_iterator digiIt = ((*dtLayerId_It).second).first;
131  digiIt!=((*dtLayerId_It).second).second; ++digiIt){
132 
133  //Check the TDC trigger width
134  int tdcTime = (*digiIt).countsTDC();
135  double upperLimit = tTrigStMap[(*dtLayerId_It).first.superlayerId().chamberId()]-safeMargin;
136  if(doTimeBoxHistos)
137  tbHistos[(*dtLayerId_It).first.superlayerId()]->Fill(tdcTime);
138  if(tdcTime>upperLimit)
139  continue;
140 
141  //Check the chamber has no 4D segments (optional)
142  if(doSegmentVeto &&
143  segmentsChId.find((*dtLayerId_It).first.superlayerId().chamberId())!=segmentsChId.end())
144  continue;
145 
146  // fill the occupancy histo
147  // FIXME: needs to be optimized: no need to rescale the histo for each digi
148  TH2F* noise_root = noiseHistos[(*dtLayerId_It).first.superlayerId().chamberId()]->getTH2F();
149  double normalization=0;
150  if(mapEvt.find((*dtLayerId_It).first.superlayerId().chamberId())!=mapEvt.end()) {
151  LogVerbatim("DTNoiseTask") << " Last fill: # of events: "
152  << mapEvt[(*dtLayerId_It).first.superlayerId().chamberId()]
153  << endl;
154  normalization = 1e-9*upperLimit*mapEvt[(*dtLayerId_It).first.superlayerId().chamberId()];
155  // revert back to # of entries
156  noise_root->Scale(normalization);
157  }
158  int yBin=(*dtLayerId_It).first.layer()+(4*((*dtLayerId_It).first.superlayerId().superlayer()-1));
159  noise_root->Fill((*digiIt).wire(),yBin);
160  // normalize the occupancy histo
161  mapEvt[(*dtLayerId_It).first.superlayerId().chamberId()] = evtNumber;
162  LogVerbatim("DTNoiseTask") << (*dtLayerId_It).first << " wire: " << (*digiIt).wire()
163  << " # counts: " << noise_root->GetBinContent((*digiIt).wire(),yBin)
164  << " Time interval: " << upperLimit
165  << " # of events: " << evtNumber << endl;;
166  normalization = double( 1e-9*upperLimit*mapEvt[(*dtLayerId_It).first.superlayerId().chamberId()]);
167  // update the rate
168  noise_root->Scale(1./normalization);
169  LogVerbatim("DTNoiseTask") << " noise rate: "
170  << noise_root->GetBinContent((*digiIt).wire(),yBin) << endl;
171  }
172  }
173 }
std::map< DTChamberId, int > mapEvt
Definition: DTNoiseTask.h:84
edm::InputTag dtDigiLabel
Definition: DTNoiseTask.h:64
identifier iterator
Definition: RangeMap.h:138
MonitorElement * nEventMonitor
Definition: DTNoiseTask.h:89
bool doSegmentVeto
Definition: DTNoiseTask.h:72
void Fill(long long x)
U second(std::pair< T, U > const &p)
double safeMargin
Definition: DTNoiseTask.h:92
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::map< DTSuperLayerId, MonitorElement * > tbHistos
Definition: DTNoiseTask.h:87
std::map< DTChamberId, double > tTrigStMap
Definition: DTNoiseTask.h:78
std::vector< DigiType >::const_iterator const_iterator
bool doTimeBoxHistos
Definition: DTNoiseTask.h:68
std::map< DTChamberId, MonitorElement * > noiseHistos
Definition: DTNoiseTask.h:81
std::string theRecHits4DLabel
Definition: DTNoiseTask.h:70
void DTNoiseTask::beginJob ( void  )
protectedvirtual

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 79 of file DTNoiseTask.cc.

79  {
80 
81  LogVerbatim("DTNoiseTask") << "[DTNoiseTask]: BeginJob"<<endl;
82 
83 }
void DTNoiseTask::beginLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup context 
)
protectedvirtual

To reset the MEs.

Reimplemented from edm::EDAnalyzer.

Definition at line 88 of file DTNoiseTask.cc.

89  {
90 
91  LogVerbatim("DTNoiseTask") <<"[DTNoiseTask]: Begin of LS transition"<<endl;
92 
93 }
void DTNoiseTask::beginRun ( const edm::Run run,
const edm::EventSetup setup 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 266 of file DTNoiseTask.cc.

References DQMStore::bookFloat(), bookHistos(), dbe, doTimeBoxHistos, dtGeom, edm::EventSetup::get(), nEventMonitor, DTTimeUnits::ns, DQMStore::setCurrentFolder(), and tTrigStMap.

266  {
267 
268  LogVerbatim("DTNoiseTask") <<"[DTNoiseTask]: Begin of run"<<endl;
269 
270  // tTrig Map
271  edm::ESHandle<DTTtrig> tTrigMap;
272  setup.get<DTTtrigRcd>().get(tTrigMap);
273 
274  // get the geometry
275  setup.get<MuonGeometryRecord>().get(dtGeom);
276 
277  dbe->setCurrentFolder("DT/EventInfo/Counters");
278  nEventMonitor = dbe->bookFloat("nProcessedEventsNoise");
279 
280  // Loop over all the chambers
281  vector<DTChamber*>::const_iterator ch_it = dtGeom->chambers().begin();
282  vector<DTChamber*>::const_iterator ch_end = dtGeom->chambers().end();
283  for (; ch_it != ch_end; ++ch_it) {
284  DTChamberId chId = (*ch_it)->id();
285  // histo booking
286  bookHistos(chId);
287  vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
288  vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
289  // Loop over the SLs
290  for(; sl_it != sl_end; ++sl_it) {
291  DTSuperLayerId slId = (*sl_it)->id();
292  if(doTimeBoxHistos)
293  bookHistos(slId);
294  float tTrig, tTrigRMS, kFactor;
295  tTrigMap->get(slId, tTrig, tTrigRMS,kFactor,DTTimeUnits::ns);
296  // tTrig mapping per station
297  // check that the ttrig is the lowest of the 3 SLs
298  if(tTrigStMap.find(chId)==tTrigStMap.end() ||
299  (tTrigStMap.find(chId)!=tTrigStMap.end() && tTrig < tTrigStMap[chId]))
300  tTrigStMap[chId] = tTrig;
301  }
302  }
303 
304 
305 }
MonitorElement * nEventMonitor
Definition: DTNoiseTask.h:89
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:654
edm::ESHandle< DTGeometry > dtGeom
Definition: DTNoiseTask.h:75
const T & get() const
Definition: EventSetup.h:55
std::map< DTChamberId, double > tTrigStMap
Definition: DTNoiseTask.h:78
bool doTimeBoxHistos
Definition: DTNoiseTask.h:68
DQMStore * dbe
Definition: DTNoiseTask.h:74
void bookHistos(DTChamberId chId)
Definition: DTNoiseTask.cc:181
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
void DTNoiseTask::bookHistos ( DTChamberId  chId)
private

Definition at line 181 of file DTNoiseTask.cc.

References DQMStore::book2D(), dbe, dtGeom, noiseHistos, DTChamberId::sector(), DQMStore::setCurrentFolder(), DTChamberId::station(), relativeConstraints::station, DTChamber::superLayers(), and DTChamberId::wheel().

Referenced by beginRun().

181  {
182 
183  // set the folder
184  stringstream wheel; wheel << chId.wheel();
185  stringstream station; station << chId.station();
186  stringstream sector; sector << chId.sector();
187  dbe->setCurrentFolder("DT/05-Noise/Wheel" + wheel.str() +
188 // "/Station" + station.str() +
189  "/Sector" + sector.str());
190 
191  // Build the histo name
192  string histoName = string("NoiseRate")
193  + "_W" + wheel.str()
194  + "_St" + station.str()
195  + "_Sec" + sector.str() ;
196 
197  LogVerbatim("DTNoiseTask") << "[DTNoiseTask]: booking chamber histo:"<<endl;
198  LogVerbatim("DTNoiseTask") << " folder "<< "DT/05-Noise/Wheel" + wheel.str() +
199 // "/Station" + station.str() +
200  "/Sector" + sector.str() + "/"<<endl;
201  LogVerbatim("DTNoiseTask") << " histoName "<<histoName<<endl;
202 
203  // Get the chamber from the geometry
204  int nWires_max = 0;
205  const DTChamber* dtchamber = dtGeom->chamber(chId);
206  const vector<const DTSuperLayer*> superlayers = dtchamber->superLayers();
207 
208  // Loop over layers and find the max # of wires
209  for(vector<const DTSuperLayer*>::const_iterator sl = superlayers.begin();
210  sl != superlayers.end(); ++sl) { // loop over SLs
211  vector<const DTLayer*> layers = (*sl)->layers();
212  for(vector<const DTLayer*>::const_iterator lay = layers.begin();
213  lay != layers.end(); ++lay) { // loop over layers
214  int nWires = (*lay)->specificTopology().channels();
215  if(nWires > nWires_max) nWires_max = nWires;
216  }
217  }
218 
219  noiseHistos[chId] = dbe->book2D(histoName,"Noise rate (Hz) per channel", nWires_max,1, nWires_max+1,12,1,13);
220  noiseHistos[chId]->setAxisTitle("wire number",1);
221  noiseHistos[chId]->setBinLabel(1,"SL1-L1",2);
222  noiseHistos[chId]->setBinLabel(2,"SL1-L2",2);
223  noiseHistos[chId]->setBinLabel(3,"SL1-L3",2);
224  noiseHistos[chId]->setBinLabel(4,"SL1-L4",2);
225  noiseHistos[chId]->setBinLabel(5,"SL2-L1",2);
226  noiseHistos[chId]->setBinLabel(6,"SL2-L2",2);
227  noiseHistos[chId]->setBinLabel(7,"SL2-L3",2);
228  noiseHistos[chId]->setBinLabel(8,"SL2-L4",2);
229  noiseHistos[chId]->setBinLabel(9,"SL3-L1",2);
230  noiseHistos[chId]->setBinLabel(10,"SL3-L2",2);
231  noiseHistos[chId]->setBinLabel(11,"SL3-L3",2);
232  noiseHistos[chId]->setBinLabel(12,"SL3-L4",2);
233 
234 }
edm::ESHandle< DTGeometry > dtGeom
Definition: DTNoiseTask.h:75
const std::vector< const DTSuperLayer * > & superLayers() const
Return the superlayers in the chamber.
Definition: DTChamber.cc:62
int sector() const
Definition: DTChamberId.h:63
std::map< DTChamberId, MonitorElement * > noiseHistos
Definition: DTNoiseTask.h:81
DQMStore * dbe
Definition: DTNoiseTask.h:74
int station() const
Return the station number.
Definition: DTChamberId.h:53
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:845
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:47
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
void DTNoiseTask::bookHistos ( DTSuperLayerId  slId)
private

Definition at line 237 of file DTNoiseTask.cc.

References DQMStore::book1D(), DTSuperLayerId::chamberId(), dbe, DTChamberId::sector(), DQMStore::setCurrentFolder(), DTChamberId::station(), relativeConstraints::station, DTSuperLayerId::superlayer(), tbHistos, and DTChamberId::wheel().

237  {
238 
239  // set the folder
240  stringstream wheel; wheel << slId.chamberId().wheel();
241  stringstream station; station << slId.chamberId().station();
242  stringstream sector; sector << slId.chamberId().sector();
243  stringstream superlayer; superlayer << slId.superlayer();
244  dbe->setCurrentFolder("DT/05-Noise/Wheel" + wheel.str() +
245  "/Station" + station.str() +
246  "/Sector" + sector.str());
247 
248  // Build the histo name
249  string histoName = string("TimeBox")
250  + "_W" + wheel.str()
251  + "_St" + station.str()
252  + "_Sec" + sector.str()
253  + "_SL" + superlayer.str();
254 
255  LogVerbatim("DTNoiseTask") <<"[DTNoiseTask]: booking SL histo:"<<endl;
256  LogVerbatim("DTNoiseTask") <<" folder "<< "DT/05-Noise/Wheel" + wheel.str() +
257  "/Station" + station.str() +
258  "/Sector" + sector.str() + "/" << endl;
259  LogVerbatim("DTNoiseTask") <<" histoName "<<histoName<<endl;
260 
261  tbHistos[slId] = dbe->book1D(histoName,"Time Box (TDC counts)", 1000, 0, 6000);
262 
263 }
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
DTChamberId chamberId() const
Return the corresponding ChamberId.
std::map< DTSuperLayerId, MonitorElement * > tbHistos
Definition: DTNoiseTask.h:87
int superlayer() const
Return the superlayer number (deprecated method name)
int sector() const
Definition: DTChamberId.h:63
DQMStore * dbe
Definition: DTNoiseTask.h:74
int station() const
Return the station number.
Definition: DTChamberId.h:53
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:47
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
void DTNoiseTask::endJob ( void  )
protectedvirtual

Endjob.

Reimplemented from edm::EDAnalyzer.

Definition at line 178 of file DTNoiseTask.cc.

178 {}
void DTNoiseTask::endLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup setup 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 307 of file DTNoiseTask.cc.

References alignCSCRings::e, evtNumber, mapEvt, noiseHistos, safeMargin, and tTrigStMap.

307  {
308  LogVerbatim("DTNoiseTask") << "[DTNoiseTask]: End LS, update rates in all histos" << endl;
309 
310  // update the rate of all histos (usefull for histos with few entries: they are not updated very often
311  for(map<DTChamberId, MonitorElement*>::const_iterator meAndChamber = noiseHistos.begin();
312  meAndChamber != noiseHistos.end(); ++meAndChamber) {
313  DTChamberId chId = (*meAndChamber).first;
314  TH2F* noise_root = (*meAndChamber).second->getTH2F();
315  double upperLimit = tTrigStMap[chId]-safeMargin;
316 
317  double normalization=0;
318  if(mapEvt.find(chId) != mapEvt.end()) {
319  LogVerbatim("DTNoiseTask") << " Ch: " << chId << " Last fill: # of events: " << mapEvt[chId] << endl;
320  normalization = 1e-9*upperLimit*mapEvt[chId];
321  // revert back to # of entries
322  noise_root->Scale(normalization);
323  }
324  //check that event analyzed != 0 might happen oline
325  if (evtNumber) {
326  // set the # of events analyzed until this update
327  LogVerbatim("DTNoiseTask") << " Update for events: " << evtNumber << endl;
328  mapEvt[chId] = evtNumber;
329  // update the rate
330  normalization = double( 1e-9*upperLimit*evtNumber);
331  noise_root->Scale(1./normalization);
332  }
333  }
334 }
std::map< DTChamberId, int > mapEvt
Definition: DTNoiseTask.h:84
double safeMargin
Definition: DTNoiseTask.h:92
std::map< DTChamberId, double > tTrigStMap
Definition: DTNoiseTask.h:78
std::map< DTChamberId, MonitorElement * > noiseHistos
Definition: DTNoiseTask.h:81

Member Data Documentation

DQMStore* DTNoiseTask::dbe
private

Definition at line 74 of file DTNoiseTask.h.

Referenced by beginRun(), bookHistos(), and DTNoiseTask().

bool DTNoiseTask::doSegmentVeto
private

Definition at line 72 of file DTNoiseTask.h.

Referenced by analyze(), and DTNoiseTask().

bool DTNoiseTask::doTimeBoxHistos
private

Definition at line 68 of file DTNoiseTask.h.

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

edm::InputTag DTNoiseTask::dtDigiLabel
private

Definition at line 64 of file DTNoiseTask.h.

Referenced by analyze(), and DTNoiseTask().

edm::ESHandle<DTGeometry> DTNoiseTask::dtGeom
private

Definition at line 75 of file DTNoiseTask.h.

Referenced by beginRun(), and bookHistos().

int DTNoiseTask::evtNumber
private

Definition at line 66 of file DTNoiseTask.h.

Referenced by analyze(), and endLuminosityBlock().

std::map<DTChamberId, int> DTNoiseTask::mapEvt
private

Definition at line 84 of file DTNoiseTask.h.

Referenced by analyze(), and endLuminosityBlock().

MonitorElement* DTNoiseTask::nEventMonitor
private

Definition at line 89 of file DTNoiseTask.h.

Referenced by analyze(), and beginRun().

std::map<DTChamberId, MonitorElement*> DTNoiseTask::noiseHistos
private

Definition at line 81 of file DTNoiseTask.h.

Referenced by analyze(), bookHistos(), and endLuminosityBlock().

double DTNoiseTask::safeMargin
private

Definition at line 92 of file DTNoiseTask.h.

Referenced by analyze(), DTNoiseTask(), and endLuminosityBlock().

std::map<DTSuperLayerId, MonitorElement*> DTNoiseTask::tbHistos
private

Definition at line 87 of file DTNoiseTask.h.

Referenced by analyze(), and bookHistos().

std::string DTNoiseTask::theRecHits4DLabel
private

Definition at line 70 of file DTNoiseTask.h.

Referenced by analyze(), and DTNoiseTask().

std::map<DTChamberId, double> DTNoiseTask::tTrigStMap
private

Definition at line 78 of file DTNoiseTask.h.

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