CMS 3D CMS Logo

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

#include <StubsSimHitsMatcher.h>

Classes

class  MatchedTrackInfo
 

Public Member Functions

void beginRun (edm::EventSetup const &eventSetup)
 
void endJob ()
 
void match (const edm::Event &iEvent, const l1t::RegionalMuonCand *omtfCand, const AlgoMuonPtr &procMuon, std::ostringstream &ostr)
 
 StubsSimHitsMatcher (const edm::ParameterSet &edmCfg, const OMTFConfiguration *omtfConfig, const MuonGeometryTokens &muonGeometryTokens)
 
virtual ~StubsSimHitsMatcher ()
 

Private Attributes

edm::ESHandle< CSCGeometry_geocsc
 
edm::ESHandle< DTGeometry_geodt
 
unsigned long long _geom_cache_id = 0
 
edm::ESHandle< RPCGeometry_georpc
 
TH1I * allMatchedTracksPdgIds = nullptr
 
TH1I * bestMatchedTracksPdgIds = nullptr
 
edm::InputTag cscSimHitsInputTag
 
edm::InputTag cscStripDigiSimLinksInputTag
 
edm::InputTag dtDigiSimLinksInputTag
 
edm::InputTag dtSimHitsInputTag
 
TH2I * firedLayersCntByPdgId = nullptr
 
edm::ESWatcher< MuonGeometryRecordmuonGeometryRecordWatcher
 
const MuonGeometryTokensmuonGeometryTokens
 
const OMTFConfigurationomtfConfig
 
TH2I * ptByPdgId = nullptr
 
TH2I * rhoByPdgId = nullptr
 
edm::InputTag rpcDigiSimLinkInputTag
 
edm::InputTag rpcSimHitsInputTag
 
TH2I * stubsInLayersCntByPdgId = nullptr
 
edm::InputTag trackingParticleTag
 

Detailed Description

Definition at line 30 of file StubsSimHitsMatcher.h.

Constructor & Destructor Documentation

◆ StubsSimHitsMatcher()

StubsSimHitsMatcher::StubsSimHitsMatcher ( const edm::ParameterSet edmCfg,
const OMTFConfiguration omtfConfig,
const MuonGeometryTokens muonGeometryTokens 
)

Definition at line 35 of file StubsSimHitsMatching.cc.

References allMatchedTracksPdgIds, bestMatchedTracksPdgIds, cscSimHitsInputTag, cscStripDigiSimLinksInputTag, dtDigiSimLinksInputTag, dtSimHitsInputTag, firedLayersCntByPdgId, compareTotals::fs, edm::ParameterSet::getParameter(), OMTFConfiguration::nLayers(), omtfConfig, ptByPdgId, rhoByPdgId, rpcDigiSimLinkInputTag, rpcSimHitsInputTag, stubsInLayersCntByPdgId, PostProcessorHcalIsoTrack_cfi::subDir, and trackingParticleTag.

