CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuonTrackProducer Class Reference
Inheritance diagram for MuonTrackProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 MuonTrackProducer (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

bool ignoreMissingMuonCollection
 
edm::EDGetTokenT< CSCSegmentCollectioninputCSCSegmentToken_
 
edm::EDGetTokenT< DTRecSegment4DCollectioninputDTRecSegment4DToken_
 
edm::EDGetTokenT< reco::MuonCollectionmuonsToken
 
std::vector< std::string > selectionTags
 
std::string trackType
 
edm::ESGetToken< TrackerTopology, TrackerTopologyRcdttopoToken_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 27 of file MuonTrackProducer.cc.

Constructor & Destructor Documentation

◆ MuonTrackProducer()

MuonTrackProducer::MuonTrackProducer ( const edm::ParameterSet parset)
explicit

Definition at line 44 of file MuonTrackProducer.cc.

45  : muonsToken(consumes<reco::MuonCollection>(parset.getParameter<edm::InputTag>("muonsTag"))),
47  consumes<DTRecSegment4DCollection>(parset.getParameter<edm::InputTag>("inputDTRecSegment4DCollection"))),
49  consumes<CSCSegmentCollection>(parset.getParameter<edm::InputTag>("inputCSCSegmentCollection"))),
50  ttopoToken_(esConsumes<TrackerTopology, TrackerTopologyRcd>()),
51  selectionTags(parset.getParameter<std::vector<std::string>>("selectionTags")),
52  trackType(parset.getParameter<std::string>("trackType")),
53  ignoreMissingMuonCollection(parset.getUntrackedParameter<bool>("ignoreMissingMuonCollection", false)) {
54  edm::LogVerbatim("MuonTrackProducer") << "constructing MuonTrackProducer" << parset.dump();
55  produces<reco::TrackCollection>();
56  produces<reco::TrackExtraCollection>();
57  produces<TrackingRecHitCollection>();
58 }

References edm::ParameterSet::dump().

Member Function Documentation

◆ produce()

void MuonTrackProducer::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 60 of file MuonTrackProducer.cc.

