CMS 3D CMS Logo

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

#include <MuonAssociatorEDProducer.h>

Inheritance diagram for MuonAssociatorEDProducer:
edm::stream::EDProducer<>

Public Member Functions

 MuonAssociatorEDProducer (const edm::ParameterSet &)
 
 ~MuonAssociatorEDProducer () override
 
- Public Member Functions inherited from edm::stream::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
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

MuonAssociatorByHitsassociatorByHits
 
bool ignoreMissingTrackCollection
 
edm::ParameterSet parset_
 
bool tpRefVector
 
edm::EDGetTokenT< TrackingParticleRefVectortpRefVectorToken_
 
edm::InputTag tpTag
 
edm::EDGetTokenT< TrackingParticleCollectiontpToken_
 
edm::InputTag tracksTag
 
edm::EDGetTokenT< edm::View< reco::Track > > tracksToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 13 of file MuonAssociatorEDProducer.h.

Constructor & Destructor Documentation

◆ MuonAssociatorEDProducer()

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

Perform some sanity checks of the configuration

Definition at line 7 of file MuonAssociatorEDProducer.cc.

8  : tracksTag(parset.getParameter<edm::InputTag>("tracksTag")),
9  tpTag(parset.getParameter<edm::InputTag>("tpTag")),
10  tpRefVector(parset.getParameter<bool>("tpRefVector")),
11  ignoreMissingTrackCollection(parset.getUntrackedParameter<bool>("ignoreMissingTrackCollection", false)),
12  parset_(parset) {
13  edm::LogVerbatim("MuonAssociatorEDProducer") << "constructing MuonAssociatorEDProducer";
14  produces<reco::RecoToSimCollection>();
15  produces<reco::SimToRecoCollection>();
16  if (tpRefVector)
17  tpRefVectorToken_ = consumes<TrackingParticleRefVector>(tpTag);
18  else
19  tpToken_ = consumes<TrackingParticleCollection>(tpTag);
20  tracksToken_ = consumes<edm::View<reco::Track>>(tracksTag);
21 
23  LogTrace("MuonAssociatorEDProducer") << "constructing MuonAssociatorByHits" << parset_.dump();
24  edm::LogVerbatim("MuonAssociatorEDProducer") << "\n MuonAssociatorByHits will associate reco::Tracks with "
25  << tracksTag << "\n\t\t and TrackingParticles with " << tpTag;
26  const std::string recoTracksLabel = tracksTag.label();
27 
28  // check and fix inconsistent input settings
29  // tracks with hits only on muon detectors
30  if (recoTracksLabel == "seedsOfSTAmuons" || recoTracksLabel == "standAloneMuons" ||
31  recoTracksLabel == "refittedStandAloneMuons" || recoTracksLabel == "seedsOfDisplacedSTAmuons" ||
32  recoTracksLabel == "displacedStandAloneMuons" || recoTracksLabel == "cosmicMuons" ||
33  recoTracksLabel == "cosmicMuons1Leg" || recoTracksLabel == "hltL2Muons") {
34  if (parset_.getParameter<bool>("UseTracker")) {
35  edm::LogWarning("MuonAssociatorEDProducer")
36  << "\n*** WARNING : inconsistent input tracksTag = " << tracksTag << "\n with UseTracker = true"
37  << "\n ---> setting UseTracker = false ";
38  parset_.addParameter<bool>("UseTracker", false);
39  }
40  if (!parset_.getParameter<bool>("UseMuon")) {
41  edm::LogWarning("MuonAssociatorEDProducer")
42  << "\n*** WARNING : inconsistent input tracksTag = " << tracksTag << "\n with UseMuon = false"
43  << "\n ---> setting UseMuon = true ";
44  parset_.addParameter<bool>("UseMuon", true);
45  }
46  }
47  // tracks with hits only on tracker
48  if (recoTracksLabel == "generalTracks" || recoTracksLabel == "probeTracks" || recoTracksLabel == "displacedTracks" ||
49  recoTracksLabel == "extractGemMuons" || recoTracksLabel == "extractMe0Muons" ||
50  recoTracksLabel == "ctfWithMaterialTracksP5LHCNavigation" || recoTracksLabel == "ctfWithMaterialTracksP5" ||
51  recoTracksLabel == "hltIterL3OIMuonTrackSelectionHighPurity" || recoTracksLabel == "hltIterL3MuonMerged" ||
52  recoTracksLabel == "hltIterL3MuonAndMuonFromL1Merged") {
53  if (parset_.getParameter<bool>("UseMuon")) {
54  edm::LogWarning("MuonAssociatorEDProducer")
55  << "\n*** WARNING : inconsistent input tracksTag = " << tracksTag << "\n with UseMuon = true"
56  << "\n ---> setting UseMuon = false ";
57  parset_.addParameter<bool>("UseMuon", false);
58  }
59  if (!parset_.getParameter<bool>("UseTracker")) {
60  edm::LogWarning("MuonAssociatorEDProducer")
61  << "\n*** WARNING : inconsistent input tracksTag = " << tracksTag << "\n with UseTracker = false"
62  << "\n ---> setting UseTracker = true ";
63  parset_.addParameter<bool>("UseTracker", true);
64  }
65  }
66 
67  LogTrace("MuonAssociatorEDProducer") << "MuonAssociatorEDProducer::beginJob "
68  ": constructing MuonAssociatorByHits";
69  associatorByHits = new MuonAssociatorByHits(parset_, consumesCollector());
70 }