39  rpcSimHitsInputTag = edmCfg.getParameter<edm::InputTag>("rpcSimHitsInputTag");
40  cscSimHitsInputTag = edmCfg.getParameter<edm::InputTag>("cscSimHitsInputTag");
41  dtSimHitsInputTag = edmCfg.getParameter<edm::InputTag>("dtSimHitsInputTag");
42 
43  rpcDigiSimLinkInputTag = edmCfg.getParameter<edm::InputTag>("rpcDigiSimLinkInputTag");
44  cscStripDigiSimLinksInputTag = edmCfg.getParameter<edm::InputTag>("cscStripDigiSimLinksInputTag");
45  dtDigiSimLinksInputTag = edmCfg.getParameter<edm::InputTag>("dtDigiSimLinksInputTag");
46 
47  trackingParticleTag = edmCfg.getParameter<edm::InputTag>("trackingParticleTag");
48 
50  TFileDirectory subDir = fs->mkdir("StubsSimHitsMatcher");
51 
52  allMatchedTracksPdgIds = subDir.make<TH1I>("allMatchedTracksPdgIds", "allMatchedTracksPdgIds", 3, 0, 3);
53  allMatchedTracksPdgIds->SetCanExtend(TH1::kAllAxes);
54  bestMatchedTracksPdgIds = subDir.make<TH1I>("bestMatchedTracksPdgIds", "bestMatchedTracksPdgIds", 3, 0, 3);
55  bestMatchedTracksPdgIds->SetCanExtend(TH1::kAllAxes);
56 
57  stubsInLayersCntByPdgId = subDir.make<TH2I>("stubsInLayersCntByPdgId",
58  "stubsInLayersCntByPdgId;;OMTF layer;",
59  3,
60  0,
61  3,
63  -.5,
64  omtfConfig->nLayers() - 0.5);
65  stubsInLayersCntByPdgId->SetCanExtend(TH1::kAllAxes);
66 
67  firedLayersCntByPdgId = subDir.make<TH2I>("firedLayersCntByPdgId",
68  "firedLayersCntByPdgId",
69  3,
70  0,
71  3,
73  -.5,
74  omtfConfig->nLayers() - 0.5);
75  firedLayersCntByPdgId->SetCanExtend(TH1::kAllAxes);
76 
77  ptByPdgId = subDir.make<TH2I>("ptByPdgId", "ptByPdgId bestMatched;;pT [GeV];#", 3, 0, 3, 20, 0, 10);
78  ptByPdgId->SetCanExtend(TH1::kAllAxes);
79 
80  rhoByPdgId = subDir.make<TH2I>("rhoByPdgId", "rhoByPdgId bestMatched;;Rho [cm];#", 3, 0, 3, 50, 0, 500);
81  rhoByPdgId->SetCanExtend(TH1::kAllAxes);
82 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const OMTFConfiguration * omtfConfig
const MuonGeometryTokens & muonGeometryTokens
edm::InputTag rpcDigiSimLinkInputTag
unsigned int nLayers() const
edm::InputTag cscStripDigiSimLinksInputTag
edm::InputTag rpcSimHitsInputTag
edm::InputTag dtDigiSimLinksInputTag
edm::InputTag cscSimHitsInputTag
edm::InputTag trackingParticleTag
edm::InputTag dtSimHitsInputTag

◆ ~StubsSimHitsMatcher()

StubsSimHitsMatcher::~StubsSimHitsMatcher ( )
virtual

Definition at line 84 of file StubsSimHitsMatching.cc.

84 {}

Member Function Documentation

◆ beginRun()

void StubsSimHitsMatcher::beginRun ( edm::EventSetup const &  eventSetup)

Definition at line 86 of file StubsSimHitsMatching.cc.

References _geocsc, _geodt, _georpc, edm::ESWatcher< T >::check(), MuonGeometryTokens::cscGeometryEsToken, MuonGeometryTokens::dtGeometryEsToken, options_cfi::eventSetup, muonGeometryRecordWatcher, muonGeometryTokens, and MuonGeometryTokens::rpcGeometryEsToken.

86  {
91  }
92 }
edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeometryEsToken
edm::ESWatcher< MuonGeometryRecord > muonGeometryRecordWatcher
edm::ESHandle< RPCGeometry > _georpc
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > rpcGeometryEsToken
edm::ESHandle< CSCGeometry > _geocsc
const MuonGeometryTokens & muonGeometryTokens
edm::ESHandle< DTGeometry > _geodt
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeometryEsToken
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57

◆ endJob()

void StubsSimHitsMatcher::endJob ( void  )

Definition at line 432 of file StubsSimHitsMatching.cc.

