CMS 3D CMS Logo

Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes

CSCCathodeLCTProcessor Class Reference

#include <CSCCathodeLCTProcessor.h>

List of all members.

Public Types

enum  { MAX_CLCT_BINS = 16 }
enum  { NUM_PATTERN_STRIPS = 26 }
enum  { NUM_PATTERN_HALFSTRIPS = 42 }
enum  { MAX_CFEBS = 5 }
enum  CLCT_INDICES {
  CLCT_PATTERN, CLCT_BEND, CLCT_STRIP, CLCT_BX,
  CLCT_STRIP_TYPE, CLCT_QUALITY, CLCT_CFEB
}

Public Member Functions

void clear ()
 CSCCathodeLCTProcessor (unsigned endcap, unsigned station, unsigned sector, unsigned subsector, unsigned chamber, const edm::ParameterSet &conf, const edm::ParameterSet &comm)
 CSCCathodeLCTProcessor ()
std::vector< CSCCLCTDigigetCLCTs ()
void getDigis (const CSCComparatorDigiCollection *compdc, const CSCDetId &id)
bool getDigis (const CSCComparatorDigiCollection *compdc)
std::vector< int > preTriggerBXs () const
std::vector< CSCCLCTDigireadoutCLCTs ()
std::vector< CSCCLCTDigirun (const CSCComparatorDigiCollection *compdc)
void run (const std::vector< int > halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const std::vector< int > distrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
void setConfigParameters (const CSCDBL1TPParameters *conf)

Static Public Member Functions

static void distripStagger (int stag_triad[CSCConstants::MAX_NUM_STRIPS], int stag_time[CSCConstants::MAX_NUM_STRIPS], int stag_digi[CSCConstants::MAX_NUM_STRIPS], int i_distrip, bool debug=false)

Public Attributes

CSCCLCTDigi bestCLCT [MAX_CLCT_BINS]
CSCCLCTDigi secondCLCT [MAX_CLCT_BINS]

Static Public Attributes

static const int pattern [CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07][NUM_PATTERN_STRIPS+1]
static const int pattern2007 [CSCConstants::NUM_CLCT_PATTERNS][NUM_PATTERN_HALFSTRIPS+1]
static const int pattern2007_offset [NUM_PATTERN_HALFSTRIPS]
static const int pre_hit_pattern [2][NUM_PATTERN_STRIPS]

Private Member Functions

void checkConfigParameters ()
void dumpConfigParams () const
void dumpDigis (const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips) const
std::vector< CSCCLCTDigifindLCTs (const std::vector< int > halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
std::vector< CSCCLCTDigifindLCTs (const std::vector< int > halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const std::vector< int > distrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
std::vector< CSCCLCTDigifindLCTs (const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], int stripType)
int findNumLayersHit (std::vector< int > stripsHit[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
void getKeyStripData (const unsigned int h_pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const unsigned int d_pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], int keystrip_data[2][7], const int first_bx)
void getKeyStripData (const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], int keystrip_data[CSCConstants::NUM_HALF_STRIPS][7], int nStrips, int first_bx, int &best_strip, int stripType)
void getPattern (int pattern_num, int strip_value[NUM_PATTERN_STRIPS], int bx_time, int &quality, int &bend)
void getPattern (unsigned int pattern_num, const int strip_value[NUM_PATTERN_STRIPS], unsigned int &quality, unsigned int &bend)
bool hitIsGood (int hitTime, int BX)
void latchLCTs (const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], int keyStrip[MAX_CFEBS], unsigned int nhits[MAX_CFEBS], const int stripType, const int nStrips, const int bx_time)
void markBusyKeys (const int best_hstrip, const int best_patid, int quality[CSCConstants::NUM_HALF_STRIPS])
bool preTrigger (const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int start_bx, int &first_bx)
bool preTrigger (const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips, const int start_bx, int &first_bx)
bool preTrigger (const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips, int &first_bx)
bool preTrigLookUp (const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips, const unsigned int bx_time)
void printPatterns ()
void priorityEncode (const int h_keyStrip[MAX_CFEBS], const unsigned int h_nhits[MAX_CFEBS], const int d_keyStrip[MAX_CFEBS], const unsigned int d_nhits[MAX_CFEBS], int keystrip_data[2][7])
bool ptnFinding (const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int nStrips, const unsigned int bx_time)
void pulseExtension (const std::vector< int > time[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int nStrips, unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
void readComparatorDigis (std::vector< int > halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
void readComparatorDigis (std::vector< int >halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], std::vector< int > distrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
void setDefaultConfigParameters ()
void testDistripStagger ()
void testLCTs ()
void testPatterns ()

Private Attributes

unsigned int best_pid [CSCConstants::NUM_HALF_STRIPS]
static const unsigned int def_drift_delay = 2
static const unsigned int def_fifo_pretrig = 7
static const unsigned int def_min_separation = 10
std::vector< CSCComparatorDigidigiV [CSCConstants::NUM_LAYERS]
unsigned int drift_delay
unsigned int fifo_pretrig
unsigned int fifo_tbins
unsigned int hit_persist
int infoV
bool isMTCC
bool isTMB07
unsigned int min_separation
unsigned int nhits [CSCConstants::NUM_HALF_STRIPS]
unsigned int nplanes_hit_pattern
unsigned int nplanes_hit_pretrig
int numStrips
unsigned int pid_thresh_pretrig
int stagger [CSCConstants::NUM_LAYERS]
const unsigned theEndcap
std::vector< int > thePreTriggerBXs
const unsigned theSector
const unsigned theStation
const unsigned theSubsector
const unsigned theTrigChamber

Static Private Attributes

static const int cfeb_strips [2] = { 8, 32}
static const unsigned int def_fifo_tbins = 12
static const unsigned int def_hit_persist = 6
static const unsigned int def_nplanes_hit_pattern = 4
static const unsigned int def_nplanes_hit_pretrig = 2
static const unsigned int def_pid_thresh_pretrig = 2

Detailed Description

This class simulates the functionality of the cathode LCT card. It is run by the MotherBoard and returns up to two CathodeLCTs. It can be run either in a test mode, where it is passed arrays of halfstrip and distrip times, or in normal mode where it determines the time and comparator information from the comparator digis.

The CathodeLCTs come in distrip and halfstrip flavors; they are sorted (from best to worst) as follows: 6/6H, 5/6H, 6/6D, 4/6H, 5/6D, 4/6D.

Date:
May 2001 Removed the card boundaries. Changed the Pretrigger to emulate the hardware electronic logic. Also changed the keylayer to be the 4th layer in a chamber instead of the 3rd layer from the interaction region. The code is a more realistic simulation of hardware LCT logic now. -Jason Mumford.
Author:
Benn Tannenbaum UCLA 13 July 1999 benn@physics.ucla.edu Numerous later improvements by Jason Mumford and Slava Valuev (see cvs in ORCA). Porting from ORCA by S. Valuev (Slava.Valuev@cern.ch), May 2006.
Date:
2010/08/04 10:21:23
Revision:
1.25

Definition at line 38 of file CSCCathodeLCTProcessor.h.


Member Enumeration Documentation

anonymous enum

Maximum number of time bins.

Enumerator:
MAX_CLCT_BINS 

Definition at line 70 of file CSCCathodeLCTProcessor.h.

{MAX_CLCT_BINS = 16};
anonymous enum

Pre-defined patterns.

Enumerator:
NUM_PATTERN_STRIPS 

Definition at line 92 of file CSCCathodeLCTProcessor.h.

anonymous enum
Enumerator:
NUM_PATTERN_HALFSTRIPS 

Definition at line 96 of file CSCCathodeLCTProcessor.h.

anonymous enum

Maximum number of cathode front-end boards (move to CSCConstants?).

Enumerator:
MAX_CFEBS 

Definition at line 101 of file CSCCathodeLCTProcessor.h.

{MAX_CFEBS = 5};
Enumerator:
CLCT_PATTERN 
CLCT_BEND 
CLCT_STRIP 
CLCT_BX 
CLCT_STRIP_TYPE 
CLCT_QUALITY 
CLCT_CFEB 

Definition at line 105 of file CSCCathodeLCTProcessor.h.


Constructor & Destructor Documentation

CSCCathodeLCTProcessor::CSCCathodeLCTProcessor ( unsigned  endcap,
unsigned  station,
unsigned  sector,
unsigned  subsector,
unsigned  chamber,
const edm::ParameterSet conf,
const edm::ParameterSet comm 
)

Normal constructor.

Definition at line 235 of file CSCCathodeLCTProcessor.cc.

References checkConfigParameters(), drift_delay, dumpConfigParams(), fifo_pretrig, fifo_tbins, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hit_persist, infoV, isMTCC, isTMB07, min_separation, nplanes_hit_pattern, nplanes_hit_pretrig, CSCConstants::NUM_LAYERS, numStrips, pid_thresh_pretrig, and stagger.

                                                                            :
                     theEndcap(endcap), theStation(station), theSector(sector),
                     theSubsector(subsector), theTrigChamber(chamber) {
  static bool config_dumped = false;

  // CLCT configuration parameters.
  fifo_tbins   = conf.getParameter<unsigned int>("clctFifoTbins");
  hit_persist  = conf.getParameter<unsigned int>("clctHitPersist");
  drift_delay  = conf.getParameter<unsigned int>("clctDriftDelay");
  nplanes_hit_pretrig =
    conf.getParameter<unsigned int>("clctNplanesHitPretrig");
  nplanes_hit_pattern =
    conf.getParameter<unsigned int>("clctNplanesHitPattern");

  // Not used yet.
  fifo_pretrig = conf.getParameter<unsigned int>("clctFifoPretrig");

  // Defines pre-2007 version of the CLCT algorithm used in test beams and
  // MTCC.
  isMTCC       = comm.getParameter<bool>("isMTCC");

  // TMB07 firmware used since 2007: switch and config. parameters.
  isTMB07      = comm.getParameter<bool>("isTMB07");
  if (isTMB07) {
    pid_thresh_pretrig =
      conf.getParameter<unsigned int>("clctPidThreshPretrig");
    min_separation    =
      conf.getParameter<unsigned int>("clctMinSeparation");
  }

  // Verbosity level, set to 0 (no print) by default.
  infoV        = conf.getUntrackedParameter<int>("verbosity", 0);

  // Check and print configuration parameters.
  checkConfigParameters();
  if (infoV > 0 && !config_dumped) {
    dumpConfigParams();
    config_dumped = true;
  }

  numStrips = 0; // Will be set later.
  // Provisional, but should be OK for all stations except ME1.
  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
    if ((i_layer+1)%2 == 0) stagger[i_layer] = 0;
    else                    stagger[i_layer] = 1;
  }

  // engage in various and sundry tests, but only for a single chamber.
  //if (theStation == 2 && theSector == 1 &&
  //    CSCTriggerNumbering::ringFromTriggerLabels(theStation, theTrigChamber) == 1 && 
  //    CSCTriggerNumbering::chamberFromTriggerLabels(theSector, theSubsector,
  //                                                theStation, theTrigChamber) == 1) {
    // test all possible patterns in our uber pattern. 
    // testPatterns();
    // this tests to make sure what goes into an LCT is what comes out
    // testLCTs();
    // print out all the patterns to make sure we've got what we think
    // we've got.
    // printPatterns();
  //  }
}
CSCCathodeLCTProcessor::CSCCathodeLCTProcessor ( )

Default constructor. Used for testing.

Definition at line 303 of file CSCCathodeLCTProcessor.cc.

References checkConfigParameters(), dumpConfigParams(), infoV, isMTCC, isTMB07, CSCConstants::MAX_NUM_STRIPS, CSCConstants::NUM_LAYERS, numStrips, setDefaultConfigParameters(), and stagger.

                                               :
                     theEndcap(1), theStation(1), theSector(1),
                     theSubsector(1), theTrigChamber(1) {
  // constructor for debugging.
  static bool config_dumped = false;

  // CLCT configuration parameters.
  setDefaultConfigParameters();
  infoV =  2;
  isMTCC  = false;
  isTMB07 = true;

  // Check and print configuration parameters.
  checkConfigParameters();
  if (!config_dumped) {
    dumpConfigParams();
    config_dumped = true;
  }

  numStrips = CSCConstants::MAX_NUM_STRIPS;
  // Should be OK for all stations except ME1.
  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
    if ((i_layer+1)%2 == 0) stagger[i_layer] = 0;
    else                    stagger[i_layer] = 1;
  }
}

Member Function Documentation

void CSCCathodeLCTProcessor::checkConfigParameters ( ) [private]

Make sure that the parameter values are within the allowed range.

Definition at line 374 of file CSCCathodeLCTProcessor.cc.

References def_drift_delay, def_fifo_pretrig, def_fifo_tbins, def_hit_persist, def_min_separation, def_nplanes_hit_pattern, def_nplanes_hit_pretrig, def_pid_thresh_pretrig, drift_delay, fifo_pretrig, fifo_tbins, hit_persist, infoV, isTMB07, min_separation, nplanes_hit_pattern, nplanes_hit_pretrig, CSCConstants::NUM_HALF_STRIPS, and pid_thresh_pretrig.

Referenced by CSCCathodeLCTProcessor(), and setConfigParameters().

                                                   {
  // Make sure that the parameter values are within the allowed range.

  // Max expected values.
  static const unsigned int max_fifo_tbins   = 1 << 5;
  static const unsigned int max_fifo_pretrig = 1 << 5;
  static const unsigned int max_hit_persist  = 1 << 4;
  static const unsigned int max_drift_delay  = 1 << 2;
  static const unsigned int max_nplanes_hit_pretrig = 1 << 3;
  static const unsigned int max_nplanes_hit_pattern = 1 << 3;
  static const unsigned int max_pid_thresh_pretrig  = 1 << 4;
  static const unsigned int max_min_separation = CSCConstants::NUM_HALF_STRIPS;

  // Checks.
  if (fifo_tbins >= max_fifo_tbins) {
    if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
      << "+++ Value of fifo_tbins, " << fifo_tbins
      << ", exceeds max allowed, " << max_fifo_tbins-1 << " +++\n"
      << "+++ Try to proceed with the default value, fifo_tbins="
      << def_fifo_tbins << " +++\n";
    fifo_tbins = def_fifo_tbins;
  }
  if (fifo_pretrig >= max_fifo_pretrig) {
    if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
      << "+++ Value of fifo_pretrig, " << fifo_pretrig
      << ", exceeds max allowed, " << max_fifo_pretrig-1 << " +++\n"
      << "+++ Try to proceed with the default value, fifo_pretrig="
      << def_fifo_pretrig << " +++\n";
    fifo_pretrig = def_fifo_pretrig;
  }
  if (hit_persist >= max_hit_persist) {
    if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
      << "+++ Value of hit_persist, " << hit_persist
      << ", exceeds max allowed, " << max_hit_persist-1 << " +++\n"
      << "+++ Try to proceed with the default value, hit_persist="
      << def_hit_persist << " +++\n";
    hit_persist = def_hit_persist;
  }
  if (drift_delay >= max_drift_delay) {
    if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
      << "+++ Value of drift_delay, " << drift_delay
      << ", exceeds max allowed, " << max_drift_delay-1 << " +++\n"
      << "+++ Try to proceed with the default value, drift_delay="
      << def_drift_delay << " +++\n";
    drift_delay = def_drift_delay;
  }
  if (nplanes_hit_pretrig >= max_nplanes_hit_pretrig) {
    if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
      << "+++ Value of nplanes_hit_pretrig, " << nplanes_hit_pretrig
      << ", exceeds max allowed, " << max_nplanes_hit_pretrig-1 << " +++\n"
      << "+++ Try to proceed with the default value, nplanes_hit_pretrig="
      << def_nplanes_hit_pretrig << " +++\n";
    nplanes_hit_pretrig = def_nplanes_hit_pretrig;
  }
  if (nplanes_hit_pattern >= max_nplanes_hit_pattern) {
    if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
      << "+++ Value of nplanes_hit_pattern, " << nplanes_hit_pattern
      << ", exceeds max allowed, " << max_nplanes_hit_pattern-1 << " +++\n"
      << "+++ Try to proceed with the default value, nplanes_hit_pattern="
      << def_nplanes_hit_pattern << " +++\n";
    nplanes_hit_pattern = def_nplanes_hit_pattern;
  }

  if (isTMB07) {
    if (pid_thresh_pretrig >= max_pid_thresh_pretrig) {
      if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
        << "+++ Value of pid_thresh_pretrig, " << pid_thresh_pretrig
        << ", exceeds max allowed, " << max_pid_thresh_pretrig-1 << " +++\n"
        << "+++ Try to proceed with the default value, pid_thresh_pretrig="
        << def_pid_thresh_pretrig << " +++\n";
      pid_thresh_pretrig = def_pid_thresh_pretrig;
    }
    if (min_separation >= max_min_separation) {
      if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
        << "+++ Value of min_separation, " << min_separation
        << ", exceeds max allowed, " << max_min_separation-1 << " +++\n"
        << "+++ Try to proceed with the default value, min_separation="
        << def_min_separation << " +++\n";
      min_separation = def_min_separation;
    }
  }
}
void CSCCathodeLCTProcessor::clear ( void  )

Clears the LCT containers.

Definition at line 457 of file CSCCathodeLCTProcessor.cc.

References bestCLCT, CSCCLCTDigi::clear(), MAX_CLCT_BINS, secondCLCT, and thePreTriggerBXs.

Referenced by CSCMotherboard::clear().

                                   {
  thePreTriggerBXs.clear();
  for (int bx = 0; bx < MAX_CLCT_BINS; bx++) {
    bestCLCT[bx].clear();
    secondCLCT[bx].clear();
  }
}
void CSCCathodeLCTProcessor::distripStagger ( int  stag_triad[CSCConstants::MAX_NUM_STRIPS],
int  stag_time[CSCConstants::MAX_NUM_STRIPS],
int  stag_digi[CSCConstants::MAX_NUM_STRIPS],
int  i_distrip,
bool  debug = false 
) [static]

Definition at line 974 of file CSCCathodeLCTProcessor.cc.

References LogDebug.

Referenced by readComparatorDigis(), and testDistripStagger().

                                                            {
  // Author: Jason Mumford (mumford@physics.ucla.edu)
  // This routine takes care of the stagger situation where there is a hit
  // on the right half-strip of a di-strip.  If there is a stagger, then
  // we must associate that distrip with the next distrip. The situation
  // gets more complicated if the next distrip also has a hit on its right
  // half-strip.  One could imagine a whole chain of these in which case
  // we need to go into this routine recursively.  The formula is that
  // while this condition is satisfied, we enquire the next distrip,
  // until we have a hit on any other halfstrip (or triad!=3).  Then we
  // must compare the 2 different bx times and take the smallest one.
  // Afterwards, we must cycle out of the routine assigning the bx times
  // to the one strip over.

  // Used only for pre-TMB07 firmware.

  if (i_strip >= CSCConstants::MAX_NUM_STRIPS) {
    if (debug) edm::LogWarning("L1CSCTPEmulatorWrongInput")
      << "+++ Found wrong strip number = " << i_strip
      << "; cannot apply distrip staggering... +++\n";
    return;
  }

  if (debug)
    LogDebug("CSCCathodeLCTProcessor")
      << " Enter distripStagger: i_strip = " << i_strip
      << " stag_triad[i_strip] = "   << stag_triad[i_strip]
      << " stag_time[i_strip] =  "   << stag_time[i_strip]
      << " stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
      << " stag_time[i_strip+2] = "  << stag_time[i_strip+2];

  // So if the next distrip has a stagger hit, go into the routine again
  // for the next distrip.
  if (i_strip+2 < CSCConstants::MAX_NUM_STRIPS && stag_triad[i_strip+2] == 1)
    distripStagger(stag_triad, stag_time, stag_digi, i_strip+2);

  // When we have reached a distrip that does not have a staggered hit,
  // if it has a hit, we compare the bx times of the
  // staggered distrip with the non-staggered distrip and we take the
  // smallest of the two and assign it to the shifted distrip time.
  if (stag_time[i_strip+2] >= 0) {
    if (stag_time[i_strip] < stag_time[i_strip+2]) {
      stag_time[i_strip+2] = stag_time[i_strip];
      stag_digi[i_strip+2] = stag_digi[i_strip];
    }
  }
  // If the next distrip did not have a hit, then we merely assign the
  // shifted time to the time associated with the staggered distrip.
  else {
    stag_time[i_strip+2] = stag_time[i_strip];
    stag_digi[i_strip+2] = stag_digi[i_strip];
  }

  // Then to prevent previous staggers from being overwritten, we assign
  // the unshifted time to -999, and then mark the triads that were shifted
  // so that we don't go into the routine ever again (such as when making
  // the next loop over strips).
  stag_time[i_strip]  = -999;
  stag_triad[i_strip] =    4;
  stag_digi[i_strip]  = -999;

  if (debug)
    LogDebug("CSCCathodeLCTProcessor")
      << " Exit  distripStagger: i_strip = " << i_strip
      << " stag_triad[i_strip] = "   << stag_triad[i_strip]
      << " stag_time[i_strip] = "    << stag_time[i_strip]
      << " stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
      << " stag_time[i_strip+2] = "  << stag_time[i_strip+2];
}
void CSCCathodeLCTProcessor::dumpConfigParams ( ) const [private]

Dump CLCT configuration parameters.

Definition at line 2339 of file CSCCathodeLCTProcessor.cc.

References drift_delay, fifo_pretrig, fifo_tbins, hit_persist, isTMB07, LogDebug, min_separation, nplanes_hit_pattern, nplanes_hit_pretrig, and pid_thresh_pretrig.

Referenced by CSCCathodeLCTProcessor(), and setConfigParameters().

                                                    {
  std::ostringstream strm;
  strm << "\n";
  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
  strm << "+                  CLCT configuration parameters:                  +\n";
  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
  strm << " fifo_tbins   [total number of time bins in DAQ readout] = "
       << fifo_tbins << "\n";
  strm << " fifo_pretrig [start time of cathode raw hits in DAQ readout] = "
       << fifo_pretrig << "\n";
  strm << " hit_persist  [duration of signal pulse, in 25 ns bins] = "
       << hit_persist << "\n";
  strm << " drift_delay  [time after pre-trigger before TMB latches LCTs] = "
       << drift_delay << "\n";
  strm << " nplanes_hit_pretrig [min. number of layers hit for pre-trigger] = "
       << nplanes_hit_pretrig << "\n";
  strm << " nplanes_hit_pattern [min. number of layers hit for trigger] = "
       << nplanes_hit_pattern << "\n";
  if (isTMB07) {
    strm << " pid_thresh_pretrig [lower threshold on pattern id] = "
         << pid_thresh_pretrig << "\n";
    strm << " min_separation     [region of busy key strips] = "
         << min_separation << "\n";
  }
  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
  LogDebug("CSCCathodeLCTProcessor") << strm.str();
}
void CSCCathodeLCTProcessor::dumpDigis ( const std::vector< int >  strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
const int  stripType,
const int  nStrips 
) const [private]

Dump digis on half-strips and di-strips.

Definition at line 2368 of file CSCCathodeLCTProcessor.cc.

References cfeb_strips, CSCTriggerNumbering::chamberFromTriggerLabels(), relativeConstraints::empty, LogDebug, LogTrace, CSCConstants::NUM_LAYERS, CSCTriggerNumbering::ringFromTriggerLabels(), strip(), theEndcap, theSector, theStation, theSubsector, and theTrigChamber.

Referenced by findLCTs().

{
  LogDebug("CSCCathodeLCTProcessor")
    << "ME" << ((theEndcap == 1) ? "+" : "-") << theStation << "/"
    << CSCTriggerNumbering::ringFromTriggerLabels(theStation, theTrigChamber)
    << "/" << CSCTriggerNumbering::chamberFromTriggerLabels(theSector,
                                    theSubsector, theStation, theTrigChamber)
    << " strip type " << stripType << " nStrips " << nStrips;

  std::ostringstream strstrm;
  for (int i_strip = 0; i_strip < nStrips; i_strip++) {
    if (i_strip%10 == 0) {
      if (i_strip < 100) strstrm << i_strip/10;
      else               strstrm << (i_strip-100)/10;
    }
    else                 strstrm << " ";
    if ((i_strip+1)%cfeb_strips[stripType] == 0) strstrm << " ";
  }
  strstrm << "\n";
  for (int i_strip = 0; i_strip < nStrips; i_strip++) {
    strstrm << i_strip%10;
    if ((i_strip+1)%cfeb_strips[stripType] == 0) strstrm << " ";
  }
  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
    strstrm << "\n";
    for (int i_strip = 0; i_strip < nStrips; i_strip++) {
      if (!strip[i_layer][i_strip].empty()) {
        std::vector<int> bx_times = strip[i_layer][i_strip];
        // Dump only the first in time.
        strstrm << std::hex << bx_times[0] << std::dec;
      }
      else {
        strstrm << "-";
      }
      if ((i_strip+1)%cfeb_strips[stripType] == 0) strstrm << " ";
    }
  }
  LogTrace("CSCCathodeLCTProcessor") << strstrm.str();
}
std::vector< CSCCLCTDigi > CSCCathodeLCTProcessor::findLCTs ( const std::vector< int >  strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
int  stripType 
) [private]

Definition at line 1057 of file CSCCathodeLCTProcessor.cc.

References abs, CLCT_BEND, CLCT_BX, CLCT_CFEB, CLCT_PATTERN, CLCT_QUALITY, CLCT_STRIP, CLCT_STRIP_TYPE, dumpDigis(), getKeyStripData(), infoV, j, LogTrace, nplanes_hit_pattern, numStrips, preTrigger(), and strip().

Referenced by run(), and testPatterns().

{
  int j;
  int best_strip = 0;
  int first_bx = 999;
  const int max_lct_num = 2;
  const int adjacent_strips = 2;
  // Distrip, halfstrip pattern threshold.
  const int ptrn_thrsh[2] = {nplanes_hit_pattern, nplanes_hit_pattern};
  int highest_quality = 0;

  int keystrip_data[CSCConstants::NUM_HALF_STRIPS][7];
  int final_lcts[max_lct_num];

  std::vector <CSCCLCTDigi> lctList;

  int nStrips = 0;
  if (stripType == 1)      nStrips = 2*numStrips + 1;
  else if (stripType == 0) nStrips = numStrips/2 + 1;

  if (infoV > 1) dumpDigis(strip, stripType, nStrips);

  // Send data to a pretrigger so that we don't excessively look at data
  // that won't give an LCT. If there is a pretrigger, then get all quality
  // and bend for all keystrips.
  if (preTrigger(strip, stripType, nStrips, first_bx)){
    getKeyStripData(strip, keystrip_data, nStrips, first_bx, best_strip, stripType);

    /* Set all final_lcts to impossible key_strip numbers */
    for (j = 0; j < max_lct_num; j++)
      final_lcts[j] = -999;

    // Now take the keystrip with the best quality, and do a search over the
    // rest of the strips for the next highest quality.  Do the search over a 
    // range excluding a certain number of keystrips adjacent to the original
    // best key_strip.
    final_lcts[0] = best_strip;

    for (int key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
      // If indexed strip does not fall within excluded range, then continue
      if (abs(best_strip - key_strip) > adjacent_strips){
        // Match with highest quality
        if (keystrip_data[key_strip][CLCT_QUALITY] > highest_quality){
          highest_quality = keystrip_data[key_strip][CLCT_QUALITY];
          final_lcts[1] = key_strip;
        }
      }
    }

    for (j = 0; j < max_lct_num; j++){
      // Only report LCTs if the number of layers hit is greater than or
      // equal to the (variable) valid pattern threshold ptrn_thrsh.
      int keystrip = final_lcts[j];
      if (keystrip >= 0 &&
          keystrip_data[keystrip][CLCT_QUALITY] >= ptrn_thrsh[stripType]) {
        // assign the stripType here. 1 = halfstrip, 0 = distrip.
        keystrip_data[keystrip][CLCT_STRIP_TYPE] = stripType;
        // Now make the LCT words for the 2 highest, and store them in a list
        int theHalfStrip = (keystrip_data[keystrip][CLCT_STRIP_TYPE] ?
                            keystrip_data[keystrip][CLCT_STRIP] :
                            4*keystrip_data[keystrip][CLCT_STRIP]);
        keystrip_data[keystrip][CLCT_CFEB] = theHalfStrip/32;
        int halfstrip_in_cfeb =
          theHalfStrip - 32*keystrip_data[keystrip][CLCT_CFEB];

        CSCCLCTDigi thisLCT(1, keystrip_data[keystrip][CLCT_QUALITY],
                            keystrip_data[keystrip][CLCT_PATTERN],
                            keystrip_data[keystrip][CLCT_STRIP_TYPE],
                            keystrip_data[keystrip][CLCT_BEND],
                            halfstrip_in_cfeb,
                            keystrip_data[keystrip][CLCT_CFEB],
                            keystrip_data[keystrip][CLCT_BX]);
        if (infoV > 2) {
          char stripType =
            (keystrip_data[keystrip][CLCT_STRIP_TYPE] == 0) ? 'D' : 'H';
          char bend =
            (keystrip_data[keystrip][CLCT_BEND] == 0) ? 'L' : 'R';
          LogTrace("CSCCathodeLCTProcessor")
            << " Raw Find: "
            << "Key Strip: "  << std::setw(3)
            << keystrip_data[keystrip][CLCT_STRIP]
            << " Pattern: "   << std::setw(2)
            << keystrip_data[keystrip][CLCT_PATTERN]
            << " Bend: "      << std::setw(1) << bend
            << " Quality: "   << std::setw(1)
            << keystrip_data[keystrip][CLCT_QUALITY]
            << " stripType: " << std::setw(1) << stripType
            << " BX: "        << std::setw(1)
            << keystrip_data[keystrip][CLCT_BX];
        }
        lctList.push_back(thisLCT);
      }
    }
  }

  return lctList;
} // findLCTs -- idealized version for MC studies.
std::vector< CSCCLCTDigi > CSCCathodeLCTProcessor::findLCTs ( const std::vector< int >  halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
const std::vector< int >  distrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS] 
) [private]

