CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes
CSCCathodeLCTProcessor Class Reference

#include <CSCCathodeLCTProcessor.h>

Inheritance diagram for CSCCathodeLCTProcessor:
CSCBaseboard CSCUpgradeCathodeLCTProcessor

Public Member Functions

void clear ()
 
 CSCCathodeLCTProcessor (unsigned endcap, unsigned station, unsigned sector, unsigned subsector, unsigned chamber, const edm::ParameterSet &conf)
 
 CSCCathodeLCTProcessor ()
 
std::vector< CSCCLCTDigigetCLCTs () const
 
std::vector< int > preTriggerBXs () const
 
std::vector< CSCCLCTPreTriggerDigipreTriggerDigis () const
 
std::vector< CSCCLCTPreTriggerDigipreTriggerDigisME1a () const
 
std::vector< CSCCLCTPreTriggerDigipreTriggerDigisME1b () const
 
std::vector< CSCCLCTDigireadoutCLCTs () const
 
std::vector< CSCCLCTDigireadoutCLCTsME1a () const
 
std::vector< CSCCLCTDigireadoutCLCTsME1b () const
 
std::vector< CSCCLCTDigirun (const CSCComparatorDigiCollection *compdc)
 
void run (const std::vector< int > halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
 
void setConfigParameters (const CSCDBL1TPParameters *conf)
 
- Public Member Functions inherited from CSCBaseboard
 CSCBaseboard (unsigned endcap, unsigned station, unsigned sector, unsigned subsector, unsigned chamber, const edm::ParameterSet &conf)
 
 CSCBaseboard ()
 
std::string getCSCName () const
 
void setCSCGeometry (const CSCGeometry *g)
 
virtual ~CSCBaseboard ()=default
 

Public Attributes

CSCCLCTDigi bestCLCT [CSCConstants::MAX_CLCT_TBINS]
 
CSCCLCTDigi secondCLCT [CSCConstants::MAX_CLCT_TBINS]
 

Static Public Attributes

static const int pattern2007 [CSCConstants::NUM_CLCT_PATTERNS][CSCConstants::MAX_HALFSTRIPS_IN_PATTERN+2]
 
static const int pattern2007_offset [CSCConstants::MAX_HALFSTRIPS_IN_PATTERN]
 

Protected Types

enum  CLCT_INDICES {
  CLCT_PATTERN, CLCT_BEND, CLCT_STRIP, CLCT_BX,
  CLCT_STRIP_TYPE, CLCT_QUALITY, CLCT_CFEB, CLCT_NUM_QUANTITIES = 7
}
 

Protected Member Functions

void checkConfigParameters ()
 
void dumpConfigParams () const
 
void dumpDigis (const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int nStrips) const
 
virtual std::vector< CSCCLCTDigifindLCTs (const std::vector< int > halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
 
bool getDigis (const CSCComparatorDigiCollection *compdc)
 
void getDigis (const CSCComparatorDigiCollection *compdc, const CSCDetId &id)
 
void markBusyKeys (const int best_hstrip, const int best_patid, int quality[CSCConstants::NUM_HALF_STRIPS_7CFEBS])
 
bool patternFinding (const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int nStrips, const unsigned int bx_time)
 
virtual bool preTrigger (const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int start_bx, int &first_bx)
 
void pulseExtension (const std::vector< int > time[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int nStrips, unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
 
void readComparatorDigis (std::vector< int > halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
 
void setDefaultConfigParameters ()
 

Protected Attributes

unsigned int best_pid [CSCConstants::NUM_HALF_STRIPS_7CFEBS]
 
std::vector< CSCComparatorDigidigiV [CSCConstants::NUM_LAYERS]
 
unsigned int drift_delay
 
int early_tbins
 
unsigned int fifo_pretrig
 
unsigned int fifo_tbins
 
int first_bx_corrected [CSCConstants::NUM_HALF_STRIPS_7CFEBS]
 
unsigned int hit_persist
 
bool ispretrig [CSCConstants::NUM_HALF_STRIPS_7CFEBS]
 
unsigned int min_separation
 
unsigned int nhits [CSCConstants::NUM_HALF_STRIPS_7CFEBS]
 
unsigned int nplanes_hit_pattern
 
unsigned int nplanes_hit_pretrig
 
int numStrips
 
unsigned int pid_thresh_pretrig
 
bool readout_earliest_2
 
int stagger [CSCConstants::NUM_LAYERS]
 
int start_bx_shift
 
std::vector< int > thePreTriggerBXs
 
std::vector< CSCCLCTPreTriggerDigithePreTriggerDigis
 
unsigned int tmb_l1a_window_size
 
- Protected Attributes inherited from CSCBaseboard
unsigned int alctClctOffset_
 
edm::ParameterSet alctParams_
 
edm::ParameterSet clctParams_
 
edm::ParameterSet commonParams_
 
const CSCChambercscChamber_
 
const CSCGeometrycscGeometry_
 
CSCDetId cscId_
 
bool disableME1a_
 
bool enableAlctSLHC_
 
bool gangedME1a_
 
int infoV
 
bool isME11_
 
bool isSLHC_
 
bool runME11ILT_
 
bool runME11Up_
 
bool runME21ILT_
 
bool runME21Up_
 
bool runME31Up_
 
bool runME41Up_
 
unsigned theChamber
 
std::string theCSCName_
 
const unsigned theEndcap
 
unsigned theRegion
 
unsigned theRing
 
const unsigned theSector
 
const unsigned theStation
 
const unsigned theSubsector
 
const unsigned theTrigChamber
 
edm::ParameterSet tmbParams_
 

Static Protected Attributes

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 times, or in normal mode where it determines the time and comparator information from the comparator digis.

The CathodeLCTs only come halfstrip flavors

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.

Updates for high pileup running by Vadim Khotilovich (TAMU), December 2012

Updates for integrated local trigger with GEMs by Sven Dildick (TAMU) and Tao Huang (TAMU), April 2015

Removing usage of outdated class CSCTriggerGeometry by Sven Dildick (TAMU)

Definition at line 41 of file CSCCathodeLCTProcessor.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Normal constructor.

Definition at line 113 of file CSCCathodeLCTProcessor.cc.

References checkConfigParameters(), CSCConstants::CLCT_EMUL_TIME_OFFSET, CSCBaseboard::clctParams_, drift_delay, dumpConfigParams(), early_tbins, fifo_pretrig, fifo_tbins, edm::ParameterSet::getParameter(), hit_persist, CSCBaseboard::infoV, min_separation, nplanes_hit_pattern, nplanes_hit_pretrig, CSCConstants::NUM_LAYERS, numStrips, pid_thresh_pretrig, readout_earliest_2, stagger, start_bx_shift, thePreTriggerDigis, tmb_l1a_window_size, and CSCBaseboard::tmbParams_.

118  :
119  CSCBaseboard(endcap, station, sector, subsector, chamber, conf)
120 {
121  static std::atomic<bool> config_dumped{false};
122 
123  // CLCT configuration parameters.
124  fifo_tbins = clctParams_.getParameter<unsigned int>("clctFifoTbins");
125  hit_persist = clctParams_.getParameter<unsigned int>("clctHitPersist");
126  drift_delay = clctParams_.getParameter<unsigned int>("clctDriftDelay");
128  clctParams_.getParameter<unsigned int>("clctNplanesHitPretrig");
130  clctParams_.getParameter<unsigned int>("clctNplanesHitPattern");
131 
132  // Not used yet.
133  fifo_pretrig = clctParams_.getParameter<unsigned int>("clctFifoPretrig");
134 
136  clctParams_.getParameter<unsigned int>("clctPidThreshPretrig");
138  clctParams_.getParameter<unsigned int>("clctMinSeparation");
139 
140  start_bx_shift = clctParams_.getParameter<int>("clctStartBxShift");
141 
142  // Motherboard parameters: common for all configurations.
143  tmb_l1a_window_size = // Common to CLCT and TMB
144  tmbParams_.getParameter<unsigned int>("tmbL1aWindowSize");
145 
146  // separate handle for early time bins
147  early_tbins = tmbParams_.getParameter<int>("tmbEarlyTbins");
148  if (early_tbins<0) early_tbins = fifo_pretrig - CSCConstants::CLCT_EMUL_TIME_OFFSET;
149 
150  // wether to readout only the earliest two LCTs in readout window
151  readout_earliest_2 = tmbParams_.getParameter<bool>("tmbReadoutEarliest2");
152 
153  // Verbosity level, set to 0 (no print) by default.
154  infoV = clctParams_.getParameter<int>("verbosity");
155 
156  // Check and print configuration parameters.
158  if ((infoV > 0) && !config_dumped) {
160  config_dumped = true;
161  }
162 
163  numStrips = 0; // Will be set later.
164  // Provisional, but should be OK for all stations except ME1.
165  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
166  if ((i_layer+1)%2 == 0) stagger[i_layer] = 0;
167  else stagger[i_layer] = 1;
168  }
169 
170 
171  thePreTriggerDigis.clear();
172 }
T getParameter(std::string const &) const
edm::ParameterSet clctParams_
Definition: CSCBaseboard.h:67
std::vector< CSCCLCTPreTriggerDigi > thePreTriggerDigis
edm::ParameterSet tmbParams_
Definition: CSCBaseboard.h:61
int stagger[CSCConstants::NUM_LAYERS]
CSCCathodeLCTProcessor::CSCCathodeLCTProcessor ( )

Default constructor. Used for testing.

Definition at line 174 of file CSCCathodeLCTProcessor.cc.

References checkConfigParameters(), dumpConfigParams(), early_tbins, CSCBaseboard::infoV, CSCConstants::MAX_NUM_STRIPS, CSCConstants::NUM_LAYERS, numStrips, setDefaultConfigParameters(), stagger, start_bx_shift, and thePreTriggerDigis.

174  :
175  CSCBaseboard()
176 {
177  // constructor for debugging.
178  static std::atomic<bool> config_dumped{false};
179 
180  // CLCT configuration parameters.
182  infoV = 2;
183 
184  early_tbins = 4;
185 
186  start_bx_shift = 0;
187 
188  // Check and print configuration parameters.
190  if (!config_dumped) {
192  config_dumped = true;
193  }
194 
196  // Should be OK for all stations except ME1.
197  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
198  if ((i_layer+1)%2 == 0) stagger[i_layer] = 0;
199  else stagger[i_layer] = 1;
200  }
201 
202  thePreTriggerDigis.clear();
203 }
std::vector< CSCCLCTPreTriggerDigi > thePreTriggerDigis
int stagger[CSCConstants::NUM_LAYERS]

Member Function Documentation

void CSCCathodeLCTProcessor::checkConfigParameters ( )
protected

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

Definition at line 241 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, CSCBaseboard::infoV, min_separation, nplanes_hit_pattern, nplanes_hit_pretrig, CSCConstants::NUM_HALF_STRIPS_7CFEBS, pid_thresh_pretrig, and tmb_l1a_window_size.

Referenced by CSCCathodeLCTProcessor(), and setConfigParameters().

241  {
242  // Make sure that the parameter values are within the allowed range.
243 
244  // Max expected values.
245  static const unsigned int max_fifo_tbins = 1 << 5;
246  static const unsigned int max_fifo_pretrig = 1 << 5;
247  static const unsigned int max_hit_persist = 1 << 4;
248  static const unsigned int max_drift_delay = 1 << 2;
249  static const unsigned int max_nplanes_hit_pretrig = 1 << 3;
250  static const unsigned int max_nplanes_hit_pattern = 1 << 3;
251  static const unsigned int max_pid_thresh_pretrig = 1 << 4;
252  static const unsigned int max_min_separation = CSCConstants::NUM_HALF_STRIPS_7CFEBS;
253  static const unsigned int max_tmb_l1a_window_size = 1 << 4;
254 
255  // Checks.
256  if (fifo_tbins >= max_fifo_tbins) {
257  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
258  << "+++ Value of fifo_tbins, " << fifo_tbins
259  << ", exceeds max allowed, " << max_fifo_tbins-1 << " +++\n"
260  << "+++ Try to proceed with the default value, fifo_tbins="
261  << def_fifo_tbins << " +++\n";
263  }
264  if (fifo_pretrig >= max_fifo_pretrig) {
265  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
266  << "+++ Value of fifo_pretrig, " << fifo_pretrig
267  << ", exceeds max allowed, " << max_fifo_pretrig-1 << " +++\n"
268  << "+++ Try to proceed with the default value, fifo_pretrig="
269  << def_fifo_pretrig << " +++\n";
271  }
272  if (hit_persist >= max_hit_persist) {
273  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
274  << "+++ Value of hit_persist, " << hit_persist
275  << ", exceeds max allowed, " << max_hit_persist-1 << " +++\n"
276  << "+++ Try to proceed with the default value, hit_persist="
277  << def_hit_persist << " +++\n";
279  }
280  if (drift_delay >= max_drift_delay) {
281  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
282  << "+++ Value of drift_delay, " << drift_delay
283  << ", exceeds max allowed, " << max_drift_delay-1 << " +++\n"
284  << "+++ Try to proceed with the default value, drift_delay="
285  << def_drift_delay << " +++\n";
287  }
288  if (nplanes_hit_pretrig >= max_nplanes_hit_pretrig) {
289  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
290  << "+++ Value of nplanes_hit_pretrig, " << nplanes_hit_pretrig
291  << ", exceeds max allowed, " << max_nplanes_hit_pretrig-1 << " +++\n"
292  << "+++ Try to proceed with the default value, nplanes_hit_pretrig="
293  << def_nplanes_hit_pretrig << " +++\n";
295  }
296  if (nplanes_hit_pattern >= max_nplanes_hit_pattern) {
297  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
298  << "+++ Value of nplanes_hit_pattern, " << nplanes_hit_pattern
299  << ", exceeds max allowed, " << max_nplanes_hit_pattern-1 << " +++\n"
300  << "+++ Try to proceed with the default value, nplanes_hit_pattern="
301  << def_nplanes_hit_pattern << " +++\n";
303  }
304 
305  if (pid_thresh_pretrig >= max_pid_thresh_pretrig) {
306  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
307  << "+++ Value of pid_thresh_pretrig, " << pid_thresh_pretrig
308  << ", exceeds max allowed, " << max_pid_thresh_pretrig-1 << " +++\n"
309  << "+++ Try to proceed with the default value, pid_thresh_pretrig="
310  << def_pid_thresh_pretrig << " +++\n";
312  }
313  if (min_separation >= max_min_separation) {
314  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
315  << "+++ Value of min_separation, " << min_separation
316  << ", exceeds max allowed, " << max_min_separation-1 << " +++\n"
317  << "+++ Try to proceed with the default value, min_separation="
318  << def_min_separation << " +++\n";
320  }
321 
322  if (tmb_l1a_window_size >= max_tmb_l1a_window_size) {
323  if (infoV > 0) edm::LogError("L1CSCTPEmulatorConfigError")
324  << "+++ Value of tmb_l1a_window_size, " << tmb_l1a_window_size
325  << ", exceeds max allowed, " << max_tmb_l1a_window_size-1 << " +++\n"
326  << "+++ Try to proceed with the default value, tmb_l1a_window_size="
327  << def_tmb_l1a_window_size << " +++\n";
329  }
330 }
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 332 of file CSCCathodeLCTProcessor.cc.

References bestCLCT, CSCCLCTDigi::clear(), CSCConstants::MAX_CLCT_TBINS, secondCLCT, thePreTriggerBXs, and thePreTriggerDigis.

332  {
333  thePreTriggerDigis.clear();
334  thePreTriggerBXs.clear();
335  for (int bx = 0; bx < CSCConstants::MAX_CLCT_TBINS; bx++) {
336  bestCLCT[bx].clear();
337  secondCLCT[bx].clear();
338  }
339 }
CSCCLCTDigi bestCLCT[CSCConstants::MAX_CLCT_TBINS]
std::vector< CSCCLCTPreTriggerDigi > thePreTriggerDigis
std::vector< int > thePreTriggerBXs
CSCCLCTDigi secondCLCT[CSCConstants::MAX_CLCT_TBINS]
void clear()
clear this CLCT
Definition: CSCCLCTDigi.cc:58
void CSCCathodeLCTProcessor::dumpConfigParams ( ) const
protected

Dump CLCT configuration parameters.

Definition at line 1140 of file CSCCathodeLCTProcessor.cc.

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

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

1140  {
1141  std::ostringstream strm;
1142  strm << "\n";
1143  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
1144  strm << "+ CLCT configuration parameters: +\n";
1145  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
1146  strm << " fifo_tbins [total number of time bins in DAQ readout] = "
1147  << fifo_tbins << "\n";
1148  strm << " fifo_pretrig [start time of cathode raw hits in DAQ readout] = "
1149  << fifo_pretrig << "\n";
1150  strm << " hit_persist [duration of signal pulse, in 25 ns bins] = "
1151  << hit_persist << "\n";
1152  strm << " drift_delay [time after pre-trigger before TMB latches LCTs] = "
1153  << drift_delay << "\n";
1154  strm << " nplanes_hit_pretrig [min. number of layers hit for pre-trigger] = "
1155  << nplanes_hit_pretrig << "\n";
1156  strm << " nplanes_hit_pattern [min. number of layers hit for trigger] = "
1157  << nplanes_hit_pattern << "\n";
1158  strm << " pid_thresh_pretrig [lower threshold on pattern id] = "
1159  << pid_thresh_pretrig << "\n";
1160  strm << " min_separation [region of busy key strips] = "
1161  << min_separation << "\n";
1162  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
1163  LogDebug("CSCCathodeLCTProcessor") << strm.str();
1164 }
#define LogDebug(id)
void CSCCathodeLCTProcessor::dumpDigis ( const std::vector< int >  strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS],
const int  nStrips 
) const
protected

Dump half-strip digis

Definition at line 1167 of file CSCCathodeLCTProcessor.cc.

References CSCDetId::chamberName(), TauDecayModes::dec, relativeConstraints::empty, LogDebug, LogTrace, CSCConstants::NUM_HALF_STRIPS_PER_CFEB, CSCConstants::NUM_LAYERS, digitizers_cfi::strip, CSCBaseboard::theChamber, CSCBaseboard::theEndcap, CSCBaseboard::theRing, and CSCBaseboard::theStation.

Referenced by CSCUpgradeCathodeLCTProcessor::findLCTs(), and findLCTs().

1168 {
1169  LogDebug("CSCCathodeLCTProcessor")
1171  << " strip type: half-strip, nStrips " << nStrips;
1172 
1173  std::ostringstream strstrm;
1174  for (int i_strip = 0; i_strip < nStrips; i_strip++) {
1175  if (i_strip%10 == 0) {
1176  if (i_strip < 100) strstrm << i_strip/10;
1177  else strstrm << (i_strip-100)/10;
1178  }
1179  else strstrm << " ";
1180  if ((i_strip+1)%CSCConstants::NUM_HALF_STRIPS_PER_CFEB == 0) strstrm << " ";
1181  }
1182  strstrm << "\n";
1183  for (int i_strip = 0; i_strip < nStrips; i_strip++) {
1184  strstrm << i_strip%10;
1185  if ((i_strip+1)%CSCConstants::NUM_HALF_STRIPS_PER_CFEB == 0) strstrm << " ";
1186  }
1187  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
1188  strstrm << "\n";
1189  for (int i_strip = 0; i_strip < nStrips; i_strip++) {
1190  if (!strip[i_layer][i_strip].empty()) {
1191  std::vector<int> bx_times = strip[i_layer][i_strip];
1192  // Dump only the first in time.
1193  strstrm << std::hex << bx_times[0] << std::dec;
1194  }
1195  else {
1196  strstrm << "-";
1197  }
1198  if ((i_strip+1)%CSCConstants::NUM_HALF_STRIPS_PER_CFEB == 0) strstrm << " ";
1199  }
1200  }
1201  LogTrace("CSCCathodeLCTProcessor") << strstrm.str();
1202 }
#define LogDebug(id)
const unsigned theEndcap
Definition: CSCBaseboard.h:33
unsigned theChamber
Definition: CSCBaseboard.h:40
#define LogTrace(id)
std::string chamberName() const
Definition: CSCDetId.cc:71
const unsigned theStation
Definition: CSCBaseboard.h:34
unsigned theRing
Definition: CSCBaseboard.h:39
std::vector< CSCCLCTDigi > CSCCathodeLCTProcessor::findLCTs ( const std::vector< int >  halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
protectedvirtual

Reimplemented in CSCUpgradeCathodeLCTProcessor.

Definition at line 689 of file CSCCathodeLCTProcessor.cc.

References best_pid, CLCT_BEND, CLCT_BX, CLCT_CFEB, CLCT_NUM_QUANTITIES, CLCT_PATTERN, CLCT_QUALITY, CLCT_STRIP, CLCT_STRIP_TYPE, drift_delay, dumpDigis(), fifo_tbins, CSCBaseboard::infoV, CSCConstants::KEY_CLCT_LAYER, LogTrace, markBusyKeys(), CSCConstants::MAX_CLCTS_PER_PROCESSOR, CSCConstants::MAX_HALFSTRIPS_IN_PATTERN, nhits, nplanes_hit_pattern, nplanes_hit_pretrig, CSCConstants::NUM_HALF_STRIPS_7CFEBS, CSCConstants::NUM_HALF_STRIPS_PER_CFEB, CSCConstants::NUM_LAYERS, numStrips, pattern2007, patternFinding(), preTrigger(), pulse(), pulseExtension(), jets_cff::quality, stagger, start_bx_shift, and thePreTriggerBXs.

Referenced by CSCUpgradeCathodeLCTProcessor::findLCTs(), and run().

690 {
691  std::vector<CSCCLCTDigi> lctList;
692 
693  // Max. number of half-strips for this chamber.
694  const int maxHalfStrips = 2*numStrips + 1;
695 
696  if (infoV > 1) dumpDigis(halfstrip, maxHalfStrips);
697 
698  // 2 possible LCTs per CSC x 7 LCT quantities
701 
702  // Fire half-strip one-shots for hit_persist bx's (4 bx's by default).
703  pulseExtension(halfstrip, maxHalfStrips, pulse);
704 
705  unsigned int start_bx = start_bx_shift;
706  // Stop drift_delay bx's short of fifo_tbins since at later bx's we will
707  // not have a full set of hits to start pattern search anyway.
708  unsigned int stop_bx = fifo_tbins - drift_delay;
709  // Allow for more than one pass over the hits in the time window.
710  while (start_bx < stop_bx) {
711  // All half-strip pattern envelopes are evaluated simultaneously, on every
712  // clock cycle.
713  int first_bx = 999;
714  bool pre_trig = preTrigger(pulse, start_bx, first_bx);
715 
716  // If any of half-strip envelopes has enough layers hit in it, TMB
717  // will pre-trigger.
718  if (pre_trig) {
719  thePreTriggerBXs.push_back(first_bx);
720  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
721  << "..... pretrigger at bx = " << first_bx
722  << "; waiting drift delay .....";
723 
724  // TMB latches LCTs drift_delay clocks after pretrigger.
725  int latch_bx = first_bx + drift_delay;
726  bool hits_in_time = patternFinding(pulse, maxHalfStrips, latch_bx);
727  if (infoV > 1) {
728  if (hits_in_time) {
729  for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER-1];
730  hstrip < maxHalfStrips; hstrip++) {
731  if (nhits[hstrip] > 0) {
732  LogTrace("CSCCathodeLCTProcessor")
733  << " bx = " << std::setw(2) << latch_bx << " --->"
734  << " halfstrip = " << std::setw(3) << hstrip
735  << " best pid = " << std::setw(2) << best_pid[hstrip]
736  << " nhits = " << nhits[hstrip];
737  }
738  }
739  }
740  }
741  // The pattern finder runs continuously, so another pre-trigger
742  // could occur already at the next bx.
743  //start_bx = first_bx + 1;
744 
745  // Quality for sorting.
748  for (int ilct = 0; ilct < CSCConstants::MAX_CLCTS_PER_PROCESSOR; ilct++) {
749  best_halfstrip[ilct] = -1;
750  best_quality[ilct] = 0;
751  }
752 
753  // Calculate quality from pattern id and number of hits, and
754  // simultaneously select best-quality LCT.
755  if (hits_in_time) {
756  for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER-1];
757  hstrip < maxHalfStrips; hstrip++) {
758  // The bend-direction bit pid[0] is ignored (left and right
759  // bends have equal quality).
760  quality[hstrip] = (best_pid[hstrip] & 14) | (nhits[hstrip] << 5);
761  if (quality[hstrip] > best_quality[0]) {
762  best_halfstrip[0] = hstrip;
763  best_quality[0] = quality[hstrip];
764  }
765  if (infoV > 1 && quality[hstrip] > 0) {
766  LogTrace("CSCCathodeLCTProcessor")
767  << " 1st CLCT: halfstrip = " << std::setw(3) << hstrip
768  << " quality = " << std::setw(3) << quality[hstrip]
769  << " nhits = " << std::setw(3) << nhits[hstrip]
770  << " pid = " << std::setw(3) << best_pid[hstrip]
771  << " best halfstrip = " << std::setw(3) << best_halfstrip[0]
772  << " best quality = " << std::setw(3) << best_quality[0];
773  }
774  }
775  }
776 
777  // If 1st best CLCT is found, look for the 2nd best.
778  if (best_halfstrip[0] >= 0) {
779  // Mark keys near best CLCT as busy by setting their quality to
780  // zero, and repeat the search.
781  markBusyKeys(best_halfstrip[0], best_pid[best_halfstrip[0]], quality);
782 
783  for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER-1];
784  hstrip < maxHalfStrips; hstrip++) {
785  if (quality[hstrip] > best_quality[1]) {
786  best_halfstrip[1] = hstrip;
787  best_quality[1] = quality[hstrip];
788  }
789  if (infoV > 1 && quality[hstrip] > 0) {
790  LogTrace("CSCCathodeLCTProcessor")
791  << " 2nd CLCT: halfstrip = " << std::setw(3) << hstrip
792  << " quality = " << std::setw(3) << quality[hstrip]
793  << " nhits = " << std::setw(3) << nhits[hstrip]
794  << " pid = " << std::setw(3) << best_pid[hstrip]
795  << " best halfstrip = " << std::setw(3) << best_halfstrip[1]
796  << " best quality = " << std::setw(3) << best_quality[1];
797  }
798  }
799 
800  // Pattern finder.
801  //bool ptn_trig = false;
802  for (int ilct = 0; ilct < CSCConstants::MAX_CLCTS_PER_PROCESSOR; ilct++) {
803  int best_hs = best_halfstrip[ilct];
804  if (best_hs >= 0 && nhits[best_hs] >= nplanes_hit_pattern) {
805  //ptn_trig = true;
806  keystrip_data[ilct][CLCT_PATTERN] = best_pid[best_hs];
807  keystrip_data[ilct][CLCT_BEND] =
809  // Remove stagger if any.
810  keystrip_data[ilct][CLCT_STRIP] =
812  keystrip_data[ilct][CLCT_BX] = first_bx;
813  keystrip_data[ilct][CLCT_STRIP_TYPE] = 1; // obsolete
814  keystrip_data[ilct][CLCT_QUALITY] = nhits[best_hs];
815  keystrip_data[ilct][CLCT_CFEB] =
817  int halfstrip_in_cfeb = keystrip_data[ilct][CLCT_STRIP] -
819 
820  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
821  << " Final selection: ilct " << ilct
822  << " key halfstrip " << keystrip_data[ilct][CLCT_STRIP]
823  << " quality " << keystrip_data[ilct][CLCT_QUALITY]
824  << " pattern " << keystrip_data[ilct][CLCT_PATTERN]
825  << " bx " << keystrip_data[ilct][CLCT_BX];
826 
827  CSCCLCTDigi thisLCT(1, keystrip_data[ilct][CLCT_QUALITY],
828  keystrip_data[ilct][CLCT_PATTERN],
829  keystrip_data[ilct][CLCT_STRIP_TYPE],
830  keystrip_data[ilct][CLCT_BEND],
831  halfstrip_in_cfeb,
832  keystrip_data[ilct][CLCT_CFEB],
833  keystrip_data[ilct][CLCT_BX]);
834  lctList.push_back(thisLCT);
835  }
836  }
837  }//find CLCT, end of best_halfstrip[0] >= 0
838 
839  //if (ptn_trig) {
840  // Once there was a trigger, CLCT pre-trigger state machine
841  // checks the number of hits that lie on a pattern template
842  // at every bx, and waits for it to drop below threshold.
843  // The search for CLCTs resumes only when the number of hits
844  // drops below threshold.
845  start_bx = fifo_tbins;
846  // Stop checking drift_delay bx's short of fifo_tbins since
847  // at later bx's we won't have a full set of hits for a
848  // pattern search anyway.
849  unsigned int stop_time = fifo_tbins - drift_delay;
850  for (unsigned int bx = latch_bx + 1; bx < stop_time; bx++) {
851  bool return_to_idle = true;
852  bool hits_in_time = patternFinding(pulse, maxHalfStrips, bx);
853  if (hits_in_time) {
854  for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER-1];
855  hstrip < maxHalfStrips; hstrip++) {
856  //if (nhits[hstrip] >= nplanes_hit_pattern) {
857  if (nhits[hstrip] >= nplanes_hit_pretrig) {//Tao, move dead time to pretrigger level
858  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
859  << " State machine busy at bx = " << bx;
860  return_to_idle = false;
861  break;
862  }
863  }
864  }
865  if (return_to_idle) {
866  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
867  << " State machine returns to idle state at bx = " << bx;
868  start_bx = bx;
869  break;
870  }
871  }
872  //}
873  }//pre_trig
874  else {
875  start_bx = first_bx + 1; // no dead time
876  }
877  }
878 
879  return lctList;
880 } // findLCTs -- TMB-07 version.
void dumpDigis(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int nStrips) const
bool patternFinding(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int nStrips, const unsigned int bx_time)
virtual bool preTrigger(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int start_bx, int &first_bx)
unsigned int best_pid[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
void markBusyKeys(const int best_hstrip, const int best_patid, int quality[CSCConstants::NUM_HALF_STRIPS_7CFEBS])
static const int pattern2007[CSCConstants::NUM_CLCT_PATTERNS][CSCConstants::MAX_HALFSTRIPS_IN_PATTERN+2]
#define LogTrace(id)
double pulse(double x, double y, double z, double t)
std::vector< int > thePreTriggerBXs
int stagger[CSCConstants::NUM_LAYERS]
unsigned int nhits[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
void pulseExtension(const std::vector< int > time[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int nStrips, unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
std::vector< CSCCLCTDigi > CSCCathodeLCTProcessor::getCLCTs ( ) const

Returns vector of all found CLCTs, if any.

Definition at line 1340 of file CSCCathodeLCTProcessor.cc.

References bestCLCT, CSCConstants::MAX_CLCT_TBINS, and secondCLCT.

Referenced by readoutCLCTs(), and run().

1341 {
1342  std::vector<CSCCLCTDigi> tmpV;
1343  for (int bx = 0; bx < CSCConstants::MAX_CLCT_TBINS; bx++) {
1344  if (bestCLCT[bx].isValid()) tmpV.push_back(bestCLCT[bx]);
1345  if (secondCLCT[bx].isValid()) tmpV.push_back(secondCLCT[bx]);
1346  }
1347  return tmpV;
1348 }
CSCCLCTDigi bestCLCT[CSCConstants::MAX_CLCT_TBINS]
CSCCLCTDigi secondCLCT[CSCConstants::MAX_CLCT_TBINS]
bool CSCCathodeLCTProcessor::getDigis ( const CSCComparatorDigiCollection compdc)
protected

Access routines to comparator digis.

Definition at line 530 of file CSCCathodeLCTProcessor.cc.

References CSCDetId::chamberName(), digiV, CSCBaseboard::disableME1a_, relativeConstraints::empty, CSCBaseboard::infoV, CSCBaseboard::isME11_, LogTrace, CSCConstants::NUM_LAYERS, CSCBaseboard::theChamber, CSCBaseboard::theEndcap, CSCBaseboard::theRing, CSCBaseboard::theSector, CSCBaseboard::theStation, CSCBaseboard::theSubsector, and CSCBaseboard::theTrigChamber.

Referenced by run().

531 {
532  bool noDigis = true;
533 
534  // Loop over layers and save comparator digis on each one into digiV[layer].
535  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
536  digiV[i_layer].clear();
537 
538  CSCDetId detid(theEndcap, theStation, theRing, theChamber, i_layer+1);
539  getDigis(compdc, detid);
540 
541  if (isME11_ && !disableME1a_) {
542  CSCDetId detid_me1a(theEndcap, theStation, 4, theChamber, i_layer+1);
543  getDigis(compdc, detid_me1a);
544  }
545 
546  if (!digiV[i_layer].empty()) {
547  noDigis = false;
548  if (infoV > 1) {
549  LogTrace("CSCCathodeLCTProcessor")
550  << "found " << digiV[i_layer].size()
551  << " comparator digi(s) in layer " << i_layer << " of " <<
552  detid.chamberName() << " (trig. sector " << theSector
553  << " subsector " << theSubsector << " id " << theTrigChamber << ")";
554  }
555  }
556  }
557 
558  return noDigis;
559 }
const unsigned theEndcap
Definition: CSCBaseboard.h:33
const unsigned theSector
Definition: CSCBaseboard.h:35
bool disableME1a_
Definition: CSCBaseboard.h:77
const unsigned theTrigChamber
Definition: CSCBaseboard.h:37
bool getDigis(const CSCComparatorDigiCollection *compdc)
unsigned theChamber
Definition: CSCBaseboard.h:40
#define LogTrace(id)
const unsigned theStation
Definition: CSCBaseboard.h:34
std::vector< CSCComparatorDigi > digiV[CSCConstants::NUM_LAYERS]
unsigned theRing
Definition: CSCBaseboard.h:39
const unsigned theSubsector
Definition: CSCBaseboard.h:36
void CSCCathodeLCTProcessor::getDigis ( const CSCComparatorDigiCollection compdc,
const CSCDetId id 
)
protected

Definition at line 561 of file CSCCathodeLCTProcessor.cc.

References digiV, CSCBaseboard::disableME1a_, CSCBaseboard::gangedME1a_, CSCConstants::MAX_NUM_STRIPS_ME1A_GANGED, CSCConstants::MAX_NUM_STRIPS_ME1A_UNGANGED, CSCConstants::MAX_NUM_STRIPS_ME1B, and relativeConstraints::ring.

563 {
564  const bool me1a = (id.station() == 1) && (id.ring() == 4);
565  const CSCComparatorDigiCollection::Range rcompd = compdc->get(id);
566  for (CSCComparatorDigiCollection::const_iterator digiIt = rcompd.first;
567  digiIt != rcompd.second; ++digiIt) {
568  const unsigned int origStrip = digiIt->getStrip();
569  const unsigned int maxStripsME1a = gangedME1a_ ?
571  // this special case can only be reached in MC
572  // in real data, the comparator digis have always ring==1
573  if (me1a && origStrip <= maxStripsME1a && !disableME1a_) {
574  // Move ME1/A comparators from CFEB=0 to CFEB=4 if this has not
575  // been done already.
577  digiIt->getComparator(),
578  digiIt->getTimeBinWord());
579  digiV[id.layer()-1].push_back(digi_corr);
580  }
581  else {
582  digiV[id.layer()-1].push_back(*digiIt);
583  }
584  }
585 }
bool disableME1a_
Definition: CSCBaseboard.h:77
bool gangedME1a_
Definition: CSCBaseboard.h:77
std::vector< CSCComparatorDigi >::const_iterator const_iterator
std::vector< CSCComparatorDigi > digiV[CSCConstants::NUM_LAYERS]
std::pair< const_iterator, const_iterator > Range
void CSCCathodeLCTProcessor::markBusyKeys ( const int  best_hstrip,
const int  best_patid,
int  quality[CSCConstants::NUM_HALF_STRIPS_7CFEBS] 
)
protected

Definition at line 1121 of file CSCCathodeLCTProcessor.cc.

References min_separation, and jets_cff::quality.

Referenced by CSCUpgradeCathodeLCTProcessor::findLCTs(), and findLCTs().

1124 {
1125  int nspan = min_separation;
1126  int pspan = min_separation;
1127 
1128  for (int hstrip = best_hstrip-nspan; hstrip <= best_hstrip+pspan; hstrip++) {
1129  if (hstrip >= 0 && hstrip < CSCConstants::NUM_HALF_STRIPS_7CFEBS) {
1130  quality[hstrip] = 0;
1131  }
1132  }
1133 } // markBusyKeys -- TMB-07 version.
bool CSCCathodeLCTProcessor::patternFinding ( const unsigned int  pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS],
const int  nStrips,
const unsigned int  bx_time 
)
protected

Definition at line 997 of file CSCCathodeLCTProcessor.cc.

References best_pid, fifo_tbins, first_bx_corrected, hit_persist, CSCBaseboard::infoV, CSCConstants::KEY_CLCT_LAYER, LogTrace, CSCConstants::MAX_HALFSTRIPS_IN_PATTERN, nhits, nplanes_hit_pretrig, CSCConstants::NUM_CLCT_PATTERNS, CSCConstants::NUM_LAYERS, pattern2007, pattern2007_offset, sysUtil::pid, pid_thresh_pretrig, pulse(), and stagger.

Referenced by CSCUpgradeCathodeLCTProcessor::findLCTs(), findLCTs(), CSCUpgradeCathodeLCTProcessor::preTrigger(), and preTrigger().

1000 {
1001  if (bx_time >= fifo_tbins) return false;
1002 
1003  // This loop is a quick check of a number of layers hit at bx_time: since
1004  // most of the time it is 0, this check helps to speed-up the execution
1005  // substantially.
1006  unsigned int layers_hit = 0;
1007  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++)
1008  {
1009  for (int i_hstrip = 0; i_hstrip < nStrips; i_hstrip++)
1010  {
1011  if (((pulse[i_layer][i_hstrip] >> bx_time) & 1) == 1)
1012  {
1013  layers_hit++;
1014  break;
1015  }
1016  }
1017  }
1018  if (layers_hit < nplanes_hit_pretrig) return false;
1019 
1020  for (int key_hstrip = 0; key_hstrip < nStrips; key_hstrip++)
1021  {
1022  best_pid[key_hstrip] = 0;
1023  nhits[key_hstrip] = 0;
1024  first_bx_corrected[key_hstrip] = -999;
1025  }
1026 
1027  // Loop over candidate key strips.
1028  bool hit_layer[CSCConstants::NUM_LAYERS];
1029  for (int key_hstrip = stagger[CSCConstants::KEY_CLCT_LAYER - 1]; key_hstrip < nStrips; key_hstrip++)
1030  {
1031  // Loop over patterns and look for hits matching each pattern.
1032  for (unsigned int pid = CSCConstants::NUM_CLCT_PATTERNS - 1; pid >= pid_thresh_pretrig; pid--)
1033  {
1034  layers_hit = 0;
1035  for (int ilayer = 0; ilayer < CSCConstants::NUM_LAYERS; ilayer++)
1036  hit_layer[ilayer] = false;
1037 
1038  double num_pattern_hits=0., times_sum=0.;
1039  std::multiset<int> mset_for_median;
1040  mset_for_median.clear();
1041 
1042  // Loop over halfstrips in trigger pattern mask and calculate the
1043  // "absolute" halfstrip number for each.
1044  for (int strip_num = 0; strip_num < CSCConstants::MAX_HALFSTRIPS_IN_PATTERN; strip_num++)
1045  {
1046  int this_layer = pattern2007[pid][strip_num];
1047  if (this_layer >= 0 && this_layer < CSCConstants::NUM_LAYERS)
1048  {
1049  int this_strip = pattern2007_offset[strip_num] + key_hstrip;
1050  if (this_strip >= 0 && this_strip < nStrips) {
1051  if (infoV > 3) LogTrace("CSCCathodeLCTProcessor")
1052  << " In patternFinding: key_strip = " << key_hstrip
1053  << " pid = " << pid << " strip_num = " << strip_num
1054  << " layer = " << this_layer << " strip = " << this_strip;
1055  // Determine if "one shot" is high at this bx_time
1056  if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1)
1057  {
1058  if (hit_layer[this_layer] == false)
1059  {
1060  hit_layer[this_layer] = true;
1061  layers_hit++; // determines number of layers hit
1062  }
1063 
1064  // find at what bx did pulse on this halsfstrip&layer have started
1065  // use hit_pesrist constraint on how far back we can go
1066  int first_bx_layer = bx_time;
1067  for (unsigned int dbx = 0; dbx < hit_persist; dbx++)
1068  {
1069  if (((pulse[this_layer][this_strip] >> (first_bx_layer - 1)) & 1) == 1)
1070  first_bx_layer--;
1071  else
1072  break;
1073  }
1074  times_sum += (double) first_bx_layer;
1075  num_pattern_hits += 1.;
1076  mset_for_median.insert(first_bx_layer);
1077  if (infoV > 2)
1078  LogTrace("CSCCathodeLCTProcessor") << " 1st bx in layer: " << first_bx_layer << " sum bx: " << times_sum
1079  << " #pat. hits: " << num_pattern_hits;
1080  }
1081  }
1082  }
1083  } // end loop over strips in pretrigger pattern
1084 
1085  if (layers_hit > nhits[key_hstrip])
1086  {
1087  best_pid[key_hstrip] = pid;
1088  nhits[key_hstrip] = layers_hit;
1089 
1090  // calculate median
1091  const int sz = mset_for_median.size();
1092  if (sz>0){
1093  std::multiset<int>::iterator im = mset_for_median.begin();
1094  if (sz>1) std::advance(im,sz/2-1);
1095  if (sz==1) first_bx_corrected[key_hstrip] = *im;
1096  else if ((sz % 2) == 1) first_bx_corrected[key_hstrip] = *(++im);
1097  else first_bx_corrected[key_hstrip] = ((*im) + (*(++im)))/2;
1098 
1099 #if defined(EDM_ML_DEBUG)
1100  //LogTrace only ever prints if EDM_ML_DEBUG is defined
1101  if (infoV > 1) {
1102  auto lt = LogTrace("CSCCathodeLCTProcessor")
1103  <<"bx="<<bx_time<<" bx_cor="<< first_bx_corrected[key_hstrip]<<" bxset=";
1104  for (im = mset_for_median.begin(); im != mset_for_median.end(); im++) {
1105  lt<<" "<<*im;
1106  }
1107  }
1108 #endif
1109  }
1110  // Do not loop over the other (worse) patterns if max. numbers of
1111  // hits is found.
1112  if (nhits[key_hstrip] == CSCConstants::NUM_LAYERS) break;
1113  }
1114  } // end loop over pid
1115  } // end loop over candidate key strips
1116  return true;
1117 } // patternFinding -- TMB-07 version.
int first_bx_corrected[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
static const int pattern2007_offset[CSCConstants::MAX_HALFSTRIPS_IN_PATTERN]
unsigned int best_pid[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
static const int pattern2007[CSCConstants::NUM_CLCT_PATTERNS][CSCConstants::MAX_HALFSTRIPS_IN_PATTERN+2]
#define LogTrace(id)
double pulse(double x, double y, double z, double t)
int stagger[CSCConstants::NUM_LAYERS]
unsigned int nhits[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
bool CSCCathodeLCTProcessor::preTrigger ( const unsigned int  pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS],
const int  start_bx,
int &  first_bx 
)
protectedvirtual

Reimplemented in CSCUpgradeCathodeLCTProcessor.

Definition at line 932 of file CSCCathodeLCTProcessor.cc.

References best_pid, fifo_tbins, CSCBaseboard::infoV, ispretrig, CSCConstants::KEY_CLCT_LAYER, LogTrace, CSCConstants::MAX_HALFSTRIPS_IN_PATTERN, nhits, nplanes_hit_pretrig, CSCConstants::NUM_HALF_STRIPS_PER_CFEB, numStrips, pattern2007, patternFinding(), pid_thresh_pretrig, pulse(), stagger, and thePreTriggerDigis.

Referenced by findLCTs(), and CSCUpgradeCathodeLCTProcessor::preTrigger().

935 {
936  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
937  << "....................PreTrigger...........................";
938 
939  // Max. number of half-strips for this chamber.
940  const int nStrips = 2*numStrips + 1;
941 
942  int nPreTriggers = 0;
943 
944  bool pre_trig = false;
945  // Now do a loop over bx times to see (if/when) track goes over threshold
946  for (unsigned int bx_time = start_bx; bx_time < fifo_tbins; bx_time++) {
947  // For any given bunch-crossing, start at the lowest keystrip and look for
948  // the number of separate layers in the pattern for that keystrip that have
949  // pulses at that bunch-crossing time. Do the same for the next keystrip,
950  // etc. Then do the entire process again for the next bunch-crossing, etc
951  // until you find a pre-trigger.
952  bool hits_in_time = patternFinding(pulse, nStrips, bx_time);
953  if (hits_in_time) {
954  for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER-1];
955  hstrip < nStrips; hstrip++) {
956  if (infoV > 1) {
957  if (nhits[hstrip] > 0) {
958  LogTrace("CSCCathodeLCTProcessor")
959  << " bx = " << std::setw(2) << bx_time << " --->"
960  << " halfstrip = " << std::setw(3) << hstrip
961  << " best pid = " << std::setw(2) << best_pid[hstrip]
962  << " nhits = " << nhits[hstrip];
963  }
964  }
965  ispretrig[hstrip] = false;
966  if (nhits[hstrip] >= nplanes_hit_pretrig &&
967  best_pid[hstrip] >= pid_thresh_pretrig) {
968  pre_trig = true;
969  ispretrig[hstrip] = true;
970 
971  // write each pre-trigger to output
972  nPreTriggers++;
974  const int halfstrip = hstrip%CSCConstants::NUM_HALF_STRIPS_PER_CFEB;
975  const int cfeb = hstrip/CSCConstants::NUM_HALF_STRIPS_PER_CFEB;
976  thePreTriggerDigis.push_back(CSCCLCTPreTriggerDigi(1, nhits[hstrip], best_pid[hstrip],
977  1, bend, halfstrip, cfeb, bx_time, nPreTriggers, 0));
978 
979  }
980  }
981 
982  if (pre_trig) {
983  first_bx = bx_time; // bx at time of pretrigger
984  return true;
985  }
986  }
987  } // end loop over bx times
988 
989  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor") <<
990  "no pretrigger, returning \n";
991  first_bx = fifo_tbins;
992  return false;
993 } // preTrigger -- TMB-07 version.
bool patternFinding(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int nStrips, const unsigned int bx_time)
bool ispretrig[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
unsigned int best_pid[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
static const int pattern2007[CSCConstants::NUM_CLCT_PATTERNS][CSCConstants::MAX_HALFSTRIPS_IN_PATTERN+2]
#define LogTrace(id)
std::vector< CSCCLCTPreTriggerDigi > thePreTriggerDigis
double pulse(double x, double y, double z, double t)
int stagger[CSCConstants::NUM_LAYERS]
unsigned int nhits[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
std::vector<int> CSCCathodeLCTProcessor::preTriggerBXs ( ) const
inline

Definition at line 74 of file CSCCathodeLCTProcessor.h.

References thePreTriggerBXs.

74 {return thePreTriggerBXs;}
std::vector< int > thePreTriggerBXs
std::vector<CSCCLCTPreTriggerDigi> CSCCathodeLCTProcessor::preTriggerDigis ( ) const
inline

read out CLCTs in ME1a , ME1b

Definition at line 77 of file CSCCathodeLCTProcessor.h.

References preTriggerDigisME1a(), preTriggerDigisME1b(), and thePreTriggerDigis.

Referenced by preTriggerDigisME1a(), and preTriggerDigisME1b().

77 {return thePreTriggerDigis; }
std::vector< CSCCLCTPreTriggerDigi > thePreTriggerDigis
std::vector< CSCCLCTPreTriggerDigi > CSCCathodeLCTProcessor::preTriggerDigisME1a ( ) const

Definition at line 1313 of file CSCCathodeLCTProcessor.cc.

References or, preTriggerDigis(), CSCBaseboard::theRing, and CSCBaseboard::theStation.

Referenced by preTriggerDigis().

1314 {
1315  std::vector<CSCCLCTPreTriggerDigi> tmpV;
1316  if (not (theStation == 1 and (theRing == 1 or theRing == 4)) )
1317  return tmpV;
1318  const std::vector<CSCCLCTPreTriggerDigi>& allPretriggerdigis = preTriggerDigis();
1319  for (const auto& preclct : allPretriggerdigis)
1320  if (preclct.getCFEB() >= 4 )
1321  tmpV.push_back(preclct);
1322  return tmpV;
1323 }
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
const unsigned theStation
Definition: CSCBaseboard.h:34
unsigned theRing
Definition: CSCBaseboard.h:39
std::vector< CSCCLCTPreTriggerDigi > preTriggerDigis() const
std::vector< CSCCLCTPreTriggerDigi > CSCCathodeLCTProcessor::preTriggerDigisME1b ( ) const

Definition at line 1326 of file CSCCathodeLCTProcessor.cc.

References or, preTriggerDigis(), CSCBaseboard::theRing, and CSCBaseboard::theStation.

Referenced by preTriggerDigis().

1327 {
1328  std::vector<CSCCLCTPreTriggerDigi> tmpV;
1329  if (not (theStation == 1 and (theRing == 1 or theRing == 4)) )
1330  return tmpV;
1331  const std::vector<CSCCLCTPreTriggerDigi>& allPretriggerdigis = preTriggerDigis();
1332  for (const auto& preclct : allPretriggerdigis)
1333  if (preclct.getCFEB() < 4 )
1334  tmpV.push_back(preclct);
1335  return tmpV;
1336 }
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
const unsigned theStation
Definition: CSCBaseboard.h:34
unsigned theRing
Definition: CSCBaseboard.h:39
std::vector< CSCCLCTPreTriggerDigi > preTriggerDigis() const
void CSCCathodeLCTProcessor::pulseExtension ( const std::vector< int >  time[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS],
const int  nStrips,
unsigned int  pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS] 
)
protected

Definition at line 884 of file CSCCathodeLCTProcessor.cc.

References relativeConstraints::empty, hit_persist, mps_fire::i, CSCBaseboard::infoV, CSCConstants::NUM_LAYERS, pulse(), start_bx_shift, and ntuplemaker::time.

Referenced by CSCUpgradeCathodeLCTProcessor::findLCTs(), and findLCTs().

888 {
889  static const unsigned int bits_in_pulse = 8*sizeof(pulse[0][0]);
890 
891  // Clear pulse array. This array will be used as a bit representation of
892  // hit times. For example: if strip[1][2] has a value of 3, then 1 shifted
893  // left 3 will be bit pattern of pulse[1][2]. This would make the pattern
894  // look like 0000000000001000. Then add on additional bits to signify
895  // the duration of a signal (hit_persist, formerly bx_width) to simulate
896  // the TMB's drift delay. So for the same pulse[1][2] with a hit_persist
897  // of 3 would look like 0000000000111000. This is similating the digital
898  // one-shot in the TMB.
899  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++)
900  for (int i_strip = 0; i_strip < nStrips; i_strip++)
901  pulse[i_layer][i_strip] = 0;
902 
903  // Loop over all layers and halfstrips.
904  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
905  for (int i_strip = 0; i_strip < nStrips; i_strip++) {
906  // If there is a hit, simulate digital one-shot persistence starting
907  // in the bx of the initial hit. Fill this into pulse[][].
908  if (!time[i_layer][i_strip].empty()) {
909  std::vector<int> bx_times = time[i_layer][i_strip];
910  for (unsigned int i = 0; i < bx_times.size(); i++) {
911  // Check that min and max times are within the allowed range.
912  if (bx_times[i] < 0 || bx_times[i] + hit_persist >= bits_in_pulse) {
913  if (infoV > 0) edm::LogWarning("L1CSCTPEmulatorOutOfTimeDigi")
914  << "+++ BX time of comparator digi (halfstrip = " << i_strip
915  << " layer = " << i_layer << ") bx = " << bx_times[i]
916  << " is not within the range (0-" << bits_in_pulse
917  << "] allowed for pulse extension. Skip this digi! +++\n";
918  continue;
919  }
920  if (bx_times[i] >= start_bx_shift) {
921  for (unsigned int bx = bx_times[i]; bx < bx_times[i] + hit_persist; ++bx)
922  pulse[i_layer][i_strip] = pulse[i_layer][i_strip] | (1 << bx);
923  }
924  }
925  }
926  }
927  }
928 } // pulseExtension.
double pulse(double x, double y, double z, double t)
void CSCCathodeLCTProcessor::readComparatorDigis ( std::vector< int >  halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
protected

Definition at line 587 of file CSCCathodeLCTProcessor.cc.

References begin, digiV, fifo_tbins, hit_persist, mps_fire::i, CSCBaseboard::infoV, LogTrace, CSCConstants::NUM_LAYERS, numStrips, stagger, CSCBaseboard::theChamber, CSCBaseboard::theRing, and CSCBaseboard::theStation.

Referenced by run().

589 {
590  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
591  int i_digi = 0; // digi counter, for dumps.
592  for (std::vector<CSCComparatorDigi>::iterator pld = digiV[i_layer].begin();
593  pld != digiV[i_layer].end(); pld++, i_digi++) {
594  // Dump raw digi info.
595  if (infoV > 1) {
596  std::ostringstream strstrm;
597  strstrm << "Comparator digi: comparator = " << pld->getComparator()
598  << " strip #" << pld->getStrip()
599  << " time bins on:";
600  std::vector<int> bx_times = pld->getTimeBinsOn();
601  for (unsigned int tbin = 0; tbin < bx_times.size(); tbin++)
602  strstrm << " " << bx_times[tbin];
603  LogTrace("CSCCathodeLCTProcessor") << strstrm.str();
604  }
605 
606  // Get comparator: 0/1 for left/right halfstrip for each comparator
607  // that fired.
608  int thisComparator = pld->getComparator();
609  if (thisComparator != 0 && thisComparator != 1) {
610  if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
611  << "+++ station "<< theStation<<" ring "<< theRing<<" chamber "<< theChamber
612  << " Found comparator digi with wrong comparator value = "
613  << thisComparator << "; skipping it... +++\n";
614  continue;
615  }
616 
617  // Get strip number.
618  int thisStrip = pld->getStrip() - 1; // count from 0
619  if (thisStrip < 0 || thisStrip >= numStrips) {
620  if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
621  << "+++ station "<< theStation<<" ring "<< theRing<<" chamber "<< theChamber
622  <<" Found comparator digi with wrong strip number = "
623  << thisStrip
624  << " (max strips = " << numStrips << "); skipping it... +++\n";
625  continue;
626  }
627  // 2*strip: convert strip to 1/2 strip
628  // comp : comparator output
629  // stagger: stagger for this layer
630  int thisHalfstrip = 2*thisStrip + thisComparator + stagger[i_layer];
631  if (thisHalfstrip >= 2*numStrips + 1) {
632  if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongInput")
633  << "+++ station "<< theStation<<" ring "<< theRing<<" chamber "<< theChamber
634  << " Found wrong halfstrip number = " << thisHalfstrip
635  << "; skipping this digi... +++\n";
636  continue;
637  }
638 
639  // Get bx times on this digi and check that they are within the bounds.
640  std::vector<int> bx_times = pld->getTimeBinsOn();
641  for (unsigned int i = 0; i < bx_times.size(); i++) {
642  // Total number of time bins in DAQ readout is given by fifo_tbins,
643  // which thus determines the maximum length of time interval.
644  //
645  // In data, only the CLCT in the time bin that was matched with L1A are read out
646  // while comparator digi is read out by 12 time bin, which includes 12 time bin info
647  // in other word, CLCTs emulated from comparator digis usually showed the OTMB behavior in 12 time bin
648  // while CLCT from data only showed 1 time bin OTMB behavior
649  // the CLCT emulated from comparator digis usually is centering at time bin 7 (BX7) and
650  // it is definitly safe to ignore any CLCTs in bx 0 or 1 and those CLCTs will never impacts on any triggers
651  if (bx_times[i] > 1 && bx_times[i] < static_cast<int>(fifo_tbins)) {
652 
653  if (i == 0 || (i > 0 && bx_times[i]-bx_times[i-1] >=
654  static_cast<int>(hit_persist))) {
655  // A later hit on the same strip is ignored during the
656  // number of clocks defined by the "hit_persist" parameter
657  // (i.e., 6 bx's by default).
658  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
659  << "Comp digi: layer " << i_layer+1
660  << " digi #" << i_digi+1
661  << " strip " << thisStrip
662  << " halfstrip " << thisHalfstrip
663  << " time " << bx_times[i]
664  << " comparator " << thisComparator
665  << " stagger " << stagger[i_layer];
666  halfstrip[i_layer][thisHalfstrip].push_back(bx_times[i]);
667  }
668  else if (i > 0) {
669  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
670  << "+++ station "<< theStation<<" ring "<< theRing<<" chamber "<< theChamber
671  << " Skipping comparator digi: strip = " << thisStrip
672  << ", layer = " << i_layer+1 << ", bx = " << bx_times[i]
673  << ", bx of previous hit = " << bx_times[i-1];
674  }
675  }
676  else {
677  if (infoV > 1) LogTrace("CSCCathodeLCTProcessor")
678  << "+++ station "<< theStation<<" ring "<< theRing<<" chamber "<< theChamber
679  << "+++ Skipping comparator digi: strip = " << thisStrip
680  << ", layer = " << i_layer+1 << ", bx = " << bx_times[i] << " +++";
681  }
682  }
683  }
684  }
685 }
unsigned theChamber
Definition: CSCBaseboard.h:40
#define LogTrace(id)
const unsigned theStation
Definition: CSCBaseboard.h:34
int stagger[CSCConstants::NUM_LAYERS]
#define begin
Definition: vmac.h:32
std::vector< CSCComparatorDigi > digiV[CSCConstants::NUM_LAYERS]
unsigned theRing
Definition: CSCBaseboard.h:39
std::vector< CSCCLCTDigi > CSCCathodeLCTProcessor::readoutCLCTs ( ) const

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

