CMS 3D CMS Logo

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