Definition at line 1352 of file CSCCathodeLCTProcessor.cc.

References CLCT_BEND, CLCT_BX, CLCT_CFEB, CLCT_PATTERN, CLCT_QUALITY, CLCT_STRIP, CLCT_STRIP_TYPE, drift_delay, dumpDigis(), getKeyStripData(), infoV, latchLCTs(), LogTrace, MAX_CFEBS, CSCConstants::NUM_DI_STRIPS, CSCConstants::NUM_LAYERS, numStrips, preTrigger(), and priorityEncode().

                                                                                    {
  std::vector <CSCCLCTDigi> lctList;
  int _bx[2] = {999, 999};
  int first_bx = 999;

  const int nhStrips = 2*numStrips + 1;
  const int ndStrips = numStrips/2 + 1;

  if (infoV > 1) {
    dumpDigis(halfstrip, 1, nhStrips);
    dumpDigis(distrip,   0, ndStrips);
  }

  // Test beam version of TMB pretrigger and LCT sorting
  int h_keyStrip[MAX_CFEBS];       // one key per CFEB
  unsigned int h_nhits[MAX_CFEBS]; // number of hits in envelope for each key
  int d_keyStrip[MAX_CFEBS];       // one key per CFEB
  unsigned int d_nhits[MAX_CFEBS]; // number of hits in envelope for each key
  int keystrip_data[2][7];    // 2 possible LCTs per CSC x 7 LCT quantities
  unsigned int h_pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS]; // simulate digital one-shot
  unsigned int d_pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS]; // simulate digital one-shot
  bool pre_trig[2] = {false, false};

  // All half-strip and di-strip pattern envelopes are evaluated
  // simultaneously, on every clock cycle.
  pre_trig[0] = preTrigger(halfstrip, h_pulse, 1, nhStrips, 0, _bx[0]);
  pre_trig[1] = preTrigger(  distrip, d_pulse, 0, ndStrips, 0, _bx[1]);

  // If any of 200 half-strip and di-strip envelopes has enough layers hit in
  // it, TMB will pre-trigger.
  if (pre_trig[0] || pre_trig[1]) {
    first_bx = (_bx[0] < _bx[1]) ? _bx[0] : _bx[1];
    if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
      << "half bx " << _bx[0] << " di bx " << _bx[1] << " first " << first_bx
      << "\n ..... waiting drift delay ..... ";

    // Empirically-found trick allowing to dramatically improve agreement
    // with MTCC-II data.
    // The trick is to ignore hits in a few first time bins when latching
    // hits for priority encode envelopes.  For MTCC-II, we need to ignore
    // hits in time bins 0-3 inclusively.
    //
    // Firmware configuration has been fixed for most of 2007 runs, so
    // this trick should NOT be used when emulating 2007 trigger.
    /*
    int max_bx = 4;
    for (int ilayer = 0; ilayer < CSCConstants::NUM_LAYERS; ilayer++) {
      for (int istrip = 0; istrip < CSCConstants::NUM_HALF_STRIPS; istrip++) {
        for (int bx = 0; bx < max_bx; bx++) {
          if (((h_pulse[ilayer][istrip] >> bx) & 1) == 1) {
            h_pulse[ilayer][istrip] = 0;
          }
        }
      }
      for (int istrip = 0; istrip < CSCConstants::NUM_DI_STRIPS; istrip++) {
        for (int bx = 0; bx < max_bx; bx++) {
          if (((d_pulse[ilayer][istrip] >> bx) & 1) == 1) {
            d_pulse[ilayer][istrip] = 0;
          }
        }
      }
    }
    */

    // TMB latches LCTs drift_delay clocks after pretrigger.
    int latch_bx = first_bx + drift_delay;
    latchLCTs(h_pulse, h_keyStrip, h_nhits, 1, CSCConstants::NUM_HALF_STRIPS,
              latch_bx);
    latchLCTs(d_pulse, d_keyStrip, d_nhits, 0,   CSCConstants::NUM_DI_STRIPS,
              latch_bx);

    if (infoV > 1) {
      LogTrace("CSCCathodeLCTProcessor")
        << "...............................\n"
        << "Final halfstrip hits and keys (after drift delay) ...";
      for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
        LogTrace("CSCCathodeLCTProcessor")
          << "cfeb " << icfeb << " key: " << h_keyStrip[icfeb]
          << " hits " << h_nhits[icfeb];
      }
      LogTrace("CSCCathodeLCTProcessor")
        << "Final distrip hits and keys (after drift delay) ...";
      for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
        LogTrace("CSCCathodeLCTProcessor")
          << "cfeb " << icfeb << " key: " << d_keyStrip[icfeb]
          << " hits " << d_nhits[icfeb];
      }
    }
    priorityEncode(h_keyStrip, h_nhits, d_keyStrip, d_nhits, keystrip_data);
    getKeyStripData(h_pulse, d_pulse, keystrip_data, first_bx);

    for (int ilct = 0; ilct < 2; ilct++) {
      if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
        << "found lcts: ilct " << ilct
        << "  key strip " << keystrip_data[ilct][CLCT_STRIP];
      if (keystrip_data[ilct][CLCT_STRIP] != -1) {
        int halfstrip_in_cfeb = 0;
        if (keystrip_data[ilct][CLCT_STRIP_TYPE] == 0)
          halfstrip_in_cfeb = 4*keystrip_data[ilct][CLCT_STRIP] -
                             32*keystrip_data[ilct][CLCT_CFEB];
        else
          halfstrip_in_cfeb = keystrip_data[ilct][CLCT_STRIP] -
                             32*keystrip_data[ilct][CLCT_CFEB];

        CSCCLCTDigi thisLCT(1, keystrip_data[ilct][CLCT_QUALITY],
                            keystrip_data[ilct][CLCT_PATTERN],
                            keystrip_data[ilct][CLCT_STRIP_TYPE],
                            keystrip_data[ilct][CLCT_BEND],
                            halfstrip_in_cfeb,
                            keystrip_data[ilct][CLCT_CFEB],
                            keystrip_data[ilct][CLCT_BX]);
        lctList.push_back(thisLCT);
      }
    }
  }

  return lctList;

} // findLCTs -- pre-2007 version.
std::vector< CSCCLCTDigi > CSCCathodeLCTProcessor::findLCTs ( const std::vector< int >  halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS]) [private]