Definition at line 1206 of file CSCCathodeLCTProcessor.cc.

References early_tbins, getCLCTs(), CSCBaseboard::infoV, LogDebug, CSCConstants::MAX_CLCT_TBINS, AlCaHLTBitMon_ParallelJobs::p, readout_earliest_2, and tmb_l1a_window_size.

Referenced by readoutCLCTsME1a(), and readoutCLCTsME1b().

1207 {
1208  std::vector<CSCCLCTDigi> tmpV;
1209 
1210  // The start time of the L1A*CLCT coincidence window should be
1211  // related to the fifo_pretrig parameter, but I am not completely
1212  // sure how. For now, just choose it such that the window is
1213  // centered at bx=7. This may need further tweaking if the value of
1214  // tmb_l1a_window_size changes.
1215 
1216  // The number of CLCT bins in the read-out is given by the
1217  // tmb_l1a_window_size parameter, but made even by setting the LSB
1218  // of tmb_l1a_window_size to 0.
1219  //
1220  static std::atomic<int> lct_bins;
1222  static std::atomic<int> late_tbins;
1223  late_tbins = early_tbins + lct_bins;
1224 
1225  static std::atomic<int> ifois{0};
1226  if (ifois == 0) {
1227  if (infoV >= 0 && early_tbins < 0) {
1228  edm::LogWarning("L1CSCTPEmulatorSuspiciousParameters")
1229  << "+++ early_tbins = " << early_tbins
1230  << "; in-time CLCTs are not getting read-out!!! +++" << "\n";
1231  }
1232 
1233  if (late_tbins > CSCConstants::MAX_CLCT_TBINS-1) {
1234  if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorSuspiciousParameters")
1235  << "+++ Allowed range of time bins, [0-" << late_tbins
1236  << "] exceeds max allowed, " << CSCConstants::MAX_CLCT_TBINS-1 << " +++\n"
1237  << "+++ Set late_tbins to max allowed +++\n";
1238  late_tbins = CSCConstants::MAX_CLCT_TBINS-1;
1239  }
1240  ifois = 1;
1241  }
1242 
1243  // Start from the vector of all found CLCTs and select those within
1244  // the CLCT*L1A coincidence window.
1245  int bx_readout = -1;
1246  const std::vector<CSCCLCTDigi>& all_lcts = getCLCTs();
1247  for (const auto& p : all_lcts) {
1248  if (!p.isValid()) continue;
1249 
1250  const int bx = p.getBX();
1251  // Skip CLCTs found too early relative to L1Accept.
1252  if (bx <= early_tbins) {
1253  if (infoV > 1) LogDebug("CSCCathodeLCTProcessor")
1254  << " Do not report CLCT on key halfstrip " << p.getKeyStrip()
1255  << ": found at bx " << bx << ", whereas the earliest allowed bx is "
1256  << early_tbins+1;
1257  continue;
1258  }
1259 
1260  // Skip CLCTs found too late relative to L1Accept.
1261  if (bx > late_tbins) {
1262  if (infoV > 1) LogDebug("CSCCathodeLCTProcessor")
1263  << " Do not report CLCT on key halfstrip " << p.getKeyStrip()
1264  << ": found at bx " << bx << ", whereas the latest allowed bx is "
1265  << late_tbins;
1266  continue;
1267  }
1268 
1269  // If (readout_earliest_2) take only CLCTs in the earliest bx in the read-out window:
1270  // in digi->raw step, LCTs have to be packed into the TMB header, and
1271  // currently there is room just for two.
1272  if (readout_earliest_2) {
1273  if (bx_readout == -1 || bx == bx_readout) {
1274  tmpV.push_back(p);
1275  if (bx_readout == -1) bx_readout = bx;
1276  }
1277  }
1278  else tmpV.push_back(p);
1279  }
1280  return tmpV;
1281 }
#define LogDebug(id)
std::vector< CSCCLCTDigi > getCLCTs() const
std::vector< CSCCLCTDigi > CSCCathodeLCTProcessor::readoutCLCTsME1a ( ) const

