00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <DQM/DTMonitorModule/interface/DTDigiTask.h>
00011
00012
00013 #include <FWCore/Framework/interface/EventSetup.h>
00014
00015
00016 #include <DataFormats/DTDigi/interface/DTDigi.h>
00017 #include <DataFormats/DTDigi/interface/DTDigiCollection.h>
00018 #include <DataFormats/MuonDetId/interface/DTLayerId.h>
00019 #include <DataFormats/MuonDetId/interface/DTChamberId.h>
00020 #include "CondFormats/DataRecord/interface/DTReadOutMappingRcd.h"
00021
00022
00023 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00024 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00025 #include "Geometry/DTGeometry/interface/DTLayer.h"
00026 #include "Geometry/DTGeometry/interface/DTTopology.h"
00027
00028
00029 #include <CondFormats/DTObjects/interface/DTT0.h>
00030 #include <CondFormats/DataRecord/interface/DTT0Rcd.h>
00031 #include <CondFormats/DTObjects/interface/DTTtrig.h>
00032 #include <CondFormats/DataRecord/interface/DTTtrigRcd.h>
00033
00034 #include "CondFormats/DataRecord/interface/DTStatusFlagRcd.h"
00035 #include "CondFormats/DTObjects/interface/DTStatusFlag.h"
00036
00037 #include "DQMServices/Core/interface/DQMStore.h"
00038 #include "DQMServices/Core/interface/MonitorElement.h"
00039 #include "FWCore/ServiceRegistry/interface/Service.h"
00040
00041 #include <sstream>
00042 #include <math.h>
00043
00044 using namespace edm;
00045 using namespace std;
00046
00047
00048
00049
00050 DTDigiTask::DTDigiTask(const edm::ParameterSet& ps){
00051
00052 LogTrace("DTDQM|DTMonitorModule|DTDigiTask") << "[DTDigiTask]: Constructor" << endl;
00053
00054
00055 dtDigiLabel = ps.getParameter<InputTag>("dtDigiLabel");
00056
00057 maxTDCHits = ps.getUntrackedParameter<int>("maxTDCHitsPerChamber",30000);
00058
00059 readTTrigDB = ps.getUntrackedParameter<bool>("readDB", false);
00060
00061 subtractT0 = ps.getParameter<bool>("performPerWireT0Calibration");
00062
00063 defaultTmax = ps.getParameter<int>("defaultTmax");
00064
00065 doStaticBooking = ps.getUntrackedParameter<bool>("staticBooking", true);
00066
00067
00068 isLocalRun = ps.getUntrackedParameter<bool>("localrun", true);
00069 if (!isLocalRun) {
00070 ltcDigiCollectionTag = ps.getParameter<edm::InputTag>("ltcDigiCollectionTag");
00071 }
00072
00073
00074 resetCycle = ps.getUntrackedParameter<int>("ResetCycle", 3);
00075
00076 checkNoisyChannels = ps.getUntrackedParameter<bool>("checkNoisyChannels",false);
00077
00078 defaultTTrig = ps.getParameter<int>("defaultTtrig");
00079 inTimeHitsLowerBound = ps.getParameter<int>("inTimeHitsLowerBound");
00080 inTimeHitsUpperBound = ps.getParameter<int>("inTimeHitsUpperBound");
00081 timeBoxGranularity = ps.getUntrackedParameter<int>("timeBoxGranularity",4);
00082 maxTDCCounts = ps.getUntrackedParameter<int>("maxTDCCounts", 6400);
00083
00084 doAllHitsOccupancies = ps.getUntrackedParameter<bool>("doAllHitsOccupancies", true);
00085 doNoiseOccupancies = ps.getUntrackedParameter<bool>("doNoiseOccupancies", false);
00086 doInTimeOccupancies = ps.getUntrackedParameter<bool>("doInTimeOccupancies", false);
00087
00088
00089 tpMode = ps.getUntrackedParameter<bool>("testPulseMode", false);
00090
00091
00092 filterSyncNoise = ps.getUntrackedParameter<bool>("filterSyncNoise", false);
00093
00094 lookForSyncNoise = ps.getUntrackedParameter<bool>("lookForSyncNoise", false);
00095
00096 doLayerTimeBoxes = ps.getUntrackedParameter<bool>("doLayerTimeBoxes", false);
00097
00098 dbe = edm::Service<DQMStore>().operator->();
00099
00100 syncNumTot = 0;
00101 syncNum = 0;
00102
00103 }
00104
00105
00106
00107
00108 DTDigiTask::~DTDigiTask(){
00109 LogTrace("DTDQM|DTMonitorModule|DTDigiTask") << "DTDigiTask: analyzed " << nevents << " events" << endl;
00110
00111 }
00112
00113
00114
00115
00116 void DTDigiTask::endJob(){
00117 LogTrace("DTDQM|DTMonitorModule|DTDigiTask") <<"[DTDigiTask] endjob called!"<<endl;
00118
00119 }
00120
00121
00122
00123
00124 void DTDigiTask::beginJob(){
00125 LogTrace("DTDQM|DTMonitorModule|DTDigiTask") <<"[DTDigiTask]: BeginJob"<<endl;
00126
00127 nevents = 0;
00128 }
00129
00130
00131 void DTDigiTask::beginRun(const edm::Run& run, const edm::EventSetup& context) {
00132 LogTrace("DTDQM|DTMonitorModule|DTDigiTask") << "[DTDigiTask]: begin run" << endl;
00133
00134
00135 context.get<MuonGeometryRecord>().get(muonGeom);
00136
00137
00138 context.get<DTReadOutMappingRcd>().get(mapping);
00139
00140
00141 if (readTTrigDB)
00142 context.get<DTTtrigRcd>().get(tTrigMap);
00143
00144 if (subtractT0)
00145 context.get<DTT0Rcd>().get(t0Map);
00146
00147 tMax = defaultTmax;
00148
00149
00150 if(doStaticBooking) {
00151
00152 dbe->setCurrentFolder("DT/EventInfo/Counters");
00153 nEventMonitor = dbe->bookFloat(tpMode ? "nProcessedEventsDigiTP" : "nProcessedEventsDigi" );
00154 dbe->setCurrentFolder(topFolder());
00155 for(int wh = -2; wh <= 2; ++wh) {
00156 if(doAllHitsOccupancies) bookHistos(wh,string("Occupancies"),"OccupancyAllHits");
00157 if(doNoiseOccupancies) bookHistos(wh,string("Occupancies"),"OccupancyNoiseHits");
00158 if(doInTimeOccupancies) bookHistos(wh,string("Occupancies"),"OccupancyInTimeHits");
00159
00160 if(lookForSyncNoise || filterSyncNoise) {
00161 bookHistos(wh,string("SynchNoise"),"SyncNoiseEvents");
00162 bookHistos(wh,string("SynchNoise"),"SyncNoiseChambs");
00163 }
00164
00165 for(int st = 1; st <= 4; ++st) {
00166 for(int sect = 1; sect <= 14; ++sect) {
00167 if((sect == 13 || sect == 14) && st != 4) continue;
00168
00169 const DTChamberId dtChId(wh,st,sect);
00170
00171
00172 if (doAllHitsOccupancies) {
00173 bookHistos(dtChId,string("Occupancies"),"OccupancyAllHits_perCh");
00174
00175 channelsMap(dtChId, "OccupancyAllHits_perCh");
00176 }
00177 if(doNoiseOccupancies)
00178 bookHistos(dtChId,string("Occupancies"),"OccupancyNoise_perCh");
00179 if(doInTimeOccupancies)
00180 bookHistos(dtChId,string("Occupancies"),"OccupancyInTimeHits_perCh");
00181
00182
00183
00184
00185 for(int sl = 1; sl <= 3; ++sl) {
00186 if(st == 4 && sl == 2) continue;
00187 const DTSuperLayerId dtSLId(wh,st,sect,sl);
00188 if(isLocalRun) {
00189 bookHistos(dtSLId,string("TimeBoxes"),"TimeBox");
00190 } else {
00191
00192 bookHistos(dtSLId,string("TimeBoxes"),"TimeBoxDTonly");
00193 bookHistos(dtSLId,string("TimeBoxes"),"TimeBoxNoDT");
00194 bookHistos(dtSLId,string("TimeBoxes"),"TimeBoxDTalso");
00195 }
00196 }
00197 }
00198 }
00199 }
00200 }
00201 }
00202
00203
00204
00205
00206 void DTDigiTask::beginLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00207
00208 LogTrace("DTDQM|DTMonitorModule|DTDigiTask") << "[DTDigiTask]: Begin of LS transition" << endl;
00209
00210
00211 int lumiBlock = lumiSeg.id().luminosityBlock();
00212 if(lumiBlock % resetCycle == 0) {
00213 LogVerbatim("DTDQM|DTMonitorModule|DTDigiTask")
00214 <<"[DTDigiTask]: Reset at the LS transition : "
00215 << lumiBlock << endl;
00216
00217 map<string,map<uint32_t,MonitorElement*> >::const_iterator histosIt = digiHistos.begin();
00218 map<string,map<uint32_t,MonitorElement*> >::const_iterator histosEnd = digiHistos.end();
00219 for(;histosIt != histosEnd ; ++histosIt) {
00220 map<uint32_t,MonitorElement*>::const_iterator histoIt = (*histosIt).second.begin();
00221 map<uint32_t,MonitorElement*>::const_iterator histoEnd = (*histosIt).second.end();
00222 for(;histoIt != histoEnd; ++histoIt) { (*histoIt).second->Reset(); }
00223 }
00224
00225
00226 for(int wh=-2; wh<=2; wh++) {
00227 for(int sect=1; sect<=14; sect++) {
00228 for(int st=1; st<=4; st++) {
00229 if( (sect == 13 || sect == 14) && st != 4 ) {continue;}
00230 const DTChamberId dtChId(wh,st,sect);
00231 channelsMap(dtChId, "OccupancyAllHits_perCh");
00232 }
00233 }
00234 }
00235
00236
00237 map<string,map<int,MonitorElement*> >::const_iterator whHistosIt = wheelHistos.begin();
00238 map<string,map<int,MonitorElement*> >::const_iterator whHistosEnd = wheelHistos.end();
00239 for(; whHistosIt != whHistosEnd ; ++whHistosIt) {
00240 if ((*whHistosIt).first.find("Sync") == string::npos) {
00241 map<int,MonitorElement*>::const_iterator histoIt = (*whHistosIt).second.begin();
00242 map<int,MonitorElement*>::const_iterator histoEnd = (*whHistosIt).second.end();
00243 for(;histoIt != histoEnd; ++histoIt) { (*histoIt).second->Reset(); }
00244 }
00245 }
00246 }
00247
00248 }
00249
00250
00251
00252
00253 void DTDigiTask::bookHistos(const DTSuperLayerId& dtSL, string folder, string histoTag) {
00254
00255 stringstream wheel; wheel << dtSL.wheel();
00256 stringstream station; station << dtSL.station();
00257 stringstream sector; sector << dtSL.sector();
00258 stringstream superLayer; superLayer << dtSL.superlayer();
00259 dbe->setCurrentFolder(topFolder() + "Wheel" + wheel.str() +
00260 "/Sector" + sector.str() +
00261 "/Station" + station.str());
00262
00263
00264 string histoName = histoTag
00265 + "_W" + wheel.str()
00266 + "_St" + station.str()
00267 + "_Sec" + sector.str()
00268 + "_SL" + superLayer.str();
00269
00270 LogTrace("DTDQM|DTMonitorModule|DTDigiTask")
00271 << "[DTDigiTask]: booking SL histo:" << histoName
00272 << " (tag: " << histoTag
00273 << ") folder: " << topFolder() + "Wheel" + wheel.str() +
00274 "/Station" + station.str() +
00275 "/Sector" + sector.str() + "/" + folder << endl;
00276
00277
00278
00279 if ( readTTrigDB )
00280 tTrigMap->get(dtSL, tTrig, tTrigRMS, kFactor, DTTimeUnits::counts);
00281 else tTrig = defaultTTrig;
00282
00283
00284 if ( folder == "TimeBoxes") {
00285 string histoTitle = histoName + " (TDC Counts)";
00286
00287 if (!readTTrigDB) {
00288 (digiHistos[histoTag])[dtSL.rawId()] =
00289 dbe->book1D(histoName,histoTitle, maxTDCCounts/timeBoxGranularity, 0, maxTDCCounts);
00290 if(doLayerTimeBoxes) {
00291 for(int layer = 1; layer != 5; ++layer) {
00292 DTLayerId layerId(dtSL, layer);
00293 stringstream layerHistoName; layerHistoName << histoName << "_L" << layer;
00294 (digiHistos[histoTag])[layerId.rawId()] =
00295 dbe->book1D(layerHistoName.str(),layerHistoName.str(), maxTDCCounts/timeBoxGranularity, 0, maxTDCCounts);
00296 }
00297 }
00298 }
00299 else {
00300 (digiHistos[histoTag])[dtSL.rawId()] =
00301 dbe->book1D(histoName,histoTitle, 3*tMax/timeBoxGranularity, tTrig-tMax, tTrig+2*tMax);
00302 if(doLayerTimeBoxes) {
00303
00304 for(int layer = 1; layer != 5; ++layer) {
00305 DTLayerId layerId(dtSL, layer);
00306 stringstream layerHistoName; layerHistoName << histoName << "_L" << layer;
00307 (digiHistos[histoTag])[layerId.rawId()] =
00308 dbe->book1D(layerHistoName.str(),layerHistoName.str(), 3*tMax/timeBoxGranularity, tTrig-tMax, tTrig+2*tMax);
00309 }
00310 }
00311 }
00312 }
00313
00314 if ( folder == "CathodPhotoPeaks" ) {
00315 dbe->setCurrentFolder(topFolder() + "Wheel" + wheel.str() +
00316 "/Sector" + sector.str() +
00317 "/Station" + station.str() + "/" + folder);
00318 (digiHistos[histoTag])[dtSL.rawId()] = dbe->book1D(histoName,histoName,500,0,1000);
00319 }
00320
00321 }
00322
00323
00324
00325
00326 void DTDigiTask::bookHistos(const DTChamberId& dtCh, string folder, string histoTag) {
00327
00328 stringstream wheel; wheel << dtCh.wheel();
00329 stringstream station; station << dtCh.station();
00330 stringstream sector; sector << dtCh.sector();
00331 dbe->setCurrentFolder(topFolder() + "Wheel" + wheel.str() +
00332 "/Sector" + sector.str() +
00333 "/Station" + station.str());
00334
00335
00336 string histoName = histoTag
00337 + "_W" + wheel.str()
00338 + "_St" + station.str()
00339 + "_Sec" + sector.str();
00340
00341
00342 LogTrace("DTDQM|DTMonitorModule|DTDigiTask")
00343 << "[DTDigiTask]: booking chamber histo:"
00344 << " (tag: " << histoTag
00345 << ") folder: " << topFolder() + "Wheel" + wheel.str() +
00346 "/Station" + station.str() +
00347 "/Sector" + sector.str() << endl;
00348
00349
00350 if (folder == "Occupancies") {
00351
00352 const DTChamber* dtchamber = muonGeom->chamber(dtCh);
00353 const std::vector<const DTSuperLayer*> dtSupLylist = dtchamber->superLayers();
00354 std::vector<const DTSuperLayer*>::const_iterator suly = dtSupLylist.begin();
00355 std::vector<const DTSuperLayer*>::const_iterator sulyend = dtSupLylist.end();
00356
00357 int nWires = 0;
00358 int firstWire = 0;
00359 int nWires_max = 0;
00360
00361 while(suly != sulyend) {
00362 const std::vector<const DTLayer*> dtLyList = (*suly)->layers();
00363 std::vector<const DTLayer*>::const_iterator ly = dtLyList.begin();
00364 std::vector<const DTLayer*>::const_iterator lyend = dtLyList.end();
00365 stringstream superLayer; superLayer << (*suly)->id().superlayer();
00366
00367 while(ly != lyend) {
00368 nWires = muonGeom->layer((*ly)->id())->specificTopology().channels();
00369 firstWire = muonGeom->layer((*ly)->id())->specificTopology().firstChannel();
00370 stringstream layer; layer << (*ly)->id().layer();
00371 string histoName_layer = histoName + "_SL" + superLayer.str() + "_L" + layer.str();
00372 if(histoTag == "OccupancyAllHits_perL"
00373 || histoTag == "OccupancyNoise_perL"
00374 || histoTag == "OccupancyInTimeHits_perL")
00375 (digiHistos[histoTag])[(*ly)->id().rawId()] = dbe->book1D(histoName_layer,histoName_layer,nWires,firstWire,nWires+firstWire);
00376 ++ly;
00377 if((nWires+firstWire) > nWires_max) nWires_max = (nWires+firstWire);
00378
00379 }
00380 ++suly;
00381 }
00382
00383 if(histoTag != "OccupancyAllHits_perL"
00384 && histoTag != "OccupancyNoise_perL"
00385 && histoTag != "OccupancyInTimeHits_perL"){
00386
00387 string histoTitle = histoName;
00388 if(!readTTrigDB && histoTag == "OccupancyInTimeHits_perCh") {
00389 stringstream title;
00390 int inTimeHitsLowerBoundCorr = int(round(defaultTTrig)) - inTimeHitsLowerBound;
00391 int inTimeHitsUpperBoundCorr = int(round(defaultTTrig)) + defaultTmax + inTimeHitsUpperBound;
00392 title << "Occ. digis in time [" << inTimeHitsLowerBoundCorr << ", "
00393 << inTimeHitsUpperBoundCorr << "] (TDC counts)";
00394 histoTitle = title.str();
00395 }
00396 (digiHistos[histoTag])[dtCh.rawId()] = dbe->book2D(histoName,histoTitle,nWires_max,1,nWires_max+1,12,0,12);
00397
00398 for(int i=1;i<=12;i++) {
00399 if(i<5){
00400 stringstream layer;
00401 string layer_name;
00402 layer<<i;
00403 layer>>layer_name;
00404 string label="SL1: L"+layer_name;
00405 (digiHistos[histoTag])[dtCh.rawId()]->setBinLabel(i,label,2);
00406 }
00407 else if(i>4 && i<9){
00408 stringstream layer;
00409 string layer_name;
00410 layer<<(i-4);
00411 layer>>layer_name;
00412 string label="SL2: L"+layer_name;
00413 (digiHistos[histoTag])[dtCh.rawId()]->setBinLabel(i,label,2);
00414 }
00415 else if(i>8 && i<13){
00416 stringstream layer;
00417 string layer_name;
00418 layer<<(i-8);
00419 layer>>layer_name;
00420 string label="SL3: L"+layer_name;
00421 (digiHistos[histoTag])[dtCh.rawId()]->setBinLabel(i,label,2);
00422 }
00423 }
00424 }
00425 }
00426 }
00427
00428
00429
00430
00431 void DTDigiTask::bookHistos(const int wheelId, string folder, string histoTag) {
00432
00433 stringstream wheel; wheel << wheelId;
00434
00435
00436
00437 string histoName = histoTag + "_W" + wheel.str();
00438
00439
00440 LogTrace("DTDQM|DTMonitorModule|DTDigiTask")
00441 << "[DTDigiTask]: booking wheel histo:" << histoName
00442 << " (tag: " << histoTag
00443 << ") folder: " << topFolder() + "Wheel" + wheel.str() + "/" <<endl;
00444
00445 if(folder == "Occupancies") {
00446 dbe->setCurrentFolder(topFolder() + "Wheel" + wheel.str());
00447 string histoTitle = "# of digis per chamber WHEEL: "+wheel.str();
00448 (wheelHistos[histoTag])[wheelId] = dbe->book2D(histoName,histoTitle,12,1,13,4,1,5);
00449 (wheelHistos[histoTag])[wheelId]->setBinLabel(1,"MB1",2);
00450 (wheelHistos[histoTag])[wheelId]->setBinLabel(2,"MB2",2);
00451 (wheelHistos[histoTag])[wheelId]->setBinLabel(3,"MB3",2);
00452 (wheelHistos[histoTag])[wheelId]->setBinLabel(4,"MB4",2);
00453 (wheelHistos[histoTag])[wheelId]->setAxisTitle("sector",1);
00454 } else if(folder == "SynchNoise") {
00455 dbe->setCurrentFolder("DT/05-Noise/SynchNoise");
00456 if (histoTag== "SyncNoiseEvents") {
00457 string histoTitle = "# of Syncronous-noise events WHEEL: "+wheel.str();
00458 (wheelHistos[histoTag])[wheelId] = dbe->book2D(histoName,histoTitle,12,1,13,4,1,5);
00459 (wheelHistos[histoTag])[wheelId]->setBinLabel(1,"MB1",2);
00460 (wheelHistos[histoTag])[wheelId]->setBinLabel(2,"MB2",2);
00461 (wheelHistos[histoTag])[wheelId]->setBinLabel(3,"MB3",2);
00462 (wheelHistos[histoTag])[wheelId]->setBinLabel(4,"MB4",2);
00463 (wheelHistos[histoTag])[wheelId]->setAxisTitle("sector",1);
00464 } else if (histoTag== "SyncNoiseChambs") {
00465 string histoTitle = "# of Synchornous-noise chamb per evt. WHEEL: "+wheel.str();
00466 (wheelHistos[histoTag])[wheelId] = dbe->book1D(histoName,histoTitle,50,0.5,50.5);
00467 (wheelHistos[histoTag])[wheelId]->setAxisTitle("# of noisy chambs.",1);
00468 (wheelHistos[histoTag])[wheelId]->setAxisTitle("# of evts.",2);
00469 }
00470 }
00471
00472 }
00473
00474
00475
00476
00477 void DTDigiTask::analyze(const edm::Event& event, const edm::EventSetup& c) {
00478 nevents++;
00479 nEventMonitor->Fill(nevents);
00480 if (nevents%1000 == 0) {
00481 LogTrace("DTDQM|DTMonitorModule|DTDigiTask") << "[DTDigiTask] Analyze #Run: " << event.id().run()
00482 << " #Event: " << event.id().event() << endl;
00483 }
00484
00485
00486
00487
00488 edm::Handle<DTDigiCollection> dtdigis;
00489 event.getByLabel(dtDigiLabel, dtdigis);
00490
00491
00492 if (!isLocalRun) event.getByLabel(ltcDigiCollectionTag, ltcdigis);
00493
00494
00495 ESHandle<DTStatusFlag> statusMap;
00496 if(checkNoisyChannels) {
00497
00498 c.get<DTStatusFlagRcd>().get(statusMap);
00499 }
00500
00501 string histoTag;
00502
00503
00504
00505 if(dtdigis->begin() == dtdigis->end()) {
00506 LogTrace("DTDQM|DTMonitorModule|DTDigiTask") << "Event " << nevents << " empty." << endl;
00507 }
00508
00509 if (lookForSyncNoise || filterSyncNoise) {
00510
00511 DTDigiCollection::DigiRangeIterator dtLayerId_It;
00512 for (dtLayerId_It=dtdigis->begin(); dtLayerId_It!=dtdigis->end(); dtLayerId_It++) {
00513 DTChamberId chId = ((*dtLayerId_It).first).chamberId();
00514 if(hitMap.find(chId) == hitMap.end()) {
00515 hitMap[chId] = 0;
00516 }
00517 hitMap[chId] += (((*dtLayerId_It).second).second - ((*dtLayerId_It).second).first);
00518 }
00519
00520
00521
00522
00523 map<DTChamberId,int>::const_iterator hitMapIt = hitMap.begin();
00524 map<DTChamberId,int>::const_iterator hitMapEnd = hitMap.end();
00525
00526 map<int,int> chMap;
00527
00528 for (; hitMapIt != hitMapEnd; ++hitMapIt) {
00529 if((hitMapIt->second) > maxTDCHits) {
00530
00531 DTChamberId chId = hitMapIt->first;
00532 int wh = chId.wheel();
00533
00534 LogTrace("DTDQM|DTMonitorModule|DTDigiTask") << "[DTDigiTask] Synch noise in chamber: " << chId
00535 << " with # digis: " << hitMapIt->second << endl;
00536
00537 if(chMap.find(wh) == chMap.end()) { chMap[wh] = 0; }
00538 chMap[wh]++ ;
00539
00540 syncNoisyChambers.insert(chId);
00541
00542 wheelHistos["SyncNoiseEvents"][wh]->Fill(chId.sector(),chId.station());
00543
00544
00545
00546
00547
00548
00549
00550
00551 }
00552 }
00553
00554
00555 map<int,int>::const_iterator chMapIt = chMap.begin();
00556 map<int,int>::const_iterator chMapEnd = chMap.end();
00557 for (; chMapIt != chMapEnd; ++chMapIt) {
00558 wheelHistos["SyncNoiseChambs"][(*chMapIt).first]->Fill((*chMapIt).second);
00559 }
00560
00561
00562 hitMap.clear();
00563
00564 if (syncNoisyChambers.size() != 0) {
00565 LogVerbatim("DTDQM|DTMonitorModule|DTDigiTask") << "[DTDigiTask] Synch Noise in event: " << nevents;
00566 if(filterSyncNoise) LogVerbatim("DTDQM|DTMonitorModule|DTDigiTask") << "\tnoisy time-boxes and occupancy will not be filled!" << endl;
00567 syncNumTot++;
00568 syncNum++;
00569 }
00570
00571
00572 if (syncNoisyChambers.size() > 3) {
00573 time_t eventTime = time_t(event.time().value()>>32);
00574
00575 LogVerbatim("DTDQM|DTMonitorModule|DTDigiTask|DTSynchNoise")
00576 << "[DTDigiTask] At least 4 Synch Noisy chambers in Run : " << event.id().run()
00577 << " Lumi : " << event.id().luminosityBlock()
00578 << " Event : " << event.id().event()
00579 << " at time : " << ctime(&eventTime) << endl;
00580
00581 set<DTChamberId>::const_iterator chIt = syncNoisyChambers.begin();
00582 set<DTChamberId>::const_iterator chEnd = syncNoisyChambers.end();
00583
00584 stringstream synchNoisyCh;
00585 for (;chIt!=chEnd;++chIt) { synchNoisyCh << " " << (*chIt); }
00586 LogVerbatim("DTDQM|DTMonitorModule|DTDigiTask|DTSynchNoise") <<
00587 "[DTDigiTask] Chamber List :" << synchNoisyCh.str() << endl;
00588
00589 }
00590
00591
00592 if (nevents%1000 == 0) {
00593 LogVerbatim("DTDQM|DTMonitorModule|DTDigiTask") << (syncNumTot*100./nevents) << "% sync noise events since the beginning \n"
00594 << (syncNum*0.1) << "% sync noise events in the last 1000 events " << endl;
00595 syncNum = 0;
00596 }
00597 }
00598
00599 bool isSyncNoisy = false;
00600
00601 DTDigiCollection::DigiRangeIterator dtLayerId_It;
00602 for (dtLayerId_It=dtdigis->begin(); dtLayerId_It!=dtdigis->end(); ++dtLayerId_It) {
00603 isSyncNoisy = false;
00604
00605 if (filterSyncNoise) {
00606 DTChamberId chId = ((*dtLayerId_It).first).chamberId();
00607 if(syncNoisyChambers.find(chId) != syncNoisyChambers.end()) {
00608 isSyncNoisy = true;
00609 }
00610 }
00611
00612 for (DTDigiCollection::const_iterator digiIt = ((*dtLayerId_It).second).first;
00613 digiIt!=((*dtLayerId_It).second).second; ++digiIt) {
00614
00615 bool isNoisy = false;
00616 bool isFEMasked = false;
00617 bool isTDCMasked = false;
00618 bool isTrigMask = false;
00619 bool isDead = false;
00620 bool isNohv = false;
00621 if(checkNoisyChannels) {
00622 const DTWireId wireId(((*dtLayerId_It).first), (*digiIt).wire());
00623 statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
00624 }
00625
00626
00627
00628
00629 const DTSuperLayerId dtSLId = ((*dtLayerId_It).first).superlayerId();
00630 uint32_t indexSL = dtSLId.rawId();
00631 const DTChamberId dtChId = dtSLId.chamberId();
00632 uint32_t indexCh = dtChId.rawId();
00633 int layer_number=((*dtLayerId_It).first).layer();
00634 int superlayer_number=dtSLId.superlayer();
00635
00636
00637
00638 if (readTTrigDB)
00639 tTrigMap->get( ((*dtLayerId_It).first).superlayerId(),
00640 tTrig, tTrigRMS, kFactor, DTTimeUnits::counts);
00641 else tTrig = defaultTTrig;
00642
00643 int inTimeHitsLowerBoundCorr = int(round(tTrig)) - inTimeHitsLowerBound;
00644 int inTimeHitsUpperBoundCorr = int(round(tTrig)) + tMax + inTimeHitsUpperBound;
00645
00646 float t0; float t0RMS;
00647 int tdcTime = (*digiIt).countsTDC();
00648
00649 if (subtractT0) {
00650 const DTWireId dtWireId(((*dtLayerId_It).first), (*digiIt).wire());
00651
00652 t0Map->get(dtWireId, t0, t0RMS, DTTimeUnits::counts) ;
00653 tdcTime += int(round(t0));
00654 }
00655
00656
00657
00658
00659
00660 if (( !isNoisy ) && (!isSyncNoisy)) {
00661
00662 histoTag = "TimeBox" + triggerSource();
00663 if (digiHistos[histoTag].find(indexSL) == digiHistos[histoTag].end())
00664 bookHistos( dtSLId, string("TimeBoxes"), histoTag );
00665 (digiHistos.find(histoTag)->second).find(indexSL)->second->Fill(tdcTime);
00666 if(doLayerTimeBoxes)
00667 (digiHistos.find(histoTag)->second).find((*dtLayerId_It).first.rawId())->second->Fill(tdcTime);
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681 }
00682
00683
00684 if (!isSyncNoisy) {
00685
00686 if (doAllHitsOccupancies) {
00687
00688 histoTag = "OccupancyAllHits_perCh";
00689 map<uint32_t, MonitorElement*>::const_iterator mappedHisto =
00690 digiHistos[histoTag].find(indexCh);
00691 if (mappedHisto == digiHistos[histoTag].end()) {
00692 bookHistos(dtChId, string("Occupancies"), histoTag);
00693 mappedHisto = digiHistos[histoTag].find(indexCh);
00694 }
00695 mappedHisto->second->Fill((*digiIt).wire(),(layer_number+(superlayer_number-1)*4)-1);
00696
00697
00698
00699 histoTag = "OccupancyAllHits";
00700 map<int, MonitorElement*>::const_iterator histoPerWheel =
00701 wheelHistos[histoTag].find(dtChId.wheel());
00702 if(histoPerWheel == wheelHistos[histoTag].end()) {
00703 bookHistos(dtChId.wheel(), string("Occupancies"), histoTag);
00704 histoPerWheel = wheelHistos[histoTag].find(dtChId.wheel());
00705 }
00706 histoPerWheel->second->Fill(dtChId.sector(),dtChId.station());
00707
00708
00709 }
00710
00711 if(doNoiseOccupancies) {
00712 if (tdcTime < inTimeHitsLowerBoundCorr ) {
00713
00714
00715
00716
00717 histoTag = "OccupancyNoise_perCh";
00718 map<uint32_t, MonitorElement*>::const_iterator mappedHisto =
00719 digiHistos[histoTag].find(indexCh);
00720 if(mappedHisto == digiHistos[histoTag].end()) {
00721 bookHistos(dtChId, string("Occupancies"), histoTag);
00722 mappedHisto = digiHistos[histoTag].find(indexCh);
00723 }
00724 mappedHisto->second->Fill((*digiIt).wire(),
00725 (layer_number+(superlayer_number-1)*4)-1);
00726
00727
00728 histoTag = "OccupancyNoise";
00729 map<int, MonitorElement*>::const_iterator histoPerWheel =
00730 wheelHistos[histoTag].find(dtChId.wheel());
00731 if(histoPerWheel == wheelHistos[histoTag].end()) {
00732 bookHistos(dtChId.wheel(), string("Occupancies"), histoTag);
00733 histoPerWheel = wheelHistos[histoTag].find(dtChId.wheel());
00734 }
00735 histoPerWheel->second->Fill(dtChId.sector(),dtChId.station());
00736
00737 }
00738 }
00739
00740 if(doInTimeOccupancies) {
00741 if (tdcTime > inTimeHitsLowerBoundCorr && tdcTime < inTimeHitsUpperBoundCorr) {
00742
00743
00744
00745 histoTag = "OccupancyInTimeHits_perCh";
00746 map<uint32_t, MonitorElement*>::const_iterator mappedHisto =
00747 digiHistos[histoTag].find(indexCh);
00748 if(mappedHisto == digiHistos[histoTag].end()) {
00749 bookHistos(dtChId, string("Occupancies"), histoTag);
00750 mappedHisto = digiHistos[histoTag].find(indexCh);
00751 }
00752 mappedHisto->second->Fill((*digiIt).wire(),
00753 (layer_number+(superlayer_number-1)*4)-1);
00754
00755
00756 histoTag = "OccupancyInTimeHits";
00757 map<int, MonitorElement*>::const_iterator histoPerWheel =
00758 wheelHistos[histoTag].find(dtChId.wheel());
00759 if(histoPerWheel == wheelHistos[histoTag].end()) {
00760 bookHistos(dtChId.wheel(), string("Occupancies"), histoTag);
00761 histoPerWheel = wheelHistos[histoTag].find(dtChId.wheel());
00762 }
00763 histoPerWheel->second->Fill(dtChId.sector(),dtChId.station());
00764
00765 }
00766 }
00767 }
00768 }
00769 }
00770
00771 syncNoisyChambers.clear();
00772 }
00773
00774
00775 string DTDigiTask::triggerSource() {
00776
00777 string l1ASource;
00778 if (isLocalRun)
00779 return l1ASource;
00780
00781 for (std::vector<LTCDigi>::const_iterator ltc_it = ltcdigis->begin(); ltc_it != ltcdigis->end(); ltc_it++){
00782 size_t otherTriggerSum=0;
00783 for (size_t i = 1; i < 6; i++)
00784 otherTriggerSum += size_t((*ltc_it).HasTriggered(i));
00785
00786 if ((*ltc_it).HasTriggered(0) && otherTriggerSum == 0)
00787 l1ASource = "DTonly";
00788 else if (!(*ltc_it).HasTriggered(0))
00789 l1ASource = "NoDT";
00790 else if ((*ltc_it).HasTriggered(0) && otherTriggerSum > 0)
00791 l1ASource = "DTalso";
00792 }
00793
00794 return l1ASource;
00795
00796 }
00797
00798
00799 string DTDigiTask::topFolder() const {
00800
00801 if(tpMode) return string("DT/10-TestPulses/");
00802 return string("DT/01-Digi/");
00803
00804 }
00805
00806
00807
00808
00809 void DTDigiTask::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& setup) {
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823 }
00824
00825 void DTDigiTask::channelsMap(const DTChamberId &dtCh, string histoTag) {
00826
00827
00828 int nWires_max = (digiHistos[histoTag])[dtCh.rawId()] -> getNbinsX();
00829
00830
00831 for(int sl=1; sl<=3; sl++) {
00832 for(int ly=1; ly<=4; ly++) {
00833 for(int ch=1; ch<=nWires_max; ch++) {
00834
00835 int dduId = -1, rosId = -1, robId = -1, tdcId = -1, channelId = -1;
00836 int realCh = mapping->geometryToReadOut(dtCh.wheel(),dtCh.station(),dtCh.sector(),sl,ly,ch,dduId,rosId,robId,tdcId,channelId);
00837
00838
00839 if( realCh ) {
00840
00841 int lybin = (4*sl - 4) + ly;
00842 (digiHistos[histoTag])[dtCh.rawId()] -> setBinContent(ch,lybin,-1.);
00843
00844 }
00845
00846 }
00847 }
00848 }
00849
00850 }