48 theTrackPairFinder_(0),
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());
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 (
unsigned i = 0;
i < scHandle->size(); ++
i ) {
347 if (aClus->energy()/cosh(aClus->eta()) <=
minSCEt_)
continue;
357 std::vector<edm::Ref<reco::TrackCollection> > trackPairRef;
358 std::vector<math::XYZPointF> trackInnPos;
359 std::vector<math::XYZVectorF> trackPin;
360 std::vector<math::XYZVectorF> trackPout;
361 float minAppDist=-99;
375 if ( allPairs.size() ) {
380 for ( std::map<std::vector<reco::TransientTrack>,
reco::CaloClusterPtr>::const_iterator iPair= allPairs.begin(); iPair!= allPairs.end(); ++iPair ) {
385 if ( !( aClus == caloPtr ) )
continue;
390 std::vector<math::XYZPointF> trkPositionAtEcal = theEcalImpactPositionFinder.
find( iPair->first, bcHandle );
391 std::vector<reco::CaloClusterPtr> matchingBC = theEcalImpactPositionFinder.
matchingBC();
396 if ( (iPair->first).size() > 1 ) {
405 edm::LogWarning(metname) <<
"cms::Exception caught in ConvertedPhotonProducer::produce\n"
430 trackPairRef.clear();
436 for ( std::vector<reco::TransientTrack>::const_iterator iTk=(iPair->first).begin(); iTk!= (iPair->first).
end(); ++iTk) {
444 trackInnPos.push_back(
toFConverterP(myTkRef->innerPosition()));
445 trackPin.push_back(
toFConverterV( myTkRef->innerMomentum()));
446 trackPout.push_back(
toFConverterV(myTkRef->outerMomentum()));
448 trackPairRef.push_back(myTkRef);
456 if( theConversionVertex.
isValid() ) {
467 reco::Conversion newCandidate(scPtrVec, trackPairRef, trkPositionAtEcal, theConversionVertex, matchingBC, minAppDist, trackInnPos, trackPin, trackPout, like, algo);
472 outputConvPhotonCollection.push_back(newCandidate);
484 trackPairRef.clear();
488 std::vector<reco::TransientTrack>::const_iterator iTk=(iPair->first).
begin();
493 trackInnPos.push_back(
toFConverterP(myTk->innerPosition()));
497 trackPairRef.push_back(myTk);
501 float theta1 = myTk->innerMomentum().Theta();
503 float dCotTheta=-999.;
505 std::vector<reco::TransientTrack>::const_iterator iGoodGenTran;
506 for ( std::vector<reco::TransientTrack>::const_iterator iTran= t_generalTrk.begin(); iTran != t_generalTrk.end(); ++iTran) {
509 if ( trRef->charge()*myTk->charge() > 0 )
continue;
510 float dEta = trRef->eta() - myTk->eta();
511 float dPhi = trRef->phi() - myTk->phi();
513 float theta2 = trRef->innerMomentum().Theta();
514 dCotTheta = 1./
tan(theta1) - 1./
tan(theta2) ;
516 if ( fabs(dCotTheta) < dCot ) {
517 dCot = fabs(dCotTheta);
529 trackInnPos.push_back(
toFConverterP(goodRef->innerPosition()));
530 trackPin.push_back(
toFConverterV(goodRef->innerMomentum()));
531 trackPout.push_back(
toFConverterV(goodRef->outerMomentum()));
532 trackPairRef.push_back( goodRef );
535 std::vector<reco::TransientTrack> mypair;
536 mypair.push_back(*iTk);
537 mypair.push_back(*iGoodGenTran);
545 edm::LogWarning(metname) <<
"cms::Exception caught in ConvertedPhotonProducer::produce\n"
555 reco::Conversion newCandidate(scPtrVec, trackPairRef, trkPositionAtEcal, theConversionVertex, matchingBC, minAppDist, trackInnPos, trackPin, trackPout, like, algo);
558 outputConvPhotonCollection.push_back(newCandidate);
590 for(
unsigned int lSC=0; lSC < scHandle->size(); lSC++) {
596 if (aClus->energy()/cosh(aClus->eta()) <=
minSCEt_)
continue;
599 if ( conversionHandle.
isValid() ) {
602 std::vector<reco::ConversionRef> bestRef=
solveAmbiguity( conversionHandle , aClus);
604 for ( std::vector<reco::ConversionRef>::iterator iRef=bestRef.begin(); iRef!=bestRef.end(); iRef++ ) {
605 if ( iRef->isNonnull() ) {
606 newCandidate= (*iRef)->
clone();
607 outputConversionCollection.push_back(*newCandidate);
615 for(
unsigned int icp = 0; icp < conversionHandle->size(); icp++) {
617 if (!( aClus.
id() == cpRef->caloCluster()[0].
id() && aClus.
key() == cpRef->caloCluster()[0].
key() ))
continue;
618 if ( !cpRef->isConverted() )
continue;
619 if ( cpRef->nTracks() <2 )
continue;
620 newCandidate= (&(*cpRef))->
clone();
621 outputConversionCollection.push_back(*newCandidate);
638 std::multimap<double, reco::ConversionRef, std::greater<double> > convMap;
640 for (
unsigned int icp=0; icp< conversionHandle->size(); icp++) {
644 if (!( scRef.
id() == cpRef->caloCluster()[0].
id() && scRef.
key() == cpRef->caloCluster()[0].
key() ))
continue;
645 if ( !cpRef->isConverted() )
continue;
646 double like = cpRef->MVAout();
647 if ( cpRef->nTracks() <2 )
continue;
649 convMap.insert ( std::make_pair(like,cpRef) );
655 std::multimap<double, reco::ConversionRef>::iterator iMap;
656 std::vector<reco::ConversionRef> bestRefs;
657 for (iMap=convMap.begin(); iMap!=convMap.end(); iMap++) {
659 bestRefs.push_back( iMap->second );
676 double x1, x2, y1, y2;
677 double xx_1 = track1->innerPosition().x(), yy_1 = track1->innerPosition().y(), zz_1 = track1->innerPosition().z();
678 double xx_2 = track2->innerPosition().x(), yy_2 = track2->innerPosition().y(), zz_2 = track2->innerPosition().z();
679 double radius1 = track1->innerMomentum().Rho()/(.3*(
theMF_->inTesla(
GlobalPoint(xx_1, yy_1, zz_1)).z()))*100;
680 double radius2 = track2->innerMomentum().Rho()/(.3*(
theMF_->inTesla(
GlobalPoint(xx_2, yy_2, zz_2)).z()))*100;
683 dist =
sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) - radius1 - radius2;
692 x1 = tk->innerPosition().x();
693 y1 = tk->innerPosition().y();
694 phi = tk->innerMomentum().phi();
695 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_
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_
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)
double dPhi(double phi1, double phi2)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
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
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 void beginRun(edm::Run const &, const edm::EventSetup &es) overridefinal
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
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)
virtual void produce(edm::Event &evt, const edm::EventSetup &es)
void clear()
Clear the PtrVector.
virtual ~ConvertedPhotonProducer()
std::vector< reco::ConversionRef > solveAmbiguity(const edm::OrphanHandle< reco::ConversionCollection > &conversionHandle, reco::CaloClusterPtr &sc)
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)