CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/RecoEgamma/EgammaPhotonProducers/interface/ConversionProducer.h

Go to the documentation of this file.
00001 #ifndef RecoEgamma_EgammaPhotonProducers_ConversionProducer_h
00002 #define RecoEgamma_EgammaPhotonProducers_ConversionProducer_h
00003 
00012 // user include files
00013 #include "FWCore/Framework/interface/Frameworkfwd.h"
00014 #include "FWCore/Framework/interface/EDProducer.h"
00015 
00016 #include "FWCore/Framework/interface/Event.h"
00017 #include "FWCore/Framework/interface/MakerMacros.h"
00018 
00019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00020 #include "FWCore/Framework/interface/ESHandle.h"
00021 
00022 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00023 
00024 //ECAL clusters
00025 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00026 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00027 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00028 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00029 #include "DataFormats/CaloRecHit/interface/CaloCluster.h"
00030 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00031 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00032 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00033 #include "DataFormats/GeometrySurface/interface/BoundCylinder.h"
00034 #include "DataFormats/GeometrySurface/interface/BoundDisk.h"
00035 #include "DataFormats/GeometrySurface/interface/SimpleCylinderBounds.h"
00036 #include "DataFormats/GeometrySurface/interface/SimpleDiskBounds.h"
00037 
00038 #include "DataFormats/GeometrySurface/interface/ReferenceCounted.h"
00039 #include "RecoVertex/VertexPrimitives/interface/VertexState.h"
00040 #include "DataFormats/VertexReco/interface/Vertex.h"
00041 #include "RecoVertex/KinematicFitPrimitives/interface/KinematicVertex.h"
00042 #include "RecoVertex/KinematicFitPrimitives/interface/KinematicParticle.h"
00043 #include "RecoVertex/KinematicFitPrimitives/interface/KinematicTree.h"
00044 #include "RecoVertex/KinematicFitPrimitives/interface/TransientTrackKinematicParticle.h"
00045 #include "RecoVertex/KinematicFit/interface/KinematicParticleVertexFitter.h"
00046 
00047 
00048 //Tracker tracks
00049 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00050 #include "DataFormats/TrackReco/interface/Track.h"
00051 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
00052 
00053 
00054 //photon data format
00055 #include "DataFormats/EgammaCandidates/interface/Photon.h"
00056 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
00057 #include "DataFormats/EgammaCandidates/interface/Conversion.h"
00058 #include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
00059 #include "DataFormats/EgammaTrackReco/interface/ConversionTrackFwd.h"
00060 
00061 #include "MagneticField/Engine/interface/MagneticField.h"
00062 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00063 
00064 class TransientTrackBuilder;
00065 class ConversionVertexFinder;
00066 
00067 class ConversionProducer : public edm::EDProducer {
00068     public:
00069       explicit ConversionProducer(const edm::ParameterSet&);
00070       ~ConversionProducer();
00071 
00072 
00073 
00074 
00075    private:
00076 
00077       virtual void produce(edm::Event&, const edm::EventSetup&);
00078 
00079       void buildSuperAndBasicClusterGeoMap(const edm::Event&,  
00080                                            std::multimap<double, reco::CaloClusterPtr>& basicClusterPtrs,
00081                                            std::multimap<double, reco::CaloClusterPtr>& superClusterPtrs);
00082 
00083 
00084       // ----------member data ---------------------------
00085       std::string algoName_;
00086 
00087       typedef math::XYZPointF Point;
00088       typedef std::vector<Point> PointCollection;
00089 
00090       edm::InputTag src_; 
00091 
00092       edm::InputTag scBarrelProducer_;
00093       edm::InputTag scEndcapProducer_;
00094       edm::InputTag bcBarrelCollection_;
00095       edm::InputTag bcEndcapCollection_;
00096       std::string ConvertedPhotonCollection_;
00097 
00098       bool allowD0_, allowDeltaPhi_, allowTrackBC_, allowDeltaCot_, allowMinApproach_, allowOppCharge_, allowVertex_;
00099 
00100       bool bypassPreselGsf_, bypassPreselEcal_, bypassPreselEcalEcal_;
00101       
00102       bool usePvtx_;//if use primary vertices
00103       std::string vertexProducer_;
00104       ConversionVertexFinder*         theVertexFinder_;
00105 
00106       const TransientTrackBuilder *thettbuilder_;
00107 
00108       double deltaEta_;
00109       
00110       double halfWayEta_, halfWayPhi_;//halfway open angle to search in basic clusters
00111       unsigned int  maxNumOfTrackInPU_;
00112       double  maxTrackZ_;
00113       double  maxTrackRho_;
00114       double minSCEt_;
00115       double dEtacutForSCmatching_;
00116       double dPhicutForSCmatching_;
00117       double energyBC_;//1.5GeV for track BC selection
00118       double energyTotalBC_;//5GeV for track pair BC selection
00119       double d0Cut_;//0 for d0*charge cut
00120       double dzCut_;//innerposition of z diff cut
00121       double dEtaTkBC_, dPhiTkBC_;//0.06 0.6 for track and BC matching
00122 
00123       double maxChi2Left_, maxChi2Right_;//5. 5. for track chi2 quality
00124       double minHitsLeft_, minHitsRight_;//5 2 for track hits quality 
00125 
00126       double deltaCotTheta_, deltaPhi_, minApproachLow_, minApproachHigh_;//0.02 0.2 for track pair open angle and > -0.1 cm
00127 
00128 
00129       double r_cut;//cross_r cut
00130       double vtxChi2_;//vertex chi2 probablity cut
00131 
00132       bool allowSingleLeg_;//if single track conversion ?
00133       bool rightBC_;//if right leg requires matching BC?
00134 
00135 
00136       void buildCollection( edm::Event& iEvent, const edm::EventSetup& iSetup,
00137                             const std::multimap<float, edm::Ptr<reco::ConversionTrack> >& allTracks,
00138               const std::multimap<double, reco::CaloClusterPtr>& superClusterPtrs,
00139               const std::multimap<double, reco::CaloClusterPtr>& basicClusterPtrs,
00140               const reco::Vertex& the_pvtx,
00141               reco::ConversionCollection & outputConvPhotonCollection);
00142 
00143   
00144       //track quality cut, returns pass or no
00145       inline bool trackQualityFilter(const  edm::RefToBase<reco::Track>&  ref, bool isLeft);
00146       inline bool trackD0Cut(const edm::RefToBase<reco::Track>& ref);
00147       inline bool trackD0Cut(const edm::RefToBase<reco::Track>& ref, const reco::Vertex& the_pvtx);
00148 
00149       //track impact point at ECAL wall, returns validity to access position ew
00150       bool getTrackImpactPosition(const reco::Track* tk_ref, 
00151               const TrackerGeometry* trackerGeom, const MagneticField* magField, 
00152               math::XYZPointF& ew);
00153 
00154       //distance at min approaching point, returns distance
00155       //      double getMinApproach(const edm::RefToBase<reco::Track>& ll, const edm::RefToBase<reco::Track>& rr, 
00156       //              const MagneticField* magField);
00157 
00158       bool preselectTrackPair(const reco::TransientTrack &ttk_l, const reco::TransientTrack &ttk_r,
00159               double& appDist);
00160               
00161       //cut-based selection, TODO remove global cut variables
00162       bool checkTrackPair(const std::pair<edm::RefToBase<reco::Track>, reco::CaloClusterPtr>& ll,
00163               const std::pair<edm::RefToBase<reco::Track>, reco::CaloClusterPtr>& rr);
00164 
00165       //kinematic vertex fitting, return true for valid vertex
00166       bool checkVertex(const reco::TransientTrack &ttk_l, const reco::TransientTrack &ttk_r,
00167               const MagneticField* magField,
00168               reco::Vertex& the_vertex);
00169       bool checkPhi(const edm::RefToBase<reco::Track>& tk_l, const edm::RefToBase<reco::Track>& tk_r,
00170               const TrackerGeometry* trackerGeom, const MagneticField* magField,
00171               const reco::Vertex& the_vertex);
00172 
00173       //check the closest BC, returns true for found a BC
00174       bool getMatchedBC(const std::multimap<double, reco::CaloClusterPtr>& bcMap, 
00175               const math::XYZPointF& trackImpactPosition,
00176               reco::CaloClusterPtr& closestBC);
00177 
00178       // finds the super cluster matching with at least one track in the pair
00179       bool matchingSC(const std::multimap<double, reco::CaloClusterPtr>& scMap, 
00180                       reco::Conversion& conv,
00181                       reco::CaloClusterPtrVector& mSC);
00182 
00183      
00184 
00185       double etaTransformation(  float EtaParticle , float Zvertex);
00186 
00187 
00188       math::XYZPointF toFConverterP( const math::XYZPoint &val) {
00189         return math::XYZPointF(val.x(),val.y(),val.z());
00190       }
00191       
00192       math::XYZVectorF toFConverterV( const math::XYZVector &val) {
00193         return math::XYZVectorF(val.x(),val.y(),val.z());
00194       }
00195 
00196 
00197 };
00198 
00199 
00200 inline const GeomDet * recHitDet( const TrackingRecHit & hit, const TrackingGeometry * geom ) {
00201     return geom->idToDet( hit.geographicalId() );
00202 }
00203 
00204 inline const BoundPlane & recHitSurface( const TrackingRecHit & hit, const TrackingGeometry * geom ) {
00205     return recHitDet( hit, geom )->surface();
00206 }
00207 
00208 inline LocalVector toLocal( const reco::Track::Vector & v, const Surface & s ) {
00209     return s.toLocal( GlobalVector( v.x(), v.y(), v.z() ) );
00210 }
00211 
00212 #endif