CMS 3D CMS Logo

AlignmentMonitorTracksFromTrajectories.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CommonAlignmentProducer
4 // Class : AlignmentMonitorTracksFromTrajectories
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Jim Pivarski
10 // Created: Thu Jun 28 01:38:33 CDT 2007
11 //
12 
13 // system include files
19 #include "TH1.h"
20 #include "TObject.h"
22 
26 
27 #include <fstream>
28 
29 // user include files
30 
31 //
32 // class definition
33 //
34 
36 public:
39 
40  void book();
41  void event(const edm::Event &iEvent, const edm::EventSetup &iSetup, const ConstTrajTrackPairCollection &iTrajTracks);
42  void afterAlignment();
43 
44 private:
47  const bool m_vertexConstraint;
50 
51  TH1F *m_diMuon_Z;
55  TH1F *m_diMuon_Ups;
57  TH1F *m_diMuon_log;
58  TH1F *m_chi2_100;
59  TH1F *m_chi2_10000;
61  TH1F *m_chi2_log;
62  TH1F *m_chi2DOF_5;
68  TH1F *m_pt[36];
69 };
70 
71 //
72 // constants, enums and typedefs
73 //
74 
75 //
76 // static data member definitions
77 //
78 
79 //
80 // constructors and destructor
81 //
82 
83 // AlignmentMonitorTracksFromTrajectories::AlignmentMonitorTracksFromTrajectories(const AlignmentMonitorTracksFromTrajectories& rhs)
84 // {
85 // // do actual copying here;
86 // }
87 
88 //
89 // assignment operators
90 //
91 // const AlignmentMonitorTracksFromTrajectories& AlignmentMonitorTracksFromTrajectories::operator=(const AlignmentMonitorTracksFromTrajectories& rhs)
92 // {
93 // //An exception safe implementation is
94 // AlignmentMonitorTracksFromTrajectories temp(rhs);
95 // swap(rhs);
96 //
97 // return *this;
98 // }
99 
102  : AlignmentMonitorBase(cfg, iC, "AlignmentMonitorTracksFromTrajectories"),
103  m_vertexConstraint(cfg.getParameter<bool>("vertexConstraint")),
104  m_beamSpot(cfg.getParameter<edm::InputTag>("beamSpot")),
105  bsToken_(iC.consumes<reco::BeamSpot>(m_beamSpot)) {
106  theMuonServiceProxy = new MuonServiceProxy(cfg.getParameter<edm::ParameterSet>("ServiceParameters"));
107  theMuonUpdatorAtVertex = new MuonUpdatorAtVertex(cfg.getParameter<edm::ParameterSet>("MuonUpdatorAtVertexParameters"),
109 }
110 
111 //
112 // member functions
113 //
114 
116 // book()
118 
120  m_diMuon_Z = book1D("/iterN/", "diMuon_Z", "Di-muon mass (GeV)", 200, 90. - 50., 90. + 50.);
121  m_diMuon_Zforward = book1D("/iterN/", "diMuon_Zforward", "Di-muon mass (GeV) eta > 1.4", 200, 90. - 50., 90. + 50.);
123  book1D("/iterN/", "diMuon_Zbarrel", "Di-muon mass (GeV) -1.4 < eta < 1.4", 200, 90. - 50., 90. + 50.);
125  book1D("/iterN/", "diMuon_Zbackward", "Di-muon mass (GeV) eta < -1.4", 200, 90. - 50., 90. + 50.);
126  m_diMuon_Ups = book1D("/iterN/", "diMuon_Ups", "Di-muon mass (GeV)", 200, 9. - 3., 9. + 3.);
127  m_diMuon_Jpsi = book1D("/iterN/", "diMuon_Jpsi", "Di-muon mass (GeV)", 200, 3. - 1., 3. + 1.);
128  m_diMuon_log = book1D("/iterN/", "diMuon_log", "Di-muon mass (log GeV)", 300, 0, 3);
129  m_chi2_100 = book1D("/iterN/", "m_chi2_100", "Track chi^2", 100, 0, 100);
130  m_chi2_10000 = book1D("/iterN/", "m_chi2_10000", "Track chi^2", 100, 0, 10000);
131  m_chi2_1000000 = book1D("/iterN/", "m_chi2_1000000", "Track chi^2", 100, 1, 1000000);
132  m_chi2_log = book1D("/iterN/", "m_chi2_log", "Log track chi^2", 100, -3, 7);
133  m_chi2DOF_5 = book1D("/iterN/", "m_chi2DOF_5", "Track chi^2/nDOF", 100, 0, 5);
134  m_chi2DOF_100 = book1D("/iterN/", "m_chi2DOF_100", "Track chi^2/nDOF", 100, 0, 100);
135  m_chi2DOF_1000 = book1D("/iterN/", "m_chi2DOF_1000", "Track chi^2/nDOF", 100, 0, 1000);
136  m_chi2DOF_log = book1D("/iterN/", "m_chi2DOF_log", "Log track chi^2/nDOF", 100, -3, 7);
137  m_chi2_improvement = book1D("/iterN/", "m_chi2_improvement", "Track-by-track chi^2/original chi^2", 100, 0., 10.);
139  "/iterN/", "m_chi2DOF_improvement", "Track-by-track (chi^2/DOF)/(original chi^2/original DOF)", 100, 0., 10.);
140  for (int i = 0; i < 36; i++) {
141  char name[100], title[100];
142  snprintf(name, sizeof(name), "m_pt_phi%d", i);
143  snprintf(title, sizeof(title), "Track pt (GeV) in phi bin %d/36", i);
144  m_pt[i] = book1D("/iterN/", name, title, 100, 0, 100);
145  }
146 }
147 
149 // event()
151 
153  const edm::EventSetup &iSetup,
155  theMuonServiceProxy->update(iSetup);
156 
158 
159  GlobalVector p1, p2;
160  double e1 = 0.;
161  double e2 = 0.;
162 
163  for (ConstTrajTrackPairCollection::const_iterator it = tracks.begin(); it != tracks.end(); ++it) {
164  const Trajectory *traj = it->first;
165  const reco::Track *track = it->second;
166 
167  int nDOF = 0;
168  TrajectoryStateOnSurface closestTSOS;
169  double closest = 10000.;
170 
171  std::vector<TrajectoryMeasurement> measurements = traj->measurements();
172  for (std::vector<TrajectoryMeasurement>::const_iterator im = measurements.begin(); im != measurements.end(); ++im) {
173  const TrajectoryMeasurement meas = *im;
174  const TransientTrackingRecHit *hit = &(*meas.recHit());
175  // const DetId id = hit->geographicalId();
176 
177  nDOF += hit->dimension();
178 
180  GlobalPoint where = TSOS.surface().toGlobal(LocalPoint(0, 0, 0));
181 
182  if (where.mag() < closest) {
183  closest = where.mag();
184  closestTSOS = TSOS;
185  }
186 
187  } // end loop over measurements
188  nDOF -= 5;
189 
190  if (closest != 10000.) {
191  std::pair<bool, FreeTrajectoryState> state;
192 
193  if (m_vertexConstraint) {
195  // add in chi^2 contribution from vertex contratint?
196  } else {
198  }
199 
200  if (state.first) {
201  double chi2 = traj->chiSquared();
202  double chi2DOF = chi2 / double(nDOF);
203 
204  m_chi2_100->Fill(chi2);
205  m_chi2_10000->Fill(chi2);
206  m_chi2_1000000->Fill(chi2);
207  m_chi2_log->Fill(log10(chi2));
208 
209  m_chi2DOF_5->Fill(chi2DOF);
210  m_chi2DOF_100->Fill(chi2DOF);
211  m_chi2DOF_1000->Fill(chi2DOF);
212  m_chi2DOF_log->Fill(log10(chi2DOF));
213  m_chi2_improvement->Fill(chi2 / track->chi2());
214  m_chi2DOF_improvement->Fill(chi2DOF / track->normalizedChi2());
215 
216  GlobalVector momentum = state.second.momentum();
217  double energy = momentum.mag();
218 
219  if (energy > e1) {
220  e2 = e1;
221  e1 = energy;
222  p2 = p1;
223  p1 = momentum;
224  } else if (energy > e2) {
225  e2 = energy;
226  p2 = momentum;
227  }
228 
229  double pt = momentum.perp();
230  double phi = momentum.phi();
231  while (phi < -M_PI)
232  phi += 2. * M_PI;
233  while (phi > M_PI)
234  phi -= 2. * M_PI;
235 
236  double phibin = (phi + M_PI) / (2. * M_PI) * 36.;
237 
238  for (int i = 0; i < 36; i++) {
239  if (phibin < i + 1) {
240  m_pt[i]->Fill(pt);
241  break;
242  }
243  }
244 
245  } // end if propagate was successful
246  } // end if we have a closest TSOS
247  } // end loop over tracks
248 
249  if (e1 > 0. && e2 > 0.) {
250  double energy_tot = e1 + e2;
251  GlobalVector momentum_tot = p1 + p2;
252  double mass = sqrt(energy_tot * energy_tot - momentum_tot.mag2());
253  double eta = momentum_tot.eta();
254 
255  m_diMuon_Z->Fill(mass);
256  if (eta > 1.4)
257  m_diMuon_Zforward->Fill(mass);
258  else if (eta > -1.4)
259  m_diMuon_Zbarrel->Fill(mass);
260  else
261  m_diMuon_Zbackward->Fill(mass);
262 
263  m_diMuon_Ups->Fill(mass);
264  m_diMuon_Jpsi->Fill(mass);
265  m_diMuon_log->Fill(log10(mass));
266  } // end if we have two tracks
267 }
268 
270 // afterAlignment()
272 
274 
275 //
276 // const member functions
277 //
278 
279 //
280 // static member functions
281 //
282 
283 //
284 // SEAL definitions
285 //
286 
289  "AlignmentMonitorTracksFromTrajectories");
AlignmentMonitorTracksFromTrajectories(const edm::ParameterSet &cfg, edm::ConsumesCollector iC)
T perp() const
Definition: PV3DBase.h:69
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
void book()
Book or retrieve histograms; MUST be reimplemented.
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
int closest(std::vector< int > const &vec, int value)
T eta() const
Definition: PV3DBase.h:73
float chiSquared() const
Definition: Trajectory.h:241
T mag2() const
Definition: PV3DBase.h:63
const SurfaceType & surface() const
DataContainer const & measurements() const
Definition: Trajectory.h:178
void event(const edm::Event &iEvent, const edm::EventSetup &iSetup, const ConstTrajTrackPairCollection &iTrajTracks)
Called for each event (by "run()"): may be reimplemented.
std::pair< bool, FreeTrajectoryState > propagateWithUpdate(const TrajectoryStateOnSurface &tsos, const reco::BeamSpot &beamSpot) const
Propagate to the 2D-PCA and apply the vertex constraint.
int iEvent
Definition: GenABIO.cc:224
T sqrt(T t)
Definition: SSEVec.h:19
T mag() const
Definition: PV3DBase.h:64
TrajectoryStateOnSurface const & backwardPredictedState() const
Access to backward predicted state (from smoother)
std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection
TH1F * book1D(std::string dir, std::string name, std::string title, int nchX, double lowX, double highX)
std::pair< bool, FreeTrajectoryState > propagate(const TrajectoryStateOnSurface &tsos, const reco::BeamSpot &beamSpot) const
Propagate the state to the 2D-PCA.
#define M_PI
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
TrajectoryStateOnSurface TSOS
Definition: TestHits.cc:19
auto const & tracks
cannot be loose
fixed size matrix
HLT enums.
void update(const edm::EventSetup &setup, bool duringEvent=true)
update the services each event
#define DEFINE_EDM_PLUGIN(factory, type, name)
ConstRecHitPointer const & recHit() const