References edm::ParameterSet::addParameter(), associatorByHits, edm::ParameterSet::dump(), edm::ParameterSet::getParameter(), edm::InputTag::label(), LogTrace, parset_, AlCaHLTBitMon_QueryRunRegistry::string, tpRefVector, tpRefVectorToken_, tpTag, tpToken_, tracksTag, and tracksToken_.

◆ ~MuonAssociatorEDProducer()

MuonAssociatorEDProducer::~MuonAssociatorEDProducer ( )
override

Definition at line 72 of file MuonAssociatorEDProducer.cc.

72 {}

Member Function Documentation

◆ beginJob()

void MuonAssociatorEDProducer::beginJob ( void  )
privatevirtual

Definition at line 74 of file MuonAssociatorEDProducer.cc.

74 {}

◆ endJob()

void MuonAssociatorEDProducer::endJob ( void  )
privatevirtual

Definition at line 76 of file MuonAssociatorEDProducer.cc.

76 {}

◆ produce()

void MuonAssociatorEDProducer::produce ( edm::Event event,
const edm::EventSetup setup 
)
overrideprivate

Definition at line 78 of file MuonAssociatorEDProducer.cc.

78  {
79  using namespace edm;
80 
82  const TrackingParticleRefVector *tmpTPptr = nullptr;
84  Handle<TrackingParticleRefVector> TPCollectionRefVector;
85 
86  if (tpRefVector) {
87  event.getByToken(tpRefVectorToken_, TPCollectionRefVector);
88  tmpTPptr = TPCollectionRefVector.product();
89  //
90  tmpTP = *tmpTPptr;
91  } else {
92  event.getByToken(tpToken_, TPCollection);
93  size_t nTP = TPCollection->size();
94  for (size_t i = 0; i < nTP; ++i) {
95  tmpTP.push_back(TrackingParticleRef(TPCollection, i));
96  }
97  tmpTPptr = &tmpTP;
98  }
99 
100  LogTrace("MuonAssociatorEDProducer") << "getting TrackingParticle collection - " << tpTag;
101  LogTrace("MuonAssociatorEDProducer") << "\t... size = " << tmpTPptr->size();
102 
104  LogTrace("MuonAssociatorEDProducer") << "getting reco::Track collection - " << tracksTag;
105  bool trackAvailable = event.getByToken(tracksToken_, trackCollection);
106  if (trackAvailable)
107  LogTrace("MuonAssociatorEDProducer") << "\t... size = " << trackCollection->size();
108  else
109  LogTrace("MuonAssociatorEDProducer") << "\t... NOT FOUND.";
110 
111  std::unique_ptr<reco::RecoToSimCollection> rts;
112  std::unique_ptr<reco::SimToRecoCollection> str;
113 
114  if (ignoreMissingTrackCollection && !trackAvailable) {
115  // the track collection is not in the event and we're being told to ignore
116  // this. do not output anything to the event, other wise this would be
117  // considered as inefficiency.
118  LogTrace("MuonAssociatorEDProducer") << "\n ignoring missing track collection."
119  << "\n";
120  } else {
122  for (size_t i = 0; i < trackCollection->size(); ++i)
123  tmpT.push_back(trackCollection->refAt(i));
124 
125  edm::LogVerbatim("MuonAssociatorEDProducer")
126  << "\n >>> RecoToSim association <<< \n"
127  << " Track collection : " << tracksTag.label() << ":" << tracksTag.instance()
128  << " (size = " << trackCollection->size() << ") \n"
129  << " TrackingParticle collection : " << tpTag.label() << ":" << tpTag.instance()
130  << " (size = " << tmpTPptr->size() << ")";
131 
133 
134  edm::LogVerbatim("MuonAssociatorEDProducer")
135  << "\n >>> SimToReco association <<< \n"
136  << " TrackingParticle collection : " << tpTag.label() << ":" << tpTag.instance()
137  << " (size = " << tmpTPptr->size() << ") \n"
138  << " Track collection : " << tracksTag.label() << ":" << tracksTag.instance()
139  << " (size = " << trackCollection->size() << ")";
140 
142 
143  rts = std::make_unique<reco::RecoToSimCollection>(recSimColl);
144  str = std::make_unique<reco::SimToRecoCollection>(simRecColl);
145 
146  event.put(std::move(rts));
147  event.put(std::move(str));
148  }
149 }

