00001 00002 // Includes 00004 #include "FWCore/Framework/interface/EDProducer.h" 00005 #include "FWCore/Framework/interface/Event.h" 00006 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00007 #include "FWCore/Utilities/interface/InputTag.h" 00008 #include "DataFormats/Candidate/interface/CompositeCandidate.h" 00009 00010 #include "DataFormats/Common/interface/View.h" 00011 00012 #include <memory> 00013 #include <vector> 00014 #include <sstream> 00015 00016 //#include "Validation/RecoTau/interface/prettyPrint.h" debugging putpose 00017 00019 // class definition 00021 class CollectionFromZLegProducer : public edm::EDProducer 00022 { 00023 public: 00024 // construction/destruction 00025 CollectionFromZLegProducer(const edm::ParameterSet& iConfig); 00026 virtual ~CollectionFromZLegProducer(); 00027 00028 void produce(edm::Event& iEvent,const edm::EventSetup& iSetup); 00029 void endJob(); 00030 00031 private: 00032 // member data 00033 edm::InputTag srcTheZ_ ; 00034 std::string OutputCollection_ ; 00035 00036 }; 00037 00038 00039 00041 // construction/destruction 00043 00044 //______________________________________________________________________________ 00045 CollectionFromZLegProducer::CollectionFromZLegProducer(const edm::ParameterSet& iConfig) 00046 : srcTheZ_(iConfig.getParameter<edm::InputTag>("ZCandidateCollection")) 00047 { 00048 produces<std::vector<reco::CompositeCandidate> >("theTagLeg" ); 00049 produces<std::vector<reco::CompositeCandidate> >("theProbeLeg"); 00050 } 00051 00052 00053 //______________________________________________________________________________ 00054 CollectionFromZLegProducer::~CollectionFromZLegProducer() 00055 { 00056 } 00057 00059 // implementation of member functions 00061 00062 //______________________________________________________________________________ 00063 void CollectionFromZLegProducer::produce(edm::Event& iEvent,const edm::EventSetup& iSetup) 00064 { 00065 std::auto_ptr<std::vector<reco::CompositeCandidate> > theTagLeg(new std::vector<reco::CompositeCandidate>) ; 00066 std::auto_ptr<std::vector<reco::CompositeCandidate> > theProbeLeg(new std::vector<reco::CompositeCandidate>) ; 00067 00068 edm::Handle< std::vector<reco::CompositeCandidate> > theZHandle; 00069 iEvent.getByLabel(srcTheZ_,theZHandle); 00070 00071 // this is specific for our 'tag and probe' 00072 00073 for (std::vector<reco::CompositeCandidate>::const_iterator Zit = theZHandle->begin() ; 00074 Zit != theZHandle->end() ; 00075 ++Zit ) 00076 { 00077 int c = 0; 00078 00079 for(reco::CompositeCandidate::const_iterator Daug =(*Zit).begin(); 00080 Daug!=(*Zit).end() ; 00081 ++Daug ) 00082 { 00083 if (c == 0){ 00084 reco::CompositeCandidate candT(*Daug) ; 00085 theTagLeg->push_back(candT) ; 00086 } 00087 if (c == 1){ 00088 reco::CompositeCandidate candP(*Daug) ; 00089 theProbeLeg->push_back(candP) ; 00090 } 00091 c++ ; 00092 } 00093 } 00094 iEvent.put(theTagLeg , "theTagLeg" ) ; 00095 iEvent.put(theProbeLeg, "theProbeLeg" ) ; 00096 } 00097 00098 void CollectionFromZLegProducer::endJob() 00099 { 00100 } 00101 00102 #include "FWCore/Framework/interface/MakerMacros.h" 00103 DEFINE_FWK_MODULE(CollectionFromZLegProducer);