CMS 3D CMS Logo

HcalDataFormatMonitor.cc

Go to the documentation of this file.
00001 #include "DQM/HcalMonitorTasks/interface/HcalDataFormatMonitor.h"
00002 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00003 #include "DataFormats/FEDRawData/interface/FEDTrailer.h"
00004 #include "DQMServices/Core/interface/DQMStore.h"
00005 #include "DQMServices/Core/interface/MonitorElement.h"
00006 
00007 HcalDataFormatMonitor::HcalDataFormatMonitor() {
00008 
00009   //Initialize phatmap to a vector of vectors of uint64_t 0
00010   static size_t iphirange = IPHIMAX - IPHIMIN;
00011   static size_t ietarange = IETAMAX - IETAMIN;
00012  
00013   std::vector<uint64_t> phatv (iphirange + 1, 0);
00014   // ... nothing goes at ieta=0, so an extra bin goes there.
00015   phatmap = vector< vector < uint64_t> > ( ietarange + 1, phatv);
00016   HBmap   = vector< vector < uint64_t> > ( ietarange + 1, phatv);
00017   HEmap   = vector< vector < uint64_t> > ( ietarange + 1, phatv);
00018   HFmap   = vector< vector < uint64_t> > ( ietarange + 1, phatv);
00019   HOmap   = vector< vector < uint64_t> > ( ietarange + 1, phatv);
00020   std::vector<bool> probvect (iphirange + 1, 0);
00021   // ... nothing goes at ieta=0, so an extra bin goes there.
00022   problemhere = vector< vector <bool> > ( ietarange + 1, probvect);
00023   problemHB   = vector< vector <bool> > ( ietarange + 1, probvect);
00024   problemHE   = vector< vector <bool> > ( ietarange + 1, probvect);
00025   problemHF   = vector< vector <bool> > ( ietarange + 1, probvect);
00026   problemHO   = vector< vector <bool> > ( ietarange + 1, probvect);
00027 
00028   meChann_DataIntegrityCheck_[0] =meCh_DataIntegrityFED00_;
00029   meChann_DataIntegrityCheck_[1] =meCh_DataIntegrityFED01_;
00030   meChann_DataIntegrityCheck_[2] =meCh_DataIntegrityFED02_;
00031   meChann_DataIntegrityCheck_[3] =meCh_DataIntegrityFED03_;
00032   meChann_DataIntegrityCheck_[4] =meCh_DataIntegrityFED04_;
00033   meChann_DataIntegrityCheck_[5] =meCh_DataIntegrityFED05_;
00034   meChann_DataIntegrityCheck_[6] =meCh_DataIntegrityFED06_;
00035   meChann_DataIntegrityCheck_[7] =meCh_DataIntegrityFED07_;
00036   meChann_DataIntegrityCheck_[8] =meCh_DataIntegrityFED08_;
00037   meChann_DataIntegrityCheck_[9] =meCh_DataIntegrityFED09_;
00038   meChann_DataIntegrityCheck_[10]=meCh_DataIntegrityFED10_;
00039   meChann_DataIntegrityCheck_[11]=meCh_DataIntegrityFED11_;
00040   meChann_DataIntegrityCheck_[12]=meCh_DataIntegrityFED12_;
00041   meChann_DataIntegrityCheck_[13]=meCh_DataIntegrityFED13_;
00042   meChann_DataIntegrityCheck_[14]=meCh_DataIntegrityFED14_;
00043   meChann_DataIntegrityCheck_[15]=meCh_DataIntegrityFED15_;
00044   meChann_DataIntegrityCheck_[16]=meCh_DataIntegrityFED16_;
00045   meChann_DataIntegrityCheck_[17]=meCh_DataIntegrityFED17_;
00046   meChann_DataIntegrityCheck_[18]=meCh_DataIntegrityFED18_;
00047   meChann_DataIntegrityCheck_[19]=meCh_DataIntegrityFED19_;
00048   meChann_DataIntegrityCheck_[20]=meCh_DataIntegrityFED20_;
00049   meChann_DataIntegrityCheck_[21]=meCh_DataIntegrityFED21_;
00050   meChann_DataIntegrityCheck_[22]=meCh_DataIntegrityFED22_;
00051   meChann_DataIntegrityCheck_[23]=meCh_DataIntegrityFED23_;
00052   meChann_DataIntegrityCheck_[24]=meCh_DataIntegrityFED24_;
00053   meChann_DataIntegrityCheck_[25]=meCh_DataIntegrityFED25_;
00054   meChann_DataIntegrityCheck_[26]=meCh_DataIntegrityFED26_;
00055   meChann_DataIntegrityCheck_[27]=meCh_DataIntegrityFED27_;
00056   meChann_DataIntegrityCheck_[28]=meCh_DataIntegrityFED28_;
00057   meChann_DataIntegrityCheck_[29]=meCh_DataIntegrityFED29_;
00058   meChann_DataIntegrityCheck_[30]=meCh_DataIntegrityFED30_;
00059   meChann_DataIntegrityCheck_[31]=meCh_DataIntegrityFED31_;
00060 
00061   for (int f=0; f<NUMDCCS; f++) {
00062     for (int s=0; s<15; s++) {
00063       UScount[f][s]=0;}}
00064 
00065   for (int x=0; x<RCDIX; x++)
00066     for (int y=0; y<RCDIY; y++)
00067       DCC_DataIntegrityCheck_      [x][y]=0;    
00068 
00069   for (int x=0; x<HHDIX; x++)
00070     for (int y=0; y<HHDIY; y++)
00071       HalfHTR_DataIntegrityCheck_  [x][y]=0;
00072          
00073   for (int x=0; x<CSDIX; x++)
00074     for (int y=0; y<HHDIY; y++)
00075       ChannSumm_DataIntegrityCheck_[x][y]=0;
00076 
00077   for (int f=0; f<NUMDCCS; f++)
00078     for (int x=0; x<CIX; x++)
00079       for (int y=0; y<CIY; y++)      
00080         Chann_DataIntegrityCheck_  [f][x][y]=0;
00081 
00082 } // HcalDataFormatMonitor::HcalDataFormatMonitor()
00083 
00084 HcalDataFormatMonitor::~HcalDataFormatMonitor() {}
00085 
00086 void HcalDataFormatMonitor::reset(){}
00087 
00088 void HcalDataFormatMonitor::clearME(){
00089   if(m_dbe){
00090     m_dbe->setCurrentFolder(baseFolder_);
00091     m_dbe->removeContents();
00092   }
00093 }
00094 
00095 
00096 void HcalDataFormatMonitor::setup(const edm::ParameterSet& ps,
00097                                   DQMStore* dbe){
00098   HcalBaseMonitor::setup(ps,dbe);
00099   
00100   ievt_=0;
00101   baseFolder_ = rootFolder_+"DataFormatMonitor";
00102 
00103   if(fVerbosity) cout << "About to pushback fedUnpackList_" << endl;
00104   firstFED_ = FEDNumbering::getHcalFEDIds().first;
00105   for (int i=FEDNumbering::getHcalFEDIds().first; i<=FEDNumbering::getHcalFEDIds().second; i++) {
00106     if(fVerbosity) cout << "[DFMon:]Pushback for fedUnpackList_: " << i <<endl;
00107     fedUnpackList_.push_back(i);
00108   }
00109 
00110   prtlvl_ = ps.getUntrackedParameter<int>("dfPrtLvl");
00111   dfmon_checkNevents = ps.getUntrackedParameter<int>("DataFormatMonitor_checkNevents",checkNevents_);
00112 
00113   if ( m_dbe ) {
00114     char* type;
00115     m_dbe->setCurrentFolder(baseFolder_);
00116     
00162 
00163     meEVT_ = m_dbe->bookInt("Data Format Task Event Number");
00164     meEVT_->Fill(ievt_);    
00165 
00166     m_dbe->setCurrentFolder(baseFolder_ + "/HcalFEDChecking");
00167     
00168     type="FEDEntries";
00169     fedEntries_ = m_dbe->book1D(type,type,32,699.5,731.5);
00170     type="FEDFatal";
00171     fedFatal_ = m_dbe->book1D(type,type,32,699.5,731.5);
00172 
00173     m_dbe->setCurrentFolder(baseFolder_);
00174     type="Readout Chain DataIntegrity Check";
00175     meDCC_DataIntegrityCheck_ = m_dbe->book2D(type,type,
00176                                               RCDIX,0,RCDIX,
00177                                               RCDIY,0,RCDIY);
00178     //    meDCC_DataIntegrityCheck_->setAxisTitle("Crate/FED",1);  //Apply label in RenderPlugins, out of the way...
00179     meDCC_DataIntegrityCheck_->setBinLabel( 1," 0 702",1);
00180     meDCC_DataIntegrityCheck_->setBinLabel( 2," 0/703",1); //skip 3
00181     meDCC_DataIntegrityCheck_->setBinLabel( 4," 1 704",1);
00182     meDCC_DataIntegrityCheck_->setBinLabel( 5," 1/705",1); //skip 6
00183     meDCC_DataIntegrityCheck_->setBinLabel( 7," 2 718",1);
00184     meDCC_DataIntegrityCheck_->setBinLabel( 8," 2/719",1); //skip 9 
00185     meDCC_DataIntegrityCheck_->setBinLabel(10," 3 724",1);
00186     meDCC_DataIntegrityCheck_->setBinLabel(11," 3/725",1); //skip 12
00187     meDCC_DataIntegrityCheck_->setBinLabel(13," 4 700",1); 
00188     meDCC_DataIntegrityCheck_->setBinLabel(14," 4/701",1); //skip 15
00189     meDCC_DataIntegrityCheck_->setBinLabel(16," 5 706",1);
00190     meDCC_DataIntegrityCheck_->setBinLabel(17," 5/707",1); //skip 18
00191     meDCC_DataIntegrityCheck_->setBinLabel(19," 6 728",1);
00192     meDCC_DataIntegrityCheck_->setBinLabel(20," 6/729",1); //skip 21
00193     meDCC_DataIntegrityCheck_->setBinLabel(22," 7 726",1); 
00194     meDCC_DataIntegrityCheck_->setBinLabel(23," 7/727",1); //skip 24-27
00195     meDCC_DataIntegrityCheck_->setBinLabel(28," 9 720",1);
00196     meDCC_DataIntegrityCheck_->setBinLabel(29," 9/721",1); //skip 30
00197     meDCC_DataIntegrityCheck_->setBinLabel(31,"10 716",1); 
00198     meDCC_DataIntegrityCheck_->setBinLabel(32,"10/717",1); //skip 33
00199     meDCC_DataIntegrityCheck_->setBinLabel(34,"11 708",1);
00200     meDCC_DataIntegrityCheck_->setBinLabel(35,"11/709",1); //skip 36
00201     meDCC_DataIntegrityCheck_->setBinLabel(37,"12 722",1);
00202     meDCC_DataIntegrityCheck_->setBinLabel(38,"12/723",1); //skip 39
00203     meDCC_DataIntegrityCheck_->setBinLabel(40,"13 730",1);
00204     meDCC_DataIntegrityCheck_->setBinLabel(41,"13/731",1); //skip 42
00205     meDCC_DataIntegrityCheck_->setBinLabel(43,"14 714",1);
00206     meDCC_DataIntegrityCheck_->setBinLabel(44,"14/715",1); //skip 45
00207     meDCC_DataIntegrityCheck_->setBinLabel(46,"15 710",1);
00208     meDCC_DataIntegrityCheck_->setBinLabel(47,"15/711",1); //skip 48-51
00209     meDCC_DataIntegrityCheck_->setBinLabel(52,"17 712",1);
00210     meDCC_DataIntegrityCheck_->setBinLabel(53,"17/713",1); //leave 54
00211     meDCC_DataIntegrityCheck_->setBinLabel(22,"    TTS",2); // TTS state         
00212     meDCC_DataIntegrityCheck_->setBinLabel(21,"    Rdy",2);              
00213     meDCC_DataIntegrityCheck_->setBinLabel(20,"    OFW",2);               
00214     meDCC_DataIntegrityCheck_->setBinLabel(19,"    BSY",2);              
00215     meDCC_DataIntegrityCheck_->setBinLabel(18,"    SYN",2);              
00216     meDCC_DataIntegrityCheck_->setBinLabel(17,"HTRStat",2); // HTR State  
00217     meDCC_DataIntegrityCheck_->setBinLabel(16,"     OW",2);              
00218     meDCC_DataIntegrityCheck_->setBinLabel(15,"     BZ",2);              
00219     meDCC_DataIntegrityCheck_->setBinLabel(14,"Num Mis",2); //Num Mis    
00220     meDCC_DataIntegrityCheck_->setBinLabel(13,"    EvNt",2)              ;
00221     meDCC_DataIntegrityCheck_->setBinLabel(12,"    BcN",2);              
00222     meDCC_DataIntegrityCheck_->setBinLabel(11,"    OrN",2);              
00223     meDCC_DataIntegrityCheck_->setBinLabel(10,"DataLos",2); //Data Lost  
00224     meDCC_DataIntegrityCheck_->setBinLabel( 9,"    HTR",2);               
00225     meDCC_DataIntegrityCheck_->setBinLabel( 8,"    LRB",2);              
00226     meDCC_DataIntegrityCheck_->setBinLabel( 7,"    DCC",2);              
00227     meDCC_DataIntegrityCheck_->setBinLabel( 6,"LinkErr",2); //LinkErrs   
00228     meDCC_DataIntegrityCheck_->setBinLabel( 5,"    FEE",2);               
00229     meDCC_DataIntegrityCheck_->setBinLabel( 4,"    HTR",2);              
00230     meDCC_DataIntegrityCheck_->setBinLabel( 3,"FmtErrs",2);              
00231     meDCC_DataIntegrityCheck_->setBinLabel( 2,"   Size",2); //FmtErrs    
00232     meDCC_DataIntegrityCheck_->setBinLabel( 1,"       ",2);
00233 
00234     m_dbe->setCurrentFolder(baseFolder_ + "/HTR Plots");
00235     type="Half-HTR DataIntegrity Check";
00236     meHalfHTR_DataIntegrityCheck_= m_dbe->book2D(type,type,
00237                                                  HHDIX,0,HHDIX,
00238                                                  HHDIY,0,HHDIY);
00239     meHalfHTR_DataIntegrityCheck_->setBinLabel( 2,"700",1);
00240     meHalfHTR_DataIntegrityCheck_->setBinLabel( 5,"701",1);
00241     meHalfHTR_DataIntegrityCheck_->setBinLabel( 8,"702",1);
00242     meHalfHTR_DataIntegrityCheck_->setBinLabel(11,"703",1);
00243     meHalfHTR_DataIntegrityCheck_->setBinLabel(14,"704",1);
00244     meHalfHTR_DataIntegrityCheck_->setBinLabel(17,"705",1);
00245     meHalfHTR_DataIntegrityCheck_->setBinLabel(20,"706",1);
00246     meHalfHTR_DataIntegrityCheck_->setBinLabel(23,"707",1);
00247     meHalfHTR_DataIntegrityCheck_->setBinLabel(26,"708",1);
00248     meHalfHTR_DataIntegrityCheck_->setBinLabel(29,"709",1);
00249     meHalfHTR_DataIntegrityCheck_->setBinLabel(32,"710",1);
00250     meHalfHTR_DataIntegrityCheck_->setBinLabel(35,"711",1);
00251     meHalfHTR_DataIntegrityCheck_->setBinLabel(38,"712",1);
00252     meHalfHTR_DataIntegrityCheck_->setBinLabel(41,"713",1);
00253     meHalfHTR_DataIntegrityCheck_->setBinLabel(44,"714",1);
00254     meHalfHTR_DataIntegrityCheck_->setBinLabel(47,"715",1);
00255     meHalfHTR_DataIntegrityCheck_->setBinLabel(50,"716",1);
00256     meHalfHTR_DataIntegrityCheck_->setBinLabel(53,"717",1);
00257     meHalfHTR_DataIntegrityCheck_->setBinLabel(56,"718",1);
00258     meHalfHTR_DataIntegrityCheck_->setBinLabel(59,"719",1);
00259     meHalfHTR_DataIntegrityCheck_->setBinLabel(62,"720",1);
00260     meHalfHTR_DataIntegrityCheck_->setBinLabel(65,"721",1);
00261     meHalfHTR_DataIntegrityCheck_->setBinLabel(68,"722",1);
00262     meHalfHTR_DataIntegrityCheck_->setBinLabel(71,"723",1);
00263     meHalfHTR_DataIntegrityCheck_->setBinLabel(74,"724",1);
00264     meHalfHTR_DataIntegrityCheck_->setBinLabel(77,"725",1);
00265     meHalfHTR_DataIntegrityCheck_->setBinLabel(80,"726",1);
00266     meHalfHTR_DataIntegrityCheck_->setBinLabel(83,"727",1);
00267     meHalfHTR_DataIntegrityCheck_->setBinLabel(86,"728",1);
00268     meHalfHTR_DataIntegrityCheck_->setBinLabel(89,"729",1);
00269     meHalfHTR_DataIntegrityCheck_->setBinLabel(92,"730",1);
00270     meHalfHTR_DataIntegrityCheck_->setBinLabel(95,"731",1);
00271     label_ySpigots(meHalfHTR_DataIntegrityCheck_, 4); // 3 bins + 1 margin each spgt
00272 
00273     type = "Channel Integrity Summarized by Spigot";
00274     meChannSumm_DataIntegrityCheck_= m_dbe->book2D(type,type,
00275                                                    CSDIX,0,CSDIX,
00276                                                    HHDIY,0,HHDIY);
00277     label_xFEDs (meChannSumm_DataIntegrityCheck_, 3); // 2 bins + 1 margin per ch.
00278     label_ySpigots(meChannSumm_DataIntegrityCheck_, 4); // 3 bins + 1 margin per spgt
00279  
00280     m_dbe->setCurrentFolder(baseFolder_ + "/HTR Plots/ Channel Data Integrity");
00281     char label[10];
00282     for (int f=0; f<NUMDCCS; f++){      
00283       sprintf(label, "FED %03d Channel Integrity", f+700);
00284       meChann_DataIntegrityCheck_[f] =  m_dbe->book2D(label,label,
00285                               CIX,0,CIX,
00286                               CIY,0,CIY);
00287       label_xChanns (meChann_DataIntegrityCheck_[f], 3); // 2 bins + 1 margin per ch.
00288       label_ySpigots(meChann_DataIntegrityCheck_[f], 3); // 2 bins + 1 margin per spgt
00289       ;}
00290       
00291     m_dbe->setCurrentFolder(baseFolder_ + "/DCC Plots");
00292     type = "BCN from DCCs";
00293     medccBCN_ = m_dbe->book1D(type,type,3564,-0.5,3563.5);
00294     medccBCN_->setAxisTitle("BCN",1);
00295     medccBCN_->setAxisTitle("# of Entries",2);
00296 
00297 
00298     type = "DCC Error and Warning";
00299     meDCCErrorAndWarnConditions_ = m_dbe->book2D(type,type,32,699.5,731.5, 25,0.5,25.5);
00300     meDCCErrorAndWarnConditions_->setAxisTitle("HCAL FED ID", 1);      
00301     meDCCErrorAndWarnConditions_->setBinLabel( 1, "700", 1);
00302     meDCCErrorAndWarnConditions_->setBinLabel( 2, "701", 1);
00303     meDCCErrorAndWarnConditions_->setBinLabel( 3, "702", 1);
00304     meDCCErrorAndWarnConditions_->setBinLabel( 4, "703", 1);
00305     meDCCErrorAndWarnConditions_->setBinLabel( 5, "704", 1);
00306     meDCCErrorAndWarnConditions_->setBinLabel( 6, "705", 1);
00307     meDCCErrorAndWarnConditions_->setBinLabel( 7, "706", 1);
00308     meDCCErrorAndWarnConditions_->setBinLabel( 8, "707", 1);
00309     meDCCErrorAndWarnConditions_->setBinLabel( 9, "708", 1);
00310     meDCCErrorAndWarnConditions_->setBinLabel(10, "709", 1);
00311     meDCCErrorAndWarnConditions_->setBinLabel(11, "710", 1);
00312     meDCCErrorAndWarnConditions_->setBinLabel(12, "711", 1);
00313     meDCCErrorAndWarnConditions_->setBinLabel(13, "712", 1);
00314     meDCCErrorAndWarnConditions_->setBinLabel(14, "713", 1);
00315     meDCCErrorAndWarnConditions_->setBinLabel(15, "714", 1);
00316     meDCCErrorAndWarnConditions_->setBinLabel(16, "715", 1);
00317     meDCCErrorAndWarnConditions_->setBinLabel(17, "716", 1);
00318     meDCCErrorAndWarnConditions_->setBinLabel(18, "717", 1);
00319     meDCCErrorAndWarnConditions_->setBinLabel(19, "718", 1);
00320     meDCCErrorAndWarnConditions_->setBinLabel(20, "719", 1);
00321     meDCCErrorAndWarnConditions_->setBinLabel(21, "720", 1);
00322     meDCCErrorAndWarnConditions_->setBinLabel(22, "721", 1);
00323     meDCCErrorAndWarnConditions_->setBinLabel(23, "722", 1);
00324     meDCCErrorAndWarnConditions_->setBinLabel(24, "723", 1);
00325     meDCCErrorAndWarnConditions_->setBinLabel(25, "724", 1);
00326     meDCCErrorAndWarnConditions_->setBinLabel(26, "725", 1);
00327     meDCCErrorAndWarnConditions_->setBinLabel(27, "726", 1);
00328     meDCCErrorAndWarnConditions_->setBinLabel(28, "727", 1);
00329     meDCCErrorAndWarnConditions_->setBinLabel(29, "728", 1);
00330     meDCCErrorAndWarnConditions_->setBinLabel(30, "729", 1);
00331     meDCCErrorAndWarnConditions_->setBinLabel(31, "730", 1);
00332     meDCCErrorAndWarnConditions_->setBinLabel(32, "731", 1);
00333     meDCCErrorAndWarnConditions_->setBinLabel( 1, "MisM S14", 2);
00334     meDCCErrorAndWarnConditions_->setBinLabel( 2, "MisM S13", 2);
00335     meDCCErrorAndWarnConditions_->setBinLabel( 3, "MisM S12", 2);
00336     meDCCErrorAndWarnConditions_->setBinLabel( 4, "MisM S11", 2);
00337     meDCCErrorAndWarnConditions_->setBinLabel( 5, "MisM S10", 2);
00338     meDCCErrorAndWarnConditions_->setBinLabel( 6, "MisM S9", 2);
00339     meDCCErrorAndWarnConditions_->setBinLabel( 7, "MisM S8", 2);
00340     meDCCErrorAndWarnConditions_->setBinLabel( 8, "MisM S7", 2);
00341     meDCCErrorAndWarnConditions_->setBinLabel( 9, "MisM S6", 2);
00342     meDCCErrorAndWarnConditions_->setBinLabel(10, "MisM S5", 2);
00343     meDCCErrorAndWarnConditions_->setBinLabel(11, "MisM S4", 2);
00344     meDCCErrorAndWarnConditions_->setBinLabel(12, "MisM S3", 2);
00345     meDCCErrorAndWarnConditions_->setBinLabel(13, "MisM S2", 2);
00346     meDCCErrorAndWarnConditions_->setBinLabel(14, "MisM S1", 2);
00347     meDCCErrorAndWarnConditions_->setBinLabel(15, "MisM S0(top)", 2);
00348     meDCCErrorAndWarnConditions_->setBinLabel(16, "TTS_OFW", 2);
00349     meDCCErrorAndWarnConditions_->setBinLabel(17, "TTS_BSY", 2);
00350     meDCCErrorAndWarnConditions_->setBinLabel(18, "TTS_SYN", 2);
00351     meDCCErrorAndWarnConditions_->setBinLabel(19, "L1A_EvN Mis", 2);
00352     meDCCErrorAndWarnConditions_->setBinLabel(20, "L1A_BcN Mis", 2);
00353     meDCCErrorAndWarnConditions_->setBinLabel(21, "CT_EvN Mis", 2);
00354     meDCCErrorAndWarnConditions_->setBinLabel(22, "CT_BcN Mis", 2);
00355     meDCCErrorAndWarnConditions_->setBinLabel(23, "OrbitLenEr", 2);
00356     meDCCErrorAndWarnConditions_->setBinLabel(24, "TTC_SingEr", 2);
00357     meDCCErrorAndWarnConditions_->setBinLabel(25, "TTC_DoubEr", 2);
00358 
00359     type = "DCC Ev Fragment Size Distribution";
00360     meFEDRawDataSizes_=m_dbe->book1D(type,type,12000,-0.5,12000.5);
00361     meFEDRawDataSizes_->setAxisTitle("# of bytes",1);
00362     meFEDRawDataSizes_->setAxisTitle("# of Event Fragments",2);
00363 
00364     type = "DCC Nonzero Spigot Conditions";
00365     meDCCSummariesOfHTRs_ = m_dbe->book2D(type,type,32,699.5,731.5, 20,0.5,20.5);
00366     meDCCSummariesOfHTRs_->setAxisTitle("HCAL FED ID", 1);
00367     meDCCSummariesOfHTRs_->setBinLabel(1, "HTR OFW", 2);
00368     meDCCSummariesOfHTRs_->setBinLabel(2, "HTR BSY", 2);
00369     meDCCSummariesOfHTRs_->setBinLabel(3, "Empty Events", 2);
00370     meDCCSummariesOfHTRs_->setBinLabel(4, "L1A Reject", 2);
00371     meDCCSummariesOfHTRs_->setBinLabel(5, "Latency Er", 2);
00372     meDCCSummariesOfHTRs_->setBinLabel(6, "Latncy Warn", 2);
00373     meDCCSummariesOfHTRs_->setBinLabel(7, "Optcl Data Err", 2);
00374     meDCCSummariesOfHTRs_->setBinLabel(8, "Clock", 2);
00375     meDCCSummariesOfHTRs_->setBinLabel(9, "CorrHamm LRB", 2);
00376     meDCCSummariesOfHTRs_->setBinLabel(10, "UncorrHam", 2);
00377     meDCCSummariesOfHTRs_->setBinLabel(11, "LRB Block OvF", 2);
00378     meDCCSummariesOfHTRs_->setBinLabel(12, "LRB EvN Hdr/Tlr", 2);
00379     meDCCSummariesOfHTRs_->setBinLabel(13, "FIFOs Empty", 2);
00380     meDCCSummariesOfHTRs_->setBinLabel(14, "LRB Trunct", 2);
00381     meDCCSummariesOfHTRs_->setBinLabel(15, "LRB No Hdr/tlr", 2);
00382     meDCCSummariesOfHTRs_->setBinLabel(16, "Odd 16-Bit Wd Cnt", 2);
00383     meDCCSummariesOfHTRs_->setBinLabel(17, "Spgt E not P", 2);
00384     meDCCSummariesOfHTRs_->setBinLabel(18, "Spgt BcN Mis", 2);
00385     meDCCSummariesOfHTRs_->setBinLabel(19, "P not V", 2);
00386     meDCCSummariesOfHTRs_->setBinLabel(20, "Trunct by LRB", 2);
00387 
00388     // These status bits set in the header could be useful: They're set once, and stay on
00389     // even if the event in which they're set is not analyzed...
00390 
00404 
00405     type = "Event Fragment Size for each FED";
00406     meEvFragSize_ = m_dbe->bookProfile(type,type,32,699.5,731.5,100,-1000.0,12000.0,"");
00407     type = "All Evt Frag Sizes";
00408     meEvFragSize2_ =  m_dbe->book2D(type,type,64,699.5,731.5, 2000,0,12000);
00409 
00410     type = "Num Event Frags by FED";
00411     meFEDId_=m_dbe->book1D(type, type, 32, 699.5, 731.5);
00412     meFEDId_->setAxisTitle("HCAL FED ID",1);
00413 
00414     type = "Spigot Format Errors";
00415     meSpigotFormatErrors_=  m_dbe->book1D(type,type,50,-0.5,49.5);
00416     meSpigotFormatErrors_->setAxisTitle("# of Errors",1);
00417     meSpigotFormatErrors_->setAxisTitle("# of Events",2);
00418 
00419     m_dbe->setCurrentFolder(baseFolder_ + "/DCC Plots/ZZ DCC Expert Plots");
00420 
00421     type = "Common Data Format violations";
00422     meCDFErrorFound_ = m_dbe->book2D(type,type,32,699.5,731.5,10,0.5,10.5);
00423     meCDFErrorFound_->setAxisTitle("HCAL FED ID", 1);
00424     meCDFErrorFound_->setBinLabel(1, "Hdr1BitUnset", 2);
00425     meCDFErrorFound_->setBinLabel(2, "FmtNumChange", 2);
00426     meCDFErrorFound_->setBinLabel(3, "EvTypChange", 2);
00427     meCDFErrorFound_->setBinLabel(4, "BOE not '0x5'", 2);
00428     meCDFErrorFound_->setBinLabel(5, "Hdr2Bit Set", 2);
00429     meCDFErrorFound_->setBinLabel(6, "Hdr1 36-59", 2);
00430     meCDFErrorFound_->setBinLabel(7, "BOE not 0", 2);
00431     meCDFErrorFound_->setBinLabel(8, "Trlr1Bit Set", 2);
00432     meCDFErrorFound_->setBinLabel(9, "Size Error", 2);
00433     meCDFErrorFound_->setBinLabel(10, "TrailerBad", 2);
00434 
00435     type = "DCC Event Format violation";
00436     meDCCEventFormatError_ = m_dbe->book2D(type,type,32,699.5,731.5,4,0.5,4.5);
00437     meDCCEventFormatError_->setAxisTitle("HCAL FED ID", 1);
00438     meDCCEventFormatError_->setBinLabel(1, "FmtVersChng", 2);
00439     meDCCEventFormatError_->setBinLabel(2, "StrayBits", 2);
00440     meDCCEventFormatError_->setBinLabel(3, "HTRStatusPad", 2);
00441     meDCCEventFormatError_->setBinLabel(4, "32bitPadErr", 2);
00442     //meDCCEventFormatError_->setBinLabel(5, "Spigot Error Flag Miscalculated", 2);      
00443     //meDCCEventFormatError_->setBinLabel(7, "LRB Truncation Bit MisCopied", 2);               
00444     //meDCCEventFormatError_->setBinLabel(8, "32-Bit Padding Word Needed But Absent", 2);
00445     //meDCCEventFormatError_->setBinLabel(9, "Event Size Internally Misdescribed", 2);
00446 
00447     type = "FED Error Map from Unpacker Report";
00448     meFEDerrorMap_ = m_dbe->book1D(type,type,33,699.5,732.5);
00449     meFEDerrorMap_->setAxisTitle("Dcc Id",1);
00450     meFEDerrorMap_->setAxisTitle("# of Errors",2);
00451 
00452     m_dbe->setCurrentFolder(baseFolder_ + "/HTR Plots");
00453 
00454     type = "Fraction UnSuppressed Events";
00455     meUSFractSpigs_ = m_dbe->book1D(type,type,481,0,481);
00456     for(int f=0; f<NUMDCCS; f++) {
00457       sprintf(label, "FED 7%02d", f);
00458       meUSFractSpigs_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f), label);
00459       for(int s=1; s<HcalDCCHeader::SPIGOT_COUNT; s++) {
00460         sprintf(label, "sp%02d", s);
00461         meUSFractSpigs_->setBinLabel(1+(HcalDCCHeader::SPIGOT_COUNT*f)+s, label);}}
00462 
00463     type = "BCN Difference Between Ref HTR and DCC";
00464     meBCNCheck_ = m_dbe->book1D(type,type,501,-250.5,250.5);
00465     meBCNCheck_->setAxisTitle("htr BCN - dcc BCN",1);
00466 
00467     type = "BCN Inconsistent - HTR vs Ref HTR";
00468     meBCNSynch_= m_dbe->book2D(type,type,40,-0.25,19.75,18,-0.5,17.5);
00469     meBCNSynch_->setAxisTitle("Slot #",1);
00470     meBCNSynch_->setAxisTitle("Crate #",2);
00471 
00472     type = "BCN from HTRs";
00473     meBCN_ = m_dbe->book1D(type,type,3564,-0.5,3563.5);
00474     meBCN_->setAxisTitle("BCN",1);
00475     meBCN_->setAxisTitle("# of Entries",2);
00476 
00477     type = "EvN Difference Between Ref HTR and DCC";
00478     meEvtNCheck_ = m_dbe->book1D(type,type,601,-300.5,300.5);
00479     meEvtNCheck_->setAxisTitle("htr Evt # - dcc Evt #",1);
00480 
00481     type = "EvN Inconsistent - HTR vs Ref HTR";
00482     meEvtNumberSynch_= m_dbe->book2D(type,type,40,-0.25,19.75,18,-0.5,17.5);
00483     meEvtNumberSynch_->setAxisTitle("Slot #",1);
00484     meEvtNumberSynch_->setAxisTitle("Crate #",2);
00485 
00486     type = "HBHE Data Format Error Word";
00487     DCC_ErrWd_HBHE =  m_dbe->book1D(type,type,16,-0.5,15.5);
00488     labelHTRBits(DCC_ErrWd_HBHE,1);
00489 
00490     type = "HF Data Format Error Word";
00491     DCC_ErrWd_HF =  m_dbe->book1D(type,type,16,-0.5,15.5);
00492     labelHTRBits(DCC_ErrWd_HF,1);
00493   
00494     type = "HO Data Format Error Word";
00495     DCC_ErrWd_HO = m_dbe->book1D(type,type,16,-0.5,15.5);
00496     labelHTRBits(DCC_ErrWd_HO,1);
00497 
00498     int maxbits = 16;//Look at all bits
00499     type = "HTR Error Word by Crate";
00500     meErrWdCrate_ = m_dbe->book2D(type,type,18,-0.5,17.5,maxbits,-0.5,maxbits-0.5);
00501     meErrWdCrate_ -> setAxisTitle("Crate #",1);
00502     labelHTRBits(meErrWdCrate_,2);
00503 
00504     type = "Unpacking - HcalHTRData check failures";
00505     meInvHTRData_= m_dbe->book2D(type,type,16,-0.5,15.5,32,699.5,731.5);
00506     meInvHTRData_->setAxisTitle("Spigot #",1);
00507     meInvHTRData_->setAxisTitle("DCC #",2);
00508 
00509     m_dbe->setCurrentFolder(baseFolder_ + "/HTR Plots/ZZ HTR Expert Plots");
00510 
00511     type = "BCN of Fiber Orbit Message";
00512     meFibBCN_ = m_dbe->book1D(type,type,3564,-0.5,3563.5);
00513     meFibBCN_->setAxisTitle("BCN of Fib Orb Msg",1);
00514 
00515 
00516     type = "HTR Error Word - Crate 0";
00517     meCrate0HTRErr_ = m_dbe->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00518     meCrate0HTRErr_ ->setAxisTitle("Slot #",1);
00519     labelHTRBits(meCrate0HTRErr_,2);
00520 
00521     type = "HTR Error Word - Crate 1";
00522     meCrate1HTRErr_ = m_dbe->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00523     meCrate1HTRErr_ ->setAxisTitle("Slot #",1);
00524     labelHTRBits(meCrate1HTRErr_,2);
00525 
00526     type = "HTR Error Word - Crate 2";
00527     meCrate2HTRErr_ = m_dbe->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00528     meCrate2HTRErr_ ->setAxisTitle("Slot #",1);
00529     labelHTRBits(meCrate2HTRErr_,2);
00530 
00531     type = "HTR Error Word - Crate 3";
00532     meCrate3HTRErr_ = m_dbe->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00533     meCrate3HTRErr_ ->setAxisTitle("Slot #",1);
00534     labelHTRBits(meCrate3HTRErr_,2);
00535 
00536     type = "HTR Error Word - Crate 4";
00537     meCrate4HTRErr_ = m_dbe->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00538     meCrate4HTRErr_ ->setAxisTitle("Slot #",1);
00539     labelHTRBits(meCrate4HTRErr_,2);
00540 
00541     type = "HTR Error Word - Crate 5";
00542     meCrate5HTRErr_ = m_dbe->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00543     meCrate5HTRErr_ ->setAxisTitle("Slot #",1);
00544     labelHTRBits(meCrate5HTRErr_,2);
00545 
00546     type = "HTR Error Word - Crate 6";
00547     meCrate6HTRErr_ = m_dbe->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00548     meCrate6HTRErr_ ->setAxisTitle("Slot #",1);
00549     labelHTRBits(meCrate6HTRErr_,2);
00550 
00551     type = "HTR Error Word - Crate 7";
00552     meCrate7HTRErr_ = m_dbe->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00553     meCrate7HTRErr_ ->setAxisTitle("Slot #",1);
00554     labelHTRBits(meCrate7HTRErr_,2);
00555 
00556     type = "HTR Error Word - Crate 8";
00557     meCrate8HTRErr_ = m_dbe->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00558     meCrate8HTRErr_ ->setAxisTitle("Slot #",1);
00559     labelHTRBits(meCrate8HTRErr_,2);
00560 
00561     type = "HTR Error Word - Crate 9";
00562     meCrate9HTRErr_ = m_dbe->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00563     meCrate9HTRErr_ ->setAxisTitle("Slot #",1);
00564     labelHTRBits(meCrate9HTRErr_,2);
00565 
00566     type = "HTR Error Word - Crate 10";
00567     meCrate10HTRErr_ = m_dbe->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00568     meCrate10HTRErr_ ->setAxisTitle("Slot #",1);
00569     labelHTRBits(meCrate10HTRErr_,2);
00570 
00571     type = "HTR Error Word - Crate 11";
00572     meCrate11HTRErr_ = m_dbe->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00573     meCrate11HTRErr_ ->setAxisTitle("Slot #",1);
00574     labelHTRBits(meCrate11HTRErr_,2);
00575 
00576     type = "HTR Error Word - Crate 12";
00577     meCrate12HTRErr_ = m_dbe->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00578     meCrate12HTRErr_ ->setAxisTitle("Slot #",1);
00579     labelHTRBits(meCrate12HTRErr_,2);
00580 
00581     type = "HTR Error Word - Crate 13";
00582     meCrate13HTRErr_ = m_dbe->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00583     meCrate13HTRErr_ ->setAxisTitle("Slot #",1);
00584     labelHTRBits(meCrate13HTRErr_,2);
00585 
00586     type = "HTR Error Word - Crate 14";
00587     meCrate14HTRErr_ = m_dbe->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00588     meCrate14HTRErr_ ->setAxisTitle("Slot #",1);
00589     labelHTRBits(meCrate14HTRErr_,2);
00590 
00591     type = "HTR Error Word - Crate 15";
00592     meCrate15HTRErr_ = m_dbe->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00593     meCrate15HTRErr_ ->setAxisTitle("Slot #",1);
00594     labelHTRBits(meCrate15HTRErr_,2);
00595 
00596     type = "HTR Error Word - Crate 16";
00597     meCrate16HTRErr_ = m_dbe->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00598     meCrate16HTRErr_ ->setAxisTitle("Slot #",1);
00599     labelHTRBits(meCrate16HTRErr_,2);
00600 
00601     type = "HTR Error Word - Crate 17";
00602     meCrate17HTRErr_ = m_dbe->book2D(type,type,40,-0.25,19.75,maxbits,-0.5,maxbits-0.5);
00603     meCrate17HTRErr_ ->setAxisTitle("Slot #",1);
00604     labelHTRBits(meCrate17HTRErr_,2);
00605     
00606     // Firmware version
00607     type = "HTR Firmware Version";
00608     //  Maybe change to Profile histo eventually
00609     //meFWVersion_ = m_dbe->bookProfile(type,type,18,-0.5,17.5,245,10.0,255.0,"");
00610     meFWVersion_ = m_dbe->book2D(type,type ,18,-0.5,17.5,180,75.5,255.5);
00611     meFWVersion_->setAxisTitle("Crate #",1);
00612     meFWVersion_->setAxisTitle("HTR Firmware Version",2);
00613 
00614     m_dbe->setCurrentFolder(baseFolder_ + "/ZZ HCal-Wide Expert Plots");
00615 
00616     type = "Num Bad Quality Digis -DV bit-Err bit-Cap Rotation";
00617     meBadQualityDigis_=  m_dbe->book1D(type,type,9100,-1,9099);
00618     meBadQualityDigis_->setAxisTitle("# of Bad Digis",1);
00619     meBadQualityDigis_->setAxisTitle("# of Events",2);
00620 
00621     type = "Num Unmapped Digis";
00622     meUnmappedDigis_=  m_dbe->book1D(type,type,9100,-1,9099);
00623     meUnmappedDigis_->setAxisTitle("# of Unmapped Digis",1);
00624     meUnmappedDigis_->setAxisTitle("# of Events",2);
00625 
00626     type = "Num Unmapped Trigger Primitive Digis";
00627     meUnmappedTPDigis_=  m_dbe->book1D(type,type,9100,-1,9099);
00628     meUnmappedTPDigis_->setAxisTitle("# of Unmapped Trigger Primitive Digis",1);
00629     meUnmappedTPDigis_->setAxisTitle("# of Events",2);
00630 
00631     /* Disable these histos for now
00632        type = "Fiber 1 Orbit Message BCN";
00633        meFib1OrbMsgBCN_= m_dbe->book2D(type,type,40,-0.25,19.75,18,-0.5,17.5);
00634        type = "Fiber 2 Orbit Message BCN";
00635        meFib2OrbMsgBCN_= m_dbe->book2D(type,type,40,-0.25,19.75,18,-0.5,17.5);
00636        type = "Fiber 3 Orbit Message BCN";
00637        meFib3OrbMsgBCN_= m_dbe->book2D(type,type,40,-0.25,19.75,18,-0.5,17.5);
00638        type = "Fiber 4 Orbit Message BCN";
00639        meFib4OrbMsgBCN_= m_dbe->book2D(type,type,40,-0.25,19.75,18,-0.5,17.5);
00640        type = "Fiber 5 Orbit Message BCN";
00641        meFib5OrbMsgBCN_= m_dbe->book2D(type,type,40,-0.25,19.75,18,-0.5,17.5);
00642        type = "Fiber 6 Orbit Message BCN";
00643        meFib6OrbMsgBCN_= m_dbe->book2D(type,type,40,-0.25,19.75,18,-0.5,17.5);
00644        type = "Fiber 7 Orbit Message BCN";
00645        meFib7OrbMsgBCN_= m_dbe->book2D(type,type,40,-0.25,19.75,18,-0.5,17.5);
00646        type = "Fiber 8 Orbit Message BCN";
00647        meFib8OrbMsgBCN_= m_dbe->book2D(type,type,40,-0.25,19.75,18,-0.5,17.5);
00648     */
00649   
00650   }
00651 
00652   return;
00653 }
00654 
00655 void HcalDataFormatMonitor::processEvent(const FEDRawDataCollection& rawraw, 
00656                                          const HcalUnpackerReport& report, 
00657                                          const HcalElectronicsMap& emap){
00658   if(!m_dbe) { 
00659     printf("HcalDataFormatMonitor::processEvent DQMStore not instantiated!!!\n");  
00660     return;}
00661   
00662   ievt_++;
00663   meEVT_->Fill(ievt_);
00664   
00665   meSpigotFormatErrors_->Fill(report.spigotFormatErrors());
00666   meBadQualityDigis_->Fill(report.badQualityDigis());
00667   meUnmappedDigis_->Fill(report.unmappedDigis());
00668   meUnmappedTPDigis_->Fill(report.unmappedTPDigis());
00669 
00670   lastEvtN_ = -1;
00671   lastBCN_ = -1;
00672 
00673   // Loop over all FEDs reporting the event, unpacking if good.
00674   for (vector<int>::const_iterator i=fedUnpackList_.begin();i!=fedUnpackList_.end(); i++) {
00675     const FEDRawData& fed = rawraw.FEDData(*i);
00676     if (fed.size()<12) continue;  //At least the size of headers and trailers of a DCC.
00677     unpack(fed,emap); //Interpret data, fill histograms, everything.
00678   }
00679 
00680   // Any problem worth mapping, anywhere?
00681   for (unsigned int i =0 ; i < problemhere.size(); i++) {
00682     for (unsigned int j =0 ; j < problemhere[i].size(); j++) {
00683       if (problemhere[i][j]) 
00684         phatmap[i][j] +=1;   
00685       if (problemHB[i][j]) {
00686         HBmap[i][j] +=1; }
00687       if (problemHE[i][j])  {
00688         HEmap[i][j] +=1; }
00689       if (problemHF[i][j]) 
00690         HFmap[i][j] +=1;   
00691       if (problemHO[i][j]) 
00692         HOmap[i][j] +=1;   
00693     }
00694   }
00695   UpdateMap();  //Transfer this event's problem info to 
00696   for (unsigned int i =0 ; i < problemhere.size(); i++) {
00697     for (unsigned int j =0 ; j < problemhere[i].size(); j++) {
00698       problemhere[i][j] =false;
00699       problemHB[i][j] =false;
00700       problemHE[i][j] =false;
00701       problemHF[i][j] =false;
00702       problemHO[i][j] =false;
00703     }
00704   }  
00705 
00706 
00707   for(unsigned int i=0; i<report.getFedsError().size(); i++){
00708     // Take the ith entry in the vector of FED IDs
00709     // with zero-size FEDRawData, size < 24, 
00710     const int m = report.getFedsError()[i];
00711     const FEDRawData& fed = rawraw.FEDData(m);
00712     const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(fed.data());
00713     if(!dccHeader) continue;
00714     int dccid=dccHeader->getSourceId();
00715     meFEDerrorMap_->Fill(dccid);}
00716 
00717   if (0== (ievt_ % dfmon_checkNevents)) UpdateMEs();
00718   return;
00719 } //void HcalDataFormatMonitor::processEvent()
00720 
00721 // Process one FED's worth (one DCC's worth) of the event data.
00722 void HcalDataFormatMonitor::unpack(const FEDRawData& raw, 
00723                                    const HcalElectronicsMap& emap){
00724   // get the DCC header & trailer (or bail out)
00725   const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(raw.data());
00726   if(!dccHeader) return;
00727   unsigned char* trailer_ptr = (unsigned char*) (raw.data()+raw.size()-sizeof(uint64_t));
00728   FEDTrailer trailer = FEDTrailer(trailer_ptr);
00729 
00730   // FED id declared in the metadata
00731   int dccid=dccHeader->getSourceId();
00732   if(fVerbosity) cout << "DCC " << dccid << endl;
00733   //There should never be HCAL DCCs reporting a fed id outside [700:731]
00734   meFEDId_->Fill(dccid);
00735 
00736   //Before all else, how much data are we dealing with here?
00737   uint64_t* lastDataWord = (uint64_t*) ( raw.data()+raw.size()-(2*sizeof(uint64_t)) );
00738   int EvFragLength = ((*lastDataWord>>32)*8); // In bytes.
00739   EvFragLength = raw.size(); // Same source, at root, or a good check?
00740   meFEDRawDataSizes_->Fill(EvFragLength);
00741   meEvFragSize_ ->Fill(dccid, EvFragLength);
00742   meEvFragSize2_ ->Fill(dccid, EvFragLength);
00743 
00744   //DataIntegrity histogram bins
00745   int bin=0; 
00746   if (( (dccid-700) % 2 )==0) //...lucky that odd FED ID's all have slot 19....
00747     bin = 3*( (int)DIMbin[dccid-700]);
00748   else 
00749     bin = 1 + (3*(int)(DIMbin[dccid-700]-0.5));
00750   int halfhtrDIM_x, halfhtrDIM_y;
00751   int chsummDIM_x, chsummDIM_y;
00752   int channDIM_x, channDIM_y;
00753   chsummDIM_x = halfhtrDIM_x = 1 + (dccid-700)*3;
00754   
00755   //Orbit, BunchCount, and Event Numbers
00756   unsigned long dccEvtNum = dccHeader->getDCCEventNumber();
00757   int dccBCN = dccHeader->getBunchId();
00758   int dccOrN = dccHeader->getOrbitNumber();
00759   medccBCN_ -> Fill(dccBCN);
00760 
00762   bool CDFProbThisDCC = false; 
00763   /* 1 */ //There should always be a second CDF header word indicated.
00764   if (!dccHeader->thereIsASecondCDFHeaderWord()) {
00765     meCDFErrorFound_->Fill(dccid, 1);
00766     CDFProbThisDCC = true; 
00767   }
00768   /* 2 */ //Make sure a reference CDF Version value has been recorded for this dccid
00769   CDFvers_it = CDFversionNumber_list.find(dccid);
00770   if (CDFvers_it  == CDFversionNumber_list.end()) {
00771     CDFversionNumber_list.insert(pair<int,short>
00772                                  (dccid,dccHeader->getCDFversionNumber() ) );
00773     CDFvers_it = CDFversionNumber_list.find(dccid);
00774   } // then check against it.
00775   if (dccHeader->getCDFversionNumber()!= CDFvers_it->second) {
00776     meCDFErrorFound_->Fill(dccid,2);
00777     CDFProbThisDCC = true; 
00778   }
00779   /* 3 */ //Make sure a reference CDF EventType value has been recorded for this dccid
00780   CDFEvT_it = CDFEventType_list.find(dccid);
00781   if (CDFEvT_it  == CDFEventType_list.end()) {
00782     CDFEventType_list.insert(pair<int,short>
00783                              (dccid,dccHeader->getCDFEventType() ) );
00784     CDFEvT_it = CDFEventType_list.find(dccid);
00785   } // then check against it.
00786   if (dccHeader->getCDFEventType()!= CDFEvT_it->second) {
00787     meCDFErrorFound_->Fill(dccid,3);
00788     CDFProbThisDCC = true; 
00789   }
00790   /* 4 */ //There should always be a '5' in CDF Header word 0, bits [63:60]
00791   if (dccHeader->BOEshouldBe5Always()!=5) {
00792     meCDFErrorFound_->Fill(dccid, 4);
00793     CDFProbThisDCC = true; 
00794   }
00795   /* 5 */ //There should never be a third CDF Header word indicated.
00796   if (dccHeader->thereIsAThirdCDFHeaderWord()) {
00797     meCDFErrorFound_->Fill(dccid, 5);
00798     CDFProbThisDCC = true; 
00799   }
00800   /* 6 */ //Make sure a reference value of Reserved Bits has been recorded for this dccid
00801   CDFReservedBits_it = CDFReservedBits_list.find(dccid);
00802   if (CDFReservedBits_it  == CDFReservedBits_list.end()) {
00803     CDFReservedBits_list.insert(pair<int,short>
00804                                 (dccid,dccHeader->getSlink64ReservedBits() ) );
00805     CDFReservedBits_it = CDFReservedBits_list.find(dccid);
00806   } // then check against it.
00807   if ((int) dccHeader->getSlink64ReservedBits()!= CDFReservedBits_it->second) {
00808     meCDFErrorFound_->Fill(dccid,6);
00809     CDFProbThisDCC = true; 
00810   }
00811   /* 7 */ //There should always be 0x0 in CDF Header word 1, bits [63:60]
00812   if (dccHeader->BOEshouldBeZeroAlways() !=0) {
00813     meCDFErrorFound_->Fill(dccid, 7);
00814     CDFProbThisDCC = true; 
00815   }
00816   /* 8 */ //There should only be one trailer
00817   if (trailer.moreTrailers()) {
00818     meCDFErrorFound_->Fill(dccid, 8);
00819     CDFProbThisDCC = true; 
00820   }
00821   //  if trailer.
00822   /* 9 */ //CDF Trailer [55:30] should be the # 64-bit words in the EvFragment
00823   if ((uint64_t) raw.size() != ( (uint64_t) trailer.lenght()*sizeof(uint64_t)) )  //The function name is a typo! Awesome.
00824     {
00825       meCDFErrorFound_->Fill(dccid, 9);
00826       CDFProbThisDCC = true; 
00827     }
00828   /*10 */ //There is a rudimentary sanity check built into the FEDTrailer class
00829   if (!trailer.check()) {
00830     meCDFErrorFound_->Fill(dccid, 10);
00831     CDFProbThisDCC = true; 
00832   }
00833   if (CDFProbThisDCC) {
00834     fillzoos(6,dccid);
00835     //Set the problem flag for the ieta, iphi of any channel in this DCC
00836     mapDCCproblem(dccid);
00837   }
00838   if (CDFProbThisDCC)
00839     fedFatal_->Fill(dccid);
00840   fedEntries_->Fill(dccid);
00841 
00842   CDFProbThisDCC = false;  // reset for the next go-round.
00843   
00844   char CRC_err;
00845   for(int i=0; i<HcalDCCHeader::SPIGOT_COUNT; i++) {
00846     CRC_err = ((dccHeader->getSpigotSummary(i) >> 10) & 0x00000001);
00847     if (CRC_err) {
00848       fillzoos(5,dccid);
00849       //Set the problem flag for the ieta, iphi of any channel in this DCC
00850       mapHTRproblem(dccid, i);  
00851     }
00852   }
00853   
00854   // Unlovely. There are N bytes in the DCC's raw data, the last at raw.data(N-1).
00855   // They're in words of 8 bytes.
00856   // Take the last word, take its low byte, and the high 4 bits are the TTS state. Easy.
00857   char TTS_state = ((raw.data()[raw.size()-8]>>4) & 0x0F);
00858 
00859   //  char TTS_state=(char) dccHeader->getAcceptTimeTTS();
00860   if (TTS_state & 0x8) /*RDY*/ 
00861     ++DCC_DataIntegrityCheck_[bin][20];
00862   if (TTS_state & 0x4) /*BSY*/ {
00863     ++DCC_DataIntegrityCheck_[bin][18];
00865   }
00866   if (TTS_state & 0x2) /*SYN*/ {
00867     ++DCC_DataIntegrityCheck_[bin][17];
00868     ++DCC_DataIntegrityCheck_[bin][ 6];}          // DCC lost data
00869   if (TTS_state & 0x1) /*OFW*/ {
00870     ++DCC_DataIntegrityCheck_[bin][19];
00872     mapDCCproblem(dccid);}
00873 
00875   /* 1 */ //Make sure a reference value of the DCC Event Format version has been noted for this dcc.
00876   DCCEvtFormat_it = DCCEvtFormat_list.find(dccid);
00877   if (DCCEvtFormat_it == DCCEvtFormat_list.end()) {
00878     DCCEvtFormat_list.insert(pair<int,short>
00879                              (dccid,dccHeader->getDCCDataFormatVersion() ) );
00880     DCCEvtFormat_it = DCCEvtFormat_list.find(dccid);
00881   } // then check against it.
00882   if (dccHeader->getDCCDataFormatVersion()!= DCCEvtFormat_it->second) 
00883     meDCCEventFormatError_->Fill(dccid,1);
00884   /* 2 */ //Check for ones where there should always be zeros
00885   if (false) //dccHeader->getByte1Zeroes() || dccHeader->getByte3Zeroes() || dccHeader->getByte567Zeroes()) 
00886     meDCCEventFormatError_->Fill(dccid,2);
00887   /* 3 */ //Check that there are zeros following the HTR Status words.
00888   int SpigotPad = HcalDCCHeader::SPIGOT_COUNT;
00889   if (  ((uint64_t) dccHeader->getSpigotSummary(SpigotPad)  ) 
00890         | ((uint64_t) dccHeader->getSpigotSummary(SpigotPad+1)) 
00891         | ((uint64_t) dccHeader->getSpigotSummary(SpigotPad+2))  != 0)
00892     meDCCEventFormatError_->Fill(dccid,3);
00893   /* 4 */ //Check that there are zeros following the HTR Payloads, if needed.
00894   int nHTR32BitWords=0;
00895   // add up all the declared HTR Payload lengths
00896   for(int i=0; i<HcalDCCHeader::SPIGOT_COUNT; i++) {
00897     nHTR32BitWords += dccHeader->getSpigotDataLength(i);  }
00898   // if it's an odd number, check for the padding zeroes
00899   if (( nHTR32BitWords % 2) == 1) {
00900     uint64_t* lastDataWord = (uint64_t*) ( raw.data()+raw.size()-(2*sizeof(uint64_t)) );
00901     if ((*lastDataWord>>32) != 0x00000000)
00902       meDCCEventFormatError_->Fill(dccid, 4);
00903   }
00904   
00906   /* [1:15] */ //Histogram HTR Status Bits from the DCC Header
00907   for(int i=1; i<=HcalDCCHeader::SPIGOT_COUNT; i++)  
00908     // One bit: data missing || mismatch <EvN, BcN, || OrN>
00909     if (dccHeader->getSpigotErrorFlag(i))  meDCCErrorAndWarnConditions_->Fill(dccid, i);
00910   /* [16:25] */ //Histogram DCC Error and Warning Counters being nonzero
00911   if (TTS_state & 0x1)                  meDCCErrorAndWarnConditions_->Fill(dccid,16);
00912   if (TTS_state & 0x4)                  meDCCErrorAndWarnConditions_->Fill(dccid,17);
00913   if (TTS_state & 0x2)                  meDCCErrorAndWarnConditions_->Fill(dccid,18);
00914   if (dccHeader->SawL1A_EvN_MxMx()   )  meDCCErrorAndWarnConditions_->Fill(dccid,19);
00915   if (dccHeader->SawL1A_BcN_MxMx()   )  meDCCErrorAndWarnConditions_->Fill(dccid,20);
00916   if (dccHeader->SawCT_EvN_MxMx()    )  meDCCErrorAndWarnConditions_->Fill(dccid,21);
00917   if (dccHeader->SawCT_BcN_MxMx()    )  meDCCErrorAndWarnConditions_->Fill(dccid,22);
00918   if (dccHeader->SawOrbitLengthErr() )  meDCCErrorAndWarnConditions_->Fill(dccid,23);
00919   if (dccHeader->SawTTC_SingErr()    )  meDCCErrorAndWarnConditions_->Fill(dccid,24);
00920   if (dccHeader->SawTTC_DoubErr()    )  meDCCErrorAndWarnConditions_->Fill(dccid,25);
00921 
00922 
00924   /* [1:8] */ //Histogram HTR Error Bits in the DCC Headers
00925   bool FoundOne;
00926   unsigned char WholeErrorList=0; 
00927   for(int j=0; j<HcalDCCHeader::SPIGOT_COUNT; j++) {
00928     WholeErrorList=dccHeader->getSpigotErrorBits((unsigned int) j);
00929     if ((WholeErrorList>>0)&0x01) { //HTR OFW
00930       ++DCC_DataIntegrityCheck_[bin][15];
00931       meDCCSummariesOfHTRs_->Fill(dccid, 1);
00932       fillzoos(11,dccid);
00933     }
00934     if ((WholeErrorList>>1)&0x01) { //HTR BSY
00935       ++DCC_DataIntegrityCheck_[bin][14];
00936       meDCCSummariesOfHTRs_->Fill(dccid, 2);
00937       fillzoos(12,dccid);
00938     }
00939     if ((WholeErrorList>>2)&0x01) { //EE
00940       meDCCSummariesOfHTRs_->Fill(dccid, 3);
00941       mapHTRproblem(dccid, j);
00942       fillzoos(1,dccid);
00943     }
00944     if ((WholeErrorList>>3)&0x01) { //Trigger Rule Viol.
00945       meDCCSummariesOfHTRs_->Fill(dccid, 4);
00946       fillzoos(13,dccid);
00947     }
00948     if ((WholeErrorList>>4)&0x01) { //Latency Err
00949       meDCCSummariesOfHTRs_->Fill(dccid, 5);
00950     }
00951     if ((WholeErrorList>>5)&0x01) { //Latency Warn
00952       meDCCSummariesOfHTRs_->Fill(dccid, 6);
00953     }
00954     if ((WholeErrorList>>6)&0x01) { //OD
00955       meDCCSummariesOfHTRs_->Fill(dccid, 7);
00956       fillzoos(15,dccid);
00957     }
00958     if ((WholeErrorList>>7)&0x01) { //CK
00959       meDCCSummariesOfHTRs_->Fill(dccid, 8);
00960       fillzoos(16,dccid);
00961     }
00962   }
00963   /* [9:16] */ //Histogram LRB Error Bits in the DCC Headers
00964   WholeErrorList=0; 
00965   for(int j=0; j<HcalDCCHeader::SPIGOT_COUNT; j++) {
00966     WholeErrorList=dccHeader->getLRBErrorBits((unsigned int) j);
00967     if ((WholeErrorList>>0)&0x03) { //HammingCode Corrected & Uncorr
00968       ++DCC_DataIntegrityCheck_[bin][3]; 
00969       fillzoos(4,dccid);
00970       mapHTRproblem (dccid, j);
00971       if ((WholeErrorList>>0)&0x01)  //HammingCode Corrected 
00972         meDCCSummariesOfHTRs_->Fill(dccid, 9);
00973       if ((WholeErrorList>>1)&0x01)  //HammingCode Uncorr
00974         meDCCSummariesOfHTRs_->Fill(dccid, 10);
00975     }
00976     for (int i=2; i<8; i++) {
00977       FoundOne=false;
00978       if ((WholeErrorList>>i)&0x01) {
00979         meDCCSummariesOfHTRs_->Fill(dccid, 9+i);
00980         FoundOne = true;
00981       }
00982     }
00983     if (FoundOne) 
00984       mapHTRproblem(dccid, j);
00985   }
00986   /* [17:20] */ //Histogram condition of Enabled Spigots without data Present
00987   bool FoundEnotP=false;
00988   bool FoundPnotB=false;
00989   bool FoundPnotV=false;
00990   bool FoundT=false;
00991   for(int j=1; j<=HcalDCCHeader::SPIGOT_COUNT; j++) {
00992     if ( dccHeader->getSpigotEnabled((unsigned int) j-1)         &&
00993          (dccHeader->getSpigotDataLength(j-1) <(unsigned long)10) ) 
00994       ++DCC_DataIntegrityCheck_[bin][8];           // Lost HTR Data for sure
00995     if (dccHeader->getSpigotEnabled((unsigned int) j-1) &&
00996         !dccHeader->getSpigotPresent((unsigned int) j-1)      ) FoundEnotP=true;
00997     //I got the wrong sign on getBxMismatchWithDCC; 
00998     //It's a match, not a mismatch, when true. I'm sorry. 
00999     if (dccHeader->getSpigotPresent((unsigned int) j-1) &&
01000         !dccHeader->getBxMismatchWithDCC((unsigned int) j-1)  ) FoundPnotB=true;
01001     if (dccHeader->getSpigotPresent((unsigned int) j-1) &&
01002         !dccHeader->getSpigotValid((unsigned int) j-1)        ) FoundPnotV=true;
01003     if (dccHeader->getSpigotDataTruncated((unsigned int) j-1) ) {
01004       ++DCC_DataIntegrityCheck_[bin][7];           // LRB truncated the data
01005       FoundT=true;}
01006   }
01007   if (FoundEnotP)meDCCSummariesOfHTRs_->Fill(dccid,17);
01008   if (FoundPnotB)meDCCSummariesOfHTRs_->Fill(dccid,18);
01009   if (FoundPnotV)meDCCSummariesOfHTRs_->Fill(dccid,19);
01010   if (  FoundT  )meDCCSummariesOfHTRs_->Fill(dccid,20);
01011 
01012   // walk through the HTR data...
01013   HcalHTRData htr;  
01014   for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) {    
01015     if (!dccHeader->getSpigotPresent(spigot)) continue;
01016 
01017     halfhtrDIM_y = 1+(spigot*4);
01018     chsummDIM_y  = halfhtrDIM_y;
01019     channDIM_y   = 1+(spigot*3);
01020     bool chsummAOK=true;
01021     bool channAOK=true;
01022 
01023     // From this Spigot's DCC header, first.
01024     WholeErrorList=dccHeader->getLRBErrorBits((unsigned int) spigot);
01025     if ((WholeErrorList>>0)&0x01)  //HammingCode Corrected 
01026       ++HalfHTR_DataIntegrityCheck_[halfhtrDIM_x+1][halfhtrDIM_y+2];
01027     if ((WholeErrorList>>1)&0x01)  //HammingCode Uncorr
01028       ++HalfHTR_DataIntegrityCheck_[halfhtrDIM_x+1][halfhtrDIM_y+1];
01029     CRC_err = ((dccHeader->getSpigotSummary(spigot) >> 10) & 0x00000001);
01030     if (CRC_err)
01031       ++HalfHTR_DataIntegrityCheck_[halfhtrDIM_x+1][halfhtrDIM_y+0];
01032 
01033     // Load the given decoder with the pointer and length from this spigot.
01034     dccHeader->getSpigotData(spigot,htr, raw.size()); 
01035     const unsigned short* HTRraw = htr.getRawData();
01036     unsigned short HTRwdcount = HTRraw[htr.getRawLength() - 2];
01037     
01038     if (HTRwdcount != htr.getRawLength())
01039       //meChannSumm_DataIntegrityCheck_->Fill(chsummDIM_x, chsummDIM_y);
01040       ;
01041     
01042     //fix me!
01043     HTRwdcount=htr.getRawLength();
01044 
01045     // Size checks for internal consistency
01046     // getNTP(), get NDD() seems to be mismatched with format. Manually:
01047     int NTP = ((htr.getExtHdr6() >> 8) & 0x00FF);
01048     int NDAQ = (HTRraw[htr.getRawLength() - 4] & 0x7FF);
01049 
01050     if ( !  ((HTRwdcount != 8)               ||
01051              (HTRwdcount != 12 + NTP + NDAQ) ||
01052              (HTRwdcount != 20 + NTP + NDAQ)    )) {
01053       ++ChannSumm_DataIntegrityCheck_[chsummDIM_x+1][chsummDIM_y];
01054       chsummAOK=false;
01055       //incompatible Sizes declared. Skip it.
01056       continue; }
01057     bool EE = ((dccHeader->getSpigotErrorBits(spigot) >> 2) & 0x01);
01058     if (EE) { 
01059       if (HTRwdcount != 8) {    //incompatible Sizes declared. Skip it.
01060         ++ChannSumm_DataIntegrityCheck_[chsummDIM_x][chsummDIM_y];
01061         chsummAOK=false;}
01062       continue;}
01063     else{ //For non-EE,
01064       if ((HTRwdcount-NDAQ-NTP) != 20) {        //incompatible Sizes declared. Skip it.
01065         ++ChannSumm_DataIntegrityCheck_[chsummDIM_x][chsummDIM_y];
01066         chsummAOK=false; 
01067         continue;} }
01068 
01069     if (htr.isHistogramEvent()) continue;
01070 
01071     //We trust the data now.  Finish with the check against DCCHeader
01072     if (htr.getOrbitNumber() != (unsigned int) dccOrN)
01073       ++HalfHTR_DataIntegrityCheck_[halfhtrDIM_x+0][halfhtrDIM_y+0];
01074     if (htr.getBunchNumber() != (unsigned int) dccBCN)
01075       ++HalfHTR_DataIntegrityCheck_[halfhtrDIM_x+0][halfhtrDIM_y+1];
01076     if (htr.getL1ANumber() != dccEvtNum)
01077       ++HalfHTR_DataIntegrityCheck_[halfhtrDIM_x+0][halfhtrDIM_y+2];
01078 
01079     bool htrUnSuppressed=(HTRraw[6]>>15 & 0x0001);
01080     if (htrUnSuppressed) {
01081       UScount[dccid-700][spigot]++;
01082       int here=1+(HcalDCCHeader::SPIGOT_COUNT*(dccid-700))+spigot;
01083       meUSFractSpigs_->setBinContent(here,
01084                                      ((double)UScount[dccid-700][spigot])/(double)ievt_);}
01085 
01086     // Consider removing this check and the histogram it fills; 
01087     // unless, say, unpacker is a customer (then retitle histo.)
01088     // check min length, correct wordcount, empty event, or total length if histo event.
01089     if (!htr.check()) {
01090       meInvHTRData_ -> Fill(spigot,dccid);
01091       fillzoos(8,dccid);
01092       mapHTRproblem(dccid,spigot);}
01093 
01094     // Fish out Front-End Errors from the precision channels
01095     const short unsigned int* daq_first, *daq_last, *tp_first, *tp_last;
01096     const HcalQIESample* qie_begin, *qie_end, *qie_work;
01097 
01098     // get pointers
01099     htr.dataPointers(&daq_first,&daq_last,&tp_first,&tp_last);
01100 
01101     qie_begin=(HcalQIESample*)daq_first;
01102     qie_end=(HcalQIESample*)(daq_last+1); // one beyond last..
01103 
01104     int lastcapid=-1;
01105     int lastfibchan =0, samplecounter=0;
01106     int channum=0; // Valid: [1,24]
01107     channDIM_x=0;  
01108 
01109     // Loop over DAQ words for this spigot
01110 
01111     for (qie_work=qie_begin; qie_work!=qie_end; qie_work++) {
01112       bool yeah = (qie_work->raw()==0xFFFF);
01113       if (yeah)  // filler word
01114         continue;
01115       channAOK=true;
01116       // Beginning digitized hit of this Half-HTR?
01117       if (qie_work==qie_begin) {
01118         channum= (3* (qie_work->fiber() -1)) + qie_work->fiberChan();  
01119         channDIM_x = (channum*3)+1;
01120         lastcapid=qie_work->capid();
01121         samplecounter=1;}
01122       // or the first TS of a this channel's DAQ data?
01123       else if (qie_work->fiberAndChan() != lastfibchan) {
01124         channum= (3* (qie_work->fiber() - 1)) + qie_work->fiberChan();
01125         channDIM_x = (channum*3)+1;
01126         //Check the last digi for number of timeslices
01127         if ((samplecounter != htr.getNDD()) &&
01128             (samplecounter != 1)             ) {
01129           ++ChannSumm_DataIntegrityCheck_[chsummDIM_x][chsummDIM_y+1];
01130           ++Chann_DataIntegrityCheck_[dccid-700][channDIM_x][channDIM_y];
01131           channAOK=false;}
01132         samplecounter=1;}
01133       else { //precision samples not the first timeslice
01134         int hope = lastcapid +1;
01135         if (hope==4) hope = 0;
01136         if (qie_work->capid() != hope){
01137           ++ChannSumm_DataIntegrityCheck_[chsummDIM_x+1][chsummDIM_y+1];
01138           ++Chann_DataIntegrityCheck_[dccid-700][channDIM_x+1][channDIM_y];
01139           ++ChannSumm_DataIntegrityCheck_[chsummDIM_x+1][chsummDIM_y+1];
01140           ++Chann_DataIntegrityCheck_[dccid-700][channDIM_x+1][channDIM_y];
01141           channAOK=false;}
01142         samplecounter++;}
01143         
01144       //For every precision data sample in Hcal:
01145 
01146       // FEE - Front End Error
01147       if (!(qie_work->dv()) || qie_work->er()) {
01148         ++DCC_DataIntegrityCheck_[bin][4]; 
01149         ++ChannSumm_DataIntegrityCheck_[chsummDIM_x+1][chsummDIM_y+2];
01150         ++Chann_DataIntegrityCheck_[dccid-700][channDIM_x+1][channDIM_y+1];
01151         channAOK=false;}
01152     }
01153 
01154     //Summarize
01155     if (!channAOK) chsummAOK=false;
01156     else 
01157       ++Chann_DataIntegrityCheck_[dccid-700][channDIM_x][channDIM_y+1];
01158 
01159     // Prepare for the next round...
01160     lastcapid=qie_work->capid();
01161     lastfibchan=qie_work->fiberAndChan();
01162 
01163     if (chsummAOK) //better if every event? Here, every half-HTR's event....
01164       ++ChannSumm_DataIntegrityCheck_[chsummDIM_x][chsummDIM_y+2];
01165 
01166     if ( !(htr.getErrorsWord() >> 8) & 0x00000001) 
01167       fillzoos(14,dccid);
01168 
01169     if (dccid==723 && spigot==3) { //the ZDC spigot
01170       //const unsigned short* zdcRAW =  htr.getRawData();
01171       //std::cout  << "ZDC ===> " << zdcRAW[0] << std::endl;
01172     }
01173     
01174     int cratenum = htr.readoutVMECrateId();
01175     float slotnum = htr.htrSlot() + 0.5*htr.htrTopBottom();
01176     if (prtlvl_ > 0) HTRPrint(htr,prtlvl_);
01177 
01178     unsigned int htrBCN = htr.getBunchNumber(); 
01179     meBCN_->Fill(htrBCN);
01180     unsigned int htrEvtN = htr.getL1ANumber();
01181 
01182     if (dccEvtNum != htrEvtN)
01183       ++DCC_DataIntegrityCheck_[bin][13];
01184     if ((unsigned int) dccBCN != htrBCN)
01185       ++DCC_DataIntegrityCheck_[bin][11];
01186  
01187     unsigned int fib1BCN = htr.getFib1OrbMsgBCN();
01188     unsigned int fib2BCN = htr.getFib2OrbMsgBCN();
01189     unsigned int fib3BCN = htr.getFib3OrbMsgBCN();
01190     unsigned int fib4BCN = htr.getFib4OrbMsgBCN();
01191     unsigned int fib5BCN = htr.getFib5OrbMsgBCN();
01192     unsigned int fib6BCN = htr.getFib6OrbMsgBCN();
01193     unsigned int fib7BCN = htr.getFib7OrbMsgBCN();
01194     unsigned int fib8BCN = htr.getFib8OrbMsgBCN();
01195     
01196     if ( (dccEvtNum != fib1BCN) ||
01197          (dccEvtNum != fib2BCN) ||
01198          (dccEvtNum != fib3BCN) ||
01199          (dccEvtNum != fib4BCN) ||
01200          (dccEvtNum != fib5BCN) ||
01201          (dccEvtNum != fib6BCN) ||
01202          (dccEvtNum != fib7BCN) ||
01203          (dccEvtNum != fib8BCN) ) 
01204       ++DCC_DataIntegrityCheck_[bin][10];
01205  
01206     meFibBCN_->Fill(fib1BCN);
01207     meFibBCN_->Fill(fib2BCN);
01208     meFibBCN_->Fill(fib3BCN);
01209     meFibBCN_->Fill(fib4BCN);
01210     meFibBCN_->Fill(fib5BCN);
01211     meFibBCN_->Fill(fib6BCN);
01212     meFibBCN_->Fill(fib7BCN);
01213     meFibBCN_->Fill(fib8BCN);
01214     /* Disable for now
01215        meFib1OrbMsgBCN_->Fill(slotnum, cratenum, fib1BCN);
01216        meFib2OrbMsgBCN_->Fill(slotnum, cratenum, fib2BCN);
01217        meFib3OrbMsgBCN_->Fill(slotnum, cratenum, fib3BCN);
01218        meFib4OrbMsgBCN_->Fill(slotnum, cratenum, fib4BCN);
01219        meFib5OrbMsgBCN_->Fill(slotnum, cratenum, fib5BCN);
01220        meFib6OrbMsgBCN_->Fill(slotnum, cratenum, fib6BCN);
01221        meFib7OrbMsgBCN_->Fill(slotnum, cratenum, fib7BCN);
01222        meFib8OrbMsgBCN_->Fill(slotnum, cratenum, fib8BCN);
01223     */  
01224 
01225     unsigned int htrFWVer = htr.getFirmwareRevision() & 0xFF;
01226     meFWVersion_->Fill(cratenum,htrFWVer);
01227 
01229     unsigned int refEvtNum = dccEvtNum;
01230     /*Could use Evt # from dcc as reference, but not now.
01231       if(htr.getL1ANumber()!=refEvtNum) {meEvtNumberSynch_->Fill(slotnum,cratenum);
01232       if (prtlvl_ == 1)cout << "++++ Evt # out of sync, ref, this HTR: "<< refEvtNum << "  "<<htr.getL1ANumber() <<endl;
01233       }
01234     */
01235 
01236     if(lastEvtN_==-1) {lastEvtN_ = htrEvtN;  
01237     refEvtNum = lastEvtN_;
01238     int EvtNdiff = htrEvtN - dccEvtNum;
01239     meEvtNCheck_->Fill(EvtNdiff);
01240     }
01241     else {
01242       if((int) htrEvtN!=lastEvtN_) {meEvtNumberSynch_->Fill(slotnum,cratenum);
01243       if (prtlvl_ == 1)cout << "++++ Evt # out of sync, ref, this HTR: "<< lastEvtN_ << "  "<<htrEvtN <<endl;}
01244 
01245     }
01246 
01248 
01249     unsigned int refBCN = dccBCN;
01250     /*Could use BCN from dcc as reference, but not now.
01251       if(htr.getBunchNumber()!=refBCN) {meBCNSynch_->Fill(slotnum,cratenum);
01252       if (prtlvl_==1)cout << "++++ BCN # out of sync, ref, this HTR: "<< refBCN << "  "<<htrBCN <<endl;
01253       }
01254     */
01255     // Use 1st HTR as reference
01256     if(lastBCN_==-1) {lastBCN_ = htrBCN;  
01257     refBCN = lastBCN_;
01258     int BCNdiff = htrBCN-dccBCN;
01259     meBCNCheck_->Fill(BCNdiff);
01260     }
01261 
01262     else {
01263       if((int)htrBCN!=lastBCN_) {meBCNSynch_->Fill(slotnum,cratenum);
01264       if (prtlvl_==1)cout << "++++ BCN # out of sync, ref, this HTR: "<< lastBCN_ << "  "<<htrBCN <<endl;}
01265     }
01266 
01267     MonitorElement* tmpErr = 0;
01268     bool valid = false;
01269     for(int fchan=0; fchan<3 && !valid; fchan++){
01270       for(int fib=0; fib<9 && !valid; fib++){
01271         HcalElectronicsId eid(fchan,fib,spigot,dccid-firstFED_);
01272         eid.setHTR(htr.readoutVMECrateId(),htr.htrSlot(),htr.htrTopBottom());
01273         DetId did=emap.lookup(eid);
01274         //      if (did.null()){cout << " Detector id null  " << cratenum << "  " <<slotnum << endl;}
01275         if (!did.null()) {
01276           switch (((HcalSubdetector)did.subdetId())) {
01277           case (HcalBarrel): {
01278             tmpErr = DCC_ErrWd_HBHE;
01279             valid = true;
01280           } break;
01281           case (HcalEndcap): {
01282             tmpErr = DCC_ErrWd_HBHE;
01283             valid = true;
01284           } break;
01285           case (HcalOuter): {
01286             tmpErr = DCC_ErrWd_HO;
01287             valid = true;
01288           } break;
01289           case (HcalForward): {
01290             tmpErr = DCC_ErrWd_HF; 
01291             valid = true;
01292           } break;
01293           default: break;
01294           }
01295         }
01296       }
01297     }    
01298     int errWord = htr.getErrorsWord() & 0x1FFFF;
01299     if(tmpErr!=NULL){
01300       for(int i=0; i<16; i++){
01301         int errbit = errWord&(0x01<<i);
01302         // Bit 15 should always be 1; consider it an error if it isn't.
01303         if (i==15) errbit = errbit - 0x8000;
01304         if (errbit !=0){
01305           tmpErr->Fill(i);
01306           if (i==5 && prtlvl_ != -1) continue; // Skip latency warning for now
01307           meErrWdCrate_->Fill(cratenum,i);
01308           if (cratenum ==0)meCrate0HTRErr_ -> Fill(slotnum,i);
01309           else if (cratenum ==1)meCrate1HTRErr_ -> Fill(slotnum,i);
01310           else if (cratenum ==2)meCrate2HTRErr_ -> Fill(slotnum,i);
01311           else if (cratenum ==3)meCrate3HTRErr_ -> Fill(slotnum,i);
01312           else if (cratenum ==4)meCrate4HTRErr_ -> Fill(slotnum,i);
01313           else if (cratenum ==5)meCrate5HTRErr_ -> Fill(slotnum,i);
01314           else if (cratenum ==6)meCrate6HTRErr_ -> Fill(slotnum,i);
01315           else if (cratenum ==7)meCrate7HTRErr_ -> Fill(slotnum,i);
01316           else if (cratenum ==8)meCrate8HTRErr_ -> Fill(slotnum,i);
01317           else if (cratenum ==9)meCrate9HTRErr_ -> Fill(slotnum,i);
01318           else if (cratenum ==10)meCrate10HTRErr_ -> Fill(slotnum,i);
01319           else if (cratenum ==11)meCrate11HTRErr_ -> Fill(slotnum,i);
01320           else if (cratenum ==12)meCrate12HTRErr_ -> Fill(slotnum,i);
01321           else if (cratenum ==13)meCrate13HTRErr_ -> Fill(slotnum,i);
01322           else if (cratenum ==14)meCrate14HTRErr_ -> Fill(slotnum,i);
01323           else if (cratenum ==15)meCrate15HTRErr_ -> Fill(slotnum,i);
01324           else if (cratenum ==16)meCrate16HTRErr_ -> Fill(slotnum,i);
01325           else if (cratenum ==17)meCrate17HTRErr_ -> Fill(slotnum,i);
01326         } 
01327       }
01328     }    
01329   } //  for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) 
01330   return;
01331 } // void HcalDataFormatMonitor::unpack(
01332 
01333 void HcalDataFormatMonitor::HTRPrint(const HcalHTRData& htr,int prtlvl){
01334 
01335 
01336   if (prtlvl == 1){ 
01337     int cratenum = htr.readoutVMECrateId();
01338     float slotnum = htr.htrSlot() + 0.5*htr.htrTopBottom();
01339     printf("Crate,Slot,ErrWord,Evt#,BCN:  %3i %4.1f %6X %7i %4X \n", cratenum,slotnum,htr.getErrorsWord(),htr.getL1ANumber(),htr.getBunchNumber());
01340     //    printf(" DLLunlk,TTCrdy:%2i %2i \n",htr.getDLLunlock(),htr.getTTCready());
01341   }
01342   // This one needs new version of HcalHTRData.h to activate
01343   else if (prtlvl == 2){
01344     int cratenum = htr.readoutVMECrateId();
01345     float slotnum = htr.htrSlot() + 0.5*htr.htrTopBottom();
01346     printf("Crate, Slot:%3i %4.1f \n", cratenum,slotnum);
01347     //    printf("  Ext Hdr: %4X %4X %4X %4X %4X %4X %4X %4X \n",htr.getExtHdr1(),htr.getExtHdr2(),htr.getExtHdr3(),htr.getExtHdr4(),htr.getExtHdr5(),htr.getExtHdr6(),htr.getExtHdr7(),htr.getExtHdr8());
01348   }
01349 
01350   else if (prtlvl == 3){
01351     int cratenum = htr.readoutVMECrateId();
01352     float slotnum = htr.htrSlot() + 0.5*htr.htrTopBottom();
01353     printf("Crate, Slot:%3i %4.1f", cratenum,slotnum);
01354     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());
01355   }
01356 
01357   return;
01358 }
01359 void HcalDataFormatMonitor::labelHTRBits(MonitorElement* mePlot,unsigned int axisType) {
01360 
01361   if (axisType !=1 && axisType != 2) return;
01362 
01363   mePlot -> setBinLabel(1,"Overflow Warn",axisType);
01364   mePlot -> setBinLabel(2,"Buffer Busy",axisType);
01365   mePlot -> setBinLabel(3,"Empty Event",axisType);
01366   mePlot -> setBinLabel(4,"Reject L1A",axisType);
01367   mePlot -> setBinLabel(5,"Latency Err",axisType);
01368   mePlot -> setBinLabel(6,"Latency Warn",axisType);
01369   mePlot -> setBinLabel(7,"OptDat Err",axisType);
01370   mePlot -> setBinLabel(8,"Clock Err",axisType);
01371   mePlot -> setBinLabel(9,"Bunch Err",axisType);
01372   mePlot -> setBinLabel(10,"Link Err",axisType);
01373   mePlot -> setBinLabel(11,"CapId Err",axisType);
01374   mePlot -> setBinLabel(12,"FE Format Err",axisType);
01375   mePlot -> setBinLabel(13,"Test Mode",axisType);
01376   mePlot -> setBinLabel(14,"Histo Mode",axisType);
01377   mePlot -> setBinLabel(15,"Calib Trig",axisType);
01378   mePlot -> setBinLabel(16,"Bit15 Err",axisType);
01379 
01380   return;
01381 }
01382 
01383 //No size checking; better have enough y-axis bins!
01384 void HcalDataFormatMonitor::label_ySpigots(MonitorElement* me_ptr, int ybins) {
01385   char label[10];
01386   for (int spig=0; spig<HcalDCCHeader::SPIGOT_COUNT; spig++) {
01387     sprintf(label, "Spgt %02d", spig);
01388     me_ptr->setBinLabel((2+(spig*ybins)), label, 2); //margin of 1 at low value
01389   }
01390 }
01391 
01392 //No size checking; better have enough x-axis bins!
01393 void HcalDataFormatMonitor::label_xChanns(MonitorElement* me_ptr, int xbins) {
01394   char label[10];
01395   for (int ch=0; ch<HcalHTRData::CHANNELS_PER_SPIGOT; ch++) {
01396     sprintf(label, "Ch %02d", ch+1);
01397     me_ptr->setBinLabel((2+(ch*xbins)), label, 1); //margin of 3 at low value
01398   }
01399 }
01400 
01401 //No size checking; better have enough x-axis bins!
01402 void HcalDataFormatMonitor::label_xFEDs(MonitorElement* me_ptr, int xbins) {
01403   char label[10];
01404   for (int spig=0; spig<32; spig++) {
01405     sprintf(label, "%03d", spig+700);
01406     me_ptr->setBinLabel((2+(spig*xbins)), label, 1); //margin of 1 at low value
01407   }
01408 }
01409 
01410 
01411 void HcalDataFormatMonitor::labelthezoo(MonitorElement* zoo) {
01428 }
01429 
01430 // Public function so HcalMonitorModule can slip in a 
01431 // logical map digest or two. 
01432 void HcalDataFormatMonitor::smuggleMaps(std::map<uint32_t, std::vector<HcalDetId> >& givenDCCtoCell,
01433                                         std::map<pair <int,int> , std::vector<HcalDetId> >& givenHTRtoCell) {
01434   DCCtoCell = givenDCCtoCell;
01435   HTRtoCell = givenHTRtoCell;
01436   return;
01437 }
01438 
01439 void HcalDataFormatMonitor::fillzoos(int bin, int dccid) {
01447 }
01448 
01449 void HcalDataFormatMonitor::mapHTRproblem (int dcc, int spigot) {
01450   pair <int,int> thishtr = pair <int,int> (dcc-700, spigot);
01451   for (std::vector<HcalDetId>::iterator thishdi = HTRtoCell[thishtr].begin(); 
01452        thishdi != HTRtoCell[thishtr].end(); thishdi++) {
01453     problemhere[thishdi->ieta() - IETAMIN][thishdi->iphi()] = true;
01454     //Decide the subdet map to fill
01455     switch (thishdi->subdet()) {
01456     case (HcalBarrel): {
01457       problemHB[thishdi->ieta() - IETAMIN][thishdi->iphi()] = true;
01458     } break;
01459     case (HcalEndcap): {
01460       problemHE[thishdi->ieta() - IETAMIN][thishdi->iphi()] = true;
01461     } break;
01462     case (HcalOuter): {
01463       problemHE[thishdi->ieta() - IETAMIN][thishdi->iphi()] = true;
01464     } break;
01465     case (HcalForward): {
01466       problemHE[thishdi->ieta() - IETAMIN][thishdi->iphi()] = true;
01467     } break;
01468     default: break;
01469     }
01470   }   
01471 }
01472 void HcalDataFormatMonitor::mapDCCproblem(int dcc) {
01473   for (std::vector<HcalDetId>::iterator thishdi = DCCtoCell[dcc -700].begin(); 
01474        thishdi != DCCtoCell[dcc-700].end(); thishdi++) {
01475     problemhere[thishdi->ieta() - IETAMIN][thishdi->iphi()] = true;
01476     //Decide the subdet map to fill
01477     switch (thishdi->subdet()) {
01478     case (HcalBarrel): {
01479       problemHB[thishdi->ieta() - IETAMIN][thishdi->iphi()] = true;
01480     } break;
01481     case (HcalEndcap): {
01482       problemHE[thishdi->ieta() - IETAMIN][thishdi->iphi()] = true;
01483     } break;
01484     case (HcalOuter): {
01485       problemHE[thishdi->ieta() - IETAMIN][thishdi->iphi()] = true;
01486     } break;
01487     case (HcalForward): {
01488       problemHE[thishdi->ieta() - IETAMIN][thishdi->iphi()] = true;
01489     } break;
01490     default: break;
01491     }
01492   }
01493 }
01494 
01495 //Scale down the phatmap by the number of events.
01496 //Replace all bin contents in the DATAFORMAT_PROBLEM_MAP
01497 void HcalDataFormatMonitor::UpdateMap(void ) {
01525 }
01526 
01527 void HcalDataFormatMonitor::UpdateMEs (void ) {
01528   for (int x=0; x<RCDIX; x++)
01529     for (int y=0; y<RCDIY; y++)
01530       if (DCC_DataIntegrityCheck_[x][y]) //If it's not zero
01531         meDCC_DataIntegrityCheck_->Fill(x, y, DCC_DataIntegrityCheck_[x][y]);
01532 
01533   for (int x=0; x<HHDIX; x++)
01534     for (int y=0; y<HHDIY; y++)
01535       if (HalfHTR_DataIntegrityCheck_  [x][y])
01536         meHalfHTR_DataIntegrityCheck_->Fill(x,y,HalfHTR_DataIntegrityCheck_[x][y]);
01537          
01538   for (int x=0; x<CSDIX; x++)
01539     for (int y=0; y<HHDIY; y++)
01540       if (ChannSumm_DataIntegrityCheck_[x][y])
01541         meChannSumm_DataIntegrityCheck_->Fill(x,y,ChannSumm_DataIntegrityCheck_[x][y]);
01542 
01543   for (int f=0; f<NUMDCCS; f++)
01544     for (int x=0; x<CIX; x++)
01545       for (int y=0; y<CIY; y++)      
01546         if (Chann_DataIntegrityCheck_[f][x][y])
01547           meChann_DataIntegrityCheck_[f]->Fill(x,y,Chann_DataIntegrityCheck_ [f][x][y]);
01548 }

Generated on Tue Jun 9 17:33:00 2009 for CMSSW by  doxygen 1.5.4