CMS 3D CMS Logo

L1ElectronRecoTreeProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1Trigger/L1TNtuples
4 // Class: L1JetRecoTreeProducer
5 //
13 // system include files
14 #include <memory>
15 
16 // framework
25 
26 //electrons
28 
29 // ROOT output stuff
32 #include "TH1.h"
33 #include "TTree.h"
34 #include "TF1.h"
35 
36 //local data formats
38 
39 //
40 // class declaration
41 //
42 
44 public:
46  ~L1ElectronRecoTreeProducer() override;
47 
48 private:
49  void beginJob(void) override;
50  void analyze(const edm::Event&, const edm::EventSetup&) override;
51  void endJob() override;
52 
53 public:
55 
57 
58 private:
59  // output file
61 
62  // tree
63  TTree* tree_;
64 
65  // EDM input tags
66  //edm::EDGetToken ElectronToken_;
67  // edm::EDGetToken<edm::View<reco::GsfElectron>> ElectronToken_;
73 
74  // debug stuff
76  unsigned int maxElectron_;
77 };
78 
80  maxElectron_ = iConfig.getParameter<unsigned int>("maxElectron");
81  //ElectronToken_ = mayConsume<edm::View<reco::GsfElectron> >(iConfig.getUntrackedParameter("ElectronToken",edm::InputTag("gedGsfElectrons")));
82  ElectronToken_ = consumes<reco::GsfElectronCollection>(
83  iConfig.getUntrackedParameter("ElectronToken", edm::InputTag("gedGsfElectrons")));
84 
85  /*RhoToken_ = consumes<double>(iConfig.getUntrackedParameter("RhoToken",edm::InputTag("fixedGridRhoFastjetAllCalo")));
86  vtxToken_ = mayConsume<reco::VertexCollection>(iConfig.getUntrackedParameter("vtxToken",edm::InputTag("offlinePrimaryVertices")));
87  conversionsToken_ = mayConsume< reco::ConversionCollection >(iConfig.getUntrackedParameter("conversionsToken",edm::InputTag("conversions")));
88  beamSpotToken_ = mayConsume< reco::BeamSpot>(iConfig.getUntrackedParameter("beamSpotToken",edm::InputTag("offlineBeamSpot")));*/
89 
90  ElectronVetoIdMapToken_ = consumes<edm::ValueMap<bool> >(iConfig.getUntrackedParameter(
91  "eleVetoIdMapToken", edm::InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto")));
92  ElectronLooseIdMapToken_ = consumes<edm::ValueMap<bool> >(iConfig.getUntrackedParameter(
93  "eleLooseIdMapToken", edm::InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose")));
94  ElectronMediumIdMapToken_ = consumes<edm::ValueMap<bool> >(iConfig.getUntrackedParameter(
95  "eleMediumIdMapToken", edm::InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium")));
96  ElectronTightIdMapToken_ = consumes<edm::ValueMap<bool> >(iConfig.getUntrackedParameter(
97  "eleTightIdMapToken", edm::InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight")));
98 
101 
102  tree_ = fs_->make<TTree>("ElectronRecoTree", "ElectronRecoTree");
103  tree_->Branch("Electron", "L1Analysis::L1AnalysisRecoElectronDataFormat", &electron_data, 32000, 3);
104 }
105 
107  // do anything here that needs to be done at desctruction time
108  // (e.g. close files, deallocate resources etc.)
109 }
110 
111 //
112 // member functions
113 //
114 
115 // ------------ method called to for each event ------------
117  electron->Reset();
118  //edm::Handle<edm::View<reco::GsfElectron> > recoElectrons;
119  //iEvent.getByToken(ElectronToken_, recoElectrons);
121  iEvent.getByToken(ElectronToken_, recoElectrons);
122 
123  std::vector<edm::Handle<edm::ValueMap<bool> > > eleVIDDecisionHandles(4);
124 
125  iEvent.getByToken(ElectronVetoIdMapToken_, eleVIDDecisionHandles[0]);
126  iEvent.getByToken(ElectronLooseIdMapToken_, eleVIDDecisionHandles[1]);
127  iEvent.getByToken(ElectronMediumIdMapToken_, eleVIDDecisionHandles[2]);
128  iEvent.getByToken(ElectronTightIdMapToken_, eleVIDDecisionHandles[3]);
129 
130  if (recoElectrons.isValid() && eleVIDDecisionHandles[0].isValid() && eleVIDDecisionHandles[1].isValid() &&
131  eleVIDDecisionHandles[2].isValid() && eleVIDDecisionHandles[3].isValid()) {
132  electron->SetElectron(iEvent, iSetup, recoElectrons, eleVIDDecisionHandles, maxElectron_);
133  } else {
134  if (!electronsMissing_) {
135  edm::LogWarning("MissingProduct") << "CaloJets not found. Branch will not be filled" << std::endl;
136  }
137  electronsMissing_ = true;
138  }
139 
140  tree_->Fill();
141 }
142 
143 // ------------ method called once each job just before starting event loop ------------
145 
146 // ------------ method called once each job just after ending the event loop ------------
148 
149 //define this as a plug-in
MessageLogger.h
funct::false
false
Definition: Factorize.h:34
ESHandle.h
edm::EDGetTokenT< reco::GsfElectronCollection >
L1Analysis::L1AnalysisRecoElectron::getData
L1AnalysisRecoElectronDataFormat * getData()
Definition: L1AnalysisRecoElectron.h:43
L1ElectronRecoTreeProducer::ElectronLooseIdMapToken_
edm::EDGetTokenT< edm::ValueMap< bool > > ElectronLooseIdMapToken_
Definition: L1ElectronRecoTreeProducer.cc:70
L1ElectronRecoTreeProducer::electronsMissing_
bool electronsMissing_
Definition: L1ElectronRecoTreeProducer.cc:75
L1ElectronRecoTreeProducer::endJob
void endJob() override
Definition: L1ElectronRecoTreeProducer.cc:147
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EDAnalyzer.h
L1ElectronRecoTreeProducer::electron_data
L1Analysis::L1AnalysisRecoElectronDataFormat * electron_data
Definition: L1ElectronRecoTreeProducer.cc:56
L1ElectronRecoTreeProducer::ElectronMediumIdMapToken_
edm::EDGetTokenT< edm::ValueMap< bool > > ElectronMediumIdMapToken_
Definition: L1ElectronRecoTreeProducer.cc:71
edm::Handle< reco::GsfElectronCollection >
L1ElectronRecoTreeProducer::tree_
TTree * tree_
Definition: L1ElectronRecoTreeProducer.cc:63
edm::EDAnalyzer
Definition: EDAnalyzer.h:29
MakerMacros.h
L1Analysis::L1AnalysisRecoElectron::Reset
void Reset()
Definition: L1AnalysisRecoElectron.h:44
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
L1ElectronRecoTreeProducer::fs_
edm::Service< TFileService > fs_
Definition: L1ElectronRecoTreeProducer.cc:60
Service.h
L1Analysis::L1AnalysisRecoElectron
Definition: L1AnalysisRecoElectron.h:22
L1ElectronRecoTreeProducer::~L1ElectronRecoTreeProducer
~L1ElectronRecoTreeProducer() override
Definition: L1ElectronRecoTreeProducer.cc:106
L1Analysis::L1AnalysisRecoElectron::SetElectron
void SetElectron(const edm::Event &event, const edm::EventSetup &setup, const edm::Handle< reco::GsfElectronCollection > electrons, const std::vector< edm::Handle< edm::ValueMap< bool > > > eleVIDDecisionHandles, const unsigned &maxElectron)
Definition: L1AnalysisRecoElectron.cc:9
L1AnalysisRecoElectron.h
edm::LogWarning
Definition: MessageLogger.h:141
TFileService.h
GsfElectronFwd.h
edm::ParameterSet
Definition: ParameterSet.h:36
L1Analysis::L1AnalysisRecoElectronDataFormat
Definition: L1AnalysisRecoElectronDataFormat.h:14
Event.h
L1ElectronRecoTreeProducer::beginJob
void beginJob(void) override
Definition: L1ElectronRecoTreeProducer.cc:144
L1ElectronRecoTreeProducer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: L1ElectronRecoTreeProducer.cc:116
edm::Service< TFileService >
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
L1ElectronRecoTreeProducer
Definition: L1ElectronRecoTreeProducer.cc:43
Frameworkfwd.h
L1ElectronRecoTreeProducer::maxElectron_
unsigned int maxElectron_
Definition: L1ElectronRecoTreeProducer.cc:76
EventSetup.h
L1ElectronRecoTreeProducer::L1ElectronRecoTreeProducer
L1ElectronRecoTreeProducer(const edm::ParameterSet &)
Definition: L1ElectronRecoTreeProducer.cc:79
L1ElectronRecoTreeProducer::ElectronVetoIdMapToken_
edm::EDGetTokenT< edm::ValueMap< bool > > ElectronVetoIdMapToken_
Definition: L1ElectronRecoTreeProducer.cc:69
L1ElectronRecoTreeProducer::electron
L1Analysis::L1AnalysisRecoElectron * electron
Definition: L1ElectronRecoTreeProducer.cc:54
ParameterSet.h
L1ElectronRecoTreeProducer::ElectronTightIdMapToken_
edm::EDGetTokenT< edm::ValueMap< bool > > ElectronTightIdMapToken_
Definition: L1ElectronRecoTreeProducer.cc:72
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
L1ElectronRecoTreeProducer::ElectronToken_
edm::EDGetTokenT< reco::GsfElectronCollection > ElectronToken_
Definition: L1ElectronRecoTreeProducer.cc:68
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64