Definition at line 1961 of file CSCCathodeLCTProcessor.cc.

References best_pid, cfeb_strips, CLCT_BEND, CLCT_BX, CLCT_CFEB, CLCT_PATTERN, CLCT_QUALITY, CLCT_STRIP, CLCT_STRIP_TYPE, drift_delay, dumpDigis(), fifo_tbins, infoV, CSCConstants::KEY_CLCT_LAYER, LogTrace, markBusyKeys(), nhits, nplanes_hit_pattern, CSCConstants::NUM_LAYERS, NUM_PATTERN_HALFSTRIPS, numStrips, pattern2007, preTrigger(), ptnFinding(), pulseExtension(), stagger, and thePreTriggerBXs.

                                                                                                                                           {
  std::vector<CSCCLCTDigi> lctList;

  // Max. number of half-strips for this chamber.
  const int maxHalfStrips = 2*numStrips + 1;

  if (infoV > 1) dumpDigis(halfstrip, 1, maxHalfStrips);

  // Test beam version of TMB pretrigger and LCT sorting
  enum {max_lcts = 2};
  // 2 possible LCTs per CSC x 7 LCT quantities
  int keystrip_data[max_lcts][7] = {{0}};
  unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS];

  // Fire half-strip one-shots for hit_persist bx's (6 bx's by default).
  pulseExtension(halfstrip, maxHalfStrips, pulse);

  unsigned int start_bx = 0;
  // Stop drift_delay bx's short of fifo_tbins since at later bx's we will
  // not have a full set of hits to start pattern search anyway.
  unsigned int stop_bx  = fifo_tbins - drift_delay;
  // Allow for more than one pass over the hits in the time window.
  while (start_bx < stop_bx) {
    // All half-strip pattern envelopes are evaluated simultaneously, on every
    // clock cycle.
    int first_bx = 999;
    bool pre_trig = preTrigger(pulse, start_bx, first_bx);

    // If any of half-strip envelopes has enough layers hit in it, TMB
    // will pre-trigger.
    if (pre_trig) {
      thePreTriggerBXs.push_back(first_bx);
      if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
        << "..... pretrigger at bx = " << first_bx
        << "; waiting drift delay .....";

      // TMB latches LCTs drift_delay clocks after pretrigger.
      int latch_bx = first_bx + drift_delay;
      bool hits_in_time = ptnFinding(pulse, maxHalfStrips, latch_bx);
      if (infoV > 1) {
        if (hits_in_time) {
          for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER-1];
               hstrip < maxHalfStrips; hstrip++) {
            if (nhits[hstrip] > 0) {
              LogTrace("CSCCathodeLCTProcessor")
                << " bx = " << std::setw(2) << latch_bx << " --->"
                << " halfstrip = " << std::setw(3) << hstrip
                << " best pid = "  << std::setw(2) << best_pid[hstrip]
                << " nhits = "     << nhits[hstrip];
            }
          }
        }
      }
      // The pattern finder runs continuously, so another pre-trigger
      // could occur already at the next bx.
      start_bx = first_bx + 1;

      // Quality for sorting.
      int quality[CSCConstants::NUM_HALF_STRIPS];
      int best_halfstrip[max_lcts], best_quality[max_lcts];
      for (int ilct = 0; ilct < max_lcts; ilct++) {
        best_halfstrip[ilct] = -1;
        best_quality[ilct]   =  0;
      }

      // Calculate quality from pattern id and number of hits, and
      // simultaneously select best-quality LCT.
      if (hits_in_time) {
        for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER-1];
             hstrip < maxHalfStrips; hstrip++) {
          // The bend-direction bit pid[0] is ignored (left and right
          // bends have equal quality).
          quality[hstrip] = (best_pid[hstrip] & 14) | (nhits[hstrip] << 5);
          if (quality[hstrip] > best_quality[0]) {
            best_halfstrip[0] = hstrip;
            best_quality[0]   = quality[hstrip];
          }
          if (infoV > 1 && quality[hstrip] > 0) {
            LogTrace("CSCCathodeLCTProcessor")
              << " 1st CLCT: halfstrip = " << std::setw(3) << hstrip
              << " quality = "             << std::setw(3) << quality[hstrip]
              << " best halfstrip = " << std::setw(3) << best_halfstrip[0]
              << " best quality = "   << std::setw(3) << best_quality[0];
          }
        }
      }

      // If 1st best CLCT is found, look for the 2nd best.
      if (best_halfstrip[0] >= 0) {
        // Mark keys near best CLCT as busy by setting their quality to
        // zero, and repeat the search.
        markBusyKeys(best_halfstrip[0], best_pid[best_halfstrip[0]], quality);

        for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER-1];
           hstrip < maxHalfStrips; hstrip++) {
          if (quality[hstrip] > best_quality[1]) {
            best_halfstrip[1] = hstrip;
            best_quality[1]   = quality[hstrip];
          }
          if (infoV > 1 && quality[hstrip] > 0) {
            LogTrace("CSCCathodeLCTProcessor")
              << " 2nd CLCT: halfstrip = " << std::setw(3) << hstrip
              << " quality = "             << std::setw(3) << quality[hstrip]
              << " best halfstrip = " << std::setw(3) << best_halfstrip[1]
              << " best quality = "   << std::setw(3) << best_quality[1];
          }
        }

        // Pattern finder.
        bool ptn_trig = false;
        for (int ilct = 0; ilct < max_lcts; ilct++) {
          int best_hs = best_halfstrip[ilct];
          if (best_hs >= 0 && nhits[best_hs] >= nplanes_hit_pattern) {
            ptn_trig = true;
            keystrip_data[ilct][CLCT_PATTERN]    = best_pid[best_hs];
            keystrip_data[ilct][CLCT_BEND]       =
              pattern2007[best_pid[best_hs]][NUM_PATTERN_HALFSTRIPS];
            // Remove stagger if any.
            keystrip_data[ilct][CLCT_STRIP]      =
              best_hs - stagger[CSCConstants::KEY_CLCT_LAYER-1];
            keystrip_data[ilct][CLCT_BX]         = first_bx;
            keystrip_data[ilct][CLCT_STRIP_TYPE] = 1;           // obsolete
            keystrip_data[ilct][CLCT_QUALITY]    = nhits[best_hs];
            keystrip_data[ilct][CLCT_CFEB]       =
              keystrip_data[ilct][CLCT_STRIP]/cfeb_strips[1];
            int halfstrip_in_cfeb = keystrip_data[ilct][CLCT_STRIP] -
              cfeb_strips[1]*keystrip_data[ilct][CLCT_CFEB];

            if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
              << " Final selection: ilct " << ilct
              << " key halfstrip " << keystrip_data[ilct][CLCT_STRIP]
              << " quality "       << keystrip_data[ilct][CLCT_QUALITY]
              << " pattern "       << keystrip_data[ilct][CLCT_PATTERN]
              << " bx "            << keystrip_data[ilct][CLCT_BX];

            CSCCLCTDigi thisLCT(1, keystrip_data[ilct][CLCT_QUALITY],
                                keystrip_data[ilct][CLCT_PATTERN],
                                keystrip_data[ilct][CLCT_STRIP_TYPE],
                                keystrip_data[ilct][CLCT_BEND],
                                halfstrip_in_cfeb,
                                keystrip_data[ilct][CLCT_CFEB],
                                keystrip_data[ilct][CLCT_BX]);
            lctList.push_back(thisLCT);
          }
        }

        if (ptn_trig) {
          // Once there was a trigger, CLCT pre-trigger state machine
          // checks the number of hits that lie on a pattern template
          // at every bx, and waits for it to drop below threshold.
          // The search for CLCTs resumes only when the number of hits
          // drops below threshold.
          start_bx = fifo_tbins;
          // Stop checking drift_delay bx's short of fifo_tbins since
          // at later bx's we won't have a full set of hits for a
          // pattern search anyway.
          unsigned int stop_time = fifo_tbins - drift_delay;
          for (unsigned int bx = latch_bx + 1; bx < stop_time; bx++) {
            bool return_to_idle = true;
            bool hits_in_time = ptnFinding(pulse, maxHalfStrips, bx);
            if (hits_in_time) {
              for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER-1];
                   hstrip < maxHalfStrips; hstrip++) {
                if (nhits[hstrip] >= nplanes_hit_pattern) {
                  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
                    << " State machine busy at bx = " << bx;
                  return_to_idle = false;
                  break;
                }
              }
            }
            if (return_to_idle) {
              if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
                << " State machine returns to idle state at bx = " << bx;
              start_bx = bx;
              break;
            }
          }
        }
      }
    }
    else {
      start_bx = first_bx + 1; // no dead time
    }
  }

  return lctList;
} // findLCTs -- TMB-07 version.
int CSCCathodeLCTProcessor::findNumLayersHit ( std::vector< int >  stripsHit[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS]) [private]

Definition at line 2733 of file CSCCathodeLCTProcessor.cc.

References relativeConstraints::empty, and CSCConstants::NUM_LAYERS.

Referenced by testPatterns().

                                                                          {
  int number = 0;
  for (int layer = 0; layer < CSCConstants::NUM_LAYERS; layer++) {
    if ((!stripsHit[layer][ 9].empty()) || 
        (!stripsHit[layer][10].empty()) ||
        (!stripsHit[layer][11].empty()) ) number++;
  }
  return number;
}
std::vector< CSCCLCTDigi > CSCCathodeLCTProcessor::getCLCTs ( )

Returns vector of all found CLCTs, if any.

Definition at line 2488 of file CSCCathodeLCTProcessor.cc.

References bestCLCT, MAX_CLCT_BINS, and secondCLCT.

Referenced by readoutCLCTs(), and run().

                                                        {
  std::vector<CSCCLCTDigi> tmpV;
  for (int bx = 0; bx < MAX_CLCT_BINS; bx++) {
    if (bestCLCT[bx].isValid())   tmpV.push_back(bestCLCT[bx]);
    if (secondCLCT[bx].isValid()) tmpV.push_back(secondCLCT[bx]);
  }
  return tmpV;
}
bool CSCCathodeLCTProcessor::getDigis ( const CSCComparatorDigiCollection compdc)

Access routines to comparator digis.

Definition at line 674 of file CSCCathodeLCTProcessor.cc.

References CSCTriggerNumbering::chamberFromTriggerLabels(), cond::rpcobgas::detid, digiV, relativeConstraints::empty, infoV, LogTrace, CSCConstants::NUM_LAYERS, CSCTriggerNumbering::ringFromTriggerLabels(), theEndcap, theSector, theStation, theSubsector, and theTrigChamber.

Referenced by run().

                                                                               {
  bool noDigis = true;
  int  theRing    = CSCTriggerNumbering::ringFromTriggerLabels(theStation,
                                                               theTrigChamber);
  int  theChamber = CSCTriggerNumbering::chamberFromTriggerLabels(theSector,
                                     theSubsector, theStation, theTrigChamber);

  // Loop over layers and save comparator digis on each one into digiV[layer].
  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
    digiV[i_layer].clear();
    
    CSCDetId detid(theEndcap, theStation, theRing, theChamber, i_layer+1);
    getDigis(compdc, detid);

    // If this is ME1/1, fetch digis in corresponding ME1/A (ring=4) as well.
    if (theStation == 1 && theRing == 1) {
      CSCDetId detid_me1a(theEndcap, theStation, 4, theChamber, i_layer+1);
      getDigis(compdc, detid_me1a);
    }

    if (!digiV[i_layer].empty()) {
      noDigis = false;
      if (infoV > 1) {
        LogTrace("CSCCathodeLCTProcessor")
          << "found " << digiV[i_layer].size()
          << " comparator digi(s) in layer " << i_layer << " of ME"
          << ((theEndcap == 1) ? "+" : "-") << theStation << "/" << theRing
          << "/" << theChamber << " (trig. sector " << theSector
          << " subsector " << theSubsector << " id " << theTrigChamber << ")";
      }
    }
  }

  return noDigis;
}
void CSCCathodeLCTProcessor::getDigis ( const CSCComparatorDigiCollection compdc,
const CSCDetId id 
)

Definition at line 710 of file CSCCathodeLCTProcessor.cc.

References digiV, and relativeConstraints::ring.

                                                          {
  bool me1a = (id.station() == 1) && (id.ring() == 4);
  const CSCComparatorDigiCollection::Range rcompd = compdc->get(id);
  for (CSCComparatorDigiCollection::const_iterator digiIt = rcompd.first;
       digiIt != rcompd.second; ++digiIt) {
    if (me1a && digiIt->getStrip() <= 16) {
      // Move ME1/A comparators from CFEB=0 to CFEB=4 if this has not
      // been done already.
      CSCComparatorDigi digi_corr(digiIt->getStrip()+64,
                                  digiIt->getComparator(),
                                  digiIt->getTimeBinWord());
      digiV[id.layer()-1].push_back(digi_corr);
    }
    else {
      digiV[id.layer()-1].push_back(*digiIt);
    }
  }
}
void CSCCathodeLCTProcessor::getKeyStripData ( const std::vector< int >  strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
int  keystrip_data[CSCConstants::NUM_HALF_STRIPS][7],
int  nStrips,
int  first_bx,
int &  best_strip,
int  stripType 
) [private]

