Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:32

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