Definition at line 1285 of file CSCCathodeLCTProcessor.cc.

References or, readoutCLCTs(), CSCBaseboard::theRing, and CSCBaseboard::theStation.

1286 {
1287  std::vector<CSCCLCTDigi> tmpV;
1288  if (not (theStation == 1 and (theRing == 1 or theRing == 4)) )
1289  return tmpV;
1290  const std::vector<CSCCLCTDigi>& allCLCTs = readoutCLCTs();
1291  for (const auto& clct : allCLCTs)
1292  if (clct.getCFEB() >= 4 )
1293  tmpV.push_back(clct);
1294  return tmpV;
1295 }
std::vector< CSCCLCTDigi > readoutCLCTs() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
const unsigned theStation
Definition: CSCBaseboard.h:34
unsigned theRing
Definition: CSCBaseboard.h:39
std::vector< CSCCLCTDigi > CSCCathodeLCTProcessor::readoutCLCTsME1b ( ) const

Definition at line 1300 of file CSCCathodeLCTProcessor.cc.

References or, readoutCLCTs(), CSCBaseboard::theRing, and CSCBaseboard::theStation.

1301 {
1302  std::vector<CSCCLCTDigi> tmpV;
1303  if (not (theStation == 1 and (theRing == 1 or theRing == 4)) )
1304  return tmpV;
1305  const std::vector<CSCCLCTDigi>& allCLCTs = readoutCLCTs();
1306  for (const auto& clct : allCLCTs)
1307  if (clct.getCFEB() < 4 )
1308  tmpV.push_back(clct);
1309  return tmpV;
1310 }
std::vector< CSCCLCTDigi > readoutCLCTs() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
const unsigned theStation
Definition: CSCBaseboard.h:34
unsigned theRing
Definition: CSCBaseboard.h:39
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 342 of file CSCCathodeLCTProcessor.cc.

