CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | 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>

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, const edm::ParameterSet &ctmb)
 
 CSCCathodeLCTProcessor ()
 
std::vector< CSCCLCTDigigetCLCTs ()
 
bool getDigis (const CSCComparatorDigiCollection *compdc)
 
void getDigis (const CSCComparatorDigiCollection *compdc, const CSCDetId &id)
 
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)
 
void setRing (unsigned r)
 

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+2]
 
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 > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], int stripType)
 
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 > halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
 
std::vector< CSCCLCTDigifindLCTsSLHC (const std::vector< int > halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
 
int findNumLayersHit (std::vector< int > stripsHit[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
 
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 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 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 std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips, 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 unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int start_bx, 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], std::vector< int > distrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
 
void readComparatorDigis (std::vector< int > halfstrip[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]
 
unsigned int clct_state_machine_zone
 
std::vector< CSCComparatorDigidigiV [CSCConstants::NUM_LAYERS]
 
bool disableME1a
 
unsigned int drift_delay
 
bool dynamic_state_machine_zone
 
int early_tbins
 
unsigned int fifo_pretrig
 
unsigned int fifo_tbins
 
int first_bx_corrected [CSCConstants::NUM_HALF_STRIPS]
 
bool gangedME1a
 
unsigned int hit_persist
 
int infoV
 
bool isME11
 
bool isMTCC
 
bool ispretrig [CSCConstants::NUM_HALF_STRIPS]
 
bool isSLHC
 
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
 
unsigned int pretrig_trig_zone
 
bool readout_earliest_2
 
bool smartME1aME1b
 
int stagger [CSCConstants::NUM_LAYERS]
 
int start_bx_shift
 
unsigned int theChamber
 
const unsigned theEndcap
 
std::vector< int > thePreTriggerBXs
 
unsigned int theRing
 
const unsigned theSector
 
const unsigned theStation
 
const unsigned theSubsector
 
const unsigned theTrigChamber
 
unsigned int tmb_l1a_window_size
 
bool use_corrected_bx
 
bool use_dead_time_zoning
 

Static Private Attributes

static const int cfeb_strips [2] = { 8, 32}
 
static const unsigned int def_drift_delay = 2
 
static const unsigned int def_fifo_pretrig = 7
 
static const unsigned int def_fifo_tbins = 12
 
static const unsigned int def_hit_persist = 6
 
static const unsigned int def_min_separation = 10
 
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
 
static const unsigned int def_tmb_l1a_window_size = 7
 

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@.nosp@m.phys.nosp@m.ics.u.nosp@m.cla..nosp@m.edu Numerous later improvements by Jason Mumford and Slava Valuev (see cvs in ORCA). Porting from ORCA by S. Valuev (Slava.nosp@m..Val.nosp@m.uev@c.nosp@m.ern..nosp@m.ch), May 2006.
Id:
CSCCathodeLCTProcessor.h,v 1.26 2012/12/05 21:14:22 khotilov Exp

Definition at line 37 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.

anonymous enum

Pre-defined patterns.

Enumerator
NUM_PATTERN_STRIPS 

Definition at line 97 of file CSCCathodeLCTProcessor.h.

anonymous enum
Enumerator
NUM_PATTERN_HALFSTRIPS 

Definition at line 101 of file CSCCathodeLCTProcessor.h.

anonymous enum

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

Enumerator
MAX_CFEBS 

Definition at line 106 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,
const edm::ParameterSet ctmb 
)

Normal constructor.

Definition at line 237 of file CSCCathodeLCTProcessor.cc.

References CSCTriggerNumbering::chamberFromTriggerLabels(), checkConfigParameters(), clct_state_machine_zone, disableME1a, drift_delay, dumpConfigParams(), dynamic_state_machine_zone, early_tbins, fifo_pretrig, fifo_tbins, gangedME1a, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hit_persist, infoV, isME11, isMTCC, isSLHC, isTMB07, min_separation, nplanes_hit_pattern, nplanes_hit_pretrig, CSCConstants::NUM_LAYERS, numStrips, pid_thresh_pretrig, pretrig_trig_zone, readout_earliest_2, CSCTriggerNumbering::ringFromTriggerLabels(), smartME1aME1b, stagger, start_bx_shift, theChamber, theRing, theSector, theStation, theSubsector, theTrigChamber, tmb_l1a_window_size, use_corrected_bx, and use_dead_time_zoning.

244  :
246  theSubsector(subsector), theTrigChamber(chamber) {
247  static bool config_dumped = false;
248 
249  // CLCT configuration parameters.
250  fifo_tbins = conf.getParameter<unsigned int>("clctFifoTbins");
251  hit_persist = conf.getParameter<unsigned int>("clctHitPersist");
252  drift_delay = conf.getParameter<unsigned int>("clctDriftDelay");
254  conf.getParameter<unsigned int>("clctNplanesHitPretrig");
256  conf.getParameter<unsigned int>("clctNplanesHitPattern");
257 
258  // Not used yet.
259  fifo_pretrig = conf.getParameter<unsigned int>("clctFifoPretrig");
260 
261  // Defines pre-2007 version of the CLCT algorithm used in test beams and
262  // MTCC.
263  isMTCC = comm.getParameter<bool>("isMTCC");
264 
265  // TMB07 firmware used since 2007: switch and config. parameters.
266  isTMB07 = comm.getParameter<bool>("isTMB07");
267 
268  // Flag for SLHC studies
269  isSLHC = comm.getUntrackedParameter<bool>("isSLHC",false);
270 
271  // special configuration parameters for ME11 treatment
272  smartME1aME1b = comm.getUntrackedParameter<bool>("smartME1aME1b",false);
273  disableME1a = comm.getUntrackedParameter<bool>("disableME1a",false);
274  gangedME1a = comm.getUntrackedParameter<bool>("gangedME1a",true);
275 
276  if (isSLHC && !smartME1aME1b) edm::LogError("L1CSCTPEmulatorConfigError")
277  << "+++ SLHC upgrade configuration is used (isSLHC=True) but smartME1aME1b=False!\n"
278  << "Only smartME1aME1b algorithm is so far supported for upgrade! +++\n";
279 
280  if (isTMB07) {
282  conf.getParameter<unsigned int>("clctPidThreshPretrig");
284  conf.getParameter<unsigned int>("clctMinSeparation");
285 
286  start_bx_shift = conf.getUntrackedParameter<int>("clctStartBxShift",0);
287  }
288 
289  if (smartME1aME1b) {
290  // use of localized dead-time zones
292  conf.getUntrackedParameter<bool>("useDeadTimeZoning",true);
294  conf.getUntrackedParameter<unsigned int>("clctStateMachineZone",8);
296  conf.getUntrackedParameter<bool>("useDynamicStateMachineZone",true);
297 
298  // how far away may trigger happen from pretrigger
300  conf.getUntrackedParameter<unsigned int>("clctPretriggerTriggerZone",5);
301 
302  // whether to calculate bx as corrected_bx instead of pretrigger one
303  use_corrected_bx = conf.getUntrackedParameter<bool>("clctUseCorrectedBx",false);
304  }
305 
306  // Motherboard parameters: common for all configurations.
307  tmb_l1a_window_size = // Common to CLCT and TMB
308  ctmb.getParameter<unsigned int>("tmbL1aWindowSize");
309 
310  // separate handle for early time bins
311  early_tbins = ctmb.getUntrackedParameter<int>("tmbEarlyTbins",-1);
312  static int fpga_latency = 3;
313  if (early_tbins<0) early_tbins = fifo_pretrig - fpga_latency;
314 
315  // wether to readout only the earliest two LCTs in readout window
316  readout_earliest_2 = ctmb.getUntrackedParameter<bool>("tmbReadoutEarliest2",0);
317 
318  // Verbosity level, set to 0 (no print) by default.
319  infoV = conf.getUntrackedParameter<int>("verbosity", 0);
320 
321  // Check and print configuration parameters.
323  if ((infoV > 0 || isSLHC) && !config_dumped) {
324  //std::cerr<<"**** CLCT constructor parameters dump ****"<<std::endl;
326  config_dumped = true;
327  }
328 
329  numStrips = 0; // Will be set later.
330  // Provisional, but should be OK for all stations except ME1.
331  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
332  if ((i_layer+1)%2 == 0) stagger[i_layer] = 0;
333  else stagger[i_layer] = 1;
334  }
335 
337 
340 
341  // trigger numbering doesn't distinguish between ME1a and ME1b chambers:
342  isME11 = (theStation == 1 && theRing == 1);
343 
344  //if (theStation==1 && theRing==2) infoV = 3;
345 
347  //if (theStation == 2 && theSector == 1 &&
348  // theRing == 1 &&
349  // theChamber == 1) {
351  // testPatterns();
353  // testLCTs();
355  // printPatterns();
356  //}
357 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
static int ringFromTriggerLabels(int station, int triggerCSCID)
int stagger[CSCConstants::NUM_LAYERS]
static int chamberFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station, int TriggerCSCID)
CSCCathodeLCTProcessor::CSCCathodeLCTProcessor ( )

Default constructor. Used for testing.

Definition at line 359 of file CSCCathodeLCTProcessor.cc.

References checkConfigParameters(), clct_state_machine_zone, disableME1a, dumpConfigParams(), early_tbins, gangedME1a, infoV, isME11, isMTCC, isTMB07, CSCConstants::MAX_NUM_STRIPS, CSCConstants::NUM_LAYERS, numStrips, CSCTriggerNumbering::ringFromTriggerLabels(), setDefaultConfigParameters(), smartME1aME1b, stagger, start_bx_shift, theRing, theStation, theTrigChamber, and use_dead_time_zoning.

359  :
360  theEndcap(1), theStation(1), theSector(1),
362  // constructor for debugging.
363  static bool config_dumped = false;
364 
365  // CLCT configuration parameters.
367  infoV = 2;
368  isMTCC = false;
369  isTMB07 = true;
370 
371  smartME1aME1b = false;
372  disableME1a = false;
373  gangedME1a = true;
374 
375  early_tbins = 4;
376 
377  start_bx_shift = 0;
380 
381  // Check and print configuration parameters.
383  if (!config_dumped) {
384  //std::cerr<<"**** CLCT default constructor parameters dump ****"<<std::endl;
386  config_dumped = true;
387  }
388 
390  // Should be OK for all stations except ME1.
391  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
392  if ((i_layer+1)%2 == 0) stagger[i_layer] = 0;
393  else stagger[i_layer] = 1;
394  }
395 
397  isME11 = (theStation == 1 && theRing == 1);
398 }
static int ringFromTriggerLabels(int station, int triggerCSCID)
int stagger[CSCConstants::NUM_LAYERS]

Member Function Documentation

void CSCCathodeLCTProcessor::checkConfigParameters ( )
private

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

Definition at line 447 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, def_tmb_l1a_window_size, drift_delay, fifo_pretrig, fifo_tbins, hit_persist, infoV, isTMB07, min_separation, nplanes_hit_pattern, nplanes_hit_pretrig, CSCConstants::NUM_HALF_STRIPS, pid_thresh_pretrig, and tmb_l1a_window_size.

Referenced by CSCCathodeLCTProcessor(), and setConfigParameters().

447  {
448  // Make sure that the parameter values are within the allowed range.
449 
450  // Max expected values.
451  static const unsigned int max_fifo_tbins = 1 << 5;
452  static const unsigned int max_fifo_pretrig = 1 << 5;
453  static const unsigned int max_hit_persist = 1 << 4;
454  static const unsigned int max_drift_delay = 1 << 2;
455  static const unsigned int max_nplanes_hit_pretrig = 1 << 3;
456  static const unsigned int max_nplanes_hit_pattern = 1 << 3;
457  static const unsigned int max_pid_thresh_pretrig = 1 << 4;
458  static const unsigned int max_min_separation = CSCConstants::NUM_HALF_STRIPS;
459  static const unsigned int max_tmb_l1a_window_size = 1 << 4;
460 
461  // Checks.
462  if (fifo_tbins >= max_fifo_tbins) {
463  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
464  << "+++ Value of fifo_tbins, " << fifo_tbins
465  << ", exceeds max allowed, " << max_fifo_tbins-1 << " +++\n"
466  << "+++ Try to proceed with the default value, fifo_tbins="
467  << def_fifo_tbins << " +++\n";
469  }
470  if (fifo_pretrig >= max_fifo_pretrig) {
471  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
472  << "+++ Value of fifo_pretrig, " << fifo_pretrig
473  << ", exceeds max allowed, " << max_fifo_pretrig-1 << " +++\n"
474  << "+++ Try to proceed with the default value, fifo_pretrig="
475  << def_fifo_pretrig << " +++\n";
477  }
478  if (hit_persist >= max_hit_persist) {
479  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
480  << "+++ Value of hit_persist, " << hit_persist
481  << ", exceeds max allowed, " << max_hit_persist-1 << " +++\n"
482  << "+++ Try to proceed with the default value, hit_persist="
483  << def_hit_persist << " +++\n";
485  }
486  if (drift_delay >= max_drift_delay) {
487  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
488  << "+++ Value of drift_delay, " << drift_delay
489  << ", exceeds max allowed, " << max_drift_delay-1 << " +++\n"
490  << "+++ Try to proceed with the default value, drift_delay="
491  << def_drift_delay << " +++\n";
493  }
494  if (nplanes_hit_pretrig >= max_nplanes_hit_pretrig) {
495  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
496  << "+++ Value of nplanes_hit_pretrig, " << nplanes_hit_pretrig
497  << ", exceeds max allowed, " << max_nplanes_hit_pretrig-1 << " +++\n"
498  << "+++ Try to proceed with the default value, nplanes_hit_pretrig="
499  << def_nplanes_hit_pretrig << " +++\n";
501  }
502  if (nplanes_hit_pattern >= max_nplanes_hit_pattern) {
503  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
504  << "+++ Value of nplanes_hit_pattern, " << nplanes_hit_pattern
505  << ", exceeds max allowed, " << max_nplanes_hit_pattern-1 << " +++\n"
506  << "+++ Try to proceed with the default value, nplanes_hit_pattern="
507  << def_nplanes_hit_pattern << " +++\n";
509  }
510 
511  if (isTMB07) {
512  if (pid_thresh_pretrig >= max_pid_thresh_pretrig) {
513  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
514  << "+++ Value of pid_thresh_pretrig, " << pid_thresh_pretrig
515  << ", exceeds max allowed, " << max_pid_thresh_pretrig-1 << " +++\n"
516  << "+++ Try to proceed with the default value, pid_thresh_pretrig="
517  << def_pid_thresh_pretrig << " +++\n";
519  }
520  if (min_separation >= max_min_separation) {
521  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
522  << "+++ Value of min_separation, " << min_separation
523  << ", exceeds max allowed, " << max_min_separation-1 << " +++\n"
524  << "+++ Try to proceed with the default value, min_separation="
525  << def_min_separation << " +++\n";
527  }
528  }
529 
530  if (tmb_l1a_window_size >= max_tmb_l1a_window_size) {
531  if (infoV > 0) edm::LogError("L1CSCTPEmulatorConfigError")
532  << "+++ Value of tmb_l1a_window_size, " << tmb_l1a_window_size
533  << ", exceeds max allowed, " << max_tmb_l1a_window_size-1 << " +++\n"
534  << "+++ Try to proceed with the default value, tmb_l1a_window_size="
535  << def_tmb_l1a_window_size << " +++\n";
537  }
538 }
static const unsigned int def_drift_delay
static const unsigned int def_fifo_tbins
static const unsigned int def_min_separation
static const unsigned int def_nplanes_hit_pretrig
static const unsigned int def_pid_thresh_pretrig
static const unsigned int def_tmb_l1a_window_size
static const unsigned int def_nplanes_hit_pattern
static const unsigned int def_fifo_pretrig
static const unsigned int def_hit_persist
void CSCCathodeLCTProcessor::clear ( void  )

Clears the LCT containers.

Definition at line 540 of file CSCCathodeLCTProcessor.cc.

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

Referenced by CSCMotherboardME11::clear(), and CSCMotherboard::clear().

540  {
541  thePreTriggerBXs.clear();
542  for (int bx = 0; bx < MAX_CLCT_BINS; bx++) {
543  bestCLCT[bx].clear();
544  secondCLCT[bx].clear();
545  }
546 }
CSCCLCTDigi secondCLCT[MAX_CLCT_BINS]
CSCCLCTDigi bestCLCT[MAX_CLCT_BINS]
std::vector< int > thePreTriggerBXs
void clear()
clear this CLCT
Definition: CSCCLCTDigi.cc:60
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 1053 of file CSCCathodeLCTProcessor.cc.

References LogDebug.

Referenced by readComparatorDigis(), and testDistripStagger().

1056  {
1057  // Author: Jason Mumford (mumford@physics.ucla.edu)
1058  // This routine takes care of the stagger situation where there is a hit
1059  // on the right half-strip of a di-strip. If there is a stagger, then
1060  // we must associate that distrip with the next distrip. The situation
1061  // gets more complicated if the next distrip also has a hit on its right
1062  // half-strip. One could imagine a whole chain of these in which case
1063  // we need to go into this routine recursively. The formula is that
1064  // while this condition is satisfied, we enquire the next distrip,
1065  // until we have a hit on any other halfstrip (or triad!=3). Then we
1066  // must compare the 2 different bx times and take the smallest one.
1067  // Afterwards, we must cycle out of the routine assigning the bx times
1068  // to the one strip over.
1069 
1070  // Used only for pre-TMB07 firmware.
1071 
1072  if (i_strip >= CSCConstants::MAX_NUM_STRIPS) {
1073  if (debug) edm::LogWarning("L1CSCTPEmulatorWrongInput")
1074  << "+++ Found wrong strip number = " << i_strip
1075  << "; cannot apply distrip staggering... +++\n";
1076  return;
1077  }
1078 
1079  if (debug)
1080  LogDebug("CSCCathodeLCTProcessor")
1081  << " Enter distripStagger: i_strip = " << i_strip
1082  << " stag_triad[i_strip] = " << stag_triad[i_strip]
1083  << " stag_time[i_strip] = " << stag_time[i_strip]
1084  << " stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
1085  << " stag_time[i_strip+2] = " << stag_time[i_strip+2];
1086 
1087  // So if the next distrip has a stagger hit, go into the routine again
1088  // for the next distrip.
1089  if (i_strip+2 < CSCConstants::MAX_NUM_STRIPS && stag_triad[i_strip+2] == 1)
1090  distripStagger(stag_triad, stag_time, stag_digi, i_strip+2);
1091 
1092  // When we have reached a distrip that does not have a staggered hit,
1093  // if it has a hit, we compare the bx times of the
1094  // staggered distrip with the non-staggered distrip and we take the
1095  // smallest of the two and assign it to the shifted distrip time.
1096  if (stag_time[i_strip+2] >= 0) {
1097  if (stag_time[i_strip] < stag_time[i_strip+2]) {
1098  stag_time[i_strip+2] = stag_time[i_strip];
1099  stag_digi[i_strip+2] = stag_digi[i_strip];
1100  }
1101  }
1102  // If the next distrip did not have a hit, then we merely assign the
1103  // shifted time to the time associated with the staggered distrip.
1104  else {
1105  stag_time[i_strip+2] = stag_time[i_strip];
1106  stag_digi[i_strip+2] = stag_digi[i_strip];
1107  }
1108 
1109  // Then to prevent previous staggers from being overwritten, we assign
1110  // the unshifted time to -999, and then mark the triads that were shifted
1111  // so that we don't go into the routine ever again (such as when making
1112  // the next loop over strips).
1113  stag_time[i_strip] = -999;
1114  stag_triad[i_strip] = 4;
1115  stag_digi[i_strip] = -999;
1116 
1117  if (debug)
1118  LogDebug("CSCCathodeLCTProcessor")
1119  << " Exit distripStagger: i_strip = " << i_strip
1120  << " stag_triad[i_strip] = " << stag_triad[i_strip]
1121  << " stag_time[i_strip] = " << stag_time[i_strip]
1122  << " stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
1123  << " stag_time[i_strip+2] = " << stag_time[i_strip+2];
1124 }
#define LogDebug(id)
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)
#define debug
Definition: MEtoEDMFormat.h:34
void CSCCathodeLCTProcessor::dumpConfigParams ( ) const
private

