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