CMS 3D CMS Logo

ElectronNHitSeedProducer.cc
Go to the documentation of this file.
1 //******************************************************************************
2 //
3 // Part of the refactorisation of of the E/gamma pixel matching for 2017 pixels
4 // This refactorisation converts the monolithic approach to a series of
5 // independent producer modules, with each modules performing a specific
6 // job as recommended by the 2017 tracker framework
7 //
8 //
9 // The module produces the ElectronSeeds, similarly to ElectronSeedProducer
10 // although with a varible number of required hits
11 //
12 //
13 // Author : Sam Harper (RAL), 2017
14 //
15 //*******************************************************************************
16 
26 
37 
39 
41 public:
43  ~ElectronNHitSeedProducer() override = default;
44 
45  void produce(edm::Event&, const edm::EventSetup&) final;
46 
47  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
48 
49 private:
51 
52  std::vector<edm::EDGetTokenT<std::vector<reco::SuperClusterRef>>> superClustersTokens_;
57 };
58 
59 namespace {
60  template <typename T>
61  edm::Handle<T> getHandle(const edm::Event& event, const edm::EDGetTokenT<T>& token) {
63  event.getByToken(token, handle);
64  return handle;
65  }
66 
67  template <typename T>
68  GlobalPoint convertToGP(const T& orgPoint) {
69  return GlobalPoint(orgPoint.x(), orgPoint.y(), orgPoint.z());
70  }
71 
72  int getLayerOrDiskNr(DetId detId, const TrackerTopology& trackerTopo) {
73  if (detId.subdetId() == PixelSubdetector::PixelBarrel) {
74  return trackerTopo.pxbLayer(detId);
75  } else if (detId.subdetId() == PixelSubdetector::PixelEndcap) {
76  return trackerTopo.pxfDisk(detId);
77  } else
78  return -1;
79  }
80 
81  reco::ElectronSeed::PMVars makeSeedPixelVar(const TrajSeedMatcher::MatchInfo& matchInfo,
82  const TrackerTopology& trackerTopo) {
83  int layerOrDisk = getLayerOrDiskNr(matchInfo.detId, trackerTopo);
85  pmVars.setDet(matchInfo.detId, layerOrDisk);
86  pmVars.setDPhi(matchInfo.dPhiPos, matchInfo.dPhiNeg);
87  pmVars.setDRZ(matchInfo.dRZPos, matchInfo.dRZNeg);
88 
89  return pmVars;
90  }
91 
92 } // namespace
93 
95  : matcher_(pset.getParameter<edm::ParameterSet>("matcherConfig")),
96  initialSeedsToken_(consumes<TrajectorySeedCollection>(pset.getParameter<edm::InputTag>("initialSeeds"))),
97  verticesToken_(consumes<std::vector<reco::Vertex>>(pset.getParameter<edm::InputTag>("vertices"))),
98  beamSpotToken_(consumes<reco::BeamSpot>(pset.getParameter<edm::InputTag>("beamSpot"))),
99  measTkEvtToken_(consumes<MeasurementTrackerEvent>(pset.getParameter<edm::InputTag>("measTkEvt"))) {
100  const auto superClusTags = pset.getParameter<std::vector<edm::InputTag>>("superClusters");
101  for (const auto& scTag : superClusTags) {
102  superClustersTokens_.emplace_back(consumes<std::vector<reco::SuperClusterRef>>(scTag));
103  }
104  produces<reco::ElectronSeedCollection>();
105 }
106 
109  desc.add<edm::InputTag>("initialSeeds", edm::InputTag("hltElePixelSeedsCombined"));
110  desc.add<edm::InputTag>("vertices", edm::InputTag());
111  desc.add<edm::InputTag>("beamSpot", edm::InputTag("hltOnlineBeamSpot"));
112  desc.add<edm::InputTag>("measTkEvt", edm::InputTag("hltSiStripClusters"));
113  desc.add<std::vector<edm::InputTag>>("superClusters",
114  std::vector<edm::InputTag>{edm::InputTag{"hltEgammaSuperClustersToPixelMatch"}});
116 
117  descriptions.add("electronNHitSeedProducer", desc);
118 }
119 
121  edm::ESHandle<TrackerTopology> trackerTopoHandle;
122  iSetup.get<TrackerTopologyRcd>().get(trackerTopoHandle);
123 
124  matcher_.doEventSetup(iSetup);
125  matcher_.setMeasTkEvtHandle(getHandle(iEvent, measTkEvtToken_));
126 
127  auto eleSeeds = std::make_unique<reco::ElectronSeedCollection>();
128  auto initialSeedsHandle = getHandle(iEvent, initialSeedsToken_);
129 
130  auto beamSpotHandle = getHandle(iEvent, beamSpotToken_);
131  GlobalPoint primVtxPos = convertToGP(beamSpotHandle->position());
132 
133  // Loop over all super-cluster collections (typically barrel and forward are supplied separately)
134  for (const auto& superClustersToken : superClustersTokens_) {
135  auto superClustersHandle = getHandle(iEvent, superClustersToken);
136  for (auto& superClusRef : *superClustersHandle) {
137  //the eta of the supercluster when mustache clustered is slightly biased due to bending in magnetic field
138  //the eta of its seed cluster is a better estimate of the orginal position
139  GlobalPoint caloPosition(GlobalPoint::Polar(superClusRef->seed()->position().theta(), //seed theta
140  superClusRef->position().phi(), //supercluster phi
141  superClusRef->position().r())); //supercluster r
142 
143  const std::vector<TrajSeedMatcher::SeedWithInfo> matchedSeeds =
144  matcher_.compatibleSeeds(*initialSeedsHandle, caloPosition, primVtxPos, superClusRef->energy());
145 
146  for (auto& matchedSeed : matchedSeeds) {
147  reco::ElectronSeed eleSeed(matchedSeed.seed());
148  reco::ElectronSeed::CaloClusterRef caloClusRef(superClusRef);
149  eleSeed.setCaloCluster(caloClusRef);
150  eleSeed.setNrLayersAlongTraj(matchedSeed.nrValidLayers());
151  for (auto& matchInfo : matchedSeed.matches()) {
152  eleSeed.addHitInfo(makeSeedPixelVar(matchInfo, *trackerTopoHandle));
153  }
154  eleSeeds->emplace_back(eleSeed);
155  }
156  }
157  }
158  iEvent.put(std::move(eleSeeds));
159 }
160 
T getParameter(std::string const &) const
void doEventSetup(const edm::EventSetup &iSetup)
std::vector< TrajSeedMatcher::SeedWithInfo > compatibleSeeds(const TrajectorySeedCollection &seeds, const GlobalPoint &candPos, const GlobalPoint &vprim, const float energy)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
edm::EDGetTokenT< TrajectorySeedCollection > initialSeedsToken_
unsigned int pxfDisk(const DetId &id) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
void setDPhi(float pos, float neg)
void produce(edm::Event &, const edm::EventSetup &) final
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
void setMeasTkEvtHandle(edm::Handle< MeasurementTrackerEvent > handle)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static edm::ParameterSetDescription makePSetDescription()
std::vector< TrajectorySeed > TrajectorySeedCollection
ElectronNHitSeedProducer(const edm::ParameterSet &)
void setDet(int iDetId, int iLayerOrDiskNr)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
edm::EDGetTokenT< std::vector< reco::Vertex > > verticesToken_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
~ElectronNHitSeedProducer() override=default
unsigned int pxbLayer(const DetId &id) const
Definition: DetId.h:17
std::vector< edm::EDGetTokenT< std::vector< reco::SuperClusterRef > > > superClustersTokens_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< MeasurementTrackerEvent > measTkEvtToken_
fixed size matrix
HLT enums.
T get() const
Definition: EventSetup.h:73
long double T
void setDRZ(float pos, float neg)
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1