test
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_;
110  unsigned int maxTau_;
111  unsigned int maxVtx_;
112  unsigned int maxTrk_;
113 };
114 
115 
116 
118  caloJetsMissing_(false)
119 {
120 
121  period_ = iConfig.getParameter<std::string>("period");
122 
123  if(period_=="2015")
124  {
125  maxTau_ = iConfig.getParameter<unsigned int>("maxTau");
126  TauToken_ = consumes<reco::PFTauCollection>(iConfig.getUntrackedParameter("TauToken",edm::InputTag("hpsPFTauProducer")));
127  DMFindingToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("DMFindingToken",edm::InputTag("hpsPFTauDiscriminationByDecayModeFindingNewDMs")));
128  DMFindingOldToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("DMFindingOldToken",edm::InputTag("hpsPFTauDiscriminationByDecayModeFindingOldDMs")));
129  TightIsoToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("TightIsoToken",edm::InputTag("hpsPFTauDiscriminationByTightIsolation")));
130  LooseIsoToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("LooseIsoToken",edm::InputTag("hpsPFTauDiscriminationByLooseIsolation")));
131  LooseAntiMuonToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("LooseAntiMuonToken",edm::InputTag("hpsPFTauDiscriminationByLooseMuonRejection")));
132  TightAntiMuonToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("TightAntiMuonToken",edm::InputTag("hpsPFTauDiscriminationByTightMuonRejection")));
133  VLooseAntiElectronToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("VLooseAntiElectronToken",edm::InputTag("hpsPFTauDiscriminationByMVA5VLooseElectronRejection")));
134  LooseAntiElectronToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("LooseAntiElectronToken",edm::InputTag("hpsPFTauDiscriminationByMVA5LooseElectronRejection")));
135  TightAntiElectronToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("TightAntiElectronToken",edm::InputTag("hpsPFTauDiscriminationByMVA5TightElectronRejection")));
136  }
137  else if(period_=="2016")
138  {
139  maxTau_ = iConfig.getParameter<unsigned int>("maxTau");
140  TauToken_ = consumes<reco::PFTauCollection>(iConfig.getUntrackedParameter("TauToken",edm::InputTag("hpsPFTauProducer")));
141  DMFindingToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("DMFindingToken",edm::InputTag("hpsPFTauDiscriminationByDecayModeFindingNewDMs")));
142  DMFindingOldToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("DMFindingOldToken",edm::InputTag("hpsPFTauDiscriminationByDecayModeFindingOldDMs")));
143  TightIsoToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("TightIsoToken",edm::InputTag("hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3Hits")));
144  LooseIsoToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("LooseIsoToken",edm::InputTag("hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits")));
145  LooseAntiMuonToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("LooseAntiMuonToken",edm::InputTag("hpsPFTauDiscriminationByLooseMuonRejection3")));
146  TightAntiMuonToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("TightAntiMuonToken",edm::InputTag("hpsPFTauDiscriminationByTightMuonRejection3")));
147  VLooseAntiElectronToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("VLooseAntiElectronToken",edm::InputTag("hpsPFTauDiscriminationByMVA6VLooseElectronRejection")));
148  LooseAntiElectronToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("LooseAntiElectronToken",edm::InputTag("hpsPFTauDiscriminationByMVA6LooseElectronRejection")));
149  TightAntiElectronToken_ = consumes<reco::PFTauDiscriminator>(iConfig.getUntrackedParameter("TightAntiElectronToken",edm::InputTag("hpsPFTauDiscriminationByMVA6TightElectronRejection")));
150  }
151 
152  /*
153  caloJetToken_ = consumes<reco::CaloJetCollection>(iConfig.getUntrackedParameter("caloJetToken",edm::InputTag("ak4CaloJets")));
154  // caloJetIdToken_ = consumes<edm::ValueMap<reco::JetID> >(iConfig.getUntrackedParameter("jetIdToken",edm::InputTag("ak4JetID")));
155  jetCorrectorToken_ = consumes<reco::JetCorrector>(iConfig.getUntrackedParameter<edm::InputTag>("jetCorrToken"));
156 
157  jetptThreshold_ = iConfig.getParameter<double> ("jetptThreshold");
158  maxTau_ = iConfig.getParameter<unsigned int>("maxTau");
159  */
160 
162  tau_data = tau->getData();
163 
164  /*
165  // set up output
166  */
167  tree_=fs_->make<TTree>("TauRecoTree", "TauRecoTree");
168  //tree_=fs_->make<TTree>("JetRecoTree", "JetRecoTree");
169  tree_->Branch("Tau", "L1Analysis::L1AnalysisRecoTauDataFormat", &tau_data, 32000, 3);
170 
171 }
172 
173 
175 {
176 
177  // do anything here that needs to be done at desctruction time
178  // (e.g. close files, deallocate resources etc.)
179 
180 }
181 
182 
183 //
184 // member functions
185 //
186 
187 // ------------ method called to for each event ------------
189 {
190 
191  tau->Reset();
193  iEvent.getByToken(TauToken_, recoTaus);
194 
196  iEvent.getByToken(DMFindingToken_, DMFindingTaus);
197 
198  edm::Handle<reco::PFTauDiscriminator> DMFindingOldTaus;
199  iEvent.getByToken(DMFindingOldToken_, DMFindingOldTaus);
200 
202  iEvent.getByToken(TightIsoToken_, TightIsoTaus);
203 
205  iEvent.getByToken(LooseIsoToken_, LooseIsoTaus);
206 
208  iEvent.getByToken(LooseAntiMuonToken_, LooseAntiMuon);
209 
211  iEvent.getByToken(TightAntiMuonToken_, TightAntiMuon);
212 
213  edm::Handle<reco::PFTauDiscriminator> VLooseAntiElectron;
214  iEvent.getByToken(VLooseAntiElectronToken_, VLooseAntiElectron);
215 
216  edm::Handle<reco::PFTauDiscriminator> LooseAntiElectron;
217  iEvent.getByToken(LooseAntiElectronToken_, LooseAntiElectron);
218 
219  edm::Handle<reco::PFTauDiscriminator> TightAntiElectron;
220  iEvent.getByToken(TightAntiElectronToken_, TightAntiElectron);
221 
222  //std::cout<<"size of recoTaus = "<<recoTaus->size()<<std::endl;
223 
224  if (recoTaus.isValid()) {
225  //std::cout<<"passing here"<<std::endl;
226  tau->SetTau(iEvent, iSetup, recoTaus, DMFindingOldTaus, DMFindingTaus, TightIsoTaus, LooseIsoTaus, LooseAntiMuon, TightAntiMuon, VLooseAntiElectron, LooseAntiElectron, TightAntiElectron, 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  jet->Reset();
235 
236  // get jets & co...
237  edm::Handle<reco::CaloJetCollection> recoCaloJets;
238  edm::Handle<edm::ValueMap<reco::JetID> > jetsID;
239  edm::Handle<reco::JetCorrector> jetCorr;
240 
241  iEvent.getByToken(caloJetToken_, recoCaloJets);
242  //iEvent.getByLabel(jetIdTag_,jetsID);
243  //iEvent.getByToken(jetCorrectorToken_, jetCorr);
244 
245  if (recoCaloJets.isValid()) {
246  jet->SetCaloJet(iEvent, iSetup, recoCaloJets, maxTau_); //jetsID, maxTau_);
247  }
248  else {
249  if (!caloJetsMissing_) {edm::LogWarning("MissingProduct") << "CaloJets not found. Branch will not be filled" << std::endl;}
250  caloJetsMissing_ = true;
251  }
252  */
253 
254  tree_->Fill();
255 
256 }
257 
258 // ------------ method called once each job just before starting event loop ------------
259 void
261 {
262 }
263 
264 // ------------ method called once each job just after ending the event loop ------------
265 void
267 }
268 
269 //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_
L1AnalysisRecoTauDataFormat * getData()
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