CMS 3D CMS Logo

MuCSCTnPFlatTableProducer.cc
Go to the documentation of this file.
1 
14 
17 
19 
20 #include "TString.h"
21 #include "TRegexp.h"
22 
23 #include <iostream>
24 
25 #include <numeric>
26 #include <vector>
27 
29 
31 
34 
37 
42 
45 
48 
53 
61 
62 class MuonServiceProxy;
63 
65 public:
68 
71 
72 protected:
74  void fillTable(edm::Event&) final;
75 
77  void getFromES(const edm::Run&, const edm::EventSetup&) final;
78 
80  void getFromES(const edm::EventSetup&) final;
81 
82 private:
83  static constexpr Float_t MEZ[6] = {601.3, 696.11, 696.11, 827.56, 936.44, 1025.9};
84 
88 
90 
92 
95 
99 
103 
105  std::unique_ptr<MuonServiceProxy> m_muonSP;
106 
109 
110  // Extrapolator to cylinder
114 
117 
119  std::vector<int> m_trigIndices;
120  std::vector<int> m_isoTrigIndices;
121 
123  //bool muonTagSelection(const reco::Muon & muon,edm::Handle<std::vector<reco::Track>> tracks);
124  bool trackProbeSelection(const reco::Track& track, edm::Handle<std::vector<reco::Track>>);
125  bool muonTagSelection(const reco::Muon&);
126  //bool trackProbeSelection(const reco::Track & track);
127  bool zSelection(const reco::Muon&, const reco::Track&);
128 
129  // Calculation functions
130  double zMass(const reco::Track&, const reco::Muon&);
131  double calcDeltaR(double, double, double, double);
132  double iso(const reco::Track&, edm::Handle<std::vector<reco::Track>>);
133 
134  // Track extrapolation and segment match functions
137 
138  UChar_t ringCandidate(Int_t iiStation, Int_t station, Float_t feta, Float_t phi);
139  UChar_t thisChamberCandidate(UChar_t station, UChar_t ring, Float_t phi);
140 
144  CSCDetId&);
146  std::vector<Float_t> GetEdgeAndDistToGap(const reco::Track&, CSCDetId&);
147  Float_t YDistToHVDeadZone(Float_t, Int_t);
148 
151 
152  unsigned int m_nZCands; // the # of digis (size of all following vectors)
153 
154  double _trackIso;
155  double _muonIso;
156  double _zMass;
157 
158  bool hasTrigger(std::vector<int>&,
161  const reco::Muon&);
162 
163  float computeTrkIso(const reco::MuonIsolation&, float);
164  float computePFIso(const reco::MuonPFIsolation&, float);
165 };
166 
169  m_muToken{config, consumesCollector(), "muonSrc"},
170  m_trackToken{config, consumesCollector(), "trackSrc"},
171  m_cscSegmentToken{config, consumesCollector(), "cscSegmentSrc"},
172  m_primaryVerticesToken{config, consumesCollector(), "primaryVerticesSrc"},
173  m_trigResultsToken{config, consumesCollector(), "trigResultsSrc"},
174  m_trigEventToken{config, consumesCollector(), "trigEventSrc"},
175  m_trigName{config.getParameter<std::string>("trigName")},
176  m_isoTrigName{config.getParameter<std::string>("isoTrigName")},
177  m_cscGeometry{consumesCollector()},
178  m_muonSP{std::make_unique<MuonServiceProxy>(config.getParameter<edm::ParameterSet>("ServiceParameters"),
179  consumesCollector())},
180  m_transientTrackBuilder{consumesCollector(), "TransientTrackBuilder"} {
181  produces<nanoaod::FlatTable>();
182 }
183 
186 
187  desc.add<std::string>("name", "cscTnP");
188  desc.add<edm::InputTag>("muonSrc", edm::InputTag{"muons"});
189  desc.add<edm::InputTag>("trackSrc", edm::InputTag{"generalTracks"});
190  desc.add<edm::InputTag>("cscSegmentSrc", edm::InputTag{"cscSegments"});
191  desc.add<edm::InputTag>("primaryVerticesSrc", edm::InputTag{"offlinePrimaryVertices"});
192 
193  desc.add<edm::InputTag>("trigEventSrc", edm::InputTag{"hltTriggerSummaryAOD::HLT"});
194  desc.add<edm::InputTag>("trigResultsSrc", edm::InputTag{"TriggerResults::HLT"});
195 
196  desc.add<std::string>("trigName", "none");
197  desc.add<std::string>("isoTrigName", "HLT_IsoMu2*");
198 
199  desc.setAllowAnything();
200 
201  descriptions.addWithDefaultLabel(desc);
202 }
203 
206 
207  bool changed{true};
208  m_hltConfig.init(run, environment, "HLT", changed);
209 
210  const bool enableWildcard{true};
211 
212  TString tName = TString(m_trigName);
213  TRegexp tNamePattern = TRegexp(tName, enableWildcard);
214 
215  for (unsigned iPath = 0; iPath < m_hltConfig.size(); ++iPath) {
216  TString pathName = TString(m_hltConfig.triggerName(iPath));
217  if (pathName.Contains(tNamePattern))
218  m_trigIndices.push_back(static_cast<int>(iPath));
219  }
220 
221  tName = TString(m_isoTrigName);
222  tNamePattern = TRegexp(tName, enableWildcard);
223 
224  for (unsigned iPath = 0; iPath < m_hltConfig.size(); ++iPath) {
225  TString pathName = TString(m_hltConfig.triggerName(iPath));
226  if (pathName.Contains(tNamePattern))
227  m_isoTrigIndices.push_back(static_cast<int>(iPath));
228  }
229 }
230 
233  m_muonSP->update(environment);
234 }
235 
237  unsigned int m_nZCands = 0; // the # of digis (size of all following vectors)
238 
239  // Muon track tag variables
240  std::vector<float> m_muonPt; // muon pT [GeV/c]
241  std::vector<float> m_muonPhi; // muon phi [rad]
242  std::vector<float> m_muonEta; // muon eta
243  std::vector<float> m_muonPtError; // muon pT [GeV/c] error
244  std::vector<float> m_muonPhiError; // muon phi [rad] error
245  std::vector<float> m_muonEtaError; // muon eta error
246  std::vector<int> m_muonCharge; // muon charge
247  std::vector<float> m_muonDXY; // muon dXY
248  std::vector<float> m_muonDZ; // muon dZ
249  std::vector<int> m_muonTrkHits; // muon track Hits
250  std::vector<float> m_muonChi2; // muon Chi2
251  std::vector<bool> m_muonTrigger; // muon trigger
252  std::vector<float> m_muonIso; // track Iso
253 
254  // Track probe variabes
255  std::vector<float> m_trackPt; // track pT [GeV/c]
256  std::vector<float> m_trackP; // track P [GeV/c]
257  std::vector<float> m_trackPhi; // track phi [rad]
258  std::vector<float> m_trackEta; // track eta
259  std::vector<float> m_trackPtError; // track pT [GeV/c] error
260  std::vector<float> m_trackPhiError; // track phi [rad] error
261  std::vector<float> m_trackEtaError; // track eta error
262  std::vector<int> m_trackCharge; // track charge
263  std::vector<float> m_trackDXY; // track dXY
264  std::vector<float> m_trackDZ; // track dZ
265  std::vector<int> m_trackTrkHits; // track Hits
266  std::vector<float> m_trackChi2; // track Chi2
267  std::vector<float> m_trackIso; // track Iso
268 
269  // Z and global variables
270  std::vector<float> m_zMass; // z mass
271  std::vector<float> m_dRTrackMuon; // dR between the track and muon
272  std::vector<float> m_numberOfPrimaryVertices; // Number of primary Vertices
273 
274  // CSC chamber information, station encoded in vector
275  std::vector<int> m_chamberEndcap; // chamber endcap
276  // station encoded in array index
277  std::array<std::vector<int>, 4> m_chamberRing; // chamber Ring
278  std::array<std::vector<int>, 4> m_chamberChamber; // chamber Chamber
279  std::array<std::vector<int>, 4> m_chamberLayer; // Segment layer information
280 
281  // Track intersection variables
282  std::array<std::vector<float>, 4> m_ttIntLocalX; // track trajector intersection local X on stations 1-4
283  std::array<std::vector<float>, 4> m_ttIntLocalY; // track trajector intersection local Y on stations 1-4
284  std::array<std::vector<float>, 4> m_ttIntLocalErrorX; // track trajector intersection local X on stations 1-4
285  std::array<std::vector<float>, 4> m_ttIntLocalErrorY; // track trajector intersection local Y on stations 1-4
286  std::array<std::vector<float>, 4> m_ttIntLocalW; // track trajector intersection local Wire on stations 1-4
287  std::array<std::vector<float>, 4> m_ttIntLocalS; // track trajector intersection local Strip on stations 1-4
288  std::array<std::vector<float>, 4> m_ttIntEta; // track trajector intersection Eta stations 1-4
289 
290  // Track intersection fiducial information
291 
292  std::array<std::vector<float>, 4>
293  m_ttDistToEdge; // track trajector intersection distance to edge, neg is with chamber, on stations 1-4
294  std::array<std::vector<float>, 4> m_ttDistToHVGap; // track trajector intersection distance to HV GAP on stations 1-4
295 
296  // Segment location variables
297  std::array<std::vector<float>, 4> m_segLocalX; // segment local X on stations 1-4
298  std::array<std::vector<float>, 4> m_segLocalY; // segment local Y on stations 1-4
299  std::array<std::vector<float>, 4> m_segLocalErrorX; // segment local X error on stations 1-4
300  std::array<std::vector<float>, 4> m_segLocalErrorY; // segment local Y error on stations 1-4
301 
302  // track intersection segment residuals variables
303  std::array<std::vector<float>, 4>
304  m_ttIntSegResidualLocalX; // track trajector intersection Segment residual local X on stations 1-4
305  std::array<std::vector<float>, 4>
306  m_ttIntSegResidualLocalY; // track trajector intersection Segment residuallocal Y on stations 1-4
307 
308  auto&& propagator_along = m_muonSP->propagator("SteppingHelixPropagatorAlong");
309  auto&& propagator_opposite = m_muonSP->propagator("SteppingHelixPropagatorOpposite");
310 
311  propagatorAlong = propagator_along;
312  propagatorOpposite = propagator_opposite;
313 
314  theBField = m_muonSP->magneticField();
315 
318  auto segments = m_cscSegmentToken.conditionalGet(ev);
320 
323 
324  if (muons.isValid() && tracks.isValid() && segments.isValid() && primaryVertices.isValid() &&
326  for (const auto& muon : (*muons)) {
327  if (!muonTagSelection(muon))
328  continue;
329 
330  bool muonTrigger = false;
331  if (triggerResults.isValid() && triggerEvent.isValid()) {
332  const auto& triggerObjects = triggerEvent->getObjects();
335  }
336 
337  for (const auto& track : (*tracks)) {
339  continue;
340  if (!zSelection(muon, track))
341  continue;
342  //std::cout << "Z candidate found: " << _zMass << " track eta: " << track.eta() << std::endl;
343  //std::cout.flush();
344  m_nZCands++;
345 
346  m_trackPt.push_back(track.pt());
347  m_trackP.push_back(track.p());
348  m_trackEta.push_back(track.eta());
349  m_trackPhi.push_back(track.phi());
350  m_trackPtError.push_back(track.pt());
351  m_trackEtaError.push_back(track.eta());
352  m_trackPhiError.push_back(track.phi());
353  m_trackCharge.push_back(track.charge());
354  m_trackDXY.push_back(track.dxy());
355  m_trackDZ.push_back(track.dz());
356  m_trackTrkHits.push_back(track.hitPattern().numberOfValidTrackerHits());
357  m_trackChi2.push_back(track.normalizedChi2());
358  m_trackIso.push_back(_trackIso);
359 
360  m_muonPt.push_back(muon.track()->pt());
361  m_muonPhi.push_back(muon.track()->phi());
362  m_muonEta.push_back(muon.track()->eta());
363  m_muonPtError.push_back(muon.track()->ptError());
364  m_muonPhiError.push_back(muon.track()->phiError());
365  m_muonEtaError.push_back(muon.track()->etaError());
366  m_muonCharge.push_back(muon.charge());
367  m_muonDXY.push_back(muon.track()->dxy());
368  m_muonDZ.push_back(muon.track()->dz());
369  m_muonTrkHits.push_back(muon.track()->hitPattern().numberOfValidTrackerHits());
370  m_muonChi2.push_back(muon.track()->normalizedChi2());
371  m_muonIso.push_back(computeTrkIso(muon.isolationR03(), muon.pt()));
372  m_muonTrigger.push_back(muonTrigger);
373 
374  m_zMass.push_back(_zMass);
375  double_t dR = calcDeltaR(track.eta(), muon.eta(), track.phi(), muon.phi());
376  //double_t dR = 1.0;
377  m_dRTrackMuon.push_back(dR);
378  const reco::VertexCollection& vertices = *primaryVertices.product();
379  m_numberOfPrimaryVertices.push_back(vertices.size());
380 
381  bool ec = (track.eta() > 0);
382  UChar_t endcapCSC = ec ? 0 : 1;
383  m_chamberEndcap.push_back(endcapCSC * 1);
384 
385  Int_t iiStationFail = 0;
386  for (int iiStationZ = 0; iiStationZ < 6; iiStationZ++) {
387  UChar_t stationCSC = iiStationZ > 2 ? iiStationZ - 2 : 0;
388  UChar_t ringCSC = 0;
389  TrajectoryStateOnSurface tsos = surfExtrapTrkSam(track, ec ? MEZ[iiStationZ] : -MEZ[iiStationZ]);
390 
391  if (tsos.isValid()) {
392  Float_t trkEta = tsos.globalPosition().eta(), trkPhi = tsos.globalPosition().phi();
393  ringCSC = ringCandidate(iiStationZ, stationCSC + 1, trkEta, trkPhi);
394 
395  if (ringCSC) {
396  UChar_t chamberCSC = thisChamberCandidate(stationCSC + 1, ringCSC, track.phi()) - 1;
397  CSCDetId Layer3id = CSCDetId(endcapCSC + 1, stationCSC + 1, ringCSC, chamberCSC + 1, 3);
398  CSCDetId Layer0Id = CSCDetId(endcapCSC + 1,
399  stationCSC + 1,
400  ringCSC,
401  chamberCSC + 1,
402  0); //layer 0 is the mid point of the chamber. It is not a real layer.
403  // !!!!! need to fix Layer0Id problem with ME1/1 here
404 
405  const BoundPlane& Layer3Surface = m_cscGeometry->idToDet(Layer3id)->surface();
406 
407  tsos = surfExtrapTrkSam(track, Layer3Surface.position().z());
408 
409  if (tsos.isValid()) {
410  // Fill track intersection denominator information
411  LocalPoint localTTIntPoint = Layer3Surface.toLocal(tsos.freeState()->position());
412  const CSCLayerGeometry* layerGeoma = m_cscGeometry->chamber(Layer0Id)->layer(3)->geometry();
413  const CSCLayerGeometry* layerGeomb = m_cscGeometry->chamber(Layer0Id)->layer(4)->geometry();
414 
415  m_chamberRing[stationCSC].push_back(ringCSC);
416  m_chamberChamber[stationCSC].push_back(chamberCSC);
417  m_ttIntLocalX[stationCSC].push_back(localTTIntPoint.x());
418  m_ttIntLocalY[stationCSC].push_back(localTTIntPoint.y());
419  m_ttIntLocalW[stationCSC].push_back(
420  (layerGeoma->nearestWire(localTTIntPoint) + layerGeomb->nearestWire(localTTIntPoint)) / 2.0);
421  m_ttIntLocalS[stationCSC].push_back(
422  (layerGeoma->strip(localTTIntPoint) + layerGeomb->strip(localTTIntPoint)) / 2.0);
423  m_ttIntEta[stationCSC].push_back(trkEta);
424 
425  // Errors are those of the track intersection, chosing the plane and exact geomentry is performed in the function
426  Float_t CSCProjEdgeDist = -9999.0;
427  Float_t ttIntLocalErrorX = -9999.0;
428  Float_t CSCDyProjHVGap = 9999.0;
429  Float_t ttIntLocalErrorY = -9999.0;
430  for (Int_t ly = 1; ly < 7; ly++) {
431  CSCDetId Layerid = CSCDetId(endcapCSC + 1, stationCSC + 1, ringCSC, chamberCSC + 1, ly);
432  std::vector<Float_t> EdgeAndDistToGap(GetEdgeAndDistToGap(
433  track, Layerid)); //values: 1-edge;2-err of edge;3-disttogap;4-err of dist to gap
434  if (EdgeAndDistToGap[0] > CSCProjEdgeDist) {
435  CSCProjEdgeDist = EdgeAndDistToGap[0];
436  ttIntLocalErrorX = EdgeAndDistToGap[1];
437  }
438  if (EdgeAndDistToGap[2] < CSCDyProjHVGap) {
439  CSCDyProjHVGap = EdgeAndDistToGap[2];
440  ttIntLocalErrorY = EdgeAndDistToGap[3];
441  }
442  }
443  m_ttDistToEdge[stationCSC].push_back(CSCProjEdgeDist);
444  m_ttDistToHVGap[stationCSC].push_back(CSCDyProjHVGap);
445  m_ttIntLocalErrorX[stationCSC].push_back(ttIntLocalErrorX);
446  m_ttIntLocalErrorY[stationCSC].push_back(ttIntLocalErrorY);
447 
448  // now we have a local point for comparison to segments
450  TrajectoryStateOnSurface* TrajToSeg = matchTTwithCSCSeg(track, segments, cscSegOut, Layer3id);
451 
452  if (TrajToSeg == nullptr) {
453  // fill Null Num
454  m_segLocalX[stationCSC].push_back(-9999.0);
455  m_segLocalY[stationCSC].push_back(-9999.0);
456  m_segLocalErrorX[stationCSC].push_back(0.0);
457  m_segLocalErrorY[stationCSC].push_back(0.0);
458 
459  m_ttIntSegResidualLocalX[stationCSC].push_back(-9990.0);
460  m_ttIntSegResidualLocalY[stationCSC].push_back(-9990.0);
461 
462  m_chamberLayer[stationCSC].push_back(-9);
463 
464  continue;
465  }
466 
467  LocalPoint localSegmentPoint = (*cscSegOut).localPosition();
468  LocalError localSegErr = (*cscSegOut).localPositionError();
469 
470  m_segLocalX[stationCSC].push_back(localSegmentPoint.x());
471  m_segLocalY[stationCSC].push_back(localSegmentPoint.y());
472  m_segLocalErrorX[stationCSC].push_back(sqrt(localSegErr.xx()));
473  m_segLocalErrorY[stationCSC].push_back(sqrt(localSegErr.yy()));
474 
475  m_ttIntSegResidualLocalX[stationCSC].push_back(localTTIntPoint.x() - localSegmentPoint.x());
476  m_ttIntSegResidualLocalY[stationCSC].push_back(localTTIntPoint.y() - localSegmentPoint.y());
477  /* Extract layers for hits */
478  int layers = 0;
479  for (std::vector<CSCRecHit2D>::const_iterator itRH = cscSegOut->specificRecHits().begin();
480  itRH != cscSegOut->specificRecHits().end();
481  ++itRH) {
482  const CSCRecHit2D* recHit = &(*itRH);
483  int layer = recHit->cscDetId().layer();
484  layers |= 1 << (layer - 1);
485  }
486  m_chamberLayer[stationCSC].push_back(layers);
487 
488  } // end preliminary tsos is valid
489 
490  } // end found ring CSC
491 
492  } // end refined tsos is valid
493 
494  if ((!tsos.isValid()) || (ringCSC == 0)) {
495  // only fill Null denominator once for station 1, iiStation Z = 0,1,2
496  if (iiStationZ <= 2)
497  iiStationFail++;
498  if (iiStationZ > 2 || iiStationFail == 3) {
499  // fill Null Den Num
500  m_chamberRing[stationCSC].push_back(-9);
501  m_chamberChamber[stationCSC].push_back(-9);
502  m_ttIntLocalX[stationCSC].push_back(-9999.0);
503  m_ttIntLocalY[stationCSC].push_back(-9999.0);
504  m_ttIntLocalErrorX[stationCSC].push_back(0.0);
505  m_ttIntLocalErrorY[stationCSC].push_back(0.0);
506  m_ttIntLocalW[stationCSC].push_back(-9999.0);
507  m_ttIntLocalS[stationCSC].push_back(-9999.0);
508  m_ttIntEta[stationCSC].push_back(-9999.0);
509 
510  m_ttDistToEdge[stationCSC].push_back(-9999.0);
511  m_ttDistToHVGap[stationCSC].push_back(-9999.9);
512 
513  m_segLocalX[stationCSC].push_back(-9999.0);
514  m_segLocalY[stationCSC].push_back(-9999.0);
515  m_segLocalErrorX[stationCSC].push_back(0.0);
516  m_segLocalErrorY[stationCSC].push_back(0.0);
517 
518  m_ttIntSegResidualLocalX[stationCSC].push_back(-9990.0);
519  m_ttIntSegResidualLocalY[stationCSC].push_back(-9990.0);
520 
521  m_chamberLayer[stationCSC].push_back(-9);
522  }
523  }
524 
525  } // end loop over CSC Z planes
526  } // endl loop over tracks
527  } // end loop over muons
528 
529  } // End if good physics objects
530 
531  // if (m_nZCands>0) {
532  auto table = std::make_unique<nanoaod::FlatTable>(m_nZCands, m_name, false, false);
533 
534  table->setDoc("CSC Tag & Probe segment efficiency information");
535 
536  addColumn(table, "muonPt", m_muonPt, "muon pt [GeV/c]");
537  addColumn(table, "muonPhi", m_muonPhi, "muon phi [rad]");
538  addColumn(table, "muonEta", m_muonEta, "muon eta");
539  addColumn(table, "muonPtError", m_muonPtError, "muon pt error [GeV/c]");
540  addColumn(table, "muonPhiError", m_muonPhiError, "muon phi error [rad]");
541  addColumn(table, "muonEtaError", m_muonEtaError, "muon eta error");
542  addColumn(table, "muonCharge", m_muonCharge, "muon charge");
543  addColumn(table, "muonDXY", m_muonDXY, "muon dXY [cm]");
544  addColumn(table, "muonDZ", m_muonDZ, "muon dZ [cm]");
545  addColumn(table, "muonTrkHits", m_muonTrkHits, "muon track hits");
546  addColumn(table, "muonChi2", m_muonChi2, "muon chi2");
547  addColumn(table, "muonIso", m_trackIso, "muon relative iso");
548  addColumn(table, "muonTrigger", m_muonTrigger, "muon has trigger bool");
549 
550  addColumn(table, "trackPt", m_trackPt, "track pt [GeV/c]");
551  addColumn(table, "trackP", m_trackPt, "track p [GeV/c]");
552  addColumn(table, "trackPhi", m_trackPhi, "track phi [rad]");
553  addColumn(table, "trackEta", m_trackEta, "track eta");
554  addColumn(table, "trackPtError", m_trackPtError, "track pt error [GeV/c]");
555  addColumn(table, "trackPhiError", m_trackPhiError, "track phi error [rad]");
556  addColumn(table, "trackEtaError", m_trackEtaError, "track eta error");
557  addColumn(table, "trackCharge", m_trackCharge, "track charge");
558  addColumn(table, "trackDXY", m_trackDXY, "track dXY [cm]");
559  addColumn(table, "trackDZ", m_trackDZ, "track dZ [cm]");
560  addColumn(table, "trackTrkHits", m_trackTrkHits, "track track hits");
561  addColumn(table, "trackChi2", m_trackChi2, "track chi2");
562  addColumn(table, "trackIso", m_trackIso, "track relative iso");
563 
564  addColumn(table, "zMass", m_zMass, "Z mass [GeV/c^2]");
565  addColumn(table, "dRTrackMuon", m_dRTrackMuon, "dR between track and muon");
566  addColumn(table, "numberOfPrimaryVertidies", m_numberOfPrimaryVertices, "Number of PVs");
567 
568  addColumn(table, "chamberEndcap", m_chamberEndcap, "");
569  addColumn(table, "chamberRing1", m_chamberRing[0], "");
570  addColumn(table, "chamberRing2", m_chamberRing[1], "");
571  addColumn(table, "chamberRing3", m_chamberRing[2], "");
572  addColumn(table, "chamberRing4", m_chamberRing[3], "");
573  addColumn(table, "chamberChamber1", m_chamberChamber[0], "");
574  addColumn(table, "chamberChamber2", m_chamberChamber[1], "");
575  addColumn(table, "chamberChamber3", m_chamberChamber[2], "");
576  addColumn(table, "chamberChamber4", m_chamberChamber[3], "");
577  addColumn(table, "chamberLayer1", m_chamberLayer[0], "");
578  addColumn(table, "chamberLayer2", m_chamberLayer[1], "");
579  addColumn(table, "chamberLayer3", m_chamberLayer[2], "");
580  addColumn(table, "chamberLayer4", m_chamberLayer[3], "");
581 
582  addColumn(table, "ttIntLocalX1", m_ttIntLocalX[0], "");
583  addColumn(table, "ttIntLocalX2", m_ttIntLocalX[1], "");
584  addColumn(table, "ttIntLocalX3", m_ttIntLocalX[2], "");
585  addColumn(table, "ttIntLocalX4", m_ttIntLocalX[3], "");
586  addColumn(table, "ttIntLocalY1", m_ttIntLocalY[0], "");
587  addColumn(table, "ttIntLocalY2", m_ttIntLocalY[1], "");
588  addColumn(table, "ttIntLocalY3", m_ttIntLocalY[2], "");
589  addColumn(table, "ttIntLocalY4", m_ttIntLocalY[3], "");
590  addColumn(table, "ttIntLocalErrorX1", m_ttIntLocalErrorX[0], "");
591  addColumn(table, "ttIntLocalErrorX2", m_ttIntLocalErrorX[1], "");
592  addColumn(table, "ttIntLocalErrorX3", m_ttIntLocalErrorX[2], "");
593  addColumn(table, "ttIntLocalErrorX4", m_ttIntLocalErrorX[3], "");
594  addColumn(table, "ttIntLocalErrorY1", m_ttIntLocalErrorY[0], "");
595  addColumn(table, "ttIntLocalErrorY2", m_ttIntLocalErrorY[1], "");
596  addColumn(table, "ttIntLocalErrorY3", m_ttIntLocalErrorY[2], "");
597  addColumn(table, "ttIntLocalErrorY4", m_ttIntLocalErrorY[3], "");
598  addColumn(table, "ttIntLocalW1", m_ttIntLocalW[0], "");
599  addColumn(table, "ttIntLocalW2", m_ttIntLocalW[1], "");
600  addColumn(table, "ttIntLocalW3", m_ttIntLocalW[2], "");
601  addColumn(table, "ttIntLocalW4", m_ttIntLocalW[3], "");
602  addColumn(table, "ttIntLocalS1", m_ttIntLocalS[0], "");
603  addColumn(table, "ttIntLocalS2", m_ttIntLocalS[1], "");
604  addColumn(table, "ttIntLocalS3", m_ttIntLocalS[2], "");
605  addColumn(table, "ttIntLocalS4", m_ttIntLocalS[3], "");
606  addColumn(table, "ttIntEta1", m_ttIntEta[0], "");
607  addColumn(table, "ttIntEta2", m_ttIntEta[1], "");
608  addColumn(table, "ttIntEta3", m_ttIntEta[2], "");
609  addColumn(table, "ttIntEta4", m_ttIntEta[3], "");
610 
611  addColumn(table, "ttDistToEdge1", m_ttDistToEdge[0], "");
612  addColumn(table, "ttDistToEdge2", m_ttDistToEdge[1], "");
613  addColumn(table, "ttDistToEdge3", m_ttDistToEdge[2], "");
614  addColumn(table, "ttDistToEdge4", m_ttDistToEdge[3], "");
615  addColumn(table, "ttDistToHVGap1", m_ttDistToHVGap[0], "");
616  addColumn(table, "ttDistToHVGap2", m_ttDistToHVGap[1], "");
617  addColumn(table, "ttDistToHVGap3", m_ttDistToHVGap[2], "");
618  addColumn(table, "ttDistToHVGap4", m_ttDistToHVGap[3], "");
619 
620  addColumn(table, "segLocalX1", m_segLocalX[0], "");
621  addColumn(table, "segLocalX2", m_segLocalX[1], "");
622  addColumn(table, "segLocalX3", m_segLocalX[2], "");
623  addColumn(table, "segLocalX4", m_segLocalX[3], "");
624  addColumn(table, "segLocalY1", m_segLocalY[0], "");
625  addColumn(table, "segLocalY2", m_segLocalY[1], "");
626  addColumn(table, "segLocalY3", m_segLocalY[2], "");
627  addColumn(table, "segLocalY4", m_segLocalY[3], "");
628  addColumn(table, "segLocalErrorX1", m_segLocalErrorX[0], "");
629  addColumn(table, "segLocalErrorX2", m_segLocalErrorX[1], "");
630  addColumn(table, "segLocalErrorX3", m_segLocalErrorX[2], "");
631  addColumn(table, "segLocalErrorX4", m_segLocalErrorX[3], "");
632  addColumn(table, "segLocalErrorY1", m_segLocalErrorY[0], "");
633  addColumn(table, "segLocalErrorY2", m_segLocalErrorY[1], "");
634  addColumn(table, "segLocalErrorY3", m_segLocalErrorY[2], "");
635  addColumn(table, "segLocalErrorY4", m_segLocalErrorY[3], "");
636 
637  addColumn(table, "ttIntSegResidualLocalX1", m_ttIntSegResidualLocalX[0], "");
638  addColumn(table, "ttIntSegResidualLocalX2", m_ttIntSegResidualLocalX[1], "");
639  addColumn(table, "ttIntSegResidualLocalX3", m_ttIntSegResidualLocalX[2], "");
640  addColumn(table, "ttIntSegResidualLocalX4", m_ttIntSegResidualLocalX[3], "");
641  addColumn(table, "ttIntSegResidualLocalY1", m_ttIntSegResidualLocalY[0], "");
642  addColumn(table, "ttIntSegResidualLocalY2", m_ttIntSegResidualLocalY[1], "");
643  addColumn(table, "ttIntSegResidualLocalY3", m_ttIntSegResidualLocalY[2], "");
644  addColumn(table, "ttIntSegResidualLocalY4", m_ttIntSegResidualLocalY[3], "");
645 
646  ev.put(std::move(table));
647 }
648 
650  return isolation.sumPt / muonPt;
651 }
652 
654  return (pfIsolation.sumChargedHadronPt +
655  std::max(0., pfIsolation.sumNeutralHadronEt + pfIsolation.sumPhotonEt - 0.5 * pfIsolation.sumPUPt)) /
656  muonPt;
657 }
658 
659 bool MuCSCTnPFlatTableProducer::hasTrigger(std::vector<int>& trigIndices,
662  const reco::Muon& muon) {
663  float dRMatch = 999.;
664  for (int trigIdx : trigIndices) {
665  const std::vector<std::string> trigModuleLabels = m_hltConfig.moduleLabels(trigIdx);
666 
667  const unsigned trigModuleIndex =
668  std::find(trigModuleLabels.begin(), trigModuleLabels.end(), "hltBoolEnd") - trigModuleLabels.begin() - 1;
669  const unsigned hltFilterIndex = trigEvent->filterIndex(edm::InputTag(trigModuleLabels[trigModuleIndex], "", "HLT"));
670  if (hltFilterIndex < trigEvent->sizeFilters()) {
671  const trigger::Keys keys = trigEvent->filterKeys(hltFilterIndex);
672  const trigger::Vids vids = trigEvent->filterIds(hltFilterIndex);
673  const unsigned nTriggers = vids.size();
674 
675  for (unsigned iTrig = 0; iTrig < nTriggers; ++iTrig) {
676  trigger::TriggerObject trigObj = trigObjs[keys[iTrig]];
677  float dR = deltaR(muon, trigObj);
678  if (dR < dRMatch)
679  dRMatch = dR;
680  }
681  }
682  }
683 
684  return dRMatch < 0.1; //CB should get it programmable
685 }
686 
687 //bool MuCSCTnPFlatTableProducer::muonTagSelection(const reco::Muon & muon,edm::Handle<std::vector<reco::Track>> tracks)
689  float ptCut = 10.0;
690  int trackerHitsCut = 8;
691  float dxyCut = 2.0;
692  float dzCut = 24.0;
693  float chi2Cut = 4.0;
694 
695  bool selected = false;
696  //_muonIso = iso(*muon.track(),tracks);
697  _muonIso = computePFIso(muon.pfIsolationR04(), muon.pt());
698 
699  if (!muon.isTrackerMuon())
700  return false;
701  if (!muon.track().isNonnull())
702  return false;
703  selected =
704  ((muon.track()->pt() > ptCut) && (muon.track()->hitPattern().numberOfValidTrackerHits() >= trackerHitsCut) &&
705  (muon.track()->dxy() < dxyCut) && (std::abs(muon.track()->dz()) < dzCut) &&
706  (muon.track()->normalizedChi2() < chi2Cut) && _muonIso < 0.1);
707 
708  return selected;
709 }
710 
712  edm::Handle<std::vector<reco::Track>> tracks) {
713  float ptCut = 10.0;
714  int trackerHitsCut = 8;
715  float dxyCut = 2.0;
716  float dzCut = 24.0;
717  float chi2Cut = 4.0;
718 
719  bool selected = false;
721 
722  selected =
723  ((track.pt() > ptCut) && (std::abs(track.eta()) > 0.75) && (std::abs(track.eta()) < 2.55) &&
724  (track.numberOfValidHits() >= trackerHitsCut) && (track.dxy() < dxyCut) && (std::abs(track.dz()) < dzCut) &&
725  (track.normalizedChi2() > 0.0) && (track.normalizedChi2() < chi2Cut) && _trackIso < 0.1);
726 
727  return selected;
728 }
729 
731  bool selected = false;
732 
733  _zMass = zMass(track, muon);
734  selected = (track.charge() * muon.charge() == -1 && (_zMass > 75.0) && (_zMass < 120.0));
735 
736  return selected;
737 }
738 
739 // get track position at a particular (xy) plane given its z
741  Plane::PositionType pos(0, 0, z);
744 
746  TrajectoryStateOnSurface recoProp = propagatorAlong->propagate(recoStart, *myPlane);
747 
748  if (!recoProp.isValid())
749  recoProp = propagatorOpposite->propagate(recoStart, *myPlane);
750 
751  return recoProp;
752 }
753 
755  //no track extras in nanoaod so directly use vx and p
756  GlobalPoint innerPoint(track.vx(), track.vy(), track.vz());
757  GlobalVector innerVec(track.px(), track.py(), track.pz());
758 
759  GlobalTrajectoryParameters gtPars(innerPoint, innerVec, track.charge(), &*theBField);
760 
762  cov *= 1e-20;
763 
764  CartesianTrajectoryError tCov(cov);
765 
766  return (cov.kRows == 6 ? FreeTrajectoryState(gtPars, tCov) : FreeTrajectoryState(gtPars));
767 }
768 
769 UChar_t MuCSCTnPFlatTableProducer::ringCandidate(Int_t iiStation, Int_t station, Float_t feta, Float_t phi) {
770  UChar_t ring = 0;
771 
772  switch (station) {
773  case 1:
774  if (std::abs(feta) >= 0.85 && std::abs(feta) < 1.18) { //ME13
775  if (iiStation == 2)
776  ring = 3;
777  return ring;
778  }
779  if (std::abs(feta) >= 1.18 &&
780  std::abs(feta) <= 1.5) { //ME12 if(std::abs(feta)>1.18 && std::abs(feta)<1.7){//ME12
781  if (iiStation == 1)
782  ring = 2;
783  return ring;
784  }
785  if (std::abs(feta) > 1.5 && std::abs(feta) < 2.1) { //ME11
786  if (iiStation == 0)
787  ring = 1;
788  return ring;
789  }
790  if (std::abs(feta) >= 2.1 && std::abs(feta) < 2.45) { //ME11
791  if (iiStation == 0)
792  ring = 4;
793  return ring;
794  }
795  break;
796  case 2:
797  if (std::abs(feta) > 0.95 && std::abs(feta) < 1.6) { //ME22
798  ring = 2;
799  return ring;
800  }
801  if (std::abs(feta) > 1.55 && std::abs(feta) < 2.45) { //ME21
802  ring = 1;
803  return ring;
804  }
805  break;
806  case 3:
807  if (std::abs(feta) > 1.08 && std::abs(feta) < 1.72) { //ME32
808  ring = 2;
809  return ring;
810  }
811  if (std::abs(feta) > 1.69 && std::abs(feta) < 2.45) { //ME31
812  ring = 1;
813  return ring;
814  }
815  break;
816  case 4:
817  if (std::abs(feta) > 1.78 && std::abs(feta) < 2.45) { //ME41
818  ring = 1;
819  return ring;
820  }
821  if (std::abs(feta) > 1.15 && std::abs(feta) <= 1.78) { //ME42
822  ring = 2;
823  return ring;
824  }
825  break;
826  default:
827  edm::LogError("") << "Invalid station: " << station << std::endl;
828  break;
829  }
830  return 0;
831 }
832 
834  // cout <<"\t\t TPTrackMuonSys::thisChamberCandidate..."<<endl;
835 
836  //search for chamber candidate based on CMS IN-2007/024
837  //10 deg chambers are ME1,ME22,ME32,ME42 chambers; 20 deg chambers are ME21,31,41 chambers
838  //Chambers one always starts from approx -5 deg.
839  const UChar_t nVal = (station > 1 && ring == 1) ? 18 : 36;
840  const Float_t ChamberSpan = 2 * M_PI / nVal;
841  Float_t dphi = phi + M_PI / 36;
842  while (dphi >= 2 * M_PI)
843  dphi -= 2 * M_PI;
844  while (dphi < 0)
845  dphi += 2 * M_PI;
846  UChar_t ChCand = floor(dphi / ChamberSpan) + 1;
847  return ChCand > nVal ? nVal : ChCand;
848 }
849 
852  if (!TrajSuf.isValid())
853  return 9999.;
854  const GeomDet* gdet = m_cscGeometry->idToDet((CSCDetId)(*segIt).cscDetId());
855  LocalPoint localTTPos = gdet->surface().toLocal(TrajSuf.freeState()->position());
856  LocalPoint localSegPos = (*segIt).localPosition();
857  Float_t CSCdeltaX = localSegPos.x() - localTTPos.x();
858  Float_t CSCdeltaY = localSegPos.y() - localTTPos.y();
859  return sqrt(pow(CSCdeltaX, 2) + pow(CSCdeltaY, 2));
860 }
861 
865  CSCDetId& idCSC) {
866  TrajectoryStateOnSurface* TrajSuf = nullptr;
867  Float_t deltaCSCR = 9999.;
868  for (CSCSegmentCollection::const_iterator segIt = cscSegments->begin(); segIt != cscSegments->end(); segIt++) {
869  CSCDetId id = (CSCDetId)(*segIt).cscDetId();
870 
871  if (idCSC.endcap() != id.endcap())
872  continue;
873  if (idCSC.station() != id.station())
874  continue;
875  if (idCSC.chamber() != id.chamber())
876  continue;
877 
878  Bool_t ed1 =
879  (idCSC.station() == 1) && ((idCSC.ring() == 1 || idCSC.ring() == 4) && (id.ring() == 1 || id.ring() == 4));
880  Bool_t ed2 =
881  (idCSC.station() == 1) && ((idCSC.ring() == 2 && id.ring() == 2) || (idCSC.ring() == 3 && id.ring() == 3));
882  Bool_t ed3 = (idCSC.station() != 1) && (idCSC.ring() == id.ring());
883  Bool_t TMCSCMatch = (ed1 || ed2 || ed3);
884 
885  if (!TMCSCMatch)
886  continue;
887 
888  const CSCChamber* cscchamber = m_cscGeometry->chamber(id);
889 
890  if (!cscchamber)
891  continue;
892 
893  TrajectoryStateOnSurface TrajSuf_ = surfExtrapTrkSam(track, cscchamber->toGlobal((*segIt).localPosition()).z());
894  Float_t dR_ = std::abs(TrajectoryDistToSeg(TrajSuf_, segIt));
895  if (dR_ < deltaCSCR) {
896  delete TrajSuf;
897  TrajSuf = new TrajectoryStateOnSurface(TrajSuf_);
898  deltaCSCR = dR_;
899  cscSegOut = segIt;
900  }
901  } //loop over segments
902 
903  return TrajSuf;
904 }
905 
907  std::vector<Float_t> result(4, 9999.);
908  result[3] = -9999;
909  const GeomDet* gdet = m_cscGeometry->idToDet(detid);
911  if (!tsos.isValid())
912  return result;
913  LocalPoint localTTPos = gdet->surface().toLocal(tsos.freeState()->position());
914  const CSCWireTopology* wireTopology = m_cscGeometry->layer(detid)->geometry()->wireTopology();
915  Float_t wideWidth = wireTopology->wideWidthOfPlane();
916  Float_t narrowWidth = wireTopology->narrowWidthOfPlane();
917  Float_t length = wireTopology->lengthOfPlane();
918  // If slanted, there is no y offset between local origin and symmetry center of wire plane
919  Float_t yOfFirstWire = std::abs(wireTopology->wireAngle()) > 1.E-06 ? -0.5 * length : wireTopology->yOfWire(1);
920  // y offset between local origin and symmetry center of wire plane
921  Float_t yCOWPOffset = yOfFirstWire + 0.5 * length;
922  // tangent of the incline angle from inside the trapezoid
923  Float_t tangent = (wideWidth - narrowWidth) / (2. * length);
924  // y position wrt bottom of trapezoid
925  Float_t yPrime = localTTPos.y() + std::abs(yOfFirstWire);
926  // half trapezoid width at y' is 0.5 * narrowWidth + x side of triangle with the above tangent and side y'
927  Float_t halfWidthAtYPrime = 0.5 * narrowWidth + yPrime * tangent;
928  // x offset between local origin and symmetry center of wire plane is zero
929  // x offset of ME11s is also zero. x center of wire groups is not at zero, because it is not parallel to x. The wire groups of ME11s have a complex geometry, see the code in m_debug.
930  Float_t edgex = std::abs(localTTPos.x()) - halfWidthAtYPrime;
931  Float_t edgey = std::abs(localTTPos.y() - yCOWPOffset) - 0.5 * length;
932  LocalError localTTErr = tsos.localError().positionError();
933  if (edgex > edgey) {
934  result[0] = edgex;
935  result[1] = sqrt(localTTErr.xx());
936  //result[1] = sqrt(tsos.cartesianError().position().cxx());
937  } else {
938  result[0] = edgey;
939  result[1] = sqrt(localTTErr.yy());
940  //result[1] = sqrt(tsos.cartesianError().position().cyy());
941  }
942  result[2] = YDistToHVDeadZone(localTTPos.y(), detid.station() * 10 + detid.ring());
943  result[3] = sqrt(localTTErr.yy());
944  return result; //return values: 1-edge;2-err of edge;3-disttogap;4-err of dist to gap
945 }
946 
947 //deadzone center is according to http://cmssdt.cern.ch/SDT/lxr/source/RecoLocalMuon/CSCEfficiency/src/CSCEfficiency.cc#605
948 //wire spacing is according to CSCTDR
949 Float_t MuCSCTnPFlatTableProducer::YDistToHVDeadZone(Float_t yLocal, Int_t StationAndRing) {
950  //the ME11 wires are not parallel to x, but no gap
951  //chamber edges are not included.
952  const Float_t deadZoneCenterME1_2[2] = {-32.88305, 32.867423};
953  const Float_t deadZoneCenterME1_3[2] = {-22.7401, 27.86665};
954  const Float_t deadZoneCenterME2_1[2] = {-27.47, 33.67};
955  const Float_t deadZoneCenterME3_1[2] = {-36.21, 23.68};
956  const Float_t deadZoneCenterME4_1[2] = {-26.14, 23.85};
957  const Float_t deadZoneCenterME234_2[4] = {-81.8744, -21.18165, 39.51105, 100.2939};
958  const Float_t* deadZoneCenter;
959  Float_t deadZoneHeightHalf = 0.32 * 7 / 2; // wire spacing * (wires missing + 1)/2
960  Float_t minY = 999999.;
961  UChar_t nGaps = 2;
962  switch (std::abs(StationAndRing)) {
963  case 11:
964  case 14:
965  return 162; //the height of ME11
966  break;
967  case 12:
968  deadZoneCenter = deadZoneCenterME1_2;
969  break;
970  case 13:
971  deadZoneCenter = deadZoneCenterME1_3;
972  break;
973  case 21:
974  deadZoneCenter = deadZoneCenterME2_1;
975  break;
976  case 31:
977  deadZoneCenter = deadZoneCenterME3_1;
978  break;
979  case 41:
980  deadZoneCenter = deadZoneCenterME4_1;
981  break;
982  default:
983  deadZoneCenter = deadZoneCenterME234_2;
984  nGaps = 4;
985  }
986  for (UChar_t iGap = 0; iGap < nGaps; iGap++) {
987  Float_t newMinY = yLocal < deadZoneCenter[iGap] ? deadZoneCenter[iGap] - deadZoneHeightHalf - yLocal
988  : yLocal - (deadZoneCenter[iGap] + deadZoneHeightHalf);
989  if (newMinY < minY)
990  minY = newMinY;
991  }
992  return minY;
993 }
994 
995 double MuCSCTnPFlatTableProducer::iso(const reco::Track& track, edm::Handle<std::vector<reco::Track>> tracks) {
996  double isoSum = 0.0;
997  for (const auto& track2 : (*tracks)) {
998  double dR = calcDeltaR(track.eta(), track2.eta(), track.phi(), track2.phi());
999  if (track2.pt() > 1.0 && dR > 0.001 && dR < 0.3)
1000  isoSum += track2.pt();
1001  }
1002  return isoSum / track.pt();
1003 }
1004 
1005 double MuCSCTnPFlatTableProducer::calcDeltaR(double eta1, double eta2, double phi1, double phi2) {
1006  double deta = eta1 - eta2;
1007  if (phi1 < 0)
1008  phi1 += 2.0 * M_PI;
1009  if (phi2 < 0)
1010  phi2 += 2.0 * M_PI;
1011  double dphi = phi1 - phi2;
1012  if (dphi > M_PI)
1013  dphi -= 2. * M_PI;
1014  else if (dphi < -M_PI)
1015  dphi += 2. * M_PI;
1016  return std::sqrt(deta * deta + dphi * dphi);
1017 }
1018 
1020  double zMass = -99.0;
1021  double mMu = 0.1134289256;
1022 
1023  zMass = std::pow((std::sqrt(std::pow(muon.p(), 2) + mMu * mMu) + std::sqrt(std::pow(track.p(), 2) + mMu * mMu)), 2) -
1024  (std::pow((muon.px() + track.px()), 2) + std::pow((muon.py() + track.py()), 2) +
1025  std::pow((muon.pz() + track.pz()), 2));
1026 
1027  return std::sqrt(zMass);
1028 }
1029 
1032 
nano_mu::EDTokenHandle< std::vector< reco::Vertex > > m_primaryVerticesToken
const std::string & triggerName(unsigned int triggerIndex) const
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
edm::ESHandle< Propagator > propagatorOpposite
nano_mu::ESTokenHandle< TransientTrackBuilder, TransientTrackRecord > m_transientTrackBuilder
Transient Track Builder.
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
Definition: CSCChamber.cc:30
TrajectoryStateOnSurface surfExtrapTrkSam(const reco::Track &, double)
edm::ESHandle< MagneticField > theBField
FreeTrajectoryState freeTrajStateMuon(const reco::Track &)
double wideWidthOfPlane() const
static constexpr Float_t MEZ[6]
const LocalTrajectoryError & localError() const
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:100
const CSCWireTopology * wireTopology() const
T z() const
Definition: PV3DBase.h:61
double calcDeltaR(double, double, double, double)
void getFromES(const edm::Run &, const edm::EventSetup &) final
Get info from the ES by run.
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Float_t TrajectoryDistToSeg(TrajectoryStateOnSurface, CSCSegmentCollection::const_iterator)
T eta() const
Definition: PV3DBase.h:73
dictionary config
Read in AllInOne config in JSON format.
Definition: DMR_cfg.py:21
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
constexpr int pow(int x)
Definition: conifer.h:24
Definition: config.py:1
auto conditionalGet(const edm::Event &ev) const
Definition: MuNtupleUtils.h:49
Log< level::Error, false > LogError
LocalError positionError() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
LocalPoint toLocal(const GlobalPoint &gp) const
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
UChar_t ringCandidate(Int_t iiStation, Int_t station, Float_t feta, Float_t phi)
float float float z
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:44
static PlanePointer build(Args &&... args)
Definition: Plane.h:33
GlobalPoint position() const
void addColumn(std::unique_ptr< nanoaod::FlatTable > &table, const std::string name, const std::vector< T > &vec, const std::string descr)
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:21
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
float yy() const
Definition: LocalError.h:24
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
float wireAngle() const override
double iso(const reco::Track &, edm::Handle< std::vector< reco::Track >>)
UChar_t thisChamberCandidate(UChar_t station, UChar_t ring, Float_t phi)
float strip(const LocalPoint &lp) const
GlobalPoint globalPosition() const
bool muonTagSelection(const reco::Muon &)
unsigned int size() const
number of trigger paths in trigger table
T sqrt(T t)
Definition: SSEVec.h:19
nano_mu::EDTokenHandle< CSCSegmentCollection > m_cscSegmentToken
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
float computePFIso(const reco::MuonPFIsolation &, float)
nano_mu::ESTokenHandle< CSCGeometry, MuonGeometryRecord, edm::Transition::BeginRun > m_cscGeometry
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int chamber() const
Definition: CSCDetId.h:62
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::string m_trigName
Name of the triggers used by muon filler for trigger matching.
nano_mu::EDTokenHandle< edm::TriggerResults > m_trigResultsToken
static std::string const triggerResults
Definition: EdmProvDump.cc:47
int nearestWire(const LocalPoint &lp) const
nano_mu::EDTokenHandle< reco::MuonCollection > m_muToken
Tokens.
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
std::vector< Float_t > GetEdgeAndDistToGap(const reco::Track &, CSCDetId &)
#define M_PI
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
Float_t YDistToHVDeadZone(Float_t, Int_t)
TrajectoryStateOnSurface * matchTTwithCSCSeg(const reco::Track &, edm::Handle< CSCSegmentCollection >, CSCSegmentCollection::const_iterator &, CSCDetId &)
float yOfWire(float wire, float x=0.) const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
bool zSelection(const reco::Muon &, const reco::Track &)
const PositionType & position() const
int station() const
Definition: CSCDetId.h:79
bool trackProbeSelection(const reco::Track &track, edm::Handle< std::vector< reco::Track >>)
Selection functions.
bool isValid()
Check validity.
Definition: MuNtupleUtils.h:76
std::vector< size_type > Keys
void fillTable(edm::Event &) final
Fill tree branches for a given events.
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
float computeTrkIso(const reco::MuonIsolation &, float)
std::string m_name
The label name of the FlatTableProducer.
int endcap() const
Definition: CSCDetId.h:85
double lengthOfPlane() const
static void fillDescriptions(edm::ConfigurationDescriptions &)
Fill descriptors.
void getFromES(const edm::EventSetup &environment)
Get Handle from ES.
Definition: MuNtupleUtils.h:73
double narrowWidthOfPlane() const
std::unique_ptr< MuonServiceProxy > m_muonSP
Muon service proxy.
nano_mu::EDTokenHandle< trigger::TriggerEvent > m_trigEventToken
edm::ESHandle< Propagator > propagatorAlong
FreeTrajectoryState const * freeState(bool withErrors=true) const
isoSum
===> compute the isolation and find the most isolated track
int ring() const
Definition: CSCDetId.h:68
double zMass(const reco::Track &, const reco::Muon &)
MuCSCTnPFlatTableProducer(const edm::ParameterSet &)
Constructor.
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
Definition: CSCGeometry.cc:105
std::vector< int > m_trigIndices
Indices of the triggers used by muon filler for trigger matching.
std::vector< int > Vids
bool hasTrigger(std::vector< int > &, const trigger::TriggerObjectCollection &, edm::Handle< trigger::TriggerEvent > &, const reco::Muon &)
float xx() const
Definition: LocalError.h:22
def move(src, dest)
Definition: eostools.py:511
HLTConfigProvider m_hltConfig
HLT config provider.
nano_mu::EDTokenHandle< reco::TrackCollection > m_trackToken
Definition: Run.h:45
const GeomDet * idToDet(DetId) const override
Definition: CSCGeometry.cc:91