CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
EventCapture Class Reference

#include <EventCapture.h>

Inheritance diagram for EventCapture:
IOMTFEmulationObserver

Public Member Functions

void beginRun (edm::EventSetup const &eventSetup) override
 
void endJob () override
 
 EventCapture (const edm::ParameterSet &edmCfg, const OMTFConfiguration *omtfConfig, CandidateSimMuonMatcher *candidateSimMuonMatcher, const MuonGeometryTokens &muonGeometryTokens, const GoldenPatternVec< GoldenPattern > *gps=nullptr)
 
void observeEventBegin (const edm::Event &event) override
 
void observeEventEnd (const edm::Event &event, std::unique_ptr< l1t::RegionalMuonCandBxCollection > &finalCandidates) 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
 
 ~EventCapture () override
 
- Public Member Functions inherited from IOMTFEmulationObserver
 IOMTFEmulationObserver ()
 
virtual ~IOMTFEmulationObserver ()
 

Private Attributes

std::vector< AlgoMuonsalgoMuonsInProcs
 
CandidateSimMuonMatchercandidateSimMuonMatcher = nullptr
 
std::vector< AlgoMuonsgbCandidatesInProcs
 
const GoldenPatternVec< GoldenPattern > * goldenPatterns = nullptr
 
std::vector< std::shared_ptr< OMTFinput > > inputInProcs
 
const OMTFConfigurationomtfConfig = nullptr
 
std::vector< edm::Ptr< SimTrack > > simMuons
 
edm::InputTag simTracksTag
 
std::unique_ptr< StubsSimHitsMatcherstubsSimHitsMatcher
 

Detailed Description

Definition at line 20 of file EventCapture.h.

Constructor & Destructor Documentation

◆ EventCapture()

EventCapture::EventCapture ( const edm::ParameterSet edmCfg,
const OMTFConfiguration omtfConfig,
CandidateSimMuonMatcher candidateSimMuonMatcher,
const MuonGeometryTokens muonGeometryTokens,
const GoldenPatternVec< GoldenPattern > *  gps = nullptr 
)

Definition at line 22 of file EventCapture.cc.

References edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), omtfConfig, simTracksTag, and stubsSimHitsMatcher.

28  goldenPatterns(gps),
33  //LogTrace("l1tOmtfEventPrint")<<__FUNCTION__<<":"<<__LINE__<<" omtfConfig->nProcessors() "<<omtfConfig->nProcessors()<<std::endl;
34  if (edmCfg.exists("simTracksTag"))
35  simTracksTag = edmCfg.getParameter<edm::InputTag>("simTracksTag");
36  else
37  edm::LogImportant("OMTFReconstruction")
38  << "EventCapture::EventCapture: no InputTag simTracksTag found" << std::endl;
39 
40  if (this->candidateSimMuonMatcher)
41  stubsSimHitsMatcher = std::make_unique<StubsSimHitsMatcher>(edmCfg, omtfConfig, muonGeometryTokens);
42 }
CandidateSimMuonMatcher * candidateSimMuonMatcher
Definition: EventCapture.h:52
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< AlgoMuons > gbCandidatesInProcs
Definition: EventCapture.h:58
bool exists(std::string const &parameterName) const
checks if a parameter exists
const OMTFConfiguration * omtfConfig
Definition: EventCapture.h:48
std::unique_ptr< StubsSimHitsMatcher > stubsSimHitsMatcher
Definition: EventCapture.h:60
edm::InputTag simTracksTag
Definition: EventCapture.h:47
Log< level::Error, true > LogImportant
const GoldenPatternVec< GoldenPattern > * goldenPatterns
Definition: EventCapture.h:50
unsigned int processorCnt() const
std::vector< std::shared_ptr< OMTFinput > > inputInProcs
Definition: EventCapture.h:56
std::vector< AlgoMuons > algoMuonsInProcs
Definition: EventCapture.h:57

◆ ~EventCapture()

EventCapture::~EventCapture ( )
override

Definition at line 44 of file EventCapture.cc.

44  {
45  // TODO Auto-generated destructor stub
46 }

Member Function Documentation

◆ beginRun()

void EventCapture::beginRun ( edm::EventSetup const &  eventSetup)
overridevirtual

