Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:41

0001 #include "L1Trigger/L1THGCal/interface/backend/HGCalClusteringDummyImpl.h"
0002 #include <unordered_map>
0003 #include <unordered_set>
0004 #include "DataFormats/Common/interface/OrphanHandle.h"
0005 #include "DataFormats/Common/interface/PtrVector.h"
0006 
0007 // class constructor
0008 HGCalClusteringDummyImpl::HGCalClusteringDummyImpl(const edm::ParameterSet& conf)
0009     : calibSF_(conf.getParameter<double>("calibSF_cluster")),
0010       layerWeights_(conf.getParameter<std::vector<double>>("layerWeights")),
0011       applyLayerWeights_(conf.getParameter<bool>("applyLayerCalibration")) {
0012   edm::LogInfo("HGCalClusterParameters") << "C2d global calibration factor: " << calibSF_;
0013 }
0014 
0015 // Create one cluster per TC for direct TC->3D clustering
0016 void HGCalClusteringDummyImpl::clusterizeDummy(const std::vector<edm::Ptr<l1t::HGCalTriggerCell>>& triggerCellsPtrs,
0017                                                l1t::HGCalClusterBxCollection& clusters) {
0018   std::vector<l1t::HGCalCluster> clustersTmp;
0019   for (std::vector<edm::Ptr<l1t::HGCalTriggerCell>>::const_iterator tc = triggerCellsPtrs.begin();
0020        tc != triggerCellsPtrs.end();
0021        ++tc) {
0022     clustersTmp.emplace_back(*tc);
0023   }
0024 
0025   /* store clusters in the persistent collection */
0026   clusters.resize(0, clustersTmp.size());
0027   for (unsigned i(0); i < clustersTmp.size(); ++i) {
0028     calibratePt(clustersTmp.at(i));
0029     clusters.set(0, i, clustersTmp.at(i));
0030   }
0031 }
0032 
0033 void HGCalClusteringDummyImpl::calibratePt(l1t::HGCalCluster& cluster) {
0034   double calibPt = 0.;
0035 
0036   if (applyLayerWeights_ && !triggerTools_.isNose(cluster.detId())) {
0037     unsigned layerN = triggerTools_.layerWithOffset(cluster.detId());
0038 
0039     if (layerWeights_.at(layerN) == 0.) {
0040       throw cms::Exception("BadConfiguration")
0041           << "2D cluster energy forced to 0 by calibration coefficients.\n"
0042           << "The configuration should be changed. "
0043           << "Discarded layers should be defined in hgcalTriggerGeometryESProducer.TriggerGeometry.DisconnectedLayers "
0044              "and not with calibration coefficients = 0\n";
0045     }
0046 
0047     calibPt = layerWeights_.at(layerN) * cluster.mipPt();
0048 
0049   }
0050 
0051   else {
0052     calibPt = cluster.pt() * calibSF_;
0053   }
0054 
0055   cluster.setPt(calibPt);
0056 }