File indexing completed on 2024-04-06 12:21:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <memory>
0015
0016
0017 #include "FWCore/Framework/interface/Frameworkfwd.h"
0018 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0019 #include "FWCore/Framework/interface/Event.h"
0020 #include "FWCore/Framework/interface/EventSetup.h"
0021 #include "FWCore/Framework/interface/MakerMacros.h"
0022 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0024 #include "FWCore/Framework/interface/ESHandle.h"
0025
0026
0027 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
0028
0029
0030 #include "FWCore/ServiceRegistry/interface/Service.h"
0031 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0032 #include "TH1.h"
0033 #include "TTree.h"
0034 #include "TF1.h"
0035
0036
0037 #include "L1Trigger/L1TNtuples/interface/L1AnalysisRecoElectron.h"
0038
0039
0040
0041
0042
0043 class L1ElectronRecoTreeProducer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
0044 public:
0045 explicit L1ElectronRecoTreeProducer(const edm::ParameterSet&);
0046 ~L1ElectronRecoTreeProducer() override;
0047
0048 private:
0049 void beginJob(void) override;
0050 void analyze(const edm::Event&, const edm::EventSetup&) override;
0051 void endJob() override;
0052
0053 public:
0054 L1Analysis::L1AnalysisRecoElectron* electron;
0055
0056 L1Analysis::L1AnalysisRecoElectronDataFormat* electron_data;
0057
0058 private:
0059
0060 edm::Service<TFileService> fs_;
0061
0062
0063 TTree* tree_;
0064
0065
0066
0067
0068 edm::EDGetTokenT<reco::GsfElectronCollection> ElectronToken_;
0069 edm::EDGetTokenT<edm::ValueMap<bool> > ElectronVetoIdMapToken_;
0070 edm::EDGetTokenT<edm::ValueMap<bool> > ElectronLooseIdMapToken_;
0071 edm::EDGetTokenT<edm::ValueMap<bool> > ElectronMediumIdMapToken_;
0072 edm::EDGetTokenT<edm::ValueMap<bool> > ElectronTightIdMapToken_;
0073
0074
0075 bool electronsMissing_;
0076 unsigned int maxElectron_;
0077 };
0078
0079 L1ElectronRecoTreeProducer::L1ElectronRecoTreeProducer(const edm::ParameterSet& iConfig) : electronsMissing_(false) {
0080 maxElectron_ = iConfig.getParameter<unsigned int>("maxElectron");
0081
0082 ElectronToken_ = consumes<reco::GsfElectronCollection>(
0083 iConfig.getUntrackedParameter("ElectronToken", edm::InputTag("gedGsfElectrons")));
0084
0085
0086
0087
0088
0089
0090 ElectronVetoIdMapToken_ = consumes<edm::ValueMap<bool> >(iConfig.getUntrackedParameter(
0091 "eleVetoIdMapToken", edm::InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto")));
0092 ElectronLooseIdMapToken_ = consumes<edm::ValueMap<bool> >(iConfig.getUntrackedParameter(
0093 "eleLooseIdMapToken", edm::InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose")));
0094 ElectronMediumIdMapToken_ = consumes<edm::ValueMap<bool> >(iConfig.getUntrackedParameter(
0095 "eleMediumIdMapToken", edm::InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium")));
0096 ElectronTightIdMapToken_ = consumes<edm::ValueMap<bool> >(iConfig.getUntrackedParameter(
0097 "eleTightIdMapToken", edm::InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight")));
0098
0099 electron = new L1Analysis::L1AnalysisRecoElectron();
0100 electron_data = electron->getData();
0101
0102 usesResource(TFileService::kSharedResource);
0103 tree_ = fs_->make<TTree>("ElectronRecoTree", "ElectronRecoTree");
0104 tree_->Branch("Electron", "L1Analysis::L1AnalysisRecoElectronDataFormat", &electron_data, 32000, 3);
0105 }
0106
0107 L1ElectronRecoTreeProducer::~L1ElectronRecoTreeProducer() {
0108
0109
0110 }
0111
0112
0113
0114
0115
0116
0117 void L1ElectronRecoTreeProducer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0118 electron->Reset();
0119
0120
0121 edm::Handle<reco::GsfElectronCollection> recoElectrons;
0122 iEvent.getByToken(ElectronToken_, recoElectrons);
0123
0124 std::vector<edm::Handle<edm::ValueMap<bool> > > eleVIDDecisionHandles(4);
0125
0126 iEvent.getByToken(ElectronVetoIdMapToken_, eleVIDDecisionHandles[0]);
0127 iEvent.getByToken(ElectronLooseIdMapToken_, eleVIDDecisionHandles[1]);
0128 iEvent.getByToken(ElectronMediumIdMapToken_, eleVIDDecisionHandles[2]);
0129 iEvent.getByToken(ElectronTightIdMapToken_, eleVIDDecisionHandles[3]);
0130
0131 if (recoElectrons.isValid() && eleVIDDecisionHandles[0].isValid() && eleVIDDecisionHandles[1].isValid() &&
0132 eleVIDDecisionHandles[2].isValid() && eleVIDDecisionHandles[3].isValid()) {
0133 electron->SetElectron(iEvent, iSetup, recoElectrons, eleVIDDecisionHandles, maxElectron_);
0134 } else {
0135 if (!electronsMissing_) {
0136 edm::LogWarning("MissingProduct") << "CaloJets not found. Branch will not be filled" << std::endl;
0137 }
0138 electronsMissing_ = true;
0139 }
0140
0141 tree_->Fill();
0142 }
0143
0144
0145 void L1ElectronRecoTreeProducer::beginJob(void) {}
0146
0147
0148 void L1ElectronRecoTreeProducer::endJob() {}
0149
0150
0151 DEFINE_FWK_MODULE(L1ElectronRecoTreeProducer);