Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:10:43

0001 /*
0002  * \L1TStage2BMTF.cc
0003  * \author Esmaeel Eskandari Tadavani
0004  * \December 2015
0005 /G.karathanasis     
0006 */
0007 
0008 #include "DQM/L1TMonitor/interface/L1TStage2BMTF.h"
0009 
0010 L1TStage2BMTF::L1TStage2BMTF(const edm::ParameterSet& ps)
0011     : monitorDir(ps.getUntrackedParameter<std::string>("monitorDir", "")),
0012       bmtfSource(ps.getParameter<edm::InputTag>("bmtfSource")),
0013       //  bmtfSourceTwinMux1(ps.getParameter<edm::InputTag>("bmtfSourceTwinMux1")),
0014       //  bmtfSourceTwinMux2(ps.getParameter<edm::InputTag>("bmtfSourceTwinMux2")),
0015       verbose(ps.getUntrackedParameter<bool>("verbose", false)),
0016       kalman(ps.getUntrackedParameter<bool>("kalman", false)),
0017       global_phi(-1000) {
0018   bmtfToken = consumes<l1t::RegionalMuonCandBxCollection>(ps.getParameter<edm::InputTag>("bmtfSource"));
0019   //  bmtfTokenTwinMux1 = consumes<L1MuDTChambThContainer>(ps.getParameter<edm::InputTag>("bmtfSourceTwinMux1"));
0020   //  bmtfTokenTwinMux2 = consumes<L1MuDTChambPhContainer>(ps.getParameter<edm::InputTag>("bmtfSourceTwinMux2"));
0021 }
0022 
0023 L1TStage2BMTF::~L1TStage2BMTF() {}
0024 
0025 void L1TStage2BMTF::bookHistograms(DQMStore::IBooker& ibooker, const edm::Run& iRun, const edm::EventSetup& eveSetup) {
0026   std::string histoPrefix = "bmtf";
0027   if (kalman) {
0028     histoPrefix = "kbmtf";
0029   }
0030 
0031   int ptbins = 512;
0032   int hwQual_bxbins = 20;
0033   if (kalman) {
0034     ptbins = 522;
0035     hwQual_bxbins = 15;
0036   }
0037 
0038   ibooker.setCurrentFolder(monitorDir);
0039   bmtf_hwEta = ibooker.book1D(histoPrefix + "_hwEta", "HW #eta", 461, -230.5, 230.5);
0040   bmtf_hwLocalPhi = ibooker.book1D(histoPrefix + "_hwLocalPhi", "HW Local #phi", 201, -100.5, 100.5);
0041   bmtf_hwGlobalPhi = ibooker.book1D(histoPrefix + "_hwGlobalPhi", "HW Global #phi", 576, -0.5, 575.5);
0042   bmtf_hwPt = ibooker.book1D(histoPrefix + "_hwPt", "HW p_{T}", ptbins, -0.5, ptbins - 0.5);
0043   bmtf_hwQual = ibooker.book1D(histoPrefix + "_hwQual", "HW Quality", 20, -0.5, 19.5);
0044   bmtf_proc = ibooker.book1D(histoPrefix + "_proc", "Processor", 12, -0.5, 11.5);
0045 
0046   bmtf_wedge_bx = ibooker.book2D(histoPrefix + "_wedge_bx", "Wedge vs BX", 12, -0.5, 11.5, 5, -2.5, 2.5);
0047   bmtf_wedge_bx->setTitle(";Wedge; BX");
0048   for (int bin = 1; bin < 13; ++bin) {
0049     bmtf_wedge_bx->setBinLabel(bin, std::to_string(bin), 1);
0050   }
0051 
0052   bmtf_hwEta_hwLocalPhi = ibooker.book2D(
0053       histoPrefix + "_hwEta_hwLocalPhi", "HW #eta vs HW Local #phi", 461, -230.5, 230.5, 201, -100.5, 100.5);
0054   bmtf_hwEta_hwLocalPhi->setTitle(";HW #eta; HW Local #phi");
0055 
0056   bmtf_hwEta_hwGlobalPhi = ibooker.book2D(
0057       histoPrefix + "_hwEta_hwGlobalPhi", "HW #eta vs HW Global #phi", 100, -230.5, 230.5, 120, -0.5, 575.5);
0058   bmtf_hwEta_hwGlobalPhi->setTitle(";HW #eta; HW Global #phi");
0059 
0060   bmtf_hwPt_hwEta =
0061       ibooker.book2D(histoPrefix + "_hwPt_hwEta", "HW p_{T} vs HW #eta", 511, -0.5, 510.5, 461, -230.5, 230.5);
0062   bmtf_hwPt_hwEta->setTitle(";HW p_{T}; HW #eta");
0063 
0064   bmtf_hwPt_hwLocalPhi = ibooker.book2D(
0065       histoPrefix + "_hwPt_hwLocalPhi", "HW p_{T} vs HW Local #phi", 511, -0.5, 510.5, 201, -100.5, 100.5);
0066   bmtf_hwPt_hwLocalPhi->setTitle(";HW p_{T}; HW Local #phi");
0067 
0068   bmtf_hwEta_bx = ibooker.book2D(histoPrefix + "_hwEta_bx", "HW #eta vs BX", 461, -230.5, 230.5, 5, -2.5, 2.5);
0069   bmtf_hwEta_bx->setTitle(";HW #eta; BX");
0070 
0071   bmtf_hwLocalPhi_bx =
0072       ibooker.book2D(histoPrefix + "_hwLocalPhi_bx", "HW Local #phi vs BX", 201, -100.5, 100.5, 5, -2.5, 2.5);
0073   bmtf_hwLocalPhi_bx->setTitle(";HW Local #phi; BX");
0074 
0075   bmtf_hwPt_bx = ibooker.book2D(histoPrefix + "_hwPt_bx", "HW p_{T} vs BX", 511, -0.5, 510.5, 5, -2.5, 2.5);
0076   bmtf_hwPt_bx->setTitle(";HW p_{T}; BX");
0077 
0078   bmtf_hwQual_bx = ibooker.book2D(
0079       histoPrefix + "_hwQual_bx", "HW Quality vs BX", hwQual_bxbins, -0.5, hwQual_bxbins - 0.5, 5, -2.5, 2.5);
0080   bmtf_hwQual_bx->setTitle("; HW Quality; BX");
0081 
0082   bmtf_hwDXY = ibooker.book1D(histoPrefix + "_hwDXY", "HW DXY", 4, 0, 4);
0083   bmtf_hwPtUnconstrained =
0084       ibooker.book1D(histoPrefix + "_hwPtUnconstrained", "HW p_{T} unconstrained", 512, -0.5, 511.5);
0085 
0086   // bmtf_twinmuxInput_PhiBX = ibooker.book1D(histoPrefix+"_twinmuxInput_PhiBX"  , "TwinMux Input Phi BX"      ,  5, -2.5, 2.5);
0087   // bmtf_twinmuxInput_PhiPhi = ibooker.book1D(histoPrefix+"_twinmuxInput_PhiPhi"  , "TwinMux Input Phi HW Phi"      , 201, -100.5, 100.5);
0088   // bmtf_twinmuxInput_PhiPhiB = ibooker.book1D(histoPrefix+"_twinmuxInput_PhiPhiB"  , "TwinMux Input Phi HW PhiB"   , 201, -100.5, 100.5);
0089   // bmtf_twinmuxInput_PhiQual = ibooker.book1D(histoPrefix+"_twinmuxInput_PhiQual"  , "TwinMux Input Phi HW Quality" , 20,   -0.5,  19.5);
0090   // bmtf_twinmuxInput_PhiStation = ibooker.book1D(histoPrefix+"_twinmuxInput_PhiStation"  , "TwinMux Input Phi HW Station", 6, -1, 5);
0091   // bmtf_twinmuxInput_PhiSector = ibooker.book1D(histoPrefix+"_twinmuxInput_PhiSector" , "TwinMux Input Phi HW Sector"    , 14, -1,  13 );
0092   // bmtf_twinmuxInput_PhiWheel = ibooker.book1D(histoPrefix+"_twinmuxInput_PhiWheel"  , "TwinMux Input Phi HW Wheel"      , 16 , -4, 4);
0093   // bmtf_twinmuxInput_PhiTrSeg = ibooker.book1D(histoPrefix+"_twinmuxInput_PhiTrSeg"  , "TwinMux Input Phi HW Track Segment"      , 6, -1, 5 );
0094   // bmtf_twinmuxInput_PhiWheel_PhiSector = ibooker.book2D(histoPrefix+"_twinmuxInput_PhiWheel_PhiSector"  , "TwinMux Input Phi HW Wheel vs HW Sector", 16 , -4, 4, 14, -1,  13 );
0095 
0096   // bmtf_twinmuxInput_PhiWheel_PhiSector->setTitle("; TwinMux Input Phi HW Wheel; TwinMux Input Phi HW Sector");
0097   // for (int bin = 1; bin < 5; ++bin) {
0098   //   bmtf_twinmuxInput_PhiWheel_PhiSector->setBinLabel(bin, "station"+std::to_string(bin), 1);
0099   //   bmtf_twinmuxInput_PhiTrSeg->setBinLabel(bin, "station"+std::to_string(bin), 1);
0100   // }
0101 
0102   // bmtf_twinmuxInput_TheBX = ibooker.book1D(histoPrefix+"_twinmuxInput_TheBX"  , "TwinMux Input The BX"      ,   5, -2.5, 2.5);
0103   // bmtf_twinmuxInput_ThePhi= ibooker.book1D(histoPrefix+"_twinmuxInput_ThePhi"  , "TwinMux Input The HW Phi"      ,  201, -100.5, 100.5);
0104   // bmtf_twinmuxInput_ThePhiB = ibooker.book1D(histoPrefix+"_twinmuxInput_ThePhiB"  , "TwinMux Input The HW PhiB"   ,  201, -100.5, 100.5);
0105   // bmtf_twinmuxInput_TheQual = ibooker.book1D(histoPrefix+"_twinmuxInput_TheQual"  , "TwinMux Input The HW Quality" ,  20,   -0.5,  19.5);
0106   // bmtf_twinmuxInput_TheStation = ibooker.book1D(histoPrefix+"_twinmuxInput_TheStation"  , "TwinMux Input The HW Station"      , 6, -1, 5);
0107   // bmtf_twinmuxInput_TheSector = ibooker.book1D(histoPrefix+"_twinmuxInput_TheSector" , "TwinMux Input The HW Sector"      ,  14, -1,  13 );
0108   // bmtf_twinmuxInput_TheWheel = ibooker.book1D(histoPrefix+"_twinmuxInput_TheWheel"  , "TwinMux Input The HW Wheel"      ,   16 , -4, 4);
0109   // bmtf_twinmuxInput_TheTrSeg = ibooker.book1D(histoPrefix+"_twinmuxInput_TheTrSeg"  , "TwinMux Input The HW Track Segment"      , 6, -1, 5 );
0110   // bmtf_twinmuxInput_TheWheel_TheSector = ibooker.book2D(histoPrefix+"_twinmuxInput_TheWheel_TheSector"  , "TwinMux Input The HW Wheel vs HW Sector", 16 , -4, 4, 14, -1,  13);
0111 
0112   // bmtf_twinmuxInput_TheWheel_TheSector->setTitle("; TwinMux Input The HW Wheel; TwinMux Input The HW Sector");
0113   // for (int bin = 1; bin < 5; ++bin) {
0114   //   bmtf_twinmuxInput_TheWheel_TheSector->setBinLabel(bin,  "station"+std::to_string(bin), 1);
0115   //   bmtf_twinmuxInput_TheTrSeg->setBinLabel(bin,  "station"+std::to_string(bin), 1);
0116   // }
0117 }
0118 
0119 void L1TStage2BMTF::analyze(const edm::Event& eve, const edm::EventSetup& eveSetup) {
0120   edm::Handle<l1t::RegionalMuonCandBxCollection> bmtfMuon;
0121   eve.getByToken(bmtfToken, bmtfMuon);
0122 
0123   //  edm::Handle<L1MuDTChambThContainer> bmtfMuonTwinMux1;
0124   //  eve.getByToken(bmtfTokenTwinMux1, bmtfMuonTwinMux1);
0125 
0126   //  edm::Handle<L1MuDTChambPhContainer> bmtfMuonTwinMux2;
0127   //  eve.getByToken(bmtfTokenTwinMux2, bmtfMuonTwinMux2);
0128 
0129   for (int itBX = bmtfMuon->getFirstBX(); itBX <= bmtfMuon->getLastBX(); ++itBX) {
0130     for (l1t::RegionalMuonCandBxCollection::const_iterator itMuon = bmtfMuon->begin(itBX);
0131          itMuon != bmtfMuon->end(itBX);
0132          ++itMuon) {
0133       bmtf_hwEta->Fill(itMuon->hwEta());
0134       bmtf_hwLocalPhi->Fill(itMuon->hwPhi());
0135       bmtf_hwPt->Fill(itMuon->hwPt());
0136       bmtf_hwQual->Fill(itMuon->hwQual());
0137       bmtf_proc->Fill(itMuon->processor());
0138 
0139       bmtf_hwDXY->Fill(itMuon->hwDXY());
0140       bmtf_hwPtUnconstrained->Fill(itMuon->hwPtUnconstrained());
0141 
0142       if (fabs(bmtfMuon->getLastBX() - bmtfMuon->getFirstBX()) > 3) {
0143         bmtf_wedge_bx->Fill(itMuon->processor(), itBX);
0144         bmtf_hwEta_bx->Fill(itMuon->hwEta(), itBX);
0145         bmtf_hwLocalPhi_bx->Fill(itMuon->hwPhi(), itBX);
0146         bmtf_hwPt_bx->Fill(itMuon->hwPt(), itBX);
0147         bmtf_hwQual_bx->Fill(itMuon->hwQual(), itBX);
0148       }
0149 
0150       bmtf_hwEta_hwLocalPhi->Fill(itMuon->hwEta(), itMuon->hwPhi());
0151       bmtf_hwPt_hwEta->Fill(itMuon->hwPt(), itMuon->hwEta());
0152       bmtf_hwPt_hwLocalPhi->Fill(itMuon->hwPt(), itMuon->hwPhi());
0153 
0154       /*if(itMuon->hwPhi()*0.010902>=0 && itMuon->hwPhi()*0.010902<=30)
0155             global_phi = itMuon->hwPhi() + itMuon->processor()*30.;
0156           if(itMuon->hwPhi()*0.010902<0)
0157             global_phi = 30-itMuon->hwPhi() + (itMuon->processor()-1)*30.;
0158           if(itMuon->hwPhi()*0.010902>30)
0159             global_phi = itMuon->hwPhi()-30 + (itMuon->processor()+1)*30.;*/
0160       global_phi = itMuon->hwPhi() + itMuon->processor() * 48. - 15;
0161       if (global_phi < 0)
0162         global_phi = 576 + global_phi;
0163 
0164       bmtf_hwGlobalPhi->Fill(global_phi);
0165       bmtf_hwEta_hwGlobalPhi->Fill(itMuon->hwEta(), global_phi);
0166     }
0167   }
0168 
0169   // for(L1MuDTChambThContainer::The_Container::const_iterator itMuon = bmtfMuonTwinMux1->getContainer()->begin(); itMuon != bmtfMuonTwinMux1->getContainer()->end(); ++itMuon)
0170   //    {
0171 
0172   //      bmtf_twinmuxInput_TheBX->Fill(itMuon->bxNum());
0173   //      //      bmtf_twinmuxInput_ThePhi->Fill(itMuon->phi());
0174   //      //      bmtf_twinmuxInput_ThePhiB->Fill(itMuon->phiB());
0175   //      //      bmtf_twinmuxInput_TheQual->Fill(itMuon->code());
0176   //      bmtf_twinmuxInput_TheStation->Fill(itMuon->stNum());
0177   //      bmtf_twinmuxInput_TheSector->Fill(itMuon->scNum());
0178   //      bmtf_twinmuxInput_TheWheel->Fill(itMuon->whNum());
0179 
0180   //     for(int i = 1; i<=itMuon->stNum(); ++i)
0181   //       {
0182   //          //          bmtf_twinmuxInput_TheTrSeg->Fill(itMuon->Ts2Tag());
0183   //          bmtf_twinmuxInput_TheWheel_TheSector->Fill(itMuon->whNum(), itMuon->scNum());
0184   //        }
0185 
0186   //    }
0187 
0188   // for(L1MuDTChambPhContainer::Phi_Container::const_iterator itMuon = bmtfMuonTwinMux2->getContainer()->begin(); itMuon != bmtfMuonTwinMux2->getContainer()->end(); ++itMuon)
0189   //    {
0190 
0191   //      bmtf_twinmuxInput_PhiBX->Fill(itMuon->bxNum());
0192   //      bmtf_twinmuxInput_PhiPhi->Fill(itMuon->phi());
0193   //      bmtf_twinmuxInput_PhiPhiB->Fill(itMuon->phiB());
0194   //      bmtf_twinmuxInput_PhiQual->Fill(itMuon->code());
0195   //      bmtf_twinmuxInput_PhiStation->Fill(itMuon->stNum());
0196   //      bmtf_twinmuxInput_PhiSector->Fill(itMuon->scNum());
0197   //      bmtf_twinmuxInput_PhiWheel->Fill(itMuon->whNum());
0198 
0199   //      for(int i = 1; i<= itMuon->stNum() ; ++i)
0200   //        {
0201   //          bmtf_twinmuxInput_PhiTrSeg->Fill(itMuon->Ts2Tag());
0202   //          bmtf_twinmuxInput_PhiWheel_PhiSector->Fill(itMuon->whNum(), itMuon->scNum());
0203   //        }
0204 
0205   //    }
0206 }