CMS 3D CMS Logo

L1TauRecoTreeProducer.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 // cond formats
28 
29 // data formats
33 
34 //taus
38 
39 // #include "CommonTools/UtilAlgos/interface/PhysObjectMatcher.h"
40 // #include "CommonTools/UtilAlgos/interface/MCMatchSelector.h"
41 // #include "CommonTools/UtilAlgos/interface/DummyMatchSelector.h"
42 // #include "CommonTools/UtilAlgos/interface/MatchByDRDPt.h"
43 // #include "DataFormats/TauReco/interface/PFTauDecayMode.h"
44 // #include "DataFormats/TauReco/interface/PFTauDecayModeFwd.h"
45 // #include "DataFormats/TauReco/interface/PFTau.h"
46 
47 // ROOT output stuff
50 #include "TH1.h"
51 #include "TTree.h"
52 #include "TF1.h"
53 
54 //local data formats
57 
58 //
59 // class declaration
60 //
61 
63 public:
65  ~L1TauRecoTreeProducer() override;
66 
67 private:
68  void beginJob(void) override;
69  void analyze(const edm::Event&, const edm::EventSetup&) override;
70  void endJob() override;
71 
72 public:
74 
76 
77 private:
78  // output file
80 
81  // tree
82  TTree* tree_;
83 
84  // EDM input tags
96 
97  // edm::EDGetTokenT<reco::CaloJetCollection> caloJetToken_;
98  // edm::EDGetTokenT<edm::ValueMap<reco::JetID> > caloJetIdToken_;
99  // edm::EDGetTokenT<reco::JetCorrector> jetCorrectorToken_;
100 
101  // debug stuff
104  unsigned int maxCl_;
106  unsigned int maxTau_;
107  unsigned int maxVtx_;
108  unsigned int maxTrk_;
109 };
110 
112  period_ = iConfig.getParameter<std::string>("period");
113 
114  if (period_ == "2015") {
115  maxTau_ = iConfig.getParameter<unsigned int>("maxTau");
116  TauToken_ =
117  consumes<reco::PFTauCollection>(iConfig.getUntrackedParameter("TauToken", edm::InputTag("hpsPFTauProducer")));
118  DMFindingToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter(
119  "DMFindingToken", edm::InputTag("hpsPFTauDiscriminationByDecayModeFindingNewDMs")));
120  DMFindingOldToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter(
121  "DMFindingOldToken", edm::InputTag("hpsPFTauDiscriminationByDecayModeFindingOldDMs")));
122  TightIsoToken_ = consumes<reco::PFTauDiscriminator>(
123  iConfig.getUntrackedParameter("TightIsoToken", edm::InputTag("hpsPFTauDiscriminationByTightIsolation")));
124  TightRawIsoToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter(
125  "TightRawIsoToken", edm::InputTag("hpsPFTauDiscriminationByRawCombinedIsolationDBSumPtCorr3Hits")));
126  LooseIsoToken_ = consumes<reco::PFTauDiscriminator>(
127  iConfig.getUntrackedParameter("LooseIsoToken", edm::InputTag("hpsPFTauDiscriminationByLooseIsolation")));
128  LooseAntiMuonToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter(
129  "LooseAntiMuonToken", edm::InputTag("hpsPFTauDiscriminationByLooseMuonRejection")));
130  TightAntiMuonToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter(
131  "TightAntiMuonToken", edm::InputTag("hpsPFTauDiscriminationByTightMuonRejection")));
132  VLooseAntiElectronToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter(
133  "VLooseAntiElectronToken", edm::InputTag("hpsPFTauDiscriminationByMVA5VLooseElectronRejection")));
134  LooseAntiElectronToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter(
135  "LooseAntiElectronToken", edm::InputTag("hpsPFTauDiscriminationByMVA5LooseElectronRejection")));
136  TightAntiElectronToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter(
137  "TightAntiElectronToken", edm::InputTag("hpsPFTauDiscriminationByMVA5TightElectronRejection")));
138  } else if (period_ == "2016") {
139  maxTau_ = iConfig.getParameter<unsigned int>("maxTau");
140  TauToken_ =
141  consumes<reco::PFTauCollection>(iConfig.getUntrackedParameter("TauToken", edm::InputTag("hpsPFTauProducer")));
142  DMFindingToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter(
143  "DMFindingToken", edm::InputTag("hpsPFTauDiscriminationByDecayModeFindingNewDMs")));
144  DMFindingOldToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter(
145  "DMFindingOldToken", edm::InputTag("hpsPFTauDiscriminationByDecayModeFindingOldDMs")));
146  TightIsoToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter(
147  "TightIsoToken", edm::InputTag("hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3Hits")));
148  TightRawIsoToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter(
149  "TightRawIsoToken", edm::InputTag("hpsPFTauDiscriminationByRawCombinedIsolationDBSumPtCorr3Hits")));
150  LooseIsoToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter(
151  "LooseIsoToken", edm::InputTag("hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits")));
152  LooseAntiMuonToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter(
153  "LooseAntiMuonToken", edm::InputTag("hpsPFTauDiscriminationByLooseMuonRejection3")));
154  TightAntiMuonToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter(
155  "TightAntiMuonToken", edm::InputTag("hpsPFTauDiscriminationByTightMuonRejection3")));
156  VLooseAntiElectronToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter(
157  "VLooseAntiElectronToken", edm::InputTag("hpsPFTauDiscriminationByMVA6VLooseElectronRejection")));
158  LooseAntiElectronToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter(
159  "LooseAntiElectronToken", edm::InputTag("hpsPFTauDiscriminationByMVA6LooseElectronRejection")));
160  TightAntiElectronToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter(
161  "TightAntiElectronToken", edm::InputTag("hpsPFTauDiscriminationByMVA6TightElectronRejection")));
162  }
163 
164  /*
165  caloJetToken_ = consumes<reco::CaloJetCollection>(iConfig.getUntrackedParameter("caloJetToken",edm::InputTag("ak4CaloJets")));
166  // caloJetIdToken_ = consumes<edm::ValueMap<reco::JetID> >(iConfig.getUntrackedParameter("jetIdToken",edm::InputTag("ak4JetID")));
167  jetCorrectorToken_ = consumes<reco::JetCorrector>(iConfig.getUntrackedParameter<edm::InputTag>("jetCorrToken"));
168 
169  jetptThreshold_ = iConfig.getParameter<double> ("jetptThreshold");
170  maxTau_ = iConfig.getParameter<unsigned int>("maxTau");
171  */
172 
174  tau_data = tau->getData();
175 
176  /*
177  // set up output
178  */
179  tree_ = fs_->make<TTree>("TauRecoTree", "TauRecoTree");
180  //tree_=fs_->make<TTree>("JetRecoTree", "JetRecoTree");
181  tree_->Branch("Tau", "L1Analysis::L1AnalysisRecoTauDataFormat", &tau_data, 32000, 3);
182 }
183 
185  // do anything here that needs to be done at desctruction time
186  // (e.g. close files, deallocate resources etc.)
187 }
188 
189 //
190 // member functions
191 //
192 
193 // ------------ method called to for each event ------------
195  tau->Reset();
197  iEvent.getByToken(TauToken_, recoTaus);
198 
200  iEvent.getByToken(DMFindingToken_, DMFindingTaus);
201 
202  edm::Handle<reco::PFTauDiscriminator> DMFindingOldTaus;
203  iEvent.getByToken(DMFindingOldToken_, DMFindingOldTaus);
204 
206  iEvent.getByToken(TightIsoToken_, TightIsoTaus);
207 
209  iEvent.getByToken(TightRawIsoToken_, TightRawIsoTaus);
210 
212  iEvent.getByToken(LooseIsoToken_, LooseIsoTaus);
213 
215  iEvent.getByToken(LooseAntiMuonToken_, LooseAntiMuon);
216 
218  iEvent.getByToken(TightAntiMuonToken_, TightAntiMuon);
219 
220  edm::Handle<reco::PFTauDiscriminator> VLooseAntiElectron;
221  iEvent.getByToken(VLooseAntiElectronToken_, VLooseAntiElectron);
222 
223  edm::Handle<reco::PFTauDiscriminator> LooseAntiElectron;
224  iEvent.getByToken(LooseAntiElectronToken_, LooseAntiElectron);
225 
226  edm::Handle<reco::PFTauDiscriminator> TightAntiElectron;
227  iEvent.getByToken(TightAntiElectronToken_, TightAntiElectron);
228 
229  //std::cout<<"size of recoTaus = "<<recoTaus->size()<<std::endl;
230 
231  if (recoTaus.isValid()) {
232  //std::cout<<"passing here"<<std::endl;
233  tau->SetTau(iEvent,
234  iSetup,
235  recoTaus,
236  DMFindingOldTaus,
237  DMFindingTaus,
238  TightIsoTaus,
239  TightRawIsoTaus,
240  LooseIsoTaus,
241  LooseAntiMuon,
242  TightAntiMuon,
243  VLooseAntiElectron,
244  LooseAntiElectron,
245  TightAntiElectron,
246  maxTau_);
247  } else {
248  if (!caloJetsMissing_) {
249  edm::LogWarning("MissingProduct") << "CaloJets not found. Branch will not be filled" << std::endl;
250  }
251  caloJetsMissing_ = true;
252  }
253 
254  /*
255  jet->Reset();
256 
257  // get jets & co...
258  edm::Handle<reco::CaloJetCollection> recoCaloJets;
259  edm::Handle<edm::ValueMap<reco::JetID> > jetsID;
260  edm::Handle<reco::JetCorrector> jetCorr;
261 
262  iEvent.getByToken(caloJetToken_, recoCaloJets);
263  //iEvent.getByLabel(jetIdTag_,jetsID);
264  //iEvent.getByToken(jetCorrectorToken_, jetCorr);
265 
266  if (recoCaloJets.isValid()) {
267  jet->SetCaloJet(iEvent, iSetup, recoCaloJets, maxTau_); //jetsID, maxTau_);
268  }
269  else {
270  if (!caloJetsMissing_) {edm::LogWarning("MissingProduct") << "CaloJets not found. Branch will not be filled" << std::endl;}
271  caloJetsMissing_ = true;
272  }
273  */
274 
275  tree_->Fill();
276 }
277 
278 // ------------ method called once each job just before starting event loop ------------
280 
281 // ------------ method called once each job just after ending the event loop ------------
283 
284 //define this as a plug-in
L1TauRecoTreeProducer::jetptThreshold_
double jetptThreshold_
Definition: L1TauRecoTreeProducer.cc:103
CaloJetCollection.h
L1TauRecoTreeProducer::DMFindingOldToken_
edm::EDGetTokenT< reco::PFTauDiscriminator > DMFindingOldToken_
Definition: L1TauRecoTreeProducer.cc:87
L1TauRecoTreeProducer::tau_data
L1Analysis::L1AnalysisRecoTauDataFormat * tau_data
Definition: L1TauRecoTreeProducer.cc:75
L1TauRecoTreeProducer::LooseAntiElectronToken_
edm::EDGetTokenT< reco::PFTauDiscriminator > LooseAntiElectronToken_
Definition: L1TauRecoTreeProducer.cc:94
L1TauRecoTreeProducer::TightIsoToken_
edm::EDGetTokenT< reco::PFTauDiscriminator > TightIsoToken_
Definition: L1TauRecoTreeProducer.cc:88
PFTauFwd.h
MessageLogger.h
L1Analysis::L1AnalysisRecoTau::SetTau
void SetTau(const edm::Event &event, const edm::EventSetup &setup, const edm::Handle< reco::PFTauCollection > taus, const edm::Handle< reco::PFTauDiscriminator > DMFindingOldTaus, const edm::Handle< reco::PFTauDiscriminator > DMFindingTaus, const edm::Handle< reco::PFTauDiscriminator > TightIsoTaus, const edm::Handle< reco::PFTauDiscriminator > TightRawIsoTaus, const edm::Handle< reco::PFTauDiscriminator > LooseIsoTaus, const edm::Handle< reco::PFTauDiscriminator > LooseAntiMuon, const edm::Handle< reco::PFTauDiscriminator > TightAntiMuon, const edm::Handle< reco::PFTauDiscriminator > VLooseAntiElectron, const edm::Handle< reco::PFTauDiscriminator > LooseAntiElectron, const edm::Handle< reco::PFTauDiscriminator > TightAntiElectron, unsigned maxTau)
Definition: L1AnalysisRecoTau.cc:12
funct::false
false
Definition: Factorize.h:29
JetID.h
ESHandle.h
PFTauDiscriminator.h
L1TauRecoTreeProducer::endJob
void endJob() override
Definition: L1TauRecoTreeProducer.cc:282
edm::EDGetTokenT< reco::PFTauCollection >
L1TauRecoTreeProducer::LooseIsoToken_
edm::EDGetTokenT< reco::PFTauDiscriminator > LooseIsoToken_
Definition: L1TauRecoTreeProducer.cc:90
PFJetCollection.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EDAnalyzer.h
L1TauRecoTreeProducer::TauToken_
edm::EDGetTokenT< reco::PFTauCollection > TauToken_
Definition: L1TauRecoTreeProducer.cc:85
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
L1TauRecoTreeProducer::maxTrk_
unsigned int maxTrk_
Definition: L1TauRecoTreeProducer.cc:108
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Service.h
L1TauRecoTreeProducer::tree_
TTree * tree_
Definition: L1TauRecoTreeProducer.cc:82
L1TauRecoTreeProducer::beginJob
void beginJob(void) override
Definition: L1TauRecoTreeProducer.cc:279
L1TauRecoTreeProducer::TightAntiMuonToken_
edm::EDGetTokenT< reco::PFTauDiscriminator > TightAntiMuonToken_
Definition: L1TauRecoTreeProducer.cc:92
JetCorrector.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TFileService.h
L1AnalysisRecoMet.h
L1AnalysisRecoTau.h
L1TauRecoTreeProducer
Definition: L1TauRecoTreeProducer.cc:62
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
L1TauRecoTreeProducer::caloJetsMissing_
bool caloJetsMissing_
Definition: L1TauRecoTreeProducer.cc:102
L1Analysis::L1AnalysisRecoTau::getData
L1AnalysisRecoTauDataFormat * getData()
Definition: L1AnalysisRecoTau.h:55
L1TauRecoTreeProducer::period_
std::string period_
Definition: L1TauRecoTreeProducer.cc:105
edm::Service< TFileService >
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
L1TauRecoTreeProducer::maxCl_
unsigned int maxCl_
Definition: L1TauRecoTreeProducer.cc:104
L1TauRecoTreeProducer::TightRawIsoToken_
edm::EDGetTokenT< reco::PFTauDiscriminator > TightRawIsoToken_
Definition: L1TauRecoTreeProducer.cc:89
L1TauRecoTreeProducer::DMFindingToken_
edm::EDGetTokenT< reco::PFTauDiscriminator > DMFindingToken_
Definition: L1TauRecoTreeProducer.cc:86
L1TauRecoTreeProducer::VLooseAntiElectronToken_
edm::EDGetTokenT< reco::PFTauDiscriminator > VLooseAntiElectronToken_
Definition: L1TauRecoTreeProducer.cc:93
L1Analysis::L1AnalysisRecoTau::Reset
void Reset()
Definition: L1AnalysisRecoTau.h:56
L1TauRecoTreeProducer::~L1TauRecoTreeProducer
~L1TauRecoTreeProducer() override
Definition: L1TauRecoTreeProducer.cc:184
L1Analysis::L1AnalysisRecoTau
Definition: L1AnalysisRecoTau.h:24
L1TauRecoTreeProducer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: L1TauRecoTreeProducer.cc:194
Frameworkfwd.h
L1TauRecoTreeProducer::L1TauRecoTreeProducer
L1TauRecoTreeProducer(const edm::ParameterSet &)
Definition: L1TauRecoTreeProducer.cc:111
L1TauRecoTreeProducer::fs_
edm::Service< TFileService > fs_
Definition: L1TauRecoTreeProducer.cc:79
L1TauRecoTreeProducer::maxVtx_
unsigned int maxVtx_
Definition: L1TauRecoTreeProducer.cc:107
PFTau.h
L1Analysis::L1AnalysisRecoTauDataFormat
Definition: L1AnalysisRecoTauDataFormat.h:14
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ParameterSet.h
L1TauRecoTreeProducer::LooseAntiMuonToken_
edm::EDGetTokenT< reco::PFTauDiscriminator > LooseAntiMuonToken_
Definition: L1TauRecoTreeProducer.cc:91
L1TauRecoTreeProducer::maxTau_
unsigned int maxTau_
Definition: L1TauRecoTreeProducer.cc:106
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
L1TauRecoTreeProducer::tau
L1Analysis::L1AnalysisRecoTau * tau
Definition: L1TauRecoTreeProducer.cc:73
L1TauRecoTreeProducer::TightAntiElectronToken_
edm::EDGetTokenT< reco::PFTauDiscriminator > TightAntiElectronToken_
Definition: L1TauRecoTreeProducer.cc:95
edm::InputTag
Definition: InputTag.h:15
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64