File indexing completed on 2023-03-17 10:44:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #include "CaloOnlineTools/EcalTools/plugins/EcalExclusiveTrigFilter.h"
0020
0021 using namespace cms;
0022 using namespace edm;
0023 using namespace std;
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 EcalExclusiveTrigFilter::EcalExclusiveTrigFilter(const edm::ParameterSet& iConfig)
0037 : l1GTReadoutRecTag_(iConfig.getUntrackedParameter<std::string>("L1GlobalReadoutRecord", "gtDigis")),
0038 l1GTReadoutRecToken_(consumes<L1MuGMTReadoutCollection>(l1GTReadoutRecTag_)),
0039 l1GTReadoutToken_(consumes<L1GlobalTriggerReadoutRecord>(l1GTReadoutRecTag_)) {
0040
0041 }
0042
0043
0044
0045
0046
0047
0048 bool EcalExclusiveTrigFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0049
0050 const Handle<L1MuGMTReadoutCollection>& gmtrc_handle = iEvent.getHandle(l1GTReadoutRecToken_);
0051 L1MuGMTReadoutCollection const* gmtrc = gmtrc_handle.product();
0052 if (!(gmtrc_handle.isValid())) {
0053 LogWarning("EcalExclusiveTrigFilter") << "l1MuGMTReadoutCollection"
0054 << " not available";
0055
0056 }
0057
0058
0059 const Handle<L1GlobalTriggerReadoutRecord>& L1GTRR = iEvent.getHandle(l1GTReadoutToken_);
0060 bool isEcalL1 = false;
0061 const unsigned int sizeOfDecisionWord(L1GTRR->decisionWord().size());
0062 if (!(L1GTRR.isValid())) {
0063 LogWarning("EcalExclusiveTrigFilter") << l1GTReadoutRecTag_ << " not available";
0064 } else if (sizeOfDecisionWord < 128) {
0065 LogWarning("EcalExclusiveTrigFilter")
0066 << "size of L1 decisionword is " << sizeOfDecisionWord << "; L1 Ecal triggering bits not available";
0067 } else {
0068 l1Names_.resize(sizeOfDecisionWord);
0069 l1Accepts_.resize(sizeOfDecisionWord);
0070 for (unsigned int i = 0; i != sizeOfDecisionWord; ++i) {
0071 l1Accepts_[i] = 0;
0072 l1Names_[i] = "NameNotAvailable";
0073 }
0074 for (unsigned int i = 0; i != sizeOfDecisionWord; ++i) {
0075 if (L1GTRR->decisionWord()[i]) {
0076 l1Accepts_[i]++;
0077 }
0078 }
0079
0080 if (l1Accepts_[14] || l1Accepts_[15] || l1Accepts_[16] || l1Accepts_[17] || l1Accepts_[18] || l1Accepts_[19] ||
0081 l1Accepts_[20])
0082 isEcalL1 = true;
0083 if (l1Accepts_[73] || l1Accepts_[74] || l1Accepts_[75] || l1Accepts_[76] || l1Accepts_[77] || l1Accepts_[78])
0084 isEcalL1 = true;
0085 }
0086
0087 bool isRPCL1 = false;
0088 bool isDTL1 = false;
0089 bool isCSCL1 = false;
0090 bool isHCALL1 = false;
0091
0092 std::vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
0093 std::vector<L1MuGMTReadoutRecord>::const_iterator igmtrr;
0094
0095 for (igmtrr = gmt_records.begin(); igmtrr != gmt_records.end(); igmtrr++) {
0096 std::vector<L1MuRegionalCand>::const_iterator iter1;
0097 std::vector<L1MuRegionalCand> rmc;
0098
0099
0100 int idt = 0;
0101 rmc = igmtrr->getDTBXCands();
0102 for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
0103 if (!(*iter1).empty()) {
0104 idt++;
0105 }
0106 }
0107
0108 if (igmtrr->getBxInEvent() == 0 && idt > 0)
0109 isDTL1 = true;
0110
0111
0112 int irpcb = 0;
0113 rmc = igmtrr->getBrlRPCCands();
0114 for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
0115 if (!(*iter1).empty()) {
0116 irpcb++;
0117 }
0118 }
0119
0120 if (igmtrr->getBxInEvent() == 0 && irpcb > 0)
0121 isRPCL1 = true;
0122
0123
0124 int icsc = 0;
0125 rmc = igmtrr->getCSCCands();
0126 for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
0127 if (!(*iter1).empty()) {
0128 icsc++;
0129 }
0130 }
0131 if (igmtrr->getBxInEvent() == 0 && icsc > 0)
0132 isCSCL1 = true;
0133 }
0134
0135 L1GlobalTriggerReadoutRecord const* gtrr = L1GTRR.product();
0136
0137 for (int ibx = -1; ibx <= 1; ibx++) {
0138 bool hcal_top = false;
0139 bool hcal_bot = false;
0140 const L1GtPsbWord psb = gtrr->gtPsbWord(0xbb0d, ibx);
0141 std::vector<int> valid_phi;
0142 if ((psb.aData(4) & 0x3f) >= 1) {
0143 valid_phi.push_back((psb.aData(4) >> 10) & 0x1f);
0144 }
0145 if ((psb.bData(4) & 0x3f) >= 1) {
0146 valid_phi.push_back((psb.bData(4) >> 10) & 0x1f);
0147 }
0148 if ((psb.aData(5) & 0x3f) >= 1) {
0149 valid_phi.push_back((psb.aData(5) >> 10) & 0x1f);
0150 }
0151 if ((psb.bData(5) & 0x3f) >= 1) {
0152 valid_phi.push_back((psb.bData(5) >> 10) & 0x1f);
0153 }
0154 std::vector<int>::const_iterator iphi;
0155 for (iphi = valid_phi.begin(); iphi != valid_phi.end(); iphi++) {
0156 if (*iphi < 9)
0157 hcal_top = true;
0158 if (*iphi > 8)
0159 hcal_bot = true;
0160 }
0161 if (ibx == 0 && hcal_top && hcal_bot)
0162 isHCALL1 = true;
0163 }
0164
0165 edm::LogVerbatim("EcalTools") << "**** Trigger Source ****";
0166 if (isDTL1)
0167 edm::LogVerbatim("EcalTools") << "DT";
0168 if (isRPCL1)
0169 edm::LogVerbatim("EcalTools") << "RPC";
0170 if (isCSCL1)
0171 edm::LogVerbatim("EcalTools") << "CSC";
0172 if (isHCALL1)
0173 edm::LogVerbatim("EcalTools") << "HCAL";
0174 if (isEcalL1)
0175 edm::LogVerbatim("EcalTools") << "ECAL";
0176 edm::LogVerbatim("EcalTools") << "************************";
0177
0178 return (isEcalL1 && !isDTL1 && !isRPCL1 && !isCSCL1 && !isHCALL1);
0179 }