432  {
433  /*edm::LogVerbatim("l1tOmtfEventPrint") <<"allMatchedTracksPdgIds "<<std::endl;
434  for(auto pdgId : allMatchedTracksPdgIds) {
435  edm::LogVerbatim("l1tOmtfEventPrint") <<"pdgId "<<std::setw(8)<<pdgId.first<<" muon candidates "<<pdgId.second<<std::endl;
436  }
437 
438  edm::LogVerbatim("l1tOmtfEventPrint") <<"bestMatchedTracksPdgIds "<<std::endl;
439  for(auto pdgId : bestMatchedTracksPdgIds) {
440  edm::LogVerbatim("l1tOmtfEventPrint") <<"pdgId "<<std::setw(8) <<pdgId.first<<" muon candidates "<<pdgId.second<<std::endl;
441  }*/
442 }

◆ match()

void StubsSimHitsMatcher::match ( const edm::Event iEvent,
const l1t::RegionalMuonCand omtfCand,
const AlgoMuonPtr procMuon,
std::ostringstream &  ostr 
)

Definition at line 94 of file StubsSimHitsMatching.cc.

References _geocsc, _geodt, _georpc, funct::abs(), allMatchedTracksPdgIds, bestMatchedTracksPdgIds, relativeConstraints::chamber, CSCGeometry::chamber(), DTGeometry::chamber(), MuonSubdetId::CSC, cscSimHitsInputTag, cscStripDigiSimLinksInputTag, DetId::det(), MuonSubdetId::DT, dtDigiSimLinksInputTag, dtSimHitsInputTag, EncodedEventId::event(), TrackingParticle::eventId(), firedLayersCntByPdgId, TrackingParticle::g4Tracks(), OMTFinputMaker::getProcessorPhiZero(), iEvent, OMTFConfiguration::isBendingLayer(), edm::Ref< C, T, F >::isNonnull(), nano_mu_digi_cff::layer, CSCGeometry::layer(), DTGeometry::layer(), DetId::Muon, omtfConfig, cosmicMuonLinks_cfi::parentTrack, TrackingParticle::parentVertex(), TrackingParticle::pdgId(), point, l1t::RegionalMuonCand::processor(), OMTFConfiguration::procHwPhiToGlobalPhi(), edm::Handle< T >::product(), TrackingParticle::pt(), ptByPdgId, DetId::rawId(), rhoByPdgId, nano_mu_digi_cff::roll, RPCGeometry::roll(), MuonSubdetId::RPC, rpcDigiSimLinkInputTag, rpcSimHitsInputTag, rpcPointValidation_cfi::simHit, str, nano_mu_digi_cff::strip, stubsInLayersCntByPdgId, DetId::subdetId(), to_string(), l1t::RegionalMuonCand::trackFinderType(), trackingParticleTag, and nano_mu_digi_cff::wire.

