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