References CSCBaseboard::alctClctOffset_, CSCDetId::chamberName(), CSCBaseboard::cscChamber_, CSCBaseboard::disableME1a_, dumpConfigParams(), relativeConstraints::empty, CSCBaseboard::gangedME1a_, CSCLayer::geometry(), getCLCTs(), getDigis(), CSCBaseboard::infoV, CSCBaseboard::isME11_, CSCChamber::layer(), CSCConstants::MAX_NUM_STRIPS, CSCConstants::MAX_NUM_STRIPS_7CFEBS, CSCConstants::MAX_NUM_STRIPS_ME1B, nplanes_hit_pretrig, CSCConstants::NUM_HALF_STRIPS_7CFEBS, CSCConstants::NUM_LAYERS, CSCLayerGeometry::numberOfStrips(), numStrips, AlCaHLTBitMon_ParallelJobs::p, readComparatorDigis(), CSCLayerGeometry::stagger(), stagger, CSCBaseboard::theChamber, CSCBaseboard::theEndcap, CSCBaseboard::theRing, CSCBaseboard::theSector, CSCBaseboard::theStation, CSCBaseboard::theSubsector, and CSCBaseboard::theTrigChamber.

343 {
344  // This is the version of the run() function that is called when running
345  // over the entire detector. It gets the comparator & timing info from the
346  // comparator digis and then passes them on to another run() function.
347 
348  // clear(); // redundant; called by L1MuCSCMotherboard.
349 
350  static std::atomic<bool> config_dumped{false};
351  if ((infoV > 0) && !config_dumped) {
353  config_dumped = true;
354  }
355 
356  // Get the number of strips and stagger of layers for the given chamber.
357  // Do it only once per chamber.
358  if (numStrips == 0) {
359  if (cscChamber_) {
361  // ME1/a is known to the readout hardware as strips 65-80 of ME1/1.
362  // Still need to decide whether we do any special adjustments to
363  // reconstruct LCTs in this region (3:1 ganged strips); for now, we
364  // simply allow for hits in ME1/a and apply standard reconstruction
365  // to them.
366  // For SLHC ME1/1 is set to have 4 CFEBs in ME1/b and 3 CFEBs in ME1/a
367  if (isME11_) {
368  if (theRing == 4) {
369  if (infoV >= 0) {
370  edm::LogError("L1CSCTPEmulatorSetupError")
371  << "+++ Invalid ring number for this processor " << theRing
372  << " was set in the config."
373  << " +++\n"
374  << "+++ CSC geometry looks garbled; no emulation possible +++\n";
375  }
376  }
380  }
381 
383  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorSetupError")
384  << "+++ Number of strips, " << numStrips
386  << " (sector " << theSector << " subsector " << theSubsector
387  << " trig id. " << theTrigChamber << ")"
388  << " exceeds max expected, " << CSCConstants::MAX_NUM_STRIPS_7CFEBS
389  << " +++\n"
390  << "+++ CSC geometry looks garbled; no emulation possible +++\n";
391  numStrips = -1;
392  }
393  // The strips for a given layer may be offset from the adjacent layers.
394  // This was done in order to improve resolution. We need to find the
395  // 'staggering' for each layer and make necessary conversions in our
396  // arrays. -JM
397  // In the TMB-07 firmware, half-strips in odd layers (layers are
398  // counted as ly0-ly5) are shifted by -1 half-strip, whereas in
399  // the previous firmware versions half-strips in even layers
400  // were shifted by +1 half-strip. This difference is due to a
401  // change from ly3 to ly2 in the choice of the key layer, and
402  // the intention to keep half-strips in the key layer unchanged.
403  // In the emulator, we use the old way for both cases, to avoid
404  // negative half-strip numbers. This will necessitate a
405  // subtraction of 1 half-strip for TMB-07 later on. -SV.
406  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
407  stagger[i_layer] =
408  (cscChamber_->layer(i_layer+1)->geometry()->stagger() + 1) / 2;
409  }
410  }
411  else {
412  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
414  << " (sector " << theSector << " subsector " << theSubsector
415  << " trig id. " << theTrigChamber << ")"
416  << " is not defined in current geometry! +++\n"
417  << "+++ CSC geometry looks garbled; no emulation possible +++\n";
418  numStrips = -1;
419  }
420  }
421 
422  if (numStrips < 0) {
423  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
425  << " (sector " << theSector << " subsector " << theSubsector
426  << " trig id. " << theTrigChamber << "):"
427  << " numStrips = " << numStrips << "; CLCT emulation skipped! +++";
428  std::vector<CSCCLCTDigi> emptyV;
429  return emptyV;
430  }
431 
432  // Get comparator digis in this chamber.
433  bool noDigis = getDigis(compdc);
434 
435  if (!noDigis) {
436  // Get halfstrip times from comparator digis.
437  std::vector<int>
439  readComparatorDigis(halfstrip);
440 
441  // Pass arrays of halfstrips on to another run() doing the
442  // LCT search.
443  // If the number of layers containing digis is smaller than that
444  // required to trigger, quit right away. (If LCT-based digi suppression
445  // is implemented one day, this condition will have to be changed
446  // to the number of planes required to pre-trigger.)
447  unsigned int layersHit = 0;
448  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
449  for (int i_hstrip = 0; i_hstrip < CSCConstants::NUM_HALF_STRIPS_7CFEBS;
450  i_hstrip++) {
451  if (!halfstrip[i_layer][i_hstrip].empty()) {layersHit++; break;}
452  }
453  }
454  // Run the algorithm only if the probability for the pre-trigger
455  // to fire is not null. (Pre-trigger decisions are used for the
456  // strip read-out conditions in DigiToRaw.)
457  if (layersHit >= nplanes_hit_pretrig) run(halfstrip);
458  }
459 
460  // Return vector of CLCTs.
461  std::vector<CSCCLCTDigi> tmpV = getCLCTs();
462 
463  // shift the BX from 7 to 8
464  // the unpacked real data CLCTs have central BX at bin 7
465  // however in simulation the central BX is bin 8
466  // to make a proper comparison with ALCTs we need
467  // CLCT and ALCT to have the central BX in the same bin
468  // this shift does not affect the readout of the CLCTs
469  // emulated CLCTs put in the event should be centered at bin 7 (as in data)
470  for (auto& p : tmpV){
471  p.setBX(p.getBX() + alctClctOffset_);
472  }
473 
474  return tmpV;
475 }
const unsigned theEndcap
Definition: CSCBaseboard.h:33
const CSCChamber * cscChamber_
Definition: CSCBaseboard.h:55
const unsigned theSector
Definition: CSCBaseboard.h:35
int numberOfStrips() const
bool disableME1a_
Definition: CSCBaseboard.h:77
bool gangedME1a_
Definition: CSCBaseboard.h:77
const unsigned theTrigChamber
Definition: CSCBaseboard.h:37
void readComparatorDigis(std::vector< int > halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
bool getDigis(const CSCComparatorDigiCollection *compdc)
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
Definition: CSCChamber.cc:39
unsigned theChamber
Definition: CSCBaseboard.h:40
std::string chamberName() const
Definition: CSCDetId.cc:71
int stagger() const
std::vector< CSCCLCTDigi > getCLCTs() const
const unsigned theStation
Definition: CSCBaseboard.h:34
int stagger[CSCConstants::NUM_LAYERS]
std::vector< CSCCLCTDigi > run(const CSCComparatorDigiCollection *compdc)
unsigned theRing
Definition: CSCBaseboard.h:39
unsigned int alctClctOffset_
Definition: CSCBaseboard.h:86
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:47
const unsigned theSubsector
Definition: CSCBaseboard.h:36
void CSCCathodeLCTProcessor::run ( const std::vector< int >  halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])

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

