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  //++++
44 
46 
47  //definition of position & momentum
48  //++++++++++++++++++++++++++++++++++
49  GlobalVector initialMomentum(region->direction());//direction of the trajectory seed given by the direction of the region
50  //fix the momentum scale
51  //initialMomentum = initialMomentum.basicVector.unitVector() * region->origin().direction().mag();
52  //initialMomentum = region->origin().direction(); //alternative.
53  LogDebug("CosmicSeedCreator") << "initial momentum = " << initialMomentum;
54 
55 
56 
57  //___________________________________________
58  //
59  //Direction of the trajectory seed
60  //___________________________________________
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 usedHit=tth2;
74 
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 
82  //apply corrections
83  //+++++++++++++++++
85 
86  if (reverseAll){
87  LogDebug("CosmicSeedCreator") <<"Reverse all applied";
88 
89  seedHits.push_back(tth2->hit()->clone());
90  seedHits.push_back(tth1->hit()->clone());
91  }
92 
93  else {
94  seedHits.push_back(tth1->hit()->clone());
95  seedHits.push_back(tth2->hit()->clone());
96  }
97 
98 
99  //propagation
100  //+++++++++++
101 
102  PropagationDirection seedDirection = alongMomentum; //by default
103 
104 
105  if (reverseAll) initialMomentum *=-1;
106 
107  if (bottomSeed){
108  //means that the seed parameters are inverse of what we want.
109  //reverse the momentum again
110  initialMomentum *=-1;
111  //and change the direction of the seed
112  seedDirection = oppositeToMomentum;
113  }
114 
115 
116  for (int charge=-1;charge<=1;charge+=2){
117  //fixme, what hit do you want to use ?
118 
119  FreeTrajectoryState freeState(GlobalTrajectoryParameters(usedHit->globalPosition(),
120  initialMomentum, charge, &*bfield),
121  CurvilinearTrajectoryError(ROOT::Math::SMatrixIdentity())
122  );
123 
124  LogDebug("CosmicSeedCreator")<<"Position freeState: " << usedHit->globalPosition()
125  <<"\nCharge: "<< charge
126  <<"\nInitial momentum :" << initialMomentum ;
127 
128  TrajectoryStateOnSurface tsos(freeState, *usedHit->surface());
129 
130 
131  PTrajectoryStateOnDet const & PTraj = trajectoryStateTransform::persistentState(tsos, usedHit->hit()->geographicalId().rawId());
132  TrajectorySeed seed(PTraj,seedHits,seedDirection);
133  if (filter == 0 || filter->compatible(seed)) {
134  seedCollection.push_back(seed);
135  }
136 
137  }//end charge loop
138 
139 
140  //________________
141  //
142  //Return seed
143  //________________
144 
145 
146  LogDebug("CosmicSeedCreator")
147  << "Using SeedCreator---------->\n"
148  << "seedCollections size = " << seedCollection.size();
149 
150  if ( seedCollection.size() > maxseeds_ ) {
151  edm::LogError("TooManySeeds") << "Found too many seeds (" << seedCollection.size() << " > " << maxseeds_ << "), bailing out.\n";
152  seedCollection.clear();
153  }
154 
155 }
#define LogDebug(id)
edm::ESHandle< MagneticField > bfield
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)
const SeedComparitor * filter
GlobalVector const & direction() const
the direction around which region is constructed
void push_back(D *&d)
Definition: OwnVector.h:273
std::vector< TrajectorySeed > TrajectorySeedCollection
virtual void makeSeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits)
const TrackingRegion * region
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:41
long double T
virtual void init(const TrackingRegion &region, const edm::EventSetup &es, const SeedComparitor *filter)