File indexing completed on 2024-09-07 04:37:02
0001 #include "L1Trigger/L1TNtuples/interface/L1AnalysisCSCTF.h"
0002
0003 L1Analysis::L1AnalysisCSCTF::L1AnalysisCSCTF() {}
0004
0005 L1Analysis::L1AnalysisCSCTF::~L1AnalysisCSCTF() {}
0006
0007 void L1Analysis::L1AnalysisCSCTF::SetTracks(const edm::Handle<L1CSCTrackCollection> csctfTrks,
0008 const L1MuTriggerScales* ts,
0009 const L1MuTriggerPtScale* tpts,
0010 CSCSectorReceiverLUT* srLUTs_[5][2],
0011 CSCTFPtLUT* ptLUTs_) {
0012
0013
0014 csctf_.trSize = csctfTrks->size();
0015
0016
0017 int nTrk = 0;
0018 for (L1CSCTrackCollection::const_iterator trk = csctfTrks->begin(); trk < csctfTrks->end(); trk++) {
0019 nTrk++;
0020
0021
0022
0023 csctf_.trEndcap.push_back(trk->first.endcap() == 2 ? trk->first.endcap() - 3 : trk->first.endcap());
0024
0025 csctf_.trSector.push_back(6 * (trk->first.endcap() - 1) + trk->first.sector());
0026 csctf_.trBx.push_back(trk->first.BX());
0027
0028 csctf_.trME1ID.push_back(trk->first.me1ID());
0029 csctf_.trME2ID.push_back(trk->first.me2ID());
0030 csctf_.trME3ID.push_back(trk->first.me3ID());
0031 csctf_.trME4ID.push_back(trk->first.me4ID());
0032 csctf_.trMB1ID.push_back(trk->first.mb1ID());
0033
0034 csctf_.trME1TBin.push_back(trk->first.me1Tbin());
0035 csctf_.trME2TBin.push_back(trk->first.me2Tbin());
0036 csctf_.trME3TBin.push_back(trk->first.me3Tbin());
0037 csctf_.trME4TBin.push_back(trk->first.me4Tbin());
0038 csctf_.trMB1TBin.push_back(trk->first.mb1Tbin());
0039
0040
0041 csctf_.trOutputLink.push_back(trk->first.outputLink());
0042
0043
0044 ptadd thePtAddress(trk->first.ptLUTAddress());
0045
0046 csctf_.trPhiSign.push_back(thePtAddress.delta_phi_sign);
0047 csctf_.trPhi12.push_back(thePtAddress.delta_phi_12);
0048 csctf_.trPhi23.push_back(thePtAddress.delta_phi_23);
0049 csctf_.trMode.push_back(thePtAddress.track_mode);
0050 csctf_.trForR.push_back(thePtAddress.track_fr);
0051 csctf_.trCharge.push_back(trk->first.chargeValue());
0052
0053
0054
0055 ptdat thePtData = ptLUTs_->Pt(thePtAddress);
0056
0057
0058 if (thePtAddress.track_fr) {
0059 csctf_.trPtBit.push_back(thePtData.front_rank & 0x1f);
0060 csctf_.trQuality.push_back((thePtData.front_rank >> 5) & 0x3);
0061 csctf_.trChargeValid.push_back(thePtData.charge_valid_front);
0062 } else {
0063 csctf_.trPtBit.push_back(thePtData.rear_rank & 0x1f);
0064 csctf_.trQuality.push_back((thePtData.rear_rank >> 5) & 0x3);
0065 csctf_.trChargeValid.push_back(thePtData.charge_valid_rear);
0066 }
0067
0068
0069 csctf_.trPt.push_back(tpts->getPtScale()->getLowEdge(csctf_.trPtBit.back()));
0070
0071
0072 csctf_.trEtaBit.push_back(trk->first.eta_packed());
0073 csctf_.trPhiBit.push_back(trk->first.localPhi());
0074
0075
0076
0077
0078
0079 csctf_.trEta.push_back(ts->getRegionalEtaScale(2)->getCenter(trk->first.eta_packed()));
0080 csctf_.trPhi.push_back(ts->getPhiScale()->getLowEdge(trk->first.localPhi()));
0081
0082 csctf_.trPhi_02PI.push_back(
0083 fmod(csctf_.trPhi[nTrk - 1] + ((trk->first.sector() - 1) * TMath::Pi() / 3) +
0084 (TMath::Pi() / 12),
0085 2 * TMath::Pi()));
0086
0087
0088
0089
0090
0091 CSCCorrelatedLCTDigiCollection lctsOfTracks = trk->second;
0092
0093 int LctTrkId_ = 0;
0094
0095 for (CSCCorrelatedLCTDigiCollection::DigiRangeIterator lctOfTrks = lctsOfTracks.begin();
0096 lctOfTrks != lctsOfTracks.end();
0097 lctOfTrks++) {
0098 int lctTrkId = 0;
0099
0100 CSCCorrelatedLCTDigiCollection::Range lctRange = lctsOfTracks.get((*lctOfTrks).first);
0101
0102 for (CSCCorrelatedLCTDigiCollection::const_iterator lctTrk = lctRange.first; lctTrk != lctRange.second;
0103 lctTrk++, lctTrkId++) {
0104 csctf_.trLctEndcap[nTrk - 1][LctTrkId_] = (*lctOfTrks).first.zendcap();
0105 if ((*lctOfTrks).first.zendcap() > 0)
0106 csctf_.trLctSector[nTrk - 1][LctTrkId_] = (*lctOfTrks).first.triggerSector();
0107 else
0108 csctf_.trLctSector[nTrk - 1][LctTrkId_] = 6 + (*lctOfTrks).first.triggerSector();
0109 csctf_.trLctSubSector[nTrk - 1][LctTrkId_] =
0110 CSCTriggerNumbering::triggerSubSectorFromLabels((*lctOfTrks).first);
0111 ;
0112 csctf_.trLctBx[nTrk - 1][LctTrkId_] = lctTrk->getBX();
0113 csctf_.trLctBx0[nTrk - 1][LctTrkId_] = lctTrk->getBX0();
0114
0115 csctf_.trLctStation[nTrk - 1][LctTrkId_] = (*lctOfTrks).first.station();
0116 csctf_.trLctRing[nTrk - 1][LctTrkId_] = (*lctOfTrks).first.ring();
0117 csctf_.trLctChamber[nTrk - 1][LctTrkId_] = (*lctOfTrks).first.chamber();
0118 csctf_.trLctTriggerCSCID[nTrk - 1][LctTrkId_] = (*lctOfTrks).first.triggerCscId();
0119 csctf_.trLctFpga[nTrk - 1][LctTrkId_] =
0120 (csctf_.trLctSubSector[nTrk - 1][LctTrkId_] ? csctf_.trLctSubSector[nTrk - 1][LctTrkId_]
0121 : (*lctOfTrks).first.station() + 1);
0122
0123
0124 if (csctf_.trLctSector[nTrk - 1][LctTrkId_] < 1 || csctf_.trLctSector[nTrk - 1][LctTrkId_] > 12 ||
0125 csctf_.trLctStation[nTrk - 1][LctTrkId_] < 1 || csctf_.trLctStation[nTrk - 1][LctTrkId_] > 4 ||
0126 csctf_.trLctTriggerCSCID[nTrk - 1][LctTrkId_] < 1 || csctf_.trLctTriggerCSCID[nTrk - 1][LctTrkId_] > 9 ||
0127 lctTrkId < 0 || lctTrkId > 1) {
0128 edm::LogInfo("L1NtupleProducer") << " TRACK ERROR: CSC digi are out of range: ";
0129
0130 continue;
0131 }
0132
0133
0134 int endcap = (*lctOfTrks).first.zendcap();
0135 if (endcap < 0)
0136 endcap = 0;
0137
0138 int StationLctTrk = (*lctOfTrks).first.station();
0139 int CscIdLctTrk = (*lctOfTrks).first.triggerCscId();
0140 int SubSectorLctTrk = CSCTriggerNumbering::triggerSubSectorFromLabels((*lctOfTrks).first);
0141
0142 int FPGALctTrk = (SubSectorLctTrk ? SubSectorLctTrk - 1 : StationLctTrk);
0143
0144
0145 lclphidat lclPhi;
0146
0147 try {
0148 csctf_.trLctstripNum[nTrk - 1][LctTrkId_] = lctTrk->getStrip();
0149 lclPhi = srLUTs_[FPGALctTrk][endcap]->localPhi(
0150 lctTrk->getStrip(), lctTrk->getPattern(), lctTrk->getQuality(), lctTrk->getBend());
0151
0152 csctf_.trLctlocalPhi[nTrk - 1][LctTrkId_] = lclPhi.phi_local;
0153
0154
0155 csctf_.trLctQuality[nTrk - 1][LctTrkId_] = lctTrk->getQuality();
0156
0157
0158 } catch (...) {
0159 bzero(&lclPhi, sizeof(lclPhi));
0160 csctf_.trLctlocalPhi[nTrk - 1][LctTrkId_] = -999;
0161
0162
0163 csctf_.trLctQuality[nTrk - 1][LctTrkId_] = -999;
0164 }
0165
0166 lclphiadd lclPattern;
0167 try {
0168
0169
0170
0171 } catch (...) {
0172 }
0173
0174
0175 gblphidat gblPhi;
0176
0177 try {
0178 csctf_.trLctwireGroup[nTrk - 1][LctTrkId_] = lctTrk->getKeyWG();
0179 gblPhi = srLUTs_[FPGALctTrk][endcap]->globalPhiME(lclPhi.phi_local, lctTrk->getKeyWG(), CscIdLctTrk);
0180
0181 csctf_.trLctglobalPhi[nTrk - 1][LctTrkId_] = gblPhi.global_phi;
0182
0183 } catch (...) {
0184 bzero(&gblPhi, sizeof(gblPhi));
0185 csctf_.trLctglobalPhi[nTrk - 1][LctTrkId_] = -999;
0186 }
0187
0188
0189 gbletadat gblEta;
0190
0191 try {
0192 gblEta = srLUTs_[FPGALctTrk][endcap]->globalEtaME(
0193 lclPhi.phi_bend_local, lclPhi.phi_local, lctTrk->getKeyWG(), CscIdLctTrk);
0194 csctf_.trLctglobalEta[nTrk - 1][LctTrkId_] = gblEta.global_eta;
0195 csctf_.trLctCLCT_pattern[nTrk - 1][LctTrkId_] = gblEta.global_bend;
0196 } catch (...) {
0197 bzero(&gblEta, sizeof(gblEta));
0198 csctf_.trLctglobalEta[nTrk - 1][LctTrkId_] = -999;
0199 csctf_.trLctCLCT_pattern[nTrk - 1][LctTrkId_] = -999;
0200 }
0201
0202 ++LctTrkId_;
0203
0204 }
0205 }
0206
0207 csctf_.trNumLCTs.push_back(LctTrkId_);
0208
0209
0210
0211
0212
0213
0214 }
0215 }
0216
0217
0218 void L1Analysis::L1AnalysisCSCTF::SetLCTs(const edm::Handle<CSCCorrelatedLCTDigiCollection> corrlcts,
0219 CSCSectorReceiverLUT* srLUTs_[5][2]) {
0220 int nLCT = 0;
0221 for (CSCCorrelatedLCTDigiCollection::DigiRangeIterator corrLct = corrlcts.product()->begin();
0222 corrLct != corrlcts.product()->end();
0223 corrLct++) {
0224 nLCT++;
0225
0226 int lctId = 0;
0227
0228 CSCCorrelatedLCTDigiCollection::Range lctRange = corrlcts.product()->get((*corrLct).first);
0229
0230 for (CSCCorrelatedLCTDigiCollection::const_iterator lct = lctRange.first; lct != lctRange.second; lct++, lctId++) {
0231 csctf_.lctEndcap.push_back((*corrLct).first.zendcap());
0232 if ((*corrLct).first.zendcap() > 0)
0233 csctf_.lctSector.push_back((*corrLct).first.triggerSector());
0234 else
0235 csctf_.lctSector.push_back(6 + (*corrLct).first.triggerSector());
0236
0237 csctf_.lctSubSector.push_back(CSCTriggerNumbering::triggerSubSectorFromLabels((*corrLct).first));
0238 csctf_.lctBx.push_back(lct->getBX());
0239 csctf_.lctBx0.push_back(lct->getBX0());
0240
0241 csctf_.lctStation.push_back((*corrLct).first.station());
0242 csctf_.lctRing.push_back((*corrLct).first.ring());
0243 csctf_.lctChamber.push_back((*corrLct).first.chamber());
0244 csctf_.lctTriggerCSCID.push_back((*corrLct).first.triggerCscId());
0245 csctf_.lctFpga.push_back(
0246 (csctf_.lctSubSector.back() ? csctf_.lctSubSector.back() : (*corrLct).first.station() + 1));
0247
0248
0249 if (csctf_.lctSector.back() < 1 || csctf_.lctSector.back() > 12 || csctf_.lctStation.back() < 1 ||
0250 csctf_.lctStation.back() > 4 || csctf_.lctTriggerCSCID.back() < 1 || csctf_.lctTriggerCSCID.back() > 9 ||
0251 lctId < 0 || lctId > 1) {
0252 edm::LogInfo("L1NtupleProducer") << " LCT ERROR: CSC digi are out of range: ";
0253
0254 continue;
0255 }
0256
0257
0258 int endcap = (*corrLct).first.zendcap();
0259 if (endcap < 0)
0260 endcap = 0;
0261
0262 int StationLct = (*corrLct).first.station();
0263 int CscIdLct = (*corrLct).first.triggerCscId();
0264 int SubSectorLct = CSCTriggerNumbering::triggerSubSectorFromLabels((*corrLct).first);
0265
0266 int FPGALct = (SubSectorLct ? SubSectorLct - 1 : StationLct);
0267
0268
0269 lclphidat lclPhi;
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285 try {
0286 csctf_.lctstripNum.push_back(lct->getStrip());
0287 lclPhi =
0288 srLUTs_[FPGALct][endcap]->localPhi(lct->getStrip(), lct->getPattern(), lct->getQuality(), lct->getBend());
0289
0290 csctf_.lctlocalPhi.push_back(lclPhi.phi_local);
0291
0292
0293 csctf_.lctQuality.push_back(lct->getQuality());
0294
0295
0296
0297 } catch (...) {
0298 bzero(&lclPhi, sizeof(lclPhi));
0299 csctf_.lctlocalPhi.push_back(-999);
0300
0301
0302 csctf_.lctQuality.push_back(-999);
0303 }
0304
0305
0306 gblphidat gblPhi;
0307
0308 try {
0309 csctf_.lctwireGroup.push_back(lct->getKeyWG());
0310
0311
0312
0313
0314
0315 gblPhi = srLUTs_[FPGALct][endcap]->globalPhiME(lclPhi.phi_local, lct->getKeyWG(), CscIdLct);
0316 csctf_.lctglobalPhi.push_back(gblPhi.global_phi);
0317
0318 } catch (...) {
0319 bzero(&gblPhi, sizeof(gblPhi));
0320 csctf_.lctglobalPhi.push_back(-999);
0321 }
0322
0323
0324 gbletadat gblEta;
0325
0326 try {
0327 gblEta =
0328 srLUTs_[FPGALct][endcap]->globalEtaME(lclPhi.phi_bend_local, lclPhi.phi_local, lct->getKeyWG(), CscIdLct);
0329
0330 csctf_.lctglobalEta.push_back(gblEta.global_eta);
0331 csctf_.lctCLCT_pattern.push_back(gblEta.global_bend);
0332 } catch (...) {
0333 bzero(&gblEta, sizeof(gblEta));
0334 csctf_.lctglobalEta.push_back(-999);
0335 csctf_.lctCLCT_pattern.push_back(-999);
0336 }
0337
0338 }
0339 }
0340
0341 csctf_.lctSize = nLCT;
0342 }
0343
0344 void L1Analysis::L1AnalysisCSCTF::SetStatus(const edm::Handle<L1CSCStatusDigiCollection> status) {
0345 int nStat = 0;
0346 for (std::vector<L1CSCSPStatusDigi>::const_iterator stat = status->second.begin(); stat != status->second.end();
0347 stat++) {
0348
0349 if (stat->VPs() != 0) {
0350 csctf_.stSPslot.push_back(stat->slot());
0351 csctf_.stL1A_BXN.push_back(stat->BXN());
0352 csctf_.stTrkCounter.push_back((const_cast<L1CSCSPStatusDigi*>(&(*stat)))->track_counter());
0353 csctf_.stOrbCounter.push_back((const_cast<L1CSCSPStatusDigi*>(&(*stat)))->orbit_counter());
0354
0355 nStat++;
0356 }
0357 }
0358
0359 csctf_.nsp = nStat;
0360 }
0361
0362
0363
0364 void L1Analysis::L1AnalysisCSCTF::SetDTStubs(const edm::Handle<CSCTriggerContainer<csctf::TrackStub> > dtStubs) {
0365
0366 std::vector<csctf::TrackStub> vstubs = dtStubs->get();
0367
0368 for (std::vector<csctf::TrackStub>::const_iterator stub = vstubs.begin(); stub != vstubs.end(); stub++) {
0369 csctf_.dtBXN.push_back(stub->BX());
0370 csctf_.dtFLAG.push_back(stub->getStrip());
0371 csctf_.dtCAL.push_back(stub->getKeyWG());
0372
0373 csctf_.dtSector.push_back(6 * (stub->endcap() - 1) + stub->sector());
0374 csctf_.dtSubSector.push_back(stub->subsector());
0375
0376 csctf_.dtBX0.push_back(stub->getBX0());
0377 csctf_.dtPhiBend.push_back(stub->getBend());
0378 csctf_.dtPhiPacked.push_back(stub->phiPacked());
0379 csctf_.dtQuality.push_back(stub->getQuality());
0380 }
0381
0382 csctf_.dtSize = vstubs.size();
0383 }