27 : omtfConfig(omtfConfig),
29 candidateSimMuonMatcher(candidateSimMuonMatcher),
30 inputInProcs(omtfConfig->processorCnt()),
31 algoMuonsInProcs(omtfConfig->processorCnt()),
32 gbCandidatesInProcs(omtfConfig->processorCnt()) {
34 if (edmCfg.
exists(
"simTracksTag"))
38 <<
"EventCapture::EventCapture: no InputTag simTracksTag found" << std::endl;
40 if (this->candidateSimMuonMatcher)
60 for (
unsigned int iSimTrack = 0; iSimTrack != simTraksHandle->size(); iSimTrack++) {
62 simMuons.emplace_back(simTraksHandle, iSimTrack);
70 algoMuonsInProc.clear();
73 gbCandidatesInProc.clear();
78 const std::shared_ptr<OMTFinput>&
input,
81 const std::vector<l1t::RegionalMuonCand>& candMuons) {
91 std::unique_ptr<l1t::RegionalMuonCandBxCollection>& finalCandidates) {
92 std::ostringstream ostr;
99 edm::LogVerbatim(
"l1tOmtfEventPrint") <<
"matchingResults.size() " << matchingResults.size() << std::endl;
102 for (
auto& matchingResult : matchingResults) {
104 if (matchingResult.muonCand && matchingResult.muonCand->hwQual() >= 12 &&
105 matchingResult.muonCand->hwPt() > 38) {
108 bool runStubsSimHitsMatcher =
false;
109 if (matchingResult.trackingParticle) {
110 auto trackingParticle = matchingResult.trackingParticle;
111 ostr <<
"trackingParticle: eventId " << trackingParticle->eventId().event() <<
" pdgId " << std::setw(3)
112 << trackingParticle->pdgId() <<
" trackId " << trackingParticle->g4Tracks().at(0).trackId() <<
" pt " 113 << std::setw(9) << trackingParticle->pt()
114 <<
" eta " << std::setw(9) << trackingParticle->momentum().eta() <<
" phi " << std::setw(9)
115 << trackingParticle->momentum().phi() << std::endl;
117 ostr <<
"no simMuon ";
118 runStubsSimHitsMatcher =
true;
120 ostr <<
"matched to: " << std::endl;
121 auto finalCandidate = matchingResult.muonCand;
122 ostr <<
" hwPt " << finalCandidate->hwPt() <<
" hwSign " << finalCandidate->hwSign() <<
" hwQual " 123 << finalCandidate->hwQual() <<
" hwEta " << std::setw(4) << finalCandidate->hwEta() << std::setw(4)
124 <<
" hwPhi " << finalCandidate->hwPhi() <<
" eta " << std::setw(9)
125 << (finalCandidate->hwEta() * 0.010875) <<
" phi " << std::endl;
127 if (runStubsSimHitsMatcher)
133 bool wasSimMuInOmtfPos =
false;
134 bool wasSimMuInOmtfNeg =
false;
137 if (simMuon->eventId().event() == 0 &&
abs(simMuon->momentum().eta()) > 0.82 &&
138 abs(simMuon->momentum().eta()) < 1.24 && simMuon->momentum().pt() >= 3.) {
139 ostr <<
"SimMuon: eventId " << simMuon->eventId().event() <<
" pdgId " << std::setw(3) << simMuon->type()
140 <<
" pt " << std::setw(9) << simMuon->momentum().pt()
141 <<
" eta " << std::setw(9) << simMuon->momentum().eta() <<
" phi " << std::setw(9)
142 << simMuon->momentum().phi() << std::endl;
144 if (simMuon->momentum().eta() > 0)
145 wasSimMuInOmtfPos =
true;
147 wasSimMuInOmtfNeg =
true;
151 bool wasCandInNeg =
false;
152 bool wasCandInPos =
false;
154 for (
auto& finalCandidate : *finalCandidates) {
157 finalCandidate.hwPt() > 20)
161 finalCandidate.hwPt() > 20)
165 if ((wasSimMuInOmtfNeg && wasCandInNeg))
168 if ((wasSimMuInOmtfPos && wasCandInPos))
188 edm::LogVerbatim(
"l1tOmtfEventPrint") <<
"##################### EventCapture::observeEventEnd - dump of event " 189 <<
iEvent.id() <<
" #####################################################" 195 for (
int bx = finalCandidates->getFirstBX();
bx <= finalCandidates->getLastBX();
bx++) {
196 for (
auto finalCandidateIt = finalCandidates->begin(
bx); finalCandidateIt != finalCandidates->end(
bx);
197 finalCandidateIt++) {
198 auto& finalCandidate = *finalCandidateIt;
199 int globHwPhi = (finalCandidate.processor()) * 96 + finalCandidate.hwPhi();
201 globHwPhi = (globHwPhi + 600) % 576;
203 double globalPhi = globHwPhi * 2. *
M_PI / 576;
204 if (globalPhi >
M_PI)
205 globalPhi = globalPhi - (2. *
M_PI);
207 int layerHits = (
int)finalCandidate.trackAddress().at(0);
208 std::bitset<18> layerHitBits(layerHits);
211 <<
" bx " <<
bx <<
" hwPt " << finalCandidate.hwPt() <<
" hwSign " << finalCandidate.hwSign() <<
" hwQual " 212 << finalCandidate.hwQual() <<
" hwEta " << std::setw(4) << finalCandidate.hwEta() << std::setw(4) <<
" hwPhi " 213 << finalCandidate.hwPhi() <<
" eta " << std::setw(9) << (finalCandidate.hwEta() * 0.010875) <<
" phi " 214 << std::setw(9) << globalPhi <<
" " << layerHitBits <<
" processor " 215 <<
OmtfName(finalCandidate.processor(), finalCandidate.trackFinderType()) << std::endl;
217 for (
auto& trackAddr : finalCandidate.trackAddress()) {
218 if (trackAddr.first >= 10)
220 <<
"trackAddr first " << trackAddr.first <<
" second " << trackAddr.second <<
" ptGeV " 227 for (
unsigned int iProc = 0; iProc <
inputInProcs.size(); iProc++) {
230 std::ostringstream ostrInput;
233 int layersWithStubs = 0;
235 for (
auto& stub :
layer) {
236 bool layerFired =
false;
237 if (stub && (stub->type != MuonStub::Type::EMPTY)) {
242 ostrInput << (*stub) <<
" globalPhiRad " << globalPhiRad << std::endl;
249 if (layersWithStubs != 0) {
251 <<
" **************************************************" << std::endl;
255 if (layersWithStubs < 2)
263 if (algoMuon->isValid()) {
265 << board.
name() <<
" " << *algoMuon <<
" RefHitNum " << algoMuon->getRefHitNumber() << std::endl;
266 edm::LogVerbatim(
"l1tOmtfEventPrint") << algoMuon->getGpResult() << std::endl;
270 if (
gp->key().thePt == 0)
287 if (gbCandidate->isValid())
Log< level::Info, true > LogVerbatim
CandidateSimMuonMatcher * candidateSimMuonMatcher
T getParameter(std::string const &) const
std::vector< AlgoMuons > gbCandidatesInProcs
void observeEventBegin(const edm::Event &event) override
void observeProcesorEmulation(unsigned int iProcessor, l1t::tftype mtfType, const std::shared_ptr< OMTFinput > &, const AlgoMuons &algoCandidates, const AlgoMuons &gbCandidates, const std::vector< l1t::RegionalMuonCand > &candMuons) override
bool exists(std::string const ¶meterName) const
checks if a parameter exists
T const * product() const
const OMTFConfiguration * omtfConfig
double procHwPhiToGlobalPhi(int procHwPhi, int procHwPhi0) const
static std::string const input
std::unique_ptr< StubsSimHitsMatcher > stubsSimHitsMatcher
edm::InputTag simTracksTag
std::vector< edm::Ptr< SimTrack > > simMuons
void beginRun(edm::EventSetup const &eventSetup) override
Abs< T >::type abs(const T &t)
Log< level::Error, true > LogImportant
double hwPtToGev(int hwPt) const override
uGMT pt scale conversion
const GoldenPatternVec< GoldenPattern > * goldenPatterns
std::vector< MatchingResult > getMatchingResults()
void observeEventEnd(const edm::Event &event, std::unique_ptr< l1t::RegionalMuonCandBxCollection > &finalCandidates) override
EventCapture(const edm::ParameterSet &edmCfg, const OMTFConfiguration *omtfConfig, CandidateSimMuonMatcher *candidateSimMuonMatcher, const MuonGeometryTokens &muonGeometryTokens, const GoldenPatternVec< GoldenPattern > *gps=nullptr)
std::vector< std::shared_ptr< OMTFinput > > inputInProcs
std::vector< std::unique_ptr< GoldenPatternType > > GoldenPatternVec
std::vector< AlgoMuonPtr > AlgoMuons
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 ...
std::vector< AlgoMuons > algoMuonsInProcs