CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SimpleCosmicBONSeeder.cc
Go to the documentation of this file.
1 //
2 // Package: RecoTracker/TkSeedGenerator
3 // Class: GlobalPixelLessSeedGenerator
4 //
5 // From CosmicSeedGenerator+SimpleCosmicBONSeeder, with changes by Giovanni
6 // to seed Cosmics with B != 0
7 
14 
15 #include <numeric>
16 
17 using namespace std;
19  conf_(conf),
20  theLsb(conf.getParameter<edm::ParameterSet>("TripletsPSet")),
21  writeTriplets_(conf.getParameter<bool>("writeTriplets")),
22  seedOnMiddle_(conf.existsAs<bool>("seedOnMiddle") ? conf.getParameter<bool>("seedOnMiddle") : false),
23  rescaleError_(conf.existsAs<double>("rescaleError") ? conf.getParameter<double>("rescaleError") : 1.0),
24  tripletsVerbosity_(conf.getParameter<edm::ParameterSet>("TripletsPSet").getUntrackedParameter<uint32_t>("debugLevel",0)),
25  seedVerbosity_(conf.getUntrackedParameter<uint32_t>("seedDebugLevel",0)),
26  helixVerbosity_(conf.getUntrackedParameter<uint32_t>("helixDebugLevel",0)),
27  check_(conf.getParameter<edm::ParameterSet>("ClusterCheckPSet")),
28  maxTriplets_(conf.getParameter<int32_t>("maxTriplets")),
29  maxSeeds_(conf.getParameter<int32_t>("maxSeeds"))
30 {
31  edm::ParameterSet regionConf = conf_.getParameter<edm::ParameterSet>("RegionPSet");
32  float ptmin = regionConf.getParameter<double>("ptMin");
33  float originradius = regionConf.getParameter<double>("originRadius");
34  float halflength = regionConf.getParameter<double>("originHalfLength");
35  float originz = regionConf.getParameter<double>("originZPosition");
36  region_ = GlobalTrackingRegion(ptmin, originradius, halflength, originz);
37  pMin_ = regionConf.getParameter<double>("pMin");
38 
39  builderName = conf_.getParameter<std::string>("TTRHBuilder");
40 
41  //***top-bottom
42  positiveYOnly=conf_.getParameter<bool>("PositiveYOnly");
43  negativeYOnly=conf_.getParameter<bool>("NegativeYOnly");
44  //***
45 
46  produces<TrajectorySeedCollection>();
47  if (writeTriplets_) produces<edm::OwnVector<TrackingRecHit> >("cosmicTriplets");
48 
49  layerTripletNames_ = conf_.getParameter<edm::ParameterSet>("TripletsPSet").getParameter<std::vector<std::string> >("layerList");
50 
51  if (conf.existsAs<edm::ParameterSet>("ClusterChargeCheck")) {
52  edm::ParameterSet cccc = conf.getParameter<edm::ParameterSet>("ClusterChargeCheck");
53  checkCharge_ = cccc.getParameter<bool>("checkCharge");
54  matchedRecHitUsesAnd_ = cccc.getParameter<bool>("matchedRecHitsUseAnd");
55  chargeThresholds_.resize(7,0);
56  edm::ParameterSet ccct = cccc.getParameter<edm::ParameterSet>("Thresholds");
58  chargeThresholds_[StripSubdetector::TID] = ccct.getParameter<int32_t>("TID");
59  chargeThresholds_[StripSubdetector::TOB] = ccct.getParameter<int32_t>("TOB");
60  chargeThresholds_[StripSubdetector::TEC] = ccct.getParameter<int32_t>("TEC");
61  } else {
62  checkCharge_ = false;
63  }
64  if (conf.existsAs<edm::ParameterSet>("HitsPerModuleCheck")) {
65  edm::ParameterSet hpmcc = conf.getParameter<edm::ParameterSet>("HitsPerModuleCheck");
66  checkMaxHitsPerModule_ = hpmcc.getParameter<bool>("checkHitsPerModule");
68  edm::ParameterSet hpmct = hpmcc.getParameter<edm::ParameterSet>("Thresholds");
69  maxHitsPerModule_[StripSubdetector::TIB] = hpmct.getParameter<int32_t>("TIB");
70  maxHitsPerModule_[StripSubdetector::TID] = hpmct.getParameter<int32_t>("TID");
71  maxHitsPerModule_[StripSubdetector::TOB] = hpmct.getParameter<int32_t>("TOB");
72  maxHitsPerModule_[StripSubdetector::TEC] = hpmct.getParameter<int32_t>("TEC");
73  } else {
74  checkMaxHitsPerModule_ = false;
75  }
77  goodHitsPerSeed_ = conf.getParameter<int32_t>("minimumGoodHitsInSeed");
78  } else {
79  goodHitsPerSeed_ = 0;
80  }
81 
82 }
83 
84 // Functions that gets called by framework every event
86 {
87  std::auto_ptr<TrajectorySeedCollection> output(new TrajectorySeedCollection());
88  std::auto_ptr<edm::OwnVector<TrackingRecHit> > outtriplets(new edm::OwnVector<TrackingRecHit>());
89 
91  if (magfield->inTesla(GlobalPoint(0,0,0)).mag() > 0.01) {
92  size_t clustsOrZero = check_.tooManyClusters(ev);
93  if (clustsOrZero) {
94  edm::LogError("TooManyClusters") << "Found too many clusters (" << clustsOrZero << "), bailing out.\n";
95  } else {
96  init(es);
97  bool tripletsOk = triplets(ev,es);
98  if (tripletsOk) {
99 
100  bool seedsOk = seeds(*output,es);
101  if (!seedsOk) { }
102 
103  if (writeTriplets_) {
104  for (OrderedHitTriplets::const_iterator it = hitTriplets.begin(); it != hitTriplets.end(); ++it) {
105  const TrackingRecHit * hit1 = it->inner()->hit();
106  const TrackingRecHit * hit2 = it->middle()->hit();
107  const TrackingRecHit * hit3 = it->outer()->hit();
108  outtriplets->push_back(hit1->clone());
109  outtriplets->push_back(hit2->clone());
110  outtriplets->push_back(hit3->clone());
111  }
112  }
113  }
114  done();
115  }
116  }
117 
118  if (writeTriplets_) {
119  ev.put(outtriplets, "cosmicTriplets");
120  }
121  ev.put(output);
122 }
123 
124 void
126 {
127  iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
129 
130  // FIXME: these should come from ES too!!
133  theUpdator = new KFUpdator();
134 
135 }
136 
138  bool operator()(const OrderedHitTriplet &trip1, const OrderedHitTriplet &trip2) const {
139  //FIXME: inner gives a SEGV
140 #if 0
141  //const TransientTrackingRecHit::ConstRecHitPointer &ihit1 = trip1.inner();
142  //const TransientTrackingRecHit::ConstRecHitPointer &ihit2 = trip2.inner();
145  const TransientTrackingRecHit::ConstRecHitPointer &ohit1 = trip1.outer();
146  const TransientTrackingRecHit::ConstRecHitPointer &ohit2 = trip2.outer();
147 #endif
152  float iy1 = ihit1->globalPosition().y();
153  float oy1 = ohit1->globalPosition().y();
154  float iy2 = ihit2->globalPosition().y();
155  float oy2 = ohit2->globalPosition().y();
156  if (oy1 - iy1 > 0) { // 1 Downgoing
157  if (oy2 - iy2 > 0) { // 2 Downgoing
158  // sort by inner, or by outer if inners are the same
159  return (iy1 != iy2 ? (iy1 > iy2) : (oy1 > oy2));
160  } else return true; // else prefer downgoing
161  } else if (oy2 - iy2 > 0) {
162  return false; // prefer downgoing
163  } else { // both upgoing
164  // sort by inner, or by outer
165  return (iy1 != iy2 ? (iy1 < iy2) : (oy1 < oy2));
166  }
167  }
168 };
169 
171  using namespace ctfseeding;
172 
173  hitTriplets.clear();
174  hitTriplets.reserve(0);
175  SeedingLayerSets lss = theLsb.layers(es);
176  SeedingLayerSets::const_iterator iLss;
177 
178  double minRho = region_.ptMin() / ( 0.003 * magfield->inTesla(GlobalPoint(0,0,0)).z() );
179 
180  for (iLss = lss.begin(); iLss != lss.end(); iLss++){
181  SeedingLayers ls = *iLss;
182  if (ls.size() != 3){
183  throw cms::Exception("CtfSpecialSeedGenerator") << "You are using " << ls.size() <<" layers in set instead of 3 ";
184  }
185 
187  std::vector<SeedingHit> innerHits = region_.hits(e, es, &ls[0]);
188  std::vector<SeedingHit> middleHits = region_.hits(e, es, &ls[1]);
189  std::vector<SeedingHit> outerHits = region_.hits(e, es, &ls[2]);
190  std::vector<SeedingHit>::const_iterator iOuterHit,iMiddleHit,iInnerHit;
191 
192  if (tripletsVerbosity_ > 0) {
193  std::cout << "GenericTripletGenerator iLss = " << layerTripletNames_[iLss - lss.begin()]
194  << " (" << (iLss - lss.begin()) << "): # = "
195  << innerHits.size() << "/" << middleHits.size() << "/" << outerHits.size() << std::endl;
196  }
197 
200  std::vector<TTRH> innerTTRHs, middleTTRHs, outerTTRHs;
201 
203  std::vector<bool> innerOk( innerHits.size(), true);
204  std::vector<bool> middleOk(middleHits.size(), true);
205  std::vector<bool> outerOk( outerHits.size(), true);
206 
207  size_t sizBefore = hitTriplets.size();
209  int idx = 0;
210  for (iOuterHit = outerHits.begin(), idx = 0; iOuterHit != outerHits.end(); ++idx, ++iOuterHit){
211  outerTTRHs.push_back(ls[2].hitBuilder()->build((**iOuterHit).hit()));
212  if (checkCharge_ && !checkCharge(outerTTRHs.back()->hit())) outerOk[idx] = false;
213  }
214  for (iMiddleHit = middleHits.begin(), idx = 0; iMiddleHit != middleHits.end(); ++idx, ++iMiddleHit){
215  middleTTRHs.push_back(ls[1].hitBuilder()->build((**iMiddleHit).hit()));
216  if (checkCharge_ && !checkCharge(middleTTRHs.back()->hit())) middleOk[idx] = false;
217  }
218  for (iInnerHit = innerHits.begin(), idx = 0; iInnerHit != innerHits.end(); ++idx, ++iInnerHit){
219  innerTTRHs.push_back(ls[0].hitBuilder()->build((**iInnerHit).hit()));
220  if (checkCharge_ && !checkCharge(innerTTRHs.back()->hit())) innerOk[idx] = false;
221  }
223  checkNoisyModules(innerTTRHs, innerOk);
224  checkNoisyModules(middleTTRHs, middleOk);
225  checkNoisyModules(outerTTRHs, outerOk);
226  }
227 
228  for (iOuterHit = outerHits.begin(); iOuterHit != outerHits.end(); iOuterHit++){
229  idx = iOuterHit - outerHits.begin();
230  TTRH & outerTTRH = outerTTRHs[idx];
231  GlobalPoint outerpos = outerTTRH->globalPosition(); // this caches by itself
232  bool outerok = outerOk[idx];
233  if (outerok < goodHitsPerSeed_ - 2) {
234  if (tripletsVerbosity_ > 2)
235  std::cout << "Skipping at first hit: " << (outerok) << " < " << (goodHitsPerSeed_ - 2) << std::endl;
236  continue;
237  }
238 
239  for (iMiddleHit = middleHits.begin(); iMiddleHit != middleHits.end(); iMiddleHit++){
240  idx = iMiddleHit - middleHits.begin();
241  TTRH & middleTTRH = middleTTRHs[idx];
242  GlobalPoint middlepos = middleTTRH->globalPosition(); // this caches by itself
243  bool middleok = middleOk[idx];
244  if (outerok+middleok < goodHitsPerSeed_ - 1) {
245  if (tripletsVerbosity_ > 2)
246  std::cout << "Skipping at second hit: " << (outerok+middleok) << " < " << (goodHitsPerSeed_ - 1) << std::endl;
247  continue;
248  }
249 
250  for (iInnerHit = innerHits.begin(); iInnerHit != innerHits.end(); iInnerHit++){
251  idx = iInnerHit - innerHits.begin();
252  TTRH & innerTTRH = innerTTRHs[idx];
253  GlobalPoint innerpos = innerTTRH->globalPosition(); // this caches by itself
254  bool innerok = innerOk[idx];
255  if (outerok+middleok+innerok < goodHitsPerSeed_) {
256  if (tripletsVerbosity_ > 2)
257  std::cout << "Skipping at third hit: " << (outerok+middleok+innerok) << " < " << (goodHitsPerSeed_) << std::endl;
258  continue;
259  }
260 
261  //***top-bottom
262  if (positiveYOnly && (innerpos.y()<0 || middlepos.y()<0 || outerpos.y()<0
263  || outerpos.y() < innerpos.y()
264  ) ) continue;
265  if (negativeYOnly && (innerpos.y()>0 || middlepos.y()>0 || outerpos.y()>0
266  || outerpos.y() > innerpos.y()
267  ) ) continue;
268  //***
269 
270  if (tripletsVerbosity_ > 2) std::cout << "Trying seed with: " << innerpos << " + " << middlepos << " + " << outerpos << std::endl;
271  if (goodTriplet(innerpos,middlepos,outerpos,minRho)) {
272  OrderedHitTriplet oht(*iInnerHit,*iMiddleHit,*iOuterHit);
273  hitTriplets.push_back(oht);
274  if ((maxTriplets_ > 0) && (hitTriplets.size() > size_t(maxTriplets_))) {
275  hitTriplets.clear(); // clear
276  //OrderedHitTriplets().swap(hitTriplets); // really clear
277  edm::LogError("TooManyTriplets") << "Found too many triplets, bailing out.\n";
278  return false;
279  }
280  if (tripletsVerbosity_ > 3) {
281  std::cout << " accepted seed #" << (hitTriplets.size()-1) << " w/: "
282  << innerpos << " + " << middlepos << " + " << outerpos << std::endl;
283  }
284  if (tripletsVerbosity_ == 2) {
285  std::cout << " good seed #" << (hitTriplets.size()-1) << " w/: "
286  << innerpos << " + " << middlepos << " + " << outerpos << std::endl;
287  }
288  if (tripletsVerbosity_ > 3 && (helixVerbosity_ > 0)) { // debug the momentum here too
289  pqFromHelixFit(innerpos,middlepos,outerpos,es);
290  }
291  }
292  }
293  }
294  }
295  if ((tripletsVerbosity_ > 0) && (hitTriplets.size() > sizBefore)) {
296  std::cout << " iLss = " << layerTripletNames_[iLss - lss.begin()]
297  << " (" << (iLss - lss.begin()) << "): # = "
298  << innerHits.size() << "/" << middleHits.size() << "/" << outerHits.size()
299  << ": Found " << (hitTriplets.size() - sizBefore) << " seeds [running total: " << hitTriplets.size() << "]"
300  << std::endl ;
301  }
302 
303  }
305  return true;
306 }
308  DetId detid(hit->geographicalId());
309  if (detid.det() != DetId::Tracker) return false; // should not happen
310  int subdet = detid.subdetId();
311  if (subdet < 3) { // pixel
312  return true;
313  } else {
314  if (typeid(*hit) == typeid(SiStripMatchedRecHit2D)) {
315  const SiStripMatchedRecHit2D *mhit = static_cast<const SiStripMatchedRecHit2D *>(hit);
316  if (matchedRecHitUsesAnd_) {
317  return checkCharge(*mhit->monoHit(), subdet) && checkCharge(*mhit->stereoHit(), subdet);
318  } else {
319  return checkCharge(*mhit->monoHit(), subdet) || checkCharge(*mhit->stereoHit(), subdet);
320  }
321  } else if (typeid(*hit) == typeid(SiStripRecHit2D)) {
322  return checkCharge(static_cast<const SiStripRecHit2D &>(*hit), subdet);
323  } else {
324  return true;
325  }
326  }
327 }
328 bool SimpleCosmicBONSeeder::checkCharge(const SiStripRecHit2D &hit, int subdetid) const {
329  const SiStripCluster *clust = (hit.cluster().isNonnull() ? hit.cluster().get() : hit.cluster_regional().get());
330  int charge = std::accumulate(clust->amplitudes().begin(), clust->amplitudes().end(), int(0));
331  if (tripletsVerbosity_ > 1) {
332  std::cerr << "Hit on " << subdetid << ", charge = " << charge << ", threshold = " << chargeThresholds_[subdetid]
333  << ", detid = " << hit.geographicalId().rawId() << ", firstStrip = " << clust->firstStrip() << std::endl;
334  } else if ((tripletsVerbosity_ == 1) && (charge < chargeThresholds_[subdetid])) {
335  std::cerr << "Hit on " << subdetid << ", charge = " << charge << ", threshold = " << chargeThresholds_[subdetid]
336  << ", detid = " << hit.geographicalId().rawId() << ", firstStrip = " << clust->firstStrip() << std::endl;
337  }
338  return charge > chargeThresholds_[subdetid];
339 }
340 
341 void SimpleCosmicBONSeeder::checkNoisyModules(const std::vector<TransientTrackingRecHit::RecHitPointer> &hits, std::vector<bool> &oks) const {
343  std::vector<TTRH>::const_iterator it = hits.begin(), start = it, end = hits.end();
344  std::vector<bool>::iterator ok = oks.begin(), okStart = ok, okEnd = oks.end();
345  while (start < end) {
346  DetId lastid = (*start)->geographicalId();
347  for (it = start + 1; (it < end) && ((*it)->geographicalId() == lastid); ++it) {
348  ++ok;
349  }
350  if ( (it - start) > maxHitsPerModule_[lastid.subdetId()] ) {
351  if (tripletsVerbosity_ > 0) {
352  std::cerr << "SimpleCosmicBONSeeder: Marking noisy module " << lastid.rawId() << ", it has " << (it-start) << " rechits"
353  << " (threshold is " << maxHitsPerModule_[lastid.subdetId()] << ")" << std::endl;
354  }
355  std::fill(okStart,ok,false);
356  } else if (tripletsVerbosity_ > 0) {
357  if ( (it - start) > std::min(4,maxHitsPerModule_[lastid.subdetId()]/4) ) {
358  std::cerr << "SimpleCosmicBONSeeder: Not marking noisy module " << lastid.rawId() << ", it has " << (it-start) << " rechits"
359  << " (threshold is " << maxHitsPerModule_[lastid.subdetId()] << ")" << std::endl;
360  }
361  }
362  start = it; okStart = ok;
363  }
364 }
365 
366 bool SimpleCosmicBONSeeder::goodTriplet(const GlobalPoint &inner, const GlobalPoint & middle, const GlobalPoint & outer, const double &minRho) const {
367  float dyOM = outer.y() - middle.y(), dyIM = inner.y() - middle.y();
368  if ((dyOM * dyIM > 0) && (fabs(dyOM)>10) && (fabs(dyIM)>10)) {
369  if (tripletsVerbosity_ > 2) std::cout << " fail for non coherent dy" << std::endl;
370  return false;
371  }
372  float dzOM = outer.z() - middle.z(), dzIM = inner.z() - middle.z();
373  if ((dzOM * dzIM > 0) && (fabs(dzOM)>50) && (fabs(dzIM)>50)) {
374  if (tripletsVerbosity_ > 2) std::cout << " fail for non coherent dz" << std::endl;
375  return false;
376  }
377  if (minRho > 0) {
378  FastCircle theCircle(inner,middle,outer);
379  if (theCircle.rho() < minRho) {
380  if (tripletsVerbosity_ > 2) std::cout << " fail for pt cut" << std::endl;
381  return false;
382  }
383  }
384  return true;
385 }
386 
387 std::pair<GlobalVector,int>
389  const edm::EventSetup& iSetup) const {
390  if (helixVerbosity_ > 0) {
391  std::cout << "DEBUG PZ =====" << std::endl;
392  FastHelix helix(inner,middle,outer,iSetup);
393  GlobalVector gv=helix.stateAtVertex().parameters().momentum(); // status on inner hit
394  std::cout << "FastHelix P = " << gv << "\n";
395  std::cout << "FastHelix Q = " << helix.stateAtVertex().parameters().charge() << "\n";
396  }
397 
398  // My attempt (with different approx from FastHelix)
399  // 1) fit the circle
400  FastCircle theCircle(inner,middle,outer);
401  double rho = theCircle.rho();
402 
403  // 2) Get the PT
404  GlobalVector tesla = magfield->inTesla(middle);
405  double pt = 0.01 * rho * (0.3*tesla.z());
406 
407  // 3) Get the PX,PY at OUTER hit (VERTEX)
408  double dx1 = outer.x()-theCircle.x0();
409  double dy1 = outer.y()-theCircle.y0();
410  double py = pt*dx1/rho, px = -pt*dy1/rho;
411  if(px*(middle.x() - outer.x()) + py*(middle.y() - outer.y()) < 0.) {
412  px *= -1.; py *= -1.;
413  }
414 
415  // 4) Get the PZ through pz = pT*(dz/d(R*phi)))
416  double dz = inner.z() - outer.z();
417  double sinphi = ( dx1*(inner.y()-theCircle.y0()) - dy1*(inner.x()-theCircle.x0())) / (rho * rho);
418  double dphi = std::abs(std::asin(sinphi));
419  double pz = pt * dz / (dphi * rho);
420 
421  int myq = ((theCircle.x0()*py - theCircle.y0()*px) / tesla.z()) > 0. ? +1 : -1;
422 
423  std::pair<GlobalVector,int> mypq(GlobalVector(px,py,pz),myq);
424 
425  if (helixVerbosity_ > 1) {
426  std::cout << "Gio: pt = " << pt << std::endl;
427  std::cout << "Gio: dz = " << dz << ", sinphi = " << sinphi << ", dphi = " << dphi << ", dz/drphi = " << (dz/dphi/rho) << std::endl;
428  }
429  if (helixVerbosity_ > 0) {
430  std::cout << "Gio's fit P = " << mypq.first << "\n";
431  std::cout << "Gio's fit Q = " << myq << "\n";
432  }
433 
434  return mypq;
435 }
436 
438 {
440 
441  for (size_t it=0;it<hitTriplets.size();it++){
442  const OrderedHitTriplet &trip = hitTriplets[it];
443 
444  GlobalPoint inner = tracker->idToDet((*(trip.inner())).geographicalId())->surface().
445  toGlobal((*(trip.inner())).localPosition());
446 
447  GlobalPoint middle = tracker->idToDet((*(trip.middle())).geographicalId())->surface().
448  toGlobal((*(trip.middle())).localPosition());
449 
450  GlobalPoint outer = tracker->idToDet((*(trip.outer())).geographicalId())->surface().
451  toGlobal((*(trip.outer())).localPosition());
452 
453  if (seedVerbosity_ > 1)
454  std::cout << "Processing triplet " << it << ": " << inner << " + " << middle << " + " << outer << std::endl;
455 
456  if ( (outer.y()-inner.y())*outer.y() < 0 ) {
457  std::swap(inner,outer);
458  std::swap(const_cast<TransientTrackingRecHit::ConstRecHitPointer &>(trip.inner()),
459  const_cast<TransientTrackingRecHit::ConstRecHitPointer &>(trip.outer()) );
460 
461 // std::swap(const_cast<ctfseeding::SeedingHit &>(trip.inner()),
462 // const_cast<ctfseeding::SeedingHit &>(trip.outer()) );
463  if (seedVerbosity_ > 1) {
464  std::cout << "The seed was going away from CMS! swapped in <-> out" << std::endl;
465  std::cout << "Processing swapped triplet " << it << ": " << inner << " + " << middle << " + " << outer << std::endl;
466  }
467  }
468 
469  // First use FastHelix out of the box
470  std::pair<GlobalVector,int> pq = pqFromHelixFit(inner,middle,outer,iSetup);
471  GlobalVector gv = pq.first;
472  float ch = pq.second;
473  float Mom = sqrt( gv.x()*gv.x() + gv.y()*gv.y() + gv.z()*gv.z() );
474 
475  if(Mom > 10000 || isnan(Mom)) {
476  if (seedVerbosity_ > 1)
477  std::cout << "Processing triplet " << it << ": fail for momentum." << std::endl;
478  continue;
479  }
480 
481  if (gv.perp() < region_.ptMin()) {
482  if (seedVerbosity_ > 1)
483  std::cout << "Processing triplet " << it << ": fail for pt = " << gv.perp() << " < ptMin = " << region_.ptMin() << std::endl;
484  continue;
485  }
486 
487  const Propagator * propagator = 0;
488  if((outer.y()-inner.y())>0){
489  if (seedVerbosity_ > 1)
490  std::cout << "Processing triplet " << it << ": downgoing." << std::endl;
491  propagator = thePropagatorAl;
492  } else {
493  gv = -1*gv; ch = -1.*ch;
494  propagator = thePropagatorOp;
495  if (seedVerbosity_ > 1)
496  std::cout << "Processing triplet " << it << ": upgoing." << std::endl;
497  }
498 
499  if (seedVerbosity_ > 1) {
500  if (( gv.z() * (outer.z()-inner.z()) > 0 ) && ( fabs(outer.z()-inner.z()) > 5) && (fabs(gv.z()) > .01)) {
501  std::cout << "ORRORE: outer.z()-inner.z() = " << (outer.z()-inner.z()) << ", gv.z() = " << gv.z() << std::endl;
502  }
503  }
504 
505  GlobalTrajectoryParameters Gtp(outer,
506  gv,int(ch),
507  &(*magfield));
508  FreeTrajectoryState CosmicSeed(Gtp,
510  CosmicSeed.rescaleError(100);
511  if (seedVerbosity_ > 2) {
512  std::cout << "Processing triplet " << it << ". start from " << std::endl;
513  std::cout << " X = " << outer << ", P = " << gv << std::endl;
514  std::cout << " Cartesian error (X,P) = \n" << CosmicSeed.cartesianError().matrix() << std::endl;
515  }
516 
518 // OrderedHitTriplet::Hits seedHits;
520  seedHits.push_back(trip.outer());
521  seedHits.push_back(trip.middle());
522  seedHits.push_back(trip.inner());
523  TSOS propagated, updated;
524  bool fail = false;
525  for (size_t ih = 0; ih < 3; ++ih) {
526  if ((ih == 2) && seedOnMiddle_) {
527  if (seedVerbosity_ > 2)
528  std::cout << "Stopping at middle hit, as requested." << std::endl;
529  break;
530  }
531  if (seedVerbosity_ > 2)
532  std::cout << "Processing triplet " << it << ", hit " << ih << "." << std::endl;
533  if (ih == 0) {
534  propagated = propagator->propagate(CosmicSeed, tracker->idToDet((*seedHits[ih]).geographicalId())->surface());
535  } else {
536  propagated = propagator->propagate(updated, tracker->idToDet((*seedHits[ih]).geographicalId())->surface());
537  }
538  if (!propagated.isValid()) {
539  if (seedVerbosity_ > 1)
540  std::cout << "Processing triplet " << it << ", hit " << ih << ": failed propagation." << std::endl;
541  fail = true; break;
542  } else {
543  if (seedVerbosity_ > 2)
544  std::cout << "Processing triplet " << it << ", hit " << ih << ": propagated state = " << propagated;
545  }
546  const TransientTrackingRecHit::ConstRecHitPointer & tthp = seedHits[ih];
547  TransientTrackingRecHit::RecHitPointer newtth = tthp->clone(propagated);
548  hits.push_back(newtth->hit()->clone());
549  updated = theUpdator->update(propagated, *newtth);
550  if (!updated.isValid()) {
551  if (seedVerbosity_ > 1)
552  std::cout << "Processing triplet " << it << ", hit " << ih << ": failed update." << std::endl;
553  fail = true; break;
554  } else {
555  if (seedVerbosity_ > 2)
556  std::cout << "Processing triplet " << it << ", hit " << ih << ": updated state = " << updated;
557  }
558  }
559  if (!fail && updated.isValid() && (updated.globalMomentum().perp() < region_.ptMin())) {
560  if (seedVerbosity_ > 1)
561  std::cout << "Processing triplet " << it <<
562  ": failed for final pt " << updated.globalMomentum().perp() << " < " << region_.ptMin() << std::endl;
563  fail = true;
564  }
565  if (!fail && updated.isValid() && (updated.globalMomentum().mag() < pMin_)) {
566  if (seedVerbosity_ > 1)
567  std::cout << "Processing triplet " << it <<
568  ": failed for final p " << updated.globalMomentum().perp() << " < " << pMin_ << std::endl;
569  fail = true;
570  }
571  if (!fail) {
572  if (rescaleError_ != 1.0) {
573  if (seedVerbosity_ > 2) {
574  std::cout << "Processing triplet " << it << ", rescale error by " << rescaleError_ << ": state BEFORE rescaling " << updated;
575  std::cout << " Cartesian error (X,P) before rescaling= \n" << updated.cartesianError().matrix() << std::endl;
576  }
577  updated.rescaleError(rescaleError_);
578  }
579  if (seedVerbosity_ > 0) {
580  std::cout << "Processed triplet " << it << ": success (saved as #"<<output.size()<<") : "
581  << inner << " + " << middle << " + " << outer << std::endl;
582  std::cout << " pt = " << updated.globalMomentum().perp() <<
583  " eta = " << updated.globalMomentum().eta() <<
584  " phi = " << updated.globalMomentum().phi() <<
585  " ch = " << updated.charge() << std::endl;
586  if (seedVerbosity_ > 1) {
587  std::cout << " State:" << updated;
588  } else {
589  std::cout << " X = " << updated.globalPosition() << ", P = " << updated.globalMomentum() << std::endl;
590  }
591  std::cout << " Cartesian error (X,P) = \n" << updated.cartesianError().matrix() << std::endl;
592  }
593 
594  std::auto_ptr<PTrajectoryStateOnDet> PTraj(transformer.persistentState(updated,
595  (*(seedOnMiddle_ ? trip.middle() : trip.inner())).geographicalId().rawId()));
596  output.push_back(TrajectorySeed(*PTraj,hits,
597  ( (outer.y()-inner.y()>0) ? alongMomentum : oppositeToMomentum) ));
598  if ((maxSeeds_ > 0) && (output.size() > size_t(maxSeeds_))) {
599  output.clear();
600  edm::LogError("TooManySeeds") << "Found too many seeds, bailing out.\n";
601  return false;
602  }
603  }
604  }
605  return true;
606 }
607 
609  delete thePropagatorAl;
610  delete thePropagatorOp;
611  delete theUpdator;
612 }
613 
614 
T getParameter(std::string const &) const
GlobalTrackingRegion region_
FTS stateAtVertex() const
Definition: FastHelix.cc:7
const OuterRecHit & outer() const
bool triplets(const edm::Event &e, const edm::EventSetup &c)
void init(const edm::EventSetup &c)
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:180
T perp() const
Definition: PV3DBase.h:66
const GlobalTrajectoryParameters & parameters() const
double x0() const
Definition: FastCircle.h:50
const SiStripRecHit2D * stereoHit() const
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
OrderedHitTriplets hitTriplets
Definition: DDAxes.h:10
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:57
const InnerRecHit & inner() const
virtual void produce(edm::Event &e, const edm::EventSetup &c)
const MiddleRecHit & middle() const
#define abs(x)
Definition: mlp_lapack.h:159
GlobalPoint globalPosition() const
#define min(a, b)
Definition: mlp_lapack.h:161
uint16_t firstStrip() const
void checkNoisyModules(const std::vector< TransientTrackingRecHit::RecHitPointer > &hits, std::vector< bool > &oks) const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
bool checkCharge(const TrackingRecHit *hit) const
ClusterRegionalRef const & cluster_regional() const
TrajectoryStateOnSurface TSOS
double charge(const std::vector< uint8_t > &Ampls)
double rho() const
Definition: FastCircle.h:54
SimpleCosmicBONSeeder(const edm::ParameterSet &conf)
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:248
TrajectoryStateTransform transformer
edm::ESHandle< TrackerGeometry > tracker
std::pair< GlobalVector, int > pqFromHelixFit(const GlobalPoint &inner, const GlobalPoint &middle, const GlobalPoint &outer, const edm::EventSetup &iSetup) const
virtual TrackingRegion::Hits hits(const edm::Event &ev, const edm::EventSetup &es, const ctfseeding::SeedingLayer *layer) const
get hits from layer compatible with region constraints
void push_back(D *&d)
Definition: OwnVector.h:288
SeedingLayerSetsBuilder theLsb
T mag() const
Definition: PV3DBase.h:61
std::vector< TrajectorySeed > TrajectorySeedCollection
const T & max(const T &a, const T &b)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
bool isnan(float x)
Definition: math.h:13
const CartesianTrajectoryError & cartesianError() const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
virtual float ptMin() const
minimal pt of interest
T sqrt(T t)
Definition: SSEVec.h:28
PropagatorWithMaterial * thePropagatorOp
T z() const
Definition: PV3DBase.h:58
edm::ESHandle< MagneticField > magfield
edm::ESHandle< TransientTrackingRecHitBuilder > TTTRHBuilder
PTrajectoryStateOnDet * persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid) const
#define end
Definition: vmac.h:38
TransientTrackingRecHit::ConstRecHitContainer RecHits
Definition: SeedingHitSet.h:9
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
tuple conf
Definition: dbtoconf.py:185
PropagatorWithMaterial * thePropagatorAl
const AlgebraicSymMatrix66 & matrix() const
virtual TrajectoryStateOnSurface propagate(const FreeTrajectoryState &, const Surface &) const
Definition: Propagator.cc:9
virtual TrackingRecHit * clone() const =0
size_t tooManyClusters(const edm::Event &e)
Definition: DetId.h:20
void rescaleError(double factor)
const T & get() const
Definition: EventSetup.h:55
bool seeds(TrajectorySeedCollection &output, const edm::EventSetup &iSetup)
ClusterRef const & cluster() const
const CartesianTrajectoryError & cartesianError() const
bool goodTriplet(const GlobalPoint &inner, const GlobalPoint &middle, const GlobalPoint &outer, const double &minRho) const
T eta() const
Definition: PV3DBase.h:70
bool operator()(const OrderedHitTriplet &trip1, const OrderedHitTriplet &trip2) const
double ptmin
Definition: HydjetWrapper.h:86
double y0() const
Definition: FastCircle.h:52
GlobalVector globalMomentum() const
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TransientTrackingRecHit &) const
Definition: KFUpdator.cc:10
ctfseeding::SeedingLayerSets layers(const edm::EventSetup &es) const
std::vector< std::string > layerTripletNames_
TransientTrackingRecHit::ConstRecHitPointer SeedingHit
std::vector< int32_t > chargeThresholds_
tuple cout
Definition: gather_cfg.py:41
std::vector< int32_t > maxHitsPerModule_
DetId geographicalId() const
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:239
const SiStripRecHit2D * monoHit() const
virtual unsigned int size() const
T x() const
Definition: PV3DBase.h:56
const std::vector< uint8_t > & amplitudes() const
std::vector< SeedingLayer > SeedingLayers
Global3DVector GlobalVector
Definition: GlobalVector.h:10
std::vector< std::vector< SeedingLayer > > SeedingLayerSets