00001 #include "VZeroProducer.h"
00002
00003 #include "RecoVZero/VZeroFinding/interface/VZeroFinder.h"
00004
00005 #include "FWCore/Framework/interface/MakerMacros.h"
00006 #include "FWCore/Framework/interface/ESHandle.h"
00007 #include "FWCore/Framework/interface/Frameworkfwd.h"
00008 #include "FWCore/ServiceRegistry/interface/Service.h"
00009
00010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00012
00013 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00014
00015
00016 VZeroProducer::VZeroProducer(const edm::ParameterSet& pset)
00017 : pset_(pset)
00018 {
00019 edm::LogInfo("VZeroProducer") << " constructor";
00020 produces<reco::VZeroCollection>();
00021
00022
00023 minImpactPositiveDaughter =
00024 pset.getParameter<double>("minImpactPositiveDaughter");
00025 minImpactNegativeDaughter =
00026 pset.getParameter<double>("minImpactNegativeDaughter");
00027 }
00028
00029
00030 VZeroProducer::~VZeroProducer()
00031 {
00032 edm::LogInfo("VZeroProducer") << " destructor";
00033 }
00034
00035
00036 void VZeroProducer::produce(edm::Event& ev, const edm::EventSetup& es)
00037 {
00038
00039 edm::Handle<reco::TrackCollection> trackCollection;
00040 ev.getByLabel("allTracks", trackCollection);
00041 const reco::TrackCollection tracks = *(trackCollection.product());
00042
00043
00044 edm::Handle<reco::VertexCollection> vertexCollection;
00045 ev.getByLabel("pixelVertices", vertexCollection);
00046 const reco::VertexCollection* vertices = vertexCollection.product();
00047
00048
00049 VZeroFinder theFinder(es,pset_);
00050
00051
00052 reco::TrackRefVector positives;
00053 reco::TrackRefVector negatives;
00054
00055 for(unsigned int i=0; i<tracks.size(); i++)
00056 {
00057 if(tracks[i].charge() > 0 &&
00058 fabs(tracks[i].d0()) > minImpactPositiveDaughter)
00059 positives.push_back(reco::TrackRef(trackCollection, i));
00060
00061 if(tracks[i].charge() < 0 &&
00062 fabs(tracks[i].d0()) > minImpactNegativeDaughter)
00063 negatives.push_back(reco::TrackRef(trackCollection, i));
00064 }
00065
00066 LogTrace("MinBiasTracking") << "[VZeroProducer] using tracks :"
00067 << " +" << positives.size()
00068 << " -" << negatives.size();
00069
00070 std::auto_ptr<reco::VZeroCollection> result(new reco::VZeroCollection);
00071
00072
00073 if(positives.size() > 0 && negatives.size() > 0)
00074 for(reco::track_iterator ipos = positives.begin();
00075 ipos!= positives.end(); ipos++)
00076 for(reco::track_iterator ineg = negatives.begin();
00077 ineg!= negatives.end(); ineg++)
00078 {
00079 reco::VZeroData data;
00080
00081 if(theFinder.checkTrackPair(**ipos,**ineg, vertices, data) == true)
00082 {
00083
00084 reco::Vertex vertex(reco::Vertex::Point(data.crossingPoint.x(),
00085 data.crossingPoint.y(),
00086 data.crossingPoint.z()),
00087 reco::Vertex::Error(), 0.,0.,0);
00088
00089
00090 vertex.add(reco::TrackBaseRef(*ipos));
00091 vertex.add(reco::TrackBaseRef(*ineg));
00092
00093
00094 result->push_back(reco::VZero(vertex,data));
00095 }
00096 }
00097
00098 LogTrace("MinBiasTracking")
00099 << "[VZeroProducer] found candidates : " << result->size();
00100
00101
00102 ev.put(result);
00103 }
00104