CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
StEvtSolutionMaker Class Reference
Inheritance diagram for StEvtSolutionMaker:
edm::stream::EDProducer<>

Public Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 
 StEvtSolutionMaker (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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_
 
std::unique_ptr< StKinFittermyKinFitter
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 17 of file StEvtSolutionMaker.cc.

Constructor & Destructor Documentation

◆ StEvtSolutionMaker()

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

Definition at line 41 of file StEvtSolutionMaker.cc.

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

41  {
42  // configurables
43  leptonFlavour_ = iConfig.getParameter<std::string>("leptonFlavour");
44  if (leptonFlavour_ == "electron") {
45  electronSrcToken_ = consumes<std::vector<pat::Electron>>(iConfig.getParameter<edm::InputTag>("electronSource"));
46  } else if (leptonFlavour_ == "muon") {
47  muonSrcToken_ = consumes<std::vector<pat::Muon>>(iConfig.getParameter<edm::InputTag>("muonSource"));
48  }
49  metSrcToken_ = consumes<std::vector<pat::MET>>(iConfig.getParameter<edm::InputTag>("metSource"));
50  jetSrcToken_ = consumes<std::vector<pat::Jet>>(iConfig.getParameter<edm::InputTag>("jetSource"));
51  genEvtSrcToken_ = mayConsume<StGenEvent>(edm::InputTag("genEvt"));
52  jetCorrScheme_ = iConfig.getParameter<int>("jetCorrectionScheme");
53  //jetInput_ = iConfig.getParameter< std::string > ("jetInput");
54  doKinFit_ = iConfig.getParameter<bool>("doKinFit");
55  addLRJetComb_ = iConfig.getParameter<bool>("addLRJetComb");
56  maxNrIter_ = iConfig.getParameter<int>("maxNrIter");
57  maxDeltaS_ = iConfig.getParameter<double>("maxDeltaS");
58  maxF_ = iConfig.getParameter<double>("maxF");
59  jetParam_ = iConfig.getParameter<int>("jetParametrisation");
60  lepParam_ = iConfig.getParameter<int>("lepParametrisation");
61  metParam_ = iConfig.getParameter<int>("metParametrisation");
62  constraints_ = iConfig.getParameter<std::vector<int>>("constraints");
63  matchToGenEvt_ = iConfig.getParameter<bool>("matchToGenEvt");
64 
65  // define kinfitter
66  if (doKinFit_) {
67  myKinFitter =
68  std::make_unique<StKinFitter>(jetParam_, lepParam_, metParam_, maxNrIter_, maxDeltaS_, maxF_, constraints_);
69  }
70  // define what will be produced
71  produces<std::vector<StEvtSolution>>();
72 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< std::vector< pat::Jet > > jetSrcToken_
std::vector< int > constraints_
edm::EDGetTokenT< std::vector< pat::Muon > > muonSrcToken_
std::unique_ptr< StKinFitter > myKinFitter
edm::EDGetTokenT< StGenEvent > genEvtSrcToken_
edm::EDGetTokenT< std::vector< pat::Electron > > electronSrcToken_
edm::EDGetTokenT< std::vector< pat::MET > > metSrcToken_

Member Function Documentation

◆ produce()

void StEvtSolutionMaker::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 74 of file StEvtSolutionMaker.cc.

References b, gather_cfg::cout, doKinFit_, pwdgSkimBPark_cfi::electrons, electronSrcToken_, iEvent, jetCorrScheme_, PDWG_EXODelayedJetMET_cff::jets, jetSrcToken_, MainPageGenerator::l, leptonFlavour_, matchToGenEvt_, L1BJetProducer_cff::maxJets, singleTopDQM_cfi::mets, metSrcToken_, eostools::move(), PDWG_BPHSkim_cff::muons, muonSrcToken_, myKinFitter, StEvtSolution::setBottom(), StEvtSolution::setElectron(), StEvtSolution::setJetCorrectionScheme(), StEvtSolution::setLight(), StEvtSolution::setMuon(), and StEvtSolution::setNeutrino().

74  {
75  //
76  // TopObject Selection
77  //
78 
79  // select lepton (the TtLepton vectors are, for the moment, sorted on pT)
80  bool leptonFound = false;
82  if (leptonFlavour_ == "muon") {
83  iEvent.getByToken(muonSrcToken_, muons);
84  if (!muons->empty())
85  leptonFound = true;
86  }
88  if (leptonFlavour_ == "electron") {
89  iEvent.getByToken(electronSrcToken_, electrons);
90  if (!electrons->empty())
91  leptonFound = true;
92  }
93 
94  // select MET (TopMET vector is sorted on ET)
95  bool metFound = false;
97  iEvent.getByToken(metSrcToken_, mets);
98  if (!mets->empty())
99  metFound = true;
100 
101  // select Jets
102  bool jetsFound = false;
104  iEvent.getByToken(jetSrcToken_, jets);
105  unsigned int maxJets = 2; //this has to become a custom-defined parameter (we may want 2 or 3 jets)
106  if (jets->size() >= 2)
107  jetsFound = true;
108 
109  auto evtsols = std::make_unique<std::vector<StEvtSolution>>();
110  if (leptonFound && metFound && jetsFound) {
111  std::cout << "constructing solutions" << std::endl;
112  for (unsigned int b = 0; b < maxJets; b++) {
113  for (unsigned int l = 0; l < maxJets; l++) {
114  if (b != l) { // to avoid double counting
115  StEvtSolution asol;
117  if (leptonFlavour_ == "muon")
118  asol.setMuon(muons, 0);
119  if (leptonFlavour_ == "electron")
120  asol.setElectron(electrons, 0);
121  asol.setNeutrino(mets, 0);
122  asol.setBottom(jets, b);
123  asol.setLight(jets, l);
124 
125  if (doKinFit_)
126  asol = myKinFitter->addKinFitInfo(&asol);
127 
128  /* to be adapted to ST (Andrea)
129  if(addLRJetComb_){
130  asol.setPtrueCombExist(jetCombProbs[m].getPTrueCombExist(&afitsol));
131  asol.setPtrueBJetSel(jetCombProbs[m].getPTrueBJetSel(&afitsol));
132  asol.setPtrueBhadrSel(jetCombProbs[m].getPTrueBhadrSel(&afitsol));
133  asol.setPtrueJetComb(afitsol.getPtrueCombExist()*afitsol.getPtrueBJetSel()*afitsol.getPtrueBhadrSel());
134  }
135  */
136  evtsols->push_back(asol);
137  }
138  }
139  }
140 
141  // if asked for, match the event solutions to the gen Event
142  if (matchToGenEvt_) {
143  /*
144  edm::Handle<StGenEvent> genEvt;
145  iEvent.getByToken (genEvtSrcToken_,genEvt);
146  double bestSolDR = 9999.;
147  int bestSol = 0;
148  for(size_t s=0; s<evtsols->size(); s++) {
149  (*evtsols)[s].setGenEvt(genEvt->particles());
150  vector<double> bm = BestMatch((*evtsols)[s], false); //false to use DR, true SpaceAngles
151  (*evtsols)[s].setSumDeltaRjp(bm[0]); // dRBB + dRLL
152  (*evtsols)[s].setChangeBL((int) bm[1]); // has swapped or not
153  (*evtsols)[s].setDeltaRB(bm[2]);
154  (*evtsols)[s].setDeltaRL(bm[3]);
155  if(bm[0]<bestSolDR) { bestSolDR = bm[0]; bestSol = s; }
156  }
157  (*evtsols)[bestSol].setBestSol(true);
158  */
159  }
160 
161  //store the vector of solutions to the event
162  iEvent.put(std::move(evtsols));
163  } else {
164  std::cout << "@@@ No calibrated solutions built, because: " << std::endl;
165  ;
166  if (jets->size() < maxJets)
167  std::cout << "@ nr jets = " << jets->size() << " < " << maxJets << std::endl;
168  if (leptonFlavour_ == "muon" && !leptonFound)
169  std::cout << "@ no good muon candidate" << std::endl;
170  if (leptonFlavour_ == "electron" && !leptonFound)
171  std::cout << "@ no good electron candidate" << std::endl;
172  if (mets->empty())
173  std::cout << "@ no MET reconstruction" << std::endl;
174 
175  StEvtSolution asol;
176  evtsols->push_back(asol);
177  }
178  iEvent.put(std::move(evtsols));
179 }
void setMuon(const edm::Handle< std::vector< pat::Muon > > &muon, int i)
void setLight(const edm::Handle< std::vector< pat::Jet > > &jet, int i)
void setNeutrino(const edm::Handle< std::vector< pat::MET > > &met, int i)
edm::EDGetTokenT< std::vector< pat::Jet > > jetSrcToken_
edm::EDGetTokenT< std::vector< pat::Muon > > muonSrcToken_
int iEvent
Definition: GenABIO.cc:224
std::unique_ptr< StKinFitter > myKinFitter
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)
def move(src, dest)
Definition: eostools.py:511
void setElectron(const edm::Handle< std::vector< pat::Electron > > &elec, int i)

Member Data Documentation

◆ addLRJetComb_

bool StEvtSolutionMaker::addLRJetComb_
private

Definition at line 34 of file StEvtSolutionMaker.cc.

Referenced by StEvtSolutionMaker().

◆ constraints_

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

Definition at line 38 of file StEvtSolutionMaker.cc.

Referenced by StEvtSolutionMaker().

◆ doKinFit_

bool StEvtSolutionMaker::doKinFit_
private

Definition at line 34 of file StEvtSolutionMaker.cc.

Referenced by produce(), and StEvtSolutionMaker().

◆ electronSrcToken_

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

Definition at line 25 of file StEvtSolutionMaker.cc.

Referenced by produce(), and StEvtSolutionMaker().

◆ genEvtSrcToken_

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

Definition at line 29 of file StEvtSolutionMaker.cc.

Referenced by StEvtSolutionMaker().

◆ jetCorrScheme_

int StEvtSolutionMaker::jetCorrScheme_
private

Definition at line 31 of file StEvtSolutionMaker.cc.

Referenced by produce(), and StEvtSolutionMaker().

◆ jetParam_

int StEvtSolutionMaker::jetParam_
private

Definition at line 37 of file StEvtSolutionMaker.cc.

Referenced by StEvtSolutionMaker().

◆ jetSrcToken_

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

Definition at line 28 of file StEvtSolutionMaker.cc.

Referenced by produce(), and StEvtSolutionMaker().

◆ lepParam_

int StEvtSolutionMaker::lepParam_
private

Definition at line 37 of file StEvtSolutionMaker.cc.

Referenced by StEvtSolutionMaker().

◆ leptonFlavour_

std::string StEvtSolutionMaker::leptonFlavour_
private

Definition at line 30 of file StEvtSolutionMaker.cc.

Referenced by produce(), and StEvtSolutionMaker().

◆ matchToGenEvt_

bool StEvtSolutionMaker::matchToGenEvt_
private

Definition at line 34 of file StEvtSolutionMaker.cc.

Referenced by produce(), and StEvtSolutionMaker().

◆ maxDeltaS_

double StEvtSolutionMaker::maxDeltaS_
private

Definition at line 36 of file StEvtSolutionMaker.cc.

Referenced by StEvtSolutionMaker().

◆ maxF_

double StEvtSolutionMaker::maxF_
private

Definition at line 36 of file StEvtSolutionMaker.cc.

Referenced by StEvtSolutionMaker().

◆ maxNrIter_

int StEvtSolutionMaker::maxNrIter_
private

Definition at line 35 of file StEvtSolutionMaker.cc.

Referenced by StEvtSolutionMaker().

◆ metParam_

int StEvtSolutionMaker::metParam_
private

Definition at line 37 of file StEvtSolutionMaker.cc.

Referenced by StEvtSolutionMaker().

◆ metSrcToken_

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

Definition at line 27 of file StEvtSolutionMaker.cc.

Referenced by produce(), and StEvtSolutionMaker().

◆ muonSrcToken_

edm::EDGetTokenT<std::vector<pat::Muon> > StEvtSolutionMaker::muonSrcToken_
private

Definition at line 26 of file StEvtSolutionMaker.cc.

Referenced by produce(), and StEvtSolutionMaker().

◆ myKinFitter

std::unique_ptr<StKinFitter> StEvtSolutionMaker::myKinFitter
private

Definition at line 24 of file StEvtSolutionMaker.cc.

Referenced by produce(), and StEvtSolutionMaker().