Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:21:47

0001 /**
0002  *
0003  * Analyzer that writes LUTs.
0004  *
0005  *\author L. Gray (4/13/06)
0006  *
0007  *
0008  */
0009 
0010 #include <fstream>
0011 #include "FWCore/Framework/interface/EDAnalyzer.h"
0012 #include "FWCore/Framework/interface/Event.h"
0013 #include "DataFormats/Common/interface/Handle.h"
0014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0015 #include "FWCore/Framework/interface/EventSetup.h"
0016 #include "FWCore/Framework/interface/ESHandle.h"
0017 
0018 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
0019 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0020 
0021 #include "DataFormats/MuonDetId/interface/CSCTriggerNumbering.h"
0022 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0023 
0024 #include "DataFormats/L1CSCTrackFinder/interface/CSCBitWidths.h"
0025 #include "L1Trigger/CSCTrackFinder/interface/CSCTFPtLUT.h"
0026 
0027 #include "CondFormats/L1TObjects/interface/L1MuTriggerScales.h"
0028 #include "CondFormats/DataRecord/interface/L1MuTriggerScalesRcd.h"
0029 #include "CondFormats/L1TObjects/interface/L1MuTriggerPtScale.h"
0030 #include "CondFormats/DataRecord/interface/L1MuTriggerPtScaleRcd.h"
0031 
0032 #include "L1Trigger/CSCTrackFinder/test/analysis/CSCMakePTLUT.h"
0033 
0034 CSCMakePTLUT::CSCMakePTLUT(edm::ParameterSet const& conf) : myTF(0) {
0035   //writeLocalPhi = conf.getUntrackedParameter<bool>("WriteLocalPhi",true);
0036   station = conf.getUntrackedParameter<int>("Station", -1);
0037   sector = conf.getUntrackedParameter<int>("Sector", -1);
0038   endcap = conf.getUntrackedParameter<int>("Endcap", -1);
0039   binary = conf.getUntrackedParameter<bool>("BinaryOutput", true);
0040   LUTparam = conf.getParameter<edm::ParameterSet>("lutParam");
0041 
0042   //init Track Finder LUTs
0043   //  myTF = new CSCTFPtLUT(LUTparam);
0044 }
0045 
0046 CSCMakePTLUT::~CSCMakePTLUT() {
0047   if (myTF) {
0048     delete myTF;
0049     myTF = NULL;
0050   }
0051 }
0052 
0053 void CSCMakePTLUT::analyze(edm::Event const& e, edm::EventSetup const& iSetup) {
0054   edm::ESHandle<CSCGeometry> pDD;
0055   iSetup.get<MuonGeometryRecord>().get(pDD);
0056 
0057   edm::ESHandle<L1MuTriggerScales> scales;
0058   iSetup.get<L1MuTriggerScalesRcd>().get(scales);
0059 
0060   edm::ESHandle<L1MuTriggerPtScale> ptScale;
0061   iSetup.get<L1MuTriggerPtScaleRcd>().get(ptScale);
0062 
0063   myTF = new CSCTFPtLUT(LUTparam, scales.product(), ptScale.product());
0064 
0065   std::string filename = std::string("L1CSCPtLUT") + ((binary) ? std::string(".bin") : std::string(".dat"));
0066   std::ofstream L1CSCPtLUT(filename.c_str());
0067   for (int i = 0; i < 1 << CSCBitWidths::kPtAddressWidth; ++i) {
0068     unsigned short thedata = myTF->Pt(i).toint();
0069     if (binary)
0070       L1CSCPtLUT.write(reinterpret_cast<char*>(&thedata), sizeof(unsigned short));
0071     else
0072       L1CSCPtLUT << std::dec << thedata << std::endl;
0073   }
0074 }
0075 
0076 std::string CSCMakePTLUT::fileSuffix() const {
0077   std::string fileName = "";
0078   fileName += ((binary) ? ".bin" : ".dat");
0079   return fileName;
0080 }