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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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_
 
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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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  ignoreMissingTrackCollection(parset.getUntrackedParameter<bool>("ignoreMissingTrackCollection", false)),
11  parset_(parset) {
12  edm::LogVerbatim("MuonAssociatorEDProducer") << "constructing MuonAssociatorEDProducer";
13  produces<reco::RecoToSimCollection>();
14  produces<reco::SimToRecoCollection>();
15  tpToken_ = consumes<TrackingParticleCollection>(tpTag);
16  tracksToken_ = consumes<edm::View<reco::Track>>(tracksTag);
17 
19  LogTrace("MuonAssociatorEDProducer") << "constructing MuonAssociatorByHits" << parset_.dump();
20  edm::LogVerbatim("MuonAssociatorEDProducer") << "\n MuonAssociatorByHits will associate reco::Tracks with "
21  << tracksTag << "\n\t\t and TrackingParticles with " << tpTag;
22  const std::string recoTracksLabel = tracksTag.label();
23  const std::string recoTracksInstance = tracksTag.instance();
24 
25  // check and fix inconsistent input settings
26  // tracks with hits only on muon detectors
27  if (recoTracksLabel == "standAloneMuons" || recoTracksLabel == "standAloneSETMuons" ||
28  recoTracksLabel == "cosmicMuons" || recoTracksLabel == "hltL2Muons") {
29  if (parset_.getParameter<bool>("UseTracker")) {
30  edm::LogWarning("MuonAssociatorEDProducer")
31  << "\n*** WARNING : inconsistent input tracksTag = " << tracksTag << "\n with UseTracker = true"
32  << "\n ---> setting UseTracker = false ";
33  parset_.addParameter<bool>("UseTracker", false);
34  }
35  if (!parset_.getParameter<bool>("UseMuon")) {
36  edm::LogWarning("MuonAssociatorEDProducer")
37  << "\n*** WARNING : inconsistent input tracksTag = " << tracksTag << "\n with UseMuon = false"
38  << "\n ---> setting UseMuon = true ";
39  parset_.addParameter<bool>("UseMuon", true);
40  }
41  }
42  // tracks with hits only on tracker
43  if (recoTracksLabel == "generalTracks" || recoTracksLabel == "ctfWithMaterialTracksP5LHCNavigation" ||
44  recoTracksLabel == "hltL3TkTracksFromL2" ||
45  (recoTracksLabel == "hltL3Muons" && recoTracksInstance == "L2Seeded")) {
46  if (parset_.getParameter<bool>("UseMuon")) {
47  edm::LogWarning("MuonAssociatorEDProducer")
48  << "\n*** WARNING : inconsistent input tracksTag = " << tracksTag << "\n with UseMuon = true"
49  << "\n ---> setting UseMuon = false ";
50  parset_.addParameter<bool>("UseMuon", false);
51  }
52  if (!parset_.getParameter<bool>("UseTracker")) {
53  edm::LogWarning("MuonAssociatorEDProducer")
54  << "\n*** WARNING : inconsistent input tracksTag = " << tracksTag << "\n with UseTracker = false"
55  << "\n ---> setting UseTracker = true ";
56  parset_.addParameter<bool>("UseTracker", true);
57  }
58  }
59 
60  LogTrace("MuonAssociatorEDProducer") << "MuonAssociatorEDProducer::beginJob "
61  ": constructing MuonAssociatorByHits";
62  associatorByHits = new MuonAssociatorByHits(parset_, consumesCollector());
63 }

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

◆ ~MuonAssociatorEDProducer()

MuonAssociatorEDProducer::~MuonAssociatorEDProducer ( )
override

Definition at line 65 of file MuonAssociatorEDProducer.cc.

65 {}

Member Function Documentation

◆ beginJob()

void MuonAssociatorEDProducer::beginJob ( void  )
privatevirtual

Definition at line 67 of file MuonAssociatorEDProducer.cc.

67 {}

◆ endJob()

void MuonAssociatorEDProducer::endJob ( void  )
privatevirtual

Definition at line 69 of file MuonAssociatorEDProducer.cc.

69 {}

◆ produce()

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

Definition at line 71 of file MuonAssociatorEDProducer.cc.

