Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-24 02:52:14

0001 #ifndef L1Trigger_CSCTriggerPrimitives_LCTQualityControl_h
0002 #define L1Trigger_CSCTriggerPrimitives_LCTQualityControl_h
0003 
0004 /** \class
0005  *
0006  * This class checks if ALCT, CLCT and LCT products are valid.
0007  * It inherits from CSCBaseboard. Neither are physical boards at CMS
0008  * But they are convenient classes in the trigger code.
0009  *
0010  * Author: Sven Dildick (Rice University)
0011  *
0012  */
0013 
0014 #include "DataFormats/CSCDigi/interface/CSCCLCTDigi.h"
0015 #include "DataFormats/CSCDigi/interface/CSCALCTDigi.h"
0016 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h"
0017 #include "L1Trigger/CSCTriggerPrimitives/interface/CSCBaseboard.h"
0018 
0019 #include <vector>
0020 #include <algorithm>
0021 
0022 class LCTQualityControl : public CSCBaseboard {
0023 public:
0024   // constructor
0025   LCTQualityControl(unsigned endcap,
0026                     unsigned station,
0027                     unsigned sector,
0028                     unsigned subsector,
0029                     unsigned chamber,
0030                     const edm::ParameterSet& conf);
0031 
0032   /** Default destructor. */
0033   ~LCTQualityControl() override = default;
0034 
0035   // Check if the ALCT is valid
0036   void checkValidReadout(const CSCALCTDigi& alct) const;
0037   void checkValid(const CSCALCTDigi& alct, unsigned max_stubs = CSCConstants::MAX_ALCTS_PER_PROCESSOR) const;
0038 
0039   // Check if the CLCT is valid
0040   void checkValid(const CSCCLCTDigi& lct, unsigned max_stubs = CSCConstants::MAX_CLCTS_PER_PROCESSOR) const;
0041 
0042   // Check if the LCT is valid - TMB version
0043   void checkValid(const CSCCorrelatedLCTDigi& lct) const;
0044 
0045   // Check if the LCT is valid - MPC version
0046   void checkValid(const CSCCorrelatedLCTDigi& lct, const unsigned station, const unsigned ring) const;
0047 
0048   void checkRange(int parameter, int min_value, int max_value, const std::string& comment, unsigned& errors) const;
0049 
0050   template <class T>
0051   void reportErrors(const T& lct, const unsigned errors) const;
0052 
0053   // no more than 2 LCTs per BX in the readout
0054   void checkMultiplicityBX(const std::vector<CSCALCTDigi>& alcts) const;
0055   void checkMultiplicityBX(const std::vector<CSCCLCTDigi>& clcts) const;
0056   void checkMultiplicityBX(const std::vector<CSCCorrelatedLCTDigi>& lcts) const;
0057   template <class T>
0058   void checkMultiplicityBX(const std::vector<T>& lcts, unsigned nLCT) const;
0059 
0060   // for Phase-1 patterns
0061   int getSlopePhase1(unsigned pattern) const;
0062 
0063   /*
0064     CSC max strip & max wire
0065     Need to pass station and ring, because we want to reuse the LCTQualityControl in the
0066     MPC where the station and ring are considered arguments, not data members.
0067   */
0068   unsigned get_csc_max_wiregroup(unsigned station, unsigned ring) const;
0069   unsigned get_csc_max_halfstrip(unsigned station, unsigned ring) const;
0070   unsigned get_csc_max_quartstrip(unsigned station, unsigned ring) const;
0071   unsigned get_csc_max_eighthstrip(unsigned station, unsigned ring) const;
0072 
0073   // slope values
0074   std::pair<int, int> get_csc_clct_min_max_slope() const;
0075 
0076   // CLCT min, max CFEB numbers
0077   std::pair<unsigned, unsigned> get_csc_min_max_cfeb() const;
0078 
0079   // CSC min, max pattern
0080   std::pair<unsigned, unsigned> get_csc_min_max_pattern() const;
0081   std::pair<unsigned, unsigned> get_csc_min_max_pattern_run3() const;
0082   std::pair<unsigned, unsigned> get_csc_lct_min_max_pattern() const;
0083 
0084   /*
0085    CSC min, max quality
0086    Need to pass station and ring for the LCT implementation, because we want to
0087    reuse the LCTQualityControl in the MPC where the station and ring are considered
0088    arguments, not data members.
0089   */
0090   std::pair<unsigned, unsigned> get_csc_alct_min_max_quality() const;
0091   std::pair<unsigned, unsigned> get_csc_clct_min_max_quality() const;
0092   std::pair<unsigned, unsigned> get_csc_lct_min_max_quality(unsigned station, unsigned ring) const;
0093 
0094 private:
0095   // min number of layers for a CLCT
0096   unsigned nplanes_clct_hit_pattern;
0097 };
0098 
0099 template <class T>
0100 void LCTQualityControl::checkMultiplicityBX(const std::vector<T>& collection, unsigned nLCT) const {
0101   std::unordered_map<int, unsigned> freq;
0102   // check each BX
0103   for (const auto& p : collection) {
0104     if (p.isValid()) {
0105       freq[p.getBX()]++;
0106 
0107       // too many ALCTs, CLCTs or LCTs in this BX
0108       if (freq[p.getBX()] > nLCT) {
0109         edm::LogError("LCTQualityControl") << "Collection with more than " << nLCT << " in BX " << p.getBX();
0110         break;
0111       }
0112     }
0113   }
0114 }
0115 
0116 #endif