CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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.14 2013/02/27 19:53:13 eulisse Exp $
6 //
7 
8 #include <iostream>
9 #include <memory>
10 #include <string>
11 
29 
34 
37 
40 // Math
41 #include "Math/GenVector/VectorUtil.h"
42 #include "Math/GenVector/PxPyPzE4D.h"
43 
44 using namespace std;
45 using namespace reco;
46 
48 {
49 
50  produces<TrajectorySeedCollection>();
51 
52  ptmin_ = conf_.getParameter<double>("ptMin");
53  vertexz_ = conf_.getParameter<double>("vertexZ");
54  originradius_= conf_.getParameter<double>("originRadius");
55  halflength_ = conf_.getParameter<double>("originHalfLength");
56  deltaEta_ = conf_.getParameter<double>("deltaEtaRegion");
57  deltaPhi_ = conf_.getParameter<double>("deltaPhiRegion");
58  candTag_ = conf_.getParameter< edm::InputTag > ("candTag");
59  candTagEle_ = conf_.getParameter< edm::InputTag > ("candTagEle");
60  useZvertex_ = conf_.getParameter<bool>("UseZInVertex");
61  BSProducer_ = conf.getParameter<edm::InputTag>("BSProducer");
62  // setup orderedhits setup (in order to tell seed generator to use pairs/triplets, which layers)
63 }
64 
65 // Virtual destructor needed.
67 }
68 
70 {
73 }
74 
75 
77 {
78  edm::ParameterSet hitsfactoryPSet =
79  conf_.getParameter<edm::ParameterSet>("OrderedHitsFactoryPSet");
80  std::string hitsfactoryName = hitsfactoryPSet.getParameter<std::string>("ComponentName");
81 
82  // get orderd hits generator from factory
83  OrderedHitsGenerator* hitsGenerator =
84  OrderedHitsGeneratorFactory::get()->create( hitsfactoryName, hitsfactoryPSet);
85 
86  // start seed generator
87  // FIXME??
88  edm::ParameterSet creatorPSet;
89  creatorPSet.addParameter<std::string>("propagator","PropagatorWithMaterial");
90 
92  SeedCreatorFactory::get()->create("SeedFromConsecutiveHitsCreator", creatorPSet)
93  );
94 }
95 
96 // Functions that gets called by framework every event
98 {
99 
100  // resulting collection
101  std::auto_ptr<TrajectorySeedCollection> output(new TrajectorySeedCollection());
102 
103  // Get the recoEcalCandidates
105  iEvent.getByLabel(candTag_,recoecalcands);
106 
107  //Get the Beam Spot position
108  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
109  // iEvent.getByType(recoBeamSpotHandle);
110  iEvent.getByLabel(BSProducer_,recoBeamSpotHandle);
111  // gets its position
112  const BeamSpot::Point& BSPosition = recoBeamSpotHandle->position();
113 
114  //Get the HLT electrons collection if needed
116  if(useZvertex_){iEvent.getByLabel(candTagEle_,electronHandle);}
117 
118  reco::SuperClusterRef scRef;
119  for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand= recoecalcands->begin(); recoecalcand!=recoecalcands->end(); recoecalcand++) {
120  scRef = recoecalcand->superCluster();
121  float zvertex = 0;
122  if( useZvertex_ ){
123  reco::SuperClusterRef scRefEle;
124  for(reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); iElectron != electronHandle->end(); iElectron++){
125  //Compare electron SC with EcalCandidate SC
126  scRefEle = iElectron->superCluster();
127  if(&(*scRef) == &(*scRefEle)){
128  if(iElectron->track().isNonnull()) zvertex = iElectron->track()->vz();
129  else zvertex = iElectron->gsfTrack()->vz();
130  break;
131  }
132  }
133 
134  }
135  GlobalVector dirVector((recoecalcand)->px(),(recoecalcand)->py(),(recoecalcand)->pz());
136  RectangularEtaPhiTrackingRegion etaphiRegion( dirVector,
137  GlobalPoint( BSPosition.x(), BSPosition.y(), zvertex ),
138  ptmin_,
140  halflength_,
141  deltaEta_,
142  deltaPhi_);
143 
144  // fill Trajectory seed collection
145  combinatorialSeedGenerator->run(*output, etaphiRegion, iEvent, iSetup);
146 
147  }
148 
149  iEvent.put(output);
150 }
T getParameter(std::string const &) const
virtual void produce(edm::Event &e, const edm::EventSetup &c)
virtual void endRun(edm::Run const &run, const edm::EventSetup &es) overridefinal
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:30
int iEvent
Definition: GenABIO.cc:243
std::vector< TrajectorySeed > TrajectorySeedCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:145
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
tuple conf
Definition: dbtoconf.py:185
void run(TrajectorySeedCollection &seedCollection, const TrackingRegion &region, const edm::Event &ev, const edm::EventSetup &es)
virtual void beginRun(edm::Run const &run, const edm::EventSetup &es) overridefinal
SurfaceDeformation * create(int type, const std::vector< double > &params)
T get(const Candidate &c)
Definition: component.h:56
Definition: Run.h:36