60  {
61  edm::Handle<reco::MuonCollection> muonCollectionH = iEvent.getHandle(muonsToken);
62  if (ignoreMissingMuonCollection && !muonCollectionH.isValid())
63  edm::LogVerbatim("MuonTrackProducer") << "\n ignoring missing muon collection.";
64 
65  else {
66  const DTRecSegment4DCollection &dtSegmentCollection = iEvent.get(inputDTRecSegment4DToken_);
67  const CSCSegmentCollection &cscSegmentCollection = iEvent.get(inputCSCSegmentToken_);
68 
69  const TrackerTopology &ttopo = iSetup.getData(ttopoToken_);
70 
71  std::unique_ptr<reco::TrackCollection> selectedTracks(new reco::TrackCollection);
72  std::unique_ptr<reco::TrackExtraCollection> selectedTrackExtras(new reco::TrackExtraCollection());
73  std::unique_ptr<TrackingRecHitCollection> selectedTrackHits(new TrackingRecHitCollection());
74 
75  reco::TrackRefProd rTracks = iEvent.getRefBeforePut<reco::TrackCollection>();
76  reco::TrackExtraRefProd rTrackExtras = iEvent.getRefBeforePut<reco::TrackExtraCollection>();
77  TrackingRecHitRefProd rHits = iEvent.getRefBeforePut<TrackingRecHitCollection>();
78 
81 
82  edm::LogVerbatim("MuonTrackProducer") << "\nThere are " << dtSegmentCollection.size() << " DT segments.";
83  unsigned int index_dt_segment = 0;
84  for (DTRecSegment4DCollection::const_iterator segment = dtSegmentCollection.begin();
85  segment != dtSegmentCollection.end();
86  ++segment, index_dt_segment++) {
87  LocalPoint segmentLocalPosition = segment->localPosition();
88  LocalVector segmentLocalDirection = segment->localDirection();
89  LocalError segmentLocalPositionError = segment->localPositionError();
90  LocalError segmentLocalDirectionError = segment->localDirectionError();
91  DetId geoid = segment->geographicalId();
92  DTChamberId dtdetid = DTChamberId(geoid);
93  int wheel = dtdetid.wheel();
94  int station = dtdetid.station();
95  int sector = dtdetid.sector();
96 
97  float segmentX = segmentLocalPosition.x();
98  float segmentY = segmentLocalPosition.y();
99  float segmentdXdZ = segmentLocalDirection.x() / segmentLocalDirection.z();
100  float segmentdYdZ = segmentLocalDirection.y() / segmentLocalDirection.z();
101  float segmentXerr = sqrt(segmentLocalPositionError.xx());
102  float segmentYerr = sqrt(segmentLocalPositionError.yy());
103  float segmentdXdZerr = sqrt(segmentLocalDirectionError.xx());
104  float segmentdYdZerr = sqrt(segmentLocalDirectionError.yy());
105 
106  edm::LogVerbatim("MuonTrackProducer")
107  << "\nDT segment index :" << index_dt_segment << "\nchamber Wh:" << wheel << ",St:" << station
108  << ",Se:" << sector << "\nLocal Position (X,Y)=(" << segmentX << "," << segmentY << ") +/- (" << segmentXerr
109  << "," << segmentYerr << "), "
110  << "Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ << "," << segmentdYdZ << ") +/- (" << segmentdXdZerr << ","
111  << segmentdYdZerr << ")";
112  }
113 
114  edm::LogVerbatim("MuonTrackProducer") << "\nThere are " << cscSegmentCollection.size() << " CSC segments.";
115  unsigned int index_csc_segment = 0;
116  for (CSCSegmentCollection::const_iterator segment = cscSegmentCollection.begin();
117  segment != cscSegmentCollection.end();
118  ++segment, index_csc_segment++) {
119  LocalPoint segmentLocalPosition = segment->localPosition();
120  LocalVector segmentLocalDirection = segment->localDirection();
121  LocalError segmentLocalPositionError = segment->localPositionError();
122  LocalError segmentLocalDirectionError = segment->localDirectionError();
123 
124  DetId geoid = segment->geographicalId();
125  CSCDetId cscdetid = CSCDetId(geoid);
126  int endcap = cscdetid.endcap();
127  int station = cscdetid.station();
128  int ring = cscdetid.ring();
129  int chamber = cscdetid.chamber();
130 
131  float segmentX = segmentLocalPosition.x();
132  float segmentY = segmentLocalPosition.y();
133  float segmentdXdZ = segmentLocalDirection.x() / segmentLocalDirection.z();
134  float segmentdYdZ = segmentLocalDirection.y() / segmentLocalDirection.z();
135  float segmentXerr = sqrt(segmentLocalPositionError.xx());
136  float segmentYerr = sqrt(segmentLocalPositionError.yy());
137  float segmentdXdZerr = sqrt(segmentLocalDirectionError.xx());
138  float segmentdYdZerr = sqrt(segmentLocalDirectionError.yy());
139 
140  edm::LogVerbatim("MuonTrackProducer")
141  << "\nCSC segment index :" << index_csc_segment << "\nchamber Endcap:" << endcap << ",St:" << station
142  << ",Ri:" << ring << ",Ch:" << chamber << "\nLocal Position (X,Y)=(" << segmentX << "," << segmentY
143  << ") +/- (" << segmentXerr << "," << segmentYerr << "), "
144  << "Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ << "," << segmentdYdZ << ") +/- (" << segmentdXdZerr << ","
145  << segmentdYdZerr << ")";
146  }
147 
148  edm::LogVerbatim("MuonTrackProducer") << "\nThere are " << muonCollectionH->size() << " reco::Muons.";
149  unsigned int muon_index = 0;
150  for (reco::MuonCollection::const_iterator muon = muonCollectionH->begin(); muon != muonCollectionH->end();
151  ++muon, muon_index++) {
152  edm::LogVerbatim("MuonTrackProducer") << "\n******* muon index : " << muon_index;
153 
154  const bool isGoodResult =
155  std::all_of(selectionTags.begin(), selectionTags.end(), [&muon](const std::string &name) {
157  return muon::isGoodMuon(*muon, muonType);
158  });
159 
160  if (isGoodResult) {
161  // new copy of Track
162  reco::TrackRef trackref;
163  bool addMatchedMuonSegments = false;
164 
165  if (trackType == "innerTrack") {
166  if (muon->innerTrack().isNonnull())
167  trackref = muon->innerTrack();
168  else
169  continue;
170  } else if (trackType == "outerTrack") {
171  if (muon->outerTrack().isNonnull())
172  trackref = muon->outerTrack();
173  else
174  continue;
175  } else if (trackType == "globalTrack") {
176  if (muon->globalTrack().isNonnull())
177  trackref = muon->globalTrack();
178  else
179  continue;
180  } else if (trackType == "innerTrackPlusSegments") {
181  if (muon->innerTrack().isNonnull()) {
182  trackref = muon->innerTrack();
183  addMatchedMuonSegments = true;
184  } else
185  continue;
186  } else if (trackType == "rpcMuonTrack") {
187  if (muon->innerTrack().isNonnull() && muon->isRPCMuon()) {
188  trackref = muon->innerTrack();
189  } else
190  continue;
191  } else if (trackType == "gemMuonTrack") {
192  if (muon->innerTrack().isNonnull() && muon->isGEMMuon()) {
193  trackref = muon->innerTrack();
194  } else
195  continue;
196  } else if (trackType == "me0MuonTrack") {
197  if (muon->innerTrack().isNonnull() && muon->isME0Muon()) {
198  trackref = muon->innerTrack();
199  } else
200  continue;
201  } else if (trackType == "tunepTrack") {
202  if (muon->isGlobalMuon() && muon->tunePMuonBestTrack().isNonnull())
203  trackref = muon->tunePMuonBestTrack();
204  else
205  continue;
206  } else if (trackType == "pfTrack") {
207  if (muon->isPFMuon() && muon->muonBestTrack().isNonnull())
208  trackref = muon->muonBestTrack();
209  else
210  continue;
211  } else if (trackType == "recomuonTrack") {
212  if (muon->isGlobalMuon())
213  trackref = muon->globalTrack();
214  else if (muon->isTrackerMuon()) {
215  trackref = muon->innerTrack();
216  addMatchedMuonSegments = true;
217  } else if (muon->isStandAloneMuon())
218  trackref = muon->outerTrack();
219  else if (muon->isRPCMuon())
220  trackref = muon->innerTrack();
221  else if (muon->isGEMMuon())
222  trackref = muon->innerTrack();
223  else if (muon->isME0Muon())
224  trackref = muon->innerTrack();
225  else
226  trackref = muon->muonBestTrack();
227 
228  if (muon->muonBestTrackType() != muon->tunePMuonBestTrackType())
229  edm::LogVerbatim("MuonTrackProducer") << "\n *** PF != TuneP *** \n" << std::endl;
230 
231  edm::LogVerbatim("MuonTrackProducer") << "isGlobal ? " << muon->isGlobalMuon() << std::endl;
232  edm::LogVerbatim("MuonTrackProducer")
233  << "isTracker ? " << muon->isTrackerMuon() << ", isRPC ? " << muon->isRPCMuon() << ", isGEM ? "
234  << muon->isGEMMuon() << ", isME0 ? " << muon->isME0Muon() << std::endl;
235  edm::LogVerbatim("MuonTrackProducer") << "isStandAlone ? " << muon->isStandAloneMuon() << std::endl;
236  edm::LogVerbatim("MuonTrackProducer") << "isCalo ? " << muon->isCaloMuon() << std::endl;
237  edm::LogVerbatim("MuonTrackProducer") << "isPF ? " << muon->isPFMuon() << std::endl << std::endl;
238 
239  edm::LogVerbatim("MuonTrackProducer")
240  << " enum MuonTrackType {None, InnerTrack, OuterTrack, CombinedTrack, TPFMS, Picky, DYT }" << std::endl;
241 
242  edm::LogVerbatim("MuonTrackProducer")
243  << "(muon) pt = " << muon->pt() << ", eta = " << muon->eta() << ", phi = " << muon->phi() << std::endl;
244 
245  if (muon->muonBestTrack().isNonnull())
246  edm::LogVerbatim("MuonTrackProducer")
247  << "(best) pt = " << muon->muonBestTrack()->pt() << ", eta = " << muon->muonBestTrack()->eta()
248  << ", phi = " << muon->muonBestTrack()->phi()
249  << ", N mu hits = " << muon->muonBestTrack()->hitPattern().numberOfValidMuonHits()
250  << ", N trk hits = " << muon->muonBestTrack()->hitPattern().numberOfValidTrackerHits()
251  << ", MuonTrackType = " << muon->muonBestTrackType() << std::endl;
252  if (muon->tunePMuonBestTrack().isNonnull())
253  edm::LogVerbatim("MuonTrackProducer")
254  << "(tuneP) pt = " << muon->tunePMuonBestTrack()->pt()
255  << ", eta = " << muon->tunePMuonBestTrack()->eta() << ", phi = " << muon->tunePMuonBestTrack()->phi()
256  << ", N mu hits = " << muon->tunePMuonBestTrack()->hitPattern().numberOfValidMuonHits()
257  << ", N trk hits = " << muon->tunePMuonBestTrack()->hitPattern().numberOfValidTrackerHits()
258  << ", MuonTrackType = " << muon->tunePMuonBestTrackType() << std::endl;
259  if (muon->innerTrack().isNonnull())
260  edm::LogVerbatim("MuonTrackProducer")
261  << "(inner) pt = " << muon->innerTrack()->pt() << ", eta = " << muon->innerTrack()->eta()
262  << ", phi = " << muon->innerTrack()->phi()
263  << ", N trk hits = " << muon->innerTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
264  if (muon->globalTrack().isNonnull())
265  edm::LogVerbatim("MuonTrackProducer")
266  << "(global) pt = " << muon->globalTrack()->pt() << ", eta = " << muon->globalTrack()->eta()
267  << ", phi = " << muon->globalTrack()->phi()
268  << ", N mu hits = " << muon->globalTrack()->hitPattern().numberOfValidMuonHits()
269  << ", N trk hits = " << muon->globalTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
270  if (muon->outerTrack().isNonnull())
271  edm::LogVerbatim("MuonTrackProducer")
272  << "(outer) pt = " << muon->outerTrack()->pt() << ", eta = " << muon->outerTrack()->eta()
273  << ", phi = " << muon->outerTrack()->phi()
274  << ", N mu hits = " << muon->outerTrack()->hitPattern().numberOfValidMuonHits() << std::endl;
275  if (muon->tpfmsTrack().isNonnull())
276  edm::LogVerbatim("MuonTrackProducer")
277  << "(tpfms) pt = " << muon->tpfmsTrack()->pt() << ", eta = " << muon->tpfmsTrack()->eta()
278  << ", phi = " << muon->tpfmsTrack()->phi()
279  << ", N mu hits = " << muon->tpfmsTrack()->hitPattern().numberOfValidMuonHits()
280  << ", N trk hits = " << muon->tpfmsTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
281  if (muon->pickyTrack().isNonnull())
282  edm::LogVerbatim("MuonTrackProducer")
283  << "(picky) pt = " << muon->pickyTrack()->pt() << ", eta = " << muon->pickyTrack()->eta()
284  << ", phi = " << muon->pickyTrack()->phi()
285  << ", N mu hits = " << muon->pickyTrack()->hitPattern().numberOfValidMuonHits()
286  << ", N trk hits = " << muon->pickyTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
287  if (muon->dytTrack().isNonnull())
288  edm::LogVerbatim("MuonTrackProducer")
289  << "(dyt) pt = " << muon->dytTrack()->pt() << ", eta = " << muon->dytTrack()->eta()
290  << ", phi = " << muon->dytTrack()->phi()
291  << ", N mu hits = " << muon->dytTrack()->hitPattern().numberOfValidMuonHits()
292  << ", N trk hits = " << muon->dytTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
293  }
294 
295  edm::LogVerbatim("MuonTrackProducer") << "\t *** Selected *** ";
296  const reco::Track *trk = &(*trackref);
297  // pointer to old track:
298  std::unique_ptr<reco::Track> newTrk(new reco::Track(*trk));
299 
300  newTrk->setExtra(reco::TrackExtraRef(rTrackExtras, idx++));
301  PropagationDirection seedDir = trk->seedDirection();
302  // new copy of track Extras
303  std::unique_ptr<reco::TrackExtra> newExtra(new reco::TrackExtra(trk->outerPosition(),
304  trk->outerMomentum(),
305  trk->outerOk(),
306  trk->innerPosition(),
307  trk->innerMomentum(),
308  trk->innerOk(),
309  trk->outerStateCovariance(),
310  trk->outerDetId(),
311  trk->innerStateCovariance(),
312  trk->innerDetId(),
313  seedDir));
314 
315  // new copy of the silicon hits; add hit refs to Extra and hits to hit
316  // collection
317 
318  // edm::LogVerbatim("MuonTrackProducer")<<"\n printing initial
319  // hit_pattern"; trk->hitPattern().print();
320  unsigned int nHitsToAdd = 0;
321  for (trackingRecHit_iterator iHit = trk->recHitsBegin(); iHit != trk->recHitsEnd(); iHit++) {
322  TrackingRecHit *hit = (*iHit)->clone();
323  selectedTrackHits->push_back(hit);
324  ++nHitsToAdd;
325  }
326 
327  if (addMatchedMuonSegments) {
328  int wheel, station, sector;
329  int endcap, /*station, */ ring, chamber;
330 
331  edm::LogVerbatim("MuonTrackProducer")
332  << "Number of chambers: " << muon->matches().size()
333  << ", arbitrated: " << muon->numberOfMatches(reco::Muon::SegmentAndTrackArbitration);
334  unsigned int index_chamber = 0;
335 
336  for (std::vector<reco::MuonChamberMatch>::const_iterator chamberMatch = muon->matches().begin();
337  chamberMatch != muon->matches().end();
338  ++chamberMatch, index_chamber++) {
339  std::stringstream chamberStr;
340  chamberStr << "\nchamber index: " << index_chamber;
341 
342  int subdet = chamberMatch->detector();
343  DetId did = chamberMatch->id;
344 
345  if (subdet == MuonSubdetId::DT) {
346  DTChamberId dtdetid = DTChamberId(did);
347  wheel = dtdetid.wheel();
348  station = dtdetid.station();
349  sector = dtdetid.sector();
350  chamberStr << ", DT chamber Wh:" << wheel << ",St:" << station << ",Se:" << sector;
351  } else if (subdet == MuonSubdetId::CSC) {
352  CSCDetId cscdetid = CSCDetId(did);
353  endcap = cscdetid.endcap();
354  station = cscdetid.station();
355  ring = cscdetid.ring();
356  chamber = cscdetid.chamber();
357  chamberStr << ", CSC chamber End:" << endcap << ",St:" << station << ",Ri:" << ring << ",Ch:" << chamber;
358  }
359 
360  chamberStr << ", Number of segments: " << chamberMatch->segmentMatches.size();
361  edm::LogVerbatim("MuonTrackProducer") << chamberStr.str();
362 
363  unsigned int index_segment = 0;
364 
365  for (std::vector<reco::MuonSegmentMatch>::const_iterator segmentMatch =
366  chamberMatch->segmentMatches.begin();
367  segmentMatch != chamberMatch->segmentMatches.end();
368  ++segmentMatch, index_segment++) {
369  float segmentX = segmentMatch->x;
370  float segmentY = segmentMatch->y;
371  float segmentdXdZ = segmentMatch->dXdZ;
372  float segmentdYdZ = segmentMatch->dYdZ;
373  float segmentXerr = segmentMatch->xErr;
374  float segmentYerr = segmentMatch->yErr;
375  float segmentdXdZerr = segmentMatch->dXdZErr;
376  float segmentdYdZerr = segmentMatch->dYdZErr;
377 
378  CSCSegmentRef segmentCSC = segmentMatch->cscSegmentRef;
379  DTRecSegment4DRef segmentDT = segmentMatch->dtSegmentRef;
380 
381  bool segment_arbitrated_Ok = (segmentMatch->isMask(reco::MuonSegmentMatch::BestInChamberByDR) &&
382  segmentMatch->isMask(reco::MuonSegmentMatch::BelongsToTrackByDR));
383 
384  std::string ARBITRATED(" ***Arbitrated Off*** ");
385  if (segment_arbitrated_Ok)
386  ARBITRATED = " ***ARBITRATED OK*** ";
387 
388  if (subdet == MuonSubdetId::DT) {
389  edm::LogVerbatim("MuonTrackProducer")
390  << "\n\t segment index: " << index_segment << ARBITRATED << "\n\t Local Position (X,Y)=("
391  << segmentX << "," << segmentY << ") +/- (" << segmentXerr << "," << segmentYerr << "), "
392  << "\n\t Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ << "," << segmentdYdZ << ") +/- ("
393  << segmentdXdZerr << "," << segmentdYdZerr << ")";
394 
395  if (!segment_arbitrated_Ok)
396  continue;
397 
398  if (segmentDT.get() != nullptr) {
399  const DTRecSegment4D *segment = segmentDT.get();
400 
401  edm::LogVerbatim("MuonTrackProducer")
402  << "\t ===> MATCHING with DT segment with index = " << segmentDT.key();
403 
404  if (segment->hasPhi()) {
405  const DTChamberRecSegment2D *phiSeg = segment->phiSegment();
406  std::vector<const TrackingRecHit *> phiHits = phiSeg->recHits();
407  for (std::vector<const TrackingRecHit *>::const_iterator ihit = phiHits.begin();
408  ihit != phiHits.end();
409  ++ihit) {
410  TrackingRecHit *seghit = (*ihit)->clone();
411  newTrk->appendHitPattern(*seghit, ttopo);
412  // edm::LogVerbatim("MuonTrackProducer")<<"hit
413  // pattern for position "<<index_hit<<" set to:";
414  // newTrk->hitPattern().printHitPattern(index_hit,
415  // std::cout);
416  selectedTrackHits->push_back(seghit);
417  ++nHitsToAdd;
418  }
419  }
420 
421  if (segment->hasZed()) {
422  const DTSLRecSegment2D *zSeg = (*segment).zSegment();
423  std::vector<const TrackingRecHit *> zedHits = zSeg->recHits();
424  for (std::vector<const TrackingRecHit *>::const_iterator ihit = zedHits.begin();
425  ihit != zedHits.end();
426  ++ihit) {
427  TrackingRecHit *seghit = (*ihit)->clone();
428  newTrk->appendHitPattern(*seghit, ttopo);
429  // edm::LogVerbatim("MuonTrackProducer")<<"hit
430  // pattern for position "<<index_hit<<" set to:";
431  // newTrk->hitPattern().printHitPattern(index_hit,
432  // std::cout);
433  selectedTrackHits->push_back(seghit);
434  ++nHitsToAdd;
435  }
436  }
437  } else
438  edm::LogWarning("MuonTrackProducer") << "\n***WARNING: UNMATCHED DT segment ! \n";
439  } // if (subdet == MuonSubdetId::DT)
440 
441  else if (subdet == MuonSubdetId::CSC) {
442  edm::LogVerbatim("MuonTrackProducer")
443  << "\n\t segment index: " << index_segment << ARBITRATED << "\n\t Local Position (X,Y)=("
444  << segmentX << "," << segmentY << ") +/- (" << segmentXerr << "," << segmentYerr << "), "
445  << "\n\t Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ << "," << segmentdYdZ << ") +/- ("
446  << segmentdXdZerr << "," << segmentdYdZerr << ")";
447 
448  if (!segment_arbitrated_Ok)
449  continue;
450 
451  if (segmentCSC.get() != nullptr) {
452  const CSCSegment *segment = segmentCSC.get();
453 
454  edm::LogVerbatim("MuonTrackProducer")
455  << "\t ===> MATCHING with CSC segment with index = " << segmentCSC.key();
456 
457  std::vector<const TrackingRecHit *> hits = segment->recHits();
458  for (std::vector<const TrackingRecHit *>::const_iterator ihit = hits.begin(); ihit != hits.end();
459  ++ihit) {
460  TrackingRecHit *seghit = (*ihit)->clone();
461  newTrk->appendHitPattern(*seghit, ttopo);
462  // edm::LogVerbatim("MuonTrackProducer")<<"hit
463  // pattern for position "<<index_hit<<" set to:";
464  // newTrk->hitPattern().printHitPattern(index_hit,
465  // std::cout);
466  selectedTrackHits->push_back(seghit);
467  ++nHitsToAdd;
468  }
469  } else
470  edm::LogWarning("MuonTrackProducer") << "\n***WARNING: UNMATCHED CSC segment ! \n";
471  } // else if (subdet == MuonSubdetId::CSC)
472 
473  } // loop on vector<MuonSegmentMatch>
474  } // loop on vector<MuonChamberMatch>
475  } // if (trackType == "innerTrackPlusSegments")
476 
477  // edm::LogVerbatim("MuonTrackProducer")<<"\n printing final
478  // hit_pattern"; newTrk->hitPattern().print();
479 
480  newExtra->setHits(rHits, hidx, nHitsToAdd);
481  hidx += nHitsToAdd;
482 
483  selectedTracks->push_back(*newTrk);
484  selectedTrackExtras->push_back(*newExtra);
485 
486  } // if (isGoodResult)
487  } // loop on reco::MuonCollection
488 
490  iEvent.put(std::move(selectedTrackExtras));
491  iEvent.put(std::move(selectedTrackHits));
492  }
493 }

