20 return layer[0].name() +
"+" + layer[1].name() +
"+" + layer[2].name();
30 writeTriplets_(conf.getParameter<bool>(
"writeTriplets")),
31 seedOnMiddle_(conf.existsAs<bool>(
"seedOnMiddle") ? conf.getParameter<bool>(
"seedOnMiddle") :
false),
32 rescaleError_(conf.existsAs<double>(
"rescaleError") ? conf.getParameter<double>(
"rescaleError") : 1.0),
33 tripletsVerbosity_(conf.getUntrackedParameter<uint32_t>(
"TripletsDebugLevel", 0)),
34 seedVerbosity_(conf.getUntrackedParameter<uint32_t>(
"seedDebugLevel", 0)),
35 helixVerbosity_(conf.getUntrackedParameter<uint32_t>(
"helixDebugLevel", 0)),
36 check_(conf.getParameter<edm::
ParameterSet>(
"ClusterCheckPSet"), consumesCollector()),
37 maxTriplets_(conf.getParameter<int32_t>(
"maxTriplets")),
38 maxSeeds_(conf.getParameter<int32_t>(
"maxSeeds")) {
41 float originradius = regionConf.
getParameter<
double>(
"originRadius");
42 float halflength = regionConf.
getParameter<
double>(
"originHalfLength");
43 float originz = regionConf.
getParameter<
double>(
"originZPosition");
52 produces<TrajectorySeedCollection>();
54 produces<edm::OwnVector<TrackingRecHit>>(
"cosmicTriplets");
90 auto output = std::make_unique<TrajectorySeedCollection>();
91 auto outtriplets = std::make_unique<edm::OwnVector<TrackingRecHit>>();
94 if (magfield->inTesla(
GlobalPoint(0, 0, 0)).mag() > 0.01) {
97 edm::LogError(
"TooManyClusters") <<
"Found too many clusters (" << clustsOrZero <<
"), bailing out.\n";
111 outtriplets->push_back(hit1->
clone());
112 outtriplets->push_back(hit2->
clone());
113 outtriplets->push_back(hit3->
clone());
151 float iy1 = ihit1->globalPosition().y();
152 float oy1 = ohit1->globalPosition().y();
153 float iy2 = ihit2->globalPosition().y();
154 float oy2 = ohit2->globalPosition().y();
158 return (iy1 != iy2 ? (iy1 > iy2) : (oy1 > oy2));
161 }
else if (oy2 - iy2 > 0) {
165 return (iy1 != iy2 ? (iy1 < iy2) : (oy1 < oy2));
190 std::cout <<
"GenericTripletGenerator iLss = " << seedingLayersToString(ls) <<
" (" << layerIndex
191 <<
"): # = " << innerHits.size() <<
"/" << middleHits.size() <<
"/" << outerHits.size() << std::endl;
196 std::vector<TTRH> innerTTRHs, middleTTRHs, outerTTRHs;
199 std::vector<bool> innerOk(innerHits.size(),
true);
200 std::vector<bool> middleOk(middleHits.size(),
true);
201 std::vector<bool> outerOk(outerHits.size(),
true);
206 for (
auto iOuterHit = outerHits.begin(); iOuterHit != outerHits.end(); ++idx, ++iOuterHit) {
207 outerTTRHs.push_back(&(**iOuterHit));
209 outerOk[idx] =
false;
212 for (
auto iMiddleHit = middleHits.begin(); iMiddleHit != middleHits.end(); ++idx, ++iMiddleHit) {
213 middleTTRHs.push_back(&(**iMiddleHit));
215 middleOk[idx] =
false;
218 for (
auto iInnerHit = innerHits.begin(); iInnerHit != innerHits.end(); ++idx, ++iInnerHit) {
219 innerTTRHs.push_back(&(**iInnerHit));
221 innerOk[idx] =
false;
229 for (
auto iOuterHit = outerHits.begin(); iOuterHit != outerHits.end(); iOuterHit++) {
230 idx = iOuterHit - outerHits.begin();
231 TTRH &outerTTRH = outerTTRHs[idx];
232 GlobalPoint outerpos = outerTTRH->globalPosition();
233 bool outerok = outerOk[idx];
240 for (
auto iMiddleHit = middleHits.begin(); iMiddleHit != middleHits.end(); iMiddleHit++) {
241 idx = iMiddleHit - middleHits.begin();
242 TTRH &middleTTRH = middleTTRHs[idx];
243 GlobalPoint middlepos = middleTTRH->globalPosition();
244 bool middleok = middleOk[idx];
252 for (
auto iInnerHit = innerHits.begin(); iInnerHit != innerHits.end(); iInnerHit++) {
253 idx = iInnerHit - innerHits.begin();
254 TTRH &innerTTRH = innerTTRHs[idx];
255 GlobalPoint innerpos = innerTTRH->globalPosition();
256 bool innerok = innerOk[idx];
266 (innerpos.
y() < 0 || middlepos.
y() < 0 || outerpos.
y() < 0 || outerpos.
y() < innerpos.
y()))
269 (innerpos.
y() > 0 || middlepos.
y() > 0 || outerpos.
y() > 0 || outerpos.
y() > innerpos.
y()))
274 std::cout <<
"Trying seed with: " << innerpos <<
" + " << middlepos <<
" + " << outerpos << std::endl;
275 if (
goodTriplet(innerpos, middlepos, outerpos, minRho)) {
281 edm::LogError(
"TooManyTriplets") <<
"Found too many triplets, bailing out.\n";
286 <<
" + " << outerpos << std::endl;
290 <<
" + " << outerpos << std::endl;
300 std::cout <<
" iLss = " << seedingLayersToString(ls) <<
" (" << layerIndex
301 <<
"): # = " << innerHits.size() <<
"/" << middleHits.size() <<
"/" << outerHits.size() <<
": Found "
325 return checkCharge(static_cast<const SiStripRecHit2D &>(*hit), subdet);
347 std::vector<bool> &oks)
const {
349 std::vector<TTRH>::const_iterator it = hits.begin(),
start = it,
end = hits.end();
350 std::vector<bool>::iterator
ok = oks.begin(), okStart =
ok;
351 while (
start < end) {
352 DetId lastid = (*start)->geographicalId();
353 for (it =
start + 1; (it <
end) && ((*it)->geographicalId() == lastid); ++it) {
358 std::cerr <<
"SimpleCosmicBONSeeder: Marking noisy module " << lastid.
rawId() <<
", it has " << (it -
start)
365 std::cerr <<
"SimpleCosmicBONSeeder: Not marking noisy module " << lastid.
rawId() <<
", it has " << (it -
start)
378 const double &minRho)
const {
379 float dyOM = outer.
y() - middle.
y(), dyIM = inner.
y() - middle.
y();
380 if ((dyOM * dyIM > 0) && (fabs(dyOM) > 10) && (fabs(dyIM) > 10)) {
382 std::cout <<
" fail for non coherent dy" << std::endl;
385 float dzOM = outer.
z() - middle.
z(), dzIM = inner.
z() - middle.
z();
386 if ((dzOM * dzIM > 0) && (fabs(dzOM) > 50) && (fabs(dzIM) > 50)) {
388 std::cout <<
" fail for non coherent dz" << std::endl;
393 if (theCircle.
rho() < minRho) {
395 std::cout <<
" fail for pt cut" << std::endl;
406 std::cout <<
"DEBUG PZ =====" << std::endl;
409 std::cout <<
"FastHelix P = " << gv <<
"\n";
410 std::cout <<
"FastHelix Q = " << helix.stateAtVertex().charge() <<
"\n";
416 double rho = theCircle.
rho();
420 double pt = 0.01 * rho * (0.3 * tesla.
z());
423 double dx1 = outer.
x() - theCircle.
x0();
424 double dy1 = outer.
y() - theCircle.
y0();
425 double py = pt * dx1 /
rho, px = -pt * dy1 /
rho;
426 if (px * (middle.
x() - outer.
x()) + py * (middle.
y() - outer.
y()) < 0.) {
432 double dz = inner.
z() - outer.
z();
433 double sinphi = (dx1 * (inner.
y() - theCircle.
y0()) - dy1 * (inner.
x() - theCircle.
x0())) / (rho *
rho);
434 double dphi =
std::abs(std::asin(sinphi));
435 double pz = pt * dz / (dphi *
rho);
437 int myq = ((theCircle.
x0() * py - theCircle.
y0() * px) / tesla.
z()) > 0. ? +1 : -1;
439 std::pair<GlobalVector, int> mypq(
GlobalVector(px, py, pz), myq);
442 std::cout <<
"Gio: pt = " << pt << std::endl;
443 std::cout <<
"Gio: dz = " << dz <<
", sinphi = " << sinphi <<
", dphi = " << dphi
444 <<
", dz/drphi = " << (dz / dphi /
rho) << std::endl;
447 std::cout <<
"Gio's fit P = " << mypq.first <<
"\n";
448 std::cout <<
"Gio's fit Q = " << myq <<
"\n";
470 std::cout <<
"Processing triplet " << it <<
": " << inner <<
" + " << middle <<
" + " << outer << std::endl;
472 if ((outer.
y() - inner.
y()) * outer.
y() < 0) {
477 std::cout <<
"The seed was going away from CMS! swapped in <-> out" << std::endl;
478 std::cout <<
"Processing swapped triplet " << it <<
": " << inner <<
" + " << middle <<
" + " << outer
484 std::pair<GlobalVector, int> pq =
pqFromHelixFit(inner, middle, outer);
486 float ch = pq.second;
487 float Mom =
sqrt(gv.
x() * gv.
x() + gv.
y() * gv.
y() + gv.
z() * gv.
z());
491 std::cout <<
"Processing triplet " << it <<
": fail for momentum." << std::endl;
503 if ((outer.
y() - inner.
y()) > 0) {
505 std::cout <<
"Processing triplet " << it <<
": downgoing." << std::endl;
512 std::cout <<
"Processing triplet " << it <<
": upgoing." << std::endl;
516 if ((gv.
z() * (outer.
z() - inner.
z()) > 0) && (fabs(outer.
z() - inner.
z()) > 5) && (fabs(gv.
z()) > .01)) {
517 std::cout <<
"ORRORE: outer.z()-inner.z() = " << (outer.
z() - inner.
z()) <<
", gv.z() = " << gv.
z()
526 std::cout <<
"Processing triplet " << it <<
". start from " << std::endl;
527 std::cout <<
" X = " << outer <<
", P = " << gv << std::endl;
533 TSOS propagated, updated;
535 for (
size_t ih = 0; ih < 3; ++ih) {
538 std::cout <<
"Stopping at middle hit, as requested." << std::endl;
542 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
"." << std::endl;
548 if (!propagated.isValid()) {
550 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": failed propagation." << std::endl;
555 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": propagated state = " << propagated;
561 if (!updated.isValid()) {
563 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": failed update." << std::endl;
568 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": updated state = " << updated;
571 if (!fail && updated.isValid() && (updated.globalMomentum().perp() <
region_.
ptMin())) {
573 std::cout <<
"Processing triplet " << it <<
": failed for final pt " << updated.globalMomentum().perp() <<
" < "
577 if (!fail && updated.isValid() && (updated.globalMomentum().mag() <
pMin_)) {
579 std::cout <<
"Processing triplet " << it <<
": failed for final p " << updated.globalMomentum().perp() <<
" < "
580 <<
pMin_ << std::endl;
587 <<
": state BEFORE rescaling " << updated;
588 std::cout <<
" Cartesian error (X,P) before rescaling= \n"
589 << updated.cartesianError().matrix() << std::endl;
594 std::cout <<
"Processed triplet " << it <<
": success (saved as #" << output.size() <<
") : " << inner <<
" + "
595 << middle <<
" + " << outer << std::endl;
596 std::cout <<
" pt = " << updated.globalMomentum().perp() <<
" eta = " << updated.globalMomentum().eta()
597 <<
" phi = " << updated.globalMomentum().phi() <<
" ch = " << updated.charge() << std::endl;
601 std::cout <<
" X = " << updated.globalPosition() <<
", P = " << updated.globalMomentum() << std::endl;
603 std::cout <<
" Cartesian error (X,P) = \n" << updated.cartesianError().matrix() << std::endl;
611 edm::LogError(
"TooManySeeds") <<
"Found too many seeds, bailing out.\n";
static constexpr auto TEC
GlobalTrackingRegion region_
unsigned short numberOfLayersInSet() const
Get number of layers in each SeedingLayerSets.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
void init(const edm::EventSetup &c)
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
CartesianTrajectoryError cartesianError() const
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
bool checkMaxHitsPerModule_
std::pair< GlobalVector, int > pqFromHelixFit(const GlobalPoint &inner, const GlobalPoint &middle, const GlobalPoint &outer) const
const TrackerGeometry * tracker
MiddleRecHit middle() const
int nominalValue() const
The nominal field value for this map in kGauss.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
constexpr bool isNotFinite(T x)
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
const edm::EDGetTokenT< SeedingLayerSetsHits > seedingLayerToken_
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
SiStripCluster const & amplitudes() const
unsigned short LayerSetIndex
OrderedHitTriplets hitTriplets
Global3DPoint GlobalPoint
constexpr uint32_t rawId() const
get the raw id
uint16_t firstStrip() const
bool seeds(TrajectorySeedCollection &output)
bool checkCharge(const TrackingRecHit *hit) const
Log< level::Error, false > LogError
constexpr std::array< uint8_t, layerIndexSize > layer
SimpleCosmicBONSeeder(const edm::ParameterSet &conf)
bool getData(T &iHolder) const
InnerRecHit inner() const
bool matchedRecHitUsesAnd_
BaseTrackerRecHit const * ConstRecHitPointer
TrackingRegion::Hits hits(const SeedingLayerSetsHits::SeedingLayer &layer) const override
get hits from layer compatible with region constraints
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const override
std::vector< TrajectorySeed > TrajectorySeedCollection
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
bool triplets(const edm::Event &e)
PropagatorWithMaterial * thePropagatorOp
size_t tooManyClusters(const edm::Event &e) const
uint32_t tripletsVerbosity_
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
Abs< T >::type abs(const T &t)
uint8_t const * begin() const
ClusterRef cluster() const
T const * get() const
Returns C++ pointer to the item.
static constexpr auto TOB
const MagneticField * magfield
const TrackerGeomDet * idToDet(DetId) const override
PropagatorWithMaterial * thePropagatorAl
const AlgebraicSymMatrix66 & matrix() const
virtual TrackingRecHit * clone() const =0
TrajectoryStateOnSurface TSOS
virtual TrackingRecHit const * hit() const
void rescaleError(double factor)
static constexpr auto TIB
SiStripRecHit2D stereoHit() const
void fill(std::map< std::string, TH1 * > &h, const std::string &s, double x)
T getParameter(std::string const &) const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
float ptMin() const
minimal pt of interest
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerToken_
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
bool goodTriplet(const GlobalPoint &inner, const GlobalPoint &middle, const GlobalPoint &outer, const double &minRho) const
SiStripRecHit2D monoHit() const
bool operator()(const OrderedHitTriplet &trip1, const OrderedHitTriplet &trip2) const
void produce(edm::Event &e, const edm::EventSetup &c) override
BaseTrackerRecHit const * SeedingHit
std::vector< int32_t > chargeThresholds_
void checkNoisyModules(const std::vector< SeedingHitSet::ConstRecHitPointer > &hits, std::vector< bool > &oks) const
std::vector< int32_t > maxHitsPerModule_
DetId geographicalId() const
OuterRecHit outer() const
const edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > ttrhBuilderToken_
static constexpr auto TID
unsigned short size() const
Get the number of SeedingLayerSets.
unsigned int size() const override
uint8_t const * end() const
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magfieldToken_
Global3DVector GlobalVector