CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuonAssociatorEDProducer Class Reference

#include <MuonAssociatorEDProducer.h>

Inheritance diagram for MuonAssociatorEDProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 MuonAssociatorEDProducer (const edm::ParameterSet &)
 
 ~MuonAssociatorEDProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

Private Attributes

MuonAssociatorByHitsassociatorByHits
 
bool ignoreMissingTrackCollection
 
edm::ParameterSet parset_
 
edm::InputTag tpTag
 
edm::EDGetTokenT
< TrackingParticleCollection
tpToken_
 
edm::InputTag tracksTag
 
edm::EDGetTokenT< edm::View
< reco::Track > > 
tracksToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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::EDConsumerBase::consumesCollector(), 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  LogTrace("MuonAssociatorEDProducer") << "constructing MuonAssociatorEDProducer" << parset_.dump();
15  produces<reco::RecoToSimCollection>();
16  produces<reco::SimToRecoCollection>();
17  tpToken_=consumes<TrackingParticleCollection>(tpTag);
18  tracksToken_=consumes<edm::View<reco::Track> >(tracksTag);
19 
21  edm::LogVerbatim("MuonAssociatorByHits") << "constructing MuonAssociatorByHits" << parset_.dump();
22  edm::LogVerbatim("MuonAssociatorByHits") << "\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("MuonAssociatorByHits")
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("MuonAssociatorByHits")
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("MuonAssociatorByHits")
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("MuonAssociatorByHits")
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";
64 
65 
66 }
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
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:142
#define LogTrace(id)
std::string const & label() const
Definition: InputTag.h:42
edm::EDGetTokenT< edm::View< reco::Track > > tracksToken_
std::string const & instance() const
Definition: InputTag.h:43
MuonAssociatorEDProducer::~MuonAssociatorEDProducer ( )

Definition at line 68 of file MuonAssociatorEDProducer.cc.

68 {}

Member Function Documentation

void MuonAssociatorEDProducer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 70 of file MuonAssociatorEDProducer.cc.

70  {
71 }
void MuonAssociatorEDProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 73 of file MuonAssociatorEDProducer.cc.

73 {}
void MuonAssociatorEDProducer::produce ( edm::Event event,
const edm::EventSetup setup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 75 of file MuonAssociatorEDProducer.cc.

References MuonAssociatorByHits::associateRecoToSim(), MuonAssociatorByHits::associateSimToReco(), associatorByHits, ignoreMissingTrackCollection, edm::InputTag::instance(), edm::InputTag::label(), LogTrace, ecalTPGAnalyzer_cfg::TPCollection, tpTag, tpToken_, tracksTag, and tracksToken_.

75  {
76  using namespace edm;
77 
79  LogTrace("MuonAssociatorEDProducer") <<"getting TrackingParticle collection - "<<tpTag;
80  event.getByToken(tpToken_, TPCollection);
81  LogTrace("MuonAssociatorEDProducer") <<"\t... size = "<<TPCollection->size();
82 
83  Handle<edm::View<reco::Track> > trackCollection;
84  LogTrace("MuonAssociatorEDProducer") <<"getting reco::Track collection - "<<tracksTag;
85  bool trackAvailable = event.getByToken (tracksToken_, trackCollection);
86  if (trackAvailable) LogTrace("MuonAssociatorEDProducer") <<"\t... size = "<<trackCollection->size();
87  else LogTrace("MuonAssociatorEDProducer") <<"\t... NOT FOUND.";
88 
89  std::auto_ptr<reco::RecoToSimCollection> rts;
90  std::auto_ptr<reco::SimToRecoCollection> str;
91 
92  if (ignoreMissingTrackCollection && !trackAvailable) {
93  //the track collection is not in the event and we're being told to ignore this.
94  //do not output anything to the event, other wise this would be considered as inefficiency.
95  LogTrace("MuonAssociatorEDProducer") << "\n ignoring missing track collection." << "\n";
96  }
97  else {
98  edm::LogVerbatim("MuonAssociatorEDProducer")
99  <<"\n >>> RecoToSim association <<< \n"
100  <<" Track collection : "
101  <<tracksTag.label()<<":"<<tracksTag.instance()<<" (size = "<<trackCollection->size()<<") \n"
102  <<" TrackingParticle collection : "
103  <<tpTag.label()<<":"<<tpTag.instance()<<" (size = "<<TPCollection->size()<<")";
104 
105  reco::RecoToSimCollection recSimColl = associatorByHits->associateRecoToSim(trackCollection,TPCollection,&event,&setup);
106 
107  edm::LogVerbatim("MuonAssociatorEDProducer")
108  <<"\n >>> SimToReco association <<< \n"
109  <<" TrackingParticle collection : "
110  <<tpTag.label()<<":"<<tpTag.instance()<<" (size = "<<TPCollection->size()<<") \n"
111  <<" Track collection : "
112  <<tracksTag.label()<<":"<<tracksTag.instance()<<" (size = "<<trackCollection->size()<<")";
113 
114  reco::SimToRecoCollection simRecColl = associatorByHits->associateSimToReco(trackCollection,TPCollection,&event,&setup);
115 
116  rts.reset(new reco::RecoToSimCollection(recSimColl));
117  str.reset(new reco::SimToRecoCollection(simRecColl));
118 
119  event.put(rts);
120  event.put(str);
121  }
122 }
edm::EDGetTokenT< TrackingParticleCollection > tpToken_
reco::RecoToSimCollection associateRecoToSim(const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< TrackingParticleCollection > &, const edm::Event *event=0, const edm::EventSetup *setup=0) const
Association Reco To Sim with Collections.
MuonAssociatorByHits * associatorByHits
#define LogTrace(id)
std::string const & label() const
Definition: InputTag.h:42
edm::EDGetTokenT< edm::View< reco::Track > > tracksToken_
reco::SimToRecoCollection associateSimToReco(const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< TrackingParticleCollection > &, const edm::Event *event=0, const edm::EventSetup *setup=0) const
Association Sim To Reco with Collections.
std::string const & instance() const
Definition: InputTag.h:43

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