Definition at line 477 of file CSCCathodeLCTProcessor.cc.

References bestCLCT, CSCDetId::chamberName(), findLCTs(), CSCBaseboard::infoV, LogDebug, CSCConstants::MAX_CLCT_TBINS, AlCaHLTBitMon_ParallelJobs::p, secondCLCT, CSCCLCTDigi::setTrknmb(), CSCBaseboard::theChamber, CSCBaseboard::theEndcap, CSCBaseboard::theRing, CSCBaseboard::theSector, CSCBaseboard::theStation, CSCBaseboard::theSubsector, and CSCBaseboard::theTrigChamber.

478 {
479  // This version of the run() function can either be called in a standalone
480  // test, being passed the halfstrip times, or called by the
481  // run() function above. It uses the findLCTs() method to find vectors
482  // of LCT candidates. These candidates are sorted and the best two per bx
483  // are returned.
484  std::vector<CSCCLCTDigi> CLCTlist = findLCTs(halfstrip);
485 
486  // LCT sorting.
487  if (CLCTlist.size() > 1)
488  sort(CLCTlist.begin(), CLCTlist.end(), std::greater<CSCCLCTDigi>());
489 
490  // Take the best two candidates per bx.
491  for (const auto& p : CLCTlist) {
492  const int bx = p.getBX();
493  if (bx >= CSCConstants::MAX_CLCT_TBINS) {
494  if (infoV > 0) edm::LogWarning("L1CSCTPEmulatorOutOfTimeCLCT")
495  << "+++ Bx of CLCT candidate, " << bx << ", exceeds max allowed, "
496  << CSCConstants::MAX_CLCT_TBINS-1 << "; skipping it... +++\n";
497  continue;
498  }
499 
500  if (!bestCLCT[bx].isValid()) {
501  bestCLCT[bx] = p;
502  }
503  else if (!secondCLCT[bx].isValid()) {
504  secondCLCT[bx] = p;
505  }
506  }
507 
508  for (int bx = 0; bx < CSCConstants::MAX_CLCT_TBINS; bx++) {
509  if (bestCLCT[bx].isValid()) {
510  bestCLCT[bx].setTrknmb(1);
511  if (infoV > 0) LogDebug("CSCCathodeLCTProcessor")
512  << bestCLCT[bx] << " found in " <<
514  << " (sector " << theSector << " subsector " << theSubsector
515  << " trig id. " << theTrigChamber << ")" << "\n";
516  }
517  if (secondCLCT[bx].isValid()) {
518  secondCLCT[bx].setTrknmb(2);
519  if (infoV > 0) LogDebug("CSCCathodeLCTProcessor")
520  << secondCLCT[bx] << " found in " <<
522  << " (sector " << theSector << " subsector " << theSubsector
523  << " trig id. " << theTrigChamber << ")" << "\n";
524  }
525  }
526  // Now that we have our best CLCTs, they get correlated with the best
527  // ALCTs and then get sent to the MotherBoard. -JM
528 }
#define LogDebug(id)
CSCCLCTDigi bestCLCT[CSCConstants::MAX_CLCT_TBINS]
const unsigned theEndcap
Definition: CSCBaseboard.h:33
virtual std::vector< CSCCLCTDigi > findLCTs(const std::vector< int > halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
const unsigned theSector
Definition: CSCBaseboard.h:35
const unsigned theTrigChamber
Definition: CSCBaseboard.h:37
unsigned theChamber
Definition: CSCBaseboard.h:40
std::string chamberName() const
Definition: CSCDetId.cc:71
const unsigned theStation
Definition: CSCBaseboard.h:34
CSCCLCTDigi secondCLCT[CSCConstants::MAX_CLCT_TBINS]
unsigned theRing
Definition: CSCBaseboard.h:39
const unsigned theSubsector
Definition: CSCBaseboard.h:36
void setTrknmb(const uint16_t number)
Set track number (1,2) after sorting CLCTs.
Definition: CSCCLCTDigi.h:95
void CSCCathodeLCTProcessor::setConfigParameters ( const CSCDBL1TPParameters conf)

Sets configuration parameters obtained via EventSetup mechanism.

Definition at line 220 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, min_separation, nplanes_hit_pattern, nplanes_hit_pretrig, and pid_thresh_pretrig.

221 {
222  static std::atomic<bool> config_dumped{false};
223 
224  fifo_tbins = conf->clctFifoTbins();
225  fifo_pretrig = conf->clctFifoPretrig();
226  hit_persist = conf->clctHitPersist();
227  drift_delay = conf->clctDriftDelay();
232 
233  // Check and print configuration parameters.
235  if (!config_dumped) {
237  config_dumped = true;
238  }
239 }
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 ( )
protected

Set default values for configuration parameters.

Definition at line 205 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, min_separation, nplanes_hit_pattern, nplanes_hit_pretrig, pid_thresh_pretrig, and tmb_l1a_window_size.

Referenced by CSCCathodeLCTProcessor().

206 {
207  // Set default values for configuration parameters.
217 }
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

Member Data Documentation

unsigned int CSCCathodeLCTProcessor::best_pid[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
protected
CSCCLCTDigi CSCCathodeLCTProcessor::bestCLCT[CSCConstants::MAX_CLCT_TBINS]

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

Definition at line 82 of file CSCCathodeLCTProcessor.h.

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

const unsigned int CSCCathodeLCTProcessor::def_drift_delay = 2
staticprotected

Definition at line 195 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_fifo_pretrig = 7
staticprotected

Definition at line 194 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_fifo_tbins = 12
staticprotected

Default values of configuration parameters.

Definition at line 194 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_hit_persist = 6
staticprotected

Definition at line 195 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_min_separation = 10
staticprotected

Definition at line 198 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_nplanes_hit_pattern = 4
staticprotected

Definition at line 197 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_nplanes_hit_pretrig = 2
staticprotected

Definition at line 196 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_pid_thresh_pretrig = 2
staticprotected

Definition at line 198 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

const unsigned int CSCCathodeLCTProcessor::def_tmb_l1a_window_size = 7
staticprotected

Definition at line 199 of file CSCCathodeLCTProcessor.h.

Referenced by checkConfigParameters(), and setDefaultConfigParameters().

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

Definition at line 173 of file CSCCathodeLCTProcessor.h.

Referenced by getDigis(), and readComparatorDigis().

unsigned int CSCCathodeLCTProcessor::drift_delay
protected
int CSCCathodeLCTProcessor::early_tbins
protected

VK: separate handle for early time bins

Definition at line 188 of file CSCCathodeLCTProcessor.h.

Referenced by CSCCathodeLCTProcessor(), and readoutCLCTs().

unsigned int CSCCathodeLCTProcessor::fifo_pretrig
protected
unsigned int CSCCathodeLCTProcessor::fifo_tbins
protected
int CSCCathodeLCTProcessor::first_bx_corrected[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
protected
unsigned int CSCCathodeLCTProcessor::hit_persist
protected
bool CSCCathodeLCTProcessor::ispretrig[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
protected
unsigned int CSCCathodeLCTProcessor::min_separation
protected
unsigned int CSCCathodeLCTProcessor::nhits[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
protected
unsigned int CSCCathodeLCTProcessor::nplanes_hit_pattern
protected
unsigned int CSCCathodeLCTProcessor::nplanes_hit_pretrig
protected
int CSCCathodeLCTProcessor::numStrips
protected
const int CSCCathodeLCTProcessor::pattern2007
static
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 }

Pre-defined patterns.

Definition at line 152 of file CSCCathodeLCTProcessor.h.

Referenced by patternFinding().

unsigned int CSCCathodeLCTProcessor::pid_thresh_pretrig
protected
bool CSCCathodeLCTProcessor::readout_earliest_2
protected

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

Definition at line 191 of file CSCCathodeLCTProcessor.h.

Referenced by CSCCathodeLCTProcessor(), and readoutCLCTs().

CSCCLCTDigi CSCCathodeLCTProcessor::secondCLCT[CSCConstants::MAX_CLCT_TBINS]

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

Definition at line 85 of file CSCCathodeLCTProcessor.h.

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

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

VK: some quick and dirty fix to reduce CLCT deadtime

Definition at line 185 of file CSCCathodeLCTProcessor.h.

Referenced by CSCCathodeLCTProcessor(), CSCUpgradeCathodeLCTProcessor::findLCTs(), findLCTs(), and pulseExtension().

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

Definition at line 174 of file CSCCathodeLCTProcessor.h.

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

std::vector<CSCCLCTPreTriggerDigi> CSCCathodeLCTProcessor::thePreTriggerDigis
protected
unsigned int CSCCathodeLCTProcessor::tmb_l1a_window_size
protected