CMS 3D CMS Logo

CosmicSeedCreator.cc
Go to the documentation of this file.
9 
10 namespace {
11  template <class T>
12  inline T sqr(T t) {
13  return t * t;
14  }
15 } // namespace
16 
17 void CosmicSeedCreator::init(const TrackingRegion& iregion, const edm::EventSetup& es, const SeedComparitor* ifilter) {
18  region = &iregion;
19  filter = ifilter;
20  // mag field
22 }
23 
25  //_________________________
26  //
27  //Get Parameters
28  //________________________
29 
30  //hit package
31  //+++++++++++
32  const SeedingHitSet& hits = ordered;
33  if (hits.size() < 2)
34  return;
35 
36  //hits
37  //++++
38  SeedingHitSet::ConstRecHitPointer tth1 = hits[0];
39  SeedingHitSet::ConstRecHitPointer tth2 = hits[1];
40  assert(!trackerHitRTTI::isUndef(*tth1));
41  assert(!trackerHitRTTI::isUndef(*tth2));
42 
44 
45  //definition of position & momentum
46  //++++++++++++++++++++++++++++++++++
47  //direction of the trajectory seed given by the direction of the region
48  GlobalVector initialMomentum(region->direction());
49  //fix the momentum scale
50  //initialMomentum = initialMomentum.basicVector.unitVector() * region->origin().direction().mag();
51  //initialMomentum = region->origin().direction(); //alternative.
52  LogDebug("CosmicSeedCreator") << "initial momentum = " << initialMomentum;
53 
54  //___________________________________________
55  //
56  //Direction of the trajectory seed
57  //___________________________________________
58 
59  //radius
60  //++++++
61  bool reverseAll = false;
62  if (fabs(tth1->globalPosition().perp()) < fabs(tth2->globalPosition().perp()))
63  //comparison of the position of the 2 hits by checking/comparing their radius
64  {
65  usedHit = tth1;
66  reverseAll = true;
67  }
68 
69  else
70  usedHit = tth2;
71 
72  //location in the barrel (up or bottom)
73  //+++++++++++++++++++++++++++++++++++++
74  //simple check, probably nees to be more precise FIXME
75  bool bottomSeed = (usedHit->globalPosition().y() < 0);
76 
77  //apply corrections
78  //+++++++++++++++++
80 
81  if (reverseAll) {
82  LogDebug("CosmicSeedCreator") << "Reverse all applied";
83 
84  seedHits.push_back(tth2->clone());
85  seedHits.push_back(tth1->clone());
86  }
87 
88  else {
89  seedHits.push_back(tth1->clone());
90  seedHits.push_back(tth2->clone());
91  }
92 
93  //propagation
94  //+++++++++++
95 
96  PropagationDirection seedDirection = alongMomentum; //by default
97 
98  if (reverseAll)
99  initialMomentum *= -1;
100 
101  if (bottomSeed) {
102  //means that the seed parameters are inverse of what we want.
103  //reverse the momentum again
104  initialMomentum *= -1;
105  //and change the direction of the seed
106  seedDirection = oppositeToMomentum;
107  }
108 
109  for (int charge = -1; charge <= 1; charge += 2) {
110  //fixme, what hit do you want to use ?
111 
112  FreeTrajectoryState freeState(
113  GlobalTrajectoryParameters(usedHit->globalPosition(), initialMomentum, charge, &*bfield),
114  CurvilinearTrajectoryError(ROOT::Math::SMatrixIdentity()));
115 
116  LogDebug("CosmicSeedCreator") << "Position freeState: " << usedHit->globalPosition() << "\nCharge: " << charge
117  << "\nInitial momentum :" << initialMomentum;
118 
119  TrajectoryStateOnSurface tsos(freeState, *usedHit->surface());
120 
121  PTrajectoryStateOnDet const& PTraj =
122  trajectoryStateTransform::persistentState(tsos, usedHit->hit()->geographicalId().rawId());
123  seedCollection.emplace_back(PTraj, seedHits, seedDirection);
124 
125  } //end charge loop
126 
127  //________________
128  //
129  //Return seed
130  //________________
131 
132  LogDebug("CosmicSeedCreator") << "Using SeedCreator---------->\n"
133  << "seedCollections size = " << seedCollection.size();
134 
135  if (seedCollection.size() > maxseeds_) {
136  edm::LogError("TooManySeeds") << "Found too many seeds (" << seedCollection.size() << " > " << maxseeds_
137  << "), bailing out.\n";
138  seedCollection.clear();
139  }
140 }
#define LogDebug(id)
edm::ESHandle< MagneticField > bfield
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
void init(const TrackingRegion &region, const edm::EventSetup &es, const SeedComparitor *filter) override
PropagationDirection
const SeedComparitor * filter
GlobalVector const & direction() const
the direction around which region is constructed
void push_back(D *&d)
Definition: OwnVector.h:326
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:10
std::vector< TrajectorySeed > TrajectorySeedCollection
const TrackingRegion * region
void makeSeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits) override
unsigned int maxseeds_
Square< F >::type sqr(const F &f)
Definition: Square.h:14
T get() const
Definition: EventSetup.h:73
unsigned int size() const
Definition: SeedingHitSet.h:41
bool isUndef(TrackingRecHit const &hit)
long double T