20 return layer[0].name() +
"+" + layer[1].name() +
"+" + layer[2].name();
27 seedingLayerToken_(consumes<
SeedingLayerSetsHits>(conf.getParameter<edm::InputTag>(
"TripletsSrc"))),
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");
99 edm::LogError(
"TooManyClusters") <<
"Found too many clusters (" << clustsOrZero <<
"), bailing out.\n";
105 bool seedsOk =
seeds(*output,es);
113 outtriplets->push_back(hit1->
clone());
114 outtriplets->push_back(hit2->
clone());
115 outtriplets->push_back(hit3->
clone());
124 ev.
put(outtriplets,
"cosmicTriplets");
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));
176 using namespace ctfseeding;
183 if(
layers.numberOfLayersInSet() != 3)
184 throw cms::Exception(
"CtfSpecialSeedGenerator") <<
"You are using " <<
layers.numberOfLayersInSet() <<
" layers in set instead of 3 ";
191 auto innerHits =
region_.hits(e, es, ls[0]);
192 auto middleHits =
region_.hits(e, es, ls[1]);
193 auto outerHits =
region_.hits(e, es, ls[2]);
196 std::cout <<
"GenericTripletGenerator iLss = " << seedingLayersToString(ls)
197 <<
" (" << layerIndex <<
"): # = "
198 << innerHits.size() <<
"/" << middleHits.size() <<
"/" << outerHits.size() << std::endl;
203 std::vector<TTRH> innerTTRHs, middleTTRHs, outerTTRHs;
206 std::vector<bool> innerOk( innerHits.size(),
true);
207 std::vector<bool> middleOk(middleHits.size(),
true);
208 std::vector<bool> outerOk( outerHits.size(),
true);
213 for (
auto iOuterHit = outerHits.begin(); iOuterHit != outerHits.end(); ++
idx, ++iOuterHit){
214 outerTTRHs.push_back(&(**iOuterHit));
218 for (
auto iMiddleHit = middleHits.begin(); iMiddleHit != middleHits.end(); ++
idx, ++iMiddleHit){
219 middleTTRHs.push_back(&(**iMiddleHit));
223 for (
auto iInnerHit = innerHits.begin(); iInnerHit != innerHits.end(); ++
idx, ++iInnerHit){
224 innerTTRHs.push_back(&(**iInnerHit));
233 for (
auto iOuterHit = outerHits.begin(); iOuterHit != outerHits.end(); iOuterHit++){
234 idx = iOuterHit - outerHits.begin();
235 TTRH & outerTTRH = outerTTRHs[
idx];
236 GlobalPoint outerpos = outerTTRH->globalPosition();
237 bool outerok = outerOk[
idx];
244 for (
auto iMiddleHit = middleHits.begin(); iMiddleHit != middleHits.end(); iMiddleHit++){
245 idx = iMiddleHit - middleHits.begin();
246 TTRH & middleTTRH = middleTTRHs[
idx];
247 GlobalPoint middlepos = middleTTRH->globalPosition();
248 bool middleok = middleOk[
idx];
255 for (
auto iInnerHit = innerHits.begin(); iInnerHit != innerHits.end(); iInnerHit++){
256 idx = iInnerHit - innerHits.begin();
257 TTRH & innerTTRH = innerTTRHs[
idx];
258 GlobalPoint innerpos = innerTTRH->globalPosition();
259 bool innerok = innerOk[
idx];
268 || outerpos.
y() < innerpos.
y()
271 || outerpos.
y() > innerpos.
y()
276 if (
goodTriplet(innerpos,middlepos,outerpos,minRho)) {
282 edm::LogError(
"TooManyTriplets") <<
"Found too many triplets, bailing out.\n";
287 << innerpos <<
" + " << middlepos <<
" + " << outerpos << std::endl;
291 << innerpos <<
" + " << middlepos <<
" + " << outerpos << std::endl;
301 std::cout <<
" iLss = " << seedingLayersToString(ls)
302 <<
" (" << layerIndex <<
"): # = "
303 << innerHits.size() <<
"/" << middleHits.size() <<
"/" << outerHits.size()
315 int subdet =
detid.subdetId();
319 if (
typeid(*hit) ==
typeid(SiStripMatchedRecHit2D)) {
320 const SiStripMatchedRecHit2D *mhit =
static_cast<const SiStripMatchedRecHit2D *
>(hit);
326 }
else if (
typeid(*hit) ==
typeid(SiStripRecHit2D)) {
327 return checkCharge(static_cast<const SiStripRecHit2D &>(*hit), subdet);
340 <<
", detid = " << hit.geographicalId().rawId() <<
", firstStrip = " << clust->
firstStrip() << std::endl;
343 <<
", detid = " << hit.geographicalId().rawId() <<
", firstStrip = " << clust->
firstStrip() << std::endl;
350 std::vector<TTRH>::const_iterator it = hits.begin(),
start = it,
end = hits.end();
351 std::vector<bool>::iterator
ok = oks.begin(), okStart =
ok;
352 while (
start < end) {
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) <<
" rechits"
365 std::cerr <<
"SimpleCosmicBONSeeder: Not marking noisy module " << lastid.
rawId() <<
", it has " << (it-
start) <<
" rechits"
374 float dyOM = outer.
y() - middle.
y(), dyIM = inner.
y() - middle.
y();
375 if ((dyOM * dyIM > 0) && (fabs(dyOM)>10) && (fabs(dyIM)>10)) {
379 float dzOM = outer.
z() - middle.
z(), dzIM = inner.
z() - middle.
z();
380 if ((dzOM * dzIM > 0) && (fabs(dzOM)>50) && (fabs(dzIM)>50)) {
386 if (theCircle.
rho() < minRho) {
394 std::pair<GlobalVector,int>
398 std::cout <<
"DEBUG PZ =====" << std::endl;
401 std::cout <<
"FastHelix P = " << gv <<
"\n";
402 std::cout <<
"FastHelix Q = " << helix.stateAtVertex().charge() <<
"\n";
408 double rho = theCircle.
rho();
412 double pt = 0.01 * rho * (0.3*tesla.
z());
415 double dx1 = outer.
x()-theCircle.
x0();
416 double dy1 = outer.
y()-theCircle.
y0();
417 double py = pt*dx1/
rho, px = -pt*dy1/
rho;
418 if(px*(middle.
x() - outer.
x()) + py*(middle.
y() - outer.
y()) < 0.) {
419 px *= -1.; py *= -1.;
423 double dz = inner.
z() - outer.
z();
424 double sinphi = ( dx1*(inner.
y()-theCircle.
y0()) - dy1*(inner.
x()-theCircle.
x0())) / (rho *
rho);
425 double dphi =
std::abs(std::asin(sinphi));
426 double pz = pt * dz / (dphi *
rho);
428 int myq = ((theCircle.
x0()*py - theCircle.
y0()*px) / tesla.
z()) > 0. ? +1 : -1;
430 std::pair<GlobalVector,int> mypq(
GlobalVector(px,py,pz),myq);
433 std::cout <<
"Gio: pt = " << pt << std::endl;
434 std::cout <<
"Gio: dz = " << dz <<
", sinphi = " << sinphi <<
", dphi = " << dphi <<
", dz/drphi = " << (dz/dphi/
rho) << std::endl;
437 std::cout <<
"Gio's fit P = " << mypq.first <<
"\n";
438 std::cout <<
"Gio's fit Q = " << myq <<
"\n";
452 toGlobal((*(trip.
inner())).localPosition());
455 toGlobal((*(trip.
middle())).localPosition());
458 toGlobal((*(trip.
outer())).localPosition());
461 std::cout <<
"Processing triplet " << it <<
": " << inner <<
" + " << middle <<
" + " << outer << std::endl;
463 if ( (outer.y()-inner.
y())*outer.y() < 0 ) {
470 std::cout <<
"The seed was going away from CMS! swapped in <-> out" << std::endl;
471 std::cout <<
"Processing swapped triplet " << it <<
": " << inner <<
" + " << middle <<
" + " << outer << std::endl;
476 std::pair<GlobalVector,int> pq =
pqFromHelixFit(inner,middle,outer,iSetup);
478 float ch = pq.second;
479 float Mom =
sqrt( gv.
x()*gv.
x() + gv.
y()*gv.
y() + gv.
z()*gv.
z() );
483 std::cout <<
"Processing triplet " << it <<
": fail for momentum." << std::endl;
489 std::cout <<
"Processing triplet " << it <<
": fail for pt = " << gv.
perp() <<
" < ptMin = " <<
region_.ptMin() << std::endl;
494 if((outer.y()-inner.
y())>0){
496 std::cout <<
"Processing triplet " << it <<
": downgoing." << std::endl;
499 gv = -1*gv; ch = -1.*ch;
502 std::cout <<
"Processing triplet " << it <<
": upgoing." << std::endl;
506 if (( gv.
z() * (outer.z()-inner.
z()) > 0 ) && ( fabs(outer.z()-inner.
z()) > 5) && (fabs(gv.
z()) > .01)) {
507 std::cout <<
"ORRORE: outer.z()-inner.z() = " << (outer.z()-inner.
z()) <<
", gv.z() = " << gv.
z() << std::endl;
518 std::cout <<
"Processing triplet " << it <<
". start from " << std::endl;
519 std::cout <<
" X = " << outer <<
", P = " << gv << std::endl;
525 TSOS propagated, updated;
527 for (
size_t ih = 0; ih < 3; ++ih) {
530 std::cout <<
"Stopping at middle hit, as requested." << std::endl;
534 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
"." << std::endl;
536 propagated = propagator->
propagate(CosmicSeed,
tracker->idToDet((*seedHits[ih]).geographicalId())->surface());
538 propagated = propagator->
propagate(updated,
tracker->idToDet((*seedHits[ih]).geographicalId())->surface());
540 if (!propagated.isValid()) {
542 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": failed propagation." << std::endl;
546 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": propagated state = " << propagated;
550 updated =
theUpdator->update(propagated, *newtth);
552 if (!updated.isValid()) {
554 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": failed update." << std::endl;
558 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": updated state = " << updated;
561 if (!fail && updated.isValid() && (updated.globalMomentum().perp() <
region_.ptMin())) {
563 std::cout <<
"Processing triplet " << it <<
564 ": failed for final pt " << updated.globalMomentum().perp() <<
" < " <<
region_.ptMin() << std::endl;
567 if (!fail && updated.isValid() && (updated.globalMomentum().mag() <
pMin_)) {
569 std::cout <<
"Processing triplet " << it <<
570 ": failed for final p " << updated.globalMomentum().perp() <<
" < " <<
pMin_ << std::endl;
576 std::cout <<
"Processing triplet " << it <<
", rescale error by " <<
rescaleError_ <<
": state BEFORE rescaling " << updated;
577 std::cout <<
" Cartesian error (X,P) before rescaling= \n" << updated.cartesianError().matrix() << std::endl;
582 std::cout <<
"Processed triplet " << it <<
": success (saved as #"<<output.size()<<
") : "
583 << inner <<
" + " << middle <<
" + " << outer << std::endl;
584 std::cout <<
" pt = " << updated.globalMomentum().perp() <<
585 " eta = " << updated.globalMomentum().eta() <<
586 " phi = " << updated.globalMomentum().phi() <<
587 " ch = " << updated.charge() << std::endl;
591 std::cout <<
" X = " << updated.globalPosition() <<
", P = " << updated.globalMomentum() << std::endl;
593 std::cout <<
" Cartesian error (X,P) = \n" << updated.cartesianError().matrix() << std::endl;
602 edm::LogError(
"TooManySeeds") <<
"Found too many seeds, bailing out.\n";
T getParameter(std::string const &) const
GlobalTrackingRegion region_
tuple start
Check for commandline option errors.
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
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
BaseTrackerRecHit const * ConstRecHitPointer
std::vector< TrajectorySeed > TrajectorySeedCollection
const T & max(const T &a, const T &b)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
PropagatorWithMaterial * thePropagatorOp
edm::ESHandle< MagneticField > magfield
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_
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
PropagatorWithMaterial * thePropagatorAl
const AlgebraicSymMatrix66 & matrix() const
virtual TrackingRecHit * clone() const =0
TrajectoryStateOnSurface TSOS
virtual TrackingRecHit const * hit() const
void rescaleError(double factor)
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
bool seeds(TrajectorySeedCollection &output, const edm::EventSetup &iSetup)
T const * product() const
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
bool goodTriplet(const GlobalPoint &inner, const GlobalPoint &middle, const GlobalPoint &outer, const double &minRho) const
bool operator()(const OrderedHitTriplet &trip1, const OrderedHitTriplet &trip2) const
virtual 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
volatile std::atomic< bool > shutdown_flag false
OuterRecHit outer() const
virtual unsigned int size() const
const std::vector< uint8_t > & amplitudes() const
Global3DVector GlobalVector