Dump CLCT configuration parameters.

Definition at line 2742 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(), run(), and setConfigParameters().

2742  {
2743  std::ostringstream strm;
2744  strm << "\n";
2745  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2746  strm << "+ CLCT configuration parameters: +\n";
2747  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2748  strm << " fifo_tbins [total number of time bins in DAQ readout] = "
2749  << fifo_tbins << "\n";
2750  strm << " fifo_pretrig [start time of cathode raw hits in DAQ readout] = "
2751  << fifo_pretrig << "\n";
2752  strm << " hit_persist [duration of signal pulse, in 25 ns bins] = "
2753  << hit_persist << "\n";
2754  strm << " drift_delay [time after pre-trigger before TMB latches LCTs] = "
2755  << drift_delay << "\n";
2756  strm << " nplanes_hit_pretrig [min. number of layers hit for pre-trigger] = "
2757  << nplanes_hit_pretrig << "\n";
2758  strm << " nplanes_hit_pattern [min. number of layers hit for trigger] = "
2759  << nplanes_hit_pattern << "\n";
2760  if (isTMB07) {
2761  strm << " pid_thresh_pretrig [lower threshold on pattern id] = "
2762  << pid_thresh_pretrig << "\n";
2763  strm << " min_separation [region of busy key strips] = "
2764  << min_separation << "\n";
2765  }
2766  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2767  LogDebug("CSCCathodeLCTProcessor") << strm.str();
2768  //std::cerr<<strm.str()<<std::endl;
2769 }
#define LogDebug(id)
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 2772 of file CSCCathodeLCTProcessor.cc.

References cfeb_strips, relativeConstraints::empty, LogDebug, LogTrace, CSCConstants::NUM_LAYERS, theChamber, theEndcap, theRing, and theStation.

Referenced by findLCTs(), and findLCTsSLHC().

2773 {
2774  LogDebug("CSCCathodeLCTProcessor")
2775  << "ME" << ((theEndcap == 1) ? "+" : "-")
2776  << theStation << "/" << theRing << "/" << theChamber
2777  << " strip type " << stripType << " nStrips " << nStrips;
2778 
2779  std::ostringstream strstrm;
2780  for (int i_strip = 0; i_strip < nStrips; i_strip++) {
2781  if (i_strip%10 == 0) {
2782  if (i_strip < 100) strstrm << i_strip/10;
2783  else strstrm << (i_strip-100)/10;
2784  }
2785  else strstrm << " ";
2786  if ((i_strip+1)%cfeb_strips[stripType] == 0) strstrm << " ";
2787  }
2788  strstrm << "\n";
2789  for (int i_strip = 0; i_strip < nStrips; i_strip++) {
2790  strstrm << i_strip%10;
2791  if ((i_strip+1)%cfeb_strips[stripType] == 0) strstrm << " ";
2792  }
2793  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
2794  strstrm << "\n";
2795  for (int i_strip = 0; i_strip < nStrips; i_strip++) {
2796  if (!strip[i_layer][i_strip].empty()) {
2797  std::vector<int> bx_times = strip[i_layer][i_strip];
2798  // Dump only the first in time.
2799  strstrm << std::hex << bx_times[0] << std::dec;
2800  }
2801  else {
2802  strstrm << "-";
2803  }
2804  if ((i_strip+1)%cfeb_strips[stripType] == 0) strstrm << " ";
2805  }
2806  }
2807  LogTrace("CSCCathodeLCTProcessor") << strstrm.str();
2808 }
#define LogDebug(id)
static const int cfeb_strips[2]
#define LogTrace(id)
std::vector< CSCCLCTDigi > CSCCathodeLCTProcessor::findLCTs ( const std::vector< int >  strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
int  stripType 
)
private

Definition at line 1136 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, CSCConstants::NUM_HALF_STRIPS, numStrips, and preTrigger().

Referenced by run(), and testPatterns().

1137 {
1138  int j;
1139  int best_strip = 0;
1140  int first_bx = 999;
1141  const int max_lct_num = 2;
1142  const int adjacent_strips = 2;
1143  // Distrip, halfstrip pattern threshold.
1144  const unsigned int ptrn_thrsh[2] = {nplanes_hit_pattern, nplanes_hit_pattern};
1145  int highest_quality = 0;
1146 
1147  int keystrip_data[CSCConstants::NUM_HALF_STRIPS][7];
1148  int final_lcts[max_lct_num];
1149 
1150  std::vector <CSCCLCTDigi> lctList;
1151 
1152  int nStrips = 0;
1153  if (stripType == 1) nStrips = 2*numStrips + 1;
1154  else if (stripType == 0) nStrips = numStrips/2 + 1;
1155 
1156  if (infoV > 1) dumpDigis(strip, stripType, nStrips);
1157 
1158  // Send data to a pretrigger so that we don't excessively look at data
1159  // that won't give an LCT. If there is a pretrigger, then get all quality
1160  // and bend for all keystrips.
1161  if (preTrigger(strip, stripType, nStrips, first_bx)){
1162  getKeyStripData(strip, keystrip_data, nStrips, first_bx, best_strip, stripType);
1163 
1164  /* Set all final_lcts to impossible key_strip numbers */
1165  for (j = 0; j < max_lct_num; j++)
1166  final_lcts[j] = -999;
1167 
1168  // Now take the keystrip with the best quality, and do a search over the
1169  // rest of the strips for the next highest quality. Do the search over a
1170  // range excluding a certain number of keystrips adjacent to the original
1171  // best key_strip.
1172  final_lcts[0] = best_strip;
1173 
1174  for (int key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
1175  // If indexed strip does not fall within excluded range, then continue
1176  if (abs(best_strip - key_strip) > adjacent_strips){
1177  // Match with highest quality
1178  if (keystrip_data[key_strip][CLCT_QUALITY] > highest_quality){
1179  highest_quality = keystrip_data[key_strip][CLCT_QUALITY];
1180  final_lcts[1] = key_strip;
1181  }
1182  }
1183  }
1184 
1185  for (j = 0; j < max_lct_num; j++){
1186  // Only report LCTs if the number of layers hit is greater than or
1187  // equal to the (variable) valid pattern threshold ptrn_thrsh.
1188  int keystrip = final_lcts[j];
1189  if (keystrip >= 0 &&
1190  keystrip_data[keystrip][CLCT_QUALITY] >= static_cast<int>(ptrn_thrsh[stripType])) {
1191  // assign the stripType here. 1 = halfstrip, 0 = distrip.
1192  keystrip_data[keystrip][CLCT_STRIP_TYPE] = stripType;
1193  // Now make the LCT words for the 2 highest, and store them in a list
1194  int theHalfStrip = (keystrip_data[keystrip][CLCT_STRIP_TYPE] ?
1195  keystrip_data[keystrip][CLCT_STRIP] :
1196  4*keystrip_data[keystrip][CLCT_STRIP]);
1197  keystrip_data[keystrip][CLCT_CFEB] = theHalfStrip/32;
1198  int halfstrip_in_cfeb =
1199  theHalfStrip - 32*keystrip_data[keystrip][CLCT_CFEB];
1200 
1201  CSCCLCTDigi thisLCT(1, keystrip_data[keystrip][CLCT_QUALITY],
1202  keystrip_data[keystrip][CLCT_PATTERN],
1203  keystrip_data[keystrip][CLCT_STRIP_TYPE],
1204  keystrip_data[keystrip][CLCT_BEND],
1205  halfstrip_in_cfeb,
1206  keystrip_data[keystrip][CLCT_CFEB],
1207  keystrip_data[keystrip][CLCT_BX]);
1208  if (infoV > 2) {
1209  char stripType =
1210  (keystrip_data[keystrip][CLCT_STRIP_TYPE] == 0) ? 'D' : 'H';
1211  char bend =
1212  (keystrip_data[keystrip][CLCT_BEND] == 0) ? 'L' : 'R';
1213  LogTrace("CSCCathodeLCTProcessor")
1214  << " Raw Find: "
1215  << "Key Strip: " << std::setw(3)
1216  << keystrip_data[keystrip][CLCT_STRIP]
1217  << " Pattern: " << std::setw(2)
1218  << keystrip_data[keystrip][CLCT_PATTERN]
1219  << " Bend: " << std::setw(1) << bend
1220  << " Quality: " << std::setw(1)
1221  << keystrip_data[keystrip][CLCT_QUALITY]
1222  << " stripType: " << std::setw(1) << stripType
1223  << " BX: " << std::setw(1)
1224  << keystrip_data[keystrip][CLCT_BX];
1225  }
1226  lctList.push_back(thisLCT);
1227  }
1228  }
1229  }
1230 
1231  return lctList;
1232 } // findLCTs -- idealized version for MC studies.
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)
#define abs(x)
Definition: mlp_lapack.h:159
int j
Definition: DBlmapReader.cc:9
#define LogTrace(id)
void dumpDigis(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips) const
bool preTrigger(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips, int &first_bx)
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 1431 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_HALF_STRIPS, CSCConstants::NUM_LAYERS, numStrips, preTrigger(), and priorityEncode().

