CMS 3D CMS Logo

SeedGeneratorForCosmics.cc
Go to the documentation of this file.
7 void
9  const SiStripRecHit2DCollection &collrphi ,
10  const SiStripMatchedRecHit2DCollection &collmatched,
11  const edm::EventSetup& iSetup)
12 {
13  iSetup.get<IdealMagneticFieldRecord>().get(magfield);
14  iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
17  theUpdator= new KFUpdator();
18 
19  // get the transient builder
20  //
21 
23 
24  iSetup.get<TransientRecHitRecord>().get(builderName,theBuilder);
25  TTTRHBuilder = theBuilder.product();
26  LogDebug("CosmicSeedFinder")<<" Hits built with "<<hitsforseeds<<" hits";
27 
28  CosmicLayerPairs cosmiclayers(geometry);
29 
30  cosmiclayers.init(collstereo,collrphi,collmatched,iSetup);
31  thePairGenerator=new CosmicHitPairGenerator(cosmiclayers,iSetup);
32  HitPairs.clear();
33  if ((hitsforseeds=="pairs")||(hitsforseeds=="pairsandtriplets")){
35  }
36 
37  CosmicLayerTriplets cosmiclayers2;
38  cosmiclayers2.init(collstereo,collrphi,collmatched,geometry,iSetup);
39  theTripletGenerator=new CosmicHitTripletGenerator(cosmiclayers2,iSetup);
40  HitTriplets.clear();
41  if ((hitsforseeds=="triplets")||(hitsforseeds=="pairsandtriplets")){
43  }
44 }
45 
47  maxSeeds_(conf.getParameter<int32_t>("maxSeeds"))
48 {
49 
50  float ptmin=conf.getParameter<double>("ptMin");
51  float originradius=conf.getParameter<double>("originRadius");
52  float halflength=conf.getParameter<double>("originHalfLength");
53  float originz=conf.getParameter<double>("originZPosition");
54  seedpt = conf.getParameter<double>("SeedPt");
55 
56  builderName = conf.getParameter<std::string>("TTRHBuilder");
57  geometry=conf.getUntrackedParameter<std::string>("GeometricStructure","STANDARD");
58  region=GlobalTrackingRegion(ptmin,originradius,
59  halflength,originz);
60  hitsforseeds=conf.getUntrackedParameter<std::string>("HitsForSeeds","pairs");
61  edm::LogInfo("SeedGeneratorForCosmics")<<" PtMin of track is "<<ptmin<<
62  " The Radius of the cylinder for seeds is "<<originradius <<"cm" << " The set Seed Momentum" << seedpt;
63 
64  //***top-bottom
65  positiveYOnly=conf.getParameter<bool>("PositiveYOnly");
66  negativeYOnly=conf.getParameter<bool>("NegativeYOnly");
67  //***
68 
69 
70 }
71 
73  seeds(output,iSetup,region);
74  delete thePairGenerator;
75  delete theTripletGenerator;
76  delete thePropagatorAl;
77  delete thePropagatorOp;
78  delete theUpdator;
79 }
81  const edm::EventSetup& iSetup,
82  const TrackingRegion& region){
83  LogDebug("CosmicSeedFinder")<<"Number of triplets "<<HitTriplets.size();
84  LogDebug("CosmicSeedFinder")<<"Number of pairs "<<HitPairs.size();
85 
86  for (unsigned int it=0;it<HitTriplets.size();it++){
87 
88  //const TrackingRecHit *hit = &(
89  // const TrackingRecHit* hit = it->hits();
90 
91  // GlobalPoint inner = tracker->idToDet(HitTriplets[it].inner().RecHit()->
92 // geographicalId())->surface().
93 // toGlobal(HitTriplets[it].inner().RecHit()->localPosition());
94  //const TrackingRecHit *innerhit = &(*HitTriplets[it].inner());
95  //const TrackingRecHit *middlehit = &(*HitTriplets[it].middle());
96 
97  GlobalPoint inner = tracker->idToDet((*(HitTriplets[it].inner())).geographicalId())->surface().
98  toGlobal((*(HitTriplets[it].inner())).localPosition());
99 
100  GlobalPoint middle = tracker->idToDet((*(HitTriplets[it].middle())).geographicalId())->surface().
101  toGlobal((*(HitTriplets[it].middle())).localPosition());
102 
103  GlobalPoint outer = tracker->idToDet((*(HitTriplets[it].outer())).geographicalId())->surface().
104  toGlobal((*(HitTriplets[it].outer())).localPosition());
105 
106  // SeedingHitSet::ConstRecHitPointer outrhit=TTTRHBuilder->build(HitPairs[is].outer())
107 
108  SeedingHitSet::ConstRecHitPointer outrhit= HitTriplets[it].outer();
109  //***top-bottom
110  SeedingHitSet::ConstRecHitPointer innrhit = HitTriplets[it].inner();
111  if (positiveYOnly && (outrhit->globalPosition().y()<0 || innrhit->globalPosition().y()<0
112  || outrhit->globalPosition().y() < innrhit->globalPosition().y()
113  ) ) continue;
114  if (negativeYOnly && (outrhit->globalPosition().y()>0 || innrhit->globalPosition().y()>0
115  || outrhit->globalPosition().y() > innrhit->globalPosition().y()
116  ) ) continue;
117  //***
118 
120  hits.push_back(HitTriplets[it].outer()->hit()->clone());
121  FastHelix helix(inner, middle, outer, magfield->nominalValue(), &(*magfield));
122  GlobalVector gv=helix.stateAtVertex().momentum();
123  float ch=helix.stateAtVertex().charge();
124  float Mom = sqrt( gv.x()*gv.x() + gv.y()*gv.y() + gv.z()*gv.z() );
125  if(Mom > 1000 || std::isnan(Mom)) continue; // ChangedByDaniele
126 
127  if (gv.y()>0){
128  gv=-1.*gv;
129  ch=-1.*ch;
130  }
131 
132  GlobalTrajectoryParameters Gtp(outer,
133  gv,int(ch),
134  &(*magfield));
135  FreeTrajectoryState CosmicSeed(Gtp,
137  if((outer.y()-inner.y())>0){
138  const TSOS outerState =
139  thePropagatorAl->propagate(CosmicSeed,
140  tracker->idToDet((*(HitTriplets[it].outer())).geographicalId())->surface());
141  if ( outerState.isValid()) {
142  LogDebug("CosmicSeedFinder") <<"outerState "<<outerState;
143  const TSOS outerUpdated= theUpdator->update( outerState,*outrhit);
144  if ( outerUpdated.isValid()) {
145  LogDebug("CosmicSeedFinder") <<"outerUpdated "<<outerUpdated;
146 
147  output.push_back(TrajectorySeed(trajectoryStateTransform::persistentState(outerUpdated,(*(HitTriplets[it].outer())).geographicalId().rawId())
148  ,hits,alongMomentum));
149 
150  if ((maxSeeds_ > 0) && (output.size() > size_t(maxSeeds_))) {
151  edm::LogError("TooManySeeds") << "Found too many seeds, bailing out.\n";
152  output.clear();
153  return false;
154  }
155  }
156  }
157  } else {
158  const TSOS outerState =
159  thePropagatorOp->propagate(CosmicSeed,
160  tracker->idToDet((*(HitTriplets[it].outer())).geographicalId())->surface());
161  if ( outerState.isValid()) {
162  LogDebug("CosmicSeedFinder") <<"outerState "<<outerState;
163  const TSOS outerUpdated= theUpdator->update( outerState,*outrhit);
164  if ( outerUpdated.isValid()) {
165  LogDebug("CosmicSeedFinder") <<"outerUpdated "<<outerUpdated;
166 
167  output.push_back(TrajectorySeed(trajectoryStateTransform::persistentState(outerUpdated,
168  (*(HitTriplets[it].outer())).geographicalId().rawId()),hits,oppositeToMomentum));
169 
170  if ((maxSeeds_ > 0) && (output.size() > size_t(maxSeeds_))) {
171  edm::LogError("TooManySeeds") << "Found too many seeds, bailing out.\n";
172  output.clear();
173  return false;
174  }
175  }
176  }
177  }
178  }
179 
180 
181  for(unsigned int is=0;is<HitPairs.size();is++){
182 
183 
184 
185  GlobalPoint inner = tracker->idToDet((*(HitPairs[is].inner())).geographicalId())->surface().toGlobal((*(HitPairs[is].inner())).localPosition());
186  GlobalPoint outer = tracker->idToDet((*(HitPairs[is].outer())).geographicalId())->surface().toGlobal((*(HitPairs[is].outer())).localPosition());
187 
188  LogDebug("CosmicSeedFinder") <<"inner point of the seed "<<inner <<" outer point of the seed "<<outer;
189  //RC const TransientTrackingRecHit* outrhit=TTTRHBuilder->build(HitPairs[is].outer().RecHit());
190  SeedingHitSet::ConstRecHitPointer outrhit = HitPairs[is].outer();
191  //***top-bottom
192  SeedingHitSet::ConstRecHitPointer innrhit = HitPairs[is].inner();
193  if (positiveYOnly && (outrhit->globalPosition().y()<0 || innrhit->globalPosition().y()<0
194  || outrhit->globalPosition().y() < innrhit->globalPosition().y()
195  ) ) continue;
196  if (negativeYOnly && (outrhit->globalPosition().y()>0 || innrhit->globalPosition().y()>0
197  || outrhit->globalPosition().y() > innrhit->globalPosition().y()
198  ) ) continue;
199  //***
200 
202  hits.push_back(HitPairs[is].outer()->hit()->clone());
203  // hits.push_back(HitPairs[is].inner()->clone());
204 
205  for (int i=0;i<2;i++){
206  //FIRST STATE IS CALCULATED CONSIDERING THAT THE CHARGE CAN BE POSITIVE OR NEGATIVE
207  int predsign=(2*i)-1;
208  if((outer.y()-inner.y())>0){
209  GlobalTrajectoryParameters Gtp(outer,
210  (inner-outer)*(seedpt/(inner-outer).mag()),
211  predsign,
212  &(*magfield));
213 
214  FreeTrajectoryState CosmicSeed(Gtp,
216 
217 
218  LogDebug("CosmicSeedFinder") << " FirstTSOS "<<CosmicSeed;
219  //First propagation
220  const TSOS outerState =
221  thePropagatorAl->propagate(CosmicSeed,
222  tracker->idToDet((*(HitPairs[is].outer())).geographicalId())->surface());
223  if ( outerState.isValid()) {
224  LogDebug("CosmicSeedFinder") <<"outerState "<<outerState;
225  const TSOS outerUpdated= theUpdator->update( outerState,*outrhit);
226  if ( outerUpdated.isValid()) {
227  LogDebug("CosmicSeedFinder") <<"outerUpdated "<<outerUpdated;
228 
229  PTrajectoryStateOnDet const & PTraj =
230  trajectoryStateTransform::persistentState(outerUpdated, (*(HitPairs[is].outer())).geographicalId().rawId());
231 
232  output.push_back( TrajectorySeed(PTraj,hits,alongMomentum));
233 
234  if ((maxSeeds_ > 0) && (output.size() > size_t(maxSeeds_))) {
235  edm::LogError("TooManySeeds") << "Found too many seeds, bailing out.\n";
236  output.clear();
237  return false;
238  }
239 
240  }else edm::LogWarning("CosmicSeedFinder") << " SeedForCosmics first update failed ";
241  }else edm::LogWarning("CosmicSeedFinder") << " SeedForCosmics first propagation failed ";
242 
243 
244  }
245  else{
246  GlobalTrajectoryParameters Gtp(outer,
247  (outer-inner)*(seedpt/(outer-inner).mag()),
248  predsign,
249  &(*magfield));
250  FreeTrajectoryState CosmicSeed(Gtp,
252  LogDebug("CosmicSeedFinder") << " FirstTSOS "<<CosmicSeed;
253  //First propagation
254  const TSOS outerState =
255  thePropagatorAl->propagate(CosmicSeed,
256  tracker->idToDet((*(HitPairs[is].outer())).geographicalId())->surface());
257  if ( outerState.isValid()) {
258 
259  LogDebug("CosmicSeedFinder") <<"outerState "<<outerState;
260  const TSOS outerUpdated= theUpdator->update( outerState,*outrhit);
261  if ( outerUpdated.isValid()) {
262  LogDebug("CosmicSeedFinder") <<"outerUpdated "<<outerUpdated;
263 
264  PTrajectoryStateOnDet const & PTraj =
265  trajectoryStateTransform::persistentState(outerUpdated,(*(HitPairs[is].outer())).geographicalId().rawId());
266 
267  output.push_back(TrajectorySeed(PTraj,hits,oppositeToMomentum));
268 
269  if ((maxSeeds_ > 0) && (output.size() > size_t(maxSeeds_))) {
270  edm::LogError("TooManySeeds") << "Found too many seeds, bailing out.\n";
271  output.clear();
272  return false;
273  }
274 
275  }else edm::LogWarning("CosmicSeedFinder") << " SeedForCosmics first update failed ";
276  }else edm::LogWarning("CosmicSeedFinder") << " SeedForCosmics first propagation failed ";
277  }
278 
279  }
280  }
281  return true;
282 }
#define LogDebug(id)
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::ESHandle< TrackerGeometry > tracker
void run(TrajectorySeedCollection &, const edm::EventSetup &c)
int nominalValue() const
The nominal field value for this map in kGauss.
Definition: MagneticField.h:56
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
T y() const
Definition: PV3DBase.h:63
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
virtual unsigned int size() const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
void hitPairs(const TrackingRegion &reg, OrderedHitPairs &prs, const edm::EventSetup &iSetup)
form base class
PropagatorWithMaterial * thePropagatorOp
CosmicHitTripletGenerator * theTripletGenerator
void init(const SiStripRecHit2DCollection &collstereo, const SiStripRecHit2DCollection &collrphi, const SiStripMatchedRecHit2DCollection &collmatched, std::string geometry, const edm::EventSetup &iSetup)
void hitTriplets(const TrackingRegion &reg, OrderedHitTriplets &prs, const edm::EventSetup &iSetup)
CosmicHitPairGenerator * thePairGenerator
void push_back(D *&d)
Definition: OwnVector.h:290
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:11
PropagatorWithMaterial * thePropagatorAl
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const
Definition: KFUpdator.cc:75
std::vector< TrajectorySeed > TrajectorySeedCollection
bool isnan(float x)
Definition: math.h:13
T sqrt(T t)
Definition: SSEVec.h:18
bool seeds(TrajectorySeedCollection &output, const edm::EventSetup &c, const TrackingRegion &region)
void init(const SiStripRecHit2DCollection &collstereo, const SiStripRecHit2DCollection &collrphi, const SiStripMatchedRecHit2DCollection &collmatched, const edm::EventSetup &iSetup)
const T & get() const
Definition: EventSetup.h:56
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:53
double ptmin
Definition: HydjetWrapper.h:90
SeedGeneratorForCosmics(const edm::ParameterSet &conf)
virtual unsigned int size() const
const TransientTrackingRecHitBuilder * TTTRHBuilder
T const * product() const
Definition: ESHandle.h:86
edm::ESHandle< MagneticField > magfield
void init(const SiStripRecHit2DCollection &collstereo, const SiStripRecHit2DCollection &collrphi, const SiStripMatchedRecHit2DCollection &collmatched, const edm::EventSetup &c)
const TrackerGeomDet * idToDet(DetId) const