CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/RecoTauTag/InvariantMass/src/InvariantMass.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    InvariantMass
00004 // Class:      InvariantMass
00005 // 
00013 //
00014 // Original Author:  Suchandra Dutta
00015 //      Created:  Thu Oct 19 09:02:32 CEST 2006
00016 // $Id: InvariantMass.cc,v 1.13 2009/03/02 18:52:28 friis Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 #include <string>
00024 #include <utility>
00025 #include <boost/regex.hpp>
00026 
00027 // user include files
00028 #include "FWCore/Framework/interface/Frameworkfwd.h"
00029 #include "FWCore/Framework/interface/Event.h"
00030 #include "FWCore/Framework/interface/EventSetup.h"
00031 #include "FWCore/Framework/interface/MakerMacros.h"
00032 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00033 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00034 
00035 #include "DataFormats/Common/interface/Handle.h"
00036 #include "DataFormats/VertexReco/interface/Vertex.h"
00037 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00038 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00039 #include "DataFormats/TrackReco/interface/Track.h"
00040 #include "DataFormats/BTauReco/interface/JetTag.h"
00041 #include "DataFormats/BTauReco/interface/IsolatedTauTagInfo.h"
00042 
00043 #include "RecoTauTag/InvariantMass/interface/InvariantMass.h"
00044 
00045 using namespace std;
00046 
00047 //
00048 // constructors and destructor
00049 //
00050 InvariantMass::InvariantMass(const edm::ParameterSet& iConfig)
00051 {
00052   jetTrackSrc = iConfig.getParameter<string>("JetTrackSrc");
00053   m_ecalBClSrc = iConfig.getParameter<string>("ecalbcl");
00054 
00055   m_algo = new InvariantMassAlgorithm(iConfig);
00056   
00057   produces<reco::JetTagCollection>();
00058   produces<reco::TauMassTagInfoCollection>();
00059 }
00060 
00061 
00062 InvariantMass::~InvariantMass()
00063 {
00064   delete m_algo;
00065 }
00066 
00067 //
00068 // member functions
00069 //
00070 // ------------ method called to produce the data  ------------
00071 void
00072 InvariantMass::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00073 {
00074    using namespace edm;
00075    using namespace reco;
00076 
00077    Handle<IsolatedTauTagInfoCollection> isolatedTaus;
00078    iEvent.getByLabel(jetTrackSrc, isolatedTaus);
00079    
00080    std::auto_ptr<JetTagCollection>         tagCollection;
00081    std::auto_ptr<TauMassTagInfoCollection> extCollection( new TauMassTagInfoCollection() );
00082 
00083    // Island basic cluster collection
00084    Handle<BasicClusterCollection> barrelBasicClusterHandle;
00085    iEvent.getByLabel(m_ecalBClSrc, "islandBarrelBasicClusters", barrelBasicClusterHandle);
00086 
00087    Handle<BasicClusterCollection> endcapBasicClusterHandle;
00088    iEvent.getByLabel(m_ecalBClSrc, "islandEndcapBasicClusters", endcapBasicClusterHandle);
00089 
00090    if (isolatedTaus->empty()) {
00091      tagCollection.reset( new JetTagCollection() );
00092    } else {
00093      RefToBaseProd<reco::Jet> prod( isolatedTaus->begin()->jet() );
00094      tagCollection.reset( new JetTagCollection(RefToBaseProd<reco::Jet>(prod)) );
00095 
00096      for (unsigned int i = 0; i < isolatedTaus->size(); ++i)
00097      {
00098        IsolatedTauTagInfoRef tauRef(isolatedTaus, i);
00099        const Jet & jet = *(tauRef->jet()); 
00100        math::XYZVector jetDir(jet.px(),jet.py(),jet.pz());  
00101        pair<double,TauMassTagInfo> jetTauPair;
00102        if (jetDir.eta() < 1.2)      // barrel  
00103          jetTauPair = m_algo->tag(iEvent, iSetup, tauRef, barrelBasicClusterHandle);
00104        else                         // endcap
00105          jetTauPair = m_algo->tag(iEvent, iSetup, tauRef, endcapBasicClusterHandle);
00106        tagCollection->setValue( i, jetTauPair.first );
00107        extCollection->push_back( jetTauPair.second );
00108      }
00109    }
00110 
00111    iEvent.put( tagCollection );
00112    iEvent.put( extCollection );
00113 }
00114 
00115 #include "FWCore/PluginManager/interface/ModuleDef.h"
00116 #include "FWCore/Framework/interface/MakerMacros.h"
00117 DEFINE_FWK_MODULE(InvariantMass);