80 edm::InputTag oitracks(oitrackprod),oitracksassoc(oitrackprod,oitrackassoc),
81 iotracks(iotrackprod), iotracksassoc(iotrackprod,iotrackassoc);
85 consumes<reco::TrackCaloClusterPtrAssociation>(oitracksassoc);
88 consumes<reco::TrackCaloClusterPtrAssociation>(iotracksassoc);
123 theLikelihoodCalc_->setWeightsFile(path_mvaWeightFile.fullPath().c_str());
170 auto outputConvPhotonCollection_p = std::make_unique<reco::ConversionCollection>();
173 auto cleanedConversionCollection_p = std::make_unique<reco::ConversionCollection>();
177 bool validBarrelSCHandle=
true;
180 if (!scBarrelHandle.
isValid()) {
182 <<
"Error! Can't get the scHybridBarrelProducer";
183 validBarrelSCHandle=
false;
187 bool validEndcapSCHandle=
true;
190 if (!scEndcapHandle.
isValid()) {
192 <<
"Error! Can't get the scIslandEndcapProducer";
193 validEndcapSCHandle=
false;
198 bool validTrackInputs=
true;
201 if (!outInTrkHandle.
isValid()) {
204 <<
"Error! Can't get the conversionOITrack " <<
"\n";
205 validTrackInputs=
false;
213 if (!outInTrkSCAssocHandle.
isValid()) {
216 <<
"Error! Can't get the outInTrackSCAssociationCollection)";
217 validTrackInputs=
false;
223 if (!inOutTrkHandle.
isValid()) {
226 <<
"Error! Can't get the conversionIOTrack " <<
"\n";
227 validTrackInputs=
false;
237 if (!generalTrkHandle.
isValid()) {
240 <<
"Error! Can't get the genralTracks " <<
"\n";
247 if (!inOutTrkSCAssocHandle.
isValid()) {
250 <<
"Error! Can't get the inOutTrackSCAssociationCollection_.c_str()";
251 validTrackInputs=
false;
260 if (!bcBarrelHandle.
isValid()) {
262 <<
"Error! Can't get the bcBarrelCollection";
269 if (!bcEndcapHandle.
isValid()) {
271 <<
"Error! Can't get the bcEndcapCollection";
283 if ( validTrackInputs ) {
285 std::vector<reco::TransientTrack> t_outInTrk = ( *theTransientTrackBuilder_ ).build(outInTrkHandle );
286 std::vector<reco::TransientTrack> t_inOutTrk = ( *theTransientTrackBuilder_ ).build(inOutTrkHandle );
291 allPairs =
theTrackPairFinder_->
run(t_outInTrk, outInTrkHandle, outInTrkSCAssocHandle, t_inOutTrk, inOutTrkHandle, inOutTrkSCAssocHandle );
294 buildCollections(theEventSetup, scBarrelHandle, bcBarrelHandle, hcalTowersHandle, generalTrkHandle, allPairs, outputConvPhotonCollection);
295 buildCollections(theEventSetup, scEndcapHandle, bcEndcapHandle, hcalTowersHandle, generalTrkHandle, allPairs, outputConvPhotonCollection);
299 outputConvPhotonCollection_p->assign(outputConvPhotonCollection.begin(),outputConvPhotonCollection.end());
307 cleanedConversionCollection);
310 cleanedConversionCollection);
313 cleanedConversionCollection_p->assign(cleanedConversionCollection.begin(),cleanedConversionCollection.end());
336 std::vector<reco::TransientTrack> t_generalTrk;
337 if (
recoverOneTrackCase_ ) t_generalTrk = ( *theTransientTrackBuilder_ ).build(generalTrkHandle );
343 for(
auto const& aClus : scHandle->ptrs())
346 if (aClus->energy()/cosh(aClus->eta()) <=
minSCEt_)
continue;
356 std::vector<edm::Ref<reco::TrackCollection> > trackPairRef;
357 std::vector<math::XYZPointF> trackInnPos;
358 std::vector<math::XYZVectorF> trackPin;
359 std::vector<math::XYZVectorF> trackPout;
360 float minAppDist=-99;
374 if ( !allPairs.empty() ) {
379 for (
std::map<std::vector<reco::TransientTrack>,
reco::CaloClusterPtr>::const_iterator iPair= allPairs.begin(); iPair!= allPairs.end(); ++iPair ) {
384 if ( !( aClus == caloPtr ) )
continue;
389 std::vector<math::XYZPointF> trkPositionAtEcal = theEcalImpactPositionFinder.
find( iPair->first, bcHandle );
390 std::vector<reco::CaloClusterPtr> matchingBC = theEcalImpactPositionFinder.
matchingBC();
395 if ( (iPair->first).size() > 1 ) {
404 edm::LogWarning(metname) <<
"cms::Exception caught in ConvertedPhotonProducer::produce\n" 429 trackPairRef.clear();
435 for ( std::vector<reco::TransientTrack>::const_iterator iTk=(iPair->first).begin(); iTk!= (iPair->first).
end(); ++iTk) {
443 trackInnPos.push_back(
toFConverterP(myTkRef->innerPosition()));
444 trackPin.push_back(
toFConverterV( myTkRef->innerMomentum()));
445 trackPout.push_back(
toFConverterV(myTkRef->outerMomentum()));
447 trackPairRef.push_back(myTkRef);
455 if( theConversionVertex.
isValid() ) {
466 reco::Conversion newCandidate(scPtrVec, trackPairRef, trkPositionAtEcal, theConversionVertex, matchingBC, minAppDist, trackInnPos, trackPin, trackPout, like, algo);
471 outputConvPhotonCollection.push_back(newCandidate);
483 trackPairRef.clear();
487 std::vector<reco::TransientTrack>::const_iterator iTk=(iPair->first).
begin();
492 trackInnPos.push_back(
toFConverterP(myTk->innerPosition()));
496 trackPairRef.push_back(myTk);
500 float theta1 = myTk->innerMomentum().Theta();
502 float dCotTheta=-999.;
504 std::vector<reco::TransientTrack>::const_iterator iGoodGenTran;
505 for ( std::vector<reco::TransientTrack>::const_iterator iTran= t_generalTrk.begin(); iTran != t_generalTrk.end(); ++iTran) {
508 if ( trRef->charge()*myTk->charge() > 0 )
continue;
509 float dEta = trRef->eta() - myTk->eta();
510 float dPhi = trRef->phi() - myTk->phi();
512 float theta2 = trRef->innerMomentum().Theta();
513 dCotTheta = 1./
tan(theta1) - 1./
tan(theta2) ;
515 if ( fabs(dCotTheta) < dCot ) {
516 dCot = fabs(dCotTheta);
528 trackInnPos.push_back(
toFConverterP(goodRef->innerPosition()));
529 trackPin.push_back(
toFConverterV(goodRef->innerMomentum()));
530 trackPout.push_back(
toFConverterV(goodRef->outerMomentum()));
531 trackPairRef.push_back( goodRef );
534 std::vector<reco::TransientTrack> mypair;
535 mypair.push_back(*iTk);
536 mypair.push_back(*iGoodGenTran);
544 edm::LogWarning(metname) <<
"cms::Exception caught in ConvertedPhotonProducer::produce\n" 554 reco::Conversion newCandidate(scPtrVec, trackPairRef, trkPositionAtEcal, theConversionVertex, matchingBC, minAppDist, trackInnPos, trackPin, trackPout, like, algo);
557 outputConvPhotonCollection.push_back(newCandidate);
589 for(
auto const& aClus : scHandle->ptrs())
592 if (aClus->energy()/cosh(aClus->eta()) <=
minSCEt_)
continue;
595 if ( conversionHandle.
isValid() ) {
598 std::vector<reco::ConversionRef> bestRef=
solveAmbiguity( conversionHandle , aClus);
600 for ( std::vector<reco::ConversionRef>::iterator iRef=bestRef.begin(); iRef!=bestRef.end(); iRef++ ) {
601 if ( iRef->isNonnull() ) {
602 newCandidate= (*iRef)->
clone();
603 outputConversionCollection.push_back(*newCandidate);
611 for(
unsigned int icp = 0; icp < conversionHandle->size(); icp++) {
613 if (!( aClus.id() == cpRef->caloCluster()[0].
id() && aClus.key() == cpRef->caloCluster()[0].
key() ))
continue;
614 if ( !cpRef->isConverted() )
continue;
615 if ( cpRef->nTracks() <2 )
continue;
616 newCandidate= (&(*cpRef))->
clone();
617 outputConversionCollection.push_back(*newCandidate);
634 std::multimap<double, reco::ConversionRef, std::greater<double> > convMap;
636 for (
unsigned int icp=0; icp< conversionHandle->size(); icp++) {
640 if (!( scRef.
id() == cpRef->caloCluster()[0].
id() && scRef.
key() == cpRef->caloCluster()[0].
key() ))
continue;
641 if ( !cpRef->isConverted() )
continue;
642 double like = cpRef->MVAout();
643 if ( cpRef->nTracks() <2 )
continue;
645 convMap.insert ( std::make_pair(like,cpRef) );
651 std::multimap<double, reco::ConversionRef>::iterator iMap;
652 std::vector<reco::ConversionRef> bestRefs;
653 for (iMap=convMap.begin(); iMap!=convMap.end(); iMap++) {
655 bestRefs.push_back( iMap->second );
672 double x1,
x2, y1, y2;
673 double xx_1 = track1->innerPosition().x(), yy_1 = track1->innerPosition().y(), zz_1 = track1->innerPosition().z();
674 double xx_2 = track2->innerPosition().x(), yy_2 = track2->innerPosition().y(), zz_2 = track2->innerPosition().z();
679 dist =
sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) - radius1 - radius2;
688 x1 = tk->innerPosition().x();
689 y1 = tk->innerPosition().y();
690 phi = tk->innerMomentum().phi();
691 const int charge = tk->charge();
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackCaloClusterPtrAssociation > outInTrackSCAssociationCollection_
edm::ESHandle< CaloGeometry > theCaloGeom_
ConversionTrackPairFinder * theTrackPairFinder_
edm::EDGetTokenT< edm::View< reco::CaloCluster > > bcEndcapCollection_
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)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const std::string metname
virtual std::string explainSelf() const
void push_back(Ptr< T > const &iPtr)
edm::EDGetTokenT< reco::TrackCollection > conversionIOTrackProducer_
edm::ESHandle< TransientTrackBuilder > theTransientTrackBuilder_
bool isValid() const
Tells whether the vertex is valid.
Sin< T >::type sin(const T &t)
ConversionVertexFinder * theVertexFinder_
Global3DPoint GlobalPoint
edm::EDGetTokenT< edm::View< reco::CaloCluster > > scIslandEndcapProducer_
std::string CleanedConvertedPhotonCollection_
static ConversionAlgorithm algoByName(const std::string &name)
void buildCollections(edm::EventSetup const &es, const edm::Handle< edm::View< reco::CaloCluster > > &scHandle, const edm::Handle< edm::View< reco::CaloCluster > > &bcHandle, const edm::Handle< CaloTowerCollection > &hcalTowersHandle, const edm::Handle< reco::TrackCollection > &trkHandle, std::map< std::vector< reco::TransientTrack >, reco::CaloClusterPtr, CompareTwoTracksVectors > &allPairs, reco::ConversionCollection &outputConvPhotonCollection)
edm::Ptr< CaloCluster > CaloClusterPtr
key_type key() const
Accessor for product key.
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
ProductID id() const
Accessor for product ID.
double minApproachDisCut_
void beginRun(edm::Run const &, const edm::EventSetup &es) final
edm::EDGetTokenT< reco::TrackCollection > generalTrackProducer_
math::XYZVectorF toFConverterV(const math::XYZVector &val)
TrackRef persistentTrackRef() const
void cleanCollections(const edm::Handle< edm::View< reco::CaloCluster > > &scHandle, const edm::OrphanHandle< reco::ConversionCollection > &conversionHandle, reco::ConversionCollection &outputCollection)
Cos< T >::type cos(const T &t)
edm::EDGetTokenT< CaloTowerCollection > hcalTowers_
Tan< T >::type tan(const T &t)
math::XYZPoint Point
point in the space
std::vector< reco::ConversionRef > solveAmbiguity(const edm::OrphanHandle< reco::ConversionCollection > &conversionHandle, reco::CaloClusterPtr const &sc)
double dRForConversionRecovery_
float calculateMinApproachDistance(const reco::TrackRef &track1, const reco::TrackRef &track2)
double energy() const
cluster energy
edm::EDGetTokenT< reco::TrackCollection > conversionOITrackProducer_
edm::EDGetTokenT< reco::TrackCaloClusterPtrAssociation > inOutTrackSCAssociationCollection_
std::vector< math::XYZPointF > find(const std::vector< reco::TransientTrack > &tracks, const edm::Handle< edm::View< reco::CaloCluster > > &bcHandle)
std::string likelihoodWeights_
double getTowerESum(const reco::Candidate *cand, const std::vector< CaloTowerDetId > *detIdToExclude=0) const
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
std::string ConvertedPhotonCollection_
edm::ESHandle< MagneticField > theMF_
Conversion * clone() const
returns a clone of the candidate
double calculateLikelihood(reco::ConversionRef conversion)
edm::EDGetTokenT< edm::View< reco::CaloCluster > > bcBarrelCollection_
edm::EDGetTokenT< edm::View< reco::CaloCluster > > scHybridBarrelProducer_
T const * product() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
void produce(edm::Event &evt, const edm::EventSetup &es) override
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
void setMVAout(const float &mva)
set the value of the TMVA output
ProductID id() const
Accessor for product ID.
ConvertedPhotonProducer(const edm::ParameterSet &ps)
void clear()
Clear the PtrVector.
~ConvertedPhotonProducer() override
math::XYZPointF toFConverterP(const math::XYZPoint &val)
std::vector< reco::CaloClusterPtr > matchingBC() const
std::map< std::vector< reco::TransientTrack >, reco::CaloClusterPtr, CompareTwoTracksVectors > run(const std::vector< reco::TransientTrack > &outIn, const edm::Handle< reco::TrackCollection > &outInTrkHandle, const edm::Handle< reco::TrackCaloClusterPtrAssociation > &outInTrackSCAssH, const std::vector< reco::TransientTrack > &inOut, const edm::Handle< reco::TrackCollection > &inOutTrkHandle, const edm::Handle< reco::TrackCaloClusterPtrAssociation > &inOutTrackSCAssH)
ConversionLikelihoodCalculator * theLikelihoodCalc_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
bool recoverOneTrackCase_
void getCircleCenter(const reco::TrackRef &tk, double r, double &x0, double &y0)