Definition at line 1219 of file CSCCathodeLCTProcessor.cc.

References CLCT_BEND, CLCT_BX, CLCT_PATTERN, CLCT_QUALITY, CLCT_STRIP, drift_delay, getPattern(), i, infoV, LogTrace, CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07, NUM_PATTERN_STRIPS, pre_hit_pattern, and strip().

Referenced by findLCTs().

                                                                   {
  int lct_pattern[NUM_PATTERN_STRIPS];
  int key_strip, this_layer, this_strip;
  int quality, best_quality;
  int bend = 0;
  int highest_quality = 0;
  bool nullPattern;

  for (key_strip = 0; key_strip < nStrips; key_strip++)
    for (int i = 0; i < 7; i++)
      keystrip_data[key_strip][i] = 0;

  // Now we need to look at all the keystrips and take the best pattern
  // for each.  There are multiple patterns available for each keystrip.

  for (key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
    nullPattern = true;
    for (int pattern_strip = 0; pattern_strip < NUM_PATTERN_STRIPS; pattern_strip++){
      this_layer = pre_hit_pattern[0][pattern_strip];
      this_strip = pre_hit_pattern[1][pattern_strip] + key_strip;
      // This conditional statement prevents us from looking at strips
      // that don't exist along the chamber boundaries.
      if ((this_strip >= 0 && this_strip < nStrips) &&
          !strip[this_layer][this_strip].empty()) {
        if (nullPattern) nullPattern = false;
        std::vector<int> bx_times = strip[this_layer][this_strip];
        lct_pattern[pattern_strip] = bx_times[0];
      }
      else
        lct_pattern[pattern_strip] = -999;
      }
    // do the rest only if there is at least one DIGI in the pattern for
    // this keystrip
    if (nullPattern) continue;

    // Initialize best_quality to zero so that we can look for best pattern
    // within a keystrip.
    best_quality = 0;

    // Loop over all possible patterns.
    // Loop in reverse order, in order to give priority to a straighter
    // pattern (larger pattern_num) in case of equal qualities.
    // Exclude pattern 0 since it is not defined.
    for (int pattern_num = CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07-1; pattern_num > 0; pattern_num--) {
      // Get the pattern quality from lct_pattern.
      // TMB latches LCTs drift_delay clocks after pretrigger.
      int latch_bx = first_bx + drift_delay;
      getPattern(pattern_num, lct_pattern, latch_bx, quality, bend);
      if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
        << "Key_strip " << key_strip << " quality of pattern_num "
        << pattern_num << ": " << quality;
      if (quality > best_quality){
        // Store the best pattern, quality, etc., for each key_strip.
        keystrip_data[key_strip][CLCT_PATTERN] = pattern_num;
        keystrip_data[key_strip][CLCT_BEND]    = bend;
        keystrip_data[key_strip][CLCT_STRIP]   = key_strip;
        keystrip_data[key_strip][CLCT_BX]      = first_bx;
        // keystrip_data[key_strip][CLCT_STRIP_TYPE] = stripType; //assign the stripType elsewhere
        keystrip_data[key_strip][CLCT_QUALITY] = quality;
        if (quality > highest_quality){
          // Keep track of which strip had the highest quality.
          // highest_quality refers to the overall highest quality for all
          // key strips. This is different than best_quality which refers
          // to the best quality in a keystrip from different patterns.
          best_strip = key_strip;
          highest_quality = quality;
        }
        best_quality = quality;
      }
    }
  }
} // getKeyStripData -- idealized version for MC studies.
void CSCCathodeLCTProcessor::getKeyStripData ( const unsigned int  h_pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
const unsigned int  d_pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
int  keystrip_data[2][7],
const int  first_bx 
) [private]

Definition at line 1807 of file CSCCathodeLCTProcessor.cc.

References CLCT_BEND, CLCT_BX, CLCT_PATTERN, CLCT_QUALITY, CLCT_STRIP, CLCT_STRIP_TYPE, drift_delay, getPattern(), infoV, LogTrace, nplanes_hit_pattern, CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07, CSCConstants::NUM_DI_STRIPS, NUM_PATTERN_STRIPS, pre_hit_pattern, and TrackValidation_HighPurity_cff::valid.

                                                             {

  int lct_pattern[NUM_PATTERN_STRIPS];
  int this_layer, this_strip;
  unsigned int quality = 0, bend = 0;
  unsigned int best_quality, best_pattern;
  bool valid[2] = {false,false};

  // Time at which TMB latches LCTs.
  int latch_bx = first_bx + drift_delay;

  // Look at keystrips determined from priorityEncode and find their best
  // pattern based on number of hits matching that pattern (quality).  Also
  // find bend angle.  There are multiple patterns available for each keystrip.

  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
    << "...............getKeyStripData....................";

  for (int ilct = 0; ilct < 2; ilct++) {
    if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
      << "lct " << ilct << " keystrip " << keystrip_data[ilct][CLCT_STRIP]
      << " type " << keystrip_data[ilct][CLCT_STRIP_TYPE];
    if (keystrip_data[ilct][CLCT_STRIP] == -1) {// flag set in priorityEncode()
      if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
        << "no lct at ilct " << ilct;
      continue;
    }
    for (int pattern_strip = 0; pattern_strip < NUM_PATTERN_STRIPS;
         pattern_strip++) {
      lct_pattern[pattern_strip] = -999;
      this_layer = pre_hit_pattern[0][pattern_strip];
      this_strip = pre_hit_pattern[1][pattern_strip] +
        keystrip_data[ilct][CLCT_STRIP];
      // This conditional statement prevents us from looking at strips
      // that don't exist along the chamber boundaries.
      if (keystrip_data[ilct][CLCT_STRIP_TYPE] == 1) {
        if (this_strip >= 0 && this_strip < CSCConstants::NUM_HALF_STRIPS) {
          // Now look at one-shots in bx where TMB latches the LCTs
          if (((h_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
            lct_pattern[pattern_strip] = 1;
        }
      }
      else {
        if (this_strip >= 0 && this_strip < CSCConstants::NUM_DI_STRIPS) {
          // Now look at one-shots in bx where TMB latches the LCTs
          if (((d_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
            lct_pattern[pattern_strip] = 1;
        }
      }
    }

    // Find best pattern and quality associated with key by looping over all 
    // possible patterns
    best_quality = 0;
    best_pattern = 0;

    for (unsigned int pattern_num = 0;
         pattern_num < CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07; pattern_num++) {
      getPattern(pattern_num, lct_pattern, quality, bend);
      if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
          << "pattern " << pattern_num << " quality " << quality
          << " bend " << bend;
      // Number of layers hit matching a pattern template is compared
      // to nplanes_hit_pattern.  The threshold is the same for both half- and
      // di-strip patterns.
      if (quality >= nplanes_hit_pattern) {
        // If the number of matches is the same for two pattern templates,
        // the higher pattern-template number is selected.
        if ((quality == best_quality && pattern_num > best_pattern) ||
            (quality >  best_quality)) {
          if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
            << "valid = true at quality " << quality
            << "  thresh " << nplanes_hit_pattern;
          valid[ilct] = true;
          keystrip_data[ilct][CLCT_PATTERN]    = pattern_num;
          keystrip_data[ilct][CLCT_BEND]       = bend;
          keystrip_data[ilct][CLCT_BX]         = first_bx;
          //keystrip_data[ilct][CLCT_STRIP_TYPE] = stripType;
          keystrip_data[ilct][CLCT_QUALITY]    = quality;
          best_quality = quality;
          best_pattern = pattern_num;
        }
      }
    }

    if (!valid[ilct]) {
      keystrip_data[ilct][CLCT_STRIP] = -1;  // delete lct
      if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
        << "lct " << ilct << " not over threshold: deleting";
    }
    else {
      if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
        << "\n" << "--------- final LCT: " << ilct << " -------------\n"
        << " key strip "   << keystrip_data[ilct][CLCT_STRIP]
        << " pattern_num " << keystrip_data[ilct][CLCT_PATTERN]
        << " quality "     << keystrip_data[ilct][CLCT_QUALITY]
        << " bend "        << keystrip_data[ilct][CLCT_BEND]
        << " bx "          << keystrip_data[ilct][CLCT_BX]
        << " type "        << keystrip_data[ilct][CLCT_STRIP_TYPE] << "\n";
    }
  } // end loop over lcts
} // getKeyStripData -- pre-2007 version.
void CSCCathodeLCTProcessor::getPattern ( unsigned int  pattern_num,
const int  strip_value[NUM_PATTERN_STRIPS],
unsigned int &  quality,
unsigned int &  bend 
) [private]

Definition at line 1915 of file CSCCathodeLCTProcessor.cc.

References CSCConstants::NUM_LAYERS, NUM_PATTERN_STRIPS, and pattern.

                                                                    {

  // This function takes strip "one-shots" at the correct bx to find out
  // which hits fall within a certain pattern.  Quality and bend are then
  // calculated based on which strip pattern and how many layers were hit
  // within the pattern.

  unsigned int layers_hit = 0;
  bool hit_layer[CSCConstants::NUM_LAYERS];

  // Clear hit_layer array to keep track of number of layers hit.
  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++)
    hit_layer[i_layer] = false;

  // Loop over all designated patterns.
  for (int strip_num = 0; strip_num < NUM_PATTERN_STRIPS; strip_num++){
    if (strip_value[strip_num] == 1){
      for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++){
        // Loop over layer and see if corresponding strip is on same layer
        // If so then increment number of hits.
        if (i_layer == pattern[pattern_num][strip_num]){
          // If layer has no hits, then increment number of layers hit.
          if (hit_layer[i_layer] == false){
            layers_hit++;
            hit_layer[i_layer] = true;
          }
        }
      }
    }
  }
  // Get bend value from pattern.
  bend = pattern[pattern_num][NUM_PATTERN_STRIPS];
  quality = layers_hit;

} // getPattern -- pre-2007 version.
void CSCCathodeLCTProcessor::getPattern ( int  pattern_num,
int  strip_value[NUM_PATTERN_STRIPS],
int  bx_time,
int &  quality,
int &  bend 
) [private]

Definition at line 1296 of file CSCCathodeLCTProcessor.cc.

References hitIsGood(), CSCConstants::NUM_LAYERS, NUM_PATTERN_STRIPS, and pattern.

Referenced by getKeyStripData(), and testPatterns().

                               {
  // This function takes strip values and bx_time to find out which hits fall
  // within a certain pattern.  Quality, and bend are then calculated based on
  // which strip pattern and how many layers were hit within the pattern.
  int layers_hit = 0;
  bool hit_layer[CSCConstants::NUM_LAYERS];

  // Clear hit_layer array to keep track of number of layers hit.
  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++)
    hit_layer[i_layer] = false;

  // Loop over all designated patterns.
  for (int strip_num = 0; strip_num < NUM_PATTERN_STRIPS; strip_num++){
    if (hitIsGood(strip_value[strip_num], bx_time)){
      for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++){
        // Loop over layer and see if corresponding strip is on same layer
        // If so then increment number of hits.
        if (i_layer == pattern[pattern_num][strip_num]){
          // If layer has no hits, then increment number of layers hit.
          if (hit_layer[i_layer] == false){
            layers_hit++;
            hit_layer[i_layer] = true;
          }
        }
      }
    }
  }
  // Get bend value from pattern.
  bend = pattern[pattern_num][NUM_PATTERN_STRIPS];
  quality = layers_hit;
} // getPattern -- idealized version for MC studies.
bool CSCCathodeLCTProcessor::hitIsGood ( int  hitTime,
int  BX 
) [private]

Definition at line 1332 of file CSCCathodeLCTProcessor.cc.

References dt, and hit_persist.

Referenced by getPattern().

                                                          {
  // Find out if hit time is good.  Hit should have occurred no more than
  // hit_persist clocks before the latching time.
  int dt = BX - hitTime;
  if (dt >= 0 && dt <= static_cast<int>(hit_persist)) {return true;}
  else {return false;}
} // hitIsGood -- idealized version for MC studies.
void CSCCathodeLCTProcessor::latchLCTs ( const unsigned int  pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
int  keyStrip[MAX_CFEBS],
unsigned int  nhits[MAX_CFEBS],
const int  stripType,
const int  nStrips,
const int  bx_time 
) [private]

Definition at line 1571 of file CSCCathodeLCTProcessor.cc.

References cfeb_strips, infoV, LogTrace, MAX_CFEBS, CSCConstants::NUM_LAYERS, NUM_PATTERN_STRIPS, and pre_hit_pattern.

Referenced by findLCTs().

                                                                      {

  bool hit_layer[CSCConstants::NUM_LAYERS];
  int key_strip, this_layer, this_strip;
  int layers_hit, prev_hits;

  for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
    keyStrip[icfeb] = -1;
    n_hits[icfeb]   =  0;
  }

  if (stripType != 0 && stripType != 1) {
    if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
      << "+++ latchLCTs: stripType = " << stripType
      << " does not correspond to half-strip/di-strip patterns! +++\n";
    return;
  }

  for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) { // loop over CFEBs
    prev_hits = 0;
    // Loop over (di-/half-)strips in CFEB.
    for (int istrip = 0; istrip < cfeb_strips[stripType]; istrip++) {
      // Calculate candidate key.
      key_strip = icfeb*cfeb_strips[stripType] + istrip;
      layers_hit = 0;
      for (int ilayer = 0; ilayer < CSCConstants::NUM_LAYERS; ilayer++)
        hit_layer[ilayer] = false;

      // Loop over strips in pretrigger pattern mask and look for hits.
      for (int pstrip = 0; pstrip < NUM_PATTERN_STRIPS; pstrip++) {
        this_layer = pre_hit_pattern[0][pstrip];
        this_strip = pre_hit_pattern[1][pstrip]+key_strip;

        if (this_strip >= 0 && this_strip < nStrips) {
          // Determine if "one shot" is high at this bx_time
          if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
            if (hit_layer[this_layer] == false) {
              hit_layer[this_layer] = true;
              layers_hit++;                  // number of layers hit
            }
          }
        }
      } // end loop over strips in pretrigger pattern
      if (infoV > 1) {
        if (layers_hit > 0) LogTrace("CSCCathodeLCTProcessor")
          << "cfeb: " << icfeb << "  key_strip: " << key_strip
          << "  n_hits: " << layers_hit;
      }
      // If two or more keys have an equal number of hits, the lower number
      // key is taken.  Hence, replace the previous key only if this key has
      // more hits.
      if (layers_hit > prev_hits) {
        prev_hits = layers_hit;
        keyStrip[icfeb] = key_strip;  // key with highest hits is LCT key strip
        n_hits[icfeb] = layers_hit;   // corresponding hits in envelope
      }
    }  // end loop over candidate key strips in cfeb
  }  // end loop over cfebs
} // latchLCTs -- pre-2007 version.
void CSCCathodeLCTProcessor::markBusyKeys ( const int  best_hstrip,
const int  best_patid,
int  quality[CSCConstants::NUM_HALF_STRIPS] 
) [private]

Definition at line 2322 of file CSCCathodeLCTProcessor.cc.

References min_separation.

Referenced by findLCTs().

                                                                          {
  int nspan = min_separation;
  int pspan = min_separation;

  for (int hstrip = best_hstrip-nspan; hstrip <= best_hstrip+pspan; hstrip++) {
    if (hstrip >= 0 && hstrip < CSCConstants::NUM_HALF_STRIPS) {
      quality[hstrip] = 0;
    }
  }
} // markBusyKeys -- TMB-07 version.
bool CSCCathodeLCTProcessor::preTrigger ( const std::vector< int >  strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
const int  stripType,
const int  nStrips,
int &  first_bx 
) [private]

Definition at line 1157 of file CSCCathodeLCTProcessor.cc.

References fifo_tbins, nplanes_hit_pretrig, CSCConstants::NUM_LAYERS, NUM_PATTERN_STRIPS, pre_hit_pattern, pulseExtension(), and strip().

Referenced by findLCTs().

