Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:29

0001 #include "CSCTFSingleGen.h"
0002 
0003 //Framework stuff
0004 #include "DataFormats/Common/interface/Handle.h"
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 
0008 //Digi
0009 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h"
0010 #include "DataFormats/L1CSCTrackFinder/interface/TrackStub.h"
0011 
0012 //Digi collections
0013 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h"
0014 #include "DataFormats/L1CSCTrackFinder/interface/CSCTriggerContainer.h"
0015 
0016 //Unique key
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   // Edges of the time window, which LCTs are put into (unlike tracks, which are always centred around 0):
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;  //pset.getUntrackedParameter<int>("strip", -1);
0036   wireGroup = pset.getUntrackedParameter<int>("wireGroup", 48);
0037   pattern = pset.getUntrackedParameter<int>("pattern", 4);
0038 
0039   // As we use standard CSC digi containers, we have to initialize mapping:
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   //  produces<CSCTriggerContainer<csctf::TrackStub> >("DT");
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   // create the collection of CSC wire and strip digis as well as of DT stubs, which we receive from DTTF
0075   auto LCTProduct = std::make_unique<CSCCorrelatedLCTDigiCollection>();
0076   //  auto dtProduct = std::make_unique<CSCTriggerContainer<csctf::TrackStub>>();
0077 
0078   for (unsigned int tbin = 6; tbin < 7; tbin++) {
0079     //for(unsigned int FPGA=0; FPGA<5; FPGA++)
0080     for (unsigned int FPGA = 0; FPGA < 1; FPGA++)
0081       //for(unsigned int MPClink=1; MPClink<4; ++MPClink){
0082       for (unsigned int MPClink = 1; MPClink < 2; ++MPClink) {
0083         try {
0084           CSCDetId id = mapping->detId(endcap, station, sector, subSector, cscId, 0);
0085           // corrlcts now have no layer associated with them
0086           LCTProduct->insertDigi(id,
0087                                  CSCCorrelatedLCTDigi(0,
0088                                                       1,
0089                                                       15,
0090                                                       wireGroup,
0091                                                       strip,
0092                                                       pattern,
0093                                                       1,  //l_r
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       }  // MPC link loop
0107 
0108     //         std::vector<CSCSP_MBblock> mbStubs = sp->record(tbin).mbStubs();
0109     //         for(std::vector<CSCSP_MBblock>::const_iterator iter=mbStubs.begin(); iter!=mbStubs.end(); iter++){
0110     //           int endcap, sector;
0111     //           if( slot2sector[sp->header().slot()] ){
0112     //             endcap = slot2sector[sp->header().slot()]/7 + 1;
0113     //             sector = slot2sector[sp->header().slot()];
0114     //             if( sector>6 ) sector -= 6;
0115     //           } else {
0116     //             endcap = (sp->header().endcap()?1:2);
0117     //             sector =  sp->header().sector();
0118     //           }
0119     //           const unsigned int csc2dt[6][2] = {{2,3},{4,5},{6,7},{8,9},{10,11},{12,1}};
0120     //           DTChamberId id((endcap==1?2:-2),1, csc2dt[sector-1][iter->id()-1]);
0121     //           CSCCorrelatedLCTDigi base(0,iter->vq(),iter->quality(),iter->cal(),iter->flag(),iter->bc0(),iter->phi_bend(),tbin+(central_lct_bx-central_sp_bx),iter->id(),iter->bxn(),iter->timingError(),iter->BXN());
0122     //           csctf::TrackStub dtStub(base,id,iter->phi(),0);
0123     //           dtProduct->push_back(dtStub);
0124     //         }
0125 
0126   }  // tbin loop
0127 
0128   strip++;
0129 
0130   //e.put(std::move(dtProduct),"DT");
0131   e.put(std::move(LCTProduct));  // put processed lcts into the event.
0132 }
0133 #include "FWCore/Framework/interface/MakerMacros.h"
0134 DEFINE_FWK_MODULE(CSCTFSingleGen);