Reimplemented from IOMTFEmulationObserver.

Definition at line 48 of file EventCapture.cc.

References options_cfi::eventSetup, and stubsSimHitsMatcher.

48  {
51 }
std::unique_ptr< StubsSimHitsMatcher > stubsSimHitsMatcher
Definition: EventCapture.h:60

◆ endJob()

void EventCapture::endJob ( void  )
overridevirtual

Implements IOMTFEmulationObserver.

Definition at line 297 of file EventCapture.cc.

References stubsSimHitsMatcher.

297  {
299  stubsSimHitsMatcher->endJob();
300 }
std::unique_ptr< StubsSimHitsMatcher > stubsSimHitsMatcher
Definition: EventCapture.h:60

◆ observeEventBegin()

void EventCapture::observeEventBegin ( const edm::Event event)
overridevirtual

Reimplemented from IOMTFEmulationObserver.

Definition at line 53 of file EventCapture.cc.

References funct::abs(), algoMuonsInProcs, gbCandidatesInProcs, input, inputInProcs, edm::InputTag::label(), edm::Handle< T >::product(), simMuons, and simTracksTag.

53  {
54  simMuons.clear();
55 
56  if (!simTracksTag.label().empty()) {
58  event.getByLabel(simTracksTag, simTraksHandle);
59 
60  for (unsigned int iSimTrack = 0; iSimTrack != simTraksHandle->size(); iSimTrack++) {
61  if (abs((*simTraksHandle.product())[iSimTrack].type()) == 13)
62  simMuons.emplace_back(simTraksHandle, iSimTrack);
63  }
64  }
65 
66  for (auto& input : inputInProcs)
67  input.reset();
68 
69  for (auto& algoMuonsInProc : algoMuonsInProcs)
70  algoMuonsInProc.clear();
71 
72  for (auto& gbCandidatesInProc : gbCandidatesInProcs)
73  gbCandidatesInProc.clear();
74 }
std::vector< AlgoMuons > gbCandidatesInProcs
Definition: EventCapture.h:58
T const * product() const
Definition: Handle.h:70
std::string const & label() const
Definition: InputTag.h:36
static std::string const input
Definition: EdmProvDump.cc:50
edm::InputTag simTracksTag
Definition: EventCapture.h:47
std::vector< edm::Ptr< SimTrack > > simMuons
Definition: EventCapture.h:54
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< std::shared_ptr< OMTFinput > > inputInProcs
Definition: EventCapture.h:56
std::vector< AlgoMuons > algoMuonsInProcs
Definition: EventCapture.h:57

◆ observeEventEnd()

void EventCapture::observeEventEnd ( const edm::Event event,
std::unique_ptr< l1t::RegionalMuonCandBxCollection > &  finalCandidates 
)
overridevirtual

!!!!!!!!!!!!!!!!!!!!!!! TODO dumps all events!!!!!!!!!!!!!!!!!!!!!!!!!!!!

printing

Reimplemented from IOMTFEmulationObserver.

Definition at line 90 of file EventCapture.cc.

References funct::abs(), algoMuonsInProcs, simKBmtfDigis_cfi::bx, candidateSimMuonMatcher, GCP_Ntuples_cfg::dump, gbCandidatesInProcs, CandidateSimMuonMatcher::getMatchingResults(), OMTFinputMaker::getProcessorPhiZero(), goldenPatterns, runTauDisplay::gp, OMTFConfiguration::hwPtToGev(), iEvent, inputInProcs, createfilelist::int, edm::InputTag::label(), pixelTopology::layer, M_PI, OmtfName::name(), l1t::omtf_neg, l1t::omtf_pos, omtfConfig, simMuonQualityAdjusterDigis_cfi::omtfInput, OMTFConfiguration::procHwPhiToGlobalPhi(), simMuons, simTracksTag, and stubsSimHitsMatcher.

