CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/DQM/L1TMonitor/src/L1TGT.cc

Go to the documentation of this file.
00001 
00015 #include "DQM/L1TMonitor/interface/L1TGT.h"
00016 
00017 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
00018 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00019 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
00020 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
00021 
00022 L1TGT::L1TGT(const edm::ParameterSet& ps) :
00023             gtSource_(ps.getParameter<edm::InputTag> ("gtSource")),
00024             gtEvmSource_(ps.getParameter<edm::InputTag> ("gtEvmSource")),
00025             verbose_(ps.getUntrackedParameter<bool> ("verbose", false)),
00026             m_dbe(0),
00027             //
00028             m_nrEvJob(0), m_nrEvRun(0),
00029             preGps_(0ULL), preOrb_(0ULL),
00030             m_previousLS(-1),
00031             m_previousPfIndex(-1)
00032 {
00033 
00034     m_histFolder = ps.getUntrackedParameter<std::string> ("HistFolder",
00035             "L1T/L1TGT");
00036 
00037     m_dbe = edm::Service<DQMStore>().operator->();
00038     if (m_dbe == 0) {
00039         edm::LogInfo("L1TGT") << "\n Unable to get DQMStore service.";
00040     } else {
00041 
00042         m_dbe->setVerbose(0);
00043         m_dbe->setCurrentFolder(m_histFolder);
00044 
00045     }
00046 
00047     // reserve space for 1000 LS
00048     m_pairLsNumberPfIndex.reserve(1000);
00049 }
00050 
00051 L1TGT::~L1TGT() {
00052 
00053     // empty
00054 }
00055 
00056 void L1TGT::beginJob() {
00057 
00058     m_nrEvJob = 0;
00059 
00060     preGps_ = 0ULL;
00061     preOrb_ = 0ULL;
00062 
00063 }
00064 
00065 void L1TGT::beginRun(const edm::Run& iRun, const edm::EventSetup& evSetup) {
00066 
00067     m_nrEvRun = 0;
00068 
00069     m_dbe = edm::Service<DQMStore>().operator->();
00070 
00071     if (m_dbe == 0) {
00072         edm::LogInfo("L1TGT") << "\n Unable to get DQMStore service.";
00073     } else {
00074 
00075         // clean up directory
00076         m_dbe->setCurrentFolder(m_histFolder);
00077         if (m_dbe->dirExists(m_histFolder)) {
00078             m_dbe->rmdir(m_histFolder);
00079         }
00080 
00081         m_dbe->setCurrentFolder(m_histFolder);
00082 
00083     }
00084 
00085     // book histograms
00086     bookHistograms();
00087 
00088     // clear bookkeeping for prescale factor change
00089     m_pairLsNumberPfIndex.clear();
00090 
00091 }
00092 
00093 void L1TGT::beginLuminosityBlock(const edm::LuminosityBlock& iLumi,
00094         const edm::EventSetup& evSetup) {
00095 
00096     //
00097 
00098 }
00099 
00100 
00101 //
00102 void L1TGT::analyze(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
00103 
00104     m_nrEvJob++;
00105 
00106     if (verbose_) {
00107         edm::LogInfo("L1TGT") << "L1TGT: analyze...." << std::endl;
00108     }
00109 
00110     // initialize Bx, orbit number, luminosity segment number to invalid value
00111     int tcsBx = -1;
00112     int gtfeEvmBx = -1;
00113 
00114     long long int orbitTcs = -1;
00115     int orbitEvmFdl = -1;
00116 
00117     int lsTcs = -1;
00118     int lsEvmFdl = -1;
00119 
00120     // get once only the LS block number, to be used in many histograms
00121     const int lsNumber = iEvent.luminosityBlock();
00122 
00123     // open EVM readout record if available
00124     edm::Handle<L1GlobalTriggerEvmReadoutRecord> gtEvmReadoutRecord;
00125     iEvent.getByLabel(gtEvmSource_, gtEvmReadoutRecord);
00126 
00127     if (!gtEvmReadoutRecord.isValid()) {
00128         edm::LogInfo("L1TGT")
00129                 << "can't find L1GlobalTriggerEvmReadoutRecord with label "
00130                 << gtSource_.label();
00131     } else {
00132 
00133         // get all info from the EVM record if available and fill the histograms
00134 
00135         const L1GtfeWord& gtfeEvmWord = gtEvmReadoutRecord->gtfeWord();
00136         const L1GtfeExtWord& gtfeEvmExtWord = gtEvmReadoutRecord->gtfeWord();
00137 
00138         gtfeEvmBx = gtfeEvmWord.bxNr();
00139         int gtfeEvmActiveBoards = gtfeEvmWord.activeBoards();
00140 
00141         if (isActive(gtfeEvmActiveBoards, TCS)) { // if TCS present in the record
00142 
00143             const L1TcsWord& tcsWord = gtEvmReadoutRecord->tcsWord();
00144 
00145             tcsBx = tcsWord.bxNr();
00146             orbitTcs = tcsWord.orbitNr();
00147             lsTcs = tcsWord.luminositySegmentNr();
00148 
00149             event_type->Fill(tcsWord.triggerType());
00150             orbit_lumi->Fill(lsNumber, orbitTcs);
00151 
00152             trigger_number->Fill(tcsWord.partTrigNr());
00153             event_number->Fill(tcsWord.eventNr());
00154 
00155             trigger_lumi->Fill(lsNumber, tcsWord.partTrigNr());
00156             event_lumi->Fill(lsNumber, tcsWord.eventNr());
00157             evnum_trignum_lumi->Fill(lsNumber,
00158                     double(tcsWord.eventNr()) / double(tcsWord.partTrigNr()));
00159 
00160             boost::uint16_t master = gtfeEvmExtWord.bstMasterStatus();
00161             boost::uint32_t turnCount = gtfeEvmExtWord.turnCountNumber();
00162             boost::uint32_t lhcFill = gtfeEvmExtWord.lhcFillNumber();
00163             boost::uint16_t beam = gtfeEvmExtWord.beamMode();
00164             boost::uint16_t momentum = gtfeEvmExtWord.beamMomentum();
00165             boost::uint32_t intensity1 = gtfeEvmExtWord.totalIntensityBeam1();
00166             boost::uint32_t intensity2 = gtfeEvmExtWord.totalIntensityBeam2();
00167 
00168             BST_MasterStatus->Fill(lsNumber, (float) (master));
00169             BST_turnCountNumber->Fill(lsNumber, (float) (turnCount));
00170             BST_lhcFillNumber->Fill((float) (lhcFill % 1000));
00171             BST_beamMode->Fill(lsNumber, (float) (beam));
00172 
00173             BST_beamMomentum->Fill(lsNumber, (float) (momentum));
00174             BST_intensityBeam1->Fill(lsNumber, (float) (intensity1));
00175             BST_intensityBeam2->Fill(lsNumber, (float) (intensity2));
00176 
00177             if (verbose_) {
00178                 edm::LogInfo("L1TGT") << " check mode = " << beam << "    momentum " << momentum
00179                         << " int2 " << intensity2 << std::endl;
00180             }
00181 
00182             boost::uint64_t gpsr = gtfeEvmExtWord.gpsTime();
00183             boost::uint64_t gpshi = (gpsr >> 32) & 0xffffffff;
00184             boost::uint64_t gpslo = gpsr & 0xffffffff;
00185             boost::uint64_t gps = gpshi * 1000000 + gpslo;
00186             //  edm::LogInfo("L1TGT") << "  gpsr = " << std::hex << gpsr << " hi=" << gpshi << " lo=" << gpslo << " gps=" << gps << std::endl;
00187 
00188             Long64_t delorb = orbitTcs - preOrb_;
00189             Long64_t delgps = gps - preGps_;
00190             Double_t freq = -1.;
00191 
00192             if (delgps > 0) {
00193                 freq = ((Double_t)(delorb)) * 3564. / ((Double_t)(delgps));
00194             }
00195 
00196             if (delorb > 0) {
00197                 gpsfreq->Fill(freq);
00198                 gpsfreqwide->Fill(freq);
00199                 gpsfreqlum->Fill(lsNumber, freq);
00200                 if (verbose_) {
00201                     if (freq > 200.) {
00202                         edm::LogInfo("L1TGT") << " preOrb_ = " << preOrb_ << " orbitTcs=" << orbitTcs
00203                                 << " delorb=" << delorb << std::hex << " preGps_="
00204                                 << preGps_ << " gps=" << gps << std::dec
00205                                 << " delgps=" << delgps << " freq=" << freq
00206                                 << std::endl;
00207 
00208                     }
00209                 }
00210             }
00211 
00212             preGps_ = gps;
00213             preOrb_ = orbitTcs;
00214 
00215         }
00216 
00217         // get info from FDL if active
00218         if (isActive(gtfeEvmActiveBoards, FDL)) {
00219             const L1GtFdlWord& fdlWord = gtEvmReadoutRecord->gtFdlWord();
00220 
00221             orbitEvmFdl = fdlWord.orbitNr();
00222             lsEvmFdl = fdlWord.lumiSegmentNr();
00223         }
00224 
00225         if ((orbitTcs >= 0) && (orbitEvmFdl >= 0)) {
00226 
00227             int diffOrbit = static_cast<float> (orbitTcs - orbitEvmFdl);
00228             edm::LogInfo("L1TGT") << "\n orbitTcs = " << orbitTcs << " orbitEvmFdl = "
00229                     << orbitEvmFdl << " diffOrbit = " << diffOrbit
00230                     << " orbitEvent = " << iEvent.orbitNumber() << std::endl;
00231 
00232             if (diffOrbit >= MaxOrbitNrDiffTcsFdlEvm) {
00233                 m_monOrbitNrDiffTcsFdlEvm->Fill(MaxOrbitNrDiffTcsFdlEvm);
00234 
00235             } else if (diffOrbit <= -MaxOrbitNrDiffTcsFdlEvm) {
00236                 m_monOrbitNrDiffTcsFdlEvm->Fill(-MaxOrbitNrDiffTcsFdlEvm);
00237 
00238             } else {
00239                 m_monOrbitNrDiffTcsFdlEvm->Fill(diffOrbit);
00240                 m_monOrbitNrDiffTcsFdlEvmLs->Fill(lsNumber,
00241                         diffOrbit);
00242 
00243             }
00244 
00245         } else {
00246 
00247             if (orbitTcs >= 0) {
00248                 // EVM_FDL error
00249                 m_monOrbitNrDiffTcsFdlEvm->Fill(MaxOrbitNrDiffTcsFdlEvm);
00250             } else if (orbitEvmFdl >= 0) {
00251                 // TCS error
00252                 m_monOrbitNrDiffTcsFdlEvm->Fill(-MaxOrbitNrDiffTcsFdlEvm);
00253 
00254             } else {
00255                 // TCS and EVM_FDL error
00256                 m_monOrbitNrDiffTcsFdlEvm->Fill(-MaxOrbitNrDiffTcsFdlEvm);
00257                 m_monOrbitNrDiffTcsFdlEvm->Fill(MaxOrbitNrDiffTcsFdlEvm);
00258             }
00259         }
00260 
00261         if ((lsTcs >= 0) && (lsEvmFdl >= 0)) {
00262 
00263             int diffLs = static_cast<float> (lsTcs - lsEvmFdl);
00264             edm::LogInfo("L1TGT") << "\n lsTcs = " << lsTcs << " lsEvmFdl = " << lsEvmFdl
00265                     << " diffLs = " << diffLs << " lsEvent = "
00266                     << lsNumber << std::endl;
00267 
00268             if (diffLs >= MaxLsNrDiffTcsFdlEvm) {
00269                 m_monLsNrDiffTcsFdlEvm->Fill(MaxLsNrDiffTcsFdlEvm);
00270 
00271             } else if (diffLs <= -MaxLsNrDiffTcsFdlEvm) {
00272                 m_monLsNrDiffTcsFdlEvm->Fill(-MaxLsNrDiffTcsFdlEvm);
00273 
00274             } else {
00275                 m_monLsNrDiffTcsFdlEvm->Fill(diffLs);
00276                 m_monLsNrDiffTcsFdlEvmLs->Fill(lsNumber, diffLs);
00277 
00278             }
00279 
00280         } else {
00281 
00282             if (lsTcs >= 0) {
00283                 // EVM_FDL error
00284                 m_monLsNrDiffTcsFdlEvm->Fill(MaxLsNrDiffTcsFdlEvm);
00285             } else if (lsEvmFdl >= 0) {
00286                 // TCS error
00287                 m_monLsNrDiffTcsFdlEvm->Fill(-MaxLsNrDiffTcsFdlEvm);
00288 
00289             } else {
00290                 // TCS and EVM_FDL error
00291                 m_monLsNrDiffTcsFdlEvm->Fill(-MaxLsNrDiffTcsFdlEvm);
00292                 m_monLsNrDiffTcsFdlEvm->Fill(MaxLsNrDiffTcsFdlEvm);
00293             }
00294         }
00295 
00296     }
00297 
00298     // open GT DAQ readout record - exit if failed
00299     edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecord;
00300     iEvent.getByLabel(gtSource_, gtReadoutRecord);
00301 
00302     if (!gtReadoutRecord.isValid()) {
00303         edm::LogInfo("L1TGT")
00304                 << "can't find L1GlobalTriggerReadoutRecord with label "
00305                 << gtSource_.label();
00306         return;
00307     }
00308 
00309     // initialize bx's to invalid value
00310     int gtfeBx = -1;
00311     int fdlBx[2] = { -1, -1 };
00312     int psbBx[2][7] = { { -1, -1, -1, -1, -1, -1, -1 }, { -1, -1, -1, -1, -1,
00313             -1, -1 } };
00314     int gmtBx = -1;
00315 
00316     // get info from GTFE DAQ record
00317     const L1GtfeWord& gtfeWord = gtReadoutRecord->gtfeWord();
00318     gtfeBx = gtfeWord.bxNr();
00319     gtfe_bx->Fill(gtfeBx);
00320     setupversion_lumi->Fill(lsNumber, gtfeWord.setupVersion());
00321     int gtfeActiveBoards = gtfeWord.activeBoards();
00322 
00323     // look for GMT readout collection from the same source if GMT active
00324     if (isActive(gtfeActiveBoards, GMT)) {
00325         edm::Handle<L1MuGMTReadoutCollection> gmtReadoutCollection;
00326         iEvent.getByLabel(gtSource_, gmtReadoutCollection);
00327 
00328         if (gmtReadoutCollection.isValid()) {
00329             gmtBx = gmtReadoutCollection->getRecord().getBxNr();
00330         }
00331     }
00332 
00333     // get info from FDL if active (including decision word)
00334     if (isActive(gtfeActiveBoards, FDL)) {
00335         const L1GtFdlWord& fdlWord = gtReadoutRecord->gtFdlWord();
00336         fdlBx[0] = fdlWord.bxNr();
00337         fdlBx[1] = fdlWord.localBxNr();
00338 
00340         const DecisionWord& gtDecisionWord = gtReadoutRecord->decisionWord();
00341         const TechnicalTriggerWord& gtTTWord =
00342                 gtReadoutRecord->technicalTriggerWord();
00343 
00344         int dbitNumber = 0;
00345         DecisionWord::const_iterator GTdbitItr;
00346         algo_bits->Fill(-1.); // fill underflow to normalize
00347         for (GTdbitItr = gtDecisionWord.begin(); GTdbitItr
00348                 != gtDecisionWord.end(); GTdbitItr++) {
00349             if (*GTdbitItr) {
00350                 algo_bits->Fill(dbitNumber);
00351                 algo_bits_lumi->Fill(lsNumber, dbitNumber);
00352                 int dbitNumber1 = 0;
00353                 DecisionWord::const_iterator GTdbitItr1;
00354                 for (GTdbitItr1 = gtDecisionWord.begin(); GTdbitItr1
00355                         != gtDecisionWord.end(); GTdbitItr1++) {
00356                     if (*GTdbitItr1)
00357                         algo_bits_corr->Fill(dbitNumber, dbitNumber1);
00358                     dbitNumber1++;
00359                 }
00360                 int tbitNumber1 = 0;
00361                 TechnicalTriggerWord::const_iterator GTtbitItr1;
00362                 for (GTtbitItr1 = gtTTWord.begin(); GTtbitItr1
00363                         != gtTTWord.end(); GTtbitItr1++) {
00364                     if (*GTtbitItr1)
00365                         tt_bits_corr->Fill(dbitNumber, tbitNumber1);
00366                     tbitNumber1++;
00367                 }
00368             }
00369             dbitNumber++;
00370         }
00371 
00372         int tbitNumber = 0;
00373         TechnicalTriggerWord::const_iterator GTtbitItr;
00374         tt_bits->Fill(-1.); // fill underflow to normalize
00375         for (GTtbitItr = gtTTWord.begin(); GTtbitItr != gtTTWord.end(); GTtbitItr++) {
00376             if (*GTtbitItr) {
00377                 tt_bits->Fill(tbitNumber);
00378                 tt_bits_lumi->Fill(lsNumber, tbitNumber);
00379                 int tbitNumber1 = 0;
00380                 TechnicalTriggerWord::const_iterator GTtbitItr1;
00381                 for (GTtbitItr1 = gtTTWord.begin(); GTtbitItr1
00382                         != gtTTWord.end(); GTtbitItr1++) {
00383                     if (*GTtbitItr1)
00384                         tt_bits_corr->Fill(tbitNumber, tbitNumber1);
00385                     tbitNumber1++;
00386                 }
00387             }
00388             tbitNumber++;
00389         }
00390 
00391 
00392         // fill the index of actual prescale factor set
00393         // the index for technical triggers and algorithm trigger is the same (constraint in L1 GT TS)
00394         // so we read only pfIndexAlgoTrig (boost::uint16_t)
00395 
00396         const int pfIndexAlgoTrig = fdlWord.gtPrescaleFactorIndexAlgo();
00397         m_monL1PrescaleFactorSet->Fill(lsNumber,
00398                 static_cast<float> (pfIndexAlgoTrig));
00399 
00400         //
00401 
00402         // check that the combination (pfIndex, lsNumber) is not already included
00403         // to avoid fake entries due to different event order
00404 
00405         std::pair<int, int> pairLsPfi = std::make_pair(lsNumber,
00406                 pfIndexAlgoTrig);
00407 
00408         CItVecPair cIt = find(m_pairLsNumberPfIndex.begin(),
00409                 m_pairLsNumberPfIndex.end(), pairLsPfi);
00410 
00411         if (cIt == m_pairLsNumberPfIndex.end()) {
00412 
00413             m_pairLsNumberPfIndex.push_back(pairLsPfi);
00414 
00415             m_previousPfIndex = pfIndexAlgoTrig;
00416             m_previousLS = lsNumber;
00417         }
00418 
00419     }
00420 
00421     // get info from active PSB's
00422     int ibit = PSB9; // first psb
00423     // for now hardcode psb id's - TODO - get them from Vasile's board maps...
00424     int psbID[7] = { 0xbb09, 0xbb0d, 0xbb0e, 0xbb0f, 0xbb13, 0xbb14, 0xbb15 };
00425     for (int i = 0; i < 7; i++) {
00426         if (isActive(gtfeActiveBoards, ibit)) {
00427             L1GtPsbWord psbWord = gtReadoutRecord->gtPsbWord(psbID[i]);
00428             psbBx[0][i] = psbWord.bxNr();
00429             psbBx[1][i] = psbWord.localBxNr();
00430         }
00431         ibit++;
00432     }
00433 
00434     //fill the dbx histo
00435     if (gtfeEvmBx > -1)
00436         dbx_module->Fill(0., gtfeEvmBx - gtfeBx);
00437     if (tcsBx > -1)
00438         dbx_module->Fill(1., tcsBx - gtfeBx);
00439     for (int i = 0; i < 2; i++) {
00440         if (fdlBx[i] > -1)
00441             dbx_module->Fill(2. + i, fdlBx[i] - gtfeBx);
00442     }
00443     for (int j = 0; j < 7; j++) {
00444         for (int i = 0; i < 2; i++) {
00445             if (psbBx[i][j] > -1)
00446                 dbx_module->Fill(4. + i + 2 * j, psbBx[i][j] - gtfeBx);
00447         }
00448     }
00449     if (gmtBx > -1)
00450         dbx_module->Fill(18., gmtBx - gtfeBx);
00451 
00452 }
00453 
00454 
00455 // end section
00456 void L1TGT::endLuminosityBlock(const edm::LuminosityBlock& iLumi,
00457         const edm::EventSetup& evSetup) {
00458 
00459     edm::LogInfo("L1TGT")
00460             << "\n  endLuminosityBlock:: Prescale factor indices used in a LS "
00461             << std::endl;
00462     for (CItVecPair cIt = m_pairLsNumberPfIndex.begin(); cIt
00463             != m_pairLsNumberPfIndex.end(); ++cIt) {
00464 
00465         edm::LogVerbatim("L1TGT") << "  lsNumber = " << (*cIt).first
00466                 << " pfIndex = " << (*cIt).second << std::endl;
00467     }
00468     edm::LogVerbatim("L1TGT") << std::endl;
00469 
00470     // sort the vector (for pairs: sort after first argument, then after the second argument)
00471     std::sort(m_pairLsNumberPfIndex.begin(), m_pairLsNumberPfIndex.end());
00472 
00473 }
00474 
00475 void L1TGT::endRun(const edm::Run& iRrun, const edm::EventSetup& evSetup) {
00476 
00477     edm::LogInfo("L1TGT")
00478             << "\n  endRun:: Prescale factor indices used in a LS "
00479             << std::endl;
00480     for (CItVecPair cIt = m_pairLsNumberPfIndex.begin(); cIt
00481             != m_pairLsNumberPfIndex.end(); ++cIt) {
00482 
00483         edm::LogVerbatim("L1TGT") << "  lsNumber = " << (*cIt).first
00484                 << " pfIndex = " << (*cIt).second << std::endl;
00485     }
00486     edm::LogVerbatim("L1TGT") << std::endl;
00487 
00488     // clear the content of the vector
00489     m_pairLsNumberPfIndex.clear();
00490 
00491 }
00492 
00493 
00494 void L1TGT::endJob() {
00495 
00496     if (verbose_) {
00497         edm::LogInfo("L1TGT") << "\n Analyzed " << m_nrEvJob << " events";
00498     }
00499 
00500     return;
00501 }
00502 
00503 
00504 // book all histograms for the module
00505 void L1TGT::bookHistograms() {
00506 
00507     const int TotalNrBinsLs = 1000;
00508     const double totalNrBinsLs = static_cast<double>(TotalNrBinsLs);
00509 
00510     if (m_dbe) {
00511         m_dbe->setCurrentFolder(m_histFolder);
00512 
00513         algo_bits = m_dbe->book1D("algo_bits", "GT algo bits", 128, -0.5, 127.5);
00514         algo_bits->setAxisTitle("algorithm bits", 1);
00515 
00516         algo_bits_corr = m_dbe->book2D("algo_bits_corr",
00517                 "GT algo bit correlation",
00518                 128, -0.5, 127.5, 128, -0.5, 127.5);
00519         algo_bits_corr->setAxisTitle("algorithm bits", 1);
00520         algo_bits_corr->setAxisTitle("algorithm bits", 2);
00521 
00522         tt_bits = m_dbe->book1D("tt_bits",
00523                 "GT technical trigger bits",
00524                 64, -0.5, 63.5);
00525         tt_bits->setAxisTitle("technical trigger bits", 1);
00526 
00527         tt_bits_corr = m_dbe->book2D("tt_bits_corr",
00528                 "GT tech. trig. bit correlation",
00529                 64, -0.5, 63.5, 64, -0.5, 63.5);
00530         tt_bits_corr->setAxisTitle("technical trigger bits", 1);
00531         tt_bits_corr->setAxisTitle("technical trigger bits", 2);
00532 
00533         algo_tt_bits_corr = m_dbe->book2D("algo_tt_bits_corr",
00534                 "GT algo tech. trig. bit correlation",
00535                 128, -0.5, 127.5, 64, -0.5, 63.5);
00536         algo_tt_bits_corr->setAxisTitle("algorithm bits", 1);
00537         algo_tt_bits_corr->setAxisTitle("technical trigger bits", 2);
00538 
00539         algo_bits_lumi = m_dbe->book2D("algo_bits_lumi",
00540                 "GT algo bit rate per lumi segment",
00541                 TotalNrBinsLs, 0., totalNrBinsLs, 128, -0.5, 127.5);
00542         algo_bits_lumi->setAxisTitle("Luminosity segment", 1);
00543         algo_bits_lumi->setAxisTitle("Algorithm bits", 2);
00544 
00545         tt_bits_lumi = m_dbe->book2D("tt_bits_lumi",
00546                 "GT tech. trig. bit rate per lumi segment",
00547                 TotalNrBinsLs, 0., totalNrBinsLs, 64, -0.5, 63.5);
00548         tt_bits_lumi->setAxisTitle("Luminosity segment", 1);
00549         tt_bits_lumi->setAxisTitle("Technical trigger bits", 2);
00550 
00551         event_type = m_dbe->book1D("event_type", "GT event type", 10, -0.5, 9.5);
00552         event_type->setAxisTitle("event type", 1);
00553         event_type->setBinLabel(2, "Physics", 1);
00554         event_type->setBinLabel(3, "Calibration", 1);
00555         event_type->setBinLabel(4, "Random", 1);
00556         event_type->setBinLabel(6, "Traced", 1);
00557         event_type->setBinLabel(7, "Test", 1);
00558         event_type->setBinLabel(8, "Error", 1);
00559 
00560         event_number = m_dbe->book1D("event_number",
00561                 "GT Event number (from last resync)",
00562                 100, 0., 50000.);
00563         event_number->setAxisTitle("event number", 1);
00564 
00565         event_lumi = m_dbe->bookProfile("event_lumi",
00566                 "GT Event number (from last resync) vs lumi section",
00567                 TotalNrBinsLs, 0., totalNrBinsLs, 100, -0.1, 1.e15, "s");
00568         event_lumi->setAxisTitle("Luminosity segment", 1);
00569         event_lumi->setAxisTitle("event number", 2);
00570 
00571         trigger_number = m_dbe->book1D("trigger_number",
00572                 "GT Trigger number (from start run)",
00573                 100, 0., 50000.);
00574         trigger_number->setAxisTitle("trigger number", 1);
00575 
00576         trigger_lumi = m_dbe->bookProfile("trigger_lumi",
00577                 "GT Trigger number (from start run) vs lumi section",
00578                 TotalNrBinsLs, 0., totalNrBinsLs, 100, -0.1, 1.e15, "s");
00579         trigger_lumi->setAxisTitle("Luminosity segment", 1);
00580         trigger_lumi->setAxisTitle("Trigger number", 2);
00581 
00582         evnum_trignum_lumi = m_dbe->bookProfile("evnum_trignum_lumi",
00583                 "GT Event/Trigger number ratio vs lumi section",
00584                 TotalNrBinsLs, 0., totalNrBinsLs, 100, -0.1, 2., "s");
00585         evnum_trignum_lumi->setAxisTitle("Luminosity segment", 1);
00586         evnum_trignum_lumi->setAxisTitle("Event/trigger number ratio", 2);
00587 
00588         orbit_lumi = m_dbe->bookProfile("orbit_lumi",
00589                 "GT orbit number vs lumi section",
00590                 TotalNrBinsLs, 0., totalNrBinsLs, 100, -0.1, 1.e15, "s");
00591         orbit_lumi->setAxisTitle("Luminosity segment", 1);
00592         orbit_lumi->setAxisTitle("Orbit number", 2);
00593 
00594         setupversion_lumi = m_dbe->bookProfile("setupversion_lumi",
00595                 "GT setup version vs lumi section",
00596                 TotalNrBinsLs, 0., totalNrBinsLs, 100, -0.1, 1.e10, "i");
00597         setupversion_lumi->setAxisTitle("Luminosity segment", 1);
00598         setupversion_lumi->setAxisTitle("Setup version", 2);
00599 
00600         gtfe_bx = m_dbe->book1D("gtfe_bx", "GTFE Bx number", 3600, 0., 3600.);
00601         gtfe_bx->setAxisTitle("GTFE BX number", 1);
00602 
00603         dbx_module = m_dbe->bookProfile("dbx_module",
00604                 "delta Bx of GT modules wrt. GTFE",
00605                 20, 0., 20., 100, -4000., 4000., "i");
00606         dbx_module->setAxisTitle("GT crate module", 1);
00607         dbx_module->setAxisTitle("Module Bx - GTFE Bx", 2);
00608         dbx_module->setBinLabel(1, "GTFEevm", 1);
00609         dbx_module->setBinLabel(2, "TCS", 1);
00610         dbx_module->setBinLabel(3, "FDL", 1);
00611         dbx_module->setBinLabel(4, "FDLloc", 1);
00612         dbx_module->setBinLabel(5, "PSB9", 1);
00613         dbx_module->setBinLabel(6, "PSB9loc", 1);
00614         dbx_module->setBinLabel(7, "PSB13", 1);
00615         dbx_module->setBinLabel(8, "PSB13loc", 1);
00616         dbx_module->setBinLabel(9, "PSB14", 1);
00617         dbx_module->setBinLabel(10, "PSB14loc", 1);
00618         dbx_module->setBinLabel(11, "PSB15", 1);
00619         dbx_module->setBinLabel(12, "PSB15loc", 1);
00620         dbx_module->setBinLabel(13, "PSB19", 1);
00621         dbx_module->setBinLabel(14, "PSB19loc", 1);
00622         dbx_module->setBinLabel(15, "PSB20", 1);
00623         dbx_module->setBinLabel(16, "PSB20loc", 1);
00624         dbx_module->setBinLabel(17, "PSB21", 1);
00625         dbx_module->setBinLabel(18, "PSB21loc", 1);
00626         dbx_module->setBinLabel(19, "GMT", 1);
00627 
00628         BST_MasterStatus = m_dbe->book2D("BST_MasterStatus",
00629                 "BST master status over lumi segment",
00630                 TotalNrBinsLs, 0., totalNrBinsLs, 6, -1., 5.);
00631         BST_MasterStatus->setAxisTitle("Luminosity segment", 1);
00632         BST_MasterStatus->setAxisTitle("BST master status", 2);
00633         BST_MasterStatus->setBinLabel(2, "Master Beam 1", 2);
00634         BST_MasterStatus->setBinLabel(3, "Master Beam 2", 2);
00635 
00636         BST_turnCountNumber = m_dbe->book2D("BST_turnCountNumber",
00637                 "BST turn count over lumi segment",
00638                 TotalNrBinsLs, 0., totalNrBinsLs, 250, 0., 4.3e9);
00639         BST_turnCountNumber->setAxisTitle("Luminosity segment", 1);
00640         BST_turnCountNumber->setAxisTitle("BST turn count number", 2);
00641 
00642         BST_lhcFillNumber = m_dbe->book1D("BST_lhcFillNumber",
00643                 "BST LHC fill number % 1000", 1000, 0., 1000.);
00644         BST_lhcFillNumber->setAxisTitle("BST LHC fill number modulo 1000");
00645 
00646         BST_beamMode = m_dbe->book2D("BST_beamMode",
00647                 "BST beam mode over lumi segment",
00648                 TotalNrBinsLs, 0., totalNrBinsLs, 25, 1., 26.);
00649         BST_beamMode->setAxisTitle("Luminosity segment", 1);
00650         BST_beamMode->setAxisTitle("mode", 2);
00651         BST_beamMode->setBinLabel(1, "no mode", 2);
00652         BST_beamMode->setBinLabel(2, "setup", 2);
00653         BST_beamMode->setBinLabel(3, "inj pilot", 2);
00654         BST_beamMode->setBinLabel(4, "inj intr", 2);
00655         BST_beamMode->setBinLabel(5, "inj nomn", 2);
00656         BST_beamMode->setBinLabel(6, "pre ramp", 2);
00657         BST_beamMode->setBinLabel(7, "ramp", 2);
00658         BST_beamMode->setBinLabel(8, "flat top", 2);
00659         BST_beamMode->setBinLabel(9, "squeeze", 2);
00660         BST_beamMode->setBinLabel(10, "adjust", 2);
00661         BST_beamMode->setBinLabel(11, "stable", 2);
00662         BST_beamMode->setBinLabel(12, "unstable", 2);
00663         BST_beamMode->setBinLabel(13, "beam dump", 2);
00664         BST_beamMode->setBinLabel(14, "ramp down", 2);
00665         BST_beamMode->setBinLabel(15, "recovery", 2);
00666         BST_beamMode->setBinLabel(16, "inj dump", 2);
00667         BST_beamMode->setBinLabel(17, "circ dump", 2);
00668         BST_beamMode->setBinLabel(18, "abort", 2);
00669         BST_beamMode->setBinLabel(19, "cycling", 2);
00670         BST_beamMode->setBinLabel(20, "warn beam dump", 2);
00671         BST_beamMode->setBinLabel(21, "no beam", 2);
00672 
00673         BST_beamMomentum = m_dbe->book2D("BST_beamMomentum",
00674                 "BST beam momentum",
00675                 TotalNrBinsLs, 0., totalNrBinsLs, 100, 0., 7200.);
00676         BST_beamMomentum->setAxisTitle("Luminosity segment", 1);
00677         BST_beamMomentum->setAxisTitle("Beam momentum", 2);
00678 
00679         gpsfreq = m_dbe->book1D("gpsfreq", "clock frequency measured by GPS",
00680                 1000, 39.95, 40.2);
00681         gpsfreq->setAxisTitle("CMS clock frequency (MHz)");
00682 
00683         gpsfreqwide = m_dbe->book1D("gpsfreqwide",
00684                 "clock frequency measured by GPS", 1000, -2., 200.);
00685         gpsfreqwide->setAxisTitle("CMS clock frequency (MHz)");
00686 
00687         gpsfreqlum = m_dbe->book2D("gpsfreqlum",
00688                 "clock frequency measured by GPS",
00689                 TotalNrBinsLs, 0., totalNrBinsLs, 100, 39.95, 40.2);
00690         gpsfreqlum->setAxisTitle("Luminosity segment", 1);
00691         gpsfreqlum->setAxisTitle("CMS clock frequency (MHz)", 2);
00692 
00693         BST_intensityBeam1 = m_dbe->book2D("BST_intensityBeam1",
00694                 "intensity beam 1",
00695                 TotalNrBinsLs, 0., totalNrBinsLs, 100, 0., 100.);
00696         BST_intensityBeam1->setAxisTitle("Luminosity segment", 1);
00697         BST_intensityBeam1->setAxisTitle("Beam intensity", 2);
00698 
00699         BST_intensityBeam2 = m_dbe->book2D("BST_intensityBeam2",
00700                 "intensity beam 2",
00701                 TotalNrBinsLs, 0., totalNrBinsLs, 100, 0., 100.);
00702         BST_intensityBeam2->setAxisTitle("Luminosity segment", 1);
00703         BST_intensityBeam2->setAxisTitle("Beam intensity", 2);
00704 
00705         // prescale factor index monitoring
00706 
00707         m_monL1PrescaleFactorSet = m_dbe->book2D("L1PrescaleFactorSet",
00708                 "Index of L1 prescale factor set",
00709                 TotalNrBinsLs, 0., totalNrBinsLs, 25, 0., 25.);
00710         m_monL1PrescaleFactorSet->setAxisTitle("Luminosity segment", 1);
00711         m_monL1PrescaleFactorSet->setAxisTitle("L1 PF set index", 2);
00712 
00713         m_monL1PfIndicesPerLs = m_dbe->book1D("L1PfIndicesPerLs",
00714                 "Number of prescale factor indices used per LS", 10, 0., 10.);
00715         m_monL1PfIndicesPerLs->setAxisTitle("Number of PF indices used per LS", 1);
00716         m_monL1PfIndicesPerLs->setAxisTitle("Entries/run", 2);
00717 
00718 
00719         // TCS vs FDL common quantity monitoring
00720 
00721         m_dbe->setCurrentFolder(m_histFolder + "/TCSvsEvmFDL");
00722 
00723         //    orbit number
00724         m_monOrbitNrDiffTcsFdlEvm = m_dbe->book1D("OrbitNrDiffTcsFdlEvm",
00725                         "Orbit number difference (TCS - EVM_FDL)",
00726                         2 * MaxOrbitNrDiffTcsFdlEvm + 1,
00727                         static_cast<float>(-(MaxOrbitNrDiffTcsFdlEvm + 1)),
00728                         static_cast<float>(MaxOrbitNrDiffTcsFdlEvm + 1));
00729         m_monOrbitNrDiffTcsFdlEvm->setAxisTitle("Orbit number difference", 1);
00730         m_monOrbitNrDiffTcsFdlEvm->setAxisTitle("Entries/run", 2);
00731 
00732         m_monLsNrDiffTcsFdlEvm = m_dbe->book1D("LsNrDiffTcsFdlEvm",
00733                         "LS number difference (TCS - EVM_FDL)",
00734                         2 * MaxLsNrDiffTcsFdlEvm + 1,
00735                         static_cast<float>(-(MaxLsNrDiffTcsFdlEvm + 1)),
00736                         static_cast<float>(MaxLsNrDiffTcsFdlEvm + 1));
00737         m_monLsNrDiffTcsFdlEvm->setAxisTitle("LS number difference", 1);
00738         m_monLsNrDiffTcsFdlEvm->setAxisTitle("Entries/run", 2);
00739 
00740         //    LS number
00741 
00742         m_monOrbitNrDiffTcsFdlEvmLs = m_dbe->book2D("OrbitNrDiffTcsFdlEvmLs",
00743                 "Orbit number difference (TCS - EVM_FDL)",
00744                 TotalNrBinsLs, 0., totalNrBinsLs,
00745                 2 * MaxOrbitNrDiffTcsFdlEvm + 1,
00746                 static_cast<float>(-(MaxOrbitNrDiffTcsFdlEvm + 1)),
00747                 static_cast<float>(MaxOrbitNrDiffTcsFdlEvm + 1));
00748         m_monOrbitNrDiffTcsFdlEvmLs->setAxisTitle("Luminosity segment", 1);
00749         m_monOrbitNrDiffTcsFdlEvmLs->setAxisTitle("Orbit number difference (TCS - EVM_FDL)", 2);
00750 
00751         m_monLsNrDiffTcsFdlEvmLs = m_dbe->book2D("LsNrDiffTcsFdlEvmLs",
00752                 "LS number difference (TCS - EVM_FDL)",
00753                 TotalNrBinsLs, 0., totalNrBinsLs,
00754                 2 * MaxLsNrDiffTcsFdlEvm + 1,
00755                 static_cast<float>(-(MaxLsNrDiffTcsFdlEvm + 1)),
00756                 static_cast<float>(MaxLsNrDiffTcsFdlEvm + 1));
00757         m_monLsNrDiffTcsFdlEvmLs->setAxisTitle("Luminosity segment", 1);
00758         m_monLsNrDiffTcsFdlEvmLs->setAxisTitle("LS number difference (TCS - EVM_FDL)", 2);
00759 
00760         m_dbe->setCurrentFolder(m_histFolder);
00761    }
00762 
00763 
00764 
00765 }
00766 
00767 
00769 bool L1TGT::isActive(int word, int bit) {
00770     if (word & (1 << bit))
00771         return true;
00772     return false;
00773 }
00774 // static class members
00775 // maximum difference in orbit number
00776 const int L1TGT::MaxOrbitNrDiffTcsFdlEvm = 24;
00777 
00778 // maximum difference in luminosity segment number
00779 const int L1TGT::MaxLsNrDiffTcsFdlEvm = 24;
00780