CMS 3D CMS Logo

Public Member Functions | Private Attributes

StEvtSolutionMaker Class Reference

#include <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< int > constraints_
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.

{
  // configurables
  electronSrc_    = iConfig.getParameter<edm::InputTag>("electronSource");
  muonSrc_        = iConfig.getParameter<edm::InputTag>("muonSource");
  metSrc_         = iConfig.getParameter<edm::InputTag>("metSource");
  jetSrc_         = iConfig.getParameter<edm::InputTag>("jetSource");
  leptonFlavour_  = iConfig.getParameter< std::string >("leptonFlavour");
  jetCorrScheme_  = iConfig.getParameter<int>          ("jetCorrectionScheme");
  //jetInput_        = iConfig.getParameter< std::string >        ("jetInput");
  doKinFit_       = iConfig.getParameter< bool >       ("doKinFit");
  addLRJetComb_   = iConfig.getParameter< bool >       ("addLRJetComb");
  maxNrIter_      = iConfig.getParameter< int >        ("maxNrIter");
  maxDeltaS_      = iConfig.getParameter< double >     ("maxDeltaS");
  maxF_           = iConfig.getParameter< double >     ("maxF");
  jetParam_       = iConfig.getParameter<int>          ("jetParametrisation");
  lepParam_       = iConfig.getParameter<int>          ("lepParametrisation");
  metParam_       = iConfig.getParameter<int>          ("metParametrisation");
  constraints_    = iConfig.getParameter< std::vector<int> > ("constraints");
  matchToGenEvt_  = iConfig.getParameter< bool >        ("matchToGenEvt");
  
  // define kinfitter
  if(doKinFit_){
    myKinFitter = new StKinFitter(jetParam_, lepParam_, metParam_, maxNrIter_, maxDeltaS_, maxF_, constraints_);
  }
  // define what will be produced
  produces<std::vector<StEvtSolution> >();
}
StEvtSolutionMaker::~StEvtSolutionMaker ( )

Definition at line 38 of file StEvtSolutionMaker.cc.

References doKinFit_, and myKinFitter.

{
  if (doKinFit_) delete myKinFitter;
}

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, gather_cfg::cout, doKinFit_, HI_PhotonSkim_cff::electrons, electronSrc_, edm::Event::getByLabel(), jetCorrScheme_, analyzePatCleaning_cfg::jets, jetSrc_, prof2calltree::l, leptonFlavour_, matchToGenEvt_, metSrc_, patZpeak::muons, muonSrc_, myKinFitter, edm::Event::put(), StEvtSolution::setBottom(), StEvtSolution::setElectron(), StEvtSolution::setJetCorrectionScheme(), StEvtSolution::setLight(), StEvtSolution::setMuon(), and StEvtSolution::setNeutrino().

