CMS 3D CMS Logo

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