CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonTrackValidator.h
Go to the documentation of this file.
1 #ifndef MuonTrackValidator_h
2 #define MuonTrackValidator_h
3 
12 
17 
19  public:
22  dirName_ = pset.getParameter<std::string>("dirName");
23  associatormap = pset.getParameter< edm::InputTag >("associatormap");
24  UseAssociators = pset.getParameter< bool >("UseAssociators");
25  useGEMs_ = pset.getParameter< bool >("useGEMs");
26  useME0_ = pset.getParameter< bool >("useME0");
27  tpSelector = TrackingParticleSelector(pset.getParameter<double>("ptMinTP"),
28  pset.getParameter<double>("minRapidityTP"),
29  pset.getParameter<double>("maxRapidityTP"),
30  pset.getParameter<double>("tipTP"),
31  pset.getParameter<double>("lipTP"),
32  pset.getParameter<int>("minHitTP"),
33  pset.getParameter<bool>("signalOnlyTP"),
34  pset.getParameter<bool>("intimeOnlyTP"),
35  pset.getParameter<bool>("chargedOnlyTP"),
36  pset.getParameter<bool>("stableOnlyTP"),
37  pset.getParameter<std::vector<int> >("pdgIdTP"));
39  pset.getParameter<double>("minRapidityTP"),
40  pset.getParameter<double>("maxRapidityTP"),
41  pset.getParameter<double>("tipTP"),
42  pset.getParameter<double>("lipTP"),
43  pset.getParameter<int>("minHitTP"),
44  pset.getParameter<bool>("chargedOnlyTP"),
45  pset.getParameter<std::vector<int> >("pdgIdTP"));
46 
47  minPhi = pset.getParameter<double>("minPhi");
48  maxPhi = pset.getParameter<double>("maxPhi");
49  nintPhi = pset.getParameter<int>("nintPhi");
50  useGsf = pset.getParameter<bool>("useGsf");
51  BiDirectional_RecoToSim_association = pset.getParameter<bool>("BiDirectional_RecoToSim_association");
52 
53  // dump cfg parameters
54  edm::LogVerbatim("MuonTrackValidator") << "constructing MuonTrackValidator: " << pset.dump();
55 
56  // Declare consumes (also for the base class)
57  bsSrc_Token = consumes<reco::BeamSpot>(bsSrc);
58  tp_effic_Token = consumes<TrackingParticleCollection>(label_tp_effic);
59  tp_fake_Token = consumes<TrackingParticleCollection>(label_tp_fake);
60  for (unsigned int www=0;www<label.size();www++){
62  }
63  simToRecoCollection_Token = consumes<reco::SimToRecoCollection>(associatormap);
64  recoToSimCollection_Token = consumes<reco::RecoToSimCollection>(associatormap);
65 
66  _simHitTpMapTag = mayConsume<SimHitTPAssociationProducer::SimHitTPAssociationList>(pset.getParameter<edm::InputTag>("simHitTpMapTag"));
67 
68  MABH = false;
69  if (!UseAssociators) {
70  // flag MuonAssociatorByHits
71  if (associators[0] == "MuonAssociationByHits") MABH = true;
72  // reset string associators to the map label
73  associators.clear();
74  associators.push_back(associatormap.label());
75  edm::LogVerbatim("MuonTrackValidator") << "--> associators reset to: " <<associators[0];
76  } else {
77  for (auto const& associator :associators) {
78  consumes<reco::TrackToTrackingParticleAssociator>(edm::InputTag(associator));
79  }
80  }
81 
82  // inform on which SimHits will be counted
83  if (usetracker) edm::LogVerbatim("MuonTrackValidator")
84  <<"\n usetracker = TRUE : Tracker SimHits WILL be counted";
85  else edm::LogVerbatim("MuonTrackValidator")
86  <<"\n usetracker = FALSE : Tracker SimHits WILL NOT be counted";
87  if (usemuon) edm::LogVerbatim("MuonTrackValidator")
88  <<" usemuon = TRUE : Muon SimHits WILL be counted";
89  else edm::LogVerbatim("MuonTrackValidator")
90  <<" usemuon = FALSE : Muon SimHits WILL NOT be counted"<<std::endl;
91 
92  // loop over the reco::Track collections to validate: check for inconsistent input settings
93  for (unsigned int www=0;www<label.size();www++) {
94  std::string recoTracksLabel = label[www].label();
95  std::string recoTracksInstance = label[www].instance();
96 
97  // tracks with hits only on tracker
98  if (recoTracksLabel=="generalTracks" ||
99  (recoTracksLabel.find("cutsRecoTracks") != std::string::npos) ||
100  recoTracksLabel=="ctfWithMaterialTracksP5LHCNavigation" ||
101  recoTracksLabel=="hltL3TkTracksFromL2" ||
102  (recoTracksLabel=="hltL3Muons" && recoTracksInstance=="L2Seeded"))
103  {
104  if (usemuon) {
105  edm::LogWarning("MuonTrackValidator")
106  <<"\n*** WARNING : inconsistent input tracksTag = "<<label[www]
107  <<"\n with usemuon == true"<<"\n ---> please change to usemuon == false ";
108  }
109  if (!usetracker) {
110  edm::LogWarning("MuonTrackValidator")
111  <<"\n*** WARNING : inconsistent input tracksTag = "<<label[www]
112  <<"\n with usetracker == false"<<"\n ---> please change to usetracker == true ";
113  }
114  }
115 
116  // tracks with hits only on muon detectors
117  else if (recoTracksLabel=="standAloneMuons" ||
118  recoTracksLabel=="standAloneSETMuons" ||
119  recoTracksLabel=="cosmicMuons" ||
120  recoTracksLabel=="hltL2Muons")
121  {
122  if (usetracker) {
123  edm::LogWarning("MuonTrackValidator")
124  <<"\n*** WARNING : inconsistent input tracksTag = "<<label[www]
125  <<"\n with usetracker == true"<<"\n ---> please change to usetracker == false ";
126  }
127  if (!usemuon) {
128  edm::LogWarning("MuonTrackValidator")
129  <<"\n*** WARNING : inconsistent input tracksTag = "<<label[www]
130  <<"\n with usemuon == false"<<"\n ---> please change to usemuon == true ";
131  }
132  }
133 
134  } // for (unsigned int www=0;www<label.size();www++)
135  }
136 
138  virtual ~MuonTrackValidator(){ }
139 
141  // void beginRun(edm::Run const&, edm::EventSetup const&);
143  void analyze(const edm::Event&, const edm::EventSetup& );
145  void endRun(edm::Run const&, edm::EventSetup const&);
147 
148 private:
150  void getRecoMomentum (const reco::Track& track, double& pt, double& ptError,
151  double& qoverp, double& qoverpError, double& lambda, double& lambdaError,
152  double& phi, double& phiError ) const;
154  void getRecoMomentum (const reco::GsfTrack& gsfTrack, double& pt, double& ptError,
155  double& qoverp, double& qoverpError, double& lambda, double& lambdaError,
156  double& phi, double& phiError) const;
157 
158  private:
164 
166  bool useGEMs_;
167  bool useME0_;
168  double minPhi, maxPhi;
169  int nintPhi;
170  bool useGsf;
171  // select tracking particles
172  //(i.e. "denominator" of the efficiency ratio)
175 
176  // flag new validation logic (bidirectional RecoToSim association)
178  // flag MuonAssociatorByHits
179  bool MABH;
180 
181  //1D
182  std::vector<MonitorElement*> h_nchi2, h_nchi2_prob, h_losthits;
183 
184  //2D
185  std::vector<MonitorElement*> chi2_vs_nhits, etares_vs_eta;
186  std::vector<MonitorElement*> h_ptshifteta;
187  std::vector<MonitorElement*> ptres_vs_phi, chi2_vs_phi, nhits_vs_phi, phires_vs_phi;
188 
189  //Profile2D
190  std::vector<MonitorElement*> ptmean_vs_eta_phi, phimean_vs_eta_phi;
191 
192  //assoc chi2
193  std::vector<MonitorElement*> h_assochi2, h_assochi2_prob;
194 
195  //chi2 and # lost hits vs eta: to be used with doProfileX
196  std::vector<MonitorElement*> chi2_vs_eta, nlosthits_vs_eta;
197  std::vector<MonitorElement*> h_chi2meanh, h_losthits_eta;
198  std::vector<MonitorElement*> h_hits_phi;
199  std::vector<MonitorElement*> h_chi2meanhitsh, h_chi2mean_vs_phi;
200 
201  //resolution of track params: to be used with fitslicesytool
204 
205  //pulls of track params vs eta: to be used with fitslicesytool
207  std::vector<MonitorElement*> ptpull_vs_phi, phipull_vs_phi, thetapull_vs_phi;
209  std::vector<MonitorElement*> h_ptpullphi, h_phipullphi, h_thetapullphi;
210 
211 };
212 
213 
214 #endif
std::vector< MonitorElement * > h_dxypulleta
T getParameter(std::string const &) const
std::vector< MonitorElement * > h_ptpulleta
std::vector< MonitorElement * > etares_vs_eta
std::vector< MonitorElement * > ptres_vs_phi
std::vector< edm::EDGetTokenT< edm::View< reco::Track > > > track_Collection_Token
std::vector< MonitorElement * > h_losthits_eta
std::string dump(unsigned int indent=0) const
std::vector< MonitorElement * > h_thetapullphi
std::vector< MonitorElement * > h_ptpullphi
std::vector< MonitorElement * > ptres_vs_eta
std::vector< MonitorElement * > cotThetares_vs_eta
std::vector< MonitorElement * > h_dzpulleta
std::vector< MonitorElement * > h_thetapulleta
std::vector< MonitorElement * > phimean_vs_eta_phi
virtual ~MuonTrackValidator()
Destructor.
std::vector< MonitorElement * > phires_vs_pt
std::vector< MonitorElement * > h_assochi2_prob
std::vector< MonitorElement * > cotThetares_vs_pt
std::vector< MonitorElement * > h_ptshifteta
std::vector< MonitorElement * > dxyres_vs_eta
std::vector< MonitorElement * > dzres_vs_pt
std::vector< MonitorElement * > dzres_vs_eta
void getRecoMomentum(const reco::Track &track, double &pt, double &ptError, double &qoverp, double &qoverpError, double &lambda, double &lambdaError, double &phi, double &phiError) const
retrieval of reconstructed momentum components from reco::Track (== mean values for GSF) ...
std::vector< MonitorElement * > thetapull_vs_phi
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< SimHitTPAssociationProducer::SimHitTPAssociationList > _simHitTpMapTag
std::vector< MonitorElement * > h_assochi2
std::vector< MonitorElement * > chi2_vs_phi
std::vector< MonitorElement * > h_phipulleta
std::vector< MonitorElement * > chi2_vs_nhits
std::vector< MonitorElement * > phires_vs_phi
std::vector< MonitorElement * > h_chi2mean_vs_phi
std::vector< MonitorElement * > h_phipullphi
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
CosmicTrackingParticleSelector cosmictpSelector
std::vector< MonitorElement * > nhits_vs_phi
edm::EDGetTokenT< TrackingParticleCollection > tp_fake_Token
std::vector< MonitorElement * > dxyres_vs_pt
std::vector< edm::InputTag > label
std::vector< MonitorElement * > h_nchi2
std::vector< MonitorElement * > h_nchi2_prob
std::vector< MonitorElement * > ptpull_vs_eta
std::vector< MonitorElement * > dxypull_vs_eta
void analyze(const edm::Event &, const edm::EventSetup &)
Method called before the event loop.
std::vector< MonitorElement * > phipull_vs_eta
std::vector< MonitorElement * > thetapull_vs_eta
MuonTrackValidator(const edm::ParameterSet &pset)
Constructor.
ObjectSelector< CosmicTrackingParticleSelector > CosmicTrackingParticleSelector
std::vector< MonitorElement * > ptmean_vs_eta_phi
edm::EDGetTokenT< reco::RecoToSimCollection > recoToSimCollection_Token
edm::EDGetTokenT< reco::SimToRecoCollection > simToRecoCollection_Token
std::vector< MonitorElement * > chi2_vs_eta
TrackingParticleSelector tpSelector
std::vector< MonitorElement * > h_losthits
std::vector< MonitorElement * > ptpull_vs_phi
edm::InputTag associatormap
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
std::vector< MonitorElement * > ptres_vs_pt
std::vector< MonitorElement * > h_chi2meanhitsh
std::vector< MonitorElement * > phires_vs_eta
std::vector< MonitorElement * > h_hits_phi
std::vector< std::string > associators
std::vector< MonitorElement * > nlosthits_vs_eta
std::vector< MonitorElement * > dzpull_vs_eta
edm::EDGetTokenT< TrackingParticleCollection > tp_effic_Token
Definition: Run.h:42
std::vector< MonitorElement * > h_chi2meanh
void endRun(edm::Run const &, edm::EventSetup const &)
Method called at the end of the event loop.
std::vector< MonitorElement * > phipull_vs_phi
edm::EDGetTokenT< reco::BeamSpot > bsSrc_Token