CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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

void produce (edm::Event &, const edm::EventSetup &) override
 
 StEvtSolutionMaker (const edm::ParameterSet &)
 
 ~StEvtSolutionMaker () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector
< edm::ProductResolverIndex >
const & 
indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector
< edm::ProductResolverIndex >
const & 
putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector
< ProductResolverIndexAndSkipBit >
const & 
itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
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)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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_FULL_cff::InputTag, jetCorrScheme_, jetParam_, jetSrcToken_, lepParam_, leptonFlavour_, matchToGenEvt_, maxDeltaS_, maxF_, maxNrIter_, metParam_, metSrcToken_, muonSrcToken_, myKinFitter, and AlCaHLTBitMon_QueryRunRegistry::string.

8  {
9  // configurables
10  electronSrcToken_ = mayConsume<std::vector<pat::Electron> >(iConfig.getParameter<edm::InputTag>("electronSource"));
11  muonSrcToken_ = mayConsume<std::vector<pat::Muon> >(iConfig.getParameter<edm::InputTag>("muonSource"));
12  metSrcToken_ = consumes<std::vector<pat::MET> >(iConfig.getParameter<edm::InputTag>("metSource"));
13  jetSrcToken_ = consumes<std::vector<pat::Jet> >(iConfig.getParameter<edm::InputTag>("jetSource"));
14  genEvtSrcToken_ = mayConsume<StGenEvent>(edm::InputTag("genEvt"));
15  leptonFlavour_ = iConfig.getParameter<std::string>("leptonFlavour");
16  jetCorrScheme_ = iConfig.getParameter<int>("jetCorrectionScheme");
17  //jetInput_ = iConfig.getParameter< std::string > ("jetInput");
18  doKinFit_ = iConfig.getParameter<bool>("doKinFit");
19  addLRJetComb_ = iConfig.getParameter<bool>("addLRJetComb");
20  maxNrIter_ = iConfig.getParameter<int>("maxNrIter");
21  maxDeltaS_ = iConfig.getParameter<double>("maxDeltaS");
22  maxF_ = iConfig.getParameter<double>("maxF");
23  jetParam_ = iConfig.getParameter<int>("jetParametrisation");
24  lepParam_ = iConfig.getParameter<int>("lepParametrisation");
25  metParam_ = iConfig.getParameter<int>("metParametrisation");
26  constraints_ = iConfig.getParameter<std::vector<int> >("constraints");
27  matchToGenEvt_ = iConfig.getParameter<bool>("matchToGenEvt");
28 
29  // define kinfitter
30  if (doKinFit_) {
32  }
33  // define what will be produced
34  produces<std::vector<StEvtSolution> >();
35 }
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_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
StEvtSolutionMaker::~StEvtSolutionMaker ( )
override

Definition at line 37 of file StEvtSolutionMaker.cc.

References doKinFit_, and myKinFitter.

37  {
38  if (doKinFit_)
39  delete myKinFitter;
40 }
StKinFitter * myKinFitter

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 42 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_, eostools::move(), patZpeak::muons, muonSrcToken_, myKinFitter, edm::Event::put(), StEvtSolution::setBottom(), StEvtSolution::setElectron(), StEvtSolution::setJetCorrectionScheme(), StEvtSolution::setLight(), StEvtSolution::setMuon(), and StEvtSolution::setNeutrino().

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

Member Data Documentation

bool StEvtSolutionMaker::addLRJetComb_
private

Definition at line 35 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

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

Definition at line 39 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

bool StEvtSolutionMaker::doKinFit_
private

Definition at line 35 of file StEvtSolutionMaker.h.

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

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

Definition at line 26 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

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

Definition at line 30 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

int StEvtSolutionMaker::jetCorrScheme_
private

Definition at line 32 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

int StEvtSolutionMaker::jetParam_
private

Definition at line 38 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

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

Definition at line 29 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

int StEvtSolutionMaker::lepParam_
private

Definition at line 38 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

std::string StEvtSolutionMaker::leptonFlavour_
private

Definition at line 31 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

bool StEvtSolutionMaker::matchToGenEvt_
private

Definition at line 35 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

double StEvtSolutionMaker::maxDeltaS_
private

Definition at line 37 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

double StEvtSolutionMaker::maxF_
private

Definition at line 37 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

int StEvtSolutionMaker::maxNrIter_
private

Definition at line 36 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

int StEvtSolutionMaker::metParam_
private

Definition at line 38 of file StEvtSolutionMaker.h.

Referenced by StEvtSolutionMaker().

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

Definition at line 28 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

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

Definition at line 27 of file StEvtSolutionMaker.h.

Referenced by produce(), and StEvtSolutionMaker().

StKinFitter* StEvtSolutionMaker::myKinFitter
private

Definition at line 24 of file StEvtSolutionMaker.h.

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