References MuonAssociatorByHits::associateRecoToSim(), MuonAssociatorByHits::associateSimToReco(), associatorByHits, mps_fire::i, ignoreMissingTrackCollection, edm::InputTag::instance(), edm::InputTag::label(), LogTrace, eostools::move(), edm::Handle< T >::product(), edm::RefToBaseVector< T >::push_back(), edm::RefVector< C, T, F >::push_back(), singleTopDQM_cfi::setup, edm::RefVector< C, T, F >::size(), str, tpRefVector, tpRefVectorToken_, tpTag, tpToken_, duplicaterechits_cfi::trackCollection, tracksTag, and tracksToken_.

Member Data Documentation

◆ associatorByHits

MuonAssociatorByHits* MuonAssociatorEDProducer::associatorByHits
private

Definition at line 32 of file MuonAssociatorEDProducer.h.

Referenced by MuonAssociatorEDProducer(), and produce().

◆ ignoreMissingTrackCollection

bool MuonAssociatorEDProducer::ignoreMissingTrackCollection
private

Definition at line 30 of file MuonAssociatorEDProducer.h.

Referenced by produce().

◆ parset_

edm::ParameterSet MuonAssociatorEDProducer::parset_
private

Definition at line 31 of file MuonAssociatorEDProducer.h.

Referenced by MuonAssociatorEDProducer().

◆ tpRefVector

bool MuonAssociatorEDProducer::tpRefVector
private

Definition at line 29 of file MuonAssociatorEDProducer.h.

Referenced by MuonAssociatorEDProducer(), and produce().

◆ tpRefVectorToken_

edm::EDGetTokenT<TrackingParticleRefVector> MuonAssociatorEDProducer::tpRefVectorToken_
private

Definition at line 26 of file MuonAssociatorEDProducer.h.

Referenced by MuonAssociatorEDProducer(), and produce().

◆ tpTag

edm::InputTag MuonAssociatorEDProducer::tpTag
private

Definition at line 24 of file MuonAssociatorEDProducer.h.

Referenced by MuonAssociatorEDProducer(), and produce().

