CMS 3D CMS Logo

CtfSpecialSeedGenerator.cc
Go to the documentation of this file.
6 
12 
15 
16 using namespace ctfseeding;
17 
19  : conf_(conf),
20  requireBOFF(conf.getParameter<bool>("requireBOFF")),
21  theMaxSeeds(conf.getParameter<int32_t>("maxSeeds")),
22  check(conf, consumesCollector())
23 
24 {
25  useScintillatorsConstraint = conf_.getParameter<bool>("UseScintillatorsConstraint");
26  edm::LogVerbatim("CtfSpecialSeedGenerator") << "Constructing CtfSpecialSeedGenerator";
27  produces<TrajectorySeedCollection>();
28 
29  edm::ParameterSet regfactoryPSet = conf_.getParameter<edm::ParameterSet>("RegionFactoryPSet");
30  std::string regfactoryName = regfactoryPSet.getParameter<std::string>("ComponentName");
31  theRegionProducer = std::unique_ptr<TrackingRegionProducer>{
32  TrackingRegionProducerFactory::get()->create(regfactoryName, regfactoryPSet, consumesCollector())};
33 
34  std::vector<edm::ParameterSet> pSets = conf_.getParameter<std::vector<edm::ParameterSet>>("OrderedHitsFactoryPSets");
35  std::vector<edm::ParameterSet>::const_iterator iPSet;
36  edm::ConsumesCollector iC = consumesCollector();
37  for (iPSet = pSets.begin(); iPSet != pSets.end(); iPSet++) {
38  std::string hitsfactoryName = iPSet->getParameter<std::string>("ComponentName");
39  theGenerators.emplace_back(OrderedHitsGeneratorFactory::get()->create(hitsfactoryName, *iPSet, iC));
40  }
41 }
42 
44 
46 
48  std::string builderName = conf_.getParameter<std::string>("TTRHBuilder");
49  iSetup.get<TransientRecHitRecord>().get(builderName, theBuilder);
50 
53 
54  edm::LogVerbatim("CtfSpecialSeedGenerator") << "Initializing...";
56  edm::ParameterSet upperScintPar = conf_.getParameter<edm::ParameterSet>("UpperScintillatorParameters");
57  edm::ParameterSet lowerScintPar = conf_.getParameter<edm::ParameterSet>("LowerScintillatorParameters");
58  RectangularPlaneBounds upperBounds(
59  upperScintPar.getParameter<double>("WidthInX"), upperScintPar.getParameter<double>("LenghtInZ"), 1);
60  GlobalPoint upperPosition(upperScintPar.getParameter<double>("GlobalX"),
61  upperScintPar.getParameter<double>("GlobalY"),
62  upperScintPar.getParameter<double>("GlobalZ"));
63  edm::LogVerbatim("CtfSpecialSeedGenerator") << "Upper Scintillator position x, y, z " << upperPosition.x() << ", "
64  << upperPosition.y() << ", " << upperPosition.z();
65  RectangularPlaneBounds lowerBounds(
66  lowerScintPar.getParameter<double>("WidthInX"), lowerScintPar.getParameter<double>("LenghtInZ"), 1);
67  GlobalPoint lowerPosition(lowerScintPar.getParameter<double>("GlobalX"),
68  lowerScintPar.getParameter<double>("GlobalY"),
69  lowerScintPar.getParameter<double>("GlobalZ"));
70  edm::LogVerbatim("CtfSpecialSeedGenerator") << "Lower Scintillator position x, y, z " << lowerPosition.x() << ", "
71  << lowerPosition.y() << ", " << lowerPosition.z();
72  TkRotation<float> rot(1, 0, 0, 0, 0, 1, 0, 1, 0);
73  upperScintillator = BoundPlane::build(upperPosition, rot, &upperBounds);
74  lowerScintillator = BoundPlane::build(lowerPosition, rot, &lowerBounds);
75  }
76 
77  edm::ESHandle<Propagator> propagatorAlongHandle;
78  iSetup.get<TrackingComponentsRecord>().get("PropagatorWithMaterial", propagatorAlongHandle);
79  edm::ESHandle<Propagator> propagatorOppositeHandle;
80  iSetup.get<TrackingComponentsRecord>().get("PropagatorWithMaterialOpposite", propagatorOppositeHandle);
81 
82  std::vector<edm::ParameterSet> pSets = conf_.getParameter<std::vector<edm::ParameterSet>>("OrderedHitsFactoryPSets");
83  std::vector<edm::ParameterSet>::const_iterator iPSet;
84  for (iPSet = pSets.begin(); iPSet != pSets.end(); iPSet++) {
85  std::string propagationDirection = iPSet->getParameter<std::string>("PropagationDirection");
86  if (propagationDirection == "alongMomentum")
87  thePropDirs.push_back(alongMomentum);
88  else
90  std::string navigationDirection = iPSet->getParameter<std::string>("NavigationDirection");
91  if (navigationDirection == "insideOut")
92  theNavDirs.push_back(insideOut);
93  else
94  theNavDirs.push_back(outsideIn);
95  edm::LogVerbatim("CtfSpecialSeedGenerator") << "hitsGenerator done";
96  }
97  bool setMomentum = conf_.getParameter<bool>("SetMomentum");
98  std::vector<int> charges;
99  if (setMomentum) {
100  charges = conf_.getParameter<std::vector<int>>("Charges");
101  }
102  theSeedBuilder = std::make_unique<SeedFromGenericPairOrTriplet>(theMagfield.product(),
105  propagatorAlongHandle.product(),
106  propagatorOppositeHandle.product(),
107  charges,
108  setMomentum,
109  conf_.getParameter<double>("ErrorRescaling"));
110  double p = 1;
111  if (setMomentum) {
112  p = conf_.getParameter<double>("SeedMomentum");
113  theSeedBuilder->setMomentumTo(p);
114  }
115 }
116 
118  // get Inputs
119  auto output = std::make_unique<TrajectorySeedCollection>();
120 
121  //check on the number of clusters
122  if (!requireBOFF || (theMagfield->inTesla(GlobalPoint(0, 0, 0)).mag() == 0.00)) {
123  size_t clustsOrZero = check.tooManyClusters(e);
124  if (!clustsOrZero) {
125  bool ok = run(iSetup, e, *output);
126  if (!ok) {
127  } // nothing to do
128  } else
129  edm::LogError("TooManyClusters") << "Found too many clusters (" << clustsOrZero << "), bailing out.\n";
130  }
131 
132  edm::LogVerbatim("CtfSpecialSeedGenerator") << " number of seeds = " << output->size();
133  e.put(std::move(output));
134 }
135 
137  const edm::Event& e,
139  std::vector<std::unique_ptr<TrackingRegion>> regions = theRegionProducer->regions(e, iSetup);
140  bool ok = true;
141  for (auto iReg = regions.begin(); iReg != regions.end(); iReg++) {
142  if (!theSeedBuilder->momentumFromPSet())
143  theSeedBuilder->setMomentumTo((*iReg)->ptMin());
144  int i = 0;
145  for (auto iGen = theGenerators.begin(); iGen != theGenerators.end(); iGen++) {
146  ok = buildSeeds(iSetup, e, (*iGen)->run(**iReg, e, iSetup), theNavDirs[i], thePropDirs[i], output);
147  i++;
148  if (!ok)
149  break;
150  }
151  if (!ok)
152  break;
153  }
154  return ok;
155 }
156 
158  const edm::Event& e,
159  const OrderedSeedingHits& osh,
160  const NavigationDirection& navdir,
161  const PropagationDirection& dir,
163  //SeedFromGenericPairOrTriplet seedBuilder(conf_, magfield.product(), tracker.product(), theBuilder.product());
164  edm::LogInfo("CtfSpecialSeedGenerator") << "osh.size() " << osh.size();
165  for (unsigned int i = 0; i < osh.size(); i++) {
166  SeedingHitSet shs = osh[i];
167  if (preliminaryCheck(shs, iSetup)) {
168  std::vector<TrajectorySeed*> seeds = theSeedBuilder->seed(shs, dir, navdir, iSetup);
169  for (std::vector<TrajectorySeed*>::const_iterator iSeed = seeds.begin(); iSeed != seeds.end(); iSeed++) {
170  if (!*iSeed) {
171  edm::LogError("CtfSpecialSeedGenerator") << "a seed pointer is null. skipping.";
172  continue;
173  }
174  if (postCheck(**iSeed)) {
175  output.push_back(**iSeed);
176  }
177  delete *iSeed;
178  edm::LogVerbatim("CtfSpecialSeedGenerator") << "Seed built";
179  }
180  }
181  }
182  if ((theMaxSeeds > 0) && (output.size() > size_t(theMaxSeeds))) {
183  edm::LogWarning("TooManySeeds") << "Too many seeds (" << output.size() << "), bailing out.\n";
184  output.clear();
185  return false;
186  }
187  return true;
188 }
189 //checks the hits are on diffrent layers
192  es.get<TrackerTopologyRcd>().get(tTopo);
193 
194  std::vector<std::pair<unsigned int, unsigned int>> vSubdetLayer;
195  //std::vector<std::string> vSeedLayerNames;
196  bool checkHitsAtPositiveY = conf_.getParameter<bool>("SeedsFromPositiveY");
197  //***top-bottom
198  bool checkHitsAtNegativeY = conf_.getParameter<bool>("SeedsFromNegativeY");
199  //***
200  bool checkHitsOnDifferentLayers = conf_.getParameter<bool>("CheckHitsAreOnDifferentLayers");
201  unsigned int nHits = shs.size();
202  for (unsigned int iHit = 0; iHit < nHits; ++iHit) {
203  //hits for the seeds must be at positive y
204  auto trh = shs[iHit];
205  auto recHit = trh;
206  GlobalPoint hitPos = recHit->globalPosition();
207  //GlobalPoint point =
208  // theTracker->idToDet(iHits->geographicalId() )->surface().toGlobal(iHits->localPosition());
209  if (checkHitsAtPositiveY) {
210  if (hitPos.y() < 0)
211  return false;
212  }
213  //***top-bottom
214  if (checkHitsAtNegativeY) {
215  if (hitPos.y() > 0)
216  return false;
217  }
218  //***
219  //std::string name = iHits->seedinglayer().name();
220  //hits for the seeds must be in different layers
221  unsigned int subid = (*trh).geographicalId().subdetId();
222  unsigned int layer = tTopo->layer((*trh).geographicalId());
223  std::vector<std::pair<unsigned int, unsigned int>>::const_iterator iter;
224  //std::vector<std::string>::const_iterator iNames;
225  if (checkHitsOnDifferentLayers) {
226  for (iter = vSubdetLayer.begin(); iter != vSubdetLayer.end(); iter++) {
227  if (iter->first == subid && iter->second == layer)
228  return false;
229  }
230  /*
231  for (iNames = vSeedLayerNames.begin(); iNames != vSeedLayerNames.end(); iNames++){
232  if (*iNames == name) return false;
233  }
234  */
235  }
236  //vSeedLayerNames.push_back(iHits->seedinglayer().name());
237  vSubdetLayer.push_back(std::make_pair(subid, layer));
238  }
239  return true;
240 }
241 
244  return true;
245 
246  PTrajectoryStateOnDet pstate = seed.startingState();
248  pstate, &(theTracker->idToDet(DetId(pstate.detId()))->surface()), &(*theMagfield));
249  const FreeTrajectoryState* state = theTSOS.freeState();
250  StraightLinePlaneCrossing planeCrossingLower(
251  Basic3DVector<float>(state->position()), Basic3DVector<float>(state->momentum()), alongMomentum);
252  StraightLinePlaneCrossing planeCrossingUpper(
253  Basic3DVector<float>(state->position()), Basic3DVector<float>(state->momentum()), oppositeToMomentum);
254  std::pair<bool, StraightLinePlaneCrossing::PositionType> positionUpper =
255  planeCrossingUpper.position(*upperScintillator);
256  std::pair<bool, StraightLinePlaneCrossing::PositionType> positionLower =
257  planeCrossingLower.position(*lowerScintillator);
258  if (!(positionUpper.first && positionLower.first)) {
259  edm::LogVerbatim("CtfSpecialSeedGenerator::checkDirection") << "Scintillator plane not crossed";
260  return false;
261  }
262  LocalPoint positionUpperLocal = upperScintillator->toLocal((GlobalPoint)(positionUpper.second));
263  LocalPoint positionLowerLocal = lowerScintillator->toLocal((GlobalPoint)(positionLower.second));
264  if (upperScintillator->bounds().inside(positionUpperLocal) &&
265  lowerScintillator->bounds().inside(positionLowerLocal)) {
266  edm::LogVerbatim("CtfSpecialSeedGenerator::checkDirection")
267  << "position on Upper scintillator " << positionUpper.second;
268  edm::LogVerbatim("CtfSpecialSeedGenerator::checkDirection")
269  << "position on Lower scintillator " << positionLower.second;
270 
271  return true;
272  }
273  edm::LogVerbatim("CtfSpecialSeedGenerator::checkDirection")
274  << "scintillator not crossed in bounds: position on Upper scintillator " << positionUpper.second
275  << " position on Lower scintillator " << positionLower.second;
276  return false;
277 }
TrackerGeometry::idToDet
const TrackerGeomDet * idToDet(DetId) const override
Definition: TrackerGeometry.cc:193
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
OrderedSeedingHits.h
TkRotation< float >
CtfSpecialSeedGenerator::check
ClusterChecker check
Definition: CtfSpecialSeedGenerator.h:91
CosmicGenFilterHelix_cfi.charges
charges
only generated particles of these IDs are considered
Definition: CosmicGenFilterHelix_cfi.py:6
MagneticField::inTesla
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
CtfSpecialSeedGenerator::theGenerators
std::vector< std::unique_ptr< OrderedHitsGenerator > > theGenerators
Definition: CtfSpecialSeedGenerator.h:80
TrajectorySeedCollection
std::vector< TrajectorySeed > TrajectorySeedCollection
Definition: TrajectorySeedCollection.h:6
SeedingHitSet
Definition: SeedingHitSet.h:6
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
edm::Run
Definition: Run.h:45
CtfSpecialSeedGenerator::buildSeeds
bool buildSeeds(const edm::EventSetup &iSetup, const edm::Event &e, const OrderedSeedingHits &osh, const NavigationDirection &navdir, const PropagationDirection &dir, TrajectorySeedCollection &output)
Definition: CtfSpecialSeedGenerator.cc:157
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::LogInfo
Definition: MessageLogger.h:254
TransientRecHitRecord
Definition: TransientRecHitRecord.h:14
CtfSpecialSeedGenerator::theSeedBuilder
std::unique_ptr< SeedFromGenericPairOrTriplet > theSeedBuilder
Definition: CtfSpecialSeedGenerator.h:85
CtfSpecialSeedGenerator::useScintillatorsConstraint
bool useScintillatorsConstraint
Definition: CtfSpecialSeedGenerator.h:86
oppositeToMomentum
Definition: PropagationDirection.h:4
TrackerTopology::layer
unsigned int layer(const DetId &id) const
Definition: TrackerTopology.cc:47
CtfSpecialSeedGenerator::lowerScintillator
BoundPlane::BoundPlanePointer lowerScintillator
Definition: CtfSpecialSeedGenerator.h:88
CtfSpecialSeedGenerator::upperScintillator
BoundPlane::BoundPlanePointer upperScintillator
Definition: CtfSpecialSeedGenerator.h:87
beamerCreator.create
def create(alignables, pedeDump, additionalData, outputFile, config)
Definition: beamerCreator.py:44
newFWLiteAna.build
build
Definition: newFWLiteAna.py:126
CtfSpecialSeedGenerator::CtfSpecialSeedGenerator
CtfSpecialSeedGenerator(const edm::ParameterSet &conf)
Definition: CtfSpecialSeedGenerator.cc:18
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
TrackingRegionProducerFactory.h
DetId
Definition: DetId.h:17
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
TrackerTopology.h
RPCNoise_example.check
check
Definition: RPCNoise_example.py:71
PTrajectoryStateOnDet::detId
unsigned int detId() const
Definition: PTrajectoryStateOnDet.h:65
TrackerTopologyRcd.h
TrajectoryStateOnSurface::freeState
FreeTrajectoryState const * freeState(bool withErrors=true) const
Definition: TrajectoryStateOnSurface.h:58
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
CtfSpecialSeedGenerator::run
bool run(const edm::EventSetup &c, const edm::Event &e, TrajectorySeedCollection &output)
Definition: CtfSpecialSeedGenerator.cc:136
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
OrderedSeedingHits
Definition: OrderedSeedingHits.h:7
edm::ESHandle< Propagator >
RectangularPlaneBounds.h
Point3DBase< float, GlobalTag >
CtfSpecialSeedGenerator::theMaxSeeds
int32_t theMaxSeeds
Definition: CtfSpecialSeedGenerator.h:90
StraightLinePlaneCrossing.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
InitialStep_cff.seeds
seeds
Definition: InitialStep_cff.py:232
CtfSpecialSeedGenerator::postCheck
bool postCheck(const TrajectorySeed &seed)
Definition: CtfSpecialSeedGenerator.cc:242
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
OrderedSeedingHits::size
virtual unsigned int size() const =0
OrderedHitsGeneratorFactory.h
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
trajectoryStateTransform::transientState
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
Definition: TrajectoryStateTransform.cc:35
edm::LogVerbatim
Definition: MessageLogger.h:297
edm::EventSetup
Definition: EventSetup.h:57
ctfseeding
Definition: SeedingLayerSetsBuilder.h:23
get
#define get
CtfSpecialSeedGenerator::preliminaryCheck
bool preliminaryCheck(const SeedingHitSet &shs, const edm::EventSetup &es)
Definition: CtfSpecialSeedGenerator.cc:190
PV3DBase::mag
T mag() const
Definition: PV3DBase.h:64
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
CtfSpecialSeedGenerator::theMagfield
edm::ESHandle< MagneticField > theMagfield
Definition: CtfSpecialSeedGenerator.h:70
SeedingHitSet::size
unsigned int size() const
Definition: SeedingHitSet.h:41
eostools.move
def move(src, dest)
Definition: eostools.py:511
CtfSpecialSeedGenerator::theNavDirs
std::vector< NavigationDirection > theNavDirs
Definition: CtfSpecialSeedGenerator.h:82
RectangularPlaneBounds
Definition: RectangularPlaneBounds.h:12
CtfSpecialSeedGenerator.h
NavigationDirection
NavigationDirection
Definition: NavigationDirection.h:4
outsideIn
Definition: NavigationDirection.h:4
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
PropagationDirection
PropagationDirection
Definition: PropagationDirection.h:4
CtfSpecialSeedGenerator::~CtfSpecialSeedGenerator
~CtfSpecialSeedGenerator() override
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
CtfSpecialSeedGenerator::requireBOFF
bool requireBOFF
Definition: CtfSpecialSeedGenerator.h:89
CtfSpecialSeedGenerator::produce
void produce(edm::Event &e, const edm::EventSetup &c) override
Definition: CtfSpecialSeedGenerator.cc:117
TrajectorySeed
Definition: TrajectorySeed.h:17
insideOut
Definition: NavigationDirection.h:4
StraightLinePlaneCrossing::position
PositionType position(float s) const
Definition: StraightLinePlaneCrossing.h:42
AlignmentPI::regions
regions
Definition: AlignmentPayloadInspectorHelper.h:76
ConsumesCollector.h
TrackingRegion.h
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
CombinatorialSeedGeneratorForBeamHalo_cfi.requireBOFF
requireBOFF
Definition: CombinatorialSeedGeneratorForBeamHalo_cfi.py:100
edm::Event
Definition: Event.h:73
StraightLinePlaneCrossing
Definition: StraightLinePlaneCrossing.h:14
CtfSpecialSeedGenerator::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: CtfSpecialSeedGenerator.cc:47
ClusterChecker::tooManyClusters
size_t tooManyClusters(const edm::Event &e) const
Definition: ClusterChecker.cc:44
CtfSpecialSeedGenerator::endRun
void endRun(edm::Run const &, edm::EventSetup const &) override
Definition: CtfSpecialSeedGenerator.cc:45
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
alongMomentum
Definition: PropagationDirection.h:4
Basic3DVector< float >
SurveyInfoScenario_cff.seed
seed
Definition: SurveyInfoScenario_cff.py:295
CtfSpecialSeedGenerator::theTracker
edm::ESHandle< TrackerGeometry > theTracker
Definition: CtfSpecialSeedGenerator.h:71
CtfSpecialSeedGenerator::conf_
edm::ParameterSet conf_
Definition: CtfSpecialSeedGenerator.h:69
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
CtfSpecialSeedGenerator::theBuilder
edm::ESHandle< TransientTrackingRecHitBuilder > theBuilder
Definition: CtfSpecialSeedGenerator.h:72
CtfSpecialSeedGenerator::theRegionProducer
std::unique_ptr< TrackingRegionProducer > theRegionProducer
Definition: CtfSpecialSeedGenerator.h:83
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
CtfSpecialSeedGenerator::thePropDirs
std::vector< PropagationDirection > thePropDirs
Definition: CtfSpecialSeedGenerator.h:81
TrackingComponentsRecord
Definition: TrackingComponentsRecord.h:12