00001 #include "DQM/HcalMonitorTasks/interface/HcalEEUSMonitor.h"
00002
00003
00004 #define PI 3.1415926535897932
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 HcalEEUSMonitor::HcalEEUSMonitor()
00017 {
00018 for (int f=0; f<NUMFEDS;f++){
00019 for (int s=0; s<NUMSPIGS; s++) {
00020 consecutiveEETriggers[f][s] = 0;
00021 consecutiveNETriggers[f][s] = 0;
00022 consecutiveTriggers[f][s] = 0;
00023 prevWasEE[f][s] = 0;}}
00024
00025
00026 for (int f=0; f<NUMFEDS; f++) {
00027 for (int s=0; s<NUMSPIGS; s++) {
00028 UScount[f][s] = 0;
00029 }
00030 }
00031
00032
00033
00034 for (int f=0; f<NUMFEDS; f++) {
00035 for (int s=0; s<NUMSPIGS; s++) {
00036 US0EE0count[f][s] = 0;
00037 }
00038 }
00039
00040
00041 for (int f=0; f<NUMFEDS; f++) {
00042 for (int s=0; s<NUMSPIGS; s++) {
00043 US0EE1count[f][s] = 0;
00044 }
00045 }
00046
00047
00048 for (int f=0; f<NUMFEDS; f++) {
00049 for (int s=0; s<NUMSPIGS; s++) {
00050 US1EE0count[f][s] = 0;
00051 }
00052 }
00053
00054
00055 for (int f=0; f<NUMFEDS; f++) {
00056 for (int s=0; s<NUMSPIGS; s++) {
00057 US1EE1count[f][s] = 0;
00058 }
00059 }
00060
00061
00062 }
00063
00064
00065 HcalEEUSMonitor::~HcalEEUSMonitor() {}
00066
00067 void HcalEEUSMonitor::reset() {}
00068
00069 void HcalEEUSMonitor::clearME()
00070 {
00071 if (m_dbe)
00072 {
00073 m_dbe->setCurrentFolder(baseFolder_);
00074 m_dbe->removeContents();
00075 }
00076 meEVT_=0;
00077 }
00078
00079
00080 void HcalEEUSMonitor::setup(const edm::ParameterSet& ps, DQMStore* dbe)
00081 {
00082 HcalBaseMonitor::setup(ps,dbe);
00083
00084 ievt_=0;
00085 baseFolder_ = rootFolder_ + "EEUSMonitor";
00086 if (fVerbosity) std::cout <<"<HcalEEUSMonitor::setup> Setup in progress"<<std::endl;
00087
00088
00089 if(fVerbosity) std::cout << "About to pushback fedUnpackList_" << std::endl;
00090 firstFED_ = FEDNumbering::MINHCALFEDID;
00091 if (fVerbosity>0) std::cout <<"FIRST FED = "<<firstFED_<<std::endl;
00092
00093 for (int i=FEDNumbering::MINHCALFEDID;
00094 i<=FEDNumbering::MAXHCALFEDID; ++i)
00095 {
00096 if(fVerbosity) std::cout << "<HcalEEUSMonitor::setup>:Pushback for fedUnpackList_: " << i <<std::endl;
00097 fedUnpackList_.push_back(i);
00098 }
00099
00100
00101
00102 if (m_dbe)
00103 {
00104 std::string type;
00105 m_dbe->setCurrentFolder(baseFolder_);
00106 meEVT_ = m_dbe->bookInt("EEUSMonitor Event Number");
00107
00108 char label[10];
00109
00110
00111
00112
00113 type = "Fraction Normal Events - US0 EE0";
00114 meNormFractSpigs_US0_EE0_ = m_dbe->book1D(type,type,481,0,481);
00115 for(int f=0; f<NUMFEDS; f++) {
00116 sprintf(label, "FED 7%02d", f);
00117 meNormFractSpigs_US0_EE0_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f), label);
00118 for(int s=1; s<HcalDCCHeader::SPIGOT_COUNT; s++) {
00119 sprintf(label, "sp%02d", s-1);
00120 meNormFractSpigs_US0_EE0_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f)+s, label);}}
00121
00122 type = "Fraction Empty Events - US0 EE1";
00123 meEEFractSpigs_US0_EE1_ = m_dbe->book1D(type,type,481,0,481);
00124 for(int f=0; f<NUMFEDS; f++) {
00125 sprintf(label, "FED 7%02d", f);
00126 meEEFractSpigs_US0_EE1_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f), label);
00127 for(int s=1; s<HcalDCCHeader::SPIGOT_COUNT; s++) {
00128 sprintf(label, "sp%02d", s-1);
00129 meEEFractSpigs_US0_EE1_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f)+s, label);}}
00130
00131 type = "Fraction UnSuppressed Events - US1 EE0";
00132 meUSFractSpigs_US1_EE0_ = m_dbe->book1D(type,type,481,0,481);
00133 for(int f=0; f<NUMFEDS; f++) {
00134 sprintf(label, "FED 7%02d", f);
00135 meUSFractSpigs_US1_EE0_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f), label);
00136 for(int s=1; s<HcalDCCHeader::SPIGOT_COUNT; s++) {
00137 sprintf(label, "sp%02d", s-1);
00138 meUSFractSpigs_US1_EE0_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f)+s, label);}}
00139
00140 type = "Fraction UnSuppressed Events - US1 EE1";
00141 meUSFractSpigs_US1_EE1_ = m_dbe->book1D(type,type,481,0,481);
00142 for(int f=0; f<NUMFEDS; f++) {
00143 sprintf(label, "FED 7%02d", f);
00144 meUSFractSpigs_US1_EE1_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f), label);
00145 for(int s=1; s<HcalDCCHeader::SPIGOT_COUNT; s++) {
00146 sprintf(label, "sp%02d", s-1);
00147 meUSFractSpigs_US1_EE1_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f)+s, label);}}
00148
00149
00150
00151 type = "Length of raw data - US0 EE0";
00152 meRawDataLength2_US0_EE0_ = m_dbe->book2D(type,type,481,0,481,600,0,1200);
00153 for(int f=0; f<NUMFEDS; f++) {
00154 sprintf(label, "FED 7%02d", f);
00155 meRawDataLength2_US0_EE0_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f), label);
00156 for(int s=1; s<HcalDCCHeader::SPIGOT_COUNT; s++) {
00157 sprintf(label, "sp%02d", s-1);
00158 meRawDataLength2_US0_EE0_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f)+s, label);}}
00159
00160 type = "Length of raw data - US0 EE1";
00161 meRawDataLength2_US0_EE1_ = m_dbe->book2D(type,type,481,0,481,600,0,1200);
00162 for(int f=0; f<NUMFEDS; f++) {
00163 sprintf(label, "FED 7%02d", f);
00164 meRawDataLength2_US0_EE1_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f), label);
00165 for(int s=1; s<HcalDCCHeader::SPIGOT_COUNT; s++) {
00166 sprintf(label, "sp%02d", s-1);
00167 meRawDataLength2_US0_EE1_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f)+s, label);}}
00168
00169 type = "Length of raw data - US1 EE0";
00170 meRawDataLength2_US1_EE0_ = m_dbe->book2D(type,type,481,0,481,600,0,1200);
00171 for(int f=0; f<NUMFEDS; f++) {
00172 sprintf(label, "FED 7%02d", f);
00173 meRawDataLength2_US1_EE0_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f), label);
00174 for(int s=1; s<HcalDCCHeader::SPIGOT_COUNT; s++) {
00175 sprintf(label, "sp%02d", s-1);
00176 meRawDataLength2_US1_EE0_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f)+s, label);}}
00177
00178 type = "Length of raw data - US1 EE1";
00179 meRawDataLength2_US1_EE1_ = m_dbe->book2D(type,type,481,0,481,600,0,1200);
00180 for(int f=0; f<NUMFEDS; f++) {
00181 sprintf(label, "FED 7%02d", f);
00182 meRawDataLength2_US1_EE1_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f), label);
00183 for(int s=1; s<HcalDCCHeader::SPIGOT_COUNT; s++) {
00184 sprintf(label, "sp%02d", s-1);
00185 meRawDataLength2_US1_EE1_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f)+s, label);}}
00186
00187
00188
00189
00190
00191 type="EE Spigot Correlation";
00192 meEECorrel_ = m_dbe->book2D(type, type,
00193 (NUMSPIGS * NUMFEDS), 0, (NUMSPIGS * NUMFEDS),
00194 (NUMSPIGS * NUMFEDS), 0, (NUMSPIGS * NUMFEDS));
00195 type="EE per Spigot";
00196 meEEPerSpigot_ = m_dbe->book1D(type, type,
00197 (NUMSPIGS * NUMFEDS), 0, (NUMSPIGS * NUMFEDS));
00198 type="EE Spigots per Event";
00199 meEEThisEvent_ = m_dbe->book1D(type, type,500,-0.5,499.5);
00200
00201
00202
00203 char title[128];
00204 sprintf(title, "EE Triggers");
00205 meNumberEETriggered_ = m_dbe->book2D(title,title,(NUMSPIGS * NUMFEDS),0,(NUMSPIGS * NUMFEDS),100,-0.5,99.5);
00206 sprintf(title, "NE Triggers");
00207 meNumberNETriggered_ = m_dbe->book2D(title,title,(NUMSPIGS * NUMFEDS),0,(NUMSPIGS * NUMFEDS),100,-0.5,99.5);
00208 sprintf(title, "Triggers");
00209 meNumberTriggered_ = m_dbe->book2D(title,title,(NUMSPIGS * NUMFEDS),0,(NUMSPIGS * NUMFEDS),100,-0.5,99.5);
00210
00211 for (int f=0; f<NUMFEDS;f++){
00212 sprintf(label, "DCC 7%02d", f);
00213 meEECorrel_->setBinLabel(1+(f*NUMSPIGS), label, 1);
00214 meEECorrel_->setBinLabel(1+(f*NUMSPIGS), label, 2);
00215 meEEPerSpigot_->setBinLabel(1+(f*NUMSPIGS), label, 1);
00216 meNumberEETriggered_->setBinLabel(1+(f*NUMSPIGS), label, 1);
00217 meNumberNETriggered_->setBinLabel(1+(f*NUMSPIGS), label, 1);
00218 meNumberTriggered_->setBinLabel(1+(f*NUMSPIGS), label, 1);
00219 for (int s=1; s<NUMSPIGS; s+=2) {
00220 sprintf(label, "Spgt %02d", s-1);
00221 meEECorrel_->setBinLabel((f*NUMSPIGS)+s+1, label, 1);
00222 meEECorrel_->setBinLabel((f*NUMSPIGS)+s+1, label, 2);
00223 meEEPerSpigot_->setBinLabel((f*NUMSPIGS)+s+1, label, 1);
00224 meNumberEETriggered_->setBinLabel((f*NUMSPIGS)+s+1, label, 1);
00225 meNumberNETriggered_->setBinLabel((f*NUMSPIGS)+s+1, label, 1);
00226 meNumberTriggered_->setBinLabel((f*NUMSPIGS)+s+1, label, 1);}}
00227
00228 prevOrN = -1;
00229 }
00230
00231 return;
00232
00233 }
00234
00235
00236 void HcalEEUSMonitor::processEvent( const FEDRawDataCollection& rawraw,
00237 const HcalUnpackerReport& report,
00238 const HcalElectronicsMap& emap
00239 )
00240
00241 {
00242 if (!m_dbe)
00243 {
00244 if (fVerbosity) std::cout <<"HcalEEUSMonitor::processEvent DQMStore not instantiated!!!"<<std::endl;
00245 return;
00246 }
00247
00248
00249 ievt_++;
00250 meEVT_->Fill(ievt_);
00251
00252
00253
00254 for (int i=0; i<(NUMSPIGS*NUMFEDS); i++)
00255 EEthisEvent[i]=false;
00256
00257 processEvent_RawData(rawraw, report, emap);
00258 prevOrN=dccOrN;
00259 return;
00260 }
00261
00262
00263 void HcalEEUSMonitor::processEvent_RawData(const FEDRawDataCollection& rawraw,
00264 const HcalUnpackerReport& report,
00265 const HcalElectronicsMap& emap)
00266 {
00267
00268
00269
00270
00271
00272
00273
00274
00275 if(!m_dbe)
00276 {
00277 std::cout <<"HcalEEUSMonitor::processEvent_RawData: DQMStore not instantiated!!!\n"<<std::endl;
00278 return;
00279 }
00280 numEEthisEvent = 0;
00281
00282 for (std::vector<int>::const_iterator i=fedUnpackList_.begin();i!=fedUnpackList_.end(); i++)
00283 {
00284 const FEDRawData& fed = rawraw.FEDData(*i);
00285 if (fed.size()<12) continue;
00286 unpack(fed,emap);
00287 }
00288
00289 prevOrN=dccOrN;
00290 meEEThisEvent_->Fill(numEEthisEvent);
00291 numEEthisEvent = 0;
00292
00293
00294
00295 for (int outer=0; outer<(NUMSPIGS*NUMFEDS); outer++)
00296 if (EEthisEvent[outer])
00297 for (int inner=0; inner<(NUMSPIGS*NUMFEDS); inner++)
00298 if (EEthisEvent[inner])
00299 meEECorrel_->Fill(outer, inner);
00300
00301 return;
00302
00303 }
00304
00305
00306
00307
00308 void HcalEEUSMonitor::unpack(const FEDRawData& raw,
00309 const HcalElectronicsMap& emap)
00310 {
00311
00312
00313
00314
00315
00316
00317 const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(raw.data());
00318 if(!dccHeader) return;
00319
00320
00321 unsigned char* trailer_ptr = (unsigned char*) (raw.data()+raw.size()-sizeof(uint64_t));
00322 FEDTrailer trailer = FEDTrailer(trailer_ptr);
00323
00324
00325
00326
00327 int dccid = dccHeader->getSourceId();
00328
00329 dccOrN = dccHeader->getOrbitNumber();
00330
00331
00332
00333
00334
00335
00336
00337 unsigned char WholeErrorList=0;
00338 for(int j=0; j<HcalDCCHeader::SPIGOT_COUNT; j++) {
00339 WholeErrorList=dccHeader->getSpigotErrorBits((unsigned int) j);
00340
00341 if ((WholeErrorList>>2)&0x01) EEthisEvent[(NUMSPIGS *std::max(0,dccid-700))+j] = true;
00342 }
00343
00344
00345
00346
00347 HcalHTRData htr;
00348 for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) {
00349 if (!dccHeader->getSpigotPresent(spigot)) continue;
00350
00351
00352
00353
00354
00355 WholeErrorList=dccHeader->getLRBErrorBits((unsigned int) spigot);
00356
00357 dccHeader->getSpigotData(spigot,htr, raw.size());
00358 const unsigned short* HTRraw = htr.getRawData();
00359 unsigned short HTRwdcount = HTRraw[htr.getRawLength() - 2];
00360
00361
00362
00363 HTRwdcount=htr.getRawLength();
00364
00365
00366
00367 int NTP = ((htr.getExtHdr6() >> 8) & 0x00FF);
00368 int NDAQ = (HTRraw[htr.getRawLength() - 4] & 0x7FF);
00369
00370 int here=1+(HcalDCCHeader::SPIGOT_COUNT*(dccid-700))+spigot;
00371
00372 if ( ! ((HTRwdcount != 8) ||
00373 (HTRwdcount != 12 + NTP + NDAQ) ||
00374 (HTRwdcount != 20 + NTP + NDAQ) )) {
00375
00376
00377 continue; }
00378 bool EE = ((dccHeader->getSpigotErrorBits(spigot) >> 2) & 0x01);
00379 if (EE) {
00380 numEEthisEvent++;
00381 meEEPerSpigot_->Fill(here);
00382 if (HTRwdcount != 8) {
00383
00384
00385 continue;}}
00386 else{
00387 if ((HTRwdcount-NDAQ-NTP) != 20) {
00388
00389
00390 continue;}}
00391
00392
00393 if(dccOrN==prevOrN){
00394 consecutiveTriggers[dccid-700][spigot]++;
00395 if(prevWasEE[dccid-700][spigot]) {
00396 if (EE) consecutiveEETriggers[dccid-700][spigot]++;
00397 else {
00398 meNumberEETriggered_->Fill(here,consecutiveEETriggers[dccid-700][spigot]);
00399 consecutiveEETriggers[dccid-700][spigot] = 0;
00400 consecutiveNETriggers[dccid-700][spigot]++;}}
00401 else {
00402 if(!EE) consecutiveNETriggers[dccid-700][spigot]++;
00403 else {
00404 meNumberNETriggered_->Fill(here,consecutiveNETriggers[dccid-700][spigot]);
00405 consecutiveNETriggers[dccid-700][spigot] = 0;
00406 consecutiveEETriggers[dccid-700][spigot]++;}}}
00407 else {
00408 if (prevOrN>-1) {
00409 meNumberTriggered_->Fill(here,consecutiveTriggers[dccid-700][spigot]);
00410 meNumberEETriggered_->Fill(here,consecutiveEETriggers[dccid-700][spigot]);
00411 meNumberNETriggered_->Fill(here,consecutiveNETriggers[dccid-700][spigot]);}
00412 consecutiveTriggers[dccid-700][spigot] = 1;
00413 if(EE) {
00414 consecutiveEETriggers[dccid-700][spigot] = 1;
00415 consecutiveNETriggers[dccid-700][spigot] = 0;}
00416 else {
00417 consecutiveEETriggers[dccid-700][spigot] = 0;
00418 consecutiveNETriggers[dccid-700][spigot] = 1;}}
00419
00420
00421
00422
00423
00424 if (EE) prevWasEE[dccid-700][spigot] = 1;
00425 else prevWasEE[dccid-700][spigot] = 0;
00426
00427 if (htr.isHistogramEvent()) continue;
00428
00429 bool htrUnSuppressed=(HTRraw[6]>>15 & 0x0001);
00430
00431 bool htrEmpty=(HTRraw[2] & 0x4);
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442 if (htrUnSuppressed==false && htrEmpty==false){
00443 US0EE0count[dccid-700][spigot]++;
00444 meNormFractSpigs_US0_EE0_->setBinContent(here,
00445 ((double)US0EE0count[dccid-700][spigot])/(double)ievt_);
00446 meRawDataLength2_US0_EE0_->Fill(here-1, HTRwdcount);
00447 }
00448
00449 if (htrUnSuppressed==false && htrEmpty==true){
00450 US0EE1count[dccid-700][spigot]++;
00451 meEEFractSpigs_US0_EE1_->setBinContent(here,
00452 ((double)US0EE1count[dccid-700][spigot])/(double)ievt_);
00453 meRawDataLength2_US0_EE1_->Fill(here-1, HTRwdcount);
00454 }
00455
00456 if (htrUnSuppressed==true && htrEmpty==false){
00457 US1EE0count[dccid-700][spigot]++;
00458 meUSFractSpigs_US1_EE0_->setBinContent(here,
00459 ((double)US1EE0count[dccid-700][spigot])/(double)ievt_);
00460 meRawDataLength2_US1_EE0_->Fill(here-1, HTRwdcount);
00461 }
00462
00463 if (htrUnSuppressed==true && htrEmpty==true){
00464 US1EE1count[dccid-700][spigot]++;
00465 meUSFractSpigs_US1_EE1_->setBinContent(here,
00466 ((double)US1EE1count[dccid-700][spigot])/(double)ievt_);
00467 meRawDataLength2_US1_EE1_->Fill(here-1, HTRwdcount);
00468 }
00469
00470
00471
00472 }
00473
00474
00475
00476
00477
00478
00479
00480
00481 if (!dccHeader->thereIsASecondCDFHeaderWord())
00482 {
00483 std::cout <<"No second CDF header found!"<<std::endl;
00484 }
00485
00486 return;
00487 }