97  {
98  ostr << "stubsSimHitsMatching ---------------" << std::endl;
99 
100  edm::Handle<edm::PSimHitContainer> rpcSimHitsHandle;
101  iEvent.getByLabel(rpcSimHitsInputTag, rpcSimHitsHandle);
102  ostr << "rpcSimHitsHandle: size: " << rpcSimHitsHandle->size() << std::endl;
103 
104  edm::Handle<edm::PSimHitContainer> dtSimHitsHandle;
105  iEvent.getByLabel(dtSimHitsInputTag, dtSimHitsHandle);
106  ostr << std::endl << "dtSimHitsHandle: size: " << dtSimHitsHandle->size() << std::endl;
107 
108  edm::Handle<edm::PSimHitContainer> cscSimHitsHandle;
109  iEvent.getByLabel(cscSimHitsInputTag, cscSimHitsHandle);
110  ostr << std::endl << "cscSimHitsHandle: size: " << cscSimHitsHandle->size() << std::endl;
111 
112  edm::Handle<edm::DetSetVector<RPCDigiSimLink> > rpcDigiSimLinkHandle;
113  iEvent.getByLabel(rpcDigiSimLinkInputTag, rpcDigiSimLinkHandle);
114  ostr << "rpcDigiSimLinkHandle: size: " << rpcDigiSimLinkHandle->size() << std::endl;
115 
116  edm::Handle<edm::DetSetVector<StripDigiSimLink> > cscStripDigiSimLinkHandle;
117  iEvent.getByLabel(cscStripDigiSimLinksInputTag, cscStripDigiSimLinkHandle);
118  ostr << "cscStripDigiSimLinkHandle: size: " << cscStripDigiSimLinkHandle->size() << std::endl;
119 
121  iEvent.getByLabel(dtDigiSimLinksInputTag, dtDigiSimLinkHandle);
122  //ostr<<"dtDigiSimLinkHandle: size: " << dtDigiSimLinkHandle->size()<<std::endl;
123 
124  edm::Handle<TrackingParticleCollection> trackingParticleHandle;
125  iEvent.getByLabel(trackingParticleTag, trackingParticleHandle);
126 
127  if (procMuon->isValid() && omtfCand) {
128  OmtfName board(omtfCand->processor(), omtfCand->trackFinderType());
129  auto processorPhiZero = OMTFinputMaker::getProcessorPhiZero(omtfConfig, omtfCand->processor());
130 
131  std::set<MatchedTrackInfo> matchedTrackInfos;
132  ostr << board.name() << " " << *procMuon << std::endl;
133 
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)) {
138  if (omtfConfig->isBendingLayer(iLogicLayer))
139  continue;
140 
141  DetId stubDetId(stub->detId);
142  if (stubDetId.det() != DetId::Muon) {
143  edm::LogError("l1tOmtfEventPrint")
144  << "!!!!!!!!!!!!!!!!!!!!!!!! PROBLEM: hit in unknown Det, detID: " << stubDetId.det() << std::endl;
145  continue;
146  }
147 
148  auto stubGlobalPhi = omtfConfig->procHwPhiToGlobalPhi(stub->phiHw, processorPhiZero);
149  ostr << (*stub) << "\nstubGlobalPhi " << stubGlobalPhi << std::endl;
150 
151  switch (stubDetId.subdetId()) {
152  case MuonSubdetId::RPC: {
153  RPCDetId rpcDetId(stubDetId);
154 
155  for (auto& simHit : *(rpcSimHitsHandle.product())) {
156  if (stubDetId.rawId() == simHit.detUnitId()) {
157  const RPCRoll* roll = _georpc->roll(rpcDetId);
158  auto strip = roll->strip(simHit.localPosition());
159  double simHitStripGlobalPhi = (roll->toGlobal(roll->centreOfStrip((int)strip))).phi();
160 
161  if (abs(stubGlobalPhi - simHitStripGlobalPhi) < 0.02) {
162  matchedTrackInfos.insert(MatchedTrackInfo(simHit.eventId().event(), simHit.trackId()));
163  }
164 
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() << " "
169  << rpcDetId
170  //<<" phiAtEntry "<<simHit.phiAtEntry()
171  //<<" thetaAtEntry "<<simHit.thetaAtEntry()
172  //<<" localPosition: phi "<<simHit.localPosition().phi()<<" eta "<<simHit.localPosition().eta()
173  << " entryPoint: x " << std::setw(10) << simHit.entryPoint().x() << " y " << std::setw(10)
174  << simHit.entryPoint().y() << " timeOfFlight " << simHit.timeOfFlight() << std::endl;
175  }
176  }
177 
178  auto rpcDigiSimLinkDetSet = rpcDigiSimLinkHandle.product()->find(stub->detId);
179 
180  if (rpcDigiSimLinkDetSet != rpcDigiSimLinkHandle.product()->end()) {
181  ostr << "rpcDigiSimLinkDetSet: detId " << rpcDigiSimLinkDetSet->detId() << " size "
182  << rpcDigiSimLinkDetSet->size() << "\n";
183  for (auto& rpcDigiSimLink : *rpcDigiSimLinkDetSet) {
184  const RPCRoll* roll = _georpc->roll(rpcDetId);
185  auto strip = rpcDigiSimLink.getStrip();
186  double simHitStripGlobalPhi = (roll->toGlobal(roll->centreOfStrip((int)strip))).phi();
187 
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)++;
192  }
193 
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() << " "
199  << rpcDetId
200  //<<" phiAtEntry "<<simHit.phiAtEntry()
201  //<<" thetaAtEntry "<<simHit.thetaAtEntry()
202  //<<" localPosition: phi "<<simHit.localPosition().phi()<<" eta "<<simHit.localPosition().eta()
203  << " entryPoint: x " << std::setw(10) << rpcDigiSimLink.getEntryPoint().x() << " y "
204  << std::setw(10) << rpcDigiSimLink.getEntryPoint().y() << " timeOfFlight "
205  << rpcDigiSimLink.getTimeOfFlight() << std::endl;
206  }
207  }
208 
209  break;
210  } //----------------------------------------------------------------------
211  case MuonSubdetId::DT: {
212  //DTChamberId dt(stubDetId);
213  for (auto& simHit : *(dtSimHitsHandle.product())) {
214  const DTLayer* layer = _geodt->layer(DTLayerId(simHit.detUnitId()));
215  const DTChamber* chamber = layer->chamber();
216  if (stubDetId.rawId() == chamber->id().rawId()) {
217  //auto strip = layer->geometry()->strip(simHit.localPosition());
218  auto simHitGlobalPoint = layer->toGlobal(simHit.localPosition());
219 
220  ostr << " simHitGlobalPoint.phi " << std::setw(10)
221  << simHitGlobalPoint.phi()
222  //<<" strip "<<strip
223  << " particleType: " << simHit.particleType() << " event: " << simHit.eventId().event()
224  << " trackId " << simHit.trackId() << " processType " << simHit.processType() << " detUnitId "
225  << simHit.detUnitId() << " "
226  << layer->id()
227  //<<" phiAtEntry "<<simHit.phiAtEntry()
228  //<<" thetaAtEntry "<<simHit.thetaAtEntry()
229  //<<" localPosition: phi "<<simHit.localPosition().phi()<<" eta "<<simHit.localPosition().eta()
230  << " localPosition: x " << std::setw(10) << simHit.localPosition().x() << " y " << std::setw(10)
231  << simHit.localPosition().y() << " timeOfFlight " << simHit.timeOfFlight() << std::endl;
232  }
233  }
234 
235  auto chamber = _geodt->chamber(DTLayerId(stub->detId));
236  for (auto superlayer : chamber->superLayers()) {
237  if (superlayer->id().superLayer() == 2) //we skip the theta layer
238  continue;
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;
243 
244  for (; dtDigiSimLink != dtDigiSimLinks.second; dtDigiSimLink++) {
245  //const RPCRoll* roll = _georpc->roll(rpcDetId);
246  auto wire = dtDigiSimLink->wire();
247 
248  auto wireX = layer->specificTopology().wirePosition(wire);
249 
250  LocalPoint point(wireX, 0, 0);
251  auto digiWireGlobal = layer->toGlobal(point);
252 
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)++;
257  }
258 
259  ostr
260  << " digiWireGlobalPhi " << std::setw(10) << digiWireGlobal.phi() << " wire "
261  << wire
262  //<<" particleType: "<<cscDigiSimLink.getParticleType()
263  << " event: " << dtDigiSimLink->eventId().event() << " trackId "
264  << dtDigiSimLink->SimTrackId()
265  //<<" CFposition "<<cscDigiSimLink.CFposition() is 0
266  //the rest is not available in the StripDigiSimLink, maybe the SimHit must be found in the CrossingFrame vector(???) with CFposition()
267  //<<" processType "<<cscDigiSimLink.getProcessType()
268  //<<" detUnitId "<<cscDigiSimLink.getDetUnitId()<<" "<<rpcDetId
269  //<<" phiAtEntry "<<simHit.phiAtEntry()
270  //<<" thetaAtEntry "<<simHit.thetaAtEntry()
271  //<<" localPosition: phi "<<simHit.localPosition().phi()<<" eta "<<simHit.localPosition().eta()
272  //<<" entryPoint: x "<<std::setw(10)<<rpcDigiSimLink.getEntryPoint().x()<<" y "<<std::setw(10)<<rpcDigiSimLink.getEntryPoint().y()
273  //<<" timeOfFlight "<<rpcDigiSimLink.getTimeOfFlight()
274  << std::endl;
275  }
276  }
277  }
278 
279  break;
280  } //----------------------------------------------------------------------
281  case MuonSubdetId::CSC: {
282  //CSCDetId csc(stubDetId);
283  for (auto& simHit : *(cscSimHitsHandle.product())) {
284  const CSCLayer* layer = _geocsc->layer(CSCDetId(simHit.detUnitId()));
285  auto chamber = layer->chamber();
286  if (stubDetId.rawId() == chamber->id().rawId()) {
287  auto simHitStrip = layer->geometry()->strip(simHit.localPosition());
288  auto simHitGlobalPoint = layer->toGlobal(simHit.localPosition());
289  auto simHitStripGlobalPhi = layer->centerOfStrip(round(simHitStrip)).phi();
290 
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() << " "
296  << layer->id()
297  //<<" phiAtEntry "<<simHit.phiAtEntry()
298  //<<" thetaAtEntry "<<simHit.thetaAtEntry()
299  << " timeOfFlight "
300  << simHit.timeOfFlight()
301  //<<" localPosition: phi "<<simHit.localPosition().phi()<<" eta "<<simHit.localPosition().eta()
302  << " x " << simHit.localPosition().x() << " y " << simHit.localPosition().y()
303 
304  << std::endl;
305  }
306  }
307 
308  auto chamber = _geocsc->chamber(CSCDetId(stub->detId));
309  for (auto* layer : chamber->layers()) {
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) {
315  //const RPCRoll* roll = _georpc->roll(rpcDetId);
316  auto strip = cscDigiSimLink.channel();
317  auto digiStripGlobalPhi = layer->centerOfStrip(strip).phi();
318 
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)++;
323  }
324  ostr
325  << " digiStripGlobalPhi " << std::setw(10) << digiStripGlobalPhi << " strip "
326  << strip
327  //<<" particleType: "<<cscDigiSimLink.getParticleType()
328  << " event: " << cscDigiSimLink.eventId().event() << " trackId "
329  << cscDigiSimLink.SimTrackId()
330  //<<" CFposition "<<cscDigiSimLink.CFposition() is 0
331  //the rest is not available in the StripDigiSimLink, maybe the SimHit must be found in the CrossingFrame vector(???) with CFposition()
332  //<<" processType "<<cscDigiSimLink.getProcessType()
333  //<<" detUnitId "<<cscDigiSimLink.getDetUnitId()<<" "<<rpcDetId
334  //<<" phiAtEntry "<<simHit.phiAtEntry()
335  //<<" thetaAtEntry "<<simHit.thetaAtEntry()
336  //<<" localPosition: phi "<<simHit.localPosition().phi()<<" eta "<<simHit.localPosition().eta()
337  //<<" entryPoint: x "<<std::setw(10)<<rpcDigiSimLink.getEntryPoint().x()<<" y "<<std::setw(10)<<rpcDigiSimLink.getEntryPoint().y()
338  //<<" timeOfFlight "<<rpcDigiSimLink.getTimeOfFlight()
339  << std::endl;
340  }
341  } else {
342  ostr << "cscDigiSimLinkDetSet not found for detId " << layer->id();
343  }
344  }
345 
346  break;
347  } //end of CSC case
348  } //end of switch
349  ostr << "" << std::endl;
350  }
351  }
352 
353  ostr << board.name() << " " << *procMuon << std::endl;
354  ostr << procMuon->getGpResult() << std::endl << std::endl;
355 
356  int maxMatchedStubs = 0;
357  const TrackingParticle* bestMatchedPart = nullptr;
358  for (auto matchedTrackInfo : matchedTrackInfos) {
359  ostr << "matchedTrackInfo eventNum " << matchedTrackInfo.eventNum << " trackId " << matchedTrackInfo.trackId
360  << "\n";
361 
362  const TrackingParticle* matchedPart = nullptr;
363  for (auto& trackingParticle :
364  *trackingParticleHandle.product()) { //finding the trackingParticle corresponding to the matchedTrackInfo
365  if (trackingParticle.eventId().event() == matchedTrackInfo.eventNum &&
366  trackingParticle.g4Tracks().at(0).trackId() == matchedTrackInfo.trackId) {
367  allMatchedTracksPdgIds->Fill(to_string(trackingParticle.pdgId()).c_str(), 1);
368  matchedPart = &trackingParticle;
369 
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;
375 
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;
382 
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)
386  << parentTrack->g4Tracks().at(0).trackId() << " pt " << std::setw(9) << parentTrack->pt() << " eta "
387  << std::setw(9) << parentTrack->momentum().eta() << " phi " << std::setw(9)
388  << parentTrack->momentum().phi() << std::endl;
389  }
390  }
391 
392  break;
393  }
394  }
395 
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) {
400  matchedStubsCnt++;
401  if (matchedPart) {
402  string str = to_string(matchedPart->pdgId());
403  stubsInLayersCntByPdgId->Fill(str.c_str(), iLayer, 1);
404  }
405  }
406  }
407  ostr << std::endl;
408 
409  if (maxMatchedStubs < matchedStubsCnt) {
410  maxMatchedStubs = matchedStubsCnt;
411  bestMatchedPart = matchedPart;
412  }
413  }
414  if (bestMatchedPart) {
415  string str = to_string(bestMatchedPart->pdgId());
416 
417  bestMatchedTracksPdgIds->Fill(str.c_str(), 1);
418  firedLayersCntByPdgId->Fill(str.c_str(), gpResult.getFiredLayerCnt(), 1);
419  ptByPdgId->Fill(str.c_str(), bestMatchedPart->pt(), 1);
420 
421  if (bestMatchedPart->parentVertex().isNonnull()) {
422  rhoByPdgId->Fill(str.c_str(), bestMatchedPart->parentVertex()->position().Rho(), 1);
423  }
424 
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";
428  }
429  }
430 }
int pdgId() const
PDG ID.
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.
Definition: CSCGeometry.cc:100
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
Definition: Handle.h:70
edm::ESHandle< RPCGeometry > _georpc
double procHwPhiToGlobalPhi(int procHwPhi, int procHwPhi0) const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
Definition: RPCGeometry.cc:50
Log< level::Error, false > LogError
static std::string to_string(const XMLCh *ch)
const std::vector< SimTrack > & g4Tracks() const
edm::ESHandle< CSCGeometry > _geocsc
int iEvent
Definition: GenABIO.cc:224
const OMTFConfiguration * omtfConfig
static int getProcessorPhiZero(const OMTFConfiguration *config, unsigned int iProcessor)
const tftype trackFinderType() const
Get track-finder which found the muon (bmtf, emtf_pos/emtf_neg or omtf_pos/omtf_neg) ...
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::InputTag rpcDigiSimLinkInputTag
edm::InputTag cscStripDigiSimLinksInputTag
edm::InputTag rpcSimHitsInputTag
edm::InputTag dtDigiSimLinksInputTag
edm::ESHandle< DTGeometry > _geodt
Definition: DetId.h:17
const TrackingVertexRef & parentVertex() const
edm::InputTag cscSimHitsInputTag
edm::InputTag trackingParticleTag
static constexpr int RPC
Definition: MuonSubdetId.h:13
Monte Carlo truth information used for tracking validation.
double pt() const
Transverse momentum. Note this is taken from the first SimTrack only.
static constexpr int DT
Definition: MuonSubdetId.h:11
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
Definition: CSCGeometry.cc:105
#define str(s)
static constexpr int CSC
Definition: MuonSubdetId.h:12
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:90
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
Definition: invegas.h:5
bool isBendingLayer(unsigned int iLayer) const override
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:96

