19 theLsb(conf.getParameter<edm::
ParameterSet>(
"TripletsPSet")),
20 writeTriplets_(conf.getParameter<bool>(
"writeTriplets")),
21 seedOnMiddle_(conf.existsAs<bool>(
"seedOnMiddle") ? conf.getParameter<bool>(
"seedOnMiddle") :
false),
22 rescaleError_(conf.existsAs<double>(
"rescaleError") ? conf.getParameter<double>(
"rescaleError") : 1.0),
23 tripletsVerbosity_(conf.getParameter<edm::
ParameterSet>(
"TripletsPSet").getUntrackedParameter<uint32_t>(
"debugLevel",0)),
24 seedVerbosity_(conf.getUntrackedParameter<uint32_t>(
"seedDebugLevel",0)),
25 helixVerbosity_(conf.getUntrackedParameter<uint32_t>(
"helixDebugLevel",0)),
26 check_(conf.getParameter<edm::
ParameterSet>(
"ClusterCheckPSet")),
27 maxTriplets_(conf.getParameter<int32_t>(
"maxTriplets")),
28 maxSeeds_(conf.getParameter<int32_t>(
"maxSeeds"))
32 float originradius = regionConf.
getParameter<
double>(
"originRadius");
33 float halflength = regionConf.
getParameter<
double>(
"originHalfLength");
34 float originz = regionConf.
getParameter<
double>(
"originZPosition");
45 produces<TrajectorySeedCollection>();
46 if (
writeTriplets_) produces<edm::OwnVector<TrackingRecHit> >(
"cosmicTriplets");
93 edm::LogError(
"TooManyClusters") <<
"Found too many clusters (" << clustsOrZero <<
"), bailing out.\n";
99 bool seedsOk =
seeds(*output,es);
107 outtriplets->push_back(hit1->
clone());
108 outtriplets->push_back(hit2->
clone());
109 outtriplets->push_back(hit3->
clone());
118 ev.
put(outtriplets,
"cosmicTriplets");
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));
160 }
else if (oy2 - iy2 > 0) {
164 return (iy1 != iy2 ? (iy1 < iy2) : (oy1 < oy2));
170 using namespace ctfseeding;
175 SeedingLayerSets::const_iterator iLss;
179 for (iLss = lss.begin(); iLss != lss.end(); iLss++){
182 throw cms::Exception(
"CtfSpecialSeedGenerator") <<
"You are using " << ls.size() <<
" layers in set instead of 3 ";
186 std::vector<SeedingHit> innerHits =
region_.hits(e, es, &ls[0]);
187 std::vector<SeedingHit> middleHits =
region_.hits(e, es, &ls[1]);
188 std::vector<SeedingHit> outerHits =
region_.hits(e, es, &ls[2]);
189 std::vector<SeedingHit>::const_iterator iOuterHit,iMiddleHit,iInnerHit;
193 <<
" (" << (iLss - lss.begin()) <<
"): # = "
194 << innerHits.size() <<
"/" << middleHits.size() <<
"/" << outerHits.size() << std::endl;
199 std::vector<TTRH> innerTTRHs, middleTTRHs, outerTTRHs;
202 std::vector<bool> innerOk( innerHits.size(),
true);
203 std::vector<bool> middleOk(middleHits.size(),
true);
204 std::vector<bool> outerOk( outerHits.size(),
true);
209 for (iOuterHit = outerHits.begin(), idx = 0; iOuterHit != outerHits.end(); ++
idx, ++iOuterHit){
210 outerTTRHs.push_back(ls[2].hitBuilder()->
build((**iOuterHit).hit()));
213 for (iMiddleHit = middleHits.begin(), idx = 0; iMiddleHit != middleHits.end(); ++
idx, ++iMiddleHit){
214 middleTTRHs.push_back(ls[1].hitBuilder()->
build((**iMiddleHit).hit()));
217 for (iInnerHit = innerHits.begin(), idx = 0; iInnerHit != innerHits.end(); ++
idx, ++iInnerHit){
218 innerTTRHs.push_back(ls[0].hitBuilder()->
build((**iInnerHit).hit()));
227 for (iOuterHit = outerHits.begin(); iOuterHit != outerHits.end(); iOuterHit++){
228 idx = iOuterHit - outerHits.begin();
229 TTRH & outerTTRH = outerTTRHs[
idx];
230 GlobalPoint outerpos = outerTTRH->globalPosition();
231 bool outerok = outerOk[
idx];
238 for (iMiddleHit = middleHits.begin(); iMiddleHit != middleHits.end(); iMiddleHit++){
239 idx = iMiddleHit - middleHits.begin();
240 TTRH & middleTTRH = middleTTRHs[
idx];
241 GlobalPoint middlepos = middleTTRH->globalPosition();
242 bool middleok = middleOk[
idx];
249 for (iInnerHit = innerHits.begin(); iInnerHit != innerHits.end(); iInnerHit++){
250 idx = iInnerHit - innerHits.begin();
251 TTRH & innerTTRH = innerTTRHs[
idx];
252 GlobalPoint innerpos = innerTTRH->globalPosition();
253 bool innerok = innerOk[
idx];
262 || outerpos.
y() < innerpos.
y()
265 || outerpos.
y() > innerpos.
y()
270 if (
goodTriplet(innerpos,middlepos,outerpos,minRho)) {
276 edm::LogError(
"TooManyTriplets") <<
"Found too many triplets, bailing out.\n";
281 << innerpos <<
" + " << middlepos <<
" + " << outerpos << std::endl;
285 << innerpos <<
" + " << middlepos <<
" + " << outerpos << std::endl;
296 <<
" (" << (iLss - lss.begin()) <<
"): # = "
297 << innerHits.size() <<
"/" << middleHits.size() <<
"/" << outerHits.size()
309 int subdet =
detid.subdetId();
313 if (
typeid(*hit) ==
typeid(SiStripMatchedRecHit2D)) {
314 const SiStripMatchedRecHit2D *mhit =
static_cast<const SiStripMatchedRecHit2D *
>(hit);
320 }
else if (
typeid(*hit) ==
typeid(SiStripRecHit2D)) {
321 return checkCharge(static_cast<const SiStripRecHit2D &>(*hit), subdet);
330 const SiStripCluster *clust = (hit.cluster().isNonnull() ? hit.cluster().get() : hit.cluster_regional().get());
334 <<
", detid = " << hit.geographicalId().rawId() <<
", firstStrip = " << clust->
firstStrip() << std::endl;
337 <<
", detid = " << hit.geographicalId().rawId() <<
", firstStrip = " << clust->
firstStrip() << std::endl;
344 std::vector<TTRH>::const_iterator it = hits.begin(),
start = it,
end = hits.end();
345 std::vector<bool>::iterator
ok = oks.begin(), okStart =
ok;
346 while (
start < end) {
347 DetId lastid = (*start)->geographicalId();
348 for (it =
start + 1; (it <
end) && ((*it)->geographicalId() == lastid); ++it) {
353 std::cerr <<
"SimpleCosmicBONSeeder: Marking noisy module " << lastid.
rawId() <<
", it has " << (it-
start) <<
" rechits"
359 std::cerr <<
"SimpleCosmicBONSeeder: Not marking noisy module " << lastid.
rawId() <<
", it has " << (it-
start) <<
" rechits"
368 float dyOM = outer.
y() - middle.
y(), dyIM = inner.
y() - middle.
y();
369 if ((dyOM * dyIM > 0) && (fabs(dyOM)>10) && (fabs(dyIM)>10)) {
373 float dzOM = outer.
z() - middle.
z(), dzIM = inner.
z() - middle.
z();
374 if ((dzOM * dzIM > 0) && (fabs(dzOM)>50) && (fabs(dzIM)>50)) {
380 if (theCircle.
rho() < minRho) {
388 std::pair<GlobalVector,int>
392 std::cout <<
"DEBUG PZ =====" << std::endl;
395 std::cout <<
"FastHelix P = " << gv <<
"\n";
396 std::cout <<
"FastHelix Q = " << helix.stateAtVertex().charge() <<
"\n";
402 double rho = theCircle.
rho();
406 double pt = 0.01 * rho * (0.3*tesla.
z());
409 double dx1 = outer.
x()-theCircle.
x0();
410 double dy1 = outer.
y()-theCircle.
y0();
411 double py = pt*dx1/
rho, px = -pt*dy1/
rho;
412 if(px*(middle.
x() - outer.
x()) + py*(middle.
y() - outer.
y()) < 0.) {
413 px *= -1.; py *= -1.;
417 double dz = inner.
z() - outer.
z();
418 double sinphi = ( dx1*(inner.
y()-theCircle.
y0()) - dy1*(inner.
x()-theCircle.
x0())) / (rho *
rho);
419 double dphi =
std::abs(std::asin(sinphi));
420 double pz = pt * dz / (dphi *
rho);
422 int myq = ((theCircle.
x0()*py - theCircle.
y0()*px) / tesla.
z()) > 0. ? +1 : -1;
424 std::pair<GlobalVector,int> mypq(
GlobalVector(px,py,pz),myq);
427 std::cout <<
"Gio: pt = " << pt << std::endl;
428 std::cout <<
"Gio: dz = " << dz <<
", sinphi = " << sinphi <<
", dphi = " << dphi <<
", dz/drphi = " << (dz/dphi/
rho) << std::endl;
431 std::cout <<
"Gio's fit P = " << mypq.first <<
"\n";
432 std::cout <<
"Gio's fit Q = " << myq <<
"\n";
446 toGlobal((*(trip.
inner())).localPosition());
449 toGlobal((*(trip.
middle())).localPosition());
452 toGlobal((*(trip.
outer())).localPosition());
455 std::cout <<
"Processing triplet " << it <<
": " << inner <<
" + " << middle <<
" + " << outer << std::endl;
457 if ( (outer.y()-inner.
y())*outer.y() < 0 ) {
459 std::swap(const_cast<TransientTrackingRecHit::ConstRecHitPointer &>(trip.
inner()),
460 const_cast<TransientTrackingRecHit::ConstRecHitPointer &>(trip.
outer()) );
465 std::cout <<
"The seed was going away from CMS! swapped in <-> out" << std::endl;
466 std::cout <<
"Processing swapped triplet " << it <<
": " << inner <<
" + " << middle <<
" + " << outer << std::endl;
471 std::pair<GlobalVector,int> pq =
pqFromHelixFit(inner,middle,outer,iSetup);
473 float ch = pq.second;
474 float Mom =
sqrt( gv.
x()*gv.
x() + gv.
y()*gv.
y() + gv.
z()*gv.
z() );
478 std::cout <<
"Processing triplet " << it <<
": fail for momentum." << std::endl;
484 std::cout <<
"Processing triplet " << it <<
": fail for pt = " << gv.
perp() <<
" < ptMin = " <<
region_.ptMin() << std::endl;
489 if((outer.y()-inner.
y())>0){
491 std::cout <<
"Processing triplet " << it <<
": downgoing." << std::endl;
494 gv = -1*gv; ch = -1.*ch;
497 std::cout <<
"Processing triplet " << it <<
": upgoing." << std::endl;
501 if (( gv.
z() * (outer.z()-inner.
z()) > 0 ) && ( fabs(outer.z()-inner.
z()) > 5) && (fabs(gv.
z()) > .01)) {
502 std::cout <<
"ORRORE: outer.z()-inner.z() = " << (outer.z()-inner.
z()) <<
", gv.z() = " << gv.
z() << std::endl;
513 std::cout <<
"Processing triplet " << it <<
". start from " << std::endl;
514 std::cout <<
" X = " << outer <<
", P = " << gv << std::endl;
520 TSOS propagated, updated;
522 for (
size_t ih = 0; ih < 3; ++ih) {
525 std::cout <<
"Stopping at middle hit, as requested." << std::endl;
529 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
"." << std::endl;
531 propagated = propagator->
propagate(CosmicSeed,
tracker->idToDet((*seedHits[ih]).geographicalId())->surface());
533 propagated = propagator->
propagate(updated,
tracker->idToDet((*seedHits[ih]).geographicalId())->surface());
535 if (!propagated.isValid()) {
537 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": failed propagation." << std::endl;
541 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": propagated state = " << propagated;
546 updated =
theUpdator->update(propagated, *newtth);
547 if (!updated.isValid()) {
549 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": failed update." << std::endl;
553 std::cout <<
"Processing triplet " << it <<
", hit " << ih <<
": updated state = " << updated;
556 if (!fail && updated.isValid() && (updated.globalMomentum().perp() <
region_.ptMin())) {
558 std::cout <<
"Processing triplet " << it <<
559 ": failed for final pt " << updated.globalMomentum().perp() <<
" < " <<
region_.ptMin() << std::endl;
562 if (!fail && updated.isValid() && (updated.globalMomentum().mag() <
pMin_)) {
564 std::cout <<
"Processing triplet " << it <<
565 ": failed for final p " << updated.globalMomentum().perp() <<
" < " <<
pMin_ << std::endl;
571 std::cout <<
"Processing triplet " << it <<
", rescale error by " <<
rescaleError_ <<
": state BEFORE rescaling " << updated;
572 std::cout <<
" Cartesian error (X,P) before rescaling= \n" << updated.cartesianError().matrix() << std::endl;
577 std::cout <<
"Processed triplet " << it <<
": success (saved as #"<<output.size()<<
") : "
578 << inner <<
" + " << middle <<
" + " << outer << std::endl;
579 std::cout <<
" pt = " << updated.globalMomentum().perp() <<
580 " eta = " << updated.globalMomentum().eta() <<
581 " phi = " << updated.globalMomentum().phi() <<
582 " ch = " << updated.charge() << std::endl;
586 std::cout <<
" X = " << updated.globalPosition() <<
", P = " << updated.globalMomentum() << std::endl;
588 std::cout <<
" Cartesian error (X,P) = \n" << updated.cartesianError().matrix() << std::endl;
597 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.
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
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.
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_
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
ctfseeding::SeedingLayerSets layers(const edm::EventSetup &es) const
std::vector< std::string > layerTripletNames_
TransientTrackingRecHit::ConstRecHitPointer SeedingHit
std::vector< int32_t > chargeThresholds_
std::vector< int32_t > maxHitsPerModule_
DetId geographicalId() const
virtual unsigned int size() const
const std::vector< uint8_t > & amplitudes() const
std::vector< SeedingLayer > SeedingLayers
Global3DVector GlobalVector
std::vector< std::vector< SeedingLayer > > SeedingLayerSets