CMS 3D CMS Logo

MuonTrackValidator.h
Go to the documentation of this file.
1 #ifndef MuonTrackValidator_h
2 #define MuonTrackValidator_h
3 
11 
15 
18 
23 
25 public:
28  dirName_ = pset.getParameter<std::string>("dirName");
29  associatormap = pset.getParameter<edm::InputTag>("associatormap");
30  UseAssociators = pset.getParameter<bool>("UseAssociators");
31  useGEMs_ = pset.getParameter<bool>("useGEMs");
32  useME0_ = pset.getParameter<bool>("useME0");
33  edm::ParameterSet tpset = pset.getParameter<edm::ParameterSet>("muonTPSelector");
34  tpSelector = TrackingParticleSelector(tpset.getParameter<double>("ptMin"),
35  tpset.getParameter<double>("ptMax"),
36  tpset.getParameter<double>("minRapidity"),
37  tpset.getParameter<double>("maxRapidity"),
38  tpset.getParameter<double>("tip"),
39  tpset.getParameter<double>("lip"),
40  tpset.getParameter<int>("minHit"),
41  tpset.getParameter<bool>("signalOnly"),
42  tpset.getParameter<bool>("intimeOnly"),
43  tpset.getParameter<bool>("chargedOnly"),
44  tpset.getParameter<bool>("stableOnly"),
45  tpset.getParameter<std::vector<int> >("pdgId"));
46 
47  cosmictpSelector = CosmicTrackingParticleSelector(tpset.getParameter<double>("ptMin"),
48  tpset.getParameter<double>("minRapidity"),
49  tpset.getParameter<double>("maxRapidity"),
50  tpset.getParameter<double>("tip"),
51  tpset.getParameter<double>("lip"),
52  tpset.getParameter<int>("minHit"),
53  tpset.getParameter<bool>("chargedOnly"),
54  tpset.getParameter<std::vector<int> >("pdgId"));
55 
56  BiDirectional_RecoToSim_association = pset.getParameter<bool>("BiDirectional_RecoToSim_association");
57 
58  // dump cfg parameters
59  edm::LogVerbatim("MuonTrackValidator") << "constructing MuonTrackValidator: " << pset.dump();
60 
61  // Declare consumes (also for the base class)
62  bsSrc_Token = consumes<reco::BeamSpot>(bsSrc);
64  tp_refvector_Token = consumes<TrackingParticleRefVector>(label_tp);
65  else
66  tp_Token = consumes<TrackingParticleCollection>(label_tp);
67  pileupinfo_Token = consumes<std::vector<PileupSummaryInfo> >(label_pileupinfo);
68  for (unsigned int www = 0; www < label.size(); www++) {
69  track_Collection_Token.push_back(consumes<edm::View<reco::Track> >(label[www]));
70  }
71  simToRecoCollection_Token = consumes<reco::SimToRecoCollection>(associatormap);
72  recoToSimCollection_Token = consumes<reco::RecoToSimCollection>(associatormap);
73 
74  if (parametersDefiner == "LhcParametersDefinerForTP") {
75  lhcParametersDefinerTP_ = std::make_unique<ParametersDefinerForTP>(bsSrc, consumesCollector());
76  } else if (parametersDefiner == "CosmicParametersDefinerForTP") {
77  cosmicParametersDefinerTP_ = std::make_unique<CosmicParametersDefinerForTP>(consumesCollector());
78  } else {
79  throw cms::Exception("Configuration") << "Unexpected label: parametersDefiner = " << parametersDefiner;
80  }
81 
82  _simHitTpMapTag = mayConsume<SimHitTPAssociationProducer::SimHitTPAssociationList>(
83  pset.getParameter<edm::InputTag>("simHitTpMapTag"));
84 
85  MABH = false;
86  if (!UseAssociators) {
87  // flag MuonAssociatorByHits
88  if (associators[0] == "MuonAssociationByHits")
89  MABH = true;
90  // reset string associators to the map label
91  associators.clear();
92  associators.push_back(associatormap.label());
93  edm::LogVerbatim("MuonTrackValidator") << "--> associators reset to: " << associators[0];
94  } else {
95  for (auto const& associator : associators) {
96  consumes<reco::TrackToTrackingParticleAssociator>(edm::InputTag(associator));
97  }
98  }
99 
100  // inform on which SimHits will be counted
101  if (usetracker)
102  edm::LogVerbatim("MuonTrackValidator") << "\n usetracker = TRUE : Tracker SimHits WILL be counted";
103  else
104  edm::LogVerbatim("MuonTrackValidator") << "\n usetracker = FALSE : Tracker SimHits WILL NOT be counted";
105  if (usemuon)
106  edm::LogVerbatim("MuonTrackValidator") << " usemuon = TRUE : Muon SimHits WILL be counted";
107  else
108  edm::LogVerbatim("MuonTrackValidator") << " usemuon = FALSE : Muon SimHits WILL NOT be counted" << std::endl;
109 
110  // loop over the reco::Track collections to validate: check for inconsistent input settings
111  for (unsigned int www = 0; www < label.size(); www++) {
112  std::string recoTracksLabel = label[www].label();
113  std::string recoTracksInstance = label[www].instance();
114 
115  // tracks with hits only on tracker
116  if (recoTracksLabel == "generalTracks" || recoTracksLabel == "probeTracks" ||
117  recoTracksLabel == "displacedTracks" || recoTracksLabel == "extractGemMuons" ||
118  recoTracksLabel == "extractMe0Muons" || recoTracksLabel == "ctfWithMaterialTracksP5LHCNavigation" ||
119  recoTracksLabel == "ctfWithMaterialTracksP5" ||
120  recoTracksLabel == "hltIterL3OIMuonTrackSelectionHighPurity" || recoTracksLabel == "hltIterL3MuonMerged" ||
121  recoTracksLabel == "hltIterL3MuonAndMuonFromL1Merged") {
122  if (usemuon) {
123  edm::LogWarning("MuonTrackValidator")
124  << "\n*** WARNING : inconsistent input tracksTag = " << label[www] << "\n with usemuon == true"
125  << "\n ---> resetting to usemuon == false ";
126  usemuon = false;
127  }
128  if (!usetracker) {
129  edm::LogWarning("MuonTrackValidator")
130  << "\n*** WARNING : inconsistent input tracksTag = " << label[www] << "\n with usetracker == false"
131  << "\n ---> resetting to usetracker == true ";
132  usetracker = true;
133  }
134  }
135 
136  // tracks with hits only on muon detectors
137  else if (recoTracksLabel == "seedsOfSTAmuons" || recoTracksLabel == "standAloneMuons" ||
138  recoTracksLabel == "seedsOfDisplacedSTAmuons" || recoTracksLabel == "displacedStandAloneMuons" ||
139  recoTracksLabel == "refittedStandAloneMuons" || recoTracksLabel == "cosmicMuons" ||
140  recoTracksLabel == "cosmicMuons1Leg" || recoTracksLabel == "hltL2Muons") {
141  if (usetracker) {
142  edm::LogWarning("MuonTrackValidator")
143  << "\n*** WARNING : inconsistent input tracksTag = " << label[www] << "\n with usetracker == true"
144  << "\n ---> resetting to usetracker == false ";
145  usetracker = false;
146  }
147  if (!usemuon) {
148  edm::LogWarning("MuonTrackValidator")
149  << "\n*** WARNING : inconsistent input tracksTag = " << label[www] << "\n with usemuon == false"
150  << "\n ---> resetting to usemuon == true ";
151  usemuon = true;
152  }
153  }
154 
155  } // for (unsigned int www=0;www<label.size();www++)
156  }
157 
159  ~MuonTrackValidator() override {}
160 
161  void analyze(const edm::Event&, const edm::EventSetup&) override;
163 
164 private:
170 
171  std::unique_ptr<ParametersDefinerForTP> lhcParametersDefinerTP_;
172  std::unique_ptr<CosmicParametersDefinerForTP> cosmicParametersDefinerTP_;
173 
175  bool useGEMs_;
176  bool useME0_;
177 
178  // select tracking particles
179  //(i.e. "denominator" of the efficiency ratio)
182 
183  // flag new validation logic (bidirectional RecoToSim association)
185  // flag MuonAssociatorByHits
186  bool MABH;
187 };
188 
189 #endif
Log< level::Info, true > LogVerbatim
edm::EDGetTokenT< TrackingParticleRefVector > tp_refvector_Token
std::unique_ptr< CosmicParametersDefinerForTP > cosmicParametersDefinerTP_
std::vector< edm::EDGetTokenT< edm::View< reco::Track > > > track_Collection_Token
std::unique_ptr< ParametersDefinerForTP > lhcParametersDefinerTP_
std::string const & label() const
Definition: InputTag.h:36
edm::EDGetTokenT< SimHitTPAssociationProducer::SimHitTPAssociationList > _simHitTpMapTag
CosmicTrackingParticleSelector cosmictpSelector
std::vector< edm::InputTag > label
~MuonTrackValidator() override
Destructor.
MuonTrackValidator(const edm::ParameterSet &pset)
Constructor.
ObjectSelector< CosmicTrackingParticleSelector > CosmicTrackingParticleSelector
edm::EDGetTokenT< reco::RecoToSimCollection > recoToSimCollection_Token
edm::EDGetTokenT< TrackingParticleCollection > tp_Token
edm::EDGetTokenT< reco::SimToRecoCollection > simToRecoCollection_Token
TrackingParticleSelector tpSelector
void bookHistograms(DQMEDAnalyzer::DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
edm::InputTag associatormap
void analyze(const edm::Event &, const edm::EventSetup &) override
Log< level::Warning, false > LogWarning
std::vector< std::string > associators
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupinfo_Token
SingleObjectSelector< TrackingParticleCollection, ::TrackingParticleSelector > TrackingParticleSelector
Definition: Run.h:45
edm::EDGetTokenT< reco::BeamSpot > bsSrc_Token