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 "SymmetricLayerFinder.h"
60 
64 
65 #include <functional>
66 #include <algorithm>
67 #include <map>
68 #include <cmath>
69 
70 using namespace std;
71 
73  noPXB=conf.getParameter<bool>("noPXB");
74  noPXF=conf.getParameter<bool>("noPXF");
75  noTIB=conf.getParameter<bool>("noTIB");
76  noTID=conf.getParameter<bool>("noTID");
77  noTOB=conf.getParameter<bool>("noTOB");
78  noTEC=conf.getParameter<bool>("noTEC");
79  self = conf.getParameter<bool>("selfSearch");
80  allSelf = conf.getParameter<bool>("allSelf");
81 }
82 
84  const MagneticField* field)
85 {
86  build(theInputTracker, field, CosmicNavigationSchoolConfiguration());
87 }
88 
90  const MagneticField* field,
92 {
93  LogTrace("CosmicNavigationSchool") << "*********Running CosmicNavigationSchool***********" ;
94  theBarrelLength = 0;theField = field; theTracker = theInputTracker;
95 
96  theAllDetLayersInSystem=&theInputTracker->allLayers();
97  theAllNavigableLayer.resize(theInputTracker->allLayers().size(),nullptr);
98 
99 
100 
101 
102  // Get barrel layers
103  vector<BarrelDetLayer const*> const& blc = theTracker->barrelLayers();
104  for ( auto i = blc.begin(); i != blc.end(); i++) {
105  if (conf.noPXB && GeomDetEnumerators::isTrackerPixel((*i)->subDetector())) continue;
106  if (conf.noTOB && (*i)->subDetector() == GeomDetEnumerators::TOB) continue;
107  if (conf.noTIB && (*i)->subDetector() == GeomDetEnumerators::TIB) continue;
108  theBarrelLayers.push_back( (*i) );
109  }
110 
111  // get forward layers
112  vector<ForwardDetLayer const*> const& flc = theTracker->forwardLayers();
113  for ( auto i = flc.begin(); i != flc.end(); i++) {
114  if (conf.noPXF && GeomDetEnumerators::isTrackerPixel((*i)->subDetector())) continue;
115  if (conf.noTEC && (*i)->subDetector() == GeomDetEnumerators::TEC) continue;
116  if (conf.noTID && (*i)->subDetector() == GeomDetEnumerators::TID) continue;
117  theForwardLayers.push_back( (*i) );
118  }
119 
120  FDLI middle = find_if( theForwardLayers.begin(), theForwardLayers.end(),
121  [](auto const* a){ return a->position().z() >= 0.0; });
122  theLeftLayers = FDLC( theForwardLayers.begin(), middle);
123  theRightLayers = FDLC( middle, theForwardLayers.end());
124 
125  SymmetricLayerFinder symFinder( theForwardLayers);
126 
127  // only work on positive Z side; negative by mirror symmetry later
128  linkBarrelLayers( symFinder);
129  linkForwardLayers( symFinder);
130  establishInverseRelations( symFinder );
131 
132  if (conf.self){
133 
134  // set the self search by hand
135  // NavigationSetter setter(*this);
136 
137  //add TOB1->TOB1 inward link
138  const std::vector< const BarrelDetLayer * > & tobL = theInputTracker->tobLayers();
139  if (!tobL.empty()){
140  if (conf.allSelf){
141  LogDebug("CosmicNavigationSchool")<<" adding all TOB self search.";
142  for (auto lIt = tobL.begin(); lIt!=tobL.end(); ++lIt)
143  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
144  }else{
145  SimpleNavigableLayer* navigableLayer =
146  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[tobL.front()->seqNum()]);
147  LogDebug("CosmicNavigationSchool")<<" adding TOB1 to TOB1.";
148  navigableLayer->theSelfSearch = true;
149  }
150  }
151  const std::vector< const BarrelDetLayer * > & tibL = theInputTracker->tibLayers();
152  if (!tibL.empty()){
153  if (conf.allSelf){
154  LogDebug("CosmicNavigationSchool")<<" adding all TIB self search.";
155  for (auto lIt = tibL.begin(); lIt!=tibL.end(); ++lIt)
156  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
157  }else{
158  SimpleNavigableLayer* navigableLayer =
159  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[tibL.front()->seqNum()]);
160  LogDebug("CosmicNavigationSchool")<<" adding tib1 to tib1.";
161  navigableLayer->theSelfSearch = true;
162  }
163  }
164  const std::vector< const BarrelDetLayer * > & pxbL = theInputTracker->pixelBarrelLayers();
165  if (!pxbL.empty()){
166  if (conf.allSelf){
167  LogDebug("CosmicNavigationSchool")<<" adding all PXB self search.";
168  for (auto lIt = pxbL.begin(); lIt!=pxbL.end(); ++lIt)
169  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
170  }else{
171  SimpleNavigableLayer* navigableLayer =
172  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[pxbL.front()->seqNum()]);
173  LogDebug("CosmicNavigationSchool")<<" adding pxb1 to pxb1.";
174  navigableLayer->theSelfSearch = true;
175  }
176  }
177  }
178 }
179 
182 {
183  //identical to the SimpleNavigationSchool one, but it allows crossing over the tracker
184  //is some non-standard link is needed, it should probably be added here
185 
186  // Link barrel layers outwards
187  for ( BDLI i = theBarrelLayers.begin(); i != theBarrelLayers.end(); i++) {
188  BDLC reachableBL;
189  FDLC leftFL;
190  FDLC rightFL;
191 
192  // always add next barrel layer first
193  if ( i+1 != theBarrelLayers.end()) reachableBL.push_back(*(i+1));
194 
195  // Add closest reachable forward layer (except for last BarrelLayer)
196  if (i != theBarrelLayers.end() - 1) {
197  linkNextForwardLayer( *i, rightFL);
198  }
199 
200  // Add next BarrelLayer with length larger than the current BL
201  if ( i+2 < theBarrelLayers.end()) {
202  linkNextLargerLayer( i, theBarrelLayers.end(), reachableBL);
203  }
204 
205  theBarrelNLC.push_back( new
206  SimpleBarrelNavigableLayer( *i, reachableBL,
207  symFinder.mirror(rightFL),
208  rightFL,theField, 5.,false));
209  }
210 }
211 
212 // identical to SimpleNavigationSchool but for the last additional stuff
214 
215  //again: standard part is identical to SimpleNavigationSchool one.
216  //After the standard link, special outsideIn links are added
217 
218  // NavigationSetter setter(*this);
219 
220  setState(navigableLayers());
221 
222 
223  // find for each layer which are the barrel and forward
224  // layers that point to it
225  typedef map<const DetLayer*, vector<const BarrelDetLayer*>, less<const DetLayer*> > BarrelMapType;
226  typedef map<const DetLayer*, vector<const ForwardDetLayer*>, less<const DetLayer*> > ForwardMapType;
227 
228 
229  BarrelMapType reachedBarrelLayersMap;
230  ForwardMapType reachedForwardLayersMap;
231 
232  for ( auto bli : theBarrelLayers) {
233  auto reachedLC = nextLayers(*bli, insideOut);
234  for ( auto i : reachedLC) {
235  reachedBarrelLayersMap[i].push_back(bli);
236  }
237  }
238 
239  for ( auto fli : theForwardLayers) {
240  auto reachedLC = nextLayers(*fli, insideOut);
241  for ( auto i : reachedLC) {
242  reachedForwardLayersMap[i].push_back(fli);
243  }
244  }
245 
246  for(auto nl : theAllNavigableLayer) {
247  if (!nl) continue;
248  auto navigableLayer = static_cast<SimpleNavigableLayer*>(nl);
249  auto dl = nl->detLayer();
250  navigableLayer->setInwardLinks( reachedBarrelLayersMap[dl],reachedForwardLayersMap[dl] );
251  }
252 
253  //buildAdditionalBarrelLinks();
254  buildAdditionalForwardLinks(symFinder);
255 
256 }
257 
258 
260  for (auto i = theBarrelLayers.begin(); i != theBarrelLayers.end(); i++) {
261  SimpleNavigableLayer* navigableLayer =
262  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*i)->seqNum()]);
263  if (i+1 != theBarrelLayers.end() )navigableLayer->setAdditionalLink(*(i+1), outsideIn);
264  }
265 }
266 
267 
269  //the first layer of FPIX should not check the crossing side (since there are no inner layers to be tryed first)
270  SimpleNavigableLayer* firstR =
271  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[theRightLayers.front()->seqNum()]);
272  SimpleNavigableLayer* firstL =
273  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[theLeftLayers.front()->seqNum()]);
274  firstR->setCheckCrossingSide(false);
275  firstL->setCheckCrossingSide(false);
276 
277  for (auto i : theRightLayers){
278  //look for first bigger barrel layer and link to it outsideIn
280  dynamic_cast<SimpleForwardNavigableLayer*>(theAllNavigableLayer[(i)->seqNum()]);
282  dynamic_cast<SimpleForwardNavigableLayer*>(theAllNavigableLayer[symFinder.mirror(i)->seqNum()]);
283  for (auto j : theBarrelLayers) {
284  if ((i)->specificSurface().outerRadius() < (j)->specificSurface().radius() &&
285  fabs((i)->specificSurface().position().z()) < (j)->surface().bounds().length()/2.){
286  nfl ->setAdditionalLink(j, outsideIn);
287  mnfl->setAdditionalLink(j, outsideIn);
288  break;
289  }
290  }
291  }
292 }
293 
296 
297 
298 #include "NavigationSchoolFactory.h"
301 
302 
303 
304 
306 
307 #include <vector>
308 
309 //class FakeDetLayer;
310 
311 
316 public:
318  const MagneticField* field,
320 
321  ~SkippingLayerCosmicNavigationSchool() override{cleanMemory();};
322 };
323 
324 
326  const MagneticField* field,
328 {
329  build(theInputTracker, field, conf);
330 }
331 
332 
333 
334 
336 
337 #include <memory>
338 
339 // user include files
342 
344 
345 #include "NavigationSchoolFactory.h"
347 
348 //
349 // class decleration
350 //
352  public:
354  theNavigationPSet = iConfig;
355  theNavigationSchoolName = theNavigationPSet.getParameter<std::string>("ComponentName");
356  //the following line is needed to tell the framework what
357  // data is being produced
358  setWhatProduced(this, theNavigationSchoolName);
359  }
360 
362 
363  using ReturnType = std::unique_ptr<NavigationSchool>;
364 
365  ReturnType produce(const NavigationSchoolRecord&);
366 
367  // ----------member data ---------------------------
370 };
371 
374 
375  std::unique_ptr<NavigationSchool> theNavigationSchool ;
376 
377  // get the field
379  iRecord.getRecord<IdealMagneticFieldRecord>().get(field);
380 
381  //get the geometricsearch tracker geometry
382  edm::ESHandle<GeometricSearchTracker> geometricSearchTracker;
383  iRecord.getRecord<TrackerRecoGeometryRecord>().get(geometricSearchTracker);
384 
386  theNavigationSchool.reset(new SkippingLayerCosmicNavigationSchool(geometricSearchTracker.product(), field.product(), layerConfig) );
387 
388  return theNavigationSchool;
389 }
390 
393 
395 
396 
#define LogDebug(id)
T getParameter(std::string const &) const
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
#define dso_hidden
Definition: Visibility.h:12
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
std::vector< BarrelDetLayer const * > const & tibLayers() const
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
double a
Definition: hdecay.h:121
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)