188 auto outputConvPhotonCollection_p = std::make_unique<reco::ConversionCollection>();
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));
212 <<
"Error! Can't get the product primary Vertex Collection "<<
"\n";
216 vertexCollection = *(vertexHandle.
product());
225 if (!vertexCollection.empty())
226 the_pvtx = *(vertexCollection.begin());
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.;
451 bool goodVertex =
checkVertex(ttk_l, ttk_r, magField, theConversionVertex);
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 nHitsBeforeVtx.push_back(leftWrongHits.first);
494 nHitsBeforeVtx.push_back(rightWrongHits.first);
495 dlClosestHitToVtx.push_back(leftWrongHits.second);
496 dlClosestHitToVtx.push_back(rightWrongHits.second);
503 if (theConversionVertex.
isValid()){
505 if (chi2Prob<
vtxChi2_) highPurityPair=
false;
509 std::vector<math::XYZPointF> trkPositionAtEcal;
510 std::vector<reco::CaloClusterPtr> matchingBC;
516 std::map<edm::Ptr<reco::ConversionTrack>,
math::XYZPointF>::const_iterator trackImpactPositionLeft = trackImpactPosition.find(ll->second);
517 std::map<edm::Ptr<reco::ConversionTrack>,
math::XYZPointF>::const_iterator trackImpactPositionRight = trackImpactPosition.find(rr->second);
518 std::map<edm::Ptr<reco::ConversionTrack>,
reco::CaloClusterPtr>::const_iterator trackMatchedBCLeft = trackMatchedBC.find(ll->second);
519 std::map<edm::Ptr<reco::ConversionTrack>,
reco::CaloClusterPtr>::const_iterator trackMatchedBCRight = trackMatchedBC.find(rr->second);
521 if (trackImpactPositionLeft!=trackImpactPosition.end()) {
522 trkPositionAtEcal.push_back(trackImpactPositionLeft->second);
527 if (trackImpactPositionRight!=trackImpactPosition.end()) {
528 trkPositionAtEcal.push_back(trackImpactPositionRight->second);
531 double total_e_bc = 0.;
532 if (trackMatchedBCLeft!=trackMatchedBC.end()) {
533 matchingBC.push_back(trackMatchedBCLeft->second);
534 total_e_bc += trackMatchedBCLeft->second->energy();
539 if (trackMatchedBCRight!=trackMatchedBC.end()) {
540 matchingBC.push_back(trackMatchedBCRight->second);
541 total_e_bc += trackMatchedBCRight->second->energy();
545 highPurityPair =
false;
551 highPurityPair = highPurityPair && track1HighPurity && track2HighPurity && goodVertex &&
checkPhi(left, right, trackerGeom, magField, theConversionVertex) ;
565 const float minAppDist = approachDist;
569 reco::Conversion newCandidate(scPtrVec, trackPairRef, trkPositionAtEcal, theConversionVertex, matchingBC, minAppDist, trackInnPos, trackPin, trackPout, nHitsBeforeVtx, dlClosestHitToVtx, nSharedHits, dummy, algo );
571 if (
matchingSC ( superClusterPtrs, newCandidate, scPtrVec) )
577 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());
578 bool arbitratedEcalSeeded = ll->second->isArbitratedEcalSeeded() && rr->second->isArbitratedEcalSeeded();
579 bool arbitratedMerged = ll->second->isArbitratedMerged() && rr->second->isArbitratedMerged();
580 bool arbitratedMergedEcalGeneral = ll->second->isArbitratedMergedEcalGeneral() && rr->second->isArbitratedMergedEcalGeneral();
587 outputConvPhotonCollection.push_back(newCandidate);
647 -barrelHalfLength, barrelHalfLength)));
658 stateAtECAL = propag.
propagate(myTSOS, *theBarrel_);
662 stateAtECAL = propag.
propagate(myTSOS, *thePositiveEtaEndcap_);
664 stateAtECAL = propag.
propagate(myTSOS, *theNegativeEtaEndcap_);
687 for (std::multimap<double, reco::CaloClusterPtr>::const_iterator scItr = scMap.begin(); scItr != scMap.end(); scItr++) {
690 double sceta = sc->eta();
692 const double delta_eta = fabs(conveta - sceta);
693 if ( fabs(delta_eta) < fabs(detaMin) && fabs(delta_phi) < fabs(dphiMin) ) {
694 detaMin= fabs(delta_eta);
695 dphiMin= fabs(delta_phi);
710 const double track_eta = trackImpactPosition.eta();
711 const double track_phi = trackImpactPosition.phi();
713 double min_eta = 999., min_phi = 999.;
715 for (std::multimap<double, reco::CaloClusterPtr>::const_iterator bc = bcMap.lower_bound(track_eta -
halfWayEta_);
716 bc != bcMap.upper_bound(track_eta +
halfWayEta_); ++bc){
718 const double delta_eta = track_eta-(ebc->position().eta());
721 if (fabs(min_eta)>fabs(delta_eta) && fabs(min_phi)>fabs(delta_phi)){
724 closest_bc = bc->second;
731 closestBC = closest_bc;
756 double recoPhoR = vtx.
position().Rho();
768 stateAtVtx1 = propag.
propagate(myTSOS1, *theBarrel_);
770 stateAtVtx1 = propag.
propagate(myTSOS1, *theDisk_);
775 stateAtVtx2 = propag.
propagate(myTSOS2, *theBarrel_);
777 stateAtVtx2 = propag.
propagate(myTSOS2, *theDisk_);
819 double rho = tangentPoint.
perp();
830 std::pair<GlobalTrajectoryParameters,GlobalTrajectoryParameters> trajs = tangent.
trajectoryParameters();
833 if (
std::abs(trajs.first.position().z() - trajs.second.position().z()) >
dzCut_) {
838 float minApproach = tangent.
perpdist();
839 appDist = minApproach;
859 double total_e_bc = 0;
860 if (bc_l.
isNonnull()) total_e_bc += bc_l->energy();
863 total_e_bc += bc_r->energy();
879 std::vector<reco::TransientTrack> pair;
880 pair.push_back(ttk_l);
881 pair.push_back(ttk_r);
895 const float PI = 3.1415927;
898 const float R_ECAL = 136.5;
905 float ZEcal = R_ECAL*sinh(EtaParticle)+Zvertex;
907 if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal);
908 if(Theta<0.0) Theta = Theta+
PI ;
911 if( fabs(ETA) > etaBarrelEndcap )
914 if(EtaParticle<0.0 ) Zend = -Zend ;
915 float Zlen = Zend - Zvertex ;
916 float RR = Zlen/sinh(EtaParticle);
917 Theta = atan(RR/Zend);
918 if(Theta<0.0) Theta = Theta+
PI ;
919 ETA = -
log(
tan(0.5*Theta));
constexpr double deltaPhi(double phi1, double phi2)
value_type const * get() const
T getParameter(std::string const &) const
unsigned int maxNumOfTrackInPU_
ConversionVertexFinder * theVertexFinder_
double d0Error() const
error on d0
edm::EDGetTokenT< reco::VertexCollection > vertexProducer_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
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)
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::pair< uint8_t, Measurement1DFloat > nHitsBeforeVtx(const reco::TrackExtra &track, const reco::Vertex &vtx, float sigmaTolerance=3.0) const
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)
const_iterator begin() const
const math::XYZPoint & innerPosition() const
position of the innermost hit
TrackAlgorithm algo() const
static float endcapRadius()
bool status() const override
bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
math::XYZVectorF toFConverterV(const math::XYZVector &val)
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
const_iterator end() const
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_
bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
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)
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)
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
T const * product() const
const Track & track() const
double dPhicutForSCmatching_
bool trackD0Cut(const edm::RefToBase< reco::Track > &ref)
GlobalPoint crossingPoint() const override
bool bypassPreselEcalEcal_
std::string ConvertedPhotonCollection_
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
static const float etaBarrelEndcap
static const float Z_Endcap
edm::EDGetTokenT< edm::View< reco::ConversionTrack > > src_
edm::EDGetTokenT< edm::View< reco::CaloCluster > > scBarrelProducer_
~ConversionProducer() override
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
unsigned short found() const
Number of valid hits on track.
void produce(edm::Event &, const edm::EventSetup &) override
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)
bool status() const override
GlobalPoint crossingPoint() const override
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...
T const * product() const
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)
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)