1433  {
1434  std::vector <CSCCLCTDigi> lctList;
1435  int _bx[2] = {999, 999};
1436  int first_bx = 999;
1437 
1438  const int nhStrips = 2*numStrips + 1;
1439  const int ndStrips = numStrips/2 + 1;
1440 
1441  if (infoV > 1) {
1442  dumpDigis(halfstrip, 1, nhStrips);
1443  dumpDigis(distrip, 0, ndStrips);
1444  }
1445 
1446  // Test beam version of TMB pretrigger and LCT sorting
1447  int h_keyStrip[MAX_CFEBS]; // one key per CFEB
1448  unsigned int h_nhits[MAX_CFEBS]; // number of hits in envelope for each key
1449  int d_keyStrip[MAX_CFEBS]; // one key per CFEB
1450  unsigned int d_nhits[MAX_CFEBS]; // number of hits in envelope for each key
1451  int keystrip_data[2][7]; // 2 possible LCTs per CSC x 7 LCT quantities
1452  unsigned int h_pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS]; // simulate digital one-shot
1453  unsigned int d_pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS]; // simulate digital one-shot
1454  bool pre_trig[2] = {false, false};
1455 
1456  // All half-strip and di-strip pattern envelopes are evaluated
1457  // simultaneously, on every clock cycle.
1458  pre_trig[0] = preTrigger(halfstrip, h_pulse, 1, nhStrips, 0, _bx[0]);
1459  pre_trig[1] = preTrigger( distrip, d_pulse, 0, ndStrips, 0, _bx[1]);
1460 
1461  // If any of 200 half-strip and di-strip envelopes has enough layers hit in
1462  // it, TMB will pre-trigger.
1463  if (pre_trig[0] || pre_trig[1]) {
1464  first_bx = (_bx[0] < _bx[1]) ? _bx[0] : _bx[1];
1465  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1466  << "half bx " << _bx[0] << " di bx " << _bx[1] << " first " << first_bx
1467  << "\n ..... waiting drift delay ..... ";
1468 
1469  // Empirically-found trick allowing to dramatically improve agreement
1470  // with MTCC-II data.
1471  // The trick is to ignore hits in a few first time bins when latching
1472  // hits for priority encode envelopes. For MTCC-II, we need to ignore
1473  // hits in time bins 0-3 inclusively.
1474  //
1475  // Firmware configuration has been fixed for most of 2007 runs, so
1476  // this trick should NOT be used when emulating 2007 trigger.
1477  /*
1478  int max_bx = 4;
1479  for (int ilayer = 0; ilayer < CSCConstants::NUM_LAYERS; ilayer++) {
1480  for (int istrip = 0; istrip < CSCConstants::NUM_HALF_STRIPS; istrip++) {
1481  for (int bx = 0; bx < max_bx; bx++) {
1482  if (((h_pulse[ilayer][istrip] >> bx) & 1) == 1) {
1483  h_pulse[ilayer][istrip] = 0;
1484  }
1485  }
1486  }
1487  for (int istrip = 0; istrip < CSCConstants::NUM_DI_STRIPS; istrip++) {
1488  for (int bx = 0; bx < max_bx; bx++) {
1489  if (((d_pulse[ilayer][istrip] >> bx) & 1) == 1) {
1490  d_pulse[ilayer][istrip] = 0;
1491  }
1492  }
1493  }
1494  }
1495  */
1496 
1497  // TMB latches LCTs drift_delay clocks after pretrigger.
1498  int latch_bx = first_bx + drift_delay;
1499  latchLCTs(h_pulse, h_keyStrip, h_nhits, 1, CSCConstants::NUM_HALF_STRIPS,
1500  latch_bx);
1501  latchLCTs(d_pulse, d_keyStrip, d_nhits, 0, CSCConstants::NUM_DI_STRIPS,
1502  latch_bx);
1503 
1504  if (infoV > 1) {
1505  LogTrace("CSCCathodeLCTProcessor")
1506  << "...............................\n"
1507  << "Final halfstrip hits and keys (after drift delay) ...";
1508  for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
1509  LogTrace("CSCCathodeLCTProcessor")
1510  << "cfeb " << icfeb << " key: " << h_keyStrip[icfeb]
1511  << " hits " << h_nhits[icfeb];
1512  }
1513  LogTrace("CSCCathodeLCTProcessor")
1514  << "Final distrip hits and keys (after drift delay) ...";
1515  for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
1516  LogTrace("CSCCathodeLCTProcessor")
1517  << "cfeb " << icfeb << " key: " << d_keyStrip[icfeb]
1518  << " hits " << d_nhits[icfeb];
1519  }
1520  }
1521  priorityEncode(h_keyStrip, h_nhits, d_keyStrip, d_nhits, keystrip_data);
1522  getKeyStripData(h_pulse, d_pulse, keystrip_data, first_bx);
1523 
1524  for (int ilct = 0; ilct < 2; ilct++) {
1525  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1526  << "found lcts: ilct " << ilct
1527  << " key strip " << keystrip_data[ilct][CLCT_STRIP];
1528  if (keystrip_data[ilct][CLCT_STRIP] != -1) {
1529  int halfstrip_in_cfeb = 0;
1530  if (keystrip_data[ilct][CLCT_STRIP_TYPE] == 0)
1531  halfstrip_in_cfeb = 4*keystrip_data[ilct][CLCT_STRIP] -
1532  32*keystrip_data[ilct][CLCT_CFEB];
1533  else
1534  halfstrip_in_cfeb = keystrip_data[ilct][CLCT_STRIP] -
1535  32*keystrip_data[ilct][CLCT_CFEB];
1536 
1537  CSCCLCTDigi thisLCT(1, keystrip_data[ilct][CLCT_QUALITY],
1538  keystrip_data[ilct][CLCT_PATTERN],
1539  keystrip_data[ilct][CLCT_STRIP_TYPE],
1540  keystrip_data[ilct][CLCT_BEND],
1541  halfstrip_in_cfeb,
1542  keystrip_data[ilct][CLCT_CFEB],
1543  keystrip_data[ilct][CLCT_BX]);
1544  lctList.push_back(thisLCT);
1545  }
1546  }
1547  }
1548 
1549  return lctList;
1550 
1551 } // findLCTs -- pre-2007 version.
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 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)
#define LogTrace(id)
void dumpDigis(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips) const
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 preTrigger(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips, int &first_bx)
std::vector< CSCCLCTDigi > CSCCathodeLCTProcessor::findLCTs ( const std::vector< int >  halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
private

Definition at line 2040 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_HALF_STRIPS, CSCConstants::NUM_LAYERS, NUM_PATTERN_HALFSTRIPS, numStrips, pattern2007, preTrigger(), ptnFinding(), pulseExtension(), stagger, start_bx_shift, and thePreTriggerBXs.

2040  {
2041  std::vector<CSCCLCTDigi> lctList;
2042 
2043  // Max. number of half-strips for this chamber.
2044  const int maxHalfStrips = 2*numStrips + 1;
2045 
2046  if (infoV > 1) dumpDigis(halfstrip, 1, maxHalfStrips);
2047 
2048  // Test beam version of TMB pretrigger and LCT sorting
2049  enum {max_lcts = 2};
2050  // 2 possible LCTs per CSC x 7 LCT quantities
2051  int keystrip_data[max_lcts][7] = {{0}};
2053 
2054  // Fire half-strip one-shots for hit_persist bx's (4 bx's by default).
2055  pulseExtension(halfstrip, maxHalfStrips, pulse);
2056 
2057  unsigned int start_bx = start_bx_shift;
2058  // Stop drift_delay bx's short of fifo_tbins since at later bx's we will
2059  // not have a full set of hits to start pattern search anyway.
2060  unsigned int stop_bx = fifo_tbins - drift_delay;
2061  // Allow for more than one pass over the hits in the time window.
2062  while (start_bx < stop_bx) {
2063  // All half-strip pattern envelopes are evaluated simultaneously, on every
2064  // clock cycle.
2065  int first_bx = 999;
2066  bool pre_trig = preTrigger(pulse, start_bx, first_bx);
2067 
2068  // If any of half-strip envelopes has enough layers hit in it, TMB
2069  // will pre-trigger.
2070  if (pre_trig) {
2071  thePreTriggerBXs.push_back(first_bx);
2072  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
2073  << "..... pretrigger at bx = " << first_bx
2074  << "; waiting drift delay .....";
2075 
2076  // TMB latches LCTs drift_delay clocks after pretrigger.
2077  int latch_bx = first_bx + drift_delay;
2078  bool hits_in_time = ptnFinding(pulse, maxHalfStrips, latch_bx);
2079  if (infoV > 1) {
2080  if (hits_in_time) {
2081  for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER-1];
2082  hstrip < maxHalfStrips; hstrip++) {
2083  if (nhits[hstrip] > 0) {
2084  LogTrace("CSCCathodeLCTProcessor")
2085  << " bx = " << std::setw(2) << latch_bx << " --->"
2086  << " halfstrip = " << std::setw(3) << hstrip
2087  << " best pid = " << std::setw(2) << best_pid[hstrip]
2088  << " nhits = " << nhits[hstrip];
2089  }
2090  }
2091  }
2092  }
2093  // The pattern finder runs continuously, so another pre-trigger
2094  // could occur already at the next bx.
2095  start_bx = first_bx + 1;
2096 
2097  // Quality for sorting.
2098  int quality[CSCConstants::NUM_HALF_STRIPS];
2099  int best_halfstrip[max_lcts], best_quality[max_lcts];
2100  for (int ilct = 0; ilct < max_lcts; ilct++) {
2101  best_halfstrip[ilct] = -1;
2102  best_quality[ilct] = 0;
2103  }
2104 
2105  // Calculate quality from pattern id and number of hits, and
2106  // simultaneously select best-quality LCT.
2107  if (hits_in_time) {
2108  for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER-1];
2109  hstrip < maxHalfStrips; hstrip++) {
2110  // The bend-direction bit pid[0] is ignored (left and right
2111  // bends have equal quality).
2112  quality[hstrip] = (best_pid[hstrip] & 14) | (nhits[hstrip] << 5);
2113  if (quality[hstrip] > best_quality[0]) {
2114  best_halfstrip[0] = hstrip;
2115  best_quality[0] = quality[hstrip];
2116  }
2117  if (infoV > 1 && quality[hstrip] > 0) {
2118  LogTrace("CSCCathodeLCTProcessor")
2119  << " 1st CLCT: halfstrip = " << std::setw(3) << hstrip
2120  << " quality = " << std::setw(3) << quality[hstrip]
2121  << " best halfstrip = " << std::setw(3) << best_halfstrip[0]
2122  << " best quality = " << std::setw(3) << best_quality[0];
2123  }
2124  }
2125  }
2126 
2127  // If 1st best CLCT is found, look for the 2nd best.
2128  if (best_halfstrip[0] >= 0) {
2129  // Mark keys near best CLCT as busy by setting their quality to
2130  // zero, and repeat the search.
2131  markBusyKeys(best_halfstrip[0], best_pid[best_halfstrip[0]], quality);
2132 
2133  for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER-1];
2134  hstrip < maxHalfStrips; hstrip++) {
2135  if (quality[hstrip] > best_quality[1]) {
2136  best_halfstrip[1] = hstrip;
2137  best_quality[1] = quality[hstrip];
2138  }
2139  if (infoV > 1 && quality[hstrip] > 0) {
2140  LogTrace("CSCCathodeLCTProcessor")
2141  << " 2nd CLCT: halfstrip = " << std::setw(3) << hstrip
2142  << " quality = " << std::setw(3) << quality[hstrip]
2143  << " best halfstrip = " << std::setw(3) << best_halfstrip[1]
2144  << " best quality = " << std::setw(3) << best_quality[1];
2145  }
2146  }
2147 
2148  // Pattern finder.
2149  bool ptn_trig = false;
2150  for (int ilct = 0; ilct < max_lcts; ilct++) {
2151  int best_hs = best_halfstrip[ilct];
2152  if (best_hs >= 0 && nhits[best_hs] >= nplanes_hit_pattern) {
2153  ptn_trig = true;
2154  keystrip_data[ilct][CLCT_PATTERN] = best_pid[best_hs];
2155  keystrip_data[ilct][CLCT_BEND] =
2157  // Remove stagger if any.
2158  keystrip_data[ilct][CLCT_STRIP] =
2160  keystrip_data[ilct][CLCT_BX] = first_bx;
2161  keystrip_data[ilct][CLCT_STRIP_TYPE] = 1; // obsolete
2162  keystrip_data[ilct][CLCT_QUALITY] = nhits[best_hs];
2163  keystrip_data[ilct][CLCT_CFEB] =
2164  keystrip_data[ilct][CLCT_STRIP]/cfeb_strips[1];
2165  int halfstrip_in_cfeb = keystrip_data[ilct][CLCT_STRIP] -
2166  cfeb_strips[1]*keystrip_data[ilct][CLCT_CFEB];
2167 
2168  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
2169  << " Final selection: ilct " << ilct
2170  << " key halfstrip " << keystrip_data[ilct][CLCT_STRIP]
2171  << " quality " << keystrip_data[ilct][CLCT_QUALITY]
2172  << " pattern " << keystrip_data[ilct][CLCT_PATTERN]
2173  << " bx " << keystrip_data[ilct][CLCT_BX];
2174 
2175  CSCCLCTDigi thisLCT(1, keystrip_data[ilct][CLCT_QUALITY],
2176  keystrip_data[ilct][CLCT_PATTERN],
2177  keystrip_data[ilct][CLCT_STRIP_TYPE],
2178  keystrip_data[ilct][CLCT_BEND],
2179  halfstrip_in_cfeb,
2180  keystrip_data[ilct][CLCT_CFEB],
2181  keystrip_data[ilct][CLCT_BX]);
2182  lctList.push_back(thisLCT);
2183  }
2184  }
2185 
2186  if (ptn_trig) {
2187  // Once there was a trigger, CLCT pre-trigger state machine
2188  // checks the number of hits that lie on a pattern template
2189  // at every bx, and waits for it to drop below threshold.
2190  // The search for CLCTs resumes only when the number of hits
2191  // drops below threshold.
2192  start_bx = fifo_tbins;
2193  // Stop checking drift_delay bx's short of fifo_tbins since
2194  // at later bx's we won't have a full set of hits for a
2195  // pattern search anyway.
2196  unsigned int stop_time = fifo_tbins - drift_delay;
2197  for (unsigned int bx = latch_bx + 1; bx < stop_time; bx++) {
2198  bool return_to_idle = true;
2199  bool hits_in_time = ptnFinding(pulse, maxHalfStrips, bx);
2200  if (hits_in_time) {
2201  for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER-1];
2202  hstrip < maxHalfStrips; hstrip++) {
2203  if (nhits[hstrip] >= nplanes_hit_pattern) {
2204  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
2205  << " State machine busy at bx = " << bx;
2206  return_to_idle = false;
2207  break;
2208  }
2209  }
2210  }
2211  if (return_to_idle) {
2212  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
2213  << " State machine returns to idle state at bx = " << bx;
2214  start_bx = bx;
2215  break;
2216  }
2217  }
2218  }
2219  }
2220  }
2221  else {
2222  start_bx = first_bx + 1; // no dead time
2223  }
2224  }
2225 
2226  return lctList;
2227 } // findLCTs -- TMB-07 version.
static const int cfeb_strips[2]
void markBusyKeys(const int best_hstrip, const int best_patid, int quality[CSCConstants::NUM_HALF_STRIPS])
static const int pattern2007[CSCConstants::NUM_CLCT_PATTERNS][NUM_PATTERN_HALFSTRIPS+2]
#define LogTrace(id)
void dumpDigis(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips) const
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])
std::vector< int > thePreTriggerBXs
int stagger[CSCConstants::NUM_LAYERS]
unsigned int best_pid[CSCConstants::NUM_HALF_STRIPS]
unsigned int nhits[CSCConstants::NUM_HALF_STRIPS]
bool ptnFinding(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int nStrips, const unsigned int bx_time)
bool preTrigger(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips, int &first_bx)
std::vector< CSCCLCTDigi > CSCCathodeLCTProcessor::findLCTsSLHC ( const std::vector< int >  halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
private

Definition at line 2478 of file CSCCathodeLCTProcessor.cc.

References best_pid, cfeb_strips, CLCT_BEND, CLCT_BX, CLCT_CFEB, CLCT_PATTERN, CLCT_QUALITY, clct_state_machine_zone, CLCT_STRIP, CLCT_STRIP_TYPE, drift_delay, dumpDigis(), dynamic_state_machine_zone, fifo_tbins, first_bx_corrected, i, infoV, ispretrig, j, CSCConstants::KEY_CLCT_LAYER, LogTrace, markBusyKeys(), MAX_CLCT_BINS, nhits, nplanes_hit_pattern, CSCConstants::NUM_HALF_STRIPS, CSCConstants::NUM_LAYERS, NUM_PATTERN_HALFSTRIPS, numStrips, pattern2007, pretrig_trig_zone, preTrigger(), ptnFinding(), pulseExtension(), CSCCLCTDigi::setFullBX(), stagger, start_bx_shift, and use_corrected_bx.

Referenced by run().

2479 {
2480  std::vector<CSCCLCTDigi> lctList;
2481 
2482  // Max. number of half-strips for this chamber.
2483  const int maxHalfStrips = 2 * numStrips + 1;
2484 
2485  if (infoV > 1) dumpDigis(halfstrip, 1, maxHalfStrips);
2486 
2487  enum { max_lcts = 2 };
2488 
2489  // keeps dead-time zones around key halfstrips of triggered CLCTs
2491  for (int i = 0; i < CSCConstants::NUM_HALF_STRIPS; i++)
2492  for (int j = 0; j < MAX_CLCT_BINS; j++)
2493  busyMap[i][j] = false;
2494 
2495  std::vector<CSCCLCTDigi> lctListBX;
2496 
2498 
2499  // Fire half-strip one-shots for hit_persist bx's (4 bx's by default).
2500  pulseExtension(halfstrip, maxHalfStrips, pulse);
2501 
2502  unsigned int start_bx = start_bx_shift;
2503  // Stop drift_delay bx's short of fifo_tbins since at later bx's we will
2504  // not have a full set of hits to start pattern search anyway.
2505  unsigned int stop_bx = fifo_tbins - drift_delay;
2506 
2507  // Allow for more than one pass over the hits in the time window.
2508  // Do search in every BX
2509  while (start_bx < stop_bx)
2510  {
2511  lctListBX.clear();
2512 
2513  // All half-strip pattern envelopes are evaluated simultaneously, on every clock cycle.
2514  int first_bx = 999;
2515  bool pre_trig = preTrigger(pulse, start_bx, first_bx);
2516 
2517  // If any of half-strip envelopes has enough layers hit in it, TMB
2518  // will pre-trigger.
2519  if (pre_trig)
2520  {
2521  if (infoV > 1)
2522  LogTrace("CSCCathodeLCTProcessor") << "..... pretrigger at bx = " << first_bx << "; waiting drift delay .....";
2523 
2524  // TMB latches LCTs drift_delay clocks after pretrigger.
2525  int latch_bx = first_bx + drift_delay;
2526  bool hits_in_time = ptnFinding(pulse, maxHalfStrips, latch_bx);
2527  if (infoV > 1)
2528  {
2529  if (hits_in_time)
2530  {
2531  for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER - 1]; hstrip < maxHalfStrips; hstrip++)
2532  {
2533  if (nhits[hstrip] > 0)
2534  {
2535  LogTrace("CSCCathodeLCTProcessor") << " bx = " << std::setw(2) << latch_bx << " --->" << " halfstrip = "
2536  << std::setw(3) << hstrip << " best pid = " << std::setw(2) << best_pid[hstrip] << " nhits = " << nhits[hstrip];
2537  }
2538  }
2539  }
2540  }
2541  // The pattern finder runs continuously, so another pre-trigger
2542  // could occur already at the next bx.
2543  start_bx = first_bx + 1;
2544 
2545  // 2 possible LCTs per CSC x 7 LCT quantities per BX
2546  int keystrip_data[max_lcts][7] = {{0}};
2547 
2548  // Quality for sorting.
2549  int quality[CSCConstants::NUM_HALF_STRIPS];
2550  int best_halfstrip[max_lcts], best_quality[max_lcts];
2551  for (int ilct = 0; ilct < max_lcts; ilct++)
2552  {
2553  best_halfstrip[ilct] = -1;
2554  best_quality[ilct] = 0;
2555  }
2556 
2557  bool pretrig_zone[CSCConstants::NUM_HALF_STRIPS];
2558 
2559  // Calculate quality from pattern id and number of hits, and
2560  // simultaneously select best-quality LCT.
2561  if (hits_in_time)
2562  {
2563  // first, mark half-strip zones around pretriggers
2564  // that happened at the current first_bx
2565  for (int hstrip = 0; hstrip < CSCConstants::NUM_HALF_STRIPS; hstrip++)
2566  pretrig_zone[hstrip] = 0;
2567  for (int hstrip = 0; hstrip < CSCConstants::NUM_HALF_STRIPS; hstrip++)
2568  {
2569  if (ispretrig[hstrip])
2570  {
2571  int min_hs = hstrip - pretrig_trig_zone;
2572  int max_hs = hstrip + pretrig_trig_zone;
2573  if (min_hs < 0)
2574  min_hs = 0;
2575  if (max_hs > CSCConstants::NUM_HALF_STRIPS - 1)
2576  max_hs = CSCConstants::NUM_HALF_STRIPS - 1;
2577  for (int hs = min_hs; hs <= max_hs; hs++)
2578  pretrig_zone[hs] = 1;
2579  if (infoV > 1)
2580  LogTrace("CSCCathodeLCTProcessor") << " marked pretrigger halfstrip zone [" << min_hs << "," << max_hs << "]";
2581  }
2582  }
2583 
2584  for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER - 1]; hstrip < maxHalfStrips; hstrip++)
2585  {
2586  // The bend-direction bit pid[0] is ignored (left and right bends have equal quality).
2587  quality[hstrip] = (best_pid[hstrip] & 14) | (nhits[hstrip] << 5);
2588  // do not consider halfstrips:
2589  // - out of pretrigger-trigger zones
2590  // - in busy zones from previous trigger
2591  if (quality[hstrip] > best_quality[0] &&
2592  pretrig_zone[hstrip] &&
2593  !busyMap[hstrip][first_bx] )
2594  {
2595  best_halfstrip[0] = hstrip;
2596  best_quality[0] = quality[hstrip];
2597  if (infoV > 1)
2598  {
2599  LogTrace("CSCCathodeLCTProcessor") << " 1st CLCT: halfstrip = " << std::setw(3) << hstrip << " quality = "
2600  << std::setw(3) << quality[hstrip] << " best halfstrip = " << std::setw(3) << best_halfstrip[0]
2601  << " best quality = " << std::setw(3) << best_quality[0];
2602  }
2603  }
2604  }
2605  }
2606 
2607  // If 1st best CLCT is found, look for the 2nd best.
2608  if (best_halfstrip[0] >= 0)
2609  {
2610  // Mark keys near best CLCT as busy by setting their quality to zero, and repeat the search.
2611  markBusyKeys(best_halfstrip[0], best_pid[best_halfstrip[0]], quality);
2612 
2613  for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER - 1]; hstrip < maxHalfStrips; hstrip++)
2614  {
2615  if (quality[hstrip] > best_quality[1] &&
2616  pretrig_zone[hstrip] &&
2617  !busyMap[hstrip][first_bx] )
2618  {
2619  best_halfstrip[1] = hstrip;
2620  best_quality[1] = quality[hstrip];
2621  if (infoV > 1)
2622  {
2623  LogTrace("CSCCathodeLCTProcessor") << " 2nd CLCT: halfstrip = " << std::setw(3) << hstrip << " quality = "
2624  << std::setw(3) << quality[hstrip] << " best halfstrip = " << std::setw(3) << best_halfstrip[1]
2625  << " best quality = " << std::setw(3) << best_quality[1];
2626  }
2627  }
2628  }
2629 
2630  // Pattern finder.
2631  bool ptn_trig = false;
2632  for (int ilct = 0; ilct < max_lcts; ilct++)
2633  {
2634  int best_hs = best_halfstrip[ilct];
2635  if (best_hs >= 0 && nhits[best_hs] >= nplanes_hit_pattern)
2636  {
2637  int bx = first_bx;
2638  int fbx = first_bx_corrected[best_hs];
2639  if (use_corrected_bx) {
2640  bx = fbx;
2641  fbx = first_bx;
2642  }
2643  ptn_trig = true;
2644  keystrip_data[ilct][CLCT_PATTERN] = best_pid[best_hs];
2645  keystrip_data[ilct][CLCT_BEND] = pattern2007[best_pid[best_hs]][NUM_PATTERN_HALFSTRIPS];
2646  // Remove stagger if any.
2647  keystrip_data[ilct][CLCT_STRIP] = best_hs - stagger[CSCConstants::KEY_CLCT_LAYER - 1];
2648  keystrip_data[ilct][CLCT_BX] = bx;
2649  keystrip_data[ilct][CLCT_STRIP_TYPE] = 1; // obsolete
2650  keystrip_data[ilct][CLCT_QUALITY] = nhits[best_hs];
2651  keystrip_data[ilct][CLCT_CFEB] = keystrip_data[ilct][CLCT_STRIP] / cfeb_strips[1];
2652  int halfstrip_in_cfeb = keystrip_data[ilct][CLCT_STRIP] - cfeb_strips[1] * keystrip_data[ilct][CLCT_CFEB];
2653 
2654  if (infoV > 1)
2655  LogTrace("CSCCathodeLCTProcessor") << " Final selection: ilct " << ilct << " key halfstrip "
2656  << keystrip_data[ilct][CLCT_STRIP] << " quality " << keystrip_data[ilct][CLCT_QUALITY] << " pattern "
2657  << keystrip_data[ilct][CLCT_PATTERN] << " bx " << keystrip_data[ilct][CLCT_BX];
2658 
2659  CSCCLCTDigi thisLCT(1, keystrip_data[ilct][CLCT_QUALITY], keystrip_data[ilct][CLCT_PATTERN],
2660  keystrip_data[ilct][CLCT_STRIP_TYPE], keystrip_data[ilct][CLCT_BEND], halfstrip_in_cfeb,
2661  keystrip_data[ilct][CLCT_CFEB], keystrip_data[ilct][CLCT_BX]);
2662  thisLCT.setFullBX(fbx);
2663  lctList.push_back(thisLCT);
2664  lctListBX.push_back(thisLCT);
2665  }
2666  }
2667 
2668  // state-machine
2669  if (ptn_trig)
2670  {
2671  // Once there was a trigger, CLCT pre-trigger state machine checks the number of hits
2672  // that lie on a key halfstrip pattern template at every bx, and waits for it to drop below threshold.
2673  // During that time no CLCTs could be found with its key halfstrip in the area of
2674  // [clct_key-clct_state_machine_zone, clct_key+clct_state_machine_zone]
2675  // starting from first_bx+1.
2676  // The search for CLCTs resumes only when the number of hits on key halfstrip drops below threshold.
2677  for (unsigned int ilct = 0; ilct < lctListBX.size(); ilct++)
2678  {
2679  int key_hstrip = lctListBX[ilct].getKeyStrip() + stagger[CSCConstants::KEY_CLCT_LAYER - 1];
2680 
2681  int delta_hs = clct_state_machine_zone;
2683  delta_hs = pattern2007[lctListBX[ilct].getPattern()][NUM_PATTERN_HALFSTRIPS + 1] - 1;
2684 
2685  int min_hstrip = key_hstrip - delta_hs;
2686  int max_hstrip = key_hstrip + delta_hs;
2687 
2688  if (min_hstrip < stagger[CSCConstants::KEY_CLCT_LAYER - 1])
2689  min_hstrip = stagger[CSCConstants::KEY_CLCT_LAYER - 1];
2690  if (max_hstrip > maxHalfStrips)
2691  max_hstrip = maxHalfStrips;
2692 
2693  if (infoV > 2)
2694  LogTrace("CSCCathodeLCTProcessor") << " marking post-trigger zone after bx=" << lctListBX[ilct].getBX() << " ["
2695  << min_hstrip << "," << max_hstrip << "]";
2696 
2697  // Stop checking drift_delay bx's short of fifo_tbins since
2698  // at later bx's we won't have a full set of hits for a
2699  // pattern search anyway.
2700  //int stop_time = fifo_tbins - drift_delay;
2701  // -- no, need to extend busyMap over fifo_tbins - drift_delay
2702  for (size_t bx = first_bx + 1; bx < fifo_tbins; bx++)
2703  {
2704  bool busy_bx = false;
2705  if (bx <= (size_t)latch_bx)
2706  busy_bx = true; // always busy before drift time
2707  if (!busy_bx)
2708  {
2709  bool hits_in_time = ptnFinding(pulse, maxHalfStrips, bx);
2710  if (hits_in_time && nhits[key_hstrip] >= nplanes_hit_pattern)
2711  busy_bx = true;
2712  if (infoV > 2)
2713  LogTrace("CSCCathodeLCTProcessor") << " at bx=" << bx << " hits_in_time=" << hits_in_time << " nhits="
2714  << nhits[key_hstrip];
2715  }
2716  if (infoV > 2)
2717  LogTrace("CSCCathodeLCTProcessor") << " at bx=" << bx << " busy=" << busy_bx;
2718  if (busy_bx)
2719  for (int hstrip = min_hstrip; hstrip <= max_hstrip; hstrip++)
2720  busyMap[hstrip][bx] = true;
2721  else
2722  break;
2723  }
2724  }
2725  } // if (ptn_trig)
2726  }
2727  }
2728  else
2729  {
2730  start_bx = first_bx + 1; // no dead time
2731  }
2732  }
2733 
2734  return lctList;
2735 } // findLCTs -- SLHC version.
int i
Definition: DBlmapReader.cc:9
static const int cfeb_strips[2]
int first_bx_corrected[CSCConstants::NUM_HALF_STRIPS]
void markBusyKeys(const int best_hstrip, const int best_patid, int quality[CSCConstants::NUM_HALF_STRIPS])
static const int pattern2007[CSCConstants::NUM_CLCT_PATTERNS][NUM_PATTERN_HALFSTRIPS+2]
int j
Definition: DBlmapReader.cc:9
#define LogTrace(id)
void dumpDigis(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips) const
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])
int stagger[CSCConstants::NUM_LAYERS]
unsigned int best_pid[CSCConstants::NUM_HALF_STRIPS]
unsigned int nhits[CSCConstants::NUM_HALF_STRIPS]
bool ptnFinding(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int nStrips, const unsigned int bx_time)
bool ispretrig[CSCConstants::NUM_HALF_STRIPS]
bool preTrigger(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips, int &first_bx)
int CSCCathodeLCTProcessor::findNumLayersHit ( std::vector< int >  stripsHit[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
private

Definition at line 3137 of file CSCCathodeLCTProcessor.cc.

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

Referenced by testPatterns().

3138  {
3139  int number = 0;
3140  for (int layer = 0; layer < CSCConstants::NUM_LAYERS; layer++) {
3141  if ((!stripsHit[layer][ 9].empty()) ||
3142  (!stripsHit[layer][10].empty()) ||
3143  (!stripsHit[layer][11].empty()) ) number++;
3144  }
3145  return number;
3146 }
std::vector< CSCCLCTDigi > CSCCathodeLCTProcessor::getCLCTs ( )

Returns vector of all found CLCTs, if any.

Definition at line 2892 of file CSCCathodeLCTProcessor.cc.

References bestCLCT, MAX_CLCT_BINS, and secondCLCT.

Referenced by readoutCLCTs(), and run().

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

Access routines to comparator digis.

Definition at line 757 of file CSCCathodeLCTProcessor.cc.

References cond::rpcobgas::detid, digiV, disableME1a, relativeConstraints::empty, infoV, LogTrace, CSCConstants::NUM_LAYERS, smartME1aME1b, theChamber, theEndcap, theRing, theSector, theStation, theSubsector, and theTrigChamber.

Referenced by run().

757  {
758  bool noDigis = true;
759 
760  // Loop over layers and save comparator digis on each one into digiV[layer].
761  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
762  digiV[i_layer].clear();
763 
765  getDigis(compdc, detid);
766 
767  // If this is ME1/1, fetch digis in corresponding ME1/A (ring=4) as well.
768  if (theStation == 1 && theRing == 1 && !disableME1a && !smartME1aME1b) {
769  CSCDetId detid_me1a(theEndcap, theStation, 4, theChamber, i_layer+1);
770  getDigis(compdc, detid_me1a);
771  }
772 
773  if (!digiV[i_layer].empty()) {
774  noDigis = false;
775  if (infoV > 1) {
776  LogTrace("CSCCathodeLCTProcessor")
777  << "found " << digiV[i_layer].size()
778  << " comparator digi(s) in layer " << i_layer << " of ME"
779  << ((theEndcap == 1) ? "+" : "-") << theStation << "/" << theRing
780  << "/" << theChamber << " (trig. sector " << theSector
781  << " subsector " << theSubsector << " id " << theTrigChamber << ")";
782  }
783  }
784  }
785 
786  return noDigis;
787 }
bool getDigis(const CSCComparatorDigiCollection *compdc)
#define LogTrace(id)
std::vector< CSCComparatorDigi > digiV[CSCConstants::NUM_LAYERS]
void CSCCathodeLCTProcessor::getDigis ( const CSCComparatorDigiCollection compdc,
const CSCDetId id 
)

Definition at line 789 of file CSCCathodeLCTProcessor.cc.

References digiV, disableME1a, relativeConstraints::ring, and smartME1aME1b.

790  {
791  bool me1a = (id.station() == 1) && (id.ring() == 4);
792  const CSCComparatorDigiCollection::Range rcompd = compdc->get(id);
793  for (CSCComparatorDigiCollection::const_iterator digiIt = rcompd.first;
794  digiIt != rcompd.second; ++digiIt) {
795  if (me1a && digiIt->getStrip() <= 16 && !disableME1a && !smartME1aME1b) {
796  // Move ME1/A comparators from CFEB=0 to CFEB=4 if this has not
797  // been done already.
798  CSCComparatorDigi digi_corr(digiIt->getStrip()+64,
799  digiIt->getComparator(),
800  digiIt->getTimeBinWord());
801  digiV[id.layer()-1].push_back(digi_corr);
802  }
803  else {
804  digiV[id.layer()-1].push_back(*digiIt);
805  }
806  }
807 }
std::vector< DigiType >::const_iterator const_iterator
std::vector< CSCComparatorDigi > digiV[CSCConstants::NUM_LAYERS]
std::pair< const_iterator, const_iterator > Range
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 1298 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, and pre_hit_pattern.

Referenced by findLCTs().

1300  {
1301  int lct_pattern[NUM_PATTERN_STRIPS];
1302  int key_strip, this_layer, this_strip;
1303  int quality, best_quality;
1304  int bend = 0;
1305  int highest_quality = 0;
1306  bool nullPattern;
1307 
1308  for (key_strip = 0; key_strip < nStrips; key_strip++)
1309  for (int i = 0; i < 7; i++)
1310  keystrip_data[key_strip][i] = 0;
1311 
1312  // Now we need to look at all the keystrips and take the best pattern
1313  // for each. There are multiple patterns available for each keystrip.
1314 
1315  for (key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
1316  nullPattern = true;
1317  for (int pattern_strip = 0; pattern_strip < NUM_PATTERN_STRIPS; pattern_strip++){
1318  this_layer = pre_hit_pattern[0][pattern_strip];
1319  this_strip = pre_hit_pattern[1][pattern_strip] + key_strip;
1320  // This conditional statement prevents us from looking at strips
1321  // that don't exist along the chamber boundaries.
1322  if ((this_strip >= 0 && this_strip < nStrips) &&
1323  !strip[this_layer][this_strip].empty()) {
1324  if (nullPattern) nullPattern = false;
1325  std::vector<int> bx_times = strip[this_layer][this_strip];
1326  lct_pattern[pattern_strip] = bx_times[0];
1327  }
1328  else
1329  lct_pattern[pattern_strip] = -999;
1330  }
1331  // do the rest only if there is at least one DIGI in the pattern for
1332  // this keystrip
1333  if (nullPattern) continue;
1334 
1335  // Initialize best_quality to zero so that we can look for best pattern
1336  // within a keystrip.
1337  best_quality = 0;
1338 
1339  // Loop over all possible patterns.
1340  // Loop in reverse order, in order to give priority to a straighter
1341  // pattern (larger pattern_num) in case of equal qualities.
1342  // Exclude pattern 0 since it is not defined.
1343  for (int pattern_num = CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07-1; pattern_num > 0; pattern_num--) {
1344  // Get the pattern quality from lct_pattern.
1345  // TMB latches LCTs drift_delay clocks after pretrigger.
1346  int latch_bx = first_bx + drift_delay;
1347  getPattern(pattern_num, lct_pattern, latch_bx, quality, bend);
1348  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1349  << "Key_strip " << key_strip << " quality of pattern_num "
1350  << pattern_num << ": " << quality;
1351  if (quality > best_quality){
1352  // Store the best pattern, quality, etc., for each key_strip.
1353  keystrip_data[key_strip][CLCT_PATTERN] = pattern_num;
1354  keystrip_data[key_strip][CLCT_BEND] = bend;
1355  keystrip_data[key_strip][CLCT_STRIP] = key_strip;
1356  keystrip_data[key_strip][CLCT_BX] = first_bx;
1357  // keystrip_data[key_strip][CLCT_STRIP_TYPE] = stripType; //assign the stripType elsewhere
1358  keystrip_data[key_strip][CLCT_QUALITY] = quality;
1359  if (quality > highest_quality){
1360  // Keep track of which strip had the highest quality.
1361  // highest_quality refers to the overall highest quality for all
1362  // key strips. This is different than best_quality which refers
1363  // to the best quality in a keystrip from different patterns.
1364  best_strip = key_strip;
1365  highest_quality = quality;
1366  }
1367  best_quality = quality;
1368  }
1369  }
1370  }
1371 } // getKeyStripData -- idealized version for MC studies.
void getPattern(int pattern_num, int strip_value[NUM_PATTERN_STRIPS], int bx_time, int &quality, int &bend)
int i
Definition: DBlmapReader.cc:9
#define LogTrace(id)
static const int pre_hit_pattern[2][NUM_PATTERN_STRIPS]
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 1886 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.

1889  {
1890 
1891  int lct_pattern[NUM_PATTERN_STRIPS];
1892  int this_layer, this_strip;
1893  unsigned int quality = 0, bend = 0;
1894  unsigned int best_quality, best_pattern;
1895  bool valid[2] = {false,false};
1896 
1897  // Time at which TMB latches LCTs.
1898  int latch_bx = first_bx + drift_delay;
1899 
1900  // Look at keystrips determined from priorityEncode and find their best
1901  // pattern based on number of hits matching that pattern (quality). Also
1902  // find bend angle. There are multiple patterns available for each keystrip.
1903 
1904  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1905  << "...............getKeyStripData....................";
1906 
1907  for (int ilct = 0; ilct < 2; ilct++) {
1908  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1909  << "lct " << ilct << " keystrip " << keystrip_data[ilct][CLCT_STRIP]
1910  << " type " << keystrip_data[ilct][CLCT_STRIP_TYPE];
1911  if (keystrip_data[ilct][CLCT_STRIP] == -1) {// flag set in priorityEncode()
1912  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1913  << "no lct at ilct " << ilct;
1914  continue;
1915  }
1916  for (int pattern_strip = 0; pattern_strip < NUM_PATTERN_STRIPS;
1917  pattern_strip++) {
1918  lct_pattern[pattern_strip] = -999;
1919  this_layer = pre_hit_pattern[0][pattern_strip];
1920  this_strip = pre_hit_pattern[1][pattern_strip] +
1921  keystrip_data[ilct][CLCT_STRIP];
1922  // This conditional statement prevents us from looking at strips
1923  // that don't exist along the chamber boundaries.
1924  if (keystrip_data[ilct][CLCT_STRIP_TYPE] == 1) {
1925  if (this_strip >= 0 && this_strip < CSCConstants::NUM_HALF_STRIPS) {
1926  // Now look at one-shots in bx where TMB latches the LCTs
1927  if (((h_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
1928  lct_pattern[pattern_strip] = 1;
1929  }
1930  }
1931  else {
1932  if (this_strip >= 0 && this_strip < CSCConstants::NUM_DI_STRIPS) {
1933  // Now look at one-shots in bx where TMB latches the LCTs
1934  if (((d_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
1935  lct_pattern[pattern_strip] = 1;
1936  }
1937  }
1938  }
1939 
1940  // Find best pattern and quality associated with key by looping over all
1941  // possible patterns
1942  best_quality = 0;
1943  best_pattern = 0;
1944 
1945  for (unsigned int pattern_num = 0;
1946  pattern_num < CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07; pattern_num++) {
1947  getPattern(pattern_num, lct_pattern, quality, bend);
1948  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1949  << "pattern " << pattern_num << " quality " << quality
1950  << " bend " << bend;
1951  // Number of layers hit matching a pattern template is compared
1952  // to nplanes_hit_pattern. The threshold is the same for both half- and
1953  // di-strip patterns.
1954  if (quality >= nplanes_hit_pattern) {
1955  // If the number of matches is the same for two pattern templates,
1956  // the higher pattern-template number is selected.
1957  if ((quality == best_quality && pattern_num > best_pattern) ||
1958  (quality > best_quality)) {
1959  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1960  << "valid = true at quality " << quality
1961  << " thresh " << nplanes_hit_pattern;
1962  valid[ilct] = true;
1963  keystrip_data[ilct][CLCT_PATTERN] = pattern_num;
1964  keystrip_data[ilct][CLCT_BEND] = bend;
1965  keystrip_data[ilct][CLCT_BX] = first_bx;
1966  //keystrip_data[ilct][CLCT_STRIP_TYPE] = stripType;
1967  keystrip_data[ilct][CLCT_QUALITY] = quality;
1968  best_quality = quality;
1969  best_pattern = pattern_num;
1970  }
1971  }
1972  }
1973 
1974  if (!valid[ilct]) {
1975  keystrip_data[ilct][CLCT_STRIP] = -1; // delete lct
1976  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1977  << "lct " << ilct << " not over threshold: deleting";
1978  }
1979  else {
1980  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1981  << "\n" << "--------- final LCT: " << ilct << " -------------\n"
1982  << " key strip " << keystrip_data[ilct][CLCT_STRIP]
1983  << " pattern_num " << keystrip_data[ilct][CLCT_PATTERN]
1984  << " quality " << keystrip_data[ilct][CLCT_QUALITY]
1985  << " bend " << keystrip_data[ilct][CLCT_BEND]
1986  << " bx " << keystrip_data[ilct][CLCT_BX]
1987  << " type " << keystrip_data[ilct][CLCT_STRIP_TYPE] << "\n";
1988  }
1989  } // end loop over lcts
1990 } // getKeyStripData -- pre-2007 version.
void getPattern(int pattern_num, int strip_value[NUM_PATTERN_STRIPS], int bx_time, int &quality, int &bend)
#define LogTrace(id)
static const int pre_hit_pattern[2][NUM_PATTERN_STRIPS]
void CSCCathodeLCTProcessor::getPattern ( int  pattern_num,
int  strip_value[NUM_PATTERN_STRIPS],
int  bx_time,
int &  quality,
int &  bend 
)
private

Definition at line 1375 of file CSCCathodeLCTProcessor.cc.

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

Referenced by getKeyStripData(), and testPatterns().

1377  {
1378  // This function takes strip values and bx_time to find out which hits fall
1379  // within a certain pattern. Quality, and bend are then calculated based on
1380  // which strip pattern and how many layers were hit within the pattern.
1381  int layers_hit = 0;
1382  bool hit_layer[CSCConstants::NUM_LAYERS];
1383 
1384  // Clear hit_layer array to keep track of number of layers hit.
1385  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++)
1386  hit_layer[i_layer] = false;
1387 
1388  // Loop over all designated patterns.
1389  for (int strip_num = 0; strip_num < NUM_PATTERN_STRIPS; strip_num++){
1390  if (hitIsGood(strip_value[strip_num], bx_time)){
1391  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++){
1392  // Loop over layer and see if corresponding strip is on same layer
1393  // If so then increment number of hits.
1394  if (i_layer == pattern[pattern_num][strip_num]){
1395  // If layer has no hits, then increment number of layers hit.
1396  if (hit_layer[i_layer] == false){
1397  layers_hit++;
1398  hit_layer[i_layer] = true;
1399  }
1400  }
1401  }
1402  }
1403  }
1404  // Get bend value from pattern.
1405  bend = pattern[pattern_num][NUM_PATTERN_STRIPS];
1406  quality = layers_hit;
1407 } // getPattern -- idealized version for MC studies.
static const int pattern[CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07][NUM_PATTERN_STRIPS+1]
bool hitIsGood(int hitTime, int BX)
void CSCCathodeLCTProcessor::getPattern ( unsigned int  pattern_num,
const int  strip_value[NUM_PATTERN_STRIPS],
unsigned int &  quality,
unsigned int &  bend 
)
private

Definition at line 1994 of file CSCCathodeLCTProcessor.cc.

References CSCConstants::NUM_LAYERS, NUM_PATTERN_STRIPS, and pattern.

1996  {
1997 
1998  // This function takes strip "one-shots" at the correct bx to find out
1999  // which hits fall within a certain pattern. Quality and bend are then
2000  // calculated based on which strip pattern and how many layers were hit
2001  // within the pattern.
2002 
2003  unsigned int layers_hit = 0;
2004  bool hit_layer[CSCConstants::NUM_LAYERS];
2005 
2006  // Clear hit_layer array to keep track of number of layers hit.
2007  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++)
2008  hit_layer[i_layer] = false;
2009 
2010  // Loop over all designated patterns.
2011  for (int strip_num = 0; strip_num < NUM_PATTERN_STRIPS; strip_num++){
2012  if (strip_value[strip_num] == 1){
2013  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++){
2014  // Loop over layer and see if corresponding strip is on same layer
2015  // If so then increment number of hits.
2016  if (i_layer == pattern[pattern_num][strip_num]){
2017  // If layer has no hits, then increment number of layers hit.
2018  if (hit_layer[i_layer] == false){
2019  layers_hit++;
2020  hit_layer[i_layer] = true;
2021  }
2022  }
2023  }
2024  }
2025  }
2026  // Get bend value from pattern.
2027  bend = pattern[pattern_num][NUM_PATTERN_STRIPS];
2028  quality = layers_hit;
2029 
2030 } // getPattern -- pre-2007 version.
static const int pattern[CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07][NUM_PATTERN_STRIPS+1]
bool CSCCathodeLCTProcessor::hitIsGood ( int  hitTime,
int  BX 
)
private

Definition at line 1411 of file CSCCathodeLCTProcessor.cc.

References dt, and hit_persist.

Referenced by getPattern().

1411  {
1412  // Find out if hit time is good. Hit should have occurred no more than
1413  // hit_persist clocks before the latching time.
1414  int dt = BX - hitTime;
1415  if (dt >= 0 && dt <= static_cast<int>(hit_persist)) {return true;}
1416  else {return false;}
1417 } // hitIsGood -- idealized version for MC studies.
float dt
Definition: AMPTWrapper.h:126
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 1650 of file CSCCathodeLCTProcessor.cc.

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

Referenced by findLCTs().

1653  {
1654 
1655  bool hit_layer[CSCConstants::NUM_LAYERS];
1656  int key_strip, this_layer, this_strip;
1657  int layers_hit, prev_hits;
1658 
1659  for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
1660  keyStrip[icfeb] = -1;
1661  n_hits[icfeb] = 0;
1662  }
1663 
1664  if (stripType != 0 && stripType != 1) {
1665  if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
1666  << "+++ latchLCTs: stripType = " << stripType
1667  << " does not correspond to half-strip/di-strip patterns! +++\n";
1668  return;
1669  }
1670 
1671  for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) { // loop over CFEBs
1672  prev_hits = 0;
1673  // Loop over (di-/half-)strips in CFEB.
1674  for (int istrip = 0; istrip < cfeb_strips[stripType]; istrip++) {
1675  // Calculate candidate key.
1676  key_strip = icfeb*cfeb_strips[stripType] + istrip;
1677  layers_hit = 0;
1678  for (int ilayer = 0; ilayer < CSCConstants::NUM_LAYERS; ilayer++)
1679  hit_layer[ilayer] = false;
1680 
1681  // Loop over strips in pretrigger pattern mask and look for hits.
1682  for (int pstrip = 0; pstrip < NUM_PATTERN_STRIPS; pstrip++) {
1683  this_layer = pre_hit_pattern[0][pstrip];
1684  this_strip = pre_hit_pattern[1][pstrip]+key_strip;
1685 
1686  if (this_strip >= 0 && this_strip < nStrips) {
1687  // Determine if "one shot" is high at this bx_time
1688  if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1689  if (hit_layer[this_layer] == false) {
1690  hit_layer[this_layer] = true;
1691  layers_hit++; // number of layers hit
1692  }
1693  }
1694  }
1695  } // end loop over strips in pretrigger pattern
1696  if (infoV > 1) {
1697  if (layers_hit > 0) LogTrace("CSCCathodeLCTProcessor")
1698  << "cfeb: " << icfeb << " key_strip: " << key_strip
1699  << " n_hits: " << layers_hit;
1700  }
1701  // If two or more keys have an equal number of hits, the lower number
1702  // key is taken. Hence, replace the previous key only if this key has
1703  // more hits.
1704  if (layers_hit > prev_hits) {
1705  prev_hits = layers_hit;
1706  keyStrip[icfeb] = key_strip; // key with highest hits is LCT key strip
1707  n_hits[icfeb] = layers_hit; // corresponding hits in envelope
1708  }
1709  } // end loop over candidate key strips in cfeb
1710  } // end loop over cfebs
1711 } // latchLCTs -- pre-2007 version.
static const int cfeb_strips[2]
#define LogTrace(id)
static const int pre_hit_pattern[2][NUM_PATTERN_STRIPS]
void CSCCathodeLCTProcessor::markBusyKeys ( const int  best_hstrip,
const int  best_patid,
int  quality[CSCConstants::NUM_HALF_STRIPS] 
)
private

