Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-07-22 22:47:10

0001 #include "L1Trigger/CSCTriggerPrimitives/interface/GEMInternalCluster.h"
0002 #include "DataFormats/CSCDigi/interface/CSCConstants.h"
0003 
0004 GEMInternalCluster::GEMInternalCluster(const GEMDetId& id1,
0005                                        const GEMDetId& id2,
0006                                        const GEMPadDigiCluster& cluster1,
0007                                        const GEMPadDigiCluster& cluster2,
0008                                        const unsigned delayGEMinOTMB,
0009                                        const unsigned tmbL1aWindowSize) {
0010   // set coincidence to false first
0011   isCoincidence_ = false;
0012   isValid_ = false;
0013 
0014   // set matches to false first
0015   isMatchingLayer1_ = false;
0016   isMatchingLayer2_ = false;
0017 
0018   id1_ = id1;
0019   id2_ = id2;
0020 
0021   if (cluster1.isValid()) {
0022     isValid_ = true;
0023     cl1_ = cluster1;
0024     if (cluster1.alctMatchTime() == -1)  // It is a MC simulation
0025       bx_ = cluster1.bx() + CSCConstants::LCT_CENTRAL_BX;
0026     else if (cluster1.alctMatchTime() >= 0)  // It is real data
0027       bx_ = cluster1.bx() + CSCConstants::LCT_CENTRAL_BX - int(tmbL1aWindowSize / 2) - cluster1.alctMatchTime() +
0028             delayGEMinOTMB;
0029     layer1_pad_ = cluster1.pads()[0];
0030     layer1_size_ = cluster1.pads().size();
0031   }
0032   if (cluster2.isValid()) {
0033     isValid_ = true;
0034     cl2_ = cluster2;
0035     if (cluster2.alctMatchTime() == -1)  // It is a MC simulation
0036       bx_ = cluster2.bx() + CSCConstants::LCT_CENTRAL_BX;
0037     else if (cluster2.alctMatchTime() >= 0)  // It is real data
0038       bx_ = cluster2.bx() + CSCConstants::LCT_CENTRAL_BX - int(tmbL1aWindowSize / 2) - cluster2.alctMatchTime() +
0039             delayGEMinOTMB;
0040     layer2_pad_ = cluster2.pads()[0];
0041     layer2_size_ = cluster2.pads().size();
0042   }
0043 
0044   if (cluster1.isValid() and cluster2.isValid()) {
0045     if (cluster1.alctMatchTime() == -1)  // It is a MC simulation
0046       bx_ = cluster1.bx() + CSCConstants::LCT_CENTRAL_BX;
0047     else if (cluster1.alctMatchTime() >= 0)  // It is real data
0048       bx_ = cluster1.bx() + CSCConstants::LCT_CENTRAL_BX - int(tmbL1aWindowSize / 2) - cluster1.alctMatchTime() +
0049             delayGEMinOTMB;
0050     isCoincidence_ = true;
0051   }
0052 
0053   layer1_min_wg_ = -1;
0054   layer1_max_wg_ = -1;
0055   layer2_min_wg_ = -1;
0056   layer2_max_wg_ = -1;
0057 
0058   layer1_first_es_ = -1;
0059   layer2_first_es_ = -1;
0060   layer1_last_es_ = -1;
0061   layer2_last_es_ = -1;
0062 
0063   layer1_first_es_me1a_ = -1;
0064   layer2_first_es_me1a_ = -1;
0065   layer1_last_es_me1a_ = -1;
0066   layer2_last_es_me1a_ = -1;
0067 
0068   layer1_middle_es_ = -1;
0069   layer2_middle_es_ = -1;
0070 
0071   layer1_middle_es_me1a_ = -1;
0072   layer2_middle_es_me1a_ = -1;
0073 }
0074 
0075 GEMInternalCluster::GEMInternalCluster() {
0076   // set coincidence to false first
0077   isCoincidence_ = false;
0078   isValid_ = false;
0079 
0080   // set matches to false first
0081   isMatchingLayer1_ = false;
0082   isMatchingLayer2_ = false;
0083 
0084   layer1_min_wg_ = -1;
0085   layer1_max_wg_ = -1;
0086   layer2_min_wg_ = -1;
0087   layer2_max_wg_ = -1;
0088 
0089   layer1_first_es_ = -1;
0090   layer2_first_es_ = -1;
0091   layer1_last_es_ = -1;
0092   layer2_last_es_ = -1;
0093 
0094   layer1_first_es_me1a_ = -1;
0095   layer2_first_es_me1a_ = -1;
0096   layer1_last_es_me1a_ = -1;
0097   layer2_last_es_me1a_ = -1;
0098 
0099   layer1_middle_es_ = -1;
0100   layer2_middle_es_ = -1;
0101 
0102   layer1_middle_es_me1a_ = -1;
0103   layer2_middle_es_me1a_ = -1;
0104 }
0105 
0106 GEMPadDigi GEMInternalCluster::mid1() const {
0107   if (!cl1_.isValid())
0108     return GEMPadDigi();
0109   const unsigned pad = cl1_.pads()[cl1_.pads().size() / 2];
0110 
0111   return GEMPadDigi(pad, cl1_.bx(), cl1_.station(), cl1_.nPartitions());
0112 }
0113 
0114 GEMPadDigi GEMInternalCluster::mid2() const {
0115   if (!cl2_.isValid())
0116     return GEMPadDigi();
0117   const unsigned pad = cl2_.pads()[cl2_.pads().size() / 2];
0118 
0119   return GEMPadDigi(pad, cl2_.bx(), cl2_.station(), cl2_.nPartitions());
0120 }
0121 
0122 uint16_t GEMInternalCluster::getKeyStrip(int n, bool isLayer2) const {
0123   if (n == 8) {
0124     if (!isLayer2) {
0125       return (layer1_first_es_ + layer1_last_es_) / 2.;
0126     } else {
0127       return (layer2_first_es_ + layer2_last_es_) / 2.;
0128     }
0129   } else {  // Half Strip units
0130     if (!isLayer2) {
0131       return (layer1_first_es_ + layer1_last_es_) / 8.;
0132     } else {
0133       return (layer2_first_es_ + layer2_last_es_) / 8.;
0134     }
0135   }
0136 }
0137 
0138 uint16_t GEMInternalCluster::getKeyStripME1a(int n, bool isLayer2) const {
0139   if (n == 8) {
0140     if (!isLayer2) {
0141       return (layer1_first_es_me1a_ + layer1_last_es_me1a_) / 2.;
0142     } else {
0143       return (layer2_first_es_me1a_ + layer2_last_es_me1a_) / 2.;
0144     }
0145   } else {  // Half Strip units
0146     if (!isLayer2) {
0147       return (layer1_first_es_me1a_ + layer1_last_es_me1a_) / 8.;
0148     } else {
0149       return (layer2_first_es_me1a_ + layer2_last_es_me1a_) / 8.;
0150     }
0151   }
0152 }
0153 
0154 bool GEMInternalCluster::has_cluster(const GEMPadDigiCluster& cluster) const {
0155   return cl1_ == cluster or cl2_ == cluster;
0156 }
0157 
0158 bool GEMInternalCluster::operator==(const GEMInternalCluster& cluster) const {
0159   return id1_ == cluster.id1() and id2_ == cluster.id2() and cl1_ == cluster.cl1() and cl2_ == cluster.cl2();
0160 }
0161 
0162 std::ostream& operator<<(std::ostream& os, const GEMInternalCluster& cl) {
0163   return os << "Cluster Layer 1: " << cl.id1() << " " << cl.cl1() << ", Cluster Layer 2: " << cl.id2() << " "
0164             << cl.cl2();
0165 }