CMS 3D CMS Logo

HcalDataIntegrityTask.cc

Go to the documentation of this file.
00001 #include "DQM/HcalMonitorTasks/interface/HcalDataIntegrityTask.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 HcalDataIntegrityTask::HcalDataIntegrityTask() 
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 } // HcalDataIntegrityTask::HcalDataIntegrityTask()
00029 
00030 HcalDataIntegrityTask::~HcalDataIntegrityTask() {}
00031 
00032 void HcalDataIntegrityTask::reset(){}
00033 
00034 void HcalDataIntegrityTask::clearME()
00035 {
00036   if(m_dbe){
00037     m_dbe->setCurrentFolder(baseFolder_);
00038     m_dbe->removeContents();
00039   }
00040 }
00041 
00042 
00043 void HcalDataIntegrityTask::setup(const edm::ParameterSet& ps,
00044                                   DQMStore* dbe)
00045 {
00046   HcalBaseMonitor::setup(ps,dbe);
00047   
00048   ievt_=0;
00049   baseFolder_ = rootFolder_+"HcalDataIntegrityTask";
00050 
00051   if(fVerbosity) 
00052     cout << "About to pushback fedUnpackList_" << endl;
00053   
00054   firstFED_ = FEDNumbering::getHcalFEDIds().first;
00055   for (int i=FEDNumbering::getHcalFEDIds().first; 
00056        i<=FEDNumbering::getHcalFEDIds().second;
00057        ++i) 
00058     {
00059       if(fVerbosity) cout << "[DFMon:]Pushback for fedUnpackList_: " << i <<endl;
00060       fedUnpackList_.push_back(i);
00061     }
00062 
00063   prtlvl_ = ps.getUntrackedParameter<int>("dfPrtLvl");
00064 
00065   if ( m_dbe ) 
00066     {
00067       char* type;
00068       
00069       if (fVerbosity)
00070         cout <<"SET TO HCAL/FEDIntegrity"<<endl;
00071       m_dbe->setCurrentFolder("Hcal/FEDIntegrity/");
00072       type="FEDEntries";
00073       fedEntries_ = m_dbe->book1D(type,"# entries per HCAL FED",32,700,732);
00074       type="FEDFatal";
00075       fedFatal_ = m_dbe->book1D(type,"# fatal errors HCAL FED",32,700,732);
00076       type="FEDNonFatal";
00077       fedNonFatal_ = m_dbe->book1D(type,"# non-fatal errors HCAL FED",32,700,732);
00078     } // if (m_dbe)
00079 
00080 
00081   return;
00082 }
00083 
00084 void HcalDataIntegrityTask::processEvent(const FEDRawDataCollection& rawraw, 
00085                                          const HcalUnpackerReport& report, 
00086                                          const HcalElectronicsMap& emap){
00087   
00088   if(!m_dbe) 
00089     { 
00090       cout<<"HcalDataIntegrityTask::processEvent DQMStore not instantiated!!!"<<endl;  
00091       return;
00092     }
00093   
00094   ievt_++;
00095 
00096   // Loop over all FEDs reporting the event, unpacking if good.
00097   for (vector<int>::const_iterator i=fedUnpackList_.begin();i!=fedUnpackList_.end(); i++) 
00098     {
00099       const FEDRawData& fed = rawraw.FEDData(*i);
00100       if (fed.size()<12) continue; // Was 16. How do such tiny events even get here?
00101       unpack(fed,emap);
00102     }
00103 
00104   return;
00105 } //void HcalDataIntegrityTask::processEvent()
00106 
00107 
00108 // Process one FED's worth (one DCC's worth) of the event data.
00109 void HcalDataIntegrityTask::unpack(const FEDRawData& raw, 
00110                                    const HcalElectronicsMap& emap){
00111   // get the DCC header
00112   const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(raw.data());
00113   if(!dccHeader) return;
00114 
00115   // get the DCC trailer 
00116   unsigned char* trailer_ptr = (unsigned char*) (raw.data()+raw.size()-sizeof(uint64_t));
00117   FEDTrailer trailer = FEDTrailer(trailer_ptr);
00118 
00119   int dccid=dccHeader->getSourceId();
00120 
00122   bool CDFProbThisDCC = false; 
00123   /* 1 */ //There should always be a second CDF header word indicated.
00124   if (!dccHeader->thereIsASecondCDFHeaderWord()) 
00125     {
00126       CDFProbThisDCC = true; 
00127     }
00128 
00129   /* 2 */ //Make sure a reference CDF Version value has been recorded for this dccid
00130   CDFvers_it = CDFversionNumber_list.find(dccid);
00131   if (CDFvers_it  == CDFversionNumber_list.end()) 
00132     {
00133       CDFversionNumber_list.insert(pair<int,short>
00134                                    (dccid,dccHeader->getCDFversionNumber() ) );
00135       CDFvers_it = CDFversionNumber_list.find(dccid);
00136     } // then check against it.
00137 
00138   if (dccHeader->getCDFversionNumber()!= CDFvers_it->second) 
00139     {
00140       CDFProbThisDCC = true; 
00141     }
00142   
00143   /* 3 */ //Make sure a reference CDF EventType value has been recorded for this dccid
00144   CDFEvT_it = CDFEventType_list.find(dccid);
00145   if (CDFEvT_it  == CDFEventType_list.end()) 
00146     {
00147       CDFEventType_list.insert(pair<int,short>
00148                                (dccid,dccHeader->getCDFEventType() ) );
00149       CDFEvT_it = CDFEventType_list.find(dccid);
00150     } // then check against it.
00151   
00152   if (dccHeader->getCDFEventType()!= CDFEvT_it->second) 
00153     {
00154       CDFProbThisDCC = true; 
00155     }
00156 
00157   /* 4 */ //There should always be a '5' in CDF Header word 0, bits [63:60]
00158   if (dccHeader->BOEshouldBe5Always()!=5) 
00159     {
00160       CDFProbThisDCC = true; 
00161     }
00162 
00163   /* 5 */ //There should never be a third CDF Header word indicated.
00164   if (dccHeader->thereIsAThirdCDFHeaderWord()) 
00165     {
00166       CDFProbThisDCC = true; 
00167     }
00168 
00169   /* 6 */ //Make sure a reference value of Reserved Bits has been recorded for this dccid
00170 
00171   CDFReservedBits_it = CDFReservedBits_list.find(dccid);
00172   if (CDFReservedBits_it  == CDFReservedBits_list.end()) {
00173     CDFReservedBits_list.insert(pair<int,short>
00174                                 (dccid,dccHeader->getSlink64ReservedBits() ) );
00175     CDFReservedBits_it = CDFReservedBits_list.find(dccid);
00176   } // then check against it.
00177   
00178   if ((int) dccHeader->getSlink64ReservedBits()!= CDFReservedBits_it->second) 
00179     {
00180       CDFProbThisDCC = true; 
00181     }
00182 
00183   /* 7 */ //There should always be 0x0 in CDF Header word 1, bits [63:60]
00184   if (dccHeader->BOEshouldBeZeroAlways() !=0) 
00185     {
00186       CDFProbThisDCC = true; 
00187     }
00188   
00189   /* 8 */ //There should only be one trailer
00190   if (trailer.moreTrailers()) 
00191     {
00192       CDFProbThisDCC = true; 
00193     }
00194   //  if trailer.
00195 
00196   /* 9 */ //CDF Trailer [55:30] should be the # 64-bit words in the EvFragment
00197   if ((uint64_t) raw.size() != ( (uint64_t) trailer.lenght()*sizeof(uint64_t)) )  //The function name is a typo! Awesome.
00198     {
00199       CDFProbThisDCC = true; 
00200     }
00201   /*10 */ //There is a rudimentary sanity check built into the FEDTrailer class
00202   if (!trailer.check()) 
00203     {
00204       CDFProbThisDCC = true; 
00205     }
00206 
00207   if (CDFProbThisDCC)
00208     fedFatal_->Fill(dccid);
00209   fedEntries_->Fill(dccid);
00210 
00211   return;
00212 } // void HcalDataIntegrityTask::unpack(
00213 
00214 

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