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 
17 
18 
28 
39 
41 
43 public:
44 
45 
46  explicit ElectronNHitSeedProducer( const edm::ParameterSet & ) ;
47  virtual ~ElectronNHitSeedProducer()=default;
48 
49  virtual void produce( edm::Event &, const edm::EventSetup & ) override final;
50 
51  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
52 
53 private:
54 
56 
57  std::vector<edm::EDGetTokenT<std::vector<reco::SuperClusterRef>> > superClustersTokens_;
62 
63 };
64 
65 namespace {
66  template<typename T>
67  edm::Handle<T> getHandle(const edm::Event& event,const edm::EDGetTokenT<T>& token)
68  {
70  event.getByToken(token,handle);
71  return handle;
72  }
73 
74  template<typename T>
75  GlobalPoint convertToGP(const T& orgPoint){
76  return GlobalPoint(orgPoint.x(),orgPoint.y(),orgPoint.z());
77  }
78 
79  int getLayerOrDiskNr(DetId detId,const TrackerTopology& trackerTopo)
80  {
82  return trackerTopo.pxbLayer(detId);
83  }else if(detId.subdetId()==PixelSubdetector::PixelEndcap){
84  return trackerTopo.pxfDisk(detId);
85  }else return -1;
86  }
87 
89  makeSeedPixelVar(const TrajSeedMatcher::MatchInfo& matchInfo,
90  const TrackerTopology& trackerTopo)
91  {
92 
93  int layerOrDisk = getLayerOrDiskNr(matchInfo.detId,trackerTopo);
95  pmVars.setDet(matchInfo.detId,layerOrDisk);
96  pmVars.setDPhi(matchInfo.dPhiPos,matchInfo.dPhiNeg);
97  pmVars.setDRZ(matchInfo.dRZPos,matchInfo.dRZNeg);
98 
99  return pmVars;
100  }
101 
102 }
103 
105  matcher_(pset.getParameter<edm::ParameterSet>("matcherConfig")),
106  initialSeedsToken_(consumes<TrajectorySeedCollection>(pset.getParameter<edm::InputTag>("initialSeeds"))),
107  verticesToken_(consumes<std::vector<reco::Vertex> >(pset.getParameter<edm::InputTag>("vertices"))),
108  beamSpotToken_(consumes<reco::BeamSpot>(pset.getParameter<edm::InputTag>("beamSpot"))),
109  measTkEvtToken_(consumes<MeasurementTrackerEvent>(pset.getParameter<edm::InputTag>("measTkEvt")))
110 {
111  const auto superClusTags = pset.getParameter<std::vector<edm::InputTag> >("superClusters");
112  for(const auto& scTag : superClusTags){
113  superClustersTokens_.emplace_back(consumes<std::vector<reco::SuperClusterRef>>(scTag));
114  }
115  produces<reco::ElectronSeedCollection>() ;
116 }
117 
119 {
121  desc.add<edm::InputTag>("initialSeeds",edm::InputTag("hltElePixelSeedsCombined"));
122  desc.add<edm::InputTag>("vertices",edm::InputTag());
123  desc.add<edm::InputTag>("beamSpot",edm::InputTag("hltOnlineBeamSpot"));
124  desc.add<edm::InputTag>("measTkEvt",edm::InputTag("hltSiStripClusters"));
125  desc.add<std::vector<edm::InputTag> >("superClusters",std::vector<edm::InputTag>{edm::InputTag{"hltEgammaSuperClustersToPixelMatch"}});
127 
128  descriptions.add("electronNHitSeedProducer",desc);
129 }
130 
132 {
133  edm::ESHandle<TrackerTopology> trackerTopoHandle;
134  iSetup.get<TrackerTopologyRcd>().get(trackerTopoHandle);
135 
136  matcher_.doEventSetup(iSetup);
137  matcher_.setMeasTkEvtHandle(getHandle(iEvent,measTkEvtToken_));
138 
139  auto eleSeeds = std::make_unique<reco::ElectronSeedCollection>();
140 
141  auto initialSeedsHandle = getHandle(iEvent,initialSeedsToken_);
142 
143  auto beamSpotHandle = getHandle(iEvent,beamSpotToken_);
144  GlobalPoint primVtxPos = convertToGP(beamSpotHandle->position());
145 
146  for(const auto& superClustersToken : superClustersTokens_){
147  auto superClustersHandle = getHandle(iEvent,superClustersToken);
148  for(auto& superClusRef : *superClustersHandle){
149 
150  //the eta of the supercluster when mustache clustered is slightly biased due to bending in magnetic field
151  //the eta of its seed cluster is a better estimate of the orginal position
152  GlobalPoint caloPosition(GlobalPoint::Polar(superClusRef->seed()->position().theta(), //seed theta
153  superClusRef->position().phi(), //supercluster phi
154  superClusRef->position().r())); //supercluster r
155 
156 
157  const std::vector<TrajSeedMatcher::SeedWithInfo> matchedSeeds =
158  matcher_.compatibleSeeds(*initialSeedsHandle,caloPosition,
159  primVtxPos,superClusRef->energy());
160 
161  for(auto& matchedSeed : matchedSeeds){
162  reco::ElectronSeed eleSeed(matchedSeed.seed());
163  reco::ElectronSeed::CaloClusterRef caloClusRef(superClusRef);
164  eleSeed.setCaloCluster(caloClusRef);
165  eleSeed.setNrLayersAlongTraj(matchedSeed.nrValidLayers());
166  for(auto& matchInfo : matchedSeed.matches()){
167  eleSeed.addHitInfo(makeSeedPixelVar(matchInfo,*trackerTopoHandle));
168  }
169  eleSeeds->emplace_back(eleSeed);
170  }
171  }
172 
173  }
174  iEvent.put(std::move(eleSeeds));
175 }
176 
177 
178 
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:122
edm::EDGetTokenT< TrajectorySeedCollection > initialSeedsToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
unsigned int pxfDisk(const DetId &id) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
void setDPhi(float pos, float neg)
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void setMeasTkEvtHandle(edm::Handle< MeasurementTrackerEvent > handle)
int iEvent
Definition: GenABIO.cc:230
static edm::ParameterSetDescription makePSetDescription()
std::vector< TrajectorySeed > TrajectorySeedCollection
ElectronNHitSeedProducer(const edm::ParameterSet &)
void setDet(int iDetId, int iLayerOrDiskNr)
edm::EDGetTokenT< std::vector< reco::Vertex > > verticesToken_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
unsigned int pxbLayer(const DetId &id) const
Definition: DetId.h:18
std::vector< edm::EDGetTokenT< std::vector< reco::SuperClusterRef > > > superClustersTokens_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const T & get() const
Definition: EventSetup.h:55
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< MeasurementTrackerEvent > measTkEvtToken_
fixed size matrix
HLT enums.
virtual ~ElectronNHitSeedProducer()=default
long double T
virtual void produce(edm::Event &, const edm::EventSetup &) override final
void setDRZ(float pos, float neg)
def move(src, dest)
Definition: eostools.py:510
Definition: event.py:1