CMS 3D CMS Logo

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 
11 #include "Math/VectorUtil.h"
12 
14  : edmCfg(edmCfg), omtfConfig(omtfConfig), simMuon(nullptr) {}
15 
17  // TODO Auto-generated destructor stub
18 }
19 
21  l1t::tftype mtfType,
22  const std::shared_ptr<OMTFinput>& input,
23  const AlgoMuons& algoCandidates,
24  const AlgoMuons& gbCandidates,
25  const std::vector<l1t::RegionalMuonCand>& candMuons) {
26  unsigned int procIndx = omtfConfig->getProcIndx(iProcessor, mtfType);
27 
28  unsigned int i = 0;
29  for (auto& gbCandidate : gbCandidates) {
30  if (gbCandidate->getGoldenPatern() != nullptr &&
31  gbCandidate->getGpResultConstr().getFiredLayerCnt() > omtfCand->getGpResultConstr().getFiredLayerCnt()) {
32  //LogTrace("l1tOmtfEventPrint") <<__FUNCTION__<<":"<<__LINE__<<" gbCandidate "<<gbCandidate<<" "<<std::endl;
33  omtfCand = gbCandidate;
34 
35  candProcIndx = procIndx;
36 
37  //should be good, as the regionalMuonCand is created for every gbCandidate in OMTFProcessor<GoldenPatternType>::getFinalcandidates
38  regionalMuonCand = candMuons.at(i);
39 
40  //this->algoCandidates = algoCandidates; //TODO uncomment if needed
41  }
42  i++;
43  }
44 
46  /*if(omtfCand->isValid()) { //TODO check this condition
47  GoldenPatternWithStat* omtfCandGp = static_cast<GoldenPatternWithStat*>(omtfCand.getGoldenPatern());
48  if( omtfCandGp->key().thePt > 100 && exptCandGp->key().thePt <= 15 ) {
49  //LogTrace("l1tOmtfEventPrint") <<iEvent.id()<<std::endl;
50  LogTrace("l1tOmtfEventPrint") <<" ptSim "<<ptSim<<" chargeSim "<<chargeSim<<std::endl;
51  LogTrace("l1tOmtfEventPrint") <<"iProcessor "<<iProcessor<<" exptCandGp "<<exptCandGp->key()<<std::endl;
52  LogTrace("l1tOmtfEventPrint") <<"iProcessor "<<iProcessor<<" omtfCandGp "<<omtfCandGp->key()<<std::endl;
53  LogTrace("l1tOmtfEventPrint") <<"omtfResult "<<std::endl<<omtfResult<<std::endl;
54  int refHitNum = omtfCand.getRefHitNumber();
55  LogTrace("l1tOmtfEventPrint") <<"other gps results"<<endl;
56  for(auto& gp : goldenPatterns) {
57  if(omtfResult.getFiredLayerCnt() == gp->getResults()[procIndx][iRefHit].getFiredLayerCnt() )
58  {
59  LogTrace("l1tOmtfEventPrint") <<gp->key()<<std::endl<<gp->getResults()[procIndx][iRefHit]<<std::endl;
60  }
61  }
62  LogTrace("l1tOmtfEventPrint")<<std::endl;
63  }
64  }*/
65 }
66 
68  omtfCand.reset(new AlgoMuon());
69  candProcIndx = 0xffff;
70 
72  //LogTrace("l1tOmtfEventPrint") <<__FUNCTION__<<":"<<__LINE__<<" evevt "<<iEvent.id().event()<<" simMuon pt "<<simMuon->momentum().pt()<<" GeV "<<std::endl;
73 }
74 
76  const SimTrack* result = nullptr;
77  if (edmCfg.exists("simTracksTag") == false)
78  return result;
79 
81  event.getByLabel(edmCfg.getParameter<edm::InputTag>("simTracksTag"), simTks);
82 
83  //LogTrace("l1tOmtfEventPrint")<<__FUNCTION__<<" simTks->size() "<<simTks->size()<<std::endl;
84  for (std::vector<SimTrack>::const_iterator it = simTks->begin(); it < simTks->end(); it++) {
85  const SimTrack& aTrack = *it;
86  if (!(aTrack.type() == 13 || aTrack.type() == -13))
87  continue;
88  if (previous && ROOT::Math::VectorUtil::DeltaR(aTrack.momentum(), previous->momentum()) < 0.07)
89  continue;
90  if (!result || aTrack.momentum().pt() > result->momentum().pt())
91  result = &aTrack;
92  }
93  return result;
94 }
95 
96 const std::vector<const reco::GenParticle*> EmulationObserverBase::findGenMuon(const edm::Event& event) {
97  std::vector<const reco::GenParticle*> muons;
98 
99  if (edmCfg.exists("genParticleTag") == false)
100  return muons;
101 
103 
104  event.getByLabel(edmCfg.getParameter<edm::InputTag>("genParticleTag"), genParticles);
105 
106  //todo
107  float etaCutFrom = 0.8;
108  float etaCutTo = 1.24;
109 
110  for (size_t i = 0; i < genParticles->size(); ++i) {
111  const reco::GenParticle& genPart = (*genParticles)[i];
112 
113  if (std::abs(genPart.pdgId()) == 13) {
114  if (std::abs(genPart.momentum().eta()) >= etaCutFrom && std::abs(genPart.momentum().eta()) <= etaCutTo) {
115  genPart.momentum().eta();
116 
117  muons.push_back(&genPart);
118  //int id = p.pdgId();
119  LogTrace("l1tOmtfEventPrint") << __FUNCTION__ << ":" << __LINE__ << " genParticle: pdgId " << genPart.pdgId()
120  << " px " << genPart.px() << " py " << genPart.py() << " pz " << genPart.pz()
121  << " pt " << genPart.pt() << " vx " << genPart.vx() << " vy " << genPart.vy()
122  << " vz " << genPart.vz() << " eta " << genPart.momentum().eta() << endl;
123 
124  LogTrace("l1tOmtfEventPrint") << __FUNCTION__ << ":" << __LINE__ << " genParticle: pdgId " << genPart.pdgId()
125  << " px " << genPart.px() / genPart.p() << " py " << genPart.py() / genPart.p()
126  << " pz " << genPart.pz() / genPart.p() << " pt " << genPart.pt() << endl;
127  //<<" vx "<<genPart.vx()<<" vy "<<genPart.vy()<<" vz "<<genPart.vz()<<endl;
128  }
129  }
130  }
131 
132  return muons;
133 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
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
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:19
#define LogTrace(id)
static std::string const input
Definition: EdmProvDump.cc:50
int type() const
particle type (HEP PDT convension)
Definition: CoreSimTrack.h:22
int iEvent
Definition: GenABIO.cc:224
l1t::RegionalMuonCand regionalMuonCand
const SimTrack * findSimMuon(const edm::Event &event, const SimTrack *previous=nullptr)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void observeEventBegin(const edm::Event &iEvent) override
std::vector< AlgoMuonPtr > AlgoMuons
Definition: AlgoMuon.h:176
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 ...
const OMTFConfiguration * omtfConfig
const std::vector< const reco::GenParticle * > findGenMuon(const edm::Event &event)
Definition: event.py:1