Back to home page

Project CMSSW displayed by LXR

 
 

    


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 // system include files
0011 #include <memory>
0012 
0013 // user include files
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   // ----------member data ---------------------------
0041   CSCSectorReceiverLUT* srLUTs_[5];
0042 };
0043 //
0044 // constants, enums and typedefs
0045 //
0046 
0047 //
0048 // static data member definitions
0049 //
0050 
0051 //
0052 // constructors and destructor
0053 //
0054 LCTPrinter::LCTPrinter(const edm::ParameterSet& iConfig)
0055 
0056 {
0057   //now do what ever initialization is needed
0058 
0059   int endcap = 1, sector = 1;  // assume SR LUTs are all same for every sector in either of endcaps
0060   bool TMB07 = true;           // specific TMB firmware
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   // do anything here that needs to be done at desctruction time
0077   // (e.g. close files, deallocate resources etc.)
0078 }
0079 
0080 //
0081 // member functions
0082 //
0083 
0084 // ------------ method called to for each event  ------------
0085 void LCTPrinter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0086   ///////////////////
0087   //Setup Stuff//////
0088   ///////////////////
0089 
0090   std::vector<csctf::TrackStub> stubs;
0091   std::vector<csctf::TrackStub>::const_iterator stub;
0092 
0093   //MuonDigiCollection<CSCDetId,CSCCorrelatedLCTDigi>    "csctfunpacker"          ""        "CsctfFilter"
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       //int endcap  = (*lctDigiColl).first.endcap()-1;
0103       int station = (*lctDigiColl).first.station() - 1;
0104       //int sector  = (*lctDigiColl).first.triggerSector()-1;
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   //Analysis////
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 // ------------ method called once each job just before starting event loop  ------------
0158 void LCTPrinter::beginJob() {}
0159 
0160 // ------------ method called once each job just after ending the event loop  ------------
0161 void LCTPrinter::endJob() {}
0162 
0163 //define this as a plug-in
0164 DEFINE_FWK_MODULE(LCTPrinter);