Definition at line 2454 of file CSCCathodeLCTProcessor.cc.

References min_separation.

Referenced by findLCTs(), and findLCTsSLHC().

2456  {
2457  int nspan = min_separation;
2458  int pspan = min_separation;
2459 
2460  // if dynamic spacing is enabled, separation is defined by pattern width
2461  //if (dynamic_spacing)
2462  // nspan = pspan = pattern2007[best_patid][NUM_PATTERN_HALFSTRIPS+1]-1;
2463 
2464  for (int hstrip = best_hstrip-nspan; hstrip <= best_hstrip+pspan; hstrip++) {
2465  if (hstrip >= 0 && hstrip < CSCConstants::NUM_HALF_STRIPS) {
2466  quality[hstrip] = 0;
2467  }
2468  }
2469 } // 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 1236 of file CSCCathodeLCTProcessor.cc.

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

Referenced by findLCTs(), and findLCTsSLHC().

1239 {
1240  static const int hs_thresh = nplanes_hit_pretrig;
1241  static const int ds_thresh = nplanes_hit_pretrig;
1242 
1244  int i_layer, i_strip, this_layer, this_strip;
1245  int hits, layers_hit;
1246  bool hit_layer[CSCConstants::NUM_LAYERS];
1247 
1248  const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;
1249 
1250  // Fire half-strip/di-strip one-shots for hit_persist bx's (6 bx's by
1251  // default).
1252  pulseExtension(strip, nStrips, pulse);
1253 
1254  // Now do a loop over different bunch-crossing times.
1255  for (unsigned int bx_time = 0; bx_time < fifo_tbins; bx_time++) {
1256  // For any given bunch-crossing, start at the lowest keystrip and look for
1257  // the number of separate layers in the pattern for that keystrip that have
1258  // pulses at that bunch-crossing time. Do the same for the next keystrip,
1259  // etc. Then do the entire process again for the next bunch-crossing, etc
1260  // until you find a pre-trigger.
1261  for (int key_strip = 0; key_strip < nStrips; key_strip++){
1262  // Clear variables
1263  hits = 0;
1264  layers_hit = 0;
1265  for (i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++)
1266  hit_layer[i_layer] = false;
1267  // Loop over pattern strips and look for hits.
1268  for (i_strip = 0; i_strip < NUM_PATTERN_STRIPS; i_strip++){
1269  this_layer = pre_hit_pattern[0][i_strip];
1270  this_strip = pre_hit_pattern[1][i_strip]+key_strip;
1271  if (this_strip >= 0 && this_strip < nStrips) {
1272  // Perform bit operation to see if pulse is 1 at a certain bx_time.
1273  if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1274  hits++;
1275  // Store number of layers hit.
1276  if (hit_layer[this_layer] == false) {
1277  hit_layer[this_layer] = true;
1278  layers_hit++;
1279 
1280  // Look if number of layers hit is greater or equal than some
1281  // pre-defined threshold.
1282  if (layers_hit >= pre_trigger_layer_min) {
1283  first_bx = bx_time;
1284  return true;
1285  }
1286  }
1287  }
1288  }
1289  }
1290  }
1291  }
1292  // If the pretrigger was never satisfied, then return false.
1293  return false;
1294 } // preTrigger -- idealized version for MC studies.
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])
static const int pre_hit_pattern[2][NUM_PATTERN_STRIPS]
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 1555 of file CSCCathodeLCTProcessor.cc.

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

