File indexing completed on 2024-09-07 04:37:01
0001
0002
0003
0004
0005
0006 #include <memory>
0007
0008 #include "FWCore/Framework/interface/Frameworkfwd.h"
0009 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/Framework/interface/EventSetup.h"
0012 #include "FWCore/Framework/interface/MakerMacros.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0015
0016 #include "FWCore/ServiceRegistry/interface/Service.h"
0017 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0018 #include "TTree.h"
0019
0020 #include "L1Trigger/L1TNtuples/interface/L1AnalysisCaloSummaryDataFormat.h"
0021
0022 #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
0023 #include "DataFormats/L1CaloTrigger/interface/L1CaloRegion.h"
0024
0025 class L1CaloSummaryTreeProducer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
0026 public:
0027 explicit L1CaloSummaryTreeProducer(const edm::ParameterSet&);
0028 ~L1CaloSummaryTreeProducer() override;
0029
0030 private:
0031 void beginJob() override {}
0032 void analyze(const edm::Event&, const edm::EventSetup&) override;
0033 void endJob() override {}
0034
0035 public:
0036 L1Analysis::L1AnalysisCaloSummaryDataFormat* caloSummaryData_;
0037
0038 private:
0039 const edm::EDGetTokenT<float> scoreToken_;
0040 const edm::EDGetTokenT<L1CaloRegionCollection> regionToken_;
0041 edm::Service<TFileService> fs_;
0042 TTree* tree_;
0043 };
0044
0045 L1CaloSummaryTreeProducer::L1CaloSummaryTreeProducer(const edm::ParameterSet& iConfig)
0046 : scoreToken_(consumes<float>(iConfig.getUntrackedParameter<edm::InputTag>("scoreToken"))),
0047 regionToken_(consumes<L1CaloRegionCollection>(iConfig.getUntrackedParameter<edm::InputTag>("regionToken"))) {
0048 usesResource(TFileService::kSharedResource);
0049 tree_ = fs_->make<TTree>("L1CaloSummaryTree", "L1CaloSummaryTree");
0050 tree_->Branch("CaloSummary", "L1Analysis::L1AnalysisCaloSummaryDataFormat", &caloSummaryData_, 32000, 3);
0051
0052 caloSummaryData_ = new L1Analysis::L1AnalysisCaloSummaryDataFormat();
0053 }
0054
0055 void L1CaloSummaryTreeProducer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0056 caloSummaryData_->Reset();
0057
0058 edm::Handle<L1CaloRegionCollection> regions;
0059 iEvent.getByToken(regionToken_, regions);
0060
0061 if (regions.isValid()) {
0062 for (const auto& itr : *regions) {
0063 caloSummaryData_->modelInput[itr.gctPhi()][itr.gctEta() - 4] =
0064 itr.et();
0065 }
0066 } else {
0067 edm::LogWarning("L1Ntuple") << "Could not find region regions. CICADA model input will not be filled";
0068 }
0069
0070 edm::Handle<float> score;
0071 iEvent.getByToken(scoreToken_, score);
0072 if (score.isValid())
0073 caloSummaryData_->CICADAScore = *score;
0074 else
0075 edm::LogWarning("L1Ntuple") << "Could not find a proper CICADA score. CICADA score will not be filled.";
0076
0077 tree_->Fill();
0078 }
0079
0080 L1CaloSummaryTreeProducer::~L1CaloSummaryTreeProducer() { delete caloSummaryData_; }
0081
0082 DEFINE_FWK_MODULE(L1CaloSummaryTreeProducer);