Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-28 04:19:19

0001 #include "L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFEProcessorSums.h"
0002 
0003 DEFINE_EDM_PLUGIN(HGCalVFEProcessorBaseFactory, HGCalVFEProcessorSums, "HGCalVFEProcessorSums");
0004 
0005 HGCalVFEProcessorSums::HGCalVFEProcessorSums(const edm::ParameterSet& conf) : HGCalVFEProcessorBase(conf) {
0006   vfeLinearizationSiImpl_ =
0007       std::make_unique<HGCalVFELinearizationImpl>(conf.getParameter<edm::ParameterSet>("linearizationCfg_si"));
0008   vfeLinearizationScImpl_ =
0009       std::make_unique<HGCalVFELinearizationImpl>(conf.getParameter<edm::ParameterSet>("linearizationCfg_sc"));
0010 
0011   vfeSummationImpl_ = std::make_unique<HGCalVFESummationImpl>(conf.getParameter<edm::ParameterSet>("summationCfg"));
0012 
0013   vfeCompressionLDMImpl_ =
0014       std::make_unique<HGCalVFECompressionImpl>(conf.getParameter<edm::ParameterSet>("compressionCfg_ldm"));
0015   vfeCompressionHDMImpl_ =
0016       std::make_unique<HGCalVFECompressionImpl>(conf.getParameter<edm::ParameterSet>("compressionCfg_hdm"));
0017 
0018   calibrationEE_ =
0019       std::make_unique<HGCalTriggerCellCalibration>(conf.getParameter<edm::ParameterSet>("calibrationCfg_ee"));
0020   calibrationHEsi_ =
0021       std::make_unique<HGCalTriggerCellCalibration>(conf.getParameter<edm::ParameterSet>("calibrationCfg_hesi"));
0022   calibrationHEsc_ =
0023       std::make_unique<HGCalTriggerCellCalibration>(conf.getParameter<edm::ParameterSet>("calibrationCfg_hesc"));
0024   calibrationNose_ =
0025       std::make_unique<HGCalTriggerCellCalibration>(conf.getParameter<edm::ParameterSet>("calibrationCfg_nose"));
0026 }
0027 
0028 void HGCalVFEProcessorSums::run(const HGCalDigiCollection& digiColl,
0029                                 l1t::HGCalTriggerCellBxCollection& triggerCellColl) {
0030   vfeSummationImpl_->setGeometry(geometry());
0031   calibrationEE_->setGeometry(geometry());
0032   calibrationHEsi_->setGeometry(geometry());
0033   calibrationHEsc_->setGeometry(geometry());
0034   calibrationNose_->setGeometry(geometry());
0035   triggerTools_.setGeometry(geometry());
0036 
0037   std::vector<HGCalDataFrame> dataframes;
0038   std::vector<std::pair<DetId, uint32_t>> linearized_dataframes;
0039   std::unordered_map<uint32_t, uint32_t> tc_payload;
0040   std::unordered_map<uint32_t, std::array<uint32_t, 2>> tc_compressed_payload;
0041 
0042   // Remove disconnected modules and invalid cells
0043   for (const auto& digiData : digiColl) {
0044     if (!geometry()->validCell(digiData.id()))
0045       continue;
0046     uint32_t module = geometry()->getModuleFromCell(digiData.id());
0047 
0048     // no disconnected layer for HFNose
0049     if (DetId(digiData.id()).subdetId() != ForwardSubdetector::HFNose) {
0050       if (geometry()->disconnectedModule(module))
0051         continue;
0052     }
0053 
0054     dataframes.emplace_back(digiData.id());
0055     for (int i = 0; i < digiData.size(); i++) {
0056       dataframes.back().setSample(i, digiData.sample(i));
0057     }
0058   }
0059   if (dataframes.empty())
0060     return;
0061 
0062   constexpr int kHighDensityThickness = 0;
0063   bool isSilicon = triggerTools_.isSilicon(dataframes[0].id());
0064   bool isEM = triggerTools_.isEm(dataframes[0].id());
0065   bool isNose = triggerTools_.isNose(dataframes[0].id());
0066   int thickness = triggerTools_.thicknessIndex(dataframes[0].id());
0067   // Linearization of ADC and TOT values to the same LSB
0068   if (isSilicon) {
0069     vfeLinearizationSiImpl_->linearize(dataframes, linearized_dataframes);
0070   } else {
0071     vfeLinearizationScImpl_->linearize(dataframes, linearized_dataframes);
0072   }
0073   // Sum of sensor cells into trigger cells
0074   vfeSummationImpl_->triggerCellSums(linearized_dataframes, tc_payload);
0075   // Compression of trigger cell charges to a floating point format
0076   if (thickness == kHighDensityThickness) {
0077     vfeCompressionHDMImpl_->compress(tc_payload, tc_compressed_payload);
0078   } else {
0079     vfeCompressionLDMImpl_->compress(tc_payload, tc_compressed_payload);
0080   }
0081 
0082   // Transform map to trigger cell vector
0083   for (const auto& [tc_id, tc_value] : tc_payload) {
0084     if (tc_value > 0) {
0085       const auto& [tc_compressed_code, tc_compressed_value] = tc_compressed_payload[tc_id];
0086       l1t::HGCalTriggerCell triggerCell(reco::LeafCandidate::LorentzVector(), tc_compressed_value, 0, 0, 0, tc_id);
0087       triggerCell.setCompressedCharge(tc_compressed_code);
0088       triggerCell.setUncompressedCharge(tc_value);
0089       GlobalPoint point = geometry()->getTriggerCellPosition(tc_id);
0090 
0091       // 'value' is hardware, so p4 is meaningless, except for eta and phi
0092       math::PtEtaPhiMLorentzVector p4((double)tc_compressed_value / cosh(point.eta()), point.eta(), point.phi(), 0.);
0093       triggerCell.setP4(p4);
0094       triggerCell.setPosition(point);
0095 
0096       // calibration
0097       if (triggerCell.hwPt() > 0) {
0098         l1t::HGCalTriggerCell calibratedtriggercell(triggerCell);
0099         if (isNose) {
0100           calibrationNose_->calibrateInGeV(calibratedtriggercell);
0101         } else if (isSilicon) {
0102           if (isEM) {
0103             calibrationEE_->calibrateInGeV(calibratedtriggercell);
0104           } else {
0105             calibrationHEsi_->calibrateInGeV(calibratedtriggercell);
0106           }
0107         } else {
0108           calibrationHEsc_->calibrateInGeV(calibratedtriggercell);
0109         }
0110         triggerCellColl.push_back(0, calibratedtriggercell);
0111       }
0112     }
0113   }
0114 }