CMS 3D CMS Logo

PFV0Producer.cc

Go to the documentation of this file.
00001 #include <memory>
00002 #include "RecoParticleFlow/PFTracking/interface/PFV0Producer.h"
00003 #include "DataFormats/ParticleFlowReco/interface/PFV0.h"
00004 #include "DataFormats/ParticleFlowReco/interface/PFRecTrackFwd.h"
00005 #include "DataFormats/ParticleFlowReco/interface/PFV0Fwd.h"
00006 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
00007 using namespace std;
00008 using namespace edm;
00009 using namespace reco;
00010 PFV0Producer::PFV0Producer(const ParameterSet& iConfig):
00011   conf_(iConfig)
00012 {
00013 
00014   produces<reco::PFV0Collection>();
00015 }
00016 
00017 PFV0Producer::~PFV0Producer()
00018 {
00019 }
00020 
00021 void
00022 PFV0Producer::produce(Event& iEvent, const EventSetup& iSetup)
00023 {
00024   LogDebug("PFV0Producer")<<"START event: "<<iEvent.id().event()
00025                           <<" in run "<<iEvent.id().run();
00026   //create the empty collections 
00027   auto_ptr< PFV0Collection > 
00028     pfV0Coll (new PFV0Collection);
00029   
00030   Handle< PFRecTrackCollection > recTracks;
00031   iEvent.getByLabel(conf_.getParameter<InputTag>("PFTrackColl"), recTracks);
00032   
00033   
00034   vector<InputTag> V0list=conf_.getParameter< vector < InputTag > >("V0List");
00035   for (uint il=0; il<V0list.size(); il++){
00036     Handle<VertexCompositeCandidateCollection> V0coll;
00037     iEvent.getByLabel(V0list[il],V0coll);
00038      LogDebug("PFV0Producer")<<V0list[il]<<" contains "<<V0coll->size()<<" V0 candidates ";
00039     for (uint iv=0;iv<V0coll->size();iv++){
00040       VertexCompositeCandidateRef V0(V0coll, iv);
00041       vector<TrackRef> Tracks;
00042       vector<PFRecTrackRef> PFTracks;
00043       for( uint ndx = 0; ndx < V0->numberOfDaughters(); ndx++ ) {
00044         
00045         Tracks.push_back( (dynamic_cast<const RecoChargedCandidate*>(V0->daughter(ndx)))->track() );
00046         for (uint ipt=0;ipt<recTracks->size();ipt++){
00047           PFRecTrackRef pft(recTracks,ipt);
00048           if((dynamic_cast<const RecoChargedCandidate*>(V0->daughter(ndx)))->track()==pft->trackRef())
00049             PFTracks.push_back(pft);
00050           
00051         }
00052       }
00053       if ((PFTracks.size()==2)&&(Tracks.size()==2)){
00054         pfV0Coll->push_back(PFV0(V0,PFTracks,Tracks));
00055       }
00056         
00057       
00058 
00059     }
00060   }
00061   
00062   
00063   iEvent.put(pfV0Coll);
00064 }
00065 
00066 // ------------ method called once each job just before starting event loop  ------------
00067 void 
00068 PFV0Producer::beginJob(const EventSetup& iSetup)
00069 {
00070 }
00071 
00072 // ------------ method called once each job just after ending the event loop  ------------
00073 void 
00074 PFV0Producer::endJob() {
00075 }

Generated on Tue Jun 9 17:44:50 2009 for CMSSW by  doxygen 1.5.4