91  {
92  std::ostringstream ostr;
93  //filtering
94 
95  bool dump = false;
96 
98  std::vector<MatchingResult> matchingResults = candidateSimMuonMatcher->getMatchingResults();
99  edm::LogVerbatim("l1tOmtfEventPrint") << "matchingResults.size() " << matchingResults.size() << std::endl;
100 
101  //candidateSimMuonMatcher should use the trackingParticles, because the simTracks are not stored for the pile-up events
102  for (auto& matchingResult : matchingResults) {
103  //TODO choose a condition, to print the desired candidates
104  if (matchingResult.muonCand && matchingResult.muonCand->hwQual() >= 12 &&
105  matchingResult.muonCand->hwPt() > 38) { //&& matchingResult.genPt < 20
106  dump = true;
107 
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() //<<" Beta "<<simMuon->momentum().Beta()
114  << " eta " << std::setw(9) << trackingParticle->momentum().eta() << " phi " << std::setw(9)
115  << trackingParticle->momentum().phi() << std::endl;
116  } else {
117  ostr << "no simMuon ";
118  runStubsSimHitsMatcher = true;
119  }
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;
126 
127  if (runStubsSimHitsMatcher)
128  stubsSimHitsMatcher->match(iEvent, matchingResult.muonCand, matchingResult.procMuon, ostr);
129  }
130  }
131  } else if (!simTracksTag.label().empty()) {
132  dump = false;
133  bool wasSimMuInOmtfPos = false;
134  bool wasSimMuInOmtfNeg = false;
135  for (auto& simMuon : simMuons) {
136  //TODO choose a condition, to print the desired events
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() //<<" Beta "<<simMuon->momentum().Beta()
141  << " eta " << std::setw(9) << simMuon->momentum().eta() << " phi " << std::setw(9)
142  << simMuon->momentum().phi() << std::endl;
143 
144  if (simMuon->momentum().eta() > 0)
145  wasSimMuInOmtfPos = true;
146  else
147  wasSimMuInOmtfNeg = true;
148  }
149  }
150 
151  bool wasCandInNeg = false;
152  bool wasCandInPos = false;
153 
154  for (auto& finalCandidate : *finalCandidates) {
155  //TODO choose a condition, to print the desired candidates
156  if (finalCandidate.trackFinderType() == l1t::tftype::omtf_neg && finalCandidate.hwQual() >= 12 &&
157  finalCandidate.hwPt() > 20)
158  wasCandInNeg = true;
159 
160  if (finalCandidate.trackFinderType() == l1t::tftype::omtf_pos && finalCandidate.hwQual() >= 12 &&
161  finalCandidate.hwPt() > 20)
162  wasCandInPos = true;
163  }
164 
165  if ((wasSimMuInOmtfNeg && wasCandInNeg)) //TODO
166  dump = true;
167 
168  if ((wasSimMuInOmtfPos && wasCandInPos)) //TODO
169  dump = true;
170  } else {
171  //TODO choose a condition, to print the desired candidates
172  // an example of a simple cut, only on the canidate pt
173  /*
174  for (auto& finalCandidate : *finalCandidates) {
175  if (finalCandidate.hwPt() < 41) { // finalCandidate.hwQual() >= 1 41
176  dump = true;
177  }
178  } */
180  dump = true; //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
181  }
182 
183  if (!dump)
184  return;
185 
187 
188  edm::LogVerbatim("l1tOmtfEventPrint") << "##################### EventCapture::observeEventEnd - dump of event "
189  << iEvent.id() << " #####################################################"
190  << std::endl;
191 
192  edm::LogVerbatim("l1tOmtfEventPrint") << ostr.str() << endl; //printing sim muons
193 
194  edm::LogVerbatim("l1tOmtfEventPrint") << "finalCandidates " << std::endl;
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();
200  // first processor starts at CMS phi = 15 degrees (24 in int)... Handle wrap-around with %. Add 576 to make sure the number is positive
201  globHwPhi = (globHwPhi + 600) % 576;
202 
203  double globalPhi = globHwPhi * 2. * M_PI / 576;
204  if (globalPhi > M_PI)
205  globalPhi = globalPhi - (2. * M_PI);
206 
207  int layerHits = (int)finalCandidate.trackAddress().at(0);
208  std::bitset<18> layerHitBits(layerHits);
209 
210  edm::LogVerbatim("l1tOmtfEventPrint")
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;
216 
217  for (auto& trackAddr : finalCandidate.trackAddress()) {
218  if (trackAddr.first >= 10)
219  edm::LogVerbatim("l1tOmtfEventPrint")
220  << "trackAddr first " << trackAddr.first << " second " << trackAddr.second << " ptGeV "
221  << omtfConfig->hwPtToGev(trackAddr.second);
222  }
223  }
224  }
225  edm::LogVerbatim("l1tOmtfEventPrint") << std::endl;
226 
227  for (unsigned int iProc = 0; iProc < inputInProcs.size(); iProc++) {
228  OmtfName board(iProc);
229 
230  std::ostringstream ostrInput;
231  if (inputInProcs[iProc]) {
232  auto& omtfInput = *inputInProcs[iProc];
233  int layersWithStubs = 0;
234  for (auto& layer : omtfInput.getMuonStubs()) {
235  for (auto& stub : layer) {
236  bool layerFired = false;
237  if (stub && (stub->type != MuonStub::Type::EMPTY)) {
238  layerFired = true;
239 
240  auto globalPhiRad = omtfConfig->procHwPhiToGlobalPhi(
241  stub->phiHw, OMTFinputMaker::getProcessorPhiZero(omtfConfig, iProc % 6));
242  ostrInput << (*stub) << " globalPhiRad " << globalPhiRad << std::endl;
243  }
244  if (layerFired)
245  layersWithStubs++;
246  }
247  }
248 
249  if (layersWithStubs != 0) {
250  edm::LogVerbatim("l1tOmtfEventPrint") << "\niProcessor " << iProc << " " << board.name()
251  << " **************************************************" << std::endl;
252  edm::LogVerbatim("l1tOmtfEventPrint") << ostrInput.str() << std::endl;
253  }
254 
255  if (layersWithStubs < 2)
256  continue;
257 
258  edm::LogVerbatim("l1tOmtfEventPrint") << *inputInProcs[iProc] << std::endl;
259 
260  edm::LogVerbatim("l1tOmtfEventPrint") << "algoMuons " << std::endl;
261  //unsigned int procIndx = omtfConfig->getProcIndx(iProcessor, mtfType);
262  for (auto& algoMuon : algoMuonsInProcs[iProc]) {
263  if (algoMuon->isValid()) {
264  edm::LogVerbatim("l1tOmtfEventPrint")
265  << board.name() << " " << *algoMuon << " RefHitNum " << algoMuon->getRefHitNumber() << std::endl;
266  edm::LogVerbatim("l1tOmtfEventPrint") << algoMuon->getGpResult() << std::endl;
267 
268  if (goldenPatterns) //watch out with the golden patterns
269  for (auto& gp : *goldenPatterns) {
270  if (gp->key().thePt == 0)
271  continue;
272 
273  //printing GoldenPatternResult, uncomment if needed
274  /*auto& gpResult = gp->getResults()[iProc][algoMuon->getRefHitNumber()];
275  edm::LogVerbatim("l1tOmtfEventPrint") << " "<<gp->key() << " "
276  //<< " refLayer: " << gpResult.getRefLayer() << "\t"
277  << " Sum over layers: " << gpResult.getPdfSum() << "\t"
278  << " Number of hits: " << gpResult.getFiredLayerCnt() << "\t"
279  << std::endl;*/
280  }
281  edm::LogVerbatim("l1tOmtfEventPrint") << std::endl << std::endl;
282  }
283  }
284 
285  edm::LogVerbatim("l1tOmtfEventPrint") << "gbCandidates " << std::endl;
286  for (auto& gbCandidate : gbCandidatesInProcs[iProc])
287  if (gbCandidate->isValid())
288  edm::LogVerbatim("l1tOmtfEventPrint") << board.name() << " " << *gbCandidate << std::endl;
289 
290  edm::LogVerbatim("l1tOmtfEventPrint") << std::endl;
291  }
292  }
293 
294  edm::LogVerbatim("l1tOmtfEventPrint") << std::endl;
295 }
Log< level::Info, true > LogVerbatim
CandidateSimMuonMatcher * candidateSimMuonMatcher
Definition: EventCapture.h:52
std::vector< AlgoMuons > gbCandidatesInProcs
Definition: EventCapture.h:58
const OMTFConfiguration * omtfConfig
Definition: EventCapture.h:48
double procHwPhiToGlobalPhi(int procHwPhi, int procHwPhi0) const
std::string const & label() const
Definition: InputTag.h:36
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
std::unique_ptr< StubsSimHitsMatcher > stubsSimHitsMatcher
Definition: EventCapture.h:60
edm::InputTag simTracksTag
Definition: EventCapture.h:47
int iEvent
Definition: GenABIO.cc:224
std::vector< edm::Ptr< SimTrack > > simMuons
Definition: EventCapture.h:54
static int getProcessorPhiZero(const OMTFConfiguration *config, unsigned int iProcessor)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double hwPtToGev(int hwPt) const override
uGMT pt scale conversion
const GoldenPatternVec< GoldenPattern > * goldenPatterns
Definition: EventCapture.h:50
#define M_PI
std::vector< MatchingResult > getMatchingResults()
std::vector< std::shared_ptr< OMTFinput > > inputInProcs
Definition: EventCapture.h:56
std::vector< AlgoMuons > algoMuonsInProcs
Definition: EventCapture.h:57

