CMS 3D CMS Logo

CosmicNavigationSchool.cc
Go to the documentation of this file.
2 
4 
6 
7 #include <vector>
8 
9 //class FakeDetLayer;
10 
15 public:
16  CosmicNavigationSchool(const GeometricSearchTracker* theTracker, const MagneticField* field);
18 
20  public:
22  : noPXB(false),
23  noPXF(false),
24  noTOB(false),
25  noTIB(false),
26  noTEC(false),
27  noTID(false),
28  self(false),
29  allSelf(false) {}
31  bool noPXB;
32  bool noPXF;
33  bool noTOB;
34  bool noTIB;
35  bool noTEC;
36  bool noTID;
37 
38  bool self;
39  bool allSelf;
40  };
41 
42  void build(const GeometricSearchTracker* theTracker,
43  const MagneticField* field,
45 
46 protected:
48 
49 private:
50  //FakeDetLayer* theFakeDetLayer;
51  void linkBarrelLayers(SymmetricLayerFinder& symFinder) override;
52  //void linkForwardLayers( SymmetricLayerFinder& symFinder);
54  void establishInverseRelations(SymmetricLayerFinder& symFinder);
55  void buildAdditionalBarrelLinks();
56  void buildAdditionalForwardLinks(SymmetricLayerFinder& symFinder);
57 };
58 
60 
63 #include "SimpleNavigableLayer.h"
64 #include "SymmetricLayerFinder.h"
65 
69 
70 #include <functional>
71 #include <algorithm>
72 #include <map>
73 #include <cmath>
74 
75 using namespace std;
76 
78  const edm::ParameterSet& conf) {
79  noPXB = conf.getParameter<bool>("noPXB");
80  noPXF = conf.getParameter<bool>("noPXF");
81  noTIB = conf.getParameter<bool>("noTIB");
82  noTID = conf.getParameter<bool>("noTID");
83  noTOB = conf.getParameter<bool>("noTOB");
84  noTEC = conf.getParameter<bool>("noTEC");
85  self = conf.getParameter<bool>("selfSearch");
86  allSelf = conf.getParameter<bool>("allSelf");
87 }
88 
90  const MagneticField* field) {
91  build(theInputTracker, field, CosmicNavigationSchoolConfiguration());
92 }
93 
95  const MagneticField* field,
97  LogTrace("CosmicNavigationSchool") << "*********Running CosmicNavigationSchool***********";
98  theBarrelLength = 0;
99  theField = field;
100  theTracker = theInputTracker;
101 
102  theAllDetLayersInSystem = &theInputTracker->allLayers();
103  theAllNavigableLayer.resize(theInputTracker->allLayers().size(), nullptr);
104 
105  // Get barrel layers
106  vector<BarrelDetLayer const*> const& blc = theTracker->barrelLayers();
107  for (auto i = blc.begin(); i != blc.end(); i++) {
108  if (conf.noPXB && GeomDetEnumerators::isTrackerPixel((*i)->subDetector()))
109  continue;
110  if (conf.noTOB && (*i)->subDetector() == GeomDetEnumerators::TOB)
111  continue;
112  if (conf.noTIB && (*i)->subDetector() == GeomDetEnumerators::TIB)
113  continue;
114  theBarrelLayers.push_back((*i));
115  }
116 
117  // get forward layers
118  vector<ForwardDetLayer const*> const& flc = theTracker->forwardLayers();
119  for (auto i = flc.begin(); i != flc.end(); i++) {
120  if (conf.noPXF && GeomDetEnumerators::isTrackerPixel((*i)->subDetector()))
121  continue;
122  if (conf.noTEC && (*i)->subDetector() == GeomDetEnumerators::TEC)
123  continue;
124  if (conf.noTID && (*i)->subDetector() == GeomDetEnumerators::TID)
125  continue;
126  theForwardLayers.push_back((*i));
127  }
128 
129  FDLI middle =
130  find_if(theForwardLayers.begin(), theForwardLayers.end(), [](auto const* a) { return a->position().z() >= 0.0; });
131  theLeftLayers = FDLC(theForwardLayers.begin(), middle);
132  theRightLayers = FDLC(middle, theForwardLayers.end());
133 
134  SymmetricLayerFinder symFinder(theForwardLayers);
135 
136  // only work on positive Z side; negative by mirror symmetry later
137  linkBarrelLayers(symFinder);
138  linkForwardLayers(symFinder);
139  establishInverseRelations(symFinder);
140 
141  if (conf.self) {
142  // set the self search by hand
143  // NavigationSetter setter(*this);
144 
145  //add TOB1->TOB1 inward link
146  const std::vector<const BarrelDetLayer*>& tobL = theInputTracker->tobLayers();
147  if (!tobL.empty()) {
148  if (conf.allSelf) {
149  LogDebug("CosmicNavigationSchool") << " adding all TOB self search.";
150  for (auto lIt = tobL.begin(); lIt != tobL.end(); ++lIt)
151  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
152  } else {
153  SimpleNavigableLayer* navigableLayer =
154  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[tobL.front()->seqNum()]);
155  LogDebug("CosmicNavigationSchool") << " adding TOB1 to TOB1.";
156  navigableLayer->theSelfSearch = true;
157  }
158  }
159  const std::vector<const BarrelDetLayer*>& tibL = theInputTracker->tibLayers();
160  if (!tibL.empty()) {
161  if (conf.allSelf) {
162  LogDebug("CosmicNavigationSchool") << " adding all TIB self search.";
163  for (auto lIt = tibL.begin(); lIt != tibL.end(); ++lIt)
164  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
165  } else {
166  SimpleNavigableLayer* navigableLayer =
167  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[tibL.front()->seqNum()]);
168  LogDebug("CosmicNavigationSchool") << " adding tib1 to tib1.";
169  navigableLayer->theSelfSearch = true;
170  }
171  }
172  const std::vector<const BarrelDetLayer*>& pxbL = theInputTracker->pixelBarrelLayers();
173  if (!pxbL.empty()) {
174  if (conf.allSelf) {
175  LogDebug("CosmicNavigationSchool") << " adding all PXB self search.";
176  for (auto lIt = pxbL.begin(); lIt != pxbL.end(); ++lIt)
177  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
178  } else {
179  SimpleNavigableLayer* navigableLayer =
180  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[pxbL.front()->seqNum()]);
181  LogDebug("CosmicNavigationSchool") << " adding pxb1 to pxb1.";
182  navigableLayer->theSelfSearch = true;
183  }
184  }
185  }
186 }
187 
189  //identical to the SimpleNavigationSchool one, but it allows crossing over the tracker
190  //is some non-standard link is needed, it should probably be added here
191 
192  // Link barrel layers outwards
193  for (BDLI i = theBarrelLayers.begin(); i != theBarrelLayers.end(); i++) {
194  BDLC reachableBL;
195  FDLC leftFL;
196  FDLC rightFL;
197 
198  // always add next barrel layer first
199  if (i + 1 != theBarrelLayers.end())
200  reachableBL.push_back(*(i + 1));
201 
202  // Add closest reachable forward layer (except for last BarrelLayer)
203  if (i != theBarrelLayers.end() - 1) {
204  linkNextForwardLayer(*i, rightFL);
205  }
206 
207  // Add next BarrelLayer with length larger than the current BL
208  if (i + 2 < theBarrelLayers.end()) {
209  linkNextLargerLayer(i, theBarrelLayers.end(), reachableBL);
210  }
211 
212  theBarrelNLC.push_back(
213  new SimpleBarrelNavigableLayer(*i, reachableBL, symFinder.mirror(rightFL), rightFL, theField, 5., false));
214  }
215 }
216 
217 // identical to SimpleNavigationSchool but for the last additional stuff
219  //again: standard part is identical to SimpleNavigationSchool one.
220  //After the standard link, special outsideIn links are added
221 
222  // NavigationSetter setter(*this);
223 
224  setState(navigableLayers());
225 
226  // find for each layer which are the barrel and forward
227  // layers that point to it
228  typedef map<const DetLayer*, vector<const BarrelDetLayer*>, less<const DetLayer*> > BarrelMapType;
229  typedef map<const DetLayer*, vector<const ForwardDetLayer*>, less<const DetLayer*> > ForwardMapType;
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)
250  continue;
251  auto navigableLayer = static_cast<SimpleNavigableLayer*>(nl);
252  auto dl = nl->detLayer();
253  navigableLayer->setInwardLinks(reachedBarrelLayersMap[dl], reachedForwardLayersMap[dl]);
254  }
255 
256  //buildAdditionalBarrelLinks();
257  buildAdditionalForwardLinks(symFinder);
258 }
259 
261  for (auto i = theBarrelLayers.begin(); i != theBarrelLayers.end(); i++) {
262  SimpleNavigableLayer* navigableLayer = dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*i)->seqNum()]);
263  if (i + 1 != theBarrelLayers.end())
264  navigableLayer->setAdditionalLink(*(i + 1), outsideIn);
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
279  SimpleForwardNavigableLayer* nfl = dynamic_cast<SimpleForwardNavigableLayer*>(theAllNavigableLayer[(i)->seqNum()]);
281  dynamic_cast<SimpleForwardNavigableLayer*>(theAllNavigableLayer[symFinder.mirror(i)->seqNum()]);
282  for (auto j : theBarrelLayers) {
283  if ((i)->specificSurface().outerRadius() < (j)->specificSurface().radius() &&
284  fabs((i)->specificSurface().position().z()) < (j)->surface().bounds().length() / 2.) {
286  mnfl->setAdditionalLink(j, outsideIn);
287  break;
288  }
289  }
290  }
291 }
292 
295 
296 #include "NavigationSchoolFactory.h"
299 
301 
302 #include <vector>
303 
304 //class FakeDetLayer;
305 
310 public:
312  const MagneticField* field,
314 
315  ~SkippingLayerCosmicNavigationSchool() override { cleanMemory(); };
316 };
317 
319  const GeometricSearchTracker* theInputTracker,
320  const MagneticField* field,
322  build(theInputTracker, field, conf);
323 }
324 
326 
327 #include <memory>
328 
329 // user include files
332 
334 
335 #include "NavigationSchoolFactory.h"
337 
338 //
339 // class decleration
340 //
342 public:
344  //the following line is needed to tell the framework what
345  // data is being produced
346  setWhatProduced(this, iConfig.getParameter<std::string>("ComponentName"))
347  .setConsumes(magFieldToken_)
348  .setConsumes(geometricSearchTrackerToken_);
349  }
350 
351  using ReturnType = std::unique_ptr<NavigationSchool>;
352 
353  ReturnType produce(const NavigationSchoolRecord&);
354 
355  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
356 
357 private:
358  // ----------member data ---------------------------
362 };
363 
365  const NavigationSchoolRecord& iRecord) {
366  return std::unique_ptr<NavigationSchool>(new SkippingLayerCosmicNavigationSchool(
367  &iRecord.get(geometricSearchTrackerToken_), &iRecord.get(magFieldToken_), config_));
368 }
369 
372  desc.add<std::string>("ComponentName");
373  desc.add<bool>("noPXB");
374  desc.add<bool>("noPXF");
375  desc.add<bool>("noTIB");
376  desc.add<bool>("noTID");
377  desc.add<bool>("noTOB");
378  desc.add<bool>("noTEC");
379  desc.add<bool>("selfSearch");
380  desc.add<bool>("allSelf");
381 
382  descriptions.addDefault(desc);
383 }
384 
387 
#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)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int seqNum() const
Definition: DetLayer.h:35
SkippingLayerCosmicNavigationSchoolESProducer(const edm::ParameterSet &iConfig)
void addDefault(ParameterSetDescription const &psetDescription)
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
std::vector< BarrelDetLayer const * > const & pixelBarrelLayers() const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
#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
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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)
virtual DetLayer const * detLayer() const =0
double a
Definition: hdecay.h:119
static int position[264][3]
Definition: ReadPGInfo.cc:289
#define DEFINE_EDM_PLUGIN(factory, type, name)
ReturnType produce(const NavigationSchoolRecord &)
void setAdditionalLink(const DetLayer *, NavigationDirection direction=insideOut) override
void buildAdditionalForwardLinks(SymmetricLayerFinder &symFinder)
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)