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.

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_.

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 }
Log< level::Info, true > LogVerbatim
edm::EDGetTokenT< TrackingParticleCollection > tpToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< TrackingParticleRefVector > tpRefVectorToken_
std::string const & label() const
Definition: InputTag.h:36
MuonAssociatorByHits * associatorByHits
#define LogTrace(id)
T getUntrackedParameter(std::string const &, T const &) const
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:135
edm::EDGetTokenT< edm::View< reco::Track > > tracksToken_
std::string dump(unsigned int indent=0) const
Log< level::Warning, false > LogWarning

◆ ~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.

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_.

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 }
Log< level::Info, true > LogVerbatim
edm::EDGetTokenT< TrackingParticleCollection > tpToken_
reco::RecoToSimCollection associateRecoToSim(edm::Handle< edm::View< reco::Track >> &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) const
edm::EDGetTokenT< TrackingParticleRefVector > tpRefVectorToken_
std::string const & instance() const
Definition: InputTag.h:37
T const * product() const
Definition: Handle.h:70
std::string const & label() const
Definition: InputTag.h:36
MuonAssociatorByHits * associatorByHits
virtual reco::SimToRecoCollection associateSimToReco(edm::Handle< edm::View< reco::Track >> &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) const
#define LogTrace(id)
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
edm::EDGetTokenT< edm::View< reco::Track > > tracksToken_
HLT enums.
void push_back(const RefToBase< T > &)
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
#define str(s)
edm::Ref< TrackingParticleCollection > TrackingParticleRef
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1

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