File indexing completed on 2024-04-06 12:10:29
0001 #include "CSCTFSingleGen.h"
0002
0003
0004 #include "DataFormats/Common/interface/Handle.h"
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007
0008
0009 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h"
0010 #include "DataFormats/L1CSCTrackFinder/interface/TrackStub.h"
0011
0012
0013 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h"
0014 #include "DataFormats/L1CSCTrackFinder/interface/CSCTriggerContainer.h"
0015
0016
0017 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0018 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0019
0020 #include "CondFormats/CSCObjects/interface/CSCTriggerMappingFromFile.h"
0021 #include <sstream>
0022
0023 CSCTFSingleGen::CSCTFSingleGen(const edm::ParameterSet& pset) : edm::one::EDProducer<>(), mapping(0) {
0024 LogDebug("CSCTFSingleGen|ctor") << "Started ...";
0025
0026
0027 m_minBX = 3;
0028 m_maxBX = 9;
0029
0030 endcap = pset.getUntrackedParameter<int>("endcap", 1);
0031 sector = pset.getUntrackedParameter<int>("sector", 1);
0032 subSector = pset.getUntrackedParameter<int>("subSector", 0);
0033 station = pset.getUntrackedParameter<int>("station", 1);
0034 cscId = pset.getUntrackedParameter<int>("cscId", 5);
0035 strip = 0;
0036 wireGroup = pset.getUntrackedParameter<int>("wireGroup", 48);
0037 pattern = pset.getUntrackedParameter<int>("pattern", 4);
0038
0039
0040 std::string mappingFile = pset.getUntrackedParameter<std::string>("mappingFile", "");
0041 if (mappingFile.length()) {
0042 LogDebug("CSCTFSingleGen|ctor") << "Define ``mapping'' only if you want to screw up real geometry";
0043 mapping = new CSCTriggerMappingFromFile(mappingFile);
0044 } else {
0045 LogDebug("CSCTFSingleGen|ctor") << "Generating default hw<->geometry mapping";
0046 class M : public CSCTriggerSimpleMapping {
0047 void fill(void) {}
0048 };
0049 mapping = new M();
0050 for (int endcap = 1; endcap <= 2; endcap++)
0051 for (int station = 1; station <= 4; station++)
0052 for (int sector = 1; sector <= 6; sector++)
0053 for (int csc = 1; csc <= 9; csc++) {
0054 if (station == 1) {
0055 mapping->addRecord(endcap, station, sector, 1, csc, endcap, station, sector, 1, csc);
0056 mapping->addRecord(endcap, station, sector, 2, csc, endcap, station, sector, 2, csc);
0057 } else
0058 mapping->addRecord(endcap, station, sector, 0, csc, endcap, station, sector, 0, csc);
0059 }
0060 }
0061
0062 strip = 0;
0063
0064 produces<CSCCorrelatedLCTDigiCollection>();
0065
0066 }
0067
0068 CSCTFSingleGen::~CSCTFSingleGen() {
0069 if (mapping)
0070 delete mapping;
0071 }
0072
0073 void CSCTFSingleGen::produce(edm::Event& e, const edm::EventSetup& c) {
0074
0075 auto LCTProduct = std::make_unique<CSCCorrelatedLCTDigiCollection>();
0076
0077
0078 for (unsigned int tbin = 6; tbin < 7; tbin++) {
0079
0080 for (unsigned int FPGA = 0; FPGA < 1; FPGA++)
0081
0082 for (unsigned int MPClink = 1; MPClink < 2; ++MPClink) {
0083 try {
0084 CSCDetId id = mapping->detId(endcap, station, sector, subSector, cscId, 0);
0085
0086 LCTProduct->insertDigi(id,
0087 CSCCorrelatedLCTDigi(0,
0088 1,
0089 15,
0090 wireGroup,
0091 strip,
0092 pattern,
0093 1,
0094 tbin,
0095 MPClink,
0096 0,
0097 0,
0098 cscId));
0099 } catch (cms::Exception& e) {
0100 edm::LogInfo("CSCTFSingleGen|produce")
0101 << e.what() << "Not adding digi to collection in event "
0102 << " (endcap=" << endcap << ",station=" << station << ",sector=" << sector << ",subsector=" << subSector
0103 << ",cscid=" << cscId << ")";
0104 }
0105
0106 }
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126 }
0127
0128 strip++;
0129
0130
0131 e.put(std::move(LCTProduct));
0132 }
0133 #include "FWCore/Framework/interface/MakerMacros.h"
0134 DEFINE_FWK_MODULE(CSCTFSingleGen);