◆ observeProcesorEmulation()

void EventCapture::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 76 of file EventCapture.cc.

References algoMuonsInProcs, gbCandidatesInProcs, OMTFConfiguration::getProcIndx(), input, inputInProcs, and omtfConfig.

81  {
82  unsigned int procIndx = omtfConfig->getProcIndx(iProcessor, mtfType);
83 
84  inputInProcs[procIndx] = input;
85 
86  algoMuonsInProcs[procIndx] = algoCandidates;
87  gbCandidatesInProcs[procIndx] = gbCandidates;
88 }
std::vector< AlgoMuons > gbCandidatesInProcs
Definition: EventCapture.h:58
const OMTFConfiguration * omtfConfig
Definition: EventCapture.h:48
static std::string const input
Definition: EdmProvDump.cc:50
std::vector< std::shared_ptr< OMTFinput > > inputInProcs
Definition: EventCapture.h:56
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
Definition: EventCapture.h:57

Member Data Documentation

◆ algoMuonsInProcs

std::vector<AlgoMuons> EventCapture::algoMuonsInProcs
private

Definition at line 57 of file EventCapture.h.

Referenced by observeEventBegin(), observeEventEnd(), and observeProcesorEmulation().

◆ candidateSimMuonMatcher

CandidateSimMuonMatcher* EventCapture::candidateSimMuonMatcher = nullptr
private

