CMS 3D CMS Logo

EgammaHLTRegionalPixelSeedGeneratorProducers.cc
Go to the documentation of this file.
1 //
2 // Package: RecoEgamma/EgammaHLTProducers
3 // Class: EgammaHLTRegionalPixelSeedGeneratorProducers
4 // Modified from TkSeedGeneratorFromTrk by Jeremy Werner, Princeton University, USA
5 // $Id: EgammaHLTRegionalPixelSeedGeneratorProducers.cc,v 1.13 2012/01/23 12:56:38 sharper Exp $
6 //
7 
8 #include <iostream>
9 #include <memory>
10 #include <string>
11 
26 
31 
34 // Math
35 #include "Math/GenVector/VectorUtil.h"
36 #include "Math/GenVector/PxPyPzE4D.h"
39 
40 using namespace std;
41 using namespace reco;
42 
44 {
45 
46  produces<TrajectorySeedCollection>();
47 
48  ptmin_ = conf.getParameter<double>("ptMin");
49  vertexz_ = conf.getParameter<double>("vertexZ");
50  originradius_= conf.getParameter<double>("originRadius");
51  halflength_ = conf.getParameter<double>("originHalfLength");
52  deltaEta_ = conf.getParameter<double>("deltaEtaRegion");
53  deltaPhi_ = conf.getParameter<double>("deltaPhiRegion");
54 
55  candTag_ = consumes<reco::RecoEcalCandidateCollection>(conf.getParameter< edm::InputTag > ("candTag"));
56  candTagEle_ = consumes<reco::ElectronCollection>(conf.getParameter< edm::InputTag > ("candTagEle"));
57  BSProducer_ = consumes<reco::BeamSpot>(conf.getParameter<edm::InputTag>("BSProducer"));
58 
59  useZvertex_ = conf.getParameter<bool>("UseZInVertex");
60 
61  edm::ParameterSet hitsfactoryPSet = conf.getParameter<edm::ParameterSet>("OrderedHitsFactoryPSet");
62  std::string hitsfactoryName = hitsfactoryPSet.getParameter<std::string>("ComponentName");
63 
64  // get orderd hits generator from factory
65  edm::ConsumesCollector iC = consumesCollector();
66  OrderedHitsGenerator* hitsGenerator = OrderedHitsGeneratorFactory::get()->create( hitsfactoryName, hitsfactoryPSet, iC);
67 
68  // start seed generator
69  edm::ParameterSet creatorPSet;
70  creatorPSet.addParameter<std::string>("propagator","PropagatorWithMaterial");
71 
72  combinatorialSeedGenerator.reset(new SeedGeneratorFromRegionHits( hitsGenerator, nullptr,
73  SeedCreatorFactory::get()->create("SeedFromConsecutiveHitsCreator", creatorPSet)
74  ));
75  // setup orderedhits setup (in order to tell seed generator to use pairs/triplets, which layers)
76 }
77 
78 // Virtual destructor needed.
80 }
81 
83 
85  desc.add<double>("ptMin", 1.5);
86  desc.add<double>("vertexZ", 0);
87  desc.add<double>("originRadius", 0.02);
88  desc.add<double>("originHalfLength", 15.0);
89  desc.add<double>("deltaEtaRegion", 0.3);
90  desc.add<double>("deltaPhiRegion", 0.3);
91  desc.add<edm::InputTag>(("candTag"), edm::InputTag("hltL1SeededRecoEcalCandidate"));
92  desc.add<edm::InputTag>(("candTagEle"), edm::InputTag("pixelMatchElectrons"));
93  desc.add<edm::InputTag>(("BSProducer"), edm::InputTag("hltOnlineBeamSpot"));
94  desc.add<bool>(("UseZInVertex"), false);
95  desc.add<std::string>("TTRHBuilder", "WithTrackAngle");
96 
97  edm::ParameterSetDescription orderedHitsPSET;
98  orderedHitsPSET.add<std::string>("ComponentName", "StandardHitPairGenerator");
99  orderedHitsPSET.add<edm::InputTag>("SeedingLayers", edm::InputTag("PixelLayerPairs"));
100  orderedHitsPSET.add<unsigned int>("maxElement", 0);
101  desc.add<edm::ParameterSetDescription>("OrderedHitsFactoryPSet", orderedHitsPSET);
102 
103  descriptions.add(("hltEgammaHLTRegionalPixelSeedGeneratorProducers"), desc);
104 }
105 
106 // Functions that gets called by framework every event
108 {
109 
110  // resulting collection
111  auto output = std::make_unique< TrajectorySeedCollection>();
112 
113  // Get the recoEcalCandidates
115  iEvent.getByToken(candTag_,recoecalcands);
116 
117  //Get the Beam Spot position
118  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
119  iEvent.getByToken(BSProducer_,recoBeamSpotHandle);
120  // gets its position
121  const BeamSpot::Point& BSPosition = recoBeamSpotHandle->position();
122 
123  //Get the HLT electrons collection if needed
125  if(useZvertex_)
126  iEvent.getByToken(candTagEle_,electronHandle);
127 
128  reco::SuperClusterRef scRef;
129  for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand= recoecalcands->begin(); recoecalcand!=recoecalcands->end(); recoecalcand++) {
130  scRef = recoecalcand->superCluster();
131  float zvertex = 0;
132  if( useZvertex_ ){
133  reco::SuperClusterRef scRefEle;
134  for(reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); iElectron != electronHandle->end(); iElectron++){
135  //Compare electron SC with EcalCandidate SC
136  scRefEle = iElectron->superCluster();
137  if(&(*scRef) == &(*scRefEle)){
138  if(iElectron->track().isNonnull()) zvertex = iElectron->track()->vz();
139  else zvertex = iElectron->gsfTrack()->vz();
140  break;
141  }
142  }
143 
144  }
145  GlobalVector dirVector((recoecalcand)->px(),(recoecalcand)->py(),(recoecalcand)->pz());
146  RectangularEtaPhiTrackingRegion etaphiRegion( dirVector,
147  GlobalPoint( BSPosition.x(), BSPosition.y(), zvertex ),
148  ptmin_,
149  originradius_,
150  halflength_,
151  deltaEta_,
152  deltaPhi_);
153 
154  // fill Trajectory seed collection
155  combinatorialSeedGenerator->run(*output, etaphiRegion, iEvent, iSetup);
156 
157  }
158 
159  iEvent.put(std::move(output));
160 }
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
def create(alignables, pedeDump, additionalData, outputFile, config)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:29
void produce(edm::Event &e, const edm::EventSetup &c) override
int iEvent
Definition: GenABIO.cc:224
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:125
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
fixed size matrix
const Point & position() const
position
Definition: BeamSpot.h:62
def move(src, dest)
Definition: eostools.py:511
T get(const Candidate &c)
Definition: component.h:55