CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
< MuonGeometryRecord
muonGeometryRecordWatcher
 
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 ( 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(), TFileDirectory::make(), TFileDirectory::mkdir(), OMTFConfiguration::nLayers(), ptByPdgId, rhoByPdgId, rpcDigiSimLinkInputTag, rpcSimHitsInputTag, stubsInLayersCntByPdgId, and trackingParticleTag.

38  : omtfConfig(omtfConfig), muonGeometryTokens(muonGeometryTokens) {
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,
62  omtfConfig->nLayers(),
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,
72  omtfConfig->nLayers(),
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 }
unsigned int nLayers() const
const OMTFConfiguration * omtfConfig
const MuonGeometryTokens & muonGeometryTokens
edm::InputTag rpcDigiSimLinkInputTag
T * make(const Args &...args) const
make new ROOT object
edm::InputTag cscStripDigiSimLinksInputTag
edm::InputTag rpcSimHitsInputTag
edm::InputTag dtDigiSimLinksInputTag
edm::InputTag cscSimHitsInputTag
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
edm::InputTag trackingParticleTag
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::InputTag dtSimHitsInputTag
StubsSimHitsMatcher::~StubsSimHitsMatcher ( )
virtual

Definition at line 84 of file StubsSimHitsMatching.cc.

84 {}

Member Function Documentation

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, edm::EventSetup::getHandle(), muonGeometryRecordWatcher, muonGeometryTokens, and MuonGeometryTokens::rpcGeometryEsToken.

86  {
87  if (muonGeometryRecordWatcher.check(eventSetup)) {
88  _georpc = eventSetup.getHandle(muonGeometryTokens.rpcGeometryEsToken);
89  _geocsc = eventSetup.getHandle(muonGeometryTokens.cscGeometryEsToken);
90  _geodt = eventSetup.getHandle(muonGeometryTokens.dtGeometryEsToken);
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
void StubsSimHitsMatcher::endJob ( void  )

Definition at line 441 of file StubsSimHitsMatching.cc.

441  {
442  /*edm::LogVerbatim("l1tOmtfEventPrint") <<"allMatchedTracksPdgIds "<<std::endl;
443  for(auto pdgId : allMatchedTracksPdgIds) {
444  edm::LogVerbatim("l1tOmtfEventPrint") <<"pdgId "<<std::setw(8)<<pdgId.first<<" muon candidates "<<pdgId.second<<std::endl;
445  }
446 
447  edm::LogVerbatim("l1tOmtfEventPrint") <<"bestMatchedTracksPdgIds "<<std::endl;
448  for(auto pdgId : bestMatchedTracksPdgIds) {
449  edm::LogVerbatim("l1tOmtfEventPrint") <<"pdgId "<<std::setw(8) <<pdgId.first<<" muon candidates "<<pdgId.second<<std::endl;
450  }*/
451 }
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, CSCLayer::centerOfStrip(), RPCRoll::centreOfStrip(), CSCLayer::chamber(), DTLayer::chamber(), MuonSubdetId::CSC, CSCDetId, cscSimHitsInputTag, cscStripDigiSimLinksInputTag, DetId::det(), MuonSubdetId::DT, dtDigiSimLinksInputTag, DTLayerId, dtSimHitsInputTag, EncodedEventId::event(), TrackingParticle::eventId(), firedLayersCntByPdgId, TrackingParticle::g4Tracks(), CSCLayer::geometry(), edm::Event::getByLabel(), OMTFinputMaker::getProcessorPhiZero(), DTChamber::id(), CSCLayer::id(), DTLayer::id(), OMTFConfiguration::isBendingLayer(), edm::Ref< C, T, F >::isNonnull(), phase1PixelTopology::layer, DetId::Muon, omtfConfig, TrackingParticle::parentVertex(), TrackingParticle::pdgId(), PV3DBase< T, PVType, FrameType >::phi(), Geom::Phi< T1, Range >::phi(), point, l1t::RegionalMuonCand::processor(), OMTFConfiguration::procHwPhiToGlobalPhi(), edm::Handle< T >::product(), TrackingParticle::pt(), ptByPdgId, DetId::rawId(), rhoByPdgId, MuonSubdetId::RPC, rpcDigiSimLinkInputTag, rpcSimHitsInputTag, str, RPCRoll::strip(), digitizers_cfi::strip, CSCLayerGeometry::strip(), stubsInLayersCntByPdgId, DetId::subdetId(), cond::impl::to_string(), GeomDet::toGlobal(), l1t::RegionalMuonCand::trackFinderType(), and trackingParticleTag.

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  int matchedMuonHits = 0;
152  int matchedNotMuonHits = 0;
153 
154  switch (stubDetId.subdetId()) {
155  case MuonSubdetId::RPC: {
156  RPCDetId rpcDetId(stubDetId);
157 
158  for (auto& simHit : *(rpcSimHitsHandle.product())) {
159  if (stubDetId.rawId() == simHit.detUnitId()) {
160  const RPCRoll* roll = _georpc->roll(rpcDetId);
161  auto strip = roll->strip(simHit.localPosition());
162  double simHitStripGlobalPhi = (roll->toGlobal(roll->centreOfStrip((int)strip))).phi();
163 
164  if (abs(stubGlobalPhi - simHitStripGlobalPhi) < 0.02) {
165  if (abs(simHit.particleType()) == 13)
166  matchedMuonHits++;
167  else {
168  matchedNotMuonHits++;
169  }
170 
171  matchedTrackInfos.insert(MatchedTrackInfo(simHit.eventId().event(), simHit.trackId()));
172  }
173 
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() << " "
178  << rpcDetId
179  //<<" phiAtEntry "<<simHit.phiAtEntry()
180  //<<" thetaAtEntry "<<simHit.thetaAtEntry()
181  //<<" localPosition: phi "<<simHit.localPosition().phi()<<" eta "<<simHit.localPosition().eta()
182  << " entryPoint: x " << std::setw(10) << simHit.entryPoint().x() << " y " << std::setw(10)
183  << simHit.entryPoint().y() << " timeOfFlight " << simHit.timeOfFlight() << std::endl;
184  }
185  }
186 
187  auto rpcDigiSimLinkDetSet = rpcDigiSimLinkHandle.product()->find(stub->detId);
188 
189  if (rpcDigiSimLinkDetSet != rpcDigiSimLinkHandle.product()->end()) {
190  ostr << "rpcDigiSimLinkDetSet: detId " << rpcDigiSimLinkDetSet->detId() << " size "
191  << rpcDigiSimLinkDetSet->size() << "\n";
192  for (auto& rpcDigiSimLink : *rpcDigiSimLinkDetSet) {
193  const RPCRoll* roll = _georpc->roll(rpcDetId);
194  auto strip = rpcDigiSimLink.getStrip();
195  double simHitStripGlobalPhi = (roll->toGlobal(roll->centreOfStrip((int)strip))).phi();
196 
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)++;
201  }
202 
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() << " "
208  << rpcDetId
209  //<<" phiAtEntry "<<simHit.phiAtEntry()
210  //<<" thetaAtEntry "<<simHit.thetaAtEntry()
211  //<<" localPosition: phi "<<simHit.localPosition().phi()<<" eta "<<simHit.localPosition().eta()
212  << " entryPoint: x " << std::setw(10) << rpcDigiSimLink.getEntryPoint().x() << " y "
213  << std::setw(10) << rpcDigiSimLink.getEntryPoint().y() << " timeOfFlight "
214  << rpcDigiSimLink.getTimeOfFlight() << std::endl;
215  }
216  }
217 
218  break;
219  } //----------------------------------------------------------------------
220  case MuonSubdetId::DT: {
221  //DTChamberId dt(stubDetId);
222  for (auto& simHit : *(dtSimHitsHandle.product())) {
223  const DTLayer* layer = _geodt->layer(DTLayerId(simHit.detUnitId()));
224  const DTChamber* chamber = layer->chamber();
225  if (stubDetId.rawId() == chamber->id().rawId()) {
226  //auto strip = layer->geometry()->strip(simHit.localPosition());
227  auto simHitGlobalPoint = layer->toGlobal(simHit.localPosition());
228 
229  ostr << " simHitGlobalPoint.phi " << std::setw(10)
230  << simHitGlobalPoint.phi()
231  //<<" strip "<<strip
232  << " particleType: " << simHit.particleType() << " event: " << simHit.eventId().event()
233  << " trackId " << simHit.trackId() << " processType " << simHit.processType() << " detUnitId "
234  << simHit.detUnitId() << " "
235  << layer->id()
236  //<<" phiAtEntry "<<simHit.phiAtEntry()
237  //<<" thetaAtEntry "<<simHit.thetaAtEntry()
238  //<<" localPosition: phi "<<simHit.localPosition().phi()<<" eta "<<simHit.localPosition().eta()
239  << " localPosition: x " << std::setw(10) << simHit.localPosition().x() << " y " << std::setw(10)
240  << simHit.localPosition().y() << " timeOfFlight " << simHit.timeOfFlight() << std::endl;
241  }
242  }
243 
244  auto chamber = _geodt->chamber(DTLayerId(stub->detId));
245  for (auto superlayer : chamber->superLayers()) {
246  if (superlayer->id().superLayer() == 2) //we skip the theta layer
247  continue;
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;
252 
253  for (; dtDigiSimLink != dtDigiSimLinks.second; dtDigiSimLink++) {
254  //const RPCRoll* roll = _georpc->roll(rpcDetId);
255  auto wire = dtDigiSimLink->wire();
256 
257  auto wireX = layer->specificTopology().wirePosition(wire);
258 
259  LocalPoint point(wireX, 0, 0);
260  auto digiWireGlobal = layer->toGlobal(point);
261 
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)++;
266  }
267 
268  ostr
269  << " digiWireGlobalPhi " << std::setw(10) << digiWireGlobal.phi() << " wire "
270  << wire
271  //<<" particleType: "<<cscDigiSimLink.getParticleType()
272  << " event: " << dtDigiSimLink->eventId().event() << " trackId "
273  << dtDigiSimLink->SimTrackId()
274  //<<" CFposition "<<cscDigiSimLink.CFposition() is 0
275  //the rest is not available in the StripDigiSimLink, maybe the SimHit must be found in the CrossingFrame vector(???) with CFposition()
276  //<<" processType "<<cscDigiSimLink.getProcessType()
277  //<<" detUnitId "<<cscDigiSimLink.getDetUnitId()<<" "<<rpcDetId
278  //<<" phiAtEntry "<<simHit.phiAtEntry()
279  //<<" thetaAtEntry "<<simHit.thetaAtEntry()
280  //<<" localPosition: phi "<<simHit.localPosition().phi()<<" eta "<<simHit.localPosition().eta()
281  //<<" entryPoint: x "<<std::setw(10)<<rpcDigiSimLink.getEntryPoint().x()<<" y "<<std::setw(10)<<rpcDigiSimLink.getEntryPoint().y()
282  //<<" timeOfFlight "<<rpcDigiSimLink.getTimeOfFlight()
283  << std::endl;
284  }
285  }
286  }
287 
288  break;
289  } //----------------------------------------------------------------------
290  case MuonSubdetId::CSC: {
291  //CSCDetId csc(stubDetId);
292  for (auto& simHit : *(cscSimHitsHandle.product())) {
293  const CSCLayer* layer = _geocsc->layer(CSCDetId(simHit.detUnitId()));
294  auto chamber = layer->chamber();
295  if (stubDetId.rawId() == chamber->id().rawId()) {
296  auto simHitStrip = layer->geometry()->strip(simHit.localPosition());
297  auto simHitGlobalPoint = layer->toGlobal(simHit.localPosition());
298  auto simHitStripGlobalPhi = layer->centerOfStrip(round(simHitStrip)).phi();
299 
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() << " "
305  << layer->id()
306  //<<" phiAtEntry "<<simHit.phiAtEntry()
307  //<<" thetaAtEntry "<<simHit.thetaAtEntry()
308  << " timeOfFlight "
309  << simHit.timeOfFlight()
310  //<<" localPosition: phi "<<simHit.localPosition().phi()<<" eta "<<simHit.localPosition().eta()
311  << " x " << simHit.localPosition().x() << " y " << simHit.localPosition().y()
312 
313  << std::endl;
314  }
315  }
316 
317  auto chamber = _geocsc->chamber(CSCDetId(stub->detId));
318  for (auto* layer : chamber->layers()) {
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) {
324  //const RPCRoll* roll = _georpc->roll(rpcDetId);
325  auto strip = cscDigiSimLink.channel();
326  auto digiStripGlobalPhi = layer->centerOfStrip(strip).phi();
327 
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)++;
332  }
333  ostr
334  << " digiStripGlobalPhi " << std::setw(10) << digiStripGlobalPhi << " strip "
335  << strip
336  //<<" particleType: "<<cscDigiSimLink.getParticleType()
337  << " event: " << cscDigiSimLink.eventId().event() << " trackId "
338  << cscDigiSimLink.SimTrackId()
339  //<<" CFposition "<<cscDigiSimLink.CFposition() is 0
340  //the rest is not available in the StripDigiSimLink, maybe the SimHit must be found in the CrossingFrame vector(???) with CFposition()
341  //<<" processType "<<cscDigiSimLink.getProcessType()
342  //<<" detUnitId "<<cscDigiSimLink.getDetUnitId()<<" "<<rpcDetId
343  //<<" phiAtEntry "<<simHit.phiAtEntry()
344  //<<" thetaAtEntry "<<simHit.thetaAtEntry()
345  //<<" localPosition: phi "<<simHit.localPosition().phi()<<" eta "<<simHit.localPosition().eta()
346  //<<" entryPoint: x "<<std::setw(10)<<rpcDigiSimLink.getEntryPoint().x()<<" y "<<std::setw(10)<<rpcDigiSimLink.getEntryPoint().y()
347  //<<" timeOfFlight "<<rpcDigiSimLink.getTimeOfFlight()
348  << std::endl;
349  }
350  } else {
351  ostr << "cscDigiSimLinkDetSet not found for detId " << layer->id();
352  }
353  }
354 
355  break;
356  } //end of CSC case
357  } //end of switch
358  ostr << "" << std::endl;
359  }
360  }
361 
362  ostr << board.name() << " " << *procMuon << std::endl;
363  ostr << procMuon->getGpResult() << std::endl << std::endl;
364 
365  int maxMatchedStubs = 0;
366  const TrackingParticle* bestMatchedPart = nullptr;
367  for (auto matchedTrackInfo : matchedTrackInfos) {
368  ostr << "matchedTrackInfo eventNum " << matchedTrackInfo.eventNum << " trackId " << matchedTrackInfo.trackId
369  << "\n";
370 
371  const TrackingParticle* matchedPart = nullptr;
372  for (auto& trackingParticle :
373  *trackingParticleHandle.product()) { //finding the trackingParticle corresponding to the matchedTrackInfo
374  if (trackingParticle.eventId().event() == matchedTrackInfo.eventNum &&
375  trackingParticle.g4Tracks().at(0).trackId() == matchedTrackInfo.trackId) {
376  allMatchedTracksPdgIds->Fill(to_string(trackingParticle.pdgId()).c_str(), 1);
377  matchedPart = &trackingParticle;
378 
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;
384 
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;
391 
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)
395  << parentTrack->g4Tracks().at(0).trackId() << " pt " << std::setw(9) << parentTrack->pt() << " eta "
396  << std::setw(9) << parentTrack->momentum().eta() << " phi " << std::setw(9)
397  << parentTrack->momentum().phi() << std::endl;
398  }
399  }
400 
401  break;
402  }
403  }
404 
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) {
409  matchedStubsCnt++;
410  if (matchedPart) {
411  string str = to_string(matchedPart->pdgId());
412  stubsInLayersCntByPdgId->Fill(str.c_str(), iLayer, 1);
413  }
414  }
415  }
416  ostr << std::endl;
417 
418  if (maxMatchedStubs < matchedStubsCnt) {
419  maxMatchedStubs = matchedStubsCnt;
420  bestMatchedPart = matchedPart;
421  }
422  }
423  if (bestMatchedPart) {
424  string str = to_string(bestMatchedPart->pdgId());
425 
426  bestMatchedTracksPdgIds->Fill(str.c_str(), 1);
427  firedLayersCntByPdgId->Fill(str.c_str(), gpResult.getFiredLayerCnt(), 1);
428  ptByPdgId->Fill(str.c_str(), bestMatchedPart->pt(), 1);
429 
430  if (bestMatchedPart->parentVertex().isNonnull()) {
431  rhoByPdgId->Fill(str.c_str(), bestMatchedPart->parentVertex()->position().Rho(), 1);
432  }
433 
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";
437  }
438  }
439 }
float strip(const LocalPoint &lp) const
Definition: RPCRoll.cc:35
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:59
LocalPoint centreOfStrip(int strip) const
Definition: RPCRoll.cc:26
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
int event() const
get the contents of the subdetector field (should be protected?)
const std::vector< SimTrack > & g4Tracks() const
DTLayerId id() const
Return the DetId of this SL.
Definition: DTLayer.cc:39
int pdgId() const
PDG ID.
CSCDetId id() const
Definition: CSCLayer.h:39
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
edm::ESHandle< RPCGeometry > _georpc
double pt() const
Transverse momentum. Note this is taken from the first SimTrack only.
std::string to_string(const V &value)
Definition: OMSAccess.h:71
T1 phi() const
Definition: Phi.h:78
Log< level::Error, false > LogError
constexpr std::array< uint8_t, layerIndexSize > layer
double procHwPhiToGlobalPhi(int procHwPhi, int procHwPhi0) const
edm::ESHandle< CSCGeometry > _geocsc
const DTTopology & specificTopology() const
Definition: DTLayer.cc:37
int channel(int istrip)
Definition: CSCDetId.h:105
const OMTFConfiguration * omtfConfig
const std::vector< const DTSuperLayer * > & superLayers() const
Return the superlayers in the chamber.
Definition: DTChamber.cc:51
static int getProcessorPhiZero(const OMTFConfiguration *config, unsigned int iProcessor)
DTChamberId id() const
Return the DTChamberId of this chamber.
Definition: DTChamber.cc:32
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::InputTag rpcDigiSimLinkInputTag
float strip(const LocalPoint &lp) const
const TrackingVertexRef & parentVertex() const
edm::InputTag cscStripDigiSimLinksInputTag
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:500
edm::InputTag rpcSimHitsInputTag
edm::InputTag dtDigiSimLinksInputTag
const tftype trackFinderType() const
Get track-finder which found the muon (bmtf, emtf_pos/emtf_neg or omtf_pos/omtf_neg) ...
edm::ESHandle< DTGeometry > _geodt
Definition: DetId.h:17
GlobalPoint centerOfStrip(int strip) const
Definition: CSCLayer.cc:4
const int processor() const
Get processor ID on which the candidate was found (0..5 for OMTF/EMTF; 0..11 for BMTF) ...
edm::InputTag cscSimHitsInputTag
T const * product() const
Definition: Handle.h:70
edm::InputTag trackingParticleTag
static constexpr int RPC
Definition: MuonSubdetId.h:13
const DTChamber * chamber() const
Definition: DTLayer.cc:45
EncodedEventId eventId() const
Signal source, crossing number.
Monte Carlo truth information used for tracking validation.
static constexpr int DT
Definition: MuonSubdetId.h:11
#define str(s)
static constexpr int CSC
Definition: MuonSubdetId.h:12
const CSCChamber * chamber() const
Definition: CSCLayer.h:49
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:44
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