1559  {
1560  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1561  << "....................PreTrigger...........................";
1562 
1563  if (start_bx == 0) {
1564  // Fire one-shots for hit_persist bx's (6 bx's by default).
1565  pulseExtension(strip, nStrips, pulse);
1566  }
1567 
1568  bool pre_trig = false;
1569  // Now do a loop over bx times to see (if/when) track goes over threshold
1570  for (unsigned int bx_time = start_bx; bx_time < fifo_tbins; bx_time++) {
1571  // For any given bunch-crossing, start at the lowest keystrip and look for
1572  // the number of separate layers in the pattern for that keystrip that have
1573  // pulses at that bunch-crossing time. Do the same for the next keystrip,
1574  // etc. Then do the entire process again for the next bunch-crossing, etc
1575  // until you find a pre-trigger.
1576  pre_trig = preTrigLookUp(pulse, stripType, nStrips, bx_time);
1577  if (pre_trig) {
1578  first_bx = bx_time; // bx at time of pretrigger
1579  return true;
1580  }
1581  } // end loop over bx times
1582 
1583  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1584  << "no pretrigger for strip type " << stripType << ", returning \n";
1585  first_bx = fifo_tbins;
1586  return false;
1587 } // preTrigger -- pre-2007 version.
#define LogTrace(id)
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])
bool preTrigLookUp(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips, const unsigned int bx_time)
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 2279 of file CSCCathodeLCTProcessor.cc.

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

2281  {
2282  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
2283  << "....................PreTrigger...........................";
2284 
2285  // Max. number of half-strips for this chamber.
2286  const int nStrips = 2*numStrips + 1;
2287 
2288  bool pre_trig = false;
2289  // Now do a loop over bx times to see (if/when) track goes over threshold
2290  for (unsigned int bx_time = start_bx; bx_time < fifo_tbins; bx_time++) {
2291  // For any given bunch-crossing, start at the lowest keystrip and look for
2292  // the number of separate layers in the pattern for that keystrip that have
2293  // pulses at that bunch-crossing time. Do the same for the next keystrip,
2294  // etc. Then do the entire process again for the next bunch-crossing, etc
2295  // until you find a pre-trigger.
2296  bool hits_in_time = ptnFinding(pulse, nStrips, bx_time);
2297  if (hits_in_time) {
2298  for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER-1];
2299  hstrip < nStrips; hstrip++) {
2300  if (infoV > 1) {
2301  if (nhits[hstrip] > 0) {
2302  LogTrace("CSCCathodeLCTProcessor")
2303  << " bx = " << std::setw(2) << bx_time << " --->"
2304  << " halfstrip = " << std::setw(3) << hstrip
2305  << " best pid = " << std::setw(2) << best_pid[hstrip]
2306  << " nhits = " << nhits[hstrip];
2307  }
2308  }
2309  ispretrig[hstrip] = 0;
2310  if (nhits[hstrip] >= nplanes_hit_pretrig &&
2311  best_pid[hstrip] >= pid_thresh_pretrig) {
2312  pre_trig = true;
2313  ispretrig[hstrip] = 1;
2314  }
2315  }
2316 
2317  if (pre_trig) {
2318  first_bx = bx_time; // bx at time of pretrigger
2319  return true;
2320  }
2321  }
2322  } // end loop over bx times
2323 
2324  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor") <<
2325  "no pretrigger, returning \n";
2326  first_bx = fifo_tbins;
2327  return false;
2328 } // preTrigger -- TMB-07 version.
#define LogTrace(id)
int stagger[CSCConstants::NUM_LAYERS]
unsigned int best_pid[CSCConstants::NUM_HALF_STRIPS]
unsigned int nhits[CSCConstants::NUM_HALF_STRIPS]
bool ptnFinding(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int nStrips, const unsigned int bx_time)
bool ispretrig[CSCConstants::NUM_HALF_STRIPS]
std::vector<int> CSCCathodeLCTProcessor::preTriggerBXs ( ) const
inline

Definition at line 84 of file CSCCathodeLCTProcessor.h.

References thePreTriggerBXs.

Referenced by CSCTriggerPrimitivesBuilder::build().

84 {return thePreTriggerBXs;}
std::vector< int > 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 1591 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().

1594  {
1595  static const int hs_thresh = nplanes_hit_pretrig;
1596  static const int ds_thresh = nplanes_hit_pretrig;
1597 
1598  bool hit_layer[CSCConstants::NUM_LAYERS];
1599  int key_strip, this_layer, this_strip, layers_hit;
1600 
1601  // Layers hit threshold for pretrigger
1602  const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;
1603 
1604  if (stripType != 0 && stripType != 1) {
1605  if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
1606  << "+++ preTrigLookUp: stripType = " << stripType
1607  << " does not correspond to half-strip/di-strip patterns! +++\n";
1608  return false;
1609  }
1610 
1611  for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) { // loop over cfebs
1612  // Loop over (di-/half-)strips in CFEB.
1613  for (int istrip = 0; istrip < cfeb_strips[stripType]; istrip++) {
1614  // Calculate candidate key.
1615  key_strip = icfeb*cfeb_strips[stripType] + istrip;
1616  layers_hit = 0;
1617  for (int ilayer = 0; ilayer < CSCConstants::NUM_LAYERS; ilayer++)
1618  hit_layer[ilayer] = false;
1619 
1620  // Loop over strips in pretrigger pattern mask and look for hits.
1621  for (int pstrip = 0; pstrip < NUM_PATTERN_STRIPS; pstrip++) {
1622  this_layer = pre_hit_pattern[0][pstrip];
1623  this_strip = pre_hit_pattern[1][pstrip]+key_strip;
1624 
1625  if (this_strip >= 0 && this_strip < nStrips) {
1626  // Determine if "one shot" is high at this bx_time
1627  if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1628  if (hit_layer[this_layer] == false) {
1629  hit_layer[this_layer] = true;
1630  layers_hit++; // determines number of layers hit
1631  if (layers_hit >= pre_trigger_layer_min) {
1632  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1633  << "pretrigger at bx: " << bx_time
1634  << ", cfeb " << icfeb << ", returning";
1635  return true;
1636  }
1637  }
1638  }
1639  }
1640  } // end loop over strips in pretrigger pattern
1641  } // end loop over candidate key strips in cfeb
1642  } // end loop over cfebs, if pretrigger is found, stop looking and return
1643 
1644  return false;
1645 
1646 } // preTrigLookUp -- pre-2007 version.
static const int cfeb_strips[2]
#define LogTrace(id)
static const int pre_hit_pattern[2][NUM_PATTERN_STRIPS]
void CSCCathodeLCTProcessor::printPatterns ( )
private

Definition at line 2999 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, and pattern.

2999  {
3000  // @@
3001  std::cout<<" Printing patterns for Cathode LCT"<<std::endl;
3002  std::cout<<" ";
3003  for (int patternNum = 0; patternNum < CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07; patternNum++) {
3004  std::cout<<" Pattern "<<patternNum<<" ";
3005  }
3006  std::cout<<std::endl;
3007  std::cout<<" Layer ";
3008  for (int patternNum = 0; patternNum < CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07; patternNum++) {
3009  std::cout<<" Bend "<<(pattern[patternNum][NUM_PATTERN_STRIPS]==0 ? "L": "R")<<" ";
3010  }
3011  std::cout<<std::endl;
3012  for (int layer = 0; layer < CSCConstants::NUM_LAYERS; layer++) {
3013  for (int patternNum = 0; patternNum < CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07; patternNum++) {
3014  if (patternNum == 0) std::cout<<" "<<layer<<" ";
3015  if ((isTMB07 && layer != CSCConstants::KEY_CLCT_LAYER-1) ||
3016  (!isTMB07 && layer != CSCConstants::KEY_CLCT_LAYER_PRE_TMB07-1)) {//that old counting from 1 vs 0 thing.
3017  int minStrip =0;
3018  if ((isTMB07 && layer < CSCConstants::KEY_CLCT_LAYER-1) ||
3020  minStrip = 3*layer;
3021  } else {
3022  minStrip = 3*layer - 2;// since on the key layer we only have 1 strip
3023  }
3024  for (int strip = minStrip; strip < minStrip + 3; strip++) {
3025  if (layer == pattern[patternNum][strip]) {
3026  std::cout<<"X";
3027  } else {
3028  std::cout<<"_";
3029  }
3030  }
3031  } else {// on the key layer we always have a hit, right?
3032  std::cout<<" X ";
3033  }
3034  std::cout<<" ";
3035  }
3036  std::cout<<std::endl;
3037  }
3038 }
static const int pattern[CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07][NUM_PATTERN_STRIPS+1]
tuple cout
Definition: gather_cfg.py:121
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 1715 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().

1718  {
1719  static const unsigned int hs_thresh = nplanes_hit_pretrig;
1720  //static const unsigned int ds_thresh = nplanes_hit_pretrig;
1721 
1722  int ihits[2]; // hold hits for sorting
1723  int cfebs[2]; // holds CFEB numbers corresponding to highest hits
1724  const int nlcts = 2;
1725  int key_strip[MAX_CFEBS], key_phits[MAX_CFEBS], strip_type[MAX_CFEBS];
1726 
1727  // initialize arrays
1728  for (int ilct = 0; ilct < nlcts; ilct++) {
1729  for (int j = 0; j < 7; j++) keystrip_data[ilct][j] = -1;
1730  ihits[ilct] = 0;
1731  cfebs[ilct] = -1;
1732  }
1733  for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
1734  key_strip[icfeb] = -1;
1735  key_phits[icfeb] = -1;
1736  strip_type[icfeb] = -1;
1737  }
1738 
1739  if (infoV > 1) {
1740  LogTrace("CSCCathodeLCTProcessor")
1741  << ".....................PriorityEncode.......................";
1742  std::ostringstream strstrm;
1743  strstrm << "hkeys:";
1744  for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
1745  strstrm << std::setw(4) << h_keyStrip[icfeb];
1746  }
1747  strstrm << "\ndkeys:";
1748  for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
1749  strstrm << std::setw(4) << d_keyStrip[icfeb];
1750  }
1751  LogTrace("CSCCathodeLCTProcessor") << strstrm.str();
1752  }
1753 
1754  // Loop over CFEBs and determine better of half- or di- strip pattern.
1755  // If select halfstrip, promote it by adding an extra bit to its hits.
1756  for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
1757  if (h_keyStrip[icfeb] != -1 && d_keyStrip[icfeb] != -1) {
1758  if (h_nhits[icfeb] >= hs_thresh) {
1759  key_strip[icfeb] = h_keyStrip[icfeb];
1760  key_phits[icfeb] = h_nhits[icfeb] + 8; // halfstrip promotion
1761  strip_type[icfeb]= 1;
1762  }
1763  // For di-strip envelope there is no requirement that the number of
1764  // layers hit is >= ds_thresh!!!
1765  // else if (d_nhits[icfeb] >= ds_thresh) {
1766  else {
1767  key_strip[icfeb] = d_keyStrip[icfeb];
1768  key_phits[icfeb] = d_nhits[icfeb];
1769  strip_type[icfeb]= 0;
1770  }
1771  }
1772  else if (h_keyStrip[icfeb] != -1) {
1773  if (h_nhits[icfeb] >= hs_thresh) {
1774  key_strip[icfeb] = h_keyStrip[icfeb];
1775  key_phits[icfeb] = h_nhits[icfeb] + 8; // halfstrip promotion
1776  strip_type[icfeb]= 1;
1777  }
1778  }
1779  else if (d_keyStrip[icfeb] != -1) {
1780  // if (d_nhits[icfeb] >= ds_thresh) {
1781  key_strip[icfeb] = d_keyStrip[icfeb];
1782  key_phits[icfeb] = d_nhits[icfeb];
1783  strip_type[icfeb]= 0;
1784  // }
1785  }
1786  if (infoV > 1 && strip_type[icfeb] != -1) {
1787  if (strip_type[icfeb] == 0)
1788  LogTrace("CSCCathodeLCTProcessor")
1789  << " taking distrip pattern on cfeb " << icfeb;
1790  else if (strip_type[icfeb] == 1)
1791  LogTrace("CSCCathodeLCTProcessor")
1792  << " taking halfstrip pattern on cfeb " << icfeb;
1793  LogTrace("CSCCathodeLCTProcessor")
1794  << " cfeb " << icfeb << " key " << key_strip[icfeb]
1795  << " hits " << key_phits[icfeb] << " type " << strip_type[icfeb];
1796  }
1797  }
1798 
1799  // Remove duplicate LCTs at boundaries -- it is possilbe to have key[0]
1800  // be the higher of the two key strips, take this into account, but
1801  // preserve rank of lcts.
1802  int key[MAX_CFEBS];
1803  int loedge, hiedge;
1804 
1805  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1806  << "...... Remove Duplicates ......";
1807  for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
1808  if(strip_type[icfeb] == 0) key[icfeb] = key_strip[icfeb]*4;
1809  else key[icfeb] = key_strip[icfeb];
1810  }
1811  for (int icfeb = 0; icfeb < MAX_CFEBS-1; icfeb++) {
1812  if (key[icfeb] >= 0 && key[icfeb+1] >= 0) {
1813  loedge = cfeb_strips[1]*(icfeb*8+7)/8;
1814  hiedge = cfeb_strips[1]*(icfeb*8+9)/8 - 1;
1815  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1816  << " key 1: " << key[icfeb] << " key 2: " << key[icfeb+1]
1817  << " low edge: " << loedge << " high edge: " << hiedge;
1818  if (key[icfeb] >= loedge && key[icfeb+1] <= hiedge) {
1819  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1820  << "Duplicate LCTs found at boundary of CFEB " << icfeb << " ...";
1821  if (key_phits[icfeb+1] > key_phits[icfeb]) {
1822  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1823  << " deleting LCT on CFEB " << icfeb;
1824  key_strip[icfeb] = -1;
1825  key_phits[icfeb] = -1;
1826  }
1827  else {
1828  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1829  << " deleting LCT on CFEB " << icfeb+1;
1830  key_strip[icfeb+1] = -1;
1831  key_phits[icfeb+1] = -1;
1832  }
1833  }
1834  }
1835  }
1836 
1837  // Now loop over CFEBs and pick best two lcts based on no. hits in envelope.
1838  // In case of equal quality, select the one on lower-numbered CFEBs.
1839  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1840  << "\n...... Select best LCTs ......";
1841  for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
1842  if (key_phits[icfeb] > ihits[0]) {
1843  ihits[1] = ihits[0];
1844  cfebs[1] = cfebs[0];
1845  ihits[0] = key_phits[icfeb];
1846  cfebs[0] = icfeb;
1847  if (infoV > 1) {
1848  std::ostringstream strstrm;
1849  for (int icfeb = 0; icfeb < MAX_CFEBS; icfeb++) {
1850  strstrm << std::setw(4) << strip_type[icfeb];
1851  }
1852  LogTrace("CSCCathodeLCTProcessor")
1853  << "strip_type" << strstrm.str()
1854  << "\n best: ihits " << ihits[0] << " cfeb " << cfebs[0]
1855  << " strip_type " << ((cfebs[0] >= 0) ? strip_type[cfebs[0]] : -1)
1856  << "\n next: ihits " << ihits[1] << " cfeb " << cfebs[1]
1857  << " strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
1858  }
1859  }
1860  else if (key_phits[icfeb] > ihits[1]) {
1861  ihits[1] = key_phits[icfeb];
1862  cfebs[1] = icfeb;
1863  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1864  << "\n next: ihits " << ihits[1] << " cfeb " << cfebs[1]
1865  << " strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
1866  }
1867  }
1868 
1869  // fill lct data array key strip with 2 highest hit lcts (if they exist)
1870  int jlct = 0;
1871  for (int ilct = 0; ilct < nlcts; ilct++) {
1872  if (cfebs[ilct] != -1) {
1873  keystrip_data[jlct][CLCT_CFEB] = cfebs[ilct];
1874  keystrip_data[jlct][CLCT_STRIP] = key_strip[cfebs[ilct]];
1875  keystrip_data[jlct][CLCT_STRIP_TYPE] = strip_type[cfebs[ilct]];
1876  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
1877  << "filling key: " << key_strip[cfebs[ilct]]
1878  << " type: " << strip_type[cfebs[ilct]];
1879  jlct++;
1880  }
1881  }
1882 } // priorityEncode -- pre-2007 version.
static const int cfeb_strips[2]
int j
Definition: DBlmapReader.cc:9
#define LogTrace(id)
list key
Definition: combine.py:13
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 2332 of file CSCCathodeLCTProcessor.cc.

