CMS 3D CMS Logo

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  // LayerCacheType* layerCache,
18  const edm::EventSetup& iSetup)
19  : TTRHbuilder(nullptr),trackerGeometry(nullptr),
20  //theLayerCache(*layerCache),
21  theOuterLayer(outer), theInnerLayer(inner)
22 {
23 
25  iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
26  trackerGeometry = tracker.product();
27 }
30  const TrackingRegion & region, OrderedHitPairs & result,
31  const edm::EventSetup& iSetup)
32 {
33 // static int NSee = 0; static int Ntry = 0; static int Nacc = 0;
34 
35 
36  typedef OrderedHitPair::InnerRecHit InnerHit;
37  typedef OrderedHitPair::OuterRecHit OuterHit;
38 
39 
40  if (theInnerLayer->recHits().empty()) return;
41 
42  if (theOuterLayer->recHits().empty()) return;
43  // const DetLayer* innerlay=theOuterLayer->layer();
44  // const BarrelDetLayer *pippo=dynamic_cast<const BarrelDetLayer*>(theOuterLayer->layer());
45 
46 
47  // ************ Daniele
48 
49  const DetLayer* blay1;
50  const DetLayer* blay2;
51  blay1 = dynamic_cast<const BarrelDetLayer*>(theInnerLayer->layer());
52  blay2 = dynamic_cast<const BarrelDetLayer*>(theOuterLayer->layer());
53 
54 
55  bool seedfromoverlaps= false;
56  bool InTheBarrel = false;
57  bool InTheForward = false;
58  if (blay1 && blay2) {
59  InTheBarrel = true;
60  }
61  else InTheForward = true;
62 
63  if (InTheBarrel){
64  float radius1 =dynamic_cast<const BarrelDetLayer*>(theInnerLayer->layer())->specificSurface().radius();
65  float radius2 =dynamic_cast<const BarrelDetLayer*>(theOuterLayer->layer())->specificSurface().radius();
66  seedfromoverlaps=(abs(radius1-radius2)<0.1) ? true : false;
67  }
68 
69 
70  vector<OrderedHitPair> allthepairs;
71  std::string builderName = "WithTrackAngle";
73  iSetup.get<TransientRecHitRecord>().get(builderName, builder);
74 
75 
76 
77  for( auto ohh=theOuterLayer->recHits().begin();ohh!=theOuterLayer->recHits().end();ohh++){
78  for(auto ihh=theInnerLayer->recHits().begin();ihh!=theInnerLayer->recHits().end();ihh++){
79  auto oh = static_cast<BaseTrackerRecHit const * const>(*ohh);
80  auto ih = static_cast<BaseTrackerRecHit const * const>(*ihh);
81 
82  float z_diff =ih->globalPosition().z()-oh->globalPosition().z();
83  float inny=ih->globalPosition().y();
84  float outy=oh->globalPosition().y();
85  float innx=ih->globalPosition().x();
86  float outx=oh->globalPosition().x();;
87  float dxdy=abs((outx-innx)/(outy-inny));
88  float DeltaR=oh->globalPosition().perp()-ih->globalPosition().perp();;
89 
90  if( InTheBarrel && (abs(z_diff)<30) // && (outy > 0.) && (inny > 0.)
91  //&&((abs(inny-outy))<30)
92  &&(dxdy<2)
93  &&(inny*outy>0)
94  && (abs(DeltaR)>0)) {
95 
96  // cout << " ******** sono dentro inthebarrel *********** " << endl;
97  if (seedfromoverlaps){
98  //this part of code works for MTCC
99  // for the other geometries must be verified
100  //Overlaps in the difference in z is decreased and the difference in phi is
101  //less than 0.05
102  if ((DeltaR<0)&&(abs(z_diff)<18)&&(abs(ih->globalPosition().phi()-oh->globalPosition().phi())<0.05)&&(dxdy<2)) result.push_back( OrderedHitPair(ih, oh));
103  }
104  else result.push_back( OrderedHitPair( ih, oh));
105 
106 
107 
108 
109  }
110  if( InTheForward && (abs(z_diff) > 1.)) {
111  // cout << " ******** sono dentro intheforward *********** " << endl;
112  result.push_back( OrderedHitPair(ih,oh));
113  }
114  }
115  }
116 
117 // stable_sort(allthepairs.begin(),allthepairs.end(),CompareHitPairsY(iSetup));
118 // //Seed from overlaps are saved only if
119 // //no others have been saved
120 
121 // if (allthepairs.size()>0) {
122 // if (seedfromoverlaps) {
123 // if (result.size()==0) result.push_back(allthepairs[0]);
124 // }
125 // else result.push_back(allthepairs[0]);
126 // }
127 
128 
129 }
130 
Definition: DeltaR.py:1
const DetLayer * layer() const
Definition: LayerWithHits.h:40
SeedingHitSet::ConstRecHitPointer InnerRecHit
#define nullptr
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void hitPairs(const TrackingRegion &ar, OrderedHitPairs &ap, const edm::EventSetup &iSetup)
T get() const
Definition: EventSetup.h:63
GlobalPoint globalPosition() const final
T const * product() const
Definition: ESHandle.h:86
const std::vector< const TrackingRecHit * > & recHits() const
return the recHits of the Layer
Definition: LayerWithHits.h:37
CosmicHitPairGeneratorFromLayerPair(const LayerWithHits *inner, const LayerWithHits *outer, const edm::EventSetup &iSetup)
SeedingHitSet::ConstRecHitPointer OuterRecHit