CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CosmicHitPairGeneratorFromLayerPair.cc
Go to the documentation of this file.
12 
13 using namespace std;
15 
17  const LayerWithHits* outer,
18  // LayerCacheType* layerCache,
19  const edm::EventSetup& iSetup)
20  : TTRHbuilder(0),trackerGeometry(0),
21  //theLayerCache(*layerCache),
22  theOuterLayer(outer), theInnerLayer(inner)
23 {
24 
26  iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
27  trackerGeometry = tracker.product();
28 }
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  std::vector<const TrackingRecHit*>::const_iterator ohh;
77  for(ohh=theOuterLayer->recHits().begin();ohh!=theOuterLayer->recHits().end();ohh++){
78  TkHitPairsCachedHit oh= builder->build(*ohh);
79  std::vector<const TrackingRecHit*>::const_iterator ihh;
80  for(ihh=theInnerLayer->recHits().begin();ihh!=theInnerLayer->recHits().end();ihh++){
81  TkHitPairsCachedHit ih= builder->build(*ihh);
82 
83  float z_diff =ih->globalPosition().z()-oh->globalPosition().z();
84  float inny=ih->globalPosition().y();
85  float outy=oh->globalPosition().y();
86  float innx=ih->globalPosition().x();
87  float outx=oh->globalPosition().x();;
88  float dxdy=abs((outx-innx)/(outy-inny));
89  float DeltaR=oh->globalPosition().perp()-ih->globalPosition().perp();;
90 
91  if( InTheBarrel && (abs(z_diff)<30) // && (outy > 0.) && (inny > 0.)
92  //&&((abs(inny-outy))<30)
93  &&(dxdy<2)
94  &&(inny*outy>0)
95  && (abs(DeltaR)>0)) {
96 
97  // cout << " ******** sono dentro inthebarrel *********** " << endl;
98  if (seedfromoverlaps){
99  //this part of code works for MTCC
100  // for the other geometries must be verified
101  //Overlaps in the difference in z is decreased and the difference in phi is
102  //less than 0.05
103  if ((DeltaR<0)&&(abs(z_diff)<18)&&(abs(ih->globalPosition().phi()-oh->globalPosition().phi())<0.05)&&(dxdy<2)) result.push_back( OrderedHitPair(ih, oh));
104  }
105  else result.push_back( OrderedHitPair( ih, oh));
106 
107 
108 
109 
110  }
111  if( InTheForward && (abs(z_diff) > 1.)) {
112  // cout << " ******** sono dentro intheforward *********** " << endl;
113  result.push_back( OrderedHitPair(ih,oh));
114  }
115  }
116  }
117 
118 // stable_sort(allthepairs.begin(),allthepairs.end(),CompareHitPairsY(iSetup));
119 // //Seed from overlaps are saved only if
120 // //no others have been saved
121 
122 // if (allthepairs.size()>0) {
123 // if (seedfromoverlaps) {
124 // if (result.size()==0) result.push_back(allthepairs[0]);
125 // }
126 // else result.push_back(allthepairs[0]);
127 // }
128 
129 
130 }
131 
const DetLayer * layer() const
Definition: LayerWithHits.h:38
Definition: deltaR.h:79
TransientTrackingRecHit::ConstRecHitPointer TkHitPairsCachedHit
tuple result
Definition: query.py:137
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
virtual void hitPairs(const TrackingRegion &ar, OrderedHitPairs &ap, const edm::EventSetup &iSetup)
const std::vector< const TrackingRecHit * > & recHits() const
return the recHits of the Layer
Definition: LayerWithHits.h:35
CosmicHitPairGeneratorFromLayerPair(const LayerWithHits *inner, const LayerWithHits *outer, const edm::EventSetup &iSetup)