Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:37

0001 #include "L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeAnodeLCTProcessor.h"
0002 
0003 CSCUpgradeAnodeLCTProcessor::CSCUpgradeAnodeLCTProcessor(unsigned endcap,
0004                                                          unsigned station,
0005                                                          unsigned sector,
0006                                                          unsigned subsector,
0007                                                          unsigned chamber,
0008                                                          CSCBaseboard::Parameters& conf)
0009     : CSCAnodeLCTProcessor(endcap, station, sector, subsector, chamber, conf) {
0010   if (!runPhase2_)
0011     edm::LogError("CSCUpgradeAnodeLCTProcessor|ConfigError")
0012         << "+++ Upgrade CSCUpgradeAnodeLCTProcessor constructed while runPhase2_ is not set! +++\n";
0013 
0014   if (!enableAlctPhase2_)
0015     edm::LogError("CSCUpgradeAnodeLCTProcessor|ConfigError")
0016         << "+++ Upgrade CSCUpgradeAnodeLCTProcessor constructed while enableAlctPhase2_ is not set! +++\n";
0017 }
0018 
0019 void CSCUpgradeAnodeLCTProcessor::ghostCancellationLogicOneWire(const int key_wire, int* ghost_cleared) {
0020   for (int i_pattern = 0; i_pattern < 2; i_pattern++) {
0021     ghost_cleared[i_pattern] = 0;
0022     if (key_wire == 0)
0023       continue;
0024 
0025     // Non-empty wire group.
0026     int qual_this = quality[key_wire][i_pattern];
0027     if (qual_this > 0) {
0028       if (runPhase2_ and runME21ILT_ and isME21_)
0029         qual_this = (qual_this & 0x03);
0030       // Previous wire.
0031       int dt = -1;
0032       for (auto& p : lct_list) {
0033         if (not(p.isValid() and p.getKeyWG() == key_wire - 1 and 1 - p.getAccelerator() == i_pattern))
0034           continue;
0035 
0036         bool ghost_cleared_prev = false;
0037         int qual_prev = p.getQuality();
0038         int first_bx_prev = p.getBX();
0039         if (infoV > 1)
0040           LogTrace("CSCAnodeLCTProcessor")
0041               << "ghost concellation logic " << ((i_pattern == 0) ? "Accelerator" : "Collision") << " key_wire "
0042               << key_wire << " quality " << qual_this << " bx " << first_bx[key_wire] << " previous key_wire "
0043               << key_wire - 1 << " quality " << qual_prev << " bx " << first_bx[key_wire - 1];
0044 
0045         //int dt = first_bx[key_wire] - first_bx[key_wire-1];
0046         if (use_corrected_bx)
0047           dt = first_bx_corrected[key_wire] - first_bx_prev;
0048         else
0049           dt = first_bx[key_wire] - first_bx_prev;
0050         // hack to run the Phase-II ME2/1, ME3/1 and ME4/1 ILT
0051         if (runPhase2_ and runME21ILT_ and isME21_)
0052           qual_prev = (qual_prev & 0x03);
0053 
0054         // Cancel this wire
0055         //   1) If the candidate at the previous wire is at the same bx
0056         //      clock and has better quality (or equal? quality - this has
0057         //      been implemented only in 2004).
0058         //   2) If the candidate at the previous wire is up to 4 clocks
0059         //      earlier, regardless of quality.
0060         if (dt == 0) {
0061           if (qual_prev > qual_this)
0062             ghost_cleared[i_pattern] = 1;
0063         } else if (dt > 0 && dt <= ghost_cancellation_bx_depth) {
0064           if ((!ghost_cancellation_side_quality) || (qual_prev > qual_this))
0065             ghost_cleared[i_pattern] = 1;
0066         } else if (dt < 0 && dt * (-1) <= ghost_cancellation_bx_depth) {
0067           if ((!ghost_cancellation_side_quality) || (qual_prev < qual_this))
0068             ghost_cleared_prev = true;
0069         }
0070 
0071         if (ghost_cleared[i_pattern] == 1) {
0072           if (infoV > 1)
0073             LogTrace("CSCUpgradeAnodeLCTProcessor")
0074                 << ((i_pattern == 0) ? "Accelerator" : "Collision") << " pattern ghost cancelled on key_wire "
0075                 << key_wire << " q=" << qual_this << "  by wire " << key_wire - 1 << " q=" << qual_prev
0076                 << "  dt=" << dt;
0077           //cancellation for key_wire is done when ALCT is created and pushed to lct_list
0078         }
0079         if (ghost_cleared_prev) {
0080           if (infoV > 1)
0081             LogTrace("CSCAnodeLCTProcessor")
0082                 << ((i_pattern == 0) ? "Accelerator" : "Collision") << " pattern ghost cancelled on key_wire "
0083                 << key_wire - 1 << " q=" << qual_prev << "  by wire " << key_wire << " q=" << qual_this;
0084           p.setValid(0);  //clean prev ALCT
0085         }
0086       }
0087     }
0088   }
0089 }
0090 
0091 int CSCUpgradeAnodeLCTProcessor::getTempALCTQuality(int temp_quality) const {
0092   // Quality definition changed on 22 June 2007: it no longer depends
0093   // on pattern_thresh.
0094   int Q;
0095   // hack to run the Phase-II GE2/1-ME2/1 with 3-layer ALCTs
0096   if (temp_quality == 3 and runPhase2_ and runME21ILT_ and isME21_)
0097     Q = 1;
0098   else if (temp_quality > 3)
0099     Q = temp_quality - 3;
0100   else
0101     Q = 0;  // quality code 0 is valid!
0102 
0103   return Q;
0104 }