File indexing completed on 2024-09-07 04:36:55
0001
0002 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0003 #include "DataFormats/L1THGCal/interface/HGCalConcentratorData.h"
0004 #include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
0005 #include "DataFormats/Common/interface/AssociationMap.h"
0006 #include "DataFormats/ForwardDetId/interface/HGCalTriggerDetId.h"
0007 #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h"
0008 #include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h"
0009 #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h"
0010
0011 class HGCalTriggerNtupleHGCConcentratorData : public HGCalTriggerNtupleBase {
0012 public:
0013 HGCalTriggerNtupleHGCConcentratorData(const edm::ParameterSet& conf);
0014 ~HGCalTriggerNtupleHGCConcentratorData() override {}
0015 void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final;
0016 void fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) final;
0017
0018 private:
0019 void clear() final;
0020
0021 HGCalTriggerTools triggerTools_;
0022
0023 edm::EDGetToken concentrator_data_token_;
0024
0025 int econ_n_;
0026 std::vector<uint32_t> econ_id_;
0027 std::vector<int> econ_subdet_;
0028 std::vector<int> econ_side_;
0029 std::vector<int> econ_layer_;
0030 std::vector<int> econ_waferu_;
0031 std::vector<int> econ_waferv_;
0032 std::vector<int> econ_wafertype_;
0033 std::vector<uint32_t> econ_index_;
0034 std::vector<uint32_t> econ_data_;
0035 };
0036
0037 DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory,
0038 HGCalTriggerNtupleHGCConcentratorData,
0039 "HGCalTriggerNtupleHGCConcentratorData");
0040
0041 HGCalTriggerNtupleHGCConcentratorData::HGCalTriggerNtupleHGCConcentratorData(const edm::ParameterSet& conf)
0042 : HGCalTriggerNtupleBase(conf) {
0043 accessEventSetup_ = false;
0044 }
0045
0046 void HGCalTriggerNtupleHGCConcentratorData::initialize(TTree& tree,
0047 const edm::ParameterSet& conf,
0048 edm::ConsumesCollector&& collector) {
0049 concentrator_data_token_ =
0050 collector.consumes<l1t::HGCalConcentratorDataBxCollection>(conf.getParameter<edm::InputTag>("ConcentratorData"));
0051
0052 std::string prefix(conf.getUntrackedParameter<std::string>("Prefix", "econ"));
0053
0054 std::string bname;
0055 auto withPrefix([&prefix, &bname](char const* vname) -> char const* {
0056 bname = prefix + "_" + vname;
0057 return bname.c_str();
0058 });
0059
0060 tree.Branch(withPrefix("n"), &econ_n_, (prefix + "_n/I").c_str());
0061 tree.Branch(withPrefix("id"), &econ_id_);
0062 tree.Branch(withPrefix("subdet"), &econ_subdet_);
0063 tree.Branch(withPrefix("zside"), &econ_side_);
0064 tree.Branch(withPrefix("layer"), &econ_layer_);
0065 tree.Branch(withPrefix("waferu"), &econ_waferu_);
0066 tree.Branch(withPrefix("waferv"), &econ_waferv_);
0067 tree.Branch(withPrefix("wafertype"), &econ_wafertype_);
0068 tree.Branch(withPrefix("index"), &econ_index_);
0069 tree.Branch(withPrefix("data"), &econ_data_);
0070 }
0071
0072 void HGCalTriggerNtupleHGCConcentratorData::fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) {
0073
0074 edm::Handle<l1t::HGCalConcentratorDataBxCollection> concentrator_data_h;
0075 e.getByToken(concentrator_data_token_, concentrator_data_h);
0076 const l1t::HGCalConcentratorDataBxCollection& concentrator_data = *concentrator_data_h;
0077
0078 triggerTools_.setGeometry(es.geometry.product());
0079
0080 clear();
0081 for (auto econ_itr = concentrator_data.begin(0); econ_itr != concentrator_data.end(0); econ_itr++) {
0082 econ_n_++;
0083
0084 DetId id(econ_itr->detId());
0085 econ_id_.emplace_back(econ_itr->detId());
0086 econ_side_.emplace_back(triggerTools_.zside(id));
0087 econ_layer_.emplace_back(triggerTools_.layerWithOffset(id));
0088
0089 HGCalTriggerDetId idv9(id);
0090 econ_subdet_.emplace_back(idv9.subdet());
0091 econ_waferu_.emplace_back(idv9.waferU());
0092 econ_waferv_.emplace_back(idv9.waferV());
0093 econ_wafertype_.emplace_back(idv9.type());
0094
0095 econ_index_.emplace_back(econ_itr->index());
0096 econ_data_.emplace_back(econ_itr->data());
0097 }
0098 }
0099
0100 void HGCalTriggerNtupleHGCConcentratorData::clear() {
0101 econ_n_ = 0;
0102 econ_id_.clear();
0103 econ_subdet_.clear();
0104 econ_side_.clear();
0105 econ_layer_.clear();
0106 econ_wafertype_.clear();
0107 econ_data_.clear();
0108 }