20 theLsb(conf.getParameter<edm::
ParameterSet>(
"TripletsPSet"), consumesCollector()),
21 writeTriplets_(conf.getParameter<bool>(
"writeTriplets")),
22 seedOnMiddle_(conf.existsAs<bool>(
"seedOnMiddle") ? conf.getParameter<bool>(
"seedOnMiddle") :
false),
23 rescaleError_(conf.existsAs<double>(
"rescaleError") ? conf.getParameter<double>(
"rescaleError") : 1.0),
24 tripletsVerbosity_(conf.getParameter<edm::
ParameterSet>(
"TripletsPSet").getUntrackedParameter<uint32_t>(
"debugLevel",0)),
25 seedVerbosity_(conf.getUntrackedParameter<uint32_t>(
"seedDebugLevel",0)),
26 helixVerbosity_(conf.getUntrackedParameter<uint32_t>(
"helixDebugLevel",0)),
27 check_(conf.getParameter<edm::
ParameterSet>(
"ClusterCheckPSet"), consumesCollector()),
28 maxTriplets_(conf.getParameter<int32_t>(
"maxTriplets")),
29 maxSeeds_(conf.getParameter<int32_t>(
"maxSeeds"))
33 float originradius = regionConf.
getParameter<
double>(
"originRadius");
34 float halflength = regionConf.
getParameter<
double>(
"originHalfLength");
35 float originz = regionConf.
getParameter<
double>(
"originZPosition");
46 produces<TrajectorySeedCollection>();
47 if (
writeTriplets_) produces<edm::OwnVector<TrackingRecHit> >(
"cosmicTriplets");
94 edm::LogError(
"TooManyClusters") <<
"Found too many clusters (" << clustsOrZero <<
"), bailing out.\n";
100 bool seedsOk =
seeds(*output,es);
108 outtriplets->push_back(hit1->
clone());
109 outtriplets->push_back(hit2->
clone());
110 outtriplets->push_back(hit3->
clone());
119 ev.
put(outtriplets,
"cosmicTriplets");
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));
161 }
else if (oy2 - iy2 > 0) {
165 return (iy1 != iy2 ? (iy1 < iy2) : (oy1 < oy2));
171 using namespace ctfseeding;
178 SeedingLayerSets::const_iterator iLss;
182 for (iLss =
theLss.begin(); iLss !=
theLss.end(); iLss++){
185 throw cms::Exception(
"CtfSpecialSeedGenerator") <<
"You are using " << ls.size() <<
" layers in set instead of 3 ";
189 std::vector<SeedingHit> innerHits =
region_.hits(e, es, &ls[0]);
190 std::vector<SeedingHit> middleHits =
region_.hits(e, es, &ls[1]);
191 std::vector<SeedingHit> outerHits =
region_.hits(e, es, &ls[2]);
192 std::vector<SeedingHit>::const_iterator iOuterHit,iMiddleHit,iInnerHit;
196 <<
" (" << (iLss -
theLss.begin()) <<
"): # = "
197 << innerHits.size() <<
"/" << middleHits.size() <<
"/" << outerHits.size() << std::endl;
202 std::vector<TTRH> innerTTRHs, middleTTRHs, outerTTRHs;
205 std::vector<bool> innerOk( innerHits.size(),
true);
206 std::vector<bool> middleOk(middleHits.size(),
true);
207 std::vector<bool> outerOk( outerHits.size(),
true);
212 for (iOuterHit = outerHits.begin(), idx = 0; iOuterHit != outerHits.end(); ++
idx, ++iOuterHit){
213 outerTTRHs.push_back(ls[2].hitBuilder()->
build((**iOuterHit).hit()));
216 for (iMiddleHit = middleHits.begin(), idx = 0; iMiddleHit != middleHits.end(); ++
idx, ++iMiddleHit){
217 middleTTRHs.push_back(ls[1].hitBuilder()->
build((**iMiddleHit).hit()));
220 for (iInnerHit = innerHits.begin(), idx = 0; iInnerHit != innerHits.end(); ++
idx, ++iInnerHit){
221 innerTTRHs.push_back(ls[0].hitBuilder()->
build((**iInnerHit).hit()));
230 for (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 (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];
252 for (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];
265 || outerpos.
y() < innerpos.
y()
268 || outerpos.
y() > innerpos.
y()
273 if (
goodTriplet(innerpos,middlepos,outerpos,minRho)) {
279 edm::LogError(
"TooManyTriplets") <<
"Found too many triplets, bailing out.\n";
284 << innerpos <<
" + " << middlepos <<
" + " << outerpos << std::endl;
288 << innerpos <<
" + " << middlepos <<
" + " << outerpos << std::endl;
299 <<
" (" << (iLss -
theLss.begin()) <<
"): # = "
300 << innerHits.size() <<
"/" << middleHits.size() <<
"/" << outerHits.size()
312 int subdet =
detid.subdetId();
316 if (
typeid(*hit) ==
typeid(SiStripMatchedRecHit2D)) {
317 const SiStripMatchedRecHit2D *mhit =
static_cast<const SiStripMatchedRecHit2D *
>(hit);
323 }
else if (
typeid(*hit) ==
typeid(SiStripRecHit2D)) {
324 return checkCharge(static_cast<const SiStripRecHit2D &>(*hit), subdet);
333 const SiStripCluster *clust = (hit.cluster().isNonnull() ? hit.cluster().get() : hit.cluster_regional().get());
337 <<
", detid = " << hit.geographicalId().rawId() <<
", firstStrip = " << clust->
firstStrip() << std::endl;
340 <<
", detid = " << hit.geographicalId().rawId() <<
", firstStrip = " << clust->
firstStrip() << std::endl;
347 std::vector<TTRH>::const_iterator it = hits.begin(),
start = it,
end = hits.end();
348 std::vector<bool>::iterator
ok = oks.begin(), okStart =
ok;
349 while (
start < end) {
350 DetId lastid = (*start)->geographicalId();
351 for (it =
start + 1; (it <
end) && ((*it)->geographicalId() == lastid); ++it) {
356 std::cerr <<
"SimpleCosmicBONSeeder: Marking noisy module " << lastid.
rawId() <<
", it has " << (it-
start) <<
" rechits"
362 std::cerr <<
"SimpleCosmicBONSeeder: Not marking noisy module " << lastid.
rawId() <<
", it has " << (it-
start) <<
" rechits"
371 float dyOM = outer.
y() - middle.
y(), dyIM = inner.
y() - middle.
y();
372 if ((dyOM * dyIM > 0) && (fabs(dyOM)>10) && (fabs(dyIM)>10)) {
376 float dzOM = outer.
z() - middle.
z(), dzIM = inner.
z() - middle.
z();
377 if ((dzOM * dzIM > 0) && (fabs(dzOM)>50) && (fabs(dzIM)>50)) {
383 if (theCircle.
rho() < minRho) {
391 std::pair<GlobalVector,int>
395 std::cout <<
"DEBUG PZ =====" << std::endl;
398 std::cout <<
"FastHelix P = " << gv <<
"\n";
399 std::cout <<
"FastHelix Q = " << helix.stateAtVertex().charge() <<
"\n";
405 double rho = theCircle.
rho();
409 double pt = 0.01 * rho * (0.3*tesla.
z());
412 double dx1 = outer.
x()-theCircle.
x0();
413 double dy1 = outer.
y()-theCircle.
y0();
414 double py = pt*dx1/
rho, px = -pt*dy1/
rho;
415 if(px*(middle.
x() - outer.
x()) + py*(middle.
y() - outer.
y()) < 0.) {
416 px *= -1.; py *= -1.;
420 double dz = inner.
z() - outer.
z();
421 double sinphi = ( dx1*(inner.
y()-theCircle.
y0()) - dy1*(inner.
x()-theCircle.
x0())) / (rho *
rho);
422 double dphi =
std::abs(std::asin(sinphi));
423 double pz = pt * dz / (dphi *
rho);
425 int myq = ((theCircle.
x0()*py - theCircle.
y0()*px) / tesla.
z()) > 0. ? +1 : -1;
427 std::pair<GlobalVector,int> mypq(
GlobalVector(px,py,pz),myq);
430 std::cout <<
"Gio: pt = " << pt << std::endl;
431 std::cout <<
"Gio: dz = " << dz <<
", sinphi = " << sinphi <<
", dphi = " << dphi <<
", dz/drphi = " << (dz/dphi/
rho) << std::endl;
434 std::cout <<
"Gio's fit P = " << mypq.first <<
"\n";
435 std::cout <<
"Gio's fit Q = " << myq <<
"\n";
449 toGlobal((*(trip.
inner())).localPosition());
452 toGlobal((*(trip.
middle())).localPosition());
455 toGlobal((*(trip.
outer())).localPosition());
458 std::cout <<
"Processing triplet " << it <<
": " << inner <<
" + " << middle <<
" + " << outer << std::endl;
460 if ( (outer.y()-inner.
y())*outer.y() < 0 ) {
462 std::swap(const_cast<TransientTrackingRecHit::ConstRecHitPointer &>(trip.
inner()),
463 const_cast<TransientTrackingRecHit::ConstRecHitPointer &>(trip.
outer()) );
468 std::cout <<
"The seed was going away from CMS! swapped in <-> out" << std::endl;
469 std::cout <<
"Processing swapped triplet " << it <<
": " << inner <<
" + " << middle <<
" + " << outer << std::endl;
474 std::pair<GlobalVector,int> pq =
pqFromHelixFit(inner,middle,outer,iSetup);
476 float ch = pq.second;
477 float Mom =
sqrt( gv.
x()*gv.
x() + gv.
y()*gv.
y() + gv.
z()*gv.
z() );
481 std::cout <<
"Processing triplet " << it <<
": fail for momentum." << std::endl;
487 std::cout <<
"Processing triplet " << it <<
": fail for pt = " << gv.
perp() <<
" < ptMin = " <<
region_.ptMin() << std::endl;
492 if((outer.y()-inner.
y())>0){
494 std::cout <<
"Processing triplet " << it <<
": downgoing." << std::endl;
497 gv = -1*gv; ch = -1.*ch;
500 std::cout <<
"Processing triplet " << it <<
": upgoing." << std::endl;
504 if (( gv.
z() * (outer.z()-inner.
z()) > 0 ) && ( fabs(outer.z()-inner.
z()) > 5) && (fabs(gv.
z()) > .01)) {
505 std::cout <<
"ORRORE: outer.z()-inner.z() = " << (outer.z()-inner.
z()) <<
", gv.z() = " << gv.
z() << std::endl;
516 std::cout <<
"Processing triplet " << it <<
". start from " << std::endl;
517 std::cout <<
" X = " << outer <<
", P = " << gv << std::endl;
523 TSOS propagated, updated;
525 for (
size_t ih = 0; ih < 3; ++ih) {
528 std::cout <<
"Stopping at middle hit, as requested." << std::endl;
532 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
"." << std::endl;
534 propagated = propagator->
propagate(CosmicSeed,
tracker->idToDet((*seedHits[ih]).geographicalId())->surface());
536 propagated = propagator->
propagate(updated,
tracker->idToDet((*seedHits[ih]).geographicalId())->surface());
538 if (!propagated.isValid()) {
540 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": failed propagation." << std::endl;
544 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": propagated state = " << propagated;
549 updated =
theUpdator->update(propagated, *newtth);
550 if (!updated.isValid()) {
552 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": failed update." << std::endl;
556 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": updated state = " << updated;
559 if (!fail && updated.isValid() && (updated.globalMomentum().perp() <
region_.ptMin())) {
561 std::cout <<
"Processing triplet " << it <<
562 ": failed for final pt " << updated.globalMomentum().perp() <<
" < " <<
region_.ptMin() << std::endl;
565 if (!fail && updated.isValid() && (updated.globalMomentum().mag() <
pMin_)) {
567 std::cout <<
"Processing triplet " << it <<
568 ": failed for final p " << updated.globalMomentum().perp() <<
" < " <<
pMin_ << std::endl;
574 std::cout <<
"Processing triplet " << it <<
", rescale error by " <<
rescaleError_ <<
": state BEFORE rescaling " << updated;
575 std::cout <<
" Cartesian error (X,P) before rescaling= \n" << updated.cartesianError().matrix() << std::endl;
580 std::cout <<
"Processed triplet " << it <<
": success (saved as #"<<output.size()<<
") : "
581 << inner <<
" + " << middle <<
" + " << outer << std::endl;
582 std::cout <<
" pt = " << updated.globalMomentum().perp() <<
583 " eta = " << updated.globalMomentum().eta() <<
584 " phi = " << updated.globalMomentum().phi() <<
585 " ch = " << updated.charge() << std::endl;
589 std::cout <<
" X = " << updated.globalPosition() <<
", P = " << updated.globalMomentum() << std::endl;
591 std::cout <<
" Cartesian error (X,P) = \n" << updated.cartesianError().matrix() << std::endl;
600 edm::LogError(
"TooManySeeds") <<
"Found too many seeds, bailing out.\n";
T getParameter(std::string const &) const
GlobalTrackingRegion region_
ctfseeding::SeedingLayerSets layers(const edm::EventSetup &es)
tuple start
Check for commandline option errors.
const OuterRecHit & outer() const
bool triplets(const edm::Event &e, const edm::EventSetup &c)
void init(const edm::EventSetup &c)
CartesianTrajectoryError cartesianError() const
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
bool checkMaxHitsPerModule_
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
OrderedHitTriplets hitTriplets
Global3DPoint GlobalPoint
const InnerRecHit & inner() const
const MiddleRecHit & middle() const
bool check(const edm::EventSetup &es)
uint16_t firstStrip() const
void checkNoisyModules(const std::vector< TransientTrackingRecHit::RecHitPointer > &hits, std::vector< bool > &oks) 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
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
SeedingLayerSetsBuilder theLsb
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.
ctfseeding::SeedingLayerSets theLss
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)
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 TrajectoryStateOnSurface propagate(const FreeTrajectoryState &, const Surface &) const
virtual TrackingRecHit * clone() const =0
TrajectoryStateOnSurface TSOS
void rescaleError(double factor)
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
bool seeds(TrajectorySeedCollection &output, const edm::EventSetup &iSetup)
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
std::vector< std::string > layerTripletNames_
TransientTrackingRecHit::ConstRecHitPointer SeedingHit
std::vector< int32_t > chargeThresholds_
std::vector< int32_t > maxHitsPerModule_
DetId geographicalId() const
volatile std::atomic< bool > shutdown_flag false
virtual unsigned int size() const
const std::vector< uint8_t > & amplitudes() const
std::vector< SeedingLayer > SeedingLayers
Global3DVector GlobalVector