197 std::multimap<float, edm::Ptr<reco::ConversionTrack> > convTrackMap;
199 for (
size_t i = 0;
i < trackCollectionHandle->size(); ++
i)
200 trackPtrVector.
push_back(trackCollectionHandle->ptrAt(
i));
203 convTrackMap.insert(std::make_pair((*tk_ref)->track()->eta(),*tk_ref));
210 if (!vertexHandle.isValid()) {
212 <<
"Error! Can't get the product primary Vertex Collection "<<
"\n";
235 std::multimap<double, reco::CaloClusterPtr> basicClusterPtrs;
236 std::multimap<double, reco::CaloClusterPtr> superClusterPtrs;
241 buildCollection( iEvent, iSetup, convTrackMap, superClusterPtrs, basicClusterPtrs, the_pvtx, outputConvPhotonCollection);
243 outputConvPhotonCollection_p->assign(outputConvPhotonCollection.begin(), outputConvPhotonCollection.end());
250 std::multimap<double, reco::CaloClusterPtr>& basicClusterPtrs,
251 std::multimap<double, reco::CaloClusterPtr>& superClusterPtrs){
256 if (!scBarrelHandle.
isValid()) {
258 <<
"Error! Can't get the barrel superclusters!";
264 if (!scEndcapHandle.
isValid()) {
266 <<
"Error! Can't get the endcap superclusters!";
274 if (!bcBarrelHandle.
isValid()) {
276 <<
"Error! Can't get the barrel basic clusters!";
280 if (! bcEndcapHandle.
isValid()) {
282 <<
"Error! Can't get the endcap basic clusters!";
289 for (
unsigned jj = 0;
jj < 2; ++
jj ){
290 for (
unsigned ii = 0;
ii < bcHandle->size(); ++
ii ) {
292 basicClusterPtrs.insert(std::make_pair(bcHandle->ptrAt(
ii)->position().eta(), bcHandle->ptrAt(
ii)));
294 bcHandle = bcEndcapHandle;
300 for (
unsigned jj = 0;
jj < 2; ++
jj ){
301 for (
unsigned ii = 0;
ii < scHandle->size(); ++
ii ) {
303 superClusterPtrs.insert(std::make_pair(scHandle->ptrAt(
ii)->position().eta(), scHandle->ptrAt(
ii)));
305 scHandle = scEndcapHandle;
315 const std::multimap<double, reco::CaloClusterPtr>& superClusterPtrs,
316 const std::multimap<double, reco::CaloClusterPtr>& basicClusterPtrs,
343 std::map<edm::Ptr<reco::ConversionTrack>,
math::XYZPointF> trackImpactPosition;
352 const reco::Track* tk = tk_ref->second->trackRef().get() ;
358 trackImpactPosition[tk_ref->second] = ew;
363 trackMatchedBC[tk_ref->second] = closest_bc;
374 bool track1HighPurity=
true;
383 if (dynamic_cast<const reco::GsfTrack*>(left.
get())) {
396 if (!(
trackD0Cut(left, the_pvtx))) track1HighPurity=
false;
398 if (!(
trackD0Cut(left))) track1HighPurity=
false;
401 std::vector<int> right_candidates;
402 std::vector<double> right_candidate_theta, right_candidate_approach;
403 std::vector<std::pair<bool, reco::Vertex> > vertex_candidates;
407 std::multimap<float, edm::Ptr<reco::ConversionTrack> >::const_iterator
rr = ll;
409 for (; rr !=
allTracks.lower_bound(etasearch); ++
rr ) {
410 bool track2HighPurity =
true;
411 bool highPurityPair =
true;
418 if (dynamic_cast<const reco::GsfTrack*>(right.
get())) {
438 double approachDist = -999.;
463 highPurityPair=
false;
467 if (!(
trackD0Cut(right, the_pvtx))) track2HighPurity=
false;
469 if (!(
trackD0Cut(right))) track2HighPurity=
false;
474 std::vector<edm::RefToBase<reco::Track> > trackPairRef;
475 trackPairRef.push_back(left);
476 trackPairRef.push_back(right);
478 std::vector<math::XYZVectorF> trackPin;
479 std::vector<math::XYZVectorF> trackPout;
480 std::vector<math::XYZPointF> trackInnPos;
481 std::vector<uint8_t> nHitsBeforeVtx;
482 std::vector<Measurement1DFloat> dlClosestHitToVtx;
493 if (ll->second->trajRef().isNonnull() && rr->second->trajRef().isNonnull()) {
494 std::pair<uint8_t,Measurement1DFloat> leftWrongHits = hitChecker.
nHitsBeforeVtx(*ll->second->trajRef().get(),theConversionVertex);
495 std::pair<uint8_t,Measurement1DFloat> rightWrongHits = hitChecker.
nHitsBeforeVtx(*rr->second->trajRef().get(),theConversionVertex);
496 nHitsBeforeVtx.push_back(leftWrongHits.first);
497 nHitsBeforeVtx.push_back(rightWrongHits.first);
498 dlClosestHitToVtx.push_back(leftWrongHits.second);
499 dlClosestHitToVtx.push_back(rightWrongHits.second);
506 if (theConversionVertex.
isValid()){
508 if (chi2Prob<
vtxChi2_) highPurityPair=
false;
512 std::vector<math::XYZPointF> trkPositionAtEcal;
513 std::vector<reco::CaloClusterPtr> matchingBC;
519 std::map<edm::Ptr<reco::ConversionTrack>,
math::XYZPointF>::const_iterator trackImpactPositionLeft = trackImpactPosition.find(ll->second);
520 std::map<edm::Ptr<reco::ConversionTrack>,
math::XYZPointF>::const_iterator trackImpactPositionRight = trackImpactPosition.find(rr->second);
521 std::map<edm::Ptr<reco::ConversionTrack>,
reco::CaloClusterPtr>::const_iterator trackMatchedBCLeft = trackMatchedBC.find(ll->second);
522 std::map<edm::Ptr<reco::ConversionTrack>,
reco::CaloClusterPtr>::const_iterator trackMatchedBCRight = trackMatchedBC.find(rr->second);
524 if (trackImpactPositionLeft!=trackImpactPosition.end()) {
525 trkPositionAtEcal.push_back(trackImpactPositionLeft->second);
530 if (trackImpactPositionRight!=trackImpactPosition.end()) {
531 trkPositionAtEcal.push_back(trackImpactPositionRight->second);
534 double total_e_bc = 0.;
535 if (trackMatchedBCLeft!=trackMatchedBC.end()) {
536 matchingBC.push_back(trackMatchedBCLeft->second);
537 total_e_bc += trackMatchedBCLeft->second->energy();
542 if (trackMatchedBCRight!=trackMatchedBC.end()) {
543 matchingBC.push_back(trackMatchedBCRight->second);
544 total_e_bc += trackMatchedBCRight->second->energy();
548 highPurityPair =
false;
554 highPurityPair = highPurityPair && track1HighPurity && track2HighPurity && goodVertex &&
checkPhi(left, right, trackerGeom, magField, theConversionVertex) ;
568 const float minAppDist = approachDist;
572 reco::Conversion newCandidate(scPtrVec, trackPairRef, trkPositionAtEcal, theConversionVertex, matchingBC, minAppDist, trackInnPos, trackPin, trackPout, nHitsBeforeVtx, dlClosestHitToVtx, nSharedHits, dummy, algo );
574 if (
matchingSC ( superClusterPtrs, newCandidate, scPtrVec) )
580 bool generalTracksOnly = ll->second->isTrackerOnly() && rr->second->isTrackerOnly() && !
dynamic_cast<const reco::GsfTrack*
>(ll->second->trackRef().get()) && !dynamic_cast<const reco::GsfTrack*>(rr->second->trackRef().get());
581 bool arbitratedEcalSeeded = ll->second->isArbitratedEcalSeeded() && rr->second->isArbitratedEcalSeeded();
582 bool arbitratedMerged = ll->second->isArbitratedMerged() && rr->second->isArbitratedMerged();
583 bool arbitratedMergedEcalGeneral = ll->second->isArbitratedMergedEcalGeneral() && rr->second->isArbitratedMergedEcalGeneral();
590 outputConvPhotonCollection.push_back(newCandidate);
650 -barrelHalfLength, barrelHalfLength)));
661 stateAtECAL = propag.
propagate(myTSOS, *theBarrel_);
665 stateAtECAL = propag.
propagate(myTSOS, *thePositiveEtaEndcap_);
667 stateAtECAL = propag.
propagate(myTSOS, *theNegativeEtaEndcap_);
690 for (std::multimap<double, reco::CaloClusterPtr>::const_iterator scItr = scMap.begin(); scItr != scMap.end(); scItr++) {
693 double sceta = sc->eta();
695 const double delta_eta = fabs(conveta - sceta);
696 if ( fabs(delta_eta) < fabs(detaMin) && fabs(delta_phi) < fabs(dphiMin) ) {
697 detaMin= fabs(delta_eta);
698 dphiMin= fabs(delta_phi);
713 const double track_eta = trackImpactPosition.eta();
714 const double track_phi = trackImpactPosition.phi();
716 double min_eta = 999., min_phi = 999.;
718 for (std::multimap<double, reco::CaloClusterPtr>::const_iterator bc = bcMap.lower_bound(track_eta -
halfWayEta_);
719 bc != bcMap.upper_bound(track_eta +
halfWayEta_); ++bc){
721 const double delta_eta = track_eta-(ebc->position().eta());
724 if (fabs(min_eta)>fabs(delta_eta) && fabs(min_phi)>fabs(delta_phi)){
727 closest_bc = bc->second;
734 closestBC = closest_bc;
759 double recoPhoR = vtx.
position().Rho();
771 stateAtVtx1 = propag.
propagate(myTSOS1, *theBarrel_);
773 stateAtVtx1 = propag.
propagate(myTSOS1, *theDisk_);
778 stateAtVtx2 = propag.
propagate(myTSOS2, *theBarrel_);
780 stateAtVtx2 = propag.
propagate(myTSOS2, *theDisk_);
822 double rho = tangentPoint.
perp();
833 std::pair<GlobalTrajectoryParameters,GlobalTrajectoryParameters> trajs = tangent.
trajectoryParameters();
836 if (
std::abs(trajs.first.position().z() - trajs.second.position().z()) >
dzCut_) {
841 float minApproach = tangent.
perpdist();
842 appDist = minApproach;
862 double total_e_bc = 0;
863 if (bc_l.
isNonnull()) total_e_bc += bc_l->energy();
866 total_e_bc += bc_r->energy();
882 std::vector<reco::TransientTrack> pair;
883 pair.push_back(ttk_l);
884 pair.push_back(ttk_r);
898 const float PI = 3.1415927;
901 const float R_ECAL = 136.5;
908 float ZEcal = R_ECAL*sinh(EtaParticle)+Zvertex;
910 if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal);
911 if(Theta<0.0) Theta = Theta+
PI ;
914 if( fabs(ETA) > etaBarrelEndcap )
917 if(EtaParticle<0.0 ) Zend = -Zend ;
918 float Zlen = Zend - Zvertex ;
919 float RR = Zlen/sinh(EtaParticle);
920 Theta = atan(RR/Zend);
921 if(Theta<0.0) Theta = Theta+
PI ;
922 ETA = -
log(
tan(0.5*Theta));
value_type const * get() const
T getParameter(std::string const &) const
unsigned int maxNumOfTrackInPU_
ConversionVertexFinder * theVertexFinder_
virtual FreeTrajectoryState propagate(const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest) const final
double d0Error() const
error on d0
edm::EDGetTokenT< reco::VertexCollection > vertexProducer_
double delta_eta(double eta1, double eta2)
bool isNonnull() const
Checks for non-null.
TransientVertex run(const std::vector< reco::TransientTrack > &pair)
static float barrelHalfLength()
double d0() const
dxy parameter in perigee convention (d0 = -dxy)
bool getTrackImpactPosition(const reco::Track *tk_ref, const TrackerGeometry *trackerGeom, const MagneticField *magField, math::XYZPointF &ew)
const TrackExtraRef & extra() const
reference to "extra" object
std::pair< GlobalTrajectoryParameters, GlobalTrajectoryParameters > trajectoryParameters() const
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
double dxyError() const
error on dxy
void push_back(Ptr< T > const &iPtr)
std::pair< uint8_t, Measurement1DFloat > nHitsBeforeVtx(const Trajectory &traj, const reco::Vertex &vtx, double sigmaTolerance=3.0) const
const TransientTrackBuilder * thettbuilder_
void setQuality(ConversionQuality q, bool b)
bool isValid() const
Tells whether the vertex is valid.
Geom::Phi< T > phi() const
Global3DPoint GlobalPoint
void buildCollection(edm::Event &iEvent, const edm::EventSetup &iSetup, const std::multimap< float, edm::Ptr< reco::ConversionTrack > > &allTracks, const std::multimap< double, reco::CaloClusterPtr > &superClusterPtrs, const std::multimap< double, reco::CaloClusterPtr > &basicClusterPtrs, const reco::Vertex &the_pvtx, reco::ConversionCollection &outputConvPhotonCollection)
reco::TransientTrack build(const reco::Track *p) const
double zOfPrimaryVertexFromTracks(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
static ConversionAlgorithm algoByName(const std::string &name)
void buildSuperAndBasicClusterGeoMap(const edm::Event &, std::multimap< double, reco::CaloClusterPtr > &basicClusterPtrs, std::multimap< double, reco::CaloClusterPtr > &superClusterPtrs)
GlobalPoint globalPosition() const
std::vector< Vertex > VertexCollection
collection of Vertex objects
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
const Point & position() const
position
math::XYZVectorF refittedPairMomentum() const
Conversion tracks momentum from the tracks refitted with vertex constraint.
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
TrajectoryStateOnSurface innermostMeasurementState() const
bool matchingSC(const std::multimap< double, reco::CaloClusterPtr > &scMap, reco::Conversion &conv, reco::CaloClusterPtrVector &mSC)
virtual GlobalPoint crossingPoint() const
virtual GlobalPoint crossingPoint() const
const math::XYZPoint & innerPosition() const
position of the innermost hit
TrackAlgorithm algo() const
static float endcapRadius()
double dPhi(double phi1, double phi2)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
math::XYZVectorF toFConverterV(const math::XYZVector &val)
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
double chi2() const
chi-squares
float ChiSquaredProbability(double chiSquared, double nrDOF)
edm::EDGetTokenT< edm::View< reco::CaloCluster > > scEndcapProducer_
edm::EDGetTokenT< edm::View< reco::CaloCluster > > bcBarrelCollection_
edm::EDGetTokenT< edm::View< reco::CaloCluster > > bcEndcapCollection_
uint8_t nSharedHits(const reco::Track &trk1, const reco::Track &trk2) const
bool getMatchedBC(const std::multimap< double, reco::CaloClusterPtr > &bcMap, const math::XYZPointF &trackImpactPosition, reco::CaloClusterPtr &closestBC)
double delta_phi(double ph11, double phi2)
bool isNonnull() const
Checks for non-null.
bool checkTrackPair(const std::pair< edm::RefToBase< reco::Track >, reco::CaloClusterPtr > &ll, const std::pair< edm::RefToBase< reco::Track >, reco::CaloClusterPtr > &rr)
bool trackQualityFilter(const edm::RefToBase< reco::Track > &ref, bool isLeft)
double deltaPhi(double phi1, double phi2)
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
const Track & track() const
double dPhicutForSCmatching_
bool trackD0Cut(const edm::RefToBase< reco::Track > &ref)
REF castTo() const
cast to a concrete type
T const * product() const
bool bypassPreselEcalEcal_
std::string ConvertedPhotonCollection_
static const float etaBarrelEndcap
static const float Z_Endcap
edm::EDGetTokenT< edm::View< reco::ConversionTrack > > src_
edm::EDGetTokenT< edm::View< reco::CaloCluster > > scBarrelProducer_
virtual bool status() const
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
unsigned short found() const
Number of valid hits on track.
static const float R_ECAL
double etaTransformation(float EtaParticle, float Zvertex)
int charge() const
track electric charge
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
math::XYZPointF toFConverterP(const math::XYZPoint &val)
virtual void produce(edm::Event &, const edm::EventSetup &)
bool preselectTrackPair(const reco::TransientTrack &ttk_l, const reco::TransientTrack &ttk_r, double &appDist)
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
void setMatchingSuperCluster(const reco::CaloClusterPtrVector &sc)
bool checkPhi(const edm::RefToBase< reco::Track > &tk_l, const edm::RefToBase< reco::Track > &tk_r, const TrackerGeometry *trackerGeom, const MagneticField *magField, const reco::Vertex &the_vertex)
virtual bool status() const
static float barrelRadius()
double dEtacutForSCmatching_
GlobalVector globalDirection() const
ConversionProducer(const edm::ParameterSet &)
bool checkVertex(const reco::TransientTrack &ttk_l, const reco::TransientTrack &ttk_r, const MagneticField *magField, reco::Vertex &the_vertex)