CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SeedFilter.cc
Go to the documentation of this file.
1 // Package: EgammaElectronAlgos
2 // Class: SeedFilter.
3 
6 
7 
10 
13 #include <vector>
14 
16 
21 
22 
25 
26 
28 
30 
33 
34 using namespace std;
35 using namespace reco;
36 
38  {
39  edm::LogInfo("EtaPhiRegionSeedFactory") << "Enter the EtaPhiRegionSeedFactory";
40  edm::ParameterSet regionPSet = conf.getParameter<edm::ParameterSet>("RegionPSet");
41 
42  ptmin_ = regionPSet.getParameter<double>("ptMin");
43  originradius_ = regionPSet.getParameter<double>("originRadius");
44  halflength_ = regionPSet.getParameter<double>("originHalfLength");
45  deltaEta_ = regionPSet.getParameter<double>("deltaEtaRegion");
46  deltaPhi_ = regionPSet.getParameter<double>("deltaPhiRegion");
47  useZvertex_ = regionPSet.getParameter<bool>("useZInVertex");
48  vertexSrc_ = regionPSet.getParameter<edm::InputTag> ("VertexProducer");
49 
50  // setup orderedhits setup (in order to tell seed generator to use pairs/triplets, which layers)
51  edm::ParameterSet hitsfactoryPSet = conf.getParameter<edm::ParameterSet>("OrderedHitsFactoryPSet");
52  std::string hitsfactoryName = hitsfactoryPSet.getParameter<std::string>("ComponentName");
53 
54  // HIT FACTORY MODE (JRV)
55  // -1 = look for existing hit collections for both pixels and strips
56  // 0 = look for pixel hit collections and build strip hits on demand (regional unpacking)
57  // 1 = build both pixel and strip hits on demand (regional unpacking)
58  hitsfactoryMode_ = hitsfactoryPSet.getUntrackedParameter<int>("useOnDemandTracker");
59 
60  // get orderd hits generator from factory
61  OrderedHitsGenerator* hitsGenerator = OrderedHitsGeneratorFactory::get()->create(hitsfactoryName, hitsfactoryPSet);
62 
63  // start seed generator
64  // FIXME??
65  edm::ParameterSet creatorPSet;
66  creatorPSet.addParameter<std::string>("propagator","PropagatorWithMaterial");
67 
68  combinatorialSeedGenerator = new SeedGeneratorFromRegionHits(hitsGenerator,0,
69  SeedCreatorFactory::get()->create("SeedFromConsecutiveHitsCreator", creatorPSet)
70  );
71  beamSpotTag_ = conf.getParameter<edm::InputTag>("beamSpot") ;
72  measurementTrackerName_ = conf.getParameter<std::string>("measurementTrackerName") ;
73  }
74 
76  delete combinatorialSeedGenerator;
77 }
78 
80 
81  setup.get<IdealMagneticFieldRecord>().get(theMagField);
82  std::auto_ptr<TrajectorySeedCollection> seedColl(new TrajectorySeedCollection());
83 
84  GlobalPoint vtxPos;
85  double deltaZVertex;
86 
87  //edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
88  //e.getByType(recoBeamSpotHandle);
89 
90  // gets its position
91  //const reco::BeamSpot::Point& BSPosition = recoBeamSpotHandle->position();
92  //vtxPos = GlobalPoint(BSPosition.x(), BSPosition.y(), BSPosition.z());
93  //double sigmaZ = recoBeamSpotHandle->sigmaZ();
94  //double sigmaZ0Error = recoBeamSpotHandle->sigmaZ0Error();
95  //double sq=sqrt(sigmaZ*sigmaZ+sigmaZ0Error*sigmaZ0Error);
96  //deltaZVertex = 3*sq; //halflength_;
97 
98  // get the primary vertex (if any)
99  reco::VertexCollection vertices;
101  if (e.getByLabel(vertexSrc_, h_vertices)) {
102  vertices = *(h_vertices.product());
103  } else {
104  LogDebug("SeedFilter") << "SeedFilter::seeds"
105  << "No vertex collection found: using beam-spot";
106  }
107 
108  if (!vertices.empty() && useZvertex_) {
109  vtxPos = GlobalPoint(vertices.front().x(), vertices.front().y(), vertices.front().z());
110  deltaZVertex = halflength_;
111 
112  } else {
113  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
114  //e.getByType(recoBeamSpotHandle);
115  e.getByLabel(beamSpotTag_,recoBeamSpotHandle);
116  // gets its position
117  const reco::BeamSpot::Point& BSPosition = recoBeamSpotHandle->position();
118  double sigmaZ = recoBeamSpotHandle->sigmaZ();
119  double sigmaZ0Error = recoBeamSpotHandle->sigmaZ0Error();
120  double sq=sqrt(sigmaZ*sigmaZ+sigmaZ0Error*sigmaZ0Error);
121  vtxPos = GlobalPoint(BSPosition.x(), BSPosition.y(), BSPosition.z());
122  deltaZVertex = 3*sq;
123  }
124 
125  //seeds selection
126  float energy = scRef->energy();
127 
128  const GlobalPoint clusterPos(scRef->position().x(), scRef->position().y(), scRef->position().z());
129 
130  //===============================================
131  // EtaPhiRegion and seeds for electron hypothesis
132  //===============================================
133 
134  TrackCharge aCharge = -1 ;
135  FreeTrajectoryState fts = myFTS(&(*theMagField), clusterPos, vtxPos, energy, aCharge);
136 
137  RectangularEtaPhiTrackingRegion etaphiRegionMinus(fts.momentum(),
138  vtxPos,
139  ptmin_,
140  originradius_,
141  deltaZVertex,
142  // deltaEta_,
143  // deltaPhi_,-1);
146  ,hitsfactoryMode_,
147  true, /*default in header*/
148  measurementTrackerName_
149  );
150  combinatorialSeedGenerator->run(*seedColl, etaphiRegionMinus, e, setup);
151 
152  for (unsigned int i = 0; i<seedColl->size(); ++i)
153  output->push_back((*seedColl)[i]);
154 
155  seedColl->clear();
156 
157  //===============================================
158  // EtaPhiRegion and seeds for positron hypothesis
159  //===============================================
160 
161  TrackCharge aChargep = 1 ;
162  fts = myFTS(&(*theMagField), clusterPos, vtxPos, energy, aChargep);
163 
164  RectangularEtaPhiTrackingRegion etaphiRegionPlus(fts.momentum(),
165  vtxPos,
166  ptmin_,
167  originradius_,
168  deltaZVertex,
169  // deltaEta_,
170  // deltaPhi_,-1);
173  ,hitsfactoryMode_
174  ,true, /*default in header*/
175  measurementTrackerName_
176  );
177 
178  combinatorialSeedGenerator->run(*seedColl, etaphiRegionPlus, e, setup);
179 
180  for (unsigned int i = 0; i<seedColl->size(); ++i){
181  TrajectorySeed::range r = (*seedColl)[i].recHits();
182  // first Hit
183  TrajectorySeed::const_iterator it = r.first;
184  const TrackingRecHit* a1 = &(*it);
185  // now second Hit
186  it++;
187  const TrackingRecHit* a2 = &(*it);
188  // check if the seed is already in the collection
189  bool isInCollection = false;
190  for(unsigned int j=0; j<output->size(); ++j) {
191  TrajectorySeed::range r = (*seedColl)[i].recHits();
192  // first Hit
193  TrajectorySeed::const_iterator it = r.first;
194  const TrackingRecHit* b1 = &(*it);
195  // now second Hit
196  it++;
197  const TrackingRecHit* b2 = &(*it);
198  if ((b1->sharesInput(a1, TrackingRecHit::all)) && (b2->sharesInput(a2, TrackingRecHit::all))) {
199  isInCollection = true;
200  break;
201  }
202  }
203  if (!isInCollection)
204  output->push_back((*seedColl)[i]);
205  }
206 
207  seedColl->clear();
208 }
209 
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
virtual bool sharesInput(const TrackingRecHit *other, SharedInputType what) const
#define abs(x)
Definition: mlp_lapack.h:159
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:30
void seeds(edm::Event &, const edm::EventSetup &, const reco::SuperClusterRef &, TrajectorySeedCollection *)
Definition: SeedFilter.cc:79
int TrackCharge
Definition: TrackCharge.h:4
std::vector< TrajectorySeed > TrajectorySeedCollection
recHitContainer::const_iterator const_iterator
T sqrt(T t)
Definition: SSEVec.h:46
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:145
virtual std::vector< const TrackingRecHit * > recHits() const =0
Access to component RecHits (if any)
int j
Definition: DBlmapReader.cc:9
std::pair< const_iterator, const_iterator > range
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
GlobalVector momentum() const
tuple conf
Definition: dbtoconf.py:185
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: Handle.h:74
SeedFilter(const edm::ParameterSet &conf)
Definition: SeedFilter.cc:37
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
SurfaceDeformation * create(int type, const std::vector< double > &params)
TkTrackingRegionsMargin< float > Margin
T get(const Candidate &c)
Definition: component.h:56