References best_pid, fifo_tbins, first_bx_corrected, hit_persist, 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(), findLCTsSLHC(), and preTrigger().

2335 {
2336  if (bx_time >= fifo_tbins) return false;
2337 
2338  // This loop is a quick check of a number of layers hit at bx_time: since
2339  // most of the time it is 0, this check helps to speed-up the execution
2340  // substantially.
2341  unsigned int layers_hit = 0;
2342  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++)
2343  {
2344  for (int i_hstrip = 0; i_hstrip < nStrips; i_hstrip++)
2345  {
2346  if (((pulse[i_layer][i_hstrip] >> bx_time) & 1) == 1)
2347  {
2348  layers_hit++;
2349  break;
2350  }
2351  }
2352  }
2353  if (layers_hit < nplanes_hit_pretrig) return false;
2354 
2355  for (int key_hstrip = 0; key_hstrip < nStrips; key_hstrip++)
2356  {
2357  best_pid[key_hstrip] = 0;
2358  nhits[key_hstrip] = 0;
2359  first_bx_corrected[key_hstrip] = -999;
2360  }
2361 
2362  // Loop over candidate key strips.
2363  bool hit_layer[CSCConstants::NUM_LAYERS];
2364  for (int key_hstrip = stagger[CSCConstants::KEY_CLCT_LAYER - 1]; key_hstrip < nStrips; key_hstrip++)
2365  {
2366  // Loop over patterns and look for hits matching each pattern.
2367  for (unsigned int pid = CSCConstants::NUM_CLCT_PATTERNS - 1; pid >= pid_thresh_pretrig; pid--)
2368  {
2369  layers_hit = 0;
2370  for (int ilayer = 0; ilayer < CSCConstants::NUM_LAYERS; ilayer++)
2371  hit_layer[ilayer] = false;
2372 
2373  double num_pattern_hits=0., times_sum=0.;
2374  std::multiset<int> mset_for_median;
2375  mset_for_median.clear();
2376 
2377  // Loop over halfstrips in trigger pattern mask and calculate the
2378  // "absolute" halfstrip number for each.
2379  for (int strip_num = 0; strip_num < NUM_PATTERN_HALFSTRIPS; strip_num++)
2380  {
2381  int this_layer = pattern2007[pid][strip_num];
2382  if (this_layer >= 0 && this_layer < CSCConstants::NUM_LAYERS)
2383  {
2384  int this_strip = pattern2007_offset[strip_num] + key_hstrip;
2385  if (this_strip >= 0 && this_strip < nStrips) {
2386  if (infoV > 3) LogTrace("CSCCathodeLCTProcessor")
2387  << " In ptnFinding: key_strip = " << key_hstrip
2388  << " pid = " << pid << " strip_num = " << strip_num
2389  << " layer = " << this_layer << " strip = " << this_strip;
2390  // Determine if "one shot" is high at this bx_time
2391  if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1)
2392  {
2393  if (hit_layer[this_layer] == false)
2394  {
2395  hit_layer[this_layer] = true;
2396  layers_hit++; // determines number of layers hit
2397  }
2398 
2399  // find at what bx did pulse on this halsfstrip&layer have started
2400  // use hit_pesrist constraint on how far back we can go
2401  int first_bx_layer = bx_time;
2402  for (unsigned int dbx = 0; dbx < hit_persist; dbx++)
2403  {
2404  if (((pulse[this_layer][this_strip] >> (first_bx_layer - 1)) & 1) == 1)
2405  first_bx_layer--;
2406  else
2407  break;
2408  }
2409  times_sum += (double) first_bx_layer;
2410  num_pattern_hits += 1.;
2411  mset_for_median.insert(first_bx_layer);
2412  if (infoV > 2)
2413  LogTrace("CSCCathodeLCTProcessor") << " 1st bx in layer: " << first_bx_layer << " sum bx: " << times_sum
2414  << " #pat. hits: " << num_pattern_hits;
2415  }
2416  }
2417  }
2418  } // end loop over strips in pretrigger pattern
2419 
2420  if (layers_hit > nhits[key_hstrip])
2421  {
2422  best_pid[key_hstrip] = pid;
2423  nhits[key_hstrip] = layers_hit;
2424 
2425  // calculate median
2426  const int sz = mset_for_median.size();
2427  if (sz>0){
2428  std::multiset<int>::iterator im = mset_for_median.begin();
2429  if (sz>1) std::advance(im,sz/2-1);
2430  if (sz==1) first_bx_corrected[key_hstrip] = *im;
2431  else if ((sz % 2) == 1) first_bx_corrected[key_hstrip] = *(++im);
2432  else first_bx_corrected[key_hstrip] = ((*im) + (*(++im)))/2;
2433 
2434  if (infoV > 1) {
2435  char bxs[300]="";
2436  for (im = mset_for_median.begin(); im != mset_for_median.end(); im++)
2437  sprintf(bxs,"%s %d", bxs, *im);
2438  LogTrace("CSCCathodeLCTProcessor")
2439  <<"bx="<<bx_time<<" bx_cor="<< first_bx_corrected[key_hstrip]<<" bxset="<<bxs;
2440  }
2441  }
2442 
2443  // Do not loop over the other (worse) patterns if max. numbers of
2444  // hits is found.
2445  if (nhits[key_hstrip] == CSCConstants::NUM_LAYERS) break;
2446  }
2447  } // end loop over pid
2448  } // end loop over candidate key strips
2449  return true;
2450 } // ptnFinding -- TMB-07 version.
int first_bx_corrected[CSCConstants::NUM_HALF_STRIPS]
static const int pattern2007[CSCConstants::NUM_CLCT_PATTERNS][NUM_PATTERN_HALFSTRIPS+2]
#define LogTrace(id)
int stagger[CSCConstants::NUM_LAYERS]
unsigned int best_pid[CSCConstants::NUM_HALF_STRIPS]
static const int pattern2007_offset[NUM_PATTERN_HALFSTRIPS]
unsigned int nhits[CSCConstants::NUM_HALF_STRIPS]
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 2231 of file CSCCathodeLCTProcessor.cc.

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

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

2234  {
2235 
2236  static unsigned int bits_in_pulse = 8*sizeof(pulse[0][0]);
2237 
2238  // Clear pulse array. This array will be used as a bit representation of
2239  // hit times. For example: if strip[1][2] has a value of 3, then 1 shifted
2240  // left 3 will be bit pattern of pulse[1][2]. This would make the pattern
2241  // look like 0000000000001000. Then add on additional bits to signify
2242  // the duration of a signal (hit_persist, formerly bx_width) to simulate
2243  // the TMB's drift delay. So for the same pulse[1][2] with a hit_persist
2244  // of 3 would look like 0000000000111000. This is similating the digital
2245  // one-shot in the TMB.
2246  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++)
2247  for (int i_strip = 0; i_strip < nStrips; i_strip++)
2248  pulse[i_layer][i_strip] = 0;
2249 
2250  // Loop over all layers and halfstrips.
2251  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
2252  for (int i_strip = 0; i_strip < nStrips; i_strip++) {
2253  // If there is a hit, simulate digital one-shot persistence starting
2254  // in the bx of the initial hit. Fill this into pulse[][].
2255  if (time[i_layer][i_strip].size() > 0) {
2256  std::vector<int> bx_times = time[i_layer][i_strip];
2257  for (unsigned int i = 0; i < bx_times.size(); i++) {
2258  // Check that min and max times are within the allowed range.
2259  if (bx_times[i] < 0 || bx_times[i] + hit_persist >= bits_in_pulse) {
2260  if (infoV > 0) edm::LogWarning("L1CSCTPEmulatorOutOfTimeDigi")
2261  << "+++ BX time of comparator digi (halfstrip = " << i_strip
2262  << " layer = " << i_layer << ") bx = " << bx_times[i]
2263  << " is not within the range (0-" << bits_in_pulse
2264  << "] allowed for pulse extension. Skip this digi! +++\n";
2265  continue;
2266  }
2267  if (bx_times[i] >= start_bx_shift) {
2268  for (unsigned int bx = bx_times[i]; bx < bx_times[i] + hit_persist; ++bx)
2269  pulse[i_layer][i_strip] = pulse[i_layer][i_strip] | (1 << bx);
2270  }
2271  }
2272  }
2273  }
2274  }
2275 } // pulseExtension.
int i
Definition: DBlmapReader.cc:9
tuple size
Write out results.
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 907 of file CSCCathodeLCTProcessor.cc.

References AlCaHLTBitMon_QueryRunRegistry::comp, 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().

909  {
910  // Two-argument version for pre-TMB07 (halfstrip and distrips) firmware.
911  // Takes the comparator & time info and stuffs it into halfstrip and (and
912  // possibly distrip) vector.
913 
917  for (int i = 0; i < CSCConstants::NUM_LAYERS; i++){
918  for (int j = 0; j < CSCConstants::MAX_NUM_STRIPS; j++) {
919  time[i][j] = -999;
920  comp[i][j] = 0;
921  digiNum[i][j] = -999;
922  }
923  }
924 
925  for (int i = 0; i < CSCConstants::NUM_LAYERS; i++) {
926  std::vector <CSCComparatorDigi> layerDigiV = digiV[i];
927  for (unsigned int j = 0; j < layerDigiV.size(); j++) {
928  // Get one digi at a time for the layer. -Jm
929  CSCComparatorDigi thisDigi = layerDigiV[j];
930 
931  // Dump raw digi info
932  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
933  << "Comparator digi: comparator = " << thisDigi.getComparator()
934  << " strip #" << thisDigi.getStrip()
935  << " time bin = " << thisDigi.getTimeBin();
936 
937  // Get comparator: 0/1 for left/right halfstrip for each comparator
938  // that fired.
939  int thisComparator = thisDigi.getComparator();
940  if (thisComparator != 0 && thisComparator != 1) {
941  if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
942  << "+++ Comparator digi with wrong comparator value: digi #" << j
943  << ", comparator = " << thisComparator << "; skipping it... +++\n";
944  continue;
945  }
946 
947  // Get strip number.
948  int thisStrip = thisDigi.getStrip() - 1; // count from 0
949  if (thisStrip < 0 || thisStrip >= numStrips) {
950  if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
951  << "+++ Comparator digi with wrong strip number: digi #" << j
952  << ", strip = " << thisStrip
953  << ", max strips = " << numStrips << "; skipping it... +++\n";
954  continue;
955  }
956 
957  // Get Bx of this Digi and check that it is within the bounds
958  int thisDigiBx = thisDigi.getTimeBin();
959 
960  // Total number of time bins in DAQ readout is given by fifo_tbins,
961  // which thus determines the maximum length of time interval.
962  if (thisDigiBx >= 0 && thisDigiBx < static_cast<int>(fifo_tbins)) {
963 
964  // If there is more than one hit in the same strip, pick one
965  // which occurred earlier.
966  // In reality, the second hit on the same distrip is ignored only
967  // during the number of clocks defined by the "hit_persist"
968  // parameter (i.e., 6 bx's by default). So if one simulates
969  // a large number of bx's in a crowded environment, this
970  // approximation here may not be sufficiently good.
971  if (time[i][thisStrip] == -999 || time[i][thisStrip] > thisDigiBx) {
972  digiNum[i][thisStrip] = j;
973  time[i][thisStrip] = thisDigiBx;
974  comp[i][thisStrip] = thisComparator;
975  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
976  << "Comp digi: layer " << i+1
977  << " digi #" << j+1
978  << " strip " << thisStrip
979  << " halfstrip " << 2*thisStrip + comp[i][thisStrip] + stagger[i]
980  << " distrip " << thisStrip/2 + // [0-39]
981  ((thisStrip%2 == 1 && comp[i][thisStrip] == 1 && stagger[i] == 1) ? 1 : 0)
982  << " time " << time[i][thisStrip]
983  << " comparator " << comp[i][thisStrip]
984  << " stagger " << stagger[i];
985  }
986  }
987  else {
988  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
989  << "+++ Skipping comparator digi: strip = " << thisStrip
990  << ", layer = " << i+1 << ", bx = " << thisDigiBx << " +++";
991  }
992  }
993  }
994 
995  // Take the comparator & time info and stuff it into half- and di-strip
996  // arrays.
997  for (int i = 0; i < CSCConstants::NUM_LAYERS; i++) {
998  // Use the comparator info to setup the halfstrips and distrips. -BT
999  // This loop is only for halfstrips.
1000  for (int j = 0; j < CSCConstants::MAX_NUM_STRIPS; j++) {
1001  if (time[i][j] >= 0) {
1002  int i_halfstrip = 2*j + comp[i][j] + stagger[i];
1003  // 2*j : convert strip to 1/2 strip
1004  // comp : comparator output
1005  // stagger: stagger for this layer
1006  if (i_halfstrip >= 2*numStrips + 1) {
1007  if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
1008  << "+++ Found wrong halfstrip number = " << i_halfstrip
1009  << "; skipping this digi... +++\n";
1010  continue;
1011  }
1012  halfstrip[i][i_halfstrip].push_back(time[i][j]);
1013  }
1014  }
1015 
1016  // There are no di-strips in the 2007 version of the TMB firmware.
1017  if (!isTMB07) {
1018  // This loop is only for distrips. We have to separate the routines
1019  // because triad and time arrays can be changed by the distripStagger
1020  // routine which could mess up the halfstrips.
1021  static int test_iteration = 0;
1022  for (int j = 0; j < CSCConstants::MAX_NUM_STRIPS; j++){
1023  if (time[i][j] >= 0) {
1024  int i_distrip = j/2;
1025  if (j%2 == 1 && comp[i][j] == 1 && stagger[i] == 1) {
1026  // @@ Needs to be checked.
1027  bool stagger_debug = (infoV > 2);
1028  distripStagger(comp[i], time[i], digiNum[i], j, stagger_debug);
1029  }
1030  // comp[i][j] == 1 : hit on right half-strip.
1031  // stagger[i] == 1 : half-strips are shifted by 1.
1032  // if these conditions are met add 1; otherwise add 0.
1033  // So if there is a hit on the far right half-strip, and the
1034  // half-strips have been staggered to the right, then the di-strip
1035  // would actually correspond to the next highest di-strip. -JM
1036  if (infoV > 2 && test_iteration == 1) {
1038  test_iteration++;
1039  }
1040  if (i_distrip >= numStrips/2 + 1) {
1041  if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
1042  << "+++ Found wrong distrip number = " << i_distrip
1043  << "; skipping this digi... +++\n";
1044  continue;
1045  }
1046  distrip[i][i_distrip].push_back(time[i][j]);
1047  }
1048  }
1049  }
1050  }
1051 }
int i
Definition: DBlmapReader.cc:9
int getStrip() const
Get the strip number.
int getComparator() const
Get Comparator readings.
int getTimeBin() const
Return bin number of first time bin which is ON. Counts from 0.
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)
int j
Definition: DBlmapReader.cc:9
#define LogTrace(id)
int stagger[CSCConstants::NUM_LAYERS]
std::vector< CSCComparatorDigi > digiV[CSCConstants::NUM_LAYERS]
void CSCCathodeLCTProcessor::readComparatorDigis ( std::vector< int >  halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
private

Definition at line 809 of file CSCCathodeLCTProcessor.cc.

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

810  {
811  // Single-argument version for TMB07 (halfstrip-only) firmware.
812  // Takes the comparator & time info and stuffs it into halfstrip vector.
813  // Multiple hits on the same strip are allowed.
814 
815  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
816  int i_digi = 0; // digi counter, for dumps.
817  for (std::vector<CSCComparatorDigi>::iterator pld = digiV[i_layer].begin();
818  pld != digiV[i_layer].end(); pld++, i_digi++) {
819  // Dump raw digi info.
820  if (infoV > 1) {
821  std::ostringstream strstrm;
822  strstrm << "Comparator digi: comparator = " << pld->getComparator()
823  << " strip #" << pld->getStrip()
824  << " time bins on:";
825  std::vector<int> bx_times = pld->getTimeBinsOn();
826  for (unsigned int tbin = 0; tbin < bx_times.size(); tbin++)
827  strstrm << " " << bx_times[tbin];
828  LogTrace("CSCCathodeLCTProcessor") << strstrm.str();
829  }
830 
831  // Get comparator: 0/1 for left/right halfstrip for each comparator
832  // that fired.
833  int thisComparator = pld->getComparator();
834  if (thisComparator != 0 && thisComparator != 1) {
835  if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
836  << "+++ Found comparator digi with wrong comparator value = "
837  << thisComparator << "; skipping it... +++\n";
838  continue;
839  }
840 
841  // Get strip number.
842  int thisStrip = pld->getStrip() - 1; // count from 0
843  if (thisStrip < 0 || thisStrip >= numStrips) {
844  if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
845  << "+++ Found comparator digi with wrong strip number = "
846  << thisStrip
847  << " (max strips = " << numStrips << "); skipping it... +++\n";
848  continue;
849  }
850  // 2*strip: convert strip to 1/2 strip
851  // comp : comparator output
852  // stagger: stagger for this layer
853  int thisHalfstrip = 2*thisStrip + thisComparator + stagger[i_layer];
854  if (thisHalfstrip >= 2*numStrips + 1) {
855  if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
856  << "+++ Found wrong halfstrip number = " << thisHalfstrip
857  << "; skipping this digi... +++\n";
858  continue;
859  }
860 
861  // Get bx times on this digi and check that they are within the bounds.
862  std::vector<int> bx_times = pld->getTimeBinsOn();
863  for (unsigned int i = 0; i < bx_times.size(); i++) {
864  // Total number of time bins in DAQ readout is given by fifo_tbins,
865  // which thus determines the maximum length of time interval.
866  //
867  // In TMB07 version, better data-emulator agreement is
868  // achieved when hits in the first 2 time bins are excluded.
869  // As of May 2009, the reasons for this are not fully
870  // understood yet (the work is on-going).
871  if (bx_times[i] > 1 && bx_times[i] < static_cast<int>(fifo_tbins)) {
872 
873  if (i == 0 || (i > 0 && bx_times[i]-bx_times[i-1] >=
874  static_cast<int>(hit_persist))) {
875  // A later hit on the same strip is ignored during the
876  // number of clocks defined by the "hit_persist" parameter
877  // (i.e., 6 bx's by default).
878  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
879  << "Comp digi: layer " << i_layer+1
880  << " digi #" << i_digi+1
881  << " strip " << thisStrip
882  << " halfstrip " << thisHalfstrip
883  << " distrip " << thisStrip/2 + // [0-39]
884  ((thisStrip%2 == 1 && thisComparator == 1 && stagger[i_layer] == 1) ? 1 : 0)
885  << " time " << bx_times[i]
886  << " comparator " << thisComparator
887  << " stagger " << stagger[i_layer];
888  halfstrip[i_layer][thisHalfstrip].push_back(bx_times[i]);
889  }
890  else if (i > 0) {
891  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
892  << " Skipping comparator digi: strip = " << thisStrip
893  << ", layer = " << i_layer+1 << ", bx = " << bx_times[i]
894  << ", bx of previous hit = " << bx_times[i-1];
895  }
896  }
897  else {
898  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
899  << "+++ Skipping comparator digi: strip = " << thisStrip
900  << ", layer = " << i_layer+1 << ", bx = " << bx_times[i] << " +++";
901  }
902  }
903  }
904  }
905 }
int i
Definition: DBlmapReader.cc:9
#define LogTrace(id)
int stagger[CSCConstants::NUM_LAYERS]
#define begin
Definition: vmac.h:31
std::vector< CSCComparatorDigi > digiV[CSCConstants::NUM_LAYERS]
std::vector< CSCCLCTDigi > CSCCathodeLCTProcessor::readoutCLCTs ( )

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

