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;
159 double simHitStripGlobalPhi = (
roll->toGlobal(
roll->centreOfStrip((
int)
strip))).phi();
161 if (
abs(stubGlobalPhi - simHitStripGlobalPhi) < 0.02) {
165 ostr <<
" simHitStripGlobalPhi " << std::setw(10) << simHitStripGlobalPhi <<
" strip " <<
strip 166 <<
" particleType: " <<
simHit.particleType() <<
" event: " <<
simHit.eventId().event()
167 <<
" trackId " <<
simHit.trackId() <<
" processType " <<
simHit.processType() <<
" detUnitId " 168 <<
simHit.detUnitId() <<
" " 173 <<
" entryPoint: x " << std::setw(10) <<
simHit.entryPoint().x() <<
" y " << std::setw(10)
174 <<
simHit.entryPoint().y() <<
" timeOfFlight " <<
simHit.timeOfFlight() << std::endl;
178 auto rpcDigiSimLinkDetSet = rpcDigiSimLinkHandle.
product()->find(stub->detId);
180 if (rpcDigiSimLinkDetSet != rpcDigiSimLinkHandle.
product()->end()) {
181 ostr <<
"rpcDigiSimLinkDetSet: detId " << rpcDigiSimLinkDetSet->detId() <<
" size " 182 << rpcDigiSimLinkDetSet->size() <<
"\n";
183 for (
auto& rpcDigiSimLink : *rpcDigiSimLinkDetSet) {
185 auto strip = rpcDigiSimLink.getStrip();
186 double simHitStripGlobalPhi = (
roll->toGlobal(
roll->centreOfStrip((
int)
strip))).phi();
188 if (
abs(stubGlobalPhi - simHitStripGlobalPhi) < 0.02) {
189 auto matchedTrackInfo = matchedTrackInfos.insert(
190 MatchedTrackInfo(rpcDigiSimLink.getEventId().event(), rpcDigiSimLink.getTrackId()));
191 matchedTrackInfo.first->matchedDigiCnt.at(iLogicLayer)++;
194 ostr <<
" simHitStripGlobalPhi " << std::setw(10) << simHitStripGlobalPhi <<
" strip " <<
strip 195 <<
" particleType: " << rpcDigiSimLink.getParticleType()
196 <<
" event: " << rpcDigiSimLink.getEventId().event() <<
" trackId " << rpcDigiSimLink.getTrackId()
197 <<
" processType " << rpcDigiSimLink.getProcessType() <<
" detUnitId " 198 << rpcDigiSimLink.getDetUnitId() <<
" " 203 <<
" entryPoint: x " << std::setw(10) << rpcDigiSimLink.getEntryPoint().x() <<
" y " 204 << std::setw(10) << rpcDigiSimLink.getEntryPoint().y() <<
" timeOfFlight " 205 << rpcDigiSimLink.getTimeOfFlight() << std::endl;
218 auto simHitGlobalPoint =
layer->toGlobal(
simHit.localPosition());
220 ostr <<
" simHitGlobalPoint.phi " << std::setw(10)
221 << simHitGlobalPoint.phi()
223 <<
" particleType: " <<
simHit.particleType() <<
" event: " <<
simHit.eventId().event()
224 <<
" trackId " <<
simHit.trackId() <<
" processType " <<
simHit.processType() <<
" detUnitId " 225 <<
simHit.detUnitId() <<
" " 230 <<
" localPosition: x " << std::setw(10) <<
simHit.localPosition().x() <<
" y " << std::setw(10)
231 <<
simHit.localPosition().y() <<
" timeOfFlight " <<
simHit.timeOfFlight() << std::endl;
236 for (
auto superlayer :
chamber->superLayers()) {
237 if (superlayer->id().superLayer() == 2)
239 for (
auto layer : superlayer->layers()) {
240 auto dtDigiSimLinks = dtDigiSimLinkHandle.
product()->get(
layer->id());
241 ostr <<
"dt layer " <<
layer->id() <<
"\n";
242 auto dtDigiSimLink = dtDigiSimLinks.first;
244 for (; dtDigiSimLink != dtDigiSimLinks.second; dtDigiSimLink++) {
246 auto wire = dtDigiSimLink->wire();
248 auto wireX =
layer->specificTopology().wirePosition(
wire);
253 if (
abs(stubGlobalPhi - digiWireGlobal.phi()) < 0.03) {
254 auto matchedTrackInfo = matchedTrackInfos.insert(
255 MatchedTrackInfo(dtDigiSimLink->eventId().event(), dtDigiSimLink->SimTrackId()));
256 matchedTrackInfo.first->matchedDigiCnt.at(iLogicLayer)++;
260 <<
" digiWireGlobalPhi " << std::setw(10) << digiWireGlobal.phi() <<
" wire " 263 <<
" event: " << dtDigiSimLink->eventId().event() <<
" trackId " 264 << dtDigiSimLink->SimTrackId()
287 auto simHitStrip =
layer->geometry()->strip(
simHit.localPosition());
288 auto simHitGlobalPoint =
layer->toGlobal(
simHit.localPosition());
289 auto simHitStripGlobalPhi =
layer->centerOfStrip(round(simHitStrip)).phi();
291 ostr <<
" simHit: gloablPoint phi " << simHitGlobalPoint.phi() <<
" stripGlobalPhi " 292 << simHitStripGlobalPhi.phi() <<
" strip " << simHitStrip
293 <<
" particleType: " <<
simHit.particleType() <<
" event: " <<
simHit.eventId().event()
294 <<
" trackId " <<
simHit.trackId() <<
" processType " <<
simHit.processType() <<
" detUnitId " 295 <<
simHit.detUnitId() <<
" " 302 <<
" x " <<
simHit.localPosition().x() <<
" y " <<
simHit.localPosition().y()
310 auto cscDigiSimLinkDetSet = cscStripDigiSimLinkHandle.
product()->find(
layer->id());
311 if (cscDigiSimLinkDetSet != cscStripDigiSimLinkHandle.
product()->end()) {
312 ostr <<
"cscDigiSimLinkDetSet: detId " << cscDigiSimLinkDetSet->detId() <<
" " <<
layer->id()
313 <<
" size " << cscDigiSimLinkDetSet->size() <<
"\n";
314 for (
auto& cscDigiSimLink : *cscDigiSimLinkDetSet) {
316 auto strip = cscDigiSimLink.channel();
317 auto digiStripGlobalPhi =
layer->centerOfStrip(
strip).phi();
319 if (
abs(stubGlobalPhi - digiStripGlobalPhi) < 0.03) {
320 auto matchedTrackInfo = matchedTrackInfos.insert(
321 MatchedTrackInfo(cscDigiSimLink.eventId().event(), cscDigiSimLink.SimTrackId()));
322 matchedTrackInfo.first->matchedDigiCnt.at(iLogicLayer)++;
325 <<
" digiStripGlobalPhi " << std::setw(10) << digiStripGlobalPhi <<
" strip " 328 <<
" event: " << cscDigiSimLink.eventId().event() <<
" trackId " 329 << cscDigiSimLink.SimTrackId()
342 ostr <<
"cscDigiSimLinkDetSet not found for detId " <<
layer->id();
349 ostr <<
"" << std::endl;
353 ostr << board.name() <<
" " << *procMuon << std::endl;
354 ostr << procMuon->getGpResult() << std::endl << std::endl;
356 int maxMatchedStubs = 0;
358 for (
auto matchedTrackInfo : matchedTrackInfos) {
359 ostr <<
"matchedTrackInfo eventNum " << matchedTrackInfo.eventNum <<
" trackId " << matchedTrackInfo.trackId
363 for (
auto& trackingParticle :
364 *trackingParticleHandle.
product()) {
365 if (trackingParticle.eventId().event() == matchedTrackInfo.eventNum &&
366 trackingParticle.g4Tracks().at(0).trackId() == matchedTrackInfo.trackId) {
368 matchedPart = &trackingParticle;
370 ostr <<
"trackingParticle: pdgId " << std::setw(3) << trackingParticle.
pdgId() <<
" event " << std::setw(4)
371 << trackingParticle.eventId().event() <<
" trackId " << std::setw(8)
372 << trackingParticle.g4Tracks().at(0).trackId() <<
" pt " << std::setw(9) << trackingParticle.pt()
373 <<
" eta " << std::setw(9) << trackingParticle.momentum().eta() <<
" phi " << std::setw(9)
374 << trackingParticle.momentum().phi() << std::endl;
376 if (trackingParticle.parentVertex().isNonnull()) {
377 ostr <<
"parentVertex Rho " << trackingParticle.parentVertex()->position().Rho() <<
" z " 378 << trackingParticle.parentVertex()->position().z() <<
" R " 379 << trackingParticle.parentVertex()->position().R() <<
" eta " 380 << trackingParticle.parentVertex()->position().eta() <<
" phi " 381 << trackingParticle.parentVertex()->position().phi() << std::endl;
383 for (
auto&
parentTrack : trackingParticle.parentVertex()->sourceTracks()) {
384 ostr <<
"parentTrack: pdgId " << std::setw(3) <<
parentTrack->pdgId() <<
" event " << std::setw(4)
385 <<
parentTrack->eventId().event() <<
" trackId " << std::setw(8)
387 << std::setw(9) <<
parentTrack->momentum().eta() <<
" phi " << std::setw(9)
396 int matchedStubsCnt = 0;
397 for (
unsigned int iLayer = 0; iLayer < matchedTrackInfo.matchedDigiCnt.size(); iLayer++) {
398 ostr <<
" matchedDigiCnt in layer " << iLayer <<
" " << matchedTrackInfo.matchedDigiCnt[iLayer] <<
"\n";
399 if (matchedTrackInfo.matchedDigiCnt[iLayer] > 0) {
409 if (maxMatchedStubs < matchedStubsCnt) {
410 maxMatchedStubs = matchedStubsCnt;
411 bestMatchedPart = matchedPart;
414 if (bestMatchedPart) {
425 ostr <<
"bestMatchedPart: pdgId " << std::setw(3) << bestMatchedPart->
pdgId() <<
" event " << std::setw(4)
426 << bestMatchedPart->
eventId().
event() <<
" trackId " << std::setw(8)
427 << 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.
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
static std::string to_string(const XMLCh *ch)
const std::vector< SimTrack > & g4Tracks() const
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
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)
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
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.