129 : conversionOITrackProducer_{consumes(
config.getParameter<
std::string>(
"conversionOITrackProducer"))},
130 conversionIOTrackProducer_{consumes(
config.getParameter<
std::string>(
"conversionIOTrackProducer"))},
131 outInTrackSCAssociationCollection_{consumes({
config.getParameter<
std::string>(
"conversionOITrackProducer"),
133 inOutTrackSCAssociationCollection_{consumes({
config.getParameter<
std::string>(
"conversionIOTrackProducer"),
137 convertedPhotonCollectionPutToken_{
138 produces<reco::ConversionCollection>(
config.getParameter<
std::string>(
"convertedPhotonCollection"))},
139 cleanedConvertedPhotonCollectionPutToken_{
140 produces<reco::ConversionCollection>(
config.getParameter<
std::string>(
"cleanedConvertedPhotonCollection"))},
144 scHybridBarrelProducer_{consumes(
config.getParameter<
edm::InputTag>(
"scHybridBarrelProducer"))},
145 scIslandEndcapProducer_{consumes(
config.getParameter<
edm::InputTag>(
"scIslandEndcapProducer"))},
153 hOverEConeSize_{
config.getParameter<
double>(
"hOverEConeSize")},
154 maxHOverE_{
config.getParameter<
double>(
"maxHOverE")},
155 minSCEt_{
config.getParameter<
double>(
"minSCEt")},
156 recoverOneTrackCase_{
config.getParameter<
bool>(
"recoverOneTrackCase")},
157 dRForConversionRecovery_{
config.getParameter<
double>(
"dRForConversionRecovery")},
158 deltaCotCut_{
config.getParameter<
double>(
"deltaCotCut")},
159 minApproachDisCut_{
config.getParameter<
double>(
"minApproachDisCut")},
161 maxNumOfCandidates_{
config.getParameter<
int>(
"maxNumOfCandidates")},
162 risolveAmbiguity_{
config.getParameter<
bool>(
"risolveConversionAmbiguity")},
167 cutsFromDB_ =
config.getParameter<
bool>(
"usePFThresholdsFromDB");
169 hcalCutsToken_ = esConsumes<HcalPFCuts, HcalPFCutsRcd>(
edm::ESInputTag(
"",
"withTopo"));
186 hcalHelper_ = std::make_unique<ElectronHcalHelper>(cfgCone, consumesCollector());
208 bool validBarrelSCHandle =
true;
210 if (!scBarrelHandle.isValid()) {
211 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the scHybridBarrelProducer";
212 validBarrelSCHandle =
false;
216 bool validEndcapSCHandle =
true;
219 if (!scEndcapHandle.
isValid()) {
220 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the scIslandEndcapProducer";
221 validEndcapSCHandle =
false;
225 bool validTrackInputs =
true;
227 if (!outInTrkHandle.isValid()) {
229 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the conversionOITrack " 231 validTrackInputs =
false;
237 if (!outInTrkSCAssocHandle.isValid()) {
239 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the outInTrackSCAssociationCollection)";
240 validTrackInputs =
false;
245 if (!inOutTrkHandle.isValid()) {
247 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the conversionIOTrack " 249 validTrackInputs =
false;
258 if (!generalTrkHandle.
isValid()) {
260 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the genralTracks " 267 if (!inOutTrkSCAssocHandle.isValid()) {
269 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the inOutTrackSCAssociationCollection_.c_str()";
270 validTrackInputs =
false;
276 if (!bcBarrelHandle.
isValid()) {
277 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the bcBarrelCollection";
283 if (!bcEndcapHandle.
isValid()) {
284 edm::LogError(
"ConvertedPhotonProducer") <<
"Error! Can't get the bcEndcapCollection";
287 if (validTrackInputs) {
295 t_outInTrk, outInTrkHandle, outInTrkSCAssocHandle, t_inOutTrk, inOutTrkHandle, inOutTrkSCAssocHandle);
306 outputConvPhotonCollection);
313 outputConvPhotonCollection);
321 if (validBarrelSCHandle)
323 if (validEndcapSCHandle)
344 std::vector<reco::TransientTrack> t_generalTrk;
350 for (
auto const& aClus : scHandle->ptrs()) {
352 if (aClus->energy() / cosh(aClus->eta()) <=
minSCEt_)
361 std::vector<edm::Ref<reco::TrackCollection>> trackPairRef;
362 std::vector<math::XYZPointF> trackInnPos;
363 std::vector<math::XYZVectorF> trackPin;
364 std::vector<math::XYZVectorF> trackPout;
365 float minAppDist = -99;
376 if (!allPairs.empty()) {
377 for (
auto iPair = allPairs.begin(); iPair != allPairs.end(); ++iPair) {
382 if (!(aClus == caloPtr))
387 std::vector<math::XYZPointF> trkPositionAtEcal = theEcalImpactPositionFinder.
find(iPair->first, bcHandle);
388 std::vector<reco::CaloClusterPtr> matchingBC = theEcalImpactPositionFinder.
matchingBC();
392 if ((iPair->first).size() > 1) {
415 trackPairRef.clear();
420 for (std::vector<reco::TransientTrack>::const_iterator iTk = (iPair->first).begin();
421 iTk != (iPair->first).
end();
430 trackInnPos.push_back(
toFConverterP(myTkRef->innerPosition()));
432 trackPout.push_back(
toFConverterV(myTkRef->outerMomentum()));
434 trackPairRef.push_back(myTkRef);
441 if (theConversionVertex.
isValid()) {
463 outputConvPhotonCollection.push_back(newCandidate);
471 trackPairRef.clear();
475 std::vector<reco::TransientTrack>::const_iterator iTk = (iPair->first).begin();
484 trackPairRef.push_back(myTk);
488 float theta1 = myTk->innerMomentum().Theta();
490 float dCotTheta = -999.;
492 for (
auto const& tran : t_generalTrk) {
495 if (trRef->charge() * myTk->charge() > 0)
497 float dEta = trRef->eta() - myTk->eta();
498 float dPhi = trRef->phi() - myTk->phi();
501 float theta2 = trRef->innerMomentum().Theta();
502 dCotTheta = 1. /
tan(theta1) - 1. /
tan(theta2);
504 if (fabs(dCotTheta) < dCot) {
505 dCot = fabs(dCotTheta);
515 trackInnPos.push_back(
toFConverterP(goodRef->innerPosition()));
517 trackPout.push_back(
toFConverterV(goodRef->outerMomentum()));
518 trackPairRef.push_back(goodRef);
534 const double like = -999.;
535 outputConvPhotonCollection.emplace_back(scPtrVec,
546 auto& newCandidate = outputConvPhotonCollection.back();
559 for (
auto const& aClus : scHandle->ptrs()) {
561 if (aClus->energy() / cosh(aClus->eta()) <=
minSCEt_)
568 for (std::vector<reco::ConversionRef>::iterator iRef = bestRef.begin(); iRef != bestRef.end(); iRef++) {
569 if (iRef->isNonnull()) {
570 newCandidate = (*iRef)->
clone();
571 outputConversionCollection.push_back(*newCandidate);
579 if (!(aClus.id() == cpRef->caloCluster()[0].
id() && aClus.key() == cpRef->caloCluster()[0].
key()))
581 if (!cpRef->isConverted())
583 if (cpRef->nTracks() < 2)
585 newCandidate = (&(*cpRef))->
clone();
586 outputConversionCollection.push_back(*newCandidate);
597 std::multimap<double, reco::ConversionRef, std::greater<double>> convMap;
603 if (!(scRef.
id() == cpRef->caloCluster()[0].
id() && scRef.
key() == cpRef->caloCluster()[0].key()))
605 if (!cpRef->isConverted())
607 double like = cpRef->MVAout();
608 if (cpRef->nTracks() < 2)
611 convMap.emplace(like, cpRef);
616 std::vector<reco::ConversionRef> bestRefs;
617 for (
auto iMap = convMap.begin(); iMap != convMap.end(); iMap++) {
619 bestRefs.push_back(iMap->second);
630 double xx_1 = track1->innerPosition().x(), yy_1 = track1->innerPosition().y(), zz_1 = track1->innerPosition().z();
631 double xx_2 = track2->innerPosition().x(), yy_2 = track2->innerPosition().y(), zz_2 = track2->innerPosition().z();
644 x1 = tk->innerPosition().x();
645 y1 = tk->innerPosition().y();
646 phi = tk->innerMomentum().phi();
647 const int charge = tk->charge();
edm::EDPutTokenT< reco::ConversionCollection > cleanedConvertedPhotonCollectionPutToken_
edm::ESGetToken< HcalPFCuts, HcalPFCutsRcd > hcalCutsToken_
HcalPFCuts const * hcalCuts_
edm::EDGetTokenT< reco::TrackCaloClusterPtrAssociation > outInTrackSCAssociationCollection_
edm::EDGetTokenT< edm::View< reco::CaloCluster > > bcEndcapCollection_
TransientVertex run(const std::vector< reco::TransientTrack > &pair)
ProductID id() const
Accessor for product ID.
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
ProductID id() const
Accessor for product ID.
std::string fullPath() const
edm::EDPutTokenT< reco::ConversionCollection > convertedPhotonCollectionPutToken_
const std::string metname
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
void push_back(Ptr< T > const &iPtr)
edm::EDGetTokenT< reco::TrackCollection > conversionIOTrackProducer_
Sin< T >::type sin(const T &t)
Global3DPoint GlobalPoint
edm::EDGetTokenT< edm::View< reco::CaloCluster > > scIslandEndcapProducer_
static ConversionAlgorithm algoByName(const std::string &name)
bool isNonnull() const
Checks for non-null.
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::unique_ptr< ElectronHcalHelper > hcalHelper_
edm::Ptr< CaloCluster > CaloClusterPtr
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
edm::EDGetTokenT< HBHERecHitCollection > hbheRecHits_
Log< level::Error, false > LogError
MagneticField const * magneticField_
edm::EDGetTokenT< HBHERecHitCollection > hbheRecHits
key_type key() const
Accessor for product key.
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
std::vector< reco::CaloClusterPtr > matchingBC() const
double minApproachDisCut_
reco::TransientTrack build(const reco::Track *p) const
edm::EDGetTokenT< reco::TrackCollection > generalTrackProducer_
math::XYZVectorF toFConverterV(const math::XYZVector &val)
void buildCollections(edm::EventSetup const &es, const edm::Handle< edm::View< reco::CaloCluster >> &scHandle, const edm::Handle< edm::View< reco::CaloCluster >> &bcHandle, ElectronHcalHelper const &hcalHelper, const edm::Handle< reco::TrackCollection > &trkHandle, std::map< std::vector< reco::TransientTrack >, reco::CaloClusterPtr, CompareTwoTracksVectors > &allPairs, reco::ConversionCollection &outputConvPhotonCollection)
Cos< T >::type cos(const T &t)
Conversion * clone() const
returns a clone of the candidate
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_
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > transientTrackToken_
float calculateMinApproachDistance(const reco::TrackRef &track1, const reco::TrackRef &track2)
edm::EDGetTokenT< reco::TrackCollection > conversionOITrackProducer_
#define DEFINE_FWK_MODULE(type)
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_
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
ConversionLikelihoodCalculator likelihoodCalc_
double calculateLikelihood(reco::ConversionRef conversion)
edm::EDGetTokenT< edm::View< reco::CaloCluster > > bcBarrelCollection_
edm::EDGetTokenT< edm::View< reco::CaloCluster > > scHybridBarrelProducer_
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&... args)
puts a new product
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
void produce(edm::Event &evt, const edm::EventSetup &es) override
ConversionVertexFinder vertexFinder_
void cleanCollections(const edm::Handle< edm::View< reco::CaloCluster >> &scHandle, const edm::OrphanHandle< reco::ConversionCollection > &conversionHandle, reco::ConversionCollection &outputCollection)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
void setMVAout(const float &mva)
set the value of the TMVA output
ConvertedPhotonProducer(const edm::ParameterSet &ps)
ConversionTrackPairFinder trackPairFinder_
TransientTrackBuilder const * transientTrackBuilder_
void clear()
Clear the PtrVector.
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
EgammaHcalIsolation::arrayHB eThresHB
math::XYZPointF toFConverterP(const math::XYZPoint &val)
EgammaHcalIsolation::arrayHE eThresHE
Log< level::Warning, false > LogWarning
double hcalESum(const reco::SuperCluster &, int depth, const HcalPFCuts *hcalCuts) const
std::array< double, 4 > arrayHB
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)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > mFToken_
bool isValid() const
Tells whether the vertex is valid.
bool recoverOneTrackCase_
std::array< double, 7 > arrayHE
void getCircleCenter(const reco::TrackRef &tk, double r, double &x0, double &y0)