Member Data Documentation

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

Definition at line 90 of file StubsSimHitsMatcher.h.

Referenced by beginRun(), and match().

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

Definition at line 91 of file StubsSimHitsMatcher.h.

Referenced by beginRun(), and match().

unsigned long long StubsSimHitsMatcher::_geom_cache_id = 0
private

Definition at line 88 of file StubsSimHitsMatcher.h.

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

Definition at line 89 of file StubsSimHitsMatcher.h.

Referenced by beginRun(), and match().

TH1I* StubsSimHitsMatcher::allMatchedTracksPdgIds = nullptr
private

Definition at line 93 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

TH1I* StubsSimHitsMatcher::bestMatchedTracksPdgIds = nullptr
private

Definition at line 94 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

edm::InputTag StubsSimHitsMatcher::cscSimHitsInputTag
private

Definition at line 74 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

edm::InputTag StubsSimHitsMatcher::cscStripDigiSimLinksInputTag
private

Definition at line 78 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

edm::InputTag StubsSimHitsMatcher::dtDigiSimLinksInputTag
private

Definition at line 79 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

edm::InputTag StubsSimHitsMatcher::dtSimHitsInputTag
private

Definition at line 75 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

TH2I* StubsSimHitsMatcher::firedLayersCntByPdgId = nullptr
private

Definition at line 97 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

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

Definition at line 85 of file StubsSimHitsMatcher.h.

Referenced by beginRun().

const MuonGeometryTokens& StubsSimHitsMatcher::muonGeometryTokens
private

Definition at line 83 of file StubsSimHitsMatcher.h.

Referenced by beginRun().

const OMTFConfiguration* StubsSimHitsMatcher::omtfConfig
private

Definition at line 71 of file StubsSimHitsMatcher.h.

Referenced by match().

TH2I* StubsSimHitsMatcher::ptByPdgId = nullptr
private

Definition at line 98 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

TH2I* StubsSimHitsMatcher::rhoByPdgId = nullptr
private

Definition at line 100 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

edm::InputTag StubsSimHitsMatcher::rpcDigiSimLinkInputTag
private

Definition at line 77 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

edm::InputTag StubsSimHitsMatcher::rpcSimHitsInputTag
private

Definition at line 73 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

TH2I* StubsSimHitsMatcher::stubsInLayersCntByPdgId = nullptr
private

Definition at line 96 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().

edm::InputTag StubsSimHitsMatcher::trackingParticleTag
private

Definition at line 81 of file StubsSimHitsMatcher.h.

Referenced by match(), and StubsSimHitsMatcher().