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>>();
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));
176 if (
layers.numberOfLayersInSet() != 3)
178 <<
"You are using " <<
layers.numberOfLayersInSet() <<
" layers in set instead of 3 ";
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);
338 <<
", detid = " <<
hit.geographicalId().rawId() <<
", firstStrip = " << clust->
firstStrip() << std::endl;
341 <<
", detid = " <<
hit.geographicalId().rawId() <<
", firstStrip = " << clust->
firstStrip() << std::endl;
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;
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();
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;
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;
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 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;
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;
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;
560 hits.push_back(newtth);
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_
T getParameter(std::string const &) const
uint16_t firstStrip() const
void init(const edm::EventSetup &c)
CartesianTrajectoryError cartesianError() const
SiStripRecHit2D stereoHit() const
size_t tooManyClusters(const edm::Event &e) const
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
bool checkCharge(const TrackingRecHit *hit) const
bool checkMaxHitsPerModule_
const TrackerGeometry * tracker
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
unsigned short LayerSetIndex
OrderedHitTriplets hitTriplets
Global3DPoint GlobalPoint
std::pair< GlobalVector, int > pqFromHelixFit(const GlobalPoint &inner, const GlobalPoint &middle, const GlobalPoint &outer) const
auto const * begin() const
bool seeds(TrajectorySeedCollection &output)
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
Log< level::Error, false > LogError
SimpleCosmicBONSeeder(const edm::ParameterSet &conf)
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
MiddleRecHit middle() const
std::vector< TrajectorySeed > TrajectorySeedCollection
SiStripCluster const & amplitudes() const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
float ptMin() const
minimal pt of interest
bool triplets(const edm::Event &e)
PropagatorWithMaterial * thePropagatorOp
void checkNoisyModules(const std::vector< SeedingHitSet::ConstRecHitPointer > &hits, std::vector< bool > &oks) const
bool goodTriplet(const GlobalPoint &inner, const GlobalPoint &middle, const GlobalPoint &outer, const double &minRho) const
uint32_t tripletsVerbosity_
Abs< T >::type abs(const T &t)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
static constexpr auto TOB
const MagneticField * magfield
const TrackerGeomDet * idToDet(DetId) const override
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
PropagatorWithMaterial * thePropagatorAl
virtual TrackingRecHit * clone() const =0
TrajectoryStateOnSurface TSOS
void rescaleError(double factor)
static constexpr auto TIB
constexpr uint32_t rawId() const
get the raw id
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerToken_
OuterRecHit outer() const
void produce(edm::Event &e, const edm::EventSetup &c) override
const AlgebraicSymMatrix66 & matrix() const
SeedingHitSet::ConstRecHitPointer SeedingHit
InnerRecHit inner() const
SiStripRecHit2D monoHit() const
virtual TrackingRecHit const * hit() const
std::vector< int32_t > chargeThresholds_
int nominalValue() const
The nominal field value for this map in kGauss.
std::vector< int32_t > maxHitsPerModule_
const edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > ttrhBuilderToken_
static constexpr auto TID
unsigned int size() const override
bool operator()(const OrderedHitTriplet &trip1, const OrderedHitTriplet &trip2) const
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magfieldToken_
Global3DVector GlobalVector