{
  //
  //  TopObject Selection
  //
  
  // select lepton (the TtLepton vectors are, for the moment, sorted on pT)
  bool leptonFound = false;
  edm::Handle<std::vector<pat::Muon> > muons;
  if(leptonFlavour_ == "muon"){
    iEvent.getByLabel(muonSrc_, muons);
    if( muons->size() > 0 ) leptonFound = true;
  }
  edm::Handle<std::vector<pat::Electron> > electrons;
  if(leptonFlavour_ == "electron"){
    iEvent.getByLabel(electronSrc_, electrons);
    if( electrons->size() > 0 ) leptonFound = true;
  }
  
  // select MET (TopMET vector is sorted on ET)
  bool metFound = false;
  edm::Handle<std::vector<pat::MET> > mets;
  iEvent.getByLabel(metSrc_, mets);
  if( mets->size() > 0 ) metFound = true;
  
  // select Jets
  bool jetsFound = false;
  edm::Handle<std::vector<pat::Jet> > jets;
  iEvent.getByLabel(jetSrc_, jets);
  unsigned int maxJets=2;//this has to become a custom-defined parameter (we may want 2 or 3 jets)
  if (jets->size() >= 2) jetsFound = true;
  
  std::vector<StEvtSolution> *evtsols = new std::vector<StEvtSolution>();
  if(leptonFound && metFound && jetsFound){
    std::cout<<"constructing solutions"<<std::endl;
    for (unsigned int b=0; b<maxJets; b++) {
      for (unsigned int l=0; l<maxJets; l++) {
        if(b!=l){  // to avoid double counting
          StEvtSolution asol;
          asol.setJetCorrectionScheme(jetCorrScheme_);
          if(leptonFlavour_ == "muon")     asol.setMuon(muons, 0);
          if(leptonFlavour_ == "electron") asol.setElectron(electrons, 0);
          asol.setNeutrino(mets, 0);
          asol.setBottom(jets, b);
          asol.setLight(jets, l);
          
          if(doKinFit_) asol = myKinFitter->addKinFitInfo(&asol);
          
          /* to be adapted to ST (Andrea)
             if(addLRJetComb_){
             asol.setPtrueCombExist(jetCombProbs[m].getPTrueCombExist(&afitsol));
             asol.setPtrueBJetSel(jetCombProbs[m].getPTrueBJetSel(&afitsol));
             asol.setPtrueBhadrSel(jetCombProbs[m].getPTrueBhadrSel(&afitsol));
             asol.setPtrueJetComb(afitsol.getPtrueCombExist()*afitsol.getPtrueBJetSel()*afitsol.getPtrueBhadrSel());
             }
          */
          evtsols->push_back(asol);
        }
      }
    }
    
    // if asked for, match the event solutions to the gen Event
    if(matchToGenEvt_){
      /*
        edm::Handle<StGenEvent> genEvt;
        iEvent.getByLabel ("genEvt",genEvt);
        double bestSolDR = 9999.;
        int bestSol = 0;
        for(size_t s=0; s<evtsols->size(); s++) {
        (*evtsols)[s].setGenEvt(genEvt->particles());
        vector<double> bm = BestMatch((*evtsols)[s], false); //false to use DR, true SpaceAngles
        (*evtsols)[s].setSumDeltaRjp(bm[0]); // dRBB + dRLL
        (*evtsols)[s].setChangeBL((int) bm[1]); // has swapped or not
        (*evtsols)[s].setDeltaRB(bm[2]);
        (*evtsols)[s].setDeltaRL(bm[3]);
        if(bm[0]<bestSolDR) { bestSolDR =  bm[0]; bestSol = s; }
        }
        (*evtsols)[bestSol].setBestSol(true);
      */
    }
    
    //store the vector of solutions to the event     
    std::auto_ptr<std::vector<StEvtSolution> > pOut(evtsols);
    iEvent.put(pOut);
  }
  else
    {
      
      std::cout<<"@@@ No calibrated solutions built, because:  " << std::endl;;
      if(jets->size()<maxJets)                                    std::cout<<"@ nr jets = " << jets->size() << " < " << maxJets <<std::endl;
      if(leptonFlavour_ == "muon" && !leptonFound)                std::cout<<"@ no good muon candidate"<<std::endl;
      if(leptonFlavour_ == "electron" && !leptonFound)             std::cout<<"@ no good electron candidate"<<std::endl;
      if(mets->size() == 0)                                       std::cout<<"@ no MET reconstruction"<<std::endl;
      
      StEvtSolution asol;
      evtsols->push_back(asol);
      std::auto_ptr<std::vector<StEvtSolution> > pOut(evtsols);
      iEvent.put(pOut);
    }
}

Member Data Documentation

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().

Definition at line 36 of file StEvtSolutionMaker.h.

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

Definition at line 28 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

Definition at line 33 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

Definition at line 39 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

Definition at line 31 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

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().

Definition at line 36 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

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().

Definition at line 37 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

Definition at line 39 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

Definition at line 30 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

Definition at line 29 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

Definition at line 26 of file StEvtSolutionMaker.h.

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