50 : beamSpotTag_(
"offlineBeamSpot"),
51 theUpdator(0),thePropagator(0),theMeasurementTracker(0),
52 theSetup(0), theMatcher_(0),
53 cacheIDMagField_(0),cacheIDCkfComp_(0),cacheIDTrkGeom_(0),
54 tibOriginZCut_(pset.getParameter<double>(
"tibOriginZCut")),
55 tidOriginZCut_(pset.getParameter<double>(
"tidOriginZCut")),
56 tecOriginZCut_(pset.getParameter<double>(
"tecOriginZCut")),
57 monoOriginZCut_(pset.getParameter<double>(
"monoOriginZCut")),
58 tibDeltaPsiCut_(pset.getParameter<double>(
"tibDeltaPsiCut")),
59 tidDeltaPsiCut_(pset.getParameter<double>(
"tidDeltaPsiCut")),
60 tecDeltaPsiCut_(pset.getParameter<double>(
"tecDeltaPsiCut")),
61 monoDeltaPsiCut_(pset.getParameter<double>(
"monoDeltaPsiCut")),
62 tibPhiMissHit2Cut_(pset.getParameter<double>(
"tibPhiMissHit2Cut")),
63 tidPhiMissHit2Cut_(pset.getParameter<double>(
"tidPhiMissHit2Cut")),
64 tecPhiMissHit2Cut_(pset.getParameter<double>(
"tecPhiMissHit2Cut")),
65 monoPhiMissHit2Cut_(pset.getParameter<double>(
"monoPhiMissHit2Cut")),
66 tibZMissHit2Cut_(pset.getParameter<double>(
"tibZMissHit2Cut")),
67 tidRMissHit2Cut_(pset.getParameter<double>(
"tidRMissHit2Cut")),
68 tecRMissHit2Cut_(pset.getParameter<double>(
"tecRMissHit2Cut")),
69 tidEtaUsage_(pset.getParameter<double>(
"tidEtaUsage")),
70 tidMaxHits_(pset.getParameter<int>(
"tidMaxHits")),
71 tecMaxHits_(pset.getParameter<int>(
"tecMaxHits")),
72 monoMaxHits_(pset.getParameter<int>(
"monoMaxHits")),
73 maxSeeds_(pset.getParameter<int>(
"maxSeeds"))
76 if (pset.
exists(
"measurementTrackerName"))
80 if (pset.
exists(
"beamSpot"))
123 for (
unsigned int i=0;
i<clusters->size();++
i) {
126 LogDebug (
"run") <<
"new cluster, calling findSeedsFromCluster";
131 LogDebug (
"run") <<
"Nr of superclusters: "<<clusters->size()
132 <<
", no. of ElectronSeeds found = " << out.size();
143 layer1Hits_.clear() ;
144 layer2Hits_.clear() ;
145 backupLayer2Hits_.clear() ;
149 double sCenergy = seedCluster->energy();
151 double scEta = seedCluster->eta();
153 double scz = sCposition.z();
154 double scr =
sqrt(
pow(sCposition.x(),2)+
pow(sCposition.y(),2));
156 double pT = sCenergy * seedCluster->position().rho()/
sqrt(seedCluster->x()*seedCluster->x()+seedCluster->y()*seedCluster->y()+seedCluster->z()*seedCluster->z());
159 double magneticField = 3.8;
162 double phiVsRSlope = -3.00e-3 * magneticField / pT / 2.;
167 GlobalPoint superCluster(sCposition.x(),sCposition.y(),sCposition.z());
176 int chargeHypothesis;
177 double chargeSelector = sCenergy - (int)sCenergy;
178 if(chargeSelector >= 0.5) chargeHypothesis = -1;
179 if(chargeSelector < 0.5) chargeHypothesis = 1;
183 double phiFake = phiDiff(superCluster.phi(),chargeHypothesis * phiVsRSlope * (scr - rFake));
184 double zFake = (rFake*(scz-z0)-r0*scz+scr*z0)/(scr-r0);
185 double xFake = rFake *
cos(phiFake);
186 double yFake = rFake *
sin(phiFake);
192 float nomField = bfield->nominalValue();
207 std::vector<BarrelDetLayer*> tibLayers = gst->
tibLayers();
211 std::vector<ForwardDetLayer*> tecLayers;
212 std::vector<ForwardDetLayer*> tidLayers;
214 tecLayers = gst->negTecLayers();
215 tidLayers = gst->negTidLayers();
218 tecLayers = gst->posTecLayers();
219 tidLayers = gst->posTidLayers();
230 std::vector<bool> useDL = useDetLayer(scEta);
248 bool hasLay1Hit =
false;
249 bool hasLay2Hit =
false;
250 bool hasBackupHit =
false;
254 std::vector<TrajectoryMeasurement> tib1measurements;
255 if(useDL.at(0)) tib1measurements = layerMeasurements.
measurements(*tib1,initialTSOS,*thePropagator,*theEstimator);
256 std::vector<TrajectoryMeasurement> tib2measurements;
257 if(useDL.at(1)) tib2measurements = layerMeasurements.
measurements(*tib2,initialTSOS,*thePropagator,*theEstimator);
263 for(std::vector<TrajectoryMeasurement>::const_iterator tmIter = tib1measurements.begin(); tmIter != tib1measurements.end(); ++ tmIter){
265 const SiStripMatchedRecHit2D* matchedHit = matchedHitConverter(hit);
267 GlobalPoint position = trackerGeometryHandle->idToDet(matchedHit->geographicalId())->surface().toGlobal(matchedHit->localPosition());
268 if(preselection(position, superCluster, phiVsRSlope, 1)){
270 layer1Hits_.push_back(matchedHit);
275 for(std::vector<TrajectoryMeasurement>::const_iterator tmIter = tib2measurements.begin(); tmIter != tib2measurements.end(); ++ tmIter){
277 const SiStripMatchedRecHit2D* matchedHit = matchedHitConverter(hit);
279 GlobalPoint position = trackerGeometryHandle->idToDet(matchedHit->geographicalId())->surface().toGlobal(matchedHit->localPosition());
280 if(preselection(position, superCluster, phiVsRSlope, 1)){
282 layer2Hits_.push_back(matchedHit);
287 if(!(hasLay1Hit && hasLay2Hit)) useTID =
true;
288 if(
std::abs(scEta) > tidEtaUsage_) useTID =
true;
289 std::vector<TrajectoryMeasurement> tid1measurements;
290 if(useDL.at(2) && useTID) tid1measurements = layerMeasurements.
measurements(*tid1,initialTSOS,*thePropagator,*theEstimator);
291 std::vector<TrajectoryMeasurement> tid2measurements;
292 if(useDL.at(3) && useTID) tid2measurements = layerMeasurements.
measurements(*tid2,initialTSOS,*thePropagator,*theEstimator);
293 std::vector<TrajectoryMeasurement> tid3measurements;
294 if(useDL.at(4) && useTID) tid3measurements = layerMeasurements.
measurements(*tid3,initialTSOS,*thePropagator,*theEstimator);
296 for(std::vector<TrajectoryMeasurement>::const_iterator tmIter = tid1measurements.begin(); tmIter != tid1measurements.end(); ++ tmIter){
297 if(tid1MHC < tidMaxHits_){
299 const SiStripMatchedRecHit2D* matchedHit = matchedHitConverter(hit);
301 GlobalPoint position = trackerGeometryHandle->idToDet(matchedHit->geographicalId())->surface().toGlobal(matchedHit->localPosition());
302 if(preselection(position, superCluster, phiVsRSlope, 2)){
305 layer1Hits_.push_back(matchedHit);
307 layer2Hits_.push_back(matchedHit);
309 }
else if(useDL.at(8) && tid1BHC < monoMaxHits_){
310 const SiStripRecHit2D* backupHit = backupHitConverter(hit);
312 GlobalPoint position = trackerGeometryHandle->idToDet(backupHit->geographicalId())->surface().toGlobal(backupHit->localPosition());
313 if(preselection(position, superCluster, phiVsRSlope, 4) && position.
perp() > 37.){
316 backupLayer2Hits_.push_back(backupHit);
323 for(std::vector<TrajectoryMeasurement>::const_iterator tmIter = tid2measurements.begin(); tmIter != tid2measurements.end(); ++ tmIter){
324 if(tid2MHC < tidMaxHits_){
326 const SiStripMatchedRecHit2D* matchedHit = matchedHitConverter(hit);
328 GlobalPoint position = trackerGeometryHandle->idToDet(matchedHit->geographicalId())->surface().toGlobal(matchedHit->localPosition());
329 if(preselection(position, superCluster, phiVsRSlope, 2)){
332 layer1Hits_.push_back(matchedHit);
334 layer2Hits_.push_back(matchedHit);
336 }
else if(useDL.at(8) && tid2BHC < monoMaxHits_){
337 const SiStripRecHit2D* backupHit = backupHitConverter(hit);
339 GlobalPoint position = trackerGeometryHandle->idToDet(backupHit->geographicalId())->surface().toGlobal(backupHit->localPosition());
340 if(preselection(position, superCluster, phiVsRSlope, 4) && position.
perp() > 37.){
343 backupLayer2Hits_.push_back(backupHit);
350 for(std::vector<TrajectoryMeasurement>::const_iterator tmIter = tid3measurements.begin(); tmIter != tid3measurements.end(); ++ tmIter){
351 if(tid3MHC < tidMaxHits_){
353 const SiStripMatchedRecHit2D* matchedHit = matchedHitConverter(hit);
355 GlobalPoint position = trackerGeometryHandle->idToDet(matchedHit->geographicalId())->surface().toGlobal(matchedHit->localPosition());
356 if(preselection(position, superCluster, phiVsRSlope, 2)){
359 layer1Hits_.push_back(matchedHit);
361 layer2Hits_.push_back(matchedHit);
363 }
else if(useDL.at(8) && tid3BHC < monoMaxHits_){
364 const SiStripRecHit2D* backupHit = backupHitConverter(hit);
366 GlobalPoint position = trackerGeometryHandle->idToDet(backupHit->geographicalId())->surface().toGlobal(backupHit->localPosition());
367 if(preselection(position, superCluster, phiVsRSlope, 4) && position.
perp() > 37.){
370 backupLayer2Hits_.push_back(backupHit);
377 std::vector<TrajectoryMeasurement> tec1measurements;
378 if(useDL.at(5)) tec1measurements = layerMeasurements.
measurements(*tec1,initialTSOS,*thePropagator,*theEstimator);
379 std::vector<TrajectoryMeasurement> tec2measurements;
380 if(useDL.at(6)) tec2measurements = layerMeasurements.
measurements(*tec2,initialTSOS,*thePropagator,*theEstimator);
381 std::vector<TrajectoryMeasurement> tec3measurements;
382 if(useDL.at(7)) tec3measurements = layerMeasurements.
measurements(*tec3,initialTSOS,*thePropagator,*theEstimator);
384 for(std::vector<TrajectoryMeasurement>::const_iterator tmIter = tec1measurements.begin(); tmIter != tec1measurements.end(); ++ tmIter){
385 if(tec1MHC < tecMaxHits_){
387 const SiStripMatchedRecHit2D* matchedHit = matchedHitConverter(hit);
389 GlobalPoint position = trackerGeometryHandle->idToDet(matchedHit->geographicalId())->surface().toGlobal(matchedHit->localPosition());
390 if(preselection(position, superCluster, phiVsRSlope, 3)){
393 layer1Hits_.push_back(matchedHit);
395 layer2Hits_.push_back(matchedHit);
401 for(std::vector<TrajectoryMeasurement>::const_iterator tmIter = tec2measurements.begin(); tmIter != tec2measurements.end(); ++ tmIter){
402 if(tec2MHC < tecMaxHits_){
404 const SiStripMatchedRecHit2D* matchedHit = matchedHitConverter(hit);
406 GlobalPoint position = trackerGeometryHandle->idToDet(matchedHit->geographicalId())->surface().toGlobal(matchedHit->localPosition());
407 if(preselection(position, superCluster, phiVsRSlope, 3)){
410 layer1Hits_.push_back(matchedHit);
412 layer2Hits_.push_back(matchedHit);
418 for(std::vector<TrajectoryMeasurement>::const_iterator tmIter = tec3measurements.begin(); tmIter != tec3measurements.end(); ++ tmIter){
419 if(tec3MHC < tecMaxHits_){
421 const SiStripMatchedRecHit2D* matchedHit = matchedHitConverter(hit);
423 GlobalPoint position = trackerGeometryHandle->idToDet(matchedHit->geographicalId())->surface().toGlobal(matchedHit->localPosition());
424 if(preselection(position, superCluster, phiVsRSlope, 3)){
427 layer2Hits_.push_back(matchedHit);
434 if( hasLay1Hit && hasLay2Hit ){
436 for (std::vector<const SiStripMatchedRecHit2D*>::const_iterator hit1 = layer1Hits_.begin() ; hit1!= layer1Hits_.end(); ++hit1) {
437 for (std::vector<const SiStripMatchedRecHit2D*>::const_iterator hit2 = layer2Hits_.begin() ; hit2!= layer2Hits_.end(); ++hit2) {
439 if(seedCounter < maxSeeds_){
441 if(checkHitsAndTSOS(hit1,hit2,scr,scz,pT,scEta)) {
447 SiStripMatchedRecHit2D *
hit;
448 hit=
new SiStripMatchedRecHit2D(*(dynamic_cast <const SiStripMatchedRecHit2D *> (*hit1) ) );
449 recHits_.push_back(hit);
450 hit=
new SiStripMatchedRecHit2D(*(dynamic_cast <const SiStripMatchedRecHit2D *> (*hit2) ) );
451 recHits_.push_back(hit);
457 result.push_back(seed);
471 if(hasLay1Hit && hasBackupHit && seedCounter == 0){
473 for (std::vector<const SiStripMatchedRecHit2D*>::const_iterator hit1 = layer1Hits_.begin() ; hit1!= layer1Hits_.end(); ++hit1) {
474 for (std::vector<const SiStripRecHit2D*>::const_iterator hit2 = backupLayer2Hits_.begin() ; hit2!= backupLayer2Hits_.end(); ++hit2) {
476 if(seedCounter < maxSeeds_){
478 if(altCheckHitsAndTSOS(hit1,hit2,scr,scz,pT,scEta)) {
484 SiStripMatchedRecHit2D *innerHit;
485 innerHit=
new SiStripMatchedRecHit2D(*(dynamic_cast <const SiStripMatchedRecHit2D *> (*hit1) ) );
486 recHits_.push_back(innerHit);
487 SiStripRecHit2D *outerHit;
488 outerHit=
new SiStripRecHit2D(*(dynamic_cast <const SiStripRecHit2D *> (*hit2) ) );
489 recHits_.push_back(outerHit);
495 result.push_back(seed);
512 std::vector<const SiStripMatchedRecHit2D*>::const_iterator hit2,
513 double rc,
double zc,
double pT,
double scEta) {
515 bool seedCutsSatisfied =
false;
520 double r1 =
sqrt(hit1Pos.x()*hit1Pos.x() + hit1Pos.y()*hit1Pos.y());
521 double phi1 = hit1Pos.phi();
522 double z1=hit1Pos.z();
525 double r2 =
sqrt(hit2Pos.x()*hit2Pos.x() + hit2Pos.y()*hit2Pos.y());
526 double phi2 = hit2Pos.phi();
527 double z2 = hit2Pos.z();
533 double curv = pT*100*.877;
536 double a = (
r2-
r1)/(2*curv);
539 double phiMissHit2=0;
543 double zMissHit2 = z2 - (
r2*(zc-z1)-
r1*zc+rc*z1)/(rc-
r1);
545 double rPredHit2 =
r1 + (rc-
r1)/(zc-z1)*(z2-z1);
546 double rMissHit2 =
r2 - rPredHit2;
553 if(zVar1 > 75 && zVar1 < 95 && (zVar2 > 18 || zVar2 < 5)) zDiff =
false;
554 if(zVar1 > 100 && zVar1 < 110 && (zVar2 > 35 || zVar2 < 5)) zDiff =
false;
555 if(zVar1 > 125 && zVar1 < 150 && (zVar2 > 18 || zVar2 < 5)) zDiff =
false;
557 if(subdetector == 1){
559 if(
r1 > 23 && r1 < 28 && r2 > 31 &&
r2 < 37) tibExtraCut = 1;
561 }
else if(subdetector == 2){
563 if(
r1 > 23 && r1 < 34 && r2 > 26 &&
r2 < 42) tidExtraCut = 1;
565 }
else if(subdetector == 3){
567 if(
r1 > 23 && r1 < 32 && r2 > 26 &&
r2 < 42) tecExtraCut = 1;
573 if(!seedCutsSatisfied)
return false;
587 double vertexZ = z1 - (
r1 * (zc - z1) ) / (rc -
r1);
593 float nomField = bfield->nominalValue();
596 FastHelix helix(hit2Pos,hit1Pos,eleVertex,nomField,&*bfield);
597 if (!helix.
isValid())
return false;
600 TSOS propagatedState =
thePropagator->propagate(fts,hit1Trans->det()->surface());
602 if (!propagatedState.isValid())
return false;
604 TSOS updatedState =
theUpdator->update(propagatedState, *hit1Trans);
605 TSOS propagatedState_out =
thePropagator->propagate(fts,hit2Trans->det()->surface()) ;
607 if (!propagatedState_out.isValid())
return false;
611 TSOS updatedState_out =
theUpdator->update(propagatedState_out, *hit2Trans);
619 std::vector<const SiStripRecHit2D*>::const_iterator hit2,
620 double rc,
double zc,
double pT,
double scEta) {
622 bool seedCutSatisfied =
false;
627 double r1 =
sqrt(hit1Pos.x()*hit1Pos.x() + hit1Pos.y()*hit1Pos.y());
628 double phi1 = hit1Pos.phi();
629 double z1=hit1Pos.z();
632 double r2 =
sqrt(hit2Pos.x()*hit2Pos.x() + hit2Pos.y()*hit2Pos.y());
633 double phi2 = hit2Pos.phi();
634 double z2 = hit2Pos.z();
640 double curv = pT*100*.877;
643 double a = (
r2-
r1)/(2*curv);
645 double phiMissHit2 = 0;
653 if(!seedCutSatisfied)
return false;
668 double vertexZ = z1 - (
r1 * (zc - z1) ) / (rc -
r1);
674 float nomField = bfield->nominalValue();
677 FastHelix helix(hit2Pos,hit1Pos,eleVertex,nomField,&*bfield);
678 if (!helix.
isValid())
return false;
681 TSOS propagatedState =
thePropagator->propagate(fts,hit1Trans->det()->surface());
683 if (!propagatedState.isValid())
return false;
685 TSOS updatedState =
theUpdator->update(propagatedState, *hit1Trans);
686 TSOS propagatedState_out =
thePropagator->propagate(fts,hit2Trans->det()->surface()) ;
688 if (!propagatedState_out.isValid())
return false;
692 TSOS updatedState_out =
theUpdator->update(propagatedState_out, *hit2Trans);
701 double r = position.
perp();
702 double phi = position.
phi();
703 double z = position.
z();
704 double scr = superCluster.
perp();
705 double scphi = superCluster.
phi();
706 double scz = superCluster.
z();
708 double deltaPsi = psi - (scr-
r)*phiVsRSlope;
709 double antiDeltaPsi = psi - (r-scr)*phiVsRSlope;
716 double originZ = (scr*z - r*scz)/(scr-r);
722 }
else if(hitLayer == 2){
724 }
else if(hitLayer == 3){
726 }
else if(hitLayer == 4){
749 const SiStripMatchedRecHit2D* matchedHit =
dynamic_cast<const SiStripMatchedRecHit2D*
>(trh);
755 const SiStripRecHit2D* backupHit =
dynamic_cast<const SiStripRecHit2D*
>(trh);
762 if(variable > 0 && variable < 1.8){
763 useDetLayer.push_back(
true);
765 useDetLayer.push_back(
false);
767 if(variable > 0 && variable < 1.5){
768 useDetLayer.push_back(
true);
770 useDetLayer.push_back(
false);
772 if(variable > 1 && variable < 2.1){
773 useDetLayer.push_back(
true);
775 useDetLayer.push_back(
false);
777 if(variable > 1 && variable < 2.2){
778 useDetLayer.push_back(
true);
780 useDetLayer.push_back(
false);
782 if(variable > 1 && variable < 2.3){
783 useDetLayer.push_back(
true);
785 useDetLayer.push_back(
false);
787 if(variable > 1.8 && variable < 2.5){
788 useDetLayer.push_back(
true);
790 useDetLayer.push_back(
false);
792 if(variable > 1.8 && variable < 2.5){
793 useDetLayer.push_back(
true);
795 useDetLayer.push_back(
false);
797 if(variable > 1.8 && variable < 2.5){
798 useDetLayer.push_back(
true);
800 useDetLayer.push_back(
false);
802 if(variable > 1.2 && variable < 1.6){
803 useDetLayer.push_back(
true);
805 useDetLayer.push_back(
false);
void setCaloCluster(const CaloClusterRef &, unsigned char hitsMask=0, int subDet2=0, int subDet1=0, float hoe1=std::numeric_limits< float >::infinity(), float hoe2=std::numeric_limits< float >::infinity())
T getParameter(std::string const &) const
unsigned long long cacheIdentifier() const
std::vector< TrajectoryMeasurement > measurements(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
bool checkHitsAndTSOS(std::vector< const SiStripMatchedRecHit2D * >::const_iterator hit1, std::vector< const SiStripMatchedRecHit2D * >::const_iterator hit2, double scr, double scz, double pT, double scEta)
virtual void update(const edm::Event &) const =0
double tidPhiMissHit2Cut_
std::vector< bool > useDetLayer(double scEta)
SiStripElectronSeedGenerator(const edm::ParameterSet &)
double monoPhiMissHit2Cut_
Sin< T >::type sin(const T &t)
std::string theMeasurementTrackerName
const MeasurementTracker * theMeasurementTracker
Geom::Phi< T > phi() const
edm::ESHandle< MagneticField > theMagField
bool exists(std::string const ¶meterName) const
checks if a parameter exists
Chi2MeasurementEstimator * theEstimator
const SiStripMatchedRecHit2D * matchedHitConverter(ConstRecHitPointer crhp)
static int position[TOTALCHAMBERS][3]
std::map< std::string, int, std::less< std::string > > psi
double tibPhiMissHit2Cut_
Cos< T >::type cos(const T &t)
const edm::EventSetup * theSetup
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
edm::ESHandle< TrackerGeometry > trackerGeometryHandle
tuple Chi2MeasurementEstimator
unsigned long long cacheIDTrkGeom_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
edm::Handle< reco::BeamSpot > theBeamSpot
PropagatorWithMaterial * thePropagator
int whichSubdetector(std::vector< const SiStripMatchedRecHit2D * >::const_iterator hit)
bool preselection(GlobalPoint position, GlobalPoint superCluster, double phiVsRSlope, int hitLayer)
TrajectoryStateOnSurface TSOS
unsigned long long cacheIDCkfComp_
const SiStripRecHit2D * backupHitConverter(ConstRecHitPointer crhp)
bool altCheckHitsAndTSOS(std::vector< const SiStripMatchedRecHit2D * >::const_iterator hit1, std::vector< const SiStripRecHit2D * >::const_iterator hit2, double scr, double scz, double pT, double scEta)
void setupES(const edm::EventSetup &setup)
XYZPointD XYZPoint
point in space with cartesian internal representation
const SiStripRecHitMatcher * theMatcher_
T const * product() const
void findSeedsFromCluster(edm::Ref< reco::SuperClusterCollection >, edm::Handle< reco::BeamSpot >, reco::ElectronSeedCollection &)
~SiStripElectronSeedGenerator()
double tecPhiMissHit2Cut_
double phiDiff(double phi1, double phi2)
PTrajectoryStateOnDet pts_
std::vector< BarrelDetLayer * > const & tibLayers() const
edm::ESHandle< MeasurementTracker > measurementTrackerHandle
void run(edm::Event &, const edm::EventSetup &setup, const edm::Handle< reco::SuperClusterCollection > &, reco::ElectronSeedCollection &)
GlobalTrajectoryParameters stateAtVertex() const
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
Power< A, B >::type pow(const A &a, const B &b)
edm::InputTag beamSpotTag_
unsigned long long cacheIDMagField_