CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
StEvtSolutionMaker Class Reference

#include <StEvtSolutionMaker.h>

Inheritance diagram for StEvtSolutionMaker:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)
 
 StEvtSolutionMaker (const edm::ParameterSet &)
 
 ~StEvtSolutionMaker ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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_, myKinFitter, and AlCaHLTBitMon_QueryRunRegistry::string.

10 {
11  // configurables
12  electronSrc_ = iConfig.getParameter<edm::InputTag>("electronSource");
13  muonSrc_ = iConfig.getParameter<edm::InputTag>("muonSource");
14  metSrc_ = iConfig.getParameter<edm::InputTag>("metSource");
15  jetSrc_ = iConfig.getParameter<edm::InputTag>("jetSource");
16  leptonFlavour_ = iConfig.getParameter< std::string >("leptonFlavour");
17  jetCorrScheme_ = iConfig.getParameter<int> ("jetCorrectionScheme");
18  //jetInput_ = iConfig.getParameter< std::string > ("jetInput");
19  doKinFit_ = iConfig.getParameter< bool > ("doKinFit");
20  addLRJetComb_ = iConfig.getParameter< bool > ("addLRJetComb");
21  maxNrIter_ = iConfig.getParameter< int > ("maxNrIter");
22  maxDeltaS_ = iConfig.getParameter< double > ("maxDeltaS");
23  maxF_ = iConfig.getParameter< double > ("maxF");
24  jetParam_ = iConfig.getParameter<int> ("jetParametrisation");
25  lepParam_ = iConfig.getParameter<int> ("lepParametrisation");
26  metParam_ = iConfig.getParameter<int> ("metParametrisation");
27  constraints_ = iConfig.getParameter< std::vector<int> > ("constraints");
28  matchToGenEvt_ = iConfig.getParameter< bool > ("matchToGenEvt");
29 
30  // define kinfitter
31  if(doKinFit_){
32  myKinFitter = new StKinFitter(jetParam_, lepParam_, metParam_, maxNrIter_, maxDeltaS_, maxF_, constraints_);
33  }
34  // define what will be produced
35  produces<std::vector<StEvtSolution> >();
36 }
T getParameter(std::string const &) const
edm::InputTag electronSrc_
StKinFitter * myKinFitter
std::string leptonFlavour_
std::vector< int > constraints_
edm::InputTag muonSrc_
StEvtSolutionMaker::~StEvtSolutionMaker ( )

Definition at line 38 of file StEvtSolutionMaker.cc.

References doKinFit_, and myKinFitter.

39 {
40  if (doKinFit_) delete myKinFitter;
41 }
StKinFitter * 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_, fwrapper::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().