{
  static const int hs_thresh = nplanes_hit_pretrig;
  static const int ds_thresh = nplanes_hit_pretrig;

  unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS];
  int i_layer, i_strip, this_layer, this_strip;
  int hits, layers_hit;
  bool hit_layer[CSCConstants::NUM_LAYERS];

  const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;

  // Fire half-strip/di-strip one-shots for hit_persist bx's (6 bx's by
  // default).
  pulseExtension(strip, nStrips, pulse);

  // Now do a loop over different bunch-crossing times.
  for (unsigned int bx_time = 0; bx_time < fifo_tbins; bx_time++) {
    // For any given bunch-crossing, start at the lowest keystrip and look for
    // the number of separate layers in the pattern for that keystrip that have
    // pulses at that bunch-crossing time.  Do the same for the next keystrip, 
    // etc.  Then do the entire process again for the next bunch-crossing, etc
    // until you find a pre-trigger.
    for (int key_strip = 0; key_strip < nStrips; key_strip++){
      // Clear variables
      hits = 0;
      layers_hit = 0;
      for (i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++)
        hit_layer[i_layer] = false;
      // Loop over pattern strips and look for hits.
      for (i_strip = 0; i_strip < NUM_PATTERN_STRIPS; i_strip++){
        this_layer = pre_hit_pattern[0][i_strip];
        this_strip = pre_hit_pattern[1][i_strip]+key_strip;
        if (this_strip >= 0 && this_strip < nStrips) {
          // Perform bit operation to see if pulse is 1 at a certain bx_time.
          if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
            hits++;
            // Store number of layers hit.
            if (hit_layer[this_layer] == false) {
              hit_layer[this_layer] = true;
              layers_hit++;

              // Look if number of layers hit is greater or equal than some
              // pre-defined threshold.
              if (layers_hit >= pre_trigger_layer_min) {
                first_bx = bx_time;
                return true;
              }
            }
          }
        }
      }
    }
  }
  // If the pretrigger was never satisfied, then return false.
  return false;
} // preTrigger -- idealized version for MC studies.
bool CSCCathodeLCTProcessor::preTrigger ( const std::vector< int >  strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
unsigned int  pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
const int  stripType,
const int  nStrips,
const int  start_bx,
int &  first_bx 
) [private]

Definition at line 1476 of file CSCCathodeLCTProcessor.cc.

References fifo_tbins, infoV, LogTrace, preTrigLookUp(), pulseExtension(), and strip().

                                                                           {
  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
    << "....................PreTrigger...........................";

  if (start_bx == 0) {
    // Fire one-shots for hit_persist bx's (6 bx's by default).
    pulseExtension(strip, nStrips, pulse);
  }

  bool pre_trig = false;
  // Now do a loop over bx times to see (if/when) track goes over threshold
  for (unsigned int bx_time = start_bx; bx_time < fifo_tbins; bx_time++) {
    // For any given bunch-crossing, start at the lowest keystrip and look for
    // the number of separate layers in the pattern for that keystrip that have
    // pulses at that bunch-crossing time.  Do the same for the next keystrip, 
    // etc.  Then do the entire process again for the next bunch-crossing, etc
    // until you find a pre-trigger.
    pre_trig = preTrigLookUp(pulse, stripType, nStrips, bx_time);
    if (pre_trig) {
      first_bx = bx_time; // bx at time of pretrigger
      return true;
    }
  } // end loop over bx times

  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
    << "no pretrigger for strip type " << stripType << ", returning \n";
  first_bx = fifo_tbins;
  return false;
} // preTrigger -- pre-2007 version.
bool CSCCathodeLCTProcessor::preTrigger ( const unsigned int  pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
const int  start_bx,
int &  first_bx 
) [private]

Definition at line 2199 of file CSCCathodeLCTProcessor.cc.

References best_pid, fifo_tbins, infoV, CSCConstants::KEY_CLCT_LAYER, LogTrace, nhits, nplanes_hit_pretrig, numStrips, pid_thresh_pretrig, ptnFinding(), and stagger.

                                                                           {
  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
    << "....................PreTrigger...........................";

  // Max. number of half-strips for this chamber.
  const int nStrips = 2*numStrips + 1;

  bool pre_trig = false;
  // Now do a loop over bx times to see (if/when) track goes over threshold
  for (unsigned int bx_time = start_bx; bx_time < fifo_tbins; bx_time++) {
    // For any given bunch-crossing, start at the lowest keystrip and look for
    // the number of separate layers in the pattern for that keystrip that have
    // pulses at that bunch-crossing time.  Do the same for the next keystrip, 
    // etc.  Then do the entire process again for the next bunch-crossing, etc
    // until you find a pre-trigger.
    bool hits_in_time = ptnFinding(pulse, nStrips, bx_time);
    if (hits_in_time) {
      for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER-1];
           hstrip < nStrips; hstrip++) {
        if (infoV > 1) {
          if (nhits[hstrip] > 0) {
            LogTrace("CSCCathodeLCTProcessor")
              << " bx = " << std::setw(2) << bx_time << " --->"
              << " halfstrip = " << std::setw(3) << hstrip
              << " best pid = "  << std::setw(2) << best_pid[hstrip]
              << " nhits = "     << nhits[hstrip];
          }
        }
        if (nhits[hstrip]    >= nplanes_hit_pretrig &&
            best_pid[hstrip] >= pid_thresh_pretrig) {
          pre_trig = true;
        }
      }

      if (pre_trig) {
        first_bx = bx_time; // bx at time of pretrigger
        return true;
      }
    }
  } // end loop over bx times

  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor") <<
                   "no pretrigger, returning \n";
  first_bx = fifo_tbins;
  return false;
} // preTrigger -- TMB-07 version.
std::vector<int> CSCCathodeLCTProcessor::preTriggerBXs ( ) const [inline]

Definition at line 84 of file CSCCathodeLCTProcessor.h.

References thePreTriggerBXs.

Referenced by CSCTriggerPrimitivesBuilder::build().

{return thePreTriggerBXs;}
bool CSCCathodeLCTProcessor::preTrigLookUp ( const unsigned int  pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
const int  stripType,
const int  nStrips,
const unsigned int  bx_time 
) [private]

Definition at line 1512 of file CSCCathodeLCTProcessor.cc.

References cfeb_strips, infoV, LogTrace, MAX_CFEBS, nplanes_hit_pretrig, CSCConstants::NUM_LAYERS, NUM_PATTERN_STRIPS, and pre_hit_pattern.

Referenced by preTrigger().

                                       {
  static const int hs_thresh = nplanes_hit_pretrig;
  static const int ds_thresh = nplanes_hit_pretrig;

  bool hit_layer[CSCConstants::NUM_LAYERS];
  int key_strip, this_layer, this_strip, layers_hit;

  // Layers hit threshold for pretrigger
  const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;

  if (stripType != 0 && stripType != 1) {
    if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
      << "+++ preTrigLookUp: stripType = " << stripType
      << " does not correspond to half-strip/di-strip patterns! +++\n";
    return false;
  }

  for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) { // loop over cfebs
    // Loop over (di-/half-)strips in CFEB.
    for (int istrip = 0; istrip < cfeb_strips[stripType]; istrip++) {
      // Calculate candidate key.
      key_strip = icfeb*cfeb_strips[stripType] + istrip;
      layers_hit = 0;
      for (int ilayer = 0; ilayer < CSCConstants::NUM_LAYERS; ilayer++)
        hit_layer[ilayer] = false;

      // Loop over strips in pretrigger pattern mask and look for hits.
      for (int pstrip = 0; pstrip < NUM_PATTERN_STRIPS; pstrip++) {
        this_layer = pre_hit_pattern[0][pstrip];
        this_strip = pre_hit_pattern[1][pstrip]+key_strip;

        if (this_strip >= 0 && this_strip < nStrips) {
          // Determine if "one shot" is high at this bx_time
          if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
            if (hit_layer[this_layer] == false) {
              hit_layer[this_layer] = true;
              layers_hit++;                  // determines number of layers hit
              if (layers_hit >= pre_trigger_layer_min) {
                if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
                  << "pretrigger at bx: " << bx_time
                  << ", cfeb " << icfeb << ", returning";
                return true;
              }
            }
          }
        }
      } // end loop over strips in pretrigger pattern
    } // end loop over candidate key strips in cfeb
  } // end loop over cfebs, if pretrigger is found, stop looking and return

  return false;

} // preTrigLookUp -- pre-2007 version.
void CSCCathodeLCTProcessor::printPatterns ( ) [private]

Definition at line 2595 of file CSCCathodeLCTProcessor.cc.

References gather_cfg::cout, isTMB07, CSCConstants::KEY_CLCT_LAYER, CSCConstants::KEY_CLCT_LAYER_PRE_TMB07, CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07, CSCConstants::NUM_LAYERS, NUM_PATTERN_STRIPS, pattern, and strip().

                                           {
  // @@
  std::cout<<" Printing patterns for Cathode LCT"<<std::endl;
  std::cout<<"       ";
  for (int patternNum = 0; patternNum < CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07; patternNum++) {
    std::cout<<" Pattern "<<patternNum<<" ";
  }
  std::cout<<std::endl;
  std::cout<<" Layer ";
  for (int patternNum = 0; patternNum < CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07; patternNum++) {
    std::cout<<"   Bend "<<(pattern[patternNum][NUM_PATTERN_STRIPS]==0 ? "L": "R")<<"  ";
  }
  std::cout<<std::endl;
  for (int layer = 0; layer < CSCConstants::NUM_LAYERS; layer++) {
    for (int patternNum = 0; patternNum < CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07; patternNum++) {
      if (patternNum == 0) std::cout<<"   "<<layer<<"       ";
      if ((isTMB07  && layer != CSCConstants::KEY_CLCT_LAYER-1) ||
          (!isTMB07 && layer != CSCConstants::KEY_CLCT_LAYER_PRE_TMB07-1)) {//that old counting from 1 vs 0 thing.
        int minStrip =0;
        if ((isTMB07  && layer < CSCConstants::KEY_CLCT_LAYER-1) ||
            (!isTMB07 && layer < CSCConstants::KEY_CLCT_LAYER_PRE_TMB07-1)) {
          minStrip = 3*layer;
        } else {
          minStrip = 3*layer - 2;// since on the key layer we only have 1 strip
        }
        for (int strip = minStrip; strip < minStrip + 3; strip++) {
          if (layer == pattern[patternNum][strip]) {
            std::cout<<"X";
          } else {
            std::cout<<"_";
          }
        }
      } else {// on the key layer we always have a hit, right?
        std::cout<<" X ";
      }
      std::cout<<"        ";
    }
    std::cout<<std::endl;
  }
}
void CSCCathodeLCTProcessor::priorityEncode ( const int  h_keyStrip[MAX_CFEBS],
const unsigned int  h_nhits[MAX_CFEBS],
const int  d_keyStrip[MAX_CFEBS],
const unsigned int  d_nhits[MAX_CFEBS],
int  keystrip_data[2][7] 
) [private]

Definition at line 1636 of file CSCCathodeLCTProcessor.cc.

References cfeb_strips, CLCT_CFEB, CLCT_STRIP, CLCT_STRIP_TYPE, infoV, j, combine::key, LogTrace, MAX_CFEBS, and nplanes_hit_pretrig.

Referenced by findLCTs().

                                 {
  static const unsigned int hs_thresh = nplanes_hit_pretrig;
  //static const unsigned int ds_thresh = nplanes_hit_pretrig;

  int ihits[2]; // hold hits for sorting
  int cfebs[2]; // holds CFEB numbers corresponding to highest hits
  const int nlcts = 2;
  int key_strip[MAX_CFEBS], key_phits[MAX_CFEBS], strip_type[MAX_CFEBS];

  // initialize arrays
  for (int ilct = 0; ilct < nlcts; ilct++) {
    for (int j = 0; j < 7; j++) keystrip_data[ilct][j] = -1;
    ihits[ilct] = 0;
    cfebs[ilct] = -1;
  }
  for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
    key_strip[icfeb]  = -1;
    key_phits[icfeb]  = -1;
    strip_type[icfeb] = -1;
  }

  if (infoV > 1) {
    LogTrace("CSCCathodeLCTProcessor")
      << ".....................PriorityEncode.......................";
    std::ostringstream strstrm;
    strstrm << "hkeys:";
    for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
      strstrm << std::setw(4) << h_keyStrip[icfeb];
    }
    strstrm << "\ndkeys:";
    for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
      strstrm << std::setw(4) << d_keyStrip[icfeb];
    }
    LogTrace("CSCCathodeLCTProcessor") << strstrm.str();
  }

  // Loop over CFEBs and determine better of half- or di- strip pattern.
  // If select halfstrip, promote it by adding an extra bit to its hits.
  for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
    if (h_keyStrip[icfeb] != -1 && d_keyStrip[icfeb] != -1) {
      if (h_nhits[icfeb] >= hs_thresh) {
        key_strip[icfeb] = h_keyStrip[icfeb];
        key_phits[icfeb] = h_nhits[icfeb] + 8; // halfstrip promotion
        strip_type[icfeb]= 1;
      }
      // For di-strip envelope there is no requirement that the number of
      // layers hit is >= ds_thresh!!!
      // else if (d_nhits[icfeb] >= ds_thresh) {
      else {
        key_strip[icfeb] = d_keyStrip[icfeb];
        key_phits[icfeb] = d_nhits[icfeb];
        strip_type[icfeb]= 0;
      }
    }
    else if (h_keyStrip[icfeb] != -1) {
      if (h_nhits[icfeb] >= hs_thresh) {
        key_strip[icfeb] = h_keyStrip[icfeb];
        key_phits[icfeb] = h_nhits[icfeb] + 8; // halfstrip promotion
        strip_type[icfeb]= 1;
      }
    }
    else if (d_keyStrip[icfeb] != -1) {
      // if (d_nhits[icfeb] >= ds_thresh) {
        key_strip[icfeb] = d_keyStrip[icfeb];
        key_phits[icfeb] = d_nhits[icfeb];
        strip_type[icfeb]= 0;
      // }
    }
    if (infoV > 1 && strip_type[icfeb] != -1) {
      if (strip_type[icfeb] == 0)
        LogTrace("CSCCathodeLCTProcessor")
          << "  taking distrip pattern on cfeb " << icfeb;
      else if (strip_type[icfeb] == 1)
        LogTrace("CSCCathodeLCTProcessor")
          << "  taking halfstrip pattern on cfeb " << icfeb;
      LogTrace("CSCCathodeLCTProcessor")
        << "     cfeb " << icfeb << " key " << key_strip[icfeb]
        << " hits " << key_phits[icfeb] << " type " << strip_type[icfeb];
    }
  }

  // Remove duplicate LCTs at boundaries -- it is possilbe to have key[0]
  // be the higher of the two key strips, take this into account, but
  // preserve rank of lcts.
  int key[MAX_CFEBS];
  int loedge, hiedge;

  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
    << "...... Remove Duplicates ......";
  for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
    if(strip_type[icfeb] == 0) key[icfeb] = key_strip[icfeb]*4;
    else                       key[icfeb] = key_strip[icfeb];
  }
  for (int icfeb = 0; icfeb < MAX_CFEBS-1; icfeb++) {
    if (key[icfeb] >= 0 && key[icfeb+1] >= 0) {
      loedge = cfeb_strips[1]*(icfeb*8+7)/8;
      hiedge = cfeb_strips[1]*(icfeb*8+9)/8 - 1;
      if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
        << "  key 1: " << key[icfeb] << "  key 2: " << key[icfeb+1]
        << "  low edge:  " << loedge << "  high edge: " << hiedge;
      if (key[icfeb] >= loedge && key[icfeb+1] <= hiedge) {
        if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
          << "Duplicate LCTs found at boundary of CFEB " << icfeb << " ...";
        if (key_phits[icfeb+1] > key_phits[icfeb]) {
          if (infoV > 1) LogTrace("CSCCathodeLCTProcessor") 
            << "   deleting LCT on CFEB " << icfeb;
          key_strip[icfeb] = -1;
          key_phits[icfeb] = -1;
        }
        else {
          if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
            << "   deleting LCT on CFEB " << icfeb+1;
          key_strip[icfeb+1] = -1;
          key_phits[icfeb+1] = -1;
        }
      }
    }
  }

  // Now loop over CFEBs and pick best two lcts based on no. hits in envelope.
  // In case of equal quality, select the one on lower-numbered CFEBs.
  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
    << "\n...... Select best LCTs  ......";
  for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
    if (key_phits[icfeb] > ihits[0]) {
      ihits[1] = ihits[0];
      cfebs[1] = cfebs[0];
      ihits[0] = key_phits[icfeb];
      cfebs[0] = icfeb;
      if (infoV > 1) {
        std::ostringstream strstrm;
        for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
          strstrm << std::setw(4) << strip_type[icfeb];
        }
        LogTrace("CSCCathodeLCTProcessor")
          << "strip_type" << strstrm.str()
          << "\n best: ihits " << ihits[0] << " cfeb " << cfebs[0]
          << " strip_type " << ((cfebs[0] >= 0) ? strip_type[cfebs[0]] : -1)
          << "\n next: ihits " << ihits[1] << " cfeb " << cfebs[1]
          << " strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
      }
    }
    else if (key_phits[icfeb] > ihits[1]) {
      ihits[1] = key_phits[icfeb];
      cfebs[1] = icfeb;
      if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
        << "\n next: ihits " << ihits[1] << " cfeb " << cfebs[1]
        << " strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
    }
  }

  // fill lct data array key strip with 2 highest hit lcts (if they exist)
  int jlct = 0;
  for (int ilct = 0; ilct < nlcts; ilct++) {
    if (cfebs[ilct] != -1) {
      keystrip_data[jlct][CLCT_CFEB]       = cfebs[ilct];
      keystrip_data[jlct][CLCT_STRIP]      = key_strip[cfebs[ilct]];
      keystrip_data[jlct][CLCT_STRIP_TYPE] = strip_type[cfebs[ilct]];
      if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
        << "filling key: " << key_strip[cfebs[ilct]]
        << " type: " << strip_type[cfebs[ilct]];
      jlct++;
    }
  }
} // priorityEncode -- pre-2007 version.
bool CSCCathodeLCTProcessor::ptnFinding ( const unsigned int  pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
const int  nStrips,
const unsigned int  bx_time 
) [private]

