81 static constexpr Float_t
MEZ[6] = {601.3, 696.11, 696.11, 827.56, 936.44, 1025.9};
129 double calcDeltaR(
double,
double,
double,
double);
167 m_muToken{
config, consumesCollector(),
"muonSrc"},
168 m_trackToken{
config, consumesCollector(),
"trackSrc"},
169 m_cscSegmentToken{
config, consumesCollector(),
"cscSegmentSrc"},
170 m_primaryVerticesToken{
config, consumesCollector(),
"primaryVerticesSrc"},
171 m_trigResultsToken{
config, consumesCollector(),
"trigResultsSrc"},
172 m_trigEventToken{
config, consumesCollector(),
"trigEventSrc"},
175 m_cscGeometry{consumesCollector()},
177 consumesCollector())},
178 m_transientTrackBuilder{consumesCollector(),
"TransientTrackBuilder"} {
179 produces<nanoaod::FlatTable>();
197 desc.setAllowAnything();
208 const bool enableWildcard{
true};
211 TRegexp tNamePattern = TRegexp(
tName, enableWildcard);
215 if (
pathName.Contains(tNamePattern))
220 tNamePattern = TRegexp(
tName, enableWildcard);
224 if (
pathName.Contains(tNamePattern))
238 std::vector<float> m_muonPt;
239 std::vector<float> m_muonPhi;
240 std::vector<float> m_muonEta;
241 std::vector<float> m_muonPtError;
242 std::vector<float> m_muonPhiError;
243 std::vector<float> m_muonEtaError;
244 std::vector<int> m_muonCharge;
245 std::vector<float> m_muonDXY;
246 std::vector<float> m_muonDZ;
247 std::vector<int> m_muonTrkHits;
248 std::vector<float> m_muonChi2;
249 std::vector<bool> m_muonTrigger;
250 std::vector<float> m_muonIso;
253 std::vector<float> m_trackPt;
254 std::vector<float> m_trackP;
255 std::vector<float> m_trackPhi;
256 std::vector<float> m_trackEta;
257 std::vector<float> m_trackPtError;
258 std::vector<float> m_trackPhiError;
259 std::vector<float> m_trackEtaError;
260 std::vector<int> m_trackCharge;
261 std::vector<float> m_trackDXY;
262 std::vector<float> m_trackDZ;
263 std::vector<int> m_trackTrkHits;
264 std::vector<float> m_trackChi2;
265 std::vector<float> m_trackIso;
268 std::vector<float> m_zMass;
269 std::vector<float> m_dRTrackMuon;
270 std::vector<float> m_numberOfPrimaryVertices;
273 std::vector<int> m_chamberEndcap;
275 std::array<std::vector<int>, 4> m_chamberRing;
276 std::array<std::vector<int>, 4> m_chamberChamber;
277 std::array<std::vector<int>, 4> m_chamberLayer;
280 std::array<std::vector<float>, 4> m_ttIntLocalX;
281 std::array<std::vector<float>, 4> m_ttIntLocalY;
282 std::array<std::vector<float>, 4> m_ttIntLocalErrorX;
283 std::array<std::vector<float>, 4> m_ttIntLocalErrorY;
284 std::array<std::vector<float>, 4> m_ttIntLocalW;
285 std::array<std::vector<float>, 4> m_ttIntLocalS;
286 std::array<std::vector<float>, 4> m_ttIntEta;
290 std::array<std::vector<float>, 4>
292 std::array<std::vector<float>, 4> m_ttDistToHVGap;
295 std::array<std::vector<float>, 4> m_segLocalX;
296 std::array<std::vector<float>, 4> m_segLocalY;
297 std::array<std::vector<float>, 4> m_segLocalErrorX;
298 std::array<std::vector<float>, 4> m_segLocalErrorY;
301 std::array<std::vector<float>, 4>
302 m_ttIntSegResidualLocalX;
303 std::array<std::vector<float>, 4>
304 m_ttIntSegResidualLocalY;
306 auto&& propagator_along =
m_muonSP->propagator(
"SteppingHelixPropagatorAlong");
307 auto&& propagator_opposite =
m_muonSP->propagator(
"SteppingHelixPropagatorOpposite");
328 bool muonTrigger =
false;
344 m_trackPt.push_back(
track.pt());
345 m_trackP.push_back(
track.p());
346 m_trackEta.push_back(
track.eta());
347 m_trackPhi.push_back(
track.phi());
348 m_trackPtError.push_back(
track.pt());
349 m_trackEtaError.push_back(
track.eta());
350 m_trackPhiError.push_back(
track.phi());
351 m_trackCharge.push_back(
track.charge());
352 m_trackDXY.push_back(
track.dxy());
353 m_trackDZ.push_back(
track.dz());
354 m_trackTrkHits.push_back(
track.hitPattern().numberOfValidTrackerHits());
355 m_trackChi2.push_back(
track.normalizedChi2());
358 m_muonPt.push_back(
muon.track()->pt());
359 m_muonPhi.push_back(
muon.track()->phi());
360 m_muonEta.push_back(
muon.track()->eta());
361 m_muonPtError.push_back(
muon.track()->ptError());
362 m_muonPhiError.push_back(
muon.track()->phiError());
363 m_muonEtaError.push_back(
muon.track()->etaError());
364 m_muonCharge.push_back(
muon.charge());
365 m_muonDXY.push_back(
muon.track()->dxy());
366 m_muonDZ.push_back(
muon.track()->dz());
367 m_muonTrkHits.push_back(
muon.track()->hitPattern().numberOfValidTrackerHits());
368 m_muonChi2.push_back(
muon.track()->normalizedChi2());
370 m_muonTrigger.push_back(muonTrigger);
372 m_zMass.push_back(
_zMass);
375 m_dRTrackMuon.push_back(
dR);
377 m_numberOfPrimaryVertices.push_back(
vertices.size());
379 bool ec = (
track.eta() > 0);
380 UChar_t endcapCSC = ec ? 0 : 1;
381 m_chamberEndcap.push_back(endcapCSC * 1);
383 Int_t iiStationFail = 0;
384 Int_t iiStation0Pass = 0;
385 for (
int iiStationZ = 0; iiStationZ < 6; iiStationZ++) {
386 UChar_t stationCSC = iiStationZ > 2 ? iiStationZ - 2 : 0;
389 if (stationCSC == 0 && iiStation0Pass > 0)
399 CSCDetId Layer3id =
CSCDetId(endcapCSC + 1, stationCSC + 1, ringCSC, chamberCSC + 1, 3);
419 m_chamberRing[stationCSC].push_back(ringCSC);
420 m_chamberChamber[stationCSC].push_back(chamberCSC);
421 m_ttIntLocalX[stationCSC].push_back(localTTIntPoint.
x());
422 m_ttIntLocalY[stationCSC].push_back(localTTIntPoint.
y());
423 m_ttIntLocalW[stationCSC].push_back(
425 m_ttIntLocalS[stationCSC].push_back(
426 (layerGeoma->
strip(localTTIntPoint) + layerGeomb->
strip(localTTIntPoint)) / 2.0);
427 m_ttIntEta[stationCSC].push_back(
trkEta);
430 Float_t CSCProjEdgeDist = -9999.0;
431 Float_t ttIntLocalErrorX = -9999.0;
432 Float_t CSCDyProjHVGap = 9999.0;
433 Float_t ttIntLocalErrorY = -9999.0;
434 for (Int_t ly = 1; ly < 7; ly++) {
435 CSCDetId Layerid =
CSCDetId(endcapCSC + 1, stationCSC + 1, ringCSC, chamberCSC + 1, ly);
438 if (EdgeAndDistToGap[0] > CSCProjEdgeDist) {
439 CSCProjEdgeDist = EdgeAndDistToGap[0];
440 ttIntLocalErrorX = EdgeAndDistToGap[1];
442 if (EdgeAndDistToGap[2] < CSCDyProjHVGap) {
443 CSCDyProjHVGap = EdgeAndDistToGap[2];
444 ttIntLocalErrorY = EdgeAndDistToGap[3];
447 m_ttDistToEdge[stationCSC].push_back(CSCProjEdgeDist);
448 m_ttDistToHVGap[stationCSC].push_back(CSCDyProjHVGap);
449 m_ttIntLocalErrorX[stationCSC].push_back(ttIntLocalErrorX);
450 m_ttIntLocalErrorY[stationCSC].push_back(ttIntLocalErrorY);
456 if (TrajToSeg ==
nullptr) {
458 m_segLocalX[stationCSC].push_back(-9999.0);
459 m_segLocalY[stationCSC].push_back(-9999.0);
460 m_segLocalErrorX[stationCSC].push_back(0.0);
461 m_segLocalErrorY[stationCSC].push_back(0.0);
463 m_ttIntSegResidualLocalX[stationCSC].push_back(-9990.0);
464 m_ttIntSegResidualLocalY[stationCSC].push_back(-9990.0);
466 m_chamberLayer[stationCSC].push_back(-9);
471 LocalPoint localSegmentPoint = (*cscSegOut).localPosition();
472 LocalError localSegErr = (*cscSegOut).localPositionError();
474 m_segLocalX[stationCSC].push_back(localSegmentPoint.
x());
475 m_segLocalY[stationCSC].push_back(localSegmentPoint.
y());
476 m_segLocalErrorX[stationCSC].push_back(
sqrt(localSegErr.
xx()));
477 m_segLocalErrorY[stationCSC].push_back(
sqrt(localSegErr.
yy()));
479 m_ttIntSegResidualLocalX[stationCSC].push_back(localTTIntPoint.
x() - localSegmentPoint.
x());
480 m_ttIntSegResidualLocalY[stationCSC].push_back(localTTIntPoint.
y() - localSegmentPoint.
y());
483 for (std::vector<CSCRecHit2D>::const_iterator itRH = cscSegOut->specificRecHits().begin();
484 itRH != cscSegOut->specificRecHits().end();
490 m_chamberLayer[stationCSC].push_back(
layers);
498 if ((!tsos.
isValid()) || (ringCSC == 0)) {
502 if (iiStationZ > 2 || iiStationFail == 3) {
504 m_chamberRing[stationCSC].push_back(-9);
505 m_chamberChamber[stationCSC].push_back(-9);
506 m_ttIntLocalX[stationCSC].push_back(-9999.0);
507 m_ttIntLocalY[stationCSC].push_back(-9999.0);
508 m_ttIntLocalErrorX[stationCSC].push_back(0.0);
509 m_ttIntLocalErrorY[stationCSC].push_back(0.0);
510 m_ttIntLocalW[stationCSC].push_back(-9999.0);
511 m_ttIntLocalS[stationCSC].push_back(-9999.0);
512 m_ttIntEta[stationCSC].push_back(-9999.0);
514 m_ttDistToEdge[stationCSC].push_back(-9999.0);
515 m_ttDistToHVGap[stationCSC].push_back(-9999.9);
517 m_segLocalX[stationCSC].push_back(-9999.0);
518 m_segLocalY[stationCSC].push_back(-9999.0);
519 m_segLocalErrorX[stationCSC].push_back(0.0);
520 m_segLocalErrorY[stationCSC].push_back(0.0);
522 m_ttIntSegResidualLocalX[stationCSC].push_back(-9990.0);
523 m_ttIntSegResidualLocalY[stationCSC].push_back(-9990.0);
525 m_chamberLayer[stationCSC].push_back(-9);
538 table->setDoc(
"CSC Tag & Probe segment efficiency information");
543 addColumn(
table,
"muonPtError", m_muonPtError,
"muon pt error [GeV/c]");
544 addColumn(
table,
"muonPhiError", m_muonPhiError,
"muon phi error [rad]");
545 addColumn(
table,
"muonEtaError", m_muonEtaError,
"muon eta error");
549 addColumn(
table,
"muonTrkHits", m_muonTrkHits,
"muon track hits");
552 addColumn(
table,
"muonTrigger", m_muonTrigger,
"muon has trigger bool");
558 addColumn(
table,
"trackPtError", m_trackPtError,
"track pt error [GeV/c]");
559 addColumn(
table,
"trackPhiError", m_trackPhiError,
"track phi error [rad]");
560 addColumn(
table,
"trackEtaError", m_trackEtaError,
"track eta error");
564 addColumn(
table,
"trackTrkHits", m_trackTrkHits,
"track track hits");
569 addColumn(
table,
"dRTrackMuon", m_dRTrackMuon,
"dR between track and muon");
570 addColumn(
table,
"numberOfPrimaryVertidies", m_numberOfPrimaryVertices,
"Number of PVs");
641 addColumn(
table,
"ttIntSegResidualLocalX1", m_ttIntSegResidualLocalX[0],
"");
642 addColumn(
table,
"ttIntSegResidualLocalX2", m_ttIntSegResidualLocalX[1],
"");
643 addColumn(
table,
"ttIntSegResidualLocalX3", m_ttIntSegResidualLocalX[2],
"");
644 addColumn(
table,
"ttIntSegResidualLocalX4", m_ttIntSegResidualLocalX[3],
"");
645 addColumn(
table,
"ttIntSegResidualLocalY1", m_ttIntSegResidualLocalY[0],
"");
646 addColumn(
table,
"ttIntSegResidualLocalY2", m_ttIntSegResidualLocalY[1],
"");
647 addColumn(
table,
"ttIntSegResidualLocalY3", m_ttIntSegResidualLocalY[2],
"");
648 addColumn(
table,
"ttIntSegResidualLocalY4", m_ttIntSegResidualLocalY[3],
"");
668 for (
int trigIdx : trigIndices) {
671 const unsigned trigModuleIndex =
672 std::find(trigModuleLabels.begin(), trigModuleLabels.end(),
"hltBoolEnd") - trigModuleLabels.begin() - 1;
673 const unsigned hltFilterIndex =
trigEvent->filterIndex(
edm::InputTag(trigModuleLabels[trigModuleIndex],
"",
"HLT"));
674 if (hltFilterIndex < trigEvent->sizeFilters()) {
677 const unsigned nTriggers = vids.size();
679 for (
unsigned iTrig = 0; iTrig < nTriggers; ++iTrig) {
694 int trackerHitsCut = 8;
699 bool selected =
false;
703 if (!
muon.isTrackerMuon())
705 if (!
muon.track().isNonnull())
708 ((
muon.track()->pt() >
ptCut) && (
muon.track()->hitPattern().numberOfValidTrackerHits() >= trackerHitsCut) &&
718 int trackerHitsCut = 8;
723 bool selected =
false;
735 bool selected =
false;
843 const UChar_t nVal = (
station > 1 &&
ring == 1) ? 18 : 36;
844 const Float_t ChamberSpan = 2 *
M_PI / nVal;
845 Float_t dphi =
phi +
M_PI / 36;
846 while (dphi >= 2 *
M_PI)
850 UChar_t ChCand = floor(dphi / ChamberSpan) + 1;
851 return ChCand > nVal ? nVal : ChCand;
860 LocalPoint localSegPos = (*segIt).localPosition();
861 Float_t CSCdeltaX = localSegPos.
x() - localTTPos.
x();
862 Float_t CSCdeltaY = localSegPos.
y() - localTTPos.
y();
863 return sqrt(
pow(CSCdeltaX, 2) +
pow(CSCdeltaY, 2));
871 Float_t deltaCSCR = 9999.;
875 if (idCSC.
endcap() !=
id.endcap())
877 if (idCSC.
station() !=
id.station())
879 if (idCSC.
chamber() !=
id.chamber())
883 (idCSC.
station() == 1) && ((idCSC.
ring() == 1 || idCSC.
ring() == 4) && (
id.
ring() == 1 ||
id.ring() == 4));
885 (idCSC.
station() == 1) && ((idCSC.
ring() == 2 &&
id.ring() == 2) || (idCSC.
ring() == 3 &&
id.ring() == 3));
886 Bool_t ed3 = (idCSC.
station() != 1) && (idCSC.
ring() ==
id.ring());
887 Bool_t TMCSCMatch = (ed1 || ed2 || ed3);
899 if (dR_ < deltaCSCR) {
911 std::vector<Float_t>
result(4, 9999.);
925 Float_t yCOWPOffset = yOfFirstWire + 0.5 * length;
927 Float_t tangent = (wideWidth - narrowWidth) / (2. * length);
929 Float_t yPrime = localTTPos.
y() +
std::abs(yOfFirstWire);
931 Float_t halfWidthAtYPrime = 0.5 * narrowWidth + yPrime * tangent;
934 Float_t edgex =
std::abs(localTTPos.
x()) - halfWidthAtYPrime;
935 Float_t edgey =
std::abs(localTTPos.
y() - yCOWPOffset) - 0.5 * length;
956 const Float_t deadZoneCenterME1_2[2] = {-32.88305, 32.867423};
957 const Float_t deadZoneCenterME1_3[2] = {-22.7401, 27.86665};
958 const Float_t deadZoneCenterME2_1[2] = {-27.47, 33.67};
959 const Float_t deadZoneCenterME3_1[2] = {-36.21, 23.68};
960 const Float_t deadZoneCenterME4_1[2] = {-26.14, 23.85};
961 const Float_t deadZoneCenterME234_2[4] = {-81.8744, -21.18165, 39.51105, 100.2939};
962 const Float_t* deadZoneCenter;
963 Float_t deadZoneHeightHalf = 0.32 * 7 / 2;
964 Float_t
minY = 999999.;
972 deadZoneCenter = deadZoneCenterME1_2;
975 deadZoneCenter = deadZoneCenterME1_3;
978 deadZoneCenter = deadZoneCenterME2_1;
981 deadZoneCenter = deadZoneCenterME3_1;
984 deadZoneCenter = deadZoneCenterME4_1;
987 deadZoneCenter = deadZoneCenterME234_2;
990 for (UChar_t iGap = 0; iGap < nGaps; iGap++) {
991 Float_t newMinY = yLocal < deadZoneCenter[iGap] ? deadZoneCenter[iGap] - deadZoneHeightHalf - yLocal
992 : yLocal - (deadZoneCenter[iGap] + deadZoneHeightHalf);
1001 for (
const auto& track2 : (*
tracks)) {
1003 if (track2.pt() > 1.0 &&
dR > 0.001 &&
dR < 0.3)
1015 double dphi = phi1 - phi2;
1018 else if (dphi < -
M_PI)
1020 return std::sqrt(deta * deta + dphi * dphi);
1024 double zMass = -99.0;
1025 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)
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
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
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
dictionary config
Read in AllInOne config in JSON format.
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 &)
Power< A, B >::type pow(const A &a, const B &b)
HLTConfigProvider m_hltConfig
HLT config provider.
nano_mu::EDTokenHandle< reco::TrackCollection > m_trackToken
const GeomDet * idToDet(DetId) const override