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 
25 
35 
37 
39 public:
41 
42  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const final;
43 
44  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
45 
46 private:
48 
49  std::vector<edm::EDGetTokenT<std::vector<reco::SuperClusterRef>>> superClustersTokens_;
56 };
57 
58 namespace {
59  int getLayerOrDiskNr(DetId detId, const TrackerTopology& trackerTopo) {
60  if (detId.subdetId() == PixelSubdetector::PixelBarrel) {
61  return trackerTopo.pxbLayer(detId);
62  } else if (detId.subdetId() == PixelSubdetector::PixelEndcap) {
63  return trackerTopo.pxfDisk(detId);
64  } else
65  return -1;
66  }
67 
68  reco::ElectronSeed::PMVars makeSeedPixelVar(const TrajSeedMatcher::MatchInfo& matchInfo,
69  const TrackerTopology& trackerTopo) {
70  int layerOrDisk = getLayerOrDiskNr(matchInfo.detId, trackerTopo);
72  pmVars.setDet(matchInfo.detId, layerOrDisk);
73  pmVars.setDPhi(matchInfo.dPhiPos, matchInfo.dPhiNeg);
74  pmVars.setDRZ(matchInfo.dRZPos, matchInfo.dRZNeg);
75 
76  return pmVars;
77  }
78 
79 } // namespace
80 
82  : matcherConfiguration_(pset.getParameter<edm::ParameterSet>("matcherConfig"), consumesCollector()),
83  initialSeedsToken_(consumes(pset.getParameter<edm::InputTag>("initialSeeds"))),
84  verticesToken_(consumes(pset.getParameter<edm::InputTag>("vertices"))),
85  beamSpotToken_(consumes(pset.getParameter<edm::InputTag>("beamSpot"))),
86  measTkEvtToken_(consumes(pset.getParameter<edm::InputTag>("measTkEvt"))),
87  putToken_{produces<reco::ElectronSeedCollection>()},
88  trackerTopologyToken_{esConsumes()} {
89  for (const auto& scTag : pset.getParameter<std::vector<edm::InputTag>>("superClusters")) {
90  superClustersTokens_.emplace_back(consumes(scTag));
91  }
92 }
93 
96  desc.add<edm::InputTag>("initialSeeds", {"hltElePixelSeedsCombined"});
97  desc.add<edm::InputTag>("vertices", {});
98  desc.add<edm::InputTag>("beamSpot", {"hltOnlineBeamSpot"});
99  desc.add<edm::InputTag>("measTkEvt", {"hltSiStripClusters"});
100  desc.add<std::vector<edm::InputTag>>("superClusters", {{"hltEgammaSuperClustersToPixelMatch"}});
102 
103  descriptions.add("electronNHitSeedProducer", desc);
104 }
105 
107  auto const& trackerTopology = iSetup.getData(trackerTopologyToken_);
108 
109  reco::ElectronSeedCollection eleSeeds{};
110 
112  iEvent.get(beamSpotToken_).position(),
114  iSetup,
115  iEvent.get(measTkEvtToken_)};
116 
117  // Loop over all super-cluster collections (typically barrel and forward are supplied separately)
118  for (const auto& superClustersToken : superClustersTokens_) {
119  for (auto& superClusRef : iEvent.get(superClustersToken)) {
120  //the eta of the supercluster when mustache clustered is slightly biased due to bending in magnetic field
121  //the eta of its seed cluster is a better estimate of the orginal position
122  GlobalPoint caloPosition(GlobalPoint::Polar(superClusRef->seed()->position().theta(), //seed theta
123  superClusRef->position().phi(), //supercluster phi
124  superClusRef->position().r())); //supercluster r
125 
126  for (auto const& matchedSeed : matcher(caloPosition, superClusRef->energy())) {
127  reco::ElectronSeed eleSeed(matchedSeed.seed);
128  reco::ElectronSeed::CaloClusterRef caloClusRef(superClusRef);
129  eleSeed.setCaloCluster(caloClusRef);
130  eleSeed.setNrLayersAlongTraj(matchedSeed.nrValidLayers);
131  for (auto const& matchInfo : matchedSeed.matchInfos) {
132  eleSeed.addHitInfo(makeSeedPixelVar(matchInfo, trackerTopology));
133  }
134  eleSeeds.emplace_back(eleSeed);
135  }
136  }
137  }
138  iEvent.emplace(putToken_, std::move(eleSeeds));
139 }
140 
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
unsigned int pxbLayer(const DetId &id) const
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
void setDPhi(float pos, float neg)
const edm::EDGetTokenT< MeasurementTrackerEvent > measTkEvtToken_
const edm::EDGetTokenT< TrajectorySeedCollection > initialSeedsToken_
void setNrLayersAlongTraj(int val)
Definition: ElectronSeed.h:90
int iEvent
Definition: GenABIO.cc:224
static edm::ParameterSetDescription makePSetDescription()
ElectronNHitSeedProducer(const edm::ParameterSet &)
void setDet(int iDetId, int iLayerOrDiskNr)
unsigned int pxfDisk(const DetId &id) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
Definition: DetId.h:17
std::vector< edm::EDGetTokenT< std::vector< reco::SuperClusterRef > > > superClustersTokens_
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const final
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDPutTokenT< reco::ElectronSeedCollection > putToken_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopologyToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const TrajSeedMatcher::Configuration matcherConfiguration_
void setCaloCluster(const CaloClusterRef &clus)
Definition: ElectronSeed.h:85
HLT enums.
const edm::EDGetTokenT< std::vector< reco::Vertex > > verticesToken_
void addHitInfo(const PMVars &hitVars)
Definition: ElectronSeed.h:89
void setDRZ(float pos, float neg)
def move(src, dest)
Definition: eostools.py:511
const edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_