Definition at line 2250 of file CSCCathodeLCTProcessor.cc.

References best_pid, fifo_tbins, infoV, CSCConstants::KEY_CLCT_LAYER, LogTrace, nhits, nplanes_hit_pretrig, CSCConstants::NUM_CLCT_PATTERNS, CSCConstants::NUM_LAYERS, NUM_PATTERN_HALFSTRIPS, pattern2007, pattern2007_offset, evf::utils::pid, pid_thresh_pretrig, and stagger.

Referenced by findLCTs(), and preTrigger().

                                                          {
  if (bx_time >= fifo_tbins) return false;

  // This loop is a quick check of a number of layers hit at bx_time: since
  // most of the time it is 0, this check helps to speed-up the execution
  // substantially.
  unsigned int layers_hit = 0;
  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
    for (int i_hstrip = 0; i_hstrip < nStrips; i_hstrip++) {
      if (((pulse[i_layer][i_hstrip] >> bx_time) & 1) == 1) {
        layers_hit++;
        break;
      }
    }
  }
  if (layers_hit < nplanes_hit_pretrig) return false;

  for (int key_hstrip = 0; key_hstrip < nStrips; key_hstrip++) {
    best_pid[key_hstrip] = 0;
    nhits[key_hstrip] = 0;
  }

  // Loop over candidate key strips.
  bool hit_layer[CSCConstants::NUM_LAYERS];
  for (int key_hstrip = stagger[CSCConstants::KEY_CLCT_LAYER-1];
       key_hstrip < nStrips; key_hstrip++) {
    // Loop over patterns and look for hits matching each pattern.
    for (unsigned int pid = CSCConstants::NUM_CLCT_PATTERNS-1;
         pid >= pid_thresh_pretrig; pid--) {
      layers_hit = 0;
      for (int ilayer = 0; ilayer < CSCConstants::NUM_LAYERS; ilayer++)
        hit_layer[ilayer] = false;

      // Loop over halfstrips in trigger pattern mask and calculate the
      // "absolute" halfstrip number for each.
      for (int strip_num = 0; strip_num < NUM_PATTERN_HALFSTRIPS;
           strip_num++) {
        int this_layer = pattern2007[pid][strip_num];
        if (this_layer >= 0 && this_layer < CSCConstants::NUM_LAYERS) {
          int this_strip = pattern2007_offset[strip_num] + key_hstrip;
          if (this_strip >= 0 && this_strip < nStrips) {
            if (infoV > 3) LogTrace("CSCCathodeLCTProcessor")
              << " In ptnFinding: key_strip = " << key_hstrip
              << " pid = " << pid << " strip_num = " << strip_num
              << " layer = " << this_layer << " strip = " << this_strip;
            // Determine if "one shot" is high at this bx_time
            if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
              if (hit_layer[this_layer] == false) {
                hit_layer[this_layer] = true;
                layers_hit++;     // determines number of layers hit
              }
            }
          }
        }
      } // end loop over strips in pretrigger pattern

      if (layers_hit > nhits[key_hstrip]) {
        best_pid[key_hstrip] = pid;
        nhits[key_hstrip] = layers_hit;
        // Do not loop over the other (worse) patterns if max. numbers of
        // hits is found.
        if (nhits[key_hstrip] == CSCConstants::NUM_LAYERS) break;
      }
    } // end loop over pid
  } // end loop over candidate key strips
  return true;
} // ptnFinding -- TMB-07 version.
void CSCCathodeLCTProcessor::pulseExtension ( const std::vector< int >  time[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
const int  nStrips,
unsigned int  pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS] 
) [private]

Definition at line 2152 of file CSCCathodeLCTProcessor.cc.

References hit_persist, i, infoV, CSCConstants::NUM_LAYERS, findQualityFiles::size, and cond::rpcobgas::time.

Referenced by findLCTs(), and preTrigger().

                                                                          {

  static unsigned int bits_in_pulse = 8*sizeof(pulse[0][0]);

  // Clear pulse array.  This array will be used as a bit representation of
  // hit times.  For example: if strip[1][2] has a value of 3, then 1 shifted
  // left 3 will be bit pattern of pulse[1][2].  This would make the pattern
  // look like 0000000000001000.  Then add on additional bits to signify
  // the duration of a signal (hit_persist, formerly bx_width) to simulate
  // the TMB's drift delay.  So for the same pulse[1][2] with a hit_persist
  // of 3 would look like 0000000000111000.  This is similating the digital
  // one-shot in the TMB.
  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++)
    for (int i_strip = 0; i_strip < nStrips; i_strip++)
      pulse[i_layer][i_strip] = 0;

  // Loop over all layers and halfstrips.
  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
    for (int i_strip = 0; i_strip < nStrips; i_strip++) {
      // If there is a hit, simulate digital one-shot persistence starting
      // in the bx of the initial hit.  Fill this into pulse[][].
      if (time[i_layer][i_strip].size() > 0) {
        std::vector<int> bx_times = time[i_layer][i_strip];
        for (unsigned int i = 0; i < bx_times.size(); i++) {
          // Check that min and max times are within the allowed range.
          if (bx_times[i] < 0 || bx_times[i] + hit_persist >= bits_in_pulse) {
            if (infoV > 0) edm::LogWarning("L1CSCTPEmulatorOutOfTimeDigi")
              << "+++ BX time of comparator digi (halfstrip = " << i_strip
              << " layer = " << i_layer << ") bx = " << bx_times[i]
              << " is not within the range (0-" << bits_in_pulse
              << "] allowed for pulse extension.  Skip this digi! +++\n";
            continue;
          }
          for (unsigned int bx = bx_times[i];
               bx < bx_times[i] + hit_persist; bx++)
            pulse[i_layer][i_strip] = pulse[i_layer][i_strip] | (1 << bx);
        }
      }
    }
  }
} // pulseExtension.
void CSCCathodeLCTProcessor::readComparatorDigis ( std::vector< int >  halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS]) [private]

Definition at line 730 of file CSCCathodeLCTProcessor.cc.

References begin, digiV, fifo_tbins, hit_persist, i, infoV, LogTrace, CSCConstants::NUM_LAYERS, numStrips, and stagger.

                                                                                       {
  // Single-argument version for TMB07 (halfstrip-only) firmware.
  // Takes the comparator & time info and stuffs it into halfstrip vector.
  // Multiple hits on the same strip are allowed.

  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
    int i_digi = 0; // digi counter, for dumps.
    for (std::vector<CSCComparatorDigi>::iterator pld = digiV[i_layer].begin();
         pld != digiV[i_layer].end(); pld++, i_digi++) {
      // Dump raw digi info.
      if (infoV > 1) {
        std::ostringstream strstrm;
        strstrm << "Comparator digi: comparator = " << pld->getComparator()
                << " strip #" << pld->getStrip()
                << " time bins on:";
        std::vector<int> bx_times = pld->getTimeBinsOn();
        for (unsigned int tbin = 0; tbin < bx_times.size(); tbin++)
          strstrm << " " << bx_times[tbin];
        LogTrace("CSCCathodeLCTProcessor") << strstrm.str();
      }

      // Get comparator: 0/1 for left/right halfstrip for each comparator
      // that fired.
      int thisComparator = pld->getComparator();
      if (thisComparator != 0 && thisComparator != 1) {
        if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
          << "+++ Found comparator digi with wrong comparator value = "
          << thisComparator << "; skipping it... +++\n";
        continue;
      }

      // Get strip number.
      int thisStrip = pld->getStrip() - 1; // count from 0
      if (thisStrip < 0 || thisStrip >= numStrips) {
        if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
          << "+++ Found comparator digi with wrong strip number = "
          << thisStrip
          << " (max strips = " << numStrips << "); skipping it... +++\n";
        continue;
      }
      // 2*strip: convert strip to 1/2 strip
      // comp   : comparator output
      // stagger: stagger for this layer
      int thisHalfstrip = 2*thisStrip + thisComparator + stagger[i_layer];
      if (thisHalfstrip >= 2*numStrips + 1) {
        if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
          << "+++ Found wrong halfstrip number = " << thisHalfstrip
          << "; skipping this digi... +++\n";
        continue;
      }

      // Get bx times on this digi and check that they are within the bounds.
      std::vector<int> bx_times = pld->getTimeBinsOn();
      for (unsigned int i = 0; i < bx_times.size(); i++) {
        // Total number of time bins in DAQ readout is given by fifo_tbins,
        // which thus determines the maximum length of time interval.
        //
        // In TMB07 version, better data-emulator agreement is
        // achieved when hits in the first 2 time bins are excluded.
        // As of May 2009, the reasons for this are not fully
        // understood yet (the work is on-going).
        if (bx_times[i] > 1 && bx_times[i] < static_cast<int>(fifo_tbins)) {

          if (i == 0 || (i > 0 && bx_times[i]-bx_times[i-1] >=
                         static_cast<int>(hit_persist))) {
            // A later hit on the same strip is ignored during the
            // number of clocks defined by the "hit_persist" parameter
            // (i.e., 6 bx's by default).
            if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
              << "Comp digi: layer " << i_layer+1
              << " digi #"           << i_digi+1
              << " strip "           << thisStrip
              << " halfstrip "       << thisHalfstrip
              << " distrip "         << thisStrip/2 + // [0-39]
                             ((thisStrip%2 == 1 && thisComparator == 1 && stagger[i_layer] == 1) ? 1 : 0)
              << " time "            << bx_times[i]
              << " comparator "      << thisComparator
              << " stagger "         << stagger[i_layer];
            halfstrip[i_layer][thisHalfstrip].push_back(bx_times[i]);
          }
          else if (i > 0) {
            if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
              << " Skipping comparator digi: strip = " << thisStrip
              << ", layer = " << i_layer+1 << ", bx = " << bx_times[i]
              << ", bx of previous hit = " << bx_times[i-1];
          }
        }
        else {
          if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
            << "+++ Skipping comparator digi: strip = " << thisStrip
            << ", layer = " << i_layer+1 << ", bx = " << bx_times[i] << " +++";
        }
      }
    }
  }
}
void CSCCathodeLCTProcessor::readComparatorDigis ( std::vector< int >  halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
std::vector< int >  distrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS] 
) [private]

Definition at line 828 of file CSCCathodeLCTProcessor.cc.

References digiV, distripStagger(), fifo_tbins, CSCComparatorDigi::getComparator(), CSCComparatorDigi::getStrip(), CSCComparatorDigi::getTimeBin(), i, infoV, isTMB07, j, LogTrace, CSCConstants::MAX_NUM_STRIPS, CSCConstants::NUM_LAYERS, numStrips, stagger, testDistripStagger(), and cond::rpcobgas::time.

Referenced by run().

                                                                               {
  // Two-argument version for pre-TMB07 (halfstrip and distrips) firmware.
  // Takes the comparator & time info and stuffs it into halfstrip and (and
  // possibly distrip) vector.

  int time[CSCConstants::NUM_LAYERS][CSCConstants::MAX_NUM_STRIPS];
  int comp[CSCConstants::NUM_LAYERS][CSCConstants::MAX_NUM_STRIPS];
  int digiNum[CSCConstants::NUM_LAYERS][CSCConstants::MAX_NUM_STRIPS];
  for (int i = 0; i < CSCConstants::NUM_LAYERS; i++){
    for (int j = 0; j < CSCConstants::MAX_NUM_STRIPS; j++) {
      time[i][j]    = -999;
      comp[i][j]    =    0;
      digiNum[i][j] = -999;
    }
  }

  for (int i = 0; i < CSCConstants::NUM_LAYERS; i++) {
    std::vector <CSCComparatorDigi> layerDigiV = digiV[i];
    for (unsigned int j = 0; j < layerDigiV.size(); j++) {
      // Get one digi at a time for the layer.  -Jm
      CSCComparatorDigi thisDigi = layerDigiV[j];

      // Dump raw digi info
      if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
        << "Comparator digi: comparator = " << thisDigi.getComparator()
        << " strip #" << thisDigi.getStrip()
        << " time bin = " << thisDigi.getTimeBin();

      // Get comparator: 0/1 for left/right halfstrip for each comparator
      // that fired.
      int thisComparator = thisDigi.getComparator();
      if (thisComparator != 0 && thisComparator != 1) {
        if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
          << "+++ Comparator digi with wrong comparator value: digi #" << j
          << ", comparator = " << thisComparator << "; skipping it... +++\n";
        continue;
      }

      // Get strip number.
      int thisStrip = thisDigi.getStrip() - 1; // count from 0
      if (thisStrip < 0 || thisStrip >= numStrips) {
        if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
          << "+++ Comparator digi with wrong strip number: digi #" << j
          << ", strip = " << thisStrip
          << ", max strips = " << numStrips << "; skipping it... +++\n";
        continue;
      }

      // Get Bx of this Digi and check that it is within the bounds
      int thisDigiBx = thisDigi.getTimeBin();

      // Total number of time bins in DAQ readout is given by fifo_tbins,
      // which thus determines the maximum length of time interval.
      if (thisDigiBx >= 0 && thisDigiBx < static_cast<int>(fifo_tbins)) {

        // If there is more than one hit in the same strip, pick one
        // which occurred earlier.
        // In reality, the second hit on the same distrip is ignored only
        // during the number of clocks defined by the "hit_persist" 
        // parameter (i.e., 6 bx's by default).  So if one simulates
        // a large number of bx's in a crowded environment, this
        // approximation here may not be sufficiently good.
        if (time[i][thisStrip] == -999 || time[i][thisStrip] > thisDigiBx) {
          digiNum[i][thisStrip] = j;
          time[i][thisStrip]    = thisDigiBx;
          comp[i][thisStrip]    = thisComparator;
          if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
            << "Comp digi: layer " << i+1
            << " digi #"           << j+1
            << " strip "           << thisStrip
            << " halfstrip "       << 2*thisStrip + comp[i][thisStrip] + stagger[i]
            << " distrip "         << thisStrip/2 + // [0-39]
              ((thisStrip%2 == 1 && comp[i][thisStrip] == 1 && stagger[i] == 1) ? 1 : 0)
            << " time "            <<    time[i][thisStrip]
            << " comparator "      <<    comp[i][thisStrip]
            << " stagger "         << stagger[i];
        }
      }
      else {
        if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
          << "+++ Skipping comparator digi: strip = " << thisStrip
          << ", layer = " << i+1 << ", bx = " << thisDigiBx << " +++";
      }
    }
  }

  // Take the comparator & time info and stuff it into half- and di-strip
  // arrays.
  for (int i = 0; i < CSCConstants::NUM_LAYERS; i++) {
    // Use the comparator info to setup the halfstrips and distrips.  -BT
    // This loop is only for halfstrips.
    for (int j = 0; j < CSCConstants::MAX_NUM_STRIPS; j++) {
      if (time[i][j] >= 0) {
        int i_halfstrip = 2*j + comp[i][j] + stagger[i];
        // 2*j    : convert strip to 1/2 strip
        // comp   : comparator output
        // stagger: stagger for this layer
        if (i_halfstrip >= 2*numStrips + 1) {
          if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
            << "+++ Found wrong halfstrip number = " << i_halfstrip
            << "; skipping this digi... +++\n";
          continue;
        }
        halfstrip[i][i_halfstrip].push_back(time[i][j]);
      }
    }

    // There are no di-strips in the 2007 version of the TMB firmware.
    if (!isTMB07) {
      // This loop is only for distrips.  We have to separate the routines
      // because triad and time arrays can be changed by the distripStagger
      // routine which could mess up the halfstrips.
      static int test_iteration = 0;
      for (int j = 0; j < CSCConstants::MAX_NUM_STRIPS; j++){
        if (time[i][j] >= 0) {
          int i_distrip = j/2;
          if (j%2 == 1 && comp[i][j] == 1 && stagger[i] == 1) {
            // @@ Needs to be checked.
            bool stagger_debug = (infoV > 2);
            distripStagger(comp[i], time[i], digiNum[i], j, stagger_debug);
          }
          // comp[i][j] == 1    : hit on right half-strip.
          // stagger[i] == 1    : half-strips are shifted by 1.
          // if these conditions are met add 1; otherwise add 0.
          // So if there is a hit on the far right half-strip, and the
          // half-strips have been staggered to the right, then the di-strip
          // would actually correspond to the next highest di-strip.  -JM
          if (infoV > 2 && test_iteration == 1) {
            testDistripStagger();
            test_iteration++;
          }
          if (i_distrip >= numStrips/2 + 1) {
            if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
              << "+++ Found wrong distrip number = " << i_distrip
              << "; skipping this digi... +++\n";
            continue;
          }
          distrip[i][i_distrip].push_back(time[i][j]);
        }
      }
    }
  }
}
std::vector< CSCCLCTDigi > CSCCathodeLCTProcessor::readoutCLCTs ( )