Definition at line 2812 of file CSCCathodeLCTProcessor.cc.

References early_tbins, getCLCTs(), infoV, LogDebug, MAX_CLCT_BINS, readout_earliest_2, and tmb_l1a_window_size.

Referenced by CSCTriggerPrimitivesBuilder::build().

2812  {
2813  std::vector<CSCCLCTDigi> tmpV;
2814 
2815  // The start time of the L1A*CLCT coincidence window should be
2816  // related to the fifo_pretrig parameter, but I am not completely
2817  // sure how. For now, just choose it such that the window is
2818  // centered at bx=7. This may need further tweaking if the value of
2819  // tmb_l1a_window_size changes.
2820  // static int fpga_latency = 3;
2821  // static int early_tbins = fifo_pretrig - fpga_latency;
2822  // static int early_tbins = 4;
2823 
2824  // The number of CLCT bins in the read-out is given by the
2825  // tmb_l1a_window_size parameter, but made even by setting the LSB
2826  // of tmb_l1a_window_size to 0.
2827  //
2828  static int lct_bins =
2830  static int late_tbins = early_tbins + lct_bins;
2831 
2832  static int ifois = 0;
2833  if (ifois == 0) {
2834  if (infoV >= 0 && early_tbins < 0) {
2835  edm::LogWarning("L1CSCTPEmulatorSuspiciousParameters")
2836  << "+++ early_tbins = " << early_tbins
2837  << "; in-time CLCTs are not getting read-out!!! +++" << "\n";
2838  }
2839 
2840  if (late_tbins > MAX_CLCT_BINS-1) {
2841  if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorSuspiciousParameters")
2842  << "+++ Allowed range of time bins, [0-" << late_tbins
2843  << "] exceeds max allowed, " << MAX_CLCT_BINS-1 << " +++\n"
2844  << "+++ Set late_tbins to max allowed +++\n";
2845  late_tbins = MAX_CLCT_BINS-1;
2846  }
2847  ifois = 1;
2848  }
2849 
2850  // Start from the vector of all found CLCTs and select those within
2851  // the CLCT*L1A coincidence window.
2852  int bx_readout = -1;
2853  std::vector<CSCCLCTDigi> all_lcts = getCLCTs();
2854  for (std::vector <CSCCLCTDigi>::const_iterator plct = all_lcts.begin();
2855  plct != all_lcts.end(); plct++) {
2856  if (!plct->isValid()) continue;
2857 
2858  int bx = (*plct).getBX();
2859  // Skip CLCTs found too early relative to L1Accept.
2860  if (bx <= early_tbins) {
2861  if (infoV > 1) LogDebug("CSCCathodeLCTProcessor")
2862  << " Do not report CLCT on key halfstrip " << plct->getKeyStrip()
2863  << ": found at bx " << bx << ", whereas the earliest allowed bx is "
2864  << early_tbins+1;
2865  continue;
2866  }
2867 
2868  // Skip CLCTs found too late relative to L1Accept.
2869  if (bx > late_tbins) {
2870  if (infoV > 1) LogDebug("CSCCathodeLCTProcessor")
2871  << " Do not report CLCT on key halfstrip " << plct->getKeyStrip()
2872  << ": found at bx " << bx << ", whereas the latest allowed bx is "
2873  << late_tbins;
2874  continue;
2875  }
2876 
2877  // If (readout_earliest_2) take only CLCTs in the earliest bx in the read-out window:
2878  // in digi->raw step, LCTs have to be packed into the TMB header, and
2879  // currently there is room just for two.
2880  if (readout_earliest_2) {
2881  if (bx_readout == -1 || bx == bx_readout) {
2882  tmpV.push_back(*plct);
2883  if (bx_readout == -1) bx_readout = bx;
2884  }
2885  }
2886  else tmpV.push_back(*plct);
2887  }
2888  return tmpV;
2889 }
#define LogDebug(id)
std::vector< CSCCLCTDigi > getCLCTs()
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 549 of file CSCCathodeLCTProcessor.cc.

References CSCTriggerGeomManager::chamber(), disableME1a, dumpConfigParams(), relativeConstraints::empty, gangedME1a, CSCLayer::geometry(), CSCTriggerGeometry::get(), getCLCTs(), getDigis(), infoV, isME11, isSLHC, isTMB07, CSCChamber::layer(), CSCConstants::MAX_NUM_STRIPS, nplanes_hit_pretrig, CSCConstants::NUM_HALF_STRIPS, CSCConstants::NUM_LAYERS, CSCLayerGeometry::numberOfStrips(), numStrips, readComparatorDigis(), smartME1aME1b, CSCLayerGeometry::stagger(), stagger, theChamber, theEndcap, theRing, theSector, theStation, theSubsector, and theTrigChamber.

Referenced by CSCMotherboardME11::run(), and CSCMotherboard::run().

549  {
550  // This is the version of the run() function that is called when running
551  // over the entire detector. It gets the comparator & timing info from the
552  // comparator digis and then passes them on to another run() function.
553 
554  // clear(); // redundant; called by L1MuCSCMotherboard.
555 
556  static bool config_dumped = false;
557  if ((infoV > 0 || isSLHC) && !config_dumped) {
558  //std::cerr<<"**** CLCT run parameters dump ****"<<std::endl;
560  config_dumped = true;
561  }
562 
563  // Get the number of strips and stagger of layers for the given chamber.
564  // Do it only once per chamber.
565  if (numStrips == 0) {
567  CSCChamber* chamber = theGeom->chamber(theEndcap, theStation, theSector,
569  if (chamber) {
570  numStrips = chamber->layer(1)->geometry()->numberOfStrips();
571  // ME1/a is known to the readout hardware as strips 65-80 of ME1/1.
572  // Still need to decide whether we do any special adjustments to
573  // reconstruct LCTs in this region (3:1 ganged strips); for now, we
574  // simply allow for hits in ME1/a and apply standard reconstruction
575  // to them.
576  // For SLHC ME1/1 is set to have 4 CFEBs in ME1/b and 3 CFEBs in ME1/a
577  if (isME11) {
578  if (!smartME1aME1b && !disableME1a && theRing == 1 ) numStrips = 80;
579  if (!smartME1aME1b && disableME1a && theRing == 1 ) numStrips = 64;
580  if ( smartME1aME1b && !disableME1a && theRing == 1 ) numStrips = 64;
581  if ( smartME1aME1b && !disableME1a && theRing == 4 ) {
582  if (gangedME1a) numStrips = 16;
583  else numStrips = 48;
584  }
585  }
586 
588  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorSetupError")
589  << "+++ Number of strips, " << numStrips
590  << " found in ME" << ((theEndcap == 1) ? "+" : "-")
591  << theStation << "/" << theRing << "/" << theChamber
592  << " (sector " << theSector << " subsector " << theSubsector
593  << " trig id. " << theTrigChamber << ")"
594  << " exceeds max expected, " << CSCConstants::MAX_NUM_STRIPS
595  << " +++\n"
596  << "+++ CSC geometry looks garbled; no emulation possible +++\n";
597  numStrips = -1;
598  }
599  // The strips for a given layer may be offset from the adjacent layers.
600  // This was done in order to improve resolution. We need to find the
601  // 'staggering' for each layer and make necessary conversions in our
602  // arrays. -JM
603  // In the TMB-07 firmware, half-strips in odd layers (layers are
604  // counted as ly0-ly5) are shifted by -1 half-strip, whereas in
605  // the previous firmware versions half-strips in even layers
606  // were shifted by +1 half-strip. This difference is due to a
607  // change from ly3 to ly2 in the choice of the key layer, and
608  // the intention to keep half-strips in the key layer unchanged.
609  // In the emulator, we use the old way for both cases, to avoid
610  // negative half-strip numbers. This will necessitate a
611  // subtraction of 1 half-strip for TMB-07 later on. -SV.
612  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
613  stagger[i_layer] =
614  (chamber->layer(i_layer+1)->geometry()->stagger() + 1) / 2;
615  }
616  }
617  else {
618  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
619  << " ME" << ((theEndcap == 1) ? "+" : "-")
620  << theStation << "/" << theRing << "/" << theChamber
621  << " (sector " << theSector << " subsector " << theSubsector
622  << " trig id. " << theTrigChamber << ")"
623  << " is not defined in current geometry! +++\n"
624  << "+++ CSC geometry looks garbled; no emulation possible +++\n";
625  numStrips = -1;
626  }
627  }
628 
629  if (numStrips < 0) {
630  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
631  << " ME" << ((theEndcap == 1) ? "+" : "-")
632  << theStation << "/" << theRing << "/" << theChamber
633  << " (sector " << theSector << " subsector " << theSubsector
634  << " trig id. " << theTrigChamber << "):"
635  << " numStrips = " << numStrips << "; CLCT emulation skipped! +++";
636  std::vector<CSCCLCTDigi> emptyV;
637  return emptyV;
638  }
639 
640  // Get comparator digis in this chamber.
641  bool noDigis = getDigis(compdc);
642 
643  if (!noDigis) {
644  // Get halfstrip (and possibly distrip) times from comparator digis.
645  std::vector<int>
647  std::vector<int>
649  if (isTMB07) { // TMB07 (latest) version: halfstrips only.
650  readComparatorDigis(halfstrip);
651  }
652  else { // Earlier versions: halfstrips and distrips.
653  readComparatorDigis(halfstrip, distrip);
654  }
655 
656  // Pass arrays of halfstrips and distrips on to another run() doing the
657  // LCT search.
658  // If the number of layers containing digis is smaller than that
659  // required to trigger, quit right away. (If LCT-based digi suppression
660  // is implemented one day, this condition will have to be changed
661  // to the number of planes required to pre-trigger.)
662  unsigned int layersHit = 0;
663  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
664  for (int i_hstrip = 0; i_hstrip < CSCConstants::NUM_HALF_STRIPS;
665  i_hstrip++) {
666  if (!halfstrip[i_layer][i_hstrip].empty()) {layersHit++; break;}
667  }
668  }
669  // Run the algorithm only if the probability for the pre-trigger
670  // to fire is not null. (Pre-trigger decisions are used for the
671  // strip read-out conditions in DigiToRaw.)
672  if (layersHit >= nplanes_hit_pretrig) run(halfstrip, distrip);
673  }
674 
675  // Return vector of CLCTs.
676  std::vector<CSCCLCTDigi> tmpV = getCLCTs();
677  return tmpV;
678 }
CSCChamber * chamber(unsigned endcap, unsigned station, unsigned sector, unsigned subsector, unsigned tcscid) const
Return the CSCChamber for a corresponding endcap/station/sector/subsector/trigger cscid...
void readComparatorDigis(std::vector< int >halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], std::vector< int > distrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
int numberOfStrips() const
static CSCTriggerGeomManager * get()
bool getDigis(const CSCComparatorDigiCollection *compdc)
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
Definition: CSCChamber.cc:41
int stagger() const
int stagger[CSCConstants::NUM_LAYERS]
std::vector< CSCCLCTDigi > run(const CSCComparatorDigiCollection *compdc)
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:47
std::vector< CSCCLCTDigi > getCLCTs()
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 680 of file CSCCathodeLCTProcessor.cc.

References bestCLCT, findLCTs(), findLCTsSLHC(), i, infoV, isME11, isMTCC, isSLHC, isTMB07, LogDebug, MAX_CLCT_BINS, secondCLCT, CSCCLCTDigi::setTrknmb(), smartME1aME1b, python.multivaluedict::sort(), theChamber, theEndcap, theRing, theSector, theStation, theSubsector, theTrigChamber, and use_dead_time_zoning.

682  {
683  // This version of the run() function can either be called in a standalone
684  // test, being passed the halfstrip and distrip times, or called by the
685  // run() function above. It uses the findLCTs() method to find vectors
686  // of LCT candidates. These candidates are sorted and the best two per bx
687  // are returned.
688  std::vector<CSCCLCTDigi> LCTlist;
689 
690  if (isTMB07) {
691  // Upgrade version for ME11 with better dead-time handling
692  if (isSLHC && smartME1aME1b && isME11 && use_dead_time_zoning) LCTlist = findLCTsSLHC(halfstrip);
693  // TMB07 version of the CLCT algorithm.
694  else LCTlist = findLCTs(halfstrip);
695  }
696  else if (isMTCC) { // MTCC version.
697  LCTlist = findLCTs(halfstrip, distrip);
698  }
699  else { // Idealized algorithm of many years ago.
700  std::vector<CSCCLCTDigi> halfStripLCTs = findLCTs(halfstrip, 1);
701  std::vector<CSCCLCTDigi> diStripLCTs = findLCTs(distrip, 0);
702  // Put all the candidates into a single vector and sort them.
703  for (unsigned int i = 0; i < halfStripLCTs.size(); i++)
704  LCTlist.push_back(halfStripLCTs[i]);
705  for (unsigned int i = 0; i < diStripLCTs.size(); i++)
706  LCTlist.push_back(diStripLCTs[i]);
707  }
708 
709  // LCT sorting.
710  if (LCTlist.size() > 1)
711  sort(LCTlist.begin(), LCTlist.end(), std::greater<CSCCLCTDigi>());
712 
713  // Take the best two candidates per bx.
714  for (std::vector<CSCCLCTDigi>::const_iterator plct = LCTlist.begin();
715  plct != LCTlist.end(); plct++) {
716  int bx = plct->getBX();
717  if (bx >= MAX_CLCT_BINS) {
718  if (infoV > 0) edm::LogWarning("L1CSCTPEmulatorOutOfTimeCLCT")
719  << "+++ Bx of CLCT candidate, " << bx << ", exceeds max allowed, "
720  << MAX_CLCT_BINS-1 << "; skipping it... +++\n";
721  continue;
722  }
723 
724  if (!bestCLCT[bx].isValid()) bestCLCT[bx] = *plct;
725  else if (!secondCLCT[bx].isValid()) {
726  // Ignore CLCT if it is the same as the best (i.e. if the same
727  // CLCT was found in both half- and di-strip pattern search).
728  // This can never happen in the test beam and MTCC
729  // implementations.
730  if (!isMTCC && !isTMB07 && *plct == bestCLCT[bx]) continue;
731  secondCLCT[bx] = *plct;
732  }
733  }
734 
735  for (int bx = 0; bx < MAX_CLCT_BINS; bx++) {
736  if (bestCLCT[bx].isValid()) {
737  bestCLCT[bx].setTrknmb(1);
738  if (infoV > 0) LogDebug("CSCCathodeLCTProcessor")
739  << bestCLCT[bx] << " found in ME" << ((theEndcap == 1) ? "+" : "-")
740  << theStation << "/" << theRing << "/" << theChamber
741  << " (sector " << theSector << " subsector " << theSubsector
742  << " trig id. " << theTrigChamber << ")" << "\n";
743  }
744  if (secondCLCT[bx].isValid()) {
745  secondCLCT[bx].setTrknmb(2);
746  if (infoV > 0) LogDebug("CSCCathodeLCTProcessor")
747  << secondCLCT[bx] << " found in ME" << ((theEndcap == 1) ? "+" : "-")
748  << theStation << "/" << theRing << "/" << theChamber
749  << " (sector " << theSector << " subsector " << theSubsector
750  << " trig id. " << theTrigChamber << ")" << "\n";
751  }
752  }
753  // Now that we have our best CLCTs, they get correlated with the best
754  // ALCTs and then get sent to the MotherBoard. -JM
755 }
#define LogDebug(id)
CSCCLCTDigi secondCLCT[MAX_CLCT_BINS]
int i
Definition: DBlmapReader.cc:9
std::vector< CSCCLCTDigi > findLCTs(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], int stripType)
std::vector< CSCCLCTDigi > findLCTsSLHC(const std::vector< int > halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
CSCCLCTDigi bestCLCT[MAX_CLCT_BINS]
void setTrknmb(const uint16_t number)
Set track number (1,2) after sorting CLCTs.
Definition: CSCCLCTDigi.h:73
void CSCCathodeLCTProcessor::setConfigParameters ( const CSCDBL1TPParameters conf)

Sets configuration parameters obtained via EventSetup mechanism.

Definition at line 422 of file CSCCathodeLCTProcessor.cc.

References checkConfigParameters(), CSCDBL1TPParameters::clctDriftDelay(), CSCDBL1TPParameters::clctFifoPretrig(), CSCDBL1TPParameters::clctFifoTbins(), CSCDBL1TPParameters::clctHitPersist(), CSCDBL1TPParameters::clctMinSeparation(), CSCDBL1TPParameters::clctNplanesHitPattern(), CSCDBL1TPParameters::clctNplanesHitPretrig(), CSCDBL1TPParameters::clctPidThreshPretrig(), drift_delay, dumpConfigParams(), fifo_pretrig, fifo_tbins, hit_persist, isTMB07, min_separation, nplanes_hit_pattern, nplanes_hit_pretrig, and pid_thresh_pretrig.

Referenced by CSCMotherboardME11::setConfigParameters(), and CSCMotherboard::setConfigParameters().

422  {
423  static bool config_dumped = false;
424 
425  fifo_tbins = conf->clctFifoTbins();
426  fifo_pretrig = conf->clctFifoPretrig();
427  hit_persist = conf->clctHitPersist();
428  drift_delay = conf->clctDriftDelay();
431 
432  // TMB07 parameters.
433  if (isTMB07) {
436  }
437 
438  // Check and print configuration parameters.
440  if (!config_dumped) {
441  //std::cerr<<"**** CLCT setConfigParams parameters dump ****"<<std::endl;
443  config_dumped = true;
444  }
445 }
unsigned int clctHitPersist() const
unsigned int clctNplanesHitPattern() const
unsigned int clctMinSeparation() const
unsigned int clctNplanesHitPretrig() const
unsigned int clctDriftDelay() const
unsigned int clctPidThreshPretrig() const
unsigned int clctFifoPretrig() const
unsigned int clctFifoTbins() const
void CSCCathodeLCTProcessor::setDefaultConfigParameters ( )
private

Set default values for configuration parameters.

Definition at line 400 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, def_tmb_l1a_window_size, drift_delay, fifo_pretrig, fifo_tbins, hit_persist, isMTCC, isTMB07, min_separation, nplanes_hit_pattern, nplanes_hit_pretrig, pid_thresh_pretrig, and tmb_l1a_window_size.

Referenced by CSCCathodeLCTProcessor().

400  {
401  // Set default values for configuration parameters.
408 
409  isMTCC = false;
410 
411  // New TMB07 parameters.
412  isTMB07 = true;
413  if (isTMB07) {
416  }
417 
419 }
static const unsigned int def_drift_delay
static const unsigned int def_fifo_tbins
static const unsigned int def_min_separation
static const unsigned int def_nplanes_hit_pretrig
static const unsigned int def_pid_thresh_pretrig
static const unsigned int def_tmb_l1a_window_size
static const unsigned int def_nplanes_hit_pattern
static const unsigned int def_fifo_pretrig
static const unsigned int def_hit_persist
void CSCCathodeLCTProcessor::setRing ( unsigned  r)
inline

Set ring number Has to be done for upgrade ME1a!

Definition at line 94 of file CSCCathodeLCTProcessor.h.

References alignCSCRings::r, and theRing.

Referenced by CSCMotherboardME11::CSCMotherboardME11().

void CSCCathodeLCTProcessor::testDistripStagger ( )
private

Definition at line 2905 of file CSCCathodeLCTProcessor.cc.

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

Referenced by readComparatorDigis().

2905  {
2906  // Author: Jason Mumford (mumford@physics.ucla.edu)
2907  // This routine tests the distripStagger routine.
2908  // @@
2909  bool debug = true;
2910  int test_triad[CSCConstants::NUM_DI_STRIPS], test_time[CSCConstants::NUM_DI_STRIPS];
2911  int test_digi[CSCConstants::NUM_DI_STRIPS];
2912  int distrip = 0;
2913  test_triad[distrip] = 3; //After routine, I expect 4
2914  test_triad[distrip+1] = 3; // 4
2915  test_triad[distrip+2] = 3; // 4
2916  test_triad[distrip+3] = 3; // 4
2917  test_triad[distrip+4] = 3; // 4
2918  test_triad[distrip+5] = 3; // 4
2919  test_triad[distrip+6] = 3; // 4
2920  test_triad[distrip+7] = 3; // 4
2921  test_triad[distrip+8] = 3; // 4
2922  test_triad[distrip+9] = 3; // 4
2923  test_triad[distrip+10] = 2; // 2
2924 
2925  test_time[distrip] = 4; // "" "" 0
2926  test_time[distrip+1] = 10; // 4
2927  test_time[distrip+2] = 2; // 10
2928  test_time[distrip+3] = 0; // 2
2929  test_time[distrip+4] = 6; // 2
2930  test_time[distrip+5] = 8; // 2
2931  test_time[distrip+6] = 10; // 2
2932  test_time[distrip+7] = 1; // 2
2933  test_time[distrip+8] = 8; // 2
2934  test_time[distrip+9] = 5; // 2
2935  test_time[distrip+10] = 6; // 2
2936 
2937  std::cout << "\n ------------------------------------------------- \n";
2938  std::cout << "!!!!!!Testing distripStagger routine!!!!!!" << std::endl;
2939  std::cout << "Values before distripStagger routine:" << std::endl;
2940  for (int i=distrip; i<distrip+11; i++){
2941  test_digi[i] = 999;
2942  std::cout << "test_triad[" << i << "] = " << test_triad[i];
2943  std::cout << " test_time[" << i << "] = " << test_time[i] << std::endl;
2944  }
2945  distripStagger(test_triad, test_time, test_digi, distrip, debug);
2946  std::cout << "Values after distripStagger routine:" << std::endl;
2947  for (int i=distrip; i<distrip+11; i++){
2948  std::cout << "test_triad[" << i << "] = " << test_triad[i];
2949  std::cout << " test_time[" << i << "] = " << test_time[i] << std::endl;
2950  }
2951  std::cout << "\n ------------------------------------------------- \n \n";
2952 }
int i
Definition: DBlmapReader.cc:9
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)
tuple cout
Definition: gather_cfg.py:121
#define debug
Definition: MEtoEDMFormat.h:34
void CSCCathodeLCTProcessor::testLCTs ( )
private

