CMS 3D CMS Logo

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:
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) override;
46  //void linkForwardLayers( SymmetricLayerFinder& symFinder);
48  void establishInverseRelations( SymmetricLayerFinder& symFinder );
49  void buildAdditionalBarrelLinks();
50  void buildAdditionalForwardLinks(SymmetricLayerFinder& symFinder);
51 };
52 
53 
55 
58 #include "SimpleNavigableLayer.h"
59 #include "DiskLessInnerRadius.h"
60 #include "SymmetricLayerFinder.h"
61 
66 
67 #include <functional>
68 #include <algorithm>
69 #include <map>
70 #include <cmath>
71 
72 using namespace std;
73 
75  noPXB=conf.getParameter<bool>("noPXB");
76  noPXF=conf.getParameter<bool>("noPXF");
77  noTIB=conf.getParameter<bool>("noTIB");
78  noTID=conf.getParameter<bool>("noTID");
79  noTOB=conf.getParameter<bool>("noTOB");
80  noTEC=conf.getParameter<bool>("noTEC");
81  self = conf.getParameter<bool>("selfSearch");
82  allSelf = conf.getParameter<bool>("allSelf");
83 }
84 
86  const MagneticField* field)
87 {
88  build(theInputTracker, field, CosmicNavigationSchoolConfiguration());
89 }
90 
92  const MagneticField* field,
94 {
95  LogTrace("CosmicNavigationSchool") << "*********Running CosmicNavigationSchool***********" ;
96  theBarrelLength = 0;theField = field; theTracker = theInputTracker;
97 
98  theAllDetLayersInSystem=&theInputTracker->allLayers();
99  theAllNavigableLayer.resize(theInputTracker->allLayers().size(),nullptr);
100 
101 
102 
103 
104  // Get barrel layers
105  vector<BarrelDetLayer const*> const& blc = theTracker->barrelLayers();
106  for ( auto i = blc.begin(); i != blc.end(); i++) {
107  if (conf.noPXB && GeomDetEnumerators::isTrackerPixel((*i)->subDetector())) continue;
108  if (conf.noTOB && (*i)->subDetector() == GeomDetEnumerators::TOB) continue;
109  if (conf.noTIB && (*i)->subDetector() == GeomDetEnumerators::TIB) continue;
110  theBarrelLayers.push_back( (*i) );
111  }
112 
113  // get forward layers
114  vector<ForwardDetLayer const*> const& flc = theTracker->forwardLayers();
115  for ( auto i = flc.begin(); i != flc.end(); i++) {
116  if (conf.noPXF && GeomDetEnumerators::isTrackerPixel((*i)->subDetector())) continue;
117  if (conf.noTEC && (*i)->subDetector() == GeomDetEnumerators::TEC) continue;
118  if (conf.noTID && (*i)->subDetector() == GeomDetEnumerators::TID) continue;
119  theForwardLayers.push_back( (*i) );
120  }
121 
122  FDLI middle = find_if( theForwardLayers.begin(), theForwardLayers.end(),
123  not1(DetBelowZ(0)));
124  theLeftLayers = FDLC( theForwardLayers.begin(), middle);
125  theRightLayers = FDLC( middle, theForwardLayers.end());
126 
127  SymmetricLayerFinder symFinder( theForwardLayers);
128 
129  // only work on positive Z side; negative by mirror symmetry later
130  linkBarrelLayers( symFinder);
131  linkForwardLayers( symFinder);
132  establishInverseRelations( symFinder );
133 
134  if (conf.self){
135 
136  // set the self search by hand
137  // NavigationSetter setter(*this);
138 
139  //add TOB1->TOB1 inward link
140  const std::vector< const BarrelDetLayer * > & tobL = theInputTracker->tobLayers();
141  if (!tobL.empty()){
142  if (conf.allSelf){
143  LogDebug("CosmicNavigationSchool")<<" adding all TOB self search.";
144  for (auto lIt = tobL.begin(); lIt!=tobL.end(); ++lIt)
145  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
146  }else{
147  SimpleNavigableLayer* navigableLayer =
148  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[tobL.front()->seqNum()]);
149  LogDebug("CosmicNavigationSchool")<<" adding TOB1 to TOB1.";
150  navigableLayer->theSelfSearch = true;
151  }
152  }
153  const std::vector< const BarrelDetLayer * > & tibL = theInputTracker->tibLayers();
154  if (!tibL.empty()){
155  if (conf.allSelf){
156  LogDebug("CosmicNavigationSchool")<<" adding all TIB self search.";
157  for (auto lIt = tibL.begin(); lIt!=tibL.end(); ++lIt)
158  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
159  }else{
160  SimpleNavigableLayer* navigableLayer =
161  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[tibL.front()->seqNum()]);
162  LogDebug("CosmicNavigationSchool")<<" adding tib1 to tib1.";
163  navigableLayer->theSelfSearch = true;
164  }
165  }
166  const std::vector< const BarrelDetLayer * > & pxbL = theInputTracker->pixelBarrelLayers();
167  if (!pxbL.empty()){
168  if (conf.allSelf){
169  LogDebug("CosmicNavigationSchool")<<" adding all PXB self search.";
170  for (auto lIt = pxbL.begin(); lIt!=pxbL.end(); ++lIt)
171  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
172  }else{
173  SimpleNavigableLayer* navigableLayer =
174  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[pxbL.front()->seqNum()]);
175  LogDebug("CosmicNavigationSchool")<<" adding pxb1 to pxb1.";
176  navigableLayer->theSelfSearch = true;
177  }
178  }
179  }
180 }
181 
184 {
185  //identical to the SimpleNavigationSchool one, but it allows crossing over the tracker
186  //is some non-standard link is needed, it should probably be added here
187 
188  // Link barrel layers outwards
189  for ( BDLI i = theBarrelLayers.begin(); i != theBarrelLayers.end(); i++) {
190  BDLC reachableBL;
191  FDLC leftFL;
192  FDLC rightFL;
193 
194  // always add next barrel layer first
195  if ( i+1 != theBarrelLayers.end()) reachableBL.push_back(*(i+1));
196 
197  // Add closest reachable forward layer (except for last BarrelLayer)
198  if (i != theBarrelLayers.end() - 1) {
199  linkNextForwardLayer( *i, rightFL);
200  }
201 
202  // Add next BarrelLayer with length larger than the current BL
203  if ( i+2 < theBarrelLayers.end()) {
204  linkNextLargerLayer( i, theBarrelLayers.end(), reachableBL);
205  }
206 
207  theBarrelNLC.push_back( new
208  SimpleBarrelNavigableLayer( *i, reachableBL,
209  symFinder.mirror(rightFL),
210  rightFL,theField, 5.,false));
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
282  dynamic_cast<SimpleForwardNavigableLayer*>(theAllNavigableLayer[(i)->seqNum()]);
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 
323  ~SkippingLayerCosmicNavigationSchool() override{cleanMemory();};
324 };
325 
326 
328  const MagneticField* field,
330 {
331  build(theInputTracker, field, conf);
332 }
333 
334 
335 
336 
338 
339 #include <memory>
340 
341 // user include files
344 
346 
347 #include "NavigationSchoolFactory.h"
349 
350 //
351 // class decleration
352 //
354  public:
356  theNavigationPSet = iConfig;
357  theNavigationSchoolName = theNavigationPSet.getParameter<std::string>("ComponentName");
358  //the following line is needed to tell the framework what
359  // data is being produced
360  setWhatProduced(this, theNavigationSchoolName);
361  }
362 
364 
365  using ReturnType = std::unique_ptr<NavigationSchool>;
366 
367  ReturnType produce(const NavigationSchoolRecord&);
368 
369  // ----------member data ---------------------------
372 };
373 
376 
377  std::unique_ptr<NavigationSchool> theNavigationSchool ;
378 
379  // get the field
381  iRecord.getRecord<IdealMagneticFieldRecord>().get(field);
382 
383  //get the geometricsearch tracker geometry
384  edm::ESHandle<GeometricSearchTracker> geometricSearchTracker;
385  iRecord.getRecord<TrackerRecoGeometryRecord>().get(geometricSearchTracker);
386 
388  theNavigationSchool.reset(new SkippingLayerCosmicNavigationSchool(geometricSearchTracker.product(), field.product(), layerConfig) );
389 
390  return theNavigationSchool;
391 }
392 
395 
397 
398 
#define LogDebug(id)
T getParameter(std::string const &) const
#define dso_hidden
void linkBarrelLayers(SymmetricLayerFinder &symFinder) override
std::unique_ptr< NavigationSchool > ReturnType
std::vector< DetLayer const * > const & allLayers() const
std::vector< const BarrelDetLayer * > BDLC
SkippingLayerCosmicNavigationSchool(const GeometricSearchTracker *theTracker, const MagneticField *field, const CosmicNavigationSchoolConfiguration conf)
std::vector< BarrelDetLayer const * > const & tobLayers() const
const ForwardDetLayer * mirror(const ForwardDetLayer *layer)
int seqNum() const
Definition: DetLayer.h:36
SkippingLayerCosmicNavigationSchoolESProducer(const edm::ParameterSet &iConfig)
std::vector< BarrelDetLayer const * > const & pixelBarrelLayers() const
#define LogTrace(id)
virtual void establishInverseRelations()
std::vector< const ForwardDetLayer * > FDLC
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
void setCheckCrossingSide(bool docheck)
virtual DetLayer const * detLayer() const =0
static int position[264][3]
Definition: ReadPGInfo.cc:509
#define DEFINE_EDM_PLUGIN(factory, type, name)
ReturnType produce(const NavigationSchoolRecord &)
void setAdditionalLink(const DetLayer *, NavigationDirection direction=insideOut) override
T const * product() const
Definition: ESHandle.h:86
void buildAdditionalForwardLinks(SymmetricLayerFinder &symFinder)
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)