Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <memory>
00023
00024
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "RecoTauTag/ImpactParameter/interface/ImpactParameter.h"
00027
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/MakerMacros.h"
00030
00031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00032
00033 #include "DataFormats/BTauReco/interface/JetTag.h"
00034 #include "DataFormats/TrackReco/interface/Track.h"
00035 #include "DataFormats/VertexReco/interface/Vertex.h"
00036 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00037 #include "DataFormats/BTauReco/interface/IsolatedTauTagInfo.h"
00038
00039 #include "FWCore/Framework/interface/EventSetup.h"
00040 #include "FWCore/Framework/interface/ESHandle.h"
00041
00042 #include "TrackingTools/Records/interface/TransientTrackRecord.h"
00043
00044
00045
00046
00047 ImpactParameter::ImpactParameter(const edm::ParameterSet& iConfig) {
00048
00049 jetTrackSrc = iConfig.getParameter<std::string>("JetTagProd");
00050 vertexSrc = iConfig.getParameter<std::string>("vertexSrc");
00051 usingVertex = iConfig.getParameter<bool>("useVertex");
00052
00053 algo = new ImpactParameterAlgorithm(iConfig);
00054
00055 std::string modulname = iConfig.getParameter<std::string>( "@module_label" );
00056 produces<reco::JetTagCollection>().setBranchAlias(modulname);
00057 std::string infoBranchName = modulname + "Info";
00058 produces<reco::TauImpactParameterInfoCollection>().setBranchAlias(infoBranchName);
00059 }
00060
00061
00062 ImpactParameter::~ImpactParameter(){
00063 delete algo;
00064 }
00065
00066
00067
00068
00069
00070
00071
00072 void ImpactParameter::produce(edm::Event& iEvent, const edm::EventSetup& iSetup){
00073
00074 using namespace reco;
00075
00076 edm::Handle<IsolatedTauTagInfoCollection> isolatedTaus;
00077 iEvent.getByLabel(jetTrackSrc,isolatedTaus);
00078
00079 std::auto_ptr<JetTagCollection> tagCollection;
00080 std::auto_ptr<TauImpactParameterInfoCollection> extCollection( new TauImpactParameterInfoCollection() );
00081 if (not isolatedTaus->empty()) {
00082 edm::RefToBaseProd<reco::Jet> prod( isolatedTaus->begin()->jet() );
00083 tagCollection.reset( new JetTagCollection(prod) );
00084 } else {
00085 tagCollection.reset( new JetTagCollection() );
00086 }
00087
00088 edm::ESHandle<TransientTrackBuilder> builder;
00089 iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",builder);
00090 algo->setTransientTrackBuilder(builder.product());
00091
00092 Vertex PV;
00093 if (usingVertex) {
00094 edm::Handle<reco::VertexCollection> vertices;
00095 iEvent.getByLabel(vertexSrc,vertices);
00096
00097 const reco::VertexCollection vertCollection = *(vertices.product());
00098 reco::VertexCollection::const_iterator iVertex;
00099
00100 for(iVertex = vertCollection.begin();iVertex!=vertCollection.end();iVertex++){
00101 PV = *iVertex;
00102 }
00103
00104 } else {
00105 Vertex::Error e;
00106 e(0,0)=0;
00107 e(1,1)=0;
00108 e(2,2)=0;
00109 Vertex::Point p(0,0,0);
00110
00111 Vertex dummyPV(p,e,1,1,1);
00112 PV = dummyPV;
00113 }
00114
00115 for (unsigned int i = 0; i < isolatedTaus->size(); ++i) {
00116 IsolatedTauTagInfoRef tauRef(isolatedTaus, i);
00117 std::pair<float, TauImpactParameterInfo> ipInfo = algo->tag(tauRef,PV);
00118 tagCollection->setValue(i, ipInfo.first);
00119 extCollection->push_back(ipInfo.second);
00120 }
00121
00122 iEvent.put(extCollection);
00123 iEvent.put(tagCollection);
00124 }
00125
00126