Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-08 22:26:30

0001 #ifndef __L1Trigger_L1THGCal_HGCalTowerMap2DImpl_h__
0002 #define __L1Trigger_L1THGCal_HGCalTowerMap2DImpl_h__
0003 
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 
0007 #include "DataFormats/L1THGCal/interface/HGCalTriggerSums.h"
0008 #include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h"
0009 #include "DataFormats/L1THGCal/interface/HGCalTowerMap.h"
0010 #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h"
0011 #include "L1Trigger/L1THGCal/interface/HGCalTriggerTowerGeometryHelper.h"
0012 
0013 class HGCalTowerMap2DImpl {
0014 public:
0015   HGCalTowerMap2DImpl(const edm::ParameterSet& conf);
0016 
0017   void resetTowerMaps();
0018 
0019   template <class T>
0020   void buildTowerMap2D(const std::vector<edm::Ptr<T>>& ptrs, l1t::HGCalTowerMapBxCollection& towerMaps) {
0021     std::unordered_map<int, l1t::HGCalTowerMap> towerMapsTmp = newTowerMaps();
0022 
0023     for (const auto& ptr : ptrs) {
0024       bool isNose = triggerTools_.isNose(ptr->detId());
0025       unsigned layer = triggerTools_.layerWithOffset(ptr->detId());
0026 
0027       if (towerMapsTmp.find(layer) == towerMapsTmp.end()) {
0028         throw cms::Exception("Out of range")
0029             << "HGCalTowerMap2dImpl: Found trigger sum in layer " << layer << " for which there is no tower map\n";
0030       }
0031       // FIXME: should actually sum the energy not the Et...
0032       double calibPt = ptr->pt();
0033       if (useLayerWeights_)
0034         calibPt = layerWeights_[layer] * ptr->mipPt();
0035 
0036       double etEm = layer <= triggerTools_.lastLayerEE(isNose) ? calibPt : 0;
0037       double etHad = layer > triggerTools_.lastLayerEE(isNose) ? calibPt : 0;
0038 
0039       towerMapsTmp[layer].addEt(towerGeometryHelper_.getTriggerTower(*ptr), etEm, etHad);
0040     }
0041 
0042     /* store towerMaps in the persistent collection */
0043     towerMaps.resize(0, towerMapsTmp.size());
0044     int i = 0;
0045     for (const auto& towerMap : towerMapsTmp) {
0046       towerMaps.set(0, i, towerMap.second);
0047       i++;
0048     }
0049   }
0050 
0051   void setGeometry(const HGCalTriggerGeometryBase* const geom) {
0052     triggerTools_.setGeometry(geom);
0053     towerGeometryHelper_.setGeometry(geom);
0054   }
0055 
0056 private:
0057   bool useLayerWeights_;
0058   std::vector<double> layerWeights_;
0059   HGCalTriggerTools triggerTools_;
0060   std::unordered_map<int, l1t::HGCalTowerMap> newTowerMaps();
0061 
0062   HGCalTriggerTowerGeometryHelper towerGeometryHelper_;
0063 };
0064 
0065 #endif