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::ProductRegistryHelper

Public Member Functions

 MuonAssociatorEDProducer (const edm::ParameterSet &)
 
 ~MuonAssociatorEDProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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::InputTag tracksTag
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 12 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(), edm::ParameterSet::dump(), edm::ParameterSet::getParameter(), edm::InputTag::instance(), edm::InputTag::label(), LogTrace, parset_, tpTag, and tracksTag.

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 
19  edm::LogVerbatim("MuonAssociatorByHits") << "constructing MuonAssociatorByHits" << parset_.dump();
20  edm::LogVerbatim("MuonAssociatorByHits") << "\n MuonAssociatorByHits will associate reco::Tracks with "<<tracksTag
21  << "\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("MuonAssociatorByHits")
31  <<"\n*** WARNING : inconsistent input tracksTag = "<<tracksTag
32  <<"\n with UseTracker = true"<<"\n ---> setting UseTracker = false ";
33  parset_.addParameter<bool>("UseTracker",false);
34  }
35  if (!parset_.getParameter<bool>("UseMuon")) {
36  edm::LogWarning("MuonAssociatorByHits")
37  <<"\n*** WARNING : inconsistent input tracksTag = "<<tracksTag
38  <<"\n with UseMuon = false"<<"\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("MuonAssociatorByHits")
48  <<"\n*** WARNING : inconsistent input tracksTag = "<<tracksTag
49  <<"\n with UseMuon = true"<<"\n ---> setting UseMuon = false ";
50  parset_.addParameter<bool>("UseMuon",false);
51  }
52  if (!parset_.getParameter<bool>("UseTracker")) {
53  edm::LogWarning("MuonAssociatorByHits")
54  <<"\n*** WARNING : inconsistent input tracksTag = "<<tracksTag
55  <<"\n with UseTracker = false"<<"\n ---> setting UseTracker = true ";
56  parset_.addParameter<bool>("UseTracker",true);
57  }
58  }
59 
60 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:145
#define LogTrace(id)
std::string const & label() const
Definition: InputTag.h:25
std::string const & instance() const
Definition: InputTag.h:26
std::string dump() const
MuonAssociatorEDProducer::~MuonAssociatorEDProducer ( )

Definition at line 62 of file MuonAssociatorEDProducer.cc.

62 {}

Member Function Documentation

void MuonAssociatorEDProducer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 64 of file MuonAssociatorEDProducer.cc.

References associatorByHits, LogTrace, and parset_.

64  {
65  LogTrace("MuonAssociatorEDProducer") << "MuonAssociatorEDProducer::beginJob : constructing MuonAssociatorByHits";
67 }
MuonAssociatorByHits * associatorByHits
#define LogTrace(id)
void MuonAssociatorEDProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 69 of file MuonAssociatorEDProducer.cc.

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

Implements edm::EDProducer.

Definition at line 71 of file MuonAssociatorEDProducer.cc.

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

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

Member Data Documentation

MuonAssociatorByHits* MuonAssociatorEDProducer::associatorByHits
private

Definition at line 26 of file MuonAssociatorEDProducer.h.

Referenced by beginJob(), and produce().

bool MuonAssociatorEDProducer::ignoreMissingTrackCollection
private

Definition at line 24 of file MuonAssociatorEDProducer.h.

Referenced by produce().

edm::ParameterSet MuonAssociatorEDProducer::parset_
private

Definition at line 25 of file MuonAssociatorEDProducer.h.

Referenced by beginJob(), and MuonAssociatorEDProducer().

edm::InputTag MuonAssociatorEDProducer::tpTag
private

Definition at line 23 of file MuonAssociatorEDProducer.h.

Referenced by MuonAssociatorEDProducer(), and produce().

edm::InputTag MuonAssociatorEDProducer::tracksTag
private

Definition at line 22 of file MuonAssociatorEDProducer.h.

Referenced by MuonAssociatorEDProducer(), and produce().