Fill tree branches for a given event.
101 std::vector<bool>
isCSC;
102 std::vector<bool> isME11;
104 std::vector<float> innermost_x;
105 std::vector<float> innermost_y;
106 std::vector<float> innermost_z;
108 std::vector<float> outermost_x;
109 std::vector<float> outermost_y;
110 std::vector<float> outermost_z;
112 unsigned int nProp{0};
114 std::vector<uint32_t> propagated_muIdx;
116 std::vector<bool> propagated_isincoming;
117 std::vector<bool> propagated_isinsideout;
118 std::vector<int8_t> propagated_region;
119 std::vector<int8_t> propagated_layer;
120 std::vector<int8_t> propagated_chamber;
121 std::vector<int8_t> propagated_etaP;
123 std::vector<float> propagatedLoc_x;
124 std::vector<float> propagatedLoc_y;
125 std::vector<float> propagatedLoc_z;
126 std::vector<float> propagatedLoc_r;
127 std::vector<float> propagatedLoc_phi;
128 std::vector<float> propagatedLoc_dirX;
129 std::vector<float> propagatedLoc_dirY;
130 std::vector<float> propagatedLoc_dirZ;
131 std::vector<float> propagatedLoc_errX;
132 std::vector<float> propagatedLoc_errY;
134 std::vector<float> propagatedGlb_x;
135 std::vector<float> propagatedGlb_y;
136 std::vector<float> propagatedGlb_z;
137 std::vector<float> propagatedGlb_r;
138 std::vector<float> propagatedGlb_phi;
139 std::vector<float> propagatedGlb_errX;
140 std::vector<float> propagatedGlb_errY;
141 std::vector<float> propagatedGlb_phierr;
142 std::vector<float> propagatedGlb_rerr;
144 std::vector<float> propagated_EtaPartition_centerX;
145 std::vector<float> propagated_EtaPartition_centerY;
146 std::vector<float> propagated_EtaPartition_phiMax;
147 std::vector<float> propagated_EtaPartition_phiMin;
148 std::vector<float> propagated_EtaPartition_rMax;
149 std::vector<float> propagated_EtaPartition_rMin;
151 std::vector<int8_t> propagated_nME1hits;
152 std::vector<int8_t> propagated_nME2hits;
153 std::vector<int8_t> propagated_nME3hits;
154 std::vector<int8_t> propagated_nME4hits;
159 auto&& propagator_any =
m_muonSP->propagator(
"SteppingHelixPropagatorAny");
160 auto&& propagator_along =
m_muonSP->propagator(
"SteppingHelixPropagatorAlong");
161 auto&& propagator_opposite =
m_muonSP->propagator(
"SteppingHelixPropagatorOpposite");
163 if (!propagator_any.isValid() || !propagator_along.isValid() || !propagator_opposite.isValid()) {
173 bool is_me11 =
false;
175 if (!
muon.outerTrack().isNull()) {
176 const auto track =
muon.outerTrack().get();
177 const auto outerTrackRef =
muon.outerTrack();
179 float p2_in =
track->innerMomentum().mag2();
180 float p2_out =
track->outerMomentum().mag2();
181 float pos_out =
track->outerPosition().mag2();
182 float pos_in =
track->innerPosition().mag2();
184 bool is_insideout = pos_in > pos_out;
191 bool is_incoming = p2_out > p2_in;
194 const auto& htp = transient_track.
hitPattern();
196 if (transient_track.isValid()) {
197 const auto innerPosGlb{transient_track.innermostMeasurementState().globalPosition()};
198 const auto outerPosGlb{transient_track.outermostMeasurementState().globalPosition()};
200 innermost_x.push_back(innerPosGlb.x());
201 innermost_y.push_back(innerPosGlb.y());
202 innermost_z.push_back(innerPosGlb.z());
203 outermost_x.push_back(outerPosGlb.x());
204 outermost_y.push_back(outerPosGlb.y());
205 outermost_z.push_back(outerPosGlb.z());
216 const auto&& start_state =
217 is_insideout ? transient_track.outermostMeasurementState() : transient_track.innermostMeasurementState();
218 auto&
propagator = is_incoming ? propagator_along : propagator_opposite;
220 auto recHitMu = outerTrackRef->recHitsBegin();
221 auto recHitMuEnd = outerTrackRef->recHitsEnd();
224 for (; recHitMu != recHitMuEnd; ++recHitMu) {
233 if (csc_id.station() == 1 && ((csc_id.ring() == 1) || (csc_id.ring() == 4)))
241 int8_t nME1_hits = 0;
242 int8_t nME2_hits = 0;
243 int8_t nME3_hits = 0;
244 int8_t nME4_hits = 0;
246 int nHits{htp.numberOfAllHits(htp.TRACK_HITS)};
249 uint32_t
hit = htp.getHitPattern(htp.TRACK_HITS,
i);
250 int substructure = htp.getSubStructure(
hit);
251 int hittype = htp.getHitType(
hit);
253 if (substructure == 2 && hittype == 0) {
254 int CSC_station = htp.getMuonStation(
hit);
256 switch (CSC_station) {
277 if (eta_partition->id().station() != 1) {
280 const GEMDetId&& gem_id = eta_partition->id();
282 bool is_opposite_region =
muon.eta() * gem_id.
region() < 0;
283 if (is_incoming xor is_opposite_region) {
286 const BoundPlane& bound_plane = eta_partition->surface();
288 const auto& dest_state =
propagator->propagate(start_state, bound_plane);
289 if (!dest_state.isValid()) {
293 const GlobalPoint&& dest_global_pos = dest_state.globalPosition();
294 const LocalPoint&& local_point = eta_partition->toLocal(dest_global_pos);
295 const LocalPoint local_point_2d{local_point.
x(), local_point.
y(), 0.0f};
297 if (eta_partition->surface().bounds().inside(local_point_2d)) {
300 double xx = dest_state.curvilinearError().matrix()(3, 3);
301 double yy = dest_state.curvilinearError().matrix()(4, 4);
302 double xy = dest_state.curvilinearError().matrix()(4, 3);
307 const LocalPoint&& dest_local_pos = eta_partition->toLocal(dest_global_pos);
308 const LocalError&& dest_local_err = dest_state.localError().positionError();
311 const double dest_global_r_err =
std::sqrt(dest_global_err.
rerr(dest_global_pos));
312 const double dest_global_phi_err =
std::sqrt(dest_global_err.
phierr(dest_global_pos));
316 propagated_muIdx.push_back(
nMuons - 1);
318 propagated_nME1hits.push_back(nME1_hits);
319 propagated_nME2hits.push_back(nME2_hits);
320 propagated_nME3hits.push_back(nME3_hits);
321 propagated_nME4hits.push_back(nME4_hits);
323 const auto& eta_partition_pos{eta_partition->position()};
324 const auto& eta_partition_surf{eta_partition->surface()};
325 propagated_EtaPartition_centerX.push_back(eta_partition_pos.x());
326 propagated_EtaPartition_centerY.push_back(eta_partition_pos.y());
327 propagated_EtaPartition_rMin.push_back(eta_partition_surf.rSpan().first);
328 propagated_EtaPartition_rMax.push_back(eta_partition_surf.rSpan().second);
329 propagated_EtaPartition_phiMin.push_back(eta_partition_surf.phiSpan().first);
330 propagated_EtaPartition_phiMax.push_back(eta_partition_surf.phiSpan().second);
332 propagatedGlb_x.push_back(dest_global_pos.
x());
333 propagatedGlb_y.push_back(dest_global_pos.
y());
334 propagatedGlb_z.push_back(dest_global_pos.
z());
335 propagatedGlb_r.push_back(dest_global_pos.
perp());
336 propagatedGlb_phi.push_back(dest_global_pos.
phi());
338 const auto dest_local_dir{dest_state.localDirection()};
339 propagatedLoc_x.push_back(dest_local_pos.
x());
340 propagatedLoc_y.push_back(dest_local_pos.
y());
341 propagatedLoc_z.push_back(dest_local_pos.
z());
342 propagatedLoc_r.push_back(dest_local_pos.
perp());
343 propagatedLoc_phi.push_back(dest_local_pos.
phi());
344 propagatedLoc_dirX.push_back(dest_local_dir.x());
345 propagatedLoc_dirY.push_back(dest_local_dir.y());
346 propagatedLoc_dirZ.push_back(dest_local_dir.z());
348 propagatedLoc_errX.push_back(dest_local_err.
xx());
349 propagatedLoc_errY.push_back(dest_local_err.
yy());
351 propagatedGlb_errX.push_back(dest_glob_error_x);
352 propagatedGlb_errY.push_back(dest_glob_error_y);
353 propagatedGlb_rerr.push_back(dest_global_r_err);
354 propagatedGlb_phierr.push_back(dest_global_phi_err);
356 propagated_region.push_back(gem_id.
region());
357 propagated_layer.push_back(gem_id.
layer());
358 propagated_chamber.push_back(gem_id.
chamber());
359 propagated_etaP.push_back(gem_id.
roll());
361 propagated_isinsideout.push_back(is_insideout);
362 propagated_isincoming.push_back(is_incoming);
375 isCSC.push_back(is_csc);
376 isME11.push_back(is_me11);
395 auto tabProp = std::make_unique<nanoaod::FlatTable>(nProp,
m_name +
"_propagated",
false,
false);
397 addColumn(tabProp,
"propagated_muIdx", propagated_muIdx,
"");
400 "propagated_nME1hits",
402 "number of hits in the CSC ME1 station" 403 "in the STA muon track extrapolated to GE11");
405 "propagated_nME2hits",
407 "number of hits in the CSC ME2 station" 408 "in the STA muon track extrapolated to GE11");
410 "propagated_nME3hits",
412 "number of hits in the CSC ME3 station" 413 "in the STA muon track extrapolated to GE11");
415 "propagated_nME4hits",
417 "number of hits in the CSC ME4 station" 418 "in the STA muon track extrapolated to GE11");
421 tabProp,
"propagated_isincoming", propagated_isincoming,
"bool, condition on the muon STA track direction");
423 tabProp,
"propagated_isinsideout", propagated_isinsideout,
"bool, condition on the muon STA track direction");
427 "GE11 region where the extrapolated muon track falls" 428 "<br />(int, positive endcap: +1, negative endcap: -1");
432 "GE11 layer where the extrapolated muon track falls" 433 "<br />(int, layer1: 1, layer2: 2");
435 "propagated_chamber",
437 "GE11 superchamber where the extrapolated muon track falls" 438 "<br />(int, chambers numbered from 0 to 35");
442 "GE11 eta partition where the extrapolated muon track falls" 443 "<br />(int, partitions numbered from 1 to 8");
448 "expected position of muon track extrapolated to GE11 surface" 449 "<br />(float, local layer x coordinates, cm)");
453 "expected position of muon track extrapolated to GE11 surface" 454 "<br />(float, local layer y coordinates, cm)");
458 "expected position of muon track extrapolated to GE11 surface" 459 "<br />(float, local layer z coordinates, cm)");
463 "expected position of muon track extrapolated to GE11 surface" 464 "<br />(float, local layer radial coordinate, cm)");
468 "expected position of muon track extrapolated to GE11 surface" 469 "<br />(float, local layer phi coordinates, rad)");
472 "propagatedLoc_dirX",
474 "direction cosine of angle between local x axis and GE11 plane" 475 "<br />(float, dir. cosine)");
477 "propagatedLoc_dirY",
479 "direction cosine of angle between local y axis and GE11 plane" 480 "<br />(float, dir. cosine)");
482 "propagatedLoc_dirZ",
484 "direction cosine of angle between local z axis and GE11 plane" 485 "<br />(float, dir. cosine)");
488 "propagatedLoc_errX",
490 "uncertainty on expected position of muon track extrapolated to GE11 surface" 491 "<br />(float, local layer x coordinates, cm)");
493 "propagatedLoc_errY",
495 "uncertainty on expected position of muon track extrapolated to GE11 surface" 496 "<br />(float, local layer y coordinates, cm)");
501 "expected position of muon track extrapolated to GE11 surface" 502 "<br />(float, global x coordinates, cm)");
506 "expected position of muon track extrapolated to GE11 surface" 507 "<br />(float, global y coordinates, cm)");
511 "expected position of muon track extrapolated to GE11 surface" 512 "<br />(float, global z coordinates, cm)");
516 "expected position of muon track extrapolated to GE11 surface" 517 "<br />(float, global radial (r) coordinates, cm)");
521 "expected position of muon track extrapolated to GE11 surface" 522 "<br />(float, global phi coordinates, rad)");
524 "propagatedGlb_errX",
526 "uncertainty on position of muon track extrapolated to GE11 surface" 527 "<br />(float, global x coordinates, cm)");
529 "propagatedGlb_errY",
531 "uncertainty on position of muon track extrapolated to GE11 surface" 532 "<br />(float, global y coordinates, cm)");
534 "propagatedGlb_rerr",
536 "uncertainty on position of muon track extrapolated to GE11 surface" 537 "<br />(float, global radial (r) coordinates, cm)");
539 "propagatedGlb_phierr",
540 propagatedGlb_phierr,
541 "uncertainty on position of muon track extrapolated to GE11 surface" 542 "<br />(float, global phi coordinates, rad)");
545 "propagated_EtaPartition_centerX",
546 propagated_EtaPartition_centerX,
547 "global X coordinate of the center of the etaPartition" 548 "<br />where the extrapolated muon track position falls" 549 "<br />(float, global x coordinates, cm)");
551 "propagated_EtaPartition_centerY",
552 propagated_EtaPartition_centerY,
553 "global Y coordinate of the center of the etaPartition" 554 "<br />where the extrapolated muon track position falls" 555 "<br />(float, global x coordinates, cm)");
557 "propagated_EtaPartition_phiMax",
558 propagated_EtaPartition_phiMax,
559 "upper edge in phi global coordinates of the etaPartition" 560 "<br />where the extrapolated muon track position falls" 561 "<br />(float, global phi coordinates, rad)");
563 "propagated_EtaPartition_phiMin",
564 propagated_EtaPartition_phiMin,
565 "lower edge in phi global coordinates of the etaPartition" 566 "<br />where the extrapolated muon track position falls" 567 "<br />(float, global phi coordinates, rad)");
569 "propagated_EtaPartition_rMax",
570 propagated_EtaPartition_rMax,
571 "upper edge in r global coordinates of the etaPartition" 572 "<br />where the extrapolated muon track position falls" 573 "<br />(float, global radial (r) coordinates, cm)");
575 "propagated_EtaPartition_rMin",
576 propagated_EtaPartition_rMin,
577 "lower edge in r global coordinates of the etaPartition" 578 "<br />where the extrapolated muon track position falls" 579 "<br />(float, global radial (r) coordinates, cm)");
std::unique_ptr< MuonServiceProxy > m_muonSP
Muon service proxy.
constexpr int region() const
Geom::Phi< T > phi() const
const HitPattern & hitPattern() const
auto conditionalGet(const edm::Event &ev) const
constexpr int layer() const
static constexpr double DEFAULT_DOUBLE_VAL
Definition of default values for float variables.
constexpr int chamber() const
void swap(Association< C > &lhs, Association< C > &rhs)
T phierr(const GlobalPoint &aPoint) const
reco::TransientTrack build(const reco::Track *p) const
void addColumn(std::unique_ptr< nanoaod::FlatTable > &table, const std::string name, const std::vector< T > &vec, const std::string descr)
nano_mu::ESTokenHandle< TransientTrackBuilder, TransientTrackRecord > m_transientTrackBuilder
Transient Track Builder.
bool m_fillPropagated
Fill matches table.
nano_mu::ESTokenHandle< GEMGeometry, MuonGeometryRecord, edm::Transition::BeginRun > m_gemGeometry
GEM Geometry.
bool isValid()
Check validity.
std::string m_name
The label name of the FlatTableProducer.
constexpr int roll() const
bool isCSC(GeomDetEnumerators::SubDetector m)
T rerr(const GlobalPoint &aPoint) const
TupleMultiplicity< TrackerTraits > const *__restrict__ uint32_t nHits
nano_mu::EDTokenHandle< edm::View< reco::Muon > > m_token
The RECO mu token.
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM eta partitions.