27 : omtfConfig(omtfConfig),
29 candidateSimMuonMatcher(candidateSimMuonMatcher),
30 inputInProcs(omtfConfig->processorCnt()),
31 algoMuonsInProcs(omtfConfig->processorCnt()),
32 gbCandidatesInProcs(omtfConfig->processorCnt()) {
33 if (edmCfg.
exists(
"simTracksTag"))
37 <<
"EventCapture::EventCapture: no InputTag simTracksTag found" << std::endl;
40 if (this->candidateSimMuonMatcher && edmCfg.
exists(
"trackingParticleTag"))
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) {
83 edm::LogImportant(
"l1tOmtfEventPrint") <<
"EventCapture::observeProcesorEmulation : iProcessor" << iProcessor
84 <<
" mtfType " << mtfType <<
" procIndx " << procIndx <<
" OmtfName(procIndx) " 94 std::unique_ptr<l1t::RegionalMuonCandBxCollection>& finalCandidates) {
95 std::ostringstream ostr;
102 LogTrace(
"l1tOmtfEventPrint") <<
"matchingResults.size() " << matchingResults.size() << std::endl;
105 for (
auto& matchingResult : matchingResults) {
107 if (matchingResult.muonCand) {
110 bool runStubsSimHitsMatcher =
false;
111 if (matchingResult.trackingParticle) {
112 auto trackingParticle = matchingResult.trackingParticle;
113 ostr <<
"trackingParticle: eventId " << trackingParticle->eventId().event() <<
" pdgId " << std::setw(3)
114 << trackingParticle->pdgId() <<
" trackId " << trackingParticle->g4Tracks().at(0).trackId() <<
" pt " 115 << std::setw(9) << trackingParticle->pt()
116 <<
" eta " << std::setw(9) << trackingParticle->momentum().eta() <<
" phi " << std::setw(9)
117 << trackingParticle->momentum().phi() << std::endl;
118 }
else if (matchingResult.simTrack) {
119 runStubsSimHitsMatcher =
true;
120 ostr <<
"SimMuon: eventId " << matchingResult.simTrack->eventId().event() <<
" pdgId " << std::setw(3)
121 << matchingResult.simTrack->type() <<
" pt " << std::setw(9)
122 << matchingResult.simTrack->momentum().pt()
123 <<
" eta " << std::setw(9) << matchingResult.simTrack->momentum().eta() <<
" phi " << std::setw(9)
124 << matchingResult.simTrack->momentum().phi() << std::endl;
126 ostr <<
"no simMuon ";
127 runStubsSimHitsMatcher =
true;
129 ostr <<
"matched to: " << std::endl;
130 auto finalCandidate = matchingResult.muonCand;
131 ostr <<
" hwPt " << finalCandidate->hwPt() <<
" hwUPt " << finalCandidate->hwPtUnconstrained() <<
" hwSign " 132 << finalCandidate->hwSign() <<
" hwQual " << finalCandidate->hwQual() <<
" hwEta " << std::setw(4)
133 << finalCandidate->hwEta() << std::setw(4) <<
" hwPhi " << finalCandidate->hwPhi() <<
" eta " 134 << std::setw(9) << (finalCandidate->hwEta() * 0.010875) <<
" phi " << std::endl;
142 bool wasSimMuInOmtfPos =
false;
143 bool wasSimMuInOmtfNeg =
false;
146 if (simMuon->eventId().event() == 0 &&
std::abs(simMuon->momentum().eta()) > 0.82 &&
147 std::abs(simMuon->momentum().eta()) < 1.24 && simMuon->momentum().pt() >= 3.) {
148 ostr <<
"SimMuon: eventId " << simMuon->eventId().event() <<
" pdgId " << std::setw(3) << simMuon->type()
149 <<
" pt " << std::setw(9) << simMuon->momentum().pt()
150 <<
" eta " << std::setw(9) << simMuon->momentum().eta() <<
" phi " << std::setw(9)
151 << simMuon->momentum().phi() << std::endl;
153 if (simMuon->momentum().eta() > 0)
154 wasSimMuInOmtfPos =
true;
156 wasSimMuInOmtfNeg =
true;
160 bool wasCandInNeg =
false;
161 bool wasCandInPos =
false;
163 for (
auto& finalCandidate : *finalCandidates) {
166 finalCandidate.hwPt() > 20)
170 finalCandidate.hwPt() > 20)
174 if ((wasSimMuInOmtfNeg && wasCandInNeg))
177 if ((wasSimMuInOmtfPos && wasCandInPos))
197 edm::LogVerbatim(
"l1tOmtfEventPrint") <<
"##################### EventCapture::observeEventEnd - dump of event " 198 <<
iEvent.id() <<
" #####################################################" 204 for (
int bx = finalCandidates->getFirstBX();
bx <= finalCandidates->getLastBX();
bx++) {
205 for (
auto finalCandidateIt = finalCandidates->begin(
bx); finalCandidateIt != finalCandidates->end(
bx);
206 finalCandidateIt++) {
207 auto& finalCandidate = *finalCandidateIt;
208 int globHwPhi = (finalCandidate.processor()) * 96 + finalCandidate.hwPhi();
210 globHwPhi = (globHwPhi + 600) % 576;
212 double globalPhi = globHwPhi * 2. *
M_PI / 576;
213 if (globalPhi >
M_PI)
214 globalPhi = globalPhi - (2. *
M_PI);
216 int layerHits = (
int)finalCandidate.trackAddress().at(0);
217 std::bitset<18> layerHitBits(layerHits);
220 <<
" bx " <<
bx <<
" hwPt " << finalCandidate.hwPt() <<
" hwUPt " << finalCandidate.hwPtUnconstrained()
221 <<
" hwSign " << finalCandidate.hwSign() <<
" hwQual " << finalCandidate.hwQual() <<
" hwEta " << std::setw(4)
222 << finalCandidate.hwEta() << std::setw(4) <<
" hwPhi " << finalCandidate.hwPhi() <<
" eta " << std::setw(9)
223 << (finalCandidate.hwEta() * 0.010875) <<
" phi " << std::setw(9) << globalPhi <<
" " << layerHitBits
224 <<
" processor " <<
OmtfName(finalCandidate.processor(), finalCandidate.trackFinderType(),
omtfConfig)
227 for (
auto& trackAddr : finalCandidate.trackAddress()) {
228 if (trackAddr.first >= 10)
230 <<
"trackAddr first " << trackAddr.first <<
" second " << trackAddr.second <<
" ptGeV " 237 for (
unsigned int iProc = 0; iProc <
inputInProcs.size(); iProc++) {
240 std::ostringstream ostrInput;
243 int layersWithStubs = 0;
245 for (
auto& stub :
layer) {
246 bool layerFired =
false;
247 if (stub && (stub->type != MuonStub::Type::EMPTY)) {
252 ostrInput << (*stub) <<
" globalPhiRad " << globalPhiRad << std::endl;
259 if (layersWithStubs != 0) {
261 <<
" **************************************************" << std::endl;
265 if (layersWithStubs < 2)
273 if (algoMuon->isValid()) {
275 << board.
name() <<
" " << *algoMuon <<
" RefHitNum " << algoMuon->getRefHitNumber() << std::endl;
277 if (algoMuon->getGpResultUnconstr().isValid())
279 <<
"GpResultUnconstr " << algoMuon->getGoldenPaternUnconstr()->key() <<
"\n" 280 << algoMuon->getGpResultUnconstr() << std::endl;
284 if (
gp->key().thePt == 0)
288 auto& gpResult =
gp->getResults()[iProc][algoMuon->getRefHitNumber()];
289 std::ostringstream ostr;
290 ostr <<
" " <<
gp->key()
293 <<
" Sum over layers: " << std::setw(5) << gpResult.getPdfSum()
294 <<
" Number of hits: " << std::setw(2) << gpResult.getFiredLayerCnt();
296 for (
unsigned int iLogicLayer = 0; iLogicLayer < gpResult.getStubResults().size(); ++iLogicLayer) {
297 ostr <<
" l: " << std::setw(2) << iLogicLayer <<
" p: ";
298 if (gpResult.getStubResults()[iLogicLayer].getMuonStub()) {
299 ostr << std::setw(2) << gpResult.getStubResults()[iLogicLayer].getPdfVal();
312 if (gbCandidate->isValid())
314 << board.
name() <<
" iProc " << iProc <<
" " << *gbCandidate << std::endl;
317 edm::LogVerbatim(
"l1tOmtfEventPrint") << std::endl << std::endl <<
"\ngb_test " << board.
name() << std::endl;
320 <<
" (" << std::setw(5) << algoMuon->getHwPatternNumConstr() <<
"," << std::setw(5)
321 << algoMuon->getHwPatternNumUnconstr() <<
"," 323 << std::setw(5) << algoMuon->getGpResultConstr().getFiredLayerCnt() <<
"," << std::setw(5)
324 << algoMuon->getGpResultUnconstr().getFiredLayerCnt()
328 << std::setw(6) << algoMuon->getGpResultConstr().getFiredLayerBits() * 2 <<
"," << std::setw(6)
329 << algoMuon->getGpResultUnconstr().getFiredLayerBits() * 2 <<
"," 331 << std::setw(5) << algoMuon->getGpResultConstr().getPdfSum() <<
"," << std::setw(5)
332 << algoMuon->getGpResultUnconstr().getPdfSumUnconstr() <<
"," 334 << std::setw(5) << algoMuon->getGpResultConstr().getPhi() <<
"," << std::setw(5)
335 << algoMuon->getGpResultUnconstr().getPhi()
339 << std::setw(5) << algoMuon->getEtaHw()
343 << std::setw(5) << algoMuon->getRefLayer() <<
"" 345 <<
"), " << std::endl;
350 <<
" (" << std::setw(5) << gbCandidate->getPtConstr() <<
"," << std::setw(5)
351 << gbCandidate->getPtUnconstr() <<
"," 353 << std::setw(5) << gbCandidate->getGpResultConstr().getFiredLayerCnt() <<
"," << std::setw(5)
354 << gbCandidate->getGpResultUnconstr().getFiredLayerCnt()
358 << std::setw(6) << gbCandidate->getGpResultConstr().getFiredLayerBits() * 2 <<
"," << std::setw(6)
359 << gbCandidate->getGpResultUnconstr().getFiredLayerBits() * 2 <<
"," 361 << std::setw(5) << gbCandidate->getGpResultConstr().getPdfSum() <<
"," << std::setw(5)
362 << gbCandidate->getGpResultUnconstr().getPdfSumUnconstr() <<
"," 364 << std::setw(5) << gbCandidate->getGpResultConstr().getPhi() <<
"," << std::setw(5)
365 << gbCandidate->getGpResultUnconstr().getPhi()
369 << std::setw(5) << gbCandidate->getEtaHw()
373 << std::setw(5) << gbCandidate->getRefLayer() <<
"" 376 <<
" -- getFiredLayerBits " << std::setw(5) << gbCandidate->getGpResultConstr().getFiredLayerBits()
381 std::ostringstream ostr;
382 if (finalCandidates->size(0) > 0) {
384 for (
auto finalCandidateIt = finalCandidates->begin(0); finalCandidateIt != finalCandidates->end(0);
385 finalCandidateIt++) {
386 auto& finalCandidate = *finalCandidateIt;
388 auto omtfName =
OmtfName(finalCandidate.processor(), finalCandidate.trackFinderType(),
omtfConfig);
390 if (omtfName == board.
name()) {
391 int layerHits = (
int)finalCandidate.trackAddress().at(0);
392 std::bitset<18> layerHitBits(layerHits);
394 unsigned int trackAddr = finalCandidate.trackAddress().at(0);
395 unsigned int uPt = finalCandidate.hwPtUnconstrained();
397 trackAddr = (uPt << 18) + trackAddr;
399 ostr <<
"M" << iMu <<
":" << std::setw(4) << finalCandidate.hwPt() <<
"," << std::setw(4)
400 << finalCandidate.hwQual() <<
"," << std::setw(4) << finalCandidate.hwPhi() <<
"," << std::setw(4)
404 << std::setw(10) << trackAddr <<
"," << std::setw(4) << 0 <<
"," 405 << std::setw(4) << finalCandidate.hwSign() <<
"," << std::setw(4) << 1 <<
"; ";
415 for (; iMu <= 3; iMu++)
416 ostr <<
"M" << iMu <<
": 0, 0, 0, 0, 0, 0, 0, 0; ";
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 ...
unsigned int nProcessors() const
std::vector< AlgoMuons > algoMuonsInProcs