Go to the documentation of this file.00001 #include <iostream>
00002 #include <vector>
00003 #include <memory>
00004 #include "RecoEgamma/EgammaPhotonAlgos/interface/ConversionTrackEcalImpactPoint.h"
00005
00006
00007
00008
00009
00010 #include <vector>
00011 #include <map>
00012
00013 ReferenceCountingPointer<BoundCylinder> ConversionTrackEcalImpactPoint::theBarrel_ = 0;
00014 ReferenceCountingPointer<BoundDisk> ConversionTrackEcalImpactPoint::theNegativeEtaEndcap_ = 0;
00015 ReferenceCountingPointer<BoundDisk> ConversionTrackEcalImpactPoint::thePositiveEtaEndcap_ = 0;
00016 bool ConversionTrackEcalImpactPoint::theInit_ = false;
00017
00018
00019 ConversionTrackEcalImpactPoint::ConversionTrackEcalImpactPoint(const MagneticField* field ):
00020
00021 theMF_(field)
00022 {
00023
00024 forwardPropagator_ = new PropagatorWithMaterial ( dir_ = alongMomentum, 0.000511, theMF_ );
00025
00026 }
00027
00028 ConversionTrackEcalImpactPoint::~ConversionTrackEcalImpactPoint() {
00029
00030 delete forwardPropagator_ ;
00031
00032 }
00033
00034 std::vector<math::XYZPointF> ConversionTrackEcalImpactPoint::find( const std::vector<reco::TransientTrack>& tracks, const edm::Handle<edm::View<reco::CaloCluster> >& bcHandle ) {
00035
00036
00037 std::vector<math::XYZPointF> result;
00038
00039 matchingBC_.clear();
00040
00041 std::vector<reco::CaloClusterPtr> matchingBC(2);
00042
00043
00044
00045
00046
00047
00048 int iTrk=0;
00049 for ( std::vector<reco::TransientTrack>::const_iterator iTk=tracks.begin(); iTk!=tracks.end(); ++iTk) {
00050
00051 math::XYZPointF ecalImpactPosition(0.,0.,0.);
00052 const TrajectoryStateOnSurface myTSOS=(*iTk).innermostMeasurementState();
00053 if ( !( myTSOS.isValid() ) ) continue;
00054
00055 stateAtECAL_= forwardPropagator_->propagate( myTSOS, barrel() );
00056
00057
00058 if (!stateAtECAL_.isValid() || ( stateAtECAL_.isValid() && fabs(stateAtECAL_.globalPosition().eta() ) >1.479 ) ) {
00059
00060
00061 if ( (*iTk).innermostMeasurementState().globalPosition().eta() > 0.) {
00062 stateAtECAL_= forwardPropagator_->propagate( myTSOS, positiveEtaEndcap());
00063
00064 } else {
00065
00066 stateAtECAL_= forwardPropagator_->propagate( myTSOS, negativeEtaEndcap());
00067
00068 }
00069 }
00070
00071
00072 if ( stateAtECAL_.isValid() ) ecalImpactPosition = stateAtECAL_.globalPosition();
00073
00074
00075 result.push_back(ecalImpactPosition );
00076
00077
00078 if ( stateAtECAL_.isValid() ) {
00079 int goodBC=0;
00080 float bcDistanceToTrack=9999;
00081 reco::CaloClusterPtr matchedBCItr;
00082 int ibc=0;
00083 goodBC=0;
00084
00085 for (unsigned i = 0; i < bcHandle->size(); ++i ) {
00086 float dEta= bcHandle->ptrAt(i)->position().eta() - ecalImpactPosition.eta() ;
00087 float dPhi= bcHandle->ptrAt(i)->position().phi() - ecalImpactPosition.phi() ;
00088 if ( sqrt(dEta*dEta + dPhi*dPhi) < bcDistanceToTrack ) {
00089 goodBC=ibc;
00090 bcDistanceToTrack=sqrt(dEta*dEta + dPhi*dPhi);
00091 }
00092 ibc++;
00093
00094 }
00095
00096 matchingBC[iTrk]=bcHandle->ptrAt(goodBC);
00097 }
00098
00099
00100 iTrk++;
00101 }
00102
00103 matchingBC_=matchingBC;
00104
00105 return result;
00106
00107 }
00108
00109
00110
00111
00112 void ConversionTrackEcalImpactPoint::initialize() {
00113
00114 const float epsilon = 0.001;
00115 Surface::RotationType rot;
00116
00117
00118 theBarrel_ = new BoundCylinder( Surface::PositionType(0,0,0), rot,
00119 SimpleCylinderBounds( barrelRadius()-epsilon,
00120 barrelRadius()+epsilon,
00121 -barrelHalfLength(),
00122 barrelHalfLength()));
00123 theNegativeEtaEndcap_ =
00124 new BoundDisk( Surface::PositionType( 0, 0, -endcapZ()), rot,
00125 SimpleDiskBounds( 0, endcapRadius(), -epsilon, epsilon));
00126
00127 thePositiveEtaEndcap_ =
00128 new BoundDisk( Surface::PositionType( 0, 0, endcapZ()), rot,
00129 SimpleDiskBounds( 0, endcapRadius(), -epsilon, epsilon));
00130
00131 theInit_ = true;
00132
00133
00134 }