Go to the documentation of this file.00001 #include "RecoHI/HiMuonAlgos/interface/HICTkOuterStartingLayerFinder.h"
00002
00003 #include "DataFormats/GeometrySurface/interface/BoundSurface.h"
00004 #include "DataFormats/GeometrySurface/interface/BoundCylinder.h"
00005
00006 #include "DataFormats/GeometrySurface/interface/Cylinder.h"
00007 #include "DataFormats/GeometrySurface/interface/Plane.h"
00008 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00009 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00010 #include "Geometry/TrackerGeometryBuilder/interface/TrackerLayerIdAccessor.h"
00011 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00012
00013
00014 using namespace std;
00015 using namespace edm;
00016
00017
00018
00019 namespace cms{
00020 HICTkOuterStartingLayerFinder::HICTkOuterStartingLayerFinder(int& numberOfSigmas, const MagneticField * mf,
00021 const GeometricSearchTracker* th, const HICConst* hh):
00022 NumberOfSigm(numberOfSigmas),
00023 magfield(mf),
00024 theTracker(th),
00025 theHICConst(hh)
00026 {
00027
00028
00029
00030 theBarrelLayers = theTracker->barrelLayers();
00031 forwardPosLayers = theTracker->posForwardLayers();
00032 forwardNegLayers = theTracker->negForwardLayers();
00033
00034 }
00035
00036 HICTkOuterStartingLayerFinder::LayerContainer HICTkOuterStartingLayerFinder::startingLayers(FreeTrajectoryState& fts)
00037 {
00038 vector<DetLayer*> seedlayers;
00039
00040
00041 BoundSurface* surc = (BoundSurface*)&((theBarrelLayers.back())->specificSurface());
00042
00043 length=surc->bounds().length()/2.;
00044
00045 double maxcoor=fabs(fts.parameters().position().z())+NumberOfSigm*fts.curvilinearError().matrix()(4,4);
00046
00047
00048
00049
00050
00051 #ifdef DEBUG
00052 std::cout<<"HICTkOuterStartingLayerFinder::startingLayers::maxcoor "<<fabs(fts.parameters().position().z())<<" "<<
00053 NumberOfSigm<<" "<<fts.curvilinearError().matrix()(4,4)<<" maxcoor "<<maxcoor<<" length "<<length<<std::endl;
00054 #endif
00055
00056 if(maxcoor<length) {
00057 seedlayers.push_back( theBarrelLayers.back());
00058 seedlayers.push_back( *(theBarrelLayers.end()-2));
00059 return seedlayers;
00060 }
00061
00062 bool checkBarrel;
00063
00064 if(fts.parameters().position().z() < 0.){
00065 checkBarrel = findForwardLayers( fts, forwardNegLayers, seedlayers);
00066 } else {
00067 checkBarrel = findForwardLayers( fts, forwardPosLayers, seedlayers);
00068 }
00069
00070 if (!checkBarrel) return seedlayers;
00071
00072
00073
00074 if(fts.parameters().position().z() < 0.){
00075 return findBarrelLayers( fts, forwardNegLayers, seedlayers);
00076 }else{
00077 return findBarrelLayers( fts, forwardPosLayers, seedlayers);
00078 }
00079
00080
00081
00082 }
00083
00084 bool HICTkOuterStartingLayerFinder::findForwardLayers( const FreeTrajectoryState& fts,
00085 std::vector<ForwardDetLayer*>& fls,
00086 HICTkOuterStartingLayerFinder::LayerContainer& seedlayers){
00087
00088 bool barrel = false;
00089
00090 #ifdef DEBUG
00091 std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::start "<<NumberOfSigm<<std::endl;
00092 #endif
00093
00094 double outrad, zseed, rseed;
00095
00096 double dz, dr, a1, zdet, newzmin, newzmax;
00097 std::vector<ForwardDetLayer*>::const_iterator flayer;
00098 double mincoor=fabs(fts.parameters().position().z())-
00099 NumberOfSigm*fts.curvilinearError().matrix()(4,4);
00100
00101
00102 double zdetlast=length;
00103 outrad=(fls.back())->specificSurface().outerRadius();
00104
00105 zseed=fts.parameters().position().z();
00106 rseed=fts.parameters().position().perp();
00107 dz = 3.*NumberOfSigm*fts.curvilinearError().matrix()(4,4);
00108 dr = NumberOfSigm*fts.curvilinearError().matrix()(4,4);
00109
00110
00111
00112
00113
00114
00115
00116
00117 #ifdef DEBUG
00118 std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers "<<rseed<<" dr "<<dr<<" outrad "<<outrad<<std::endl;
00119 #endif
00120
00121 if(rseed+dr<outrad){
00122 #ifdef DEBUG
00123 std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::add last forward layer "<<rseed<<" dr "<<dr<<" outrad "<<outrad<<std::endl;
00124 #endif
00125 seedlayers.push_back(fls.back());
00126 zdetlast = fabs((fls.back())->surface().position().z());
00127
00128 }else{
00129 if(rseed>outrad) {
00130 #ifdef DEBUG
00131 std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::1 zseed "<<zseed<<" dz "<<dz<<std::endl;
00132 #endif
00133
00134 newzmin=abs(zseed)-3.*dz;
00135
00136 newzmax=fabs(zseed)+dz/(2.*NumberOfSigm);
00137 } else {
00138 a1=(rseed+dr)/(fabs(zseed)-fabs(theHICConst->zvert));
00139 if(zseed<0.) a1=-1.*a1;
00140
00141 #ifdef DEBUG
00142 std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::2 zseed "<<zseed<<" dz "<<dz<<" "<<(fls.back())->surface().position().z()<<std::endl;
00143 #endif
00144
00145 newzmin=abs(outrad/a1)-3.*dz;
00146
00147 newzmax=fabs((fls.back())->surface().position().z())+dz;
00148 }
00149 #ifdef DEBUG
00150 std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::newzmin,newzmax "<<newzmin<<" "<<newzmax<<std::endl;
00151 #endif
00152
00153 for(flayer=fls.end()-1;flayer!=fls.begin()-1;flayer--){
00154
00155 zdet=(**flayer).surface().position().z();
00156 #ifdef DEBUG
00157 std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::zdet "<<zdet<<" thickness "<<(**flayer).surface().bounds().thickness()<<std::endl;
00158 #endif
00159
00160
00161
00162
00163 if(fabs(zdet)<length) break;
00164
00165 if(fabs(newzmin)<=fabs(zdet)+(**flayer).surface().bounds().thickness()
00166 && fabs(zdet)-(**flayer).surface().bounds().thickness()<=fabs(newzmax)){
00167
00168 #ifdef DEBUG
00169 std::cout<<"HICTkOuterStartingLayerFinder::findForwardLayers::add layer "<<zdet<<std::endl;
00170 #endif
00171
00172 seedlayers.push_back(&(**flayer));
00173 zdetlast=zdet;
00174
00175 }
00176
00177 }
00178 }
00179
00180 #ifdef DEBUG
00181
00182 std::cout<<"HICTkOuterStartingLayerFinder::zdetlast,mincoor "<<zdetlast<<" "<<mincoor<<std::endl;
00183
00184 #endif
00185 if(fabs(mincoor)<fabs(zdetlast)||fabs(zdetlast)<140.){
00186 #ifdef DEBUG
00187 std::cout<<"HICTkOuterStartingLayerFinder::add barrel layers to forward "<<std::endl;
00188 #endif
00189 barrel=true;
00190 }
00191 return barrel;
00192 }
00193 HICTkOuterStartingLayerFinder::LayerContainer HICTkOuterStartingLayerFinder::findBarrelLayers( const FreeTrajectoryState& fts,
00194 std::vector<ForwardDetLayer*>& fls, LayerContainer& seedlayers)
00195 {
00196 #ifdef DEBUG
00197 std::cout<<"HICTkOuterStartingLayerFinder::findBarrelLayers::start::zdetlast "<<length<<std::endl;
00198 #endif
00199 std::vector<BarrelDetLayer*>::const_iterator blayer;
00200
00201
00202
00203 double zdetlast = length+10.;
00204
00205
00206
00207
00208
00209
00210 double r,rmin,rmax;
00211
00212 BoundSurface* surc = (BoundSurface*)&((theBarrelLayers.back())->surface());
00213 double zbarrel=surc->bounds().length()/2.;
00214 BoundCylinder* bc = dynamic_cast<BoundCylinder*>(surc);
00215 double barrelradius=bc->radius();
00216
00217 double a1=barrelradius/(fabs(zdetlast)-fabs(theHICConst->zvert));
00218
00219
00220 rmin=a1*zbarrel-(theBarrelLayers.back())->surface().bounds().thickness();
00221 rmax=barrelradius+(theBarrelLayers.back())->surface().bounds().thickness();
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232 #ifdef DEBUG
00233 std::cout<<"HICTkOuterStartingLayerFinder::findBarrelLayers::rmin,rmax "<<rmin<<" "<<rmax<<std::endl;
00234 #endif
00235
00236 for(blayer=theBarrelLayers.end()-1;blayer!=theBarrelLayers.begin()-1;blayer--){
00237
00238 BoundSurface* sc = (BoundSurface*)&((*blayer)->surface());
00239 r=(dynamic_cast<BoundCylinder*>(sc))->radius();
00240
00241
00242 if(r>rmin&&r<=rmax){
00243 seedlayers.push_back(&(**blayer));
00244 #ifdef DEBUG
00245 std::cout<<"HICTkOuterStartingLayerFinder::findBarrelLayers::add "<<r<<std::endl;
00246 #endif
00247 }
00248 }
00249 return seedlayers;
00250 }
00251 }