CMS 3D CMS Logo

SeedGeneratorForCosmics.cc
Go to the documentation of this file.
8  const SiStripRecHit2DCollection& collrphi,
9  const SiStripMatchedRecHit2DCollection& collmatched,
10  const edm::EventSetup& iSetup) {
15  theUpdator = new KFUpdator();
16 
17  // get the transient builder
18  //
19 
21 
22  iSetup.get<TransientRecHitRecord>().get(builderName, theBuilder);
23  TTTRHBuilder = theBuilder.product();
24  LogDebug("CosmicSeedFinder") << " Hits built with " << hitsforseeds << " hits";
25 
26  CosmicLayerPairs cosmiclayers(geometry);
27 
28  cosmiclayers.init(collstereo, collrphi, collmatched, iSetup);
29  thePairGenerator = new CosmicHitPairGenerator(cosmiclayers, iSetup);
30  HitPairs.clear();
31  if ((hitsforseeds == "pairs") || (hitsforseeds == "pairsandtriplets")) {
33  }
34 
35  CosmicLayerTriplets cosmiclayers2;
36  cosmiclayers2.init(collstereo, collrphi, collmatched, geometry, iSetup);
37  theTripletGenerator = new CosmicHitTripletGenerator(cosmiclayers2, iSetup);
38  HitTriplets.clear();
39  if ((hitsforseeds == "triplets") || (hitsforseeds == "pairsandtriplets")) {
41  }
42 }
43 
45  : maxSeeds_(conf.getParameter<int32_t>("maxSeeds")) {
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  builderName = conf.getParameter<std::string>("TTRHBuilder");
53  geometry = conf.getUntrackedParameter<std::string>("GeometricStructure", "STANDARD");
54  region = GlobalTrackingRegion(ptmin, originradius, halflength, originz);
55  hitsforseeds = conf.getUntrackedParameter<std::string>("HitsForSeeds", "pairs");
56  edm::LogInfo("SeedGeneratorForCosmics")
57  << " PtMin of track is " << ptmin << " The Radius of the cylinder for seeds is " << originradius << "cm"
58  << " The set Seed Momentum" << seedpt;
59 
60  //***top-bottom
61  positiveYOnly = conf.getParameter<bool>("PositiveYOnly");
62  negativeYOnly = conf.getParameter<bool>("NegativeYOnly");
63  //***
64 }
65 
67  seeds(output, iSetup, region);
68  delete thePairGenerator;
69  delete theTripletGenerator;
70  delete thePropagatorAl;
71  delete thePropagatorOp;
72  delete theUpdator;
73 }
75  const edm::EventSetup& iSetup,
76  const TrackingRegion& region) {
77  LogDebug("CosmicSeedFinder") << "Number of triplets " << HitTriplets.size();
78  LogDebug("CosmicSeedFinder") << "Number of pairs " << HitPairs.size();
79 
80  for (unsigned int it = 0; it < HitTriplets.size(); it++) {
81  //const TrackingRecHit *hit = &(
82  // const TrackingRecHit* hit = it->hits();
83 
84  // GlobalPoint inner = tracker->idToDet(HitTriplets[it].inner().RecHit()->
85  // geographicalId())->surface().
86  // toGlobal(HitTriplets[it].inner().RecHit()->localPosition());
87  //const TrackingRecHit *innerhit = &(*HitTriplets[it].inner());
88  //const TrackingRecHit *middlehit = &(*HitTriplets[it].middle());
89 
90  GlobalPoint inner = tracker->idToDet((*(HitTriplets[it].inner())).geographicalId())
91  ->surface()
92  .toGlobal((*(HitTriplets[it].inner())).localPosition());
93 
94  GlobalPoint middle = tracker->idToDet((*(HitTriplets[it].middle())).geographicalId())
95  ->surface()
96  .toGlobal((*(HitTriplets[it].middle())).localPosition());
97 
98  GlobalPoint outer = tracker->idToDet((*(HitTriplets[it].outer())).geographicalId())
99  ->surface()
100  .toGlobal((*(HitTriplets[it].outer())).localPosition());
101 
102  // SeedingHitSet::ConstRecHitPointer outrhit=TTTRHBuilder->build(HitPairs[is].outer())
103 
104  SeedingHitSet::ConstRecHitPointer outrhit = HitTriplets[it].outer();
105  //***top-bottom
106  SeedingHitSet::ConstRecHitPointer innrhit = HitTriplets[it].inner();
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 Mom = sqrt(gv.x() * gv.x() + gv.y() * gv.y() + gv.z() * gv.z());
121  if (Mom > 1000 || std::isnan(Mom))
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  //RC const TransientTrackingRecHit* outrhit=TTTRHBuilder->build(HitPairs[is].outer().RecHit());
186  SeedingHitSet::ConstRecHitPointer outrhit = HitPairs[is].outer();
187  //***top-bottom
188  SeedingHitSet::ConstRecHitPointer innrhit = HitPairs[is].inner();
189  if (positiveYOnly && (outrhit->globalPosition().y() < 0 || innrhit->globalPosition().y() < 0 ||
190  outrhit->globalPosition().y() < innrhit->globalPosition().y()))
191  continue;
192  if (negativeYOnly && (outrhit->globalPosition().y() > 0 || innrhit->globalPosition().y() > 0 ||
193  outrhit->globalPosition().y() > innrhit->globalPosition().y()))
194  continue;
195  //***
196 
198  hits.push_back(HitPairs[is].outer()->hit()->clone());
199  // hits.push_back(HitPairs[is].inner()->clone());
200 
201  for (int i = 0; i < 2; i++) {
202  //FIRST STATE IS CALCULATED CONSIDERING THAT THE CHARGE CAN BE POSITIVE OR NEGATIVE
203  int predsign = (2 * i) - 1;
204  if ((outer.y() - inner.y()) > 0) {
206  outer, (inner - outer) * (seedpt / (inner - outer).mag()), predsign, &(*magfield));
207 
209 
210  LogDebug("CosmicSeedFinder") << " FirstTSOS " << CosmicSeed;
211  //First propagation
212  const TSOS outerState = thePropagatorAl->propagate(
213  CosmicSeed, tracker->idToDet((*(HitPairs[is].outer())).geographicalId())->surface());
214  if (outerState.isValid()) {
215  LogDebug("CosmicSeedFinder") << "outerState " << outerState;
216  const TSOS outerUpdated = theUpdator->update(outerState, *outrhit);
217  if (outerUpdated.isValid()) {
218  LogDebug("CosmicSeedFinder") << "outerUpdated " << outerUpdated;
219 
221  outerUpdated, (*(HitPairs[is].outer())).geographicalId().rawId());
222 
223  output.push_back(TrajectorySeed(PTraj, hits, alongMomentum));
224 
225  if ((maxSeeds_ > 0) && (output.size() > size_t(maxSeeds_))) {
226  edm::LogError("TooManySeeds") << "Found too many seeds, bailing out.\n";
227  output.clear();
228  return false;
229  }
230 
231  } else
232  edm::LogWarning("CosmicSeedFinder") << " SeedForCosmics first update failed ";
233  } else
234  edm::LogWarning("CosmicSeedFinder") << " SeedForCosmics first propagation failed ";
235 
236  } else {
238  outer, (outer - inner) * (seedpt / (outer - inner).mag()), predsign, &(*magfield));
240  LogDebug("CosmicSeedFinder") << " FirstTSOS " << CosmicSeed;
241  //First propagation
242  const TSOS outerState = thePropagatorAl->propagate(
243  CosmicSeed, tracker->idToDet((*(HitPairs[is].outer())).geographicalId())->surface());
244  if (outerState.isValid()) {
245  LogDebug("CosmicSeedFinder") << "outerState " << outerState;
246  const TSOS outerUpdated = theUpdator->update(outerState, *outrhit);
247  if (outerUpdated.isValid()) {
248  LogDebug("CosmicSeedFinder") << "outerUpdated " << outerUpdated;
249 
251  outerUpdated, (*(HitPairs[is].outer())).geographicalId().rawId());
252 
253  output.push_back(TrajectorySeed(PTraj, hits, oppositeToMomentum));
254 
255  if ((maxSeeds_ > 0) && (output.size() > size_t(maxSeeds_))) {
256  edm::LogError("TooManySeeds") << "Found too many seeds, bailing out.\n";
257  output.clear();
258  return false;
259  }
260 
261  } else
262  edm::LogWarning("CosmicSeedFinder") << " SeedForCosmics first update failed ";
263  } else
264  edm::LogWarning("CosmicSeedFinder") << " SeedForCosmics first propagation failed ";
265  }
266  }
267  }
268  return true;
269 }
Vector3DBase
Definition: Vector3DBase.h:8
TrackerGeometry::idToDet
const TrackerGeomDet * idToDet(DetId) const override
Definition: TrackerGeometry.cc:193
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
SeedGeneratorForCosmics::magfield
edm::ESHandle< MagneticField > magfield
Definition: SeedGeneratorForCosmics.h:44
SeedGeneratorForCosmics::init
void init(const SiStripRecHit2DCollection &collstereo, const SiStripRecHit2DCollection &collrphi, const SiStripMatchedRecHit2DCollection &collmatched, const edm::EventSetup &c)
Definition: SeedGeneratorForCosmics.cc:7
KFUpdator::update
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const override
Definition: KFUpdator.cc:177
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
SeedGeneratorForCosmics::run
void run(TrajectorySeedCollection &, const edm::EventSetup &c)
Definition: SeedGeneratorForCosmics.cc:66
CosmicLayerTriplets.h
TrajectorySeedCollection
std::vector< TrajectorySeed > TrajectorySeedCollection
Definition: TrajectorySeedCollection.h:6
FastHelix.h
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
PropagatorWithMaterial::propagate
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
FastHelix
Definition: FastHelix.h:26
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
SeedGeneratorForCosmics::tracker
edm::ESHandle< TrackerGeometry > tracker
Definition: SeedGeneratorForCosmics.h:45
trajectoryStateTransform::persistentState
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
Definition: TrajectoryStateTransform.cc:14
TransientRecHitRecord.h
geometry
Definition: geometry.py:1
SeedingHitSet::ConstRecHitPointer
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:10
TransientRecHitRecord
Definition: TransientRecHitRecord.h:14
oppositeToMomentum
Definition: PropagationDirection.h:4
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
CosmicLayerTriplets
Definition: CosmicLayerTriplets.h:24
GlobalTrackingRegion
Definition: GlobalTrackingRegion.h:13
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
AlgebraicMatrixID
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
Definition: AlgebraicROOTObjects.h:72
SeedGeneratorForCosmics::thePairGenerator
CosmicHitPairGenerator * thePairGenerator
Definition: SeedGeneratorForCosmics.h:42
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
PropagatorWithMaterial
Definition: PropagatorWithMaterial.h:25
SeedGeneratorForCosmics::thePropagatorAl
PropagatorWithMaterial * thePropagatorAl
Definition: SeedGeneratorForCosmics.h:48
SeedGeneratorForCosmics::region
GlobalTrackingRegion region
Definition: SeedGeneratorForCosmics.h:41
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
CurvilinearTrajectoryError
Definition: CurvilinearTrajectoryError.h:27
SeedGeneratorForCosmics.h
SeedGeneratorForCosmics::HitTriplets
OrderedHitTriplets HitTriplets
Definition: SeedGeneratorForCosmics.h:56
SeedGeneratorForCosmics::thePropagatorOp
PropagatorWithMaterial * thePropagatorOp
Definition: SeedGeneratorForCosmics.h:49
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
SeedGeneratorForCosmics::theTripletGenerator
CosmicHitTripletGenerator * theTripletGenerator
Definition: SeedGeneratorForCosmics.h:43
SurfaceOrientation::inner
Definition: Surface.h:19
SeedGeneratorForCosmics::positiveYOnly
bool positiveYOnly
Definition: SeedGeneratorForCosmics.h:59
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
edm::ESHandle< TransientTrackingRecHitBuilder >
MagneticField::nominalValue
int nominalValue() const
The nominal field value for this map in kGauss.
Definition: MagneticField.h:49
CommonMethods.isnan
def isnan(num)
Definition: CommonMethods.py:98
GlobalTrajectoryParameters
Definition: GlobalTrajectoryParameters.h:15
Point3DBase< float, GlobalTag >
SeedGeneratorForCosmics::negativeYOnly
bool negativeYOnly
Definition: SeedGeneratorForCosmics.h:60
SeedGeneratorForCosmics::seeds
bool seeds(TrajectorySeedCollection &output, const edm::EventSetup &c, const TrackingRegion &region)
Definition: SeedGeneratorForCosmics.cc:74
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
SeedGeneratorForCosmics::hitsforseeds
std::string hitsforseeds
Definition: SeedGeneratorForCosmics.h:53
CosmicLayerPairs::init
void init(const SiStripRecHit2DCollection &collstereo, const SiStripRecHit2DCollection &collrphi, const SiStripMatchedRecHit2DCollection &collmatched, const edm::EventSetup &iSetup)
Definition: CosmicLayerPairs.cc:239
SeedGeneratorForCosmics::builderName
std::string builderName
Definition: SeedGeneratorForCosmics.h:51
SeedGeneratorForCosmics::maxSeeds_
int32_t maxSeeds_
Definition: SeedGeneratorForCosmics.h:40
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88271
CosmicLayerTriplets::init
void init(const SiStripRecHit2DCollection &collstereo, const SiStripRecHit2DCollection &collrphi, const SiStripMatchedRecHit2DCollection &collmatched, std::string geometry, const edm::EventSetup &iSetup)
Definition: CosmicLayerTriplets.cc:56
OrderedHitTriplets::size
unsigned int size() const override
Definition: OrderedHitTriplets.h:13
edm::EventSetup
Definition: EventSetup.h:58
CosmicLayerPairs
Definition: CosmicLayerPairs.h:19
SeedGeneratorForCosmics::theUpdator
KFUpdator * theUpdator
Definition: SeedGeneratorForCosmics.h:47
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
get
#define get
SeedGeneratorForCosmics::seedpt
float seedpt
Definition: SeedGeneratorForCosmics.h:54
CosmicHitTripletGenerator::hitTriplets
void hitTriplets(const TrackingRegion &reg, OrderedHitTriplets &prs, const edm::EventSetup &iSetup)
Definition: CosmicHitTripletGenerator.cc:34
CosmicLayerPairs.h
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
edmNew::DetSetVector
Definition: DetSetNew.h:13
CosmicHitTripletGenerator
Definition: CosmicHitTripletGenerator.h:19
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
SeedGeneratorForCosmics::SeedGeneratorForCosmics
SeedGeneratorForCosmics(const edm::ParameterSet &conf)
Definition: SeedGeneratorForCosmics.cc:44
CosmicHitPairGenerator
Definition: CosmicHitPairGenerator.h:17
SeedGeneratorForCosmics::HitPairs
OrderedHitPairs HitPairs
Definition: SeedGeneratorForCosmics.h:55
ptmin
double ptmin
Definition: HydjetWrapper.h:84
TrajectorySeed
Definition: TrajectorySeed.h:18
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
OrderedHitPairs::size
unsigned int size() const override
Definition: OrderedHitPairs.h:12
TrackingRegion
Definition: TrackingRegion.h:41
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
SurfaceOrientation::outer
Definition: Surface.h:19
AlgebraicSymMatrix55
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
Definition: AlgebraicROOTObjects.h:23
alongMomentum
Definition: PropagationDirection.h:4
CosmicHitPairGenerator::hitPairs
void hitPairs(const TrackingRegion &reg, OrderedHitPairs &prs, const edm::EventSetup &iSetup)
form base class
Definition: CosmicHitPairGenerator.cc:25
KFUpdator
Definition: KFUpdator.h:32
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
hit
Definition: SiStripHitEffFromCalibTree.cc:88
edm::OwnVector< TrackingRecHit >
SeedGeneratorForCosmics::TTTRHBuilder
const TransientTrackingRecHitBuilder * TTTRHBuilder
Definition: SeedGeneratorForCosmics.h:50