CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HICTkOuterStartingLayerFinder.cc
Go to the documentation of this file.
2 
5 
12 
13 //#define PROPAGATOR_DB
14 using namespace std;
15 using namespace edm;
16 
17 //#define DEBUG
18 
19 namespace cms{
20 HICTkOuterStartingLayerFinder::HICTkOuterStartingLayerFinder(int& numberOfSigmas, const MagneticField * mf,
21  const GeometricSearchTracker* th, const HICConst* hh):
22  NumberOfSigm(numberOfSigmas),
23  magfield(mf),
24  theTracker(th),
25  theHICConst(hh)
26 {
27 
28 // Get tracking geometry
29 
33  //cout<<" HICTkOuterStartingLayerFinder::zvert "<<theHICConst->zvert<<endl;
34 }
35 
37 {
38  vector<DetLayer*> seedlayers;
39 
40 
41  BoundSurface* surc = (BoundSurface*)&((theBarrelLayers.back())->specificSurface());
42 
43  length=surc->bounds().length()/2.;
44 
45  double maxcoor=fabs(fts.parameters().position().z())+NumberOfSigm*fts.curvilinearError().matrix()(4,4);
46 
47  //
48  // barrel part (muon and tracker)
49  //
50 
51 #ifdef DEBUG
52  std::cout<<"HICTkOuterStartingLayerFinder::startingLayers::maxcoor "<<fabs(fts.parameters().position().z())<<" "<<
53  NumberOfSigm<<" "<<fts.curvilinearError().matrix()(4,4)<<" maxcoor "<<maxcoor<<" length "<<length<<std::endl;
54 #endif
55 
56  if(maxcoor<length) {
57  seedlayers.push_back( theBarrelLayers.back());
58  seedlayers.push_back( *(theBarrelLayers.end()-2));
59  return seedlayers;
60  }
61 
62  bool checkBarrel;
63 
64  if(fts.parameters().position().z() < 0.){
65  checkBarrel = findForwardLayers( fts, forwardNegLayers, seedlayers);
66  } else {
67  checkBarrel = findForwardLayers( fts, forwardPosLayers, seedlayers);
68  }
69 
70  if (!checkBarrel) return seedlayers;
71 //
72 // One should attach barrel layers
73 //
74  if(fts.parameters().position().z() < 0.){
75  return findBarrelLayers( fts, forwardNegLayers, seedlayers);
76  }else{
77  return findBarrelLayers( fts, forwardPosLayers, seedlayers);
78  }
79 
80  // return seedlayers;
81 
82 }
83 
85  std::vector<ForwardDetLayer*>& fls,
87 
88  bool barrel = false;
89 
90 #ifdef DEBUG
91  std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::start "<<NumberOfSigm<<std::endl;
92 #endif
93 
94  double outrad, zseed, rseed, theta, atrack, btrack;
95  double dz, dr, a1, zdet, newzmin, newzmax;
96  std::vector<ForwardDetLayer*>::const_iterator flayer;
97  double mincoor=fabs(fts.parameters().position().z())-
99 
100 // double zdetlast=(fls.front())->surface().position().z();
101  double zdetlast=length;
102  outrad=(fls.back())->specificSurface().outerRadius();
103 
104  zseed=fts.parameters().position().z();
105  rseed=fts.parameters().position().perp();
106  dz = 3.*NumberOfSigm*fts.curvilinearError().matrix()(4,4); // ok
107  dr = NumberOfSigm*fts.curvilinearError().matrix()(4,4);
108 
109  theta=fts.parameters().momentum().theta();
110  atrack=tan(theta);
111  btrack=rseed-atrack*zseed;
112 // zvert=-btrack/atrack;
113 
114 #ifdef DEBUG
115  std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers "<<rseed<<" dr "<<dr<<" outrad "<<outrad<<std::endl;
116 #endif
117 
118  if(rseed+dr<outrad){
119 #ifdef DEBUG
120  std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::add last forward layer "<<rseed<<" dr "<<dr<<" outrad "<<outrad<<std::endl;
121 #endif
122  seedlayers.push_back(fls.back());
123  zdetlast = fabs((fls.back())->surface().position().z());
124 
125  }else{
126  if(rseed>outrad) {
127 #ifdef DEBUG
128  std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::1 zseed "<<zseed<<" dz "<<dz<<std::endl;
129 #endif
130 
131  newzmin=abs(zseed)-3.*dz; // ok 8*dz now 3*dz
132 // newzmin = fabs(zseed)-30.; // ok 16.06.08
133  newzmax=fabs(zseed)+dz/(2.*NumberOfSigm); // ok dz
134  } else {
135  a1=(rseed+dr)/(fabs(zseed)-fabs(theHICConst->zvert));
136  if(zseed<0.) a1=-1.*a1;
137 
138 #ifdef DEBUG
139  std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::2 zseed "<<zseed<<" dz "<<dz<<" "<<(fls.back())->surface().position().z()<<std::endl;
140 #endif
141 
142  newzmin=abs(outrad/a1)-3.*dz; //ok 6*dz now 3*dz
143 // newzmin = fabs(zseed)-30.; // ok 16.06.08
144  newzmax=fabs((fls.back())->surface().position().z())+dz;
145  }
146 #ifdef DEBUG
147  std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::newzmin,newzmax "<<newzmin<<" "<<newzmax<<std::endl;
148 #endif
149 
150  for(flayer=fls.end()-1;flayer!=fls.begin()-1;flayer--){
151 
152  zdet=(**flayer).surface().position().z();
153 #ifdef DEBUG
154  std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::zdet "<<zdet<<" thickness "<<(**flayer).surface().bounds().thickness()<<std::endl;
155 #endif
156 
157 // if(abs(newzmin)<=abs(zdet+(**flayer).surface().bounds().thickness())
158 // && abs(zdet-(**flayer).surface().bounds().thickness())<=abs(newzmax)){
159 
160  if(fabs(zdet)<length) break;
161 
162  if(fabs(newzmin)<=fabs(zdet)+(**flayer).surface().bounds().thickness()
163  && fabs(zdet)-(**flayer).surface().bounds().thickness()<=fabs(newzmax)){
164 
165 #ifdef DEBUG
166  std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::add layer "<<zdet<<std::endl;
167 #endif
168 
169  seedlayers.push_back(&(**flayer));
170  zdetlast=zdet;
171 
172  } //zmin
173 
174  } //flayer
175  }
176 // if(mincoor<abs(zdetlast) ){
177 #ifdef DEBUG
178 
179  std::cout<<"HICTkOuterStartingLayerFinder::zdetlast,mincoor "<<zdetlast<<" "<<mincoor<<std::endl;
180 
181 #endif
182  if(fabs(mincoor)<fabs(zdetlast)||fabs(zdetlast)<140.){
183 #ifdef DEBUG
184  std::cout<<"HICTkOuterStartingLayerFinder::add barrel layers to forward "<<std::endl;
185 #endif
186  barrel=true;
187  }
188  return barrel;
189 }
191  std::vector<ForwardDetLayer*>& fls, LayerContainer& seedlayers)
192 {
193 #ifdef DEBUG
194  std::cout<<"HICTkOuterStartingLayerFinder::findBarrelLayers::start::zdetlast "<<length<<std::endl;
195 #endif
196  std::vector<BarrelDetLayer*>::const_iterator blayer;
197  //
198  // double zdetlast=(fls.front())->surface().position().z();
199 
200  double zdetlast = length+10.;
201  //double zseed=fts.parameters().position().z();
202  //double rseed=fts.parameters().position().perp();
203  //double dz = NumberOfSigm*fts.curvilinearError().matrix()(5,5);
204  //double atrack=tan(fts.parameters().momentum().theta());
205  //double btrack=rseed-atrack*zseed;
206 // double zvert=-btrack/atrack;
207  double r,rmin,rmax;
208 
209  BoundSurface* surc = (BoundSurface*)&((theBarrelLayers.back())->surface());
210  double zbarrel=surc->bounds().length()/2.;
211  BoundCylinder* bc = dynamic_cast<BoundCylinder*>(surc);
212  double barrelradius=bc->radius();
213 
214  double a1=barrelradius/(fabs(zdetlast)-fabs(theHICConst->zvert));
215 
216 
217  rmin=a1*zbarrel-(theBarrelLayers.back())->surface().bounds().thickness();
218  rmax=barrelradius+(theBarrelLayers.back())->surface().bounds().thickness();
219 
220 // if(fabs(zseed)-dz<zbarrel){
221 // rmax=barrelradius+(theBarrelLayers.back())->surface().bounds().thickness();
222 // } else{
223 // a2=barrelradius/(fabs(zseed-theHICConst->zvert)-dz);
224 // if(zseed<0.) a2=-1.*a2;
225 // rmax=a2*zbarrel+(theBarrelLayers.back())->surface().bounds().thickness();
226 // cout<<" Check a2,rmax "<<a2<<" "<<rmax<<endl;
227 // }
228 
229 #ifdef DEBUG
230  std::cout<<"HICTkOuterStartingLayerFinder::findBarrelLayers::rmin,rmax "<<rmin<<" "<<rmax<<std::endl;
231 #endif
232 
233  for(blayer=theBarrelLayers.end()-1;blayer!=theBarrelLayers.begin()-1;blayer--){
234 
235  BoundSurface* sc = (BoundSurface*)&((*blayer)->surface());
236  r=(dynamic_cast<BoundCylinder*>(sc))->radius();
237 
238 
239  if(r>rmin&&r<=rmax){
240  seedlayers.push_back(&(**blayer));
241 #ifdef DEBUG
242  std::cout<<"HICTkOuterStartingLayerFinder::findBarrelLayers::add "<<r<<std::endl;
243 #endif
244  }
245  }//blayer barrel
246  return seedlayers;
247 }
248 }
virtual float length() const =0
T perp() const
Definition: PV3DBase.h:66
const GlobalTrajectoryParameters & parameters() const
float zvert
Definition: HICConst.h:25
Geom::Theta< T > theta() const
#define abs(x)
Definition: mlp_lapack.h:159
const CurvilinearTrajectoryError & curvilinearError() const
Geom::Theta< T > theta() const
Definition: PV3DBase.h:69
std::vector< BarrelDetLayer * > const & barrelLayers() const
std::vector< BarrelDetLayer * > theBarrelLayers
Scalar radius() const
Radius of the cylinder.
Definition: Cylinder.h:55
LayerContainer startingLayers(FreeTrajectoryState &fts)
T z() const
Definition: PV3DBase.h:58
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
std::vector< ForwardDetLayer * > const & negForwardLayers() const
bool findForwardLayers(const FreeTrajectoryState &fts, std::vector< ForwardDetLayer * > &fls, LayerContainer &lc)
const Bounds & bounds() const
Definition: BoundSurface.h:89
std::vector< ForwardDetLayer * > const & posForwardLayers() const
const AlgebraicSymMatrix55 & matrix() const
tuple cout
Definition: gather_cfg.py:41
std::vector< ForwardDetLayer * > forwardPosLayers
LayerContainer findBarrelLayers(const FreeTrajectoryState &fts, std::vector< ForwardDetLayer * > &fls, LayerContainer &lc)
std::vector< ForwardDetLayer * > forwardNegLayers