File indexing completed on 2024-04-06 12:19:33
0001 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h"
0002 #include "DataFormats/L1CSCTrackFinder/interface/TrackStub.h" //
0003 #include "DataFormats/L1CSCTrackFinder/interface/CSCTriggerContainer.h"
0004 #include "DataFormats/MuonDetId/interface/CSCTriggerNumbering.h"
0005 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0006 #include "L1Trigger/CSCTrackFinder/interface/CSCTrackFinderDataTypes.h"
0007
0008 #include <iostream>
0009
0010
0011 #include <memory>
0012
0013
0014 #include "FWCore/Framework/interface/Frameworkfwd.h"
0015 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0016
0017 #include "FWCore/Framework/interface/Event.h"
0018 #include "FWCore/Framework/interface/MakerMacros.h"
0019
0020 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0021 #include "FWCore/ServiceRegistry/interface/Service.h"
0022
0023 #include "L1Trigger/CSCTrackFinder/interface/CSCSectorReceiverLUT.h"
0024
0025 #include "TH1F.h"
0026
0027 using namespace std;
0028 using namespace edm;
0029
0030 class LCTPrinter : public edm::one::EDAnalyzer<> {
0031 public:
0032 explicit LCTPrinter(const edm::ParameterSet&);
0033 ~LCTPrinter();
0034
0035 private:
0036 virtual void beginJob();
0037 virtual void analyze(const edm::Event&, const edm::EventSetup&);
0038 virtual void endJob();
0039
0040
0041 CSCSectorReceiverLUT* srLUTs_[5];
0042 };
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054 LCTPrinter::LCTPrinter(const edm::ParameterSet& iConfig)
0055
0056 {
0057
0058
0059 int endcap = 1, sector = 1;
0060 bool TMB07 = true;
0061
0062 edm::ParameterSet srLUTset;
0063 srLUTset.addUntrackedParameter<bool>("ReadLUTs", false);
0064 srLUTset.addUntrackedParameter<bool>("Binary", false);
0065 srLUTset.addUntrackedParameter<std::string>("LUTPath", "./");
0066 for (int station = 1, fpga = 0; station <= 4 && fpga < 5; station++) {
0067 if (station == 1)
0068 for (int subSector = 0; subSector < 2 && fpga < 5; subSector++)
0069 srLUTs_[fpga++] = new CSCSectorReceiverLUT(endcap, sector, subSector + 1, station, srLUTset, TMB07);
0070 else
0071 srLUTs_[fpga++] = new CSCSectorReceiverLUT(endcap, sector, 0, station, srLUTset, TMB07);
0072 }
0073 }
0074
0075 LCTPrinter::~LCTPrinter() {
0076
0077
0078 }
0079
0080
0081
0082
0083
0084
0085 void LCTPrinter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0086
0087
0088
0089
0090 std::vector<csctf::TrackStub> stubs;
0091 std::vector<csctf::TrackStub>::const_iterator stub;
0092
0093
0094 edm::Handle<CSCCorrelatedLCTDigiCollection> lctDigiColls;
0095 iEvent.getByLabel("csctfunpacker", lctDigiColls);
0096 CSCCorrelatedLCTDigiCollection::DigiRangeIterator lctDigiColl;
0097 for (lctDigiColl = lctDigiColls->begin(); lctDigiColl != lctDigiColls->end(); lctDigiColl++) {
0098 CSCCorrelatedLCTDigiCollection::const_iterator lctDigi = (*lctDigiColl).second.first;
0099 CSCCorrelatedLCTDigiCollection::const_iterator lctDigiEnd = (*lctDigiColl).second.second;
0100
0101 for (; lctDigi != lctDigiEnd; lctDigi++) {
0102
0103 int station = (*lctDigiColl).first.station() - 1;
0104
0105 int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*lctDigiColl).first);
0106 int cscId = (*lctDigiColl).first.triggerCscId() - 1;
0107 int fpga = (subSector ? subSector - 1 : station + 1);
0108
0109 lclphidat lclPhi;
0110 gblphidat gblPhi;
0111 gbletadat gblEta;
0112
0113 try {
0114 lclPhi = srLUTs_[fpga]->localPhi(
0115 lctDigi->getStrip(), lctDigi->getPattern(), lctDigi->getQuality(), lctDigi->getBend());
0116 } catch (...) {
0117 bzero(&lclPhi, sizeof(lclPhi));
0118 std::cout << "Bad local phi!" << std::endl;
0119 }
0120 try {
0121 gblPhi = srLUTs_[fpga]->globalPhiME(lclPhi.phi_local, lctDigi->getKeyWG(), cscId + 1);
0122 } catch (...) {
0123 bzero(&gblPhi, sizeof(gblPhi));
0124 std::cout << "Bad global phi!" << std::endl;
0125 }
0126 try {
0127 gblEta = srLUTs_[fpga]->globalEtaME(lclPhi.phi_bend_local, lclPhi.phi_local, lctDigi->getKeyWG(), cscId + 1);
0128 } catch (...) {
0129 bzero(&gblEta, sizeof(gblEta));
0130 std::cout << "Bad global eta!" << std::endl;
0131 }
0132
0133 csctf::TrackStub theStub((*lctDigi), (*lctDigiColl).first);
0134 theStub.setPhiPacked(gblPhi.global_phi);
0135 theStub.setEtaPacked(gblEta.global_eta);
0136
0137 stubs.push_back(theStub);
0138 }
0139 }
0140
0141
0142
0143
0144
0145 for (stub = stubs.begin(); stub != stubs.end(); stub++) {
0146 stub->print();
0147 std::cout << "Endcap: " << stub->endcap() << " Station: " << stub->station() << " Sector: " << stub->sector()
0148 << " Ring: " << CSCDetId(stub->getDetId()).ring() << " SubSector: " << stub->subsector()
0149 << " CscId: " << stub->cscid() << " ChamberId: " << CSCDetId(stub->getDetId()).chamber()
0150 << " TriggerChamberId: " << CSCTriggerNumbering::triggerCscIdFromLabels(stub->getDetId())
0151 << " Bx: " << stub->BX() << std::endl;
0152 std::cout << "Phi Packed: " << stub->phiPacked() << std::endl;
0153 std::cout << "Eta Packed: " << stub->etaPacked() << std::endl;
0154 }
0155 }
0156
0157
0158 void LCTPrinter::beginJob() {}
0159
0160
0161 void LCTPrinter::endJob() {}
0162
0163
0164 DEFINE_FWK_MODULE(LCTPrinter);