28 writeTriplets_(conf.getParameter<
bool>(
"writeTriplets")),
29 seedOnMiddle_(conf.existsAs<
bool>(
"seedOnMiddle") ? conf.getParameter<
bool>(
"seedOnMiddle") :
false),
30 rescaleError_(conf.existsAs<double>(
"rescaleError") ? conf.getParameter<double>(
"rescaleError") : 1.0),
31 tripletsVerbosity_(conf.getUntrackedParameter<uint32_t>(
"TripletsDebugLevel", 0)),
32 seedVerbosity_(conf.getUntrackedParameter<uint32_t>(
"seedDebugLevel", 0)),
33 helixVerbosity_(conf.getUntrackedParameter<uint32_t>(
"helixDebugLevel", 0)),
34 check_(conf.getParameter<
edm::
ParameterSet>(
"ClusterCheckPSet"), consumesCollector()),
35 maxTriplets_(conf.getParameter<int32_t>(
"maxTriplets")),
36 maxSeeds_(conf.getParameter<int32_t>(
"maxSeeds")) {
39 float originradius = regionConf.
getParameter<
double>(
"originRadius");
40 float halflength = regionConf.
getParameter<
double>(
"originHalfLength");
41 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());
152 float iy1 = ihit1->globalPosition().y();
153 float oy1 = ohit1->globalPosition().y();
154 float iy2 = ihit2->globalPosition().y();
155 float oy2 = ohit2->globalPosition().y();
159 return (iy1 != iy2 ? (iy1 > iy2) : (oy1 > oy2));
162 }
else if (oy2 - iy2 > 0) {
166 return (iy1 != iy2 ? (iy1 < iy2) : (oy1 < oy2));
177 if (
layers.numberOfLayersInSet() != 3)
179 <<
"You are using " <<
layers.numberOfLayersInSet() <<
" layers in set instead of 3 ";
191 std::cout <<
"GenericTripletGenerator iLss = " << seedingLayersToString(
ls) <<
" (" << layerIndex
192 <<
"): # = " << innerHits.size() <<
"/" << middleHits.size() <<
"/" << outerHits.size() << std::endl;
197 std::vector<TTRH> innerTTRHs, middleTTRHs, outerTTRHs;
200 std::vector<bool> innerOk(innerHits.size(),
true);
201 std::vector<bool> middleOk(middleHits.size(),
true);
202 std::vector<bool> outerOk(outerHits.size(),
true);
207 for (
auto iOuterHit = outerHits.begin(); iOuterHit != outerHits.end(); ++
idx, ++iOuterHit) {
208 outerTTRHs.push_back(&(**iOuterHit));
210 outerOk[
idx] =
false;
213 for (
auto iMiddleHit = middleHits.begin(); iMiddleHit != middleHits.end(); ++
idx, ++iMiddleHit) {
214 middleTTRHs.push_back(&(**iMiddleHit));
216 middleOk[
idx] =
false;
219 for (
auto iInnerHit = innerHits.begin(); iInnerHit != innerHits.end(); ++
idx, ++iInnerHit) {
220 innerTTRHs.push_back(&(**iInnerHit));
222 innerOk[
idx] =
false;
230 for (
auto iOuterHit = outerHits.begin(); iOuterHit != outerHits.end(); iOuterHit++) {
231 idx = iOuterHit - outerHits.begin();
232 TTRH &outerTTRH = outerTTRHs[
idx];
233 GlobalPoint outerpos = outerTTRH->globalPosition();
234 bool outerok = outerOk[
idx];
241 for (
auto iMiddleHit = middleHits.begin(); iMiddleHit != middleHits.end(); iMiddleHit++) {
242 idx = iMiddleHit - middleHits.begin();
243 TTRH &middleTTRH = middleTTRHs[
idx];
244 GlobalPoint middlepos = middleTTRH->globalPosition();
245 bool middleok = middleOk[
idx];
253 for (
auto iInnerHit = innerHits.begin(); iInnerHit != innerHits.end(); iInnerHit++) {
254 idx = iInnerHit - innerHits.begin();
255 TTRH &innerTTRH = innerTTRHs[
idx];
256 GlobalPoint innerpos = innerTTRH->globalPosition();
257 bool innerok = innerOk[
idx];
267 (innerpos.
y() < 0 || middlepos.
y() < 0 || outerpos.
y() < 0 || outerpos.
y() < innerpos.
y()))
270 (innerpos.
y() > 0 || middlepos.
y() > 0 || outerpos.
y() > 0 || outerpos.
y() > innerpos.
y()))
275 std::cout <<
"Trying seed with: " << innerpos <<
" + " << middlepos <<
" + " << outerpos << std::endl;
276 if (
goodTriplet(innerpos, middlepos, outerpos, minRho)) {
282 edm::LogError(
"TooManyTriplets") <<
"Found too many triplets, bailing out.\n";
287 <<
" + " << outerpos << std::endl;
291 <<
" + " << outerpos << std::endl;
301 std::cout <<
" iLss = " << seedingLayersToString(
ls) <<
" (" << layerIndex
302 <<
"): # = " << innerHits.size() <<
"/" << middleHits.size() <<
"/" << outerHits.size() <<
": Found "
326 return checkCharge(static_cast<const SiStripRecHit2D &>(*
hit), subdet);
339 <<
", detid = " <<
hit.geographicalId().rawId() <<
", firstStrip = " << clust->
firstStrip() << std::endl;
342 <<
", detid = " <<
hit.geographicalId().rawId() <<
", firstStrip = " << clust->
firstStrip() << std::endl;
348 std::vector<bool> &oks)
const {
350 std::vector<TTRH>::const_iterator it =
hits.begin(),
start = it,
end =
hits.end();
351 std::vector<bool>::iterator
ok = oks.begin(), okStart =
ok;
353 DetId lastid = (*start)->geographicalId();
354 for (it =
start + 1; (it <
end) && ((*it)->geographicalId() == lastid); ++it) {
359 std::cerr <<
"SimpleCosmicBONSeeder: Marking noisy module " << lastid.
rawId() <<
", it has " << (it -
start)
366 std::cerr <<
"SimpleCosmicBONSeeder: Not marking noisy module " << lastid.
rawId() <<
", it has " << (it -
start)
379 const double &minRho)
const {
380 float dyOM =
outer.y() - middle.
y(), dyIM =
inner.y() - middle.
y();
381 if ((dyOM * dyIM > 0) && (fabs(dyOM) > 10) && (fabs(dyIM) > 10)) {
383 std::cout <<
" fail for non coherent dy" << std::endl;
386 float dzOM =
outer.z() - middle.
z(), dzIM =
inner.z() - middle.
z();
387 if ((dzOM * dzIM > 0) && (fabs(dzOM) > 50) && (fabs(dzIM) > 50)) {
389 std::cout <<
" fail for non coherent dz" << std::endl;
394 if (theCircle.
rho() < minRho) {
396 std::cout <<
" fail for pt cut" << std::endl;
408 std::cout <<
"DEBUG PZ =====" << std::endl;
411 std::cout <<
"FastHelix P = " << gv <<
"\n";
412 std::cout <<
"FastHelix Q = " << helix.stateAtVertex().charge() <<
"\n";
418 double rho = theCircle.
rho();
422 double pt = 0.01 *
rho * (0.3 * tesla.
z());
425 double dx1 =
outer.x() - theCircle.
x0();
426 double dy1 =
outer.y() - theCircle.
y0();
435 double sinphi = (dx1 * (
inner.y() - theCircle.
y0()) - dy1 * (
inner.x() - theCircle.
x0())) / (
rho *
rho);
436 double dphi =
std::abs(std::asin(sinphi));
437 double pz =
pt *
dz / (dphi *
rho);
439 int myq = ((theCircle.
x0() *
py - theCircle.
y0() *
px) / tesla.
z()) > 0. ? +1 : -1;
445 std::cout <<
"Gio: dz = " <<
dz <<
", sinphi = " << sinphi <<
", dphi = " << dphi
446 <<
", dz/drphi = " << (
dz / dphi /
rho) << std::endl;
449 std::cout <<
"Gio's fit P = " << mypq.first <<
"\n";
450 std::cout <<
"Gio's fit Q = " << myq <<
"\n";
472 std::cout <<
"Processing triplet " << it <<
": " <<
inner <<
" + " << middle <<
" + " <<
outer << std::endl;
479 std::cout <<
"The seed was going away from CMS! swapped in <-> out" << std::endl;
480 std::cout <<
"Processing swapped triplet " << it <<
": " <<
inner <<
" + " << middle <<
" + " <<
outer
488 float ch = pq.second;
489 float Mom =
sqrt(gv.
x() * gv.
x() + gv.
y() * gv.
y() + gv.
z() * gv.
z());
493 std::cout <<
"Processing triplet " << it <<
": fail for momentum." << std::endl;
507 std::cout <<
"Processing triplet " << it <<
": downgoing." << std::endl;
514 std::cout <<
"Processing triplet " << it <<
": upgoing." << std::endl;
518 if ((gv.
z() * (
outer.z() -
inner.z()) > 0) && (fabs(
outer.z() -
inner.z()) > 5) && (fabs(gv.
z()) > .01)) {
519 std::cout <<
"ORRORE: outer.z()-inner.z() = " << (
outer.z() -
inner.z()) <<
", gv.z() = " << gv.
z()
528 std::cout <<
"Processing triplet " << it <<
". start from " << std::endl;
535 TSOS propagated, updated;
537 for (
size_t ih = 0; ih < 3; ++ih) {
540 std::cout <<
"Stopping at middle hit, as requested." << std::endl;
544 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
"." << std::endl;
550 if (!propagated.isValid()) {
552 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": failed propagation." << std::endl;
557 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": propagated state = " << propagated;
560 auto newtth = static_cast<SeedingHitSet::RecHitPointer>(
cloner(*tthp, propagated));
562 hits.push_back(newtth);
563 if (!updated.isValid()) {
565 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": failed update." << std::endl;
570 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": updated state = " << updated;
573 if (!fail && updated.isValid() && (updated.globalMomentum().perp() <
region_.
ptMin())) {
575 std::cout <<
"Processing triplet " << it <<
": failed for final pt " << updated.globalMomentum().perp() <<
" < "
579 if (!fail && updated.isValid() && (updated.globalMomentum().mag() <
pMin_)) {
581 std::cout <<
"Processing triplet " << it <<
": failed for final p " << updated.globalMomentum().perp() <<
" < "
582 <<
pMin_ << std::endl;
589 <<
": state BEFORE rescaling " << updated;
590 std::cout <<
" Cartesian error (X,P) before rescaling= \n"
591 << updated.cartesianError().matrix() << std::endl;
596 std::cout <<
"Processed triplet " << it <<
": success (saved as #" <<
output.size() <<
") : " <<
inner <<
" + "
597 << middle <<
" + " <<
outer << std::endl;
598 std::cout <<
" pt = " << updated.globalMomentum().perp() <<
" eta = " << updated.globalMomentum().eta()
599 <<
" phi = " << updated.globalMomentum().phi() <<
" ch = " << updated.charge() << std::endl;
603 std::cout <<
" X = " << updated.globalPosition() <<
", P = " << updated.globalMomentum() << std::endl;
605 std::cout <<
" Cartesian error (X,P) = \n" << updated.cartesianError().matrix() << std::endl;
613 edm::LogError(
"TooManySeeds") <<
"Found too many seeds, bailing out.\n";