38 : omtfConfig(omtfConfig), muonGeometryTokens(muonGeometryTokens) {
58 "stubsInLayersCntByPdgId;;OMTF layer;",
68 "firedLayersCntByPdgId",
77 ptByPdgId =
subDir.make<TH2I>(
"ptByPdgId",
"ptByPdgId bestMatched;;pT [GeV];#", 3, 0, 3, 20, 0, 10);
80 rhoByPdgId =
subDir.make<TH2I>(
"rhoByPdgId",
"rhoByPdgId bestMatched;;Rho [cm];#", 3, 0, 3, 50, 0, 500);
97 std::ostringstream& ostr) {
98 ostr <<
"stubsSimHitsMatching ---------------" << std::endl;
102 ostr <<
"rpcSimHitsHandle: size: " << rpcSimHitsHandle->size() << std::endl;
106 ostr << std::endl <<
"dtSimHitsHandle: size: " << dtSimHitsHandle->size() << std::endl;
110 ostr << std::endl <<
"cscSimHitsHandle: size: " << cscSimHitsHandle->size() << std::endl;
114 ostr <<
"rpcDigiSimLinkHandle: size: " << rpcDigiSimLinkHandle->size() << std::endl;
118 ostr <<
"cscStripDigiSimLinkHandle: size: " << cscStripDigiSimLinkHandle->size() << std::endl;
127 if (procMuon->isValid() && omtfCand) {
131 std::set<MatchedTrackInfo> matchedTrackInfos;
132 ostr << board.name() <<
" " << *procMuon << std::endl;
134 auto& gpResult = procMuon->getGpResult();
135 for (
unsigned int iLogicLayer = 0; iLogicLayer < gpResult.getStubResults().size(); ++iLogicLayer) {
136 auto& stub = gpResult.getStubResults()[iLogicLayer].getMuonStub();
137 if (stub && gpResult.isLayerFired(iLogicLayer)) {
141 DetId stubDetId(stub->detId);
144 <<
"!!!!!!!!!!!!!!!!!!!!!!!! PROBLEM: hit in unknown Det, detID: " << stubDetId.
det() << std::endl;
149 ostr << (*stub) <<
"\nstubGlobalPhi " << stubGlobalPhi << std::endl;
151 int matchedMuonHits = 0;
152 int matchedNotMuonHits = 0;
164 if (
abs(stubGlobalPhi - simHitStripGlobalPhi) < 0.02) {
168 matchedNotMuonHits++;
174 ostr <<
" simHitStripGlobalPhi " << std::setw(10) << simHitStripGlobalPhi <<
" strip " <<
strip 175 <<
" particleType: " <<
simHit.particleType() <<
" event: " <<
simHit.eventId().event()
176 <<
" trackId " <<
simHit.trackId() <<
" processType " <<
simHit.processType() <<
" detUnitId " 177 <<
simHit.detUnitId() <<
" " 182 <<
" entryPoint: x " << std::setw(10) <<
simHit.entryPoint().x() <<
" y " << std::setw(10)
183 <<
simHit.entryPoint().y() <<
" timeOfFlight " <<
simHit.timeOfFlight() << std::endl;
187 auto rpcDigiSimLinkDetSet = rpcDigiSimLinkHandle.
product()->find(stub->detId);
189 if (rpcDigiSimLinkDetSet != rpcDigiSimLinkHandle.
product()->end()) {
190 ostr <<
"rpcDigiSimLinkDetSet: detId " << rpcDigiSimLinkDetSet->detId() <<
" size " 191 << rpcDigiSimLinkDetSet->size() <<
"\n";
192 for (
auto& rpcDigiSimLink : *rpcDigiSimLinkDetSet) {
194 auto strip = rpcDigiSimLink.getStrip();
197 if (
abs(stubGlobalPhi - simHitStripGlobalPhi) < 0.02) {
198 auto matchedTrackInfo = matchedTrackInfos.insert(
199 MatchedTrackInfo(rpcDigiSimLink.getEventId().event(), rpcDigiSimLink.getTrackId()));
200 matchedTrackInfo.first->matchedDigiCnt.at(iLogicLayer)++;
203 ostr <<
" simHitStripGlobalPhi " << std::setw(10) << simHitStripGlobalPhi <<
" strip " <<
strip 204 <<
" particleType: " << rpcDigiSimLink.getParticleType()
205 <<
" event: " << rpcDigiSimLink.getEventId().event() <<
" trackId " << rpcDigiSimLink.getTrackId()
206 <<
" processType " << rpcDigiSimLink.getProcessType() <<
" detUnitId " 207 << rpcDigiSimLink.getDetUnitId() <<
" " 212 <<
" entryPoint: x " << std::setw(10) << rpcDigiSimLink.getEntryPoint().x() <<
" y " 213 << std::setw(10) << rpcDigiSimLink.getEntryPoint().y() <<
" timeOfFlight " 214 << rpcDigiSimLink.getTimeOfFlight() << std::endl;
227 auto simHitGlobalPoint =
layer->toGlobal(
simHit.localPosition());
229 ostr <<
" simHitGlobalPoint.phi " << std::setw(10)
230 << simHitGlobalPoint.phi()
232 <<
" particleType: " <<
simHit.particleType() <<
" event: " <<
simHit.eventId().event()
233 <<
" trackId " <<
simHit.trackId() <<
" processType " <<
simHit.processType() <<
" detUnitId " 234 <<
simHit.detUnitId() <<
" " 239 <<
" localPosition: x " << std::setw(10) <<
simHit.localPosition().x() <<
" y " << std::setw(10)
240 <<
simHit.localPosition().y() <<
" timeOfFlight " <<
simHit.timeOfFlight() << std::endl;
245 for (
auto superlayer :
chamber->superLayers()) {
246 if (superlayer->id().superLayer() == 2)
248 for (
auto layer : superlayer->layers()) {
249 auto dtDigiSimLinks = dtDigiSimLinkHandle.
product()->get(
layer->id());
250 ostr <<
"dt layer " <<
layer->id() <<
"\n";
251 auto dtDigiSimLink = dtDigiSimLinks.first;
253 for (; dtDigiSimLink != dtDigiSimLinks.second; dtDigiSimLink++) {
255 auto wire = dtDigiSimLink->wire();
257 auto wireX =
layer->specificTopology().wirePosition(wire);
262 if (
abs(stubGlobalPhi - digiWireGlobal.phi()) < 0.03) {
263 auto matchedTrackInfo = matchedTrackInfos.insert(
264 MatchedTrackInfo(dtDigiSimLink->eventId().event(), dtDigiSimLink->SimTrackId()));
265 matchedTrackInfo.first->matchedDigiCnt.at(iLogicLayer)++;
269 <<
" digiWireGlobalPhi " << std::setw(10) << digiWireGlobal.phi() <<
" wire " 272 <<
" event: " << dtDigiSimLink->eventId().event() <<
" trackId " 273 << dtDigiSimLink->SimTrackId()
296 auto simHitStrip =
layer->geometry()->strip(
simHit.localPosition());
297 auto simHitGlobalPoint =
layer->toGlobal(
simHit.localPosition());
298 auto simHitStripGlobalPhi =
layer->centerOfStrip(round(simHitStrip)).phi();
300 ostr <<
" simHit: gloablPoint phi " << simHitGlobalPoint.phi() <<
" stripGlobalPhi " 301 << simHitStripGlobalPhi.phi() <<
" strip " << simHitStrip
302 <<
" particleType: " <<
simHit.particleType() <<
" event: " <<
simHit.eventId().event()
303 <<
" trackId " <<
simHit.trackId() <<
" processType " <<
simHit.processType() <<
" detUnitId " 304 <<
simHit.detUnitId() <<
" " 311 <<
" x " <<
simHit.localPosition().x() <<
" y " <<
simHit.localPosition().y()
319 auto cscDigiSimLinkDetSet = cscStripDigiSimLinkHandle.
product()->find(
layer->id());
320 if (cscDigiSimLinkDetSet != cscStripDigiSimLinkHandle.
product()->end()) {
321 ostr <<
"cscDigiSimLinkDetSet: detId " << cscDigiSimLinkDetSet->detId() <<
" " <<
layer->id()
322 <<
" size " << cscDigiSimLinkDetSet->size() <<
"\n";
323 for (
auto& cscDigiSimLink : *cscDigiSimLinkDetSet) {
325 auto strip = cscDigiSimLink.channel();
326 auto digiStripGlobalPhi =
layer->centerOfStrip(
strip).phi();
328 if (
abs(stubGlobalPhi - digiStripGlobalPhi) < 0.03) {
329 auto matchedTrackInfo = matchedTrackInfos.insert(
330 MatchedTrackInfo(cscDigiSimLink.eventId().event(), cscDigiSimLink.SimTrackId()));
331 matchedTrackInfo.first->matchedDigiCnt.at(iLogicLayer)++;
334 <<
" digiStripGlobalPhi " << std::setw(10) << digiStripGlobalPhi <<
" strip " 337 <<
" event: " << cscDigiSimLink.eventId().event() <<
" trackId " 338 << cscDigiSimLink.SimTrackId()
351 ostr <<
"cscDigiSimLinkDetSet not found for detId " <<
layer->id();
358 ostr <<
"" << std::endl;
362 ostr << board.name() <<
" " << *procMuon << std::endl;
363 ostr << procMuon->getGpResult() << std::endl << std::endl;
365 int maxMatchedStubs = 0;
367 for (
auto matchedTrackInfo : matchedTrackInfos) {
368 ostr <<
"matchedTrackInfo eventNum " << matchedTrackInfo.eventNum <<
" trackId " << matchedTrackInfo.trackId
372 for (
auto& trackingParticle :
373 *trackingParticleHandle.
product()) {
374 if (trackingParticle.eventId().event() == matchedTrackInfo.eventNum &&
375 trackingParticle.g4Tracks().at(0).trackId() == matchedTrackInfo.trackId) {
377 matchedPart = &trackingParticle;
379 ostr <<
"trackingParticle: pdgId " << std::setw(3) << trackingParticle.
pdgId() <<
" event " << std::setw(4)
380 << trackingParticle.eventId().event() <<
" trackId " << std::setw(8)
381 << trackingParticle.g4Tracks().at(0).trackId() <<
" pt " << std::setw(9) << trackingParticle.pt()
382 <<
" eta " << std::setw(9) << trackingParticle.momentum().eta() <<
" phi " << std::setw(9)
383 << trackingParticle.momentum().phi() << std::endl;
385 if (trackingParticle.parentVertex().isNonnull()) {
386 ostr <<
"parentVertex Rho " << trackingParticle.parentVertex()->position().Rho() <<
" z " 387 << trackingParticle.parentVertex()->position().z() <<
" R " 388 << trackingParticle.parentVertex()->position().R() <<
" eta " 389 << trackingParticle.parentVertex()->position().eta() <<
" phi " 390 << trackingParticle.parentVertex()->position().phi() << std::endl;
392 for (
auto&
parentTrack : trackingParticle.parentVertex()->sourceTracks()) {
393 ostr <<
"parentTrack: pdgId " << std::setw(3) <<
parentTrack->pdgId() <<
" event " << std::setw(4)
394 <<
parentTrack->eventId().event() <<
" trackId " << std::setw(8)
396 << std::setw(9) <<
parentTrack->momentum().eta() <<
" phi " << std::setw(9)
405 int matchedStubsCnt = 0;
406 for (
unsigned int iLayer = 0; iLayer < matchedTrackInfo.matchedDigiCnt.size(); iLayer++) {
407 ostr <<
" matchedDigiCnt in layer " << iLayer <<
" " << matchedTrackInfo.matchedDigiCnt[iLayer] <<
"\n";
408 if (matchedTrackInfo.matchedDigiCnt[iLayer] > 0) {
418 if (maxMatchedStubs < matchedStubsCnt) {
419 maxMatchedStubs = matchedStubsCnt;
420 bestMatchedPart = matchedPart;
423 if (bestMatchedPart) {
434 ostr <<
"bestMatchedPart: pdgId " << std::setw(3) << bestMatchedPart->
pdgId() <<
" event " << std::setw(4)
435 << bestMatchedPart->
eventId().
event() <<
" trackId " << std::setw(8)
436 << bestMatchedPart->
g4Tracks().at(0).trackId() <<
"\n\n";
T getParameter(std::string const &) const
EncodedEventId eventId() const
Signal source, crossing number.
int event() const
get the contents of the subdetector field (should be protected?)
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeometryEsToken
virtual ~StubsSimHitsMatcher()
edm::ESWatcher< MuonGeometryRecord > muonGeometryRecordWatcher
const int processor() const
Get processor ID on which the candidate was found (0..5 for OMTF/EMTF; 0..11 for BMTF) ...
T const * product() const
edm::ESHandle< RPCGeometry > _georpc
double procHwPhiToGlobalPhi(int procHwPhi, int procHwPhi0) const
bool isNonnull() const
Checks for non-null.
std::string to_string(const V &value)
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
Log< level::Error, false > LogError
constexpr Detector det() const
get the detector field from this detid
TH2I * stubsInLayersCntByPdgId
const std::vector< SimTrack > & g4Tracks() const
constexpr std::array< uint8_t, layerIndexSize > layer
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > rpcGeometryEsToken
edm::ESHandle< CSCGeometry > _geocsc
StubsSimHitsMatcher(const edm::ParameterSet &edmCfg, const OMTFConfiguration *omtfConfig, const MuonGeometryTokens &muonGeometryTokens)
const OMTFConfiguration * omtfConfig
TH2I * firedLayersCntByPdgId
const tftype trackFinderType() const
Get track-finder which found the muon (bmtf, emtf_pos/emtf_neg or omtf_pos/omtf_neg) ...
const MuonGeometryTokens & muonGeometryTokens
Abs< T >::type abs(const T &t)
edm::InputTag rpcDigiSimLinkInputTag
unsigned int nLayers() const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
edm::InputTag cscStripDigiSimLinksInputTag
TH1I * bestMatchedTracksPdgIds
edm::InputTag rpcSimHitsInputTag
edm::InputTag dtDigiSimLinksInputTag
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
edm::ESHandle< DTGeometry > _geodt
const TrackingVertexRef & parentVertex() const
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeometryEsToken
edm::InputTag cscSimHitsInputTag
constexpr uint32_t rawId() const
get the raw id
edm::InputTag trackingParticleTag
TH1I * allMatchedTracksPdgIds
bool check(const edm::EventSetup &iSetup)
void beginRun(edm::EventSetup const &eventSetup)
float strip(const LocalPoint &lp) const
Monte Carlo truth information used for tracking validation.
void match(const edm::Event &iEvent, const l1t::RegionalMuonCand *omtfCand, const AlgoMuonPtr &procMuon, std::ostringstream &ostr)
std::shared_ptr< AlgoMuon > AlgoMuonPtr
double pt() const
Transverse momentum. Note this is taken from the first SimTrack only.
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
edm::InputTag dtSimHitsInputTag
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
bool isBendingLayer(unsigned int iLayer) const override
LocalPoint centreOfStrip(int strip) const
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.