00001 #include "DQM/HcalMonitorTasks/interface/HcalRawDataMonitor.h"
00002 #include "EventFilter/HcalRawToDigi/interface/HcalDCCHeader.h"
00003 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
00004 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
00005
00006
00007 HcalRawDataMonitor::HcalRawDataMonitor(const edm::ParameterSet& ps) {
00008 Online_ = ps.getParameter<bool>("online");
00009 mergeRuns_ = ps.getParameter<bool>("mergeRuns");
00010 enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup");
00011 debug_ = ps.getUntrackedParameter<int>("debug",0);
00012 prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder", "Hcal/");
00013 if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
00014 prefixME_.append("/");
00015 subdir_ = ps.getUntrackedParameter<std::string>("TaskFolder", "RawDataMonitor_Hcal/");
00016 if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
00017 subdir_.append("/");
00018 subdir_=prefixME_+subdir_;
00019 AllowedCalibTypes_ = ps.getUntrackedParameter<std::vector<int> > ("AllowedCalibTypes");
00020 skipOutOfOrderLS_ = ps.getUntrackedParameter<bool>("skipOutOfOrderLS",true);
00021 NLumiBlocks_ = ps.getUntrackedParameter<int>("NLumiBlocks",-1);
00022 makeDiagnostics_ = ps.getUntrackedParameter<bool>("makeDiagnostics",false);
00023
00024 FEDRawDataCollection_ = ps.getUntrackedParameter<edm::InputTag>("FEDRawDataCollection");
00025 digiLabel_ = ps.getUntrackedParameter<edm::InputTag>("digiLabel");
00026
00027 excludeHORing2_ = ps.getUntrackedParameter<bool>("excludeHORing2",false);
00028
00029
00030
00031
00032 meChann_DataIntegrityCheck_[0] =meCh_DataIntegrityFED00_;
00033 meChann_DataIntegrityCheck_[1] =meCh_DataIntegrityFED01_;
00034 meChann_DataIntegrityCheck_[2] =meCh_DataIntegrityFED02_;
00035 meChann_DataIntegrityCheck_[3] =meCh_DataIntegrityFED03_;
00036 meChann_DataIntegrityCheck_[4] =meCh_DataIntegrityFED04_;
00037 meChann_DataIntegrityCheck_[5] =meCh_DataIntegrityFED05_;
00038 meChann_DataIntegrityCheck_[6] =meCh_DataIntegrityFED06_;
00039 meChann_DataIntegrityCheck_[7] =meCh_DataIntegrityFED07_;
00040 meChann_DataIntegrityCheck_[8] =meCh_DataIntegrityFED08_;
00041 meChann_DataIntegrityCheck_[9] =meCh_DataIntegrityFED09_;
00042 meChann_DataIntegrityCheck_[10]=meCh_DataIntegrityFED10_;
00043 meChann_DataIntegrityCheck_[11]=meCh_DataIntegrityFED11_;
00044 meChann_DataIntegrityCheck_[12]=meCh_DataIntegrityFED12_;
00045 meChann_DataIntegrityCheck_[13]=meCh_DataIntegrityFED13_;
00046 meChann_DataIntegrityCheck_[14]=meCh_DataIntegrityFED14_;
00047 meChann_DataIntegrityCheck_[15]=meCh_DataIntegrityFED15_;
00048 meChann_DataIntegrityCheck_[16]=meCh_DataIntegrityFED16_;
00049 meChann_DataIntegrityCheck_[17]=meCh_DataIntegrityFED17_;
00050 meChann_DataIntegrityCheck_[18]=meCh_DataIntegrityFED18_;
00051 meChann_DataIntegrityCheck_[19]=meCh_DataIntegrityFED19_;
00052 meChann_DataIntegrityCheck_[20]=meCh_DataIntegrityFED20_;
00053 meChann_DataIntegrityCheck_[21]=meCh_DataIntegrityFED21_;
00054 meChann_DataIntegrityCheck_[22]=meCh_DataIntegrityFED22_;
00055 meChann_DataIntegrityCheck_[23]=meCh_DataIntegrityFED23_;
00056 meChann_DataIntegrityCheck_[24]=meCh_DataIntegrityFED24_;
00057 meChann_DataIntegrityCheck_[25]=meCh_DataIntegrityFED25_;
00058 meChann_DataIntegrityCheck_[26]=meCh_DataIntegrityFED26_;
00059 meChann_DataIntegrityCheck_[27]=meCh_DataIntegrityFED27_;
00060 meChann_DataIntegrityCheck_[28]=meCh_DataIntegrityFED28_;
00061 meChann_DataIntegrityCheck_[29]=meCh_DataIntegrityFED29_;
00062 meChann_DataIntegrityCheck_[30]=meCh_DataIntegrityFED30_;
00063 meChann_DataIntegrityCheck_[31]=meCh_DataIntegrityFED31_;
00064
00065 for (int f=0; f<NUMDCCS; f++) {
00066 for (int s=0; s<15; s++) {
00067 UScount[f][s]=0;}}
00068
00069 for (int x=0; x<THREE_FED; x++)
00070 for (int y=0; y<THREE_SPG; y++)
00071 HalfHTRDataCorruptionIndicators_ [x][y]=0;
00072
00073 for (int x=0; x<THREE_FED; x++)
00074 for (int y=0; y<THREE_SPG; y++)
00075 LRBDataCorruptionIndicators_ [x][y]=0;
00076
00077 for (int x=0; x<TWO___FED; x++)
00078 for (int y=0; y<TWO__SPGT; y++)
00079 ChannSumm_DataIntegrityCheck_[x][y]=0;
00080
00081 for (int x=0; x<TWO___FED; x++)
00082 for (int y=0; y<THREE_SPG; y++)
00083 DataFlowInd_[x][y]=0;
00084
00085 for (int f=0; f<NUMDCCS; f++)
00086 for (int x=0; x< TWO_CHANN; x++)
00087 for (int y=0; y<TWO__SPGT; y++)
00088 Chann_DataIntegrityCheck_ [f][x][y]=0;
00089
00090 for (int i=0; i<(NUMDCCS * NUMSPIGS * HTRCHANMAX); i++)
00091 hashedHcalDetId_[i]=HcalDetId::Undefined;
00092
00093 for (int d=0; d<DEPTHBINS; d++) {
00094 for (int eta=0; eta<ETABINS; eta++) {
00095 for (int phi=0; phi<PHIBINS; phi++){
00096 problemcount[eta][phi][d] = 0.0;
00097 problemfound[eta][phi][d] = false;
00098 }
00099 }
00100 }
00101
00102
00103 }
00104
00105
00106 HcalRawDataMonitor::~HcalRawDataMonitor(){}
00107
00108
00109 void HcalRawDataMonitor::beginRun(const edm::Run& run, const edm::EventSetup& c){
00110 HcalBaseDQMonitor::beginRun(run,c);
00111 edm::ESHandle<HcalDbService> pSetup;
00112 c.get<HcalDbRecord>().get( pSetup );
00113
00114 readoutMap_=pSetup->getHcalMapping();
00115 DetId detid_;
00116 HcalDetId hcaldetid_;
00117
00118
00119 std::vector <HcalElectronicsId> AllElIds = readoutMap_->allElectronicsIdPrecision();
00120 uint32_t itsdcc =0;
00121 uint32_t itsspigot =0;
00122 uint32_t itshtrchan=0;
00123
00124
00125 for (std::vector <HcalElectronicsId>::iterator eid = AllElIds.begin();
00126 eid != AllElIds.end();
00127 eid++) {
00128
00129
00130 detid_ = readoutMap_->lookup(*eid);
00131
00132 if (!detid_.null()) {
00133 if (detid_.det()!=4) continue;
00134 if (detid_.subdetId()!=HcalBarrel &&
00135 detid_.subdetId()!=HcalEndcap &&
00136 detid_.subdetId()!=HcalOuter &&
00137 detid_.subdetId()!=HcalForward) continue;
00138
00139 itsdcc =(uint32_t) eid->dccid();
00140 itsspigot =(uint32_t) eid->spigot();
00141 itshtrchan=(uint32_t) eid->htrChanId();
00142 hcaldetid_ = HcalDetId(detid_);
00143 stashHDI(hashup(itsdcc,itsspigot,itshtrchan),
00144 hcaldetid_);
00145 }
00146 }
00147 }
00148
00149
00150 void HcalRawDataMonitor::beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
00151 const edm::EventSetup& c) {}
00152
00153 void HcalRawDataMonitor::setup(void){
00154
00155 HcalBaseDQMonitor::setup();
00156 if (!dbe_) {
00157 if (debug_>1)
00158 std::cout <<"<HcalRawDataMonitor::setup> No DQMStore instance available. Bailing out."<<std::endl;
00159 return;}
00160
00161
00162 if (debug_>1)
00163 std::cout <<"<HcalRawDataMonitor::beginRun> Setting up histograms"<<std::endl;
00164
00165 dbe_->setCurrentFolder(subdir_);
00166
00167 MonitorElement* excludeHO2=dbe_->bookInt("ExcludeHOring2");
00168
00169 if (excludeHO2) excludeHO2->Fill(excludeHORing2_==true ? 1 : 0);
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 std::string type;
00184
00185 dbe_->setCurrentFolder(subdir_ + "Corruption");
00186 type = "01 Common Data Format violations";
00187 meCDFErrorFound_ = dbe_->book2D(type,type,32,699.5,731.5,9,0.5,9.5);
00188 meCDFErrorFound_->setAxisTitle("HCAL FED ID", 1);
00189 meCDFErrorFound_->setBinLabel(1, "Hdr1BitUnset", 2);
00190 meCDFErrorFound_->setBinLabel(2, "FmtNumChange", 2);
00191 meCDFErrorFound_->setBinLabel(3, "BOE not '0x5'", 2);
00192 meCDFErrorFound_->setBinLabel(4, "Hdr2Bit Set", 2);
00193 meCDFErrorFound_->setBinLabel(5, "Hdr1 36-55", 2);
00194 meCDFErrorFound_->setBinLabel(6, "BOE not 0", 2);
00195 meCDFErrorFound_->setBinLabel(7, "Trlr1Bit Set", 2);
00196 meCDFErrorFound_->setBinLabel(8, "Size Error", 2);
00197 meCDFErrorFound_->setBinLabel(9, "TrailerBad", 2);
00198
00199 type = "02 DCC Event Format violation";
00200 meDCCEventFormatError_ = dbe_->book2D(type,type,32,699.5,731.5,6,0.5,6.5);
00201 meDCCEventFormatError_->setAxisTitle("HCAL FED ID", 1);
00202 meDCCEventFormatError_->setBinLabel(1, "FmtVers Changed", 2);
00203 meDCCEventFormatError_->setBinLabel(2, "StrayBits Changed", 2);
00204 meDCCEventFormatError_->setBinLabel(3, "HTRStatusPad", 2);
00205 meDCCEventFormatError_->setBinLabel(4, "32bitPadErr", 2);
00206 meDCCEventFormatError_->setBinLabel(5, "Number Mismatch Bit Miscalc", 2);
00207 meDCCEventFormatError_->setBinLabel(6, "Low 8 HTR Status Bits Miscopy", 2);
00208
00209 type = "04 HTR BCN when OrN Diff";
00210 meBCNwhenOrNDiff_ = dbe_->book1D(type,type,3564,-0.5,3563.5);
00211 meBCNwhenOrNDiff_->setAxisTitle("BCN",1);
00212 meBCNwhenOrNDiff_->setAxisTitle("# of Entries",2);
00213
00214 type = "03 OrN NonZero Difference HTR - DCC";
00215 meOrNCheck_ = dbe_->book1D(type,type,65,-32.5,32.5);
00216 meOrNCheck_->setAxisTitle("htr OrN - dcc OrN",1);
00217
00218 type = "03 OrN Inconsistent - HTR vs DCC";
00219 meOrNSynch_= dbe_->book2D(type,type,32,700,732, 15,0,15);
00220 meOrNSynch_->setAxisTitle("FED #",1);
00221 meOrNSynch_->setAxisTitle("Spigot #",2);
00222
00223 type = "05 BCN NonZero Difference HTR - DCC";
00224 meBCNCheck_ = dbe_->book1D(type,type,501,-250.5,250.5);
00225 meBCNCheck_->setAxisTitle("htr BCN - dcc BCN",1);
00226
00227 type = "05 BCN Inconsistent - HTR vs DCC";
00228 meBCNSynch_= dbe_->book2D(type,type,32,700,732, 15,0,15);
00229 meBCNSynch_->setAxisTitle("FED #",1);
00230 meBCNSynch_->setAxisTitle("Slot #",2);
00231
00232 type = "06 EvN NonZero Difference HTR - DCC";
00233 meEvtNCheck_ = dbe_->book1D(type,type,601,-300.5,300.5);
00234 meEvtNCheck_->setAxisTitle("htr Evt # - dcc Evt #",1);
00235
00236 type = "06 EvN Inconsistent - HTR vs DCC";
00237 meEvtNumberSynch_= dbe_->book2D(type,type,32,700,732, 15,0,15);
00238 meEvtNumberSynch_->setAxisTitle("FED #",1);
00239 meEvtNumberSynch_->setAxisTitle("Slot #",2);
00240
00241
00242
00243
00244
00245
00246 type="07 LRB Data Corruption Indicators";
00247 meLRBDataCorruptionIndicators_= dbe_->book2D(type,type,
00248 THREE_FED,0,THREE_FED,
00249 THREE_SPG,0,THREE_SPG);
00250 label_xFEDs (meLRBDataCorruptionIndicators_, 4);
00251 label_ySpigots(meLRBDataCorruptionIndicators_, 4);
00252
00253
00254
00255
00256
00257
00258 type="08 Half-HTR Data Corruption Indicators";
00259 meHalfHTRDataCorruptionIndicators_= dbe_->book2D(type,type,
00260 THREE_FED,0,THREE_FED,
00261 THREE_SPG,0,THREE_SPG);
00262 label_xFEDs (meHalfHTRDataCorruptionIndicators_, 4);
00263 label_ySpigots(meHalfHTRDataCorruptionIndicators_, 4);
00264
00265
00266
00267
00268
00269 type = "09 Channel Integrity Summarized by Spigot";
00270 meChannSumm_DataIntegrityCheck_= dbe_->book2D(type,type,
00271 TWO___FED,0,TWO___FED,
00272 TWO__SPGT,0,TWO__SPGT);
00273 label_xFEDs (meChannSumm_DataIntegrityCheck_, 3);
00274 label_ySpigots(meChannSumm_DataIntegrityCheck_, 3);
00275
00276 dbe_->setCurrentFolder(subdir_ + "Corruption/Channel Data Integrity");
00277 char label[256];
00278 for (int f=0; f<NUMDCCS; f++){
00279 snprintf(label, 256, "FED %03d Channel Integrity", f+700);
00280 meChann_DataIntegrityCheck_[f] = dbe_->book2D(label,label,
00281 TWO_CHANN,0,TWO_CHANN,
00282 TWO__SPGT,0,TWO__SPGT);
00283 label_xChanns (meChann_DataIntegrityCheck_[f], 3);
00284 label_ySpigots(meChann_DataIntegrityCheck_[f], 3);
00285 ;}
00286
00287 dbe_->setCurrentFolder(subdir_ + "Data Flow");
00288 type="DCC Event Counts";
00289 mefedEntries_ = dbe_->book1D(type,type,32,699.5,731.5);
00290
00291 type = "BCN from DCCs";
00292 medccBCN_ = dbe_->book1D(type,type,3564,-0.5,3563.5);
00293 medccBCN_->setAxisTitle("BCN",1);
00294 medccBCN_->setAxisTitle("# of Entries",2);
00295
00296 type = "BCN from HTRs";
00297 meBCN_ = dbe_->book1D(type,type,3564,-0.5,3563.5);
00298 meBCN_->setAxisTitle("BCN",1);
00299 meBCN_->setAxisTitle("# of Entries",2);
00300
00301 type = "DCC Data Block Size Distribution";
00302 meFEDRawDataSizes_=dbe_->book1D(type,type,1200,-0.5,12000.5);
00303 meFEDRawDataSizes_->setAxisTitle("# of bytes",1);
00304 meFEDRawDataSizes_->setAxisTitle("# of Data Blocks",2);
00305
00306 type = "DCC Data Block Size Profile";
00307 meEvFragSize_ = dbe_->bookProfile(type,type,32,699.5,731.5,100,-1000.0,12000.0,"");
00308 type = "DCC Data Block Size Each FED";
00309 meEvFragSize2_ = dbe_->book2D(type,type,64,699.5,731.5, 240,0,12000);
00310
00311
00312
00313
00314
00315
00316
00317
00318 type = "01 Data Flow Indicators";
00319 meDataFlowInd_= dbe_->book2D(type,type,
00320 TWO___FED,0,TWO___FED,
00321 THREE_SPG,0,THREE_SPG);
00322 label_xFEDs (meDataFlowInd_, 3);
00323 label_ySpigots(meDataFlowInd_, 4);
00324
00325 dbe_->setCurrentFolder(subdir_ + "Diagnostics");
00326
00327 type = "DCC Firmware Version";
00328 meDCCVersion_ = dbe_->bookProfile(type,type, 32, 699.5, 731.5, 256, -0.5, 255.5);
00329 meDCCVersion_ ->setAxisTitle("FED ID", 1);
00330
00331 type = "HTR Status Word HBHE";
00332 HTR_StatusWd_HBHE = dbe_->book1D(type,type,16,-0.5,15.5);
00333 labelHTRBits(HTR_StatusWd_HBHE,1);
00334
00335 type = "HTR Status Word HF";
00336 HTR_StatusWd_HF = dbe_->book1D(type,type,16,-0.5,15.5);
00337 labelHTRBits(HTR_StatusWd_HF,1);
00338
00339 type = "HTR Status Word HO";
00340 HTR_StatusWd_HO = dbe_->book1D(type,type,16,-0.5,15.5);
00341 labelHTRBits(HTR_StatusWd_HO,1);
00342
00343 int maxbits = 16;
00344 type = "HTR Status Word by Crate";
00345 meStatusWdCrate_ = dbe_->book2D(type,type,18,-0.5,17.5,maxbits,-0.5,maxbits-0.5);
00346 meStatusWdCrate_ -> setAxisTitle("Crate #",1);
00347 labelHTRBits(meStatusWdCrate_,2);
00348
00349 type = "Unpacking - HcalHTRData check failures";
00350 meInvHTRData_= dbe_->book2D(type,type,16,-0.5,15.5,32,699.5,731.5);
00351 meInvHTRData_->setAxisTitle("Spigot #",1);
00352 meInvHTRData_->setAxisTitle("DCC #",2);
00353
00354 type = "HTR Fiber Orbit Message BCN";
00355 meFibBCN_ = dbe_->book1D(type,type,3564,-0.5,3563.5);
00356 meFibBCN_->setAxisTitle("BCN of Fib Orb Msg",1);
00357
00358 type = "HTR Status Word - Crate 0";
00359 meCrate0HTRStatus_ = dbe_->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00360 meCrate0HTRStatus_ ->setAxisTitle("Slot #",1);
00361 labelHTRBits(meCrate0HTRStatus_,2);
00362
00363 type = "HTR Status Word - Crate 1";
00364 meCrate1HTRStatus_ = dbe_->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00365 meCrate1HTRStatus_ ->setAxisTitle("Slot #",1);
00366 labelHTRBits(meCrate1HTRStatus_,2);
00367
00368 type = "HTR Status Word - Crate 2";
00369 meCrate2HTRStatus_ = dbe_->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00370 meCrate2HTRStatus_ ->setAxisTitle("Slot #",1);
00371 labelHTRBits(meCrate2HTRStatus_,2);
00372
00373 type = "HTR Status Word - Crate 3";
00374 meCrate3HTRStatus_ = dbe_->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00375 meCrate3HTRStatus_ ->setAxisTitle("Slot #",1);
00376 labelHTRBits(meCrate3HTRStatus_,2);
00377
00378 type = "HTR Status Word - Crate 4";
00379 meCrate4HTRStatus_ = dbe_->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00380 meCrate4HTRStatus_ ->setAxisTitle("Slot #",1);
00381 labelHTRBits(meCrate4HTRStatus_,2);
00382
00383 type = "HTR Status Word - Crate 5";
00384 meCrate5HTRStatus_ = dbe_->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00385 meCrate5HTRStatus_ ->setAxisTitle("Slot #",1);
00386 labelHTRBits(meCrate5HTRStatus_,2);
00387
00388 type = "HTR Status Word - Crate 6";
00389 meCrate6HTRStatus_ = dbe_->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00390 meCrate6HTRStatus_ ->setAxisTitle("Slot #",1);
00391 labelHTRBits(meCrate6HTRStatus_,2);
00392
00393 type = "HTR Status Word - Crate 7";
00394 meCrate7HTRStatus_ = dbe_->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00395 meCrate7HTRStatus_ ->setAxisTitle("Slot #",1);
00396 labelHTRBits(meCrate7HTRStatus_,2);
00397
00398 type = "HTR Status Word - Crate 9";
00399 meCrate9HTRStatus_ = dbe_->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00400 meCrate9HTRStatus_ ->setAxisTitle("Slot #",1);
00401 labelHTRBits(meCrate9HTRStatus_,2);
00402
00403 type = "HTR Status Word - Crate 10";
00404 meCrate10HTRStatus_ = dbe_->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00405 meCrate10HTRStatus_ ->setAxisTitle("Slot #",1);
00406 labelHTRBits(meCrate10HTRStatus_,2);
00407
00408 type = "HTR Status Word - Crate 11";
00409 meCrate11HTRStatus_ = dbe_->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00410 meCrate11HTRStatus_ ->setAxisTitle("Slot #",1);
00411 labelHTRBits(meCrate11HTRStatus_,2);
00412
00413 type = "HTR Status Word - Crate 12";
00414 meCrate12HTRStatus_ = dbe_->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00415 meCrate12HTRStatus_ ->setAxisTitle("Slot #",1);
00416 labelHTRBits(meCrate12HTRStatus_,2);
00417
00418 type = "HTR Status Word - Crate 13";
00419 meCrate13HTRStatus_ = dbe_->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00420 meCrate13HTRStatus_ ->setAxisTitle("Slot #",1);
00421 labelHTRBits(meCrate13HTRStatus_,2);
00422
00423 type = "HTR Status Word - Crate 14";
00424 meCrate14HTRStatus_ = dbe_->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00425 meCrate14HTRStatus_ ->setAxisTitle("Slot #",1);
00426 labelHTRBits(meCrate14HTRStatus_,2);
00427
00428 type = "HTR Status Word - Crate 15";
00429 meCrate15HTRStatus_ = dbe_->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00430 meCrate15HTRStatus_ ->setAxisTitle("Slot #",1);
00431 labelHTRBits(meCrate15HTRStatus_,2);
00432
00433 type = "HTR Status Word - Crate 17";
00434 meCrate17HTRStatus_ = dbe_->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00435 meCrate17HTRStatus_ ->setAxisTitle("Slot #",1);
00436 labelHTRBits(meCrate17HTRStatus_,2);
00437
00438 type = "HTR UnSuppressed Event Fractions";
00439 meUSFractSpigs_ = dbe_->book1D(type,type,481,0,481);
00440 for(int f=0; f<NUMDCCS; f++) {
00441 snprintf(label, 256, "FED 7%02d", f);
00442 meUSFractSpigs_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f), label);
00443 for(int s=1; s<HcalDCCHeader::SPIGOT_COUNT; s++) {
00444 snprintf(label, 256, "sp%02d", s);
00445 meUSFractSpigs_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f)+s, label);}}
00446
00447
00448 type = "HTR Firmware Version";
00449
00450
00451 meHTRFWVersion_ = dbe_->book2D(type,type ,18,-0.5,17.5,180,75.5,255.5);
00452 meHTRFWVersion_->setAxisTitle("Crate #",1);
00453 meHTRFWVersion_->setAxisTitle("HTR Firmware Version",2);
00454
00455 type = "HTR Fiber 1 Orbit Message BCNs";
00456 meFib1OrbMsgBCN_= dbe_->book2D(type,type,40,-0.25,19.75,18,-0.5,17.5);
00457 type = "HTR Fiber 2 Orbit Message BCNs";
00458 meFib2OrbMsgBCN_= dbe_->book2D(type,type,40,-0.25,19.75,18,-0.5,17.5);
00459 type = "HTR Fiber 3 Orbit Message BCNs";
00460 meFib3OrbMsgBCN_= dbe_->book2D(type,type,40,-0.25,19.75,18,-0.5,17.5);
00461 type = "HTR Fiber 4 Orbit Message BCNs";
00462 meFib4OrbMsgBCN_= dbe_->book2D(type,type,40,-0.25,19.75,18,-0.5,17.5);
00463 type = "HTR Fiber 5 Orbit Message BCNs";
00464 meFib5OrbMsgBCN_= dbe_->book2D(type,type,40,-0.25,19.75,18,-0.5,17.5);
00465 type = "HTR Fiber 6 Orbit Message BCNs";
00466 meFib6OrbMsgBCN_= dbe_->book2D(type,type,40,-0.25,19.75,18,-0.5,17.5);
00467 type = "HTR Fiber 7 Orbit Message BCNs";
00468 meFib7OrbMsgBCN_= dbe_->book2D(type,type,40,-0.25,19.75,18,-0.5,17.5);
00469 type = "HTR Fiber 8 Orbit Message BCNs";
00470 meFib8OrbMsgBCN_= dbe_->book2D(type,type,40,-0.25,19.75,18,-0.5,17.5);
00471
00472 }
00473
00474
00475 void HcalRawDataMonitor::analyze(const edm::Event& e, const edm::EventSetup& s){
00476 if (!IsAllowedCalibType()) return;
00477 if (LumiInOrder(e.luminosityBlock())==false) return;
00478
00479 HcalBaseDQMonitor::analyze(e,s);
00480
00481
00482 edm::Handle<FEDRawDataCollection> rawraw;
00483 if (!(e.getByLabel(FEDRawDataCollection_,rawraw)))
00484 {
00485 edm::LogWarning("HcalRawDataMonitor")<<" raw data with label "<<FEDRawDataCollection_ <<" not available";
00486 return;
00487 }
00488 edm::Handle<HcalUnpackerReport> report;
00489 if (!(e.getByLabel(digiLabel_,report)))
00490 {
00491 edm::LogWarning("HcalRawDataMonitor")<<" Unpacker Report "<<digiLabel_<<" not available";
00492 return;
00493 }
00494
00495
00496 if (debug_>1) std::cout <<"\t<HcalRawDataMonitor::analyze> Processing good event! event # = "<<ievt_<<std::endl;
00497
00498
00499 processEvent(*rawraw, *report);
00500
00501
00502
00503 for (int d=0; d<DEPTHBINS; d++) {
00504 for (int eta=0; eta<ETABINS; eta++) {
00505 int ieta=CalcIeta(eta,d+1);
00506 if (ieta==-9999) continue;
00507 for (int phi=0; phi<PHIBINS; phi++){
00508 if (problemcount[eta][phi][d]) {
00509
00510 HcalSubdetector subdet=HcalEmpty;
00511 if (isHB(eta,d+1))subdet=HcalBarrel;
00512 else if (isHE(eta,d+1)) subdet=HcalEndcap;
00513 else if (isHF(eta,d+1)) subdet=HcalForward;
00514 else if (isHO(eta,d+1)) subdet=HcalOuter;
00515 if (subdet!=HcalEmpty){
00516 if (subdet==HcalBarrel) NumBadHB+= problemcount[eta][phi][d];
00517 else if (subdet==HcalEndcap) NumBadHE+= problemcount[eta][phi][d];
00518 else if (subdet==HcalOuter)
00519 {
00520 NumBadHO += problemcount[eta][phi][d];
00521 if (abs(ieta)<5) NumBadHO0+= problemcount[eta][phi][d];
00522 else NumBadHO12+= problemcount[eta][phi][d];
00523 }
00524 else if (subdet==HcalForward)
00525 {
00526 NumBadHF+= problemcount[eta][phi][d];
00527 if (d==1 && (abs(ieta)==33 || abs(ieta)==34))
00528 NumBadHFLUMI+= problemcount[eta][phi][d];
00529 else if (d==2 && (abs(ieta)==35 || abs(ieta)==36))
00530 NumBadHFLUMI+= problemcount[eta][phi][d];
00531 }
00532 }
00533 problemcount[eta][phi][d]=0;
00534 }
00535 }
00536 }
00537 }
00538 }
00539
00540 void HcalRawDataMonitor::processEvent(const FEDRawDataCollection& rawraw,
00541 const HcalUnpackerReport& report){
00542 if(!dbe_) {
00543 if (debug_>1)
00544 printf("HcalRawDataMonitor::processEvent DQMStore not instantiated!\n");
00545 return;}
00546
00547
00548 meLRBDataCorruptionIndicators_->update();
00549 meHalfHTRDataCorruptionIndicators_->update();
00550 meChannSumm_DataIntegrityCheck_->update();
00551 for (int f=0; f<NUMDCCS; f++)
00552 meChann_DataIntegrityCheck_[f]->update();
00553 meDataFlowInd_->update();
00554
00555
00556 for (int i=FEDNumbering::MINHCALFEDID; i<=FEDNumbering::MAXHCALFEDID; i++) {
00557 const FEDRawData& fed = rawraw.FEDData(i);
00558 if (fed.size()<12) continue;
00559 unpack(fed);
00560 }
00561
00562
00563 for (int x=0; x<ETABINS; x++)
00564 for (int y=0; y<PHIBINS; y++)
00565 for (int z=0; z<DEPTHBINS; z++)
00566 if (problemfound[x][y][z]) {
00567 problemcount[x][y][z]++;
00568 problemfound[x][y][z]=false;
00569 }
00570 return;
00571 }
00572
00573
00574 void HcalRawDataMonitor::unpack(const FEDRawData& raw){
00575
00576
00577 const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(raw.data());
00578 if(!dccHeader) return;
00579 unsigned char* trailer_ptr = (unsigned char*) (raw.data()+raw.size()-sizeof(uint64_t));
00580 FEDTrailer trailer = FEDTrailer(trailer_ptr);
00581
00582
00583 int dccid=dccHeader->getSourceId();
00584
00585 int dcc_=std::max(0,dccid-700);
00586 dcc_ = std::min(dcc_,31);
00587 if(debug_>1) std::cout << "DCC " << dccid << std::endl;
00588 uint64_t* dccfw= (uint64_t*) (raw.data()+(sizeof(uint64_t)*2));
00589 int dcc_fw = ( ((*dccfw)>>(6*8))&0x00000000000000FF );
00590 meDCCVersion_ -> Fill(dccid,dcc_fw);
00591
00592
00593 uint64_t* lastDataWord = (uint64_t*) ( raw.data()+(raw.size())-(1*sizeof(uint64_t)) );
00594 int EvFragLength = (int) (*lastDataWord>>(4*8)) & 0x0000000000FFFFFF ;
00595 meFEDRawDataSizes_->Fill(EvFragLength*8);
00596 meEvFragSize_ ->Fill(dccid, EvFragLength*8);
00597 meEvFragSize2_ ->Fill(dccid, EvFragLength*8);
00598
00599
00600 unsigned long dccEvtNum = dccHeader->getDCCEventNumber();
00601 int dccBCN = dccHeader->getBunchId();
00602
00603 unsigned int dccOrN = (unsigned int) (dccHeader->getOrbitNumber() & 0x0000001F);
00604 medccBCN_ -> Fill(dccBCN);
00605
00607 bool CDFProbThisDCC = false;
00608
00609 if (!dccHeader->thereIsASecondCDFHeaderWord()
00610
00611
00612 ) {
00613 meCDFErrorFound_->Fill(dccid, 1);
00614 CDFProbThisDCC = true;
00615 }
00616
00617 CDFvers_it = CDFversionNumber_list.find(dccid);
00618 if (CDFvers_it == CDFversionNumber_list.end()) {
00619 CDFversionNumber_list.insert(std::pair<int,short>
00620 (dccid,dccHeader->getCDFversionNumber() ) );
00621 CDFvers_it = CDFversionNumber_list.find(dccid);
00622 }
00623 if (dccHeader->getCDFversionNumber()!= CDFvers_it->second) {
00624 meCDFErrorFound_->Fill(dccid,2);
00625 CDFProbThisDCC = true;
00626 }
00627
00628 if (dccHeader->BOEshouldBe5Always()!=5) {
00629 meCDFErrorFound_->Fill(dccid, 3);
00630 CDFProbThisDCC = true;
00631 }
00632
00633 if (dccHeader->thereIsAThirdCDFHeaderWord()) {
00634 meCDFErrorFound_->Fill(dccid, 4);
00635 CDFProbThisDCC = true;
00636 }
00637
00638 CDFReservedBits_it = CDFReservedBits_list.find(dccid);
00639 if (CDFReservedBits_it == CDFReservedBits_list.end()) {
00640 CDFReservedBits_list.insert(std::pair<int,short>
00641 (dccid,dccHeader->getSlink64ReservedBits() & 0x0000FFFF ) );
00642 CDFReservedBits_it = CDFReservedBits_list.find(dccid);
00643 }
00644 if (((int) dccHeader->getSlink64ReservedBits() & 0x0000FFFF ) != CDFReservedBits_it->second) {
00645 meCDFErrorFound_->Fill(dccid,5);
00646
00647 }
00648
00649 if (dccHeader->BOEshouldBeZeroAlways() !=0) {
00650 meCDFErrorFound_->Fill(dccid, 6);
00651 CDFProbThisDCC = true;
00652 }
00653
00654 if (trailer.moreTrailers()) {
00655 meCDFErrorFound_->Fill(dccid, 7);
00656 CDFProbThisDCC = true;
00657 }
00658
00659
00660 if ((uint64_t) raw.size() != ( (uint64_t) trailer.lenght()*sizeof(uint64_t)) )
00661 {
00662 meCDFErrorFound_->Fill(dccid, 8);
00663 CDFProbThisDCC = true;
00664 }
00665
00666 if (!trailer.check()) {
00667 meCDFErrorFound_->Fill(dccid, 9);
00668 CDFProbThisDCC = true;
00669 }
00670 if (CDFProbThisDCC) {
00671
00672 mapDCCproblem(dcc_);
00673 if (debug_>0) std::cout <<"CDFProbThisDCC"<<std::endl;
00674 }
00675
00676 mefedEntries_->Fill(dccid);
00677
00678 CDFProbThisDCC = false;
00679
00680 char CRC_err;
00681 for(int i=0; i<HcalDCCHeader::SPIGOT_COUNT; i++) {
00682 CRC_err = ((dccHeader->getSpigotSummary(i) >> 10) & 0x00000001);
00683 if (CRC_err) {
00684 mapDCCproblem(dcc_);
00685
00686 if (debug_>0) std::cout <<"HTR Problem: CRC_err"<<std::endl;
00687 }
00688 }
00689
00690
00691 char TTS_state = (char)trailer.ttsBits();
00692
00693 char L1AtimeTTS_state=(char) dccHeader->getAcceptTimeTTS();
00694 if (TTS_state==L1AtimeTTS_state) ;
00695
00697
00698 DCCEvtFormat_it = DCCEvtFormat_list.find(dccid);
00699 if (DCCEvtFormat_it == DCCEvtFormat_list.end()) {
00700 DCCEvtFormat_list.insert(std::pair<int,short>
00701 (dccid,dccHeader->getDCCDataFormatVersion() ) );
00702 DCCEvtFormat_it = DCCEvtFormat_list.find(dccid);
00703 }
00704 if (dccHeader->getDCCDataFormatVersion()!= DCCEvtFormat_it->second) {
00705 meDCCEventFormatError_->Fill(dccid,1);
00706 mapDCCproblem(dcc_);
00707 if (debug_>0)std::cout <<"DCC Error Type 1"<<std::endl;
00708 }
00709
00710 if (false)
00711 {
00712 meDCCEventFormatError_->Fill(dccid,2);
00713 mapDCCproblem(dcc_);
00714 if (debug_>0)std::cout <<"DCC Error Type 2"<<std::endl;
00715 }
00716
00717 int SpigotPad = HcalDCCHeader::SPIGOT_COUNT;
00718 if ( (((uint64_t) dccHeader->getSpigotSummary(SpigotPad) )
00719 | ((uint64_t) dccHeader->getSpigotSummary(SpigotPad+1))
00720 | ((uint64_t) dccHeader->getSpigotSummary(SpigotPad+2))) != 0){
00721 meDCCEventFormatError_->Fill(dccid,3);
00722 mapDCCproblem(dcc_);
00723 if (debug_>0)std::cout <<"DCC Error Type 3"<<std::endl;
00724 }
00725
00726 int nHTR32BitWords=0;
00727
00728 for(int i=0; i<HcalDCCHeader::SPIGOT_COUNT; i++) {
00729 nHTR32BitWords += dccHeader->getSpigotDataLength(i); }
00730
00731 if (( nHTR32BitWords % 2) == 1) {
00732 uint64_t* lastDataWord = (uint64_t*) ( raw.data()+raw.size()-(2*sizeof(uint64_t)) );
00733 if ((*lastDataWord>>32) != 0x00000000){
00734 meDCCEventFormatError_->Fill(dccid, 4);
00735 mapDCCproblem(dcc_);
00736 if (debug_>0)std::cout <<"DCC Error Type 4"<<std::endl;
00737 }
00738 }
00739
00740 unsigned char HTRErrorList=0;
00741 for(int j=0; j<HcalDCCHeader::SPIGOT_COUNT; j++) {
00742 HTRErrorList=dccHeader->getSpigotErrorBits(j);
00743 }
00744
00745
00746 const int fed3offset = 1 + (4*dcc_);
00747 const int fed2offset = 1 + (3*dcc_);
00748 if (TTS_state & 0x8)
00749 ;
00750 if (TTS_state & 0x2)
00751 {
00752 mapDCCproblem(dcc_);
00753 if (debug_>0)std::cout <<"TTS_state Error:sync"<<std::endl;
00754 }
00755
00756 int WholeErrorList=0;
00757 for(int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) {
00758 if (!( dccHeader->getSpigotEnabled((unsigned int) spigot)) )
00759 continue;
00760
00761 const int spg3offset = 1 + (4*spigot);
00762
00763 if (TTS_state & 0x4)
00764 ++DataFlowInd_[fed2offset+1][spg3offset+1];
00765 if (TTS_state & 0x1)
00766 ++DataFlowInd_[fed2offset+1][spg3offset+2];
00767
00768 WholeErrorList=dccHeader->getLRBErrorBits((unsigned int) spigot);
00769 if (WholeErrorList!=0) {
00770 if ((WholeErrorList>>0)&0x01)
00771 DataFlowInd_[fed2offset-1][spg3offset-1]++;
00772 if (((WholeErrorList>>1)&0x01)!=0) {
00773 LRBDataCorruptionIndicators_[fed3offset+1][spg3offset+2]++;
00774 mapHTRproblem(dcc_,spigot);
00775 }
00776 if (((WholeErrorList>>2)&0x01)!=0) {
00777 LRBDataCorruptionIndicators_[fed3offset+2][spg3offset+2]++;
00778 mapHTRproblem(dcc_,spigot);
00779 }
00780 if (((WholeErrorList>>3)&0x01)!=0) {
00781 LRBDataCorruptionIndicators_[fed3offset+1][spg3offset+1]++;
00782 mapHTRproblem(dcc_,spigot);
00783 }
00784 if (((WholeErrorList>>4)&0x01)!=0) {
00785 LRBDataCorruptionIndicators_[fed3offset+2][spg3offset+1]++;
00786 mapHTRproblem(dcc_,spigot);
00787 }
00788 if (((WholeErrorList>>5)&0x01)!=0) {
00789 LRBDataCorruptionIndicators_[fed3offset+1][spg3offset+0]++;
00790 mapHTRproblem(dcc_,spigot);
00791 }
00792 if (((WholeErrorList>>6)&0x01)!=0) {
00793 LRBDataCorruptionIndicators_[fed3offset+2][spg3offset+0]++;
00794 mapHTRproblem(dcc_,spigot);
00795 }
00796 }
00797 if (!dccHeader->getSpigotPresent((unsigned int) spigot)){
00798 LRBDataCorruptionIndicators_[fed3offset+0][spg3offset+2]++;
00799 mapHTRproblem(dcc_,spigot);
00800 if (debug_>0)std::cout <<"HTR Problem: Spigot Not Present"<<std::endl;
00801 } else {
00802 if ( dccHeader->getSpigotDataTruncated((unsigned int) spigot)) {
00803 LRBDataCorruptionIndicators_[fed3offset-1][spg3offset+0]++;
00804 mapHTRproblem(dcc_,spigot);
00805 if (debug_>0)std::cout <<"HTR Problem: Spigot Data Truncated"<<std::endl;
00806 }
00807 if ( dccHeader->getSpigotCRCError((unsigned int) spigot)) {
00808 LRBDataCorruptionIndicators_[fed3offset+0][spg3offset+0]++;
00809 mapHTRproblem(dcc_,spigot);
00810 }
00811 }
00812 if (dccHeader->getSpigotDataLength(spigot) <(unsigned long)4) {
00813 LRBDataCorruptionIndicators_[fed3offset+0][spg3offset+1]++;
00814 mapHTRproblem(dcc_,spigot);
00815 if (debug_>0)std::cout <<"HTR Problem: Spigot Data Length too small"<<std::endl;
00816 }
00817 }
00818
00819
00820 HcalHTRData htr;
00821 for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) {
00822 const int spg3offset = 1 + (4*spigot);
00823 const int spg2offset = 1 + (3*spigot);
00824 if (!dccHeader->getSpigotPresent(spigot)) continue;
00825
00826
00827
00828 dccHeader->getSpigotData(spigot,htr, raw.size());
00829 const unsigned short* HTRraw = htr.getRawData();
00830
00831
00832 if (!htr.check()) {
00833 meInvHTRData_ -> Fill(spigot,dccid);
00834 mapHTRproblem(dcc_,spigot);
00835 if (debug_>0)std::cout <<"HTR Problem: HTR check fails"<<std::endl;
00836 }
00837
00838 unsigned short HTRwdcount = htr.getRawLength();
00839
00840
00841
00842 int NTP = ((htr.getExtHdr6() >> 8) & 0x00FF);
00843 int NDAQ = (HTRraw[htr.getRawLength() - 4] & 0x7FF);
00844
00845 if ( ! ((HTRwdcount != 8) ||
00846 (HTRwdcount != 12 + NTP + NDAQ) ||
00847 (HTRwdcount != 20 + NTP + NDAQ) )) {
00848 ++HalfHTRDataCorruptionIndicators_[fed3offset+2][spg3offset+0];
00849 mapHTRproblem(dcc_,spigot);
00850 if (debug_>0)std::cout <<"HTR Problem: NTP+NDAQ size consistency check fails"<<std::endl;
00851
00852 continue; }
00853 bool EE = ((dccHeader->getSpigotErrorBits(spigot) >> 2) & 0x01);
00854 if (EE) {
00855 if (HTRwdcount != 8) {
00856 ++HalfHTRDataCorruptionIndicators_[fed3offset+2][spg3offset+1];
00857 if (debug_>0)std::cout <<"HTR Problem: HTRwdcount !=8"<<std::endl;
00858 }
00859 DataFlowInd_[fed2offset+0][spg3offset+0]++;
00860 continue;}
00861 else{
00862 bool CM = (htr.getExtHdr7() >> 14)&0x0001;
00863 if (( CM && ( (HTRwdcount-NDAQ-NTP) != 12) )
00864 ||
00865 (!CM && ( (HTRwdcount-NDAQ-NTP) != 20) ) ) {
00866 ++HalfHTRDataCorruptionIndicators_[fed3offset+2][spg3offset+1];
00867 mapHTRproblem(dcc_,spigot);
00868 continue;} }
00869
00870 if (htr.isHistogramEvent()) continue;
00871
00872
00873 unsigned int htrOrN = htr.getOrbitNumber();
00874 unsigned int htrBCN = htr.getBunchNumber();
00875 unsigned int htrEvtN = htr.getL1ANumber();
00876 meBCN_->Fill(htrBCN);
00877
00878 if (( (htrOrN == dccOrN ) &&
00879 (htrBCN == (unsigned int) dccBCN) )
00880 != (dccHeader->getBxMismatchWithDCC(spigot)) ){
00881 meDCCEventFormatError_->Fill(dccid,5);
00882 mapHTRproblem(dcc_,spigot);
00883 if (debug_>0)std::cout <<"Orbit or BCN HTR/DCC mismatch"<<std::endl;
00884 }
00885 if ( (htrEvtN == dccEvtNum) !=
00886 dccHeader->getSpigotValid(spigot) ) {
00887 meDCCEventFormatError_->Fill(dccid,5);
00888 mapHTRproblem(dcc_,spigot);
00889 if (debug_>0)std::cout <<"DCC invalid spigot"<<std::endl;
00890 }
00891 int cratenum = htr.readoutVMECrateId();
00892 float slotnum = htr.htrSlot() + 0.5*htr.htrTopBottom();
00893 if (debug_ > 0) HTRPrint(htr,debug_);
00894 unsigned int htrFWVer = htr.getFirmwareRevision() & 0xFF;
00895 meHTRFWVersion_->Fill(cratenum,htrFWVer);
00896
00898 int EvtNdiff = htrEvtN - dccEvtNum;
00899 if (EvtNdiff!=0) {
00900 meEvtNumberSynch_->Fill(dccid,spigot);
00901 mapHTRproblem(dcc_,spigot);
00902 meEvtNCheck_->Fill(EvtNdiff);
00903 if (debug_ == 1)std::cout << "++++ Evt # out of sync, ref, this HTR: "<< dccEvtNum << " "<<htrEvtN <<std::endl;
00904 }
00905
00907 int BCNdiff = htrBCN-dccBCN;
00908 if ((BCNdiff!=0)
00909
00910
00911 ){
00912 meBCNSynch_->Fill(dccid,spigot);
00913 mapHTRproblem(dcc_,spigot);
00914 meBCNCheck_->Fill(BCNdiff);
00915 if (debug_==1)std::cout << "++++ BCN # out of sync, ref, this HTR: "<< dccBCN << " "<<htrBCN <<std::endl;
00916 }
00917
00919 int OrNdiff = htrOrN-dccOrN;
00920 if (OrNdiff!=0) {
00921 meOrNSynch_->Fill(dccid,spigot);
00922 mapHTRproblem(dcc_,spigot);
00923 meOrNCheck_->Fill(OrNdiff);
00924 meBCNwhenOrNDiff_->Fill(htrBCN);
00925 if (debug_==1)std::cout << "++++ OrN # out of sync, ref, this HTR: "<< dccOrN << " "<<htrOrN <<std::endl;
00926 }
00927
00928 bool htrUnSuppressed=(HTRraw[6]>>15 & 0x0001);
00929 if (htrUnSuppressed) {
00930 UScount[dcc_][spigot]++;
00931 int here=1+(HcalDCCHeader::SPIGOT_COUNT*(dcc_))+spigot;
00932 meUSFractSpigs_->setBinContent(here,
00933 ((double)UScount[dcc_][spigot])/(double)ievt_);}
00934
00935 MonitorElement* tmpErr = 0;
00936 HcalDetId HDI = hashedHcalDetId_[hashup(dcc_,spigot)];
00937 if (HDI != HcalDetId::Undefined) {
00938 switch (HDI.subdetId()) {
00939 case (HcalBarrel): {
00940 tmpErr = HTR_StatusWd_HBHE;
00941 } break;
00942 case (HcalEndcap): {
00943 tmpErr = HTR_StatusWd_HBHE;
00944 } break;
00945 case (HcalOuter): {
00946 tmpErr = HTR_StatusWd_HO;
00947 } break;
00948 case (HcalForward): {
00949 tmpErr = HTR_StatusWd_HF;
00950 } break;
00951 default: break;
00952 }
00953 }
00954
00955 int errWord = htr.getErrorsWord() & 0xFFFF;
00956 if ( (((dccHeader->getSpigotSummary( spigot))>>24)&0x00FF)
00957 != (errWord&0x00FF) ){
00958 meDCCEventFormatError_->Fill(dccid,6);
00959 mapHTRproblem(dcc_,spigot);
00960 if (debug_>0)std::cout <<"DCC spigot summary error or HTR error word"<<std::endl;
00961
00962 }
00963 if(tmpErr!=NULL){
00964 for(int i=0; i<16; i++){
00965 int errbit = errWord&(0x01<<i);
00966
00967 if (i==15) errbit = errbit - 0x8000;
00968 if (errbit !=0) {
00969 tmpErr->Fill(i);
00970
00971 switch (i) {
00972 case (14):
00973 HalfHTRDataCorruptionIndicators_[fed3offset+0][spg3offset+2]++;
00974 mapHTRproblem(dcc_,spigot);
00975 if (debug_>0)std::cout <<"HTR Problem: Case 14"<<std::endl;
00976 break;
00977 case (13):
00978 HalfHTRDataCorruptionIndicators_[fed3offset+0][spg3offset+1]++;
00979 mapHTRproblem(dcc_,spigot);
00980 if (debug_>0)std::cout <<"HTR Problem: Case 13"<<std::endl;
00981 break;
00982 case (12):
00983 HalfHTRDataCorruptionIndicators_[fed3offset+0][spg3offset+0]++;
00984 mapHTRproblem(dcc_,spigot);
00985 if (debug_>0)std::cout <<"HTR Problem: Case 12"<<std::endl;
00986 break;
00987 case ( 8):
00988 HalfHTRDataCorruptionIndicators_[fed3offset+1][spg3offset+2]++;
00989 mapHTRproblem(dcc_,spigot);
00990 if (debug_>0)std::cout <<"HTR Problem: Case 8"<<std::endl;
00991 break;
00992 case (15):
00993 HalfHTRDataCorruptionIndicators_[fed3offset+1][spg3offset+1]++;
00994 mapHTRproblem(dcc_,spigot);
00995 break;
00996 case ( 7):
00997 HalfHTRDataCorruptionIndicators_[fed3offset+1][spg3offset+0]++;
00998 mapHTRproblem(dcc_,spigot);
00999 if (debug_>0)std::cout <<"HTR Problem: Case 7"<<std::endl;
01000 break;
01001
01002
01003
01004
01005
01006
01007
01008 case ( 3):
01009 DataFlowInd_[fed2offset+1][spg3offset+0]++; break;
01010 case ( 1):
01011 DataFlowInd_[fed2offset+0][spg3offset+1]++; break;
01012 case ( 0):
01013 DataFlowInd_[fed2offset+0][spg3offset+2]++;
01014 default: break;
01015 }
01016 meStatusWdCrate_->Fill(cratenum,i);
01017 if (cratenum == 0) meCrate0HTRStatus_ -> Fill(slotnum,i);
01018 else if (cratenum == 1) meCrate1HTRStatus_ -> Fill(slotnum,i);
01019 else if (cratenum == 2) meCrate2HTRStatus_ -> Fill(slotnum,i);
01020 else if (cratenum == 3) meCrate3HTRStatus_ -> Fill(slotnum,i);
01021 else if (cratenum == 4) meCrate4HTRStatus_ -> Fill(slotnum,i);
01022 else if (cratenum == 5) meCrate5HTRStatus_ -> Fill(slotnum,i);
01023 else if (cratenum == 6) meCrate6HTRStatus_ -> Fill(slotnum,i);
01024 else if (cratenum == 7) meCrate7HTRStatus_ -> Fill(slotnum,i);
01025 else if (cratenum == 9) meCrate9HTRStatus_ -> Fill(slotnum,i);
01026 else if (cratenum ==10)meCrate10HTRStatus_ -> Fill(slotnum,i);
01027 else if (cratenum ==11)meCrate11HTRStatus_ -> Fill(slotnum,i);
01028 else if (cratenum ==12)meCrate12HTRStatus_ -> Fill(slotnum,i);
01029 else if (cratenum ==13)meCrate13HTRStatus_ -> Fill(slotnum,i);
01030 else if (cratenum ==14)meCrate14HTRStatus_ -> Fill(slotnum,i);
01031 else if (cratenum ==15)meCrate15HTRStatus_ -> Fill(slotnum,i);
01032 else if (cratenum ==17)meCrate17HTRStatus_ -> Fill(slotnum,i);
01033 }
01034 }
01035 }
01036
01037
01038 const short unsigned int* daq_first, *daq_last, *tp_first, *tp_last;
01039 const HcalQIESample* qie_begin, *qie_end, *qie_work;
01040
01041
01042 htr.dataPointers(&daq_first,&daq_last,&tp_first,&tp_last);
01043 qie_begin=(HcalQIESample*)daq_first;
01044 qie_end=(HcalQIESample*)(daq_last+1);
01045
01046
01047
01048
01049 int lastcapid=-1;
01050 int samplecounter=-1;
01051 int htrchan=-1;
01052 int chn2offset=0;
01053 int NTS = htr.getNDD();
01054
01055 ChannSumm_DataIntegrityCheck_ [fed2offset-1][spg2offset+0]=-NTS;
01056
01057 for (qie_work=qie_begin; qie_work!=qie_end; qie_work++) {
01058 if (qie_work->raw()==0xFFFF)
01059 continue;
01060
01061 if (( 1 + ( 3* (qie_work->fiber()-1) ) + qie_work->fiberChan() ) != htrchan) {
01062
01063 htrchan= (3* (qie_work->fiber()-1) ) + qie_work->fiberChan();
01064 chn2offset = (htrchan*3)+1;
01065 --ChannSumm_DataIntegrityCheck_ [fed2offset-1][spg2offset-1];
01066 --Chann_DataIntegrityCheck_[dcc_][chn2offset-1][spg2offset-1];
01067 if (samplecounter !=-1) {
01068
01069 if (((samplecounter != NTS) &&
01070 (samplecounter != 1) )
01071
01072
01073 )
01074 {
01075 ++ChannSumm_DataIntegrityCheck_ [fed2offset+0][spg2offset+0];
01076 ++Chann_DataIntegrityCheck_[dcc_][chn2offset+0][spg2offset+0];
01077 mapChannproblem(dcc_,spigot,htrchan);
01078 if (debug_)std::cout <<"mapChannelProblem: Wrong Digi Size"<<std::endl;
01079 }
01080 }
01081
01082 lastcapid=qie_work->capid();
01083 samplecounter=1;}
01084 else {
01085 int hope = lastcapid +1;
01086 if (hope==4) hope = 0;
01087 if (qie_work->capid() != hope){
01088 ++ChannSumm_DataIntegrityCheck_ [fed2offset+1][spg2offset+0];
01089 ++Chann_DataIntegrityCheck_[dcc_][chn2offset+1][spg2offset+0];
01090 mapChannproblem(dcc_,spigot,htrchan);
01091 if (debug_)std::cout <<"mapChannelProblem: Wrong Cap ID"<<std::endl;
01092 }
01093 lastcapid=qie_work->capid();
01094 samplecounter++;}
01095
01096 if (!(qie_work->dv())){
01097 ++ChannSumm_DataIntegrityCheck_ [fed2offset+0][spg2offset+1];
01098 ++Chann_DataIntegrityCheck_[dcc_][chn2offset+0][spg2offset+1];
01099 }
01100 if (qie_work->er()) {
01101 ++ChannSumm_DataIntegrityCheck_ [fed2offset+1][spg2offset+1];
01102 ++Chann_DataIntegrityCheck_[dcc_][chn2offset+1][spg2offset+1];
01103 mapChannproblem(dcc_,spigot,htrchan);
01104 if (debug_)std::cout <<"mapChannelProblem: FE Error"<<std::endl;
01105 }
01106 }
01107
01108
01109 if ((samplecounter != NTS) &&
01110 (samplecounter != 1) &&
01111 (samplecounter !=-1) ) {
01112 ++ChannSumm_DataIntegrityCheck_ [fed2offset+0][spg2offset+0];
01113 ++Chann_DataIntegrityCheck_[dcc_][chn2offset+0][spg2offset+0];
01114 mapChannproblem(dcc_,spigot,htrchan);
01115 if (debug_)std::cout <<"mapChannelProblem: Wrong Digi Size (last digi)"<<std::endl;
01116 }
01117 unsigned int fib1BCN = htr.getFib1OrbMsgBCN();
01118 unsigned int fib2BCN = htr.getFib2OrbMsgBCN();
01119 unsigned int fib3BCN = htr.getFib3OrbMsgBCN();
01120 unsigned int fib4BCN = htr.getFib4OrbMsgBCN();
01121 unsigned int fib5BCN = htr.getFib5OrbMsgBCN();
01122 unsigned int fib6BCN = htr.getFib6OrbMsgBCN();
01123 unsigned int fib7BCN = htr.getFib7OrbMsgBCN();
01124 unsigned int fib8BCN = htr.getFib8OrbMsgBCN();
01125 meFibBCN_->Fill(fib1BCN);
01126 meFibBCN_->Fill(fib2BCN);
01127 meFibBCN_->Fill(fib3BCN);
01128 meFibBCN_->Fill(fib4BCN);
01129 meFibBCN_->Fill(fib5BCN);
01130 meFibBCN_->Fill(fib6BCN);
01131 meFibBCN_->Fill(fib7BCN);
01132 meFibBCN_->Fill(fib8BCN);
01133
01134 meFib1OrbMsgBCN_->Fill(slotnum, cratenum, fib1BCN);
01135 meFib2OrbMsgBCN_->Fill(slotnum, cratenum, fib2BCN);
01136 meFib3OrbMsgBCN_->Fill(slotnum, cratenum, fib3BCN);
01137 meFib4OrbMsgBCN_->Fill(slotnum, cratenum, fib4BCN);
01138 meFib5OrbMsgBCN_->Fill(slotnum, cratenum, fib5BCN);
01139 meFib6OrbMsgBCN_->Fill(slotnum, cratenum, fib6BCN);
01140 meFib7OrbMsgBCN_->Fill(slotnum, cratenum, fib7BCN);
01141 meFib8OrbMsgBCN_->Fill(slotnum, cratenum, fib8BCN);
01142 }
01143 return;
01144 }
01145
01146
01147
01148 void HcalRawDataMonitor::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
01149 const edm::EventSetup& c){
01150
01151 if (ProblemsCurrentLB)
01152 ProblemsCurrentLB->Reset();
01153 if (ProblemsCurrentLB)
01154 {
01155 ProblemsCurrentLB->setBinContent(0,0, levt_);
01156 ProblemsCurrentLB->setBinContent(1,1, NumBadHB*levt_);
01157 ProblemsCurrentLB->setBinContent(2,1, NumBadHE*levt_);
01158 ProblemsCurrentLB->setBinContent(3,1, NumBadHO*levt_);
01159 ProblemsCurrentLB->setBinContent(4,1, NumBadHF*levt_);
01160 ProblemsCurrentLB->setBinContent(5,1, NumBadHO0*levt_);
01161 ProblemsCurrentLB->setBinContent(6,1, NumBadHO12*levt_);
01162 ProblemsCurrentLB->setBinContent(7,1, NumBadHFLUMI*levt_);
01163 }
01164
01165 UpdateMEs();
01166 }
01167
01168 void HcalRawDataMonitor::endRun(const edm::Run& run, const edm::EventSetup& c){}
01169
01170
01171 void HcalRawDataMonitor::endJob(void){
01172 if (debug_>0) std::cout <<"HcalRawDataMonitor::endJob()"<<std::endl;
01173 if (enableCleanup_) cleanup();
01174 }
01175
01176
01177 void HcalRawDataMonitor::label_ySpigots(MonitorElement* me_ptr, int ybins) {
01178 char label[32];
01179 for (int spig=0; spig<HcalDCCHeader::SPIGOT_COUNT; spig++) {
01180 snprintf(label, 32, "Spgt %02d", spig);
01181 me_ptr->setBinLabel((2+(spig*ybins)), label, 2);
01182 }
01183 }
01184
01185
01186 void HcalRawDataMonitor::label_xChanns(MonitorElement* me_ptr, int xbins) {
01187 char label[32];
01188 for (int ch=0; ch<HcalHTRData::CHANNELS_PER_SPIGOT; ch++) {
01189 snprintf(label, 32, "Ch %02d", ch+1);
01190 me_ptr->setBinLabel((2+(ch*xbins)), label, 1);
01191 }
01192 }
01193
01194
01195 void HcalRawDataMonitor::label_xFEDs(MonitorElement* me_ptr, int xbins) {
01196 char label[32];
01197 for (int thfed=0; thfed<NUMDCCS; thfed++) {
01198 snprintf(label, 32, "%03d", thfed+700);
01199 me_ptr->setBinLabel((2+(thfed*xbins)), label, 1);
01200 }
01201 }
01202
01203 void HcalRawDataMonitor::labelHTRBits(MonitorElement* mePlot,unsigned int axisType) {
01204
01205 if (axisType !=1 && axisType != 2) return;
01206
01207 mePlot -> setBinLabel(1,"Overflow Warn",axisType);
01208 mePlot -> setBinLabel(2,"Buffer Busy",axisType);
01209 mePlot -> setBinLabel(3,"Empty Event",axisType);
01210 mePlot -> setBinLabel(4,"Rejected L1A",axisType);
01211 mePlot -> setBinLabel(5,"Invalid Stream",axisType);
01212 mePlot -> setBinLabel(6,"Latency Warn",axisType);
01213 mePlot -> setBinLabel(7,"OptDat Err",axisType);
01214 mePlot -> setBinLabel(8,"Clock Err",axisType);
01215 mePlot -> setBinLabel(9,"Bunch Err",axisType);
01216 mePlot -> setBinLabel(10,"b9",axisType);
01217 mePlot -> setBinLabel(11,"b10",axisType);
01218 mePlot -> setBinLabel(12,"b11",axisType);
01219 mePlot -> setBinLabel(13,"Test Mode",axisType);
01220 mePlot -> setBinLabel(14,"Histo Mode",axisType);
01221 mePlot -> setBinLabel(15,"Calib Trig",axisType);
01222 mePlot -> setBinLabel(16,"Bit15 Err",axisType);
01223
01224 return;
01225 }
01226
01227 void HcalRawDataMonitor::stashHDI(int thehash, HcalDetId thehcaldetid) {
01228
01229 if ((thehash<0)||(thehash>(NUMDCCS*NUMSPIGS*HTRCHANMAX)))return;
01230
01231 hashedHcalDetId_[thehash] = thehcaldetid;
01232 }
01233
01234
01235
01236 void HcalRawDataMonitor::HTRPrint(const HcalHTRData& htr,int prtlvl){
01237 if (prtlvl == 1){
01238 int cratenum = htr.readoutVMECrateId();
01239 float slotnum = htr.htrSlot() + 0.5*htr.htrTopBottom();
01240 printf("Crate,Slot,ErrWord,Evt#,BCN: %3i %4.1f %6X %7i %4X \n", cratenum,slotnum,htr.getErrorsWord(),htr.getL1ANumber(),htr.getBunchNumber());
01241
01242 }
01243
01244 else if (prtlvl == 2){
01245 int cratenum = htr.readoutVMECrateId();
01246 float slotnum = htr.htrSlot() + 0.5*htr.htrTopBottom();
01247 printf("Crate, Slot:%3i %4.1f \n", cratenum,slotnum);
01248
01249 }
01250
01251 else if (prtlvl == 3){
01252 int cratenum = htr.readoutVMECrateId();
01253 float slotnum = htr.htrSlot() + 0.5*htr.htrTopBottom();
01254 printf("Crate, Slot:%3i %4.1f", cratenum,slotnum);
01255 printf(" FibOrbMsgBCNs: %4X %4X %4X %4X %4X %4X %4X %4X \n",htr.getFib1OrbMsgBCN(),htr.getFib2OrbMsgBCN(),htr.getFib3OrbMsgBCN(),htr.getFib4OrbMsgBCN(),htr.getFib5OrbMsgBCN(),htr.getFib6OrbMsgBCN(),htr.getFib7OrbMsgBCN(),htr.getFib8OrbMsgBCN());
01256 }
01257
01258 return;
01259 }
01260
01261
01262 void HcalRawDataMonitor::UpdateMEs (void ) {
01263 tevt_=0;
01264 if (meTevtHist_) tevt_= (int)meTevtHist_->getBinContent(1);
01265 NumBadHB=0;
01266 NumBadHE=0;
01267 NumBadHO=0;
01268 NumBadHF=0;
01269 NumBadHFLUMI=0;
01270 NumBadHO0=0;
01271 NumBadHO12=0;
01272
01273
01274 meLRBDataCorruptionIndicators_->setBinContent(0,0,tevt_);
01275 for (int x=0; x<THREE_FED; x++)
01276 for (int y=0; y<THREE_SPG; y++)
01277 if (LRBDataCorruptionIndicators_ [x][y])
01278 meLRBDataCorruptionIndicators_->setBinContent(x+1,y+1,LRBDataCorruptionIndicators_[x][y]);
01279
01280 meHalfHTRDataCorruptionIndicators_->setBinContent(0,0,tevt_);
01281 for (int x=0; x<THREE_FED; x++)
01282 for (int y=0; y<THREE_SPG; y++)
01283 if (HalfHTRDataCorruptionIndicators_ [x][y])
01284 meHalfHTRDataCorruptionIndicators_->setBinContent(x+1,y+1,HalfHTRDataCorruptionIndicators_[x][y]);
01285
01286 meChannSumm_DataIntegrityCheck_->setBinContent(0,0,tevt_);
01287 for (int x=0; x<TWO___FED; x++)
01288 for (int y=0; y<TWO__SPGT; y++)
01289 if (ChannSumm_DataIntegrityCheck_[x][y])
01290 meChannSumm_DataIntegrityCheck_->setBinContent(x+1,y+1,ChannSumm_DataIntegrityCheck_[x][y]);
01291
01292 for (int f=0; f<NUMDCCS; f++){
01293 meChann_DataIntegrityCheck_[f]->setBinContent(0,0,tevt_);
01294 for (int x=0; x<TWO_CHANN; x++)
01295 for (int y=0; y<TWO__SPGT; y++)
01296 if (Chann_DataIntegrityCheck_[f][x][y])
01297 meChann_DataIntegrityCheck_[f]->setBinContent(x+1,y+1,Chann_DataIntegrityCheck_ [f][x][y]);
01298 }
01299
01300 meDataFlowInd_->setBinContent(0,0,tevt_);
01301 for (int x=0; x<TWO___FED; x++)
01302 for (int y=0; y<THREE_SPG; y++)
01303 if (DataFlowInd_[x][y])
01304 meDataFlowInd_->setBinContent(x+1,y+1,DataFlowInd_[x][y]);
01305 }
01306
01307
01308 void HcalRawDataMonitor::whosebad(int subdet) {
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325 }
01326
01327 void HcalRawDataMonitor::mapDCCproblem(int dcc) {
01328 int myeta = 0;
01329 int myphi =-1;
01330 int mydepth = 0;
01331 HcalDetId HDI;
01332
01333 for (int i=hashup(dcc);
01334 i<hashup(dcc)+(NUMSPIGS*HTRCHANMAX);
01335 i++) {
01336 HDI = hashedHcalDetId_[i];
01337 if (HDI==HcalDetId::Undefined)
01338 continue;
01339 mydepth = HDI.depth();
01340 myphi = HDI.iphi();
01341 myeta = CalcEtaBin(HDI.subdet(),
01342 HDI.ieta(),
01343 mydepth);
01344
01345 if (myeta>=0 && myeta<85 &&
01346 (myphi-1)>=0 && (myphi-1)<72 &&
01347 (mydepth-1)>=0 && (mydepth-1)<4){
01348 problemfound[myeta][myphi-1][mydepth-1] = true;
01349
01350
01351 if(mydepth==4 && excludeHORing2_==true)
01352 if (abs(HDI.ieta())>=11 && abs(HDI.ieta())<=15 && !isSiPM(HDI.ieta(),HDI.iphi(),mydepth))
01353 problemfound[myeta][myphi-1][mydepth-1] = false;
01354
01355 if (debug_>0)
01356 std::cout<<" mapDCCproblem found error! "<<HDI.subdet()<<"("<<HDI.ieta()<<", "<<HDI.iphi()<<", "<<HDI.depth()<<")"<<std::endl;
01357 }
01358 }
01359 }
01360 void HcalRawDataMonitor::mapHTRproblem(int dcc, int spigot) {
01361 int myeta = 0;
01362 int myphi =-1;
01363 int mydepth = 0;
01364 HcalDetId HDI;
01365
01366 for (int i=hashup(dcc,spigot);
01367 i<hashup(dcc,spigot)+(HTRCHANMAX);
01368 i++) {
01369 HDI = hashedHcalDetId_[i];
01370 if (HDI==HcalDetId::Undefined) {
01371 continue;
01372 }
01373 mydepth = HDI.depth();
01374 myphi = HDI.iphi();
01375 myeta = CalcEtaBin(HDI.subdet(),
01376 HDI.ieta(),
01377 mydepth);
01378
01379 if (myeta>=0 && myeta<85 &&
01380 (myphi-1)>=0 && (myphi-1)<72 &&
01381 (mydepth-1)>=0 && (mydepth-1)<4){
01382 problemfound[myeta][myphi-1][mydepth-1] = true;
01383
01384
01385 if(mydepth==4 && excludeHORing2_==true)
01386 if (abs(HDI.ieta())>=11 && abs(HDI.ieta())<=15 && !isSiPM(HDI.ieta(),HDI.iphi(),mydepth))
01387 problemfound[myeta][myphi-1][mydepth-1] = false;
01388
01389 if (debug_>0)
01390 std::cout<<" mapDCCproblem found error! "<<HDI.subdet()<<"("<<HDI.ieta()<<", "<<HDI.iphi()<<", "<<HDI.depth()<<")"<<std::endl;
01391 }
01392
01393 }
01394 }
01395
01396 void HcalRawDataMonitor::mapChannproblem(int dcc, int spigot, int htrchan) {
01397 int myeta = 0;
01398 int myphi =-1;
01399 int mydepth = 0;
01400 HcalDetId HDI;
01401
01402 int i=hashup(dcc,spigot,htrchan);
01403 HDI = HashToHDI(i);
01404 if (HDI==HcalDetId::Undefined) {
01405 return;
01406 }
01407 mydepth = HDI.depth();
01408 myphi = HDI.iphi();
01409 myeta = CalcEtaBin(HDI.subdet(),
01410 HDI.ieta(),
01411 mydepth);
01412
01413 if (myeta>=0 && myeta<85 &&
01414 (myphi-1)>=0 && (myphi-1)<72 &&
01415 (mydepth-1)>=0 && (mydepth-1)<4){
01416 problemfound[myeta][myphi-1][mydepth-1] = true;
01417
01418
01419 if(mydepth==4 && excludeHORing2_==true)
01420 if (abs(HDI.ieta())>=11 && abs(HDI.ieta())<=15 && !isSiPM(HDI.ieta(),HDI.iphi(),mydepth))
01421 problemfound[myeta][myphi-1][mydepth-1] = false;
01422
01423 if (debug_>0)
01424 std::cout<<" mapDCCproblem found error! "<<HDI.subdet()<<"("<<HDI.ieta()<<", "<<HDI.iphi()<<", "<<HDI.depth()<<")"<<std::endl;
01425 }
01426 }
01427
01428
01429 DEFINE_FWK_MODULE(HcalRawDataMonitor);
01430