CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DQM/L1TMonitor/src/L1GtHwValidation.cc

Go to the documentation of this file.
00001 
00018 // this class header
00019 #include "DQM/L1TMonitor/interface/L1GtHwValidation.h"
00020 
00021 // system include files
00022 #include <memory>
00023 #include <iostream>
00024 #include <iomanip>
00025 
00026 // user include files
00027 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00028 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
00029 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00030 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
00031 
00032 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00033 #include "FWCore/ServiceRegistry/interface/Service.h"
00034 
00035 #include "FWCore/Framework/interface/EventSetup.h"
00036 #include "FWCore/Framework/interface/ESHandle.h"
00037 #include "FWCore/Framework/interface/Run.h"
00038 
00039 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
00040 #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
00041 
00042 #include "CondFormats/L1TObjects/interface/L1GtPrescaleFactors.h"
00043 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsAlgoTrigRcd.h"
00044 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsTechTrigRcd.h"
00045 
00046 #include "CondFormats/L1TObjects/interface/L1GtTriggerMask.h"
00047 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskAlgoTrigRcd.h"
00048 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskTechTrigRcd.h"
00049 
00050 #include "TH1.h"
00051 #include "TH2.h"
00052 #include "TTree.h"
00053 
00054 // constructor(s)
00055 L1GtHwValidation::L1GtHwValidation(const edm::ParameterSet& paramSet) :
00056             //
00057             // input tag for the L1 GT hardware DAQ record
00058             m_l1GtDataDaqInputTag(paramSet.getParameter<edm::InputTag>(
00059                     "L1GtDataDaqInputTag")),
00060             // input tag for the L1 GT hardware EVM record
00061             m_l1GtDataEvmInputTag(paramSet.getParameter<edm::InputTag>(
00062                     "L1GtDataEvmInputTag")),
00063             // input tag for the L1 GT emulator DAQ record
00064             m_l1GtEmulDaqInputTag(paramSet.getParameter<edm::InputTag>(
00065                     "L1GtEmulDaqInputTag")),
00066             // input tag for the L1 GT emulator EVM record
00067             m_l1GtEmulEvmInputTag(paramSet.getParameter<edm::InputTag>(
00068                     "L1GtEmulEvmInputTag")),
00069             // input tag for the L1 GCT hardware record
00070             m_l1GctDataInputTag(paramSet.getParameter<edm::InputTag>(
00071                     "L1GctDataInputTag")),
00072             //
00073             m_dirName(paramSet.getUntrackedParameter("DirName", std::string(
00074                     "L1Trigger/L1ExtraDQM/source"))),
00075             // initialize counters
00076             m_nrDataEventError(0),
00077             m_nrEmulEventError(0),
00078             // cache
00079             m_l1GtMenuCacheID(0ULL), m_l1GtPfAlgoCacheID(0ULL),
00080             m_l1GtPfTechCacheID(0ULL), m_l1GtTmAlgoCacheID(0ULL),
00081             m_l1GtTmTechCacheID(0ULL),
00082             //
00083             m_dbe(0),
00084             //
00085             m_nrEvJob(0), m_nrEvRun(0) {
00086 
00087     LogDebug("L1GtHwValidation")
00088             << "\nInput tag for the L1 GT DAQ hardware record:       "
00089             << m_l1GtDataDaqInputTag
00090             << "\nInput tag for the L1 GT EVM hardware record:       "
00091             << m_l1GtDataEvmInputTag
00092             << "\nInput tag for the L1 GT DAQ emulator records:          "
00093             << m_l1GtEmulDaqInputTag
00094             << "\nInput tag for the L1 GT EVM emulator records:          "
00095             << m_l1GtEmulEvmInputTag
00096             << "\nInput tag for the L1 GCT hardware record:          "
00097             << m_l1GctDataInputTag << std::endl;
00098 
00099     m_dbe = edm::Service<DQMStore>().operator->();
00100     if (m_dbe == 0) {
00101         edm::LogInfo("L1GtHwValidation")
00102                 << "\n Unable to get DQMStore service.";
00103     } else {
00104 
00105         if (paramSet.getUntrackedParameter<bool>("DQMStore", false)) {
00106             m_dbe->setVerbose(0);
00107         }
00108 
00109         m_dbe->setCurrentFolder(m_dirName);
00110 
00111     }
00112 
00113 }
00114 
00115 // destructor
00116 L1GtHwValidation::~L1GtHwValidation() {
00117     // empty   
00118 }
00119 
00120 // member functions
00121 
00122 // method called once each job just before starting event loop
00123 void L1GtHwValidation::beginJob() {
00124 
00125     DQMStore* dbe = 0;
00126     dbe = edm::Service<DQMStore>().operator->();
00127 
00128     // clean up directory
00129     if (dbe) {
00130         dbe->setCurrentFolder(m_dirName);
00131         if (dbe->dirExists(m_dirName)) {
00132             dbe->rmdir(m_dirName);
00133         }
00134         dbe->setCurrentFolder(m_dirName);
00135     }
00136 
00137     // book histograms
00138     bookHistograms();
00139 
00140 }
00141 
00142 void L1GtHwValidation::beginRun(const edm::Run& iRun,
00143         const edm::EventSetup& evSetup) {
00144 
00145     m_nrEvRun = 0;
00146 
00147     // get / update the trigger menu from the EventSetup
00148     // local cache & check on cacheIdentifier
00149 
00150     unsigned long long l1GtMenuCacheID =
00151             evSetup.get<L1GtTriggerMenuRcd>().cacheIdentifier();
00152 
00153     if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
00154 
00155         edm::ESHandle<L1GtTriggerMenu> l1GtMenu;
00156         evSetup.get<L1GtTriggerMenuRcd>().get(l1GtMenu);
00157         m_l1GtMenu = l1GtMenu.product();
00158 
00159         m_l1GtMenuCacheID = l1GtMenuCacheID;
00160 
00161     }
00162 
00163     // FIXME when the menu changes, make a copy of histograms, and clear the old one
00164     //       otherwise the labels are wrong
00165     const AlgorithmMap& algorithmMap = m_l1GtMenu->gtAlgorithmMap();
00166 
00167     for (CItAlgo itAlgo = algorithmMap.begin(); itAlgo != algorithmMap.end(); itAlgo++) {
00168 
00169         std::string aName = itAlgo->first;
00170         const char* algName = aName.c_str();
00171         int algBitNumber = (itAlgo->second).algoBitNumber();
00172 
00173         for (int iRec = 0; iRec < NumberOfGtRecords; ++iRec) {
00174             for (int iBxInEvent = 0; iBxInEvent < TotalBxInEvent; ++iBxInEvent) {
00175                 m_fdlDataAlgoDecision[iBxInEvent][iRec]->setBinLabel(
00176                         algBitNumber + 1, algName, 1);
00177                 m_fdlDataAlgoDecisionPrescaled[iBxInEvent][iRec]->setBinLabel(
00178                         algBitNumber + 1, algName, 1);
00179                 m_fdlDataAlgoDecisionUnprescaled[iBxInEvent][iRec]->setBinLabel(
00180                         algBitNumber + 1, algName, 1);
00181                 m_fdlDataAlgoDecisionMask[iBxInEvent][iRec]->setBinLabel(
00182                         algBitNumber + 1, algName, 1);
00183                 m_fdlDataAlgoDecision_NoMatch[iBxInEvent][iRec]->setBinLabel(
00184                         algBitNumber + 1, algName, 1);
00185                 m_fdlDataAlgoDecision_Err[iRec]->setBinLabel(algBitNumber + 1,
00186                         algName, 1);
00187 
00188                 m_fdlEmulAlgoDecision[iBxInEvent][iRec]->setBinLabel(
00189                         algBitNumber + 1, algName, 1);
00190                 m_fdlEmulAlgoDecisionPrescaled[iBxInEvent][iRec]->setBinLabel(
00191                         algBitNumber + 1, algName, 1);
00192                 m_fdlEmulAlgoDecisionUnprescaled[iBxInEvent][iRec]->setBinLabel(
00193                         algBitNumber + 1, algName, 1);
00194                 m_fdlEmulAlgoDecisionMask[iBxInEvent][iRec]->setBinLabel(
00195                         algBitNumber + 1, algName, 1);
00196                 m_fdlEmulAlgoDecision_NoMatch[iBxInEvent][iRec]->setBinLabel(
00197                         algBitNumber + 1, algName, 1);
00198                 m_fdlEmulAlgoDecision_Err[iRec]->setBinLabel(algBitNumber + 1,
00199                         algName, 1);
00200 
00201                 m_fdlDataEmulAlgoDecision[iBxInEvent][iRec]->setBinLabel(
00202                         algBitNumber + 1, algName, 1);
00203                 m_fdlDataEmulAlgoDecisionPrescaled[iBxInEvent][iRec]->setBinLabel(
00204                         algBitNumber + 1, algName, 1);
00205                 m_fdlDataEmulAlgoDecisionUnprescaled[iBxInEvent][iRec]->setBinLabel(
00206                         algBitNumber + 1, algName, 1);
00207                 m_fdlDataEmulAlgoDecisionMask[iBxInEvent][iRec]->setBinLabel(
00208                         algBitNumber + 1, algName, 1);
00209                 m_fdlDataEmulAlgoDecision_Err[iRec]->setBinLabel(algBitNumber
00210                         + 1, algName, 1);
00211             }
00212         }
00213 
00214     }
00215 
00216     // get / update the prescale factors from the EventSetup
00217     // local cache & check on cacheIdentifier
00218 
00219     unsigned long long l1GtPfAlgoCacheID = evSetup.get<
00220             L1GtPrescaleFactorsAlgoTrigRcd>().cacheIdentifier();
00221 
00222     if (m_l1GtPfAlgoCacheID != l1GtPfAlgoCacheID) {
00223 
00224         edm::ESHandle<L1GtPrescaleFactors> l1GtPfAlgo;
00225         evSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().get(l1GtPfAlgo);
00226         m_l1GtPfAlgo = l1GtPfAlgo.product();
00227 
00228         m_prescaleFactorsAlgoTrig = &(m_l1GtPfAlgo->gtPrescaleFactors());
00229 
00230         m_l1GtPfAlgoCacheID = l1GtPfAlgoCacheID;
00231 
00232     }
00233 
00234     unsigned long long l1GtPfTechCacheID = evSetup.get<
00235             L1GtPrescaleFactorsTechTrigRcd>().cacheIdentifier();
00236 
00237     if (m_l1GtPfTechCacheID != l1GtPfTechCacheID) {
00238 
00239         edm::ESHandle<L1GtPrescaleFactors> l1GtPfTech;
00240         evSetup.get<L1GtPrescaleFactorsTechTrigRcd>().get(l1GtPfTech);
00241         m_l1GtPfTech = l1GtPfTech.product();
00242 
00243         m_prescaleFactorsTechTrig = &(m_l1GtPfTech->gtPrescaleFactors());
00244 
00245         m_l1GtPfTechCacheID = l1GtPfTechCacheID;
00246 
00247     }
00248 
00249     // get / update the trigger mask from the EventSetup
00250     // local cache & check on cacheIdentifier
00251 
00252     unsigned long long l1GtTmAlgoCacheID = evSetup.get<
00253             L1GtTriggerMaskAlgoTrigRcd>().cacheIdentifier();
00254 
00255     if (m_l1GtTmAlgoCacheID != l1GtTmAlgoCacheID) {
00256 
00257         edm::ESHandle<L1GtTriggerMask> l1GtTmAlgo;
00258         evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().get(l1GtTmAlgo);
00259         m_l1GtTmAlgo = l1GtTmAlgo.product();
00260 
00261         m_triggerMaskAlgoTrig = m_l1GtTmAlgo->gtTriggerMask();
00262 
00263         m_l1GtTmAlgoCacheID = l1GtTmAlgoCacheID;
00264 
00265     }
00266 
00267     unsigned long long l1GtTmTechCacheID = evSetup.get<
00268             L1GtTriggerMaskTechTrigRcd>().cacheIdentifier();
00269 
00270     if (m_l1GtTmTechCacheID != l1GtTmTechCacheID) {
00271 
00272         edm::ESHandle<L1GtTriggerMask> l1GtTmTech;
00273         evSetup.get<L1GtTriggerMaskTechTrigRcd>().get(l1GtTmTech);
00274         m_l1GtTmTech = l1GtTmTech.product();
00275 
00276         m_triggerMaskTechTrig = m_l1GtTmTech->gtTriggerMask();
00277 
00278         m_l1GtTmTechCacheID = l1GtTmTechCacheID;
00279 
00280     }
00281 
00282 }
00283 
00284 //compare the GTFE board
00285 void L1GtHwValidation::compareGTFE(const edm::Event& iEvent,
00286         const edm::EventSetup& evSetup, const L1GtfeWord& gtfeBlockData,
00287         const L1GtfeWord& gtfeBlockEmul, const int iRec) {
00288 
00289     //
00290     std::string recString;
00291     if (iRec == 0) {
00292         recString = "DAQ";
00293     } else {
00294         recString = "EVM";
00295     }
00296 
00297     if (gtfeBlockData == gtfeBlockEmul) {
00298         m_myCoutStream << "\n" << recString
00299                 << " Data and emulated GTFE blocks: identical.\n";
00300         gtfeBlockData.print(m_myCoutStream);
00301     } else {
00302         m_myCoutStream << "\n" << recString
00303                 << " Data and emulated GTFE blocks: different.\n";
00304 
00305         m_myCoutStream << "\nData: GTFE block\n";
00306         gtfeBlockData.print(m_myCoutStream);
00307 
00308         m_myCoutStream << "\nEmul: GTFE block\n";
00309         gtfeBlockEmul.print(m_myCoutStream);
00310 
00311     }
00312 
00313     LogDebug("L1GtHwValidation") << m_myCoutStream.str() << std::endl;
00314 
00315     m_myCoutStream.str("");
00316     m_myCoutStream.clear();
00317 
00318     // get BoardId value
00319     const boost::uint16_t boardIdData = gtfeBlockData.boardId();
00320     const boost::uint16_t boardIdEmul = gtfeBlockEmul.boardId();
00321 
00322     if (boardIdData == boardIdEmul) {
00323         m_myCoutStream << "\n" << recString
00324                 << " Data and emulated GTFE boardId identical.";
00325         m_myCoutStream << "\n boardId() = " << std::hex << "0x" << std::setw(4)
00326                 << std::setfill('0') << boardIdData << std::setfill(' ')
00327                 << std::dec;
00328         m_myCoutStream << "\n";
00329 
00330     } else {
00331         m_myCoutStream << "\n" << recString
00332                 << " Data and emulated GTFE boardId different.";
00333         m_myCoutStream << "\n Data: boardId() = " << std::hex << "0x"
00334                 << std::setw(4) << std::setfill('0') << boardIdData
00335                 << std::setfill(' ') << std::dec;
00336         m_myCoutStream << "\n Emul: boardId() = " << std::hex << "0x"
00337                 << std::setw(4) << std::setfill('0') << boardIdEmul
00338                 << std::setfill(' ') << std::dec;
00339         m_myCoutStream << "\n";
00340         m_gtfeDataEmul[iRec]->Fill(0);
00341 
00342     }
00343 
00345     const boost::uint16_t recordLength1Data = gtfeBlockData.recordLength1();
00346     const boost::uint16_t recordLength1Emul = gtfeBlockEmul.recordLength1();
00347 
00348     if (recordLength1Data == recordLength1Emul) {
00349         m_myCoutStream << "\n" << recString
00350                 << " Data and emulated GTFE recordLength for alternative 1 identical.";
00351         m_myCoutStream << "\n recordLength1() = " << recordLength1Data;
00352         m_myCoutStream << "\n";
00353 
00354     } else {
00355         m_myCoutStream << "\n" << recString
00356                 << " Data and emulated GTFE recordLength for alternative 1 different.";
00357         m_myCoutStream << "\n Data: recordLength1() = " << recordLength1Data;
00358         m_myCoutStream << "\n Emul: recordLength1() = " << recordLength1Emul;
00359         m_myCoutStream << "\n";
00360         m_gtfeDataEmul[iRec]->Fill(1);
00361 
00362     }
00363 
00365     const boost::uint16_t recordLengthData = gtfeBlockData.recordLength();
00366     const boost::uint16_t recordLengthEmul = gtfeBlockEmul.recordLength();
00367 
00368     if (recordLengthData == recordLengthEmul) {
00369         m_myCoutStream << "\n" << recString
00370                 << " Data and emulated GTFE recordLength for alternative 0 identical.";
00371         m_myCoutStream << "\n recordLength() = " << recordLengthData;
00372         m_myCoutStream << "\n";
00373 
00374     } else {
00375         m_myCoutStream << "\n" << recString
00376                 << " Data and emulated GTFE recordLength for alternative 1 different.";
00377         m_myCoutStream << "\n Data: recordLength() = " << recordLengthData;
00378         m_myCoutStream << "\n Emul: recordLength() = " << recordLengthEmul;
00379         m_myCoutStream << "\n";
00380         m_gtfeDataEmul[iRec]->Fill(2);
00381 
00382     }
00383 
00385     const boost::uint16_t bxNrData = gtfeBlockData.bxNr();
00386     const boost::uint16_t bxNrEmul = gtfeBlockEmul.bxNr();
00387 
00388     if (bxNrData == bxNrEmul) {
00389         m_myCoutStream << "\n" << recString
00390                 << " Data and emulated GTFE bxNr identical.";
00391         m_myCoutStream << "\n bxNr() = " << bxNrData;
00392         m_myCoutStream << "\n";
00393 
00394     } else {
00395         m_myCoutStream << "\n" << recString
00396                 << " Data and emulated GTFE bxNr different.";
00397         m_myCoutStream << "\n Data: bxNr() = " << bxNrData;
00398         m_myCoutStream << "\n Emul: bxNr() = " << bxNrEmul;
00399         m_myCoutStream << "\n";
00400         m_gtfeDataEmul[iRec]->Fill(3);
00401 
00402     }
00403 
00405     const boost::uint32_t setupVersionData = gtfeBlockData.setupVersion();
00406     const boost::uint32_t setupVersionEmul = gtfeBlockEmul.setupVersion();
00407 
00408     if (setupVersionData == setupVersionEmul) {
00409         m_myCoutStream << "\n" << recString
00410                 << " Data and emulated GTFE setupVersion identical.";
00411         m_myCoutStream << "\n setupVersion() = " << setupVersionData;
00412         m_myCoutStream << "\n";
00413 
00414     } else {
00415         m_myCoutStream << "\n" << recString
00416                 << " Data and emulated GTFE setupVersion different.";
00417         m_myCoutStream << "\n Data: setupVersion() = " << setupVersionData;
00418         m_myCoutStream << "\n Emul: setupVersion() = " << setupVersionEmul;
00419         m_myCoutStream << "\n";
00420         m_gtfeDataEmul[iRec]->Fill(4);
00421 
00422     }
00423 
00425     const boost::uint16_t activeBoardsData = gtfeBlockData.activeBoards();
00426     const boost::uint16_t activeBoardsEmul = gtfeBlockEmul.activeBoards();
00427 
00428     if (activeBoardsData == activeBoardsEmul) {
00429         m_myCoutStream << "\n" << recString
00430                 << " Data and emulated GTFE activeBoards identical.";
00431         m_myCoutStream << "\n activeBoards() = " << std::hex << "0x"
00432                 << std::setw(4) << std::setfill('0') << activeBoardsData
00433                 << std::setfill(' ') << std::dec;
00434         m_myCoutStream << "\n";
00435 
00436     } else {
00437         m_myCoutStream << "\n" << recString
00438                 << " Data and emulated GTFE activeBoards different.";
00439         m_myCoutStream << "\n Data: activeBoards() = " << std::hex << "0x"
00440                 << std::setw(4) << std::setfill('0') << activeBoardsData
00441                 << std::setfill(' ') << std::dec;
00442         m_myCoutStream << "\n Emul: activeBoards() = " << std::hex << "0x"
00443                 << std::setw(4) << std::setfill('0') << activeBoardsEmul
00444                 << std::setfill(' ') << std::dec;
00445         m_myCoutStream << "\n";
00446         m_gtfeDataEmul[iRec]->Fill(5);
00447 
00448     }
00453     const boost::uint16_t altNrBxBoardData = gtfeBlockData.altNrBxBoard();
00454     const boost::uint16_t altNrBxBoardEmul = gtfeBlockEmul.altNrBxBoard();
00455 
00456     if (altNrBxBoardData == altNrBxBoardEmul) {
00457         m_myCoutStream << "\n" << recString
00458                 << " Data and emulated GTFE altNrBxBoard identical.";
00459         m_myCoutStream << "\n altNrBxBoard() = " << altNrBxBoardData;
00460         m_myCoutStream << "\n";
00461 
00462     } else {
00463         m_myCoutStream << "\n" << recString
00464                 << " Data and emulated GTFE altNrBxBoard different.";
00465         m_myCoutStream << "\n Data: altNrBxBoard() = " << altNrBxBoardData;
00466         m_myCoutStream << "\n Emul: altNrBxBoard() = " << altNrBxBoardEmul;
00467         m_myCoutStream << "\n";
00468         m_gtfeDataEmul[iRec]->Fill(6);
00469 
00470     }
00471 
00473     const boost::uint32_t totalTriggerNrData = gtfeBlockData.totalTriggerNr();
00474     const boost::uint32_t totalTriggerNrEmul = gtfeBlockEmul.totalTriggerNr();
00475 
00476     if (totalTriggerNrData == totalTriggerNrEmul) {
00477         m_myCoutStream << "\n" << recString
00478                 << " Data and emulated GTFE totalTriggerNr identical.";
00479         m_myCoutStream << "\n totalTriggerNr() = " << totalTriggerNrData;
00480         m_myCoutStream << "\n";
00481 
00482     } else {
00483         m_myCoutStream << "\n" << recString
00484                 << " Data and emulated GTFE totalTriggerNr different.";
00485         m_myCoutStream << "\n Data: totalTriggerNr() = " << totalTriggerNrData;
00486         m_myCoutStream << "\n Emul: totalTriggerNr() = " << totalTriggerNrEmul;
00487         m_myCoutStream << "\n";
00488         m_gtfeDataEmul[iRec]->Fill(7);
00489 
00490     }
00491 
00492     edm::LogInfo("L1GtHwValidation") << m_myCoutStream.str() << std::endl;
00493     m_myCoutStream.str("");
00494     m_myCoutStream.clear();
00495 
00496 }
00497 
00498 //compare the FDL board
00499 void L1GtHwValidation::compareFDL(const edm::Event& iEvent,
00500         const edm::EventSetup& evSetup, const L1GtFdlWord& fdlBlockData,
00501         const L1GtFdlWord& fdlBlockEmul, const int iRec) {
00502 
00503     // index of physics partition
00504     int PhysicsPartition = 0;
00505 
00506     // 
00507     std::string recString;
00508     if (iRec == 0) {
00509         recString = "DAQ";
00510     } else {
00511         recString = "EVM";
00512     }
00513 
00514     if (fdlBlockData == fdlBlockEmul) {
00515         m_myCoutStream << "\n" << recString
00516                 << " Data and emulated FDL blocks: identical.\n";
00517         fdlBlockData.print(m_myCoutStream);
00518 
00519     } else {
00520         m_myCoutStream << "\n" << recString
00521                 << " Data and emulated FDL blocks: different.\n";
00522 
00523         m_myCoutStream << "\nData: FDL block\n";
00524         fdlBlockData.print(m_myCoutStream);
00525 
00526         m_myCoutStream << "\nEmul: FDL block\n";
00527         fdlBlockEmul.print(m_myCoutStream);
00528 
00529     }
00530 
00531     LogDebug("L1GtHwValidation") << m_myCoutStream.str() << std::endl;
00532 
00533     m_myCoutStream.str("");
00534     m_myCoutStream.clear();
00535 
00536     // get bunch cross in the GT event record - 
00537     // move it first as histograms are BxInEvent dependent
00538     const int bxInEventData = fdlBlockData.bxInEvent();
00539     const int bxInEventEmul = fdlBlockEmul.bxInEvent();
00540 
00541     bool matchBxInEvent = false;
00542 
00543     if (bxInEventData == bxInEventEmul) {
00544         m_myCoutStream << "\n" << recString
00545                 << " Data and emulated FDL bxInEvent identical.";
00546         m_myCoutStream << "\n bxInEvent() = " << bxInEventData;
00547         m_myCoutStream << "\n";
00548         matchBxInEvent = true;
00549 
00550     } else {
00551         m_myCoutStream << "\n" << recString
00552                 << " Data and emulated FDL bxInEvent different.";
00553         m_myCoutStream << "\n Data: bxInEvent() = " << bxInEventData;
00554         m_myCoutStream << "\n Emul: bxInEvent() = " << bxInEventEmul;
00555         m_myCoutStream << "\n";
00556 
00557         m_fdlDataEmul_Err[iRec]->Fill(1);
00558     }
00559 
00560     LogDebug("L1GtHwValidation") << m_myCoutStream.str() << std::endl;
00561     m_myCoutStream.str("");
00562     m_myCoutStream.clear();
00563 
00564     // symmetrize 
00565     bool validBxInEvent = false;
00566     int histIndex = bxInEventData + (TotalBxInEvent + 1) / 2 - 1;
00567     LogDebug("L1GtHwValidation") << "\n Convert bxInEvent = " << bxInEventData
00568             << " to histIndex = " << histIndex << std::endl;
00569     if ((histIndex <= TotalBxInEvent) && (histIndex >= 0)) {
00570         validBxInEvent = true;
00571     }
00572 
00573     // loop over algorithms and increase the corresponding counters
00574 
00575     // get BoardId value
00576     const boost::uint16_t boardIdData = fdlBlockData.boardId();
00577     const boost::uint16_t boardIdEmul = fdlBlockEmul.boardId();
00578 
00579     if (boardIdData == boardIdEmul) {
00580         m_myCoutStream << "\n" << recString
00581                 << " Data and emulated FDL boardId identical.";
00582         m_myCoutStream << "\n boardId() = " << std::hex << "0x" << std::setw(4)
00583                 << std::setfill('0') << boardIdData << std::setfill(' ')
00584                 << std::dec;
00585         m_myCoutStream << "\n";
00586 
00587     } else {
00588         m_myCoutStream << "\n" << recString
00589                 << " Data and emulated FDL boardId different.";
00590         m_myCoutStream << "\n Data: boardId() = " << std::hex << "0x"
00591                 << std::setw(4) << std::setfill('0') << boardIdData
00592                 << std::setfill(' ') << std::dec;
00593         m_myCoutStream << "\n Emul: boardId() = " << std::hex << "0x"
00594                 << std::setw(4) << std::setfill('0') << boardIdEmul
00595                 << std::setfill(' ') << std::dec;
00596         m_myCoutStream << "\n";
00597 
00598         if (matchBxInEvent && validBxInEvent) {
00599             m_fdlDataEmul[histIndex][iRec]->Fill(0);
00600         } else {
00601             m_fdlDataEmul_Err[iRec]->Fill(0);
00602         }
00603 
00604     }
00605 
00606     LogDebug("L1GtHwValidation") << m_myCoutStream.str() << std::endl;
00607     m_myCoutStream.str("");
00608     m_myCoutStream.clear();
00609 
00610     // get BxNr - bunch cross number of the actual bx
00611     const boost::uint16_t bxNrData = fdlBlockData.bxNr();
00612     const boost::uint16_t bxNrEmul = fdlBlockEmul.bxNr();
00613 
00614     if (bxNrData == bxNrEmul) {
00615         m_myCoutStream << "\n" << recString
00616                 << " Data and emulated FDL bxNr identical.";
00617         m_myCoutStream << "\n bxNr() = " << bxNrData;
00618         m_myCoutStream << "\n";
00619 
00620     } else {
00621         m_myCoutStream << "\n" << recString
00622                 << " Data and emulated FDL bxNr different.";
00623         m_myCoutStream << "\n Data: bxNr() = " << bxNrData;
00624         m_myCoutStream << "\n Emul: bxNr() = " << bxNrEmul;
00625         m_myCoutStream << "\n";
00626 
00627         if (matchBxInEvent && validBxInEvent) {
00628             m_fdlDataEmul[histIndex][iRec]->Fill(2);
00629         } else {
00630             m_fdlDataEmul_Err[iRec]->Fill(2);
00631         }
00632     }
00633 
00634     LogDebug("L1GtHwValidation") << m_myCoutStream.str() << std::endl;
00635     m_myCoutStream.str("");
00636     m_myCoutStream.clear();
00637 
00638     // get event number since last L1 reset generated in FDL
00639     const boost::uint32_t eventNrData = fdlBlockData.eventNr();
00640     const boost::uint32_t eventNrEmul = fdlBlockEmul.eventNr();
00641 
00642     if (eventNrData == eventNrEmul) {
00643         m_myCoutStream << "\n" << recString
00644                 << " Data and emulated FDL eventNr identical.";
00645         m_myCoutStream << "\n eventNr() = " << eventNrData;
00646         m_myCoutStream << "\n";
00647 
00648     } else {
00649         m_myCoutStream << "\n" << recString
00650                 << " Data and emulated FDL eventNr different.";
00651         m_myCoutStream << "\n Data: eventNr() = " << eventNrData;
00652         m_myCoutStream << "\n Emul: eventNr() = " << eventNrEmul;
00653         m_myCoutStream << "\n";
00654 
00655         if (matchBxInEvent && validBxInEvent) {
00656             m_fdlDataEmul[histIndex][iRec]->Fill(3);
00657         } else {
00658             m_fdlDataEmul_Err[iRec]->Fill(3);
00659         }
00660 
00661     }
00662 
00663     LogDebug("L1GtHwValidation") << m_myCoutStream.str() << std::endl;
00664     m_myCoutStream.str("");
00665     m_myCoutStream.clear();
00666 
00667     // get  technical trigger bits
00668     const TechnicalTriggerWord& gtTechnicalTriggerWordData =
00669             fdlBlockData.gtTechnicalTriggerWord();
00670     const TechnicalTriggerWord& gtTechnicalTriggerWordEmul =
00671             fdlBlockEmul.gtTechnicalTriggerWord();
00672 
00673     int nTechBits = gtTechnicalTriggerWordData.size();
00674 
00675     TechnicalTriggerWord gtTechnicalTriggerWordDataMask(nTechBits);
00676     TechnicalTriggerWord gtTechnicalTriggerWordEmulMask(nTechBits);
00677 
00678     unsigned int bitValue = 0;
00679 
00680     if (matchBxInEvent && validBxInEvent) {
00681         for (int iBit = 0; iBit < nTechBits; ++iBit) {
00682 
00683             unsigned int triggerMask = (m_triggerMaskTechTrig.at(iBit)) & (1
00684                     << PhysicsPartition);
00685 
00686             if (gtTechnicalTriggerWordData[iBit]) {
00687                 m_fdlDataTechDecision[histIndex][iRec]->Fill(iBit);
00688 
00689                 bitValue = (triggerMask) ? 0 : 1;
00690                 gtTechnicalTriggerWordDataMask[iBit] = bitValue;
00691                 if (bitValue) {
00692                     m_fdlDataTechDecisionMask[histIndex][iRec]->Fill(iBit);
00693                 }
00694             }
00695 
00696             if (gtTechnicalTriggerWordEmul.at(iBit)) {
00697                 m_fdlEmulTechDecision[histIndex][iRec]->Fill(iBit);
00698 
00699                 bitValue = (triggerMask) ? 0 : 1;
00700                 gtTechnicalTriggerWordEmulMask[iBit] = bitValue;
00701                 if (bitValue) {
00702                     m_fdlEmulTechDecisionMask[histIndex][iRec]->Fill(iBit);
00703                 }
00704             }
00705         }
00706     } else {
00707         for (int iBit = 0; iBit < nTechBits; ++iBit) {
00708 
00709             if (gtTechnicalTriggerWordData[iBit]) {
00710                 m_fdlDataTechDecision_Err[iRec]->Fill(iBit);
00711             }
00712 
00713             if (gtTechnicalTriggerWordEmul.at(iBit)) {
00714                 m_fdlEmulTechDecision_Err[iRec]->Fill(iBit);
00715             }
00716         }
00717     }
00718 
00719     if (gtTechnicalTriggerWordData == gtTechnicalTriggerWordEmul) {
00720         m_myCoutStream << "\n" << recString
00721                 << " Data and emulated FDL gtTechnicalTriggerWord identical.\n";
00722         fdlBlockData.printGtTechnicalTriggerWord(m_myCoutStream);
00723         m_myCoutStream << "\n";
00724 
00725     } else {
00726         m_myCoutStream << "\n" << recString
00727                 << " Data and emulated FDL gtTechnicalTriggerWord different.";
00728         m_myCoutStream << "\n Data: ";
00729         fdlBlockData.printGtTechnicalTriggerWord(m_myCoutStream);
00730         m_myCoutStream << "\n Emul: ";
00731         fdlBlockEmul.printGtTechnicalTriggerWord(m_myCoutStream);
00732         m_myCoutStream << "\n";
00733 
00734         if (matchBxInEvent && validBxInEvent) {
00735             m_fdlDataEmul[histIndex][iRec]->Fill(4);
00736         } else {
00737             m_fdlDataEmul_Err[iRec]->Fill(4);
00738         }
00739 
00740         if (matchBxInEvent && validBxInEvent) {
00741             for (int iBit = 0; iBit < nTechBits; ++iBit) {
00742                 if (gtTechnicalTriggerWordData[iBit]
00743                         != gtTechnicalTriggerWordEmul.at(iBit)) {
00744                     m_fdlDataEmulTechDecision[histIndex][iRec]->Fill(iBit);
00745                 }
00746             }
00747         } else {
00748             for (int iBit = 0; iBit < nTechBits; ++iBit) {
00749                 if (gtTechnicalTriggerWordData[iBit]
00750                         != gtTechnicalTriggerWordEmul.at(iBit)) {
00751                     m_fdlDataEmulTechDecision_Err[iRec]->Fill(iBit);
00752                 }
00753             }
00754         }
00755     }
00756 
00757     LogDebug("L1GtHwValidation") << m_myCoutStream.str() << std::endl;
00758     m_myCoutStream.str("");
00759     m_myCoutStream.clear();
00760 
00761     if (gtTechnicalTriggerWordDataMask == gtTechnicalTriggerWordEmulMask) {
00762         m_myCoutStream << "\n" << recString
00763                 << " Data and emulated FDL gtTechnicalTriggerWord after mask identical.\n";
00764         m_myCoutStream << "\n";
00765 
00766     } else {
00767         m_myCoutStream << "\n" << recString
00768                 << " Data and emulated FDL gtTechnicalTriggerWord after mask different.";
00769         m_myCoutStream << "\n Data: ";
00770         m_myCoutStream << "\n Emul: ";
00771         m_myCoutStream << "\n";
00772 
00773         if (matchBxInEvent && validBxInEvent) {
00774             m_fdlDataEmul[histIndex][iRec]->Fill(5);
00775         } else {
00776             m_fdlDataEmul_Err[iRec]->Fill(5);
00777         }
00778 
00779         if (matchBxInEvent && validBxInEvent) {
00780             for (int iBit = 0; iBit < nTechBits; ++iBit) {
00781                 if (gtTechnicalTriggerWordData[iBit]
00782                         != gtTechnicalTriggerWordEmul.at(iBit)) {
00783                     m_fdlDataEmulTechDecisionMask[histIndex][iRec]->Fill(iBit);
00784                 }
00785             }
00786         }
00787     }
00788 
00789     LogDebug("L1GtHwValidation") << m_myCoutStream.str() << std::endl;
00790     m_myCoutStream.str("");
00791     m_myCoutStream.clear();
00792 
00793     // get algorithms bits (decision word)
00794     const DecisionWord& gtDecisionWordData = fdlBlockData.gtDecisionWord();
00795     const DecisionWord& gtDecisionWordEmul = fdlBlockEmul.gtDecisionWord();
00796 
00797     int nAlgoBits = gtDecisionWordData.size();
00798 
00799     DecisionWord gtDecisionWordDataMask(nAlgoBits);
00800     DecisionWord gtDecisionWordEmulMask(nAlgoBits);
00801 
00802     // get the index of the prescale factor set from data
00803     int iPfSet = fdlBlockData.gtPrescaleFactorIndexAlgo();
00804     const std::vector<int>& prescaleFactorsAlgoTrig =
00805             (*m_prescaleFactorsAlgoTrig).at(iPfSet);
00806 
00807 
00808     if (matchBxInEvent && validBxInEvent) {
00809 
00810         for (int iBit = 0; iBit < nAlgoBits; ++iBit) {
00811 
00812             unsigned int triggerMask = (m_triggerMaskAlgoTrig.at(iBit)) & (1
00813                     << PhysicsPartition);
00814 
00815             int prescaleFactor = prescaleFactorsAlgoTrig.at(iBit);
00816 
00817             LogTrace("L1GtHwValidation") << "Bit " << iBit
00818                     << ": prescale factor = " << prescaleFactor
00819                     << " trigger mask = " << triggerMask << std::endl;
00820 
00821             if (gtDecisionWordData[iBit]) {
00822                 m_fdlDataAlgoDecision[histIndex][iRec]->Fill(iBit);
00823 
00824                 if (prescaleFactor == 1) {
00825                     m_fdlDataAlgoDecisionUnprescaled[histIndex][iRec]->Fill(
00826                             iBit);
00827                 } else {
00828                     m_fdlDataAlgoDecisionPrescaled[histIndex][iRec]->Fill(iBit);
00829                 }
00830 
00831                 bitValue = (triggerMask) ? 0 : 1;
00832                 gtDecisionWordDataMask[iBit] = bitValue;
00833                 if (bitValue) {
00834                     m_fdlDataAlgoDecisionMask[histIndex][iRec]->Fill(iBit);
00835                 }
00836             }
00837 
00838             if (gtDecisionWordEmul.at(iBit)) {
00839                 m_fdlEmulAlgoDecision[histIndex][iRec]->Fill(iBit);
00840 
00841                 bitValue = (triggerMask) ? 0 : 1;
00842                 gtDecisionWordEmulMask[iBit] = bitValue;
00843                 if (bitValue) {
00844                     m_fdlEmulAlgoDecisionMask[histIndex][iRec]->Fill(iBit);
00845                 }
00846             }
00847         }
00848     } else {
00849         for (int iBit = 0; iBit < nAlgoBits; ++iBit) {
00850             if (gtDecisionWordData[iBit]) {
00851                 m_fdlDataAlgoDecision_Err[iRec]->Fill(iBit);
00852             }
00853         }
00854 
00855         for (int iBit = 0; iBit < nAlgoBits; ++iBit) {
00856             if (gtDecisionWordEmul.at(iBit)) {
00857                 m_fdlEmulAlgoDecision_Err[iRec]->Fill(iBit);
00858             }
00859         }
00860     }
00861 
00862     if (gtDecisionWordData == gtDecisionWordEmul) {
00863         m_myCoutStream << "\n" << recString
00864                 << " Data and emulated FDL gtDecisionWord identical.";
00865         fdlBlockData.printGtDecisionWord(m_myCoutStream);
00866         m_myCoutStream << "\n";
00867 
00868     } else {
00869         m_myCoutStream << "\n" << recString
00870                 << " Data and emulated FDL gtDecisionWord different.";
00871         m_myCoutStream << "\n Data: ";
00872         fdlBlockData.printGtDecisionWord(m_myCoutStream);
00873         m_myCoutStream << "\n Emul: ";
00874         fdlBlockEmul.printGtDecisionWord(m_myCoutStream);
00875         m_myCoutStream << "\n";
00876 
00877         if (matchBxInEvent && validBxInEvent) {
00878             m_fdlDataEmul[histIndex][iRec]->Fill(6);
00879         } else {
00880             m_fdlDataEmul_Err[iRec]->Fill(6);
00881         }
00882 
00883         if (matchBxInEvent && validBxInEvent) {
00884             for (int iBit = 0; iBit < nAlgoBits; ++iBit) {
00885 
00886                 int prescaleFactor = prescaleFactorsAlgoTrig.at(iBit);
00887 
00888                 if (gtDecisionWordData[iBit] != gtDecisionWordEmul.at(iBit)) {
00889 
00890                     m_fdlDataEmulAlgoDecision[histIndex][iRec]->Fill(iBit);
00891 
00892                     if (prescaleFactor == 1) {
00893                         m_fdlDataEmulAlgoDecisionUnprescaled[histIndex][iRec]->Fill(
00894                                 iBit);
00895                     } else {
00896                         m_fdlDataEmulAlgoDecisionPrescaled[histIndex][iRec]->Fill(
00897                                 iBit);
00898                     }
00899 
00900                     if (gtDecisionWordData[iBit]) {
00901                         m_fdlDataAlgoDecision_NoMatch[histIndex][iRec]->Fill(
00902                                 iBit);
00903 
00904                         if (prescaleFactor == 1) {
00905                             m_fdlDataAlgoDecisionUnprescaled_NoMatch[histIndex][iRec]->Fill(
00906                                     iBit);
00907                         } else {
00908                             m_fdlDataAlgoDecisionPrescaled_NoMatch[histIndex][iRec]->Fill(
00909                                     iBit);
00910                         }
00911 
00912                     } else {
00913                         m_fdlEmulAlgoDecision_NoMatch[histIndex][iRec]->Fill(
00914                                 iBit);
00915 
00916                         if (prescaleFactor == 1) {
00917                             m_fdlEmulAlgoDecisionUnprescaled_NoMatch[histIndex][iRec]->Fill(
00918                                     iBit);
00919                         } else {
00920                             m_fdlEmulAlgoDecisionPrescaled_NoMatch[histIndex][iRec]->Fill(
00921                                     iBit);
00922                         }
00923                     }
00924                 }
00925             }
00926         } else {
00927             for (int iBit = 0; iBit < nAlgoBits; ++iBit) {
00928                 if (gtDecisionWordData[iBit] != gtDecisionWordEmul.at(iBit)) {
00929                     m_fdlDataEmulAlgoDecision_Err[iRec]->Fill(iBit);
00930                 }
00931             }
00932         }
00933 
00934     }
00935 
00936     if (gtDecisionWordDataMask == gtDecisionWordEmulMask) {
00937         m_myCoutStream << "\n" << recString
00938                 << " Data and emulated FDL gtDecisionWord after mask identical.";
00939         m_myCoutStream << "\n";
00940 
00941     } else {
00942         m_myCoutStream << "\n" << recString
00943                 << " Data and emulated FDL gtDecisionWord after mask different.";
00944         m_myCoutStream << "\n Data: ";
00945         m_myCoutStream << "\n Emul: ";
00946         m_myCoutStream << "\n";
00947 
00948         if (matchBxInEvent && validBxInEvent) {
00949             m_fdlDataEmul[histIndex][iRec]->Fill(7);
00950         } else {
00951             m_fdlDataEmul_Err[iRec]->Fill(7);
00952         }
00953 
00954         if (matchBxInEvent && validBxInEvent) {
00955             for (int iBit = 0; iBit < nAlgoBits; ++iBit) {
00956                 if (gtDecisionWordDataMask[iBit] != gtDecisionWordEmulMask.at(
00957                         iBit)) {
00958                     m_fdlDataEmulAlgoDecisionMask[histIndex][iRec]->Fill(iBit);
00959                 }
00960             }
00961         }
00962 
00963     }
00964 
00965     // get  extended algorithms bits (extended decision word)
00966     const DecisionWordExtended gtDecisionWordExtendedData =
00967             fdlBlockData.gtDecisionWordExtended();
00968     const DecisionWordExtended gtDecisionWordExtendedEmul =
00969             fdlBlockEmul.gtDecisionWordExtended();
00970 
00971     if (gtDecisionWordExtendedData == gtDecisionWordExtendedEmul) {
00972         m_myCoutStream << "\n" << recString
00973                 << " Data and emulated FDL gtDecisionWordExtended identical.\n";
00974         fdlBlockData.printGtDecisionWordExtended(m_myCoutStream);
00975         m_myCoutStream << "\n";
00976 
00977     } else {
00978         m_myCoutStream << "\n" << recString
00979                 << " Data and emulated FDL gtDecisionWordExtended different.\n";
00980         m_myCoutStream << "\n Data: ";
00981         fdlBlockData.printGtDecisionWordExtended(m_myCoutStream);
00982         m_myCoutStream << "\n Emul: ";
00983         fdlBlockEmul.printGtDecisionWordExtended(m_myCoutStream);
00984         m_myCoutStream << "\n";
00985 
00986         if (matchBxInEvent && validBxInEvent) {
00987             m_fdlDataEmul[histIndex][iRec]->Fill(8);
00988         } else {
00989             m_fdlDataEmul_Err[iRec]->Fill(8);
00990         }
00991 
00992     }
00993 
00994     // get  NoAlgo
00995     const boost::uint16_t noAlgoData = fdlBlockData.noAlgo();
00996     const boost::uint16_t noAlgoEmul = fdlBlockEmul.noAlgo();
00997 
00998     if (noAlgoData == noAlgoEmul) {
00999         m_myCoutStream << "\n" << recString
01000                 << " Data and emulated FDL noAlgo identical.";
01001         m_myCoutStream << "\n noAlgo() = " << noAlgoData;
01002         m_myCoutStream << "\n";
01003 
01004     } else {
01005         m_myCoutStream << "\n" << recString
01006                 << " Data and emulated FDL noAlgo different.";
01007         m_myCoutStream << "\n Data: noAlgo() = " << noAlgoData;
01008         m_myCoutStream << "\n Emul: noAlgo() = " << noAlgoEmul;
01009         m_myCoutStream << "\n";
01010 
01011         if (matchBxInEvent && validBxInEvent) {
01012             m_fdlDataEmul[histIndex][iRec]->Fill(9);
01013         } else {
01014             m_fdlDataEmul_Err[iRec]->Fill(9);
01015         }
01016 
01017     }
01018 
01019     // get  "Final OR" bits
01020     const boost::uint16_t finalORData = fdlBlockData.finalOR();
01021     const boost::uint16_t finalOREmul = fdlBlockEmul.finalOR();
01022 
01023     if (finalORData == finalOREmul) {
01024         m_myCoutStream << "\n" << recString
01025                 << " Data and emulated FDL finalOR identical.";
01026         m_myCoutStream << "\n finalOR() = " << std::hex << "0x" << std::setw(2)
01027                 << std::setfill('0') << finalORData << std::setfill(' ')
01028                 << std::dec;
01029         m_myCoutStream << "\n";
01030 
01031     } else {
01032         m_myCoutStream << "\n" << recString
01033                 << " Data and emulated FDL finalOR different.";
01034         m_myCoutStream << "\n Data: finalOR() = " << std::hex << "0x"
01035                 << std::setw(2) << std::setfill('0') << finalORData
01036                 << std::setfill(' ') << std::dec;
01037         m_myCoutStream << "\n Emul: finalOR() = " << std::hex << "0x"
01038                 << std::setw(2) << std::setfill('0') << finalOREmul
01039                 << std::setfill(' ') << std::dec;
01040         m_myCoutStream << "\n";
01041 
01042         if (matchBxInEvent && validBxInEvent) {
01043             m_fdlDataEmul[histIndex][iRec]->Fill(10);
01044         } else {
01045             m_fdlDataEmul_Err[iRec]->Fill(10);
01046         }
01047 
01048     }
01049 
01050     // get  "Final OR" for physics partition
01051     const int finalORPhysData = finalORData & (1 << PhysicsPartition);
01052     const int finalORPhysEmul = finalOREmul & (1 << PhysicsPartition);
01053 
01054     if (finalORPhysData == finalORPhysEmul) {
01055         m_myCoutStream << "\n" << recString
01056                 << " Data and emulated FDL finalOR for the physics partition identical.";
01057         m_myCoutStream << "\n finalOR() = " << finalORPhysData;
01058         m_myCoutStream << "\n";
01059 
01060     } else {
01061         m_myCoutStream << "\n" << recString
01062                 << " Data and emulated FDL finalOR for the physics partition  different.";
01063         m_myCoutStream << "\n Data: finalOR() = " << finalORPhysData;
01064         m_myCoutStream << "\n Emul: finalOR() = " << finalORPhysEmul;
01065         m_myCoutStream << "\n";
01066 
01067         if (matchBxInEvent && validBxInEvent) {
01068             m_fdlDataEmul[histIndex][iRec]->Fill(11);
01069         } else {
01070             m_fdlDataEmul_Err[iRec]->Fill(11);
01071         }
01072 
01073     }
01074 
01075     // get  local bunch cross number of the actual bx
01076     const boost::uint16_t localBxNrData = fdlBlockData.localBxNr();
01077     const boost::uint16_t localBxNrEmul = fdlBlockEmul.localBxNr();
01078 
01079     if (localBxNrData == localBxNrEmul) {
01080         m_myCoutStream << "\n" << recString
01081                 << " Data and emulated FDL localBxNr identical.";
01082         m_myCoutStream << "\n localBxNr() = " << localBxNrData;
01083         m_myCoutStream << "\n";
01084 
01085     } else {
01086         m_myCoutStream << "\n" << recString
01087                 << " Data and emulated FDL localBxNr different.";
01088         m_myCoutStream << "\n Data: localBxNr() = " << localBxNrData;
01089         m_myCoutStream << "\n Emul: localBxNr() = " << localBxNrEmul;
01090         m_myCoutStream << "\n";
01091 
01092         if (matchBxInEvent && validBxInEvent) {
01093             m_fdlDataEmul[histIndex][iRec]->Fill(12);
01094         } else {
01095             m_fdlDataEmul_Err[iRec]->Fill(12);
01096         }
01097 
01098     }
01099 
01100     edm::LogInfo("L1GtHwValidation") << m_myCoutStream.str() << std::endl;
01101     m_myCoutStream.str("");
01102     m_myCoutStream.clear();
01103 
01104 }
01105 
01106 //compare the PSB board
01107 void L1GtHwValidation::comparePSB(const edm::Event& iEvent,
01108         const edm::EventSetup& evSetup, const L1GtPsbWord& psbBlockData,
01109         const L1GtPsbWord& psbBlockEmul) {
01110 
01111     if (psbBlockData == psbBlockEmul) {
01112         m_myCoutStream << "\nData and emulated PSB blocks: identical.\n";
01113         psbBlockData.print(m_myCoutStream);
01114 
01115     } else {
01116         m_myCoutStream << "\nData and emulated PSB blocks: different.\n";
01117 
01118         m_myCoutStream << "\nData: PSB block\n";
01119         psbBlockData.print(m_myCoutStream);
01120 
01121         m_myCoutStream << "\nEmul: PSB block\n";
01122         psbBlockEmul.print(m_myCoutStream);
01123 
01124     }
01125 
01126     LogDebug("L1GtHwValidation") << m_myCoutStream.str() << std::endl;
01127 
01128     m_myCoutStream.str("");
01129     m_myCoutStream.clear();
01130 
01131     // get BoardId value
01132     const boost::uint16_t boardIdData = psbBlockData.boardId();
01133     const boost::uint16_t boardIdEmul = psbBlockEmul.boardId();
01134 
01135     if (boardIdData == boardIdEmul) {
01136         m_myCoutStream << "\nData and emulated PSB boardId identical.";
01137         m_myCoutStream << "\n boardId() = " << std::hex << "0x" << std::setw(4)
01138                 << std::setfill('0') << boardIdData << std::setfill(' ')
01139                 << std::dec;
01140         m_myCoutStream << "\n";
01141 
01142     } else {
01143         m_myCoutStream << "\nData and emulated PSB boardId different.";
01144         m_myCoutStream << "\n Data: boardId() = " << std::hex << "0x"
01145                 << std::setw(4) << std::setfill('0') << boardIdData
01146                 << std::setfill(' ') << std::dec;
01147         m_myCoutStream << "\n Emul: boardId() = " << std::hex << "0x"
01148                 << std::setw(4) << std::setfill('0') << boardIdEmul
01149                 << std::setfill(' ') << std::dec;
01150         m_myCoutStream << "\n";
01151 
01152     }
01153 
01154     // get bunch cross in the GT event record
01155     const int bxInEventData = psbBlockData.bxInEvent();
01156     const int bxInEventEmul = psbBlockEmul.bxInEvent();
01157 
01158     if (bxInEventData == bxInEventEmul) {
01159         m_myCoutStream << "\nData and emulated PSB bxInEvent identical.";
01160         m_myCoutStream << "\n bxInEvent() = " << bxInEventData;
01161         m_myCoutStream << "\n";
01162 
01163     } else {
01164         m_myCoutStream << "\nData and emulated PSB bxInEvent different.";
01165         m_myCoutStream << "\n Data: bxInEvent() = " << bxInEventData;
01166         m_myCoutStream << "\n Emul: bxInEvent() = " << bxInEventEmul;
01167         m_myCoutStream << "\n";
01168 
01169     }
01170 
01171     // get BxNr - bunch cross number of the actual bx
01172     const boost::uint16_t bxNrData = psbBlockData.bxNr();
01173     const boost::uint16_t bxNrEmul = psbBlockEmul.bxNr();
01174 
01175     if (bxNrData == bxNrEmul) {
01176         m_myCoutStream << "\nData and emulated PSB bxNr identical.";
01177         m_myCoutStream << "\n bxNr() = " << bxNrData;
01178         m_myCoutStream << "\n";
01179 
01180     } else {
01181         m_myCoutStream << "\nData and emulated PSB bxNr different.";
01182         m_myCoutStream << "\n Data: bxNr() = " << bxNrData;
01183         m_myCoutStream << "\n Emul: bxNr() = " << bxNrEmul;
01184         m_myCoutStream << "\n";
01185 
01186     }
01187 
01188     // get event number since last L1 reset generated in FDL
01189     const boost::uint32_t eventNrData = psbBlockData.eventNr();
01190     const boost::uint32_t eventNrEmul = psbBlockEmul.eventNr();
01191 
01192     if (eventNrData == eventNrEmul) {
01193         m_myCoutStream << "\nData and emulated PSB eventNr identical.";
01194         m_myCoutStream << "\n eventNr() = " << eventNrData;
01195         m_myCoutStream << "\n";
01196 
01197     } else {
01198         m_myCoutStream << "\nData and emulated PSB eventNr different.";
01199         m_myCoutStream << "\n Data: eventNr() = " << eventNrData;
01200         m_myCoutStream << "\n Emul: eventNr() = " << eventNrEmul;
01201         m_myCoutStream << "\n";
01202 
01203     }
01204 
01206     boost::uint16_t valData;
01207     boost::uint16_t valEmul;
01208 
01209     for (int iA = 0; iA < psbBlockData.NumberAData; ++iA) {
01210         valData = psbBlockData.aData(iA);
01211         valEmul = psbBlockEmul.aData(iA);
01212 
01213         if (valData == valEmul) {
01214             m_myCoutStream << "\nData and emulated PSB aData(" << iA
01215                     << ") identical.";
01216             m_myCoutStream << "\n aData(iA) = " << std::hex << "0x"
01217                     << std::setw(4) << std::setfill('0') << valData
01218                     << std::setfill(' ') << std::dec;
01219             m_myCoutStream << "\n";
01220 
01221         } else {
01222             m_myCoutStream << "\nData and emulated PSB aData(" << iA
01223                     << ") different.";
01224             m_myCoutStream << "\n Data: aData(iA) = " << std::hex << "0x"
01225                     << std::setw(4) << std::setfill('0') << valData
01226                     << std::setfill(' ') << std::dec;
01227             m_myCoutStream << "\n Emul: aData(iA) = " << std::hex << "0x"
01228                     << std::setw(4) << std::setfill('0') << valEmul
01229                     << std::setfill(' ') << std::dec;
01230             m_myCoutStream << "\n";
01231 
01232         }
01233 
01234     }
01235 
01237     for (int iB = 0; iB < psbBlockData.NumberBData; ++iB) {
01238         valData = psbBlockData.bData(iB);
01239         valEmul = psbBlockEmul.bData(iB);
01240 
01241         if (valData == valEmul) {
01242             m_myCoutStream << "\nData and emulated PSB bData(" << iB
01243                     << ") identical.";
01244             m_myCoutStream << "\n bData(iA) = " << std::hex << "0x"
01245                     << std::setw(4) << std::setfill('0') << valData
01246                     << std::setfill(' ') << std::dec;
01247             m_myCoutStream << "\n";
01248 
01249         } else {
01250             m_myCoutStream << "\nData and emulated PSB bData(" << iB
01251                     << ") different.";
01252             m_myCoutStream << "\n Data: bData(iA) = " << std::hex << "0x"
01253                     << std::setw(4) << std::setfill('0') << valData
01254                     << std::setfill(' ') << std::dec;
01255             m_myCoutStream << "\n Emul: bData(iA) = " << std::hex << "0x"
01256                     << std::setw(4) << std::setfill('0') << valEmul
01257                     << std::setfill(' ') << std::dec;
01258             m_myCoutStream << "\n";
01259 
01260         }
01261 
01262     }
01263 
01264     // get  local bunch cross number of the actual bx
01265     const boost::uint16_t localBxNrData = psbBlockData.localBxNr();
01266     const boost::uint16_t localBxNrEmul = psbBlockEmul.localBxNr();
01267 
01268     if (localBxNrData == localBxNrEmul) {
01269         m_myCoutStream << "\nData and emulated PSB localBxNr identical.";
01270         m_myCoutStream << "\n localBxNr() = " << localBxNrData;
01271         m_myCoutStream << "\n";
01272 
01273     } else {
01274         m_myCoutStream << "\nData and emulated PSB localBxNr different.";
01275         m_myCoutStream << "\n Data: localBxNr() = " << localBxNrData;
01276         m_myCoutStream << "\n Emul: localBxNr() = " << localBxNrEmul;
01277         m_myCoutStream << "\n";
01278 
01279     }
01280 
01281     edm::LogInfo("L1GtHwValidation") << m_myCoutStream.str() << std::endl;
01282     m_myCoutStream.str("");
01283     m_myCoutStream.clear();
01284 
01285 }
01286 
01287 //compare the TCS board
01288 void L1GtHwValidation::compareTCS(const edm::Event& iEvent,
01289         const edm::EventSetup& evSetup, const L1TcsWord&, const L1TcsWord&) {
01290     // empty
01291 }
01292 
01293 //L1 GT DAQ record comparison
01294 void L1GtHwValidation::compareDaqRecord(const edm::Event& iEvent,
01295         const edm::EventSetup& evSetup) {
01296 
01297     // formal index for DAQ record 
01298     int iRec = 0;
01299 
01300     // get the L1 GT hardware DAQ record L1GlobalTriggerReadoutRecord
01301     edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecordData;
01302     iEvent.getByLabel(m_l1GtDataDaqInputTag, gtReadoutRecordData);
01303 
01304     bool validData = false;
01305 
01306     if (!gtReadoutRecordData.isValid()) {
01307         m_nrDataEventError++;
01308     } else {
01309         validData = true;
01310     }
01311 
01312     // get the L1 GT emulator DAQ record L1GlobalTriggerReadoutRecord
01313     edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecordEmul;
01314     iEvent.getByLabel(m_l1GtEmulDaqInputTag, gtReadoutRecordEmul);
01315 
01316     bool validEmul = false;
01317 
01318     if (!gtReadoutRecordEmul.isValid()) {
01319         m_nrEmulEventError++;
01320     } else {
01321         validEmul = true;
01322     }
01323 
01324     if ((!validData) || (!validEmul)) {
01325         edm::LogWarning("L1GtHwValidation")
01326                 << "\n No valid product found: DAQ L1GlobalTriggerReadoutRecord"
01327                 << "\n     Data validity [1 = true; 0 = false]: " << validData
01328                 << "\n     Emulator validity: [1 = true; 0 = false]: "
01329                 << validEmul << "\n DAQ histograms will not be filled.\n"
01330                 << std::endl;
01331 
01332         return;
01333     }
01334 
01335     // compare GTFE
01336     const L1GtfeWord& gtfeBlockData = gtReadoutRecordData->gtfeWord();
01337     const L1GtfeWord& gtfeBlockEmul = gtReadoutRecordEmul->gtfeWord();
01338 
01339     compareGTFE(iEvent, evSetup, gtfeBlockData, gtfeBlockEmul, iRec);
01340 
01341     // FDL comparison
01342     const std::vector<L1GtFdlWord>& gtFdlVectorData =
01343             gtReadoutRecordData->gtFdlVector();
01344     const std::vector<L1GtFdlWord>& gtFdlVectorEmul =
01345             gtReadoutRecordEmul->gtFdlVector();
01346 
01347     int gtFdlVectorDataSize = gtFdlVectorData.size();
01348     int gtFdlVectorEmulSize = gtFdlVectorEmul.size();
01349 
01350     if (gtFdlVectorDataSize == gtFdlVectorEmulSize) {
01351         m_myCoutStream << "\nData and emulated FDL vector size: identical.\n";
01352         m_myCoutStream << "  Size: " << gtFdlVectorDataSize << std::endl;
01353 
01354         for (int iFdl = 0; iFdl < gtFdlVectorDataSize; ++iFdl) {
01355 
01356             const L1GtFdlWord& fdlBlockData = gtFdlVectorData[iFdl];
01357             const L1GtFdlWord& fdlBlockEmul = gtFdlVectorEmul[iFdl];
01358 
01359             compareFDL(iEvent, evSetup, fdlBlockData, fdlBlockEmul, iRec);
01360         }
01361     } else {
01362         m_myCoutStream << "\nData and emulated FDL vector size: different.\n";
01363         m_myCoutStream << "  Data: size = " << gtFdlVectorDataSize << std::endl;
01364         m_myCoutStream << "  Emul: size = " << gtFdlVectorEmulSize << std::endl;
01365 
01366     }
01367 
01368     LogDebug("L1GtHwValidation") << m_myCoutStream.str() << std::endl;
01369 
01370     m_myCoutStream.str("");
01371     m_myCoutStream.clear();
01372 
01373     // PSB comparison
01374     const std::vector<L1GtPsbWord>& gtPsbVectorData =
01375             gtReadoutRecordData->gtPsbVector();
01376     const std::vector<L1GtPsbWord>& gtPsbVectorEmul =
01377             gtReadoutRecordEmul->gtPsbVector();
01378 
01379     int gtPsbVectorDataSize = gtPsbVectorData.size();
01380     int gtPsbVectorEmulSize = gtPsbVectorEmul.size();
01381 
01382     if (gtPsbVectorDataSize == gtPsbVectorEmulSize) {
01383         m_myCoutStream << "\nData and emulated PSB vector size: identical.\n";
01384         m_myCoutStream << "  Size: " << gtPsbVectorDataSize << std::endl;
01385     } else {
01386         m_myCoutStream << "\nData and emulated PSB vector size: different.\n";
01387         m_myCoutStream << "  Data: size = " << gtPsbVectorDataSize << std::endl;
01388         m_myCoutStream << "  Emul: size = " << gtPsbVectorEmulSize << std::endl;
01389 
01390     }
01391 
01392     // the order of PSB block in the gtPsbVector is different in emulator and in data
01393     // in emulator: all active PSB in one BxInEvent, ordered L1A-1, L1A, L1A+1
01394     // in unpacker: every PSB in all BxInEvent
01395     for (int iPsb = 0; iPsb < gtPsbVectorDataSize; ++iPsb) {
01396 
01397         const L1GtPsbWord& psbBlockData = gtPsbVectorData[iPsb];
01398         const boost::uint16_t boardIdData = psbBlockData.boardId();
01399         const int bxInEventData = psbBlockData.bxInEvent();
01400 
01401         // search the corresponding PSB in the emulated record using the 
01402         // BoardId and the BxInEvent  
01403 
01404         bool foundPSB = false;
01405 
01406         for (int iPsbF = 0; iPsbF < gtPsbVectorEmulSize; ++iPsbF) {
01407 
01408             const L1GtPsbWord& psbBlockEmul = gtPsbVectorEmul[iPsbF];
01409             const boost::uint16_t boardIdEmul = psbBlockEmul.boardId();
01410             const int bxInEventEmul = psbBlockEmul.bxInEvent();
01411 
01412             if ((boardIdEmul == boardIdData)
01413                     && (bxInEventData == bxInEventEmul)) {
01414 
01415                 foundPSB = true;
01416 
01417                 // compare the boards
01418                 comparePSB(iEvent, evSetup, psbBlockData, psbBlockEmul);
01419             }
01420 
01421         }
01422 
01423         if (!foundPSB) {
01424             m_myCoutStream << "\nNo emulated PSB with boardId() = " << std::hex
01425                     << "0x" << std::setw(4) << std::setfill('0') << boardIdData
01426                     << std::setfill(' ') << std::dec << " and BxInEvent = "
01427                     << bxInEventData << " was found";
01428 
01429         }
01430 
01431     }
01432 
01433     edm::LogInfo("L1GtHwValidation") << m_myCoutStream.str() << std::endl;
01434 
01435     m_myCoutStream.str("");
01436     m_myCoutStream.clear();
01437 
01438 }
01439 
01440 // L1 GT EVM record comparison
01441 void L1GtHwValidation::compareEvmRecord(const edm::Event& iEvent,
01442         const edm::EventSetup& evSetup) {
01443 
01444     // formal index for EVM record
01445     int iRec = 1;
01446 
01447     // get the L1 GT hardware EVM record L1GlobalTriggerEvmReadoutRecord
01448     edm::Handle<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecordData;
01449     iEvent.getByLabel(m_l1GtDataEvmInputTag, gtReadoutRecordData);
01450 
01451     bool validData = false;
01452 
01453     if (!gtReadoutRecordData.isValid()) {
01454         m_nrDataEventError++;
01455     } else {
01456         validData = true;
01457     }
01458 
01459     // get the L1 GT emulator EVM record L1GlobalTriggerEvmReadoutRecord
01460     edm::Handle<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecordEmul;
01461     iEvent.getByLabel(m_l1GtEmulEvmInputTag, gtReadoutRecordEmul);
01462 
01463     bool validEmul = false;
01464 
01465     if (!gtReadoutRecordEmul.isValid()) {
01466         m_nrEmulEventError++;
01467     } else {
01468         validEmul = true;
01469     }
01470 
01471     if ((!validData) || (!validEmul)) {
01472         edm::LogWarning("L1GtHwValidation")
01473                 << "\n No valid product found: EVM L1GlobalTriggerEvmReadoutRecord"
01474                 << "\n     Data validity [1 = true; 0 = false]: " << validData
01475                 << "\n     Emulator validity: [1 = true; 0 = false]: "
01476                 << validEmul << "\n EVM histograms will not be filled.\n"
01477                 << std::endl;
01478 
01479         return;
01480     }
01481 
01482     // compare GTFE
01483     const L1GtfeWord& gtfeBlockData = gtReadoutRecordData->gtfeWord();
01484     const L1GtfeWord& gtfeBlockEmul = gtReadoutRecordEmul->gtfeWord();
01485 
01486     compareGTFE(iEvent, evSetup, gtfeBlockData, gtfeBlockEmul, iRec);
01487 
01488     // FDL comparison
01489     const std::vector<L1GtFdlWord>& gtFdlVectorData =
01490             gtReadoutRecordData->gtFdlVector();
01491     const std::vector<L1GtFdlWord>& gtFdlVectorEmul =
01492             gtReadoutRecordEmul->gtFdlVector();
01493 
01494     int gtFdlVectorDataSize = gtFdlVectorData.size();
01495     int gtFdlVectorEmulSize = gtFdlVectorEmul.size();
01496 
01497     if (gtFdlVectorDataSize == gtFdlVectorEmulSize) {
01498         m_myCoutStream << "\nData and emulated FDL vector size: identical.\n";
01499         m_myCoutStream << "  Size: " << gtFdlVectorDataSize << std::endl;
01500 
01501         for (int iFdl = 0; iFdl < gtFdlVectorDataSize; ++iFdl) {
01502 
01503             const L1GtFdlWord& fdlBlockData = gtFdlVectorData[iFdl];
01504             const L1GtFdlWord& fdlBlockEmul = gtFdlVectorEmul[iFdl];
01505 
01506             compareFDL(iEvent, evSetup, fdlBlockData, fdlBlockEmul, iRec);
01507         }
01508     } else {
01509         m_myCoutStream << "\nData and emulated FDL vector size: different.\n";
01510         m_myCoutStream << "  Data: size = " << gtFdlVectorDataSize << std::endl;
01511         m_myCoutStream << "  Emul: size = " << gtFdlVectorEmulSize << std::endl;
01512 
01513     }
01514 
01515     // FIXME compare TCS
01516 
01517     LogDebug("L1GtHwValidation") << m_myCoutStream.str() << std::endl;
01518 
01519     m_myCoutStream.str("");
01520     m_myCoutStream.clear();
01521 
01522     edm::LogInfo("L1GtHwValidation") << m_myCoutStream.str() << std::endl;
01523 
01524     m_myCoutStream.str("");
01525     m_myCoutStream.clear();
01526 
01527 }
01528 
01529 // compare the GCT collections obtained from L1 GT PSB with the input 
01530 // GCT collections
01531 void L1GtHwValidation::compareGt_Gct(const edm::Event& iEvent,
01532         const edm::EventSetup&) {
01533 
01534     // FIXME
01535 
01536 }
01537 
01538 // analyze each event: event loop
01539 void L1GtHwValidation::analyze(const edm::Event& iEvent,
01540         const edm::EventSetup& evSetup) {
01541 
01542     ++m_nrEvJob;
01543     ++m_nrEvRun;
01544 
01545     // L1 GT DAQ record comparison
01546     compareDaqRecord(iEvent, evSetup);
01547 
01548     // L1 GT EVM record comparison
01549     compareEvmRecord(iEvent, evSetup);
01550 
01551     // GCT collections from L1 GT PSB versus unpacked GCT 
01552     compareGt_Gct(iEvent, evSetup);
01553 
01554 }
01555 
01556 // book all histograms for the module
01557 void L1GtHwValidation::bookHistograms() {
01558 
01559     // histograms
01560 
01561     const unsigned int numberTechTriggers =
01562             L1GlobalTriggerReadoutSetup::NumberTechnicalTriggers;
01563 
01564     const unsigned int numberAlgoTriggers =
01565             L1GlobalTriggerReadoutSetup::NumberPhysTriggers;
01566 
01567     for (int iRec = 0; iRec < NumberOfGtRecords; ++iRec) {
01568 
01569         std::string recString;
01570         if (iRec == 0) {
01571             recString = "Daq_";
01572         } else {
01573             recString = "Evm_";
01574         }
01575 
01576         std::string hName;
01577         const char* histName;
01578 
01579         hName = recString + "gtfeDataEmul";
01580         histName = hName.c_str();
01581 
01582         // GTFE histograms
01583         m_gtfeDataEmul[iRec] = m_dbe->book1D(histName,
01584                 "GTFE data vs emul mismatch", 8, 0., 7.);
01585         m_gtfeDataEmul[iRec]->setBinLabel(1, "BoardId", 1);
01586         m_gtfeDataEmul[iRec]->setBinLabel(2, "RecordLength1", 1);
01587         m_gtfeDataEmul[iRec]->setBinLabel(3, "RecordLength0", 1);
01588         m_gtfeDataEmul[iRec]->setBinLabel(4, "BxNr", 1);
01589         m_gtfeDataEmul[iRec]->setBinLabel(5, "SetupVersion", 1);
01590         m_gtfeDataEmul[iRec]->setBinLabel(6, "DaqActiveBoards", 1);
01591         m_gtfeDataEmul[iRec]->setBinLabel(7, "AltNrBxBoard", 1);
01592         m_gtfeDataEmul[iRec]->setBinLabel(8, "TotalTriggerNr", 1);
01593 
01594         // FDL histograms
01595 
01596         for (int iHist = 0; iHist < TotalBxInEvent; ++iHist) {
01597 
01598             // convert [0, TotalBxInEvent] to [-X, +X] and add to histogram name 
01599             int iIndex = iHist - ((TotalBxInEvent + 1) / 2 - 1);
01600             int hIndex = (iIndex + 16) % 16;
01601 
01602             std::stringstream ss;
01603             std::string str;
01604             ss << std::uppercase << std::hex << hIndex;
01605             ss >> str;
01606 
01607             hName = recString + "FdlDataEmul_" + str;
01608             histName = hName.c_str();
01609 
01610             std::string hTitle = "FDL data vs emul mismatch for BxInEvent = "
01611                     + str;
01612             const char* histTitle = hTitle.c_str();
01613 
01614             //
01615 
01616             m_fdlDataEmul[iHist][iRec] = m_dbe->book1D(histName, histTitle, 13,
01617                     0., 13.);
01618             m_fdlDataEmul[iHist][iRec]->setBinLabel(1, "BoardId", 1);
01619             m_fdlDataEmul[iHist][iRec]->setBinLabel(2, "BxInEvent", 1);
01620             m_fdlDataEmul[iHist][iRec]->setBinLabel(3, "BxNr", 1);
01621             m_fdlDataEmul[iHist][iRec]->setBinLabel(4, "EventNr", 1);
01622             m_fdlDataEmul[iHist][iRec]->setBinLabel(5, "TechTrigger", 1);
01623             m_fdlDataEmul[iHist][iRec]->setBinLabel(6, "TechTriggerMask", 1);
01624             m_fdlDataEmul[iHist][iRec]->setBinLabel(7, "AlgoTrigger", 1);
01625             m_fdlDataEmul[iHist][iRec]->setBinLabel(8, "AlgoTriggerMask", 1);
01626             m_fdlDataEmul[iHist][iRec]->setBinLabel(9, "AlgoExtend", 1);
01627             m_fdlDataEmul[iHist][iRec]->setBinLabel(10, "NoAlgo", 1);
01628             m_fdlDataEmul[iHist][iRec]->setBinLabel(11, "FinalORAllParts", 1);
01629             m_fdlDataEmul[iHist][iRec]->setBinLabel(12, "FinalORPhysPart", 1);
01630             m_fdlDataEmul[iHist][iRec]->setBinLabel(13, "LocalBxNr", 1);
01631 
01632             // algorithm decision
01633             //   data
01634             hName = recString + "Data_AlgoDecision_" + str;
01635             histName = hName.c_str();
01636 
01637             hTitle = "Data: algorithm decision word for BxInEvent = " + str;
01638             histTitle = hTitle.c_str();
01639 
01640             m_fdlDataAlgoDecision[iHist][iRec] = m_dbe->book1D(histName,
01641                     histTitle, numberAlgoTriggers, 0., numberAlgoTriggers);
01642 
01643             //   emul
01644             hName = recString + "Emul_AlgoDecision_" + str;
01645             histName = hName.c_str();
01646 
01647             hTitle = "Emul: algorithm decision word for BxInEvent = " + str;
01648             histTitle = hTitle.c_str();
01649 
01650             m_fdlEmulAlgoDecision[iHist][iRec] = m_dbe->book1D(histName,
01651                     histTitle, numberAlgoTriggers, 0., numberAlgoTriggers);
01652 
01653             // algorithm decision for prescaled algorithms
01654             //   data
01655             hName = recString + "Data_AlgoDecision_Prescaled_" + str;
01656             histName = hName.c_str();
01657 
01658             hTitle
01659                     = "Data: prescaled algorithms: algorithm decision for BxInEvent = "
01660                             + str;
01661             histTitle = hTitle.c_str();
01662 
01663             m_fdlDataAlgoDecisionPrescaled[iHist][iRec] = m_dbe->book1D(
01664                     histName, histTitle, numberAlgoTriggers, 0.,
01665                     numberAlgoTriggers);
01666 
01667             //   emul
01668             hName = recString + "Emul_AlgoDecision_Prescaled_" + str;
01669             histName = hName.c_str();
01670 
01671             hTitle
01672                     = "Emul: prescaled algorithms: algorithm decision for BxInEvent = "
01673                             + str;
01674             histTitle = hTitle.c_str();
01675 
01676             m_fdlEmulAlgoDecisionPrescaled[iHist][iRec] = m_dbe->book1D(
01677                     histName, histTitle, numberAlgoTriggers, 0.,
01678                     numberAlgoTriggers);
01679 
01680             // algorithm decision for unprescaled algorithms
01681             //   data
01682             hName = recString + "Data_AlgoDecision_Unprescaled_" + str;
01683             histName = hName.c_str();
01684 
01685             hTitle
01686                     = "Data: unprescaled algorithms: algorithm decision for BxInEvent = "
01687                             + str;
01688             histTitle = hTitle.c_str();
01689 
01690             m_fdlDataAlgoDecisionUnprescaled[iHist][iRec] = m_dbe->book1D(
01691                     histName, histTitle, numberAlgoTriggers, 0.,
01692                     numberAlgoTriggers);
01693 
01694             //   emul
01695             hName = recString + "Emul_AlgoDecision_Unprescaled_" + str;
01696             histName = hName.c_str();
01697 
01698             hTitle
01699                     = "Emul: unprescaled algorithms: algorithm decision for BxInEvent = "
01700                             + str;
01701             histTitle = hTitle.c_str();
01702 
01703             m_fdlEmulAlgoDecisionUnprescaled[iHist][iRec] = m_dbe->book1D(
01704                     histName, histTitle, numberAlgoTriggers, 0.,
01705                     numberAlgoTriggers);
01706 
01707             // algorithm decision after masking (partition physics)
01708             //   data
01709             hName = recString + "Data_AlgoDecisionAfterMask_" + str;
01710             histName = hName.c_str();
01711 
01712             hTitle
01713                     = "Data, physics partition: algorithm decision word after mask for BxInEvent = "
01714                             + str;
01715             histTitle = hTitle.c_str();
01716 
01717             m_fdlDataAlgoDecisionMask[iHist][iRec] = m_dbe->book1D(histName,
01718                     histTitle, numberAlgoTriggers, 0., numberAlgoTriggers);
01719 
01720             //   emul
01721             hName = recString + "Emul_AlgoDecisionAfterMask_" + str;
01722             histName = hName.c_str();
01723 
01724             hTitle
01725                     = "Emul, physics partition: algorithm decision word after mask for BxInEvent =  "
01726                             + str;
01727             histTitle = hTitle.c_str();
01728 
01729             m_fdlEmulAlgoDecisionMask[iHist][iRec] = m_dbe->book1D(histName,
01730                     histTitle, numberAlgoTriggers, 0., numberAlgoTriggers);
01731 
01732             //
01733             hName = recString + "DataEmul_AlgoDecision_" + str;
01734             histName = hName.c_str();
01735 
01736             hTitle
01737                     = "Data vs emul: non-matching algorithm decision word for BxInEvent = "
01738                             + str;
01739             histTitle = hTitle.c_str();
01740 
01741             m_fdlDataEmulAlgoDecision[iHist][iRec] = m_dbe->book1D(histName,
01742                     histTitle, numberAlgoTriggers, 0., numberAlgoTriggers);
01743 
01744             //
01745             hName = recString + "DataEmul_AlgoDecision_Prescaled_" + str;
01746             histName = hName.c_str();
01747 
01748             hTitle
01749                     = "Data vs emul: prescaled algorithms with non-matching decision for BxInEvent = "
01750                             + str;
01751             histTitle = hTitle.c_str();
01752 
01753             m_fdlDataEmulAlgoDecisionPrescaled[iHist][iRec] = m_dbe->book1D(
01754                     histName, histTitle, numberAlgoTriggers, 0.,
01755                     numberAlgoTriggers);
01756 
01757             //
01758             hName = recString + "DataEmul_AlgoDecision_Unprescaled_" + str;
01759             histName = hName.c_str();
01760 
01761             hTitle
01762                     = "Data vs emul: unprescaled algorithms with non-matching decision for BxInEvent = "
01763                             + str;
01764             histTitle = hTitle.c_str();
01765 
01766             m_fdlDataEmulAlgoDecisionUnprescaled[iHist][iRec] = m_dbe->book1D(
01767                     histName, histTitle, numberAlgoTriggers, 0.,
01768                     numberAlgoTriggers);
01769 
01770             //
01771             hName = recString + "Data_AlgoDecision_NoMatch_" + str;
01772             histName = hName.c_str();
01773 
01774             hTitle
01775                     = "Data: algorithm decision for non-matching cases for BxInEvent = "
01776                             + str;
01777             histTitle = hTitle.c_str();
01778 
01779             m_fdlDataAlgoDecision_NoMatch[iHist][iRec] = m_dbe->book1D(
01780                     histName, histTitle, numberAlgoTriggers, 0.,
01781                     numberAlgoTriggers);
01782 
01783             //
01784             hName = recString + "Emul_AlgoDecision_NoMatch_" + str;
01785             histName = hName.c_str();
01786 
01787             hTitle
01788                     = "Emul: algorithm decision for non-matching cases for BxInEvent = "
01789                             + str;
01790             histTitle = hTitle.c_str();
01791 
01792             m_fdlEmulAlgoDecision_NoMatch[iHist][iRec] = m_dbe->book1D(
01793                     histName, histTitle, numberAlgoTriggers, 0.,
01794                     numberAlgoTriggers);
01795 
01796             // prescaled algorithms
01797             hName = recString + "Data_AlgoDecision_Prescaled_NoMatch_" + str;
01798             histName = hName.c_str();
01799 
01800             hTitle
01801                     = "Data: prescaled algorithms: non-matching algorithm decision for BxInEvent = "
01802                             + str;
01803             histTitle = hTitle.c_str();
01804 
01805             m_fdlDataAlgoDecisionPrescaled_NoMatch[iHist][iRec]
01806                     = m_dbe->book1D(histName, histTitle, numberAlgoTriggers,
01807                             0., numberAlgoTriggers);
01808 
01809             //
01810             hName = recString + "Emul_AlgoDecision_Prescaled_NoMatch_" + str;
01811             histName = hName.c_str();
01812 
01813             hTitle
01814                     = "Emul: prescaled algorithms: non-matching algorithm decision for BxInEvent = "
01815                             + str;
01816             histTitle = hTitle.c_str();
01817 
01818             m_fdlEmulAlgoDecisionPrescaled_NoMatch[iHist][iRec]
01819                     = m_dbe->book1D(histName, histTitle, numberAlgoTriggers,
01820                             0., numberAlgoTriggers);
01821 
01822 
01823             // unprescaled algorithms - non-matching
01824             hName = recString + "Data_AlgoDecision_Unprescaled_NoMatch_" + str;
01825             histName = hName.c_str();
01826 
01827             hTitle
01828                     = "Data: unprescaled algorithms: non-matching algorithm decision for BxInEvent = "
01829                             + str;
01830             histTitle = hTitle.c_str();
01831 
01832             m_fdlDataAlgoDecisionUnprescaled_NoMatch[iHist][iRec]
01833                     = m_dbe->book1D(histName, histTitle, numberAlgoTriggers,
01834                             0., numberAlgoTriggers);
01835 
01836             //
01837             hName = recString + "Emul_AlgoDecision_Unprescaled_NoMatch_" + str;
01838             histName = hName.c_str();
01839 
01840             hTitle
01841                     = "Emul: unprescaled algorithms: non-matching algorithm decision for BxInEvent = "
01842                             + str;
01843             histTitle = hTitle.c_str();
01844 
01845             m_fdlEmulAlgoDecisionUnprescaled_NoMatch[iHist][iRec]
01846                     = m_dbe->book1D(histName, histTitle, numberAlgoTriggers,
01847                             0., numberAlgoTriggers);
01848 
01849 
01850             // 
01851             hName = recString + "DataEmul_AlgoDecisionAfterMask_" + str;
01852             histName = hName.c_str();
01853 
01854             hTitle
01855                     = "Data vs emul, physics partition: non-matching algorithm decision word after mask for BxInEvent = "
01856                             + str;
01857             histTitle = hTitle.c_str();
01858 
01859             m_fdlDataEmulAlgoDecisionMask[iHist][iRec] = m_dbe->book1D(
01860                     histName, histTitle, numberAlgoTriggers, 0.,
01861                     numberAlgoTriggers);
01862 
01863             // technical trigger decision 
01864             //   data
01865             hName = recString + "Data_TechDecision_" + str;
01866             histName = hName.c_str();
01867 
01868             hTitle = "Data technical trigger decision word for BxInEvent = "
01869                     + str;
01870             histTitle = hTitle.c_str();
01871 
01872             m_fdlDataTechDecision[iHist][iRec] = m_dbe->book1D(histName,
01873                     histTitle, numberTechTriggers, 0., numberTechTriggers);
01874 
01875             //   emul
01876             hName = recString + "Emul_TechDecision_" + str;
01877             histName = hName.c_str();
01878 
01879             hTitle = "Emul: technical trigger decision word for BxInEvent = "
01880                     + str;
01881             histTitle = hTitle.c_str();
01882 
01883             m_fdlEmulTechDecision[iHist][iRec] = m_dbe->book1D(histName,
01884                     histTitle, numberTechTriggers, 0., numberTechTriggers);
01885 
01886             // technical trigger decision after masking (partition physics)
01887             hName = recString + "Data_TechDecisionAfterMask_" + str;
01888             histName = hName.c_str();
01889 
01890             hTitle
01891                     = "Data technical trigger decision word after mask for BxInEvent = "
01892                             + str;
01893             histTitle = hTitle.c_str();
01894 
01895             m_fdlDataTechDecisionMask[iHist][iRec] = m_dbe->book1D(histName,
01896                     histTitle, numberTechTriggers, 0., numberTechTriggers);
01897 
01898             //
01899             hName = recString + "Emul_TechDecisionAfterMask_" + str;
01900             histName = hName.c_str();
01901 
01902             hTitle
01903                     = "Emul: technical trigger decision word after mask for BxInEvent = "
01904                             + str;
01905             histTitle = hTitle.c_str();
01906 
01907             m_fdlEmulTechDecisionMask[iHist][iRec] = m_dbe->book1D(histName,
01908                     histTitle, numberTechTriggers, 0., numberTechTriggers);
01909 
01910             //
01911             hName = recString + "DataEmul_TechDecision_" + str;
01912             histName = hName.c_str();
01913 
01914             hTitle
01915                     = "Data vs emul: non-matching technical trigger decision word for BxInEvent = "
01916                             + str;
01917             histTitle = hTitle.c_str();
01918 
01919             m_fdlDataEmulTechDecision[iHist][iRec] = m_dbe->book1D(histName,
01920                     histTitle, numberTechTriggers, 0., numberTechTriggers);
01921 
01922             hName = recString + "DataEmul_TechDecisionAfterMask_" + str;
01923             histName = hName.c_str();
01924 
01925             hTitle
01926                     = "Data vs emul: non-matching technical trigger decision word after mask for BxInEvent = "
01927                             + str;
01928             histTitle = hTitle.c_str();
01929 
01930             m_fdlDataEmulTechDecisionMask[iHist][iRec] = m_dbe->book1D(
01931                     histName, histTitle, numberTechTriggers, 0.,
01932                     numberTechTriggers);
01933 
01934         }
01935 
01936         hName = recString + "FdlDataEmul_Err";
01937         histName = hName.c_str();
01938 
01939         m_fdlDataEmul_Err[iRec]
01940                 = m_dbe->book1D(
01941                         histName,
01942                         "FDL data vs emul mismatch for non-matching BxInEvent in FDL payload",
01943                         13, 0., 13.);
01944         m_fdlDataEmul_Err[iRec]->setBinLabel(1, "BoardId", 1);
01945         m_fdlDataEmul_Err[iRec]->setBinLabel(2, "BxInEvent", 1);
01946         m_fdlDataEmul_Err[iRec]->setBinLabel(3, "BxNr", 1);
01947         m_fdlDataEmul_Err[iRec]->setBinLabel(4, "EventNr", 1);
01948         m_fdlDataEmul_Err[iRec]->setBinLabel(5, "TechTrigger", 1);
01949         m_fdlDataEmul_Err[iRec]->setBinLabel(6, "TechTriggerMask", 1);
01950         m_fdlDataEmul_Err[iRec]->setBinLabel(7, "AlgoTrigger", 1);
01951         m_fdlDataEmul_Err[iRec]->setBinLabel(8, "AlgoTriggerMask", 1);
01952         m_fdlDataEmul_Err[iRec]->setBinLabel(9, "AlgoExtend", 1);
01953         m_fdlDataEmul_Err[iRec]->setBinLabel(10, "NoAlgo", 1);
01954         m_fdlDataEmul_Err[iRec]->setBinLabel(11, "FinalORAllParts", 1);
01955         m_fdlDataEmul_Err[iRec]->setBinLabel(12, "FinalORPhysPart", 1);
01956         m_fdlDataEmul_Err[iRec]->setBinLabel(13, "LocalBxNr", 1);
01957 
01958         hName = recString + "FdlDataAlgoDecision_Err";
01959         histName = hName.c_str();
01960 
01961         m_fdlDataAlgoDecision_Err[iRec]
01962                 = m_dbe->book1D(
01963                         histName,
01964                         "Data: algorithm trigger decision word, non-matching BxInEvent",
01965                         numberAlgoTriggers, 0., numberAlgoTriggers);
01966 
01967         //
01968         hName = recString + "Emul_AlgoDecision_Err";
01969         histName = hName.c_str();
01970 
01971         m_fdlEmulAlgoDecision_Err[iRec]
01972                 = m_dbe->book1D(
01973                         histName,
01974                         "Emul: algorithm trigger decision word, non-matching BxInEvent",
01975                         numberAlgoTriggers, 0., numberAlgoTriggers);
01976 
01977         hName = recString + "DataEmul_AlgoDecision_Err";
01978         histName = hName.c_str();
01979 
01980         m_fdlDataEmulAlgoDecision_Err[iRec]
01981                 = m_dbe->book1D(
01982                         histName,
01983                         "Data vs emul: algorithm trigger decision word, non-matching BxInEvent",
01984                         numberAlgoTriggers, 0., numberAlgoTriggers);
01985 
01986         //
01987         hName = recString + "Data_TechDecision_Err";
01988         histName = hName.c_str();
01989 
01990         m_fdlDataTechDecision_Err[iRec]
01991                 = m_dbe->book1D(
01992                         histName,
01993                         "Data: technical trigger decision word, non-matching BxInEvent",
01994                         numberTechTriggers, 0., numberTechTriggers);
01995 
01996         hName = recString + "Emul_TechDecision_Err";
01997         histName = hName.c_str();
01998 
01999         m_fdlEmulTechDecision_Err[iRec]
02000                 = m_dbe->book1D(
02001                         histName,
02002                         "Emul: technical trigger decision word, non-matching BxInEvent",
02003                         numberTechTriggers, 0., numberTechTriggers);
02004 
02005         hName = recString + "DataEmul_TechDecision_Err";
02006         histName = hName.c_str();
02007 
02008         m_fdlDataEmulTechDecision_Err[iRec]
02009                 = m_dbe->book1D(
02010                         histName,
02011                         "Data vs emul: technical trigger decision word, non-matching BxInEvent",
02012                         numberTechTriggers, 0., numberTechTriggers);
02013 
02014     }
02015 }
02016 
02017 void L1GtHwValidation::endRun(const edm::Run& run,
02018         const edm::EventSetup& evSetup) {
02019 
02020     LogDebug("L1GtHwValidation") << "\n\n endRun: " << run.id()
02021             << "\n  Number of events analyzed in this run:       " << m_nrEvRun
02022             << "\n  Total number of events analyzed in this job: " << m_nrEvJob
02023             << "\n" << std::endl;
02024 
02025 }
02026 
02027 // method called once each job just after ending the event loop
02028 void L1GtHwValidation::endJob() {
02029 
02030     edm::LogInfo("L1GtHwValidation")
02031             << "\n\nTotal number of events analyzed in this job: " << m_nrEvJob
02032             << "\n" << std::endl;
02033 
02034     return;
02035 
02036 }
02037 
02038 //define this as a plug-in
02039 DEFINE_FWK_MODULE( L1GtHwValidation);