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