Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-08-30 22:38:50

0001 #include "EventFilter/L1TRawToDigi/plugins/PackerFactory.h"
0002 #include "EventFilter/L1TRawToDigi/plugins/PackingSetupFactory.h"
0003 #include "EventFilter/L1TRawToDigi/plugins/UnpackerFactory.h"
0004 
0005 #include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/MuonPacker.h"
0006 #include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/MuonUnpacker.h"
0007 #include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/EGammaUnpacker.h"
0008 #include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/EtSumUnpacker.h"
0009 #include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/JetUnpacker.h"
0010 #include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/TauUnpacker.h"
0011 
0012 #include "GTSetup.h"
0013 
0014 namespace l1t {
0015   namespace stage2 {
0016     std::unique_ptr<PackerTokens> GTSetup::registerConsumes(const edm::ParameterSet& cfg, edm::ConsumesCollector& cc) {
0017       return std::unique_ptr<PackerTokens>(new GTTokens(cfg, cc));
0018     }
0019 
0020     void GTSetup::fillDescription(edm::ParameterSetDescription& desc) {
0021       desc.addOptional<edm::InputTag>("GtInputTag")->setComment("for stage2");
0022       desc.addOptional<edm::InputTag>("ExtInputTag")->setComment("for stage2");
0023       desc.addOptional<edm::InputTag>("MuonInputTag")->setComment("for stage2");
0024       desc.addOptional<edm::InputTag>("ShowerInputTag")->setComment("for Run3");
0025       desc.addOptional<edm::InputTag>("EGammaInputTag")->setComment("for stage2");
0026       desc.addOptional<edm::InputTag>("JetInputTag")->setComment("for stage2");
0027       desc.addOptional<edm::InputTag>("TauInputTag")->setComment("for stage2");
0028       desc.addOptional<edm::InputTag>("EtSumInputTag")->setComment("for stage2");
0029     }
0030 
0031     PackerMap GTSetup::getPackers(int fed, unsigned int fw) {
0032       PackerMap res;
0033 
0034       if ((fed == 1404) || (fed == 1405)) {
0035         // Use board id 1 for packing
0036         //fed id 1404 corresponds to the production crate, 1405 to the test crate
0037         auto gt_muon_packer =
0038             static_pointer_cast<l1t::stage2::GTMuonPacker>(PackerFactory::get()->make("stage2::GTMuonPacker"));
0039         gt_muon_packer->setFed(fed);
0040         gt_muon_packer->setFwVersion(fw);
0041         res[{1, 1}] = {gt_muon_packer,
0042                        PackerFactory::get()->make("stage2::GTEGammaPacker"),
0043                        PackerFactory::get()->make("stage2::GTEtSumPacker"),
0044                        PackerFactory::get()->make("stage2::GTJetPacker"),
0045                        PackerFactory::get()->make("stage2::GTTauPacker"),
0046                        PackerFactory::get()->make("stage2::GlobalAlgBlkPacker"),
0047                        PackerFactory::get()->make("stage2::GlobalExtBlkPacker")};
0048       }
0049 
0050       return res;
0051     }
0052 
0053     void GTSetup::registerProducts(edm::ProducesCollector prod) {
0054       prod.produces<MuonBxCollection>("Muon");
0055       prod.produces<MuonShowerBxCollection>("MuonShower");
0056       prod.produces<EGammaBxCollection>("EGamma");
0057       prod.produces<EtSumBxCollection>("EtSum");
0058       prod.produces<JetBxCollection>("Jet");
0059       prod.produces<TauBxCollection>("Tau");
0060       prod.produces<GlobalAlgBlkBxCollection>();
0061       prod.produces<GlobalExtBlkBxCollection>();
0062       for (int i = 2; i < 7; ++i) {  // Collections from boards 2-6
0063         prod.produces<MuonBxCollection>("Muon" + std::to_string(i));
0064         prod.produces<MuonShowerBxCollection>("MuonShower" + std::to_string(i));
0065         prod.produces<EGammaBxCollection>("EGamma" + std::to_string(i));
0066         prod.produces<EtSumBxCollection>("EtSum" + std::to_string(i));
0067         prod.produces<JetBxCollection>("Jet" + std::to_string(i));
0068         prod.produces<TauBxCollection>("Tau" + std::to_string(i));
0069       }
0070     }
0071 
0072     std::unique_ptr<UnpackerCollections> GTSetup::getCollections(edm::Event& e) {
0073       return std::unique_ptr<UnpackerCollections>(new GTCollections(e));
0074     }
0075 
0076     UnpackerMap GTSetup::getUnpackers(int fed, int board, int amc, unsigned int fw) {
0077       auto muon_unp =
0078           static_pointer_cast<l1t::stage2::MuonUnpacker>(UnpackerFactory::get()->make("stage2::MuonUnpacker"));
0079       auto egamma_unp =
0080           static_pointer_cast<l1t::stage2::EGammaUnpacker>(UnpackerFactory::get()->make("stage2::EGammaUnpacker"));
0081       auto etsum_unp =
0082           static_pointer_cast<l1t::stage2::EtSumUnpacker>(UnpackerFactory::get()->make("stage2::EtSumUnpacker"));
0083       auto jet_unp = static_pointer_cast<l1t::stage2::JetUnpacker>(UnpackerFactory::get()->make("stage2::JetUnpacker"));
0084       auto tau_unp = static_pointer_cast<l1t::stage2::TauUnpacker>(UnpackerFactory::get()->make("stage2::TauUnpacker"));
0085 
0086       if (fw >= 0x10f2) {
0087         etsum_unp = static_pointer_cast<l1t::stage2::EtSumUnpacker>(
0088             UnpackerFactory::get()->make("stage2::EtSumUnpacker_0x10010057"));
0089       }
0090 
0091       auto alg_unp = UnpackerFactory::get()->make("stage2::GlobalAlgBlkUnpacker");
0092       auto ext_unp = UnpackerFactory::get()->make("stage2::GlobalExtBlkUnpacker");
0093 
0094       muon_unp->setAlgoVersion(fw);
0095       muon_unp->setFedNumber(fed);
0096 
0097       muon_unp->setMuonCopy(amc - 1);
0098       egamma_unp->setEGammaCopy(amc - 1);
0099       etsum_unp->setEtSumCopy(amc - 1);
0100       jet_unp->setJetCopy(amc - 1);
0101       tau_unp->setTauCopy(amc - 1);
0102 
0103       UnpackerMap res;
0104 
0105       if ((fed == 1404) || (fed == 1405)) {
0106         // From the rx buffers
0107         // fed id 1404 corresponds to the production crate, 1405 to the test crate
0108         res[0] = muon_unp;
0109         res[2] = muon_unp;
0110         res[4] = muon_unp;
0111         res[6] = muon_unp;
0112         res[8] = egamma_unp;
0113         res[10] = egamma_unp;
0114         res[12] = jet_unp;
0115         res[14] = jet_unp;
0116         res[16] = tau_unp;
0117         res[18] = tau_unp;
0118         res[20] = etsum_unp;
0119 
0120         if (amc == 1) {  // only unpack first uGT board for the external signal inputs (single copy)
0121           res[24] = ext_unp;
0122           //res[22] = empty link no data
0123           res[26] = ext_unp;
0124           res[28] = ext_unp;
0125           res[30] = ext_unp;
0126         }
0127 
0128         //From tx buffers
0129         res[33] = alg_unp;
0130         res[35] = alg_unp;
0131         res[37] = alg_unp;
0132         res[39] = alg_unp;
0133         res[41] = alg_unp;
0134         res[43] = alg_unp;
0135         res[45] = alg_unp;
0136         res[47] = alg_unp;
0137         res[49] = alg_unp;
0138       }
0139 
0140       return res;
0141     }
0142   }  // namespace stage2
0143 }  // namespace l1t
0144 
0145 DEFINE_L1T_PACKING_SETUP(l1t::stage2::GTSetup);