Go to the documentation of this file.00001 #include "RecoTracker/TkNavigation/interface/BeamHaloNavigationSchool.h"
00002
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004
00005 #include "TrackingTools/DetLayers/src/DetBelowZ.h"
00006 #include "TrackingTools/DetLayers/src/DetLessZ.h"
00007 #include "TrackingTools/DetLayers/interface/BarrelDetLayer.h"
00008 #include "TrackingTools/DetLayers/interface/ForwardDetLayer.h"
00009
00010 #include "RecoTracker/TkNavigation/interface/SymmetricLayerFinder.h"
00011 #include "RecoTracker/TkNavigation/interface/SimpleBarrelNavigableLayer.h"
00012 #include "RecoTracker/TkNavigation/interface/SimpleForwardNavigableLayer.h"
00013 #include "RecoTracker/TkNavigation/interface/SimpleNavigableLayer.h"
00014
00015 #include "TrackingTools/DetLayers/interface/NavigationSetter.h"
00016
00017 using namespace std;
00018
00019 BeamHaloNavigationSchool::BeamHaloNavigationSchool(const GeometricSearchTracker* theInputTracker,
00020 const MagneticField* field)
00021 {
00022 edm::LogInfo("BeamHaloNavigationSchool")<<"*********Running BeamHaloNavigationSchool *********";
00023 theBarrelLength = 0;theField = field; theTracker = theInputTracker;
00024 theAllDetLayersInSystem=&theInputTracker->allLayers();
00025
00026
00027
00028
00029
00030
00031
00032
00033 vector<ForwardDetLayer*> flc = theTracker->forwardLayers();
00034 for ( vector<ForwardDetLayer*>::iterator i = flc.begin(); i != flc.end(); i++) {
00035 theForwardLayers.push_back( (*i) );
00036 }
00037
00038 FDLI middle = find_if( theForwardLayers.begin(), theForwardLayers.end(),
00039 not1(DetBelowZ(0)));
00040 theLeftLayers = FDLC( theForwardLayers.begin(), middle);
00041 theRightLayers = FDLC( middle, theForwardLayers.end());
00042
00043 SymmetricLayerFinder symFinder( theForwardLayers);
00044
00045
00046
00047
00048
00049 linkForwardLayers( symFinder);
00050 LogDebug("BeamHaloNavigationSchool")<<"inverse relation";
00051 establishInverseRelations();
00052
00053
00054
00055 LogDebug("BeamHaloNavigationSchool")<<"linkOtherEndLayer";
00056 linkOtherEndLayers( symFinder);
00057
00058
00059 SimpleNavigationSchool::StateType allLayers=navigableLayers();
00060 SimpleNavigationSchool::StateType::iterator layerIt=allLayers.begin();
00061 SimpleNavigationSchool::StateType::iterator layerIt_end=allLayers.end();
00062 for (;layerIt!=layerIt_end;++layerIt)
00063 {
00064
00065 SimpleNavigableLayer* snl=dynamic_cast<SimpleNavigableLayer*>(*layerIt);
00066 if (!snl){
00067 edm::LogError("BeamHaloNavigationSchool")<<"navigable layer not casting to simplenavigablelayer.";
00068 continue;}
00069 snl->setCheckCrossingSide(false);
00070 }
00071
00072 }
00073
00074 void BeamHaloNavigationSchool::establishInverseRelations() {
00075 NavigationSetter setter(*this);
00076
00077
00078
00079 typedef map<const DetLayer*, vector<BarrelDetLayer*>, less<const DetLayer*> > BarrelMapType;
00080 typedef map<const DetLayer*, vector<ForwardDetLayer*>, less<const DetLayer*> > ForwardMapType;
00081
00082
00083 BarrelMapType reachedBarrelLayersMap;
00084 ForwardMapType reachedForwardLayersMap;
00085
00086 for ( BDLI bli = theBarrelLayers.begin();
00087 bli!=theBarrelLayers.end(); bli++) {
00088 DLC reachedLC = (**bli).nextLayers( insideOut);
00089 for ( DLI i = reachedLC.begin(); i != reachedLC.end(); i++) {
00090 reachedBarrelLayersMap[*i].push_back( *bli);
00091 }
00092 }
00093
00094 for ( FDLI fli = theForwardLayers.begin();
00095 fli!=theForwardLayers.end(); fli++) {
00096 DLC reachedLC = (**fli).nextLayers( insideOut);
00097 for ( DLI i = reachedLC.begin(); i != reachedLC.end(); i++) {
00098 reachedForwardLayersMap[*i].push_back( *fli);
00099 }
00100 }
00101
00102
00103 vector<DetLayer*> lc = theTracker->allLayers();
00104 for ( vector<DetLayer*>::iterator i = lc.begin(); i != lc.end(); i++) {
00105 SimpleNavigableLayer* navigableLayer =
00106 dynamic_cast<SimpleNavigableLayer*>((**i).navigableLayer());
00107 if (!navigableLayer) {edm::LogInfo("BeamHaloNavigationSchool")<<"a detlayer does not have a navigable layer, which is normal in beam halo navigation.";}
00108 if (navigableLayer){navigableLayer->setInwardLinks( reachedBarrelLayersMap[*i],reachedForwardLayersMap[*i], TkLayerLess(outsideIn, (*i)) );}
00109 }
00110
00111 }
00112
00113
00114 void BeamHaloNavigationSchool::
00115 linkOtherEndLayers( SymmetricLayerFinder& symFinder){
00116 NavigationSetter setter(*this);
00117
00118 LogDebug("BeamHaloNavigationSchool")<<"reachable from horizontal";
00119
00120 FDLC reachableFL= reachableFromHorizontal();
00121
00122
00123
00124 for (FDLI fl=reachableFL.begin();fl!=reachableFL.end();fl++)
00125 {
00126 LogDebug("BeamHaloNavigationSchool")<<"adding inward from right";
00127
00128 addInward((DetLayer*)*fl,symFinder.mirror(*fl));
00129
00130 LogDebug("BeamHaloNavigationSchool")<<"adding inward from mirror of right (left?)";
00131 addInward((DetLayer*)symFinder.mirror(*fl),*fl);
00132 }
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243 }
00244
00245 void BeamHaloNavigationSchool::
00246 addInward(DetLayer * det, ForwardDetLayer * newF){
00247
00248 SimpleNavigableLayer* navigableLayer =
00249 dynamic_cast<SimpleNavigableLayer*>((*det).navigableLayer());
00250
00251 LogDebug("BeamHaloNavigationSchool")<<"retreive the nextlayer outsidein";
00252
00253 DLC inwardsLayers(navigableLayer->nextLayers(outsideIn));
00254
00255 LogDebug("BeamHaloNavigationSchool")<<"split them barrel/forward";
00256
00257 BDLC inwardsBarrel;
00258 FDLC inwardsForward;
00259 for ( DLC::iterator dli=inwardsLayers.begin();dli!=inwardsLayers.end();dli++)
00260 {
00261 if ((**dli).location()==GeomDetEnumerators::barrel)
00262 inwardsBarrel.push_back((BarrelDetLayer*)*dli);
00263 else
00264 inwardsForward.push_back((ForwardDetLayer*)*dli);
00265 }
00266 LogDebug("BeamHaloNavigationSchool")<<"add the new ones";
00267
00268 inwardsForward.push_back(newF);
00269
00270 LogDebug("BeamHaloNavigationSchool")<<"no duplicate please";
00271 sort(inwardsForward.begin(),inwardsForward.end());
00272
00273
00274
00275
00276
00277 FDLI new_end =unique(inwardsForward.begin(),inwardsForward.end());
00278
00279 inwardsForward.erase(new_end,inwardsForward.end());
00280
00281 LogDebug("BeamHaloNavigationSchool")<<"set back the inward links (no duplicate)";
00282
00283 navigableLayer->setInwardLinks( inwardsBarrel, inwardsForward, TkLayerLess(outsideIn, det));
00284 }
00285
00286 void BeamHaloNavigationSchool::
00287 addInward(DetLayer * det, FDLC news){
00288
00289 SimpleNavigableLayer* navigableLayer =
00290 dynamic_cast<SimpleNavigableLayer*>((*det).navigableLayer());
00291
00292 LogDebug("BeamHaloNavigationSchool")<<"retreive the nextlayer outsidein";
00293
00294 DLC inwardsLayers(navigableLayer->nextLayers(outsideIn));
00295
00296 LogDebug("BeamHaloNavigationSchool")<<"split them barrel/forward";
00297
00298 BDLC inwardsBarrel;
00299 FDLC inwardsForward;
00300 for ( DLC::iterator dli=inwardsLayers.begin();dli!=inwardsLayers.end();dli++)
00301 {
00302 if ((**dli).location()==GeomDetEnumerators::barrel)
00303 inwardsBarrel.push_back((BarrelDetLayer*)*dli);
00304 else
00305 inwardsForward.push_back((ForwardDetLayer*)*dli);
00306 }
00307
00308 LogDebug("BeamHaloNavigationSchool")<<"add the new ones";
00309
00310 inwardsForward.insert( inwardsForward.end(), news.begin(), news.end());
00311
00312 LogDebug("BeamHaloNavigationSchool")<<"no duplicate please";
00313 FDLI new_end =unique(inwardsForward.begin(),inwardsForward.end());
00314 inwardsForward.erase(new_end,inwardsForward.end());
00315
00316 LogDebug("BeamHaloNavigationSchool")<<"set back the inward links (no duplicate)";
00317
00318 navigableLayer->setInwardLinks( inwardsBarrel, inwardsForward, TkLayerLess(outsideIn, det));
00319 }
00320
00321 BeamHaloNavigationSchool::FDLC
00322 BeamHaloNavigationSchool::reachableFromHorizontal()
00323 {
00324
00325
00326
00327 FDLC myRightLayers( theRightLayers);
00328 FDLI begin = myRightLayers.begin();
00329 FDLI end = myRightLayers.end();
00330
00331
00332 sort(begin, end, DetLessZ());
00333
00334 FDLC reachableFL;
00335
00336 begin = myRightLayers.begin();
00337 end = myRightLayers.end();
00338
00339
00340 reachableFL.push_back(*begin);
00341 FDLI current = begin;
00342 for (FDLI i = begin+1; i!= end; i++)
00343 {
00344
00345
00346 if ((**i).specificSurface().innerRadius() < (**current).specificSurface().innerRadius() ||
00347 (**i).specificSurface().outerRadius() > (**current).specificSurface().outerRadius())
00348 {
00349 reachableFL.push_back(*i);
00350 current=i;
00351 }
00352 }
00353 return reachableFL;
00354 }