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

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

66 {}

Member Function Documentation

void MuonAssociatorEDProducer::beginJob ( void  )
privatevirtual

Definition at line 68 of file MuonAssociatorEDProducer.cc.

68  {
69 }
void MuonAssociatorEDProducer::endJob ( void  )
privatevirtual

Definition at line 71 of file MuonAssociatorEDProducer.cc.

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

Definition at line 73 of file MuonAssociatorEDProducer.cc.

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

73  {
74  using namespace edm;
75 
77  LogTrace("MuonAssociatorEDProducer") <<"getting TrackingParticle collection - "<<tpTag;
78  event.getByToken(tpToken_, TPCollection);
79  LogTrace("MuonAssociatorEDProducer") <<"\t... size = "<<TPCollection->size();
80 
82  LogTrace("MuonAssociatorEDProducer") <<"getting reco::Track collection - "<<tracksTag;
83  bool trackAvailable = event.getByToken (tracksToken_, trackCollection);
84  if (trackAvailable) LogTrace("MuonAssociatorEDProducer") <<"\t... size = "<<trackCollection->size();
85  else 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 this.
92  //do not output anything to the event, other wise this would be considered as inefficiency.
93  LogTrace("MuonAssociatorEDProducer") << "\n ignoring missing track collection." << "\n";
94  }
95  else {
96  edm::LogVerbatim("MuonAssociatorEDProducer")
97  <<"\n >>> RecoToSim association <<< \n"
98  <<" Track collection : "
99  <<tracksTag.label()<<":"<<tracksTag.instance()<<" (size = "<<trackCollection->size()<<") \n"
100  <<" TrackingParticle collection : "
101  <<tpTag.label()<<":"<<tpTag.instance()<<" (size = "<<TPCollection->size()<<")";
102 
103  reco::RecoToSimCollection recSimColl = associatorByHits->associateRecoToSim(trackCollection,TPCollection,&event,&setup);
104 
105  edm::LogVerbatim("MuonAssociatorEDProducer")
106  <<"\n >>> SimToReco association <<< \n"
107  <<" TrackingParticle collection : "
108  <<tpTag.label()<<":"<<tpTag.instance()<<" (size = "<<TPCollection->size()<<") \n"
109  <<" Track collection : "
110  <<tracksTag.label()<<":"<<tracksTag.instance()<<" (size = "<<trackCollection->size()<<")";
111 
112  reco::SimToRecoCollection simRecColl = associatorByHits->associateSimToReco(trackCollection,TPCollection,&event,&setup);
113 
114  rts.reset(new reco::RecoToSimCollection(recSimColl));
115  str.reset(new reco::SimToRecoCollection(simRecColl));
116 
117  event.put(std::move(rts));
118  event.put(std::move(str));
119  }
120 }
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
std::string const & instance() const
Definition: InputTag.h:37
def move(src, dest)
Definition: eostools.py:510

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