CMS 3D CMS Logo

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