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 
11 
15 
17  public:
20  dirName_ = pset.getParameter<std::string>("dirName");
21  associatormap = pset.getParameter< edm::InputTag >("associatormap");
22  UseAssociators = pset.getParameter< bool >("UseAssociators");
23  tpSelector = TrackingParticleSelector(pset.getParameter<double>("ptMinTP"),
24  pset.getParameter<double>("minRapidityTP"),
25  pset.getParameter<double>("maxRapidityTP"),
26  pset.getParameter<double>("tipTP"),
27  pset.getParameter<double>("lipTP"),
28  pset.getParameter<int>("minHitTP"),
29  pset.getParameter<bool>("signalOnlyTP"),
30  pset.getParameter<bool>("chargedOnlyTP"),
31  pset.getParameter<bool>("stableOnlyTP"),
32  pset.getParameter<std::vector<int> >("pdgIdTP"));
34  pset.getParameter<double>("minRapidityTP"),
35  pset.getParameter<double>("maxRapidityTP"),
36  pset.getParameter<double>("tipTP"),
37  pset.getParameter<double>("lipTP"),
38  pset.getParameter<int>("minHitTP"),
39  pset.getParameter<bool>("chargedOnlyTP"),
40  pset.getParameter<std::vector<int> >("pdgIdTP"));
41 
42  minPhi = pset.getParameter<double>("minPhi");
43  maxPhi = pset.getParameter<double>("maxPhi");
44  nintPhi = pset.getParameter<int>("nintPhi");
45  useGsf = pset.getParameter<bool>("useGsf");
46  BiDirectional_RecoToSim_association = pset.getParameter<bool>("BiDirectional_RecoToSim_association");
47 
48  // dump cfg parameters
49  edm::LogVerbatim("MuonTrackValidator") << "constructing MuonTrackValidator: " << pset.dump();
50 
51  // Declare consumes (also for the base class)
52  bsSrc_Token = consumes<reco::BeamSpot>(bsSrc);
53  tp_effic_Token = consumes<TrackingParticleCollection>(label_tp_effic);
54  tp_fake_Token = consumes<TrackingParticleCollection>(label_tp_fake);
55  for (unsigned int www=0;www<label.size();www++){
57  }
58  simToRecoCollection_Token = consumes<reco::SimToRecoCollection>(associatormap);
59  recoToSimCollection_Token = consumes<reco::RecoToSimCollection>(associatormap);
60 
61  MABH = false;
62  if (!UseAssociators) {
63  // flag MuonAssociatorByHits
64  if (associators[0] == "MuonAssociationByHits") MABH = true;
65  // reset string associators to the map label
66  associators.clear();
67  associators.push_back(associatormap.label());
68  edm::LogVerbatim("MuonTrackValidator") << "--> associators reset to: " <<associators[0];
69  }
70 
71  // inform on which SimHits will be counted
72  if (usetracker) edm::LogVerbatim("MuonTrackValidator")
73  <<"\n usetracker = TRUE : Tracker SimHits WILL be counted";
74  else edm::LogVerbatim("MuonTrackValidator")
75  <<"\n usetracker = FALSE : Tracker SimHits WILL NOT be counted";
76  if (usemuon) edm::LogVerbatim("MuonTrackValidator")
77  <<" usemuon = TRUE : Muon SimHits WILL be counted";
78  else edm::LogVerbatim("MuonTrackValidator")
79  <<" usemuon = FALSE : Muon SimHits WILL NOT be counted"<<std::endl;
80 
81  // loop over the reco::Track collections to validate: check for inconsistent input settings
82  for (unsigned int www=0;www<label.size();www++) {
83  std::string recoTracksLabel = label[www].label();
84  std::string recoTracksInstance = label[www].instance();
85 
86  // tracks with hits only on tracker
87  if (recoTracksLabel=="generalTracks" ||
88  (recoTracksLabel.find("cutsRecoTracks") != std::string::npos) ||
89  recoTracksLabel=="ctfWithMaterialTracksP5LHCNavigation" ||
90  recoTracksLabel=="hltL3TkTracksFromL2" ||
91  (recoTracksLabel=="hltL3Muons" && recoTracksInstance=="L2Seeded"))
92  {
93  if (usemuon) {
94  edm::LogWarning("MuonTrackValidator")
95  <<"\n*** WARNING : inconsistent input tracksTag = "<<label[www]
96  <<"\n with usemuon == true"<<"\n ---> please change to usemuon == false ";
97  }
98  if (!usetracker) {
99  edm::LogWarning("MuonTrackValidator")
100  <<"\n*** WARNING : inconsistent input tracksTag = "<<label[www]
101  <<"\n with usetracker == false"<<"\n ---> please change to usetracker == true ";
102  }
103  }
104 
105  // tracks with hits only on muon detectors
106  else if (recoTracksLabel=="standAloneMuons" ||
107  recoTracksLabel=="standAloneSETMuons" ||
108  recoTracksLabel=="cosmicMuons" ||
109  recoTracksLabel=="hltL2Muons")
110  {
111  if (usetracker) {
112  edm::LogWarning("MuonTrackValidator")
113  <<"\n*** WARNING : inconsistent input tracksTag = "<<label[www]
114  <<"\n with usetracker == true"<<"\n ---> please change to usetracker == false ";
115  }
116  if (!usemuon) {
117  edm::LogWarning("MuonTrackValidator")
118  <<"\n*** WARNING : inconsistent input tracksTag = "<<label[www]
119  <<"\n with usemuon == false"<<"\n ---> please change to usemuon == true ";
120  }
121  }
122 
123  } // for (unsigned int www=0;www<label.size();www++)
124  }
125 
127  virtual ~MuonTrackValidator(){ }
128 
130  void beginRun(edm::Run const&, edm::EventSetup const&);
132  void analyze(const edm::Event&, const edm::EventSetup& );
134  void endRun(edm::Run const&, edm::EventSetup const&);
135 
136 private:
138  void getRecoMomentum (const reco::Track& track, double& pt, double& ptError,
139  double& qoverp, double& qoverpError, double& lambda, double& lambdaError,
140  double& phi, double& phiError ) const;
142  void getRecoMomentum (const reco::GsfTrack& gsfTrack, double& pt, double& ptError,
143  double& qoverp, double& qoverpError, double& lambda, double& lambdaError,
144  double& phi, double& phiError) const;
145 
146  private:
152  double minPhi, maxPhi;
153  int nintPhi;
154  bool useGsf;
155  // select tracking particles
156  //(i.e. "denominator" of the efficiency ratio)
159 
160  // flag new validation logic (bidirectional RecoToSim association)
162  // flag MuonAssociatorByHits
163  bool MABH;
164 
165  //1D
166  std::vector<MonitorElement*> h_nchi2, h_nchi2_prob, h_losthits;
167 
168  //2D
169  std::vector<MonitorElement*> chi2_vs_nhits, etares_vs_eta;
170  std::vector<MonitorElement*> h_ptshifteta;
171  std::vector<MonitorElement*> ptres_vs_phi, chi2_vs_phi, nhits_vs_phi, phires_vs_phi;
172 
173  //Profile2D
174  std::vector<MonitorElement*> ptmean_vs_eta_phi, phimean_vs_eta_phi;
175 
176  //assoc chi2
177  std::vector<MonitorElement*> h_assochi2, h_assochi2_prob;
178 
179  //chi2 and # lost hits vs eta: to be used with doProfileX
180  std::vector<MonitorElement*> chi2_vs_eta, nlosthits_vs_eta;
181  std::vector<MonitorElement*> h_chi2meanh, h_losthits_eta;
182  std::vector<MonitorElement*> h_hits_phi;
183  std::vector<MonitorElement*> h_chi2meanhitsh, h_chi2mean_vs_phi;
184 
185  //resolution of track params: to be used with fitslicesytool
188 
189  //pulls of track params vs eta: to be used with fitslicesytool
191  std::vector<MonitorElement*> ptpull_vs_phi, phipull_vs_phi, thetapull_vs_phi;
193  std::vector<MonitorElement*> h_ptpullphi, h_phipullphi, h_thetapullphi;
194 
195 };
196 
197 
198 #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)
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 once per event.
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
void beginRun(edm::Run const &, edm::EventSetup const &)
Method called before the event loop.
std::vector< MonitorElement * > chi2_vs_eta
TrackingParticleSelector tpSelector
std::vector< MonitorElement * > h_losthits
std::vector< MonitorElement * > ptpull_vs_phi
edm::InputTag associatormap
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:41
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
Definition: DDAxes.h:10