CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
EmulationObserverBase Class Reference

#include <EmulationObserverBase.h>

Inheritance diagram for EmulationObserverBase:
IOMTFEmulationObserver DataROOTDumper2 PatternOptimizerBase PatternGenerator

Public Member Functions

 EmulationObserverBase (const edm::ParameterSet &edmCfg, const OMTFConfiguration *omtfConfig)
 
const std::vector< const reco::GenParticle * > findGenMuon (const edm::Event &event)
 
const SimTrackfindSimMuon (const edm::Event &event, const SimTrack *previous=nullptr)
 
void observeEventBegin (const edm::Event &iEvent) override
 
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
 
 ~EmulationObserverBase () override
 
- Public Member Functions inherited from IOMTFEmulationObserver
virtual void addProcesorData (std::string key, boost::property_tree::ptree &procDataTree)
 
virtual void beginRun (edm::EventSetup const &eventSetup)
 
virtual void endJob ()=0
 
 IOMTFEmulationObserver ()
 
virtual void observeEventEnd (const edm::Event &iEvent, std::unique_ptr< l1t::RegionalMuonCandBxCollection > &finalCandidates)
 
virtual void observeProcesorBegin (unsigned int iProcessor, l1t::tftype mtfType)
 
virtual ~IOMTFEmulationObserver ()
 

Protected Attributes

unsigned int candProcIndx = 0
 
edm::ParameterSet edmCfg
 
AlgoMuons::value_type omtfCand
 
const OMTFConfigurationomtfConfig
 
l1t::RegionalMuonCand regionalMuonCand
 
const SimTracksimMuon = nullptr
 

Detailed Description

Definition at line 19 of file EmulationObserverBase.h.

Constructor & Destructor Documentation

◆ EmulationObserverBase()

EmulationObserverBase::EmulationObserverBase ( const edm::ParameterSet edmCfg,
const OMTFConfiguration omtfConfig 
)

Definition at line 13 of file EmulationObserverBase.cc.

14  : edmCfg(edmCfg), omtfConfig(omtfConfig), simMuon(nullptr) {}
const OMTFConfiguration * omtfConfig

◆ ~EmulationObserverBase()

EmulationObserverBase::~EmulationObserverBase ( )
override

Definition at line 16 of file EmulationObserverBase.cc.

16  {
17  // TODO Auto-generated destructor stub
18 }

Member Function Documentation

◆ findGenMuon()

const std::vector< const reco::GenParticle * > EmulationObserverBase::findGenMuon ( const edm::Event event)

Definition at line 96 of file EmulationObserverBase.cc.

References funct::abs(), edmCfg, edm::ParameterSet::exists(), AJJGenJetFilter_cfi::genParticles, edm::ParameterSet::getParameter(), mps_fire::i, LogTrace, reco::LeafCandidate::momentum(), DiMuonV_cfg::muons, reco::LeafCandidate::p(), reco::LeafCandidate::pdgId(), reco::LeafCandidate::pt(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), reco::LeafCandidate::pz(), reco::LeafCandidate::vx(), reco::LeafCandidate::vy(), and reco::LeafCandidate::vz().

96  {
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
Vector momentum() const final
spatial momentum vector
double pz() const final
z coordinate of momentum vector
double pt() const final
transverse momentum
double vz() const override
z coordinate of vertex position
bool exists(std::string const &parameterName) const
checks if a parameter exists
double vy() const override
y coordinate of vertex position
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
#define LogTrace(id)
int pdgId() const final
PDG identifier.
double px() const final
x coordinate of momentum vector
double p() const final
magnitude of momentum vector
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double py() const final
y coordinate of momentum vector
double vx() const override
x coordinate of vertex position

◆ findSimMuon()

const SimTrack * EmulationObserverBase::findSimMuon ( const edm::Event event,
const SimTrack previous = nullptr 
)

Definition at line 75 of file EmulationObserverBase.cc.

References electronAnalyzer_cfi::DeltaR, edmCfg, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, CoreSimTrack::momentum(), callgraph::previous, mps_fire::result, and CoreSimTrack::type().

Referenced by observeEventBegin().

75  {
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 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
bool exists(std::string const &parameterName) const
checks if a parameter exists
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:19
int type() const
particle type (HEP PDT convension)
Definition: CoreSimTrack.h:22

◆ observeEventBegin()

void EmulationObserverBase::observeEventBegin ( const edm::Event iEvent)
overridevirtual

Reimplemented from IOMTFEmulationObserver.

Definition at line 67 of file EmulationObserverBase.cc.

References candProcIndx, findSimMuon(), iEvent, omtfCand, and simMuon.

67  {
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 }
AlgoMuons::value_type omtfCand
int iEvent
Definition: GenABIO.cc:224
const SimTrack * findSimMuon(const edm::Event &event, const SimTrack *previous=nullptr)

◆ observeProcesorEmulation()

void EmulationObserverBase::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 
)
overridevirtual

Implements IOMTFEmulationObserver.

Definition at line 20 of file EmulationObserverBase.cc.

References candProcIndx, OMTFConfiguration::getProcIndx(), mps_fire::i, omtfCand, omtfConfig, and regionalMuonCand.

25  {
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 }
AlgoMuons::value_type omtfCand
l1t::RegionalMuonCand regionalMuonCand
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

Member Data Documentation

◆ candProcIndx

unsigned int EmulationObserverBase::candProcIndx = 0
protected

◆ edmCfg

edm::ParameterSet EmulationObserverBase::edmCfg
protected

◆ omtfCand

AlgoMuons::value_type EmulationObserverBase::omtfCand
protected

◆ omtfConfig

const OMTFConfiguration* EmulationObserverBase::omtfConfig
protected

◆ regionalMuonCand

l1t::RegionalMuonCand EmulationObserverBase::regionalMuonCand
protected

Definition at line 52 of file EmulationObserverBase.h.

Referenced by observeProcesorEmulation().

◆ simMuon

const SimTrack* EmulationObserverBase::simMuon = nullptr
protected