CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonAssociatorEDProducer.cc
Go to the documentation of this file.
1 #include <memory>
6 
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 }
61 
63 
65  LogTrace("MuonAssociatorEDProducer") << "MuonAssociatorEDProducer::beginJob : constructing MuonAssociatorByHits";
67 }
68 
70 
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 }
T getParameter(std::string const &) const
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.
MuonAssociatorEDProducer(const edm::ParameterSet &)
std::string dump(unsigned int indent=0) const
MuonAssociatorByHits * associatorByHits
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:142
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
#define LogTrace(id)
std::string const & label() const
Definition: InputTag.h:42
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.
volatile std::atomic< bool > shutdown_flag false
std::string const & instance() const
Definition: InputTag.h:43
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
virtual void produce(edm::Event &, const edm::EventSetup &)