Member Data Documentation

◆ _geocsc

edm::ESHandle<CSCGeometry> StubsSimHitsMatcher::_geocsc
private

Definition at line 90 of file StubsSimHitsMatcher.h.

Referenced by beginRun(), and match().

◆ _geodt

edm::ESHandle<DTGeometry> StubsSimHitsMatcher::_geodt
private

Definition at line 91 of file StubsSimHitsMatcher.h.

Referenced by beginRun(), and match().

◆ _geom_cache_id

unsigned long long StubsSimHitsMatcher::_geom_cache_id = 0
private

Definition at line 88 of file StubsSimHitsMatcher.h.

◆ _georpc

edm::ESHandle<RPCGeometry> StubsSimHitsMatcher::_georpc
private

Definition at line 89 of file StubsSimHitsMatcher.h.

Referenced by beginRun(), and match().

◆ allMatchedTracksPdgIds

TH1I* StubsSimHitsMatcher::allMatchedTracksPdgIds = nullptr
private

Definition at line 93 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

◆ bestMatchedTracksPdgIds

TH1I* StubsSimHitsMatcher::bestMatchedTracksPdgIds = nullptr
private

Definition at line 94 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

◆ cscSimHitsInputTag

edm::InputTag StubsSimHitsMatcher::cscSimHitsInputTag
private

