test
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 ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

bool addLRJetComb_
 
std::vector< int > constraints_
 
bool doKinFit_
 
edm::EDGetTokenT< std::vector
< pat::Electron > > 
electronSrcToken_
 
edm::EDGetTokenT< StGenEventgenEvtSrcToken_
 
int jetCorrScheme_
 
int jetParam_
 
edm::EDGetTokenT< std::vector
< pat::Jet > > 
jetSrcToken_
 
int lepParam_
 
std::string leptonFlavour_
 
bool matchToGenEvt_
 
double maxDeltaS_
 
double maxF_
 
int maxNrIter_
 
int metParam_
 
edm::EDGetTokenT< std::vector
< pat::MET > > 
metSrcToken_
 
edm::EDGetTokenT< std::vector
< pat::Muon > > 
muonSrcToken_
 
StKinFittermyKinFitter
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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::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 8 of file StEvtSolutionMaker.cc.

References addLRJetComb_, constraints_, doKinFit_, electronSrcToken_, genEvtSrcToken_, edm::ParameterSet::getParameter(), HLT_25ns10e33_v2_cff::InputTag, jetCorrScheme_, jetParam_, jetSrcToken_, lepParam_, leptonFlavour_, matchToGenEvt_, maxDeltaS_, maxF_, maxNrIter_, metParam_, metSrcToken_, muonSrcToken_, myKinFitter, and AlCaHLTBitMon_QueryRunRegistry::string.

9 {
10  // configurables
11  electronSrcToken_ = mayConsume<std::vector<pat::Electron> >(iConfig.getParameter<edm::InputTag>("electronSource"));
12  muonSrcToken_ = mayConsume<std::vector<pat::Muon> >(iConfig.getParameter<edm::InputTag>("muonSource"));
13  metSrcToken_ = consumes<std::vector<pat::MET> >(iConfig.getParameter<edm::InputTag>("metSource"));
14  jetSrcToken_ = consumes<std::vector<pat::Jet> >(iConfig.getParameter<edm::InputTag>("jetSource"));
15  genEvtSrcToken_ = mayConsume<StGenEvent>(edm::InputTag("genEvt"));
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_){
33  }
34  // define what will be produced
35  produces<std::vector<StEvtSolution> >();
36 }
T getParameter(std::string const &) const
StKinFitter * myKinFitter
std::string leptonFlavour_
edm::EDGetTokenT< std::vector< pat::Jet > > jetSrcToken_
std::vector< int > constraints_
edm::EDGetTokenT< std::vector< pat::Muon > > muonSrcToken_
edm::EDGetTokenT< StGenEvent > genEvtSrcToken_
edm::EDGetTokenT< std::vector< pat::Electron > > electronSrcToken_
edm::EDGetTokenT< std::vector< pat::MET > > metSrcToken_
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, electronSrcToken_, edm::Event::getByToken(), jetCorrScheme_, fwrapper::jets, jetSrcToken_, cmsLHEtoEOSManager::l, leptonFlavour_, matchToGenEvt_, metSrcToken_, patZpeak::muons, muonSrcToken_, 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.getByToken(muonSrcToken_, muons);
54  if( muons->size() > 0 ) leptonFound = true;
55  }
57  if(leptonFlavour_ == "electron"){
58  iEvent.getByToken(electronSrcToken_, 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.getByToken(metSrcToken_, mets);
66  if( mets->size() > 0 ) metFound = true;
67 
68  // select Jets
69  bool jetsFound = false;
71  iEvent.getByToken(jetSrcToken_, 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.getByToken (genEvtSrcToken_,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 }
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)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
void setNeutrino(const edm::Handle< std::vector< pat::MET > > &met, int i)
std::string leptonFlavour_
edm::EDGetTokenT< std::vector< pat::Jet > > jetSrcToken_
edm::EDGetTokenT< std::vector< pat::Muon > > muonSrcToken_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
vector< PseudoJet > jets
edm::EDGetTokenT< std::vector< pat::Electron > > electronSrcToken_
edm::EDGetTokenT< std::vector< pat::MET > > metSrcToken_
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:64
tuple cout
Definition: gather_cfg.py:145
void setElectron(const edm::Handle< std::vector< pat::Electron > > &elec, int i)

Member Data Documentation

bool StEvtSolutionMaker::addLRJetComb_
private

Definition at line 37 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

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

Definition at line 41 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

bool StEvtSolutionMaker::doKinFit_
private

Definition at line 37 of file StEvtSolutionMaker.h.

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

edm::EDGetTokenT<std::vector<pat::Electron> > StEvtSolutionMaker::electronSrcToken_
private

Definition at line 28 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

edm::EDGetTokenT<StGenEvent> StEvtSolutionMaker::genEvtSrcToken_
private

Definition at line 32 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

int StEvtSolutionMaker::jetCorrScheme_
private

Definition at line 34 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

int StEvtSolutionMaker::jetParam_
private

Definition at line 40 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

edm::EDGetTokenT<std::vector<pat::Jet> > StEvtSolutionMaker::jetSrcToken_
private

Definition at line 31 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

int StEvtSolutionMaker::lepParam_
private

Definition at line 40 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

std::string StEvtSolutionMaker::leptonFlavour_
private

Definition at line 33 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

bool StEvtSolutionMaker::matchToGenEvt_
private

Definition at line 37 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

double StEvtSolutionMaker::maxDeltaS_
private

Definition at line 39 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

double StEvtSolutionMaker::maxF_
private

Definition at line 39 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

int StEvtSolutionMaker::maxNrIter_
private

Definition at line 38 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

int StEvtSolutionMaker::metParam_
private

Definition at line 40 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

edm::EDGetTokenT<std::vector<pat::MET> > StEvtSolutionMaker::metSrcToken_
private

Definition at line 30 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

edm::EDGetTokenT<std::vector<pat::Muon> > StEvtSolutionMaker::muonSrcToken_
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().