References reco::MuonSegmentMatch::BelongsToTrackByDR, reco::MuonSegmentMatch::BestInChamberByDR, relativeConstraints::chamber, CSCDetId::chamber(), TrackingRecHit::clone(), MuonSubdetId::CSC, MuonSubdetId::DT, CSCDetId::endcap(), makeMuonMisalignmentScenario::endcap, edm::Ref< C, T, F >::get(), edm::EventSetup::getData(), DTRecSegment4D::hasPhi(), DTRecSegment4D::hasZed(), hfClusterShapes_cfi::hits, heavyIonCSV_trainingSettings::idx, iEvent, ignoreMissingMuonCollection, reco::Track::innerDetId(), reco::Track::innerMomentum(), reco::Track::innerOk(), reco::Track::innerPosition(), reco::Track::innerStateCovariance(), inputCSCSegmentToken_, inputDTRecSegment4DToken_, muon::isGoodMuon(), edm::HandleBase::isValid(), edm::Ref< C, T, F >::key(), eostools::move(), HLT_FULL_cff::muon, muonsToken, Skims_PA_cff::name, reco::Track::outerDetId(), reco::Track::outerMomentum(), reco::Track::outerOk(), reco::Track::outerPosition(), reco::Track::outerStateCovariance(), DTRecSegment4D::phiSegment(), CSCSegment::recHits(), DTRecSegment2D::recHits(), reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), CSCDetId::ring(), relativeConstraints::ring, DTChamberId::sector(), reco::Track::seedDirection(), reco::Muon::SegmentAndTrackArbitration, TrackCollections2monitor_cff::selectedTracks, selectionTags, muon::selectionTypeFromString(), mathSSE::sqrt(), DTChamberId::station(), relativeConstraints::station, CSCDetId::station(), AlCaHLTBitMon_QueryRunRegistry::string, trackType, ttopoToken_, DTChamberId::wheel(), makeMuonMisalignmentScenario::wheel, PV3DBase< T, PVType, FrameType >::x(), LocalError::xx(), PV3DBase< T, PVType, FrameType >::y(), LocalError::yy(), and PV3DBase< T, PVType, FrameType >::z().

