Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-01 23:54:08

0001 #include "L1Trigger/Phase2L1GMT/interface/L1TPhase2GMTBarrelStubProcessor.h"
0002 #include <cmath>
0003 #include <iostream>
0004 #include <string>
0005 #include <sstream>
0006 
0007 L1TPhase2GMTBarrelStubProcessor::L1TPhase2GMTBarrelStubProcessor() : minPhiQuality_(0), minBX_(-3), maxBX_(3) {}
0008 
0009 L1TPhase2GMTBarrelStubProcessor::L1TPhase2GMTBarrelStubProcessor(const edm::ParameterSet& iConfig)
0010     : minPhiQuality_(iConfig.getParameter<int>("minPhiQuality")),
0011       minBX_(iConfig.getParameter<int>("minBX")),
0012       maxBX_(iConfig.getParameter<int>("maxBX")),
0013       eta1_(iConfig.getParameter<std::vector<int> >("eta_1")),
0014       eta2_(iConfig.getParameter<std::vector<int> >("eta_2")),
0015       eta3_(iConfig.getParameter<std::vector<int> >("eta_3")),
0016       coarseEta1_(iConfig.getParameter<std::vector<int> >("coarseEta_1")),
0017       coarseEta2_(iConfig.getParameter<std::vector<int> >("coarseEta_2")),
0018       coarseEta3_(iConfig.getParameter<std::vector<int> >("coarseEta_3")),
0019       coarseEta4_(iConfig.getParameter<std::vector<int> >("coarseEta_4")),
0020       phiOffset_(iConfig.getParameter<std::vector<int> >("phiOffset")),
0021       phiBFactor_(iConfig.getParameter<int>("phiBDivider")),
0022       verbose_(iConfig.getParameter<int>("verbose")),
0023       phiLSB_(iConfig.getParameter<double>("phiLSB")),
0024       etaLSB_(iConfig.getParameter<double>("etaLSB")) {}
0025 
0026 L1TPhase2GMTBarrelStubProcessor::~L1TPhase2GMTBarrelStubProcessor() {}
0027 
0028 l1t::MuonStub L1TPhase2GMTBarrelStubProcessor::buildStub(const L1Phase2MuDTPhDigi& phiS,
0029                                                          const L1MuDTChambThDigi* etaS) {
0030   l1t::MuonStub stub = buildStubNoEta(phiS);
0031 
0032   //Now full eta
0033   int qeta1 = -16384;
0034   int qeta2 = -16384;
0035   int eta1 = -16384;
0036   int eta2 = -16384;
0037 
0038   bool hasEta = false;
0039   for (uint i = 0; i < 7; ++i) {
0040     if (etaS->position(i) == 0)
0041       continue;
0042     if (!hasEta) {
0043       hasEta = true;
0044       eta1 = calculateEta(i, etaS->whNum(), etaS->scNum(), etaS->stNum());
0045 
0046       if (etaS->quality(i) == 1)
0047         qeta1 = 2;
0048       else
0049         qeta1 = 1;
0050     } else {
0051       eta2 = calculateEta(i, etaS->whNum(), etaS->scNum(), etaS->stNum());
0052       if (etaS->quality(i) == 1)
0053         qeta2 = 2;
0054       else
0055         qeta2 = 1;
0056     }
0057   }
0058 
0059   if (qeta2 > 0) {  //both stubs->average
0060     stub.setEta(eta1, eta2, 3);
0061     stub.setOfflineQuantities(stub.offline_coord1(), stub.offline_coord2(), eta1 * etaLSB_, eta2 * etaLSB_);
0062 
0063   } else if (qeta1 > 0) {  //Good single stub
0064     stub.setEta(eta1, 0, 1);
0065     stub.setOfflineQuantities(stub.offline_coord1(), stub.offline_coord2(), eta1 * etaLSB_, 0.0);
0066   }
0067 
0068   return stub;
0069 }
0070 
0071 l1t::MuonStub L1TPhase2GMTBarrelStubProcessor::buildStubNoEta(const L1Phase2MuDTPhDigi& phiS) {
0072   int wheel = phiS.whNum();
0073   int abswheel = fabs(phiS.whNum());
0074   int sign = wheel > 0 ? 1 : -1;
0075   int sector = phiS.scNum();
0076   int station = phiS.stNum();
0077   double globalPhi = (sector * 30) + phiS.phi() * 30. / 65535.;
0078   if (globalPhi < -180)
0079     globalPhi += 360;
0080   if (globalPhi > 180)
0081     globalPhi -= 360;
0082   globalPhi = globalPhi * M_PI / 180.;
0083   int phi = int(globalPhi / phiLSB_) + phiOffset_[station - 1];
0084   int phiB = phiS.phiBend() / phiBFactor_;
0085   uint tag = phiS.index();
0086   int bx = phiS.bxNum() - 20;
0087   int quality = 3;
0088   uint tfLayer = phiS.stNum() - 1;
0089   int eta = -16384;
0090   if (station == 1) {
0091     eta = coarseEta1_[abswheel];
0092   } else if (station == 2) {
0093     eta = coarseEta2_[abswheel];
0094   } else if (station == 3) {
0095     eta = coarseEta3_[abswheel];
0096   } else if (station == 4) {
0097     eta = coarseEta4_[abswheel];
0098   }
0099 
0100   //override!!!
0101   //  eta=abswheel;
0102 
0103   //Now full eta
0104 
0105   eta = eta * sign;
0106   l1t::MuonStub stub(wheel, sector, station, tfLayer, phi, phiB, tag, bx, quality, eta, 0, 0, 1);
0107   stub.setOfflineQuantities(globalPhi, float(phiB), eta* etaLSB_, 0.0);
0108   return stub;
0109 }
0110 
0111 l1t::MuonStubCollection L1TPhase2GMTBarrelStubProcessor::makeStubs(const L1Phase2MuDTPhContainer* phiContainer,
0112                                                                    const L1MuDTChambThContainer* etaContainer) {
0113   l1t::MuonStubCollection out;
0114   for (int bx = minBX_; bx <= maxBX_; bx++) {
0115     for (int wheel = -2; wheel <= 2; wheel++) {
0116       for (int sector = 0; sector < 12; sector++) {
0117         for (int station = 1; station < 5; station++) {
0118           bool hasEta = false;
0119           const L1MuDTChambThDigi* tseta = etaContainer->chThetaSegm(wheel, station, sector, bx);
0120           if (tseta != nullptr) {
0121             hasEta = true;
0122           }
0123 
0124           for (const auto& phiDigi : *phiContainer->getContainer()) {
0125             if ((phiDigi.bxNum() - 20) != bx || phiDigi.whNum() != wheel || phiDigi.scNum() != sector ||
0126                 phiDigi.stNum() != station)
0127               continue;
0128             if (phiDigi.quality() < minPhiQuality_)
0129               continue;
0130             if (hasEta) {
0131               out.push_back(buildStub(phiDigi, tseta));
0132             } else {
0133               out.push_back(buildStubNoEta(phiDigi));
0134             }
0135           }
0136         }
0137       }
0138     }
0139   }
0140 
0141   if (verbose_) {
0142     printf("Barrel Stubs\n");
0143     for (const auto& stub : out)
0144       printf(
0145           "Barrel Stub bx=%d TF=%d etaRegion=%d phiRegion=%d depthRegion=%d  coord1=%f,%d coord2=%f,%d eta1=%f,%d "
0146           "eta2=%f,%d quality=%d etaQuality=%d\n",
0147           stub.bxNum(),
0148           stub.tfLayer(),
0149           stub.etaRegion(),
0150           stub.phiRegion(),
0151           stub.depthRegion(),
0152           stub.offline_coord1(),
0153           stub.coord1(),
0154           stub.offline_coord2(),
0155           stub.coord2(),
0156           stub.offline_eta1(),
0157           stub.eta1(),
0158           stub.offline_eta2(),
0159           stub.eta2(),
0160           stub.quality(),
0161           stub.etaQuality());
0162   }
0163 
0164   return out;
0165 }
0166 
0167 int L1TPhase2GMTBarrelStubProcessor::calculateEta(uint i, int wheel, uint sector, uint station) {
0168   int eta = 0;
0169   if (wheel > 0) {
0170     eta = 7 * wheel + 3 - i;
0171   } else if (wheel < 0) {
0172     eta = 7 * wheel + i - 3;
0173   } else {
0174     if (sector == 0 || sector == 3 || sector == 4 || sector == 7 || sector == 8 || sector == 11)
0175       eta = i - 3;
0176     else
0177       eta = 3 - i;
0178   }
0179 
0180   if (station == 1)
0181     eta = eta1_[eta + 17];
0182   else if (station == 2)
0183     eta = eta2_[eta + 17];
0184   else
0185     eta = eta3_[eta + 17];
0186 
0187   return eta;
0188 }