Returns vector of CLCTs in the read-out time window, if any.

Definition at line 2410 of file CSCCathodeLCTProcessor.cc.

References getCLCTs(), infoV, LogDebug, and MAX_CLCT_BINS.

Referenced by CSCTriggerPrimitivesBuilder::build().

                                                            {
  std::vector<CSCCLCTDigi> tmpV;

  // The start time of the L1A*CLCT coincidence window should be
  // related to the fifo_pretrig parameter, but I am not completely
  // sure how.  For now, just choose it such that the window is
  // centered at bx=7.  This may need further tweaking if the value of
  // tmb_l1a_window_size changes.
  // static int fpga_latency = 3;
  // static int early_tbins  = fifo_pretrig - fpga_latency;
  static int early_tbins = 4;
  // The number of CLCT bins in the read-out is given by the
  // tmb_l1a_window_size parameter, but made even by setting the LSB
  // of tmb_l1a_window_size to 0.
  //
  // Need to send tmb_l1a_window_size from CSCMotherboard!
  static int tmb_l1a_window_size = 7;
  static int lct_bins   = 
    (tmb_l1a_window_size%2 == 0) ? tmb_l1a_window_size : tmb_l1a_window_size-1;
  static int late_tbins = early_tbins + lct_bins;

  static int ifois = 0;
  if (ifois == 0) {
    if (infoV >= 0 && early_tbins < 0) {
      edm::LogWarning("L1CSCTPEmulatorSuspiciousParameters")
        << "+++ early_tbins = " << early_tbins
        << "; in-time CLCTs are not getting read-out!!! +++" << "\n";
    }

    if (late_tbins > MAX_CLCT_BINS-1) {
      if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorSuspiciousParameters")
        << "+++ Allowed range of time bins, [0-" << late_tbins
        << "] exceeds max allowed, " << MAX_CLCT_BINS-1 << " +++\n"
        << "+++ Set late_tbins to max allowed +++\n";
      late_tbins = MAX_CLCT_BINS-1;
    }
    ifois = 1;
  }

  // Start from the vector of all found CLCTs and select those within
  // the CLCT*L1A coincidence window.
  int bx_readout = -1;
  std::vector<CSCCLCTDigi> all_lcts = getCLCTs();
  for (std::vector <CSCCLCTDigi>::const_iterator plct = all_lcts.begin();
       plct != all_lcts.end(); plct++) {
    if (!plct->isValid()) continue;

    int bx = (*plct).getBX();
    // Skip CLCTs found too early relative to L1Accept.
    if (bx <= early_tbins) {
      if (infoV > 1) LogDebug("CSCCathodeLCTProcessor")
        << " Do not report CLCT on key halfstrip " << plct->getKeyStrip()
        << ": found at bx " << bx << ", whereas the earliest allowed bx is "
        << early_tbins+1;
      continue;
    }

    // Skip CLCTs found too late relative to L1Accept.
    if (bx > late_tbins) {
      if (infoV > 1) LogDebug("CSCCathodeLCTProcessor")
        << " Do not report CLCT on key halfstrip " << plct->getKeyStrip()
        << ": found at bx " << bx << ", whereas the latest allowed bx is "
        << late_tbins;
      continue;
    }

    // For now, take only CLCTs in the earliest bx in the read-out window:
    // in digi->raw step, CLCTs have to be packed into the TMB header, and
    // there is room just for two.
    if (bx_readout == -1 || bx == bx_readout) {
      tmpV.push_back(*plct);
      if (bx_readout == -1) bx_readout = bx;
    }
  }
  return tmpV;
}
void CSCCathodeLCTProcessor::run ( const std::vector< int >  halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
const std::vector< int >  distrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS] 
)

Called in test mode and by the run(compdc) function; does the actual LCT finding.

Definition at line 592 of file CSCCathodeLCTProcessor.cc.

References bestCLCT, CSCTriggerNumbering::chamberFromTriggerLabels(), findLCTs(), i, infoV, isMTCC, isTMB07, LogDebug, MAX_CLCT_BINS, CSCTriggerNumbering::ringFromTriggerLabels(), secondCLCT, CSCCLCTDigi::setTrknmb(), python::multivaluedict::sort(), theEndcap, theSector, theStation, theSubsector, and theTrigChamber.

                                                                                     {
  // This version of the run() function can either be called in a standalone
  // test, being passed the halfstrip and distrip times, or called by the 
  // run() function above.  It uses the findLCTs() method to find vectors
  // of LCT candidates. These candidates are sorted and the best two per bx
  // are returned.
  std::vector<CSCCLCTDigi> LCTlist;

  if (isTMB07) { // TMB07 (latest) version of the CLCT algorithm.
    LCTlist = findLCTs(halfstrip);
  }
  else if (isMTCC) { // MTCC version.
    LCTlist = findLCTs(halfstrip, distrip);
  }
  else { // Idealized algorithm of many years ago.
    std::vector<CSCCLCTDigi> halfStripLCTs = findLCTs(halfstrip, 1);
    std::vector<CSCCLCTDigi> diStripLCTs   = findLCTs(distrip,   0);
    // Put all the candidates into a single vector and sort them.
    for (unsigned int i = 0; i < halfStripLCTs.size(); i++)
      LCTlist.push_back(halfStripLCTs[i]);
    for (unsigned int i = 0; i < diStripLCTs.size(); i++)
      LCTlist.push_back(diStripLCTs[i]);
  }

  // LCT sorting.
  if (LCTlist.size() > 1)
    sort(LCTlist.begin(), LCTlist.end(), std::greater<CSCCLCTDigi>());

  // Take the best two candidates per bx.
  for (std::vector<CSCCLCTDigi>::const_iterator plct = LCTlist.begin();
       plct != LCTlist.end(); plct++) {
    int bx = plct->getBX();
    if (bx >= MAX_CLCT_BINS) {
      if (infoV > 0) edm::LogWarning("L1CSCTPEmulatorOutOfTimeCLCT")
        << "+++ Bx of CLCT candidate, " << bx << ", exceeds max allowed, "
        << MAX_CLCT_BINS-1 << "; skipping it... +++\n";
      continue;
    }

    if (!bestCLCT[bx].isValid()) bestCLCT[bx] = *plct;
    else if (!secondCLCT[bx].isValid()) {
      // Ignore CLCT if it is the same as the best (i.e. if the same
      // CLCT was found in both half- and di-strip pattern search).
      // This can never happen in the test beam and MTCC
      // implementations.
      if (!isMTCC && !isTMB07 && *plct == bestCLCT[bx]) continue;
      secondCLCT[bx] = *plct;
    }
  }

  for (int bx = 0; bx < MAX_CLCT_BINS; bx++) {
    if (bestCLCT[bx].isValid()) {
      bestCLCT[bx].setTrknmb(1);
      if (infoV > 0) LogDebug("CSCCathodeLCTProcessor")
        << bestCLCT[bx] << " found in ME" << ((theEndcap == 1) ? "+" : "-")
        << theStation << "/"
        << CSCTriggerNumbering::ringFromTriggerLabels(theStation,
                                                      theTrigChamber) << "/"
        << CSCTriggerNumbering::chamberFromTriggerLabels(theSector,
                            theSubsector, theStation, theTrigChamber)
        << " (sector " << theSector << " subsector " << theSubsector
        << " trig id. " << theTrigChamber << ")" << "\n";
    }
    if (secondCLCT[bx].isValid()) {
      secondCLCT[bx].setTrknmb(2);
      if (infoV > 0) LogDebug("CSCCathodeLCTProcessor")
        << secondCLCT[bx] << " found in ME" << ((theEndcap == 1) ? "+" : "-")
        << theStation << "/"
        << CSCTriggerNumbering::ringFromTriggerLabels(theStation,
                                                      theTrigChamber) << "/"
        << CSCTriggerNumbering::chamberFromTriggerLabels(theSector,
                            theSubsector, theStation, theTrigChamber)
        << " (sector " << theSector << " subsector " << theSubsector
        << " trig id. " << theTrigChamber << ")" << "\n";
    }
  }
  // Now that we have our best CLCTs, they get correlated with the best
  // ALCTs and then get sent to the MotherBoard.  -JM
}
std::vector< CSCCLCTDigi > CSCCathodeLCTProcessor::run ( const CSCComparatorDigiCollection compdc)

Runs the LCT processor code. Called in normal running -- gets info from a collection of comparator digis.

Definition at line 466 of file CSCCathodeLCTProcessor.cc.

References CSCTriggerGeomManager::chamber(), CSCTriggerNumbering::chamberFromTriggerLabels(), relativeConstraints::empty, CSCLayer::geometry(), reco::get(), getCLCTs(), getDigis(), infoV, isTMB07, CSCChamber::layer(), CSCConstants::MAX_NUM_STRIPS, nplanes_hit_pattern, CSCConstants::NUM_HALF_STRIPS, CSCConstants::NUM_LAYERS, CSCLayerGeometry::numberOfStrips(), numStrips, readComparatorDigis(), CSCTriggerNumbering::ringFromTriggerLabels(), stagger, CSCLayerGeometry::stagger(), theEndcap, theSector, theStation, theSubsector, and theTrigChamber.

Referenced by CSCMotherboard::run().

                                                                     {
  // This is the version of the run() function that is called when running
  // over the entire detector.  It gets the comparator & timing info from the
  // comparator digis and then passes them on to another run() function.

  // clear(); // redundant; called by L1MuCSCMotherboard.

  // Get the number of strips and stagger of layers for the given chamber.
  // Do it only once per chamber.
  if (numStrips == 0) {
    CSCTriggerGeomManager* theGeom = CSCTriggerGeometry::get();
    CSCChamber* theChamber = theGeom->chamber(theEndcap, theStation, theSector,
                                              theSubsector, theTrigChamber);
    if (theChamber) {
      numStrips = theChamber->layer(1)->geometry()->numberOfStrips();
      // ME1/a is known to the readout hardware as strips 65-80 of ME1/1.
      // Still need to decide whether we do any special adjustments to
      // reconstruct LCTs in this region (3:1 ganged strips); for now, we
      // simply allow for hits in ME1/a and apply standard reconstruction
      // to them.
      if (theStation == 1 &&
          CSCTriggerNumbering::ringFromTriggerLabels(theStation,
                                                     theTrigChamber) == 1) {
        numStrips = 80;
      }

      if (numStrips > CSCConstants::MAX_NUM_STRIPS) {
        if (infoV >= 0) edm::LogError("L1CSCTPEmulatorSetupError")
          << "+++ Number of strips, " << numStrips
          << " found in ME" << ((theEndcap == 1) ? "+" : "-")
          << theStation << "/"
          << CSCTriggerNumbering::ringFromTriggerLabels(theStation,
                                                        theTrigChamber) << "/"
          << CSCTriggerNumbering::chamberFromTriggerLabels(theSector,
                              theSubsector, theStation, theTrigChamber)
          << " (sector " << theSector << " subsector " << theSubsector
          << " trig id. " << theTrigChamber << ")"
          << " exceeds max expected, " << CSCConstants::MAX_NUM_STRIPS
          << " +++\n" 
          << "+++ CSC geometry looks garbled; no emulation possible +++\n";
        numStrips = -1;
      }
      // The strips for a given layer may be offset from the adjacent layers.
      // This was done in order to improve resolution.  We need to find the
      // 'staggering' for each layer and make necessary conversions in our
      // arrays.  -JM
      // In the TMB-07 firmware, half-strips in odd layers (layers are
      // counted as ly0-ly5) are shifted by -1 half-strip, whereas in
      // the previous firmware versions half-strips in even layers
      // were shifted by +1 half-strip.  This difference is due to a
      // change from ly3 to ly2 in the choice of the key layer, and
      // the intention to keep half-strips in the key layer unchanged.
      // In the emulator, we use the old way for both cases, to avoid
      // negative half-strip numbers.  This will necessitate a
      // subtraction of 1 half-strip for TMB-07 later on. -SV.
      for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
        stagger[i_layer] =
          (theChamber->layer(i_layer+1)->geometry()->stagger() + 1) / 2;
      }
    }
    else {
      if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
        << " ME" << ((theEndcap == 1) ? "+" : "-") << theStation << "/"
        << CSCTriggerNumbering::ringFromTriggerLabels(theStation,
                                                      theTrigChamber) << "/"
        << CSCTriggerNumbering::chamberFromTriggerLabels(theSector,
                            theSubsector, theStation, theTrigChamber)
        << " (sector " << theSector << " subsector " << theSubsector
        << " trig id. " << theTrigChamber << ")"
        << " is not defined in current geometry! +++\n"
        << "+++ CSC geometry looks garbled; no emulation possible +++\n";
      numStrips = -1;
    }
  }

  if (numStrips < 0) {
    if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
      << " ME" << ((theEndcap == 1) ? "+" : "-") << theStation << "/"
      << CSCTriggerNumbering::ringFromTriggerLabels(theStation,
                                                    theTrigChamber) << "/"
      << CSCTriggerNumbering::chamberFromTriggerLabels(theSector,
                          theSubsector, theStation, theTrigChamber)
      << " (sector " << theSector << " subsector " << theSubsector
      << " trig id. " << theTrigChamber << "):"
      << " numStrips = " << numStrips << "; CLCT emulation skipped! +++";
    std::vector<CSCCLCTDigi> emptyV;
    return emptyV;
  }

  // Get comparator digis in this chamber.
  bool noDigis = getDigis(compdc);

  if (!noDigis) {
    // Get halfstrip (and possibly distrip) times from comparator digis.
    std::vector<int>
      halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS];
    std::vector<int>
      distrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS];
    if (isTMB07) { // TMB07 (latest) version: halfstrips only.
      readComparatorDigis(halfstrip);
    }
    else { // Earlier versions: halfstrips and distrips.
      readComparatorDigis(halfstrip, distrip);
    }

    // Pass arrays of halfstrips and distrips on to another run() doing the
    // LCT search.
    // If the number of layers containing digis is smaller than that
    // required to trigger, quit right away.  (If LCT-based digi suppression
    // is implemented one day, this condition will have to be changed
    // to the number of planes required to pre-trigger.)
    unsigned int layersHit = 0;
    for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
      for (int i_hstrip = 0; i_hstrip < CSCConstants::NUM_HALF_STRIPS;
           i_hstrip++) {
        if (!halfstrip[i_layer][i_hstrip].empty()) {layersHit++; break;}
      }
    }
    if (layersHit >= nplanes_hit_pattern) run(halfstrip, distrip);
  }

  // Return vector of CLCTs.
  std::vector<CSCCLCTDigi> tmpV = getCLCTs();
  return tmpV;
}
void CSCCathodeLCTProcessor::setConfigParameters ( const CSCDBL1TPParameters conf)
void CSCCathodeLCTProcessor::setDefaultConfigParameters ( ) [private]
void CSCCathodeLCTProcessor::testDistripStagger ( ) [private]

