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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
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<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

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.

References edm::ParameterSet::dump().

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 }
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< DTRecSegment4DCollection > inputDTRecSegment4DToken_
std::vector< std::string > selectionTags
edm::EDGetTokenT< reco::MuonCollection > muonsToken
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > ttopoToken_
T getUntrackedParameter(std::string const &, T const &) const
std::string dump(unsigned int indent=0) const
edm::EDGetTokenT< CSCSegmentCollection > inputCSCSegmentToken_

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.

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_2023v12_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(), relativeConstraints::ring, CSCDetId::ring(), hgcalTBTopologyTester_cfi::sector, 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().

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->muonBestTrackType() != muon->tunePMuonBestTrackType())
213  edm::LogVerbatim("MuonTrackProducer") << "\n *** PF != TuneP *** \n" << std::endl;
214 
215  edm::LogVerbatim("MuonTrackProducer") << "isGlobal ? " << muon->isGlobalMuon() << std::endl;
216  edm::LogVerbatim("MuonTrackProducer")
217  << "isTracker ? " << muon->isTrackerMuon() << ", isRPC ? " << muon->isRPCMuon() << ", isGEM ? "
218  << muon->isGEMMuon() << ", isME0 ? " << muon->isME0Muon() << std::endl;
219  edm::LogVerbatim("MuonTrackProducer") << "isStandAlone ? " << muon->isStandAloneMuon() << std::endl;
220  edm::LogVerbatim("MuonTrackProducer") << "isCalo ? " << muon->isCaloMuon() << std::endl;
221  edm::LogVerbatim("MuonTrackProducer") << "isPF ? " << muon->isPFMuon() << std::endl << std::endl;
222 
223  edm::LogVerbatim("MuonTrackProducer")
224  << " enum MuonTrackType {None, InnerTrack, OuterTrack, CombinedTrack, TPFMS, Picky, DYT }" << std::endl;
225 
226  edm::LogVerbatim("MuonTrackProducer")
227  << "(muon) pt = " << muon->pt() << ", eta = " << muon->eta() << ", phi = " << muon->phi() << std::endl;
228 
229  if (muon->muonBestTrack().isNonnull())
230  edm::LogVerbatim("MuonTrackProducer")
231  << "(best) pt = " << muon->muonBestTrack()->pt() << ", eta = " << muon->muonBestTrack()->eta()
232  << ", phi = " << muon->muonBestTrack()->phi()
233  << ", N mu hits = " << muon->muonBestTrack()->hitPattern().numberOfValidMuonHits()
234  << ", N trk hits = " << muon->muonBestTrack()->hitPattern().numberOfValidTrackerHits()
235  << ", MuonTrackType = " << muon->muonBestTrackType() << std::endl;
236  if (muon->tunePMuonBestTrack().isNonnull())
237  edm::LogVerbatim("MuonTrackProducer")
238  << "(tuneP) pt = " << muon->tunePMuonBestTrack()->pt()
239  << ", eta = " << muon->tunePMuonBestTrack()->eta() << ", phi = " << muon->tunePMuonBestTrack()->phi()
240  << ", N mu hits = " << muon->tunePMuonBestTrack()->hitPattern().numberOfValidMuonHits()
241  << ", N trk hits = " << muon->tunePMuonBestTrack()->hitPattern().numberOfValidTrackerHits()
242  << ", MuonTrackType = " << muon->tunePMuonBestTrackType() << std::endl;
243  if (muon->innerTrack().isNonnull())
244  edm::LogVerbatim("MuonTrackProducer")
245  << "(inner) pt = " << muon->innerTrack()->pt() << ", eta = " << muon->innerTrack()->eta()
246  << ", phi = " << muon->innerTrack()->phi()
247  << ", N trk hits = " << muon->innerTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
248  if (muon->globalTrack().isNonnull())
249  edm::LogVerbatim("MuonTrackProducer")
250  << "(global) pt = " << muon->globalTrack()->pt() << ", eta = " << muon->globalTrack()->eta()
251  << ", phi = " << muon->globalTrack()->phi()
252  << ", N mu hits = " << muon->globalTrack()->hitPattern().numberOfValidMuonHits()
253  << ", N trk hits = " << muon->globalTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
254  if (muon->outerTrack().isNonnull())
255  edm::LogVerbatim("MuonTrackProducer")
256  << "(outer) pt = " << muon->outerTrack()->pt() << ", eta = " << muon->outerTrack()->eta()
257  << ", phi = " << muon->outerTrack()->phi()
258  << ", N mu hits = " << muon->outerTrack()->hitPattern().numberOfValidMuonHits() << std::endl;
259  if (muon->tpfmsTrack().isNonnull())
260  edm::LogVerbatim("MuonTrackProducer")
261  << "(tpfms) pt = " << muon->tpfmsTrack()->pt() << ", eta = " << muon->tpfmsTrack()->eta()
262  << ", phi = " << muon->tpfmsTrack()->phi()
263  << ", N mu hits = " << muon->tpfmsTrack()->hitPattern().numberOfValidMuonHits()
264  << ", N trk hits = " << muon->tpfmsTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
265  if (muon->pickyTrack().isNonnull())
266  edm::LogVerbatim("MuonTrackProducer")
267  << "(picky) pt = " << muon->pickyTrack()->pt() << ", eta = " << muon->pickyTrack()->eta()
268  << ", phi = " << muon->pickyTrack()->phi()
269  << ", N mu hits = " << muon->pickyTrack()->hitPattern().numberOfValidMuonHits()
270  << ", N trk hits = " << muon->pickyTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
271  if (muon->dytTrack().isNonnull())
272  edm::LogVerbatim("MuonTrackProducer")
273  << "(dyt) pt = " << muon->dytTrack()->pt() << ", eta = " << muon->dytTrack()->eta()
274  << ", phi = " << muon->dytTrack()->phi()
275  << ", N mu hits = " << muon->dytTrack()->hitPattern().numberOfValidMuonHits()
276  << ", N trk hits = " << muon->dytTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
277 
278  if (muon->isGlobalMuon() && muon->globalTrack()->hitPattern().numberOfValidMuonHits() > 0)
279  trackref = muon->globalTrack();
280  else if (muon->isTrackerMuon()) {
281  trackref = muon->innerTrack();
282  addMatchedMuonSegments = true;
283  } else if (muon->isPFMuon())
284  trackref = muon->muonBestTrack();
285  else if (muon->isStandAloneMuon())
286  trackref = muon->outerTrack();
287  else if (muon->isRPCMuon())
288  trackref = muon->innerTrack();
289  else if (muon->isGEMMuon())
290  trackref = muon->innerTrack();
291  else if (muon->isME0Muon())
292  trackref = muon->innerTrack();
293  else
294  trackref = muon->muonBestTrack();
295  }
296 
297  edm::LogVerbatim("MuonTrackProducer") << "\t *** Selected *** ";
298  const reco::Track *trk = &(*trackref);
299  // pointer to old track:
300  std::unique_ptr<reco::Track> newTrk(new reco::Track(*trk));
301 
302  newTrk->setExtra(reco::TrackExtraRef(rTrackExtras, idx++));
303  PropagationDirection seedDir = trk->seedDirection();
304  // new copy of track Extras
305  std::unique_ptr<reco::TrackExtra> newExtra(new reco::TrackExtra(trk->outerPosition(),
306  trk->outerMomentum(),
307  trk->outerOk(),
308  trk->innerPosition(),
309  trk->innerMomentum(),
310  trk->innerOk(),
311  trk->outerStateCovariance(),
312  trk->outerDetId(),
313  trk->innerStateCovariance(),
314  trk->innerDetId(),
315  seedDir));
316 
317  // new copy of the silicon hits; add hit refs to Extra and hits to hit
318  // collection
319 
320  // edm::LogVerbatim("MuonTrackProducer")<<"\n printing initial
321  // hit_pattern"; trk->hitPattern().print();
322  unsigned int nHitsToAdd = 0;
323  for (trackingRecHit_iterator iHit = trk->recHitsBegin(); iHit != trk->recHitsEnd(); iHit++) {
324  TrackingRecHit *hit = (*iHit)->clone();
325  selectedTrackHits->push_back(hit);
326  ++nHitsToAdd;
327  }
328 
329  if (addMatchedMuonSegments) {
330  int wheel, station, sector;
331  int endcap, /*station, */ ring, chamber;
332 
333  edm::LogVerbatim("MuonTrackProducer")
334  << "Number of chambers: " << muon->matches().size()
335  << ", arbitrated: " << muon->numberOfMatches(reco::Muon::SegmentAndTrackArbitration);
336  unsigned int index_chamber = 0;
337 
338  for (std::vector<reco::MuonChamberMatch>::const_iterator chamberMatch = muon->matches().begin();
339  chamberMatch != muon->matches().end();
340  ++chamberMatch, index_chamber++) {
341  std::stringstream chamberStr;
342  chamberStr << "\nchamber index: " << index_chamber;
343 
344  int subdet = chamberMatch->detector();
345  DetId did = chamberMatch->id;
346 
347  if (subdet == MuonSubdetId::DT) {
348  DTChamberId dtdetid = DTChamberId(did);
349  wheel = dtdetid.wheel();
350  station = dtdetid.station();
351  sector = dtdetid.sector();
352  chamberStr << ", DT chamber Wh:" << wheel << ",St:" << station << ",Se:" << sector;
353  } else if (subdet == MuonSubdetId::CSC) {
354  CSCDetId cscdetid = CSCDetId(did);
355  endcap = cscdetid.endcap();
356  station = cscdetid.station();
357  ring = cscdetid.ring();
358  chamber = cscdetid.chamber();
359  chamberStr << ", CSC chamber End:" << endcap << ",St:" << station << ",Ri:" << ring << ",Ch:" << chamber;
360  }
361 
362  chamberStr << ", Number of segments: " << chamberMatch->segmentMatches.size();
363  edm::LogVerbatim("MuonTrackProducer") << chamberStr.str();
364 
365  unsigned int index_segment = 0;
366 
367  for (std::vector<reco::MuonSegmentMatch>::const_iterator segmentMatch =
368  chamberMatch->segmentMatches.begin();
369  segmentMatch != chamberMatch->segmentMatches.end();
370  ++segmentMatch, index_segment++) {
371  float segmentX = segmentMatch->x;
372  float segmentY = segmentMatch->y;
373  float segmentdXdZ = segmentMatch->dXdZ;
374  float segmentdYdZ = segmentMatch->dYdZ;
375  float segmentXerr = segmentMatch->xErr;
376  float segmentYerr = segmentMatch->yErr;
377  float segmentdXdZerr = segmentMatch->dXdZErr;
378  float segmentdYdZerr = segmentMatch->dYdZErr;
379 
380  CSCSegmentRef segmentCSC = segmentMatch->cscSegmentRef;
381  DTRecSegment4DRef segmentDT = segmentMatch->dtSegmentRef;
382 
383  bool segment_arbitrated_Ok = (segmentMatch->isMask(reco::MuonSegmentMatch::BestInChamberByDR) &&
384  segmentMatch->isMask(reco::MuonSegmentMatch::BelongsToTrackByDR));
385 
386  std::string ARBITRATED(" ***Arbitrated Off*** ");
387  if (segment_arbitrated_Ok)
388  ARBITRATED = " ***ARBITRATED OK*** ";
389 
390  if (subdet == MuonSubdetId::DT) {
391  edm::LogVerbatim("MuonTrackProducer")
392  << "\n\t segment index: " << index_segment << ARBITRATED << "\n\t Local Position (X,Y)=("
393  << segmentX << "," << segmentY << ") +/- (" << segmentXerr << "," << segmentYerr << "), "
394  << "\n\t Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ << "," << segmentdYdZ << ") +/- ("
395  << segmentdXdZerr << "," << segmentdYdZerr << ")";
396 
397  if (!segment_arbitrated_Ok)
398  continue;
399 
400  if (segmentDT.get() != nullptr) {
401  const DTRecSegment4D *segment = segmentDT.get();
402 
403  edm::LogVerbatim("MuonTrackProducer")
404  << "\t ===> MATCHING with DT segment with index = " << segmentDT.key();
405 
406  if (segment->hasPhi()) {
407  const DTChamberRecSegment2D *phiSeg = segment->phiSegment();
408  std::vector<const TrackingRecHit *> phiHits = phiSeg->recHits();
409  for (std::vector<const TrackingRecHit *>::const_iterator ihit = phiHits.begin();
410  ihit != phiHits.end();
411  ++ihit) {
412  TrackingRecHit *seghit = (*ihit)->clone();
413  newTrk->appendHitPattern(*seghit, ttopo);
414  // edm::LogVerbatim("MuonTrackProducer")<<"hit
415  // pattern for position "<<index_hit<<" set to:";
416  // newTrk->hitPattern().printHitPattern(index_hit,
417  // std::cout);
418  selectedTrackHits->push_back(seghit);
419  ++nHitsToAdd;
420  }
421  }
422 
423  if (segment->hasZed()) {
424  const DTSLRecSegment2D *zSeg = (*segment).zSegment();
425  std::vector<const TrackingRecHit *> zedHits = zSeg->recHits();
426  for (std::vector<const TrackingRecHit *>::const_iterator ihit = zedHits.begin();
427  ihit != zedHits.end();
428  ++ihit) {
429  TrackingRecHit *seghit = (*ihit)->clone();
430  newTrk->appendHitPattern(*seghit, ttopo);
431  // edm::LogVerbatim("MuonTrackProducer")<<"hit
432  // pattern for position "<<index_hit<<" set to:";
433  // newTrk->hitPattern().printHitPattern(index_hit,
434  // std::cout);
435  selectedTrackHits->push_back(seghit);
436  ++nHitsToAdd;
437  }
438  }
439  } else
440  edm::LogWarning("MuonTrackProducer") << "\n***WARNING: UNMATCHED DT segment ! \n";
441  } // if (subdet == MuonSubdetId::DT)
442 
443  else if (subdet == MuonSubdetId::CSC) {
444  edm::LogVerbatim("MuonTrackProducer")
445  << "\n\t segment index: " << index_segment << ARBITRATED << "\n\t Local Position (X,Y)=("
446  << segmentX << "," << segmentY << ") +/- (" << segmentXerr << "," << segmentYerr << "), "
447  << "\n\t Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ << "," << segmentdYdZ << ") +/- ("
448  << segmentdXdZerr << "," << segmentdYdZerr << ")";
449 
450  if (!segment_arbitrated_Ok)
451  continue;
452 
453  if (segmentCSC.get() != nullptr) {
454  const CSCSegment *segment = segmentCSC.get();
455 
456  edm::LogVerbatim("MuonTrackProducer")
457  << "\t ===> MATCHING with CSC segment with index = " << segmentCSC.key();
458 
459  std::vector<const TrackingRecHit *> hits = segment->recHits();
460  for (std::vector<const TrackingRecHit *>::const_iterator ihit = hits.begin(); ihit != hits.end();
461  ++ihit) {
462  TrackingRecHit *seghit = (*ihit)->clone();
463  newTrk->appendHitPattern(*seghit, ttopo);
464  // edm::LogVerbatim("MuonTrackProducer")<<"hit
465  // pattern for position "<<index_hit<<" set to:";
466  // newTrk->hitPattern().printHitPattern(index_hit,
467  // std::cout);
468  selectedTrackHits->push_back(seghit);
469  ++nHitsToAdd;
470  }
471  } else
472  edm::LogWarning("MuonTrackProducer") << "\n***WARNING: UNMATCHED CSC segment ! \n";
473  } // else if (subdet == MuonSubdetId::CSC)
474 
475  } // loop on vector<MuonSegmentMatch>
476  } // loop on vector<MuonChamberMatch>
477  } // if (trackType == "innerTrackPlusSegments")
478 
479  // edm::LogVerbatim("MuonTrackProducer")<<"\n printing final
480  // hit_pattern"; newTrk->hitPattern().print();
481 
482  newExtra->setHits(rHits, hidx, nHitsToAdd);
483  hidx += nHitsToAdd;
484 
485  selectedTracks->push_back(*newTrk);
486  selectedTrackExtras->push_back(*newExtra);
487 
488  } // if (isGoodResult)
489  } // loop on reco::MuonCollection
490 
492  iEvent.put(std::move(selectedTrackExtras));
493  iEvent.put(std::move(selectedTrackHits));
494  }
495 }
Log< level::Info, true > LogVerbatim
int station() const
Return the station number.
Definition: DTChamberId.h:42
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:164
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
Definition: CSCSegment.cc:32
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
Definition: Track.h:68
bool hasPhi() const
Does it have the Phi projection?
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:62
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:65
edm::EDGetTokenT< DTRecSegment4DCollection > inputDTRecSegment4DToken_
std::vector< std::string > selectionTags
T z() const
Definition: PV3DBase.h:61
edm::EDGetTokenT< reco::MuonCollection > muonsToken
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
PropagationDirection
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > ttopoToken_
key_type key() const
Accessor for product key.
Definition: Ref.h:250
SelectionType
Selector type.
Definition: MuonSelectors.h:18
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
Definition: Track.h:71
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
float yy() const
Definition: LocalError.h:24
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
int iEvent
Definition: GenABIO.cc:224
T sqrt(T t)
Definition: SSEVec.h:19
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:91
int chamber() const
Definition: CSCDetId.h:62
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
static const unsigned int BestInChamberByDR
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:82
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:88
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
virtual TrackingRecHit * clone() const =0
bool innerOk() const
return true if the innermost hit is valid
Definition: Track.h:53
Definition: DetId.h:17
const PropagationDirection & seedDirection() const
direction of how the hits were sorted in the original seed
Definition: Track.h:148
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
edm::OwnVector< TrackingRecHit > TrackingRecHitCollection
collection of TrackingRecHits
int station() const
Definition: CSCDetId.h:79
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
SelectionType selectionTypeFromString(const std::string &label)
Definition: MuonSelectors.cc:9
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:79
int endcap() const
Definition: CSCDetId.h:85
bool isValid() const
Definition: HandleBase.h:70
static const unsigned int BelongsToTrackByDR
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
int sector() const
Definition: DTChamberId.h:49
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:59
static constexpr int DT
Definition: MuonSubdetId.h:11
int ring() const
Definition: CSCDetId.h:68
Log< level::Warning, false > LogWarning
bool hasZed() const
Does it have the Z projection?
static constexpr int CSC
Definition: MuonSubdetId.h:12
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:56
edm::EDGetTokenT< CSCSegmentCollection > inputCSCSegmentToken_
float xx() const
Definition: LocalError.h:22
def move(src, dest)
Definition: eostools.py:511
bool outerOk() const
return true if the outermost hit is valid
Definition: Track.h:50

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().