Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-07-22 22:47:10

0001 #include "L1Trigger/CSCTriggerPrimitives/interface/LCTQualityAssignment.h"
0002 
0003 LCTQualityAssignment::LCTQualityAssignment(unsigned endcap,
0004                                            unsigned station,
0005                                            unsigned sector,
0006                                            unsigned subsector,
0007                                            unsigned chamber,
0008                                            const edm::ParameterSet& conf)
0009     : CSCBaseboard(endcap, station, sector, subsector, chamber, conf) {
0010   // at least one integrated local trigger is running
0011   runILT_ = (isME11_ and runME11ILT_) or (isME21_ and runME21ILT_);
0012 }
0013 
0014 unsigned LCTQualityAssignment::findQuality(const CSCALCTDigi& aLCT, const CSCCLCTDigi& cLCT) const {
0015   // ALCT-CLCT matching without a cluster and ILT off
0016   if (run3_ and !runILT_) {
0017     return findQualityRun3(aLCT, cLCT);
0018   }
0019   // ALCT-CLCT matching without a cluster and ILT on
0020   // preferred for Run-3
0021   else if (runCCLUT_ and runILT_) {
0022     return findQualityGEMv2(aLCT, cLCT, GEMInternalCluster());
0023   }
0024   // ALCT-CLCT matching without a cluster with CCLUT off and ILT on
0025   // case when interfacing the GEM-CSC trigger with Run-2 EMTF
0026   // not intended for Run-3. temporary intermediate case for CMSSW_12
0027   else if (!runCCLUT_ and runILT_) {
0028     return findQualityGEMv1(aLCT, cLCT, GEMInternalCluster());
0029   }
0030   // ALCT-CLCT matching without a cluster with CCLUT off and ILT off
0031   // regular Run-1 and Run-2 case
0032   else {
0033     return findQualityRun2(aLCT, cLCT);
0034   }
0035 }
0036 unsigned LCTQualityAssignment::findQuality(const CSCALCTDigi& aLCT,
0037                                            const CSCCLCTDigi& cLCT,
0038                                            const GEMInternalCluster& cl) const {
0039   // preferred for Run-3
0040   if (runCCLUT_) {
0041     return findQualityGEMv2(aLCT, cLCT, cl);
0042   }
0043   // not intended for Run-3. temporary intermediate case for CMSSW_12
0044   else {
0045     return findQualityGEMv1(aLCT, cLCT, cl);
0046   }
0047 }
0048 
0049 unsigned LCTQualityAssignment::findQuality(const CSCALCTDigi& aLCT, const GEMInternalCluster& cl) const {
0050   // preferred for Run-3
0051   if (runCCLUT_) {
0052     return findQualityGEMv2(aLCT, CSCCLCTDigi(), cl);
0053   }
0054   // not intended for Run-3. temporary intermediate case for CMSSW_12
0055   else {
0056     return static_cast<unsigned>(LCTQualityAssignment::LCT_QualityRun2::HQ_PATTERN_10);
0057   }
0058 }
0059 
0060 unsigned LCTQualityAssignment::findQuality(const CSCCLCTDigi& cLCT, const GEMInternalCluster& cl) const {
0061   // preferred for Run-3
0062   if (runCCLUT_) {
0063     return findQualityGEMv2(CSCALCTDigi(), cLCT, cl);
0064   }
0065   // not intended for Run-3. temporary intermediate case for CMSSW_12
0066   else {
0067     return findQualityGEMv1(cLCT, cl);
0068   }
0069 }
0070 
0071 // 4-bit LCT quality number.
0072 unsigned LCTQualityAssignment::findQualityRun2(const CSCALCTDigi& aLCT, const CSCCLCTDigi& cLCT) const {
0073   LCT_QualityRun2 qual = LCT_QualityRun2::INVALID;
0074 
0075   // Either ALCT or CLCT is invalid
0076   if (!(aLCT.isValid()) || !(cLCT.isValid())) {
0077     // No CLCT
0078     if (aLCT.isValid() && !(cLCT.isValid()))
0079       qual = LCT_QualityRun2::NO_CLCT;
0080 
0081     // No ALCT
0082     else if (!(aLCT.isValid()) && cLCT.isValid())
0083       qual = LCT_QualityRun2::NO_ALCT;
0084 
0085     // No ALCT and no CLCT
0086     else
0087       qual = LCT_QualityRun2::INVALID;
0088   }
0089   // Both ALCT and CLCT are valid
0090   else {
0091     const int pattern(cLCT.getPattern());
0092 
0093     // Layer-trigger in CLCT
0094     if (pattern == 1)
0095       qual = LCT_QualityRun2::CLCT_LAYER_TRIGGER;
0096 
0097     // Multi-layer pattern in CLCT
0098     else {
0099       // ALCT quality is the number of layers hit minus 3.
0100       const bool a4(aLCT.getQuality() >= 1);
0101 
0102       // CLCT quality is the number of layers hit.
0103       const bool c4(cLCT.getQuality() >= 4);
0104 
0105       // quality = 4; "reserved for low-quality muons in future"
0106 
0107       // marginal anode and cathode
0108       if (!a4 && !c4)
0109         qual = LCT_QualityRun2::MARGINAL_ANODE_CATHODE;
0110 
0111       // HQ anode, but marginal cathode
0112       else if (a4 && !c4)
0113         qual = LCT_QualityRun2::HQ_ANODE_MARGINAL_CATHODE;
0114 
0115       // HQ cathode, but marginal anode
0116       else if (!a4 && c4)
0117         qual = LCT_QualityRun2::HQ_CATHODE_MARGINAL_ANODE;
0118 
0119       // HQ muon, but accelerator ALCT
0120       else if (a4 && c4) {
0121         if (aLCT.getAccelerator())
0122           qual = LCT_QualityRun2::HQ_ACCEL_ALCT;
0123 
0124         else {
0125           // quality =  9; "reserved for HQ muons with future patterns
0126           // quality = 10; "reserved for HQ muons with future patterns
0127 
0128           // High quality muons are determined by their CLCT pattern
0129           if (pattern == 2 || pattern == 3)
0130             qual = LCT_QualityRun2::HQ_PATTERN_2_3;
0131 
0132           else if (pattern == 4 || pattern == 5)
0133             qual = LCT_QualityRun2::HQ_PATTERN_4_5;
0134 
0135           else if (pattern == 6 || pattern == 7)
0136             qual = LCT_QualityRun2::HQ_PATTERN_6_7;
0137 
0138           else if (pattern == 8 || pattern == 9)
0139             qual = LCT_QualityRun2::HQ_PATTERN_8_9;
0140 
0141           else if (pattern == 10)
0142             qual = LCT_QualityRun2::HQ_PATTERN_10;
0143 
0144           else {
0145             edm::LogWarning("LCTQualityAssignment") << "findQualityRun2: Unexpected CLCT pattern id = " << pattern;
0146             qual = LCT_QualityRun2::INVALID;
0147           }
0148         }
0149       }
0150     }
0151   }
0152   return static_cast<unsigned>(qual);
0153 }
0154 
0155 // 2-bit LCT quality number for Run-3
0156 unsigned LCTQualityAssignment::findQualityRun3(const CSCALCTDigi& aLCT, const CSCCLCTDigi& cLCT) const {
0157   LCT_QualityRun3 qual = LCT_QualityRun3::INVALID;
0158 
0159   // Run-3 definition
0160   if (!(aLCT.isValid()) and !(cLCT.isValid())) {
0161     qual = LCT_QualityRun3::INVALID;
0162   }
0163   // use number of layers on each as indicator
0164   else {
0165     const bool a4 = (aLCT.getQuality() == 1);
0166     const bool a5 = (aLCT.getQuality() == 2);
0167     const bool a6 = (aLCT.getQuality() == 3);
0168 
0169     const bool c4 = (cLCT.getQuality() == 4);
0170     const bool c5 = (cLCT.getQuality() == 5);
0171     const bool c6 = (cLCT.getQuality() == 6);
0172     if (a6 or c6)
0173       qual = LCT_QualityRun3::HighQ;
0174     else if (a5 or c5)
0175       qual = LCT_QualityRun3::MedQ;
0176     else if (a4 or c4)
0177       qual = LCT_QualityRun3::LowQ;
0178     else
0179       qual = LCT_QualityRun3::INVALID;
0180   }
0181   return static_cast<unsigned>(qual);
0182 }
0183 
0184 unsigned LCTQualityAssignment::findQualityGEMv1(const CSCCLCTDigi& cLCT, const GEMInternalCluster& cl) const {
0185   LCT_QualityRun2 qual = LCT_QualityRun2::INVALID;
0186 
0187   if (!cl.isCoincidence() or !cLCT.isValid())
0188     return static_cast<unsigned>(qual);
0189 
0190   const int pattern(cLCT.getPattern());
0191 
0192   // High quality muons are determined by their CLCT pattern
0193   if (pattern == 2 || pattern == 3)
0194     qual = LCT_QualityRun2::HQ_PATTERN_2_3;
0195 
0196   else if (pattern == 4 || pattern == 5)
0197     qual = LCT_QualityRun2::HQ_PATTERN_4_5;
0198 
0199   else if (pattern == 6 || pattern == 7)
0200     qual = LCT_QualityRun2::HQ_PATTERN_6_7;
0201 
0202   else if (pattern == 8 || pattern == 9)
0203     qual = LCT_QualityRun2::HQ_PATTERN_8_9;
0204 
0205   else if (pattern == 10)
0206     qual = LCT_QualityRun2::HQ_PATTERN_10;
0207 
0208   else {
0209     edm::LogWarning("CSCGEMMotherboard") << "findQualityGEMv1: Unexpected CLCT pattern id = " << pattern;
0210     qual = LCT_QualityRun2::INVALID;
0211   }
0212 
0213   return static_cast<unsigned>(qual);
0214 }
0215 
0216 unsigned LCTQualityAssignment::findQualityGEMv1(const CSCALCTDigi& aLCT,
0217                                                 const CSCCLCTDigi& cLCT,
0218                                                 const GEMInternalCluster& cl) const {
0219   LCT_QualityRun2 qual = LCT_QualityRun2::INVALID;
0220 
0221   int gemlayers = 0;
0222   if (cl.isValid())
0223     gemlayers = 1;
0224   if (cl.isCoincidence())
0225     gemlayers = 2;
0226 
0227   // Either ALCT or CLCT is invalid
0228   if (!(aLCT.isValid()) || !(cLCT.isValid())) {
0229     // No CLCT
0230     if (aLCT.isValid() && !(cLCT.isValid()))
0231       qual = LCT_QualityRun2::NO_CLCT;
0232 
0233     // No ALCT
0234     else if (!(aLCT.isValid()) && cLCT.isValid())
0235       qual = LCT_QualityRun2::NO_ALCT;
0236 
0237     // No ALCT and no CLCT
0238     else
0239       qual = LCT_QualityRun2::INVALID;
0240   }
0241   // Both ALCT and CLCT are valid
0242   else {
0243     const int pattern(cLCT.getPattern());
0244 
0245     // Layer-trigger in CLCT
0246     if (pattern == 1)
0247       qual = LCT_QualityRun2::CLCT_LAYER_TRIGGER;
0248 
0249     // Multi-layer pattern in CLCT
0250     else {
0251       // ALCT quality is the number of layers hit minus 3.
0252       bool a4 = false;
0253 
0254       // Case of ME11 with GEMs: require 4 layers for ALCT
0255       if (isME11_)
0256         a4 = aLCT.getQuality() >= 1;
0257 
0258       // Case of ME21 with GEMs: require 4 layers for ALCT+GEM
0259       if (isME21_)
0260         a4 = aLCT.getQuality() + gemlayers >= 1;
0261 
0262       // CLCT quality is the number of layers hit.
0263       const bool c4((cLCT.getQuality() >= 4) or (cLCT.getQuality() >= 3 and gemlayers >= 1));
0264 
0265       // quality = 4; "reserved for low-quality muons in future"
0266 
0267       // marginal anode and cathode
0268       if (!a4 && !c4)
0269         qual = LCT_QualityRun2::MARGINAL_ANODE_CATHODE;
0270 
0271       // HQ anode, but marginal cathode
0272       else if (a4 && !c4)
0273         qual = LCT_QualityRun2::HQ_ANODE_MARGINAL_CATHODE;
0274 
0275       // HQ cathode, but marginal anode
0276       else if (!a4 && c4)
0277         qual = LCT_QualityRun2::HQ_CATHODE_MARGINAL_ANODE;
0278 
0279       // HQ muon, but accelerator ALCT
0280       else if (a4 && c4) {
0281         if (aLCT.getAccelerator())
0282           qual = LCT_QualityRun2::HQ_ACCEL_ALCT;
0283 
0284         else {
0285           // quality =  9; "reserved for HQ muons with future patterns
0286           // quality = 10; "reserved for HQ muons with future patterns
0287 
0288           // High quality muons are determined by their CLCT pattern
0289           if (pattern == 2 || pattern == 3)
0290             qual = LCT_QualityRun2::HQ_PATTERN_2_3;
0291 
0292           else if (pattern == 4 || pattern == 5)
0293             qual = LCT_QualityRun2::HQ_PATTERN_4_5;
0294 
0295           else if (pattern == 6 || pattern == 7)
0296             qual = LCT_QualityRun2::HQ_PATTERN_6_7;
0297 
0298           else if (pattern == 8 || pattern == 9)
0299             qual = LCT_QualityRun2::HQ_PATTERN_8_9;
0300 
0301           else if (pattern == 10)
0302             qual = LCT_QualityRun2::HQ_PATTERN_10;
0303 
0304           else {
0305             edm::LogWarning("CSCGEMMotherboard") << "findQualityGEMv1: Unexpected CLCT pattern id = " << pattern;
0306             qual = LCT_QualityRun2::INVALID;
0307           }
0308         }
0309       }
0310     }
0311   }
0312   return static_cast<unsigned>(qual);
0313 }
0314 
0315 unsigned LCTQualityAssignment::findQualityGEMv2(const CSCALCTDigi& aLCT,
0316                                                 const CSCCLCTDigi& cLCT,
0317                                                 const GEMInternalCluster& cl) const {
0318   LCT_QualityRun3GEM qual = LCT_QualityRun3GEM::INVALID;
0319 
0320   const bool aValid(aLCT.isValid());
0321   const bool cValid(cLCT.isValid());
0322   const bool gValid(cl.isValid());
0323   const bool ggValid(cl.isValid() and cl.isCoincidence());
0324 
0325   // ALCT-CLCT-2GEM
0326   if (aValid and cValid and ggValid) {
0327     if (assignGEMCSCBending_)
0328       qual = LCT_QualityRun3GEM::ALCT_CLCT_2GEM_GEMCSCBend;
0329     else
0330       qual = LCT_QualityRun3GEM::ALCT_CLCT_2GEM_CSCBend;
0331   }
0332 
0333   // ALCT-CLCT-1GEM
0334   else if (aValid and cValid and gValid) {
0335     if (assignGEMCSCBending_)
0336       qual = LCT_QualityRun3GEM::ALCT_CLCT_1GEM_GEMCSCBend;
0337     else
0338       qual = LCT_QualityRun3GEM::ALCT_CLCT_1GEM_CSCBend;
0339   }
0340 
0341   // ALCT-CLCT
0342   else if (aValid and cValid and !gValid and !ggValid) {
0343     qual = LCT_QualityRun3GEM::ALCT_CLCT;
0344   }
0345 
0346   // CLCT-2GEM
0347   else if (!aValid and cValid and ggValid) {
0348     qual = LCT_QualityRun3GEM::CLCT_2GEM;
0349   }
0350 
0351   // ALCT-2GEM
0352   else if (!cValid and aValid and ggValid) {
0353     qual = LCT_QualityRun3GEM::ALCT_2GEM;
0354   }
0355 
0356   // at this point we have exhausted all possibilities
0357   // only remaing option is an invalid LCT
0358   else
0359     qual = LCT_QualityRun3GEM::INVALID;
0360 
0361   return static_cast<unsigned>(qual);
0362 }