CMS 3D CMS Logo

StEvtSolutionMaker Class Reference

#include <TopQuarkAnalysis/TopEventProducers/interface/StEvtSolutionMaker.h>

Inheritance diagram for StEvtSolutionMaker:

edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)
 StEvtSolutionMaker (const edm::ParameterSet &)
 ~StEvtSolutionMaker ()

Private Attributes

bool addLRJetComb_
std::vector< intconstraints_
bool doKinFit_
edm::InputTag electronSrc_
int jetCorrScheme_
int jetParam_
edm::InputTag jetSrc_
int lepParam_
std::string leptonFlavour_
bool matchToGenEvt_
double maxDeltaS_
double maxF_
int maxNrIter_
int metParam_
edm::InputTag metSrc_
edm::InputTag muonSrc_
StKinFittermyKinFitter


Detailed Description

Definition at line 16 of file StEvtSolutionMaker.h.


Constructor & Destructor Documentation

StEvtSolutionMaker::StEvtSolutionMaker ( const edm::ParameterSet iConfig  )  [explicit]

Definition at line 9 of file StEvtSolutionMaker.cc.

References addLRJetComb_, constraints_, doKinFit_, electronSrc_, edm::ParameterSet::getParameter(), jetCorrScheme_, jetParam_, jetSrc_, lepParam_, leptonFlavour_, matchToGenEvt_, maxDeltaS_, maxF_, maxNrIter_, metParam_, metSrc_, muonSrc_, and myKinFitter.

00010 {
00011   // configurables
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   //jetInput_        = iConfig.getParameter< std::string >        ("jetInput");
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   // define kinfitter
00031   if(doKinFit_){
00032     myKinFitter = new StKinFitter(jetParam_, lepParam_, metParam_, maxNrIter_, maxDeltaS_, maxF_, constraints_);
00033   }
00034   // define what will be produced
00035   produces<std::vector<StEvtSolution> >();
00036 }

StEvtSolutionMaker::~StEvtSolutionMaker (  ) 

Definition at line 38 of file StEvtSolutionMaker.cc.

References doKinFit_, and myKinFitter.

00039 {
00040   if (doKinFit_) delete myKinFitter;
00041 }


Member Function Documentation

void StEvtSolutionMaker::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 43 of file StEvtSolutionMaker.cc.

References StKinFitter::addKinFitInfo(), b, GenMuonPlsPt100GeV_cfg::cout, doKinFit_, electronSrc_, lat::endl(), edm::Event::getByLabel(), jetCorrScheme_, pfTauBenchmarkGeneric_cfi::jets, jetSrc_, edm::es::l(), leptonFlavour_, matchToGenEvt_, metSrc_, muons_cfi::muons, muonSrc_, myKinFitter, edm::Event::put(), StEvtSolution::setBottom(), StEvtSolution::setElectron(), StEvtSolution::setJetCorrectionScheme(), StEvtSolution::setLight(), StEvtSolution::setMuon(), and StEvtSolution::setNeutrino().

00044 {
00045   //
00046   //  TopObject Selection
00047   //
00048   
00049   // select lepton (the TtLepton vectors are, for the moment, sorted on pT)
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   // select MET (TopMET vector is sorted on ET)
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   // select Jets
00069   bool jetsFound = false;
00070   edm::Handle<std::vector<pat::Jet> > jets;
00071   iEvent.getByLabel(jetSrc_, jets);
00072   unsigned int maxJets=2;//this has to become a custom-defined parameter (we may want 2 or 3 jets)
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){  // to avoid double counting
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           /* to be adapted to ST (Andrea)
00092              if(addLRJetComb_){
00093              asol.setPtrueCombExist(jetCombProbs[m].getPTrueCombExist(&afitsol));
00094              asol.setPtrueBJetSel(jetCombProbs[m].getPTrueBJetSel(&afitsol));
00095              asol.setPtrueBhadrSel(jetCombProbs[m].getPTrueBhadrSel(&afitsol));
00096              asol.setPtrueJetComb(afitsol.getPtrueCombExist()*afitsol.getPtrueBJetSel()*afitsol.getPtrueBhadrSel());
00097              }
00098           */
00099           evtsols->push_back(asol);
00100         }
00101       }
00102     }
00103     
00104     // if asked for, match the event solutions to the gen Event
00105     if(matchToGenEvt_){
00106       /*
00107         edm::Handle<StGenEvent> genEvt;
00108         iEvent.getByLabel ("genEvt",genEvt);
00109         double bestSolDR = 9999.;
00110         int bestSol = 0;
00111         for(size_t s=0; s<evtsols->size(); s++) {
00112         (*evtsols)[s].setGenEvt(genEvt->particles());
00113         vector<double> bm = BestMatch((*evtsols)[s], false); //false to use DR, true SpaceAngles
00114         (*evtsols)[s].setSumDeltaRjp(bm[0]); // dRBB + dRLL
00115         (*evtsols)[s].setChangeBL((int) bm[1]); // has swapped or not
00116         (*evtsols)[s].setDeltaRB(bm[2]);
00117         (*evtsols)[s].setDeltaRL(bm[3]);
00118         if(bm[0]<bestSolDR) { bestSolDR =  bm[0]; bestSol = s; }
00119         }
00120         (*evtsols)[bestSol].setBestSol(true);
00121       */
00122     }
00123     
00124     //store the vector of solutions to the event     
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 }


Member Data Documentation

bool StEvtSolutionMaker::addLRJetComb_ [private]

Definition at line 36 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

std::vector<int> StEvtSolutionMaker::constraints_ [private]

Definition at line 40 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

bool StEvtSolutionMaker::doKinFit_ [private]

Definition at line 36 of file StEvtSolutionMaker.h.

Referenced by produce(), StEvtSolutionMaker(), and ~StEvtSolutionMaker().

edm::InputTag StEvtSolutionMaker::electronSrc_ [private]

Definition at line 28 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

int StEvtSolutionMaker::jetCorrScheme_ [private]

Definition at line 33 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

int StEvtSolutionMaker::jetParam_ [private]

Definition at line 39 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

edm::InputTag StEvtSolutionMaker::jetSrc_ [private]

Definition at line 31 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

int StEvtSolutionMaker::lepParam_ [private]

Definition at line 39 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

std::string StEvtSolutionMaker::leptonFlavour_ [private]

Definition at line 32 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

bool StEvtSolutionMaker::matchToGenEvt_ [private]

Definition at line 36 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

double StEvtSolutionMaker::maxDeltaS_ [private]

Definition at line 38 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

double StEvtSolutionMaker::maxF_ [private]

Definition at line 38 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

int StEvtSolutionMaker::maxNrIter_ [private]

Definition at line 37 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

int StEvtSolutionMaker::metParam_ [private]

Definition at line 39 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

edm::InputTag StEvtSolutionMaker::metSrc_ [private]

Definition at line 30 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

edm::InputTag StEvtSolutionMaker::muonSrc_ [private]

Definition at line 29 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

StKinFitter* StEvtSolutionMaker::myKinFitter [private]

Definition at line 26 of file StEvtSolutionMaker.h.

Referenced by produce(), StEvtSolutionMaker(), and ~StEvtSolutionMaker().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:32:50 2009 for CMSSW by  doxygen 1.5.4