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
 
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)
 

Detailed Description

No description available.

Date:
2010/01/05 10:14:40
Revision:
1.7
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(), cmsCodeRules.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:90
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, edm::Event::getByLabel(), mapEvt, noiseHistos, safeMargin, edm::second(), tbHistos, theRecHits4DLabel, and tTrigStMap.

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

References bookHistos(), doTimeBoxHistos, dtGeom, edm::EventSetup::get(), DTTimeUnits::ns, and tTrigStMap.

264  {
265 
266  LogVerbatim("DTNoiseTask") <<"[DTNoiseTask]: Begin of run"<<endl;
267 
268  // tTrig Map
269  edm::ESHandle<DTTtrig> tTrigMap;
270  setup.get<DTTtrigRcd>().get(tTrigMap);
271 
272  // get the geometry
273  setup.get<MuonGeometryRecord>().get(dtGeom);
274 
275  // Loop over all the chambers
276  vector<DTChamber*>::const_iterator ch_it = dtGeom->chambers().begin();
277  vector<DTChamber*>::const_iterator ch_end = dtGeom->chambers().end();
278  for (; ch_it != ch_end; ++ch_it) {
279  DTChamberId chId = (*ch_it)->id();
280  // histo booking
281  bookHistos(chId);
282  vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
283  vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
284  // Loop over the SLs
285  for(; sl_it != sl_end; ++sl_it) {
286  DTSuperLayerId slId = (*sl_it)->id();
287  if(doTimeBoxHistos)
288  bookHistos(slId);
289  float tTrig, tTrigRMS, kFactor;
290  tTrigMap->get(slId, tTrig, tTrigRMS,kFactor,DTTimeUnits::ns);
291  // tTrig mapping per station
292  // check that the ttrig is the lowest of the 3 SLs
293  if(tTrigStMap.find(chId)==tTrigStMap.end() ||
294  (tTrigStMap.find(chId)!=tTrigStMap.end() && tTrig < tTrigStMap[chId]))
295  tTrigStMap[chId] = tTrig;
296  }
297  }
298 
299 
300 }
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
void bookHistos(DTChamberId chId)
Definition: DTNoiseTask.cc:179
void DTNoiseTask::bookHistos ( DTChamberId  chId)
private

Definition at line 179 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().

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

Definition at line 235 of file DTNoiseTask.cc.

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

235  {
236 
237  // set the folder
238  stringstream wheel; wheel << slId.chamberId().wheel();
239  stringstream station; station << slId.chamberId().station();
240  stringstream sector; sector << slId.chamberId().sector();
241  stringstream superlayer; superlayer << slId.superlayer();
242  dbe->setCurrentFolder("DT/05-Noise/Wheel" + wheel.str() +
243  "/Station" + station.str() +
244  "/Sector" + sector.str());
245 
246  // Build the histo name
247  string histoName = string("TimeBox")
248  + "_W" + wheel.str()
249  + "_St" + station.str()
250  + "_Sec" + sector.str()
251  + "_SL" + superlayer.str();
252 
253  LogVerbatim("DTNoiseTask") <<"[DTNoiseTask]: booking SL histo:"<<endl;
254  LogVerbatim("DTNoiseTask") <<" folder "<< "DT/05-Noise/Wheel" + wheel.str() +
255  "/Station" + station.str() +
256  "/Sector" + sector.str() + "/" << endl;
257  LogVerbatim("DTNoiseTask") <<" histoName "<<histoName<<endl;
258 
259  tbHistos[slId] = dbe->book1D(histoName,"Time Box (TDC counts)", 1000, 0, 6000);
260 
261 }
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:514
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:232
void DTNoiseTask::endJob ( void  )
protectedvirtual

Endjob.

Reimplemented from edm::EDAnalyzer.

Definition at line 176 of file DTNoiseTask.cc.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 302 of file DTNoiseTask.cc.

References evtNumber, mapEvt, noiseHistos, safeMargin, and tTrigStMap.

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

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 90 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().