Definition at line 2954 of file CSCCathodeLCTProcessor.cc.

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

2954  {
2955  // test to make sure what goes into an LCT is what comes out.
2956  for (int ptn = 0; ptn < 8; ptn++) {
2957  for (int bend = 0; bend < 2; bend++) {
2958  for (int cfeb = 0; cfeb < MAX_CFEBS; cfeb++) {
2959  for (int key_strip = 0; key_strip < 32; key_strip++) {
2960  for (int bx = 0; bx < 7; bx++) {
2961  for (int stripType = 0; stripType < 2; stripType++) {
2962  for (int quality = 3; quality < 6; quality++) {
2963  CSCCLCTDigi thisLCT(1, quality, ptn, stripType, bend,
2964  key_strip, cfeb, bx);
2965  if (ptn != thisLCT.getPattern())
2966  LogTrace("CSCCathodeLCTProcessor")
2967  << "pattern mismatch: " << ptn << " "
2968  << thisLCT.getPattern();
2969  if (bend != thisLCT.getBend())
2970  LogTrace("CSCCathodeLCTProcessor")
2971  << "bend mismatch: " << bend << " " << thisLCT.getBend();
2972  if (cfeb != thisLCT.getCFEB())
2973  LogTrace("CSCCathodeLCTProcessor")
2974  << "cfeb mismatch: " << cfeb << " " << thisLCT.getCFEB();
2975  if (key_strip != thisLCT.getKeyStrip())
2976  LogTrace("CSCCathodeLCTProcessor")
2977  << "strip mismatch: " << key_strip << " "
2978  << thisLCT.getKeyStrip();
2979  if (bx != thisLCT.getBX())
2980  LogTrace("CSCCathodeLCTProcessor")
2981  << "bx mismatch: " << bx << " " << thisLCT.getBX();
2982  if (stripType != thisLCT.getStripType())
2983  LogTrace("CSCCathodeLCTProcessor")
2984  << "Strip Type mismatch: " << stripType << " "
2985  << thisLCT.getStripType();
2986  if (quality != thisLCT.getQuality())
2987  LogTrace("CSCCathodeLCTProcessor")
2988  << "quality mismatch: " << quality << " "
2989  << thisLCT.getQuality();
2990  }
2991  }
2992  }
2993  }
2994  }
2995  }
2996  }
2997 }
#define LogTrace(id)
void CSCCathodeLCTProcessor::testPatterns ( )
private

Definition at line 3040 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, and python.entryComment::results.

3040  {
3041 //generate all possible combinations of hits in a given area and see what we find.
3042 // Benn Tannenbaum 21 June 2001
3043 
3044  //there are 16 strips in our uber-pattern, each of which can be on or off.
3045  // 2^16 = 65536
3046  for (int possibleHits = 0; possibleHits < 65536; possibleHits++) {
3047  std::vector<int> stripsHit[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS];
3048  //assign one bit to each strip in an array. I'll start centered around strip 10.
3049  stripsHit[0][ 9].push_back(( possibleHits & 1 ) != 0); // 2^0
3050  stripsHit[0][10].push_back(( possibleHits & 2 ) != 0); // 2^1
3051  stripsHit[0][11].push_back(( possibleHits & 4 ) != 0); // 2^2
3052  stripsHit[1][ 9].push_back(( possibleHits & 8 ) != 0); // 2^3
3053  stripsHit[1][10].push_back(( possibleHits & 16 ) != 0); // 2^4
3054  stripsHit[1][11].push_back(( possibleHits & 32 ) != 0); // 2^5
3055  stripsHit[2][ 9].push_back(( possibleHits & 64 ) != 0); // 2^6
3056  stripsHit[2][10].push_back(( possibleHits & 128 ) != 0); // 2^7
3057  stripsHit[2][11].push_back(( possibleHits & 256 ) != 0); // 2^8
3058  stripsHit[3][10].push_back(( possibleHits & 512 ) != 0); // 2^9
3059  stripsHit[4][ 9].push_back(( possibleHits & 1024 ) != 0); // 2^10
3060  stripsHit[4][10].push_back(( possibleHits & 2048 ) != 0); // 2^11
3061  stripsHit[4][11].push_back(( possibleHits & 4096 ) != 0); // 2^12
3062  stripsHit[5][ 9].push_back(( possibleHits & 8192 ) != 0); // 2^13
3063  stripsHit[5][10].push_back(( possibleHits & 16384 ) != 0); // 2^14
3064  stripsHit[5][11].push_back(( possibleHits & 32768 ) != 0); // 2^15
3065  int numLayersHit = findNumLayersHit(stripsHit);
3066  std::vector <CSCCLCTDigi> results = findLCTs(stripsHit, 1);
3067 // print out whatever we find-- but only ones where 4 or more layers are hit
3068 // OR ones where we find something
3069 // key: X a hit there and was used to find pattern
3070 // x a hit not involved in pattern
3071 // _ empty strip
3072 // o a hit was there, but no pattern was found
3073  if (numLayersHit > 3 || results.size() > 0) {
3074  std::cout<<"Input "<<possibleHits<<"/"<< 65536 <<" # Found Patterns "<<results.size()<<std::endl<<" ";
3075  for (int layer = 0; layer < CSCConstants::NUM_LAYERS; layer++) {
3076  if ((isTMB07 && layer != CSCConstants::KEY_CLCT_LAYER - 1) ||
3077  (!isTMB07 && layer != CSCConstants::KEY_CLCT_LAYER_PRE_TMB07 - 1)) {
3078  for (int strip = 9; strip < 12; strip++) {
3079  if (!stripsHit[layer][strip].empty()) {
3080  if (results.size() > 0) {
3081  int thePatternStrip = strip - (results[0].getKeyStrip() - 2) + 3*layer;
3082  if ((isTMB07 && layer>=CSCConstants::KEY_CLCT_LAYER) ||
3084  thePatternStrip -= 2;
3085 
3086  if (pattern[results[0].getPattern()][thePatternStrip] == layer)
3087  {
3088  std::cout<<"X";
3089  } else {
3090  std::cout<<"x";
3091  }
3092  } else {
3093  std::cout<<"o";
3094  }
3095  } else {
3096  std::cout<<"_";
3097  }
3098  }
3099  std::cout<<" ";
3100  for (unsigned int output = 0; output < results.size(); output++) {
3101  int minStrip;
3102  if ((isTMB07 && layer < CSCConstants::KEY_CLCT_LAYER-1) ||
3104  minStrip = 3*layer;
3105  } else {
3106  minStrip = 3*layer - 2;// since on the key layer we only have 1 strip
3107  }
3108  for (int strip = minStrip; strip < minStrip + 3; strip++) {
3109  if (layer == pattern[results[output].getPattern()][strip]) {
3110  std::cout<<"X";
3111  } else {
3112  std::cout<<"_";
3113  }
3114  }
3115  std::cout<<" ";
3116  }
3117  } else {
3118  if (!stripsHit[layer][10].empty()) {
3119  std::cout<<" X ";
3120  } else {
3121  std::cout<<" _ ";
3122  }
3123  for (unsigned int output = 0; output < results.size(); output++)
3124  std::cout<<" X ";
3125  }
3126  if (layer < static_cast<int>(results.size()) ) {
3127  std::cout<<results[layer];
3128  std::cout<<" ";
3129  } else {
3130  std::cout<<" "<<std::endl<<" ";
3131  }
3132  }
3133  }
3134  }
3135 }
void getPattern(int pattern_num, int strip_value[NUM_PATTERN_STRIPS], int bx_time, int &quality, int &bend)
std::vector< CSCCLCTDigi > findLCTs(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])
static const int pattern[CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07][NUM_PATTERN_STRIPS+1]
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

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

Definition at line 257 of file CSCCathodeLCTProcessor.h.

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

CSCCLCTDigi CSCCathodeLCTProcessor::bestCLCT[MAX_CLCT_BINS]

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

Definition at line 73 of file CSCCathodeLCTProcessor.h.

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

const int CSCCathodeLCTProcessor::cfeb_strips = { 8, 32}
staticprivate

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

Definition at line 192 of file CSCCathodeLCTProcessor.h.

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

unsigned int CSCCathodeLCTProcessor::clct_state_machine_zone
private

Definition at line 165 of file CSCCathodeLCTProcessor.h.

Referenced by CSCCathodeLCTProcessor(), and findLCTsSLHC().

const unsigned int CSCCathodeLCTProcessor::def_drift_delay = 2
staticprivate

Definition at line 179 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_fifo_pretrig = 7
staticprivate

Definition at line 178 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_fifo_tbins = 12
staticprivate

Default values of configuration parameters.

Definition at line 178 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_hit_persist = 6
staticprivate

Definition at line 179 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_min_separation = 10
staticprivate

Definition at line 182 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_nplanes_hit_pattern = 4
staticprivate

Definition at line 181 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_nplanes_hit_pretrig = 2
staticprivate

Definition at line 180 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_pid_thresh_pretrig = 2
staticprivate

Definition at line 182 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_tmb_l1a_window_size = 7
staticprivate

Definition at line 183 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

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

Definition at line 135 of file CSCCathodeLCTProcessor.h.

Referenced by getDigis(), and readComparatorDigis().

bool CSCCathodeLCTProcessor::disableME1a
private

Definition at line 158 of file CSCCathodeLCTProcessor.h.

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

unsigned int CSCCathodeLCTProcessor::drift_delay
private
bool CSCCathodeLCTProcessor::dynamic_state_machine_zone
private

Definition at line 166 of file CSCCathodeLCTProcessor.h.

Referenced by CSCCathodeLCTProcessor(), and findLCTsSLHC().

int CSCCathodeLCTProcessor::early_tbins
private

VK: separate handle for early time bins

Definition at line 161 of file CSCCathodeLCTProcessor.h.

Referenced by CSCCathodeLCTProcessor(), and readoutCLCTs().

unsigned int CSCCathodeLCTProcessor::fifo_pretrig
private
unsigned int CSCCathodeLCTProcessor::fifo_tbins
private
int CSCCathodeLCTProcessor::first_bx_corrected[CSCConstants::NUM_HALF_STRIPS]
private

Definition at line 259 of file CSCCathodeLCTProcessor.h.

Referenced by findLCTsSLHC(), and ptnFinding().

bool CSCCathodeLCTProcessor::gangedME1a
private

Definition at line 158 of file CSCCathodeLCTProcessor.h.

Referenced by CSCCathodeLCTProcessor(), and run().

unsigned int CSCCathodeLCTProcessor::hit_persist
private
int CSCCathodeLCTProcessor::infoV
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 118 of file CSCCathodeLCTProcessor.h.

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

bool CSCCathodeLCTProcessor::isME11
private

Definition at line 130 of file CSCCathodeLCTProcessor.h.

Referenced by CSCCathodeLCTProcessor(), and run().

bool CSCCathodeLCTProcessor::isMTCC
private

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

Definition at line 139 of file CSCCathodeLCTProcessor.h.

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

bool CSCCathodeLCTProcessor::ispretrig[CSCConstants::NUM_HALF_STRIPS]
private

Definition at line 266 of file CSCCathodeLCTProcessor.h.

Referenced by findLCTsSLHC(), and preTrigger().

bool CSCCathodeLCTProcessor::isSLHC
private

Flag for SLHC studies.

Definition at line 145 of file CSCCathodeLCTProcessor.h.

Referenced by CSCCathodeLCTProcessor(), and run().

bool CSCCathodeLCTProcessor::isTMB07
private
unsigned int CSCCathodeLCTProcessor::min_separation
private
unsigned int CSCCathodeLCTProcessor::nhits[CSCConstants::NUM_HALF_STRIPS]
private

Definition at line 258 of file CSCCathodeLCTProcessor.h.

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

unsigned int CSCCathodeLCTProcessor::nplanes_hit_pattern
private
unsigned int CSCCathodeLCTProcessor::nplanes_hit_pretrig
private
int CSCCathodeLCTProcessor::numStrips
private
const int CSCCathodeLCTProcessor::pattern
static

Definition at line 99 of file CSCCathodeLCTProcessor.h.

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

const int CSCCathodeLCTProcessor::pattern2007
static

Definition at line 103 of file CSCCathodeLCTProcessor.h.

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

const int CSCCathodeLCTProcessor::pattern2007_offset
static
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 102 of file CSCCathodeLCTProcessor.h.

Referenced by ptnFinding().

unsigned int CSCCathodeLCTProcessor::pid_thresh_pretrig
private
const int CSCCathodeLCTProcessor::pre_hit_pattern
static
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 98 of file CSCCathodeLCTProcessor.h.

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

unsigned int CSCCathodeLCTProcessor::pretrig_trig_zone
private

VK: allow triggers only in +-pretrig_trig_zone around pretriggers

Definition at line 169 of file CSCCathodeLCTProcessor.h.

Referenced by CSCCathodeLCTProcessor(), and findLCTsSLHC().

bool CSCCathodeLCTProcessor::readout_earliest_2
private

VK: whether to readout only the earliest two LCTs in readout window

Definition at line 175 of file CSCCathodeLCTProcessor.h.

Referenced by CSCCathodeLCTProcessor(), and readoutCLCTs().

CSCCLCTDigi CSCCathodeLCTProcessor::secondCLCT[MAX_CLCT_BINS]

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

Definition at line 76 of file CSCCathodeLCTProcessor.h.

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

bool CSCCathodeLCTProcessor::smartME1aME1b
private

VK: special configuration parameters for ME1a treatment

Definition at line 158 of file CSCCathodeLCTProcessor.h.

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

int CSCCathodeLCTProcessor::stagger[CSCConstants::NUM_LAYERS]
private
int CSCCathodeLCTProcessor::start_bx_shift
private

VK: some quick and dirty fix to reduce CLCT deadtime

Definition at line 155 of file CSCCathodeLCTProcessor.h.

Referenced by CSCCathodeLCTProcessor(), findLCTs(), findLCTsSLHC(), and pulseExtension().

unsigned int CSCCathodeLCTProcessor::theChamber
private

Definition at line 129 of file CSCCathodeLCTProcessor.h.

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

const unsigned CSCCathodeLCTProcessor::theEndcap
private

Chamber id (trigger-type labels).

Definition at line 121 of file CSCCathodeLCTProcessor.h.

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

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

Definition at line 136 of file CSCCathodeLCTProcessor.h.

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

unsigned int CSCCathodeLCTProcessor::theRing
private

Definition at line 128 of file CSCCathodeLCTProcessor.h.

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

const unsigned CSCCathodeLCTProcessor::theSector
private

Definition at line 123 of file CSCCathodeLCTProcessor.h.

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

const unsigned CSCCathodeLCTProcessor::theStation
private

Definition at line 122 of file CSCCathodeLCTProcessor.h.

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

const unsigned CSCCathodeLCTProcessor::theSubsector
private

Definition at line 124 of file CSCCathodeLCTProcessor.h.

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

const unsigned CSCCathodeLCTProcessor::theTrigChamber
private

Definition at line 125 of file CSCCathodeLCTProcessor.h.

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

unsigned int CSCCathodeLCTProcessor::tmb_l1a_window_size
private
bool CSCCathodeLCTProcessor::use_corrected_bx
private

VK: whether to use corrected_bx instead of pretrigger BX

Definition at line 172 of file CSCCathodeLCTProcessor.h.

Referenced by CSCCathodeLCTProcessor(), and findLCTsSLHC().

bool CSCCathodeLCTProcessor::use_dead_time_zoning
private

VK: use of localized dead-time zones

Definition at line 164 of file CSCCathodeLCTProcessor.h.

Referenced by CSCCathodeLCTProcessor(), and run().