CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CosmicSeedCreator.cc
Go to the documentation of this file.
9 
10 template <class T> T sqr( T t) {return t*t;}
11 
13  const SeedingHitSet & ordered,
14  const TrackingRegion & region,
15  const edm::EventSetup& es,
16  const SeedComparitor *filter)
17 {
18 
19  //_________________________
20  //
21  //Get Parameters
22  //________________________
23 
24 
25  //hit package
26  //+++++++++++
27  const SeedingHitSet & hits = ordered;
28  if ( hits.size() < 2) return 0;
29 
30 
31  //hits
32  //++++
35 
37 
38  //definition of position & momentum
39  //++++++++++++++++++++++++++++++++++
40  GlobalVector initialMomentum(region.direction());//direction of the trajectory seed given by the direction of the region
41  //fix the momentum scale
42  //initialMomentum = initialMomentum.basicVector.unitVector() * region.origin().direction().mag();
43  //initialMomentum = region.origin().direction(); //alternative.
44  LogDebug("CosmicSeedCreator") << "initial momentum = " << initialMomentum;
45 
46 
47  //magnetic field
48  //++++++++++++++
50  es.get<IdealMagneticFieldRecord>().get(bfield);
51 
52 
53  //___________________________________________
54  //
55  //Direction of the trajectory seed
56  //___________________________________________
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 usedHit=tth2;
70 
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 
78  //apply corrections
79  //+++++++++++++++++
81 
82  if (reverseAll){
83  LogDebug("CosmicSeedCreator") <<"Reverse all applied";
84 
85  seedHits.push_back(tth2->hit()->clone());
86  seedHits.push_back(tth1->hit()->clone());
87  }
88 
89  else {
90  seedHits.push_back(tth1->hit()->clone());
91  seedHits.push_back(tth2->hit()->clone());
92  }
93 
94 
95  //propagation
96  //+++++++++++
97 
98  PropagationDirection seedDirection = alongMomentum; //by default
99 
100 
101  if (reverseAll) initialMomentum *=-1;
102 
103  if (bottomSeed){
104  //means that the seed parameters are inverse of what we want.
105  //reverse the momentum again
106  initialMomentum *=-1;
107  //and change the direction of the seed
108  seedDirection = oppositeToMomentum;
109  }
110 
111 
112  for (int charge=-1;charge<=1;charge+=2){
113  //fixme, what hit do you want to use ?
114 
115  FreeTrajectoryState freeState(GlobalTrajectoryParameters(usedHit->globalPosition(),
116  initialMomentum, charge, &*bfield),
117  CurvilinearTrajectoryError(ROOT::Math::SMatrixIdentity())
118  );
119 
120  LogDebug("CosmicSeedCreator")<<"Position freeState: " << usedHit->globalPosition()
121  <<"\nCharge: "<< charge
122  <<"\nInitial momentum :" << initialMomentum ;
123 
124  TrajectoryStateOnSurface tsos(freeState, *usedHit->surface());
125 
126 
127  PTrajectoryStateOnDet const & PTraj = trajectoryStateTransform::persistentState(tsos, usedHit->hit()->geographicalId().rawId());
128  TrajectorySeed seed(PTraj,seedHits,seedDirection);
129  if (filter == 0 || filter->compatible(seed)) {
130  seedCollection.push_back(seed);
131  }
132 
133  }//end charge loop
134 
135 
136  //________________
137  //
138  //Return seed
139  //________________
140 
141 
142  LogDebug("CosmicSeedCreator")
143  << "Using SeedCreator---------->\n"
144  << "seedCollections size = " << seedCollection.size();
145 
146  if ( seedCollection.size() > maxseeds_ ) {
147  edm::LogError("TooManySeeds") << "Found too many seeds (" << seedCollection.size() << " > " << maxseeds_ << "), bailing out.\n";
148  seedCollection.clear();
149  return 0;
150  }
151  else {
152  return (seedCollection.empty() ? 0 : &seedCollection.back());
153  }
154 
155 }
#define LogDebug(id)
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
PropagationDirection
virtual bool compatible(const SeedingHitSet &hits, const TrackingRegion &region) const =0
double charge(const std::vector< uint8_t > &Ampls)
void push_back(D *&d)
Definition: OwnVector.h:273
virtual GlobalVector direction() const =0
the direction around which region is constructed
std::vector< TrajectorySeed > TrajectorySeedCollection
const TrajectorySeed * trajectorySeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &ordered, const TrackingRegion &region, const edm::EventSetup &es, const SeedComparitor *filter)
const T & get() const
Definition: EventSetup.h:55
unsigned int maxseeds_
Square< F >::type sqr(const F &f)
Definition: Square.h:13
unsigned int size() const
Definition: SeedingHitSet.h:31
long double T