Definition at line 2501 of file CSCCathodeLCTProcessor.cc.

References gather_cfg::cout, debug, distripStagger(), i, and CSCConstants::NUM_DI_STRIPS.

Referenced by readComparatorDigis().

                                                {
  // Author: Jason Mumford (mumford@physics.ucla.edu)
  // This routine tests the distripStagger routine.
  // @@
  bool debug = true;
  int test_triad[CSCConstants::NUM_DI_STRIPS], test_time[CSCConstants::NUM_DI_STRIPS];
  int test_digi[CSCConstants::NUM_DI_STRIPS];
  int distrip = 0;
  test_triad[distrip] = 3;    //After routine, I expect 4
  test_triad[distrip+1] = 3;  //                        4
  test_triad[distrip+2] = 3;  //                        4 
  test_triad[distrip+3] = 3;  //                        4
  test_triad[distrip+4] = 3;  //                        4
  test_triad[distrip+5] = 3;  //                        4
  test_triad[distrip+6] = 3;  //                        4
  test_triad[distrip+7] = 3;  //                        4
  test_triad[distrip+8] = 3;  //                        4
  test_triad[distrip+9] = 3;  //                        4
  test_triad[distrip+10] = 2;  //                       2

  test_time[distrip] = 4;     //      ""      ""        0
  test_time[distrip+1] = 10;  //                        4
  test_time[distrip+2] = 2;   //                        10
  test_time[distrip+3] = 0;   //                        2
  test_time[distrip+4] = 6;   //                        2
  test_time[distrip+5] = 8;   //                        2
  test_time[distrip+6] = 10;   //                        2
  test_time[distrip+7] = 1;   //                        2
  test_time[distrip+8] = 8;   //                        2
  test_time[distrip+9] = 5;   //                        2
  test_time[distrip+10] = 6;   //                        2

  std::cout << "\n ------------------------------------------------- \n";
  std::cout << "!!!!!!Testing distripStagger routine!!!!!!" << std::endl;
  std::cout << "Values before distripStagger routine:" << std::endl;
  for (int i=distrip; i<distrip+11; i++){
    test_digi[i] = 999;
    std::cout << "test_triad[" << i << "] = " << test_triad[i];
    std::cout << "   test_time[" << i << "] = " << test_time[i] << std::endl;
  }
  distripStagger(test_triad, test_time, test_digi, distrip, debug);
  std::cout << "Values after distripStagger routine:" << std::endl;
  for (int i=distrip; i<distrip+11; i++){
    std::cout << "test_triad[" << i << "] = " << test_triad[i];
    std::cout << "   test_time[" << i << "] = " << test_time[i] << std::endl;
  }
  std::cout << "\n ------------------------------------------------- \n \n";
}
void CSCCathodeLCTProcessor::testLCTs ( ) [private]

Definition at line 2550 of file CSCCathodeLCTProcessor.cc.

References CSCCLCTDigi::getBend(), CSCCLCTDigi::getBX(), CSCCLCTDigi::getCFEB(), CSCCLCTDigi::getKeyStrip(), CSCCLCTDigi::getPattern(), CSCCLCTDigi::getQuality(), CSCCLCTDigi::getStripType(), LogTrace, and MAX_CFEBS.

                                      {
  // test to make sure what goes into an LCT is what comes out.
  for (int ptn = 0; ptn < 8; ptn++) {
    for (int bend = 0; bend < 2; bend++) {
      for (int cfeb = 0; cfeb < MAX_CFEBS; cfeb++) {
        for (int key_strip = 0; key_strip < 32; key_strip++) {
          for (int bx = 0; bx < 7; bx++) {
            for (int stripType = 0; stripType < 2; stripType++) {
              for (int quality = 3; quality < 6; quality++) {
                CSCCLCTDigi thisLCT(1, quality, ptn, stripType, bend,
                                    key_strip, cfeb, bx);
                if (ptn != thisLCT.getPattern())
                  LogTrace("CSCCathodeLCTProcessor")
                    << "pattern mismatch: " << ptn << " "
                    << thisLCT.getPattern();
                if (bend != thisLCT.getBend())
                  LogTrace("CSCCathodeLCTProcessor")
                    << "bend mismatch: " << bend << " " << thisLCT.getBend();
                if (cfeb != thisLCT.getCFEB()) 
                  LogTrace("CSCCathodeLCTProcessor")
                    << "cfeb mismatch: " << cfeb << " " << thisLCT.getCFEB();
                if (key_strip != thisLCT.getKeyStrip())
                  LogTrace("CSCCathodeLCTProcessor")
                    << "strip mismatch: " << key_strip << " "
                    << thisLCT.getKeyStrip();
                if (bx != thisLCT.getBX())
                  LogTrace("CSCCathodeLCTProcessor")
                    << "bx mismatch: " << bx << " " << thisLCT.getBX();
                if (stripType != thisLCT.getStripType())
                  LogTrace("CSCCathodeLCTProcessor")
                    << "Strip Type mismatch: " << stripType << " "
                    << thisLCT.getStripType();
                if (quality != thisLCT.getQuality())
                  LogTrace("CSCCathodeLCTProcessor")
                    << "quality mismatch: " << quality << " "
                    << thisLCT.getQuality();
              }
            }
          }
        }
      }
    }
  }
}
void CSCCathodeLCTProcessor::testPatterns ( ) [private]

Definition at line 2636 of file CSCCathodeLCTProcessor.cc.

References gather_cfg::cout, relativeConstraints::empty, findLCTs(), findNumLayersHit(), getPattern(), isTMB07, CSCConstants::KEY_CLCT_LAYER, CSCConstants::KEY_CLCT_LAYER_PRE_TMB07, CSCConstants::NUM_HALF_STRIPS, CSCConstants::NUM_LAYERS, convertSQLitetoXML_cfg::output, pattern, python::entryComment::results, and strip().

                                          {
//generate all possible combinations of hits in a given area and see what we find.
// Benn Tannenbaum 21 June 2001
  
  //there are 16 strips in our uber-pattern, each of which can be on or off.
  // 2^16 = 65536
  for (int possibleHits = 0; possibleHits < 65536; possibleHits++) {
    std::vector<int> stripsHit[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS];
    //assign one bit to each strip in an array. I'll start centered around strip 10.
    stripsHit[0][ 9].push_back(( possibleHits &     1 ) != 0);     // 2^0
    stripsHit[0][10].push_back(( possibleHits &     2 ) != 0);     // 2^1
    stripsHit[0][11].push_back(( possibleHits &     4 ) != 0);     // 2^2
    stripsHit[1][ 9].push_back(( possibleHits &     8 ) != 0);     // 2^3
    stripsHit[1][10].push_back(( possibleHits &    16 ) != 0);     // 2^4
    stripsHit[1][11].push_back(( possibleHits &    32 ) != 0);     // 2^5
    stripsHit[2][ 9].push_back(( possibleHits &    64 ) != 0);     // 2^6
    stripsHit[2][10].push_back(( possibleHits &   128 ) != 0);     // 2^7
    stripsHit[2][11].push_back(( possibleHits &   256 ) != 0);     // 2^8
    stripsHit[3][10].push_back(( possibleHits &   512 ) != 0);     // 2^9
    stripsHit[4][ 9].push_back(( possibleHits &  1024 ) != 0);     // 2^10
    stripsHit[4][10].push_back(( possibleHits &  2048 ) != 0);     // 2^11
    stripsHit[4][11].push_back(( possibleHits &  4096 ) != 0);     // 2^12
    stripsHit[5][ 9].push_back(( possibleHits &  8192 ) != 0);     // 2^13
    stripsHit[5][10].push_back(( possibleHits & 16384 ) != 0);     // 2^14
    stripsHit[5][11].push_back(( possibleHits & 32768 ) != 0);     // 2^15
    int numLayersHit = findNumLayersHit(stripsHit);
    std::vector <CSCCLCTDigi> results = findLCTs(stripsHit, 1);
// print out whatever we find-- but only ones where 4 or more layers are hit
// OR ones where we find something
// key: X    a hit there and was used to find pattern
//      x    a hit not involved in pattern
//      _    empty strip
//      o    a hit was there, but no pattern was found
    if (numLayersHit > 3 || results.size() > 0) {
      std::cout<<"Input "<<possibleHits<<"/"<< 65536 <<" # Found Patterns "<<results.size()<<std::endl<<" ";
      for (int layer = 0; layer < CSCConstants::NUM_LAYERS; layer++) {
        if ((isTMB07  && layer != CSCConstants::KEY_CLCT_LAYER - 1) || 
            (!isTMB07 && layer != CSCConstants::KEY_CLCT_LAYER_PRE_TMB07 - 1)) {
          for (int strip = 9; strip < 12; strip++) {
            if (!stripsHit[layer][strip].empty()) {
              if (results.size() > 0) {
                int thePatternStrip = strip - (results[0].getKeyStrip() - 2) + 3*layer;
                if ((isTMB07 && layer>=CSCConstants::KEY_CLCT_LAYER) ||
                    (!isTMB07 && layer>=CSCConstants::KEY_CLCT_LAYER_PRE_TMB07))
                  thePatternStrip -= 2;

                if (pattern[results[0].getPattern()][thePatternStrip] == layer)
                {
                  std::cout<<"X";
                } else {
                  std::cout<<"x";
                }
              } else {
                std::cout<<"o";
              }
            } else {
              std::cout<<"_";
            }
          }
          std::cout<<"   ";
          for (unsigned int output = 0; output < results.size(); output++) {
            int minStrip;
            if ((isTMB07 && layer < CSCConstants::KEY_CLCT_LAYER-1) ||
                (!isTMB07 && layer < CSCConstants::KEY_CLCT_LAYER_PRE_TMB07-1))  {
              minStrip = 3*layer;
            } else {
              minStrip = 3*layer - 2;// since on the key layer we only have 1 strip
            }
            for (int strip = minStrip; strip < minStrip + 3; strip++) {
              if (layer == pattern[results[output].getPattern()][strip]) {
                std::cout<<"X";
              } else {
                std::cout<<"_";
              }
            }
            std::cout<<"  ";
          }
        } else {
          if (!stripsHit[layer][10].empty()) {
            std::cout<<" X ";
          } else {
            std::cout<<" _ ";
          }
          for (unsigned int output = 0; output < results.size(); output++)
            std::cout<<"    X   ";
        }
        if (layer < static_cast<int>(results.size()) ) {
          std::cout<<results[layer];
          std::cout<<" ";
        } else {
          std::cout<<" "<<std::endl<<" ";
        }
      }
    }
  }
}

Member Data Documentation

unsigned int CSCCathodeLCTProcessor::best_pid[CSCConstants::NUM_HALF_STRIPS] [private]

Definition at line 219 of file CSCCathodeLCTProcessor.h.

Referenced by findLCTs(), preTrigger(), and ptnFinding().

Best LCT in this chamber, as found by the processor.

Definition at line 73 of file CSCCathodeLCTProcessor.h.

Referenced by clear(), getCLCTs(), CSCMotherboard::run(), and run().

const int CSCCathodeLCTProcessor::cfeb_strips = { 8, 32} [static, private]

Number of di-strips/half-strips per CFEB.

Definition at line 154 of file CSCCathodeLCTProcessor.h.

Referenced by dumpDigis(), findLCTs(), latchLCTs(), preTrigLookUp(), and priorityEncode().

const unsigned int CSCCathodeLCTProcessor::def_drift_delay = 2 [private]

Definition at line 142 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_fifo_pretrig = 7 [private]

Definition at line 141 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_fifo_tbins = 12 [static, private]

Default values of configuration parameters.

Definition at line 141 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_hit_persist = 6 [static, private]

Definition at line 142 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_min_separation = 10 [private]

Definition at line 145 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_nplanes_hit_pattern = 4 [static, private]

Definition at line 144 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_nplanes_hit_pretrig = 2 [static, private]

Definition at line 143 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_pid_thresh_pretrig = 2 [static, private]

Definition at line 145 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

std::vector<CSCComparatorDigi> CSCCathodeLCTProcessor::digiV[CSCConstants::NUM_LAYERS] [private]

Definition at line 125 of file CSCCathodeLCTProcessor.h.

Referenced by getDigis(), and readComparatorDigis().

unsigned int CSCCathodeLCTProcessor::drift_delay [private]
unsigned int CSCCathodeLCTProcessor::fifo_pretrig [private]
unsigned int CSCCathodeLCTProcessor::fifo_tbins [private]
unsigned int CSCCathodeLCTProcessor::hit_persist [private]

Verbosity level: 0: no print (default). 1: print only CLCTs found. 2: info at every step of the algorithm. 3: add special-purpose prints.

Definition at line 113 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), CSCCathodeLCTProcessor(), findLCTs(), getDigis(), getKeyStripData(), latchLCTs(), preTrigger(), preTrigLookUp(), priorityEncode(), ptnFinding(), pulseExtension(), readComparatorDigis(), readoutCLCTs(), and run().

Flag for "real" - not idealized - version of the algorithm.

Definition at line 129 of file CSCCathodeLCTProcessor.h.

Referenced by CSCCathodeLCTProcessor(), run(), and setDefaultConfigParameters().

unsigned int CSCCathodeLCTProcessor::nhits[CSCConstants::NUM_HALF_STRIPS] [private]

Definition at line 220 of file CSCCathodeLCTProcessor.h.

Referenced by findLCTs(), preTrigger(), and ptnFinding().

const int CSCCathodeLCTProcessor::pattern [static]

Definition at line 94 of file CSCCathodeLCTProcessor.h.

Referenced by getPattern(), printPatterns(), and testPatterns().

Definition at line 98 of file CSCCathodeLCTProcessor.h.

Referenced by findLCTs(), and ptnFinding().

Initial value:
  {  -5,  -4,  -3,  -2,  -1,   0,   1,   2,   3,   4,   5,
                    -2,  -1,   0,   1,   2,
                               0,
                    -2,  -1,   0,   1,   2,
          -4,  -3,  -2,  -1,   0,   1,   2,   3,   4,
     -5,  -4,  -3,  -2,  -1,   0,   1,   2,   3,   4,   5 }

Definition at line 97 of file CSCCathodeLCTProcessor.h.

Referenced by ptnFinding().

Initial value:
 {
  { 999,  0,  0,  0,  999,
    999,  1,  1,  1,  999,
    999,  2,  2,  2,  999,
              3,                
    999,  4,  4,  4,  999,
    999,  5,  5,  5,  999},
  
  { 999, -1,  0,  1,  999,
    999, -1,  0,  1,  999,
    999, -1,  0,  1,  999,
              0,                
    999, -1,  0,  1,  999,
    999, -1,  0,  1,  999}
}

Definition at line 93 of file CSCCathodeLCTProcessor.h.

Referenced by getKeyStripData(), latchLCTs(), preTrigger(), and preTrigLookUp().

Second best LCT in this chamber, as found by the processor.

Definition at line 76 of file CSCCathodeLCTProcessor.h.

Referenced by clear(), getCLCTs(), CSCMotherboard::run(), and run().

int CSCCathodeLCTProcessor::stagger[CSCConstants::NUM_LAYERS] [private]
const unsigned CSCCathodeLCTProcessor::theEndcap [private]

Chamber id (trigger-type labels).

Definition at line 116 of file CSCCathodeLCTProcessor.h.

Referenced by dumpDigis(), getDigis(), and run().

std::vector<int> CSCCathodeLCTProcessor::thePreTriggerBXs [private]

Definition at line 126 of file CSCCathodeLCTProcessor.h.

Referenced by clear(), findLCTs(), and preTriggerBXs().

const unsigned CSCCathodeLCTProcessor::theSector [private]

Definition at line 118 of file CSCCathodeLCTProcessor.h.

Referenced by dumpDigis(), getDigis(), and run().

const unsigned CSCCathodeLCTProcessor::theStation [private]

Definition at line 117 of file CSCCathodeLCTProcessor.h.

Referenced by dumpDigis(), getDigis(), and run().

const unsigned CSCCathodeLCTProcessor::theSubsector [private]

Definition at line 119 of file CSCCathodeLCTProcessor.h.

Referenced by dumpDigis(), getDigis(), and run().

const unsigned CSCCathodeLCTProcessor::theTrigChamber [private]

Definition at line 120 of file CSCCathodeLCTProcessor.h.

Referenced by dumpDigis(), getDigis(), and run().