Member Data Documentation

◆ ignoreMissingMuonCollection

bool MuonTrackProducer::ignoreMissingMuonCollection
private

Definition at line 41 of file MuonTrackProducer.cc.

Referenced by produce().

◆ inputCSCSegmentToken_

edm::EDGetTokenT<CSCSegmentCollection> MuonTrackProducer::inputCSCSegmentToken_
private

Definition at line 36 of file MuonTrackProducer.cc.

Referenced by produce().

◆ inputDTRecSegment4DToken_

edm::EDGetTokenT<DTRecSegment4DCollection> MuonTrackProducer::inputDTRecSegment4DToken_
private

Definition at line 35 of file MuonTrackProducer.cc.

Referenced by produce().

◆ muonsToken

edm::EDGetTokenT<reco::MuonCollection> MuonTrackProducer::muonsToken
private

Definition at line 34 of file MuonTrackProducer.cc.

Referenced by produce().

◆ selectionTags

std::vector<std::string> MuonTrackProducer::selectionTags
private

Definition at line 39 of file MuonTrackProducer.cc.

Referenced by produce().

◆ trackType

std::string MuonTrackProducer::trackType
private

Definition at line 40 of file MuonTrackProducer.cc.

Referenced by produce().

◆ ttopoToken_

edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> MuonTrackProducer::ttopoToken_
private

