1717#include " DataFormats/GEMDigi/interface/GEMVFATStatusCollection.h"
1818#include " DataFormats/GEMDigi/interface/GEMOHStatusCollection.h"
1919#include " DataFormats/GEMDigi/interface/GEMAMCStatusCollection.h"
20+ #include " Geometry/GEMGeometry/interface/GEMGeometry.h"
21+
22+ #include " FWCore/Framework/interface/ConsumesCollector.h"
23+ #include " RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
24+
25+ #include " Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
26+ #include " Geometry/Records/interface/TrackerDigiGeometryRecord.h"
27+ #include " DataFormats/GeometryCommonDetAlgo/interface/ErrorFrameTransformer.h"
2028
2129class GEMTnPEfficiencyTask : public BaseTnPEfficiencyTask {
2230public:
@@ -25,14 +33,18 @@ class GEMTnPEfficiencyTask : public BaseTnPEfficiencyTask {
2533 uint16_t maskChamberWithError (const GEMDetId& chamber_id,
2634 const GEMOHStatusCollection*,
2735 const GEMVFATStatusCollection*);
28-
36+ bool checkBounds (const Plane& plane,
37+ const GlobalPoint& global_point,
38+ const LocalError& local_error,
39+ const float scale);
2940 // / Destructor
3041 ~GEMTnPEfficiencyTask () override ;
3142
3243 const bool m_maskChamberWithError_;
3344 const edm::EDGetTokenT<GEMOHStatusCollection> m_GEMOHStatusCollectionToken_;
3445 const edm::EDGetTokenT<GEMVFATStatusCollection> m_GEMVFATStatusCollectionToken_;
3546 const edm::EDGetTokenT<GEMAMCStatusCollection> m_GEMAMCStatusCollectionToken_;
47+ std::unique_ptr<MuonServiceProxy> muon_service_;
3648
3749protected:
3850 std::string topFolder () const override ;
@@ -53,6 +65,7 @@ GEMTnPEfficiencyTask::GEMTnPEfficiencyTask(const edm::ParameterSet& config)
5365 m_GEMAMCStatusCollectionToken_(
5466 consumes<GEMAMCStatusCollection>(config.getUntrackedParameter<edm::InputTag>(" amcStatusTag" ))) {
5567 LogTrace (" DQMOffline|MuonDPG|GEMTnPEfficiencyTask" ) << " [GEMTnPEfficiencyTask]: Constructor" << std::endl;
68+ muon_service_ = std::make_unique<MuonServiceProxy>(config.getParameter <edm::ParameterSet>(" ServiceParameters" ), consumesCollector ());
5669}
5770
5871GEMTnPEfficiencyTask::~GEMTnPEfficiencyTask () {
@@ -1316,12 +1329,22 @@ uint16_t GEMTnPEfficiencyTask::maskChamberWithError(const GEMDetId& chamber_id,
13161329 return oh_warning;
13171330}
13181331
1332+ bool GEMTnPEfficiencyTask::checkBounds (const Plane& plane,
1333+ const GlobalPoint& global_point,
1334+ const LocalError& local_error,
1335+ const float scale) {
1336+ const LocalPoint local_point = plane.toLocal (global_point);
1337+ const LocalPoint local_point_2d{local_point.x (), local_point.y (), 0 .0f };
1338+ return plane.bounds ().inside (local_point_2d, local_error, scale);
1339+ }
1340+
13191341void GEMTnPEfficiencyTask::analyze (const edm::Event& event, const edm::EventSetup& context) {
13201342 BaseTnPEfficiencyTask::analyze (event, context);
13211343 GEMOHStatusCollection oh_status;
13221344 GEMVFATStatusCollection vfat_status;
13231345 edm::Handle<GEMOHStatusCollection> oh_status_collection;
13241346 edm::Handle<GEMVFATStatusCollection> vfat_status_collection;
1347+ muon_service_->update (context);
13251348 if (m_maskChamberWithError_) {
13261349 event.getByToken (m_GEMOHStatusCollectionToken_, oh_status_collection);
13271350 // if (oh_status_collem_tion.isValid()) {
@@ -1435,18 +1458,36 @@ void GEMTnPEfficiencyTask::analyze(const edm::Event& event, const edm::EventSetu
14351458
14361459 GEMDetId chId (chambMatch.id .rawId ());
14371460 const uint16_t warnings = maskChamberWithError (chId, &oh_status, &vfat_status);
1438-
14391461 const int roll = chId.roll ();
14401462 const int region = chId.region ();
14411463 const int station = chId.station ();
14421464 const int layer = chId.layer ();
14431465 const int chamber = chId.chamber ();
1444- const int ieta = chId.ieta ();
14451466 const float pt = (*muons).at (i).pt ();
14461467 const float eta = (*muons).at (i).eta ();
14471468 const float phi = (*muons).at (i).phi ();
1469+ int ieta = 0 ;
14481470 GEM_stationMatching = GEM_stationMatching | (1 << station);
14491471
1472+ // const GeomDet* geomDet = tGeom.idToDet(chId);
1473+ const GeomDet* geomDet = muon_service_->trackingGeometry ()->idToDet (chId);
1474+
1475+ // edm::ESHandle<GlobalTrackingGeometry> tracking_geom = muon_service_->trackingGeometry();
1476+ // const GeomDet* geomDet = tracking_geom->idToDet(chId);
1477+
1478+ LocalPoint pos (chambMatch.x ,chambMatch.y );
1479+ LocalError err (chambMatch.xErr , 0 , chambMatch.yErr ); // We don't have xy error in ChamberMatch
1480+
1481+ const GlobalPoint& global_point = geomDet->toGlobal (pos);
1482+
1483+ if (const GEMChamber* gemChamber = dynamic_cast <const GEMChamber*>(geomDet)) {
1484+ for (const GEMEtaPartition* eta_partition : gemChamber->etaPartitions ())
1485+ if (checkBounds (eta_partition->surface (), global_point, err, 2 )) {
1486+ ieta = eta_partition->id ().ieta ();
1487+ break ;
1488+ }
1489+ }
1490+
14501491 if (station == 1 || station == 2 ) {
14511492 reco::MuonGEMHitMatch closest_matchedHit;
14521493 double smallestDx = 99999 .;
0 commit comments