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
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
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
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 }
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 }
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
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;
00101 unpack(fed,emap);
00102 }
00103
00104 return;
00105 }
00106
00107
00108
00109 void HcalDataIntegrityTask::unpack(const FEDRawData& raw,
00110 const HcalElectronicsMap& emap){
00111
00112 const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(raw.data());
00113 if(!dccHeader) return;
00114
00115
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
00124 if (!dccHeader->thereIsASecondCDFHeaderWord())
00125 {
00126 CDFProbThisDCC = true;
00127 }
00128
00129
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 }
00137
00138 if (dccHeader->getCDFversionNumber()!= CDFvers_it->second)
00139 {
00140 CDFProbThisDCC = true;
00141 }
00142
00143
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 }
00151
00152 if (dccHeader->getCDFEventType()!= CDFEvT_it->second)
00153 {
00154 CDFProbThisDCC = true;
00155 }
00156
00157
00158 if (dccHeader->BOEshouldBe5Always()!=5)
00159 {
00160 CDFProbThisDCC = true;
00161 }
00162
00163
00164 if (dccHeader->thereIsAThirdCDFHeaderWord())
00165 {
00166 CDFProbThisDCC = true;
00167 }
00168
00169
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 }
00177
00178 if ((int) dccHeader->getSlink64ReservedBits()!= CDFReservedBits_it->second)
00179 {
00180 CDFProbThisDCC = true;
00181 }
00182
00183
00184 if (dccHeader->BOEshouldBeZeroAlways() !=0)
00185 {
00186 CDFProbThisDCC = true;
00187 }
00188
00189
00190 if (trailer.moreTrailers())
00191 {
00192 CDFProbThisDCC = true;
00193 }
00194
00195
00196
00197 if ((uint64_t) raw.size() != ( (uint64_t) trailer.lenght()*sizeof(uint64_t)) )
00198 {
00199 CDFProbThisDCC = true;
00200 }
00201
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 }
00213
00214