Definition at line 52 of file EventCapture.h.

Referenced by observeEventEnd().

◆ gbCandidatesInProcs

std::vector<AlgoMuons> EventCapture::gbCandidatesInProcs
private

Definition at line 58 of file EventCapture.h.

Referenced by observeEventBegin(), observeEventEnd(), and observeProcesorEmulation().

◆ goldenPatterns

const GoldenPatternVec<GoldenPattern>* EventCapture::goldenPatterns = nullptr
private

Definition at line 50 of file EventCapture.h.

Referenced by observeEventEnd().

◆ inputInProcs

std::vector<std::shared_ptr<OMTFinput> > EventCapture::inputInProcs
private

Definition at line 56 of file EventCapture.h.

Referenced by observeEventBegin(), observeEventEnd(), and observeProcesorEmulation().

◆ omtfConfig

const OMTFConfiguration* EventCapture::omtfConfig = nullptr
private

Definition at line 48 of file EventCapture.h.

Referenced by EventCapture(), observeEventEnd(), and observeProcesorEmulation().

◆ simMuons

std::vector<edm::Ptr<SimTrack> > EventCapture::simMuons
private

Definition at line 54 of file EventCapture.h.

Referenced by observeEventBegin(), and observeEventEnd().

◆ simTracksTag

edm::InputTag EventCapture::simTracksTag
private

Definition at line 47 of file EventCapture.h.

Referenced by EventCapture(), observeEventBegin(), and observeEventEnd().

◆ stubsSimHitsMatcher

std::unique_ptr<StubsSimHitsMatcher> EventCapture::stubsSimHitsMatcher
private

Definition at line 60 of file EventCapture.h.

Referenced by beginRun(), endJob(), EventCapture(), and observeEventEnd().