CMS 3D CMS Logo

CosmicNavigationSchool.cc
Go to the documentation of this file.
2 
4 
7 
8 #include <vector>
9 
10 //class FakeDetLayer;
11 
16 public:
17  CosmicNavigationSchool(const GeometricSearchTracker* theTracker, const MagneticField* field);
19 
21  public:
23  : noPXB(false),
24  noPXF(false),
25  noTOB(false),
26  noTIB(false),
27  noTEC(false),
28  noTID(false),
29  self(false),
30  allSelf(false) {}
32  bool noPXB;
33  bool noPXF;
34  bool noTOB;
35  bool noTIB;
36  bool noTEC;
37  bool noTID;
38 
39  bool self;
40  bool allSelf;
41  };
42 
43  void build(const GeometricSearchTracker* theTracker,
44  const MagneticField* field,
46 
47 protected:
49 
50 private:
51  //FakeDetLayer* theFakeDetLayer;
52  void linkBarrelLayers(SymmetricLayerFinder& symFinder) override;
53  //void linkForwardLayers( SymmetricLayerFinder& symFinder);
56  void buildAdditionalBarrelLinks();
57  void buildAdditionalForwardLinks(SymmetricLayerFinder& symFinder);
58 };
59 
61 
64 #include "SimpleNavigableLayer.h"
65 #include "SymmetricLayerFinder.h"
66 
70 
71 #include <functional>
72 #include <algorithm>
73 #include <map>
74 #include <cmath>
75 
76 using namespace std;
77 
79  const edm::ParameterSet& conf) {
80  noPXB = conf.getParameter<bool>("noPXB");
81  noPXF = conf.getParameter<bool>("noPXF");
82  noTIB = conf.getParameter<bool>("noTIB");
83  noTID = conf.getParameter<bool>("noTID");
84  noTOB = conf.getParameter<bool>("noTOB");
85  noTEC = conf.getParameter<bool>("noTEC");
86  self = conf.getParameter<bool>("selfSearch");
87  allSelf = conf.getParameter<bool>("allSelf");
88 }
89 
91  const MagneticField* field) {
92  build(theInputTracker, field, CosmicNavigationSchoolConfiguration());
93 }
94 
96  const MagneticField* field,
98  LogTrace("CosmicNavigationSchool") << "*********Running CosmicNavigationSchool***********";
99  theBarrelLength = 0;
100  theField = field;
101  theTracker = theInputTracker;
102 
103  theAllDetLayersInSystem = &theInputTracker->allLayers();
104  theAllNavigableLayer.resize(theInputTracker->allLayers().size(), nullptr);
105 
106  // Get barrel layers
107  vector<BarrelDetLayer const*> const& blc = theTracker->barrelLayers();
108  for (auto i = blc.begin(); i != blc.end(); i++) {
109  if (conf.noPXB && GeomDetEnumerators::isTrackerPixel((*i)->subDetector()))
110  continue;
111  if (conf.noTOB && (*i)->subDetector() == GeomDetEnumerators::TOB)
112  continue;
113  if (conf.noTIB && (*i)->subDetector() == GeomDetEnumerators::TIB)
114  continue;
115  theBarrelLayers.push_back((*i));
116  }
117 
118  // get forward layers
119  vector<ForwardDetLayer const*> const& flc = theTracker->forwardLayers();
120  for (auto i = flc.begin(); i != flc.end(); i++) {
121  if (conf.noPXF && GeomDetEnumerators::isTrackerPixel((*i)->subDetector()))
122  continue;
123  if (conf.noTEC && (*i)->subDetector() == GeomDetEnumerators::TEC)
124  continue;
125  if (conf.noTID && (*i)->subDetector() == GeomDetEnumerators::TID)
126  continue;
127  theForwardLayers.push_back((*i));
128  }
129 
130  FDLI middle =
131  find_if(theForwardLayers.begin(), theForwardLayers.end(), [](auto const* a) { return a->position().z() >= 0.0; });
132  theLeftLayers = FDLC(theForwardLayers.begin(), middle);
133  theRightLayers = FDLC(middle, theForwardLayers.end());
134 
135  SymmetricLayerFinder symFinder(theForwardLayers);
136 
137  // only work on positive Z side; negative by mirror symmetry later
138  linkBarrelLayers(symFinder);
139  linkForwardLayers(symFinder);
140  establishInverseRelations(symFinder);
141 
142  if (conf.self) {
143  // set the self search by hand
144  // NavigationSetter setter(*this);
145 
146  //add TOB1->TOB1 inward link
147  const std::vector<const BarrelDetLayer*>& tobL = theInputTracker->tobLayers();
148  if (!tobL.empty()) {
149  if (conf.allSelf) {
150  LogDebug("CosmicNavigationSchool") << " adding all TOB self search.";
151  for (auto lIt = tobL.begin(); lIt != tobL.end(); ++lIt)
152  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
153  } else {
154  SimpleNavigableLayer* navigableLayer =
155  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[tobL.front()->seqNum()]);
156  LogDebug("CosmicNavigationSchool") << " adding TOB1 to TOB1.";
157  navigableLayer->theSelfSearch = true;
158  }
159  }
160  const std::vector<const BarrelDetLayer*>& tibL = theInputTracker->tibLayers();
161  if (!tibL.empty()) {
162  if (conf.allSelf) {
163  LogDebug("CosmicNavigationSchool") << " adding all TIB self search.";
164  for (auto lIt = tibL.begin(); lIt != tibL.end(); ++lIt)
165  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
166  } else {
167  SimpleNavigableLayer* navigableLayer =
168  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[tibL.front()->seqNum()]);
169  LogDebug("CosmicNavigationSchool") << " adding tib1 to tib1.";
170  navigableLayer->theSelfSearch = true;
171  }
172  }
173  const std::vector<const BarrelDetLayer*>& pxbL = theInputTracker->pixelBarrelLayers();
174  if (!pxbL.empty()) {
175  if (conf.allSelf) {
176  LogDebug("CosmicNavigationSchool") << " adding all PXB self search.";
177  for (auto lIt = pxbL.begin(); lIt != pxbL.end(); ++lIt)
178  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
179  } else {
180  SimpleNavigableLayer* navigableLayer =
181  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[pxbL.front()->seqNum()]);
182  LogDebug("CosmicNavigationSchool") << " adding pxb1 to pxb1.";
183  navigableLayer->theSelfSearch = true;
184  }
185  }
186  }
187 }
188 
190  //identical to the SimpleNavigationSchool one, but it allows crossing over the tracker
191  //is some non-standard link is needed, it should probably be added here
192 
193  // Link barrel layers outwards
194  for (BDLI i = theBarrelLayers.begin(); i != theBarrelLayers.end(); i++) {
195  BDLC reachableBL;
196  FDLC leftFL;
197  FDLC rightFL;
198 
199  // always add next barrel layer first
200  if (i + 1 != theBarrelLayers.end())
201  reachableBL.push_back(*(i + 1));
202 
203  // Add closest reachable forward layer (except for last BarrelLayer)
204  if (i != theBarrelLayers.end() - 1) {
205  linkNextForwardLayer(*i, rightFL);
206  }
207 
208  // Add next BarrelLayer with length larger than the current BL
209  if (i + 2 < theBarrelLayers.end()) {
210  linkNextLargerLayer(i, theBarrelLayers.end(), reachableBL);
211  }
212 
213  theBarrelNLC.push_back(
214  new SimpleBarrelNavigableLayer(*i, reachableBL, symFinder.mirror(rightFL), rightFL, theField, 5., false));
215  }
216 }
217 
218 // identical to SimpleNavigationSchool but for the last additional stuff
220  //again: standard part is identical to SimpleNavigationSchool one.
221  //After the standard link, special outsideIn links are added
222 
223  // NavigationSetter setter(*this);
224 
225  setState(navigableLayers());
226 
227  // find for each layer which are the barrel and forward
228  // layers that point to it
229  typedef map<const DetLayer*, vector<const BarrelDetLayer*>, less<const DetLayer*> > BarrelMapType;
230  typedef map<const DetLayer*, vector<const ForwardDetLayer*>, less<const DetLayer*> > ForwardMapType;
231 
232  BarrelMapType reachedBarrelLayersMap;
233  ForwardMapType reachedForwardLayersMap;
234 
235  for (auto bli : theBarrelLayers) {
236  auto reachedLC = nextLayers(*bli, insideOut);
237  for (auto i : reachedLC) {
238  reachedBarrelLayersMap[i].push_back(bli);
239  }
240  }
241 
242  for (auto fli : theForwardLayers) {
243  auto reachedLC = nextLayers(*fli, insideOut);
244  for (auto i : reachedLC) {
245  reachedForwardLayersMap[i].push_back(fli);
246  }
247  }
248 
249  for (auto nl : theAllNavigableLayer) {
250  if (!nl)
251  continue;
252  auto navigableLayer = static_cast<SimpleNavigableLayer*>(nl);
253  auto dl = nl->detLayer();
254  navigableLayer->setInwardLinks(reachedBarrelLayersMap[dl], reachedForwardLayersMap[dl]);
255  }
256 
257  //buildAdditionalBarrelLinks();
258  buildAdditionalForwardLinks(symFinder);
259 }
260 
262  for (auto i = theBarrelLayers.begin(); i != theBarrelLayers.end(); i++) {
263  SimpleNavigableLayer* navigableLayer = dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*i)->seqNum()]);
264  if (i + 1 != theBarrelLayers.end())
265  navigableLayer->setAdditionalLink(*(i + 1), outsideIn);
266  }
267 }
268 
270  //the first layer of FPIX should not check the crossing side (since there are no inner layers to be tryed first)
271  SimpleNavigableLayer* firstR =
272  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[theRightLayers.front()->seqNum()]);
273  SimpleNavigableLayer* firstL =
274  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[theLeftLayers.front()->seqNum()]);
275  firstR->setCheckCrossingSide(false);
276  firstL->setCheckCrossingSide(false);
277 
278  for (auto i : theRightLayers) {
279  //look for first bigger barrel layer and link to it outsideIn
280  SimpleForwardNavigableLayer* nfl = 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.) {
287  mnfl->setAdditionalLink(j, outsideIn);
288  break;
289  }
290  }
291  }
292 }
293 
296 
297 #include "NavigationSchoolFactory.h"
300 
302 
303 #include <vector>
304 
305 //class FakeDetLayer;
306 
311 public:
313  const MagneticField* field,
315 
316  ~SkippingLayerCosmicNavigationSchool() override { cleanMemory(); };
317 };
318 
320  const GeometricSearchTracker* theInputTracker,
321  const MagneticField* field,
323  build(theInputTracker, field, conf);
324 }
325 
327 
328 #include <memory>
329 
330 // user include files
333 
335 
336 #include "NavigationSchoolFactory.h"
338 
339 //
340 // class decleration
341 //
343 public:
345  //the following line is needed to tell the framework what
346  // data is being produced
347  auto cc = setWhatProduced(this, iConfig.getParameter<std::string>("ComponentName"));
348  magFieldToken_ = cc.consumes();
349  geometricSearchTrackerToken_ = cc.consumes();
350  }
351 
352  using ReturnType = std::unique_ptr<NavigationSchool>;
353 
354  ReturnType produce(const NavigationSchoolRecord&);
355 
356  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
357 
358 private:
359  // ----------member data ---------------------------
363 };
364 
366  const NavigationSchoolRecord& iRecord) {
367  return std::unique_ptr<NavigationSchool>(new SkippingLayerCosmicNavigationSchool(
368  &iRecord.get(geometricSearchTrackerToken_), &iRecord.get(magFieldToken_), config_));
369 }
370 
373  desc.add<std::string>("ComponentName");
374  desc.add<bool>("noPXB");
375  desc.add<bool>("noPXF");
376  desc.add<bool>("noTIB");
377  desc.add<bool>("noTID");
378  desc.add<bool>("noTOB");
379  desc.add<bool>("noTEC");
380  desc.add<bool>("selfSearch");
381  desc.add<bool>("allSelf");
382 
383  descriptions.addDefault(desc);
384 }
385 
388 
void linkBarrelLayers(SymmetricLayerFinder &symFinder) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unique_ptr< NavigationSchool > ReturnType
std::vector< const BarrelDetLayer * > BDLC
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
virtual DetLayer const * detLayer() const =0
std::vector< DetLayer const * > const & allLayers() const
SkippingLayerCosmicNavigationSchool(const GeometricSearchTracker *theTracker, const MagneticField *field, const CosmicNavigationSchoolConfiguration conf)
#define LogTrace(id)
const ForwardDetLayer * mirror(const ForwardDetLayer *layer)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
SkippingLayerCosmicNavigationSchoolESProducer(const edm::ParameterSet &iConfig)
void addDefault(ParameterSetDescription const &psetDescription)
int seqNum() const
Definition: DetLayer.h:35
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:61
virtual void establishInverseRelations()
std::vector< const ForwardDetLayer * > FDLC
#define dso_hidden
Definition: Visibility.h:12
std::vector< BarrelDetLayer const * > const & pixelBarrelLayers() const
virtual void linkBarrelLayers(SymmetricLayerFinder &symFinder)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< BarrelDetLayer const * > const & tibLayers() const
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
edm::ESGetToken< GeometricSearchTracker, TrackerRecoGeometryRecord > geometricSearchTrackerToken_
void build(const GeometricSearchTracker *theTracker, const MagneticField *field, const CosmicNavigationSchoolConfiguration conf)
virtual void setAdditionalLink(const DetLayer *, NavigationDirection direction=insideOut)=0
CosmicNavigationSchool::CosmicNavigationSchoolConfiguration const config_
void setCheckCrossingSide(bool docheck)
double a
Definition: hdecay.h:121
static int position[264][3]
Definition: ReadPGInfo.cc:289
std::vector< BarrelDetLayer const * > const & tobLayers() const
#define DEFINE_EDM_PLUGIN(factory, type, name)
ReturnType produce(const NavigationSchoolRecord &)
void setAdditionalLink(const DetLayer *, NavigationDirection direction=insideOut) override
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
void buildAdditionalForwardLinks(SymmetricLayerFinder &symFinder)
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
#define LogDebug(id)