20 return layer[0].name() +
"+" + layer[1].name() +
"+" + layer[2].name();
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"))
40 float originradius = regionConf.
getParameter<
double>(
"originRadius");
41 float halflength = regionConf.
getParameter<
double>(
"originHalfLength");
42 float originz = regionConf.
getParameter<
double>(
"originZPosition");
53 produces<TrajectorySeedCollection>();
54 if (
writeTriplets_) produces<edm::OwnVector<TrackingRecHit> >(
"cosmicTriplets");
92 auto output = std::make_unique<TrajectorySeedCollection>();
93 auto outtriplets = std::make_unique<edm::OwnVector<TrackingRecHit>>();
99 edm::LogError(
"TooManyClusters") <<
"Found too many clusters (" << clustsOrZero <<
"), bailing out.\n";
113 outtriplets->push_back(hit1->
clone());
114 outtriplets->push_back(hit2->
clone());
115 outtriplets->push_back(hit3->
clone());
157 float iy1 = ihit1->globalPosition().y();
158 float oy1 = ohit1->globalPosition().y();
159 float iy2 = ihit2->globalPosition().y();
160 float oy2 = ohit2->globalPosition().y();
164 return (iy1 != iy2 ? (iy1 > iy2) : (oy1 > oy2));
166 }
else if (oy2 - iy2 > 0) {
170 return (iy1 != iy2 ? (iy1 < iy2) : (oy1 < oy2));
194 std::cout <<
"GenericTripletGenerator iLss = " << seedingLayersToString(ls)
195 <<
" (" << layerIndex <<
"): # = " 196 << innerHits.size() <<
"/" << middleHits.size() <<
"/" << outerHits.size() << std::endl;
201 std::vector<TTRH> innerTTRHs, middleTTRHs, outerTTRHs;
204 std::vector<bool> innerOk( innerHits.size(),
true);
205 std::vector<bool> middleOk(middleHits.size(),
true);
206 std::vector<bool> outerOk( outerHits.size(),
true);
211 for (
auto iOuterHit = outerHits.begin(); iOuterHit != outerHits.end(); ++
idx, ++iOuterHit){
212 outerTTRHs.push_back(&(**iOuterHit));
216 for (
auto iMiddleHit = middleHits.begin(); iMiddleHit != middleHits.end(); ++
idx, ++iMiddleHit){
217 middleTTRHs.push_back(&(**iMiddleHit));
221 for (
auto iInnerHit = innerHits.begin(); iInnerHit != innerHits.end(); ++
idx, ++iInnerHit){
222 innerTTRHs.push_back(&(**iInnerHit));
231 for (
auto iOuterHit = outerHits.begin(); iOuterHit != outerHits.end(); iOuterHit++){
232 idx = iOuterHit - outerHits.begin();
233 TTRH & outerTTRH = outerTTRHs[
idx];
234 GlobalPoint outerpos = outerTTRH->globalPosition();
235 bool outerok = outerOk[
idx];
242 for (
auto iMiddleHit = middleHits.begin(); iMiddleHit != middleHits.end(); iMiddleHit++){
243 idx = iMiddleHit - middleHits.begin();
244 TTRH & middleTTRH = middleTTRHs[
idx];
245 GlobalPoint middlepos = middleTTRH->globalPosition();
246 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];
266 || outerpos.
y() < innerpos.
y()
269 || outerpos.
y() > innerpos.
y()
274 if (
goodTriplet(innerpos,middlepos,outerpos,minRho)) {
280 edm::LogError(
"TooManyTriplets") <<
"Found too many triplets, bailing out.\n";
285 << innerpos <<
" + " << middlepos <<
" + " << outerpos << std::endl;
289 << innerpos <<
" + " << middlepos <<
" + " << outerpos << std::endl;
299 std::cout <<
" iLss = " << seedingLayersToString(ls)
300 <<
" (" << layerIndex <<
"): # = " 301 << innerHits.size() <<
"/" << middleHits.size() <<
"/" << outerHits.size()
325 return checkCharge(static_cast<const SiStripRecHit2D &>(*hit), subdet);
348 std::vector<TTRH>::const_iterator it = hits.begin(),
start = it,
end = hits.end();
349 std::vector<bool>::iterator
ok = oks.begin(), okStart =
ok;
350 while (
start < end) {
351 DetId lastid = (*start)->geographicalId();
352 for (it =
start + 1; (it <
end) && ((*it)->geographicalId() == lastid); ++it) {
357 std::cerr <<
"SimpleCosmicBONSeeder: Marking noisy module " << lastid.
rawId() <<
", it has " << (it-
start) <<
" rechits" 363 std::cerr <<
"SimpleCosmicBONSeeder: Not marking noisy module " << lastid.
rawId() <<
", it has " << (it-
start) <<
" rechits" 372 float dyOM = outer.
y() - middle.
y(), dyIM = inner.
y() - middle.
y();
373 if ((dyOM * dyIM > 0) && (fabs(dyOM)>10) && (fabs(dyIM)>10)) {
377 float dzOM = outer.
z() - middle.
z(), dzIM = inner.
z() - middle.
z();
378 if ((dzOM * dzIM > 0) && (fabs(dzOM)>50) && (fabs(dzIM)>50)) {
384 if (theCircle.
rho() < minRho) {
392 std::pair<GlobalVector,int>
396 std::cout <<
"DEBUG PZ =====" << std::endl;
399 std::cout <<
"FastHelix P = " << gv <<
"\n";
400 std::cout <<
"FastHelix Q = " << helix.stateAtVertex().charge() <<
"\n";
406 double rho = theCircle.
rho();
410 double pt = 0.01 * rho * (0.3*tesla.
z());
413 double dx1 = outer.
x()-theCircle.
x0();
414 double dy1 = outer.
y()-theCircle.
y0();
415 double py = pt*dx1/
rho, px = -pt*dy1/
rho;
416 if(px*(middle.
x() - outer.
x()) + py*(middle.
y() - outer.
y()) < 0.) {
417 px *= -1.; py *= -1.;
421 double dz = inner.
z() - outer.
z();
422 double sinphi = ( dx1*(inner.
y()-theCircle.
y0()) - dy1*(inner.
x()-theCircle.
x0())) / (rho *
rho);
423 double dphi =
std::abs(std::asin(sinphi));
424 double pz = pt * dz / (dphi *
rho);
426 int myq = ((theCircle.
x0()*py - theCircle.
y0()*px) / tesla.
z()) > 0. ? +1 : -1;
428 std::pair<GlobalVector,int> mypq(
GlobalVector(px,py,pz),myq);
431 std::cout <<
"Gio: pt = " << pt << std::endl;
432 std::cout <<
"Gio: dz = " << dz <<
", sinphi = " << sinphi <<
", dphi = " << dphi <<
", dz/drphi = " << (dz/dphi/
rho) << std::endl;
435 std::cout <<
"Gio's fit P = " << mypq.first <<
"\n";
436 std::cout <<
"Gio's fit Q = " << myq <<
"\n";
450 toGlobal((*(trip.
inner())).localPosition());
453 toGlobal((*(trip.
middle())).localPosition());
456 toGlobal((*(trip.
outer())).localPosition());
459 std::cout <<
"Processing triplet " << it <<
": " << inner <<
" + " << middle <<
" + " << outer << std::endl;
461 if ( (outer.y()-inner.
y())*outer.y() < 0 ) {
466 std::cout <<
"The seed was going away from CMS! swapped in <-> out" << std::endl;
467 std::cout <<
"Processing swapped triplet " << it <<
": " << inner <<
" + " << middle <<
" + " << outer << std::endl;
472 std::pair<GlobalVector,int> pq =
pqFromHelixFit(inner,middle,outer,iSetup);
474 float ch = pq.second;
475 float Mom =
sqrt( gv.
x()*gv.
x() + gv.
y()*gv.
y() + gv.
z()*gv.
z() );
479 std::cout <<
"Processing triplet " << it <<
": fail for momentum." << std::endl;
485 std::cout <<
"Processing triplet " << it <<
": fail for pt = " << gv.
perp() <<
" < ptMin = " <<
region_.
ptMin() << std::endl;
490 if((outer.y()-inner.
y())>0){
492 std::cout <<
"Processing triplet " << it <<
": downgoing." << std::endl;
495 gv = -1*gv; ch = -1.*ch;
498 std::cout <<
"Processing triplet " << it <<
": upgoing." << std::endl;
502 if (( gv.
z() * (outer.z()-inner.
z()) > 0 ) && ( fabs(outer.z()-inner.
z()) > 5) && (fabs(gv.
z()) > .01)) {
503 std::cout <<
"ORRORE: outer.z()-inner.z() = " << (outer.z()-inner.
z()) <<
", gv.z() = " << gv.
z() << std::endl;
514 std::cout <<
"Processing triplet " << it <<
". start from " << std::endl;
515 std::cout <<
" X = " << outer <<
", P = " << gv << std::endl;
521 TSOS propagated, updated;
523 for (
size_t ih = 0; ih < 3; ++ih) {
526 std::cout <<
"Stopping at middle hit, as requested." << std::endl;
530 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
"." << std::endl;
536 if (!propagated.isValid()) {
538 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": failed propagation." << std::endl;
542 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": propagated state = " << propagated;
548 if (!updated.isValid()) {
550 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": failed update." << std::endl;
554 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": updated state = " << updated;
557 if (!fail && updated.isValid() && (updated.globalMomentum().perp() <
region_.
ptMin())) {
559 std::cout <<
"Processing triplet " << it <<
560 ": failed for final pt " << updated.globalMomentum().perp() <<
" < " <<
region_.
ptMin() << std::endl;
563 if (!fail && updated.isValid() && (updated.globalMomentum().mag() <
pMin_)) {
565 std::cout <<
"Processing triplet " << it <<
566 ": failed for final p " << updated.globalMomentum().perp() <<
" < " <<
pMin_ << std::endl;
572 std::cout <<
"Processing triplet " << it <<
", rescale error by " <<
rescaleError_ <<
": state BEFORE rescaling " << updated;
573 std::cout <<
" Cartesian error (X,P) before rescaling= \n" << updated.cartesianError().matrix() << std::endl;
578 std::cout <<
"Processed triplet " << it <<
": success (saved as #"<<output.size()<<
") : " 579 << inner <<
" + " << middle <<
" + " << outer << std::endl;
580 std::cout <<
" pt = " << updated.globalMomentum().perp() <<
581 " eta = " << updated.globalMomentum().eta() <<
582 " phi = " << updated.globalMomentum().phi() <<
583 " ch = " << updated.charge() << std::endl;
587 std::cout <<
" X = " << updated.globalPosition() <<
", P = " << updated.globalMomentum() << std::endl;
589 std::cout <<
" Cartesian error (X,P) = \n" << updated.cartesianError().matrix() << std::endl;
598 edm::LogError(
"TooManySeeds") <<
"Found too many seeds, bailing out.\n";
T getParameter(std::string const &) const
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.
bool triplets(const edm::Event &e, const edm::EventSetup &c)
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_
MiddleRecHit middle() const
int nominalValue() const
The nominal field value for this map in kGauss.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
unsigned short LayerSetIndex
OrderedHitTriplets hitTriplets
Global3DPoint GlobalPoint
uint16_t firstStrip() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
bool checkCharge(const TrackingRecHit *hit) const
SimpleCosmicBONSeeder(const edm::ParameterSet &conf)
uint32_t rawId() const
get the raw id
InnerRecHit inner() const
edm::ESHandle< TrackerGeometry > tracker
bool matchedRecHitUsesAnd_
std::pair< GlobalVector, int > pqFromHelixFit(const GlobalPoint &inner, const GlobalPoint &middle, const GlobalPoint &outer, const edm::EventSetup &iSetup) const
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const override
BaseTrackerRecHit const * ConstRecHitPointer
std::vector< TrajectorySeed > TrajectorySeedCollection
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
PropagatorWithMaterial * thePropagatorOp
edm::ESHandle< MagneticField > magfield
virtual TrackingRecHit * clone() const =0
size_t tooManyClusters(const edm::Event &e) const
edm::ESHandle< TransientTrackingRecHitBuilder > TTTRHBuilder
uint32_t tripletsVerbosity_
Abs< T >::type abs(const T &t)
edm::EDGetTokenT< SeedingLayerSetsHits > seedingLayerToken_
ClusterRef cluster() const
T const * get() const
Returns C++ pointer to the item.
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
TrackingRegion::Hits hits(const edm::EventSetup &es, const SeedingLayerSetsHits::SeedingLayer &layer) const override
get hits from layer compatible with region constraints
unsigned int size() const override
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
PropagatorWithMaterial * thePropagatorAl
const AlgebraicSymMatrix66 & matrix() const
TrajectoryStateOnSurface TSOS
virtual TrackingRecHit const * hit() const
void rescaleError(double factor)
SiStripRecHit2D stereoHit() const
bool seeds(TrajectorySeedCollection &output, const edm::EventSetup &iSetup)
float ptMin() const
minimal pt of interest
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
const TrackerGeomDet * idToDet(DetId) const override
SeedingHitSet::ConstRecHitPointer 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
unsigned short size() const
Get the number of SeedingLayerSets.
T const * product() const
const std::vector< uint8_t > & amplitudes() const
Global3DVector GlobalVector