44 {
45  //
46  // TopObject Selection
47  //
48 
49  // select lepton (the TtLepton vectors are, for the moment, sorted on pT)
50  bool leptonFound = false;
52  if(leptonFlavour_ == "muon"){
53  iEvent.getByLabel(muonSrc_, muons);
54  if( muons->size() > 0 ) leptonFound = true;
55  }
57  if(leptonFlavour_ == "electron"){
58  iEvent.getByLabel(electronSrc_, electrons);
59  if( electrons->size() > 0 ) leptonFound = true;
60  }
61 
62  // select MET (TopMET vector is sorted on ET)
63  bool metFound = false;
65  iEvent.getByLabel(metSrc_, mets);
66  if( mets->size() > 0 ) metFound = true;
67 
68  // select Jets
69  bool jetsFound = false;
71  iEvent.getByLabel(jetSrc_, jets);
72  unsigned int maxJets=2;//this has to become a custom-defined parameter (we may want 2 or 3 jets)
73  if (jets->size() >= 2) jetsFound = true;
74 
75  std::vector<StEvtSolution> *evtsols = new std::vector<StEvtSolution>();
76  if(leptonFound && metFound && jetsFound){
77  std::cout<<"constructing solutions"<<std::endl;
78  for (unsigned int b=0; b<maxJets; b++) {
79  for (unsigned int l=0; l<maxJets; l++) {
80  if(b!=l){ // to avoid double counting
81  StEvtSolution asol;
83  if(leptonFlavour_ == "muon") asol.setMuon(muons, 0);
84  if(leptonFlavour_ == "electron") asol.setElectron(electrons, 0);
85  asol.setNeutrino(mets, 0);
86  asol.setBottom(jets, b);
87  asol.setLight(jets, l);
88 
89  if(doKinFit_) asol = myKinFitter->addKinFitInfo(&asol);
90 
91  /* to be adapted to ST (Andrea)
92  if(addLRJetComb_){
93  asol.setPtrueCombExist(jetCombProbs[m].getPTrueCombExist(&afitsol));
94  asol.setPtrueBJetSel(jetCombProbs[m].getPTrueBJetSel(&afitsol));
95  asol.setPtrueBhadrSel(jetCombProbs[m].getPTrueBhadrSel(&afitsol));
96  asol.setPtrueJetComb(afitsol.getPtrueCombExist()*afitsol.getPtrueBJetSel()*afitsol.getPtrueBhadrSel());
97  }
98  */
99  evtsols->push_back(asol);
100  }
101  }
102  }
103 
104  // if asked for, match the event solutions to the gen Event
105  if(matchToGenEvt_){
106  /*
107  edm::Handle<StGenEvent> genEvt;
108  iEvent.getByLabel ("genEvt",genEvt);
109  double bestSolDR = 9999.;
110  int bestSol = 0;
111  for(size_t s=0; s<evtsols->size(); s++) {
112  (*evtsols)[s].setGenEvt(genEvt->particles());
113  vector<double> bm = BestMatch((*evtsols)[s], false); //false to use DR, true SpaceAngles
114  (*evtsols)[s].setSumDeltaRjp(bm[0]); // dRBB + dRLL
115  (*evtsols)[s].setChangeBL((int) bm[1]); // has swapped or not
116  (*evtsols)[s].setDeltaRB(bm[2]);
117  (*evtsols)[s].setDeltaRL(bm[3]);
118  if(bm[0]<bestSolDR) { bestSolDR = bm[0]; bestSol = s; }
119  }
120  (*evtsols)[bestSol].setBestSol(true);
121  */
122  }
123 
124  //store the vector of solutions to the event
125  std::auto_ptr<std::vector<StEvtSolution> > pOut(evtsols);
126  iEvent.put(pOut);
127  }
128  else
129  {
130 
131  std::cout<<"@@@ No calibrated solutions built, because: " << std::endl;;
132  if(jets->size()<maxJets) std::cout<<"@ nr jets = " << jets->size() << " < " << maxJets <<std::endl;
133  if(leptonFlavour_ == "muon" && !leptonFound) std::cout<<"@ no good muon candidate"<<std::endl;
134  if(leptonFlavour_ == "electron" && !leptonFound) std::cout<<"@ no good electron candidate"<<std::endl;
135  if(mets->size() == 0) std::cout<<"@ no MET reconstruction"<<std::endl;
136 
137  StEvtSolution asol;
138  evtsols->push_back(asol);
139  std::auto_ptr<std::vector<StEvtSolution> > pOut(evtsols);
140  iEvent.put(pOut);
141  }
142 }
edm::InputTag electronSrc_
void setMuon(const edm::Handle< std::vector< pat::Muon > > &muon, int i)
StKinFitter * myKinFitter
void setLight(const edm::Handle< std::vector< pat::Jet > > &jet, int i)
void setNeutrino(const edm::Handle< std::vector< pat::MET > > &met, int i)
std::string leptonFlavour_
edm::InputTag muonSrc_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
vector< PseudoJet > jets
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
void setJetCorrectionScheme(int scheme)
double b
Definition: hdecay.h:120
void setBottom(const edm::Handle< std::vector< pat::Jet > > &jet, int i)
tuple muons
Definition: patZpeak.py:38
StEvtSolution addKinFitInfo(StEvtSolution *asol)
Definition: StKinFitter.cc:65
tuple cout
Definition: gather_cfg.py:121
void setElectron(const edm::Handle< std::vector< pat::Electron > > &elec, int i)

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