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;
95  //double theta, atrack, btrack;
96  double dz, dr, a1, zdet, newzmin, newzmax;
97  std::vector<ForwardDetLayer*>::const_iterator flayer;
98  double mincoor=fabs(fts.parameters().position().z())-
100 
101 // double zdetlast=(fls.front())->surface().position().z();
102  double zdetlast=length;
103  outrad=(fls.back())->specificSurface().outerRadius();
104 
105  zseed=fts.parameters().position().z();
106  rseed=fts.parameters().position().perp();
107  dz = 3.*NumberOfSigm*fts.curvilinearError().matrix()(4,4); // ok
108  dr = NumberOfSigm*fts.curvilinearError().matrix()(4,4);
109 
110 
111  //theta=fts.parameters().momentum().theta();
112  //atrack=tan(theta);
113  //btrack=rseed-atrack*zseed;
114  //zvert=-btrack/atrack;
115 
116 
117 #ifdef DEBUG
118  std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers "<<rseed<<" dr "<<dr<<" outrad "<<outrad<<std::endl;
119 #endif
120 
121  if(rseed+dr<outrad){
122 #ifdef DEBUG
123  std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::add last forward layer "<<rseed<<" dr "<<dr<<" outrad "<<outrad<<std::endl;
124 #endif
125  seedlayers.push_back(fls.back());
126  zdetlast = fabs((fls.back())->surface().position().z());
127 
128  }else{
129  if(rseed>outrad) {
130 #ifdef DEBUG
131  std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::1 zseed "<<zseed<<" dz "<<dz<<std::endl;
132 #endif
133 
134  newzmin=abs(zseed)-3.*dz; // ok 8*dz now 3*dz
135 // newzmin = fabs(zseed)-30.; // ok 16.06.08
136  newzmax=fabs(zseed)+dz/(2.*NumberOfSigm); // ok dz
137  } else {
138  a1=(rseed+dr)/(fabs(zseed)-fabs(theHICConst->zvert));
139  if(zseed<0.) a1=-1.*a1;
140 
141 #ifdef DEBUG
142  std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::2 zseed "<<zseed<<" dz "<<dz<<" "<<(fls.back())->surface().position().z()<<std::endl;
143 #endif
144 
145  newzmin=abs(outrad/a1)-3.*dz; //ok 6*dz now 3*dz
146 // newzmin = fabs(zseed)-30.; // ok 16.06.08
147  newzmax=fabs((fls.back())->surface().position().z())+dz;
148  }
149 #ifdef DEBUG
150  std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::newzmin,newzmax "<<newzmin<<" "<<newzmax<<std::endl;
151 #endif
152 
153  for(flayer=fls.end()-1;flayer!=fls.begin()-1;flayer--){
154 
155  zdet=(**flayer).surface().position().z();
156 #ifdef DEBUG
157  std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::zdet "<<zdet<<" thickness "<<(**flayer).surface().bounds().thickness()<<std::endl;
158 #endif
159 
160 // if(abs(newzmin)<=abs(zdet+(**flayer).surface().bounds().thickness())
161 // && abs(zdet-(**flayer).surface().bounds().thickness())<=abs(newzmax)){
162 
163  if(fabs(zdet)<length) break;
164 
165  if(fabs(newzmin)<=fabs(zdet)+(**flayer).surface().bounds().thickness()
166  && fabs(zdet)-(**flayer).surface().bounds().thickness()<=fabs(newzmax)){
167 
168 #ifdef DEBUG
169  std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::add layer "<<zdet<<std::endl;
170 #endif
171 
172  seedlayers.push_back(&(**flayer));
173  zdetlast=zdet;
174 
175  } //zmin
176 
177  } //flayer
178  }
179 // if(mincoor<abs(zdetlast) ){
180 #ifdef DEBUG
181 
182  std::cout<<"HICTkOuterStartingLayerFinder::zdetlast,mincoor "<<zdetlast<<" "<<mincoor<<std::endl;
183 
184 #endif
185  if(fabs(mincoor)<fabs(zdetlast)||fabs(zdetlast)<140.){
186 #ifdef DEBUG
187  std::cout<<"HICTkOuterStartingLayerFinder::add barrel layers to forward "<<std::endl;
188 #endif
189  barrel=true;
190  }
191  return barrel;
192 }
194  std::vector<ForwardDetLayer*>& fls, LayerContainer& seedlayers)
195 {
196 #ifdef DEBUG
197  std::cout<<"HICTkOuterStartingLayerFinder::findBarrelLayers::start::zdetlast "<<length<<std::endl;
198 #endif
199  std::vector<BarrelDetLayer*>::const_iterator blayer;
200  //
201  // double zdetlast=(fls.front())->surface().position().z();
202 
203  double zdetlast = length+10.;
204  //double zseed=fts.parameters().position().z();
205  //double rseed=fts.parameters().position().perp();
206  //double dz = NumberOfSigm*fts.curvilinearError().matrix()(5,5);
207  //double atrack=tan(fts.parameters().momentum().theta());
208  //double btrack=rseed-atrack*zseed;
209 // double zvert=-btrack/atrack;
210  double r,rmin,rmax;
211 
212  BoundSurface* surc = (BoundSurface*)&((theBarrelLayers.back())->surface());
213  double zbarrel=surc->bounds().length()/2.;
214  BoundCylinder* bc = dynamic_cast<BoundCylinder*>(surc);
215  double barrelradius=bc->radius();
216 
217  double a1=barrelradius/(fabs(zdetlast)-fabs(theHICConst->zvert));
218 
219 
220  rmin=a1*zbarrel-(theBarrelLayers.back())->surface().bounds().thickness();
221  rmax=barrelradius+(theBarrelLayers.back())->surface().bounds().thickness();
222 
223 // if(fabs(zseed)-dz<zbarrel){
224 // rmax=barrelradius+(theBarrelLayers.back())->surface().bounds().thickness();
225 // } else{
226 // a2=barrelradius/(fabs(zseed-theHICConst->zvert)-dz);
227 // if(zseed<0.) a2=-1.*a2;
228 // rmax=a2*zbarrel+(theBarrelLayers.back())->surface().bounds().thickness();
229 // cout<<" Check a2,rmax "<<a2<<" "<<rmax<<endl;
230 // }
231 
232 #ifdef DEBUG
233  std::cout<<"HICTkOuterStartingLayerFinder::findBarrelLayers::rmin,rmax "<<rmin<<" "<<rmax<<std::endl;
234 #endif
235 
236  for(blayer=theBarrelLayers.end()-1;blayer!=theBarrelLayers.begin()-1;blayer--){
237 
238  BoundSurface* sc = (BoundSurface*)&((*blayer)->surface());
239  r=(dynamic_cast<BoundCylinder*>(sc))->radius();
240 
241 
242  if(r>rmin&&r<=rmax){
243  seedlayers.push_back(&(**blayer));
244 #ifdef DEBUG
245  std::cout<<"HICTkOuterStartingLayerFinder::findBarrelLayers::add "<<r<<std::endl;
246 #endif
247  }
248  }//blayer barrel
249  return seedlayers;
250 }
251 }
virtual float length() const =0
T perp() const
Definition: PV3DBase.h:71
const GlobalTrajectoryParameters & parameters() const
float zvert
Definition: HICConst.h:25
tuple magfield
Definition: HLT_ES_cff.py:2311
#define abs(x)
Definition: mlp_lapack.h:159
const CurvilinearTrajectoryError & curvilinearError() const
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:63
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:121
std::vector< ForwardDetLayer * > forwardPosLayers
LayerContainer findBarrelLayers(const FreeTrajectoryState &fts, std::vector< ForwardDetLayer * > &fls, LayerContainer &lc)
std::vector< ForwardDetLayer * > forwardNegLayers