Go to the documentation of this file.00001
00002
00003
00004
00005 #include <memory>
00006
00007 #include "TopQuarkAnalysis/TopEventProducers/interface/StEvtSolutionMaker.h"
00008
00009 StEvtSolutionMaker::StEvtSolutionMaker(const edm::ParameterSet& iConfig)
00010 {
00011
00012 electronSrc_ = iConfig.getParameter<edm::InputTag>("electronSource");
00013 muonSrc_ = iConfig.getParameter<edm::InputTag>("muonSource");
00014 metSrc_ = iConfig.getParameter<edm::InputTag>("metSource");
00015 jetSrc_ = iConfig.getParameter<edm::InputTag>("jetSource");
00016 leptonFlavour_ = iConfig.getParameter< std::string >("leptonFlavour");
00017 jetCorrScheme_ = iConfig.getParameter<int> ("jetCorrectionScheme");
00018
00019 doKinFit_ = iConfig.getParameter< bool > ("doKinFit");
00020 addLRJetComb_ = iConfig.getParameter< bool > ("addLRJetComb");
00021 maxNrIter_ = iConfig.getParameter< int > ("maxNrIter");
00022 maxDeltaS_ = iConfig.getParameter< double > ("maxDeltaS");
00023 maxF_ = iConfig.getParameter< double > ("maxF");
00024 jetParam_ = iConfig.getParameter<int> ("jetParametrisation");
00025 lepParam_ = iConfig.getParameter<int> ("lepParametrisation");
00026 metParam_ = iConfig.getParameter<int> ("metParametrisation");
00027 constraints_ = iConfig.getParameter< std::vector<int> > ("constraints");
00028 matchToGenEvt_ = iConfig.getParameter< bool > ("matchToGenEvt");
00029
00030
00031 if(doKinFit_){
00032 myKinFitter = new StKinFitter(jetParam_, lepParam_, metParam_, maxNrIter_, maxDeltaS_, maxF_, constraints_);
00033 }
00034
00035 produces<std::vector<StEvtSolution> >();
00036 }
00037
00038 StEvtSolutionMaker::~StEvtSolutionMaker()
00039 {
00040 if (doKinFit_) delete myKinFitter;
00041 }
00042
00043 void StEvtSolutionMaker::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00044 {
00045
00046
00047
00048
00049
00050 bool leptonFound = false;
00051 edm::Handle<std::vector<pat::Muon> > muons;
00052 if(leptonFlavour_ == "muon"){
00053 iEvent.getByLabel(muonSrc_, muons);
00054 if( muons->size() > 0 ) leptonFound = true;
00055 }
00056 edm::Handle<std::vector<pat::Electron> > electrons;
00057 if(leptonFlavour_ == "electron"){
00058 iEvent.getByLabel(electronSrc_, electrons);
00059 if( electrons->size() > 0 ) leptonFound = true;
00060 }
00061
00062
00063 bool metFound = false;
00064 edm::Handle<std::vector<pat::MET> > mets;
00065 iEvent.getByLabel(metSrc_, mets);
00066 if( mets->size() > 0 ) metFound = true;
00067
00068
00069 bool jetsFound = false;
00070 edm::Handle<std::vector<pat::Jet> > jets;
00071 iEvent.getByLabel(jetSrc_, jets);
00072 unsigned int maxJets=2;
00073 if (jets->size() >= 2) jetsFound = true;
00074
00075 std::vector<StEvtSolution> *evtsols = new std::vector<StEvtSolution>();
00076 if(leptonFound && metFound && jetsFound){
00077 std::cout<<"constructing solutions"<<std::endl;
00078 for (unsigned int b=0; b<maxJets; b++) {
00079 for (unsigned int l=0; l<maxJets; l++) {
00080 if(b!=l){
00081 StEvtSolution asol;
00082 asol.setJetCorrectionScheme(jetCorrScheme_);
00083 if(leptonFlavour_ == "muon") asol.setMuon(muons, 0);
00084 if(leptonFlavour_ == "electron") asol.setElectron(electrons, 0);
00085 asol.setNeutrino(mets, 0);
00086 asol.setBottom(jets, b);
00087 asol.setLight(jets, l);
00088
00089 if(doKinFit_) asol = myKinFitter->addKinFitInfo(&asol);
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 evtsols->push_back(asol);
00100 }
00101 }
00102 }
00103
00104
00105 if(matchToGenEvt_){
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 }
00123
00124
00125 std::auto_ptr<std::vector<StEvtSolution> > pOut(evtsols);
00126 iEvent.put(pOut);
00127 }
00128 else
00129 {
00130
00131 std::cout<<"@@@ No calibrated solutions built, because: " << std::endl;;
00132 if(jets->size()<maxJets) std::cout<<"@ nr jets = " << jets->size() << " < " << maxJets <<std::endl;
00133 if(leptonFlavour_ == "muon" && !leptonFound) std::cout<<"@ no good muon candidate"<<std::endl;
00134 if(leptonFlavour_ == "electron" && !leptonFound) std::cout<<"@ no good electron candidate"<<std::endl;
00135 if(mets->size() == 0) std::cout<<"@ no MET reconstruction"<<std::endl;
00136
00137 StEvtSolution asol;
00138 evtsols->push_back(asol);
00139 std::auto_ptr<std::vector<StEvtSolution> > pOut(evtsols);
00140 iEvent.put(pOut);
00141 }
00142 }