807 const float BARL = 1.4442;
809 const float END_HI = 2.5;
818 LogInfo(
"TkConvValidator") <<
"TkConvValidator Analyzing event number: " << e.
id() <<
" Global Counter " <<
nEvt_ <<
"\n";
836 edm::LogError(
"ConversionsProducer") <<
"Error! Can't get the collection "<< std::endl;
845 edm::LogError(
"PhotonProducer") <<
"Error! Can't get the Photon collection "<< std::endl;
855 edm::LogError(
"TrackerOnlyConversionProducer") <<
"Error! Can't get the product primary Vertex Collection "<<
"\n";
857 vertexCollection = *(vertexHandle.
product());
860 bool valid_pvtx =
false;
861 if (!vertexCollection.empty()){
862 the_pvtx = *(vertexCollection.begin());
873 <<
"Error! Can't get the product primary Vertex Collection "<<
"\n";
907 const std::vector<SimTrack> &theSimTracks= *SimTk;
908 const std::vector<SimVertex> &theSimVertices= *SimVtx;
927 std::map<const reco::Track*,TrackingParticleRef> myAss;
928 std::map<const reco::Track*,TrackingParticleRef>::const_iterator itAss;
930 for ( std::vector<PhotonMCTruth>::const_iterator mcPho=mcPhotons.begin(); mcPho !=mcPhotons.end(); mcPho++) {
933 float mcPhi= (*mcPho).fourMomentum().phi();
935 mcEta_= (*mcPho).fourMomentum().pseudoRapidity();
944 if ( fabs(
mcEta_) > END_HI )
continue;
952 bool goodSimConversion=
false;
953 bool visibleConversion=
false;
954 bool visibleConversionsWithTwoSimTracks=
false;
955 if ( (*mcPho).isAConversion() == 1 ) {
965 if ( ( fabs(
mcEta_) <= BARL && mcConvR_ <85 ) ||
966 ( fabs(
mcEta_) > BARL && fabs(
mcEta_) <=END_HI && fabs( (*mcPho).vertex().z() ) < 210 ) ) visibleConversion=
true;
972 if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.0001 &&
973 fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.0001 &&
974 fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.0001) {
980 if (
theConvTP_.
size() == 2 ) visibleConversionsWithTwoSimTracks=
true;
981 goodSimConversion=
false;
983 if ( visibleConversion && visibleConversionsWithTwoSimTracks ) goodSimConversion=
true;
984 if ( goodSimConversion ) {
1002 if ( ! (visibleConversion && visibleConversionsWithTwoSimTracks ) )
continue;
1005 if ( fabs(
mcEta_) <=1.) {
1018 bool recomatch =
false;
1019 float chi2Prob = 0.;
1022 for (reco::ConversionCollection::const_iterator
conv = convHandle->begin();
conv!=convHandle->end();++
conv) {
1033 const std::vector<edm::RefToBase<reco::Track> >&
tracks = aConv.
tracks();
1038 if (tracks.size() !=2 || !(vtx.
isValid()))
continue;
1049 double lxy = (themom.x()*dbsx + themom.y()*dbsy)/themom.rho();
1069 bool isAssociated =
false;
1073 std::vector<std::pair<RefToBase<reco::Track>,
double> > trackV1, trackV2;
1075 int tp_1 = 0, tp_2 = 1;
1077 trackV1 = (std::vector<std::pair<RefToBase<reco::Track>,
double> >) q1[
theConvTP_[0]];
1079 trackV1 = (std::vector<std::pair<RefToBase<reco::Track>,
double> >) q1[
theConvTP_[1]];
1083 trackV2 = (std::vector<std::pair<RefToBase<reco::Track>,
double> >) q2[
theConvTP_[1]];
1085 trackV2 = (std::vector<std::pair<RefToBase<reco::Track>,
double> >) q2[
theConvTP_[0]];
1088 if (!(!trackV1.empty()&&!trackV2.empty()))
1090 if (tp_1 == tp_2)
continue;
1096 myAss.insert( std::make_pair (tr1.
get(),
theConvTP_[tp_1] ) );
1097 myAss.insert( std::make_pair (tr2.
get(),
theConvTP_[tp_2]) );
1105 isAssociated =
true;
1128 if ( chi2Prob > 0) {
1135 if ( chi2Prob > 0.0005) {
1150 for (reco::ConversionCollection::const_iterator
conv = convHandle->begin();
conv!=convHandle->end();++
conv) {
1160 std::vector<edm::RefToBase<reco::Track> > tracks = aConv.
tracks();
1164 if (tracks.size() !=2 || !(vtx.
isValid()))
continue;
1175 double lxy = (themom.x()*dbsx + themom.y()*dbsy)/themom.rho();
1179 bool phoIsInBarrel=
false;
1180 bool phoIsInEndcap=
false;
1199 if (
sqrt(p1AtVtx.perp2()) >
sqrt(p2AtVtx.perp2()) )
1200 dPhiTracksAtVtx = p1AtVtx.phi() - p2AtVtx.phi();
1202 dPhiTracksAtVtx = p2AtVtx.phi() - p1AtVtx.phi();
1208 if (fabs(refittedMom.eta())< 1.479 ) {
1217 double Mindeltaeta = 999999;
1218 double Mindeltaphi = 999999;
1219 bool matchConvSC=
false;
1220 reco::PhotonCollection::const_iterator iMatchingSC;
1221 for( reco::PhotonCollection::const_iterator iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
1225 double deltaeta =
abs( aPho.
superCluster()->position().eta() -ConvEta);
1226 if (
abs(deltaeta)<
abs(Mindeltaeta) &&
abs(deltaphi)<
abs(Mindeltaphi)) {
1227 Mindeltaphi=
abs(deltaphi);
1228 Mindeltaeta=
abs(deltaeta);
1229 iMatchingSC = iPho ;
1232 if (
abs(Mindeltaeta)<0.1 &&
abs(Mindeltaphi)<0.1) {
1246 int ilead = 0, itrail = 1;
1247 if (tk2->
pt() > tk1->
pt()) {
1284 if ( matchConvSC ) {
1305 if ( phoIsInBarrel ) {
1330 if ( matchConvSC ) {
1339 if ( phoIsInEndcap ) {
1355 if ( matchConvSC ) {
1371 for (
unsigned int i=0;
i<tracks.size();
i++) {
1374 d0 = - tracks[
i]->dxy(the_pvtx.
position());
1376 d0 = tracks[
i]->d0();
1396 bool associated =
false;
1400 for ( std::vector<PhotonMCTruth>::const_iterator mcPho=mcPhotons.begin(); mcPho !=mcPhotons.end(); mcPho++) {
1401 mcConvPt_= (*mcPho).fourMomentum().et();
1402 float mcPhi= (*mcPho).fourMomentum().phi();
1403 simPV_Z = (*mcPho).primaryVertex().z();
1405 mcEta_= (*mcPho).fourMomentum().pseudoRapidity();
1407 mcConvR_= (*mcPho).vertex().perp();
1413 if ( fabs(
mcEta_) > END_HI )
continue;
1419 if ( (*mcPho).isAConversion() != 1 )
continue;
1420 if (!( ( fabs(
mcEta_) <= BARL && mcConvR_ <85 ) ||
1421 ( fabs(
mcEta_) > BARL && fabs(
mcEta_) <=END_HI && fabs( (*mcPho).vertex().z() ) < 210 ) ) )
1427 if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.0001 &&
1428 fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.0001 &&
1429 fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.0001) {
1440 auto itP1 = p1.
find(tk1);
1441 auto itP2 = p2.
find(tk2);
1442 bool good = (itP1 != p1.
end()) and (not itP1->val.empty()) and (itP2 != p2.
end()) and (not itP2->val.empty());
1444 itP1 = p1.
find(tk2);
1445 itP2 = p2.
find(tk1);
1446 good = (itP1 != p1.
end()) and (not itP1->val.empty()) and (itP2 != p2.
end()) and (not itP2->val.empty());
1450 std::vector<std::pair<TrackingParticleRef, double> >
const& tp1 = itP1->val;
1451 std::vector<std::pair<TrackingParticleRef, double> >
const& tp2 = itP2->val;
1454 if (
abs(tpr1->pdgId())==11&&
abs(tpr2->pdgId())==11&& tpr1->pdgId()*tpr2->pdgId()<0) {
1455 if ( (tpr1->parentVertex()->sourceTracks_end()-tpr1->parentVertex()->sourceTracks_begin()==1) &&
1456 (tpr2->parentVertex()->sourceTracks_end()-tpr2->parentVertex()->sourceTracks_begin()==1)) {
1457 if (tpr1->parentVertex().
key()==tpr2->parentVertex().
key() && ((*tpr1->parentVertex()->sourceTracks_begin())->
pdgId()==22)) {
1458 mcConvR_ =
sqrt(tpr1->parentVertex()->position().Perp2());
1459 mcConvZ_ = tpr1->parentVertex()->position().z();
1460 mcConvX_ = tpr1->parentVertex()->position().x();
1461 mcConvY_ = tpr1->parentVertex()->position().y();
1462 mcConvEta_ = tpr1->parentVertex()->position().eta();
1463 mcConvPhi_ = tpr1->parentVertex()->position().phi();
1464 mcConvPt_ =
sqrt((*tpr1->parentVertex()->sourceTracks_begin())->momentum().Perp2());
1485 for ( std::vector<PhotonMCTruth>::const_iterator mcPho=mcPhotons.begin(); mcPho !=mcPhotons.end(); mcPho++) {
1486 mcConvPt_= (*mcPho).fourMomentum().et();
1487 float mcPhi= (*mcPho).fourMomentum().phi();
1488 simPV_Z = (*mcPho).primaryVertex().z();
1490 mcEta_= (*mcPho).fourMomentum().pseudoRapidity();
1492 mcConvR_= (*mcPho).vertex().perp();
1495 mcConvZ_= (*mcPho).vertex().z();
1498 if ( fabs(
mcEta_) > END_HI )
continue;
1504 if ( (*mcPho).isAConversion() != 1 )
continue;
1505 if (!( ( fabs(
mcEta_) <= BARL && mcConvR_ <85 ) ||
1506 ( fabs(
mcEta_) > BARL && fabs(
mcEta_) <=END_HI && fabs( (*mcPho).vertex().z() ) < 210 ) ) )
1512 if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.0001 &&
1513 fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.0001 &&
1514 fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.0001) {
1533 std::vector<std::pair<TrackingParticleRef, double> > tp1 = p1incl[tk1];
1534 std::vector<std::pair<TrackingParticleRef, double> > tp2 = p2incl[tk2];
1535 if (!(!tp1.empty()&&!tp2.empty())){
1539 if (!tp1.empty()&&!tp2.empty()) {
1542 if (
abs(tpr1->pdgId())==11&&
abs(tpr2->pdgId())==11 && tpr1->pdgId()*tpr2->pdgId()<0) {
1543 if ( ((tpr1->parentVertex()->sourceTracks_end()-tpr1->parentVertex()->sourceTracks_begin()>=1) && (*tpr1->parentVertex()->sourceTracks_begin())->
pdgId()==22) &&
1544 ((tpr2->parentVertex()->sourceTracks_end()-tpr2->parentVertex()->sourceTracks_begin()>=1) && (*tpr2->parentVertex()->sourceTracks_begin())->
pdgId()==22) ) {
1575 if ( associated ) match=1;
1604 if ( matchConvSC ) {
1617 if ( phoIsInBarrel ) {
1633 if ( matchConvSC ) {
1645 if ( phoIsInEndcap ) {
1661 if ( matchConvSC ) {
1704 if ( phoIsInBarrel ) {
1711 if ( phoIsInEndcap ) {
1723 for (
unsigned int i=0;
i<tracks.size();
i++) {
1726 itAss= myAss.find( tfrb.get() );
1740 d0 = - tracks[
i]->dxy(the_pvtx.
position());
1742 d0 = tracks[
i]->d0();
1750 if ( itAss == myAss.end() )
continue;
1753 float simPt =
sqrt( ((*itAss).second)->momentum().perp2() );
1755 float ptres= recPt - simPt ;
1762 if ( phoIsInBarrel ) {
1766 if ( phoIsInEndcap ) {
MonitorElement * h2_DPhiTracksAtVtxVsR_
MonitorElement * h2_dzPVVsR_
const reco::Vertex & conversionVertex() const
returns the reco conversion vertex
MonitorElement * h_maxDlClosestHitToVtx_[3][3]
MonitorElement * h_convPt_[3][3]
MonitorElement * p_convVtxdYVsY_
value_type const * get() const
T getParameter(std::string const &) const
MonitorElement * h2_DCotTracksVsR_
MonitorElement * h_convVtxdR_
MonitorElement * h2_DCotTracksVsEta_
MonitorElement * h_simConvVtxRvsZ_[4]
MonitorElement * h_convZplot_
MonitorElement * h_convSCdPhi_[3][3]
MonitorElement * h_SimConvTwoMTracksAndVtxPGT0_[5]
MonitorElement * h_SimConvTwoMTracksAndVtxPGT0005_[5]
MonitorElement * h_DCotTracks_[3][3]
const_iterator end() const
last iterator over the map (read only)
static HepMC::IO_HEPEVT conv
MonitorElement * nHitsVsEta_[3]
edm::EDGetTokenT< TrackingParticleRefVector > tpSelForFake_Token_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
MonitorElement * h_lxybs_[3][3]
edm::RefVector< TrackingParticleCollection > theConvTP_
MonitorElement * h_trailNHitsBeforeVtx_[3][3]
bool quality(ConversionQuality q) const
double y() const
y coordinate
math::XYZVector recalculateMomentumAtFittedVertex(const MagneticField &mf, const TrackerGeometry &trackerGeom, const edm::RefToBase< reco::Track > &tk, const reco::Vertex &vtx)
MonitorElement * p_Chi2VsR_[3]
bool isValid() const
Tells whether the vertex is valid.
MonitorElement * h_convVtxYvsX_zoom_[2]
edm::EDGetTokenT< reco::PhotonCollection > photonCollectionPr_Token_
MonitorElement * p_DCotTracksVsR_
MonitorElement * h_tkChi2_[3]
bool empty() const
return true if empty
const std::vector< Measurement1DFloat > & dlClosestHitToVtx() const
Vector of signed decay length with uncertainty from nearest hit on track to the conversion vtx positi...
MonitorElement * h_convVtxdX_
const_iterator find(const key_type &k) const
find element with specified reference key
MonitorElement * h_convPtRes_[3]
MonitorElement * h_convEtaMatchSC_[3][3]
double zOfPrimaryVertexFromTracks(const math::XYZPoint &myBeamSpot=math::XYZPoint()) const
double distOfMinimumApproach() const
MonitorElement * h2_Chi2VsEta_[3]
MonitorElement * h_SimRecConvTwoMTracks_[5]
double pairCotThetaSeparation() const
Delta cot(Theta) where Theta is the angle in the (y,z) plane between the two tracks. Original tracks are used.
MonitorElement * h_vtxChi2Prob_[3][3]
std::vector< Vertex > VertexCollection
collection of Vertex objects
MonitorElement * h_convVtxdX_endcap_
MonitorElement * h_convVtxdR_endcap_
edm::EDGetTokenT< reco::VertexCollection > offline_pvToken_
key_type key() const
Accessor for product key.
MonitorElement * h_zPVFromTracks_[2]
MonitorElement * h_convVtxdY_barrel_
MonitorElement * h_tkChi2Large_[3]
edm::ParameterSet parameters_
edm::EDGetTokenT< edm::SimTrackContainer > g4_simTk_Token_
MonitorElement * p_DCotTracksVsEta_
edm::EDGetTokenT< edm::SimVertexContainer > g4_simVtx_Token_
const_iterator end() const
Termination of iteration.
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
const std::vector< Track > & refittedTracks() const
Returns the container of refitted tracks.
MonitorElement * h_maxDlClosestHitToVtxSig_[3][3]
MonitorElement * h_convVtxdR_barrel_
MonitorElement * h_leadExpectedHitsInner_[3][3]
double pairInvariantMass() const
if nTracks=2 returns the pair invariant mass. Original tracks are used here
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
const_iterator begin() const
Initialize an iterator over the RefVector.
MonitorElement * h_convSCdEta_[3][3]
MonitorElement * h_sumNHitsBeforeVtx_[3][3]
MonitorElement * h_dzPVFromTracks_[2]
TrackAlgorithm algo() const
MonitorElement * h_nConv_[3][3]
info per conversion
edm::ESHandle< CaloGeometry > theCaloGeom_
MonitorElement * h_convVtxdY_
MonitorElement * p_DPhiTracksAtVtxVsEta_
MonitorElement * h_deltaExpectedHitsInner_[3][3]
MonitorElement * h_convVtxdEta_
edm::EDGetTokenT< reco::BeamSpot > beamspotToken_
MonitorElement * h_convVtxYvsX_
MonitorElement * p_convVtxdZVsR_
edm::EDGetTokenT< TrackingParticleRefVector > tpSelForEff_Token_
MonitorElement * p_convVtxdRVsR_
MonitorElement * h_convR_[3][3]
float etaTransformation(float a, float b)
float phiNormalization(float &a)
MonitorElement * h_VisSimConv_[6]
MonitorElement * h2_photonPtRecVsPtSim_
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
MonitorElement * h_EoverPTracks_[3][3]
edm::ESHandle< MagneticField > theMF_
PhotonMCTruthFinder * thePhotonMCTruthFinder_
double pt() const
track transverse momentum
MonitorElement * h_leadNHitsBeforeVtx_[3][3]
edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > trackAssociator_Token_
edm::EDGetTokenT< reco::ConversionCollection > conversionCollectionPr_Token_
MonitorElement * h_distMinAppTracks_[3][3]
MonitorElement * p_DPhiTracksAtVtxVsR_
Abs< T >::type abs(const T &t)
MonitorElement * h_SimConvEtaPix_[2]
double chi2() const
chi-squares
MonitorElement * h_convVtxdX_barrel_
MonitorElement * p_nHitsVsEta_[3]
MonitorElement * h_simTkPt_
float ChiSquaredProbability(double chiSquared, double nrDOF)
MonitorElement * p_convVtxdXVsX_
MonitorElement * h_convVtxdY_endcap_
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
MonitorElement * h_convEta_[3][3]
MonitorElement * h_simConvVtxYvsX_
MonitorElement * h_convEta2_[3][3]
MonitorElement * h_nHitsBeforeVtx_[3]
MonitorElement * p2_convVtxdRVsRZ_
MonitorElement * p_Chi2VsEta_[3]
double deltaPhi(double phi1, double phi2)
double x() const
x coordinate
MonitorElement * h_convVtxdZ_
MonitorElement * h_convVtxRvsZ_[3]
uint8_t nSharedHits() const
number of shared hits btw the two track
MonitorElement * h2_DPhiTracksAtVtxVsEta_
MonitorElement * h_convPhi_[3][3]
T const * product() const
void clear()
Clear the vector.
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
reco::RecoToSimCollection associateRecoToSim(const edm::Handle< edm::View< reco::Track > > &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
compare reco to sim the handle of reco::Track and TrackingParticle collections
XYZVectorD XYZVector
spatial vector with cartesian internal representation
MonitorElement * h_convVtxdZ_barrel_
std::vector< Photon > PhotonCollection
collectin of Photon objects
MonitorElement * h2_convVtxRrecVsTrue_
MonitorElement * h_AllSimConv_[5]
Denominator for efficiencies.
MonitorElement * h_convRplot_
MonitorElement * p_nHitsVsR_[3]
double maxPhoEtaForPurity
MonitorElement * p_dzPVVsR_
MonitorElement * h2_Chi2VsR_[3]
int numberOfLostHits(HitCategory category) const
std::vector< PhotonMCTruth > find(const std::vector< SimTrack > &simTracks, const std::vector< SimVertex > &simVertices)
MonitorElement * h_convVtxdPhi_
MonitorElement * h_invMass_[3][3]
MonitorElement * h_convZ_[3][3]
MonitorElement * h_dlClosestHitToVtxSig_[3]
bool arbitratedEcalSeeded_
MonitorElement * h2_PtRecVsPtSim_[3]
MonitorElement * h_match_
double mcPhi_
global variable for the MC photon
MonitorElement * p_convVtxdZVsZ_
MonitorElement * h2_TkPtPull_[3]
void push_back(const RefToBase< T > &)
const std::vector< uint8_t > & nHitsBeforeVtx() const
Vector of the number of hits before the vertex along each track trajector.
MonitorElement * h_convVtxdZ_endcap_
MonitorElement * h2_convVtxdRVsR_
MonitorElement * h_DPhiTracksAtVtx_[3][3]
double y0() const
y coordinate
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
size_type size() const
Size of the RefVector.
MonitorElement * nHitsVsR_[3]
MonitorElement * h_simTkEta_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
MonitorElement * h_TkPtPull_[3]
MonitorElement * p2_convVtxdZVsRZ_
MonitorElement * h_SimConvTwoMTracks_[5]
reco::SimToRecoCollection associateSimToReco(const edm::Handle< edm::View< reco::Track > > &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
compare reco to sim the handle of reco::Track and TrackingParticle collections
MonitorElement * p_convVtxdRVsEta_
MonitorElement * h_dlClosestHitToVtx_[3]
MonitorElement * h_TkD0_[3]
MonitorElement * h2_convVtxdRVsEta_
T const * product() const
MonitorElement * h_nSharedHits_[3][3]
double dPhiTracksAtVtx() const
std::vector< edm::RefToBase< reco::Track > > const & tracks() const
vector of track to base references
MonitorElement * h_maxNHitsBeforeVtx_[3][3]
double x0() const
x coordinate