◆ tpToken_

edm::EDGetTokenT<TrackingParticleCollection> MuonAssociatorEDProducer::tpToken_
private

Definition at line 25 of file MuonAssociatorEDProducer.h.

Referenced by MuonAssociatorEDProducer(), and produce().

◆ tracksTag

edm::InputTag MuonAssociatorEDProducer::tracksTag
private

Definition at line 23 of file MuonAssociatorEDProducer.h.

Referenced by MuonAssociatorEDProducer(), and produce().

◆ tracksToken_

edm::EDGetTokenT<edm::View<reco::Track> > MuonAssociatorEDProducer::tracksToken_
private

Definition at line 27 of file MuonAssociatorEDProducer.h.

Referenced by MuonAssociatorEDProducer(), and produce().

mps_fire.i
i
Definition: mps_fire.py:428
edm::Handle::product
T const * product() const
Definition: Handle.h:70
MuonAssociatorEDProducer::tpToken_
edm::EDGetTokenT< TrackingParticleCollection > tpToken_
Definition: MuonAssociatorEDProducer.h:25
edm::InputTag::instance
std::string const & instance() const
Definition: InputTag.h:37
MuonAssociatorEDProducer::tpRefVectorToken_
edm::EDGetTokenT< TrackingParticleRefVector > tpRefVectorToken_
Definition: MuonAssociatorEDProducer.h:26
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::RefVector< TrackingParticleCollection >
MuonAssociatorEDProducer::tpTag
edm::InputTag tpTag
Definition: MuonAssociatorEDProducer.h:24
edm::Handle< TrackingParticleCollection >
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
MuonAssociatorEDProducer::tracksToken_
edm::EDGetTokenT< edm::View< reco::Track > > tracksToken_
Definition: MuonAssociatorEDProducer.h:27
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
edm::RefToBaseVector::push_back
void push_back(const RefToBase< T > &)
Definition: RefToBaseVector.h:217
edm::ParameterSet::dump
std::string dump(unsigned int indent=0) const
Definition: ParameterSet.cc:832
str
#define str(s)
Definition: TestProcessor.cc:53
MuonAssociatorByHits::associateRecoToSim
reco::RecoToSimCollection associateRecoToSim(edm::Handle< edm::View< reco::Track >> &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) const
Definition: MuonAssociatorByHits.h:32
MuonAssociatorEDProducer::parset_
edm::ParameterSet parset_
Definition: MuonAssociatorEDProducer.h:31
MuonAssociatorByHits
Definition: MuonAssociatorByHits.h:25
duplicaterechits_cfi.trackCollection
trackCollection
Definition: duplicaterechits_cfi.py:4
edm::AssociationMap< edm::OneToManyWithQualityGeneric< edm::View< reco::Track >, TrackingParticleCollection, double > >
MuonAssociatorEDProducer::tracksTag
edm::InputTag tracksTag
Definition: MuonAssociatorEDProducer.h:23
edm::ParameterSet::addParameter
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:135
MuonAssociatorEDProducer::ignoreMissingTrackCollection
bool ignoreMissingTrackCollection
Definition: MuonAssociatorEDProducer.h:30
MuonAssociatorByHits::associateSimToReco
virtual reco::SimToRecoCollection associateSimToReco(edm::Handle< edm::View< reco::Track >> &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) const
Definition: MuonAssociatorByHits.h:47
edm::RefVector::push_back
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
edm::RefToBaseVector< reco::Track >
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
MuonAssociatorEDProducer::associatorByHits
MuonAssociatorByHits * associatorByHits
Definition: MuonAssociatorEDProducer.h:32
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
TrackingParticleRef
edm::Ref< TrackingParticleCollection > TrackingParticleRef
Definition: TrackingParticleFwd.h:12
event
Definition: event.py:1
edm::RefVector::size
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
edm::InputTag
Definition: InputTag.h:15
MuonAssociatorEDProducer::tpRefVector
bool tpRefVector
Definition: MuonAssociatorEDProducer.h:29