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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 ( 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::instance(), edm::InputTag::label(), LogTrace, parset_, AlCaHLTBitMon_QueryRunRegistry::string, tpTag, tpToken_, tracksTag, and tracksToken_.

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 }
T getParameter(std::string const &) const
edm::EDGetTokenT< TrackingParticleCollection > tpToken_
T getUntrackedParameter(std::string const &, T const &) const
std::string dump(unsigned int indent=0) const
MuonAssociatorByHits * associatorByHits
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:125
#define LogTrace(id)
std::string const & label() const
Definition: InputTag.h:36
edm::EDGetTokenT< edm::View< reco::Track > > tracksToken_
std::string const & instance() const
Definition: InputTag.h:37
MuonAssociatorEDProducer::~MuonAssociatorEDProducer ( )
override

Definition at line 65 of file MuonAssociatorEDProducer.cc.

65 {}

Member Function Documentation

void MuonAssociatorEDProducer::beginJob ( void  )
privatevirtual

Definition at line 67 of file MuonAssociatorEDProducer.cc.

67 {}
void MuonAssociatorEDProducer::endJob ( void  )
privatevirtual

Definition at line 69 of file MuonAssociatorEDProducer.cc.

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

Definition at line 71 of file MuonAssociatorEDProducer.cc.

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

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 =
105  associatorByHits->associateRecoToSim(trackCollection, TPCollection, &event, &setup);
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 =
115  associatorByHits->associateSimToReco(trackCollection, TPCollection, &event, &setup);
116 
117  rts.reset(new reco::RecoToSimCollection(recSimColl));
118  str.reset(new reco::SimToRecoCollection(simRecColl));
119 
120  event.put(std::move(rts));
121  event.put(std::move(str));
122  }
123 }
edm::EDGetTokenT< TrackingParticleCollection > tpToken_
MuonAssociatorByHits * associatorByHits
#define LogTrace(id)
reco::RecoToSimCollection associateRecoToSim(edm::Handle< edm::View< reco::Track >> &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) const
std::string const & label() const
Definition: InputTag.h:36
edm::EDGetTokenT< edm::View< reco::Track > > tracksToken_
HLT enums.
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 str(s)
std::string const & instance() const
Definition: InputTag.h:37
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

MuonAssociatorByHits* MuonAssociatorEDProducer::associatorByHits
private

Definition at line 30 of file MuonAssociatorEDProducer.h.

Referenced by MuonAssociatorEDProducer(), and produce().

bool MuonAssociatorEDProducer::ignoreMissingTrackCollection
private

Definition at line 28 of file MuonAssociatorEDProducer.h.

Referenced by produce().

edm::ParameterSet MuonAssociatorEDProducer::parset_
private

Definition at line 29 of file MuonAssociatorEDProducer.h.

Referenced by MuonAssociatorEDProducer().

edm::InputTag MuonAssociatorEDProducer::tpTag
private

Definition at line 24 of file MuonAssociatorEDProducer.h.

Referenced by MuonAssociatorEDProducer(), and produce().

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

Definition at line 25 of file MuonAssociatorEDProducer.h.

Referenced by MuonAssociatorEDProducer(), and produce().

edm::InputTag MuonAssociatorEDProducer::tracksTag
private

Definition at line 23 of file MuonAssociatorEDProducer.h.

Referenced by MuonAssociatorEDProducer(), and produce().

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

Definition at line 26 of file MuonAssociatorEDProducer.h.

Referenced by MuonAssociatorEDProducer(), and produce().