CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CosmicNavigationSchool.cc
Go to the documentation of this file.
2 
4 
6 
7 #include <vector>
8 
9 //class FakeDetLayer;
10 
11 
16 public:
18  const MagneticField* field);
20 
22  public:
23  CosmicNavigationSchoolConfiguration() : noPXB(false), noPXF(false), noTOB(false), noTIB(false), noTEC(false), noTID(false) , self(false), allSelf(false) {}
25  bool noPXB;
26  bool noPXF;
27  bool noTOB;
28  bool noTIB;
29  bool noTEC;
30  bool noTID;
31 
32  bool self;
33  bool allSelf;
34  };
35 
36  void build(const GeometricSearchTracker* theTracker,
37  const MagneticField* field,
39 
40 protected:
42 private:
43 
44  //FakeDetLayer* theFakeDetLayer;
45  void linkBarrelLayers( SymmetricLayerFinder& symFinder);
46  //void linkForwardLayers( SymmetricLayerFinder& symFinder);
48  void buildAdditionalBarrelLinks();
49  void buildAdditionalForwardLinks(SymmetricLayerFinder& symFinder);
50 };
51 
52 
54 
57 #include "SimpleNavigableLayer.h"
58 #include "DiskLessInnerRadius.h"
59 #include "SymmetricLayerFinder.h"
60 
65 
66 #include <functional>
67 #include <algorithm>
68 #include <map>
69 #include <cmath>
70 
71 using namespace std;
72 
74  noPXB=conf.getParameter<bool>("noPXB");
75  noPXF=conf.getParameter<bool>("noPXF");
76  noTIB=conf.getParameter<bool>("noTIB");
77  noTID=conf.getParameter<bool>("noTID");
78  noTOB=conf.getParameter<bool>("noTOB");
79  noTEC=conf.getParameter<bool>("noTEC");
80  self = conf.getParameter<bool>("selfSearch");
81  allSelf = conf.getParameter<bool>("allSelf");
82 }
83 
85  const MagneticField* field)
86 {
87  build(theInputTracker, field, CosmicNavigationSchoolConfiguration());
88 }
89 
91  const MagneticField* field,
93 {
94  LogTrace("CosmicNavigationSchool") << "*********Running CosmicNavigationSchool***********" ;
95  theBarrelLength = 0;theField = field; theTracker = theInputTracker;
96 
97  theAllDetLayersInSystem=&theInputTracker->allLayers();
98  theAllNavigableLayer.resize(theInputTracker->allLayers().size(),nullptr);
99 
100 
101 
102 
103  // Get barrel layers
104  vector<BarrelDetLayer const*> const& blc = theTracker->barrelLayers();
105  for ( auto i = blc.begin(); i != blc.end(); i++) {
106  if (conf.noPXB && (*i)->subDetector() == GeomDetEnumerators::PixelBarrel) continue;
107  if (conf.noTOB && (*i)->subDetector() == GeomDetEnumerators::TOB) continue;
108  if (conf.noTIB && (*i)->subDetector() == GeomDetEnumerators::TIB) continue;
109  theBarrelLayers.push_back( (*i) );
110  }
111 
112  // get forward layers
113  vector<ForwardDetLayer const*> const& flc = theTracker->forwardLayers();
114  for ( auto i = flc.begin(); i != flc.end(); i++) {
115  if (conf.noPXF && (*i)->subDetector() == GeomDetEnumerators::PixelEndcap) continue;
116  if (conf.noTEC && (*i)->subDetector() == GeomDetEnumerators::TEC) continue;
117  if (conf.noTID && (*i)->subDetector() == GeomDetEnumerators::TID) continue;
118  theForwardLayers.push_back( (*i) );
119  }
120 
121  FDLI middle = find_if( theForwardLayers.begin(), theForwardLayers.end(),
122  not1(DetBelowZ(0)));
123  theLeftLayers = FDLC( theForwardLayers.begin(), middle);
124  theRightLayers = FDLC( middle, theForwardLayers.end());
125 
126  SymmetricLayerFinder symFinder( theForwardLayers);
127 
128  // only work on positive Z side; negative by mirror symmetry later
129  linkBarrelLayers( symFinder);
130  linkForwardLayers( symFinder);
131  establishInverseRelations( symFinder );
132 
133  if (conf.self){
134 
135  // set the self search by hand
136  // NavigationSetter setter(*this);
137 
138  //add TOB1->TOB1 inward link
139  const std::vector< const BarrelDetLayer * > & tobL = theInputTracker->tobLayers();
140  if (tobL.size()>=1){
141  if (conf.allSelf){
142  LogDebug("CosmicNavigationSchool")<<" adding all TOB self search.";
143  for (auto lIt = tobL.begin(); lIt!=tobL.end(); ++lIt)
144  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
145  }else{
146  SimpleNavigableLayer* navigableLayer =
147  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[tobL.front()->seqNum()]);
148  LogDebug("CosmicNavigationSchool")<<" adding TOB1 to TOB1.";
149  navigableLayer->theSelfSearch = true;
150  }
151  }
152  const std::vector< const BarrelDetLayer * > & tibL = theInputTracker->tibLayers();
153  if (tibL.size()>=1){
154  if (conf.allSelf){
155  LogDebug("CosmicNavigationSchool")<<" adding all TIB self search.";
156  for (auto lIt = tibL.begin(); lIt!=tibL.end(); ++lIt)
157  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
158  }else{
159  SimpleNavigableLayer* navigableLayer =
160  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[tibL.front()->seqNum()]);
161  LogDebug("CosmicNavigationSchool")<<" adding tib1 to tib1.";
162  navigableLayer->theSelfSearch = true;
163  }
164  }
165  const std::vector< const BarrelDetLayer * > & pxbL = theInputTracker->pixelBarrelLayers();
166  if (pxbL.size()>=1){
167  if (conf.allSelf){
168  LogDebug("CosmicNavigationSchool")<<" adding all PXB self search.";
169  for (auto lIt = pxbL.begin(); lIt!=pxbL.end(); ++lIt)
170  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
171  }else{
172  SimpleNavigableLayer* navigableLayer =
173  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[pxbL.front()->seqNum()]);
174  LogDebug("CosmicNavigationSchool")<<" adding pxb1 to pxb1.";
175  navigableLayer->theSelfSearch = true;
176  }
177  }
178  }
179 }
180 
183 {
184  //identical to the SimpleNavigationSchool one, but it allows crossing over the tracker
185  //is some non-standard link is needed, it should probably be added here
186 
187  // Link barrel layers outwards
188  for ( BDLI i = theBarrelLayers.begin(); i != theBarrelLayers.end(); i++) {
189  BDLC reachableBL;
190  FDLC leftFL;
191  FDLC rightFL;
192 
193  // always add next barrel layer first
194  if ( i+1 != theBarrelLayers.end()) reachableBL.push_back(*(i+1));
195 
196  // Add closest reachable forward layer (except for last BarrelLayer)
197  if (i != theBarrelLayers.end() - 1) {
198  linkNextForwardLayer( *i, rightFL);
199  }
200 
201  // Add next BarrelLayer with length larger than the current BL
202  if ( i+2 < theBarrelLayers.end()) {
203  linkNextLargerLayer( i, theBarrelLayers.end(), reachableBL);
204  }
205 
206  theBarrelNLC.push_back( new
207  SimpleBarrelNavigableLayer( *i, reachableBL,
208  symFinder.mirror(rightFL),
209  rightFL,theField, 5.,false));
210  }
211 }
212 
213 
214 // identical to SimpleNavigationSchool but for the last additional stuff
216 
217  //again: standard part is identical to SimpleNavigationSchool one.
218  //After the standard link, special outsideIn links are added
219 
220  // NavigationSetter setter(*this);
221 
222  setState(navigableLayers());
223 
224 
225  // find for each layer which are the barrel and forward
226  // layers that point to it
227  typedef map<const DetLayer*, vector<const BarrelDetLayer*>, less<const DetLayer*> > BarrelMapType;
228  typedef map<const DetLayer*, vector<const ForwardDetLayer*>, less<const DetLayer*> > ForwardMapType;
229 
230 
231  BarrelMapType reachedBarrelLayersMap;
232  ForwardMapType reachedForwardLayersMap;
233 
234  for ( auto bli : theBarrelLayers) {
235  auto reachedLC = nextLayers(*bli, insideOut);
236  for ( auto i : reachedLC) {
237  reachedBarrelLayersMap[i].push_back(bli);
238  }
239  }
240 
241  for ( auto fli : theForwardLayers) {
242  auto reachedLC = nextLayers(*fli, insideOut);
243  for ( auto i : reachedLC) {
244  reachedForwardLayersMap[i].push_back(fli);
245  }
246  }
247 
248  for(auto nl : theAllNavigableLayer) {
249  if (!nl) continue;
250  auto navigableLayer = static_cast<SimpleNavigableLayer*>(nl);
251  auto dl = nl->detLayer();
252  navigableLayer->setInwardLinks( reachedBarrelLayersMap[dl],reachedForwardLayersMap[dl] );
253  }
254 
255  //buildAdditionalBarrelLinks();
256  buildAdditionalForwardLinks(symFinder);
257 
258 }
259 
260 
262  for (auto i = theBarrelLayers.begin(); i != theBarrelLayers.end(); i++) {
263  SimpleNavigableLayer* navigableLayer =
264  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*i)->seqNum()]);
265  if (i+1 != theBarrelLayers.end() )navigableLayer->setAdditionalLink(*(i+1), outsideIn);
266  }
267 }
268 
269 
271  //the first layer of FPIX should not check the crossing side (since there are no inner layers to be tryed first)
272  SimpleNavigableLayer* firstR =
273  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[theRightLayers.front()->seqNum()]);
274  SimpleNavigableLayer* firstL =
275  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[theLeftLayers.front()->seqNum()]);
276  firstR->setCheckCrossingSide(false);
277  firstL->setCheckCrossingSide(false);
278 
279  for (auto i : theRightLayers){
280  //look for first bigger barrel layer and link to it outsideIn
281  SimpleForwardNavigableLayer* nfl =
282  dynamic_cast<SimpleForwardNavigableLayer*>(theAllNavigableLayer[(i)->seqNum()]);
283  SimpleForwardNavigableLayer* mnfl =
284  dynamic_cast<SimpleForwardNavigableLayer*>(theAllNavigableLayer[symFinder.mirror(i)->seqNum()]);
285  for (auto j : theBarrelLayers) {
286  if ((i)->specificSurface().outerRadius() < (j)->specificSurface().radius() &&
287  fabs((i)->specificSurface().position().z()) < (j)->surface().bounds().length()/2.){
288  nfl ->setAdditionalLink(j, outsideIn);
289  mnfl->setAdditionalLink(j, outsideIn);
290  break;
291  }
292  }
293  }
294 }
295 
298 
299 
300 #include "NavigationSchoolFactory.h"
303 
304 
305 
306 
308 
309 #include <vector>
310 
311 //class FakeDetLayer;
312 
313 
318 public:
320  const MagneticField* field,
322 
324 };
325 
326 
328  const MagneticField* field,
330 {
331  build(theInputTracker, field, conf);
332 }
333 
334 
335 
336 
338 
339 #include <memory>
340 #include "boost/shared_ptr.hpp"
341 
342 // user include files
345 
347 
348 #include "NavigationSchoolFactory.h"
350 
351 //
352 // class decleration
353 //
355  public:
357  theNavigationPSet = iConfig;
358  theNavigationSchoolName = theNavigationPSet.getParameter<std::string>("ComponentName");
359  //the following line is needed to tell the framework what
360  // data is being produced
361  setWhatProduced(this, theNavigationSchoolName);
362 
363 }
364 
365 
367 
368  typedef boost::shared_ptr<NavigationSchool> ReturnType;
369 
370 
371  ReturnType produce(const NavigationSchoolRecord&);
372 
373  // ----------member data ---------------------------
376  boost::shared_ptr<NavigationSchool> theNavigationSchool ;
377 
378 
379 };
380 
381 
383  using namespace edm::es;
384 
385  // get the field
387  iRecord.getRecord<IdealMagneticFieldRecord>().get(field);
388 
389  //get the geometricsearch tracker geometry
390  edm::ESHandle<GeometricSearchTracker> geometricSearchTracker;
391  iRecord.getRecord<TrackerRecoGeometryRecord>().get(geometricSearchTracker);
392 
394  theNavigationSchool.reset(new SkippingLayerCosmicNavigationSchool(geometricSearchTracker.product(), field.product(), layerConfig) );
395 
396  return theNavigationSchool;
397 }
398 
401 
403 
404 
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
void linkBarrelLayers(SymmetricLayerFinder &symFinder)
std::vector< DetLayer const * > const & allLayers() const
std::vector< const BarrelDetLayer * > BDLC
virtual DetLayer const * detLayer() const =0
SkippingLayerCosmicNavigationSchool(const GeometricSearchTracker *theTracker, const MagneticField *field, const CosmicNavigationSchoolConfiguration conf)
std::vector< BarrelDetLayer const * > const & tobLayers() const
float float float z
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
const ForwardDetLayer * mirror(const ForwardDetLayer *layer)
boost::shared_ptr< NavigationSchool > ReturnType
int seqNum() const
Definition: DetLayer.h:36
SkippingLayerCosmicNavigationSchoolESProducer(const edm::ParameterSet &iConfig)
int j
Definition: DBlmapReader.cc:9
std::vector< BarrelDetLayer const * > const & pixelBarrelLayers() const
#define LogTrace(id)
virtual void establishInverseRelations()
tuple conf
Definition: dbtoconf.py:185
std::vector< const ForwardDetLayer * > FDLC
#define dso_hidden
Definition: Visibility.h:12
virtual void linkBarrelLayers(SymmetricLayerFinder &symFinder)
std::vector< BarrelDetLayer const * > const & tibLayers() const
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
void build(const GeometricSearchTracker *theTracker, const MagneticField *field, const CosmicNavigationSchoolConfiguration conf)
virtual void setAdditionalLink(const DetLayer *, NavigationDirection direction=insideOut)=0
boost::shared_ptr< NavigationSchool > theNavigationSchool
void setCheckCrossingSide(bool docheck)
#define DEFINE_EDM_PLUGIN(factory, type, name)
ReturnType produce(const NavigationSchoolRecord &)
volatile std::atomic< bool > shutdown_flag false
void buildAdditionalForwardLinks(SymmetricLayerFinder &symFinder)