CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TauRecoTreeProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1Trigger/L1TNtuples
4 // Class: L1JetRecoTreeProducer
5 //
14 // system include files
15 #include <memory>
16 
17 // framework
26 
27 // cond formats
29 
30 // data formats
34 
35 
36 //taus
40 
41 // #include "CommonTools/UtilAlgos/interface/PhysObjectMatcher.h"
42 // #include "CommonTools/UtilAlgos/interface/MCMatchSelector.h"
43 // #include "CommonTools/UtilAlgos/interface/DummyMatchSelector.h"
44 // #include "CommonTools/UtilAlgos/interface/MatchByDRDPt.h"
45 // #include "DataFormats/TauReco/interface/PFTauDecayMode.h"
46 // #include "DataFormats/TauReco/interface/PFTauDecayModeFwd.h"
47 // #include "DataFormats/TauReco/interface/PFTau.h"
48 
49 
50 // ROOT output stuff
53 #include "TH1.h"
54 #include "TTree.h"
55 #include "TF1.h"
56 
57 //local data formats
60 
61 //
62 // class declaration
63 //
64 
66 public:
69 
70 
71 private:
72  virtual void beginJob(void) ;
73  virtual void analyze(const edm::Event&, const edm::EventSetup&);
74  virtual void endJob();
75 
76 public:
78 
80 
81 private:
82 
83  // output file
85 
86  // tree
87  TTree * tree_;
88 
89  // EDM input tags
100 
101  // edm::EDGetTokenT<reco::CaloJetCollection> caloJetToken_;
102  // edm::EDGetTokenT<edm::ValueMap<reco::JetID> > caloJetIdToken_;
103  // edm::EDGetTokenT<reco::JetCorrector> jetCorrectorToken_;
104 
105  // debug stuff
108  unsigned int maxCl_;
109  unsigned int maxTau_;
110  unsigned int maxVtx_;
111  unsigned int maxTrk_;
112 };
113 
114 
115 
117  caloJetsMissing_(false)
118 {
119 
120  maxTau_ = iConfig.getParameter<unsigned int>("maxTau");
121  TauToken_ = consumes<reco::PFTauCollection>(iConfig.getUntrackedParameter("TauToken",edm::InputTag("hpsPFTauProducer")));
122  DMFindingToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("DMFindingToken",edm::InputTag("hpsPFTauDiscriminationByDecayModeFindingNewDMs")));
123  DMFindingOldToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("DMFindingOldToken",edm::InputTag("hpsPFTauDiscriminationByDecayModeFindingOldDMs")));
124  TightIsoToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("TightIsoToken",edm::InputTag("hpsPFTauDiscriminationByTightIsolation")));
125  LooseIsoToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("LooseIsoToken",edm::InputTag("hpsPFTauDiscriminationByLooseIsolation")));
126  LooseAntiMuonToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("LooseAntiMuonToken",edm::InputTag("hpsPFTauDiscriminationByLooseMuonRejection")));
127  TightAntiMuonToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("TightAntiMuonToken",edm::InputTag("hpsPFTauDiscriminationByTightMuonRejection")));
128  VLooseAntiElectronToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("VLooseAntiElectronToken",edm::InputTag("hpsPFTauDiscriminationByMVA5VLooseElectronRejection")));
129  LooseAntiElectronToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("LooseAntiElectronToken",edm::InputTag("hpsPFTauDiscriminationByMVA5LooseElectronRejection")));
130  TightAntiElectronToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("TightAntiElectronToken",edm::InputTag("hpsPFTauDiscriminationByMVA5TightElectronRejection")));
131 
132  /*
133  caloJetToken_ = consumes<reco::CaloJetCollection>(iConfig.getUntrackedParameter("caloJetToken",edm::InputTag("ak4CaloJets")));
134  // caloJetIdToken_ = consumes<edm::ValueMap<reco::JetID> >(iConfig.getUntrackedParameter("jetIdToken",edm::InputTag("ak4JetID")));
135  jetCorrectorToken_ = consumes<reco::JetCorrector>(iConfig.getUntrackedParameter<edm::InputTag>("jetCorrToken"));
136 
137  jetptThreshold_ = iConfig.getParameter<double> ("jetptThreshold");
138  maxTau_ = iConfig.getParameter<unsigned int>("maxTau");
139  */
140 
142  tau_data = tau->getData();
143 
144  /*
145  // set up output
146  */
147  tree_=fs_->make<TTree>("TauRecoTree", "TauRecoTree");
148  //tree_=fs_->make<TTree>("JetRecoTree", "JetRecoTree");
149  tree_->Branch("Tau", "L1Analysis::L1AnalysisRecoTauDataFormat", &tau_data, 32000, 3);
150 
151 }
152 
153 
155 {
156 
157  // do anything here that needs to be done at desctruction time
158  // (e.g. close files, deallocate resources etc.)
159 
160 }
161 
162 
163 //
164 // member functions
165 //
166 
167 // ------------ method called to for each event ------------
169 {
170 
171  tau->Reset();
173  iEvent.getByToken(TauToken_, recoTaus);
174 
176  iEvent.getByToken(DMFindingToken_, DMFindingTaus);
177 
178  edm::Handle<reco::PFTauDiscriminator> DMFindingOldTaus;
179  iEvent.getByToken(DMFindingOldToken_, DMFindingOldTaus);
180 
182  iEvent.getByToken(TightIsoToken_, TightIsoTaus);
183 
185  iEvent.getByToken(LooseIsoToken_, LooseIsoTaus);
186 
188  iEvent.getByToken(LooseAntiMuonToken_, LooseAntiMuon);
189 
191  iEvent.getByToken(TightAntiMuonToken_, TightAntiMuon);
192 
193  edm::Handle<reco::PFTauDiscriminator> VLooseAntiElectron;
194  iEvent.getByToken(VLooseAntiElectronToken_, VLooseAntiElectron);
195 
196  edm::Handle<reco::PFTauDiscriminator> LooseAntiElectron;
197  iEvent.getByToken(LooseAntiElectronToken_, LooseAntiElectron);
198 
199  edm::Handle<reco::PFTauDiscriminator> TightAntiElectron;
200  iEvent.getByToken(TightAntiElectronToken_, TightAntiElectron);
201 
202  //std::cout<<"size of recoTaus = "<<recoTaus->size()<<std::endl;
203 
204  if (recoTaus.isValid()) {
205  //std::cout<<"passing here"<<std::endl;
206  tau->SetTau(iEvent, iSetup, recoTaus, DMFindingOldTaus, DMFindingTaus, TightIsoTaus, LooseIsoTaus, LooseAntiMuon, TightAntiMuon, VLooseAntiElectron, LooseAntiElectron, TightAntiElectron, maxTau_);
207  }
208  else {
209  if (!caloJetsMissing_) {edm::LogWarning("MissingProduct") << "CaloJets not found. Branch will not be filled" << std::endl;}
210  caloJetsMissing_ = true;
211  }
212 
213  /*
214  jet->Reset();
215 
216  // get jets & co...
217  edm::Handle<reco::CaloJetCollection> recoCaloJets;
218  edm::Handle<edm::ValueMap<reco::JetID> > jetsID;
219  edm::Handle<reco::JetCorrector> jetCorr;
220 
221  iEvent.getByToken(caloJetToken_, recoCaloJets);
222  //iEvent.getByLabel(jetIdTag_,jetsID);
223  //iEvent.getByToken(jetCorrectorToken_, jetCorr);
224 
225  if (recoCaloJets.isValid()) {
226  jet->SetCaloJet(iEvent, iSetup, recoCaloJets, maxTau_); //jetsID, maxTau_);
227  }
228  else {
229  if (!caloJetsMissing_) {edm::LogWarning("MissingProduct") << "CaloJets not found. Branch will not be filled" << std::endl;}
230  caloJetsMissing_ = true;
231  }
232  */
233 
234  tree_->Fill();
235 
236 }
237 
238 // ------------ method called once each job just before starting event loop ------------
239 void
241 {
242 }
243 
244 // ------------ method called once each job just after ending the event loop ------------
245 void
247 }
248 
249 //define this as a plug-in
edm::EDGetTokenT< reco::PFTauDiscriminator > TightAntiMuonToken_
T getParameter(std::string const &) const
L1Analysis::L1AnalysisRecoTauDataFormat * tau_data
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::PFTauDiscriminator > VLooseAntiElectronToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
edm::EDGetTokenT< reco::PFTauDiscriminator > LooseIsoToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::EDGetTokenT< reco::PFTauDiscriminator > TightIsoToken_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
edm::EDGetTokenT< reco::PFTauDiscriminator > DMFindingToken_
L1Analysis::L1AnalysisRecoTau * tau
edm::EDGetTokenT< reco::PFTauDiscriminator > DMFindingOldToken_
edm::EDGetTokenT< reco::PFTauDiscriminator > TightAntiElectronToken_
int iEvent
Definition: GenABIO.cc:230
L1TauRecoTreeProducer(const edm::ParameterSet &)
edm::EDGetTokenT< reco::PFTauCollection > TauToken_
edm::EDGetTokenT< reco::PFTauDiscriminator > LooseAntiElectronToken_
virtual void analyze(const edm::Event &, const edm::EventSetup &)
bool isValid() const
Definition: HandleBase.h:75
edm::EDGetTokenT< reco::PFTauDiscriminator > LooseAntiMuonToken_
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 > 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)
edm::Service< TFileService > fs_
volatile std::atomic< bool > shutdown_flag false