Definition at line 37 of file MuonTrackProducer.cc.

Referenced by produce().

reco::Track::outerPosition
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:62
Vector3DBase< float, LocalTag >
reco::Track::outerMomentum
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:65
edm::RefProd< TrackCollection >
DTSLRecSegment2D
Definition: DTSLRecSegment2D.h:15
reco::Track::outerStateCovariance
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
Definition: Track.h:68
MuonSubdetId::CSC
static constexpr int CSC
Definition: MuonSubdetId.h:12
DTRecSegment4D
Definition: DTRecSegment4D.h:23
reco::Track::outerDetId
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:79
reco::Muon::SegmentAndTrackArbitration
Definition: Muon.h:190
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
reco::Track::recHitsBegin
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:88
muon
Definition: MuonCocktails.h:17
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
relativeConstraints.station
station
Definition: relativeConstraints.py:67
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
TrackerTopology
Definition: TrackerTopology.h:16
edm::Ref::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
MuonTrackProducer::inputCSCSegmentToken_
edm::EDGetTokenT< CSCSegmentCollection > inputCSCSegmentToken_
Definition: MuonTrackProducer.cc:36
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
CSCSegmentCollection
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
reco::Track::outerOk
bool outerOk() const
return true if the outermost hit is valid
Definition: Track.h:50
edm::Handle< reco::MuonCollection >
MuonTrackProducer::inputDTRecSegment4DToken_
edm::EDGetTokenT< DTRecSegment4DCollection > inputDTRecSegment4DToken_
Definition: MuonTrackProducer.cc:35
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
reco::MuonSegmentMatch::BelongsToTrackByDR
static const unsigned int BelongsToTrackByDR
Definition: MuonSegmentMatch.h:25
edm::Ref< TrackCollection >
reco::Track::innerStateCovariance
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
Definition: Track.h:71
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
reco::Track::innerOk
bool innerOk() const
return true if the innermost hit is valid
Definition: Track.h:53
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
DTRecSegment2D::recHits
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
Definition: DTRecSegment2D.cc:86
DetId
Definition: DetId.h:17
reco::TrackExtra
Definition: TrackExtra.h:26
MuonTrackProducer::muonsToken
edm::EDGetTokenT< reco::MuonCollection > muonsToken
Definition: MuonTrackProducer.cc:34
reco::Track::innerMomentum
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:59
muon::isGoodMuon
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
Definition: MuonSelectors.cc:649
muon::selectionTypeFromString
SelectionType selectionTypeFromString(const std::string &label)
Definition: MuonSelectors.cc:9
muon::SelectionType
SelectionType
Selector type.
Definition: MuonSelectors.h:18
MuonTrackProducer::selectionTags
std::vector< std::string > selectionTags
Definition: MuonTrackProducer.cc:39
LocalError::xx
float xx() const
Definition: LocalError.h:22
HLT_FULL_cff.muon
muon
Definition: HLT_FULL_cff.py:11710
edm::ParameterSet::dump
std::string dump(unsigned int indent=0) const
Definition: ParameterSet.cc:832
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
reco::Track::recHitsEnd
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:91
reco::Track
Definition: Track.h:27
reco::TrackExtraCollection
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
MuonSubdetId::DT
static constexpr int DT
Definition: MuonSubdetId.h:11
Point3DBase< float, LocalTag >
DTRecSegment4DCollection
CSCSegment
Definition: CSCSegment.h:21
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
reco::Track::seedDirection
const PropagationDirection & seedDirection() const
direction of how the hits were sorted in the original seed
Definition: Track.h:148
MuonTrackProducer::ttopoToken_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > ttopoToken_
Definition: MuonTrackProducer.cc:37
LocalError
Definition: LocalError.h:12
edm::RangeMap::const_iterator
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
CSCDetId
Definition: CSCDetId.h:26
MuonTrackProducer::ignoreMissingMuonCollection
bool ignoreMissingMuonCollection
Definition: MuonTrackProducer.cc:41
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
reco::Track::innerPosition
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:56
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
iEvent
int iEvent
Definition: GenABIO.cc:224
DTChamberRecSegment2D
Definition: DTChamberRecSegment2D.h:31
reco::Track::innerDetId
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:82
CSCDetId::chamber
int chamber() const
Definition: CSCDetId.h:62
TrackingRecHit::clone
virtual TrackingRecHit * clone() const =0
edm::Ref::key_type
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:164
MuonTrackProducer::trackType
std::string trackType
Definition: MuonTrackProducer.cc:40
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
TrackingRecHit
Definition: TrackingRecHit.h:21
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
eostools.move
def move(src, dest)
Definition: eostools.py:511
DTRecSegment4D::hasZed
bool hasZed() const
Does it have the Z projection?
Definition: DTRecSegment4D.h:93
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
CSCDetId::endcap
int endcap() const
Definition: CSCDetId.h:85
PropagationDirection
PropagationDirection
Definition: PropagationDirection.h:4
TrackingRecHitCollection
edm::OwnVector< TrackingRecHit > TrackingRecHitCollection
collection of TrackingRecHits
Definition: TrackingRecHitFwd.h:10
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
DTRecSegment4D::hasPhi
bool hasPhi() const
Does it have the Phi projection?
Definition: DTRecSegment4D.h:90
edm::Ref::key
key_type key() const
Accessor for product key.
Definition: Ref.h:250
DTChamberId
Definition: DTChamberId.h:14
CSCDetId::station
int station() const
Definition: CSCDetId.h:79
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Log
Definition: MessageLogger.h:70
DTRecSegment4D::phiSegment
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
Definition: DTRecSegment4D.h:96
LocalError::yy
float yy() const
Definition: LocalError.h:24
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
hit
Definition: SiStripHitEffFromCalibTree.cc:88
edm::OwnVector< TrackingRecHit >
TrackCollections2monitor_cff.selectedTracks
selectedTracks
Definition: TrackCollections2monitor_cff.py:32
reco::MuonSegmentMatch::BestInChamberByDR
static const unsigned int BestInChamberByDR
Definition: MuonSegmentMatch.h:17
CSCSegment::recHits
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
Definition: CSCSegment.cc:32