Definition at line 74 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

◆ cscStripDigiSimLinksInputTag

edm::InputTag StubsSimHitsMatcher::cscStripDigiSimLinksInputTag
private

Definition at line 78 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

◆ dtDigiSimLinksInputTag

edm::InputTag StubsSimHitsMatcher::dtDigiSimLinksInputTag
private

Definition at line 79 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

◆ dtSimHitsInputTag

edm::InputTag StubsSimHitsMatcher::dtSimHitsInputTag
private

Definition at line 75 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

◆ firedLayersCntByPdgId

TH2I* StubsSimHitsMatcher::firedLayersCntByPdgId = nullptr
private

Definition at line 97 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

◆ muonGeometryRecordWatcher

edm::ESWatcher<MuonGeometryRecord> StubsSimHitsMatcher::muonGeometryRecordWatcher
private

Definition at line 85 of file StubsSimHitsMatcher.h.

Referenced by beginRun().

◆ muonGeometryTokens

const MuonGeometryTokens& StubsSimHitsMatcher::muonGeometryTokens
private

Definition at line 83 of file StubsSimHitsMatcher.h.

Referenced by beginRun().

◆ omtfConfig

const OMTFConfiguration* StubsSimHitsMatcher::omtfConfig
private

Definition at line 71 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

◆ ptByPdgId

TH2I* StubsSimHitsMatcher::ptByPdgId = nullptr
private

Definition at line 98 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

◆ rhoByPdgId

TH2I* StubsSimHitsMatcher::rhoByPdgId = nullptr
private

Definition at line 100 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

◆ rpcDigiSimLinkInputTag

edm::InputTag StubsSimHitsMatcher::rpcDigiSimLinkInputTag
private

Definition at line 77 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

◆ rpcSimHitsInputTag

edm::InputTag StubsSimHitsMatcher::rpcSimHitsInputTag
private

Definition at line 73 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

◆ stubsInLayersCntByPdgId

TH2I* StubsSimHitsMatcher::stubsInLayersCntByPdgId = nullptr
private

Definition at line 96 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

◆ trackingParticleTag

edm::InputTag StubsSimHitsMatcher::trackingParticleTag
private

Definition at line 81 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().