CMS 3D CMS Logo

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