File indexing completed on 2024-04-06 12:19:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "L1Trigger/GlobalMuonTrigger/test/L1MuGMTDump.h"
0017
0018
0019
0020
0021
0022 #include <iostream>
0023 #include <iomanip>
0024 #include <vector>
0025 #include <cmath>
0026
0027
0028
0029
0030
0031 #include "FWCore/Framework/interface/Frameworkfwd.h"
0032 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0033 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
0034 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0035
0036 using namespace std;
0037
0038
0039
0040
0041 L1MuGMTDump::L1MuGMTDump(const edm::ParameterSet& ps) {
0042 m_inputTag = ps.getUntrackedParameter<edm::InputTag>("GMTInputTag", edm::InputTag("gmt"));
0043 }
0044
0045
0046
0047
0048 void L1MuGMTDump::endJob() {}
0049
0050
0051
0052
0053
0054 void L1MuGMTDump::analyze(const edm::Event& e, const edm::EventSetup& es) {
0055
0056
0057
0058 runn = e.id().run();
0059 eventn = e.id().event();
0060
0061 edm::LogVerbatim("GMTDump") << "run: " << runn << ", event: " << eventn << endl;
0062
0063
0064
0065 edm::Handle<edm::SimVertexContainer> simvertices_handle;
0066 e.getByLabel("g4SimHits", simvertices_handle);
0067 if (simvertices_handle.isValid()) {
0068 edm::SimVertexContainer const* simvertices = simvertices_handle.product();
0069
0070 edm::Handle<edm::SimTrackContainer> simtracks_handle;
0071 e.getByLabel("g4SimHits", simtracks_handle);
0072 if (simtracks_handle.isValid()) {
0073 edm::SimTrackContainer const* simtracks = simtracks_handle.product();
0074
0075 edm::SimTrackContainer::const_iterator isimtr;
0076 int igen = 0;
0077 for (isimtr = simtracks->begin(); isimtr != simtracks->end(); isimtr++) {
0078 if (abs((*isimtr).type()) != 13 || igen >= MAXGEN)
0079 continue;
0080 pxgen[igen] = (*isimtr).momentum().px();
0081 pygen[igen] = (*isimtr).momentum().py();
0082 pzgen[igen] = (*isimtr).momentum().pz();
0083 ptgen[igen] = (*isimtr).momentum().pt();
0084 etagen[igen] = (*isimtr).momentum().eta();
0085 phigen[igen] = (*isimtr).momentum().phi() > 0 ? (*isimtr).momentum().phi()
0086 : (*isimtr).momentum().phi() + 2 * 3.14159265359;
0087 chagen[igen] = (*isimtr).type() > 0 ? -1 : 1;
0088 vxgen[igen] = (*simvertices)[(*isimtr).vertIndex()].position().x();
0089 vygen[igen] = (*simvertices)[(*isimtr).vertIndex()].position().y();
0090 vzgen[igen] = (*simvertices)[(*isimtr).vertIndex()].position().z();
0091 igen++;
0092 }
0093 ngen = igen;
0094 } else {
0095 edm::LogWarning("BlockMissing") << "Simulated track block missing" << endl;
0096 ngen = 0;
0097 }
0098 } else {
0099 edm::LogWarning("BlockMissing") << "Simulated vertex block missing" << endl;
0100 ngen = 0;
0101 }
0102
0103
0104
0105 edm::Handle<L1MuGMTReadoutCollection> gmtrc_handle;
0106 e.getByLabel(m_inputTag.label(), gmtrc_handle);
0107 L1MuGMTReadoutCollection const* gmtrc = gmtrc_handle.product();
0108
0109 int idt = 0;
0110 int icsc = 0;
0111 int irpcb = 0;
0112 int irpcf = 0;
0113 int igmt = 0;
0114 vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
0115 vector<L1MuGMTReadoutRecord>::const_iterator igmtrr;
0116
0117 for (igmtrr = gmt_records.begin(); igmtrr != gmt_records.end(); igmtrr++) {
0118 vector<L1MuRegionalCand>::const_iterator iter1;
0119 vector<L1MuRegionalCand> rmc;
0120 ;
0121
0122
0123
0124
0125
0126 rmc = igmtrr->getDTBXCands();
0127 for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
0128 if (idt < MAXDTBX && !(*iter1).empty()) {
0129 bxd[idt] = (*iter1).bx();
0130 ptd[idt] = (*iter1).ptValue();
0131 chad[idt] = (*iter1).chargeValue();
0132 etad[idt] = (*iter1).etaValue();
0133 etafined[idt] = 0;
0134 phid[idt] = (*iter1).phiValue();
0135 quald[idt] = (*iter1).quality();
0136 tclassd[idt] = 0;
0137 ntsd[idt] = 0;
0138
0139 idt++;
0140 }
0141 }
0142
0143
0144
0145
0146
0147 rmc = igmtrr->getCSCCands();
0148 for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
0149 if (icsc < MAXCSC && !(*iter1).empty()) {
0150 bxc[icsc] = (*iter1).bx();
0151 ptc[icsc] = (*iter1).ptValue();
0152 chac[icsc] = (*iter1).chargeValue();
0153 etac[icsc] = (*iter1).etaValue();
0154 phic[icsc] = (*iter1).phiValue();
0155 qualc[icsc] = (*iter1).quality();
0156
0157 ntsc[icsc] = 0;
0158 rankc[icsc] = 0;
0159
0160 icsc++;
0161 }
0162 }
0163
0164
0165
0166
0167 rmc = igmtrr->getBrlRPCCands();
0168 for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
0169 if (irpcb < MAXRPC && !(*iter1).empty()) {
0170 bxrb[irpcb] = (*iter1).bx();
0171 ptrb[irpcb] = (*iter1).ptValue();
0172 charb[irpcb] = (*iter1).chargeValue();
0173 etarb[irpcb] = (*iter1).etaValue();
0174 phirb[irpcb] = (*iter1).phiValue();
0175 qualrb[irpcb] = (*iter1).quality();
0176
0177 irpcb++;
0178 }
0179 }
0180
0181
0182
0183
0184 rmc = igmtrr->getFwdRPCCands();
0185 for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
0186 if (irpcf < MAXRPC && !(*iter1).empty()) {
0187 bxrf[irpcf] = (*iter1).bx();
0188 ptrf[irpcf] = (*iter1).ptValue();
0189 charf[irpcf] = (*iter1).chargeValue();
0190 etarf[irpcf] = (*iter1).etaValue();
0191 phirf[irpcf] = (*iter1).phiValue();
0192 qualrf[irpcf] = (*iter1).quality();
0193
0194 irpcf++;
0195 }
0196 }
0197
0198
0199
0200
0201
0202 vector<L1MuGMTExtendedCand>::const_iterator gmt_iter;
0203 vector<L1MuGMTExtendedCand> exc = igmtrr->getGMTCands();
0204 for (gmt_iter = exc.begin(); gmt_iter != exc.end(); gmt_iter++) {
0205 if (igmt < MAXGMT && !(*gmt_iter).empty()) {
0206 bxg[igmt] = (*gmt_iter).bx();
0207 ptg[igmt] = (*gmt_iter).ptValue();
0208 chag[igmt] = (*gmt_iter).charge();
0209 etag[igmt] = (*gmt_iter).etaValue();
0210 phig[igmt] = (*gmt_iter).phiValue();
0211 qualg[igmt] = (*gmt_iter).quality();
0212 detg[igmt] = (*gmt_iter).detector();
0213 rankg[igmt] = (*gmt_iter).rank();
0214 isolg[igmt] = (*gmt_iter).isol();
0215 mipg[igmt] = (*gmt_iter).mip();
0216 int data = (*gmt_iter).getDataWord();
0217 datawordg[igmt] = data;
0218
0219 idxRPCb[igmt] = -1;
0220 idxRPCf[igmt] = -1;
0221 idxDTBX[igmt] = -1;
0222 idxCSC[igmt] = -1;
0223
0224 if ((*gmt_iter).isMatchedCand() || (*gmt_iter).isRPC()) {
0225 if ((*gmt_iter).isFwd()) {
0226 idxRPCf[igmt] = (*gmt_iter).getRPCIndex();
0227 } else {
0228 idxRPCb[igmt] = (*gmt_iter).getRPCIndex();
0229 }
0230 }
0231
0232 if ((*gmt_iter).isMatchedCand() || (!(*gmt_iter).isRPC())) {
0233 if ((*gmt_iter).isFwd())
0234 idxCSC[igmt] = (*gmt_iter).getDTCSCIndex();
0235 else
0236 idxDTBX[igmt] = (*gmt_iter).getDTCSCIndex();
0237 }
0238 igmt++;
0239 }
0240 }
0241 }
0242 ndt = idt;
0243 ncsc = icsc;
0244 nrpcb = irpcb;
0245 nrpcf = irpcf;
0246 ngmt = igmt;
0247
0248
0249 edm::LogVerbatim("GMTDump") << "************** GMTDump from " << m_inputTag.label() << ": *************************";
0250
0251
0252
0253 edm::LogVerbatim("GMTDump") << "Number of muons generated: " << ngen << endl;
0254 edm::LogVerbatim("GMTDump") << "Generated muons:" << endl;
0255 for (int igen = 0; igen < ngen; igen++) {
0256 edm::LogVerbatim("GMTDump") << setiosflags(ios::showpoint | ios::fixed) << setw(2) << igen + 1 << " : "
0257 << "pt = " << setw(5) << setprecision(1) << ptgen[igen] << " GeV "
0258 << "charge = " << setw(2) << chagen[igen] << " "
0259 << "eta = " << setw(6) << setprecision(3) << etagen[igen] << " "
0260 << "phi = " << setw(5) << setprecision(3) << phigen[igen] << " rad "
0261 << "vx = " << setw(5) << setprecision(3) << vxgen[igen] << " cm "
0262 << "vy = " << setw(5) << setprecision(3) << vygen[igen] << " cm "
0263 << "vz = " << setw(5) << setprecision(3) << vzgen[igen] << " cm " << endl;
0264 }
0265
0266
0267
0268
0269 edm::LogVerbatim("GMTDump") << "Number of muons found by the L1 DTBX TRIGGER: " << ndt << endl;
0270 edm::LogVerbatim("GMTDump") << "L1 DT TRIGGER muons: " << endl;
0271 for (idt = 0; idt < ndt; idt++) {
0272 edm::LogVerbatim("GMTDump") << setiosflags(ios::showpoint | ios::fixed) << setw(2) << idt + 1 << " : "
0273 << "pt = " << setw(5) << setprecision(1) << ptd[idt] << " GeV "
0274 << "charge = " << setw(2) << chad[idt] << " "
0275 << "eta = " << setw(6) << setprecision(3) << etad[idt] << " "
0276 << "phi = " << setw(5) << setprecision(3) << phid[idt] << " rad "
0277 << "quality = " << setw(1) << quald[idt] << " "
0278 << "bx = " << setw(2) << bxd[idt] << endl;
0279 }
0280
0281
0282
0283
0284 edm::LogVerbatim("GMTDump") << "Number of muons found by the L1 CSC TRIGGER: " << ncsc << endl;
0285 edm::LogVerbatim("GMTDump") << "L1 CSC TRIGGER muons: " << endl;
0286 for (icsc = 0; icsc < ncsc; icsc++) {
0287 edm::LogVerbatim("GMTDump") << setiosflags(ios::showpoint | ios::fixed) << setw(2) << icsc + 1 << " : "
0288 << "pt = " << setw(5) << setprecision(1) << ptc[icsc] << " GeV "
0289 << "charge = " << setw(2) << chac[icsc] << " "
0290 << "eta = " << setw(6) << setprecision(3) << etac[icsc] << " "
0291 << "phi = " << setw(5) << setprecision(3) << phic[icsc] << " rad "
0292 << "quality = " << setw(1) << qualc[icsc] << " "
0293 << "bx = " << setw(2) << bxc[icsc] << endl;
0294 }
0295
0296
0297
0298
0299 edm::LogVerbatim("GMTDump") << "Number of muons found by the L1 RPCb TRIGGER: " << nrpcb << endl;
0300 edm::LogVerbatim("GMTDump") << "L1 RPCb TRIGGER muons: " << endl;
0301 for (irpcb = 0; irpcb < nrpcb; irpcb++) {
0302 edm::LogVerbatim("GMTDump") << setiosflags(ios::showpoint | ios::fixed) << setw(2) << irpcb + 1 << " : "
0303 << "pt = " << setw(5) << setprecision(1) << ptrb[irpcb] << " GeV "
0304 << "charge = " << setw(2) << charb[irpcb] << " "
0305 << "eta = " << setw(6) << setprecision(3) << etarb[irpcb] << " "
0306 << "phi = " << setw(5) << setprecision(3) << phirb[irpcb] << " rad "
0307 << "quality = " << setw(1) << qualrb[irpcb] << " "
0308 << "bx = " << setw(2) << bxrb[irpcb] << endl;
0309 }
0310
0311
0312
0313
0314 edm::LogVerbatim("GMTDump") << "Number of muons found by the L1 RPCf TRIGGER: " << nrpcf << endl;
0315 edm::LogVerbatim("GMTDump") << "L1 RPCf TRIGGER muons: " << endl;
0316 for (irpcf = 0; irpcf < nrpcf; irpcf++) {
0317 edm::LogVerbatim("GMTDump") << setiosflags(ios::showpoint | ios::fixed) << setw(2) << irpcf + 1 << " : "
0318 << "pt = " << setw(5) << setprecision(1) << ptrf[irpcf] << " GeV "
0319 << "charge = " << setw(2) << charf[irpcf] << " "
0320 << "eta = " << setw(6) << setprecision(3) << etarf[irpcf] << " "
0321 << "phi = " << setw(5) << setprecision(3) << phirf[irpcf] << " rad "
0322 << "quality = " << setw(1) << qualrf[irpcf] << " "
0323 << "bx = " << setw(2) << bxrf[irpcf] << endl;
0324 }
0325
0326
0327
0328
0329 edm::LogVerbatim("GMTDump") << "Number of muons found by the L1 Global Muon TRIGGER: " << ngmt << endl;
0330 edm::LogVerbatim("GMTDump") << "L1 GMT muons: " << endl;
0331 for (igmt = 0; igmt < ngmt; igmt++) {
0332 if (igmt == 4) {
0333 edm::LogVerbatim("GMTDump") << "Additional muon candidates" << endl;
0334 }
0335 edm::LogVerbatim("GMTDump") << setiosflags(ios::showpoint | ios::fixed) << setw(2) << igmt + 1 << " : "
0336 << "pt = " << setw(5) << setprecision(1) << ptg[igmt] << " GeV "
0337 << "charge = " << setw(2) << chag[igmt] << " "
0338 << "eta = " << setw(6) << setprecision(3) << etag[igmt] << " "
0339 << "phi = " << setw(5) << setprecision(3) << phig[igmt] << " rad "
0340 << "quality = " << setw(1) << qualg[igmt] << " "
0341 << "rank = " << setw(3) << rankg[igmt] << " "
0342 << "bx = " << setw(2) << bxg[igmt] << " "
0343 << "detectors = " << setw(2) << idxDTBX[igmt] << idxRPCb[igmt] << idxCSC[igmt]
0344 << idxRPCf[igmt] << endl;
0345 }
0346
0347 edm::LogVerbatim("GMTDump") << "**************************************************************";
0348 }
0349
0350
0351 DEFINE_FWK_MODULE(L1MuGMTDump);