CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CosmicHitPairGeneratorFromLayerPair.cc
Go to the documentation of this file.
11 
12 using namespace std;
13 // typedef TransientTrackingRecHit::ConstRecHitPointer TkHitPairsCachedHit;
14 
16  const LayerWithHits* outer,
17  const TrackerGeometry& geom)
18  : trackerGeometry(&geom), theOuterLayer(outer), theInnerLayer(inner) {}
20 
22  // static int NSee = 0; static int Ntry = 0; static int Nacc = 0;
23 
24  typedef OrderedHitPair::InnerRecHit InnerHit;
25  typedef OrderedHitPair::OuterRecHit OuterHit;
26 
27  if (theInnerLayer->recHits().empty())
28  return;
29 
30  if (theOuterLayer->recHits().empty())
31  return;
32  // const DetLayer* innerlay=theOuterLayer->layer();
33  // const BarrelDetLayer *pippo=dynamic_cast<const BarrelDetLayer*>(theOuterLayer->layer());
34 
35  // ************ Daniele
36 
37  const DetLayer* blay1;
38  const DetLayer* blay2;
39  blay1 = dynamic_cast<const BarrelDetLayer*>(theInnerLayer->layer());
40  blay2 = dynamic_cast<const BarrelDetLayer*>(theOuterLayer->layer());
41 
42  bool seedfromoverlaps = false;
43  bool InTheBarrel = false;
44  bool InTheForward = false;
45  if (blay1 && blay2) {
46  InTheBarrel = true;
47  } else
48  InTheForward = true;
49 
50  if (InTheBarrel) {
51  float radius1 = dynamic_cast<const BarrelDetLayer*>(theInnerLayer->layer())->specificSurface().radius();
52  float radius2 = dynamic_cast<const BarrelDetLayer*>(theOuterLayer->layer())->specificSurface().radius();
53  seedfromoverlaps = (abs(radius1 - radius2) < 0.1) ? true : false;
54  }
55 
56  vector<OrderedHitPair> allthepairs;
57 
58  for (auto ohh = theOuterLayer->recHits().begin(); ohh != theOuterLayer->recHits().end(); ohh++) {
59  for (auto ihh = theInnerLayer->recHits().begin(); ihh != theInnerLayer->recHits().end(); ihh++) {
60  auto oh = static_cast<BaseTrackerRecHit const* const>(*ohh);
61  auto ih = static_cast<BaseTrackerRecHit const* const>(*ihh);
62 
63  float z_diff = ih->globalPosition().z() - oh->globalPosition().z();
64  float inny = ih->globalPosition().y();
65  float outy = oh->globalPosition().y();
66  float innx = ih->globalPosition().x();
67  float outx = oh->globalPosition().x();
68  ;
69  float dxdy = abs((outx - innx) / (outy - inny));
70  float DeltaR = oh->globalPosition().perp() - ih->globalPosition().perp();
71  ;
72 
73  if (InTheBarrel &&
74  (abs(z_diff) < 30) // && (outy > 0.) && (inny > 0.)
75  //&&((abs(inny-outy))<30)
76  && (dxdy < 2) && (inny * outy > 0) && (abs(DeltaR) > 0)) {
77  // cout << " ******** sono dentro inthebarrel *********** " << endl;
78  if (seedfromoverlaps) {
79  //this part of code works for MTCC
80  // for the other geometries must be verified
81  //Overlaps in the difference in z is decreased and the difference in phi is
82  //less than 0.05
83  if ((DeltaR < 0) && (abs(z_diff) < 18) &&
84  (abs(ih->globalPosition().phi() - oh->globalPosition().phi()) < 0.05) && (dxdy < 2))
85  result.push_back(OrderedHitPair(ih, oh));
86  } else
87  result.push_back(OrderedHitPair(ih, oh));
88  }
89  if (InTheForward && (abs(z_diff) > 1.)) {
90  // cout << " ******** sono dentro intheforward *********** " << endl;
91  result.push_back(OrderedHitPair(ih, oh));
92  }
93  }
94  }
95 
96  /*
97  // uncomment if the sort operation below needs to be called
98  class CompareHitPairsY {
99  public:
100  CompareHitPairsY(const TrackerGeometry& t): tracker{&t} {}
101  bool operator()(const OrderedHitPair& h1, const OrderedHitPair& h2) {
102  const TrackingRecHit* trh1i = h1.inner()->hit();
103  const TrackingRecHit* trh2i = h2.inner()->hit();
104  const TrackingRecHit* trh1o = h1.outer()->hit();
105  const TrackingRecHit* trh2o = h2.outer()->hit();
106  GlobalPoint in1p = tracker->idToDet(trh1i->geographicalId())->surface().toGlobal(trh1i->localPosition());
107  GlobalPoint in2p = tracker->idToDet(trh2i->geographicalId())->surface().toGlobal(trh2i->localPosition());
108  GlobalPoint ou1p = tracker->idToDet(trh1o->geographicalId())->surface().toGlobal(trh1o->localPosition());
109  GlobalPoint ou2p = tracker->idToDet(trh2o->geographicalId())->surface().toGlobal(trh2o->localPosition());
110  if (ou1p.y() * ou2p.y() < 0)
111  return ou1p.y() > ou2p.y();
112  else {
113  float dist1 = 100 * std::abs(ou1p.z() - in1p.z()) - std::abs(ou1p.y()) - 0.1 * std::abs(in1p.y());
114  float dist2 = 100 * std::abs(ou2p.z() - in2p.z()) - std::abs(ou2p.y()) - 0.1 * std::abs(in2p.y());
115  return dist1 < dist2;
116  }
117  }
118 
119  private:
120  const TrackerGeometry* tracker;
121  };
122  stable_sort(allthepairs.begin(),allthepairs.end(),CompareHitPairsY(*trackerGeometry));
123  //Seed from overlaps are saved only if
124  //no others have been saved
125 
126  if (allthepairs.size()>0) {
127  if (seedfromoverlaps) {
128  if (result.size()==0) result.push_back(allthepairs[0]);
129  }
130  else result.push_back(allthepairs[0]);
131  }
132 */
133 }
const DetLayer * layer() const
Definition: LayerWithHits.h:35
Definition: deltaR.h:58
SeedingHitSet::ConstRecHitPointer InnerRecHit
Definition: OrderedHitPair.h:9
tuple result
Definition: mps_fire.py:311
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void hitPairs(const TrackingRegion &ar, OrderedHitPairs &ap)
CosmicHitPairGeneratorFromLayerPair(const LayerWithHits *inner, const LayerWithHits *outer, const TrackerGeometry &)
const std::vector< const TrackingRecHit * > & recHits() const
return the recHits of the Layer
Definition: LayerWithHits.h:32
SeedingHitSet::ConstRecHitPointer OuterRecHit
Definition: OrderedHitPair.h:8