CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EmulationObserverBase.cc
Go to the documentation of this file.
1 /*
2  * EmulationObserverBase.cc
3  *
4  * Created on: Aug 18, 2021
5  * Author: kbunkow
6  */
7 
9 
10 #include "Math/VectorUtil.h"
11 
13  : edmCfg(edmCfg), omtfConfig(omtfConfig), simMuon(nullptr) {}
14 
16  // TODO Auto-generated destructor stub
17 }
18 
20  l1t::tftype mtfType,
21  const std::shared_ptr<OMTFinput>& input,
22  const AlgoMuons& algoCandidates,
23  const AlgoMuons& gbCandidates,
24  const std::vector<l1t::RegionalMuonCand>& candMuons) {
25  unsigned int procIndx = omtfConfig->getProcIndx(iProcessor, mtfType);
26 
27  unsigned int i = 0;
28  for (auto& gbCandidate : gbCandidates) {
29  if (gbCandidate->getGoldenPatern() != nullptr &&
30  gbCandidate->getGpResult().getFiredLayerCnt() > omtfCand->getGpResult().getFiredLayerCnt()) {
31  //LogTrace("l1tOmtfEventPrint") <<__FUNCTION__<<":"<<__LINE__<<" gbCandidate "<<gbCandidate<<" "<<std::endl;
32  omtfCand = gbCandidate;
33 
34  candProcIndx = procIndx;
35 
36  //should be good, as the regionalMuonCand is created for every gbCandidate in OMTFProcessor<GoldenPatternType>::getFinalcandidates
37  regionalMuonCand = candMuons.at(i);
38 
39  //this->algoCandidates = algoCandidates; //TODO uncomment if needed
40  }
41  i++;
42  }
43 
45  /*if(omtfCand->isValid()) { //TODO check this condition
46  GoldenPatternWithStat* omtfCandGp = static_cast<GoldenPatternWithStat*>(omtfCand.getGoldenPatern());
47  if( omtfCandGp->key().thePt > 100 && exptCandGp->key().thePt <= 15 ) {
48  //LogTrace("l1tOmtfEventPrint") <<iEvent.id()<<std::endl;
49  LogTrace("l1tOmtfEventPrint") <<" ptSim "<<ptSim<<" chargeSim "<<chargeSim<<std::endl;
50  LogTrace("l1tOmtfEventPrint") <<"iProcessor "<<iProcessor<<" exptCandGp "<<exptCandGp->key()<<std::endl;
51  LogTrace("l1tOmtfEventPrint") <<"iProcessor "<<iProcessor<<" omtfCandGp "<<omtfCandGp->key()<<std::endl;
52  LogTrace("l1tOmtfEventPrint") <<"omtfResult "<<std::endl<<omtfResult<<std::endl;
53  int refHitNum = omtfCand.getRefHitNumber();
54  LogTrace("l1tOmtfEventPrint") <<"other gps results"<<endl;
55  for(auto& gp : goldenPatterns) {
56  if(omtfResult.getFiredLayerCnt() == gp->getResults()[procIndx][iRefHit].getFiredLayerCnt() )
57  {
58  LogTrace("l1tOmtfEventPrint") <<gp->key()<<std::endl<<gp->getResults()[procIndx][iRefHit]<<std::endl;
59  }
60  }
61  LogTrace("l1tOmtfEventPrint")<<std::endl;
62  }
63  }*/
64 }
65 
67  omtfCand.reset(new AlgoMuon());
68  candProcIndx = 0xffff;
69 
70  simMuon = findSimMuon(iEvent);
71  //LogTrace("l1tOmtfEventPrint") <<__FUNCTION__<<":"<<__LINE__<<" evevt "<<iEvent.id().event()<<" simMuon pt "<<simMuon->momentum().pt()<<" GeV "<<std::endl;
72 }
73 
75  const SimTrack* result = nullptr;
76  if (edmCfg.exists("simTracksTag") == false)
77  return result;
78 
80  event.getByLabel(edmCfg.getParameter<edm::InputTag>("simTracksTag"), simTks);
81 
82  //LogTrace("l1tOmtfEventPrint")<<__FUNCTION__<<" simTks->size() "<<simTks->size()<<std::endl;
83  for (std::vector<SimTrack>::const_iterator it = simTks->begin(); it < simTks->end(); it++) {
84  const SimTrack& aTrack = *it;
85  if (!(aTrack.type() == 13 || aTrack.type() == -13))
86  continue;
87  if (previous && ROOT::Math::VectorUtil::DeltaR(aTrack.momentum(), previous->momentum()) < 0.07)
88  continue;
89  if (!result || aTrack.momentum().pt() > result->momentum().pt())
90  result = &aTrack;
91  }
92  return result;
93 }
AlgoMuons::value_type omtfCand
EmulationObserverBase(const edm::ParameterSet &edmCfg, const OMTFConfiguration *omtfConfig)
bool exists(std::string const &parameterName) const
checks if a parameter exists
void observeProcesorEmulation(unsigned int iProcessor, l1t::tftype mtfType, const std::shared_ptr< OMTFinput > &input, const AlgoMuons &algoCandidates, const AlgoMuons &gbCandidates, const std::vector< l1t::RegionalMuonCand > &candMuons) override
omtfConfig(omtfConfig)
tuple previous
Definition: callgraph.py:103
static std::string const input
Definition: EdmProvDump.cc:47
tuple result
Definition: mps_fire.py:311
int iEvent
Definition: GenABIO.cc:224
l1t::RegionalMuonCand regionalMuonCand
const SimTrack * findSimMuon(const edm::Event &event, const SimTrack *previous=nullptr)
void observeEventBegin(const edm::Event &iEvent) override
unsigned int getProcIndx(unsigned int iProcessor, l1t::tftype mtfType) const
input phi should be in the hardware scale (nPhiBins units for 2pi), can be in range -nPhiBins ...
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
int type() const
particle type (HEP PDT convension)
Definition: CoreSimTrack.h:22
std::vector< AlgoMuonPtr > AlgoMuons
Definition: AlgoMuon.h:102
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:19
const OMTFConfiguration * omtfConfig