71  {
72  using namespace edm;
73 
75  LogTrace("MuonAssociatorEDProducer") << "getting TrackingParticle collection - " << tpTag;
76  event.getByToken(tpToken_, TPCollection);
77  LogTrace("MuonAssociatorEDProducer") << "\t... size = " << TPCollection->size();
78 
80  LogTrace("MuonAssociatorEDProducer") << "getting reco::Track collection - " << tracksTag;
81  bool trackAvailable = event.getByToken(tracksToken_, trackCollection);
82  if (trackAvailable)
83  LogTrace("MuonAssociatorEDProducer") << "\t... size = " << trackCollection->size();
84  else
85  LogTrace("MuonAssociatorEDProducer") << "\t... NOT FOUND.";
86 
87  std::unique_ptr<reco::RecoToSimCollection> rts;
88  std::unique_ptr<reco::SimToRecoCollection> str;
89 
90  if (ignoreMissingTrackCollection && !trackAvailable) {
91  // the track collection is not in the event and we're being told to ignore
92  // this. do not output anything to the event, other wise this would be
93  // considered as inefficiency.
94  LogTrace("MuonAssociatorEDProducer") << "\n ignoring missing track collection."
95  << "\n";
96  } else {
97  edm::LogVerbatim("MuonAssociatorEDProducer")
98  << "\n >>> RecoToSim association <<< \n"
99  << " Track collection : " << tracksTag.label() << ":" << tracksTag.instance()
100  << " (size = " << trackCollection->size() << ") \n"
101  << " TrackingParticle collection : " << tpTag.label() << ":" << tpTag.instance()
102  << " (size = " << TPCollection->size() << ")";
103 
104  reco::RecoToSimCollection recSimColl =
106 
107  edm::LogVerbatim("MuonAssociatorEDProducer")
108  << "\n >>> SimToReco association <<< \n"
109  << " TrackingParticle collection : " << tpTag.label() << ":" << tpTag.instance()
110  << " (size = " << TPCollection->size() << ") \n"
111  << " Track collection : " << tracksTag.label() << ":" << tracksTag.instance()
112  << " (size = " << trackCollection->size() << ")";
113 
114  reco::SimToRecoCollection simRecColl =
116 
117  rts = std::make_unique<reco::RecoToSimCollection>(recSimColl);
118  str = std::make_unique<reco::SimToRecoCollection>(simRecColl);
119 
120  event.put(std::move(rts));
121  event.put(std::move(str));
122  }
123 }

References MuonAssociatorByHits::associateRecoToSim(), MuonAssociatorByHits::associateSimToReco(), associatorByHits, ignoreMissingTrackCollection, edm::InputTag::instance(), edm::InputTag::label(), LogTrace, eostools::move(), singleTopDQM_cfi::setup, str, tpTag, tpToken_, duplicaterechits_cfi::trackCollection, tracksTag, and tracksToken_.

Member Data Documentation

◆ associatorByHits

MuonAssociatorByHits* MuonAssociatorEDProducer::associatorByHits
private

Definition at line 30 of file MuonAssociatorEDProducer.h.

Referenced by MuonAssociatorEDProducer(), and produce().

◆ ignoreMissingTrackCollection

bool MuonAssociatorEDProducer::ignoreMissingTrackCollection
private

Definition at line 28 of file MuonAssociatorEDProducer.h.

Referenced by produce().

◆ parset_

edm::ParameterSet MuonAssociatorEDProducer::parset_
private

Definition at line 29 of file MuonAssociatorEDProducer.h.

Referenced by MuonAssociatorEDProducer().

◆ 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 26 of file MuonAssociatorEDProducer.h.

Referenced by MuonAssociatorEDProducer(), and produce().

MuonAssociatorEDProducer::tpToken_
edm::EDGetTokenT< TrackingParticleCollection > tpToken_
Definition: MuonAssociatorEDProducer.h:25
edm::InputTag::instance
std::string const & instance() const
Definition: InputTag.h:37
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
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:26
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
edm::ParameterSet::dump
std::string dump(unsigned int indent=0) const
Definition: ParameterSet.cc:832
str
#define str(s)
Definition: TestProcessor.cc:51
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
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MuonAssociatorEDProducer::parset_
edm::ParameterSet parset_
Definition: MuonAssociatorEDProducer.h:29
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:28
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
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:30
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
event
Definition: event.py:1
edm::InputTag
Definition: InputTag.h:15