83 static constexpr Float_t
MEZ[6] = {601.3, 696.11, 696.11, 827.56, 936.44, 1025.9};
131 double calcDeltaR(
double,
double,
double,
double);
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"},
177 m_cscGeometry{consumesCollector()},
179 consumesCollector())},
180 m_transientTrackBuilder{consumesCollector(),
"TransientTrackBuilder"} {
181 produces<nanoaod::FlatTable>();
199 desc.setAllowAnything();
210 const bool enableWildcard{
true};
213 TRegexp tNamePattern = TRegexp(
tName, enableWildcard);
217 if (
pathName.Contains(tNamePattern))
222 tNamePattern = TRegexp(
tName, enableWildcard);
226 if (
pathName.Contains(tNamePattern))
240 std::vector<float> m_muonPt;
241 std::vector<float> m_muonPhi;
242 std::vector<float> m_muonEta;
243 std::vector<float> m_muonPtError;
244 std::vector<float> m_muonPhiError;
245 std::vector<float> m_muonEtaError;
246 std::vector<int> m_muonCharge;
247 std::vector<float> m_muonDXY;
248 std::vector<float> m_muonDZ;
249 std::vector<int> m_muonTrkHits;
250 std::vector<float> m_muonChi2;
251 std::vector<bool> m_muonTrigger;
252 std::vector<float> m_muonIso;
255 std::vector<float> m_trackPt;
256 std::vector<float> m_trackP;
257 std::vector<float> m_trackPhi;
258 std::vector<float> m_trackEta;
259 std::vector<float> m_trackPtError;
260 std::vector<float> m_trackPhiError;
261 std::vector<float> m_trackEtaError;
262 std::vector<int> m_trackCharge;
263 std::vector<float> m_trackDXY;
264 std::vector<float> m_trackDZ;
265 std::vector<int> m_trackTrkHits;
266 std::vector<float> m_trackChi2;
267 std::vector<float> m_trackIso;
270 std::vector<float> m_zMass;
271 std::vector<float> m_dRTrackMuon;
272 std::vector<float> m_numberOfPrimaryVertices;
275 std::vector<int> m_chamberEndcap;
277 std::array<std::vector<int>, 4> m_chamberRing;
278 std::array<std::vector<int>, 4> m_chamberChamber;
279 std::array<std::vector<int>, 4> m_chamberLayer;
282 std::array<std::vector<float>, 4> m_ttIntLocalX;
283 std::array<std::vector<float>, 4> m_ttIntLocalY;
284 std::array<std::vector<float>, 4> m_ttIntLocalErrorX;
285 std::array<std::vector<float>, 4> m_ttIntLocalErrorY;
286 std::array<std::vector<float>, 4> m_ttIntLocalW;
287 std::array<std::vector<float>, 4> m_ttIntLocalS;
288 std::array<std::vector<float>, 4> m_ttIntEta;
292 std::array<std::vector<float>, 4>
294 std::array<std::vector<float>, 4> m_ttDistToHVGap;
297 std::array<std::vector<float>, 4> m_segLocalX;
298 std::array<std::vector<float>, 4> m_segLocalY;
299 std::array<std::vector<float>, 4> m_segLocalErrorX;
300 std::array<std::vector<float>, 4> m_segLocalErrorY;
303 std::array<std::vector<float>, 4>
304 m_ttIntSegResidualLocalX;
305 std::array<std::vector<float>, 4>
306 m_ttIntSegResidualLocalY;
308 auto&& propagator_along =
m_muonSP->propagator(
"SteppingHelixPropagatorAlong");
309 auto&& propagator_opposite =
m_muonSP->propagator(
"SteppingHelixPropagatorOpposite");
330 bool muonTrigger =
false;
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());
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());
372 m_muonTrigger.push_back(muonTrigger);
374 m_zMass.push_back(
_zMass);
377 m_dRTrackMuon.push_back(
dR);
379 m_numberOfPrimaryVertices.push_back(
vertices.size());
381 bool ec = (
track.eta() > 0);
382 UChar_t endcapCSC = ec ? 0 : 1;
383 m_chamberEndcap.push_back(endcapCSC * 1);
385 Int_t iiStationFail = 0;
386 for (
int iiStationZ = 0; iiStationZ < 6; iiStationZ++) {
387 UChar_t stationCSC = iiStationZ > 2 ? iiStationZ - 2 : 0;
397 CSCDetId Layer3id =
CSCDetId(endcapCSC + 1, stationCSC + 1, ringCSC, chamberCSC + 1, 3);
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(
421 m_ttIntLocalS[stationCSC].push_back(
422 (layerGeoma->
strip(localTTIntPoint) + layerGeomb->
strip(localTTIntPoint)) / 2.0);
423 m_ttIntEta[stationCSC].push_back(
trkEta);
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);
434 if (EdgeAndDistToGap[0] > CSCProjEdgeDist) {
435 CSCProjEdgeDist = EdgeAndDistToGap[0];
436 ttIntLocalErrorX = EdgeAndDistToGap[1];
438 if (EdgeAndDistToGap[2] < CSCDyProjHVGap) {
439 CSCDyProjHVGap = EdgeAndDistToGap[2];
440 ttIntLocalErrorY = EdgeAndDistToGap[3];
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);
452 if (TrajToSeg ==
nullptr) {
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);
459 m_ttIntSegResidualLocalX[stationCSC].push_back(-9990.0);
460 m_ttIntSegResidualLocalY[stationCSC].push_back(-9990.0);
462 m_chamberLayer[stationCSC].push_back(-9);
467 LocalPoint localSegmentPoint = (*cscSegOut).localPosition();
468 LocalError localSegErr = (*cscSegOut).localPositionError();
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()));
475 m_ttIntSegResidualLocalX[stationCSC].push_back(localTTIntPoint.
x() - localSegmentPoint.
x());
476 m_ttIntSegResidualLocalY[stationCSC].push_back(localTTIntPoint.
y() - localSegmentPoint.
y());
479 for (std::vector<CSCRecHit2D>::const_iterator itRH = cscSegOut->specificRecHits().begin();
480 itRH != cscSegOut->specificRecHits().end();
486 m_chamberLayer[stationCSC].push_back(
layers);
494 if ((!tsos.
isValid()) || (ringCSC == 0)) {
498 if (iiStationZ > 2 || iiStationFail == 3) {
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);
510 m_ttDistToEdge[stationCSC].push_back(-9999.0);
511 m_ttDistToHVGap[stationCSC].push_back(-9999.9);
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);
518 m_ttIntSegResidualLocalX[stationCSC].push_back(-9990.0);
519 m_ttIntSegResidualLocalY[stationCSC].push_back(-9990.0);
521 m_chamberLayer[stationCSC].push_back(-9);
534 table->setDoc(
"CSC Tag & Probe segment efficiency information");
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");
545 addColumn(
table,
"muonTrkHits", m_muonTrkHits,
"muon track hits");
548 addColumn(
table,
"muonTrigger", m_muonTrigger,
"muon has trigger bool");
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");
560 addColumn(
table,
"trackTrkHits", m_trackTrkHits,
"track track hits");
565 addColumn(
table,
"dRTrackMuon", m_dRTrackMuon,
"dR between track and muon");
566 addColumn(
table,
"numberOfPrimaryVertidies", m_numberOfPrimaryVertices,
"Number of PVs");
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],
"");
664 for (
int trigIdx : trigIndices) {
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()) {
673 const unsigned nTriggers = vids.size();
675 for (
unsigned iTrig = 0; iTrig < nTriggers; ++iTrig) {
690 int trackerHitsCut = 8;
695 bool selected =
false;
699 if (!
muon.isTrackerMuon())
701 if (!
muon.track().isNonnull())
704 ((
muon.track()->pt() >
ptCut) && (
muon.track()->hitPattern().numberOfValidTrackerHits() >= trackerHitsCut) &&
714 int trackerHitsCut = 8;
719 bool selected =
false;
731 bool selected =
false;
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)
846 UChar_t ChCand = floor(dphi / ChamberSpan) + 1;
847 return ChCand > nVal ? nVal : ChCand;
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));
867 Float_t deltaCSCR = 9999.;
871 if (idCSC.
endcap() !=
id.endcap())
873 if (idCSC.
station() !=
id.station())
875 if (idCSC.
chamber() !=
id.chamber())
879 (idCSC.
station() == 1) && ((idCSC.
ring() == 1 || idCSC.
ring() == 4) && (
id.
ring() == 1 ||
id.ring() == 4));
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);
895 if (dR_ < deltaCSCR) {
907 std::vector<Float_t>
result(4, 9999.);
921 Float_t yCOWPOffset = yOfFirstWire + 0.5 * length;
923 Float_t tangent = (wideWidth - narrowWidth) / (2. * length);
925 Float_t yPrime = localTTPos.
y() +
std::abs(yOfFirstWire);
927 Float_t halfWidthAtYPrime = 0.5 * narrowWidth + yPrime * tangent;
930 Float_t edgex =
std::abs(localTTPos.
x()) - halfWidthAtYPrime;
931 Float_t edgey =
std::abs(localTTPos.
y() - yCOWPOffset) - 0.5 * length;
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;
960 Float_t
minY = 999999.;
968 deadZoneCenter = deadZoneCenterME1_2;
971 deadZoneCenter = deadZoneCenterME1_3;
974 deadZoneCenter = deadZoneCenterME2_1;
977 deadZoneCenter = deadZoneCenterME3_1;
980 deadZoneCenter = deadZoneCenterME4_1;
983 deadZoneCenter = deadZoneCenterME234_2;
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);
997 for (
const auto& track2 : (*
tracks)) {
999 if (track2.pt() > 1.0 &&
dR > 0.001 &&
dR < 0.3)
1011 double dphi = phi1 - phi2;
1014 else if (dphi < -
M_PI)
1016 return std::sqrt(deta * deta + dphi * dphi);
1020 double zMass = -99.0;
1021 double mMu = 0.1134289256;
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.
TrajectoryStateOnSurface surfExtrapTrkSam(const reco::Track &, double)
edm::ESHandle< MagneticField > theBField
FreeTrajectoryState freeTrajStateMuon(const reco::Track &)
double wideWidthOfPlane() const
static constexpr Float_t MEZ[6]
std::vector< int > m_isoTrigIndices
const LocalTrajectoryError & localError() const
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
const CSCWireTopology * wireTopology() const
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
Float_t TrajectoryDistToSeg(TrajectoryStateOnSurface, CSCSegmentCollection::const_iterator)
dictionary config
Read in AllInOne config in JSON format.
std::vector< Vertex > VertexCollection
collection of Vertex objects
auto conditionalGet(const edm::Event &ev) const
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)
LocalPoint toLocal(const GlobalPoint &gp) const
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
UChar_t ringCandidate(Int_t iiStation, Int_t station, Float_t feta, Float_t phi)
const CSCLayerGeometry * geometry() const
static PlanePointer build(Args &&... args)
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)
C::const_iterator const_iterator
constant access iterator type
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
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)
#define DEFINE_FWK_MODULE(type)
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
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.
std::vector< Float_t > GetEdgeAndDistToGap(const reco::Track &, CSCDetId &)
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)
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.
bool zSelection(const reco::Muon &, const reco::Track &)
const PositionType & position() const
bool trackProbeSelection(const reco::Track &track, edm::Handle< std::vector< reco::Track >>)
Selection functions.
bool isValid()
Check validity.
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'tor
float computeTrkIso(const reco::MuonIsolation &, float)
std::string m_name
The label name of the FlatTableProducer.
double lengthOfPlane() const
static void fillDescriptions(edm::ConfigurationDescriptions &)
Fill descriptors.
void getFromES(const edm::EventSetup &environment)
Get Handle from ES.
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
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.
std::vector< int > m_trigIndices
Indices of the triggers used by muon filler for trigger matching.
std::string m_isoTrigName
bool hasTrigger(std::vector< int > &, const trigger::TriggerObjectCollection &, edm::Handle< trigger::TriggerEvent > &, const reco::Muon &)
HLTConfigProvider m_hltConfig
HLT config provider.
nano_mu::EDTokenHandle< reco::TrackCollection > m_trackToken
const GeomDet * idToDet(DetId) const override